@brightlocal/ui-components 2.11.0 → 2.12.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/component-meta.json +163 -12
- package/dist/blocks/data-table.cjs +1 -1
- package/dist/blocks/data-table.d.ts +16 -4
- package/dist/blocks/data-table.d.ts.map +1 -1
- package/dist/blocks/data-table.js +57 -53
- package/dist/blocks/input-list.cjs +2 -2
- package/dist/blocks/input-list.d.ts +7 -1
- package/dist/blocks/input-list.d.ts.map +1 -1
- package/dist/blocks/input-list.js +82 -81
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts +18 -7
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +143 -136
- package/dist/breadcrumb.cjs +1 -1
- package/dist/breadcrumb.d.ts +14 -2
- package/dist/breadcrumb.d.ts.map +1 -1
- package/dist/breadcrumb.js +37 -37
- package/dist/callout.cjs +1 -1
- package/dist/callout.d.ts +3 -3
- package/dist/callout.d.ts.map +1 -1
- package/dist/callout.js +2 -1
- package/dist/carousel.cjs +1 -1
- package/dist/carousel.d.ts +24 -3
- package/dist/carousel.d.ts.map +1 -1
- package/dist/carousel.js +121 -117
- package/dist/chip.cjs +1 -1
- package/dist/chip.d.ts +11 -0
- package/dist/chip.d.ts.map +1 -1
- package/dist/chip.js +43 -38
- package/dist/combobox.cjs +3 -3
- package/dist/combobox.d.ts +12 -2
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +235 -230
- package/dist/command.cjs +1 -1
- package/dist/command.d.ts +5 -0
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js +207 -206
- package/dist/date-picker.cjs +1 -1
- package/dist/date-picker.d.ts +10 -0
- package/dist/date-picker.d.ts.map +1 -1
- package/dist/date-picker.js +96 -96
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.d.ts +7 -2
- package/dist/dialog.d.ts.map +1 -1
- package/dist/dialog.js +38 -30
- package/dist/drawer.d.ts +2 -2
- package/dist/global-layout.cjs +1 -1
- package/dist/global-layout.d.ts +5 -0
- package/dist/global-layout.d.ts.map +1 -1
- package/dist/global-layout.js +15 -7
- package/dist/index.cjs +1 -1
- package/dist/index.js +178 -178
- package/dist/input-chip.cjs +1 -1
- package/dist/input-chip.d.ts +7 -1
- package/dist/input-chip.d.ts.map +1 -1
- package/dist/input-chip.js +131 -130
- package/dist/input-group.d.ts +1 -1
- package/dist/input-password.cjs +1 -1
- package/dist/input-password.d.ts +10 -0
- package/dist/input-password.d.ts.map +1 -1
- package/dist/input-password.js +108 -106
- package/dist/link.cjs +1 -1
- package/dist/link.d.ts +1 -1
- package/dist/link.d.ts.map +1 -1
- package/dist/link.js +36 -37
- package/dist/list.d.ts +1 -1
- package/dist/logo.cjs +1 -1
- package/dist/logo.d.ts +6 -1
- package/dist/logo.d.ts.map +1 -1
- package/dist/logo.js +25 -22
- package/dist/map.cjs +1 -1
- package/dist/map.d.ts +17 -2
- package/dist/map.d.ts.map +1 -1
- package/dist/map.js +32 -26
- package/dist/pagination.cjs +1 -1
- package/dist/pagination.d.ts +29 -3
- package/dist/pagination.d.ts.map +1 -1
- package/dist/pagination.js +26 -25
- package/dist/rating.cjs +1 -1
- package/dist/rating.d.ts +6 -0
- package/dist/rating.d.ts.map +1 -1
- package/dist/rating.js +27 -19
- package/dist/resizable.d.ts +1 -1
- package/dist/select.cjs +2 -2
- package/dist/select.d.ts +7 -1
- package/dist/select.d.ts.map +1 -1
- package/dist/select.js +52 -51
- package/dist/separator.cjs +1 -1
- package/dist/separator.d.ts +16 -4
- package/dist/separator.d.ts.map +1 -1
- package/dist/separator.js +38 -35
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.d.ts +6 -1
- package/dist/sheet.d.ts.map +1 -1
- package/dist/sheet.js +42 -41
- package/dist/skeleton.cjs +1 -1
- package/dist/skeleton.d.ts +5 -0
- package/dist/skeleton.d.ts.map +1 -1
- package/dist/skeleton.js +13 -11
- package/dist/text-reveal-motion.cjs +1 -1
- package/dist/text-reveal-motion.d.ts +5 -0
- package/dist/text-reveal-motion.d.ts.map +1 -1
- package/dist/text-reveal-motion.js +111 -110
- package/dist/typography.cjs +1 -1
- package/dist/typography.d.ts +1 -2
- package/dist/typography.d.ts.map +1 -1
- package/dist/typography.js +49 -50
- package/package.json +2 -3
- package/src/blocks/data-table.tsx +26 -9
- package/src/blocks/input-list.tsx +12 -1
- package/src/blocks/sidebar.tsx +43 -21
- package/src/components/breadcrumb.tsx +43 -26
- package/src/components/callout.tsx +5 -4
- package/src/components/carousel.tsx +33 -4
- package/src/components/chip.tsx +22 -2
- package/src/components/combobox.tsx +18 -3
- package/src/components/command.tsx +7 -1
- package/src/components/date-picker.tsx +17 -3
- package/src/components/dialog.tsx +17 -4
- package/src/components/drawer.tsx +2 -2
- package/src/components/global-layout.tsx +15 -2
- package/src/components/input-chip.tsx +12 -1
- package/src/components/input-password.tsx +73 -49
- package/src/components/link.tsx +29 -17
- package/src/components/logo.tsx +10 -2
- package/src/components/map.tsx +23 -0
- package/src/components/pagination.tsx +44 -11
- package/src/components/rating.tsx +20 -2
- package/src/components/select.tsx +9 -1
- package/src/components/separator.tsx +40 -25
- package/src/components/sheet.tsx +28 -20
- package/src/components/skeleton.tsx +13 -2
- package/src/components/text-reveal-motion.tsx +7 -1
- package/src/components/typography.tsx +6 -7
package/dist/combobox.js
CHANGED
|
@@ -20,93 +20,93 @@ function Fe({
|
|
|
20
20
|
onValueChange: r,
|
|
21
21
|
open: n,
|
|
22
22
|
onOpenChange: o,
|
|
23
|
-
shouldFilter:
|
|
23
|
+
shouldFilter: l = !0,
|
|
24
24
|
disabled: c = !1,
|
|
25
25
|
itemToStringValue: s,
|
|
26
|
-
children:
|
|
26
|
+
children: x
|
|
27
27
|
}) {
|
|
28
|
-
const [
|
|
28
|
+
const [m, C] = t.useState(""), [S, v] = t.useState(!1), [d, y] = t.useState(
|
|
29
29
|
() => /* @__PURE__ */ new Map()
|
|
30
|
-
), [
|
|
31
|
-
(
|
|
32
|
-
|
|
30
|
+
), [I, p] = t.useState(""), [V, D] = t.useState(void 0), k = e !== void 0, w = n !== void 0, L = k ? e : m, R = w ? n : S, M = t.useCallback(
|
|
31
|
+
(g) => {
|
|
32
|
+
g || p(""), w || v(g), o?.(g);
|
|
33
33
|
},
|
|
34
|
-
[
|
|
35
|
-
),
|
|
36
|
-
(
|
|
37
|
-
|
|
34
|
+
[w, o]
|
|
35
|
+
), P = t.useCallback(
|
|
36
|
+
(g) => {
|
|
37
|
+
k || C(g), r?.(g);
|
|
38
38
|
},
|
|
39
|
-
[
|
|
40
|
-
),
|
|
39
|
+
[k, r]
|
|
40
|
+
), i = t.useRef(/* @__PURE__ */ new Map()), E = t.useRef(!1), z = t.useRef(!0);
|
|
41
41
|
t.useEffect(() => () => {
|
|
42
42
|
z.current = !1;
|
|
43
43
|
}, []);
|
|
44
|
-
const
|
|
44
|
+
const f = t.useCallback(() => {
|
|
45
45
|
E.current || (E.current = !0, queueMicrotask(() => {
|
|
46
|
-
E.current = !1, z.current && y(new Map(
|
|
46
|
+
E.current = !1, z.current && y(new Map(i.current));
|
|
47
47
|
}));
|
|
48
48
|
}, []), F = t.useCallback(
|
|
49
|
-
(
|
|
50
|
-
|
|
49
|
+
(g, $) => {
|
|
50
|
+
i.current.get(g) !== $ && (i.current.set(g, $), f());
|
|
51
51
|
},
|
|
52
|
-
[
|
|
52
|
+
[f]
|
|
53
53
|
), j = t.useCallback(
|
|
54
|
-
(
|
|
55
|
-
for (const [$, U] of
|
|
56
|
-
|
|
57
|
-
y(new Map(
|
|
54
|
+
(g) => {
|
|
55
|
+
for (const [$, U] of g)
|
|
56
|
+
i.current.set($, U);
|
|
57
|
+
y(new Map(i.current));
|
|
58
58
|
},
|
|
59
59
|
[]
|
|
60
|
-
), q = t.useRef(
|
|
60
|
+
), q = t.useRef(L);
|
|
61
61
|
t.useLayoutEffect(() => {
|
|
62
|
-
q.current =
|
|
63
|
-
}, [
|
|
62
|
+
q.current = L;
|
|
63
|
+
}, [L]);
|
|
64
64
|
const T = t.useCallback(
|
|
65
|
-
(
|
|
66
|
-
|
|
65
|
+
(g) => {
|
|
66
|
+
g !== q.current && i.current.has(g) && (i.current.delete(g), f());
|
|
67
67
|
},
|
|
68
|
-
[
|
|
68
|
+
[f]
|
|
69
69
|
), O = t.useMemo(
|
|
70
|
-
() => s ? (
|
|
70
|
+
() => s ? (g, $, U) => K(s(g), $, U) : K,
|
|
71
71
|
[s]
|
|
72
72
|
), H = t.useMemo(
|
|
73
73
|
() => ({
|
|
74
|
-
open:
|
|
74
|
+
open: R,
|
|
75
75
|
setOpen: M,
|
|
76
|
-
value:
|
|
77
|
-
onValueChange:
|
|
78
|
-
shouldFilter:
|
|
76
|
+
value: L,
|
|
77
|
+
onValueChange: P,
|
|
78
|
+
shouldFilter: l,
|
|
79
79
|
disabled: c,
|
|
80
|
-
itemLabels:
|
|
80
|
+
itemLabels: d,
|
|
81
81
|
registerItem: F,
|
|
82
82
|
registerItemsSync: j,
|
|
83
83
|
unregisterItem: T,
|
|
84
84
|
itemToStringValue: s,
|
|
85
85
|
filterFn: O,
|
|
86
|
-
searchValue:
|
|
87
|
-
setSearchValue:
|
|
88
|
-
activeDescendantId:
|
|
89
|
-
setActiveDescendantId:
|
|
86
|
+
searchValue: I,
|
|
87
|
+
setSearchValue: p,
|
|
88
|
+
activeDescendantId: V,
|
|
89
|
+
setActiveDescendantId: D
|
|
90
90
|
}),
|
|
91
91
|
[
|
|
92
|
-
L,
|
|
93
|
-
M,
|
|
94
92
|
R,
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
M,
|
|
94
|
+
L,
|
|
95
|
+
P,
|
|
96
|
+
l,
|
|
97
97
|
c,
|
|
98
|
-
|
|
98
|
+
d,
|
|
99
99
|
F,
|
|
100
100
|
j,
|
|
101
101
|
T,
|
|
102
102
|
s,
|
|
103
103
|
O,
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
I,
|
|
105
|
+
V,
|
|
106
|
+
D
|
|
107
107
|
]
|
|
108
108
|
);
|
|
109
|
-
return /* @__PURE__ */ u(J.Provider, { value: H, children: /* @__PURE__ */ u(re, { open:
|
|
109
|
+
return /* @__PURE__ */ u(J.Provider, { value: H, children: /* @__PURE__ */ u(re, { open: R, onOpenChange: M, children: x }) });
|
|
110
110
|
}
|
|
111
111
|
const be = oe([
|
|
112
112
|
// Base layout
|
|
@@ -137,17 +137,17 @@ const be = oe([
|
|
|
137
137
|
dataHook: r,
|
|
138
138
|
error: n,
|
|
139
139
|
trackingEl: o,
|
|
140
|
-
trackingLabel:
|
|
140
|
+
trackingLabel: l,
|
|
141
141
|
children: c,
|
|
142
142
|
...s
|
|
143
|
-
},
|
|
144
|
-
const { open:
|
|
143
|
+
}, x) => {
|
|
144
|
+
const { open: m, disabled: C, value: S } = _(), v = t.useId(), d = !S, y = n || s["aria-invalid"] === !0 || s["aria-invalid"] === "true";
|
|
145
145
|
return /* @__PURE__ */ u(ae, { asChild: !0, children: /* @__PURE__ */ B(
|
|
146
146
|
"button",
|
|
147
147
|
{
|
|
148
|
-
ref:
|
|
149
|
-
"aria-controls":
|
|
150
|
-
"aria-expanded":
|
|
148
|
+
ref: x,
|
|
149
|
+
"aria-controls": m ? v : void 0,
|
|
150
|
+
"aria-expanded": m,
|
|
151
151
|
"aria-haspopup": "listbox",
|
|
152
152
|
"aria-invalid": y ? "true" : void 0,
|
|
153
153
|
className: A(
|
|
@@ -156,12 +156,12 @@ const be = oe([
|
|
|
156
156
|
e
|
|
157
157
|
),
|
|
158
158
|
"data-hook": r,
|
|
159
|
-
"data-placeholder":
|
|
159
|
+
"data-placeholder": d,
|
|
160
160
|
"data-slot": "combobox-trigger",
|
|
161
|
-
"data-state":
|
|
161
|
+
"data-state": m ? "open" : "closed",
|
|
162
162
|
"data-tracking-el": o || "combobox-trigger",
|
|
163
|
-
"data-tracking-label":
|
|
164
|
-
disabled:
|
|
163
|
+
"data-tracking-label": l,
|
|
164
|
+
disabled: C || s.disabled,
|
|
165
165
|
role: "combobox",
|
|
166
166
|
type: "button",
|
|
167
167
|
...s,
|
|
@@ -192,10 +192,10 @@ function X(e, r, n) {
|
|
|
192
192
|
};
|
|
193
193
|
const o = e[0];
|
|
194
194
|
if (!pe(o)) return null;
|
|
195
|
-
const
|
|
195
|
+
const l = (x) => x.value, c = "label" in o && typeof o.label == "string";
|
|
196
196
|
return {
|
|
197
|
-
getValue:
|
|
198
|
-
getLabel: n ?? (c ? (
|
|
197
|
+
getValue: l,
|
|
198
|
+
getLabel: n ?? (c ? (x) => String(x.label) : l),
|
|
199
199
|
hasDistinctLabel: c || !!n
|
|
200
200
|
};
|
|
201
201
|
}
|
|
@@ -204,21 +204,21 @@ function Ae({
|
|
|
204
204
|
className: r,
|
|
205
205
|
displayValue: n,
|
|
206
206
|
items: o,
|
|
207
|
-
getItemValue:
|
|
207
|
+
getItemValue: l,
|
|
208
208
|
getItemLabel: c
|
|
209
209
|
}) {
|
|
210
|
-
const { value: s, itemLabels:
|
|
211
|
-
() => o ? X(o,
|
|
212
|
-
[o,
|
|
210
|
+
const { value: s, itemLabels: x } = _(), m = t.useMemo(
|
|
211
|
+
() => o ? X(o, l, c) : null,
|
|
212
|
+
[o, l, c]
|
|
213
213
|
);
|
|
214
214
|
G(
|
|
215
|
-
() => !!o && o.length > 0 && !
|
|
215
|
+
() => !!o && o.length > 0 && !m,
|
|
216
216
|
"ComboboxValue: could not infer `getItemValue` from item shape. Pass `getItemValue` explicitly, or use items with a `value` string property.",
|
|
217
|
-
[o,
|
|
217
|
+
[o, m]
|
|
218
218
|
);
|
|
219
|
-
const
|
|
220
|
-
o.map((
|
|
221
|
-
), [o,
|
|
219
|
+
const C = t.useMemo(() => !o || !m ? null : new Map(
|
|
220
|
+
o.map((v) => [m.getValue(v), m.getLabel(v)])
|
|
221
|
+
), [o, m]), S = s ? C?.get(s) || x.get(s) || n?.(s) || s : e;
|
|
222
222
|
return /* @__PURE__ */ u(
|
|
223
223
|
"span",
|
|
224
224
|
{
|
|
@@ -227,7 +227,7 @@ function Ae({
|
|
|
227
227
|
r
|
|
228
228
|
),
|
|
229
229
|
"data-slot": "combobox-value",
|
|
230
|
-
children:
|
|
230
|
+
children: S
|
|
231
231
|
}
|
|
232
232
|
);
|
|
233
233
|
}
|
|
@@ -236,48 +236,49 @@ function Te({
|
|
|
236
236
|
className: r,
|
|
237
237
|
children: n,
|
|
238
238
|
align: o = "start",
|
|
239
|
-
side:
|
|
239
|
+
side: l = "bottom",
|
|
240
240
|
sideOffset: c,
|
|
241
241
|
avoidCollisions: s,
|
|
242
|
-
hideList:
|
|
242
|
+
hideList: x = !1,
|
|
243
|
+
ariaLabel: m
|
|
243
244
|
}) {
|
|
244
|
-
const { open:
|
|
245
|
+
const { open: C, shouldFilter: S, filterFn: v, itemToStringValue: d } = _(), [y, I] = t.useState(
|
|
245
246
|
null
|
|
246
|
-
),
|
|
247
|
-
if (
|
|
248
|
-
let
|
|
249
|
-
const
|
|
250
|
-
|
|
247
|
+
), p = t.useRef(null), V = t.useCallback((k) => {
|
|
248
|
+
if (p.current?.(), p.current = null, !k) return;
|
|
249
|
+
let w = !1;
|
|
250
|
+
const L = (i) => {
|
|
251
|
+
w || (i === "top" || i === "bottom") && (w = !0, R.disconnect(), I(i));
|
|
251
252
|
}, R = new MutationObserver(() => {
|
|
252
|
-
|
|
253
|
+
L(k.getAttribute("data-side"));
|
|
253
254
|
});
|
|
254
255
|
R.observe(k, {
|
|
255
256
|
attributes: !0,
|
|
256
257
|
attributeFilter: ["data-side"]
|
|
257
258
|
});
|
|
258
|
-
let
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
259
|
+
let M = 0, P = 0;
|
|
260
|
+
M = requestAnimationFrame(() => {
|
|
261
|
+
P = requestAnimationFrame(() => {
|
|
262
|
+
L(k.getAttribute("data-side"));
|
|
262
263
|
});
|
|
263
|
-
}),
|
|
264
|
-
|
|
264
|
+
}), p.current = () => {
|
|
265
|
+
w = !0, R.disconnect(), cancelAnimationFrame(M), cancelAnimationFrame(P);
|
|
265
266
|
};
|
|
266
267
|
}, []);
|
|
267
268
|
t.useEffect(() => {
|
|
268
|
-
if (!
|
|
269
|
-
|
|
270
|
-
const k = setTimeout(() =>
|
|
269
|
+
if (!C) {
|
|
270
|
+
p.current?.(), p.current = null;
|
|
271
|
+
const k = setTimeout(() => I(null), 150);
|
|
271
272
|
return () => clearTimeout(k);
|
|
272
273
|
}
|
|
273
|
-
}, [
|
|
274
|
-
const
|
|
274
|
+
}, [C]);
|
|
275
|
+
const D = d ? v : void 0;
|
|
275
276
|
return /* @__PURE__ */ u(
|
|
276
277
|
ne,
|
|
277
278
|
{
|
|
278
|
-
ref:
|
|
279
|
+
ref: V,
|
|
279
280
|
align: o,
|
|
280
|
-
"aria-label": "Options",
|
|
281
|
+
"aria-label": m ?? "Options",
|
|
281
282
|
avoidCollisions: s,
|
|
282
283
|
className: A(
|
|
283
284
|
"flex max-h-[var(--radix-popover-content-available-height)] w-[var(--radix-popover-trigger-width)] flex-col overflow-hidden p-0",
|
|
@@ -285,7 +286,7 @@ function Te({
|
|
|
285
286
|
),
|
|
286
287
|
collisionPadding: 4,
|
|
287
288
|
"data-slot": "combobox-popover",
|
|
288
|
-
side:
|
|
289
|
+
side: y ?? l,
|
|
289
290
|
sideOffset: c,
|
|
290
291
|
children: /* @__PURE__ */ u(
|
|
291
292
|
se,
|
|
@@ -293,12 +294,12 @@ function Te({
|
|
|
293
294
|
className: A(
|
|
294
295
|
"min-h-0 flex-1 border-0 shadow-none",
|
|
295
296
|
"[&_[data-slot='command-input-wrapper']]:shrink-0",
|
|
296
|
-
|
|
297
|
+
x && "[&_[data-slot='command-input-wrapper']]:border-b-0"
|
|
297
298
|
),
|
|
298
299
|
"data-slot": "combobox-command",
|
|
299
300
|
dataHook: e || "combobox-command",
|
|
300
|
-
filter:
|
|
301
|
-
shouldFilter:
|
|
301
|
+
filter: D,
|
|
302
|
+
shouldFilter: S,
|
|
302
303
|
children: n
|
|
303
304
|
}
|
|
304
305
|
)
|
|
@@ -306,7 +307,7 @@ function Te({
|
|
|
306
307
|
);
|
|
307
308
|
}
|
|
308
309
|
const xe = t.forwardRef(({ debounceMs: e, onValueChange: r, ...n }, o) => {
|
|
309
|
-
const { setSearchValue:
|
|
310
|
+
const { setSearchValue: l, shouldFilter: c, activeDescendantId: s } = _(), x = t.useRef(
|
|
310
311
|
void 0
|
|
311
312
|
);
|
|
312
313
|
G(
|
|
@@ -320,15 +321,15 @@ Set shouldFilter={false} on <Combobox> for async search, or remove debounceMs fo
|
|
|
320
321
|
"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.",
|
|
321
322
|
[e, n.value]
|
|
322
323
|
), t.useEffect(() => () => {
|
|
323
|
-
|
|
324
|
+
x.current && clearTimeout(x.current);
|
|
324
325
|
}, []);
|
|
325
|
-
const
|
|
326
|
-
(
|
|
327
|
-
|
|
328
|
-
r?.(
|
|
329
|
-
}, e)) : r?.(
|
|
326
|
+
const m = t.useCallback(
|
|
327
|
+
(C) => {
|
|
328
|
+
l(C), e && e > 0 ? (clearTimeout(x.current), x.current = setTimeout(() => {
|
|
329
|
+
r?.(C);
|
|
330
|
+
}, e)) : r?.(C);
|
|
330
331
|
},
|
|
331
|
-
[e, r,
|
|
332
|
+
[e, r, l]
|
|
332
333
|
);
|
|
333
334
|
return /* @__PURE__ */ u(
|
|
334
335
|
ue,
|
|
@@ -336,7 +337,7 @@ Set shouldFilter={false} on <Combobox> for async search, or remove debounceMs fo
|
|
|
336
337
|
ref: o,
|
|
337
338
|
"aria-activedescendant": s,
|
|
338
339
|
"data-slot": "combobox-input",
|
|
339
|
-
onValueChange:
|
|
340
|
+
onValueChange: m,
|
|
340
341
|
...n
|
|
341
342
|
}
|
|
342
343
|
);
|
|
@@ -357,170 +358,170 @@ function he({
|
|
|
357
358
|
getItemValue: r,
|
|
358
359
|
getItemLabel: n,
|
|
359
360
|
getItemKeywords: o,
|
|
360
|
-
estimateSize:
|
|
361
|
+
estimateSize: l = 36,
|
|
361
362
|
overscan: c = 5,
|
|
362
363
|
children: s,
|
|
363
|
-
renderEmpty:
|
|
364
|
-
className:
|
|
365
|
-
dataHook:
|
|
366
|
-
},
|
|
367
|
-
const
|
|
364
|
+
renderEmpty: x,
|
|
365
|
+
className: m,
|
|
366
|
+
dataHook: C
|
|
367
|
+
}, S) {
|
|
368
|
+
const v = t.useMemo(
|
|
368
369
|
() => X(e, r, n),
|
|
369
370
|
[e, r, n]
|
|
370
|
-
),
|
|
371
|
-
() =>
|
|
371
|
+
), d = t.useMemo(
|
|
372
|
+
() => v?.getValue ?? ((a) => {
|
|
372
373
|
if (typeof a == "string" || typeof a == "number")
|
|
373
374
|
return String(a);
|
|
374
375
|
throw new Error(
|
|
375
376
|
"[BrightLocal DS] ComboboxVirtualList: `getItemValue` is required for non-primitive items without a `value` property."
|
|
376
377
|
);
|
|
377
378
|
}),
|
|
378
|
-
[
|
|
379
|
+
[v]
|
|
379
380
|
), y = t.useMemo(
|
|
380
|
-
() =>
|
|
381
|
-
[
|
|
381
|
+
() => v?.getLabel ?? d,
|
|
382
|
+
[v, d]
|
|
382
383
|
);
|
|
383
384
|
G(
|
|
384
|
-
() => !
|
|
385
|
+
() => !v && e.length > 0,
|
|
385
386
|
"ComboboxVirtualList: could not infer `getItemValue` from item shape. Pass `getItemValue` explicitly, or use items with a `value` string property.",
|
|
386
|
-
[
|
|
387
|
+
[v, e.length]
|
|
387
388
|
);
|
|
388
|
-
const
|
|
389
|
-
value:
|
|
390
|
-
onValueChange:
|
|
391
|
-
setOpen:
|
|
392
|
-
shouldFilter:
|
|
393
|
-
searchValue:
|
|
394
|
-
filterFn:
|
|
395
|
-
setActiveDescendantId:
|
|
389
|
+
const I = t.useRef(null), {
|
|
390
|
+
value: p,
|
|
391
|
+
onValueChange: V,
|
|
392
|
+
setOpen: D,
|
|
393
|
+
shouldFilter: k,
|
|
394
|
+
searchValue: w,
|
|
395
|
+
filterFn: L,
|
|
396
|
+
setActiveDescendantId: R,
|
|
396
397
|
registerItemsSync: M,
|
|
397
|
-
unregisterItem:
|
|
398
|
-
} = _(), [
|
|
399
|
-
t.useImperativeHandle(
|
|
400
|
-
const a = e.map((
|
|
401
|
-
|
|
402
|
-
y(
|
|
398
|
+
unregisterItem: P
|
|
399
|
+
} = _(), [i, E] = t.useState(0), z = t.useId();
|
|
400
|
+
t.useImperativeHandle(S, () => I.current, []), t.useLayoutEffect(() => {
|
|
401
|
+
const a = e.map((b) => [
|
|
402
|
+
d(b),
|
|
403
|
+
y(b)
|
|
403
404
|
]);
|
|
404
405
|
return M(a), () => {
|
|
405
|
-
for (const
|
|
406
|
-
|
|
406
|
+
for (const b of e)
|
|
407
|
+
P(d(b));
|
|
407
408
|
};
|
|
408
|
-
}, [e,
|
|
409
|
-
const
|
|
410
|
-
if (!
|
|
409
|
+
}, [e, d, y, M, P]);
|
|
410
|
+
const f = t.useMemo(() => {
|
|
411
|
+
if (!k || !w.trim()) return e;
|
|
411
412
|
const a = [];
|
|
412
|
-
for (const
|
|
413
|
-
let
|
|
413
|
+
for (const b of e) {
|
|
414
|
+
let h = v?.hasDistinctLabel ? K(y(b), w) : L(d(b), w);
|
|
414
415
|
if (o)
|
|
415
|
-
for (const
|
|
416
|
-
|
|
417
|
-
|
|
416
|
+
for (const N of o(b))
|
|
417
|
+
h = Math.max(h, K(N, w));
|
|
418
|
+
h > 0 && a.push({ item: b, score: h });
|
|
418
419
|
}
|
|
419
|
-
return a.sort((
|
|
420
|
+
return a.sort((b, h) => h.score - b.score), a.map((b) => b.item);
|
|
420
421
|
}, [
|
|
421
422
|
e,
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
423
|
+
k,
|
|
424
|
+
w,
|
|
425
|
+
d,
|
|
425
426
|
y,
|
|
426
427
|
o,
|
|
427
|
-
|
|
428
|
-
|
|
428
|
+
L,
|
|
429
|
+
v?.hasDistinctLabel
|
|
429
430
|
]), F = te({
|
|
430
|
-
count:
|
|
431
|
-
getScrollElement: () =>
|
|
432
|
-
estimateSize: () =>
|
|
431
|
+
count: f.length,
|
|
432
|
+
getScrollElement: () => I.current,
|
|
433
|
+
estimateSize: () => l,
|
|
433
434
|
overscan: c
|
|
434
|
-
}), j =
|
|
435
|
+
}), j = i >= 0 && i < f.length ? d(f[i]) : null;
|
|
435
436
|
t.useEffect(() => {
|
|
436
437
|
E(0);
|
|
437
|
-
}, [
|
|
438
|
+
}, [w, f.length]);
|
|
438
439
|
const q = t.useRef(!1);
|
|
439
440
|
t.useEffect(() => {
|
|
440
|
-
if (q.current || !
|
|
441
|
-
const a =
|
|
441
|
+
if (q.current || !p) return;
|
|
442
|
+
const a = f.findIndex((b) => d(b) === p);
|
|
442
443
|
a >= 0 && (E(a), F.scrollToIndex(a, { align: "center" }), q.current = !0);
|
|
443
|
-
}, [
|
|
444
|
+
}, [p, f, d, F]);
|
|
444
445
|
const T = t.useRef(!1);
|
|
445
446
|
t.useEffect(() => {
|
|
446
|
-
T.current &&
|
|
447
|
-
}, [
|
|
448
|
-
const a =
|
|
447
|
+
T.current && i >= 0 && i < f.length && F.scrollToIndex(i, { align: "auto" }), T.current = !1;
|
|
448
|
+
}, [i, f.length, F]), t.useEffect(() => {
|
|
449
|
+
const a = I.current?.closest(
|
|
449
450
|
'[data-slot="combobox-command"]'
|
|
450
451
|
);
|
|
451
452
|
if (!a) return;
|
|
452
|
-
const
|
|
453
|
-
switch (
|
|
453
|
+
const b = (h) => {
|
|
454
|
+
switch (h.key) {
|
|
454
455
|
case "ArrowDown":
|
|
455
|
-
|
|
456
|
-
(
|
|
456
|
+
h.preventDefault(), h.stopPropagation(), T.current = !0, E(
|
|
457
|
+
(N) => N < f.length - 1 ? N + 1 : N
|
|
457
458
|
);
|
|
458
459
|
break;
|
|
459
460
|
case "ArrowUp":
|
|
460
|
-
|
|
461
|
+
h.preventDefault(), h.stopPropagation(), T.current = !0, E((N) => N > 0 ? N - 1 : N);
|
|
461
462
|
break;
|
|
462
463
|
case "Enter":
|
|
463
|
-
if (
|
|
464
|
-
const
|
|
465
|
-
|
|
464
|
+
if (h.preventDefault(), h.stopPropagation(), i >= 0 && i < f.length) {
|
|
465
|
+
const N = d(f[i]);
|
|
466
|
+
V(N === p ? "" : N), D(!1);
|
|
466
467
|
}
|
|
467
468
|
break;
|
|
468
469
|
case "Home":
|
|
469
|
-
|
|
470
|
+
h.preventDefault(), h.stopPropagation(), T.current = !0, E(0);
|
|
470
471
|
break;
|
|
471
472
|
case "End":
|
|
472
|
-
|
|
473
|
+
h.preventDefault(), h.stopPropagation(), T.current = !0, E(f.length - 1);
|
|
473
474
|
break;
|
|
474
475
|
}
|
|
475
476
|
};
|
|
476
|
-
return a.addEventListener("keydown",
|
|
477
|
-
}, [
|
|
477
|
+
return a.addEventListener("keydown", b, { capture: !0 }), () => a.removeEventListener("keydown", b, { capture: !0 });
|
|
478
|
+
}, [f, i, p, V, D, d]);
|
|
478
479
|
const O = t.useMemo(() => {
|
|
479
480
|
const a = /* @__PURE__ */ new Map();
|
|
480
|
-
return
|
|
481
|
-
a.set(
|
|
481
|
+
return f.forEach((b, h) => {
|
|
482
|
+
a.set(d(b), h);
|
|
482
483
|
}), a;
|
|
483
|
-
}, [
|
|
484
|
+
}, [f, d]), H = t.useCallback(
|
|
484
485
|
(a) => {
|
|
485
|
-
const
|
|
486
|
-
|
|
486
|
+
const b = O.get(a);
|
|
487
|
+
b !== void 0 && E(b);
|
|
487
488
|
},
|
|
488
489
|
[O]
|
|
489
|
-
),
|
|
490
|
+
), g = t.useCallback(
|
|
490
491
|
(a) => (O.get(a) ?? 0) + 1,
|
|
491
492
|
[O]
|
|
492
|
-
), $ =
|
|
493
|
+
), $ = f.length, U = t.useMemo(
|
|
493
494
|
() => ({
|
|
494
495
|
activeValue: j,
|
|
495
496
|
onItemPointerMove: H,
|
|
496
497
|
idPrefix: z,
|
|
497
498
|
filteredCount: $,
|
|
498
|
-
getItemPosition:
|
|
499
|
+
getItemPosition: g
|
|
499
500
|
}),
|
|
500
|
-
[j, H, z, $,
|
|
501
|
+
[j, H, z, $, g]
|
|
501
502
|
), W = j != null ? `${z}item-${j}` : void 0;
|
|
502
|
-
return t.useEffect(() => (
|
|
503
|
+
return t.useEffect(() => (R(W), () => R(void 0)), [W, R]), f.length === 0 ? /* @__PURE__ */ u(
|
|
503
504
|
"div",
|
|
504
505
|
{
|
|
505
|
-
ref:
|
|
506
|
+
ref: I,
|
|
506
507
|
className: A(
|
|
507
508
|
"scrollbar max-h-[300px] min-h-0 flex-1 scroll-py-1 overflow-x-hidden overflow-y-auto py-1",
|
|
508
|
-
|
|
509
|
+
m
|
|
509
510
|
),
|
|
510
|
-
"data-hook":
|
|
511
|
+
"data-hook": C,
|
|
511
512
|
"data-slot": "combobox-virtual-list",
|
|
512
513
|
role: "listbox",
|
|
513
|
-
children:
|
|
514
|
+
children: x
|
|
514
515
|
}
|
|
515
516
|
) : /* @__PURE__ */ u(Q.Provider, { value: U, children: /* @__PURE__ */ u(
|
|
516
517
|
"div",
|
|
517
518
|
{
|
|
518
|
-
ref:
|
|
519
|
+
ref: I,
|
|
519
520
|
className: A(
|
|
520
521
|
"scrollbar max-h-[300px] min-h-0 flex-1 scroll-py-1 overflow-x-hidden overflow-y-auto py-1",
|
|
521
|
-
|
|
522
|
+
m
|
|
522
523
|
),
|
|
523
|
-
"data-hook":
|
|
524
|
+
"data-hook": C,
|
|
524
525
|
"data-slot": "combobox-virtual-list",
|
|
525
526
|
role: "listbox",
|
|
526
527
|
children: /* @__PURE__ */ u(
|
|
@@ -538,9 +539,9 @@ function he({
|
|
|
538
539
|
transform: `translateY(${a.start}px)`
|
|
539
540
|
},
|
|
540
541
|
children: s(
|
|
541
|
-
|
|
542
|
+
f[a.index],
|
|
542
543
|
a.index,
|
|
543
|
-
|
|
544
|
+
w
|
|
544
545
|
)
|
|
545
546
|
},
|
|
546
547
|
a.key
|
|
@@ -562,8 +563,8 @@ Import: import { ComboboxVirtualList } from "@brightlocal/ui-components/combobox
|
|
|
562
563
|
), /* @__PURE__ */ u(
|
|
563
564
|
le,
|
|
564
565
|
{
|
|
565
|
-
ref: (
|
|
566
|
-
o.current =
|
|
566
|
+
ref: (l) => {
|
|
567
|
+
o.current = l, typeof n == "function" ? n(l) : n && (n.current = l);
|
|
567
568
|
},
|
|
568
569
|
"data-slot": "combobox-group",
|
|
569
570
|
...r,
|
|
@@ -578,8 +579,8 @@ function we(e, r, n) {
|
|
|
578
579
|
const o = new RegExp(
|
|
579
580
|
`(${r.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})`,
|
|
580
581
|
"gi"
|
|
581
|
-
),
|
|
582
|
-
return /* @__PURE__ */ u("span", { children:
|
|
582
|
+
), l = e.split(o);
|
|
583
|
+
return /* @__PURE__ */ u("span", { children: l.map(
|
|
583
584
|
(c, s) => s % 2 === 1 ? /* @__PURE__ */ u("span", { className: n, children: c }, s) : /* @__PURE__ */ u(t.Fragment, { children: c }, s)
|
|
584
585
|
) });
|
|
585
586
|
}
|
|
@@ -589,58 +590,58 @@ const ye = t.forwardRef(
|
|
|
589
590
|
label: r,
|
|
590
591
|
dataHook: n,
|
|
591
592
|
children: o,
|
|
592
|
-
className:
|
|
593
|
+
className: l,
|
|
593
594
|
highlight: c,
|
|
594
595
|
highlightClassName: s,
|
|
595
|
-
keywords:
|
|
596
|
-
...
|
|
597
|
-
},
|
|
598
|
-
const { value:
|
|
596
|
+
keywords: x,
|
|
597
|
+
...m
|
|
598
|
+
}, C) => {
|
|
599
|
+
const { value: S, onValueChange: v, setOpen: d, registerItem: y, unregisterItem: I } = _(), p = t.useContext(Q), V = S === e, D = t.useMemo(() => r || (typeof o == "string" ? o : typeof o == "number" ? String(o) : e), [r, o, e]), k = t.useRef(y), w = t.useRef(I);
|
|
599
600
|
t.useEffect(() => {
|
|
600
|
-
|
|
601
|
-
}, [y,
|
|
602
|
-
const
|
|
601
|
+
k.current = y, w.current = I;
|
|
602
|
+
}, [y, I]);
|
|
603
|
+
const L = !!p;
|
|
603
604
|
t.useEffect(() => {
|
|
604
|
-
if (!
|
|
605
|
-
return
|
|
606
|
-
}, [e,
|
|
607
|
-
const
|
|
608
|
-
|
|
605
|
+
if (!L)
|
|
606
|
+
return k.current(e, D), () => w.current(e);
|
|
607
|
+
}, [e, D, L]);
|
|
608
|
+
const R = () => {
|
|
609
|
+
v(e === S ? "" : e), d(!1);
|
|
609
610
|
}, M = () => c && typeof o == "string" ? we(
|
|
610
611
|
o,
|
|
611
612
|
c,
|
|
612
613
|
s || "text-sm leading-normal font-semibold"
|
|
613
614
|
) : o;
|
|
614
|
-
if (
|
|
615
|
-
const
|
|
615
|
+
if (p) {
|
|
616
|
+
const P = p.activeValue === e, i = !!m.disabled;
|
|
616
617
|
return /* @__PURE__ */ B(
|
|
617
618
|
"div",
|
|
618
619
|
{
|
|
619
|
-
ref:
|
|
620
|
-
"aria-disabled":
|
|
621
|
-
"aria-posinset":
|
|
622
|
-
"aria-selected":
|
|
623
|
-
"aria-setsize":
|
|
620
|
+
ref: C,
|
|
621
|
+
"aria-disabled": i || void 0,
|
|
622
|
+
"aria-posinset": p.getItemPosition(e),
|
|
623
|
+
"aria-selected": V,
|
|
624
|
+
"aria-setsize": p.filteredCount,
|
|
624
625
|
className: A(
|
|
625
626
|
"data-[highlighted=true]:bg-accent data-[highlighted=true]:text-accent-foreground relative flex cursor-default items-center justify-between gap-2 rounded-sm px-2 py-3 text-sm outline-hidden select-none",
|
|
626
627
|
"[&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
627
|
-
|
|
628
|
-
|
|
628
|
+
i && "pointer-events-none opacity-50",
|
|
629
|
+
l
|
|
629
630
|
),
|
|
630
|
-
"data-highlighted":
|
|
631
|
+
"data-highlighted": P || void 0,
|
|
631
632
|
"data-hook": n,
|
|
632
633
|
"data-slot": "combobox-item",
|
|
633
|
-
id: `${
|
|
634
|
+
id: `${p.idPrefix}item-${e}`,
|
|
634
635
|
role: "option",
|
|
635
636
|
tabIndex: -1,
|
|
636
|
-
onClick:
|
|
637
|
-
onKeyDown:
|
|
638
|
-
(E.key === "Enter" || E.key === " ") &&
|
|
637
|
+
onClick: i ? void 0 : R,
|
|
638
|
+
onKeyDown: i ? void 0 : (E) => {
|
|
639
|
+
(E.key === "Enter" || E.key === " ") && R();
|
|
639
640
|
},
|
|
640
|
-
onPointerMove:
|
|
641
|
+
onPointerMove: i ? void 0 : () => p.onItemPointerMove(e),
|
|
641
642
|
children: [
|
|
642
643
|
M(),
|
|
643
|
-
|
|
644
|
+
V && /* @__PURE__ */ u(
|
|
644
645
|
Y,
|
|
645
646
|
{
|
|
646
647
|
"aria-hidden": "true",
|
|
@@ -654,17 +655,17 @@ const ye = t.forwardRef(
|
|
|
654
655
|
return /* @__PURE__ */ B(
|
|
655
656
|
ce,
|
|
656
657
|
{
|
|
657
|
-
ref:
|
|
658
|
-
className: A("justify-between",
|
|
658
|
+
ref: C,
|
|
659
|
+
className: A("justify-between", l),
|
|
659
660
|
"data-slot": "combobox-item",
|
|
660
661
|
dataHook: n,
|
|
661
|
-
keywords:
|
|
662
|
+
keywords: x ? [D, ...x] : [D],
|
|
662
663
|
value: e,
|
|
663
|
-
onSelect:
|
|
664
|
-
...
|
|
664
|
+
onSelect: R,
|
|
665
|
+
...m,
|
|
665
666
|
children: [
|
|
666
667
|
M(),
|
|
667
|
-
|
|
668
|
+
V && /* @__PURE__ */ u(
|
|
668
669
|
Y,
|
|
669
670
|
{
|
|
670
671
|
"aria-hidden": "true",
|
|
@@ -679,7 +680,11 @@ const ye = t.forwardRef(
|
|
|
679
680
|
ye.displayName = "ComboboxItem";
|
|
680
681
|
const ke = t.forwardRef((e, r) => /* @__PURE__ */ u(fe, { ref: r, "data-slot": "combobox-separator", ...e }));
|
|
681
682
|
ke.displayName = "ComboboxSeparator";
|
|
682
|
-
function je({
|
|
683
|
+
function je({
|
|
684
|
+
className: e,
|
|
685
|
+
children: r,
|
|
686
|
+
loadingText: n
|
|
687
|
+
}) {
|
|
683
688
|
return /* @__PURE__ */ u(
|
|
684
689
|
"div",
|
|
685
690
|
{
|
|
@@ -698,7 +703,7 @@ function je({ className: e, children: r }) {
|
|
|
698
703
|
className: "size-4 animate-spin rounded-full border-2 border-current border-t-transparent [animation-duration:0.6s]"
|
|
699
704
|
}
|
|
700
705
|
),
|
|
701
|
-
"Loading..."
|
|
706
|
+
n ?? "Loading..."
|
|
702
707
|
] })
|
|
703
708
|
}
|
|
704
709
|
);
|