@proyecto-viviana/solidaria 0.4.0 → 0.4.2
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/dist/_chunk/DragManager.js +627 -0
- package/dist/_chunk/DragManager.js.map +1 -0
- package/dist/_chunk/DragManager.jsx +627 -0
- package/dist/_chunk/DragManager.jsx.map +1 -0
- package/dist/_chunk/FocusScope.js +400 -0
- package/dist/_chunk/FocusScope.js.map +1 -0
- package/dist/_chunk/FocusScope.jsx +375 -0
- package/dist/_chunk/FocusScope.jsx.map +1 -0
- package/dist/_chunk/actiongroup.js +13 -79
- package/dist/_chunk/actiongroup.js.map +1 -1
- package/dist/_chunk/actiongroup.jsx +13 -79
- package/dist/_chunk/actiongroup.jsx.map +1 -1
- package/dist/_chunk/{live-announcer.js → announce.js} +1 -1
- package/dist/_chunk/announce.js.map +1 -0
- package/dist/_chunk/{live-announcer.jsx → announce.jsx} +1 -1
- package/dist/_chunk/announce.jsx.map +1 -0
- package/dist/_chunk/autocomplete.js +56 -8
- package/dist/_chunk/autocomplete.js.map +1 -1
- package/dist/_chunk/autocomplete.jsx +56 -8
- package/dist/_chunk/autocomplete.jsx.map +1 -1
- package/dist/_chunk/breadcrumbs.js +6 -4
- package/dist/_chunk/breadcrumbs.js.map +1 -1
- package/dist/_chunk/breadcrumbs.jsx +6 -4
- package/dist/_chunk/breadcrumbs.jsx.map +1 -1
- package/dist/_chunk/button.js +8 -9
- package/dist/_chunk/button.js.map +1 -1
- package/dist/_chunk/button.jsx +8 -9
- package/dist/_chunk/button.jsx.map +1 -1
- package/dist/_chunk/calendar.js +27 -26
- package/dist/_chunk/calendar.js.map +1 -1
- package/dist/_chunk/calendar.jsx +27 -26
- package/dist/_chunk/calendar.jsx.map +1 -1
- package/dist/_chunk/checkbox.js +5 -4
- package/dist/_chunk/checkbox.js.map +1 -1
- package/dist/_chunk/checkbox.jsx +5 -4
- package/dist/_chunk/checkbox.jsx.map +1 -1
- package/dist/_chunk/color.js +302 -18
- package/dist/_chunk/color.js.map +1 -1
- package/dist/_chunk/color.jsx +302 -18
- package/dist/_chunk/color.jsx.map +1 -1
- package/dist/_chunk/combobox.js +638 -12
- package/dist/_chunk/combobox.js.map +1 -1
- package/dist/_chunk/combobox.jsx +638 -12
- package/dist/_chunk/combobox.jsx.map +1 -1
- package/dist/_chunk/constants.js +19 -0
- package/dist/_chunk/constants.js.map +1 -0
- package/dist/_chunk/constants.jsx +19 -0
- package/dist/_chunk/constants.jsx.map +1 -0
- package/dist/_chunk/createCollator.js +3 -171
- package/dist/_chunk/createCollator.js.map +1 -1
- package/dist/_chunk/createCollator.jsx +3 -165
- package/dist/_chunk/createCollator.jsx.map +1 -1
- package/dist/_chunk/createField.js +2 -1
- package/dist/_chunk/createField.js.map +1 -1
- package/dist/_chunk/createField.jsx +2 -1
- package/dist/_chunk/createField.jsx.map +1 -1
- package/dist/_chunk/createFocus.js +12 -8
- package/dist/_chunk/createFocus.js.map +1 -1
- package/dist/_chunk/createFocus.jsx +12 -8
- package/dist/_chunk/createFocus.jsx.map +1 -1
- package/dist/_chunk/createFocusWithin.js +12 -13
- package/dist/_chunk/createFocusWithin.js.map +1 -1
- package/dist/_chunk/createFocusWithin.jsx +12 -13
- package/dist/_chunk/createFocusWithin.jsx.map +1 -1
- package/dist/_chunk/createFocusable.js +3 -3
- package/dist/_chunk/createFocusable.js.map +1 -1
- package/dist/_chunk/createFocusable.jsx +3 -3
- package/dist/_chunk/createFocusable.jsx.map +1 -1
- package/dist/_chunk/{form.js → createFormReset.js} +1 -1
- package/dist/_chunk/createFormReset.js.map +1 -0
- package/dist/_chunk/{form.jsx → createFormReset.jsx} +1 -1
- package/dist/_chunk/createFormReset.jsx.map +1 -0
- package/dist/_chunk/createHover.js +2 -1
- package/dist/_chunk/createHover.js.map +1 -1
- package/dist/_chunk/createHover.jsx +2 -1
- package/dist/_chunk/createHover.jsx.map +1 -1
- package/dist/_chunk/createInteractionModality.js +2 -3
- package/dist/_chunk/createInteractionModality.js.map +1 -1
- package/dist/_chunk/createInteractionModality.jsx +2 -3
- package/dist/_chunk/createInteractionModality.jsx.map +1 -1
- package/dist/_chunk/createLabel.js +2 -1
- package/dist/_chunk/createLabel.js.map +1 -1
- package/dist/_chunk/createLabel.jsx +2 -1
- package/dist/_chunk/createLabel.jsx.map +1 -1
- package/dist/_chunk/createLabels.js +3 -2
- package/dist/_chunk/createLabels.js.map +1 -1
- package/dist/_chunk/createLabels.jsx +3 -2
- package/dist/_chunk/createLabels.jsx.map +1 -1
- package/dist/_chunk/createLandmark.js +1 -1
- package/dist/_chunk/createLandmark.jsx +1 -1
- package/dist/_chunk/createProgressBar.js +2 -1
- package/dist/_chunk/createProgressBar.js.map +1 -1
- package/dist/_chunk/createProgressBar.jsx +2 -1
- package/dist/_chunk/createProgressBar.jsx.map +1 -1
- package/dist/_chunk/createSelectableItem.js +7 -3
- package/dist/_chunk/createSelectableItem.js.map +1 -1
- package/dist/_chunk/createSelectableItem.jsx +7 -3
- package/dist/_chunk/createSelectableItem.jsx.map +1 -1
- package/dist/_chunk/createStringFormatter.js +61 -0
- package/dist/_chunk/createStringFormatter.js.map +1 -0
- package/dist/_chunk/createStringFormatter.jsx +61 -0
- package/dist/_chunk/createStringFormatter.jsx.map +1 -0
- package/dist/_chunk/createToggle.js +5 -4
- package/dist/_chunk/createToggle.js.map +1 -1
- package/dist/_chunk/createToggle.jsx +5 -4
- package/dist/_chunk/createToggle.jsx.map +1 -1
- package/dist/_chunk/datepicker.js +1413 -1100
- package/dist/_chunk/datepicker.js.map +1 -1
- package/dist/_chunk/datepicker.jsx +1413 -1100
- package/dist/_chunk/datepicker.jsx.map +1 -1
- package/dist/_chunk/disclosure.js +2 -2
- package/dist/_chunk/disclosure.js.map +1 -1
- package/dist/_chunk/disclosure.jsx +2 -2
- package/dist/_chunk/disclosure.jsx.map +1 -1
- package/dist/_chunk/dnd.js +1586 -495
- package/dist/_chunk/dnd.js.map +1 -1
- package/dist/_chunk/dnd.jsx +1586 -495
- package/dist/_chunk/dnd.jsx.map +1 -1
- package/dist/_chunk/env.js +1 -19
- package/dist/_chunk/env.js.map +1 -1
- package/dist/_chunk/env.jsx +1 -19
- package/dist/_chunk/env.jsx.map +1 -1
- package/dist/_chunk/focus.js +1 -1
- package/dist/_chunk/focus.js.map +1 -1
- package/dist/_chunk/focus.jsx +1 -1
- package/dist/_chunk/focus.jsx.map +1 -1
- package/dist/_chunk/focus2.js +54 -318
- package/dist/_chunk/focus2.js.map +1 -1
- package/dist/_chunk/focus2.jsx +53 -292
- package/dist/_chunk/focus2.jsx.map +1 -1
- package/dist/_chunk/grid.js +1 -1
- package/dist/_chunk/grid.jsx +1 -1
- package/dist/_chunk/gridlist.js +14 -9
- package/dist/_chunk/gridlist.js.map +1 -1
- package/dist/_chunk/gridlist.jsx +14 -9
- package/dist/_chunk/gridlist.jsx.map +1 -1
- package/dist/_chunk/i18n.js +3 -58
- package/dist/_chunk/i18n.js.map +1 -1
- package/dist/_chunk/i18n.jsx +3 -58
- package/dist/_chunk/i18n.jsx.map +1 -1
- package/dist/_chunk/interactions.js +99 -9
- package/dist/_chunk/interactions.js.map +1 -1
- package/dist/_chunk/interactions.jsx +97 -9
- package/dist/_chunk/interactions.jsx.map +1 -1
- package/dist/_chunk/link.js +2 -1
- package/dist/_chunk/link.js.map +1 -1
- package/dist/_chunk/link.jsx +2 -1
- package/dist/_chunk/link.jsx.map +1 -1
- package/dist/_chunk/listbox.js +42 -10
- package/dist/_chunk/listbox.js.map +1 -1
- package/dist/_chunk/listbox.jsx +42 -10
- package/dist/_chunk/listbox.jsx.map +1 -1
- package/dist/_chunk/locale.js +173 -0
- package/dist/_chunk/locale.js.map +1 -0
- package/dist/_chunk/locale.jsx +167 -0
- package/dist/_chunk/locale.jsx.map +1 -0
- package/dist/_chunk/menu.js +5 -4
- package/dist/_chunk/menu.js.map +1 -1
- package/dist/_chunk/menu.jsx +5 -4
- package/dist/_chunk/menu.jsx.map +1 -1
- package/dist/_chunk/numberfield.js +3 -2
- package/dist/_chunk/numberfield.js.map +1 -1
- package/dist/_chunk/numberfield.jsx +3 -2
- package/dist/_chunk/numberfield.jsx.map +1 -1
- package/dist/_chunk/overlays.js +1 -1
- package/dist/_chunk/overlays.jsx +1 -1
- package/dist/_chunk/popover.js +3 -3
- package/dist/_chunk/popover.js.map +1 -1
- package/dist/_chunk/popover.jsx +3 -3
- package/dist/_chunk/popover.jsx.map +1 -1
- package/dist/_chunk/radio.js +7 -6
- package/dist/_chunk/radio.js.map +1 -1
- package/dist/_chunk/radio.jsx +7 -6
- package/dist/_chunk/radio.jsx.map +1 -1
- package/dist/_chunk/reactivity.js +21 -0
- package/dist/_chunk/reactivity.js.map +1 -0
- package/dist/_chunk/reactivity.jsx +21 -0
- package/dist/_chunk/reactivity.jsx.map +1 -0
- package/dist/_chunk/searchfield.js +2 -1
- package/dist/_chunk/searchfield.js.map +1 -1
- package/dist/_chunk/searchfield.jsx +2 -1
- package/dist/_chunk/searchfield.jsx.map +1 -1
- package/dist/_chunk/select.js +8 -5
- package/dist/_chunk/select.js.map +1 -1
- package/dist/_chunk/select.jsx +8 -5
- package/dist/_chunk/select.jsx.map +1 -1
- package/dist/_chunk/selection.js +8 -21
- package/dist/_chunk/selection.js.map +1 -1
- package/dist/_chunk/selection.jsx +8 -21
- package/dist/_chunk/selection.jsx.map +1 -1
- package/dist/_chunk/separator.js +1 -1
- package/dist/_chunk/separator.jsx +1 -1
- package/dist/_chunk/slider.js +5 -4
- package/dist/_chunk/slider.js.map +1 -1
- package/dist/_chunk/slider.jsx +5 -4
- package/dist/_chunk/slider.jsx.map +1 -1
- package/dist/_chunk/spinbutton.js +153 -0
- package/dist/_chunk/spinbutton.js.map +1 -0
- package/dist/_chunk/spinbutton.jsx +153 -0
- package/dist/_chunk/spinbutton.jsx.map +1 -0
- package/dist/_chunk/table.js +45 -8
- package/dist/_chunk/table.js.map +1 -1
- package/dist/_chunk/table.jsx +45 -8
- package/dist/_chunk/table.jsx.map +1 -1
- package/dist/_chunk/tabs.js +11 -8
- package/dist/_chunk/tabs.js.map +1 -1
- package/dist/_chunk/tabs.jsx +11 -8
- package/dist/_chunk/tabs.jsx.map +1 -1
- package/dist/_chunk/tag.js +54 -18
- package/dist/_chunk/tag.js.map +1 -1
- package/dist/_chunk/tag.jsx +54 -18
- package/dist/_chunk/tag.jsx.map +1 -1
- package/dist/_chunk/textfield.js +2 -1
- package/dist/_chunk/textfield.js.map +1 -1
- package/dist/_chunk/textfield.jsx +2 -1
- package/dist/_chunk/textfield.jsx.map +1 -1
- package/dist/_chunk/toolbar.js +4 -36
- package/dist/_chunk/toolbar.js.map +1 -1
- package/dist/_chunk/toolbar.jsx +4 -36
- package/dist/_chunk/toolbar.jsx.map +1 -1
- package/dist/_chunk/tooltip.js +2 -2
- package/dist/_chunk/tooltip.js.map +1 -1
- package/dist/_chunk/tooltip.jsx +2 -2
- package/dist/_chunk/tooltip.jsx.map +1 -1
- package/dist/_chunk/tree.js +42 -14
- package/dist/_chunk/tree.js.map +1 -1
- package/dist/_chunk/tree.jsx +42 -14
- package/dist/_chunk/tree.jsx.map +1 -1
- package/dist/_chunk/utils.js +59 -19
- package/dist/_chunk/utils.js.map +1 -1
- package/dist/_chunk/utils.jsx +59 -19
- package/dist/_chunk/utils.jsx.map +1 -1
- package/dist/_chunk/visually-hidden.js +3 -2
- package/dist/_chunk/visually-hidden.js.map +1 -1
- package/dist/_chunk/visually-hidden.jsx +3 -2
- package/dist/_chunk/visually-hidden.jsx.map +1 -1
- package/dist/actiongroup/createActionGroup.d.ts.map +1 -1
- package/dist/autocomplete/createAutocomplete.d.ts +10 -7
- package/dist/autocomplete/createAutocomplete.d.ts.map +1 -1
- package/dist/breadcrumbs/createBreadcrumbs.d.ts.map +1 -1
- package/dist/button/createToggleButtonGroup.d.ts.map +1 -1
- package/dist/calendar/createCalendar.d.ts.map +1 -1
- package/dist/calendar/createCalendarCell.d.ts.map +1 -1
- package/dist/calendar/createCalendarGrid.d.ts.map +1 -1
- package/dist/calendar/createRangeCalendar.d.ts.map +1 -1
- package/dist/calendar/createRangeCalendarCell.d.ts.map +1 -1
- package/dist/calendar/intl/index.d.ts +1 -1
- package/dist/calendar/intl/index.d.ts.map +1 -1
- package/dist/collections/index.js +1 -1
- package/dist/collections/index.jsx +1 -1
- package/dist/color/createColorArea.d.ts.map +1 -1
- package/dist/color/createColorField.d.ts.map +1 -1
- package/dist/color/createColorSlider.d.ts.map +1 -1
- package/dist/color/createColorSwatch.d.ts.map +1 -1
- package/dist/color/createColorWheel.d.ts.map +1 -1
- package/dist/color/intl/index.d.ts +30 -0
- package/dist/color/intl/index.d.ts.map +1 -0
- package/dist/combobox/createComboBox.d.ts.map +1 -1
- package/dist/combobox/intl/generated-locales.d.ts +16 -0
- package/dist/combobox/intl/generated-locales.d.ts.map +1 -0
- package/dist/combobox/intl/index.d.ts +2 -2
- package/dist/combobox/intl/index.d.ts.map +1 -1
- package/dist/datepicker/createDateField.d.ts +45 -23
- package/dist/datepicker/createDateField.d.ts.map +1 -1
- package/dist/datepicker/createDatePicker.d.ts +34 -6
- package/dist/datepicker/createDatePicker.d.ts.map +1 -1
- package/dist/datepicker/createDatePickerGroup.d.ts +13 -13
- package/dist/datepicker/createDatePickerGroup.d.ts.map +1 -1
- package/dist/datepicker/createDateRangePicker.d.ts +55 -7
- package/dist/datepicker/createDateRangePicker.d.ts.map +1 -1
- package/dist/datepicker/createDateSegment.d.ts +6 -15
- package/dist/datepicker/createDateSegment.d.ts.map +1 -1
- package/dist/datepicker/createDisplayNames.d.ts +17 -0
- package/dist/datepicker/createDisplayNames.d.ts.map +1 -0
- package/dist/datepicker/createTimeField.d.ts +12 -49
- package/dist/datepicker/createTimeField.d.ts.map +1 -1
- package/dist/datepicker/index.d.ts +3 -3
- package/dist/datepicker/index.d.ts.map +1 -1
- package/dist/datepicker/index.js +2 -2
- package/dist/datepicker/index.jsx +2 -2
- package/dist/datepicker/intl.d.ts +12 -0
- package/dist/datepicker/intl.d.ts.map +1 -0
- package/dist/dnd/DragManager.d.ts +86 -0
- package/dist/dnd/DragManager.d.ts.map +1 -0
- package/dist/dnd/DropTargetKeyboardNavigation.d.ts +42 -0
- package/dist/dnd/DropTargetKeyboardNavigation.d.ts.map +1 -0
- package/dist/dnd/createDrag.d.ts.map +1 -1
- package/dist/dnd/createDraggableCollection.d.ts.map +1 -1
- package/dist/dnd/createDraggableItem.d.ts +12 -7
- package/dist/dnd/createDraggableItem.d.ts.map +1 -1
- package/dist/dnd/createDroppableCollection.d.ts +7 -15
- package/dist/dnd/createDroppableCollection.d.ts.map +1 -1
- package/dist/dnd/index.d.ts +5 -1
- package/dist/dnd/index.d.ts.map +1 -1
- package/dist/dnd/index.js +3 -2
- package/dist/dnd/index.jsx +3 -2
- package/dist/dnd/intl/index.d.ts +39 -0
- package/dist/dnd/intl/index.d.ts.map +1 -0
- package/dist/dnd/utils.d.ts +5 -0
- package/dist/dnd/utils.d.ts.map +1 -1
- package/dist/focus/FocusScope.d.ts +7 -0
- package/dist/focus/FocusScope.d.ts.map +1 -1
- package/dist/focus/index.d.ts +2 -1
- package/dist/focus/index.d.ts.map +1 -1
- package/dist/focus/index.js +3 -2
- package/dist/focus/index.jsx +3 -2
- package/dist/focus/virtualFocus.d.ts +26 -0
- package/dist/focus/virtualFocus.d.ts.map +1 -0
- package/dist/form/index.js +1 -1
- package/dist/form/index.jsx +1 -1
- package/dist/gridlist/createGridList.d.ts.map +1 -1
- package/dist/i18n/index.js +4 -2
- package/dist/i18n/index.jsx +4 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -12
- package/dist/index.jsx +18 -12
- package/dist/interactions/FocusableProvider.d.ts.map +1 -1
- package/dist/interactions/createFocus.d.ts.map +1 -1
- package/dist/interactions/createFocusWithin.d.ts.map +1 -1
- package/dist/interactions/createInteractionModality.d.ts.map +1 -1
- package/dist/interactions/index.js +1 -2
- package/dist/interactions/index.jsx +1 -2
- package/dist/label/createLabels.d.ts.map +1 -1
- package/dist/listbox/createListBox.d.ts.map +1 -1
- package/dist/listbox/createOption.d.ts +1 -1
- package/dist/listbox/createOption.d.ts.map +1 -1
- package/dist/live-announcer/index.js +1 -1
- package/dist/live-announcer/index.jsx +1 -1
- package/dist/select/createSelect.d.ts +2 -0
- package/dist/select/createSelect.d.ts.map +1 -1
- package/dist/selection/createSelectableItem.d.ts.map +1 -1
- package/dist/selection/index.js +2 -1
- package/dist/selection/index.jsx +2 -1
- package/dist/spinbutton/createSpinButton.d.ts +41 -0
- package/dist/spinbutton/createSpinButton.d.ts.map +1 -0
- package/dist/spinbutton/index.d.ts +3 -0
- package/dist/spinbutton/index.d.ts.map +1 -0
- package/dist/spinbutton/index.js +2 -0
- package/dist/spinbutton/index.jsx +2 -0
- package/dist/spinbutton/intl.d.ts +5 -0
- package/dist/spinbutton/intl.d.ts.map +1 -0
- package/dist/table/createTable.d.ts.map +1 -1
- package/dist/table/createTableColumnHeader.d.ts.map +1 -1
- package/dist/table/createTableRow.d.ts.map +1 -1
- package/dist/table/createTableSelectionCheckbox.d.ts.map +1 -1
- package/dist/table/types.d.ts +8 -0
- package/dist/table/types.d.ts.map +1 -1
- package/dist/table/utils.d.ts +15 -0
- package/dist/table/utils.d.ts.map +1 -0
- package/dist/tabs/createTabs.d.ts +1 -0
- package/dist/tabs/createTabs.d.ts.map +1 -1
- package/dist/tag/createTag.d.ts.map +1 -1
- package/dist/tag/createTagGroup.d.ts +7 -0
- package/dist/tag/createTagGroup.d.ts.map +1 -1
- package/dist/toolbar/createToolbar.d.ts.map +1 -1
- package/dist/tree/createTree.d.ts.map +1 -1
- package/dist/tree/createTreeSelectionCheckbox.d.ts.map +1 -1
- package/dist/utils/animation.d.ts.map +1 -1
- package/dist/utils/dom.d.ts +1 -0
- package/dist/utils/dom.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +4 -3
- package/dist/utils/index.jsx +4 -3
- package/package.json +2 -2
- package/src/actiongroup/createActionGroup.ts +26 -109
- package/src/autocomplete/createAutocomplete.ts +136 -15
- package/src/breadcrumbs/createBreadcrumbs.ts +12 -4
- package/src/button/createToggleButtonGroup.ts +19 -14
- package/src/calendar/createCalendar.ts +3 -4
- package/src/calendar/createCalendarCell.ts +17 -3
- package/src/calendar/createCalendarGrid.ts +5 -4
- package/src/calendar/createRangeCalendar.ts +27 -17
- package/src/calendar/createRangeCalendarCell.ts +17 -3
- package/src/calendar/intl/index.ts +8 -0
- package/src/color/createColorArea.ts +17 -10
- package/src/color/createColorField.ts +8 -1
- package/src/color/createColorSlider.ts +1 -2
- package/src/color/createColorSwatch.ts +4 -2
- package/src/color/createColorWheel.ts +0 -6
- package/src/color/intl/index.ts +316 -0
- package/src/combobox/createComboBox.ts +35 -4
- package/src/combobox/intl/generated-locales.ts +635 -0
- package/src/combobox/intl/index.ts +8 -2
- package/src/datepicker/createDateField.ts +228 -213
- package/src/datepicker/createDatePicker.ts +157 -146
- package/src/datepicker/createDatePickerGroup.ts +88 -82
- package/src/datepicker/createDateRangePicker.ts +230 -179
- package/src/datepicker/createDateSegment.ts +386 -389
- package/src/datepicker/createDisplayNames.ts +45 -0
- package/src/datepicker/createTimeField.ts +36 -129
- package/src/datepicker/index.ts +13 -14
- package/src/datepicker/intl.ts +633 -0
- package/src/dnd/DragManager.ts +693 -0
- package/src/dnd/DropTargetKeyboardNavigation.ts +337 -0
- package/src/dnd/createDrag.ts +31 -5
- package/src/dnd/createDraggableCollection.ts +33 -15
- package/src/dnd/createDraggableItem.ts +92 -5
- package/src/dnd/createDroppableCollection.ts +487 -373
- package/src/dnd/index.ts +11 -0
- package/src/dnd/intl/ar-AE.json +29 -0
- package/src/dnd/intl/bg-BG.json +29 -0
- package/src/dnd/intl/cs-CZ.json +29 -0
- package/src/dnd/intl/da-DK.json +29 -0
- package/src/dnd/intl/de-DE.json +29 -0
- package/src/dnd/intl/el-GR.json +29 -0
- package/src/dnd/intl/en-US.json +29 -0
- package/src/dnd/intl/es-ES.json +29 -0
- package/src/dnd/intl/et-EE.json +29 -0
- package/src/dnd/intl/fi-FI.json +29 -0
- package/src/dnd/intl/fr-FR.json +29 -0
- package/src/dnd/intl/he-IL.json +29 -0
- package/src/dnd/intl/hr-HR.json +29 -0
- package/src/dnd/intl/hu-HU.json +29 -0
- package/src/dnd/intl/index.ts +139 -0
- package/src/dnd/intl/it-IT.json +29 -0
- package/src/dnd/intl/ja-JP.json +29 -0
- package/src/dnd/intl/ko-KR.json +29 -0
- package/src/dnd/intl/lt-LT.json +29 -0
- package/src/dnd/intl/lv-LV.json +29 -0
- package/src/dnd/intl/nb-NO.json +29 -0
- package/src/dnd/intl/nl-NL.json +29 -0
- package/src/dnd/intl/pl-PL.json +29 -0
- package/src/dnd/intl/pt-BR.json +29 -0
- package/src/dnd/intl/pt-PT.json +29 -0
- package/src/dnd/intl/ro-RO.json +29 -0
- package/src/dnd/intl/ru-RU.json +29 -0
- package/src/dnd/intl/sk-SK.json +29 -0
- package/src/dnd/intl/sl-SI.json +29 -0
- package/src/dnd/intl/sr-SP.json +29 -0
- package/src/dnd/intl/sv-SE.json +29 -0
- package/src/dnd/intl/tr-TR.json +29 -0
- package/src/dnd/intl/uk-UA.json +29 -0
- package/src/dnd/intl/zh-CN.json +29 -0
- package/src/dnd/intl/zh-TW.json +29 -0
- package/src/dnd/utils.ts +36 -0
- package/src/focus/FocusScope.tsx +120 -12
- package/src/focus/index.ts +8 -0
- package/src/focus/virtualFocus.ts +55 -0
- package/src/gridlist/createGridList.ts +52 -16
- package/src/index.ts +11 -3
- package/src/interactions/FocusableProvider.tsx +11 -6
- package/src/interactions/createFocus.ts +26 -21
- package/src/interactions/createFocusWithin.ts +23 -24
- package/src/interactions/createInteractionModality.ts +5 -3
- package/src/label/createLabels.ts +7 -4
- package/src/listbox/createListBox.ts +74 -2
- package/src/listbox/createOption.ts +16 -1
- package/src/select/createSelect.ts +23 -2
- package/src/selection/createSelectableItem.ts +14 -0
- package/src/spinbutton/createSpinButton.ts +163 -0
- package/src/spinbutton/index.ts +10 -0
- package/src/spinbutton/intl.ts +115 -0
- package/src/table/createTable.ts +26 -1
- package/src/table/createTableColumnHeader.ts +10 -0
- package/src/table/createTableRow.ts +10 -0
- package/src/table/createTableSelectionCheckbox.ts +24 -1
- package/src/table/types.ts +8 -0
- package/src/table/utils.ts +41 -0
- package/src/tabs/createTabs.ts +53 -12
- package/src/tag/createTag.ts +21 -32
- package/src/tag/createTagGroup.ts +92 -0
- package/src/toolbar/createToolbar.ts +6 -58
- package/src/tree/createTree.ts +69 -14
- package/src/tree/createTreeSelectionCheckbox.ts +14 -1
- package/src/utils/animation.ts +119 -27
- package/src/utils/dom.ts +3 -2
- package/src/utils/index.ts +2 -0
- package/dist/_chunk/createLongPress.js +0 -91
- package/dist/_chunk/createLongPress.js.map +0 -1
- package/dist/_chunk/createLongPress.jsx +0 -91
- package/dist/_chunk/createLongPress.jsx.map +0 -1
- package/dist/_chunk/form.js.map +0 -1
- package/dist/_chunk/form.jsx.map +0 -1
- package/dist/_chunk/live-announcer.js.map +0 -1
- package/dist/_chunk/live-announcer.jsx.map +0 -1
- package/dist/datepicker/createTimeSegment.d.ts +0 -29
- package/dist/datepicker/createTimeSegment.d.ts.map +0 -1
- package/src/datepicker/createTimeSegment.ts +0 -352
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gridlist.js","names":["createId"],"sources":["../../src/gridlist/createGridList.ts","../../src/gridlist/createGridListItem.ts","../../src/gridlist/createGridListSelectionCheckbox.ts","../../src/gridlist/createGridListSection.ts"],"sourcesContent":["/**\n * createGridList - Provides accessibility for a grid list.\n * Based on @react-aria/gridlist/useGridList.\n */\n\nimport { createMemo, createEffect, type Accessor } from \"solid-js\";\nimport type { JSX } from \"solid-js\";\nimport { createId } from \"@proyecto-viviana/solid-stately\";\nimport type { GridState, GridCollection, Key } from \"@proyecto-viviana/solid-stately\";\nimport type { AriaGridListProps, GridListAria } from \"./types\";\nimport { scrollIntoViewport } from \"../utils\";\nimport { getInteractionModality } from \"../interactions/createInteractionModality\";\n\n/**\n * Metadata stored for a grid list instance.\n */\ninterface GridListData {\n /** The generated ID for the grid list. */\n gridListId: string;\n /** How selection should behave when pressing an item. */\n selectionBehavior: \"replace\" | \"toggle\";\n /** Whether row selection should occur on press up. */\n shouldSelectOnPressUp: boolean;\n /** How keyboard navigation behaves within row children. */\n keyboardNavigationBehavior: \"arrow\" | \"tab\";\n /** Text direction for row-child arrow navigation. */\n direction: \"ltr\" | \"rtl\";\n /** Actions registered for the grid list. */\n actions: {\n onAction?: (key: Key) => void;\n };\n}\n\n/**\n * WeakMap to store grid list data for child components to access.\n */\nconst gridListDataMap = new WeakMap<object, GridListData>();\n\n/**\n * Gets the grid list data for a given state.\n */\nexport function getGridListData<T extends object, C extends GridCollection<T>>(\n state: GridState<T, C>,\n): GridListData | undefined {\n return gridListDataMap.get(state);\n}\n\n/**\n * Whether a key should be skipped during keyboard navigation. Disabled keys only\n * block navigation under `disabledBehavior: \"all\"` (the default); under\n * `\"selection\"` they remain focusable (selection is still blocked elsewhere).\n * Mirrors `ListKeyboardDelegate.isDisabled` in React Aria.\n */\nfunction isNavigationDisabled<T extends object, C extends GridCollection<T>>(\n state: GridState<T, C>,\n key: Key,\n): boolean {\n return state.isDisabled(key) && state.disabledBehavior === \"all\";\n}\n\n/**\n * Walks from `startKey` via `step` until reaching a navigable (not\n * navigation-disabled) key, mirroring React Aria's\n * `ListKeyboardDelegate.findNextNonDisabled`. The next/previous lookups and the\n * `getFirstKey`/`getLastKey` boundaries all funnel through this so arrow keys,\n * Home and End land on enabled rows only.\n */\nfunction findNextNavigableKey<T extends object, C extends GridCollection<T>>(\n state: GridState<T, C>,\n startKey: Key | null,\n step: (key: Key) => Key | null,\n): Key | null {\n let key = startKey;\n while (key != null && isNavigationDisabled(state, key)) {\n key = step(key);\n }\n return key;\n}\n\n/**\n * Creates accessibility props for a grid list.\n */\nexport function createGridList<T extends object, C extends GridCollection<T> = GridCollection<T>>(\n props: Accessor<AriaGridListProps>,\n state: Accessor<GridState<T, C>>,\n ref: Accessor<HTMLElement | null>,\n): GridListAria {\n // Generate a unique ID for the grid list\n const gridListId = props().id ?? createId();\n\n // Store grid list data for child components\n const gridListData: GridListData = {\n gridListId,\n get selectionBehavior() {\n return props().selectionBehavior ?? \"replace\";\n },\n get shouldSelectOnPressUp() {\n return props().shouldSelectOnPressUp ?? false;\n },\n get keyboardNavigationBehavior() {\n return props().keyboardNavigationBehavior ?? \"arrow\";\n },\n get direction() {\n return props().direction ?? \"ltr\";\n },\n actions: {\n get onAction() {\n return props().onAction;\n },\n },\n };\n\n // Store in WeakMap using the state as key\n gridListDataMap.set(state(), gridListData);\n\n // Handle keyboard navigation\n const onKeyDown = (e: KeyboardEvent) => {\n const s = state();\n const p = props();\n const collection = s.collection;\n const focusedKey = s.focusedKey;\n\n if (p.isDisabled) return;\n\n switch (e.key) {\n case \"ArrowDown\": {\n e.preventDefault();\n const nextKey =\n focusedKey != null\n ? findNextNavigableKey(s, collection.getKeyAfter(focusedKey), (k) =>\n collection.getKeyAfter(k),\n )\n : findNextNavigableKey(s, collection.getFirstKey(), (k) => collection.getKeyAfter(k));\n if (nextKey != null) {\n s.setFocusedKey(nextKey);\n }\n break;\n }\n case \"ArrowUp\": {\n e.preventDefault();\n const prevKey =\n focusedKey != null\n ? findNextNavigableKey(s, collection.getKeyBefore(focusedKey), (k) =>\n collection.getKeyBefore(k),\n )\n : findNextNavigableKey(s, collection.getLastKey(), (k) => collection.getKeyBefore(k));\n if (prevKey != null) {\n s.setFocusedKey(prevKey);\n }\n break;\n }\n case \"ArrowRight\":\n case \"ArrowLeft\": {\n // Horizontal orientation promotes the inline axis to the primary\n // navigation axis. Upstream's ListKeyboardDelegate strips\n // getKeyLeftOf/getKeyRightOf for a vertical stack, so Left/Right stay\n // no-ops there; in a horizontal stack they move prev/next, flipped\n // under RTL (Right=next, Left=prev in LTR).\n if (p.orientation !== \"horizontal\") break;\n e.preventDefault();\n const isRtl = p.direction === \"rtl\";\n const forward = e.key === \"ArrowRight\" ? !isRtl : isRtl;\n const step = forward\n ? (k: Key) => collection.getKeyAfter(k)\n : (k: Key) => collection.getKeyBefore(k);\n const nextKey =\n focusedKey != null\n ? findNextNavigableKey(s, step(focusedKey), step)\n : findNextNavigableKey(s, collection.getFirstKey(), (k) => collection.getKeyAfter(k));\n if (nextKey != null) {\n s.setFocusedKey(nextKey);\n }\n break;\n }\n case \"Home\": {\n e.preventDefault();\n const firstKey = findNextNavigableKey(s, collection.getFirstKey(), (k) =>\n collection.getKeyAfter(k),\n );\n if (firstKey != null) {\n s.setFocusedKey(firstKey);\n }\n break;\n }\n case \"End\": {\n e.preventDefault();\n const lastKey = findNextNavigableKey(s, collection.getLastKey(), (k) =>\n collection.getKeyBefore(k),\n );\n if (lastKey != null) {\n s.setFocusedKey(lastKey);\n }\n break;\n }\n case \"a\":\n case \"A\": {\n if ((e.ctrlKey || e.metaKey) && s.selectionMode === \"multiple\") {\n e.preventDefault();\n s.selectAll();\n }\n break;\n }\n // Space (toggle selection) and Enter (onAction) are intentionally absent\n // here. Upstream's useSelectableCollection has no Space/Enter case — the\n // focused item owns both, via useSelectableItem. We follow browser focus\n // onto the focused row (the effect below), so the row's own handlers in\n // createGridListItem fire. Handling them here too would double-toggle a\n // focused row, because Solid delegates keydown and bubbles the row event\n // up to this grid handler.\n case \"Escape\": {\n if (s.selectionMode !== \"none\") {\n e.preventDefault();\n s.clearSelection();\n }\n break;\n }\n }\n };\n\n const onFocus = () => {\n const s = state();\n s.setFocused(true);\n\n // If nothing is focused, focus the first navigable item\n if (s.focusedKey == null) {\n const firstKey = findNextNavigableKey(s, s.collection.getFirstKey(), (k) =>\n s.collection.getKeyAfter(k),\n );\n if (firstKey != null) {\n s.setFocusedKey(firstKey);\n }\n }\n };\n\n const onBlur = () => {\n const s = state();\n s.setFocused(false);\n };\n\n // Mirror React Aria's useSelectableCollection: once the roving tabindex for the\n // focused key has been committed to the DOM, move browser focus onto that row\n // from a post-commit effect, looking it up by its stable data-key rather than by\n // transient tabindex. Selection and activation live on the row\n // (createGridListItem) to match upstream, so keyboard nav has to carry focus\n // there for the row's Space/Enter handlers to act on.\n createEffect(() => {\n const s = state();\n const key = s.focusedKey;\n const el = ref();\n if (!el || key == null) {\n return;\n }\n\n // Only manage focus while it already lives inside the grid — i.e. the user is\n // navigating with the keyboard. Gate on the physical position of browser focus\n // rather than the grid's logical isFocused signal: focus can land directly on a\n // row (a pointer click) without ever firing the grid's own focus handler, and\n // the contains() check keeps us from yanking focus back from elsewhere on the\n // page when the focused key changes from a background interaction.\n const active = document.activeElement;\n if (!active || (active !== el && !el.contains(active))) {\n return;\n }\n\n const target = el.querySelector<HTMLElement>(`[data-key=\"${key}\"]`);\n if (target && target !== active) {\n target.focus();\n\n // Reveal the newly focused row when navigating with the keyboard, mirroring\n // useSelectableCollection. Pointer-driven focus changes should not shift the\n // scroll position under the user's finger.\n if (getInteractionModality() !== \"pointer\") {\n scrollIntoViewport(target, { containingElement: el });\n }\n }\n });\n\n const gridProps = createMemo(() => {\n const p = props();\n const s = state();\n\n const baseProps: Record<string, unknown> = {\n role: \"grid\",\n id: gridListId,\n \"aria-label\": p[\"aria-label\"],\n \"aria-labelledby\": p[\"aria-labelledby\"],\n \"aria-describedby\": p[\"aria-describedby\"],\n \"aria-multiselectable\": s.selectionMode === \"multiple\" ? true : undefined,\n \"aria-disabled\": p.isDisabled || undefined,\n tabIndex: p.isDisabled ? undefined : 0,\n onKeyDown,\n onFocus,\n onBlur,\n };\n\n // Add row count for virtualized lists\n if (p.isVirtualized) {\n baseProps[\"aria-rowcount\"] = s.collection.rowCount;\n }\n\n return baseProps as JSX.HTMLAttributes<HTMLElement>;\n });\n\n return {\n get gridProps() {\n return gridProps();\n },\n };\n}\n","/**\n * createGridListItem - Provides accessibility for a grid list item.\n * Based on @react-aria/gridlist/useGridListItem.\n */\n\nimport { createMemo, type Accessor } from \"solid-js\";\nimport type { JSX } from \"solid-js\";\nimport type {\n Collection,\n GridState,\n GridCollection,\n Key,\n Selection,\n} from \"@proyecto-viviana/solid-stately\";\nimport type { AriaGridListItemProps, GridListItemAria } from \"./types\";\nimport { getGridListData } from \"./createGridList\";\nimport { createSelectableItem, type SelectableItemState } from \"../selection/createSelectableItem\";\nimport { mergeCollectionRowInteractionProps } from \"../selection/createCollectionRowInteraction\";\nimport { mergeProps } from \"../utils/mergeProps\";\n\n/**\n * Creates accessibility props for a grid list item.\n */\nexport function createGridListItem<\n T extends object,\n C extends GridCollection<T> = GridCollection<T>,\n>(\n props: Accessor<AriaGridListItemProps>,\n state: Accessor<GridState<T, C>>,\n ref: Accessor<HTMLElement | null>,\n): GridListItemAria {\n const isSelected = createMemo(() => {\n const s = state();\n const p = props();\n return s.isSelected(p.node.key);\n });\n\n const selectableState: SelectableItemState<T> = {\n collection: () => state().collection as unknown as Collection<T>,\n isFocused: () => state().isFocused,\n setFocused: (focused: boolean) => state().setFocused(focused),\n focusedKey: () => state().focusedKey,\n childFocusStrategy: () => state().childFocusStrategy,\n setFocusedKey: (key: Key | null, strategy) => state().setFocusedKey(key, strategy),\n selectionMode: () => state().selectionMode,\n selectionBehavior: () => props().selectionBehavior ?? state().selectionBehavior,\n disallowEmptySelection: () => state().disallowEmptySelection,\n selectedKeys: () => state().selectedKeys as Selection,\n disabledKeys: () => state().disabledKeys,\n disabledBehavior: () => state().disabledBehavior,\n isEmpty: () => {\n const keys = state().selectedKeys;\n return keys !== \"all\" && keys.size === 0;\n },\n isSelectAll: () => state().selectedKeys === \"all\",\n isSelected: (key: Key) => state().isSelected(key),\n isDisabled: (key: Key) => {\n const s = state();\n const item = s.collection.getItem(key);\n return (\n s.disabledBehavior === \"all\" &&\n s.isDisabled(key) &&\n item?.props?.disabledBehavior !== \"selection\"\n );\n },\n canSelectItem: (key: Key) => {\n const s = state();\n return s.selectionMode !== \"none\" && !s.isDisabled(key);\n },\n setSelectionBehavior: (behavior) => state().setSelectionBehavior(behavior),\n toggleSelection: (key: Key) => state().toggleSelection(key),\n replaceSelection: (key: Key) => state().replaceSelection(key),\n setSelectedKeys: (keys: Iterable<Key>) => state().setSelectedKeys(keys),\n selectAll: () => state().selectAll(),\n clearSelection: () => state().clearSelection(),\n toggleSelectAll: () => state().toggleSelectAll(),\n extendSelection: (toKey: Key, _collection: Collection<T>) => state().extendSelection(toKey),\n };\n\n const selectableItem = createSelectableItem<T>(\n () => {\n const s = state();\n const p = props();\n const gridListData = getGridListData(s);\n const onAction = gridListData?.actions.onAction;\n\n return {\n key: p.node.key,\n id: `${gridListData?.gridListId ?? \"gridlist\"}-row-${String(p.node.key)}`,\n isVirtualized: p.isVirtualized,\n shouldSelectOnPressUp: gridListData?.shouldSelectOnPressUp ?? false,\n onAction:\n onAction || p.onAction\n ? () => {\n p.onAction?.();\n onAction?.(p.node.key);\n }\n : undefined,\n };\n },\n selectableState,\n ref,\n );\n\n const rowProps = createMemo(() => {\n const s = state();\n const p = props();\n const node = p.node;\n\n const baseProps: Record<string, unknown> = {\n role: \"row\",\n \"aria-selected\": s.selectionMode !== \"none\" ? isSelected() : undefined,\n \"aria-disabled\": selectableItem.isDisabled() || undefined,\n };\n\n // Add aria-rowindex for virtualized lists\n if (p.isVirtualized && node.rowIndex != null) {\n baseProps[\"aria-rowindex\"] = node.rowIndex + 1; // 1-based\n }\n\n const gridListData = getGridListData(s);\n const mergedProps = mergeProps<JSX.HTMLAttributes<HTMLElement>>(\n selectableItem.itemProps,\n baseProps,\n );\n\n return mergeCollectionRowInteractionProps(mergedProps, {\n ref,\n keyboardNavigationBehavior: () => gridListData?.keyboardNavigationBehavior ?? \"arrow\",\n direction: () => gridListData?.direction ?? \"ltr\",\n });\n });\n\n const gridCellProps = createMemo(() => {\n return {\n role: \"gridcell\",\n } as JSX.HTMLAttributes<HTMLDivElement>;\n });\n\n return {\n get rowProps() {\n return rowProps();\n },\n get gridCellProps() {\n return gridCellProps();\n },\n get isSelected() {\n return isSelected();\n },\n get isDisabled() {\n return selectableItem.isDisabled();\n },\n get isPressed() {\n return selectableItem.isPressed();\n },\n };\n}\n","/**\n * createGridListSelectionCheckbox - Provides accessibility for a grid list item selection checkbox.\n * Based on @react-aria/gridlist.\n */\n\nimport { createMemo, type Accessor } from \"solid-js\";\nimport type { JSX } from \"solid-js\";\nimport { createId } from \"@proyecto-viviana/solid-stately\";\nimport type { GridState, GridCollection } from \"@proyecto-viviana/solid-stately\";\nimport type { AriaGridListSelectionCheckboxProps, GridListSelectionCheckboxAria } from \"./types\";\n\n/**\n * Creates accessibility props for a grid list item selection checkbox.\n */\nexport function createGridListSelectionCheckbox<\n T extends object,\n C extends GridCollection<T> = GridCollection<T>,\n>(\n props: Accessor<AriaGridListSelectionCheckboxProps>,\n state: Accessor<GridState<T, C>>,\n): GridListSelectionCheckboxAria {\n const checkboxId = createId();\n\n const isSelected = createMemo(() => {\n const s = state();\n const p = props();\n return s.isSelected(p.key);\n });\n\n const isDisabled = createMemo(() => {\n const s = state();\n const p = props();\n return s.isDisabled(p.key);\n });\n\n const onChange = () => {\n const s = state();\n const p = props();\n if (!isDisabled()) {\n s.toggleSelection(p.key);\n }\n };\n\n const checkboxProps = createMemo(() => {\n const baseProps: Record<string, unknown> = {\n id: checkboxId,\n type: \"checkbox\",\n checked: isSelected(),\n disabled: isDisabled(),\n onChange,\n \"aria-label\": \"Select\",\n };\n\n return baseProps as JSX.InputHTMLAttributes<HTMLInputElement>;\n });\n\n return {\n get checkboxProps() {\n return checkboxProps();\n },\n };\n}\n","/**\n * createGridListSection - Provides accessibility for a grid list section.\n * Based on @react-aria/gridlist/useGridListSection.\n */\n\nimport { createMemo } from \"solid-js\";\nimport { createId, createSlotId } from \"../ssr\";\nimport { createLabels } from \"../label/createLabels\";\nimport type { AriaGridListSectionProps, GridListSectionAria } from \"./types\";\n\n/**\n * Creates accessibility props for a grid list section.\n *\n * Mirrors upstream `useGridListSection`: a section is a `role=\"rowgroup\"`\n * wrapper whose optional header renders as `role=\"row\"` › `role=\"rowheader\"`.\n * The `aria-labelledby` of the wrapper points at the header's id via a slot id\n * that resolves to `undefined` when no header is rendered.\n */\nexport function createGridListSection(props: AriaGridListSectionProps): GridListSectionAria {\n const headingId = createSlotId();\n // Stable id for the rowgroup so `createLabels` does not regenerate one each\n // time the slot id resolves (it short-circuits on a provided id).\n const rowGroupId = createId();\n\n const labelProps = createMemo(() =>\n createLabels({\n id: rowGroupId,\n \"aria-label\": props[\"aria-label\"],\n \"aria-labelledby\": headingId(),\n }),\n );\n\n return {\n rowProps: { role: \"row\" },\n rowHeaderProps: {\n get id() {\n return headingId();\n },\n role: \"rowheader\",\n },\n rowGroupProps: {\n role: \"rowgroup\",\n get id() {\n return labelProps().id;\n },\n get \"aria-label\"() {\n return labelProps()[\"aria-label\"];\n },\n get \"aria-labelledby\"() {\n return labelProps()[\"aria-labelledby\"];\n },\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoCA,MAAM,kCAAkB,IAAI,QAA8B;;;;AAK1D,SAAgB,gBACd,OAC0B;CAC1B,OAAO,gBAAgB,IAAI,KAAK;AAClC;;;;;;;AAQA,SAAS,qBACP,OACA,KACS;CACT,OAAO,MAAM,WAAW,GAAG,KAAK,MAAM,qBAAqB;AAC7D;;;;;;;;AASA,SAAS,qBACP,OACA,UACA,MACY;CACZ,IAAI,MAAM;CACV,OAAO,OAAO,QAAQ,qBAAqB,OAAO,GAAG,GACnD,MAAM,KAAK,GAAG;CAEhB,OAAO;AACT;;;;AAKA,SAAgB,eACd,OACA,OACA,KACc;CAEd,MAAM,aAAa,MAAM,CAAC,CAAC,MAAM,SAAS;CAG1C,MAAM,eAA6B;EACjC;EACA,IAAI,oBAAoB;GACtB,OAAO,MAAM,CAAC,CAAC,qBAAqB;EACtC;EACA,IAAI,wBAAwB;GAC1B,OAAO,MAAM,CAAC,CAAC,yBAAyB;EAC1C;EACA,IAAI,6BAA6B;GAC/B,OAAO,MAAM,CAAC,CAAC,8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ARL,IAAI;GACJ,MAAM;GACN,SAAS,WAAW;GACpB,UAAU,WAAW;GACrB;GACA,cAAc;EAGD;CACjB,CAAC;CAED,OAAO,EACL,IAAI,gBAAgB;EAClB,OAAO,cAAc;CACvB,EACF;AACF;;;;;;;;;;;;;;;AC3CA,SAAgB,sBAAsB,OAAsD;CAC1F,MAAM,YAAY,aAAa;CAG/B,MAAM,aAAaA,WAAS;CAE5B,MAAM,aAAa,iBACjB,aAAa;EACX,IAAI;EACJ,cAAc,MAAM;EACpB,mBAAmB,UAAU;CAC/B,CAAC,CACH;CAEA,OAAO;EACL,UAAU,EAAE,MAAM,MAAM;EACxB,gBAAgB;GACd,IAAI,KAAK;IACP,OAAO,UAAU;GACnB;GACA,MAAM;EACR;EACA,eAAe;GACb,MAAM;GACN,IAAI,KAAK;IACP,OAAO,WAAW,CAAC,CAAC;GACtB;GACA,IAAI,eAAe;IACjB,OAAO,WAAW,CAAC,CAAC;GACtB;GACA,IAAI,oBAAoB;IACtB,OAAO,WAAW,CAAC,CAAC;GACtB;EACF;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"gridlist.js","names":["mergeProps","createId"],"sources":["../../src/gridlist/createGridList.ts","../../src/gridlist/createGridListItem.ts","../../src/gridlist/createGridListSelectionCheckbox.ts","../../src/gridlist/createGridListSection.ts"],"sourcesContent":["/**\n * createGridList - Provides accessibility for a grid list.\n * Based on @react-aria/gridlist/useGridList.\n */\n\nimport { createMemo, createEffect, type Accessor } from \"solid-js\";\nimport type { JSX } from \"solid-js\";\nimport { createId } from \"@proyecto-viviana/solid-stately\";\nimport type { GridState, GridCollection, Key } from \"@proyecto-viviana/solid-stately\";\nimport type { AriaGridListProps, GridListAria } from \"./types\";\nimport { scrollIntoViewport } from \"../utils\";\nimport { getInteractionModality } from \"../interactions/createInteractionModality\";\n\n/**\n * Metadata stored for a grid list instance.\n */\ninterface GridListData {\n /** The generated ID for the grid list. */\n gridListId: string;\n /** How selection should behave when pressing an item. */\n selectionBehavior: \"replace\" | \"toggle\";\n /** Whether row selection should occur on press up. */\n shouldSelectOnPressUp: boolean;\n /** How keyboard navigation behaves within row children. */\n keyboardNavigationBehavior: \"arrow\" | \"tab\";\n /** Text direction for row-child arrow navigation. */\n direction: \"ltr\" | \"rtl\";\n /** Actions registered for the grid list. */\n actions: {\n onAction?: (key: Key) => void;\n };\n}\n\n/**\n * WeakMap to store grid list data for child components to access.\n */\nconst gridListDataMap = new WeakMap<object, GridListData>();\n\n/**\n * Gets the grid list data for a given state.\n */\nexport function getGridListData<T extends object, C extends GridCollection<T>>(\n state: GridState<T, C>,\n): GridListData | undefined {\n return gridListDataMap.get(state);\n}\n\n/**\n * Whether a key should be skipped during keyboard navigation. Disabled keys only\n * block navigation under `disabledBehavior: \"all\"` (the default); under\n * `\"selection\"` they remain focusable (selection is still blocked elsewhere).\n * Mirrors `ListKeyboardDelegate.isDisabled` in React Aria.\n */\nfunction isNavigationDisabled<T extends object, C extends GridCollection<T>>(\n state: GridState<T, C>,\n key: Key,\n): boolean {\n return state.isDisabled(key) && state.disabledBehavior === \"all\";\n}\n\n/**\n * Walks from `startKey` via `step` until reaching a navigable (not\n * navigation-disabled) key, mirroring React Aria's\n * `ListKeyboardDelegate.findNextNonDisabled`. The next/previous lookups and the\n * `getFirstKey`/`getLastKey` boundaries all funnel through this so arrow keys,\n * Home and End land on enabled rows only.\n */\nfunction findNextNavigableKey<T extends object, C extends GridCollection<T>>(\n state: GridState<T, C>,\n startKey: Key | null,\n step: (key: Key) => Key | null,\n): Key | null {\n let key = startKey;\n while (key != null && isNavigationDisabled(state, key)) {\n key = step(key);\n }\n return key;\n}\n\n/**\n * Creates accessibility props for a grid list.\n */\nexport function createGridList<T extends object, C extends GridCollection<T> = GridCollection<T>>(\n props: Accessor<AriaGridListProps>,\n state: Accessor<GridState<T, C>>,\n ref: Accessor<HTMLElement | null>,\n): GridListAria {\n // Generate a unique ID for the grid list\n const gridListId = props().id ?? createId();\n\n // Store grid list data for child components\n const gridListData: GridListData = {\n gridListId,\n get selectionBehavior() {\n return props().selectionBehavior ?? \"replace\";\n },\n get shouldSelectOnPressUp() {\n return props().shouldSelectOnPressUp ?? false;\n },\n get keyboardNavigationBehavior() {\n return props().keyboardNavigationBehavior ?? \"arrow\";\n },\n get direction() {\n return props().direction ?? \"ltr\";\n },\n actions: {\n get onAction() {\n return props().onAction;\n },\n },\n };\n\n // Store in WeakMap using the state as key\n gridListDataMap.set(state(), gridListData);\n\n // Handle keyboard navigation\n const onKeyDown = (e: KeyboardEvent) => {\n const s = state();\n const p = props();\n const collection = s.collection;\n const focusedKey = s.focusedKey;\n\n if (p.isDisabled) return;\n\n switch (e.key) {\n case \"ArrowDown\": {\n e.preventDefault();\n const nextKey =\n focusedKey != null\n ? findNextNavigableKey(s, collection.getKeyAfter(focusedKey), (k) =>\n collection.getKeyAfter(k),\n )\n : findNextNavigableKey(s, collection.getFirstKey(), (k) => collection.getKeyAfter(k));\n if (nextKey != null) {\n s.setFocusedKey(nextKey);\n }\n break;\n }\n case \"ArrowUp\": {\n e.preventDefault();\n const prevKey =\n focusedKey != null\n ? findNextNavigableKey(s, collection.getKeyBefore(focusedKey), (k) =>\n collection.getKeyBefore(k),\n )\n : findNextNavigableKey(s, collection.getLastKey(), (k) => collection.getKeyBefore(k));\n if (prevKey != null) {\n s.setFocusedKey(prevKey);\n }\n break;\n }\n case \"ArrowRight\":\n case \"ArrowLeft\": {\n // The inline axis (Left/Right) belongs to the ROW under the default\n // \"arrow\" navigation behavior: createGridListItem's onKeyDownCapture\n // intercepts Left/Right for intra-row focus movement (a no-op for\n // text-only rows), exactly as useGridListItem does upstream, so the\n // container must NOT step between rows here. Only under \"tab\" navigation\n // does the row stop intercepting and the event reach the collection —\n // mirroring how useSelectableCollection handles Left/Right via\n // ListKeyboardDelegate. Even then it strips getKeyLeftOf/getKeyRightOf\n // for a vertical stack, so this stays a no-op unless the stack is\n // horizontal, where Right=next / Left=prev in LTR, flipped under RTL.\n // (In Solid the row's capture-phase stopPropagation does not reliably\n // prevent the container's delegated onKeyDown, so this gate — not the\n // row's stopPropagation — is what keeps the axes from double-firing.)\n const behavior = p.keyboardNavigationBehavior ?? \"arrow\";\n if (p.orientation !== \"horizontal\" || behavior !== \"tab\") break;\n e.preventDefault();\n const isRtl = p.direction === \"rtl\";\n const forward = e.key === \"ArrowRight\" ? !isRtl : isRtl;\n const step = forward\n ? (k: Key) => collection.getKeyAfter(k)\n : (k: Key) => collection.getKeyBefore(k);\n const nextKey =\n focusedKey != null\n ? findNextNavigableKey(s, step(focusedKey), step)\n : findNextNavigableKey(s, collection.getFirstKey(), (k) => collection.getKeyAfter(k));\n if (nextKey != null) {\n s.setFocusedKey(nextKey);\n }\n break;\n }\n case \"Home\": {\n e.preventDefault();\n const firstKey = findNextNavigableKey(s, collection.getFirstKey(), (k) =>\n collection.getKeyAfter(k),\n );\n if (firstKey != null) {\n s.setFocusedKey(firstKey);\n }\n break;\n }\n case \"End\": {\n e.preventDefault();\n const lastKey = findNextNavigableKey(s, collection.getLastKey(), (k) =>\n collection.getKeyBefore(k),\n );\n if (lastKey != null) {\n s.setFocusedKey(lastKey);\n }\n break;\n }\n case \"a\":\n case \"A\": {\n if ((e.ctrlKey || e.metaKey) && s.selectionMode === \"multiple\") {\n e.preventDefault();\n s.selectAll();\n }\n break;\n }\n // Space (toggle selection) and Enter (onAction) are intentionally absent\n // here. Upstream's useSelectableCollection has no Space/Enter case — the\n // focused item owns both, via useSelectableItem. We follow browser focus\n // onto the focused row (the effect below), so the row's own handlers in\n // createGridListItem fire. Handling them here too would double-toggle a\n // focused row, because Solid delegates keydown and bubbles the row event\n // up to this grid handler.\n case \"Escape\": {\n if (s.selectionMode !== \"none\") {\n e.preventDefault();\n s.clearSelection();\n }\n break;\n }\n }\n };\n\n // Focus marshalling — the grid container is a trampoline. Its roving tabIndex\n // is 0 only while `focusedKey == null` (see gridProps below), so a Tab that\n // reaches a standalone grid lands on the container itself; move the focused key\n // onto the first/last row and the post-commit effect below pulls REAL DOM focus\n // there while the container rolls to tabIndex -1. This mirrors\n // useSelectableCollection's `onFocus` — the same direction-aware trampoline the\n // standalone ListBox uses (createListBox.ts) — and is why a standalone grid\n // announces the active row through real focus, never `aria-activedescendant`.\n const onFocus: JSX.EventHandler<HTMLElement, FocusEvent> = (e) => {\n const s = state();\n const p = props();\n s.setFocused(true);\n\n // onFocus is non-bubbling in Solid, so this fires only when the container\n // itself receives focus; ignore anything that bubbled from a descendant.\n // (`currentTarget` is null only in synthetic unit-test FocusEvents — treat\n // those as a direct container focus.)\n const container = e.currentTarget as HTMLElement | null;\n if (container && !container.contains(e.target as Node)) return;\n // Only marshal when no row is focused yet.\n if (s.focusedKey != null || p.isDisabled) return;\n\n const collection = s.collection;\n const relatedTarget = e.relatedTarget as Element | null;\n // Detect tab direction: focus arriving from an element that FOLLOWS the grid\n // in document order means the user shift-tabbed backward into it, so enter at\n // the LAST row; otherwise (forward Tab, or programmatic) enter at the FIRST.\n const enterKey =\n relatedTarget &&\n container &&\n container.compareDocumentPosition(relatedTarget) & Node.DOCUMENT_POSITION_FOLLOWING\n ? findNextNavigableKey(s, collection.getLastKey(), (k) => collection.getKeyBefore(k))\n : findNextNavigableKey(s, collection.getFirstKey(), (k) => collection.getKeyAfter(k));\n if (enterKey != null) {\n s.setFocusedKey(enterKey);\n }\n };\n\n const onBlur = () => {\n const s = state();\n s.setFocused(false);\n };\n\n // Mirror React Aria's useSelectableCollection: once the roving tabindex for the\n // focused key has been committed to the DOM, move browser focus onto that row\n // from a post-commit effect, looking it up by its stable data-key rather than by\n // transient tabindex. Selection and activation live on the row\n // (createGridListItem) to match upstream, so keyboard nav has to carry focus\n // there for the row's Space/Enter handlers to act on.\n createEffect(() => {\n const s = state();\n const key = s.focusedKey;\n const el = ref();\n if (!el || key == null) {\n return;\n }\n\n // Only manage focus while it already lives inside the grid — i.e. the user is\n // navigating with the keyboard. Gate on the physical position of browser focus\n // rather than the grid's logical isFocused signal: focus can land directly on a\n // row (a pointer click) without ever firing the grid's own focus handler, and\n // the contains() check keeps us from yanking focus back from elsewhere on the\n // page when the focused key changes from a background interaction.\n const active = document.activeElement;\n if (!active || (active !== el && !el.contains(active))) {\n return;\n }\n\n const target = el.querySelector<HTMLElement>(`[data-key=\"${key}\"]`);\n if (target && target !== active) {\n target.focus();\n\n // Reveal the newly focused row when navigating with the keyboard, mirroring\n // useSelectableCollection. Pointer-driven focus changes should not shift the\n // scroll position under the user's finger.\n if (getInteractionModality() !== \"pointer\") {\n scrollIntoViewport(target, { containingElement: el });\n }\n }\n });\n\n const gridProps = createMemo(() => {\n const p = props();\n const s = state();\n\n const baseProps: Record<string, unknown> = {\n role: \"grid\",\n id: gridListId,\n \"aria-label\": p[\"aria-label\"],\n \"aria-labelledby\": p[\"aria-labelledby\"],\n \"aria-describedby\": p[\"aria-describedby\"],\n \"aria-multiselectable\": s.selectionMode === \"multiple\" ? true : undefined,\n \"aria-disabled\": p.isDisabled || undefined,\n // Roving container tabIndex mirrors useSelectableCollection: the container\n // is tabbable (0) only while nothing is focused, then rolls to -1 once a row\n // takes focus so Tab exits the grid. A standalone grid drives AT through\n // real row focus, so it never needs (nor emits) aria-activedescendant.\n tabIndex: p.isDisabled ? undefined : s.focusedKey != null ? -1 : 0,\n onKeyDown,\n onFocus,\n onBlur,\n };\n\n // Add row count for virtualized lists\n if (p.isVirtualized) {\n baseProps[\"aria-rowcount\"] = s.collection.rowCount;\n }\n\n return baseProps as JSX.HTMLAttributes<HTMLElement>;\n });\n\n return {\n get gridProps() {\n return gridProps();\n },\n };\n}\n","/**\n * createGridListItem - Provides accessibility for a grid list item.\n * Based on @react-aria/gridlist/useGridListItem.\n */\n\nimport { createMemo, type Accessor } from \"solid-js\";\nimport type { JSX } from \"solid-js\";\nimport type {\n Collection,\n GridState,\n GridCollection,\n Key,\n Selection,\n} from \"@proyecto-viviana/solid-stately\";\nimport type { AriaGridListItemProps, GridListItemAria } from \"./types\";\nimport { getGridListData } from \"./createGridList\";\nimport { createSelectableItem, type SelectableItemState } from \"../selection/createSelectableItem\";\nimport { mergeCollectionRowInteractionProps } from \"../selection/createCollectionRowInteraction\";\nimport { mergeProps } from \"../utils/mergeProps\";\n\n/**\n * Creates accessibility props for a grid list item.\n */\nexport function createGridListItem<\n T extends object,\n C extends GridCollection<T> = GridCollection<T>,\n>(\n props: Accessor<AriaGridListItemProps>,\n state: Accessor<GridState<T, C>>,\n ref: Accessor<HTMLElement | null>,\n): GridListItemAria {\n const isSelected = createMemo(() => {\n const s = state();\n const p = props();\n return s.isSelected(p.node.key);\n });\n\n const selectableState: SelectableItemState<T> = {\n collection: () => state().collection as unknown as Collection<T>,\n isFocused: () => state().isFocused,\n setFocused: (focused: boolean) => state().setFocused(focused),\n focusedKey: () => state().focusedKey,\n childFocusStrategy: () => state().childFocusStrategy,\n setFocusedKey: (key: Key | null, strategy) => state().setFocusedKey(key, strategy),\n selectionMode: () => state().selectionMode,\n selectionBehavior: () => props().selectionBehavior ?? state().selectionBehavior,\n disallowEmptySelection: () => state().disallowEmptySelection,\n selectedKeys: () => state().selectedKeys as Selection,\n disabledKeys: () => state().disabledKeys,\n disabledBehavior: () => state().disabledBehavior,\n isEmpty: () => {\n const keys = state().selectedKeys;\n return keys !== \"all\" && keys.size === 0;\n },\n isSelectAll: () => state().selectedKeys === \"all\",\n isSelected: (key: Key) => state().isSelected(key),\n isDisabled: (key: Key) => {\n const s = state();\n const item = s.collection.getItem(key);\n return (\n s.disabledBehavior === \"all\" &&\n s.isDisabled(key) &&\n item?.props?.disabledBehavior !== \"selection\"\n );\n },\n canSelectItem: (key: Key) => {\n const s = state();\n return s.selectionMode !== \"none\" && !s.isDisabled(key);\n },\n setSelectionBehavior: (behavior) => state().setSelectionBehavior(behavior),\n toggleSelection: (key: Key) => state().toggleSelection(key),\n replaceSelection: (key: Key) => state().replaceSelection(key),\n setSelectedKeys: (keys: Iterable<Key>) => state().setSelectedKeys(keys),\n selectAll: () => state().selectAll(),\n clearSelection: () => state().clearSelection(),\n toggleSelectAll: () => state().toggleSelectAll(),\n extendSelection: (toKey: Key, _collection: Collection<T>) => state().extendSelection(toKey),\n };\n\n const selectableItem = createSelectableItem<T>(\n () => {\n const s = state();\n const p = props();\n const gridListData = getGridListData(s);\n const onAction = gridListData?.actions.onAction;\n\n return {\n key: p.node.key,\n id: `${gridListData?.gridListId ?? \"gridlist\"}-row-${String(p.node.key)}`,\n isVirtualized: p.isVirtualized,\n shouldSelectOnPressUp: gridListData?.shouldSelectOnPressUp ?? false,\n onAction:\n onAction || p.onAction\n ? () => {\n p.onAction?.();\n onAction?.(p.node.key);\n }\n : undefined,\n };\n },\n selectableState,\n ref,\n );\n\n const rowProps = createMemo(() => {\n const s = state();\n const p = props();\n const node = p.node;\n\n const baseProps: Record<string, unknown> = {\n role: \"row\",\n \"aria-selected\": s.selectionMode !== \"none\" ? isSelected() : undefined,\n \"aria-disabled\": selectableItem.isDisabled() || undefined,\n };\n\n // Add aria-rowindex for virtualized lists\n if (p.isVirtualized && node.rowIndex != null) {\n baseProps[\"aria-rowindex\"] = node.rowIndex + 1; // 1-based\n }\n\n const gridListData = getGridListData(s);\n const mergedProps = mergeProps<JSX.HTMLAttributes<HTMLElement>>(\n selectableItem.itemProps,\n baseProps,\n );\n\n return mergeCollectionRowInteractionProps(mergedProps, {\n ref,\n keyboardNavigationBehavior: () => gridListData?.keyboardNavigationBehavior ?? \"arrow\",\n direction: () => gridListData?.direction ?? \"ltr\",\n });\n });\n\n const gridCellProps = createMemo(() => {\n return {\n role: \"gridcell\",\n } as JSX.HTMLAttributes<HTMLDivElement>;\n });\n\n return {\n get rowProps() {\n return rowProps();\n },\n get gridCellProps() {\n return gridCellProps();\n },\n get isSelected() {\n return isSelected();\n },\n get isDisabled() {\n return selectableItem.isDisabled();\n },\n get isPressed() {\n return selectableItem.isPressed();\n },\n };\n}\n","/**\n * createGridListSelectionCheckbox - Provides accessibility for a grid list item selection checkbox.\n * Based on @react-aria/gridlist.\n */\n\nimport { createMemo, type Accessor } from \"solid-js\";\nimport type { JSX } from \"solid-js\";\nimport { createId } from \"@proyecto-viviana/solid-stately\";\nimport type { GridState, GridCollection } from \"@proyecto-viviana/solid-stately\";\nimport type { AriaGridListSelectionCheckboxProps, GridListSelectionCheckboxAria } from \"./types\";\n\n/**\n * Creates accessibility props for a grid list item selection checkbox.\n */\nexport function createGridListSelectionCheckbox<\n T extends object,\n C extends GridCollection<T> = GridCollection<T>,\n>(\n props: Accessor<AriaGridListSelectionCheckboxProps>,\n state: Accessor<GridState<T, C>>,\n): GridListSelectionCheckboxAria {\n const checkboxId = createId();\n\n const isSelected = createMemo(() => {\n const s = state();\n const p = props();\n return s.isSelected(p.key);\n });\n\n const isDisabled = createMemo(() => {\n const s = state();\n const p = props();\n return s.isDisabled(p.key);\n });\n\n const onChange = () => {\n const s = state();\n const p = props();\n if (!isDisabled()) {\n s.toggleSelection(p.key);\n }\n };\n\n const checkboxProps = createMemo(() => {\n const baseProps: Record<string, unknown> = {\n id: checkboxId,\n type: \"checkbox\",\n checked: isSelected(),\n disabled: isDisabled(),\n onChange,\n \"aria-label\": \"Select\",\n };\n\n return baseProps as JSX.InputHTMLAttributes<HTMLInputElement>;\n });\n\n return {\n get checkboxProps() {\n return checkboxProps();\n },\n };\n}\n","/**\n * createGridListSection - Provides accessibility for a grid list section.\n * Based on @react-aria/gridlist/useGridListSection.\n */\n\nimport { createMemo } from \"solid-js\";\nimport { createId, createSlotId } from \"../ssr\";\nimport { createLabels } from \"../label/createLabels\";\nimport type { AriaGridListSectionProps, GridListSectionAria } from \"./types\";\n\n/**\n * Creates accessibility props for a grid list section.\n *\n * Mirrors upstream `useGridListSection`: a section is a `role=\"rowgroup\"`\n * wrapper whose optional header renders as `role=\"row\"` › `role=\"rowheader\"`.\n * The `aria-labelledby` of the wrapper points at the header's id via a slot id\n * that resolves to `undefined` when no header is rendered.\n */\nexport function createGridListSection(props: AriaGridListSectionProps): GridListSectionAria {\n const headingId = createSlotId();\n // Stable id for the rowgroup so `createLabels` does not regenerate one each\n // time the slot id resolves (it short-circuits on a provided id).\n const rowGroupId = createId();\n\n const labelProps = createMemo(() =>\n createLabels({\n id: rowGroupId,\n \"aria-label\": props[\"aria-label\"],\n \"aria-labelledby\": headingId(),\n }),\n );\n\n return {\n rowProps: { role: \"row\" },\n rowHeaderProps: {\n get id() {\n return headingId();\n },\n role: \"rowheader\",\n },\n rowGroupProps: {\n role: \"rowgroup\",\n get id() {\n return labelProps().id;\n },\n get \"aria-label\"() {\n return labelProps()[\"aria-label\"];\n },\n get \"aria-labelledby\"() {\n return labelProps()[\"aria-labelledby\"];\n },\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoCA,MAAM,kCAAkB,IAAI,QAA8B;;;;AAK1D,SAAgB,gBACd,OAC0B;CAC1B,OAAO,gBAAgB,IAAI,KAAK;AAClC;;;;;;;AAQA,SAAS,qBACP,OACA,KACS;CACT,OAAO,MAAM,WAAW,GAAG,KAAK,MAAM,qBAAqB;AAC7D;;;;;;;;AASA,SAAS,qBACP,OACA,UACA,MACY;CACZ,IAAI,MAAM;CACV,OAAO,OAAO,QAAQ,qBAAqB,OAAO,GAAG,GACnD,MAAM,KAAK,GAAG;CAEhB,OAAO;AACT;;;;AAKA,SAAgB,eACd,OACA,OACA,KACc;CAEd,MAAM,aAAa,MAAM,CAAC,CAAC,MAAM,SAAS;CAG1C,MAAM,eAA6B;EACjC;EACA,IAAI,oBAAoB;GACtB,OAAO,MAAM,CAAC,CAAC,qBAAqB;EACtC;EACA,IAAI,wBAAwB;GAC1B,OAAO,MAAM,CAAC,CAAC,yBAAyB;EAC1C;EACA,IAAI,6BAA6B;GAC/B,OAAO,MAAM,CAAC,CAAC,8BAA8B;EAC/C;EACA,IAAI,YAAY;GACd,OAAO,MAAM,CAAC,CAAC,aAAa;EAC9B;EACA,SAAS,EACP,IAAI,WAAW;GACb,OAAO,MAAM,CAAC,CAAC;EACjB,EACF;CACF;CAGA,gBAAgB,IAAI,MAAM,GAAG,YAAY;CA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iBAAiB;EACrB,MAAM,IAAI,MAAM;EAChB,MAAM,IAAI,MAAM;EAChB,IAAI,CAAC,WAAW,GACd,EAAE,gBAAgB,EAAE,GAAG;CAE3B;CAEA,MAAM,gBAAgB,iBAAiB;EAUrC,OAAO;GARL,IAAI;GACJ,MAAM;GACN,SAAS,WAAW;GACpB,UAAU,WAAW;GACrB;GACA,cAAc;EAGD;CACjB,CAAC;CAED,OAAO,EACL,IAAI,gBAAgB;EAClB,OAAO,cAAc;CACvB,EACF;AACF;;;;;;;;;;;;;;;AC3CA,SAAgB,sBAAsB,OAAsD;CAC1F,MAAM,YAAY,aAAa;CAG/B,MAAM,aAAaC,WAAS;CAE5B,MAAM,aAAa,iBACjB,aAAa;EACX,IAAI;EACJ,cAAc,MAAM;EACpB,mBAAmB,UAAU;CAC/B,CAAC,CACH;CAEA,OAAO;EACL,UAAU,EAAE,MAAM,MAAM;EACxB,gBAAgB;GACd,IAAI,KAAK;IACP,OAAO,UAAU;GACnB;GACA,MAAM;EACR;EACA,eAAe;GACb,MAAM;GACN,IAAI,KAAK;IACP,OAAO,WAAW,CAAC,CAAC;GACtB;GACA,IAAI,eAAe;IACjB,OAAO,WAAW,CAAC,CAAC;GACtB;GACA,IAAI,oBAAoB;IACtB,OAAO,WAAW,CAAC,CAAC;GACtB;EACF;CACF;AACF"}
|
package/dist/_chunk/gridlist.jsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as mergeProps$1 } from "./env.jsx";
|
|
2
2
|
import { S as scrollIntoViewport } from "./utils.jsx";
|
|
3
3
|
import { o as getInteractionModality } from "./createInteractionModality.jsx";
|
|
4
4
|
import { createId as createId$1, createSlotId } from "../ssr/index.jsx";
|
|
@@ -88,7 +88,8 @@ function createGridList(props, state, ref) {
|
|
|
88
88
|
}
|
|
89
89
|
case "ArrowRight":
|
|
90
90
|
case "ArrowLeft": {
|
|
91
|
-
|
|
91
|
+
const behavior = p.keyboardNavigationBehavior ?? "arrow";
|
|
92
|
+
if (p.orientation !== "horizontal" || behavior !== "tab") break;
|
|
92
93
|
e.preventDefault();
|
|
93
94
|
const isRtl = p.direction === "rtl";
|
|
94
95
|
const step = (e.key === "ArrowRight" ? !isRtl : isRtl) ? (k) => collection.getKeyAfter(k) : (k) => collection.getKeyBefore(k);
|
|
@@ -123,13 +124,17 @@ function createGridList(props, state, ref) {
|
|
|
123
124
|
break;
|
|
124
125
|
}
|
|
125
126
|
};
|
|
126
|
-
const onFocus = () => {
|
|
127
|
+
const onFocus = (e) => {
|
|
127
128
|
const s = state();
|
|
129
|
+
const p = props();
|
|
128
130
|
s.setFocused(true);
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
const container = e.currentTarget;
|
|
132
|
+
if (container && !container.contains(e.target)) return;
|
|
133
|
+
if (s.focusedKey != null || p.isDisabled) return;
|
|
134
|
+
const collection = s.collection;
|
|
135
|
+
const relatedTarget = e.relatedTarget;
|
|
136
|
+
const enterKey = relatedTarget && container && container.compareDocumentPosition(relatedTarget) & Node.DOCUMENT_POSITION_FOLLOWING ? findNextNavigableKey(s, collection.getLastKey(), (k) => collection.getKeyBefore(k)) : findNextNavigableKey(s, collection.getFirstKey(), (k) => collection.getKeyAfter(k));
|
|
137
|
+
if (enterKey != null) s.setFocusedKey(enterKey);
|
|
133
138
|
};
|
|
134
139
|
const onBlur = () => {
|
|
135
140
|
state().setFocused(false);
|
|
@@ -157,7 +162,7 @@ function createGridList(props, state, ref) {
|
|
|
157
162
|
"aria-describedby": p["aria-describedby"],
|
|
158
163
|
"aria-multiselectable": s.selectionMode === "multiple" ? true : void 0,
|
|
159
164
|
"aria-disabled": p.isDisabled || void 0,
|
|
160
|
-
tabIndex: p.isDisabled ? void 0 : 0,
|
|
165
|
+
tabIndex: p.isDisabled ? void 0 : s.focusedKey != null ? -1 : 0,
|
|
161
166
|
onKeyDown,
|
|
162
167
|
onFocus,
|
|
163
168
|
onBlur
|
|
@@ -247,7 +252,7 @@ function createGridListItem(props, state, ref) {
|
|
|
247
252
|
};
|
|
248
253
|
if (p.isVirtualized && node.rowIndex != null) baseProps["aria-rowindex"] = node.rowIndex + 1;
|
|
249
254
|
const gridListData = getGridListData(s);
|
|
250
|
-
return mergeCollectionRowInteractionProps(mergeProps(selectableItem.itemProps, baseProps), {
|
|
255
|
+
return mergeCollectionRowInteractionProps(mergeProps$1(selectableItem.itemProps, baseProps), {
|
|
251
256
|
ref,
|
|
252
257
|
keyboardNavigationBehavior: () => gridListData?.keyboardNavigationBehavior ?? "arrow",
|
|
253
258
|
direction: () => gridListData?.direction ?? "ltr"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gridlist.jsx","names":["createId"],"sources":["../../src/gridlist/createGridList.ts","../../src/gridlist/createGridListItem.ts","../../src/gridlist/createGridListSelectionCheckbox.ts","../../src/gridlist/createGridListSection.ts"],"sourcesContent":["/**\n * createGridList - Provides accessibility for a grid list.\n * Based on @react-aria/gridlist/useGridList.\n */\n\nimport { createMemo, createEffect, type Accessor } from \"solid-js\";\nimport type { JSX } from \"solid-js\";\nimport { createId } from \"@proyecto-viviana/solid-stately\";\nimport type { GridState, GridCollection, Key } from \"@proyecto-viviana/solid-stately\";\nimport type { AriaGridListProps, GridListAria } from \"./types\";\nimport { scrollIntoViewport } from \"../utils\";\nimport { getInteractionModality } from \"../interactions/createInteractionModality\";\n\n/**\n * Metadata stored for a grid list instance.\n */\ninterface GridListData {\n /** The generated ID for the grid list. */\n gridListId: string;\n /** How selection should behave when pressing an item. */\n selectionBehavior: \"replace\" | \"toggle\";\n /** Whether row selection should occur on press up. */\n shouldSelectOnPressUp: boolean;\n /** How keyboard navigation behaves within row children. */\n keyboardNavigationBehavior: \"arrow\" | \"tab\";\n /** Text direction for row-child arrow navigation. */\n direction: \"ltr\" | \"rtl\";\n /** Actions registered for the grid list. */\n actions: {\n onAction?: (key: Key) => void;\n };\n}\n\n/**\n * WeakMap to store grid list data for child components to access.\n */\nconst gridListDataMap = new WeakMap<object, GridListData>();\n\n/**\n * Gets the grid list data for a given state.\n */\nexport function getGridListData<T extends object, C extends GridCollection<T>>(\n state: GridState<T, C>,\n): GridListData | undefined {\n return gridListDataMap.get(state);\n}\n\n/**\n * Whether a key should be skipped during keyboard navigation. Disabled keys only\n * block navigation under `disabledBehavior: \"all\"` (the default); under\n * `\"selection\"` they remain focusable (selection is still blocked elsewhere).\n * Mirrors `ListKeyboardDelegate.isDisabled` in React Aria.\n */\nfunction isNavigationDisabled<T extends object, C extends GridCollection<T>>(\n state: GridState<T, C>,\n key: Key,\n): boolean {\n return state.isDisabled(key) && state.disabledBehavior === \"all\";\n}\n\n/**\n * Walks from `startKey` via `step` until reaching a navigable (not\n * navigation-disabled) key, mirroring React Aria's\n * `ListKeyboardDelegate.findNextNonDisabled`. The next/previous lookups and the\n * `getFirstKey`/`getLastKey` boundaries all funnel through this so arrow keys,\n * Home and End land on enabled rows only.\n */\nfunction findNextNavigableKey<T extends object, C extends GridCollection<T>>(\n state: GridState<T, C>,\n startKey: Key | null,\n step: (key: Key) => Key | null,\n): Key | null {\n let key = startKey;\n while (key != null && isNavigationDisabled(state, key)) {\n key = step(key);\n }\n return key;\n}\n\n/**\n * Creates accessibility props for a grid list.\n */\nexport function createGridList<T extends object, C extends GridCollection<T> = GridCollection<T>>(\n props: Accessor<AriaGridListProps>,\n state: Accessor<GridState<T, C>>,\n ref: Accessor<HTMLElement | null>,\n): GridListAria {\n // Generate a unique ID for the grid list\n const gridListId = props().id ?? createId();\n\n // Store grid list data for child components\n const gridListData: GridListData = {\n gridListId,\n get selectionBehavior() {\n return props().selectionBehavior ?? \"replace\";\n },\n get shouldSelectOnPressUp() {\n return props().shouldSelectOnPressUp ?? false;\n },\n get keyboardNavigationBehavior() {\n return props().keyboardNavigationBehavior ?? \"arrow\";\n },\n get direction() {\n return props().direction ?? \"ltr\";\n },\n actions: {\n get onAction() {\n return props().onAction;\n },\n },\n };\n\n // Store in WeakMap using the state as key\n gridListDataMap.set(state(), gridListData);\n\n // Handle keyboard navigation\n const onKeyDown = (e: KeyboardEvent) => {\n const s = state();\n const p = props();\n const collection = s.collection;\n const focusedKey = s.focusedKey;\n\n if (p.isDisabled) return;\n\n switch (e.key) {\n case \"ArrowDown\": {\n e.preventDefault();\n const nextKey =\n focusedKey != null\n ? findNextNavigableKey(s, collection.getKeyAfter(focusedKey), (k) =>\n collection.getKeyAfter(k),\n )\n : findNextNavigableKey(s, collection.getFirstKey(), (k) => collection.getKeyAfter(k));\n if (nextKey != null) {\n s.setFocusedKey(nextKey);\n }\n break;\n }\n case \"ArrowUp\": {\n e.preventDefault();\n const prevKey =\n focusedKey != null\n ? findNextNavigableKey(s, collection.getKeyBefore(focusedKey), (k) =>\n collection.getKeyBefore(k),\n )\n : findNextNavigableKey(s, collection.getLastKey(), (k) => collection.getKeyBefore(k));\n if (prevKey != null) {\n s.setFocusedKey(prevKey);\n }\n break;\n }\n case \"ArrowRight\":\n case \"ArrowLeft\": {\n // Horizontal orientation promotes the inline axis to the primary\n // navigation axis. Upstream's ListKeyboardDelegate strips\n // getKeyLeftOf/getKeyRightOf for a vertical stack, so Left/Right stay\n // no-ops there; in a horizontal stack they move prev/next, flipped\n // under RTL (Right=next, Left=prev in LTR).\n if (p.orientation !== \"horizontal\") break;\n e.preventDefault();\n const isRtl = p.direction === \"rtl\";\n const forward = e.key === \"ArrowRight\" ? !isRtl : isRtl;\n const step = forward\n ? (k: Key) => collection.getKeyAfter(k)\n : (k: Key) => collection.getKeyBefore(k);\n const nextKey =\n focusedKey != null\n ? findNextNavigableKey(s, step(focusedKey), step)\n : findNextNavigableKey(s, collection.getFirstKey(), (k) => collection.getKeyAfter(k));\n if (nextKey != null) {\n s.setFocusedKey(nextKey);\n }\n break;\n }\n case \"Home\": {\n e.preventDefault();\n const firstKey = findNextNavigableKey(s, collection.getFirstKey(), (k) =>\n collection.getKeyAfter(k),\n );\n if (firstKey != null) {\n s.setFocusedKey(firstKey);\n }\n break;\n }\n case \"End\": {\n e.preventDefault();\n const lastKey = findNextNavigableKey(s, collection.getLastKey(), (k) =>\n collection.getKeyBefore(k),\n );\n if (lastKey != null) {\n s.setFocusedKey(lastKey);\n }\n break;\n }\n case \"a\":\n case \"A\": {\n if ((e.ctrlKey || e.metaKey) && s.selectionMode === \"multiple\") {\n e.preventDefault();\n s.selectAll();\n }\n break;\n }\n // Space (toggle selection) and Enter (onAction) are intentionally absent\n // here. Upstream's useSelectableCollection has no Space/Enter case — the\n // focused item owns both, via useSelectableItem. We follow browser focus\n // onto the focused row (the effect below), so the row's own handlers in\n // createGridListItem fire. Handling them here too would double-toggle a\n // focused row, because Solid delegates keydown and bubbles the row event\n // up to this grid handler.\n case \"Escape\": {\n if (s.selectionMode !== \"none\") {\n e.preventDefault();\n s.clearSelection();\n }\n break;\n }\n }\n };\n\n const onFocus = () => {\n const s = state();\n s.setFocused(true);\n\n // If nothing is focused, focus the first navigable item\n if (s.focusedKey == null) {\n const firstKey = findNextNavigableKey(s, s.collection.getFirstKey(), (k) =>\n s.collection.getKeyAfter(k),\n );\n if (firstKey != null) {\n s.setFocusedKey(firstKey);\n }\n }\n };\n\n const onBlur = () => {\n const s = state();\n s.setFocused(false);\n };\n\n // Mirror React Aria's useSelectableCollection: once the roving tabindex for the\n // focused key has been committed to the DOM, move browser focus onto that row\n // from a post-commit effect, looking it up by its stable data-key rather than by\n // transient tabindex. Selection and activation live on the row\n // (createGridListItem) to match upstream, so keyboard nav has to carry focus\n // there for the row's Space/Enter handlers to act on.\n createEffect(() => {\n const s = state();\n const key = s.focusedKey;\n const el = ref();\n if (!el || key == null) {\n return;\n }\n\n // Only manage focus while it already lives inside the grid — i.e. the user is\n // navigating with the keyboard. Gate on the physical position of browser focus\n // rather than the grid's logical isFocused signal: focus can land directly on a\n // row (a pointer click) without ever firing the grid's own focus handler, and\n // the contains() check keeps us from yanking focus back from elsewhere on the\n // page when the focused key changes from a background interaction.\n const active = document.activeElement;\n if (!active || (active !== el && !el.contains(active))) {\n return;\n }\n\n const target = el.querySelector<HTMLElement>(`[data-key=\"${key}\"]`);\n if (target && target !== active) {\n target.focus();\n\n // Reveal the newly focused row when navigating with the keyboard, mirroring\n // useSelectableCollection. Pointer-driven focus changes should not shift the\n // scroll position under the user's finger.\n if (getInteractionModality() !== \"pointer\") {\n scrollIntoViewport(target, { containingElement: el });\n }\n }\n });\n\n const gridProps = createMemo(() => {\n const p = props();\n const s = state();\n\n const baseProps: Record<string, unknown> = {\n role: \"grid\",\n id: gridListId,\n \"aria-label\": p[\"aria-label\"],\n \"aria-labelledby\": p[\"aria-labelledby\"],\n \"aria-describedby\": p[\"aria-describedby\"],\n \"aria-multiselectable\": s.selectionMode === \"multiple\" ? true : undefined,\n \"aria-disabled\": p.isDisabled || undefined,\n tabIndex: p.isDisabled ? undefined : 0,\n onKeyDown,\n onFocus,\n onBlur,\n };\n\n // Add row count for virtualized lists\n if (p.isVirtualized) {\n baseProps[\"aria-rowcount\"] = s.collection.rowCount;\n }\n\n return baseProps as JSX.HTMLAttributes<HTMLElement>;\n });\n\n return {\n get gridProps() {\n return gridProps();\n },\n };\n}\n","/**\n * createGridListItem - Provides accessibility for a grid list item.\n * Based on @react-aria/gridlist/useGridListItem.\n */\n\nimport { createMemo, type Accessor } from \"solid-js\";\nimport type { JSX } from \"solid-js\";\nimport type {\n Collection,\n GridState,\n GridCollection,\n Key,\n Selection,\n} from \"@proyecto-viviana/solid-stately\";\nimport type { AriaGridListItemProps, GridListItemAria } from \"./types\";\nimport { getGridListData } from \"./createGridList\";\nimport { createSelectableItem, type SelectableItemState } from \"../selection/createSelectableItem\";\nimport { mergeCollectionRowInteractionProps } from \"../selection/createCollectionRowInteraction\";\nimport { mergeProps } from \"../utils/mergeProps\";\n\n/**\n * Creates accessibility props for a grid list item.\n */\nexport function createGridListItem<\n T extends object,\n C extends GridCollection<T> = GridCollection<T>,\n>(\n props: Accessor<AriaGridListItemProps>,\n state: Accessor<GridState<T, C>>,\n ref: Accessor<HTMLElement | null>,\n): GridListItemAria {\n const isSelected = createMemo(() => {\n const s = state();\n const p = props();\n return s.isSelected(p.node.key);\n });\n\n const selectableState: SelectableItemState<T> = {\n collection: () => state().collection as unknown as Collection<T>,\n isFocused: () => state().isFocused,\n setFocused: (focused: boolean) => state().setFocused(focused),\n focusedKey: () => state().focusedKey,\n childFocusStrategy: () => state().childFocusStrategy,\n setFocusedKey: (key: Key | null, strategy) => state().setFocusedKey(key, strategy),\n selectionMode: () => state().selectionMode,\n selectionBehavior: () => props().selectionBehavior ?? state().selectionBehavior,\n disallowEmptySelection: () => state().disallowEmptySelection,\n selectedKeys: () => state().selectedKeys as Selection,\n disabledKeys: () => state().disabledKeys,\n disabledBehavior: () => state().disabledBehavior,\n isEmpty: () => {\n const keys = state().selectedKeys;\n return keys !== \"all\" && keys.size === 0;\n },\n isSelectAll: () => state().selectedKeys === \"all\",\n isSelected: (key: Key) => state().isSelected(key),\n isDisabled: (key: Key) => {\n const s = state();\n const item = s.collection.getItem(key);\n return (\n s.disabledBehavior === \"all\" &&\n s.isDisabled(key) &&\n item?.props?.disabledBehavior !== \"selection\"\n );\n },\n canSelectItem: (key: Key) => {\n const s = state();\n return s.selectionMode !== \"none\" && !s.isDisabled(key);\n },\n setSelectionBehavior: (behavior) => state().setSelectionBehavior(behavior),\n toggleSelection: (key: Key) => state().toggleSelection(key),\n replaceSelection: (key: Key) => state().replaceSelection(key),\n setSelectedKeys: (keys: Iterable<Key>) => state().setSelectedKeys(keys),\n selectAll: () => state().selectAll(),\n clearSelection: () => state().clearSelection(),\n toggleSelectAll: () => state().toggleSelectAll(),\n extendSelection: (toKey: Key, _collection: Collection<T>) => state().extendSelection(toKey),\n };\n\n const selectableItem = createSelectableItem<T>(\n () => {\n const s = state();\n const p = props();\n const gridListData = getGridListData(s);\n const onAction = gridListData?.actions.onAction;\n\n return {\n key: p.node.key,\n id: `${gridListData?.gridListId ?? \"gridlist\"}-row-${String(p.node.key)}`,\n isVirtualized: p.isVirtualized,\n shouldSelectOnPressUp: gridListData?.shouldSelectOnPressUp ?? false,\n onAction:\n onAction || p.onAction\n ? () => {\n p.onAction?.();\n onAction?.(p.node.key);\n }\n : undefined,\n };\n },\n selectableState,\n ref,\n );\n\n const rowProps = createMemo(() => {\n const s = state();\n const p = props();\n const node = p.node;\n\n const baseProps: Record<string, unknown> = {\n role: \"row\",\n \"aria-selected\": s.selectionMode !== \"none\" ? isSelected() : undefined,\n \"aria-disabled\": selectableItem.isDisabled() || undefined,\n };\n\n // Add aria-rowindex for virtualized lists\n if (p.isVirtualized && node.rowIndex != null) {\n baseProps[\"aria-rowindex\"] = node.rowIndex + 1; // 1-based\n }\n\n const gridListData = getGridListData(s);\n const mergedProps = mergeProps<JSX.HTMLAttributes<HTMLElement>>(\n selectableItem.itemProps,\n baseProps,\n );\n\n return mergeCollectionRowInteractionProps(mergedProps, {\n ref,\n keyboardNavigationBehavior: () => gridListData?.keyboardNavigationBehavior ?? \"arrow\",\n direction: () => gridListData?.direction ?? \"ltr\",\n });\n });\n\n const gridCellProps = createMemo(() => {\n return {\n role: \"gridcell\",\n } as JSX.HTMLAttributes<HTMLDivElement>;\n });\n\n return {\n get rowProps() {\n return rowProps();\n },\n get gridCellProps() {\n return gridCellProps();\n },\n get isSelected() {\n return isSelected();\n },\n get isDisabled() {\n return selectableItem.isDisabled();\n },\n get isPressed() {\n return selectableItem.isPressed();\n },\n };\n}\n","/**\n * createGridListSelectionCheckbox - Provides accessibility for a grid list item selection checkbox.\n * Based on @react-aria/gridlist.\n */\n\nimport { createMemo, type Accessor } from \"solid-js\";\nimport type { JSX } from \"solid-js\";\nimport { createId } from \"@proyecto-viviana/solid-stately\";\nimport type { GridState, GridCollection } from \"@proyecto-viviana/solid-stately\";\nimport type { AriaGridListSelectionCheckboxProps, GridListSelectionCheckboxAria } from \"./types\";\n\n/**\n * Creates accessibility props for a grid list item selection checkbox.\n */\nexport function createGridListSelectionCheckbox<\n T extends object,\n C extends GridCollection<T> = GridCollection<T>,\n>(\n props: Accessor<AriaGridListSelectionCheckboxProps>,\n state: Accessor<GridState<T, C>>,\n): GridListSelectionCheckboxAria {\n const checkboxId = createId();\n\n const isSelected = createMemo(() => {\n const s = state();\n const p = props();\n return s.isSelected(p.key);\n });\n\n const isDisabled = createMemo(() => {\n const s = state();\n const p = props();\n return s.isDisabled(p.key);\n });\n\n const onChange = () => {\n const s = state();\n const p = props();\n if (!isDisabled()) {\n s.toggleSelection(p.key);\n }\n };\n\n const checkboxProps = createMemo(() => {\n const baseProps: Record<string, unknown> = {\n id: checkboxId,\n type: \"checkbox\",\n checked: isSelected(),\n disabled: isDisabled(),\n onChange,\n \"aria-label\": \"Select\",\n };\n\n return baseProps as JSX.InputHTMLAttributes<HTMLInputElement>;\n });\n\n return {\n get checkboxProps() {\n return checkboxProps();\n },\n };\n}\n","/**\n * createGridListSection - Provides accessibility for a grid list section.\n * Based on @react-aria/gridlist/useGridListSection.\n */\n\nimport { createMemo } from \"solid-js\";\nimport { createId, createSlotId } from \"../ssr\";\nimport { createLabels } from \"../label/createLabels\";\nimport type { AriaGridListSectionProps, GridListSectionAria } from \"./types\";\n\n/**\n * Creates accessibility props for a grid list section.\n *\n * Mirrors upstream `useGridListSection`: a section is a `role=\"rowgroup\"`\n * wrapper whose optional header renders as `role=\"row\"` › `role=\"rowheader\"`.\n * The `aria-labelledby` of the wrapper points at the header's id via a slot id\n * that resolves to `undefined` when no header is rendered.\n */\nexport function createGridListSection(props: AriaGridListSectionProps): GridListSectionAria {\n const headingId = createSlotId();\n // Stable id for the rowgroup so `createLabels` does not regenerate one each\n // time the slot id resolves (it short-circuits on a provided id).\n const rowGroupId = createId();\n\n const labelProps = createMemo(() =>\n createLabels({\n id: rowGroupId,\n \"aria-label\": props[\"aria-label\"],\n \"aria-labelledby\": headingId(),\n }),\n );\n\n return {\n rowProps: { role: \"row\" },\n rowHeaderProps: {\n get id() {\n return headingId();\n },\n role: \"rowheader\",\n },\n rowGroupProps: {\n role: \"rowgroup\",\n get id() {\n return labelProps().id;\n },\n get \"aria-label\"() {\n return labelProps()[\"aria-label\"];\n },\n get \"aria-labelledby\"() {\n return labelProps()[\"aria-labelledby\"];\n },\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoCA,MAAM,kCAAkB,IAAI,QAA8B;;;;AAK1D,SAAgB,gBACd,OAC0B;CAC1B,OAAO,gBAAgB,IAAI,KAAK;AAClC;;;;;;;AAQA,SAAS,qBACP,OACA,KACS;CACT,OAAO,MAAM,WAAW,GAAG,KAAK,MAAM,qBAAqB;AAC7D;;;;;;;;AASA,SAAS,qBACP,OACA,UACA,MACY;CACZ,IAAI,MAAM;CACV,OAAO,OAAO,QAAQ,qBAAqB,OAAO,GAAG,GACnD,MAAM,KAAK,GAAG;CAEhB,OAAO;AACT;;;;AAKA,SAAgB,eACd,OACA,OACA,KACc;CAEd,MAAM,aAAa,MAAM,CAAC,CAAC,MAAM,SAAS;CAG1C,MAAM,eAA6B;EACjC;EACA,IAAI,oBAAoB;GACtB,OAAO,MAAM,CAAC,CAAC,qBAAqB;EACtC;EACA,IAAI,wBAAwB;GAC1B,OAAO,MAAM,CAAC,CAAC,yBAAyB;EAC1C;EACA,IAAI,6BAA6B;GAC/B,OAAO,MAAM,CAAC,CAAC,8BAA8B;EAC/C;EACA,IAAI,YAAY;GACd,OAAO,MAAM,CAAC,CAAC,aAAa;EAC9B;EACA,SAAS,EACP,IAAI,WAAW;GACb,OAAO,MAAM,CAAC,CAAC;EACjB,EACF;CACF;CAGA,gBAAgB,IAAI,MAAM,GAAG,YAAY;CAGzC,MAAM,aAAa,MAAqB;EACtC,MAAM,IAAI,MAAM;EAChB,MAAM,IAAI,MAAM;EAChB,MAAM,aAAa,EAAE;EACrB,MAAM,aAAa,EAAE;EAErB,IAAI,EAAE,YAAY;EAElB,QAAQ,EAAE,KAAV;GACE,KAAK,aAAa;IAChB,EAAE,eAAe;IACjB,MAAM,UACJ,cAAc,OACV,qBAAqB,GAAG,WAAW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AU;GACnB;GACA,MAAM;EACR;EACA,eAAe;GACb,MAAM;GACN,IAAI,KAAK;IACP,OAAO,WAAW,CAAC,CAAC;GACtB;GACA,IAAI,eAAe;IACjB,OAAO,WAAW,CAAC,CAAC;GACtB;GACA,IAAI,oBAAoB;IACtB,OAAO,WAAW,CAAC,CAAC;GACtB;EACF;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"gridlist.jsx","names":["mergeProps","createId"],"sources":["../../src/gridlist/createGridList.ts","../../src/gridlist/createGridListItem.ts","../../src/gridlist/createGridListSelectionCheckbox.ts","../../src/gridlist/createGridListSection.ts"],"sourcesContent":["/**\n * createGridList - Provides accessibility for a grid list.\n * Based on @react-aria/gridlist/useGridList.\n */\n\nimport { createMemo, createEffect, type Accessor } from \"solid-js\";\nimport type { JSX } from \"solid-js\";\nimport { createId } from \"@proyecto-viviana/solid-stately\";\nimport type { GridState, GridCollection, Key } from \"@proyecto-viviana/solid-stately\";\nimport type { AriaGridListProps, GridListAria } from \"./types\";\nimport { scrollIntoViewport } from \"../utils\";\nimport { getInteractionModality } from \"../interactions/createInteractionModality\";\n\n/**\n * Metadata stored for a grid list instance.\n */\ninterface GridListData {\n /** The generated ID for the grid list. */\n gridListId: string;\n /** How selection should behave when pressing an item. */\n selectionBehavior: \"replace\" | \"toggle\";\n /** Whether row selection should occur on press up. */\n shouldSelectOnPressUp: boolean;\n /** How keyboard navigation behaves within row children. */\n keyboardNavigationBehavior: \"arrow\" | \"tab\";\n /** Text direction for row-child arrow navigation. */\n direction: \"ltr\" | \"rtl\";\n /** Actions registered for the grid list. */\n actions: {\n onAction?: (key: Key) => void;\n };\n}\n\n/**\n * WeakMap to store grid list data for child components to access.\n */\nconst gridListDataMap = new WeakMap<object, GridListData>();\n\n/**\n * Gets the grid list data for a given state.\n */\nexport function getGridListData<T extends object, C extends GridCollection<T>>(\n state: GridState<T, C>,\n): GridListData | undefined {\n return gridListDataMap.get(state);\n}\n\n/**\n * Whether a key should be skipped during keyboard navigation. Disabled keys only\n * block navigation under `disabledBehavior: \"all\"` (the default); under\n * `\"selection\"` they remain focusable (selection is still blocked elsewhere).\n * Mirrors `ListKeyboardDelegate.isDisabled` in React Aria.\n */\nfunction isNavigationDisabled<T extends object, C extends GridCollection<T>>(\n state: GridState<T, C>,\n key: Key,\n): boolean {\n return state.isDisabled(key) && state.disabledBehavior === \"all\";\n}\n\n/**\n * Walks from `startKey` via `step` until reaching a navigable (not\n * navigation-disabled) key, mirroring React Aria's\n * `ListKeyboardDelegate.findNextNonDisabled`. The next/previous lookups and the\n * `getFirstKey`/`getLastKey` boundaries all funnel through this so arrow keys,\n * Home and End land on enabled rows only.\n */\nfunction findNextNavigableKey<T extends object, C extends GridCollection<T>>(\n state: GridState<T, C>,\n startKey: Key | null,\n step: (key: Key) => Key | null,\n): Key | null {\n let key = startKey;\n while (key != null && isNavigationDisabled(state, key)) {\n key = step(key);\n }\n return key;\n}\n\n/**\n * Creates accessibility props for a grid list.\n */\nexport function createGridList<T extends object, C extends GridCollection<T> = GridCollection<T>>(\n props: Accessor<AriaGridListProps>,\n state: Accessor<GridState<T, C>>,\n ref: Accessor<HTMLElement | null>,\n): GridListAria {\n // Generate a unique ID for the grid list\n const gridListId = props().id ?? createId();\n\n // Store grid list data for child components\n const gridListData: GridListData = {\n gridListId,\n get selectionBehavior() {\n return props().selectionBehavior ?? \"replace\";\n },\n get shouldSelectOnPressUp() {\n return props().shouldSelectOnPressUp ?? false;\n },\n get keyboardNavigationBehavior() {\n return props().keyboardNavigationBehavior ?? \"arrow\";\n },\n get direction() {\n return props().direction ?? \"ltr\";\n },\n actions: {\n get onAction() {\n return props().onAction;\n },\n },\n };\n\n // Store in WeakMap using the state as key\n gridListDataMap.set(state(), gridListData);\n\n // Handle keyboard navigation\n const onKeyDown = (e: KeyboardEvent) => {\n const s = state();\n const p = props();\n const collection = s.collection;\n const focusedKey = s.focusedKey;\n\n if (p.isDisabled) return;\n\n switch (e.key) {\n case \"ArrowDown\": {\n e.preventDefault();\n const nextKey =\n focusedKey != null\n ? findNextNavigableKey(s, collection.getKeyAfter(focusedKey), (k) =>\n collection.getKeyAfter(k),\n )\n : findNextNavigableKey(s, collection.getFirstKey(), (k) => collection.getKeyAfter(k));\n if (nextKey != null) {\n s.setFocusedKey(nextKey);\n }\n break;\n }\n case \"ArrowUp\": {\n e.preventDefault();\n const prevKey =\n focusedKey != null\n ? findNextNavigableKey(s, collection.getKeyBefore(focusedKey), (k) =>\n collection.getKeyBefore(k),\n )\n : findNextNavigableKey(s, collection.getLastKey(), (k) => collection.getKeyBefore(k));\n if (prevKey != null) {\n s.setFocusedKey(prevKey);\n }\n break;\n }\n case \"ArrowRight\":\n case \"ArrowLeft\": {\n // The inline axis (Left/Right) belongs to the ROW under the default\n // \"arrow\" navigation behavior: createGridListItem's onKeyDownCapture\n // intercepts Left/Right for intra-row focus movement (a no-op for\n // text-only rows), exactly as useGridListItem does upstream, so the\n // container must NOT step between rows here. Only under \"tab\" navigation\n // does the row stop intercepting and the event reach the collection —\n // mirroring how useSelectableCollection handles Left/Right via\n // ListKeyboardDelegate. Even then it strips getKeyLeftOf/getKeyRightOf\n // for a vertical stack, so this stays a no-op unless the stack is\n // horizontal, where Right=next / Left=prev in LTR, flipped under RTL.\n // (In Solid the row's capture-phase stopPropagation does not reliably\n // prevent the container's delegated onKeyDown, so this gate — not the\n // row's stopPropagation — is what keeps the axes from double-firing.)\n const behavior = p.keyboardNavigationBehavior ?? \"arrow\";\n if (p.orientation !== \"horizontal\" || behavior !== \"tab\") break;\n e.preventDefault();\n const isRtl = p.direction === \"rtl\";\n const forward = e.key === \"ArrowRight\" ? !isRtl : isRtl;\n const step = forward\n ? (k: Key) => collection.getKeyAfter(k)\n : (k: Key) => collection.getKeyBefore(k);\n const nextKey =\n focusedKey != null\n ? findNextNavigableKey(s, step(focusedKey), step)\n : findNextNavigableKey(s, collection.getFirstKey(), (k) => collection.getKeyAfter(k));\n if (nextKey != null) {\n s.setFocusedKey(nextKey);\n }\n break;\n }\n case \"Home\": {\n e.preventDefault();\n const firstKey = findNextNavigableKey(s, collection.getFirstKey(), (k) =>\n collection.getKeyAfter(k),\n );\n if (firstKey != null) {\n s.setFocusedKey(firstKey);\n }\n break;\n }\n case \"End\": {\n e.preventDefault();\n const lastKey = findNextNavigableKey(s, collection.getLastKey(), (k) =>\n collection.getKeyBefore(k),\n );\n if (lastKey != null) {\n s.setFocusedKey(lastKey);\n }\n break;\n }\n case \"a\":\n case \"A\": {\n if ((e.ctrlKey || e.metaKey) && s.selectionMode === \"multiple\") {\n e.preventDefault();\n s.selectAll();\n }\n break;\n }\n // Space (toggle selection) and Enter (onAction) are intentionally absent\n // here. Upstream's useSelectableCollection has no Space/Enter case — the\n // focused item owns both, via useSelectableItem. We follow browser focus\n // onto the focused row (the effect below), so the row's own handlers in\n // createGridListItem fire. Handling them here too would double-toggle a\n // focused row, because Solid delegates keydown and bubbles the row event\n // up to this grid handler.\n case \"Escape\": {\n if (s.selectionMode !== \"none\") {\n e.preventDefault();\n s.clearSelection();\n }\n break;\n }\n }\n };\n\n // Focus marshalling — the grid container is a trampoline. Its roving tabIndex\n // is 0 only while `focusedKey == null` (see gridProps below), so a Tab that\n // reaches a standalone grid lands on the container itself; move the focused key\n // onto the first/last row and the post-commit effect below pulls REAL DOM focus\n // there while the container rolls to tabIndex -1. This mirrors\n // useSelectableCollection's `onFocus` — the same direction-aware trampoline the\n // standalone ListBox uses (createListBox.ts) — and is why a standalone grid\n // announces the active row through real focus, never `aria-activedescendant`.\n const onFocus: JSX.EventHandler<HTMLElement, FocusEvent> = (e) => {\n const s = state();\n const p = props();\n s.setFocused(true);\n\n // onFocus is non-bubbling in Solid, so this fires only when the container\n // itself receives focus; ignore anything that bubbled from a descendant.\n // (`currentTarget` is null only in synthetic unit-test FocusEvents — treat\n // those as a direct container focus.)\n const container = e.currentTarget as HTMLElement | null;\n if (container && !container.contains(e.target as Node)) return;\n // Only marshal when no row is focused yet.\n if (s.focusedKey != null || p.isDisabled) return;\n\n const collection = s.collection;\n const relatedTarget = e.relatedTarget as Element | null;\n // Detect tab direction: focus arriving from an element that FOLLOWS the grid\n // in document order means the user shift-tabbed backward into it, so enter at\n // the LAST row; otherwise (forward Tab, or programmatic) enter at the FIRST.\n const enterKey =\n relatedTarget &&\n container &&\n container.compareDocumentPosition(relatedTarget) & Node.DOCUMENT_POSITION_FOLLOWING\n ? findNextNavigableKey(s, collection.getLastKey(), (k) => collection.getKeyBefore(k))\n : findNextNavigableKey(s, collection.getFirstKey(), (k) => collection.getKeyAfter(k));\n if (enterKey != null) {\n s.setFocusedKey(enterKey);\n }\n };\n\n const onBlur = () => {\n const s = state();\n s.setFocused(false);\n };\n\n // Mirror React Aria's useSelectableCollection: once the roving tabindex for the\n // focused key has been committed to the DOM, move browser focus onto that row\n // from a post-commit effect, looking it up by its stable data-key rather than by\n // transient tabindex. Selection and activation live on the row\n // (createGridListItem) to match upstream, so keyboard nav has to carry focus\n // there for the row's Space/Enter handlers to act on.\n createEffect(() => {\n const s = state();\n const key = s.focusedKey;\n const el = ref();\n if (!el || key == null) {\n return;\n }\n\n // Only manage focus while it already lives inside the grid — i.e. the user is\n // navigating with the keyboard. Gate on the physical position of browser focus\n // rather than the grid's logical isFocused signal: focus can land directly on a\n // row (a pointer click) without ever firing the grid's own focus handler, and\n // the contains() check keeps us from yanking focus back from elsewhere on the\n // page when the focused key changes from a background interaction.\n const active = document.activeElement;\n if (!active || (active !== el && !el.contains(active))) {\n return;\n }\n\n const target = el.querySelector<HTMLElement>(`[data-key=\"${key}\"]`);\n if (target && target !== active) {\n target.focus();\n\n // Reveal the newly focused row when navigating with the keyboard, mirroring\n // useSelectableCollection. Pointer-driven focus changes should not shift the\n // scroll position under the user's finger.\n if (getInteractionModality() !== \"pointer\") {\n scrollIntoViewport(target, { containingElement: el });\n }\n }\n });\n\n const gridProps = createMemo(() => {\n const p = props();\n const s = state();\n\n const baseProps: Record<string, unknown> = {\n role: \"grid\",\n id: gridListId,\n \"aria-label\": p[\"aria-label\"],\n \"aria-labelledby\": p[\"aria-labelledby\"],\n \"aria-describedby\": p[\"aria-describedby\"],\n \"aria-multiselectable\": s.selectionMode === \"multiple\" ? true : undefined,\n \"aria-disabled\": p.isDisabled || undefined,\n // Roving container tabIndex mirrors useSelectableCollection: the container\n // is tabbable (0) only while nothing is focused, then rolls to -1 once a row\n // takes focus so Tab exits the grid. A standalone grid drives AT through\n // real row focus, so it never needs (nor emits) aria-activedescendant.\n tabIndex: p.isDisabled ? undefined : s.focusedKey != null ? -1 : 0,\n onKeyDown,\n onFocus,\n onBlur,\n };\n\n // Add row count for virtualized lists\n if (p.isVirtualized) {\n baseProps[\"aria-rowcount\"] = s.collection.rowCount;\n }\n\n return baseProps as JSX.HTMLAttributes<HTMLElement>;\n });\n\n return {\n get gridProps() {\n return gridProps();\n },\n };\n}\n","/**\n * createGridListItem - Provides accessibility for a grid list item.\n * Based on @react-aria/gridlist/useGridListItem.\n */\n\nimport { createMemo, type Accessor } from \"solid-js\";\nimport type { JSX } from \"solid-js\";\nimport type {\n Collection,\n GridState,\n GridCollection,\n Key,\n Selection,\n} from \"@proyecto-viviana/solid-stately\";\nimport type { AriaGridListItemProps, GridListItemAria } from \"./types\";\nimport { getGridListData } from \"./createGridList\";\nimport { createSelectableItem, type SelectableItemState } from \"../selection/createSelectableItem\";\nimport { mergeCollectionRowInteractionProps } from \"../selection/createCollectionRowInteraction\";\nimport { mergeProps } from \"../utils/mergeProps\";\n\n/**\n * Creates accessibility props for a grid list item.\n */\nexport function createGridListItem<\n T extends object,\n C extends GridCollection<T> = GridCollection<T>,\n>(\n props: Accessor<AriaGridListItemProps>,\n state: Accessor<GridState<T, C>>,\n ref: Accessor<HTMLElement | null>,\n): GridListItemAria {\n const isSelected = createMemo(() => {\n const s = state();\n const p = props();\n return s.isSelected(p.node.key);\n });\n\n const selectableState: SelectableItemState<T> = {\n collection: () => state().collection as unknown as Collection<T>,\n isFocused: () => state().isFocused,\n setFocused: (focused: boolean) => state().setFocused(focused),\n focusedKey: () => state().focusedKey,\n childFocusStrategy: () => state().childFocusStrategy,\n setFocusedKey: (key: Key | null, strategy) => state().setFocusedKey(key, strategy),\n selectionMode: () => state().selectionMode,\n selectionBehavior: () => props().selectionBehavior ?? state().selectionBehavior,\n disallowEmptySelection: () => state().disallowEmptySelection,\n selectedKeys: () => state().selectedKeys as Selection,\n disabledKeys: () => state().disabledKeys,\n disabledBehavior: () => state().disabledBehavior,\n isEmpty: () => {\n const keys = state().selectedKeys;\n return keys !== \"all\" && keys.size === 0;\n },\n isSelectAll: () => state().selectedKeys === \"all\",\n isSelected: (key: Key) => state().isSelected(key),\n isDisabled: (key: Key) => {\n const s = state();\n const item = s.collection.getItem(key);\n return (\n s.disabledBehavior === \"all\" &&\n s.isDisabled(key) &&\n item?.props?.disabledBehavior !== \"selection\"\n );\n },\n canSelectItem: (key: Key) => {\n const s = state();\n return s.selectionMode !== \"none\" && !s.isDisabled(key);\n },\n setSelectionBehavior: (behavior) => state().setSelectionBehavior(behavior),\n toggleSelection: (key: Key) => state().toggleSelection(key),\n replaceSelection: (key: Key) => state().replaceSelection(key),\n setSelectedKeys: (keys: Iterable<Key>) => state().setSelectedKeys(keys),\n selectAll: () => state().selectAll(),\n clearSelection: () => state().clearSelection(),\n toggleSelectAll: () => state().toggleSelectAll(),\n extendSelection: (toKey: Key, _collection: Collection<T>) => state().extendSelection(toKey),\n };\n\n const selectableItem = createSelectableItem<T>(\n () => {\n const s = state();\n const p = props();\n const gridListData = getGridListData(s);\n const onAction = gridListData?.actions.onAction;\n\n return {\n key: p.node.key,\n id: `${gridListData?.gridListId ?? \"gridlist\"}-row-${String(p.node.key)}`,\n isVirtualized: p.isVirtualized,\n shouldSelectOnPressUp: gridListData?.shouldSelectOnPressUp ?? false,\n onAction:\n onAction || p.onAction\n ? () => {\n p.onAction?.();\n onAction?.(p.node.key);\n }\n : undefined,\n };\n },\n selectableState,\n ref,\n );\n\n const rowProps = createMemo(() => {\n const s = state();\n const p = props();\n const node = p.node;\n\n const baseProps: Record<string, unknown> = {\n role: \"row\",\n \"aria-selected\": s.selectionMode !== \"none\" ? isSelected() : undefined,\n \"aria-disabled\": selectableItem.isDisabled() || undefined,\n };\n\n // Add aria-rowindex for virtualized lists\n if (p.isVirtualized && node.rowIndex != null) {\n baseProps[\"aria-rowindex\"] = node.rowIndex + 1; // 1-based\n }\n\n const gridListData = getGridListData(s);\n const mergedProps = mergeProps<JSX.HTMLAttributes<HTMLElement>>(\n selectableItem.itemProps,\n baseProps,\n );\n\n return mergeCollectionRowInteractionProps(mergedProps, {\n ref,\n keyboardNavigationBehavior: () => gridListData?.keyboardNavigationBehavior ?? \"arrow\",\n direction: () => gridListData?.direction ?? \"ltr\",\n });\n });\n\n const gridCellProps = createMemo(() => {\n return {\n role: \"gridcell\",\n } as JSX.HTMLAttributes<HTMLDivElement>;\n });\n\n return {\n get rowProps() {\n return rowProps();\n },\n get gridCellProps() {\n return gridCellProps();\n },\n get isSelected() {\n return isSelected();\n },\n get isDisabled() {\n return selectableItem.isDisabled();\n },\n get isPressed() {\n return selectableItem.isPressed();\n },\n };\n}\n","/**\n * createGridListSelectionCheckbox - Provides accessibility for a grid list item selection checkbox.\n * Based on @react-aria/gridlist.\n */\n\nimport { createMemo, type Accessor } from \"solid-js\";\nimport type { JSX } from \"solid-js\";\nimport { createId } from \"@proyecto-viviana/solid-stately\";\nimport type { GridState, GridCollection } from \"@proyecto-viviana/solid-stately\";\nimport type { AriaGridListSelectionCheckboxProps, GridListSelectionCheckboxAria } from \"./types\";\n\n/**\n * Creates accessibility props for a grid list item selection checkbox.\n */\nexport function createGridListSelectionCheckbox<\n T extends object,\n C extends GridCollection<T> = GridCollection<T>,\n>(\n props: Accessor<AriaGridListSelectionCheckboxProps>,\n state: Accessor<GridState<T, C>>,\n): GridListSelectionCheckboxAria {\n const checkboxId = createId();\n\n const isSelected = createMemo(() => {\n const s = state();\n const p = props();\n return s.isSelected(p.key);\n });\n\n const isDisabled = createMemo(() => {\n const s = state();\n const p = props();\n return s.isDisabled(p.key);\n });\n\n const onChange = () => {\n const s = state();\n const p = props();\n if (!isDisabled()) {\n s.toggleSelection(p.key);\n }\n };\n\n const checkboxProps = createMemo(() => {\n const baseProps: Record<string, unknown> = {\n id: checkboxId,\n type: \"checkbox\",\n checked: isSelected(),\n disabled: isDisabled(),\n onChange,\n \"aria-label\": \"Select\",\n };\n\n return baseProps as JSX.InputHTMLAttributes<HTMLInputElement>;\n });\n\n return {\n get checkboxProps() {\n return checkboxProps();\n },\n };\n}\n","/**\n * createGridListSection - Provides accessibility for a grid list section.\n * Based on @react-aria/gridlist/useGridListSection.\n */\n\nimport { createMemo } from \"solid-js\";\nimport { createId, createSlotId } from \"../ssr\";\nimport { createLabels } from \"../label/createLabels\";\nimport type { AriaGridListSectionProps, GridListSectionAria } from \"./types\";\n\n/**\n * Creates accessibility props for a grid list section.\n *\n * Mirrors upstream `useGridListSection`: a section is a `role=\"rowgroup\"`\n * wrapper whose optional header renders as `role=\"row\"` › `role=\"rowheader\"`.\n * The `aria-labelledby` of the wrapper points at the header's id via a slot id\n * that resolves to `undefined` when no header is rendered.\n */\nexport function createGridListSection(props: AriaGridListSectionProps): GridListSectionAria {\n const headingId = createSlotId();\n // Stable id for the rowgroup so `createLabels` does not regenerate one each\n // time the slot id resolves (it short-circuits on a provided id).\n const rowGroupId = createId();\n\n const labelProps = createMemo(() =>\n createLabels({\n id: rowGroupId,\n \"aria-label\": props[\"aria-label\"],\n \"aria-labelledby\": headingId(),\n }),\n );\n\n return {\n rowProps: { role: \"row\" },\n rowHeaderProps: {\n get id() {\n return headingId();\n },\n role: \"rowheader\",\n },\n rowGroupProps: {\n role: \"rowgroup\",\n get id() {\n return labelProps().id;\n },\n get \"aria-label\"() {\n return labelProps()[\"aria-label\"];\n },\n get \"aria-labelledby\"() {\n return labelProps()[\"aria-labelledby\"];\n },\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoCA,MAAM,kCAAkB,IAA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BACjB,aAAa;EACX,IAAI;EACJ,cAAc,MAAM;EACpB,mBAAmB,UAAU;CAC/B,CAAC,CACH;CAEA,OAAO;EACL,UAAU,EAAE,MAAM,MAAM;EACxB,gBAAgB;GACd,IAAI,KAAK;IACP,OAAO,UAAU;GACnB;GACA,MAAM;EACR;EACA,eAAe;GACb,MAAM;GACN,IAAI,KAAK;IACP,OAAO,WAAW,CAAC,CAAC;GACtB;GACA,IAAI,eAAe;IACjB,OAAO,WAAW,CAAC,CAAC;GACtB;GACA,IAAI,oBAAoB;IACtB,OAAO,WAAW,CAAC,CAAC;GACtB;EACF;CACF;AACF"}
|
package/dist/_chunk/i18n.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as createCacheKey, i as useLocale } from "./locale.js";
|
|
2
|
+
import { t as createCollator } from "./createCollator.js";
|
|
2
3
|
import { createMemo } from "solid-js";
|
|
3
4
|
import { NumberFormatter, NumberFormatter as NumberFormatter$1 } from "@internationalized/number";
|
|
4
|
-
import { LocalizedStringDictionary, LocalizedStringFormatter } from "@internationalized/string";
|
|
5
5
|
//#region src/i18n/createNumberFormatter.ts
|
|
6
6
|
/**
|
|
7
7
|
* createNumberFormatter hook for solidaria
|
|
@@ -194,61 +194,6 @@ function createFilter(options) {
|
|
|
194
194
|
});
|
|
195
195
|
}
|
|
196
196
|
//#endregion
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* String formatter for localized strings with ICU MessageFormat support.
|
|
200
|
-
* Port of @react-aria/i18n useLocalizedStringFormatter.
|
|
201
|
-
*/
|
|
202
|
-
const cache = /* @__PURE__ */ new WeakMap();
|
|
203
|
-
function getCachedDictionary(strings) {
|
|
204
|
-
let dictionary = cache.get(strings);
|
|
205
|
-
if (!dictionary) {
|
|
206
|
-
dictionary = new LocalizedStringDictionary(strings);
|
|
207
|
-
cache.set(strings, dictionary);
|
|
208
|
-
}
|
|
209
|
-
return dictionary;
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Returns a cached LocalizedStringDictionary for the given strings.
|
|
213
|
-
*/
|
|
214
|
-
function createStringDictionary(strings, packageName) {
|
|
215
|
-
return packageName && LocalizedStringDictionary.getGlobalDictionaryForPackage(packageName) || getCachedDictionary(strings);
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Provides localized string formatting for the current locale.
|
|
219
|
-
* Supports interpolating variables, selecting the correct pluralization,
|
|
220
|
-
* and formatting numbers. Automatically updates when the locale changes.
|
|
221
|
-
*
|
|
222
|
-
* @param strings - A mapping of languages to localized strings by key.
|
|
223
|
-
* @param packageName - Optional package name for global dictionary lookup.
|
|
224
|
-
*
|
|
225
|
-
* @example
|
|
226
|
-
* ```tsx
|
|
227
|
-
* const strings = {
|
|
228
|
-
* 'en-US': {
|
|
229
|
-
* greeting: 'Hello, {name}!',
|
|
230
|
-
* count: '{count, plural, one {# item} other {# items}}'
|
|
231
|
-
* }
|
|
232
|
-
* };
|
|
233
|
-
*
|
|
234
|
-
* function MyComponent() {
|
|
235
|
-
* const stringFormatter = createStringFormatter(strings);
|
|
236
|
-
*
|
|
237
|
-
* return (
|
|
238
|
-
* <div>
|
|
239
|
-
* {stringFormatter().format('greeting', { name: 'World' })}
|
|
240
|
-
* {stringFormatter().format('count', { count: 5 })}
|
|
241
|
-
* </div>
|
|
242
|
-
* );
|
|
243
|
-
* }
|
|
244
|
-
* ```
|
|
245
|
-
*/
|
|
246
|
-
function createStringFormatter(strings, packageName) {
|
|
247
|
-
const localeAccessor = useLocale();
|
|
248
|
-
const dictionary = createStringDictionary(strings, packageName);
|
|
249
|
-
return createMemo(() => new LocalizedStringFormatter(localeAccessor().locale, dictionary));
|
|
250
|
-
}
|
|
251
|
-
//#endregion
|
|
252
|
-
export { createDateFormatter as a, createFilter as i, createStringDictionary as n, createNumberFormatter as o, createStringFormatter as r, NumberFormatter$1 as t };
|
|
197
|
+
export { createNumberFormatter as i, createFilter as n, createDateFormatter as r, NumberFormatter$1 as t };
|
|
253
198
|
|
|
254
199
|
//# sourceMappingURL=i18n.js.map
|
package/dist/_chunk/i18n.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.js","names":[],"sources":["../../src/i18n/createNumberFormatter.ts","../../src/i18n/createDateFormatter.ts","../../src/i18n/createFilter.ts","../../src/i18n/createStringFormatter.ts"],"sourcesContent":["/**\n * createNumberFormatter hook for solidaria\n *\n * Provides localized number formatting with automatic locale updates.\n *\n * Port of @react-aria/i18n useNumberFormatter.\n */\n\nimport { createMemo } from \"solid-js\";\nimport { useLocale } from \"./locale\";\nimport { NumberFormatter, type NumberFormatOptions } from \"@internationalized/number\";\n\n/**\n * Provides localized number formatting for the current locale.\n * Automatically updates when the locale changes.\n *\n * @example\n * ```tsx\n * function PriceDisplay(props: { value: number }) {\n * const formatter = createNumberFormatter({\n * style: 'currency',\n * currency: 'USD',\n * });\n *\n * return <span>{formatter().format(props.value)}</span>;\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Percent formatting\n * const percentFormatter = createNumberFormatter({\n * style: 'percent',\n * minimumFractionDigits: 1,\n * });\n * percentFormatter().format(0.125); // '12.5%'\n *\n * // Unit formatting\n * const tempFormatter = createNumberFormatter({\n * style: 'unit',\n * unit: 'celsius',\n * });\n * tempFormatter().format(25); // '25°C'\n * ```\n */\nexport function createNumberFormatter(options: NumberFormatOptions = {}): () => NumberFormatter {\n const locale = useLocale();\n\n return createMemo(() => new NumberFormatter(locale().locale, options));\n}\n","/**\n * createDateFormatter hook for solidaria\n *\n * Provides localized date formatting with caching.\n *\n * Port of @react-aria/i18n useDateFormatter.\n */\n\nimport { createMemo } from \"solid-js\";\nimport { useLocale } from \"./locale\";\nimport { createCacheKey } from \"./utils\";\n\nconst dateFormatterCache = new Map<string, Intl.DateTimeFormat>();\n\n/**\n * Gets or creates a cached date formatter.\n */\nfunction getCachedDateFormatter(\n locale: string,\n options?: Intl.DateTimeFormatOptions,\n): Intl.DateTimeFormat {\n const cacheKey = createCacheKey(locale, options as Record<string, unknown>);\n\n if (dateFormatterCache.has(cacheKey)) {\n return dateFormatterCache.get(cacheKey)!;\n }\n\n const formatter = new Intl.DateTimeFormat(locale, options);\n dateFormatterCache.set(cacheKey, formatter);\n return formatter;\n}\n\n/**\n * Provides localized date and time formatting for the current locale.\n * Automatically updates when the locale changes.\n *\n * @example\n * ```tsx\n * function DateDisplay(props: { date: Date }) {\n * const formatter = createDateFormatter({\n * year: 'numeric',\n * month: 'long',\n * day: 'numeric',\n * });\n *\n * return <span>{formatter().format(props.date)}</span>;\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Short date\n * const shortDate = createDateFormatter({ dateStyle: 'short' });\n * shortDate().format(new Date()); // '1/19/26' (US) or '19/01/26' (UK)\n *\n * // Full date with time\n * const fullDateTime = createDateFormatter({\n * dateStyle: 'full',\n * timeStyle: 'short',\n * });\n *\n * // Time only\n * const timeFormatter = createDateFormatter({\n * hour: 'numeric',\n * minute: '2-digit',\n * });\n * ```\n */\nexport function createDateFormatter(\n options?: Intl.DateTimeFormatOptions,\n): () => Intl.DateTimeFormat {\n const locale = useLocale();\n\n return createMemo(() => getCachedDateFormatter(locale().locale, options));\n}\n","/**\n * createFilter hook for solidaria\n *\n * Provides localized string filtering with collation support.\n *\n * Port of @react-aria/i18n useFilter.\n */\n\nimport { createMemo } from \"solid-js\";\nimport { createCollator } from \"./createCollator\";\n\nexport interface Filter {\n /** Returns whether a string starts with a given substring. */\n startsWith(string: string, substring: string): boolean;\n /** Returns whether a string ends with a given substring. */\n endsWith(string: string, substring: string): boolean;\n /** Returns whether a string contains a given substring. */\n contains(string: string, substring: string): boolean;\n}\n\n/**\n * Provides localized string search functionality for filtering or matching items.\n * Respects locale-specific collation rules for case and diacritic sensitivity.\n *\n * @example\n * ```tsx\n * function SearchableList(props: { items: { name: string }[] }) {\n * const [query, setQuery] = createSignal('');\n * const filter = createFilter({ sensitivity: 'base' });\n *\n * const filteredItems = () =>\n * props.items.filter((item) =>\n * filter().contains(item.name, query())\n * );\n *\n * return (\n * <>\n * <input\n * value={query()}\n * onInput={(e) => setQuery(e.target.value)}\n * placeholder=\"Search...\"\n * />\n * <ul>\n * <For each={filteredItems()}>\n * {(item) => <li>{item.name}</li>}\n * </For>\n * </ul>\n * </>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Case-insensitive, diacritic-insensitive filtering\n * const filter = createFilter({ sensitivity: 'base' });\n * filter().contains('Café', 'cafe'); // true\n * filter().startsWith('Hello', 'hello'); // true\n * ```\n */\nexport function createFilter(options?: Intl.CollatorOptions): () => Filter {\n const collator = createCollator({\n usage: \"search\",\n ...options,\n });\n\n return createMemo(() => {\n const coll = collator();\n\n const startsWith = (str: string, substring: string): boolean => {\n if (substring.length === 0) {\n return true;\n }\n\n // Normalize both strings for safe slicing\n const normalizedStr = str.normalize(\"NFC\");\n const normalizedSub = substring.normalize(\"NFC\");\n\n return coll.compare(normalizedStr.slice(0, normalizedSub.length), normalizedSub) === 0;\n };\n\n const endsWith = (str: string, substring: string): boolean => {\n if (substring.length === 0) {\n return true;\n }\n\n const normalizedStr = str.normalize(\"NFC\");\n const normalizedSub = substring.normalize(\"NFC\");\n\n return coll.compare(normalizedStr.slice(-normalizedSub.length), normalizedSub) === 0;\n };\n\n const contains = (str: string, substring: string): boolean => {\n if (substring.length === 0) {\n return true;\n }\n\n const normalizedStr = str.normalize(\"NFC\");\n const normalizedSub = substring.normalize(\"NFC\");\n const sliceLen = normalizedSub.length;\n\n for (let scan = 0; scan + sliceLen <= normalizedStr.length; scan++) {\n const slice = normalizedStr.slice(scan, scan + sliceLen);\n if (coll.compare(normalizedSub, slice) === 0) {\n return true;\n }\n }\n\n return false;\n };\n\n return {\n startsWith,\n endsWith,\n contains,\n };\n });\n}\n","/**\n * String formatter for localized strings with ICU MessageFormat support.\n * Port of @react-aria/i18n useLocalizedStringFormatter.\n */\n\nimport {\n LocalizedString,\n LocalizedStringDictionary,\n LocalizedStringFormatter,\n type LocalizedStrings,\n} from \"@internationalized/string\";\nimport { createMemo, type Accessor } from \"solid-js\";\nimport { useLocale } from \"./locale\";\n\n// Cache for dictionaries to avoid recreating them\nconst cache = new WeakMap<\n LocalizedStrings<string, LocalizedString>,\n LocalizedStringDictionary<string, LocalizedString>\n>();\n\nfunction getCachedDictionary<K extends string, T extends LocalizedString>(\n strings: LocalizedStrings<K, T>,\n): LocalizedStringDictionary<K, T> {\n let dictionary = cache.get(strings as LocalizedStrings<string, LocalizedString>);\n if (!dictionary) {\n dictionary = new LocalizedStringDictionary(\n strings as LocalizedStrings<string, LocalizedString>,\n );\n cache.set(strings as LocalizedStrings<string, LocalizedString>, dictionary);\n }\n return dictionary as LocalizedStringDictionary<K, T>;\n}\n\n/**\n * Returns a cached LocalizedStringDictionary for the given strings.\n */\nexport function createStringDictionary<\n K extends string = string,\n T extends LocalizedString = string,\n>(strings: LocalizedStrings<K, T>, packageName?: string): LocalizedStringDictionary<K, T> {\n return (\n (packageName && LocalizedStringDictionary.getGlobalDictionaryForPackage(packageName)) ||\n getCachedDictionary(strings)\n );\n}\n\n/**\n * Provides localized string formatting for the current locale.\n * Supports interpolating variables, selecting the correct pluralization,\n * and formatting numbers. Automatically updates when the locale changes.\n *\n * @param strings - A mapping of languages to localized strings by key.\n * @param packageName - Optional package name for global dictionary lookup.\n *\n * @example\n * ```tsx\n * const strings = {\n * 'en-US': {\n * greeting: 'Hello, {name}!',\n * count: '{count, plural, one {# item} other {# items}}'\n * }\n * };\n *\n * function MyComponent() {\n * const stringFormatter = createStringFormatter(strings);\n *\n * return (\n * <div>\n * {stringFormatter().format('greeting', { name: 'World' })}\n * {stringFormatter().format('count', { count: 5 })}\n * </div>\n * );\n * }\n * ```\n */\nexport function createStringFormatter<\n K extends string = string,\n T extends LocalizedString = string,\n>(strings: LocalizedStrings<K, T>, packageName?: string): Accessor<LocalizedStringFormatter<K, T>> {\n const localeAccessor = useLocale();\n const dictionary = createStringDictionary(strings, packageName);\n\n return createMemo(() => new LocalizedStringFormatter(localeAccessor().locale, dictionary));\n}\n\nexport type {\n LocalizedString,\n LocalizedStringDictionary,\n LocalizedStringFormatter,\n LocalizedStrings,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,SAAgB,sBAAsB,UAA+B,CAAC,GAA0B;CAC9F,MAAM,SAAS,UAAU;CAEzB,OAAO,iBAAiB,IAAI,gBAAgB,OAAO,CAAC,CAAC,QAAQ,OAAO,CAAC;AACvE;;;;;;;;;;ACrCA,MAAM,qCAAqB,IAAI,IAAiC;;;;AAKhE,SAAS,uBACP,QACA,SACqB;CACrB,MAAM,WAAW,eAAe,QAAQ,OAAkC;CAE1E,IAAI,mBAAmB,IAAI,QAAQ,GACjC,OAAO,mBAAmB,IAAI,QAAQ;CAGxC,MAAM,YAAY,IAAI,KAAK,eAAe,QAAQ,OAAO;CACzD,mBAAmB,IAAI,UAAU,SAAS;CAC1C,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,SAAgB,oBACd,SAC2B;CAC3B,MAAM,SAAS,UAAU;CAEzB,OAAO,iBAAiB,uBAAuB,OAAO,CAAC,CAAC,QAAQ,OAAO,CAAC;AAC1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACdA,SAAgB,aAAa,SAA8C;CACzE,MAAM,WAAW,eAAe;EAC9B,OAAO;EACP,GAAG;CACL,CAAC;CAED,OAAO,iBAAiB;EACtB,MAAM,OAAO,SAAS;EAEtB,MAAM,cAAc,KAAa,cAA+B;GAC9D,IAAI,UAAU,WAAW,GACvB,OAAO;GAIT,MAAM,gBAAgB,IAAI,UAAU,KAAK;GACzC,MAAM,gBAAgB,UAAU,UAAU,KAAK;GAE/C,OAAO,KAAK,QAAQ,cAAc,MAAM,GAAG,cAAc,MAAM,GAAG,aAAa,MAAM;EACvF;EAEA,MAAM,YAAY,KAAa,cAA+B;G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i18n/createFilter.ts"],"sourcesContent":["/**\n * createNumberFormatter hook for solidaria\n *\n * Provides localized number formatting with automatic locale updates.\n *\n * Port of @react-aria/i18n useNumberFormatter.\n */\n\nimport { createMemo } from \"solid-js\";\nimport { useLocale } from \"./locale\";\nimport { NumberFormatter, type NumberFormatOptions } from \"@internationalized/number\";\n\n/**\n * Provides localized number formatting for the current locale.\n * Automatically updates when the locale changes.\n *\n * @example\n * ```tsx\n * function PriceDisplay(props: { value: number }) {\n * const formatter = createNumberFormatter({\n * style: 'currency',\n * currency: 'USD',\n * });\n *\n * return <span>{formatter().format(props.value)}</span>;\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Percent formatting\n * const percentFormatter = createNumberFormatter({\n * style: 'percent',\n * minimumFractionDigits: 1,\n * });\n * percentFormatter().format(0.125); // '12.5%'\n *\n * // Unit formatting\n * const tempFormatter = createNumberFormatter({\n * style: 'unit',\n * unit: 'celsius',\n * });\n * tempFormatter().format(25); // '25°C'\n * ```\n */\nexport function createNumberFormatter(options: NumberFormatOptions = {}): () => NumberFormatter {\n const locale = useLocale();\n\n return createMemo(() => new NumberFormatter(locale().locale, options));\n}\n","/**\n * createDateFormatter hook for solidaria\n *\n * Provides localized date formatting with caching.\n *\n * Port of @react-aria/i18n useDateFormatter.\n */\n\nimport { createMemo } from \"solid-js\";\nimport { useLocale } from \"./locale\";\nimport { createCacheKey } from \"./utils\";\n\nconst dateFormatterCache = new Map<string, Intl.DateTimeFormat>();\n\n/**\n * Gets or creates a cached date formatter.\n */\nfunction getCachedDateFormatter(\n locale: string,\n options?: Intl.DateTimeFormatOptions,\n): Intl.DateTimeFormat {\n const cacheKey = createCacheKey(locale, options as Record<string, unknown>);\n\n if (dateFormatterCache.has(cacheKey)) {\n return dateFormatterCache.get(cacheKey)!;\n }\n\n const formatter = new Intl.DateTimeFormat(locale, options);\n dateFormatterCache.set(cacheKey, formatter);\n return formatter;\n}\n\n/**\n * Provides localized date and time formatting for the current locale.\n * Automatically updates when the locale changes.\n *\n * @example\n * ```tsx\n * function DateDisplay(props: { date: Date }) {\n * const formatter = createDateFormatter({\n * year: 'numeric',\n * month: 'long',\n * day: 'numeric',\n * });\n *\n * return <span>{formatter().format(props.date)}</span>;\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Short date\n * const shortDate = createDateFormatter({ dateStyle: 'short' });\n * shortDate().format(new Date()); // '1/19/26' (US) or '19/01/26' (UK)\n *\n * // Full date with time\n * const fullDateTime = createDateFormatter({\n * dateStyle: 'full',\n * timeStyle: 'short',\n * });\n *\n * // Time only\n * const timeFormatter = createDateFormatter({\n * hour: 'numeric',\n * minute: '2-digit',\n * });\n * ```\n */\nexport function createDateFormatter(\n options?: Intl.DateTimeFormatOptions,\n): () => Intl.DateTimeFormat {\n const locale = useLocale();\n\n return createMemo(() => getCachedDateFormatter(locale().locale, options));\n}\n","/**\n * createFilter hook for solidaria\n *\n * Provides localized string filtering with collation support.\n *\n * Port of @react-aria/i18n useFilter.\n */\n\nimport { createMemo } from \"solid-js\";\nimport { createCollator } from \"./createCollator\";\n\nexport interface Filter {\n /** Returns whether a string starts with a given substring. */\n startsWith(string: string, substring: string): boolean;\n /** Returns whether a string ends with a given substring. */\n endsWith(string: string, substring: string): boolean;\n /** Returns whether a string contains a given substring. */\n contains(string: string, substring: string): boolean;\n}\n\n/**\n * Provides localized string search functionality for filtering or matching items.\n * Respects locale-specific collation rules for case and diacritic sensitivity.\n *\n * @example\n * ```tsx\n * function SearchableList(props: { items: { name: string }[] }) {\n * const [query, setQuery] = createSignal('');\n * const filter = createFilter({ sensitivity: 'base' });\n *\n * const filteredItems = () =>\n * props.items.filter((item) =>\n * filter().contains(item.name, query())\n * );\n *\n * return (\n * <>\n * <input\n * value={query()}\n * onInput={(e) => setQuery(e.target.value)}\n * placeholder=\"Search...\"\n * />\n * <ul>\n * <For each={filteredItems()}>\n * {(item) => <li>{item.name}</li>}\n * </For>\n * </ul>\n * </>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Case-insensitive, diacritic-insensitive filtering\n * const filter = createFilter({ sensitivity: 'base' });\n * filter().contains('Café', 'cafe'); // true\n * filter().startsWith('Hello', 'hello'); // true\n * ```\n */\nexport function createFilter(options?: Intl.CollatorOptions): () => Filter {\n const collator = createCollator({\n usage: \"search\",\n ...options,\n });\n\n return createMemo(() => {\n const coll = collator();\n\n const startsWith = (str: string, substring: string): boolean => {\n if (substring.length === 0) {\n return true;\n }\n\n // Normalize both strings for safe slicing\n const normalizedStr = str.normalize(\"NFC\");\n const normalizedSub = substring.normalize(\"NFC\");\n\n return coll.compare(normalizedStr.slice(0, normalizedSub.length), normalizedSub) === 0;\n };\n\n const endsWith = (str: string, substring: string): boolean => {\n if (substring.length === 0) {\n return true;\n }\n\n const normalizedStr = str.normalize(\"NFC\");\n const normalizedSub = substring.normalize(\"NFC\");\n\n return coll.compare(normalizedStr.slice(-normalizedSub.length), normalizedSub) === 0;\n };\n\n const contains = (str: string, substring: string): boolean => {\n if (substring.length === 0) {\n return true;\n }\n\n const normalizedStr = str.normalize(\"NFC\");\n const normalizedSub = substring.normalize(\"NFC\");\n const sliceLen = normalizedSub.length;\n\n for (let scan = 0; scan + sliceLen <= normalizedStr.length; scan++) {\n const slice = normalizedStr.slice(scan, scan + sliceLen);\n if (coll.compare(normalizedSub, slice) === 0) {\n return true;\n }\n }\n\n return false;\n };\n\n return {\n startsWith,\n endsWith,\n contains,\n };\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,SAAgB,sBAAsB,UAA+B,CAAC,GAA0B;CAC9F,MAAM,SAAS,UAAU;CAEzB,OAAO,iBAAiB,IAAI,gBAAgB,OAAO,CAAC,CAAC,QAAQ,OAAO,CAAC;AACvE;;;;;;;;;;ACrCA,MAAM,qCAAqB,IAAI,IAAiC;;;;AAKhE,SAAS,uBACP,QACA,SACqB;CACrB,MAAM,WAAW,eAAe,QAAQ,OAAkC;CAE1E,IAAI,mBA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AAM,OAAO,QAAQ;IACvD,IAAI,KAAK,QAAQ,eAAe,KAAK,MAAM,GACzC,OAAO;GAEX;GAEA,OAAO;EACT;EAEA,OAAO;GACL;GACA;GACA;EACF;CACF,CAAC;AACH"}
|
package/dist/_chunk/i18n.jsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as createCacheKey, i as useLocale } from "./locale.jsx";
|
|
2
|
+
import { t as createCollator } from "./createCollator.jsx";
|
|
2
3
|
import { createMemo } from "solid-js";
|
|
3
4
|
import { NumberFormatter, NumberFormatter as NumberFormatter$1 } from "@internationalized/number";
|
|
4
|
-
import { LocalizedStringDictionary, LocalizedStringFormatter } from "@internationalized/string";
|
|
5
5
|
//#region src/i18n/createNumberFormatter.ts
|
|
6
6
|
/**
|
|
7
7
|
* createNumberFormatter hook for solidaria
|
|
@@ -194,61 +194,6 @@ function createFilter(options) {
|
|
|
194
194
|
});
|
|
195
195
|
}
|
|
196
196
|
//#endregion
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* String formatter for localized strings with ICU MessageFormat support.
|
|
200
|
-
* Port of @react-aria/i18n useLocalizedStringFormatter.
|
|
201
|
-
*/
|
|
202
|
-
const cache = /* @__PURE__ */ new WeakMap();
|
|
203
|
-
function getCachedDictionary(strings) {
|
|
204
|
-
let dictionary = cache.get(strings);
|
|
205
|
-
if (!dictionary) {
|
|
206
|
-
dictionary = new LocalizedStringDictionary(strings);
|
|
207
|
-
cache.set(strings, dictionary);
|
|
208
|
-
}
|
|
209
|
-
return dictionary;
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Returns a cached LocalizedStringDictionary for the given strings.
|
|
213
|
-
*/
|
|
214
|
-
function createStringDictionary(strings, packageName) {
|
|
215
|
-
return packageName && LocalizedStringDictionary.getGlobalDictionaryForPackage(packageName) || getCachedDictionary(strings);
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Provides localized string formatting for the current locale.
|
|
219
|
-
* Supports interpolating variables, selecting the correct pluralization,
|
|
220
|
-
* and formatting numbers. Automatically updates when the locale changes.
|
|
221
|
-
*
|
|
222
|
-
* @param strings - A mapping of languages to localized strings by key.
|
|
223
|
-
* @param packageName - Optional package name for global dictionary lookup.
|
|
224
|
-
*
|
|
225
|
-
* @example
|
|
226
|
-
* ```tsx
|
|
227
|
-
* const strings = {
|
|
228
|
-
* 'en-US': {
|
|
229
|
-
* greeting: 'Hello, {name}!',
|
|
230
|
-
* count: '{count, plural, one {# item} other {# items}}'
|
|
231
|
-
* }
|
|
232
|
-
* };
|
|
233
|
-
*
|
|
234
|
-
* function MyComponent() {
|
|
235
|
-
* const stringFormatter = createStringFormatter(strings);
|
|
236
|
-
*
|
|
237
|
-
* return (
|
|
238
|
-
* <div>
|
|
239
|
-
* {stringFormatter().format('greeting', { name: 'World' })}
|
|
240
|
-
* {stringFormatter().format('count', { count: 5 })}
|
|
241
|
-
* </div>
|
|
242
|
-
* );
|
|
243
|
-
* }
|
|
244
|
-
* ```
|
|
245
|
-
*/
|
|
246
|
-
function createStringFormatter(strings, packageName) {
|
|
247
|
-
const localeAccessor = useLocale();
|
|
248
|
-
const dictionary = createStringDictionary(strings, packageName);
|
|
249
|
-
return createMemo(() => new LocalizedStringFormatter(localeAccessor().locale, dictionary));
|
|
250
|
-
}
|
|
251
|
-
//#endregion
|
|
252
|
-
export { createDateFormatter as a, createFilter as i, createStringDictionary as n, createNumberFormatter as o, createStringFormatter as r, NumberFormatter$1 as t };
|
|
197
|
+
export { createNumberFormatter as i, createFilter as n, createDateFormatter as r, NumberFormatter$1 as t };
|
|
253
198
|
|
|
254
199
|
//# sourceMappingURL=i18n.jsx.map
|
package/dist/_chunk/i18n.jsx.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.jsx","names":[],"sources":["../../src/i18n/createNumberFormatter.ts","../../src/i18n/createDateFormatter.ts","../../src/i18n/createFilter.ts","../../src/i18n/createStringFormatter.ts"],"sourcesContent":["/**\n * createNumberFormatter hook for solidaria\n *\n * Provides localized number formatting with automatic locale updates.\n *\n * Port of @react-aria/i18n useNumberFormatter.\n */\n\nimport { createMemo } from \"solid-js\";\nimport { useLocale } from \"./locale\";\nimport { NumberFormatter, type NumberFormatOptions } from \"@internationalized/number\";\n\n/**\n * Provides localized number formatting for the current locale.\n * Automatically updates when the locale changes.\n *\n * @example\n * ```tsx\n * function PriceDisplay(props: { value: number }) {\n * const formatter = createNumberFormatter({\n * style: 'currency',\n * currency: 'USD',\n * });\n *\n * return <span>{formatter().format(props.value)}</span>;\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Percent formatting\n * const percentFormatter = createNumberFormatter({\n * style: 'percent',\n * minimumFractionDigits: 1,\n * });\n * percentFormatter().format(0.125); // '12.5%'\n *\n * // Unit formatting\n * const tempFormatter = createNumberFormatter({\n * style: 'unit',\n * unit: 'celsius',\n * });\n * tempFormatter().format(25); // '25°C'\n * ```\n */\nexport function createNumberFormatter(options: NumberFormatOptions = {}): () => NumberFormatter {\n const locale = useLocale();\n\n return createMemo(() => new NumberFormatter(locale().locale, options));\n}\n","/**\n * createDateFormatter hook for solidaria\n *\n * Provides localized date formatting with caching.\n *\n * Port of @react-aria/i18n useDateFormatter.\n */\n\nimport { createMemo } from \"solid-js\";\nimport { useLocale } from \"./locale\";\nimport { createCacheKey } from \"./utils\";\n\nconst dateFormatterCache = new Map<string, Intl.DateTimeFormat>();\n\n/**\n * Gets or creates a cached date formatter.\n */\nfunction getCachedDateFormatter(\n locale: string,\n options?: Intl.DateTimeFormatOptions,\n): Intl.DateTimeFormat {\n const cacheKey = createCacheKey(locale, options as Record<string, unknown>);\n\n if (dateFormatterCache.has(cacheKey)) {\n return dateFormatterCache.get(cacheKey)!;\n }\n\n const formatter = new Intl.DateTimeFormat(locale, options);\n dateFormatterCache.set(cacheKey, formatter);\n return formatter;\n}\n\n/**\n * Provides localized date and time formatting for the current locale.\n * Automatically updates when the locale changes.\n *\n * @example\n * ```tsx\n * function DateDisplay(props: { date: Date }) {\n * const formatter = createDateFormatter({\n * year: 'numeric',\n * month: 'long',\n * day: 'numeric',\n * });\n *\n * return <span>{formatter().format(props.date)}</span>;\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Short date\n * const shortDate = createDateFormatter({ dateStyle: 'short' });\n * shortDate().format(new Date()); // '1/19/26' (US) or '19/01/26' (UK)\n *\n * // Full date with time\n * const fullDateTime = createDateFormatter({\n * dateStyle: 'full',\n * timeStyle: 'short',\n * });\n *\n * // Time only\n * const timeFormatter = createDateFormatter({\n * hour: 'numeric',\n * minute: '2-digit',\n * });\n * ```\n */\nexport function createDateFormatter(\n options?: Intl.DateTimeFormatOptions,\n): () => Intl.DateTimeFormat {\n const locale = useLocale();\n\n return createMemo(() => getCachedDateFormatter(locale().locale, options));\n}\n","/**\n * createFilter hook for solidaria\n *\n * Provides localized string filtering with collation support.\n *\n * Port of @react-aria/i18n useFilter.\n */\n\nimport { createMemo } from \"solid-js\";\nimport { createCollator } from \"./createCollator\";\n\nexport interface Filter {\n /** Returns whether a string starts with a given substring. */\n startsWith(string: string, substring: string): boolean;\n /** Returns whether a string ends with a given substring. */\n endsWith(string: string, substring: string): boolean;\n /** Returns whether a string contains a given substring. */\n contains(string: string, substring: string): boolean;\n}\n\n/**\n * Provides localized string search functionality for filtering or matching items.\n * Respects locale-specific collation rules for case and diacritic sensitivity.\n *\n * @example\n * ```tsx\n * function SearchableList(props: { items: { name: string }[] }) {\n * const [query, setQuery] = createSignal('');\n * const filter = createFilter({ sensitivity: 'base' });\n *\n * const filteredItems = () =>\n * props.items.filter((item) =>\n * filter().contains(item.name, query())\n * );\n *\n * return (\n * <>\n * <input\n * value={query()}\n * onInput={(e) => setQuery(e.target.value)}\n * placeholder=\"Search...\"\n * />\n * <ul>\n * <For each={filteredItems()}>\n * {(item) => <li>{item.name}</li>}\n * </For>\n * </ul>\n * </>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Case-insensitive, diacritic-insensitive filtering\n * const filter = createFilter({ sensitivity: 'base' });\n * filter().contains('Café', 'cafe'); // true\n * filter().startsWith('Hello', 'hello'); // true\n * ```\n */\nexport function createFilter(options?: Intl.CollatorOptions): () => Filter {\n const collator = createCollator({\n usage: \"search\",\n ...options,\n });\n\n return createMemo(() => {\n const coll = collator();\n\n const startsWith = (str: string, substring: string): boolean => {\n if (substring.length === 0) {\n return true;\n }\n\n // Normalize both strings for safe slicing\n const normalizedStr = str.normalize(\"NFC\");\n const normalizedSub = substring.normalize(\"NFC\");\n\n return coll.compare(normalizedStr.slice(0, normalizedSub.length), normalizedSub) === 0;\n };\n\n const endsWith = (str: string, substring: string): boolean => {\n if (substring.length === 0) {\n return true;\n }\n\n const normalizedStr = str.normalize(\"NFC\");\n const normalizedSub = substring.normalize(\"NFC\");\n\n return coll.compare(normalizedStr.slice(-normalizedSub.length), normalizedSub) === 0;\n };\n\n const contains = (str: string, substring: string): boolean => {\n if (substring.length === 0) {\n return true;\n }\n\n const normalizedStr = str.normalize(\"NFC\");\n const normalizedSub = substring.normalize(\"NFC\");\n const sliceLen = normalizedSub.length;\n\n for (let scan = 0; scan + sliceLen <= normalizedStr.length; scan++) {\n const slice = normalizedStr.slice(scan, scan + sliceLen);\n if (coll.compare(normalizedSub, slice) === 0) {\n return true;\n }\n }\n\n return false;\n };\n\n return {\n startsWith,\n endsWith,\n contains,\n };\n });\n}\n","/**\n * String formatter for localized strings with ICU MessageFormat support.\n * Port of @react-aria/i18n useLocalizedStringFormatter.\n */\n\nimport {\n LocalizedString,\n LocalizedStringDictionary,\n LocalizedStringFormatter,\n type LocalizedStrings,\n} from \"@internationalized/string\";\nimport { createMemo, type Accessor } from \"solid-js\";\nimport { useLocale } from \"./locale\";\n\n// Cache for dictionaries to avoid recreating them\nconst cache = new WeakMap<\n LocalizedStrings<string, LocalizedString>,\n LocalizedStringDictionary<string, LocalizedString>\n>();\n\nfunction getCachedDictionary<K extends string, T extends LocalizedString>(\n strings: LocalizedStrings<K, T>,\n): LocalizedStringDictionary<K, T> {\n let dictionary = cache.get(strings as LocalizedStrings<string, LocalizedString>);\n if (!dictionary) {\n dictionary = new LocalizedStringDictionary(\n strings as LocalizedStrings<string, LocalizedString>,\n );\n cache.set(strings as LocalizedStrings<string, LocalizedString>, dictionary);\n }\n return dictionary as LocalizedStringDictionary<K, T>;\n}\n\n/**\n * Returns a cached LocalizedStringDictionary for the given strings.\n */\nexport function createStringDictionary<\n K extends string = string,\n T extends LocalizedString = string,\n>(strings: LocalizedStrings<K, T>, packageName?: string): LocalizedStringDictionary<K, T> {\n return (\n (packageName && LocalizedStringDictionary.getGlobalDictionaryForPackage(packageName)) ||\n getCachedDictionary(strings)\n );\n}\n\n/**\n * Provides localized string formatting for the current locale.\n * Supports interpolating variables, selecting the correct pluralization,\n * and formatting numbers. Automatically updates when the locale changes.\n *\n * @param strings - A mapping of languages to localized strings by key.\n * @param packageName - Optional package name for global dictionary lookup.\n *\n * @example\n * ```tsx\n * const strings = {\n * 'en-US': {\n * greeting: 'Hello, {name}!',\n * count: '{count, plural, one {# item} other {# items}}'\n * }\n * };\n *\n * function MyComponent() {\n * const stringFormatter = createStringFormatter(strings);\n *\n * return (\n * <div>\n * {stringFormatter().format('greeting', { name: 'World' })}\n * {stringFormatter().format('count', { count: 5 })}\n * </div>\n * );\n * }\n * ```\n */\nexport function createStringFormatter<\n K extends string = string,\n T extends LocalizedString = string,\n>(strings: LocalizedStrings<K, T>, packageName?: string): Accessor<LocalizedStringFormatter<K, T>> {\n const localeAccessor = useLocale();\n const dictionary = createStringDictionary(strings, packageName);\n\n return createMemo(() => new LocalizedStringFormatter(localeAccessor().locale, dictionary));\n}\n\nexport type {\n LocalizedString,\n LocalizedStringDictionary,\n LocalizedStringFormatter,\n LocalizedStrings,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,SAAgB,sBAAsB,UAA+B,CAAC,GAA0B;CAC9F,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5D,IAAI,UAAU,WAAW,GACvB,OAAO;GAGT,MAAM,gBAAgB,IAAI,UAAU,KAAK;GACzC,MAAM,gBAAgB,UAAU,UAAU,KAAK;GAC/C,MAAM,WAAW,cAAc;GAE/B,KAAK,IAAI,OAAO,GAAG,OAAO,YAAY,cAAc,QAAQ,QAAQ;IAClE,MAAM,QAAQ,cAAc,MAAM,MAAM,OAAO,QAAQ;IACvD,IAAI,KAAK,QAAQ,eAAe,KAAK,MAAM,GACzC,OAAO;GAEX;GAEA,OAAO;EACT;EAEA,OAAO;GACL;GACA;GACA;EACF;CACF,CAAC;AACH;;;;;;;ACtGA,MAAM,wBAAQ,IAAI,QAGhB;AAEF,SAAS,oBACP,SACiC;CACjC,IAAI,aAAa,MAAM,IAAI,OAAoD;CAC/E,IAAI,CAAC,YAAY;EACf,aAAa,IAAI,0BACf,OACF;EACA,MAAM,IAAI,SAAsD,UAAU;CAC5E;CACA,OAAO;AACT;;;;AAKA,SAAgB,uBAGd,SAAiC,aAAuD;CACxF,OACG,eAAe,0BAA0B,8BAA8B,WAAW,KACnF,oBAAoB,OAAO;AAE/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,SAAgB,sBAGd,SAAiC,aAAgE;CACjG,MAAM,iBAAiB,UAAU;CACjC,MAAM,aAAa,uBAAuB,SAAS,WAAW;CAE9D,OAAO,iBAAiB,IAAI,yBAAyB,eAAe,CAAC,CAAC,QAAQ,UAAU,CAAC;AAC3F"}
|
|
1
|
+
{"version":3,"file":"i18n.jsx","names":[],"sources":["../../src/i18n/createNumberFormatter.ts","../../src/i18n/createDateFormatter.ts","../../src/i18n/createFilter.ts"],"sourcesContent":["/**\n * createNumberFormatter hook for solidaria\n *\n * Provides localized number formatting with automatic locale updates.\n *\n * Port of @react-aria/i18n useNumberFormatter.\n */\n\nimport { createMemo } from \"solid-js\";\nimport { useLocale } from \"./locale\";\nimport { NumberFormatter, type NumberFormatOptions } from \"@internationalized/number\";\n\n/**\n * Provides localized number formatting for the current locale.\n * Automatically updates when the locale changes.\n *\n * @example\n * ```tsx\n * function PriceDisplay(props: { value: number }) {\n * const formatter = createNumberFormatter({\n * style: 'currency',\n * currency: 'USD',\n * });\n *\n * return <span>{formatter().format(props.value)}</span>;\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Percent formatting\n * const percentFormatter = createNumberFormatter({\n * style: 'percent',\n * minimumFractionDigits: 1,\n * });\n * percentFormatter().format(0.125); // '12.5%'\n *\n * // Unit formatting\n * const tempFormatter = createNumberFormatter({\n * style: 'unit',\n * unit: 'celsius',\n * });\n * tempFormatter().format(25); // '25°C'\n * ```\n */\nexport function createNumberFormatter(options: NumberFormatOptions = {}): () => NumberFormatter {\n const locale = useLocale();\n\n return createMemo(() => new NumberFormatter(locale().locale, options));\n}\n","/**\n * createDateFormatter hook for solidaria\n *\n * Provides localized date formatting with caching.\n *\n * Port of @react-aria/i18n useDateFormatter.\n */\n\nimport { createMemo } from \"solid-js\";\nimport { useLocale } from \"./locale\";\nimport { createCacheKey } from \"./utils\";\n\nconst dateFormatterCache = new Map<string, Intl.DateTimeFormat>();\n\n/**\n * Gets or creates a cached date formatter.\n */\nfunction getCachedDateFormatter(\n locale: string,\n options?: Intl.DateTimeFormatOptions,\n): Intl.DateTimeFormat {\n const cacheKey = createCacheKey(locale, options as Record<string, unknown>);\n\n if (dateFormatterCache.has(cacheKey)) {\n return dateFormatterCache.get(cacheKey)!;\n }\n\n const formatter = new Intl.DateTimeFormat(locale, options);\n dateFormatterCache.set(cacheKey, formatter);\n return formatter;\n}\n\n/**\n * Provides localized date and time formatting for the current locale.\n * Automatically updates when the locale changes.\n *\n * @example\n * ```tsx\n * function DateDisplay(props: { date: Date }) {\n * const formatter = createDateFormatter({\n * year: 'numeric',\n * month: 'long',\n * day: 'numeric',\n * });\n *\n * return <span>{formatter().format(props.date)}</span>;\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Short date\n * const shortDate = createDateFormatter({ dateStyle: 'short' });\n * shortDate().format(new Date()); // '1/19/26' (US) or '19/01/26' (UK)\n *\n * // Full date with time\n * const fullDateTime = createDateFormatter({\n * dateStyle: 'full',\n * timeStyle: 'short',\n * });\n *\n * // Time only\n * const timeFormatter = createDateFormatter({\n * hour: 'numeric',\n * minute: '2-digit',\n * });\n * ```\n */\nexport function createDateFormatter(\n options?: Intl.DateTimeFormatOptions,\n): () => Intl.DateTimeFormat {\n const locale = useLocale();\n\n return createMemo(() => getCachedDateFormatter(locale().locale, options));\n}\n","/**\n * createFilter hook for solidaria\n *\n * Provides localized string filtering with collation support.\n *\n * Port of @react-aria/i18n useFilter.\n */\n\nimport { createMemo } from \"solid-js\";\nimport { createCollator } from \"./createCollator\";\n\nexport interface Filter {\n /** Returns whether a string starts with a given substring. */\n startsWith(string: string, substring: string): boolean;\n /** Returns whether a string ends with a given substring. */\n endsWith(string: string, substring: string): boolean;\n /** Returns whether a string contains a given substring. */\n contains(string: string, substring: string): boolean;\n}\n\n/**\n * Provides localized string search functionality for filtering or matching items.\n * Respects locale-specific collation rules for case and diacritic sensitivity.\n *\n * @example\n * ```tsx\n * function SearchableList(props: { items: { name: string }[] }) {\n * const [query, setQuery] = createSignal('');\n * const filter = createFilter({ sensitivity: 'base' });\n *\n * const filteredItems = () =>\n * props.items.filter((item) =>\n * filter().contains(item.name, query())\n * );\n *\n * return (\n * <>\n * <input\n * value={query()}\n * onInput={(e) => setQuery(e.target.value)}\n * placeholder=\"Search...\"\n * />\n * <ul>\n * <For each={filteredItems()}>\n * {(item) => <li>{item.name}</li>}\n * </For>\n * </ul>\n * </>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Case-insensitive, diacritic-insensitive filtering\n * const filter = createFilter({ sensitivity: 'base' });\n * filter().contains('Café', 'cafe'); // true\n * filter().startsWith('Hello', 'hello'); // true\n * ```\n */\nexport function createFilter(options?: Intl.CollatorOptions): () => Filter {\n const collator = createCollator({\n usage: \"search\",\n ...options,\n });\n\n return createMemo(() => {\n const coll = collator();\n\n const startsWith = (str: string, substring: string): boolean => {\n if (substring.length === 0) {\n return true;\n }\n\n // Normalize both strings for safe slicing\n const normalizedStr = str.normalize(\"NFC\");\n const normalizedSub = substring.normalize(\"NFC\");\n\n return coll.compare(normalizedStr.slice(0, normalizedSub.length), normalizedSub) === 0;\n };\n\n const endsWith = (str: string, substring: string): boolean => {\n if (substring.length === 0) {\n return true;\n }\n\n const normalizedStr = str.normalize(\"NFC\");\n const normalizedSub = substring.normalize(\"NFC\");\n\n return coll.compare(normalizedStr.slice(-normalizedSub.length), normalizedSub) === 0;\n };\n\n const contains = (str: string, substring: string): boolean => {\n if (substring.length === 0) {\n return true;\n }\n\n const normalizedStr = str.normalize(\"NFC\");\n const normalizedSub = substring.normalize(\"NFC\");\n const sliceLen = normalizedSub.length;\n\n for (let scan = 0; scan + sliceLen <= normalizedStr.length; scan++) {\n const slice = normalizedStr.slice(scan, scan + sliceLen);\n if (coll.compare(normalizedSub, slice) === 0) {\n return true;\n }\n }\n\n return false;\n };\n\n return {\n startsWith,\n endsWith,\n contains,\n };\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,SAAgB,sBAAsB,UAA+B,CAAC,GAA0B;CAC9F,MAAM,SAAS,UAAU;CAEzB,OAAO,iBAAiB,IAAI,gBAAgB,OAAO,CAAC,CAAC,QAAQ,OAAO,CAAC;AACvE;;;;;;;;;;ACrCA,MAAM,qCAAqB,IAAI,IAAiC;;;;AAKhE,SAAS,uBACP,QACA,SACqB;CACrB,MAAM,WAAW,eAAe,QAAQ,OAAkC;CAE1E,IAAI,mBAAmB,IAAI,QAAQ,GACjC,OAAO,mBAAmB,IAAI,QAAQ;CAGxC,MAAM,YAAY,IAAI,KAAK,eAAe,QAAQ,OAAO;CACzD,mBAAmB,IAAI,UAAU,SAAS;CAC1C,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,SAAgB,oBACd,SAC2B;CA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