@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,158 @@
|
|
|
1
|
+
import { t as createPress } from "./createPress.jsx";
|
|
2
|
+
import { i as access, o as mergeProps, t as isDevEnv } from "./env.jsx";
|
|
3
|
+
import { t as filterDOMProps } from "./filterDOMProps.jsx";
|
|
4
|
+
import { n as createFocusable } from "./createFocusable.jsx";
|
|
5
|
+
import { createSlotId } from "../ssr/index.jsx";
|
|
6
|
+
import { createEffect } from "solid-js";
|
|
7
|
+
//#region src/toggle/createToggle.ts
|
|
8
|
+
/**
|
|
9
|
+
* Toggle hook for Solidaria
|
|
10
|
+
*
|
|
11
|
+
* Handles interactions for toggle elements, e.g. Checkboxes and Switches.
|
|
12
|
+
*
|
|
13
|
+
* This is a 1:1 port of @react-aria/toggle's useToggle hook.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Handles interactions for toggle elements, e.g. Checkboxes and Switches.
|
|
17
|
+
*/
|
|
18
|
+
function createToggle(props, state, ref) {
|
|
19
|
+
const getProps = () => access(props);
|
|
20
|
+
const isDisabled = () => getProps().isDisabled ?? false;
|
|
21
|
+
const isReadOnly = () => getProps().isReadOnly ?? false;
|
|
22
|
+
const isInvalid = () => {
|
|
23
|
+
return getProps().isInvalid ?? false;
|
|
24
|
+
};
|
|
25
|
+
const { pressProps, isPressed } = createPress({
|
|
26
|
+
get onPressStart() {
|
|
27
|
+
return getProps().onPressStart;
|
|
28
|
+
},
|
|
29
|
+
get onPressEnd() {
|
|
30
|
+
return getProps().onPressEnd;
|
|
31
|
+
},
|
|
32
|
+
get onPressChange() {
|
|
33
|
+
return getProps().onPressChange;
|
|
34
|
+
},
|
|
35
|
+
get onPress() {
|
|
36
|
+
return getProps().onPress;
|
|
37
|
+
},
|
|
38
|
+
get onPressUp() {
|
|
39
|
+
return getProps().onPressUp;
|
|
40
|
+
},
|
|
41
|
+
get onClick() {
|
|
42
|
+
return getProps().onClick;
|
|
43
|
+
},
|
|
44
|
+
get isDisabled() {
|
|
45
|
+
return isDisabled();
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
const { pressProps: labelPressProps, isPressed: isLabelPressed } = createPress({
|
|
49
|
+
get onPressStart() {
|
|
50
|
+
return getProps().onPressStart;
|
|
51
|
+
},
|
|
52
|
+
get onPressEnd() {
|
|
53
|
+
return getProps().onPressEnd;
|
|
54
|
+
},
|
|
55
|
+
get onPressChange() {
|
|
56
|
+
return getProps().onPressChange;
|
|
57
|
+
},
|
|
58
|
+
get onPressUp() {
|
|
59
|
+
return getProps().onPressUp;
|
|
60
|
+
},
|
|
61
|
+
get onClick() {
|
|
62
|
+
return getProps().onClick;
|
|
63
|
+
},
|
|
64
|
+
onPress(e) {
|
|
65
|
+
getProps().onPress?.(e);
|
|
66
|
+
state.toggle();
|
|
67
|
+
ref()?.focus();
|
|
68
|
+
},
|
|
69
|
+
get isDisabled() {
|
|
70
|
+
return isDisabled() || isReadOnly();
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
const { focusableProps } = createFocusable({
|
|
74
|
+
get isDisabled() {
|
|
75
|
+
return isDisabled();
|
|
76
|
+
},
|
|
77
|
+
get autoFocus() {
|
|
78
|
+
return getProps().autoFocus;
|
|
79
|
+
},
|
|
80
|
+
get onFocus() {
|
|
81
|
+
return getProps().onFocus;
|
|
82
|
+
},
|
|
83
|
+
get onBlur() {
|
|
84
|
+
return getProps().onBlur;
|
|
85
|
+
},
|
|
86
|
+
get onFocusChange() {
|
|
87
|
+
return getProps().onFocusChange;
|
|
88
|
+
},
|
|
89
|
+
get onKeyDown() {
|
|
90
|
+
return getProps().onKeyDown;
|
|
91
|
+
},
|
|
92
|
+
get onKeyUp() {
|
|
93
|
+
return getProps().onKeyUp;
|
|
94
|
+
},
|
|
95
|
+
get excludeFromTabOrder() {
|
|
96
|
+
return getProps().excludeFromTabOrder;
|
|
97
|
+
}
|
|
98
|
+
}, ref);
|
|
99
|
+
const interactions = mergeProps(pressProps, focusableProps);
|
|
100
|
+
const domProps = () => filterDOMProps(getProps(), { labelable: true });
|
|
101
|
+
const onChange = (e) => {
|
|
102
|
+
e.stopPropagation();
|
|
103
|
+
if (isReadOnly()) {
|
|
104
|
+
e.currentTarget.checked = state.isSelected();
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
state.setSelected(e.currentTarget.checked);
|
|
108
|
+
};
|
|
109
|
+
createEffect(() => {
|
|
110
|
+
const p = getProps();
|
|
111
|
+
const hasChildren = p.children != null;
|
|
112
|
+
const hasAriaLabel = p["aria-label"] != null || p["aria-labelledby"] != null;
|
|
113
|
+
if (!hasChildren && !hasAriaLabel && isDevEnv()) console.warn("If you do not provide children, you must specify an aria-label for accessibility");
|
|
114
|
+
});
|
|
115
|
+
const combinedIsPressed = () => isPressed() || isLabelPressed();
|
|
116
|
+
const descriptionId = createSlotId();
|
|
117
|
+
const errorMessageId = createSlotId();
|
|
118
|
+
return {
|
|
119
|
+
labelProps: mergeProps(labelPressProps, { onClick: (e) => e.preventDefault() }),
|
|
120
|
+
get inputProps() {
|
|
121
|
+
const p = getProps();
|
|
122
|
+
return mergeProps(domProps(), {
|
|
123
|
+
"aria-invalid": isInvalid() || void 0,
|
|
124
|
+
"aria-errormessage": p["aria-errormessage"],
|
|
125
|
+
"aria-controls": p["aria-controls"],
|
|
126
|
+
"aria-readonly": isReadOnly() || void 0,
|
|
127
|
+
"aria-describedby": [
|
|
128
|
+
descriptionId(),
|
|
129
|
+
errorMessageId(),
|
|
130
|
+
p["aria-describedby"]
|
|
131
|
+
].filter(Boolean).join(" ") || void 0,
|
|
132
|
+
onChange,
|
|
133
|
+
disabled: isDisabled(),
|
|
134
|
+
...p.value == null ? {} : { value: p.value },
|
|
135
|
+
name: p.name,
|
|
136
|
+
form: p.form,
|
|
137
|
+
type: "checkbox",
|
|
138
|
+
...interactions,
|
|
139
|
+
onClick: (e) => e.stopPropagation()
|
|
140
|
+
});
|
|
141
|
+
},
|
|
142
|
+
get descriptionProps() {
|
|
143
|
+
return { id: descriptionId() };
|
|
144
|
+
},
|
|
145
|
+
get errorMessageProps() {
|
|
146
|
+
return { id: errorMessageId() };
|
|
147
|
+
},
|
|
148
|
+
isSelected: state.isSelected,
|
|
149
|
+
isPressed: combinedIsPressed,
|
|
150
|
+
isDisabled: isDisabled(),
|
|
151
|
+
isReadOnly: isReadOnly(),
|
|
152
|
+
isInvalid: isInvalid()
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
//#endregion
|
|
156
|
+
export { createToggle as t };
|
|
157
|
+
|
|
158
|
+
//# sourceMappingURL=createToggle.jsx.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createToggle.jsx","names":[],"sources":["../../src/toggle/createToggle.ts"],"sourcesContent":["/**\n * Toggle hook for Solidaria\n *\n * Handles interactions for toggle elements, e.g. Checkboxes and Switches.\n *\n * This is a 1:1 port of @react-aria/toggle's useToggle hook.\n */\n\nimport { JSX, Accessor, createEffect } from \"solid-js\";\nimport { createPress } from \"../interactions/createPress\";\nimport { createFocusable } from \"../interactions/createFocusable\";\nimport { mergeProps } from \"../utils/mergeProps\";\nimport { filterDOMProps } from \"../utils/filterDOMProps\";\nimport { type MaybeAccessor, access } from \"../utils/reactivity\";\nimport { isDevEnv } from \"../utils/env\";\nimport { createSlotId } from \"../ssr\";\nimport { type ToggleState } from \"@proyecto-viviana/solid-stately\";\nimport { type PressEvent } from \"../interactions/PressEvent\";\n\nexport interface AriaToggleProps {\n /** Whether the element should be selected (controlled). */\n isSelected?: boolean;\n /** Whether the element should be selected by default (uncontrolled). */\n defaultSelected?: boolean;\n /** Handler that is called when the element's selection state changes. */\n onChange?: (isSelected: boolean) => void;\n /** The value of the input element, used when submitting an HTML form. */\n value?: string;\n /** The name of the input element, used when submitting an HTML form. */\n name?: string;\n /** The form to associate the input with. */\n form?: string;\n /** Whether the element is disabled. */\n isDisabled?: boolean;\n /** Whether the element is read only. */\n isReadOnly?: boolean;\n /** Whether the element is required. */\n isRequired?: boolean;\n /** Whether the element is invalid. */\n isInvalid?: boolean;\n /** The element's children. */\n children?: JSX.Element;\n /** Defines a string value that labels the current element. */\n \"aria-label\"?: string;\n /** Identifies the element (or elements) that labels the current element. */\n \"aria-labelledby\"?: string;\n /** Identifies the element (or elements) that describes the object. */\n \"aria-describedby\"?: string;\n /** Identifies the element (or elements) that provide an error message for the object. */\n \"aria-errormessage\"?: string;\n /** Identifies the element (or elements) whose contents or presence are controlled by the current element. */\n \"aria-controls\"?: string;\n /** The element's unique identifier. */\n id?: string;\n /** Handler that is called when the press is released over the target. */\n onPress?: (e: PressEvent) => void;\n /** Handler that is called when a press interaction starts. */\n onPressStart?: (e: PressEvent) => void;\n /** Handler that is called when a press interaction ends, either over the target or when the pointer leaves the target. */\n onPressEnd?: (e: PressEvent) => void;\n /** Handler that is called when the press state changes. */\n onPressChange?: (isPressed: boolean) => void;\n /** Handler that is called when a press is released over the target, regardless of whether it started on the target or not. */\n onPressUp?: (e: PressEvent) => void;\n /** Handler that is called when the element is clicked. */\n onClick?: (e: MouseEvent) => void;\n /** Handler that is called when the element receives focus. */\n onFocus?: (e: FocusEvent) => void;\n /** Handler that is called when the element loses focus. */\n onBlur?: (e: FocusEvent) => void;\n /** Handler that is called when the element's focus status changes. */\n onFocusChange?: (isFocused: boolean) => void;\n /** Handler that is called when a key is pressed. */\n onKeyDown?: (e: KeyboardEvent) => void;\n /** Handler that is called when a key is released. */\n onKeyUp?: (e: KeyboardEvent) => void;\n /** Whether to exclude the element from the tab order. */\n excludeFromTabOrder?: boolean;\n /** Whether to autofocus the element. */\n autoFocus?: boolean;\n}\n\nexport interface ToggleAria {\n /** Props to be spread on the label element. */\n labelProps: JSX.LabelHTMLAttributes<HTMLLabelElement>;\n /** Props to be spread on the input element. */\n inputProps: JSX.InputHTMLAttributes<HTMLInputElement>;\n /** Props for the description element, if any. */\n descriptionProps: JSX.HTMLAttributes<HTMLElement>;\n /** Props for the error message element, if any. */\n errorMessageProps: JSX.HTMLAttributes<HTMLElement>;\n /** Whether the toggle is selected. */\n isSelected: Accessor<boolean>;\n /** Whether the toggle is in a pressed state. */\n isPressed: Accessor<boolean>;\n /** Whether the toggle is disabled. */\n isDisabled: boolean;\n /** Whether the toggle is read only. */\n isReadOnly: boolean;\n /** Whether the toggle is invalid. */\n isInvalid: boolean;\n}\n\n/**\n * Handles interactions for toggle elements, e.g. Checkboxes and Switches.\n */\nexport function createToggle(\n props: MaybeAccessor<AriaToggleProps>,\n state: ToggleState,\n ref: () => HTMLInputElement | null,\n): ToggleAria {\n const getProps = () => access(props);\n\n const isDisabled = () => getProps().isDisabled ?? false;\n const isReadOnly = () => getProps().isReadOnly ?? false;\n const isInvalid = () => {\n return getProps().isInvalid ?? false;\n };\n\n // Handle press state for keyboard interactions and cases where labelProps is not used.\n const { pressProps, isPressed } = createPress({\n get onPressStart() {\n return getProps().onPressStart;\n },\n get onPressEnd() {\n return getProps().onPressEnd;\n },\n get onPressChange() {\n return getProps().onPressChange;\n },\n get onPress() {\n return getProps().onPress;\n },\n get onPressUp() {\n return getProps().onPressUp;\n },\n get onClick() {\n return getProps().onClick;\n },\n get isDisabled() {\n return isDisabled();\n },\n });\n\n // Handle press state on the label.\n const { pressProps: labelPressProps, isPressed: isLabelPressed } = createPress({\n get onPressStart() {\n return getProps().onPressStart;\n },\n get onPressEnd() {\n return getProps().onPressEnd;\n },\n get onPressChange() {\n return getProps().onPressChange;\n },\n get onPressUp() {\n return getProps().onPressUp;\n },\n get onClick() {\n return getProps().onClick;\n },\n onPress(e: PressEvent) {\n getProps().onPress?.(e);\n state.toggle();\n ref()?.focus();\n },\n get isDisabled() {\n return isDisabled() || isReadOnly();\n },\n });\n\n // Handle focusable - extract the relevant props for createFocusable\n const { focusableProps } = createFocusable(\n {\n get isDisabled() {\n return isDisabled();\n },\n get autoFocus() {\n return getProps().autoFocus;\n },\n get onFocus() {\n return getProps().onFocus;\n },\n get onBlur() {\n return getProps().onBlur;\n },\n get onFocusChange() {\n return getProps().onFocusChange;\n },\n get onKeyDown() {\n return getProps().onKeyDown;\n },\n get onKeyUp() {\n return getProps().onKeyUp;\n },\n get excludeFromTabOrder() {\n return getProps().excludeFromTabOrder;\n },\n },\n ref as unknown as (el: HTMLElement) => void,\n );\n\n // Combine press and focusable props for input\n const interactions = mergeProps(pressProps, focusableProps);\n\n // Filter DOM props\n const domProps = () =>\n filterDOMProps(getProps() as unknown as Record<string, unknown>, { labelable: true });\n\n // Handle input change\n const onChange: JSX.EventHandler<HTMLInputElement, Event> = (e) => {\n // Since we spread props on label, onChange will end up there as well as in here.\n // So we have to stop propagation at the lowest level that we care about\n e.stopPropagation();\n\n // Don't update state if readonly\n if (isReadOnly()) {\n // Reset the checkbox to its previous state since the browser already toggled it\n e.currentTarget.checked = state.isSelected();\n return;\n }\n\n state.setSelected(e.currentTarget.checked);\n };\n\n // Warn if no accessible label\n createEffect(() => {\n const p = getProps();\n const hasChildren = p.children != null;\n const hasAriaLabel = p[\"aria-label\"] != null || p[\"aria-labelledby\"] != null;\n if (!hasChildren && !hasAriaLabel && isDevEnv()) {\n console.warn(\n \"If you do not provide children, you must specify an aria-label for accessibility\",\n );\n }\n });\n\n // Combined pressed state\n const combinedIsPressed: Accessor<boolean> = () => isPressed() || isLabelPressed();\n\n // Mint ids for the description and error message slots. Copied from createField\n // because we don't want the label behavior that provides — the id resolves only\n // once an element with that id is actually rendered (e.g. via TextContext slots).\n const descriptionId = createSlotId();\n const errorMessageId = createSlotId();\n\n return {\n labelProps: mergeProps(labelPressProps, {\n onClick: (e: MouseEvent) => e.preventDefault(),\n }) as JSX.LabelHTMLAttributes<HTMLLabelElement>,\n get inputProps() {\n const p = getProps();\n return mergeProps(domProps(), {\n \"aria-invalid\": isInvalid() || undefined,\n \"aria-errormessage\": p[\"aria-errormessage\"],\n \"aria-controls\": p[\"aria-controls\"],\n \"aria-readonly\": isReadOnly() || undefined,\n \"aria-describedby\":\n [descriptionId(), errorMessageId(), p[\"aria-describedby\"]].filter(Boolean).join(\" \") ||\n undefined,\n onChange,\n disabled: isDisabled(),\n ...(p.value == null ? {} : { value: p.value }),\n name: p.name,\n form: p.form,\n type: \"checkbox\" as const,\n ...interactions,\n // Stop click propagation to prevent labelProps.onClick from calling preventDefault\n // which would prevent the checkbox from toggling in JSDOM/testing-library environments\n onClick: (e: MouseEvent) => e.stopPropagation(),\n }) as JSX.InputHTMLAttributes<HTMLInputElement>;\n },\n get descriptionProps() {\n return { id: descriptionId() };\n },\n get errorMessageProps() {\n return { id: errorMessageId() };\n },\n isSelected: state.isSelected,\n isPressed: combinedIsPressed,\n isDisabled: isDisabled(),\n isReadOnly: isReadOnly(),\n isInvalid: isInvalid(),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA0GA,SAAgB,aACd,OACA,OACA,KACY;CACZ,MAAM,iBAAiB,OAAO,KAAK;CAEnC,MAAM,mBAAmB,SAAS,CAAC,CAAC,cAAc;CAClD,MAAM,mBAAmB,SAAS,CAAC,CAAC,cAAc;CAClD,MAAM,kBAAkB;EACtB,OAAO,SAAS,CAAC,CAAC,aAAa;CACjC;CAGA,MAAM,EAAE,YAAY,cAAc,YAAY;EAC5C,IAAI,eAAe;GACjB,OAAO,SAAS,CAAC,CAAC;EACpB;EACA,IAAI,aAAa;GACf,OAAO,SAAS,CAAC,CAAC;EACpB;EACA,IAAI,gBAAgB;GAClB,OAAO,SAAS,CAAC,CAAC;EACpB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EACvB,YAAY,WAAW;EACvB,WAAW,UAAU;CACvB;AACF"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { t as createCollator } from "./createCollator.js";
|
|
2
|
+
import { onCleanup } from "solid-js";
|
|
3
|
+
//#region src/selection/createTypeSelect.ts
|
|
4
|
+
/**
|
|
5
|
+
* createTypeSelect - Handles typeahead interactions with collections.
|
|
6
|
+
* Based on @react-aria/selection useTypeSelect.
|
|
7
|
+
*
|
|
8
|
+
* Allows users to navigate to items by typing characters that match
|
|
9
|
+
* item text values. Supports multi-character search with debouncing.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Controls how long to wait before clearing the typeahead buffer.
|
|
13
|
+
*/
|
|
14
|
+
const TYPEAHEAD_DEBOUNCE_WAIT_MS = 1e3;
|
|
15
|
+
/**
|
|
16
|
+
* Get a printable character from a key event.
|
|
17
|
+
* Returns the character if it's a single printable character,
|
|
18
|
+
* or empty string for non-printable keys.
|
|
19
|
+
*/
|
|
20
|
+
function getStringForKey(key) {
|
|
21
|
+
if (key.length === 1 || !/^[A-Z]/i.test(key)) return key;
|
|
22
|
+
return "";
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Search for a key in the collection that matches the search string.
|
|
26
|
+
* Starts *at* `fromKey` (inclusive) and scans to the end, with no internal
|
|
27
|
+
* wrap; the caller retries from the top to cover earlier items. Matching is
|
|
28
|
+
* locale-aware via the supplied `collator`.
|
|
29
|
+
*/
|
|
30
|
+
function getKeyForSearch(collection, search, fromKey, collator, isKeyDisabled) {
|
|
31
|
+
const items = [];
|
|
32
|
+
for (const item of collection) if (item.type === "item") items.push(item);
|
|
33
|
+
if (items.length === 0) return null;
|
|
34
|
+
let startIndex = 0;
|
|
35
|
+
if (fromKey != null) {
|
|
36
|
+
const fromIndex = items.findIndex((item) => item.key === fromKey);
|
|
37
|
+
if (fromIndex !== -1) startIndex = fromIndex;
|
|
38
|
+
}
|
|
39
|
+
for (let index = startIndex; index < items.length; index++) {
|
|
40
|
+
const item = items[index];
|
|
41
|
+
if (item.isDisabled || isKeyDisabled && isKeyDisabled(item.key)) continue;
|
|
42
|
+
const textValue = item.textValue || "";
|
|
43
|
+
const substring = textValue.slice(0, search.length);
|
|
44
|
+
if (textValue && collator.compare(substring, search) === 0) return item.key;
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Creates typeahead/type-to-select functionality for a collection.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```tsx
|
|
53
|
+
* const { typeSelectProps } = createTypeSelect({
|
|
54
|
+
* collection: () => state.collection(),
|
|
55
|
+
* focusedKey: () => state.focusedKey(),
|
|
56
|
+
* onFocusedKeyChange: (key) => state.setFocusedKey(key),
|
|
57
|
+
* });
|
|
58
|
+
*
|
|
59
|
+
* return <ul {...mergeProps(listBoxProps, typeSelectProps)}>...</ul>;
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
function createTypeSelect(options) {
|
|
63
|
+
const state = {
|
|
64
|
+
search: "",
|
|
65
|
+
timeout: void 0
|
|
66
|
+
};
|
|
67
|
+
const collator = createCollator({
|
|
68
|
+
usage: "search",
|
|
69
|
+
sensitivity: "base"
|
|
70
|
+
});
|
|
71
|
+
const searchAndFocus = () => {
|
|
72
|
+
const collection = options.collection();
|
|
73
|
+
const currentKey = options.focusedKey();
|
|
74
|
+
let key = getKeyForSearch(collection, state.search, currentKey, collator(), options.isKeyDisabled);
|
|
75
|
+
if (key == null) key = getKeyForSearch(collection, state.search, null, collator(), options.isKeyDisabled);
|
|
76
|
+
if (key != null) {
|
|
77
|
+
options.onFocusedKeyChange(key);
|
|
78
|
+
options.onTypeSelect?.(key);
|
|
79
|
+
}
|
|
80
|
+
return key;
|
|
81
|
+
};
|
|
82
|
+
const restartDebounce = () => {
|
|
83
|
+
clearTimeout(state.timeout);
|
|
84
|
+
state.timeout = setTimeout(() => {
|
|
85
|
+
state.search = "";
|
|
86
|
+
}, TYPEAHEAD_DEBOUNCE_WAIT_MS);
|
|
87
|
+
};
|
|
88
|
+
const onKeyDownCapture = (e) => {
|
|
89
|
+
if (options.isDisabled) return;
|
|
90
|
+
if (state.search.length > 0 && e.key === " ") {
|
|
91
|
+
e.preventDefault();
|
|
92
|
+
e.stopPropagation();
|
|
93
|
+
state.search += " ";
|
|
94
|
+
searchAndFocus();
|
|
95
|
+
restartDebounce();
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const onKeyDown = (e) => {
|
|
99
|
+
if (options.isDisabled) return;
|
|
100
|
+
const character = getStringForKey(e.key);
|
|
101
|
+
if (!character || e.ctrlKey || e.metaKey || e.altKey || !e.currentTarget.contains(e.target) || state.search.length === 0 && character === " ") return;
|
|
102
|
+
state.search += character;
|
|
103
|
+
if (searchAndFocus() != null) {
|
|
104
|
+
e.preventDefault();
|
|
105
|
+
e.stopPropagation();
|
|
106
|
+
} else {
|
|
107
|
+
state.search = "";
|
|
108
|
+
clearTimeout(state.timeout);
|
|
109
|
+
state.timeout = void 0;
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
restartDebounce();
|
|
113
|
+
};
|
|
114
|
+
onCleanup(() => {
|
|
115
|
+
clearTimeout(state.timeout);
|
|
116
|
+
});
|
|
117
|
+
return { typeSelectProps: {
|
|
118
|
+
onKeyDownCapture,
|
|
119
|
+
onKeyDown
|
|
120
|
+
} };
|
|
121
|
+
}
|
|
122
|
+
//#endregion
|
|
123
|
+
export { createTypeSelect as t };
|
|
124
|
+
|
|
125
|
+
//# sourceMappingURL=createTypeSelect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createTypeSelect.js","names":[],"sources":["../../src/selection/createTypeSelect.ts"],"sourcesContent":["/**\n * createTypeSelect - Handles typeahead interactions with collections.\n * Based on @react-aria/selection useTypeSelect.\n *\n * Allows users to navigate to items by typing characters that match\n * item text values. Supports multi-character search with debouncing.\n */\n\nimport { onCleanup } from \"solid-js\";\nimport type { JSX, Accessor } from \"solid-js\";\nimport type { Key, Collection, CollectionNode } from \"@proyecto-viviana/solid-stately\";\nimport { createCollator } from \"../i18n/createCollator\";\n\n/**\n * Controls how long to wait before clearing the typeahead buffer.\n */\nconst TYPEAHEAD_DEBOUNCE_WAIT_MS = 1000; // 1 second\n\nexport interface TypeSelectOptions<T> {\n /** The collection to search through. */\n collection: Accessor<Collection<T>>;\n /** The currently focused key. */\n focusedKey: Accessor<Key | null>;\n /** Callback to set the focused key when a match is found. */\n onFocusedKeyChange: (key: Key) => void;\n /** Callback when an item is focused by typing. */\n onTypeSelect?: (key: Key) => void;\n /** Function to check if a key is disabled. */\n isKeyDisabled?: (key: Key) => boolean;\n /** Whether type-to-select is disabled. */\n isDisabled?: boolean;\n}\n\nexport interface TypeSelectAria {\n /** Props to spread on the collection element. */\n typeSelectProps: JSX.HTMLAttributes<HTMLElement>;\n}\n\n// Internal state for tracking the search buffer\ninterface TypeSelectState {\n search: string;\n timeout: ReturnType<typeof setTimeout> | undefined;\n}\n\n/**\n * Get a printable character from a key event.\n * Returns the character if it's a single printable character,\n * or empty string for non-printable keys.\n */\nfunction getStringForKey(key: string): string {\n // If the key is of length 1, it is an ASCII value.\n // Otherwise, if there are no ASCII characters in the key name,\n // it is a Unicode character.\n // See https://www.w3.org/TR/uievents-key/\n if (key.length === 1 || !/^[A-Z]/i.test(key)) {\n return key;\n }\n return \"\";\n}\n\n/**\n * Search for a key in the collection that matches the search string.\n * Starts *at* `fromKey` (inclusive) and scans to the end, with no internal\n * wrap; the caller retries from the top to cover earlier items. Matching is\n * locale-aware via the supplied `collator`.\n */\nfunction getKeyForSearch<T>(\n collection: Collection<T>,\n search: string,\n fromKey: Key | null,\n collator: Intl.Collator,\n isKeyDisabled?: (key: Key) => boolean,\n): Key | null {\n // Collect all items in order\n const items: CollectionNode<T>[] = [];\n for (const item of collection) {\n if (item.type === \"item\") {\n items.push(item);\n }\n }\n\n if (items.length === 0) return null;\n\n // Find the starting index. Start *at* the currently focused item (inclusive),\n // mirroring upstream ListKeyboardDelegate.getKeyForSearch (`key = fromKey ||\n // getFirstKey()`): typing a prefix the focused item already matches keeps focus\n // on it instead of advancing to the next match.\n let startIndex = 0;\n if (fromKey != null) {\n const fromIndex = items.findIndex((item) => item.key === fromKey);\n if (fromIndex !== -1) {\n startIndex = fromIndex;\n }\n }\n\n // Scan from startIndex to the end (no wrap). The caller retries from the top to\n // cover items before the focused one, matching upstream useTypeSelect.\n for (let index = startIndex; index < items.length; index++) {\n const item = items[index];\n\n // Skip disabled items\n if (item.isDisabled || (isKeyDisabled && isKeyDisabled(item.key))) {\n continue;\n }\n\n // Match the leading characters of the text value against the search string\n // using locale-aware collation, mirroring upstream ListKeyboardDelegate\n // (`collator.compare(textValue.slice(0, search.length), search) === 0`). The\n // collator's `usage: 'search'` / `sensitivity: 'base'` makes this case- and\n // diacritic-insensitive in a locale-aware way.\n const textValue = item.textValue || \"\";\n const substring = textValue.slice(0, search.length);\n if (textValue && collator.compare(substring, search) === 0) {\n return item.key;\n }\n }\n\n return null;\n}\n\n/**\n * Creates typeahead/type-to-select functionality for a collection.\n *\n * @example\n * ```tsx\n * const { typeSelectProps } = createTypeSelect({\n * collection: () => state.collection(),\n * focusedKey: () => state.focusedKey(),\n * onFocusedKeyChange: (key) => state.setFocusedKey(key),\n * });\n *\n * return <ul {...mergeProps(listBoxProps, typeSelectProps)}>...</ul>;\n * ```\n */\nexport function createTypeSelect<T>(options: TypeSelectOptions<T>): TypeSelectAria {\n // Create mutable state object to persist across keystrokes\n const state: TypeSelectState = {\n search: \"\",\n timeout: undefined,\n };\n\n // Locale-aware search collator, mirroring upstream useSelectableList's\n // `useCollator({ usage: 'search', sensitivity: 'base' })`.\n const collator = createCollator({ usage: \"search\", sensitivity: \"base\" });\n\n // Append the search buffer, find a matching key (from the focused item,\n // falling back to the whole list), focus it, and (re)start the debounce timer.\n // Shared by both phase handlers below, mirroring the duplicated body in\n // upstream useTypeSelect.\n const searchAndFocus = (): Key | null => {\n const collection = options.collection();\n const currentKey = options.focusedKey();\n\n // Prioritize items at/after the focused item, then retry from the top to\n // cover earlier ones (upstream's two getKeyForSearch calls).\n let key = getKeyForSearch(\n collection,\n state.search,\n currentKey,\n collator(),\n options.isKeyDisabled,\n );\n if (key == null) {\n key = getKeyForSearch(collection, state.search, null, collator(), options.isKeyDisabled);\n }\n\n if (key != null) {\n options.onFocusedKeyChange(key);\n options.onTypeSelect?.(key);\n }\n\n return key;\n };\n\n const restartDebounce = () => {\n clearTimeout(state.timeout);\n state.timeout = setTimeout(() => {\n state.search = \"\";\n }, TYPEAHEAD_DEBOUNCE_WAIT_MS);\n };\n\n // Capture phase: mid-search a Spacebar is part of the query, not a selection\n // action, so we consume it before the collection's own keydown handler can act\n // on it. Mirrors upstream useTypeSelect's onKeyDownCapture.\n const onKeyDownCapture: JSX.EventHandler<HTMLElement, KeyboardEvent> = (e) => {\n if (options.isDisabled) return;\n\n if (state.search.length > 0 && e.key === \" \") {\n e.preventDefault();\n // Upstream guards this with `!('continuePropagation' in e) ||\n // !e.isPropagationStopped()`. Our raw DOM KeyboardEvents never carry\n // `continuePropagation`, so the guard always holds — stop unconditionally.\n e.stopPropagation();\n state.search += \" \";\n searchAndFocus();\n restartDebounce();\n }\n };\n\n // Bubble phase: handles ordinary characters (and, in environments where the\n // capture listener above is inert, mid-search Spacebar via its non-bailing\n // branch). Mirrors upstream useTypeSelect's onKeyDown.\n const onKeyDown: JSX.EventHandler<HTMLElement, KeyboardEvent> = (e) => {\n if (options.isDisabled) return;\n\n const character = getStringForKey(e.key);\n\n // Ignore non-printable keys, Ctrl/Meta/Alt combos (Alt is excluded to match\n // upstream — AltGr-only layouts shouldn't drive type-select), events from\n // outside the element, and a leading Space (a common action key).\n if (\n !character ||\n e.ctrlKey ||\n e.metaKey ||\n e.altKey ||\n !e.currentTarget.contains(e.target as HTMLElement) ||\n (state.search.length === 0 && character === \" \")\n ) {\n return;\n }\n\n state.search += character;\n\n const key = searchAndFocus();\n\n if (key != null) {\n e.preventDefault();\n // Our raw DOM events never carry `continuePropagation`, so upstream's\n // `if (!('continuePropagation' in e)) e.stopPropagation()` is unconditional.\n e.stopPropagation();\n } else {\n // Nothing matched even after retrying from the top: type-to-select is done,\n // so reset the buffer and let the key propagate normally.\n state.search = \"\";\n clearTimeout(state.timeout);\n state.timeout = undefined;\n return;\n }\n\n restartDebounce();\n };\n\n // Mirror upstream's unmount cleanup (a useEffect teardown) so a pending\n // debounce timer never fires after the consumer is disposed.\n onCleanup(() => {\n clearTimeout(state.timeout);\n });\n\n return {\n typeSelectProps: {\n // Upstream binds `onKeyDownCapture` so Spacebar is handled before the\n // collection's own keydown handler. In Solid a capture handler delivered\n // through a `{...typeSelectProps}` spread is inert (it never fires), so the\n // bubble-phase `onKeyDown` is the live path — and it also covers mid-search\n // Space because its bail check only rejects a *leading* Space. True capture\n // would need a ref-based addEventListener threaded through every consumer;\n // see the typeahead follow-up in upstream-sync.md.\n onKeyDownCapture,\n onKeyDown,\n } as JSX.HTMLAttributes<HTMLElement>,\n };\n}\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAM,6BAA6B;;;;;;AAiCnC,SAAS,gBAAgB,KAAqB;CAK5C,IAAI,IAAI,WAAW,KAAK,CAAC,UAAU,KAAK,GAAG,GACzC,OAAO;CAET,OAAO;AACT;;;;;;;AAQA,SAAS,gBACP,YACA,QACA,SACA,UACA,eACY;CAEZ,MAAM,QAA6B,CAAC;CACpC,KAAK,MAAM,QAAQ,YACjB,IAAI,KAAK,SAAS,QAChB,MAAM,KAAK,IAAI;CAInB,IAAI,MAAM,WAAW,GAAG,OAAO;CAM/B,IAAI,aAAa;CACjB,IAAI,WAAW,MAAM;EACnB,MAAM,YAAY,MAAM,WAAW,SAAS,KAAK,QAAQ,OAAO;EAChE,IAAI,cAAc,IAChB,aAAa;CAEjB;CAIA,KAAK,IAAI,QAAQ,YAAY,QAAQ,MAAM,QAAQ,SAAS;EAC1D,M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Ac,SAAS,EAAE,MAAqB,KAChD,MAAM,OAAO,WAAW,KAAK,cAAc,KAE5C;EAGF,MAAM,UAAU;EAIhB,IAFY,eAEN,KAAK,MAAM;GACf,EAAE,eAAe;GAGjB,EAAE,gBAAgB;EACpB,OAAO;GAGL,MAAM,SAAS;GACf,aAAa,MAAM,OAAO;GAC1B,MAAM,UAAU,KAAA;GAChB;EACF;EAEA,gBAAgB;CAClB;CAIA,gBAAgB;EACd,aAAa,MAAM,OAAO;CAC5B,CAAC;CAED,OAAO,EACL,iBAAiB;EAQf;EACA;CACF,EACF;AACF"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { t as createCollator } from "./createCollator.jsx";
|
|
2
|
+
import { onCleanup } from "solid-js";
|
|
3
|
+
//#region src/selection/createTypeSelect.ts
|
|
4
|
+
/**
|
|
5
|
+
* createTypeSelect - Handles typeahead interactions with collections.
|
|
6
|
+
* Based on @react-aria/selection useTypeSelect.
|
|
7
|
+
*
|
|
8
|
+
* Allows users to navigate to items by typing characters that match
|
|
9
|
+
* item text values. Supports multi-character search with debouncing.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Controls how long to wait before clearing the typeahead buffer.
|
|
13
|
+
*/
|
|
14
|
+
const TYPEAHEAD_DEBOUNCE_WAIT_MS = 1e3;
|
|
15
|
+
/**
|
|
16
|
+
* Get a printable character from a key event.
|
|
17
|
+
* Returns the character if it's a single printable character,
|
|
18
|
+
* or empty string for non-printable keys.
|
|
19
|
+
*/
|
|
20
|
+
function getStringForKey(key) {
|
|
21
|
+
if (key.length === 1 || !/^[A-Z]/i.test(key)) return key;
|
|
22
|
+
return "";
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Search for a key in the collection that matches the search string.
|
|
26
|
+
* Starts *at* `fromKey` (inclusive) and scans to the end, with no internal
|
|
27
|
+
* wrap; the caller retries from the top to cover earlier items. Matching is
|
|
28
|
+
* locale-aware via the supplied `collator`.
|
|
29
|
+
*/
|
|
30
|
+
function getKeyForSearch(collection, search, fromKey, collator, isKeyDisabled) {
|
|
31
|
+
const items = [];
|
|
32
|
+
for (const item of collection) if (item.type === "item") items.push(item);
|
|
33
|
+
if (items.length === 0) return null;
|
|
34
|
+
let startIndex = 0;
|
|
35
|
+
if (fromKey != null) {
|
|
36
|
+
const fromIndex = items.findIndex((item) => item.key === fromKey);
|
|
37
|
+
if (fromIndex !== -1) startIndex = fromIndex;
|
|
38
|
+
}
|
|
39
|
+
for (let index = startIndex; index < items.length; index++) {
|
|
40
|
+
const item = items[index];
|
|
41
|
+
if (item.isDisabled || isKeyDisabled && isKeyDisabled(item.key)) continue;
|
|
42
|
+
const textValue = item.textValue || "";
|
|
43
|
+
const substring = textValue.slice(0, search.length);
|
|
44
|
+
if (textValue && collator.compare(substring, search) === 0) return item.key;
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Creates typeahead/type-to-select functionality for a collection.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```tsx
|
|
53
|
+
* const { typeSelectProps } = createTypeSelect({
|
|
54
|
+
* collection: () => state.collection(),
|
|
55
|
+
* focusedKey: () => state.focusedKey(),
|
|
56
|
+
* onFocusedKeyChange: (key) => state.setFocusedKey(key),
|
|
57
|
+
* });
|
|
58
|
+
*
|
|
59
|
+
* return <ul {...mergeProps(listBoxProps, typeSelectProps)}>...</ul>;
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
function createTypeSelect(options) {
|
|
63
|
+
const state = {
|
|
64
|
+
search: "",
|
|
65
|
+
timeout: void 0
|
|
66
|
+
};
|
|
67
|
+
const collator = createCollator({
|
|
68
|
+
usage: "search",
|
|
69
|
+
sensitivity: "base"
|
|
70
|
+
});
|
|
71
|
+
const searchAndFocus = () => {
|
|
72
|
+
const collection = options.collection();
|
|
73
|
+
const currentKey = options.focusedKey();
|
|
74
|
+
let key = getKeyForSearch(collection, state.search, currentKey, collator(), options.isKeyDisabled);
|
|
75
|
+
if (key == null) key = getKeyForSearch(collection, state.search, null, collator(), options.isKeyDisabled);
|
|
76
|
+
if (key != null) {
|
|
77
|
+
options.onFocusedKeyChange(key);
|
|
78
|
+
options.onTypeSelect?.(key);
|
|
79
|
+
}
|
|
80
|
+
return key;
|
|
81
|
+
};
|
|
82
|
+
const restartDebounce = () => {
|
|
83
|
+
clearTimeout(state.timeout);
|
|
84
|
+
state.timeout = setTimeout(() => {
|
|
85
|
+
state.search = "";
|
|
86
|
+
}, TYPEAHEAD_DEBOUNCE_WAIT_MS);
|
|
87
|
+
};
|
|
88
|
+
const onKeyDownCapture = (e) => {
|
|
89
|
+
if (options.isDisabled) return;
|
|
90
|
+
if (state.search.length > 0 && e.key === " ") {
|
|
91
|
+
e.preventDefault();
|
|
92
|
+
e.stopPropagation();
|
|
93
|
+
state.search += " ";
|
|
94
|
+
searchAndFocus();
|
|
95
|
+
restartDebounce();
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const onKeyDown = (e) => {
|
|
99
|
+
if (options.isDisabled) return;
|
|
100
|
+
const character = getStringForKey(e.key);
|
|
101
|
+
if (!character || e.ctrlKey || e.metaKey || e.altKey || !e.currentTarget.contains(e.target) || state.search.length === 0 && character === " ") return;
|
|
102
|
+
state.search += character;
|
|
103
|
+
if (searchAndFocus() != null) {
|
|
104
|
+
e.preventDefault();
|
|
105
|
+
e.stopPropagation();
|
|
106
|
+
} else {
|
|
107
|
+
state.search = "";
|
|
108
|
+
clearTimeout(state.timeout);
|
|
109
|
+
state.timeout = void 0;
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
restartDebounce();
|
|
113
|
+
};
|
|
114
|
+
onCleanup(() => {
|
|
115
|
+
clearTimeout(state.timeout);
|
|
116
|
+
});
|
|
117
|
+
return { typeSelectProps: {
|
|
118
|
+
onKeyDownCapture,
|
|
119
|
+
onKeyDown
|
|
120
|
+
} };
|
|
121
|
+
}
|
|
122
|
+
//#endregion
|
|
123
|
+
export { createTypeSelect as t };
|
|
124
|
+
|
|
125
|
+
//# sourceMappingURL=createTypeSelect.jsx.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createTypeSelect.jsx","names":[],"sources":["../../src/selection/createTypeSelect.ts"],"sourcesContent":["/**\n * createTypeSelect - Handles typeahead interactions with collections.\n * Based on @react-aria/selection useTypeSelect.\n *\n * Allows users to navigate to items by typing characters that match\n * item text values. Supports multi-character search with debouncing.\n */\n\nimport { onCleanup } from \"solid-js\";\nimport type { JSX, Accessor } from \"solid-js\";\nimport type { Key, Collection, CollectionNode } from \"@proyecto-viviana/solid-stately\";\nimport { createCollator } from \"../i18n/createCollator\";\n\n/**\n * Controls how long to wait before clearing the typeahead buffer.\n */\nconst TYPEAHEAD_DEBOUNCE_WAIT_MS = 1000; // 1 second\n\nexport interface TypeSelectOptions<T> {\n /** The collection to search through. */\n collection: Accessor<Collection<T>>;\n /** The currently focused key. */\n focusedKey: Accessor<Key | null>;\n /** Callback to set the focused key when a match is found. */\n onFocusedKeyChange: (key: Key) => void;\n /** Callback when an item is focused by typing. */\n onTypeSelect?: (key: Key) => void;\n /** Function to check if a key is disabled. */\n isKeyDisabled?: (key: Key) => boolean;\n /** Whether type-to-select is disabled. */\n isDisabled?: boolean;\n}\n\nexport interface TypeSelectAria {\n /** Props to spread on the collection element. */\n typeSelectProps: JSX.HTMLAttributes<HTMLElement>;\n}\n\n// Internal state for tracking the search buffer\ninterface TypeSelectState {\n search: string;\n timeout: ReturnType<typeof setTimeout> | undefined;\n}\n\n/**\n * Get a printable character from a key event.\n * Returns the character if it's a single printable character,\n * or empty string for non-printable keys.\n */\nfunction getStringForKey(key: string): string {\n // If the key is of length 1, it is an ASCII value.\n // Otherwise, if there are no ASCII characters in the key name,\n // it is a Unicode character.\n // See https://www.w3.org/TR/uievents-key/\n if (key.length === 1 || !/^[A-Z]/i.test(key)) {\n return key;\n }\n return \"\";\n}\n\n/**\n * Search for a key in the collection that matches the search string.\n * Starts *at* `fromKey` (inclusive) and scans to the end, with no internal\n * wrap; the caller retries from the top to cover earlier items. Matching is\n * locale-aware via the supplied `collator`.\n */\nfunction getKeyForSearch<T>(\n collection: Collection<T>,\n search: string,\n fromKey: Key | null,\n collator: Intl.Collator,\n isKeyDisabled?: (key: Key) => boolean,\n): Key | null {\n // Collect all items in order\n const items: CollectionNode<T>[] = [];\n for (const item of collection) {\n if (item.type === \"item\") {\n items.push(item);\n }\n }\n\n if (items.length === 0) return null;\n\n // Find the starting index. Start *at* the currently focused item (inclusive),\n // mirroring upstream ListKeyboardDelegate.getKeyForSearch (`key = fromKey ||\n // getFirstKey()`): typing a prefix the focused item already matches keeps focus\n // on it instead of advancing to the next match.\n let startIndex = 0;\n if (fromKey != null) {\n const fromIndex = items.findIndex((item) => item.key === fromKey);\n if (fromIndex !== -1) {\n startIndex = fromIndex;\n }\n }\n\n // Scan from startIndex to the end (no wrap). The caller retries from the top to\n // cover items before the focused one, matching upstream useTypeSelect.\n for (let index = startIndex; index < items.length; index++) {\n const item = items[index];\n\n // Skip disabled items\n if (item.isDisabled || (isKeyDisabled && isKeyDisabled(item.key))) {\n continue;\n }\n\n // Match the leading characters of the text value against the search string\n // using locale-aware collation, mirroring upstream ListKeyboardDelegate\n // (`collator.compare(textValue.slice(0, search.length), search) === 0`). The\n // collator's `usage: 'search'` / `sensitivity: 'base'` makes this case- and\n // diacritic-insensitive in a locale-aware way.\n const textValue = item.textValue || \"\";\n const substring = textValue.slice(0, search.length);\n if (textValue && collator.compare(substring, search) === 0) {\n return item.key;\n }\n }\n\n return null;\n}\n\n/**\n * Creates typeahead/type-to-select functionality for a collection.\n *\n * @example\n * ```tsx\n * const { typeSelectProps } = createTypeSelect({\n * collection: () => state.collection(),\n * focusedKey: () => state.focusedKey(),\n * onFocusedKeyChange: (key) => state.setFocusedKey(key),\n * });\n *\n * return <ul {...mergeProps(listBoxProps, typeSelectProps)}>...</ul>;\n * ```\n */\nexport function createTypeSelect<T>(options: TypeSelectOptions<T>): TypeSelectAria {\n // Create mutable state object to persist across keystrokes\n const state: TypeSelectState = {\n search: \"\",\n timeout: undefined,\n };\n\n // Locale-aware search collator, mirroring upstream useSelectableList's\n // `useCollator({ usage: 'search', sensitivity: 'base' })`.\n const collator = createCollator({ usage: \"search\", sensitivity: \"base\" });\n\n // Append the search buffer, find a matching key (from the focused item,\n // falling back to the whole list), focus it, and (re)start the debounce timer.\n // Shared by both phase handlers below, mirroring the duplicated body in\n // upstream useTypeSelect.\n const searchAndFocus = (): Key | null => {\n const collection = options.collection();\n const currentKey = options.focusedKey();\n\n // Prioritize items at/after the focused item, then retry from the top to\n // cover earlier ones (upstream's two getKeyForSearch calls).\n let key = getKeyForSearch(\n collection,\n state.search,\n currentKey,\n collator(),\n options.isKeyDisabled,\n );\n if (key == null) {\n key = getKeyForSearch(collection, state.search, null, collator(), options.isKeyDisabled);\n }\n\n if (key != null) {\n options.onFocusedKeyChange(key);\n options.onTypeSelect?.(key);\n }\n\n return key;\n };\n\n const restartDebounce = () => {\n clearTimeout(state.timeout);\n state.timeout = setTimeout(() => {\n state.search = \"\";\n }, TYPEAHEAD_DEBOUNCE_WAIT_MS);\n };\n\n // Capture phase: mid-search a Spacebar is part of the query, not a selection\n // action, so we consume it before the collection's own keydown handler can act\n // on it. Mirrors upstream useTypeSelect's onKeyDownCapture.\n const onKeyDownCapture: JSX.EventHandler<HTMLElement, KeyboardEvent> = (e) => {\n if (options.isDisabled) return;\n\n if (state.search.length > 0 && e.key === \" \") {\n e.preventDefault();\n // Upstream guards this with `!('continuePropagation' in e) ||\n // !e.isPropagationStopped()`. Our raw DOM KeyboardEvents never carry\n // `continuePropagation`, so the guard always holds — stop unconditionally.\n e.stopPropagation();\n state.search += \" \";\n searchAndFocus();\n restartDebounce();\n }\n };\n\n // Bubble phase: handles ordinary characters (and, in environments where the\n // capture listener above is inert, mid-search Spacebar via its non-bailing\n // branch). Mirrors upstream useTypeSelect's onKeyDown.\n const onKeyDown: JSX.EventHandler<HTMLElement, KeyboardEvent> = (e) => {\n if (options.isDisabled) return;\n\n const character = getStringForKey(e.key);\n\n // Ignore non-printable keys, Ctrl/Meta/Alt combos (Alt is excluded to match\n // upstream — AltGr-only layouts shouldn't drive type-select), events from\n // outside the element, and a leading Space (a common action key).\n if (\n !character ||\n e.ctrlKey ||\n e.metaKey ||\n e.altKey ||\n !e.currentTarget.contains(e.target as HTMLElement) ||\n (state.search.length === 0 && character === \" \")\n ) {\n return;\n }\n\n state.search += character;\n\n const key = searchAndFocus();\n\n if (key != null) {\n e.preventDefault();\n // Our raw DOM events never carry `continuePropagation`, so upstream's\n // `if (!('continuePropagation' in e)) e.stopPropagation()` is unconditional.\n e.stopPropagation();\n } else {\n // Nothing matched even after retrying from the top: type-to-select is done,\n // so reset the buffer and let the key propagate normally.\n state.search = \"\";\n clearTimeout(state.timeout);\n state.timeout = undefined;\n return;\n }\n\n restartDebounce();\n };\n\n // Mirror upstream's unmount cleanup (a useEffect teardown) so a pending\n // debounce timer never fires after the consumer is disposed.\n onCleanup(() => {\n clearTimeout(state.timeout);\n });\n\n return {\n typeSelectProps: {\n // Upstream binds `onKeyDownCapture` so Spacebar is handled before the\n // collection's own keydown handler. In Solid a capture handler delivered\n // through a `{...typeSelectProps}` spread is inert (it never fires), so the\n // bubble-phase `onKeyDown` is the live path — and it also covers mid-search\n // Space because its bail check only rejects a *leading* Space. True capture\n // would need a ref-based addEventListener threaded through every consumer;\n // see the typeahead follow-up in upstream-sync.md.\n onKeyDownCapture,\n onKeyDown,\n } as JSX.HTMLAttributes<HTMLElement>,\n };\n}\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAM,6BAA6B;;;;;;AAiCnC,SAAS,gBAAgB,KAAqB;CAK5C,IAAI,IAAI,WAAW,KAAK,CAAC,UAAU,KAAK,GAAG,GACzC,OAAO;CAET,OAAO;AACT;;;;;;;AAQA,SAAS,gBACP,YACA,QACA,SACA,UACA,eACY;CAEZ,MAAM,Q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