@proyecto-viviana/solidaria 0.3.0 → 0.4.0
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/actiongroup.js +207 -0
- package/dist/_chunk/actiongroup.js.map +1 -0
- package/dist/_chunk/actiongroup.jsx +207 -0
- package/dist/_chunk/actiongroup.jsx.map +1 -0
- package/dist/_chunk/ariaHideOutside.js +122 -0
- package/dist/_chunk/ariaHideOutside.js.map +1 -0
- package/dist/_chunk/ariaHideOutside.jsx +122 -0
- package/dist/_chunk/ariaHideOutside.jsx.map +1 -0
- package/dist/_chunk/autocomplete.js +196 -0
- package/dist/_chunk/autocomplete.js.map +1 -0
- package/dist/_chunk/autocomplete.jsx +196 -0
- package/dist/_chunk/autocomplete.jsx.map +1 -0
- package/dist/_chunk/breadcrumbs.js +119 -0
- package/dist/_chunk/breadcrumbs.js.map +1 -0
- package/dist/_chunk/breadcrumbs.jsx +119 -0
- package/dist/_chunk/breadcrumbs.jsx.map +1 -0
- package/dist/_chunk/button.js +276 -0
- package/dist/_chunk/button.js.map +1 -0
- package/dist/_chunk/button.jsx +276 -0
- package/dist/_chunk/button.jsx.map +1 -0
- package/dist/_chunk/calendar.js +1036 -0
- package/dist/_chunk/calendar.js.map +1 -0
- package/dist/_chunk/calendar.jsx +1036 -0
- package/dist/_chunk/calendar.jsx.map +1 -0
- package/dist/_chunk/checkbox.js +234 -0
- package/dist/_chunk/checkbox.js.map +1 -0
- package/dist/_chunk/checkbox.jsx +234 -0
- package/dist/_chunk/checkbox.jsx.map +1 -0
- package/dist/_chunk/color.js +1174 -0
- package/dist/_chunk/color.js.map +1 -0
- package/dist/_chunk/color.jsx +1174 -0
- package/dist/_chunk/color.jsx.map +1 -0
- package/dist/_chunk/combobox.js +436 -0
- package/dist/_chunk/combobox.js.map +1 -0
- package/dist/_chunk/combobox.jsx +436 -0
- package/dist/_chunk/combobox.jsx.map +1 -0
- package/dist/_chunk/createCollator.js +229 -0
- package/dist/_chunk/createCollator.js.map +1 -0
- package/dist/_chunk/createCollator.jsx +223 -0
- package/dist/_chunk/createCollator.jsx.map +1 -0
- package/dist/_chunk/createCollectionRowInteraction.js +133 -0
- package/dist/_chunk/createCollectionRowInteraction.js.map +1 -0
- package/dist/_chunk/createCollectionRowInteraction.jsx +133 -0
- package/dist/_chunk/createCollectionRowInteraction.jsx.map +1 -0
- package/dist/_chunk/createField.js +54 -0
- package/dist/_chunk/createField.js.map +1 -0
- package/dist/_chunk/createField.jsx +54 -0
- package/dist/_chunk/createField.jsx.map +1 -0
- package/dist/_chunk/createFocus.js +101 -0
- package/dist/_chunk/createFocus.js.map +1 -0
- package/dist/_chunk/createFocus.jsx +101 -0
- package/dist/_chunk/createFocus.jsx.map +1 -0
- package/dist/_chunk/createFocusRing.js +54 -0
- package/dist/_chunk/createFocusRing.js.map +1 -0
- package/dist/_chunk/createFocusRing.jsx +54 -0
- package/dist/_chunk/createFocusRing.jsx.map +1 -0
- package/dist/_chunk/createFocusWithin.js +121 -0
- package/dist/_chunk/createFocusWithin.js.map +1 -0
- package/dist/_chunk/createFocusWithin.jsx +121 -0
- package/dist/_chunk/createFocusWithin.jsx.map +1 -0
- package/dist/_chunk/createFocusable.js +131 -0
- package/dist/_chunk/createFocusable.js.map +1 -0
- package/dist/_chunk/createFocusable.jsx +131 -0
- package/dist/_chunk/createFocusable.jsx.map +1 -0
- package/dist/_chunk/createFormValidation.js +135 -0
- package/dist/_chunk/createFormValidation.js.map +1 -0
- package/dist/_chunk/createFormValidation.jsx +135 -0
- package/dist/_chunk/createFormValidation.jsx.map +1 -0
- package/dist/_chunk/createHover.js +130 -0
- package/dist/_chunk/createHover.js.map +1 -0
- package/dist/_chunk/createHover.jsx +130 -0
- package/dist/_chunk/createHover.jsx.map +1 -0
- package/dist/_chunk/createInteractionModality.js +269 -0
- package/dist/_chunk/createInteractionModality.js.map +1 -0
- package/dist/_chunk/createInteractionModality.jsx +269 -0
- package/dist/_chunk/createInteractionModality.jsx.map +1 -0
- package/dist/_chunk/createLabel.js +46 -0
- package/dist/_chunk/createLabel.js.map +1 -0
- package/dist/_chunk/createLabel.jsx +46 -0
- package/dist/_chunk/createLabel.jsx.map +1 -0
- package/dist/_chunk/createLabels.js +31 -0
- package/dist/_chunk/createLabels.js.map +1 -0
- package/dist/_chunk/createLabels.jsx +31 -0
- package/dist/_chunk/createLabels.jsx.map +1 -0
- package/dist/_chunk/createLandmark.js +198 -0
- package/dist/_chunk/createLandmark.js.map +1 -0
- package/dist/_chunk/createLandmark.jsx +198 -0
- package/dist/_chunk/createLandmark.jsx.map +1 -0
- package/dist/_chunk/createLongPress.js +91 -0
- package/dist/_chunk/createLongPress.js.map +1 -0
- package/dist/_chunk/createLongPress.jsx +91 -0
- package/dist/_chunk/createLongPress.jsx.map +1 -0
- package/dist/_chunk/createOverlay.js +327 -0
- package/dist/_chunk/createOverlay.js.map +1 -0
- package/dist/_chunk/createOverlay.jsx +327 -0
- package/dist/_chunk/createOverlay.jsx.map +1 -0
- package/dist/_chunk/createPress.js +526 -0
- package/dist/_chunk/createPress.js.map +1 -0
- package/dist/_chunk/createPress.jsx +526 -0
- package/dist/_chunk/createPress.jsx.map +1 -0
- package/dist/_chunk/createProgressBar.js +81 -0
- package/dist/_chunk/createProgressBar.js.map +1 -0
- package/dist/_chunk/createProgressBar.jsx +81 -0
- package/dist/_chunk/createProgressBar.jsx.map +1 -0
- package/dist/_chunk/createSelectableItem.js +298 -0
- package/dist/_chunk/createSelectableItem.js.map +1 -0
- package/dist/_chunk/createSelectableItem.jsx +298 -0
- package/dist/_chunk/createSelectableItem.jsx.map +1 -0
- package/dist/_chunk/createToggle.js +158 -0
- package/dist/_chunk/createToggle.js.map +1 -0
- package/dist/_chunk/createToggle.jsx +158 -0
- package/dist/_chunk/createToggle.jsx.map +1 -0
- package/dist/_chunk/createTypeSelect.js +125 -0
- package/dist/_chunk/createTypeSelect.js.map +1 -0
- package/dist/_chunk/createTypeSelect.jsx +125 -0
- package/dist/_chunk/createTypeSelect.jsx.map +1 -0
- package/dist/_chunk/datepicker.js +1393 -0
- package/dist/_chunk/datepicker.js.map +1 -0
- package/dist/_chunk/datepicker.jsx +1393 -0
- package/dist/_chunk/datepicker.jsx.map +1 -0
- package/dist/_chunk/dialog.js +62 -0
- package/dist/_chunk/dialog.js.map +1 -0
- package/dist/_chunk/dialog.jsx +62 -0
- package/dist/_chunk/dialog.jsx.map +1 -0
- package/dist/_chunk/disclosure.js +185 -0
- package/dist/_chunk/disclosure.js.map +1 -0
- package/dist/_chunk/disclosure.jsx +185 -0
- package/dist/_chunk/disclosure.jsx.map +1 -0
- package/dist/_chunk/dnd.js +1304 -0
- package/dist/_chunk/dnd.js.map +1 -0
- package/dist/_chunk/dnd.jsx +1304 -0
- package/dist/_chunk/dnd.jsx.map +1 -0
- package/dist/_chunk/env.js +105 -0
- package/dist/_chunk/env.js.map +1 -0
- package/dist/_chunk/env.jsx +105 -0
- package/dist/_chunk/env.jsx.map +1 -0
- package/dist/_chunk/filterDOMProps.js +82 -0
- package/dist/_chunk/filterDOMProps.js.map +1 -0
- package/dist/_chunk/filterDOMProps.jsx +82 -0
- package/dist/_chunk/filterDOMProps.jsx.map +1 -0
- package/dist/_chunk/focus.js +399 -0
- package/dist/_chunk/focus.js.map +1 -0
- package/dist/_chunk/focus.jsx +399 -0
- package/dist/_chunk/focus.jsx.map +1 -0
- package/dist/_chunk/focus2.js +895 -0
- package/dist/_chunk/focus2.js.map +1 -0
- package/dist/_chunk/focus2.jsx +870 -0
- package/dist/_chunk/focus2.jsx.map +1 -0
- package/dist/_chunk/form.js +39 -0
- package/dist/_chunk/form.js.map +1 -0
- package/dist/_chunk/form.jsx +39 -0
- package/dist/_chunk/form.jsx.map +1 -0
- package/dist/_chunk/grid.js +623 -0
- package/dist/_chunk/grid.js.map +1 -0
- package/dist/_chunk/grid.jsx +623 -0
- package/dist/_chunk/grid.jsx.map +1 -0
- package/dist/_chunk/gridlist.js +364 -0
- package/dist/_chunk/gridlist.js.map +1 -0
- package/dist/_chunk/gridlist.jsx +364 -0
- package/dist/_chunk/gridlist.jsx.map +1 -0
- package/dist/_chunk/i18n.js +254 -0
- package/dist/_chunk/i18n.js.map +1 -0
- package/dist/_chunk/i18n.jsx +254 -0
- package/dist/_chunk/i18n.jsx.map +1 -0
- package/dist/_chunk/interactions.js +241 -0
- package/dist/_chunk/interactions.js.map +1 -0
- package/dist/_chunk/interactions.jsx +237 -0
- package/dist/_chunk/interactions.jsx.map +1 -0
- package/dist/_chunk/link.js +96 -0
- package/dist/_chunk/link.js.map +1 -0
- package/dist/_chunk/link.jsx +96 -0
- package/dist/_chunk/link.jsx.map +1 -0
- package/dist/_chunk/listbox.js +324 -0
- package/dist/_chunk/listbox.js.map +1 -0
- package/dist/_chunk/listbox.jsx +324 -0
- package/dist/_chunk/listbox.jsx.map +1 -0
- package/dist/_chunk/live-announcer.js +207 -0
- package/dist/_chunk/live-announcer.js.map +1 -0
- package/dist/_chunk/live-announcer.jsx +207 -0
- package/dist/_chunk/live-announcer.jsx.map +1 -0
- package/dist/_chunk/menu.js +518 -0
- package/dist/_chunk/menu.js.map +1 -0
- package/dist/_chunk/menu.jsx +518 -0
- package/dist/_chunk/menu.jsx.map +1 -0
- package/dist/_chunk/meter.js +33 -0
- package/dist/_chunk/meter.js.map +1 -0
- package/dist/_chunk/meter.jsx +33 -0
- package/dist/_chunk/meter.jsx.map +1 -0
- package/dist/_chunk/numberfield.js +258 -0
- package/dist/_chunk/numberfield.js.map +1 -0
- package/dist/_chunk/numberfield.jsx +258 -0
- package/dist/_chunk/numberfield.jsx.map +1 -0
- package/dist/_chunk/overlays.js +186 -0
- package/dist/_chunk/overlays.js.map +1 -0
- package/dist/_chunk/overlays.jsx +162 -0
- package/dist/_chunk/overlays.jsx.map +1 -0
- package/dist/_chunk/popover.js +574 -0
- package/dist/_chunk/popover.js.map +1 -0
- package/dist/_chunk/popover.jsx +574 -0
- package/dist/_chunk/popover.jsx.map +1 -0
- package/dist/_chunk/radio.js +319 -0
- package/dist/_chunk/radio.js.map +1 -0
- package/dist/_chunk/radio.jsx +319 -0
- package/dist/_chunk/radio.jsx.map +1 -0
- package/dist/_chunk/searchfield.js +209 -0
- package/dist/_chunk/searchfield.js.map +1 -0
- package/dist/_chunk/searchfield.jsx +209 -0
- package/dist/_chunk/searchfield.jsx.map +1 -0
- package/dist/_chunk/select.js +403 -0
- package/dist/_chunk/select.js.map +1 -0
- package/dist/_chunk/select.jsx +394 -0
- package/dist/_chunk/select.jsx.map +1 -0
- package/dist/_chunk/selection.js +679 -0
- package/dist/_chunk/selection.js.map +1 -0
- package/dist/_chunk/selection.jsx +679 -0
- package/dist/_chunk/selection.jsx.map +1 -0
- package/dist/_chunk/separator.js +29 -0
- package/dist/_chunk/separator.js.map +1 -0
- package/dist/_chunk/separator.jsx +29 -0
- package/dist/_chunk/separator.jsx.map +1 -0
- package/dist/_chunk/slider.js +255 -0
- package/dist/_chunk/slider.js.map +1 -0
- package/dist/_chunk/slider.jsx +255 -0
- package/dist/_chunk/slider.jsx.map +1 -0
- package/dist/_chunk/steplist.js +66 -0
- package/dist/_chunk/steplist.js.map +1 -0
- package/dist/_chunk/steplist.jsx +66 -0
- package/dist/_chunk/steplist.jsx.map +1 -0
- package/dist/_chunk/switch.js +34 -0
- package/dist/_chunk/switch.js.map +1 -0
- package/dist/_chunk/switch.jsx +34 -0
- package/dist/_chunk/switch.jsx.map +1 -0
- package/dist/_chunk/table.js +1051 -0
- package/dist/_chunk/table.js.map +1 -0
- package/dist/_chunk/table.jsx +1051 -0
- package/dist/_chunk/table.jsx.map +1 -0
- package/dist/_chunk/tabs.js +260 -0
- package/dist/_chunk/tabs.js.map +1 -0
- package/dist/_chunk/tabs.jsx +260 -0
- package/dist/_chunk/tabs.jsx.map +1 -0
- package/dist/_chunk/tag.js +286 -0
- package/dist/_chunk/tag.js.map +1 -0
- package/dist/_chunk/tag.jsx +286 -0
- package/dist/_chunk/tag.jsx.map +1 -0
- package/dist/_chunk/textfield.js +109 -0
- package/dist/_chunk/textfield.js.map +1 -0
- package/dist/_chunk/textfield.jsx +109 -0
- package/dist/_chunk/textfield.jsx.map +1 -0
- package/dist/_chunk/toast.js +250 -0
- package/dist/_chunk/toast.js.map +1 -0
- package/dist/_chunk/toast.jsx +250 -0
- package/dist/_chunk/toast.jsx.map +1 -0
- package/dist/_chunk/toolbar.js +258 -0
- package/dist/_chunk/toolbar.js.map +1 -0
- package/dist/_chunk/toolbar.jsx +258 -0
- package/dist/_chunk/toolbar.jsx.map +1 -0
- package/dist/_chunk/tooltip.js +185 -0
- package/dist/_chunk/tooltip.js.map +1 -0
- package/dist/_chunk/tooltip.jsx +185 -0
- package/dist/_chunk/tooltip.jsx.map +1 -0
- package/dist/_chunk/tree.js +424 -0
- package/dist/_chunk/tree.js.map +1 -0
- package/dist/_chunk/tree.jsx +424 -0
- package/dist/_chunk/tree.jsx.map +1 -0
- package/dist/_chunk/utils.js +665 -0
- package/dist/_chunk/utils.js.map +1 -0
- package/dist/_chunk/utils.jsx +665 -0
- package/dist/_chunk/utils.jsx.map +1 -0
- package/dist/_chunk/visually-hidden.js +92 -0
- package/dist/_chunk/visually-hidden.js.map +1 -0
- package/dist/_chunk/visually-hidden.jsx +92 -0
- package/dist/_chunk/visually-hidden.jsx.map +1 -0
- package/dist/actiongroup/index.js +2 -0
- package/dist/actiongroup/index.jsx +2 -0
- package/dist/autocomplete/createAutocomplete.d.ts +2 -0
- package/dist/autocomplete/createAutocomplete.d.ts.map +1 -1
- package/dist/autocomplete/index.js +2 -0
- package/dist/autocomplete/index.jsx +2 -0
- package/dist/breadcrumbs/index.js +2 -0
- package/dist/breadcrumbs/index.jsx +2 -0
- package/dist/button/index.js +2 -0
- package/dist/button/index.jsx +2 -0
- 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/createCalendarMonthPicker.d.ts +41 -0
- package/dist/calendar/createCalendarMonthPicker.d.ts.map +1 -0
- package/dist/calendar/createCalendarYearPicker.d.ts +49 -0
- package/dist/calendar/createCalendarYearPicker.d.ts.map +1 -0
- package/dist/calendar/createRangeCalendar.d.ts.map +1 -1
- package/dist/calendar/index.d.ts +2 -0
- package/dist/calendar/index.d.ts.map +1 -1
- package/dist/calendar/index.js +2 -0
- package/dist/calendar/index.jsx +2 -0
- package/dist/calendar/utils.d.ts +4 -0
- package/dist/calendar/utils.d.ts.map +1 -1
- package/dist/checkbox/createCheckbox.d.ts +4 -0
- package/dist/checkbox/createCheckbox.d.ts.map +1 -1
- package/dist/checkbox/createCheckboxGroupItem.d.ts.map +1 -1
- package/dist/checkbox/index.js +2 -0
- package/dist/checkbox/index.jsx +2 -0
- package/dist/collections/index.js +160 -0
- package/dist/collections/index.js.map +1 -0
- package/dist/collections/index.jsx +160 -0
- package/dist/collections/index.jsx.map +1 -0
- package/dist/color/index.js +2 -0
- package/dist/color/index.jsx +2 -0
- package/dist/combobox/index.js +2 -0
- package/dist/combobox/index.jsx +2 -0
- package/dist/datepicker/createDateSegment.d.ts.map +1 -1
- package/dist/datepicker/index.js +2 -0
- package/dist/datepicker/index.jsx +2 -0
- package/dist/dialog/index.js +2 -0
- package/dist/dialog/index.jsx +2 -0
- package/dist/disclosure/index.js +2 -0
- package/dist/disclosure/index.jsx +2 -0
- package/dist/dnd/createDroppableCollection.d.ts.map +1 -1
- package/dist/dnd/index.js +2 -0
- package/dist/dnd/index.jsx +2 -0
- package/dist/dnd/utils.d.ts +2 -2
- package/dist/dnd/utils.d.ts.map +1 -1
- package/dist/focus/FocusScope.d.ts.map +1 -1
- package/dist/focus/index.js +2 -0
- package/dist/focus/index.jsx +2 -0
- package/dist/form/createFormValidation.d.ts.map +1 -1
- package/dist/form/index.js +3 -0
- package/dist/form/index.jsx +3 -0
- package/dist/grid/index.js +2 -0
- package/dist/grid/index.jsx +2 -0
- package/dist/gridlist/createGridList.d.ts +7 -1
- package/dist/gridlist/createGridList.d.ts.map +1 -1
- package/dist/gridlist/createGridListItem.d.ts +1 -1
- package/dist/gridlist/createGridListItem.d.ts.map +1 -1
- package/dist/gridlist/createGridListSection.d.ts +15 -0
- package/dist/gridlist/createGridListSection.d.ts.map +1 -0
- package/dist/gridlist/index.d.ts +2 -1
- package/dist/gridlist/index.d.ts.map +1 -1
- package/dist/gridlist/index.js +2 -0
- package/dist/gridlist/index.jsx +2 -0
- package/dist/gridlist/types.d.ts +50 -0
- package/dist/gridlist/types.d.ts.map +1 -1
- package/dist/i18n/index.js +3 -0
- package/dist/i18n/index.jsx +3 -0
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +71 -18311
- package/dist/index.jsx +71 -18242
- package/dist/interactions/PressEvent.d.ts +11 -0
- package/dist/interactions/PressEvent.d.ts.map +1 -1
- package/dist/interactions/createInteractionModality.d.ts +0 -1
- package/dist/interactions/createInteractionModality.d.ts.map +1 -1
- package/dist/interactions/createKeyboard.d.ts.map +1 -1
- package/dist/interactions/createPress.d.ts.map +1 -1
- package/dist/interactions/index.js +10 -0
- package/dist/interactions/index.jsx +10 -0
- package/dist/label/index.js +4 -0
- package/dist/label/index.jsx +4 -0
- package/dist/landmark/index.js +2 -0
- package/dist/landmark/index.jsx +2 -0
- package/dist/link/index.js +2 -0
- package/dist/link/index.jsx +2 -0
- package/dist/listbox/createListBox.d.ts +37 -0
- package/dist/listbox/createListBox.d.ts.map +1 -1
- package/dist/listbox/createOption.d.ts +6 -0
- package/dist/listbox/createOption.d.ts.map +1 -1
- package/dist/listbox/index.js +2 -0
- package/dist/listbox/index.jsx +2 -0
- package/dist/live-announcer/index.js +2 -0
- package/dist/live-announcer/index.jsx +2 -0
- package/dist/menu/createMenu.d.ts +7 -4
- package/dist/menu/createMenu.d.ts.map +1 -1
- package/dist/menu/createMenuItem.d.ts +9 -1
- package/dist/menu/createMenuItem.d.ts.map +1 -1
- package/dist/menu/index.js +2 -0
- package/dist/menu/index.jsx +2 -0
- package/dist/meter/index.js +2 -0
- package/dist/meter/index.jsx +2 -0
- package/dist/numberfield/createNumberField.d.ts.map +1 -1
- package/dist/numberfield/index.js +2 -0
- package/dist/numberfield/index.jsx +2 -0
- package/dist/overlays/index.js +4 -0
- package/dist/overlays/index.jsx +4 -0
- package/dist/popover/calculatePosition.d.ts +2 -0
- package/dist/popover/calculatePosition.d.ts.map +1 -1
- package/dist/popover/createOverlayPosition.d.ts +8 -0
- package/dist/popover/createOverlayPosition.d.ts.map +1 -1
- package/dist/popover/index.js +2 -0
- package/dist/popover/index.jsx +2 -0
- package/dist/progress/index.js +2 -0
- package/dist/progress/index.jsx +2 -0
- package/dist/radio/createRadio.d.ts +2 -0
- package/dist/radio/createRadio.d.ts.map +1 -1
- package/dist/radio/index.js +2 -0
- package/dist/radio/index.jsx +2 -0
- package/dist/searchfield/index.js +2 -0
- package/dist/searchfield/index.jsx +2 -0
- package/dist/select/createSelect.d.ts.map +1 -1
- package/dist/select/index.js +2 -0
- package/dist/select/index.jsx +2 -0
- package/dist/selection/DOMLayoutDelegate.d.ts +58 -0
- package/dist/selection/DOMLayoutDelegate.d.ts.map +1 -0
- package/dist/selection/ListKeyboardDelegate.d.ts +95 -0
- package/dist/selection/ListKeyboardDelegate.d.ts.map +1 -0
- package/dist/selection/constants.d.ts +15 -0
- package/dist/selection/constants.d.ts.map +1 -0
- package/dist/selection/createCollectionRowInteraction.d.ts +13 -0
- package/dist/selection/createCollectionRowInteraction.d.ts.map +1 -0
- package/dist/selection/createScrollIntoViewOnFocus.d.ts +31 -0
- package/dist/selection/createScrollIntoViewOnFocus.d.ts.map +1 -0
- package/dist/selection/createSelectableCollection.d.ts +69 -0
- package/dist/selection/createSelectableCollection.d.ts.map +1 -0
- package/dist/selection/createSelectableItem.d.ts +154 -0
- package/dist/selection/createSelectableItem.d.ts.map +1 -0
- package/dist/selection/createSelectableList.d.ts +43 -0
- package/dist/selection/createSelectableList.d.ts.map +1 -0
- package/dist/selection/createTypeSelect.d.ts.map +1 -1
- package/dist/selection/index.d.ts +9 -0
- package/dist/selection/index.d.ts.map +1 -1
- package/dist/selection/index.js +4 -0
- package/dist/selection/index.jsx +4 -0
- package/dist/selection/selectItem.d.ts +29 -0
- package/dist/selection/selectItem.d.ts.map +1 -0
- package/dist/selection/utils.d.ts +40 -0
- package/dist/selection/utils.d.ts.map +1 -0
- package/dist/separator/index.js +2 -0
- package/dist/separator/index.jsx +2 -0
- package/dist/slider/createSlider.d.ts.map +1 -1
- package/dist/slider/index.js +2 -0
- package/dist/slider/index.jsx +2 -0
- package/dist/ssr/index.d.ts +17 -0
- package/dist/ssr/index.d.ts.map +1 -1
- package/dist/ssr/index.js +299 -0
- package/dist/ssr/index.js.map +1 -0
- package/dist/ssr/index.jsx +292 -0
- package/dist/ssr/index.jsx.map +1 -0
- package/dist/steplist/index.js +2 -0
- package/dist/steplist/index.jsx +2 -0
- package/dist/switch/createSwitch.d.ts +4 -0
- package/dist/switch/createSwitch.d.ts.map +1 -1
- package/dist/switch/index.js +2 -0
- package/dist/switch/index.jsx +2 -0
- package/dist/table/createTable.d.ts.map +1 -1
- package/dist/table/createTableRow.d.ts +1 -1
- package/dist/table/createTableRow.d.ts.map +1 -1
- package/dist/table/createTableSelectAllCheckbox.d.ts.map +1 -1
- package/dist/table/index.js +2 -0
- package/dist/table/index.jsx +2 -0
- package/dist/table/types.d.ts +27 -1
- package/dist/table/types.d.ts.map +1 -1
- package/dist/tabs/createTabs.d.ts +4 -3
- package/dist/tabs/createTabs.d.ts.map +1 -1
- package/dist/tabs/index.js +2 -0
- package/dist/tabs/index.jsx +2 -0
- package/dist/tag/createTag.d.ts +2 -0
- package/dist/tag/createTag.d.ts.map +1 -1
- package/dist/tag/index.js +2 -0
- package/dist/tag/index.jsx +2 -0
- package/dist/textfield/index.js +2 -0
- package/dist/textfield/index.jsx +2 -0
- package/dist/toast/createToast.d.ts.map +1 -1
- package/dist/toast/index.js +2 -0
- package/dist/toast/index.jsx +2 -0
- package/dist/toggle/createToggle.d.ts +4 -0
- package/dist/toggle/createToggle.d.ts.map +1 -1
- package/dist/toggle/index.js +3 -0
- package/dist/toggle/index.jsx +3 -0
- package/dist/toolbar/createToolbar.d.ts +1 -1
- package/dist/toolbar/createToolbar.d.ts.map +1 -1
- package/dist/toolbar/index.js +2 -0
- package/dist/toolbar/index.jsx +2 -0
- package/dist/tooltip/index.js +2 -0
- package/dist/tooltip/index.jsx +2 -0
- package/dist/tree/createTree.d.ts +5 -1
- package/dist/tree/createTree.d.ts.map +1 -1
- package/dist/tree/createTreeItem.d.ts +1 -1
- package/dist/tree/createTreeItem.d.ts.map +1 -1
- package/dist/tree/index.js +2 -0
- package/dist/tree/index.jsx +2 -0
- package/dist/tree/types.d.ts +10 -0
- package/dist/tree/types.d.ts.map +1 -1
- package/dist/utils/animation.d.ts +60 -0
- package/dist/utils/animation.d.ts.map +1 -0
- package/dist/utils/dom.d.ts +48 -2
- package/dist/utils/dom.d.ts.map +1 -1
- package/dist/utils/index.d.ts +4 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +5 -0
- package/dist/utils/index.jsx +5 -0
- package/dist/utils/keyboard.d.ts +17 -0
- package/dist/utils/keyboard.d.ts.map +1 -0
- package/dist/utils/mergeProps.d.ts.map +1 -1
- package/dist/utils/scrollIntoView.d.ts +30 -0
- package/dist/utils/scrollIntoView.d.ts.map +1 -0
- package/dist/visually-hidden/index.js +2 -0
- package/dist/visually-hidden/index.jsx +2 -0
- package/package.json +304 -3
- package/src/autocomplete/createAutocomplete.ts +67 -21
- package/src/calendar/createCalendar.ts +2 -0
- package/src/calendar/createCalendarCell.ts +19 -2
- package/src/calendar/createCalendarGrid.ts +43 -9
- package/src/calendar/createCalendarMonthPicker.ts +105 -0
- package/src/calendar/createCalendarYearPicker.ts +144 -0
- package/src/calendar/createRangeCalendar.ts +2 -0
- package/src/calendar/index.ts +17 -0
- package/src/calendar/utils.ts +4 -0
- package/src/checkbox/createCheckbox.ts +10 -0
- package/src/checkbox/createCheckboxGroupItem.ts +12 -16
- package/src/datepicker/createDateSegment.ts +6 -1
- package/src/dnd/createDroppableCollection.ts +4 -1
- package/src/dnd/utils.ts +27 -3
- package/src/focus/FocusScope.tsx +152 -18
- package/src/form/createFormValidation.ts +8 -1
- package/src/gridlist/createGridList.ts +145 -42
- package/src/gridlist/createGridListItem.ts +87 -155
- package/src/gridlist/createGridListSection.ts +54 -0
- package/src/gridlist/index.ts +3 -0
- package/src/gridlist/types.ts +47 -0
- package/src/index.ts +40 -0
- package/src/interactions/PressEvent.ts +14 -0
- package/src/interactions/createInteractionModality.ts +21 -12
- package/src/interactions/createKeyboard.ts +10 -0
- package/src/interactions/createPress.ts +29 -6
- package/src/listbox/createListBox.ts +129 -8
- package/src/listbox/createOption.ts +68 -73
- package/src/menu/createMenu.ts +93 -16
- package/src/menu/createMenuItem.ts +253 -41
- package/src/numberfield/createNumberField.ts +82 -14
- package/src/popover/calculatePosition.ts +19 -7
- package/src/popover/createOverlayPosition.ts +9 -0
- package/src/radio/createRadio.ts +19 -2
- package/src/select/createSelect.ts +18 -2
- package/src/selection/DOMLayoutDelegate.ts +102 -0
- package/src/selection/ListKeyboardDelegate.ts +398 -0
- package/src/selection/constants.ts +16 -0
- package/src/selection/createCollectionRowInteraction.ts +209 -0
- package/src/selection/createScrollIntoViewOnFocus.ts +65 -0
- package/src/selection/createSelectableCollection.ts +645 -0
- package/src/selection/createSelectableItem.ts +498 -0
- package/src/selection/createSelectableList.ts +93 -0
- package/src/selection/createTypeSelect.ts +112 -51
- package/src/selection/index.ts +31 -0
- package/src/selection/selectItem.ts +80 -0
- package/src/selection/utils.ts +82 -0
- package/src/slider/createSlider.ts +48 -1
- package/src/ssr/index.tsx +31 -0
- package/src/switch/createSwitch.ts +10 -0
- package/src/table/createTable.ts +56 -26
- package/src/table/createTableRow.ts +198 -203
- package/src/table/createTableSelectAllCheckbox.ts +3 -4
- package/src/table/types.ts +29 -1
- package/src/tabs/createTabs.ts +50 -20
- package/src/tag/createTag.ts +9 -4
- package/src/toast/createToast.ts +1 -0
- package/src/toggle/createToggle.ts +20 -0
- package/src/toolbar/createToolbar.ts +43 -42
- package/src/tree/createTree.ts +100 -42
- package/src/tree/createTreeItem.ts +105 -120
- package/src/tree/types.ts +10 -0
- package/src/utils/animation.ts +151 -0
- package/src/utils/dom.ts +215 -25
- package/src/utils/index.ts +8 -0
- package/src/utils/keyboard.ts +25 -0
- package/src/utils/mergeProps.ts +8 -1
- package/src/utils/scrollIntoView.ts +181 -0
- package/dist/index.js.map +0 -1
- package/dist/index.jsx.map +0 -1
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { o as mergeProps } from "./env.js";
|
|
2
|
+
import { t as filterDOMProps } from "./filterDOMProps.js";
|
|
3
|
+
import { a as getEventTarget, p as isFocusable, t as focusSafely, y as nodeContains } from "./focus.js";
|
|
4
|
+
import { i as createButton } from "./button.js";
|
|
5
|
+
import { a as useLocale } from "./createCollator.js";
|
|
6
|
+
import { onCleanup } from "solid-js";
|
|
7
|
+
//#region src/actiongroup/createActionGroup.ts
|
|
8
|
+
const actionGroupData = /* @__PURE__ */ new WeakMap();
|
|
9
|
+
const GROUP_ROLE_BY_MODE = {
|
|
10
|
+
none: "toolbar",
|
|
11
|
+
single: "radiogroup",
|
|
12
|
+
multiple: "toolbar"
|
|
13
|
+
};
|
|
14
|
+
const ITEM_ROLE_BY_MODE = {
|
|
15
|
+
none: void 0,
|
|
16
|
+
single: "radio",
|
|
17
|
+
multiple: "checkbox"
|
|
18
|
+
};
|
|
19
|
+
function isActionGroupDisabled(props, state) {
|
|
20
|
+
if (props.isDisabled) return true;
|
|
21
|
+
const keys = [...state.collection().getKeys()];
|
|
22
|
+
if (keys.length === 0) return true;
|
|
23
|
+
return !keys.some((key) => !state.isDisabled(key));
|
|
24
|
+
}
|
|
25
|
+
function createActionGroup(props, state, _ref) {
|
|
26
|
+
const locale = useLocale();
|
|
27
|
+
let groupRef;
|
|
28
|
+
const applyRoleAttributes = () => {
|
|
29
|
+
if (!groupRef) return;
|
|
30
|
+
const mappedRole = GROUP_ROLE_BY_MODE[state.selectionMode()];
|
|
31
|
+
const nestedToolbar = Boolean(groupRef.parentElement?.closest("[role=\"toolbar\"]"));
|
|
32
|
+
const role = mappedRole === "toolbar" && nestedToolbar ? "group" : mappedRole;
|
|
33
|
+
groupRef.setAttribute("role", role);
|
|
34
|
+
if (mappedRole === "toolbar" && !nestedToolbar) groupRef.setAttribute("aria-orientation", props.orientation ?? "horizontal");
|
|
35
|
+
else groupRef.removeAttribute("aria-orientation");
|
|
36
|
+
};
|
|
37
|
+
const getFocusableItems = (root) => {
|
|
38
|
+
const out = [];
|
|
39
|
+
const pushIfFocusable = (el) => {
|
|
40
|
+
if (!el || !(el instanceof HTMLElement)) return;
|
|
41
|
+
if (isFocusable(el) && el.getAttribute("aria-disabled") !== "true") out.push(el);
|
|
42
|
+
};
|
|
43
|
+
pushIfFocusable(root);
|
|
44
|
+
for (const node of root.querySelectorAll("*")) pushIfFocusable(node);
|
|
45
|
+
return out;
|
|
46
|
+
};
|
|
47
|
+
const focusRelative = (root, direction) => {
|
|
48
|
+
const focusables = getFocusableItems(root);
|
|
49
|
+
if (focusables.length === 0) return null;
|
|
50
|
+
if (direction === "first") {
|
|
51
|
+
const first = focusables[0];
|
|
52
|
+
focusSafely(first);
|
|
53
|
+
return first;
|
|
54
|
+
}
|
|
55
|
+
if (direction === "last") {
|
|
56
|
+
const last = focusables[focusables.length - 1];
|
|
57
|
+
focusSafely(last);
|
|
58
|
+
return last;
|
|
59
|
+
}
|
|
60
|
+
const active = root.ownerDocument.activeElement;
|
|
61
|
+
const currentIndex = active ? focusables.indexOf(active) : -1;
|
|
62
|
+
const next = focusables[currentIndex === -1 ? direction === "next" ? 0 : focusables.length - 1 : (currentIndex + (direction === "next" ? 1 : -1) + focusables.length) % focusables.length];
|
|
63
|
+
focusSafely(next);
|
|
64
|
+
return next;
|
|
65
|
+
};
|
|
66
|
+
const resolveKeyFromElement = (element) => {
|
|
67
|
+
if (!element) return null;
|
|
68
|
+
const keyedElement = element.closest("[data-key]");
|
|
69
|
+
if (!(keyedElement instanceof HTMLElement)) return null;
|
|
70
|
+
const rawKey = keyedElement.getAttribute("data-key");
|
|
71
|
+
if (!rawKey) return null;
|
|
72
|
+
for (const item of state.collection()) if (String(item.key) === rawKey) return item.key;
|
|
73
|
+
return null;
|
|
74
|
+
};
|
|
75
|
+
const handleFocusMove = (movedTo) => {
|
|
76
|
+
const key = resolveKeyFromElement(movedTo);
|
|
77
|
+
if (key == null) return;
|
|
78
|
+
state.setFocusedKey(key);
|
|
79
|
+
if (state.selectionMode() === "single") state.replaceSelection(key);
|
|
80
|
+
};
|
|
81
|
+
const onKeyDown = (e) => {
|
|
82
|
+
const root = groupRef;
|
|
83
|
+
if (!root || isActionGroupDisabled(props, state)) return;
|
|
84
|
+
if (!nodeContains(e.currentTarget, getEventTarget(e))) return;
|
|
85
|
+
const isHorizontal = (props.orientation ?? "horizontal") === "horizontal";
|
|
86
|
+
const isRTL = locale().direction === "rtl" && isHorizontal;
|
|
87
|
+
switch (e.key) {
|
|
88
|
+
case "ArrowRight":
|
|
89
|
+
case "ArrowDown":
|
|
90
|
+
if (e.key === "ArrowRight" && isHorizontal && isRTL) {
|
|
91
|
+
e.preventDefault();
|
|
92
|
+
e.stopPropagation();
|
|
93
|
+
handleFocusMove(focusRelative(root, "previous"));
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (e.key === "ArrowRight" && isHorizontal || e.key === "ArrowDown" && !isHorizontal) {
|
|
97
|
+
e.preventDefault();
|
|
98
|
+
e.stopPropagation();
|
|
99
|
+
handleFocusMove(focusRelative(root, "next"));
|
|
100
|
+
}
|
|
101
|
+
return;
|
|
102
|
+
case "ArrowLeft":
|
|
103
|
+
case "ArrowUp":
|
|
104
|
+
if (e.key === "ArrowLeft" && isHorizontal && isRTL) {
|
|
105
|
+
e.preventDefault();
|
|
106
|
+
e.stopPropagation();
|
|
107
|
+
handleFocusMove(focusRelative(root, "next"));
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (e.key === "ArrowLeft" && isHorizontal || e.key === "ArrowUp" && !isHorizontal) {
|
|
111
|
+
e.preventDefault();
|
|
112
|
+
e.stopPropagation();
|
|
113
|
+
handleFocusMove(focusRelative(root, "previous"));
|
|
114
|
+
}
|
|
115
|
+
return;
|
|
116
|
+
case "Home":
|
|
117
|
+
e.preventDefault();
|
|
118
|
+
e.stopPropagation();
|
|
119
|
+
handleFocusMove(focusRelative(root, "first"));
|
|
120
|
+
return;
|
|
121
|
+
case "End":
|
|
122
|
+
e.preventDefault();
|
|
123
|
+
e.stopPropagation();
|
|
124
|
+
handleFocusMove(focusRelative(root, "last"));
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
const actionGroupProps = mergeProps(filterDOMProps(props, { labelable: true }), {
|
|
129
|
+
ref: (el) => {
|
|
130
|
+
groupRef = el;
|
|
131
|
+
applyRoleAttributes();
|
|
132
|
+
queueMicrotask(() => {
|
|
133
|
+
if (!groupRef) return;
|
|
134
|
+
applyRoleAttributes();
|
|
135
|
+
});
|
|
136
|
+
},
|
|
137
|
+
onKeyDown,
|
|
138
|
+
get "aria-label"() {
|
|
139
|
+
return props["aria-label"];
|
|
140
|
+
},
|
|
141
|
+
get "aria-labelledby"() {
|
|
142
|
+
return props["aria-label"] ? void 0 : props["aria-labelledby"];
|
|
143
|
+
},
|
|
144
|
+
get "aria-disabled"() {
|
|
145
|
+
return isActionGroupDisabled(props, state) || void 0;
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
actionGroupData.set(state, { get onAction() {
|
|
149
|
+
return props.onAction;
|
|
150
|
+
} });
|
|
151
|
+
onCleanup(() => {
|
|
152
|
+
actionGroupData.delete(state);
|
|
153
|
+
});
|
|
154
|
+
return { actionGroupProps };
|
|
155
|
+
}
|
|
156
|
+
function createActionGroupItem(props, state) {
|
|
157
|
+
const button = createButton({
|
|
158
|
+
elementType: "button",
|
|
159
|
+
isDisabled: state.isDisabled(props.key),
|
|
160
|
+
onPress: () => {
|
|
161
|
+
state.setFocusedKey(props.key);
|
|
162
|
+
actionGroupData.get(state)?.onAction?.(props.key);
|
|
163
|
+
if (state.selectionMode() !== "none") state.select(props.key);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
const isFocused = () => props.key === state.focusedKey();
|
|
167
|
+
const getFirstEnabledKey = () => {
|
|
168
|
+
const collection = state.collection();
|
|
169
|
+
let key = collection.getFirstKey();
|
|
170
|
+
while (key != null && state.isDisabled(key)) key = collection.getKeyAfter(key);
|
|
171
|
+
return key;
|
|
172
|
+
};
|
|
173
|
+
const getDefaultTabStopKey = () => {
|
|
174
|
+
if (state.selectionMode() !== "none") {
|
|
175
|
+
const selectedKeys = state.selectedKeys();
|
|
176
|
+
if (selectedKeys === "all") return getFirstEnabledKey();
|
|
177
|
+
for (const item of state.collection()) if (!state.isDisabled(item.key) && selectedKeys.has(item.key)) return item.key;
|
|
178
|
+
}
|
|
179
|
+
return getFirstEnabledKey();
|
|
180
|
+
};
|
|
181
|
+
onCleanup(() => {
|
|
182
|
+
if (isFocused()) state.setFocusedKey(null);
|
|
183
|
+
});
|
|
184
|
+
return { buttonProps: mergeProps(button.buttonProps, {
|
|
185
|
+
get role() {
|
|
186
|
+
return ITEM_ROLE_BY_MODE[state.selectionMode()];
|
|
187
|
+
},
|
|
188
|
+
get "aria-checked"() {
|
|
189
|
+
if (state.selectionMode() === "none") return void 0;
|
|
190
|
+
return state.isSelected(props.key);
|
|
191
|
+
},
|
|
192
|
+
get tabIndex() {
|
|
193
|
+
if (state.isDisabled(props.key)) return -1;
|
|
194
|
+
if (isFocused()) return 0;
|
|
195
|
+
if (state.focusedKey() != null) return -1;
|
|
196
|
+
return getDefaultTabStopKey() === props.key ? 0 : -1;
|
|
197
|
+
},
|
|
198
|
+
"data-key": String(props.key),
|
|
199
|
+
onFocus: () => {
|
|
200
|
+
state.setFocusedKey(props.key);
|
|
201
|
+
}
|
|
202
|
+
}) };
|
|
203
|
+
}
|
|
204
|
+
//#endregion
|
|
205
|
+
export { createActionGroupItem as n, createActionGroup as t };
|
|
206
|
+
|
|
207
|
+
//# sourceMappingURL=actiongroup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actiongroup.js","names":[],"sources":["../../src/actiongroup/createActionGroup.ts"],"sourcesContent":["import { onCleanup, type JSX, type Accessor } from \"solid-js\";\nimport { createButton } from \"../button\";\nimport {\n filterDOMProps,\n getEventTarget,\n mergeProps,\n nodeContains,\n isFocusable,\n focusSafely,\n} from \"../utils\";\nimport { useLocale } from \"../i18n\";\nimport type { Orientation } from \"../toolbar\";\nimport type { Key, ListState } from \"@proyecto-viviana/solid-stately\";\n\nexport interface AriaActionGroupProps<T = unknown> {\n /** List items (optional, parity with React Aria prop shape). */\n items?: T[];\n /** Whether the whole action group is disabled. */\n isDisabled?: boolean;\n /** Group orientation. */\n orientation?: Orientation;\n /** Accessible label. */\n \"aria-label\"?: string;\n /** Labelled-by id. */\n \"aria-labelledby\"?: string;\n /** Handler called when an item action is triggered. */\n onAction?: (key: Key) => void;\n}\n\nexport interface ActionGroupAria {\n actionGroupProps: JSX.HTMLAttributes<HTMLElement>;\n}\n\nexport interface AriaActionGroupItemProps {\n key: Key;\n}\n\nexport interface ActionGroupItemAria {\n buttonProps: JSX.HTMLAttributes<HTMLElement>;\n}\n\ninterface ActionGroupData {\n onAction?: (key: Key) => void;\n}\n\nconst actionGroupData = new WeakMap<object, ActionGroupData>();\n\nconst GROUP_ROLE_BY_MODE = {\n none: \"toolbar\",\n single: \"radiogroup\",\n multiple: \"toolbar\",\n} as const;\n\nconst ITEM_ROLE_BY_MODE = {\n none: undefined,\n single: \"radio\",\n multiple: \"checkbox\",\n} as const;\n\nfunction isActionGroupDisabled<T>(props: AriaActionGroupProps<T>, state: ListState<T>): boolean {\n if (props.isDisabled) return true;\n const keys = [...state.collection().getKeys()];\n if (keys.length === 0) return true;\n return !keys.some((key) => !state.isDisabled(key));\n}\n\nexport function createActionGroup<T>(\n props: AriaActionGroupProps<T>,\n state: ListState<T>,\n _ref?: Accessor<HTMLElement | null>,\n): ActionGroupAria {\n const locale = useLocale();\n let groupRef: HTMLElement | undefined;\n const applyRoleAttributes = (): void => {\n if (!groupRef) return;\n const selectionMode = state.selectionMode();\n const mappedRole = GROUP_ROLE_BY_MODE[selectionMode];\n const nestedToolbar = Boolean(groupRef.parentElement?.closest('[role=\"toolbar\"]'));\n const role = mappedRole === \"toolbar\" && nestedToolbar ? \"group\" : mappedRole;\n groupRef.setAttribute(\"role\", role);\n if (mappedRole === \"toolbar\" && !nestedToolbar) {\n groupRef.setAttribute(\"aria-orientation\", props.orientation ?? \"horizontal\");\n } else {\n groupRef.removeAttribute(\"aria-orientation\");\n }\n };\n\n const getFocusableItems = (root: HTMLElement): HTMLElement[] => {\n const out: HTMLElement[] = [];\n const pushIfFocusable = (el: Element | null | undefined): void => {\n if (!el || !(el instanceof HTMLElement)) return;\n if (isFocusable(el) && el.getAttribute(\"aria-disabled\") !== \"true\") {\n out.push(el);\n }\n };\n\n pushIfFocusable(root);\n for (const node of root.querySelectorAll(\"*\")) {\n pushIfFocusable(node);\n }\n return out;\n };\n\n const focusRelative = (\n root: HTMLElement,\n direction: \"next\" | \"previous\" | \"first\" | \"last\",\n ): HTMLElement | null => {\n const focusables = getFocusableItems(root);\n if (focusables.length === 0) return null;\n\n if (direction === \"first\") {\n const first = focusables[0];\n focusSafely(first);\n return first;\n }\n\n if (direction === \"last\") {\n const last = focusables[focusables.length - 1];\n focusSafely(last);\n return last;\n }\n\n const active = root.ownerDocument.activeElement as HTMLElement | null;\n const currentIndex = active ? focusables.indexOf(active) : -1;\n const delta = direction === \"next\" ? 1 : -1;\n const nextIndex =\n currentIndex === -1\n ? direction === \"next\"\n ? 0\n : focusables.length - 1\n : (currentIndex + delta + focusables.length) % focusables.length;\n const next = focusables[nextIndex];\n focusSafely(next);\n return next;\n };\n\n const resolveKeyFromElement = (element: HTMLElement | null): Key | null => {\n if (!element) return null;\n const keyedElement = element.closest(\"[data-key]\");\n if (!(keyedElement instanceof HTMLElement)) return null;\n const rawKey = keyedElement.getAttribute(\"data-key\");\n if (!rawKey) return null;\n for (const item of state.collection()) {\n if (String(item.key) === rawKey) {\n return item.key;\n }\n }\n return null;\n };\n\n const handleFocusMove = (movedTo: HTMLElement | null): void => {\n const key = resolveKeyFromElement(movedTo);\n if (key == null) return;\n state.setFocusedKey(key);\n if (state.selectionMode() === \"single\") {\n state.replaceSelection(key);\n }\n };\n\n const onKeyDown: JSX.EventHandler<HTMLElement, KeyboardEvent> = (e) => {\n const root = groupRef;\n if (!root || isActionGroupDisabled(props, state)) return;\n if (!nodeContains(e.currentTarget, getEventTarget(e))) return;\n\n const orientation = props.orientation ?? \"horizontal\";\n const isHorizontal = orientation === \"horizontal\";\n const isRTL = locale().direction === \"rtl\" && isHorizontal;\n\n switch (e.key) {\n case \"ArrowRight\":\n case \"ArrowDown\": {\n if (e.key === \"ArrowRight\" && isHorizontal && isRTL) {\n e.preventDefault();\n e.stopPropagation();\n handleFocusMove(focusRelative(root, \"previous\"));\n return;\n }\n if ((e.key === \"ArrowRight\" && isHorizontal) || (e.key === \"ArrowDown\" && !isHorizontal)) {\n e.preventDefault();\n e.stopPropagation();\n handleFocusMove(focusRelative(root, \"next\"));\n }\n return;\n }\n case \"ArrowLeft\":\n case \"ArrowUp\": {\n if (e.key === \"ArrowLeft\" && isHorizontal && isRTL) {\n e.preventDefault();\n e.stopPropagation();\n handleFocusMove(focusRelative(root, \"next\"));\n return;\n }\n if ((e.key === \"ArrowLeft\" && isHorizontal) || (e.key === \"ArrowUp\" && !isHorizontal)) {\n e.preventDefault();\n e.stopPropagation();\n handleFocusMove(focusRelative(root, \"previous\"));\n }\n return;\n }\n case \"Home\": {\n e.preventDefault();\n e.stopPropagation();\n handleFocusMove(focusRelative(root, \"first\"));\n return;\n }\n case \"End\": {\n e.preventDefault();\n e.stopPropagation();\n handleFocusMove(focusRelative(root, \"last\"));\n return;\n }\n }\n };\n\n const actionGroupProps: JSX.HTMLAttributes<HTMLElement> = mergeProps(\n filterDOMProps(props as Record<string, unknown>, { labelable: true }),\n {\n ref: (el: HTMLElement) => {\n groupRef = el;\n applyRoleAttributes();\n queueMicrotask(() => {\n if (!groupRef) return;\n applyRoleAttributes();\n });\n },\n onKeyDown,\n get \"aria-label\"() {\n return props[\"aria-label\"];\n },\n get \"aria-labelledby\"() {\n return props[\"aria-label\"] ? undefined : props[\"aria-labelledby\"];\n },\n get \"aria-disabled\"() {\n return isActionGroupDisabled(props, state) || undefined;\n },\n },\n );\n\n actionGroupData.set(state, {\n get onAction() {\n return props.onAction;\n },\n });\n\n onCleanup(() => {\n actionGroupData.delete(state);\n });\n\n return { actionGroupProps };\n}\n\nexport function createActionGroupItem<T>(\n props: AriaActionGroupItemProps,\n state: ListState<T>,\n): ActionGroupItemAria {\n const button = createButton({\n elementType: \"button\",\n isDisabled: state.isDisabled(props.key),\n onPress: () => {\n state.setFocusedKey(props.key);\n actionGroupData.get(state)?.onAction?.(props.key);\n if (state.selectionMode() !== \"none\") {\n state.select(props.key);\n }\n },\n });\n\n const isFocused = () => props.key === state.focusedKey();\n const getFirstEnabledKey = (): Key | null => {\n const collection = state.collection();\n let key = collection.getFirstKey();\n while (key != null && state.isDisabled(key)) {\n key = collection.getKeyAfter(key);\n }\n return key;\n };\n\n const getDefaultTabStopKey = (): Key | null => {\n const selectionMode = state.selectionMode();\n if (selectionMode !== \"none\") {\n const selectedKeys = state.selectedKeys();\n if (selectedKeys === \"all\") {\n return getFirstEnabledKey();\n }\n\n for (const item of state.collection()) {\n if (!state.isDisabled(item.key) && selectedKeys.has(item.key)) {\n return item.key;\n }\n }\n }\n\n return getFirstEnabledKey();\n };\n\n onCleanup(() => {\n if (isFocused()) {\n state.setFocusedKey(null);\n }\n });\n\n const buttonProps: JSX.HTMLAttributes<HTMLElement> = mergeProps(button.buttonProps, {\n get role() {\n return ITEM_ROLE_BY_MODE[state.selectionMode()];\n },\n get \"aria-checked\"() {\n const mode = state.selectionMode();\n if (mode === \"none\") return undefined;\n return state.isSelected(props.key);\n },\n get tabIndex() {\n if (state.isDisabled(props.key)) {\n return -1;\n }\n\n if (isFocused()) {\n return 0;\n }\n\n if (state.focusedKey() != null) {\n return -1;\n }\n\n const defaultTabStopKey = getDefaultTabStopKey();\n return defaultTabStopKey === props.key ? 0 : -1;\n },\n \"data-key\": String(props.key),\n onFocus: () => {\n state.setFocusedKey(props.key);\n },\n });\n\n return { buttonProps };\n}\n"],"mappings":";;;;;;;AA6CA,MAAM,kCAAkB,IAAI,QAAiC;AAE7D,MAAM,qBAAqB;CACzB,MAAM;CACN,QAAQ;CACR,UAAU;AACZ;AAEA,MAAM,oBAAoB;CACxB,MAAM,KAAA;CACN,QAAQ;CACR,UAAU;AACZ;AAEA,SAAS,sBAAyB,OAAgC,OAA8B;CAC9F,IAAI,MAAM,YAAY,OAAO;CAC7B,MAAM,OAAO,CAAC,GAAG,MAAM,WAAW,CAAC,CAAC,QAAQ,CAAC;CAC7C,IAAI,KAAK,WAAW,GAAG,OAAO;CAC9B,OAAO,CAAC,KAAK,MAAM,QAAQ,CAAC,MAAM,WAAW,GAAG,CAAC;AACnD;AAEA,SAAgB,kBACd,OACA,OACA,MACiB;CACjB,MAAM,SAAS,UAAU;CACzB,IAAI;CACJ,MAAM,4BAAkC;EACtC,IAAI,CAAC,UAAU;EAEf,MAAM,aAAa,mBADG,MAAM,cACsB;EAClD,MAAM,gBAAgB,QAAQ,SAAS,eAAe,QAAQ,oBAAkB,CAAC;EACjF,MAAM,OAAO,eAAe,aAAa,gBAAgB,UAAU;EACnE,SAAS,aAAa,QAAQ,IAAI;EAClC,IAAI,eAAe,aAAa,CAAC,eAC/B,SAAS,aAAa,oBAAoB,MAAM,eAAe,YAAY;OAE3E,SAAS,gBAAgB,k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IAAI,KAAK,GAAG,GAC1D,OAAO,KAAK;EAGlB;EAEA,OAAO,mBAAmB;CAC5B;CAEA,gBAAgB;EACd,IAAI,UAAU,GACZ,MAAM,cAAc,IAAI;CAE5B,CAAC;CAiCD,OAAO,EAAE,aA/B4C,WAAW,OAAO,aAAa;EAClF,IAAI,OAAO;GACT,OAAO,kBAAkB,MAAM,cAAc;EAC/C;EACA,IAAI,iBAAiB;GAEnB,IADa,MAAM,cACZ,MAAM,QAAQ,OAAO,KAAA;GAC5B,OAAO,MAAM,WAAW,MAAM,GAAG;EACnC;EACA,IAAI,WAAW;GACb,IAAI,MAAM,WAAW,MAAM,GAAG,GAC5B,OAAO;GAGT,IAAI,UAAU,GACZ,OAAO;GAGT,IAAI,MAAM,WAAW,KAAK,MACxB,OAAO;GAIT,OAD0B,qBACH,MAAM,MAAM,MAAM,IAAI;EAC/C;EACA,YAAY,OAAO,MAAM,GAAG;EAC5B,eAAe;GACb,MAAM,cAAc,MAAM,GAAG;EAC/B;CACF,CAEmB,EAAE;AACvB"}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { o as mergeProps } from "./env.jsx";
|
|
2
|
+
import { t as filterDOMProps } from "./filterDOMProps.jsx";
|
|
3
|
+
import { a as getEventTarget, p as isFocusable, t as focusSafely, y as nodeContains } from "./focus.jsx";
|
|
4
|
+
import { i as createButton } from "./button.jsx";
|
|
5
|
+
import { a as useLocale } from "./createCollator.jsx";
|
|
6
|
+
import { onCleanup } from "solid-js";
|
|
7
|
+
//#region src/actiongroup/createActionGroup.ts
|
|
8
|
+
const actionGroupData = /* @__PURE__ */ new WeakMap();
|
|
9
|
+
const GROUP_ROLE_BY_MODE = {
|
|
10
|
+
none: "toolbar",
|
|
11
|
+
single: "radiogroup",
|
|
12
|
+
multiple: "toolbar"
|
|
13
|
+
};
|
|
14
|
+
const ITEM_ROLE_BY_MODE = {
|
|
15
|
+
none: void 0,
|
|
16
|
+
single: "radio",
|
|
17
|
+
multiple: "checkbox"
|
|
18
|
+
};
|
|
19
|
+
function isActionGroupDisabled(props, state) {
|
|
20
|
+
if (props.isDisabled) return true;
|
|
21
|
+
const keys = [...state.collection().getKeys()];
|
|
22
|
+
if (keys.length === 0) return true;
|
|
23
|
+
return !keys.some((key) => !state.isDisabled(key));
|
|
24
|
+
}
|
|
25
|
+
function createActionGroup(props, state, _ref) {
|
|
26
|
+
const locale = useLocale();
|
|
27
|
+
let groupRef;
|
|
28
|
+
const applyRoleAttributes = () => {
|
|
29
|
+
if (!groupRef) return;
|
|
30
|
+
const mappedRole = GROUP_ROLE_BY_MODE[state.selectionMode()];
|
|
31
|
+
const nestedToolbar = Boolean(groupRef.parentElement?.closest("[role=\"toolbar\"]"));
|
|
32
|
+
const role = mappedRole === "toolbar" && nestedToolbar ? "group" : mappedRole;
|
|
33
|
+
groupRef.setAttribute("role", role);
|
|
34
|
+
if (mappedRole === "toolbar" && !nestedToolbar) groupRef.setAttribute("aria-orientation", props.orientation ?? "horizontal");
|
|
35
|
+
else groupRef.removeAttribute("aria-orientation");
|
|
36
|
+
};
|
|
37
|
+
const getFocusableItems = (root) => {
|
|
38
|
+
const out = [];
|
|
39
|
+
const pushIfFocusable = (el) => {
|
|
40
|
+
if (!el || !(el instanceof HTMLElement)) return;
|
|
41
|
+
if (isFocusable(el) && el.getAttribute("aria-disabled") !== "true") out.push(el);
|
|
42
|
+
};
|
|
43
|
+
pushIfFocusable(root);
|
|
44
|
+
for (const node of root.querySelectorAll("*")) pushIfFocusable(node);
|
|
45
|
+
return out;
|
|
46
|
+
};
|
|
47
|
+
const focusRelative = (root, direction) => {
|
|
48
|
+
const focusables = getFocusableItems(root);
|
|
49
|
+
if (focusables.length === 0) return null;
|
|
50
|
+
if (direction === "first") {
|
|
51
|
+
const first = focusables[0];
|
|
52
|
+
focusSafely(first);
|
|
53
|
+
return first;
|
|
54
|
+
}
|
|
55
|
+
if (direction === "last") {
|
|
56
|
+
const last = focusables[focusables.length - 1];
|
|
57
|
+
focusSafely(last);
|
|
58
|
+
return last;
|
|
59
|
+
}
|
|
60
|
+
const active = root.ownerDocument.activeElement;
|
|
61
|
+
const currentIndex = active ? focusables.indexOf(active) : -1;
|
|
62
|
+
const next = focusables[currentIndex === -1 ? direction === "next" ? 0 : focusables.length - 1 : (currentIndex + (direction === "next" ? 1 : -1) + focusables.length) % focusables.length];
|
|
63
|
+
focusSafely(next);
|
|
64
|
+
return next;
|
|
65
|
+
};
|
|
66
|
+
const resolveKeyFromElement = (element) => {
|
|
67
|
+
if (!element) return null;
|
|
68
|
+
const keyedElement = element.closest("[data-key]");
|
|
69
|
+
if (!(keyedElement instanceof HTMLElement)) return null;
|
|
70
|
+
const rawKey = keyedElement.getAttribute("data-key");
|
|
71
|
+
if (!rawKey) return null;
|
|
72
|
+
for (const item of state.collection()) if (String(item.key) === rawKey) return item.key;
|
|
73
|
+
return null;
|
|
74
|
+
};
|
|
75
|
+
const handleFocusMove = (movedTo) => {
|
|
76
|
+
const key = resolveKeyFromElement(movedTo);
|
|
77
|
+
if (key == null) return;
|
|
78
|
+
state.setFocusedKey(key);
|
|
79
|
+
if (state.selectionMode() === "single") state.replaceSelection(key);
|
|
80
|
+
};
|
|
81
|
+
const onKeyDown = (e) => {
|
|
82
|
+
const root = groupRef;
|
|
83
|
+
if (!root || isActionGroupDisabled(props, state)) return;
|
|
84
|
+
if (!nodeContains(e.currentTarget, getEventTarget(e))) return;
|
|
85
|
+
const isHorizontal = (props.orientation ?? "horizontal") === "horizontal";
|
|
86
|
+
const isRTL = locale().direction === "rtl" && isHorizontal;
|
|
87
|
+
switch (e.key) {
|
|
88
|
+
case "ArrowRight":
|
|
89
|
+
case "ArrowDown":
|
|
90
|
+
if (e.key === "ArrowRight" && isHorizontal && isRTL) {
|
|
91
|
+
e.preventDefault();
|
|
92
|
+
e.stopPropagation();
|
|
93
|
+
handleFocusMove(focusRelative(root, "previous"));
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (e.key === "ArrowRight" && isHorizontal || e.key === "ArrowDown" && !isHorizontal) {
|
|
97
|
+
e.preventDefault();
|
|
98
|
+
e.stopPropagation();
|
|
99
|
+
handleFocusMove(focusRelative(root, "next"));
|
|
100
|
+
}
|
|
101
|
+
return;
|
|
102
|
+
case "ArrowLeft":
|
|
103
|
+
case "ArrowUp":
|
|
104
|
+
if (e.key === "ArrowLeft" && isHorizontal && isRTL) {
|
|
105
|
+
e.preventDefault();
|
|
106
|
+
e.stopPropagation();
|
|
107
|
+
handleFocusMove(focusRelative(root, "next"));
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (e.key === "ArrowLeft" && isHorizontal || e.key === "ArrowUp" && !isHorizontal) {
|
|
111
|
+
e.preventDefault();
|
|
112
|
+
e.stopPropagation();
|
|
113
|
+
handleFocusMove(focusRelative(root, "previous"));
|
|
114
|
+
}
|
|
115
|
+
return;
|
|
116
|
+
case "Home":
|
|
117
|
+
e.preventDefault();
|
|
118
|
+
e.stopPropagation();
|
|
119
|
+
handleFocusMove(focusRelative(root, "first"));
|
|
120
|
+
return;
|
|
121
|
+
case "End":
|
|
122
|
+
e.preventDefault();
|
|
123
|
+
e.stopPropagation();
|
|
124
|
+
handleFocusMove(focusRelative(root, "last"));
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
const actionGroupProps = mergeProps(filterDOMProps(props, { labelable: true }), {
|
|
129
|
+
ref: (el) => {
|
|
130
|
+
groupRef = el;
|
|
131
|
+
applyRoleAttributes();
|
|
132
|
+
queueMicrotask(() => {
|
|
133
|
+
if (!groupRef) return;
|
|
134
|
+
applyRoleAttributes();
|
|
135
|
+
});
|
|
136
|
+
},
|
|
137
|
+
onKeyDown,
|
|
138
|
+
get "aria-label"() {
|
|
139
|
+
return props["aria-label"];
|
|
140
|
+
},
|
|
141
|
+
get "aria-labelledby"() {
|
|
142
|
+
return props["aria-label"] ? void 0 : props["aria-labelledby"];
|
|
143
|
+
},
|
|
144
|
+
get "aria-disabled"() {
|
|
145
|
+
return isActionGroupDisabled(props, state) || void 0;
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
actionGroupData.set(state, { get onAction() {
|
|
149
|
+
return props.onAction;
|
|
150
|
+
} });
|
|
151
|
+
onCleanup(() => {
|
|
152
|
+
actionGroupData.delete(state);
|
|
153
|
+
});
|
|
154
|
+
return { actionGroupProps };
|
|
155
|
+
}
|
|
156
|
+
function createActionGroupItem(props, state) {
|
|
157
|
+
const button = createButton({
|
|
158
|
+
elementType: "button",
|
|
159
|
+
isDisabled: state.isDisabled(props.key),
|
|
160
|
+
onPress: () => {
|
|
161
|
+
state.setFocusedKey(props.key);
|
|
162
|
+
actionGroupData.get(state)?.onAction?.(props.key);
|
|
163
|
+
if (state.selectionMode() !== "none") state.select(props.key);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
const isFocused = () => props.key === state.focusedKey();
|
|
167
|
+
const getFirstEnabledKey = () => {
|
|
168
|
+
const collection = state.collection();
|
|
169
|
+
let key = collection.getFirstKey();
|
|
170
|
+
while (key != null && state.isDisabled(key)) key = collection.getKeyAfter(key);
|
|
171
|
+
return key;
|
|
172
|
+
};
|
|
173
|
+
const getDefaultTabStopKey = () => {
|
|
174
|
+
if (state.selectionMode() !== "none") {
|
|
175
|
+
const selectedKeys = state.selectedKeys();
|
|
176
|
+
if (selectedKeys === "all") return getFirstEnabledKey();
|
|
177
|
+
for (const item of state.collection()) if (!state.isDisabled(item.key) && selectedKeys.has(item.key)) return item.key;
|
|
178
|
+
}
|
|
179
|
+
return getFirstEnabledKey();
|
|
180
|
+
};
|
|
181
|
+
onCleanup(() => {
|
|
182
|
+
if (isFocused()) state.setFocusedKey(null);
|
|
183
|
+
});
|
|
184
|
+
return { buttonProps: mergeProps(button.buttonProps, {
|
|
185
|
+
get role() {
|
|
186
|
+
return ITEM_ROLE_BY_MODE[state.selectionMode()];
|
|
187
|
+
},
|
|
188
|
+
get "aria-checked"() {
|
|
189
|
+
if (state.selectionMode() === "none") return void 0;
|
|
190
|
+
return state.isSelected(props.key);
|
|
191
|
+
},
|
|
192
|
+
get tabIndex() {
|
|
193
|
+
if (state.isDisabled(props.key)) return -1;
|
|
194
|
+
if (isFocused()) return 0;
|
|
195
|
+
if (state.focusedKey() != null) return -1;
|
|
196
|
+
return getDefaultTabStopKey() === props.key ? 0 : -1;
|
|
197
|
+
},
|
|
198
|
+
"data-key": String(props.key),
|
|
199
|
+
onFocus: () => {
|
|
200
|
+
state.setFocusedKey(props.key);
|
|
201
|
+
}
|
|
202
|
+
}) };
|
|
203
|
+
}
|
|
204
|
+
//#endregion
|
|
205
|
+
export { createActionGroupItem as n, createActionGroup as t };
|
|
206
|
+
|
|
207
|
+
//# sourceMappingURL=actiongroup.jsx.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actiongroup.jsx","names":[],"sources":["../../src/actiongroup/createActionGroup.ts"],"sourcesContent":["import { onCleanup, type JSX, type Accessor } from \"solid-js\";\nimport { createButton } from \"../button\";\nimport {\n filterDOMProps,\n getEventTarget,\n mergeProps,\n nodeContains,\n isFocusable,\n focusSafely,\n} from \"../utils\";\nimport { useLocale } from \"../i18n\";\nimport type { Orientation } from \"../toolbar\";\nimport type { Key, ListState } from \"@proyecto-viviana/solid-stately\";\n\nexport interface AriaActionGroupProps<T = unknown> {\n /** List items (optional, parity with React Aria prop shape). */\n items?: T[];\n /** Whether the whole action group is disabled. */\n isDisabled?: boolean;\n /** Group orientation. */\n orientation?: Orientation;\n /** Accessible label. */\n \"aria-label\"?: string;\n /** Labelled-by id. */\n \"aria-labelledby\"?: string;\n /** Handler called when an item action is triggered. */\n onAction?: (key: Key) => void;\n}\n\nexport interface ActionGroupAria {\n actionGroupProps: JSX.HTMLAttributes<HTMLElement>;\n}\n\nexport interface AriaActionGroupItemProps {\n key: Key;\n}\n\nexport interface ActionGroupItemAria {\n buttonProps: JSX.HTMLAttributes<HTMLElement>;\n}\n\ninterface ActionGroupData {\n onAction?: (key: Key) => void;\n}\n\nconst actionGroupData = new WeakMap<object, ActionGroupData>();\n\nconst GROUP_ROLE_BY_MODE = {\n none: \"toolbar\",\n single: \"radiogroup\",\n multiple: \"toolbar\",\n} as const;\n\nconst ITEM_ROLE_BY_MODE = {\n none: undefined,\n single: \"radio\",\n multiple: \"checkbox\",\n} as const;\n\nfunction isActionGroupDisabled<T>(props: AriaActionGroupProps<T>, state: ListState<T>): boolean {\n if (props.isDisabled) return true;\n const keys = [...state.collection().getKeys()];\n if (keys.length === 0) return true;\n return !keys.some((key) => !state.isDisabled(key));\n}\n\nexport function createActionGroup<T>(\n props: AriaActionGroupProps<T>,\n state: ListState<T>,\n _ref?: Accessor<HTMLElement | null>,\n): ActionGroupAria {\n const locale = useLocale();\n let groupRef: HTMLElement | undefined;\n const applyRoleAttributes = (): void => {\n if (!groupRef) return;\n const selectionMode = state.selectionMode();\n const mappedRole = GROUP_ROLE_BY_MODE[selectionMode];\n const nestedToolbar = Boolean(groupRef.parentElement?.closest('[role=\"toolbar\"]'));\n const role = mappedRole === \"toolbar\" && nestedToolbar ? \"group\" : mappedRole;\n groupRef.setAttribute(\"role\", role);\n if (mappedRole === \"toolbar\" && !nestedToolbar) {\n groupRef.setAttribute(\"aria-orientation\", props.orientation ?? \"horizontal\");\n } else {\n groupRef.removeAttribute(\"aria-orientation\");\n }\n };\n\n const getFocusableItems = (root: HTMLElement): HTMLElement[] => {\n const out: HTMLElement[] = [];\n const pushIfFocusable = (el: Element | null | undefined): void => {\n if (!el || !(el instanceof HTMLElement)) return;\n if (isFocusable(el) && el.getAttribute(\"aria-disabled\") !== \"true\") {\n out.push(el);\n }\n };\n\n pushIfFocusable(root);\n for (const node of root.querySelectorAll(\"*\")) {\n pushIfFocusable(node);\n }\n return out;\n };\n\n const focusRelative = (\n root: HTMLElement,\n direction: \"next\" | \"previous\" | \"first\" | \"last\",\n ): HTMLElement | null => {\n const focusables = getFocusableItems(root);\n if (focusables.length === 0) return null;\n\n if (direction === \"first\") {\n const first = focusables[0];\n focusSafely(first);\n return first;\n }\n\n if (direction === \"last\") {\n const last = focusables[focusables.length - 1];\n focusSafely(last);\n return last;\n }\n\n const active = root.ownerDocument.activeElement as HTMLElement | null;\n const currentIndex = active ? focusables.indexOf(active) : -1;\n const delta = direction === \"next\" ? 1 : -1;\n const nextIndex =\n currentIndex === -1\n ? direction === \"next\"\n ? 0\n : focusables.length - 1\n : (currentIndex + delta + focusables.length) % focusables.length;\n const next = focusables[nextIndex];\n focusSafely(next);\n return next;\n };\n\n const resolveKeyFromElement = (element: HTMLElement | null): Key | null => {\n if (!element) return null;\n const keyedElement = element.closest(\"[data-key]\");\n if (!(keyedElement instanceof HTMLElement)) return null;\n const rawKey = keyedElement.getAttribute(\"data-key\");\n if (!rawKey) return null;\n for (const item of state.collection()) {\n if (String(item.key) === rawKey) {\n return item.key;\n }\n }\n return null;\n };\n\n const handleFocusMove = (movedTo: HTMLElement | null): void => {\n const key = resolveKeyFromElement(movedTo);\n if (key == null) return;\n state.setFocusedKey(key);\n if (state.selectionMode() === \"single\") {\n state.replaceSelection(key);\n }\n };\n\n const onKeyDown: JSX.EventHandler<HTMLElement, KeyboardEvent> = (e) => {\n const root = groupRef;\n if (!root || isActionGroupDisabled(props, state)) return;\n if (!nodeContains(e.currentTarget, getEventTarget(e))) return;\n\n const orientation = props.orientation ?? \"horizontal\";\n const isHorizontal = orientation === \"horizontal\";\n const isRTL = locale().direction === \"rtl\" && isHorizontal;\n\n switch (e.key) {\n case \"ArrowRight\":\n case \"ArrowDown\": {\n if (e.key === \"ArrowRight\" && isHorizontal && isRTL) {\n e.preventDefault();\n e.stopPropagation();\n handleFocusMove(focusRelative(root, \"previous\"));\n return;\n }\n if ((e.key === \"ArrowRight\" && isHorizontal) || (e.key === \"ArrowDown\" && !isHorizontal)) {\n e.preventDefault();\n e.stopPropagation();\n handleFocusMove(focusRelative(root, \"next\"));\n }\n return;\n }\n case \"ArrowLeft\":\n case \"ArrowUp\": {\n if (e.key === \"ArrowLeft\" && isHorizontal && isRTL) {\n e.preventDefault();\n e.stopPropagation();\n handleFocusMove(focusRelative(root, \"next\"));\n return;\n }\n if ((e.key === \"ArrowLeft\" && isHorizontal) || (e.key === \"ArrowUp\" && !isHorizontal)) {\n e.preventDefault();\n e.stopPropagation();\n handleFocusMove(focusRelative(root, \"previous\"));\n }\n return;\n }\n case \"Home\": {\n e.preventDefault();\n e.stopPropagation();\n handleFocusMove(focusRelative(root, \"first\"));\n return;\n }\n case \"End\": {\n e.preventDefault();\n e.stopPropagation();\n handleFocusMove(focusRelative(root, \"last\"));\n return;\n }\n }\n };\n\n const actionGroupProps: JSX.HTMLAttributes<HTMLElement> = mergeProps(\n filterDOMProps(props as Record<string, unknown>, { labelable: true }),\n {\n ref: (el: HTMLElement) => {\n groupRef = el;\n applyRoleAttributes();\n queueMicrotask(() => {\n if (!groupRef) return;\n applyRoleAttributes();\n });\n },\n onKeyDown,\n get \"aria-label\"() {\n return props[\"aria-label\"];\n },\n get \"aria-labelledby\"() {\n return props[\"aria-label\"] ? undefined : props[\"aria-labelledby\"];\n },\n get \"aria-disabled\"() {\n return isActionGroupDisabled(props, state) || undefined;\n },\n },\n );\n\n actionGroupData.set(state, {\n get onAction() {\n return props.onAction;\n },\n });\n\n onCleanup(() => {\n actionGroupData.delete(state);\n });\n\n return { actionGroupProps };\n}\n\nexport function createActionGroupItem<T>(\n props: AriaActionGroupItemProps,\n state: ListState<T>,\n): ActionGroupItemAria {\n const button = createButton({\n elementType: \"button\",\n isDisabled: state.isDisabled(props.key),\n onPress: () => {\n state.setFocusedKey(props.key);\n actionGroupData.get(state)?.onAction?.(props.key);\n if (state.selectionMode() !== \"none\") {\n state.select(props.key);\n }\n },\n });\n\n const isFocused = () => props.key === state.focusedKey();\n const getFirstEnabledKey = (): Key | null => {\n const collection = state.collection();\n let key = collection.getFirstKey();\n while (key != null && state.isDisabled(key)) {\n key = collection.getKeyAfter(key);\n }\n return key;\n };\n\n const getDefaultTabStopKey = (): Key | null => {\n const selectionMode = state.selectionMode();\n if (selectionMode !== \"none\") {\n const selectedKeys = state.selectedKeys();\n if (selectedKeys === \"all\") {\n return getFirstEnabledKey();\n }\n\n for (const item of state.collection()) {\n if (!state.isDisabled(item.key) && selectedKeys.has(item.key)) {\n return item.key;\n }\n }\n }\n\n return getFirstEnabledKey();\n };\n\n onCleanup(() => {\n if (isFocused()) {\n state.setFocusedKey(null);\n }\n });\n\n const buttonProps: JSX.HTMLAttributes<HTMLElement> = mergeProps(button.buttonProps, {\n get role() {\n return ITEM_ROLE_BY_MODE[state.selectionMode()];\n },\n get \"aria-checked\"() {\n const mode = state.selectionMode();\n if (mode === \"none\") return undefined;\n return state.isSelected(props.key);\n },\n get tabIndex() {\n if (state.isDisabled(props.key)) {\n return -1;\n }\n\n if (isFocused()) {\n return 0;\n }\n\n if (state.focusedKey() != null) {\n return -1;\n }\n\n const defaultTabStopKey = getDefaultTabStopKey();\n return defaultTabStopKey === props.key ? 0 : -1;\n },\n \"data-key\": String(props.key),\n onFocus: () => {\n state.setFocusedKey(props.key);\n },\n });\n\n return { buttonProps };\n}\n"],"mappings":";;;;;;;AA6CA,MAAM,kCAAkB,IAAI,QAAiC;AAE7D,MAAM,qBAAqB;CACzB,MAAM;CACN,QAAQ;CACR,UAAU;AACZ;AAEA,MAAM,oBAAoB;CACxB,MAAM,KAAA;CACN,QAAQ;CACR,UAAU;AACZ;AAEA,SAAS,sBAAyB,OAAgC,OAA8B;CAC9F,IAAI,MAAM,YAAY,OAAO;CAC7B,MAAM,OAAO,CAAC,GAAG,MAAM,WAAW,CAAC,CAAC,QAAQ,CAAC;CAC7C,IAAI,KAAK,WAAW,GAAG,OAAO;CAC9B,OAAO,CAAC,KAAK,MAAM,QAAQ,CAAC,MAAM,WAAW,GAAG,CAAC;AACnD;AAEA,SAAgB,kBACd,OACA,OACA,MACiB;CACjB,MAAM,SAAS,UAAU;CACzB,IAAI;CACJ,MAAM,4BAAkC;EACtC,IAAI,CAAC,UAAU;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,GACxC,MAAM,WAAW,YAAY,GAAG;EAElC,OAAO;CACT;CAEA,MAAM,6BAAyC;EAE7C,IADsB,MAAM,cACZ,MAAM,QAAQ;GAC5B,MAAM,eAAe,MAAM,aAAa;GACxC,IAAI,iBAAiB,OACnB,OAAO,mBAAmB;GAG5B,KAAK,MAAM,QAAQ,MAAM,WAAW,GAClC,IAAI,CAAC,MAAM,WAAW,KAAK,GAAG,KAAK,aAAa,IAAI,KAAK,GAAG,GAC1D,OAAO,KAAK;EAGlB;EAEA,OAAO,mBAAmB;CAC5B;CAEA,gBAAgB;EACd,IAAI,UAAU,GACZ,MAAM,cAAc,IAAI;CAE5B,CAAC;CAiCD,OAAO,EAAE,aA/B4C,WAAW,OAAO,aAAa;EAClF,IAAI,OAAO;GACT,OAAO,kBAAkB,MAAM,cAAc;EAC/C;EACA,IAAI,iBAAiB;GAEnB,IADa,MAAM,cACZ,MAAM,QAAQ,OAAO,KAAA;GAC5B,OAAO,MAAM,WAAW,MAAM,GAAG;EACnC;EACA,IAAI,WAAW;GACb,IAAI,MAAM,WAAW,MAAM,GAAG,GAC5B,OAAO;GAGT,IAAI,UAAU,GACZ,OAAO;GAGT,IAAI,MAAM,WAAW,KAAK,MACxB,OAAO;GAIT,OAD0B,qBACH,MAAM,MAAM,MAAM,IAAI;EAC/C;EACA,YAAY,OAAO,MAAM,GAAG;EAC5B,eAAe;GACb,MAAM,cAAc,MAAM,GAAG;EAC/B;CACF,CAEmB,EAAE;AACvB"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { c as getOwnerWindow } from "./focus.js";
|
|
2
|
+
//#region src/overlays/ariaHideOutside.ts
|
|
3
|
+
/**
|
|
4
|
+
* Hides all elements in the DOM outside the given targets from screen readers.
|
|
5
|
+
* Based on @react-aria/overlays ariaHideOutside.
|
|
6
|
+
*/
|
|
7
|
+
const supportsInert = typeof HTMLElement !== "undefined" && "inert" in HTMLElement.prototype;
|
|
8
|
+
const refCountMap = /* @__PURE__ */ new WeakMap();
|
|
9
|
+
const observerStack = [];
|
|
10
|
+
/**
|
|
11
|
+
* Hides all elements in the DOM outside the given targets from screen readers using aria-hidden,
|
|
12
|
+
* and returns a function to revert these changes. In addition, changes to the DOM are watched
|
|
13
|
+
* and new elements outside the targets are automatically hidden.
|
|
14
|
+
* @param targets - The elements that should remain visible.
|
|
15
|
+
* @param options - Options for hiding behavior.
|
|
16
|
+
* @returns - A function to restore all hidden elements.
|
|
17
|
+
*/
|
|
18
|
+
function ariaHideOutside(targets, options) {
|
|
19
|
+
const windowObj = getOwnerWindow(targets?.[0]);
|
|
20
|
+
const opts = options instanceof windowObj.Element ? { root: options } : options;
|
|
21
|
+
const root = opts?.root ?? document.body;
|
|
22
|
+
const shouldUseInert = opts?.shouldUseInert && supportsInert;
|
|
23
|
+
const visibleNodes = new Set(targets);
|
|
24
|
+
const hiddenNodes = /* @__PURE__ */ new Set();
|
|
25
|
+
const getHidden = (element) => {
|
|
26
|
+
return shouldUseInert && element instanceof windowObj.HTMLElement ? element.inert : element.getAttribute("aria-hidden") === "true";
|
|
27
|
+
};
|
|
28
|
+
const setHidden = (element, hidden) => {
|
|
29
|
+
if (shouldUseInert && element instanceof windowObj.HTMLElement) element.inert = hidden;
|
|
30
|
+
else if (hidden) element.setAttribute("aria-hidden", "true");
|
|
31
|
+
else {
|
|
32
|
+
element.removeAttribute("aria-hidden");
|
|
33
|
+
if (element instanceof windowObj.HTMLElement) element.inert = false;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const hide = (node) => {
|
|
37
|
+
let refCount = refCountMap.get(node) ?? 0;
|
|
38
|
+
if (getHidden(node) && refCount === 0) return;
|
|
39
|
+
if (refCount === 0) setHidden(node, true);
|
|
40
|
+
hiddenNodes.add(node);
|
|
41
|
+
refCountMap.set(node, refCount + 1);
|
|
42
|
+
};
|
|
43
|
+
const walk = (walkRoot) => {
|
|
44
|
+
for (const element of walkRoot.querySelectorAll("[data-live-announcer], [data-solidaria-top-layer]")) visibleNodes.add(element);
|
|
45
|
+
const acceptNode = (node) => {
|
|
46
|
+
if (hiddenNodes.has(node) || visibleNodes.has(node) || node.parentElement && hiddenNodes.has(node.parentElement) && node.parentElement.getAttribute("role") !== "row") return NodeFilter.FILTER_REJECT;
|
|
47
|
+
for (const target of visibleNodes) if (node.contains(target)) return NodeFilter.FILTER_SKIP;
|
|
48
|
+
return NodeFilter.FILTER_ACCEPT;
|
|
49
|
+
};
|
|
50
|
+
const walker = document.createTreeWalker(walkRoot, NodeFilter.SHOW_ELEMENT, { acceptNode });
|
|
51
|
+
const acceptRoot = acceptNode(walkRoot);
|
|
52
|
+
if (acceptRoot === NodeFilter.FILTER_ACCEPT) hide(walkRoot);
|
|
53
|
+
if (acceptRoot !== NodeFilter.FILTER_REJECT) {
|
|
54
|
+
let node = walker.nextNode();
|
|
55
|
+
while (node != null) {
|
|
56
|
+
hide(node);
|
|
57
|
+
node = walker.nextNode();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
if (observerStack.length) observerStack[observerStack.length - 1].disconnect();
|
|
62
|
+
walk(root);
|
|
63
|
+
const observer = new MutationObserver((changes) => {
|
|
64
|
+
for (const change of changes) {
|
|
65
|
+
if (change.type !== "childList") continue;
|
|
66
|
+
if (![...visibleNodes, ...hiddenNodes].some((node) => node.contains(change.target))) {
|
|
67
|
+
for (const node of change.addedNodes) if ((node instanceof HTMLElement || node instanceof SVGElement) && (node.dataset.liveAnnouncer === "true" || node.dataset.solidariaTopLayer === "true")) visibleNodes.add(node);
|
|
68
|
+
else if (node instanceof Element) walk(node);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
observer.observe(root, {
|
|
73
|
+
childList: true,
|
|
74
|
+
subtree: true
|
|
75
|
+
});
|
|
76
|
+
const observerWrapper = {
|
|
77
|
+
visibleNodes,
|
|
78
|
+
hiddenNodes,
|
|
79
|
+
observe() {
|
|
80
|
+
observer.observe(root, {
|
|
81
|
+
childList: true,
|
|
82
|
+
subtree: true
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
disconnect() {
|
|
86
|
+
observer.disconnect();
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
observerStack.push(observerWrapper);
|
|
90
|
+
return () => {
|
|
91
|
+
observer.disconnect();
|
|
92
|
+
for (const node of hiddenNodes) {
|
|
93
|
+
const count = refCountMap.get(node);
|
|
94
|
+
if (count == null) continue;
|
|
95
|
+
if (count === 1) {
|
|
96
|
+
setHidden(node, false);
|
|
97
|
+
refCountMap.delete(node);
|
|
98
|
+
} else refCountMap.set(node, count - 1);
|
|
99
|
+
}
|
|
100
|
+
if (observerWrapper === observerStack[observerStack.length - 1]) {
|
|
101
|
+
observerStack.pop();
|
|
102
|
+
if (observerStack.length) observerStack[observerStack.length - 1].observe();
|
|
103
|
+
} else observerStack.splice(observerStack.indexOf(observerWrapper), 1);
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Keeps an element visible when aria-hiding is active.
|
|
108
|
+
* Used for elements like live regions that should remain accessible.
|
|
109
|
+
*/
|
|
110
|
+
function keepVisible(element) {
|
|
111
|
+
const observer = observerStack[observerStack.length - 1];
|
|
112
|
+
if (observer && !observer.visibleNodes.has(element)) {
|
|
113
|
+
observer.visibleNodes.add(element);
|
|
114
|
+
return () => {
|
|
115
|
+
observer.visibleNodes.delete(element);
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
//#endregion
|
|
120
|
+
export { keepVisible as n, ariaHideOutside as t };
|
|
121
|
+
|
|
122
|
+
//# sourceMappingURL=ariaHideOutside.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ariaHideOutside.js","names":[],"sources":["../../src/overlays/ariaHideOutside.ts"],"sourcesContent":["/**\n * Hides all elements in the DOM outside the given targets from screen readers.\n * Based on @react-aria/overlays ariaHideOutside.\n */\n\nimport { getOwnerWindow } from \"../utils\";\n\nconst supportsInert = typeof HTMLElement !== \"undefined\" && \"inert\" in HTMLElement.prototype;\n\nexport interface AriaHideOutsideOptions {\n /** The root element to start hiding from. */\n root?: Element;\n /** Whether to use the `inert` attribute instead of `aria-hidden`. */\n shouldUseInert?: boolean;\n}\n\n// Keeps a ref count of all hidden elements. Added to when hiding an element, and\n// subtracted from when showing it again. When it reaches zero, aria-hidden is removed.\nconst refCountMap = new WeakMap<Element, number>();\n\ninterface ObserverWrapper {\n visibleNodes: Set<Element>;\n hiddenNodes: Set<Element>;\n observe: () => void;\n disconnect: () => void;\n}\n\nconst observerStack: ObserverWrapper[] = [];\n\n/**\n * Hides all elements in the DOM outside the given targets from screen readers using aria-hidden,\n * and returns a function to revert these changes. In addition, changes to the DOM are watched\n * and new elements outside the targets are automatically hidden.\n * @param targets - The elements that should remain visible.\n * @param options - Options for hiding behavior.\n * @returns - A function to restore all hidden elements.\n */\nexport function ariaHideOutside(\n targets: Element[],\n options?: AriaHideOutsideOptions | Element,\n): () => void {\n const windowObj = getOwnerWindow(targets?.[0]);\n const opts = options instanceof windowObj.Element ? { root: options } : options;\n const root = opts?.root ?? document.body;\n const shouldUseInert = opts?.shouldUseInert && supportsInert;\n const visibleNodes = new Set<Element>(targets);\n const hiddenNodes = new Set<Element>();\n\n const getHidden = (element: Element): boolean => {\n return shouldUseInert && element instanceof windowObj.HTMLElement\n ? element.inert\n : element.getAttribute(\"aria-hidden\") === \"true\";\n };\n\n const setHidden = (element: Element, hidden: boolean): void => {\n if (shouldUseInert && element instanceof windowObj.HTMLElement) {\n element.inert = hidden;\n } else if (hidden) {\n element.setAttribute(\"aria-hidden\", \"true\");\n } else {\n element.removeAttribute(\"aria-hidden\");\n if (element instanceof windowObj.HTMLElement) {\n // We only ever call setHidden with hidden = false when the nodeCount is 1 aka\n // we are trying to make the element visible to screen readers again, so remove inert as well\n element.inert = false;\n }\n }\n };\n\n const hide = (node: Element): void => {\n let refCount = refCountMap.get(node) ?? 0;\n\n // If already aria-hidden, and the ref count is zero, then this element\n // was already hidden and there's nothing for us to do.\n if (getHidden(node) && refCount === 0) {\n return;\n }\n\n if (refCount === 0) {\n setHidden(node, true);\n }\n\n hiddenNodes.add(node);\n refCountMap.set(node, refCount + 1);\n };\n\n const walk = (walkRoot: Element): void => {\n // Keep live announcer and top layer elements (e.g. toasts) visible.\n for (const element of walkRoot.querySelectorAll(\n \"[data-live-announcer], [data-solidaria-top-layer]\",\n )) {\n visibleNodes.add(element);\n }\n\n const acceptNode = (node: Element): number => {\n // Skip this node and its children if it is one of the target nodes, or a live announcer.\n // Also skip children of already hidden nodes, as aria-hidden is recursive. An exception is\n // made for elements with role=\"row\" since VoiceOver on iOS has issues hiding elements with role=\"row\".\n // For that case we want to hide the cells inside as well (https://bugs.webkit.org/show_bug.cgi?id=222623).\n if (\n hiddenNodes.has(node) ||\n visibleNodes.has(node) ||\n (node.parentElement &&\n hiddenNodes.has(node.parentElement) &&\n node.parentElement.getAttribute(\"role\") !== \"row\")\n ) {\n return NodeFilter.FILTER_REJECT;\n }\n\n // Skip this node but continue to children if one of the targets is inside the node.\n for (const target of visibleNodes) {\n if (node.contains(target)) {\n return NodeFilter.FILTER_SKIP;\n }\n }\n\n return NodeFilter.FILTER_ACCEPT;\n };\n\n const walker = document.createTreeWalker(walkRoot, NodeFilter.SHOW_ELEMENT, { acceptNode });\n\n // TreeWalker does not include the root.\n const acceptRoot = acceptNode(walkRoot);\n if (acceptRoot === NodeFilter.FILTER_ACCEPT) {\n hide(walkRoot);\n }\n\n if (acceptRoot !== NodeFilter.FILTER_REJECT) {\n let node = walker.nextNode() as Element;\n while (node != null) {\n hide(node);\n node = walker.nextNode() as Element;\n }\n }\n };\n\n // If there is already a MutationObserver listening from a previous call,\n // disconnect it so the new one takes over.\n if (observerStack.length) {\n observerStack[observerStack.length - 1].disconnect();\n }\n\n walk(root);\n\n const observer = new MutationObserver((changes) => {\n for (const change of changes) {\n if (change.type !== \"childList\") {\n continue;\n }\n\n // If the parent element of the added nodes is not within one of the targets,\n // and not already inside a hidden node, hide all of the new children.\n if (![...visibleNodes, ...hiddenNodes].some((node) => node.contains(change.target))) {\n for (const node of change.addedNodes) {\n if (\n (node instanceof HTMLElement || node instanceof SVGElement) &&\n (node.dataset.liveAnnouncer === \"true\" || node.dataset.solidariaTopLayer === \"true\")\n ) {\n visibleNodes.add(node);\n } else if (node instanceof Element) {\n walk(node);\n }\n }\n }\n }\n });\n\n observer.observe(root, { childList: true, subtree: true });\n\n const observerWrapper: ObserverWrapper = {\n visibleNodes,\n hiddenNodes,\n observe() {\n observer.observe(root, { childList: true, subtree: true });\n },\n disconnect() {\n observer.disconnect();\n },\n };\n\n observerStack.push(observerWrapper);\n\n return (): void => {\n observer.disconnect();\n\n for (const node of hiddenNodes) {\n const count = refCountMap.get(node);\n if (count == null) {\n continue;\n }\n if (count === 1) {\n setHidden(node, false);\n refCountMap.delete(node);\n } else {\n refCountMap.set(node, count - 1);\n }\n }\n\n // Remove this observer from the stack, and start the previous one.\n if (observerWrapper === observerStack[observerStack.length - 1]) {\n observerStack.pop();\n if (observerStack.length) {\n observerStack[observerStack.length - 1].observe();\n }\n } else {\n observerStack.splice(observerStack.indexOf(observerWrapper), 1);\n }\n };\n}\n\n/**\n * Keeps an element visible when aria-hiding is active.\n * Used for elements like live regions that should remain accessible.\n */\nexport function keepVisible(element: Element): (() => void) | undefined {\n const observer = observerStack[observerStack.length - 1];\n if (observer && !observer.visibleNodes.has(element)) {\n observer.visibleNodes.add(element);\n return () => {\n observer.visibleNodes.delete(element);\n };\n }\n}\n"],"mappings":";;;;;;AAOA,MAAM,gBAAgB,OAAO,gBAAgB,eAAe,WAAW,YAAY;AAWnF,MAAM,8BAAc,IAAI,QAAyB;AASjD,MAAM,gBAAmC,CAAC;;;;;;;;;AAU1C,SAAgB,gBACd,SACA,SACY;CACZ,MAAM,YAAY,eAAe,UAAU,EAAE;CAC7C,MAAM,OAAO,mBAAmB,UAAU,UAAU,EAAE,MAAM,QAAQ,IA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