@cdx-ui/primitives 0.0.1-beta.140 → 0.0.1-beta.142
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/calendar/CalendarGrid.js +33 -0
- package/lib/commonjs/calendar/CalendarGrid.js.map +1 -0
- package/lib/commonjs/calendar/CalendarRoot.js +95 -0
- package/lib/commonjs/calendar/CalendarRoot.js.map +1 -0
- package/lib/commonjs/calendar/context.js +17 -0
- package/lib/commonjs/calendar/context.js.map +1 -0
- package/lib/commonjs/calendar/index.js +27 -0
- package/lib/commonjs/calendar/index.js.map +1 -0
- package/lib/commonjs/calendar/types.js +6 -0
- package/lib/commonjs/calendar/types.js.map +1 -0
- package/lib/commonjs/checkbox/CheckboxRoot.web.js +91 -28
- package/lib/commonjs/checkbox/CheckboxRoot.web.js.map +1 -1
- package/lib/commonjs/checkbox/useCheckboxRoot.js +33 -19
- package/lib/commonjs/checkbox/useCheckboxRoot.js.map +1 -1
- package/lib/commonjs/date-field/DateFieldHiddenInput.js +148 -0
- package/lib/commonjs/date-field/DateFieldHiddenInput.js.map +1 -0
- package/lib/commonjs/date-field/DateFieldInput.js +122 -0
- package/lib/commonjs/date-field/DateFieldInput.js.map +1 -0
- package/lib/commonjs/date-field/DateFieldRoot.js +85 -0
- package/lib/commonjs/date-field/DateFieldRoot.js.map +1 -0
- package/lib/commonjs/date-field/DateFieldSegment.js +92 -0
- package/lib/commonjs/date-field/DateFieldSegment.js.map +1 -0
- package/lib/commonjs/date-field/context.js +19 -0
- package/lib/commonjs/date-field/context.js.map +1 -0
- package/lib/commonjs/date-field/index.js +34 -0
- package/lib/commonjs/date-field/index.js.map +1 -0
- package/lib/commonjs/date-field/segmentIndex.js +23 -0
- package/lib/commonjs/date-field/segmentIndex.js.map +1 -0
- package/lib/commonjs/date-field/segmentKeyboard.js +169 -0
- package/lib/commonjs/date-field/segmentKeyboard.js.map +1 -0
- package/lib/commonjs/date-field/types.js +6 -0
- package/lib/commonjs/date-field/types.js.map +1 -0
- package/lib/commonjs/date-field/useDateFieldSegmentState.js +381 -0
- package/lib/commonjs/date-field/useDateFieldSegmentState.js.map +1 -0
- package/lib/commonjs/date-field/useRangeDateFieldBridge.js +67 -0
- package/lib/commonjs/date-field/useRangeDateFieldBridge.js.map +1 -0
- package/lib/commonjs/date-picker/DatePickerRoot.js +123 -0
- package/lib/commonjs/date-picker/DatePickerRoot.js.map +1 -0
- package/lib/commonjs/date-picker/context.js +17 -0
- package/lib/commonjs/date-picker/context.js.map +1 -0
- package/lib/commonjs/date-picker/index.js +26 -0
- package/lib/commonjs/date-picker/index.js.map +1 -0
- package/lib/commonjs/date-range-picker/DateRangePickerRoot.js +144 -0
- package/lib/commonjs/date-range-picker/DateRangePickerRoot.js.map +1 -0
- package/lib/commonjs/date-range-picker/context.js +23 -0
- package/lib/commonjs/date-range-picker/context.js.map +1 -0
- package/lib/commonjs/date-range-picker/index.js +26 -0
- package/lib/commonjs/date-range-picker/index.js.map +1 -0
- package/lib/commonjs/date-time-field/DateTimeFieldHiddenInput.js +150 -0
- package/lib/commonjs/date-time-field/DateTimeFieldHiddenInput.js.map +1 -0
- package/lib/commonjs/date-time-field/DateTimeFieldInput.js +104 -0
- package/lib/commonjs/date-time-field/DateTimeFieldInput.js.map +1 -0
- package/lib/commonjs/date-time-field/DateTimeFieldRoot.js +159 -0
- package/lib/commonjs/date-time-field/DateTimeFieldRoot.js.map +1 -0
- package/lib/commonjs/date-time-field/DateTimeFieldSegment.js +87 -0
- package/lib/commonjs/date-time-field/DateTimeFieldSegment.js.map +1 -0
- package/lib/commonjs/date-time-field/context.js +17 -0
- package/lib/commonjs/date-time-field/context.js.map +1 -0
- package/lib/commonjs/date-time-field/index.js +40 -0
- package/lib/commonjs/date-time-field/index.js.map +1 -0
- package/lib/commonjs/date-time-field/useDateTimeFieldSegmentState.js +564 -0
- package/lib/commonjs/date-time-field/useDateTimeFieldSegmentState.js.map +1 -0
- package/lib/commonjs/date-time-list/DateTimeListRoot.js +418 -0
- package/lib/commonjs/date-time-list/DateTimeListRoot.js.map +1 -0
- package/lib/commonjs/date-time-list/context.js +26 -0
- package/lib/commonjs/date-time-list/context.js.map +1 -0
- package/lib/commonjs/date-time-list/index.js +62 -0
- package/lib/commonjs/date-time-list/index.js.map +1 -0
- package/lib/commonjs/date-time-picker/DateTimePickerRoot.js +134 -0
- package/lib/commonjs/date-time-picker/DateTimePickerRoot.js.map +1 -0
- package/lib/commonjs/date-time-picker/context.js +17 -0
- package/lib/commonjs/date-time-picker/context.js.map +1 -0
- package/lib/commonjs/date-time-picker/index.js +26 -0
- package/lib/commonjs/date-time-picker/index.js.map +1 -0
- package/lib/commonjs/dialog/DialogRoot.js +1 -1
- package/lib/commonjs/dialog/DialogRoot.js.map +1 -1
- package/lib/commonjs/index.js +148 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/month-calendar/MonthCalendarCell.js +64 -0
- package/lib/commonjs/month-calendar/MonthCalendarCell.js.map +1 -0
- package/lib/commonjs/month-calendar/MonthCalendarRoot.js +103 -0
- package/lib/commonjs/month-calendar/MonthCalendarRoot.js.map +1 -0
- package/lib/commonjs/month-calendar/MonthCalendarYearCell.js +63 -0
- package/lib/commonjs/month-calendar/MonthCalendarYearCell.js.map +1 -0
- package/lib/commonjs/month-calendar/context.js +17 -0
- package/lib/commonjs/month-calendar/context.js.map +1 -0
- package/lib/commonjs/month-calendar/index.js +34 -0
- package/lib/commonjs/month-calendar/index.js.map +1 -0
- package/lib/commonjs/month-picker/MonthPickerRoot.js +118 -0
- package/lib/commonjs/month-picker/MonthPickerRoot.js.map +1 -0
- package/lib/commonjs/month-picker/context.js +17 -0
- package/lib/commonjs/month-picker/context.js.map +1 -0
- package/lib/commonjs/month-picker/index.js +26 -0
- package/lib/commonjs/month-picker/index.js.map +1 -0
- package/lib/commonjs/overlay/useAnchorPosition.js +27 -16
- package/lib/commonjs/overlay/useAnchorPosition.js.map +1 -1
- package/lib/commonjs/overlay/useDismissOverlay.web.js +10 -2
- package/lib/commonjs/overlay/useDismissOverlay.web.js.map +1 -1
- package/lib/commonjs/overlay/useOverlayPosition.js +5 -2
- package/lib/commonjs/overlay/useOverlayPosition.js.map +1 -1
- package/lib/commonjs/portal/portal.js +59 -2
- package/lib/commonjs/portal/portal.js.map +1 -1
- package/lib/commonjs/radio/RadioGroup.js +65 -16
- package/lib/commonjs/radio/RadioGroup.js.map +1 -1
- package/lib/commonjs/radio/RadioRoot.web.js +114 -26
- package/lib/commonjs/radio/RadioRoot.web.js.map +1 -1
- package/lib/commonjs/radio/context.js.map +1 -1
- package/lib/commonjs/radio/useRadioGroupNavigation.js +79 -0
- package/lib/commonjs/radio/useRadioGroupNavigation.js.map +1 -0
- package/lib/commonjs/radio/useRadioRoot.js +14 -13
- package/lib/commonjs/radio/useRadioRoot.js.map +1 -1
- package/lib/commonjs/range-calendar/RangeCalendarRoot.js +148 -0
- package/lib/commonjs/range-calendar/RangeCalendarRoot.js.map +1 -0
- package/lib/commonjs/range-calendar/context.js +17 -0
- package/lib/commonjs/range-calendar/context.js.map +1 -0
- package/lib/commonjs/range-calendar/index.js +20 -0
- package/lib/commonjs/range-calendar/index.js.map +1 -0
- package/lib/commonjs/select/SelectRoot.js +1 -1
- package/lib/commonjs/select/SelectRoot.js.map +1 -1
- package/lib/commonjs/utils/accessibleLabel.js +23 -0
- package/lib/commonjs/utils/accessibleLabel.js.map +1 -0
- package/lib/commonjs/utils/createPortal.web.js +21 -0
- package/lib/commonjs/utils/createPortal.web.js.map +1 -0
- package/lib/module/calendar/CalendarGrid.js +29 -0
- package/lib/module/calendar/CalendarGrid.js.map +1 -0
- package/lib/module/calendar/CalendarRoot.js +91 -0
- package/lib/module/calendar/CalendarRoot.js.map +1 -0
- package/lib/module/calendar/context.js +12 -0
- package/lib/module/calendar/context.js.map +1 -0
- package/lib/module/calendar/index.js +6 -0
- package/lib/module/calendar/index.js.map +1 -0
- package/lib/module/calendar/types.js +4 -0
- package/lib/module/calendar/types.js.map +1 -0
- package/lib/module/checkbox/CheckboxRoot.web.js +92 -29
- package/lib/module/checkbox/CheckboxRoot.web.js.map +1 -1
- package/lib/module/checkbox/useCheckboxRoot.js +34 -20
- package/lib/module/checkbox/useCheckboxRoot.js.map +1 -1
- package/lib/module/date-field/DateFieldHiddenInput.js +146 -0
- package/lib/module/date-field/DateFieldHiddenInput.js.map +1 -0
- package/lib/module/date-field/DateFieldInput.js +118 -0
- package/lib/module/date-field/DateFieldInput.js.map +1 -0
- package/lib/module/date-field/DateFieldRoot.js +81 -0
- package/lib/module/date-field/DateFieldRoot.js.map +1 -0
- package/lib/module/date-field/DateFieldSegment.js +88 -0
- package/lib/module/date-field/DateFieldSegment.js.map +1 -0
- package/lib/module/date-field/context.js +15 -0
- package/lib/module/date-field/context.js.map +1 -0
- package/lib/module/date-field/index.js +7 -0
- package/lib/module/date-field/index.js.map +1 -0
- package/lib/module/date-field/segmentIndex.js +18 -0
- package/lib/module/date-field/segmentIndex.js.map +1 -0
- package/lib/module/date-field/segmentKeyboard.js +157 -0
- package/lib/module/date-field/segmentKeyboard.js.map +1 -0
- package/lib/module/date-field/types.js +4 -0
- package/lib/module/date-field/types.js.map +1 -0
- package/lib/module/date-field/useDateFieldSegmentState.js +378 -0
- package/lib/module/date-field/useDateFieldSegmentState.js.map +1 -0
- package/lib/module/date-field/useRangeDateFieldBridge.js +63 -0
- package/lib/module/date-field/useRangeDateFieldBridge.js.map +1 -0
- package/lib/module/date-picker/DatePickerRoot.js +119 -0
- package/lib/module/date-picker/DatePickerRoot.js.map +1 -0
- package/lib/module/date-picker/context.js +12 -0
- package/lib/module/date-picker/context.js.map +1 -0
- package/lib/module/date-picker/index.js +5 -0
- package/lib/module/date-picker/index.js.map +1 -0
- package/lib/module/date-range-picker/DateRangePickerRoot.js +140 -0
- package/lib/module/date-range-picker/DateRangePickerRoot.js.map +1 -0
- package/lib/module/date-range-picker/context.js +19 -0
- package/lib/module/date-range-picker/context.js.map +1 -0
- package/lib/module/date-range-picker/index.js +5 -0
- package/lib/module/date-range-picker/index.js.map +1 -0
- package/lib/module/date-time-field/DateTimeFieldHiddenInput.js +148 -0
- package/lib/module/date-time-field/DateTimeFieldHiddenInput.js.map +1 -0
- package/lib/module/date-time-field/DateTimeFieldInput.js +100 -0
- package/lib/module/date-time-field/DateTimeFieldInput.js.map +1 -0
- package/lib/module/date-time-field/DateTimeFieldRoot.js +154 -0
- package/lib/module/date-time-field/DateTimeFieldRoot.js.map +1 -0
- package/lib/module/date-time-field/DateTimeFieldSegment.js +83 -0
- package/lib/module/date-time-field/DateTimeFieldSegment.js.map +1 -0
- package/lib/module/date-time-field/context.js +12 -0
- package/lib/module/date-time-field/context.js.map +1 -0
- package/lib/module/date-time-field/index.js +7 -0
- package/lib/module/date-time-field/index.js.map +1 -0
- package/lib/module/date-time-field/useDateTimeFieldSegmentState.js +561 -0
- package/lib/module/date-time-field/useDateTimeFieldSegmentState.js.map +1 -0
- package/lib/module/date-time-list/DateTimeListRoot.js +416 -0
- package/lib/module/date-time-list/DateTimeListRoot.js.map +1 -0
- package/lib/module/date-time-list/context.js +20 -0
- package/lib/module/date-time-list/context.js.map +1 -0
- package/lib/module/date-time-list/index.js +5 -0
- package/lib/module/date-time-list/index.js.map +1 -0
- package/lib/module/date-time-picker/DateTimePickerRoot.js +130 -0
- package/lib/module/date-time-picker/DateTimePickerRoot.js.map +1 -0
- package/lib/module/date-time-picker/context.js +12 -0
- package/lib/module/date-time-picker/context.js.map +1 -0
- package/lib/module/date-time-picker/index.js +5 -0
- package/lib/module/date-time-picker/index.js.map +1 -0
- package/lib/module/dialog/DialogRoot.js +1 -1
- package/lib/module/dialog/DialogRoot.js.map +1 -1
- package/lib/module/index.js +11 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/month-calendar/MonthCalendarCell.js +60 -0
- package/lib/module/month-calendar/MonthCalendarCell.js.map +1 -0
- package/lib/module/month-calendar/MonthCalendarRoot.js +99 -0
- package/lib/module/month-calendar/MonthCalendarRoot.js.map +1 -0
- package/lib/module/month-calendar/MonthCalendarYearCell.js +59 -0
- package/lib/module/month-calendar/MonthCalendarYearCell.js.map +1 -0
- package/lib/module/month-calendar/context.js +12 -0
- package/lib/module/month-calendar/context.js.map +1 -0
- package/lib/module/month-calendar/index.js +7 -0
- package/lib/module/month-calendar/index.js.map +1 -0
- package/lib/module/month-picker/MonthPickerRoot.js +114 -0
- package/lib/module/month-picker/MonthPickerRoot.js.map +1 -0
- package/lib/module/month-picker/context.js +12 -0
- package/lib/module/month-picker/context.js.map +1 -0
- package/lib/module/month-picker/index.js +5 -0
- package/lib/module/month-picker/index.js.map +1 -0
- package/lib/module/overlay/useAnchorPosition.js +27 -16
- package/lib/module/overlay/useAnchorPosition.js.map +1 -1
- package/lib/module/overlay/useDismissOverlay.web.js +9 -2
- package/lib/module/overlay/useDismissOverlay.web.js.map +1 -1
- package/lib/module/overlay/useOverlayPosition.js +5 -2
- package/lib/module/overlay/useOverlayPosition.js.map +1 -1
- package/lib/module/portal/portal.js +59 -2
- package/lib/module/portal/portal.js.map +1 -1
- package/lib/module/radio/RadioGroup.js +68 -19
- package/lib/module/radio/RadioGroup.js.map +1 -1
- package/lib/module/radio/RadioRoot.web.js +117 -29
- package/lib/module/radio/RadioRoot.web.js.map +1 -1
- package/lib/module/radio/context.js.map +1 -1
- package/lib/module/radio/useRadioGroupNavigation.js +74 -0
- package/lib/module/radio/useRadioGroupNavigation.js.map +1 -0
- package/lib/module/radio/useRadioRoot.js +14 -13
- package/lib/module/radio/useRadioRoot.js.map +1 -1
- package/lib/module/range-calendar/RangeCalendarRoot.js +144 -0
- package/lib/module/range-calendar/RangeCalendarRoot.js.map +1 -0
- package/lib/module/range-calendar/context.js +12 -0
- package/lib/module/range-calendar/context.js.map +1 -0
- package/lib/module/range-calendar/index.js +5 -0
- package/lib/module/range-calendar/index.js.map +1 -0
- package/lib/module/select/SelectRoot.js +1 -1
- package/lib/module/select/SelectRoot.js.map +1 -1
- package/lib/module/utils/accessibleLabel.js +18 -0
- package/lib/module/utils/accessibleLabel.js.map +1 -0
- package/lib/module/utils/createPortal.web.js +17 -0
- package/lib/module/utils/createPortal.web.js.map +1 -0
- package/lib/typescript/calendar/CalendarGrid.d.ts +7 -0
- package/lib/typescript/calendar/CalendarGrid.d.ts.map +1 -0
- package/lib/typescript/calendar/CalendarRoot.d.ts +10 -0
- package/lib/typescript/calendar/CalendarRoot.d.ts.map +1 -0
- package/lib/typescript/calendar/context.d.ts +18 -0
- package/lib/typescript/calendar/context.d.ts.map +1 -0
- package/lib/typescript/calendar/index.d.ts +5 -0
- package/lib/typescript/calendar/index.d.ts.map +1 -0
- package/lib/typescript/calendar/types.d.ts +29 -0
- package/lib/typescript/calendar/types.d.ts.map +1 -0
- package/lib/typescript/checkbox/CheckboxRoot.web.d.ts +8 -0
- package/lib/typescript/checkbox/CheckboxRoot.web.d.ts.map +1 -1
- package/lib/typescript/checkbox/useCheckboxRoot.d.ts +7 -18
- package/lib/typescript/checkbox/useCheckboxRoot.d.ts.map +1 -1
- package/lib/typescript/date-field/DateFieldHiddenInput.d.ts +4 -0
- package/lib/typescript/date-field/DateFieldHiddenInput.d.ts.map +1 -0
- package/lib/typescript/date-field/DateFieldInput.d.ts +8 -0
- package/lib/typescript/date-field/DateFieldInput.d.ts.map +1 -0
- package/lib/typescript/date-field/DateFieldRoot.d.ts +10 -0
- package/lib/typescript/date-field/DateFieldRoot.d.ts.map +1 -0
- package/lib/typescript/date-field/DateFieldSegment.d.ts +9 -0
- package/lib/typescript/date-field/DateFieldSegment.d.ts.map +1 -0
- package/lib/typescript/date-field/context.d.ts +33 -0
- package/lib/typescript/date-field/context.d.ts.map +1 -0
- package/lib/typescript/date-field/index.d.ts +9 -0
- package/lib/typescript/date-field/index.d.ts.map +1 -0
- package/lib/typescript/date-field/segmentIndex.d.ts +7 -0
- package/lib/typescript/date-field/segmentIndex.d.ts.map +1 -0
- package/lib/typescript/date-field/segmentKeyboard.d.ts +23 -0
- package/lib/typescript/date-field/segmentKeyboard.d.ts.map +1 -0
- package/lib/typescript/date-field/types.d.ts +38 -0
- package/lib/typescript/date-field/types.d.ts.map +1 -0
- package/lib/typescript/date-field/useDateFieldSegmentState.d.ts +26 -0
- package/lib/typescript/date-field/useDateFieldSegmentState.d.ts.map +1 -0
- package/lib/typescript/date-field/useRangeDateFieldBridge.d.ts +4 -0
- package/lib/typescript/date-field/useRangeDateFieldBridge.d.ts.map +1 -0
- package/lib/typescript/date-picker/DatePickerRoot.d.ts +28 -0
- package/lib/typescript/date-picker/DatePickerRoot.d.ts.map +1 -0
- package/lib/typescript/date-picker/context.d.ts +25 -0
- package/lib/typescript/date-picker/context.d.ts.map +1 -0
- package/lib/typescript/date-picker/index.d.ts +5 -0
- package/lib/typescript/date-picker/index.d.ts.map +1 -0
- package/lib/typescript/date-range-picker/DateRangePickerRoot.d.ts +43 -0
- package/lib/typescript/date-range-picker/DateRangePickerRoot.d.ts.map +1 -0
- package/lib/typescript/date-range-picker/context.d.ts +42 -0
- package/lib/typescript/date-range-picker/context.d.ts.map +1 -0
- package/lib/typescript/date-range-picker/index.d.ts +4 -0
- package/lib/typescript/date-range-picker/index.d.ts.map +1 -0
- package/lib/typescript/date-time-field/DateTimeFieldHiddenInput.d.ts +4 -0
- package/lib/typescript/date-time-field/DateTimeFieldHiddenInput.d.ts.map +1 -0
- package/lib/typescript/date-time-field/DateTimeFieldInput.d.ts +10 -0
- package/lib/typescript/date-time-field/DateTimeFieldInput.d.ts.map +1 -0
- package/lib/typescript/date-time-field/DateTimeFieldRoot.d.ts +24 -0
- package/lib/typescript/date-time-field/DateTimeFieldRoot.d.ts.map +1 -0
- package/lib/typescript/date-time-field/DateTimeFieldSegment.d.ts +10 -0
- package/lib/typescript/date-time-field/DateTimeFieldSegment.d.ts.map +1 -0
- package/lib/typescript/date-time-field/context.d.ts +27 -0
- package/lib/typescript/date-time-field/context.d.ts.map +1 -0
- package/lib/typescript/date-time-field/index.d.ts +8 -0
- package/lib/typescript/date-time-field/index.d.ts.map +1 -0
- package/lib/typescript/date-time-field/useDateTimeFieldSegmentState.d.ts +26 -0
- package/lib/typescript/date-time-field/useDateTimeFieldSegmentState.d.ts.map +1 -0
- package/lib/typescript/date-time-list/DateTimeListRoot.d.ts +42 -0
- package/lib/typescript/date-time-list/DateTimeListRoot.d.ts.map +1 -0
- package/lib/typescript/date-time-list/context.d.ts +29 -0
- package/lib/typescript/date-time-list/context.d.ts.map +1 -0
- package/lib/typescript/date-time-list/index.d.ts +4 -0
- package/lib/typescript/date-time-list/index.d.ts.map +1 -0
- package/lib/typescript/date-time-picker/DateTimePickerRoot.d.ts +36 -0
- package/lib/typescript/date-time-picker/DateTimePickerRoot.d.ts.map +1 -0
- package/lib/typescript/date-time-picker/context.d.ts +25 -0
- package/lib/typescript/date-time-picker/context.d.ts.map +1 -0
- package/lib/typescript/date-time-picker/index.d.ts +4 -0
- package/lib/typescript/date-time-picker/index.d.ts.map +1 -0
- package/lib/typescript/dialog/types.d.ts +2 -1
- package/lib/typescript/dialog/types.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +11 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/month-calendar/MonthCalendarCell.d.ts +9 -0
- package/lib/typescript/month-calendar/MonthCalendarCell.d.ts.map +1 -0
- package/lib/typescript/month-calendar/MonthCalendarRoot.d.ts +30 -0
- package/lib/typescript/month-calendar/MonthCalendarRoot.d.ts.map +1 -0
- package/lib/typescript/month-calendar/MonthCalendarYearCell.d.ts +9 -0
- package/lib/typescript/month-calendar/MonthCalendarYearCell.d.ts.map +1 -0
- package/lib/typescript/month-calendar/context.d.ts +20 -0
- package/lib/typescript/month-calendar/context.d.ts.map +1 -0
- package/lib/typescript/month-calendar/index.d.ts +7 -0
- package/lib/typescript/month-calendar/index.d.ts.map +1 -0
- package/lib/typescript/month-picker/MonthPickerRoot.d.ts +29 -0
- package/lib/typescript/month-picker/MonthPickerRoot.d.ts.map +1 -0
- package/lib/typescript/month-picker/context.d.ts +23 -0
- package/lib/typescript/month-picker/context.d.ts.map +1 -0
- package/lib/typescript/month-picker/index.d.ts +4 -0
- package/lib/typescript/month-picker/index.d.ts.map +1 -0
- package/lib/typescript/overlay/useAnchorPosition.d.ts.map +1 -1
- package/lib/typescript/overlay/useDismissOverlay.web.d.ts.map +1 -1
- package/lib/typescript/overlay/useOverlayPosition.d.ts.map +1 -1
- package/lib/typescript/portal/portal.d.ts.map +1 -1
- package/lib/typescript/radio/RadioGroup.d.ts.map +1 -1
- package/lib/typescript/radio/RadioRoot.web.d.ts +8 -0
- package/lib/typescript/radio/RadioRoot.web.d.ts.map +1 -1
- package/lib/typescript/radio/context.d.ts +6 -1
- package/lib/typescript/radio/context.d.ts.map +1 -1
- package/lib/typescript/radio/types.d.ts +7 -0
- package/lib/typescript/radio/types.d.ts.map +1 -1
- package/lib/typescript/radio/useRadioGroupNavigation.d.ts +17 -0
- package/lib/typescript/radio/useRadioGroupNavigation.d.ts.map +1 -0
- package/lib/typescript/radio/useRadioRoot.d.ts +4 -18
- package/lib/typescript/radio/useRadioRoot.d.ts.map +1 -1
- package/lib/typescript/range-calendar/RangeCalendarRoot.d.ts +34 -0
- package/lib/typescript/range-calendar/RangeCalendarRoot.d.ts.map +1 -0
- package/lib/typescript/range-calendar/context.d.ts +26 -0
- package/lib/typescript/range-calendar/context.d.ts.map +1 -0
- package/lib/typescript/range-calendar/index.d.ts +5 -0
- package/lib/typescript/range-calendar/index.d.ts.map +1 -0
- package/lib/typescript/select/types.d.ts +2 -1
- package/lib/typescript/select/types.d.ts.map +1 -1
- package/lib/typescript/utils/accessibleLabel.d.ts +13 -0
- package/lib/typescript/utils/accessibleLabel.d.ts.map +1 -0
- package/lib/typescript/utils/createPortal.web.d.ts +17 -0
- package/lib/typescript/utils/createPortal.web.d.ts.map +1 -0
- package/package.json +3 -2
- package/src/calendar/CalendarGrid.tsx +29 -0
- package/src/calendar/CalendarRoot.tsx +138 -0
- package/src/calendar/context.tsx +28 -0
- package/src/calendar/index.ts +4 -0
- package/src/calendar/types.ts +30 -0
- package/src/checkbox/CheckboxRoot.web.tsx +105 -29
- package/src/checkbox/useCheckboxRoot.ts +37 -15
- package/src/date-field/DateFieldHiddenInput.tsx +152 -0
- package/src/date-field/DateFieldInput.tsx +138 -0
- package/src/date-field/DateFieldRoot.tsx +117 -0
- package/src/date-field/DateFieldSegment.tsx +97 -0
- package/src/date-field/context.tsx +48 -0
- package/src/date-field/index.ts +8 -0
- package/src/date-field/segmentIndex.tsx +17 -0
- package/src/date-field/segmentKeyboard.ts +207 -0
- package/src/date-field/types.ts +40 -0
- package/src/date-field/useDateFieldSegmentState.ts +455 -0
- package/src/date-field/useRangeDateFieldBridge.ts +78 -0
- package/src/date-picker/DatePickerRoot.tsx +186 -0
- package/src/date-picker/context.tsx +34 -0
- package/src/date-picker/index.ts +4 -0
- package/src/date-range-picker/DateRangePickerRoot.tsx +236 -0
- package/src/date-range-picker/context.tsx +48 -0
- package/src/date-range-picker/index.ts +8 -0
- package/src/date-time-field/DateTimeFieldHiddenInput.tsx +156 -0
- package/src/date-time-field/DateTimeFieldInput.tsx +119 -0
- package/src/date-time-field/DateTimeFieldRoot.tsx +209 -0
- package/src/date-time-field/DateTimeFieldSegment.tsx +95 -0
- package/src/date-time-field/context.tsx +41 -0
- package/src/date-time-field/index.ts +7 -0
- package/src/date-time-field/useDateTimeFieldSegmentState.ts +672 -0
- package/src/date-time-list/DateTimeListRoot.tsx +530 -0
- package/src/date-time-list/context.tsx +45 -0
- package/src/date-time-list/index.ts +16 -0
- package/src/date-time-picker/DateTimePickerRoot.tsx +210 -0
- package/src/date-time-picker/context.tsx +33 -0
- package/src/date-time-picker/index.ts +7 -0
- package/src/dialog/DialogRoot.tsx +1 -1
- package/src/dialog/types.ts +2 -1
- package/src/index.ts +21 -2
- package/src/month-calendar/MonthCalendarCell.tsx +53 -0
- package/src/month-calendar/MonthCalendarRoot.tsx +153 -0
- package/src/month-calendar/MonthCalendarYearCell.tsx +54 -0
- package/src/month-calendar/context.tsx +30 -0
- package/src/month-calendar/index.ts +6 -0
- package/src/month-picker/MonthPickerRoot.tsx +183 -0
- package/src/month-picker/context.tsx +31 -0
- package/src/month-picker/index.ts +3 -0
- package/src/overlay/useAnchorPosition.ts +25 -11
- package/src/overlay/useDismissOverlay.web.ts +10 -2
- package/src/overlay/useOverlayPosition.ts +5 -2
- package/src/portal/portal.tsx +79 -2
- package/src/radio/RadioGroup.tsx +84 -20
- package/src/radio/RadioRoot.web.tsx +136 -31
- package/src/radio/context.tsx +6 -1
- package/src/radio/types.ts +6 -0
- package/src/radio/useRadioGroupNavigation.ts +104 -0
- package/src/radio/useRadioRoot.ts +18 -11
- package/src/range-calendar/RangeCalendarRoot.tsx +213 -0
- package/src/range-calendar/context.tsx +33 -0
- package/src/range-calendar/index.ts +4 -0
- package/src/select/SelectRoot.tsx +1 -1
- package/src/select/types.ts +2 -1
- package/src/utils/accessibleLabel.ts +22 -0
- package/src/utils/createPortal.web.ts +18 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { forwardRef, type ComponentRef } from 'react';
|
|
2
|
+
import { View, type ViewProps } from 'react-native';
|
|
3
|
+
import { Slot } from '../slot';
|
|
4
|
+
import { dataAttributes, mergeDataAttributes } from '../utils/dataAttributes';
|
|
5
|
+
|
|
6
|
+
export interface CalendarGridProps extends ViewProps {
|
|
7
|
+
asChild?: boolean;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const CalendarGrid = forwardRef<ComponentRef<typeof View>, CalendarGridProps>(
|
|
12
|
+
({ asChild, className, style, children, ...props }, ref) => {
|
|
13
|
+
const Comp = asChild ? Slot : View;
|
|
14
|
+
return (
|
|
15
|
+
<Comp
|
|
16
|
+
ref={ref}
|
|
17
|
+
className={className}
|
|
18
|
+
style={style}
|
|
19
|
+
accessibilityRole="none"
|
|
20
|
+
{...props}
|
|
21
|
+
{...mergeDataAttributes(props, dataAttributes({ slot: 'calendar-grid' }))}
|
|
22
|
+
>
|
|
23
|
+
{children}
|
|
24
|
+
</Comp>
|
|
25
|
+
);
|
|
26
|
+
},
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
CalendarGrid.displayName = 'CalendarGrid';
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import {
|
|
2
|
+
forwardRef,
|
|
3
|
+
useCallback,
|
|
4
|
+
useEffect,
|
|
5
|
+
useMemo,
|
|
6
|
+
useRef,
|
|
7
|
+
useState,
|
|
8
|
+
type ComponentRef,
|
|
9
|
+
type ReactNode,
|
|
10
|
+
} from 'react';
|
|
11
|
+
import { View, type ViewProps } from 'react-native';
|
|
12
|
+
import {
|
|
13
|
+
todayMonthId,
|
|
14
|
+
toMonthId,
|
|
15
|
+
resolveDateComponentLabels,
|
|
16
|
+
type DateId,
|
|
17
|
+
type MonthId,
|
|
18
|
+
} from '@cdx-ui/formatters';
|
|
19
|
+
import { useControllableState } from '@cdx-ui/utils';
|
|
20
|
+
import { Slot } from '../slot';
|
|
21
|
+
import { accessibleLabelAttributes, resolveAccessibleLabel } from '../utils/accessibleLabel';
|
|
22
|
+
import { dataAttributes, mergeDataAttributes } from '../utils/dataAttributes';
|
|
23
|
+
import { CalendarContext, type CalendarView } from './context';
|
|
24
|
+
import type { ICalendarProps } from './types';
|
|
25
|
+
|
|
26
|
+
export interface CalendarRootProps extends ICalendarProps, Omit<ViewProps, 'children'> {
|
|
27
|
+
asChild?: boolean;
|
|
28
|
+
children?: ReactNode;
|
|
29
|
+
className?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const CalendarRoot = forwardRef<ComponentRef<typeof View>, CalendarRootProps>(
|
|
33
|
+
(
|
|
34
|
+
{
|
|
35
|
+
asChild,
|
|
36
|
+
children,
|
|
37
|
+
value: valueProp,
|
|
38
|
+
defaultValue,
|
|
39
|
+
onValueChange,
|
|
40
|
+
monthId: monthIdProp,
|
|
41
|
+
defaultMonthId,
|
|
42
|
+
onMonthIdChange,
|
|
43
|
+
minValue,
|
|
44
|
+
maxValue,
|
|
45
|
+
disabled = false,
|
|
46
|
+
locale = 'en-US',
|
|
47
|
+
labels: labelsProp,
|
|
48
|
+
accessibilityLabel: accessibilityLabelProp,
|
|
49
|
+
'aria-label': ariaLabelProp,
|
|
50
|
+
...props
|
|
51
|
+
},
|
|
52
|
+
ref,
|
|
53
|
+
) => {
|
|
54
|
+
const labels = useMemo(() => resolveDateComponentLabels(labelsProp), [labelsProp]);
|
|
55
|
+
const accessibilityLabel = resolveAccessibleLabel({
|
|
56
|
+
accessibilityLabel: accessibilityLabelProp,
|
|
57
|
+
'aria-label': ariaLabelProp,
|
|
58
|
+
});
|
|
59
|
+
const [value, setValue] = useControllableState<DateId | undefined>({
|
|
60
|
+
prop: valueProp,
|
|
61
|
+
defaultProp: defaultValue,
|
|
62
|
+
onChange: onValueChange,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const [monthId, setMonthId] = useControllableState<MonthId>({
|
|
66
|
+
prop: monthIdProp,
|
|
67
|
+
defaultProp: defaultMonthId ?? (value ? toMonthId(value) : todayMonthId()),
|
|
68
|
+
onChange: onMonthIdChange,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const prevValueRef = useRef(value);
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (monthIdProp !== undefined) {
|
|
74
|
+
prevValueRef.current = value;
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (value === undefined || prevValueRef.current === value) {
|
|
78
|
+
prevValueRef.current = value;
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
prevValueRef.current = value;
|
|
82
|
+
setMonthId(toMonthId(value));
|
|
83
|
+
}, [monthIdProp, setMonthId, value]);
|
|
84
|
+
|
|
85
|
+
const [view, setViewState] = useState<CalendarView>('month');
|
|
86
|
+
|
|
87
|
+
const setView = useCallback((next: CalendarView) => {
|
|
88
|
+
setViewState(next);
|
|
89
|
+
}, []);
|
|
90
|
+
|
|
91
|
+
const contextValue = useMemo(
|
|
92
|
+
() => ({
|
|
93
|
+
value,
|
|
94
|
+
onValueChange: setValue,
|
|
95
|
+
monthId: monthId ?? todayMonthId(),
|
|
96
|
+
onMonthIdChange: setMonthId,
|
|
97
|
+
minValue,
|
|
98
|
+
maxValue,
|
|
99
|
+
disabled,
|
|
100
|
+
locale,
|
|
101
|
+
labels,
|
|
102
|
+
view,
|
|
103
|
+
setView,
|
|
104
|
+
}),
|
|
105
|
+
[
|
|
106
|
+
value,
|
|
107
|
+
setValue,
|
|
108
|
+
monthId,
|
|
109
|
+
setMonthId,
|
|
110
|
+
minValue,
|
|
111
|
+
maxValue,
|
|
112
|
+
disabled,
|
|
113
|
+
locale,
|
|
114
|
+
labels,
|
|
115
|
+
view,
|
|
116
|
+
setView,
|
|
117
|
+
],
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
const Comp = asChild ? Slot : View;
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
<CalendarContext.Provider value={contextValue}>
|
|
124
|
+
<Comp
|
|
125
|
+
ref={ref}
|
|
126
|
+
accessibilityRole="none"
|
|
127
|
+
{...props}
|
|
128
|
+
{...mergeDataAttributes(props, dataAttributes({ disabled }))}
|
|
129
|
+
{...accessibleLabelAttributes(accessibilityLabel)}
|
|
130
|
+
>
|
|
131
|
+
{children}
|
|
132
|
+
</Comp>
|
|
133
|
+
</CalendarContext.Provider>
|
|
134
|
+
);
|
|
135
|
+
},
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
CalendarRoot.displayName = 'CalendarRoot';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
import type { DateComponentLabels, DateId, MonthId } from '@cdx-ui/formatters';
|
|
3
|
+
|
|
4
|
+
export type CalendarView = 'month' | 'year';
|
|
5
|
+
|
|
6
|
+
export interface CalendarContextValue {
|
|
7
|
+
value?: DateId;
|
|
8
|
+
onValueChange?: (value: DateId | undefined) => void;
|
|
9
|
+
monthId: MonthId;
|
|
10
|
+
onMonthIdChange: (monthId: MonthId) => void;
|
|
11
|
+
minValue?: DateId;
|
|
12
|
+
maxValue?: DateId;
|
|
13
|
+
disabled: boolean;
|
|
14
|
+
locale: string;
|
|
15
|
+
labels: DateComponentLabels;
|
|
16
|
+
view: CalendarView;
|
|
17
|
+
setView: (view: CalendarView) => void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const CalendarContext = createContext<CalendarContextValue | null>(null);
|
|
21
|
+
|
|
22
|
+
export function useCalendarContext(): CalendarContextValue {
|
|
23
|
+
const ctx = useContext(CalendarContext);
|
|
24
|
+
if (!ctx) {
|
|
25
|
+
throw new Error('Calendar compound components must be used within CalendarRoot');
|
|
26
|
+
}
|
|
27
|
+
return ctx;
|
|
28
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ViewProps } from 'react-native';
|
|
2
|
+
import type { DateComponentLabels, DateId, MonthId } from '@cdx-ui/formatters';
|
|
3
|
+
|
|
4
|
+
export interface ICalendarProps {
|
|
5
|
+
/** Selected date as a `YYYY-MM-DD` string. */
|
|
6
|
+
value?: DateId;
|
|
7
|
+
/** Uncontrolled initial selection as a `YYYY-MM-DD` string. */
|
|
8
|
+
defaultValue?: DateId;
|
|
9
|
+
/** Called with the new selection, or `undefined` when the selection is cleared. */
|
|
10
|
+
onValueChange?: (value: DateId | undefined) => void;
|
|
11
|
+
/** Month shown in the grid as a `YYYY-MM-01` string. Follows the selected `value` unless controlled. */
|
|
12
|
+
monthId?: MonthId;
|
|
13
|
+
/** Uncontrolled initial month as a `YYYY-MM-01` string. */
|
|
14
|
+
defaultMonthId?: MonthId;
|
|
15
|
+
onMonthIdChange?: (monthId: MonthId) => void;
|
|
16
|
+
/** Earliest selectable date. Build with `dateId(...)` from `@cdx-ui/formatters`. */
|
|
17
|
+
minValue?: DateId;
|
|
18
|
+
/** Latest selectable date. Build with `dateId(...)` from `@cdx-ui/formatters`. */
|
|
19
|
+
maxValue?: DateId;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
/** BCP 47 locale for weekday and month formatting. Defaults to `en-US`. */
|
|
22
|
+
locale?: string;
|
|
23
|
+
labels?: Partial<DateComponentLabels>;
|
|
24
|
+
/** Accessible name for the calendar region. */
|
|
25
|
+
accessibilityLabel?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface ICalendarGridProps extends ViewProps {
|
|
29
|
+
className?: string;
|
|
30
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { forwardRef } from 'react';
|
|
2
2
|
import { Pressable, type PressableProps } from 'react-native';
|
|
3
3
|
import { VisuallyHidden } from '@react-aria/visually-hidden';
|
|
4
|
+
import { composeEventHandlers } from '@cdx-ui/utils';
|
|
4
5
|
import { useFocusRing } from '@react-native-aria/focus';
|
|
5
6
|
import { Slot } from '../slot';
|
|
6
7
|
import { dataAttributes, mergeDataAttributes } from '../utils/dataAttributes';
|
|
@@ -12,6 +13,14 @@ export interface CheckboxRootProps extends ICheckboxProps {
|
|
|
12
13
|
asChild?: boolean;
|
|
13
14
|
}
|
|
14
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Web Checkbox root.
|
|
18
|
+
*
|
|
19
|
+
* On web, `@react-native-aria/checkbox` re-exports `@react-aria/checkbox`'s
|
|
20
|
+
* `useCheckbox`, whose `inputProps` target a native `<input type="checkbox">`
|
|
21
|
+
* (selection via `onChange`). Toggle must be applied explicitly on the Pressable —
|
|
22
|
+
* `inputProps.onPress` does **not** call `toggleState.toggle()`.
|
|
23
|
+
*/
|
|
15
24
|
export const CheckboxRoot = forwardRef<React.ComponentRef<typeof Pressable>, CheckboxRootProps>(
|
|
16
25
|
({ asChild, children, ...props }, ref) => {
|
|
17
26
|
const {
|
|
@@ -37,18 +46,55 @@ export const CheckboxRoot = forwardRef<React.ComponentRef<typeof Pressable>, Che
|
|
|
37
46
|
isHovered,
|
|
38
47
|
mergedRef,
|
|
39
48
|
inputRef,
|
|
49
|
+
toggle,
|
|
40
50
|
} = useCheckboxRoot(props, ref, { useInputRefForAria: true });
|
|
41
51
|
|
|
42
52
|
const { focusProps, isFocusVisible } = useFocusRing();
|
|
43
53
|
|
|
54
|
+
// Strip native-input / internal props — they must not land on Pressable.
|
|
55
|
+
const {
|
|
56
|
+
onPress: _onPress,
|
|
57
|
+
onChange: _onChange,
|
|
58
|
+
role: _role,
|
|
59
|
+
tabIndex: _tabIndex,
|
|
60
|
+
disabled: _disabled,
|
|
61
|
+
checked: _checked,
|
|
62
|
+
value: _value,
|
|
63
|
+
type: _type,
|
|
64
|
+
name: _name,
|
|
65
|
+
form: _form,
|
|
66
|
+
required: _required,
|
|
67
|
+
...inputAriaProps
|
|
68
|
+
} = groupItemInputProps;
|
|
69
|
+
|
|
70
|
+
const resolvedChecked = !!(isChecked || isCheckedProp);
|
|
71
|
+
const resolvedIndeterminate = !!(isIndeterminate || isIndeterminateProp);
|
|
72
|
+
const resolvedDisabled = !!(isDisabled || isDisabledProp);
|
|
73
|
+
const resolvedReadOnly = !!(isReadOnly || isReadOnlyProp);
|
|
74
|
+
const ariaChecked = resolvedIndeterminate ? 'mixed' : resolvedChecked;
|
|
75
|
+
|
|
76
|
+
const handleToggle = () => {
|
|
77
|
+
if (resolvedDisabled || resolvedReadOnly) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
toggle();
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const handleKeyDown = (event: { key: string; preventDefault: () => void }) => {
|
|
84
|
+
if (event.key === ' ' || event.key === 'Spacebar') {
|
|
85
|
+
event.preventDefault();
|
|
86
|
+
handleToggle();
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
44
90
|
const contextValue: ICheckboxContextValue = {
|
|
45
|
-
isChecked:
|
|
46
|
-
isDisabled:
|
|
91
|
+
isChecked: resolvedChecked,
|
|
92
|
+
isDisabled: resolvedDisabled,
|
|
47
93
|
isFocusVisible: isFocusVisible || isFocusVisibleProp,
|
|
48
94
|
isHovered: isHovered || isHoveredProp,
|
|
49
95
|
isInvalid: isInvalid || isInvalidProp,
|
|
50
|
-
isReadOnly:
|
|
51
|
-
isIndeterminate:
|
|
96
|
+
isReadOnly: resolvedReadOnly,
|
|
97
|
+
isIndeterminate: resolvedIndeterminate,
|
|
52
98
|
isPressed,
|
|
53
99
|
isFocused,
|
|
54
100
|
};
|
|
@@ -57,33 +103,63 @@ export const CheckboxRoot = forwardRef<React.ComponentRef<typeof Pressable>, Che
|
|
|
57
103
|
|
|
58
104
|
return (
|
|
59
105
|
<CheckboxProvider value={contextValue}>
|
|
60
|
-
|
|
61
|
-
{...(combinedProps as PressableProps)}
|
|
62
|
-
ref={mergedRef}
|
|
63
|
-
tabIndex={-1}
|
|
64
|
-
role="label"
|
|
65
|
-
// eslint-disable-next-line react-native-a11y/has-valid-accessibility-role
|
|
66
|
-
accessibilityRole="label"
|
|
67
|
-
{...mergeDataAttributes(
|
|
68
|
-
props,
|
|
69
|
-
dataAttributes({
|
|
70
|
-
checked: isChecked || isCheckedProp,
|
|
71
|
-
disabled: isDisabled || isDisabledProp,
|
|
72
|
-
hover: isHovered || isHoveredProp,
|
|
73
|
-
invalid: isInvalid || isInvalidProp,
|
|
74
|
-
readonly: isReadOnly || isReadOnlyProp,
|
|
75
|
-
active: isPressed,
|
|
76
|
-
focus: isFocused,
|
|
77
|
-
indeterminate: isIndeterminate || isIndeterminateProp,
|
|
78
|
-
focusVisible: isFocusVisible,
|
|
79
|
-
}),
|
|
80
|
-
)}
|
|
81
|
-
>
|
|
106
|
+
<>
|
|
82
107
|
<VisuallyHidden>
|
|
83
|
-
<input
|
|
108
|
+
<input
|
|
109
|
+
ref={inputRef as React.RefObject<HTMLInputElement>}
|
|
110
|
+
type="checkbox"
|
|
111
|
+
value={combinedProps.value}
|
|
112
|
+
checked={resolvedChecked}
|
|
113
|
+
disabled={resolvedDisabled}
|
|
114
|
+
tabIndex={-1}
|
|
115
|
+
aria-hidden
|
|
116
|
+
readOnly
|
|
117
|
+
style={{ pointerEvents: 'none' }}
|
|
118
|
+
/>
|
|
84
119
|
</VisuallyHidden>
|
|
85
|
-
|
|
86
|
-
|
|
120
|
+
<Comp
|
|
121
|
+
{...(combinedProps as PressableProps)}
|
|
122
|
+
{...inputAriaProps}
|
|
123
|
+
ref={mergedRef}
|
|
124
|
+
role="checkbox"
|
|
125
|
+
aria-checked={ariaChecked}
|
|
126
|
+
aria-disabled={resolvedDisabled || undefined}
|
|
127
|
+
accessibilityRole="checkbox"
|
|
128
|
+
accessibilityState={{
|
|
129
|
+
checked: resolvedIndeterminate ? 'mixed' : resolvedChecked,
|
|
130
|
+
disabled: resolvedDisabled,
|
|
131
|
+
}}
|
|
132
|
+
tabIndex={resolvedDisabled ? -1 : 0}
|
|
133
|
+
disabled={resolvedDisabled}
|
|
134
|
+
{...focusProps}
|
|
135
|
+
onPress={handleToggle}
|
|
136
|
+
onClick={handleToggle}
|
|
137
|
+
onKeyDown={composeEventHandlers(
|
|
138
|
+
(
|
|
139
|
+
combinedProps as {
|
|
140
|
+
onKeyDown?: (e: { key: string; preventDefault: () => void }) => void;
|
|
141
|
+
}
|
|
142
|
+
).onKeyDown,
|
|
143
|
+
handleKeyDown,
|
|
144
|
+
)}
|
|
145
|
+
{...mergeDataAttributes(
|
|
146
|
+
props,
|
|
147
|
+
dataAttributes({
|
|
148
|
+
checked: resolvedChecked,
|
|
149
|
+
disabled: resolvedDisabled,
|
|
150
|
+
hover: isHovered || isHoveredProp,
|
|
151
|
+
invalid: isInvalid || isInvalidProp,
|
|
152
|
+
readonly: resolvedReadOnly,
|
|
153
|
+
active: isPressed,
|
|
154
|
+
focus: isFocused,
|
|
155
|
+
indeterminate: resolvedIndeterminate,
|
|
156
|
+
focusVisible: isFocusVisible || isFocusVisibleProp,
|
|
157
|
+
}),
|
|
158
|
+
)}
|
|
159
|
+
>
|
|
160
|
+
{children}
|
|
161
|
+
</Comp>
|
|
162
|
+
</>
|
|
87
163
|
</CheckboxProvider>
|
|
88
164
|
);
|
|
89
165
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useContext, useRef } from 'react';
|
|
1
|
+
import { useCallback, useContext, useRef } from 'react';
|
|
2
2
|
import { mergeRefs, useFormControlContext } from '@cdx-ui/utils';
|
|
3
3
|
import { useCheckbox } from '@react-native-aria/checkbox';
|
|
4
4
|
import { useHover } from '@react-native-aria/interactions';
|
|
@@ -16,29 +16,43 @@ export function useCheckboxRoot(
|
|
|
16
16
|
{ useInputRefForAria = false }: UseCheckboxRootOptions = {},
|
|
17
17
|
) {
|
|
18
18
|
const formControlContext = useFormControlContext();
|
|
19
|
+
const checkboxGroupContext = useContext(CheckboxGroupContext);
|
|
20
|
+
|
|
21
|
+
// Only pull field-state flags from FormControl — never spread the whole context
|
|
22
|
+
// (ids, setters, htmlProps) onto the host element.
|
|
23
|
+
const isInvalid = props.isInvalid ?? formControlContext.isInvalid;
|
|
24
|
+
const isReadOnly =
|
|
25
|
+
props.isReadOnly ?? formControlContext.isReadOnly ?? checkboxGroupContext?.state.isReadOnly;
|
|
26
|
+
const isDisabled =
|
|
27
|
+
props.isDisabled ?? formControlContext.isDisabled ?? checkboxGroupContext?.state.isDisabled;
|
|
28
|
+
const isIndeterminate = props.isIndeterminate;
|
|
19
29
|
|
|
20
|
-
const
|
|
21
|
-
...formControlContext,
|
|
30
|
+
const combinedProps = {
|
|
22
31
|
...props,
|
|
32
|
+
isInvalid,
|
|
33
|
+
isReadOnly,
|
|
34
|
+
isDisabled,
|
|
35
|
+
isIndeterminate,
|
|
23
36
|
};
|
|
24
37
|
|
|
25
|
-
const checkboxGroupContext = useContext(CheckboxGroupContext);
|
|
26
|
-
|
|
27
38
|
const state = useToggleState({
|
|
28
|
-
...combinedProps,
|
|
29
39
|
defaultSelected: props.defaultIsChecked,
|
|
30
40
|
isSelected: props.isChecked,
|
|
41
|
+
onChange: props.onChange,
|
|
42
|
+
isReadOnly,
|
|
43
|
+
isDisabled,
|
|
31
44
|
});
|
|
32
45
|
|
|
33
46
|
const rootRef = useRef(null);
|
|
34
47
|
const inputRef = useRef<HTMLInputElement | null>(null);
|
|
35
48
|
const mergedRootRef = mergeRefs(ref as any, rootRef as any);
|
|
36
|
-
const ariaLabel =
|
|
49
|
+
const ariaLabel = props['aria-label'] || props.value || 'Checkbox';
|
|
37
50
|
|
|
38
51
|
const groupToggleState = useToggleState(
|
|
39
52
|
checkboxGroupContext
|
|
40
53
|
? {
|
|
41
|
-
isReadOnly: isReadOnly
|
|
54
|
+
isReadOnly: !!isReadOnly,
|
|
55
|
+
isDisabled: !!isDisabled,
|
|
42
56
|
isSelected: checkboxGroupContext.state.isSelected(combinedProps.value),
|
|
43
57
|
onChange(isSelected: boolean) {
|
|
44
58
|
if (isSelected) {
|
|
@@ -52,23 +66,30 @@ export function useCheckboxRoot(
|
|
|
52
66
|
: { isSelected: false },
|
|
53
67
|
);
|
|
54
68
|
|
|
69
|
+
const toggleState = checkboxGroupContext ? groupToggleState : state;
|
|
70
|
+
|
|
55
71
|
const { inputProps: groupItemInputProps } = useCheckbox(
|
|
56
72
|
{
|
|
57
73
|
...combinedProps,
|
|
58
74
|
'aria-label': ariaLabel,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
isDisabled: combinedProps.isDisabled || checkboxGroupContext.state.isDisabled,
|
|
62
|
-
}),
|
|
75
|
+
isReadOnly: !!isReadOnly,
|
|
76
|
+
isDisabled: !!isDisabled,
|
|
63
77
|
} as any,
|
|
64
|
-
|
|
78
|
+
toggleState,
|
|
65
79
|
(useInputRefForAria ? inputRef : rootRef) as any,
|
|
66
80
|
);
|
|
67
81
|
|
|
68
|
-
const { checked: isChecked, disabled:
|
|
82
|
+
const { checked: isChecked, disabled: isDisabledFromInput } = groupItemInputProps;
|
|
69
83
|
|
|
70
84
|
const { hoverProps, isHovered } = useHover({}, rootRef);
|
|
71
85
|
|
|
86
|
+
const toggle = useCallback(() => {
|
|
87
|
+
if (isDisabled || isReadOnly) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
toggleState.toggle();
|
|
91
|
+
}, [isDisabled, isReadOnly, toggleState]);
|
|
92
|
+
|
|
72
93
|
return {
|
|
73
94
|
combinedProps,
|
|
74
95
|
isInvalid,
|
|
@@ -76,10 +97,11 @@ export function useCheckboxRoot(
|
|
|
76
97
|
isIndeterminate,
|
|
77
98
|
groupItemInputProps,
|
|
78
99
|
isChecked,
|
|
79
|
-
isDisabled,
|
|
100
|
+
isDisabled: isDisabledFromInput,
|
|
80
101
|
isHovered,
|
|
81
102
|
hoverProps,
|
|
82
103
|
mergedRef: mergedRootRef,
|
|
83
104
|
inputRef,
|
|
105
|
+
toggle,
|
|
84
106
|
};
|
|
85
107
|
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { Platform, TextInput, type TextInputKeyPressEvent } from 'react-native';
|
|
3
|
+
import { useDateFieldContext } from './context';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Invisible input that owns keyboard focus while a segment is active.
|
|
7
|
+
* Kept always mounted (never conditionally unmounted) so focus/blur races
|
|
8
|
+
* cannot clear segment focus before keystrokes arrive.
|
|
9
|
+
*
|
|
10
|
+
* Value is synced to the segment draft so native backspace shortens the text
|
|
11
|
+
* via onChangeText (iOS number-pad has no delete key; phone-pad does).
|
|
12
|
+
*/
|
|
13
|
+
const HIDDEN_INPUT_STYLE = {
|
|
14
|
+
position: 'absolute' as const,
|
|
15
|
+
opacity: 0.01,
|
|
16
|
+
width: '100%' as const,
|
|
17
|
+
height: '100%' as const,
|
|
18
|
+
left: 0,
|
|
19
|
+
top: 0,
|
|
20
|
+
zIndex: 0,
|
|
21
|
+
fontSize: 16,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const KEYBOARD_TYPE = Platform.select<'number-pad' | 'phone-pad'>({
|
|
25
|
+
ios: 'phone-pad',
|
|
26
|
+
default: 'number-pad',
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export function DateFieldHiddenInput({ accessibilityLabel }: { accessibilityLabel: string }) {
|
|
30
|
+
const {
|
|
31
|
+
focusedSegmentIndex,
|
|
32
|
+
disabled,
|
|
33
|
+
readOnly,
|
|
34
|
+
segmentDraft,
|
|
35
|
+
handleSegmentInputChange,
|
|
36
|
+
handleSegmentBackspace,
|
|
37
|
+
focusNextEditableSegment,
|
|
38
|
+
focusPrevEditableSegment,
|
|
39
|
+
blurSegment,
|
|
40
|
+
} = useDateFieldContext();
|
|
41
|
+
|
|
42
|
+
const inputRef = useRef<TextInput>(null);
|
|
43
|
+
const suppressBlurRef = useRef(false);
|
|
44
|
+
const focusedIndexRef = useRef(focusedSegmentIndex);
|
|
45
|
+
focusedIndexRef.current = focusedSegmentIndex;
|
|
46
|
+
|
|
47
|
+
const isActive = focusedSegmentIndex != null && !disabled && !readOnly;
|
|
48
|
+
const draftDigits = segmentDraft.replace(/\D/g, '');
|
|
49
|
+
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
if (!isActive) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
suppressBlurRef.current = true;
|
|
56
|
+
const focusInput = () => {
|
|
57
|
+
inputRef.current?.focus();
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const frame = requestAnimationFrame(focusInput);
|
|
61
|
+
const timer = setTimeout(() => {
|
|
62
|
+
focusInput();
|
|
63
|
+
suppressBlurRef.current = false;
|
|
64
|
+
}, 50);
|
|
65
|
+
|
|
66
|
+
return () => {
|
|
67
|
+
cancelAnimationFrame(frame);
|
|
68
|
+
clearTimeout(timer);
|
|
69
|
+
};
|
|
70
|
+
}, [isActive, focusedSegmentIndex]);
|
|
71
|
+
|
|
72
|
+
const onKeyPress = (event: TextInputKeyPressEvent) => {
|
|
73
|
+
if (!isActive) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const key = event.nativeEvent.key;
|
|
77
|
+
if (key === 'Backspace') {
|
|
78
|
+
// When draft still has digits, onChangeText mirrors the shortened value.
|
|
79
|
+
// Only handle empty-draft backspace here (move to previous / clear).
|
|
80
|
+
if (draftDigits.length === 0) {
|
|
81
|
+
handleSegmentBackspace();
|
|
82
|
+
}
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (key === 'ArrowRight') {
|
|
86
|
+
focusNextEditableSegment();
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (key === 'ArrowLeft') {
|
|
90
|
+
focusPrevEditableSegment();
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<TextInput
|
|
96
|
+
testID="date-field-keyboard-input"
|
|
97
|
+
accessibilityLabel={accessibilityLabel}
|
|
98
|
+
accessibilityElementsHidden
|
|
99
|
+
importantForAccessibility="no-hide-descendants"
|
|
100
|
+
ref={inputRef}
|
|
101
|
+
value={isActive ? draftDigits : ''}
|
|
102
|
+
editable={isActive}
|
|
103
|
+
showSoftInputOnFocus={isActive}
|
|
104
|
+
pointerEvents="none"
|
|
105
|
+
caretHidden
|
|
106
|
+
importantForAutofill="no"
|
|
107
|
+
autoComplete="off"
|
|
108
|
+
autoCorrect={false}
|
|
109
|
+
spellCheck={false}
|
|
110
|
+
keyboardType={KEYBOARD_TYPE}
|
|
111
|
+
inputMode="numeric"
|
|
112
|
+
style={HIDDEN_INPUT_STYLE}
|
|
113
|
+
onChangeText={(text) => {
|
|
114
|
+
if (!isActive) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
handleSegmentInputChange(text);
|
|
118
|
+
}}
|
|
119
|
+
onKeyPress={onKeyPress}
|
|
120
|
+
onBlur={() => {
|
|
121
|
+
if (suppressBlurRef.current) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
requestAnimationFrame(() => {
|
|
125
|
+
if (suppressBlurRef.current) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const index = focusedIndexRef.current;
|
|
129
|
+
if (index == null) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (Platform.OS !== 'web') {
|
|
133
|
+
blurSegment(index);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const node = inputRef.current as unknown as { isFocused?: () => boolean } | null;
|
|
137
|
+
if (node?.isFocused?.()) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const active = typeof document !== 'undefined' ? document.activeElement : null;
|
|
141
|
+
if (active && (active as HTMLElement).tagName === 'INPUT') {
|
|
142
|
+
const label = (active as HTMLElement).getAttribute('aria-label');
|
|
143
|
+
if (label === accessibilityLabel) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
blurSegment(index);
|
|
148
|
+
});
|
|
149
|
+
}}
|
|
150
|
+
/>
|
|
151
|
+
);
|
|
152
|
+
}
|