@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
|
@@ -1,20 +1,27 @@
|
|
|
1
|
-
import { forwardRef } from 'react';
|
|
1
|
+
import { forwardRef, useContext, useEffect, useMemo, useRef } from 'react';
|
|
2
2
|
import { Pressable } from 'react-native';
|
|
3
3
|
import { VisuallyHidden } from '@react-aria/visually-hidden';
|
|
4
|
-
import {
|
|
4
|
+
import { composeEventHandlers, mergeRefs } from '@cdx-ui/utils';
|
|
5
5
|
import { useFocusRing } from '@react-native-aria/focus';
|
|
6
6
|
import { Slot } from '../slot';
|
|
7
7
|
import { dataAttributes, mergeDataAttributes } from '../utils/dataAttributes';
|
|
8
|
-
import { RadioProvider } from './context';
|
|
8
|
+
import { RadioGroupContext, RadioProvider } from './context';
|
|
9
9
|
import type { IRadioProps, IRadioContextValue } from './types';
|
|
10
10
|
import { useRadioRoot } from './useRadioRoot';
|
|
11
|
-
|
|
12
|
-
// TODO: Keyboard focus is not working as expected
|
|
11
|
+
import { getRovingFocusValue } from './useRadioGroupNavigation';
|
|
13
12
|
|
|
14
13
|
export interface RadioRootProps extends IRadioProps {
|
|
15
14
|
asChild?: boolean;
|
|
16
15
|
}
|
|
17
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Web Radio root.
|
|
19
|
+
*
|
|
20
|
+
* On web, `@react-native-aria/radio` re-exports `@react-aria/radio`'s `useRadio`,
|
|
21
|
+
* whose `inputProps` target a native `<input type="radio">` (selection via
|
|
22
|
+
* `onChange`). Selection must be applied explicitly on the Pressable —
|
|
23
|
+
* `inputProps.onPress` does **not** call `setSelectedValue`.
|
|
24
|
+
*/
|
|
18
25
|
export const RadioRoot = forwardRef<React.ComponentRef<typeof Pressable>, RadioRootProps>(
|
|
19
26
|
({ asChild, children, ...props }, ref) => {
|
|
20
27
|
const {
|
|
@@ -27,12 +34,13 @@ export const RadioRoot = forwardRef<React.ComponentRef<typeof Pressable>, RadioR
|
|
|
27
34
|
isPressed,
|
|
28
35
|
} = props;
|
|
29
36
|
|
|
37
|
+
const radioGroupContext = useContext(RadioGroupContext);
|
|
38
|
+
|
|
30
39
|
const {
|
|
31
40
|
combinedProps,
|
|
32
41
|
isInvalid,
|
|
33
42
|
isReadOnly,
|
|
34
43
|
inputProps,
|
|
35
|
-
labelProps,
|
|
36
44
|
isChecked,
|
|
37
45
|
isDisabled,
|
|
38
46
|
isHovered,
|
|
@@ -42,13 +50,80 @@ export const RadioRoot = forwardRef<React.ComponentRef<typeof Pressable>, RadioR
|
|
|
42
50
|
|
|
43
51
|
const { focusProps, isFocusVisible } = useFocusRing();
|
|
44
52
|
|
|
53
|
+
const nodeRef = useRef<React.ComponentRef<typeof Pressable> | null>(null);
|
|
54
|
+
const setRefs = mergeRefs(mergedRef, nodeRef);
|
|
55
|
+
|
|
56
|
+
// Strip native-input / internal props — they must not land on Pressable.
|
|
57
|
+
const {
|
|
58
|
+
onPress: _onPress,
|
|
59
|
+
onChange: _onChange,
|
|
60
|
+
role: _role,
|
|
61
|
+
tabIndex: _tabIndex,
|
|
62
|
+
disabled: _disabled,
|
|
63
|
+
checked: _checked,
|
|
64
|
+
value: _value,
|
|
65
|
+
type: _type,
|
|
66
|
+
name: _name,
|
|
67
|
+
form: _form,
|
|
68
|
+
required: _required,
|
|
69
|
+
...inputAriaProps
|
|
70
|
+
} = inputProps;
|
|
71
|
+
|
|
72
|
+
const resolvedDisabled = !!(isDisabled || isDisabledProp);
|
|
73
|
+
const resolvedReadOnly = !!(isReadOnly || isReadOnlyProp);
|
|
74
|
+
|
|
75
|
+
const selectThis = () => {
|
|
76
|
+
if (resolvedDisabled || resolvedReadOnly) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
radioGroupContext?.radioGroupState.setSelectedValue(combinedProps.value);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const selectedValue = radioGroupContext?.radioGroupState.selectedValue;
|
|
83
|
+
const focusedValue = radioGroupContext?.focusedValue;
|
|
84
|
+
const registerRadio = radioGroupContext?.registerRadio;
|
|
85
|
+
const unregisterRadio = radioGroupContext?.unregisterRadio;
|
|
86
|
+
const getRadios = radioGroupContext?.getRadios;
|
|
87
|
+
const groupName = radioGroupContext?.name;
|
|
88
|
+
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
if (!registerRadio || !unregisterRadio) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
registerRadio(combinedProps.value, {
|
|
95
|
+
disabled: !!resolvedDisabled,
|
|
96
|
+
node: nodeRef.current as { focus?: () => void } | null,
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
return () => unregisterRadio(combinedProps.value);
|
|
100
|
+
}, [combinedProps.value, resolvedDisabled, registerRadio, unregisterRadio]);
|
|
101
|
+
|
|
102
|
+
const isRovingTabStop = useMemo(() => {
|
|
103
|
+
if (resolvedDisabled) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const enabledRadios = getRadios?.().filter(([, entry]) => !entry.disabled) ?? [];
|
|
108
|
+
const rovingValue = getRovingFocusValue(focusedValue, selectedValue, enabledRadios);
|
|
109
|
+
|
|
110
|
+
return combinedProps.value === rovingValue;
|
|
111
|
+
}, [combinedProps.value, focusedValue, getRadios, resolvedDisabled, selectedValue]);
|
|
112
|
+
|
|
113
|
+
const handleKeyDown = (event: { key: string; preventDefault: () => void }) => {
|
|
114
|
+
if (event.key === ' ' || event.key === 'Spacebar') {
|
|
115
|
+
event.preventDefault();
|
|
116
|
+
selectThis();
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
45
120
|
const contextValue: IRadioContextValue = {
|
|
46
121
|
isChecked,
|
|
47
|
-
isDisabled:
|
|
122
|
+
isDisabled: resolvedDisabled,
|
|
48
123
|
isFocusVisible: isFocusVisible || isFocusVisibleProp,
|
|
49
124
|
isHovered: isHovered || isHoveredProp,
|
|
50
125
|
isInvalid: isInvalid || isInvalidProp,
|
|
51
|
-
isReadOnly:
|
|
126
|
+
isReadOnly: resolvedReadOnly,
|
|
52
127
|
isPressed,
|
|
53
128
|
isFocused,
|
|
54
129
|
};
|
|
@@ -57,31 +132,61 @@ export const RadioRoot = forwardRef<React.ComponentRef<typeof Pressable>, RadioR
|
|
|
57
132
|
|
|
58
133
|
return (
|
|
59
134
|
<RadioProvider value={contextValue}>
|
|
60
|
-
|
|
61
|
-
{...mergeProps(combinedProps as any, labelProps as any, focusProps as any)}
|
|
62
|
-
ref={mergedRef}
|
|
63
|
-
role="label"
|
|
64
|
-
// eslint-disable-next-line react-native-a11y/has-valid-accessibility-role
|
|
65
|
-
accessibilityRole="label"
|
|
66
|
-
{...mergeDataAttributes(
|
|
67
|
-
props,
|
|
68
|
-
dataAttributes({
|
|
69
|
-
checked: isChecked,
|
|
70
|
-
disabled: isDisabled || isDisabledProp,
|
|
71
|
-
hover: isHovered || isHoveredProp,
|
|
72
|
-
invalid: isInvalid || isInvalidProp,
|
|
73
|
-
readonly: isReadOnly || isReadOnlyProp,
|
|
74
|
-
active: isPressed,
|
|
75
|
-
focus: isFocused,
|
|
76
|
-
focusVisible: isFocusVisible || isFocusVisibleProp,
|
|
77
|
-
}),
|
|
78
|
-
)}
|
|
79
|
-
>
|
|
135
|
+
<>
|
|
80
136
|
<VisuallyHidden>
|
|
81
|
-
<input
|
|
137
|
+
<input
|
|
138
|
+
ref={inputRef as React.RefObject<HTMLInputElement>}
|
|
139
|
+
type="radio"
|
|
140
|
+
name={groupName}
|
|
141
|
+
value={combinedProps.value}
|
|
142
|
+
checked={!!isChecked}
|
|
143
|
+
disabled={resolvedDisabled}
|
|
144
|
+
tabIndex={-1}
|
|
145
|
+
aria-hidden
|
|
146
|
+
readOnly
|
|
147
|
+
// Decorative form mirror — pointer events must not steal clicks from Pressable.
|
|
148
|
+
style={{ pointerEvents: 'none' }}
|
|
149
|
+
/>
|
|
82
150
|
</VisuallyHidden>
|
|
83
|
-
|
|
84
|
-
|
|
151
|
+
<Comp
|
|
152
|
+
{...(combinedProps as object)}
|
|
153
|
+
{...inputAriaProps}
|
|
154
|
+
ref={setRefs}
|
|
155
|
+
role="radio"
|
|
156
|
+
aria-checked={isChecked}
|
|
157
|
+
aria-disabled={resolvedDisabled || undefined}
|
|
158
|
+
accessibilityRole="radio"
|
|
159
|
+
accessibilityState={{ checked: isChecked, disabled: resolvedDisabled }}
|
|
160
|
+
tabIndex={resolvedDisabled ? -1 : isRovingTabStop ? 0 : -1}
|
|
161
|
+
disabled={resolvedDisabled}
|
|
162
|
+
{...focusProps}
|
|
163
|
+
onPress={selectThis}
|
|
164
|
+
onClick={selectThis}
|
|
165
|
+
onKeyDown={composeEventHandlers(
|
|
166
|
+
(
|
|
167
|
+
combinedProps as {
|
|
168
|
+
onKeyDown?: (e: { key: string; preventDefault: () => void }) => void;
|
|
169
|
+
}
|
|
170
|
+
).onKeyDown,
|
|
171
|
+
handleKeyDown,
|
|
172
|
+
)}
|
|
173
|
+
{...mergeDataAttributes(
|
|
174
|
+
props,
|
|
175
|
+
dataAttributes({
|
|
176
|
+
checked: isChecked,
|
|
177
|
+
disabled: resolvedDisabled,
|
|
178
|
+
hover: isHovered || isHoveredProp,
|
|
179
|
+
invalid: isInvalid || isInvalidProp,
|
|
180
|
+
readonly: resolvedReadOnly,
|
|
181
|
+
active: isPressed,
|
|
182
|
+
focus: isFocused,
|
|
183
|
+
focusVisible: isFocusVisible || isFocusVisibleProp,
|
|
184
|
+
}),
|
|
185
|
+
)}
|
|
186
|
+
>
|
|
187
|
+
{children}
|
|
188
|
+
</Comp>
|
|
189
|
+
</>
|
|
85
190
|
</RadioProvider>
|
|
86
191
|
);
|
|
87
192
|
},
|
package/src/radio/context.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { createContext } from '@cdx-ui/utils';
|
|
3
3
|
import type { RadioGroupState } from '@react-stately/radio';
|
|
4
|
-
import type { IRadioContextValue } from './types';
|
|
4
|
+
import type { IRadioContextValue, RegisteredRadio } from './types';
|
|
5
5
|
|
|
6
6
|
export const [RadioProvider, useRadioContext] = createContext<IRadioContextValue>('RadioContext');
|
|
7
7
|
|
|
@@ -18,4 +18,9 @@ export const RadioGroupContext = React.createContext<{
|
|
|
18
18
|
state: IRadioGroupState;
|
|
19
19
|
radioGroupState: RadioGroupState;
|
|
20
20
|
name?: string;
|
|
21
|
+
focusedValue?: string | undefined;
|
|
22
|
+
setFocusedValue?: (value: string | undefined) => void;
|
|
23
|
+
registerRadio?: (value: string, entry: RegisteredRadio) => void;
|
|
24
|
+
unregisterRadio?: (value: string) => void;
|
|
25
|
+
getRadios?: () => [string, RegisteredRadio][];
|
|
21
26
|
} | null>(null);
|
package/src/radio/types.ts
CHANGED
|
@@ -43,3 +43,9 @@ export interface IRadioContextValue {
|
|
|
43
43
|
isHovered?: boolean;
|
|
44
44
|
isPressed?: boolean;
|
|
45
45
|
}
|
|
46
|
+
|
|
47
|
+
/** Web roving-focus registration entry for a single radio item. */
|
|
48
|
+
export interface RegisteredRadio {
|
|
49
|
+
disabled: boolean;
|
|
50
|
+
node: { focus?: () => void } | null;
|
|
51
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { useCallback, useRef } from 'react';
|
|
2
|
+
import type { RegisteredRadio } from './types';
|
|
3
|
+
|
|
4
|
+
// Web-only — native platforms rely on OS-managed sequential focus (VoiceOver/TalkBack).
|
|
5
|
+
|
|
6
|
+
function isEnabledRadioValue(
|
|
7
|
+
value: string | null | undefined,
|
|
8
|
+
enabledRadios: [string, RegisteredRadio][],
|
|
9
|
+
): value is string {
|
|
10
|
+
return value != null && enabledRadios.some(([radioValue]) => radioValue === value);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Resolves which radio value should hold the roving tab stop / keyboard focus anchor. */
|
|
14
|
+
export function getRovingFocusValue(
|
|
15
|
+
focusedValue: string | undefined,
|
|
16
|
+
selectedValue: string | null | undefined,
|
|
17
|
+
enabledRadios: [string, RegisteredRadio][],
|
|
18
|
+
): string | undefined {
|
|
19
|
+
const defaultFocusValue = isEnabledRadioValue(selectedValue, enabledRadios)
|
|
20
|
+
? selectedValue
|
|
21
|
+
: enabledRadios[0]?.[0];
|
|
22
|
+
|
|
23
|
+
const resolvedFocusedValue = isEnabledRadioValue(focusedValue, enabledRadios)
|
|
24
|
+
? focusedValue
|
|
25
|
+
: undefined;
|
|
26
|
+
|
|
27
|
+
return resolvedFocusedValue ?? defaultFocusValue;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface UseRadioGroupNavigationOptions {
|
|
31
|
+
getRadios: () => [string, RegisteredRadio][];
|
|
32
|
+
focusedValue: string | undefined;
|
|
33
|
+
setFocusedValue: (value: string | undefined) => void;
|
|
34
|
+
selectedValue: string | null | undefined;
|
|
35
|
+
selectValue: (value: string) => void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function useRadioGroupNavigation({
|
|
39
|
+
getRadios,
|
|
40
|
+
focusedValue,
|
|
41
|
+
setFocusedValue,
|
|
42
|
+
selectedValue,
|
|
43
|
+
selectValue,
|
|
44
|
+
}: UseRadioGroupNavigationOptions) {
|
|
45
|
+
const selectValueRef = useRef(selectValue);
|
|
46
|
+
selectValueRef.current = selectValue;
|
|
47
|
+
|
|
48
|
+
const getEnabledRadios = useCallback(
|
|
49
|
+
() => getRadios().filter(([, entry]) => !entry.disabled),
|
|
50
|
+
[getRadios],
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const moveFocus = useCallback(
|
|
54
|
+
([targetValue, targetEntry]: [string, RegisteredRadio]) => {
|
|
55
|
+
setFocusedValue(targetValue);
|
|
56
|
+
targetEntry.node?.focus?.();
|
|
57
|
+
selectValueRef.current(targetValue);
|
|
58
|
+
},
|
|
59
|
+
[setFocusedValue],
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
const handleKeyDown = useCallback(
|
|
63
|
+
(e: { key: string; preventDefault: () => void }) => {
|
|
64
|
+
const enabledRadios = getEnabledRadios();
|
|
65
|
+
if (enabledRadios.length === 0) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const currentValue = getRovingFocusValue(focusedValue, selectedValue, enabledRadios);
|
|
70
|
+
const idx = enabledRadios.findIndex(([value]) => value === currentValue);
|
|
71
|
+
|
|
72
|
+
switch (e.key) {
|
|
73
|
+
case 'ArrowDown':
|
|
74
|
+
case 'ArrowRight': {
|
|
75
|
+
e.preventDefault();
|
|
76
|
+
moveFocus(enabledRadios[idx < enabledRadios.length - 1 ? idx + 1 : 0]);
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
case 'ArrowUp':
|
|
80
|
+
case 'ArrowLeft': {
|
|
81
|
+
e.preventDefault();
|
|
82
|
+
moveFocus(enabledRadios[idx > 0 ? idx - 1 : enabledRadios.length - 1]);
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
case 'Home': {
|
|
86
|
+
e.preventDefault();
|
|
87
|
+
moveFocus(enabledRadios[0]);
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
case 'End': {
|
|
91
|
+
e.preventDefault();
|
|
92
|
+
const last = enabledRadios.at(-1);
|
|
93
|
+
if (last) {
|
|
94
|
+
moveFocus(last);
|
|
95
|
+
}
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
[focusedValue, selectedValue, getEnabledRadios, moveFocus],
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
return { handleKeyDown };
|
|
104
|
+
}
|
|
@@ -15,12 +15,6 @@ export function useRadioRoot(
|
|
|
15
15
|
{ useInputRefForAria = false }: UseRadioRootOptions = {},
|
|
16
16
|
) {
|
|
17
17
|
const formControlContext = useFormControlContext();
|
|
18
|
-
|
|
19
|
-
const { isInvalid, isReadOnly, ...combinedProps } = {
|
|
20
|
-
...formControlContext,
|
|
21
|
-
...props,
|
|
22
|
-
};
|
|
23
|
-
|
|
24
18
|
const radioGroupContext = useContext(RadioGroupContext);
|
|
25
19
|
|
|
26
20
|
if (!radioGroupContext) {
|
|
@@ -29,17 +23,30 @@ export function useRadioRoot(
|
|
|
29
23
|
);
|
|
30
24
|
}
|
|
31
25
|
|
|
26
|
+
const isInvalid = props.isInvalid ?? formControlContext.isInvalid;
|
|
27
|
+
const isReadOnly =
|
|
28
|
+
props.isReadOnly ?? formControlContext.isReadOnly ?? radioGroupContext.state.isReadOnly;
|
|
29
|
+
const isDisabled =
|
|
30
|
+
props.isDisabled ?? formControlContext.isDisabled ?? radioGroupContext.state.isDisabled;
|
|
31
|
+
|
|
32
|
+
const combinedProps = {
|
|
33
|
+
...props,
|
|
34
|
+
isInvalid,
|
|
35
|
+
isReadOnly,
|
|
36
|
+
isDisabled,
|
|
37
|
+
};
|
|
38
|
+
|
|
32
39
|
const rootRef = useRef(null);
|
|
33
40
|
const inputRef = useRef<HTMLInputElement | null>(null);
|
|
34
41
|
const mergedRootRef = mergeRefs(ref as any, rootRef as any);
|
|
35
|
-
const ariaLabel =
|
|
42
|
+
const ariaLabel = props['aria-label'] || props.value || 'Radio';
|
|
36
43
|
|
|
37
44
|
const radio = useRadio(
|
|
38
45
|
{
|
|
39
46
|
...combinedProps,
|
|
40
47
|
'aria-label': ariaLabel,
|
|
41
|
-
isReadOnly
|
|
42
|
-
isDisabled
|
|
48
|
+
isReadOnly,
|
|
49
|
+
isDisabled,
|
|
43
50
|
} as any,
|
|
44
51
|
radioGroupContext.radioGroupState,
|
|
45
52
|
(useInputRefForAria ? inputRef : rootRef) as any,
|
|
@@ -49,7 +56,7 @@ export function useRadioRoot(
|
|
|
49
56
|
labelProps?: Record<string, unknown>;
|
|
50
57
|
};
|
|
51
58
|
|
|
52
|
-
const { checked: isChecked, disabled:
|
|
59
|
+
const { checked: isChecked, disabled: isDisabledFromInput } = inputProps;
|
|
53
60
|
|
|
54
61
|
const { hoverProps, isHovered } = useHover({}, rootRef);
|
|
55
62
|
|
|
@@ -60,7 +67,7 @@ export function useRadioRoot(
|
|
|
60
67
|
inputProps,
|
|
61
68
|
labelProps: labelProps ?? {},
|
|
62
69
|
isChecked,
|
|
63
|
-
isDisabled,
|
|
70
|
+
isDisabled: isDisabledFromInput,
|
|
64
71
|
isHovered,
|
|
65
72
|
hoverProps,
|
|
66
73
|
mergedRef: mergedRootRef,
|
|
@@ -0,0 +1,213 @@
|
|
|
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
|
+
normalizeDateRange,
|
|
14
|
+
resolveDateComponentLabels,
|
|
15
|
+
todayMonthId,
|
|
16
|
+
toMonthId,
|
|
17
|
+
type DateComponentLabels,
|
|
18
|
+
type DateId,
|
|
19
|
+
type MonthId,
|
|
20
|
+
} from '@cdx-ui/formatters';
|
|
21
|
+
import { useControllableState } from '@cdx-ui/utils';
|
|
22
|
+
import { Slot } from '../slot';
|
|
23
|
+
import { accessibleLabelAttributes, resolveAccessibleLabel } from '../utils/accessibleLabel';
|
|
24
|
+
import { dataAttributes, mergeDataAttributes } from '../utils/dataAttributes';
|
|
25
|
+
import type { CalendarView } from '../calendar/context';
|
|
26
|
+
import { RangeCalendarContext, type RangeCalendarFocus } from './context';
|
|
27
|
+
|
|
28
|
+
export interface RangeCalendarRootProps extends Omit<ViewProps, 'children'> {
|
|
29
|
+
asChild?: boolean;
|
|
30
|
+
children?: ReactNode;
|
|
31
|
+
className?: string;
|
|
32
|
+
startValue?: DateId;
|
|
33
|
+
endValue?: DateId;
|
|
34
|
+
defaultStartValue?: DateId;
|
|
35
|
+
defaultEndValue?: DateId;
|
|
36
|
+
onRangeChange?: (range: { startId?: DateId; endId?: DateId }) => void;
|
|
37
|
+
monthId?: MonthId;
|
|
38
|
+
defaultMonthId?: MonthId;
|
|
39
|
+
onMonthIdChange?: (monthId: MonthId) => void;
|
|
40
|
+
focusedField?: RangeCalendarFocus;
|
|
41
|
+
defaultFocusedField?: RangeCalendarFocus;
|
|
42
|
+
onFocusedFieldChange?: (field: RangeCalendarFocus) => void;
|
|
43
|
+
/** Earliest selectable date. Build with `dateId(...)` from `@cdx-ui/formatters`. */
|
|
44
|
+
minValue?: DateId;
|
|
45
|
+
/** Latest selectable date. Build with `dateId(...)` from `@cdx-ui/formatters`. */
|
|
46
|
+
maxValue?: DateId;
|
|
47
|
+
disabled?: boolean;
|
|
48
|
+
locale?: string;
|
|
49
|
+
labels?: Partial<DateComponentLabels>;
|
|
50
|
+
/** Accessible name for the range-calendar region. */
|
|
51
|
+
accessibilityLabel?: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const RangeCalendarRoot = forwardRef<ComponentRef<typeof View>, RangeCalendarRootProps>(
|
|
55
|
+
(props, ref) => {
|
|
56
|
+
const {
|
|
57
|
+
asChild,
|
|
58
|
+
children,
|
|
59
|
+
startValue: startProp,
|
|
60
|
+
endValue: endProp,
|
|
61
|
+
defaultStartValue,
|
|
62
|
+
defaultEndValue,
|
|
63
|
+
onRangeChange,
|
|
64
|
+
monthId: monthIdProp,
|
|
65
|
+
defaultMonthId,
|
|
66
|
+
onMonthIdChange,
|
|
67
|
+
focusedField: focusedProp,
|
|
68
|
+
defaultFocusedField = 'start',
|
|
69
|
+
onFocusedFieldChange,
|
|
70
|
+
minValue,
|
|
71
|
+
maxValue,
|
|
72
|
+
disabled = false,
|
|
73
|
+
locale = 'en-US',
|
|
74
|
+
labels: labelsProp,
|
|
75
|
+
accessibilityLabel: accessibilityLabelProp,
|
|
76
|
+
'aria-label': ariaLabelProp,
|
|
77
|
+
...rest
|
|
78
|
+
} = props;
|
|
79
|
+
|
|
80
|
+
const labels = useMemo(() => resolveDateComponentLabels(labelsProp), [labelsProp]);
|
|
81
|
+
const accessibilityLabel = resolveAccessibleLabel({
|
|
82
|
+
accessibilityLabel: accessibilityLabelProp,
|
|
83
|
+
'aria-label': ariaLabelProp,
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const isRangeControlled = 'startValue' in props || 'endValue' in props;
|
|
87
|
+
const [uncontrolledStart, setUncontrolledStart] = useState<DateId | undefined>(
|
|
88
|
+
defaultStartValue,
|
|
89
|
+
);
|
|
90
|
+
const [uncontrolledEnd, setUncontrolledEnd] = useState<DateId | undefined>(defaultEndValue);
|
|
91
|
+
|
|
92
|
+
const startId = isRangeControlled ? startProp : uncontrolledStart;
|
|
93
|
+
const endId = isRangeControlled ? endProp : uncontrolledEnd;
|
|
94
|
+
|
|
95
|
+
const [monthId, setMonthId] = useControllableState<MonthId>({
|
|
96
|
+
prop: monthIdProp,
|
|
97
|
+
defaultProp:
|
|
98
|
+
defaultMonthId ??
|
|
99
|
+
(startId ? toMonthId(startId) : endId ? toMonthId(endId) : todayMonthId()),
|
|
100
|
+
onChange: onMonthIdChange,
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const prevRangeRef = useRef({ startId, endId });
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
if (monthIdProp !== undefined) {
|
|
106
|
+
prevRangeRef.current = { startId, endId };
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (prevRangeRef.current.startId === startId && prevRangeRef.current.endId === endId) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
prevRangeRef.current = { startId, endId };
|
|
113
|
+
const anchor = startId ?? endId;
|
|
114
|
+
if (anchor !== undefined) {
|
|
115
|
+
setMonthId(toMonthId(anchor));
|
|
116
|
+
}
|
|
117
|
+
}, [endId, monthIdProp, setMonthId, startId]);
|
|
118
|
+
|
|
119
|
+
const [focusedField, setFocusedField] = useControllableState<RangeCalendarFocus>({
|
|
120
|
+
prop: focusedProp,
|
|
121
|
+
defaultProp: defaultFocusedField,
|
|
122
|
+
onChange: onFocusedFieldChange,
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
const [view, setViewState] = useState<CalendarView>('month');
|
|
126
|
+
|
|
127
|
+
const setView = useCallback((next: CalendarView) => {
|
|
128
|
+
setViewState(next);
|
|
129
|
+
}, []);
|
|
130
|
+
|
|
131
|
+
const onDayPress = useCallback(
|
|
132
|
+
(dateId: DateId) => {
|
|
133
|
+
if (disabled) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
let next: { startId: DateId; endId?: DateId };
|
|
138
|
+
|
|
139
|
+
// Empty or complete range → start a new selection at this day.
|
|
140
|
+
if (!startId || endId) {
|
|
141
|
+
next = { startId: dateId, endId: undefined };
|
|
142
|
+
setFocusedField('end');
|
|
143
|
+
} else {
|
|
144
|
+
// Incomplete range (start only) → set end and normalize order.
|
|
145
|
+
next = normalizeDateRange({ startId, endId: dateId });
|
|
146
|
+
setFocusedField('start');
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (!isRangeControlled) {
|
|
150
|
+
setUncontrolledStart(next.startId);
|
|
151
|
+
setUncontrolledEnd(next.endId);
|
|
152
|
+
}
|
|
153
|
+
onRangeChange?.(next);
|
|
154
|
+
},
|
|
155
|
+
[disabled, endId, isRangeControlled, onRangeChange, setFocusedField, startId],
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
const contextValue = useMemo(
|
|
159
|
+
() => ({
|
|
160
|
+
startId,
|
|
161
|
+
endId,
|
|
162
|
+
onRangeChange,
|
|
163
|
+
monthId: monthId ?? todayMonthId(),
|
|
164
|
+
onMonthIdChange: setMonthId,
|
|
165
|
+
focusedField: focusedField ?? 'start',
|
|
166
|
+
onFocusedFieldChange: setFocusedField,
|
|
167
|
+
minValue,
|
|
168
|
+
maxValue,
|
|
169
|
+
disabled,
|
|
170
|
+
locale,
|
|
171
|
+
labels,
|
|
172
|
+
onDayPress,
|
|
173
|
+
view,
|
|
174
|
+
setView,
|
|
175
|
+
}),
|
|
176
|
+
[
|
|
177
|
+
startId,
|
|
178
|
+
endId,
|
|
179
|
+
onRangeChange,
|
|
180
|
+
monthId,
|
|
181
|
+
setMonthId,
|
|
182
|
+
focusedField,
|
|
183
|
+
setFocusedField,
|
|
184
|
+
minValue,
|
|
185
|
+
maxValue,
|
|
186
|
+
disabled,
|
|
187
|
+
locale,
|
|
188
|
+
labels,
|
|
189
|
+
onDayPress,
|
|
190
|
+
view,
|
|
191
|
+
setView,
|
|
192
|
+
],
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
const Comp = asChild ? Slot : View;
|
|
196
|
+
|
|
197
|
+
return (
|
|
198
|
+
<RangeCalendarContext.Provider value={contextValue}>
|
|
199
|
+
<Comp
|
|
200
|
+
ref={ref}
|
|
201
|
+
accessibilityRole="none"
|
|
202
|
+
{...rest}
|
|
203
|
+
{...mergeDataAttributes(rest, dataAttributes({ disabled }))}
|
|
204
|
+
{...accessibleLabelAttributes(accessibilityLabel)}
|
|
205
|
+
>
|
|
206
|
+
{children}
|
|
207
|
+
</Comp>
|
|
208
|
+
</RangeCalendarContext.Provider>
|
|
209
|
+
);
|
|
210
|
+
},
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
RangeCalendarRoot.displayName = 'RangeCalendarRoot';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
import type { DateComponentLabels, DateId, MonthId } from '@cdx-ui/formatters';
|
|
3
|
+
import type { CalendarView } from '../calendar/context';
|
|
4
|
+
|
|
5
|
+
export type RangeCalendarFocus = 'start' | 'end';
|
|
6
|
+
|
|
7
|
+
export interface RangeCalendarContextValue {
|
|
8
|
+
startId?: DateId;
|
|
9
|
+
endId?: DateId;
|
|
10
|
+
onRangeChange?: (range: { startId?: DateId; endId?: DateId }) => void;
|
|
11
|
+
monthId: MonthId;
|
|
12
|
+
onMonthIdChange: (monthId: MonthId) => void;
|
|
13
|
+
focusedField: RangeCalendarFocus;
|
|
14
|
+
onFocusedFieldChange: (field: RangeCalendarFocus) => void;
|
|
15
|
+
minValue?: DateId;
|
|
16
|
+
maxValue?: DateId;
|
|
17
|
+
disabled: boolean;
|
|
18
|
+
locale: string;
|
|
19
|
+
labels: DateComponentLabels;
|
|
20
|
+
onDayPress: (dateId: DateId) => void;
|
|
21
|
+
view: CalendarView;
|
|
22
|
+
setView: (view: CalendarView) => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const RangeCalendarContext = createContext<RangeCalendarContextValue | null>(null);
|
|
26
|
+
|
|
27
|
+
export function useRangeCalendarContext(): RangeCalendarContextValue {
|
|
28
|
+
const ctx = useContext(RangeCalendarContext);
|
|
29
|
+
if (!ctx) {
|
|
30
|
+
throw new Error('RangeCalendar compound components must be used within RangeCalendarRoot');
|
|
31
|
+
}
|
|
32
|
+
return ctx;
|
|
33
|
+
}
|
package/src/select/types.ts
CHANGED
|
@@ -17,7 +17,8 @@ export interface ISelectProps {
|
|
|
17
17
|
value?: string;
|
|
18
18
|
defaultValue?: string;
|
|
19
19
|
onValueChange?: (value: string) => void;
|
|
20
|
-
open
|
|
20
|
+
/** Controlled open state. Use `defaultOpen` for the uncontrolled variant. */
|
|
21
|
+
isOpen?: boolean;
|
|
21
22
|
defaultOpen?: boolean;
|
|
22
23
|
onOpenChange?: (open: boolean) => void;
|
|
23
24
|
disabled?: boolean;
|