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,472 @@
|
|
|
1
|
+
import { ref as T, inject as me, computed as ee, shallowRef as ae, watch as K, onDeactivated as je, onBeforeUnmount as Ee, onActivated as Pe, nextTick as pe } from "vue";
|
|
2
|
+
import { fieldKey as qe, formKey as Ie, useHysControlState as Ke } from "./formContext.js";
|
|
3
|
+
import { useChoiceNativeReset as Ne } from "./choiceModel.js";
|
|
4
|
+
import { useUploadModel as We } from "./useUploadModel.js";
|
|
5
|
+
import { useUploadRequests as Ce } from "./useUploadRequests.js";
|
|
6
|
+
import { uploadLocale as Be, uploadUrl as R, uploadImage as N, uploadStatus as we, uploadFailure as Q, uploadPercent as He } from "./upload.js";
|
|
7
|
+
function Ye(i, d) {
|
|
8
|
+
const te = T(), ie = T(), U = T(), c = T(!0), F = T(!1), A = T(!1), S = T(""), w = me(qe, void 0), k = me(Ie, void 0), j = Ke(i), m = ee(
|
|
9
|
+
() => c.value && !j.disabled.value && !i.readonly && !i.loading
|
|
10
|
+
), ge = ee(() => ({ ...Be, ...i.locale })), o = We(i, d, () => c.value), x = /* @__PURE__ */ new Map(), v = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Map(), W = /* @__PURE__ */ new Set(), z = ae(/* @__PURE__ */ new Set());
|
|
11
|
+
let P, D = 0, p = 0, g, b, M, O;
|
|
12
|
+
const L = ae(/* @__PURE__ */ new Map()), I = ae(), re = () => Number.isFinite(i.limit) && i.limit > 0 ? Math.floor(i.limit) : 1 / 0, y = (e) => c.value && !e.aborted && m.value;
|
|
13
|
+
function X(e) {
|
|
14
|
+
const a = Q(e).message;
|
|
15
|
+
S.value = a, d("error", a);
|
|
16
|
+
}
|
|
17
|
+
function C() {
|
|
18
|
+
i.validateEvent !== !1 && !(k != null && k.resetting.value) && pe(() => {
|
|
19
|
+
var e;
|
|
20
|
+
c.value && !(k != null && k.resetting.value) && ((e = w == null ? void 0 : w.validate) == null || e.call(w, "change"));
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function q(e, a, t) {
|
|
24
|
+
c.value && (S.value = t, d("error", t), d("invalid", { file: e, reason: a, message: t, files: o.files.value }));
|
|
25
|
+
}
|
|
26
|
+
function be(e) {
|
|
27
|
+
return !i.accept || i.accept.split(",").some((a) => {
|
|
28
|
+
const t = a.trim().toLowerCase(), r = e.type.toLowerCase();
|
|
29
|
+
return t.startsWith(".") ? e.name.toLowerCase().endsWith(t) : t.endsWith("/*") ? r.startsWith(t.slice(0, -1)) : r === t;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
async function le(e, a) {
|
|
33
|
+
if (y(a)) {
|
|
34
|
+
if (!be(e)) {
|
|
35
|
+
q(e, "type", "文件类型不符合要求:" + e.name);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (Number.isFinite(i.maxSize) && i.maxSize > 0 && e.size > i.maxSize) {
|
|
39
|
+
q(e, "size", "文件超过大小限制:" + e.name);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
const t = i.beforeUpload ? await i.beforeUpload(e, { signal: a, files: o.files.value }) : void 0;
|
|
44
|
+
if (!y(a) || t === !1) return;
|
|
45
|
+
const r = t instanceof Blob ? t : e;
|
|
46
|
+
if (Number.isFinite(i.maxSize) && i.maxSize > 0 && r.size > i.maxSize) {
|
|
47
|
+
q(e, "size", "处理后的文件超过大小限制:" + e.name);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
return r;
|
|
51
|
+
} catch (t) {
|
|
52
|
+
y(a) && q(e, "validation", Q(t).message);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
async function ye(e, a, t) {
|
|
57
|
+
const r = await o.commit(
|
|
58
|
+
(l) => l.map(
|
|
59
|
+
(u) => e.has(u.uid) && (t == null ? void 0 : t(u.uid)) !== !1 ? { ...u, ...e.get(u.uid) } : u
|
|
60
|
+
),
|
|
61
|
+
a,
|
|
62
|
+
{ guard: () => c.value && (t == null ? void 0 : t()) !== !1 }
|
|
63
|
+
);
|
|
64
|
+
return r && ["success", "error", "retry"].includes(a) && C(), r;
|
|
65
|
+
}
|
|
66
|
+
const f = Ce({
|
|
67
|
+
props: i,
|
|
68
|
+
files: o.files,
|
|
69
|
+
available: m,
|
|
70
|
+
live: () => c.value,
|
|
71
|
+
emit: d,
|
|
72
|
+
patch: ye,
|
|
73
|
+
forget: (e) => x.delete(e),
|
|
74
|
+
prepare: async (e, a) => {
|
|
75
|
+
if (!e.raw) return;
|
|
76
|
+
const t = x.get(e.uid);
|
|
77
|
+
if ((t == null ? void 0 : t.raw) === e.raw) return t.body;
|
|
78
|
+
const r = await le(e.raw, a);
|
|
79
|
+
return r && y(a) && x.set(e.uid, { raw: e.raw, body: r }), r;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
function Y() {
|
|
83
|
+
D++, P == null || P.abort(), P = void 0, F.value = !1, A.value = !1, p = 0, U.value && (U.value.value = "");
|
|
84
|
+
}
|
|
85
|
+
function Z(e) {
|
|
86
|
+
return typeof e == "string" ? e : e.uid;
|
|
87
|
+
}
|
|
88
|
+
async function $(e) {
|
|
89
|
+
if (!m.value || F.value) return [];
|
|
90
|
+
const a = i.multiple === !1 ? [...e].slice(0, 1) : [...e];
|
|
91
|
+
if (!a.length) return [];
|
|
92
|
+
if ((i.multiple === !1 ? 0 : o.files.value.length) + a.length > re())
|
|
93
|
+
return d("exceed", a), U.value && (U.value.value = ""), [];
|
|
94
|
+
const t = ++D, r = new AbortController();
|
|
95
|
+
P = r, F.value = !0, S.value = "";
|
|
96
|
+
const l = [], u = /* @__PURE__ */ new Map();
|
|
97
|
+
try {
|
|
98
|
+
for (const n of a) {
|
|
99
|
+
if (t !== D || !y(r.signal)) return [];
|
|
100
|
+
const G = await le(n, r.signal);
|
|
101
|
+
if (!G) continue;
|
|
102
|
+
if (t !== D || !y(r.signal)) return [];
|
|
103
|
+
const ve = crypto.randomUUID();
|
|
104
|
+
let h;
|
|
105
|
+
try {
|
|
106
|
+
const J = {
|
|
107
|
+
uid: ve,
|
|
108
|
+
name: n.name,
|
|
109
|
+
size: n.size,
|
|
110
|
+
raw: n,
|
|
111
|
+
status: "ready",
|
|
112
|
+
percentage: 0,
|
|
113
|
+
type: n.type,
|
|
114
|
+
...n.webkitRelativePath ? { relativePath: n.webkitRelativePath } : {}
|
|
115
|
+
};
|
|
116
|
+
if (h = i.createFile ? { ...J, ...i.createFile(n, ve) } : J, !h.uid || typeof h.uid != "string" || typeof h.name != "string" || !h.raw || o.files.value.some((Ae) => Ae.uid === h.uid) || u.has(h.uid)) {
|
|
117
|
+
q(n, "identity", "文件标识无效或重复:" + n.name);
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
} catch (J) {
|
|
121
|
+
q(n, "identity", Q(J).message);
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
l.push(h), u.set(h.uid, { raw: h.raw, body: G });
|
|
125
|
+
}
|
|
126
|
+
if (!l.length || t !== D || !y(r.signal))
|
|
127
|
+
return [];
|
|
128
|
+
if (!await o.commit(
|
|
129
|
+
(n) => {
|
|
130
|
+
if ((i.multiple === !1 ? 0 : n.length) + l.length > re()) {
|
|
131
|
+
d("exceed", a);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
return i.multiple === !1 ? l : [...n, ...l];
|
|
135
|
+
},
|
|
136
|
+
"select",
|
|
137
|
+
{
|
|
138
|
+
guard: () => t === D && y(r.signal),
|
|
139
|
+
accepted: () => {
|
|
140
|
+
for (const [n, G] of u) x.set(n, G);
|
|
141
|
+
d(
|
|
142
|
+
"select",
|
|
143
|
+
l.map((n) => n.raw)
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
)) return [];
|
|
148
|
+
if (C(), i.autoUpload !== !1 && f.configured.value)
|
|
149
|
+
for (const n of l) f.submit(n.uid);
|
|
150
|
+
return l;
|
|
151
|
+
} finally {
|
|
152
|
+
t === D && (F.value = !1, P = void 0, U.value && (U.value.value = ""));
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
async function ue(e) {
|
|
156
|
+
if (!m.value) return !1;
|
|
157
|
+
const a = Z(e), t = o.files.value.find((l) => l.uid === a);
|
|
158
|
+
if (!t || v.has(a)) return !1;
|
|
159
|
+
const r = new AbortController();
|
|
160
|
+
v.set(a, r), E.set(a, t.raw), z.value = new Set(v.keys());
|
|
161
|
+
try {
|
|
162
|
+
if (i.beforeRemove && await i.beforeRemove(t, o.files.value, {
|
|
163
|
+
signal: r.signal,
|
|
164
|
+
files: o.files.value
|
|
165
|
+
}) === !1 || !y(r.signal) || !o.files.value.some(
|
|
166
|
+
(u) => u.uid === a && u.raw === t.raw
|
|
167
|
+
))
|
|
168
|
+
return !1;
|
|
169
|
+
W.add(a);
|
|
170
|
+
const l = await o.commit(
|
|
171
|
+
(u) => u.some((s) => s.uid === a && s.raw === t.raw) ? u.filter((s) => s.uid !== a) : void 0,
|
|
172
|
+
"remove",
|
|
173
|
+
{
|
|
174
|
+
guard: () => y(r.signal),
|
|
175
|
+
accepted: () => d("remove", t)
|
|
176
|
+
}
|
|
177
|
+
);
|
|
178
|
+
return l && (S.value = "", C()), l;
|
|
179
|
+
} catch (l) {
|
|
180
|
+
return y(r.signal) && (X(l), d("removeError", Q(l), t)), !1;
|
|
181
|
+
} finally {
|
|
182
|
+
W.delete(a), v.get(a) === r && (v.delete(a), E.delete(a), z.value = new Set(v.keys()));
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
function ne(e) {
|
|
186
|
+
var r;
|
|
187
|
+
Y(), o.cancel();
|
|
188
|
+
const a = new Set(
|
|
189
|
+
o.files.value.filter((l) => !e || e.includes(we(l))).map((l) => l.uid)
|
|
190
|
+
);
|
|
191
|
+
for (const l of a)
|
|
192
|
+
f.abort(l, "clear", !1), (r = v.get(l)) == null || r.abort(), v.delete(l), E.delete(l), x.delete(l);
|
|
193
|
+
z.value = new Set(v.keys()), S.value = "";
|
|
194
|
+
const t = o.commit(
|
|
195
|
+
(l) => l.filter((u) => !a.has(u.uid)),
|
|
196
|
+
"clear",
|
|
197
|
+
{ force: !0, allowInactive: !0 }
|
|
198
|
+
);
|
|
199
|
+
return t.then((l) => {
|
|
200
|
+
l && C();
|
|
201
|
+
}), t;
|
|
202
|
+
}
|
|
203
|
+
function B(e) {
|
|
204
|
+
var a;
|
|
205
|
+
return R(e.thumbUrl, !0) ?? (N(e) ? R(e.url, !0) : void 0) ?? ((a = L.value.get(e.uid)) == null ? void 0 : a.url);
|
|
206
|
+
}
|
|
207
|
+
function oe(e) {
|
|
208
|
+
const a = L.value.get(e.uid);
|
|
209
|
+
if (a && a.raw === e.raw) return a.url;
|
|
210
|
+
if (!(!e.raw || !N(e) || typeof URL.createObjectURL != "function"))
|
|
211
|
+
try {
|
|
212
|
+
const t = URL.createObjectURL(e.raw);
|
|
213
|
+
return a && URL.revokeObjectURL(a.url), L.value = new Map(L.value).set(e.uid, {
|
|
214
|
+
raw: e.raw,
|
|
215
|
+
url: t
|
|
216
|
+
}), t;
|
|
217
|
+
} catch {
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
function he() {
|
|
221
|
+
for (const e of L.value.values())
|
|
222
|
+
URL.revokeObjectURL(e.url);
|
|
223
|
+
L.value = /* @__PURE__ */ new Map();
|
|
224
|
+
}
|
|
225
|
+
function H() {
|
|
226
|
+
var l;
|
|
227
|
+
const e = c.value && i.showFileList !== !1 && i.listType !== "text", a = new Map(o.files.value.map((u) => [u.uid, u]));
|
|
228
|
+
let t = !1;
|
|
229
|
+
const r = new Map(L.value);
|
|
230
|
+
for (const [u, s] of r) {
|
|
231
|
+
const n = a.get(u);
|
|
232
|
+
(!n || n.raw !== s.raw || !e && ((l = I.value) == null ? void 0 : l.file.uid) !== u || R(n.thumbUrl, !0) || N(n) && R(n.url, !0)) && (URL.revokeObjectURL(s.url), r.delete(u), t = !0);
|
|
233
|
+
}
|
|
234
|
+
if (t && (L.value = r), e)
|
|
235
|
+
for (const u of o.files.value)
|
|
236
|
+
N(u) && !B(u) && oe(u);
|
|
237
|
+
}
|
|
238
|
+
function se() {
|
|
239
|
+
g == null || g.abort(), g = void 0, M = void 0, I.value = void 0, H();
|
|
240
|
+
}
|
|
241
|
+
async function ce(e) {
|
|
242
|
+
const a = o.files.value.find((r) => r.uid === Z(e));
|
|
243
|
+
if (!a || !c.value || j.disabled.value || i.loading)
|
|
244
|
+
return !1;
|
|
245
|
+
g == null || g.abort();
|
|
246
|
+
const t = new AbortController();
|
|
247
|
+
g = t, M = a;
|
|
248
|
+
try {
|
|
249
|
+
d("preview", a);
|
|
250
|
+
const r = i.previewFile ? await i.previewFile(a, {
|
|
251
|
+
signal: t.signal,
|
|
252
|
+
files: o.files.value
|
|
253
|
+
}) : void 0;
|
|
254
|
+
if (!c.value || t.signal.aborted || !o.files.value.some(
|
|
255
|
+
(u) => u.uid === a.uid && u.raw === a.raw
|
|
256
|
+
) || r === !1)
|
|
257
|
+
return !1;
|
|
258
|
+
const l = typeof r == "string" ? R(r, !0) : B(a) ?? oe(a);
|
|
259
|
+
return l ? (I.value = { file: a, url: l }, !0) : !1;
|
|
260
|
+
} catch (r) {
|
|
261
|
+
return c.value && !t.signal.aborted && X(r), !1;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
async function fe(e) {
|
|
265
|
+
const a = o.files.value.find((r) => r.uid === Z(e));
|
|
266
|
+
if (!a || !c.value || j.disabled.value || i.loading)
|
|
267
|
+
return !1;
|
|
268
|
+
b == null || b.abort();
|
|
269
|
+
const t = new AbortController();
|
|
270
|
+
b = t, O = a;
|
|
271
|
+
try {
|
|
272
|
+
d("download", a);
|
|
273
|
+
const r = i.downloadFile ? await i.downloadFile(a, {
|
|
274
|
+
signal: t.signal,
|
|
275
|
+
files: o.files.value
|
|
276
|
+
}) : void 0;
|
|
277
|
+
if (!c.value || t.signal.aborted || !o.files.value.some((n) => n.uid === a.uid && n.raw === a.raw))
|
|
278
|
+
return !1;
|
|
279
|
+
if (i.downloadFile && typeof r != "string")
|
|
280
|
+
return r !== !1;
|
|
281
|
+
let l;
|
|
282
|
+
const u = typeof r == "string" ? R(r) : R(a.url) ?? (a.raw && typeof URL.createObjectURL == "function" ? l = URL.createObjectURL(a.raw) : void 0);
|
|
283
|
+
if (!u) return !1;
|
|
284
|
+
const s = document.createElement("a");
|
|
285
|
+
return s.href = u, s.download = a.name, s.rel = "noopener noreferrer", s.target = "_blank", document.body.append(s), s.click(), s.remove(), l && setTimeout(() => URL.revokeObjectURL(l), 0), !0;
|
|
286
|
+
} catch (r) {
|
|
287
|
+
return c.value && !t.signal.aborted && X(r), !1;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
function Ue(e) {
|
|
291
|
+
return i.showPreview !== !1 && (!!i.previewFile || N(e) && !!(e.raw || B(e)));
|
|
292
|
+
}
|
|
293
|
+
function ke(e) {
|
|
294
|
+
return i.showDownload !== !1 && !!(i.downloadFile || e.raw || R(e.url));
|
|
295
|
+
}
|
|
296
|
+
function Le(e) {
|
|
297
|
+
return {
|
|
298
|
+
file: e,
|
|
299
|
+
status: we(e),
|
|
300
|
+
percentage: He(e),
|
|
301
|
+
queued: f.queuedKeys.value.has(e.uid),
|
|
302
|
+
busy: f.activeKeys.value.has(e.uid) || z.value.has(e.uid),
|
|
303
|
+
thumbnail: B(e),
|
|
304
|
+
actions: {
|
|
305
|
+
preview: () => ce(e),
|
|
306
|
+
download: () => fe(e),
|
|
307
|
+
remove: () => ue(e),
|
|
308
|
+
retry: () => f.retry(e.uid),
|
|
309
|
+
abort: () => f.abort(e.uid)
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
function V(e) {
|
|
314
|
+
var a;
|
|
315
|
+
!m.value || F.value || (e == null || e.preventDefault(), e == null || e.stopPropagation(), (a = U.value) == null || a.click());
|
|
316
|
+
}
|
|
317
|
+
function Re(e) {
|
|
318
|
+
i.openFileDialogOnClick === !1 || e.defaultPrevented || e.target.closest(
|
|
319
|
+
"input,textarea,select,a[href],[data-upload-no-trigger]"
|
|
320
|
+
) || V(e);
|
|
321
|
+
}
|
|
322
|
+
function Fe(e) {
|
|
323
|
+
e.target.closest(
|
|
324
|
+
'button,a[href],input,textarea,select,[contenteditable="true"]'
|
|
325
|
+
) || (e.key === "Enter" || e.key === " ") && i.openFileDialogOnClick !== !1 && V(e);
|
|
326
|
+
}
|
|
327
|
+
function Se(e) {
|
|
328
|
+
var t;
|
|
329
|
+
if (A.value = !1, p = 0, i.drag === !1 || !m.value) return;
|
|
330
|
+
const a = Array.from(((t = e.dataTransfer) == null ? void 0 : t.files) ?? []);
|
|
331
|
+
a.length && (e.preventDefault(), d("drop", e), $(a));
|
|
332
|
+
}
|
|
333
|
+
function xe(e) {
|
|
334
|
+
var a;
|
|
335
|
+
i.drag === !1 || !m.value || !Array.from(((a = e.dataTransfer) == null ? void 0 : a.types) ?? []).includes("Files") || (e.preventDefault(), p++, A.value = !0);
|
|
336
|
+
}
|
|
337
|
+
function ze(e) {
|
|
338
|
+
var a;
|
|
339
|
+
i.drag === !1 || !m.value || !Array.from(((a = e.dataTransfer) == null ? void 0 : a.types) ?? []).includes("Files") || (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "copy"), A.value = !0);
|
|
340
|
+
}
|
|
341
|
+
function De() {
|
|
342
|
+
p = Math.max(0, p - 1), p || (A.value = !1);
|
|
343
|
+
}
|
|
344
|
+
function Me(e) {
|
|
345
|
+
var t;
|
|
346
|
+
if (!i.paste || !m.value) return;
|
|
347
|
+
const a = Array.from(((t = e.clipboardData) == null ? void 0 : t.files) ?? []);
|
|
348
|
+
a.length && (e.preventDefault(), d("paste", e), $(a));
|
|
349
|
+
}
|
|
350
|
+
function _(e = !0) {
|
|
351
|
+
Y(), o.cancel();
|
|
352
|
+
const a = new Set(f.tasks.value.keys());
|
|
353
|
+
f.cleanup();
|
|
354
|
+
for (const t of v.values()) t.abort();
|
|
355
|
+
v.clear(), E.clear(), W.clear(), z.value = /* @__PURE__ */ new Set(), g == null || g.abort(), b == null || b.abort(), M = O = void 0, I.value = void 0, he(), e && o.interrupt(a);
|
|
356
|
+
}
|
|
357
|
+
K(
|
|
358
|
+
m,
|
|
359
|
+
(e) => {
|
|
360
|
+
e || _();
|
|
361
|
+
},
|
|
362
|
+
{ flush: "sync" }
|
|
363
|
+
), K(
|
|
364
|
+
() => [
|
|
365
|
+
i.accept,
|
|
366
|
+
i.limit,
|
|
367
|
+
i.maxSize,
|
|
368
|
+
i.multiple,
|
|
369
|
+
i.beforeUpload
|
|
370
|
+
],
|
|
371
|
+
() => {
|
|
372
|
+
Y();
|
|
373
|
+
for (const [e, a] of f.tasks.value)
|
|
374
|
+
a.phase === "preparing" && f.abort(e, "configuration");
|
|
375
|
+
}
|
|
376
|
+
), K(
|
|
377
|
+
() => o.files.value.map((e) => [
|
|
378
|
+
e.uid,
|
|
379
|
+
e.raw,
|
|
380
|
+
e.url,
|
|
381
|
+
e.thumbUrl,
|
|
382
|
+
e.type,
|
|
383
|
+
e.name
|
|
384
|
+
]),
|
|
385
|
+
() => {
|
|
386
|
+
var t, r, l, u;
|
|
387
|
+
const e = o.files.value, a = new Map(e.map((s) => [s.uid, s]));
|
|
388
|
+
for (const [s, n] of x)
|
|
389
|
+
((t = a.get(s)) == null ? void 0 : t.raw) !== n.raw && x.delete(s);
|
|
390
|
+
for (const [s, n] of v)
|
|
391
|
+
(!a.has(s) && !W.has(s) || a.has(s) && ((r = a.get(s)) == null ? void 0 : r.raw) !== E.get(s)) && (n.abort(), v.delete(s), E.delete(s), z.value = new Set(v.keys()));
|
|
392
|
+
M && (!a.has(M.uid) || ((l = a.get(M.uid)) == null ? void 0 : l.raw) !== M.raw) && se(), O && (!a.has(O.uid) || ((u = a.get(O.uid)) == null ? void 0 : u.raw) !== O.raw) && (b == null || b.abort(), b = void 0, O = void 0), H();
|
|
393
|
+
},
|
|
394
|
+
{ flush: "post" }
|
|
395
|
+
), K(() => [i.listType, i.showFileList], H);
|
|
396
|
+
function de() {
|
|
397
|
+
_(!1), o.resetLocal(), S.value = "";
|
|
398
|
+
}
|
|
399
|
+
K(
|
|
400
|
+
() => k == null ? void 0 : k.resetting.value,
|
|
401
|
+
(e) => {
|
|
402
|
+
e && de();
|
|
403
|
+
},
|
|
404
|
+
{ flush: "sync" }
|
|
405
|
+
), Ne(U, de), je(() => {
|
|
406
|
+
c.value = !1, _();
|
|
407
|
+
}), Ee(() => {
|
|
408
|
+
c.value = !1, _();
|
|
409
|
+
}), Pe(() => {
|
|
410
|
+
c.value = !0, H();
|
|
411
|
+
});
|
|
412
|
+
const Oe = ee(() => ({
|
|
413
|
+
files: o.files.value,
|
|
414
|
+
busy: F.value,
|
|
415
|
+
disabled: !m.value,
|
|
416
|
+
uploading: f.uploading.value,
|
|
417
|
+
queued: f.queued.value,
|
|
418
|
+
open: V,
|
|
419
|
+
submit: () => f.submit(),
|
|
420
|
+
abort: () => f.abort(),
|
|
421
|
+
clear: () => ne()
|
|
422
|
+
}));
|
|
423
|
+
function Te(e) {
|
|
424
|
+
var a, t;
|
|
425
|
+
(a = te.value) != null && a.contains(e.relatedTarget) || i.validateEvent !== !1 && ((t = w == null ? void 0 : w.validate) == null || t.call(w, "blur"));
|
|
426
|
+
}
|
|
427
|
+
return {
|
|
428
|
+
element: te,
|
|
429
|
+
zone: ie,
|
|
430
|
+
input: U,
|
|
431
|
+
active: c,
|
|
432
|
+
available: m,
|
|
433
|
+
disabled: j.disabled,
|
|
434
|
+
size: j.size,
|
|
435
|
+
label: j.label,
|
|
436
|
+
field: w,
|
|
437
|
+
checking: F,
|
|
438
|
+
dragging: A,
|
|
439
|
+
lastError: S,
|
|
440
|
+
words: ge,
|
|
441
|
+
files: o.files,
|
|
442
|
+
requests: f,
|
|
443
|
+
removing: z,
|
|
444
|
+
preview: I,
|
|
445
|
+
closePreview: se,
|
|
446
|
+
context: Le,
|
|
447
|
+
scope: Oe,
|
|
448
|
+
canPreview: Ue,
|
|
449
|
+
canDownload: ke,
|
|
450
|
+
open: V,
|
|
451
|
+
click: Re,
|
|
452
|
+
keys: Fe,
|
|
453
|
+
drop: Se,
|
|
454
|
+
dragEnter: xe,
|
|
455
|
+
dragOver: ze,
|
|
456
|
+
dragLeave: De,
|
|
457
|
+
paste: Me,
|
|
458
|
+
blur: Te,
|
|
459
|
+
addFiles: $,
|
|
460
|
+
remove: ue,
|
|
461
|
+
clearFiles: ne,
|
|
462
|
+
previewFile: ce,
|
|
463
|
+
download: fe,
|
|
464
|
+
focus: () => {
|
|
465
|
+
var e;
|
|
466
|
+
m.value && ((e = ie.value) == null || e.focus());
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
export {
|
|
471
|
+
Ye as useUpload
|
|
472
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { shallowRef as A, computed as p, nextTick as D, toRaw as F } from "vue";
|
|
2
|
+
const P = (n, u) => Object.is(F(n), F(u));
|
|
3
|
+
function L(n) {
|
|
4
|
+
const u = /* @__PURE__ */ new Set();
|
|
5
|
+
return n.filter(
|
|
6
|
+
(t) => t && typeof t.uid == "string" && t.uid && typeof t.name == "string" && !u.has(t.uid) && !!u.add(t.uid)
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
function G(n, u, t) {
|
|
10
|
+
const x = () => L(n.defaultFileList ?? n.defaultValue ?? []).map(
|
|
11
|
+
(c) => ({ ...c })
|
|
12
|
+
), f = A(x()), b = p(() => n.fileList ?? n.modelValue), r = p(() => b.value !== void 0), d = p(() => L(b.value ?? f.value));
|
|
13
|
+
let i = 0, k = Promise.resolve();
|
|
14
|
+
async function S(c, l, a = {}) {
|
|
15
|
+
const h = i, g = async () => {
|
|
16
|
+
var O, R, z;
|
|
17
|
+
if (h !== i || !a.allowInactive && !t() || ((O = a.guard) == null ? void 0 : O.call(a)) === !1)
|
|
18
|
+
return !1;
|
|
19
|
+
const m = d.value, j = c(m);
|
|
20
|
+
if (!j) return !1;
|
|
21
|
+
const s = L(j), C = new Map(m.map((e) => [e.uid, e])), q = new Map(s.map((e) => [e.uid, e])), I = m.filter((e) => !q.has(e.uid)), w = s.map((e) => ({
|
|
22
|
+
file: e,
|
|
23
|
+
keys: Object.keys(e).filter(
|
|
24
|
+
(o) => !C.has(e.uid) || !P(C.get(e.uid)[o], e[o])
|
|
25
|
+
)
|
|
26
|
+
})).filter((e) => e.keys.length);
|
|
27
|
+
if (!a.force && !I.length && !w.length || (r.value || (f.value = s), u("update:fileList", s), u("update:modelValue", s), r.value && await D(), h !== i || !a.allowInactive && !t() || ((R = a.guard) == null ? void 0 : R.call(a)) === !1))
|
|
28
|
+
return !1;
|
|
29
|
+
const y = d.value, v = new Map(y.map((e) => [e.uid, e]));
|
|
30
|
+
return I.some((e) => v.has(e.uid)) || w.some(
|
|
31
|
+
({ file: e, keys: o }) => !v.has(e.uid) || o.some(
|
|
32
|
+
(B) => !P(v.get(e.uid)[B], e[B])
|
|
33
|
+
)
|
|
34
|
+
) ? !1 : ((z = a.accepted) == null || z.call(a), u("change", [...y]), u("fileChange", {
|
|
35
|
+
type: l,
|
|
36
|
+
files: [...y],
|
|
37
|
+
changed: w.map((e) => v.get(e.file.uid)).filter(Boolean)
|
|
38
|
+
}), !0);
|
|
39
|
+
};
|
|
40
|
+
if (!r.value) return g();
|
|
41
|
+
const V = k.then(g, g);
|
|
42
|
+
return k = V.catch(() => {
|
|
43
|
+
}), V;
|
|
44
|
+
}
|
|
45
|
+
function M() {
|
|
46
|
+
i++;
|
|
47
|
+
}
|
|
48
|
+
function T() {
|
|
49
|
+
M(), r.value || (f.value = x());
|
|
50
|
+
}
|
|
51
|
+
function U(c) {
|
|
52
|
+
const l = d.value.map(
|
|
53
|
+
(a) => c.has(a.uid) && a.status === "uploading" ? { ...a, status: "ready", percentage: 0 } : a
|
|
54
|
+
);
|
|
55
|
+
l.every((a, h) => a === d.value[h]) || (r.value || (f.value = l), u("update:fileList", l), u("update:modelValue", l), r.value || (u("change", [...l]), u("fileChange", {
|
|
56
|
+
type: "abort",
|
|
57
|
+
files: l,
|
|
58
|
+
changed: l.filter((a) => c.has(a.uid))
|
|
59
|
+
})));
|
|
60
|
+
}
|
|
61
|
+
return { files: d, controlled: r, commit: S, cancel: M, resetLocal: T, interrupt: U };
|
|
62
|
+
}
|
|
63
|
+
export {
|
|
64
|
+
G as useUploadModel
|
|
65
|
+
};
|