@brightlocal/ui-components 3.3.0 → 3.5.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/AI_USAGE.md +22 -3
- package/README.md +177 -109
- package/component-meta.json +1307 -113
- package/dist/alert-dialog.cjs +1 -1
- package/dist/alert-dialog.d.ts +13 -2
- package/dist/alert-dialog.d.ts.map +1 -1
- package/dist/alert-dialog.js +4 -3
- package/dist/banner.cjs +1 -1
- package/dist/banner.d.ts +47 -11
- package/dist/banner.d.ts.map +1 -1
- package/dist/banner.js +156 -79
- package/dist/blocks/empty-state.cjs +1 -1
- package/dist/blocks/empty-state.d.ts +40 -5
- package/dist/blocks/empty-state.d.ts.map +1 -1
- package/dist/blocks/empty-state.js +59 -52
- package/dist/blocks/input-list.cjs +1 -1
- package/dist/blocks/input-list.d.ts +1 -0
- package/dist/blocks/input-list.d.ts.map +1 -1
- package/dist/blocks/input-list.js +39 -39
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts +12 -6
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +64 -63
- package/dist/button.cjs +1 -1
- package/dist/button.d.ts.map +1 -1
- package/dist/button.js +47 -43
- package/dist/card.cjs +1 -1
- package/dist/card.d.ts +12 -0
- package/dist/card.d.ts.map +1 -1
- package/dist/card.js +115 -97
- package/dist/chart.cjs +6 -6
- package/dist/chart.d.ts +6 -10
- package/dist/chart.d.ts.map +1 -1
- package/dist/chart.js +281 -296
- package/dist/combobox.cjs +3 -3
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +430 -343
- package/dist/command.cjs +1 -1
- package/dist/command.d.ts +23 -2
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js +212 -207
- package/dist/count-indicator.cjs +1 -0
- package/dist/count-indicator.d.ts +85 -0
- package/dist/count-indicator.d.ts.map +1 -0
- package/dist/count-indicator.js +72 -0
- package/dist/data-table.cjs +1 -1
- package/dist/data-table.d.ts +101 -11
- package/dist/data-table.d.ts.map +1 -1
- package/dist/data-table.js +593 -523
- package/dist/description-list.cjs +1 -0
- package/dist/description-list.d.ts +142 -0
- package/dist/description-list.d.ts.map +1 -0
- package/dist/description-list.js +173 -0
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.d.ts +26 -3
- package/dist/dialog.d.ts.map +1 -1
- package/dist/dialog.js +62 -47
- package/dist/drawer.cjs +1 -1
- package/dist/drawer.d.ts +8 -4
- package/dist/drawer.d.ts.map +1 -1
- package/dist/drawer.js +37 -38
- package/dist/file-upload.cjs +1 -0
- package/dist/file-upload.d.ts +546 -0
- package/dist/file-upload.d.ts.map +1 -0
- package/dist/file-upload.js +1103 -0
- package/dist/global-layout.cjs +1 -1
- package/dist/global-layout.d.ts +7 -2
- package/dist/global-layout.d.ts.map +1 -1
- package/dist/global-layout.js +52 -52
- package/dist/hooks/use-file-dropzone.cjs +1 -0
- package/dist/hooks/use-file-dropzone.d.ts +75 -0
- package/dist/hooks/use-file-dropzone.d.ts.map +1 -0
- package/dist/hooks/use-file-dropzone.js +133 -0
- package/dist/hover-card.cjs +1 -1
- package/dist/hover-card.d.ts +29 -16
- package/dist/hover-card.d.ts.map +1 -1
- package/dist/hover-card.js +153 -36
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +681 -623
- package/dist/input-chip.cjs +1 -1
- package/dist/input-chip.d.ts +30 -1
- package/dist/input-chip.d.ts.map +1 -1
- package/dist/input-chip.js +131 -115
- package/dist/input-group.cjs +1 -1
- package/dist/input-group.d.ts +37 -2
- package/dist/input-group.d.ts.map +1 -1
- package/dist/input-group.js +131 -114
- package/dist/input-password.cjs +1 -1
- package/dist/input-password.js +6 -6
- package/dist/lib/empty-canvas.cjs +1 -1
- package/dist/lib/empty-canvas.d.ts +27 -1
- package/dist/lib/empty-canvas.d.ts.map +1 -1
- package/dist/lib/empty-canvas.js +27 -23
- package/dist/lib/empty-chip.cjs +1 -1
- package/dist/lib/empty-chip.d.ts +19 -2
- package/dist/lib/empty-chip.d.ts.map +1 -1
- package/dist/lib/empty-chip.js +14 -9
- package/dist/lib/field-aria.cjs +1 -1
- package/dist/lib/field-aria.d.ts +4 -4
- package/dist/lib/field-aria.d.ts.map +1 -1
- package/dist/lib/field-aria.js +7 -5
- package/dist/lib/media-viewer-content.cjs +1 -1
- package/dist/lib/media-viewer-content.js +1 -1
- package/dist/lib/motion.cjs +1 -1
- package/dist/lib/motion.js +15 -10
- package/dist/lib/table-internal.cjs +1 -1
- package/dist/lib/table-internal.d.ts +19 -0
- package/dist/lib/table-internal.d.ts.map +1 -1
- package/dist/lib/table-internal.js +22 -7
- package/dist/list.cjs +1 -1
- package/dist/list.d.ts +230 -40
- package/dist/list.d.ts.map +1 -1
- package/dist/list.js +301 -66
- package/dist/logo-mark.cjs +1 -1
- package/dist/logo-mark.d.ts +18 -2
- package/dist/logo-mark.d.ts.map +1 -1
- package/dist/logo-mark.js +159 -79
- package/dist/media-empty.cjs +1 -1
- package/dist/media-empty.d.ts +50 -7
- package/dist/media-empty.d.ts.map +1 -1
- package/dist/media-empty.js +14 -13
- package/dist/media-viewer.cjs +1 -1
- package/dist/media-viewer.js +6 -6
- package/dist/multi-select-filter.cjs +1 -1
- package/dist/multi-select-filter.d.ts.map +1 -1
- package/dist/multi-select-filter.js +92 -101
- package/dist/pagination.cjs +1 -1
- package/dist/pagination.d.ts +11 -0
- package/dist/pagination.d.ts.map +1 -1
- package/dist/pagination.js +17 -17
- package/dist/relative-date.d.ts +6 -0
- package/dist/relative-date.d.ts.map +1 -1
- package/dist/resizable.d.ts +1 -1
- package/dist/result-count.cjs +1 -1
- package/dist/result-count.d.ts +13 -16
- package/dist/result-count.d.ts.map +1 -1
- package/dist/result-count.js +24 -33
- package/dist/route-progress.cjs +1 -1
- package/dist/route-progress.js +24 -23
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.d.ts +22 -3
- package/dist/sheet.d.ts.map +1 -1
- package/dist/sheet.js +152 -125
- package/dist/single-select-filter.cjs +1 -1
- package/dist/single-select-filter.d.ts.map +1 -1
- package/dist/single-select-filter.js +67 -76
- package/dist/table.cjs +1 -1
- package/dist/table.d.ts.map +1 -1
- package/dist/table.js +77 -76
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.d.ts +39 -3
- package/dist/tabs.d.ts.map +1 -1
- package/dist/tabs.js +127 -76
- package/dist/textarea.cjs +1 -1
- package/dist/textarea.d.ts +34 -0
- package/dist/textarea.d.ts.map +1 -1
- package/dist/textarea.js +115 -19
- package/dist/tooltip.cjs +1 -1
- package/dist/tooltip.d.ts.map +1 -1
- package/dist/tooltip.js +137 -131
- package/dist/typography-text.cjs +1 -1
- package/dist/typography-text.d.ts +6 -2
- package/dist/typography-text.d.ts.map +1 -1
- package/dist/typography-text.js +14 -13
- package/package.json +2 -3
- package/src/blocks/empty-state.tsx +108 -48
- package/src/blocks/input-list.tsx +15 -9
- package/src/blocks/sidebar.tsx +39 -16
- package/src/components/alert-dialog.tsx +18 -2
- package/src/components/banner.tsx +247 -68
- package/src/components/button.tsx +27 -10
- package/src/components/card.tsx +89 -7
- package/src/components/chart.tsx +47 -67
- package/src/components/combobox.tsx +221 -12
- package/src/components/command.tsx +83 -37
- package/src/components/count-indicator.tsx +188 -0
- package/src/components/data-table.tsx +506 -159
- package/src/components/description-list.tsx +445 -0
- package/src/components/dialog.tsx +74 -5
- package/src/components/drawer.tsx +52 -32
- package/src/components/file-upload.tsx +2574 -0
- package/src/components/global-layout.tsx +18 -5
- package/src/components/hover-card.tsx +395 -65
- package/src/components/input-chip.tsx +67 -2
- package/src/components/input-group.tsx +89 -6
- package/src/components/list.tsx +720 -72
- package/src/components/logo-mark.tsx +109 -25
- package/src/components/media-empty.tsx +62 -7
- package/src/components/multi-select-filter.tsx +9 -16
- package/src/components/pagination.tsx +15 -2
- package/src/components/relative-date.tsx +6 -0
- package/src/components/result-count.tsx +27 -54
- package/src/components/sheet.tsx +86 -8
- package/src/components/single-select-filter.tsx +9 -16
- package/src/components/table.tsx +16 -1
- package/src/components/tabs.tsx +223 -41
- package/src/components/textarea.tsx +271 -4
- package/src/components/tooltip.tsx +29 -2
- package/src/components/typography-text.tsx +7 -2
- package/src/hooks/use-file-dropzone.ts +325 -0
- package/src/index.ts +4 -0
- package/src/lib/empty-canvas.tsx +47 -20
- package/src/lib/empty-chip.tsx +38 -3
- package/src/lib/field-aria.tsx +11 -6
- package/src/lib/table-internal.ts +38 -0
package/dist/combobox.js
CHANGED
|
@@ -1,99 +1,102 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import * as e from "react";
|
|
3
|
-
import { Check as
|
|
4
|
-
import { cn as
|
|
5
|
-
import { Fragment as
|
|
6
|
-
import { cva as
|
|
7
|
-
import { useDevWarning as
|
|
8
|
-
import { Spinner as
|
|
9
|
-
import { useVirtualizer as
|
|
10
|
-
import { defaultFilter as
|
|
11
|
-
import { Popover as
|
|
12
|
-
import { Command as
|
|
13
|
-
var
|
|
14
|
-
function
|
|
15
|
-
const t = e.useContext(
|
|
3
|
+
import { Check as X, ChevronsUpDown as re } from "@brightlocal/icons";
|
|
4
|
+
import { cn as O } from "@brightlocal/ui-components/lib/utils";
|
|
5
|
+
import { Fragment as ne, jsx as l, jsxs as K } from "react/jsx-runtime";
|
|
6
|
+
import { cva as ae } from "class-variance-authority";
|
|
7
|
+
import { useDevWarning as Y } from "@brightlocal/ui-components/lib/use-dev-warning";
|
|
8
|
+
import { Spinner as se } from "@brightlocal/ui-components/spinner";
|
|
9
|
+
import { useVirtualizer as ie } from "@tanstack/react-virtual";
|
|
10
|
+
import { defaultFilter as J } from "cmdk";
|
|
11
|
+
import { Popover as ce, PopoverContent as ue, PopoverTrigger as le } from "@brightlocal/ui-components/popover";
|
|
12
|
+
import { Command as de, CommandEmpty as fe, CommandGroup as me, CommandInput as be, CommandItem as pe, CommandList as ve, CommandSeparator as ge } from "@brightlocal/ui-components/command";
|
|
13
|
+
var ee = e.createContext(null), te = e.createContext(null);
|
|
14
|
+
function B() {
|
|
15
|
+
const t = e.useContext(ee);
|
|
16
16
|
if (!t) throw new Error("Combobox components must be used within a <Combobox>");
|
|
17
17
|
return t;
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
const [
|
|
21
|
-
x ||
|
|
22
|
-
}, [
|
|
23
|
-
|
|
24
|
-
}, [
|
|
19
|
+
function He({ value: t, onValueChange: r, open: n, onOpenChange: o, onClose: i, shouldFilter: u = !0, disabled: s = !1, itemToStringValue: d, children: f }) {
|
|
20
|
+
const [v, p] = e.useState(""), [m, a] = e.useState(!1), [y, w] = e.useState(() => /* @__PURE__ */ new Map()), [k, h] = e.useState(""), [P, R] = e.useState(void 0), [M, I] = e.useState(void 0), N = t !== void 0, A = n !== void 0, L = N ? t : v, E = A ? n : m, D = e.useCallback((x) => {
|
|
21
|
+
x || h(""), A || a(x), o?.(x);
|
|
22
|
+
}, [A, o]), S = e.useCallback((x) => {
|
|
23
|
+
N || p(x), r?.(x);
|
|
24
|
+
}, [N, r]), T = e.useRef(i);
|
|
25
25
|
e.useEffect(() => {
|
|
26
|
-
|
|
27
|
-
}, [
|
|
28
|
-
const
|
|
26
|
+
T.current = i;
|
|
27
|
+
}, [i]);
|
|
28
|
+
const z = e.useRef(E);
|
|
29
29
|
e.useEffect(() => {
|
|
30
|
-
|
|
31
|
-
}, [
|
|
32
|
-
|
|
30
|
+
z.current && !E && T.current?.(), z.current = E;
|
|
31
|
+
}, [E]), e.useEffect(() => () => {
|
|
32
|
+
z.current && T.current?.();
|
|
33
33
|
}, []);
|
|
34
|
-
const
|
|
34
|
+
const b = e.useRef(/* @__PURE__ */ new Map()), V = e.useRef(!1), H = e.useRef(!0);
|
|
35
35
|
e.useEffect(() => () => {
|
|
36
|
-
|
|
36
|
+
H.current = !1;
|
|
37
37
|
}, []);
|
|
38
|
-
const
|
|
38
|
+
const q = e.useCallback(() => {
|
|
39
39
|
V.current || (V.current = !0, queueMicrotask(() => {
|
|
40
|
-
V.current = !1,
|
|
40
|
+
V.current = !1, H.current && w(new Map(b.current));
|
|
41
41
|
}));
|
|
42
|
-
}, []),
|
|
43
|
-
|
|
44
|
-
}, [
|
|
45
|
-
for (const [
|
|
46
|
-
|
|
47
|
-
}, []),
|
|
42
|
+
}, []), j = e.useCallback((x, $) => {
|
|
43
|
+
b.current.get(x) !== $ && (b.current.set(x, $), q());
|
|
44
|
+
}, [q]), _ = e.useCallback((x) => {
|
|
45
|
+
for (const [$, c] of x) b.current.set($, c);
|
|
46
|
+
w(new Map(b.current));
|
|
47
|
+
}, []), U = e.useRef(L);
|
|
48
48
|
e.useLayoutEffect(() => {
|
|
49
|
-
|
|
49
|
+
U.current = L;
|
|
50
50
|
}, [L]);
|
|
51
|
-
const
|
|
52
|
-
x !==
|
|
53
|
-
}, [
|
|
54
|
-
open:
|
|
55
|
-
setOpen:
|
|
51
|
+
const G = e.useCallback((x) => {
|
|
52
|
+
x !== U.current && b.current.has(x) && (b.current.delete(x), q());
|
|
53
|
+
}, [q]), W = e.useMemo(() => d ? (x, $, c) => J(d(x), $, c) : J, [d]), Q = e.useMemo(() => ({
|
|
54
|
+
open: E,
|
|
55
|
+
setOpen: D,
|
|
56
56
|
value: L,
|
|
57
|
-
onValueChange:
|
|
58
|
-
shouldFilter:
|
|
59
|
-
disabled:
|
|
60
|
-
itemLabels:
|
|
61
|
-
registerItem:
|
|
62
|
-
registerItemsSync:
|
|
63
|
-
unregisterItem:
|
|
64
|
-
itemToStringValue:
|
|
65
|
-
filterFn:
|
|
66
|
-
searchValue:
|
|
67
|
-
setSearchValue:
|
|
68
|
-
activeDescendantId:
|
|
69
|
-
setActiveDescendantId:
|
|
57
|
+
onValueChange: S,
|
|
58
|
+
shouldFilter: u,
|
|
59
|
+
disabled: s,
|
|
60
|
+
itemLabels: y,
|
|
61
|
+
registerItem: j,
|
|
62
|
+
registerItemsSync: _,
|
|
63
|
+
unregisterItem: G,
|
|
64
|
+
itemToStringValue: d,
|
|
65
|
+
filterFn: W,
|
|
66
|
+
searchValue: k,
|
|
67
|
+
setSearchValue: h,
|
|
68
|
+
activeDescendantId: P,
|
|
69
|
+
setActiveDescendantId: R,
|
|
70
|
+
listboxId: M,
|
|
71
|
+
setListboxId: I
|
|
70
72
|
}), [
|
|
71
|
-
|
|
72
|
-
|
|
73
|
+
E,
|
|
74
|
+
D,
|
|
73
75
|
L,
|
|
74
|
-
h,
|
|
75
|
-
d,
|
|
76
|
-
i,
|
|
77
76
|
S,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
77
|
+
u,
|
|
78
|
+
s,
|
|
79
|
+
y,
|
|
80
|
+
j,
|
|
81
|
+
_,
|
|
82
82
|
G,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
d,
|
|
84
|
+
W,
|
|
85
|
+
k,
|
|
86
|
+
P,
|
|
87
|
+
R,
|
|
88
|
+
M
|
|
86
89
|
]);
|
|
87
|
-
return /* @__PURE__ */
|
|
88
|
-
value:
|
|
89
|
-
children: /* @__PURE__ */
|
|
90
|
-
open:
|
|
91
|
-
onOpenChange:
|
|
92
|
-
children:
|
|
90
|
+
return /* @__PURE__ */ l(ee.Provider, {
|
|
91
|
+
value: Q,
|
|
92
|
+
children: /* @__PURE__ */ l(ce, {
|
|
93
|
+
open: E,
|
|
94
|
+
onOpenChange: D,
|
|
95
|
+
children: f
|
|
93
96
|
})
|
|
94
97
|
});
|
|
95
98
|
}
|
|
96
|
-
var
|
|
99
|
+
var he = ae([
|
|
97
100
|
"relative flex w-full items-center justify-between gap-2",
|
|
98
101
|
"px-3 py-2 h-9",
|
|
99
102
|
"border border-border rounded-sm outline-none",
|
|
@@ -107,433 +110,517 @@ var be = te([
|
|
|
107
110
|
"cursor-pointer disabled:cursor-not-allowed disabled:opacity-50",
|
|
108
111
|
"transition-[background-color,border-color,box-shadow] duration-fast ease-out",
|
|
109
112
|
"[&_svg]:pointer-events-none [&_svg]:shrink-0"
|
|
110
|
-
]),
|
|
111
|
-
const { open:
|
|
112
|
-
return /* @__PURE__ */
|
|
113
|
+
]), xe = e.forwardRef(({ className: t, dataHook: r, error: n, trackingEl: o, trackingLabel: i, reserveValues: u, children: s, ...d }, f) => {
|
|
114
|
+
const { open: v, disabled: p, value: m } = B(), a = e.useId(), y = !m, w = n || d["aria-invalid"] === !0 || d["aria-invalid"] === "true";
|
|
115
|
+
return /* @__PURE__ */ l(le, {
|
|
113
116
|
asChild: !0,
|
|
114
|
-
children: /* @__PURE__ */
|
|
115
|
-
ref:
|
|
116
|
-
"aria-controls":
|
|
117
|
-
"aria-expanded":
|
|
117
|
+
children: /* @__PURE__ */ K("button", {
|
|
118
|
+
ref: f,
|
|
119
|
+
"aria-controls": v ? a : void 0,
|
|
120
|
+
"aria-expanded": v,
|
|
118
121
|
"aria-haspopup": "listbox",
|
|
119
|
-
"aria-invalid":
|
|
120
|
-
className:
|
|
122
|
+
"aria-invalid": w ? "true" : void 0,
|
|
123
|
+
className: O(he(), w && "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", t),
|
|
121
124
|
"data-hook": r,
|
|
122
|
-
"data-placeholder":
|
|
125
|
+
"data-placeholder": y,
|
|
123
126
|
"data-slot": "combobox-trigger",
|
|
124
|
-
"data-state":
|
|
127
|
+
"data-state": v ? "open" : "closed",
|
|
125
128
|
"data-tracking-el": o || "combobox-trigger",
|
|
126
|
-
"data-tracking-label":
|
|
127
|
-
disabled:
|
|
129
|
+
"data-tracking-label": i,
|
|
130
|
+
disabled: p || d.disabled,
|
|
128
131
|
role: "combobox",
|
|
129
132
|
type: "button",
|
|
130
|
-
...
|
|
131
|
-
children: [
|
|
133
|
+
...d,
|
|
134
|
+
children: [u?.length ? /* @__PURE__ */ K("span", {
|
|
132
135
|
className: "grid min-w-0 text-left",
|
|
133
136
|
"data-slot": "combobox-reserve",
|
|
134
|
-
children: [
|
|
137
|
+
children: [u.map((k, h) => /* @__PURE__ */ l("span", {
|
|
135
138
|
"aria-hidden": "true",
|
|
136
139
|
className: "invisible col-start-1 row-start-1 truncate",
|
|
137
|
-
children:
|
|
138
|
-
},
|
|
140
|
+
children: k
|
|
141
|
+
}, h)), /* @__PURE__ */ l("span", {
|
|
139
142
|
className: "col-start-1 row-start-1 truncate",
|
|
140
|
-
children:
|
|
143
|
+
children: s
|
|
141
144
|
})]
|
|
142
|
-
}) :
|
|
145
|
+
}) : s, /* @__PURE__ */ l(re, {
|
|
143
146
|
"aria-hidden": "true",
|
|
144
147
|
className: "text-muted-foreground ml-auto shrink-0"
|
|
145
148
|
})]
|
|
146
149
|
})
|
|
147
150
|
});
|
|
148
151
|
});
|
|
149
|
-
|
|
150
|
-
function
|
|
152
|
+
xe.displayName = "ComboboxTrigger";
|
|
153
|
+
function Ce(t) {
|
|
151
154
|
return t != null && typeof t == "object" && "value" in t && typeof t.value == "string";
|
|
152
155
|
}
|
|
153
|
-
function
|
|
156
|
+
function oe(t, r, n) {
|
|
154
157
|
if (r) return {
|
|
155
158
|
getValue: r,
|
|
156
|
-
getLabel:
|
|
157
|
-
hasDistinctLabel: !!
|
|
159
|
+
getLabel: n ?? r,
|
|
160
|
+
hasDistinctLabel: !!n
|
|
158
161
|
};
|
|
159
162
|
const o = t[0];
|
|
160
|
-
if (!
|
|
161
|
-
const
|
|
163
|
+
if (!Ce(o)) return null;
|
|
164
|
+
const i = (s) => s.value, u = "label" in o && typeof o.label == "string";
|
|
162
165
|
return {
|
|
163
|
-
getValue:
|
|
164
|
-
getLabel:
|
|
165
|
-
hasDistinctLabel:
|
|
166
|
+
getValue: i,
|
|
167
|
+
getLabel: n ?? (u ? (s) => String(s.label) : i),
|
|
168
|
+
hasDistinctLabel: u || !!n
|
|
166
169
|
};
|
|
167
170
|
}
|
|
168
|
-
function
|
|
169
|
-
const { value:
|
|
171
|
+
function _e({ placeholder: t, className: r, displayValue: n, items: o, getItemValue: i, getItemLabel: u }) {
|
|
172
|
+
const { value: s, itemLabels: d } = B(), f = e.useMemo(() => o ? oe(o, i, u) : null, [
|
|
170
173
|
o,
|
|
171
|
-
|
|
172
|
-
|
|
174
|
+
i,
|
|
175
|
+
u
|
|
173
176
|
]);
|
|
174
|
-
|
|
175
|
-
const
|
|
176
|
-
return /* @__PURE__ */
|
|
177
|
-
className:
|
|
177
|
+
Y(() => !!o && o.length > 0 && !f, "ComboboxValue: could not infer `getItemValue` from item shape. Pass `getItemValue` explicitly, or use items with a `value` string property.", [o, f]);
|
|
178
|
+
const v = e.useMemo(() => !o || !f ? null : new Map(o.map((m) => [f.getValue(m), f.getLabel(m)])), [o, f]), p = s ? v?.get(s) || d.get(s) || n?.(s) || s : t;
|
|
179
|
+
return /* @__PURE__ */ l("span", {
|
|
180
|
+
className: O("text-field overflow-hidden text-ellipsis whitespace-nowrap", r),
|
|
178
181
|
"data-slot": "combobox-value",
|
|
179
|
-
children:
|
|
182
|
+
children: p
|
|
180
183
|
});
|
|
181
184
|
}
|
|
182
|
-
function
|
|
183
|
-
const { open:
|
|
184
|
-
if (
|
|
185
|
-
let
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
},
|
|
189
|
-
|
|
185
|
+
function Be({ dataHook: t, className: r, children: n, align: o = "start", side: i = "bottom", sideOffset: u, avoidCollisions: s, hideList: d = !1, ariaLabel: f }) {
|
|
186
|
+
const { open: v, shouldFilter: p, filterFn: m, itemToStringValue: a } = B(), [y, w] = e.useState(null), k = e.useRef(null), h = e.useCallback((R) => {
|
|
187
|
+
if (k.current?.(), k.current = null, !R) return;
|
|
188
|
+
let M = !1;
|
|
189
|
+
const I = (E) => {
|
|
190
|
+
M || (E === "top" || E === "bottom") && (M = !0, N.disconnect(), w(E));
|
|
191
|
+
}, N = new MutationObserver(() => {
|
|
192
|
+
I(R.getAttribute("data-side"));
|
|
190
193
|
});
|
|
191
|
-
|
|
194
|
+
N.observe(R, {
|
|
192
195
|
attributes: !0,
|
|
193
196
|
attributeFilter: ["data-side"]
|
|
194
197
|
});
|
|
195
|
-
let
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
198
|
+
let A = 0, L = 0;
|
|
199
|
+
A = requestAnimationFrame(() => {
|
|
200
|
+
L = requestAnimationFrame(() => {
|
|
201
|
+
I(R.getAttribute("data-side"));
|
|
199
202
|
});
|
|
200
|
-
}),
|
|
201
|
-
|
|
203
|
+
}), k.current = () => {
|
|
204
|
+
M = !0, N.disconnect(), cancelAnimationFrame(A), cancelAnimationFrame(L);
|
|
202
205
|
};
|
|
203
206
|
}, []);
|
|
204
207
|
e.useEffect(() => {
|
|
205
|
-
if (!
|
|
206
|
-
|
|
207
|
-
const
|
|
208
|
-
return () => clearTimeout(
|
|
208
|
+
if (!v) {
|
|
209
|
+
k.current?.(), k.current = null;
|
|
210
|
+
const R = setTimeout(() => w(null), 150);
|
|
211
|
+
return () => clearTimeout(R);
|
|
209
212
|
}
|
|
210
|
-
}, [
|
|
211
|
-
const
|
|
212
|
-
return /* @__PURE__ */
|
|
213
|
-
ref:
|
|
213
|
+
}, [v]);
|
|
214
|
+
const P = a ? m : void 0;
|
|
215
|
+
return /* @__PURE__ */ l(ue, {
|
|
216
|
+
ref: h,
|
|
214
217
|
align: o,
|
|
215
|
-
"aria-label":
|
|
216
|
-
avoidCollisions:
|
|
217
|
-
className:
|
|
218
|
+
"aria-label": f ?? "Options",
|
|
219
|
+
avoidCollisions: s,
|
|
220
|
+
className: O("flex max-h-[var(--radix-popover-content-available-height)] w-[var(--radix-popover-trigger-width)] flex-col overflow-hidden p-0", r),
|
|
218
221
|
collisionPadding: 4,
|
|
219
222
|
"data-slot": "combobox-popover",
|
|
220
|
-
side:
|
|
221
|
-
sideOffset:
|
|
222
|
-
children: /* @__PURE__ */
|
|
223
|
-
className:
|
|
224
|
-
"data-slot": "combobox-command",
|
|
223
|
+
side: y ?? i,
|
|
224
|
+
sideOffset: u,
|
|
225
|
+
children: /* @__PURE__ */ l(ke, {
|
|
226
|
+
className: O("min-h-0 flex-1 border-0 shadow-none", "[&_[data-slot='command-input-wrapper']]:shrink-0", d && "[&_[data-slot='command-input-wrapper']]:border-b-0"),
|
|
225
227
|
dataHook: t || "combobox-command",
|
|
226
|
-
filter:
|
|
227
|
-
shouldFilter:
|
|
228
|
-
children:
|
|
228
|
+
filter: P,
|
|
229
|
+
shouldFilter: p,
|
|
230
|
+
children: n
|
|
229
231
|
})
|
|
230
232
|
});
|
|
231
233
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
234
|
+
function ye(t) {
|
|
235
|
+
return typeof CSS < "u" && CSS.escape ? CSS.escape(t) : t.replace(/["\\]/g, "\\$&");
|
|
236
|
+
}
|
|
237
|
+
function Z(t) {
|
|
238
|
+
const r = t.closest("[cmdk-list]");
|
|
239
|
+
if (!r || r.offsetHeight === 0) return;
|
|
240
|
+
const n = r.getBoundingClientRect(), o = t.getBoundingClientRect(), i = n.height / r.offsetHeight || 1, u = (o.top - n.top) / i + r.scrollTop, s = o.height / i;
|
|
241
|
+
r.scrollTop = u - (r.clientHeight - s) / 2;
|
|
242
|
+
}
|
|
243
|
+
function we(t) {
|
|
244
|
+
const r = t.closest("[cmdk-list]");
|
|
245
|
+
if (!r) return !0;
|
|
246
|
+
const n = r.getBoundingClientRect(), o = t.getBoundingClientRect();
|
|
247
|
+
return o.top >= n.top && o.bottom <= n.bottom;
|
|
248
|
+
}
|
|
249
|
+
function ke({ children: t, ...r }) {
|
|
250
|
+
const { open: n, value: o } = B(), i = e.useRef(null), [u, s] = e.useState(() => o || void 0), d = e.useRef(0), f = e.useRef(!1);
|
|
251
|
+
return e.useLayoutEffect(() => {
|
|
252
|
+
if (!n) {
|
|
253
|
+
f.current = !0;
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
f.current && (f.current = !1, s(o || i.current?.querySelector('[cmdk-item]:not([aria-disabled="true"])')?.getAttribute("data-value") || void 0));
|
|
257
|
+
}, [n, o]), e.useLayoutEffect(() => {
|
|
258
|
+
const v = i.current;
|
|
259
|
+
if (u === void 0 || !v) return;
|
|
260
|
+
if (u === "") {
|
|
261
|
+
s(void 0);
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
const p = v.querySelector(`[cmdk-item][data-value="${ye(u)}"]:not([aria-disabled="true"])`);
|
|
265
|
+
if (!p) {
|
|
266
|
+
const m = v.querySelector('[cmdk-item]:not([aria-disabled="true"])')?.getAttribute("data-value");
|
|
267
|
+
s(m ?? "");
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
for (const m of v.querySelectorAll("[cmdk-input], [cmdk-list]")) m.setAttribute("aria-activedescendant", p.id);
|
|
271
|
+
Z(p), s(void 0), d.current = requestAnimationFrame(() => {
|
|
272
|
+
p.isConnected && !we(p) && Z(p);
|
|
273
|
+
});
|
|
274
|
+
}, [u]), e.useEffect(() => () => cancelAnimationFrame(d.current), []), /* @__PURE__ */ l(de, {
|
|
275
|
+
...r,
|
|
276
|
+
ref: i,
|
|
277
|
+
"data-slot": "combobox-command",
|
|
278
|
+
value: u,
|
|
279
|
+
children: t
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
var Re = e.forwardRef(({ debounceMs: t, onValueChange: r, ...n }, o) => {
|
|
283
|
+
const { setSearchValue: i, shouldFilter: u, activeDescendantId: s, listboxId: d } = B(), f = e.useRef(void 0);
|
|
284
|
+
Y(() => !!(t && t > 0 && u), `debounceMs is set on <ComboboxInput> but shouldFilter is true (default).
|
|
235
285
|
Debounce is designed for async/server-driven search where the consumer controls the items list.
|
|
236
|
-
Set shouldFilter={false} on <Combobox> for async search, or remove debounceMs for client-side filtering.`, [t,
|
|
286
|
+
Set shouldFilter={false} on <Combobox> for async search, or remove debounceMs for client-side filtering.`, [t, u]), Y(() => !!(t && t > 0 && n.value !== void 0), "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.", [t, n.value]), e.useEffect(() => () => {
|
|
237
287
|
f.current && clearTimeout(f.current);
|
|
238
288
|
}, []);
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
r?.(
|
|
242
|
-
}, t)) : r?.(
|
|
289
|
+
const v = e.useCallback((a) => {
|
|
290
|
+
i(a), t && t > 0 ? (clearTimeout(f.current), f.current = setTimeout(() => {
|
|
291
|
+
r?.(a);
|
|
292
|
+
}, t)) : r?.(a);
|
|
243
293
|
}, [
|
|
244
294
|
t,
|
|
245
295
|
r,
|
|
246
|
-
|
|
247
|
-
])
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
296
|
+
i
|
|
297
|
+
]), p = e.useRef(null), m = e.useCallback((a) => {
|
|
298
|
+
if (p.current = a, typeof o != "function") {
|
|
299
|
+
o && (o.current = a);
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
const y = o(a);
|
|
303
|
+
if (typeof y == "function")
|
|
304
|
+
return () => {
|
|
305
|
+
p.current = null, y();
|
|
306
|
+
};
|
|
307
|
+
}, [o]);
|
|
308
|
+
return e.useLayoutEffect(() => {
|
|
309
|
+
const a = p.current;
|
|
310
|
+
if (!(!a || s === void 0))
|
|
311
|
+
return a.setAttribute("aria-activedescendant", s), () => a.removeAttribute("aria-activedescendant");
|
|
312
|
+
}, [s]), e.useLayoutEffect(() => {
|
|
313
|
+
const a = p.current;
|
|
314
|
+
if (!a || d === void 0) return;
|
|
315
|
+
const y = a.getAttribute("aria-controls");
|
|
316
|
+
return a.setAttribute("aria-controls", d), () => {
|
|
317
|
+
y ? a.setAttribute("aria-controls", y) : a.removeAttribute("aria-controls");
|
|
318
|
+
};
|
|
319
|
+
}, [d]), /* @__PURE__ */ l(be, {
|
|
320
|
+
ref: m,
|
|
321
|
+
"aria-activedescendant": s,
|
|
251
322
|
"data-slot": "combobox-input",
|
|
252
|
-
onValueChange:
|
|
253
|
-
...
|
|
323
|
+
onValueChange: v,
|
|
324
|
+
...n
|
|
254
325
|
});
|
|
255
326
|
});
|
|
256
|
-
|
|
257
|
-
var
|
|
258
|
-
ref:
|
|
259
|
-
className:
|
|
327
|
+
Re.displayName = "ComboboxInput";
|
|
328
|
+
var Ie = e.forwardRef(({ className: t, ...r }, n) => /* @__PURE__ */ l(ve, {
|
|
329
|
+
ref: n,
|
|
330
|
+
className: O("scrollbar min-h-0 flex-1", t),
|
|
260
331
|
"data-slot": "combobox-list",
|
|
261
332
|
...r
|
|
262
333
|
}));
|
|
263
|
-
|
|
264
|
-
function
|
|
265
|
-
const
|
|
334
|
+
Ie.displayName = "ComboboxList";
|
|
335
|
+
function Se({ items: t, getItemValue: r, getItemLabel: n, getItemKeywords: o, estimateSize: i = 36, overscan: u = 5, children: s, renderEmpty: d, className: f, dataHook: v }, p) {
|
|
336
|
+
const m = e.useMemo(() => oe(t, r, n), [
|
|
266
337
|
t,
|
|
267
338
|
r,
|
|
268
|
-
|
|
269
|
-
]),
|
|
270
|
-
if (typeof
|
|
339
|
+
n
|
|
340
|
+
]), a = e.useMemo(() => m?.getValue ?? ((c) => {
|
|
341
|
+
if (typeof c == "string" || typeof c == "number") return String(c);
|
|
271
342
|
throw new Error("[BrightLocal DS] ComboboxVirtualList: `getItemValue` is required for non-primitive items without a `value` property.");
|
|
272
|
-
}), [
|
|
273
|
-
|
|
274
|
-
const
|
|
275
|
-
e.useImperativeHandle(
|
|
276
|
-
const
|
|
277
|
-
return
|
|
278
|
-
for (const
|
|
343
|
+
}), [m]), y = e.useMemo(() => m?.getLabel ?? a, [m, a]);
|
|
344
|
+
Y(() => !m && t.length > 0, "ComboboxVirtualList: could not infer `getItemValue` from item shape. Pass `getItemValue` explicitly, or use items with a `value` string property.", [m, t.length]);
|
|
345
|
+
const w = e.useRef(null), { open: k, value: h, onValueChange: P, setOpen: R, shouldFilter: M, searchValue: I, filterFn: N, setActiveDescendantId: A, setListboxId: L, registerItemsSync: E, unregisterItem: D } = B(), [S, T] = e.useState(0), z = e.useId();
|
|
346
|
+
e.useImperativeHandle(p, () => w.current, []), e.useLayoutEffect(() => {
|
|
347
|
+
const c = t.map((g) => [a(g), y(g)]);
|
|
348
|
+
return E(c), () => {
|
|
349
|
+
for (const g of t) D(a(g));
|
|
279
350
|
};
|
|
280
351
|
}, [
|
|
281
352
|
t,
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
353
|
+
a,
|
|
354
|
+
y,
|
|
355
|
+
E,
|
|
356
|
+
D
|
|
286
357
|
]);
|
|
287
|
-
const
|
|
288
|
-
if (!
|
|
289
|
-
const
|
|
290
|
-
for (const
|
|
291
|
-
let
|
|
292
|
-
if (o) for (const
|
|
293
|
-
|
|
294
|
-
item:
|
|
295
|
-
score:
|
|
358
|
+
const b = e.useMemo(() => {
|
|
359
|
+
if (!M || !I.trim()) return t;
|
|
360
|
+
const c = [];
|
|
361
|
+
for (const g of t) {
|
|
362
|
+
let C = m?.hasDistinctLabel ? J(y(g), I) : N(a(g), I);
|
|
363
|
+
if (o) for (const F of o(g)) C = Math.max(C, J(F, I));
|
|
364
|
+
C > 0 && c.push({
|
|
365
|
+
item: g,
|
|
366
|
+
score: C
|
|
296
367
|
});
|
|
297
368
|
}
|
|
298
|
-
return
|
|
369
|
+
return c.sort((g, C) => C.score - g.score), c.map((g) => g.item);
|
|
299
370
|
}, [
|
|
300
371
|
t,
|
|
372
|
+
M,
|
|
301
373
|
I,
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
S,
|
|
374
|
+
a,
|
|
375
|
+
y,
|
|
305
376
|
o,
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
]), V =
|
|
309
|
-
count:
|
|
310
|
-
getScrollElement: () =>
|
|
311
|
-
estimateSize: () =>
|
|
312
|
-
overscan:
|
|
313
|
-
}),
|
|
314
|
-
e.useEffect(() => {
|
|
315
|
-
E(0);
|
|
316
|
-
}, [w, u.length]);
|
|
317
|
-
const j = e.useRef(!1);
|
|
377
|
+
N,
|
|
378
|
+
m?.hasDistinctLabel
|
|
379
|
+
]), V = ie({
|
|
380
|
+
count: b.length,
|
|
381
|
+
getScrollElement: () => w.current,
|
|
382
|
+
estimateSize: () => i,
|
|
383
|
+
overscan: u
|
|
384
|
+
}), H = S >= 0 && S < b.length ? a(b[S]) : null;
|
|
318
385
|
e.useEffect(() => {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
386
|
+
T(0);
|
|
387
|
+
}, [I, b.length]);
|
|
388
|
+
const q = e.useRef(!0);
|
|
389
|
+
e.useEffect(() => () => {
|
|
390
|
+
q.current = !0;
|
|
391
|
+
}, []), e.useEffect(() => {
|
|
392
|
+
if (!k) {
|
|
393
|
+
q.current = !0;
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
if (!q.current || !h) return;
|
|
397
|
+
if (I) {
|
|
398
|
+
q.current = !1;
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
const c = b.findIndex((g) => a(g) === h);
|
|
402
|
+
c >= 0 && (q.current = !1, T(c), V.scrollToIndex(c, { align: "center" }));
|
|
322
403
|
}, [
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
404
|
+
k,
|
|
405
|
+
h,
|
|
406
|
+
I,
|
|
407
|
+
b,
|
|
408
|
+
a,
|
|
326
409
|
V
|
|
327
410
|
]);
|
|
328
|
-
const
|
|
411
|
+
const j = e.useRef(!1);
|
|
329
412
|
e.useEffect(() => {
|
|
330
|
-
|
|
413
|
+
j.current && S >= 0 && S < b.length && V.scrollToIndex(S, { align: "auto" }), j.current = !1;
|
|
331
414
|
}, [
|
|
332
|
-
|
|
333
|
-
|
|
415
|
+
S,
|
|
416
|
+
b.length,
|
|
334
417
|
V
|
|
335
418
|
]), e.useEffect(() => {
|
|
336
|
-
const
|
|
337
|
-
if (!
|
|
338
|
-
const
|
|
339
|
-
switch (
|
|
419
|
+
const c = w.current?.closest('[data-slot="combobox-command"]');
|
|
420
|
+
if (!c) return;
|
|
421
|
+
const g = (C) => {
|
|
422
|
+
switch (C.key) {
|
|
340
423
|
case "ArrowDown":
|
|
341
|
-
|
|
424
|
+
C.preventDefault(), C.stopPropagation(), j.current = !0, T((F) => F < b.length - 1 ? F + 1 : F);
|
|
342
425
|
break;
|
|
343
426
|
case "ArrowUp":
|
|
344
|
-
|
|
427
|
+
C.preventDefault(), C.stopPropagation(), j.current = !0, T((F) => F > 0 ? F - 1 : F);
|
|
345
428
|
break;
|
|
346
429
|
case "Enter":
|
|
347
|
-
if (
|
|
348
|
-
const
|
|
349
|
-
|
|
430
|
+
if (C.preventDefault(), C.stopPropagation(), S >= 0 && S < b.length) {
|
|
431
|
+
const F = a(b[S]);
|
|
432
|
+
P(F === h ? "" : F), R(!1);
|
|
350
433
|
}
|
|
351
434
|
break;
|
|
352
435
|
case "Home":
|
|
353
|
-
|
|
436
|
+
C.preventDefault(), C.stopPropagation(), j.current = !0, T(0);
|
|
354
437
|
break;
|
|
355
438
|
case "End":
|
|
356
|
-
|
|
439
|
+
C.preventDefault(), C.stopPropagation(), j.current = !0, T(b.length - 1);
|
|
357
440
|
}
|
|
358
441
|
};
|
|
359
|
-
return
|
|
442
|
+
return c.addEventListener("keydown", g, { capture: !0 }), () => c.removeEventListener("keydown", g, { capture: !0 });
|
|
360
443
|
}, [
|
|
361
|
-
|
|
444
|
+
b,
|
|
445
|
+
S,
|
|
362
446
|
h,
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
m
|
|
447
|
+
P,
|
|
448
|
+
R,
|
|
449
|
+
a
|
|
367
450
|
]);
|
|
368
|
-
const
|
|
369
|
-
const
|
|
370
|
-
return
|
|
371
|
-
|
|
372
|
-
}),
|
|
373
|
-
}, [
|
|
374
|
-
const
|
|
375
|
-
|
|
376
|
-
}, [
|
|
377
|
-
activeValue:
|
|
378
|
-
onItemPointerMove:
|
|
379
|
-
idPrefix:
|
|
380
|
-
filteredCount:
|
|
381
|
-
getItemPosition:
|
|
451
|
+
const _ = e.useMemo(() => {
|
|
452
|
+
const c = /* @__PURE__ */ new Map();
|
|
453
|
+
return b.forEach((g, C) => {
|
|
454
|
+
c.set(a(g), C);
|
|
455
|
+
}), c;
|
|
456
|
+
}, [b, a]), U = e.useCallback((c) => {
|
|
457
|
+
const g = _.get(c);
|
|
458
|
+
g !== void 0 && T(g);
|
|
459
|
+
}, [_]), G = e.useCallback((c) => (_.get(c) ?? 0) + 1, [_]), W = b.length, Q = e.useMemo(() => ({
|
|
460
|
+
activeValue: H,
|
|
461
|
+
onItemPointerMove: U,
|
|
462
|
+
idPrefix: z,
|
|
463
|
+
filteredCount: W,
|
|
464
|
+
getItemPosition: G
|
|
382
465
|
}), [
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
]), x =
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
466
|
+
H,
|
|
467
|
+
U,
|
|
468
|
+
z,
|
|
469
|
+
W,
|
|
470
|
+
G
|
|
471
|
+
]), x = H != null ? `${z}item-${H}` : void 0;
|
|
472
|
+
e.useEffect(() => (A(x), () => A(void 0)), [x, A]);
|
|
473
|
+
const $ = `${z}listbox`;
|
|
474
|
+
return e.useEffect(() => (L($), () => L(void 0)), [$, L]), b.length === 0 ? /* @__PURE__ */ l("div", {
|
|
475
|
+
ref: w,
|
|
476
|
+
className: O("scrollbar max-h-[300px] min-h-0 flex-1 scroll-py-1 overflow-x-hidden overflow-y-auto py-1", f),
|
|
477
|
+
"data-hook": v,
|
|
393
478
|
"data-slot": "combobox-virtual-list",
|
|
479
|
+
id: $,
|
|
394
480
|
role: "listbox",
|
|
395
|
-
children:
|
|
396
|
-
}) : /* @__PURE__ */
|
|
397
|
-
value:
|
|
398
|
-
children: /* @__PURE__ */
|
|
399
|
-
ref:
|
|
400
|
-
className:
|
|
401
|
-
"data-hook":
|
|
481
|
+
children: d
|
|
482
|
+
}) : /* @__PURE__ */ l(te.Provider, {
|
|
483
|
+
value: Q,
|
|
484
|
+
children: /* @__PURE__ */ l("div", {
|
|
485
|
+
ref: w,
|
|
486
|
+
className: O("scrollbar max-h-[300px] min-h-0 flex-1 scroll-py-1 overflow-x-hidden overflow-y-auto py-1", f),
|
|
487
|
+
"data-hook": v,
|
|
402
488
|
"data-slot": "combobox-virtual-list",
|
|
489
|
+
id: $,
|
|
403
490
|
role: "listbox",
|
|
404
|
-
children: /* @__PURE__ */
|
|
491
|
+
children: /* @__PURE__ */ l("div", {
|
|
405
492
|
className: "relative w-full",
|
|
406
493
|
style: { height: `${V.getTotalSize()}px` },
|
|
407
|
-
children: V.getVirtualItems().map((
|
|
494
|
+
children: V.getVirtualItems().map((c) => /* @__PURE__ */ l("div", {
|
|
408
495
|
ref: V.measureElement,
|
|
409
496
|
className: "absolute top-0 left-0 w-full px-2",
|
|
410
|
-
"data-index":
|
|
411
|
-
style: { transform: `translateY(${
|
|
412
|
-
children:
|
|
413
|
-
},
|
|
497
|
+
"data-index": c.index,
|
|
498
|
+
style: { transform: `translateY(${c.start}px)` },
|
|
499
|
+
children: s(b[c.index], c.index, I)
|
|
500
|
+
}, c.key))
|
|
414
501
|
})
|
|
415
502
|
})
|
|
416
503
|
});
|
|
417
504
|
}
|
|
418
|
-
var
|
|
505
|
+
var Ue = e.forwardRef(Se), Ee = e.forwardRef((t, r) => /* @__PURE__ */ l(fe, {
|
|
419
506
|
ref: r,
|
|
420
507
|
"data-slot": "combobox-empty",
|
|
421
508
|
...t
|
|
422
509
|
}));
|
|
423
|
-
|
|
424
|
-
var
|
|
510
|
+
Ee.displayName = "ComboboxEmpty";
|
|
511
|
+
var Le = e.forwardRef(({ children: t, ...r }, n) => {
|
|
425
512
|
const o = e.useRef(null);
|
|
426
|
-
return
|
|
427
|
-
Import: import { ComboboxVirtualList } from "@brightlocal/ui-components/combobox"`, [t]), /* @__PURE__ */
|
|
428
|
-
ref: (
|
|
429
|
-
o.current =
|
|
513
|
+
return Y(() => o.current ? o.current.querySelectorAll('[data-slot="combobox-item"]').length >= 100 : !1, `ComboboxGroup contains 100+ items. Use <ComboboxVirtualList> for large datasets to avoid DOM bloat and slow renders.
|
|
514
|
+
Import: import { ComboboxVirtualList } from "@brightlocal/ui-components/combobox"`, [t]), /* @__PURE__ */ l(me, {
|
|
515
|
+
ref: (i) => {
|
|
516
|
+
o.current = i, typeof n == "function" ? n(i) : n && (n.current = i);
|
|
430
517
|
},
|
|
431
518
|
"data-slot": "combobox-group",
|
|
432
519
|
...r,
|
|
433
520
|
children: t
|
|
434
521
|
});
|
|
435
522
|
});
|
|
436
|
-
|
|
437
|
-
function
|
|
523
|
+
Le.displayName = "ComboboxGroup";
|
|
524
|
+
function Ae(t, r, n) {
|
|
438
525
|
if (!r || !r.trim()) return t;
|
|
439
|
-
const o = new RegExp(`(${r.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})`, "gi"),
|
|
440
|
-
return /* @__PURE__ */
|
|
441
|
-
className:
|
|
442
|
-
children:
|
|
443
|
-
},
|
|
526
|
+
const o = new RegExp(`(${r.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})`, "gi"), i = t.split(o);
|
|
527
|
+
return /* @__PURE__ */ l("span", { children: i.map((u, s) => s % 2 === 1 ? /* @__PURE__ */ l("span", {
|
|
528
|
+
className: n,
|
|
529
|
+
children: u
|
|
530
|
+
}, s) : /* @__PURE__ */ l(e.Fragment, { children: u }, s)) });
|
|
444
531
|
}
|
|
445
|
-
var
|
|
446
|
-
const { value:
|
|
532
|
+
var Ne = e.forwardRef(({ value: t, label: r, dataHook: n, children: o, className: i, highlight: u, highlightClassName: s, keywords: d, onSelect: f, ...v }, p) => {
|
|
533
|
+
const { value: m, onValueChange: a, setOpen: y, registerItem: w, unregisterItem: k } = B(), h = e.useContext(te), P = m === t, R = e.useMemo(() => r || (typeof o == "string" ? o : typeof o == "number" ? String(o) : t), [
|
|
447
534
|
r,
|
|
448
535
|
o,
|
|
449
536
|
t
|
|
450
|
-
]),
|
|
537
|
+
]), M = e.useRef(w), I = e.useRef(k);
|
|
451
538
|
e.useEffect(() => {
|
|
452
|
-
|
|
453
|
-
}, [
|
|
454
|
-
const
|
|
539
|
+
M.current = w, I.current = k;
|
|
540
|
+
}, [w, k]);
|
|
541
|
+
const N = !!h;
|
|
455
542
|
e.useEffect(() => {
|
|
456
|
-
if (!
|
|
457
|
-
return
|
|
543
|
+
if (!N)
|
|
544
|
+
return M.current(t, R), () => I.current(t);
|
|
458
545
|
}, [
|
|
459
546
|
t,
|
|
460
|
-
|
|
461
|
-
|
|
547
|
+
R,
|
|
548
|
+
N
|
|
462
549
|
]);
|
|
463
|
-
const
|
|
464
|
-
|
|
465
|
-
},
|
|
466
|
-
if (
|
|
467
|
-
const
|
|
468
|
-
return /* @__PURE__ */
|
|
469
|
-
ref:
|
|
470
|
-
"aria-disabled":
|
|
471
|
-
"aria-posinset":
|
|
472
|
-
"aria-selected":
|
|
473
|
-
"aria-setsize":
|
|
474
|
-
className:
|
|
475
|
-
"data-highlighted":
|
|
476
|
-
"data-hook":
|
|
550
|
+
const A = () => {
|
|
551
|
+
a(t === m ? "" : t), y(!1), f?.(t);
|
|
552
|
+
}, L = () => u && typeof o == "string" ? Ae(o, u, s || "text-label font-semibold") : o;
|
|
553
|
+
if (h) {
|
|
554
|
+
const E = h.activeValue === t, D = !!v.disabled;
|
|
555
|
+
return /* @__PURE__ */ K("div", {
|
|
556
|
+
ref: p,
|
|
557
|
+
"aria-disabled": D || void 0,
|
|
558
|
+
"aria-posinset": h.getItemPosition(t),
|
|
559
|
+
"aria-selected": P,
|
|
560
|
+
"aria-setsize": h.filteredCount,
|
|
561
|
+
className: O("data-[highlighted=true]:bg-accent data-[highlighted=true]:text-accent-foreground text-label relative flex cursor-pointer items-center justify-between gap-2 rounded-sm px-2 py-3 outline-hidden select-none", "[&_svg]:pointer-events-none [&_svg]:shrink-0", D && "pointer-events-none opacity-50", i),
|
|
562
|
+
"data-highlighted": E || void 0,
|
|
563
|
+
"data-hook": n,
|
|
477
564
|
"data-slot": "combobox-item",
|
|
478
|
-
id: `${
|
|
565
|
+
id: `${h.idPrefix}item-${t}`,
|
|
479
566
|
role: "option",
|
|
480
567
|
tabIndex: -1,
|
|
481
|
-
onClick:
|
|
482
|
-
onKeyDown:
|
|
483
|
-
(
|
|
568
|
+
onClick: D ? void 0 : A,
|
|
569
|
+
onKeyDown: D ? void 0 : (S) => {
|
|
570
|
+
(S.key === "Enter" || S.key === " ") && A();
|
|
484
571
|
},
|
|
485
|
-
onPointerMove:
|
|
486
|
-
children: [
|
|
572
|
+
onPointerMove: D ? void 0 : () => h.onItemPointerMove(t),
|
|
573
|
+
children: [L(), P && /* @__PURE__ */ l(X, {
|
|
487
574
|
"aria-hidden": "true",
|
|
488
575
|
className: "text-muted-foreground shrink-0"
|
|
489
576
|
})]
|
|
490
577
|
});
|
|
491
578
|
}
|
|
492
|
-
return /* @__PURE__ */
|
|
493
|
-
ref:
|
|
494
|
-
className:
|
|
579
|
+
return /* @__PURE__ */ K(pe, {
|
|
580
|
+
ref: p,
|
|
581
|
+
className: O("justify-between", i),
|
|
495
582
|
"data-slot": "combobox-item",
|
|
496
|
-
dataHook:
|
|
497
|
-
keywords:
|
|
583
|
+
dataHook: n,
|
|
584
|
+
keywords: d ? [R, ...d] : [R],
|
|
498
585
|
value: t,
|
|
499
|
-
onSelect:
|
|
500
|
-
...
|
|
501
|
-
children: [
|
|
586
|
+
onSelect: A,
|
|
587
|
+
...v,
|
|
588
|
+
children: [L(), P && /* @__PURE__ */ l(X, {
|
|
502
589
|
"aria-hidden": "true",
|
|
503
590
|
className: "text-muted-foreground shrink-0"
|
|
504
591
|
})]
|
|
505
592
|
});
|
|
506
593
|
});
|
|
507
|
-
|
|
508
|
-
var
|
|
594
|
+
Ne.displayName = "ComboboxItem";
|
|
595
|
+
var Me = e.forwardRef((t, r) => /* @__PURE__ */ l(ge, {
|
|
509
596
|
ref: r,
|
|
510
597
|
"data-slot": "combobox-separator",
|
|
511
598
|
...t
|
|
512
599
|
}));
|
|
513
|
-
|
|
514
|
-
function
|
|
515
|
-
return /* @__PURE__ */
|
|
600
|
+
Me.displayName = "ComboboxSeparator";
|
|
601
|
+
function Ge({ className: t, children: r, loadingText: n }) {
|
|
602
|
+
return /* @__PURE__ */ l("div", {
|
|
516
603
|
"aria-live": "polite",
|
|
517
|
-
className:
|
|
604
|
+
className: O("text-body-sm text-muted-foreground relative flex items-center justify-center gap-2 py-6", "animate-entrance-fade flash-delay", t),
|
|
518
605
|
"data-slot": "combobox-loading",
|
|
519
606
|
role: "status",
|
|
520
|
-
children: r || /* @__PURE__ */
|
|
607
|
+
children: r || /* @__PURE__ */ K(ne, { children: [/* @__PURE__ */ l(se, { size: "md" }), /* @__PURE__ */ l("span", {
|
|
521
608
|
className: "sr-only",
|
|
522
|
-
children:
|
|
609
|
+
children: n ?? "Loading suggestions"
|
|
523
610
|
})] })
|
|
524
611
|
});
|
|
525
612
|
}
|
|
526
613
|
export {
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
614
|
+
He as Combobox,
|
|
615
|
+
Be as ComboboxContent,
|
|
616
|
+
Ee as ComboboxEmpty,
|
|
617
|
+
Le as ComboboxGroup,
|
|
618
|
+
Re as ComboboxInput,
|
|
619
|
+
Ne as ComboboxItem,
|
|
620
|
+
Ie as ComboboxList,
|
|
621
|
+
Ge as ComboboxLoading,
|
|
622
|
+
Me as ComboboxSeparator,
|
|
623
|
+
xe as ComboboxTrigger,
|
|
624
|
+
_e as ComboboxValue,
|
|
625
|
+
Ue as ComboboxVirtualList
|
|
539
626
|
};
|