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