hys-ui 0.1.0 → 0.1.1
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 +26 -1
- package/README.md +16 -6
- package/dist/components/HysAlert/HysAlert.vue.js +14 -14
- package/dist/components/HysAnimatedNumber/HysAnimatedNumber.vue.js +23 -20
- package/dist/components/HysBadge/HysBadge.vue.js +1 -1
- package/dist/components/HysBadge/HysBadge2.vue.js +20 -19
- package/dist/components/HysCalendar/HysCalendar.vue.js +48 -40
- package/dist/components/HysCard/HysCard.vue.js +2 -2
- package/dist/components/HysCard/HysCard2.vue.js +9 -9
- package/dist/components/HysCascader/HysCascader.vue.js +88 -76
- package/dist/components/HysCheckbox/HysCheckbox.vue.js +5 -39
- package/dist/components/HysCheckbox/HysCheckbox2.vue.js +85 -2
- package/dist/components/HysCommandPalette/HysCommandPalette.vue.js +52 -51
- package/dist/components/HysCommentEditor/HysCommentEditor.vue.js +17 -17
- package/dist/components/HysDataGrid/HysDataGrid2.vue.js +22 -22
- package/dist/components/HysDrawer/HysDrawer.vue.js +1 -1
- package/dist/components/HysDrawer/HysDrawer2.vue.js +55 -54
- package/dist/components/HysFileManager/HysFileManager.vue.js +5 -63
- package/dist/components/HysFileManager/HysFileManager2.vue.js +85 -2
- package/dist/components/HysForm/HysForm.vue.js +2 -2
- package/dist/components/HysForm/HysForm2.vue.js +66 -64
- package/dist/components/HysFormItem/HysFormItem.vue.js +53 -37
- package/dist/components/HysGantt/HysGantt.vue.js +5 -264
- package/dist/components/HysGantt/HysGantt2.vue.js +302 -2
- package/dist/components/HysInput/HysInput.vue.js +1 -1
- package/dist/components/HysInput/HysInput2.vue.js +42 -41
- package/dist/components/HysModal/HysModal.vue.js +2 -2
- package/dist/components/HysModal/HysModal2.vue.js +35 -35
- package/dist/components/HysNotificationCenter/HysNotificationCenter.vue.js +37 -36
- package/dist/components/HysNumberInput/HysNumberInput.vue.js +2 -2
- package/dist/components/HysNumberInput/HysNumberInput2.vue.js +49 -40
- package/dist/components/HysOrgTree/HysOrgTree.vue.js +34 -32
- package/dist/components/HysPagination/HysPagination.vue.js +2 -2
- package/dist/components/HysPagination/HysPagination2.vue.js +91 -91
- package/dist/components/HysPermissionMatrix/HysPermissionMatrix.vue.js +5 -41
- package/dist/components/HysPermissionMatrix/HysPermissionMatrix2.vue.js +100 -2
- package/dist/components/HysRadioGroup/HysRadioGroup.vue.js +5 -40
- package/dist/components/HysRadioGroup/HysRadioGroup2.vue.js +80 -2
- package/dist/components/HysResizablePanel/HysResizablePanel.vue.js +46 -28
- package/dist/components/HysRichTextEditor/HysRichTextEditor.vue.js +2 -2
- package/dist/components/HysRichTextEditor/HysRichTextEditor2.vue.js +86 -67
- package/dist/components/HysSearch/HysSearch.vue.js +49 -38
- package/dist/components/HysSegmented/HysSegmented.vue.js +39 -34
- package/dist/components/HysSelect/HysSelect.vue.js +2 -2
- package/dist/components/HysSelect/HysSelect2.vue.js +130 -109
- package/dist/components/HysSlider/HysSlider.vue.js +2 -2
- package/dist/components/HysSlider/HysSlider2.vue.js +40 -40
- package/dist/components/HysSplitPane/HysSplitPane.vue.js +48 -42
- package/dist/components/HysSteps/HysSteps.vue.js +2 -2
- package/dist/components/HysSteps/HysSteps2.vue.js +15 -14
- package/dist/components/HysSwitch/HysSwitch.vue.js +2 -2
- package/dist/components/HysSwitch/HysSwitch2.vue.js +38 -27
- package/dist/components/HysTable/HysTable.vue.js +2 -2
- package/dist/components/HysTable/HysTable2.vue.js +42 -38
- package/dist/components/HysTabs/HysTabs.vue.js +1 -1
- package/dist/components/HysTabs/HysTabs2.vue.js +8 -6
- package/dist/components/HysTextarea/HysTextarea.vue.js +58 -48
- package/dist/components/HysToast/HysToast.vue.js +2 -2
- package/dist/components/HysToast/HysToast2.vue.js +121 -38
- package/dist/components/HysTour/HysTour.vue.js +47 -42
- package/dist/components/HysTransfer/HysTransfer.vue.js +159 -143
- package/dist/components/HysTree/HysTree.vue.js +2 -2
- package/dist/components/HysTree/HysTree2.vue.js +62 -61
- package/dist/components/HysTreeSelect/HysTreeSelect.vue.js +64 -57
- package/dist/components/HysUpload/HysUpload.vue.js +2 -2
- package/dist/components/HysUpload/HysUpload2.vue.js +95 -77
- package/dist/composables/formContext.js +9 -3
- package/dist/composables/toastEscape.js +16 -0
- package/dist/composables/useDialog.js +16 -16
- package/dist/composables/useFloating.js +40 -40
- package/dist/composables/useHysToast.js +148 -0
- package/dist/config.js +18 -15
- package/dist/index.js +10 -7
- package/dist/style.css +1 -1
- package/dist/types/components/HysCalendar/HysCalendar.vue.d.ts +2 -0
- package/dist/types/components/HysCard/HysCard.vue.d.ts +5 -1
- package/dist/types/components/HysCheckbox/HysCheckbox.vue.d.ts +21 -4
- package/dist/types/components/HysDrawer/HysDrawer.vue.d.ts +1 -0
- package/dist/types/components/HysFileManager/HysFileManager.vue.d.ts +6 -2
- package/dist/types/components/HysGantt/HysGantt.vue.d.ts +6 -0
- package/dist/types/components/HysNumberInput/HysNumberInput.vue.d.ts +2 -0
- package/dist/types/components/HysOrgTree/HysOrgTree.vue.d.ts +3 -1
- package/dist/types/components/HysPermissionMatrix/HysPermissionMatrix.vue.d.ts +8 -1
- package/dist/types/components/HysRadioGroup/HysRadioGroup.vue.d.ts +40 -17
- package/dist/types/components/HysResizablePanel/HysResizablePanel.vue.d.ts +6 -0
- package/dist/types/components/HysSelect/HysSelect.vue.d.ts +7 -1
- package/dist/types/components/HysSplitPane/HysSplitPane.vue.d.ts +6 -0
- package/dist/types/components/HysSteps/HysSteps.vue.d.ts +1 -0
- package/dist/types/components/HysSwitch/HysSwitch.vue.d.ts +1 -1
- package/dist/types/components/HysTextarea/HysTextarea.vue.d.ts +1 -1
- package/dist/types/components/HysToast/HysToast.vue.d.ts +55 -7
- package/dist/types/components/HysTour/HysTour.vue.d.ts +3 -1
- package/dist/types/components/HysTransfer/HysTransfer.vue.d.ts +11 -1
- package/dist/types/composables/formContext.d.ts +5 -0
- package/dist/types/composables/toastEscape.d.ts +1 -0
- package/dist/types/composables/useFloating.d.ts +1 -1
- package/dist/types/composables/useHysToast.d.ts +50 -0
- package/dist/types/index.d.ts +5 -0
- package/package.json +46 -11
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { CloudUpload as
|
|
3
|
-
import { useHysRootAttrs as
|
|
4
|
-
const
|
|
1
|
+
import { defineComponent as L, ref as b, watch as S, onActivated as N, onDeactivated as V, onBeforeUnmount as W, openBlock as p, createElementBlock as y, normalizeProps as E, guardReactiveProps as R, unref as g, createElementVNode as m, withModifiers as h, withKeys as x, normalizeClass as T, renderSlot as C, createVNode as k, toDisplayString as U, Fragment as H, renderList as K, createTextVNode as P, createCommentVNode as I } from "vue";
|
|
2
|
+
import { CloudUpload as M, FileText as X, X as j } from "lucide-vue-next";
|
|
3
|
+
import { useHysRootAttrs as q } from "../../config.js";
|
|
4
|
+
const G = ["aria-disabled", "tabindex"], J = ["accept", "multiple", "disabled"], O = { key: 0 }, Q = ["aria-label", "disabled", "onClick"], ee = /* @__PURE__ */ L({
|
|
5
5
|
__name: "HysUpload",
|
|
6
6
|
props: {
|
|
7
7
|
accept: {},
|
|
@@ -14,115 +14,133 @@ const H = ["aria-disabled", "tabindex"], K = ["accept", "multiple", "disabled"],
|
|
|
14
14
|
beforeUpload: {}
|
|
15
15
|
},
|
|
16
16
|
emits: ["change", "remove", "exceed", "error", "select"],
|
|
17
|
-
setup(
|
|
18
|
-
const
|
|
19
|
-
function
|
|
20
|
-
return !
|
|
17
|
+
setup(n, { expose: $, emit: B }) {
|
|
18
|
+
const l = n, r = B, D = q(), o = b([]), d = b(), v = b(!1), u = b(!1);
|
|
19
|
+
function A(i) {
|
|
20
|
+
return !l.accept || l.accept.split(",").some((e) => (e = e.trim().toLowerCase(), e.startsWith(".") ? i.name.toLowerCase().endsWith(e) : e.endsWith("/*") ? i.type.startsWith(e.slice(0, -1)) : i.type === e));
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
let f = 0, s = !0;
|
|
23
|
+
function c() {
|
|
24
|
+
f++, u.value = !1, v.value = !1, d.value && (d.value.value = "");
|
|
25
|
+
}
|
|
26
|
+
S(() => l.disabled, c), N(() => {
|
|
27
|
+
s = !0;
|
|
28
|
+
}), V(() => {
|
|
29
|
+
s = !1, c();
|
|
30
|
+
}), W(() => {
|
|
31
|
+
s = !1, c();
|
|
32
|
+
});
|
|
33
|
+
async function z(i) {
|
|
34
|
+
if (!s || l.disabled || u.value) return;
|
|
35
|
+
if (l.multiple || (i = i.slice(0, 1)), l.limit && (l.multiple ? o.value.length : 0) + i.length > l.limit) {
|
|
36
|
+
r("exceed", i);
|
|
26
37
|
return;
|
|
27
38
|
}
|
|
28
|
-
|
|
29
|
-
|
|
39
|
+
const e = ++f;
|
|
40
|
+
u.value = !0;
|
|
41
|
+
const a = [];
|
|
30
42
|
try {
|
|
31
|
-
for (const t of
|
|
32
|
-
if (
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
43
|
+
for (const t of i) {
|
|
44
|
+
if (!s || e !== f || l.disabled) return;
|
|
45
|
+
try {
|
|
46
|
+
if (!A(t)) {
|
|
47
|
+
r("error", "文件类型不符合要求:" + t.name);
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (l.maxSize && t.size > l.maxSize) {
|
|
51
|
+
r("error", "文件超过大小限制:" + t.name);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if (l.beforeUpload && await l.beforeUpload(t) === !1) continue;
|
|
55
|
+
if (!s || e !== f || l.disabled) return;
|
|
56
|
+
a.push({ uid: crypto.randomUUID(), name: t.name, size: t.size, raw: t });
|
|
57
|
+
} catch (w) {
|
|
58
|
+
s && e === f && r("error", w instanceof Error ? w.message : "文件检查失败");
|
|
39
59
|
}
|
|
40
|
-
i.beforeUpload && await i.beforeUpload(t) === !1 || e.push({ uid: crypto.randomUUID(), name: t.name, size: t.size, raw: t });
|
|
41
60
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
r("error", t instanceof Error ? t.message : "文件检查失败");
|
|
61
|
+
if (!s || e !== f || l.disabled || !a.length) return;
|
|
62
|
+
o.value = l.multiple ? [...o.value, ...a] : a, a.length && (r("select", a.map((t) => t.raw)), r("change", [...o.value]));
|
|
45
63
|
} finally {
|
|
46
|
-
|
|
64
|
+
e === f && (u.value = !1, d.value && (d.value.value = ""));
|
|
47
65
|
}
|
|
48
66
|
}
|
|
49
|
-
function
|
|
50
|
-
|
|
67
|
+
function F(i) {
|
|
68
|
+
l.disabled || (o.value = o.value.filter((e) => e.uid !== i.uid), r("remove", i), r("change", [...o.value]));
|
|
51
69
|
}
|
|
52
|
-
return
|
|
53
|
-
o.value = [], r("change", []);
|
|
70
|
+
return $({ clearFiles: () => {
|
|
71
|
+
c(), o.value = [], r("change", []);
|
|
54
72
|
}, open: () => {
|
|
55
|
-
var
|
|
56
|
-
|
|
57
|
-
} }), (
|
|
58
|
-
|
|
59
|
-
class:
|
|
73
|
+
var i;
|
|
74
|
+
s && !l.disabled && !u.value && ((i = d.value) == null || i.click());
|
|
75
|
+
} }), (i, e) => (p(), y("div", E(R(g(D))), [
|
|
76
|
+
m("div", {
|
|
77
|
+
class: T(["hys-ui-upload-zone", { "hys-ui-upload-dragging": v.value }]),
|
|
60
78
|
role: "button",
|
|
61
|
-
"aria-disabled":
|
|
62
|
-
tabindex:
|
|
79
|
+
"aria-disabled": n.disabled || u.value,
|
|
80
|
+
tabindex: n.disabled ? -1 : 0,
|
|
63
81
|
"aria-label": "选择上传文件",
|
|
64
|
-
onClick: e[0] || (e[0] = (
|
|
65
|
-
var
|
|
66
|
-
return !
|
|
82
|
+
onClick: e[0] || (e[0] = (a) => {
|
|
83
|
+
var t;
|
|
84
|
+
return !n.disabled && ((t = d.value) == null ? void 0 : t.click());
|
|
67
85
|
}),
|
|
68
86
|
onKeydown: [
|
|
69
|
-
e[1] || (e[1] = h(
|
|
70
|
-
var
|
|
71
|
-
return !
|
|
87
|
+
e[1] || (e[1] = x(h((a) => {
|
|
88
|
+
var t;
|
|
89
|
+
return !n.disabled && ((t = d.value) == null ? void 0 : t.click());
|
|
72
90
|
}, ["prevent"]), ["enter"])),
|
|
73
|
-
e[2] || (e[2] = h(
|
|
74
|
-
var
|
|
75
|
-
return !
|
|
91
|
+
e[2] || (e[2] = x(h((a) => {
|
|
92
|
+
var t;
|
|
93
|
+
return !n.disabled && ((t = d.value) == null ? void 0 : t.click());
|
|
76
94
|
}, ["prevent"]), ["space"]))
|
|
77
95
|
],
|
|
78
|
-
onDragover: e[3] || (e[3] =
|
|
79
|
-
onDragleave: e[4] || (e[4] = (
|
|
80
|
-
onDrop: e[5] || (e[5] =
|
|
81
|
-
var
|
|
82
|
-
|
|
96
|
+
onDragover: e[3] || (e[3] = h((a) => n.drag && !n.disabled && (v.value = !0), ["prevent"])),
|
|
97
|
+
onDragleave: e[4] || (e[4] = (a) => v.value = !1),
|
|
98
|
+
onDrop: e[5] || (e[5] = h((a) => {
|
|
99
|
+
var t;
|
|
100
|
+
v.value = !1, n.drag && z(Array.from(((t = a.dataTransfer) == null ? void 0 : t.files) || []));
|
|
83
101
|
}, ["prevent"]))
|
|
84
102
|
}, [
|
|
85
|
-
|
|
86
|
-
|
|
103
|
+
C(i.$slots, "default", {}, () => [
|
|
104
|
+
k(g(M), {
|
|
87
105
|
size: 28,
|
|
88
106
|
"aria-hidden": "true"
|
|
89
107
|
}),
|
|
90
|
-
|
|
91
|
-
e[7] || (e[7] =
|
|
108
|
+
m("strong", null, U(u.value ? "正在检查文件…" : "点击选择或拖入文件"), 1),
|
|
109
|
+
e[7] || (e[7] = m("span", null, "文件通过事件交给业务层上传", -1))
|
|
92
110
|
], !0)
|
|
93
|
-
], 42,
|
|
94
|
-
|
|
111
|
+
], 42, G),
|
|
112
|
+
m("input", {
|
|
95
113
|
ref_key: "input",
|
|
96
114
|
ref: d,
|
|
97
115
|
hidden: "",
|
|
98
116
|
type: "file",
|
|
99
|
-
accept:
|
|
100
|
-
multiple:
|
|
101
|
-
disabled:
|
|
102
|
-
onChange: e[6] || (e[6] = (
|
|
103
|
-
}, null, 40,
|
|
104
|
-
|
|
105
|
-
(
|
|
106
|
-
key:
|
|
117
|
+
accept: n.accept,
|
|
118
|
+
multiple: n.multiple,
|
|
119
|
+
disabled: n.disabled || u.value,
|
|
120
|
+
onChange: e[6] || (e[6] = (a) => z(Array.from(a.target.files || [])))
|
|
121
|
+
}, null, 40, J),
|
|
122
|
+
n.showFileList ? (p(), y("div", O, [
|
|
123
|
+
(p(!0), y(H, null, K(o.value, (a) => (p(), y("div", {
|
|
124
|
+
key: a.uid,
|
|
107
125
|
class: "hys-ui-upload-file"
|
|
108
126
|
}, [
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
127
|
+
k(g(X), { size: 16 }),
|
|
128
|
+
C(i.$slots, "file", { file: a }, () => [
|
|
129
|
+
P(U(a.name), 1)
|
|
112
130
|
], !0),
|
|
113
|
-
|
|
131
|
+
m("button", {
|
|
114
132
|
type: "button",
|
|
115
|
-
"aria-label": "移除" +
|
|
116
|
-
disabled:
|
|
117
|
-
onClick: (
|
|
133
|
+
"aria-label": "移除" + a.name,
|
|
134
|
+
disabled: n.disabled,
|
|
135
|
+
onClick: (t) => F(a)
|
|
118
136
|
}, [
|
|
119
|
-
|
|
120
|
-
], 8,
|
|
137
|
+
k(g(j), { size: 14 })
|
|
138
|
+
], 8, Q)
|
|
121
139
|
]))), 128))
|
|
122
|
-
])) :
|
|
140
|
+
])) : I("", !0)
|
|
123
141
|
], 16));
|
|
124
142
|
}
|
|
125
143
|
});
|
|
126
144
|
export {
|
|
127
|
-
|
|
145
|
+
ee as default
|
|
128
146
|
};
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
const
|
|
1
|
+
const i = Symbol("hys-ui-form"), d = Symbol("hys-ui-field");
|
|
2
|
+
function n(e) {
|
|
3
|
+
if (!e || e.closest("[inert],fieldset[disabled]") || e.getAttribute("aria-disabled") === "true") return;
|
|
4
|
+
const t = e.matches('input,button,textarea,select,a[href],[tabindex],[contenteditable="true"]') ? e : e.querySelector('input:checked:not(:disabled),input:not(:disabled):not([hidden]),button:not(:disabled),[tabindex]:not([tabindex="-1"])');
|
|
5
|
+
t == null || t.focus();
|
|
6
|
+
}
|
|
2
7
|
export {
|
|
3
|
-
|
|
4
|
-
|
|
8
|
+
d as fieldKey,
|
|
9
|
+
n as focusHysField,
|
|
10
|
+
i as formKey
|
|
5
11
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const e = [];
|
|
2
|
+
function i(t) {
|
|
3
|
+
if (t.key !== "Escape" || t.defaultPrevented) return;
|
|
4
|
+
const n = e.at(-1);
|
|
5
|
+
n && (t.preventDefault(), n.close());
|
|
6
|
+
}
|
|
7
|
+
function o(t) {
|
|
8
|
+
const n = { close: t };
|
|
9
|
+
return e.length || document.addEventListener("keydown", i), e.push(n), () => {
|
|
10
|
+
const s = e.indexOf(n);
|
|
11
|
+
s >= 0 && e.splice(s, 1), e.length || document.removeEventListener("keydown", i);
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
o as registerToastEscape
|
|
16
|
+
};
|
|
@@ -2,13 +2,13 @@ import { ref as k, computed as D, onActivated as w, onDeactivated as x, watch as
|
|
|
2
2
|
import { lockBodyScroll as T, registerOverlay as A } from "./overlayManager.js";
|
|
3
3
|
const C = 'a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])';
|
|
4
4
|
function B(h, t, m) {
|
|
5
|
-
const
|
|
5
|
+
const o = k(!0), s = D(() => h.value && o.value);
|
|
6
6
|
w(() => {
|
|
7
|
-
|
|
7
|
+
o.value = !0;
|
|
8
8
|
}), x(() => {
|
|
9
|
-
|
|
9
|
+
o.value = !1, c++, f();
|
|
10
10
|
});
|
|
11
|
-
let d = null,
|
|
11
|
+
let d = null, i, u, c = 0;
|
|
12
12
|
function v() {
|
|
13
13
|
var e;
|
|
14
14
|
return Array.from(((e = t.value) == null ? void 0 : e.querySelectorAll(C)) ?? []).filter((n) => n.getClientRects().length > 0 && getComputedStyle(n).visibility !== "hidden");
|
|
@@ -25,31 +25,31 @@ function B(h, t, m) {
|
|
|
25
25
|
e.preventDefault(), t.value.focus();
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
|
-
const
|
|
29
|
-
e.shiftKey && (document.activeElement ===
|
|
28
|
+
const l = n[0], r = n[n.length - 1];
|
|
29
|
+
e.shiftKey && (document.activeElement === l || document.activeElement === t.value || !t.value.contains(document.activeElement)) ? (e.preventDefault(), r.focus()) : !e.shiftKey && (document.activeElement === r || !t.value.contains(document.activeElement)) && (e.preventDefault(), l.focus());
|
|
30
30
|
}
|
|
31
31
|
function p(e) {
|
|
32
32
|
!s.value || !(u != null && u()) || !t.value || e.target instanceof Node && !t.value.contains(e.target) && (v()[0] ?? t.value).focus();
|
|
33
33
|
}
|
|
34
34
|
function f() {
|
|
35
|
-
|
|
35
|
+
i == null || i(), i = void 0, u = void 0, document.removeEventListener("keydown", y, !0), document.removeEventListener("focusin", p, !0);
|
|
36
36
|
}
|
|
37
37
|
return L(s, async (e) => {
|
|
38
|
-
var
|
|
38
|
+
var l, r;
|
|
39
39
|
const n = ++c;
|
|
40
40
|
if (e) {
|
|
41
41
|
f(), d = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
42
|
-
const
|
|
43
|
-
u = E.isTop,
|
|
44
|
-
E.unregister(),
|
|
45
|
-
}, document.addEventListener("keydown", y, !0), document.addEventListener("focusin", p, !0), await b(), n === c && s.value && ((
|
|
42
|
+
const a = T(), E = A("dialog", m);
|
|
43
|
+
u = E.isTop, i = () => {
|
|
44
|
+
E.unregister(), a();
|
|
45
|
+
}, document.addEventListener("keydown", y, !0), document.addEventListener("focusin", p, !0), await b(), n === c && s.value && ((r = ((l = t.value) == null ? void 0 : l.querySelector("[autofocus]")) ?? v()[0] ?? t.value) == null || r.focus());
|
|
46
46
|
} else {
|
|
47
|
-
const
|
|
48
|
-
f(), await b(), n === c &&
|
|
47
|
+
const a = d;
|
|
48
|
+
f(), await b(), n === c && o.value && (a != null && a.isConnected) && a.focus();
|
|
49
49
|
}
|
|
50
50
|
}, { immediate: !0, flush: "post" }), S(() => {
|
|
51
|
-
c++, f();
|
|
52
|
-
}), { active:
|
|
51
|
+
o.value = !1, c++, f();
|
|
52
|
+
}), { active: o };
|
|
53
53
|
}
|
|
54
54
|
export {
|
|
55
55
|
B as useDialog
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { registerOverlay as
|
|
3
|
-
function
|
|
4
|
-
const
|
|
5
|
-
let
|
|
6
|
-
function
|
|
7
|
-
if (!
|
|
1
|
+
import { ref as E, onDeactivated as q, onBeforeUnmount as D, nextTick as H } from "vue";
|
|
2
|
+
import { registerOverlay as I } from "./overlayManager.js";
|
|
3
|
+
function P(f, a, m = {}) {
|
|
4
|
+
const l = E(!1), W = E(!1), M = E({ position: "fixed", top: "0px", left: "0px", visibility: "hidden" }), A = E(m.placement ?? "bottom-start"), d = m.gap ?? 8, r = m.padding ?? 10;
|
|
5
|
+
let L = 0, h, c, g = 0;
|
|
6
|
+
function $() {
|
|
7
|
+
if (!l.value || !f.value || !a.value) return;
|
|
8
8
|
const t = f.value.getBoundingClientRect();
|
|
9
9
|
if (!t.width && !t.height) {
|
|
10
10
|
s();
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
|
-
const e = document.documentElement.clientWidth, n = document.documentElement.clientHeight, o = Math.min(t.width, Math.max(0, e - 2 * r));
|
|
14
|
-
|
|
15
|
-
const
|
|
13
|
+
const e = document.documentElement.clientWidth, n = document.documentElement.clientHeight, o = Math.min(t.width, Math.max(0, e - 2 * r)), v = typeof m.matchWidth == "function" ? m.matchWidth() : m.matchWidth;
|
|
14
|
+
v === !0 && (a.value.style.width = `${o}px`, a.value.style.minWidth = "0", a.value.style.maxWidth = `${o}px`), v === "min" && (a.value.style.width = "max-content", a.value.style.minWidth = `${o}px`, a.value.style.maxWidth = `calc(100vw - ${r * 2}px)`);
|
|
15
|
+
const w = a.value.getBoundingClientRect(), p = Math.min(w.width, Math.max(0, e - 2 * r)), x = Math.min(w.height, Math.max(0, n - 2 * r));
|
|
16
16
|
let i = m.placement ?? "bottom-start";
|
|
17
|
-
const k = n - t.bottom - d,
|
|
18
|
-
i.startsWith("bottom") && k <
|
|
19
|
-
let
|
|
20
|
-
(i === "right" || i === "left") && (
|
|
17
|
+
const k = n - t.bottom - d, z = t.top - d;
|
|
18
|
+
i.startsWith("bottom") && k < x && z > k ? i = i.replace("bottom", "top") : i.startsWith("top") && z < x && k > z ? i = i.replace("top", "bottom") : i === "right" && e - t.right - d < p && t.left > e - t.right ? i = "left" : i === "left" && t.left - d < p && e - t.right > t.left && (i = "right");
|
|
19
|
+
let y = i.endsWith("end") ? t.right - p : t.left, b = i.startsWith("top") ? t.top - x - d : t.bottom + d;
|
|
20
|
+
(i === "right" || i === "left") && (y = i === "right" ? t.right + d : t.left - p - d, b = t.top + (t.height - x) / 2), y = Math.max(r, Math.min(y, e - p - r)), b = Math.max(r, Math.min(b, n - x - r)), A.value = i, M.value = { ...v === !0 ? { width: `${o}px`, minWidth: "0" } : v === "min" ? { width: "max-content", minWidth: `${o}px` } : {}, position: "fixed", left: `${Math.round(y)}px`, top: `${Math.round(b)}px`, visibility: "visible", zIndex: "1200", maxWidth: `calc(100vw - ${r * 2}px)`, maxHeight: `calc(100vh - ${r * 2}px)`, overflowY: "auto", overscrollBehavior: "contain" };
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
cancelAnimationFrame(
|
|
22
|
+
function u() {
|
|
23
|
+
cancelAnimationFrame(L), L = requestAnimationFrame($);
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function F(t) {
|
|
26
26
|
var e, n;
|
|
27
|
-
c != null && c() && !((e = f.value) != null && e.contains(t.target)) && !((n =
|
|
27
|
+
c != null && c() && !((e = f.value) != null && e.contains(t.target)) && !((n = a.value) != null && n.contains(t.target)) && s();
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function B(t) {
|
|
30
30
|
var e, n;
|
|
31
|
-
if (!(!
|
|
31
|
+
if (!(!l.value || !(c != null && c()))) {
|
|
32
32
|
if (t.key === "Escape")
|
|
33
33
|
t.preventDefault(), t.stopImmediatePropagation(), s(!0);
|
|
34
34
|
else if (t.key === "Tab") {
|
|
@@ -37,46 +37,46 @@ function O(f, u, m = {}) {
|
|
|
37
37
|
s();
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
|
-
if ((n =
|
|
41
|
-
const
|
|
42
|
-
(!
|
|
40
|
+
if ((n = a.value) != null && n.contains(o)) {
|
|
41
|
+
const v = Array.from(a.value.querySelectorAll('a[href],button:not(:disabled),input:not(:disabled),textarea:not(:disabled),select:not(:disabled),[tabindex]:not([tabindex="-1"])')).filter((w) => w.getClientRects().length && !w.closest("[inert]"));
|
|
42
|
+
(!v.length || o === (t.shiftKey ? v[0] : v.at(-1))) && s(!0);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function C() {
|
|
48
48
|
var t, e;
|
|
49
|
-
document.removeEventListener("pointerdown",
|
|
49
|
+
document.removeEventListener("pointerdown", F, !0), document.removeEventListener("keydown", B, !0), window.removeEventListener("resize", u), window.removeEventListener("scroll", u, !0), (t = window.visualViewport) == null || t.removeEventListener("resize", u), (e = window.visualViewport) == null || e.removeEventListener("scroll", u), cancelAnimationFrame(L), h == null || h(), h = void 0, c = void 0;
|
|
50
50
|
}
|
|
51
51
|
function s(t = !1) {
|
|
52
52
|
var e;
|
|
53
|
-
if (g++, !!
|
|
54
|
-
|
|
53
|
+
if (g++, !!l.value && (l.value = !1, C(), t && ((e = f.value) != null && e.isConnected))) {
|
|
54
|
+
W.value = !0;
|
|
55
55
|
try {
|
|
56
56
|
f.value.focus();
|
|
57
57
|
} finally {
|
|
58
|
-
|
|
58
|
+
W.value = !1;
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
async function
|
|
62
|
+
async function V() {
|
|
63
63
|
var n, o;
|
|
64
|
-
if (
|
|
65
|
-
|
|
64
|
+
if (l.value) {
|
|
65
|
+
u();
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
68
|
const t = ++g;
|
|
69
|
-
if (
|
|
70
|
-
const e =
|
|
71
|
-
|
|
69
|
+
if (l.value = !0, M.value = { position: "fixed", top: "0px", left: "0px", visibility: "hidden" }, await H(), t !== g || !l.value) return;
|
|
70
|
+
const e = I("floating", () => s(!0));
|
|
71
|
+
h = e.unregister, c = e.isTop, $(), document.addEventListener("pointerdown", F, !0), document.addEventListener("keydown", B, !0), window.addEventListener("resize", u), window.addEventListener("scroll", u, !0), (n = window.visualViewport) == null || n.addEventListener("resize", u), (o = window.visualViewport) == null || o.addEventListener("scroll", u);
|
|
72
72
|
}
|
|
73
|
-
function
|
|
74
|
-
return
|
|
73
|
+
function R() {
|
|
74
|
+
return l.value ? s() : V();
|
|
75
75
|
}
|
|
76
|
-
return
|
|
77
|
-
g++,
|
|
78
|
-
}), { open:
|
|
76
|
+
return q(() => s()), D(() => {
|
|
77
|
+
g++, C();
|
|
78
|
+
}), { open: l, style: M, placement: A, update: $, show: V, close: s, toggle: R, restoringFocus: W };
|
|
79
79
|
}
|
|
80
80
|
export {
|
|
81
|
-
|
|
81
|
+
P as useFloating
|
|
82
82
|
};
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { defineComponent as k, createApp as F, h as m, getCurrentInstance as Q, shallowReactive as A, Fragment as R, onDeactivated as B, onActivated as N, onScopeDispose as P, nextTick as W, render as b } from "vue";
|
|
2
|
+
import X from "../components/HysToast/HysToast.vue.js";
|
|
3
|
+
import { provideHysConfig as z, useHysRootAttrs as G } from "../config.js";
|
|
4
|
+
let J = 0;
|
|
5
|
+
const g = (n = "top-center") => n === "top" ? "top-center" : n === "bottom" ? "bottom-center" : n;
|
|
6
|
+
function K(n = {}) {
|
|
7
|
+
const l = Q();
|
|
8
|
+
if (!l) throw new Error("useHysToast must be called during component setup");
|
|
9
|
+
const p = G(), a = A([]), d = /* @__PURE__ */ new Map();
|
|
10
|
+
let r, x = !0, v = !1;
|
|
11
|
+
const M = Number.isFinite(n.maxCount) ? Math.max(1, Math.floor(n.maxCount)) : 5, w = (e) => typeof e == "string" ? { message: e } : e;
|
|
12
|
+
function C(e) {
|
|
13
|
+
try {
|
|
14
|
+
e == null || e();
|
|
15
|
+
} catch (o) {
|
|
16
|
+
try {
|
|
17
|
+
l.appContext.config.errorHandler ? l.appContext.config.errorHandler(o, l.proxy, "HysToast callback") : console.error(o);
|
|
18
|
+
} catch (s) {
|
|
19
|
+
console.error(s);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function H(e) {
|
|
24
|
+
if (e.finished) return;
|
|
25
|
+
e.finished = !0;
|
|
26
|
+
const o = a.indexOf(e);
|
|
27
|
+
o >= 0 && a.splice(o, 1), d.delete(e.token), e.resolve(), C(e.onAfterClose);
|
|
28
|
+
const s = r;
|
|
29
|
+
W(() => {
|
|
30
|
+
s && s === r && !a.length && (b(null, s), s.remove(), r = void 0);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function h(e) {
|
|
34
|
+
if (!(e.closing || e.finished)) {
|
|
35
|
+
e.closing = !0;
|
|
36
|
+
try {
|
|
37
|
+
C(e.onClose);
|
|
38
|
+
} finally {
|
|
39
|
+
const o = d.get(e.token);
|
|
40
|
+
o ? o.close() : H(e);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function I(e, o) {
|
|
45
|
+
if (e.closing || e.finished || v) return;
|
|
46
|
+
const s = w(o), t = e.type;
|
|
47
|
+
Object.assign(e, s, { id: e.id }), s.type && s.type !== t && s.duration === void 0 && (e.duration = s.type === "loading" ? 0 : n.duration), W(() => {
|
|
48
|
+
var f;
|
|
49
|
+
e.closing || (f = d.get(e.token)) == null || f.restart();
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function j(e) {
|
|
53
|
+
const o = g(e.position), s = Math.max(0, e.offset ?? 24) + "px", t = { position: "fixed", width: "max-content", display: "flex", flexDirection: o.startsWith("bottom") ? "column-reverse" : "column", gap: "10px", alignItems: o.endsWith("left") ? "flex-start" : o.endsWith("right") ? "flex-end" : "center", maxWidth: `calc(100vw - ${Math.max(16, e.offset ?? 24) * 2}px)`, pointerEvents: "none", zIndex: e.zIndex ?? 2e3 };
|
|
54
|
+
return o === "center" ? Object.assign(t, { left: "50%", top: "50%", transform: "translate(-50%,-50%)" }) : (o.startsWith("bottom") ? t.bottom = `max(${s},env(safe-area-inset-bottom))` : t.top = `max(${s},env(safe-area-inset-top))`, o.endsWith("left") ? t.left = `max(${s},env(safe-area-inset-left))` : o.endsWith("right") ? t.right = `max(${s},env(safe-area-inset-right))` : Object.assign(t, { left: "50%", transform: "translateX(-50%)" })), t;
|
|
55
|
+
}
|
|
56
|
+
const q = k({
|
|
57
|
+
name: "HysToastQueue",
|
|
58
|
+
setup() {
|
|
59
|
+
return z({ theme: () => p.value["data-hys-theme"], motion: () => p.value["data-hys-motion"] }), () => {
|
|
60
|
+
const e = /* @__PURE__ */ new Map();
|
|
61
|
+
for (const o of a) {
|
|
62
|
+
const s = `${g(o.position)}:${o.offset ?? 24}:${o.zIndex ?? 2e3}`, t = e.get(s) || [];
|
|
63
|
+
t.push(o), e.set(s, t);
|
|
64
|
+
}
|
|
65
|
+
return m(R, [...e].map(([o, s]) => m("div", { key: o, ...p.value, class: "hys-ui-toast-stack", style: j(s[0]) }, s.map((t) => m(X, {
|
|
66
|
+
key: t.token,
|
|
67
|
+
ref: (f) => {
|
|
68
|
+
f ? d.set(t.token, f) : d.delete(t.token);
|
|
69
|
+
},
|
|
70
|
+
"data-toast-id": t.id,
|
|
71
|
+
message: t.message,
|
|
72
|
+
type: t.type,
|
|
73
|
+
duration: t.duration,
|
|
74
|
+
closable: t.closable ?? !0,
|
|
75
|
+
showIcon: t.showIcon ?? !0,
|
|
76
|
+
pauseOnHover: t.pauseOnHover ?? !0,
|
|
77
|
+
closeOnEscape: t.closeOnEscape,
|
|
78
|
+
position: t.position,
|
|
79
|
+
offset: t.offset,
|
|
80
|
+
zIndex: t.zIndex,
|
|
81
|
+
plain: t.plain,
|
|
82
|
+
repeat: t.repeat,
|
|
83
|
+
teleport: !1,
|
|
84
|
+
onClose: () => h(t),
|
|
85
|
+
onAfterClose: () => H(t)
|
|
86
|
+
}, {
|
|
87
|
+
...t.content !== void 0 ? { default: () => typeof t.content == "function" ? t.content() : t.content } : {},
|
|
88
|
+
...t.icon !== void 0 ? { icon: () => typeof t.icon == "function" ? t.icon() : t.icon } : {}
|
|
89
|
+
})))));
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
function D() {
|
|
94
|
+
if (r) return;
|
|
95
|
+
const e = typeof n.appendTo == "string" ? document.querySelector(n.appendTo) : n.appendTo ?? document.body;
|
|
96
|
+
if (!e) throw new Error("Toast appendTo target was not found");
|
|
97
|
+
r = document.createElement("div"), r.dataset.hysToastHost = "", e.appendChild(r);
|
|
98
|
+
const o = m(q);
|
|
99
|
+
o.appContext = l.appContext, b(o, r);
|
|
100
|
+
}
|
|
101
|
+
function O(e) {
|
|
102
|
+
const o = w(e), s = { type: "info", ...n, ...o };
|
|
103
|
+
s.type === "loading" && o.duration === void 0 && (s.duration = 0);
|
|
104
|
+
const t = a.find((i) => !i.closing && (o.id && i.id === o.id || s.grouping && o.message && o.content === void 0 && i.message === o.message && i.type === s.type && g(i.position) === g(s.position)));
|
|
105
|
+
if (t)
|
|
106
|
+
return o.id || t.repeat++, I(t, o), t.handle;
|
|
107
|
+
const f = "hys-toast-" + ++J, $ = o.id ?? f;
|
|
108
|
+
let T;
|
|
109
|
+
const S = new Promise((i) => {
|
|
110
|
+
T = i;
|
|
111
|
+
}), c = A({ ...s, token: f, id: $, repeat: 1, closing: !1, finished: !1, resolve: T });
|
|
112
|
+
if (c.handle = { id: $, closed: S, close: () => h(c), update: (i) => I(c, i) }, v || !x || !c.message && (c.content == null || c.content === !1 || c.content === ""))
|
|
113
|
+
return c.finished = !0, T(), c.handle;
|
|
114
|
+
for (; a.filter((i) => !i.closing).length >= M; ) h(a.find((i) => !i.closing));
|
|
115
|
+
return D(), a.push(c), c.handle;
|
|
116
|
+
}
|
|
117
|
+
function E() {
|
|
118
|
+
for (const e of [...a])
|
|
119
|
+
e.closing || (e.closing = !0, C(e.onClose)), H(e);
|
|
120
|
+
r && (b(null, r), r.remove(), r = void 0);
|
|
121
|
+
}
|
|
122
|
+
B(() => {
|
|
123
|
+
x = !1, E();
|
|
124
|
+
}), N(() => {
|
|
125
|
+
x = !0;
|
|
126
|
+
}), P(() => {
|
|
127
|
+
v = !0, E();
|
|
128
|
+
});
|
|
129
|
+
const u = (e) => (o) => O({ ...w(o), type: e });
|
|
130
|
+
return { show: O, success: u("success"), info: u("info"), warning: u("warning"), error: u("error"), loading: u("loading"), closeAll: () => {
|
|
131
|
+
for (const e of [...a]) h(e);
|
|
132
|
+
} };
|
|
133
|
+
}
|
|
134
|
+
function Y(n = {}) {
|
|
135
|
+
let l, p = !1;
|
|
136
|
+
const a = k({ setup() {
|
|
137
|
+
return l = K(n), () => null;
|
|
138
|
+
} }), d = F(k({ setup() {
|
|
139
|
+
return z(n), () => m(a);
|
|
140
|
+
} }));
|
|
141
|
+
return d.mount(document.createElement("div")), { ...l, dispose() {
|
|
142
|
+
p || (p = !0, d.unmount());
|
|
143
|
+
} };
|
|
144
|
+
}
|
|
145
|
+
export {
|
|
146
|
+
Y as createHysToast,
|
|
147
|
+
K as useHysToast
|
|
148
|
+
};
|
package/dist/config.js
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
import { computed as
|
|
2
|
-
const
|
|
3
|
-
function
|
|
4
|
-
const
|
|
5
|
-
|
|
1
|
+
import { computed as a, toValue as s, provide as m, getCurrentInstance as i, inject as f } from "vue";
|
|
2
|
+
const u = Symbol("hys-ui-config"), r = /* @__PURE__ */ new WeakMap();
|
|
3
|
+
function h(t) {
|
|
4
|
+
const e = c(), n = { theme: t.theme ?? e.theme, motion: t.motion ?? e.motion };
|
|
5
|
+
m(u, n);
|
|
6
|
+
const o = i();
|
|
7
|
+
o && r.set(o, n);
|
|
6
8
|
}
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
+
function c() {
|
|
10
|
+
const t = i();
|
|
11
|
+
return t && r.get(t) || f(u, {});
|
|
9
12
|
}
|
|
10
|
-
function
|
|
11
|
-
const
|
|
12
|
-
return
|
|
13
|
-
const
|
|
14
|
-
return { "data-hys-ui": "", "data-hys-theme":
|
|
13
|
+
function d() {
|
|
14
|
+
const t = c();
|
|
15
|
+
return a(() => {
|
|
16
|
+
const e = s(t.theme), n = s(t.motion);
|
|
17
|
+
return { "data-hys-ui": "", "data-hys-theme": e && ["blue", "dark", "green", "purple", "orange", "forest"].includes(e) ? e : "blue", "data-hys-motion": n && ["full", "subtle", "off"].includes(n) ? n : "subtle" };
|
|
15
18
|
});
|
|
16
19
|
}
|
|
17
20
|
export {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
h as provideHysConfig,
|
|
22
|
+
c as useHysConfig,
|
|
23
|
+
d as useHysRootAttrs
|
|
21
24
|
};
|