@proyecto-viviana/solidaria 0.2.8 → 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/README.md +31 -236
- package/dist/actiongroup/createActionGroup.d.ts +5 -5
- package/dist/actiongroup/createActionGroup.d.ts.map +1 -1
- package/dist/actiongroup/index.d.ts +1 -1
- package/dist/autocomplete/createAutocomplete.d.ts +10 -10
- 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 +9 -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 +7 -7
- package/dist/button/createToggleButtonGroup.d.ts.map +1 -1
- package/dist/button/index.d.ts +6 -6
- 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 +6 -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 +4 -2
- 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 +7 -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 +3 -3
- package/dist/collections/index.d.ts.map +1 -1
- 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 +10 -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 +51 -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 +8 -6
- package/dist/datepicker/createDateRangePicker.d.ts.map +1 -1
- package/dist/datepicker/createDateSegment.d.ts +10 -2
- 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 +2 -2
- package/dist/datepicker/createTimeSegment.d.ts.map +1 -1
- package/dist/datepicker/index.d.ts +7 -6
- 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 -4
- 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 +2 -2
- 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 +26 -6
- package/dist/dnd/createDroppableCollection.d.ts.map +1 -1
- package/dist/dnd/createDroppableItem.d.ts +3 -3
- 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/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 -51
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18012 -16820
- package/dist/index.js.map +1 -1
- 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 +14 -8
- package/dist/link/createLink.d.ts.map +1 -1
- package/dist/link/index.d.ts +1 -1
- package/dist/listbox/createListBox.d.ts +11 -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 +7 -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 +9 -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 +3 -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 +10 -10
- 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 +2 -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 +10 -6
- 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.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/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 +32 -32
- package/src/actiongroup/createActionGroup.ts +101 -91
- package/src/actiongroup/index.ts +1 -1
- package/src/autocomplete/createAutocomplete.ts +117 -134
- package/src/autocomplete/index.ts +1 -1
- package/src/breadcrumbs/createBreadcrumbs.ts +33 -42
- 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 +25 -32
- package/src/button/index.ts +6 -9
- package/src/button/types.ts +18 -12
- package/src/calendar/createCalendar.ts +62 -29
- package/src/calendar/createCalendarCell.ts +98 -46
- package/src/calendar/createCalendarGrid.ts +57 -35
- package/src/calendar/createRangeCalendar.ts +66 -31
- package/src/calendar/createRangeCalendarCell.ts +92 -31
- 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 +68 -44
- 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 +33 -29
- package/src/color/createColorArea.ts +232 -154
- package/src/color/createColorField.ts +107 -58
- package/src/color/createColorSlider.ts +231 -73
- package/src/color/createColorSwatch.ts +38 -13
- package/src/color/createColorWheel.ts +208 -83
- package/src/color/index.ts +6 -6
- package/src/color/types.ts +98 -16
- package/src/combobox/createComboBox.ts +157 -100
- package/src/combobox/index.ts +1 -1
- package/src/combobox/intl/index.ts +5 -5
- package/src/datepicker/createDateField.ts +192 -39
- package/src/datepicker/createDatePicker.ts +260 -67
- package/src/datepicker/createDatePickerGroup.ts +149 -0
- package/src/datepicker/createDateRangePicker.ts +105 -57
- package/src/datepicker/createDateSegment.ts +183 -96
- package/src/datepicker/createTimeField.ts +38 -34
- package/src/datepicker/createTimeSegment.ts +67 -85
- package/src/datepicker/index.ts +13 -14
- package/src/dialog/createDialog.ts +45 -38
- package/src/dialog/index.ts +2 -2
- package/src/dialog/types.ts +4 -4
- package/src/disclosure/createDisclosure.ts +138 -33
- package/src/disclosure/createDisclosureGroup.ts +8 -21
- package/src/disclosure/index.ts +2 -2
- package/src/dnd/createDrag.ts +19 -25
- package/src/dnd/createDraggableCollection.ts +4 -4
- package/src/dnd/createDraggableItem.ts +20 -19
- package/src/dnd/createDrop.ts +42 -51
- package/src/dnd/createDroppableCollection.ts +290 -173
- package/src/dnd/createDroppableItem.ts +34 -34
- package/src/dnd/index.ts +23 -12
- package/src/dnd/types.ts +4 -7
- package/src/dnd/utils.ts +36 -49
- package/src/focus/FocusScope.tsx +155 -164
- package/src/focus/createAutoFocus.ts +4 -20
- package/src/focus/createFocusRestore.ts +15 -28
- package/src/focus/createVirtualFocus.ts +20 -36
- package/src/focus/index.ts +4 -8
- package/src/form/createFormReset.ts +4 -4
- package/src/form/createFormValidation.ts +20 -43
- package/src/form/index.ts +2 -5
- package/src/grid/GridKeyboardDelegate.ts +30 -30
- package/src/grid/createGrid.ts +36 -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 +34 -29
- 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 +5 -18
- package/src/i18n/createDateFormatter.ts +5 -13
- package/src/i18n/createFilter.ts +11 -24
- package/src/i18n/createNumberFormatter.ts +4 -6
- package/src/i18n/createStringFormatter.ts +19 -15
- package/src/i18n/index.ts +8 -11
- package/src/i18n/locale.tsx +15 -40
- package/src/i18n/utils.ts +35 -39
- package/src/index.ts +68 -169
- package/src/interactions/FocusableProvider.tsx +3 -7
- package/src/interactions/PressEvent.ts +4 -4
- package/src/interactions/createFocus.ts +12 -8
- package/src/interactions/createFocusRing.ts +21 -19
- package/src/interactions/createFocusWithin.ts +20 -13
- 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 +23 -23
- package/src/interactions/createMove.ts +72 -62
- package/src/interactions/createPress.ts +164 -87
- 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 +30 -51
- package/src/landmark/index.ts +1 -1
- package/src/link/createLink.ts +83 -56
- package/src/link/index.ts +1 -1
- package/src/listbox/createListBox.ts +69 -58
- package/src/listbox/createOption.ts +83 -37
- package/src/listbox/index.ts +2 -6
- package/src/live-announcer/announce.ts +44 -71
- package/src/live-announcer/index.ts +1 -1
- package/src/menu/createMenu.ts +79 -50
- package/src/menu/createMenuItem.ts +79 -27
- package/src/menu/createMenuTrigger.ts +15 -15
- package/src/menu/index.ts +3 -12
- package/src/meter/createMeter.ts +7 -15
- package/src/meter/index.ts +1 -1
- package/src/numberfield/createNumberField.ts +138 -81
- package/src/numberfield/index.ts +1 -1
- package/src/overlays/ariaHideOutside.ts +14 -10
- package/src/overlays/createInteractOutside.ts +21 -18
- package/src/overlays/createModal.tsx +17 -17
- package/src/overlays/createOverlay.ts +38 -8
- package/src/overlays/createOverlayTrigger.ts +16 -16
- package/src/overlays/createPreventScroll.ts +46 -24
- package/src/overlays/index.ts +6 -17
- package/src/popover/calculatePosition.ts +115 -117
- package/src/popover/createOverlayPosition.ts +46 -40
- package/src/popover/createPopover.ts +42 -17
- package/src/popover/index.ts +3 -3
- package/src/progress/createProgressBar.ts +31 -32
- package/src/progress/index.ts +1 -1
- package/src/radio/createRadio.ts +95 -73
- package/src/radio/createRadioGroup.ts +83 -77
- package/src/radio/createRadioGroupState.ts +7 -31
- package/src/radio/index.ts +3 -8
- package/src/searchfield/createSearchField.ts +57 -29
- package/src/searchfield/index.ts +2 -2
- package/src/select/createHiddenSelect.tsx +57 -44
- package/src/select/createSelect.ts +128 -71
- package/src/select/index.ts +2 -7
- 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 +93 -124
- package/src/slider/index.ts +2 -2
- package/src/ssr/index.tsx +8 -47
- 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 +152 -85
- 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 +74 -92
- package/src/tabs/index.ts +1 -1
- package/src/tag/createTag.ts +52 -50
- package/src/tag/createTagGroup.ts +47 -41
- 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 +28 -26
- package/src/toast/createToastRegion.ts +169 -26
- 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 +193 -210
- package/src/toolbar/index.ts +1 -1
- package/src/tooltip/createTooltip.ts +11 -24
- package/src/tooltip/createTooltipTrigger.ts +61 -49
- package/src/tooltip/index.ts +2 -2
- package/src/tree/createTree.ts +35 -37
- package/src/tree/createTreeItem.ts +29 -29
- package/src/tree/createTreeSelectionCheckbox.ts +11 -8
- package/src/tree/index.ts +4 -4
- package/src/tree/types.ts +10 -6
- package/src/utils/createDescription.ts +6 -23
- package/src/utils/dom.ts +61 -54
- package/src/utils/env.ts +9 -11
- 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 +2 -2
- package/src/utils/reactivity.ts +3 -3
- package/src/utils/textSelection.ts +16 -16
- package/src/visually-hidden/createVisuallyHidden.ts +16 -28
- package/src/visually-hidden/index.ts +1 -1
- package/dist/i18n/NumberFormatter.d.ts +0 -43
- package/dist/i18n/NumberFormatter.d.ts.map +0 -1
- package/dist/index.ssr.js +0 -17082
- package/dist/index.ssr.js.map +0 -1
- package/src/i18n/NumberFormatter.ts +0 -266
|
@@ -5,23 +5,24 @@
|
|
|
5
5
|
* component like ListBox, GridList, or Table.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { createMemo, onCleanup, type Accessor } from
|
|
9
|
-
import type { JSX } from
|
|
8
|
+
import { createMemo, onCleanup, type Accessor } from "solid-js";
|
|
9
|
+
import type { JSX } from "solid-js";
|
|
10
10
|
import type {
|
|
11
11
|
DroppableCollectionState,
|
|
12
12
|
DropTarget,
|
|
13
13
|
DropOperation,
|
|
14
14
|
DropItem,
|
|
15
15
|
DragTypes,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
import {
|
|
16
|
+
Key,
|
|
17
|
+
} from "@proyecto-viviana/solid-stately";
|
|
18
|
+
import { DIRECTORY_DRAG_TYPE } from "@proyecto-viviana/solid-stately";
|
|
19
|
+
import { createDrop } from "./createDrop";
|
|
19
20
|
import {
|
|
20
21
|
getGlobalDraggingCollectionRef,
|
|
21
22
|
getGlobalDraggingKeys,
|
|
22
23
|
getGlobalDraggingTypes,
|
|
23
|
-
} from
|
|
24
|
-
import { getGlobalAllowedDropOperations, DROP_OPERATION } from
|
|
24
|
+
} from "./createDraggableCollection";
|
|
25
|
+
import { getGlobalAllowedDropOperations, DROP_OPERATION } from "./utils";
|
|
25
26
|
|
|
26
27
|
// Global state for tracking the drop collection
|
|
27
28
|
let globalDropCollectionRef: HTMLElement | null = null;
|
|
@@ -41,23 +42,23 @@ export interface DropTargetDelegate {
|
|
|
41
42
|
getDropTargetFromPoint(
|
|
42
43
|
x: number,
|
|
43
44
|
y: number,
|
|
44
|
-
isValidDropTarget: (target: DropTarget) => boolean
|
|
45
|
+
isValidDropTarget: (target: DropTarget) => boolean,
|
|
45
46
|
): DropTarget | null;
|
|
46
47
|
/**
|
|
47
48
|
* Returns the next keyboard-navigable drop target.
|
|
48
49
|
*/
|
|
49
50
|
getKeyboardNavigationTarget?(
|
|
50
51
|
target: DropTarget | null,
|
|
51
|
-
direction:
|
|
52
|
-
isValidDropTarget: (target: DropTarget) => boolean
|
|
52
|
+
direction: "next" | "previous",
|
|
53
|
+
isValidDropTarget: (target: DropTarget) => boolean,
|
|
53
54
|
): DropTarget | null;
|
|
54
55
|
/**
|
|
55
56
|
* Returns the next page-navigable drop target.
|
|
56
57
|
*/
|
|
57
58
|
getKeyboardPageNavigationTarget?(
|
|
58
59
|
target: DropTarget | null,
|
|
59
|
-
direction:
|
|
60
|
-
isValidDropTarget: (target: DropTarget) => boolean
|
|
60
|
+
direction: "next" | "previous",
|
|
61
|
+
isValidDropTarget: (target: DropTarget) => boolean,
|
|
61
62
|
): DropTarget | null;
|
|
62
63
|
}
|
|
63
64
|
|
|
@@ -72,17 +73,26 @@ export interface KeyboardDelegateLike {
|
|
|
72
73
|
getKeyPageAbove?: (key: string | number) => string | number | null;
|
|
73
74
|
}
|
|
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
|
+
|
|
75
89
|
export interface DroppableCollectionOptions {
|
|
76
90
|
/** Reference to the collection element. */
|
|
77
91
|
ref: Accessor<HTMLElement | null>;
|
|
78
92
|
/** A delegate that provides drop targets for pointer coordinates. */
|
|
79
93
|
dropTargetDelegate: DropTargetDelegate;
|
|
80
94
|
/** Handler called when items are dropped to be inserted. */
|
|
81
|
-
onInsert?: (e: {
|
|
82
|
-
items: DropItem[];
|
|
83
|
-
target: DropTarget;
|
|
84
|
-
dropOperation: DropOperation;
|
|
85
|
-
}) => void;
|
|
95
|
+
onInsert?: (e: { items: DropItem[]; target: DropTarget; dropOperation: DropOperation }) => void;
|
|
86
96
|
/** Handler called when items are dropped on the root. */
|
|
87
97
|
onRootDrop?: (e: { items: DropItem[]; dropOperation: DropOperation }) => void;
|
|
88
98
|
/** Handler called when items are dropped on an item. */
|
|
@@ -118,17 +128,25 @@ export interface DroppableCollectionOptions {
|
|
|
118
128
|
keyboardDelegate?: KeyboardDelegateLike;
|
|
119
129
|
/** Optional keyboard handler composed with internal drop target navigation keys. */
|
|
120
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;
|
|
121
139
|
/** Whether the collection is disabled for dropping. */
|
|
122
140
|
isDisabled?: boolean;
|
|
123
141
|
/** Accepted drag types. 'all' accepts any type. */
|
|
124
|
-
acceptedDragTypes?:
|
|
142
|
+
acceptedDragTypes?: "all" | Array<string | symbol>;
|
|
125
143
|
}
|
|
126
144
|
|
|
127
145
|
export function getDropItemTypes(item: DropItem): Set<string | symbol> {
|
|
128
|
-
if (item.kind ===
|
|
146
|
+
if (item.kind === "file") {
|
|
129
147
|
return new Set([item.type]);
|
|
130
148
|
}
|
|
131
|
-
if (item.kind ===
|
|
149
|
+
if (item.kind === "text") {
|
|
132
150
|
return new Set(item.types);
|
|
133
151
|
}
|
|
134
152
|
return new Set([DIRECTORY_DRAG_TYPE]);
|
|
@@ -148,7 +166,7 @@ export interface DroppableCollectionAria {
|
|
|
148
166
|
*/
|
|
149
167
|
export function createDroppableCollection(
|
|
150
168
|
options: Accessor<DroppableCollectionOptions>,
|
|
151
|
-
state: DroppableCollectionState
|
|
169
|
+
state: DroppableCollectionState,
|
|
152
170
|
): DroppableCollectionAria {
|
|
153
171
|
const getOptions = createMemo(() => options());
|
|
154
172
|
|
|
@@ -165,7 +183,7 @@ export function createDroppableCollection(
|
|
|
165
183
|
const getDropOperationForTarget = (
|
|
166
184
|
target: DropTarget,
|
|
167
185
|
types: DragTypes,
|
|
168
|
-
allowedOperations: DropOperation[]
|
|
186
|
+
allowedOperations: DropOperation[],
|
|
169
187
|
): DropOperation => {
|
|
170
188
|
return state.getDropOperation(target, types, allowedOperations);
|
|
171
189
|
};
|
|
@@ -176,35 +194,23 @@ export function createDroppableCollection(
|
|
|
176
194
|
getDropOperationForPoint: (types, allowedOperations, x, y) => {
|
|
177
195
|
const opts = getOptions();
|
|
178
196
|
const isValidDropTarget = (target: DropTarget) =>
|
|
179
|
-
getDropOperationForTarget(target, types, allowedOperations) !==
|
|
197
|
+
getDropOperationForTarget(target, types, allowedOperations) !== "cancel";
|
|
180
198
|
|
|
181
|
-
const target = opts.dropTargetDelegate.getDropTargetFromPoint(
|
|
182
|
-
x,
|
|
183
|
-
y,
|
|
184
|
-
isValidDropTarget
|
|
185
|
-
);
|
|
199
|
+
const target = opts.dropTargetDelegate.getDropTargetFromPoint(x, y, isValidDropTarget);
|
|
186
200
|
|
|
187
201
|
if (!target) {
|
|
188
|
-
currentDropOperation =
|
|
202
|
+
currentDropOperation = "cancel";
|
|
189
203
|
nextTarget = null;
|
|
190
|
-
return
|
|
204
|
+
return "cancel";
|
|
191
205
|
}
|
|
192
206
|
|
|
193
|
-
currentDropOperation = getDropOperationForTarget(
|
|
194
|
-
target,
|
|
195
|
-
types,
|
|
196
|
-
allowedOperations
|
|
197
|
-
);
|
|
207
|
+
currentDropOperation = getDropOperationForTarget(target, types, allowedOperations);
|
|
198
208
|
|
|
199
209
|
// If target doesn't accept, try root
|
|
200
|
-
if (currentDropOperation ===
|
|
201
|
-
const rootTarget: DropTarget = { type:
|
|
202
|
-
const rootOp = getDropOperationForTarget(
|
|
203
|
-
|
|
204
|
-
types,
|
|
205
|
-
allowedOperations
|
|
206
|
-
);
|
|
207
|
-
if (rootOp !== 'cancel') {
|
|
210
|
+
if (currentDropOperation === "cancel") {
|
|
211
|
+
const rootTarget: DropTarget = { type: "root" };
|
|
212
|
+
const rootOp = getDropOperationForTarget(rootTarget, types, allowedOperations);
|
|
213
|
+
if (rootOp !== "cancel") {
|
|
208
214
|
nextTarget = rootTarget;
|
|
209
215
|
currentDropOperation = rootOp;
|
|
210
216
|
return currentDropOperation;
|
|
@@ -213,11 +219,11 @@ export function createDroppableCollection(
|
|
|
213
219
|
|
|
214
220
|
// Update drop collection ref
|
|
215
221
|
const ref = opts.ref();
|
|
216
|
-
if (target && currentDropOperation !==
|
|
222
|
+
if (target && currentDropOperation !== "cancel" && ref !== globalDropCollectionRef) {
|
|
217
223
|
setGlobalDropCollectionRef(ref);
|
|
218
224
|
}
|
|
219
225
|
|
|
220
|
-
nextTarget = currentDropOperation ===
|
|
226
|
+
nextTarget = currentDropOperation === "cancel" ? null : target;
|
|
221
227
|
return currentDropOperation;
|
|
222
228
|
},
|
|
223
229
|
onDropEnter: () => {
|
|
@@ -237,9 +243,9 @@ export function createDroppableCollection(
|
|
|
237
243
|
onDropActivate: (e) => {
|
|
238
244
|
const opts = getOptions();
|
|
239
245
|
if (
|
|
240
|
-
state.target?.type ===
|
|
241
|
-
state.target.dropPosition ===
|
|
242
|
-
typeof opts.onDropActivate ===
|
|
246
|
+
state.target?.type === "item" &&
|
|
247
|
+
state.target.dropPosition === "on" &&
|
|
248
|
+
typeof opts.onDropActivate === "function"
|
|
243
249
|
) {
|
|
244
250
|
opts.onDropActivate({
|
|
245
251
|
target: state.target,
|
|
@@ -253,14 +259,21 @@ export function createDroppableCollection(
|
|
|
253
259
|
setGlobalDropCollectionRef(opts.ref());
|
|
254
260
|
|
|
255
261
|
if (state.target) {
|
|
262
|
+
const target = state.target;
|
|
263
|
+
const previousCollection = opts.collection;
|
|
264
|
+
const previousSelectedKeys = normalizeSelection(opts.selectedKeys);
|
|
256
265
|
opts.onDrop?.({
|
|
257
266
|
items: e.items,
|
|
258
|
-
target
|
|
267
|
+
target,
|
|
259
268
|
dropOperation: e.dropOperation,
|
|
260
269
|
x: e.x,
|
|
261
270
|
y: e.y,
|
|
262
271
|
});
|
|
263
|
-
handleDrop(e.items,
|
|
272
|
+
void Promise.resolve(handleDrop(e.items, target, e.dropOperation)).then(() => {
|
|
273
|
+
queueMicrotask(() => {
|
|
274
|
+
updateFocusAfterDrop(getOptions(), previousCollection, previousSelectedKeys, target);
|
|
275
|
+
});
|
|
276
|
+
});
|
|
264
277
|
}
|
|
265
278
|
},
|
|
266
279
|
}));
|
|
@@ -268,7 +281,7 @@ export function createDroppableCollection(
|
|
|
268
281
|
const handleDrop = async (
|
|
269
282
|
items: DropItem[],
|
|
270
283
|
target: DropTarget,
|
|
271
|
-
dropOperation: DropOperation
|
|
284
|
+
dropOperation: DropOperation,
|
|
272
285
|
) => {
|
|
273
286
|
const opts = getOptions();
|
|
274
287
|
const isInternal = isInternalDropOperation();
|
|
@@ -276,7 +289,7 @@ export function createDroppableCollection(
|
|
|
276
289
|
// Filter items by accepted types
|
|
277
290
|
let filteredItems = items;
|
|
278
291
|
const acceptedTypes = opts.acceptedDragTypes;
|
|
279
|
-
if (acceptedTypes && acceptedTypes !==
|
|
292
|
+
if (acceptedTypes && acceptedTypes !== "all") {
|
|
280
293
|
filteredItems = items.filter((item) => {
|
|
281
294
|
const itemTypes = getDropItemTypes(item);
|
|
282
295
|
return acceptedTypes.some((type) => itemTypes.has(type));
|
|
@@ -286,12 +299,12 @@ export function createDroppableCollection(
|
|
|
286
299
|
if (filteredItems.length === 0) return;
|
|
287
300
|
|
|
288
301
|
// Call appropriate handlers based on target type
|
|
289
|
-
if (target.type ===
|
|
302
|
+
if (target.type === "root" && opts.onRootDrop) {
|
|
290
303
|
await opts.onRootDrop({ items: filteredItems, dropOperation });
|
|
291
304
|
}
|
|
292
305
|
|
|
293
|
-
if (target.type ===
|
|
294
|
-
if (target.dropPosition ===
|
|
306
|
+
if (target.type === "item") {
|
|
307
|
+
if (target.dropPosition === "on" && opts.onItemDrop) {
|
|
295
308
|
await opts.onItemDrop({
|
|
296
309
|
items: filteredItems,
|
|
297
310
|
target,
|
|
@@ -310,7 +323,7 @@ export function createDroppableCollection(
|
|
|
310
323
|
});
|
|
311
324
|
}
|
|
312
325
|
|
|
313
|
-
if (target.dropPosition !==
|
|
326
|
+
if (target.dropPosition !== "on") {
|
|
314
327
|
if (!isInternal && opts.onInsert) {
|
|
315
328
|
await opts.onInsert({
|
|
316
329
|
items: filteredItems,
|
|
@@ -346,26 +359,30 @@ export function createDroppableCollection(
|
|
|
346
359
|
onKeyDownBase?.(e);
|
|
347
360
|
const opts = getOptions();
|
|
348
361
|
if (opts.isDisabled) return;
|
|
349
|
-
const resolveDirection = ():
|
|
362
|
+
const resolveDirection = (): "ltr" | "rtl" => {
|
|
350
363
|
const refEl = opts.ref();
|
|
351
|
-
if (
|
|
364
|
+
if (
|
|
365
|
+
refEl &&
|
|
366
|
+
typeof window !== "undefined" &&
|
|
367
|
+
typeof window.getComputedStyle === "function"
|
|
368
|
+
) {
|
|
352
369
|
const computedDir = window.getComputedStyle(refEl).direction;
|
|
353
|
-
if (computedDir ===
|
|
370
|
+
if (computedDir === "rtl") return "rtl";
|
|
354
371
|
}
|
|
355
|
-
return typeof document !==
|
|
372
|
+
return typeof document !== "undefined" && document.dir === "rtl" ? "rtl" : "ltr";
|
|
356
373
|
};
|
|
357
|
-
const isRtl = resolveDirection() ===
|
|
358
|
-
const forwardHorizontalKey = isRtl ?
|
|
359
|
-
const backwardHorizontalKey = isRtl ?
|
|
374
|
+
const isRtl = resolveDirection() === "rtl";
|
|
375
|
+
const forwardHorizontalKey = isRtl ? "ArrowLeft" : "ArrowRight";
|
|
376
|
+
const backwardHorizontalKey = isRtl ? "ArrowRight" : "ArrowLeft";
|
|
360
377
|
const callUserOnKeyDown = () => opts.onKeyDown?.(e);
|
|
361
378
|
const getKeyboardAllowedOperations = (): DropOperation[] => {
|
|
362
379
|
const allowedBits = getGlobalAllowedDropOperations();
|
|
363
|
-
if (!allowedBits) return [
|
|
380
|
+
if (!allowedBits) return ["copy", "move", "link"];
|
|
364
381
|
const allowed: DropOperation[] = [];
|
|
365
|
-
if (allowedBits & DROP_OPERATION.copy) allowed.push(
|
|
366
|
-
if (allowedBits & DROP_OPERATION.move) allowed.push(
|
|
367
|
-
if (allowedBits & DROP_OPERATION.link) allowed.push(
|
|
368
|
-
return allowed.length > 0 ? allowed : [
|
|
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"];
|
|
369
386
|
};
|
|
370
387
|
const getKeyboardDragTypes = (): DragTypes => {
|
|
371
388
|
const draggingTypes = getGlobalDraggingTypes();
|
|
@@ -373,20 +390,21 @@ export function createDroppableCollection(
|
|
|
373
390
|
return { has: () => true };
|
|
374
391
|
}
|
|
375
392
|
return {
|
|
376
|
-
has: (type: string | symbol) => typeof type ===
|
|
393
|
+
has: (type: string | symbol) => typeof type === "string" && draggingTypes.has(type),
|
|
377
394
|
};
|
|
378
395
|
};
|
|
379
396
|
const isValidDropTarget = (target: DropTarget) =>
|
|
380
|
-
state.getDropOperation(target, getKeyboardDragTypes(), getKeyboardAllowedOperations()) !==
|
|
397
|
+
state.getDropOperation(target, getKeyboardDragTypes(), getKeyboardAllowedOperations()) !==
|
|
398
|
+
"cancel";
|
|
381
399
|
const targetsEqual = (a: DropTarget, b: DropTarget): boolean => {
|
|
382
400
|
if (a.type !== b.type) return false;
|
|
383
|
-
if (a.type ===
|
|
384
|
-
if (a.type !==
|
|
401
|
+
if (a.type === "root" && b.type === "root") return true;
|
|
402
|
+
if (a.type !== "item" || b.type !== "item") return false;
|
|
385
403
|
return a.key === b.key && a.dropPosition === b.dropPosition;
|
|
386
404
|
};
|
|
387
405
|
const findNextValidTarget = (
|
|
388
406
|
start: DropTarget | null,
|
|
389
|
-
getNext: (target: DropTarget | null) => DropTarget | null
|
|
407
|
+
getNext: (target: DropTarget | null) => DropTarget | null,
|
|
390
408
|
): DropTarget | null => {
|
|
391
409
|
let current = start;
|
|
392
410
|
let seenRoot = 0;
|
|
@@ -399,7 +417,7 @@ export function createDroppableCollection(
|
|
|
399
417
|
return isValidDropTarget(next) ? next : null;
|
|
400
418
|
}
|
|
401
419
|
current = next;
|
|
402
|
-
if (next.type ===
|
|
420
|
+
if (next.type === "root") {
|
|
403
421
|
seenRoot += 1;
|
|
404
422
|
if (seenRoot >= 2) {
|
|
405
423
|
return isValidDropTarget(next) ? next : null;
|
|
@@ -411,49 +429,48 @@ export function createDroppableCollection(
|
|
|
411
429
|
};
|
|
412
430
|
const resolveTargetForKey = (
|
|
413
431
|
key: string | number | null,
|
|
414
|
-
direction:
|
|
432
|
+
direction: "next" | "previous",
|
|
415
433
|
): DropTarget | null => {
|
|
416
434
|
if (key == null) return null;
|
|
417
|
-
const onTarget: DropTarget = { type:
|
|
435
|
+
const onTarget: DropTarget = { type: "item", key, dropPosition: "on" };
|
|
418
436
|
if (isValidDropTarget(onTarget)) return onTarget;
|
|
419
|
-
const insertionOrder: Array<
|
|
420
|
-
? [
|
|
421
|
-
: ['after', 'before'];
|
|
437
|
+
const insertionOrder: Array<"before" | "after"> =
|
|
438
|
+
direction === "next" ? ["before", "after"] : ["after", "before"];
|
|
422
439
|
for (const position of insertionOrder) {
|
|
423
|
-
const insertionTarget: DropTarget = { type:
|
|
440
|
+
const insertionTarget: DropTarget = { type: "item", key, dropPosition: position };
|
|
424
441
|
if (isValidDropTarget(insertionTarget)) return insertionTarget;
|
|
425
442
|
}
|
|
426
443
|
return null;
|
|
427
444
|
};
|
|
428
445
|
const resolveBoundaryTargetForDirection = (
|
|
429
446
|
key: string | number | null,
|
|
430
|
-
direction:
|
|
447
|
+
direction: "next" | "previous",
|
|
431
448
|
): DropTarget | null => {
|
|
432
449
|
if (key == null) return null;
|
|
433
|
-
const boundaryOrder: Array<
|
|
434
|
-
? [
|
|
435
|
-
: ['after', 'on', 'before'];
|
|
450
|
+
const boundaryOrder: Array<"before" | "on" | "after"> =
|
|
451
|
+
direction === "next" ? ["before", "on", "after"] : ["after", "on", "before"];
|
|
436
452
|
for (const position of boundaryOrder) {
|
|
437
|
-
const candidate: DropTarget = { type:
|
|
453
|
+
const candidate: DropTarget = { type: "item", key, dropPosition: position };
|
|
438
454
|
if (isValidDropTarget(candidate)) return candidate;
|
|
439
455
|
}
|
|
440
456
|
return null;
|
|
441
457
|
};
|
|
442
458
|
const resolveFallbackKeyboardTarget = (
|
|
443
459
|
keyName: string,
|
|
444
|
-
currentTarget: DropTarget | null = state.target
|
|
460
|
+
currentTarget: DropTarget | null = state.target,
|
|
445
461
|
): DropTarget | null => {
|
|
446
462
|
const keyboardDelegate = opts.keyboardDelegate;
|
|
447
463
|
if (!keyboardDelegate) return null;
|
|
448
|
-
const currentKey = currentTarget?.type ===
|
|
464
|
+
const currentKey = currentTarget?.type === "item" ? currentTarget.key : null;
|
|
449
465
|
const keyForDirection = (
|
|
450
|
-
direction:
|
|
451
|
-
getter: ((key: string | number) => string | number | null) | undefined
|
|
466
|
+
direction: "next" | "previous",
|
|
467
|
+
getter: ((key: string | number) => string | number | null) | undefined,
|
|
452
468
|
): DropTarget | null => {
|
|
453
469
|
if (currentKey == null) {
|
|
454
|
-
const boundaryKey =
|
|
455
|
-
|
|
456
|
-
|
|
470
|
+
const boundaryKey =
|
|
471
|
+
direction === "next"
|
|
472
|
+
? keyboardDelegate.getFirstKey?.()
|
|
473
|
+
: keyboardDelegate.getLastKey?.();
|
|
457
474
|
return resolveBoundaryTargetForDirection(boundaryKey ?? null, direction);
|
|
458
475
|
}
|
|
459
476
|
if (!getter) return null;
|
|
@@ -470,113 +487,132 @@ export function createDroppableCollection(
|
|
|
470
487
|
return null;
|
|
471
488
|
};
|
|
472
489
|
|
|
473
|
-
if (keyName ===
|
|
474
|
-
if (keyName ===
|
|
490
|
+
if (keyName === "ArrowDown") return keyForDirection("next", keyboardDelegate.getKeyBelow);
|
|
491
|
+
if (keyName === "ArrowUp") return keyForDirection("previous", keyboardDelegate.getKeyAbove);
|
|
475
492
|
if (keyName === forwardHorizontalKey) {
|
|
476
|
-
return keyForDirection(
|
|
493
|
+
return keyForDirection(
|
|
494
|
+
"next",
|
|
495
|
+
isRtl ? keyboardDelegate.getKeyLeftOf : keyboardDelegate.getKeyRightOf,
|
|
496
|
+
);
|
|
477
497
|
}
|
|
478
498
|
if (keyName === backwardHorizontalKey) {
|
|
479
|
-
return keyForDirection(
|
|
499
|
+
return keyForDirection(
|
|
500
|
+
"previous",
|
|
501
|
+
isRtl ? keyboardDelegate.getKeyRightOf : keyboardDelegate.getKeyLeftOf,
|
|
502
|
+
);
|
|
480
503
|
}
|
|
481
|
-
if (keyName ===
|
|
482
|
-
|
|
483
|
-
|
|
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") {
|
|
484
515
|
if (currentKey != null && keyboardDelegate.getKeyPageBelow) {
|
|
485
|
-
return resolveTargetForKey(keyboardDelegate.getKeyPageBelow(currentKey),
|
|
516
|
+
return resolveTargetForKey(keyboardDelegate.getKeyPageBelow(currentKey), "next");
|
|
486
517
|
}
|
|
487
|
-
return keyForDirection(
|
|
518
|
+
return keyForDirection("next", keyboardDelegate.getKeyBelow);
|
|
488
519
|
}
|
|
489
|
-
if (keyName ===
|
|
520
|
+
if (keyName === "PageUp") {
|
|
490
521
|
if (currentKey != null && keyboardDelegate.getKeyPageAbove) {
|
|
491
|
-
return resolveTargetForKey(keyboardDelegate.getKeyPageAbove(currentKey),
|
|
522
|
+
return resolveTargetForKey(keyboardDelegate.getKeyPageAbove(currentKey), "previous");
|
|
492
523
|
}
|
|
493
|
-
return keyForDirection(
|
|
524
|
+
return keyForDirection("previous", keyboardDelegate.getKeyAbove);
|
|
494
525
|
}
|
|
495
526
|
return null;
|
|
496
527
|
};
|
|
497
528
|
const resolvePageTargetForState = (
|
|
498
|
-
direction:
|
|
499
|
-
currentTarget: DropTarget
|
|
529
|
+
direction: "next" | "previous",
|
|
530
|
+
currentTarget: DropTarget,
|
|
500
531
|
): DropTarget | null => {
|
|
501
532
|
const keyboardDelegate = opts.keyboardDelegate;
|
|
502
533
|
if (!keyboardDelegate) return null;
|
|
503
|
-
if (direction ===
|
|
534
|
+
if (direction === "next") {
|
|
504
535
|
let targetKey = keyboardDelegate.getFirstKey?.() ?? null;
|
|
505
|
-
let dropPosition:
|
|
506
|
-
if (currentTarget.type ===
|
|
536
|
+
let dropPosition: "before" | "on" | "after" = "after";
|
|
537
|
+
if (currentTarget.type === "item") {
|
|
507
538
|
targetKey = currentTarget.key;
|
|
508
539
|
dropPosition = currentTarget.dropPosition;
|
|
509
540
|
}
|
|
510
|
-
let nextKey =
|
|
541
|
+
let nextKey =
|
|
542
|
+
targetKey != null ? (keyboardDelegate.getKeyPageBelow?.(targetKey) ?? null) : null;
|
|
511
543
|
if (
|
|
512
544
|
nextKey == null ||
|
|
513
|
-
(currentTarget.type ===
|
|
545
|
+
(currentTarget.type === "item" && currentTarget.key === keyboardDelegate.getLastKey?.())
|
|
514
546
|
) {
|
|
515
547
|
nextKey = keyboardDelegate.getLastKey?.() ?? null;
|
|
516
|
-
dropPosition =
|
|
548
|
+
dropPosition = "after";
|
|
517
549
|
}
|
|
518
550
|
if (nextKey == null) return null;
|
|
519
551
|
return {
|
|
520
|
-
type:
|
|
552
|
+
type: "item",
|
|
521
553
|
key: nextKey,
|
|
522
554
|
dropPosition,
|
|
523
555
|
};
|
|
524
556
|
}
|
|
525
557
|
|
|
526
|
-
if (currentTarget.type ===
|
|
558
|
+
if (currentTarget.type === "item") {
|
|
527
559
|
if (currentTarget.key === keyboardDelegate.getFirstKey?.()) {
|
|
528
|
-
return { type:
|
|
560
|
+
return { type: "root" };
|
|
529
561
|
}
|
|
530
562
|
let nextKey = keyboardDelegate.getKeyPageAbove?.(currentTarget.key) ?? null;
|
|
531
|
-
let dropPosition:
|
|
563
|
+
let dropPosition: "before" | "on" | "after" = currentTarget.dropPosition;
|
|
532
564
|
if (nextKey == null) {
|
|
533
565
|
nextKey = keyboardDelegate.getFirstKey?.() ?? null;
|
|
534
|
-
dropPosition =
|
|
566
|
+
dropPosition = "before";
|
|
535
567
|
}
|
|
536
568
|
if (nextKey == null) return null;
|
|
537
569
|
return {
|
|
538
|
-
type:
|
|
570
|
+
type: "item",
|
|
539
571
|
key: nextKey,
|
|
540
572
|
dropPosition,
|
|
541
573
|
};
|
|
542
574
|
}
|
|
543
575
|
|
|
544
|
-
return currentTarget.type ===
|
|
576
|
+
return currentTarget.type === "root" ? currentTarget : null;
|
|
545
577
|
};
|
|
546
|
-
if (e.key ===
|
|
578
|
+
if (e.key === "PageDown" || e.key === "PageUp") {
|
|
547
579
|
if (
|
|
548
|
-
(e.key ===
|
|
549
|
-
(e.key ===
|
|
580
|
+
(e.key === "PageDown" && !opts.keyboardDelegate?.getKeyPageBelow) ||
|
|
581
|
+
(e.key === "PageUp" && !opts.keyboardDelegate?.getKeyPageAbove)
|
|
550
582
|
) {
|
|
551
583
|
callUserOnKeyDown();
|
|
552
584
|
return;
|
|
553
585
|
}
|
|
554
|
-
const direction = e.key ===
|
|
586
|
+
const direction = e.key === "PageDown" ? "next" : "previous";
|
|
555
587
|
const pageNavigation = opts.dropTargetDelegate.getKeyboardPageNavigationTarget;
|
|
556
588
|
const stepNavigation = opts.dropTargetDelegate.getKeyboardNavigationTarget;
|
|
557
589
|
const resolveStepTarget = (
|
|
558
590
|
target: DropTarget | null,
|
|
559
|
-
navDirection:
|
|
591
|
+
navDirection: "next" | "previous",
|
|
560
592
|
): DropTarget | null =>
|
|
561
|
-
stepNavigation?.(target, navDirection, isValidDropTarget)
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
593
|
+
stepNavigation?.(target, navDirection, isValidDropTarget) ??
|
|
594
|
+
resolveFallbackKeyboardTarget(
|
|
595
|
+
navDirection === "next" ? "ArrowDown" : "ArrowUp",
|
|
596
|
+
target,
|
|
597
|
+
) ??
|
|
598
|
+
resolveFallbackKeyboardTarget(navDirection === "next" ? "Home" : "End", target) ??
|
|
599
|
+
null;
|
|
565
600
|
let nextTarget: DropTarget | null = null;
|
|
566
601
|
if (!state.target) {
|
|
567
602
|
nextTarget = findNextValidTarget(null, (target) => resolveStepTarget(target, direction));
|
|
568
603
|
} else {
|
|
569
|
-
const pageTarget =
|
|
570
|
-
|
|
571
|
-
??
|
|
604
|
+
const pageTarget =
|
|
605
|
+
pageNavigation?.(state.target, direction, isValidDropTarget) ??
|
|
606
|
+
resolvePageTargetForState(direction, state.target) ??
|
|
607
|
+
null;
|
|
572
608
|
if (pageTarget && isValidDropTarget(pageTarget)) {
|
|
573
609
|
nextTarget = pageTarget;
|
|
574
610
|
} else {
|
|
575
611
|
const startTarget = pageTarget ?? state.target;
|
|
576
|
-
nextTarget =
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
612
|
+
nextTarget =
|
|
613
|
+
findNextValidTarget(startTarget, (target) => resolveStepTarget(target, direction)) ??
|
|
614
|
+
findNextValidTarget(startTarget, (target) =>
|
|
615
|
+
resolveStepTarget(target, direction === "next" ? "previous" : "next"),
|
|
580
616
|
);
|
|
581
617
|
}
|
|
582
618
|
}
|
|
@@ -588,34 +624,37 @@ export function createDroppableCollection(
|
|
|
588
624
|
return;
|
|
589
625
|
}
|
|
590
626
|
if (
|
|
591
|
-
(e.key ===
|
|
592
|
-
e.key ===
|
|
593
|
-
e.key ===
|
|
594
|
-
e.key ===
|
|
595
|
-
e.key ===
|
|
596
|
-
e.key ===
|
|
627
|
+
(e.key === "ArrowDown" ||
|
|
628
|
+
e.key === "ArrowUp" ||
|
|
629
|
+
e.key === "ArrowRight" ||
|
|
630
|
+
e.key === "ArrowLeft" ||
|
|
631
|
+
e.key === "Home" ||
|
|
632
|
+
e.key === "End") &&
|
|
597
633
|
opts.dropTargetDelegate.getKeyboardNavigationTarget
|
|
598
634
|
) {
|
|
599
635
|
if (
|
|
600
|
-
(e.key ===
|
|
601
|
-
(e.key ===
|
|
602
|
-
(e.key ===
|
|
603
|
-
(e.key ===
|
|
604
|
-
(e.key ===
|
|
605
|
-
(e.key ===
|
|
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)
|
|
606
642
|
) {
|
|
607
643
|
callUserOnKeyDown();
|
|
608
644
|
return;
|
|
609
645
|
}
|
|
610
|
-
const isForwardKey =
|
|
611
|
-
|
|
612
|
-
const
|
|
613
|
-
const
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
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),
|
|
619
658
|
);
|
|
620
659
|
if (nextTarget) {
|
|
621
660
|
e.preventDefault();
|
|
@@ -625,27 +664,27 @@ export function createDroppableCollection(
|
|
|
625
664
|
return;
|
|
626
665
|
}
|
|
627
666
|
if (
|
|
628
|
-
e.key ===
|
|
629
|
-
e.key ===
|
|
630
|
-
e.key ===
|
|
631
|
-
e.key ===
|
|
632
|
-
e.key ===
|
|
633
|
-
e.key ===
|
|
667
|
+
e.key === "ArrowDown" ||
|
|
668
|
+
e.key === "ArrowUp" ||
|
|
669
|
+
e.key === "ArrowRight" ||
|
|
670
|
+
e.key === "ArrowLeft" ||
|
|
671
|
+
e.key === "Home" ||
|
|
672
|
+
e.key === "End"
|
|
634
673
|
) {
|
|
635
674
|
if (
|
|
636
|
-
(e.key ===
|
|
637
|
-
(e.key ===
|
|
638
|
-
(e.key ===
|
|
639
|
-
(e.key ===
|
|
640
|
-
(e.key ===
|
|
641
|
-
(e.key ===
|
|
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)
|
|
642
681
|
) {
|
|
643
682
|
callUserOnKeyDown();
|
|
644
683
|
return;
|
|
645
684
|
}
|
|
646
|
-
const navigationStart = e.key ===
|
|
685
|
+
const navigationStart = e.key === "Home" || e.key === "End" ? null : state.target;
|
|
647
686
|
const nextTarget = findNextValidTarget(navigationStart, (target) =>
|
|
648
|
-
resolveFallbackKeyboardTarget(e.key, target)
|
|
687
|
+
resolveFallbackKeyboardTarget(e.key, target),
|
|
649
688
|
);
|
|
650
689
|
if (nextTarget) {
|
|
651
690
|
e.preventDefault();
|
|
@@ -654,13 +693,13 @@ export function createDroppableCollection(
|
|
|
654
693
|
callUserOnKeyDown();
|
|
655
694
|
return;
|
|
656
695
|
}
|
|
657
|
-
if (e.key ===
|
|
696
|
+
if (e.key === "Enter" && state.target) {
|
|
658
697
|
e.preventDefault();
|
|
659
698
|
state.activateTarget(0, 0);
|
|
660
699
|
callUserOnKeyDown();
|
|
661
700
|
return;
|
|
662
701
|
}
|
|
663
|
-
if (e.key ===
|
|
702
|
+
if (e.key === "Escape" && state.target) {
|
|
664
703
|
e.preventDefault();
|
|
665
704
|
state.exitTarget(0, 0);
|
|
666
705
|
callUserOnKeyDown();
|
|
@@ -676,7 +715,85 @@ export function createDroppableCollection(
|
|
|
676
715
|
|
|
677
716
|
return {
|
|
678
717
|
get collectionProps() {
|
|
679
|
-
return collectionProps() as DroppableCollectionAria[
|
|
718
|
+
return collectionProps() as DroppableCollectionAria["collectionProps"];
|
|
680
719
|
},
|
|
681
720
|
};
|
|
682
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
|
+
}
|