hys-ui 0.5.0 → 0.7.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/CHANGELOG.md +16 -0
- package/LICENSE +19 -0
- package/dist/components/HysDataGrid/HysDataGrid.vue.js +1 -1
- package/dist/components/HysDataGrid/HysDataGrid2.vue.js +1055 -753
- package/dist/components/HysDataGrid/gridColumnLayout.js +46 -0
- package/dist/components/HysDataGrid/gridPresentation.js +17 -0
- package/dist/components/HysDataGrid/useGridContextMenu.js +33 -0
- package/dist/components/HysDescriptions/HysDescriptions.vue.js +7 -0
- package/dist/components/HysDescriptions/HysDescriptions2.vue.js +146 -0
- package/dist/components/HysDrawer/HysDrawer.vue.js +1 -1
- package/dist/components/HysDrawer/HysDrawer2.vue.js +2 -2
- package/dist/components/HysForm/HysForm2.vue.js +9 -8
- package/dist/components/HysIcon/HysIcon.vue.js +373 -0
- package/dist/components/HysIcon/HysIcon2.vue.js +5 -0
- package/dist/components/HysIcon/IconGraphic/IconGraphic.vue.js +147 -0
- package/dist/components/HysIcon/IconGraphic/IconGraphic2.vue.js +4 -0
- package/dist/components/HysIcon/IconPickerPanel/IconPickerPanel.vue.js +7 -0
- package/dist/components/HysIcon/IconPickerPanel/IconPickerPanel2.vue.js +440 -0
- package/dist/components/HysIcon/IconReferenceGraphic/IconReferenceGraphic.vue.js +29 -0
- package/dist/components/HysIcon/IconReferenceGraphic/IconReferenceGraphic2.vue.js +4 -0
- package/dist/components/HysIcon/IconTooltip/IconTooltip.vue.js +19 -0
- package/dist/components/HysIcon/IconTooltip/IconTooltip2.vue.js +4 -0
- package/dist/components/HysIcon/builtins/access.js +180 -0
- package/dist/components/HysIcon/builtins/actions.js +327 -0
- package/dist/components/HysIcon/builtins/business.js +364 -0
- package/dist/components/HysIcon/builtins/catalog/access-1.json.js +51 -0
- package/dist/components/HysIcon/builtins/catalog/access-2.json.js +35 -0
- package/dist/components/HysIcon/builtins/catalog/accessibility.json.js +26 -0
- package/dist/components/HysIcon/builtins/catalog/arrows-1.json.js +45 -0
- package/dist/components/HysIcon/builtins/catalog/arrows-2.json.js +46 -0
- package/dist/components/HysIcon/builtins/catalog/arrows-3.json.js +42 -0
- package/dist/components/HysIcon/builtins/catalog/charts-1.json.js +50 -0
- package/dist/components/HysIcon/builtins/catalog/charts-2.json.js +13 -0
- package/dist/components/HysIcon/builtins/catalog/commerce.json.js +43 -0
- package/dist/components/HysIcon/builtins/catalog/communication-1.json.js +49 -0
- package/dist/components/HysIcon/builtins/catalog/communication-2.json.js +37 -0
- package/dist/components/HysIcon/builtins/catalog/design-1.json.js +61 -0
- package/dist/components/HysIcon/builtins/catalog/design-2.json.js +27 -0
- package/dist/components/HysIcon/builtins/catalog/development-1.json.js +58 -0
- package/dist/components/HysIcon/builtins/catalog/development-2.json.js +60 -0
- package/dist/components/HysIcon/builtins/catalog/development-3.json.js +25 -0
- package/dist/components/HysIcon/builtins/catalog/devices-1.json.js +52 -0
- package/dist/components/HysIcon/builtins/catalog/devices-2.json.js +55 -0
- package/dist/components/HysIcon/builtins/catalog/devices-3.json.js +23 -0
- package/dist/components/HysIcon/builtins/catalog/education.json.js +34 -0
- package/dist/components/HysIcon/builtins/catalog/emoji.json.js +24 -0
- package/dist/components/HysIcon/builtins/catalog/files-1.json.js +45 -0
- package/dist/components/HysIcon/builtins/catalog/files-2.json.js +47 -0
- package/dist/components/HysIcon/builtins/catalog/files-3.json.js +8 -0
- package/dist/components/HysIcon/builtins/catalog/food-1.json.js +67 -0
- package/dist/components/HysIcon/builtins/catalog/food-2.json.js +40 -0
- package/dist/components/HysIcon/builtins/catalog/home.json.js +36 -0
- package/dist/components/HysIcon/builtins/catalog/layout-1.json.js +46 -0
- package/dist/components/HysIcon/builtins/catalog/layout-2.json.js +45 -0
- package/dist/components/HysIcon/builtins/catalog/manifest.json.js +4 -0
- package/dist/components/HysIcon/builtins/catalog/maps-1.json.js +61 -0
- package/dist/components/HysIcon/builtins/catalog/maps-2.json.js +24 -0
- package/dist/components/HysIcon/builtins/catalog/media-1.json.js +57 -0
- package/dist/components/HysIcon/builtins/catalog/media-2.json.js +13 -0
- package/dist/components/HysIcon/builtins/catalog/medical.json.js +30 -0
- package/dist/components/HysIcon/builtins/catalog/nature.json.js +54 -0
- package/dist/components/HysIcon/builtins/catalog/recreation.json.js +51 -0
- package/dist/components/HysIcon/builtins/catalog/shapes.json.js +54 -0
- package/dist/components/HysIcon/builtins/catalog/text-1.json.js +52 -0
- package/dist/components/HysIcon/builtins/catalog/text-2.json.js +54 -0
- package/dist/components/HysIcon/builtins/catalog/text-3.json.js +58 -0
- package/dist/components/HysIcon/builtins/catalog/text-4.json.js +41 -0
- package/dist/components/HysIcon/builtins/catalog/time.json.js +39 -0
- package/dist/components/HysIcon/builtins/catalog/transport-1.json.js +57 -0
- package/dist/components/HysIcon/builtins/catalog/transport-2.json.js +7 -0
- package/dist/components/HysIcon/builtins/catalog/weather.json.js +46 -0
- package/dist/components/HysIcon/builtins/communication.js +314 -0
- package/dist/components/HysIcon/builtins/documents.js +315 -0
- package/dist/components/HysIcon/builtins/extendedCatalog.js +75 -0
- package/dist/components/HysIcon/builtins/iconInCategory.js +11 -0
- package/dist/components/HysIcon/builtins/media.js +255 -0
- package/dist/components/HysIcon/builtins/navigation.js +276 -0
- package/dist/components/HysIcon/builtins/technology.js +189 -0
- package/dist/components/HysIcon/iconBuiltins.js +228 -0
- package/dist/components/HysIcon/iconConfig.js +30 -0
- package/dist/components/HysIcon/iconRegistry.js +183 -0
- package/dist/components/HysIcon/iconSafety.js +191 -0
- package/dist/components/HysIcon/iconStyle.js +70 -0
- package/dist/components/HysIcon/useIconResource.js +75 -0
- package/dist/components/HysModal/HysModal.vue.js +2 -2
- package/dist/components/HysModal/HysModal2.vue.js +38 -38
- package/dist/components/HysPopconfirm/HysPopconfirm.vue.js +7 -0
- package/dist/components/HysPopconfirm/HysPopconfirm2.vue.js +346 -0
- package/dist/components/HysPopconfirm/usePopconfirmAction.js +32 -0
- package/dist/components/HysResult/HysResult.vue.js +7 -0
- package/dist/components/HysResult/HysResult2.vue.js +124 -0
- package/dist/components/HysSearch/HysSearch.vue.js +2 -2
- package/dist/components/HysSortableList/HysSortableList.vue.js +2 -2
- package/dist/components/HysSortableList/HysSortableList2.vue.js +498 -129
- package/dist/components/HysSortableList/SortableGhost/SortableGhost.vue.js +7 -0
- package/dist/components/HysSortableList/SortableGhost/SortableGhost2.vue.js +43 -0
- package/dist/components/HysSortableList/SortableGhost/useSortGhost.js +54 -0
- package/dist/components/HysSortableList/geometry.js +230 -0
- package/dist/components/HysSortableList/model.js +254 -0
- package/dist/components/HysSortableList/transactions.js +281 -0
- package/dist/components/HysSortableList/useSortDrag.js +270 -0
- package/dist/components/HysSortableList/useSortKeyboard.js +72 -0
- package/dist/components/HysSortableList/useSortWindow.js +144 -0
- package/dist/components/HysSpace/HysSpace.vue.js +7 -0
- package/dist/components/HysSpace/HysSpace2.vue.js +79 -0
- package/dist/components/HysSpace/spaceItems.js +17 -0
- package/dist/components/HysSpin/HysSpin.vue.js +7 -0
- package/dist/components/HysSpin/HysSpin2.vue.js +427 -0
- package/dist/components/HysSpin/SpinGlyph/SpinGlyph.vue.js +334 -0
- package/dist/components/HysSpin/SpinGlyph/SpinGlyph2.vue.js +5 -0
- package/dist/components/HysSpin/SpinPortal/SpinPortal.vue.js +7 -0
- package/dist/components/HysSpin/SpinPortal/SpinPortal2.vue.js +66 -0
- package/dist/components/HysSpin/SpinPortal/spinTarget.js +57 -0
- package/dist/components/HysSpin/spinCatalog.js +35 -0
- package/dist/components/HysSpin/spinConfig.js +32 -0
- package/dist/components/HysSpin/spinService.js +160 -0
- package/dist/components/HysSpin/spinStyle.js +39 -0
- package/dist/components/HysSpin/useHysSpinTask.js +92 -0
- package/dist/components/HysSpin/useSpinFullscreen.js +60 -0
- package/dist/components/HysSpin/useSpinVisibility.js +59 -0
- package/dist/components/HysSplitPane/HysSplitPane.vue.js +285 -204
- package/dist/components/HysSplitPane/splitPaneResize.js +75 -0
- package/dist/components/HysTabPane/HysTabPane.vue.js +49 -0
- package/dist/components/HysTabPane/HysTabPane2.vue.js +4 -0
- package/dist/components/HysTable/HysTable.vue.js +3 -3
- package/dist/components/HysTable/HysTable2.vue.js +412 -383
- package/dist/components/HysTable/tableSearch.js +24 -0
- package/dist/components/HysTabs/HysTabs.vue.js +172 -5
- package/dist/components/HysTabs/HysTabs2.vue.js +2 -275
- package/dist/components/HysTabs/TabsMore/TabsMore.vue.js +7 -0
- package/dist/components/HysTabs/TabsMore/TabsMore2.vue.js +133 -0
- package/dist/components/HysTabs/TabsPanels/TabsPanels.vue.js +161 -0
- package/dist/components/HysTabs/TabsPanels/TabsPanels2.vue.js +4 -0
- package/dist/components/HysTabs/TabsPrompts/TabsPrompts.vue.js +4 -0
- package/dist/components/HysTabs/TabsPrompts/TabsPrompts2.vue.js +88 -0
- package/dist/components/HysTabs/TabsSlot/TabsSlot.js +13 -0
- package/dist/components/HysTabs/TabsWorkbench/TabsWorkbench.vue.js +7 -0
- package/dist/components/HysTabs/TabsWorkbench/TabsWorkbench2.vue.js +687 -0
- package/dist/components/HysTabs/tabsConfig.js +35 -0
- package/dist/components/HysTabs/tabsItems.js +79 -0
- package/dist/components/HysTabs/tabsPersistence.js +118 -0
- package/dist/components/HysTabs/useHysRouteTabs.js +77 -0
- package/dist/components/HysTabs/useTabsDragGhost.js +47 -0
- package/dist/components/HysTabs/useTabsNav.js +127 -0
- package/dist/components/HysTabs/useTabsOverlays.js +52 -0
- package/dist/components/HysTabs/useTabsPanels.js +101 -0
- package/dist/components/HysTabs/useTabsPointer.js +131 -0
- package/dist/components/HysTabs/useTabsState.js +263 -0
- package/dist/components/HysToast/HysToast.vue.js +3 -3
- package/dist/components/HysToast/HysToast2.vue.js +379 -107
- package/dist/components/HysToast/ToastViewport/ToastViewport.vue.js +7 -0
- package/dist/components/HysToast/ToastViewport/ToastViewport2.vue.js +211 -0
- package/dist/components/HysToast/ToastViewport/useToastStackDisclosure.js +71 -0
- package/dist/components/HysToast/toastPresentation.js +98 -0
- package/dist/components/HysToast/useToastActions.js +62 -0
- package/dist/components/HysToast/useToastSwipe.js +48 -0
- package/dist/components/HysToast/useToastTimer.js +90 -0
- package/dist/composables/formLayout.js +20 -42
- package/dist/composables/popupReferenceBinding.js +41 -0
- package/dist/composables/popupSurfaceStyle.js +30 -0
- package/dist/composables/toastEscape.js +18 -10
- package/dist/composables/toastQueue.js +276 -0
- package/dist/composables/toastQueueModel.js +86 -0
- package/dist/composables/toastTasks.js +58 -0
- package/dist/composables/useContainerWidth.js +24 -0
- package/dist/composables/useFloating.js +28 -28
- package/dist/composables/useHysToast.js +117 -135
- package/dist/composables/usePageVisibility.js +19 -0
- package/dist/composables/usePopupSurface.js +181 -356
- package/dist/composables/usePopupSurfaceInteractions.js +173 -0
- package/dist/composables/useSplitPaneDrag.js +29 -26
- package/dist/composables/useSvgInstanceId.js +15 -0
- package/dist/composables/useTable.js +321 -306
- package/dist/composables/useTabularRowNavigation.js +46 -0
- package/dist/index.js +231 -185
- package/dist/internal/MultiSplitPane.vue.js +246 -205
- package/dist/internal/PopupSurfacePanel.vue.js +2 -2
- package/dist/internal/PopupSurfacePanel2.vue.js +35 -30
- package/dist/style.css +1 -1
- package/dist/types/components/HysDataGrid/HysDataGrid.vue.d.ts +40 -2
- package/dist/types/components/HysDataGrid/gridColumnLayout.d.ts +22 -0
- package/dist/types/components/HysDataGrid/gridPresentation.d.ts +47 -0
- package/dist/types/components/HysDataGrid/useGridContextMenu.d.ts +14 -0
- package/dist/types/components/HysDescriptions/HysDescriptions.vue.d.ts +20 -0
- package/dist/types/components/HysDescriptions/descriptionsTypes.d.ts +54 -0
- package/dist/types/components/HysForm/HysForm.vue.d.ts +1 -1
- package/dist/types/components/HysFormItem/HysFormItem.vue.d.ts +1 -1
- package/dist/types/components/HysGantt/HysGantt.vue.d.ts +1 -1
- package/dist/types/components/HysIcon/HysIcon.vue.d.ts +76 -0
- package/dist/types/components/HysIcon/IconGraphic/IconGraphic.vue.d.ts +43 -0
- package/dist/types/components/HysIcon/IconPickerPanel/IconPickerPanel.vue.d.ts +17 -0
- package/dist/types/components/HysIcon/IconReferenceGraphic/IconReferenceGraphic.vue.d.ts +10 -0
- package/dist/types/components/HysIcon/IconTooltip/IconTooltip.vue.d.ts +11 -0
- package/dist/types/components/HysIcon/builtins/access.d.ts +15 -0
- package/dist/types/components/HysIcon/builtins/actions.d.ts +30 -0
- package/dist/types/components/HysIcon/builtins/business.d.ts +31 -0
- package/dist/types/components/HysIcon/builtins/communication.d.ts +27 -0
- package/dist/types/components/HysIcon/builtins/documents.d.ts +29 -0
- package/dist/types/components/HysIcon/builtins/extendedCatalog.d.ts +2 -0
- package/dist/types/components/HysIcon/builtins/iconInCategory.d.ts +2 -0
- package/dist/types/components/HysIcon/builtins/media.d.ts +24 -0
- package/dist/types/components/HysIcon/builtins/navigation.d.ts +30 -0
- package/dist/types/components/HysIcon/builtins/technology.d.ts +18 -0
- package/dist/types/components/HysIcon/iconBuiltins.d.ts +2 -0
- package/dist/types/components/HysIcon/iconConfig.d.ts +10 -0
- package/dist/types/components/HysIcon/iconRegistry.d.ts +5 -0
- package/dist/types/components/HysIcon/iconSafety.d.ts +8 -0
- package/dist/types/components/HysIcon/iconStyle.d.ts +6 -0
- package/dist/types/components/HysIcon/iconTypes.d.ts +192 -0
- package/dist/types/components/HysIcon/useIconResource.d.ts +14 -0
- package/dist/types/components/HysModal/HysModal.vue.d.ts +1 -1
- package/dist/types/components/HysPopconfirm/HysPopconfirm.vue.d.ts +85 -0
- package/dist/types/components/HysPopconfirm/popconfirmTypes.d.ts +72 -0
- package/dist/types/components/HysPopconfirm/usePopconfirmAction.d.ts +6 -0
- package/dist/types/components/HysProgress/HysProgress.vue.d.ts +1 -1
- package/dist/types/components/HysResult/HysResult.vue.d.ts +22 -0
- package/dist/types/components/HysResult/resultTypes.d.ts +32 -0
- package/dist/types/components/HysSortableList/HysSortableList.vue.d.ts +48 -25
- package/dist/types/components/HysSortableList/SortableGhost/SortableGhost.vue.d.ts +31 -0
- package/dist/types/components/HysSortableList/SortableGhost/useSortGhost.d.ts +23 -0
- package/dist/types/components/HysSortableList/geometry.d.ts +35 -0
- package/dist/types/components/HysSortableList/model.d.ts +61 -0
- package/dist/types/components/HysSortableList/sortableList.d.ts +151 -0
- package/dist/types/components/HysSortableList/transactions.d.ts +10 -0
- package/dist/types/components/HysSortableList/useSortDrag.d.ts +25 -0
- package/dist/types/components/HysSortableList/useSortKeyboard.d.ts +17 -0
- package/dist/types/components/HysSortableList/useSortWindow.d.ts +16 -0
- package/dist/types/components/HysSpace/HysSpace.vue.d.ts +15 -0
- package/dist/types/components/HysSpace/spaceItems.d.ts +9 -0
- package/dist/types/components/HysSpace/spaceTypes.d.ts +20 -0
- package/dist/types/components/HysSpin/HysSpin.vue.d.ts +84 -0
- package/dist/types/components/HysSpin/SpinGlyph/SpinGlyph.vue.d.ts +16 -0
- package/dist/types/components/HysSpin/SpinPortal/SpinPortal.vue.d.ts +21 -0
- package/dist/types/components/HysSpin/SpinPortal/spinTarget.d.ts +3 -0
- package/dist/types/components/HysSpin/spinCatalog.d.ts +122 -0
- package/dist/types/components/HysSpin/spinConfig.d.ts +10 -0
- package/dist/types/components/HysSpin/spinService.d.ts +7 -0
- package/dist/types/components/HysSpin/spinStyle.d.ts +5 -0
- package/dist/types/components/HysSpin/spinTypes.d.ts +133 -0
- package/dist/types/components/HysSpin/useHysSpinTask.d.ts +4 -0
- package/dist/types/components/HysSpin/useSpinFullscreen.d.ts +17 -0
- package/dist/types/components/HysSpin/useSpinVisibility.d.ts +10 -0
- package/dist/types/components/HysSplitPane/HysSplitPane.vue.d.ts +25 -2
- package/dist/types/components/HysSplitPane/splitPaneResize.d.ts +17 -0
- package/dist/types/components/HysTabPane/HysTabPane.vue.d.ts +11 -0
- package/dist/types/components/HysTable/HysTable.vue.d.ts +16 -10
- package/dist/types/components/HysTable/tableSearch.d.ts +2 -0
- package/dist/types/components/HysTabs/HysTabs.vue.d.ts +83 -74
- package/dist/types/components/HysTabs/TabsMore/TabsMore.vue.d.ts +14 -0
- package/dist/types/components/HysTabs/TabsPanels/TabsPanels.vue.d.ts +17 -0
- package/dist/types/components/HysTabs/TabsPrompts/TabsPrompts.vue.d.ts +7 -0
- package/dist/types/components/HysTabs/TabsSlot/TabsSlot.d.ts +9 -0
- package/dist/types/components/HysTabs/TabsWorkbench/TabsWorkbench.vue.d.ts +32 -0
- package/dist/types/components/HysTabs/tabsConfig.d.ts +4 -0
- package/dist/types/components/HysTabs/tabsItems.d.ts +14 -0
- package/dist/types/components/HysTabs/tabsPersistence.d.ts +6 -0
- package/dist/types/components/HysTabs/tabsTypes.d.ts +236 -0
- package/dist/types/components/HysTabs/useHysRouteTabs.d.ts +22 -0
- package/dist/types/components/HysTabs/useTabsDragGhost.d.ts +22 -0
- package/dist/types/components/HysTabs/useTabsNav.d.ts +20 -0
- package/dist/types/components/HysTabs/useTabsOverlays.d.ts +54 -0
- package/dist/types/components/HysTabs/useTabsPanels.d.ts +14 -0
- package/dist/types/components/HysTabs/useTabsPointer.d.ts +30 -0
- package/dist/types/components/HysTabs/useTabsState.d.ts +32 -0
- package/dist/types/components/HysTagInput/HysTagInput.vue.d.ts +2 -2
- package/dist/types/components/HysToast/HysToast.vue.d.ts +44 -46
- package/dist/types/components/HysToast/ToastViewport/ToastViewport.vue.d.ts +25 -0
- package/dist/types/components/HysToast/ToastViewport/useToastStackDisclosure.d.ts +16 -0
- package/dist/types/components/HysToast/toastPresentation.d.ts +8 -0
- package/dist/types/components/HysToast/toastTypes.d.ts +212 -0
- package/dist/types/components/HysToast/useToastActions.d.ts +18 -0
- package/dist/types/components/HysToast/useToastSwipe.d.ts +11 -0
- package/dist/types/components/HysToast/useToastTimer.d.ts +22 -0
- package/dist/types/components/HysVirtualTable/HysVirtualTable.vue.d.ts +2 -2
- package/dist/types/composables/dataGrid.d.ts +34 -0
- package/dist/types/composables/formLayout.d.ts +1 -2
- package/dist/types/composables/popupReferenceBinding.d.ts +9 -0
- package/dist/types/composables/popupSurfaceStyle.d.ts +7 -0
- package/dist/types/composables/table.d.ts +10 -1
- package/dist/types/composables/toastEscape.d.ts +1 -1
- package/dist/types/composables/toastQueue.d.ts +121 -0
- package/dist/types/composables/toastQueueModel.d.ts +116 -0
- package/dist/types/composables/toastTasks.d.ts +2 -0
- package/dist/types/composables/useColorPicker.d.ts +1 -1
- package/dist/types/composables/useContainerWidth.d.ts +2 -0
- package/dist/types/composables/useContextMenu.d.ts +1 -1
- package/dist/types/composables/useFloating.d.ts +2 -2
- package/dist/types/composables/useHysToast.d.ts +4 -48
- package/dist/types/composables/usePageVisibility.d.ts +1 -0
- package/dist/types/composables/usePopupSurface.d.ts +28 -22
- package/dist/types/composables/usePopupSurfaceInteractions.d.ts +35 -0
- package/dist/types/composables/useSplitPaneDrag.d.ts +2 -2
- package/dist/types/composables/useSvgInstanceId.d.ts +1 -0
- package/dist/types/composables/useTable.d.ts +2 -0
- package/dist/types/composables/useTabularRowNavigation.d.ts +18 -0
- package/dist/types/index.d.ts +33 -6
- package/dist/types/internal/MultiSplitPane.vue.d.ts +10 -1
- package/dist/types/internal/PopupSurfacePanel.vue.d.ts +3 -0
- package/package.json +1 -1
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import { nextTick as L } from "vue";
|
|
2
|
+
import { sameItems as g, feedback as u, preserved as N, makeDrag as M, proposeSort as I } from "./model.js";
|
|
3
|
+
const w = /* @__PURE__ */ new WeakMap(), S = /* @__PURE__ */ new WeakMap(), P = (t) => t === !1 || t === 0 ? 0 : typeof t == "number" && Number.isFinite(t) ? Math.max(0, Math.min(200, Math.floor(t))) : 20;
|
|
4
|
+
function v(t) {
|
|
5
|
+
let n = S.get(t);
|
|
6
|
+
return n || (n = { undo: [], redo: [] }, S.set(t, n)), n;
|
|
7
|
+
}
|
|
8
|
+
const J = (t) => w.has(t), R = (t) => {
|
|
9
|
+
var n;
|
|
10
|
+
return (n = w.get(t)) == null ? void 0 : n.abort();
|
|
11
|
+
};
|
|
12
|
+
function T(t) {
|
|
13
|
+
const n = v(t), e = /* @__PURE__ */ new Set([...n.undo, ...n.redo]);
|
|
14
|
+
for (const s of e)
|
|
15
|
+
for (const r of s.participants) {
|
|
16
|
+
const o = v(r);
|
|
17
|
+
o.undo = o.undo.filter((c) => c !== s), o.redo = o.redo.filter((c) => c !== s);
|
|
18
|
+
}
|
|
19
|
+
S.delete(t);
|
|
20
|
+
}
|
|
21
|
+
function K(t) {
|
|
22
|
+
for (const n of t) {
|
|
23
|
+
const e = v(n).redo;
|
|
24
|
+
for (const s of e.slice())
|
|
25
|
+
for (const r of s.participants) {
|
|
26
|
+
const o = v(r).redo, c = o.indexOf(s);
|
|
27
|
+
c !== -1 && o.splice(c, 1);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function $(t) {
|
|
32
|
+
K(t.participants);
|
|
33
|
+
for (const n of t.participants) {
|
|
34
|
+
const e = P(n.props.history);
|
|
35
|
+
if (!e) continue;
|
|
36
|
+
const s = v(n).undo;
|
|
37
|
+
s.push(t), s.splice(0, Math.max(0, s.length - e));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function j(t, n) {
|
|
41
|
+
const e = t.data();
|
|
42
|
+
if (!e.valid) return e.items;
|
|
43
|
+
const s = new Set(e.fixed.map((l) => l.key)), r = new Map(n.map((l, x) => [l, x])), o = (l) => r.has(t.key(l)) && !s.has(t.key(l)), c = e.items.filter(o).sort((l, x) => r.get(t.key(l)) - r.get(t.key(x)));
|
|
44
|
+
let d = 0;
|
|
45
|
+
const p = e.items.map(
|
|
46
|
+
(l) => o(l) ? c[d++] : l
|
|
47
|
+
);
|
|
48
|
+
return N(t, p) ? p : e.items;
|
|
49
|
+
}
|
|
50
|
+
function V(t) {
|
|
51
|
+
const n = t.props.storageKey;
|
|
52
|
+
if (n)
|
|
53
|
+
try {
|
|
54
|
+
const e = JSON.parse(localStorage.getItem(n) ?? "null");
|
|
55
|
+
if (!Array.isArray(e)) return;
|
|
56
|
+
const s = j(t, e);
|
|
57
|
+
g(t.data().items, s) || t.apply(s.slice());
|
|
58
|
+
} catch {
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function W(t) {
|
|
62
|
+
for (const { port: n, next: e } of t) {
|
|
63
|
+
const s = n.props.storageKey;
|
|
64
|
+
if (s)
|
|
65
|
+
try {
|
|
66
|
+
localStorage.setItem(s, JSON.stringify(e.map(n.key)));
|
|
67
|
+
} catch (r) {
|
|
68
|
+
n.reject(u("save", void 0, "无法保存本地排序记录", r));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const k = (t, n) => t.every((e) => g(e.port.data().items, e[n])), H = (t, n, e) => ({
|
|
73
|
+
action: n,
|
|
74
|
+
proposal: e,
|
|
75
|
+
lists: t.map(({ port: s, previous: r, next: o }) => ({
|
|
76
|
+
id: s.id(),
|
|
77
|
+
previous: r.slice(),
|
|
78
|
+
next: o.slice()
|
|
79
|
+
}))
|
|
80
|
+
});
|
|
81
|
+
function f(t, n) {
|
|
82
|
+
for (const e of t) e.reject(n);
|
|
83
|
+
return !1;
|
|
84
|
+
}
|
|
85
|
+
async function O(t, n, e) {
|
|
86
|
+
if (!t.length) return !0;
|
|
87
|
+
const s = t.map(({ port: o, next: c, previous: d }) => ({
|
|
88
|
+
port: o,
|
|
89
|
+
previous: c,
|
|
90
|
+
next: d
|
|
91
|
+
}));
|
|
92
|
+
for (const o of s) o.port.apply(o.next.slice());
|
|
93
|
+
await L();
|
|
94
|
+
const r = H(s, "rollback", e);
|
|
95
|
+
for (const o of n) o.change(r);
|
|
96
|
+
return k(s, "next");
|
|
97
|
+
}
|
|
98
|
+
async function D(t, n) {
|
|
99
|
+
if (n.aborted) throw Error("操作已取消");
|
|
100
|
+
let e = () => {
|
|
101
|
+
};
|
|
102
|
+
const s = new Promise((r, o) => {
|
|
103
|
+
e = () => o(Error("操作已取消")), n.addEventListener("abort", e, { once: !0 });
|
|
104
|
+
});
|
|
105
|
+
try {
|
|
106
|
+
return await Promise.race([Promise.resolve().then(t), s]);
|
|
107
|
+
} finally {
|
|
108
|
+
n.removeEventListener("abort", e);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
async function E(t, n, e, s, r) {
|
|
112
|
+
var x;
|
|
113
|
+
const { participants: o, changes: c } = t, d = o[0];
|
|
114
|
+
if (o.some((a) => J(a) || !a.root()))
|
|
115
|
+
return f([d], u("conflict", e));
|
|
116
|
+
if (o.some((a) => a.props.disabled))
|
|
117
|
+
return f([d], u("disabled", e));
|
|
118
|
+
if (!k(c, "previous"))
|
|
119
|
+
return f(o, u("conflict", e));
|
|
120
|
+
const p = new AbortController();
|
|
121
|
+
for (const a of o)
|
|
122
|
+
w.set(a, p), a.lock(!0);
|
|
123
|
+
let l = !1;
|
|
124
|
+
try {
|
|
125
|
+
if (e)
|
|
126
|
+
for (const m of o) {
|
|
127
|
+
const i = m.props.beforeDrop;
|
|
128
|
+
if (!i) continue;
|
|
129
|
+
const y = await D(
|
|
130
|
+
() => i(e, p.signal),
|
|
131
|
+
p.signal
|
|
132
|
+
);
|
|
133
|
+
if (p.signal.aborted)
|
|
134
|
+
return f(o, u("cancelled", e));
|
|
135
|
+
if (y === !1 || typeof y == "string")
|
|
136
|
+
return f(
|
|
137
|
+
o,
|
|
138
|
+
u(
|
|
139
|
+
"rule",
|
|
140
|
+
e,
|
|
141
|
+
typeof y == "string" ? y : void 0
|
|
142
|
+
)
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
if (p.signal.aborted)
|
|
146
|
+
return f(o, u("cancelled", e));
|
|
147
|
+
if (!k(c, "previous") || o.some((m) => m.props.disabled))
|
|
148
|
+
return f(o, u("conflict", e));
|
|
149
|
+
const a = s == null ? void 0 : s();
|
|
150
|
+
if (a) return f(o, a);
|
|
151
|
+
for (const m of c) m.port.apply(m.next.slice());
|
|
152
|
+
if (l = !0, await L(), !k(c, "next"))
|
|
153
|
+
return c.every(
|
|
154
|
+
(i) => g(i.port.data().items, i.previous) || g(i.port.data().items, i.next)
|
|
155
|
+
) && await O(
|
|
156
|
+
c.filter(
|
|
157
|
+
(i) => g(i.port.data().items, i.next)
|
|
158
|
+
),
|
|
159
|
+
o,
|
|
160
|
+
e
|
|
161
|
+
), f(o, u("conflict", e));
|
|
162
|
+
r == null || r();
|
|
163
|
+
const h = H(c, n, e), b = (x = o.find((m) => m.props.save)) == null ? void 0 : x.props.save;
|
|
164
|
+
if (b && await D(
|
|
165
|
+
() => b(h, p.signal),
|
|
166
|
+
p.signal
|
|
167
|
+
) === !1)
|
|
168
|
+
throw Error("保存请求被拒绝");
|
|
169
|
+
if (p.signal.aborted) throw Error("操作已取消");
|
|
170
|
+
if (!k(c, "next"))
|
|
171
|
+
return f(o, u("conflict", e));
|
|
172
|
+
W(c);
|
|
173
|
+
for (const m of o) m.change(h);
|
|
174
|
+
return !0;
|
|
175
|
+
} catch (a) {
|
|
176
|
+
if (l && (!k(c, "next") || !await O(c, o, e)))
|
|
177
|
+
return f(o, u("conflict", e, void 0, a));
|
|
178
|
+
const h = p.signal.aborted ? "cancelled" : l ? "save" : "rule";
|
|
179
|
+
return f(o, u(h, e, void 0, a));
|
|
180
|
+
} finally {
|
|
181
|
+
for (const a of o)
|
|
182
|
+
w.delete(a), a.lock(!1);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
async function _(t, n, e, s) {
|
|
186
|
+
var m;
|
|
187
|
+
let r;
|
|
188
|
+
try {
|
|
189
|
+
const i = M(t, n.keys, n.source);
|
|
190
|
+
if ("reason" in i) return f([t], i);
|
|
191
|
+
if (!g(i.items, n.items))
|
|
192
|
+
return f([t], u("conflict"));
|
|
193
|
+
r = I(t, i, e, !0);
|
|
194
|
+
} catch (i) {
|
|
195
|
+
return f(
|
|
196
|
+
[t],
|
|
197
|
+
u(
|
|
198
|
+
"rule",
|
|
199
|
+
void 0,
|
|
200
|
+
i instanceof Error ? i.message : void 0,
|
|
201
|
+
i
|
|
202
|
+
)
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
if ("reason" in r) return f([t], r);
|
|
206
|
+
const o = r.source === r.target ? [t] : [t, r.target], c = {
|
|
207
|
+
participants: o,
|
|
208
|
+
changes: r.changes.map((i) => ({
|
|
209
|
+
...i,
|
|
210
|
+
previous: i.previous.slice(),
|
|
211
|
+
next: i.next.slice()
|
|
212
|
+
}))
|
|
213
|
+
}, d = r.proposal, p = r.target, l = d.operation === "move" ? n.items[0] : (m = r.changes.find((i) => i.port === p)) == null ? void 0 : m.next[d.index], x = o.some((i) => !!i.props.beforeDrop);
|
|
214
|
+
if (!await E(
|
|
215
|
+
c,
|
|
216
|
+
"sort",
|
|
217
|
+
d,
|
|
218
|
+
x ? () => {
|
|
219
|
+
const i = M(t, n.keys, n.source);
|
|
220
|
+
if ("reason" in i) return i;
|
|
221
|
+
if (!g(i.items, n.items))
|
|
222
|
+
return u("conflict", d);
|
|
223
|
+
const y = I(t, i, e);
|
|
224
|
+
if ("reason" in y) return y;
|
|
225
|
+
if (y.proposal.index !== d.index || y.proposal.operation !== d.operation || y.proposal.mode !== d.mode)
|
|
226
|
+
return u("conflict", d);
|
|
227
|
+
} : void 0,
|
|
228
|
+
s && (() => s(
|
|
229
|
+
l ? p.row(p.key(l)) : void 0
|
|
230
|
+
))
|
|
231
|
+
))
|
|
232
|
+
return !1;
|
|
233
|
+
$(c);
|
|
234
|
+
const a = r.target.data(), h = r.proposal.operation === "move" ? a.keys.get(r.target.key(n.items[0])) : r.proposal.index, b = n.items.length > 1 ? `已排序 ${n.items.length} 项` : `已将${t.label(n.items[0])}放到第 ${(h ?? 0) + 1} 项`;
|
|
235
|
+
return t.announce(b), n.source !== "pointer" && h !== void 0 && a.items[h] && await r.target.focus(r.target.key(a.items[h])), !0;
|
|
236
|
+
}
|
|
237
|
+
async function q(t, n) {
|
|
238
|
+
const e = v(t)[n].at(-1);
|
|
239
|
+
if (!e || !P(t.props.history)) return !1;
|
|
240
|
+
if (e.participants.some((r) => {
|
|
241
|
+
const o = v(r)[n];
|
|
242
|
+
return o.includes(e) && o.at(-1) !== e;
|
|
243
|
+
}))
|
|
244
|
+
return f([t], u("conflict"));
|
|
245
|
+
const s = n === "redo" ? e.changes : e.changes.map((r) => ({
|
|
246
|
+
...r,
|
|
247
|
+
previous: r.next,
|
|
248
|
+
next: r.previous
|
|
249
|
+
}));
|
|
250
|
+
for (const r of s) {
|
|
251
|
+
if (!N(r.port, r.next))
|
|
252
|
+
return f([t], u("fixed"));
|
|
253
|
+
if (r.next.length > r.previous.length && r.next.length > (r.port.props.maxItems ?? 1 / 0))
|
|
254
|
+
return f([t], u("capacity"));
|
|
255
|
+
}
|
|
256
|
+
if (!await E({ ...e, changes: s }, n)) return !1;
|
|
257
|
+
for (const r of e.participants) {
|
|
258
|
+
const o = v(r);
|
|
259
|
+
o[n].at(-1) === e && (o[n].pop(), o[n === "undo" ? "redo" : "undo"].push(e));
|
|
260
|
+
}
|
|
261
|
+
return t.announce(n === "undo" ? "已撤销排序" : "已重做排序"), !0;
|
|
262
|
+
}
|
|
263
|
+
async function z(t, n) {
|
|
264
|
+
const e = t.data().items.slice(), s = j(t, n.map(t.key));
|
|
265
|
+
if (g(e, s)) return !1;
|
|
266
|
+
const r = { participants: [t], changes: [{ port: t, previous: e, next: s }] };
|
|
267
|
+
return await E(r, "reset") ? ($(r), t.announce("已恢复初始顺序"), !0) : !1;
|
|
268
|
+
}
|
|
269
|
+
function A(t) {
|
|
270
|
+
return typeof t == "string" || typeof t == "number" ? [t] : t;
|
|
271
|
+
}
|
|
272
|
+
export {
|
|
273
|
+
R as abortSort,
|
|
274
|
+
J as busySort,
|
|
275
|
+
_ as commitSort,
|
|
276
|
+
T as discardSortHistory,
|
|
277
|
+
A as keysArray,
|
|
278
|
+
q as navigateHistory,
|
|
279
|
+
z as resetSort,
|
|
280
|
+
V as restoreStoredSort
|
|
281
|
+
};
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { computed as X, shallowRef as ce } from "vue";
|
|
2
|
+
import { dropMarkerFor as ue, relativeCandidate as de, wholeRowDrag as fe, hitsSelectableText as me, withinDragBounds as ve, findSortHit as pe, tokenOf as ye, keepSortCandidate as he, autoScrollSort as ge, sameCandidate as Ee } from "./geometry.js";
|
|
3
|
+
import { feedback as k, makeDrag as be, proposeSort as Le } from "./model.js";
|
|
4
|
+
import { abortSort as xe, busySort as Y, commitSort as _ } from "./transactions.js";
|
|
5
|
+
import { useSortKeyboard as ke, sortInteractive as Se, keyboardPreviewLabel as De } from "./useSortKeyboard.js";
|
|
6
|
+
import { useSortGhost as Pe } from "./SortableGhost/useSortGhost.js";
|
|
7
|
+
const D = ce(null), m = () => D.value, S = (r) => {
|
|
8
|
+
D.value = r;
|
|
9
|
+
};
|
|
10
|
+
function Ye(r, j, w) {
|
|
11
|
+
const f = X(() => {
|
|
12
|
+
var e;
|
|
13
|
+
return ((e = m()) == null ? void 0 : e.source) === r ? m() : null;
|
|
14
|
+
}), G = X(
|
|
15
|
+
() => {
|
|
16
|
+
var e, n;
|
|
17
|
+
return ((n = (e = m()) == null ? void 0 : e.candidate) == null ? void 0 : n.port) === r ? m() : null;
|
|
18
|
+
}
|
|
19
|
+
), {
|
|
20
|
+
ghost: g,
|
|
21
|
+
show: ee,
|
|
22
|
+
clear: R,
|
|
23
|
+
release: te
|
|
24
|
+
} = Pe(w, () => ({
|
|
25
|
+
duration: r.props.animationDuration ?? 180,
|
|
26
|
+
easing: r.props.animationEasing ?? "ease"
|
|
27
|
+
}));
|
|
28
|
+
let V, P, E = 0, h, C = -1 / 0, I = !1, t, c, a, M = "";
|
|
29
|
+
function q(e, n) {
|
|
30
|
+
if (!Y(r))
|
|
31
|
+
try {
|
|
32
|
+
const o = be(r, e, n);
|
|
33
|
+
if (!("reason" in o)) return o;
|
|
34
|
+
r.reject(o);
|
|
35
|
+
} catch (o) {
|
|
36
|
+
r.reject(
|
|
37
|
+
k(
|
|
38
|
+
"rule",
|
|
39
|
+
void 0,
|
|
40
|
+
o instanceof Error ? o.message : void 0,
|
|
41
|
+
o
|
|
42
|
+
)
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function z(e, n) {
|
|
47
|
+
if (D.value) return !1;
|
|
48
|
+
const o = q(j(e), n);
|
|
49
|
+
return o ? (S({ source: r, drag: o }), r.start(o), r.announce(
|
|
50
|
+
o.items.length > 1 ? `已拾起 ${o.items.length} 项` : `已拾起${r.label(o.items[0])}`
|
|
51
|
+
), M = "", !0) : !1;
|
|
52
|
+
}
|
|
53
|
+
function A(e) {
|
|
54
|
+
var d;
|
|
55
|
+
const n = m();
|
|
56
|
+
if ((n == null ? void 0 : n.source) !== r || Ee(n.candidate, e))
|
|
57
|
+
return;
|
|
58
|
+
let o;
|
|
59
|
+
try {
|
|
60
|
+
o = e ? Le(r, n.drag, e) : void 0;
|
|
61
|
+
} catch (l) {
|
|
62
|
+
o = k(
|
|
63
|
+
"rule",
|
|
64
|
+
void 0,
|
|
65
|
+
l instanceof Error ? l.message : void 0,
|
|
66
|
+
l
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
const i = (d = n.candidate) == null ? void 0 : d.port, s = e == null ? void 0 : e.port;
|
|
70
|
+
S({ ...n, candidate: e, result: o }), g.value && (g.value.allowed.value = !!o && (!("reason" in o) || o.reason === "noop")), i && i !== r && i !== s && i.preview(null);
|
|
71
|
+
const u = o && !("reason" in o) ? {
|
|
72
|
+
proposal: o.proposal,
|
|
73
|
+
lists: o.changes.map((l) => ({
|
|
74
|
+
id: l.port.id(),
|
|
75
|
+
previous: l.previous.slice(),
|
|
76
|
+
next: l.next.slice()
|
|
77
|
+
}))
|
|
78
|
+
} : null;
|
|
79
|
+
if (r.preview(u), s && s !== r && s.preview(u), n.drag.source === "keyboard") {
|
|
80
|
+
const l = De(r, n.drag.items[0], o);
|
|
81
|
+
l && l !== M && r.announce(l), M = l;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function B() {
|
|
85
|
+
const e = m();
|
|
86
|
+
if ((e == null ? void 0 : e.source) === r)
|
|
87
|
+
return S(null), r.preview(null), e.candidate && e.candidate.port !== r && e.candidate.port.preview(null), e;
|
|
88
|
+
}
|
|
89
|
+
function b() {
|
|
90
|
+
var e, n, o;
|
|
91
|
+
clearTimeout(V), t == null || t.cancelAnimationFrame(E), E = 0, h = void 0, a && ((n = (e = r.root()) == null ? void 0 : e.hasPointerCapture) != null && n.call(e, a.id)) && ((o = r.root()) == null || o.releasePointerCapture(a.id)), a = void 0, t == null || t.removeEventListener("pointermove", U), t == null || t.removeEventListener("pointerup", J), t == null || t.removeEventListener("pointercancel", L), t == null || t.removeEventListener("keydown", F), t == null || t.removeEventListener("blur", L), t == null || t.removeEventListener("resize", p), t == null || t.removeEventListener("scroll", p, !0), c == null || c.removeEventListener("selectstart", $, !0), c == null || c.removeEventListener("visibilitychange", H);
|
|
92
|
+
}
|
|
93
|
+
function $(e) {
|
|
94
|
+
e.preventDefault();
|
|
95
|
+
}
|
|
96
|
+
function v(e = "cancelled", n = !0) {
|
|
97
|
+
var i;
|
|
98
|
+
const o = B();
|
|
99
|
+
R(n, a == null ? void 0 : a.row), b(), o && r.reject(k(e, (i = o.result) == null ? void 0 : i.proposal)), xe(r);
|
|
100
|
+
}
|
|
101
|
+
function re() {
|
|
102
|
+
var n;
|
|
103
|
+
const e = m();
|
|
104
|
+
((n = e == null ? void 0 : e.candidate) == null ? void 0 : n.port) === r && e.source !== r && (e.source.preview(null), S({ ...e, candidate: void 0, result: void 0 })), v("cancelled", !1), clearTimeout(P), t == null || t.removeEventListener("click", T, !0);
|
|
105
|
+
}
|
|
106
|
+
function H() {
|
|
107
|
+
c != null && c.hidden && v();
|
|
108
|
+
}
|
|
109
|
+
function F(e) {
|
|
110
|
+
e.key === "Escape" && (f.value && e.preventDefault(), v());
|
|
111
|
+
}
|
|
112
|
+
function L(e) {
|
|
113
|
+
"pointerId" in e && e.pointerId !== (a == null ? void 0 : a.id) || v();
|
|
114
|
+
}
|
|
115
|
+
function p() {
|
|
116
|
+
E || !a || !f.value || !t || (E = t.requestAnimationFrame(ne));
|
|
117
|
+
}
|
|
118
|
+
function K(e, n = !0) {
|
|
119
|
+
var y;
|
|
120
|
+
if (!a || !f.value) return;
|
|
121
|
+
h = a.latest;
|
|
122
|
+
const { point: o, inside: i } = ve(
|
|
123
|
+
r,
|
|
124
|
+
a.latest,
|
|
125
|
+
a.origin
|
|
126
|
+
);
|
|
127
|
+
g.value && (g.value.position.value = {
|
|
128
|
+
x: o.x - a.offset.x,
|
|
129
|
+
y: o.y - a.offset.y
|
|
130
|
+
});
|
|
131
|
+
const s = i ? pe(r, o) : void 0, u = s == null ? void 0 : s.rowKey, d = f.value;
|
|
132
|
+
!(r.props.livePreview !== !1 && ((y = s == null ? void 0 : s.candidate) == null ? void 0 : y.port) === r && d.result && !("reason" in d.result) && u !== void 0 && d.drag.keys.some((x) => ye(x) === u)) && !he(r, d.candidate, s) && A(s == null ? void 0 : s.candidate), n && (e - C >= 14 && (C = e, I = ge(
|
|
133
|
+
(s == null ? void 0 : s.element) ?? null,
|
|
134
|
+
o,
|
|
135
|
+
r.props.autoScroll
|
|
136
|
+
)), I && p());
|
|
137
|
+
}
|
|
138
|
+
function ne(e) {
|
|
139
|
+
E = 0, K(e);
|
|
140
|
+
}
|
|
141
|
+
function O() {
|
|
142
|
+
var e, n;
|
|
143
|
+
if (!a || !z(a.key, "pointer")) return b();
|
|
144
|
+
ee(f.value.drag, a.row, {
|
|
145
|
+
x: a.latest.x - a.offset.x,
|
|
146
|
+
y: a.latest.y - a.offset.y
|
|
147
|
+
});
|
|
148
|
+
try {
|
|
149
|
+
(n = (e = r.root()) == null ? void 0 : e.setPointerCapture) == null || n.call(e, a.id);
|
|
150
|
+
} catch {
|
|
151
|
+
}
|
|
152
|
+
C = -1 / 0, I = !1, p();
|
|
153
|
+
}
|
|
154
|
+
function oe(e, n, o) {
|
|
155
|
+
var Z;
|
|
156
|
+
if (o || e.defaultPrevented || e.button !== 0 || e.isPrimary === !1 || a || D.value || Y(r))
|
|
157
|
+
return;
|
|
158
|
+
const i = e.target;
|
|
159
|
+
if (!(i instanceof Element) || i.closest("[data-sort-root]") !== r.root())
|
|
160
|
+
return;
|
|
161
|
+
const s = e.currentTarget, u = typeof r.props.handle == "string" ? r.props.handle : "[data-sort-handle]", d = i.closest(u) ?? i.closest("[data-sort-handle]");
|
|
162
|
+
if (fe(r.props) ? !d && (i.closest(Se) || me(i, e.clientX, e.clientY)) : !d || !s.contains(d))
|
|
163
|
+
return;
|
|
164
|
+
const l = s.getBoundingClientRect(), y = { x: e.clientX, y: e.clientY }, x = Math.max(
|
|
165
|
+
0,
|
|
166
|
+
e.pointerType === "touch" ? r.props.touchDelay ?? 180 : r.props.dragDelay ?? 0
|
|
167
|
+
), le = Math.max(1, r.props.dragThreshold ?? 5);
|
|
168
|
+
a = {
|
|
169
|
+
key: n,
|
|
170
|
+
origin: y,
|
|
171
|
+
latest: y,
|
|
172
|
+
threshold: le,
|
|
173
|
+
delay: x,
|
|
174
|
+
row: s,
|
|
175
|
+
id: e.pointerId,
|
|
176
|
+
offset: {
|
|
177
|
+
x: Math.min(28, Math.max(0, y.x - l.left)),
|
|
178
|
+
y: Math.min(24, Math.max(0, y.y - l.top))
|
|
179
|
+
}
|
|
180
|
+
}, c = s.ownerDocument, t = c.defaultView, t == null || t.addEventListener("pointermove", U, { passive: !1 }), t == null || t.addEventListener("pointerup", J), t == null || t.addEventListener("pointercancel", L), t == null || t.addEventListener("keydown", F), t == null || t.addEventListener("blur", L), t == null || t.addEventListener("resize", p), t == null || t.addEventListener("scroll", p, {
|
|
181
|
+
capture: !0,
|
|
182
|
+
passive: !0
|
|
183
|
+
}), c.addEventListener("selectstart", $, !0), c.addEventListener("visibilitychange", H), x && (V = setTimeout(O, x)), e.pointerType !== "touch" && (e.preventDefault(), (Z = i.closest(
|
|
184
|
+
"button, a[href], input, textarea, select, summary, [contenteditable=true], [tabindex]"
|
|
185
|
+
)) == null || Z.focus({ preventScroll: !0 }));
|
|
186
|
+
}
|
|
187
|
+
function U(e) {
|
|
188
|
+
if ((a == null ? void 0 : a.id) === e.pointerId) {
|
|
189
|
+
if (a.latest = { x: e.clientX, y: e.clientY }, !f.value && Math.hypot(
|
|
190
|
+
e.clientX - a.origin.x,
|
|
191
|
+
e.clientY - a.origin.y
|
|
192
|
+
) >= a.threshold) {
|
|
193
|
+
if (a.delay) return b();
|
|
194
|
+
O();
|
|
195
|
+
}
|
|
196
|
+
f.value && (e.preventDefault(), p());
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
function T(e) {
|
|
200
|
+
e.stopImmediatePropagation(), e.preventDefault(), t == null || t.removeEventListener("click", T, !0), clearTimeout(P);
|
|
201
|
+
}
|
|
202
|
+
function J(e) {
|
|
203
|
+
if ((a == null ? void 0 : a.id) === e.pointerId) {
|
|
204
|
+
if (!f.value) return b();
|
|
205
|
+
e.preventDefault(), t == null || t.addEventListener("click", T, !0), clearTimeout(P), P = setTimeout(
|
|
206
|
+
() => t == null ? void 0 : t.removeEventListener("click", T, !0),
|
|
207
|
+
0
|
|
208
|
+
), a.latest = { x: e.clientX, y: e.clientY }, ((h == null ? void 0 : h.x) !== e.clientX || h.y !== e.clientY) && K(0, !1), N();
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
async function N() {
|
|
212
|
+
const e = B();
|
|
213
|
+
if (!e) return !1;
|
|
214
|
+
const { result: n, candidate: o, drag: i } = e, s = !!o && !!n && !("reason" in n);
|
|
215
|
+
if (s || R(!0, a == null ? void 0 : a.row), b(), !s) {
|
|
216
|
+
const u = n && "reason" in n ? n : k("outside");
|
|
217
|
+
return u.reason !== "noop" ? r.reject(u) : r.announce(u.message), !1;
|
|
218
|
+
}
|
|
219
|
+
return te(
|
|
220
|
+
(u) => _(r, i, o, u),
|
|
221
|
+
() => r.row(i.keys[0])
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
async function Q(e, n, o) {
|
|
225
|
+
if (D.value || Y(r)) return !1;
|
|
226
|
+
const i = q(e, o);
|
|
227
|
+
return i ? _(r, i, n) : !1;
|
|
228
|
+
}
|
|
229
|
+
function W(e, n, o) {
|
|
230
|
+
const i = de(r, e, n);
|
|
231
|
+
return i ? Q(j(e), i, o) : Promise.resolve(!1);
|
|
232
|
+
}
|
|
233
|
+
const ae = ke(r, {
|
|
234
|
+
current: () => f.value,
|
|
235
|
+
begin: (e) => {
|
|
236
|
+
var n;
|
|
237
|
+
z(e, "keyboard") && (t = (n = r.root()) == null ? void 0 : n.ownerDocument.defaultView, t == null || t.addEventListener("keydown", F), t == null || t.addEventListener("blur", L));
|
|
238
|
+
},
|
|
239
|
+
update: A,
|
|
240
|
+
finish: N,
|
|
241
|
+
cancel: v,
|
|
242
|
+
relative: (e, n) => W(e, n, "keyboard")
|
|
243
|
+
});
|
|
244
|
+
function ie() {
|
|
245
|
+
var n;
|
|
246
|
+
const e = m();
|
|
247
|
+
(e == null ? void 0 : e.source) === r ? v("conflict") : ((n = e == null ? void 0 : e.candidate) == null ? void 0 : n.port) === r && (S({ ...e, candidate: void 0, result: void 0 }), e.source.preview(null), e.source.announce(k("conflict").message));
|
|
248
|
+
}
|
|
249
|
+
const se = X(() => {
|
|
250
|
+
const e = G.value;
|
|
251
|
+
if (e != null && e.candidate)
|
|
252
|
+
return ue(r, e.candidate, e.drag, e.result);
|
|
253
|
+
});
|
|
254
|
+
return {
|
|
255
|
+
own: f,
|
|
256
|
+
over: G,
|
|
257
|
+
ghost: g,
|
|
258
|
+
anchorForDisplay: se,
|
|
259
|
+
pointerDown: oe,
|
|
260
|
+
keyboard: ae,
|
|
261
|
+
move: Q,
|
|
262
|
+
relative: W,
|
|
263
|
+
cancel: v,
|
|
264
|
+
detach: re,
|
|
265
|
+
dataChanged: ie
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
export {
|
|
269
|
+
Ye as useSortDrag
|
|
270
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { nextTick as E } from "vue";
|
|
2
|
+
import { keyStep as x, candidateAt as O } from "./geometry.js";
|
|
3
|
+
import { linkedPorts as L } from "./model.js";
|
|
4
|
+
const P = "button,input,select,textarea,a[href],label,[contenteditable=true],[role=button],[data-sort-ignore]", T = /* @__PURE__ */ new Set([" ", "Enter"]);
|
|
5
|
+
function K(t, r, e) {
|
|
6
|
+
if (!e) return "";
|
|
7
|
+
if ("reason" in e) return e.message;
|
|
8
|
+
const i = e.target === t ? e.changes[0].next.indexOf(r) : e.proposal.index;
|
|
9
|
+
return `${e.target.props.ariaLabel ?? "目标列表"},第 ${i + 1} 项`;
|
|
10
|
+
}
|
|
11
|
+
function M(t) {
|
|
12
|
+
return L(t).sort((r, e) => {
|
|
13
|
+
const i = r.root(), c = e.root();
|
|
14
|
+
return !i || !c || i === c ? 0 : i.compareDocumentPosition(c) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function N(t, r) {
|
|
18
|
+
return (e, i, c) => {
|
|
19
|
+
var g, k;
|
|
20
|
+
if (t.props.keyboard === !1 || e.defaultPrevented || c)
|
|
21
|
+
return;
|
|
22
|
+
const a = e.target, p = e.currentTarget;
|
|
23
|
+
if (!(a instanceof Element) || a.closest("[data-sort-root]") !== t.root())
|
|
24
|
+
return;
|
|
25
|
+
const m = a.closest("[data-sort-handle]") || typeof t.props.handle == "string" && a.closest(t.props.handle);
|
|
26
|
+
if (a !== p && !m && a.closest(P)) return;
|
|
27
|
+
const o = r.current();
|
|
28
|
+
if (e.altKey) {
|
|
29
|
+
const f = x(t, e.key);
|
|
30
|
+
f && !o && (e.preventDefault(), r.relative(i, f));
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (T.has(e.key) && (m || a === p)) {
|
|
34
|
+
if (e.preventDefault(), e.repeat) return;
|
|
35
|
+
(o == null ? void 0 : o.drag.source) === "keyboard" ? r.finish() : r.begin(i);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if ((o == null ? void 0 : o.drag.source) !== "keyboard") return;
|
|
39
|
+
if (e.key === "Escape" || e.key === "Tab") {
|
|
40
|
+
e.key === "Escape" && e.preventDefault(), r.cancel();
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
let n = ((g = o.candidate) == null ? void 0 : g.port) ?? t, s = ((k = o.candidate) == null ? void 0 : k.index) ?? o.drag.indices[0];
|
|
44
|
+
const l = x(n, e.key);
|
|
45
|
+
if (e.ctrlKey && e.key.startsWith("Arrow")) {
|
|
46
|
+
const f = e.key === "ArrowLeft" || e.key === "ArrowUp" ? -1 : 1, b = M(t), u = b[b.indexOf(n) + f];
|
|
47
|
+
if (!u) return;
|
|
48
|
+
n = u, s = u.data().items.length;
|
|
49
|
+
} else if (e.key === "Home") s = 0;
|
|
50
|
+
else if (e.key === "End") s = n.data().items.length;
|
|
51
|
+
else if (l)
|
|
52
|
+
s += l, !o.candidate && l > 0 && n.props.mode !== "swap" && s++;
|
|
53
|
+
else return;
|
|
54
|
+
const w = n === t && t.props.mode === "swap", D = Math.max(0, n.data().items.length - (w ? 1 : 0)), y = O(
|
|
55
|
+
t,
|
|
56
|
+
n,
|
|
57
|
+
Math.min(D, Math.max(0, s))
|
|
58
|
+
);
|
|
59
|
+
e.preventDefault();
|
|
60
|
+
const d = a instanceof HTMLElement ? a : void 0;
|
|
61
|
+
r.update(y);
|
|
62
|
+
const h = y.anchor;
|
|
63
|
+
h !== void 0 && E(() => {
|
|
64
|
+
r.current() && (d != null && d.isConnected) && d.ownerDocument.activeElement === d.ownerDocument.body && d.focus({ preventScroll: !0 }), (n !== t || !n.props.virtual) && n.scroll(h);
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export {
|
|
69
|
+
K as keyboardPreviewLabel,
|
|
70
|
+
P as sortInteractive,
|
|
71
|
+
N as useSortKeyboard
|
|
72
|
+
};
|