hys-ui 0.3.0 → 0.4.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 (93) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +68 -73
  3. package/dist/components/HysAnimatedNumber/HysAnimatedNumber.vue.js +5 -41
  4. package/dist/components/HysAnimatedNumber/HysAnimatedNumber2.vue.js +146 -2
  5. package/dist/components/HysButton/HysButton.vue.js +2 -2
  6. package/dist/components/HysButton/HysButton2.vue.js +227 -60
  7. package/dist/components/HysButtonGroup/HysButtonGroup.vue.js +7 -0
  8. package/dist/components/HysButtonGroup/HysButtonGroup2.vue.js +51 -0
  9. package/dist/components/HysMention/HysMention.vue.js +1 -1
  10. package/dist/components/HysMention/HysMention2.vue.js +1092 -154
  11. package/dist/components/HysModal/HysModal.vue.js +3 -3
  12. package/dist/components/HysModal/HysModal2.vue.js +81 -80
  13. package/dist/components/HysPagination/HysPagination.vue.js +2 -2
  14. package/dist/components/HysPagination/HysPagination2.vue.js +243 -180
  15. package/dist/components/HysSearch/HysSearch.vue.js +5 -82
  16. package/dist/components/HysSearch/HysSearch2.vue.js +176 -2
  17. package/dist/components/HysSelect/HysSelect.vue.js +2 -2
  18. package/dist/components/HysSelect/HysSelect2.vue.js +472 -443
  19. package/dist/components/HysSplitPane/HysSplitPane.vue.js +315 -58
  20. package/dist/components/HysSplitPane/HysSplitPane3.vue.js +5 -0
  21. package/dist/components/HysTable/HysTable.vue.js +2 -2
  22. package/dist/components/HysTable/HysTable2.vue.js +1418 -1150
  23. package/dist/components/HysTour/HysTour.vue.js +291 -67
  24. package/dist/components/HysTour/HysTour3.vue.js +5 -0
  25. package/dist/composables/buttonGroup.js +12 -0
  26. package/dist/composables/floatingPosition.js +18 -0
  27. package/dist/composables/mentionDocument.js +79 -0
  28. package/dist/composables/mentionEditor.js +58 -0
  29. package/dist/composables/selectOptions.js +44 -38
  30. package/dist/composables/splitPaneSizes.js +58 -0
  31. package/dist/composables/table.js +128 -105
  32. package/dist/composables/useDialog.js +50 -50
  33. package/dist/composables/useFloating.js +107 -103
  34. package/dist/composables/useMentionCaret.js +81 -0
  35. package/dist/composables/useMentionList.js +81 -0
  36. package/dist/composables/useMentionModel.js +90 -0
  37. package/dist/composables/useMentionOptions.js +421 -0
  38. package/dist/composables/useSplitPaneDrag.js +52 -0
  39. package/dist/composables/useSplitPaneStorage.js +38 -0
  40. package/dist/composables/useTable.js +344 -312
  41. package/dist/composables/useTableSticky.js +79 -0
  42. package/dist/composables/useTourLayout.js +129 -0
  43. package/dist/config.js +11 -11
  44. package/dist/index.js +175 -156
  45. package/dist/internal/MultiSplitPane.vue.js +305 -0
  46. package/dist/internal/MultiSplitPane2.vue.js +4 -0
  47. package/dist/style.css +1 -1
  48. package/dist/types/components/HysAnimatedNumber/HysAnimatedNumber.vue.d.ts +61 -7
  49. package/dist/types/components/HysAutocomplete/HysAutocomplete.vue.d.ts +1 -1
  50. package/dist/types/components/HysButton/HysButton.vue.d.ts +82 -22
  51. package/dist/types/components/HysButtonGroup/HysButtonGroup.vue.d.ts +30 -0
  52. package/dist/types/components/HysCascader/HysCascaderColumn.vue.d.ts +2 -2
  53. package/dist/types/components/HysColorPicker/HysColorPicker.vue.d.ts +2 -2
  54. package/dist/types/components/HysContextMenu/HysMenuPanel.vue.d.ts +2 -2
  55. package/dist/types/components/HysDatePicker/HysDatePickerControl.vue.d.ts +2 -2
  56. package/dist/types/components/HysDrawer/HysDrawer.vue.d.ts +1 -1
  57. package/dist/types/components/HysMention/HysMention.vue.d.ts +91 -40
  58. package/dist/types/components/HysModal/HysModal.vue.d.ts +1 -1
  59. package/dist/types/components/HysNumberInput/HysNumberInput.vue.d.ts +2 -2
  60. package/dist/types/components/HysPagination/HysPagination.vue.d.ts +55 -4
  61. package/dist/types/components/HysRating/HysRating.vue.d.ts +1 -1
  62. package/dist/types/components/HysSearch/HysSearch.vue.d.ts +45 -7
  63. package/dist/types/components/HysSelect/HysSelect.vue.d.ts +6 -1
  64. package/dist/types/components/HysSplitPane/HysSplitPane.vue.d.ts +125 -14
  65. package/dist/types/components/HysSteps/HysSteps.vue.d.ts +1 -1
  66. package/dist/types/components/HysTable/HysTable.vue.d.ts +1740 -3
  67. package/dist/types/components/HysTour/HysTour.vue.d.ts +46 -9
  68. package/dist/types/composables/buttonGroup.d.ts +9 -0
  69. package/dist/types/composables/floatingPosition.d.ts +14 -0
  70. package/dist/types/composables/mention.d.ts +284 -0
  71. package/dist/types/composables/mentionDocument.d.ts +15 -0
  72. package/dist/types/composables/mentionEditor.d.ts +7 -0
  73. package/dist/types/composables/modal.d.ts +2 -0
  74. package/dist/types/composables/selectOptions.d.ts +5 -0
  75. package/dist/types/composables/splitPaneSizes.d.ts +11 -0
  76. package/dist/types/composables/table.d.ts +116 -6
  77. package/dist/types/composables/tour.d.ts +68 -0
  78. package/dist/types/composables/useFloating.d.ts +1 -1
  79. package/dist/types/composables/useMentionCaret.d.ts +6 -0
  80. package/dist/types/composables/useMentionList.d.ts +23 -0
  81. package/dist/types/composables/useMentionModel.d.ts +14 -0
  82. package/dist/types/composables/useMentionOptions.d.ts +26 -0
  83. package/dist/types/composables/useSplitPaneDrag.d.ts +14 -0
  84. package/dist/types/composables/useSplitPaneStorage.d.ts +4 -0
  85. package/dist/types/composables/useTable.d.ts +7 -3
  86. package/dist/types/composables/useTableSticky.d.ts +22 -0
  87. package/dist/types/composables/useTourLayout.d.ts +33 -0
  88. package/dist/types/config.d.ts +1 -0
  89. package/dist/types/index.d.ts +36 -1
  90. package/dist/types/internal/MultiSplitPane.vue.d.ts +54 -0
  91. package/package.json +3 -2
  92. package/dist/components/HysSplitPane/HysSplitPane2.vue.js +0 -4
  93. package/dist/components/HysTour/HysTour2.vue.js +0 -4
@@ -0,0 +1,58 @@
1
+ const E = 1e-7;
2
+ function b(e, i) {
3
+ if (e === void 0) return;
4
+ const a = typeof e == "number" ? e : Number.parseFloat(e);
5
+ if (Number.isFinite(a)) {
6
+ if (a <= 0) return 0;
7
+ if (typeof e == "string" && e.endsWith("%")) return a;
8
+ if (i > 0) return a / i * 100;
9
+ }
10
+ }
11
+ function x(e) {
12
+ const i = e.map(({ min: t, max: n, preferred: o }) => Math.min(n, Math.max(t, o ?? t))), a = i.reduce((t, n) => t + n, 0), u = e.flatMap((t, n) => t.relative ? [n] : []);
13
+ if (a > 100 + 1e-7) {
14
+ let t = function(r) {
15
+ const c = r.reduce((s, M) => s + i[M] - e[M].min, 0);
16
+ if (c <= 1e-7 || o <= 1e-7) return;
17
+ const p = Math.min(o, c);
18
+ for (const s of r) i[s] -= (i[s] - e[s].min) * p / c;
19
+ o -= p;
20
+ };
21
+ const n = e.reduce((r, c) => r + c.min, 0);
22
+ if (n >= 100) return e.map((r) => r.min / n * 100);
23
+ let o = a - 100;
24
+ return t(u), t(e.map((r, c) => c)), i;
25
+ }
26
+ let f = 100 - a;
27
+ const h = e.flatMap((t, n) => t.preferred === void 0 ? [n] : []), g = h.flatMap((t) => [
28
+ { size: e[t].min, change: 1 },
29
+ { size: e[t].max, change: -1 }
30
+ ]).sort((t, n) => t.size - n.size);
31
+ let m = 0, l = 0;
32
+ for (const t of g) {
33
+ const n = (t.size - m) * l;
34
+ if (f < n) {
35
+ m += f / l, f = 0;
36
+ break;
37
+ }
38
+ m = t.size, f -= n, l += t.change;
39
+ }
40
+ for (const t of h)
41
+ i[t] = Math.min(e[t].max, Math.max(i[t], m));
42
+ function z(t) {
43
+ let n = t.filter((o) => e[o].max > i[o]);
44
+ for (; f > 1e-7 && n.length; ) {
45
+ const o = f / n.length;
46
+ n = n.filter((r) => {
47
+ const c = Math.min(o, e[r].max - i[r]);
48
+ return i[r] += c, f -= c, i[r] + 1e-7 < e[r].max;
49
+ });
50
+ }
51
+ }
52
+ return z(u), i;
53
+ }
54
+ export {
55
+ x as fitPaneSizes,
56
+ E as paneEpsilon,
57
+ b as paneRatio
58
+ };
@@ -1,150 +1,173 @@
1
- const N = (n) => typeof n + ":" + n;
2
- function g(n, r) {
3
- const s = typeof r == "string" ? r.split(".") : r;
4
- let o = n;
5
- for (const e of s) {
6
- if (o == null || typeof o != "object") return;
7
- o = o[e];
1
+ const C = (i) => typeof i + ":" + i;
2
+ function v(i, o) {
3
+ const a = typeof o == "string" ? o.split(".") : o;
4
+ let s = i;
5
+ for (const e of a) {
6
+ if (s == null || typeof s != "object") return;
7
+ s = s[e];
8
8
  }
9
- return o;
9
+ return s;
10
10
  }
11
- const M = (n) => n < 576 ? "xs" : n < 768 ? "sm" : n < 992 ? "md" : n < 1200 ? "lg" : n < 1600 ? "xl" : "xxl";
12
- function S(n, r, s = !0) {
13
- const o = /* @__PURE__ */ new Set();
14
- function e(y, u, i = /* @__PURE__ */ new Set(), p = 0) {
15
- return p > 32 ? [] : y.flatMap((d) => {
16
- if (i.has(d) || d.hidden || !s && d.type === "expand" || d.responsive && !d.responsive.includes(r) || o.has(d.key))
11
+ const F = (i) => i < 576 ? "xs" : i < 768 ? "sm" : i < 992 ? "md" : i < 1200 ? "lg" : i < 1600 ? "xl" : "xxl";
12
+ function I(i, o, a = !0) {
13
+ const s = /* @__PURE__ */ new Set();
14
+ function e(h, r, n = /* @__PURE__ */ new Set(), c = 0) {
15
+ return c > 32 ? [] : h.flatMap((l) => {
16
+ if (n.has(l) || l.hidden || !a && l.type === "expand" || l.responsive && !l.responsive.includes(o) || s.has(l.key))
17
17
  return [];
18
- o.add(d.key);
19
- const v = d.fixed === !1 ? void 0 : d.fixed === !0 ? "left" : d.fixed ?? u, b = d.children ? e(
20
- d.children,
21
- v,
22
- /* @__PURE__ */ new Set([...i, d]),
23
- p + 1
18
+ s.add(l.key);
19
+ const m = l.fixed === !1 ? void 0 : l.fixed === !0 ? "left" : l.fixed ?? r, k = l.children ? e(
20
+ l.children,
21
+ m,
22
+ /* @__PURE__ */ new Set([...n, l]),
23
+ c + 1
24
24
  ) : void 0;
25
- return b && !b.length ? [] : [{ ...d, fixed: v, children: b }];
25
+ return k && !k.length ? [] : [{ ...l, fixed: m, children: k }];
26
26
  });
27
27
  }
28
- const t = e(n);
29
- function a(y, u) {
30
- return y.flatMap((i) => {
31
- if (i.children) {
32
- const p = a(i.children, u);
33
- return p.length ? [{ ...i, children: p, fixed: u }] : [];
28
+ const t = e(i);
29
+ function u(h, r) {
30
+ return h.flatMap((n) => {
31
+ if (n.children) {
32
+ const c = u(n.children, r);
33
+ return c.length ? [{ ...n, children: c, fixed: r }] : [];
34
34
  }
35
- return i.fixed === u ? [i] : [];
35
+ return n.fixed === r ? [n] : [];
36
36
  });
37
37
  }
38
- const f = [
39
- ...a(t, "left"),
40
- ...a(t),
41
- ...a(t, "right")
38
+ const d = [
39
+ ...u(t, "left"),
40
+ ...u(t),
41
+ ...u(t, "right")
42
42
  ];
43
- function m(y) {
44
- return y.flatMap((u) => u.children ? m(u.children) : [u]);
43
+ function x(h) {
44
+ return h.flatMap((r) => r.children ? x(r.children) : [r]);
45
45
  }
46
- function l(y) {
46
+ function f(h) {
47
47
  return Math.max(
48
48
  1,
49
- ...y.map((u) => u.children ? 1 + l(u.children) : 1)
49
+ ...h.map((r) => r.children ? 1 + f(r.children) : 1)
50
50
  );
51
51
  }
52
- const c = l(f), h = Array.from({ length: c }, () => []);
53
- function x(y, u) {
54
- for (const i of y) {
55
- const p = i.children ? m(i.children) : [i];
56
- h[u].push({
57
- column: i,
58
- key: i.key + ":" + (i.fixed || "center"),
59
- leaves: p,
60
- colspan: p.length,
61
- rowspan: i.children ? 1 : c - u,
62
- fixed: i.fixed === "left" || i.fixed === "right" ? i.fixed : void 0
63
- }), i.children && x(i.children, u + 1);
52
+ const p = f(d), y = Array.from({ length: p }, () => []);
53
+ function b(h, r) {
54
+ for (const n of h) {
55
+ const c = n.children ? x(n.children) : [n];
56
+ y[r].push({
57
+ column: n,
58
+ key: n.key + ":" + (n.fixed || "center"),
59
+ leaves: c,
60
+ colspan: c.length,
61
+ rowspan: n.children ? 1 : p - r,
62
+ fixed: n.fixed === "left" || n.fixed === "right" ? n.fixed : void 0
63
+ }), n.children && b(n.children, r + 1);
64
64
  }
65
65
  }
66
- return x(f, 0), { leaves: m(f), headers: h };
66
+ b(d, 0);
67
+ const N = x(d), M = new Map(N.map((h, r) => [h.key, r])), w = y.map((h) => {
68
+ const r = [];
69
+ for (let n = 0; n < h.length; n++) {
70
+ const c = h[n], l = c.column.headerColSpan;
71
+ if (l === 0) {
72
+ r.push({ ...c, blank: !0 });
73
+ continue;
74
+ }
75
+ if (l === void 0 || !Number.isSafeInteger(l) || l <= 1 || c.column.children) {
76
+ r.push(c);
77
+ continue;
78
+ }
79
+ const m = [...c.leaves], k = M.get(m[0].key);
80
+ for (; m.length < l; ) {
81
+ const g = h[n + 1];
82
+ if (!g || g.column.children || g.column.type && g.column.type !== "default" || g.fixed !== c.fixed || g.rowspan !== c.rowspan || M.get(g.column.key) !== k + m.length) break;
83
+ m.push(g.column), n++;
84
+ }
85
+ r.push({ ...c, leaves: m, colspan: m.length });
86
+ }
87
+ return r;
88
+ });
89
+ return { leaves: N, headers: w };
67
90
  }
68
- function F(n, r) {
69
- const s = new Intl.Collator("zh-CN", {
91
+ function B(i, o) {
92
+ const a = new Intl.Collator("zh-CN", {
70
93
  numeric: !0,
71
94
  sensitivity: "base"
72
- }), o = n.flatMap((e) => {
73
- const t = r.find((a) => a.key === e.key);
95
+ }), s = i.flatMap((e) => {
96
+ const t = o.find((u) => u.key === e.key);
74
97
  return t && t.sortable !== "custom" ? [{ ...e, column: t }] : [];
75
98
  });
76
99
  return (e, t) => {
77
- for (const { direction: a, column: f } of o) {
78
- if (f.sorter) {
79
- const l = f.sorter(e, t);
80
- if (Number.isFinite(l) && l !== 0)
81
- return (a === "asc" ? 1 : -1) * l;
100
+ for (const { direction: u, column: d } of s) {
101
+ if (d.sorter) {
102
+ const f = d.sorter(e, t);
103
+ if (Number.isFinite(f) && f !== 0)
104
+ return (u === "asc" ? 1 : -1) * f;
82
105
  continue;
83
106
  }
84
- const m = Array.isArray(f.sortBy) ? f.sortBy : [f.sortBy ?? f.dataIndex ?? f.key];
85
- for (const l of m) {
86
- const c = typeof l == "function" ? l(e) : g(e, l), h = typeof l == "function" ? l(t) : g(t, l);
87
- if (c == null || h == null) {
88
- if (c == null && h == null) continue;
89
- return c == null ? 1 : -1;
107
+ const x = Array.isArray(d.sortBy) ? d.sortBy : [d.sortBy ?? d.dataIndex ?? d.key];
108
+ for (const f of x) {
109
+ const p = typeof f == "function" ? f(e) : v(e, f), y = typeof f == "function" ? f(t) : v(t, f);
110
+ if (p == null || y == null) {
111
+ if (p == null && y == null) continue;
112
+ return p == null ? 1 : -1;
90
113
  }
91
- const x = typeof c == "number" && typeof h == "number" ? Number.isNaN(c) ? Number.isNaN(h) ? 0 : 1 : Number.isNaN(h) ? -1 : c - h : s.compare(String(c), String(h));
92
- if (Number.isFinite(x) && x !== 0)
93
- return (a === "asc" ? 1 : -1) * x;
114
+ const b = typeof p == "number" && typeof y == "number" ? Number.isNaN(p) ? Number.isNaN(y) ? 0 : 1 : Number.isNaN(y) ? -1 : p - y : a.compare(String(p), String(y));
115
+ if (Number.isFinite(b) && b !== 0)
116
+ return (u === "asc" ? 1 : -1) * b;
94
117
  }
95
118
  }
96
119
  return 0;
97
120
  };
98
121
  }
99
- function w(n, r) {
100
- var o;
101
- const s = /* @__PURE__ */ new Map();
102
- for (const e of r) {
103
- const t = n[e.key];
122
+ function L(i, o) {
123
+ var s;
124
+ const a = /* @__PURE__ */ new Map();
125
+ for (const e of o) {
126
+ const t = i[e.key];
104
127
  if (!(t != null && t.length) || !e.filters || e.filterMethod) continue;
105
- const a = new Set(t), f = k(e.filters), m = new Map(f.map((l) => [l.value, l]));
106
- for (const l of t) {
107
- const c = (o = m.get(l)) == null ? void 0 : o.children;
108
- if (c)
109
- for (const h of k(c))
110
- a.add(h.value);
128
+ const u = new Set(t), d = S(e.filters), x = new Map(d.map((f) => [f.value, f]));
129
+ for (const f of t) {
130
+ const p = (s = x.get(f)) == null ? void 0 : s.children;
131
+ if (p)
132
+ for (const y of S(p))
133
+ u.add(y.value);
111
134
  }
112
- s.set(e.key, a);
135
+ a.set(e.key, u);
113
136
  }
114
- return (e) => r.every((t) => {
115
- const a = n[t.key];
116
- return a != null && a.length ? s.has(t.key) ? s.get(t.key).has(
117
- g(
137
+ return (e) => o.every((t) => {
138
+ const u = i[t.key];
139
+ return u != null && u.length ? a.has(t.key) ? a.get(t.key).has(
140
+ v(
118
141
  e,
119
142
  t.dataIndex ?? t.key
120
143
  )
121
- ) : a.some(
122
- (f) => t.filterMethod ? t.filterMethod(f, e, t) : String(g(e, t.dataIndex ?? t.key) ?? "").toLocaleLowerCase().includes(String(f).toLocaleLowerCase())
144
+ ) : u.some(
145
+ (d) => t.filterMethod ? t.filterMethod(d, e, t) : String(v(e, t.dataIndex ?? t.key) ?? "").toLocaleLowerCase().includes(String(d).toLocaleLowerCase())
123
146
  ) : !0;
124
147
  });
125
148
  }
126
- function k(n) {
127
- const r = [], s = /* @__PURE__ */ new Set(), o = [...n].reverse();
128
- for (; o.length; ) {
129
- const e = o.pop();
130
- s.has(e) || (s.add(e), r.push(e), e.children && o.push(...[...e.children].reverse()));
149
+ function S(i) {
150
+ const o = [], a = /* @__PURE__ */ new Set(), s = [...i].reverse();
151
+ for (; s.length; ) {
152
+ const e = s.pop();
153
+ a.has(e) || (a.add(e), o.push(e), e.children && s.push(...[...e.children].reverse()));
131
154
  }
132
- return r;
155
+ return o;
133
156
  }
134
- function C(n, r) {
135
- if (r.summary === "count") return n.length;
136
- const s = n.map((e) => g(e, r.dataIndex ?? r.key)).filter((e) => typeof e == "number" && Number.isFinite(e));
137
- if (!s.length) return "—";
138
- const o = s.reduce((e, t) => e + t, 0);
139
- return r.summary === "sum" ? +o.toFixed(12) : r.summary === "avg" ? +(o / s.length).toFixed(12) : r.summary === "min" ? s.reduce((e, t) => Math.min(e, t)) : r.summary === "max" ? s.reduce((e, t) => Math.max(e, t)) : "";
157
+ function A(i, o) {
158
+ if (o.summary === "count") return i.length;
159
+ const a = i.map((e) => v(e, o.dataIndex ?? o.key)).filter((e) => typeof e == "number" && Number.isFinite(e));
160
+ if (!a.length) return "—";
161
+ const s = a.reduce((e, t) => e + t, 0);
162
+ return o.summary === "sum" ? +s.toFixed(12) : o.summary === "avg" ? +(s / a.length).toFixed(12) : o.summary === "min" ? a.reduce((e, t) => Math.min(e, t)) : o.summary === "max" ? a.reduce((e, t) => Math.max(e, t)) : "";
140
163
  }
141
164
  export {
142
- M as tableBreakpoint,
143
- S as tableColumns,
144
- F as tableCompare,
145
- k as tableFilterOptions,
146
- w as tableFilterPredicate,
147
- C as tableSummary,
148
- N as tableToken,
149
- g as tableValue
165
+ F as tableBreakpoint,
166
+ I as tableColumns,
167
+ B as tableCompare,
168
+ S as tableFilterOptions,
169
+ L as tableFilterPredicate,
170
+ A as tableSummary,
171
+ C as tableToken,
172
+ v as tableValue
150
173
  };
@@ -1,98 +1,98 @@
1
- import { ref as O, inject as P, computed as b, provide as R, shallowRef as g, watch as L, nextTick as w, onActivated as B, onDeactivated as H, onBeforeUnmount as M } from "vue";
2
- import { overlayOwnerKey as D, registerOverlay as j, lockBodyScroll as N } from "./overlayManager.js";
1
+ import { ref as O, inject as P, computed as b, provide as R, shallowRef as g, watch as D, nextTick as x, onActivated as B, onDeactivated as H, onBeforeUnmount as M } from "vue";
2
+ import { overlayOwnerKey as A, registerOverlay as j, lockBodyScroll as N } from "./overlayManager.js";
3
3
  const U = 'a[href],button:not([disabled]),input:not([disabled]):not([type="hidden"]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])';
4
- function J(A, a, x, t = {}) {
5
- const m = O(!0), h = P(D, void 0), o = b(() => m.value && (h == null ? void 0 : h.value) !== !1), i = b(() => A.value && o.value);
4
+ function J(z, r, T, u = {}) {
5
+ const o = O(!0), h = P(A, void 0), s = b(() => o.value && (h == null ? void 0 : h.value) !== !1), i = b(() => z.value && s.value);
6
6
  R(
7
- D,
7
+ A,
8
8
  b(() => {
9
9
  var e;
10
- return i.value && ((e = t.childVisible) == null ? void 0 : e.call(t)) !== !1;
10
+ return i.value && ((e = u.childVisible) == null ? void 0 : e.call(u)) !== !1;
11
11
  })
12
12
  );
13
- const d = g(), z = b(
13
+ const d = g(), k = b(
14
14
  () => {
15
- var e, u;
16
- return ((e = d.value) == null ? void 0 : e.zIndex.value) ?? ((u = t.zIndex) == null ? void 0 : u.call(t)) ?? 100;
15
+ var e, t;
16
+ return ((e = d.value) == null ? void 0 : e.zIndex.value) ?? ((t = u.zIndex) == null ? void 0 : t.call(u)) ?? 100;
17
17
  }
18
18
  );
19
- let E = null, r, s = 0;
19
+ let E = null, a, m = 0;
20
20
  function S() {
21
21
  var e;
22
22
  return Array.from(
23
- ((e = a.value) == null ? void 0 : e.querySelectorAll(U)) ?? []
23
+ ((e = r.value) == null ? void 0 : e.querySelectorAll(U)) ?? []
24
24
  ).filter(
25
- (u) => u.tabIndex >= 0 && u.getClientRects().length > 0 && getComputedStyle(u).visibility !== "hidden" && !u.closest('[inert],[aria-hidden="true"]')
25
+ (t) => t.tabIndex >= 0 && t.getClientRects().length > 0 && getComputedStyle(t).visibility !== "hidden" && !t.closest('[inert],[aria-hidden="true"]')
26
26
  );
27
27
  }
28
- function T() {
28
+ function w() {
29
29
  var e;
30
- (e = S()[0] ?? a.value) == null || e.focus({ preventScroll: !0 });
30
+ (e = S()[0] ?? r.value) == null || e.focus({ preventScroll: !0 });
31
31
  }
32
- function k(e) {
32
+ function C(e) {
33
33
  var n, f;
34
- if (!i.value || !((n = d.value) != null && n.isTop()) || !a.value) return;
34
+ if (!i.value || !((n = d.value) != null && n.isTop()) || !r.value) return;
35
35
  if (e.key === "Escape") {
36
- e.preventDefault(), e.stopImmediatePropagation(), x();
36
+ e.preventDefault(), e.stopImmediatePropagation(), T();
37
37
  return;
38
38
  }
39
- if (e.key !== "Tab" || ((f = t.trapFocus) == null ? void 0 : f.call(t)) === !1) return;
40
- const u = S();
41
- if (!u.length) {
42
- e.preventDefault(), a.value.focus({ preventScroll: !0 });
39
+ if (e.key !== "Tab" || ((f = u.trapFocus) == null ? void 0 : f.call(u)) === !1) return;
40
+ const t = S();
41
+ if (!t.length) {
42
+ e.preventDefault(), r.value.focus({ preventScroll: !0 });
43
43
  return;
44
44
  }
45
- const l = u[0], c = u[u.length - 1];
46
- e.shiftKey && (document.activeElement === l || document.activeElement === a.value || !a.value.contains(document.activeElement)) ? (e.preventDefault(), c.focus({ preventScroll: !0 })) : !e.shiftKey && (document.activeElement === c || !a.value.contains(document.activeElement)) && (e.preventDefault(), l.focus({ preventScroll: !0 }));
45
+ const l = t[0], c = t[t.length - 1];
46
+ e.shiftKey && (document.activeElement === l || document.activeElement === r.value || !r.value.contains(document.activeElement)) ? (e.preventDefault(), c.focus({ preventScroll: !0 })) : !e.shiftKey && (document.activeElement === c || !r.value.contains(document.activeElement)) && (e.preventDefault(), l.focus({ preventScroll: !0 }));
47
47
  }
48
- function C(e) {
49
- var u, l, c;
50
- i.value && ((u = d.value) != null && u.isTop()) && ((l = t.trapFocus) == null ? void 0 : l.call(t)) !== !1 && e.target instanceof Node && !((c = a.value) != null && c.contains(e.target)) && T();
48
+ function F(e) {
49
+ var t, l, c;
50
+ i.value && ((t = d.value) != null && t.isTop()) && ((l = u.trapFocus) == null ? void 0 : l.call(u)) !== !1 && e.target instanceof Node && !((c = r.value) != null && c.contains(e.target)) && w();
51
51
  }
52
- function F() {
52
+ function I() {
53
53
  var e;
54
- i.value && ((e = t.lockScroll) == null ? void 0 : e.call(t)) !== !1 ? r ?? (r = N()) : (r == null || r(), r = void 0);
54
+ i.value && ((e = u.lockScroll) == null ? void 0 : e.call(u)) !== !1 ? a ?? (a = N()) : (a == null || a(), a = void 0);
55
55
  }
56
56
  function y() {
57
- var u, l;
58
- const e = ((u = d.value) == null ? void 0 : u.isTop()) ?? !1;
59
- return (l = d.value) == null || l.unregister(), d.value = void 0, r == null || r(), r = void 0, document.removeEventListener("keydown", k, !0), document.removeEventListener("focusin", C, !0), e;
57
+ var t, l;
58
+ const e = ((t = d.value) == null ? void 0 : t.isTop()) ?? !1;
59
+ return (l = d.value) == null || l.unregister(), d.value = void 0, a == null || a(), a = void 0, document.removeEventListener("keydown", C, !0), document.removeEventListener("focusin", F, !0), e;
60
60
  }
61
- function q(e, u, l) {
62
- w(() => {
61
+ function q(e, t, l) {
62
+ x(() => {
63
63
  var n, f;
64
- if (u !== s || !o.value || !l || ((n = t.restoreFocus) == null ? void 0 : n.call(t)) === !1)
64
+ if (t !== m || !s.value || !l || ((n = u.restoreFocus) == null ? void 0 : n.call(u)) === !1)
65
65
  return;
66
66
  const c = new Event("hys-ui-close-auto-focus", { cancelable: !0 });
67
- (f = t.onCloseAutoFocus) == null || f.call(t, c), !c.defaultPrevented && (e != null && e.isConnected) && e.focus({ preventScroll: !0 });
67
+ (f = u.onCloseAutoFocus) == null || f.call(u, c), !c.defaultPrevented && (e != null && e.isConnected) && e.focus({ preventScroll: !0 });
68
68
  });
69
69
  }
70
- return L(
70
+ return typeof document > "u" ? { active: s, zIndex: k, focus: w } : (D(
71
71
  i,
72
72
  async (e) => {
73
73
  var l, c, n, f;
74
- const u = ++s;
74
+ const t = ++m;
75
75
  if (e) {
76
- if (y(), E = document.activeElement instanceof HTMLElement ? document.activeElement : null, d.value = j("dialog", x, t.zIndex), F(), document.addEventListener("keydown", k, !0), document.addEventListener("focusin", C, !0), await w(), u !== s || !i.value) return;
77
- const I = new Event("hys-ui-open-auto-focus", { cancelable: !0 });
78
- (l = t.onOpenAutoFocus) == null || l.call(t, I);
79
- const v = (c = t.initialFocus) == null ? void 0 : c.call(t), K = v instanceof HTMLElement && v.isConnected && v.getClientRects().length > 0 && getComputedStyle(v).visibility !== "hidden" && !v.closest('[inert],[aria-hidden="true"]') && !v.disabled ? v : void 0;
80
- !I.defaultPrevented && v !== !1 && ((f = K ?? ((n = a.value) == null ? void 0 : n.querySelector("[autofocus]")) ?? S()[0] ?? a.value) == null || f.focus({ preventScroll: !0 }));
81
- } else q(E, u, y());
76
+ if (y(), E = document.activeElement instanceof HTMLElement ? document.activeElement : null, d.value = j("dialog", T, u.zIndex), I(), document.addEventListener("keydown", C, !0), document.addEventListener("focusin", F, !0), await x(), t !== m || !i.value) return;
77
+ const L = new Event("hys-ui-open-auto-focus", { cancelable: !0 });
78
+ (l = u.onOpenAutoFocus) == null || l.call(u, L);
79
+ const v = (c = u.initialFocus) == null ? void 0 : c.call(u), K = v instanceof HTMLElement && v.isConnected && v.getClientRects().length > 0 && getComputedStyle(v).visibility !== "hidden" && !v.closest('[inert],[aria-hidden="true"]') && !v.disabled ? v : void 0;
80
+ !L.defaultPrevented && v !== !1 && ((f = K ?? ((n = r.value) == null ? void 0 : n.querySelector("[autofocus]")) ?? S()[0] ?? r.value) == null || f.focus({ preventScroll: !0 }));
81
+ } else q(E, t, y());
82
82
  },
83
83
  { immediate: !0, flush: "post" }
84
- ), L(() => {
84
+ ), D(() => {
85
85
  var e;
86
- return (e = t.lockScroll) == null ? void 0 : e.call(t);
87
- }, F), B(() => m.value = !0), H(() => {
88
- m.value = !1, s++, y();
86
+ return (e = u.lockScroll) == null ? void 0 : e.call(u);
87
+ }, I), B(() => o.value = !0), H(() => {
88
+ o.value = !1, m++, y();
89
89
  }), M(() => {
90
90
  var c;
91
- const e = E, u = y(), l = o.value && ((c = t.restoreFocus) == null ? void 0 : c.call(t)) !== !1;
92
- m.value = !1, s++, l && u && w(() => {
91
+ const e = E, t = y(), l = s.value && ((c = u.restoreFocus) == null ? void 0 : c.call(u)) !== !1;
92
+ o.value = !1, m++, l && t && x(() => {
93
93
  e != null && e.isConnected && e.focus({ preventScroll: !0 });
94
94
  });
95
- }), { active: o, zIndex: z, focus: T };
95
+ }), { active: s, zIndex: k, focus: w });
96
96
  }
97
97
  export {
98
98
  J as useDialog