hys-ui 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +59 -0
- package/README.md +68 -59
- package/dist/components/HysAlert/HysAlert.vue.js +5 -54
- package/dist/components/HysAlert/HysAlert2.vue.js +159 -2
- package/dist/components/HysAnimatedNumber/HysAnimatedNumber.vue.js +5 -41
- package/dist/components/HysAnimatedNumber/HysAnimatedNumber2.vue.js +146 -2
- package/dist/components/HysAutocomplete/HysAutocomplete.vue.js +2 -2
- package/dist/components/HysAutocomplete/HysAutocomplete2.vue.js +285 -273
- package/dist/components/HysAvatarGroup/HysAvatarGroup.vue.js +1 -1
- package/dist/components/HysAvatarGroup/HysAvatarGroup2.vue.js +102 -98
- package/dist/components/HysBreadcrumb/HysBreadcrumb.vue.js +1 -1
- package/dist/components/HysBreadcrumb/HysBreadcrumb2.vue.js +273 -59
- package/dist/components/HysButton/HysButton.vue.js +2 -2
- package/dist/components/HysButton/HysButton2.vue.js +227 -60
- package/dist/components/HysButtonGroup/HysButtonGroup.vue.js +7 -0
- package/dist/components/HysButtonGroup/HysButtonGroup2.vue.js +51 -0
- package/dist/components/HysCalendar/HysCalendar.vue.js +3 -3
- package/dist/components/HysCalendar/HysCalendar2.vue.js +237 -225
- package/dist/components/HysCascader/HysCascader.vue.js +2 -2
- package/dist/components/HysCascader/HysCascader2.vue.js +337 -324
- package/dist/components/HysColorPicker/HysColorPanel.vue.js +7 -0
- package/dist/components/HysColorPicker/HysColorPanel2.vue.js +238 -0
- package/dist/components/HysColorPicker/HysColorPicker.vue.js +2 -2
- package/dist/components/HysColorPicker/HysColorPicker2.vue.js +239 -217
- package/dist/components/HysCommandPalette/HysCommandPalette.vue.js +90 -76
- package/dist/components/HysContextMenu/HysContextMenu.vue.js +5 -89
- package/dist/components/HysContextMenu/HysContextMenu2.vue.js +247 -2
- package/dist/components/HysContextMenu/HysMenuPanel.vue.js +7 -0
- package/dist/components/HysContextMenu/HysMenuPanel2.vue.js +208 -0
- package/dist/components/HysContextMenu/HysMenuSlot.js +10 -0
- package/dist/components/HysDataGrid/HysDataGrid.vue.js +1 -1
- package/dist/components/HysDataGrid/HysDataGrid2.vue.js +1008 -559
- package/dist/components/HysDatePicker/HysDatePicker.vue.js +2 -0
- package/dist/components/HysDatePicker/HysDatePickerControl.vue.js +2 -2
- package/dist/components/HysDatePicker/HysDatePickerControl2.vue.js +539 -526
- package/dist/components/HysDateRangePicker/HysDateRangePicker.vue.js +5 -3
- package/dist/components/HysDrawer/HysDrawer.vue.js +1 -1
- package/dist/components/HysDrawer/HysDrawer2.vue.js +434 -84
- package/dist/components/HysEmpty/HysEmpty.vue.js +5 -41
- package/dist/components/HysEmpty/HysEmpty2.vue.js +181 -2
- package/dist/components/HysFormItem/HysFormItem.vue.js +2 -2
- package/dist/components/HysFormItem/HysFormItem2.vue.js +171 -164
- package/dist/components/HysGantt/HysGantt.vue.js +1 -1
- package/dist/components/HysGantt/HysGantt2.vue.js +810 -795
- package/dist/components/HysMention/HysMention.vue.js +1 -1
- package/dist/components/HysMention/HysMention2.vue.js +1092 -142
- package/dist/components/HysModal/HysModal.vue.js +2 -2
- package/dist/components/HysModal/HysModal2.vue.js +491 -85
- package/dist/components/HysPagination/HysPagination.vue.js +2 -2
- package/dist/components/HysPagination/HysPagination2.vue.js +243 -180
- package/dist/components/HysPopover/HysPopover.vue.js +5 -91
- package/dist/components/HysPopover/HysPopover2.vue.js +120 -2
- package/dist/components/HysProgress/HysProgress.vue.js +2 -2
- package/dist/components/HysProgress/HysProgress2.vue.js +319 -52
- package/dist/components/HysSearch/HysSearch.vue.js +5 -82
- package/dist/components/HysSearch/HysSearch2.vue.js +176 -2
- package/dist/components/HysSelect/HysSelect.vue.js +2 -2
- package/dist/components/HysSelect/HysSelect2.vue.js +755 -590
- package/dist/components/HysSlider/HysSlider.vue.js +2 -2
- package/dist/components/HysSlider/HysSlider2.vue.js +192 -188
- package/dist/components/HysSlider/SliderTooltip.vue.js +2 -2
- package/dist/components/HysSlider/SliderTooltip2.vue.js +103 -89
- package/dist/components/HysSplitPane/HysSplitPane.vue.js +315 -58
- package/dist/components/HysSplitPane/HysSplitPane3.vue.js +5 -0
- package/dist/components/HysTable/HysTable.vue.js +2 -2
- package/dist/components/HysTable/HysTable2.vue.js +1416 -1127
- package/dist/components/HysTagInput/HysTagInput.vue.js +5 -82
- package/dist/components/HysTagInput/HysTagInput2.vue.js +396 -2
- package/dist/components/HysTimeline/HysTimeline.vue.js +2 -2
- package/dist/components/HysTimeline/HysTimeline2.vue.js +243 -24
- package/dist/components/HysTooltip/HysTooltip.vue.js +5 -64
- package/dist/components/HysTooltip/HysTooltip2.vue.js +110 -2
- package/dist/components/HysTour/HysTour.vue.js +291 -63
- package/dist/components/HysTour/HysTour3.vue.js +5 -0
- package/dist/components/HysTransfer/HysTransfer.vue.js +2 -2
- package/dist/components/HysTransfer/HysTransfer2.vue.js +237 -207
- package/dist/components/HysTransfer/HysTransferPanel.vue.js +1 -1
- package/dist/components/HysTransfer/HysTransferPanel2.vue.js +320 -271
- package/dist/components/HysTree/HysTree.vue.js +2 -2
- package/dist/components/HysTree/HysTree2.vue.js +195 -184
- package/dist/components/HysTreeSelect/HysTreeSelect.vue.js +4 -4
- package/dist/components/HysTreeSelect/HysTreeSelect2.vue.js +389 -377
- package/dist/components/HysUpload/HysUpload.vue.js +2 -2
- package/dist/components/HysUpload/HysUpload2.vue.js +459 -125
- package/dist/components/HysVirtualTable/HysVirtualTable.vue.js +5 -94
- package/dist/components/HysVirtualTable/HysVirtualTable2.vue.js +656 -2
- package/dist/composables/buttonGroup.js +12 -0
- package/dist/composables/color.js +97 -0
- package/dist/composables/dataGrid.js +68 -0
- package/dist/composables/drawer.js +17 -0
- package/dist/composables/feedback.js +14 -0
- package/dist/composables/floatingPosition.js +18 -0
- package/dist/composables/mentionDocument.js +79 -0
- package/dist/composables/mentionEditor.js +58 -0
- package/dist/composables/menu.js +96 -0
- package/dist/composables/modal.js +14 -0
- package/dist/composables/overlayManager.js +48 -18
- package/dist/composables/progress.js +94 -0
- package/dist/composables/selectOptions.js +44 -38
- package/dist/composables/splitPaneSizes.js +58 -0
- package/dist/composables/table.js +128 -105
- package/dist/composables/tagInput.js +16 -0
- package/dist/composables/timeline.js +19 -0
- package/dist/composables/transfer.js +19 -17
- package/dist/composables/upload.js +55 -0
- package/dist/composables/uploadRequest.js +58 -0
- package/dist/composables/useAlert.js +124 -0
- package/dist/composables/useColorPicker.js +402 -0
- package/dist/composables/useContextMenu.js +514 -0
- package/dist/composables/useDataGridRemote.js +67 -0
- package/dist/composables/useDialog.js +86 -43
- package/dist/composables/useDrawerPush.js +33 -0
- package/dist/composables/useDrawerResize.js +221 -0
- package/dist/composables/useFloating.js +118 -80
- package/dist/composables/useHysModal.js +185 -0
- package/dist/composables/useMentionCaret.js +81 -0
- package/dist/composables/useMentionList.js +81 -0
- package/dist/composables/useMentionModel.js +90 -0
- package/dist/composables/useMentionOptions.js +421 -0
- package/dist/composables/useModal.js +295 -0
- package/dist/composables/useModalInteraction.js +394 -0
- package/dist/composables/usePopupSurface.js +458 -0
- package/dist/composables/useSplitPaneDrag.js +52 -0
- package/dist/composables/useSplitPaneStorage.js +38 -0
- package/dist/composables/useTable.js +344 -312
- package/dist/composables/useTableSticky.js +79 -0
- package/dist/composables/useTagInput.js +313 -0
- package/dist/composables/useTourLayout.js +129 -0
- package/dist/composables/useTransferMotion.js +185 -0
- package/dist/composables/useUpload.js +472 -0
- package/dist/composables/useUploadModel.js +65 -0
- package/dist/composables/useUploadRequests.js +266 -0
- package/dist/composables/useVirtualTableLayout.js +277 -0
- package/dist/composables/virtualTable.js +43 -0
- package/dist/config.js +11 -11
- package/dist/index.js +175 -153
- package/dist/internal/MultiSplitPane.vue.js +305 -0
- package/dist/internal/MultiSplitPane2.vue.js +4 -0
- package/dist/internal/PopupReference.js +39 -0
- package/dist/internal/PopupSurfacePanel.vue.js +7 -0
- package/dist/internal/PopupSurfacePanel2.vue.js +92 -0
- package/dist/motion/PopupMotion.js +105 -0
- package/dist/motion/popup.js +10 -0
- package/dist/style.css +1 -1
- package/dist/types/components/HysAlert/HysAlert.vue.d.ts +32 -22
- package/dist/types/components/HysAnimatedNumber/HysAnimatedNumber.vue.d.ts +61 -7
- package/dist/types/components/HysAutocomplete/HysAutocomplete.vue.d.ts +7 -7
- package/dist/types/components/HysAvatarGroup/HysAvatarGroup.vue.d.ts +6 -1
- package/dist/types/components/HysBadge/HysBadge.vue.d.ts +3 -3
- package/dist/types/components/HysBreadcrumb/HysBreadcrumb.vue.d.ts +54 -31
- package/dist/types/components/HysButton/HysButton.vue.d.ts +82 -22
- package/dist/types/components/HysButtonGroup/HysButtonGroup.vue.d.ts +30 -0
- package/dist/types/components/HysCalendar/HysCalendar.vue.d.ts +3 -2
- package/dist/types/components/HysCascader/HysCascader.vue.d.ts +7 -7
- package/dist/types/components/HysCascader/HysCascaderColumn.vue.d.ts +2 -2
- package/dist/types/components/HysColorPicker/HysColorPanel.vue.d.ts +58 -0
- package/dist/types/components/HysColorPicker/HysColorPicker.vue.d.ts +63 -10
- package/dist/types/components/HysCommandPalette/HysCommandPalette.vue.d.ts +2 -1
- package/dist/types/components/HysContextMenu/HysContextMenu.vue.d.ts +50 -34
- package/dist/types/components/HysContextMenu/HysMenuPanel.vue.d.ts +79 -0
- package/dist/types/components/HysContextMenu/HysMenuSlot.d.ts +8 -0
- package/dist/types/components/HysDataGrid/HysDataGrid.vue.d.ts +65 -118
- package/dist/types/components/HysDatePicker/HysDatePickerControl.vue.d.ts +3 -3
- package/dist/types/components/HysDrawer/HysDrawer.vue.d.ts +92 -35
- package/dist/types/components/HysEmpty/HysEmpty.vue.d.ts +24 -20
- package/dist/types/components/HysFileManager/HysFileManager.vue.d.ts +2 -2
- package/dist/types/components/HysGantt/HysGantt.vue.d.ts +2 -1
- package/dist/types/components/HysMention/HysMention.vue.d.ts +91 -39
- package/dist/types/components/HysModal/HysModal.vue.d.ts +111 -34
- package/dist/types/components/HysNumberInput/HysNumberInput.vue.d.ts +2 -2
- package/dist/types/components/HysPagination/HysPagination.vue.d.ts +55 -4
- package/dist/types/components/HysPopover/HysPopover.vue.d.ts +41 -29
- package/dist/types/components/HysProgress/HysProgress.vue.d.ts +18 -24
- package/dist/types/components/HysRating/HysRating.vue.d.ts +1 -1
- package/dist/types/components/HysResizablePanel/HysResizablePanel.vue.d.ts +2 -2
- package/dist/types/components/HysSearch/HysSearch.vue.d.ts +45 -7
- package/dist/types/components/HysSelect/HysSelect.vue.d.ts +19 -5
- package/dist/types/components/HysSlider/HysSlider.vue.d.ts +5 -4
- package/dist/types/components/HysSlider/SliderTooltip.vue.d.ts +3 -1
- package/dist/types/components/HysSplitPane/HysSplitPane.vue.d.ts +125 -14
- package/dist/types/components/HysSteps/HysSteps.vue.d.ts +1 -1
- package/dist/types/components/HysTable/HysTable.vue.d.ts +1742 -5
- package/dist/types/components/HysTabs/HysTabs.vue.d.ts +2 -2
- package/dist/types/components/HysTagInput/HysTagInput.vue.d.ts +47 -25
- package/dist/types/components/HysTimeline/HysTimeline.vue.d.ts +19 -32
- package/dist/types/components/HysTooltip/HysTooltip.vue.d.ts +39 -19
- package/dist/types/components/HysTour/HysTour.vue.d.ts +46 -8
- package/dist/types/components/HysTransfer/HysTransfer.vue.d.ts +2 -2
- package/dist/types/components/HysTransfer/HysTransferPanel.vue.d.ts +5 -3
- package/dist/types/components/HysTree/HysTree.vue.d.ts +2 -2
- package/dist/types/components/HysUpload/HysUpload.vue.d.ts +55 -67
- package/dist/types/components/HysVirtualTable/HysVirtualTable.vue.d.ts +71 -40
- package/dist/types/composables/autocomplete.d.ts +3 -0
- package/dist/types/composables/avatar.d.ts +3 -0
- package/dist/types/composables/buttonGroup.d.ts +9 -0
- package/dist/types/composables/cascader.d.ts +3 -0
- package/dist/types/composables/color.d.ts +97 -0
- package/dist/types/composables/dataGrid.d.ts +100 -0
- package/dist/types/composables/datePicker.d.ts +3 -0
- package/dist/types/composables/drawer.d.ts +102 -0
- package/dist/types/composables/feedback.d.ts +98 -0
- package/dist/types/composables/floatingPosition.d.ts +14 -0
- package/dist/types/composables/formContext.d.ts +2 -0
- package/dist/types/composables/mention.d.ts +284 -0
- package/dist/types/composables/mentionDocument.d.ts +15 -0
- package/dist/types/composables/mentionEditor.d.ts +7 -0
- package/dist/types/composables/menu.d.ts +183 -0
- package/dist/types/composables/modal.d.ts +185 -0
- package/dist/types/composables/overlayManager.d.ts +7 -3
- package/dist/types/composables/popupSurface.d.ts +83 -0
- package/dist/types/composables/progress.d.ts +92 -0
- package/dist/types/composables/selectOptions.d.ts +7 -0
- package/dist/types/composables/splitPaneSizes.d.ts +11 -0
- package/dist/types/composables/table.d.ts +119 -6
- package/dist/types/composables/tagInput.d.ts +96 -0
- package/dist/types/composables/timeline.d.ts +82 -0
- package/dist/types/composables/tour.d.ts +68 -0
- package/dist/types/composables/transfer.d.ts +7 -0
- package/dist/types/composables/tree.d.ts +3 -0
- package/dist/types/composables/treeSelect.d.ts +3 -0
- package/dist/types/composables/upload.d.ts +202 -0
- package/dist/types/composables/uploadRequest.d.ts +3 -0
- package/dist/types/composables/useAlert.d.ts +21 -0
- package/dist/types/composables/useCascader.d.ts +1 -1
- package/dist/types/composables/useColorPicker.d.ts +101 -0
- package/dist/types/composables/useContextMenu.d.ts +81 -0
- package/dist/types/composables/useDataGridRemote.d.ts +15 -0
- package/dist/types/composables/useDialog.d.ts +16 -3
- package/dist/types/composables/useDrawerPush.d.ts +6 -0
- package/dist/types/composables/useDrawerResize.d.ts +27 -0
- package/dist/types/composables/useFloating.d.ts +22 -3
- package/dist/types/composables/useHysModal.d.ts +44 -0
- package/dist/types/composables/useMentionCaret.d.ts +6 -0
- package/dist/types/composables/useMentionList.d.ts +23 -0
- package/dist/types/composables/useMentionModel.d.ts +14 -0
- package/dist/types/composables/useMentionOptions.d.ts +26 -0
- package/dist/types/composables/useModal.d.ts +62 -0
- package/dist/types/composables/useModalInteraction.d.ts +27 -0
- package/dist/types/composables/usePopupSurface.d.ts +3341 -0
- package/dist/types/composables/useSplitPaneDrag.d.ts +14 -0
- package/dist/types/composables/useSplitPaneStorage.d.ts +4 -0
- package/dist/types/composables/useTable.d.ts +7 -3
- package/dist/types/composables/useTableSticky.d.ts +22 -0
- package/dist/types/composables/useTagInput.d.ts +66 -0
- package/dist/types/composables/useTourLayout.d.ts +33 -0
- package/dist/types/composables/useTransferMotion.d.ts +36 -0
- package/dist/types/composables/useUpload.d.ts +94 -0
- package/dist/types/composables/useUploadModel.d.ts +14 -0
- package/dist/types/composables/useUploadRequests.d.ts +38 -0
- package/dist/types/composables/useVirtualTableLayout.d.ts +51 -0
- package/dist/types/composables/virtualTable.d.ts +126 -0
- package/dist/types/config.d.ts +1 -0
- package/dist/types/index.d.ts +53 -3
- package/dist/types/internal/MultiSplitPane.vue.d.ts +54 -0
- package/dist/types/internal/PopupReference.d.ts +18 -0
- package/dist/types/internal/PopupSurfacePanel.vue.d.ts +37 -0
- package/dist/types/motion/PopupMotion.d.ts +59 -0
- package/dist/types/motion/popup.d.ts +12 -0
- package/package.json +3 -2
- package/dist/components/HysSplitPane/HysSplitPane2.vue.js +0 -4
- package/dist/components/HysTour/HysTour2.vue.js +0 -4
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { computed as O, ref as b, shallowRef as de, watch as L, onMounted as ve, onActivated as me, onDeactivated as ye, onBeforeUnmount as be, nextTick as P } from "vue";
|
|
2
|
+
import { useChoiceModel as ae } from "./choiceModel.js";
|
|
3
|
+
import { useDialog as he } from "./useDialog.js";
|
|
4
|
+
import { useHysRootAttrs as ge } from "../config.js";
|
|
5
|
+
import { useModalInteraction as Ce } from "./useModalInteraction.js";
|
|
6
|
+
function Se(a, v, o, te = {}) {
|
|
7
|
+
const h = ae(
|
|
8
|
+
{
|
|
9
|
+
get modelValue() {
|
|
10
|
+
return a.open === void 0 ? a.modelValue : a.open;
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
() => !!a.defaultOpen
|
|
14
|
+
), A = ae(
|
|
15
|
+
{
|
|
16
|
+
get modelValue() {
|
|
17
|
+
return a.fullscreen;
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
() => !!a.defaultFullscreen
|
|
21
|
+
), $ = O(() => !!A.current.value), u = b(!0), w = b(!1), i = b(!1), g = b(!1), V = b(!1), m = b(!1), k = b(""), ne = ge(), z = b(!1), f = de(), B = O(
|
|
22
|
+
() => {
|
|
23
|
+
var e;
|
|
24
|
+
return ((e = f.value) == null ? void 0 : e.kind) === "confirm" || !!a.confirmLoading;
|
|
25
|
+
}
|
|
26
|
+
), I = O(
|
|
27
|
+
() => {
|
|
28
|
+
var e;
|
|
29
|
+
return ((e = f.value) == null ? void 0 : e.kind) === "close" || m.value || i.value && !h.current.value;
|
|
30
|
+
}
|
|
31
|
+
), G = O(() => B.value || I.value || !!a.loading), F = O(
|
|
32
|
+
() => ne.value["data-hys-motion"] !== "off" && !z.value && a.transition !== !1 && a.transition !== "none" && a.transitionDuration !== 0
|
|
33
|
+
);
|
|
34
|
+
let H, K = 0, M = 0, j = -1, S = -1, C, r;
|
|
35
|
+
const c = Ce(
|
|
36
|
+
a,
|
|
37
|
+
v,
|
|
38
|
+
i,
|
|
39
|
+
$,
|
|
40
|
+
o,
|
|
41
|
+
{
|
|
42
|
+
beforeStart: x,
|
|
43
|
+
motion: () => F.value,
|
|
44
|
+
enabled: te.interaction !== !1
|
|
45
|
+
}
|
|
46
|
+
), le = (e) => Number.isFinite(e) ? Math.max(0, Math.min(1, e)) : 1;
|
|
47
|
+
function x() {
|
|
48
|
+
C == null || C.cancel(), C = void 0;
|
|
49
|
+
}
|
|
50
|
+
function oe() {
|
|
51
|
+
var t, n, l, s;
|
|
52
|
+
const e = a.initialFocus;
|
|
53
|
+
if (e === !1) return !1;
|
|
54
|
+
if (e instanceof HTMLElement)
|
|
55
|
+
return e.isConnected ? e : void 0;
|
|
56
|
+
if (e === "dialog") return v.value;
|
|
57
|
+
if (e === "confirm" || e === "cancel")
|
|
58
|
+
return ((t = v.value) == null ? void 0 : t.querySelector(
|
|
59
|
+
`[data-hys-modal-${e}]:not(:disabled)`
|
|
60
|
+
)) ?? void 0;
|
|
61
|
+
if (e && e !== "auto")
|
|
62
|
+
try {
|
|
63
|
+
return ((n = v.value) == null ? void 0 : n.querySelector(e)) ?? void 0;
|
|
64
|
+
} catch {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
return ((l = v.value) == null ? void 0 : l.querySelector(
|
|
68
|
+
'[autofocus],input:not([disabled]):not([type="hidden"]),textarea:not([disabled]),select:not([disabled]),[data-hys-modal-initial-focus]'
|
|
69
|
+
)) ?? ((s = v.value) == null ? void 0 : s.querySelector(
|
|
70
|
+
".hys-ui-dialog-body button:not(:disabled),.hys-ui-dialog-body a[href],[data-hys-modal-cancel]:not(:disabled),[data-hys-modal-confirm]:not(:disabled)"
|
|
71
|
+
)) ?? v.value;
|
|
72
|
+
}
|
|
73
|
+
const y = he(
|
|
74
|
+
g,
|
|
75
|
+
v,
|
|
76
|
+
() => {
|
|
77
|
+
if (c.gesturing.value) {
|
|
78
|
+
c.stop(!0);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
a.closeOnEscape !== !1 && q("escape");
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
lockScroll: () => a.lockScroll ?? !(a.modal === !1 && a.modalPenetrable),
|
|
85
|
+
trapFocus: () => a.trapFocus ?? !(a.modal === !1 && a.modalPenetrable),
|
|
86
|
+
restoreFocus: () => a.restoreFocus !== !1,
|
|
87
|
+
initialFocus: oe,
|
|
88
|
+
zIndex: () => a.zIndex,
|
|
89
|
+
childVisible: () => i.value,
|
|
90
|
+
onOpenAutoFocus: (e) => o("openAutoFocus", e),
|
|
91
|
+
onCloseAutoFocus: (e) => o("closeAutoFocus", e)
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
function D() {
|
|
95
|
+
var e;
|
|
96
|
+
(e = f.value) == null || e.controller.abort(), f.value = void 0;
|
|
97
|
+
}
|
|
98
|
+
function J(e, t, n) {
|
|
99
|
+
const l = new AbortController(), s = {
|
|
100
|
+
kind: e,
|
|
101
|
+
context: { reason: t, event: n, signal: l.signal },
|
|
102
|
+
controller: l
|
|
103
|
+
};
|
|
104
|
+
return f.value = s, k.value = "", s;
|
|
105
|
+
}
|
|
106
|
+
const R = (e) => u.value && y.active.value && i.value && f.value === e && !e.context.signal.aborted;
|
|
107
|
+
function Q(e, t, n) {
|
|
108
|
+
const l = "操作未完成,请重试";
|
|
109
|
+
try {
|
|
110
|
+
k.value = typeof a.errorText == "function" ? String(a.errorText(e, t)) : a.errorText ?? l;
|
|
111
|
+
} catch {
|
|
112
|
+
k.value = l;
|
|
113
|
+
}
|
|
114
|
+
o(t === "confirm" ? "confirmError" : "closeError", e, n);
|
|
115
|
+
}
|
|
116
|
+
async function N(e) {
|
|
117
|
+
return !u.value || !y.active.value ? !1 : h.current.value === e ? !0 : h.commit(
|
|
118
|
+
e,
|
|
119
|
+
(t) => {
|
|
120
|
+
o("update:open", t), o("update:modelValue", t);
|
|
121
|
+
},
|
|
122
|
+
() => {
|
|
123
|
+
}
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
async function q(e = "button", t) {
|
|
127
|
+
const n = typeof e == "string" ? e : "button";
|
|
128
|
+
if (typeof e != "string" && (t = e), n === "confirm") return U(t);
|
|
129
|
+
if (!u.value || !y.active.value || !i.value || I.value || B.value && !a.closeWhileConfirming)
|
|
130
|
+
return !1;
|
|
131
|
+
f.value && D();
|
|
132
|
+
const l = J("close", n, t);
|
|
133
|
+
try {
|
|
134
|
+
return a.beforeClose && await a.beforeClose(n, l.context) === !1 || !R(l) ? !1 : (o("cancel", l.context), o("close"), await N(!1));
|
|
135
|
+
} catch (s) {
|
|
136
|
+
return R(l) && Q(s, "close", l.context), !1;
|
|
137
|
+
} finally {
|
|
138
|
+
f.value === l && (f.value = void 0);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
async function U(e) {
|
|
142
|
+
var n;
|
|
143
|
+
if (!u.value || !y.active.value || !i.value || G.value || a.confirmDisabled || (n = a.okButtonProps) != null && n.disabled)
|
|
144
|
+
return !1;
|
|
145
|
+
const t = J("confirm", "confirm", e);
|
|
146
|
+
try {
|
|
147
|
+
return a.beforeConfirm && await a.beforeConfirm(t.context) === !1 || !R(t) || a.closeOnConfirm !== !1 && a.beforeClose && await a.beforeClose("confirm", t.context) === !1 || !R(t) ? !1 : (o("ok", t.context), a.closeOnConfirm === !1 ? !0 : (o("close"), await N(!1)));
|
|
148
|
+
} catch (l) {
|
|
149
|
+
return R(t) && Q(l, "confirm", t.context), !1;
|
|
150
|
+
} finally {
|
|
151
|
+
f.value === t && (f.value = void 0);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
const ie = (e) => Number.isFinite(e) ? Math.max(0, Math.min(3e4, e)) : 0;
|
|
155
|
+
function W() {
|
|
156
|
+
clearTimeout(H);
|
|
157
|
+
const e = ++K;
|
|
158
|
+
if (!u.value || !y.active.value || w.value) {
|
|
159
|
+
x(), D(), c.stop(!0), i.value = !1, g.value = !1, m.value = !1;
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
const t = !!h.current.value;
|
|
163
|
+
if (t || D(), t === i.value) return;
|
|
164
|
+
const n = () => {
|
|
165
|
+
e !== K || !u.value || !y.active.value || w.value || (t ? (M++, j = -1, S = -1, m.value = !1, V.value = !0, k.value = "", g.value = !0, i.value = !0, o("open"), o("visibleChange", !0)) : (x(), m.value = !0, S = M, c.stop(!0), i.value = !1, F.value || (g.value = !1), o("visibleChange", !1)));
|
|
166
|
+
}, l = ie(t ? a.openDelay : a.closeDelay);
|
|
167
|
+
l ? H = setTimeout(n, l) : n();
|
|
168
|
+
}
|
|
169
|
+
async function ue() {
|
|
170
|
+
const e = M;
|
|
171
|
+
await P(), await P(), u.value && i.value && e === M && j !== e && (j = e, o("opened"));
|
|
172
|
+
}
|
|
173
|
+
async function Z() {
|
|
174
|
+
const e = S;
|
|
175
|
+
!m.value || i.value || e < 0 || (g.value = !1, m.value = !1, a.destroyOnClose !== !1 && !a.forceRender && (V.value = !1), a.resetPositionOnClose !== !1 && c.resetPosition(), a.resetSizeOnClose !== !1 && c.resetSize(), await P(), await P(), u.value && !i.value && M === e && S === e && (S = -1, o("closed"), o("afterClose")));
|
|
176
|
+
}
|
|
177
|
+
async function re() {
|
|
178
|
+
if (!u.value || !y.active.value) return !1;
|
|
179
|
+
w.value = !1;
|
|
180
|
+
const e = await N(!0);
|
|
181
|
+
return e && W(), e;
|
|
182
|
+
}
|
|
183
|
+
async function _(e) {
|
|
184
|
+
if (!u.value || !i.value) return !1;
|
|
185
|
+
if (c.stop(!0), A.current.value === e) return !0;
|
|
186
|
+
const t = v.value, n = t == null ? void 0 : t.getBoundingClientRect(), l = t ? getComputedStyle(t).borderRadius : "0px";
|
|
187
|
+
x();
|
|
188
|
+
const s = await A.commit(
|
|
189
|
+
e,
|
|
190
|
+
(d) => o("update:fullscreen", d),
|
|
191
|
+
(d) => o("fullscreenChange", d)
|
|
192
|
+
);
|
|
193
|
+
if (s && !e && (c.clampViewport(), await P()), s && F.value && t && n && i.value && u.value && typeof t.animate == "function") {
|
|
194
|
+
const d = t.getBoundingClientRect(), Y = getComputedStyle(t);
|
|
195
|
+
if (d.width > 0 && d.height > 0) {
|
|
196
|
+
const ee = Y.transform === "none" ? "" : Y.transform, T = t.animate(
|
|
197
|
+
[
|
|
198
|
+
{
|
|
199
|
+
transformOrigin: "0 0",
|
|
200
|
+
transform: `translate(${n.left - d.left}px,${n.top - d.top}px) ${ee} scale(${n.width / d.width},${n.height / d.height})`,
|
|
201
|
+
borderRadius: l
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
transformOrigin: "0 0",
|
|
205
|
+
transform: ee || "none",
|
|
206
|
+
borderRadius: Y.borderRadius
|
|
207
|
+
}
|
|
208
|
+
],
|
|
209
|
+
{
|
|
210
|
+
duration: Math.max(
|
|
211
|
+
0,
|
|
212
|
+
Math.min(1e3, a.transitionDuration ?? 220)
|
|
213
|
+
),
|
|
214
|
+
easing: "cubic-bezier(.22,1,.36,1)"
|
|
215
|
+
}
|
|
216
|
+
);
|
|
217
|
+
C = T, T.onfinish = () => {
|
|
218
|
+
C === T && (C = void 0);
|
|
219
|
+
}, T.oncancel = T.onfinish;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return s;
|
|
223
|
+
}
|
|
224
|
+
function ce(e) {
|
|
225
|
+
if (a.draggable && e.altKey && e.key === "Home" && !e.defaultPrevented && !e.isComposing) {
|
|
226
|
+
e.preventDefault(), c.resetPosition();
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
a.confirmOnCtrlEnter && (e.ctrlKey || e.metaKey) && e.key === "Enter" && !e.isComposing && e.keyCode !== 229 && (e.preventDefault(), U(e));
|
|
230
|
+
}
|
|
231
|
+
let E;
|
|
232
|
+
function fe(e) {
|
|
233
|
+
e.target === e.currentTarget && e.button === 0 ? E = { id: e.pointerId, x: e.clientX, y: e.clientY } : E = void 0;
|
|
234
|
+
}
|
|
235
|
+
function se(e) {
|
|
236
|
+
const t = E;
|
|
237
|
+
E = void 0, t && t.id === e.pointerId && e.target === e.currentTarget && Math.hypot(t.x - e.clientX, t.y - e.clientY) < 6 && a.closeOnMask !== !1 && q("mask", e);
|
|
238
|
+
}
|
|
239
|
+
function X(e) {
|
|
240
|
+
z.value = e.matches;
|
|
241
|
+
}
|
|
242
|
+
function p() {
|
|
243
|
+
x(), u.value = !1, w.value = !0, K++, clearTimeout(H), D(), c.stop(!0), i.value = !1, g.value = !1, m.value = !1, r == null || r.removeEventListener("change", X), a.destroyOnClose !== !1 && !a.forceRender && (V.value = !1), h.current.value && (o("update:open", !1), o("update:modelValue", !1));
|
|
244
|
+
}
|
|
245
|
+
return L(
|
|
246
|
+
h.current,
|
|
247
|
+
(e, t) => {
|
|
248
|
+
e && e !== t && (w.value = !1), W();
|
|
249
|
+
},
|
|
250
|
+
{ immediate: !0, flush: "sync" }
|
|
251
|
+
), L([y.active, u, w], W, { flush: "post" }), L(
|
|
252
|
+
() => [a.beforeClose, a.beforeConfirm],
|
|
253
|
+
() => D()
|
|
254
|
+
), L(F, (e) => {
|
|
255
|
+
e || x(), !e && m.value && Z();
|
|
256
|
+
}), ve(() => {
|
|
257
|
+
var e;
|
|
258
|
+
r = (e = window.matchMedia) == null ? void 0 : e.call(window, "(prefers-reduced-motion: reduce)"), z.value = !!(r != null && r.matches), r == null || r.addEventListener("change", X);
|
|
259
|
+
}), me(() => {
|
|
260
|
+
u.value = !0, c.activate(), r == null || r.addEventListener("change", X);
|
|
261
|
+
}), ye(p), be(p), {
|
|
262
|
+
model: h,
|
|
263
|
+
alpha: le,
|
|
264
|
+
fullscreen: $,
|
|
265
|
+
live: u,
|
|
266
|
+
state: y,
|
|
267
|
+
shown: i,
|
|
268
|
+
engaged: g,
|
|
269
|
+
rendered: V,
|
|
270
|
+
leaving: m,
|
|
271
|
+
error: k,
|
|
272
|
+
confirming: B,
|
|
273
|
+
closing: I,
|
|
274
|
+
busy: G,
|
|
275
|
+
motion: F,
|
|
276
|
+
interaction: c,
|
|
277
|
+
show: re,
|
|
278
|
+
requestClose: q,
|
|
279
|
+
confirm: U,
|
|
280
|
+
cancel: (e) => {
|
|
281
|
+
var t;
|
|
282
|
+
return a.cancelDisabled || (t = a.cancelButtonProps) != null && t.disabled ? Promise.resolve(!1) : q("cancel", e);
|
|
283
|
+
},
|
|
284
|
+
setFullscreen: _,
|
|
285
|
+
toggleFullscreen: () => _(!$.value),
|
|
286
|
+
afterEnter: ue,
|
|
287
|
+
afterLeave: Z,
|
|
288
|
+
key: ce,
|
|
289
|
+
maskDown: fe,
|
|
290
|
+
maskUp: se
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
export {
|
|
294
|
+
Se as useModal
|
|
295
|
+
};
|
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
import { shallowRef as ue, ref as B, watch as W, nextTick as P, onMounted as se, onDeactivated as me, onBeforeUnmount as ve, computed as ce } from "vue";
|
|
2
|
+
import { modalLength as de, modalWidth as ge } from "./modal.js";
|
|
3
|
+
function xe(r, d, s, v, w, h = {}) {
|
|
4
|
+
const o = ue({ x: 0, y: 0 }), f = ue(), I = B(!1), S = B(!1), R = B(!1), C = B(!1), b = B();
|
|
5
|
+
let z = 0, c, m = !0, a;
|
|
6
|
+
const x = (e, t = 0) => Number.isFinite(e) ? e : t;
|
|
7
|
+
function G() {
|
|
8
|
+
if (!a && c && o.value.x === 0 && o.value.y === 0)
|
|
9
|
+
return;
|
|
10
|
+
l(!0);
|
|
11
|
+
const e = o.value;
|
|
12
|
+
o.value = { x: 0, y: 0 }, M(o.value, void 0, !1, !0), ie(e, o.value);
|
|
13
|
+
}
|
|
14
|
+
function T() {
|
|
15
|
+
if (!a && c && f.value === void 0) return;
|
|
16
|
+
l(!0);
|
|
17
|
+
const e = d.value, t = f.value !== void 0, i = t && m && s.value && !v.value ? e == null ? void 0 : e.getBoundingClientRect() : void 0;
|
|
18
|
+
if (f.value = void 0, !(!t || v.value) && (M(o.value, void 0, !0, !0), i && e && ee())) {
|
|
19
|
+
const n = e.getBoundingClientRect();
|
|
20
|
+
if (n.width > 0 && n.height > 0) {
|
|
21
|
+
const u = `translate3d(${o.value.x}px,${o.value.y}px,0)`;
|
|
22
|
+
te([
|
|
23
|
+
{
|
|
24
|
+
transformOrigin: "0 0",
|
|
25
|
+
transform: `translate(${i.left - n.left}px,${i.top - n.top}px) ${u} scale(${i.width / n.width},${i.height / n.height})`
|
|
26
|
+
},
|
|
27
|
+
{ transformOrigin: "0 0", transform: u }
|
|
28
|
+
]);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const X = () => {
|
|
33
|
+
var e, t, i, n;
|
|
34
|
+
return {
|
|
35
|
+
width: ((t = (e = d.value) == null ? void 0 : e.parentElement) == null ? void 0 : t.clientWidth) || document.documentElement.clientWidth || window.innerWidth,
|
|
36
|
+
height: ((n = (i = d.value) == null ? void 0 : i.parentElement) == null ? void 0 : n.clientHeight) || document.documentElement.clientHeight || window.innerHeight
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
function F(e, t, i = o.value, n = X(), u) {
|
|
40
|
+
if (r.overflow) {
|
|
41
|
+
if (r.keepHandleVisible === !1) return e;
|
|
42
|
+
const oe = u ?? O().map((D) => D.getBoundingClientRect());
|
|
43
|
+
if (oe.length) {
|
|
44
|
+
let D = -1 / 0, q = 1 / 0, N = 1 / 0, j = -1 / 0;
|
|
45
|
+
for (const $ of oe)
|
|
46
|
+
D = Math.max(D, $.left), q = Math.min(q, $.right), N = Math.min(N, $.top), j = Math.max(j, $.bottom);
|
|
47
|
+
return {
|
|
48
|
+
x: Math.max(
|
|
49
|
+
8 - D + i.x,
|
|
50
|
+
Math.min(n.width - 8 - q + i.x, e.x)
|
|
51
|
+
),
|
|
52
|
+
y: Math.max(
|
|
53
|
+
8 - N + i.y,
|
|
54
|
+
Math.min(n.height - 8 - j + i.y, e.y)
|
|
55
|
+
)
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
return e;
|
|
59
|
+
}
|
|
60
|
+
const { width: g, height: y } = n, E = 8 - t.left + i.x, k = g - 8 - t.right + i.x, L = 8 - t.top + i.y, H = y - 8 - t.bottom + i.y;
|
|
61
|
+
return {
|
|
62
|
+
x: E > k ? (E + k) / 2 : Math.max(E, Math.min(k, e.x)),
|
|
63
|
+
y: L > H ? Math.max(
|
|
64
|
+
L,
|
|
65
|
+
Math.min(e.y, L + Math.max(0, t.height - 40))
|
|
66
|
+
) : Math.max(L, Math.min(H, e.y))
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function J(e) {
|
|
70
|
+
!m || !s.value || v.value || !d.value || (l(!0), o.value = F(
|
|
71
|
+
{ x: x(e.x), y: x(e.y) },
|
|
72
|
+
d.value.getBoundingClientRect()
|
|
73
|
+
), M(o.value, void 0, !1, !0));
|
|
74
|
+
}
|
|
75
|
+
function Q(e, t = X()) {
|
|
76
|
+
const i = r.overflow ? Math.max(240, r.maxWidth ?? 6e3) : Math.max(0, t.width - ((e == null ? void 0 : e.left) ?? 8) - 8), n = r.overflow ? 6e3 : Math.max(0, t.height - ((e == null ? void 0 : e.top) ?? 8) - 8), u = Math.min(
|
|
77
|
+
i,
|
|
78
|
+
Math.max(120, x(r.maxWidth ?? i, i))
|
|
79
|
+
), g = typeof r.maxHeight == "number" ? r.maxHeight : typeof r.maxHeight == "string" && /^\d+(\.\d+)?px$/.test(r.maxHeight) ? parseFloat(r.maxHeight) : n, y = Math.min(
|
|
80
|
+
n,
|
|
81
|
+
Math.max(0, x(g, n))
|
|
82
|
+
);
|
|
83
|
+
return {
|
|
84
|
+
minWidth: Math.min(
|
|
85
|
+
u,
|
|
86
|
+
Math.max(120, x(r.minWidth ?? 280, 280))
|
|
87
|
+
),
|
|
88
|
+
maxWidth: u,
|
|
89
|
+
minHeight: Math.min(
|
|
90
|
+
y,
|
|
91
|
+
Math.max(80, x(r.minHeight ?? 160, 160))
|
|
92
|
+
),
|
|
93
|
+
maxHeight: y
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function Z(e) {
|
|
97
|
+
if (!m || !s.value || v.value) return;
|
|
98
|
+
l(!0);
|
|
99
|
+
const t = Q();
|
|
100
|
+
f.value = {
|
|
101
|
+
width: Math.max(
|
|
102
|
+
t.minWidth,
|
|
103
|
+
Math.min(t.maxWidth, x(e.width, t.minWidth))
|
|
104
|
+
),
|
|
105
|
+
height: Math.max(
|
|
106
|
+
t.minHeight,
|
|
107
|
+
Math.min(t.maxHeight, x(e.height, t.minHeight))
|
|
108
|
+
)
|
|
109
|
+
}, P(p);
|
|
110
|
+
}
|
|
111
|
+
function _() {
|
|
112
|
+
z = 0;
|
|
113
|
+
const e = a;
|
|
114
|
+
if (!e || !m || !s.value || !e.dirty) return;
|
|
115
|
+
e.dirty = !1;
|
|
116
|
+
const t = e.x - e.startX, i = e.y - e.startY;
|
|
117
|
+
if (e.kind === "drag")
|
|
118
|
+
e.previewPosition = F(
|
|
119
|
+
{ x: e.position.x + t, y: e.position.y + i },
|
|
120
|
+
e.box,
|
|
121
|
+
e.position,
|
|
122
|
+
e.screen,
|
|
123
|
+
e.handleBoxes
|
|
124
|
+
), M(e.previewPosition), w("drag", e.previewPosition);
|
|
125
|
+
else {
|
|
126
|
+
const n = e.bounds, u = {
|
|
127
|
+
width: Math.max(
|
|
128
|
+
n.minWidth,
|
|
129
|
+
Math.min(n.maxWidth, e.size.width + t)
|
|
130
|
+
),
|
|
131
|
+
height: Math.max(
|
|
132
|
+
n.minHeight,
|
|
133
|
+
Math.min(n.maxHeight, e.size.height + i)
|
|
134
|
+
)
|
|
135
|
+
};
|
|
136
|
+
e.previewDimensions = u, e.previewPosition = {
|
|
137
|
+
x: e.position.x + (u.width - e.size.width) / 2,
|
|
138
|
+
y: e.position.y + (r.centered === !1 ? 0 : (u.height - e.size.height) / 2)
|
|
139
|
+
}, M(e.previewPosition, u, !0), w("resize", u);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function M(e, t, i = !1, n = !1) {
|
|
143
|
+
if (!n && !i && (a != null && a.preview)) {
|
|
144
|
+
b.value && (b.value.style.transform = `translate3d(${e.x - a.position.x}px,${e.y - a.position.y}px,0)`);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
const u = d.value;
|
|
148
|
+
u && (u.style.setProperty("--hys-ui-modal-x", e.x + "px"), u.style.setProperty("--hys-ui-modal-y", e.y + "px"), i && (u.style.width = de((t == null ? void 0 : t.width) ?? ge(r)) ?? "", u.style.height = de((t == null ? void 0 : t.height) ?? r.height) ?? ""));
|
|
149
|
+
}
|
|
150
|
+
function Y() {
|
|
151
|
+
c == null || c.cancel(), c = void 0;
|
|
152
|
+
}
|
|
153
|
+
function ee() {
|
|
154
|
+
var e, t;
|
|
155
|
+
return m && s.value && !v.value && ((e = h.motion) == null ? void 0 : e.call(h)) !== !1 && !!((t = d.value) != null && t.animate);
|
|
156
|
+
}
|
|
157
|
+
function te(e) {
|
|
158
|
+
Y();
|
|
159
|
+
const t = d.value;
|
|
160
|
+
if (!ee() || !t) return;
|
|
161
|
+
const i = t.animate(e, {
|
|
162
|
+
duration: Math.max(0, Math.min(1e3, r.transitionDuration ?? 200)),
|
|
163
|
+
easing: "cubic-bezier(.22,1,.36,1)"
|
|
164
|
+
});
|
|
165
|
+
c = i, i.onfinish = () => {
|
|
166
|
+
c === i && (c = void 0, P(p));
|
|
167
|
+
}, i.oncancel = () => {
|
|
168
|
+
c === i && (c = void 0);
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
function ie(e, t) {
|
|
172
|
+
var u;
|
|
173
|
+
Y();
|
|
174
|
+
const i = d.value;
|
|
175
|
+
if (!m || !s.value || v.value || ((u = h.motion) == null ? void 0 : u.call(h)) === !1 || !(i != null && i.animate) || e.x === t.x && e.y === t.y)
|
|
176
|
+
return;
|
|
177
|
+
const n = (g) => `translate3d(${g.x}px,${g.y}px,0)`;
|
|
178
|
+
te([
|
|
179
|
+
{ transform: n(e) },
|
|
180
|
+
{ transform: n(t) }
|
|
181
|
+
]);
|
|
182
|
+
}
|
|
183
|
+
function ae(e) {
|
|
184
|
+
if (!(!a || e.pointerId !== a.pointerId)) {
|
|
185
|
+
if (e.pointerType !== "touch" && e.buttons === 0) {
|
|
186
|
+
l(!0);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (!a.activated) {
|
|
190
|
+
if (Math.hypot(
|
|
191
|
+
e.clientX - a.startX,
|
|
192
|
+
e.clientY - a.startY
|
|
193
|
+
) < K())
|
|
194
|
+
return;
|
|
195
|
+
U(a);
|
|
196
|
+
}
|
|
197
|
+
e.preventDefault(), a.x = e.clientX, a.y = e.clientY, a.dirty = !0, z || (z = requestAnimationFrame(_));
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
function l(e = !1) {
|
|
201
|
+
var u, g, y;
|
|
202
|
+
if (!a) {
|
|
203
|
+
e && Y();
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
cancelAnimationFrame(z), z = 0;
|
|
207
|
+
const t = a;
|
|
208
|
+
!e && t.activated && _();
|
|
209
|
+
const i = e ? t.position : t.previewPosition, n = e ? t.dimensions : t.previewDimensions;
|
|
210
|
+
t.activated && M(i, n, t.kind === "resize", !0), !e && t.preview && t.activated && ie(t.position, i), t.activated && (o.value = i), t.kind === "resize" && t.activated && (f.value = n), a = void 0, I.value = !1, S.value = !1, R.value = !1, C.value = !1, document.removeEventListener("pointermove", ae, !0), document.removeEventListener("pointerup", ne, !0), document.removeEventListener("pointercancel", A, !0), window.removeEventListener("blur", A), t.target.removeEventListener("lostpointercapture", A);
|
|
211
|
+
try {
|
|
212
|
+
(g = (u = t.target).releasePointerCapture) == null || g.call(u, t.pointerId);
|
|
213
|
+
} catch {
|
|
214
|
+
}
|
|
215
|
+
if (t.activated && !e && t.kind === "drag" && m && s.value) {
|
|
216
|
+
const E = X(), k = (L) => {
|
|
217
|
+
const H = L.getBoundingClientRect();
|
|
218
|
+
return H.left >= 0 && H.right <= E.width && H.top >= 0 && H.bottom <= E.height;
|
|
219
|
+
};
|
|
220
|
+
k(t.target) || (y = O().find(k)) == null || y.focus({ preventScroll: !0 });
|
|
221
|
+
}
|
|
222
|
+
t.activated && w(
|
|
223
|
+
t.kind === "drag" ? "dragEnd" : "resizeEnd",
|
|
224
|
+
t.kind === "drag" ? o.value : f.value ?? t.size,
|
|
225
|
+
{ cancelled: e }
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
function ne(e) {
|
|
229
|
+
a && e.pointerId === a.pointerId && (!a.activated && Math.hypot(
|
|
230
|
+
e.clientX - a.startX,
|
|
231
|
+
e.clientY - a.startY
|
|
232
|
+
) >= K() && U(a), a.x = e.clientX, a.y = e.clientY, a.dirty = !0, l());
|
|
233
|
+
}
|
|
234
|
+
function A() {
|
|
235
|
+
l(!0);
|
|
236
|
+
}
|
|
237
|
+
const K = () => Number.isFinite(r.dragThreshold) ? Math.max(0, r.dragThreshold) : 6;
|
|
238
|
+
function U(e) {
|
|
239
|
+
var t, i;
|
|
240
|
+
if (!e.activated) {
|
|
241
|
+
e.activated = !0, R.value = !1, I.value = e.kind === "drag", S.value = e.kind === "resize", C.value = e.preview, e.preview && P(() => {
|
|
242
|
+
a !== e || !b.value || (Object.assign(b.value.style, {
|
|
243
|
+
left: e.box.left + "px",
|
|
244
|
+
top: e.box.top + "px",
|
|
245
|
+
width: e.box.width + "px",
|
|
246
|
+
height: e.box.height + "px"
|
|
247
|
+
}), M(e.previewPosition));
|
|
248
|
+
}), e.target.focus({ preventScroll: !0 });
|
|
249
|
+
try {
|
|
250
|
+
(i = (t = e.target).setPointerCapture) == null || i.call(t, e.pointerId);
|
|
251
|
+
} catch {
|
|
252
|
+
}
|
|
253
|
+
e.target.addEventListener("lostpointercapture", A), w(
|
|
254
|
+
e.kind === "drag" ? "dragStart" : "resizeStart",
|
|
255
|
+
e.kind === "drag" ? o.value : e.size
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
function he(e, t) {
|
|
260
|
+
var g;
|
|
261
|
+
if (!m || !s.value || v.value || e.button !== 0 || !d.value || t === "drag" && !r.draggable || t === "resize" && !r.resizable || t === "drag" && e.target.closest(
|
|
262
|
+
'button,a,input,select,textarea,[contenteditable="true"],[data-hys-modal-no-drag]'
|
|
263
|
+
) && !e.currentTarget.hasAttribute(
|
|
264
|
+
"data-hys-modal-drag-handle"
|
|
265
|
+
))
|
|
266
|
+
return;
|
|
267
|
+
l(!0), (g = h.beforeStart) == null || g.call(h);
|
|
268
|
+
const i = d.value.getBoundingClientRect(), n = X(), u = e.currentTarget;
|
|
269
|
+
a = {
|
|
270
|
+
kind: t,
|
|
271
|
+
pointerId: e.pointerId,
|
|
272
|
+
startX: e.clientX,
|
|
273
|
+
startY: e.clientY,
|
|
274
|
+
x: e.clientX,
|
|
275
|
+
y: e.clientY,
|
|
276
|
+
position: { ...o.value },
|
|
277
|
+
size: { width: i.width, height: i.height },
|
|
278
|
+
dimensions: f.value ? { ...f.value } : void 0,
|
|
279
|
+
previewPosition: { ...o.value },
|
|
280
|
+
previewDimensions: f.value,
|
|
281
|
+
screen: n,
|
|
282
|
+
bounds: Q(i, n),
|
|
283
|
+
dirty: !1,
|
|
284
|
+
preview: t === "drag" && r.dragMode === "preview",
|
|
285
|
+
activated: !1,
|
|
286
|
+
box: i,
|
|
287
|
+
handleBoxes: r.overflow ? O().map((y) => y.getBoundingClientRect()) : void 0,
|
|
288
|
+
target: u
|
|
289
|
+
}, R.value = t === "drag" && K() > 0, R.value || (e.preventDefault(), U(a)), document.addEventListener("pointermove", ae, {
|
|
290
|
+
capture: !0,
|
|
291
|
+
passive: !1
|
|
292
|
+
}), document.addEventListener("pointerup", ne, !0), document.addEventListener("pointercancel", A, !0), window.addEventListener("blur", A);
|
|
293
|
+
}
|
|
294
|
+
function le(e) {
|
|
295
|
+
if (!m || !s.value || v.value || !r.draggable || !e.altKey || e.target !== e.currentTarget || !["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Home"].includes(
|
|
296
|
+
e.key
|
|
297
|
+
))
|
|
298
|
+
return;
|
|
299
|
+
e.preventDefault();
|
|
300
|
+
const t = e.shiftKey ? 50 : 10;
|
|
301
|
+
w("dragStart", o.value), e.key === "Home" ? G() : J({
|
|
302
|
+
x: o.value.x + (e.key === "ArrowRight" ? t : e.key === "ArrowLeft" ? -t : 0),
|
|
303
|
+
y: o.value.y + (e.key === "ArrowDown" ? t : e.key === "ArrowUp" ? -t : 0)
|
|
304
|
+
}), w("drag", o.value), w("dragEnd", o.value, { cancelled: !1 });
|
|
305
|
+
}
|
|
306
|
+
function fe(e) {
|
|
307
|
+
if (!m || !s.value || v.value || !r.resizable || !["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Home"].includes(
|
|
308
|
+
e.key
|
|
309
|
+
) || !d.value)
|
|
310
|
+
return;
|
|
311
|
+
e.preventDefault();
|
|
312
|
+
const t = d.value.getBoundingClientRect(), i = f.value ?? { width: t.width, height: t.height }, n = e.shiftKey ? 50 : 10;
|
|
313
|
+
w("resizeStart", i), e.key === "Home" ? T() : Z({
|
|
314
|
+
width: i.width + (e.key === "ArrowRight" ? n : e.key === "ArrowLeft" ? -n : 0),
|
|
315
|
+
height: i.height + (e.key === "ArrowDown" ? n : e.key === "ArrowUp" ? -n : 0)
|
|
316
|
+
}), w("resize", f.value ?? i), w("resizeEnd", f.value ?? i, { cancelled: !1 });
|
|
317
|
+
}
|
|
318
|
+
function p() {
|
|
319
|
+
if (h.enabled === !1 || !m || !s.value || v.value || !d.value || a || c)
|
|
320
|
+
return;
|
|
321
|
+
const e = F(o.value, d.value.getBoundingClientRect());
|
|
322
|
+
(e.x !== o.value.x || e.y !== o.value.y) && (o.value = e, M(e, void 0, !1, !0));
|
|
323
|
+
}
|
|
324
|
+
function re() {
|
|
325
|
+
m = !1, l(!0), window.removeEventListener("resize", V), cancelAnimationFrame(z);
|
|
326
|
+
}
|
|
327
|
+
W([s, v], () => {
|
|
328
|
+
!s.value || v.value ? l(!0) : P(p);
|
|
329
|
+
}), W(
|
|
330
|
+
() => r.dragMode,
|
|
331
|
+
() => l(!0)
|
|
332
|
+
), W(
|
|
333
|
+
[
|
|
334
|
+
() => r.keepHandleVisible,
|
|
335
|
+
() => r.overflow,
|
|
336
|
+
() => r.headerSize,
|
|
337
|
+
() => r.headerHeight
|
|
338
|
+
],
|
|
339
|
+
() => {
|
|
340
|
+
l(!0), P(p);
|
|
341
|
+
}
|
|
342
|
+
), W(
|
|
343
|
+
() => {
|
|
344
|
+
var e;
|
|
345
|
+
return (e = h.motion) == null ? void 0 : e.call(h);
|
|
346
|
+
},
|
|
347
|
+
(e) => {
|
|
348
|
+
e === !1 && Y();
|
|
349
|
+
}
|
|
350
|
+
), W([() => r.width, () => r.height, () => r.size], () => {
|
|
351
|
+
l(!0), T(), P(p);
|
|
352
|
+
});
|
|
353
|
+
function V() {
|
|
354
|
+
l(!0), p();
|
|
355
|
+
}
|
|
356
|
+
function O() {
|
|
357
|
+
var e;
|
|
358
|
+
return [
|
|
359
|
+
...((e = d.value) == null ? void 0 : e.querySelectorAll(
|
|
360
|
+
":scope > .hys-ui-dialog-head [data-hys-modal-drag-handle]"
|
|
361
|
+
)) ?? []
|
|
362
|
+
];
|
|
363
|
+
}
|
|
364
|
+
return se(() => {
|
|
365
|
+
h.enabled !== !1 && window.addEventListener("resize", V);
|
|
366
|
+
}), me(re), ve(re), {
|
|
367
|
+
position: o,
|
|
368
|
+
dimensions: f,
|
|
369
|
+
previewing: C,
|
|
370
|
+
previewLayer: b,
|
|
371
|
+
getPosition: () => (a == null ? void 0 : a.previewPosition) ?? o.value,
|
|
372
|
+
getDimensions: () => (a == null ? void 0 : a.previewDimensions) ?? f.value,
|
|
373
|
+
dragging: I,
|
|
374
|
+
resizing: S,
|
|
375
|
+
gesturing: ce(
|
|
376
|
+
() => R.value || I.value || S.value
|
|
377
|
+
),
|
|
378
|
+
start: he,
|
|
379
|
+
stop: l,
|
|
380
|
+
headerKey: le,
|
|
381
|
+
resizeKey: fe,
|
|
382
|
+
resetPosition: G,
|
|
383
|
+
resetSize: T,
|
|
384
|
+
setPosition: J,
|
|
385
|
+
setSize: Z,
|
|
386
|
+
clampViewport: p,
|
|
387
|
+
activate() {
|
|
388
|
+
m = !0, h.enabled !== !1 && window.addEventListener("resize", V);
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
export {
|
|
393
|
+
xe as useModalInteraction
|
|
394
|
+
};
|