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

Function DateField

starters/hooks/src/DateField.tsx:30–56  ·  view source on GitHub ↗
(props: DateFieldProps)

Source from the content-addressed store, hash-verified

28}
29
30export function DateField(props: DateFieldProps) {
31 let {locale} = useLocale();
32 let state = useDateFieldState({...props, locale, createCalendar});
33 let ref = useRef<HTMLDivElement>(null);
34 /*- begin highlight -*/
35 let {labelProps, fieldProps} = useDateField(props, state, ref);
36 /*- end highlight -*/
37 let [isFocusWithin, setFocusWithin] = useState(false);
38 let {focusWithinProps} = useFocusWithin({onFocusWithinChange: setFocusWithin});
39
40 return (
41 <div className="react-aria-DateField">
42 <label className="react-aria-Label" {...labelProps}>
43 {props.label}
44 </label>
45 <div
46 {...mergeProps(fieldProps, focusWithinProps)}
47 ref={ref}
48 className="react-aria-DateInput inset"
49 data-focus-within={isFocusWithin || undefined}>
50 {state.segments.map((segment, i) => (
51 <DateSegment key={i} segment={segment} state={state} />
52 ))}
53 </div>
54 </div>
55 );
56}
57
58export function DateSegment({segment, state}: DateSegmentProps) {
59 let ref = useRef<HTMLSpanElement>(null);

Callers

nothing calls this directly

Calls 5

useLocaleFunction · 0.90
useDateFieldStateFunction · 0.90
useDateFieldFunction · 0.90
useFocusWithinFunction · 0.90
mergePropsFunction · 0.90

Tested by

no test coverage detected