@shlinkio/shlink-frontend-kit 0.8.3 → 0.8.5

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 CHANGED
@@ -16,6 +16,8 @@ declare type BooleanControlProps = PropsWithChildren<{
16
16
  inline?: boolean;
17
17
  }>;
18
18
 
19
+ export declare type Callback = () => unknown;
20
+
19
21
  export declare const changeThemeInMarkup: (theme: Theme) => void | undefined;
20
22
 
21
23
  export declare const Checkbox: FC<BooleanControlProps>;
@@ -191,7 +193,20 @@ export declare type Theme = 'dark' | 'light';
191
193
 
192
194
  export declare type TimeoutToggle = typeof useTimeoutToggle;
193
195
 
194
- declare type ToggleResult = [boolean, () => void, () => void, () => void];
196
+ export declare type TimeoutToggleOptions = {
197
+ /**
198
+ * What should the flag value be initially.
199
+ * This will drive the behavior of the callback, which will set the opposite value, and then go back to the initial
200
+ * value after a delay.
201
+ *
202
+ * Defaults to false.
203
+ */
204
+ initialValue?: boolean;
205
+ /** Delay in ms after which the flag should return to its initial value. Defaults to 2000 */
206
+ delay?: number;
207
+ };
208
+
209
+ export declare type ToggleResult = [boolean, () => void, () => void, () => void];
195
210
 
196
211
  export declare const ToggleSwitch: FC<BooleanControlProps>;
197
212
 
@@ -203,7 +218,26 @@ export declare const useParsedQuery: <T>() => T;
203
218
 
204
219
  export declare const useTheme: (initialTheme?: Theme) => readonly [Theme, Dispatch<SetStateAction<Theme>>];
205
220
 
206
- 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];
221
+ export declare function useTimeout(defaultDelay: number,
222
+ /** Test seam. Defaults to global setTimeout */
223
+ setTimeout_?: typeof globalThis.setTimeout,
224
+ /** Test seam. Defaults to global clearTimeout */
225
+ clearTimeout_?: typeof clearTimeout): UseTimeoutResult;
226
+
227
+ export declare type UseTimeoutResult = {
228
+ /**
229
+ * Clears any in-progress timeout, and schedules a new callback.
230
+ * It optionally allows a delay to be provided, or falls back to the default delay otherwise.
231
+ */
232
+ setTimeout: (callback: Callback, delay?: number) => void;
233
+ /** Clears any in-progress timeout */
234
+ clearCurrentTimeout: () => void;
235
+ };
236
+
237
+ /**
238
+ * Passing individual args is deprecated. Pass an object of options instead.
239
+ */
240
+ export declare const useTimeoutToggle: (initialValueOrOptions?: TimeoutToggleOptions | boolean, secondArg?: number, setTimeout_?: typeof setTimeout, clearTimeout_?: typeof clearTimeout) => [boolean, () => void];
207
241
 
208
242
  export declare const useToggle: (initialValue?: boolean) => ToggleResult;
209
243
 
package/dist/index.js CHANGED
@@ -1,20 +1,21 @@
1
- import { jsx as o, jsxs as d, Fragment as N } from "react/jsx-runtime";
2
- import { faCircleNotch as I, faSearch as A, faEllipsisV as E, faSortAmountUp as F, faSortAmountDown as P } from "@fortawesome/free-solid-svg-icons";
3
- import { FontAwesomeIcon as w } from "@fortawesome/react-fontawesome";
1
+ import { jsx as o, jsxs as m, Fragment as N } from "react/jsx-runtime";
2
+ import { faCircleNotch as A, faSearch as I, faEllipsisV as E, faSortAmountUp as F, faSortAmountDown as P } from "@fortawesome/free-solid-svg-icons";
3
+ import { FontAwesomeIcon as g } from "@fortawesome/react-fontawesome";
4
4
  import { clsx as u } from "clsx";
5
- import { Card as _, CardHeader as H, CardBody as M, Dropdown as $, DropdownToggle as k, DropdownMenu as S, NavItem as j, NavLink as G, Nav as U, UncontrolledDropdown as q, DropdownItem as g } from "reactstrap";
6
- import { useId as T, useState as p, useRef as C, useCallback as f, useMemo as Q, Children as V, isValidElement as Y, useEffect as W } from "react";
5
+ import { Card as C, CardHeader as H, CardBody as M, Dropdown as $, DropdownToggle as k, DropdownMenu as v, NavItem as j, NavLink as G, Nav as U, UncontrolledDropdown as V, DropdownItem as w } from "reactstrap";
6
+ import { useId as S, useState as p, useRef as y, useMemo as q, useCallback as f, Children as Q, isValidElement as Y, useEffect as W } from "react";
7
7
  import { useLocation as z, NavLink as J } from "react-router";
8
- const he = ({ className: e, children: r, loading: t = !1, type: n = "default", fullWidth: c = !1 }) => /* @__PURE__ */ o(
9
- _,
8
+ import { u as X } from "./use-timeout-BbfWTbuj.js";
9
+ const be = ({ className: e, children: t, loading: r = !1, type: n = "default", fullWidth: s = !1 }) => /* @__PURE__ */ o(
10
+ C,
10
11
  {
11
12
  body: !0,
12
13
  className: u(e, {
13
- "w-100": c,
14
- "w-75 mx-auto": !c,
14
+ "w-100": s,
15
+ "w-75 mx-auto": !s,
15
16
  "border-danger": n === "error"
16
17
  }),
17
- children: /* @__PURE__ */ d(
18
+ children: /* @__PURE__ */ m(
18
19
  "h3",
19
20
  {
20
21
  className: u("text-center mb-0", {
@@ -22,189 +23,192 @@ const he = ({ className: e, children: r, loading: t = !1, type: n = "default", f
22
23
  "text-danger": n === "error"
23
24
  }),
24
25
  children: [
25
- t && /* @__PURE__ */ o(w, { icon: I, spin: !0 }),
26
- t && /* @__PURE__ */ o("span", { className: "ms-2", children: r ?? "Loading..." }),
27
- !t && r
26
+ r && /* @__PURE__ */ o(g, { icon: A, spin: !0 }),
27
+ r && /* @__PURE__ */ o("span", { className: "ms-2", children: t ?? "Loading..." }),
28
+ !r && t
28
29
  ]
29
30
  }
30
31
  )
31
32
  }
32
- ), X = ({ title: e, children: r, bodyClassName: t, ...n }) => /* @__PURE__ */ d(_, { ...n, children: [
33
+ ), Z = ({ title: e, children: t, bodyClassName: r, ...n }) => /* @__PURE__ */ m(C, { ...n, children: [
33
34
  e && /* @__PURE__ */ o(H, { role: "heading", "aria-level": 4, children: e }),
34
- /* @__PURE__ */ o(M, { className: t, children: r })
35
- ] }), fe = ({ children: e, type: r, className: t, small: n = !1 }) => /* @__PURE__ */ o(
36
- X,
35
+ /* @__PURE__ */ o(M, { className: r, children: t })
36
+ ] }), ge = ({ children: e, type: t, className: r, small: n = !1 }) => /* @__PURE__ */ o(
37
+ Z,
37
38
  {
38
39
  role: "document",
39
40
  className: u("text-center", {
40
41
  "w-75 mx-auto": !n,
41
42
  "w-100": n,
42
- "bg-main": r === "success",
43
- "bg-danger": r === "error",
44
- "bg-warning": r === "warning",
45
- "text-white": r !== "warning"
46
- }, t),
43
+ "bg-main": t === "success",
44
+ "bg-danger": t === "error",
45
+ "bg-warning": t === "warning",
46
+ "text-white": t !== "warning"
47
+ }, r),
47
48
  bodyClassName: u({ "p-2": n }),
48
49
  children: e
49
50
  }
50
- ), x = ({ checked: e = !1, onChange: r, className: t, children: n, type: c, inline: s = !1 }) => {
51
- const l = T(), a = (h) => r == null ? void 0 : r(h.target.checked, h), i = {
52
- "form-switch": c === "switch",
53
- "form-checkbox": c === "checkbox"
54
- }, m = s ? { display: "inline-block" } : {};
55
- return /* @__PURE__ */ d("span", { className: u("form-check", i, t), style: m, children: [
56
- /* @__PURE__ */ o("input", { type: "checkbox", className: "form-check-input", id: l, checked: e, onChange: a }),
57
- /* @__PURE__ */ o("label", { className: "form-check-label", htmlFor: l, children: n })
51
+ ), O = ({ checked: e = !1, onChange: t, className: r, children: n, type: s, inline: c = !1 }) => {
52
+ const a = S(), l = (h) => t == null ? void 0 : t(h.target.checked, h), i = {
53
+ "form-switch": s === "switch",
54
+ "form-checkbox": s === "checkbox"
55
+ }, d = c ? { display: "inline-block" } : {};
56
+ return /* @__PURE__ */ m("span", { className: u("form-check", i, r), style: d, children: [
57
+ /* @__PURE__ */ o("input", { type: "checkbox", className: "form-check-input", id: a, checked: e, onChange: l }),
58
+ /* @__PURE__ */ o("label", { className: "form-check-label", htmlFor: a, children: n })
58
59
  ] });
59
- }, pe = (e) => /* @__PURE__ */ o(x, { type: "checkbox", ...e }), be = (e) => /* @__PURE__ */ o(x, { type: "switch", ...e }), Z = ({ children: e, label: r, className: t = "", labelClassName: n = "", noMargin: c = !1, id: s }) => /* @__PURE__ */ d("div", { className: `${t} ${c ? "" : "mb-3"}`, children: [
60
- /* @__PURE__ */ o("label", { className: `form-label ${n}`, htmlFor: s, children: r }),
60
+ }, we = (e) => /* @__PURE__ */ o(O, { type: "checkbox", ...e }), Ne = (e) => /* @__PURE__ */ o(O, { type: "switch", ...e }), B = ({ children: e, label: t, className: r = "", labelClassName: n = "", noMargin: s = !1, id: c }) => /* @__PURE__ */ m("div", { className: `${r} ${s ? "" : "mb-3"}`, children: [
61
+ /* @__PURE__ */ o("label", { className: `form-label ${n}`, htmlFor: c, children: t }),
61
62
  e
62
- ] }), we = ({ children: e, value: r, onChange: t, type: n, required: c, placeholder: s, className: l, labelClassName: a }) => {
63
- const i = T();
64
- return /* @__PURE__ */ o(Z, { label: /* @__PURE__ */ d(N, { children: [
63
+ ] }), Ce = ({ children: e, value: t, onChange: r, type: n, required: s, placeholder: c, className: a, labelClassName: l }) => {
64
+ const i = S();
65
+ return /* @__PURE__ */ o(B, { label: /* @__PURE__ */ m(N, { children: [
65
66
  e,
66
67
  ":"
67
- ] }), className: l, labelClassName: a, id: i, children: /* @__PURE__ */ o(
68
+ ] }), className: a, labelClassName: l, id: i, children: /* @__PURE__ */ o(
68
69
  "input",
69
70
  {
70
71
  id: i,
71
72
  className: "form-control",
72
73
  type: n ?? "text",
73
- value: r,
74
- required: c ?? !0,
75
- placeholder: s,
76
- onChange: (m) => t(m.target.value)
74
+ value: t,
75
+ required: s ?? !0,
76
+ placeholder: c,
77
+ onChange: (d) => r(d.target.value)
77
78
  }
78
79
  ) });
79
- }, B = 500;
80
+ }, K = 500;
80
81
  let b;
81
- const v = () => {
82
+ const _ = () => {
82
83
  b !== null && clearTimeout(b), b = null;
83
- }, ge = ({ onChange: e, className: r, large: t = !0, noBorder: n = !1, initialValue: c = "", setTimeout_: s = setTimeout }) => {
84
- const [l, a] = p(c), i = (m, h = B) => {
85
- a(m), v(), b = s(() => {
86
- e(m), v();
84
+ }, Te = ({ onChange: e, className: t, large: r = !0, noBorder: n = !1, initialValue: s = "", setTimeout_: c = setTimeout }) => {
85
+ const [a, l] = p(s), i = (d, h = K) => {
86
+ l(d), _(), b = c(() => {
87
+ e(d), _();
87
88
  }, h);
88
89
  };
89
- return /* @__PURE__ */ d("div", { className: u("search-field", r), children: [
90
+ return /* @__PURE__ */ m("div", { className: u("search-field", t), children: [
90
91
  /* @__PURE__ */ o(
91
92
  "input",
92
93
  {
93
94
  type: "text",
94
95
  className: u("form-control search-field__input", {
95
- "form-control-lg": t,
96
+ "form-control-lg": r,
96
97
  "search-field__input--no-border": n
97
98
  }),
98
99
  placeholder: "Search...",
99
- value: l,
100
- onChange: (m) => i(m.target.value)
100
+ value: a,
101
+ onChange: (d) => i(d.target.value)
101
102
  }
102
103
  ),
103
- /* @__PURE__ */ o(w, { icon: A, className: "search-field__icon" }),
104
+ /* @__PURE__ */ o(g, { icon: I, className: "search-field__icon" }),
104
105
  /* @__PURE__ */ o(
105
106
  "button",
106
107
  {
107
108
  "aria-label": "Clear search",
108
109
  type: "button",
109
110
  className: "close search-field__close btn-close",
110
- hidden: l === "",
111
+ hidden: a === "",
111
112
  id: "search-field__close",
112
113
  onClick: () => i("", 0)
113
114
  }
114
115
  )
115
116
  ] });
116
- }, K = (e) => {
117
- const r = new URLSearchParams(e), t = {};
118
- return r.forEach((n, c) => {
119
- if (c.endsWith("[]")) {
120
- const s = c.slice(0, -2);
121
- t[s] ?? (t[s] = []), t[s].push(n);
117
+ }, _e = () => y(null), ee = (e) => {
118
+ const t = new URLSearchParams(e), r = {};
119
+ return t.forEach((n, s) => {
120
+ if (s.endsWith("[]")) {
121
+ const c = s.slice(0, -2);
122
+ r[c] ?? (r[c] = []), r[c].push(n);
122
123
  } else
123
- t[c] = n;
124
- }), t;
125
- }, Ne = (e) => {
126
- const r = new URLSearchParams();
127
- for (const [t, n] of Object.entries(e))
128
- n !== void 0 && (Array.isArray(n) ? n.forEach((c) => r.append(`${t}[]`, `${c}`)) : r.append(t, `${n}`));
129
- return r.toString();
130
- }, ee = (e = !1) => {
131
- const [r, t] = p(e), n = f(() => t((l) => !l), []), c = f(() => t(!0), []), s = f(() => t(!1), []);
132
- return [r, n, c, s];
133
- }, Ce = (e = !1, r = 2e3, t = window.setTimeout, n = window.clearTimeout) => {
134
- const [c, s] = p(e), l = C(e), a = C(void 0), i = f(() => {
135
- s(!l.current), a.current && n(a.current), a.current = t(() => s(l.current), r);
136
- }, [n, r, t]);
137
- return [c, i];
138
- }, _e = () => C(null), Oe = () => {
124
+ r[s] = n;
125
+ }), r;
126
+ }, ke = (e) => {
127
+ const t = new URLSearchParams();
128
+ for (const [r, n] of Object.entries(e))
129
+ n !== void 0 && (Array.isArray(n) ? n.forEach((s) => t.append(`${r}[]`, `${s}`)) : t.append(r, `${n}`));
130
+ return t.toString();
131
+ }, ve = () => {
139
132
  const { search: e } = z();
140
- return Q(() => K(e), [e]);
141
- }, re = ({
133
+ return q(() => ee(e), [e]);
134
+ }, te = 2e3, Se = (e = {}, t, r = globalThis.setTimeout, n = globalThis.clearTimeout) => {
135
+ const { initialValue: s = !1, delay: c = te } = typeof e == "boolean" ? {
136
+ initialValue: e,
137
+ delay: t
138
+ } : e, { setTimeout: a } = X(c, r, n), [l, i] = p(s), d = y(s), h = f(() => {
139
+ i(!d.current), a(() => i(d.current));
140
+ }, [a]);
141
+ return [l, h];
142
+ }, re = (e = !1) => {
143
+ const [t, r] = p(e), n = f(() => r((a) => !a), []), s = f(() => r(!0), []), c = f(() => r(!1), []);
144
+ return [t, n, s, c];
145
+ }, ne = ({
142
146
  text: e,
143
- disabled: r = !1,
144
- className: t,
147
+ disabled: t = !1,
148
+ className: r,
145
149
  children: n,
146
- dropdownClassName: c,
147
- noCaret: s,
148
- end: l = !1,
149
- minWidth: a,
150
+ dropdownClassName: s,
151
+ noCaret: c,
152
+ end: a = !1,
153
+ minWidth: l,
150
154
  inline: i,
151
- size: m,
155
+ size: d,
152
156
  ...h
153
157
  }) => {
154
- const [y, L] = ee(), D = u("dropdown-btn__toggle", t, {
158
+ const [L, x] = re(), D = u("dropdown-btn__toggle", r, {
155
159
  "btn-block": !i,
156
- "dropdown-btn__toggle--with-caret": !s
157
- }), R = { minWidth: a && `${a}px` };
158
- return /* @__PURE__ */ d($, { isOpen: y, toggle: L, disabled: r, className: c, children: [
159
- /* @__PURE__ */ o(k, { size: m, caret: !s, className: D, color: "primary", ...h, children: e }),
160
- /* @__PURE__ */ o(S, { className: "w-100", end: l, style: R, children: n })
160
+ "dropdown-btn__toggle--with-caret": !c
161
+ }), R = { minWidth: l && `${l}px` };
162
+ return /* @__PURE__ */ m($, { isOpen: L, toggle: x, disabled: t, className: s, children: [
163
+ /* @__PURE__ */ o(k, { size: d, caret: !c, className: D, color: "primary", ...h, children: e }),
164
+ /* @__PURE__ */ o(v, { className: "w-100", end: a, style: R, children: n })
161
165
  ] });
162
- }, ve = ({ children: e, minWidth: r, label: t = "Options" }) => /* @__PURE__ */ o(
163
- re,
166
+ }, ye = ({ children: e, minWidth: t, label: r = "Options" }) => /* @__PURE__ */ o(
167
+ ne,
164
168
  {
165
- text: /* @__PURE__ */ o(w, { className: "px-1", icon: E }),
166
- "aria-label": t,
169
+ text: /* @__PURE__ */ o(g, { className: "px-1", icon: E }),
170
+ "aria-label": r,
167
171
  size: "sm",
168
- minWidth: r,
172
+ minWidth: t,
169
173
  end: !0,
170
174
  noCaret: !0,
171
175
  inline: !0,
172
176
  children: e
173
177
  }
174
- ), te = ({ children: e, ...r }) => /* @__PURE__ */ o(j, { children: /* @__PURE__ */ o(G, { className: "nav-pills__nav-link", tag: J, ...r, children: e }) }), ke = ({ children: e, fill: r = !1, className: t = "" }) => /* @__PURE__ */ o(_, { className: `nav-pills__nav p-0 overflow-hidden ${t}`, body: !0, children: /* @__PURE__ */ o(U, { pills: !0, fill: r, children: V.map(e, (n) => {
175
- if (!Y(n) || n.type !== te)
178
+ ), oe = ({ children: e, ...t }) => /* @__PURE__ */ o(j, { children: /* @__PURE__ */ o(G, { className: "nav-pills__nav-link", tag: J, ...t, children: e }) }), Oe = ({ children: e, fill: t = !1, className: r = "" }) => /* @__PURE__ */ o(C, { className: `nav-pills__nav p-0 overflow-hidden ${r}`, body: !0, children: /* @__PURE__ */ o(U, { pills: !0, fill: t, children: Q.map(e, (n) => {
179
+ if (!Y(n) || n.type !== oe)
176
180
  throw new Error("Only NavPillItem children are allowed inside NavPills.");
177
181
  return n;
178
182
  }) }) });
179
- function O(e, r, t) {
180
- return typeof e == "object" ? O(e.currentField, e.newField, e.currentOrderDir) : e !== r ? "ASC" : t ? {
183
+ function T(e, t, r) {
184
+ return typeof e == "object" ? T(e.currentField, e.newField, e.currentOrderDir) : e !== t ? "ASC" : r ? {
181
185
  ASC: "DESC",
182
186
  DESC: void 0
183
- }[t] : "ASC";
187
+ }[r] : "ASC";
184
188
  }
185
- function ne(e, r, t) {
186
- return typeof e == "object" ? ne(e.currentField, e.newField, e.currentOrderDir) : {
187
- field: r,
188
- dir: O(e, r, t)
189
+ function se(e, t, r) {
190
+ return typeof e == "object" ? se(e.currentField, e.newField, e.currentOrderDir) : {
191
+ field: t,
192
+ dir: T(e, t, r)
189
193
  };
190
194
  }
191
- const Se = (e, { field: r, dir: t }) => !r || !t ? e : e.sort((n, c) => {
192
- const s = t === "ASC" ? 1 : -1, l = t === "ASC" ? -1 : 1;
193
- return n[r] > c[r] ? s : l;
194
- }), Te = (e) => e.dir ? `${e.field}-${e.dir}` : void 0, xe = (e) => {
195
- const [r, t] = e.split("-");
196
- return { field: r, dir: t };
197
- }, ye = (e) => {
198
- const [r, t] = p(e), n = f((c, s) => t({ field: c, dir: s }), []);
199
- return [r, n];
195
+ const Le = (e, { field: t, dir: r }) => !t || !r ? e : e.sort((n, s) => {
196
+ const c = r === "ASC" ? 1 : -1, a = r === "ASC" ? -1 : 1;
197
+ return n[t] > s[t] ? c : a;
198
+ }), xe = (e) => e.dir ? `${e.field}-${e.dir}` : void 0, De = (e) => {
199
+ const [t, r] = e.split("-");
200
+ return { field: t, dir: r };
201
+ }, Re = (e) => {
202
+ const [t, r] = p(e), n = f((s, c) => r({ field: s, dir: c }), []);
203
+ return [t, n];
200
204
  };
201
- function Le({ items: e, order: r, onChange: t, isButton: n = !0, right: c = !1, prefixed: s = !0 }) {
202
- const l = (a) => () => {
203
- const i = O(a, r.field, r.dir);
204
- t(i ? a : void 0, i);
205
+ function Ae({ items: e, order: t, onChange: r, isButton: n = !0, right: s = !1, prefixed: c = !0 }) {
206
+ const a = (l) => () => {
207
+ const i = T(l, t.field, t.dir);
208
+ r(i ? l : void 0, i);
205
209
  };
206
- return /* @__PURE__ */ d(q, { children: [
207
- /* @__PURE__ */ d(
210
+ return /* @__PURE__ */ m(V, { children: [
211
+ /* @__PURE__ */ m(
208
212
  k,
209
213
  {
210
214
  caret: !0,
@@ -215,81 +219,82 @@ function Le({ items: e, order: r, onChange: t, isButton: n = !0, right: c = !1,
215
219
  }),
216
220
  children: [
217
221
  !n && /* @__PURE__ */ o(N, { children: "Order by" }),
218
- n && !r.field && /* @__PURE__ */ o("i", { children: "Order by..." }),
219
- n && r.field && /* @__PURE__ */ d(N, { children: [
220
- s && "Order by: ",
221
- e[r.field],
222
+ n && !t.field && /* @__PURE__ */ o("i", { children: "Order by..." }),
223
+ n && t.field && /* @__PURE__ */ m(N, { children: [
224
+ c && "Order by: ",
225
+ e[t.field],
222
226
  " - ",
223
- /* @__PURE__ */ o("small", { children: r.dir ?? "DESC" })
227
+ /* @__PURE__ */ o("small", { children: t.dir ?? "DESC" })
224
228
  ] })
225
229
  ]
226
230
  }
227
231
  ),
228
- /* @__PURE__ */ d(S, { end: c, className: "w-100", style: n ? void 0 : { minWidth: "11rem" }, children: [
229
- Object.entries(e).map(([a, i]) => /* @__PURE__ */ d(
230
- g,
232
+ /* @__PURE__ */ m(v, { end: s, className: "w-100", style: n ? void 0 : { minWidth: "11rem" }, children: [
233
+ Object.entries(e).map(([l, i]) => /* @__PURE__ */ m(
234
+ w,
231
235
  {
232
- active: r.field === a,
233
- onClick: l(a),
236
+ active: t.field === l,
237
+ onClick: a(l),
234
238
  className: "d-flex justify-content-between align-items-center",
235
239
  children: [
236
240
  i,
237
- r.field === a && /* @__PURE__ */ o(w, { icon: r.dir === "ASC" ? F : P })
241
+ t.field === l && /* @__PURE__ */ o(g, { icon: t.dir === "ASC" ? F : P })
238
242
  ]
239
243
  },
240
- a
244
+ l
241
245
  )),
242
- /* @__PURE__ */ o(g, { divider: !0 }),
243
- /* @__PURE__ */ o(g, { disabled: !r.field, onClick: () => t(), children: /* @__PURE__ */ o("i", { children: "Clear selection" }) })
246
+ /* @__PURE__ */ o(w, { divider: !0 }),
247
+ /* @__PURE__ */ o(w, { disabled: !t.field, onClick: () => r(), children: /* @__PURE__ */ o("i", { children: "Clear selection" }) })
244
248
  ] })
245
249
  ] });
246
250
  }
247
- const De = "#4696e5", Re = "rgba(70, 150, 229, 0.4)", Ie = "#f77f28", Ae = "rgba(247, 127, 40, 0.4)", Ee = "white", Fe = "#161b22", oe = (e) => {
248
- var r;
249
- return (r = document.querySelector("html")) == null ? void 0 : r.setAttribute("data-theme", e);
250
- }, Pe = () => {
251
+ const Ie = "#4696e5", Ee = "rgba(70, 150, 229, 0.4)", Fe = "#f77f28", Pe = "rgba(247, 127, 40, 0.4)", He = "white", Me = "#161b22", ce = (e) => {
252
+ var t;
253
+ return (t = document.querySelector("html")) == null ? void 0 : t.setAttribute("data-theme", e);
254
+ }, $e = () => {
251
255
  var e;
252
256
  return ((e = document.querySelector("html")) == null ? void 0 : e.getAttribute("data-theme")) === "dark";
253
- }, ce = (e = window.matchMedia.bind(window)) => e("(prefers-color-scheme: dark)").matches ? "dark" : "light", He = (e) => {
254
- const [r, t] = p(() => e ?? ce());
257
+ }, ae = (e = window.matchMedia.bind(window)) => e("(prefers-color-scheme: dark)").matches ? "dark" : "light", je = (e) => {
258
+ const [t, r] = p(() => e ?? ae());
255
259
  return W(() => {
256
- oe(r);
257
- }, [r]), [r, t];
260
+ ce(t);
261
+ }, [t]), [t, r];
258
262
  };
259
263
  export {
260
- pe as Checkbox,
261
- re as DropdownBtn,
262
- Ie as HIGHLIGHTED_COLOR,
263
- Ae as HIGHLIGHTED_COLOR_ALPHA,
264
- we as InputFormGroup,
265
- Z as LabeledFormGroup,
266
- De as MAIN_COLOR,
267
- Re as MAIN_COLOR_ALPHA,
268
- he as Message,
269
- te as NavPillItem,
270
- ke as NavPills,
271
- Le as OrderingDropdown,
272
- Fe as PRIMARY_DARK_COLOR,
273
- Ee as PRIMARY_LIGHT_COLOR,
274
- fe as Result,
275
- ve as RowDropdownBtn,
276
- ge as SearchField,
277
- X as SimpleCard,
278
- be as ToggleSwitch,
279
- oe as changeThemeInMarkup,
280
- ne as determineOrder,
281
- O as determineOrderDir,
282
- ce as getSystemPreferredTheme,
283
- Pe as isDarkThemeEnabled,
284
- Te as orderToString,
285
- K as parseQueryString,
286
- Se as sortList,
287
- xe as stringToOrder,
288
- Ne as stringifyQueryParams,
264
+ we as Checkbox,
265
+ ne as DropdownBtn,
266
+ Fe as HIGHLIGHTED_COLOR,
267
+ Pe as HIGHLIGHTED_COLOR_ALPHA,
268
+ Ce as InputFormGroup,
269
+ B as LabeledFormGroup,
270
+ Ie as MAIN_COLOR,
271
+ Ee as MAIN_COLOR_ALPHA,
272
+ be as Message,
273
+ oe as NavPillItem,
274
+ Oe as NavPills,
275
+ Ae as OrderingDropdown,
276
+ Me as PRIMARY_DARK_COLOR,
277
+ He as PRIMARY_LIGHT_COLOR,
278
+ ge as Result,
279
+ ye as RowDropdownBtn,
280
+ Te as SearchField,
281
+ Z as SimpleCard,
282
+ Ne as ToggleSwitch,
283
+ ce as changeThemeInMarkup,
284
+ se as determineOrder,
285
+ T as determineOrderDir,
286
+ ae as getSystemPreferredTheme,
287
+ $e as isDarkThemeEnabled,
288
+ xe as orderToString,
289
+ ee as parseQueryString,
290
+ Le as sortList,
291
+ De as stringToOrder,
292
+ ke as stringifyQueryParams,
289
293
  _e as useElementRef,
290
- ye as useOrder,
291
- Oe as useParsedQuery,
292
- He as useTheme,
293
- Ce as useTimeoutToggle,
294
- ee as useToggle
294
+ Re as useOrder,
295
+ ve as useParsedQuery,
296
+ je as useTheme,
297
+ X as useTimeout,
298
+ Se as useTimeoutToggle,
299
+ re as useToggle
295
300
  };
@@ -26,8 +26,6 @@ export declare type ButtonProps = PropsWithChildren<{
26
26
  solid?: boolean;
27
27
  } & (RegularButtonProps | LinkButtonProps_2)>;
28
28
 
29
- export declare type Callback = () => unknown;
30
-
31
29
  export declare const Card: FC<CardProps> & {
32
30
  Body: FC<CardProps>;
33
31
  Header: FC<CardProps>;
@@ -84,6 +82,8 @@ export declare const ELLIPSIS = "...";
84
82
 
85
83
  declare type Ellipsis = typeof ELLIPSIS;
86
84
 
85
+ export declare type ExitAction = 'confirm' | 'cancel';
86
+
87
87
  export declare const formatNumber: (number: number | string) => string;
88
88
 
89
89
  export declare const Input: FC<InputProps>;
@@ -191,7 +191,9 @@ declare type RegularCardModalProps = CommonCardModalProps & {
191
191
  /** Determines the horizontal size of the dialog */
192
192
  size?: Size | 'xl';
193
193
  /** Value to display in confirm button. Defaults to 'Confirm' */
194
- confirmText?: string;
194
+ confirmText?: ReactNode;
195
+ /** Value to display in cancel button. Defaults to 'Cancel' */
196
+ cancelText?: ReactNode;
195
197
  /** Whether the confirm button is disabled or not */
196
198
  confirmDisabled?: boolean;
197
199
  /**
@@ -199,6 +201,8 @@ declare type RegularCardModalProps = CommonCardModalProps & {
199
201
  * Invoked when the confirm button is actioned.
200
202
  */
201
203
  onConfirm?: () => void;
204
+ /** Invoked after finishing the close transition */
205
+ onClosed?: (exitAction: ExitAction) => void;
202
206
  };
203
207
 
204
208
  export declare type RequiredReactNode = Exclude<ReactNode, undefined | null>;
@@ -268,20 +272,4 @@ export declare const ToggleSwitch: FC<ToggleSwitchProps>;
268
272
 
269
273
  export declare type ToggleSwitchProps = BooleanControlProps;
270
274
 
271
- export declare function useTimeout(defaultDelay: number,
272
- /** Test seam. Defaults to global setTimeout */
273
- setTimeout_?: typeof globalThis.setTimeout,
274
- /** Test seam. Defaults to global clearTimeout */
275
- clearTimeout_?: typeof clearTimeout): UseTimeoutResult;
276
-
277
- export declare type UseTimeoutResult = {
278
- /**
279
- * Clears any in-progress timeout, and schedules a new callback.
280
- * It optionally allows a delay to be provided, or falls back to the default delay otherwise.
281
- */
282
- setTimeout: (callback: Callback, delay?: number) => void;
283
- /** Clears any in-progress timeout */
284
- clearCurrentTimeout: () => void;
285
- };
286
-
287
275
  export { }
package/dist/tailwind.js CHANGED
@@ -1,12 +1,14 @@
1
- import { jsx as n, jsxs as i, Fragment as B } from "react/jsx-runtime";
2
- import s, { clsx as f } from "clsx";
3
- import { createContext as F, useContext as g, useCallback as N, useId as $, useRef as R, useEffect as T, useMemo as E, useState as Q } from "react";
4
- import { Link as U, NavLink as V } from "react-router";
5
- import { faClose as X, faSearch as Y, faChevronLeft as j, faChevronRight as D, faCircleNotch as Z } from "@fortawesome/free-solid-svg-icons";
6
- import { FontAwesomeIcon as b } from "@fortawesome/react-fontawesome";
7
- const v = F(void 0), x = F({ responsive: !0 }), tt = ({ children: t, className: e }) => {
8
- const { responsive: r } = g(x);
9
- return /* @__PURE__ */ n(v.Provider, { value: { section: "head" }, children: /* @__PURE__ */ n(
1
+ import { jsx as n, jsxs as i, Fragment as S } from "react/jsx-runtime";
2
+ import s, { clsx as x } from "clsx";
3
+ import { createContext as M, useContext as g, useCallback as L, useId as U, useMemo as z, useRef as _, useEffect as F, useState as et } from "react";
4
+ import { Link as W, NavLink as rt } from "react-router";
5
+ import { faClose as ot, faSearch as nt, faChevronLeft as H, faChevronRight as O, faCircleNotch as dt } from "@fortawesome/free-solid-svg-icons";
6
+ import { FontAwesomeIcon as p } from "@fortawesome/react-fontawesome";
7
+ import { createPortal as lt } from "react-dom";
8
+ import { u as at } from "./use-timeout-BbfWTbuj.js";
9
+ const N = M(void 0), y = M({ responsive: !0 }), st = ({ children: t, className: e }) => {
10
+ const { responsive: r } = g(y);
11
+ return /* @__PURE__ */ n(N.Provider, { value: { section: "head" }, children: /* @__PURE__ */ n(
10
12
  "thead",
11
13
  {
12
14
  className: s(
@@ -16,9 +18,9 @@ const v = F(void 0), x = F({ responsive: !0 }), tt = ({ children: t, className:
16
18
  children: t
17
19
  }
18
20
  ) });
19
- }, et = ({ children: t, className: e }) => {
20
- const { responsive: r } = g(x);
21
- return /* @__PURE__ */ n(v.Provider, { value: { section: "body" }, children: /* @__PURE__ */ n(
21
+ }, wt = ({ children: t, className: e }) => {
22
+ const { responsive: r } = g(y);
23
+ return /* @__PURE__ */ n(N.Provider, { value: { section: "body" }, children: /* @__PURE__ */ n(
22
24
  "tbody",
23
25
  {
24
26
  className: s(
@@ -28,9 +30,9 @@ const v = F(void 0), x = F({ responsive: !0 }), tt = ({ children: t, className:
28
30
  children: t
29
31
  }
30
32
  ) });
31
- }, rt = ({ children: t, className: e }) => {
32
- const { responsive: r } = g(x);
33
- return /* @__PURE__ */ n(v.Provider, { value: { section: "footer" }, children: /* @__PURE__ */ n(
33
+ }, it = ({ children: t, className: e }) => {
34
+ const { responsive: r } = g(y);
35
+ return /* @__PURE__ */ n(N.Provider, { value: { section: "footer" }, children: /* @__PURE__ */ n(
34
36
  "tfoot",
35
37
  {
36
38
  className: s(
@@ -40,8 +42,8 @@ const v = F(void 0), x = F({ responsive: !0 }), tt = ({ children: t, className:
40
42
  children: t
41
43
  }
42
44
  ) });
43
- }, ot = ({ children: t, className: e, ...r }) => {
44
- const o = g(v), d = (o == null ? void 0 : o.section) === "body", { responsive: a } = g(x);
45
+ }, ct = ({ children: t, className: e, ...r }) => {
46
+ const o = g(N), d = (o == null ? void 0 : o.section) === "body", { responsive: a } = g(y);
45
47
  return /* @__PURE__ */ n(
46
48
  "tr",
47
49
  {
@@ -60,8 +62,8 @@ const v = F(void 0), x = F({ responsive: !0 }), tt = ({ children: t, className:
60
62
  children: t
61
63
  }
62
64
  );
63
- }, nt = ({ children: t, className: e, columnName: r, type: o, ...d }) => {
64
- const a = g(v), l = o ?? ((a == null ? void 0 : a.section) !== "body" ? "th" : "td"), { responsive: w } = g(x);
65
+ }, mt = ({ children: t, className: e, columnName: r, type: o, ...d }) => {
66
+ const a = g(N), l = o ?? ((a == null ? void 0 : a.section) !== "body" ? "th" : "td"), { responsive: w } = g(y);
65
67
  return /* @__PURE__ */ n(
66
68
  l,
67
69
  {
@@ -80,11 +82,11 @@ const v = F(void 0), x = F({ responsive: !0 }), tt = ({ children: t, className:
80
82
  children: t
81
83
  }
82
84
  );
83
- }, dt = ({ header: t, footer: e, children: r, responsive: o = !0, ...d }) => /* @__PURE__ */ n(x.Provider, { value: { responsive: o }, children: /* @__PURE__ */ i("table", { className: "tw:w-full", ...d, children: [
84
- /* @__PURE__ */ n(tt, { children: t }),
85
- /* @__PURE__ */ n(et, { children: r }),
86
- e && /* @__PURE__ */ n(rt, { children: e })
87
- ] }) }), Rt = Object.assign(dt, { Row: ot, Cell: nt }), lt = ({
85
+ }, gt = ({ header: t, footer: e, children: r, responsive: o = !0, ...d }) => /* @__PURE__ */ n(y.Provider, { value: { responsive: o }, children: /* @__PURE__ */ i("table", { className: "tw:w-full", ...d, children: [
86
+ /* @__PURE__ */ n(st, { children: t }),
87
+ /* @__PURE__ */ n(wt, { children: r }),
88
+ e && /* @__PURE__ */ n(it, { children: e })
89
+ ] }) }), At = Object.assign(gt, { Row: ct, Cell: mt }), bt = ({
88
90
  children: t,
89
91
  className: e,
90
92
  disabled: r,
@@ -94,7 +96,7 @@ const v = F(void 0), x = F({ responsive: !0 }), tt = ({ children: t, className:
94
96
  solid: l = !1,
95
97
  ...w
96
98
  }) => {
97
- const c = "to" in w ? U : "button";
99
+ const c = "to" in w ? W : "button";
98
100
  return (
99
101
  // @ts-expect-error We are explicitly checking for the `to` prop before using Link
100
102
  /* @__PURE__ */ n(
@@ -150,13 +152,13 @@ const v = F(void 0), x = F({ responsive: !0 }), tt = ({ children: t, className:
150
152
  }
151
153
  )
152
154
  );
153
- }, z = ({ className: t, onChange: e, ...r }) => {
154
- const o = N((d) => e == null ? void 0 : e(d.target.checked, d), [e]);
155
+ }, q = ({ className: t, onChange: e, ...r }) => {
156
+ const o = L((d) => e == null ? void 0 : e(d.target.checked, d), [e]);
155
157
  return /* @__PURE__ */ n(
156
158
  "input",
157
159
  {
158
160
  type: "checkbox",
159
- className: f(
161
+ className: x(
160
162
  "tw:appearance-none tw:focus-ring",
161
163
  "tw:border-1 tw:border-lm-input-border tw:dark:border-dm-input-border",
162
164
  "tw:bg-lm-primary tw:dark:bg-dm-primary tw:checked:bg-brand tw:bg-no-repeat",
@@ -168,13 +170,13 @@ const v = F(void 0), x = F({ responsive: !0 }), tt = ({ children: t, className:
168
170
  ...r
169
171
  }
170
172
  );
171
- }, Et = ({ className: t, ...e }) => /* @__PURE__ */ n(
172
- z,
173
+ }, Ut = ({ className: t, ...e }) => /* @__PURE__ */ n(
174
+ q,
173
175
  {
174
- className: f("tw:rounded-sm tw:w-4 tw:h-4 tw:checked:bg-(image:--tick) tw:bg-center", t),
176
+ className: x("tw:rounded-sm tw:w-4 tw:h-4 tw:checked:bg-(image:--tick) tw:bg-center", t),
175
177
  ...e
176
178
  }
177
- ), H = ({ onClick: t, label: e = "Close" }) => /* @__PURE__ */ n(
179
+ ), $ = ({ onClick: t, label: e = "Close" }) => /* @__PURE__ */ n(
178
180
  "button",
179
181
  {
180
182
  onClick: t,
@@ -183,9 +185,9 @@ const v = F(void 0), x = F({ responsive: !0 }), tt = ({ children: t, className:
183
185
  "tw:rounded-md tw:focus-ring"
184
186
  ),
185
187
  "aria-label": e,
186
- children: /* @__PURE__ */ n(b, { icon: X, size: "xl" })
188
+ children: /* @__PURE__ */ n(p, { icon: ot, size: "xl" })
187
189
  }
188
- ), A = ({
190
+ ), G = ({
189
191
  borderless: t = !1,
190
192
  size: e = "md",
191
193
  feedback: r,
@@ -225,15 +227,15 @@ const v = F(void 0), x = F({ responsive: !0 }), tt = ({ children: t, className:
225
227
  ...l
226
228
  }
227
229
  );
228
- }, W = ({ required: t, children: e, ...r }) => /* @__PURE__ */ i("label", { ...r, children: [
230
+ }, J = ({ required: t, children: e, ...r }) => /* @__PURE__ */ i("label", { ...r, children: [
229
231
  e,
230
232
  t && /* @__PURE__ */ n("span", { className: "tw:text-danger tw:ml-1", "data-testid": "required-indicator", children: "*" })
231
- ] }), Mt = ({ label: t, inputClassName: e, required: r, hiddenRequired: o, error: d, ...a }) => {
232
- const l = $();
233
+ ] }), zt = ({ label: t, inputClassName: e, required: r, hiddenRequired: o, error: d, ...a }) => {
234
+ const l = U();
233
235
  return /* @__PURE__ */ i("div", { className: "tw:flex tw:flex-col tw:gap-1", children: [
234
- /* @__PURE__ */ n(W, { htmlFor: l, required: r, children: t }),
236
+ /* @__PURE__ */ n(J, { htmlFor: l, required: r, children: t }),
235
237
  /* @__PURE__ */ n(
236
- A,
238
+ G,
237
239
  {
238
240
  id: l,
239
241
  className: e,
@@ -244,7 +246,7 @@ const v = F(void 0), x = F({ responsive: !0 }), tt = ({ children: t, className:
244
246
  ),
245
247
  d && /* @__PURE__ */ n("span", { className: "tw:text-danger", children: d })
246
248
  ] });
247
- }, at = ({
249
+ }, ut = ({
248
250
  className: t,
249
251
  size: e = "md",
250
252
  feedback: r,
@@ -283,27 +285,13 @@ const v = F(void 0), x = F({ responsive: !0 }), tt = ({ children: t, className:
283
285
  disabled: d,
284
286
  ...a
285
287
  }
286
- ), _t = ({ selectClassName: t, label: e, required: r, hiddenRequired: o, ...d }) => {
287
- const a = $();
288
+ ), Wt = ({ selectClassName: t, label: e, required: r, hiddenRequired: o, ...d }) => {
289
+ const a = U();
288
290
  return /* @__PURE__ */ i("div", { className: "tw:flex tw:flex-col tw:gap-1", children: [
289
- /* @__PURE__ */ n(W, { htmlFor: a, required: r, children: e }),
290
- /* @__PURE__ */ n(at, { id: a, className: t, required: r || o, ...d })
291
+ /* @__PURE__ */ n(J, { htmlFor: a, required: r, children: e }),
292
+ /* @__PURE__ */ n(ut, { id: a, className: t, required: r || o, ...d })
291
293
  ] });
292
- };
293
- function st(t, e = globalThis.setTimeout.bind(globalThis), r = globalThis.clearTimeout.bind(globalThis)) {
294
- const o = R(null), d = N(() => {
295
- o.current && r(o.current);
296
- }, [r]), a = N((l, w) => {
297
- d(), o.current = e(() => {
298
- l(), o.current = null;
299
- }, w ?? t);
300
- }, [d, t, e]);
301
- return T(() => d, [d]), E(
302
- () => ({ setTimeout: a, clearCurrentTimeout: d }),
303
- [d, a]
304
- );
305
- }
306
- const jt = ({
294
+ }, qt = ({
307
295
  onChange: t,
308
296
  containerClassName: e,
309
297
  inputClassName: r,
@@ -311,14 +299,14 @@ const jt = ({
311
299
  size: o = "lg",
312
300
  ...d
313
301
  }) => {
314
- const { setTimeout: a, clearCurrentTimeout: l } = st(500), w = N((c) => {
302
+ const { setTimeout: a, clearCurrentTimeout: l } = at(500), w = L((c) => {
315
303
  c ? a(() => t(c)) : (l(), t(c));
316
304
  }, [l, t, a]);
317
305
  return /* @__PURE__ */ i("div", { className: s("tw:group tw:relative tw:focus-within:z-10", e), children: [
318
306
  /* @__PURE__ */ n(
319
- b,
307
+ p,
320
308
  {
321
- icon: Y,
309
+ icon: nt,
322
310
  className: s(
323
311
  "tw:absolute tw:top-[50%] tw:translate-y-[-50%] tw:transition-colors",
324
312
  "tw:text-placeholder tw:group-focus-within:text-lm-text tw:dark:group-focus-within:text-dm-text",
@@ -330,7 +318,7 @@ const jt = ({
330
318
  }
331
319
  ),
332
320
  /* @__PURE__ */ n(
333
- A,
321
+ G,
334
322
  {
335
323
  type: "search",
336
324
  className: s(
@@ -347,10 +335,10 @@ const jt = ({
347
335
  }
348
336
  )
349
337
  ] });
350
- }, Dt = ({ className: t, ...e }) => /* @__PURE__ */ n(
351
- z,
338
+ }, Gt = ({ className: t, ...e }) => /* @__PURE__ */ n(
339
+ q,
352
340
  {
353
- className: f(
341
+ className: x(
354
342
  "tw:rounded-full tw:w-8 tw:h-4",
355
343
  "tw:bg-(image:--circle-grey-dark) tw:dark:bg-(image:--circle-grey-light) tw:checked:bg-(image:--circle-white)",
356
344
  "tw:focus-visible:not-checked:bg-(image:--circle-light-blue)",
@@ -359,7 +347,7 @@ const jt = ({
359
347
  ),
360
348
  ...e
361
349
  }
362
- ), wt = ({ className: t, disabled: e, size: r = "md", ...o }) => /* @__PURE__ */ n(
350
+ ), pt = ({ className: t, disabled: e, size: r = "md", ...o }) => /* @__PURE__ */ n(
363
351
  "button",
364
352
  {
365
353
  className: s(
@@ -376,7 +364,7 @@ const jt = ({
376
364
  disabled: e,
377
365
  ...o
378
366
  }
379
- ), it = ({ className: t, ...e }) => /* @__PURE__ */ n(
367
+ ), ht = ({ className: t, ...e }) => /* @__PURE__ */ n(
380
368
  "div",
381
369
  {
382
370
  className: s(
@@ -386,7 +374,7 @@ const jt = ({
386
374
  ),
387
375
  ...e
388
376
  }
389
- ), ct = ({ className: t, ...e }) => /* @__PURE__ */ n(
377
+ ), ft = ({ className: t, ...e }) => /* @__PURE__ */ n(
390
378
  "div",
391
379
  {
392
380
  className: s(
@@ -396,7 +384,7 @@ const jt = ({
396
384
  ),
397
385
  ...e
398
386
  }
399
- ), mt = ({ className: t, ...e }) => /* @__PURE__ */ n(
387
+ ), xt = ({ className: t, ...e }) => /* @__PURE__ */ n(
400
388
  "div",
401
389
  {
402
390
  className: s(
@@ -406,7 +394,7 @@ const jt = ({
406
394
  ),
407
395
  ...e
408
396
  }
409
- ), gt = ({ className: t, ...e }) => /* @__PURE__ */ n(
397
+ ), yt = ({ className: t, ...e }) => /* @__PURE__ */ n(
410
398
  "div",
411
399
  {
412
400
  className: s(
@@ -416,7 +404,7 @@ const jt = ({
416
404
  ),
417
405
  ...e
418
406
  }
419
- ), m = Object.assign(gt, { Body: ct, Header: it, Footer: mt }), bt = ({ bodyClassName: t, children: e, ...r }) => {
407
+ ), m = Object.assign(yt, { Body: ft, Header: ht, Footer: xt }), kt = ({ bodyClassName: t, children: e, ...r }) => {
420
408
  const { title: o, titleSize: d = "md", ...a } = "title" in r ? r : {
421
409
  ...r,
422
410
  title: void 0,
@@ -430,10 +418,10 @@ const jt = ({
430
418
  ] }),
431
419
  /* @__PURE__ */ n(m.Body, { className: t, children: e })
432
420
  ] });
433
- }, q = F(null), ut = ({ className: t, to: e, ...r }) => {
434
- const o = g(q);
421
+ }, K = M(null), Nt = ({ className: t, to: e, ...r }) => {
422
+ const o = g(K);
435
423
  return /* @__PURE__ */ n(
436
- V,
424
+ rt,
437
425
  {
438
426
  role: "menuitem",
439
427
  to: e,
@@ -451,83 +439,86 @@ const jt = ({
451
439
  ...r
452
440
  }
453
441
  );
454
- }, ht = ({ children: t, className: e, fill: r }) => /* @__PURE__ */ n(q.Provider, { value: { fill: r }, children: /* @__PURE__ */ n(m, { role: "menubar", className: s("tw:flex tw:overflow-hidden", e), children: t }) }), Ht = Object.assign(ht, { Pill: ut }), pt = new Intl.NumberFormat("en-US"), ft = (t) => pt.format(Number(t)), O = 10, Ot = (t) => Math.ceil(t / O) * O, p = 2, I = "...", xt = (t, e) => Array.from({ length: e - t }, (r, o) => t + o), yt = (t, e) => {
455
- const r = xt(
456
- Math.max(p, t - p),
457
- Math.min(e - 1, t + p) + 1
442
+ }, vt = ({ children: t, className: e, fill: r }) => /* @__PURE__ */ n(K.Provider, { value: { fill: r }, children: /* @__PURE__ */ n(m, { role: "menubar", className: s("tw:flex tw:overflow-hidden", e), children: t }) }), Jt = Object.assign(vt, { Pill: Nt }), Pt = new Intl.NumberFormat("en-US"), Ct = (t) => Pt.format(Number(t)), A = 10, Kt = (t) => Math.ceil(t / A) * A, f = 2, I = "...", Tt = (t, e) => Array.from({ length: e - t }, (r, o) => t + o), It = (t, e) => {
443
+ const r = Tt(
444
+ Math.max(f, t - f),
445
+ Math.min(e - 1, t + f) + 1
458
446
  );
459
- return t - p > p && r.unshift(I), t + p < e - 1 && r.push(I), r.unshift(1), r.push(e), r;
460
- }, k = (t) => t === I, kt = (t) => k(t) ? t : ft(t), Nt = (t, e) => k(t) ? `${t}_${e}` : `${t}`, G = [
447
+ return t - f > f && r.unshift(I), t + f < e - 1 && r.push(I), r.unshift(1), r.push(e), r;
448
+ }, k = (t) => t === I, Lt = (t) => k(t) ? t : Ct(t), Bt = (t, e) => k(t) ? `${t}_${e}` : `${t}`, Q = [
461
449
  "tw:border tw:border-r-0 tw:last:border-r tw:border-lm-border tw:dark:border-dm-border",
462
450
  "tw:rounded-none tw:first:rounded-l tw:last:rounded-r"
463
- ], J = (t = !1) => s(
464
- G,
451
+ ], V = (t = !1) => s(
452
+ Q,
465
453
  "tw:px-3 py-2 tw:cursor-pointer tw:no-underline",
466
454
  "tw:focus-ring tw:focus-visible:z-1",
467
455
  {
468
456
  "tw:highlight:bg-lm-secondary tw:dark:highlight:bg-dm-secondary tw:text-brand": !t,
469
457
  "tw:bg-lm-brand tw:dark:bg-dm-brand tw:text-white": t
470
458
  }
471
- ), S = ({ children: t }) => /* @__PURE__ */ n("span", { "aria-hidden": !0, className: s(G, "tw:px-3 py-2 tw:text-gray-400"), children: t }), K = () => /* @__PURE__ */ n(S, { children: I });
472
- function vt({ children: t, active: e, isEllipsis: r, href: o, ...d }) {
473
- const a = E(() => J(e), [e]);
474
- return r ? /* @__PURE__ */ n(K, {}) : /* @__PURE__ */ n(U, { className: a, to: o, ...d, children: t });
459
+ ), E = ({ children: t }) => /* @__PURE__ */ n("span", { "aria-hidden": !0, className: s(Q, "tw:px-3 py-2 tw:text-gray-400"), children: t }), X = () => /* @__PURE__ */ n(E, { children: I });
460
+ function St({ children: t, active: e, isEllipsis: r, href: o, ...d }) {
461
+ const a = z(() => V(e), [e]);
462
+ return r ? /* @__PURE__ */ n(X, {}) : /* @__PURE__ */ n(W, { className: a, to: o, ...d, children: t });
475
463
  }
476
- function Pt({ children: t, active: e, isEllipsis: r, ...o }) {
477
- const d = E(() => J(e), [e]);
478
- return r ? /* @__PURE__ */ n(K, {}) : /* @__PURE__ */ n("button", { type: "button", className: d, ...o, children: t });
464
+ function _t({ children: t, active: e, isEllipsis: r, ...o }) {
465
+ const d = z(() => V(e), [e]);
466
+ return r ? /* @__PURE__ */ n(X, {}) : /* @__PURE__ */ n("button", { type: "button", className: d, ...o, children: t });
479
467
  }
480
- const $t = ({ currentPage: t, pagesCount: e, ...r }) => {
481
- const o = "urlForPage" in r, d = o ? vt : Pt, a = N(
468
+ const Qt = ({ currentPage: t, pagesCount: e, ...r }) => {
469
+ const o = "urlForPage" in r, d = o ? St : _t, a = L(
482
470
  (l) => o ? { href: k(l) ? void 0 : r.urlForPage(l) } : { onClick: () => !k(l) && r.onPageChange(l) },
483
471
  [o, r]
484
472
  );
485
473
  return e < 2 ? null : /* @__PURE__ */ i("div", { className: "tw:select-none tw:flex", "data-testid": "paginator", children: [
486
- t === 1 ? /* @__PURE__ */ n(S, { children: /* @__PURE__ */ n(b, { size: "xs", icon: j }) }) : /* @__PURE__ */ n(d, { ...a(Math.max(1, t - 1)), "aria-label": "Previous", children: /* @__PURE__ */ n(b, { size: "xs", icon: j }) }),
487
- yt(t, e).map((l, w) => /* @__PURE__ */ n(
474
+ t === 1 ? /* @__PURE__ */ n(E, { children: /* @__PURE__ */ n(p, { size: "xs", icon: H }) }) : /* @__PURE__ */ n(d, { ...a(Math.max(1, t - 1)), "aria-label": "Previous", children: /* @__PURE__ */ n(p, { size: "xs", icon: H }) }),
475
+ It(t, e).map((l, w) => /* @__PURE__ */ n(
488
476
  d,
489
477
  {
490
478
  active: l === t,
491
479
  isEllipsis: k(l),
492
480
  ...a(l),
493
- children: kt(l)
481
+ children: Lt(l)
494
482
  },
495
- Nt(l, w)
483
+ Bt(l, w)
496
484
  )),
497
- t === e ? /* @__PURE__ */ n(S, { children: /* @__PURE__ */ n(b, { size: "xs", icon: D }) }) : /* @__PURE__ */ n(d, { ...a(Math.min(e, t + 1)), "aria-label": "Next", children: /* @__PURE__ */ n(b, { size: "xs", icon: D }) })
485
+ t === e ? /* @__PURE__ */ n(E, { children: /* @__PURE__ */ n(p, { size: "xs", icon: O }) }) : /* @__PURE__ */ n(d, { ...a(Math.min(e, t + 1)), "aria-label": "Next", children: /* @__PURE__ */ n(p, { size: "xs", icon: O }) })
498
486
  ] });
499
- }, Ct = ({
487
+ }, Ft = ({
500
488
  open: t,
501
489
  children: e,
502
490
  className: r,
503
491
  onClose: o,
504
492
  ...d
505
493
  }) => {
506
- const a = R(null);
507
- return T(() => {
508
- var P, y;
494
+ const a = _(null);
495
+ return F(() => {
496
+ var v, P;
509
497
  const l = document.body, w = l.style.overflow, c = l.style.paddingRight;
510
498
  if (t) {
511
- const L = window.outerWidth - l.clientWidth, u = l.scrollHeight > l.clientHeight;
512
- l.style.overflow = "hidden", u && (l.style.paddingRight = `${L}px`), (P = a.current) == null || P.showModal();
499
+ const b = window.outerWidth - l.clientWidth, h = l.scrollHeight > l.clientHeight;
500
+ l.style.overflow = "hidden", h && (l.style.paddingRight = `${b}px`), (v = a.current) == null || v.showModal();
513
501
  } else
514
- (y = a.current) == null || y.close();
502
+ (P = a.current) == null || P.close();
515
503
  return () => {
516
504
  l.style.overflow = w, l.style.paddingRight = c;
517
505
  };
518
- }, [t]), /* @__PURE__ */ n(
519
- "dialog",
520
- {
521
- ref: a,
522
- className: s("tw:bg-transparent tw:backdrop:bg-black/50", r),
523
- onCancel: (l) => {
524
- l.preventDefault(), o();
525
- },
526
- ...d,
527
- children: t && e
528
- }
506
+ }, [t]), lt(
507
+ /* @__PURE__ */ n(
508
+ "dialog",
509
+ {
510
+ ref: a,
511
+ className: s("tw:bg-transparent tw:backdrop:bg-black/50", r),
512
+ onCancel: (l) => {
513
+ l.preventDefault(), o();
514
+ },
515
+ ...d,
516
+ children: t && e
517
+ }
518
+ ),
519
+ document.body
529
520
  );
530
- }, Ut = ({
521
+ }, Vt = ({
531
522
  open: t,
532
523
  onClose: e,
533
524
  variant: r = "default",
@@ -539,49 +530,56 @@ const $t = ({ currentPage: t, pagesCount: e, ...r }) => {
539
530
  const {
540
531
  size: w = "md",
541
532
  confirmText: c = "Confirm",
533
+ cancelText: v = "Cancel",
542
534
  confirmDisabled: P,
543
- onConfirm: y,
544
- ...L
545
- } = "onConfirm" in l ? l : { ...l }, [u, M] = Q(t), C = R(null);
546
- return T(() => {
535
+ onConfirm: b,
536
+ onClosed: h,
537
+ ...Y
538
+ } = "onConfirm" in l ? l : { ...l }, [C, R] = et(t), T = _(null), B = _("cancel"), Z = L(() => {
539
+ B.current = "confirm", b == null || b();
540
+ }, [b]);
541
+ return F(() => {
547
542
  if (t) {
548
- M(!0);
543
+ B.current = "cancel", R(!0);
549
544
  return;
550
545
  }
551
- const h = C.current;
552
- if (h) {
553
- delete C.current.dataset.open;
554
- const _ = () => M(!1);
555
- return h.addEventListener("transitionend", _, { once: !0 }), () => {
556
- h.removeEventListener("transitionend", _);
546
+ const u = T.current;
547
+ if (u) {
548
+ delete T.current.dataset.open;
549
+ let j = !1;
550
+ const D = (tt) => {
551
+ j || tt.target !== u || (j = !0, R(!1), h == null || h(B.current));
552
+ };
553
+ return u.addEventListener("transitionend", D), () => {
554
+ u.removeEventListener("transitionend", D);
557
555
  };
558
556
  }
559
- }, [t]), T(() => {
560
- const h = C.current;
561
- u && h && (h.dataset.open = "");
562
- }, [u]), /* @__PURE__ */ n(
563
- Ct,
557
+ }, [h, t]), F(() => {
558
+ const u = T.current;
559
+ C && u && (u.dataset.open = "");
560
+ }, [C]), /* @__PURE__ */ n(
561
+ Ft,
564
562
  {
565
- open: u,
563
+ open: C,
566
564
  onClose: e,
567
565
  className: s(
568
566
  {
569
- "tw:flex tw:w-screen tw:h-screen tw:max-w-screen tw:max-h-screen": u,
567
+ "tw:flex tw:w-screen tw:h-screen tw:max-w-screen tw:max-h-screen": C,
570
568
  "tw:overflow-hidden": r === "cover"
571
569
  },
572
570
  a
573
571
  ),
574
- ...L,
572
+ ...Y,
575
573
  children: /* @__PURE__ */ n(
576
574
  "div",
577
575
  {
578
576
  "data-testid": "transition-container",
579
- ref: C,
577
+ ref: T,
580
578
  className: s(
581
579
  "tw:w-full tw:m-auto tw:p-4 tw:sm:p-6",
582
580
  // CSS transitions are based on the presence of the `data-open` attribute
583
581
  "tw:-translate-y-4 tw:data-open:translate-y-0 tw:opacity-0 tw:data-open:opacity-100",
584
- "tw:transition-[opacity_transform] tw:duration-300",
582
+ "tw:transition-[opacity_,_translate] tw:duration-300",
585
583
  // Handle modal dimensions for different variants and sizes
586
584
  r !== "cover" && {
587
585
  "tw:sm:w-sm": w === "sm",
@@ -594,7 +592,7 @@ const $t = ({ currentPage: t, pagesCount: e, ...r }) => {
594
592
  children: /* @__PURE__ */ n(m, { className: s(
595
593
  "tw:w-full",
596
594
  { "tw:h-full tw:relative tw:overflow-auto": r === "cover" }
597
- ), children: r === "cover" ? /* @__PURE__ */ i(B, { children: [
595
+ ), children: r === "cover" ? /* @__PURE__ */ i(S, { children: [
598
596
  /* @__PURE__ */ i(
599
597
  "div",
600
598
  {
@@ -606,21 +604,21 @@ const $t = ({ currentPage: t, pagesCount: e, ...r }) => {
606
604
  ),
607
605
  children: [
608
606
  /* @__PURE__ */ n("h5", { children: o }),
609
- /* @__PURE__ */ n(H, { onClick: e, label: "Close dialog" })
607
+ /* @__PURE__ */ n($, { onClick: e, label: "Close dialog" })
610
608
  ]
611
609
  }
612
610
  ),
613
611
  /* @__PURE__ */ n("div", { children: d })
614
- ] }) : /* @__PURE__ */ i(B, { children: [
612
+ ] }) : /* @__PURE__ */ i(S, { children: [
615
613
  /* @__PURE__ */ i(m.Header, { className: s(
616
614
  "tw:sticky tw:top-0",
617
615
  "tw:flex tw:items-center tw:justify-between tw:gap-x-2"
618
616
  ), children: [
619
617
  /* @__PURE__ */ n("h5", { className: s({ "tw:text-danger": r === "danger" }), children: o }),
620
- /* @__PURE__ */ n(H, { onClick: e, label: "Close dialog" })
618
+ /* @__PURE__ */ n($, { onClick: e, label: "Close dialog" })
621
619
  ] }),
622
620
  /* @__PURE__ */ n(m.Body, { children: d }),
623
- y && /* @__PURE__ */ i(
621
+ b && /* @__PURE__ */ i(
624
622
  m.Footer,
625
623
  {
626
624
  "data-testid": "footer",
@@ -629,14 +627,14 @@ const $t = ({ currentPage: t, pagesCount: e, ...r }) => {
629
627
  "tw:[&]:px-3 tw:sticky tw:bottom-0"
630
628
  ),
631
629
  children: [
632
- /* @__PURE__ */ n(wt, { onClick: e, children: "Cancel" }),
630
+ /* @__PURE__ */ n(pt, { onClick: e, children: v }),
633
631
  /* @__PURE__ */ n(
634
- lt,
632
+ bt,
635
633
  {
636
634
  solid: !0,
637
635
  variant: r === "danger" ? "danger" : "primary",
638
636
  disabled: P,
639
- onClick: y,
637
+ onClick: Z,
640
638
  children: c
641
639
  }
642
640
  )
@@ -648,19 +646,19 @@ const $t = ({ currentPage: t, pagesCount: e, ...r }) => {
648
646
  )
649
647
  }
650
648
  );
651
- }, zt = ({ className: t, children: e, loading: r = !1, variant: o = "default" }) => /* @__PURE__ */ n(bt, { className: f({ "tw:[&]:border-danger": o === "error" }, t), children: /* @__PURE__ */ i("h3", { className: f("tw:text-center", {
649
+ }, Xt = ({ className: t, children: e, loading: r = !1, variant: o = "default" }) => /* @__PURE__ */ n(kt, { className: x({ "tw:[&]:border-danger": o === "error" }, t), children: /* @__PURE__ */ i("h3", { className: x("tw:text-center", {
652
650
  "tw:text-gray-500 tw:dark:text-gray-400": o === "default",
653
651
  "tw:text-danger": o === "error"
654
652
  }), children: [
655
- r && /* @__PURE__ */ i(B, { children: [
656
- /* @__PURE__ */ n(b, { icon: Z, spin: !0 }),
653
+ r && /* @__PURE__ */ i(S, { children: [
654
+ /* @__PURE__ */ n(p, { icon: dt, spin: !0 }),
657
655
  /* @__PURE__ */ n("span", { className: "tw:ml-2", children: e ?? "Loading..." })
658
656
  ] }),
659
657
  !r && e
660
- ] }) }), At = ({ variant: t, className: e, size: r = "md", children: o }) => /* @__PURE__ */ n(
658
+ ] }) }), Yt = ({ variant: t, className: e, size: r = "md", children: o }) => /* @__PURE__ */ n(
661
659
  "div",
662
660
  {
663
- className: f(
661
+ className: x(
664
662
  "tw:rounded-md tw:text-center",
665
663
  {
666
664
  "tw:p-2": r === "sm",
@@ -677,32 +675,31 @@ const $t = ({ currentPage: t, pagesCount: e, ...r }) => {
677
675
  }
678
676
  );
679
677
  export {
680
- lt as Button,
678
+ bt as Button,
681
679
  m as Card,
682
- Ut as CardModal,
683
- Et as Checkbox,
684
- H as CloseButton,
680
+ Vt as CardModal,
681
+ Ut as Checkbox,
682
+ $ as CloseButton,
685
683
  I as ELLIPSIS,
686
- A as Input,
687
- W as Label,
688
- Mt as LabelledInput,
689
- _t as LabelledSelect,
690
- wt as LinkButton,
691
- zt as Message,
692
- Ct as ModalDialog,
693
- Ht as NavPills,
694
- $t as Paginator,
695
- At as Result,
696
- jt as SearchInput,
697
- at as Select,
698
- bt as SimpleCard,
699
- Rt as Table,
700
- Dt as ToggleSwitch,
701
- ft as formatNumber,
702
- Nt as keyForPage,
684
+ G as Input,
685
+ J as Label,
686
+ zt as LabelledInput,
687
+ Wt as LabelledSelect,
688
+ pt as LinkButton,
689
+ Xt as Message,
690
+ Ft as ModalDialog,
691
+ Jt as NavPills,
692
+ Qt as Paginator,
693
+ Yt as Result,
694
+ qt as SearchInput,
695
+ ut as Select,
696
+ kt as SimpleCard,
697
+ At as Table,
698
+ Gt as ToggleSwitch,
699
+ Ct as formatNumber,
700
+ Bt as keyForPage,
703
701
  k as pageIsEllipsis,
704
- kt as prettifyPageNumber,
705
- yt as progressivePagination,
706
- Ot as roundTen,
707
- st as useTimeout
702
+ Lt as prettifyPageNumber,
703
+ It as progressivePagination,
704
+ Kt as roundTen
708
705
  };
@@ -157,6 +157,19 @@
157
157
  @apply tw:focus-ring-base tw:focus-visible:ring-danger/50;
158
158
  }
159
159
 
160
+ @utility scroll-thin {
161
+ /* Standard. New browsers */
162
+ scrollbar-width: thin;
163
+
164
+ /* Fallbacks */
165
+ &::-webkit-scrollbar {
166
+ width: 6px;
167
+ }
168
+ &::-webkit-scrollbar-thumb {
169
+ border-radius: .5rem;
170
+ }
171
+ }
172
+
160
173
  @custom-variant highlight {
161
174
  &:hover,
162
175
  &:focus {
@@ -0,0 +1,17 @@
1
+ import { useRef as l, useCallback as s, useEffect as m, useMemo as f } from "react";
2
+ function a(u, r = globalThis.setTimeout, o = globalThis.clearTimeout) {
3
+ const t = l(null), e = s(() => {
4
+ t.current && o(t.current);
5
+ }, [o]), n = s((c, i) => {
6
+ e(), t.current = r(() => {
7
+ c(), t.current = null;
8
+ }, i ?? u);
9
+ }, [e, u, r]);
10
+ return m(() => e, [e]), f(
11
+ () => ({ setTimeout: n, clearCurrentTimeout: e }),
12
+ [e, n]
13
+ );
14
+ }
15
+ export {
16
+ a as u
17
+ };
package/package.json CHANGED
@@ -89,5 +89,5 @@
89
89
  "not ie <= 11",
90
90
  "not op_mini all"
91
91
  ],
92
- "version": "0.8.3"
92
+ "version": "0.8.5"
93
93
  }