@luanlu/mk-motion 1.0.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 +120 -0
- package/dist/a11y/focus-trap.d.ts +10 -0
- package/dist/a11y/keyboard.d.ts +28 -0
- package/dist/components/alert/alert.d.ts +18 -0
- package/dist/components/avatar/avatar.d.ts +31 -0
- package/dist/components/breadcrumb/breadcrumb.d.ts +16 -0
- package/dist/components/button/button.d.ts +28 -0
- package/dist/components/card/card.d.ts +19 -0
- package/dist/components/collapse/collapse.d.ts +23 -0
- package/dist/components/dialog/dialog.d.ts +27 -0
- package/dist/components/drawer/drawer.d.ts +21 -0
- package/dist/components/empty/empty.d.ts +14 -0
- package/dist/components/form/checkbox.d.ts +27 -0
- package/dist/components/form/radio.d.ts +32 -0
- package/dist/components/form/select.d.ts +32 -0
- package/dist/components/form/slider.d.ts +31 -0
- package/dist/components/input/input.d.ts +31 -0
- package/dist/components/layout/divider.d.ts +12 -0
- package/dist/components/layout/row.d.ts +14 -0
- package/dist/components/layout/space.d.ts +13 -0
- package/dist/components/loading/loading.d.ts +8 -0
- package/dist/components/menu/menu.d.ts +30 -0
- package/dist/components/message/message.d.ts +10 -0
- package/dist/components/popover/popover.d.ts +31 -0
- package/dist/components/progress/progress.d.ts +25 -0
- package/dist/components/steps/steps.d.ts +22 -0
- package/dist/components/switch/switch.d.ts +23 -0
- package/dist/components/table/table.d.ts +47 -0
- package/dist/components/tabs/tabs.d.ts +30 -0
- package/dist/components/tag/tag.d.ts +24 -0
- package/dist/components/tooltip/tooltip.d.ts +8 -0
- package/dist/core/animator.d.ts +29 -0
- package/dist/core/timeline.d.ts +14 -0
- package/dist/core/utils.d.ts +13 -0
- package/dist/effects/glitch.d.ts +14 -0
- package/dist/effects/particle.d.ts +17 -0
- package/dist/effects/text-split.d.ts +14 -0
- package/dist/effects/wave-text.d.ts +17 -0
- package/dist/gesture/draggable.d.ts +23 -0
- package/dist/gesture/spring.d.ts +24 -0
- package/dist/index.d.ts +109 -0
- package/dist/interactive/coverflow.d.ts +24 -0
- package/dist/interactive/cursor-trail.d.ts +11 -0
- package/dist/interactive/flip-card.d.ts +18 -0
- package/dist/interactive/magnetic.d.ts +12 -0
- package/dist/micro/hover-lift.d.ts +15 -0
- package/dist/micro/ripple.d.ts +13 -0
- package/dist/mk-motion.js +3194 -0
- package/dist/mk-motion.umd.cjs +149 -0
- package/dist/motion/component-motion.d.ts +43 -0
- package/dist/presets/index.d.ts +20 -0
- package/dist/scroll/scroll-trigger.d.ts +20 -0
- package/dist/style.css +1 -0
- package/dist/text/count-up.d.ts +23 -0
- package/dist/text/typewriter.d.ts +21 -0
- package/dist/theme/theme.d.ts +28 -0
- package/dist/transitions/blur-reveal.d.ts +14 -0
- package/dist/transitions/collapse.d.ts +16 -0
- package/dist/transitions/lazy-image.d.ts +14 -0
- package/dist/transitions/list.d.ts +9 -0
- package/dist/transitions/loading.d.ts +13 -0
- package/dist/transitions/parallax.d.ts +16 -0
- package/dist/transitions/shimmer.d.ts +13 -0
- package/dist/transitions/toast.d.ts +25 -0
- package/dist/types.d.ts +4 -0
- package/package.json +57 -0
|
@@ -0,0 +1,3194 @@
|
|
|
1
|
+
var J = Object.defineProperty;
|
|
2
|
+
var Z = (n, t, e) => t in n ? J(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
|
+
var c = (n, t, e) => Z(n, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
function Q(n) {
|
|
5
|
+
return n < 1e3 ? `${n}ms` : `${(n / 1e3).toFixed(2).replace(/\.?0+$/, "")}s`;
|
|
6
|
+
}
|
|
7
|
+
function q(n, t) {
|
|
8
|
+
Object.entries(t).forEach(([e, s]) => {
|
|
9
|
+
n.style.setProperty(`--mk-${e}`, String(s));
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
function tt(n, t) {
|
|
13
|
+
t.forEach((e) => {
|
|
14
|
+
n.style.removeProperty(`--mk-${e}`);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
const D = {
|
|
18
|
+
duration: 500,
|
|
19
|
+
easing: "ease",
|
|
20
|
+
delay: 0,
|
|
21
|
+
iterations: 1,
|
|
22
|
+
direction: "normal",
|
|
23
|
+
fill: "both"
|
|
24
|
+
};
|
|
25
|
+
class F {
|
|
26
|
+
constructor(t) {
|
|
27
|
+
c(this, "element");
|
|
28
|
+
c(this, "currentAnimation", null);
|
|
29
|
+
if (this.element = typeof t == "string" ? document.querySelector(t) : t, !this.element)
|
|
30
|
+
throw new Error("Animator: element not found");
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* 播放 CSS 类动画
|
|
34
|
+
*/
|
|
35
|
+
animate(t, e = {}) {
|
|
36
|
+
return new Promise((s) => {
|
|
37
|
+
const i = { ...D, ...e };
|
|
38
|
+
q(this.element, {
|
|
39
|
+
duration: Q(i.duration),
|
|
40
|
+
easing: i.easing
|
|
41
|
+
});
|
|
42
|
+
const o = `mk-animated mk-${t}`;
|
|
43
|
+
this.element.classList.add(...o.split(" "));
|
|
44
|
+
const r = () => {
|
|
45
|
+
this.element.classList.remove(...o.split(" ")), tt(this.element, ["duration", "easing"]), s(this);
|
|
46
|
+
}, a = (l) => {
|
|
47
|
+
l.animationName.startsWith("mk-") && (this.element.removeEventListener("animationend", a), r());
|
|
48
|
+
};
|
|
49
|
+
if (i.iterations === 1 / 0 || i.iterations <= 0) {
|
|
50
|
+
this.element.classList.add("mk-infinite"), s(this);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
this.element.addEventListener("animationend", a);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* 使用 Web Animations API 播放动画
|
|
58
|
+
*/
|
|
59
|
+
waa(t, e = {}) {
|
|
60
|
+
return new Promise((s) => {
|
|
61
|
+
const i = { ...D, ...e };
|
|
62
|
+
this.currentAnimation = this.element.animate(t, {
|
|
63
|
+
duration: i.duration,
|
|
64
|
+
easing: i.easing,
|
|
65
|
+
delay: i.delay,
|
|
66
|
+
iterations: i.iterations === 1 / 0 ? 1 / 0 : i.iterations,
|
|
67
|
+
direction: i.direction,
|
|
68
|
+
fill: i.fill
|
|
69
|
+
}), this.currentAnimation.onfinish = () => s(this), (i.iterations === 1 / 0 || i.iterations <= 0) && s(this);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* 停止当前动画
|
|
74
|
+
*/
|
|
75
|
+
stop() {
|
|
76
|
+
return this.currentAnimation && (this.currentAnimation.cancel(), this.currentAnimation = null), this;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* 移除所有动效类
|
|
80
|
+
*/
|
|
81
|
+
reset() {
|
|
82
|
+
const e = Array.from(this.element.classList).filter((s) => s.startsWith("mk-"));
|
|
83
|
+
return this.element.classList.remove(...e), this;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* 设置元素样式变量
|
|
87
|
+
*/
|
|
88
|
+
vars(t) {
|
|
89
|
+
return q(this.element, t), this;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
class Ne {
|
|
93
|
+
constructor() {
|
|
94
|
+
c(this, "items", []);
|
|
95
|
+
c(this, "running", !1);
|
|
96
|
+
c(this, "abortController", null);
|
|
97
|
+
}
|
|
98
|
+
add(t, e, s) {
|
|
99
|
+
return this.items.push({
|
|
100
|
+
name: t,
|
|
101
|
+
target: e,
|
|
102
|
+
options: s,
|
|
103
|
+
at: (s == null ? void 0 : s.at) ?? this.estimateEndTime()
|
|
104
|
+
}), this;
|
|
105
|
+
}
|
|
106
|
+
estimateEndTime() {
|
|
107
|
+
var s;
|
|
108
|
+
if (this.items.length === 0) return 0;
|
|
109
|
+
const t = this.items[this.items.length - 1], e = ((s = t.options) == null ? void 0 : s.duration) ?? 500;
|
|
110
|
+
return (t.at ?? 0) + e;
|
|
111
|
+
}
|
|
112
|
+
async play() {
|
|
113
|
+
if (this.running) return;
|
|
114
|
+
this.running = !0, this.abortController = new AbortController();
|
|
115
|
+
const t = this.abortController.signal, e = this.items.map((s) => new Promise((i) => {
|
|
116
|
+
var h, p;
|
|
117
|
+
const o = typeof s.target == "string" ? document.querySelector(s.target) : s.target;
|
|
118
|
+
if (!o || t.aborted) {
|
|
119
|
+
i();
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const r = s.at ?? 0, a = ((h = s.options) == null ? void 0 : h.duration) ?? 500, l = ((p = s.options) == null ? void 0 : p.easing) ?? "ease", d = setTimeout(() => {
|
|
123
|
+
if (t.aborted) {
|
|
124
|
+
i();
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const u = `mk-animated mk-${s.name}`, m = o;
|
|
128
|
+
m.classList.add(...u.split(" ")), m.style.setProperty("--mk-duration", `${a}ms`), m.style.setProperty("--mk-easing", l);
|
|
129
|
+
const y = (g) => {
|
|
130
|
+
g.animationName.startsWith("mk-") && (m.removeEventListener("animationend", y), m.classList.remove(...u.split(" ")), m.style.removeProperty("--mk-duration"), m.style.removeProperty("--mk-easing"), i());
|
|
131
|
+
};
|
|
132
|
+
m.addEventListener("animationend", y), setTimeout(() => {
|
|
133
|
+
m.removeEventListener("animationend", y), m.classList.remove(...u.split(" ")), m.style.removeProperty("--mk-duration"), m.style.removeProperty("--mk-easing"), i();
|
|
134
|
+
}, a + 100);
|
|
135
|
+
}, r);
|
|
136
|
+
t.addEventListener("abort", () => {
|
|
137
|
+
clearTimeout(d), i();
|
|
138
|
+
});
|
|
139
|
+
}));
|
|
140
|
+
await Promise.all(e), this.running = !1;
|
|
141
|
+
}
|
|
142
|
+
stop() {
|
|
143
|
+
var t;
|
|
144
|
+
(t = this.abortController) == null || t.abort(), this.running = !1, this.items.forEach((e) => {
|
|
145
|
+
const s = typeof e.target == "string" ? document.querySelector(e.target) : e.target;
|
|
146
|
+
if (s) {
|
|
147
|
+
const i = s, o = `mk-animated mk-${e.name}`;
|
|
148
|
+
i.classList.remove(...o.split(" ")), i.style.removeProperty("--mk-duration"), i.style.removeProperty("--mk-easing");
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
clear() {
|
|
153
|
+
return this.stop(), this.items = [], this;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function b(n) {
|
|
157
|
+
return new F(n);
|
|
158
|
+
}
|
|
159
|
+
function et(n, t) {
|
|
160
|
+
return b(n).animate("fadeIn", t);
|
|
161
|
+
}
|
|
162
|
+
function st(n, t) {
|
|
163
|
+
return b(n).animate("fadeOut", t);
|
|
164
|
+
}
|
|
165
|
+
function it(n, t) {
|
|
166
|
+
return b(n).animate("slideInUp", t);
|
|
167
|
+
}
|
|
168
|
+
function nt(n, t) {
|
|
169
|
+
return b(n).animate("slideInDown", t);
|
|
170
|
+
}
|
|
171
|
+
function ot(n, t) {
|
|
172
|
+
return b(n).animate("slideInLeft", t);
|
|
173
|
+
}
|
|
174
|
+
function rt(n, t) {
|
|
175
|
+
return b(n).animate("slideInRight", t);
|
|
176
|
+
}
|
|
177
|
+
function at(n, t) {
|
|
178
|
+
return b(n).animate("slideOutUp", t);
|
|
179
|
+
}
|
|
180
|
+
function lt(n, t) {
|
|
181
|
+
return b(n).animate("slideOutDown", t);
|
|
182
|
+
}
|
|
183
|
+
function ct(n, t) {
|
|
184
|
+
return b(n).animate("zoomIn", t);
|
|
185
|
+
}
|
|
186
|
+
function dt(n, t) {
|
|
187
|
+
return b(n).animate("zoomOut", t);
|
|
188
|
+
}
|
|
189
|
+
function ht(n, t) {
|
|
190
|
+
return b(n).animate("bounceIn", t);
|
|
191
|
+
}
|
|
192
|
+
function pt(n, t) {
|
|
193
|
+
return b(n).animate("bounceOut", t);
|
|
194
|
+
}
|
|
195
|
+
function ut(n, t) {
|
|
196
|
+
return b(n).animate("flipInX", t);
|
|
197
|
+
}
|
|
198
|
+
function mt(n, t) {
|
|
199
|
+
return b(n).animate("flipInY", t);
|
|
200
|
+
}
|
|
201
|
+
function ft(n, t) {
|
|
202
|
+
return b(n).animate("shake", t);
|
|
203
|
+
}
|
|
204
|
+
function yt(n, t) {
|
|
205
|
+
return b(n).animate("pulse", t);
|
|
206
|
+
}
|
|
207
|
+
function gt(n, t) {
|
|
208
|
+
return b(n).animate("rotateIn", t);
|
|
209
|
+
}
|
|
210
|
+
const Pe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
211
|
+
__proto__: null,
|
|
212
|
+
bounceIn: ht,
|
|
213
|
+
bounceOut: pt,
|
|
214
|
+
fadeIn: et,
|
|
215
|
+
fadeOut: st,
|
|
216
|
+
flipInX: ut,
|
|
217
|
+
flipInY: mt,
|
|
218
|
+
pulse: yt,
|
|
219
|
+
rotateIn: gt,
|
|
220
|
+
shake: ft,
|
|
221
|
+
slideInDown: nt,
|
|
222
|
+
slideInLeft: ot,
|
|
223
|
+
slideInRight: rt,
|
|
224
|
+
slideInUp: it,
|
|
225
|
+
slideOutDown: lt,
|
|
226
|
+
slideOutUp: at,
|
|
227
|
+
zoomIn: ct,
|
|
228
|
+
zoomOut: dt
|
|
229
|
+
}, Symbol.toStringTag, { value: "Module" })), vt = {
|
|
230
|
+
threshold: 0.2,
|
|
231
|
+
rootMargin: "0px",
|
|
232
|
+
once: !0,
|
|
233
|
+
duration: 500,
|
|
234
|
+
easing: "ease"
|
|
235
|
+
};
|
|
236
|
+
class bt {
|
|
237
|
+
constructor() {
|
|
238
|
+
c(this, "observer", null);
|
|
239
|
+
c(this, "elements", /* @__PURE__ */ new Map());
|
|
240
|
+
}
|
|
241
|
+
watch(t, e, s = {}) {
|
|
242
|
+
const i = { ...vt, ...s };
|
|
243
|
+
let o;
|
|
244
|
+
return typeof t == "string" ? o = Array.from(document.querySelectorAll(t)) : Array.isArray(t) ? o = t : o = [t], this.observer || (this.observer = new IntersectionObserver(
|
|
245
|
+
(r) => this.handleEntries(r),
|
|
246
|
+
{
|
|
247
|
+
threshold: i.threshold,
|
|
248
|
+
rootMargin: i.rootMargin
|
|
249
|
+
}
|
|
250
|
+
)), o.forEach((r) => {
|
|
251
|
+
this.elements.set(r, { name: e, opts: i }), this.observer.observe(r);
|
|
252
|
+
}), this;
|
|
253
|
+
}
|
|
254
|
+
handleEntries(t) {
|
|
255
|
+
t.forEach((e) => {
|
|
256
|
+
var s;
|
|
257
|
+
if (e.isIntersecting) {
|
|
258
|
+
const i = this.elements.get(e.target);
|
|
259
|
+
if (!i) return;
|
|
260
|
+
const o = e.target, r = `mk-animated mk-${i.name}`;
|
|
261
|
+
o.classList.add(...r.split(" ")), o.style.setProperty("--mk-duration", `${i.opts.duration}ms`), o.style.setProperty("--mk-easing", i.opts.easing);
|
|
262
|
+
const a = (l) => {
|
|
263
|
+
l.animationName.startsWith("mk-") && (o.removeEventListener("animationend", a), i.opts.once && o.classList.remove(...r.split(" ")));
|
|
264
|
+
};
|
|
265
|
+
o.addEventListener("animationend", a), i.opts.once && ((s = this.observer) == null || s.unobserve(e.target), this.elements.delete(e.target));
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
destroy() {
|
|
270
|
+
var t;
|
|
271
|
+
(t = this.observer) == null || t.disconnect(), this.observer = null, this.elements.clear();
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
function qe(n, t, e) {
|
|
275
|
+
return new bt().watch(n, t, e);
|
|
276
|
+
}
|
|
277
|
+
const Et = {
|
|
278
|
+
speed: 80,
|
|
279
|
+
cursor: !0,
|
|
280
|
+
cursorChar: "|"
|
|
281
|
+
};
|
|
282
|
+
class kt {
|
|
283
|
+
constructor(t) {
|
|
284
|
+
c(this, "element");
|
|
285
|
+
c(this, "originalText", "");
|
|
286
|
+
c(this, "timer", null);
|
|
287
|
+
c(this, "running", !1);
|
|
288
|
+
if (this.element = typeof t == "string" ? document.querySelector(t) : t, !this.element)
|
|
289
|
+
throw new Error("Typewriter: element not found");
|
|
290
|
+
this.originalText = this.element.textContent ?? "";
|
|
291
|
+
}
|
|
292
|
+
async start(t = {}) {
|
|
293
|
+
if (this.running) return;
|
|
294
|
+
this.running = !0;
|
|
295
|
+
const e = { ...Et, ...t }, s = this.originalText || this.element.textContent || "";
|
|
296
|
+
return this.element.textContent = "", e.cursor && (this.element.style.borderRight = "2px solid currentColor", this.element.style.paddingRight = "2px", this.startCursorBlink()), new Promise((i) => {
|
|
297
|
+
let o = 0;
|
|
298
|
+
const r = () => {
|
|
299
|
+
var a;
|
|
300
|
+
if (!this.running) {
|
|
301
|
+
i();
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
o < s.length ? (this.element.textContent += s.charAt(o), o++, this.timer = setTimeout(r, e.speed)) : (this.running = !1, (a = e.onComplete) == null || a.call(e), i());
|
|
305
|
+
};
|
|
306
|
+
r();
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
stop() {
|
|
310
|
+
this.running = !1, this.timer && (clearTimeout(this.timer), this.timer = null);
|
|
311
|
+
}
|
|
312
|
+
reset() {
|
|
313
|
+
this.stop(), this.element.textContent = this.originalText, this.element.style.borderRight = "none", this.element.style.paddingRight = "0";
|
|
314
|
+
}
|
|
315
|
+
startCursorBlink() {
|
|
316
|
+
let t = !0;
|
|
317
|
+
const e = () => {
|
|
318
|
+
if (!this.running) {
|
|
319
|
+
this.element.style.borderRightColor = "transparent";
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
this.element.style.borderRightColor = t ? "currentColor" : "transparent", t = !t, setTimeout(e, 530);
|
|
323
|
+
};
|
|
324
|
+
e();
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
function De(n, t) {
|
|
328
|
+
const e = new kt(n);
|
|
329
|
+
return e.reset(), e.start(t);
|
|
330
|
+
}
|
|
331
|
+
const wt = {
|
|
332
|
+
duration: 2e3,
|
|
333
|
+
easing: "easeOut",
|
|
334
|
+
decimals: 0,
|
|
335
|
+
prefix: "",
|
|
336
|
+
suffix: "",
|
|
337
|
+
separator: ","
|
|
338
|
+
};
|
|
339
|
+
class xt {
|
|
340
|
+
constructor(t) {
|
|
341
|
+
c(this, "element");
|
|
342
|
+
c(this, "rafId", null);
|
|
343
|
+
if (this.element = typeof t == "string" ? document.querySelector(t) : t, !this.element)
|
|
344
|
+
throw new Error("CountUp: element not found");
|
|
345
|
+
}
|
|
346
|
+
animateTo(t, e = 0, s = {}) {
|
|
347
|
+
const i = { ...wt, ...s }, o = performance.now();
|
|
348
|
+
return new Promise((r) => {
|
|
349
|
+
const a = (l) => {
|
|
350
|
+
var m, y;
|
|
351
|
+
const d = l - o, h = Math.min(d / i.duration, 1), p = this.applyEasing(h, i.easing), u = e + (t - e) * p;
|
|
352
|
+
this.render(u, i), (m = i.onUpdate) == null || m.call(i, u), h < 1 ? this.rafId = requestAnimationFrame(a) : (this.render(t, i), (y = i.onComplete) == null || y.call(i), r());
|
|
353
|
+
};
|
|
354
|
+
this.rafId = requestAnimationFrame(a);
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
stop() {
|
|
358
|
+
this.rafId && (cancelAnimationFrame(this.rafId), this.rafId = null);
|
|
359
|
+
}
|
|
360
|
+
render(t, e) {
|
|
361
|
+
let s = t.toFixed(e.decimals);
|
|
362
|
+
if (e.separator) {
|
|
363
|
+
const i = s.split(".");
|
|
364
|
+
i[0] = i[0].replace(/\B(?=(\d{3})+(?!\d))/g, e.separator), s = i.join(".");
|
|
365
|
+
}
|
|
366
|
+
this.element.textContent = `${e.prefix}${s}${e.suffix}`;
|
|
367
|
+
}
|
|
368
|
+
applyEasing(t, e) {
|
|
369
|
+
switch (e) {
|
|
370
|
+
case "easeOut":
|
|
371
|
+
return 1 - Math.pow(1 - t, 3);
|
|
372
|
+
case "easeInOut":
|
|
373
|
+
return t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2;
|
|
374
|
+
default:
|
|
375
|
+
return t;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
function ze(n, t, e) {
|
|
380
|
+
return new xt(n).animateTo(t, 0, e);
|
|
381
|
+
}
|
|
382
|
+
const Ct = {
|
|
383
|
+
stiffness: 170,
|
|
384
|
+
damping: 26,
|
|
385
|
+
mass: 1,
|
|
386
|
+
precision: 0.01
|
|
387
|
+
};
|
|
388
|
+
function $(n, t = {}) {
|
|
389
|
+
const e = { ...Ct, ...t };
|
|
390
|
+
let s = 0, i = n.from, o, r = !0;
|
|
391
|
+
const a = () => {
|
|
392
|
+
var u;
|
|
393
|
+
if (!r) return;
|
|
394
|
+
const l = i - n.to, d = -e.stiffness * l, h = -e.damping * s, p = (d + h) / e.mass;
|
|
395
|
+
if (s += p * (1 / 60), i += s * (1 / 60), n.onUpdate(i), Math.abs(l) < e.precision && Math.abs(s) < e.precision) {
|
|
396
|
+
n.onUpdate(n.to), (u = n.onComplete) == null || u.call(n), r = !1;
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
o = requestAnimationFrame(a);
|
|
400
|
+
};
|
|
401
|
+
return o = requestAnimationFrame(a), () => {
|
|
402
|
+
r = !1, cancelAnimationFrame(o);
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
function Fe(n, t = 1, e) {
|
|
406
|
+
const s = typeof n == "string" ? document.querySelector(n) : n;
|
|
407
|
+
if (!s) throw new Error("elasticScale: element not found");
|
|
408
|
+
const i = getComputedStyle(s).transform;
|
|
409
|
+
let o = 1;
|
|
410
|
+
if (i !== "none") {
|
|
411
|
+
const r = new DOMMatrix(i);
|
|
412
|
+
o = Math.sqrt(r.a * r.a + r.b * r.b);
|
|
413
|
+
}
|
|
414
|
+
return $(
|
|
415
|
+
{
|
|
416
|
+
from: o,
|
|
417
|
+
to: t,
|
|
418
|
+
onUpdate: (r) => {
|
|
419
|
+
s.style.transform = `scale(${r})`;
|
|
420
|
+
}
|
|
421
|
+
},
|
|
422
|
+
e
|
|
423
|
+
);
|
|
424
|
+
}
|
|
425
|
+
function Re(n, t, e, s) {
|
|
426
|
+
const i = typeof n == "string" ? document.querySelector(n) : n;
|
|
427
|
+
if (!i) throw new Error("elasticMove: element not found");
|
|
428
|
+
let o = 0, r = 0;
|
|
429
|
+
const a = $(
|
|
430
|
+
{
|
|
431
|
+
from: 0,
|
|
432
|
+
to: t,
|
|
433
|
+
onUpdate: (d) => {
|
|
434
|
+
o = d, i.style.transform = `translate3d(${o}px, ${r}px, 0)`;
|
|
435
|
+
}
|
|
436
|
+
},
|
|
437
|
+
s
|
|
438
|
+
), l = $(
|
|
439
|
+
{
|
|
440
|
+
from: 0,
|
|
441
|
+
to: e,
|
|
442
|
+
onUpdate: (d) => {
|
|
443
|
+
r = d, i.style.transform = `translate3d(${o}px, ${r}px, 0)`;
|
|
444
|
+
}
|
|
445
|
+
},
|
|
446
|
+
s
|
|
447
|
+
);
|
|
448
|
+
return () => {
|
|
449
|
+
a(), l();
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
class Oe {
|
|
453
|
+
constructor(t, e = {}) {
|
|
454
|
+
c(this, "element");
|
|
455
|
+
c(this, "options");
|
|
456
|
+
c(this, "startX", 0);
|
|
457
|
+
c(this, "startY", 0);
|
|
458
|
+
c(this, "currentX", 0);
|
|
459
|
+
c(this, "currentY", 0);
|
|
460
|
+
c(this, "initialTransformX", 0);
|
|
461
|
+
c(this, "initialTransformY", 0);
|
|
462
|
+
c(this, "pointerId", null);
|
|
463
|
+
c(this, "onPointerDown", (t) => {
|
|
464
|
+
var s, i;
|
|
465
|
+
if (this.pointerId !== null) return;
|
|
466
|
+
this.pointerId = t.pointerId, this.element.setPointerCapture(t.pointerId), this.startX = t.clientX, this.startY = t.clientY;
|
|
467
|
+
const e = getComputedStyle(this.element).transform;
|
|
468
|
+
if (e !== "none") {
|
|
469
|
+
const o = new DOMMatrix(e);
|
|
470
|
+
this.initialTransformX = o.m41, this.initialTransformY = o.m42;
|
|
471
|
+
} else
|
|
472
|
+
this.initialTransformX = 0, this.initialTransformY = 0;
|
|
473
|
+
this.currentX = this.initialTransformX, this.currentY = this.initialTransformY, (i = (s = this.options).onStart) == null || i.call(s, t), this.element.addEventListener("pointermove", this.onPointerMove), this.element.addEventListener("pointerup", this.onPointerUp);
|
|
474
|
+
});
|
|
475
|
+
c(this, "onPointerMove", (t) => {
|
|
476
|
+
var r, a;
|
|
477
|
+
if (t.pointerId !== this.pointerId) return;
|
|
478
|
+
const e = t.clientX - this.startX, s = t.clientY - this.startY;
|
|
479
|
+
let i = this.initialTransformX + e, o = this.initialTransformY + s;
|
|
480
|
+
if (this.options.bounds) {
|
|
481
|
+
const l = typeof this.options.bounds == "string" ? document.querySelector(this.options.bounds) : this.options.bounds;
|
|
482
|
+
if (l) {
|
|
483
|
+
const d = l.getBoundingClientRect(), h = this.element.getBoundingClientRect(), p = d.left - h.left + i, u = d.right - h.right + i, m = d.top - h.top + o, y = d.bottom - h.bottom + o;
|
|
484
|
+
i = Math.max(p, Math.min(u, i)), o = Math.max(m, Math.min(y, o));
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
this.options.axis === "x" && (o = this.initialTransformY), this.options.axis === "y" && (i = this.initialTransformX), this.currentX = i, this.currentY = o, this.element.style.transform = `translate3d(${i}px, ${o}px, 0)`, (a = (r = this.options).onDrag) == null || a.call(r, i, o);
|
|
488
|
+
});
|
|
489
|
+
c(this, "onPointerUp", (t) => {
|
|
490
|
+
var e, s;
|
|
491
|
+
t.pointerId === this.pointerId && (this.pointerId = null, this.element.releasePointerCapture(t.pointerId), this.element.removeEventListener("pointermove", this.onPointerMove), this.element.removeEventListener("pointerup", this.onPointerUp), (s = (e = this.options).onEnd) == null || s.call(e, this.currentX, this.currentY));
|
|
492
|
+
});
|
|
493
|
+
if (this.element = typeof t == "string" ? document.querySelector(t) : t, !this.element)
|
|
494
|
+
throw new Error("Draggable: element not found");
|
|
495
|
+
this.options = {
|
|
496
|
+
axis: e.axis ?? "both",
|
|
497
|
+
bounds: e.bounds ?? null,
|
|
498
|
+
onStart: e.onStart,
|
|
499
|
+
onDrag: e.onDrag,
|
|
500
|
+
onEnd: e.onEnd
|
|
501
|
+
}, this.element.style.touchAction = "none", this.element.addEventListener("pointerdown", this.onPointerDown);
|
|
502
|
+
}
|
|
503
|
+
destroy() {
|
|
504
|
+
this.element.removeEventListener("pointerdown", this.onPointerDown), this.pointerId !== null && (this.element.releasePointerCapture(this.pointerId), this.pointerId = null);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
const R = {
|
|
508
|
+
color: "rgba(255, 255, 255, 0.35)",
|
|
509
|
+
duration: 600,
|
|
510
|
+
maxScale: 2.5
|
|
511
|
+
};
|
|
512
|
+
function He(n, t = {}) {
|
|
513
|
+
const e = typeof n == "string" ? document.querySelector(n) : n;
|
|
514
|
+
if (!e) throw new Error("addRipple: element not found");
|
|
515
|
+
e.style.position = "relative", e.style.overflow = "hidden";
|
|
516
|
+
const s = { ...R, ...t }, i = (o) => {
|
|
517
|
+
const r = e.getBoundingClientRect(), a = Math.max(r.width, r.height), l = o.clientX - r.left - a / 2, d = o.clientY - r.top - a / 2, h = document.createElement("span");
|
|
518
|
+
h.style.cssText = `
|
|
519
|
+
position: absolute;
|
|
520
|
+
border-radius: 50%;
|
|
521
|
+
background: ${s.color};
|
|
522
|
+
width: ${a}px;
|
|
523
|
+
height: ${a}px;
|
|
524
|
+
left: ${l}px;
|
|
525
|
+
top: ${d}px;
|
|
526
|
+
pointer-events: none;
|
|
527
|
+
transform: scale(0);
|
|
528
|
+
opacity: 1;
|
|
529
|
+
`, e.appendChild(h);
|
|
530
|
+
const p = h.animate(
|
|
531
|
+
[
|
|
532
|
+
{ transform: "scale(0)", opacity: 1 },
|
|
533
|
+
{ transform: `scale(${s.maxScale})`, opacity: 0 }
|
|
534
|
+
],
|
|
535
|
+
{
|
|
536
|
+
duration: s.duration,
|
|
537
|
+
easing: "ease-out"
|
|
538
|
+
}
|
|
539
|
+
);
|
|
540
|
+
p.onfinish = () => {
|
|
541
|
+
h.remove();
|
|
542
|
+
};
|
|
543
|
+
};
|
|
544
|
+
return e.addEventListener("click", i), () => {
|
|
545
|
+
e.removeEventListener("click", i);
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
function Ye(n, t = {}) {
|
|
549
|
+
const e = typeof n == "string" ? document.querySelector(n) : n;
|
|
550
|
+
if (!e) throw new Error("rippleEffect: element not found");
|
|
551
|
+
const s = { ...R, ...t }, i = e.getBoundingClientRect(), o = Math.max(i.width, i.height), r = document.createElement("span");
|
|
552
|
+
return r.style.cssText = `
|
|
553
|
+
position: absolute;
|
|
554
|
+
border-radius: 50%;
|
|
555
|
+
background: ${s.color};
|
|
556
|
+
width: ${o}px;
|
|
557
|
+
height: ${o}px;
|
|
558
|
+
left: ${i.width / 2 - o / 2}px;
|
|
559
|
+
top: ${i.height / 2 - o / 2}px;
|
|
560
|
+
pointer-events: none;
|
|
561
|
+
transform: scale(0);
|
|
562
|
+
opacity: 1;
|
|
563
|
+
`, e.style.position = "relative", e.style.overflow = "hidden", e.appendChild(r), new Promise((a) => {
|
|
564
|
+
const l = r.animate(
|
|
565
|
+
[
|
|
566
|
+
{ transform: "scale(0)", opacity: 1 },
|
|
567
|
+
{ transform: `scale(${s.maxScale})`, opacity: 0 }
|
|
568
|
+
],
|
|
569
|
+
{
|
|
570
|
+
duration: s.duration,
|
|
571
|
+
easing: "ease-out"
|
|
572
|
+
}
|
|
573
|
+
);
|
|
574
|
+
l.onfinish = () => {
|
|
575
|
+
r.remove(), a();
|
|
576
|
+
};
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
const Lt = {
|
|
580
|
+
y: -6,
|
|
581
|
+
scale: 1.02,
|
|
582
|
+
shadow: "0 12px 24px rgba(0,0,0,0.15)",
|
|
583
|
+
duration: 250,
|
|
584
|
+
easing: "cubic-bezier(0.25, 0.1, 0.25, 1)"
|
|
585
|
+
};
|
|
586
|
+
function Xe(n, t = {}) {
|
|
587
|
+
const e = typeof n == "string" ? document.querySelector(n) : n;
|
|
588
|
+
if (!e) throw new Error("hoverLift: element not found");
|
|
589
|
+
const s = { ...Lt, ...t };
|
|
590
|
+
e.style.transition = `transform ${s.duration}ms ${s.easing}, box-shadow ${s.duration}ms ${s.easing}`;
|
|
591
|
+
const i = () => {
|
|
592
|
+
e.style.transform = `translateY(${s.y}px) scale(${s.scale})`, e.style.boxShadow = s.shadow;
|
|
593
|
+
}, o = () => {
|
|
594
|
+
e.style.transform = "", e.style.boxShadow = "";
|
|
595
|
+
};
|
|
596
|
+
return e.addEventListener("mouseenter", i), e.addEventListener("mouseleave", o), () => {
|
|
597
|
+
e.removeEventListener("mouseenter", i), e.removeEventListener("mouseleave", o), e.style.transition = "", e.style.transform = "", e.style.boxShadow = "";
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
function Ue(n, t = "rgba(56, 189, 248, 0.4)", e) {
|
|
601
|
+
const s = typeof n == "string" ? document.querySelector(n) : n;
|
|
602
|
+
if (!s) throw new Error("hoverGlow: element not found");
|
|
603
|
+
const i = (e == null ? void 0 : e.duration) ?? 250, o = (e == null ? void 0 : e.easing) ?? "ease";
|
|
604
|
+
s.style.transition = `box-shadow ${i}ms ${o}`;
|
|
605
|
+
const r = () => {
|
|
606
|
+
s.style.boxShadow = `0 0 20px ${t}`;
|
|
607
|
+
}, a = () => {
|
|
608
|
+
s.style.boxShadow = "";
|
|
609
|
+
};
|
|
610
|
+
return s.addEventListener("mouseenter", r), s.addEventListener("mouseleave", a), () => {
|
|
611
|
+
s.removeEventListener("mouseenter", r), s.removeEventListener("mouseleave", a), s.style.transition = "", s.style.boxShadow = "";
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
const _t = {
|
|
615
|
+
count: 30,
|
|
616
|
+
speed: 6,
|
|
617
|
+
size: 6,
|
|
618
|
+
gravity: 0.3,
|
|
619
|
+
fadeOut: !0,
|
|
620
|
+
duration: 1e3
|
|
621
|
+
};
|
|
622
|
+
function Tt(n, t = {}) {
|
|
623
|
+
const e = typeof n == "string" ? document.querySelector(n) : n;
|
|
624
|
+
if (!e) throw new Error("particleBurst: element not found");
|
|
625
|
+
const s = { ..._t, ...t }, i = Array.isArray(s.color) ? s.color : [s.color ?? "#38bdf8"], o = e.getBoundingClientRect(), r = o.left + o.width / 2, a = o.top + o.height / 2, l = [];
|
|
626
|
+
for (let d = 0; d < s.count; d++) {
|
|
627
|
+
const h = Math.PI * 2 * d / s.count + Math.random() * 0.5, p = s.speed * (0.5 + Math.random() * 0.8), u = document.createElement("div");
|
|
628
|
+
u.style.cssText = `
|
|
629
|
+
position: fixed;
|
|
630
|
+
left: ${r}px;
|
|
631
|
+
top: ${a}px;
|
|
632
|
+
width: ${s.size}px;
|
|
633
|
+
height: ${s.size}px;
|
|
634
|
+
border-radius: 50%;
|
|
635
|
+
background: ${i[d % i.length]};
|
|
636
|
+
pointer-events: none;
|
|
637
|
+
z-index: 9999;
|
|
638
|
+
`, document.body.appendChild(u), l.push({
|
|
639
|
+
el: u,
|
|
640
|
+
vx: Math.cos(h) * p,
|
|
641
|
+
vy: Math.sin(h) * p,
|
|
642
|
+
x: r,
|
|
643
|
+
y: a,
|
|
644
|
+
life: 0,
|
|
645
|
+
maxLife: s.duration
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
return new Promise((d) => {
|
|
649
|
+
const h = performance.now(), p = (u) => {
|
|
650
|
+
const m = u - h;
|
|
651
|
+
let y = 0;
|
|
652
|
+
l.forEach((g) => {
|
|
653
|
+
g.life = m, g.vy += s.gravity, g.x += g.vx, g.y += g.vy;
|
|
654
|
+
const C = g.life / g.maxLife, G = s.fadeOut ? 1 - C : 1;
|
|
655
|
+
C < 1 && (y++, g.el.style.transform = `translate(${g.x - r}px, ${g.y - a}px)`, g.el.style.opacity = String(Math.max(0, G)));
|
|
656
|
+
}), y > 0 ? requestAnimationFrame(p) : (l.forEach((g) => g.el.remove()), d());
|
|
657
|
+
};
|
|
658
|
+
requestAnimationFrame(p);
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
function Be(n, t, e = {}) {
|
|
662
|
+
const s = document.createElement("div");
|
|
663
|
+
return s.style.position = "fixed", s.style.left = n + "px", s.style.top = t + "px", document.body.appendChild(s), Tt(s, e).finally(() => s.remove());
|
|
664
|
+
}
|
|
665
|
+
const St = {
|
|
666
|
+
type: "char",
|
|
667
|
+
stagger: 40,
|
|
668
|
+
duration: 500,
|
|
669
|
+
animation: "fadeUp"
|
|
670
|
+
}, At = {
|
|
671
|
+
fadeUp: { from: "opacity:0;transform:translateY(20px)", to: "opacity:1;transform:translateY(0)" },
|
|
672
|
+
fadeDown: { from: "opacity:0;transform:translateY(-20px)", to: "opacity:1;transform:translateY(0)" },
|
|
673
|
+
zoomIn: { from: "opacity:0;transform:scale(0.5)", to: "opacity:1;transform:scale(1)" },
|
|
674
|
+
rotateIn: { from: "opacity:0;transform:rotate(-180deg)", to: "opacity:1;transform:rotate(0)" },
|
|
675
|
+
slideLeft: { from: "opacity:0;transform:translateX(-30px)", to: "opacity:1;transform:translateX(0)" }
|
|
676
|
+
};
|
|
677
|
+
class $t {
|
|
678
|
+
constructor(t) {
|
|
679
|
+
c(this, "element");
|
|
680
|
+
c(this, "originalHTML");
|
|
681
|
+
if (this.element = typeof t == "string" ? document.querySelector(t) : t, !this.element)
|
|
682
|
+
throw new Error("TextSplit: element not found");
|
|
683
|
+
this.originalHTML = this.element.innerHTML;
|
|
684
|
+
}
|
|
685
|
+
async animate(t = {}) {
|
|
686
|
+
const e = { ...St, ...t }, s = At[e.animation], i = this.element.textContent ?? "";
|
|
687
|
+
this.element.innerHTML = "", this.element.style.display = "inline-block";
|
|
688
|
+
const o = e.type === "char" ? i.split("") : i.split(/(\s+)/), r = [];
|
|
689
|
+
return o.forEach((a) => {
|
|
690
|
+
const l = document.createElement("span");
|
|
691
|
+
l.textContent = a, l.style.display = "inline-block", l.style.cssText += s.from, l.style.transition = `all ${e.duration}ms cubic-bezier(0.34, 1.56, 0.64, 1)`, this.element.appendChild(l), r.push(l);
|
|
692
|
+
}), this.element.offsetHeight, new Promise((a) => {
|
|
693
|
+
let l = 0;
|
|
694
|
+
const d = r.length;
|
|
695
|
+
r.forEach((h, p) => {
|
|
696
|
+
setTimeout(() => {
|
|
697
|
+
h.style.cssText += s.to, setTimeout(() => {
|
|
698
|
+
l++, l >= d && a();
|
|
699
|
+
}, e.duration);
|
|
700
|
+
}, p * e.stagger);
|
|
701
|
+
});
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
reset() {
|
|
705
|
+
this.element.innerHTML = this.originalHTML, this.element.style.display = "";
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
function Ke(n, t) {
|
|
709
|
+
const e = new $t(n);
|
|
710
|
+
return e.reset(), e.animate(t);
|
|
711
|
+
}
|
|
712
|
+
const O = {
|
|
713
|
+
duration: 300,
|
|
714
|
+
intensity: 5,
|
|
715
|
+
color1: "#ff0040",
|
|
716
|
+
color2: "#00ffff"
|
|
717
|
+
};
|
|
718
|
+
function It(n, t = {}) {
|
|
719
|
+
const e = typeof n == "string" ? document.querySelector(n) : n;
|
|
720
|
+
if (!e) throw new Error("glitch: element not found");
|
|
721
|
+
const s = { ...O, ...t }, i = Math.min(Math.max(s.intensity, 1), 10), o = e.style.cssText, r = Math.floor(i * 2);
|
|
722
|
+
return new Promise((a) => {
|
|
723
|
+
let l = 0;
|
|
724
|
+
const d = s.duration / r, h = () => {
|
|
725
|
+
if (l >= r) {
|
|
726
|
+
e.style.cssText = o, e.style.textShadow = "", a();
|
|
727
|
+
return;
|
|
728
|
+
}
|
|
729
|
+
const p = (Math.random() - 0.5) * i * 4, u = `inset(${Math.random() * 80}% 0 ${Math.random() * 80}% 0)`, m = `${s.color1} ${p}px 0`, y = `${s.color2} ${-p}px 0`;
|
|
730
|
+
e.style.transform = `translateX(${p}px)`, e.style.clipPath = u, e.style.textShadow = `${m}, ${y}`, l++, setTimeout(h, d);
|
|
731
|
+
};
|
|
732
|
+
h();
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
function Ve(n, t = {}) {
|
|
736
|
+
const e = typeof n == "string" ? document.querySelector(n) : n;
|
|
737
|
+
if (!e) throw new Error("glitchLoop: element not found");
|
|
738
|
+
const s = { ...O, ...t }, i = e.style.cssText;
|
|
739
|
+
let o = !0;
|
|
740
|
+
const r = async () => {
|
|
741
|
+
o && (await It(e, { ...s, duration: 100 + Math.random() * 200 }), o && setTimeout(r, 200 + Math.random() * 800));
|
|
742
|
+
};
|
|
743
|
+
return r(), () => {
|
|
744
|
+
o = !1, e.style.cssText = i, e.style.textShadow = "", e.style.clipPath = "", e.style.transform = "";
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
const Mt = {
|
|
748
|
+
amplitude: 15,
|
|
749
|
+
frequency: 0.3,
|
|
750
|
+
speed: 0.08,
|
|
751
|
+
stagger: 0.15
|
|
752
|
+
};
|
|
753
|
+
class Nt {
|
|
754
|
+
constructor(t) {
|
|
755
|
+
c(this, "element");
|
|
756
|
+
c(this, "spans", []);
|
|
757
|
+
c(this, "rafId", null);
|
|
758
|
+
c(this, "originalHTML");
|
|
759
|
+
if (this.element = typeof t == "string" ? document.querySelector(t) : t, !this.element)
|
|
760
|
+
throw new Error("WaveText: element not found");
|
|
761
|
+
this.originalHTML = this.element.innerHTML;
|
|
762
|
+
}
|
|
763
|
+
start(t = {}) {
|
|
764
|
+
this.stop();
|
|
765
|
+
const e = { ...Mt, ...t }, s = this.element.textContent ?? "";
|
|
766
|
+
this.element.innerHTML = "", this.element.style.display = "inline-block";
|
|
767
|
+
const i = s.split("");
|
|
768
|
+
this.spans = i.map((a) => {
|
|
769
|
+
const l = document.createElement("span");
|
|
770
|
+
return l.textContent = a === " " ? " " : a, l.style.display = "inline-block", l.style.transition = "transform 0.1s linear", this.element.appendChild(l), l;
|
|
771
|
+
});
|
|
772
|
+
let o = 0;
|
|
773
|
+
const r = () => {
|
|
774
|
+
o += e.speed, this.spans.forEach((a, l) => {
|
|
775
|
+
const d = l * e.stagger, h = Math.sin(o + d) * e.amplitude;
|
|
776
|
+
a.style.transform = `translateY(${h}px)`;
|
|
777
|
+
}), this.rafId = requestAnimationFrame(r);
|
|
778
|
+
};
|
|
779
|
+
this.rafId = requestAnimationFrame(r);
|
|
780
|
+
}
|
|
781
|
+
stop() {
|
|
782
|
+
this.rafId && (cancelAnimationFrame(this.rafId), this.rafId = null);
|
|
783
|
+
}
|
|
784
|
+
reset() {
|
|
785
|
+
this.stop(), this.element.innerHTML = this.originalHTML, this.element.style.display = "";
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
function We(n, t) {
|
|
789
|
+
const e = new Nt(n);
|
|
790
|
+
return e.start(t), () => e.stop();
|
|
791
|
+
}
|
|
792
|
+
const Pt = {
|
|
793
|
+
speed: 0.3,
|
|
794
|
+
direction: "vertical"
|
|
795
|
+
};
|
|
796
|
+
function qt(n, t = {}) {
|
|
797
|
+
const e = typeof n == "string" ? document.querySelector(n) : n;
|
|
798
|
+
if (!e) throw new Error("parallax: element not found");
|
|
799
|
+
const s = { ...Pt, ...t }, i = () => {
|
|
800
|
+
const o = e.getBoundingClientRect(), r = window.innerHeight, l = (o.top + o.height / 2 - r / 2) * s.speed;
|
|
801
|
+
s.direction === "vertical" ? e.style.transform = `translateY(${l}px)` : e.style.transform = `translateX(${l}px)`;
|
|
802
|
+
};
|
|
803
|
+
return window.addEventListener("scroll", i, { passive: !0 }), i(), () => {
|
|
804
|
+
window.removeEventListener("scroll", i), e.style.transform = "";
|
|
805
|
+
};
|
|
806
|
+
}
|
|
807
|
+
function je(n) {
|
|
808
|
+
const t = n.map(
|
|
809
|
+
(e) => qt(e.selector, { speed: e.speed, direction: e.direction })
|
|
810
|
+
);
|
|
811
|
+
return () => t.forEach((e) => e());
|
|
812
|
+
}
|
|
813
|
+
const Dt = {
|
|
814
|
+
duration: 1500,
|
|
815
|
+
color: "rgba(255,255,255,0.25)",
|
|
816
|
+
angle: 100
|
|
817
|
+
};
|
|
818
|
+
function zt(n, t = {}) {
|
|
819
|
+
const e = typeof n == "string" ? document.querySelector(n) : n;
|
|
820
|
+
if (!e) throw new Error("shimmer: element not found");
|
|
821
|
+
const s = { ...Dt, ...t };
|
|
822
|
+
e.style.background = "#1e293b", e.style.position = "relative", e.style.overflow = "hidden";
|
|
823
|
+
const i = document.createElement("div");
|
|
824
|
+
if (i.style.cssText = `
|
|
825
|
+
position: absolute;
|
|
826
|
+
inset: 0;
|
|
827
|
+
background: linear-gradient(${s.angle}deg, transparent 30%, ${s.color} 50%, transparent 70%);
|
|
828
|
+
background-size: 200% 100%;
|
|
829
|
+
animation: mk-shimmer ${s.duration}ms infinite linear;
|
|
830
|
+
pointer-events: none;
|
|
831
|
+
`, !document.getElementById("mk-shimmer-style")) {
|
|
832
|
+
const o = document.createElement("style");
|
|
833
|
+
o.id = "mk-shimmer-style", o.textContent = `
|
|
834
|
+
@keyframes mk-shimmer {
|
|
835
|
+
0% { background-position: 200% 0; }
|
|
836
|
+
100% { background-position: -200% 0; }
|
|
837
|
+
}
|
|
838
|
+
`, document.head.appendChild(o);
|
|
839
|
+
}
|
|
840
|
+
return e.appendChild(i), () => {
|
|
841
|
+
i.remove(), e.style.background = "", e.style.position = "", e.style.overflow = "";
|
|
842
|
+
};
|
|
843
|
+
}
|
|
844
|
+
function Ge(n, t = 3, e) {
|
|
845
|
+
const s = typeof n == "string" ? document.querySelector(n) : n;
|
|
846
|
+
if (!s) throw new Error("skeleton: container not found");
|
|
847
|
+
const i = s.innerHTML;
|
|
848
|
+
s.innerHTML = "", s.style.display = "flex", s.style.flexDirection = "column", s.style.gap = "12px";
|
|
849
|
+
const o = [];
|
|
850
|
+
for (let r = 0; r < t; r++) {
|
|
851
|
+
const a = document.createElement("div");
|
|
852
|
+
a.style.height = r === 0 ? "24px" : "16px", a.style.width = r === t - 1 ? "60%" : "100%", a.style.borderRadius = "4px", s.appendChild(a), o.push(zt(a, e));
|
|
853
|
+
}
|
|
854
|
+
return () => {
|
|
855
|
+
o.forEach((r) => r()), s.innerHTML = i, s.style.display = "", s.style.flexDirection = "", s.style.gap = "";
|
|
856
|
+
};
|
|
857
|
+
}
|
|
858
|
+
const H = {
|
|
859
|
+
duration: 800,
|
|
860
|
+
blurStart: 10,
|
|
861
|
+
stagger: 100
|
|
862
|
+
};
|
|
863
|
+
function Je(n, t = {}) {
|
|
864
|
+
const e = typeof n == "string" ? document.querySelector(n) : n;
|
|
865
|
+
if (!e) throw new Error("blurReveal: element not found");
|
|
866
|
+
const s = { ...H, ...t };
|
|
867
|
+
return e.style.filter = `blur(${s.blurStart}px)`, e.style.opacity = "0", e.style.transition = `filter ${s.duration}ms ease, opacity ${s.duration}ms ease`, e.offsetHeight, new Promise((i) => {
|
|
868
|
+
e.style.filter = "blur(0px)", e.style.opacity = "1", setTimeout(() => {
|
|
869
|
+
e.style.transition = "", i();
|
|
870
|
+
}, s.duration);
|
|
871
|
+
});
|
|
872
|
+
}
|
|
873
|
+
function Ze(n, t = {}) {
|
|
874
|
+
const e = typeof n == "string" ? document.querySelector(n) : n;
|
|
875
|
+
if (!e) throw new Error("blurRevealChildren: element not found");
|
|
876
|
+
const s = { ...H, ...t }, i = s.childSelector ? Array.from(e.querySelectorAll(s.childSelector)) : Array.from(e.children);
|
|
877
|
+
return i.forEach((o) => {
|
|
878
|
+
const r = o;
|
|
879
|
+
r.style.filter = `blur(${s.blurStart}px)`, r.style.opacity = "0", r.style.transition = `filter ${s.duration}ms ease, opacity ${s.duration}ms ease`;
|
|
880
|
+
}), e.offsetHeight, new Promise((o) => {
|
|
881
|
+
let r = 0;
|
|
882
|
+
i.forEach((a, l) => {
|
|
883
|
+
setTimeout(() => {
|
|
884
|
+
const d = a;
|
|
885
|
+
d.style.filter = "blur(0px)", d.style.opacity = "1", setTimeout(() => {
|
|
886
|
+
d.style.transition = "", r++, r >= i.length && o();
|
|
887
|
+
}, s.duration);
|
|
888
|
+
}, l * s.stagger);
|
|
889
|
+
});
|
|
890
|
+
});
|
|
891
|
+
}
|
|
892
|
+
const Ft = {
|
|
893
|
+
threshold: 0.1,
|
|
894
|
+
rootMargin: "50px",
|
|
895
|
+
blur: !0,
|
|
896
|
+
placeholder: "#1e293b"
|
|
897
|
+
};
|
|
898
|
+
function Rt(n, t = {}) {
|
|
899
|
+
const e = typeof n == "string" ? document.querySelector(n) : n;
|
|
900
|
+
if (!e) throw new Error("lazyImage: image not found");
|
|
901
|
+
const s = { ...Ft, ...t };
|
|
902
|
+
if (!e.dataset.src)
|
|
903
|
+
return console.warn("lazyImage: img 缺少 data-src 属性"), () => {
|
|
904
|
+
};
|
|
905
|
+
e.style.background = s.placeholder, e.style.transition = "opacity 0.6s ease, filter 0.6s ease", s.blur ? (e.style.filter = "blur(8px)", e.style.opacity = "0.5") : e.style.opacity = "0";
|
|
906
|
+
const o = new IntersectionObserver(
|
|
907
|
+
(r) => {
|
|
908
|
+
r.forEach((a) => {
|
|
909
|
+
if (a.isIntersecting) {
|
|
910
|
+
const l = a.target, d = l.dataset.src, h = new Image();
|
|
911
|
+
h.onload = () => {
|
|
912
|
+
l.src = d, l.style.opacity = "1", l.style.filter = "blur(0px)", l.style.background = "";
|
|
913
|
+
}, h.onerror = () => {
|
|
914
|
+
l.style.opacity = "1", l.style.filter = "blur(0px)";
|
|
915
|
+
}, h.src = d, o.unobserve(l);
|
|
916
|
+
}
|
|
917
|
+
});
|
|
918
|
+
},
|
|
919
|
+
{ threshold: s.threshold, rootMargin: s.rootMargin }
|
|
920
|
+
);
|
|
921
|
+
return o.observe(e), () => o.disconnect();
|
|
922
|
+
}
|
|
923
|
+
function Qe(n = "img[data-src]") {
|
|
924
|
+
const t = document.querySelectorAll(n), e = Array.from(t).map((s) => Rt(s));
|
|
925
|
+
return () => e.forEach((s) => s());
|
|
926
|
+
}
|
|
927
|
+
const Y = {
|
|
928
|
+
duration: 300,
|
|
929
|
+
easing: "ease-in-out"
|
|
930
|
+
};
|
|
931
|
+
function Ot(n, t = {}) {
|
|
932
|
+
const e = typeof n == "string" ? document.querySelector(n) : n;
|
|
933
|
+
if (!e) throw new Error("expand: element not found");
|
|
934
|
+
const s = { ...Y, ...t };
|
|
935
|
+
e.style.overflow = "hidden", e.style.display = "";
|
|
936
|
+
const i = e.scrollHeight;
|
|
937
|
+
return e.style.height = "0px", e.style.opacity = "0", e.style.transition = `height ${s.duration}ms ${s.easing}, opacity ${s.duration}ms ${s.easing}`, new Promise((o) => {
|
|
938
|
+
requestAnimationFrame(() => {
|
|
939
|
+
e.style.height = `${i}px`, e.style.opacity = "1", setTimeout(() => {
|
|
940
|
+
e.style.height = "", e.style.overflow = "", e.style.transition = "", e.style.opacity = "", o();
|
|
941
|
+
}, s.duration);
|
|
942
|
+
});
|
|
943
|
+
});
|
|
944
|
+
}
|
|
945
|
+
function Ht(n, t = {}) {
|
|
946
|
+
const e = typeof n == "string" ? document.querySelector(n) : n;
|
|
947
|
+
if (!e) throw new Error("collapse: element not found");
|
|
948
|
+
const s = { ...Y, ...t }, i = e.scrollHeight;
|
|
949
|
+
return e.style.overflow = "hidden", e.style.height = `${i}px`, e.style.transition = `height ${s.duration}ms ${s.easing}, opacity ${s.duration}ms ${s.easing}`, new Promise((o) => {
|
|
950
|
+
requestAnimationFrame(() => {
|
|
951
|
+
e.style.height = "0px", e.style.opacity = "0", setTimeout(() => {
|
|
952
|
+
e.style.display = "none", e.style.height = "", e.style.overflow = "", e.style.transition = "", e.style.opacity = "", o();
|
|
953
|
+
}, s.duration);
|
|
954
|
+
});
|
|
955
|
+
});
|
|
956
|
+
}
|
|
957
|
+
async function ts(n, t) {
|
|
958
|
+
const e = typeof n == "string" ? document.querySelector(n) : n;
|
|
959
|
+
if (!e) throw new Error("toggleCollapse: element not found");
|
|
960
|
+
return getComputedStyle(e).display === "none" || e.offsetHeight === 0 ? (await Ot(e, t), !0) : (await Ht(e, t), !1);
|
|
961
|
+
}
|
|
962
|
+
const Yt = {
|
|
963
|
+
stagger: 60,
|
|
964
|
+
duration: 400,
|
|
965
|
+
animation: "fadeUp"
|
|
966
|
+
}, Xt = {
|
|
967
|
+
fadeUp: {
|
|
968
|
+
from: "opacity:0;transform:translate3d(0,16px,0)",
|
|
969
|
+
to: "opacity:1;transform:translate3d(0,0,0)"
|
|
970
|
+
},
|
|
971
|
+
fadeDown: {
|
|
972
|
+
from: "opacity:0;transform:translate3d(0,-16px,0)",
|
|
973
|
+
to: "opacity:1;transform:translate3d(0,0,0)"
|
|
974
|
+
},
|
|
975
|
+
fadeLeft: {
|
|
976
|
+
from: "opacity:0;transform:translate3d(16px,0,0)",
|
|
977
|
+
to: "opacity:1;transform:translate3d(0,0,0)"
|
|
978
|
+
},
|
|
979
|
+
fadeRight: {
|
|
980
|
+
from: "opacity:0;transform:translate3d(-16px,0,0)",
|
|
981
|
+
to: "opacity:1;transform:translate3d(0,0,0)"
|
|
982
|
+
},
|
|
983
|
+
zoom: {
|
|
984
|
+
from: "opacity:0;transform:scale3d(0.9,0.9,0.9)",
|
|
985
|
+
to: "opacity:1;transform:scale3d(1,1,1)"
|
|
986
|
+
}
|
|
987
|
+
};
|
|
988
|
+
function es(n, t = {}) {
|
|
989
|
+
const e = typeof n == "string" ? document.querySelector(n) : n;
|
|
990
|
+
if (!e) throw new Error("listStagger: container not found");
|
|
991
|
+
const s = { ...Yt, ...t }, i = Xt[s.animation], o = Array.from(e.children);
|
|
992
|
+
return o.forEach((r) => {
|
|
993
|
+
r.style.cssText += i.from;
|
|
994
|
+
}), e.offsetHeight, new Promise((r) => {
|
|
995
|
+
let a = 0;
|
|
996
|
+
o.forEach((l, d) => {
|
|
997
|
+
setTimeout(() => {
|
|
998
|
+
l.style.transition = `all ${s.duration}ms cubic-bezier(0.25, 0.1, 0.25, 1)`, l.style.cssText += i.to, setTimeout(() => {
|
|
999
|
+
l.style.transition = "", a++, a >= o.length && r();
|
|
1000
|
+
}, s.duration);
|
|
1001
|
+
}, d * s.stagger);
|
|
1002
|
+
});
|
|
1003
|
+
});
|
|
1004
|
+
}
|
|
1005
|
+
const X = {
|
|
1006
|
+
size: 40,
|
|
1007
|
+
color: "#38bdf8",
|
|
1008
|
+
thickness: 3
|
|
1009
|
+
};
|
|
1010
|
+
function ss(n, t = {}) {
|
|
1011
|
+
const e = typeof n == "string" ? document.querySelector(n) : n;
|
|
1012
|
+
if (!e) throw new Error("showLoading: element not found");
|
|
1013
|
+
const s = { ...X, ...t };
|
|
1014
|
+
e.style.position = "relative";
|
|
1015
|
+
const i = document.createElement("div");
|
|
1016
|
+
i.className = "mk-loading-mask", i.style.cssText = `
|
|
1017
|
+
position: absolute;
|
|
1018
|
+
inset: 0;
|
|
1019
|
+
background: rgba(15, 23, 42, 0.7);
|
|
1020
|
+
display: flex;
|
|
1021
|
+
align-items: center;
|
|
1022
|
+
justify-content: center;
|
|
1023
|
+
z-index: 100;
|
|
1024
|
+
border-radius: inherit;
|
|
1025
|
+
`;
|
|
1026
|
+
const o = document.createElement("div");
|
|
1027
|
+
return o.className = "mk-transition mk-spin", o.style.cssText = `
|
|
1028
|
+
width: ${s.size}px;
|
|
1029
|
+
height: ${s.size}px;
|
|
1030
|
+
border: ${s.thickness}px solid rgba(255,255,255,0.1);
|
|
1031
|
+
border-top-color: ${s.color};
|
|
1032
|
+
border-radius: 50%;
|
|
1033
|
+
`, i.appendChild(o), e.appendChild(i), () => {
|
|
1034
|
+
i.remove();
|
|
1035
|
+
};
|
|
1036
|
+
}
|
|
1037
|
+
function is(n = {}) {
|
|
1038
|
+
const t = { ...X, ...n }, e = document.createElement("div");
|
|
1039
|
+
e.style.cssText = `
|
|
1040
|
+
position: fixed;
|
|
1041
|
+
inset: 0;
|
|
1042
|
+
background: rgba(0, 0, 0, 0.5);
|
|
1043
|
+
display: flex;
|
|
1044
|
+
align-items: center;
|
|
1045
|
+
justify-content: center;
|
|
1046
|
+
z-index: 9999;
|
|
1047
|
+
`;
|
|
1048
|
+
const s = document.createElement("div");
|
|
1049
|
+
return s.className = "mk-transition mk-spin", s.style.cssText = `
|
|
1050
|
+
width: ${t.size}px;
|
|
1051
|
+
height: ${t.size}px;
|
|
1052
|
+
border: ${t.thickness}px solid rgba(255,255,255,0.15);
|
|
1053
|
+
border-top-color: ${t.color};
|
|
1054
|
+
border-radius: 50%;
|
|
1055
|
+
`, e.appendChild(s), document.body.appendChild(e), () => {
|
|
1056
|
+
e.remove();
|
|
1057
|
+
};
|
|
1058
|
+
}
|
|
1059
|
+
const U = {
|
|
1060
|
+
duration: 3e3,
|
|
1061
|
+
type: "info",
|
|
1062
|
+
position: "top"
|
|
1063
|
+
}, B = {
|
|
1064
|
+
info: { bg: "#38bdf8", icon: "ℹ️" },
|
|
1065
|
+
success: { bg: "#34d399", icon: "✅" },
|
|
1066
|
+
warning: { bg: "#fbbf24", icon: "⚠️" },
|
|
1067
|
+
error: { bg: "#f87171", icon: "❌" }
|
|
1068
|
+
}, K = {
|
|
1069
|
+
top: "top:20px;left:50%;transform:translateX(-50%)",
|
|
1070
|
+
"top-right": "top:20px;right:20px",
|
|
1071
|
+
"top-left": "top:20px;left:20px",
|
|
1072
|
+
bottom: "bottom:20px;left:50%;transform:translateX(-50%)",
|
|
1073
|
+
"bottom-right": "bottom:20px;right:20px",
|
|
1074
|
+
"bottom-left": "bottom:20px;left:20px"
|
|
1075
|
+
};
|
|
1076
|
+
function I(n, t = {}) {
|
|
1077
|
+
const e = { ...U, ...t }, s = B[e.type], i = K[e.position], o = document.createElement("div");
|
|
1078
|
+
o.style.cssText = `
|
|
1079
|
+
position: fixed;
|
|
1080
|
+
${i};
|
|
1081
|
+
background: ${s.bg};
|
|
1082
|
+
color: #fff;
|
|
1083
|
+
padding: 12px 20px;
|
|
1084
|
+
border-radius: 8px;
|
|
1085
|
+
font-size: 0.9rem;
|
|
1086
|
+
display: flex;
|
|
1087
|
+
align-items: center;
|
|
1088
|
+
gap: 8px;
|
|
1089
|
+
z-index: 9999;
|
|
1090
|
+
box-shadow: 0 4px 20px rgba(0,0,0,0.3);
|
|
1091
|
+
opacity: 0;
|
|
1092
|
+
transform: translateY(-20px);
|
|
1093
|
+
transition: all 0.3s ease;
|
|
1094
|
+
pointer-events: none;
|
|
1095
|
+
`, o.innerHTML = `<span>${s.icon}</span><span>${n}</span>`, document.body.appendChild(o), requestAnimationFrame(() => {
|
|
1096
|
+
o.style.opacity = "1", o.style.transform = (e.position.startsWith("bottom"), "translateY(0)");
|
|
1097
|
+
});
|
|
1098
|
+
const r = setTimeout(() => {
|
|
1099
|
+
o.style.opacity = "0", o.style.transform = e.position.startsWith("bottom") ? "translateY(20px)" : "translateY(-20px)", setTimeout(() => o.remove(), 300);
|
|
1100
|
+
}, e.duration);
|
|
1101
|
+
return () => {
|
|
1102
|
+
clearTimeout(r), o.remove();
|
|
1103
|
+
};
|
|
1104
|
+
}
|
|
1105
|
+
function ns(n, t) {
|
|
1106
|
+
return I(n, { ...t, type: "success" });
|
|
1107
|
+
}
|
|
1108
|
+
function os(n, t) {
|
|
1109
|
+
return I(n, { ...t, type: "error" });
|
|
1110
|
+
}
|
|
1111
|
+
function rs(n, t) {
|
|
1112
|
+
return I(n, { ...t, type: "warning" });
|
|
1113
|
+
}
|
|
1114
|
+
function as(n, t, e = {}) {
|
|
1115
|
+
const s = { ...U, ...e }, i = B[s.type], o = K[s.position], r = document.createElement("div");
|
|
1116
|
+
r.style.cssText = `
|
|
1117
|
+
position: fixed;
|
|
1118
|
+
${o};
|
|
1119
|
+
background: #1e293b;
|
|
1120
|
+
border-left: 4px solid ${i.bg};
|
|
1121
|
+
color: #e2e8f0;
|
|
1122
|
+
padding: 16px 20px;
|
|
1123
|
+
border-radius: 8px;
|
|
1124
|
+
font-size: 0.9rem;
|
|
1125
|
+
z-index: 9999;
|
|
1126
|
+
box-shadow: 0 4px 20px rgba(0,0,0,0.3);
|
|
1127
|
+
min-width: 280px;
|
|
1128
|
+
opacity: 0;
|
|
1129
|
+
transform: translateX(30px);
|
|
1130
|
+
transition: all 0.3s ease;
|
|
1131
|
+
`, r.innerHTML = `
|
|
1132
|
+
<div style="font-weight:600;margin-bottom:4px;color:${i.bg};">${i.icon} ${n}</div>
|
|
1133
|
+
<div style="color:#94a3b8;font-size:0.85rem;">${t}</div>
|
|
1134
|
+
`, document.body.appendChild(r), requestAnimationFrame(() => {
|
|
1135
|
+
r.style.opacity = "1", r.style.transform = "translateX(0)";
|
|
1136
|
+
});
|
|
1137
|
+
const a = setTimeout(() => {
|
|
1138
|
+
r.style.opacity = "0", r.style.transform = "translateX(30px)", setTimeout(() => r.remove(), 300);
|
|
1139
|
+
}, s.duration);
|
|
1140
|
+
return () => {
|
|
1141
|
+
clearTimeout(a), r.remove();
|
|
1142
|
+
};
|
|
1143
|
+
}
|
|
1144
|
+
const V = {
|
|
1145
|
+
strength: 0.4,
|
|
1146
|
+
radius: 150
|
|
1147
|
+
};
|
|
1148
|
+
function ls(n, t = {}) {
|
|
1149
|
+
const e = typeof n == "string" ? document.querySelector(n) : n;
|
|
1150
|
+
if (!e) throw new Error("magnetic: element not found");
|
|
1151
|
+
const s = { ...V, ...t };
|
|
1152
|
+
e.style.transition = "transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1)";
|
|
1153
|
+
const i = (r) => {
|
|
1154
|
+
const a = e.getBoundingClientRect(), l = a.left + a.width / 2, d = a.top + a.height / 2, h = r.clientX - l, p = r.clientY - d, u = Math.sqrt(h * h + p * p);
|
|
1155
|
+
if (u < s.radius) {
|
|
1156
|
+
const m = 1 - u / s.radius, y = h * s.strength * m, g = p * s.strength * m;
|
|
1157
|
+
e.style.transform = `translate(${y}px, ${g}px)`;
|
|
1158
|
+
} else
|
|
1159
|
+
e.style.transform = "";
|
|
1160
|
+
}, o = () => {
|
|
1161
|
+
e.style.transform = "";
|
|
1162
|
+
};
|
|
1163
|
+
return document.addEventListener("mousemove", i), e.addEventListener("mouseleave", o), () => {
|
|
1164
|
+
document.removeEventListener("mousemove", i), e.removeEventListener("mouseleave", o), e.style.transform = "", e.style.transition = "";
|
|
1165
|
+
};
|
|
1166
|
+
}
|
|
1167
|
+
function cs(n, t = {}) {
|
|
1168
|
+
const e = typeof n == "string" ? document.querySelector(n) : n;
|
|
1169
|
+
if (!e) throw new Error("magneticText: element not found");
|
|
1170
|
+
const s = e.textContent ?? "";
|
|
1171
|
+
e.innerHTML = "", e.style.display = "inline-block";
|
|
1172
|
+
const i = [];
|
|
1173
|
+
s.split("").forEach((l) => {
|
|
1174
|
+
const d = document.createElement("span");
|
|
1175
|
+
d.textContent = l === " " ? " " : l, d.style.display = "inline-block", d.style.transition = "transform 0.3s ease", e.appendChild(d), i.push(d);
|
|
1176
|
+
});
|
|
1177
|
+
const o = { ...V, ...t }, r = (l) => {
|
|
1178
|
+
i.forEach((d) => {
|
|
1179
|
+
const h = d.getBoundingClientRect(), p = h.left + h.width / 2, u = h.top + h.height / 2, m = l.clientX - p, y = l.clientY - u, g = Math.sqrt(m * m + y * y);
|
|
1180
|
+
if (g < o.radius) {
|
|
1181
|
+
const C = 1 - g / o.radius;
|
|
1182
|
+
d.style.transform = `translate(${m * o.strength * C}px, ${y * o.strength * C}px)`;
|
|
1183
|
+
} else
|
|
1184
|
+
d.style.transform = "";
|
|
1185
|
+
});
|
|
1186
|
+
}, a = () => {
|
|
1187
|
+
i.forEach((l) => l.style.transform = "");
|
|
1188
|
+
};
|
|
1189
|
+
return document.addEventListener("mousemove", r), e.addEventListener("mouseleave", a), () => {
|
|
1190
|
+
document.removeEventListener("mousemove", r), e.removeEventListener("mouseleave", a);
|
|
1191
|
+
};
|
|
1192
|
+
}
|
|
1193
|
+
const Ut = {
|
|
1194
|
+
perspective: 800,
|
|
1195
|
+
rotateY: 45,
|
|
1196
|
+
spacing: 60,
|
|
1197
|
+
scale: 1.15
|
|
1198
|
+
};
|
|
1199
|
+
class Bt {
|
|
1200
|
+
constructor(t, e, s = {}) {
|
|
1201
|
+
c(this, "container");
|
|
1202
|
+
c(this, "cards");
|
|
1203
|
+
c(this, "currentIndex", 0);
|
|
1204
|
+
c(this, "options");
|
|
1205
|
+
if (this.container = typeof t == "string" ? document.querySelector(t) : t, !this.container)
|
|
1206
|
+
throw new Error("CoverFlow: container not found");
|
|
1207
|
+
this.cards = Array.from(this.container.querySelectorAll(e)), this.options = { ...Ut, ...s }, this.container.style.perspective = `${this.options.perspective}px`, this.container.style.transformStyle = "preserve-3d", this.update();
|
|
1208
|
+
}
|
|
1209
|
+
goTo(t) {
|
|
1210
|
+
return this.currentIndex = Math.max(0, Math.min(t, this.cards.length - 1)), this.update(), this;
|
|
1211
|
+
}
|
|
1212
|
+
next() {
|
|
1213
|
+
return this.goTo(this.currentIndex + 1);
|
|
1214
|
+
}
|
|
1215
|
+
prev() {
|
|
1216
|
+
return this.goTo(this.currentIndex - 1);
|
|
1217
|
+
}
|
|
1218
|
+
update() {
|
|
1219
|
+
this.cards.forEach((t, e) => {
|
|
1220
|
+
const s = e - this.currentIndex, i = Math.abs(s);
|
|
1221
|
+
let o = s * this.options.spacing, r = s > 0 ? -this.options.rotateY : this.options.rotateY, a = 1, l = this.cards.length - i, d = 1;
|
|
1222
|
+
s === 0 ? (r = 0, a = this.options.scale, l = this.cards.length + 1) : i > 2 ? (d = 0, l = 0) : d = 1 - i * 0.3, t.style.transition = "all 0.5s cubic-bezier(0.25, 0.1, 0.25, 1)", t.style.transform = `translateX(${o}px) rotateY(${r}deg) scale(${a})`, t.style.zIndex = String(l), t.style.opacity = String(d);
|
|
1223
|
+
});
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
function ds(n, t, e) {
|
|
1227
|
+
return new Bt(n, t, e);
|
|
1228
|
+
}
|
|
1229
|
+
const Kt = {
|
|
1230
|
+
axis: "y",
|
|
1231
|
+
duration: 600,
|
|
1232
|
+
perspective: 1e3
|
|
1233
|
+
};
|
|
1234
|
+
class Vt {
|
|
1235
|
+
constructor(t, e = {}) {
|
|
1236
|
+
c(this, "container");
|
|
1237
|
+
c(this, "inner");
|
|
1238
|
+
c(this, "front");
|
|
1239
|
+
c(this, "back");
|
|
1240
|
+
c(this, "flipped", !1);
|
|
1241
|
+
c(this, "options");
|
|
1242
|
+
if (this.container = typeof t == "string" ? document.querySelector(t) : t, !this.container)
|
|
1243
|
+
throw new Error("FlipCard: container not found");
|
|
1244
|
+
if (this.options = { ...Kt, ...e }, this.container.style.perspective = `${this.options.perspective}px`, this.container.style.cursor = "pointer", this.inner = document.createElement("div"), this.inner.style.cssText = `
|
|
1245
|
+
position: relative;
|
|
1246
|
+
width: 100%;
|
|
1247
|
+
height: 100%;
|
|
1248
|
+
transform-style: preserve-3d;
|
|
1249
|
+
transition: transform ${this.options.duration}ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
1250
|
+
`, this.front = this.container.querySelector('[data-flip="front"]'), this.back = this.container.querySelector('[data-flip="back"]'), !this.front || !this.back)
|
|
1251
|
+
throw new Error('FlipCard: 需要包含 data-flip="front" 和 data-flip="back" 的子元素');
|
|
1252
|
+
const s = `
|
|
1253
|
+
position: absolute;
|
|
1254
|
+
inset: 0;
|
|
1255
|
+
backface-visibility: hidden;
|
|
1256
|
+
-webkit-backface-visibility: hidden;
|
|
1257
|
+
`;
|
|
1258
|
+
this.front.style.cssText += s, this.back.style.cssText += s, this.options.axis === "y" ? this.back.style.transform = "rotateY(180deg)" : this.back.style.transform = "rotateX(180deg)", this.inner.appendChild(this.front), this.inner.appendChild(this.back), this.container.innerHTML = "", this.container.appendChild(this.inner), this.container.addEventListener("click", () => this.toggle());
|
|
1259
|
+
}
|
|
1260
|
+
toggle() {
|
|
1261
|
+
this.flipped = !this.flipped;
|
|
1262
|
+
const t = this.flipped ? 180 : 0;
|
|
1263
|
+
return this.options.axis === "y" ? this.inner.style.transform = `rotateY(${t}deg)` : this.inner.style.transform = `rotateX(${t}deg)`, this;
|
|
1264
|
+
}
|
|
1265
|
+
flipToFront() {
|
|
1266
|
+
return this.flipped = !1, this.inner.style.transform = "", this;
|
|
1267
|
+
}
|
|
1268
|
+
flipToBack() {
|
|
1269
|
+
this.flipped = !0;
|
|
1270
|
+
const t = 180;
|
|
1271
|
+
return this.options.axis === "y" ? this.inner.style.transform = `rotateY(${t}deg)` : this.inner.style.transform = `rotateX(${t}deg)`, this;
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
function hs(n, t) {
|
|
1275
|
+
return new Vt(n, t);
|
|
1276
|
+
}
|
|
1277
|
+
const Wt = {
|
|
1278
|
+
count: 15,
|
|
1279
|
+
color: "#38bdf8",
|
|
1280
|
+
size: 8,
|
|
1281
|
+
fadeSpeed: 0.92,
|
|
1282
|
+
smoothing: 0.15
|
|
1283
|
+
};
|
|
1284
|
+
function ps(n = {}) {
|
|
1285
|
+
const t = { ...Wt, ...n }, e = [], s = document.createElement("div");
|
|
1286
|
+
s.style.cssText = `
|
|
1287
|
+
position: fixed;
|
|
1288
|
+
inset: 0;
|
|
1289
|
+
pointer-events: none;
|
|
1290
|
+
z-index: 9998;
|
|
1291
|
+
overflow: hidden;
|
|
1292
|
+
`, document.body.appendChild(s);
|
|
1293
|
+
for (let d = 0; d < t.count; d++) {
|
|
1294
|
+
const h = document.createElement("div");
|
|
1295
|
+
h.style.cssText = `
|
|
1296
|
+
position: absolute;
|
|
1297
|
+
width: ${t.size}px;
|
|
1298
|
+
height: ${t.size}px;
|
|
1299
|
+
border-radius: 50%;
|
|
1300
|
+
background: ${t.color};
|
|
1301
|
+
opacity: 0;
|
|
1302
|
+
pointer-events: none;
|
|
1303
|
+
`, s.appendChild(h), e.push({
|
|
1304
|
+
el: h,
|
|
1305
|
+
x: -100,
|
|
1306
|
+
y: -100,
|
|
1307
|
+
targetX: -100,
|
|
1308
|
+
targetY: -100,
|
|
1309
|
+
opacity: 0
|
|
1310
|
+
});
|
|
1311
|
+
}
|
|
1312
|
+
let i = -100, o = -100, r = !0;
|
|
1313
|
+
const a = (d) => {
|
|
1314
|
+
i = d.clientX, o = d.clientY;
|
|
1315
|
+
};
|
|
1316
|
+
document.addEventListener("mousemove", a);
|
|
1317
|
+
const l = () => {
|
|
1318
|
+
r && (e.forEach((d, h) => {
|
|
1319
|
+
h === 0 ? (d.targetX = i, d.targetY = o) : (d.targetX = e[h - 1].x, d.targetY = e[h - 1].y), d.x += (d.targetX - d.x) * t.smoothing, d.y += (d.targetY - d.y) * t.smoothing, i > 0 && (d.opacity = Math.min(1, d.opacity + 0.1)), d.opacity *= t.fadeSpeed;
|
|
1320
|
+
const p = t.size * (1 - h / t.count * 0.6);
|
|
1321
|
+
d.el.style.transform = `translate(${d.x - p / 2}px, ${d.y - p / 2}px)`, d.el.style.width = `${p}px`, d.el.style.height = `${p}px`, d.el.style.opacity = String(d.opacity);
|
|
1322
|
+
}), requestAnimationFrame(l));
|
|
1323
|
+
};
|
|
1324
|
+
return requestAnimationFrame(l), () => {
|
|
1325
|
+
r = !1, document.removeEventListener("mousemove", a), s.remove();
|
|
1326
|
+
};
|
|
1327
|
+
}
|
|
1328
|
+
const jt = {
|
|
1329
|
+
enter: "fadeIn",
|
|
1330
|
+
exit: "fadeOut",
|
|
1331
|
+
hover: "none",
|
|
1332
|
+
active: "none",
|
|
1333
|
+
focus: "none",
|
|
1334
|
+
duration: 250,
|
|
1335
|
+
delay: 0,
|
|
1336
|
+
easing: "cubic-bezier(0.16, 1, 0.3, 1)"
|
|
1337
|
+
};
|
|
1338
|
+
function _(n, t = {}) {
|
|
1339
|
+
const e = { ...jt, ...t }, s = e.enter !== "none" ? new F(n) : null, i = n.style, o = i.transition;
|
|
1340
|
+
let r = !1;
|
|
1341
|
+
function a() {
|
|
1342
|
+
e.hover !== "none" && (r = !0, d(!0));
|
|
1343
|
+
}
|
|
1344
|
+
function l() {
|
|
1345
|
+
r && (r = !1, d(!1));
|
|
1346
|
+
}
|
|
1347
|
+
function d(y) {
|
|
1348
|
+
const g = `transform ${e.duration}ms ${e.easing}, box-shadow ${e.duration}ms ${e.easing}`;
|
|
1349
|
+
switch (e.hover) {
|
|
1350
|
+
case "lift":
|
|
1351
|
+
i.transition = g, i.transform = y ? "translateY(-2px)" : "", i.boxShadow = y ? "var(--mk-shadow-md)" : "";
|
|
1352
|
+
break;
|
|
1353
|
+
case "glow":
|
|
1354
|
+
i.transition = `box-shadow ${e.duration}ms ${e.easing}`, i.boxShadow = y ? "var(--mk-shadow-glow)" : "";
|
|
1355
|
+
break;
|
|
1356
|
+
case "scale":
|
|
1357
|
+
i.transition = `transform ${e.duration}ms ${e.easing}`, i.transform = y ? "scale(1.02)" : "";
|
|
1358
|
+
break;
|
|
1359
|
+
case "slideUp":
|
|
1360
|
+
i.transition = g, i.transform = y ? "translateY(-4px)" : "";
|
|
1361
|
+
break;
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
function h() {
|
|
1365
|
+
e.active === "press" && (i.transition = `transform ${e.duration * 0.5}ms ${e.easing}`, i.transform = "scale(0.97)");
|
|
1366
|
+
}
|
|
1367
|
+
function p() {
|
|
1368
|
+
e.active === "press" && (i.transform = r ? e.hover === "lift" ? "translateY(-2px)" : e.hover === "scale" ? "scale(1.02)" : "" : "");
|
|
1369
|
+
}
|
|
1370
|
+
function u() {
|
|
1371
|
+
e.focus === "ring" && (i.outline = "none", i.boxShadow = "0 0 0 2px var(--mk-primary-muted), 0 0 0 4px var(--mk-primary)", i.transition = `box-shadow ${e.duration}ms ${e.easing}`);
|
|
1372
|
+
}
|
|
1373
|
+
function m() {
|
|
1374
|
+
e.focus === "ring" && (i.boxShadow = "");
|
|
1375
|
+
}
|
|
1376
|
+
return n.addEventListener("mouseenter", a), n.addEventListener("mouseleave", l), n.addEventListener("mousedown", h), n.addEventListener("mouseup", p), n.addEventListener("focus", u), n.addEventListener("blur", m), {
|
|
1377
|
+
/** Play entrance animation */
|
|
1378
|
+
async playEnter() {
|
|
1379
|
+
!s || e.enter === "none" || await s.animate(e.enter, { duration: e.duration, delay: e.delay });
|
|
1380
|
+
},
|
|
1381
|
+
/** Play exit animation. Returns a Promise that resolves when animation completes. */
|
|
1382
|
+
async playExit() {
|
|
1383
|
+
!s || e.exit === "none" || await s.animate(e.exit, { duration: e.duration });
|
|
1384
|
+
},
|
|
1385
|
+
/** Programmatically set hover state */
|
|
1386
|
+
setHover(y) {
|
|
1387
|
+
y ? a() : l();
|
|
1388
|
+
},
|
|
1389
|
+
/** Clean up all listeners and styles */
|
|
1390
|
+
destroy() {
|
|
1391
|
+
n.removeEventListener("mouseenter", a), n.removeEventListener("mouseleave", l), n.removeEventListener("mousedown", h), n.removeEventListener("mouseup", p), n.removeEventListener("focus", u), n.removeEventListener("blur", m), i.transition = o, i.transform = "", i.boxShadow = "", i.outline = "", s == null || s.stop();
|
|
1392
|
+
}
|
|
1393
|
+
};
|
|
1394
|
+
}
|
|
1395
|
+
function us(n, t, e, s) {
|
|
1396
|
+
const i = n.querySelectorAll(t);
|
|
1397
|
+
if (i.length === 0) return;
|
|
1398
|
+
const o = (s == null ? void 0 : s.delay) ?? 100, r = (s == null ? void 0 : s.stagger) ?? 80, a = (s == null ? void 0 : s.duration) ?? 400;
|
|
1399
|
+
i.forEach((l, d) => {
|
|
1400
|
+
const h = l;
|
|
1401
|
+
h.style.opacity = "0", setTimeout(() => {
|
|
1402
|
+
h.style.transition = `opacity ${a}ms ease`, h.style.opacity = "1";
|
|
1403
|
+
}, o + d * r);
|
|
1404
|
+
});
|
|
1405
|
+
}
|
|
1406
|
+
const Gt = [
|
|
1407
|
+
"a[href]",
|
|
1408
|
+
"button:not([disabled])",
|
|
1409
|
+
"input:not([disabled])",
|
|
1410
|
+
"select:not([disabled])",
|
|
1411
|
+
"textarea:not([disabled])",
|
|
1412
|
+
'[tabindex]:not([tabindex="-1"])'
|
|
1413
|
+
].join(",");
|
|
1414
|
+
class M {
|
|
1415
|
+
constructor(t) {
|
|
1416
|
+
c(this, "container");
|
|
1417
|
+
c(this, "previousActiveElement", null);
|
|
1418
|
+
c(this, "listeners", []);
|
|
1419
|
+
this.container = t;
|
|
1420
|
+
}
|
|
1421
|
+
activate(t) {
|
|
1422
|
+
this.previousActiveElement = document.activeElement;
|
|
1423
|
+
const e = this.getFocusableElements(), s = t || (e.length > 0 ? e[0] : null);
|
|
1424
|
+
s instanceof HTMLElement && s.focus();
|
|
1425
|
+
const i = (o) => this.handleKeyDown(o);
|
|
1426
|
+
this.container.addEventListener("keydown", i), this.listeners.push(() => this.container.removeEventListener("keydown", i));
|
|
1427
|
+
}
|
|
1428
|
+
deactivate() {
|
|
1429
|
+
this.listeners.forEach((t) => t()), this.listeners = [], this.previousActiveElement instanceof HTMLElement && this.previousActiveElement.focus();
|
|
1430
|
+
}
|
|
1431
|
+
getFocusableElements() {
|
|
1432
|
+
return this.container.querySelectorAll(Gt);
|
|
1433
|
+
}
|
|
1434
|
+
handleKeyDown(t) {
|
|
1435
|
+
if (t.key !== "Tab") return;
|
|
1436
|
+
const e = Array.from(this.getFocusableElements());
|
|
1437
|
+
if (e.length === 0) return;
|
|
1438
|
+
const s = e[0], i = e[e.length - 1];
|
|
1439
|
+
t.shiftKey && document.activeElement === s ? (t.preventDefault(), i.focus()) : !t.shiftKey && document.activeElement === i && (t.preventDefault(), s.focus());
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
function k(n, t) {
|
|
1443
|
+
const e = (s) => {
|
|
1444
|
+
for (const i of t)
|
|
1445
|
+
if (s.key === i.key) {
|
|
1446
|
+
i.preventDefault !== !1 && s.preventDefault(), i.handler(s);
|
|
1447
|
+
return;
|
|
1448
|
+
}
|
|
1449
|
+
};
|
|
1450
|
+
return n.addEventListener("keydown", e), () => n.removeEventListener("keydown", e);
|
|
1451
|
+
}
|
|
1452
|
+
const f = {
|
|
1453
|
+
Enter: "Enter",
|
|
1454
|
+
Escape: "Escape",
|
|
1455
|
+
Tab: "Tab",
|
|
1456
|
+
ArrowUp: "ArrowUp",
|
|
1457
|
+
ArrowDown: "ArrowDown",
|
|
1458
|
+
ArrowLeft: "ArrowLeft",
|
|
1459
|
+
ArrowRight: "ArrowRight",
|
|
1460
|
+
Home: "Home",
|
|
1461
|
+
End: "End",
|
|
1462
|
+
Space: " "
|
|
1463
|
+
};
|
|
1464
|
+
class Jt {
|
|
1465
|
+
constructor() {
|
|
1466
|
+
c(this, "currentTheme", "dark");
|
|
1467
|
+
c(this, "listeners", /* @__PURE__ */ new Set());
|
|
1468
|
+
document.documentElement.setAttribute("data-mk-theme", "dark");
|
|
1469
|
+
}
|
|
1470
|
+
setTheme(t) {
|
|
1471
|
+
this.currentTheme = t, document.documentElement.setAttribute("data-mk-theme", t), this.listeners.forEach((e) => e(t));
|
|
1472
|
+
}
|
|
1473
|
+
toggle() {
|
|
1474
|
+
this.setTheme(this.currentTheme === "dark" ? "light" : "dark");
|
|
1475
|
+
}
|
|
1476
|
+
getTheme() {
|
|
1477
|
+
return this.currentTheme;
|
|
1478
|
+
}
|
|
1479
|
+
applyCustom(t) {
|
|
1480
|
+
const e = document.documentElement;
|
|
1481
|
+
Object.entries(t).forEach(([s, i]) => {
|
|
1482
|
+
e.style.setProperty(`--mk-${s}`, i);
|
|
1483
|
+
});
|
|
1484
|
+
}
|
|
1485
|
+
resetCustom() {
|
|
1486
|
+
const t = document.documentElement;
|
|
1487
|
+
[
|
|
1488
|
+
"bg",
|
|
1489
|
+
"surface",
|
|
1490
|
+
"surface-hover",
|
|
1491
|
+
"border",
|
|
1492
|
+
"border-hover",
|
|
1493
|
+
"primary",
|
|
1494
|
+
"primary-hover",
|
|
1495
|
+
"primary-active",
|
|
1496
|
+
"success",
|
|
1497
|
+
"warning",
|
|
1498
|
+
"danger",
|
|
1499
|
+
"text",
|
|
1500
|
+
"text-secondary",
|
|
1501
|
+
"text-tertiary"
|
|
1502
|
+
].forEach((s) => t.style.removeProperty(`--mk-${s}`));
|
|
1503
|
+
}
|
|
1504
|
+
onChange(t) {
|
|
1505
|
+
return this.listeners.add(t), () => this.listeners.delete(t);
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
const ms = new Jt();
|
|
1509
|
+
class Zt {
|
|
1510
|
+
constructor(t, e = {}) {
|
|
1511
|
+
c(this, "el");
|
|
1512
|
+
const s = typeof t == "string" ? document.querySelector(t) : t;
|
|
1513
|
+
this.el = document.createElement("div"), this.el.className = "mk-row", e.justify && this.el.classList.add(`mk-row--justify-${e.justify}`), e.align && this.el.classList.add(`mk-row--align-${e.align}`), e.wrap === !1 && this.el.classList.add("mk-row--no-wrap"), e.gutter && (this.el.style.margin = `0 -${e.gutter / 2}px`), s.appendChild(this.el);
|
|
1514
|
+
}
|
|
1515
|
+
addCol(t, e, s) {
|
|
1516
|
+
const i = document.createElement("div");
|
|
1517
|
+
return i.className = `mk-col mk-col-${t === "flex" ? "flex" : t}`, s && i.classList.add(s), typeof e == "string" ? i.innerHTML = e : e && i.appendChild(e), this.el.appendChild(i), i;
|
|
1518
|
+
}
|
|
1519
|
+
destroy() {
|
|
1520
|
+
this.el.remove();
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
function fs(n, t) {
|
|
1524
|
+
return new Zt(n, t);
|
|
1525
|
+
}
|
|
1526
|
+
class Qt {
|
|
1527
|
+
constructor(t, e = {}) {
|
|
1528
|
+
c(this, "el");
|
|
1529
|
+
const s = typeof t == "string" ? document.querySelector(t) : t;
|
|
1530
|
+
this.el = document.createElement("div"), this.el.className = "mk-space", e.direction === "vertical" && this.el.classList.add("mk-space--vertical"), e.size && this.el.classList.add(`mk-space--${e.size}`), e.wrap !== !1 && this.el.classList.add("mk-space--wrap"), s.appendChild(this.el);
|
|
1531
|
+
}
|
|
1532
|
+
add(t) {
|
|
1533
|
+
if (typeof t == "string") {
|
|
1534
|
+
const e = document.createElement("span");
|
|
1535
|
+
e.innerHTML = t, this.el.appendChild(e);
|
|
1536
|
+
} else
|
|
1537
|
+
this.el.appendChild(t);
|
|
1538
|
+
}
|
|
1539
|
+
destroy() {
|
|
1540
|
+
this.el.remove();
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
function ys(n, t) {
|
|
1544
|
+
return new Qt(n, t);
|
|
1545
|
+
}
|
|
1546
|
+
class te {
|
|
1547
|
+
constructor(t, e = {}) {
|
|
1548
|
+
c(this, "el");
|
|
1549
|
+
const s = typeof t == "string" ? document.querySelector(t) : t;
|
|
1550
|
+
this.el = document.createElement("div"), this.el.className = "mk-divider", e.direction === "vertical" ? this.el.classList.add("mk-divider--vertical") : this.el.classList.add("mk-divider--horizontal"), e.dashed && this.el.classList.add("mk-divider--dashed"), e.text && (this.el.textContent = e.text), s.appendChild(this.el);
|
|
1551
|
+
}
|
|
1552
|
+
destroy() {
|
|
1553
|
+
this.el.remove();
|
|
1554
|
+
}
|
|
1555
|
+
}
|
|
1556
|
+
function gs(n, t) {
|
|
1557
|
+
return new te(n, t);
|
|
1558
|
+
}
|
|
1559
|
+
class ee {
|
|
1560
|
+
constructor(t, e = {}) {
|
|
1561
|
+
c(this, "el");
|
|
1562
|
+
c(this, "options");
|
|
1563
|
+
c(this, "motion", null);
|
|
1564
|
+
const s = typeof t == "string" ? document.querySelector(t) : t;
|
|
1565
|
+
if (this.options = {
|
|
1566
|
+
type: "default",
|
|
1567
|
+
size: "default",
|
|
1568
|
+
...e
|
|
1569
|
+
}, this.el = document.createElement("button"), this.el.type = "button", this.el.className = this.buildClass(), this.el.disabled = !!this.options.disabled || !!this.options.loading, this.options.icon && !this.options.text && this.el.setAttribute("aria-label", "Button"), this.updateAriaDisabled(), this.options.loading) {
|
|
1570
|
+
this.el.classList.add("is-loading");
|
|
1571
|
+
const i = document.createElement("span");
|
|
1572
|
+
i.className = "mk-button__spinner", this.el.appendChild(i);
|
|
1573
|
+
}
|
|
1574
|
+
if (this.options.icon && !this.options.loading) {
|
|
1575
|
+
const i = document.createElement("span");
|
|
1576
|
+
i.textContent = this.options.icon, this.el.appendChild(i);
|
|
1577
|
+
}
|
|
1578
|
+
if (this.options.text) {
|
|
1579
|
+
const i = document.createElement("span");
|
|
1580
|
+
i.textContent = this.options.text, this.el.appendChild(i);
|
|
1581
|
+
}
|
|
1582
|
+
this.el.addEventListener("click", (i) => {
|
|
1583
|
+
var o, r;
|
|
1584
|
+
this.createRipple(i), (r = (o = this.options).onClick) == null || r.call(o, i);
|
|
1585
|
+
}), s.appendChild(this.el), this.motion = _(this.el, e.motion || { hover: "lift", active: "press", focus: "ring", enter: "fadeIn", duration: 200 });
|
|
1586
|
+
}
|
|
1587
|
+
buildClass() {
|
|
1588
|
+
const t = ["mk-button"];
|
|
1589
|
+
return this.options.type && this.options.type !== "default" && t.push(`mk-button--${this.options.type}`), this.options.size && this.options.size !== "default" && t.push(`mk-button--${this.options.size}`), this.options.plain && t.push("is-plain"), this.options.round && t.push("is-round"), this.options.circle && t.push("is-circle"), this.options.loading && t.push("is-loading"), this.options.disabled && t.push("is-disabled"), t.join(" ");
|
|
1590
|
+
}
|
|
1591
|
+
createRipple(t) {
|
|
1592
|
+
const e = this.el.getBoundingClientRect(), s = Math.max(e.width, e.height), i = document.createElement("span");
|
|
1593
|
+
i.className = "mk-button__ripple", i.style.width = i.style.height = `${s}px`, i.style.left = `${t.clientX - e.left - s / 2}px`, i.style.top = `${t.clientY - e.top - s / 2}px`, this.el.appendChild(i), setTimeout(() => i.remove(), 600);
|
|
1594
|
+
}
|
|
1595
|
+
setLoading(t) {
|
|
1596
|
+
this.options.loading = t, this.el.classList.toggle("is-loading", t), this.el.disabled = t || !!this.options.disabled, this.updateAriaDisabled();
|
|
1597
|
+
const e = this.el.querySelector(".mk-button__spinner");
|
|
1598
|
+
if (t && !e) {
|
|
1599
|
+
const s = document.createElement("span");
|
|
1600
|
+
s.className = "mk-button__spinner", this.el.insertBefore(s, this.el.firstChild);
|
|
1601
|
+
} else !t && e && e.remove();
|
|
1602
|
+
}
|
|
1603
|
+
setDisabled(t) {
|
|
1604
|
+
this.options.disabled = t, this.el.classList.toggle("is-disabled", t), this.el.disabled = t || !!this.options.loading, this.updateAriaDisabled();
|
|
1605
|
+
}
|
|
1606
|
+
updateAriaDisabled() {
|
|
1607
|
+
this.el.setAttribute("aria-disabled", String(this.el.disabled));
|
|
1608
|
+
}
|
|
1609
|
+
destroy() {
|
|
1610
|
+
var t;
|
|
1611
|
+
(t = this.motion) == null || t.destroy(), this.el.remove();
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
function vs(n, t) {
|
|
1615
|
+
return new ee(n, t);
|
|
1616
|
+
}
|
|
1617
|
+
class se {
|
|
1618
|
+
constructor(t, e = {}) {
|
|
1619
|
+
c(this, "el");
|
|
1620
|
+
c(this, "input");
|
|
1621
|
+
c(this, "options");
|
|
1622
|
+
c(this, "errorMsg");
|
|
1623
|
+
c(this, "motion", null);
|
|
1624
|
+
const s = typeof t == "string" ? document.querySelector(t) : t;
|
|
1625
|
+
this.options = { ...e }, this.el = document.createElement("div"), this.el.className = "mk-input-wrapper";
|
|
1626
|
+
const i = `mk-input-${Math.random().toString(36).slice(2)}`;
|
|
1627
|
+
this.input = document.createElement("input"), this.input.className = "mk-input", this.input.id = i, this.input.type = this.options.type || "text", this.input.placeholder = this.options.placeholder || "", this.input.value = this.options.value || "", this.input.disabled = !!this.options.disabled, this.el.appendChild(this.input);
|
|
1628
|
+
const o = document.createElement("span");
|
|
1629
|
+
if (o.className = "mk-input__suffix", this.options.clearable) {
|
|
1630
|
+
const r = document.createElement("span");
|
|
1631
|
+
r.className = "mk-input__suffix-item mk-input__clear", r.innerHTML = "✕", r.addEventListener("click", () => {
|
|
1632
|
+
var a, l;
|
|
1633
|
+
this.input.value = "", this.input.focus(), (l = (a = this.options).onInput) == null || l.call(a, ""), this.clearError();
|
|
1634
|
+
}), o.appendChild(r);
|
|
1635
|
+
}
|
|
1636
|
+
if (this.options.showPassword && this.input.type === "password") {
|
|
1637
|
+
const r = document.createElement("span");
|
|
1638
|
+
r.className = "mk-input__suffix-item", r.innerHTML = "👁", r.title = "显示密码";
|
|
1639
|
+
let a = !1;
|
|
1640
|
+
r.addEventListener("click", () => {
|
|
1641
|
+
a = !a, this.input.type = a ? "text" : "password", r.innerHTML = a ? "🙈" : "👁";
|
|
1642
|
+
}), o.appendChild(r);
|
|
1643
|
+
}
|
|
1644
|
+
o.children.length > 0 && this.el.appendChild(o), this.errorMsg = document.createElement("span"), this.errorMsg.className = "mk-input__errormsg", this.errorMsg.id = `${i}-error`, this.el.appendChild(this.errorMsg), this.input.addEventListener("input", () => {
|
|
1645
|
+
var r, a;
|
|
1646
|
+
(a = (r = this.options).onInput) == null || a.call(r, this.input.value), this.clearError();
|
|
1647
|
+
}), this.input.addEventListener("keydown", (r) => {
|
|
1648
|
+
var a, l;
|
|
1649
|
+
r.key === "Enter" && ((l = (a = this.options).onEnter) == null || l.call(a, this.input.value));
|
|
1650
|
+
}), this.input.addEventListener("blur", () => {
|
|
1651
|
+
this.validate();
|
|
1652
|
+
}), s.appendChild(this.el), this.motion = _(this.input, e.motion || { focus: "ring", enter: "fadeIn", duration: 200 });
|
|
1653
|
+
}
|
|
1654
|
+
get value() {
|
|
1655
|
+
return this.input.value;
|
|
1656
|
+
}
|
|
1657
|
+
set value(t) {
|
|
1658
|
+
this.input.value = t;
|
|
1659
|
+
}
|
|
1660
|
+
validate() {
|
|
1661
|
+
if (!this.options.validate) return !0;
|
|
1662
|
+
const t = this.options.validate(this.input.value);
|
|
1663
|
+
return t ? (this.showError(t), !1) : (this.clearError(), !0);
|
|
1664
|
+
}
|
|
1665
|
+
showError(t) {
|
|
1666
|
+
this.el.classList.add("is-error"), this.el.classList.remove("is-success"), this.errorMsg.textContent = t, this.errorMsg.classList.add("show"), this.input.setAttribute("aria-invalid", "true"), this.input.setAttribute("aria-describedby", this.errorMsg.id);
|
|
1667
|
+
}
|
|
1668
|
+
showSuccess() {
|
|
1669
|
+
this.el.classList.remove("is-error"), this.el.classList.add("is-success"), this.errorMsg.classList.remove("show");
|
|
1670
|
+
}
|
|
1671
|
+
clearError() {
|
|
1672
|
+
this.el.classList.remove("is-error"), this.errorMsg.classList.remove("show"), this.input.removeAttribute("aria-invalid"), this.input.removeAttribute("aria-describedby");
|
|
1673
|
+
}
|
|
1674
|
+
focus() {
|
|
1675
|
+
this.input.focus();
|
|
1676
|
+
}
|
|
1677
|
+
destroy() {
|
|
1678
|
+
var t;
|
|
1679
|
+
(t = this.motion) == null || t.destroy(), this.el.remove();
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1682
|
+
function bs(n, t) {
|
|
1683
|
+
return new se(n, t);
|
|
1684
|
+
}
|
|
1685
|
+
class ie {
|
|
1686
|
+
constructor(t, e = {}) {
|
|
1687
|
+
c(this, "el");
|
|
1688
|
+
c(this, "motion", null);
|
|
1689
|
+
const s = typeof t == "string" ? document.querySelector(t) : t;
|
|
1690
|
+
if (this.el = document.createElement("div"), this.el.className = "mk-card", e.shadow && (e.shadow === "always" ? this.el.classList.add("is-always-shadow") : e.shadow === "hover" && this.el.classList.add("is-hover-shadow")), e.loading && this.el.classList.add("is-loading"), e.image) {
|
|
1691
|
+
const o = document.createElement("img");
|
|
1692
|
+
o.className = "mk-card__image", o.src = e.image, o.alt = "", this.el.appendChild(o);
|
|
1693
|
+
}
|
|
1694
|
+
if (e.title) {
|
|
1695
|
+
const o = document.createElement("div");
|
|
1696
|
+
o.className = "mk-card__header";
|
|
1697
|
+
const r = document.createElement("span");
|
|
1698
|
+
r.className = "mk-card__title", r.textContent = e.title, o.appendChild(r), this.el.appendChild(o);
|
|
1699
|
+
}
|
|
1700
|
+
const i = document.createElement("div");
|
|
1701
|
+
if (i.className = "mk-card__body", e.body && (i.innerHTML = e.body), this.el.appendChild(i), e.footer) {
|
|
1702
|
+
const o = document.createElement("div");
|
|
1703
|
+
o.className = "mk-card__footer", o.textContent = e.footer, this.el.appendChild(o);
|
|
1704
|
+
}
|
|
1705
|
+
s.appendChild(this.el), this.motion = _(this.el, e.motion || { hover: "lift", duration: 300 });
|
|
1706
|
+
}
|
|
1707
|
+
setLoading(t) {
|
|
1708
|
+
this.el.classList.toggle("is-loading", t);
|
|
1709
|
+
}
|
|
1710
|
+
destroy() {
|
|
1711
|
+
var t;
|
|
1712
|
+
(t = this.motion) == null || t.destroy(), this.el.remove();
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
function Es(n, t) {
|
|
1716
|
+
return new ie(n, t);
|
|
1717
|
+
}
|
|
1718
|
+
let ne = 0;
|
|
1719
|
+
class oe {
|
|
1720
|
+
constructor(t = {}) {
|
|
1721
|
+
c(this, "overlay");
|
|
1722
|
+
c(this, "dialog");
|
|
1723
|
+
c(this, "options");
|
|
1724
|
+
c(this, "focusTrap");
|
|
1725
|
+
c(this, "escapeCleanup", null);
|
|
1726
|
+
c(this, "confirmBtn");
|
|
1727
|
+
c(this, "titleId");
|
|
1728
|
+
this.options = {
|
|
1729
|
+
showClose: !0,
|
|
1730
|
+
showCancel: !0,
|
|
1731
|
+
...t
|
|
1732
|
+
}, this.overlay = document.createElement("div"), this.overlay.className = "mk-dialog-overlay", this.overlay.style.display = "none", this.dialog = document.createElement("div"), this.dialog.className = "mk-dialog", this.options.center && this.dialog.classList.add("is-center"), this.dialog.setAttribute("role", "dialog"), this.dialog.setAttribute("aria-modal", "true");
|
|
1733
|
+
const e = document.createElement("div");
|
|
1734
|
+
e.className = "mk-dialog__header";
|
|
1735
|
+
const s = document.createElement("span");
|
|
1736
|
+
if (s.className = "mk-dialog__title", s.textContent = this.options.title || "", this.titleId = `mk-dialog-title-${++ne}`, s.id = this.titleId, this.dialog.setAttribute("aria-labelledby", this.titleId), e.appendChild(s), this.options.showClose) {
|
|
1737
|
+
const r = document.createElement("span");
|
|
1738
|
+
r.className = "mk-dialog__close", r.innerHTML = "✕", r.setAttribute("role", "button"), r.setAttribute("tabindex", "0"), r.setAttribute("aria-label", "Close"), r.addEventListener("click", () => this.close()), r.addEventListener("keydown", (a) => {
|
|
1739
|
+
(a.key === "Enter" || a.key === " ") && (a.preventDefault(), this.close());
|
|
1740
|
+
}), e.appendChild(r);
|
|
1741
|
+
}
|
|
1742
|
+
this.dialog.appendChild(e);
|
|
1743
|
+
const i = document.createElement("div");
|
|
1744
|
+
i.className = "mk-dialog__body", typeof this.options.content == "string" ? i.innerHTML = this.options.content : this.options.content && i.appendChild(this.options.content), this.dialog.appendChild(i);
|
|
1745
|
+
const o = document.createElement("div");
|
|
1746
|
+
if (o.className = "mk-dialog__footer", this.options.showCancel) {
|
|
1747
|
+
const r = document.createElement("button");
|
|
1748
|
+
r.className = "mk-button", r.textContent = this.options.cancelText || "取消", r.addEventListener("click", () => {
|
|
1749
|
+
var a, l;
|
|
1750
|
+
(l = (a = this.options).onCancel) == null || l.call(a), this.close();
|
|
1751
|
+
}), o.appendChild(r);
|
|
1752
|
+
}
|
|
1753
|
+
this.confirmBtn = document.createElement("button"), this.confirmBtn.className = "mk-button mk-button--primary", this.confirmBtn.textContent = this.options.confirmText || "确定", this.confirmBtn.addEventListener("click", () => {
|
|
1754
|
+
var r, a;
|
|
1755
|
+
(a = (r = this.options).onConfirm) == null || a.call(r), this.close();
|
|
1756
|
+
}), o.appendChild(this.confirmBtn), this.dialog.appendChild(o), this.overlay.appendChild(this.dialog), this.overlay.addEventListener("click", (r) => {
|
|
1757
|
+
var a, l;
|
|
1758
|
+
r.target === this.overlay && ((l = (a = this.options).onClose) == null || l.call(a), this.close());
|
|
1759
|
+
}), document.body.appendChild(this.overlay), this.focusTrap = new M(this.dialog);
|
|
1760
|
+
}
|
|
1761
|
+
open() {
|
|
1762
|
+
this.overlay.style.display = "flex", requestAnimationFrame(() => {
|
|
1763
|
+
this.overlay.classList.add("is-open"), this.focusTrap.activate(this.confirmBtn), this.escapeCleanup = k(this.dialog, [
|
|
1764
|
+
{ key: f.Escape, handler: () => this.close() }
|
|
1765
|
+
]);
|
|
1766
|
+
});
|
|
1767
|
+
}
|
|
1768
|
+
close() {
|
|
1769
|
+
this.overlay.classList.remove("is-open"), this.escapeCleanup && (this.escapeCleanup(), this.escapeCleanup = null), this.focusTrap.deactivate(), setTimeout(() => {
|
|
1770
|
+
var t, e;
|
|
1771
|
+
this.overlay.style.display = "none", (e = (t = this.options).onClose) == null || e.call(t);
|
|
1772
|
+
}, 300);
|
|
1773
|
+
}
|
|
1774
|
+
destroy() {
|
|
1775
|
+
this.escapeCleanup && (this.escapeCleanup(), this.escapeCleanup = null), this.focusTrap.deactivate(), this.overlay.remove();
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
function ks(n) {
|
|
1779
|
+
return new oe(n);
|
|
1780
|
+
}
|
|
1781
|
+
class re {
|
|
1782
|
+
constructor(t = {}) {
|
|
1783
|
+
c(this, "overlay");
|
|
1784
|
+
c(this, "drawer");
|
|
1785
|
+
c(this, "options");
|
|
1786
|
+
c(this, "focusTrap");
|
|
1787
|
+
c(this, "escapeCleanup", null);
|
|
1788
|
+
this.options = {
|
|
1789
|
+
direction: "right",
|
|
1790
|
+
showClose: !0,
|
|
1791
|
+
...t
|
|
1792
|
+
}, this.overlay = document.createElement("div"), this.overlay.className = "mk-drawer-overlay", this.overlay.style.display = "none", this.drawer = document.createElement("div"), this.drawer.className = `mk-drawer mk-drawer--${this.options.direction}`, this.drawer.setAttribute("role", "dialog"), this.drawer.setAttribute("aria-modal", "true"), this.options.size && (this.options.direction === "right" || this.options.direction === "left" ? this.drawer.style.width = `${this.options.size}px` : this.drawer.style.height = `${this.options.size}px`);
|
|
1793
|
+
const e = document.createElement("div");
|
|
1794
|
+
e.className = "mk-drawer__header";
|
|
1795
|
+
const s = document.createElement("span");
|
|
1796
|
+
if (s.className = "mk-drawer__title", s.textContent = this.options.title || "", e.appendChild(s), this.options.showClose) {
|
|
1797
|
+
const o = document.createElement("span");
|
|
1798
|
+
o.className = "mk-drawer__close", o.innerHTML = "✕", o.setAttribute("role", "button"), o.setAttribute("tabindex", "0"), o.setAttribute("aria-label", "Close"), o.addEventListener("click", () => this.close()), o.addEventListener("keydown", (r) => {
|
|
1799
|
+
(r.key === "Enter" || r.key === " ") && (r.preventDefault(), this.close());
|
|
1800
|
+
}), e.appendChild(o);
|
|
1801
|
+
}
|
|
1802
|
+
this.drawer.appendChild(e);
|
|
1803
|
+
const i = document.createElement("div");
|
|
1804
|
+
i.className = "mk-drawer__body", typeof this.options.content == "string" ? i.innerHTML = this.options.content : this.options.content && i.appendChild(this.options.content), this.drawer.appendChild(i), this.overlay.appendChild(this.drawer), this.overlay.addEventListener("click", (o) => {
|
|
1805
|
+
o.target === this.overlay && this.close();
|
|
1806
|
+
}), document.body.appendChild(this.overlay), this.focusTrap = new M(this.drawer);
|
|
1807
|
+
}
|
|
1808
|
+
open() {
|
|
1809
|
+
this.overlay.style.display = "block", requestAnimationFrame(() => {
|
|
1810
|
+
this.overlay.classList.add("is-open"), this.focusTrap.activate(), this.escapeCleanup = k(this.drawer, [
|
|
1811
|
+
{ key: f.Escape, handler: () => this.close() }
|
|
1812
|
+
]);
|
|
1813
|
+
});
|
|
1814
|
+
}
|
|
1815
|
+
close() {
|
|
1816
|
+
this.overlay.classList.remove("is-open"), this.escapeCleanup && (this.escapeCleanup(), this.escapeCleanup = null), this.focusTrap.deactivate(), setTimeout(() => {
|
|
1817
|
+
var t, e;
|
|
1818
|
+
this.overlay.style.display = "none", (e = (t = this.options).onClose) == null || e.call(t);
|
|
1819
|
+
}, 300);
|
|
1820
|
+
}
|
|
1821
|
+
destroy() {
|
|
1822
|
+
this.escapeCleanup && (this.escapeCleanup(), this.escapeCleanup = null), this.focusTrap.deactivate(), this.overlay.remove();
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1825
|
+
function ws(n) {
|
|
1826
|
+
return new re(n);
|
|
1827
|
+
}
|
|
1828
|
+
const ae = {
|
|
1829
|
+
success: "✓",
|
|
1830
|
+
warning: "!",
|
|
1831
|
+
error: "✕",
|
|
1832
|
+
info: "i"
|
|
1833
|
+
}, le = {
|
|
1834
|
+
success: "#67c23a",
|
|
1835
|
+
warning: "#e6a23c",
|
|
1836
|
+
error: "#f56c6c",
|
|
1837
|
+
info: "#409eff"
|
|
1838
|
+
};
|
|
1839
|
+
let E = null;
|
|
1840
|
+
function ce() {
|
|
1841
|
+
return E || (E = document.createElement("div"), E.className = "mk-message-container", document.body.appendChild(E)), E;
|
|
1842
|
+
}
|
|
1843
|
+
function N(n, t = {}) {
|
|
1844
|
+
const e = { type: "info", duration: 3e3, closable: !0, ...t }, s = document.createElement("div");
|
|
1845
|
+
s.className = `mk-message mk-message--${e.type}`;
|
|
1846
|
+
const i = document.createElement("span");
|
|
1847
|
+
i.className = "mk-message__icon", i.style.color = le[e.type], i.textContent = ae[e.type], s.appendChild(i);
|
|
1848
|
+
const o = document.createElement("span");
|
|
1849
|
+
if (o.className = "mk-message__content", o.textContent = n, s.appendChild(o), e.closable) {
|
|
1850
|
+
const a = document.createElement("span");
|
|
1851
|
+
a.className = "mk-message__close", a.innerHTML = "✕", a.addEventListener("click", () => T(s)), s.appendChild(a);
|
|
1852
|
+
}
|
|
1853
|
+
ce().appendChild(s), requestAnimationFrame(() => s.classList.add("is-show"));
|
|
1854
|
+
const r = setTimeout(() => T(s), e.duration);
|
|
1855
|
+
return () => {
|
|
1856
|
+
clearTimeout(r), T(s);
|
|
1857
|
+
};
|
|
1858
|
+
}
|
|
1859
|
+
function T(n) {
|
|
1860
|
+
n.classList.remove("is-show"), n.style.opacity = "0", n.style.transform = "translateY(-20px) scale(0.95)", setTimeout(() => {
|
|
1861
|
+
n.remove(), E && E.children.length === 0 && (E.remove(), E = null);
|
|
1862
|
+
}, 300);
|
|
1863
|
+
}
|
|
1864
|
+
function xs(n, t) {
|
|
1865
|
+
return N(n, { ...t, type: "success" });
|
|
1866
|
+
}
|
|
1867
|
+
function Cs(n, t) {
|
|
1868
|
+
return N(n, { ...t, type: "error" });
|
|
1869
|
+
}
|
|
1870
|
+
function Ls(n, t) {
|
|
1871
|
+
return N(n, { ...t, type: "warning" });
|
|
1872
|
+
}
|
|
1873
|
+
class de {
|
|
1874
|
+
constructor(t, e = {}) {
|
|
1875
|
+
c(this, "el");
|
|
1876
|
+
c(this, "core");
|
|
1877
|
+
c(this, "options");
|
|
1878
|
+
c(this, "_value");
|
|
1879
|
+
c(this, "activeLabel");
|
|
1880
|
+
c(this, "_cleanupKey");
|
|
1881
|
+
c(this, "inactiveLabel");
|
|
1882
|
+
const s = typeof t == "string" ? document.querySelector(t) : t;
|
|
1883
|
+
this.options = { value: !1, ...e }, this._value = this.options.value, this.el = document.createElement("label"), this.el.className = "mk-switch", this._value && this.el.classList.add("is-checked"), this.options.disabled && this.el.classList.add("is-disabled"), this.el.setAttribute("role", "switch"), this.el.setAttribute("aria-checked", String(this._value)), this.options.disabled || this.el.setAttribute("tabindex", "0"), this.options.inactiveText && (this.inactiveLabel = document.createElement("span"), this.inactiveLabel.className = "mk-switch__label", this.inactiveLabel.textContent = this.options.inactiveText, this._value || this.inactiveLabel.classList.add("mk-switch__label--active"), this.el.appendChild(this.inactiveLabel)), this.core = document.createElement("div"), this.core.className = "mk-switch__core", this.el.appendChild(this.core), this.options.activeText && (this.activeLabel = document.createElement("span"), this.activeLabel.className = "mk-switch__label", this.activeLabel.textContent = this.options.activeText, this._value && this.activeLabel.classList.add("mk-switch__label--active"), this.el.appendChild(this.activeLabel)), this.el.addEventListener("click", () => {
|
|
1884
|
+
this.options.disabled || this.toggle();
|
|
1885
|
+
}), this._cleanupKey = k(this.el, [
|
|
1886
|
+
{ key: f.Enter, handler: () => this.toggle() },
|
|
1887
|
+
{ key: f.Space, handler: () => this.toggle() }
|
|
1888
|
+
]), s.appendChild(this.el);
|
|
1889
|
+
}
|
|
1890
|
+
get value() {
|
|
1891
|
+
return this._value;
|
|
1892
|
+
}
|
|
1893
|
+
set value(t) {
|
|
1894
|
+
var e, s, i, o;
|
|
1895
|
+
this._value !== t && (this._value = t, this.el.classList.toggle("is-checked", t), this.el.setAttribute("aria-checked", String(t)), (e = this.activeLabel) == null || e.classList.toggle("mk-switch__label--active", t), (s = this.inactiveLabel) == null || s.classList.toggle("mk-switch__label--active", !t), (o = (i = this.options).onChange) == null || o.call(i, t));
|
|
1896
|
+
}
|
|
1897
|
+
toggle() {
|
|
1898
|
+
this.value = !this._value;
|
|
1899
|
+
}
|
|
1900
|
+
destroy() {
|
|
1901
|
+
var t;
|
|
1902
|
+
(t = this._cleanupKey) == null || t.call(this), this.el.remove();
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1905
|
+
function _s(n, t) {
|
|
1906
|
+
return new de(n, t);
|
|
1907
|
+
}
|
|
1908
|
+
function he(n = {}) {
|
|
1909
|
+
const t = document.createElement("div");
|
|
1910
|
+
if (t.className = "mk-loading-mask", n.fullscreen)
|
|
1911
|
+
t.classList.add("is-fullscreen"), document.body.appendChild(t);
|
|
1912
|
+
else {
|
|
1913
|
+
const s = typeof n.target == "string" ? document.querySelector(n.target) : n.target || document.body;
|
|
1914
|
+
s && s !== document.body && (s.style.position = "relative"), (s || document.body).appendChild(t);
|
|
1915
|
+
}
|
|
1916
|
+
const e = document.createElement("div");
|
|
1917
|
+
if (e.className = "mk-loading__spinner", t.appendChild(e), n.text) {
|
|
1918
|
+
const s = document.createElement("div");
|
|
1919
|
+
s.className = "mk-loading__text", s.textContent = n.text, t.appendChild(s);
|
|
1920
|
+
}
|
|
1921
|
+
return () => {
|
|
1922
|
+
t.remove();
|
|
1923
|
+
};
|
|
1924
|
+
}
|
|
1925
|
+
function Ts(n) {
|
|
1926
|
+
return he({ fullscreen: !0, text: n });
|
|
1927
|
+
}
|
|
1928
|
+
class pe {
|
|
1929
|
+
constructor(t, e) {
|
|
1930
|
+
c(this, "el");
|
|
1931
|
+
c(this, "trigger");
|
|
1932
|
+
c(this, "dropdown");
|
|
1933
|
+
c(this, "options");
|
|
1934
|
+
c(this, "_value");
|
|
1935
|
+
c(this, "isOpen", !1);
|
|
1936
|
+
c(this, "_cleanupKey");
|
|
1937
|
+
const s = typeof t == "string" ? document.querySelector(t) : t;
|
|
1938
|
+
this.options = e, this._value = e.value, this.el = document.createElement("div"), this.el.className = "mk-select", this.trigger = document.createElement("div"), this.trigger.className = "mk-select__trigger", this.trigger.setAttribute("role", "combobox"), this.trigger.setAttribute("aria-haspopup", "listbox"), this.trigger.setAttribute("aria-expanded", "false"), this.trigger.setAttribute("tabindex", "0"), this.trigger.addEventListener("click", () => this.toggle());
|
|
1939
|
+
const i = document.createElement("span");
|
|
1940
|
+
i.className = "mk-select__label", this.updateLabel(i), this.trigger.appendChild(i);
|
|
1941
|
+
const o = document.createElement("span");
|
|
1942
|
+
o.className = "mk-select__arrow", o.textContent = "▼", this.trigger.appendChild(o), this.dropdown = document.createElement("div"), this.dropdown.className = "mk-select__dropdown", this.dropdown.setAttribute("role", "listbox"), e.options.forEach((r) => {
|
|
1943
|
+
const a = document.createElement("div");
|
|
1944
|
+
a.className = "mk-select__option", a.textContent = r.label, a.setAttribute("role", "option"), a.setAttribute("aria-selected", String(r.value === this._value)), r.disabled && (a.setAttribute("aria-disabled", "true"), a.style.opacity = "0.4", a.style.pointerEvents = "none"), a.addEventListener("click", () => {
|
|
1945
|
+
this.setValue(r.value), this.close();
|
|
1946
|
+
}), this.dropdown.appendChild(a);
|
|
1947
|
+
}), this.el.appendChild(this.trigger), this.el.appendChild(this.dropdown), s.appendChild(this.el), this._cleanupKey = k(this.trigger, [
|
|
1948
|
+
{ key: f.ArrowDown, handler: () => this.moveSelection(1) },
|
|
1949
|
+
{ key: f.ArrowUp, handler: () => this.moveSelection(-1) },
|
|
1950
|
+
{ key: f.Enter, handler: () => {
|
|
1951
|
+
this.isOpen ? this.close() : this.open();
|
|
1952
|
+
} },
|
|
1953
|
+
{ key: f.Escape, handler: () => this.close() }
|
|
1954
|
+
]), document.addEventListener("click", (r) => {
|
|
1955
|
+
this.el.contains(r.target) || this.close();
|
|
1956
|
+
});
|
|
1957
|
+
}
|
|
1958
|
+
updateLabel(t) {
|
|
1959
|
+
const e = this.options.options.find((s) => s.value === this._value);
|
|
1960
|
+
e ? (t.textContent = e.label, t.classList.remove("mk-select__placeholder")) : (t.textContent = this.options.placeholder || "请选择", t.classList.add("mk-select__placeholder"));
|
|
1961
|
+
}
|
|
1962
|
+
get value() {
|
|
1963
|
+
return this._value;
|
|
1964
|
+
}
|
|
1965
|
+
setValue(t) {
|
|
1966
|
+
var s, i;
|
|
1967
|
+
this._value = t;
|
|
1968
|
+
const e = this.trigger.querySelector(".mk-select__label");
|
|
1969
|
+
this.updateLabel(e), this.renderOptions(), (i = (s = this.options).onChange) == null || i.call(s, t);
|
|
1970
|
+
}
|
|
1971
|
+
renderOptions() {
|
|
1972
|
+
this.dropdown.querySelectorAll(".mk-select__option").forEach((e, s) => {
|
|
1973
|
+
const i = this.options.options[s];
|
|
1974
|
+
e.classList.toggle("is-selected", i.value === this._value), e.setAttribute("aria-selected", String(i.value === this._value));
|
|
1975
|
+
});
|
|
1976
|
+
}
|
|
1977
|
+
toggle() {
|
|
1978
|
+
this.isOpen ? this.close() : this.open();
|
|
1979
|
+
}
|
|
1980
|
+
open() {
|
|
1981
|
+
this.isOpen = !0, this.trigger.setAttribute("aria-expanded", "true"), this.trigger.classList.add("is-open"), this.dropdown.classList.add("is-open"), this.renderOptions();
|
|
1982
|
+
}
|
|
1983
|
+
close() {
|
|
1984
|
+
this.isOpen = !1, this.trigger.setAttribute("aria-expanded", "false"), this.trigger.classList.remove("is-open"), this.dropdown.classList.remove("is-open");
|
|
1985
|
+
}
|
|
1986
|
+
moveSelection(t) {
|
|
1987
|
+
this.isOpen || this.open();
|
|
1988
|
+
let s = this.options.options.findIndex((i) => i.value === this._value);
|
|
1989
|
+
for (let i = 0; i < this.options.options.length; i++)
|
|
1990
|
+
if (s = (s + t + this.options.options.length) % this.options.options.length, !this.options.options[s].disabled) {
|
|
1991
|
+
this.setValue(this.options.options[s].value);
|
|
1992
|
+
return;
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
destroy() {
|
|
1996
|
+
var t;
|
|
1997
|
+
(t = this._cleanupKey) == null || t.call(this), this.el.remove();
|
|
1998
|
+
}
|
|
1999
|
+
}
|
|
2000
|
+
function Ss(n, t) {
|
|
2001
|
+
return new pe(n, t);
|
|
2002
|
+
}
|
|
2003
|
+
class W {
|
|
2004
|
+
constructor(t, e = {}) {
|
|
2005
|
+
c(this, "el");
|
|
2006
|
+
c(this, "options");
|
|
2007
|
+
c(this, "_checked");
|
|
2008
|
+
c(this, "_cleanupKey");
|
|
2009
|
+
const s = typeof t == "string" ? document.querySelector(t) : t;
|
|
2010
|
+
this.options = { checked: !1, ...e }, this._checked = this.options.checked, this.el = document.createElement("label"), this.el.className = "mk-checkbox", this._checked && this.el.classList.add("is-checked"), this.options.disabled && this.el.classList.add("is-disabled"), this.el.setAttribute("role", "checkbox"), this.el.setAttribute("aria-checked", String(this._checked)), this.options.disabled || this.el.setAttribute("tabindex", "0");
|
|
2011
|
+
const i = document.createElement("span");
|
|
2012
|
+
i.className = "mk-checkbox__input";
|
|
2013
|
+
const o = document.createElement("span");
|
|
2014
|
+
if (o.className = "mk-checkbox__check", o.textContent = "✓", i.appendChild(o), this.el.appendChild(i), this.options.label) {
|
|
2015
|
+
const r = document.createElement("span");
|
|
2016
|
+
r.textContent = this.options.label, this.el.appendChild(r);
|
|
2017
|
+
}
|
|
2018
|
+
this.el.addEventListener("click", () => {
|
|
2019
|
+
this.options.disabled || this.toggle();
|
|
2020
|
+
}), this._cleanupKey = k(this.el, [
|
|
2021
|
+
{ key: f.Space, handler: () => this.toggle() }
|
|
2022
|
+
]), s.appendChild(this.el);
|
|
2023
|
+
}
|
|
2024
|
+
get checked() {
|
|
2025
|
+
return this._checked;
|
|
2026
|
+
}
|
|
2027
|
+
set checked(t) {
|
|
2028
|
+
var e, s;
|
|
2029
|
+
this._checked = t, this.el.classList.toggle("is-checked", t), this.el.setAttribute("aria-checked", String(t)), (s = (e = this.options).onChange) == null || s.call(e, t);
|
|
2030
|
+
}
|
|
2031
|
+
toggle() {
|
|
2032
|
+
this.checked = !this._checked;
|
|
2033
|
+
}
|
|
2034
|
+
destroy() {
|
|
2035
|
+
var t;
|
|
2036
|
+
(t = this._cleanupKey) == null || t.call(this), this.el.remove();
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
function As(n, t) {
|
|
2040
|
+
return new W(n, t);
|
|
2041
|
+
}
|
|
2042
|
+
class $s {
|
|
2043
|
+
constructor(t) {
|
|
2044
|
+
c(this, "el");
|
|
2045
|
+
c(this, "checkboxes", []);
|
|
2046
|
+
const e = typeof t == "string" ? document.querySelector(t) : t;
|
|
2047
|
+
this.el = document.createElement("div"), this.el.className = "mk-checkbox-group", e.appendChild(this.el);
|
|
2048
|
+
}
|
|
2049
|
+
add(t) {
|
|
2050
|
+
const e = new W(this.el, t);
|
|
2051
|
+
return this.checkboxes.push(e), e;
|
|
2052
|
+
}
|
|
2053
|
+
getValues() {
|
|
2054
|
+
return this.checkboxes.map((t) => t.checked);
|
|
2055
|
+
}
|
|
2056
|
+
destroy() {
|
|
2057
|
+
this.el.remove();
|
|
2058
|
+
}
|
|
2059
|
+
}
|
|
2060
|
+
class ue {
|
|
2061
|
+
constructor(t, e) {
|
|
2062
|
+
c(this, "el");
|
|
2063
|
+
c(this, "options");
|
|
2064
|
+
c(this, "_checked");
|
|
2065
|
+
const s = typeof t == "string" ? document.querySelector(t) : t;
|
|
2066
|
+
this.options = { checked: !1, ...e }, this._checked = this.options.checked, this.el = document.createElement("label"), this.el.className = "mk-radio", this._checked && this.el.classList.add("is-checked"), this.options.disabled && this.el.classList.add("is-disabled"), this.el.setAttribute("role", "radio"), this.el.setAttribute("aria-checked", String(this._checked));
|
|
2067
|
+
const i = document.createElement("span");
|
|
2068
|
+
i.className = "mk-radio__input";
|
|
2069
|
+
const o = document.createElement("span");
|
|
2070
|
+
if (o.className = "mk-radio__dot", i.appendChild(o), this.el.appendChild(i), this.options.label) {
|
|
2071
|
+
const r = document.createElement("span");
|
|
2072
|
+
r.textContent = this.options.label, this.el.appendChild(r);
|
|
2073
|
+
}
|
|
2074
|
+
this.el.addEventListener("click", () => {
|
|
2075
|
+
var r, a;
|
|
2076
|
+
this.options.disabled || (a = (r = this.options).onChange) == null || a.call(r, this.options.value);
|
|
2077
|
+
}), s.appendChild(this.el);
|
|
2078
|
+
}
|
|
2079
|
+
setChecked(t) {
|
|
2080
|
+
this._checked = t, this.el.classList.toggle("is-checked", t), this.el.setAttribute("aria-checked", String(t));
|
|
2081
|
+
}
|
|
2082
|
+
getValue() {
|
|
2083
|
+
return this.options.value;
|
|
2084
|
+
}
|
|
2085
|
+
destroy() {
|
|
2086
|
+
this.el.remove();
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
class Is {
|
|
2090
|
+
constructor(t, e = {}) {
|
|
2091
|
+
c(this, "el");
|
|
2092
|
+
c(this, "radios", []);
|
|
2093
|
+
c(this, "_value");
|
|
2094
|
+
c(this, "_cleanupKey");
|
|
2095
|
+
const s = typeof t == "string" ? document.querySelector(t) : t;
|
|
2096
|
+
this._value = e.value, this.el = document.createElement("div"), this.el.className = "mk-radio-group", this.el.setAttribute("role", "radiogroup"), s.appendChild(this.el), this._cleanupKey = k(this.el, [
|
|
2097
|
+
{ key: f.ArrowUp, handler: () => this.focusRadio(-1) },
|
|
2098
|
+
{ key: f.ArrowLeft, handler: () => this.focusRadio(-1) },
|
|
2099
|
+
{ key: f.ArrowDown, handler: () => this.focusRadio(1) },
|
|
2100
|
+
{ key: f.ArrowRight, handler: () => this.focusRadio(1) }
|
|
2101
|
+
]);
|
|
2102
|
+
}
|
|
2103
|
+
add(t) {
|
|
2104
|
+
const e = new ue(this.el, {
|
|
2105
|
+
...t,
|
|
2106
|
+
onChange: (i) => {
|
|
2107
|
+
this.setValue(i);
|
|
2108
|
+
}
|
|
2109
|
+
}), s = t.value === this._value;
|
|
2110
|
+
return e.setChecked(s), this._value === void 0 && this.radios.length === 0 ? e.el.setAttribute("tabindex", "0") : e.el.setAttribute("tabindex", s ? "0" : "-1"), this.radios.push(e), e;
|
|
2111
|
+
}
|
|
2112
|
+
setValue(t) {
|
|
2113
|
+
this._value = t, this.radios.forEach((e) => {
|
|
2114
|
+
const s = e.getValue() === t;
|
|
2115
|
+
e.setChecked(s), e.el.setAttribute("tabindex", s ? "0" : "-1");
|
|
2116
|
+
});
|
|
2117
|
+
}
|
|
2118
|
+
getValue() {
|
|
2119
|
+
return this._value;
|
|
2120
|
+
}
|
|
2121
|
+
focusRadio(t) {
|
|
2122
|
+
let e = this.radios.findIndex((i) => i.el.getAttribute("tabindex") === "0");
|
|
2123
|
+
e === -1 && (e = this.radios.findIndex((i) => i.el.classList.contains("is-checked"))), e === -1 && (e = 0);
|
|
2124
|
+
let s = e;
|
|
2125
|
+
for (let i = 0; i < this.radios.length && (s = (s + t + this.radios.length) % this.radios.length, !!this.radios[s].el.classList.contains("is-disabled")); i++)
|
|
2126
|
+
;
|
|
2127
|
+
(s !== e || this.radios.length === 1) && (this.radios.forEach((i, o) => i.el.setAttribute("tabindex", o === s ? "0" : "-1")), this.radios[s].el.focus(), this.setValue(this.radios[s].getValue()));
|
|
2128
|
+
}
|
|
2129
|
+
destroy() {
|
|
2130
|
+
var t;
|
|
2131
|
+
(t = this._cleanupKey) == null || t.call(this), this.el.remove();
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2134
|
+
class Ms {
|
|
2135
|
+
constructor(t, e = {}) {
|
|
2136
|
+
c(this, "el");
|
|
2137
|
+
c(this, "track");
|
|
2138
|
+
c(this, "fill");
|
|
2139
|
+
c(this, "thumb");
|
|
2140
|
+
c(this, "valueEl");
|
|
2141
|
+
c(this, "options");
|
|
2142
|
+
c(this, "_value");
|
|
2143
|
+
c(this, "dragging", !1);
|
|
2144
|
+
c(this, "_cleanupKey");
|
|
2145
|
+
const s = typeof t == "string" ? document.querySelector(t) : t;
|
|
2146
|
+
this.options = {
|
|
2147
|
+
min: 0,
|
|
2148
|
+
max: 100,
|
|
2149
|
+
step: 1,
|
|
2150
|
+
value: 0,
|
|
2151
|
+
showValue: !0,
|
|
2152
|
+
...e
|
|
2153
|
+
}, this._value = this.options.value, this.el = document.createElement("div"), this.el.className = "mk-slider", this.track = document.createElement("div"), this.track.className = "mk-slider__track", this.fill = document.createElement("div"), this.fill.className = "mk-slider__fill", this.track.appendChild(this.fill), this.thumb = document.createElement("div"), this.thumb.className = "mk-slider__thumb", this.thumb.setAttribute("role", "slider"), this.thumb.setAttribute("tabindex", "0"), this.track.appendChild(this.thumb), this.el.appendChild(this.track), this.options.showValue && (this.valueEl = document.createElement("div"), this.valueEl.className = "mk-slider__value", this.el.appendChild(this.valueEl)), this.updateUI(), this._cleanupKey = k(this.thumb, [
|
|
2154
|
+
{ key: f.ArrowLeft, handler: () => this.adjustValue(-this.options.step) },
|
|
2155
|
+
{ key: f.ArrowRight, handler: () => this.adjustValue(this.options.step) },
|
|
2156
|
+
{ key: f.Home, handler: () => {
|
|
2157
|
+
this.value = this.options.min;
|
|
2158
|
+
} },
|
|
2159
|
+
{ key: f.End, handler: () => {
|
|
2160
|
+
this.value = this.options.max;
|
|
2161
|
+
} }
|
|
2162
|
+
]), this.track.addEventListener("mousedown", (i) => this.onStart(i.clientX)), this.thumb.addEventListener("mousedown", (i) => {
|
|
2163
|
+
i.stopPropagation(), this.onStart(i.clientX);
|
|
2164
|
+
}), document.addEventListener("mousemove", (i) => this.onMove(i.clientX)), document.addEventListener("mouseup", () => this.onEnd()), this.track.addEventListener("touchstart", (i) => this.onStart(i.touches[0].clientX), { passive: !0 }), document.addEventListener("touchmove", (i) => this.onMove(i.touches[0].clientX), { passive: !0 }), document.addEventListener("touchend", () => this.onEnd()), s.appendChild(this.el);
|
|
2165
|
+
}
|
|
2166
|
+
onStart(t) {
|
|
2167
|
+
this.dragging = !0, this.updateFromPosition(t);
|
|
2168
|
+
}
|
|
2169
|
+
onMove(t) {
|
|
2170
|
+
this.dragging && this.updateFromPosition(t);
|
|
2171
|
+
}
|
|
2172
|
+
onEnd() {
|
|
2173
|
+
this.dragging = !1;
|
|
2174
|
+
}
|
|
2175
|
+
updateFromPosition(t) {
|
|
2176
|
+
const e = this.track.getBoundingClientRect(), s = Math.max(0, Math.min(1, (t - e.left) / e.width)), i = this.options.min + s * (this.options.max - this.options.min), o = Math.round(i / this.options.step) * this.options.step;
|
|
2177
|
+
this.value = Math.max(this.options.min, Math.min(this.options.max, o));
|
|
2178
|
+
}
|
|
2179
|
+
get value() {
|
|
2180
|
+
return this._value;
|
|
2181
|
+
}
|
|
2182
|
+
set value(t) {
|
|
2183
|
+
var e, s;
|
|
2184
|
+
this._value !== t && (this._value = t, this.updateUI(), (s = (e = this.options).onChange) == null || s.call(e, t));
|
|
2185
|
+
}
|
|
2186
|
+
updateUI() {
|
|
2187
|
+
const t = (this._value - this.options.min) / (this.options.max - this.options.min);
|
|
2188
|
+
this.fill.style.width = `${t * 100}%`, this.thumb.style.left = `${t * 100}%`, this.valueEl && (this.valueEl.textContent = String(this._value)), this.updateAria();
|
|
2189
|
+
}
|
|
2190
|
+
updateAria() {
|
|
2191
|
+
this.thumb.setAttribute("aria-valuenow", String(this._value)), this.thumb.setAttribute("aria-valuemin", String(this.options.min)), this.thumb.setAttribute("aria-valuemax", String(this.options.max));
|
|
2192
|
+
}
|
|
2193
|
+
adjustValue(t) {
|
|
2194
|
+
this.value = Math.max(this.options.min, Math.min(this.options.max, this._value + t));
|
|
2195
|
+
}
|
|
2196
|
+
destroy() {
|
|
2197
|
+
var t;
|
|
2198
|
+
(t = this._cleanupKey) == null || t.call(this), this.el.remove();
|
|
2199
|
+
}
|
|
2200
|
+
}
|
|
2201
|
+
class Ns {
|
|
2202
|
+
constructor(t, e) {
|
|
2203
|
+
c(this, "el");
|
|
2204
|
+
c(this, "table");
|
|
2205
|
+
c(this, "tbody");
|
|
2206
|
+
c(this, "columns");
|
|
2207
|
+
c(this, "data");
|
|
2208
|
+
c(this, "pageSize");
|
|
2209
|
+
c(this, "currentPage", 1);
|
|
2210
|
+
c(this, "sortState", null);
|
|
2211
|
+
c(this, "editingRow", null);
|
|
2212
|
+
c(this, "editCache", null);
|
|
2213
|
+
c(this, "filteredData");
|
|
2214
|
+
c(this, "callbacks");
|
|
2215
|
+
const s = typeof t == "string" ? document.querySelector(t) : t;
|
|
2216
|
+
this.columns = e.columns, this.data = e.data, this.pageSize = e.pageSize || 10, this.filteredData = [...this.data], this.callbacks = e, this.el = document.createElement("div"), this.el.className = "mk-table-wrapper", this.table = document.createElement("table"), this.table.className = "mk-table", this.table.setAttribute("role", "table");
|
|
2217
|
+
const i = document.createElement("thead");
|
|
2218
|
+
i.setAttribute("role", "rowgroup");
|
|
2219
|
+
const o = document.createElement("tr");
|
|
2220
|
+
o.setAttribute("role", "row"), this.columns.forEach((r) => {
|
|
2221
|
+
const a = document.createElement("th");
|
|
2222
|
+
if (a.setAttribute("role", "columnheader"), a.textContent = r.title, r.width && (a.style.width = r.width), r.sortable) {
|
|
2223
|
+
a.classList.add("is-sortable"), a.setAttribute("aria-sort", "none");
|
|
2224
|
+
const l = document.createElement("span");
|
|
2225
|
+
l.className = "mk-table__sort-icon", l.textContent = "⇅", a.appendChild(l), a.addEventListener("click", () => this.handleSort(r.key));
|
|
2226
|
+
}
|
|
2227
|
+
o.appendChild(a);
|
|
2228
|
+
}), i.appendChild(o), this.table.appendChild(i), this.tbody = document.createElement("tbody"), this.tbody.setAttribute("role", "rowgroup"), this.table.appendChild(this.tbody), this.el.appendChild(this.table), s.appendChild(this.el), this.render();
|
|
2229
|
+
}
|
|
2230
|
+
getDisplayData() {
|
|
2231
|
+
return this.sortState ? [...this.filteredData].sort((e, s) => {
|
|
2232
|
+
const i = e[this.sortState.key], o = s[this.sortState.key];
|
|
2233
|
+
return i < o ? this.sortState.order === "asc" ? -1 : 1 : i > o ? this.sortState.order === "asc" ? 1 : -1 : 0;
|
|
2234
|
+
}) : this.filteredData;
|
|
2235
|
+
}
|
|
2236
|
+
handleSort(t) {
|
|
2237
|
+
!this.sortState || this.sortState.key !== t ? this.sortState = { key: t, order: "asc" } : this.sortState.order === "asc" ? this.sortState.order = "desc" : this.sortState = null, this.render();
|
|
2238
|
+
}
|
|
2239
|
+
render() {
|
|
2240
|
+
this.tbody.innerHTML = "";
|
|
2241
|
+
const t = this.getDisplayData(), e = (this.currentPage - 1) * this.pageSize, s = t.slice(e, e + this.pageSize);
|
|
2242
|
+
if (s.length === 0) {
|
|
2243
|
+
const i = document.createElement("tr");
|
|
2244
|
+
i.setAttribute("role", "row");
|
|
2245
|
+
const o = document.createElement("td");
|
|
2246
|
+
o.setAttribute("role", "cell"), o.colSpan = this.columns.length, o.className = "mk-table__empty", o.textContent = "暂无数据", i.appendChild(o), this.tbody.appendChild(i);
|
|
2247
|
+
} else
|
|
2248
|
+
s.forEach((i, o) => {
|
|
2249
|
+
const r = e + o, a = document.createElement("tr");
|
|
2250
|
+
a.setAttribute("role", "row"), this.editingRow === r && a.classList.add("is-editing"), a.addEventListener("click", () => {
|
|
2251
|
+
var l, d;
|
|
2252
|
+
(d = (l = this.callbacks).onRowClick) == null || d.call(l, i, r);
|
|
2253
|
+
}), this.columns.forEach((l) => {
|
|
2254
|
+
const d = document.createElement("td");
|
|
2255
|
+
if (d.setAttribute("role", "cell"), this.editingRow === r && l.editable && l.key !== "actions") {
|
|
2256
|
+
const h = document.createElement("input");
|
|
2257
|
+
h.className = "mk-table__edit-input", h.value = String(this.editCache[l.key] ?? i[l.key] ?? ""), h.addEventListener("input", (p) => {
|
|
2258
|
+
this.editCache[l.key] = p.target.value;
|
|
2259
|
+
}), h.addEventListener("keydown", (p) => {
|
|
2260
|
+
p.key === "Enter" && this.saveEdit(), p.key === "Escape" && this.cancelEdit();
|
|
2261
|
+
}), d.appendChild(h);
|
|
2262
|
+
} else if (l.render) {
|
|
2263
|
+
const h = l.render(i[l.key], i, r);
|
|
2264
|
+
h instanceof HTMLElement ? d.appendChild(h) : typeof h == "string" && h.includes("<") ? d.innerHTML = h : d.textContent = String(h);
|
|
2265
|
+
} else
|
|
2266
|
+
d.textContent = i[l.key] !== void 0 ? String(i[l.key]) : "";
|
|
2267
|
+
a.appendChild(d);
|
|
2268
|
+
}), this.tbody.appendChild(a);
|
|
2269
|
+
});
|
|
2270
|
+
this.renderPagination(t.length), this.updateSortIcons();
|
|
2271
|
+
}
|
|
2272
|
+
updateSortIcons() {
|
|
2273
|
+
const t = this.table.querySelectorAll("th");
|
|
2274
|
+
if (t.forEach((e) => {
|
|
2275
|
+
const s = e.querySelector(".mk-table__sort-icon");
|
|
2276
|
+
s && (s.classList.remove("is-active"), s.textContent = "⇅", e.setAttribute("aria-sort", "none"));
|
|
2277
|
+
}), this.sortState) {
|
|
2278
|
+
const e = this.columns.findIndex((s) => s.key === this.sortState.key);
|
|
2279
|
+
if (e >= 0) {
|
|
2280
|
+
const s = t[e], i = s == null ? void 0 : s.querySelector(".mk-table__sort-icon");
|
|
2281
|
+
i && (i.classList.add("is-active"), i.textContent = this.sortState.order === "asc" ? "↑" : "↓"), s && s.setAttribute("aria-sort", this.sortState.order === "asc" ? "ascending" : "descending");
|
|
2282
|
+
}
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2285
|
+
renderPagination(t) {
|
|
2286
|
+
const e = this.el.querySelector(".mk-pagination");
|
|
2287
|
+
e == null || e.remove();
|
|
2288
|
+
const s = Math.max(1, Math.ceil(t / this.pageSize)), i = document.createElement("div");
|
|
2289
|
+
i.className = "mk-pagination";
|
|
2290
|
+
const o = document.createElement("span");
|
|
2291
|
+
o.className = "mk-pagination__total", o.textContent = `共 ${t} 条`, i.appendChild(o);
|
|
2292
|
+
const r = document.createElement("button");
|
|
2293
|
+
r.className = "mk-pagination__btn", r.textContent = "‹", r.disabled = this.currentPage <= 1, r.addEventListener("click", () => {
|
|
2294
|
+
this.currentPage > 1 && (this.currentPage--, this.render());
|
|
2295
|
+
}), i.appendChild(r);
|
|
2296
|
+
const a = 5;
|
|
2297
|
+
let l = Math.max(1, this.currentPage - Math.floor(a / 2)), d = Math.min(s, l + a - 1);
|
|
2298
|
+
if (d - l + 1 < a && (l = Math.max(1, d - a + 1)), l > 1 && (i.appendChild(this.createPageBtn(1)), l > 2)) {
|
|
2299
|
+
const u = document.createElement("span");
|
|
2300
|
+
u.className = "mk-pagination__btn", u.textContent = "...", u.style.cursor = "default", i.appendChild(u);
|
|
2301
|
+
}
|
|
2302
|
+
for (let u = l; u <= d; u++)
|
|
2303
|
+
i.appendChild(this.createPageBtn(u));
|
|
2304
|
+
if (d < s) {
|
|
2305
|
+
if (d < s - 1) {
|
|
2306
|
+
const u = document.createElement("span");
|
|
2307
|
+
u.className = "mk-pagination__btn", u.textContent = "...", u.style.cursor = "default", i.appendChild(u);
|
|
2308
|
+
}
|
|
2309
|
+
i.appendChild(this.createPageBtn(s));
|
|
2310
|
+
}
|
|
2311
|
+
const h = document.createElement("button");
|
|
2312
|
+
h.className = "mk-pagination__btn", h.textContent = "›", h.disabled = this.currentPage >= s, h.addEventListener("click", () => {
|
|
2313
|
+
this.currentPage < s && (this.currentPage++, this.render());
|
|
2314
|
+
}), i.appendChild(h);
|
|
2315
|
+
const p = document.createElement("span");
|
|
2316
|
+
p.className = "mk-pagination__size", p.innerHTML = `
|
|
2317
|
+
每页
|
|
2318
|
+
<select>
|
|
2319
|
+
<option value="10" ${this.pageSize === 10 ? "selected" : ""}>10</option>
|
|
2320
|
+
<option value="20" ${this.pageSize === 20 ? "selected" : ""}>20</option>
|
|
2321
|
+
<option value="50" ${this.pageSize === 50 ? "selected" : ""}>50</option>
|
|
2322
|
+
</select>
|
|
2323
|
+
条
|
|
2324
|
+
`, p.querySelector("select").addEventListener("change", (u) => {
|
|
2325
|
+
this.pageSize = Number(u.target.value), this.currentPage = 1, this.render();
|
|
2326
|
+
}), i.appendChild(p), this.el.appendChild(i);
|
|
2327
|
+
}
|
|
2328
|
+
createPageBtn(t) {
|
|
2329
|
+
const e = document.createElement("button");
|
|
2330
|
+
return e.className = "mk-pagination__btn", e.textContent = String(t), t === this.currentPage && e.classList.add("is-active"), e.addEventListener("click", () => {
|
|
2331
|
+
this.currentPage = t, this.render();
|
|
2332
|
+
}), e;
|
|
2333
|
+
}
|
|
2334
|
+
setData(t) {
|
|
2335
|
+
this.data = t, this.filteredData = [...t], this.currentPage = 1, this.render();
|
|
2336
|
+
}
|
|
2337
|
+
filter(t) {
|
|
2338
|
+
this.filteredData = this.data.filter(t), this.currentPage = 1, this.render();
|
|
2339
|
+
}
|
|
2340
|
+
clearFilter() {
|
|
2341
|
+
this.filteredData = [...this.data], this.currentPage = 1, this.render();
|
|
2342
|
+
}
|
|
2343
|
+
startEdit(t) {
|
|
2344
|
+
this.editingRow = t, this.editCache = { ...this.filteredData[t] }, this.render();
|
|
2345
|
+
const e = this.tbody.querySelector(".mk-table__edit-input");
|
|
2346
|
+
e == null || e.focus();
|
|
2347
|
+
}
|
|
2348
|
+
saveEdit() {
|
|
2349
|
+
var t, e;
|
|
2350
|
+
if (this.editingRow !== null && this.editCache) {
|
|
2351
|
+
const s = this.editCache;
|
|
2352
|
+
this.filteredData[this.editingRow] = s;
|
|
2353
|
+
const i = this.data.findIndex(
|
|
2354
|
+
(o, r) => r === this.editingRow || JSON.stringify(o) === JSON.stringify(s)
|
|
2355
|
+
);
|
|
2356
|
+
i >= 0 && (this.data[i] = s), (e = (t = this.callbacks).onEdit) == null || e.call(t, s, this.editingRow);
|
|
2357
|
+
}
|
|
2358
|
+
this.editingRow = null, this.editCache = null, this.render();
|
|
2359
|
+
}
|
|
2360
|
+
cancelEdit() {
|
|
2361
|
+
this.editingRow = null, this.editCache = null, this.render();
|
|
2362
|
+
}
|
|
2363
|
+
deleteRow(t) {
|
|
2364
|
+
var s, i;
|
|
2365
|
+
const e = this.filteredData[t];
|
|
2366
|
+
this.data = this.data.filter((o) => o !== e), this.filteredData = this.filteredData.filter((o) => o !== e), (i = (s = this.callbacks).onDelete) == null || i.call(s, e, t), this.filteredData.length <= (this.currentPage - 1) * this.pageSize && this.currentPage > 1 && this.currentPage--, this.render();
|
|
2367
|
+
}
|
|
2368
|
+
destroy() {
|
|
2369
|
+
this.el.remove();
|
|
2370
|
+
}
|
|
2371
|
+
}
|
|
2372
|
+
class me {
|
|
2373
|
+
constructor(t, e = {}) {
|
|
2374
|
+
c(this, "el");
|
|
2375
|
+
c(this, "options");
|
|
2376
|
+
c(this, "motion", null);
|
|
2377
|
+
c(this, "_cleanupCloseKey");
|
|
2378
|
+
const s = typeof t == "string" ? document.querySelector(t) : t;
|
|
2379
|
+
if (this.options = {
|
|
2380
|
+
type: "default",
|
|
2381
|
+
size: "default",
|
|
2382
|
+
...e
|
|
2383
|
+
}, this.el = document.createElement("span"), this.el.className = this.buildClass(), this.options.text && (this.el.textContent = this.options.text), this.options.closable) {
|
|
2384
|
+
const i = document.createElement("span");
|
|
2385
|
+
i.className = "mk-tag__close", i.innerHTML = "×", i.setAttribute("role", "button"), i.setAttribute("tabindex", "0"), i.setAttribute("aria-label", "Close"), i.addEventListener("click", (o) => {
|
|
2386
|
+
o.stopPropagation(), this.close();
|
|
2387
|
+
}), this._cleanupCloseKey = k(i, [
|
|
2388
|
+
{ key: f.Enter, handler: () => this.close() },
|
|
2389
|
+
{ key: f.Space, handler: () => this.close() }
|
|
2390
|
+
]), this.el.appendChild(i);
|
|
2391
|
+
}
|
|
2392
|
+
s.appendChild(this.el), this.motion = _(this.el, e.motion || { hover: "scale", enter: "zoomIn", duration: 200 });
|
|
2393
|
+
}
|
|
2394
|
+
buildClass() {
|
|
2395
|
+
const t = ["mk-tag"];
|
|
2396
|
+
return this.options.type && this.options.type !== "default" && t.push(`mk-tag--${this.options.type}`), this.options.size && this.options.size !== "default" && t.push(`mk-tag--${this.options.size}`), this.options.plain && t.push("is-plain"), this.options.round && t.push("is-round"), this.options.closable && t.push("is-closable"), t.join(" ");
|
|
2397
|
+
}
|
|
2398
|
+
setText(t) {
|
|
2399
|
+
if (this.options.text = t, this.options.closable) {
|
|
2400
|
+
const e = this.el.querySelector(".mk-tag__close");
|
|
2401
|
+
this.el.childNodes.forEach((s) => {
|
|
2402
|
+
s !== e && s.remove();
|
|
2403
|
+
}), this.el.insertBefore(document.createTextNode(t), e);
|
|
2404
|
+
} else
|
|
2405
|
+
this.el.textContent = t;
|
|
2406
|
+
}
|
|
2407
|
+
close() {
|
|
2408
|
+
var t, e, s;
|
|
2409
|
+
this.el.style.pointerEvents = "none", (t = this.motion) == null || t.playExit().then(() => {
|
|
2410
|
+
this.destroy();
|
|
2411
|
+
}), (s = (e = this.options).onClose) == null || s.call(e);
|
|
2412
|
+
}
|
|
2413
|
+
destroy() {
|
|
2414
|
+
var t, e;
|
|
2415
|
+
(t = this._cleanupCloseKey) == null || t.call(this), (e = this.motion) == null || e.destroy(), this.el.remove();
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
function Ps(n, t) {
|
|
2419
|
+
return new me(n, t);
|
|
2420
|
+
}
|
|
2421
|
+
let v = null, S = null, A = null, w = null, L = null, x = null;
|
|
2422
|
+
const j = "mk-tooltip";
|
|
2423
|
+
function P() {
|
|
2424
|
+
return v || (v = document.createElement("div"), v.className = "mk-tooltip", v.id = j, v.setAttribute("role", "tooltip"), v.style.position = "absolute", v.style.zIndex = "var(--mk-z-tooltip)", S = document.createElement("div"), S.className = "mk-tooltip__arrow", v.appendChild(S), A = document.createElement("div"), A.className = "mk-tooltip__content", v.appendChild(A), document.body.appendChild(v)), v;
|
|
2425
|
+
}
|
|
2426
|
+
function fe(n) {
|
|
2427
|
+
const e = P().querySelector(".mk-tooltip__content");
|
|
2428
|
+
e.innerHTML = "", typeof n == "string" ? e.textContent = n : e.appendChild(n);
|
|
2429
|
+
}
|
|
2430
|
+
function ye(n, t, e) {
|
|
2431
|
+
const s = P(), i = s.querySelector(".mk-tooltip__arrow"), o = n.getBoundingClientRect(), r = s.getBoundingClientRect(), a = window.scrollX, l = window.scrollY;
|
|
2432
|
+
let d = 0, h = 0, p = "";
|
|
2433
|
+
switch (t) {
|
|
2434
|
+
case "top":
|
|
2435
|
+
d = o.top + l - r.height - e, h = o.left + a + o.width / 2 - r.width / 2, p = "is-bottom";
|
|
2436
|
+
break;
|
|
2437
|
+
case "bottom":
|
|
2438
|
+
d = o.bottom + l + e, h = o.left + a + o.width / 2 - r.width / 2, p = "is-top";
|
|
2439
|
+
break;
|
|
2440
|
+
case "left":
|
|
2441
|
+
d = o.top + l + o.height / 2 - r.height / 2, h = o.left + a - r.width - e, p = "is-right";
|
|
2442
|
+
break;
|
|
2443
|
+
case "right":
|
|
2444
|
+
d = o.top + l + o.height / 2 - r.height / 2, h = o.right + a + e, p = "is-left";
|
|
2445
|
+
break;
|
|
2446
|
+
default:
|
|
2447
|
+
d = o.top + l - r.height - e, h = o.left + a + o.width / 2 - r.width / 2, p = "is-bottom";
|
|
2448
|
+
}
|
|
2449
|
+
const u = 8;
|
|
2450
|
+
h < u && (h = u), h + r.width > window.innerWidth - u && (h = window.innerWidth - r.width - u), d < u && (d = u), s.style.top = `${d}px`, s.style.left = `${h}px`, i.className = `mk-tooltip__arrow ${p}`;
|
|
2451
|
+
}
|
|
2452
|
+
function ge(n, t) {
|
|
2453
|
+
L && (clearTimeout(L), L = null), x = n, n.setAttribute("aria-describedby", j), fe(t.content);
|
|
2454
|
+
const e = P();
|
|
2455
|
+
e.classList.remove("is-visible"), e.style.visibility = "hidden", e.style.display = "block", requestAnimationFrame(() => {
|
|
2456
|
+
x === n && (ye(n, t.placement, t.offset), e.style.visibility = "visible", e.classList.add("is-visible"));
|
|
2457
|
+
});
|
|
2458
|
+
}
|
|
2459
|
+
function z() {
|
|
2460
|
+
v && (v.classList.remove("is-visible"), L = setTimeout(() => {
|
|
2461
|
+
v != null && v.classList.contains("is-visible") || (v.style.display = "none");
|
|
2462
|
+
}, 200), x && x.removeAttribute("aria-describedby"), x = null);
|
|
2463
|
+
}
|
|
2464
|
+
function qs(n, t = {}) {
|
|
2465
|
+
const e = {
|
|
2466
|
+
content: "",
|
|
2467
|
+
placement: "top",
|
|
2468
|
+
delay: 150,
|
|
2469
|
+
offset: 8,
|
|
2470
|
+
...t
|
|
2471
|
+
}, s = () => {
|
|
2472
|
+
w && clearTimeout(w), w = setTimeout(() => {
|
|
2473
|
+
ge(n, e);
|
|
2474
|
+
}, e.delay);
|
|
2475
|
+
}, i = () => {
|
|
2476
|
+
w && (clearTimeout(w), w = null), z();
|
|
2477
|
+
};
|
|
2478
|
+
return n.addEventListener("mouseenter", s), n.addEventListener("mouseleave", i), n.addEventListener("focus", s), n.addEventListener("blur", i), () => {
|
|
2479
|
+
n.removeEventListener("mouseenter", s), n.removeEventListener("mouseleave", i), n.removeEventListener("focus", s), n.removeEventListener("blur", i), x === n && z();
|
|
2480
|
+
};
|
|
2481
|
+
}
|
|
2482
|
+
let ve = 0;
|
|
2483
|
+
class be {
|
|
2484
|
+
constructor(t, e = {}) {
|
|
2485
|
+
c(this, "el");
|
|
2486
|
+
c(this, "options");
|
|
2487
|
+
c(this, "headerEl");
|
|
2488
|
+
c(this, "contentEl");
|
|
2489
|
+
c(this, "indicatorEl", null);
|
|
2490
|
+
c(this, "tabItems", []);
|
|
2491
|
+
c(this, "panels", []);
|
|
2492
|
+
c(this, "currentIndex");
|
|
2493
|
+
c(this, "tabIdPrefix");
|
|
2494
|
+
const s = typeof t == "string" ? document.querySelector(t) : t;
|
|
2495
|
+
this.options = {
|
|
2496
|
+
type: "line",
|
|
2497
|
+
items: [],
|
|
2498
|
+
activeIndex: 0,
|
|
2499
|
+
...e
|
|
2500
|
+
}, this.currentIndex = this.options.activeIndex, this.tabIdPrefix = `mk-tabs-${++ve}`, this.el = document.createElement("div"), this.el.className = `mk-tabs mk-tabs--${this.options.type}`, this.headerEl = document.createElement("div"), this.headerEl.className = "mk-tabs__header", this.headerEl.setAttribute("role", "tablist"), this.el.appendChild(this.headerEl), this.contentEl = document.createElement("div"), this.contentEl.className = "mk-tabs__content", this.el.appendChild(this.contentEl), this.options.type === "line" && (this.indicatorEl = document.createElement("div"), this.indicatorEl.className = "mk-tabs__indicator", this.headerEl.appendChild(this.indicatorEl)), this.renderTabs(), this.setActive(this.currentIndex, !1), s.appendChild(this.el);
|
|
2501
|
+
}
|
|
2502
|
+
renderTabs() {
|
|
2503
|
+
var t;
|
|
2504
|
+
(t = this.options.items) == null || t.forEach((e, s) => {
|
|
2505
|
+
const i = `${this.tabIdPrefix}-panel-${s}`, o = `${this.tabIdPrefix}-tab-${s}`, r = document.createElement("button");
|
|
2506
|
+
r.className = "mk-tabs__item", r.type = "button", r.textContent = e.label, r.id = o, r.setAttribute("role", "tab"), r.setAttribute("aria-controls", i), e.disabled && (r.disabled = !0, r.classList.add("is-disabled")), r.addEventListener("click", () => {
|
|
2507
|
+
e.disabled || this.setActive(s);
|
|
2508
|
+
}), this.headerEl.appendChild(r), this.tabItems.push(r);
|
|
2509
|
+
const a = document.createElement("div");
|
|
2510
|
+
a.className = "mk-tabs__panel", a.id = i, a.setAttribute("role", "tabpanel"), a.setAttribute("aria-labelledby", o), e.content && (typeof e.content == "string" ? a.textContent = e.content : a.appendChild(e.content)), this.contentEl.appendChild(a), this.panels.push(a);
|
|
2511
|
+
}), this.headerEl.addEventListener("keydown", (e) => {
|
|
2512
|
+
if (![f.ArrowLeft, f.ArrowRight, f.Home, f.End].includes(e.key)) return;
|
|
2513
|
+
const s = this.tabItems.filter((l, d) => {
|
|
2514
|
+
var h, p;
|
|
2515
|
+
return !((p = (h = this.options.items) == null ? void 0 : h[d]) != null && p.disabled);
|
|
2516
|
+
}), i = this.tabItems[this.currentIndex];
|
|
2517
|
+
let o = s.indexOf(i);
|
|
2518
|
+
o === -1 && (o = 0);
|
|
2519
|
+
let r = o;
|
|
2520
|
+
switch (e.key) {
|
|
2521
|
+
case f.ArrowLeft:
|
|
2522
|
+
e.preventDefault(), r = o > 0 ? o - 1 : s.length - 1;
|
|
2523
|
+
break;
|
|
2524
|
+
case f.ArrowRight:
|
|
2525
|
+
e.preventDefault(), r = o < s.length - 1 ? o + 1 : 0;
|
|
2526
|
+
break;
|
|
2527
|
+
case f.Home:
|
|
2528
|
+
e.preventDefault(), r = 0;
|
|
2529
|
+
break;
|
|
2530
|
+
case f.End:
|
|
2531
|
+
e.preventDefault(), r = s.length - 1;
|
|
2532
|
+
break;
|
|
2533
|
+
}
|
|
2534
|
+
const a = s[r];
|
|
2535
|
+
if (a) {
|
|
2536
|
+
const l = this.tabItems.indexOf(a);
|
|
2537
|
+
this.setActive(l), a.focus();
|
|
2538
|
+
}
|
|
2539
|
+
});
|
|
2540
|
+
}
|
|
2541
|
+
setActive(t, e = !0) {
|
|
2542
|
+
var i, o, r, a;
|
|
2543
|
+
if (t < 0 || t >= this.tabItems.length || (o = (i = this.options.items) == null ? void 0 : i[t]) != null && o.disabled) return;
|
|
2544
|
+
const s = this.currentIndex;
|
|
2545
|
+
this.currentIndex = t, this.tabItems.forEach((l, d) => {
|
|
2546
|
+
const h = d === t;
|
|
2547
|
+
l.classList.toggle("is-active", h), l.setAttribute("aria-selected", String(h)), l.setAttribute("tabindex", h ? "0" : "-1");
|
|
2548
|
+
}), this.panels.forEach((l, d) => {
|
|
2549
|
+
const h = d === t;
|
|
2550
|
+
l.classList.toggle("is-active", h), h ? (l.style.display = "block", e && requestAnimationFrame(() => {
|
|
2551
|
+
l.classList.add("is-entering"), requestAnimationFrame(() => {
|
|
2552
|
+
l.classList.remove("is-entering");
|
|
2553
|
+
});
|
|
2554
|
+
})) : (l.style.display = "none", l.classList.remove("is-entering"));
|
|
2555
|
+
}), this.indicatorEl && this.updateIndicator(), s !== t && ((a = (r = this.options).onChange) == null || a.call(r, t));
|
|
2556
|
+
}
|
|
2557
|
+
updateIndicator() {
|
|
2558
|
+
if (!this.indicatorEl) return;
|
|
2559
|
+
const t = this.tabItems[this.currentIndex];
|
|
2560
|
+
if (!t) return;
|
|
2561
|
+
const e = this.headerEl.getBoundingClientRect(), s = t.getBoundingClientRect();
|
|
2562
|
+
this.indicatorEl.style.left = `${s.left - e.left + this.headerEl.scrollLeft}px`, this.indicatorEl.style.width = `${s.width}px`;
|
|
2563
|
+
}
|
|
2564
|
+
getActive() {
|
|
2565
|
+
return this.currentIndex;
|
|
2566
|
+
}
|
|
2567
|
+
destroy() {
|
|
2568
|
+
this.el.remove();
|
|
2569
|
+
}
|
|
2570
|
+
}
|
|
2571
|
+
function Ds(n, t) {
|
|
2572
|
+
return new be(n, t);
|
|
2573
|
+
}
|
|
2574
|
+
class Ee {
|
|
2575
|
+
constructor(t, e = {}) {
|
|
2576
|
+
c(this, "el");
|
|
2577
|
+
c(this, "options");
|
|
2578
|
+
const s = typeof t == "string" ? document.querySelector(t) : t;
|
|
2579
|
+
if (this.options = {
|
|
2580
|
+
size: "default",
|
|
2581
|
+
shape: "circle",
|
|
2582
|
+
...e
|
|
2583
|
+
}, this.el = document.createElement("div"), this.el.className = this.buildClass(), this.options.src) {
|
|
2584
|
+
const i = document.createElement("img");
|
|
2585
|
+
i.className = "mk-avatar__image", i.src = this.options.src, i.alt = this.options.text || "", i.addEventListener("error", () => this.showFallback()), this.el.appendChild(i);
|
|
2586
|
+
} else
|
|
2587
|
+
this.showFallback();
|
|
2588
|
+
s.appendChild(this.el);
|
|
2589
|
+
}
|
|
2590
|
+
buildClass() {
|
|
2591
|
+
const t = ["mk-avatar"];
|
|
2592
|
+
return this.options.size && this.options.size !== "default" && t.push(`mk-avatar--${this.options.size}`), this.options.shape && this.options.shape !== "circle" && t.push(`mk-avatar--${this.options.shape}`), t.join(" ");
|
|
2593
|
+
}
|
|
2594
|
+
showFallback() {
|
|
2595
|
+
const t = this.el.querySelector(".mk-avatar__image");
|
|
2596
|
+
t && t.remove();
|
|
2597
|
+
const e = document.createElement("span");
|
|
2598
|
+
e.className = "mk-avatar__fallback", this.options.icon ? e.textContent = this.options.icon : this.options.text ? e.textContent = this.options.text.split(" ").map((s) => s[0]).slice(0, 2).join("").toUpperCase() : e.textContent = "?", this.el.appendChild(e);
|
|
2599
|
+
}
|
|
2600
|
+
setSrc(t) {
|
|
2601
|
+
this.options.src = t;
|
|
2602
|
+
const e = this.el.querySelector(".mk-avatar__fallback");
|
|
2603
|
+
e && e.remove();
|
|
2604
|
+
let s = this.el.querySelector(".mk-avatar__image");
|
|
2605
|
+
s || (s = document.createElement("img"), s.className = "mk-avatar__image", s.alt = this.options.text || "", s.addEventListener("error", () => this.showFallback()), this.el.appendChild(s)), s.src = t;
|
|
2606
|
+
}
|
|
2607
|
+
setText(t) {
|
|
2608
|
+
this.options.text = t, this.options.src || this.showFallback();
|
|
2609
|
+
}
|
|
2610
|
+
destroy() {
|
|
2611
|
+
this.el.remove();
|
|
2612
|
+
}
|
|
2613
|
+
}
|
|
2614
|
+
function zs(n, t) {
|
|
2615
|
+
return new Ee(n, t);
|
|
2616
|
+
}
|
|
2617
|
+
const ke = {
|
|
2618
|
+
info: "ℹ",
|
|
2619
|
+
success: "✓",
|
|
2620
|
+
warning: "⚠",
|
|
2621
|
+
danger: "✕"
|
|
2622
|
+
};
|
|
2623
|
+
class we {
|
|
2624
|
+
constructor(t, e = {}) {
|
|
2625
|
+
c(this, "el");
|
|
2626
|
+
c(this, "options");
|
|
2627
|
+
const s = typeof t == "string" ? document.querySelector(t) : t;
|
|
2628
|
+
if (this.options = {
|
|
2629
|
+
type: "info",
|
|
2630
|
+
showIcon: !0,
|
|
2631
|
+
...e
|
|
2632
|
+
}, this.el = document.createElement("div"), this.el.className = this.buildClass(), this.el.setAttribute("role", "alert"), this.options.showIcon) {
|
|
2633
|
+
const o = document.createElement("span");
|
|
2634
|
+
o.className = "mk-alert__icon", o.textContent = ke[this.options.type], this.el.appendChild(o);
|
|
2635
|
+
}
|
|
2636
|
+
const i = document.createElement("div");
|
|
2637
|
+
if (i.className = "mk-alert__content", this.options.title) {
|
|
2638
|
+
const o = document.createElement("div");
|
|
2639
|
+
o.className = "mk-alert__title", o.textContent = this.options.title, i.appendChild(o);
|
|
2640
|
+
}
|
|
2641
|
+
if (this.options.description) {
|
|
2642
|
+
const o = document.createElement("div");
|
|
2643
|
+
o.className = "mk-alert__description", o.textContent = this.options.description, i.appendChild(o);
|
|
2644
|
+
}
|
|
2645
|
+
if (this.el.appendChild(i), this.options.closable) {
|
|
2646
|
+
const o = document.createElement("button");
|
|
2647
|
+
o.className = "mk-alert__close", o.setAttribute("aria-label", "Close"), o.innerHTML = "×", o.addEventListener("click", () => this.close()), this.el.appendChild(o);
|
|
2648
|
+
}
|
|
2649
|
+
s.appendChild(this.el);
|
|
2650
|
+
}
|
|
2651
|
+
buildClass() {
|
|
2652
|
+
const t = ["mk-alert", `mk-alert--${this.options.type}`];
|
|
2653
|
+
return this.options.closable && t.push("is-closable"), t.join(" ");
|
|
2654
|
+
}
|
|
2655
|
+
close() {
|
|
2656
|
+
this.el.classList.add("is-closing"), this.el.style.pointerEvents = "none", this.el.addEventListener(
|
|
2657
|
+
"transitionend",
|
|
2658
|
+
() => {
|
|
2659
|
+
var t, e;
|
|
2660
|
+
this.destroy(), (e = (t = this.options).onClose) == null || e.call(t);
|
|
2661
|
+
},
|
|
2662
|
+
{ once: !0 }
|
|
2663
|
+
);
|
|
2664
|
+
}
|
|
2665
|
+
destroy() {
|
|
2666
|
+
this.el.remove();
|
|
2667
|
+
}
|
|
2668
|
+
}
|
|
2669
|
+
function Fs(n, t) {
|
|
2670
|
+
return new we(n, t);
|
|
2671
|
+
}
|
|
2672
|
+
class xe {
|
|
2673
|
+
constructor(t, e = {}) {
|
|
2674
|
+
c(this, "el");
|
|
2675
|
+
c(this, "options");
|
|
2676
|
+
c(this, "barEl", null);
|
|
2677
|
+
c(this, "textEl", null);
|
|
2678
|
+
c(this, "circleSvg", null);
|
|
2679
|
+
c(this, "circleTrack", null);
|
|
2680
|
+
c(this, "circlePath", null);
|
|
2681
|
+
const s = typeof t == "string" ? document.querySelector(t) : t;
|
|
2682
|
+
this.options = {
|
|
2683
|
+
type: "line",
|
|
2684
|
+
percent: 0,
|
|
2685
|
+
showInfo: !0,
|
|
2686
|
+
...e
|
|
2687
|
+
}, this.el = document.createElement("div"), this.el.className = this.buildClass(), this.options.type === "line" ? this.renderLine() : this.renderCircleOrDashboard(), s.appendChild(this.el), requestAnimationFrame(() => {
|
|
2688
|
+
this.setPercent(this.options.percent);
|
|
2689
|
+
});
|
|
2690
|
+
}
|
|
2691
|
+
buildClass() {
|
|
2692
|
+
const t = ["mk-progress", `mk-progress--${this.options.type}`];
|
|
2693
|
+
return this.options.status && t.push(`is-${this.options.status}`), this.options.showInfo || t.push("is-hide-info"), t.join(" ");
|
|
2694
|
+
}
|
|
2695
|
+
renderLine() {
|
|
2696
|
+
const t = document.createElement("div");
|
|
2697
|
+
t.className = "mk-progress__track", this.options.strokeWidth && (t.style.height = `${this.options.strokeWidth}px`), this.barEl = document.createElement("div"), this.barEl.className = "mk-progress__bar", t.appendChild(this.barEl), this.el.appendChild(t), this.options.showInfo && (this.textEl = document.createElement("span"), this.textEl.className = "mk-progress__text", this.el.appendChild(this.textEl));
|
|
2698
|
+
}
|
|
2699
|
+
renderCircleOrDashboard() {
|
|
2700
|
+
const e = this.options.strokeWidth || 6, s = (120 - e) / 2, i = 2 * Math.PI * s, o = this.options.type === "dashboard", r = o ? i * 0.75 : i;
|
|
2701
|
+
this.circleSvg = document.createElementNS("http://www.w3.org/2000/svg", "svg"), this.circleSvg.setAttribute("width", "120"), this.circleSvg.setAttribute("height", "120"), this.circleSvg.setAttribute("viewBox", "0 0 120 120"), this.circleSvg.classList.add("mk-progress__svg"), this.circleTrack = document.createElementNS("http://www.w3.org/2000/svg", "circle"), this.circleTrack.setAttribute("cx", `${120 / 2}`), this.circleTrack.setAttribute("cy", `${120 / 2}`), this.circleTrack.setAttribute("r", `${s}`), this.circleTrack.setAttribute("fill", "none"), this.circleTrack.setAttribute("stroke-width", `${e}`), this.circleTrack.classList.add("mk-progress__track-circle"), this.circlePath = document.createElementNS("http://www.w3.org/2000/svg", "circle"), this.circlePath.setAttribute("cx", `${120 / 2}`), this.circlePath.setAttribute("cy", `${120 / 2}`), this.circlePath.setAttribute("r", `${s}`), this.circlePath.setAttribute("fill", "none"), this.circlePath.setAttribute("stroke-width", `${e}`), this.circlePath.setAttribute("stroke-linecap", "round"), this.circlePath.style.strokeDasharray = `${r} ${i}`, this.circlePath.style.strokeDashoffset = `${r}`, this.circlePath.style.transformOrigin = "50% 50%", o ? (this.circleTrack.style.transform = "rotate(135deg)", this.circleTrack.style.transformOrigin = "50% 50%", this.circlePath.style.transform = "rotate(135deg)") : (this.circleTrack.style.transform = "rotate(-90deg)", this.circleTrack.style.transformOrigin = "50% 50%", this.circlePath.style.transform = "rotate(-90deg)"), this.circlePath.classList.add("mk-progress__path-circle"), this.circleSvg.appendChild(this.circleTrack), this.circleSvg.appendChild(this.circlePath), this.el.appendChild(this.circleSvg), this.options.showInfo && (this.textEl = document.createElement("span"), this.textEl.className = "mk-progress__text", this.el.appendChild(this.textEl));
|
|
2702
|
+
}
|
|
2703
|
+
setPercent(t) {
|
|
2704
|
+
const e = Math.max(0, Math.min(100, t));
|
|
2705
|
+
if (this.options.percent = e, this.options.type === "line" && this.barEl)
|
|
2706
|
+
this.barEl.style.width = `${e}%`, this.options.color && (this.barEl.style.background = this.options.color);
|
|
2707
|
+
else if (this.circlePath && this.circleSvg) {
|
|
2708
|
+
const o = (120 - (this.options.strokeWidth || 6)) / 2, r = 2 * Math.PI * o, l = this.options.type === "dashboard" ? r * 0.75 : r, d = l - e / 100 * l;
|
|
2709
|
+
this.circlePath.style.strokeDashoffset = `${d}`, this.options.color && (this.circlePath.style.stroke = this.options.color);
|
|
2710
|
+
}
|
|
2711
|
+
this.textEl && (this.textEl.textContent = `${Math.round(e)}%`);
|
|
2712
|
+
}
|
|
2713
|
+
destroy() {
|
|
2714
|
+
this.el.remove();
|
|
2715
|
+
}
|
|
2716
|
+
}
|
|
2717
|
+
function Rs(n, t) {
|
|
2718
|
+
return new xe(n, t);
|
|
2719
|
+
}
|
|
2720
|
+
let Ce = 0;
|
|
2721
|
+
class Le {
|
|
2722
|
+
constructor(t, e) {
|
|
2723
|
+
c(this, "el");
|
|
2724
|
+
c(this, "options");
|
|
2725
|
+
c(this, "activeKeys");
|
|
2726
|
+
c(this, "itemEls", []);
|
|
2727
|
+
const s = typeof t == "string" ? document.querySelector(t) : t;
|
|
2728
|
+
this.options = {
|
|
2729
|
+
accordion: !1,
|
|
2730
|
+
activeKeys: [],
|
|
2731
|
+
...e
|
|
2732
|
+
}, this.activeKeys = new Set(this.options.activeKeys), this.el = document.createElement("div"), this.el.className = "mk-collapse", this.options.items.forEach((i, o) => {
|
|
2733
|
+
const r = `mk-collapse-content-${++Ce}`, a = document.createElement("div");
|
|
2734
|
+
a.className = "mk-collapse__item", i.disabled && a.classList.add("is-disabled");
|
|
2735
|
+
const l = document.createElement("div");
|
|
2736
|
+
l.className = "mk-collapse__header", l.setAttribute("role", "button"), l.setAttribute("tabindex", i.disabled ? "-1" : "0"), l.setAttribute("aria-expanded", "false"), l.setAttribute("aria-controls", r);
|
|
2737
|
+
const d = document.createElement("span");
|
|
2738
|
+
d.className = "mk-collapse__title", d.textContent = i.title;
|
|
2739
|
+
const h = document.createElement("span");
|
|
2740
|
+
h.className = "mk-collapse__arrow", h.innerHTML = '<svg width="12" height="12" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M4 2l4 4-4 4"/></svg>', l.appendChild(d), l.appendChild(h), a.appendChild(l);
|
|
2741
|
+
const p = document.createElement("div");
|
|
2742
|
+
p.className = "mk-collapse__content", p.id = r;
|
|
2743
|
+
const u = document.createElement("div");
|
|
2744
|
+
u.className = "mk-collapse__inner", typeof i.content == "string" ? u.innerHTML = i.content : u.appendChild(i.content), p.appendChild(u), a.appendChild(p), this.itemEls.push({ header: l, content: p, inner: u, arrow: h, contentId: r }), this.el.appendChild(a), i.disabled || (l.addEventListener("click", () => this.toggle(o)), l.addEventListener("keydown", (m) => {
|
|
2745
|
+
(m.key === "Enter" || m.key === " ") && (m.preventDefault(), this.toggle(o));
|
|
2746
|
+
}));
|
|
2747
|
+
}), s.appendChild(this.el), requestAnimationFrame(() => {
|
|
2748
|
+
this.itemEls.forEach((i, o) => {
|
|
2749
|
+
this.updateItemState(o);
|
|
2750
|
+
});
|
|
2751
|
+
});
|
|
2752
|
+
}
|
|
2753
|
+
toggle(t) {
|
|
2754
|
+
const e = this.activeKeys.has(t);
|
|
2755
|
+
if (this.options.accordion) {
|
|
2756
|
+
const s = Array.from(this.activeKeys);
|
|
2757
|
+
this.activeKeys.clear(), e || this.activeKeys.add(t), s.forEach((i) => this.updateItemState(i)), this.updateItemState(t);
|
|
2758
|
+
} else
|
|
2759
|
+
e ? this.activeKeys.delete(t) : this.activeKeys.add(t), this.updateItemState(t);
|
|
2760
|
+
}
|
|
2761
|
+
updateItemState(t) {
|
|
2762
|
+
const e = this.itemEls[t];
|
|
2763
|
+
if (!e) return;
|
|
2764
|
+
const s = this.activeKeys.has(t), i = e.header.parentElement;
|
|
2765
|
+
e.header.setAttribute("aria-expanded", String(s)), e.arrow.classList.toggle("is-expanded", s), i.classList.toggle("is-active", s), s ? e.content.style.maxHeight = `${e.inner.scrollHeight}px` : e.content.style.maxHeight = "0px";
|
|
2766
|
+
}
|
|
2767
|
+
setActiveKeys(t) {
|
|
2768
|
+
const e = new Set(this.activeKeys);
|
|
2769
|
+
this.activeKeys = new Set(t), e.forEach((s) => this.updateItemState(s)), t.forEach((s) => this.updateItemState(s));
|
|
2770
|
+
}
|
|
2771
|
+
destroy() {
|
|
2772
|
+
this.el.remove();
|
|
2773
|
+
}
|
|
2774
|
+
}
|
|
2775
|
+
function Os(n, t) {
|
|
2776
|
+
return new Le(n, t);
|
|
2777
|
+
}
|
|
2778
|
+
const _e = `<svg viewBox="0 0 120 120" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2779
|
+
<rect x="20" y="30" width="80" height="60" rx="8" stroke="currentColor" stroke-width="1.5" opacity="0.3"/>
|
|
2780
|
+
<circle cx="45" cy="55" r="8" fill="currentColor" opacity="0.2"/>
|
|
2781
|
+
<rect x="60" y="48" width="28" height="4" rx="2" fill="currentColor" opacity="0.2"/>
|
|
2782
|
+
<rect x="60" y="58" width="20" height="4" rx="2" fill="currentColor" opacity="0.15"/>
|
|
2783
|
+
<line x1="35" y1="82" x2="85" y2="82" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" opacity="0.15"/>
|
|
2784
|
+
<line x1="45" y1="90" x2="75" y2="90" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" opacity="0.1"/>
|
|
2785
|
+
</svg>`;
|
|
2786
|
+
class Te {
|
|
2787
|
+
constructor(t, e = {}) {
|
|
2788
|
+
c(this, "el");
|
|
2789
|
+
c(this, "options");
|
|
2790
|
+
const s = typeof t == "string" ? document.querySelector(t) : t;
|
|
2791
|
+
this.options = {
|
|
2792
|
+
image: "default",
|
|
2793
|
+
...e
|
|
2794
|
+
}, this.el = document.createElement("div"), this.el.className = "mk-empty";
|
|
2795
|
+
const i = document.createElement("div");
|
|
2796
|
+
if (i.className = "mk-empty__image", this.options.imageStyle && Object.assign(i.style, this.options.imageStyle), this.options.image === "default")
|
|
2797
|
+
i.innerHTML = _e;
|
|
2798
|
+
else if (this.options.image) {
|
|
2799
|
+
const o = document.createElement("img");
|
|
2800
|
+
o.src = this.options.image, o.alt = "", i.appendChild(o);
|
|
2801
|
+
}
|
|
2802
|
+
if (this.el.appendChild(i), this.options.description) {
|
|
2803
|
+
const o = document.createElement("p");
|
|
2804
|
+
o.className = "mk-empty__description", o.textContent = this.options.description, this.el.appendChild(o);
|
|
2805
|
+
}
|
|
2806
|
+
s.appendChild(this.el);
|
|
2807
|
+
}
|
|
2808
|
+
setDescription(t) {
|
|
2809
|
+
this.options.description = t;
|
|
2810
|
+
let e = this.el.querySelector(".mk-empty__description");
|
|
2811
|
+
e || (e = document.createElement("p"), e.className = "mk-empty__description", this.el.appendChild(e)), e.textContent = t;
|
|
2812
|
+
}
|
|
2813
|
+
destroy() {
|
|
2814
|
+
this.el.remove();
|
|
2815
|
+
}
|
|
2816
|
+
}
|
|
2817
|
+
function Hs(n, t) {
|
|
2818
|
+
return new Te(n, t);
|
|
2819
|
+
}
|
|
2820
|
+
class Se {
|
|
2821
|
+
constructor(t, e = {}) {
|
|
2822
|
+
c(this, "el");
|
|
2823
|
+
c(this, "options");
|
|
2824
|
+
c(this, "popoverEl", null);
|
|
2825
|
+
c(this, "arrowEl", null);
|
|
2826
|
+
c(this, "contentEl", null);
|
|
2827
|
+
c(this, "showTimer", null);
|
|
2828
|
+
c(this, "hideTimer", null);
|
|
2829
|
+
c(this, "isVisible", !1);
|
|
2830
|
+
c(this, "cleanupFns", []);
|
|
2831
|
+
c(this, "focusTrap", null);
|
|
2832
|
+
c(this, "escapeCleanup", null);
|
|
2833
|
+
if (this.options = {
|
|
2834
|
+
placement: "top",
|
|
2835
|
+
trigger: "hover",
|
|
2836
|
+
offset: 8,
|
|
2837
|
+
...e
|
|
2838
|
+
}, this.el = document.createElement("div"), this.el.style.display = "contents", this.buildPopover(), this.options.trigger === "click") {
|
|
2839
|
+
const s = (o) => {
|
|
2840
|
+
o.stopPropagation(), this.toggle();
|
|
2841
|
+
};
|
|
2842
|
+
t.addEventListener("click", s), this.cleanupFns.push(() => t.removeEventListener("click", s));
|
|
2843
|
+
const i = (o) => {
|
|
2844
|
+
this.isVisible && this.popoverEl && !this.popoverEl.contains(o.target) && o.target !== t && this.hide();
|
|
2845
|
+
};
|
|
2846
|
+
document.addEventListener("click", i), this.cleanupFns.push(() => document.removeEventListener("click", i));
|
|
2847
|
+
} else {
|
|
2848
|
+
const s = () => {
|
|
2849
|
+
this.hideTimer && (clearTimeout(this.hideTimer), this.hideTimer = null), this.showTimer = setTimeout(() => this.show(), 150);
|
|
2850
|
+
}, i = () => {
|
|
2851
|
+
this.showTimer && (clearTimeout(this.showTimer), this.showTimer = null), this.hideTimer = setTimeout(() => this.hide(), 150);
|
|
2852
|
+
};
|
|
2853
|
+
if (t.addEventListener("mouseenter", s), t.addEventListener("mouseleave", i), t.addEventListener("focus", s), t.addEventListener("blur", i), this.cleanupFns.push(() => t.removeEventListener("mouseenter", s)), this.cleanupFns.push(() => t.removeEventListener("mouseleave", i)), this.cleanupFns.push(() => t.removeEventListener("focus", s)), this.cleanupFns.push(() => t.removeEventListener("blur", i)), this.popoverEl) {
|
|
2854
|
+
const o = () => {
|
|
2855
|
+
this.hideTimer && (clearTimeout(this.hideTimer), this.hideTimer = null);
|
|
2856
|
+
}, r = () => {
|
|
2857
|
+
this.hideTimer = setTimeout(() => this.hide(), 150);
|
|
2858
|
+
};
|
|
2859
|
+
this.popoverEl.addEventListener("mouseenter", o), this.popoverEl.addEventListener("mouseleave", r), this.cleanupFns.push(() => this.popoverEl.removeEventListener("mouseenter", o)), this.cleanupFns.push(() => this.popoverEl.removeEventListener("mouseleave", r));
|
|
2860
|
+
}
|
|
2861
|
+
}
|
|
2862
|
+
t.appendChild(this.el);
|
|
2863
|
+
}
|
|
2864
|
+
buildPopover() {
|
|
2865
|
+
if (this.popoverEl = document.createElement("div"), this.popoverEl.className = "mk-popover", this.popoverEl.style.position = "absolute", this.popoverEl.style.zIndex = "var(--mk-z-popover)", this.popoverEl.setAttribute("role", this.options.trigger === "click" ? "dialog" : "tooltip"), this.options.trigger === "click" && this.popoverEl.setAttribute("tabindex", "-1"), this.options.width && (this.popoverEl.style.width = `${this.options.width}px`), this.arrowEl = document.createElement("div"), this.arrowEl.className = "mk-popover__arrow", this.popoverEl.appendChild(this.arrowEl), this.options.title) {
|
|
2866
|
+
const t = document.createElement("div");
|
|
2867
|
+
t.className = "mk-popover__title", t.textContent = this.options.title, this.popoverEl.appendChild(t);
|
|
2868
|
+
}
|
|
2869
|
+
this.contentEl = document.createElement("div"), this.contentEl.className = "mk-popover__content", typeof this.options.content == "string" ? this.contentEl.textContent = this.options.content : this.options.content && this.contentEl.appendChild(this.options.content), this.popoverEl.appendChild(this.contentEl), document.body.appendChild(this.popoverEl);
|
|
2870
|
+
}
|
|
2871
|
+
position() {
|
|
2872
|
+
if (!this.popoverEl || !this.arrowEl) return;
|
|
2873
|
+
const e = this.el.parentElement.getBoundingClientRect(), s = this.popoverEl.getBoundingClientRect(), i = window.scrollX, o = window.scrollY, r = this.options.offset;
|
|
2874
|
+
let a = 0, l = 0, d = "";
|
|
2875
|
+
switch (this.options.placement) {
|
|
2876
|
+
case "top":
|
|
2877
|
+
a = e.top + o - s.height - r, l = e.left + i + e.width / 2 - s.width / 2, d = "is-bottom";
|
|
2878
|
+
break;
|
|
2879
|
+
case "bottom":
|
|
2880
|
+
a = e.bottom + o + r, l = e.left + i + e.width / 2 - s.width / 2, d = "is-top";
|
|
2881
|
+
break;
|
|
2882
|
+
case "left":
|
|
2883
|
+
a = e.top + o + e.height / 2 - s.height / 2, l = e.left + i - s.width - r, d = "is-right";
|
|
2884
|
+
break;
|
|
2885
|
+
case "right":
|
|
2886
|
+
a = e.top + o + e.height / 2 - s.height / 2, l = e.right + i + r, d = "is-left";
|
|
2887
|
+
break;
|
|
2888
|
+
default:
|
|
2889
|
+
a = e.top + o - s.height - r, l = e.left + i + e.width / 2 - s.width / 2, d = "is-bottom";
|
|
2890
|
+
}
|
|
2891
|
+
const h = 8;
|
|
2892
|
+
l < h && (l = h), l + s.width > window.innerWidth - h && (l = window.innerWidth - s.width - h), a < h && (a = h), this.popoverEl.style.top = `${a}px`, this.popoverEl.style.left = `${l}px`, this.arrowEl.className = `mk-popover__arrow ${d}`;
|
|
2893
|
+
}
|
|
2894
|
+
show() {
|
|
2895
|
+
this.popoverEl && (this.isVisible = !0, this.popoverEl.classList.remove("is-visible"), this.popoverEl.style.visibility = "hidden", this.popoverEl.style.display = "block", requestAnimationFrame(() => {
|
|
2896
|
+
this.isVisible && (this.position(), this.popoverEl.style.visibility = "visible", this.popoverEl.classList.add("is-visible"), this.options.trigger === "click" && (this.focusTrap || (this.focusTrap = new M(this.popoverEl)), this.focusTrap.activate(this.popoverEl), this.escapeCleanup = k(this.popoverEl, [
|
|
2897
|
+
{ key: f.Escape, handler: () => this.hide() }
|
|
2898
|
+
])));
|
|
2899
|
+
}));
|
|
2900
|
+
}
|
|
2901
|
+
hide() {
|
|
2902
|
+
this.popoverEl && (this.isVisible = !1, this.popoverEl.classList.remove("is-visible"), this.escapeCleanup && (this.escapeCleanup(), this.escapeCleanup = null), this.focusTrap && this.focusTrap.deactivate(), this.hideTimer = setTimeout(() => {
|
|
2903
|
+
this.isVisible || (this.popoverEl.style.display = "none");
|
|
2904
|
+
}, 200));
|
|
2905
|
+
}
|
|
2906
|
+
toggle() {
|
|
2907
|
+
this.isVisible ? this.hide() : this.show();
|
|
2908
|
+
}
|
|
2909
|
+
setContent(t) {
|
|
2910
|
+
this.contentEl && (this.contentEl.innerHTML = "", typeof t == "string" ? this.contentEl.textContent = t : this.contentEl.appendChild(t));
|
|
2911
|
+
}
|
|
2912
|
+
destroy() {
|
|
2913
|
+
var t;
|
|
2914
|
+
this.cleanupFns.forEach((e) => e()), this.cleanupFns = [], this.showTimer && clearTimeout(this.showTimer), this.hideTimer && clearTimeout(this.hideTimer), this.escapeCleanup && (this.escapeCleanup(), this.escapeCleanup = null), this.focusTrap && this.focusTrap.deactivate(), (t = this.popoverEl) == null || t.remove(), this.el.remove();
|
|
2915
|
+
}
|
|
2916
|
+
}
|
|
2917
|
+
function Ys(n, t) {
|
|
2918
|
+
return new Se(n, t);
|
|
2919
|
+
}
|
|
2920
|
+
class Ae {
|
|
2921
|
+
constructor(t, e) {
|
|
2922
|
+
c(this, "el");
|
|
2923
|
+
c(this, "options");
|
|
2924
|
+
c(this, "openeds");
|
|
2925
|
+
c(this, "activeIndex");
|
|
2926
|
+
const s = typeof t == "string" ? document.querySelector(t) : t;
|
|
2927
|
+
this.options = { mode: "vertical", collapse: !1, ...e }, this.openeds = new Set(e.defaultOpeneds || []), this.activeIndex = e.defaultActive || "", this.el = document.createElement("ul"), this.el.className = `mk-menu mk-menu--${this.options.mode}`, this.options.collapse && this.el.classList.add("is-collapse"), this.el.setAttribute("role", "menu"), this.render(), s.appendChild(this.el), this.setupKeyboard();
|
|
2928
|
+
}
|
|
2929
|
+
render() {
|
|
2930
|
+
this.el.innerHTML = "", this.options.items.forEach((t) => {
|
|
2931
|
+
this.el.appendChild(this.renderItem(t, 0));
|
|
2932
|
+
});
|
|
2933
|
+
}
|
|
2934
|
+
renderItem(t, e) {
|
|
2935
|
+
const s = t.children && t.children.length > 0, i = this.openeds.has(t.index), o = this.activeIndex === t.index, r = this.options.collapse && this.options.mode === "vertical", a = document.createElement("li");
|
|
2936
|
+
a.className = "mk-menu-item", t.disabled && a.classList.add("is-disabled"), o && a.classList.add("is-active"), s && a.classList.add("has-children"), i && a.classList.add("is-open"), a.style.paddingLeft = r ? "0" : `${16 + e * 16}px`;
|
|
2937
|
+
const l = document.createElement("div");
|
|
2938
|
+
if (l.className = "mk-menu-item__title", l.style.cursor = t.disabled ? "not-allowed" : "pointer", l.setAttribute("role", "menuitem"), l.setAttribute("tabindex", t.disabled ? "-1" : "0"), t.disabled && l.setAttribute("aria-disabled", "true"), s && (l.setAttribute("aria-haspopup", "true"), l.setAttribute("aria-expanded", String(i))), t.icon) {
|
|
2939
|
+
const h = document.createElement("span");
|
|
2940
|
+
h.className = "mk-menu-item__icon", h.textContent = t.icon, l.appendChild(h);
|
|
2941
|
+
}
|
|
2942
|
+
const d = document.createElement("span");
|
|
2943
|
+
if (d.className = "mk-menu-item__text", d.textContent = t.label, l.appendChild(d), s && !r) {
|
|
2944
|
+
const h = document.createElement("span");
|
|
2945
|
+
h.className = "mk-menu-item__arrow", h.textContent = "›", l.appendChild(h);
|
|
2946
|
+
}
|
|
2947
|
+
if (l.addEventListener("click", () => {
|
|
2948
|
+
var h, p, u, m, y, g;
|
|
2949
|
+
t.disabled || (s ? (i ? (this.openeds.delete(t.index), (p = (h = this.options).onClose) == null || p.call(h, t.index)) : (this.openeds.add(t.index), (m = (u = this.options).onOpen) == null || m.call(u, t.index)), this.render()) : (this.activeIndex = t.index, (g = (y = this.options).onSelect) == null || g.call(y, t.index), this.render()));
|
|
2950
|
+
}), a.appendChild(l), s && !r) {
|
|
2951
|
+
const h = document.createElement("ul");
|
|
2952
|
+
h.className = "mk-menu-submenu", i && h.classList.add("is-open"), h.setAttribute("role", "menu"), t.children.forEach((p) => {
|
|
2953
|
+
h.appendChild(this.renderItem(p, e + 1));
|
|
2954
|
+
}), a.appendChild(h);
|
|
2955
|
+
}
|
|
2956
|
+
return a;
|
|
2957
|
+
}
|
|
2958
|
+
setupKeyboard() {
|
|
2959
|
+
this.el.addEventListener("keydown", (t) => {
|
|
2960
|
+
var a, l;
|
|
2961
|
+
const e = document.activeElement;
|
|
2962
|
+
if (!(e != null && e.classList.contains("mk-menu-item__title"))) return;
|
|
2963
|
+
const i = e.parentElement.parentElement, o = Array.from(i.children).filter((d) => d.classList.contains("mk-menu-item")).map((d) => d.querySelector(".mk-menu-item__title")).filter(Boolean), r = o.indexOf(e);
|
|
2964
|
+
switch (t.key) {
|
|
2965
|
+
case f.ArrowDown:
|
|
2966
|
+
t.preventDefault(), (a = o[r + 1]) == null || a.focus();
|
|
2967
|
+
break;
|
|
2968
|
+
case f.ArrowUp:
|
|
2969
|
+
t.preventDefault(), (l = o[r - 1]) == null || l.focus();
|
|
2970
|
+
break;
|
|
2971
|
+
case f.Enter:
|
|
2972
|
+
case f.Space:
|
|
2973
|
+
t.preventDefault(), e.click();
|
|
2974
|
+
break;
|
|
2975
|
+
case f.Escape:
|
|
2976
|
+
t.preventDefault();
|
|
2977
|
+
const d = i.closest(".mk-menu-item");
|
|
2978
|
+
if (d && i !== this.el) {
|
|
2979
|
+
const h = d.querySelector(".mk-menu-item__title");
|
|
2980
|
+
h && h.getAttribute("aria-expanded") === "true" && (h.click(), h.focus());
|
|
2981
|
+
}
|
|
2982
|
+
break;
|
|
2983
|
+
}
|
|
2984
|
+
});
|
|
2985
|
+
}
|
|
2986
|
+
destroy() {
|
|
2987
|
+
this.el.remove();
|
|
2988
|
+
}
|
|
2989
|
+
}
|
|
2990
|
+
function Xs(n, t) {
|
|
2991
|
+
return new Ae(n, t);
|
|
2992
|
+
}
|
|
2993
|
+
class $e {
|
|
2994
|
+
constructor(t, e) {
|
|
2995
|
+
c(this, "el");
|
|
2996
|
+
const s = typeof t == "string" ? document.querySelector(t) : t;
|
|
2997
|
+
this.el = document.createElement("nav"), this.el.className = "mk-breadcrumb", this.el.setAttribute("aria-label", "breadcrumb");
|
|
2998
|
+
const i = e.separator ?? "/";
|
|
2999
|
+
e.items.forEach((o, r) => {
|
|
3000
|
+
const a = r === e.items.length - 1;
|
|
3001
|
+
if (r > 0) {
|
|
3002
|
+
const l = document.createElement("span");
|
|
3003
|
+
l.className = "mk-breadcrumb__separator", typeof i == "string" ? l.textContent = i : i instanceof HTMLElement && l.appendChild(i), this.el.appendChild(l);
|
|
3004
|
+
}
|
|
3005
|
+
if (a) {
|
|
3006
|
+
const l = document.createElement("span");
|
|
3007
|
+
l.className = "mk-breadcrumb__item is-current", l.setAttribute("aria-current", "page"), l.textContent = o.label, this.el.appendChild(l);
|
|
3008
|
+
} else {
|
|
3009
|
+
const l = document.createElement(o.href ? "a" : "span");
|
|
3010
|
+
l.className = "mk-breadcrumb__item is-link", o.href && (l.href = o.href), l.textContent = o.label, l.style.cursor = o.onClick || o.href ? "pointer" : "default", o.onClick && l.addEventListener("click", o.onClick), this.el.appendChild(l);
|
|
3011
|
+
}
|
|
3012
|
+
}), s.appendChild(this.el);
|
|
3013
|
+
}
|
|
3014
|
+
destroy() {
|
|
3015
|
+
this.el.remove();
|
|
3016
|
+
}
|
|
3017
|
+
}
|
|
3018
|
+
function Us(n, t) {
|
|
3019
|
+
return new $e(n, t);
|
|
3020
|
+
}
|
|
3021
|
+
class Ie {
|
|
3022
|
+
constructor(t, e) {
|
|
3023
|
+
c(this, "el");
|
|
3024
|
+
c(this, "options");
|
|
3025
|
+
const s = typeof t == "string" ? document.querySelector(t) : t;
|
|
3026
|
+
this.options = { direction: "horizontal", current: 0, size: "default", ...e }, this.el = document.createElement("div"), this.el.className = `mk-steps mk-steps--${this.options.direction}`, this.options.size === "small" && this.el.classList.add("mk-steps--small"), this.render(), s.appendChild(this.el);
|
|
3027
|
+
}
|
|
3028
|
+
render() {
|
|
3029
|
+
this.el.innerHTML = "";
|
|
3030
|
+
const { items: t, current: e = 0, direction: s } = this.options;
|
|
3031
|
+
t.forEach((i, o) => {
|
|
3032
|
+
const r = document.createElement("div");
|
|
3033
|
+
r.className = "mk-step";
|
|
3034
|
+
const a = i.status ?? (o < e ? "finish" : o === e ? "process" : "wait");
|
|
3035
|
+
r.classList.add(`is-${a}`), o === t.length - 1 && r.classList.add("is-last");
|
|
3036
|
+
const l = document.createElement("div");
|
|
3037
|
+
l.className = "mk-step__head";
|
|
3038
|
+
const d = document.createElement("div");
|
|
3039
|
+
d.className = "mk-step__line", s === "vertical" && (d.style.width = "1px", d.style.height = "100%", d.style.left = "15px", d.style.top = "30px"), l.appendChild(d);
|
|
3040
|
+
const h = document.createElement("div");
|
|
3041
|
+
h.className = "mk-step__icon", a === "finish" ? h.textContent = i.icon || "✓" : a === "error" ? h.textContent = i.icon || "✕" : h.textContent = i.icon || String(o + 1), l.appendChild(h);
|
|
3042
|
+
const p = document.createElement("div");
|
|
3043
|
+
p.className = "mk-step__main";
|
|
3044
|
+
const u = document.createElement("div");
|
|
3045
|
+
if (u.className = "mk-step__title", u.textContent = i.title, p.appendChild(u), i.description) {
|
|
3046
|
+
const m = document.createElement("div");
|
|
3047
|
+
m.className = "mk-step__description", m.textContent = i.description, p.appendChild(m);
|
|
3048
|
+
}
|
|
3049
|
+
r.appendChild(l), r.appendChild(p), this.el.appendChild(r);
|
|
3050
|
+
});
|
|
3051
|
+
}
|
|
3052
|
+
setCurrent(t) {
|
|
3053
|
+
this.options.current = t, this.render();
|
|
3054
|
+
}
|
|
3055
|
+
destroy() {
|
|
3056
|
+
this.el.remove();
|
|
3057
|
+
}
|
|
3058
|
+
}
|
|
3059
|
+
function Bs(n, t) {
|
|
3060
|
+
return new Ie(n, t);
|
|
3061
|
+
}
|
|
3062
|
+
export {
|
|
3063
|
+
F as Animator,
|
|
3064
|
+
xt as CountUp,
|
|
3065
|
+
Bt as CoverFlow,
|
|
3066
|
+
Oe as Draggable,
|
|
3067
|
+
Vt as FlipCard,
|
|
3068
|
+
M as FocusTrap,
|
|
3069
|
+
f as Keys,
|
|
3070
|
+
we as MkAlert,
|
|
3071
|
+
Ee as MkAvatar,
|
|
3072
|
+
$e as MkBreadcrumb,
|
|
3073
|
+
ee as MkButton,
|
|
3074
|
+
ie as MkCard,
|
|
3075
|
+
W as MkCheckbox,
|
|
3076
|
+
$s as MkCheckboxGroup,
|
|
3077
|
+
Le as MkCollapse,
|
|
3078
|
+
oe as MkDialog,
|
|
3079
|
+
te as MkDivider,
|
|
3080
|
+
re as MkDrawer,
|
|
3081
|
+
Te as MkEmpty,
|
|
3082
|
+
se as MkInput,
|
|
3083
|
+
Ae as MkMenu,
|
|
3084
|
+
Se as MkPopover,
|
|
3085
|
+
xe as MkProgress,
|
|
3086
|
+
ue as MkRadio,
|
|
3087
|
+
Is as MkRadioGroup,
|
|
3088
|
+
Zt as MkRow,
|
|
3089
|
+
pe as MkSelect,
|
|
3090
|
+
Ms as MkSlider,
|
|
3091
|
+
Qt as MkSpace,
|
|
3092
|
+
Ie as MkSteps,
|
|
3093
|
+
de as MkSwitch,
|
|
3094
|
+
Ns as MkTable,
|
|
3095
|
+
be as MkTabs,
|
|
3096
|
+
me as MkTag,
|
|
3097
|
+
bt as ScrollTrigger,
|
|
3098
|
+
$t as TextSplit,
|
|
3099
|
+
Jt as ThemeManager,
|
|
3100
|
+
Ne as Timeline,
|
|
3101
|
+
kt as Typewriter,
|
|
3102
|
+
Nt as WaveText,
|
|
3103
|
+
He as addRipple,
|
|
3104
|
+
Je as blurReveal,
|
|
3105
|
+
Ze as blurRevealChildren,
|
|
3106
|
+
ht as bounceIn,
|
|
3107
|
+
pt as bounceOut,
|
|
3108
|
+
Ht as collapse,
|
|
3109
|
+
ze as countUp,
|
|
3110
|
+
Fs as createAlert,
|
|
3111
|
+
zs as createAvatar,
|
|
3112
|
+
Us as createBreadcrumb,
|
|
3113
|
+
vs as createButton,
|
|
3114
|
+
Es as createCard,
|
|
3115
|
+
As as createCheckbox,
|
|
3116
|
+
Os as createCollapse,
|
|
3117
|
+
ds as createCoverFlow,
|
|
3118
|
+
ks as createDialog,
|
|
3119
|
+
gs as createDivider,
|
|
3120
|
+
ws as createDrawer,
|
|
3121
|
+
Hs as createEmpty,
|
|
3122
|
+
hs as createFlipCard,
|
|
3123
|
+
bs as createInput,
|
|
3124
|
+
Xs as createMenu,
|
|
3125
|
+
Ys as createPopover,
|
|
3126
|
+
Rs as createProgress,
|
|
3127
|
+
fs as createRow,
|
|
3128
|
+
Ss as createSelect,
|
|
3129
|
+
ys as createSpace,
|
|
3130
|
+
Bs as createSteps,
|
|
3131
|
+
_s as createSwitch,
|
|
3132
|
+
Ds as createTabs,
|
|
3133
|
+
Ps as createTag,
|
|
3134
|
+
qs as createTooltip,
|
|
3135
|
+
ps as cursorTrail,
|
|
3136
|
+
Re as elasticMove,
|
|
3137
|
+
Fe as elasticScale,
|
|
3138
|
+
Ot as expand,
|
|
3139
|
+
et as fadeIn,
|
|
3140
|
+
st as fadeOut,
|
|
3141
|
+
ut as flipInX,
|
|
3142
|
+
mt as flipInY,
|
|
3143
|
+
is as fullscreenLoading,
|
|
3144
|
+
It as glitch,
|
|
3145
|
+
Ve as glitchLoop,
|
|
3146
|
+
Ue as hoverGlow,
|
|
3147
|
+
Xe as hoverLift,
|
|
3148
|
+
Rt as lazyImage,
|
|
3149
|
+
Qe as lazyImages,
|
|
3150
|
+
es as listStagger,
|
|
3151
|
+
ls as magnetic,
|
|
3152
|
+
cs as magneticText,
|
|
3153
|
+
N as message,
|
|
3154
|
+
Cs as messageError,
|
|
3155
|
+
xs as messageSuccess,
|
|
3156
|
+
Ls as messageWarning,
|
|
3157
|
+
as as notify,
|
|
3158
|
+
k as onKey,
|
|
3159
|
+
qt as parallax,
|
|
3160
|
+
je as parallaxGroup,
|
|
3161
|
+
Be as particleAt,
|
|
3162
|
+
Tt as particleBurst,
|
|
3163
|
+
Pe as presets,
|
|
3164
|
+
yt as pulse,
|
|
3165
|
+
Ye as rippleEffect,
|
|
3166
|
+
gt as rotateIn,
|
|
3167
|
+
qe as scrollAnimate,
|
|
3168
|
+
ft as shake,
|
|
3169
|
+
zt as shimmer,
|
|
3170
|
+
he as showComponentLoading,
|
|
3171
|
+
Ts as showFullscreenLoading,
|
|
3172
|
+
ss as showLoading,
|
|
3173
|
+
Ge as skeleton,
|
|
3174
|
+
nt as slideInDown,
|
|
3175
|
+
ot as slideInLeft,
|
|
3176
|
+
rt as slideInRight,
|
|
3177
|
+
it as slideInUp,
|
|
3178
|
+
lt as slideOutDown,
|
|
3179
|
+
at as slideOutUp,
|
|
3180
|
+
Ke as splitText,
|
|
3181
|
+
$ as spring,
|
|
3182
|
+
us as staggerEnter,
|
|
3183
|
+
ms as theme,
|
|
3184
|
+
I as toast,
|
|
3185
|
+
os as toastError,
|
|
3186
|
+
ns as toastSuccess,
|
|
3187
|
+
rs as toastWarning,
|
|
3188
|
+
ts as toggleCollapse,
|
|
3189
|
+
De as typewrite,
|
|
3190
|
+
We as waveText,
|
|
3191
|
+
_ as withMotion,
|
|
3192
|
+
ct as zoomIn,
|
|
3193
|
+
dt as zoomOut
|
|
3194
|
+
};
|