@arcadeai/design-system 3.39.4 → 3.40.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/dist/components/index.js +114 -111
- package/dist/components/ui/index.js +114 -111
- package/dist/components/ui/molecules/index.d.ts +2 -0
- package/dist/components/ui/molecules/index.d.ts.map +1 -1
- package/dist/components/ui/molecules/index.js +30 -27
- package/dist/components/ui/molecules/steps-progress.d.ts +3 -1
- package/dist/components/ui/molecules/steps-progress.d.ts.map +1 -1
- package/dist/components/ui/molecules/steps-progress.js +153 -112
- package/dist/components/ui/molecules/tags-input.d.ts +44 -0
- package/dist/components/ui/molecules/tags-input.d.ts.map +1 -0
- package/dist/components/ui/molecules/tags-input.js +139 -0
- package/dist/main.js +90 -87
- package/package.json +3 -3
|
@@ -1,237 +1,278 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { ChevronLeft as
|
|
4
|
-
import { useState as
|
|
2
|
+
import { jsx as t, jsxs as c } from "react/jsx-runtime";
|
|
3
|
+
import { Check as D, ChevronLeft as E, X as C, ChevronRight as P } from "lucide-react";
|
|
4
|
+
import { useState as L, useLayoutEffect as V, useRef as p, useEffect as M } from "react";
|
|
5
5
|
import { Button as j } from "../atoms/button.js";
|
|
6
|
-
import { DS_SPARKLE_DURATION_MS as
|
|
7
|
-
import { StepIndicator as
|
|
8
|
-
import { cn as
|
|
9
|
-
function
|
|
10
|
-
const
|
|
11
|
-
|
|
6
|
+
import { DS_SPARKLE_DURATION_MS as _, SparkleBurst as G } from "../atoms/sparkle-burst.js";
|
|
7
|
+
import { stepIndicatorIconVariants as K, stepIndicatorLabelVariants as F, StepIndicator as O } from "../atoms/step-indicator.js";
|
|
8
|
+
import { cn as l } from "../../../lib/utils.js";
|
|
9
|
+
function U({ step: e, stepNumber: n, isAttention: a }) {
|
|
10
|
+
const s = /* @__PURE__ */ t(
|
|
11
|
+
O,
|
|
12
12
|
{
|
|
13
13
|
className: "min-w-0",
|
|
14
14
|
label: e.label,
|
|
15
15
|
status: e.status,
|
|
16
|
-
stepNumber:
|
|
16
|
+
stepNumber: n
|
|
17
17
|
}
|
|
18
|
-
),
|
|
18
|
+
), u = l(
|
|
19
19
|
"flex min-w-0 flex-1 items-center justify-center",
|
|
20
|
-
|
|
20
|
+
a && "step-attention-target"
|
|
21
21
|
);
|
|
22
|
-
return e.onClick ? /* @__PURE__ */
|
|
22
|
+
return e.onClick ? /* @__PURE__ */ t(
|
|
23
23
|
"button",
|
|
24
24
|
{
|
|
25
|
-
className: u
|
|
25
|
+
className: l(u, "cursor-pointer"),
|
|
26
26
|
onClick: e.onClick,
|
|
27
27
|
type: "button",
|
|
28
|
-
children:
|
|
28
|
+
children: s
|
|
29
29
|
}
|
|
30
|
-
) : /* @__PURE__ */
|
|
30
|
+
) : /* @__PURE__ */ t("span", { className: u, children: s });
|
|
31
31
|
}
|
|
32
32
|
function R(e) {
|
|
33
33
|
return e.length - 1;
|
|
34
34
|
}
|
|
35
|
-
function
|
|
36
|
-
return e.findIndex((
|
|
35
|
+
function X(e) {
|
|
36
|
+
return e.findIndex((n) => n.status === "active");
|
|
37
37
|
}
|
|
38
|
-
function
|
|
39
|
-
return e.length === 0 ?
|
|
38
|
+
function z(e, n) {
|
|
39
|
+
return e.length === 0 ? n ? 0 : -1 : n ? e.length : R(e);
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
const { currentIndex:
|
|
43
|
-
if (
|
|
44
|
-
return
|
|
41
|
+
function g(e, n) {
|
|
42
|
+
const { currentIndex: a, isDismissible: s = !1 } = n ?? {}, u = X(e);
|
|
43
|
+
if (u >= 0)
|
|
44
|
+
return u;
|
|
45
45
|
if (e.length === 0)
|
|
46
|
-
return
|
|
47
|
-
const
|
|
48
|
-
return
|
|
46
|
+
return s ? 0 : -1;
|
|
47
|
+
const h = z(e, s);
|
|
48
|
+
return a !== void 0 && a >= 0 && a <= h ? a : R(e);
|
|
49
49
|
}
|
|
50
|
-
function
|
|
51
|
-
const
|
|
52
|
-
return
|
|
53
|
-
currentIndex:
|
|
54
|
-
isDismissible:
|
|
50
|
+
function $(e, n, a) {
|
|
51
|
+
const s = z(e, a);
|
|
52
|
+
return n >= 0 && n <= s ? n : g(e, {
|
|
53
|
+
currentIndex: n,
|
|
54
|
+
isDismissible: a
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
-
function
|
|
57
|
+
function q(e) {
|
|
58
58
|
return `calc(${(e - 1) / e} * (100% - 4.25rem) + 0.75rem)`;
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function te({
|
|
61
61
|
steps: e,
|
|
62
|
-
onDismiss:
|
|
63
|
-
animateStepTransitions:
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
onDismiss: n,
|
|
63
|
+
animateStepTransitions: a = !1,
|
|
64
|
+
orientation: s = "horizontal",
|
|
65
|
+
className: u,
|
|
66
|
+
...h
|
|
66
67
|
}) {
|
|
67
|
-
const
|
|
68
|
-
() =>
|
|
68
|
+
const m = !!n, [T, b] = L(
|
|
69
|
+
() => g(e, { isDismissible: m })
|
|
69
70
|
);
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
(
|
|
73
|
-
currentIndex:
|
|
74
|
-
isDismissible:
|
|
71
|
+
V(() => {
|
|
72
|
+
b(
|
|
73
|
+
(r) => g(e, {
|
|
74
|
+
currentIndex: r,
|
|
75
|
+
isDismissible: m
|
|
75
76
|
})
|
|
76
77
|
);
|
|
77
|
-
}, [
|
|
78
|
-
const [
|
|
78
|
+
}, [m, e]);
|
|
79
|
+
const [v, N] = L(void 0), x = p(null), f = p(null), k = p(0);
|
|
79
80
|
M(() => {
|
|
80
|
-
const
|
|
81
|
-
if (
|
|
82
|
-
|
|
81
|
+
const r = x.current, o = new Map(e.map((i) => [i.id, i.status]));
|
|
82
|
+
if (r === null) {
|
|
83
|
+
x.current = o;
|
|
83
84
|
return;
|
|
84
85
|
}
|
|
85
|
-
if (
|
|
86
|
-
const
|
|
87
|
-
(
|
|
86
|
+
if (a) {
|
|
87
|
+
const i = e.find(
|
|
88
|
+
(S) => S.status === "complete" && r.get(S.id) !== "complete"
|
|
88
89
|
);
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
},
|
|
90
|
+
i && (f.current !== null && window.clearTimeout(f.current), k.current += 1, N({ stepId: i.id, key: k.current }), f.current = window.setTimeout(() => {
|
|
91
|
+
N(void 0), f.current = null;
|
|
92
|
+
}, _));
|
|
92
93
|
}
|
|
93
|
-
|
|
94
|
-
}, [
|
|
94
|
+
x.current = o;
|
|
95
|
+
}, [a, e]), M(
|
|
95
96
|
() => () => {
|
|
96
|
-
|
|
97
|
+
f.current !== null && window.clearTimeout(f.current);
|
|
97
98
|
},
|
|
98
99
|
[]
|
|
99
100
|
);
|
|
100
|
-
const
|
|
101
|
+
const d = $(
|
|
101
102
|
e,
|
|
102
103
|
T,
|
|
103
|
-
|
|
104
|
-
),
|
|
105
|
-
return /* @__PURE__ */
|
|
104
|
+
m
|
|
105
|
+
), A = e[d], w = e.length, I = d > 0, y = m ? d < w : d < e.length - 1, B = m && e.at(-1)?.status === "active";
|
|
106
|
+
return s === "vertical" ? /* @__PURE__ */ t("section", { "aria-label": "Steps progress", className: l(u), ...h, children: /* @__PURE__ */ t("ol", { className: "flex flex-col", children: e.map((r, o) => {
|
|
107
|
+
const i = o === e.length - 1;
|
|
108
|
+
return /* @__PURE__ */ c(
|
|
109
|
+
"li",
|
|
110
|
+
{
|
|
111
|
+
className: l("flex items-start gap-3", !i && "pb-5"),
|
|
112
|
+
children: [
|
|
113
|
+
/* @__PURE__ */ c("div", { className: "flex shrink-0 flex-col items-center self-stretch", children: [
|
|
114
|
+
/* @__PURE__ */ t(
|
|
115
|
+
"span",
|
|
116
|
+
{
|
|
117
|
+
className: l(
|
|
118
|
+
K({ status: r.status })
|
|
119
|
+
),
|
|
120
|
+
children: r.status === "complete" ? /* @__PURE__ */ t(D, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ t("span", { className: "text-sm", children: o + 1 })
|
|
121
|
+
}
|
|
122
|
+
),
|
|
123
|
+
!i && /* @__PURE__ */ t("div", { className: "mt-2 w-px flex-1 bg-border" })
|
|
124
|
+
] }),
|
|
125
|
+
/* @__PURE__ */ c(
|
|
126
|
+
"span",
|
|
127
|
+
{
|
|
128
|
+
"aria-current": r.status === "active" ? "step" : void 0,
|
|
129
|
+
className: l(
|
|
130
|
+
F({ status: r.status }),
|
|
131
|
+
"pt-0.5"
|
|
132
|
+
),
|
|
133
|
+
children: [
|
|
134
|
+
r.label,
|
|
135
|
+
/* @__PURE__ */ c("span", { className: "sr-only", children: [
|
|
136
|
+
" — ",
|
|
137
|
+
r.status
|
|
138
|
+
] })
|
|
139
|
+
]
|
|
140
|
+
}
|
|
141
|
+
)
|
|
142
|
+
]
|
|
143
|
+
},
|
|
144
|
+
r.id
|
|
145
|
+
);
|
|
146
|
+
}) }) }) : /* @__PURE__ */ c(
|
|
106
147
|
"section",
|
|
107
148
|
{
|
|
108
149
|
"aria-label": "Steps progress",
|
|
109
|
-
className:
|
|
150
|
+
className: l(
|
|
110
151
|
"relative h-14 overflow-hidden border border-border bg-card text-foreground",
|
|
111
|
-
|
|
152
|
+
u
|
|
112
153
|
),
|
|
113
|
-
...
|
|
154
|
+
...h,
|
|
114
155
|
children: [
|
|
115
|
-
|
|
156
|
+
B && /* @__PURE__ */ t(
|
|
116
157
|
"span",
|
|
117
158
|
{
|
|
118
159
|
"aria-hidden": "true",
|
|
119
160
|
className: "pointer-events-none absolute top-0 right-0 z-10 hidden h-0.5 bg-foreground sm:block",
|
|
120
|
-
style: { left:
|
|
161
|
+
style: { left: q(e.length) }
|
|
121
162
|
}
|
|
122
163
|
),
|
|
123
|
-
|
|
164
|
+
A?.status === "active" && /* @__PURE__ */ t(
|
|
124
165
|
"span",
|
|
125
166
|
{
|
|
126
167
|
"aria-hidden": "true",
|
|
127
168
|
className: "pointer-events-none absolute inset-x-0 top-0 z-20 h-0.5 bg-foreground sm:hidden"
|
|
128
169
|
}
|
|
129
170
|
),
|
|
130
|
-
/* @__PURE__ */
|
|
131
|
-
/* @__PURE__ */
|
|
171
|
+
/* @__PURE__ */ c("div", { className: "relative z-10 flex h-full items-center sm:gap-3 sm:px-3", children: [
|
|
172
|
+
/* @__PURE__ */ t(
|
|
132
173
|
"button",
|
|
133
174
|
{
|
|
134
175
|
"aria-label": "Go to previous step",
|
|
135
|
-
className:
|
|
176
|
+
className: l(
|
|
136
177
|
"flex h-full shrink-0 items-center px-2 text-muted-foreground sm:hidden",
|
|
137
|
-
!
|
|
178
|
+
!I && "pointer-events-none invisible"
|
|
138
179
|
),
|
|
139
|
-
onClick: () =>
|
|
140
|
-
tabIndex:
|
|
180
|
+
onClick: () => b(d - 1),
|
|
181
|
+
tabIndex: I ? 0 : -1,
|
|
141
182
|
type: "button",
|
|
142
|
-
children: /* @__PURE__ */
|
|
183
|
+
children: /* @__PURE__ */ t(E, { className: "h-4 w-4" })
|
|
143
184
|
}
|
|
144
185
|
),
|
|
145
|
-
/* @__PURE__ */
|
|
146
|
-
e.map((
|
|
147
|
-
const
|
|
148
|
-
return /* @__PURE__ */
|
|
186
|
+
/* @__PURE__ */ c("ol", { className: "flex h-full min-w-0 flex-1 items-center gap-0", children: [
|
|
187
|
+
e.map((r, o) => {
|
|
188
|
+
const i = v?.stepId === r.id;
|
|
189
|
+
return /* @__PURE__ */ c(
|
|
149
190
|
"li",
|
|
150
191
|
{
|
|
151
|
-
"aria-current":
|
|
152
|
-
className:
|
|
192
|
+
"aria-current": r.status === "active" ? "step" : void 0,
|
|
193
|
+
className: l(
|
|
153
194
|
"relative isolate flex h-full min-w-0 flex-1 items-center justify-center px-2 py-4 sm:px-3",
|
|
154
|
-
|
|
195
|
+
o !== d && "hidden sm:flex"
|
|
155
196
|
),
|
|
156
|
-
"data-attention":
|
|
157
|
-
"data-status":
|
|
197
|
+
"data-attention": i ? "true" : void 0,
|
|
198
|
+
"data-status": r.status,
|
|
158
199
|
children: [
|
|
159
|
-
|
|
200
|
+
o > 0 && /* @__PURE__ */ t(
|
|
160
201
|
"span",
|
|
161
202
|
{
|
|
162
203
|
"aria-hidden": "true",
|
|
163
204
|
className: "absolute left-0 hidden h-full w-px bg-border sm:block"
|
|
164
205
|
}
|
|
165
206
|
),
|
|
166
|
-
/* @__PURE__ */
|
|
167
|
-
|
|
207
|
+
/* @__PURE__ */ t(
|
|
208
|
+
U,
|
|
168
209
|
{
|
|
169
|
-
isAttention:
|
|
170
|
-
step:
|
|
171
|
-
stepNumber:
|
|
210
|
+
isAttention: i,
|
|
211
|
+
step: r,
|
|
212
|
+
stepNumber: o + 1
|
|
172
213
|
}
|
|
173
214
|
),
|
|
174
|
-
|
|
215
|
+
i ? /* @__PURE__ */ t(
|
|
175
216
|
"span",
|
|
176
217
|
{
|
|
177
218
|
"aria-hidden": !0,
|
|
178
219
|
className: "pointer-events-none absolute inset-0 z-30 flex items-center justify-center",
|
|
179
|
-
children: /* @__PURE__ */
|
|
220
|
+
children: /* @__PURE__ */ t(G, {}, v.key)
|
|
180
221
|
}
|
|
181
222
|
) : null
|
|
182
223
|
]
|
|
183
224
|
},
|
|
184
|
-
|
|
225
|
+
r.id
|
|
185
226
|
);
|
|
186
227
|
}),
|
|
187
|
-
|
|
228
|
+
n && /* @__PURE__ */ t(
|
|
188
229
|
"li",
|
|
189
230
|
{
|
|
190
|
-
className:
|
|
231
|
+
className: l(
|
|
191
232
|
"relative isolate flex h-full flex-1 items-center justify-center sm:hidden",
|
|
192
|
-
|
|
233
|
+
d !== w && "hidden"
|
|
193
234
|
),
|
|
194
|
-
children: /* @__PURE__ */
|
|
235
|
+
children: /* @__PURE__ */ c(
|
|
195
236
|
j,
|
|
196
237
|
{
|
|
197
238
|
"aria-label": "Dismiss steps progress",
|
|
198
239
|
className: "h-8 gap-1.5 border border-border px-3 text-muted-foreground hover:bg-muted hover:text-foreground",
|
|
199
|
-
onClick:
|
|
240
|
+
onClick: n,
|
|
200
241
|
type: "button",
|
|
201
242
|
variant: "ghost",
|
|
202
243
|
children: [
|
|
203
|
-
/* @__PURE__ */
|
|
204
|
-
/* @__PURE__ */
|
|
244
|
+
/* @__PURE__ */ t(C, { className: "h-4 w-4" }),
|
|
245
|
+
/* @__PURE__ */ t("span", { className: "text-sm", children: "Dismiss" })
|
|
205
246
|
]
|
|
206
247
|
}
|
|
207
248
|
)
|
|
208
249
|
}
|
|
209
250
|
)
|
|
210
251
|
] }),
|
|
211
|
-
/* @__PURE__ */
|
|
252
|
+
/* @__PURE__ */ t(
|
|
212
253
|
"button",
|
|
213
254
|
{
|
|
214
255
|
"aria-label": "Go to next step",
|
|
215
|
-
className:
|
|
256
|
+
className: l(
|
|
216
257
|
"flex h-full shrink-0 items-center px-2 text-muted-foreground sm:hidden",
|
|
217
|
-
!
|
|
258
|
+
!y && "pointer-events-none invisible"
|
|
218
259
|
),
|
|
219
|
-
onClick: () =>
|
|
220
|
-
tabIndex:
|
|
260
|
+
onClick: () => b(d + 1),
|
|
261
|
+
tabIndex: y ? 0 : -1,
|
|
221
262
|
type: "button",
|
|
222
|
-
children: /* @__PURE__ */
|
|
263
|
+
children: /* @__PURE__ */ t(P, { className: "h-4 w-4" })
|
|
223
264
|
}
|
|
224
265
|
),
|
|
225
|
-
|
|
266
|
+
n && /* @__PURE__ */ t(
|
|
226
267
|
j,
|
|
227
268
|
{
|
|
228
269
|
"aria-label": "Dismiss steps progress",
|
|
229
270
|
className: "hidden h-8 w-8 shrink-0 border border-border text-muted-foreground hover:bg-muted hover:text-foreground sm:flex",
|
|
230
|
-
onClick:
|
|
271
|
+
onClick: n,
|
|
231
272
|
size: "icon",
|
|
232
273
|
type: "button",
|
|
233
274
|
variant: "ghost",
|
|
234
|
-
children: /* @__PURE__ */
|
|
275
|
+
children: /* @__PURE__ */ t(C, { className: "h-4 w-4" })
|
|
235
276
|
}
|
|
236
277
|
)
|
|
237
278
|
] })
|
|
@@ -240,6 +281,6 @@ function W({
|
|
|
240
281
|
);
|
|
241
282
|
}
|
|
242
283
|
export {
|
|
243
|
-
|
|
244
|
-
|
|
284
|
+
te as StepsProgress,
|
|
285
|
+
g as getMobileIndexForSteps
|
|
245
286
|
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { InputHTMLAttributes } from 'react';
|
|
2
|
+
export type TagsInputValidationResult = {
|
|
3
|
+
/** Normalized value to store. Falls back to the trimmed input if omitted. */
|
|
4
|
+
normalizedValue?: string;
|
|
5
|
+
/** Human-readable error message. Undefined means valid. */
|
|
6
|
+
error?: string;
|
|
7
|
+
};
|
|
8
|
+
type ForwardedInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, "className" | "defaultValue" | "disabled" | "onBlur" | "onChange" | "onKeyDown" | "onPaste" | "placeholder" | "type" | "value">;
|
|
9
|
+
export type TagsInputProps = {
|
|
10
|
+
values: string[];
|
|
11
|
+
onChange: (values: string[]) => void;
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
/** Commit the pending input value when the field loses focus. Default: true. */
|
|
14
|
+
addOnBlur?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Validate (and optionally normalize) a trimmed input string before it is added.
|
|
17
|
+
* Return `{ error }` to reject with a message, `{ normalizedValue }` to accept
|
|
18
|
+
* with a transformed value, or `{}` to accept as-is.
|
|
19
|
+
*/
|
|
20
|
+
validateValue?: (trimmed: string, currentValues: string[]) => TagsInputValidationResult;
|
|
21
|
+
/**
|
|
22
|
+
* Determine whether `incoming` is a duplicate of an existing `stored` value.
|
|
23
|
+
* Return `true` to reject with the default "Already added" message, or a
|
|
24
|
+
* non-empty string to reject with that string as the error. Defaults to
|
|
25
|
+
* exact string equality with "Already added".
|
|
26
|
+
*/
|
|
27
|
+
isDuplicate?: (incoming: string, stored: string) => boolean | string;
|
|
28
|
+
/**
|
|
29
|
+
* Render a custom chip for each committed value. Receives the value and a
|
|
30
|
+
* `remove` callback. When omitted a plain Badge with an X button is rendered.
|
|
31
|
+
* Keys are managed by TagsInput — do not add a `key` prop to the returned element.
|
|
32
|
+
*/
|
|
33
|
+
renderValue?: (value: string, remove: () => void) => React.ReactNode;
|
|
34
|
+
className?: string;
|
|
35
|
+
disabled?: boolean;
|
|
36
|
+
} & ForwardedInputProps;
|
|
37
|
+
export type TagsInputValueProps = {
|
|
38
|
+
value: string;
|
|
39
|
+
onRemove: () => void;
|
|
40
|
+
};
|
|
41
|
+
export declare function TagsInputValue({ value, onRemove }: TagsInputValueProps): import("react/jsx-runtime").JSX.Element;
|
|
42
|
+
export declare function TagsInput({ values, onChange, placeholder, addOnBlur, validateValue, isDuplicate, renderValue, className, disabled, id, ...inputProps }: TagsInputProps): import("react/jsx-runtime").JSX.Element;
|
|
43
|
+
export {};
|
|
44
|
+
//# sourceMappingURL=tags-input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tags-input.d.ts","sourceRoot":"","sources":["../../../../lib/components/ui/molecules/tags-input.tsx"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,mBAAmB,EAKzB,MAAM,OAAO,CAAC;AAIf,MAAM,MAAM,yBAAyB,GAAG;IACtC,6EAA6E;IAC7E,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,2DAA2D;IAC3D,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,KAAK,mBAAmB,GAAG,IAAI,CAC7B,mBAAmB,CAAC,gBAAgB,CAAC,EACnC,WAAW,GACX,cAAc,GACd,UAAU,GACV,QAAQ,GACR,UAAU,GACV,WAAW,GACX,SAAS,GACT,aAAa,GACb,MAAM,GACN,OAAO,CACV,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;OAIG;IACH,aAAa,CAAC,EAAE,CACd,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,MAAM,EAAE,KACpB,yBAAyB,CAAC;IAC/B;;;;;OAKG;IACH,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,GAAG,MAAM,CAAC;IACrE;;;;OAIG;IACH,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,KAAK,KAAK,CAAC,SAAS,CAAC;IACrE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,GAAG,mBAAmB,CAAC;AAExB,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAEF,wBAAgB,cAAc,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,mBAAmB,2CAiBtE;AAMD,wBAAgB,SAAS,CAAC,EACxB,MAAM,EACN,QAAQ,EACR,WAAW,EACX,SAAgB,EAChB,aAAa,EACb,WAAW,EACX,WAAW,EACX,SAAS,EACT,QAAgB,EAChB,EAAE,EACF,GAAG,UAAU,EACd,EAAE,cAAc,2CA+JhB"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { jsxs as h, jsx as c } from "react/jsx-runtime";
|
|
2
|
+
import { X as _ } from "lucide-react";
|
|
3
|
+
import { useId as C, useState as D, useRef as P, Fragment as L } from "react";
|
|
4
|
+
import { Badge as X } from "../atoms/badge.js";
|
|
5
|
+
import { cn as $ } from "../../../lib/utils.js";
|
|
6
|
+
const T = /[,\n\r]+/;
|
|
7
|
+
function q({ value: n, onRemove: s }) {
|
|
8
|
+
return /* @__PURE__ */ h(X, { className: "gap-1 pr-1", variant: "secondary", children: [
|
|
9
|
+
/* @__PURE__ */ c("span", { className: "max-w-[220px] truncate", children: n }),
|
|
10
|
+
/* @__PURE__ */ c(
|
|
11
|
+
"button",
|
|
12
|
+
{
|
|
13
|
+
"aria-label": `Remove ${n}`,
|
|
14
|
+
className: "ml-0.5 rounded text-muted-foreground hover:text-foreground",
|
|
15
|
+
onClick: (p) => {
|
|
16
|
+
p.stopPropagation(), s();
|
|
17
|
+
},
|
|
18
|
+
type: "button",
|
|
19
|
+
children: /* @__PURE__ */ c(_, { className: "size-3" })
|
|
20
|
+
}
|
|
21
|
+
)
|
|
22
|
+
] });
|
|
23
|
+
}
|
|
24
|
+
function G(n, s) {
|
|
25
|
+
return /* @__PURE__ */ c(q, { onRemove: s, value: n });
|
|
26
|
+
}
|
|
27
|
+
function W({
|
|
28
|
+
values: n,
|
|
29
|
+
onChange: s,
|
|
30
|
+
placeholder: p,
|
|
31
|
+
addOnBlur: z = !0,
|
|
32
|
+
validateValue: f,
|
|
33
|
+
isDuplicate: x,
|
|
34
|
+
renderValue: B,
|
|
35
|
+
className: V,
|
|
36
|
+
disabled: y = !1,
|
|
37
|
+
id: A,
|
|
38
|
+
...F
|
|
39
|
+
}) {
|
|
40
|
+
const S = C(), b = A ?? S, [i, m] = D(""), [w, d] = D(null), k = P(null), l = P(n);
|
|
41
|
+
l.current = n;
|
|
42
|
+
const j = B ?? G, I = (e, t) => {
|
|
43
|
+
for (const o of t) {
|
|
44
|
+
const r = x ? x(e, o) : e === o;
|
|
45
|
+
if (r === !0)
|
|
46
|
+
return "Already added";
|
|
47
|
+
if (typeof r == "string" && r)
|
|
48
|
+
return r;
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
}, N = (e) => {
|
|
52
|
+
const t = e.trim();
|
|
53
|
+
if (!t)
|
|
54
|
+
return;
|
|
55
|
+
const o = l.current, r = f ? f(t, o) : {};
|
|
56
|
+
if (r.error) {
|
|
57
|
+
d(r.error);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const u = r.normalizedValue ?? t, a = I(u, o);
|
|
61
|
+
if (a) {
|
|
62
|
+
d(a);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
s([...o, u]), m(""), d(null);
|
|
66
|
+
}, v = (e) => {
|
|
67
|
+
s(l.current.filter((t) => t !== e));
|
|
68
|
+
}, K = (e) => {
|
|
69
|
+
if ((e.key === "Enter" || e.key === ",") && !e.nativeEvent.isComposing)
|
|
70
|
+
e.preventDefault(), N(i);
|
|
71
|
+
else if (e.key === "Backspace" && i === "") {
|
|
72
|
+
const t = l.current.at(-1);
|
|
73
|
+
t !== void 0 && v(t);
|
|
74
|
+
} else
|
|
75
|
+
d(null);
|
|
76
|
+
}, M = (e) => {
|
|
77
|
+
const t = e.clipboardData.getData("text");
|
|
78
|
+
if (!T.test(t))
|
|
79
|
+
return;
|
|
80
|
+
e.preventDefault();
|
|
81
|
+
const o = t.split(T).map((a) => a.trim()).filter(Boolean);
|
|
82
|
+
let r = [...l.current], u = null;
|
|
83
|
+
for (const a of o) {
|
|
84
|
+
const g = f ? f(a, r) : {};
|
|
85
|
+
if (g.error) {
|
|
86
|
+
u = g.error;
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
const E = g.normalizedValue ?? a, R = I(E, r);
|
|
90
|
+
if (R) {
|
|
91
|
+
u = R;
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
r = [...r, E];
|
|
95
|
+
}
|
|
96
|
+
r.length > l.current.length && s(r), m(""), d(u);
|
|
97
|
+
};
|
|
98
|
+
return /* @__PURE__ */ h("div", { className: "space-y-1", children: [
|
|
99
|
+
/* @__PURE__ */ h(
|
|
100
|
+
"label",
|
|
101
|
+
{
|
|
102
|
+
className: $(
|
|
103
|
+
"flex min-h-10 w-full cursor-text flex-wrap items-center gap-1.5 rounded-md border border-input bg-transparent px-3 py-2 text-sm transition-[color,box-shadow] focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/50",
|
|
104
|
+
y && "cursor-not-allowed opacity-50",
|
|
105
|
+
V
|
|
106
|
+
),
|
|
107
|
+
htmlFor: b,
|
|
108
|
+
ref: k,
|
|
109
|
+
children: [
|
|
110
|
+
n.map((e) => /* @__PURE__ */ c(L, { children: j(e, () => v(e)) }, e)),
|
|
111
|
+
/* @__PURE__ */ c(
|
|
112
|
+
"input",
|
|
113
|
+
{
|
|
114
|
+
...F,
|
|
115
|
+
className: "min-w-32 flex-1 bg-transparent outline-none placeholder:text-muted-foreground",
|
|
116
|
+
disabled: y,
|
|
117
|
+
id: b,
|
|
118
|
+
onBlur: (e) => {
|
|
119
|
+
const t = k.current?.contains(e.relatedTarget);
|
|
120
|
+
z && i.trim() && !t && N(i);
|
|
121
|
+
},
|
|
122
|
+
onChange: (e) => m(e.target.value),
|
|
123
|
+
onKeyDown: K,
|
|
124
|
+
onPaste: M,
|
|
125
|
+
placeholder: n.length === 0 ? p : "",
|
|
126
|
+
type: "text",
|
|
127
|
+
value: i
|
|
128
|
+
}
|
|
129
|
+
)
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
),
|
|
133
|
+
w && /* @__PURE__ */ c("p", { className: "text-destructive text-sm", children: w })
|
|
134
|
+
] });
|
|
135
|
+
}
|
|
136
|
+
export {
|
|
137
|
+
W as TagsInput,
|
|
138
|
+
q as TagsInputValue
|
|
139
|
+
};
|