@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/command.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as l, jsxs as _ } from "react/jsx-runtime";
|
|
2
2
|
import * as e from "react";
|
|
3
|
-
import { Command as
|
|
3
|
+
import { Command as P, defaultFilter as B } from "cmdk";
|
|
4
4
|
import { useVirtualizer as U } from "@tanstack/react-virtual";
|
|
5
5
|
import { Search as W, X, Check as F } from "@brightlocal/icons";
|
|
6
6
|
import { Button as Y } from "@brightlocal/ui-components/button";
|
|
7
|
-
import { cn as
|
|
7
|
+
import { cn as I } from "@brightlocal/ui-components/lib/utils";
|
|
8
8
|
import { useDevWarning as q } from "@brightlocal/ui-components/lib/use-dev-warning";
|
|
9
9
|
const T = e.createContext({
|
|
10
10
|
searchValue: "",
|
|
@@ -16,33 +16,33 @@ const T = e.createContext({
|
|
|
16
16
|
listboxId: void 0,
|
|
17
17
|
setListboxId: () => {
|
|
18
18
|
}
|
|
19
|
-
}), J = e.forwardRef(({ className: t, dataHook:
|
|
20
|
-
const [g,
|
|
19
|
+
}), J = e.forwardRef(({ className: t, dataHook: o, trackingEl: a, trackingLabel: n, ...r }, c) => {
|
|
20
|
+
const [g, h] = e.useState(""), [y, R] = e.useState(void 0), [w, k] = e.useState(
|
|
21
21
|
void 0
|
|
22
|
-
),
|
|
22
|
+
), v = e.useMemo(
|
|
23
23
|
() => ({
|
|
24
24
|
searchValue: g,
|
|
25
|
-
setSearchValue:
|
|
26
|
-
activeDescendantId:
|
|
27
|
-
setActiveDescendantId:
|
|
28
|
-
listboxId:
|
|
29
|
-
setListboxId:
|
|
25
|
+
setSearchValue: h,
|
|
26
|
+
activeDescendantId: y,
|
|
27
|
+
setActiveDescendantId: R,
|
|
28
|
+
listboxId: w,
|
|
29
|
+
setListboxId: k
|
|
30
30
|
}),
|
|
31
|
-
[g,
|
|
31
|
+
[g, y, w]
|
|
32
32
|
);
|
|
33
|
-
return /* @__PURE__ */
|
|
34
|
-
|
|
33
|
+
return /* @__PURE__ */ l(T.Provider, { value: v, children: /* @__PURE__ */ l(
|
|
34
|
+
P,
|
|
35
35
|
{
|
|
36
|
-
ref:
|
|
37
|
-
className:
|
|
36
|
+
ref: c,
|
|
37
|
+
className: I(
|
|
38
38
|
"bg-popover text-popover-foreground flex w-full flex-col overflow-hidden rounded-lg border shadow-md",
|
|
39
39
|
t
|
|
40
40
|
),
|
|
41
|
-
"data-hook":
|
|
41
|
+
"data-hook": o,
|
|
42
42
|
"data-slot": "command",
|
|
43
43
|
"data-tracking-el": a,
|
|
44
|
-
"data-tracking-label":
|
|
45
|
-
...
|
|
44
|
+
"data-tracking-label": n,
|
|
45
|
+
...r
|
|
46
46
|
}
|
|
47
47
|
) });
|
|
48
48
|
});
|
|
@@ -50,68 +50,69 @@ J.displayName = "Command";
|
|
|
50
50
|
const Q = e.forwardRef(
|
|
51
51
|
({
|
|
52
52
|
className: t,
|
|
53
|
-
dataHook:
|
|
53
|
+
dataHook: o,
|
|
54
54
|
trackingEl: a,
|
|
55
|
-
trackingLabel:
|
|
56
|
-
value:
|
|
57
|
-
onValueChange:
|
|
55
|
+
trackingLabel: n,
|
|
56
|
+
value: r,
|
|
57
|
+
onValueChange: c,
|
|
58
58
|
onClear: g,
|
|
59
|
-
debounceMs:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
debounceMs: h,
|
|
60
|
+
clearSearchAriaLabel: y,
|
|
61
|
+
...R
|
|
62
|
+
}, w) => {
|
|
63
|
+
const k = e.useRef(null), [v, b] = e.useState(""), s = e.useRef(
|
|
63
64
|
void 0
|
|
64
|
-
), { setSearchValue:
|
|
65
|
-
e.useImperativeHandle(
|
|
66
|
-
() => !!(
|
|
65
|
+
), { setSearchValue: N, activeDescendantId: x, listboxId: u } = e.useContext(T);
|
|
66
|
+
e.useImperativeHandle(w, () => k.current, []), q(
|
|
67
|
+
() => !!(h && h > 0 && r !== void 0),
|
|
67
68
|
"debounceMs is set on <CommandInput> 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.",
|
|
68
|
-
[
|
|
69
|
+
[h, r]
|
|
69
70
|
), e.useEffect(() => () => {
|
|
70
|
-
|
|
71
|
+
s.current && clearTimeout(s.current);
|
|
71
72
|
}, []), e.useEffect(() => {
|
|
72
|
-
const
|
|
73
|
-
|
|
73
|
+
const f = k.current;
|
|
74
|
+
f && (u && f.setAttribute("aria-controls", u), x ? f.setAttribute("aria-activedescendant", x) : f.removeAttribute("aria-activedescendant"));
|
|
74
75
|
});
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
|
|
76
|
+
const E = r !== void 0, S = E ? r : v, A = String(S).length > 0, M = (f) => {
|
|
77
|
+
E || b(f), N(f), h && h > 0 ? (clearTimeout(s.current), s.current = setTimeout(() => {
|
|
78
|
+
c?.(f);
|
|
79
|
+
}, h)) : c?.(f);
|
|
80
|
+
}, m = () => {
|
|
81
|
+
E || b(""), N(""), clearTimeout(s.current), c?.(""), g?.(), k.current?.focus();
|
|
81
82
|
};
|
|
82
83
|
return /* @__PURE__ */ _(
|
|
83
84
|
"div",
|
|
84
85
|
{
|
|
85
86
|
className: "border-base-border flex h-12 items-center gap-2 self-stretch border-b px-3",
|
|
86
|
-
"data-hook":
|
|
87
|
+
"data-hook": o,
|
|
87
88
|
"data-slot": "command-input-wrapper",
|
|
88
89
|
children: [
|
|
89
|
-
/* @__PURE__ */
|
|
90
|
-
/* @__PURE__ */
|
|
91
|
-
|
|
90
|
+
/* @__PURE__ */ l(W, { className: "shrink-0 opacity-50" }),
|
|
91
|
+
/* @__PURE__ */ l(
|
|
92
|
+
P.Input,
|
|
92
93
|
{
|
|
93
|
-
ref:
|
|
94
|
-
className:
|
|
94
|
+
ref: k,
|
|
95
|
+
className: I(
|
|
95
96
|
"placeholder:text-muted-foreground flex w-full bg-transparent text-base outline-hidden disabled:cursor-not-allowed disabled:opacity-50",
|
|
96
97
|
t
|
|
97
98
|
),
|
|
98
99
|
"data-slot": "command-input",
|
|
99
100
|
"data-tracking-el": a,
|
|
100
|
-
"data-tracking-label":
|
|
101
|
+
"data-tracking-label": n,
|
|
101
102
|
value: S,
|
|
102
|
-
onValueChange:
|
|
103
|
-
...
|
|
103
|
+
onValueChange: M,
|
|
104
|
+
...R
|
|
104
105
|
}
|
|
105
106
|
),
|
|
106
|
-
|
|
107
|
+
A && /* @__PURE__ */ l(
|
|
107
108
|
Y,
|
|
108
109
|
{
|
|
109
|
-
"aria-label": "Clear search",
|
|
110
|
+
"aria-label": y ?? "Clear search",
|
|
110
111
|
className: "text-muted-foreground hover:text-foreground",
|
|
111
112
|
dataHook: "command-input-clear",
|
|
112
113
|
variant: "ghost",
|
|
113
|
-
onClick:
|
|
114
|
-
children: /* @__PURE__ */
|
|
114
|
+
onClick: m,
|
|
115
|
+
children: /* @__PURE__ */ l(X, {})
|
|
115
116
|
}
|
|
116
117
|
)
|
|
117
118
|
]
|
|
@@ -120,61 +121,61 @@ const Q = e.forwardRef(
|
|
|
120
121
|
}
|
|
121
122
|
);
|
|
122
123
|
Q.displayName = "CommandInput";
|
|
123
|
-
const Z = e.forwardRef(({ className: t, dataHook:
|
|
124
|
-
|
|
124
|
+
const Z = e.forwardRef(({ className: t, dataHook: o, ...a }, n) => /* @__PURE__ */ l(
|
|
125
|
+
P.List,
|
|
125
126
|
{
|
|
126
|
-
ref:
|
|
127
|
-
className:
|
|
127
|
+
ref: n,
|
|
128
|
+
className: I(
|
|
128
129
|
"max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",
|
|
129
130
|
t
|
|
130
131
|
),
|
|
131
|
-
"data-hook":
|
|
132
|
+
"data-hook": o,
|
|
132
133
|
"data-slot": "command-list",
|
|
133
134
|
...a
|
|
134
135
|
}
|
|
135
136
|
));
|
|
136
137
|
Z.displayName = "CommandList";
|
|
137
|
-
const ee = e.forwardRef(({ dataHook: t, ...
|
|
138
|
-
const
|
|
139
|
-
(
|
|
140
|
-
|
|
138
|
+
const ee = e.forwardRef(({ dataHook: t, ...o }, a) => {
|
|
139
|
+
const n = e.useCallback(
|
|
140
|
+
(r) => {
|
|
141
|
+
r?.setAttribute("role", "option"), typeof a == "function" ? a(r) : a && (a.current = r);
|
|
141
142
|
},
|
|
142
143
|
[a]
|
|
143
144
|
);
|
|
144
|
-
return /* @__PURE__ */
|
|
145
|
-
|
|
145
|
+
return /* @__PURE__ */ l(
|
|
146
|
+
P.Empty,
|
|
146
147
|
{
|
|
147
|
-
ref:
|
|
148
|
+
ref: n,
|
|
148
149
|
"aria-disabled": "true",
|
|
149
150
|
"aria-selected": "false",
|
|
150
151
|
className: "py-6 text-center text-sm",
|
|
151
152
|
"data-hook": t,
|
|
152
153
|
"data-slot": "command-empty",
|
|
153
|
-
...
|
|
154
|
+
...o
|
|
154
155
|
}
|
|
155
156
|
);
|
|
156
157
|
});
|
|
157
158
|
ee.displayName = "CommandEmpty";
|
|
158
|
-
const te = e.forwardRef(({ className: t, dataHook:
|
|
159
|
-
|
|
159
|
+
const te = e.forwardRef(({ className: t, dataHook: o, ...a }, n) => /* @__PURE__ */ l(
|
|
160
|
+
P.Group,
|
|
160
161
|
{
|
|
161
|
-
ref:
|
|
162
|
-
className:
|
|
162
|
+
ref: n,
|
|
163
|
+
className: I(
|
|
163
164
|
"text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden px-2 py-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",
|
|
164
165
|
t
|
|
165
166
|
),
|
|
166
|
-
"data-hook":
|
|
167
|
+
"data-hook": o,
|
|
167
168
|
"data-slot": "command-group",
|
|
168
169
|
...a
|
|
169
170
|
}
|
|
170
171
|
));
|
|
171
172
|
te.displayName = "CommandGroup";
|
|
172
|
-
const ae = e.forwardRef(({ className: t, dataHook:
|
|
173
|
-
|
|
173
|
+
const ae = e.forwardRef(({ className: t, dataHook: o, ...a }, n) => /* @__PURE__ */ l(
|
|
174
|
+
P.Separator,
|
|
174
175
|
{
|
|
175
|
-
ref:
|
|
176
|
-
className:
|
|
177
|
-
"data-hook":
|
|
176
|
+
ref: n,
|
|
177
|
+
className: I("bg-border -mx-1 h-px", t),
|
|
178
|
+
"data-hook": o,
|
|
178
179
|
"data-slot": "command-separator",
|
|
179
180
|
...a
|
|
180
181
|
}
|
|
@@ -183,48 +184,48 @@ ae.displayName = "CommandSeparator";
|
|
|
183
184
|
const oe = e.forwardRef(
|
|
184
185
|
({
|
|
185
186
|
className: t,
|
|
186
|
-
dataHook:
|
|
187
|
+
dataHook: o,
|
|
187
188
|
trackingEl: a,
|
|
188
|
-
trackingLabel:
|
|
189
|
-
selected:
|
|
190
|
-
children:
|
|
189
|
+
trackingLabel: n,
|
|
190
|
+
selected: r,
|
|
191
|
+
children: c,
|
|
191
192
|
...g
|
|
192
|
-
},
|
|
193
|
-
|
|
193
|
+
}, h) => /* @__PURE__ */ _(
|
|
194
|
+
P.Item,
|
|
194
195
|
{
|
|
195
|
-
ref:
|
|
196
|
-
className:
|
|
196
|
+
ref: h,
|
|
197
|
+
className: I(
|
|
197
198
|
"data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-3 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
198
199
|
t
|
|
199
200
|
),
|
|
200
|
-
"data-hook":
|
|
201
|
-
"data-selected-item":
|
|
201
|
+
"data-hook": o,
|
|
202
|
+
"data-selected-item": r || void 0,
|
|
202
203
|
"data-slot": "command-item",
|
|
203
204
|
"data-tracking-el": a,
|
|
204
|
-
"data-tracking-label":
|
|
205
|
+
"data-tracking-label": n,
|
|
205
206
|
...g,
|
|
206
207
|
children: [
|
|
207
|
-
|
|
208
|
-
|
|
208
|
+
c,
|
|
209
|
+
r && /* @__PURE__ */ l(F, { className: "text-foreground ml-auto" })
|
|
209
210
|
]
|
|
210
211
|
}
|
|
211
212
|
)
|
|
212
213
|
);
|
|
213
214
|
oe.displayName = "CommandItem";
|
|
214
215
|
const ne = e.forwardRef(
|
|
215
|
-
({ className: t, dataHook:
|
|
216
|
+
({ className: t, dataHook: o, trackingEl: a, trackingLabel: n, ...r }, c) => /* @__PURE__ */ l(
|
|
216
217
|
"span",
|
|
217
218
|
{
|
|
218
|
-
ref:
|
|
219
|
-
className:
|
|
219
|
+
ref: c,
|
|
220
|
+
className: I(
|
|
220
221
|
"text-muted-foreground ml-auto text-xs tracking-widest",
|
|
221
222
|
t
|
|
222
223
|
),
|
|
223
|
-
"data-hook":
|
|
224
|
+
"data-hook": o,
|
|
224
225
|
"data-slot": "command-shortcut",
|
|
225
226
|
"data-tracking-el": a,
|
|
226
|
-
"data-tracking-label":
|
|
227
|
-
...
|
|
227
|
+
"data-tracking-label": n,
|
|
228
|
+
...r
|
|
228
229
|
}
|
|
229
230
|
)
|
|
230
231
|
);
|
|
@@ -232,146 +233,146 @@ ne.displayName = "CommandShortcut";
|
|
|
232
233
|
const K = e.createContext(null);
|
|
233
234
|
function re({
|
|
234
235
|
items: t,
|
|
235
|
-
getItemValue:
|
|
236
|
+
getItemValue: o,
|
|
236
237
|
getItemLabel: a,
|
|
237
|
-
getItemKeywords:
|
|
238
|
-
estimateSize:
|
|
239
|
-
overscan:
|
|
238
|
+
getItemKeywords: n,
|
|
239
|
+
estimateSize: r = 44,
|
|
240
|
+
overscan: c = 5,
|
|
240
241
|
children: g,
|
|
241
|
-
renderEmpty:
|
|
242
|
-
"aria-label":
|
|
243
|
-
className:
|
|
244
|
-
dataHook:
|
|
245
|
-
},
|
|
246
|
-
const
|
|
247
|
-
e.useImperativeHandle(
|
|
242
|
+
renderEmpty: h,
|
|
243
|
+
"aria-label": y,
|
|
244
|
+
className: R,
|
|
245
|
+
dataHook: w
|
|
246
|
+
}, k) {
|
|
247
|
+
const v = e.useRef(null), { searchValue: b, setActiveDescendantId: s, setListboxId: N } = e.useContext(T), [x, u] = e.useState(0), E = e.useId(), S = e.useId(), A = e.useRef(/* @__PURE__ */ new Map());
|
|
248
|
+
e.useImperativeHandle(k, () => v.current, []);
|
|
248
249
|
const M = e.useMemo(
|
|
249
|
-
() => a ??
|
|
250
|
-
[a,
|
|
251
|
-
),
|
|
252
|
-
if (!
|
|
250
|
+
() => a ?? o,
|
|
251
|
+
[a, o]
|
|
252
|
+
), m = e.useMemo(() => {
|
|
253
|
+
if (!b.trim()) return t;
|
|
253
254
|
const d = [];
|
|
254
|
-
for (const
|
|
255
|
-
let i = B(M(
|
|
256
|
-
if (
|
|
257
|
-
for (const
|
|
258
|
-
i = Math.max(i, B(
|
|
259
|
-
i > 0 && d.push({ item:
|
|
255
|
+
for (const p of t) {
|
|
256
|
+
let i = B(M(p), b);
|
|
257
|
+
if (n)
|
|
258
|
+
for (const C of n(p))
|
|
259
|
+
i = Math.max(i, B(C, b));
|
|
260
|
+
i > 0 && d.push({ item: p, score: i });
|
|
260
261
|
}
|
|
261
|
-
return d.sort((
|
|
262
|
-
}, [t,
|
|
263
|
-
count:
|
|
264
|
-
getScrollElement: () =>
|
|
265
|
-
estimateSize: () =>
|
|
266
|
-
overscan:
|
|
267
|
-
}),
|
|
262
|
+
return d.sort((p, i) => i.score - p.score), d.map((p) => p.item);
|
|
263
|
+
}, [t, b, M, n]), f = U({
|
|
264
|
+
count: m.length,
|
|
265
|
+
getScrollElement: () => v.current,
|
|
266
|
+
estimateSize: () => r,
|
|
267
|
+
overscan: c
|
|
268
|
+
}), D = x >= 0 && x < m.length ? o(m[x]) : null;
|
|
268
269
|
e.useEffect(() => {
|
|
269
|
-
|
|
270
|
-
}, [
|
|
271
|
-
const
|
|
270
|
+
u(0);
|
|
271
|
+
}, [b, m.length]);
|
|
272
|
+
const L = e.useRef(!1);
|
|
272
273
|
e.useEffect(() => {
|
|
273
|
-
|
|
274
|
-
}, [x,
|
|
275
|
-
const d =
|
|
274
|
+
L.current && x >= 0 && x < m.length && f.scrollToIndex(x, { align: "auto" }), L.current = !1;
|
|
275
|
+
}, [x, m.length, f]), e.useEffect(() => {
|
|
276
|
+
const d = v.current?.closest(
|
|
276
277
|
'[data-slot="command"]'
|
|
277
278
|
);
|
|
278
279
|
if (!d) return;
|
|
279
|
-
const
|
|
280
|
+
const p = (i) => {
|
|
280
281
|
switch (i.key) {
|
|
281
282
|
case "ArrowDown":
|
|
282
|
-
i.preventDefault(), i.stopPropagation(),
|
|
283
|
-
(
|
|
283
|
+
i.preventDefault(), i.stopPropagation(), L.current = !0, u(
|
|
284
|
+
(C) => C < m.length - 1 ? C + 1 : C
|
|
284
285
|
);
|
|
285
286
|
break;
|
|
286
287
|
case "ArrowUp":
|
|
287
|
-
i.preventDefault(), i.stopPropagation(),
|
|
288
|
+
i.preventDefault(), i.stopPropagation(), L.current = !0, u((C) => C > 0 ? C - 1 : C);
|
|
288
289
|
break;
|
|
289
290
|
case "Enter": {
|
|
290
|
-
i.preventDefault(), i.stopPropagation(),
|
|
291
|
+
i.preventDefault(), i.stopPropagation(), D != null && A.current.get(D)?.();
|
|
291
292
|
break;
|
|
292
293
|
}
|
|
293
294
|
case "Home":
|
|
294
|
-
i.preventDefault(), i.stopPropagation(),
|
|
295
|
+
i.preventDefault(), i.stopPropagation(), L.current = !0, u(0);
|
|
295
296
|
break;
|
|
296
297
|
case "End":
|
|
297
|
-
i.preventDefault(), i.stopPropagation(),
|
|
298
|
+
i.preventDefault(), i.stopPropagation(), L.current = !0, u(m.length - 1);
|
|
298
299
|
break;
|
|
299
300
|
}
|
|
300
301
|
};
|
|
301
|
-
return d.addEventListener("keydown",
|
|
302
|
-
}, [
|
|
302
|
+
return d.addEventListener("keydown", p, { capture: !0 }), () => d.removeEventListener("keydown", p, { capture: !0 });
|
|
303
|
+
}, [m, D]);
|
|
303
304
|
const V = e.useMemo(() => {
|
|
304
305
|
const d = /* @__PURE__ */ new Map();
|
|
305
|
-
return
|
|
306
|
-
d.set(
|
|
306
|
+
return m.forEach((p, i) => {
|
|
307
|
+
d.set(o(p), i);
|
|
307
308
|
}), d;
|
|
308
|
-
}, [
|
|
309
|
+
}, [m, o]), $ = e.useCallback(
|
|
309
310
|
(d) => {
|
|
310
|
-
const
|
|
311
|
-
|
|
311
|
+
const p = V.get(d);
|
|
312
|
+
p !== void 0 && u(p);
|
|
312
313
|
},
|
|
313
314
|
[V]
|
|
314
315
|
), z = e.useCallback(
|
|
315
316
|
(d) => (V.get(d) ?? 0) + 1,
|
|
316
317
|
[V]
|
|
317
|
-
), H =
|
|
318
|
+
), H = m.length, O = e.useMemo(
|
|
318
319
|
() => ({
|
|
319
|
-
activeValue:
|
|
320
|
+
activeValue: D,
|
|
320
321
|
onItemPointerMove: $,
|
|
321
|
-
idPrefix:
|
|
322
|
+
idPrefix: E,
|
|
322
323
|
filteredCount: H,
|
|
323
324
|
getItemPosition: z,
|
|
324
325
|
onSelectCallbacks: A
|
|
325
326
|
}),
|
|
326
|
-
[
|
|
327
|
-
), G =
|
|
328
|
-
e.useEffect(() => (
|
|
329
|
-
const j =
|
|
327
|
+
[D, $, E, H, z]
|
|
328
|
+
), G = D != null ? `${E}item-${D}` : void 0;
|
|
329
|
+
e.useEffect(() => (s(G), () => s(void 0)), [G, s]), e.useEffect(() => (N(S), () => N(void 0)), [S, N]);
|
|
330
|
+
const j = I(
|
|
330
331
|
"scrollbar max-h-[300px] min-h-0 flex-1 scroll-py-1 overflow-x-hidden overflow-y-auto py-1",
|
|
331
|
-
|
|
332
|
+
R
|
|
332
333
|
);
|
|
333
|
-
return
|
|
334
|
+
return m.length === 0 ? /* @__PURE__ */ l(
|
|
334
335
|
"div",
|
|
335
336
|
{
|
|
336
|
-
ref:
|
|
337
|
-
"aria-label":
|
|
337
|
+
ref: v,
|
|
338
|
+
"aria-label": y,
|
|
338
339
|
className: j,
|
|
339
|
-
"data-hook":
|
|
340
|
+
"data-hook": w,
|
|
340
341
|
"data-slot": "command-virtual-list",
|
|
341
|
-
id:
|
|
342
|
+
id: S,
|
|
342
343
|
role: "listbox",
|
|
343
344
|
tabIndex: -1,
|
|
344
|
-
children:
|
|
345
|
+
children: h
|
|
345
346
|
}
|
|
346
|
-
) : /* @__PURE__ */
|
|
347
|
+
) : /* @__PURE__ */ l(K.Provider, { value: O, children: /* @__PURE__ */ l(
|
|
347
348
|
"div",
|
|
348
349
|
{
|
|
349
|
-
ref:
|
|
350
|
-
"aria-label":
|
|
350
|
+
ref: v,
|
|
351
|
+
"aria-label": y,
|
|
351
352
|
className: j,
|
|
352
|
-
"data-hook":
|
|
353
|
+
"data-hook": w,
|
|
353
354
|
"data-slot": "command-virtual-list",
|
|
354
|
-
id:
|
|
355
|
+
id: S,
|
|
355
356
|
role: "listbox",
|
|
356
357
|
tabIndex: -1,
|
|
357
|
-
children: /* @__PURE__ */
|
|
358
|
+
children: /* @__PURE__ */ l(
|
|
358
359
|
"div",
|
|
359
360
|
{
|
|
360
361
|
className: "relative w-full",
|
|
361
|
-
style: { height: `${
|
|
362
|
-
children:
|
|
362
|
+
style: { height: `${f.getTotalSize()}px` },
|
|
363
|
+
children: f.getVirtualItems().map((d) => /* @__PURE__ */ l(
|
|
363
364
|
"div",
|
|
364
365
|
{
|
|
365
|
-
ref:
|
|
366
|
+
ref: f.measureElement,
|
|
366
367
|
className: "absolute top-0 left-0 w-full px-2",
|
|
367
368
|
"data-index": d.index,
|
|
368
369
|
style: {
|
|
369
370
|
transform: `translateY(${d.start}px)`
|
|
370
371
|
},
|
|
371
372
|
children: g(
|
|
372
|
-
|
|
373
|
+
m[d.index],
|
|
373
374
|
d.index,
|
|
374
|
-
|
|
375
|
+
b
|
|
375
376
|
)
|
|
376
377
|
},
|
|
377
378
|
d.key
|
|
@@ -384,66 +385,66 @@ function re({
|
|
|
384
385
|
const pe = e.forwardRef(re), se = e.forwardRef(
|
|
385
386
|
({
|
|
386
387
|
value: t,
|
|
387
|
-
dataHook:
|
|
388
|
+
dataHook: o,
|
|
388
389
|
trackingEl: a,
|
|
389
|
-
trackingLabel:
|
|
390
|
-
selected:
|
|
391
|
-
disabled:
|
|
390
|
+
trackingLabel: n,
|
|
391
|
+
selected: r,
|
|
392
|
+
disabled: c,
|
|
392
393
|
onSelect: g,
|
|
393
|
-
children:
|
|
394
|
-
className:
|
|
395
|
-
onClick:
|
|
396
|
-
onKeyDown:
|
|
397
|
-
onPointerMove:
|
|
398
|
-
...
|
|
399
|
-
},
|
|
400
|
-
const
|
|
394
|
+
children: h,
|
|
395
|
+
className: y,
|
|
396
|
+
onClick: R,
|
|
397
|
+
onKeyDown: w,
|
|
398
|
+
onPointerMove: k,
|
|
399
|
+
...v
|
|
400
|
+
}, b) => {
|
|
401
|
+
const s = e.useContext(K), N = s?.activeValue === t, x = e.useRef(g);
|
|
401
402
|
return e.useEffect(() => {
|
|
402
403
|
x.current = g;
|
|
403
404
|
}), e.useEffect(() => {
|
|
404
|
-
if (
|
|
405
|
-
return
|
|
405
|
+
if (s)
|
|
406
|
+
return s.onSelectCallbacks.current.set(
|
|
406
407
|
t,
|
|
407
408
|
() => x.current?.()
|
|
408
409
|
), () => {
|
|
409
|
-
|
|
410
|
+
s.onSelectCallbacks.current.delete(t);
|
|
410
411
|
};
|
|
411
|
-
}, [t,
|
|
412
|
+
}, [t, s]), /* @__PURE__ */ _(
|
|
412
413
|
"div",
|
|
413
414
|
{
|
|
414
|
-
ref:
|
|
415
|
-
...
|
|
416
|
-
"aria-disabled":
|
|
417
|
-
"aria-posinset":
|
|
418
|
-
"aria-selected":
|
|
419
|
-
"aria-setsize":
|
|
420
|
-
className:
|
|
415
|
+
ref: b,
|
|
416
|
+
...v,
|
|
417
|
+
"aria-disabled": c || void 0,
|
|
418
|
+
"aria-posinset": s?.getItemPosition(t),
|
|
419
|
+
"aria-selected": r || void 0,
|
|
420
|
+
"aria-setsize": s?.filteredCount,
|
|
421
|
+
className: I(
|
|
421
422
|
"data-[highlighted=true]:bg-accent data-[highlighted=true]:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-3 text-sm outline-hidden select-none",
|
|
422
423
|
"[&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
423
|
-
|
|
424
|
-
|
|
424
|
+
c && "pointer-events-none opacity-50",
|
|
425
|
+
y
|
|
425
426
|
),
|
|
426
|
-
"data-highlighted":
|
|
427
|
-
"data-hook":
|
|
428
|
-
"data-selected-item":
|
|
427
|
+
"data-highlighted": N || void 0,
|
|
428
|
+
"data-hook": o,
|
|
429
|
+
"data-selected-item": r || void 0,
|
|
429
430
|
"data-slot": "command-virtual-item",
|
|
430
431
|
"data-tracking-el": a,
|
|
431
|
-
"data-tracking-label":
|
|
432
|
-
id:
|
|
432
|
+
"data-tracking-label": n,
|
|
433
|
+
id: s ? `${s.idPrefix}item-${t}` : void 0,
|
|
433
434
|
role: "option",
|
|
434
435
|
tabIndex: -1,
|
|
435
|
-
onClick:
|
|
436
|
-
g?.(),
|
|
436
|
+
onClick: c ? void 0 : (u) => {
|
|
437
|
+
g?.(), R?.(u);
|
|
437
438
|
},
|
|
438
|
-
onKeyDown:
|
|
439
|
-
(
|
|
439
|
+
onKeyDown: c ? void 0 : (u) => {
|
|
440
|
+
(u.key === "Enter" || u.key === " ") && g?.(), w?.(u);
|
|
440
441
|
},
|
|
441
|
-
onPointerMove:
|
|
442
|
-
|
|
442
|
+
onPointerMove: c ? void 0 : (u) => {
|
|
443
|
+
s?.onItemPointerMove(t), k?.(u);
|
|
443
444
|
},
|
|
444
445
|
children: [
|
|
445
|
-
|
|
446
|
-
|
|
446
|
+
h,
|
|
447
|
+
r && /* @__PURE__ */ l(F, { className: "text-foreground ml-auto" })
|
|
447
448
|
]
|
|
448
449
|
}
|
|
449
450
|
);
|