@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,122 @@
|
|
|
1
|
+
import { c as getOwnerWindow } from "./focus.jsx";
|
|
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.jsx.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ariaHideOutside.jsx","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,IAAI;CACxE,MAAM,OAAO,MAAM,QAAQ,SAAS;CACpC,MAAM,iBAAiB,MAAM,kBAAkB;CAC/C,MAAM,eAAe,IAAI,IAAa,OAAO;CAC7C,MAAM,8BAAc,IAAI,IAAa;CAErC,MAAM,aAAa,YAA8B;EAC/C,OAAO,kBAAkB,mBAAmB,UAAU,cAClD,QAAQ,QACR,QAAQ,aAAa,aAAa,MAAM;CAC9C;CAEA,MAAM,aAAa,SAAkB,WAA0B;EAC7D,IAAI,kBAAkB,mBAAmB,UAAU,aACjD,QAAQ,QAAQ;OACX,IAAI,QACT,QAAQ,aAAa,eAAe,MAAM;OACrC;GACL,QAAQ,gBAAgB,aAAa;GACrC,IAAI,mBAAmB,UAAU,aAG/B,QAAQ,QAAQ;EAEpB;CACF;CAEA,MAAM,QAAQ,SAAwB;EACpC,IAAI,W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BAAsB,SAE7E,aAAa,IAAI,IAAI;SAChB,IAAI,gBAAgB,SACzB,KAAK,IAAI;GAAA;EAIjB;CACF,CAAC;CAED,SAAS,QAAQ,MAAM;EAAE,WAAW;EAAM,SAAS;CAAK,CAAC;CAEzD,MAAM,kBAAmC;EACvC;EACA;EACA,UAAU;GACR,SAAS,QAAQ,MAAM;IAAE,WAAW;IAAM,SAAS;GAAK,CAAC;EAC3D;EACA,aAAa;GACX,SAAS,WAAW;EACtB;CACF;CAEA,cAAc,KAAK,eAAe;CAElC,aAAmB;EACjB,SAAS,WAAW;EAEpB,KAAK,MAAM,QAAQ,aAAa;GAC9B,MAAM,QAAQ,YAAY,IAAI,IAAI;GAClC,IAAI,SAAS,MACX;GAEF,IAAI,UAAU,GAAG;IACf,UAAU,MAAM,KAAK;IACrB,YAAY,OAAO,IAAI;GACzB,OACE,YAAY,IAAI,MAAM,QAAQ,CAAC;EAEnC;EAGA,IAAI,oBAAoB,cAAc,cAAc,SAAS,IAAI;GAC/D,cAAc,IAAI;GAClB,IAAI,cAAc,QAChB,cAAc,cAAc,SAAS,EAAE,CAAC,QAAQ;EAEpD,OACE,cAAc,OAAO,cAAc,QAAQ,eAAe,GAAG,CAAC;CAElE;AACF;;;;;AAMA,SAAgB,YAAY,SAA4C;CACtE,MAAM,WAAW,cAAc,cAAc,SAAS;CACtD,IAAI,YAAY,CAAC,SAAS,aAAa,IAAI,OAAO,GAAG;EACnD,SAAS,aAAa,IAAI,OAAO;EACjC,aAAa;GACX,SAAS,aAAa,OAAO,OAAO;EACtC;CACF;AACF"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { createId, getOwnerDocument } from "../ssr/index.js";
|
|
2
|
+
import { createEffect, createSignal, onCleanup } from "solid-js";
|
|
3
|
+
//#region src/autocomplete/createAutocomplete.ts
|
|
4
|
+
/**
|
|
5
|
+
* createAutocomplete - Accessibility hook for autocomplete components
|
|
6
|
+
*
|
|
7
|
+
* Provides keyboard navigation, virtual focus via aria-activedescendant,
|
|
8
|
+
* and filtering capabilities for autocomplete inputs.
|
|
9
|
+
*
|
|
10
|
+
* Based on @react-aria/autocomplete useAutocomplete.
|
|
11
|
+
*/
|
|
12
|
+
function toKeyboardEventInit(e) {
|
|
13
|
+
return {
|
|
14
|
+
key: e.key,
|
|
15
|
+
code: e.code,
|
|
16
|
+
location: e.location,
|
|
17
|
+
repeat: e.repeat,
|
|
18
|
+
isComposing: e.isComposing,
|
|
19
|
+
ctrlKey: e.ctrlKey,
|
|
20
|
+
shiftKey: e.shiftKey,
|
|
21
|
+
altKey: e.altKey,
|
|
22
|
+
metaKey: e.metaKey,
|
|
23
|
+
bubbles: e.bubbles,
|
|
24
|
+
cancelable: e.cancelable
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const AUTOCOMPLETE_FOCUS_EVENT = "autocomplete:focus";
|
|
28
|
+
const AUTOCOMPLETE_CLEAR_FOCUS_EVENT = "autocomplete:clearfocus";
|
|
29
|
+
/**
|
|
30
|
+
* Provides the behavior and accessibility implementation for an autocomplete component.
|
|
31
|
+
* An autocomplete combines a text input with a collection, allowing users to filter
|
|
32
|
+
* the collection's contents to match a query.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```tsx
|
|
36
|
+
* const state = createAutocompleteState({ defaultInputValue: '' });
|
|
37
|
+
* let inputRef, collectionRef;
|
|
38
|
+
*
|
|
39
|
+
* const { inputProps, collectionProps, filter } = createAutocomplete({
|
|
40
|
+
* inputRef: () => inputRef,
|
|
41
|
+
* collectionRef: () => collectionRef,
|
|
42
|
+
* filter: (textValue, inputValue) =>
|
|
43
|
+
* textValue.toLowerCase().includes(inputValue.toLowerCase()),
|
|
44
|
+
* }, state);
|
|
45
|
+
*
|
|
46
|
+
* return (
|
|
47
|
+
* <div>
|
|
48
|
+
* <input ref={inputRef} {...inputProps} />
|
|
49
|
+
* <ul ref={collectionRef} {...collectionProps}>
|
|
50
|
+
* {items.filter(item => filter?.(item.name) ?? true).map(item => (
|
|
51
|
+
* <li key={item.id}>{item.name}</li>
|
|
52
|
+
* ))}
|
|
53
|
+
* </ul>
|
|
54
|
+
* </div>
|
|
55
|
+
* );
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
function createAutocomplete(props, state) {
|
|
59
|
+
const { inputRef, collectionRef, filter, collectionId: collectionIdProp, collectionAriaLabel, disableAutoFocusFirst = false, disableVirtualFocus = false } = props;
|
|
60
|
+
const collectionId = collectionIdProp ?? createId();
|
|
61
|
+
const [shouldUseVirtualFocus] = createSignal(!disableVirtualFocus);
|
|
62
|
+
const [autoFocusOnMount, setAutoFocusOnMount] = createSignal(false);
|
|
63
|
+
let lastInputType = "";
|
|
64
|
+
const handleBeforeInput = (e) => {
|
|
65
|
+
lastInputType = e.inputType || "";
|
|
66
|
+
};
|
|
67
|
+
createEffect(() => {
|
|
68
|
+
const input = inputRef();
|
|
69
|
+
if (input) {
|
|
70
|
+
input.addEventListener("beforeinput", handleBeforeInput);
|
|
71
|
+
onCleanup(() => {
|
|
72
|
+
input.removeEventListener("beforeinput", handleBeforeInput);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
const focusFirstItem = () => {
|
|
77
|
+
const collection = collectionRef();
|
|
78
|
+
if (!collection) {
|
|
79
|
+
setAutoFocusOnMount(true);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
collection.dispatchEvent(new CustomEvent(AUTOCOMPLETE_FOCUS_EVENT, {
|
|
83
|
+
cancelable: true,
|
|
84
|
+
bubbles: true,
|
|
85
|
+
detail: { focusStrategy: "first" }
|
|
86
|
+
}));
|
|
87
|
+
};
|
|
88
|
+
const clearVirtualFocus = (clearFocusKey = false) => {
|
|
89
|
+
setAutoFocusOnMount(false);
|
|
90
|
+
state.setFocusedNodeId(null);
|
|
91
|
+
const collection = collectionRef();
|
|
92
|
+
if (collection) collection.dispatchEvent(new CustomEvent(AUTOCOMPLETE_CLEAR_FOCUS_EVENT, {
|
|
93
|
+
cancelable: true,
|
|
94
|
+
bubbles: true,
|
|
95
|
+
detail: { clearFocusKey }
|
|
96
|
+
}));
|
|
97
|
+
};
|
|
98
|
+
const onChange = (value) => {
|
|
99
|
+
if ((lastInputType === "insertText" || lastInputType === "insertCompositionText" || lastInputType === "insertFromComposition") && !disableAutoFocusFirst) focusFirstItem();
|
|
100
|
+
else if (lastInputType && (lastInputType.includes("insert") || lastInputType.includes("delete") || lastInputType.includes("history"))) clearVirtualFocus(true);
|
|
101
|
+
state.setInputValue(value);
|
|
102
|
+
};
|
|
103
|
+
const onKeyDown = (e) => {
|
|
104
|
+
if ("isComposing" in e && e.isComposing) return;
|
|
105
|
+
const focusedNodeId = state.focusedNodeId();
|
|
106
|
+
const collection = collectionRef();
|
|
107
|
+
const ownerDocument = getOwnerDocument(inputRef() ?? collection);
|
|
108
|
+
switch (e.key) {
|
|
109
|
+
case "Escape":
|
|
110
|
+
if (e.defaultPrevented) return;
|
|
111
|
+
break;
|
|
112
|
+
case " ": return;
|
|
113
|
+
case "Tab": return;
|
|
114
|
+
case "ArrowUp":
|
|
115
|
+
case "ArrowDown":
|
|
116
|
+
case "Home":
|
|
117
|
+
case "End":
|
|
118
|
+
case "PageUp":
|
|
119
|
+
case "PageDown":
|
|
120
|
+
e.preventDefault();
|
|
121
|
+
if (collection) collection.dispatchEvent(new CustomEvent(AUTOCOMPLETE_FOCUS_EVENT, {
|
|
122
|
+
cancelable: true,
|
|
123
|
+
bubbles: true
|
|
124
|
+
}));
|
|
125
|
+
break;
|
|
126
|
+
case "ArrowLeft":
|
|
127
|
+
case "ArrowRight":
|
|
128
|
+
if (!focusedNodeId) {
|
|
129
|
+
e.stopPropagation();
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
break;
|
|
133
|
+
case "Enter":
|
|
134
|
+
if (focusedNodeId) {
|
|
135
|
+
const item = ownerDocument?.getElementById(focusedNodeId);
|
|
136
|
+
if (item) {
|
|
137
|
+
item.click();
|
|
138
|
+
e.preventDefault();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (!e.defaultPrevented && collection) {
|
|
144
|
+
e.stopPropagation();
|
|
145
|
+
let shouldPerformDefaultAction = true;
|
|
146
|
+
if (focusedNodeId) {
|
|
147
|
+
const item = ownerDocument?.getElementById(focusedNodeId);
|
|
148
|
+
if (item) shouldPerformDefaultAction = item.dispatchEvent(new KeyboardEvent(e.type, toKeyboardEventInit(e)));
|
|
149
|
+
} else shouldPerformDefaultAction = collection.dispatchEvent(new KeyboardEvent(e.type, toKeyboardEventInit(e)));
|
|
150
|
+
if (shouldPerformDefaultAction && (e.key === "ArrowLeft" || e.key === "ArrowRight")) clearVirtualFocus();
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
const onFocus = (e) => {
|
|
154
|
+
if (!e.isTrusted) return;
|
|
155
|
+
const focusedNodeId = state.focusedNodeId();
|
|
156
|
+
if (focusedNodeId) {
|
|
157
|
+
if (document.getElementById(focusedNodeId)) {}
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
const onBlur = (e) => {
|
|
161
|
+
if (!e.isTrusted) return;
|
|
162
|
+
};
|
|
163
|
+
const filterFn = filter ? (textValue) => filter(textValue, state.inputValue()) : void 0;
|
|
164
|
+
return {
|
|
165
|
+
inputProps: {
|
|
166
|
+
value: state.inputValue,
|
|
167
|
+
onChange,
|
|
168
|
+
onKeyDown,
|
|
169
|
+
onFocus,
|
|
170
|
+
onBlur,
|
|
171
|
+
get "aria-activedescendant"() {
|
|
172
|
+
return () => shouldUseVirtualFocus() ? state.focusedNodeId() ?? void 0 : void 0;
|
|
173
|
+
},
|
|
174
|
+
"aria-controls": collectionId,
|
|
175
|
+
"aria-autocomplete": "list",
|
|
176
|
+
enterKeyHint: "go",
|
|
177
|
+
autoCorrect: "off",
|
|
178
|
+
spellCheck: "false",
|
|
179
|
+
autoComplete: "off"
|
|
180
|
+
},
|
|
181
|
+
collectionProps: {
|
|
182
|
+
id: collectionId,
|
|
183
|
+
"aria-label": collectionAriaLabel,
|
|
184
|
+
shouldUseVirtualFocus: shouldUseVirtualFocus(),
|
|
185
|
+
disallowTypeAhead: shouldUseVirtualFocus(),
|
|
186
|
+
get autoFocus() {
|
|
187
|
+
return autoFocusOnMount() ? "first" : false;
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
filter: filterFn
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
//#endregion
|
|
194
|
+
export { AUTOCOMPLETE_FOCUS_EVENT as n, createAutocomplete as r, AUTOCOMPLETE_CLEAR_FOCUS_EVENT as t };
|
|
195
|
+
|
|
196
|
+
//# sourceMappingURL=autocomplete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autocomplete.js","names":["inputEvent"],"sources":["../../src/autocomplete/createAutocomplete.ts"],"sourcesContent":["/**\n * createAutocomplete - Accessibility hook for autocomplete components\n *\n * Provides keyboard navigation, virtual focus via aria-activedescendant,\n * and filtering capabilities for autocomplete inputs.\n *\n * Based on @react-aria/autocomplete useAutocomplete.\n */\n\nimport { createSignal, createEffect, onCleanup, type Accessor } from \"solid-js\";\nimport { createId, getOwnerDocument } from \"../ssr\";\nimport { type AutocompleteState } from \"@proyecto-viviana/solid-stately\";\n\nexport interface CollectionOptions {\n /** The id of the collection element. */\n id?: string;\n /** Accessible label for the collection. */\n \"aria-label\"?: string;\n /** Whether the collection items should use virtual focus instead of being focused directly. */\n shouldUseVirtualFocus: boolean;\n /** Whether typeahead is disabled. */\n disallowTypeAhead: boolean;\n /** Whether and where to focus an item when the collection mounts. */\n autoFocus?: boolean | \"first\" | \"last\";\n}\n\nexport interface AutocompleteInputProps {\n /** Current input value. */\n value: Accessor<string>;\n /** Handler for input value changes. */\n onChange: (value: string) => void;\n /** Handler for key events. */\n onKeyDown: (e: KeyboardEvent) => void;\n /** Handler for focus events. */\n onFocus: (e: FocusEvent) => void;\n /** Handler for blur events. */\n onBlur: (e: FocusEvent) => void;\n /** The id of the currently focused item for aria-activedescendant. */\n \"aria-activedescendant\": Accessor<string | undefined>;\n /** The id of the controlled collection. */\n \"aria-controls\": string;\n /** Autocomplete type. */\n \"aria-autocomplete\": \"list\" | \"none\" | \"inline\" | \"both\";\n /** Enter key hint for mobile keyboards. */\n enterKeyHint: \"go\";\n /** Disable autocorrect. */\n autoCorrect: \"off\";\n /** Disable spell check. */\n spellCheck: \"false\";\n /** Disable browser autocomplete. */\n autoComplete: \"off\";\n}\n\nexport interface AriaAutocompleteOptions<_T = unknown> {\n /** Ref accessor for the input element. */\n inputRef: Accessor<HTMLInputElement | undefined>;\n /** Ref accessor for the collection element. */\n collectionRef: Accessor<HTMLElement | undefined>;\n /** Optional id override for the controlled collection element. */\n collectionId?: string;\n /** Optional accessible name for the controlled collection element. */\n collectionAriaLabel?: string;\n /**\n * An optional filter function used to determine if an option should be included.\n * @param textValue - The text value of the item\n * @param inputValue - The current input value\n */\n filter?: (textValue: string, inputValue: string) => boolean;\n /**\n * Whether to focus the first item after filtering.\n * @default false\n */\n disableAutoFocusFirst?: boolean;\n /**\n * Whether to disable virtual focus (aria-activedescendant).\n * @default false\n */\n disableVirtualFocus?: boolean;\n}\n\nexport interface AutocompleteAria<_T = unknown> {\n /** Props for the autocomplete input element. */\n inputProps: AutocompleteInputProps;\n /** Props for the collection (ListBox/Menu). */\n collectionProps: CollectionOptions;\n /** A filter function that returns if the item should be shown. */\n filter?: (textValue: string) => boolean;\n}\n\nfunction toKeyboardEventInit(e: KeyboardEvent): KeyboardEventInit {\n return {\n key: e.key,\n code: e.code,\n location: e.location,\n repeat: e.repeat,\n isComposing: e.isComposing,\n ctrlKey: e.ctrlKey,\n shiftKey: e.shiftKey,\n altKey: e.altKey,\n metaKey: e.metaKey,\n bubbles: e.bubbles,\n cancelable: e.cancelable,\n };\n}\n\n// Custom event names for collection communication\nexport const AUTOCOMPLETE_FOCUS_EVENT = \"autocomplete:focus\";\nexport const AUTOCOMPLETE_CLEAR_FOCUS_EVENT = \"autocomplete:clearfocus\";\n\n/**\n * Provides the behavior and accessibility implementation for an autocomplete component.\n * An autocomplete combines a text input with a collection, allowing users to filter\n * the collection's contents to match a query.\n *\n * @example\n * ```tsx\n * const state = createAutocompleteState({ defaultInputValue: '' });\n * let inputRef, collectionRef;\n *\n * const { inputProps, collectionProps, filter } = createAutocomplete({\n * inputRef: () => inputRef,\n * collectionRef: () => collectionRef,\n * filter: (textValue, inputValue) =>\n * textValue.toLowerCase().includes(inputValue.toLowerCase()),\n * }, state);\n *\n * return (\n * <div>\n * <input ref={inputRef} {...inputProps} />\n * <ul ref={collectionRef} {...collectionProps}>\n * {items.filter(item => filter?.(item.name) ?? true).map(item => (\n * <li key={item.id}>{item.name}</li>\n * ))}\n * </ul>\n * </div>\n * );\n * ```\n */\nexport function createAutocomplete<T = unknown>(\n props: AriaAutocompleteOptions<T>,\n state: AutocompleteState,\n): AutocompleteAria<T> {\n const {\n inputRef,\n collectionRef,\n filter,\n collectionId: collectionIdProp,\n collectionAriaLabel,\n disableAutoFocusFirst = false,\n disableVirtualFocus = false,\n } = props;\n\n const collectionId = collectionIdProp ?? createId();\n const [shouldUseVirtualFocus] = createSignal(!disableVirtualFocus);\n // When the first item should be focused but the collection hasn't mounted yet,\n // defer it by threading autoFocus through collectionProps so the collection\n // focuses on mount (mirrors upstream's autoFocusOnMount state).\n const [autoFocusOnMount, setAutoFocusOnMount] = createSignal(false);\n let lastInputType = \"\";\n\n // Track the input type for determining focus behavior. We listen to\n // `beforeinput` (not `input`) so `lastInputType` is set before the input's\n // `onChange` runs, mirroring @react-aria/autocomplete.\n const handleBeforeInput = (e: Event) => {\n const inputEvent = e as InputEvent;\n lastInputType = inputEvent.inputType || \"\";\n };\n\n // Set up beforeinput event listener\n createEffect(() => {\n const input = inputRef();\n if (input) {\n input.addEventListener(\"beforeinput\", handleBeforeInput);\n onCleanup(() => {\n input.removeEventListener(\"beforeinput\", handleBeforeInput);\n });\n }\n });\n\n // Focus first item in collection\n const focusFirstItem = () => {\n const collection = collectionRef();\n if (!collection) {\n // Collection isn't mounted yet — defer focusing the first item to mount\n // time via collectionProps.autoFocus instead of firing a focus event into\n // a not-yet-rendered collection.\n setAutoFocusOnMount(true);\n return;\n }\n collection.dispatchEvent(\n new CustomEvent(AUTOCOMPLETE_FOCUS_EVENT, {\n cancelable: true,\n bubbles: true,\n detail: { focusStrategy: \"first\" },\n }),\n );\n };\n\n // Clear virtual focus\n const clearVirtualFocus = (clearFocusKey = false) => {\n setAutoFocusOnMount(false);\n state.setFocusedNodeId(null);\n const collection = collectionRef();\n if (collection) {\n collection.dispatchEvent(\n new CustomEvent(AUTOCOMPLETE_CLEAR_FOCUS_EVENT, {\n cancelable: true,\n bubbles: true,\n detail: { clearFocusKey },\n }),\n );\n }\n };\n\n // Handle input value changes\n const onChange = (value: string) => {\n // Focus first item when typing forward, clear when backspacing/pasting.\n // IME composition (e.g. CJK input) reports 'insertCompositionText'/\n // 'insertFromComposition' instead of 'insertText'; treat those as forward\n // typing so the first item still gets virtual focus.\n if (\n (lastInputType === \"insertText\" ||\n lastInputType === \"insertCompositionText\" ||\n lastInputType === \"insertFromComposition\") &&\n !disableAutoFocusFirst\n ) {\n focusFirstItem();\n } else if (\n lastInputType &&\n (lastInputType.includes(\"insert\") ||\n lastInputType.includes(\"delete\") ||\n lastInputType.includes(\"history\"))\n ) {\n clearVirtualFocus(true);\n }\n\n state.setInputValue(value);\n };\n\n // Handle keyboard navigation\n const onKeyDown = (e: KeyboardEvent) => {\n if (\"isComposing\" in e && e.isComposing) {\n return;\n }\n\n const focusedNodeId = state.focusedNodeId();\n const collection = collectionRef();\n const ownerDocument = getOwnerDocument(inputRef() ?? collection);\n\n switch (e.key) {\n case \"Escape\":\n // Let the input handle Escape (e.g., clear value)\n if (e.defaultPrevented) {\n return;\n }\n break;\n\n case \" \":\n // Space shouldn't trigger item action\n return;\n\n case \"Tab\":\n // Let Tab propagate normally for focus management\n return;\n\n case \"ArrowUp\":\n case \"ArrowDown\":\n case \"Home\":\n case \"End\":\n case \"PageUp\":\n case \"PageDown\": {\n // Prevent cursor movement in input\n e.preventDefault();\n\n // Dispatch focus event to collection\n if (collection) {\n collection.dispatchEvent(\n new CustomEvent(AUTOCOMPLETE_FOCUS_EVENT, {\n cancelable: true,\n bubbles: true,\n }),\n );\n }\n break;\n }\n\n case \"ArrowLeft\":\n case \"ArrowRight\":\n // With no virtual focus, just let the arrow move the text cursor; stop\n // propagation so it doesn't leak into the collection. With virtual focus,\n // fall through to dispatch the key to the focused item below, then clear\n // the active descendant only after the item has seen it.\n if (!focusedNodeId) {\n e.stopPropagation();\n return;\n }\n break;\n\n case \"Enter\":\n // Trigger click on focused item\n if (focusedNodeId) {\n const item = ownerDocument?.getElementById(focusedNodeId);\n if (item) {\n item.click();\n e.preventDefault();\n }\n }\n return;\n }\n\n // Forward keyboard events to the focused item (or the collection when there\n // is no virtual focus) so the collection can act on them, e.g. onAction.\n if (!e.defaultPrevented && collection) {\n e.stopPropagation();\n\n let shouldPerformDefaultAction = true;\n if (focusedNodeId) {\n const item = ownerDocument?.getElementById(focusedNodeId);\n if (item) {\n shouldPerformDefaultAction = item.dispatchEvent(\n new KeyboardEvent(e.type, toKeyboardEventInit(e)),\n );\n }\n } else {\n shouldPerformDefaultAction = collection.dispatchEvent(\n new KeyboardEvent(e.type, toKeyboardEventInit(e)),\n );\n }\n\n // After the focused item has seen ArrowLeft/ArrowRight, clear the active\n // descendant so SR announcements aren't interrupted, but retain the\n // collection's focused key so navigation restarts where it left off. If\n // the item consumed the key (e.g. an expandable row collapsing), it\n // cancels the event and we keep virtual focus.\n if (shouldPerformDefaultAction && (e.key === \"ArrowLeft\" || e.key === \"ArrowRight\")) {\n clearVirtualFocus();\n }\n }\n };\n\n // Handle focus events\n const onFocus = (e: FocusEvent) => {\n if (!e.isTrusted) return;\n\n // Restore virtual focus when refocusing input\n const focusedNodeId = state.focusedNodeId();\n if (focusedNodeId) {\n const item = document.getElementById(focusedNodeId);\n if (item) {\n // Item still exists, keep focus on it\n }\n }\n };\n\n const onBlur = (e: FocusEvent) => {\n if (!e.isTrusted) return;\n // Virtual focus blur handling would go here\n };\n\n // Create filter function\n const filterFn = filter\n ? (textValue: string) => filter(textValue, state.inputValue())\n : undefined;\n\n return {\n inputProps: {\n value: state.inputValue,\n onChange,\n onKeyDown,\n onFocus,\n onBlur,\n get \"aria-activedescendant\"() {\n return () => (shouldUseVirtualFocus() ? (state.focusedNodeId() ?? undefined) : undefined);\n },\n \"aria-controls\": collectionId,\n \"aria-autocomplete\": \"list\",\n enterKeyHint: \"go\",\n autoCorrect: \"off\",\n spellCheck: \"false\",\n autoComplete: \"off\",\n },\n collectionProps: {\n id: collectionId,\n \"aria-label\": collectionAriaLabel,\n shouldUseVirtualFocus: shouldUseVirtualFocus(),\n disallowTypeAhead: shouldUseVirtualFocus(),\n get autoFocus() {\n return autoFocusOnMount() ? \"first\" : false;\n },\n },\n filter: filterFn,\n };\n}\n"],"mappings":";;;;;;;;;;;AAyFA,SAAS,oBAAoB,GAAqC;CAChE,OAAO;EACL,KAAK,EAAE;EACP,MAAM,EAAE;EACR,UAAU,EAAE;EACZ,QAAQ,EAAE;EACV,aAAa,EAAE;EACf,SAAS,EAAE;EACX,UAAU,EAAE;EACZ,QAAQ,EAAE;EACV,SAAS,EAAE;EACX,SAAS,EAAE;EACX,YAAY,EAAE;CAChB;AACF;AAGA,MAAa,2BAA2B;AACxC,MAAa,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+B9C,SAAgB,mBACd,OACA,OACqB;CACrB,MAAM,EACJ,UACA,eACA,QACA,cAAc,kBACd,qBACA,wBAAwB,OACxB,sBAAsB,UACpB;CAEJ,MAAM,eAAe,oBAAoB,SAAS;CAClD,MAAM,CAAC,yBAAyB,aAAa,CAAC,mBAAmB;CAIjE,MAAM,CAAC,kBAAkB,uBAAuB,aAAa,KAAK;CAClE,IAAI,gBAAgB;CAKp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AY;GACZ,cAAc;EAChB;EACA,iBAAiB;GACf,IAAI;GACJ,cAAc;GACd,uBAAuB,sBAAsB;GAC7C,mBAAmB,sBAAsB;GACzC,IAAI,YAAY;IACd,OAAO,iBAAiB,IAAI,UAAU;GACxC;EACF;EACA,QAAQ;CACV;AACF"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { createId, getOwnerDocument } from "../ssr/index.jsx";
|
|
2
|
+
import { createEffect, createSignal, onCleanup } from "solid-js";
|
|
3
|
+
//#region src/autocomplete/createAutocomplete.ts
|
|
4
|
+
/**
|
|
5
|
+
* createAutocomplete - Accessibility hook for autocomplete components
|
|
6
|
+
*
|
|
7
|
+
* Provides keyboard navigation, virtual focus via aria-activedescendant,
|
|
8
|
+
* and filtering capabilities for autocomplete inputs.
|
|
9
|
+
*
|
|
10
|
+
* Based on @react-aria/autocomplete useAutocomplete.
|
|
11
|
+
*/
|
|
12
|
+
function toKeyboardEventInit(e) {
|
|
13
|
+
return {
|
|
14
|
+
key: e.key,
|
|
15
|
+
code: e.code,
|
|
16
|
+
location: e.location,
|
|
17
|
+
repeat: e.repeat,
|
|
18
|
+
isComposing: e.isComposing,
|
|
19
|
+
ctrlKey: e.ctrlKey,
|
|
20
|
+
shiftKey: e.shiftKey,
|
|
21
|
+
altKey: e.altKey,
|
|
22
|
+
metaKey: e.metaKey,
|
|
23
|
+
bubbles: e.bubbles,
|
|
24
|
+
cancelable: e.cancelable
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const AUTOCOMPLETE_FOCUS_EVENT = "autocomplete:focus";
|
|
28
|
+
const AUTOCOMPLETE_CLEAR_FOCUS_EVENT = "autocomplete:clearfocus";
|
|
29
|
+
/**
|
|
30
|
+
* Provides the behavior and accessibility implementation for an autocomplete component.
|
|
31
|
+
* An autocomplete combines a text input with a collection, allowing users to filter
|
|
32
|
+
* the collection's contents to match a query.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```tsx
|
|
36
|
+
* const state = createAutocompleteState({ defaultInputValue: '' });
|
|
37
|
+
* let inputRef, collectionRef;
|
|
38
|
+
*
|
|
39
|
+
* const { inputProps, collectionProps, filter } = createAutocomplete({
|
|
40
|
+
* inputRef: () => inputRef,
|
|
41
|
+
* collectionRef: () => collectionRef,
|
|
42
|
+
* filter: (textValue, inputValue) =>
|
|
43
|
+
* textValue.toLowerCase().includes(inputValue.toLowerCase()),
|
|
44
|
+
* }, state);
|
|
45
|
+
*
|
|
46
|
+
* return (
|
|
47
|
+
* <div>
|
|
48
|
+
* <input ref={inputRef} {...inputProps} />
|
|
49
|
+
* <ul ref={collectionRef} {...collectionProps}>
|
|
50
|
+
* {items.filter(item => filter?.(item.name) ?? true).map(item => (
|
|
51
|
+
* <li key={item.id}>{item.name}</li>
|
|
52
|
+
* ))}
|
|
53
|
+
* </ul>
|
|
54
|
+
* </div>
|
|
55
|
+
* );
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
function createAutocomplete(props, state) {
|
|
59
|
+
const { inputRef, collectionRef, filter, collectionId: collectionIdProp, collectionAriaLabel, disableAutoFocusFirst = false, disableVirtualFocus = false } = props;
|
|
60
|
+
const collectionId = collectionIdProp ?? createId();
|
|
61
|
+
const [shouldUseVirtualFocus] = createSignal(!disableVirtualFocus);
|
|
62
|
+
const [autoFocusOnMount, setAutoFocusOnMount] = createSignal(false);
|
|
63
|
+
let lastInputType = "";
|
|
64
|
+
const handleBeforeInput = (e) => {
|
|
65
|
+
lastInputType = e.inputType || "";
|
|
66
|
+
};
|
|
67
|
+
createEffect(() => {
|
|
68
|
+
const input = inputRef();
|
|
69
|
+
if (input) {
|
|
70
|
+
input.addEventListener("beforeinput", handleBeforeInput);
|
|
71
|
+
onCleanup(() => {
|
|
72
|
+
input.removeEventListener("beforeinput", handleBeforeInput);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
const focusFirstItem = () => {
|
|
77
|
+
const collection = collectionRef();
|
|
78
|
+
if (!collection) {
|
|
79
|
+
setAutoFocusOnMount(true);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
collection.dispatchEvent(new CustomEvent(AUTOCOMPLETE_FOCUS_EVENT, {
|
|
83
|
+
cancelable: true,
|
|
84
|
+
bubbles: true,
|
|
85
|
+
detail: { focusStrategy: "first" }
|
|
86
|
+
}));
|
|
87
|
+
};
|
|
88
|
+
const clearVirtualFocus = (clearFocusKey = false) => {
|
|
89
|
+
setAutoFocusOnMount(false);
|
|
90
|
+
state.setFocusedNodeId(null);
|
|
91
|
+
const collection = collectionRef();
|
|
92
|
+
if (collection) collection.dispatchEvent(new CustomEvent(AUTOCOMPLETE_CLEAR_FOCUS_EVENT, {
|
|
93
|
+
cancelable: true,
|
|
94
|
+
bubbles: true,
|
|
95
|
+
detail: { clearFocusKey }
|
|
96
|
+
}));
|
|
97
|
+
};
|
|
98
|
+
const onChange = (value) => {
|
|
99
|
+
if ((lastInputType === "insertText" || lastInputType === "insertCompositionText" || lastInputType === "insertFromComposition") && !disableAutoFocusFirst) focusFirstItem();
|
|
100
|
+
else if (lastInputType && (lastInputType.includes("insert") || lastInputType.includes("delete") || lastInputType.includes("history"))) clearVirtualFocus(true);
|
|
101
|
+
state.setInputValue(value);
|
|
102
|
+
};
|
|
103
|
+
const onKeyDown = (e) => {
|
|
104
|
+
if ("isComposing" in e && e.isComposing) return;
|
|
105
|
+
const focusedNodeId = state.focusedNodeId();
|
|
106
|
+
const collection = collectionRef();
|
|
107
|
+
const ownerDocument = getOwnerDocument(inputRef() ?? collection);
|
|
108
|
+
switch (e.key) {
|
|
109
|
+
case "Escape":
|
|
110
|
+
if (e.defaultPrevented) return;
|
|
111
|
+
break;
|
|
112
|
+
case " ": return;
|
|
113
|
+
case "Tab": return;
|
|
114
|
+
case "ArrowUp":
|
|
115
|
+
case "ArrowDown":
|
|
116
|
+
case "Home":
|
|
117
|
+
case "End":
|
|
118
|
+
case "PageUp":
|
|
119
|
+
case "PageDown":
|
|
120
|
+
e.preventDefault();
|
|
121
|
+
if (collection) collection.dispatchEvent(new CustomEvent(AUTOCOMPLETE_FOCUS_EVENT, {
|
|
122
|
+
cancelable: true,
|
|
123
|
+
bubbles: true
|
|
124
|
+
}));
|
|
125
|
+
break;
|
|
126
|
+
case "ArrowLeft":
|
|
127
|
+
case "ArrowRight":
|
|
128
|
+
if (!focusedNodeId) {
|
|
129
|
+
e.stopPropagation();
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
break;
|
|
133
|
+
case "Enter":
|
|
134
|
+
if (focusedNodeId) {
|
|
135
|
+
const item = ownerDocument?.getElementById(focusedNodeId);
|
|
136
|
+
if (item) {
|
|
137
|
+
item.click();
|
|
138
|
+
e.preventDefault();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (!e.defaultPrevented && collection) {
|
|
144
|
+
e.stopPropagation();
|
|
145
|
+
let shouldPerformDefaultAction = true;
|
|
146
|
+
if (focusedNodeId) {
|
|
147
|
+
const item = ownerDocument?.getElementById(focusedNodeId);
|
|
148
|
+
if (item) shouldPerformDefaultAction = item.dispatchEvent(new KeyboardEvent(e.type, toKeyboardEventInit(e)));
|
|
149
|
+
} else shouldPerformDefaultAction = collection.dispatchEvent(new KeyboardEvent(e.type, toKeyboardEventInit(e)));
|
|
150
|
+
if (shouldPerformDefaultAction && (e.key === "ArrowLeft" || e.key === "ArrowRight")) clearVirtualFocus();
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
const onFocus = (e) => {
|
|
154
|
+
if (!e.isTrusted) return;
|
|
155
|
+
const focusedNodeId = state.focusedNodeId();
|
|
156
|
+
if (focusedNodeId) {
|
|
157
|
+
if (document.getElementById(focusedNodeId)) {}
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
const onBlur = (e) => {
|
|
161
|
+
if (!e.isTrusted) return;
|
|
162
|
+
};
|
|
163
|
+
const filterFn = filter ? (textValue) => filter(textValue, state.inputValue()) : void 0;
|
|
164
|
+
return {
|
|
165
|
+
inputProps: {
|
|
166
|
+
value: state.inputValue,
|
|
167
|
+
onChange,
|
|
168
|
+
onKeyDown,
|
|
169
|
+
onFocus,
|
|
170
|
+
onBlur,
|
|
171
|
+
get "aria-activedescendant"() {
|
|
172
|
+
return () => shouldUseVirtualFocus() ? state.focusedNodeId() ?? void 0 : void 0;
|
|
173
|
+
},
|
|
174
|
+
"aria-controls": collectionId,
|
|
175
|
+
"aria-autocomplete": "list",
|
|
176
|
+
enterKeyHint: "go",
|
|
177
|
+
autoCorrect: "off",
|
|
178
|
+
spellCheck: "false",
|
|
179
|
+
autoComplete: "off"
|
|
180
|
+
},
|
|
181
|
+
collectionProps: {
|
|
182
|
+
id: collectionId,
|
|
183
|
+
"aria-label": collectionAriaLabel,
|
|
184
|
+
shouldUseVirtualFocus: shouldUseVirtualFocus(),
|
|
185
|
+
disallowTypeAhead: shouldUseVirtualFocus(),
|
|
186
|
+
get autoFocus() {
|
|
187
|
+
return autoFocusOnMount() ? "first" : false;
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
filter: filterFn
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
//#endregion
|
|
194
|
+
export { AUTOCOMPLETE_FOCUS_EVENT as n, createAutocomplete as r, AUTOCOMPLETE_CLEAR_FOCUS_EVENT as t };
|
|
195
|
+
|
|
196
|
+
//# sourceMappingURL=autocomplete.jsx.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autocomplete.jsx","names":["inputEvent"],"sources":["../../src/autocomplete/createAutocomplete.ts"],"sourcesContent":["/**\n * createAutocomplete - Accessibility hook for autocomplete components\n *\n * Provides keyboard navigation, virtual focus via aria-activedescendant,\n * and filtering capabilities for autocomplete inputs.\n *\n * Based on @react-aria/autocomplete useAutocomplete.\n */\n\nimport { createSignal, createEffect, onCleanup, type Accessor } from \"solid-js\";\nimport { createId, getOwnerDocument } from \"../ssr\";\nimport { type AutocompleteState } from \"@proyecto-viviana/solid-stately\";\n\nexport interface CollectionOptions {\n /** The id of the collection element. */\n id?: string;\n /** Accessible label for the collection. */\n \"aria-label\"?: string;\n /** Whether the collection items should use virtual focus instead of being focused directly. */\n shouldUseVirtualFocus: boolean;\n /** Whether typeahead is disabled. */\n disallowTypeAhead: boolean;\n /** Whether and where to focus an item when the collection mounts. */\n autoFocus?: boolean | \"first\" | \"last\";\n}\n\nexport interface AutocompleteInputProps {\n /** Current input value. */\n value: Accessor<string>;\n /** Handler for input value changes. */\n onChange: (value: string) => void;\n /** Handler for key events. */\n onKeyDown: (e: KeyboardEvent) => void;\n /** Handler for focus events. */\n onFocus: (e: FocusEvent) => void;\n /** Handler for blur events. */\n onBlur: (e: FocusEvent) => void;\n /** The id of the currently focused item for aria-activedescendant. */\n \"aria-activedescendant\": Accessor<string | undefined>;\n /** The id of the controlled collection. */\n \"aria-controls\": string;\n /** Autocomplete type. */\n \"aria-autocomplete\": \"list\" | \"none\" | \"inline\" | \"both\";\n /** Enter key hint for mobile keyboards. */\n enterKeyHint: \"go\";\n /** Disable autocorrect. */\n autoCorrect: \"off\";\n /** Disable spell check. */\n spellCheck: \"false\";\n /** Disable browser autocomplete. */\n autoComplete: \"off\";\n}\n\nexport interface AriaAutocompleteOptions<_T = unknown> {\n /** Ref accessor for the input element. */\n inputRef: Accessor<HTMLInputElement | undefined>;\n /** Ref accessor for the collection element. */\n collectionRef: Accessor<HTMLElement | undefined>;\n /** Optional id override for the controlled collection element. */\n collectionId?: string;\n /** Optional accessible name for the controlled collection element. */\n collectionAriaLabel?: string;\n /**\n * An optional filter function used to determine if an option should be included.\n * @param textValue - The text value of the item\n * @param inputValue - The current input value\n */\n filter?: (textValue: string, inputValue: string) => boolean;\n /**\n * Whether to focus the first item after filtering.\n * @default false\n */\n disableAutoFocusFirst?: boolean;\n /**\n * Whether to disable virtual focus (aria-activedescendant).\n * @default false\n */\n disableVirtualFocus?: boolean;\n}\n\nexport interface AutocompleteAria<_T = unknown> {\n /** Props for the autocomplete input element. */\n inputProps: AutocompleteInputProps;\n /** Props for the collection (ListBox/Menu). */\n collectionProps: CollectionOptions;\n /** A filter function that returns if the item should be shown. */\n filter?: (textValue: string) => boolean;\n}\n\nfunction toKeyboardEventInit(e: KeyboardEvent): KeyboardEventInit {\n return {\n key: e.key,\n code: e.code,\n location: e.location,\n repeat: e.repeat,\n isComposing: e.isComposing,\n ctrlKey: e.ctrlKey,\n shiftKey: e.shiftKey,\n altKey: e.altKey,\n metaKey: e.metaKey,\n bubbles: e.bubbles,\n cancelable: e.cancelable,\n };\n}\n\n// Custom event names for collection communication\nexport const AUTOCOMPLETE_FOCUS_EVENT = \"autocomplete:focus\";\nexport const AUTOCOMPLETE_CLEAR_FOCUS_EVENT = \"autocomplete:clearfocus\";\n\n/**\n * Provides the behavior and accessibility implementation for an autocomplete component.\n * An autocomplete combines a text input with a collection, allowing users to filter\n * the collection's contents to match a query.\n *\n * @example\n * ```tsx\n * const state = createAutocompleteState({ defaultInputValue: '' });\n * let inputRef, collectionRef;\n *\n * const { inputProps, collectionProps, filter } = createAutocomplete({\n * inputRef: () => inputRef,\n * collectionRef: () => collectionRef,\n * filter: (textValue, inputValue) =>\n * textValue.toLowerCase().includes(inputValue.toLowerCase()),\n * }, state);\n *\n * return (\n * <div>\n * <input ref={inputRef} {...inputProps} />\n * <ul ref={collectionRef} {...collectionProps}>\n * {items.filter(item => filter?.(item.name) ?? true).map(item => (\n * <li key={item.id}>{item.name}</li>\n * ))}\n * </ul>\n * </div>\n * );\n * ```\n */\nexport function createAutocomplete<T = unknown>(\n props: AriaAutocompleteOptions<T>,\n state: AutocompleteState,\n): AutocompleteAria<T> {\n const {\n inputRef,\n collectionRef,\n filter,\n collectionId: collectionIdProp,\n collectionAriaLabel,\n disableAutoFocusFirst = false,\n disableVirtualFocus = false,\n } = props;\n\n const collectionId = collectionIdProp ?? createId();\n const [shouldUseVirtualFocus] = createSignal(!disableVirtualFocus);\n // When the first item should be focused but the collection hasn't mounted yet,\n // defer it by threading autoFocus through collectionProps so the collection\n // focuses on mount (mirrors upstream's autoFocusOnMount state).\n const [autoFocusOnMount, setAutoFocusOnMount] = createSignal(false);\n let lastInputType = \"\";\n\n // Track the input type for determining focus behavior. We listen to\n // `beforeinput` (not `input`) so `lastInputType` is set before the input's\n // `onChange` runs, mirroring @react-aria/autocomplete.\n const handleBeforeInput = (e: Event) => {\n const inputEvent = e as InputEvent;\n lastInputType = inputEvent.inputType || \"\";\n };\n\n // Set up beforeinput event listener\n createEffect(() => {\n const input = inputRef();\n if (input) {\n input.addEventListener(\"beforeinput\", handleBeforeInput);\n onCleanup(() => {\n input.removeEventListener(\"beforeinput\", handleBeforeInput);\n });\n }\n });\n\n // Focus first item in collection\n const focusFirstItem = () => {\n const collection = collectionRef();\n if (!collection) {\n // Collection isn't mounted yet — defer focusing the first item to mount\n // time via collectionProps.autoFocus instead of firing a focus event into\n // a not-yet-rendered collection.\n setAutoFocusOnMount(true);\n return;\n }\n collection.dispatchEvent(\n new CustomEvent(AUTOCOMPLETE_FOCUS_EVENT, {\n cancelable: true,\n bubbles: true,\n detail: { focusStrategy: \"first\" },\n }),\n );\n };\n\n // Clear virtual focus\n const clearVirtualFocus = (clearFocusKey = false) => {\n setAutoFocusOnMount(false);\n state.setFocusedNodeId(null);\n const collection = collectionRef();\n if (collection) {\n collection.dispatchEvent(\n new CustomEvent(AUTOCOMPLETE_CLEAR_FOCUS_EVENT, {\n cancelable: true,\n bubbles: true,\n detail: { clearFocusKey },\n }),\n );\n }\n };\n\n // Handle input value changes\n const onChange = (value: string) => {\n // Focus first item when typing forward, clear when backspacing/pasting.\n // IME composition (e.g. CJK input) reports 'insertCompositionText'/\n // 'insertFromComposition' instead of 'insertText'; treat those as forward\n // typing so the first item still gets virtual focus.\n if (\n (lastInputType === \"insertText\" ||\n lastInputType === \"insertCompositionText\" ||\n lastInputType === \"insertFromComposition\") &&\n !disableAutoFocusFirst\n ) {\n focusFirstItem();\n } else if (\n lastInputType &&\n (lastInputType.includes(\"insert\") ||\n lastInputType.includes(\"delete\") ||\n lastInputType.includes(\"history\"))\n ) {\n clearVirtualFocus(true);\n }\n\n state.setInputValue(value);\n };\n\n // Handle keyboard navigation\n const onKeyDown = (e: KeyboardEvent) => {\n if (\"isComposing\" in e && e.isComposing) {\n return;\n }\n\n const focusedNodeId = state.focusedNodeId();\n const collection = collectionRef();\n const ownerDocument = getOwnerDocument(inputRef() ?? collection);\n\n switch (e.key) {\n case \"Escape\":\n // Let the input handle Escape (e.g., clear value)\n if (e.defaultPrevented) {\n return;\n }\n break;\n\n case \" \":\n // Space shouldn't trigger item action\n return;\n\n case \"Tab\":\n // Let Tab propagate normally for focus management\n return;\n\n case \"ArrowUp\":\n case \"ArrowDown\":\n case \"Home\":\n case \"End\":\n case \"PageUp\":\n case \"PageDown\": {\n // Prevent cursor movement in input\n e.preventDefault();\n\n // Dispatch focus event to collection\n if (collection) {\n collection.dispatchEvent(\n new CustomEvent(AUTOCOMPLETE_FOCUS_EVENT, {\n cancelable: true,\n bubbles: true,\n }),\n );\n }\n break;\n }\n\n case \"ArrowLeft\":\n case \"ArrowRight\":\n // With no virtual focus, just let the arrow move the text cursor; stop\n // propagation so it doesn't leak into the collection. With virtual focus,\n // fall through to dispatch the key to the focused item below, then clear\n // the active descendant only after the item has seen it.\n if (!focusedNodeId) {\n e.stopPropagation();\n return;\n }\n break;\n\n case \"Enter\":\n // Trigger click on focused item\n if (focusedNodeId) {\n const item = ownerDocument?.getElementById(focusedNodeId);\n if (item) {\n item.click();\n e.preventDefault();\n }\n }\n return;\n }\n\n // Forward keyboard events to the focused item (or the collection when there\n // is no virtual focus) so the collection can act on them, e.g. onAction.\n if (!e.defaultPrevented && collection) {\n e.stopPropagation();\n\n let shouldPerformDefaultAction = true;\n if (focusedNodeId) {\n const item = ownerDocument?.getElementById(focusedNodeId);\n if (item) {\n shouldPerformDefaultAction = item.dispatchEvent(\n new KeyboardEvent(e.type, toKeyboardEventInit(e)),\n );\n }\n } else {\n shouldPerformDefaultAction = collection.dispatchEvent(\n new KeyboardEvent(e.type, toKeyboardEventInit(e)),\n );\n }\n\n // After the focused item has seen ArrowLeft/ArrowRight, clear the active\n // descendant so SR announcements aren't interrupted, but retain the\n // collection's focused key so navigation restarts where it left off. If\n // the item consumed the key (e.g. an expandable row collapsing), it\n // cancels the event and we keep virtual focus.\n if (shouldPerformDefaultAction && (e.key === \"ArrowLeft\" || e.key === \"ArrowRight\")) {\n clearVirtualFocus();\n }\n }\n };\n\n // Handle focus events\n const onFocus = (e: FocusEvent) => {\n if (!e.isTrusted) return;\n\n // Restore virtual focus when refocusing input\n const focusedNodeId = state.focusedNodeId();\n if (focusedNodeId) {\n const item = document.getElementById(focusedNodeId);\n if (item) {\n // Item still exists, keep focus on it\n }\n }\n };\n\n const onBlur = (e: FocusEvent) => {\n if (!e.isTrusted) return;\n // Virtual focus blur handling would go here\n };\n\n // Create filter function\n const filterFn = filter\n ? (textValue: string) => filter(textValue, state.inputValue())\n : undefined;\n\n return {\n inputProps: {\n value: state.inputValue,\n onChange,\n onKeyDown,\n onFocus,\n onBlur,\n get \"aria-activedescendant\"() {\n return () => (shouldUseVirtualFocus() ? (state.focusedNodeId() ?? undefined) : undefined);\n },\n \"aria-controls\": collectionId,\n \"aria-autocomplete\": \"list\",\n enterKeyHint: \"go\",\n autoCorrect: \"off\",\n spellCheck: \"false\",\n autoComplete: \"off\",\n },\n collectionProps: {\n id: collectionId,\n \"aria-label\": collectionAriaLabel,\n shouldUseVirtualFocus: shouldUseVirtualFocus(),\n disallowTypeAhead: shouldUseVirtualFocus(),\n get autoFocus() {\n return autoFocusOnMount() ? \"first\" : false;\n },\n },\n filter: filterFn,\n };\n}\n"],"mappings":";;;;;;;;;;;AAyFA,SAAS,oBAAoB,GAAqC;CAChE,OAAO;EACL,KAAK,EAAE;EACP,MAAM,EAAE;EACR,UAAU,EAAE;EACZ,QAAQ,EAAE;EACV,aAAa,EAAE;EACf,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