hys-ui 0.4.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 (152) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/components/HysAnimatedNumber/HysAnimatedNumber.vue.js +3 -3
  3. package/dist/components/HysAnimatedNumber/HysAnimatedNumber2.vue.js +440 -119
  4. package/dist/components/HysAnimatedNumber/NumberAnimationCanvas/NumberAnimationCanvas.vue.js +7 -0
  5. package/dist/components/HysAnimatedNumber/NumberAnimationCanvas/NumberAnimationCanvas2.vue.js +166 -0
  6. package/dist/components/HysAnimatedNumber/NumberDigits/NumberDigits.vue.js +7 -0
  7. package/dist/components/HysAnimatedNumber/NumberDigits/NumberDigits2.vue.js +105 -0
  8. package/dist/components/HysAnimatedNumber/animation/digital.js +186 -0
  9. package/dist/components/HysAnimatedNumber/animation/morph.js +110 -0
  10. package/dist/components/HysAnimatedNumber/animation/paint.js +34 -0
  11. package/dist/components/HysAnimatedNumber/animation/particles.js +51 -0
  12. package/dist/components/HysAnimatedNumber/animation/paths.js +165 -0
  13. package/dist/components/HysAnimatedNumber/animation/physics.js +66 -0
  14. package/dist/components/HysAnimatedNumber/animation/render.js +89 -0
  15. package/dist/components/HysAnimatedNumber/animation/reveal.js +125 -0
  16. package/dist/components/HysAnimatedNumber/animation/rolling.js +66 -0
  17. package/dist/components/HysAnimatedNumber/animation/scenarios.js +217 -0
  18. package/dist/components/HysAnimatedNumber/animation/spatial.js +112 -0
  19. package/dist/components/HysAnimatedNumber/useNumberCountdown.js +58 -0
  20. package/dist/components/HysAnimatedNumber/useNumberVisuals.js +60 -0
  21. package/dist/components/HysDrawer/HysDrawer.vue.js +1 -1
  22. package/dist/components/HysDrawer/HysDrawer2.vue.js +2 -2
  23. package/dist/components/HysFormItem/HysFormItem.vue.js +1 -1
  24. package/dist/components/HysFormItem/HysFormItem2.vue.js +231 -229
  25. package/dist/components/HysInput/HysInput.vue.js +2 -2
  26. package/dist/components/HysInput/HysInput2.vue.js +327 -274
  27. package/dist/components/HysModal/HysModal.vue.js +2 -2
  28. package/dist/components/HysModal/HysModal2.vue.js +38 -38
  29. package/dist/components/HysSearch/HysSearch.vue.js +2 -2
  30. package/dist/components/HysSortableList/HysSortableList.vue.js +2 -2
  31. package/dist/components/HysSortableList/HysSortableList2.vue.js +498 -129
  32. package/dist/components/HysSortableList/SortableGhost/SortableGhost.vue.js +7 -0
  33. package/dist/components/HysSortableList/SortableGhost/SortableGhost2.vue.js +43 -0
  34. package/dist/components/HysSortableList/SortableGhost/useSortGhost.js +54 -0
  35. package/dist/components/HysSortableList/geometry.js +230 -0
  36. package/dist/components/HysSortableList/model.js +254 -0
  37. package/dist/components/HysSortableList/transactions.js +281 -0
  38. package/dist/components/HysSortableList/useSortDrag.js +270 -0
  39. package/dist/components/HysSortableList/useSortKeyboard.js +72 -0
  40. package/dist/components/HysSortableList/useSortWindow.js +144 -0
  41. package/dist/components/HysTextarea/HysTextarea.vue.js +56 -32
  42. package/dist/components/HysToast/HysToast.vue.js +3 -3
  43. package/dist/components/HysToast/HysToast2.vue.js +379 -107
  44. package/dist/components/HysToast/ToastViewport/ToastViewport.vue.js +7 -0
  45. package/dist/components/HysToast/ToastViewport/ToastViewport2.vue.js +211 -0
  46. package/dist/components/HysToast/ToastViewport/useToastStackDisclosure.js +71 -0
  47. package/dist/components/HysToast/toastPresentation.js +98 -0
  48. package/dist/components/HysToast/useToastActions.js +62 -0
  49. package/dist/components/HysToast/useToastSwipe.js +48 -0
  50. package/dist/components/HysToast/useToastTimer.js +90 -0
  51. package/dist/composables/animatedNumberDigits.js +106 -0
  52. package/dist/composables/animatedNumberFormat.js +222 -0
  53. package/dist/composables/animatedNumberTiming.js +66 -0
  54. package/dist/composables/numberAnimation.js +72 -0
  55. package/dist/composables/numberAnimationCatalog.js +301 -0
  56. package/dist/composables/numberAnimationSequence.js +45 -0
  57. package/dist/composables/popupReferenceBinding.js +41 -0
  58. package/dist/composables/textInput.js +23 -14
  59. package/dist/composables/toastEscape.js +18 -10
  60. package/dist/composables/toastQueue.js +276 -0
  61. package/dist/composables/toastQueueModel.js +86 -0
  62. package/dist/composables/toastTasks.js +58 -0
  63. package/dist/composables/useHysAnimatedNumber.js +264 -0
  64. package/dist/composables/useHysNumberAnimationGroup.js +23 -0
  65. package/dist/composables/useHysToast.js +117 -135
  66. package/dist/composables/usePopupSurface.js +190 -356
  67. package/dist/composables/usePopupSurfaceInteractions.js +172 -0
  68. package/dist/composables/useTextareaSize.js +62 -46
  69. package/dist/index.js +125 -111
  70. package/dist/style.css +1 -1
  71. package/dist/types/components/HysAnimatedNumber/HysAnimatedNumber.vue.d.ts +88 -49
  72. package/dist/types/components/HysAnimatedNumber/NumberAnimationCanvas/NumberAnimationCanvas.vue.d.ts +19 -0
  73. package/dist/types/components/HysAnimatedNumber/NumberDigits/NumberDigits.vue.d.ts +31 -0
  74. package/dist/types/components/HysAnimatedNumber/animation/digital.d.ts +3 -0
  75. package/dist/types/components/HysAnimatedNumber/animation/morph.d.ts +2 -0
  76. package/dist/types/components/HysAnimatedNumber/animation/paint.d.ts +44 -0
  77. package/dist/types/components/HysAnimatedNumber/animation/particles.d.ts +5 -0
  78. package/dist/types/components/HysAnimatedNumber/animation/paths.d.ts +12 -0
  79. package/dist/types/components/HysAnimatedNumber/animation/physics.d.ts +2 -0
  80. package/dist/types/components/HysAnimatedNumber/animation/render.d.ts +2 -0
  81. package/dist/types/components/HysAnimatedNumber/animation/reveal.d.ts +2 -0
  82. package/dist/types/components/HysAnimatedNumber/animation/rolling.d.ts +2 -0
  83. package/dist/types/components/HysAnimatedNumber/animation/scenarios.d.ts +4 -0
  84. package/dist/types/components/HysAnimatedNumber/animation/spatial.d.ts +2 -0
  85. package/dist/types/components/HysAnimatedNumber/useNumberCountdown.d.ts +8 -0
  86. package/dist/types/components/HysAnimatedNumber/useNumberVisuals.d.ts +12 -0
  87. package/dist/types/components/HysAutocomplete/HysAutocomplete.vue.d.ts +11 -2
  88. package/dist/types/components/HysAvatarGroup/HysAvatarGroup.vue.d.ts +2 -2
  89. package/dist/types/components/HysCard/HysCard.vue.d.ts +1 -1
  90. package/dist/types/components/HysCascader/HysCascader.vue.d.ts +3 -3
  91. package/dist/types/components/HysCascader/HysCascaderColumn.vue.d.ts +2 -2
  92. package/dist/types/components/HysColorPicker/HysColorPicker.vue.d.ts +2 -2
  93. package/dist/types/components/HysDatePicker/HysDatePicker.vue.d.ts +3 -3
  94. package/dist/types/components/HysDatePicker/HysDatePickerControl.vue.d.ts +5 -5
  95. package/dist/types/components/HysDateRangePicker/HysDateRangePicker.vue.d.ts +3 -3
  96. package/dist/types/components/HysDrawer/HysDrawer.vue.d.ts +1 -1
  97. package/dist/types/components/HysFormItem/HysFormItem.vue.d.ts +1 -1
  98. package/dist/types/components/HysGantt/HysGantt.vue.d.ts +1 -1
  99. package/dist/types/components/HysInput/HysInput.vue.d.ts +13 -1
  100. package/dist/types/components/HysModal/HysModal.vue.d.ts +1 -1
  101. package/dist/types/components/HysNumberInput/HysNumberInput.vue.d.ts +2 -2
  102. package/dist/types/components/HysPopover/HysPopover.vue.d.ts +1 -1
  103. package/dist/types/components/HysSearch/HysSearch.vue.d.ts +1 -1
  104. package/dist/types/components/HysSkeleton/HysSkeleton.vue.d.ts +2 -2
  105. package/dist/types/components/HysSortableList/HysSortableList.vue.d.ts +48 -25
  106. package/dist/types/components/HysSortableList/SortableGhost/SortableGhost.vue.d.ts +31 -0
  107. package/dist/types/components/HysSortableList/SortableGhost/useSortGhost.d.ts +23 -0
  108. package/dist/types/components/HysSortableList/geometry.d.ts +35 -0
  109. package/dist/types/components/HysSortableList/model.d.ts +61 -0
  110. package/dist/types/components/HysSortableList/sortableList.d.ts +151 -0
  111. package/dist/types/components/HysSortableList/transactions.d.ts +10 -0
  112. package/dist/types/components/HysSortableList/useSortDrag.d.ts +25 -0
  113. package/dist/types/components/HysSortableList/useSortKeyboard.d.ts +17 -0
  114. package/dist/types/components/HysSortableList/useSortWindow.d.ts +16 -0
  115. package/dist/types/components/HysSteps/HysSteps.vue.d.ts +1 -1
  116. package/dist/types/components/HysTabs/HysTabs.vue.d.ts +1 -1
  117. package/dist/types/components/HysTagInput/HysTagInput.vue.d.ts +1 -1
  118. package/dist/types/components/HysTextarea/HysTextarea.vue.d.ts +13 -2
  119. package/dist/types/components/HysToast/HysToast.vue.d.ts +44 -46
  120. package/dist/types/components/HysToast/ToastViewport/ToastViewport.vue.d.ts +25 -0
  121. package/dist/types/components/HysToast/ToastViewport/useToastStackDisclosure.d.ts +16 -0
  122. package/dist/types/components/HysToast/toastPresentation.d.ts +8 -0
  123. package/dist/types/components/HysToast/toastTypes.d.ts +212 -0
  124. package/dist/types/components/HysToast/useToastActions.d.ts +18 -0
  125. package/dist/types/components/HysToast/useToastSwipe.d.ts +11 -0
  126. package/dist/types/components/HysToast/useToastTimer.d.ts +22 -0
  127. package/dist/types/components/HysTooltip/HysTooltip.vue.d.ts +1 -1
  128. package/dist/types/components/HysTour/HysTour.vue.d.ts +1 -1
  129. package/dist/types/components/HysTreeSelect/HysTreeSelect.vue.d.ts +3 -3
  130. package/dist/types/components/HysUpload/HysUpload.vue.d.ts +2 -2
  131. package/dist/types/composables/animatedNumber.d.ts +220 -0
  132. package/dist/types/composables/animatedNumberDigits.d.ts +32 -0
  133. package/dist/types/composables/animatedNumberFormat.d.ts +16 -0
  134. package/dist/types/composables/animatedNumberTiming.d.ts +21 -0
  135. package/dist/types/composables/drawer.d.ts +1 -1
  136. package/dist/types/composables/numberAnimation.d.ts +29 -0
  137. package/dist/types/composables/numberAnimationCatalog.d.ts +58 -0
  138. package/dist/types/composables/numberAnimationSequence.d.ts +13 -0
  139. package/dist/types/composables/popupReferenceBinding.d.ts +9 -0
  140. package/dist/types/composables/textInput.d.ts +39 -4
  141. package/dist/types/composables/toastEscape.d.ts +1 -1
  142. package/dist/types/composables/toastQueue.d.ts +121 -0
  143. package/dist/types/composables/toastQueueModel.d.ts +116 -0
  144. package/dist/types/composables/toastTasks.d.ts +2 -0
  145. package/dist/types/composables/useHysAnimatedNumber.d.ts +37 -0
  146. package/dist/types/composables/useHysNumberAnimationGroup.d.ts +4 -0
  147. package/dist/types/composables/useHysToast.d.ts +4 -48
  148. package/dist/types/composables/usePopupSurface.d.ts +20 -20
  149. package/dist/types/composables/usePopupSurfaceInteractions.d.ts +33 -0
  150. package/dist/types/composables/useTextareaSize.d.ts +5 -2
  151. package/dist/types/index.d.ts +15 -6
  152. package/package.json +1 -1
@@ -0,0 +1,45 @@
1
+ import { hysNumberAnimationCatalog as w } from "./numberAnimationCatalog.js";
2
+ const A = new Map(
3
+ w.filter(({ category: o }) => o === "sequence").map(({ name: o, variant: m }) => [o, m])
4
+ ), l = (o, m, c) => typeof o == "number" && Number.isFinite(o) ? Math.max(0, Math.min(c, o)) : m;
5
+ function j(o, m, c = {}) {
6
+ const n = Math.floor(l(m, 0, 256)), M = l(c.duration, 650, 6e4), f = l(c.interval, 130, 6e4), u = Math.max(1, Math.floor(l(c.columns, 3, n))), r = A.get(o) ?? 0, p = l(c.seed, 17, 2147483647), e = Array.from({ length: n }, (a, t) => t);
7
+ for (let a = e.length - 1; a > 0; a--) {
8
+ const t = ((Math.imul(a + 1, 2246822507) ^ Math.imul(p + 1, 3266489909)) >>> 0) % (a + 1);
9
+ [e[a], e[t]] = [e[t], e[a]];
10
+ }
11
+ const g = new Map(e.map((a, t) => [a, t]));
12
+ return Array.from({ length: n }, (a, t) => {
13
+ const y = Math.min(t, n - t - 1), N = Math.floor(Math.abs(t - (n - 1) / 2)), s = Math.floor(t / u), h = t % u, b = [
14
+ t,
15
+ s + h,
16
+ Math.floor(t / 2),
17
+ N,
18
+ y,
19
+ g.get(t),
20
+ t,
21
+ 0,
22
+ t % 2,
23
+ t,
24
+ t * 1.15,
25
+ t % 3 * 2,
26
+ t + s,
27
+ y,
28
+ s,
29
+ s + h,
30
+ s * u + (s % 2 ? u - 1 - h : h),
31
+ g.get(t),
32
+ s,
33
+ h
34
+ ][r] * (r === 9 ? M : f), q = r === 7 ? t * f : 0;
35
+ return {
36
+ index: r === 17 ? e[t] : t,
37
+ delay: b,
38
+ duration: r === 6 ? Math.max(0, M + Math.max(0, n - 1) * f - b) : M + q,
39
+ reverse: (r === 8 || r === 13) && t % 2 === 1
40
+ };
41
+ });
42
+ }
43
+ export {
44
+ j as createHysNumberSequence
45
+ };
@@ -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,7 +1,14 @@
1
- let f;
2
- function u(t) {
1
+ function l(t) {
2
+ return t === "small" ? "sm" : t === "middle" || t === "default" ? "md" : t === "large" ? "lg" : t;
3
+ }
4
+ function h(t, n) {
5
+ const r = n != null && n.trim ? t.trim() : t, e = n != null && n.number ? parseFloat(r) : NaN;
6
+ return Number.isNaN(e) ? r : String(e);
7
+ }
8
+ let c;
9
+ function f(t) {
3
10
  const n = Intl.Segmenter;
4
- return n && (f ?? (f = new n(void 0, { granularity: "grapheme" })), f) ? Array.from(f.segment(t), (r) => r.segment) : Array.from(t);
11
+ return n && (c ?? (c = new n(void 0, { granularity: "grapheme" })), c) ? Array.from(c.segment(t), (r) => r.segment) : Array.from(t);
5
12
  }
6
13
  function m(t, n) {
7
14
  if (typeof n == "function")
@@ -10,25 +17,27 @@ function m(t, n) {
10
17
  if (Number.isFinite(r) && r >= 0) return r;
11
18
  } catch {
12
19
  }
13
- return n ? u(t).length : t.length;
20
+ return n ? f(t).length : t.length;
14
21
  }
15
- function h(t, n, r) {
22
+ function g(t, n, r) {
16
23
  if (n === void 0 || m(t, r) <= n) return t;
17
- const i = r ? u(t) : Array.from(t);
18
- let e = 0, o = i.length;
19
- for (; e < o; ) {
20
- const c = Math.ceil((e + o) / 2);
21
- m(i.slice(0, c).join(""), r) <= n ? e = c : o = c - 1;
24
+ const e = r ? f(t) : Array.from(t);
25
+ let o = 0, i = e.length;
26
+ for (; o < i; ) {
27
+ const u = Math.ceil((o + i) / 2);
28
+ m(e.slice(0, u).join(""), r) <= n ? o = u : i = u - 1;
22
29
  }
23
- return i.slice(0, e).join("");
30
+ return e.slice(0, o).join("");
24
31
  }
25
- function s(t) {
32
+ function N(t) {
26
33
  if (t === void 0 || t === "") return;
27
34
  const n = Number(t);
28
35
  return Number.isFinite(n) && n >= 0 ? Math.floor(n) : void 0;
29
36
  }
30
37
  export {
38
+ h as modelText,
31
39
  m as textCount,
32
- s as textLengthLimit,
33
- h as textLimit
40
+ l as textInputSize,
41
+ N as textLengthLimit,
42
+ g as textLimit
34
43
  };
@@ -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
  };
@@ -0,0 +1,276 @@
1
+ import { shallowRef as oe, shallowReactive as H, nextTick as J } from "vue";
2
+ import { finite as f, toastDuration as L, normalizeToastPosition as N } from "../components/HysToast/toastPresentation.js";
3
+ import { context as U, matches as V, snapshot as D, defaults as se, toastStackKey as X, asOptions as W, nextToastSequence as ie } from "./toastQueueModel.js";
4
+ import { createToastTaskRunner as ne } from "./toastTasks.js";
5
+ function de(Y, j, B) {
6
+ const l = oe({ ...Y }), a = H(/* @__PURE__ */ new Map()), c = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Map(), q = /* @__PURE__ */ new Set();
7
+ let p = !0, K = !1, v = 0, Q = !1, A = !1;
8
+ function m(e, ...t) {
9
+ try {
10
+ e == null || e(...t);
11
+ } catch (o) {
12
+ B(o);
13
+ }
14
+ }
15
+ function k(e, t) {
16
+ e.status = t, m(e.options.onStateChange, D(e));
17
+ }
18
+ function P() {
19
+ return Math.max(1, Math.floor(f(l.value.maxCount, 5)));
20
+ }
21
+ function C(e) {
22
+ switch (l.value.queueScope) {
23
+ case "position":
24
+ return N(e.options.position);
25
+ case "type":
26
+ return e.options.type ?? "info";
27
+ case "group":
28
+ return e.options.group ?? "";
29
+ default:
30
+ return "";
31
+ }
32
+ }
33
+ function M(e, t) {
34
+ return f(t.options.priority, 0) - f(e.options.priority, 0) || (l.value.queueOrder === "lifo" ? t.serial - e.serial : e.serial - t.serial);
35
+ }
36
+ function g() {
37
+ if (!(!p || v)) {
38
+ if (Q) {
39
+ A = !0;
40
+ return;
41
+ }
42
+ Q = !0;
43
+ try {
44
+ A = !1;
45
+ const e = /* @__PURE__ */ new Map(), t = [], o = l.value.overflow === "queue";
46
+ for (const s of a.values())
47
+ if (s.status === "queued") t.push(s);
48
+ else if (s.status === "visible" || s.status === "closing" && o) {
49
+ const i = C(s);
50
+ e.set(i, (e.get(i) ?? 0) + 1);
51
+ }
52
+ for (const s of t.sort(M)) {
53
+ if (!p || s.status !== "queued") continue;
54
+ const i = C(s), u = e.get(i) ?? 0;
55
+ u >= P() || (e.set(i, u + 1), k(s, "visible"));
56
+ }
57
+ } finally {
58
+ Q = !1;
59
+ }
60
+ A && g();
61
+ }
62
+ }
63
+ function R(e, t) {
64
+ e.status === "closing" || e.status === "closed" || (e.closeContext = t, k(e, "closing"), m(e.options.onClose, t));
65
+ }
66
+ function S(e) {
67
+ if (e.status === "closed") return;
68
+ const t = e.closeContext;
69
+ a.get(e.id) === e && a.delete(e.id), c.delete(e.serial), x.delete(e.serial), q.delete(e), k(e, "closed"), e.resolve(), t && m(e.options.onAfterClose, t), g(), a.size || j.empty();
70
+ }
71
+ async function w(e, t = "api", o = !1) {
72
+ if (e.status === "closing" || e.status === "closed" || !o && q.has(e))
73
+ return;
74
+ const s = c.get(e.serial);
75
+ if (s) {
76
+ await s.close(t, void 0, o);
77
+ return;
78
+ }
79
+ const i = { ...U(e), reason: t };
80
+ if (!o && e.options.beforeClose) {
81
+ q.add(e);
82
+ try {
83
+ if (await e.options.beforeClose(i) === !1) return;
84
+ } catch {
85
+ return;
86
+ } finally {
87
+ q.delete(e);
88
+ }
89
+ if (e.status === "closed" || e.status === "closing")
90
+ return;
91
+ const u = c.get(e.serial);
92
+ if (u) {
93
+ await u.close(t, void 0, !0);
94
+ return;
95
+ }
96
+ }
97
+ R(e, i), S(e);
98
+ }
99
+ function T(e, t) {
100
+ var u;
101
+ if (!p || e.status === "closing" || e.status === "closed")
102
+ return;
103
+ const o = e.options, s = W(t), i = { ...o, ...s, id: e.id };
104
+ s.type && s.type !== o.type && !("duration" in s) && (i.duration = s.type === "loading" ? 0 : l.value.duration), i.message !== o.message || L(i) !== L(o) ? e.clock = void 0 : X(i) !== X(o) && (e.clock ?? (e.clock = (u = c.get(e.serial)) == null ? void 0 : u.snapshotClock())), e.options = i, (i.type !== o.type || i.group !== o.group || i.position !== o.position || i.priority !== o.priority) && (m(e.options.onStateChange, D(e)), g());
105
+ }
106
+ function Z(e) {
107
+ if (!(e.dedupe ?? (e.grouping ? "merge" : void 0)) || !e.dedupeKey && (!e.message || e.content !== void 0))
108
+ return;
109
+ const o = Date.now(), s = Math.max(0, f(e.dedupeWindow, 1 / 0));
110
+ return [...a.values()].find(
111
+ (i) => i.status !== "closing" && i.status !== "closed" && o - i.lastSeen <= s && i.options.group === e.group && (e.dedupeKey ? i.options.dedupeKey === e.dedupeKey : i.options.message === e.message && i.options.type === e.type && N(i.options.position) === N(e.position))
112
+ );
113
+ }
114
+ function b(e) {
115
+ var E;
116
+ const t = W(e), o = {
117
+ type: "info",
118
+ ...se(l.value),
119
+ ...t
120
+ };
121
+ o.type === "loading" && t.duration === void 0 && (o.duration = 0);
122
+ const s = t.id === void 0 ? void 0 : a.get(t.id);
123
+ if (s && s.status !== "closing" && s.status !== "closed")
124
+ return s.lastSeen = Date.now(), T(s, t), s.clock = void 0, J(() => {
125
+ var n;
126
+ return (n = c.get(s.serial)) == null ? void 0 : n.restart();
127
+ }), s.handle;
128
+ const i = Z(o);
129
+ if (i)
130
+ return i.lastSeen = Date.now(), o.dedupe !== "ignore" && (i.repeat++, T(i, t), (E = c.get(i.serial)) == null || E.restart()), i.handle;
131
+ const u = ie(), F = t.id ?? "hys-toast-" + u;
132
+ let O;
133
+ const y = new Promise((n) => {
134
+ O = n;
135
+ }), I = {
136
+ id: F,
137
+ closed: y,
138
+ close: () => {
139
+ w(d);
140
+ },
141
+ update: (n) => T(d, n),
142
+ extend: (n) => {
143
+ if (!Number.isFinite(n) || n <= 0 || !L(d.options))
144
+ return;
145
+ const r = c.get(u);
146
+ r ? r.extend(n) : d.extending += n;
147
+ },
148
+ pause: () => {
149
+ d.paused = !0;
150
+ },
151
+ resume: () => {
152
+ d.paused = !1;
153
+ }
154
+ }, d = H({
155
+ id: F,
156
+ serial: u,
157
+ options: o,
158
+ status: "queued",
159
+ repeat: 1,
160
+ paused: !1,
161
+ lastSeen: Date.now(),
162
+ extending: 0,
163
+ handle: I,
164
+ resolve: O
165
+ });
166
+ if (K || !p || typeof document > "u" || !o.message && !o.title && o.content == null && o.header == null)
167
+ return O(), I;
168
+ j.mount(), v++;
169
+ try {
170
+ (s == null ? void 0 : s.status) === "closing" && S(s), a.set(F, d);
171
+ const n = [...a.values()].filter(
172
+ (r) => r.status === "visible" && C(r) === C(d)
173
+ );
174
+ if (l.value.overflow !== "queue" && n.length >= P()) {
175
+ n.sort(
176
+ (r, G) => f(r.options.priority, 0) - f(G.options.priority, 0) || r.serial - G.serial
177
+ );
178
+ for (const r of n.slice(
179
+ 0,
180
+ n.length - P() + 1
181
+ ))
182
+ w(r, "overflow", !0);
183
+ }
184
+ k(d, "queued");
185
+ } finally {
186
+ v--;
187
+ }
188
+ g();
189
+ const ee = [...a.values()].filter((n) => n.status === "queued").sort(M), te = Math.max(
190
+ 0,
191
+ Math.floor(f(l.value.maxQueue, 1e3))
192
+ );
193
+ for (const n of ee.slice(te))
194
+ w(n, "overflow", !0);
195
+ return I;
196
+ }
197
+ function _(e, t, o) {
198
+ if (!t) {
199
+ x.get(e.serial) === o && (x.delete(e.serial), c.delete(e.serial));
200
+ return;
201
+ }
202
+ if (c.set(e.serial, t), x.set(e.serial, o), e.clock) {
203
+ const s = e.clock;
204
+ J(() => {
205
+ c.get(e.serial) !== t || e.clock !== s || (e.clock = void 0, t.restoreClock(s));
206
+ });
207
+ }
208
+ e.extending && (t.extend(e.extending), e.extending = 0);
209
+ }
210
+ async function z(e, t = !1) {
211
+ v++;
212
+ try {
213
+ await Promise.all(
214
+ [...a.values()].filter((o) => V(o, e)).map((o) => w(o, "api", t))
215
+ );
216
+ } finally {
217
+ v--, g();
218
+ }
219
+ }
220
+ function $(e = !1) {
221
+ p = !1, K || (K = e);
222
+ for (const t of [...a.values()])
223
+ R(t, { ...U(t), reason: "dispose" }), S(t);
224
+ }
225
+ const h = (e) => (t) => b({ ...W(t), type: e });
226
+ return {
227
+ api: {
228
+ show: b,
229
+ promise: ne(b, B),
230
+ success: h("success"),
231
+ info: h("info"),
232
+ warning: h("warning"),
233
+ error: h("error"),
234
+ loading: h("loading"),
235
+ close: (e) => {
236
+ const t = a.get(e);
237
+ t && w(t);
238
+ },
239
+ update: (e, t) => {
240
+ const o = a.get(e);
241
+ o && T(o, t);
242
+ },
243
+ find: (e) => {
244
+ const t = a.get(e);
245
+ return t && D(t);
246
+ },
247
+ list: (e) => [...a.values()].filter((t) => V(t, e)).sort(M).map(D),
248
+ closeAll: (e) => {
249
+ z(e);
250
+ },
251
+ closeType: (e) => {
252
+ z({ type: e });
253
+ },
254
+ clearQueue: () => {
255
+ z({ status: "queued" }, !0);
256
+ },
257
+ configure: (e) => {
258
+ l.value = { ...l.value, ...e }, g();
259
+ }
260
+ },
261
+ records: a,
262
+ settings: l,
263
+ order: M,
264
+ notify: m,
265
+ begin: R,
266
+ finish: S,
267
+ setInstance: _,
268
+ suspend: $,
269
+ resume: () => {
270
+ K || (p = !0);
271
+ }
272
+ };
273
+ }
274
+ export {
275
+ de as createToastQueue
276
+ };
@@ -0,0 +1,86 @@
1
+ import { normalizeToastPosition as e, finite as C } from "../components/HysToast/toastPresentation.js";
2
+ let S = 0;
3
+ const O = () => ++S, k = (o) => typeof o == "string" ? { message: o } : o;
4
+ function z(o) {
5
+ const {
6
+ id: t,
7
+ content: s,
8
+ icon: i,
9
+ header: p,
10
+ footer: u,
11
+ renderActions: a,
12
+ priority: r,
13
+ group: d,
14
+ grouping: c,
15
+ dedupe: f,
16
+ dedupeKey: g,
17
+ dedupeWindow: n,
18
+ onShow: x,
19
+ onAfterShow: l,
20
+ onClose: q,
21
+ onAfterClose: w,
22
+ onClick: A,
23
+ onAction: T,
24
+ onStateChange: v,
25
+ ...m
26
+ } = o;
27
+ return m;
28
+ }
29
+ function K(o) {
30
+ return JSON.stringify([
31
+ e(o.position),
32
+ o.offsetX ?? o.offset ?? 24,
33
+ o.offsetY ?? o.offset ?? 24,
34
+ o.zIndex ?? 2e3,
35
+ o.coordinates
36
+ ]);
37
+ }
38
+ function I(o) {
39
+ const {
40
+ maxCount: t,
41
+ maxQueue: s,
42
+ overflow: i,
43
+ queueOrder: p,
44
+ queueScope: u,
45
+ layout: a,
46
+ gap: r,
47
+ collapsedCount: d,
48
+ layerCount: c,
49
+ layerTrigger: f,
50
+ appendTo: g,
51
+ ...n
52
+ } = o;
53
+ return n;
54
+ }
55
+ function h(o) {
56
+ return {
57
+ id: o.id,
58
+ message: o.options.message ?? "",
59
+ title: o.options.title,
60
+ type: o.options.type ?? "info"
61
+ };
62
+ }
63
+ function J(o) {
64
+ return {
65
+ ...h(o),
66
+ id: o.id,
67
+ status: o.status,
68
+ position: e(o.options.position),
69
+ group: o.options.group,
70
+ priority: C(o.options.priority, 0),
71
+ repeat: o.repeat
72
+ };
73
+ }
74
+ function N(o, t = {}) {
75
+ return (t.type === void 0 || t.type === o.options.type) && (t.group === void 0 || t.group === o.options.group) && (t.status === void 0 || t.status === o.status) && (t.position === void 0 || e(t.position) === e(o.options.position));
76
+ }
77
+ export {
78
+ k as asOptions,
79
+ h as context,
80
+ I as defaults,
81
+ N as matches,
82
+ O as nextToastSequence,
83
+ z as presentation,
84
+ J as snapshot,
85
+ K as toastStackKey
86
+ };
@@ -0,0 +1,58 @@
1
+ import { feedback as l } from "../components/HysToast/useToastActions.js";
2
+ import { asOptions as k } from "./toastQueueModel.js";
3
+ function v(d, u) {
4
+ const t = /* @__PURE__ */ new WeakMap();
5
+ function c(a, r = {}) {
6
+ var p;
7
+ const s = d({
8
+ actions: void 0,
9
+ progress: void 0,
10
+ ...r.options,
11
+ id: r.id ?? ((p = r.options) == null ? void 0 : p.id),
12
+ type: "loading",
13
+ message: "正在处理…",
14
+ duration: 0,
15
+ ...k(r.loading ?? {})
16
+ }), o = Symbol();
17
+ t.set(s, o);
18
+ const n = (e) => {
19
+ t.get(s) === o && s.update(e);
20
+ };
21
+ function i(e, f) {
22
+ try {
23
+ return l(e, f);
24
+ } catch (g) {
25
+ u(g);
26
+ }
27
+ }
28
+ const m = Promise.resolve().then(
29
+ () => typeof a == "function" ? a({
30
+ handle: s,
31
+ update: n,
32
+ progress: (e) => n({ progress: e })
33
+ }) : a
34
+ ).then(
35
+ (e) => (t.get(s) === o && (n({
36
+ type: "success",
37
+ message: "操作成功",
38
+ progress: void 0,
39
+ persistent: !1,
40
+ ...i(r.success, e)
41
+ }), t.delete(s)), e),
42
+ (e) => {
43
+ throw t.get(s) === o && (n({
44
+ type: "error",
45
+ message: "操作失败",
46
+ progress: void 0,
47
+ persistent: !1,
48
+ ...i(r.error, e)
49
+ }), t.delete(s)), e;
50
+ }
51
+ );
52
+ return { handle: s, promise: m };
53
+ }
54
+ return c;
55
+ }
56
+ export {
57
+ v as createToastTaskRunner
58
+ };