@apo100l/ace-ui-kit 0.2.1 → 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.
- package/README.md +21 -2
- package/dist/ace-compat.css +1 -1
- package/dist/ace-compat.js +1 -1
- package/dist/ace-compat.js.map +1 -1
- package/dist/ace-ui-kit.css +1 -1
- package/dist/ace-ui-kit.js +186 -148
- package/dist/ace-ui-kit.js.map +1 -1
- package/dist/icons.svg +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/js/init.d.ts +2 -2
- package/dist/js/mode.d.ts +6 -0
- package/package.json +1 -1
- package/src/icons/icons.json +10 -0
- package/src/scss/_tokens.scss +83 -13
- package/src/scss/compat/_layout.scss +60 -26
- package/src/scss/compat/_plugins.scss +44 -0
- package/src/scss/compat/_theme-ace.scss +77 -0
- package/src/scss/compat/index.scss +1 -0
- package/src/scss/components/_auth.scss +199 -0
- package/src/scss/components/_icon.scss +7 -0
- package/src/scss/components/_shell.scss +32 -15
- package/src/scss/index.scss +1 -0
- package/src/scss/mixins/_card.scss +1 -0
- package/src/scss/mixins/_table.scss +1 -1
package/dist/ace-ui-kit.js
CHANGED
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
let
|
|
2
|
-
function
|
|
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
|
|
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
|
|
13
|
-
|
|
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
|
|
19
|
-
|
|
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
|
|
25
|
-
|
|
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
|
|
30
|
-
(
|
|
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",
|
|
32
|
+
}), document.addEventListener("close", X, !0));
|
|
33
33
|
}
|
|
34
|
-
const
|
|
35
|
-
function
|
|
34
|
+
const C = "akBound";
|
|
35
|
+
function G(e = document) {
|
|
36
36
|
e.querySelectorAll("[data-ak-dismiss]").forEach((t) => {
|
|
37
|
-
t.dataset[
|
|
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
|
|
43
|
-
const
|
|
44
|
-
function
|
|
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((
|
|
49
|
+
...[...t.files ?? []].map((i) => {
|
|
50
50
|
const s = document.createElement("span");
|
|
51
51
|
s.className = "ak-file__item";
|
|
52
|
-
const l =
|
|
53
|
-
return s.toggleAttribute("data-invalid", l), s.textContent = `${
|
|
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
|
|
57
|
-
t.setCustomValidity(
|
|
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
|
|
60
|
-
if (
|
|
61
|
-
|
|
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 &&
|
|
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"]'),
|
|
79
|
-
if (!o || !
|
|
80
|
-
const
|
|
81
|
-
[...
|
|
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
|
|
85
|
-
const v = '.ak-menu__item:not(:disabled):not([aria-disabled="true"])',
|
|
86
|
-
function
|
|
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
|
|
89
|
+
function nt(e, t) {
|
|
90
90
|
const n = t.getBoundingClientRect(), o = e.getBoundingClientRect();
|
|
91
|
-
let
|
|
92
|
-
|
|
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(
|
|
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
|
|
97
|
-
|
|
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 =
|
|
103
|
-
o?.setAttribute("aria-expanded", String(n)), n && (o && !
|
|
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
|
|
113
|
-
e.key === "ArrowDown" ?
|
|
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
|
-
|
|
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
|
|
123
|
-
|
|
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
|
|
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
|
|
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
|
|
149
|
-
o.disabled = t.disabled || (
|
|
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
|
|
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)),
|
|
154
|
-
e.value = o.toFixed(
|
|
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
|
|
157
|
-
e.querySelectorAll(".ak-stepper").forEach(
|
|
158
|
-
const n = t.target?.closest?.(".ak-stepper [data-ak-step]"), o = n?.closest(".ak-stepper"),
|
|
159
|
-
!n || !o || !
|
|
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 &&
|
|
198
|
+
n && O(n);
|
|
163
199
|
}));
|
|
164
200
|
}
|
|
165
|
-
let
|
|
166
|
-
function
|
|
201
|
+
let H = !1;
|
|
202
|
+
function w(e) {
|
|
167
203
|
return [...e.querySelectorAll(':scope > [role="tab"]')];
|
|
168
204
|
}
|
|
169
|
-
function
|
|
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
|
|
173
|
-
const
|
|
174
|
-
o.setAttribute("aria-selected", String(
|
|
175
|
-
const
|
|
176
|
-
|
|
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
|
|
217
|
+
function dt(e = document) {
|
|
182
218
|
e.querySelectorAll('[role="tablist"]').forEach((t) => {
|
|
183
|
-
const n =
|
|
184
|
-
n.forEach((
|
|
185
|
-
}), !
|
|
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 &&
|
|
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 =
|
|
192
|
-
let
|
|
193
|
-
t.key === "ArrowRight" ?
|
|
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
|
|
232
|
+
const ut = 4;
|
|
197
233
|
let u = null;
|
|
198
|
-
function
|
|
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
|
|
202
|
-
const
|
|
203
|
-
|
|
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,
|
|
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(),
|
|
209
|
-
}),
|
|
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", () =>
|
|
213
|
-
const
|
|
214
|
-
|
|
215
|
-
const
|
|
216
|
-
let E =
|
|
217
|
-
const
|
|
218
|
-
p && (clearTimeout(p), p = 0, E -= Date.now() -
|
|
219
|
-
},
|
|
220
|
-
!
|
|
221
|
-
},
|
|
222
|
-
|
|
223
|
-
function
|
|
224
|
-
if (
|
|
225
|
-
|
|
226
|
-
const d = () =>
|
|
227
|
-
|
|
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
|
|
265
|
+
return i._close = g, { close: g };
|
|
230
266
|
}
|
|
231
|
-
function
|
|
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",
|
|
237
|
-
|
|
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
|
|
241
|
-
let
|
|
242
|
-
function
|
|
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
|
|
281
|
+
function ht(e) {
|
|
246
282
|
return (e.dataset.akTooltip || e.getAttribute("aria-label") || e.getAttribute("title") || "").trim();
|
|
247
283
|
}
|
|
248
|
-
function
|
|
284
|
+
function Et(e, t) {
|
|
249
285
|
const n = e.getBoundingClientRect(), o = t.getBoundingClientRect();
|
|
250
|
-
let
|
|
251
|
-
|
|
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(
|
|
289
|
+
t.style.top = `${Math.round(a)}px`, t.style.left = `${Math.round(s)}px`, t.dataset.side = i;
|
|
254
290
|
}
|
|
255
|
-
function
|
|
256
|
-
const n =
|
|
291
|
+
function z(e, t) {
|
|
292
|
+
const n = ht(e);
|
|
257
293
|
if (!n) return;
|
|
258
|
-
const o =
|
|
259
|
-
r = e, o.textContent = n, o.toggleAttribute("data-instant", t), o.setAttribute("data-open", ""),
|
|
260
|
-
const
|
|
261
|
-
|
|
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(
|
|
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"),
|
|
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
|
|
304
|
+
function U(e, t) {
|
|
269
305
|
if (r === e) return;
|
|
270
|
-
clearTimeout(
|
|
271
|
-
const n = !!r || Date.now() -
|
|
272
|
-
r && m(), t || n ?
|
|
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
|
|
275
|
-
if (
|
|
276
|
-
|
|
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 &&
|
|
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") &&
|
|
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
|
|
295
|
-
|
|
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
|
|
298
|
-
let
|
|
299
|
-
function
|
|
300
|
-
|
|
333
|
+
const W = "http://www.w3.org/2000/svg";
|
|
334
|
+
let j = "";
|
|
335
|
+
function At(e) {
|
|
336
|
+
j = e;
|
|
301
337
|
}
|
|
302
|
-
function
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
const
|
|
306
|
-
return
|
|
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
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
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
|