@brightlocal/ui-components 2.11.0 → 2.13.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 +474 -27
- 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 +221 -11
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +687 -406
- 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 +20 -2
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +244 -238
- 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/dropdown-menu.cjs +1 -1
- package/dist/dropdown-menu.js +1 -1
- 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 +313 -305
- 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.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/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/popover.cjs +1 -1
- package/dist/popover.js +7 -7
- 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 +28 -20
- package/dist/resizable.d.ts +1 -1
- package/dist/select.cjs +2 -2
- package/dist/select.d.ts +17 -3
- package/dist/select.d.ts.map +1 -1
- package/dist/select.js +65 -58
- 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/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/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 +638 -29
- 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 +28 -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/dropdown-menu.tsx +1 -1
- 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/list.tsx +45 -2
- package/src/components/logo.tsx +10 -2
- package/src/components/map.tsx +23 -0
- package/src/components/pagination.tsx +44 -11
- package/src/components/popover.tsx +1 -1
- package/src/components/rating.tsx +21 -3
- package/src/components/select.tsx +33 -3
- package/src/components/separator.tsx +40 -25
- package/src/components/sheet.tsx +28 -20
- package/src/components/skeleton.tsx +13 -2
- package/src/components/table.tsx +39 -2
- package/src/components/tabs.tsx +195 -146
- package/src/components/text-reveal-motion.tsx +7 -1
- package/src/components/typography.tsx +6 -7
package/dist/combobox.js
CHANGED
|
@@ -23,90 +23,90 @@ function Fe({
|
|
|
23
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
|
-
), [
|
|
31
|
-
(
|
|
32
|
-
|
|
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
|
+
(g) => {
|
|
32
|
+
g || C(""), y || x(g), o?.(g);
|
|
33
33
|
},
|
|
34
|
-
[
|
|
35
|
-
),
|
|
36
|
-
(
|
|
37
|
-
|
|
34
|
+
[y, o]
|
|
35
|
+
), V = t.useCallback(
|
|
36
|
+
(g) => {
|
|
37
|
+
w || v(g), r?.(g);
|
|
38
38
|
},
|
|
39
|
-
[
|
|
40
|
-
), l = t.useRef(/* @__PURE__ */ new Map()),
|
|
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
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
const f = t.useCallback(() => {
|
|
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
|
-
(
|
|
50
|
-
l.current.get(
|
|
49
|
+
(g, j) => {
|
|
50
|
+
l.current.get(g) !== j && (l.current.set(g, j), f());
|
|
51
51
|
},
|
|
52
|
-
[
|
|
53
|
-
),
|
|
54
|
-
(
|
|
55
|
-
for (const [
|
|
56
|
-
l.current.set(
|
|
57
|
-
|
|
52
|
+
[f]
|
|
53
|
+
), O = t.useCallback(
|
|
54
|
+
(g) => {
|
|
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
|
|
65
|
-
(
|
|
66
|
-
|
|
62
|
+
q.current = E;
|
|
63
|
+
}, [E]);
|
|
64
|
+
const $ = t.useCallback(
|
|
65
|
+
(g) => {
|
|
66
|
+
g !== q.current && l.current.has(g) && (l.current.delete(g), f());
|
|
67
67
|
},
|
|
68
|
-
[
|
|
69
|
-
),
|
|
70
|
-
() => s ? (
|
|
68
|
+
[f]
|
|
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:
|
|
74
|
+
open: S,
|
|
75
|
+
setOpen: D,
|
|
76
|
+
value: E,
|
|
77
|
+
onValueChange: V,
|
|
78
78
|
shouldFilter: i,
|
|
79
79
|
disabled: c,
|
|
80
|
-
itemLabels:
|
|
80
|
+
itemLabels: d,
|
|
81
81
|
registerItem: F,
|
|
82
|
-
registerItemsSync:
|
|
83
|
-
unregisterItem:
|
|
82
|
+
registerItemsSync: O,
|
|
83
|
+
unregisterItem: $,
|
|
84
84
|
itemToStringValue: s,
|
|
85
|
-
filterFn:
|
|
86
|
-
searchValue:
|
|
85
|
+
filterFn: z,
|
|
86
|
+
searchValue: I,
|
|
87
87
|
setSearchValue: C,
|
|
88
|
-
activeDescendantId:
|
|
89
|
-
setActiveDescendantId:
|
|
88
|
+
activeDescendantId: R,
|
|
89
|
+
setActiveDescendantId: P
|
|
90
90
|
}),
|
|
91
91
|
[
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
S,
|
|
93
|
+
D,
|
|
94
|
+
E,
|
|
95
|
+
V,
|
|
96
96
|
i,
|
|
97
97
|
c,
|
|
98
|
-
|
|
98
|
+
d,
|
|
99
99
|
F,
|
|
100
|
-
j,
|
|
101
|
-
T,
|
|
102
|
-
s,
|
|
103
100
|
O,
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
101
|
+
$,
|
|
102
|
+
s,
|
|
103
|
+
z,
|
|
104
|
+
I,
|
|
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
|
|
@@ -140,28 +140,28 @@ const be = oe([
|
|
|
140
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
|
-
"data-placeholder":
|
|
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
163
|
"data-tracking-label": i,
|
|
164
|
-
disabled:
|
|
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 i = (
|
|
195
|
+
const i = (m) => m.value, c = "label" in o && typeof o.label == "string";
|
|
196
196
|
return {
|
|
197
197
|
getValue: i,
|
|
198
|
-
getLabel: n ?? (c ? (
|
|
198
|
+
getLabel: n ?? (c ? (m) => String(m.label) : i),
|
|
199
199
|
hasDistinctLabel: c || !!n
|
|
200
200
|
};
|
|
201
201
|
}
|
|
@@ -207,18 +207,18 @@ function Ae({
|
|
|
207
207
|
getItemValue: i,
|
|
208
208
|
getItemLabel: c
|
|
209
209
|
}) {
|
|
210
|
-
const { value: s, itemLabels:
|
|
210
|
+
const { value: s, itemLabels: m } = _(), p = t.useMemo(
|
|
211
211
|
() => o ? X(o, i, c) : null,
|
|
212
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
|
}
|
|
@@ -239,45 +239,46 @@ function Te({
|
|
|
239
239
|
side: i = "bottom",
|
|
240
240
|
sideOffset: c,
|
|
241
241
|
avoidCollisions: s,
|
|
242
|
-
hideList:
|
|
242
|
+
hideList: m = !1,
|
|
243
|
+
ariaLabel: p
|
|
243
244
|
}) {
|
|
244
|
-
const { open:
|
|
245
|
+
const { open: v, shouldFilter: M, filterFn: x, itemToStringValue: d } = _(), [L, I] = t.useState(
|
|
245
246
|
null
|
|
246
|
-
),
|
|
247
|
-
if (
|
|
248
|
-
let
|
|
249
|
-
const
|
|
250
|
-
|
|
251
|
-
},
|
|
252
|
-
|
|
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"));
|
|
253
254
|
});
|
|
254
|
-
|
|
255
|
+
S.observe(w, {
|
|
255
256
|
attributes: !0,
|
|
256
257
|
attributeFilter: ["data-side"]
|
|
257
258
|
});
|
|
258
|
-
let
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
259
|
+
let D = 0, V = 0;
|
|
260
|
+
D = requestAnimationFrame(() => {
|
|
261
|
+
V = requestAnimationFrame(() => {
|
|
262
|
+
E(w.getAttribute("data-side"));
|
|
262
263
|
});
|
|
263
|
-
}),
|
|
264
|
-
|
|
264
|
+
}), C.current = () => {
|
|
265
|
+
y = !0, S.disconnect(), cancelAnimationFrame(D), cancelAnimationFrame(V);
|
|
265
266
|
};
|
|
266
267
|
}, []);
|
|
267
268
|
t.useEffect(() => {
|
|
268
|
-
if (!
|
|
269
|
-
|
|
270
|
-
const
|
|
271
|
-
return () => clearTimeout(
|
|
269
|
+
if (!v) {
|
|
270
|
+
C.current?.(), C.current = null;
|
|
271
|
+
const w = setTimeout(() => I(null), 150);
|
|
272
|
+
return () => clearTimeout(w);
|
|
272
273
|
}
|
|
273
|
-
}, [
|
|
274
|
-
const P =
|
|
274
|
+
}, [v]);
|
|
275
|
+
const P = d ? x : void 0;
|
|
275
276
|
return /* @__PURE__ */ u(
|
|
276
277
|
ne,
|
|
277
278
|
{
|
|
278
|
-
ref:
|
|
279
|
+
ref: R,
|
|
279
280
|
align: o,
|
|
280
|
-
"aria-label": "Options",
|
|
281
|
+
"aria-label": p ?? "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: L ?? i,
|
|
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
|
+
m && "[&_[data-slot='command-input-wrapper']]:border-b-0"
|
|
297
298
|
),
|
|
298
299
|
"data-slot": "combobox-command",
|
|
299
300
|
dataHook: e || "combobox-command",
|
|
300
301
|
filter: P,
|
|
301
|
-
shouldFilter:
|
|
302
|
+
shouldFilter: M,
|
|
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: i, shouldFilter: c, activeDescendantId: s } = _(),
|
|
310
|
+
const { setSearchValue: i, shouldFilter: c, activeDescendantId: s } = _(), m = t.useRef(
|
|
310
311
|
void 0
|
|
311
312
|
);
|
|
312
313
|
G(
|
|
@@ -320,13 +321,13 @@ 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
|
+
m.current && clearTimeout(m.current);
|
|
324
325
|
}, []);
|
|
325
|
-
const
|
|
326
|
-
(
|
|
327
|
-
i(
|
|
328
|
-
r?.(
|
|
329
|
-
}, 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);
|
|
330
331
|
},
|
|
331
332
|
[e, r, i]
|
|
332
333
|
);
|
|
@@ -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: p,
|
|
340
341
|
...n
|
|
341
342
|
}
|
|
342
343
|
);
|
|
@@ -360,167 +361,167 @@ function he({
|
|
|
360
361
|
estimateSize: i = 36,
|
|
361
362
|
overscan: c = 5,
|
|
362
363
|
children: s,
|
|
363
|
-
renderEmpty:
|
|
364
|
-
className:
|
|
365
|
-
dataHook:
|
|
366
|
-
},
|
|
367
|
-
const
|
|
364
|
+
renderEmpty: m,
|
|
365
|
+
className: p,
|
|
366
|
+
dataHook: v
|
|
367
|
+
}, M) {
|
|
368
|
+
const x = t.useMemo(
|
|
368
369
|
() => X(e, r, n),
|
|
369
370
|
[e, r, n]
|
|
370
|
-
),
|
|
371
|
-
() =>
|
|
371
|
+
), d = t.useMemo(
|
|
372
|
+
() => x?.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
|
-
),
|
|
380
|
-
() =>
|
|
381
|
-
[
|
|
379
|
+
[x]
|
|
380
|
+
), L = t.useMemo(
|
|
381
|
+
() => x?.getLabel ?? d,
|
|
382
|
+
[x, d]
|
|
382
383
|
);
|
|
383
384
|
G(
|
|
384
|
-
() => !
|
|
385
|
+
() => !x && 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
|
+
[x, e.length]
|
|
387
388
|
);
|
|
388
|
-
const
|
|
389
|
+
const I = t.useRef(null), {
|
|
389
390
|
value: C,
|
|
390
|
-
onValueChange:
|
|
391
|
-
setOpen:
|
|
392
|
-
shouldFilter:
|
|
393
|
-
searchValue:
|
|
394
|
-
filterFn:
|
|
395
|
-
setActiveDescendantId:
|
|
396
|
-
registerItemsSync:
|
|
397
|
-
unregisterItem:
|
|
398
|
-
} = _(), [l,
|
|
399
|
-
t.useImperativeHandle(
|
|
400
|
-
const a = e.map((
|
|
401
|
-
|
|
402
|
-
|
|
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
|
+
const a = e.map((b) => [
|
|
402
|
+
d(b),
|
|
403
|
+
L(b)
|
|
403
404
|
]);
|
|
404
|
-
return
|
|
405
|
-
for (const
|
|
406
|
-
|
|
405
|
+
return D(a), () => {
|
|
406
|
+
for (const b of e)
|
|
407
|
+
V(d(b));
|
|
407
408
|
};
|
|
408
|
-
}, [e,
|
|
409
|
-
const
|
|
410
|
-
if (!
|
|
409
|
+
}, [e, d, L, D, V]);
|
|
410
|
+
const f = t.useMemo(() => {
|
|
411
|
+
if (!w || !y.trim()) return e;
|
|
411
412
|
const a = [];
|
|
412
|
-
for (const
|
|
413
|
-
let
|
|
413
|
+
for (const b of e) {
|
|
414
|
+
let h = x?.hasDistinctLabel ? K(L(b), y) : E(d(b), y);
|
|
414
415
|
if (o)
|
|
415
|
-
for (const
|
|
416
|
-
|
|
417
|
-
|
|
416
|
+
for (const N of o(b))
|
|
417
|
+
h = Math.max(h, K(N, y));
|
|
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
|
-
I,
|
|
424
|
-
f,
|
|
423
|
+
w,
|
|
425
424
|
y,
|
|
425
|
+
d,
|
|
426
|
+
L,
|
|
426
427
|
o,
|
|
427
|
-
|
|
428
|
-
|
|
428
|
+
E,
|
|
429
|
+
x?.hasDistinctLabel
|
|
429
430
|
]), F = te({
|
|
430
|
-
count:
|
|
431
|
-
getScrollElement: () =>
|
|
431
|
+
count: f.length,
|
|
432
|
+
getScrollElement: () => I.current,
|
|
432
433
|
estimateSize: () => i,
|
|
433
434
|
overscan: c
|
|
434
|
-
}),
|
|
435
|
+
}), O = l >= 0 && l < f.length ? d(f[l]) : null;
|
|
435
436
|
t.useEffect(() => {
|
|
436
|
-
|
|
437
|
-
}, [
|
|
437
|
+
k(0);
|
|
438
|
+
}, [y, f.length]);
|
|
438
439
|
const q = t.useRef(!1);
|
|
439
440
|
t.useEffect(() => {
|
|
440
441
|
if (q.current || !C) return;
|
|
441
|
-
const a =
|
|
442
|
-
a >= 0 && (
|
|
443
|
-
}, [C,
|
|
444
|
-
const
|
|
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);
|
|
445
446
|
t.useEffect(() => {
|
|
446
|
-
|
|
447
|
-
}, [l,
|
|
448
|
-
const a =
|
|
447
|
+
$.current && l >= 0 && l < f.length && F.scrollToIndex(l, { align: "auto" }), $.current = !1;
|
|
448
|
+
}, [l, 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(), $.current = !0, k(
|
|
457
|
+
(N) => N < f.length - 1 ? N + 1 : N
|
|
457
458
|
);
|
|
458
459
|
break;
|
|
459
460
|
case "ArrowUp":
|
|
460
|
-
|
|
461
|
+
h.preventDefault(), h.stopPropagation(), $.current = !0, k((N) => N > 0 ? N - 1 : N);
|
|
461
462
|
break;
|
|
462
463
|
case "Enter":
|
|
463
|
-
if (
|
|
464
|
-
const
|
|
465
|
-
|
|
464
|
+
if (h.preventDefault(), h.stopPropagation(), l >= 0 && l < f.length) {
|
|
465
|
+
const N = d(f[l]);
|
|
466
|
+
R(N === C ? "" : N), P(!1);
|
|
466
467
|
}
|
|
467
468
|
break;
|
|
468
469
|
case "Home":
|
|
469
|
-
|
|
470
|
+
h.preventDefault(), h.stopPropagation(), $.current = !0, k(0);
|
|
470
471
|
break;
|
|
471
472
|
case "End":
|
|
472
|
-
|
|
473
|
+
h.preventDefault(), h.stopPropagation(), $.current = !0, k(f.length - 1);
|
|
473
474
|
break;
|
|
474
475
|
}
|
|
475
476
|
};
|
|
476
|
-
return a.addEventListener("keydown",
|
|
477
|
-
}, [
|
|
478
|
-
const
|
|
477
|
+
return a.addEventListener("keydown", b, { capture: !0 }), () => a.removeEventListener("keydown", b, { capture: !0 });
|
|
478
|
+
}, [f, l, C, R, P, d]);
|
|
479
|
+
const z = 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 = z.get(a);
|
|
487
|
+
b !== void 0 && k(b);
|
|
487
488
|
},
|
|
488
|
-
[
|
|
489
|
-
),
|
|
490
|
-
(a) => (
|
|
491
|
-
[
|
|
492
|
-
),
|
|
489
|
+
[z]
|
|
490
|
+
), g = t.useCallback(
|
|
491
|
+
(a) => (z.get(a) ?? 0) + 1,
|
|
492
|
+
[z]
|
|
493
|
+
), j = f.length, U = t.useMemo(
|
|
493
494
|
() => ({
|
|
494
|
-
activeValue:
|
|
495
|
+
activeValue: O,
|
|
495
496
|
onItemPointerMove: H,
|
|
496
|
-
idPrefix:
|
|
497
|
-
filteredCount:
|
|
498
|
-
getItemPosition:
|
|
497
|
+
idPrefix: T,
|
|
498
|
+
filteredCount: j,
|
|
499
|
+
getItemPosition: g
|
|
499
500
|
}),
|
|
500
|
-
[
|
|
501
|
-
), W =
|
|
502
|
-
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(
|
|
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
|
+
p
|
|
509
510
|
),
|
|
510
|
-
"data-hook":
|
|
511
|
+
"data-hook": v,
|
|
511
512
|
"data-slot": "combobox-virtual-list",
|
|
512
513
|
role: "listbox",
|
|
513
|
-
children:
|
|
514
|
+
children: m
|
|
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
|
+
p
|
|
522
523
|
),
|
|
523
|
-
"data-hook":
|
|
524
|
+
"data-hook": v,
|
|
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
|
+
y
|
|
544
545
|
)
|
|
545
546
|
},
|
|
546
547
|
a.key
|
|
@@ -592,54 +593,55 @@ const ye = t.forwardRef(
|
|
|
592
593
|
className: i,
|
|
593
594
|
highlight: c,
|
|
594
595
|
highlightClassName: s,
|
|
595
|
-
keywords:
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
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);
|
|
599
601
|
t.useEffect(() => {
|
|
600
|
-
|
|
601
|
-
}, [
|
|
602
|
-
const
|
|
602
|
+
y.current = I, E.current = C;
|
|
603
|
+
}, [I, C]);
|
|
604
|
+
const S = !!R;
|
|
603
605
|
t.useEffect(() => {
|
|
604
|
-
if (!
|
|
605
|
-
return
|
|
606
|
-
}, [e,
|
|
607
|
-
const
|
|
608
|
-
|
|
609
|
-
},
|
|
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(
|
|
610
612
|
o,
|
|
611
613
|
c,
|
|
612
614
|
s || "text-sm leading-normal font-semibold"
|
|
613
615
|
) : o;
|
|
614
|
-
if (
|
|
615
|
-
const
|
|
616
|
+
if (R) {
|
|
617
|
+
const l = R.activeValue === e, k = !!v.disabled;
|
|
616
618
|
return /* @__PURE__ */ B(
|
|
617
619
|
"div",
|
|
618
620
|
{
|
|
619
|
-
ref:
|
|
620
|
-
"aria-disabled":
|
|
621
|
-
"aria-posinset":
|
|
621
|
+
ref: M,
|
|
622
|
+
"aria-disabled": k || void 0,
|
|
623
|
+
"aria-posinset": R.getItemPosition(e),
|
|
622
624
|
"aria-selected": P,
|
|
623
|
-
"aria-setsize":
|
|
625
|
+
"aria-setsize": R.filteredCount,
|
|
624
626
|
className: A(
|
|
625
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",
|
|
626
628
|
"[&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
627
|
-
|
|
629
|
+
k && "pointer-events-none opacity-50",
|
|
628
630
|
i
|
|
629
631
|
),
|
|
630
|
-
"data-highlighted":
|
|
632
|
+
"data-highlighted": l || void 0,
|
|
631
633
|
"data-hook": n,
|
|
632
634
|
"data-slot": "combobox-item",
|
|
633
|
-
id: `${
|
|
635
|
+
id: `${R.idPrefix}item-${e}`,
|
|
634
636
|
role: "option",
|
|
635
637
|
tabIndex: -1,
|
|
636
|
-
onClick:
|
|
637
|
-
onKeyDown:
|
|
638
|
-
(
|
|
638
|
+
onClick: k ? void 0 : D,
|
|
639
|
+
onKeyDown: k ? void 0 : (T) => {
|
|
640
|
+
(T.key === "Enter" || T.key === " ") && D();
|
|
639
641
|
},
|
|
640
|
-
onPointerMove:
|
|
642
|
+
onPointerMove: k ? void 0 : () => R.onItemPointerMove(e),
|
|
641
643
|
children: [
|
|
642
|
-
|
|
644
|
+
V(),
|
|
643
645
|
P && /* @__PURE__ */ u(
|
|
644
646
|
Y,
|
|
645
647
|
{
|
|
@@ -654,16 +656,16 @@ const ye = t.forwardRef(
|
|
|
654
656
|
return /* @__PURE__ */ B(
|
|
655
657
|
ce,
|
|
656
658
|
{
|
|
657
|
-
ref:
|
|
659
|
+
ref: M,
|
|
658
660
|
className: A("justify-between", i),
|
|
659
661
|
"data-slot": "combobox-item",
|
|
660
662
|
dataHook: n,
|
|
661
|
-
keywords:
|
|
663
|
+
keywords: m ? [w, ...m] : [w],
|
|
662
664
|
value: e,
|
|
663
|
-
onSelect:
|
|
664
|
-
...
|
|
665
|
+
onSelect: D,
|
|
666
|
+
...v,
|
|
665
667
|
children: [
|
|
666
|
-
|
|
668
|
+
V(),
|
|
667
669
|
P && /* @__PURE__ */ u(
|
|
668
670
|
Y,
|
|
669
671
|
{
|
|
@@ -679,7 +681,11 @@ const ye = t.forwardRef(
|
|
|
679
681
|
ye.displayName = "ComboboxItem";
|
|
680
682
|
const ke = t.forwardRef((e, r) => /* @__PURE__ */ u(fe, { ref: r, "data-slot": "combobox-separator", ...e }));
|
|
681
683
|
ke.displayName = "ComboboxSeparator";
|
|
682
|
-
function je({
|
|
684
|
+
function je({
|
|
685
|
+
className: e,
|
|
686
|
+
children: r,
|
|
687
|
+
loadingText: n
|
|
688
|
+
}) {
|
|
683
689
|
return /* @__PURE__ */ u(
|
|
684
690
|
"div",
|
|
685
691
|
{
|
|
@@ -698,7 +704,7 @@ function je({ className: e, children: r }) {
|
|
|
698
704
|
className: "size-4 animate-spin rounded-full border-2 border-current border-t-transparent [animation-duration:0.6s]"
|
|
699
705
|
}
|
|
700
706
|
),
|
|
701
|
-
"Loading..."
|
|
707
|
+
n ?? "Loading..."
|
|
702
708
|
] })
|
|
703
709
|
}
|
|
704
710
|
);
|