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