@brightlocal/ui-components 2.26.0 → 2.27.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/README.md +4 -2
- package/component-meta.json +3761 -360
- package/dist/blocks/progress-screen.cjs +1 -0
- package/dist/blocks/progress-screen.d.ts +109 -0
- package/dist/blocks/progress-screen.d.ts.map +1 -0
- package/dist/blocks/progress-screen.js +339 -0
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +155 -153
- package/dist/brand-illustration-motif.d.ts +1 -1
- package/dist/breadcrumb.cjs +1 -1
- package/dist/breadcrumb.d.ts.map +1 -1
- package/dist/breadcrumb.js +44 -40
- package/dist/button.cjs +1 -1
- package/dist/button.d.ts.map +1 -1
- package/dist/button.js +28 -28
- package/dist/chip.cjs +1 -1
- package/dist/chip.d.ts +1 -1
- package/dist/chip.d.ts.map +1 -1
- package/dist/chip.js +42 -41
- package/dist/combobox.cjs +3 -3
- package/dist/combobox.d.ts +4 -2
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +161 -161
- package/dist/data-table.cjs +1 -1
- package/dist/data-table.d.ts +138 -3
- package/dist/data-table.d.ts.map +1 -1
- package/dist/data-table.js +455 -309
- package/dist/global-layout.cjs +1 -1
- package/dist/global-layout.d.ts +31 -5
- package/dist/global-layout.d.ts.map +1 -1
- package/dist/global-layout.js +276 -194
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +462 -451
- package/dist/lib/motion.cjs +1 -1
- package/dist/lib/motion.js +10 -8
- package/dist/link.cjs +1 -1
- package/dist/link.d.ts +8 -6
- package/dist/link.d.ts.map +1 -1
- package/dist/link.js +52 -20
- package/dist/list.cjs +1 -1
- package/dist/list.js +65 -63
- package/dist/progress.cjs +1 -1
- package/dist/progress.d.ts +61 -3
- package/dist/progress.d.ts.map +1 -1
- package/dist/progress.js +142 -65
- package/dist/route-progress.cjs +1 -0
- package/dist/route-progress.d.ts +103 -0
- package/dist/route-progress.d.ts.map +1 -0
- package/dist/route-progress.js +106 -0
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.d.ts +35 -2
- package/dist/sheet.d.ts.map +1 -1
- package/dist/sheet.js +102 -65
- package/dist/sonner.cjs +1 -1
- package/dist/sonner.d.ts.map +1 -1
- package/dist/sonner.js +11 -15
- package/dist/spinner.cjs +1 -0
- package/dist/spinner.d.ts +57 -0
- package/dist/spinner.d.ts.map +1 -0
- package/dist/spinner.js +35 -0
- package/dist/stepper.cjs +1 -1
- package/dist/stepper.d.ts.map +1 -1
- package/dist/stepper.js +26 -25
- package/dist/table.cjs +1 -1
- package/dist/table.d.ts +1 -1
- package/dist/table.d.ts.map +1 -1
- package/dist/table.js +6 -2
- package/package.json +14 -2
- package/src/blocks/progress-screen.tsx +481 -0
- package/src/blocks/sidebar.tsx +22 -15
- package/src/components/breadcrumb.tsx +9 -4
- package/src/components/button.tsx +2 -5
- package/src/components/chip.tsx +4 -3
- package/src/components/combobox.tsx +15 -8
- package/src/components/data-table.tsx +333 -14
- package/src/components/global-layout.tsx +228 -62
- package/src/components/link.tsx +39 -5
- package/src/components/list.tsx +5 -5
- package/src/components/progress.tsx +217 -30
- package/src/components/route-progress.tsx +354 -0
- package/src/components/sheet.tsx +87 -5
- package/src/components/sonner.tsx +3 -12
- package/src/components/spinner.tsx +94 -0
- package/src/components/stepper.tsx +3 -4
- package/src/components/table.tsx +6 -2
- package/src/index.ts +3 -0
package/dist/combobox.js
CHANGED
|
@@ -7,7 +7,8 @@ import { defaultFilter as K } from "cmdk";
|
|
|
7
7
|
import { cn as T } from "@brightlocal/ui-components/lib/utils";
|
|
8
8
|
import { useDevWarning as H } from "@brightlocal/ui-components/lib/use-dev-warning";
|
|
9
9
|
import { Popover as re, PopoverContent as ne, PopoverTrigger as ae } from "@brightlocal/ui-components/popover";
|
|
10
|
-
import { Command as se, CommandEmpty as ie, CommandGroup as le, CommandInput as
|
|
10
|
+
import { Command as se, CommandEmpty as ie, CommandGroup as le, CommandInput as ce, CommandItem as ue, CommandList as de, CommandSeparator as fe } from "@brightlocal/ui-components/command";
|
|
11
|
+
import { Spinner as me } from "@brightlocal/ui-components/spinner";
|
|
11
12
|
const J = e.createContext(null), Q = e.createContext(null);
|
|
12
13
|
function _() {
|
|
13
14
|
const t = e.useContext(J);
|
|
@@ -15,7 +16,7 @@ function _() {
|
|
|
15
16
|
throw new Error("Combobox components must be used within a <Combobox>");
|
|
16
17
|
return t;
|
|
17
18
|
}
|
|
18
|
-
function
|
|
19
|
+
function Te({
|
|
19
20
|
value: t,
|
|
20
21
|
onValueChange: r,
|
|
21
22
|
open: a,
|
|
@@ -23,21 +24,21 @@ function Fe({
|
|
|
23
24
|
onClose: s,
|
|
24
25
|
shouldFilter: f = !0,
|
|
25
26
|
disabled: l = !1,
|
|
26
|
-
itemToStringValue:
|
|
27
|
-
children:
|
|
27
|
+
itemToStringValue: u,
|
|
28
|
+
children: b
|
|
28
29
|
}) {
|
|
29
|
-
const [v, D] = e.useState(""), [
|
|
30
|
+
const [v, D] = e.useState(""), [g, m] = e.useState(!1), [S, E] = e.useState(
|
|
30
31
|
() => /* @__PURE__ */ new Map()
|
|
31
|
-
), [C, L] = e.useState(""), [V,
|
|
32
|
-
(
|
|
33
|
-
|
|
32
|
+
), [C, L] = e.useState(""), [V, w] = e.useState(void 0), y = t !== void 0, M = a !== void 0, R = y ? t : v, k = M ? a : g, N = e.useCallback(
|
|
33
|
+
(x) => {
|
|
34
|
+
x || L(""), M || m(x), o?.(x);
|
|
34
35
|
},
|
|
35
36
|
[M, o]
|
|
36
37
|
), p = e.useCallback(
|
|
37
|
-
(
|
|
38
|
-
|
|
38
|
+
(x) => {
|
|
39
|
+
y || D(x), r?.(x);
|
|
39
40
|
},
|
|
40
|
-
[
|
|
41
|
+
[y, r]
|
|
41
42
|
), I = e.useRef(s);
|
|
42
43
|
e.useEffect(() => {
|
|
43
44
|
I.current = s;
|
|
@@ -48,24 +49,24 @@ function Fe({
|
|
|
48
49
|
}, [k]), e.useEffect(() => () => {
|
|
49
50
|
A.current && I.current?.();
|
|
50
51
|
}, []);
|
|
51
|
-
const
|
|
52
|
+
const c = e.useRef(/* @__PURE__ */ new Map()), F = e.useRef(!1), O = e.useRef(!0);
|
|
52
53
|
e.useEffect(() => () => {
|
|
53
54
|
O.current = !1;
|
|
54
55
|
}, []);
|
|
55
56
|
const j = e.useCallback(() => {
|
|
56
57
|
F.current || (F.current = !0, queueMicrotask(() => {
|
|
57
|
-
F.current = !1, O.current && E(new Map(
|
|
58
|
+
F.current = !1, O.current && E(new Map(c.current));
|
|
58
59
|
}));
|
|
59
60
|
}, []), $ = e.useCallback(
|
|
60
|
-
(
|
|
61
|
-
|
|
61
|
+
(x, n) => {
|
|
62
|
+
c.current.get(x) !== n && (c.current.set(x, n), j());
|
|
62
63
|
},
|
|
63
64
|
[j]
|
|
64
65
|
), z = e.useCallback(
|
|
65
|
-
(
|
|
66
|
-
for (const [n, i] of
|
|
67
|
-
|
|
68
|
-
E(new Map(
|
|
66
|
+
(x) => {
|
|
67
|
+
for (const [n, i] of x)
|
|
68
|
+
c.current.set(n, i);
|
|
69
|
+
E(new Map(c.current));
|
|
69
70
|
},
|
|
70
71
|
[]
|
|
71
72
|
), q = e.useRef(R);
|
|
@@ -73,13 +74,13 @@ function Fe({
|
|
|
73
74
|
q.current = R;
|
|
74
75
|
}, [R]);
|
|
75
76
|
const U = e.useCallback(
|
|
76
|
-
(
|
|
77
|
-
|
|
77
|
+
(x) => {
|
|
78
|
+
x !== q.current && c.current.has(x) && (c.current.delete(x), j());
|
|
78
79
|
},
|
|
79
80
|
[j]
|
|
80
81
|
), G = e.useMemo(
|
|
81
|
-
() =>
|
|
82
|
-
[
|
|
82
|
+
() => u ? (x, n, i) => K(u(x), n, i) : K,
|
|
83
|
+
[u]
|
|
83
84
|
), W = e.useMemo(
|
|
84
85
|
() => ({
|
|
85
86
|
open: k,
|
|
@@ -92,12 +93,12 @@ function Fe({
|
|
|
92
93
|
registerItem: $,
|
|
93
94
|
registerItemsSync: z,
|
|
94
95
|
unregisterItem: U,
|
|
95
|
-
itemToStringValue:
|
|
96
|
+
itemToStringValue: u,
|
|
96
97
|
filterFn: G,
|
|
97
98
|
searchValue: C,
|
|
98
99
|
setSearchValue: L,
|
|
99
100
|
activeDescendantId: V,
|
|
100
|
-
setActiveDescendantId:
|
|
101
|
+
setActiveDescendantId: w
|
|
101
102
|
}),
|
|
102
103
|
[
|
|
103
104
|
k,
|
|
@@ -110,14 +111,14 @@ function Fe({
|
|
|
110
111
|
$,
|
|
111
112
|
z,
|
|
112
113
|
U,
|
|
113
|
-
|
|
114
|
+
u,
|
|
114
115
|
G,
|
|
115
116
|
C,
|
|
116
117
|
V,
|
|
117
|
-
|
|
118
|
+
w
|
|
118
119
|
]
|
|
119
120
|
);
|
|
120
|
-
return /* @__PURE__ */ d(J.Provider, { value: W, children: /* @__PURE__ */ d(re, { open: k, onOpenChange: N, children:
|
|
121
|
+
return /* @__PURE__ */ d(J.Provider, { value: W, children: /* @__PURE__ */ d(re, { open: k, onOpenChange: N, children: b }) });
|
|
121
122
|
}
|
|
122
123
|
const be = oe([
|
|
123
124
|
// Base layout
|
|
@@ -142,7 +143,7 @@ const be = oe([
|
|
|
142
143
|
"transition-[background-color,border-color,box-shadow] duration-fast ease-out",
|
|
143
144
|
// Icon styles
|
|
144
145
|
"[&_svg]:pointer-events-none [&_svg]:shrink-0"
|
|
145
|
-
]),
|
|
146
|
+
]), pe = e.forwardRef(
|
|
146
147
|
({
|
|
147
148
|
className: t,
|
|
148
149
|
dataHook: r,
|
|
@@ -151,14 +152,14 @@ const be = oe([
|
|
|
151
152
|
trackingLabel: s,
|
|
152
153
|
children: f,
|
|
153
154
|
...l
|
|
154
|
-
},
|
|
155
|
-
const { open:
|
|
155
|
+
}, u) => {
|
|
156
|
+
const { open: b, disabled: v, value: D } = _(), g = e.useId(), m = !D, S = a || l["aria-invalid"] === !0 || l["aria-invalid"] === "true";
|
|
156
157
|
return /* @__PURE__ */ d(ae, { asChild: !0, children: /* @__PURE__ */ B(
|
|
157
158
|
"button",
|
|
158
159
|
{
|
|
159
|
-
ref:
|
|
160
|
-
"aria-controls":
|
|
161
|
-
"aria-expanded":
|
|
160
|
+
ref: u,
|
|
161
|
+
"aria-controls": b ? g : void 0,
|
|
162
|
+
"aria-expanded": b,
|
|
162
163
|
"aria-haspopup": "listbox",
|
|
163
164
|
"aria-invalid": S ? "true" : void 0,
|
|
164
165
|
className: T(
|
|
@@ -167,9 +168,9 @@ const be = oe([
|
|
|
167
168
|
t
|
|
168
169
|
),
|
|
169
170
|
"data-hook": r,
|
|
170
|
-
"data-placeholder":
|
|
171
|
+
"data-placeholder": m,
|
|
171
172
|
"data-slot": "combobox-trigger",
|
|
172
|
-
"data-state":
|
|
173
|
+
"data-state": b ? "open" : "closed",
|
|
173
174
|
"data-tracking-el": o || "combobox-trigger",
|
|
174
175
|
"data-tracking-label": s,
|
|
175
176
|
disabled: v || l.disabled,
|
|
@@ -190,8 +191,8 @@ const be = oe([
|
|
|
190
191
|
) });
|
|
191
192
|
}
|
|
192
193
|
);
|
|
193
|
-
|
|
194
|
-
function
|
|
194
|
+
pe.displayName = "ComboboxTrigger";
|
|
195
|
+
function ge(t) {
|
|
195
196
|
return t != null && typeof t == "object" && "value" in t && typeof t.value == "string";
|
|
196
197
|
}
|
|
197
198
|
function X(t, r, a) {
|
|
@@ -202,15 +203,15 @@ function X(t, r, a) {
|
|
|
202
203
|
hasDistinctLabel: !!a
|
|
203
204
|
};
|
|
204
205
|
const o = t[0];
|
|
205
|
-
if (!
|
|
206
|
-
const s = (
|
|
206
|
+
if (!ge(o)) return null;
|
|
207
|
+
const s = (u) => u.value, f = "label" in o && typeof o.label == "string";
|
|
207
208
|
return {
|
|
208
209
|
getValue: s,
|
|
209
|
-
getLabel: a ?? (f ? (
|
|
210
|
+
getLabel: a ?? (f ? (u) => String(u.label) : s),
|
|
210
211
|
hasDistinctLabel: f || !!a
|
|
211
212
|
};
|
|
212
213
|
}
|
|
213
|
-
function
|
|
214
|
+
function $e({
|
|
214
215
|
placeholder: t,
|
|
215
216
|
className: r,
|
|
216
217
|
displayValue: a,
|
|
@@ -218,18 +219,18 @@ function Ae({
|
|
|
218
219
|
getItemValue: s,
|
|
219
220
|
getItemLabel: f
|
|
220
221
|
}) {
|
|
221
|
-
const { value: l, itemLabels:
|
|
222
|
+
const { value: l, itemLabels: u } = _(), b = e.useMemo(
|
|
222
223
|
() => o ? X(o, s, f) : null,
|
|
223
224
|
[o, s, f]
|
|
224
225
|
);
|
|
225
226
|
H(
|
|
226
|
-
() => !!o && o.length > 0 && !
|
|
227
|
+
() => !!o && o.length > 0 && !b,
|
|
227
228
|
"ComboboxValue: could not infer `getItemValue` from item shape. Pass `getItemValue` explicitly, or use items with a `value` string property.",
|
|
228
|
-
[o,
|
|
229
|
+
[o, b]
|
|
229
230
|
);
|
|
230
|
-
const v = e.useMemo(() => !o || !
|
|
231
|
-
o.map((
|
|
232
|
-
), [o,
|
|
231
|
+
const v = e.useMemo(() => !o || !b ? null : new Map(
|
|
232
|
+
o.map((g) => [b.getValue(g), b.getLabel(g)])
|
|
233
|
+
), [o, b]), D = l ? v?.get(l) || u.get(l) || a?.(l) || l : t;
|
|
233
234
|
return /* @__PURE__ */ d(
|
|
234
235
|
"span",
|
|
235
236
|
{
|
|
@@ -242,7 +243,7 @@ function Ae({
|
|
|
242
243
|
}
|
|
243
244
|
);
|
|
244
245
|
}
|
|
245
|
-
function
|
|
246
|
+
function Oe({
|
|
246
247
|
dataHook: t,
|
|
247
248
|
className: r,
|
|
248
249
|
children: a,
|
|
@@ -250,46 +251,46 @@ function Te({
|
|
|
250
251
|
side: s = "bottom",
|
|
251
252
|
sideOffset: f,
|
|
252
253
|
avoidCollisions: l,
|
|
253
|
-
hideList:
|
|
254
|
-
ariaLabel:
|
|
254
|
+
hideList: u = !1,
|
|
255
|
+
ariaLabel: b
|
|
255
256
|
}) {
|
|
256
|
-
const { open: v, shouldFilter: D, filterFn:
|
|
257
|
+
const { open: v, shouldFilter: D, filterFn: g, itemToStringValue: m } = _(), [S, E] = e.useState(
|
|
257
258
|
null
|
|
258
|
-
), C = e.useRef(null), L = e.useCallback((
|
|
259
|
-
if (C.current?.(), C.current = null, !
|
|
260
|
-
let
|
|
259
|
+
), C = e.useRef(null), L = e.useCallback((w) => {
|
|
260
|
+
if (C.current?.(), C.current = null, !w) return;
|
|
261
|
+
let y = !1;
|
|
261
262
|
const M = (p) => {
|
|
262
|
-
|
|
263
|
+
y || (p === "top" || p === "bottom") && (y = !0, R.disconnect(), E(p));
|
|
263
264
|
}, R = new MutationObserver(() => {
|
|
264
|
-
M(
|
|
265
|
+
M(w.getAttribute("data-side"));
|
|
265
266
|
});
|
|
266
|
-
R.observe(
|
|
267
|
+
R.observe(w, {
|
|
267
268
|
attributes: !0,
|
|
268
269
|
attributeFilter: ["data-side"]
|
|
269
270
|
});
|
|
270
271
|
let k = 0, N = 0;
|
|
271
272
|
k = requestAnimationFrame(() => {
|
|
272
273
|
N = requestAnimationFrame(() => {
|
|
273
|
-
M(
|
|
274
|
+
M(w.getAttribute("data-side"));
|
|
274
275
|
});
|
|
275
276
|
}), C.current = () => {
|
|
276
|
-
|
|
277
|
+
y = !0, R.disconnect(), cancelAnimationFrame(k), cancelAnimationFrame(N);
|
|
277
278
|
};
|
|
278
279
|
}, []);
|
|
279
280
|
e.useEffect(() => {
|
|
280
281
|
if (!v) {
|
|
281
282
|
C.current?.(), C.current = null;
|
|
282
|
-
const
|
|
283
|
-
return () => clearTimeout(
|
|
283
|
+
const w = setTimeout(() => E(null), 150);
|
|
284
|
+
return () => clearTimeout(w);
|
|
284
285
|
}
|
|
285
286
|
}, [v]);
|
|
286
|
-
const V =
|
|
287
|
+
const V = m ? g : void 0;
|
|
287
288
|
return /* @__PURE__ */ d(
|
|
288
289
|
ne,
|
|
289
290
|
{
|
|
290
291
|
ref: L,
|
|
291
292
|
align: o,
|
|
292
|
-
"aria-label":
|
|
293
|
+
"aria-label": b ?? "Options",
|
|
293
294
|
avoidCollisions: l,
|
|
294
295
|
className: T(
|
|
295
296
|
"flex max-h-[var(--radix-popover-content-available-height)] w-[var(--radix-popover-trigger-width)] flex-col overflow-hidden p-0",
|
|
@@ -305,7 +306,7 @@ function Te({
|
|
|
305
306
|
className: T(
|
|
306
307
|
"min-h-0 flex-1 border-0 shadow-none",
|
|
307
308
|
"[&_[data-slot='command-input-wrapper']]:shrink-0",
|
|
308
|
-
|
|
309
|
+
u && "[&_[data-slot='command-input-wrapper']]:border-b-0"
|
|
309
310
|
),
|
|
310
311
|
"data-slot": "combobox-command",
|
|
311
312
|
dataHook: t || "combobox-command",
|
|
@@ -318,7 +319,7 @@ function Te({
|
|
|
318
319
|
);
|
|
319
320
|
}
|
|
320
321
|
const xe = e.forwardRef(({ debounceMs: t, onValueChange: r, ...a }, o) => {
|
|
321
|
-
const { setSearchValue: s, shouldFilter: f, activeDescendantId: l } = _(),
|
|
322
|
+
const { setSearchValue: s, shouldFilter: f, activeDescendantId: l } = _(), u = e.useRef(
|
|
322
323
|
void 0
|
|
323
324
|
);
|
|
324
325
|
H(
|
|
@@ -332,23 +333,23 @@ Set shouldFilter={false} on <Combobox> for async search, or remove debounceMs fo
|
|
|
332
333
|
"debounceMs is set on <ComboboxInput> together with a controlled `value` prop.\nThe debounced onValueChange callback cannot update the controlled value synchronously, so the input will appear to lag behind typing.\nRemove `value` to let the input manage its own display, or remove debounceMs if you need a controlled input.",
|
|
333
334
|
[t, a.value]
|
|
334
335
|
), e.useEffect(() => () => {
|
|
335
|
-
|
|
336
|
+
u.current && clearTimeout(u.current);
|
|
336
337
|
}, []);
|
|
337
|
-
const
|
|
338
|
+
const b = e.useCallback(
|
|
338
339
|
(v) => {
|
|
339
|
-
s(v), t && t > 0 ? (clearTimeout(
|
|
340
|
+
s(v), t && t > 0 ? (clearTimeout(u.current), u.current = setTimeout(() => {
|
|
340
341
|
r?.(v);
|
|
341
342
|
}, t)) : r?.(v);
|
|
342
343
|
},
|
|
343
344
|
[t, r, s]
|
|
344
345
|
);
|
|
345
346
|
return /* @__PURE__ */ d(
|
|
346
|
-
|
|
347
|
+
ce,
|
|
347
348
|
{
|
|
348
349
|
ref: o,
|
|
349
350
|
"aria-activedescendant": l,
|
|
350
351
|
"data-slot": "combobox-input",
|
|
351
|
-
onValueChange:
|
|
352
|
+
onValueChange: b,
|
|
352
353
|
...a
|
|
353
354
|
}
|
|
354
355
|
);
|
|
@@ -364,7 +365,7 @@ const he = e.forwardRef(({ className: t, ...r }, a) => /* @__PURE__ */ d(
|
|
|
364
365
|
}
|
|
365
366
|
));
|
|
366
367
|
he.displayName = "ComboboxList";
|
|
367
|
-
function
|
|
368
|
+
function ve({
|
|
368
369
|
items: t,
|
|
369
370
|
getItemValue: r,
|
|
370
371
|
getItemLabel: a,
|
|
@@ -372,37 +373,37 @@ function ge({
|
|
|
372
373
|
estimateSize: s = 36,
|
|
373
374
|
overscan: f = 5,
|
|
374
375
|
children: l,
|
|
375
|
-
renderEmpty:
|
|
376
|
-
className:
|
|
376
|
+
renderEmpty: u,
|
|
377
|
+
className: b,
|
|
377
378
|
dataHook: v
|
|
378
379
|
}, D) {
|
|
379
|
-
const
|
|
380
|
+
const g = e.useMemo(
|
|
380
381
|
() => X(t, r, a),
|
|
381
382
|
[t, r, a]
|
|
382
|
-
),
|
|
383
|
-
() =>
|
|
383
|
+
), m = e.useMemo(
|
|
384
|
+
() => g?.getValue ?? ((n) => {
|
|
384
385
|
if (typeof n == "string" || typeof n == "number")
|
|
385
386
|
return String(n);
|
|
386
387
|
throw new Error(
|
|
387
388
|
"[BrightLocal DS] ComboboxVirtualList: `getItemValue` is required for non-primitive items without a `value` property."
|
|
388
389
|
);
|
|
389
390
|
}),
|
|
390
|
-
[
|
|
391
|
+
[g]
|
|
391
392
|
), S = e.useMemo(
|
|
392
|
-
() =>
|
|
393
|
-
[
|
|
393
|
+
() => g?.getLabel ?? m,
|
|
394
|
+
[g, m]
|
|
394
395
|
);
|
|
395
396
|
H(
|
|
396
|
-
() => !
|
|
397
|
+
() => !g && t.length > 0,
|
|
397
398
|
"ComboboxVirtualList: could not infer `getItemValue` from item shape. Pass `getItemValue` explicitly, or use items with a `value` string property.",
|
|
398
|
-
[
|
|
399
|
+
[g, t.length]
|
|
399
400
|
);
|
|
400
401
|
const E = e.useRef(null), {
|
|
401
402
|
value: C,
|
|
402
403
|
onValueChange: L,
|
|
403
404
|
setOpen: V,
|
|
404
|
-
shouldFilter:
|
|
405
|
-
searchValue:
|
|
405
|
+
shouldFilter: w,
|
|
406
|
+
searchValue: y,
|
|
406
407
|
filterFn: M,
|
|
407
408
|
setActiveDescendantId: R,
|
|
408
409
|
registerItemsSync: k,
|
|
@@ -410,89 +411,89 @@ function ge({
|
|
|
410
411
|
} = _(), [p, I] = e.useState(0), A = e.useId();
|
|
411
412
|
e.useImperativeHandle(D, () => E.current, []), e.useLayoutEffect(() => {
|
|
412
413
|
const n = t.map((i) => [
|
|
413
|
-
|
|
414
|
+
m(i),
|
|
414
415
|
S(i)
|
|
415
416
|
]);
|
|
416
417
|
return k(n), () => {
|
|
417
418
|
for (const i of t)
|
|
418
|
-
N(
|
|
419
|
+
N(m(i));
|
|
419
420
|
};
|
|
420
|
-
}, [t,
|
|
421
|
-
const
|
|
422
|
-
if (!
|
|
421
|
+
}, [t, m, S, k, N]);
|
|
422
|
+
const c = e.useMemo(() => {
|
|
423
|
+
if (!w || !y.trim()) return t;
|
|
423
424
|
const n = [];
|
|
424
425
|
for (const i of t) {
|
|
425
|
-
let
|
|
426
|
+
let h = g?.hasDistinctLabel ? K(S(i), y) : M(m(i), y);
|
|
426
427
|
if (o)
|
|
427
428
|
for (const P of o(i))
|
|
428
|
-
|
|
429
|
-
|
|
429
|
+
h = Math.max(h, K(P, y));
|
|
430
|
+
h > 0 && n.push({ item: i, score: h });
|
|
430
431
|
}
|
|
431
|
-
return n.sort((i,
|
|
432
|
+
return n.sort((i, h) => h.score - i.score), n.map((i) => i.item);
|
|
432
433
|
}, [
|
|
433
434
|
t,
|
|
434
|
-
y,
|
|
435
435
|
w,
|
|
436
|
-
|
|
436
|
+
y,
|
|
437
|
+
m,
|
|
437
438
|
S,
|
|
438
439
|
o,
|
|
439
440
|
M,
|
|
440
|
-
|
|
441
|
+
g?.hasDistinctLabel
|
|
441
442
|
]), F = te({
|
|
442
|
-
count:
|
|
443
|
+
count: c.length,
|
|
443
444
|
getScrollElement: () => E.current,
|
|
444
445
|
estimateSize: () => s,
|
|
445
446
|
overscan: f
|
|
446
|
-
}), O = p >= 0 && p <
|
|
447
|
+
}), O = p >= 0 && p < c.length ? m(c[p]) : null;
|
|
447
448
|
e.useEffect(() => {
|
|
448
449
|
I(0);
|
|
449
|
-
}, [
|
|
450
|
+
}, [y, c.length]);
|
|
450
451
|
const j = e.useRef(!1);
|
|
451
452
|
e.useEffect(() => {
|
|
452
453
|
if (j.current || !C) return;
|
|
453
|
-
const n =
|
|
454
|
+
const n = c.findIndex((i) => m(i) === C);
|
|
454
455
|
n >= 0 && (I(n), F.scrollToIndex(n, { align: "center" }), j.current = !0);
|
|
455
|
-
}, [C,
|
|
456
|
+
}, [C, c, m, F]);
|
|
456
457
|
const $ = e.useRef(!1);
|
|
457
458
|
e.useEffect(() => {
|
|
458
|
-
$.current && p >= 0 && p <
|
|
459
|
-
}, [p,
|
|
459
|
+
$.current && p >= 0 && p < c.length && F.scrollToIndex(p, { align: "auto" }), $.current = !1;
|
|
460
|
+
}, [p, c.length, F]), e.useEffect(() => {
|
|
460
461
|
const n = E.current?.closest(
|
|
461
462
|
'[data-slot="combobox-command"]'
|
|
462
463
|
);
|
|
463
464
|
if (!n) return;
|
|
464
|
-
const i = (
|
|
465
|
-
switch (
|
|
465
|
+
const i = (h) => {
|
|
466
|
+
switch (h.key) {
|
|
466
467
|
case "ArrowDown":
|
|
467
|
-
|
|
468
|
-
(P) => P <
|
|
468
|
+
h.preventDefault(), h.stopPropagation(), $.current = !0, I(
|
|
469
|
+
(P) => P < c.length - 1 ? P + 1 : P
|
|
469
470
|
);
|
|
470
471
|
break;
|
|
471
472
|
case "ArrowUp":
|
|
472
|
-
|
|
473
|
+
h.preventDefault(), h.stopPropagation(), $.current = !0, I((P) => P > 0 ? P - 1 : P);
|
|
473
474
|
break;
|
|
474
475
|
case "Enter":
|
|
475
|
-
if (
|
|
476
|
-
const P =
|
|
476
|
+
if (h.preventDefault(), h.stopPropagation(), p >= 0 && p < c.length) {
|
|
477
|
+
const P = m(c[p]);
|
|
477
478
|
L(P === C ? "" : P), V(!1);
|
|
478
479
|
}
|
|
479
480
|
break;
|
|
480
481
|
case "Home":
|
|
481
|
-
|
|
482
|
+
h.preventDefault(), h.stopPropagation(), $.current = !0, I(0);
|
|
482
483
|
break;
|
|
483
484
|
case "End":
|
|
484
|
-
|
|
485
|
+
h.preventDefault(), h.stopPropagation(), $.current = !0, I(c.length - 1);
|
|
485
486
|
break;
|
|
486
487
|
}
|
|
487
488
|
};
|
|
488
489
|
return n.addEventListener("keydown", i, { capture: !0 }), () => n.removeEventListener("keydown", i, { capture: !0 });
|
|
489
|
-
}, [
|
|
490
|
+
}, [c, p, C, L, V, m]);
|
|
490
491
|
const z = e.useMemo(() => {
|
|
491
492
|
const n = /* @__PURE__ */ new Map();
|
|
492
|
-
return
|
|
493
|
-
n.set(
|
|
493
|
+
return c.forEach((i, h) => {
|
|
494
|
+
n.set(m(i), h);
|
|
494
495
|
}), n;
|
|
495
|
-
}, [
|
|
496
|
+
}, [c, m]), q = e.useCallback(
|
|
496
497
|
(n) => {
|
|
497
498
|
const i = z.get(n);
|
|
498
499
|
i !== void 0 && I(i);
|
|
@@ -501,7 +502,7 @@ function ge({
|
|
|
501
502
|
), U = e.useCallback(
|
|
502
503
|
(n) => (z.get(n) ?? 0) + 1,
|
|
503
504
|
[z]
|
|
504
|
-
), G =
|
|
505
|
+
), G = c.length, W = e.useMemo(
|
|
505
506
|
() => ({
|
|
506
507
|
activeValue: O,
|
|
507
508
|
onItemPointerMove: q,
|
|
@@ -510,19 +511,19 @@ function ge({
|
|
|
510
511
|
getItemPosition: U
|
|
511
512
|
}),
|
|
512
513
|
[O, q, A, G, U]
|
|
513
|
-
),
|
|
514
|
-
return e.useEffect(() => (R(
|
|
514
|
+
), x = O != null ? `${A}item-${O}` : void 0;
|
|
515
|
+
return e.useEffect(() => (R(x), () => R(void 0)), [x, R]), c.length === 0 ? /* @__PURE__ */ d(
|
|
515
516
|
"div",
|
|
516
517
|
{
|
|
517
518
|
ref: E,
|
|
518
519
|
className: T(
|
|
519
520
|
"scrollbar max-h-[300px] min-h-0 flex-1 scroll-py-1 overflow-x-hidden overflow-y-auto py-1",
|
|
520
|
-
|
|
521
|
+
b
|
|
521
522
|
),
|
|
522
523
|
"data-hook": v,
|
|
523
524
|
"data-slot": "combobox-virtual-list",
|
|
524
525
|
role: "listbox",
|
|
525
|
-
children:
|
|
526
|
+
children: u
|
|
526
527
|
}
|
|
527
528
|
) : /* @__PURE__ */ d(Q.Provider, { value: W, children: /* @__PURE__ */ d(
|
|
528
529
|
"div",
|
|
@@ -530,7 +531,7 @@ function ge({
|
|
|
530
531
|
ref: E,
|
|
531
532
|
className: T(
|
|
532
533
|
"scrollbar max-h-[300px] min-h-0 flex-1 scroll-py-1 overflow-x-hidden overflow-y-auto py-1",
|
|
533
|
-
|
|
534
|
+
b
|
|
534
535
|
),
|
|
535
536
|
"data-hook": v,
|
|
536
537
|
"data-slot": "combobox-virtual-list",
|
|
@@ -550,9 +551,9 @@ function ge({
|
|
|
550
551
|
transform: `translateY(${n.start}px)`
|
|
551
552
|
},
|
|
552
553
|
children: l(
|
|
553
|
-
|
|
554
|
+
c[n.index],
|
|
554
555
|
n.index,
|
|
555
|
-
|
|
556
|
+
y
|
|
556
557
|
)
|
|
557
558
|
},
|
|
558
559
|
n.key
|
|
@@ -562,9 +563,9 @@ function ge({
|
|
|
562
563
|
}
|
|
563
564
|
) });
|
|
564
565
|
}
|
|
565
|
-
const
|
|
566
|
-
|
|
567
|
-
const
|
|
566
|
+
const je = e.forwardRef(ve), Ce = e.forwardRef((t, r) => /* @__PURE__ */ d(ie, { ref: r, "data-slot": "combobox-empty", ...t }));
|
|
567
|
+
Ce.displayName = "ComboboxEmpty";
|
|
568
|
+
const ye = e.forwardRef(({ children: t, ...r }, a) => {
|
|
568
569
|
const o = e.useRef(null);
|
|
569
570
|
return H(
|
|
570
571
|
() => o.current ? o.current.querySelectorAll('[data-slot="combobox-item"]').length >= 100 : !1,
|
|
@@ -583,7 +584,7 @@ Import: import { ComboboxVirtualList } from "@brightlocal/ui-components/combobox
|
|
|
583
584
|
}
|
|
584
585
|
);
|
|
585
586
|
});
|
|
586
|
-
|
|
587
|
+
ye.displayName = "ComboboxGroup";
|
|
587
588
|
function we(t, r, a) {
|
|
588
589
|
if (!r || !r.trim())
|
|
589
590
|
return t;
|
|
@@ -595,7 +596,7 @@ function we(t, r, a) {
|
|
|
595
596
|
(f, l) => l % 2 === 1 ? /* @__PURE__ */ d("span", { className: a, children: f }, l) : /* @__PURE__ */ d(e.Fragment, { children: f }, l)
|
|
596
597
|
) });
|
|
597
598
|
}
|
|
598
|
-
const
|
|
599
|
+
const ke = e.forwardRef(
|
|
599
600
|
({
|
|
600
601
|
value: t,
|
|
601
602
|
label: r,
|
|
@@ -604,21 +605,21 @@ const ye = e.forwardRef(
|
|
|
604
605
|
className: s,
|
|
605
606
|
highlight: f,
|
|
606
607
|
highlightClassName: l,
|
|
607
|
-
keywords:
|
|
608
|
-
onSelect:
|
|
608
|
+
keywords: u,
|
|
609
|
+
onSelect: b,
|
|
609
610
|
...v
|
|
610
611
|
}, D) => {
|
|
611
|
-
const { value:
|
|
612
|
+
const { value: g, onValueChange: m, setOpen: S, registerItem: E, unregisterItem: C } = _(), L = e.useContext(Q), V = g === t, w = e.useMemo(() => r || (typeof o == "string" ? o : typeof o == "number" ? String(o) : t), [r, o, t]), y = e.useRef(E), M = e.useRef(C);
|
|
612
613
|
e.useEffect(() => {
|
|
613
|
-
|
|
614
|
+
y.current = E, M.current = C;
|
|
614
615
|
}, [E, C]);
|
|
615
616
|
const R = !!L;
|
|
616
617
|
e.useEffect(() => {
|
|
617
618
|
if (!R)
|
|
618
|
-
return
|
|
619
|
-
}, [t,
|
|
619
|
+
return y.current(t, w), () => M.current(t);
|
|
620
|
+
}, [t, w, R]);
|
|
620
621
|
const k = () => {
|
|
621
|
-
|
|
622
|
+
m(t === g ? "" : t), S(!1), b?.(t);
|
|
622
623
|
}, N = () => f && typeof o == "string" ? we(
|
|
623
624
|
o,
|
|
624
625
|
f,
|
|
@@ -665,13 +666,13 @@ const ye = e.forwardRef(
|
|
|
665
666
|
);
|
|
666
667
|
}
|
|
667
668
|
return /* @__PURE__ */ B(
|
|
668
|
-
|
|
669
|
+
ue,
|
|
669
670
|
{
|
|
670
671
|
ref: D,
|
|
671
672
|
className: T("justify-between", s),
|
|
672
673
|
"data-slot": "combobox-item",
|
|
673
674
|
dataHook: a,
|
|
674
|
-
keywords:
|
|
675
|
+
keywords: u ? [w, ...u] : [w],
|
|
675
676
|
value: t,
|
|
676
677
|
onSelect: k,
|
|
677
678
|
...v,
|
|
@@ -689,10 +690,10 @@ const ye = e.forwardRef(
|
|
|
689
690
|
);
|
|
690
691
|
}
|
|
691
692
|
);
|
|
692
|
-
|
|
693
|
-
const
|
|
694
|
-
|
|
695
|
-
function
|
|
693
|
+
ke.displayName = "ComboboxItem";
|
|
694
|
+
const Ie = e.forwardRef((t, r) => /* @__PURE__ */ d(fe, { ref: r, "data-slot": "combobox-separator", ...t }));
|
|
695
|
+
Ie.displayName = "ComboboxSeparator";
|
|
696
|
+
function ze({
|
|
696
697
|
className: t,
|
|
697
698
|
children: r,
|
|
698
699
|
loadingText: a
|
|
@@ -702,35 +703,34 @@ function Oe({
|
|
|
702
703
|
{
|
|
703
704
|
"aria-live": "polite",
|
|
704
705
|
className: T(
|
|
705
|
-
|
|
706
|
+
// The entrance fade doubles as a ~150ms appearance delay (`both`
|
|
707
|
+
// holds the hidden start): a fetch that resolves faster than the
|
|
708
|
+
// delay never flashes a spinner, which would read slower than no
|
|
709
|
+
// indicator at all.
|
|
710
|
+
"text-muted-foreground relative flex items-center justify-center gap-2 py-6 text-sm",
|
|
711
|
+
"animate-entrance-fade entrance-delay-1",
|
|
706
712
|
t
|
|
707
713
|
),
|
|
708
714
|
"data-slot": "combobox-loading",
|
|
709
715
|
role: "status",
|
|
710
716
|
children: r || /* @__PURE__ */ B(Z, { children: [
|
|
711
|
-
/* @__PURE__ */ d(
|
|
712
|
-
|
|
713
|
-
{
|
|
714
|
-
"aria-hidden": "true",
|
|
715
|
-
className: "size-4 animate-spin rounded-full border-2 border-current border-t-transparent [animation-duration:0.6s]"
|
|
716
|
-
}
|
|
717
|
-
),
|
|
718
|
-
a ?? "Loading..."
|
|
717
|
+
/* @__PURE__ */ d(me, { size: "md" }),
|
|
718
|
+
/* @__PURE__ */ d("span", { className: "sr-only", children: a ?? "Loading suggestions" })
|
|
719
719
|
] })
|
|
720
720
|
}
|
|
721
721
|
);
|
|
722
722
|
}
|
|
723
723
|
export {
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
724
|
+
Te as Combobox,
|
|
725
|
+
Oe as ComboboxContent,
|
|
726
|
+
Ce as ComboboxEmpty,
|
|
727
|
+
ye as ComboboxGroup,
|
|
728
728
|
xe as ComboboxInput,
|
|
729
|
-
|
|
729
|
+
ke as ComboboxItem,
|
|
730
730
|
he as ComboboxList,
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
731
|
+
ze as ComboboxLoading,
|
|
732
|
+
Ie as ComboboxSeparator,
|
|
733
|
+
pe as ComboboxTrigger,
|
|
734
|
+
$e as ComboboxValue,
|
|
735
|
+
je as ComboboxVirtualList
|
|
736
736
|
};
|