MCPcopy Create free account
hub / github.com/adobe/react-spectrum / TimeField

Function TimeField

starters/hooks/src/TimeField.tsx:18–44  ·  view source on GitHub ↗
(props: TimeFieldProps)

Source from the content-addressed store, hash-verified

16}
17
18export function TimeField(props: TimeFieldProps) {
19 let {locale} = useLocale();
20 let state = useTimeFieldState({...props, locale});
21 let ref = useRef<HTMLDivElement>(null);
22 /*- begin highlight -*/
23 let {labelProps, fieldProps} = useTimeField(props, state, ref);
24 /*- end highlight -*/
25 let [isFocusWithin, setFocusWithin] = useState(false);
26 let {focusWithinProps} = useFocusWithin({onFocusWithinChange: setFocusWithin});
27
28 return (
29 <div className="react-aria-TimeField">
30 <label className="react-aria-Label" {...labelProps}>
31 {props.label}
32 </label>
33 <div
34 {...mergeProps(fieldProps, focusWithinProps)}
35 ref={ref}
36 className="react-aria-DateInput inset"
37 data-focus-within={isFocusWithin || undefined}>
38 {state.segments.map((segment, i) => (
39 <DateSegment key={i} segment={segment} state={state} />
40 ))}
41 </div>
42 </div>
43 );
44}
45
46function DateSegment({segment, state}: {segment: DateSegmentType; state: TimeFieldState}) {
47 let ref = useRef<HTMLSpanElement>(null);

Callers

nothing calls this directly

Calls 5

useLocaleFunction · 0.90
useTimeFieldStateFunction · 0.90
useFocusWithinFunction · 0.90
mergePropsFunction · 0.90
useTimeFieldFunction · 0.85

Tested by

no test coverage detected