@@ -15,6 +15,7 @@ interface InputDatetimeProps extends React.HTMLAttributes<HTMLDivElement> {
15
15
16
16
function InputDatetime ( props : InputDatetimeProps ) {
17
17
const elementId = React . useRef ( generateShortId ( ) ) ;
18
+ // eslint-disable-next-line react-compiler/react-compiler
18
19
const id = props . id ?? elementId . current ;
19
20
20
21
const [ date , setDate ] = React . useState < Date | undefined > (
@@ -62,42 +63,45 @@ function InputDatetime(props: InputDatetimeProps) {
62
63
className = "flex h-10 items-center justify-start gap-0.5 rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background duration-100 focus-within:border-input focus-within:outline-none focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 focus-within:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50"
63
64
{ ...getRootProps ( ) }
64
65
>
65
- { segments . map ( ( segment , idx ) => {
66
- if ( segment . type === "separator" ) {
66
+ {
67
+ // eslint-disable-next-line react-compiler/react-compiler
68
+ segments . map ( ( segment , idx ) => {
69
+ if ( segment . type === "separator" ) {
70
+ return (
71
+ < span
72
+ key = { `${ id } -separator-${ idx } ` }
73
+ className = "separator m-0 font-mono text-[60%] text-muted-foreground"
74
+ >
75
+ { segment . value }
76
+ </ span >
77
+ ) ;
78
+ }
79
+
80
+ const inputId = idx === 0 ? id : `${ id } -${ segment . type } ` ;
81
+ const placeholder =
82
+ segment . type !== "am/pm" ? segment . value : undefined ;
83
+
67
84
return (
68
- < span
69
- key = { `${ id } -separator-${ idx } ` }
70
- className = "separator m-0 font-mono text-[60%] text-muted-foreground"
71
- >
72
- { segment . value }
73
- </ span >
85
+ < input
86
+ key = { `${ id } -${ segment . type } -${ idx } ` }
87
+ id = { inputId }
88
+ placeholder = { placeholder }
89
+ disabled = { props . disabled }
90
+ readOnly = { props . readOnly }
91
+ onFocus = { props . onDateFocus }
92
+ onBlur = { props . onDateBlur }
93
+ className = "inline-block h-full flex-grow-0 rounded-sm border-none bg-transparent px-0.5 font-sans text-sm tabular-nums text-foreground caret-transparent outline-none ring-0 selection:bg-foreground selection:text-background placeholder:font-mono focus:bg-foreground focus:text-background focus:ring-0"
94
+ style = {
95
+ {
96
+ "--char-length" : `${ segment . type === "years" ? 4 : segment . type === "am/pm" ? 2.5 : 2 } ch` ,
97
+ minWidth : "calc(var(--char-length) + 0.25rem)" ,
98
+ } as React . CSSProperties
99
+ }
100
+ { ...getInputProps ( segment . type ) }
101
+ />
74
102
) ;
75
- }
76
-
77
- const inputId = idx === 0 ? id : `${ id } -${ segment . type } ` ;
78
- const placeholder =
79
- segment . type !== "am/pm" ? segment . value : undefined ;
80
-
81
- return (
82
- < input
83
- key = { `${ id } -${ segment . type } -${ idx } ` }
84
- id = { inputId }
85
- placeholder = { placeholder }
86
- disabled = { props . disabled }
87
- readOnly = { props . readOnly }
88
- onFocus = { props . onDateFocus }
89
- onBlur = { props . onDateBlur }
90
- className = "inline-block h-full flex-grow-0 rounded-sm border-none bg-transparent px-0.5 font-sans text-sm tabular-nums text-foreground caret-transparent outline-none ring-0 selection:bg-foreground selection:text-background placeholder:font-mono focus:bg-foreground focus:text-background focus:ring-0"
91
- style = {
92
- {
93
- "--char-length" : `${ segment . type === "years" ? 4 : segment . type === "am/pm" ? 2.5 : 2 } ch` ,
94
- minWidth : "calc(var(--char-length) + 0.25rem)" ,
95
- } as React . CSSProperties
96
- }
97
- { ...getInputProps ( segment . type ) }
98
- />
99
- ) ;
100
- } ) }
103
+ } )
104
+ }
101
105
</ div >
102
106
) ;
103
107
}
0 commit comments