@shlinkio/shlink-frontend-kit 0.5.3 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +0 -9
- package/dist/index.js +94 -97
- package/package.json +17 -24
- package/dist/index.umd.cjs +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -118,9 +118,6 @@ export declare type OrderingDropdownProps<T extends string = string> = {
|
|
|
118
118
|
|
|
119
119
|
export declare const orderToString: <T>(order: Order<T>) => string | undefined;
|
|
120
120
|
|
|
121
|
-
/** @deprecated Use parseQueryString instead */
|
|
122
|
-
export declare const parseQuery: <T>(search: string) => T;
|
|
123
|
-
|
|
124
121
|
/**
|
|
125
122
|
* Parses provided query string into an object.
|
|
126
123
|
* Parameters ending with "[]" will be considered arrays and returned as a single prop with all values.
|
|
@@ -163,9 +160,6 @@ export declare type SimpleCardProps = Omit<CardProps, 'title'> & {
|
|
|
163
160
|
|
|
164
161
|
export declare const sortList: <List>(list: List[], { field, dir }: Order<keyof List>) => List[];
|
|
165
162
|
|
|
166
|
-
/** @deprecated Use stringifyQueryParams instead */
|
|
167
|
-
export declare const stringifyQuery: (params: Record<string, unknown | unknown[] | undefined>) => string;
|
|
168
|
-
|
|
169
163
|
/**
|
|
170
164
|
* Stringify an object of query parameters.
|
|
171
165
|
* Keys explicitly defined with undefined value will be skipped.
|
|
@@ -184,9 +178,6 @@ declare type ToggleResult = [boolean, () => void, () => void, () => void];
|
|
|
184
178
|
|
|
185
179
|
export declare const ToggleSwitch: FC<BooleanControlProps>;
|
|
186
180
|
|
|
187
|
-
/** @deprecated Use standard useId() instead */
|
|
188
|
-
export declare const useDomId: () => string;
|
|
189
|
-
|
|
190
181
|
export declare const useElementRef: <T>() => MutableRefObject<T | null>;
|
|
191
182
|
|
|
192
183
|
export declare const useOrder: <T>(initialOrder: Order<T>) => [Order<T>, (orderField?: T, orderDir?: OrderDir) => void];
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { jsx as s, jsxs as d, Fragment as N } from "react/jsx-runtime";
|
|
2
|
-
import { faCircleNotch as
|
|
2
|
+
import { faCircleNotch as I, faSearch as D, faEllipsisV as E, faSortAmountUp as P, faSortAmountDown as F } from "@fortawesome/free-solid-svg-icons";
|
|
3
3
|
import { FontAwesomeIcon as g } from "@fortawesome/react-fontawesome";
|
|
4
4
|
import { clsx as m } from "clsx";
|
|
5
|
-
import { Row as
|
|
6
|
-
import { useId as
|
|
7
|
-
import { useLocation as
|
|
8
|
-
const
|
|
5
|
+
import { Row as v, Card as _, CardHeader as H, CardBody as M, Dropdown as $, DropdownToggle as T, DropdownMenu as O, NavItem as G, NavLink as U, Nav as j, UncontrolledDropdown as q, DropdownItem as w } from "reactstrap";
|
|
6
|
+
import { useId as S, useState as b, useCallback as f, useRef as C, useMemo as Q, Children as V, isValidElement as Y } from "react";
|
|
7
|
+
import { useLocation as z, NavLink as J } from "react-router-dom";
|
|
8
|
+
const W = (e) => ({
|
|
9
9
|
error: "border-danger",
|
|
10
10
|
default: ""
|
|
11
|
-
})[e],
|
|
11
|
+
})[e], X = (e) => ({
|
|
12
12
|
error: "text-danger",
|
|
13
13
|
default: "text-muted"
|
|
14
14
|
})[e], he = ({ className: e, children: r, loading: t = !1, type: n = "default", fullWidth: o = !1 }) => {
|
|
@@ -16,16 +16,16 @@ const X = (e) => ({
|
|
|
16
16
|
"col-md-12": o,
|
|
17
17
|
"col-md-10 offset-md-1": !o
|
|
18
18
|
});
|
|
19
|
-
return /* @__PURE__ */ s(
|
|
20
|
-
t && /* @__PURE__ */ s(g, { icon:
|
|
19
|
+
return /* @__PURE__ */ s(v, { className: m("g-0", e), children: /* @__PURE__ */ s("div", { className: c, children: /* @__PURE__ */ s(_, { className: W(n), body: !0, children: /* @__PURE__ */ d("h3", { className: m("text-center mb-0", X(n)), children: [
|
|
20
|
+
t && /* @__PURE__ */ s(g, { icon: I, spin: !0 }),
|
|
21
21
|
t && /* @__PURE__ */ s("span", { className: "ms-2", children: r ?? "Loading..." }),
|
|
22
22
|
!t && r
|
|
23
23
|
] }) }) }) });
|
|
24
|
-
},
|
|
25
|
-
e && /* @__PURE__ */ s(
|
|
26
|
-
/* @__PURE__ */ s(
|
|
27
|
-
] }),
|
|
28
|
-
|
|
24
|
+
}, Z = ({ title: e, children: r, bodyClassName: t, ...n }) => /* @__PURE__ */ d(_, { ...n, children: [
|
|
25
|
+
e && /* @__PURE__ */ s(H, { role: "heading", "aria-level": 4, children: e }),
|
|
26
|
+
/* @__PURE__ */ s(M, { className: t, children: r })
|
|
27
|
+
] }), ue = ({ children: e, type: r, className: t, small: n = !1 }) => /* @__PURE__ */ s(v, { className: t, children: /* @__PURE__ */ s("div", { className: m({ "col-md-10 offset-md-1": !n, "col-12": n }), children: /* @__PURE__ */ s(
|
|
28
|
+
Z,
|
|
29
29
|
{
|
|
30
30
|
role: "document",
|
|
31
31
|
className: m("text-center", {
|
|
@@ -38,20 +38,20 @@ const X = (e) => ({
|
|
|
38
38
|
children: e
|
|
39
39
|
}
|
|
40
40
|
) }) }), A = ({ checked: e = !1, onChange: r, className: t, children: n, type: o, inline: c = !1 }) => {
|
|
41
|
-
const l =
|
|
41
|
+
const l = S(), a = (u) => r == null ? void 0 : r(u.target.checked, u), i = {
|
|
42
42
|
"form-switch": o === "switch",
|
|
43
43
|
"form-checkbox": o === "checkbox"
|
|
44
|
-
},
|
|
45
|
-
return /* @__PURE__ */ d("span", { className: m("form-check", i, t), style:
|
|
44
|
+
}, h = c ? { display: "inline-block" } : {};
|
|
45
|
+
return /* @__PURE__ */ d("span", { className: m("form-check", i, t), style: h, children: [
|
|
46
46
|
/* @__PURE__ */ s("input", { type: "checkbox", className: "form-check-input", id: l, checked: e, onChange: a }),
|
|
47
47
|
/* @__PURE__ */ s("label", { className: "form-check-label", htmlFor: l, children: n })
|
|
48
48
|
] });
|
|
49
|
-
},
|
|
49
|
+
}, fe = (e) => /* @__PURE__ */ s(A, { type: "checkbox", ...e }), pe = (e) => /* @__PURE__ */ s(A, { type: "switch", ...e }), B = ({ children: e, label: r, className: t = "", labelClassName: n = "", noMargin: o = !1, id: c }) => /* @__PURE__ */ d("div", { className: `${t} ${o ? "" : "mb-3"}`, children: [
|
|
50
50
|
/* @__PURE__ */ s("label", { className: `form-label ${n}`, htmlFor: c, children: r }),
|
|
51
51
|
e
|
|
52
|
-
] }),
|
|
53
|
-
const i =
|
|
54
|
-
return /* @__PURE__ */ s(
|
|
52
|
+
] }), ge = ({ children: e, value: r, onChange: t, type: n, required: o, placeholder: c, className: l, labelClassName: a }) => {
|
|
53
|
+
const i = S();
|
|
54
|
+
return /* @__PURE__ */ s(B, { label: /* @__PURE__ */ d(N, { children: [
|
|
55
55
|
e,
|
|
56
56
|
":"
|
|
57
57
|
] }), className: l, labelClassName: a, id: i, children: /* @__PURE__ */ s(
|
|
@@ -63,18 +63,18 @@ const X = (e) => ({
|
|
|
63
63
|
value: r,
|
|
64
64
|
required: o ?? !0,
|
|
65
65
|
placeholder: c,
|
|
66
|
-
onChange: (
|
|
66
|
+
onChange: (h) => t(h.target.value)
|
|
67
67
|
}
|
|
68
68
|
) });
|
|
69
|
-
},
|
|
69
|
+
}, K = 500;
|
|
70
70
|
let p;
|
|
71
|
-
const
|
|
71
|
+
const k = () => {
|
|
72
72
|
p !== null && clearTimeout(p), p = null;
|
|
73
|
-
},
|
|
74
|
-
const [l, a] = b(o), i = (
|
|
75
|
-
a(
|
|
76
|
-
e(
|
|
77
|
-
},
|
|
73
|
+
}, be = ({ onChange: e, className: r, large: t = !0, noBorder: n = !1, initialValue: o = "", setTimeout_: c = setTimeout }) => {
|
|
74
|
+
const [l, a] = b(o), i = (h, u = K) => {
|
|
75
|
+
a(h), k(), p = c(() => {
|
|
76
|
+
e(h), k();
|
|
77
|
+
}, u);
|
|
78
78
|
};
|
|
79
79
|
return /* @__PURE__ */ d("div", { className: m("search-field", r), children: [
|
|
80
80
|
/* @__PURE__ */ s(
|
|
@@ -87,10 +87,10 @@ const v = () => {
|
|
|
87
87
|
}),
|
|
88
88
|
placeholder: "Search...",
|
|
89
89
|
value: l,
|
|
90
|
-
onChange: (
|
|
90
|
+
onChange: (h) => i(h.target.value)
|
|
91
91
|
}
|
|
92
92
|
),
|
|
93
|
-
/* @__PURE__ */ s(g, { icon:
|
|
93
|
+
/* @__PURE__ */ s(g, { icon: D, className: "search-field__icon" }),
|
|
94
94
|
/* @__PURE__ */ s(
|
|
95
95
|
"button",
|
|
96
96
|
{
|
|
@@ -103,7 +103,7 @@ const v = () => {
|
|
|
103
103
|
}
|
|
104
104
|
)
|
|
105
105
|
] });
|
|
106
|
-
},
|
|
106
|
+
}, ee = (e) => {
|
|
107
107
|
const r = new URLSearchParams(e), t = {};
|
|
108
108
|
return r.forEach((n, o) => {
|
|
109
109
|
if (o.endsWith("[]")) {
|
|
@@ -112,23 +112,23 @@ const v = () => {
|
|
|
112
112
|
} else
|
|
113
113
|
t[o] = n;
|
|
114
114
|
}), t;
|
|
115
|
-
},
|
|
115
|
+
}, we = (e) => {
|
|
116
116
|
const r = new URLSearchParams();
|
|
117
117
|
for (const [t, n] of Object.entries(e))
|
|
118
118
|
n !== void 0 && (Array.isArray(n) ? n.forEach((o) => r.append(`${t}[]`, `${o}`)) : r.append(t, `${n}`));
|
|
119
119
|
return r.toString();
|
|
120
|
-
},
|
|
120
|
+
}, re = (e = !1) => {
|
|
121
121
|
const [r, t] = b(e), n = f(() => t((l) => !l), []), o = f(() => t(!0), []), c = f(() => t(!1), []);
|
|
122
122
|
return [r, n, o, c];
|
|
123
|
-
},
|
|
123
|
+
}, Ne = (e = !1, r = 2e3, t = window.setTimeout, n = window.clearTimeout) => {
|
|
124
124
|
const [o, c] = b(e), l = C(e), a = C(), i = f(() => {
|
|
125
125
|
c(!l.current), a.current && n(a.current), a.current = t(() => c(l.current), r);
|
|
126
126
|
}, [n, r, t]);
|
|
127
127
|
return [o, i];
|
|
128
|
-
},
|
|
129
|
-
const { search: e } =
|
|
130
|
-
return
|
|
131
|
-
},
|
|
128
|
+
}, Ce = () => C(null), _e = () => {
|
|
129
|
+
const { search: e } = z();
|
|
130
|
+
return Q(() => ee(e), [e]);
|
|
131
|
+
}, te = ({
|
|
132
132
|
text: e,
|
|
133
133
|
disabled: r = !1,
|
|
134
134
|
className: t,
|
|
@@ -138,21 +138,21 @@ const v = () => {
|
|
|
138
138
|
end: l = !1,
|
|
139
139
|
minWidth: a,
|
|
140
140
|
inline: i,
|
|
141
|
-
size:
|
|
142
|
-
...
|
|
141
|
+
size: h,
|
|
142
|
+
...u
|
|
143
143
|
}) => {
|
|
144
|
-
const [L,
|
|
144
|
+
const [L, y] = re(), R = m("dropdown-btn__toggle", t, {
|
|
145
145
|
"btn-block": !i,
|
|
146
146
|
"dropdown-btn__toggle--with-caret": !c
|
|
147
|
-
}),
|
|
148
|
-
return /* @__PURE__ */ d(
|
|
149
|
-
/* @__PURE__ */ s(
|
|
150
|
-
/* @__PURE__ */ s(
|
|
147
|
+
}), x = { minWidth: a && `${a}px` };
|
|
148
|
+
return /* @__PURE__ */ d($, { isOpen: L, toggle: y, disabled: r, className: o, children: [
|
|
149
|
+
/* @__PURE__ */ s(T, { size: h, caret: !c, className: R, color: "primary", ...u, children: e }),
|
|
150
|
+
/* @__PURE__ */ s(O, { className: "w-100", end: l, style: x, children: n })
|
|
151
151
|
] });
|
|
152
|
-
},
|
|
153
|
-
|
|
152
|
+
}, ke = ({ children: e, minWidth: r, label: t = "Options" }) => /* @__PURE__ */ s(
|
|
153
|
+
te,
|
|
154
154
|
{
|
|
155
|
-
text: /* @__PURE__ */ s(g, { className: "px-1", icon:
|
|
155
|
+
text: /* @__PURE__ */ s(g, { className: "px-1", icon: E }),
|
|
156
156
|
"aria-label": t,
|
|
157
157
|
size: "sm",
|
|
158
158
|
minWidth: r,
|
|
@@ -161,31 +161,31 @@ const v = () => {
|
|
|
161
161
|
inline: !0,
|
|
162
162
|
children: e
|
|
163
163
|
}
|
|
164
|
-
),
|
|
165
|
-
if (!
|
|
164
|
+
), ne = ({ children: e, ...r }) => /* @__PURE__ */ s(G, { children: /* @__PURE__ */ s(U, { className: "nav-pills__nav-link", tag: J, ...r, children: e }) }), ve = ({ 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: V.map(e, (n) => {
|
|
165
|
+
if (!Y(n) || n.type !== ne)
|
|
166
166
|
throw new Error("Only NavPillItem children are allowed inside NavPills.");
|
|
167
167
|
return n;
|
|
168
|
-
}) }) }),
|
|
168
|
+
}) }) }), se = (e, r, t) => e !== r ? "ASC" : t ? {
|
|
169
169
|
ASC: "DESC",
|
|
170
170
|
DESC: void 0
|
|
171
|
-
}[t] : "ASC",
|
|
171
|
+
}[t] : "ASC", Te = (e, { field: r, dir: t }) => !r || !t ? e : e.sort((n, o) => {
|
|
172
172
|
const c = t === "ASC" ? 1 : -1, l = t === "ASC" ? -1 : 1;
|
|
173
173
|
return n[r] > o[r] ? c : l;
|
|
174
|
-
}),
|
|
174
|
+
}), Oe = (e) => e.dir ? `${e.field}-${e.dir}` : void 0, Se = (e) => {
|
|
175
175
|
const [r, t] = e.split("-");
|
|
176
176
|
return { field: r, dir: t };
|
|
177
|
-
},
|
|
177
|
+
}, Ae = (e) => {
|
|
178
178
|
const [r, t] = b(e), n = f((o, c) => t({ field: o, dir: c }), []);
|
|
179
179
|
return [r, n];
|
|
180
180
|
};
|
|
181
|
-
function
|
|
181
|
+
function Le({ items: e, order: r, onChange: t, isButton: n = !0, right: o = !1, prefixed: c = !0 }) {
|
|
182
182
|
const l = (a) => () => {
|
|
183
|
-
const i =
|
|
183
|
+
const i = se(a, r.field, r.dir);
|
|
184
184
|
t(i ? a : void 0, i);
|
|
185
185
|
};
|
|
186
186
|
return /* @__PURE__ */ d(q, { children: [
|
|
187
187
|
/* @__PURE__ */ d(
|
|
188
|
-
|
|
188
|
+
T,
|
|
189
189
|
{
|
|
190
190
|
caret: !0,
|
|
191
191
|
color: n ? "primary" : "link",
|
|
@@ -206,7 +206,7 @@ function xe({ items: e, order: r, onChange: t, isButton: n = !0, right: o = !1,
|
|
|
206
206
|
}
|
|
207
207
|
),
|
|
208
208
|
/* @__PURE__ */ d(
|
|
209
|
-
|
|
209
|
+
O,
|
|
210
210
|
{
|
|
211
211
|
end: o,
|
|
212
212
|
className: m("w-100", { "ordering-dropdown__menu--link": !n }),
|
|
@@ -216,7 +216,7 @@ function xe({ items: e, order: r, onChange: t, isButton: n = !0, right: o = !1,
|
|
|
216
216
|
r.field === a && /* @__PURE__ */ s(
|
|
217
217
|
g,
|
|
218
218
|
{
|
|
219
|
-
icon: r.dir === "ASC" ?
|
|
219
|
+
icon: r.dir === "ASC" ? P : F,
|
|
220
220
|
className: "ordering-dropdown__sort-icon"
|
|
221
221
|
}
|
|
222
222
|
)
|
|
@@ -228,48 +228,45 @@ function xe({ items: e, order: r, onChange: t, isButton: n = !0, right: o = !1,
|
|
|
228
228
|
)
|
|
229
229
|
] });
|
|
230
230
|
}
|
|
231
|
-
const
|
|
231
|
+
const ye = "#4696e5", Re = "rgba(70, 150, 229, 0.4)", xe = "#f77f28", Ie = "rgba(247, 127, 40, 0.4)", De = "white", Ee = "#161b22", Pe = (e) => {
|
|
232
232
|
var r;
|
|
233
233
|
return (r = document.querySelector("html")) == null ? void 0 : r.setAttribute("data-theme", e);
|
|
234
|
-
},
|
|
234
|
+
}, Fe = () => {
|
|
235
235
|
var e;
|
|
236
236
|
return ((e = document.querySelector("html")) == null ? void 0 : e.getAttribute("data-theme")) === "dark";
|
|
237
|
-
},
|
|
237
|
+
}, He = (e = window.matchMedia.bind(window)) => e("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
238
238
|
export {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
239
|
+
fe as Checkbox,
|
|
240
|
+
te as DropdownBtn,
|
|
241
|
+
xe as HIGHLIGHTED_COLOR,
|
|
242
|
+
Ie as HIGHLIGHTED_COLOR_ALPHA,
|
|
243
|
+
ge as InputFormGroup,
|
|
244
|
+
B as LabeledFormGroup,
|
|
245
|
+
ye as MAIN_COLOR,
|
|
246
|
+
Re as MAIN_COLOR_ALPHA,
|
|
247
247
|
he as Message,
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
Ce as
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
Te as useParsedQuery,
|
|
273
|
-
_e as useTimeoutToggle,
|
|
274
|
-
te as useToggle
|
|
248
|
+
ne as NavPillItem,
|
|
249
|
+
ve as NavPills,
|
|
250
|
+
Le as OrderingDropdown,
|
|
251
|
+
Ee as PRIMARY_DARK_COLOR,
|
|
252
|
+
De as PRIMARY_LIGHT_COLOR,
|
|
253
|
+
ue as Result,
|
|
254
|
+
ke as RowDropdownBtn,
|
|
255
|
+
be as SearchField,
|
|
256
|
+
Z as SimpleCard,
|
|
257
|
+
pe as ToggleSwitch,
|
|
258
|
+
Pe as changeThemeInMarkup,
|
|
259
|
+
se as determineOrderDir,
|
|
260
|
+
He as getSystemPreferredTheme,
|
|
261
|
+
Fe as isDarkThemeEnabled,
|
|
262
|
+
Oe as orderToString,
|
|
263
|
+
ee as parseQueryString,
|
|
264
|
+
Te as sortList,
|
|
265
|
+
Se as stringToOrder,
|
|
266
|
+
we as stringifyQueryParams,
|
|
267
|
+
Ce as useElementRef,
|
|
268
|
+
Ae as useOrder,
|
|
269
|
+
_e as useParsedQuery,
|
|
270
|
+
Ne as useTimeoutToggle,
|
|
271
|
+
re as useToggle
|
|
275
272
|
};
|
package/package.json
CHANGED
|
@@ -5,15 +5,8 @@
|
|
|
5
5
|
"repository": "https://github.com/shlinkio/shlink-frontend-kit",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
8
|
-
"main": "./dist/index.
|
|
9
|
-
"module": "./dist/index.js",
|
|
8
|
+
"main": "./dist/index.js",
|
|
10
9
|
"types": "./dist/index.d.ts",
|
|
11
|
-
"exports": {
|
|
12
|
-
".": {
|
|
13
|
-
"import": "./dist/index.js",
|
|
14
|
-
"require": "./dist/index.umd.cjs"
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
10
|
"files": [
|
|
18
11
|
"dist"
|
|
19
12
|
],
|
|
@@ -43,35 +36,35 @@
|
|
|
43
36
|
"reactstrap": "^9.2.0"
|
|
44
37
|
},
|
|
45
38
|
"devDependencies": {
|
|
46
|
-
"@shlinkio/eslint-config-js-coding-standard": "~3.
|
|
39
|
+
"@shlinkio/eslint-config-js-coding-standard": "~3.2.0",
|
|
47
40
|
"@shlinkio/stylelint-config-css-coding-standard": "~1.1.1",
|
|
48
|
-
"@stylistic/eslint-plugin": "^2.
|
|
41
|
+
"@stylistic/eslint-plugin": "^2.9.0",
|
|
49
42
|
"@testing-library/jest-dom": "^6.5.0",
|
|
50
43
|
"@testing-library/react": "^16.0.1",
|
|
51
44
|
"@testing-library/user-event": "^14.5.2",
|
|
52
45
|
"@total-typescript/shoehorn": "^0.1.2",
|
|
53
46
|
"@types/qs": "^6.9.16",
|
|
54
|
-
"@types/react": "^18.3.
|
|
55
|
-
"@types/react-dom": "^18.3.
|
|
47
|
+
"@types/react": "^18.3.11",
|
|
48
|
+
"@types/react-dom": "^18.3.1",
|
|
56
49
|
"@types/uuid": "^10.0.0",
|
|
57
|
-
"@vitejs/plugin-react": "^4.3.
|
|
58
|
-
"@vitest/coverage-v8": "^2.1.
|
|
59
|
-
"axe-core": "^4.10.
|
|
50
|
+
"@vitejs/plugin-react": "^4.3.2",
|
|
51
|
+
"@vitest/coverage-v8": "^2.1.3",
|
|
52
|
+
"axe-core": "^4.10.1",
|
|
60
53
|
"bootstrap": "5.2.3",
|
|
61
|
-
"eslint": "^
|
|
54
|
+
"eslint": "^9.13.0",
|
|
62
55
|
"eslint-plugin-jsx-a11y": "^6.10.0",
|
|
63
|
-
"eslint-plugin-react": "^7.37.
|
|
64
|
-
"eslint-plugin-react-hooks": "^
|
|
56
|
+
"eslint-plugin-react": "^7.37.1",
|
|
57
|
+
"eslint-plugin-react-hooks": "^5.0.0",
|
|
65
58
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
66
59
|
"history": "^5.3.0",
|
|
67
60
|
"jsdom": "^25.0.1",
|
|
68
61
|
"resize-observer-polyfill": "^1.5.1",
|
|
69
|
-
"sass": "^1.
|
|
62
|
+
"sass": "^1.80.3",
|
|
70
63
|
"stylelint": "^15.11.0",
|
|
71
|
-
"typescript": "^5.6.
|
|
72
|
-
"typescript-eslint": "^8.
|
|
73
|
-
"vite": "^5.4.
|
|
74
|
-
"vite-plugin-dts": "^4.2.
|
|
64
|
+
"typescript": "^5.6.3",
|
|
65
|
+
"typescript-eslint": "^8.10.0",
|
|
66
|
+
"vite": "^5.4.9",
|
|
67
|
+
"vite-plugin-dts": "^4.2.4",
|
|
75
68
|
"vitest": "^2.0.2"
|
|
76
69
|
},
|
|
77
70
|
"browserslist": [
|
|
@@ -80,5 +73,5 @@
|
|
|
80
73
|
"not ie <= 11",
|
|
81
74
|
"not op_mini all"
|
|
82
75
|
],
|
|
83
|
-
"version": "0.
|
|
76
|
+
"version": "0.6.0"
|
|
84
77
|
}
|
package/dist/index.umd.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
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")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@fortawesome/free-solid-svg-icons","@fortawesome/react-fontawesome","clsx","reactstrap","react","react-router-dom"],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))})(this,function(o,s,w,b,f,d,i,T){"use strict";const S=e=>({error:"border-danger",default:""})[e],v=e=>({error:"text-danger",default:"text-muted"})[e],P=({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:S(c),body:!0,children:s.jsxs("h3",{className:f.clsx("text-center mb-0",v(c)),children:[n&&s.jsx(b.FontAwesomeIcon,{icon:w.faCircleNotch,spin:!0}),n&&s.jsx("span",{className:"ms-2",children:r??"Loading..."}),!n&&r]})})})})},N=({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(N,{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})})}),O=({checked:e=!1,onChange:r,className:n,children:c,type:l,inline:a=!1})=>{const h=i.useId(),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:h,checked:e,onChange:t}),s.jsx("label",{className:"form-check-label",htmlFor:h,children:c})]})},F=e=>s.jsx(O,{type:"checkbox",...e}),H=e=>s.jsx(O,{type:"switch",...e}),A=({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]}),M=({children:e,value:r,onChange:n,type:c,required:l,placeholder:a,className:h,labelClassName:t})=>{const u=i.useId();return s.jsx(A,{label:s.jsxs(s.Fragment,{children:[e,":"]}),className:h,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)})})};let C;const I=()=>{C!==null&&clearTimeout(C),C=null},G=({onChange:e,className:r,large:n=!0,noBorder:c=!1,initialValue:l="",setTimeout_:a=setTimeout})=>{const[h,t]=i.useState(l),u=(m,g=500)=>{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:h,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:h==="",id:"search-field__close",onClick:()=>u("",0)})]})},_=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()},q=_,Q=k,p=(e=!1)=>{const[r,n]=i.useState(e),c=i.useCallback(()=>n(h=>!h),[]),l=i.useCallback(()=>n(!0),[]),a=i.useCallback(()=>n(!1),[]);return[r,c,l,a]},$=(e=!1,r=2e3,n=window.setTimeout,c=window.clearTimeout)=>{const[l,a]=i.useState(e),h=i.useRef(e),t=i.useRef(),u=i.useCallback(()=>{a(!h.current),t.current&&c(t.current),t.current=n(()=>a(h.current),r)},[c,r,n]);return[l,u]},U=()=>i.useId(),j=()=>i.useRef(null),V=()=>{const{search:e}=T.useLocation();return i.useMemo(()=>_(e),[e])},y=({text:e,disabled:r=!1,className:n,children:c,dropdownClassName:l,noCaret:a,end:h=!1,minWidth:t,inline:u,size:m,...g})=>{const[le,ae]=p(),te=f.clsx("dropdown-btn__toggle",n,{"btn-block":!u,"dropdown-btn__toggle--with-caret":!a}),de={minWidth:t&&`${t}px`};return s.jsxs(d.Dropdown,{isOpen:le,toggle:ae,disabled:r,className:l,children:[s.jsx(d.DropdownToggle,{size:m,caret:!a,className:te,color:"primary",...g,children:e}),s.jsx(d.DropdownMenu,{className:"w-100",end:h,style:de,children:c})]})},Y=({children:e,minWidth:r,label:n="Options"})=>s.jsx(y,{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}),L=({children:e,...r})=>s.jsx(d.NavItem,{children:s.jsx(d.NavLink,{className:"nav-pills__nav-link",tag:T.NavLink,...r,children:e})}),z=({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:i.Children.map(e,c=>{if(!i.isValidElement(c)||c.type!==L)throw new Error("Only NavPillItem children are allowed inside NavPills.");return c})})}),D=(e,r,n)=>e!==r?"ASC":n?{ASC:"DESC",DESC:void 0}[n]:"ASC",B=(e,{field:r,dir:n})=>!r||!n?e:e.sort((c,l)=>{const a=n==="ASC"?1:-1,h=n==="ASC"?-1:1;return c[r]>l[r]?a:h}),J=e=>e.dir?`${e.field}-${e.dir}`:void 0,W=e=>{const[r,n]=e.split("-");return{field:r,dir:n}},X=e=>{const[r,n]=i.useState(e),c=i.useCallback((l,a)=>n({field:l,dir:a}),[]);return[r,c]};function Z({items:e,order:r,onChange:n,isButton:c=!0,right:l=!1,prefixed:a=!0}){const h=t=>()=>{const u=D(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:h(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 K="#4696e5",R="rgba(70, 150, 229, 0.4)",x="#f77f28",ee="rgba(247, 127, 40, 0.4)",re="white",se="#161b22",ne=e=>{var r;return(r=document.querySelector("html"))==null?void 0:r.setAttribute("data-theme",e)},oe=()=>{var e;return((e=document.querySelector("html"))==null?void 0:e.getAttribute("data-theme"))==="dark"},ce=(e=window.matchMedia.bind(window))=>e("(prefers-color-scheme: dark)").matches?"dark":"light";o.Checkbox=F,o.DropdownBtn=y,o.HIGHLIGHTED_COLOR=x,o.HIGHLIGHTED_COLOR_ALPHA=ee,o.InputFormGroup=M,o.LabeledFormGroup=A,o.MAIN_COLOR=K,o.MAIN_COLOR_ALPHA=R,o.Message=P,o.NavPillItem=L,o.NavPills=z,o.OrderingDropdown=Z,o.PRIMARY_DARK_COLOR=se,o.PRIMARY_LIGHT_COLOR=re,o.Result=E,o.RowDropdownBtn=Y,o.SearchField=G,o.SimpleCard=N,o.ToggleSwitch=H,o.changeThemeInMarkup=ne,o.determineOrderDir=D,o.getSystemPreferredTheme=ce,o.isDarkThemeEnabled=oe,o.orderToString=J,o.parseQuery=q,o.parseQueryString=_,o.sortList=B,o.stringToOrder=W,o.stringifyQuery=Q,o.stringifyQueryParams=k,o.useDomId=U,o.useElementRef=j,o.useOrder=X,o.useParsedQuery=V,o.useTimeoutToggle=$,o.useToggle=p,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
|