@shlinkio/shlink-frontend-kit 0.5.1 → 0.5.2
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 +18 -4
- package/dist/index.js +110 -95
- package/dist/index.umd.cjs +1 -1
- package/package.json +26 -23
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
|
|
3
1
|
import { CardProps } from 'reactstrap';
|
|
4
2
|
import { ChangeEvent } from 'react';
|
|
5
3
|
import { DropdownToggleProps } from 'reactstrap/types/lib/DropdownToggle';
|
|
@@ -120,8 +118,15 @@ export declare type OrderingDropdownProps<T extends string = string> = {
|
|
|
120
118
|
|
|
121
119
|
export declare const orderToString: <T>(order: Order<T>) => string | undefined;
|
|
122
120
|
|
|
121
|
+
/** @deprecated Use parseQueryString instead */
|
|
123
122
|
export declare const parseQuery: <T>(search: string) => T;
|
|
124
123
|
|
|
124
|
+
/**
|
|
125
|
+
* Parses provided query string into an object.
|
|
126
|
+
* Parameters ending with "[]" will be considered arrays and returned as a single prop with all values.
|
|
127
|
+
*/
|
|
128
|
+
export declare const parseQueryString: <T>(search: string) => T;
|
|
129
|
+
|
|
125
130
|
export declare const PRIMARY_DARK_COLOR = "#161b22";
|
|
126
131
|
|
|
127
132
|
export declare const PRIMARY_LIGHT_COLOR = "white";
|
|
@@ -158,7 +163,16 @@ export declare type SimpleCardProps = Omit<CardProps, 'title'> & {
|
|
|
158
163
|
|
|
159
164
|
export declare const sortList: <List>(list: List[], { field, dir }: Order<keyof List>) => List[];
|
|
160
165
|
|
|
161
|
-
|
|
166
|
+
/** @deprecated Use stringifyQueryParams instead */
|
|
167
|
+
export declare const stringifyQuery: (params: Record<string, unknown | unknown[] | undefined>) => string;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Stringify an object of query parameters.
|
|
171
|
+
* Keys explicitly defined with undefined value will be skipped.
|
|
172
|
+
* Arrays will be appended multiple times with the "[]" suffix in the param name.
|
|
173
|
+
* All values are cast to string.
|
|
174
|
+
*/
|
|
175
|
+
export declare const stringifyQueryParams: (params: Record<string, unknown | unknown[] | undefined>) => string;
|
|
162
176
|
|
|
163
177
|
export declare const stringToOrder: <T>(order: string) => Order<T>;
|
|
164
178
|
|
|
@@ -178,7 +192,7 @@ export declare const useOrder: <T>(initialOrder: Order<T>) => [Order<T>, (orderF
|
|
|
178
192
|
|
|
179
193
|
export declare const useParsedQuery: <T>() => T;
|
|
180
194
|
|
|
181
|
-
export declare const useTimeoutToggle: (initialValue?: boolean, delay?: number, setTimeout?: ((handler: TimerHandler, timeout?: number
|
|
195
|
+
export declare const useTimeoutToggle: (initialValue?: boolean, delay?: number, setTimeout?: ((handler: TimerHandler, timeout?: number, ...arguments: any[]) => number) & typeof globalThis.setTimeout, clearTimeout?: ((id: number | undefined) => void) & typeof globalThis.clearTimeout) => [boolean, () => void];
|
|
182
196
|
|
|
183
197
|
export declare const useToggle: (initialValue?: boolean) => ToggleResult;
|
|
184
198
|
|
package/dist/index.js
CHANGED
|
@@ -1,32 +1,31 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { faCircleNotch as
|
|
1
|
+
import { jsx as s, jsxs as d, Fragment as C } from "react/jsx-runtime";
|
|
2
|
+
import { faCircleNotch as I, faSearch as E, faEllipsisV as P, faSortAmountUp as F, faSortAmountDown as $ } from "@fortawesome/free-solid-svg-icons";
|
|
3
3
|
import { FontAwesomeIcon as b } from "@fortawesome/react-fontawesome";
|
|
4
4
|
import { clsx as m } from "clsx";
|
|
5
|
-
import { Row as
|
|
6
|
-
import { useState as w, useCallback as
|
|
7
|
-
import { useLocation as J, NavLink as
|
|
8
|
-
import { v4 as
|
|
9
|
-
|
|
10
|
-
const W = (e) => ({
|
|
5
|
+
import { Row as k, Card as _, CardHeader as H, CardBody as M, Dropdown as G, DropdownToggle as T, DropdownMenu as O, NavItem as Q, NavLink as U, Nav as j, UncontrolledDropdown as q, DropdownItem as N } from "reactstrap";
|
|
6
|
+
import { useState as w, useCallback as f, useRef as g, useMemo as V, Children as Y, isValidElement as z } from "react";
|
|
7
|
+
import { useLocation as J, NavLink as W } from "react-router-dom";
|
|
8
|
+
import { v4 as X } from "uuid";
|
|
9
|
+
const Z = (e) => ({
|
|
11
10
|
error: "border-danger",
|
|
12
11
|
default: ""
|
|
13
12
|
})[e], B = (e) => ({
|
|
14
13
|
error: "text-danger",
|
|
15
14
|
default: "text-muted"
|
|
16
|
-
})[e],
|
|
15
|
+
})[e], pe = ({ className: e, children: r, loading: t = !1, type: n = "default", fullWidth: o = !1 }) => {
|
|
17
16
|
const c = m({
|
|
18
|
-
"col-md-12":
|
|
19
|
-
"col-md-10 offset-md-1": !
|
|
17
|
+
"col-md-12": o,
|
|
18
|
+
"col-md-10 offset-md-1": !o
|
|
20
19
|
});
|
|
21
|
-
return /* @__PURE__ */
|
|
22
|
-
t && /* @__PURE__ */
|
|
23
|
-
t && /* @__PURE__ */
|
|
20
|
+
return /* @__PURE__ */ s(k, { className: m("g-0", e), children: /* @__PURE__ */ s("div", { className: c, children: /* @__PURE__ */ s(_, { className: Z(n), body: !0, children: /* @__PURE__ */ d("h3", { className: m("text-center mb-0", B(n)), children: [
|
|
21
|
+
t && /* @__PURE__ */ s(b, { icon: I, spin: !0 }),
|
|
22
|
+
t && /* @__PURE__ */ s("span", { className: "ms-2", children: r ?? "Loading..." }),
|
|
24
23
|
!t && r
|
|
25
24
|
] }) }) }) });
|
|
26
25
|
}, K = ({ title: e, children: r, bodyClassName: t, ...n }) => /* @__PURE__ */ d(_, { ...n, children: [
|
|
27
|
-
e && /* @__PURE__ */
|
|
28
|
-
/* @__PURE__ */
|
|
29
|
-
] }),
|
|
26
|
+
e && /* @__PURE__ */ s(H, { role: "heading", "aria-level": 4, children: e }),
|
|
27
|
+
/* @__PURE__ */ s(M, { className: t, children: r })
|
|
28
|
+
] }), ge = ({ children: e, type: r, className: t, small: n = !1 }) => /* @__PURE__ */ s(k, { className: t, children: /* @__PURE__ */ s("div", { className: m({ "col-md-10 offset-md-1": !n, "col-12": n }), children: /* @__PURE__ */ s(
|
|
30
29
|
K,
|
|
31
30
|
{
|
|
32
31
|
role: "document",
|
|
@@ -39,61 +38,75 @@ const W = (e) => ({
|
|
|
39
38
|
bodyClassName: m({ "p-2": n }),
|
|
40
39
|
children: e
|
|
41
40
|
}
|
|
42
|
-
) }) }),
|
|
43
|
-
const
|
|
44
|
-
return
|
|
41
|
+
) }) }), S = (e) => {
|
|
42
|
+
const r = new URLSearchParams(e), t = {};
|
|
43
|
+
return r.forEach((n, o) => {
|
|
44
|
+
if (o.endsWith("[]")) {
|
|
45
|
+
const c = o.slice(0, -2);
|
|
46
|
+
t[c] ?? (t[c] = []), t[c].push(n);
|
|
47
|
+
} else
|
|
48
|
+
t[o] = n;
|
|
49
|
+
}), t;
|
|
50
|
+
}, ee = (e) => {
|
|
51
|
+
const r = new URLSearchParams();
|
|
52
|
+
for (const [t, n] of Object.entries(e))
|
|
53
|
+
n !== void 0 && (Array.isArray(n) ? n.forEach((o) => r.append(`${t}[]`, `${o}`)) : r.append(t, `${n}`));
|
|
54
|
+
return r.toString();
|
|
55
|
+
}, be = S, we = ee, re = (e = !1) => {
|
|
56
|
+
const [r, t] = w(e), n = f(() => t((l) => !l), []), o = f(() => t(!0), []), c = f(() => t(!1), []);
|
|
57
|
+
return [r, n, o, c];
|
|
45
58
|
}, Ne = (e = !1, r = 2e3, t = window.setTimeout, n = window.clearTimeout) => {
|
|
46
|
-
const [
|
|
59
|
+
const [o, c] = w(e), l = g(e), a = g(), i = f(() => {
|
|
47
60
|
c(!l.current), a.current && n(a.current), a.current = t(() => c(l.current), r);
|
|
48
61
|
}, [n, r, t]);
|
|
49
|
-
return [
|
|
62
|
+
return [o, i];
|
|
50
63
|
}, A = () => {
|
|
51
|
-
const { current: e } = g(`dom-${
|
|
64
|
+
const { current: e } = g(`dom-${X()}`);
|
|
52
65
|
return e;
|
|
53
66
|
}, Ce = () => g(null), _e = () => {
|
|
54
67
|
const { search: e } = J();
|
|
55
|
-
return V(() =>
|
|
56
|
-
},
|
|
68
|
+
return V(() => S(e), [e]);
|
|
69
|
+
}, y = ({ checked: e = !1, onChange: r, className: t, children: n, type: o, inline: c = !1 }) => {
|
|
57
70
|
const l = A(), a = (h) => r == null ? void 0 : r(h.target.checked, h), i = {
|
|
58
|
-
"form-switch":
|
|
59
|
-
"form-checkbox":
|
|
71
|
+
"form-switch": o === "switch",
|
|
72
|
+
"form-checkbox": o === "checkbox"
|
|
60
73
|
}, u = c ? { display: "inline-block" } : {};
|
|
61
74
|
return /* @__PURE__ */ d("span", { className: m("form-check", i, t), style: u, children: [
|
|
62
|
-
/* @__PURE__ */
|
|
63
|
-
/* @__PURE__ */
|
|
75
|
+
/* @__PURE__ */ s("input", { type: "checkbox", className: "form-check-input", id: l, checked: e, onChange: a }),
|
|
76
|
+
/* @__PURE__ */ s("label", { className: "form-check-label", htmlFor: l, children: n })
|
|
64
77
|
] });
|
|
65
|
-
},
|
|
66
|
-
/* @__PURE__ */
|
|
78
|
+
}, ve = (e) => /* @__PURE__ */ s(y, { type: "checkbox", ...e }), ke = (e) => /* @__PURE__ */ s(y, { type: "switch", ...e }), te = ({ children: e, label: r, className: t = "", labelClassName: n = "", noMargin: o = !1, id: c }) => /* @__PURE__ */ d("div", { className: `${t} ${o ? "" : "mb-3"}`, children: [
|
|
79
|
+
/* @__PURE__ */ s("label", { className: `form-label ${n}`, htmlFor: c, children: r }),
|
|
67
80
|
e
|
|
68
|
-
] }), Te = ({ children: e, value: r, onChange: t, type: n, required:
|
|
81
|
+
] }), Te = ({ children: e, value: r, onChange: t, type: n, required: o, placeholder: c, className: l, labelClassName: a }) => {
|
|
69
82
|
const i = A();
|
|
70
|
-
return /* @__PURE__ */
|
|
83
|
+
return /* @__PURE__ */ s(te, { label: /* @__PURE__ */ d(C, { children: [
|
|
71
84
|
e,
|
|
72
85
|
":"
|
|
73
|
-
] }), className: l, labelClassName: a, id: i, children: /* @__PURE__ */
|
|
86
|
+
] }), className: l, labelClassName: a, id: i, children: /* @__PURE__ */ s(
|
|
74
87
|
"input",
|
|
75
88
|
{
|
|
76
89
|
id: i,
|
|
77
90
|
className: "form-control",
|
|
78
91
|
type: n ?? "text",
|
|
79
92
|
value: r,
|
|
80
|
-
required:
|
|
93
|
+
required: o ?? !0,
|
|
81
94
|
placeholder: c,
|
|
82
95
|
onChange: (u) => t(u.target.value)
|
|
83
96
|
}
|
|
84
97
|
) });
|
|
85
98
|
}, ne = 500;
|
|
86
|
-
let
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
}, Oe = ({ onChange: e, className: r, large: t = !0, noBorder: n = !1, initialValue:
|
|
90
|
-
const [l, a] = w(
|
|
91
|
-
a(u),
|
|
92
|
-
e(u),
|
|
99
|
+
let p;
|
|
100
|
+
const v = () => {
|
|
101
|
+
p && clearTimeout(p), p = null;
|
|
102
|
+
}, Oe = ({ onChange: e, className: r, large: t = !0, noBorder: n = !1, initialValue: o = "", setTimeout_: c = setTimeout }) => {
|
|
103
|
+
const [l, a] = w(o), i = (u, h = ne) => {
|
|
104
|
+
a(u), v(), p = c(() => {
|
|
105
|
+
e(u), v();
|
|
93
106
|
}, h);
|
|
94
107
|
};
|
|
95
108
|
return /* @__PURE__ */ d("div", { className: m("search-field", r), children: [
|
|
96
|
-
/* @__PURE__ */
|
|
109
|
+
/* @__PURE__ */ s(
|
|
97
110
|
"input",
|
|
98
111
|
{
|
|
99
112
|
type: "text",
|
|
@@ -106,8 +119,8 @@ const k = () => {
|
|
|
106
119
|
onChange: (u) => i(u.target.value)
|
|
107
120
|
}
|
|
108
121
|
),
|
|
109
|
-
/* @__PURE__ */
|
|
110
|
-
/* @__PURE__ */
|
|
122
|
+
/* @__PURE__ */ s(b, { icon: E, className: "search-field__icon" }),
|
|
123
|
+
/* @__PURE__ */ s(
|
|
111
124
|
"button",
|
|
112
125
|
{
|
|
113
126
|
"aria-label": "Clear search",
|
|
@@ -119,12 +132,12 @@ const k = () => {
|
|
|
119
132
|
}
|
|
120
133
|
)
|
|
121
134
|
] });
|
|
122
|
-
},
|
|
135
|
+
}, se = ({
|
|
123
136
|
text: e,
|
|
124
137
|
disabled: r = !1,
|
|
125
138
|
className: t,
|
|
126
139
|
children: n,
|
|
127
|
-
dropdownClassName:
|
|
140
|
+
dropdownClassName: o,
|
|
128
141
|
noCaret: c,
|
|
129
142
|
end: l = !1,
|
|
130
143
|
minWidth: a,
|
|
@@ -132,18 +145,18 @@ const k = () => {
|
|
|
132
145
|
size: u,
|
|
133
146
|
...h
|
|
134
147
|
}) => {
|
|
135
|
-
const [
|
|
148
|
+
const [L, R] = re(), x = m("dropdown-btn__toggle", t, {
|
|
136
149
|
"btn-block": !i,
|
|
137
150
|
"dropdown-btn__toggle--with-caret": !c
|
|
138
|
-
}),
|
|
139
|
-
return /* @__PURE__ */ d(G, { isOpen:
|
|
140
|
-
/* @__PURE__ */
|
|
141
|
-
/* @__PURE__ */
|
|
151
|
+
}), D = { minWidth: a && `${a}px` };
|
|
152
|
+
return /* @__PURE__ */ d(G, { isOpen: L, toggle: R, disabled: r, className: o, children: [
|
|
153
|
+
/* @__PURE__ */ s(T, { size: u, caret: !c, className: x, color: "primary", ...h, children: e }),
|
|
154
|
+
/* @__PURE__ */ s(O, { className: "w-100", end: l, style: D, children: n })
|
|
142
155
|
] });
|
|
143
|
-
},
|
|
144
|
-
|
|
156
|
+
}, Se = ({ children: e, minWidth: r, label: t = "Options" }) => /* @__PURE__ */ s(
|
|
157
|
+
se,
|
|
145
158
|
{
|
|
146
|
-
text: /* @__PURE__ */
|
|
159
|
+
text: /* @__PURE__ */ s(b, { className: "px-1", icon: P }),
|
|
147
160
|
"aria-label": t,
|
|
148
161
|
size: "sm",
|
|
149
162
|
minWidth: r,
|
|
@@ -152,29 +165,29 @@ const k = () => {
|
|
|
152
165
|
inline: !0,
|
|
153
166
|
children: e
|
|
154
167
|
}
|
|
155
|
-
),
|
|
156
|
-
if (!z(n) || n.type !==
|
|
168
|
+
), oe = ({ children: e, ...r }) => /* @__PURE__ */ s(Q, { children: /* @__PURE__ */ s(U, { className: "nav-pills__nav-link", tag: W, ...r, children: e }) }), Ae = ({ children: e, fill: r = !1, className: t = "" }) => /* @__PURE__ */ s(_, { className: `nav-pills__nav p-0 overflow-hidden ${t}`, body: !0, children: /* @__PURE__ */ s(j, { pills: !0, fill: r, children: Y.map(e, (n) => {
|
|
169
|
+
if (!z(n) || n.type !== oe)
|
|
157
170
|
throw new Error("Only NavPillItem children are allowed inside NavPills.");
|
|
158
171
|
return n;
|
|
159
172
|
}) }) }), ce = (e, r, t) => e !== r ? "ASC" : t ? {
|
|
160
173
|
ASC: "DESC",
|
|
161
174
|
DESC: void 0
|
|
162
|
-
}[t] : "ASC",
|
|
175
|
+
}[t] : "ASC", ye = (e, { field: r, dir: t }) => !r || !t ? e : e.sort((n, o) => {
|
|
163
176
|
const c = t === "ASC" ? 1 : -1, l = t === "ASC" ? -1 : 1;
|
|
164
|
-
return n[r] >
|
|
165
|
-
}),
|
|
177
|
+
return n[r] > o[r] ? c : l;
|
|
178
|
+
}), Le = (e) => e.dir ? `${e.field}-${e.dir}` : void 0, Re = (e) => {
|
|
166
179
|
const [r, t] = e.split("-");
|
|
167
180
|
return { field: r, dir: t };
|
|
168
|
-
},
|
|
169
|
-
const [r, t] = w(e), n =
|
|
181
|
+
}, xe = (e) => {
|
|
182
|
+
const [r, t] = w(e), n = f((o, c) => t({ field: o, dir: c }), []);
|
|
170
183
|
return [r, n];
|
|
171
184
|
};
|
|
172
|
-
function
|
|
185
|
+
function De({ items: e, order: r, onChange: t, isButton: n = !0, right: o = !1, prefixed: c = !0 }) {
|
|
173
186
|
const l = (a) => () => {
|
|
174
187
|
const i = ce(a, r.field, r.dir);
|
|
175
188
|
t(i ? a : void 0, i);
|
|
176
189
|
};
|
|
177
|
-
return /* @__PURE__ */ d(
|
|
190
|
+
return /* @__PURE__ */ d(q, { children: [
|
|
178
191
|
/* @__PURE__ */ d(
|
|
179
192
|
T,
|
|
180
193
|
{
|
|
@@ -185,13 +198,13 @@ function Ie({ items: e, order: r, onChange: t, isButton: n = !0, right: s = !1,
|
|
|
185
198
|
"btn-sm p-0": !n
|
|
186
199
|
}),
|
|
187
200
|
children: [
|
|
188
|
-
!n && /* @__PURE__ */
|
|
189
|
-
n && !r.field && /* @__PURE__ */
|
|
201
|
+
!n && /* @__PURE__ */ s(C, { children: "Order by" }),
|
|
202
|
+
n && !r.field && /* @__PURE__ */ s("i", { children: "Order by..." }),
|
|
190
203
|
n && r.field && /* @__PURE__ */ d(C, { children: [
|
|
191
204
|
c && "Order by: ",
|
|
192
205
|
e[r.field],
|
|
193
206
|
" - ",
|
|
194
|
-
/* @__PURE__ */
|
|
207
|
+
/* @__PURE__ */ s("small", { children: r.dir ?? "DESC" })
|
|
195
208
|
] })
|
|
196
209
|
]
|
|
197
210
|
}
|
|
@@ -199,65 +212,67 @@ function Ie({ items: e, order: r, onChange: t, isButton: n = !0, right: s = !1,
|
|
|
199
212
|
/* @__PURE__ */ d(
|
|
200
213
|
O,
|
|
201
214
|
{
|
|
202
|
-
end:
|
|
215
|
+
end: o,
|
|
203
216
|
className: m("w-100", { "ordering-dropdown__menu--link": !n }),
|
|
204
217
|
children: [
|
|
205
218
|
Object.entries(e).map(([a, i]) => /* @__PURE__ */ d(N, { active: r.field === a, onClick: l(a), children: [
|
|
206
219
|
i,
|
|
207
|
-
r.field === a && /* @__PURE__ */
|
|
220
|
+
r.field === a && /* @__PURE__ */ s(
|
|
208
221
|
b,
|
|
209
222
|
{
|
|
210
|
-
icon: r.dir === "ASC" ?
|
|
223
|
+
icon: r.dir === "ASC" ? F : $,
|
|
211
224
|
className: "ordering-dropdown__sort-icon"
|
|
212
225
|
}
|
|
213
226
|
)
|
|
214
227
|
] }, a)),
|
|
215
|
-
/* @__PURE__ */
|
|
216
|
-
/* @__PURE__ */
|
|
228
|
+
/* @__PURE__ */ s(N, { divider: !0 }),
|
|
229
|
+
/* @__PURE__ */ s(N, { disabled: !r.field, onClick: () => t(), children: /* @__PURE__ */ s("i", { children: "Clear selection" }) })
|
|
217
230
|
]
|
|
218
231
|
}
|
|
219
232
|
)
|
|
220
233
|
] });
|
|
221
234
|
}
|
|
222
|
-
const
|
|
235
|
+
const Ie = "#4696e5", Ee = "rgba(70, 150, 229, 0.4)", Pe = "#f77f28", Fe = "rgba(247, 127, 40, 0.4)", $e = "white", He = "#161b22", Me = (e) => {
|
|
223
236
|
var r;
|
|
224
237
|
return (r = document.querySelector("html")) == null ? void 0 : r.setAttribute("data-theme", e);
|
|
225
238
|
}, Ge = () => {
|
|
226
239
|
var e;
|
|
227
240
|
return ((e = document.querySelector("html")) == null ? void 0 : e.getAttribute("data-theme")) === "dark";
|
|
228
|
-
},
|
|
241
|
+
}, Qe = (e = window.matchMedia.bind(window)) => e("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
229
242
|
export {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
243
|
+
ve as Checkbox,
|
|
244
|
+
se as DropdownBtn,
|
|
245
|
+
Pe as HIGHLIGHTED_COLOR,
|
|
246
|
+
Fe as HIGHLIGHTED_COLOR_ALPHA,
|
|
234
247
|
Te as InputFormGroup,
|
|
235
248
|
te as LabeledFormGroup,
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
249
|
+
Ie as MAIN_COLOR,
|
|
250
|
+
Ee as MAIN_COLOR_ALPHA,
|
|
251
|
+
pe as Message,
|
|
252
|
+
oe as NavPillItem,
|
|
240
253
|
Ae as NavPills,
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
254
|
+
De as OrderingDropdown,
|
|
255
|
+
He as PRIMARY_DARK_COLOR,
|
|
256
|
+
$e as PRIMARY_LIGHT_COLOR,
|
|
257
|
+
ge as Result,
|
|
258
|
+
Se as RowDropdownBtn,
|
|
246
259
|
Oe as SearchField,
|
|
247
260
|
K as SimpleCard,
|
|
248
|
-
|
|
249
|
-
|
|
261
|
+
ke as ToggleSwitch,
|
|
262
|
+
Me as changeThemeInMarkup,
|
|
250
263
|
ce as determineOrderDir,
|
|
251
|
-
|
|
264
|
+
Qe as getSystemPreferredTheme,
|
|
252
265
|
Ge as isDarkThemeEnabled,
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
266
|
+
Le as orderToString,
|
|
267
|
+
be as parseQuery,
|
|
268
|
+
S as parseQueryString,
|
|
269
|
+
ye as sortList,
|
|
270
|
+
Re as stringToOrder,
|
|
257
271
|
we as stringifyQuery,
|
|
272
|
+
ee as stringifyQueryParams,
|
|
258
273
|
A as useDomId,
|
|
259
274
|
Ce as useElementRef,
|
|
260
|
-
|
|
275
|
+
xe as useOrder,
|
|
261
276
|
_e as useParsedQuery,
|
|
262
277
|
Ne as useTimeoutToggle,
|
|
263
278
|
re as useToggle
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(o,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("react/jsx-runtime"),require("@fortawesome/free-solid-svg-icons"),require("@fortawesome/react-fontawesome"),require("clsx"),require("reactstrap"),require("react"),require("react-router-dom"),require("uuid")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@fortawesome/free-solid-svg-icons","@fortawesome/react-fontawesome","clsx","reactstrap","react","react-router-dom","uuid"],s):(o=typeof globalThis<"u"?globalThis:o||self,s(o["shlink-frontend-kit"]={},o.jsxRuntime,o.freeSolidSvgIcons,o.reactFontawesome,o.clsx,o.reactstrap,o.react,o.reactRouterDom,o.uuid))})(this,function(o,s,w,b,f,d,h,O,v){"use strict";const P=e=>({error:"border-danger",default:""})[e],F=e=>({error:"text-danger",default:"text-muted"})[e],H=({className:e,children:r,loading:n=!1,type:c="default",fullWidth:l=!1})=>{const a=f.clsx({"col-md-12":l,"col-md-10 offset-md-1":!l});return s.jsx(d.Row,{className:f.clsx("g-0",e),children:s.jsx("div",{className:a,children:s.jsx(d.Card,{className:P(c),body:!0,children:s.jsxs("h3",{className:f.clsx("text-center mb-0",F(c)),children:[n&&s.jsx(b.FontAwesomeIcon,{icon:w.faCircleNotch,spin:!0}),n&&s.jsx("span",{className:"ms-2",children:r??"Loading..."}),!n&&r]})})})})},T=({title:e,children:r,bodyClassName:n,...c})=>s.jsxs(d.Card,{...c,children:[e&&s.jsx(d.CardHeader,{role:"heading","aria-level":4,children:e}),s.jsx(d.CardBody,{className:n,children:r})]}),E=({children:e,type:r,className:n,small:c=!1})=>s.jsx(d.Row,{className:n,children:s.jsx("div",{className:f.clsx({"col-md-10 offset-md-1":!c,"col-12":c}),children:s.jsx(T,{role:"document",className:f.clsx("text-center",{"bg-main":r==="success","bg-danger":r==="error","bg-warning":r==="warning","text-white":r!=="warning"}),bodyClassName:f.clsx({"p-2":c}),children:e})})}),_=e=>{const r=new URLSearchParams(e),n={};return r.forEach((c,l)=>{if(l.endsWith("[]")){const a=l.slice(0,-2);n[a]??(n[a]=[]),n[a].push(c)}else n[l]=c}),n},k=e=>{const r=new URLSearchParams;for(const[n,c]of Object.entries(e))c!==void 0&&(Array.isArray(c)?c.forEach(l=>r.append(`${n}[]`,`${l}`)):r.append(n,`${c}`));return r.toString()},M=_,G=k,A=(e=!1)=>{const[r,n]=h.useState(e),c=h.useCallback(()=>n(i=>!i),[]),l=h.useCallback(()=>n(!0),[]),a=h.useCallback(()=>n(!1),[]);return[r,c,l,a]},q=(e=!1,r=2e3,n=window.setTimeout,c=window.clearTimeout)=>{const[l,a]=h.useState(e),i=h.useRef(e),t=h.useRef(),u=h.useCallback(()=>{a(!i.current),t.current&&c(t.current),t.current=n(()=>a(i.current),r)},[c,r,n]);return[l,u]},N=()=>{const{current:e}=h.useRef(`dom-${v.v4()}`);return e},$=()=>h.useRef(null),Q=()=>{const{search:e}=O.useLocation();return h.useMemo(()=>_(e),[e])},p=({checked:e=!1,onChange:r,className:n,children:c,type:l,inline:a=!1})=>{const i=N(),t=g=>r==null?void 0:r(g.target.checked,g),u={"form-switch":l==="switch","form-checkbox":l==="checkbox"},m=a?{display:"inline-block"}:{};return s.jsxs("span",{className:f.clsx("form-check",u,n),style:m,children:[s.jsx("input",{type:"checkbox",className:"form-check-input",id:i,checked:e,onChange:t}),s.jsx("label",{className:"form-check-label",htmlFor:i,children:c})]})},j=e=>s.jsx(p,{type:"checkbox",...e}),U=e=>s.jsx(p,{type:"switch",...e}),y=({children:e,label:r,className:n="",labelClassName:c="",noMargin:l=!1,id:a})=>s.jsxs("div",{className:`${n} ${l?"":"mb-3"}`,children:[s.jsx("label",{className:`form-label ${c}`,htmlFor:a,children:r}),e]}),Y=({children:e,value:r,onChange:n,type:c,required:l,placeholder:a,className:i,labelClassName:t})=>{const u=N();return s.jsx(y,{label:s.jsxs(s.Fragment,{children:[e,":"]}),className:i,labelClassName:t,id:u,children:s.jsx("input",{id:u,className:"form-control",type:c??"text",value:r,required:l??!0,placeholder:a,onChange:m=>n(m.target.value)})})},V=500;let C;const I=()=>{C&&clearTimeout(C),C=null},z=({onChange:e,className:r,large:n=!0,noBorder:c=!1,initialValue:l="",setTimeout_:a=setTimeout})=>{const[i,t]=h.useState(l),u=(m,g=V)=>{t(m),I(),C=a(()=>{e(m),I()},g)};return s.jsxs("div",{className:f.clsx("search-field",r),children:[s.jsx("input",{type:"text",className:f.clsx("form-control search-field__input",{"form-control-lg":n,"search-field__input--no-border":c}),placeholder:"Search...",value:i,onChange:m=>u(m.target.value)}),s.jsx(b.FontAwesomeIcon,{icon:w.faSearch,className:"search-field__icon"}),s.jsx("button",{"aria-label":"Clear search",type:"button",className:"close search-field__close btn-close",hidden:i==="",id:"search-field__close",onClick:()=>u("",0)})]})},L=({text:e,disabled:r=!1,className:n,children:c,dropdownClassName:l,noCaret:a,end:i=!1,minWidth:t,inline:u,size:m,...g})=>{const[te,de]=A(),ie=f.clsx("dropdown-btn__toggle",n,{"btn-block":!u,"dropdown-btn__toggle--with-caret":!a}),he={minWidth:t&&`${t}px`};return s.jsxs(d.Dropdown,{isOpen:te,toggle:de,disabled:r,className:l,children:[s.jsx(d.DropdownToggle,{size:m,caret:!a,className:ie,color:"primary",...g,children:e}),s.jsx(d.DropdownMenu,{className:"w-100",end:i,style:he,children:c})]})},B=({children:e,minWidth:r,label:n="Options"})=>s.jsx(L,{text:s.jsx(b.FontAwesomeIcon,{className:"px-1",icon:w.faEllipsisV}),"aria-label":n,size:"sm",minWidth:r,end:!0,noCaret:!0,inline:!0,children:e}),D=({children:e,...r})=>s.jsx(d.NavItem,{children:s.jsx(d.NavLink,{className:"nav-pills__nav-link",tag:O.NavLink,...r,children:e})}),J=({children:e,fill:r=!1,className:n=""})=>s.jsx(d.Card,{className:`nav-pills__nav p-0 overflow-hidden ${n}`,body:!0,children:s.jsx(d.Nav,{pills:!0,fill:r,children:h.Children.map(e,c=>{if(!h.isValidElement(c)||c.type!==D)throw new Error("Only NavPillItem children are allowed inside NavPills.");return c})})}),S=(e,r,n)=>e!==r?"ASC":n?{ASC:"DESC",DESC:void 0}[n]:"ASC",W=(e,{field:r,dir:n})=>!r||!n?e:e.sort((c,l)=>{const a=n==="ASC"?1:-1,i=n==="ASC"?-1:1;return c[r]>l[r]?a:i}),X=e=>e.dir?`${e.field}-${e.dir}`:void 0,Z=e=>{const[r,n]=e.split("-");return{field:r,dir:n}},K=e=>{const[r,n]=h.useState(e),c=h.useCallback((l,a)=>n({field:l,dir:a}),[]);return[r,c]};function R({items:e,order:r,onChange:n,isButton:c=!0,right:l=!1,prefixed:a=!0}){const i=t=>()=>{const u=S(t,r.field,r.dir);n(u?t:void 0,u)};return s.jsxs(d.UncontrolledDropdown,{children:[s.jsxs(d.DropdownToggle,{caret:!0,color:c?"primary":"link",className:f.clsx({"dropdown-btn__toggle btn-block pe-4 overflow-hidden":c,"btn-sm p-0":!c}),children:[!c&&s.jsx(s.Fragment,{children:"Order by"}),c&&!r.field&&s.jsx("i",{children:"Order by..."}),c&&r.field&&s.jsxs(s.Fragment,{children:[a&&"Order by: ",e[r.field]," - ",s.jsx("small",{children:r.dir??"DESC"})]})]}),s.jsxs(d.DropdownMenu,{end:l,className:f.clsx("w-100",{"ordering-dropdown__menu--link":!c}),children:[Object.entries(e).map(([t,u])=>s.jsxs(d.DropdownItem,{active:r.field===t,onClick:i(t),children:[u,r.field===t&&s.jsx(b.FontAwesomeIcon,{icon:r.dir==="ASC"?w.faSortAmountUp:w.faSortAmountDown,className:"ordering-dropdown__sort-icon"})]},t)),s.jsx(d.DropdownItem,{divider:!0}),s.jsx(d.DropdownItem,{disabled:!r.field,onClick:()=>n(),children:s.jsx("i",{children:"Clear selection"})})]})]})}const x="#4696e5",ee="rgba(70, 150, 229, 0.4)",re="#f77f28",se="rgba(247, 127, 40, 0.4)",ne="white",oe="#161b22",ce=e=>{var r;return(r=document.querySelector("html"))==null?void 0:r.setAttribute("data-theme",e)},le=()=>{var e;return((e=document.querySelector("html"))==null?void 0:e.getAttribute("data-theme"))==="dark"},ae=(e=window.matchMedia.bind(window))=>e("(prefers-color-scheme: dark)").matches?"dark":"light";o.Checkbox=j,o.DropdownBtn=L,o.HIGHLIGHTED_COLOR=re,o.HIGHLIGHTED_COLOR_ALPHA=se,o.InputFormGroup=Y,o.LabeledFormGroup=y,o.MAIN_COLOR=x,o.MAIN_COLOR_ALPHA=ee,o.Message=H,o.NavPillItem=D,o.NavPills=J,o.OrderingDropdown=R,o.PRIMARY_DARK_COLOR=oe,o.PRIMARY_LIGHT_COLOR=ne,o.Result=E,o.RowDropdownBtn=B,o.SearchField=z,o.SimpleCard=T,o.ToggleSwitch=U,o.changeThemeInMarkup=ce,o.determineOrderDir=S,o.getSystemPreferredTheme=ae,o.isDarkThemeEnabled=le,o.orderToString=X,o.parseQuery=M,o.parseQueryString=_,o.sortList=W,o.stringToOrder=Z,o.stringifyQuery=G,o.stringifyQueryParams=k,o.useDomId=N,o.useElementRef=$,o.useOrder=K,o.useParsedQuery=Q,o.useTimeoutToggle=q,o.useToggle=A,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"test:ci": "npm run test -- --coverage",
|
|
24
24
|
"lint": "npm run lint:css && npm run lint:js",
|
|
25
25
|
"lint:css": "stylelint src/*.scss src/**/*.scss dev/*.scss dev/**/*.scss",
|
|
26
|
-
"lint:js": "eslint
|
|
26
|
+
"lint:js": "eslint dev src test",
|
|
27
27
|
"lint:fix": "npm run lint:css:fix && npm run lint:js:fix",
|
|
28
28
|
"lint:css:fix": "npm run lint:css -- --fix",
|
|
29
29
|
"lint:js:fix": "npm run lint:js -- --fix",
|
|
@@ -31,9 +31,8 @@
|
|
|
31
31
|
"dev": "vite serve --host=0.0.0.0 --port 3001"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"clsx": "^2.1.
|
|
35
|
-
"
|
|
36
|
-
"uuid": "^9.0.1"
|
|
34
|
+
"clsx": "^2.1.1",
|
|
35
|
+
"uuid": "^10.0.0"
|
|
37
36
|
},
|
|
38
37
|
"peerDependencies": {
|
|
39
38
|
"@fortawesome/fontawesome-free": "^6.4.2",
|
|
@@ -45,32 +44,36 @@
|
|
|
45
44
|
"reactstrap": "^9.2.0"
|
|
46
45
|
},
|
|
47
46
|
"devDependencies": {
|
|
48
|
-
"@shlinkio/eslint-config-js-coding-standard": "~
|
|
47
|
+
"@shlinkio/eslint-config-js-coding-standard": "~3.0.0",
|
|
49
48
|
"@shlinkio/stylelint-config-css-coding-standard": "~1.1.1",
|
|
50
|
-
"@
|
|
51
|
-
"@testing-library/
|
|
49
|
+
"@stylistic/eslint-plugin": "^2.3.0",
|
|
50
|
+
"@testing-library/jest-dom": "^6.4.6",
|
|
51
|
+
"@testing-library/react": "^16.0.0",
|
|
52
52
|
"@testing-library/user-event": "^14.5.2",
|
|
53
53
|
"@total-typescript/shoehorn": "^0.1.2",
|
|
54
|
-
"@types/qs": "^6.9.
|
|
55
|
-
"@types/react": "^18.
|
|
56
|
-
"@types/react-dom": "^18.
|
|
57
|
-
"@types/uuid": "^
|
|
58
|
-
"@
|
|
59
|
-
"@
|
|
60
|
-
"
|
|
61
|
-
"@vitest/coverage-v8": "^1.5.0",
|
|
62
|
-
"axe-core": "^4.9.0",
|
|
54
|
+
"@types/qs": "^6.9.15",
|
|
55
|
+
"@types/react": "^18.3.3",
|
|
56
|
+
"@types/react-dom": "^18.3.0",
|
|
57
|
+
"@types/uuid": "^10.0.0",
|
|
58
|
+
"@vitejs/plugin-react": "^4.3.1",
|
|
59
|
+
"@vitest/coverage-v8": "^2.0.2",
|
|
60
|
+
"axe-core": "^4.9.1",
|
|
63
61
|
"bootstrap": "5.2.3",
|
|
64
62
|
"eslint": "^8.57.0",
|
|
63
|
+
"eslint-plugin-jsx-a11y": "^6.9.0",
|
|
64
|
+
"eslint-plugin-react": "^7.34.3",
|
|
65
|
+
"eslint-plugin-react-hooks": "^4.6.2",
|
|
66
|
+
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
65
67
|
"history": "^5.3.0",
|
|
66
|
-
"jsdom": "^24.
|
|
68
|
+
"jsdom": "^24.1.0",
|
|
67
69
|
"resize-observer-polyfill": "^1.5.1",
|
|
68
|
-
"sass": "^1.
|
|
70
|
+
"sass": "^1.77.8",
|
|
69
71
|
"stylelint": "^15.11.0",
|
|
70
|
-
"typescript": "^5.
|
|
71
|
-
"
|
|
72
|
-
"vite
|
|
73
|
-
"
|
|
72
|
+
"typescript": "^5.5.3",
|
|
73
|
+
"typescript-eslint": "^7.16.0",
|
|
74
|
+
"vite": "^5.3.3",
|
|
75
|
+
"vite-plugin-dts": "^3.9.1",
|
|
76
|
+
"vitest": "^2.0.2"
|
|
74
77
|
},
|
|
75
78
|
"browserslist": [
|
|
76
79
|
">0.2%",
|
|
@@ -78,5 +81,5 @@
|
|
|
78
81
|
"not ie <= 11",
|
|
79
82
|
"not op_mini all"
|
|
80
83
|
],
|
|
81
|
-
"version": "0.5.
|
|
84
|
+
"version": "0.5.2"
|
|
82
85
|
}
|