hys-ui 0.2.0 → 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/CHANGELOG.md +38 -0
- package/README.md +15 -1
- package/dist/components/HysAlert/HysAlert.vue.js +5 -54
- package/dist/components/HysAlert/HysAlert2.vue.js +159 -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/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 +112 -100
- package/dist/components/HysModal/HysModal.vue.js +2 -2
- package/dist/components/HysModal/HysModal2.vue.js +490 -85
- 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/HysSelect/HysSelect.vue.js +2 -2
- package/dist/components/HysSelect/HysSelect2.vue.js +730 -594
- 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/HysTable/HysTable.vue.js +2 -2
- package/dist/components/HysTable/HysTable2.vue.js +389 -368
- 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 +46 -42
- 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/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/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/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 +110 -76
- package/dist/composables/useHysModal.js +185 -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/useTagInput.js +313 -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/index.js +27 -24
- 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/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/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 +1 -1
- 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 +2 -1
- package/dist/types/components/HysModal/HysModal.vue.d.ts +111 -34
- 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/HysResizablePanel/HysResizablePanel.vue.d.ts +2 -2
- package/dist/types/components/HysSelect/HysSelect.vue.d.ts +13 -4
- 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 +2 -2
- package/dist/types/components/HysTable/HysTable.vue.d.ts +4 -4
- 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 +2 -1
- 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/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/formContext.d.ts +2 -0
- package/dist/types/composables/menu.d.ts +183 -0
- package/dist/types/composables/modal.d.ts +183 -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 +2 -0
- package/dist/types/composables/table.d.ts +3 -0
- package/dist/types/composables/tagInput.d.ts +96 -0
- package/dist/types/composables/timeline.d.ts +82 -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 +21 -2
- package/dist/types/composables/useHysModal.d.ts +44 -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/useTagInput.d.ts +66 -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/index.d.ts +17 -2
- 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 +1 -1
|
@@ -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
|
+
};
|