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,313 @@
|
|
|
1
|
+
import { useAttrs as Ee, inject as ne, ref as b, useId as le, computed as S, watch as G, onMounted as Ce, onActivated as Le, onDeactivated as xe, onBeforeUnmount as Te, nextTick as P } from "vue";
|
|
2
|
+
import { fieldKey as Ie, formKey as Se, useHysControlState as Me } from "./formContext.js";
|
|
3
|
+
import { useChoiceModel as Be, useChoiceNativeReset as Ke } from "./choiceModel.js";
|
|
4
|
+
import { splitTags as Q } from "./tagInput.js";
|
|
5
|
+
function He(n, i) {
|
|
6
|
+
const ue = Ee(), f = ne(Ie, void 0), y = ne(Se, void 0), L = Me(n), R = b(), W = b(), u = b(""), m = b(!1), g = b(!1), D = b(!1), ie = le();
|
|
7
|
+
let j = 0, A, v = !0, M;
|
|
8
|
+
const B = (e, a) => e.length === a.length && e.every((t, r) => t === a[r]);
|
|
9
|
+
function d() {
|
|
10
|
+
j++, A == null || A.abort(), A = void 0, m.value = !1, M = void 0, E();
|
|
11
|
+
}
|
|
12
|
+
const K = Be(
|
|
13
|
+
n,
|
|
14
|
+
() => [...n.defaultValue ?? []],
|
|
15
|
+
B,
|
|
16
|
+
d
|
|
17
|
+
), l = S(
|
|
18
|
+
() => Array.isArray(K.current.value) ? K.current.value.filter((e) => typeof e == "string") : []
|
|
19
|
+
), s = S(() => L.disabled.value || !!n.readonly), Y = S(
|
|
20
|
+
() => n.max === 1 / 0 ? 1 / 0 : Number.isFinite(n.max) ? Math.max(0, Math.floor(n.max)) : 10
|
|
21
|
+
), re = S(
|
|
22
|
+
() => {
|
|
23
|
+
var e, a;
|
|
24
|
+
return n.error || (e = f == null ? void 0 : f.invalid) != null && e.value ? "error" : n.status ?? ((a = f == null ? void 0 : f.status) == null ? void 0 : a.value);
|
|
25
|
+
}
|
|
26
|
+
), Z = le(), w = b(), x = b();
|
|
27
|
+
function N(e) {
|
|
28
|
+
var a;
|
|
29
|
+
e === "change" && (y != null && y.model.value) || n.validateEvent !== !1 && !(y != null && y.resetting.value) && ((a = f == null ? void 0 : f.validate) == null || a.call(f, e));
|
|
30
|
+
}
|
|
31
|
+
async function H(e) {
|
|
32
|
+
return K.commit(
|
|
33
|
+
e,
|
|
34
|
+
(a) => i("update:modelValue", [...a]),
|
|
35
|
+
(a) => i("change", [...a]),
|
|
36
|
+
!0
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
function U(e, a, t) {
|
|
40
|
+
i("reject", e), i("invalid", {
|
|
41
|
+
value: e,
|
|
42
|
+
reason: a,
|
|
43
|
+
...t ? { error: t instanceof Error ? t : new Error(String(t)) } : {}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
async function T(e, a = "api") {
|
|
47
|
+
var te;
|
|
48
|
+
if (!v || s.value || m.value || g.value) return !1;
|
|
49
|
+
const t = u.value, r = e ?? t, o = Array.isArray(r) ? r : Q(r, n.delimiters ?? n.separator), C = [...l.value], O = [], F = [], z = new AbortController(), ae = ++j;
|
|
50
|
+
A = z, m.value = !0;
|
|
51
|
+
const k = () => ae === j && !z.signal.aborted && v && !s.value;
|
|
52
|
+
try {
|
|
53
|
+
for (const J of o) {
|
|
54
|
+
if (!k()) return !1;
|
|
55
|
+
const c = n.trim === !1 ? J : J.trim();
|
|
56
|
+
if (!c) continue;
|
|
57
|
+
let I;
|
|
58
|
+
if (!n.allowDuplicates && C.some(
|
|
59
|
+
(h) => n.caseSensitive === !1 ? h.toLocaleLowerCase() === c.toLocaleLowerCase() : h === c
|
|
60
|
+
) ? I = "duplicate" : C.length >= Y.value ? I = "max" : n.maxlength !== void 0 && c.length > n.maxlength ? I = "maxlength" : n.minlength !== void 0 && c.length < n.minlength && (I = "minlength"), I) {
|
|
61
|
+
if (U(c, I), F.push(c), !k()) return !1;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
const h = (te = n.beforeAdd) == null ? void 0 : te.call(n, c, {
|
|
66
|
+
signal: z.signal,
|
|
67
|
+
values: [...C],
|
|
68
|
+
reason: a
|
|
69
|
+
}), Ae = h && typeof h.then == "function" ? await h : h;
|
|
70
|
+
if (!k()) return !1;
|
|
71
|
+
if (Ae === !1) {
|
|
72
|
+
U(c, "guard"), F.push(c);
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
} catch (h) {
|
|
76
|
+
if (!k()) return !1;
|
|
77
|
+
U(c, "error", h), F.push(c);
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (!k()) return !1;
|
|
81
|
+
C.push(c), O.push(c);
|
|
82
|
+
}
|
|
83
|
+
if (!k() || !O.length) return !1;
|
|
84
|
+
for (const J of O) i("add", J);
|
|
85
|
+
if (!k()) return !1;
|
|
86
|
+
M = C;
|
|
87
|
+
const De = await H(C);
|
|
88
|
+
return !k() || !De ? !1 : (e === void 0 && u.value === t && (u.value = F.join(
|
|
89
|
+
typeof n.separator == "string" && n.separator ? n.separator : ", "
|
|
90
|
+
)), i("acceptedChange", [...l.value]), N("change"), !0);
|
|
91
|
+
} finally {
|
|
92
|
+
ae === j && (A = void 0, m.value = !1, M = void 0);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async function X(e) {
|
|
96
|
+
if (!v || s.value || !Number.isInteger(e) || e < 0 || e >= l.value.length)
|
|
97
|
+
return !1;
|
|
98
|
+
d();
|
|
99
|
+
const a = l.value[e], t = l.value.filter((C, O) => O !== e), r = H(t);
|
|
100
|
+
i("remove", a);
|
|
101
|
+
const o = await r;
|
|
102
|
+
return o && (i("acceptedChange", [...l.value]), N("change")), o;
|
|
103
|
+
}
|
|
104
|
+
async function $() {
|
|
105
|
+
if (!v || s.value) return !1;
|
|
106
|
+
d();
|
|
107
|
+
const e = u.value;
|
|
108
|
+
if (!l.value.length)
|
|
109
|
+
return u.value = "", e && i("clear"), !!e;
|
|
110
|
+
const a = await H([]);
|
|
111
|
+
return a && (u.value === e && (u.value = ""), i("clear"), i("acceptedChange", []), N("change")), a;
|
|
112
|
+
}
|
|
113
|
+
async function _(e, a) {
|
|
114
|
+
if (!v || s.value || !n.draggable || ![e, a].every(Number.isInteger) || e < 0 || a < 0 || e >= l.value.length || a >= l.value.length || e === a)
|
|
115
|
+
return !1;
|
|
116
|
+
d();
|
|
117
|
+
const t = [...l.value], r = t.splice(e, 1)[0];
|
|
118
|
+
t.splice(a, 0, r), i("reorder", e, a, [...t]);
|
|
119
|
+
const o = await H(t);
|
|
120
|
+
return o && (i("acceptedChange", [...l.value]), N("change")), o;
|
|
121
|
+
}
|
|
122
|
+
function V(e) {
|
|
123
|
+
var a;
|
|
124
|
+
v && !L.disabled.value && ((a = W.value) == null || a.focus(e));
|
|
125
|
+
}
|
|
126
|
+
function ce(e) {
|
|
127
|
+
u.value = e.target.value, i("input", u.value), !(g.value || e.isComposing) && n.delimiters && Q(u.value, n.delimiters).length > 1 && T(void 0, "separator");
|
|
128
|
+
}
|
|
129
|
+
function oe(e) {
|
|
130
|
+
g.value = !1, u.value = e.target.value, i("compositionend", e);
|
|
131
|
+
}
|
|
132
|
+
function fe(e) {
|
|
133
|
+
var o;
|
|
134
|
+
if (s.value || g.value || !n.delimiters) return;
|
|
135
|
+
const a = (o = e.clipboardData) == null ? void 0 : o.getData("text/plain");
|
|
136
|
+
if (!a) return;
|
|
137
|
+
const t = e.target, r = u.value.slice(0, t.selectionStart ?? u.value.length) + a + u.value.slice(t.selectionEnd ?? u.value.length);
|
|
138
|
+
Q(r, n.delimiters).length < 2 || (e.preventDefault(), u.value = r, i("input", r), T(void 0, "paste"));
|
|
139
|
+
}
|
|
140
|
+
function se(e) {
|
|
141
|
+
if (e.isComposing || e.keyCode === 229 || g.value || s.value)
|
|
142
|
+
return;
|
|
143
|
+
const a = Array.isArray(n.trigger) ? n.trigger : [n.trigger ?? "Enter"], t = e.key === " " ? "Space" : e.key;
|
|
144
|
+
if (a.includes(t) && u.value.trim()) {
|
|
145
|
+
t !== "Tab" && e.preventDefault(), T(void 0, "keyboard");
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
e.key === "Backspace" && !u.value && l.value.length ? (e.preventDefault(), X(l.value.length - 1)) : e.key === "ArrowLeft" && !u.value && l.value.length ? (e.preventDefault(), q(l.value.length - 1)) : e.key === "Escape" && m.value && (e.preventDefault(), d());
|
|
149
|
+
}
|
|
150
|
+
function q(e) {
|
|
151
|
+
var t;
|
|
152
|
+
if (!v || L.disabled.value) return;
|
|
153
|
+
const a = (t = R.value) == null ? void 0 : t.querySelector(
|
|
154
|
+
'[data-tag-index="' + e + '"]'
|
|
155
|
+
);
|
|
156
|
+
a ? a.focus() : V();
|
|
157
|
+
}
|
|
158
|
+
async function ve(e, a) {
|
|
159
|
+
if (!(s.value || e.isComposing)) {
|
|
160
|
+
if (n.draggable && e.altKey && ["ArrowLeft", "ArrowRight"].includes(e.key)) {
|
|
161
|
+
e.preventDefault();
|
|
162
|
+
const t = a + (e.key === "ArrowLeft" ? -1 : 1);
|
|
163
|
+
await _(a, t) && (await P(), q(t));
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (["Backspace", "Delete"].includes(e.key)) {
|
|
167
|
+
e.preventDefault(), await X(a) && (await P(), q(Math.min(a, l.value.length - 1)));
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if (["ArrowLeft", "ArrowRight", "Home", "End"].includes(e.key)) {
|
|
171
|
+
e.preventDefault();
|
|
172
|
+
const t = e.key === "Home" ? 0 : e.key === "End" ? l.value.length - 1 : a + (e.key === "ArrowLeft" ? -1 : 1);
|
|
173
|
+
t >= 0 && t < l.value.length ? q(t) : V();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function de(e, a) {
|
|
178
|
+
var t;
|
|
179
|
+
return !!e && (!!((t = R.value) != null && t.contains(e)) || !!(a != null && a.contains(e)));
|
|
180
|
+
}
|
|
181
|
+
function ge(e) {
|
|
182
|
+
D.value || (D.value = !0, i("focus", e));
|
|
183
|
+
}
|
|
184
|
+
function ye(e, a) {
|
|
185
|
+
P(() => {
|
|
186
|
+
!v || de(document.activeElement, a) || D.value && (D.value = !1, i("blur", e), n.addOnBlur && !g.value && T(void 0, "blur"), N("blur"));
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
function E() {
|
|
190
|
+
w.value = void 0, x.value = void 0, document.removeEventListener("keydown", p, !0), window.removeEventListener("blur", E);
|
|
191
|
+
}
|
|
192
|
+
function p(e) {
|
|
193
|
+
e.key === "Escape" && E();
|
|
194
|
+
}
|
|
195
|
+
function he(e, a) {
|
|
196
|
+
var t;
|
|
197
|
+
if (s.value || m.value || !n.draggable || e.target.closest("button,input,a")) {
|
|
198
|
+
e.preventDefault();
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
d(), w.value = { index: a, values: [...l.value] }, (t = e.dataTransfer) == null || t.setData("application/x-hys-tag-input", Z), e.dataTransfer && (e.dataTransfer.effectAllowed = "move"), document.addEventListener("keydown", p, !0), window.addEventListener("blur", E);
|
|
202
|
+
}
|
|
203
|
+
function me(e, a) {
|
|
204
|
+
if (!w.value || s.value || !B(w.value.values, l.value))
|
|
205
|
+
return;
|
|
206
|
+
e.preventDefault();
|
|
207
|
+
const t = e.currentTarget.getBoundingClientRect();
|
|
208
|
+
x.value = { index: a, after: e.clientX > t.left + t.width / 2 }, e.dataTransfer && (e.dataTransfer.dropEffect = "move");
|
|
209
|
+
}
|
|
210
|
+
async function we(e) {
|
|
211
|
+
var o;
|
|
212
|
+
if (!w.value || !x.value || s.value || !B(w.value.values, l.value) || ((o = e.dataTransfer) == null ? void 0 : o.getData("application/x-hys-tag-input")) !== Z)
|
|
213
|
+
return;
|
|
214
|
+
e.preventDefault();
|
|
215
|
+
const a = w.value.index, t = x.value.index + (x.value.after ? 1 : 0), r = t - (a < t ? 1 : 0);
|
|
216
|
+
await _(a, r), E();
|
|
217
|
+
}
|
|
218
|
+
Ke(
|
|
219
|
+
R,
|
|
220
|
+
() => {
|
|
221
|
+
d(), K.reset(), u.value = "", g.value = !1, D.value = !1;
|
|
222
|
+
},
|
|
223
|
+
void 0,
|
|
224
|
+
() => n.form
|
|
225
|
+
), G(
|
|
226
|
+
l,
|
|
227
|
+
(e, a) => {
|
|
228
|
+
!B(e, a) && (!M || !B(e, M)) && (A ? d() : E());
|
|
229
|
+
},
|
|
230
|
+
{ flush: "sync" }
|
|
231
|
+
), G(
|
|
232
|
+
() => [
|
|
233
|
+
L.disabled.value,
|
|
234
|
+
n.readonly,
|
|
235
|
+
n.beforeAdd,
|
|
236
|
+
n.max,
|
|
237
|
+
n.delimiters,
|
|
238
|
+
n.separator
|
|
239
|
+
],
|
|
240
|
+
d,
|
|
241
|
+
{ flush: "sync" }
|
|
242
|
+
), G(
|
|
243
|
+
() => y == null ? void 0 : y.resetting.value,
|
|
244
|
+
(e) => {
|
|
245
|
+
e && (d(), K.reset(), u.value = "", g.value = !1);
|
|
246
|
+
},
|
|
247
|
+
{ flush: "sync" }
|
|
248
|
+
), Ce(() => {
|
|
249
|
+
n.autofocus && V();
|
|
250
|
+
}), Le(() => {
|
|
251
|
+
v = !0;
|
|
252
|
+
});
|
|
253
|
+
function ee() {
|
|
254
|
+
v = !1, d(), g.value = !1, D.value = !1;
|
|
255
|
+
}
|
|
256
|
+
xe(ee), Te(ee);
|
|
257
|
+
const ke = S(() => ({
|
|
258
|
+
values: l.value,
|
|
259
|
+
draft: u.value,
|
|
260
|
+
disabled: L.disabled.value,
|
|
261
|
+
readonly: !!n.readonly,
|
|
262
|
+
pending: m.value,
|
|
263
|
+
add: (e) => T(e),
|
|
264
|
+
clear: $
|
|
265
|
+
})), be = S(() => {
|
|
266
|
+
const e = /* @__PURE__ */ new Map();
|
|
267
|
+
return l.value.map((a, t) => {
|
|
268
|
+
const r = e.get(a) ?? 0;
|
|
269
|
+
return e.set(a, r + 1), { value: a, index: t, key: JSON.stringify([a, r]) };
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
return {
|
|
273
|
+
attrs: ue,
|
|
274
|
+
field: f,
|
|
275
|
+
control: L,
|
|
276
|
+
element: R,
|
|
277
|
+
input: W,
|
|
278
|
+
errorId: ie,
|
|
279
|
+
draft: u,
|
|
280
|
+
pending: m,
|
|
281
|
+
composing: g,
|
|
282
|
+
focused: D,
|
|
283
|
+
values: l,
|
|
284
|
+
status: re,
|
|
285
|
+
maximum: Y,
|
|
286
|
+
context: ke,
|
|
287
|
+
tags: be,
|
|
288
|
+
drag: w,
|
|
289
|
+
drop: x,
|
|
290
|
+
add: T,
|
|
291
|
+
remove: X,
|
|
292
|
+
clear: $,
|
|
293
|
+
move: _,
|
|
294
|
+
focus: V,
|
|
295
|
+
nativeInput: ce,
|
|
296
|
+
compositionEnd: oe,
|
|
297
|
+
pasted: fe,
|
|
298
|
+
key: se,
|
|
299
|
+
tagKey: ve,
|
|
300
|
+
focusIn: ge,
|
|
301
|
+
focusOut: ye,
|
|
302
|
+
stopDrag: E,
|
|
303
|
+
dragStart: he,
|
|
304
|
+
dragOver: me,
|
|
305
|
+
dragDrop: we,
|
|
306
|
+
setDraft: (e) => {
|
|
307
|
+
v && !s.value && (u.value = e);
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
export {
|
|
312
|
+
He as useTagInput
|
|
313
|
+
};
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { inject as K, watch as U, onActivated as V, onDeactivated as G, onBeforeUnmount as J } from "vue";
|
|
2
|
+
import { useHysRootAttrs as Q } from "../config.js";
|
|
3
|
+
import { useMotion as X } from "../motion/useMotion.js";
|
|
4
|
+
import { overlayOwnerKey as Y } from "./overlayManager.js";
|
|
5
|
+
import { transferToken as T } from "./transfer.js";
|
|
6
|
+
const D = (x) => '[data-transfer-key="' + x.replace(
|
|
7
|
+
/["\\\n\r\f]/g,
|
|
8
|
+
(a) => "\\" + a.codePointAt(0).toString(16) + " "
|
|
9
|
+
) + '"]';
|
|
10
|
+
function ne(x, a) {
|
|
11
|
+
const j = Q(), { effectiveMotion: P } = X(), w = K(Y, void 0), C = /* @__PURE__ */ new Set(), M = /* @__PURE__ */ new Set();
|
|
12
|
+
let A, L = 0, F = !0, k, b;
|
|
13
|
+
const q = () => Number.isFinite(a.moveDuration) ? Math.max(0, Math.min(1500, a.moveDuration)) : 240, E = () => Number.isFinite(a.maxAnimatedItems) ? Math.max(0, Math.min(12, Math.floor(a.maxAnimatedItems))) : 6, z = () => {
|
|
14
|
+
var e;
|
|
15
|
+
return F && ((e = x.value) == null ? void 0 : e.isConnected) && (w == null ? void 0 : w.value) !== !1 && a.animated !== !1 && a.moveAnimation !== "none" && q() > 0 && P.value !== "off";
|
|
16
|
+
};
|
|
17
|
+
function o() {
|
|
18
|
+
L++, A !== void 0 && cancelAnimationFrame(A), A = void 0, clearTimeout(k), k = void 0, window.removeEventListener("scroll", o, !0), window.removeEventListener("resize", o), window.removeEventListener("focusin", o), window.removeEventListener("blur", o), window.removeEventListener("keydown", B);
|
|
19
|
+
for (const e of M)
|
|
20
|
+
e.animation.cancel(), e.restore(), e.node.remove();
|
|
21
|
+
M.clear();
|
|
22
|
+
for (const e of C) e.classList.remove("hys-ui-transfer-landed");
|
|
23
|
+
C.clear(), b == null || b.classList.remove("hys-ui-transfer-received"), b = void 0;
|
|
24
|
+
}
|
|
25
|
+
function B(e) {
|
|
26
|
+
e.key === "Escape" && o();
|
|
27
|
+
}
|
|
28
|
+
function O(e) {
|
|
29
|
+
var s;
|
|
30
|
+
return (s = x.value) == null ? void 0 : s.querySelector(
|
|
31
|
+
'.hys-ui-transfer-pane[data-side="' + e + '"]'
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
function I(e, s) {
|
|
35
|
+
var v, g;
|
|
36
|
+
if (o(), !z() || !s.length) return;
|
|
37
|
+
const d = (v = O(
|
|
38
|
+
e === "right" ? "left" : "right"
|
|
39
|
+
)) == null ? void 0 : v.querySelector(".hys-ui-pf-transfer-list"), i = {
|
|
40
|
+
generation: L,
|
|
41
|
+
direction: e,
|
|
42
|
+
count: s.length,
|
|
43
|
+
samples: []
|
|
44
|
+
};
|
|
45
|
+
if (!d || !E() || typeof HTMLElement.prototype.animate != "function")
|
|
46
|
+
return i;
|
|
47
|
+
const r = d.getBoundingClientRect(), u = Math.max(0, r.top), c = Math.min(window.innerHeight, r.bottom);
|
|
48
|
+
if (r.right <= 0 || r.left >= window.innerWidth || c <= u)
|
|
49
|
+
return i;
|
|
50
|
+
const l = new Set(s.map(T)), n = /* @__PURE__ */ new Set();
|
|
51
|
+
function y(t) {
|
|
52
|
+
var S;
|
|
53
|
+
if (!t || !d.contains(t) || i.samples.length >= E())
|
|
54
|
+
return;
|
|
55
|
+
const f = t.dataset.transferKey;
|
|
56
|
+
if (!l.has(f) || n.has(f)) return;
|
|
57
|
+
const m = t.getBoundingClientRect();
|
|
58
|
+
!m.width || !m.height || m.bottom <= u || m.top >= c || (n.add(f), i.samples.push({
|
|
59
|
+
token: f,
|
|
60
|
+
label: (((S = t.querySelector(".hys-ui-transfer-label")) == null ? void 0 : S.textContent) ?? t.textContent ?? "").trim().slice(0, 120),
|
|
61
|
+
box: m
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
if (s.length <= E())
|
|
65
|
+
for (const t of s)
|
|
66
|
+
y(d.querySelector(D(T(t))));
|
|
67
|
+
else if (document.elementFromPoint) {
|
|
68
|
+
const t = Math.min(24, Math.max(1, Math.ceil((c - u) / 20))), f = Math.max(
|
|
69
|
+
1,
|
|
70
|
+
Math.min(window.innerWidth - 1, r.left + r.width / 2)
|
|
71
|
+
);
|
|
72
|
+
for (let m = 0; m < t && i.samples.length < E(); m++)
|
|
73
|
+
y(
|
|
74
|
+
(g = document.elementFromPoint(f, u + (m + 0.5) * (c - u) / t)) == null ? void 0 : g.closest(".hys-ui-transfer-row")
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
return i;
|
|
78
|
+
}
|
|
79
|
+
function N(e) {
|
|
80
|
+
if (!e || e.generation !== L || !z()) return;
|
|
81
|
+
const s = O(e.direction), d = s == null ? void 0 : s.querySelector(".hys-ui-pf-transfer-list");
|
|
82
|
+
if (!s || !d) return;
|
|
83
|
+
const i = d.getBoundingClientRect();
|
|
84
|
+
if (i.right <= 0 || i.left >= window.innerWidth || i.bottom <= 0 || i.top >= window.innerHeight)
|
|
85
|
+
return;
|
|
86
|
+
b = s, s.classList.add("hys-ui-transfer-received");
|
|
87
|
+
const r = e.samples.length ? getComputedStyle(x.value) : void 0, u = (c) => {
|
|
88
|
+
c.restore(), c.node.remove(), M.delete(c);
|
|
89
|
+
};
|
|
90
|
+
for (const [c, l] of e.samples.entries()) {
|
|
91
|
+
const n = d.querySelector(D(l.token)), y = n == null ? void 0 : n.getBoundingClientRect(), v = !!y && y.bottom > Math.max(0, i.top) && y.top < Math.min(window.innerHeight, i.bottom), g = v ? y : {
|
|
92
|
+
left: Math.max(8, i.left + 8),
|
|
93
|
+
top: Math.max(
|
|
94
|
+
8,
|
|
95
|
+
Math.min(
|
|
96
|
+
window.innerHeight - 44,
|
|
97
|
+
i.top + Math.min(i.height / 2, 80) + c * 4
|
|
98
|
+
)
|
|
99
|
+
),
|
|
100
|
+
width: Math.max(40, i.width - 16),
|
|
101
|
+
height: l.box.height
|
|
102
|
+
}, t = document.createElement("div");
|
|
103
|
+
t.className = "hys-ui-transfer-flight";
|
|
104
|
+
for (const [p, h] of Object.entries(j.value))
|
|
105
|
+
t.setAttribute(p, h);
|
|
106
|
+
t.setAttribute("aria-hidden", "true"), t.inert = !0, t.textContent = l.label + (c === e.samples.length - 1 && e.count > e.samples.length ? " · +" + (e.count - e.samples.length) : ""), Object.assign(t.style, {
|
|
107
|
+
left: l.box.left + "px",
|
|
108
|
+
top: l.box.top + "px",
|
|
109
|
+
width: l.box.width + "px",
|
|
110
|
+
height: l.box.height + "px",
|
|
111
|
+
fontFamily: r == null ? void 0 : r.fontFamily,
|
|
112
|
+
fontSize: r == null ? void 0 : r.fontSize
|
|
113
|
+
});
|
|
114
|
+
for (const p of [
|
|
115
|
+
"--hys-ui-primary",
|
|
116
|
+
"--hys-ui-primary-soft",
|
|
117
|
+
"--hys-ui-border",
|
|
118
|
+
"--hys-ui-surface",
|
|
119
|
+
"--hys-ui-text",
|
|
120
|
+
"--hys-ui-muted"
|
|
121
|
+
]) {
|
|
122
|
+
const h = r == null ? void 0 : r.getPropertyValue(p);
|
|
123
|
+
h && t.style.setProperty(p, h);
|
|
124
|
+
}
|
|
125
|
+
const f = (n == null ? void 0 : n.style.opacity) ?? "", m = (n == null ? void 0 : n.style.transition) ?? "";
|
|
126
|
+
let S = !1;
|
|
127
|
+
const R = () => {
|
|
128
|
+
S || (S = !0, n && v && (n.style.opacity = f, n.style.transition = m));
|
|
129
|
+
};
|
|
130
|
+
n && v && (n.style.transition = "none", n.style.opacity = "0"), document.body.append(t);
|
|
131
|
+
const H = "translate3d(" + (g.left - l.box.left) + "px," + (g.top - l.box.top) + "px,0) scale(" + g.width / l.box.width + "," + g.height / l.box.height + ")", W = a.moveAnimation === "fade" ? [
|
|
132
|
+
{ transform: H, opacity: 0 },
|
|
133
|
+
{ transform: H, opacity: 1 }
|
|
134
|
+
] : [
|
|
135
|
+
{ transform: "translate3d(0,0,0) scale(1)", opacity: 0.9 },
|
|
136
|
+
{ transform: H, opacity: 1 }
|
|
137
|
+
];
|
|
138
|
+
try {
|
|
139
|
+
const p = t.animate(W, {
|
|
140
|
+
duration: q(),
|
|
141
|
+
easing: "cubic-bezier(.22,1,.36,1)",
|
|
142
|
+
fill: "both"
|
|
143
|
+
}), h = { node: t, animation: p, restore: R };
|
|
144
|
+
M.add(h), p.finished.then(
|
|
145
|
+
() => {
|
|
146
|
+
u(h), n && v && n.isConnected && e.generation === L && z() && a.highlightOnArrival !== !1 && (n.classList.add("hys-ui-transfer-landed"), C.add(n));
|
|
147
|
+
},
|
|
148
|
+
() => u(h)
|
|
149
|
+
);
|
|
150
|
+
} catch {
|
|
151
|
+
R(), t.remove();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
A = requestAnimationFrame(() => {
|
|
155
|
+
A = void 0, e.generation === L && window.addEventListener("scroll", o, !0);
|
|
156
|
+
}), window.addEventListener("resize", o), window.addEventListener("focusin", o), window.addEventListener("blur", o), window.addEventListener("keydown", B), k = setTimeout(o, q() + 440);
|
|
157
|
+
}
|
|
158
|
+
return U(
|
|
159
|
+
() => [
|
|
160
|
+
a.animated,
|
|
161
|
+
a.moveAnimation,
|
|
162
|
+
a.moveDuration,
|
|
163
|
+
a.maxAnimatedItems,
|
|
164
|
+
a.highlightOnArrival,
|
|
165
|
+
P.value,
|
|
166
|
+
w == null ? void 0 : w.value
|
|
167
|
+
],
|
|
168
|
+
o,
|
|
169
|
+
{ flush: "sync" }
|
|
170
|
+
), V(() => {
|
|
171
|
+
F = !0;
|
|
172
|
+
}), G(() => {
|
|
173
|
+
F = !1, o();
|
|
174
|
+
}), J(o), {
|
|
175
|
+
capture: I,
|
|
176
|
+
play: N,
|
|
177
|
+
stop: o,
|
|
178
|
+
cancelPlaying: () => {
|
|
179
|
+
(M.size || b) && o();
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
export {
|
|
184
|
+
ne as useTransferMotion
|
|
185
|
+
};
|