mirror of
https://bitbucket.org/Mattrixwv/mattrixwvreactcomponents.git
synced 2025-12-06 21:53:57 -05:00
Temporal input components added
This commit is contained in:
26
lib/component/input/date/DateInput.tsx
Normal file
26
lib/component/input/date/DateInput.tsx
Normal file
@@ -0,0 +1,26 @@
|
||||
import type { DateInputProps } from "$/types/Input";
|
||||
import clsx from "clsx";
|
||||
import moment from "moment";
|
||||
|
||||
|
||||
export default function DateInput({
|
||||
id,
|
||||
className,
|
||||
defaultValue,
|
||||
value,
|
||||
onChange
|
||||
}: DateInputProps){
|
||||
return (
|
||||
<input
|
||||
type="date"
|
||||
id={id}
|
||||
className={clsx(
|
||||
"border rounded-lg px-2 py-1",
|
||||
className
|
||||
)}
|
||||
defaultValue={defaultValue ? moment(defaultValue).format("YYYY-MM-DD") : undefined}
|
||||
value={value ? moment(value).format("YYYY-MM-DD") : undefined}
|
||||
onChange={(e) => onChange?.(new Date(moment(e.target.value, "YYYY-MM-DD").toDate()))}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user