hys-ui 0.5.0 → 0.6.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.
Files changed (66) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/components/HysDrawer/HysDrawer.vue.js +1 -1
  3. package/dist/components/HysDrawer/HysDrawer2.vue.js +2 -2
  4. package/dist/components/HysModal/HysModal.vue.js +2 -2
  5. package/dist/components/HysModal/HysModal2.vue.js +38 -38
  6. package/dist/components/HysSearch/HysSearch.vue.js +2 -2
  7. package/dist/components/HysSortableList/HysSortableList.vue.js +2 -2
  8. package/dist/components/HysSortableList/HysSortableList2.vue.js +498 -129
  9. package/dist/components/HysSortableList/SortableGhost/SortableGhost.vue.js +7 -0
  10. package/dist/components/HysSortableList/SortableGhost/SortableGhost2.vue.js +43 -0
  11. package/dist/components/HysSortableList/SortableGhost/useSortGhost.js +54 -0
  12. package/dist/components/HysSortableList/geometry.js +230 -0
  13. package/dist/components/HysSortableList/model.js +254 -0
  14. package/dist/components/HysSortableList/transactions.js +281 -0
  15. package/dist/components/HysSortableList/useSortDrag.js +270 -0
  16. package/dist/components/HysSortableList/useSortKeyboard.js +72 -0
  17. package/dist/components/HysSortableList/useSortWindow.js +144 -0
  18. package/dist/components/HysToast/HysToast.vue.js +3 -3
  19. package/dist/components/HysToast/HysToast2.vue.js +379 -107
  20. package/dist/components/HysToast/ToastViewport/ToastViewport.vue.js +7 -0
  21. package/dist/components/HysToast/ToastViewport/ToastViewport2.vue.js +211 -0
  22. package/dist/components/HysToast/ToastViewport/useToastStackDisclosure.js +71 -0
  23. package/dist/components/HysToast/toastPresentation.js +98 -0
  24. package/dist/components/HysToast/useToastActions.js +62 -0
  25. package/dist/components/HysToast/useToastSwipe.js +48 -0
  26. package/dist/components/HysToast/useToastTimer.js +90 -0
  27. package/dist/composables/popupReferenceBinding.js +41 -0
  28. package/dist/composables/toastEscape.js +18 -10
  29. package/dist/composables/toastQueue.js +276 -0
  30. package/dist/composables/toastQueueModel.js +86 -0
  31. package/dist/composables/toastTasks.js +58 -0
  32. package/dist/composables/useHysToast.js +117 -135
  33. package/dist/composables/usePopupSurface.js +190 -356
  34. package/dist/composables/usePopupSurfaceInteractions.js +172 -0
  35. package/dist/index.js +59 -57
  36. package/dist/style.css +1 -1
  37. package/dist/types/components/HysGantt/HysGantt.vue.d.ts +1 -1
  38. package/dist/types/components/HysModal/HysModal.vue.d.ts +1 -1
  39. package/dist/types/components/HysSortableList/HysSortableList.vue.d.ts +48 -25
  40. package/dist/types/components/HysSortableList/SortableGhost/SortableGhost.vue.d.ts +31 -0
  41. package/dist/types/components/HysSortableList/SortableGhost/useSortGhost.d.ts +23 -0
  42. package/dist/types/components/HysSortableList/geometry.d.ts +35 -0
  43. package/dist/types/components/HysSortableList/model.d.ts +61 -0
  44. package/dist/types/components/HysSortableList/sortableList.d.ts +151 -0
  45. package/dist/types/components/HysSortableList/transactions.d.ts +10 -0
  46. package/dist/types/components/HysSortableList/useSortDrag.d.ts +25 -0
  47. package/dist/types/components/HysSortableList/useSortKeyboard.d.ts +17 -0
  48. package/dist/types/components/HysSortableList/useSortWindow.d.ts +16 -0
  49. package/dist/types/components/HysToast/HysToast.vue.d.ts +44 -46
  50. package/dist/types/components/HysToast/ToastViewport/ToastViewport.vue.d.ts +25 -0
  51. package/dist/types/components/HysToast/ToastViewport/useToastStackDisclosure.d.ts +16 -0
  52. package/dist/types/components/HysToast/toastPresentation.d.ts +8 -0
  53. package/dist/types/components/HysToast/toastTypes.d.ts +212 -0
  54. package/dist/types/components/HysToast/useToastActions.d.ts +18 -0
  55. package/dist/types/components/HysToast/useToastSwipe.d.ts +11 -0
  56. package/dist/types/components/HysToast/useToastTimer.d.ts +22 -0
  57. package/dist/types/composables/popupReferenceBinding.d.ts +9 -0
  58. package/dist/types/composables/toastEscape.d.ts +1 -1
  59. package/dist/types/composables/toastQueue.d.ts +121 -0
  60. package/dist/types/composables/toastQueueModel.d.ts +116 -0
  61. package/dist/types/composables/toastTasks.d.ts +2 -0
  62. package/dist/types/composables/useHysToast.d.ts +4 -48
  63. package/dist/types/composables/usePopupSurface.d.ts +20 -20
  64. package/dist/types/composables/usePopupSurfaceInteractions.d.ts +33 -0
  65. package/dist/types/index.d.ts +3 -4
  66. package/package.json +1 -1
@@ -0,0 +1,211 @@
1
+ import { defineComponent as T, reactive as W, computed as A, watch as P, h as v, TransitionGroup as z, Transition as H, withDirectives as I, vShow as O } from "vue";
2
+ import { provideHysConfig as B } from "../../../config.js";
3
+ import { toastStackKey as F, presentation as L } from "../../../composables/toastQueueModel.js";
4
+ import _ from "../HysToast.vue.js";
5
+ import { finite as w, toastLocale as j, normalizeToastPosition as x, toastPlacement as G } from "../toastPresentation.js";
6
+ import { useToastStackDisclosure as K } from "./useToastStackDisclosure.js";
7
+ function S(a) {
8
+ var s;
9
+ const c = x(a.options.position);
10
+ return c.startsWith("bottom") || c === "custom" && ((s = a.options.coordinates) == null ? void 0 : s.bottom) !== void 0 && a.options.coordinates.top === void 0;
11
+ }
12
+ function R(a) {
13
+ const c = x(a.options.position), s = G(a.options), l = "calc(-1 * var(--hys-toast-stack-padding))", m = c === "center" || c.endsWith("center");
14
+ return {
15
+ ...s,
16
+ maxWidth: `calc(${s.maxWidth} + var(--hys-toast-stack-padding) * 2)`,
17
+ marginTop: s.top !== void 0 && c !== "center" ? l : void 0,
18
+ marginBottom: s.bottom !== void 0 ? l : void 0,
19
+ marginLeft: s.left !== void 0 && !m ? l : void 0,
20
+ marginRight: s.right !== void 0 ? l : void 0
21
+ };
22
+ }
23
+ function U(a, c, s) {
24
+ const l = x(a.options.position);
25
+ return {
26
+ flexDirection: c === "horizontal" ? "row" : S(a) ? "column-reverse" : "column",
27
+ flexWrap: c === "horizontal" ? "wrap" : "nowrap",
28
+ justifyContent: c === "horizontal" ? l.endsWith("right") ? "flex-end" : l.endsWith("left") ? "flex-start" : "center" : void 0,
29
+ alignItems: l.endsWith("left") ? "flex-start" : l.endsWith("right") ? "flex-end" : "center",
30
+ gap: Math.max(0, s) + "px"
31
+ };
32
+ }
33
+ const X = T({
34
+ name: "HysToastViewport",
35
+ props: {
36
+ queue: {
37
+ type: Object,
38
+ required: !0
39
+ },
40
+ skin: {
41
+ type: Function,
42
+ required: !0
43
+ }
44
+ },
45
+ setup(a) {
46
+ const c = W(/* @__PURE__ */ new Set()), s = K(), l = A(() => {
47
+ const t = /* @__PURE__ */ new Map();
48
+ for (const e of a.queue.records.values()) {
49
+ if (e.status === "queued") continue;
50
+ const o = F(e.options), d = t.get(o);
51
+ d ? d.push(e) : t.set(o, [e]);
52
+ }
53
+ return t;
54
+ });
55
+ P(
56
+ [l, () => a.queue.settings.value.layout],
57
+ ([t, e]) => {
58
+ s.retain(
59
+ e === "layered" ? [...t].filter(([, o]) => o.length > 1).map(([o]) => o) : []
60
+ );
61
+ for (const o of c) t.has(o) || c.delete(o);
62
+ }
63
+ ), B({
64
+ theme: () => a.skin()["data-hys-theme"],
65
+ motion: () => a.skin()["data-hys-motion"]
66
+ });
67
+ const m = (t) => (e) => typeof t == "function" ? t(e) : t;
68
+ function q(t, e, o, d, f) {
69
+ const { queue: u } = a, i = t.options, h = S(t), r = Array.from(
70
+ { length: d },
71
+ (n, p) => v("span", {
72
+ key: "layer-" + p,
73
+ class: "hys-ui-toast-layer-preview",
74
+ "aria-hidden": "true",
75
+ style: { "--hys-toast-layer-depth": p + 1, zIndex: -(p + 1) },
76
+ onClick: a.queue.settings.value.layerTrigger === "hover" ? void 0 : () => s.toggle(o)
77
+ })
78
+ ), g = v(
79
+ "div",
80
+ {
81
+ class: [
82
+ "hys-ui-toast-stack-item",
83
+ {
84
+ "hys-ui-toast-layered-front": d,
85
+ "hys-ui-toast-layered-bottom": d && h
86
+ }
87
+ ],
88
+ style: d ? { "--hys-toast-stack-depth": d } : void 0,
89
+ ...d && i.theme ? { "data-hys-ui": "", "data-hys-theme": i.theme } : {},
90
+ inert: e || void 0,
91
+ "aria-hidden": e || void 0
92
+ },
93
+ [
94
+ ...r,
95
+ v(
96
+ _,
97
+ {
98
+ ...L(i),
99
+ teleport: !1,
100
+ repeat: t.repeat,
101
+ paused: t.paused || f && i.pauseOnHover !== !1,
102
+ interactive: !e && i.interactive !== !1,
103
+ ref: (n) => u.setInstance(
104
+ t,
105
+ n,
106
+ o
107
+ ),
108
+ "data-toast-id": t.id,
109
+ onUpdate: t.handle.update,
110
+ onShow: (n) => {
111
+ t.shown || t.status !== "visible" || (t.shown = !0, u.notify(t.options.onShow, n));
112
+ },
113
+ onAfterShow: (n) => {
114
+ t.entered || t.status !== "visible" || (t.entered = !0, u.notify(t.options.onAfterShow, n));
115
+ },
116
+ onClose: (n) => u.begin(t, n),
117
+ onAfterClose: () => u.finish(t),
118
+ onClick: (n, p) => u.notify(t.options.onClick, n, p),
119
+ onAction: (n) => u.notify(t.options.onAction, n)
120
+ },
121
+ {
122
+ ...i.content !== void 0 ? { default: m(i.content) } : {},
123
+ ...i.icon !== void 0 ? { icon: m(i.icon) } : {},
124
+ ...i.header !== void 0 ? { header: m(i.header) } : {},
125
+ ...i.footer !== void 0 ? { footer: m(i.footer) } : {},
126
+ ...i.renderActions !== void 0 ? { action: m(i.renderActions) } : {}
127
+ }
128
+ )
129
+ ]
130
+ );
131
+ return v(
132
+ H,
133
+ { key: t.serial, name: "hys-ui-toast-stack-expand" },
134
+ {
135
+ default: () => I(g, [[O, !e]])
136
+ }
137
+ );
138
+ }
139
+ return () => {
140
+ const { queue: t } = a, e = t.settings.value;
141
+ return [...l.value].map(([o, d]) => {
142
+ const f = e.layout === "layered", u = f ? 1 : Math.max(0, Math.floor(w(e.collapsedCount, 0))), i = d.sort(t.order), h = u ? Math.max(0, i.length - u) : 0, r = s.stacks.get(o), g = f && e.layerTrigger !== "click", n = f ? !!(r != null && r.pinned || g && (r != null && r.preview || r != null && r.focused)) : c.has(o), p = f && !n ? Math.min(
143
+ h,
144
+ Math.min(
145
+ 4,
146
+ Math.max(1, Math.floor(w(e.layerCount, 3)) - 1)
147
+ )
148
+ ) : 0, k = { ...j, ...e.locale }, C = i.map(
149
+ (y, b) => q(
150
+ y,
151
+ !n && !!h && b >= u,
152
+ o,
153
+ b === 0 ? p : 0,
154
+ !!(g && (r != null && r.preview))
155
+ )
156
+ );
157
+ h && C.push(
158
+ v(
159
+ "button",
160
+ {
161
+ key: "stack-toggle",
162
+ type: "button",
163
+ class: "hys-ui-toast-stack-toggle",
164
+ "aria-expanded": n,
165
+ onClick: () => {
166
+ f ? s.toggle(o) : n ? c.delete(o) : c.add(o);
167
+ }
168
+ },
169
+ (f ? r != null && r.pinned : n) ? k.collapseStack : f && n ? k.pinStack : k.more(h)
170
+ )
171
+ );
172
+ const M = v(
173
+ z,
174
+ {
175
+ tag: "div",
176
+ moveClass: "hys-ui-toast-stack-move",
177
+ class: [
178
+ "hys-ui-toast-stack-items",
179
+ { "hys-ui-toast-stack-hover": g && h }
180
+ ],
181
+ ...g && h ? {
182
+ onPointerenter: (y) => s.enter(o, y),
183
+ onPointerleave: () => s.leave(o),
184
+ onFocusin: () => s.focusIn(o),
185
+ onFocusout: (y) => s.focusOut(o, y)
186
+ } : {},
187
+ style: U(
188
+ i[0],
189
+ e.layout ?? "vertical",
190
+ w(e.gap, 10)
191
+ )
192
+ },
193
+ { default: () => C }
194
+ );
195
+ return v(
196
+ "div",
197
+ {
198
+ key: o,
199
+ ...a.skin(),
200
+ class: "hys-ui-toast-stack",
201
+ style: R(i[0])
202
+ },
203
+ [M]
204
+ );
205
+ });
206
+ };
207
+ }
208
+ });
209
+ export {
210
+ X as default
211
+ };
@@ -0,0 +1,71 @@
1
+ import { reactive as v, onBeforeUnmount as g } from "vue";
2
+ function m() {
3
+ const r = v(/* @__PURE__ */ new Map()), s = /* @__PURE__ */ new Map();
4
+ function o(e) {
5
+ clearTimeout(s.get(e)), s.delete(e);
6
+ }
7
+ function u(e, t, n) {
8
+ s.set(
9
+ e,
10
+ setTimeout(() => {
11
+ s.delete(e), t();
12
+ }, n)
13
+ );
14
+ }
15
+ function c(e) {
16
+ return r.has(e) || r.set(e, {
17
+ pinned: !1,
18
+ preview: !1,
19
+ focused: !1,
20
+ suppressHover: !1
21
+ }), r.get(e);
22
+ }
23
+ function f(e, t) {
24
+ if (t.pointerType === "touch") return;
25
+ const n = c(e);
26
+ o(e), n.suppressHover || u(
27
+ e,
28
+ () => {
29
+ n.preview = !0;
30
+ },
31
+ 110
32
+ );
33
+ }
34
+ function a(e) {
35
+ const t = r.get(e);
36
+ t && (o(e), t.suppressHover = !1, u(
37
+ e,
38
+ () => {
39
+ t.preview = !1;
40
+ },
41
+ 140
42
+ ));
43
+ }
44
+ function p(e) {
45
+ const t = c(e);
46
+ if (!t.pinned) {
47
+ t.pinned = !0;
48
+ return;
49
+ }
50
+ o(e), t.pinned = t.preview = t.focused = !1, t.suppressHover = !0;
51
+ }
52
+ function l(e) {
53
+ const t = r.get(e);
54
+ t && (t.pinned || t.preview) && (t.focused = !0);
55
+ }
56
+ function d(e, t) {
57
+ const n = r.get(e);
58
+ n && !t.currentTarget.contains(
59
+ t.relatedTarget
60
+ ) && (n.focused = !1);
61
+ }
62
+ function i(e) {
63
+ const t = new Set(e);
64
+ for (const n of r.keys())
65
+ t.has(n) || (o(n), r.delete(n));
66
+ }
67
+ return g(() => i([])), { stacks: r, enter: f, leave: a, toggle: p, focusIn: l, focusOut: d, retain: i };
68
+ }
69
+ export {
70
+ m as useToastStackDisclosure
71
+ };
@@ -0,0 +1,98 @@
1
+ const m = {
2
+ close: "关闭提示",
3
+ copy: "复制消息",
4
+ copied: "已复制",
5
+ copyFailed: "无法复制消息",
6
+ expand: "展开内容",
7
+ collapse: "收起内容",
8
+ collapseStack: "收起提示列表",
9
+ pinStack: "固定展开提示列表",
10
+ remaining: (t) => t + " 秒后关闭",
11
+ repeat: (t) => "重复 " + t + " 次",
12
+ more: (t) => "展开其余 " + t + " 条提示",
13
+ actionFailed: "操作失败,请重试",
14
+ progress: "任务进度"
15
+ };
16
+ function c(t = "top-center") {
17
+ return t === "top" ? "top-center" : t === "bottom" ? "bottom-center" : t;
18
+ }
19
+ const r = (t, e) => Number.isFinite(t) ? t : e, p = (t) => t.persistent ? 0 : Math.min(
20
+ 2147483647,
21
+ Math.max(
22
+ 0,
23
+ r(t.duration, t.type === "loading" ? 0 : 3e3)
24
+ )
25
+ );
26
+ function u(t) {
27
+ const e = c(t.position), n = Math.max(0, r(t.offsetX, r(t.offset, 24))), i = Math.max(0, r(t.offsetY, r(t.offset, 24))), o = {
28
+ position: "fixed",
29
+ zIndex: t.zIndex ?? 2e3,
30
+ maxWidth: `min(calc(100vw - ${Math.min(48, Math.max(16, n)) * 2}px), calc(100vw - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px) - 16px))`
31
+ };
32
+ if (e === "custom") {
33
+ const a = t.coordinates;
34
+ return {
35
+ ...o,
36
+ top: (a == null ? void 0 : a.bottom) === void 0 ? `${i}px` : void 0,
37
+ left: (a == null ? void 0 : a.right) === void 0 ? `${n}px` : void 0,
38
+ ...a
39
+ };
40
+ }
41
+ if (e === "center")
42
+ return { ...o, top: "50%", left: "50%", translate: "-50% -50%" };
43
+ const s = e.startsWith("bottom") ? "bottom" : "top";
44
+ return o[s] = `max(${i}px, env(safe-area-inset-${s}, 0px))`, e.endsWith("left") ? o.left = `max(${n}px, env(safe-area-inset-left, 0px))` : e.endsWith("right") ? o.right = `max(${n}px, env(safe-area-inset-right, 0px))` : Object.assign(o, { left: "50%", translate: "-50% 0" }), o;
45
+ }
46
+ function f(t) {
47
+ const e = c(t.position);
48
+ return t.direction ? t.direction : e.endsWith("left") ? "left" : e.endsWith("right") ? "right" : e.startsWith("bottom") ? "bottom" : "top";
49
+ }
50
+ function l(t, e) {
51
+ if (typeof t != "function") return t ?? e;
52
+ try {
53
+ const i = `linear(${Array.from(
54
+ { length: 21 },
55
+ (o, s) => r(t(s / 20), s / 20)
56
+ ).join(",")})`;
57
+ return typeof CSS > "u" || CSS.supports("animation-timing-function", i) ? i : e;
58
+ } catch {
59
+ return e;
60
+ }
61
+ }
62
+ function x(t) {
63
+ const e = f(t), n = t.animation ?? "scale", i = {
64
+ top: "translateY(-16px)",
65
+ bottom: "translateY(16px)",
66
+ left: "translateX(-20px)",
67
+ right: "translateX(20px)"
68
+ }[e], o = typeof n == "object" ? n.enterFrom : {
69
+ fade: "none",
70
+ slide: i,
71
+ scale: "scale(.96)",
72
+ spring: i + " scale(.92)",
73
+ bounce: i + " scale(.93)",
74
+ rotate: "rotate(-6deg) scale(.96)",
75
+ none: "none"
76
+ }[n], s = n === "spring" ? "cubic-bezier(.18,.9,.32,1.45)" : n === "bounce" ? "cubic-bezier(.34,1.56,.64,1)" : "var(--hys-ui-motion-ease, ease)", a = typeof n == "object" ? n.leaveTo ?? o : o;
77
+ return {
78
+ "--hys-toast-enter": o,
79
+ "--hys-toast-recoil": {
80
+ top: "translateY(4px)",
81
+ bottom: "translateY(-4px)",
82
+ left: "translateX(4px)",
83
+ right: "translateX(-4px)"
84
+ }[e],
85
+ "--hys-toast-leave": a === "none" ? "translate(0)" : a,
86
+ "--hys-toast-motion-opacity": typeof n == "object" ? n.opacity ?? 0 : 0,
87
+ "--hys-toast-motion-duration": n === "none" ? "0ms" : t.animationDuration === void 0 ? "var(--hys-ui-motion-base, 200ms)" : Math.max(0, r(t.animationDuration, 200)) + "ms",
88
+ "--hys-toast-motion-easing": l(t.easing, s)
89
+ };
90
+ }
91
+ export {
92
+ r as finite,
93
+ c as normalizeToastPosition,
94
+ p as toastDuration,
95
+ m as toastLocale,
96
+ x as toastMotion,
97
+ u as toastPlacement
98
+ };
@@ -0,0 +1,62 @@
1
+ import { ref as v } from "vue";
2
+ function y(e, u) {
3
+ const r = typeof e == "function" ? e(u) : e;
4
+ return typeof r == "string" ? { message: r } : r;
5
+ }
6
+ function x(e) {
7
+ const u = v(), r = v("");
8
+ let a = 0;
9
+ async function d() {
10
+ if (!e.available()) return !1;
11
+ const t = a;
12
+ try {
13
+ return await navigator.clipboard.writeText(e.copyText()), t === a && (r.value = e.locale().copied), !0;
14
+ } catch {
15
+ return t === a && (r.value = e.locale().copyFailed), !1;
16
+ }
17
+ }
18
+ function i() {
19
+ return {
20
+ ...e.context(),
21
+ close: e.close,
22
+ update: e.update,
23
+ copy: d
24
+ };
25
+ }
26
+ async function b(t) {
27
+ var n;
28
+ if (!e.available() || u.value !== void 0 || t.disabled)
29
+ return;
30
+ const s = a, f = e.context();
31
+ u.value = t.id, e.emit({ ...f, action: t, status: "start" });
32
+ try {
33
+ const l = await ((n = t.run) == null ? void 0 : n.call(t, i()));
34
+ if (s !== a || !e.available()) return;
35
+ const c = y(t.success, l);
36
+ c && e.update({ type: "success", ...c }), e.emit({ ...f, action: t, status: "success", result: l }), t.closeOnSuccess !== !1 && await e.close();
37
+ } catch (l) {
38
+ if (s !== a || !e.available()) return;
39
+ let c;
40
+ try {
41
+ c = y(t.error, l);
42
+ } catch {
43
+ c = void 0;
44
+ }
45
+ e.update({
46
+ type: "error",
47
+ message: e.locale().actionFailed,
48
+ ...c
49
+ }), e.emit({ ...f, action: t, status: "error", result: l });
50
+ } finally {
51
+ s === a && (u.value = void 0);
52
+ }
53
+ }
54
+ function m() {
55
+ a++, u.value = void 0, r.value = "";
56
+ }
57
+ return { busy: u, copyStatus: r, copy: d, context: i, run: b, reset: m };
58
+ }
59
+ export {
60
+ y as feedback,
61
+ x as useToastActions
62
+ };
@@ -0,0 +1,48 @@
1
+ import { ref as f } from "vue";
2
+ function y(s, d, h) {
3
+ const o = f(0), u = f(!1), n = f(!1);
4
+ let a;
5
+ function l() {
6
+ var e, r;
7
+ const t = a == null ? void 0 : a.id;
8
+ a = void 0, t !== void 0 && ((r = (e = s.value) == null ? void 0 : e.hasPointerCapture) != null && r.call(e, t)) && s.value.releasePointerCapture(t), u.value = !1, o.value = 0;
9
+ }
10
+ function v(t) {
11
+ var e;
12
+ n.value = !1, !(a || !d() || t.button !== 0 || (e = t.target) != null && e.closest(
13
+ "button,a,input,textarea,select,[role=button],[contenteditable=true]"
14
+ )) && (a = { id: t.pointerId, x: t.clientX, y: t.clientY });
15
+ }
16
+ function p(t) {
17
+ var i, c;
18
+ if (t.pointerId !== (a == null ? void 0 : a.id)) return;
19
+ const e = t.clientX - a.x, r = t.clientY - a.y;
20
+ if (!(!u.value && Math.hypot(e, r) < 7)) {
21
+ if (!u.value && Math.abs(r) > Math.abs(e)) {
22
+ l();
23
+ return;
24
+ }
25
+ u.value || ((c = (i = s.value) == null ? void 0 : i.setPointerCapture) == null || c.call(i, t.pointerId), u.value = !0, n.value = !0), o.value = e, t.cancelable && t.preventDefault();
26
+ }
27
+ }
28
+ async function b(t) {
29
+ var i;
30
+ if (t.pointerId !== (a == null ? void 0 : a.id)) return;
31
+ const e = Math.min(
32
+ 110,
33
+ Math.max(44, (((i = s.value) == null ? void 0 : i.offsetWidth) ?? 240) * 0.26)
34
+ );
35
+ if (!u.value || Math.abs(o.value) < e) {
36
+ l();
37
+ return;
38
+ }
39
+ await h(t) ? a = void 0 : l();
40
+ }
41
+ function x(t) {
42
+ (a == null ? void 0 : a.id) === t.pointerId && !u.value && l();
43
+ }
44
+ return { shift: o, dragging: u, suppressClick: n, reset: l, start: v, move: p, end: b, leave: x };
45
+ }
46
+ export {
47
+ y as useToastSwipe
48
+ };
@@ -0,0 +1,90 @@
1
+ import { ref as m, watch as E, onMounted as L, onBeforeUnmount as p } from "vue";
2
+ const f = /* @__PURE__ */ new Set();
3
+ let o = !1;
4
+ function c() {
5
+ for (const e of f) e(o || document.hidden);
6
+ }
7
+ function x() {
8
+ o = !0, c();
9
+ }
10
+ function b() {
11
+ o = !1, c();
12
+ }
13
+ function y(e) {
14
+ return f.size || (window.addEventListener("blur", x), window.addEventListener("focus", b), document.addEventListener("visibilitychange", c)), f.add(e), e(o || document.hidden), () => {
15
+ f.delete(e), !f.size && (o = !1, window.removeEventListener("blur", x), window.removeEventListener("focus", b), document.removeEventListener("visibilitychange", c));
16
+ };
17
+ }
18
+ function D(e) {
19
+ const t = m(0), u = m(0), v = m(!1), w = m(!1);
20
+ let l, a = 0, r = !1, s;
21
+ function i() {
22
+ clearTimeout(l), l = void 0, a && (t.value = Math.max(0, a - Date.now())), a = 0;
23
+ }
24
+ function h() {
25
+ const n = Math.max(0, a - Date.now());
26
+ if (t.value = n, n === 0) {
27
+ a = 0, l = void 0, r = !0, e.expire();
28
+ return;
29
+ }
30
+ l = setTimeout(h, e.indicators() ? Math.min(n, 100) : n);
31
+ }
32
+ function d() {
33
+ if (i(), !(typeof window > "u") && !(!e.running() || v.value || e.pauseOnBlur() && w.value || !u.value || r)) {
34
+ if (t.value <= 0) {
35
+ r = !0, e.expire();
36
+ return;
37
+ }
38
+ a = Date.now() + t.value, l = setTimeout(
39
+ h,
40
+ e.indicators() ? Math.min(t.value, 100) : t.value
41
+ );
42
+ }
43
+ }
44
+ function g() {
45
+ i(), r = !1, t.value = u.value = e.duration(), d();
46
+ }
47
+ function M(n) {
48
+ !u.value || !Number.isFinite(n) || n <= 0 || (i(), r = !1, t.value = Math.min(2147483647, t.value + n), u.value = Math.min(2147483647, u.value + n), d());
49
+ }
50
+ return E(
51
+ [
52
+ e.running,
53
+ e.indicators,
54
+ e.pauseOnBlur,
55
+ v,
56
+ w
57
+ ],
58
+ d,
59
+ { flush: "sync" }
60
+ ), L(() => {
61
+ s = y((n) => {
62
+ w.value = n;
63
+ });
64
+ }), p(() => {
65
+ s == null || s(), i();
66
+ }), {
67
+ remaining: t,
68
+ total: u,
69
+ restart: g,
70
+ extend: M,
71
+ stop: i,
72
+ snapshot: () => ({
73
+ remaining: a ? Math.max(0, a - Date.now()) : t.value,
74
+ total: u.value,
75
+ expired: r
76
+ }),
77
+ restore(n) {
78
+ i(), t.value = n.remaining, u.value = n.total, r = n.expired, d();
79
+ },
80
+ pause: () => {
81
+ v.value = !0;
82
+ },
83
+ resume: () => {
84
+ v.value = !1;
85
+ }
86
+ };
87
+ }
88
+ export {
89
+ D as useToastTimer
90
+ };
@@ -0,0 +1,41 @@
1
+ function l(b, n, o) {
2
+ let e, i;
3
+ function s(t) {
4
+ if (!(!e || !i))
5
+ if (b === "tooltip") {
6
+ const r = t ? [i["aria-describedby"], n].filter(Boolean).join(" ") : i["aria-describedby"];
7
+ r ? e.setAttribute("aria-describedby", r) : e.removeAttribute("aria-describedby");
8
+ } else {
9
+ e.setAttribute(
10
+ "aria-haspopup",
11
+ i["aria-haspopup"] ?? "dialog"
12
+ ), e.setAttribute("aria-expanded", String(t));
13
+ const r = t ? n : i["aria-controls"];
14
+ r ? e.setAttribute("aria-controls", r) : e.removeAttribute("aria-controls");
15
+ }
16
+ }
17
+ function c() {
18
+ if (e)
19
+ for (const [t, r] of Object.entries(o))
20
+ e.removeEventListener(t, r);
21
+ if (e && i)
22
+ for (const [t, r] of Object.entries(i))
23
+ r === null ? e.removeAttribute(t) : e.setAttribute(t, r);
24
+ i = void 0, e = void 0;
25
+ }
26
+ function u(t, r) {
27
+ if (c(), !!t) {
28
+ e = t, i = Object.fromEntries(
29
+ ["aria-describedby", "aria-controls", "aria-expanded", "aria-haspopup"].map(
30
+ (a) => [a, t.getAttribute(a)]
31
+ )
32
+ ), s(r);
33
+ for (const [a, f] of Object.entries(o))
34
+ t.addEventListener(a, f);
35
+ }
36
+ }
37
+ return { attach: u, detach: c, syncAria: s };
38
+ }
39
+ export {
40
+ l as createPopupReferenceBinding
41
+ };
@@ -1,16 +1,24 @@
1
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());
2
+ function c(n) {
3
+ var i;
4
+ if (n.key !== "Escape" || n.defaultPrevented) return;
5
+ const r = document.activeElement;
6
+ let t = e.at(-1);
7
+ for (let o = e.length - 1; o >= 0; o--)
8
+ if ((i = e[o].element()) != null && i.contains(r)) {
9
+ t = e[o];
10
+ break;
11
+ }
12
+ t && (n.preventDefault(), t.close(n));
6
13
  }
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);
14
+ function d(n, r) {
15
+ if (typeof document > "u") return;
16
+ const t = { close: n, element: r };
17
+ return e.length || document.addEventListener("keydown", c), e.push(t), () => {
18
+ const i = e.indexOf(t);
19
+ i >= 0 && e.splice(i, 1), e.length || document.removeEventListener("keydown", c);
12
20
  };
13
21
  }
14
22
  export {
15
- o as registerToastEscape
23
+ d as registerToastEscape
16
24
  };