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