@shlinkio/shlink-frontend-kit 0.8.7 → 0.8.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -0
- package/dist/index.js +107 -104
- package/dist/tailwind.d.ts +61 -0
- package/dist/tailwind.js +567 -434
- package/dist/use-toggle-CNvdDGvy.js +22 -0
- package/package.json +3 -2
- package/dist/use-toggle-DlYE68B3.js +0 -24
package/dist/index.d.ts
CHANGED
|
@@ -210,8 +210,11 @@ export declare type ToggleResult = [boolean, () => void, () => void, () => void]
|
|
|
210
210
|
|
|
211
211
|
export declare const ToggleSwitch: FC<BooleanControlProps>;
|
|
212
212
|
|
|
213
|
+
/** @deprecated Use `useRef<T>(null) instead */
|
|
213
214
|
export declare const useElementRef: <T extends HTMLElement>() => RefObject<T | null>;
|
|
214
215
|
|
|
216
|
+
export declare const useGoBack: () => () => void | Promise<void>;
|
|
217
|
+
|
|
215
218
|
export declare const useOrder: <T>(initialOrder: Order<T>) => [Order<T>, (orderField?: T, orderDir?: OrderDir) => void];
|
|
216
219
|
|
|
217
220
|
export declare const useParsedQuery: <T>() => T;
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { jsx as o, jsxs as m, Fragment as
|
|
2
|
-
import { faCircleNotch as
|
|
1
|
+
import { jsx as o, jsxs as m, Fragment as w } from "react/jsx-runtime";
|
|
2
|
+
import { faCircleNotch as A, faSearch as I, faEllipsisV as E, faSortAmountUp as P, faSortAmountDown as F } from "@fortawesome/free-solid-svg-icons";
|
|
3
3
|
import { FontAwesomeIcon as p } from "@fortawesome/react-fontawesome";
|
|
4
4
|
import { clsx as u } from "clsx";
|
|
5
|
-
import { Card as N, CardHeader as
|
|
6
|
-
import { useId as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
const be = ({ className: e, children: r, loading: t = !1, type: n = "default", fullWidth: s = !1 }) => /* @__PURE__ */ o(
|
|
5
|
+
import { Card as N, CardHeader as H, CardBody as M, Dropdown as $, DropdownToggle as v, DropdownMenu as k, NavItem as G, NavLink as j, Nav as U, UncontrolledDropdown as V, DropdownItem as g } from "reactstrap";
|
|
6
|
+
import { useId as S, useState as b, useRef as y, useCallback as C, useMemo as q, Children as Q, isValidElement as Y, useEffect as W } from "react";
|
|
7
|
+
import { useNavigate as z, useLocation as J, NavLink as X } from "react-router";
|
|
8
|
+
import { u as Z, a as B } from "./use-toggle-CNvdDGvy.js";
|
|
9
|
+
const ge = ({ className: e, children: r, loading: t = !1, type: n = "default", fullWidth: s = !1 }) => /* @__PURE__ */ o(
|
|
11
10
|
N,
|
|
12
11
|
{
|
|
13
12
|
body: !0,
|
|
@@ -24,18 +23,18 @@ const be = ({ className: e, children: r, loading: t = !1, type: n = "default", f
|
|
|
24
23
|
"text-danger": n === "error"
|
|
25
24
|
}),
|
|
26
25
|
children: [
|
|
27
|
-
t && /* @__PURE__ */ o(p, { icon:
|
|
26
|
+
t && /* @__PURE__ */ o(p, { icon: A, spin: !0 }),
|
|
28
27
|
t && /* @__PURE__ */ o("span", { className: "ms-2", children: r ?? "Loading..." }),
|
|
29
28
|
!t && r
|
|
30
29
|
]
|
|
31
30
|
}
|
|
32
31
|
)
|
|
33
32
|
}
|
|
34
|
-
),
|
|
35
|
-
e && /* @__PURE__ */ o(
|
|
36
|
-
/* @__PURE__ */ o(
|
|
33
|
+
), K = ({ title: e, children: r, bodyClassName: t, ...n }) => /* @__PURE__ */ m(N, { ...n, children: [
|
|
34
|
+
e && /* @__PURE__ */ o(H, { role: "heading", "aria-level": 4, children: e }),
|
|
35
|
+
/* @__PURE__ */ o(M, { className: t, children: r })
|
|
37
36
|
] }), we = ({ children: e, type: r, className: t, small: n = !1 }) => /* @__PURE__ */ o(
|
|
38
|
-
|
|
37
|
+
K,
|
|
39
38
|
{
|
|
40
39
|
role: "document",
|
|
41
40
|
className: u("text-center", {
|
|
@@ -49,8 +48,8 @@ const be = ({ className: e, children: r, loading: t = !1, type: n = "default", f
|
|
|
49
48
|
bodyClassName: u({ "p-2": n }),
|
|
50
49
|
children: e
|
|
51
50
|
}
|
|
52
|
-
),
|
|
53
|
-
const i =
|
|
51
|
+
), O = ({ checked: e = !1, onChange: r, className: t, children: n, type: s, inline: c = !1 }) => {
|
|
52
|
+
const i = S(), a = (h) => r == null ? void 0 : r(h.target.checked, h), l = {
|
|
54
53
|
"form-switch": s === "switch",
|
|
55
54
|
"form-checkbox": s === "checkbox"
|
|
56
55
|
}, d = c ? { display: "inline-block" } : {};
|
|
@@ -58,12 +57,12 @@ const be = ({ className: e, children: r, loading: t = !1, type: n = "default", f
|
|
|
58
57
|
/* @__PURE__ */ o("input", { type: "checkbox", className: "form-check-input", id: i, checked: e, onChange: a }),
|
|
59
58
|
/* @__PURE__ */ o("label", { className: "form-check-label", htmlFor: i, children: n })
|
|
60
59
|
] });
|
|
61
|
-
},
|
|
60
|
+
}, Ne = (e) => /* @__PURE__ */ o(O, { type: "checkbox", ...e }), Ce = (e) => /* @__PURE__ */ o(O, { type: "switch", ...e }), ee = ({ children: e, label: r, className: t = "", labelClassName: n = "", noMargin: s = !1, id: c }) => /* @__PURE__ */ m("div", { className: `${t} ${s ? "" : "mb-3"}`, children: [
|
|
62
61
|
/* @__PURE__ */ o("label", { className: `form-label ${n}`, htmlFor: c, children: r }),
|
|
63
62
|
e
|
|
64
|
-
] }),
|
|
65
|
-
const l =
|
|
66
|
-
return /* @__PURE__ */ o(
|
|
63
|
+
] }), _e = ({ children: e, value: r, onChange: t, type: n, required: s, placeholder: c, className: i, labelClassName: a }) => {
|
|
64
|
+
const l = S();
|
|
65
|
+
return /* @__PURE__ */ o(ee, { label: /* @__PURE__ */ m(w, { children: [
|
|
67
66
|
e,
|
|
68
67
|
":"
|
|
69
68
|
] }), className: i, labelClassName: a, id: l, children: /* @__PURE__ */ o(
|
|
@@ -78,14 +77,14 @@ const be = ({ className: e, children: r, loading: t = !1, type: n = "default", f
|
|
|
78
77
|
onChange: (d) => t(d.target.value)
|
|
79
78
|
}
|
|
80
79
|
) });
|
|
81
|
-
},
|
|
80
|
+
}, re = 500;
|
|
82
81
|
let f;
|
|
83
|
-
const
|
|
82
|
+
const T = () => {
|
|
84
83
|
f !== null && clearTimeout(f), f = null;
|
|
85
|
-
},
|
|
86
|
-
const [i, a] = b(s), l = (d, h =
|
|
87
|
-
a(d),
|
|
88
|
-
e(d),
|
|
84
|
+
}, Te = ({ onChange: e, className: r, large: t = !0, noBorder: n = !1, initialValue: s = "", setTimeout_: c = setTimeout }) => {
|
|
85
|
+
const [i, a] = b(s), l = (d, h = re) => {
|
|
86
|
+
a(d), T(), f = c(() => {
|
|
87
|
+
e(d), T();
|
|
89
88
|
}, h);
|
|
90
89
|
};
|
|
91
90
|
return /* @__PURE__ */ m("div", { className: u("search-field", r), children: [
|
|
@@ -102,7 +101,7 @@ const _ = () => {
|
|
|
102
101
|
onChange: (d) => l(d.target.value)
|
|
103
102
|
}
|
|
104
103
|
),
|
|
105
|
-
/* @__PURE__ */ o(p, { icon:
|
|
104
|
+
/* @__PURE__ */ o(p, { icon: I, className: "search-field__icon" }),
|
|
106
105
|
/* @__PURE__ */ o(
|
|
107
106
|
"button",
|
|
108
107
|
{
|
|
@@ -115,7 +114,10 @@ const _ = () => {
|
|
|
115
114
|
}
|
|
116
115
|
)
|
|
117
116
|
] });
|
|
118
|
-
},
|
|
117
|
+
}, ve = () => y(null), ke = () => {
|
|
118
|
+
const e = z();
|
|
119
|
+
return C(() => e(-1), [e]);
|
|
120
|
+
}, te = (e) => {
|
|
119
121
|
const r = new URLSearchParams(e), t = {};
|
|
120
122
|
return r.forEach((n, s) => {
|
|
121
123
|
if (s.endsWith("[]")) {
|
|
@@ -124,23 +126,23 @@ const _ = () => {
|
|
|
124
126
|
} else
|
|
125
127
|
t[s] = n;
|
|
126
128
|
}), t;
|
|
127
|
-
},
|
|
129
|
+
}, Se = (e) => {
|
|
128
130
|
const r = new URLSearchParams();
|
|
129
131
|
for (const [t, n] of Object.entries(e))
|
|
130
132
|
n !== void 0 && (Array.isArray(n) ? n.forEach((s) => r.append(`${t}[]`, `${s}`)) : r.append(t, `${n}`));
|
|
131
133
|
return r.toString();
|
|
132
|
-
},
|
|
133
|
-
const { search: e } =
|
|
134
|
-
return
|
|
135
|
-
},
|
|
136
|
-
const { initialValue: s = !1, delay: c =
|
|
134
|
+
}, ye = () => {
|
|
135
|
+
const { search: e } = J();
|
|
136
|
+
return q(() => te(e), [e]);
|
|
137
|
+
}, ne = 2e3, Oe = (e = {}, r, t = globalThis.setTimeout, n = globalThis.clearTimeout) => {
|
|
138
|
+
const { initialValue: s = !1, delay: c = ne } = typeof e == "boolean" ? {
|
|
137
139
|
initialValue: e,
|
|
138
140
|
delay: r
|
|
139
|
-
} : e, { setTimeout: i } =
|
|
141
|
+
} : e, { setTimeout: i } = Z(c, t, n), [a, l] = b(s), d = y(s), h = C(() => {
|
|
140
142
|
l(!d.current), i(() => l(d.current));
|
|
141
143
|
}, [i]);
|
|
142
144
|
return [a, h];
|
|
143
|
-
},
|
|
145
|
+
}, oe = ({
|
|
144
146
|
text: e,
|
|
145
147
|
disabled: r = !1,
|
|
146
148
|
className: t,
|
|
@@ -153,18 +155,18 @@ const _ = () => {
|
|
|
153
155
|
size: d,
|
|
154
156
|
...h
|
|
155
157
|
}) => {
|
|
156
|
-
const [
|
|
158
|
+
const [L, x] = B(), D = u("dropdown-btn__toggle", t, {
|
|
157
159
|
"btn-block": !l,
|
|
158
160
|
"dropdown-btn__toggle--with-caret": !c
|
|
159
|
-
}),
|
|
160
|
-
return /* @__PURE__ */ m(
|
|
161
|
-
/* @__PURE__ */ o(
|
|
162
|
-
/* @__PURE__ */ o(k, { className: "w-100", end: i, style:
|
|
161
|
+
}), R = { minWidth: a && `${a}px` };
|
|
162
|
+
return /* @__PURE__ */ m($, { isOpen: L, toggle: x, disabled: r, className: s, children: [
|
|
163
|
+
/* @__PURE__ */ o(v, { size: d, caret: !c, className: D, color: "primary", ...h, children: e }),
|
|
164
|
+
/* @__PURE__ */ o(k, { className: "w-100", end: i, style: R, children: n })
|
|
163
165
|
] });
|
|
164
|
-
},
|
|
165
|
-
|
|
166
|
+
}, Le = ({ children: e, minWidth: r, label: t = "Options" }) => /* @__PURE__ */ o(
|
|
167
|
+
oe,
|
|
166
168
|
{
|
|
167
|
-
text: /* @__PURE__ */ o(p, { className: "px-1", icon:
|
|
169
|
+
text: /* @__PURE__ */ o(p, { className: "px-1", icon: E }),
|
|
168
170
|
"aria-label": t,
|
|
169
171
|
size: "sm",
|
|
170
172
|
minWidth: r,
|
|
@@ -173,41 +175,41 @@ const _ = () => {
|
|
|
173
175
|
inline: !0,
|
|
174
176
|
children: e
|
|
175
177
|
}
|
|
176
|
-
),
|
|
177
|
-
if (!Y(n) || n.type !==
|
|
178
|
+
), se = ({ children: e, ...r }) => /* @__PURE__ */ o(G, { children: /* @__PURE__ */ o(j, { className: "nav-pills__nav-link", tag: X, ...r, children: e }) }), xe = ({ children: e, fill: r = !1, className: t = "" }) => /* @__PURE__ */ o(N, { className: `nav-pills__nav p-0 overflow-hidden ${t}`, body: !0, children: /* @__PURE__ */ o(U, { pills: !0, fill: r, children: Q.map(e, (n) => {
|
|
179
|
+
if (!Y(n) || n.type !== se)
|
|
178
180
|
throw new Error("Only NavPillItem children are allowed inside NavPills.");
|
|
179
181
|
return n;
|
|
180
182
|
}) }) });
|
|
181
|
-
function
|
|
182
|
-
return typeof e == "object" ?
|
|
183
|
+
function _(e, r, t) {
|
|
184
|
+
return typeof e == "object" ? _(e.currentField, e.newField, e.currentOrderDir) : e !== r ? "ASC" : t ? {
|
|
183
185
|
ASC: "DESC",
|
|
184
186
|
DESC: void 0
|
|
185
187
|
}[t] : "ASC";
|
|
186
188
|
}
|
|
187
|
-
function
|
|
188
|
-
return typeof e == "object" ?
|
|
189
|
+
function ce(e, r, t) {
|
|
190
|
+
return typeof e == "object" ? ce(e.currentField, e.newField, e.currentOrderDir) : {
|
|
189
191
|
field: r,
|
|
190
|
-
dir:
|
|
192
|
+
dir: _(e, r, t)
|
|
191
193
|
};
|
|
192
194
|
}
|
|
193
|
-
const
|
|
195
|
+
const De = (e, { field: r, dir: t }) => !r || !t ? e : e.sort((n, s) => {
|
|
194
196
|
const c = t === "ASC" ? 1 : -1, i = t === "ASC" ? -1 : 1;
|
|
195
197
|
return n[r] > s[r] ? c : i;
|
|
196
|
-
}),
|
|
198
|
+
}), Re = (e) => e.dir ? `${e.field}-${e.dir}` : void 0, Ae = (e) => {
|
|
197
199
|
const [r, t] = e.split("-");
|
|
198
200
|
return { field: r, dir: t };
|
|
199
|
-
},
|
|
200
|
-
const [r, t] = b(e), n =
|
|
201
|
+
}, Ie = (e) => {
|
|
202
|
+
const [r, t] = b(e), n = C((s, c) => t({ field: s, dir: c }), []);
|
|
201
203
|
return [r, n];
|
|
202
204
|
};
|
|
203
|
-
function
|
|
205
|
+
function Ee({ items: e, order: r, onChange: t, isButton: n = !0, right: s = !1, prefixed: c = !0 }) {
|
|
204
206
|
const i = (a) => () => {
|
|
205
|
-
const l =
|
|
207
|
+
const l = _(a, r.field, r.dir);
|
|
206
208
|
t(l ? a : void 0, l);
|
|
207
209
|
};
|
|
208
|
-
return /* @__PURE__ */ m(
|
|
210
|
+
return /* @__PURE__ */ m(V, { children: [
|
|
209
211
|
/* @__PURE__ */ m(
|
|
210
|
-
|
|
212
|
+
v,
|
|
211
213
|
{
|
|
212
214
|
caret: !0,
|
|
213
215
|
color: n ? "primary" : "link",
|
|
@@ -216,9 +218,9 @@ function Re({ items: e, order: r, onChange: t, isButton: n = !0, right: s = !1,
|
|
|
216
218
|
"btn-sm p-0": !n
|
|
217
219
|
}),
|
|
218
220
|
children: [
|
|
219
|
-
!n && /* @__PURE__ */ o(
|
|
221
|
+
!n && /* @__PURE__ */ o(w, { children: "Order by" }),
|
|
220
222
|
n && !r.field && /* @__PURE__ */ o("i", { children: "Order by..." }),
|
|
221
|
-
n && r.field && /* @__PURE__ */ m(
|
|
223
|
+
n && r.field && /* @__PURE__ */ m(w, { children: [
|
|
222
224
|
c && "Order by: ",
|
|
223
225
|
e[r.field],
|
|
224
226
|
" - ",
|
|
@@ -229,70 +231,71 @@ function Re({ items: e, order: r, onChange: t, isButton: n = !0, right: s = !1,
|
|
|
229
231
|
),
|
|
230
232
|
/* @__PURE__ */ m(k, { end: s, className: "w-100", style: n ? void 0 : { minWidth: "11rem" }, children: [
|
|
231
233
|
Object.entries(e).map(([a, l]) => /* @__PURE__ */ m(
|
|
232
|
-
|
|
234
|
+
g,
|
|
233
235
|
{
|
|
234
236
|
active: r.field === a,
|
|
235
237
|
onClick: i(a),
|
|
236
238
|
className: "d-flex justify-content-between align-items-center",
|
|
237
239
|
children: [
|
|
238
240
|
l,
|
|
239
|
-
r.field === a && /* @__PURE__ */ o(p, { icon: r.dir === "ASC" ?
|
|
241
|
+
r.field === a && /* @__PURE__ */ o(p, { icon: r.dir === "ASC" ? P : F })
|
|
240
242
|
]
|
|
241
243
|
},
|
|
242
244
|
a
|
|
243
245
|
)),
|
|
244
|
-
/* @__PURE__ */ o(
|
|
245
|
-
/* @__PURE__ */ o(
|
|
246
|
+
/* @__PURE__ */ o(g, { divider: !0 }),
|
|
247
|
+
/* @__PURE__ */ o(g, { disabled: !r.field, onClick: () => t(), children: /* @__PURE__ */ o("i", { children: "Clear selection" }) })
|
|
246
248
|
] })
|
|
247
249
|
] });
|
|
248
250
|
}
|
|
249
|
-
const
|
|
251
|
+
const Pe = "#4696e5", Fe = "rgba(70, 150, 229, 0.4)", He = "#f77f28", Me = "rgba(247, 127, 40, 0.4)", $e = "white", Ge = "#161b22", ae = (e) => {
|
|
250
252
|
var r;
|
|
251
253
|
return (r = document.querySelector("html")) == null ? void 0 : r.setAttribute("data-theme", e);
|
|
252
|
-
},
|
|
254
|
+
}, je = () => {
|
|
253
255
|
var e;
|
|
254
256
|
return ((e = document.querySelector("html")) == null ? void 0 : e.getAttribute("data-theme")) === "dark";
|
|
255
|
-
},
|
|
256
|
-
const [r, t] = b(() => e ??
|
|
257
|
+
}, le = (e = window.matchMedia.bind(window)) => e("(prefers-color-scheme: dark)").matches ? "dark" : "light", Ue = (e) => {
|
|
258
|
+
const [r, t] = b(() => e ?? le());
|
|
257
259
|
return W(() => {
|
|
258
|
-
|
|
260
|
+
ae(r);
|
|
259
261
|
}, [r]), [r, t];
|
|
260
262
|
};
|
|
261
263
|
export {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
264
|
+
Ne as Checkbox,
|
|
265
|
+
oe as DropdownBtn,
|
|
266
|
+
He as HIGHLIGHTED_COLOR,
|
|
267
|
+
Me as HIGHLIGHTED_COLOR_ALPHA,
|
|
268
|
+
_e as InputFormGroup,
|
|
269
|
+
ee as LabeledFormGroup,
|
|
270
|
+
Pe as MAIN_COLOR,
|
|
271
|
+
Fe as MAIN_COLOR_ALPHA,
|
|
272
|
+
ge as Message,
|
|
273
|
+
se as NavPillItem,
|
|
274
|
+
xe as NavPills,
|
|
275
|
+
Ee as OrderingDropdown,
|
|
276
|
+
Ge as PRIMARY_DARK_COLOR,
|
|
277
|
+
$e as PRIMARY_LIGHT_COLOR,
|
|
276
278
|
we as Result,
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
279
|
+
Le as RowDropdownBtn,
|
|
280
|
+
Te as SearchField,
|
|
281
|
+
K as SimpleCard,
|
|
282
|
+
Ce as ToggleSwitch,
|
|
283
|
+
ae as changeThemeInMarkup,
|
|
284
|
+
ce as determineOrder,
|
|
285
|
+
_ as determineOrderDir,
|
|
286
|
+
le as getSystemPreferredTheme,
|
|
287
|
+
je as isDarkThemeEnabled,
|
|
288
|
+
Re as orderToString,
|
|
289
|
+
te as parseQueryString,
|
|
290
|
+
De as sortList,
|
|
291
|
+
Ae as stringToOrder,
|
|
292
|
+
Se as stringifyQueryParams,
|
|
293
|
+
ve as useElementRef,
|
|
294
|
+
ke as useGoBack,
|
|
295
|
+
Ie as useOrder,
|
|
296
|
+
ye as useParsedQuery,
|
|
297
|
+
Ue as useTheme,
|
|
298
|
+
Z as useTimeout,
|
|
299
|
+
Oe as useTimeoutToggle,
|
|
300
|
+
B as useToggle
|
|
298
301
|
};
|
package/dist/tailwind.d.ts
CHANGED
|
@@ -3,16 +3,20 @@ import { FC } from 'react';
|
|
|
3
3
|
import { ForwardRefExoticComponent } from 'react';
|
|
4
4
|
import { HTMLProps } from 'react';
|
|
5
5
|
import { InputHTMLAttributes } from 'react';
|
|
6
|
+
import { JSX } from 'react/jsx-runtime';
|
|
6
7
|
import { LinkProps } from 'react-router';
|
|
7
8
|
import { PropsWithChildren } from 'react';
|
|
8
9
|
import { ReactNode } from 'react';
|
|
9
10
|
import { RefAttributes } from 'react';
|
|
11
|
+
import { RefObject } from 'react';
|
|
10
12
|
|
|
11
13
|
export declare type BaseInputProps = {
|
|
12
14
|
size?: Size;
|
|
13
15
|
feedback?: 'error';
|
|
14
16
|
};
|
|
15
17
|
|
|
18
|
+
declare type BaseInputProps_2 = Omit<SearchInputProps, 'role' | 'aria-autocomplete' | 'aria-expanded' | 'aria-controls' | 'aria-activedescendant' | 'onChange' | 'autoComplete' | 'autoCorrect'>;
|
|
19
|
+
|
|
16
20
|
declare type BooleanControlProps = Omit<HTMLProps<HTMLInputElement>, 'type' | 'onChange' | 'value' | 'defaultValue'> & {
|
|
17
21
|
onChange?: (checked: boolean, e: ChangeEvent<HTMLInputElement>) => void;
|
|
18
22
|
};
|
|
@@ -155,6 +159,31 @@ export declare type LinkButtonProps = Omit<HTMLProps<HTMLButtonElement>, 'size'
|
|
|
155
159
|
|
|
156
160
|
declare type LinkButtonProps_2 = LinkProps;
|
|
157
161
|
|
|
162
|
+
export declare function Listbox<Item>({ id, items, onSelectItem, onActiveItemChange, renderItem, className, noItemsMessage, anchor, 'aria-label': label, ...rest }: ListboxProps<Item>): JSX.Element;
|
|
163
|
+
|
|
164
|
+
export declare type ListboxProps<Item> = Omit<CardProps, 'id' | 'role' | 'aria-orientation'> & {
|
|
165
|
+
/** Map of items in the listbox, with a key representing them uniquely */
|
|
166
|
+
items: Map<string, Item>;
|
|
167
|
+
/** Invoked when the active item is selected via click or `Enter` */
|
|
168
|
+
onSelectItem: (item: Item) => void;
|
|
169
|
+
/** Invoked when the active item changes via vertical arrows or hover */
|
|
170
|
+
onActiveItemChange?: (key: string, item: Item) => void;
|
|
171
|
+
/** To customize the shape of an item */
|
|
172
|
+
renderItem: (item: Item) => ReactNode;
|
|
173
|
+
/** Used to link with the element controlling this listbox */
|
|
174
|
+
id: string;
|
|
175
|
+
/**
|
|
176
|
+
* Allows to optionally anchor this listbox to another element.
|
|
177
|
+
* If provided, it will attach arrow key and Enter press listeners to interact with the listbox.
|
|
178
|
+
*/
|
|
179
|
+
anchor?: RefObject<HTMLElement | null>;
|
|
180
|
+
/**
|
|
181
|
+
* Message to display when the list of items is empty.
|
|
182
|
+
* Defaults to 'No items'.
|
|
183
|
+
*/
|
|
184
|
+
noItemsMessage?: string;
|
|
185
|
+
};
|
|
186
|
+
|
|
158
187
|
/**
|
|
159
188
|
* Component used to display a card with general information, about current page status, loading, etc.
|
|
160
189
|
*/
|
|
@@ -255,16 +284,48 @@ export declare type RevealablePasswordInputProps = Omit<InputProps, 'type'> & {
|
|
|
255
284
|
|
|
256
285
|
export declare const roundTen: (number: number) => number;
|
|
257
286
|
|
|
287
|
+
/**
|
|
288
|
+
* This component combines a SearchInput with a Listbox, to behave close to an editable combobox with autocomplete, as
|
|
289
|
+
* described in https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-autocomplete-list/.
|
|
290
|
+
* The main difference is that the input is used only to search in the listbox, and once an item is selected, the input
|
|
291
|
+
* is cleared and the listbox is closed.
|
|
292
|
+
*/
|
|
293
|
+
export declare function SearchCombobox<Item>({ searchResults, onSearch, onSelectSearchResult, renderSearchResult, size, // SearchInput defaults its size to 'lg'. Change it to 'md'
|
|
294
|
+
listboxSpan, onFocus, ...rest }: SearchComboboxProps<Item>): JSX.Element;
|
|
295
|
+
|
|
296
|
+
export declare type SearchComboboxProps<Item> = BaseInputProps_2 & {
|
|
297
|
+
/** If defined, it will display a listbox with the search results */
|
|
298
|
+
searchResults?: Map<string, Item>;
|
|
299
|
+
/** Invoked when the search input value changes */
|
|
300
|
+
onSearch: (searchTerm: string) => void;
|
|
301
|
+
/** Invoked when the active search result is selected */
|
|
302
|
+
onSelectSearchResult: (item: Item) => void;
|
|
303
|
+
/** To customize the look and feel of a search result */
|
|
304
|
+
renderSearchResult: (item: Item) => ReactNode;
|
|
305
|
+
/**
|
|
306
|
+
* Determines how the listbox should span when visible.
|
|
307
|
+
* - `full`: Be always as big as the input, regardless its content.
|
|
308
|
+
* - `auto`: Take only the needed space to display its content, up to the width of the input.
|
|
309
|
+
*
|
|
310
|
+
* Defaults to `full`.
|
|
311
|
+
*/
|
|
312
|
+
listboxSpan?: 'full' | 'auto';
|
|
313
|
+
};
|
|
314
|
+
|
|
258
315
|
export declare const SearchInput: ForwardRefExoticComponent<Omit<InputProps, "className" | "onChange" | "value"> & {
|
|
259
316
|
onChange: (searchTerm: string) => void;
|
|
260
317
|
containerClassName?: string;
|
|
261
318
|
inputClassName?: string;
|
|
319
|
+
/** When set to true, it displays a loading indicator in place of the magnifyinf glass icon */
|
|
320
|
+
loading?: boolean;
|
|
262
321
|
} & RefAttributes<HTMLInputElement>>;
|
|
263
322
|
|
|
264
323
|
export declare type SearchInputProps = Omit<InputProps, 'className' | 'onChange' | 'value'> & {
|
|
265
324
|
onChange: (searchTerm: string) => void;
|
|
266
325
|
containerClassName?: string;
|
|
267
326
|
inputClassName?: string;
|
|
327
|
+
/** When set to true, it displays a loading indicator in place of the magnifyinf glass icon */
|
|
328
|
+
loading?: boolean;
|
|
268
329
|
};
|
|
269
330
|
|
|
270
331
|
export declare type SectionType = 'head' | 'body' | 'footer';
|