mirror of
https://bitbucket.org/Mattrixwv/mattrixwvreactcomponents.git
synced 2025-12-06 21:53:57 -05:00
27 lines
619 B
TypeScript
27 lines
619 B
TypeScript
import type { DateInputProps } from "$/types/Input";
|
|
import clsx from "clsx";
|
|
import moment from "moment";
|
|
|
|
|
|
export default function TimeInput({
|
|
id,
|
|
className,
|
|
defaultValue,
|
|
value,
|
|
onChange
|
|
}: DateInputProps){
|
|
return (
|
|
<input
|
|
type="time"
|
|
id={id}
|
|
className={clsx(
|
|
"border rounded-lg px-2 py-1 outline-none",
|
|
className
|
|
)}
|
|
defaultValue={defaultValue ? moment(defaultValue).format("YYYY-MM-DDTHH:mm") : undefined}
|
|
value={value ? moment(value).format("YYYY-MM-DDTHH:mm") : undefined}
|
|
onChange={(e) => onChange?.(new Date(moment(e.target.value, "YYYY-MM-DDTHH:mm").toDate()))}
|
|
/>
|
|
);
|
|
}
|