@proyecto-viviana/solidaria 0.2.5 → 0.3.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/LICENSE +21 -0
- package/README.md +31 -236
- package/dist/actiongroup/createActionGroup.d.ts +29 -0
- package/dist/actiongroup/createActionGroup.d.ts.map +1 -0
- package/dist/actiongroup/index.d.ts +2 -0
- package/dist/actiongroup/index.d.ts.map +1 -0
- package/dist/autocomplete/createAutocomplete.d.ts +16 -12
- package/dist/autocomplete/createAutocomplete.d.ts.map +1 -1
- package/dist/autocomplete/index.d.ts +1 -1
- package/dist/autocomplete/index.d.ts.map +1 -1
- package/dist/breadcrumbs/createBreadcrumbs.d.ts +11 -7
- package/dist/breadcrumbs/createBreadcrumbs.d.ts.map +1 -1
- package/dist/breadcrumbs/index.d.ts +1 -1
- package/dist/button/createButton.d.ts +1 -1
- package/dist/button/createButton.d.ts.map +1 -1
- package/dist/button/createToggleButton.d.ts +3 -3
- package/dist/button/createToggleButtonGroup.d.ts +32 -0
- package/dist/button/createToggleButtonGroup.d.ts.map +1 -0
- package/dist/button/index.d.ts +6 -4
- package/dist/button/index.d.ts.map +1 -1
- package/dist/button/types.d.ts +18 -12
- package/dist/button/types.d.ts.map +1 -1
- package/dist/calendar/createCalendar.d.ts +15 -5
- package/dist/calendar/createCalendar.d.ts.map +1 -1
- package/dist/calendar/createCalendarCell.d.ts +8 -2
- package/dist/calendar/createCalendarCell.d.ts.map +1 -1
- package/dist/calendar/createCalendarGrid.d.ts +4 -4
- package/dist/calendar/createCalendarGrid.d.ts.map +1 -1
- package/dist/calendar/createRangeCalendar.d.ts +15 -5
- package/dist/calendar/createRangeCalendar.d.ts.map +1 -1
- package/dist/calendar/createRangeCalendarCell.d.ts +7 -3
- package/dist/calendar/createRangeCalendarCell.d.ts.map +1 -1
- package/dist/calendar/index.d.ts +5 -5
- package/dist/calendar/index.d.ts.map +1 -1
- package/dist/calendar/intl/index.d.ts +12 -0
- package/dist/calendar/intl/index.d.ts.map +1 -0
- package/dist/calendar/utils.d.ts +12 -0
- package/dist/calendar/utils.d.ts.map +1 -0
- package/dist/checkbox/createCheckbox.d.ts +6 -6
- package/dist/checkbox/createCheckbox.d.ts.map +1 -1
- package/dist/checkbox/createCheckboxGroup.d.ts +11 -7
- package/dist/checkbox/createCheckboxGroup.d.ts.map +1 -1
- package/dist/checkbox/createCheckboxGroupItem.d.ts +4 -4
- package/dist/checkbox/createCheckboxGroupItem.d.ts.map +1 -1
- package/dist/checkbox/createCheckboxGroupState.d.ts +2 -2
- package/dist/checkbox/createCheckboxGroupState.d.ts.map +1 -1
- package/dist/checkbox/index.d.ts +8 -8
- package/dist/checkbox/index.d.ts.map +1 -1
- package/dist/collections/index.d.ts +56 -0
- package/dist/collections/index.d.ts.map +1 -0
- package/dist/color/createColorArea.d.ts +3 -3
- package/dist/color/createColorArea.d.ts.map +1 -1
- package/dist/color/createColorField.d.ts +4 -4
- package/dist/color/createColorField.d.ts.map +1 -1
- package/dist/color/createColorSlider.d.ts +4 -4
- package/dist/color/createColorSlider.d.ts.map +1 -1
- package/dist/color/createColorSwatch.d.ts +2 -2
- package/dist/color/createColorSwatch.d.ts.map +1 -1
- package/dist/color/createColorWheel.d.ts +3 -3
- package/dist/color/createColorWheel.d.ts.map +1 -1
- package/dist/color/index.d.ts +6 -6
- package/dist/color/types.d.ts +98 -16
- package/dist/color/types.d.ts.map +1 -1
- package/dist/combobox/createComboBox.d.ts +16 -7
- package/dist/combobox/createComboBox.d.ts.map +1 -1
- package/dist/combobox/index.d.ts +1 -1
- package/dist/combobox/intl/index.d.ts +1 -1
- package/dist/datepicker/createDateField.d.ts +18 -6
- package/dist/datepicker/createDateField.d.ts.map +1 -1
- package/dist/datepicker/createDatePicker.d.ts +57 -5
- package/dist/datepicker/createDatePicker.d.ts.map +1 -1
- package/dist/datepicker/createDatePickerGroup.d.ts +19 -0
- package/dist/datepicker/createDatePickerGroup.d.ts.map +1 -0
- package/dist/datepicker/createDateRangePicker.d.ts +42 -0
- package/dist/datepicker/createDateRangePicker.d.ts.map +1 -0
- package/dist/datepicker/createDateSegment.d.ts +11 -3
- package/dist/datepicker/createDateSegment.d.ts.map +1 -1
- package/dist/datepicker/createTimeField.d.ts +11 -5
- package/dist/datepicker/createTimeField.d.ts.map +1 -1
- package/dist/datepicker/createTimeSegment.d.ts +29 -0
- package/dist/datepicker/createTimeSegment.d.ts.map +1 -0
- package/dist/datepicker/index.d.ts +7 -4
- package/dist/datepicker/index.d.ts.map +1 -1
- package/dist/dialog/createDialog.d.ts +5 -5
- package/dist/dialog/createDialog.d.ts.map +1 -1
- package/dist/dialog/index.d.ts +2 -2
- package/dist/dialog/index.d.ts.map +1 -1
- package/dist/dialog/types.d.ts +4 -4
- package/dist/disclosure/createDisclosure.d.ts +5 -2
- package/dist/disclosure/createDisclosure.d.ts.map +1 -1
- package/dist/disclosure/createDisclosureGroup.d.ts +4 -3
- package/dist/disclosure/createDisclosureGroup.d.ts.map +1 -1
- package/dist/disclosure/index.d.ts +2 -2
- package/dist/dnd/createDrag.d.ts +2 -2
- package/dist/dnd/createDrag.d.ts.map +1 -1
- package/dist/dnd/createDraggableCollection.d.ts +6 -2
- package/dist/dnd/createDraggableCollection.d.ts.map +1 -1
- package/dist/dnd/createDraggableItem.d.ts +3 -3
- package/dist/dnd/createDraggableItem.d.ts.map +1 -1
- package/dist/dnd/createDrop.d.ts +2 -2
- package/dist/dnd/createDrop.d.ts.map +1 -1
- package/dist/dnd/createDroppableCollection.d.ts +55 -4
- package/dist/dnd/createDroppableCollection.d.ts.map +1 -1
- package/dist/dnd/createDroppableItem.d.ts +3 -3
- package/dist/dnd/createDroppableItem.d.ts.map +1 -1
- package/dist/dnd/index.d.ts +12 -12
- package/dist/dnd/index.d.ts.map +1 -1
- package/dist/dnd/types.d.ts +2 -2
- package/dist/dnd/types.d.ts.map +1 -1
- package/dist/dnd/utils.d.ts +1 -1
- package/dist/dnd/utils.d.ts.map +1 -1
- package/dist/focus/FocusScope.d.ts +1 -1
- package/dist/focus/FocusScope.d.ts.map +1 -1
- package/dist/focus/createAutoFocus.d.ts.map +1 -1
- package/dist/focus/createFocusRestore.d.ts.map +1 -1
- package/dist/focus/createVirtualFocus.d.ts +4 -4
- package/dist/focus/createVirtualFocus.d.ts.map +1 -1
- package/dist/focus/index.d.ts +4 -4
- package/dist/focus/index.d.ts.map +1 -1
- package/dist/form/createFormReset.d.ts +1 -1
- package/dist/form/createFormValidation.d.ts +3 -3
- package/dist/form/createFormValidation.d.ts.map +1 -1
- package/dist/form/index.d.ts +2 -2
- package/dist/form/index.d.ts.map +1 -1
- package/dist/grid/GridKeyboardDelegate.d.ts +5 -5
- package/dist/grid/createGrid.d.ts +3 -3
- package/dist/grid/createGrid.d.ts.map +1 -1
- package/dist/grid/createGridCell.d.ts +3 -3
- package/dist/grid/createGridRow.d.ts +3 -3
- package/dist/grid/index.d.ts +5 -5
- package/dist/grid/types.d.ts +8 -8
- package/dist/gridlist/createGridList.d.ts +6 -4
- package/dist/gridlist/createGridList.d.ts.map +1 -1
- package/dist/gridlist/createGridListItem.d.ts +4 -4
- package/dist/gridlist/createGridListItem.d.ts.map +1 -1
- package/dist/gridlist/createGridListSelectionCheckbox.d.ts +3 -3
- package/dist/gridlist/createGridListSelectionCheckbox.d.ts.map +1 -1
- package/dist/gridlist/index.d.ts +4 -4
- package/dist/gridlist/types.d.ts +11 -7
- package/dist/gridlist/types.d.ts.map +1 -1
- package/dist/i18n/createCollator.d.ts.map +1 -1
- package/dist/i18n/createDateFormatter.d.ts.map +1 -1
- package/dist/i18n/createFilter.d.ts.map +1 -1
- package/dist/i18n/createNumberFormatter.d.ts +1 -1
- package/dist/i18n/createNumberFormatter.d.ts.map +1 -1
- package/dist/i18n/createStringFormatter.d.ts +2 -2
- package/dist/i18n/createStringFormatter.d.ts.map +1 -1
- package/dist/i18n/index.d.ts +8 -8
- package/dist/i18n/index.d.ts.map +1 -1
- package/dist/i18n/locale.d.ts +2 -2
- package/dist/i18n/locale.d.ts.map +1 -1
- package/dist/i18n/utils.d.ts.map +1 -1
- package/dist/index.d.ts +52 -49
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18089 -15690
- package/dist/index.js.map +1 -7
- package/dist/index.jsx +18242 -0
- package/dist/index.jsx.map +1 -0
- package/dist/interactions/FocusableProvider.d.ts +2 -2
- package/dist/interactions/FocusableProvider.d.ts.map +1 -1
- package/dist/interactions/PressEvent.d.ts +2 -2
- package/dist/interactions/createFocus.d.ts +1 -1
- package/dist/interactions/createFocus.d.ts.map +1 -1
- package/dist/interactions/createFocusRing.d.ts +1 -1
- package/dist/interactions/createFocusRing.d.ts.map +1 -1
- package/dist/interactions/createFocusWithin.d.ts +1 -1
- package/dist/interactions/createFocusWithin.d.ts.map +1 -1
- package/dist/interactions/createFocusable.d.ts +3 -3
- package/dist/interactions/createFocusable.d.ts.map +1 -1
- package/dist/interactions/createHover.d.ts +5 -5
- package/dist/interactions/createHover.d.ts.map +1 -1
- package/dist/interactions/createInteractionModality.d.ts +3 -3
- package/dist/interactions/createInteractionModality.d.ts.map +1 -1
- package/dist/interactions/createKeyboard.d.ts +1 -1
- package/dist/interactions/createLongPress.d.ts +5 -5
- package/dist/interactions/createMove.d.ts +5 -5
- package/dist/interactions/createMove.d.ts.map +1 -1
- package/dist/interactions/createPress.d.ts +4 -4
- package/dist/interactions/createPress.d.ts.map +1 -1
- package/dist/interactions/index.d.ts +12 -12
- package/dist/interactions/index.d.ts.map +1 -1
- package/dist/label/createField.d.ts +4 -4
- package/dist/label/createField.d.ts.map +1 -1
- package/dist/label/createLabel.d.ts +7 -7
- package/dist/label/createLabel.d.ts.map +1 -1
- package/dist/label/createLabels.d.ts +1 -1
- package/dist/label/createLabels.d.ts.map +1 -1
- package/dist/label/index.d.ts +5 -5
- package/dist/landmark/createLandmark.d.ts +5 -5
- package/dist/landmark/createLandmark.d.ts.map +1 -1
- package/dist/landmark/index.d.ts +1 -1
- package/dist/link/createLink.d.ts +23 -7
- package/dist/link/createLink.d.ts.map +1 -1
- package/dist/link/index.d.ts +1 -1
- package/dist/listbox/createListBox.d.ts +12 -6
- package/dist/listbox/createListBox.d.ts.map +1 -1
- package/dist/listbox/createOption.d.ts +21 -4
- package/dist/listbox/createOption.d.ts.map +1 -1
- package/dist/listbox/index.d.ts +2 -2
- package/dist/listbox/index.d.ts.map +1 -1
- package/dist/live-announcer/announce.d.ts +2 -2
- package/dist/live-announcer/announce.d.ts.map +1 -1
- package/dist/live-announcer/index.d.ts +1 -1
- package/dist/menu/createMenu.d.ts +8 -7
- package/dist/menu/createMenu.d.ts.map +1 -1
- package/dist/menu/createMenuItem.d.ts +16 -4
- package/dist/menu/createMenuItem.d.ts.map +1 -1
- package/dist/menu/createMenuTrigger.d.ts +4 -4
- package/dist/menu/index.d.ts +3 -3
- package/dist/menu/index.d.ts.map +1 -1
- package/dist/meter/createMeter.d.ts +6 -6
- package/dist/meter/createMeter.d.ts.map +1 -1
- package/dist/meter/index.d.ts +1 -1
- package/dist/numberfield/createNumberField.d.ts +27 -8
- package/dist/numberfield/createNumberField.d.ts.map +1 -1
- package/dist/numberfield/index.d.ts +1 -1
- package/dist/overlays/ariaHideOutside.d.ts.map +1 -1
- package/dist/overlays/createModal.d.ts +19 -3
- package/dist/overlays/createModal.d.ts.map +1 -1
- package/dist/overlays/createOverlay.d.ts +1 -1
- package/dist/overlays/createOverlay.d.ts.map +1 -1
- package/dist/overlays/createOverlayTrigger.d.ts +6 -6
- package/dist/overlays/index.d.ts +6 -6
- package/dist/overlays/index.d.ts.map +1 -1
- package/dist/popover/calculatePosition.d.ts +4 -4
- package/dist/popover/calculatePosition.d.ts.map +1 -1
- package/dist/popover/createOverlayPosition.d.ts +3 -3
- package/dist/popover/createOverlayPosition.d.ts.map +1 -1
- package/dist/popover/createPopover.d.ts +4 -4
- package/dist/popover/createPopover.d.ts.map +1 -1
- package/dist/popover/index.d.ts +3 -3
- package/dist/progress/createProgressBar.d.ts +7 -5
- package/dist/progress/createProgressBar.d.ts.map +1 -1
- package/dist/progress/index.d.ts +1 -1
- package/dist/radio/createRadio.d.ts +7 -7
- package/dist/radio/createRadio.d.ts.map +1 -1
- package/dist/radio/createRadioGroup.d.ts +11 -11
- package/dist/radio/createRadioGroup.d.ts.map +1 -1
- package/dist/radio/createRadioGroupState.d.ts +3 -3
- package/dist/radio/createRadioGroupState.d.ts.map +1 -1
- package/dist/radio/index.d.ts +3 -3
- package/dist/radio/index.d.ts.map +1 -1
- package/dist/searchfield/createSearchField.d.ts +7 -7
- package/dist/searchfield/createSearchField.d.ts.map +1 -1
- package/dist/searchfield/index.d.ts +2 -2
- package/dist/select/createHiddenSelect.d.ts +4 -4
- package/dist/select/createHiddenSelect.d.ts.map +1 -1
- package/dist/select/createSelect.d.ts +14 -6
- package/dist/select/createSelect.d.ts.map +1 -1
- package/dist/select/index.d.ts +2 -2
- package/dist/select/index.d.ts.map +1 -1
- package/dist/selection/createTypeSelect.d.ts +2 -2
- package/dist/selection/index.d.ts +1 -1
- package/dist/separator/createSeparator.d.ts +9 -5
- package/dist/separator/createSeparator.d.ts.map +1 -1
- package/dist/separator/index.d.ts +1 -1
- package/dist/slider/createSlider.d.ts +11 -7
- package/dist/slider/createSlider.d.ts.map +1 -1
- package/dist/slider/index.d.ts +2 -2
- package/dist/ssr/index.d.ts +1 -1
- package/dist/ssr/index.d.ts.map +1 -1
- package/dist/steplist/createStepList.d.ts +36 -0
- package/dist/steplist/createStepList.d.ts.map +1 -0
- package/dist/steplist/index.d.ts +2 -0
- package/dist/steplist/index.d.ts.map +1 -0
- package/dist/switch/createSwitch.d.ts +6 -4
- package/dist/switch/createSwitch.d.ts.map +1 -1
- package/dist/switch/index.d.ts +1 -1
- package/dist/table/createTable.d.ts +3 -3
- package/dist/table/createTable.d.ts.map +1 -1
- package/dist/table/createTableCell.d.ts +3 -3
- package/dist/table/createTableCell.d.ts.map +1 -1
- package/dist/table/createTableColumnHeader.d.ts +3 -3
- package/dist/table/createTableColumnHeader.d.ts.map +1 -1
- package/dist/table/createTableColumnResize.d.ts +41 -0
- package/dist/table/createTableColumnResize.d.ts.map +1 -0
- package/dist/table/createTableHeaderRow.d.ts +3 -3
- package/dist/table/createTableRow.d.ts +3 -3
- package/dist/table/createTableRow.d.ts.map +1 -1
- package/dist/table/createTableRowGroup.d.ts +2 -2
- package/dist/table/createTableRowGroup.d.ts.map +1 -1
- package/dist/table/createTableSelectAllCheckbox.d.ts +3 -3
- package/dist/table/createTableSelectAllCheckbox.d.ts.map +1 -1
- package/dist/table/createTableSelectionCheckbox.d.ts +3 -3
- package/dist/table/index.d.ts +11 -9
- package/dist/table/index.d.ts.map +1 -1
- package/dist/table/types.d.ts +15 -7
- package/dist/table/types.d.ts.map +1 -1
- package/dist/tabs/createTabs.d.ts +28 -25
- package/dist/tabs/createTabs.d.ts.map +1 -1
- package/dist/tabs/index.d.ts +1 -1
- package/dist/tag/createTag.d.ts +2 -2
- package/dist/tag/createTag.d.ts.map +1 -1
- package/dist/tag/createTagGroup.d.ts +5 -5
- package/dist/tag/createTagGroup.d.ts.map +1 -1
- package/dist/tag/index.d.ts +2 -2
- package/dist/tag/index.d.ts.map +1 -1
- package/dist/textfield/createTextField.d.ts +17 -11
- package/dist/textfield/createTextField.d.ts.map +1 -1
- package/dist/textfield/index.d.ts +1 -1
- package/dist/textfield/index.d.ts.map +1 -1
- package/dist/toast/createToast.d.ts +6 -2
- package/dist/toast/createToast.d.ts.map +1 -1
- package/dist/toast/createToastRegion.d.ts +5 -3
- package/dist/toast/createToastRegion.d.ts.map +1 -1
- package/dist/toast/index.d.ts +2 -2
- package/dist/toast/index.d.ts.map +1 -1
- package/dist/toggle/createToggle.d.ts +9 -9
- package/dist/toggle/createToggle.d.ts.map +1 -1
- package/dist/toggle/createToggleState.d.ts +2 -2
- package/dist/toggle/createToggleState.d.ts.map +1 -1
- package/dist/toggle/index.d.ts +4 -4
- package/dist/toggle/index.d.ts.map +1 -1
- package/dist/toolbar/createToolbar.d.ts +9 -9
- package/dist/toolbar/createToolbar.d.ts.map +1 -1
- package/dist/toolbar/index.d.ts +1 -1
- package/dist/toolbar/index.d.ts.map +1 -1
- package/dist/tooltip/createTooltip.d.ts +5 -5
- package/dist/tooltip/createTooltip.d.ts.map +1 -1
- package/dist/tooltip/createTooltipTrigger.d.ts +10 -5
- package/dist/tooltip/createTooltipTrigger.d.ts.map +1 -1
- package/dist/tooltip/index.d.ts +2 -2
- package/dist/tree/createTree.d.ts +3 -3
- package/dist/tree/createTree.d.ts.map +1 -1
- package/dist/tree/createTreeItem.d.ts +4 -4
- package/dist/tree/createTreeItem.d.ts.map +1 -1
- package/dist/tree/createTreeSelectionCheckbox.d.ts +3 -3
- package/dist/tree/createTreeSelectionCheckbox.d.ts.map +1 -1
- package/dist/tree/index.d.ts +4 -4
- package/dist/tree/types.d.ts +13 -5
- package/dist/tree/types.d.ts.map +1 -1
- package/dist/utils/createDescription.d.ts +2 -2
- package/dist/utils/createDescription.d.ts.map +1 -1
- package/dist/utils/dom.d.ts.map +1 -1
- package/dist/utils/env.d.ts +1 -1
- package/dist/utils/env.d.ts.map +1 -1
- package/dist/utils/focus.d.ts +1 -1
- package/dist/utils/focus.d.ts.map +1 -1
- package/dist/utils/geometry.d.ts.map +1 -1
- package/dist/utils/index.d.ts +12 -12
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/mergeProps.d.ts.map +1 -1
- package/dist/utils/platform.d.ts.map +1 -1
- package/dist/utils/reactivity.d.ts +1 -1
- package/dist/visually-hidden/createVisuallyHidden.d.ts +2 -2
- package/dist/visually-hidden/createVisuallyHidden.d.ts.map +1 -1
- package/dist/visually-hidden/index.d.ts +1 -1
- package/package.json +34 -32
- package/src/actiongroup/createActionGroup.ts +334 -0
- package/src/actiongroup/index.ts +8 -0
- package/src/autocomplete/createAutocomplete.ts +137 -131
- package/src/autocomplete/index.ts +1 -1
- package/src/breadcrumbs/createBreadcrumbs.ts +37 -51
- package/src/breadcrumbs/index.ts +1 -1
- package/src/button/createButton.ts +102 -73
- package/src/button/createToggleButton.ts +10 -10
- package/src/button/createToggleButtonGroup.ts +121 -0
- package/src/button/index.ts +10 -4
- package/src/button/types.ts +18 -12
- package/src/calendar/createCalendar.ts +62 -29
- package/src/calendar/createCalendarCell.ts +102 -48
- package/src/calendar/createCalendarGrid.ts +78 -47
- package/src/calendar/createRangeCalendar.ts +66 -31
- package/src/calendar/createRangeCalendarCell.ts +115 -37
- package/src/calendar/index.ts +5 -9
- package/src/calendar/intl/index.ts +210 -0
- package/src/calendar/utils.ts +227 -0
- package/src/checkbox/createCheckbox.ts +13 -21
- package/src/checkbox/createCheckboxGroup.ts +86 -45
- package/src/checkbox/createCheckboxGroupItem.ts +16 -27
- package/src/checkbox/createCheckboxGroupState.ts +3 -22
- package/src/checkbox/index.ts +8 -10
- package/src/collections/index.ts +246 -0
- package/src/color/createColorArea.ts +458 -314
- package/src/color/createColorField.ts +186 -137
- package/src/color/createColorSlider.ts +444 -197
- package/src/color/createColorSwatch.ts +65 -40
- package/src/color/createColorWheel.ts +343 -208
- package/src/color/index.ts +24 -24
- package/src/color/types.ts +198 -116
- package/src/combobox/createComboBox.ts +727 -647
- package/src/combobox/index.ts +6 -6
- package/src/combobox/intl/index.ts +5 -5
- package/src/datepicker/createDateField.ts +192 -39
- package/src/datepicker/createDatePicker.ts +294 -63
- package/src/datepicker/createDatePickerGroup.ts +149 -0
- package/src/datepicker/createDateRangePicker.ts +294 -0
- package/src/datepicker/createDateSegment.ts +316 -75
- package/src/datepicker/createTimeField.ts +38 -34
- package/src/datepicker/createTimeSegment.ts +352 -0
- package/src/datepicker/index.ts +24 -11
- package/src/dialog/createDialog.ts +127 -120
- package/src/dialog/index.ts +2 -2
- package/src/dialog/types.ts +19 -19
- package/src/disclosure/createDisclosure.ts +138 -33
- package/src/disclosure/createDisclosureGroup.ts +8 -18
- package/src/disclosure/index.ts +2 -2
- package/src/dnd/createDrag.ts +218 -209
- package/src/dnd/createDraggableCollection.ts +96 -63
- package/src/dnd/createDraggableItem.ts +260 -243
- package/src/dnd/createDrop.ts +313 -321
- package/src/dnd/createDroppableCollection.ts +799 -293
- package/src/dnd/createDroppableItem.ts +215 -213
- package/src/dnd/index.ts +66 -47
- package/src/dnd/types.ts +86 -89
- package/src/dnd/utils.ts +281 -294
- package/src/focus/FocusScope.tsx +155 -164
- package/src/focus/createAutoFocus.ts +305 -321
- package/src/focus/createFocusRestore.ts +300 -313
- package/src/focus/createVirtualFocus.ts +380 -396
- package/src/focus/index.ts +4 -8
- package/src/form/createFormReset.ts +4 -4
- package/src/form/createFormValidation.ts +201 -224
- package/src/form/index.ts +8 -11
- package/src/grid/GridKeyboardDelegate.ts +30 -30
- package/src/grid/createGrid.ts +38 -36
- package/src/grid/createGridCell.ts +18 -18
- package/src/grid/createGridRow.ts +14 -14
- package/src/grid/index.ts +5 -5
- package/src/grid/types.ts +8 -8
- package/src/gridlist/createGridList.ts +45 -24
- package/src/gridlist/createGridListItem.ts +68 -23
- package/src/gridlist/createGridListSelectionCheckbox.ts +12 -9
- package/src/gridlist/index.ts +4 -4
- package/src/gridlist/types.ts +11 -7
- package/src/i18n/createCollator.ts +66 -79
- package/src/i18n/createDateFormatter.ts +75 -83
- package/src/i18n/createFilter.ts +118 -131
- package/src/i18n/createNumberFormatter.ts +50 -52
- package/src/i18n/createStringFormatter.ts +19 -15
- package/src/i18n/index.ts +37 -40
- package/src/i18n/locale.tsx +163 -188
- package/src/i18n/utils.ts +95 -99
- package/src/index.ts +114 -164
- package/src/interactions/FocusableProvider.tsx +3 -7
- package/src/interactions/PressEvent.ts +4 -4
- package/src/interactions/createFocus.ts +16 -11
- package/src/interactions/createFocusRing.ts +21 -19
- package/src/interactions/createFocusWithin.ts +24 -16
- package/src/interactions/createFocusable.ts +15 -16
- package/src/interactions/createHover.ts +70 -55
- package/src/interactions/createInteractionModality.ts +75 -82
- package/src/interactions/createKeyboard.ts +2 -2
- package/src/interactions/createLongPress.ts +174 -174
- package/src/interactions/createMove.ts +299 -289
- package/src/interactions/createPress.ts +168 -91
- package/src/interactions/index.ts +24 -16
- package/src/label/createField.ts +18 -19
- package/src/label/createLabel.ts +18 -30
- package/src/label/createLabels.ts +8 -12
- package/src/label/index.ts +5 -5
- package/src/landmark/createLandmark.ts +356 -377
- package/src/landmark/index.ts +8 -8
- package/src/link/createLink.ts +96 -54
- package/src/link/index.ts +1 -1
- package/src/listbox/createListBox.ts +319 -269
- package/src/listbox/createOption.ts +208 -151
- package/src/listbox/index.ts +8 -12
- package/src/live-announcer/announce.ts +295 -322
- package/src/live-announcer/index.ts +9 -9
- package/src/menu/createMenu.ts +434 -396
- package/src/menu/createMenuItem.ts +201 -149
- package/src/menu/createMenuTrigger.ts +88 -88
- package/src/menu/index.ts +9 -18
- package/src/meter/createMeter.ts +7 -20
- package/src/meter/index.ts +1 -1
- package/src/numberfield/createNumberField.ts +368 -268
- package/src/numberfield/index.ts +5 -5
- package/src/overlays/ariaHideOutside.ts +223 -219
- package/src/overlays/createInteractOutside.ts +152 -149
- package/src/overlays/createModal.tsx +238 -202
- package/src/overlays/createOverlay.ts +195 -155
- package/src/overlays/createOverlayTrigger.ts +85 -85
- package/src/overlays/createPreventScroll.ts +288 -266
- package/src/overlays/index.ts +37 -44
- package/src/popover/calculatePosition.ts +117 -119
- package/src/popover/createOverlayPosition.ts +52 -43
- package/src/popover/createPopover.ts +63 -24
- package/src/popover/index.ts +3 -3
- package/src/progress/createProgressBar.ts +36 -32
- package/src/progress/index.ts +1 -1
- package/src/radio/createRadio.ts +95 -73
- package/src/radio/createRadioGroup.ts +142 -62
- package/src/radio/createRadioGroupState.ts +7 -31
- package/src/radio/index.ts +3 -8
- package/src/searchfield/createSearchField.ts +269 -186
- package/src/searchfield/index.ts +2 -2
- package/src/select/createHiddenSelect.tsx +276 -236
- package/src/select/createSelect.ts +430 -395
- package/src/select/index.ts +9 -14
- package/src/selection/createTypeSelect.ts +11 -11
- package/src/selection/index.ts +1 -1
- package/src/separator/createSeparator.ts +20 -25
- package/src/separator/index.ts +1 -1
- package/src/slider/createSlider.ts +333 -349
- package/src/slider/index.ts +2 -2
- package/src/ssr/index.tsx +331 -370
- package/src/steplist/createStepList.ts +106 -0
- package/src/steplist/index.ts +8 -0
- package/src/switch/createSwitch.ts +9 -14
- package/src/switch/index.ts +1 -1
- package/src/table/createTable.ts +155 -86
- package/src/table/createTableCell.ts +17 -16
- package/src/table/createTableColumnHeader.ts +67 -20
- package/src/table/createTableColumnResize.ts +256 -0
- package/src/table/createTableHeaderRow.ts +7 -7
- package/src/table/createTableRow.ts +149 -29
- package/src/table/createTableRowGroup.ts +5 -7
- package/src/table/createTableSelectAllCheckbox.ts +12 -11
- package/src/table/createTableSelectionCheckbox.ts +8 -8
- package/src/table/index.ts +14 -9
- package/src/table/types.ts +15 -7
- package/src/tabs/createTabs.ts +138 -127
- package/src/tabs/index.ts +1 -1
- package/src/tag/createTag.ts +171 -40
- package/src/tag/createTagGroup.ts +50 -39
- package/src/tag/index.ts +2 -6
- package/src/textfield/createTextField.ts +67 -35
- package/src/textfield/index.ts +1 -5
- package/src/toast/createToast.ts +34 -26
- package/src/toast/createToastRegion.ts +169 -27
- package/src/toast/index.ts +2 -6
- package/src/toggle/createToggle.ts +95 -53
- package/src/toggle/createToggleState.ts +2 -10
- package/src/toggle/index.ts +4 -5
- package/src/toolbar/createToolbar.ts +226 -169
- package/src/toolbar/index.ts +1 -1
- package/src/tooltip/createTooltip.ts +66 -79
- package/src/tooltip/createTooltipTrigger.ts +238 -222
- package/src/tooltip/index.ts +6 -6
- package/src/tree/createTree.ts +259 -246
- package/src/tree/createTreeItem.ts +282 -233
- package/src/tree/createTreeSelectionCheckbox.ts +71 -68
- package/src/tree/index.ts +16 -16
- package/src/tree/types.ts +95 -87
- package/src/utils/createDescription.ts +6 -23
- package/src/utils/dom.ts +61 -54
- package/src/utils/env.ts +53 -54
- package/src/utils/events.ts +7 -7
- package/src/utils/filterDOMProps.ts +49 -49
- package/src/utils/focus.ts +60 -68
- package/src/utils/geometry.ts +1 -4
- package/src/utils/globalListeners.ts +9 -9
- package/src/utils/index.ts +12 -22
- package/src/utils/mergeProps.ts +42 -15
- package/src/utils/platform.ts +16 -6
- package/src/utils/reactivity.ts +3 -3
- package/src/utils/textSelection.ts +16 -16
- package/src/visually-hidden/createVisuallyHidden.ts +127 -124
- package/src/visually-hidden/index.ts +6 -6
- package/dist/i18n/NumberFormatter.d.ts +0 -43
- package/dist/i18n/NumberFormatter.d.ts.map +0 -1
- package/dist/index.ssr.js +0 -15875
- package/dist/index.ssr.js.map +0 -7
- package/src/i18n/NumberFormatter.ts +0 -266
|
@@ -1,293 +1,799 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* createDroppableCollection - ARIA hook for droppable collection targets.
|
|
3
|
-
*
|
|
4
|
-
* Provides accessibility support for dropping items into a collection
|
|
5
|
-
* component like ListBox, GridList, or Table.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { createMemo, onCleanup, type Accessor } from
|
|
9
|
-
import type { JSX } from
|
|
10
|
-
import type {
|
|
11
|
-
DroppableCollectionState,
|
|
12
|
-
DropTarget,
|
|
13
|
-
DropOperation,
|
|
14
|
-
DropItem,
|
|
15
|
-
DragTypes,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
}
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
const
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
1
|
+
/**
|
|
2
|
+
* createDroppableCollection - ARIA hook for droppable collection targets.
|
|
3
|
+
*
|
|
4
|
+
* Provides accessibility support for dropping items into a collection
|
|
5
|
+
* component like ListBox, GridList, or Table.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { createMemo, onCleanup, type Accessor } from "solid-js";
|
|
9
|
+
import type { JSX } from "solid-js";
|
|
10
|
+
import type {
|
|
11
|
+
DroppableCollectionState,
|
|
12
|
+
DropTarget,
|
|
13
|
+
DropOperation,
|
|
14
|
+
DropItem,
|
|
15
|
+
DragTypes,
|
|
16
|
+
Key,
|
|
17
|
+
} from "@proyecto-viviana/solid-stately";
|
|
18
|
+
import { DIRECTORY_DRAG_TYPE } from "@proyecto-viviana/solid-stately";
|
|
19
|
+
import { createDrop } from "./createDrop";
|
|
20
|
+
import {
|
|
21
|
+
getGlobalDraggingCollectionRef,
|
|
22
|
+
getGlobalDraggingKeys,
|
|
23
|
+
getGlobalDraggingTypes,
|
|
24
|
+
} from "./createDraggableCollection";
|
|
25
|
+
import { getGlobalAllowedDropOperations, DROP_OPERATION } from "./utils";
|
|
26
|
+
|
|
27
|
+
// Global state for tracking the drop collection
|
|
28
|
+
let globalDropCollectionRef: HTMLElement | null = null;
|
|
29
|
+
|
|
30
|
+
export function setGlobalDropCollectionRef(ref: HTMLElement | null): void {
|
|
31
|
+
globalDropCollectionRef = ref;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function getGlobalDropCollectionRef(): HTMLElement | null {
|
|
35
|
+
return globalDropCollectionRef;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface DropTargetDelegate {
|
|
39
|
+
/**
|
|
40
|
+
* Returns a drop target from a point within the collection.
|
|
41
|
+
*/
|
|
42
|
+
getDropTargetFromPoint(
|
|
43
|
+
x: number,
|
|
44
|
+
y: number,
|
|
45
|
+
isValidDropTarget: (target: DropTarget) => boolean,
|
|
46
|
+
): DropTarget | null;
|
|
47
|
+
/**
|
|
48
|
+
* Returns the next keyboard-navigable drop target.
|
|
49
|
+
*/
|
|
50
|
+
getKeyboardNavigationTarget?(
|
|
51
|
+
target: DropTarget | null,
|
|
52
|
+
direction: "next" | "previous",
|
|
53
|
+
isValidDropTarget: (target: DropTarget) => boolean,
|
|
54
|
+
): DropTarget | null;
|
|
55
|
+
/**
|
|
56
|
+
* Returns the next page-navigable drop target.
|
|
57
|
+
*/
|
|
58
|
+
getKeyboardPageNavigationTarget?(
|
|
59
|
+
target: DropTarget | null,
|
|
60
|
+
direction: "next" | "previous",
|
|
61
|
+
isValidDropTarget: (target: DropTarget) => boolean,
|
|
62
|
+
): DropTarget | null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface KeyboardDelegateLike {
|
|
66
|
+
getFirstKey?: () => string | number | null;
|
|
67
|
+
getLastKey?: () => string | number | null;
|
|
68
|
+
getKeyBelow?: (key: string | number) => string | number | null;
|
|
69
|
+
getKeyAbove?: (key: string | number) => string | number | null;
|
|
70
|
+
getKeyRightOf?: (key: string | number) => string | number | null;
|
|
71
|
+
getKeyLeftOf?: (key: string | number) => string | number | null;
|
|
72
|
+
getKeyPageBelow?: (key: string | number) => string | number | null;
|
|
73
|
+
getKeyPageAbove?: (key: string | number) => string | number | null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
interface CollectionNodeLike {
|
|
77
|
+
type?: string;
|
|
78
|
+
key: Key;
|
|
79
|
+
parentKey?: Key | null;
|
|
80
|
+
childNodes?: CollectionNodeLike[];
|
|
81
|
+
isExpanded?: boolean;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
interface CollectionLike {
|
|
85
|
+
getItem(key: Key): CollectionNodeLike | null;
|
|
86
|
+
[Symbol.iterator](): Iterator<CollectionNodeLike>;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface DroppableCollectionOptions {
|
|
90
|
+
/** Reference to the collection element. */
|
|
91
|
+
ref: Accessor<HTMLElement | null>;
|
|
92
|
+
/** A delegate that provides drop targets for pointer coordinates. */
|
|
93
|
+
dropTargetDelegate: DropTargetDelegate;
|
|
94
|
+
/** Handler called when items are dropped to be inserted. */
|
|
95
|
+
onInsert?: (e: { items: DropItem[]; target: DropTarget; dropOperation: DropOperation }) => void;
|
|
96
|
+
/** Handler called when items are dropped on the root. */
|
|
97
|
+
onRootDrop?: (e: { items: DropItem[]; dropOperation: DropOperation }) => void;
|
|
98
|
+
/** Handler called when items are dropped on an item. */
|
|
99
|
+
onItemDrop?: (e: {
|
|
100
|
+
items: DropItem[];
|
|
101
|
+
target: DropTarget;
|
|
102
|
+
dropOperation: DropOperation;
|
|
103
|
+
isInternal: boolean;
|
|
104
|
+
}) => void;
|
|
105
|
+
/** Handler called when items are reordered within the collection. */
|
|
106
|
+
onReorder?: (e: {
|
|
107
|
+
keys: Set<string | number>;
|
|
108
|
+
target: DropTarget;
|
|
109
|
+
dropOperation: DropOperation;
|
|
110
|
+
}) => void;
|
|
111
|
+
/** Handler called when items are moved within/between collections. */
|
|
112
|
+
onMove?: (e: {
|
|
113
|
+
keys: Set<string | number>;
|
|
114
|
+
target: DropTarget;
|
|
115
|
+
dropOperation: DropOperation;
|
|
116
|
+
}) => void;
|
|
117
|
+
/** Handler called when a drop occurs on any collection target. */
|
|
118
|
+
onDrop?: (e: {
|
|
119
|
+
items: DropItem[];
|
|
120
|
+
target: DropTarget;
|
|
121
|
+
dropOperation: DropOperation;
|
|
122
|
+
x: number;
|
|
123
|
+
y: number;
|
|
124
|
+
}) => void;
|
|
125
|
+
/** Handler called when the drop target is activated (held over). */
|
|
126
|
+
onDropActivate?: (e: { target: DropTarget; x: number; y: number }) => void;
|
|
127
|
+
/** Optional keyboard delegate used as fallback when drop-target delegates do not provide keyboard navigation methods. */
|
|
128
|
+
keyboardDelegate?: KeyboardDelegateLike;
|
|
129
|
+
/** Optional keyboard handler composed with internal drop target navigation keys. */
|
|
130
|
+
onKeyDown?: (e: KeyboardEvent) => void;
|
|
131
|
+
/** Collection snapshot used to restore focus and selection after a drop mutates items. */
|
|
132
|
+
collection?: CollectionLike;
|
|
133
|
+
/** Current collection selection used to avoid replacing user-updated selection after a drop. */
|
|
134
|
+
selectedKeys?: "all" | Iterable<Key>;
|
|
135
|
+
/** Sets collection selection after a drop when new rows were inserted and selection was unchanged. */
|
|
136
|
+
setSelectedKeys?: (keys: Set<Key>) => void;
|
|
137
|
+
/** Sets collection focus after a drop when new rows were inserted. */
|
|
138
|
+
setFocusedKey?: (key: Key | null) => void;
|
|
139
|
+
/** Whether the collection is disabled for dropping. */
|
|
140
|
+
isDisabled?: boolean;
|
|
141
|
+
/** Accepted drag types. 'all' accepts any type. */
|
|
142
|
+
acceptedDragTypes?: "all" | Array<string | symbol>;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export function getDropItemTypes(item: DropItem): Set<string | symbol> {
|
|
146
|
+
if (item.kind === "file") {
|
|
147
|
+
return new Set([item.type]);
|
|
148
|
+
}
|
|
149
|
+
if (item.kind === "text") {
|
|
150
|
+
return new Set(item.types);
|
|
151
|
+
}
|
|
152
|
+
return new Set([DIRECTORY_DRAG_TYPE]);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export interface DroppableCollectionAria {
|
|
156
|
+
/** Props to spread on the collection element. */
|
|
157
|
+
collectionProps: JSX.HTMLAttributes<HTMLElement>;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Creates ARIA support for a droppable collection.
|
|
162
|
+
*
|
|
163
|
+
* @param options - Collection options accessor
|
|
164
|
+
* @param state - Droppable collection state
|
|
165
|
+
* @returns Droppable collection ARIA result
|
|
166
|
+
*/
|
|
167
|
+
export function createDroppableCollection(
|
|
168
|
+
options: Accessor<DroppableCollectionOptions>,
|
|
169
|
+
state: DroppableCollectionState,
|
|
170
|
+
): DroppableCollectionAria {
|
|
171
|
+
const getOptions = createMemo(() => options());
|
|
172
|
+
|
|
173
|
+
// Track the next target during drag operations
|
|
174
|
+
let nextTarget: DropTarget | null = null;
|
|
175
|
+
let currentDropOperation: DropOperation | null = null;
|
|
176
|
+
|
|
177
|
+
const isInternalDropOperation = (): boolean => {
|
|
178
|
+
const ref = getOptions().ref();
|
|
179
|
+
const draggingRef = getGlobalDraggingCollectionRef();
|
|
180
|
+
return ref !== null && draggingRef === ref;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
const getDropOperationForTarget = (
|
|
184
|
+
target: DropTarget,
|
|
185
|
+
types: DragTypes,
|
|
186
|
+
allowedOperations: DropOperation[],
|
|
187
|
+
): DropOperation => {
|
|
188
|
+
return state.getDropOperation(target, types, allowedOperations);
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
// Create base drop behavior
|
|
192
|
+
const drop = createDrop(() => ({
|
|
193
|
+
isDisabled: getOptions().isDisabled,
|
|
194
|
+
getDropOperationForPoint: (types, allowedOperations, x, y) => {
|
|
195
|
+
const opts = getOptions();
|
|
196
|
+
const isValidDropTarget = (target: DropTarget) =>
|
|
197
|
+
getDropOperationForTarget(target, types, allowedOperations) !== "cancel";
|
|
198
|
+
|
|
199
|
+
const target = opts.dropTargetDelegate.getDropTargetFromPoint(x, y, isValidDropTarget);
|
|
200
|
+
|
|
201
|
+
if (!target) {
|
|
202
|
+
currentDropOperation = "cancel";
|
|
203
|
+
nextTarget = null;
|
|
204
|
+
return "cancel";
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
currentDropOperation = getDropOperationForTarget(target, types, allowedOperations);
|
|
208
|
+
|
|
209
|
+
// If target doesn't accept, try root
|
|
210
|
+
if (currentDropOperation === "cancel") {
|
|
211
|
+
const rootTarget: DropTarget = { type: "root" };
|
|
212
|
+
const rootOp = getDropOperationForTarget(rootTarget, types, allowedOperations);
|
|
213
|
+
if (rootOp !== "cancel") {
|
|
214
|
+
nextTarget = rootTarget;
|
|
215
|
+
currentDropOperation = rootOp;
|
|
216
|
+
return currentDropOperation;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// Update drop collection ref
|
|
221
|
+
const ref = opts.ref();
|
|
222
|
+
if (target && currentDropOperation !== "cancel" && ref !== globalDropCollectionRef) {
|
|
223
|
+
setGlobalDropCollectionRef(ref);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
nextTarget = currentDropOperation === "cancel" ? null : target;
|
|
227
|
+
return currentDropOperation;
|
|
228
|
+
},
|
|
229
|
+
onDropEnter: () => {
|
|
230
|
+
if (nextTarget) {
|
|
231
|
+
state.setTarget(nextTarget);
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
onDropMove: () => {
|
|
235
|
+
if (nextTarget) {
|
|
236
|
+
state.setTarget(nextTarget);
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
onDropExit: () => {
|
|
240
|
+
setGlobalDropCollectionRef(null);
|
|
241
|
+
state.setTarget(null);
|
|
242
|
+
},
|
|
243
|
+
onDropActivate: (e) => {
|
|
244
|
+
const opts = getOptions();
|
|
245
|
+
if (
|
|
246
|
+
state.target?.type === "item" &&
|
|
247
|
+
state.target.dropPosition === "on" &&
|
|
248
|
+
typeof opts.onDropActivate === "function"
|
|
249
|
+
) {
|
|
250
|
+
opts.onDropActivate({
|
|
251
|
+
target: state.target,
|
|
252
|
+
x: e.x,
|
|
253
|
+
y: e.y,
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
onDrop: (e) => {
|
|
258
|
+
const opts = getOptions();
|
|
259
|
+
setGlobalDropCollectionRef(opts.ref());
|
|
260
|
+
|
|
261
|
+
if (state.target) {
|
|
262
|
+
const target = state.target;
|
|
263
|
+
const previousCollection = opts.collection;
|
|
264
|
+
const previousSelectedKeys = normalizeSelection(opts.selectedKeys);
|
|
265
|
+
opts.onDrop?.({
|
|
266
|
+
items: e.items,
|
|
267
|
+
target,
|
|
268
|
+
dropOperation: e.dropOperation,
|
|
269
|
+
x: e.x,
|
|
270
|
+
y: e.y,
|
|
271
|
+
});
|
|
272
|
+
void Promise.resolve(handleDrop(e.items, target, e.dropOperation)).then(() => {
|
|
273
|
+
queueMicrotask(() => {
|
|
274
|
+
updateFocusAfterDrop(getOptions(), previousCollection, previousSelectedKeys, target);
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
}));
|
|
280
|
+
|
|
281
|
+
const handleDrop = async (
|
|
282
|
+
items: DropItem[],
|
|
283
|
+
target: DropTarget,
|
|
284
|
+
dropOperation: DropOperation,
|
|
285
|
+
) => {
|
|
286
|
+
const opts = getOptions();
|
|
287
|
+
const isInternal = isInternalDropOperation();
|
|
288
|
+
|
|
289
|
+
// Filter items by accepted types
|
|
290
|
+
let filteredItems = items;
|
|
291
|
+
const acceptedTypes = opts.acceptedDragTypes;
|
|
292
|
+
if (acceptedTypes && acceptedTypes !== "all") {
|
|
293
|
+
filteredItems = items.filter((item) => {
|
|
294
|
+
const itemTypes = getDropItemTypes(item);
|
|
295
|
+
return acceptedTypes.some((type) => itemTypes.has(type));
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
if (filteredItems.length === 0) return;
|
|
300
|
+
|
|
301
|
+
// Call appropriate handlers based on target type
|
|
302
|
+
if (target.type === "root" && opts.onRootDrop) {
|
|
303
|
+
await opts.onRootDrop({ items: filteredItems, dropOperation });
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (target.type === "item") {
|
|
307
|
+
if (target.dropPosition === "on" && opts.onItemDrop) {
|
|
308
|
+
await opts.onItemDrop({
|
|
309
|
+
items: filteredItems,
|
|
310
|
+
target,
|
|
311
|
+
dropOperation,
|
|
312
|
+
isInternal,
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// Handle move for internal operations
|
|
317
|
+
if (opts.onMove && isInternal) {
|
|
318
|
+
const draggingKeys = getGlobalDraggingKeys();
|
|
319
|
+
await opts.onMove({
|
|
320
|
+
keys: draggingKeys,
|
|
321
|
+
target,
|
|
322
|
+
dropOperation,
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
if (target.dropPosition !== "on") {
|
|
327
|
+
if (!isInternal && opts.onInsert) {
|
|
328
|
+
await opts.onInsert({
|
|
329
|
+
items: filteredItems,
|
|
330
|
+
target,
|
|
331
|
+
dropOperation,
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
if (isInternal && opts.onReorder) {
|
|
336
|
+
const draggingKeys = getGlobalDraggingKeys();
|
|
337
|
+
await opts.onReorder({
|
|
338
|
+
keys: draggingKeys,
|
|
339
|
+
target,
|
|
340
|
+
dropOperation,
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
// Clean up on unmount
|
|
348
|
+
onCleanup(() => {
|
|
349
|
+
const ref = getOptions().ref();
|
|
350
|
+
if (globalDropCollectionRef === ref) {
|
|
351
|
+
setGlobalDropCollectionRef(null);
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
const collectionProps = createMemo(() => {
|
|
356
|
+
const baseDropProps = drop.dropProps;
|
|
357
|
+
const onKeyDownBase = baseDropProps.onKeyDown as ((e: KeyboardEvent) => void) | undefined;
|
|
358
|
+
const onKeyDown = (e: KeyboardEvent): void => {
|
|
359
|
+
onKeyDownBase?.(e);
|
|
360
|
+
const opts = getOptions();
|
|
361
|
+
if (opts.isDisabled) return;
|
|
362
|
+
const resolveDirection = (): "ltr" | "rtl" => {
|
|
363
|
+
const refEl = opts.ref();
|
|
364
|
+
if (
|
|
365
|
+
refEl &&
|
|
366
|
+
typeof window !== "undefined" &&
|
|
367
|
+
typeof window.getComputedStyle === "function"
|
|
368
|
+
) {
|
|
369
|
+
const computedDir = window.getComputedStyle(refEl).direction;
|
|
370
|
+
if (computedDir === "rtl") return "rtl";
|
|
371
|
+
}
|
|
372
|
+
return typeof document !== "undefined" && document.dir === "rtl" ? "rtl" : "ltr";
|
|
373
|
+
};
|
|
374
|
+
const isRtl = resolveDirection() === "rtl";
|
|
375
|
+
const forwardHorizontalKey = isRtl ? "ArrowLeft" : "ArrowRight";
|
|
376
|
+
const backwardHorizontalKey = isRtl ? "ArrowRight" : "ArrowLeft";
|
|
377
|
+
const callUserOnKeyDown = () => opts.onKeyDown?.(e);
|
|
378
|
+
const getKeyboardAllowedOperations = (): DropOperation[] => {
|
|
379
|
+
const allowedBits = getGlobalAllowedDropOperations();
|
|
380
|
+
if (!allowedBits) return ["copy", "move", "link"];
|
|
381
|
+
const allowed: DropOperation[] = [];
|
|
382
|
+
if (allowedBits & DROP_OPERATION.copy) allowed.push("copy");
|
|
383
|
+
if (allowedBits & DROP_OPERATION.move) allowed.push("move");
|
|
384
|
+
if (allowedBits & DROP_OPERATION.link) allowed.push("link");
|
|
385
|
+
return allowed.length > 0 ? allowed : ["copy", "move", "link"];
|
|
386
|
+
};
|
|
387
|
+
const getKeyboardDragTypes = (): DragTypes => {
|
|
388
|
+
const draggingTypes = getGlobalDraggingTypes();
|
|
389
|
+
if (draggingTypes.size === 0) {
|
|
390
|
+
return { has: () => true };
|
|
391
|
+
}
|
|
392
|
+
return {
|
|
393
|
+
has: (type: string | symbol) => typeof type === "string" && draggingTypes.has(type),
|
|
394
|
+
};
|
|
395
|
+
};
|
|
396
|
+
const isValidDropTarget = (target: DropTarget) =>
|
|
397
|
+
state.getDropOperation(target, getKeyboardDragTypes(), getKeyboardAllowedOperations()) !==
|
|
398
|
+
"cancel";
|
|
399
|
+
const targetsEqual = (a: DropTarget, b: DropTarget): boolean => {
|
|
400
|
+
if (a.type !== b.type) return false;
|
|
401
|
+
if (a.type === "root" && b.type === "root") return true;
|
|
402
|
+
if (a.type !== "item" || b.type !== "item") return false;
|
|
403
|
+
return a.key === b.key && a.dropPosition === b.dropPosition;
|
|
404
|
+
};
|
|
405
|
+
const findNextValidTarget = (
|
|
406
|
+
start: DropTarget | null,
|
|
407
|
+
getNext: (target: DropTarget | null) => DropTarget | null,
|
|
408
|
+
): DropTarget | null => {
|
|
409
|
+
let current = start;
|
|
410
|
+
let seenRoot = 0;
|
|
411
|
+
let safety = 0;
|
|
412
|
+
while (safety < 256) {
|
|
413
|
+
safety += 1;
|
|
414
|
+
const next = getNext(current);
|
|
415
|
+
if (!next) return null;
|
|
416
|
+
if (current && targetsEqual(current, next)) {
|
|
417
|
+
return isValidDropTarget(next) ? next : null;
|
|
418
|
+
}
|
|
419
|
+
current = next;
|
|
420
|
+
if (next.type === "root") {
|
|
421
|
+
seenRoot += 1;
|
|
422
|
+
if (seenRoot >= 2) {
|
|
423
|
+
return isValidDropTarget(next) ? next : null;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
if (isValidDropTarget(next)) return next;
|
|
427
|
+
}
|
|
428
|
+
return null;
|
|
429
|
+
};
|
|
430
|
+
const resolveTargetForKey = (
|
|
431
|
+
key: string | number | null,
|
|
432
|
+
direction: "next" | "previous",
|
|
433
|
+
): DropTarget | null => {
|
|
434
|
+
if (key == null) return null;
|
|
435
|
+
const onTarget: DropTarget = { type: "item", key, dropPosition: "on" };
|
|
436
|
+
if (isValidDropTarget(onTarget)) return onTarget;
|
|
437
|
+
const insertionOrder: Array<"before" | "after"> =
|
|
438
|
+
direction === "next" ? ["before", "after"] : ["after", "before"];
|
|
439
|
+
for (const position of insertionOrder) {
|
|
440
|
+
const insertionTarget: DropTarget = { type: "item", key, dropPosition: position };
|
|
441
|
+
if (isValidDropTarget(insertionTarget)) return insertionTarget;
|
|
442
|
+
}
|
|
443
|
+
return null;
|
|
444
|
+
};
|
|
445
|
+
const resolveBoundaryTargetForDirection = (
|
|
446
|
+
key: string | number | null,
|
|
447
|
+
direction: "next" | "previous",
|
|
448
|
+
): DropTarget | null => {
|
|
449
|
+
if (key == null) return null;
|
|
450
|
+
const boundaryOrder: Array<"before" | "on" | "after"> =
|
|
451
|
+
direction === "next" ? ["before", "on", "after"] : ["after", "on", "before"];
|
|
452
|
+
for (const position of boundaryOrder) {
|
|
453
|
+
const candidate: DropTarget = { type: "item", key, dropPosition: position };
|
|
454
|
+
if (isValidDropTarget(candidate)) return candidate;
|
|
455
|
+
}
|
|
456
|
+
return null;
|
|
457
|
+
};
|
|
458
|
+
const resolveFallbackKeyboardTarget = (
|
|
459
|
+
keyName: string,
|
|
460
|
+
currentTarget: DropTarget | null = state.target,
|
|
461
|
+
): DropTarget | null => {
|
|
462
|
+
const keyboardDelegate = opts.keyboardDelegate;
|
|
463
|
+
if (!keyboardDelegate) return null;
|
|
464
|
+
const currentKey = currentTarget?.type === "item" ? currentTarget.key : null;
|
|
465
|
+
const keyForDirection = (
|
|
466
|
+
direction: "next" | "previous",
|
|
467
|
+
getter: ((key: string | number) => string | number | null) | undefined,
|
|
468
|
+
): DropTarget | null => {
|
|
469
|
+
if (currentKey == null) {
|
|
470
|
+
const boundaryKey =
|
|
471
|
+
direction === "next"
|
|
472
|
+
? keyboardDelegate.getFirstKey?.()
|
|
473
|
+
: keyboardDelegate.getLastKey?.();
|
|
474
|
+
return resolveBoundaryTargetForDirection(boundaryKey ?? null, direction);
|
|
475
|
+
}
|
|
476
|
+
if (!getter) return null;
|
|
477
|
+
let nextKey = getter(currentKey);
|
|
478
|
+
let safety = 0;
|
|
479
|
+
while (nextKey != null && safety < 256) {
|
|
480
|
+
const resolvedTarget = resolveTargetForKey(nextKey, direction);
|
|
481
|
+
if (resolvedTarget) return resolvedTarget;
|
|
482
|
+
const candidate = getter(nextKey);
|
|
483
|
+
if (candidate === nextKey) break;
|
|
484
|
+
nextKey = candidate;
|
|
485
|
+
safety += 1;
|
|
486
|
+
}
|
|
487
|
+
return null;
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
if (keyName === "ArrowDown") return keyForDirection("next", keyboardDelegate.getKeyBelow);
|
|
491
|
+
if (keyName === "ArrowUp") return keyForDirection("previous", keyboardDelegate.getKeyAbove);
|
|
492
|
+
if (keyName === forwardHorizontalKey) {
|
|
493
|
+
return keyForDirection(
|
|
494
|
+
"next",
|
|
495
|
+
isRtl ? keyboardDelegate.getKeyLeftOf : keyboardDelegate.getKeyRightOf,
|
|
496
|
+
);
|
|
497
|
+
}
|
|
498
|
+
if (keyName === backwardHorizontalKey) {
|
|
499
|
+
return keyForDirection(
|
|
500
|
+
"previous",
|
|
501
|
+
isRtl ? keyboardDelegate.getKeyRightOf : keyboardDelegate.getKeyLeftOf,
|
|
502
|
+
);
|
|
503
|
+
}
|
|
504
|
+
if (keyName === "Home")
|
|
505
|
+
return resolveBoundaryTargetForDirection(
|
|
506
|
+
keyboardDelegate.getFirstKey?.() ?? null,
|
|
507
|
+
"next",
|
|
508
|
+
);
|
|
509
|
+
if (keyName === "End")
|
|
510
|
+
return resolveBoundaryTargetForDirection(
|
|
511
|
+
keyboardDelegate.getLastKey?.() ?? null,
|
|
512
|
+
"previous",
|
|
513
|
+
);
|
|
514
|
+
if (keyName === "PageDown") {
|
|
515
|
+
if (currentKey != null && keyboardDelegate.getKeyPageBelow) {
|
|
516
|
+
return resolveTargetForKey(keyboardDelegate.getKeyPageBelow(currentKey), "next");
|
|
517
|
+
}
|
|
518
|
+
return keyForDirection("next", keyboardDelegate.getKeyBelow);
|
|
519
|
+
}
|
|
520
|
+
if (keyName === "PageUp") {
|
|
521
|
+
if (currentKey != null && keyboardDelegate.getKeyPageAbove) {
|
|
522
|
+
return resolveTargetForKey(keyboardDelegate.getKeyPageAbove(currentKey), "previous");
|
|
523
|
+
}
|
|
524
|
+
return keyForDirection("previous", keyboardDelegate.getKeyAbove);
|
|
525
|
+
}
|
|
526
|
+
return null;
|
|
527
|
+
};
|
|
528
|
+
const resolvePageTargetForState = (
|
|
529
|
+
direction: "next" | "previous",
|
|
530
|
+
currentTarget: DropTarget,
|
|
531
|
+
): DropTarget | null => {
|
|
532
|
+
const keyboardDelegate = opts.keyboardDelegate;
|
|
533
|
+
if (!keyboardDelegate) return null;
|
|
534
|
+
if (direction === "next") {
|
|
535
|
+
let targetKey = keyboardDelegate.getFirstKey?.() ?? null;
|
|
536
|
+
let dropPosition: "before" | "on" | "after" = "after";
|
|
537
|
+
if (currentTarget.type === "item") {
|
|
538
|
+
targetKey = currentTarget.key;
|
|
539
|
+
dropPosition = currentTarget.dropPosition;
|
|
540
|
+
}
|
|
541
|
+
let nextKey =
|
|
542
|
+
targetKey != null ? (keyboardDelegate.getKeyPageBelow?.(targetKey) ?? null) : null;
|
|
543
|
+
if (
|
|
544
|
+
nextKey == null ||
|
|
545
|
+
(currentTarget.type === "item" && currentTarget.key === keyboardDelegate.getLastKey?.())
|
|
546
|
+
) {
|
|
547
|
+
nextKey = keyboardDelegate.getLastKey?.() ?? null;
|
|
548
|
+
dropPosition = "after";
|
|
549
|
+
}
|
|
550
|
+
if (nextKey == null) return null;
|
|
551
|
+
return {
|
|
552
|
+
type: "item",
|
|
553
|
+
key: nextKey,
|
|
554
|
+
dropPosition,
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
if (currentTarget.type === "item") {
|
|
559
|
+
if (currentTarget.key === keyboardDelegate.getFirstKey?.()) {
|
|
560
|
+
return { type: "root" };
|
|
561
|
+
}
|
|
562
|
+
let nextKey = keyboardDelegate.getKeyPageAbove?.(currentTarget.key) ?? null;
|
|
563
|
+
let dropPosition: "before" | "on" | "after" = currentTarget.dropPosition;
|
|
564
|
+
if (nextKey == null) {
|
|
565
|
+
nextKey = keyboardDelegate.getFirstKey?.() ?? null;
|
|
566
|
+
dropPosition = "before";
|
|
567
|
+
}
|
|
568
|
+
if (nextKey == null) return null;
|
|
569
|
+
return {
|
|
570
|
+
type: "item",
|
|
571
|
+
key: nextKey,
|
|
572
|
+
dropPosition,
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
return currentTarget.type === "root" ? currentTarget : null;
|
|
577
|
+
};
|
|
578
|
+
if (e.key === "PageDown" || e.key === "PageUp") {
|
|
579
|
+
if (
|
|
580
|
+
(e.key === "PageDown" && !opts.keyboardDelegate?.getKeyPageBelow) ||
|
|
581
|
+
(e.key === "PageUp" && !opts.keyboardDelegate?.getKeyPageAbove)
|
|
582
|
+
) {
|
|
583
|
+
callUserOnKeyDown();
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
const direction = e.key === "PageDown" ? "next" : "previous";
|
|
587
|
+
const pageNavigation = opts.dropTargetDelegate.getKeyboardPageNavigationTarget;
|
|
588
|
+
const stepNavigation = opts.dropTargetDelegate.getKeyboardNavigationTarget;
|
|
589
|
+
const resolveStepTarget = (
|
|
590
|
+
target: DropTarget | null,
|
|
591
|
+
navDirection: "next" | "previous",
|
|
592
|
+
): DropTarget | null =>
|
|
593
|
+
stepNavigation?.(target, navDirection, isValidDropTarget) ??
|
|
594
|
+
resolveFallbackKeyboardTarget(
|
|
595
|
+
navDirection === "next" ? "ArrowDown" : "ArrowUp",
|
|
596
|
+
target,
|
|
597
|
+
) ??
|
|
598
|
+
resolveFallbackKeyboardTarget(navDirection === "next" ? "Home" : "End", target) ??
|
|
599
|
+
null;
|
|
600
|
+
let nextTarget: DropTarget | null = null;
|
|
601
|
+
if (!state.target) {
|
|
602
|
+
nextTarget = findNextValidTarget(null, (target) => resolveStepTarget(target, direction));
|
|
603
|
+
} else {
|
|
604
|
+
const pageTarget =
|
|
605
|
+
pageNavigation?.(state.target, direction, isValidDropTarget) ??
|
|
606
|
+
resolvePageTargetForState(direction, state.target) ??
|
|
607
|
+
null;
|
|
608
|
+
if (pageTarget && isValidDropTarget(pageTarget)) {
|
|
609
|
+
nextTarget = pageTarget;
|
|
610
|
+
} else {
|
|
611
|
+
const startTarget = pageTarget ?? state.target;
|
|
612
|
+
nextTarget =
|
|
613
|
+
findNextValidTarget(startTarget, (target) => resolveStepTarget(target, direction)) ??
|
|
614
|
+
findNextValidTarget(startTarget, (target) =>
|
|
615
|
+
resolveStepTarget(target, direction === "next" ? "previous" : "next"),
|
|
616
|
+
);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
if (nextTarget) {
|
|
620
|
+
e.preventDefault();
|
|
621
|
+
state.setTarget(nextTarget);
|
|
622
|
+
}
|
|
623
|
+
callUserOnKeyDown();
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
if (
|
|
627
|
+
(e.key === "ArrowDown" ||
|
|
628
|
+
e.key === "ArrowUp" ||
|
|
629
|
+
e.key === "ArrowRight" ||
|
|
630
|
+
e.key === "ArrowLeft" ||
|
|
631
|
+
e.key === "Home" ||
|
|
632
|
+
e.key === "End") &&
|
|
633
|
+
opts.dropTargetDelegate.getKeyboardNavigationTarget
|
|
634
|
+
) {
|
|
635
|
+
if (
|
|
636
|
+
(e.key === "ArrowDown" && !opts.keyboardDelegate?.getKeyBelow) ||
|
|
637
|
+
(e.key === "ArrowUp" && !opts.keyboardDelegate?.getKeyAbove) ||
|
|
638
|
+
(e.key === "ArrowLeft" && !opts.keyboardDelegate?.getKeyLeftOf) ||
|
|
639
|
+
(e.key === "ArrowRight" && !opts.keyboardDelegate?.getKeyRightOf) ||
|
|
640
|
+
(e.key === "Home" && !opts.keyboardDelegate?.getFirstKey) ||
|
|
641
|
+
(e.key === "End" && !opts.keyboardDelegate?.getLastKey)
|
|
642
|
+
) {
|
|
643
|
+
callUserOnKeyDown();
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
const isForwardKey =
|
|
647
|
+
e.key === "ArrowDown" || e.key === forwardHorizontalKey || e.key === "Home";
|
|
648
|
+
const direction = isForwardKey ? "next" : "previous";
|
|
649
|
+
const navigationStart = e.key === "Home" || e.key === "End" ? null : state.target;
|
|
650
|
+
const nextTarget = findNextValidTarget(
|
|
651
|
+
navigationStart,
|
|
652
|
+
(target) =>
|
|
653
|
+
opts.dropTargetDelegate.getKeyboardNavigationTarget?.(
|
|
654
|
+
target,
|
|
655
|
+
direction,
|
|
656
|
+
isValidDropTarget,
|
|
657
|
+
) ?? resolveFallbackKeyboardTarget(e.key, target),
|
|
658
|
+
);
|
|
659
|
+
if (nextTarget) {
|
|
660
|
+
e.preventDefault();
|
|
661
|
+
state.setTarget(nextTarget);
|
|
662
|
+
}
|
|
663
|
+
callUserOnKeyDown();
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
666
|
+
if (
|
|
667
|
+
e.key === "ArrowDown" ||
|
|
668
|
+
e.key === "ArrowUp" ||
|
|
669
|
+
e.key === "ArrowRight" ||
|
|
670
|
+
e.key === "ArrowLeft" ||
|
|
671
|
+
e.key === "Home" ||
|
|
672
|
+
e.key === "End"
|
|
673
|
+
) {
|
|
674
|
+
if (
|
|
675
|
+
(e.key === "ArrowDown" && !opts.keyboardDelegate?.getKeyBelow) ||
|
|
676
|
+
(e.key === "ArrowUp" && !opts.keyboardDelegate?.getKeyAbove) ||
|
|
677
|
+
(e.key === "ArrowLeft" && !opts.keyboardDelegate?.getKeyLeftOf) ||
|
|
678
|
+
(e.key === "ArrowRight" && !opts.keyboardDelegate?.getKeyRightOf) ||
|
|
679
|
+
(e.key === "Home" && !opts.keyboardDelegate?.getFirstKey) ||
|
|
680
|
+
(e.key === "End" && !opts.keyboardDelegate?.getLastKey)
|
|
681
|
+
) {
|
|
682
|
+
callUserOnKeyDown();
|
|
683
|
+
return;
|
|
684
|
+
}
|
|
685
|
+
const navigationStart = e.key === "Home" || e.key === "End" ? null : state.target;
|
|
686
|
+
const nextTarget = findNextValidTarget(navigationStart, (target) =>
|
|
687
|
+
resolveFallbackKeyboardTarget(e.key, target),
|
|
688
|
+
);
|
|
689
|
+
if (nextTarget) {
|
|
690
|
+
e.preventDefault();
|
|
691
|
+
state.setTarget(nextTarget);
|
|
692
|
+
}
|
|
693
|
+
callUserOnKeyDown();
|
|
694
|
+
return;
|
|
695
|
+
}
|
|
696
|
+
if (e.key === "Enter" && state.target) {
|
|
697
|
+
e.preventDefault();
|
|
698
|
+
state.activateTarget(0, 0);
|
|
699
|
+
callUserOnKeyDown();
|
|
700
|
+
return;
|
|
701
|
+
}
|
|
702
|
+
if (e.key === "Escape" && state.target) {
|
|
703
|
+
e.preventDefault();
|
|
704
|
+
state.exitTarget(0, 0);
|
|
705
|
+
callUserOnKeyDown();
|
|
706
|
+
return;
|
|
707
|
+
}
|
|
708
|
+
callUserOnKeyDown();
|
|
709
|
+
};
|
|
710
|
+
return {
|
|
711
|
+
...baseDropProps,
|
|
712
|
+
onKeyDown,
|
|
713
|
+
};
|
|
714
|
+
});
|
|
715
|
+
|
|
716
|
+
return {
|
|
717
|
+
get collectionProps() {
|
|
718
|
+
return collectionProps() as DroppableCollectionAria["collectionProps"];
|
|
719
|
+
},
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
function normalizeSelection(selection: "all" | Iterable<Key> | undefined): "all" | Set<Key> | null {
|
|
724
|
+
if (selection == null) return null;
|
|
725
|
+
if (selection === "all") return "all";
|
|
726
|
+
return new Set(selection);
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
function selectionEquals(a: "all" | Set<Key> | null, b: "all" | Set<Key> | null): boolean {
|
|
730
|
+
if (a === b) return true;
|
|
731
|
+
if (!a || !b || a === "all" || b === "all") return false;
|
|
732
|
+
if (a.size !== b.size) return false;
|
|
733
|
+
for (const key of a) {
|
|
734
|
+
if (!b.has(key)) return false;
|
|
735
|
+
}
|
|
736
|
+
return true;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
function getNewItemKeys(collection: CollectionLike, previousCollection: CollectionLike): Set<Key> {
|
|
740
|
+
const keys = new Set<Key>();
|
|
741
|
+
const visit = (node: CollectionNodeLike) => {
|
|
742
|
+
if (node.type === "item" && !previousCollection.getItem(node.key)) {
|
|
743
|
+
keys.add(node.key);
|
|
744
|
+
}
|
|
745
|
+
for (const child of node.childNodes ?? []) {
|
|
746
|
+
visit(child);
|
|
747
|
+
}
|
|
748
|
+
};
|
|
749
|
+
|
|
750
|
+
for (const node of collection) {
|
|
751
|
+
visit(node);
|
|
752
|
+
}
|
|
753
|
+
return keys;
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
function updateFocusAfterDrop(
|
|
757
|
+
opts: DroppableCollectionOptions,
|
|
758
|
+
previousCollection: CollectionLike | undefined,
|
|
759
|
+
previousSelectedKeys: "all" | Set<Key> | null,
|
|
760
|
+
target: DropTarget,
|
|
761
|
+
): void {
|
|
762
|
+
const collection = opts.collection;
|
|
763
|
+
if (!collection || !previousCollection) return;
|
|
764
|
+
|
|
765
|
+
const newKeys = getNewItemKeys(collection, previousCollection);
|
|
766
|
+
if (newKeys.size === 0) return;
|
|
767
|
+
|
|
768
|
+
const currentSelectedKeys = normalizeSelection(opts.selectedKeys);
|
|
769
|
+
if (
|
|
770
|
+
opts.setSelectedKeys &&
|
|
771
|
+
previousSelectedKeys &&
|
|
772
|
+
selectionEquals(previousSelectedKeys, currentSelectedKeys)
|
|
773
|
+
) {
|
|
774
|
+
opts.setSelectedKeys(newKeys);
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
const first = newKeys.values().next().value;
|
|
778
|
+
if (first == null) return;
|
|
779
|
+
|
|
780
|
+
let focusKey: Key | null = first;
|
|
781
|
+
const item = collection.getItem(first);
|
|
782
|
+
const parent = item?.parentKey != null ? collection.getItem(item.parentKey) : null;
|
|
783
|
+
const isDroppedOnCollapsedParent =
|
|
784
|
+
target.type === "item" &&
|
|
785
|
+
target.dropPosition === "on" &&
|
|
786
|
+
item?.parentKey != null &&
|
|
787
|
+
parent?.isExpanded !== true;
|
|
788
|
+
|
|
789
|
+
if (item && (item.type === "cell" || item.type === "rowheader" || isDroppedOnCollapsedParent)) {
|
|
790
|
+
focusKey = item.parentKey ?? first;
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
opts.setFocusedKey?.(focusKey);
|
|
794
|
+
|
|
795
|
+
queueMicrotask(() => {
|
|
796
|
+
const row = opts.ref()?.querySelector<HTMLElement>('[role="row"][tabindex="0"]');
|
|
797
|
+
row?.focus();
|
|
798
|
+
});
|
|
799
|
+
}
|