@apo100l/ace-ui-kit 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,68 +1,68 @@
1
- let T = !1;
2
- function P(e) {
1
+ let M = !1;
2
+ function K(e) {
3
3
  e.open || (e.showModal(), document.documentElement.classList.add("ak-dialog-open"));
4
4
  }
5
5
  function D(e, t) {
6
6
  e.open && e.close(t);
7
7
  }
8
- function U() {
8
+ function X() {
9
9
  const e = document.querySelector("dialog.ak-dialog[open]");
10
10
  document.documentElement.classList.toggle("ak-dialog-open", !!e);
11
11
  }
12
- function V() {
13
- T || (T = !0, document.addEventListener("click", (e) => {
12
+ function Y() {
13
+ M || (M = !0, document.addEventListener("click", (e) => {
14
14
  const t = e.target instanceof Element ? e.target : null;
15
15
  if (!t) return;
16
16
  const n = t.closest("[data-ak-dialog-open]");
17
17
  if (n) {
18
- const i = document.getElementById(n.dataset.akDialogOpen ?? "");
19
- i instanceof HTMLDialogElement && (e.preventDefault(), P(i));
18
+ const a = document.getElementById(n.dataset.akDialogOpen ?? "");
19
+ a instanceof HTMLDialogElement && (e.preventDefault(), K(a));
20
20
  return;
21
21
  }
22
22
  const o = t.closest("[data-ak-dialog-close]");
23
23
  if (o) {
24
- const i = o.closest("dialog");
25
- i && D(i, o.dataset.akDialogClose || void 0);
24
+ const a = o.closest("dialog");
25
+ a && D(a, o.dataset.akDialogClose || void 0);
26
26
  return;
27
27
  }
28
28
  if (t instanceof HTMLDialogElement && t.open && t.classList.contains("ak-dialog") && !t.hasAttribute("data-ak-static")) {
29
- const i = t.getBoundingClientRect(), { clientX: a, clientY: s } = e;
30
- (a < i.left || a > i.right || s < i.top || s > i.bottom) && D(t, "cancel");
29
+ const a = t.getBoundingClientRect(), { clientX: i, clientY: s } = e;
30
+ (i < a.left || i > a.right || s < a.top || s > a.bottom) && D(t, "cancel");
31
31
  }
32
- }), document.addEventListener("close", U, !0));
32
+ }), document.addEventListener("close", X, !0));
33
33
  }
34
- const $ = "akBound";
35
- function j(e = document) {
34
+ const C = "akBound";
35
+ function G(e = document) {
36
36
  e.querySelectorAll("[data-ak-dismiss]").forEach((t) => {
37
- t.dataset[$] || (t.dataset[$] = "1", t.addEventListener("click", () => {
37
+ t.dataset[C] || (t.dataset[C] = "1", t.addEventListener("click", () => {
38
38
  t.closest("[data-ak-dismissible], .ak-alert")?.remove();
39
39
  }));
40
40
  });
41
41
  }
42
- let C = !1;
43
- const X = (e) => e < 1024 ? `${e} Б` : e < 1048576 ? `${(e / 1024).toFixed(0)} КБ` : `${(e / 1048576).toFixed(1).replace(".", ",")} МБ`;
44
- function Y(e, t) {
42
+ let q = !1;
43
+ const J = (e) => e < 1024 ? `${e} Б` : e < 1048576 ? `${(e / 1024).toFixed(0)} КБ` : `${(e / 1048576).toFixed(1).replace(".", ",")} МБ`;
44
+ function Q(e, t) {
45
45
  const n = e.querySelector(".ak-file__list");
46
46
  if (!n) return;
47
47
  const o = Number(t.dataset.maxSize) || 1 / 0;
48
48
  n.replaceChildren(
49
- ...[...t.files ?? []].map((a) => {
49
+ ...[...t.files ?? []].map((i) => {
50
50
  const s = document.createElement("span");
51
51
  s.className = "ak-file__item";
52
- const l = a.size > o;
53
- return s.toggleAttribute("data-invalid", l), s.textContent = `${a.name} · ${X(a.size)}${l ? " — больше допустимого" : ""}`, s;
52
+ const l = i.size > o;
53
+ return s.toggleAttribute("data-invalid", l), s.textContent = `${i.name} · ${J(i.size)}${l ? " — больше допустимого" : ""}`, s;
54
54
  })
55
55
  );
56
- const i = [...t.files ?? []].some((a) => a.size > o);
57
- t.setCustomValidity(i ? "Файл больше допустимого размера" : ""), e.toggleAttribute("data-has-files", !!t.files?.length);
56
+ const a = [...t.files ?? []].some((i) => i.size > o);
57
+ t.setCustomValidity(a ? "Файл больше допустимого размера" : ""), e.toggleAttribute("data-has-files", !!t.files?.length);
58
58
  }
59
- function G() {
60
- if (C) return;
61
- C = !0, document.addEventListener("change", (t) => {
59
+ function Z() {
60
+ if (q) return;
61
+ q = !0, document.addEventListener("change", (t) => {
62
62
  const n = t.target;
63
63
  if (!(n instanceof HTMLInputElement) || n.type !== "file") return;
64
64
  const o = n.closest(".ak-file");
65
- o && Y(o, n);
65
+ o && Q(o, n);
66
66
  });
67
67
  const e = (t) => t.target?.closest?.(".ak-file") ?? null;
68
68
  document.addEventListener("dragover", (t) => {
@@ -75,32 +75,32 @@ function G() {
75
75
  const n = e(t);
76
76
  if (!n) return;
77
77
  t.preventDefault(), n.removeAttribute("data-dragover");
78
- const o = n.querySelector('input[type="file"]'), i = t.dataTransfer?.files;
79
- if (!o || !i?.length || o.disabled) return;
80
- const a = new DataTransfer();
81
- [...i].slice(0, o.multiple ? void 0 : 1).forEach((s) => a.items.add(s)), o.files = a.files, o.dispatchEvent(new Event("change", { bubbles: !0 }));
78
+ const o = n.querySelector('input[type="file"]'), a = t.dataTransfer?.files;
79
+ if (!o || !a?.length || o.disabled) return;
80
+ const i = new DataTransfer();
81
+ [...a].slice(0, o.multiple ? void 0 : 1).forEach((s) => i.items.add(s)), o.files = i.files, o.dispatchEvent(new Event("change", { bubbles: !0 }));
82
82
  });
83
83
  }
84
- let q = !1;
85
- const v = '.ak-menu__item:not(:disabled):not([aria-disabled="true"])', K = typeof CSS < "u" && CSS.supports?.("position-area", "block-end");
86
- function J(e) {
84
+ let N = !1;
85
+ const v = '.ak-menu__item:not(:disabled):not([aria-disabled="true"])', tt = typeof CSS < "u" && CSS.supports?.("position-area", "block-end");
86
+ function et(e) {
87
87
  return e.id ? document.querySelector(`[popovertarget="${CSS.escape(e.id)}"]`) : null;
88
88
  }
89
- function Q(e, t) {
89
+ function nt(e, t) {
90
90
  const n = t.getBoundingClientRect(), o = e.getBoundingClientRect();
91
- let a = e.classList.contains("ak-menu--end") ? n.right - o.width : n.left;
92
- a = Math.max(8, Math.min(a, window.innerWidth - o.width - 8));
91
+ let i = e.classList.contains("ak-menu--end") ? n.right - o.width : n.left;
92
+ i = Math.max(8, Math.min(i, window.innerWidth - o.width - 8));
93
93
  let s = n.bottom + 4;
94
- s + o.height > window.innerHeight - 8 && n.top - o.height - 4 > 8 && (s = n.top - o.height - 4), e.style.position = "fixed", e.style.left = `${Math.round(a)}px`, e.style.top = `${Math.round(s)}px`, e.style.margin = "0";
94
+ s + o.height > window.innerHeight - 8 && n.top - o.height - 4 > 8 && (s = n.top - o.height - 4), e.style.position = "fixed", e.style.left = `${Math.round(i)}px`, e.style.top = `${Math.round(s)}px`, e.style.margin = "0";
95
95
  }
96
- function Z() {
97
- q || (q = !0, document.addEventListener(
96
+ function ot() {
97
+ N || (N = !0, document.addEventListener(
98
98
  "toggle",
99
99
  (e) => {
100
100
  const t = e.target;
101
101
  if (!(t instanceof HTMLElement) || !t.classList.contains("ak-menu")) return;
102
- const n = e.newState === "open", o = J(t);
103
- o?.setAttribute("aria-expanded", String(n)), n && (o && !K && Q(t, o), t.querySelector(v)?.focus());
102
+ const n = e.newState === "open", o = et(t);
103
+ o?.setAttribute("aria-expanded", String(n)), n && (o && !tt && nt(t, o), t.querySelector(v)?.focus());
104
104
  },
105
105
  !0
106
106
  ), document.addEventListener("keydown", (e) => {
@@ -109,18 +109,54 @@ function Z() {
109
109
  const n = [...t.querySelectorAll(v)];
110
110
  if (!n.length) return;
111
111
  const o = n.indexOf(document.activeElement);
112
- let i = -1;
113
- e.key === "ArrowDown" ? i = (o + 1) % n.length : e.key === "ArrowUp" ? i = (o - 1 + n.length) % n.length : e.key === "Home" ? i = 0 : e.key === "End" ? i = n.length - 1 : e.key === "Tab" && t.hidePopover(), i >= 0 && (e.preventDefault(), n[i].focus());
112
+ let a = -1;
113
+ e.key === "ArrowDown" ? a = (o + 1) % n.length : e.key === "ArrowUp" ? a = (o - 1 + n.length) % n.length : e.key === "Home" ? a = 0 : e.key === "End" ? a = n.length - 1 : e.key === "Tab" && t.hidePopover(), a >= 0 && (e.preventDefault(), n[a].focus());
114
114
  }), document.addEventListener("click", (e) => {
115
115
  e.target?.closest?.(v)?.closest(".ak-menu:popover-open")?.hidePopover();
116
116
  }));
117
117
  }
118
- let M = !1;
118
+ const A = "ak-mode";
119
+ let _ = !1;
120
+ function at(e) {
121
+ const t = document.cookie.match(new RegExp(`(?:^|; )${e.replace(/[.$?*|{}()[\]\\/+^]/g, "\\$&")}=([^;]*)`));
122
+ return t ? decodeURIComponent(t[1]) : null;
123
+ }
124
+ function P() {
125
+ const e = document.documentElement;
126
+ return e.dataset.akMode === "dark" || e.dataset.akTheme === "dark" ? "dark" : "light";
127
+ }
128
+ function it(e, t = A) {
129
+ const n = document.documentElement;
130
+ e === "dark" ? n.dataset.akMode = "dark" : delete n.dataset.akMode, n.dataset.akTheme === "dark" && delete n.dataset.akTheme;
131
+ const o = location.protocol === "https:" ? "; Secure" : "";
132
+ document.cookie = `${t}=${e}; path=/; max-age=31536000; SameSite=Lax${o}`, L(), n.dispatchEvent(new CustomEvent("ak:mode-change", { bubbles: !0, detail: { mode: e } }));
133
+ }
134
+ function L() {
135
+ const e = P() === "dark";
136
+ document.querySelectorAll("[data-ak-mode-toggle]").forEach((t) => {
137
+ t.setAttribute("aria-pressed", String(e));
138
+ const n = e ? t.dataset.akLabelLight : t.dataset.akLabelDark;
139
+ n && (t.setAttribute("aria-label", n), t.hasAttribute("title") && (t.title = n));
140
+ });
141
+ }
142
+ function st() {
143
+ if (_) {
144
+ L();
145
+ return;
146
+ }
147
+ _ = !0;
148
+ const t = document.querySelector("[data-ak-mode-toggle]")?.dataset.akModeToggle || A, n = document.documentElement;
149
+ !n.dataset.akMode && at(t) === "dark" && (n.dataset.akMode = "dark"), L(), document.addEventListener("click", (o) => {
150
+ const a = o.target?.closest?.("[data-ak-mode-toggle]");
151
+ a && (o.preventDefault(), it(P() === "dark" ? "light" : "dark", a.dataset.akModeToggle || A));
152
+ });
153
+ }
154
+ let I = !1;
119
155
  function y(e, t) {
120
156
  e.toggleAttribute("data-sidebar-open", t), e.querySelectorAll("[data-ak-sidebar-toggle]").forEach((n) => n.setAttribute("aria-expanded", String(t)));
121
157
  }
122
- function tt() {
123
- M || (M = !0, document.addEventListener("click", (e) => {
158
+ function rt() {
159
+ I || (I = !0, document.addEventListener("click", (e) => {
124
160
  const t = e.target instanceof Element ? e.target : null, n = t?.closest("[data-ak-sidebar-toggle]"), o = t?.closest(".ak-app");
125
161
  if (o) {
126
162
  if (n) {
@@ -135,186 +171,188 @@ function tt() {
135
171
  t && (y(t, !1), t.querySelector("[data-ak-sidebar-toggle]")?.focus());
136
172
  }));
137
173
  }
138
- let N = !1;
174
+ let B = !1;
139
175
  const f = (e, t) => {
140
176
  const n = Number(e);
141
177
  return e !== "" && Number.isFinite(n) ? n : t;
142
178
  };
143
- function _(e) {
179
+ function O(e) {
144
180
  const t = e.querySelector("input");
145
181
  if (!t) return;
146
182
  const n = f(t.value, 0);
147
183
  e.querySelectorAll("[data-ak-step]").forEach((o) => {
148
- const i = Number(o.dataset.akStep);
149
- o.disabled = t.disabled || (i < 0 ? n <= f(t.min, -1 / 0) : n >= f(t.max, 1 / 0));
184
+ const a = Number(o.dataset.akStep);
185
+ o.disabled = t.disabled || (a < 0 ? n <= f(t.min, -1 / 0) : n >= f(t.max, 1 / 0));
150
186
  });
151
187
  }
152
- function et(e, t) {
153
- const n = f(e.step, 1) || 1, o = Math.min(f(e.max, 1 / 0), Math.max(f(e.min, -1 / 0), f(e.value, 0) + t * n)), i = (String(n).split(".")[1] ?? "").length;
154
- e.value = o.toFixed(i), e.dispatchEvent(new Event("input", { bubbles: !0 })), e.dispatchEvent(new Event("change", { bubbles: !0 }));
188
+ function lt(e, t) {
189
+ const n = f(e.step, 1) || 1, o = Math.min(f(e.max, 1 / 0), Math.max(f(e.min, -1 / 0), f(e.value, 0) + t * n)), a = (String(n).split(".")[1] ?? "").length;
190
+ e.value = o.toFixed(a), e.dispatchEvent(new Event("input", { bubbles: !0 })), e.dispatchEvent(new Event("change", { bubbles: !0 }));
155
191
  }
156
- function nt(e = document) {
157
- e.querySelectorAll(".ak-stepper").forEach(_), !N && (N = !0, document.addEventListener("click", (t) => {
158
- const n = t.target?.closest?.(".ak-stepper [data-ak-step]"), o = n?.closest(".ak-stepper"), i = o?.querySelector("input");
159
- !n || !o || !i || (t.preventDefault(), et(i, Number(n.dataset.akStep) || 1));
192
+ function ct(e = document) {
193
+ e.querySelectorAll(".ak-stepper").forEach(O), !B && (B = !0, document.addEventListener("click", (t) => {
194
+ const n = t.target?.closest?.(".ak-stepper [data-ak-step]"), o = n?.closest(".ak-stepper"), a = o?.querySelector("input");
195
+ !n || !o || !a || (t.preventDefault(), lt(a, Number(n.dataset.akStep) || 1));
160
196
  }), document.addEventListener("input", (t) => {
161
197
  const n = t.target?.closest?.(".ak-stepper");
162
- n && _(n);
198
+ n && O(n);
163
199
  }));
164
200
  }
165
- let B = !1;
166
- function A(e) {
201
+ let H = !1;
202
+ function w(e) {
167
203
  return [...e.querySelectorAll(':scope > [role="tab"]')];
168
204
  }
169
- function I(e, t = !1) {
205
+ function F(e, t = !1) {
170
206
  const n = e.closest('[role="tablist"]');
171
207
  if (!(!n || e.getAttribute("aria-disabled") === "true")) {
172
- for (const o of A(n)) {
173
- const i = o === e;
174
- o.setAttribute("aria-selected", String(i)), o.tabIndex = i ? 0 : -1;
175
- const a = document.getElementById(o.getAttribute("aria-controls") ?? "");
176
- a && (a.hidden = !i, a.hasAttribute("tabindex") || (a.tabIndex = 0));
208
+ for (const o of w(n)) {
209
+ const a = o === e;
210
+ o.setAttribute("aria-selected", String(a)), o.tabIndex = a ? 0 : -1;
211
+ const i = document.getElementById(o.getAttribute("aria-controls") ?? "");
212
+ i && (i.hidden = !a, i.hasAttribute("tabindex") || (i.tabIndex = 0));
177
213
  }
178
214
  t && e.focus(), n.dispatchEvent(new CustomEvent("ak:tab-change", { bubbles: !0, detail: { tab: e } }));
179
215
  }
180
216
  }
181
- function ot(e = document) {
217
+ function dt(e = document) {
182
218
  e.querySelectorAll('[role="tablist"]').forEach((t) => {
183
- const n = A(t), o = n.find((i) => i.getAttribute("aria-selected") === "true") ?? n[0];
184
- n.forEach((i) => i.tabIndex = i === o ? 0 : -1);
185
- }), !B && (B = !0, document.addEventListener("click", (t) => {
219
+ const n = w(t), o = n.find((a) => a.getAttribute("aria-selected") === "true") ?? n[0];
220
+ n.forEach((a) => a.tabIndex = a === o ? 0 : -1);
221
+ }), !H && (H = !0, document.addEventListener("click", (t) => {
186
222
  const n = t.target?.closest?.('[role="tablist"] > [role="tab"]');
187
- n && I(n);
223
+ n && F(n);
188
224
  }), document.addEventListener("keydown", (t) => {
189
225
  const n = t.target?.closest?.('[role="tablist"] > [role="tab"]');
190
226
  if (!n) return;
191
- const o = A(n.parentElement).filter((s) => s.getAttribute("aria-disabled") !== "true"), i = o.indexOf(n);
192
- let a;
193
- t.key === "ArrowRight" ? a = o[(i + 1) % o.length] : t.key === "ArrowLeft" ? a = o[(i - 1 + o.length) % o.length] : t.key === "Home" ? a = o[0] : t.key === "End" && (a = o[o.length - 1]), a && (t.preventDefault(), I(a, !0));
227
+ const o = w(n.parentElement).filter((s) => s.getAttribute("aria-disabled") !== "true"), a = o.indexOf(n);
228
+ let i;
229
+ t.key === "ArrowRight" ? i = o[(a + 1) % o.length] : t.key === "ArrowLeft" ? i = o[(a - 1 + o.length) % o.length] : t.key === "Home" ? i = o[0] : t.key === "End" && (i = o[o.length - 1]), i && (t.preventDefault(), F(i, !0));
194
230
  }));
195
231
  }
196
- const it = 4;
232
+ const ut = 4;
197
233
  let u = null;
198
- function at() {
234
+ function ft() {
199
235
  return u?.isConnected || (u = document.createElement("section"), u.className = "ak-toaster", u.setAttribute("aria-label", "Уведомления"), document.body.append(u)), u;
200
236
  }
201
- function st(e, { tone: t = "neutral", duration: n, action: o } = {}) {
202
- const i = at(), a = document.createElement("div");
203
- a.className = `ak-toast ak-toast--${t}`, a.setAttribute("role", t === "negative" ? "alert" : "status"), a.setAttribute("aria-live", t === "negative" ? "assertive" : "polite");
237
+ function mt(e, { tone: t = "neutral", duration: n, action: o } = {}) {
238
+ const a = ft(), i = document.createElement("div");
239
+ i.className = `ak-toast ak-toast--${t}`, i.setAttribute("role", t === "negative" ? "alert" : "status"), i.setAttribute("aria-live", t === "negative" ? "assertive" : "polite");
204
240
  const s = document.createElement("p");
205
- if (s.className = "ak-toast__text", s.textContent = e, a.append(s), o) {
241
+ if (s.className = "ak-toast__text", s.textContent = e, i.append(s), o) {
206
242
  const d = document.createElement("button");
207
243
  d.type = "button", d.className = "ak-toast__action", d.textContent = o.label, d.addEventListener("click", () => {
208
- o.onClick(), b();
209
- }), a.append(d);
244
+ o.onClick(), g();
245
+ }), i.append(d);
210
246
  }
211
247
  const l = document.createElement("button");
212
- l.type = "button", l.className = "ak-toast__close", l.setAttribute("aria-label", "Закрыть"), l.textContent = "×", l.addEventListener("click", () => b()), a.append(l), i.append(a);
213
- const w = i.querySelectorAll(".ak-toast:not([data-leaving])");
214
- w.length > it && w[0]._close?.(), requestAnimationFrame(() => requestAnimationFrame(() => a.setAttribute("data-shown", "")));
215
- const L = n ?? (t === "negative" ? 0 : 5e3);
216
- let E = L, S = 0, p = 0;
217
- const g = () => {
218
- p && (clearTimeout(p), p = 0, E -= Date.now() - S);
219
- }, h = () => {
220
- !L || p || E <= 0 || document.hidden || (S = Date.now(), p = window.setTimeout(b, E));
221
- }, x = () => document.hidden ? g() : h();
222
- a.addEventListener("mouseenter", g), a.addEventListener("mouseleave", h), a.addEventListener("focusin", g), a.addEventListener("focusout", h), document.addEventListener("visibilitychange", x), h();
223
- function b() {
224
- if (a.hasAttribute("data-leaving")) return;
225
- g(), document.removeEventListener("visibilitychange", x), a.setAttribute("data-leaving", ""), a.removeAttribute("data-shown");
226
- const d = () => a.remove();
227
- a.addEventListener("transitionend", d, { once: !0 }), window.setTimeout(d, 400);
248
+ l.type = "button", l.className = "ak-toast__close", l.setAttribute("aria-label", "Закрыть"), l.textContent = "×", l.addEventListener("click", () => g()), i.append(l), a.append(i);
249
+ const S = a.querySelectorAll(".ak-toast:not([data-leaving])");
250
+ S.length > ut && S[0]._close?.(), requestAnimationFrame(() => requestAnimationFrame(() => i.setAttribute("data-shown", "")));
251
+ const x = n ?? (t === "negative" ? 0 : 5e3);
252
+ let E = x, T = 0, p = 0;
253
+ const b = () => {
254
+ p && (clearTimeout(p), p = 0, E -= Date.now() - T);
255
+ }, k = () => {
256
+ !x || p || E <= 0 || document.hidden || (T = Date.now(), p = window.setTimeout(g, E));
257
+ }, $ = () => document.hidden ? b() : k();
258
+ i.addEventListener("mouseenter", b), i.addEventListener("mouseleave", k), i.addEventListener("focusin", b), i.addEventListener("focusout", k), document.addEventListener("visibilitychange", $), k();
259
+ function g() {
260
+ if (i.hasAttribute("data-leaving")) return;
261
+ b(), document.removeEventListener("visibilitychange", $), i.setAttribute("data-leaving", ""), i.removeAttribute("data-shown");
262
+ const d = () => i.remove();
263
+ i.addEventListener("transitionend", d, { once: !0 }), window.setTimeout(d, 400);
228
264
  }
229
- return a._close = b, { close: b };
265
+ return i._close = g, { close: g };
230
266
  }
231
- function rt(e = document) {
267
+ function pt(e = document) {
232
268
  e.querySelectorAll("[data-ak-toast]:not([data-ak-bound])").forEach((t) => {
233
269
  t.setAttribute("data-ak-bound", "");
234
270
  const n = (t instanceof HTMLTemplateElement ? t.content.textContent : t.textContent)?.trim();
235
271
  if (!n) return;
236
- const o = t.dataset.akToast || "neutral", i = t.dataset.akDuration ? Number(t.dataset.akDuration) : void 0;
237
- st(n, { tone: o, duration: i }), t instanceof HTMLTemplateElement || (t.hidden = !0);
272
+ const o = t.dataset.akToast || "neutral", a = t.dataset.akDuration ? Number(t.dataset.akDuration) : void 0;
273
+ mt(n, { tone: o, duration: a }), t instanceof HTMLTemplateElement || (t.hidden = !0);
238
274
  });
239
275
  }
240
- const lt = 500, ct = 400;
241
- let H = !1, c = null, r = null, k = 0, R = 0;
242
- function dt() {
276
+ const gt = 500, bt = 400;
277
+ let R = !1, c = null, r = null, h = 0, V = 0;
278
+ function kt() {
243
279
  return c?.isConnected || (c = document.createElement("div"), c.className = "ak-tooltip", c.id = "ak-tooltip", c.setAttribute("role", "tooltip"), document.body.append(c)), c;
244
280
  }
245
- function ut(e) {
281
+ function ht(e) {
246
282
  return (e.dataset.akTooltip || e.getAttribute("aria-label") || e.getAttribute("title") || "").trim();
247
283
  }
248
- function ft(e, t) {
284
+ function Et(e, t) {
249
285
  const n = e.getBoundingClientRect(), o = t.getBoundingClientRect();
250
- let i = n.top - o.height - 6, a = "top";
251
- i < 8 && (i = n.bottom + 6, a = "bottom");
286
+ let a = n.top - o.height - 6, i = "top";
287
+ a < 8 && (a = n.bottom + 6, i = "bottom");
252
288
  const s = Math.max(8, Math.min(n.left + n.width / 2 - o.width / 2, window.innerWidth - o.width - 8));
253
- t.style.top = `${Math.round(i)}px`, t.style.left = `${Math.round(s)}px`, t.dataset.side = a;
289
+ t.style.top = `${Math.round(a)}px`, t.style.left = `${Math.round(s)}px`, t.dataset.side = i;
254
290
  }
255
- function O(e, t) {
256
- const n = ut(e);
291
+ function z(e, t) {
292
+ const n = ht(e);
257
293
  if (!n) return;
258
- const o = dt();
259
- r = e, o.textContent = n, o.toggleAttribute("data-instant", t), o.setAttribute("data-open", ""), ft(e, o);
260
- const i = e.getAttribute("aria-describedby") ?? "";
261
- i.split(" ").includes(o.id) || e.setAttribute("aria-describedby", `${i} ${o.id}`.trim());
294
+ const o = kt();
295
+ r = e, o.textContent = n, o.toggleAttribute("data-instant", t), o.setAttribute("data-open", ""), Et(e, o);
296
+ const a = e.getAttribute("aria-describedby") ?? "";
297
+ a.split(" ").includes(o.id) || e.setAttribute("aria-describedby", `${a} ${o.id}`.trim());
262
298
  }
263
299
  function m() {
264
- if (clearTimeout(k), k = 0, !r) return;
300
+ if (clearTimeout(h), h = 0, !r) return;
265
301
  const e = (r.getAttribute("aria-describedby") ?? "").split(" ").filter((t) => t && t !== "ak-tooltip");
266
- e.length ? r.setAttribute("aria-describedby", e.join(" ")) : r.removeAttribute("aria-describedby"), r = null, c?.removeAttribute("data-open"), R = Date.now();
302
+ e.length ? r.setAttribute("aria-describedby", e.join(" ")) : r.removeAttribute("aria-describedby"), r = null, c?.removeAttribute("data-open"), V = Date.now();
267
303
  }
268
- function z(e, t) {
304
+ function U(e, t) {
269
305
  if (r === e) return;
270
- clearTimeout(k);
271
- const n = !!r || Date.now() - R < ct;
272
- r && m(), t || n ? O(e, n) : k = window.setTimeout(() => O(e, !1), lt);
306
+ clearTimeout(h);
307
+ const n = !!r || Date.now() - V < bt;
308
+ r && m(), t || n ? z(e, n) : h = window.setTimeout(() => z(e, !1), gt);
273
309
  }
274
- function mt() {
275
- if (H) return;
276
- H = !0;
310
+ function vt() {
311
+ if (R) return;
312
+ R = !0;
277
313
  const e = (t) => t.target?.closest?.("[data-ak-tooltip]") ?? null;
278
314
  document.addEventListener("pointerover", (t) => {
279
315
  if (t.pointerType === "touch") return;
280
316
  const n = e(t);
281
- n && z(n, !1);
317
+ n && U(n, !1);
282
318
  }), document.addEventListener("pointerout", (t) => {
283
319
  const n = e(t);
284
320
  n && !n.contains(t.relatedTarget) && m();
285
321
  }), document.addEventListener("focusin", (t) => {
286
322
  const n = e(t);
287
- n && n.matches(":focus-visible") && z(n, !0);
323
+ n && n.matches(":focus-visible") && U(n, !0);
288
324
  }), document.addEventListener("focusout", (t) => {
289
325
  e(t) && m();
290
326
  }), document.addEventListener("keydown", (t) => {
291
327
  t.key === "Escape" && r && m();
292
328
  }), window.addEventListener("scroll", m, { passive: !0, capture: !0 }), document.addEventListener("pointerdown", m);
293
329
  }
294
- function pt({ root: e = document } = {}) {
295
- V(), Z(), tt(), mt(), G(), ot(e), nt(e), j(e), rt(e);
330
+ function yt({ root: e = document } = {}) {
331
+ Y(), ot(), rt(), vt(), st(), Z(), dt(e), ct(e), G(e), pt(e);
296
332
  }
297
- const F = "http://www.w3.org/2000/svg";
298
- let W = "";
299
- function bt(e) {
300
- W = e;
333
+ const W = "http://www.w3.org/2000/svg";
334
+ let j = "";
335
+ function At(e) {
336
+ j = e;
301
337
  }
302
- function gt(e, { size: t, label: n, className: o } = {}) {
303
- const i = document.createElementNS(F, "svg");
304
- i.setAttribute("class", ["ak-icon", t && `ak-icon--${t}`, o].filter(Boolean).join(" ")), n ? (i.setAttribute("role", "img"), i.setAttribute("aria-label", n)) : i.setAttribute("aria-hidden", "true"), i.setAttribute("focusable", "false");
305
- const a = document.createElementNS(F, "use");
306
- return a.setAttribute("href", `${W}#${e}`), i.append(a), i;
338
+ function Lt(e, { size: t, label: n, className: o } = {}) {
339
+ const a = document.createElementNS(W, "svg");
340
+ a.setAttribute("class", ["ak-icon", t && `ak-icon--${t}`, o].filter(Boolean).join(" ")), n ? (a.setAttribute("role", "img"), a.setAttribute("aria-label", n)) : a.setAttribute("aria-hidden", "true"), a.setAttribute("focusable", "false");
341
+ const i = document.createElementNS(W, "use");
342
+ return i.setAttribute("href", `${j}#${e}`), a.append(i), a;
307
343
  }
308
344
  export {
309
345
  D as closeDialog,
310
- j as dismissible,
311
- gt as icon,
312
- pt as init,
313
- P as openDialog,
314
- I as selectTab,
315
- bt as setIconSprite,
316
- et as stepBy,
317
- st as toast,
318
- rt as toastsFromDom
346
+ G as dismissible,
347
+ P as getMode,
348
+ Lt as icon,
349
+ yt as init,
350
+ K as openDialog,
351
+ F as selectTab,
352
+ At as setIconSprite,
353
+ it as setMode,
354
+ lt as stepBy,
355
+ mt as toast,
356
+ pt as toastsFromDom
319
357
  };
320
358
  //# sourceMappingURL=ace-ui-kit.js.map