@brightlocal/ui-components 1.2.2 → 1.2.4
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 -112
- package/dist/blocks/input-list.cjs +2 -2
- package/dist/blocks/input-list.d.ts.map +1 -1
- package/dist/blocks/input-list.js +142 -166
- package/dist/combobox.cjs +1 -1
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +77 -73
- package/package.json +3 -3
- package/src/blocks/input-list.tsx +94 -124
- package/src/components/combobox.tsx +6 -2
package/dist/combobox.js
CHANGED
|
@@ -6,9 +6,9 @@ import { defaultFilter as P } from "cmdk";
|
|
|
6
6
|
import { cn as y } from "@brightlocal/ui-components/lib/utils";
|
|
7
7
|
import { Popover as G, PopoverContent as U, PopoverTrigger as _ } from "@brightlocal/ui-components/popover";
|
|
8
8
|
import { Command as $, CommandEmpty as q, CommandGroup as z, CommandInput as D, CommandItem as H, CommandList as V, CommandSeparator as B } from "@brightlocal/ui-components/command";
|
|
9
|
-
const
|
|
9
|
+
const F = t.createContext(null);
|
|
10
10
|
function I() {
|
|
11
|
-
const e = t.useContext(
|
|
11
|
+
const e = t.useContext(F);
|
|
12
12
|
if (!e)
|
|
13
13
|
throw new Error("Combobox components must be used within a <Combobox>");
|
|
14
14
|
return e;
|
|
@@ -18,14 +18,14 @@ function ue({
|
|
|
18
18
|
onValueChange: o,
|
|
19
19
|
open: n,
|
|
20
20
|
onOpenChange: r,
|
|
21
|
-
shouldFilter:
|
|
22
|
-
disabled:
|
|
23
|
-
itemToStringValue:
|
|
24
|
-
children:
|
|
21
|
+
shouldFilter: d = !0,
|
|
22
|
+
disabled: u = !1,
|
|
23
|
+
itemToStringValue: c,
|
|
24
|
+
children: m
|
|
25
25
|
}) {
|
|
26
|
-
const [h, v] = t.useState(""), [f, w] = t.useState(!1), [C,
|
|
26
|
+
const [h, v] = t.useState(""), [f, w] = t.useState(!1), [C, i] = t.useState(
|
|
27
27
|
() => /* @__PURE__ */ new Map()
|
|
28
|
-
), p = e !== void 0, x = n !== void 0,
|
|
28
|
+
), p = e !== void 0, x = n !== void 0, s = p ? e : h, b = x ? n : f, g = t.useCallback(
|
|
29
29
|
(l) => {
|
|
30
30
|
x || w(l), r?.(l);
|
|
31
31
|
},
|
|
@@ -36,36 +36,36 @@ function ue({
|
|
|
36
36
|
},
|
|
37
37
|
[p, o]
|
|
38
38
|
), N = t.useCallback((l, L) => {
|
|
39
|
-
|
|
39
|
+
i((S) => {
|
|
40
40
|
if (S.get(l) === L) return S;
|
|
41
|
-
const
|
|
42
|
-
return
|
|
41
|
+
const T = new Map(S);
|
|
42
|
+
return T.set(l, L), T;
|
|
43
43
|
});
|
|
44
44
|
}, []), R = t.useMemo(
|
|
45
45
|
() => ({
|
|
46
|
-
open:
|
|
46
|
+
open: b,
|
|
47
47
|
setOpen: g,
|
|
48
|
-
value:
|
|
48
|
+
value: s,
|
|
49
49
|
onValueChange: k,
|
|
50
|
-
shouldFilter:
|
|
51
|
-
disabled:
|
|
50
|
+
shouldFilter: d,
|
|
51
|
+
disabled: u,
|
|
52
52
|
itemLabels: C,
|
|
53
53
|
registerItem: N,
|
|
54
|
-
itemToStringValue:
|
|
54
|
+
itemToStringValue: c
|
|
55
55
|
}),
|
|
56
56
|
[
|
|
57
|
-
|
|
57
|
+
b,
|
|
58
58
|
g,
|
|
59
|
-
|
|
59
|
+
s,
|
|
60
60
|
k,
|
|
61
|
-
i,
|
|
62
61
|
d,
|
|
62
|
+
u,
|
|
63
63
|
C,
|
|
64
64
|
N,
|
|
65
|
-
|
|
65
|
+
c
|
|
66
66
|
]
|
|
67
67
|
);
|
|
68
|
-
return /* @__PURE__ */ a(
|
|
68
|
+
return /* @__PURE__ */ a(F.Provider, { value: R, children: /* @__PURE__ */ a(G, { open: b, onOpenChange: g, children: m }) });
|
|
69
69
|
}
|
|
70
70
|
const J = O(
|
|
71
71
|
[
|
|
@@ -109,12 +109,12 @@ const J = O(
|
|
|
109
109
|
variant: o,
|
|
110
110
|
dataHook: n,
|
|
111
111
|
error: r,
|
|
112
|
-
trackingEl:
|
|
113
|
-
trackingLabel:
|
|
114
|
-
children:
|
|
115
|
-
...
|
|
112
|
+
trackingEl: d,
|
|
113
|
+
trackingLabel: u,
|
|
114
|
+
children: c,
|
|
115
|
+
...m
|
|
116
116
|
}, h) => {
|
|
117
|
-
const { open: v, disabled: f, value: w } = I(), C = t.useId(),
|
|
117
|
+
const { open: v, disabled: f, value: w } = I(), C = t.useId(), i = !w, p = r || m["aria-invalid"] === !0 || m["aria-invalid"] === "true";
|
|
118
118
|
return /* @__PURE__ */ a(_, { asChild: !0, children: /* @__PURE__ */ E(
|
|
119
119
|
"button",
|
|
120
120
|
{
|
|
@@ -129,17 +129,17 @@ const J = O(
|
|
|
129
129
|
e
|
|
130
130
|
),
|
|
131
131
|
"data-hook": n,
|
|
132
|
-
"data-placeholder":
|
|
132
|
+
"data-placeholder": i,
|
|
133
133
|
"data-slot": "combobox-trigger",
|
|
134
134
|
"data-state": v ? "open" : "closed",
|
|
135
|
-
"data-tracking-el":
|
|
136
|
-
"data-tracking-label":
|
|
137
|
-
disabled: f ||
|
|
135
|
+
"data-tracking-el": d || "combobox-trigger",
|
|
136
|
+
"data-tracking-label": u,
|
|
137
|
+
disabled: f || m.disabled,
|
|
138
138
|
role: "combobox",
|
|
139
139
|
type: "button",
|
|
140
|
-
...
|
|
140
|
+
...m,
|
|
141
141
|
children: [
|
|
142
|
-
|
|
142
|
+
c,
|
|
143
143
|
/* @__PURE__ */ a(
|
|
144
144
|
j,
|
|
145
145
|
{
|
|
@@ -154,7 +154,7 @@ const J = O(
|
|
|
154
154
|
);
|
|
155
155
|
K.displayName = "ComboboxTrigger";
|
|
156
156
|
function ce({ placeholder: e, className: o }) {
|
|
157
|
-
const { value: n, itemLabels: r } = I(),
|
|
157
|
+
const { value: n, itemLabels: r } = I(), d = n ? r.get(n) || n : e;
|
|
158
158
|
return /* @__PURE__ */ a(
|
|
159
159
|
"span",
|
|
160
160
|
{
|
|
@@ -163,7 +163,7 @@ function ce({ placeholder: e, className: o }) {
|
|
|
163
163
|
o
|
|
164
164
|
),
|
|
165
165
|
"data-slot": "combobox-value",
|
|
166
|
-
children:
|
|
166
|
+
children: d
|
|
167
167
|
}
|
|
168
168
|
);
|
|
169
169
|
}
|
|
@@ -172,40 +172,44 @@ function le({
|
|
|
172
172
|
className: o,
|
|
173
173
|
children: n,
|
|
174
174
|
align: r = "start",
|
|
175
|
-
side:
|
|
176
|
-
sideOffset:
|
|
177
|
-
avoidCollisions:
|
|
178
|
-
hideList:
|
|
175
|
+
side: d = "bottom",
|
|
176
|
+
sideOffset: u,
|
|
177
|
+
avoidCollisions: c,
|
|
178
|
+
hideList: m = !1
|
|
179
179
|
}) {
|
|
180
180
|
const { open: h, shouldFilter: v, itemToStringValue: f } = I(), [w, C] = t.useState(
|
|
181
181
|
null
|
|
182
|
-
),
|
|
183
|
-
if (
|
|
184
|
-
let
|
|
182
|
+
), i = t.useRef(null), p = t.useCallback((s) => {
|
|
183
|
+
if (i.current?.(), i.current = null, !s) return;
|
|
184
|
+
let b = !1;
|
|
185
185
|
const g = (l) => {
|
|
186
|
-
|
|
186
|
+
b || (l === "top" || l === "bottom") && (b = !0, k.disconnect(), C(l));
|
|
187
187
|
}, k = new MutationObserver(() => {
|
|
188
|
-
g(
|
|
188
|
+
g(s.getAttribute("data-side"));
|
|
189
189
|
});
|
|
190
|
-
k.observe(
|
|
190
|
+
k.observe(s, {
|
|
191
191
|
attributes: !0,
|
|
192
192
|
attributeFilter: ["data-side"]
|
|
193
193
|
});
|
|
194
194
|
let N = 0, R = 0;
|
|
195
195
|
N = requestAnimationFrame(() => {
|
|
196
196
|
R = requestAnimationFrame(() => {
|
|
197
|
-
g(
|
|
197
|
+
g(s.getAttribute("data-side"));
|
|
198
198
|
});
|
|
199
|
-
}),
|
|
200
|
-
|
|
199
|
+
}), i.current = () => {
|
|
200
|
+
b = !0, k.disconnect(), cancelAnimationFrame(N), cancelAnimationFrame(R);
|
|
201
201
|
};
|
|
202
202
|
}, []);
|
|
203
203
|
t.useEffect(() => {
|
|
204
|
-
|
|
204
|
+
if (!h) {
|
|
205
|
+
i.current?.(), i.current = null;
|
|
206
|
+
const s = setTimeout(() => C(null), 150);
|
|
207
|
+
return () => clearTimeout(s);
|
|
208
|
+
}
|
|
205
209
|
}, [h]);
|
|
206
210
|
const x = t.useMemo(() => {
|
|
207
211
|
if (f)
|
|
208
|
-
return (
|
|
212
|
+
return (s, b, g) => P(f(s), b, g);
|
|
209
213
|
}, [f]);
|
|
210
214
|
return /* @__PURE__ */ a(
|
|
211
215
|
U,
|
|
@@ -213,17 +217,17 @@ function le({
|
|
|
213
217
|
ref: p,
|
|
214
218
|
align: r,
|
|
215
219
|
"aria-label": "Options",
|
|
216
|
-
avoidCollisions:
|
|
220
|
+
avoidCollisions: c,
|
|
217
221
|
className: y("w-[var(--radix-popover-trigger-width)] p-0", o),
|
|
218
222
|
"data-slot": "combobox-popover",
|
|
219
|
-
side: w ??
|
|
220
|
-
sideOffset:
|
|
223
|
+
side: w ?? d,
|
|
224
|
+
sideOffset: u,
|
|
221
225
|
children: /* @__PURE__ */ a(
|
|
222
226
|
$,
|
|
223
227
|
{
|
|
224
228
|
className: y(
|
|
225
229
|
"border-0 shadow-none",
|
|
226
|
-
|
|
230
|
+
m && "[&_[data-slot='command-input-wrapper']]:border-b-0"
|
|
227
231
|
),
|
|
228
232
|
"data-slot": "combobox-command",
|
|
229
233
|
dataHook: e || "combobox-command",
|
|
@@ -249,9 +253,9 @@ function Z(e, o, n) {
|
|
|
249
253
|
const r = new RegExp(
|
|
250
254
|
`(${o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})`,
|
|
251
255
|
"gi"
|
|
252
|
-
),
|
|
253
|
-
return /* @__PURE__ */ a("span", { children:
|
|
254
|
-
(
|
|
256
|
+
), d = e.split(r);
|
|
257
|
+
return /* @__PURE__ */ a("span", { children: d.map(
|
|
258
|
+
(u, c) => c % 2 === 1 ? /* @__PURE__ */ a("span", { className: n, children: u }, c) : /* @__PURE__ */ a(t.Fragment, { children: u }, c)
|
|
255
259
|
) });
|
|
256
260
|
}
|
|
257
261
|
const ee = t.forwardRef(
|
|
@@ -260,35 +264,35 @@ const ee = t.forwardRef(
|
|
|
260
264
|
label: o,
|
|
261
265
|
dataHook: n,
|
|
262
266
|
children: r,
|
|
263
|
-
className:
|
|
264
|
-
highlight:
|
|
265
|
-
highlightClassName:
|
|
266
|
-
keywords:
|
|
267
|
+
className: d,
|
|
268
|
+
highlight: u,
|
|
269
|
+
highlightClassName: c,
|
|
270
|
+
keywords: m,
|
|
267
271
|
...h
|
|
268
272
|
}, v) => {
|
|
269
|
-
const { value: f, onValueChange: w, setOpen: C, registerItem:
|
|
273
|
+
const { value: f, onValueChange: w, setOpen: C, registerItem: i } = I(), p = f === e, x = t.useMemo(() => o || (typeof r == "string" ? r : typeof r == "number" ? String(r) : e), [o, r, e]), s = t.useRef(i);
|
|
270
274
|
t.useEffect(() => {
|
|
271
|
-
|
|
272
|
-
}, [
|
|
273
|
-
|
|
275
|
+
s.current = i;
|
|
276
|
+
}, [i]), t.useEffect(() => {
|
|
277
|
+
s.current(e, x);
|
|
274
278
|
}, [e, x]);
|
|
275
|
-
const
|
|
279
|
+
const b = () => {
|
|
276
280
|
w(e === f ? "" : e), C(!1);
|
|
277
|
-
}, g = () =>
|
|
281
|
+
}, g = () => u && typeof r == "string" ? Z(
|
|
278
282
|
r,
|
|
279
|
-
|
|
280
|
-
|
|
283
|
+
u,
|
|
284
|
+
c || "text-sm leading-normal font-semibold"
|
|
281
285
|
) : r;
|
|
282
286
|
return /* @__PURE__ */ E(
|
|
283
287
|
H,
|
|
284
288
|
{
|
|
285
289
|
ref: v,
|
|
286
|
-
className: y("justify-between",
|
|
290
|
+
className: y("justify-between", d),
|
|
287
291
|
"data-slot": "combobox-item",
|
|
288
292
|
dataHook: n,
|
|
289
|
-
keywords:
|
|
293
|
+
keywords: m ? [x, ...m] : [x],
|
|
290
294
|
value: e,
|
|
291
|
-
onSelect:
|
|
295
|
+
onSelect: b,
|
|
292
296
|
...h,
|
|
293
297
|
children: [
|
|
294
298
|
g(),
|
|
@@ -307,7 +311,7 @@ const ee = t.forwardRef(
|
|
|
307
311
|
ee.displayName = "ComboboxItem";
|
|
308
312
|
const oe = t.forwardRef((e, o) => /* @__PURE__ */ a(B, { ref: o, "data-slot": "combobox-separator", ...e }));
|
|
309
313
|
oe.displayName = "ComboboxSeparator";
|
|
310
|
-
function
|
|
314
|
+
function me({ className: e, children: o }) {
|
|
311
315
|
return /* @__PURE__ */ a(
|
|
312
316
|
"div",
|
|
313
317
|
{
|
|
@@ -340,7 +344,7 @@ export {
|
|
|
340
344
|
Q as ComboboxInput,
|
|
341
345
|
ee as ComboboxItem,
|
|
342
346
|
W as ComboboxList,
|
|
343
|
-
|
|
347
|
+
me as ComboboxLoading,
|
|
344
348
|
oe as ComboboxSeparator,
|
|
345
349
|
K as ComboboxTrigger,
|
|
346
350
|
ce as ComboboxValue
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightlocal/ui-components",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "BrightLocal Design System UI Components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -105,8 +105,8 @@
|
|
|
105
105
|
"vite-bundle-visualizer": "^1.2.1",
|
|
106
106
|
"vite-plugin-dts": "^4.5.4",
|
|
107
107
|
"vite-plugin-lib-inject-css": "^2.2.2",
|
|
108
|
-
"@workspace/
|
|
109
|
-
"@workspace/
|
|
108
|
+
"@workspace/typescript-config": "0.0.0",
|
|
109
|
+
"@workspace/eslint-config": "0.0.0"
|
|
110
110
|
},
|
|
111
111
|
"publishConfig": {
|
|
112
112
|
"access": "public",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
|
+
import { motion, AnimatePresence } from "framer-motion";
|
|
4
5
|
import { X } from "@brightlocal/icons";
|
|
5
6
|
|
|
6
7
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
@@ -119,45 +120,31 @@ function InputList({
|
|
|
119
120
|
className,
|
|
120
121
|
}: InputListProps) {
|
|
121
122
|
const [inputValue, setInputValue] = React.useState("");
|
|
122
|
-
const [removingIndices, setRemovingIndices] = React.useState<Set<number>>(
|
|
123
|
-
() => new Set()
|
|
124
|
-
);
|
|
125
|
-
const [addingIndices, setAddingIndices] = React.useState<Set<number>>(
|
|
126
|
-
() => new Set()
|
|
127
|
-
);
|
|
128
123
|
|
|
129
|
-
//
|
|
130
|
-
React.useEffect(() => {
|
|
131
|
-
if (addingIndices.size === 0) return;
|
|
132
|
-
const frame = requestAnimationFrame(() => {
|
|
133
|
-
setAddingIndices(new Set());
|
|
134
|
-
});
|
|
135
|
-
return () => cancelAnimationFrame(frame);
|
|
136
|
-
}, [addingIndices]);
|
|
137
|
-
const valueRef = React.useRef(value);
|
|
138
|
-
React.useEffect(() => {
|
|
139
|
-
valueRef.current = value;
|
|
140
|
-
}, [value]);
|
|
141
|
-
const timersRef = React.useRef(new Set<ReturnType<typeof setTimeout>>());
|
|
142
|
-
React.useEffect(() => {
|
|
143
|
-
const timers = timersRef.current;
|
|
144
|
-
return () => {
|
|
145
|
-
timers.forEach(clearTimeout);
|
|
146
|
-
timers.clear();
|
|
147
|
-
};
|
|
148
|
-
}, []);
|
|
149
|
-
|
|
150
|
-
// Stable keys so remaining items don't remount (and re-animate) on removal
|
|
124
|
+
// Stable keys so AnimatePresence can track items across additions/removals
|
|
151
125
|
const nextIdRef = React.useRef(value.length);
|
|
152
126
|
const [stableKeys, setStableKeys] = React.useState<number[]>(() =>
|
|
153
127
|
value.map((_, i) => i)
|
|
154
128
|
);
|
|
129
|
+
|
|
130
|
+
// Sync keys when value changes externally (not via addItems/removeItem).
|
|
131
|
+
// Simple appends preserve existing keys; other changes (removal, reorder)
|
|
132
|
+
// regenerate all keys to avoid incorrect exit animations.
|
|
155
133
|
React.useEffect(() => {
|
|
156
134
|
setStableKeys((prev) => {
|
|
157
|
-
if (prev.length
|
|
158
|
-
|
|
135
|
+
if (prev.length === value.length) return prev;
|
|
136
|
+
if (value.length > prev.length) {
|
|
137
|
+
// Append: preserve existing keys, generate new ones
|
|
138
|
+
return [
|
|
139
|
+
...prev,
|
|
140
|
+
...Array.from(
|
|
141
|
+
{ length: value.length - prev.length },
|
|
142
|
+
() => nextIdRef.current++
|
|
143
|
+
),
|
|
144
|
+
];
|
|
159
145
|
}
|
|
160
|
-
|
|
146
|
+
// Removal or reorder: regenerate all keys
|
|
147
|
+
return value.map(() => nextIdRef.current++);
|
|
161
148
|
});
|
|
162
149
|
}, [value]);
|
|
163
150
|
|
|
@@ -173,13 +160,6 @@ function InputList({
|
|
|
173
160
|
maxItems !== undefined ? maxItems - value.length : Infinity;
|
|
174
161
|
const toAdd = trimmed.slice(0, available);
|
|
175
162
|
if (toAdd.length) {
|
|
176
|
-
const prefersReducedMotion = window.matchMedia(
|
|
177
|
-
"(prefers-reduced-motion: reduce)"
|
|
178
|
-
).matches;
|
|
179
|
-
if (!prefersReducedMotion) {
|
|
180
|
-
const startIndex = value.length;
|
|
181
|
-
setAddingIndices(new Set(toAdd.map((_, i) => startIndex + i)));
|
|
182
|
-
}
|
|
183
163
|
setStableKeys((prev) => [
|
|
184
164
|
...prev,
|
|
185
165
|
...toAdd.map(() => nextIdRef.current++),
|
|
@@ -193,30 +173,10 @@ function InputList({
|
|
|
193
173
|
|
|
194
174
|
const removeItem = React.useCallback(
|
|
195
175
|
(index: number) => {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
).matches;
|
|
199
|
-
|
|
200
|
-
if (prefersReducedMotion) {
|
|
201
|
-
setStableKeys((prev) => prev.filter((_, i) => i !== index));
|
|
202
|
-
onValueChange(valueRef.current.filter((_, i) => i !== index));
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
setRemovingIndices((prev) => new Set(prev).add(index));
|
|
207
|
-
const timer = setTimeout(() => {
|
|
208
|
-
timersRef.current.delete(timer);
|
|
209
|
-
setRemovingIndices((prev) => {
|
|
210
|
-
const next = new Set(prev);
|
|
211
|
-
next.delete(index);
|
|
212
|
-
return next;
|
|
213
|
-
});
|
|
214
|
-
setStableKeys((prev) => prev.filter((_, i) => i !== index));
|
|
215
|
-
onValueChange(valueRef.current.filter((_, i) => i !== index));
|
|
216
|
-
}, 200);
|
|
217
|
-
timersRef.current.add(timer);
|
|
176
|
+
setStableKeys((prev) => prev.filter((_, i) => i !== index));
|
|
177
|
+
onValueChange(value.filter((_, i) => i !== index));
|
|
218
178
|
},
|
|
219
|
-
[onValueChange]
|
|
179
|
+
[value, onValueChange]
|
|
220
180
|
);
|
|
221
181
|
|
|
222
182
|
const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
|
@@ -252,55 +212,63 @@ function InputList({
|
|
|
252
212
|
</ul>
|
|
253
213
|
) : value.length > 0 ? (
|
|
254
214
|
<ul
|
|
255
|
-
className="flex flex-col"
|
|
215
|
+
className="flex flex-col gap-2"
|
|
256
216
|
data-hook={`${dataHook}-list`}
|
|
257
217
|
data-slot="list"
|
|
258
218
|
>
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
const isCollapsed = isAdding || isRemoving;
|
|
263
|
-
return (
|
|
264
|
-
<li
|
|
219
|
+
<AnimatePresence initial={false}>
|
|
220
|
+
{value.map((item, index) => (
|
|
221
|
+
<motion.li
|
|
265
222
|
key={stableKeys[index]}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
isCollapsed
|
|
269
|
-
? "mb-0 grid-rows-[0fr] opacity-0"
|
|
270
|
-
: "mb-2 grid-rows-[1fr] opacity-100 last:mb-0",
|
|
271
|
-
isRemoving ? "duration-200" : "duration-300"
|
|
272
|
-
)}
|
|
223
|
+
layout
|
|
224
|
+
animate={{ opacity: 1, scale: 1 }}
|
|
273
225
|
data-hook={`${dataHook}-item-${index}`}
|
|
274
226
|
data-slot="item"
|
|
227
|
+
exit={{
|
|
228
|
+
opacity: 0,
|
|
229
|
+
scale: 0.8,
|
|
230
|
+
transition: {
|
|
231
|
+
opacity: { duration: 0.15 },
|
|
232
|
+
scale: { duration: 0.12 },
|
|
233
|
+
},
|
|
234
|
+
}}
|
|
235
|
+
initial={{ opacity: 0, scale: 0.8 }}
|
|
236
|
+
transition={{
|
|
237
|
+
opacity: { duration: 0.15 },
|
|
238
|
+
scale: { duration: 0.15 },
|
|
239
|
+
layout: {
|
|
240
|
+
type: "spring",
|
|
241
|
+
stiffness: 500,
|
|
242
|
+
damping: 35,
|
|
243
|
+
},
|
|
244
|
+
}}
|
|
275
245
|
>
|
|
276
|
-
<div className="
|
|
277
|
-
<
|
|
278
|
-
<
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
<
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
</ItemActions>
|
|
299
|
-
</div>
|
|
246
|
+
<div className="bg-card flex items-center gap-4 rounded-lg py-2 pr-2 pl-4">
|
|
247
|
+
<ItemContent>
|
|
248
|
+
<ItemTitle>{item}</ItemTitle>
|
|
249
|
+
</ItemContent>
|
|
250
|
+
<ItemActions>
|
|
251
|
+
<button
|
|
252
|
+
aria-label={`Remove ${item}`}
|
|
253
|
+
className={cn(
|
|
254
|
+
"inline-flex size-9 cursor-pointer items-center justify-center rounded-full",
|
|
255
|
+
"text-muted-foreground",
|
|
256
|
+
"focus-visible:shadow-default outline-none",
|
|
257
|
+
"transition-colors duration-150 ease-in-out",
|
|
258
|
+
"disabled:pointer-events-none disabled:opacity-50"
|
|
259
|
+
)}
|
|
260
|
+
data-hook={`${dataHook}-remove-${index}`}
|
|
261
|
+
disabled={disabled}
|
|
262
|
+
type="button"
|
|
263
|
+
onClick={() => removeItem(index)}
|
|
264
|
+
>
|
|
265
|
+
<X />
|
|
266
|
+
</button>
|
|
267
|
+
</ItemActions>
|
|
300
268
|
</div>
|
|
301
|
-
</li>
|
|
302
|
-
)
|
|
303
|
-
|
|
269
|
+
</motion.li>
|
|
270
|
+
))}
|
|
271
|
+
</AnimatePresence>
|
|
304
272
|
</ul>
|
|
305
273
|
) : null}
|
|
306
274
|
|
|
@@ -327,34 +295,36 @@ function InputList({
|
|
|
327
295
|
</Button>
|
|
328
296
|
</div>
|
|
329
297
|
|
|
330
|
-
{/*
|
|
331
|
-
{
|
|
332
|
-
<FieldDescription
|
|
333
|
-
data-slot="input-list-description"
|
|
334
|
-
dataHook={`${dataHook}-description`}
|
|
335
|
-
>
|
|
336
|
-
{description}
|
|
337
|
-
</FieldDescription>
|
|
338
|
-
)}
|
|
339
|
-
|
|
340
|
-
{/* Count indicator — always shown when maxItems is set */}
|
|
341
|
-
{maxItems !== undefined && (
|
|
342
|
-
<FieldDescription
|
|
343
|
-
data-slot="input-list-count"
|
|
344
|
-
dataHook={`${dataHook}-count`}
|
|
345
|
-
>
|
|
346
|
-
{value.length}/{maxItems}
|
|
347
|
-
</FieldDescription>
|
|
348
|
-
)}
|
|
349
|
-
|
|
350
|
-
{/* Error message */}
|
|
351
|
-
{error && errorMessage && (
|
|
298
|
+
{/* Error message replaces description and counter */}
|
|
299
|
+
{error && errorMessage ? (
|
|
352
300
|
<FieldError
|
|
353
301
|
data-slot="input-list-error"
|
|
354
302
|
dataHook={`${dataHook}-error`}
|
|
355
303
|
>
|
|
356
304
|
{errorMessage}
|
|
357
305
|
</FieldError>
|
|
306
|
+
) : (
|
|
307
|
+
<>
|
|
308
|
+
{/* Description */}
|
|
309
|
+
{description && (
|
|
310
|
+
<FieldDescription
|
|
311
|
+
data-slot="input-list-description"
|
|
312
|
+
dataHook={`${dataHook}-description`}
|
|
313
|
+
>
|
|
314
|
+
{description}
|
|
315
|
+
</FieldDescription>
|
|
316
|
+
)}
|
|
317
|
+
|
|
318
|
+
{/* Count indicator — always shown when maxItems is set */}
|
|
319
|
+
{maxItems !== undefined && (
|
|
320
|
+
<FieldDescription
|
|
321
|
+
data-slot="input-list-count"
|
|
322
|
+
dataHook={`${dataHook}-count`}
|
|
323
|
+
>
|
|
324
|
+
{value.length}/{maxItems}
|
|
325
|
+
</FieldDescription>
|
|
326
|
+
)}
|
|
327
|
+
</>
|
|
358
328
|
)}
|
|
359
329
|
</div>
|
|
360
330
|
</div>
|
|
@@ -443,13 +443,17 @@ function ComboboxContent({
|
|
|
443
443
|
};
|
|
444
444
|
}, []);
|
|
445
445
|
|
|
446
|
-
//
|
|
446
|
+
// Cleanup observers on close, but delay the lockedSide reset until
|
|
447
|
+
// the exit animation finishes (150ms) so the side prop stays locked
|
|
448
|
+
// and the dropdown doesn't visibly flip during the fade-out/zoom-out.
|
|
447
449
|
React.useEffect(() => {
|
|
448
450
|
if (!open) {
|
|
449
451
|
cleanupRef.current?.();
|
|
450
452
|
cleanupRef.current = null;
|
|
451
|
-
setLockedSide(null);
|
|
453
|
+
const timer = setTimeout(() => setLockedSide(null), 150);
|
|
454
|
+
return () => clearTimeout(timer);
|
|
452
455
|
}
|
|
456
|
+
return undefined;
|
|
453
457
|
}, [open]);
|
|
454
458
|
|
|
455
459
|
const filter = React.useMemo(() => {
|