@@ -18,6 +18,14 @@ import {
1818 TextInput ,
1919 type TextInputProps ,
2020} from "@mantine/core" ;
21+ import {
22+ DateInput ,
23+ type DateInputProps ,
24+ DateTimePicker ,
25+ type DateTimePickerProps ,
26+ TimeInput ,
27+ type TimeInputProps ,
28+ } from "@mantine/dates" ;
2129import type { ComponentType , ReactNode } from "react" ;
2230
2331export interface ControlProps {
@@ -35,6 +43,9 @@ export interface ControlProps {
3543 password ?: boolean | PasswordInputProps ;
3644 switch ?: boolean | SwitchProps ;
3745 segmented ?: boolean | Partial < SegmentedControlProps > ;
46+ date ?: boolean | DateInputProps ;
47+ datetime ?: boolean | DateTimePickerProps ;
48+ time ?: boolean | TimeInputProps ;
3849
3950 custom ?: ComponentType < CustomControlProps > ;
4051}
@@ -50,6 +61,9 @@ export interface ControlProps {
5061 * - PasswordInput
5162 * - Switch (for boolean types)
5263 * - SegmentedControl (for enum types)
64+ * - DateInput (for date format)
65+ * - DateTimePicker (for date-time format)
66+ * - TimeInput (for time format)
5367 * - Custom component
5468 *
5569 * Automatically handles labels, descriptions, error messages, and required state.
@@ -215,7 +229,7 @@ const Control = (props: ControlProps) => {
215229 // endregion
216230
217231 // region <PasswordInput/>
218- if ( props . password ) {
232+ if ( props . password || props . input . props . name ?. includes ( "password" ) ) {
219233 const passwordInputProps =
220234 typeof props . password === "object" ? props . password : { } ;
221235 return (
@@ -245,6 +259,92 @@ const Control = (props: ControlProps) => {
245259 }
246260 //endregion
247261
262+ // region <DateTimePicker/>
263+ if (
264+ props . datetime ||
265+ ( props . input . schema &&
266+ "type" in props . input . schema &&
267+ props . input . schema . type === "string" &&
268+ "format" in props . input . schema &&
269+ props . input . schema . format === "date-time" )
270+ ) {
271+ const dateTimePickerProps =
272+ typeof props . datetime === "object" ? props . datetime : { } ;
273+ return (
274+ < DateTimePicker
275+ { ...inputProps }
276+ id = { id }
277+ leftSection = { icon }
278+ defaultValue = {
279+ props . input . props . defaultValue
280+ ? new Date ( props . input . props . defaultValue )
281+ : undefined
282+ }
283+ onChange = { ( value ) => {
284+ props . input . set ( value ? new Date ( value ) . toISOString ( ) : undefined ) ;
285+ } }
286+ { ...dateTimePickerProps }
287+ />
288+ ) ;
289+ }
290+ //endregion
291+
292+ // region <DateInput/>
293+ if (
294+ props . date ||
295+ ( props . input . schema &&
296+ "type" in props . input . schema &&
297+ props . input . schema . type === "string" &&
298+ "format" in props . input . schema &&
299+ props . input . schema . format === "date" )
300+ ) {
301+ const dateInputProps = typeof props . date === "object" ? props . date : { } ;
302+ return (
303+ < DateInput
304+ { ...inputProps }
305+ id = { id }
306+ leftSection = { icon }
307+ defaultValue = {
308+ props . input . props . defaultValue
309+ ? new Date ( props . input . props . defaultValue )
310+ : undefined
311+ }
312+ onChange = { ( value ) => {
313+ props . input . set (
314+ value ? new Date ( value ) . toISOString ( ) . slice ( 0 , 10 ) : undefined ,
315+ ) ;
316+ } }
317+ { ...dateInputProps }
318+ />
319+ ) ;
320+ }
321+ //endregion
322+
323+ // region <TimeInput/>
324+ if (
325+ props . time ||
326+ ( props . input . schema &&
327+ "type" in props . input . schema &&
328+ props . input . schema . type === "string" &&
329+ "format" in props . input . schema &&
330+ props . input . schema . format === "time" )
331+ ) {
332+ const timeInputProps = typeof props . time === "object" ? props . time : { } ;
333+ return (
334+ < TimeInput
335+ { ...inputProps }
336+ id = { id }
337+ leftSection = { icon }
338+ defaultValue = { props . input . props . defaultValue }
339+ onChange = { ( event ) => {
340+ props . input . set ( event . currentTarget . value ) ;
341+ } }
342+ { ...timeInputProps }
343+ />
344+ ) ;
345+ }
346+ //endregion
347+
248348 // region <TextInput/>
249349 const textInputProps = typeof props . text === "object" ? props . text : { } ;
250350 return (
0 commit comments