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