@apo100l/ace-ui-kit 0.6.1 → 0.8.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/dist/ace-compat.css +1 -1
- package/dist/ace-ui-kit.css +1 -1
- package/dist/ace-ui-kit.js +360 -278
- package/dist/ace-ui-kit.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/js/copy.d.ts +4 -0
- package/dist/js/init.d.ts +1 -1
- package/dist/js/trend.d.ts +2 -0
- package/package.json +1 -1
- package/src/scss/_tokens.scss +4 -0
- package/src/scss/components/_badge.scss +24 -0
- package/src/scss/components/_shell.scss +28 -0
- package/src/scss/components/_stat.scss +78 -0
- package/src/scss/components/_trend.scss +116 -0
- package/src/scss/index.scss +2 -0
package/dist/ace-ui-kit.js
CHANGED
|
@@ -1,377 +1,459 @@
|
|
|
1
|
+
let v = null;
|
|
2
|
+
function Z() {
|
|
3
|
+
return v?.isConnected || (v = document.createElement("section"), v.className = "ak-toaster", v.setAttribute("aria-label", "Уведомления"), document.body.append(v)), v;
|
|
4
|
+
}
|
|
5
|
+
function M(t, { tone: e = "neutral", duration: n, action: o } = {}) {
|
|
6
|
+
const a = Z(), i = document.createElement("div");
|
|
7
|
+
i.className = `ak-toast ak-toast--${e}`, i.setAttribute("role", e === "negative" ? "alert" : "status"), i.setAttribute("aria-live", e === "negative" ? "assertive" : "polite");
|
|
8
|
+
const r = document.createElement("p");
|
|
9
|
+
if (r.className = "ak-toast__text", r.textContent = t, i.append(r), o) {
|
|
10
|
+
const l = document.createElement("button");
|
|
11
|
+
l.type = "button", l.className = "ak-toast__action", l.textContent = o.label, l.addEventListener("click", () => {
|
|
12
|
+
o.onClick(), m();
|
|
13
|
+
}), i.append(l);
|
|
14
|
+
}
|
|
15
|
+
const c = document.createElement("button");
|
|
16
|
+
c.type = "button", c.className = "ak-toast__close", c.setAttribute("aria-label", "Закрыть"), c.textContent = "×", c.addEventListener("click", () => m()), i.append(c), a.append(i);
|
|
17
|
+
const d = a.querySelectorAll(".ak-toast:not([data-leaving])");
|
|
18
|
+
d.length > 4 && d[0]._close?.(), requestAnimationFrame(() => requestAnimationFrame(() => i.setAttribute("data-shown", "")));
|
|
19
|
+
const u = n ?? (e === "negative" ? 0 : 5e3);
|
|
20
|
+
let b = u, h = 0, g = 0;
|
|
21
|
+
const A = () => {
|
|
22
|
+
g && (clearTimeout(g), g = 0, b -= Date.now() - h);
|
|
23
|
+
}, s = () => {
|
|
24
|
+
!u || g || b <= 0 || document.hidden || (h = Date.now(), g = window.setTimeout(m, b));
|
|
25
|
+
}, f = () => document.hidden ? A() : s();
|
|
26
|
+
i.addEventListener("mouseenter", A), i.addEventListener("mouseleave", s), i.addEventListener("focusin", A), i.addEventListener("focusout", s), document.addEventListener("visibilitychange", f), s();
|
|
27
|
+
function m() {
|
|
28
|
+
if (i.hasAttribute("data-leaving")) return;
|
|
29
|
+
A(), document.removeEventListener("visibilitychange", f), i.setAttribute("data-leaving", ""), i.removeAttribute("data-shown");
|
|
30
|
+
const l = () => i.remove();
|
|
31
|
+
i.addEventListener("transitionend", l, { once: !0 }), window.setTimeout(l, 400);
|
|
32
|
+
}
|
|
33
|
+
return i._close = m, { close: m };
|
|
34
|
+
}
|
|
35
|
+
function ee(t = document) {
|
|
36
|
+
t.querySelectorAll("[data-ak-toast]:not([data-ak-bound])").forEach((e) => {
|
|
37
|
+
e.setAttribute("data-ak-bound", "");
|
|
38
|
+
const n = (e instanceof HTMLTemplateElement ? e.content.textContent : e.textContent)?.trim();
|
|
39
|
+
if (!n) return;
|
|
40
|
+
const o = e.dataset.akToast || "neutral", a = e.dataset.akDuration ? Number(e.dataset.akDuration) : void 0;
|
|
41
|
+
M(n, { tone: o, duration: a }), e instanceof HTMLTemplateElement || (e.hidden = !0);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
let _ = !1;
|
|
45
|
+
function te(t) {
|
|
46
|
+
const e = document.createElement("textarea");
|
|
47
|
+
e.value = t, e.setAttribute("readonly", ""), e.style.cssText = "position:fixed;top:0;left:0;opacity:0;pointer-events:none;", document.body.append(e), e.select();
|
|
48
|
+
let n = !1;
|
|
49
|
+
try {
|
|
50
|
+
n = document.execCommand("copy");
|
|
51
|
+
} catch {
|
|
52
|
+
n = !1;
|
|
53
|
+
}
|
|
54
|
+
return e.remove(), n;
|
|
55
|
+
}
|
|
56
|
+
async function ne(t) {
|
|
57
|
+
try {
|
|
58
|
+
return await navigator.clipboard.writeText(t), !0;
|
|
59
|
+
} catch {
|
|
60
|
+
return te(t);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function oe(t) {
|
|
64
|
+
const e = t.dataset.akCopyFrom;
|
|
65
|
+
if (e === void 0) return { text: t.dataset.akCopy, field: null };
|
|
66
|
+
const n = document.getElementById(e);
|
|
67
|
+
return n instanceof HTMLInputElement || n instanceof HTMLTextAreaElement ? { text: n.value, field: n } : { text: n?.textContent?.trim() ?? void 0, field: null };
|
|
68
|
+
}
|
|
69
|
+
function ae() {
|
|
70
|
+
_ || (_ = !0, document.addEventListener("click", async (t) => {
|
|
71
|
+
const e = t.target?.closest?.("[data-ak-copy], [data-ak-copy-from]");
|
|
72
|
+
if (!e) return;
|
|
73
|
+
const { text: n, field: o } = oe(e);
|
|
74
|
+
n !== void 0 && (t.preventDefault(), await ne(n) ? M(e.dataset.akCopyMessage || `Скопировано: ${n}`, { tone: "positive", duration: 2e3 }) : o ? (o.focus(), o.select()) : M("Не удалось скопировать — выделите текст вручную", { tone: "warning" }));
|
|
75
|
+
}));
|
|
76
|
+
}
|
|
1
77
|
let D = !1;
|
|
2
|
-
function
|
|
3
|
-
|
|
78
|
+
function ie(t) {
|
|
79
|
+
t.open || (t.showModal(), document.documentElement.classList.add("ak-dialog-open"));
|
|
4
80
|
}
|
|
5
|
-
function
|
|
6
|
-
|
|
81
|
+
function N(t, e) {
|
|
82
|
+
t.open && t.close(e);
|
|
7
83
|
}
|
|
8
|
-
function
|
|
9
|
-
const
|
|
10
|
-
document.documentElement.classList.toggle("ak-dialog-open", !!
|
|
11
|
-
}
|
|
12
|
-
function
|
|
13
|
-
D || (D = !0, document.addEventListener("click", (
|
|
14
|
-
const
|
|
15
|
-
if (!
|
|
16
|
-
const n =
|
|
84
|
+
function re() {
|
|
85
|
+
const t = document.querySelector("dialog.ak-dialog[open]");
|
|
86
|
+
document.documentElement.classList.toggle("ak-dialog-open", !!t);
|
|
87
|
+
}
|
|
88
|
+
function se() {
|
|
89
|
+
D || (D = !0, document.addEventListener("click", (t) => {
|
|
90
|
+
const e = t.target instanceof Element ? t.target : null;
|
|
91
|
+
if (!e) return;
|
|
92
|
+
const n = e.closest("[data-ak-dialog-open]");
|
|
17
93
|
if (n) {
|
|
18
94
|
const a = document.getElementById(n.dataset.akDialogOpen ?? "");
|
|
19
|
-
a instanceof HTMLDialogElement && (
|
|
95
|
+
a instanceof HTMLDialogElement && (t.preventDefault(), ie(a));
|
|
20
96
|
return;
|
|
21
97
|
}
|
|
22
|
-
const o =
|
|
98
|
+
const o = e.closest("[data-ak-dialog-close]");
|
|
23
99
|
if (o) {
|
|
24
100
|
const a = o.closest("dialog");
|
|
25
|
-
a &&
|
|
101
|
+
a && N(a, o.dataset.akDialogClose || void 0);
|
|
26
102
|
return;
|
|
27
103
|
}
|
|
28
|
-
if (
|
|
29
|
-
const a =
|
|
30
|
-
(i < a.left || i > a.right ||
|
|
104
|
+
if (e instanceof HTMLDialogElement && e.open && e.classList.contains("ak-dialog") && !e.hasAttribute("data-ak-static")) {
|
|
105
|
+
const a = e.getBoundingClientRect(), { clientX: i, clientY: r } = t;
|
|
106
|
+
(i < a.left || i > a.right || r < a.top || r > a.bottom) && N(e, "cancel");
|
|
31
107
|
}
|
|
32
|
-
}), document.addEventListener("close",
|
|
108
|
+
}), document.addEventListener("close", re, !0));
|
|
33
109
|
}
|
|
34
|
-
const
|
|
35
|
-
function
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
110
|
+
const I = "akBound";
|
|
111
|
+
function ce(t = document) {
|
|
112
|
+
t.querySelectorAll("[data-ak-dismiss]").forEach((e) => {
|
|
113
|
+
e.dataset[I] || (e.dataset[I] = "1", e.addEventListener("click", () => {
|
|
114
|
+
e.closest("[data-ak-dismissible], .ak-alert")?.remove();
|
|
39
115
|
}));
|
|
40
116
|
});
|
|
41
117
|
}
|
|
42
|
-
let
|
|
43
|
-
const
|
|
44
|
-
function
|
|
45
|
-
const n =
|
|
118
|
+
let B = !1;
|
|
119
|
+
const le = (t) => t < 1024 ? `${t} Б` : t < 1048576 ? `${(t / 1024).toFixed(0)} КБ` : `${(t / 1048576).toFixed(1).replace(".", ",")} МБ`;
|
|
120
|
+
function de(t, e) {
|
|
121
|
+
const n = t.querySelector(".ak-file__list");
|
|
46
122
|
if (!n) return;
|
|
47
|
-
const o = Number(
|
|
123
|
+
const o = Number(e.dataset.maxSize) || 1 / 0;
|
|
48
124
|
n.replaceChildren(
|
|
49
|
-
...[...
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
return
|
|
125
|
+
...[...e.files ?? []].map((i) => {
|
|
126
|
+
const r = document.createElement("span");
|
|
127
|
+
r.className = "ak-file__item";
|
|
128
|
+
const c = i.size > o;
|
|
129
|
+
return r.toggleAttribute("data-invalid", c), r.textContent = `${i.name} · ${le(i.size)}${c ? " — больше допустимого" : ""}`, r;
|
|
54
130
|
})
|
|
55
131
|
);
|
|
56
|
-
const a = [...
|
|
57
|
-
|
|
132
|
+
const a = [...e.files ?? []].some((i) => i.size > o);
|
|
133
|
+
e.setCustomValidity(a ? "Файл больше допустимого размера" : ""), t.toggleAttribute("data-has-files", !!e.files?.length);
|
|
58
134
|
}
|
|
59
|
-
function
|
|
60
|
-
if (
|
|
61
|
-
|
|
62
|
-
const n =
|
|
135
|
+
function ue() {
|
|
136
|
+
if (B) return;
|
|
137
|
+
B = !0, document.addEventListener("change", (e) => {
|
|
138
|
+
const n = e.target;
|
|
63
139
|
if (!(n instanceof HTMLInputElement) || n.type !== "file") return;
|
|
64
140
|
const o = n.closest(".ak-file");
|
|
65
|
-
o &&
|
|
141
|
+
o && de(o, n);
|
|
66
142
|
});
|
|
67
|
-
const
|
|
68
|
-
document.addEventListener("dragover", (
|
|
69
|
-
const n = e
|
|
70
|
-
n && (
|
|
71
|
-
}), document.addEventListener("dragleave", (
|
|
72
|
-
const n = e
|
|
73
|
-
n && !n.contains(
|
|
74
|
-
}), document.addEventListener("drop", (
|
|
75
|
-
const n = e
|
|
143
|
+
const t = (e) => e.target?.closest?.(".ak-file") ?? null;
|
|
144
|
+
document.addEventListener("dragover", (e) => {
|
|
145
|
+
const n = t(e);
|
|
146
|
+
n && (e.preventDefault(), n.setAttribute("data-dragover", ""));
|
|
147
|
+
}), document.addEventListener("dragleave", (e) => {
|
|
148
|
+
const n = t(e);
|
|
149
|
+
n && !n.contains(e.relatedTarget) && n.removeAttribute("data-dragover");
|
|
150
|
+
}), document.addEventListener("drop", (e) => {
|
|
151
|
+
const n = t(e);
|
|
76
152
|
if (!n) return;
|
|
77
|
-
|
|
78
|
-
const o = n.querySelector('input[type="file"]'), a =
|
|
153
|
+
e.preventDefault(), n.removeAttribute("data-dragover");
|
|
154
|
+
const o = n.querySelector('input[type="file"]'), a = e.dataTransfer?.files;
|
|
79
155
|
if (!o || !a?.length || o.disabled) return;
|
|
80
156
|
const i = new DataTransfer();
|
|
81
|
-
[...a].slice(0, o.multiple ? void 0 : 1).forEach((
|
|
157
|
+
[...a].slice(0, o.multiple ? void 0 : 1).forEach((r) => i.items.add(r)), o.files = i.files, o.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
82
158
|
});
|
|
83
159
|
}
|
|
84
|
-
let
|
|
85
|
-
const
|
|
86
|
-
function
|
|
87
|
-
return
|
|
160
|
+
let O = !1;
|
|
161
|
+
const L = '.ak-menu__item:not(:disabled):not([aria-disabled="true"])', fe = typeof CSS < "u" && CSS.supports?.("position-area", "block-end");
|
|
162
|
+
function me(t) {
|
|
163
|
+
return t.id ? document.querySelector(`[popovertarget="${CSS.escape(t.id)}"]`) : null;
|
|
88
164
|
}
|
|
89
|
-
function
|
|
90
|
-
const n =
|
|
91
|
-
let i =
|
|
165
|
+
function pe(t, e) {
|
|
166
|
+
const n = e.getBoundingClientRect(), o = t.getBoundingClientRect();
|
|
167
|
+
let i = t.classList.contains("ak-menu--end") ? n.right - o.width : n.left;
|
|
92
168
|
i = Math.max(8, Math.min(i, window.innerWidth - o.width - 8));
|
|
93
|
-
let
|
|
94
|
-
|
|
169
|
+
let r = n.bottom + 4;
|
|
170
|
+
r + o.height > window.innerHeight - 8 && n.top - o.height - 4 > 8 && (r = n.top - o.height - 4), t.style.position = "fixed", t.style.left = `${Math.round(i)}px`, t.style.top = `${Math.round(r)}px`, t.style.margin = "0";
|
|
95
171
|
}
|
|
96
|
-
function
|
|
97
|
-
|
|
172
|
+
function be() {
|
|
173
|
+
O || (O = !0, document.addEventListener(
|
|
98
174
|
"toggle",
|
|
99
|
-
(
|
|
100
|
-
const
|
|
101
|
-
if (!(
|
|
102
|
-
const n =
|
|
103
|
-
o?.setAttribute("aria-expanded", String(n)), n && (o && !
|
|
175
|
+
(t) => {
|
|
176
|
+
const e = t.target;
|
|
177
|
+
if (!(e instanceof HTMLElement) || !e.classList.contains("ak-menu")) return;
|
|
178
|
+
const n = t.newState === "open", o = me(e);
|
|
179
|
+
o?.setAttribute("aria-expanded", String(n)), n && (o && !fe && pe(e, o), e.querySelector(L)?.focus());
|
|
104
180
|
},
|
|
105
181
|
!0
|
|
106
|
-
), document.addEventListener("keydown", (
|
|
107
|
-
const
|
|
108
|
-
if (!
|
|
109
|
-
const n = [...
|
|
182
|
+
), document.addEventListener("keydown", (t) => {
|
|
183
|
+
const e = t.target?.closest?.(".ak-menu:popover-open");
|
|
184
|
+
if (!e) return;
|
|
185
|
+
const n = [...e.querySelectorAll(L)];
|
|
110
186
|
if (!n.length) return;
|
|
111
187
|
const o = n.indexOf(document.activeElement);
|
|
112
188
|
let a = -1;
|
|
113
|
-
|
|
114
|
-
}), document.addEventListener("click", (
|
|
115
|
-
|
|
189
|
+
t.key === "ArrowDown" ? a = (o + 1) % n.length : t.key === "ArrowUp" ? a = (o - 1 + n.length) % n.length : t.key === "Home" ? a = 0 : t.key === "End" ? a = n.length - 1 : t.key === "Tab" && e.hidePopover(), a >= 0 && (t.preventDefault(), n[a].focus());
|
|
190
|
+
}), document.addEventListener("click", (t) => {
|
|
191
|
+
t.target?.closest?.(L)?.closest(".ak-menu:popover-open")?.hidePopover();
|
|
116
192
|
}));
|
|
117
193
|
}
|
|
118
|
-
const
|
|
119
|
-
let
|
|
120
|
-
function
|
|
121
|
-
const
|
|
122
|
-
return
|
|
194
|
+
const C = "ak-mode";
|
|
195
|
+
let H = !1;
|
|
196
|
+
function ge(t) {
|
|
197
|
+
const e = document.cookie.match(new RegExp(`(?:^|; )${t.replace(/[.$?*|{}()[\]\\/+^]/g, "\\$&")}=([^;]*)`));
|
|
198
|
+
return e ? decodeURIComponent(e[1]) : null;
|
|
123
199
|
}
|
|
124
|
-
function
|
|
125
|
-
const
|
|
126
|
-
return
|
|
200
|
+
function G() {
|
|
201
|
+
const t = document.documentElement;
|
|
202
|
+
return t.dataset.akMode === "dark" || t.dataset.akTheme === "dark" ? "dark" : "light";
|
|
127
203
|
}
|
|
128
|
-
function
|
|
204
|
+
function ke(t, e = C) {
|
|
129
205
|
const n = document.documentElement;
|
|
130
|
-
|
|
206
|
+
t === "dark" ? n.dataset.akMode = "dark" : delete n.dataset.akMode, n.dataset.akTheme === "dark" && delete n.dataset.akTheme;
|
|
131
207
|
const o = location.protocol === "https:" ? "; Secure" : "";
|
|
132
|
-
document.cookie = `${
|
|
133
|
-
}
|
|
134
|
-
function
|
|
135
|
-
const
|
|
136
|
-
document.querySelectorAll("[data-ak-mode-toggle]").forEach((
|
|
137
|
-
|
|
138
|
-
const n =
|
|
139
|
-
n && (
|
|
208
|
+
document.cookie = `${e}=${t}; path=/; max-age=31536000; SameSite=Lax${o}`, $(), n.dispatchEvent(new CustomEvent("ak:mode-change", { bubbles: !0, detail: { mode: t } }));
|
|
209
|
+
}
|
|
210
|
+
function $() {
|
|
211
|
+
const t = G() === "dark";
|
|
212
|
+
document.querySelectorAll("[data-ak-mode-toggle]").forEach((e) => {
|
|
213
|
+
e.setAttribute("aria-pressed", String(t));
|
|
214
|
+
const n = t ? e.dataset.akLabelLight : e.dataset.akLabelDark;
|
|
215
|
+
n && (e.setAttribute("aria-label", n), e.hasAttribute("title") && (e.title = n));
|
|
140
216
|
});
|
|
141
217
|
}
|
|
142
|
-
function
|
|
143
|
-
if (
|
|
144
|
-
|
|
218
|
+
function he() {
|
|
219
|
+
if (H) {
|
|
220
|
+
$();
|
|
145
221
|
return;
|
|
146
222
|
}
|
|
147
|
-
|
|
148
|
-
const
|
|
149
|
-
!n.dataset.akMode &&
|
|
223
|
+
H = !0;
|
|
224
|
+
const e = document.querySelector("[data-ak-mode-toggle]")?.dataset.akModeToggle || C, n = document.documentElement;
|
|
225
|
+
!n.dataset.akMode && ge(e) === "dark" && (n.dataset.akMode = "dark"), $(), document.addEventListener("click", (o) => {
|
|
150
226
|
const a = o.target?.closest?.("[data-ak-mode-toggle]");
|
|
151
|
-
a && (o.preventDefault(),
|
|
227
|
+
a && (o.preventDefault(), ke(G() === "dark" ? "light" : "dark", a.dataset.akModeToggle || C));
|
|
152
228
|
});
|
|
153
229
|
}
|
|
154
|
-
let
|
|
155
|
-
function
|
|
156
|
-
|
|
230
|
+
let R = !1;
|
|
231
|
+
function S(t, e) {
|
|
232
|
+
t.toggleAttribute("data-sidebar-open", e), t.querySelectorAll("[data-ak-sidebar-toggle]").forEach((n) => n.setAttribute("aria-expanded", String(e)));
|
|
157
233
|
}
|
|
158
|
-
function
|
|
159
|
-
|
|
160
|
-
const
|
|
234
|
+
function ye() {
|
|
235
|
+
R || (R = !0, document.addEventListener("click", (t) => {
|
|
236
|
+
const e = t.target instanceof Element ? t.target : null, n = e?.closest("[data-ak-sidebar-toggle]"), o = e?.closest(".ak-app");
|
|
161
237
|
if (o) {
|
|
162
238
|
if (n) {
|
|
163
|
-
|
|
239
|
+
S(o, !o.hasAttribute("data-sidebar-open"));
|
|
164
240
|
return;
|
|
165
241
|
}
|
|
166
|
-
o.hasAttribute("data-sidebar-open") && !
|
|
242
|
+
o.hasAttribute("data-sidebar-open") && !e?.closest(".ak-sidebar") && S(o, !1);
|
|
167
243
|
}
|
|
168
|
-
}), document.addEventListener("keydown", (
|
|
169
|
-
if (
|
|
170
|
-
const
|
|
171
|
-
|
|
244
|
+
}), document.addEventListener("keydown", (t) => {
|
|
245
|
+
if (t.key !== "Escape") return;
|
|
246
|
+
const e = document.querySelector(".ak-app[data-sidebar-open]");
|
|
247
|
+
e && (S(e, !1), e.querySelector("[data-ak-sidebar-toggle]")?.focus());
|
|
172
248
|
}));
|
|
173
249
|
}
|
|
174
|
-
let
|
|
175
|
-
const
|
|
176
|
-
const n = Number(
|
|
177
|
-
return
|
|
250
|
+
let F = !1;
|
|
251
|
+
const E = (t, e) => {
|
|
252
|
+
const n = Number(t);
|
|
253
|
+
return t !== "" && Number.isFinite(n) ? n : e;
|
|
178
254
|
};
|
|
179
|
-
function
|
|
180
|
-
const
|
|
181
|
-
if (!
|
|
182
|
-
const n =
|
|
183
|
-
|
|
255
|
+
function z(t) {
|
|
256
|
+
const e = t.querySelector("input");
|
|
257
|
+
if (!e) return;
|
|
258
|
+
const n = E(e.value, 0);
|
|
259
|
+
t.querySelectorAll("[data-ak-step]").forEach((o) => {
|
|
184
260
|
const a = Number(o.dataset.akStep);
|
|
185
|
-
o.disabled =
|
|
261
|
+
o.disabled = e.disabled || (a < 0 ? n <= E(e.min, -1 / 0) : n >= E(e.max, 1 / 0));
|
|
186
262
|
});
|
|
187
263
|
}
|
|
188
|
-
function
|
|
189
|
-
const n =
|
|
190
|
-
|
|
191
|
-
}
|
|
192
|
-
function
|
|
193
|
-
|
|
194
|
-
const n =
|
|
195
|
-
!n || !o || !a || (
|
|
196
|
-
}), document.addEventListener("input", (
|
|
197
|
-
const n =
|
|
198
|
-
n &&
|
|
264
|
+
function ve(t, e) {
|
|
265
|
+
const n = E(t.step, 1) || 1, o = Math.min(E(t.max, 1 / 0), Math.max(E(t.min, -1 / 0), E(t.value, 0) + e * n)), a = (String(n).split(".")[1] ?? "").length;
|
|
266
|
+
t.value = o.toFixed(a), t.dispatchEvent(new Event("input", { bubbles: !0 })), t.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
267
|
+
}
|
|
268
|
+
function Ee(t = document) {
|
|
269
|
+
t.querySelectorAll(".ak-stepper").forEach(z), !F && (F = !0, document.addEventListener("click", (e) => {
|
|
270
|
+
const n = e.target?.closest?.(".ak-stepper [data-ak-step]"), o = n?.closest(".ak-stepper"), a = o?.querySelector("input");
|
|
271
|
+
!n || !o || !a || (e.preventDefault(), ve(a, Number(n.dataset.akStep) || 1));
|
|
272
|
+
}), document.addEventListener("input", (e) => {
|
|
273
|
+
const n = e.target?.closest?.(".ak-stepper");
|
|
274
|
+
n && z(n);
|
|
199
275
|
}));
|
|
200
276
|
}
|
|
201
|
-
let
|
|
202
|
-
function
|
|
203
|
-
const
|
|
204
|
-
|
|
277
|
+
let T = null;
|
|
278
|
+
function W(t) {
|
|
279
|
+
const e = t.querySelector(":scope > table");
|
|
280
|
+
e && (t.removeAttribute("data-overflow"), t.toggleAttribute("data-overflow", e.scrollWidth > t.clientWidth + 1));
|
|
205
281
|
}
|
|
206
|
-
function
|
|
207
|
-
typeof ResizeObserver > "u" || (
|
|
208
|
-
|
|
282
|
+
function Ae(t = document) {
|
|
283
|
+
typeof ResizeObserver > "u" || (T ??= new ResizeObserver((e) => {
|
|
284
|
+
e.forEach((n) => {
|
|
209
285
|
const o = n.target;
|
|
210
|
-
|
|
286
|
+
W(o.matches(".ak-table-wrap") ? o : o.closest(".ak-table-wrap") ?? o);
|
|
211
287
|
});
|
|
212
|
-
}),
|
|
213
|
-
if (
|
|
214
|
-
|
|
215
|
-
const n =
|
|
216
|
-
n &&
|
|
288
|
+
}), t.querySelectorAll(".ak-table-wrap--page-sticky").forEach((e) => {
|
|
289
|
+
if (e.dataset.akObserved) return;
|
|
290
|
+
e.dataset.akObserved = "1", T?.observe(e);
|
|
291
|
+
const n = e.querySelector(":scope > table");
|
|
292
|
+
n && T?.observe(n), W(e);
|
|
217
293
|
}));
|
|
218
294
|
}
|
|
219
|
-
let
|
|
220
|
-
function
|
|
221
|
-
return [...
|
|
295
|
+
let U = !1;
|
|
296
|
+
function q(t) {
|
|
297
|
+
return [...t.querySelectorAll(':scope > [role="tab"]')];
|
|
222
298
|
}
|
|
223
|
-
function
|
|
224
|
-
const n =
|
|
225
|
-
if (!(!n ||
|
|
226
|
-
for (const o of
|
|
227
|
-
const a = o ===
|
|
299
|
+
function P(t, e = !1) {
|
|
300
|
+
const n = t.closest('[role="tablist"]');
|
|
301
|
+
if (!(!n || t.getAttribute("aria-disabled") === "true")) {
|
|
302
|
+
for (const o of q(n)) {
|
|
303
|
+
const a = o === t;
|
|
228
304
|
o.setAttribute("aria-selected", String(a)), o.tabIndex = a ? 0 : -1;
|
|
229
305
|
const i = document.getElementById(o.getAttribute("aria-controls") ?? "");
|
|
230
306
|
i && (i.hidden = !a, i.hasAttribute("tabindex") || (i.tabIndex = 0));
|
|
231
307
|
}
|
|
232
|
-
|
|
308
|
+
e && t.focus(), n.dispatchEvent(new CustomEvent("ak:tab-change", { bubbles: !0, detail: { tab: t } }));
|
|
233
309
|
}
|
|
234
310
|
}
|
|
235
|
-
function
|
|
236
|
-
|
|
237
|
-
const n =
|
|
311
|
+
function we(t = document) {
|
|
312
|
+
t.querySelectorAll('[role="tablist"]').forEach((e) => {
|
|
313
|
+
const n = q(e), o = n.find((a) => a.getAttribute("aria-selected") === "true") ?? n[0];
|
|
238
314
|
n.forEach((a) => a.tabIndex = a === o ? 0 : -1);
|
|
239
|
-
}), !
|
|
240
|
-
const n =
|
|
241
|
-
n &&
|
|
242
|
-
}), document.addEventListener("keydown", (
|
|
243
|
-
const n =
|
|
315
|
+
}), !U && (U = !0, document.addEventListener("click", (e) => {
|
|
316
|
+
const n = e.target?.closest?.('[role="tablist"] > [role="tab"]');
|
|
317
|
+
n && P(n);
|
|
318
|
+
}), document.addEventListener("keydown", (e) => {
|
|
319
|
+
const n = e.target?.closest?.('[role="tablist"] > [role="tab"]');
|
|
244
320
|
if (!n) return;
|
|
245
|
-
const o =
|
|
321
|
+
const o = q(n.parentElement).filter((r) => r.getAttribute("aria-disabled") !== "true"), a = o.indexOf(n);
|
|
246
322
|
let i;
|
|
247
|
-
|
|
323
|
+
e.key === "ArrowRight" ? i = o[(a + 1) % o.length] : e.key === "ArrowLeft" ? i = o[(a - 1 + o.length) % o.length] : e.key === "Home" ? i = o[0] : e.key === "End" && (i = o[o.length - 1]), i && (e.preventDefault(), P(i, !0));
|
|
248
324
|
}));
|
|
249
325
|
}
|
|
250
|
-
const
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
const s = document.createElement("p");
|
|
259
|
-
if (s.className = "ak-toast__text", s.textContent = e, i.append(s), o) {
|
|
260
|
-
const d = document.createElement("button");
|
|
261
|
-
d.type = "button", d.className = "ak-toast__action", d.textContent = o.label, d.addEventListener("click", () => {
|
|
262
|
-
o.onClick(), g();
|
|
263
|
-
}), i.append(d);
|
|
264
|
-
}
|
|
265
|
-
const l = document.createElement("button");
|
|
266
|
-
l.type = "button", l.className = "ak-toast__close", l.setAttribute("aria-label", "Закрыть"), l.textContent = "×", l.addEventListener("click", () => g()), i.append(l), a.append(i);
|
|
267
|
-
const x = a.querySelectorAll(".ak-toast:not([data-leaving])");
|
|
268
|
-
x.length > bt && x[0]._close?.(), requestAnimationFrame(() => requestAnimationFrame(() => i.setAttribute("data-shown", "")));
|
|
269
|
-
const T = n ?? (t === "negative" ? 0 : 5e3);
|
|
270
|
-
let E = T, $ = 0, b = 0;
|
|
271
|
-
const p = () => {
|
|
272
|
-
b && (clearTimeout(b), b = 0, E -= Date.now() - $);
|
|
273
|
-
}, k = () => {
|
|
274
|
-
!T || b || E <= 0 || document.hidden || ($ = Date.now(), b = window.setTimeout(g, E));
|
|
275
|
-
}, M = () => document.hidden ? p() : k();
|
|
276
|
-
i.addEventListener("mouseenter", p), i.addEventListener("mouseleave", k), i.addEventListener("focusin", p), i.addEventListener("focusout", k), document.addEventListener("visibilitychange", M), k();
|
|
277
|
-
function g() {
|
|
278
|
-
if (i.hasAttribute("data-leaving")) return;
|
|
279
|
-
p(), document.removeEventListener("visibilitychange", M), i.setAttribute("data-leaving", ""), i.removeAttribute("data-shown");
|
|
280
|
-
const d = () => i.remove();
|
|
281
|
-
i.addEventListener("transitionend", d, { once: !0 }), window.setTimeout(d, 400);
|
|
326
|
+
const V = /* @__PURE__ */ new WeakSet();
|
|
327
|
+
function xe(t) {
|
|
328
|
+
const e = t.querySelector(".ak-trend__points")?.textContent ?? "";
|
|
329
|
+
try {
|
|
330
|
+
const n = JSON.parse(e);
|
|
331
|
+
return Array.isArray(n) ? n.filter((o) => Array.isArray(o) && typeof o[0] == "number" && typeof o[1] == "number").map((o) => [o[0], o[1], String(o[2] ?? "")]) : [];
|
|
332
|
+
} catch {
|
|
333
|
+
return [];
|
|
282
334
|
}
|
|
283
|
-
return i._close = g, { close: g };
|
|
284
335
|
}
|
|
285
|
-
function
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
336
|
+
function Le(t) {
|
|
337
|
+
if (V.has(t)) return;
|
|
338
|
+
const e = t.querySelector(".ak-trend__plot"), n = e?.querySelector("svg"), o = xe(t);
|
|
339
|
+
if (!e || !n || o.length < 2) return;
|
|
340
|
+
V.add(t);
|
|
341
|
+
const a = n.viewBox.baseVal, i = a && a.width ? a.width : 300, r = a && a.height ? a.height : 64, c = document.createElement("span"), d = document.createElement("span"), u = document.createElement("span");
|
|
342
|
+
c.className = "ak-trend__cursor", d.className = "ak-trend__dot", u.className = "ak-trend__tip", u.setAttribute("role", "status");
|
|
343
|
+
for (const s of [c, d, u]) s.hidden = !0;
|
|
344
|
+
e.append(c, d), t.querySelector(".ak-trend__title")?.after(u), e.hasAttribute("tabindex") || (e.tabIndex = 0);
|
|
345
|
+
let b = -1;
|
|
346
|
+
const h = (s) => {
|
|
347
|
+
b = Math.max(0, Math.min(o.length - 1, s));
|
|
348
|
+
const [f, m, l] = o[b], y = `${f / i * 100}%`;
|
|
349
|
+
c.style.left = y, d.style.left = y, d.style.top = `${m / r * 100}%`, u.textContent = l, c.hidden = d.hidden = u.hidden = !1;
|
|
350
|
+
}, g = () => {
|
|
351
|
+
c.hidden = d.hidden = u.hidden = !0;
|
|
352
|
+
}, A = (s) => {
|
|
353
|
+
const f = e.getBoundingClientRect(), m = (s - f.left) / f.width * i;
|
|
354
|
+
let l = 0;
|
|
355
|
+
for (let y = 1; y < o.length; y++)
|
|
356
|
+
Math.abs(o[y][0] - m) < Math.abs(o[l][0] - m) && (l = y);
|
|
357
|
+
return l;
|
|
358
|
+
};
|
|
359
|
+
e.addEventListener("pointermove", (s) => h(A(s.clientX))), e.addEventListener("pointerleave", () => {
|
|
360
|
+
document.activeElement !== e && g();
|
|
361
|
+
}), e.addEventListener("focus", () => h(b < 0 ? o.length - 1 : b)), e.addEventListener("blur", g), e.addEventListener("keydown", (s) => {
|
|
362
|
+
const f = { ArrowLeft: -1, ArrowRight: 1 };
|
|
363
|
+
if (s.key in f) h(b + f[s.key]);
|
|
364
|
+
else if (s.key === "Home") h(0);
|
|
365
|
+
else if (s.key === "End") h(o.length - 1);
|
|
366
|
+
else if (s.key === "Escape") g();
|
|
367
|
+
else return;
|
|
368
|
+
s.preventDefault();
|
|
292
369
|
});
|
|
293
370
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
function vt() {
|
|
297
|
-
return c?.isConnected || (c = document.createElement("div"), c.className = "ak-tooltip", c.id = "ak-tooltip", c.setAttribute("role", "tooltip"), document.body.append(c)), c;
|
|
371
|
+
function Se(t = document) {
|
|
372
|
+
t.querySelectorAll(".ak-trend[data-ak-trend]").forEach(Le);
|
|
298
373
|
}
|
|
299
|
-
|
|
300
|
-
|
|
374
|
+
const Te = 500, Me = 400;
|
|
375
|
+
let X = !1, k = null, p = null, x = 0, J = 0;
|
|
376
|
+
function Ce() {
|
|
377
|
+
return k?.isConnected || (k = document.createElement("div"), k.className = "ak-tooltip", k.id = "ak-tooltip", k.setAttribute("role", "tooltip"), document.body.append(k)), k;
|
|
301
378
|
}
|
|
302
|
-
function
|
|
303
|
-
|
|
379
|
+
function $e(t) {
|
|
380
|
+
return (t.dataset.akTooltip || t.getAttribute("aria-label") || t.getAttribute("title") || "").trim();
|
|
381
|
+
}
|
|
382
|
+
function qe(t, e) {
|
|
383
|
+
const n = t.getBoundingClientRect(), o = e.getBoundingClientRect();
|
|
304
384
|
let a = n.top - o.height - 6, i = "top";
|
|
305
385
|
a < 8 && (a = n.bottom + 6, i = "bottom");
|
|
306
|
-
const
|
|
307
|
-
|
|
386
|
+
const r = Math.max(8, Math.min(n.left + n.width / 2 - o.width / 2, window.innerWidth - o.width - 8));
|
|
387
|
+
e.style.top = `${Math.round(a)}px`, e.style.left = `${Math.round(r)}px`, e.dataset.side = i;
|
|
308
388
|
}
|
|
309
|
-
function
|
|
310
|
-
const n =
|
|
389
|
+
function j(t, e) {
|
|
390
|
+
const n = $e(t);
|
|
311
391
|
if (!n) return;
|
|
312
|
-
const o =
|
|
313
|
-
|
|
314
|
-
const a =
|
|
315
|
-
a.split(" ").includes(o.id) ||
|
|
316
|
-
}
|
|
317
|
-
function
|
|
318
|
-
if (clearTimeout(
|
|
319
|
-
const
|
|
320
|
-
|
|
321
|
-
}
|
|
322
|
-
function
|
|
323
|
-
if (
|
|
324
|
-
clearTimeout(
|
|
325
|
-
const n = !!
|
|
326
|
-
|
|
327
|
-
}
|
|
328
|
-
function
|
|
329
|
-
if (
|
|
330
|
-
|
|
331
|
-
const
|
|
332
|
-
document.addEventListener("pointerover", (
|
|
333
|
-
if (
|
|
334
|
-
const n = e
|
|
335
|
-
n &&
|
|
336
|
-
}), document.addEventListener("pointerout", (
|
|
337
|
-
const n = e
|
|
338
|
-
n && !n.contains(
|
|
339
|
-
}), document.addEventListener("focusin", (
|
|
340
|
-
const n = e
|
|
341
|
-
n && n.matches(":focus-visible") &&
|
|
342
|
-
}), document.addEventListener("focusout", (
|
|
343
|
-
e
|
|
344
|
-
}), document.addEventListener("keydown", (
|
|
345
|
-
|
|
346
|
-
}), window.addEventListener("scroll",
|
|
392
|
+
const o = Ce();
|
|
393
|
+
p = t, o.textContent = n, o.toggleAttribute("data-instant", e), o.setAttribute("data-open", ""), qe(t, o);
|
|
394
|
+
const a = t.getAttribute("aria-describedby") ?? "";
|
|
395
|
+
a.split(" ").includes(o.id) || t.setAttribute("aria-describedby", `${a} ${o.id}`.trim());
|
|
396
|
+
}
|
|
397
|
+
function w() {
|
|
398
|
+
if (clearTimeout(x), x = 0, !p) return;
|
|
399
|
+
const t = (p.getAttribute("aria-describedby") ?? "").split(" ").filter((e) => e && e !== "ak-tooltip");
|
|
400
|
+
t.length ? p.setAttribute("aria-describedby", t.join(" ")) : p.removeAttribute("aria-describedby"), p = null, k?.removeAttribute("data-open"), J = Date.now();
|
|
401
|
+
}
|
|
402
|
+
function K(t, e) {
|
|
403
|
+
if (p === t) return;
|
|
404
|
+
clearTimeout(x);
|
|
405
|
+
const n = !!p || Date.now() - J < Me;
|
|
406
|
+
p && w(), e || n ? j(t, n) : x = window.setTimeout(() => j(t, !1), Te);
|
|
407
|
+
}
|
|
408
|
+
function _e() {
|
|
409
|
+
if (X) return;
|
|
410
|
+
X = !0;
|
|
411
|
+
const t = (e) => e.target?.closest?.("[data-ak-tooltip]") ?? null;
|
|
412
|
+
document.addEventListener("pointerover", (e) => {
|
|
413
|
+
if (e.pointerType === "touch") return;
|
|
414
|
+
const n = t(e);
|
|
415
|
+
n && K(n, !1);
|
|
416
|
+
}), document.addEventListener("pointerout", (e) => {
|
|
417
|
+
const n = t(e);
|
|
418
|
+
n && !n.contains(e.relatedTarget) && w();
|
|
419
|
+
}), document.addEventListener("focusin", (e) => {
|
|
420
|
+
const n = t(e);
|
|
421
|
+
n && n.matches(":focus-visible") && K(n, !0);
|
|
422
|
+
}), document.addEventListener("focusout", (e) => {
|
|
423
|
+
t(e) && w();
|
|
424
|
+
}), document.addEventListener("keydown", (e) => {
|
|
425
|
+
e.key === "Escape" && p && w();
|
|
426
|
+
}), window.addEventListener("scroll", w, { passive: !0, capture: !0 }), document.addEventListener("pointerdown", w);
|
|
347
427
|
}
|
|
348
|
-
function
|
|
349
|
-
|
|
428
|
+
function De({ root: t = document } = {}) {
|
|
429
|
+
se(), ae(), be(), ye(), _e(), he(), ue(), we(t), Ee(t), Ae(t), Se(t), ce(t), ee(t);
|
|
350
430
|
}
|
|
351
|
-
const
|
|
352
|
-
let
|
|
353
|
-
function
|
|
354
|
-
|
|
431
|
+
const Y = "http://www.w3.org/2000/svg";
|
|
432
|
+
let Q = "";
|
|
433
|
+
function Ne(t) {
|
|
434
|
+
Q = t;
|
|
355
435
|
}
|
|
356
|
-
function
|
|
357
|
-
const a = document.createElementNS(
|
|
358
|
-
a.setAttribute("class", ["ak-icon",
|
|
359
|
-
const i = document.createElementNS(
|
|
360
|
-
return i.setAttribute("href", `${
|
|
436
|
+
function Ie(t, { size: e, label: n, className: o } = {}) {
|
|
437
|
+
const a = document.createElementNS(Y, "svg");
|
|
438
|
+
a.setAttribute("class", ["ak-icon", e && `ak-icon--${e}`, o].filter(Boolean).join(" ")), n ? (a.setAttribute("role", "img"), a.setAttribute("aria-label", n)) : a.setAttribute("aria-hidden", "true"), a.setAttribute("focusable", "false");
|
|
439
|
+
const i = document.createElementNS(Y, "use");
|
|
440
|
+
return i.setAttribute("href", `${Q}#${t}`), a.append(i), a;
|
|
361
441
|
}
|
|
362
442
|
export {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
443
|
+
N as closeDialog,
|
|
444
|
+
ne as copyText,
|
|
445
|
+
ce as dismissible,
|
|
446
|
+
G as getMode,
|
|
447
|
+
Ie as icon,
|
|
448
|
+
De as init,
|
|
449
|
+
ie as openDialog,
|
|
450
|
+
P as selectTab,
|
|
451
|
+
Ne as setIconSprite,
|
|
452
|
+
ke as setMode,
|
|
453
|
+
ve as stepBy,
|
|
454
|
+
Ae as stickyTables,
|
|
455
|
+
M as toast,
|
|
456
|
+
ee as toastsFromDom,
|
|
457
|
+
Se as trends
|
|
376
458
|
};
|
|
377
459
|
//# sourceMappingURL=ace-ui-kit.js.map
|