@shlinkio/shlink-frontend-kit 0.9.7 → 0.9.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +40 -4
- package/dist/index.js +167 -188
- package/dist/ordering-B_hekQuu.js +96 -0
- package/dist/tailwind.d.ts +966 -3
- package/dist/tailwind.js +784 -462
- package/dist/tailwind.preset.css +2 -2
- package/package.json +8 -7
- package/dist/use-toggle-C1uZwbSD.js +0 -32
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { useMemo as b, useEffect as C, useRef as E, useCallback as d, useState as g } from "react";
|
|
2
|
+
function k(e, { elementsSelector: s, focusFirstItem: n = !1, vertical: o = !0, horizontal: t = !0 }) {
|
|
3
|
+
const r = b(() => {
|
|
4
|
+
const c = [];
|
|
5
|
+
return o && c.push("ArrowDown"), t && c.push("ArrowRight"), c;
|
|
6
|
+
}, [t, o]), u = b(() => {
|
|
7
|
+
const c = [];
|
|
8
|
+
return o && c.push("ArrowUp"), t && c.push("ArrowLeft"), c;
|
|
9
|
+
}, [t, o]), l = b(() => [...r, ...u], [r, u]);
|
|
10
|
+
C(() => {
|
|
11
|
+
const c = e.current;
|
|
12
|
+
if (!c)
|
|
13
|
+
return () => {
|
|
14
|
+
};
|
|
15
|
+
const f = new AbortController(), T = () => [...c.querySelectorAll(s)], w = T(), p = Math.max(w.findIndex((i) => i.dataset.selected === "true"), 0);
|
|
16
|
+
return w.forEach((i, a) => {
|
|
17
|
+
i.tabIndex = a === p ? 0 : -1, n && a === p && i.focus();
|
|
18
|
+
}), c.addEventListener("keydown", (i) => {
|
|
19
|
+
if (!l.includes(i.key))
|
|
20
|
+
return;
|
|
21
|
+
i.preventDefault();
|
|
22
|
+
const a = T(), h = a.findIndex((m) => m.tabIndex === 0), y = r.includes(i.key) ? a[h + 1] ?? a[0] : a[h - 1] ?? a[a.length - 1];
|
|
23
|
+
a.forEach((m) => {
|
|
24
|
+
m.tabIndex = -1;
|
|
25
|
+
}), y.tabIndex = 0, y.focus();
|
|
26
|
+
}, { signal: f.signal }), () => f.abort();
|
|
27
|
+
}, [l, e, s, n, r]);
|
|
28
|
+
}
|
|
29
|
+
function F(e, s = globalThis.setTimeout, n = globalThis.clearTimeout) {
|
|
30
|
+
const o = E(null), t = d(() => {
|
|
31
|
+
o.current && n(o.current);
|
|
32
|
+
}, [n]), r = d((u, l) => {
|
|
33
|
+
t(), o.current = s(() => {
|
|
34
|
+
u(), o.current = null;
|
|
35
|
+
}, l ?? e);
|
|
36
|
+
}, [t, e, s]);
|
|
37
|
+
return C(() => t, [t]), b(
|
|
38
|
+
() => ({ setTimeout: r, clearCurrentTimeout: t }),
|
|
39
|
+
[t, r]
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
const S = 2e3, I = (e = {}, s, n = globalThis.setTimeout, o = globalThis.clearTimeout) => {
|
|
43
|
+
const { initialValue: t = !1, delay: r = S } = typeof e == "boolean" ? {
|
|
44
|
+
initialValue: e,
|
|
45
|
+
delay: s
|
|
46
|
+
} : e, { setTimeout: u } = F(r, n, o), [l, c] = g(t), f = E(t), T = d(() => {
|
|
47
|
+
c(!f.current), u(() => c(f.current));
|
|
48
|
+
}, [u]);
|
|
49
|
+
return [l, T];
|
|
50
|
+
};
|
|
51
|
+
function L(e = !1, s = !1) {
|
|
52
|
+
const [n, o] = g(e), t = d(() => o((l) => !l), []), r = d(() => o(!0), []), u = d(() => o(!1), []);
|
|
53
|
+
return s ? { flag: n, toggle: t, setToTrue: r, setToFalse: u } : [n, t, r, u];
|
|
54
|
+
}
|
|
55
|
+
function A(e, s, n) {
|
|
56
|
+
return typeof e == "object" ? A(e.currentField, e.newField, e.currentOrderDir) : e !== s ? "ASC" : n ? {
|
|
57
|
+
ASC: "DESC",
|
|
58
|
+
DESC: void 0
|
|
59
|
+
}[n] : "ASC";
|
|
60
|
+
}
|
|
61
|
+
function x(e, s, n) {
|
|
62
|
+
if (typeof e == "object")
|
|
63
|
+
return x(e.currentField, e.newField, e.currentOrderDir);
|
|
64
|
+
const o = A(e, s, n);
|
|
65
|
+
return {
|
|
66
|
+
field: o ? s : void 0,
|
|
67
|
+
dir: o
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const v = (e, { field: s, dir: n }) => !s || !n ? e : e.sort((o, t) => {
|
|
71
|
+
const r = n === "ASC" ? 1 : -1, u = n === "ASC" ? -1 : 1;
|
|
72
|
+
return o[s] > t[s] ? r : u;
|
|
73
|
+
}), M = (e) => e.dir ? `${e.field}-${e.dir}` : void 0, j = (e) => {
|
|
74
|
+
const [s, n] = e.split("-");
|
|
75
|
+
return { field: s, dir: n };
|
|
76
|
+
}, R = (e) => {
|
|
77
|
+
const [s, n] = g(e), o = d(
|
|
78
|
+
(t, r) => n(
|
|
79
|
+
t && typeof t == "object" ? t : { field: t, dir: r }
|
|
80
|
+
),
|
|
81
|
+
[]
|
|
82
|
+
);
|
|
83
|
+
return [s, o];
|
|
84
|
+
};
|
|
85
|
+
export {
|
|
86
|
+
k as a,
|
|
87
|
+
F as b,
|
|
88
|
+
I as c,
|
|
89
|
+
A as d,
|
|
90
|
+
x as e,
|
|
91
|
+
j as f,
|
|
92
|
+
R as g,
|
|
93
|
+
M as o,
|
|
94
|
+
v as s,
|
|
95
|
+
L as u
|
|
96
|
+
};
|