beez-ui 2.3.1 → 2.5.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/CHANGELOG.md +17 -0
- package/README.md +4 -3
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/dist/components/action-button.d.ts +25 -0
- package/dist/components/action-button.js +264 -0
- package/dist/components/button-label.js +5 -124
- package/dist/components/field.d.ts +51 -0
- package/dist/components/field.js +700 -0
- package/dist/components/input-group.js +3 -3
- package/dist/components/input.d.ts +16 -2
- package/dist/components/input.js +117 -10
- package/dist/components/morph-text.d.ts +14 -0
- package/dist/components/morph-text.js +210 -0
- package/dist/components/split-button.d.ts +36 -0
- package/dist/components/split-button.js +306 -0
- package/dist/components/textarea.d.ts +13 -5
- package/dist/components/textarea.js +107 -12
- package/dist/constants/action-button.d.ts +20 -0
- package/dist/constants/action-button.js +17 -0
- package/dist/constants/field.d.ts +24 -0
- package/dist/constants/field.js +24 -0
- package/dist/constants/morph-text.d.ts +13 -0
- package/dist/constants/morph-text.js +13 -0
- package/dist/constants/split-button.d.ts +7 -0
- package/dist/constants/split-button.js +5 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/motion/arc-swap.d.ts +22 -0
- package/dist/motion/arc-swap.js +49 -0
- package/dist/motion/arc-tokens.d.ts +11 -0
- package/dist/motion/arc-tokens.js +9 -0
- package/dist/motion/use-morph-width.d.ts +13 -0
- package/dist/motion/use-morph-width.js +59 -0
- package/dist/styles.css +1 -1
- package/package.json +11 -1
|
@@ -0,0 +1,700 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c as _c } from "react/compiler-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* Labelled field with animated helper and error rows, adapted from Arc's Input and Textarea (https://uiarc.dev),
|
|
5
|
+
* Copyright (c) 2026 Elia Kuratli, MIT License. The full license text ships in THIRD_PARTY_NOTICES.md.
|
|
6
|
+
* Internal: shared by `Input` and `Textarea`, which render it only when they receive a label, description or error.
|
|
7
|
+
*/
|
|
8
|
+
import { useEffect, useId, useRef, useState } from "react";
|
|
9
|
+
import { AnimatePresence, motion } from "motion/react";
|
|
10
|
+
import { FIELD_MESSAGE_DIGIT_OFFSET_EM, FIELD_MESSAGE_ID_SUFFIX, FIELD_MESSAGE_COMPONENT_SEPARATOR_PATTERN, FIELD_MESSAGE_DECIMAL_COMMA, FIELD_MESSAGE_GROUP_SEPARATOR_PATTERN, FIELD_MESSAGE_NUMBER_PATTERN, FIELD_MESSAGE_WORD_OFFSET_EM } from "../constants/field.js";
|
|
11
|
+
import { usePrefersReducedMotion } from "../hooks/use-prefers-reduced-motion.js";
|
|
12
|
+
import { cn } from "../lib/utils.js";
|
|
13
|
+
import { ARC_BLUR, ARC_DURATION, ARC_EASE, ARC_SPRING_MORPH, ARC_SPRING_SMOOTH, ARC_SPRING_SNAPPY } from "../motion/arc-tokens.js";
|
|
14
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
15
|
+
const digitVariants = {
|
|
16
|
+
enter: (direction) => ({
|
|
17
|
+
opacity: 0,
|
|
18
|
+
y: `${direction * FIELD_MESSAGE_DIGIT_OFFSET_EM}em`,
|
|
19
|
+
filter: `blur(${ARC_BLUR.subtle}px)`
|
|
20
|
+
}),
|
|
21
|
+
center: {
|
|
22
|
+
opacity: 1,
|
|
23
|
+
y: 0,
|
|
24
|
+
filter: "blur(0px)"
|
|
25
|
+
},
|
|
26
|
+
exit: (direction) => ({
|
|
27
|
+
opacity: 0,
|
|
28
|
+
y: `${-direction * FIELD_MESSAGE_DIGIT_OFFSET_EM}em`,
|
|
29
|
+
filter: `blur(${ARC_BLUR.subtle}px)`
|
|
30
|
+
})
|
|
31
|
+
};
|
|
32
|
+
const instantTransition = { duration: 0 };
|
|
33
|
+
/**
|
|
34
|
+
* Reads one component of a count as a number, in English or Spanish formatting: grouping separators are dropped and
|
|
35
|
+
* a decimal comma becomes a point.
|
|
36
|
+
* @param component - A count, or one side of a time or ratio.
|
|
37
|
+
* @returns Its numeric value.
|
|
38
|
+
*/
|
|
39
|
+
function parseCountComponent(component) {
|
|
40
|
+
return parseFloat(component.replace(FIELD_MESSAGE_GROUP_SEPARATOR_PATTERN, "").replace(FIELD_MESSAGE_DECIMAL_COMMA, "."));
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Tells whether a count went down. Times and ratios compare component by component from the left, so `0:10` to
|
|
44
|
+
* `0:09` counts as a decrease.
|
|
45
|
+
* @param next - The new count.
|
|
46
|
+
* @param previous - The count shown before.
|
|
47
|
+
* @returns `true` when `next` is smaller than `previous`.
|
|
48
|
+
*/
|
|
49
|
+
function isCountDecrease(next, previous) {
|
|
50
|
+
const nextComponents = next.split(FIELD_MESSAGE_COMPONENT_SEPARATOR_PATTERN).map(parseCountComponent);
|
|
51
|
+
const previousComponents = previous.split(FIELD_MESSAGE_COMPONENT_SEPARATOR_PATTERN).map(parseCountComponent);
|
|
52
|
+
for (let index = 0; index < Math.min(nextComponents.length, previousComponents.length); index++) {
|
|
53
|
+
if (nextComponents[index] !== previousComponents[index]) return nextComponents[index] < previousComponents[index];
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Keys each word by its text and how many times that text appeared before it, so a word keeps its key when copy is
|
|
59
|
+
* inserted or removed before it and only the words that really changed animate. Counts are keyed by their order
|
|
60
|
+
* among counts instead of their value, so a changing count rolls its digits instead of being replaced.
|
|
61
|
+
* @param words - Words of the message in reading order.
|
|
62
|
+
* @returns The words with their keys.
|
|
63
|
+
*/
|
|
64
|
+
function keyWords(words) {
|
|
65
|
+
const occurrences = new Map();
|
|
66
|
+
return words.map((word) => {
|
|
67
|
+
const isCount = FIELD_MESSAGE_NUMBER_PATTERN.test(word);
|
|
68
|
+
const identity = isCount ? "#" : `w:${word}`;
|
|
69
|
+
const occurrence = occurrences.get(identity) ?? 0;
|
|
70
|
+
occurrences.set(identity, occurrence + 1);
|
|
71
|
+
return {
|
|
72
|
+
word,
|
|
73
|
+
isCount,
|
|
74
|
+
key: `${identity}:${occurrence}`
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* A count in the copy, such as "12 caracteres", rolls only the digits that changed, up when it grows and down when
|
|
80
|
+
* it shrinks; a gained or lost digit opens or closes its width.
|
|
81
|
+
*/
|
|
82
|
+
function RollingNumber(t0) {
|
|
83
|
+
const $ = _c(14);
|
|
84
|
+
const { word } = t0;
|
|
85
|
+
const reduceMotion = usePrefersReducedMotion();
|
|
86
|
+
let t1;
|
|
87
|
+
if ($[0] !== word) {
|
|
88
|
+
t1 = {
|
|
89
|
+
word,
|
|
90
|
+
direction: 1
|
|
91
|
+
};
|
|
92
|
+
$[0] = word;
|
|
93
|
+
$[1] = t1;
|
|
94
|
+
} else {
|
|
95
|
+
t1 = $[1];
|
|
96
|
+
}
|
|
97
|
+
const [shown, setShown] = useState(t1);
|
|
98
|
+
if (shown.word !== word) {
|
|
99
|
+
setShown({
|
|
100
|
+
word,
|
|
101
|
+
direction: isCountDecrease(word, shown.word) ? -1 : 1
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
let T0;
|
|
105
|
+
let t2;
|
|
106
|
+
let t3;
|
|
107
|
+
if ($[2] !== reduceMotion || $[3] !== shown.direction || $[4] !== word) {
|
|
108
|
+
const characters = word.split("");
|
|
109
|
+
let t4;
|
|
110
|
+
if ($[8] !== reduceMotion) {
|
|
111
|
+
t4 = reduceMotion ? instantTransition : {
|
|
112
|
+
y: ARC_SPRING_SNAPPY,
|
|
113
|
+
width: ARC_SPRING_MORPH,
|
|
114
|
+
opacity: { duration: ARC_DURATION.fast },
|
|
115
|
+
filter: { duration: ARC_DURATION.fast }
|
|
116
|
+
};
|
|
117
|
+
$[8] = reduceMotion;
|
|
118
|
+
$[9] = t4;
|
|
119
|
+
} else {
|
|
120
|
+
t4 = $[9];
|
|
121
|
+
}
|
|
122
|
+
const transition = t4;
|
|
123
|
+
T0 = AnimatePresence;
|
|
124
|
+
t2 = false;
|
|
125
|
+
t3 = characters.map((character, index) => /* @__PURE__ */ _jsx(motion.span, {
|
|
126
|
+
className: "relative inline-flex justify-center tabular-nums",
|
|
127
|
+
initial: reduceMotion ? false : {
|
|
128
|
+
width: 0,
|
|
129
|
+
opacity: 0
|
|
130
|
+
},
|
|
131
|
+
animate: {
|
|
132
|
+
width: "auto",
|
|
133
|
+
opacity: 1
|
|
134
|
+
},
|
|
135
|
+
exit: {
|
|
136
|
+
width: 0,
|
|
137
|
+
opacity: 0
|
|
138
|
+
},
|
|
139
|
+
transition,
|
|
140
|
+
children: /* @__PURE__ */ _jsx(AnimatePresence, {
|
|
141
|
+
initial: false,
|
|
142
|
+
mode: "popLayout",
|
|
143
|
+
custom: shown.direction,
|
|
144
|
+
children: /* @__PURE__ */ _jsx(motion.span, {
|
|
145
|
+
className: "inline-block",
|
|
146
|
+
custom: shown.direction,
|
|
147
|
+
variants: digitVariants,
|
|
148
|
+
initial: reduceMotion ? false : "enter",
|
|
149
|
+
animate: "center",
|
|
150
|
+
exit: "exit",
|
|
151
|
+
transition,
|
|
152
|
+
children: character
|
|
153
|
+
}, character)
|
|
154
|
+
})
|
|
155
|
+
}, characters.length - index));
|
|
156
|
+
$[2] = reduceMotion;
|
|
157
|
+
$[3] = shown.direction;
|
|
158
|
+
$[4] = word;
|
|
159
|
+
$[5] = T0;
|
|
160
|
+
$[6] = t2;
|
|
161
|
+
$[7] = t3;
|
|
162
|
+
} else {
|
|
163
|
+
T0 = $[5];
|
|
164
|
+
t2 = $[6];
|
|
165
|
+
t3 = $[7];
|
|
166
|
+
}
|
|
167
|
+
let t4;
|
|
168
|
+
if ($[10] !== T0 || $[11] !== t2 || $[12] !== t3) {
|
|
169
|
+
t4 = /* @__PURE__ */ _jsx(T0, {
|
|
170
|
+
initial: t2,
|
|
171
|
+
children: t3
|
|
172
|
+
});
|
|
173
|
+
$[10] = T0;
|
|
174
|
+
$[11] = t2;
|
|
175
|
+
$[12] = t3;
|
|
176
|
+
$[13] = t4;
|
|
177
|
+
} else {
|
|
178
|
+
t4 = $[13];
|
|
179
|
+
}
|
|
180
|
+
return t4;
|
|
181
|
+
}
|
|
182
|
+
/** Changed words rise in and unblur while unchanged words hold still, and counts roll. Assistive tech reads the plain copy. */
|
|
183
|
+
function MotionText(t0) {
|
|
184
|
+
const $ = _c(23);
|
|
185
|
+
const { text } = t0;
|
|
186
|
+
const reduceMotion = usePrefersReducedMotion();
|
|
187
|
+
let T0;
|
|
188
|
+
let t1;
|
|
189
|
+
let t2;
|
|
190
|
+
let t3;
|
|
191
|
+
let t4;
|
|
192
|
+
let t5;
|
|
193
|
+
let t6;
|
|
194
|
+
if ($[0] !== reduceMotion || $[1] !== text) {
|
|
195
|
+
const words = text.split(" ");
|
|
196
|
+
if ($[9] !== text) {
|
|
197
|
+
t6 = /* @__PURE__ */ _jsx("span", {
|
|
198
|
+
className: "sr-only",
|
|
199
|
+
children: text
|
|
200
|
+
});
|
|
201
|
+
$[9] = text;
|
|
202
|
+
$[10] = t6;
|
|
203
|
+
} else {
|
|
204
|
+
t6 = $[10];
|
|
205
|
+
}
|
|
206
|
+
t4 = "relative block";
|
|
207
|
+
t5 = "true";
|
|
208
|
+
T0 = AnimatePresence;
|
|
209
|
+
t1 = false;
|
|
210
|
+
t2 = "popLayout";
|
|
211
|
+
t3 = keyWords(words).map((t7, index) => {
|
|
212
|
+
const { word, isCount, key } = t7;
|
|
213
|
+
return /* @__PURE__ */ _jsxs(motion.span, {
|
|
214
|
+
className: "inline-block whitespace-pre",
|
|
215
|
+
initial: reduceMotion ? false : {
|
|
216
|
+
opacity: 0,
|
|
217
|
+
y: `${FIELD_MESSAGE_WORD_OFFSET_EM.enter}em`,
|
|
218
|
+
filter: `blur(${ARC_BLUR.soft}px)`
|
|
219
|
+
},
|
|
220
|
+
animate: {
|
|
221
|
+
opacity: 1,
|
|
222
|
+
y: 0,
|
|
223
|
+
filter: "blur(0px)"
|
|
224
|
+
},
|
|
225
|
+
exit: reduceMotion ? {
|
|
226
|
+
opacity: 0,
|
|
227
|
+
transition: instantTransition
|
|
228
|
+
} : {
|
|
229
|
+
opacity: 0,
|
|
230
|
+
y: `${FIELD_MESSAGE_WORD_OFFSET_EM.exit}em`,
|
|
231
|
+
filter: `blur(${ARC_BLUR.subtle}px)`,
|
|
232
|
+
transition: {
|
|
233
|
+
duration: ARC_DURATION.exit,
|
|
234
|
+
ease: [...ARC_EASE.standard]
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
transition: reduceMotion ? instantTransition : {
|
|
238
|
+
duration: ARC_DURATION.standard,
|
|
239
|
+
ease: [...ARC_EASE.enter]
|
|
240
|
+
},
|
|
241
|
+
children: [isCount ? /* @__PURE__ */ _jsx(RollingNumber, { word }) : word, index < words.length - 1 ? " " : null]
|
|
242
|
+
}, key);
|
|
243
|
+
});
|
|
244
|
+
$[0] = reduceMotion;
|
|
245
|
+
$[1] = text;
|
|
246
|
+
$[2] = T0;
|
|
247
|
+
$[3] = t1;
|
|
248
|
+
$[4] = t2;
|
|
249
|
+
$[5] = t3;
|
|
250
|
+
$[6] = t4;
|
|
251
|
+
$[7] = t5;
|
|
252
|
+
$[8] = t6;
|
|
253
|
+
} else {
|
|
254
|
+
T0 = $[2];
|
|
255
|
+
t1 = $[3];
|
|
256
|
+
t2 = $[4];
|
|
257
|
+
t3 = $[5];
|
|
258
|
+
t4 = $[6];
|
|
259
|
+
t5 = $[7];
|
|
260
|
+
t6 = $[8];
|
|
261
|
+
}
|
|
262
|
+
let t7;
|
|
263
|
+
if ($[11] !== T0 || $[12] !== t1 || $[13] !== t2 || $[14] !== t3) {
|
|
264
|
+
t7 = /* @__PURE__ */ _jsx(T0, {
|
|
265
|
+
initial: t1,
|
|
266
|
+
mode: t2,
|
|
267
|
+
children: t3
|
|
268
|
+
});
|
|
269
|
+
$[11] = T0;
|
|
270
|
+
$[12] = t1;
|
|
271
|
+
$[13] = t2;
|
|
272
|
+
$[14] = t3;
|
|
273
|
+
$[15] = t7;
|
|
274
|
+
} else {
|
|
275
|
+
t7 = $[15];
|
|
276
|
+
}
|
|
277
|
+
let t8;
|
|
278
|
+
if ($[16] !== t4 || $[17] !== t5 || $[18] !== t7) {
|
|
279
|
+
t8 = /* @__PURE__ */ _jsx("span", {
|
|
280
|
+
className: t4,
|
|
281
|
+
"aria-hidden": t5,
|
|
282
|
+
children: t7
|
|
283
|
+
});
|
|
284
|
+
$[16] = t4;
|
|
285
|
+
$[17] = t5;
|
|
286
|
+
$[18] = t7;
|
|
287
|
+
$[19] = t8;
|
|
288
|
+
} else {
|
|
289
|
+
t8 = $[19];
|
|
290
|
+
}
|
|
291
|
+
let t9;
|
|
292
|
+
if ($[20] !== t6 || $[21] !== t8) {
|
|
293
|
+
t9 = /* @__PURE__ */ _jsxs(_Fragment, { children: [t6, t8] });
|
|
294
|
+
$[20] = t6;
|
|
295
|
+
$[21] = t8;
|
|
296
|
+
$[22] = t9;
|
|
297
|
+
} else {
|
|
298
|
+
t9 = $[22];
|
|
299
|
+
}
|
|
300
|
+
return t9;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* A helper or error row: it opens its height on a smooth spring, then the words settle in. The row tracks the
|
|
304
|
+
* measured copy, so a longer message that wraps opens its next line instead of snapping.
|
|
305
|
+
*/
|
|
306
|
+
function MessageRow(t0) {
|
|
307
|
+
const $ = _c(36);
|
|
308
|
+
const { id, text, className, alert: t1 } = t0;
|
|
309
|
+
const alert = t1 === undefined ? false : t1;
|
|
310
|
+
const reduceMotion = usePrefersReducedMotion();
|
|
311
|
+
const copyRef = useRef(null);
|
|
312
|
+
const [height, setHeight] = useState("auto");
|
|
313
|
+
let t2;
|
|
314
|
+
let t3;
|
|
315
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
316
|
+
t2 = () => {
|
|
317
|
+
const copyElement = copyRef.current;
|
|
318
|
+
if (!copyElement || typeof ResizeObserver === "undefined") {
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
const observer = new ResizeObserver((t4) => {
|
|
322
|
+
const [entry] = t4;
|
|
323
|
+
if (entry) {
|
|
324
|
+
setHeight(entry.borderBoxSize?.[0]?.blockSize ?? copyElement.offsetHeight);
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
observer.observe(copyElement);
|
|
328
|
+
return () => observer.disconnect();
|
|
329
|
+
};
|
|
330
|
+
t3 = [];
|
|
331
|
+
$[0] = t2;
|
|
332
|
+
$[1] = t3;
|
|
333
|
+
} else {
|
|
334
|
+
t2 = $[0];
|
|
335
|
+
t3 = $[1];
|
|
336
|
+
}
|
|
337
|
+
useEffect(t2, t3);
|
|
338
|
+
let t4;
|
|
339
|
+
if ($[2] !== reduceMotion) {
|
|
340
|
+
t4 = reduceMotion ? false : {
|
|
341
|
+
height: 0,
|
|
342
|
+
opacity: 0
|
|
343
|
+
};
|
|
344
|
+
$[2] = reduceMotion;
|
|
345
|
+
$[3] = t4;
|
|
346
|
+
} else {
|
|
347
|
+
t4 = $[3];
|
|
348
|
+
}
|
|
349
|
+
let t5;
|
|
350
|
+
if ($[4] !== height) {
|
|
351
|
+
t5 = {
|
|
352
|
+
height,
|
|
353
|
+
opacity: 1
|
|
354
|
+
};
|
|
355
|
+
$[4] = height;
|
|
356
|
+
$[5] = t5;
|
|
357
|
+
} else {
|
|
358
|
+
t5 = $[5];
|
|
359
|
+
}
|
|
360
|
+
let t6;
|
|
361
|
+
if ($[6] !== reduceMotion) {
|
|
362
|
+
t6 = reduceMotion ? instantTransition : {
|
|
363
|
+
height: ARC_SPRING_SMOOTH,
|
|
364
|
+
opacity: { duration: ARC_DURATION.instant }
|
|
365
|
+
};
|
|
366
|
+
$[6] = reduceMotion;
|
|
367
|
+
$[7] = t6;
|
|
368
|
+
} else {
|
|
369
|
+
t6 = $[7];
|
|
370
|
+
}
|
|
371
|
+
let t7;
|
|
372
|
+
if ($[8] !== t6) {
|
|
373
|
+
t7 = {
|
|
374
|
+
height: 0,
|
|
375
|
+
opacity: 0,
|
|
376
|
+
transition: t6
|
|
377
|
+
};
|
|
378
|
+
$[8] = t6;
|
|
379
|
+
$[9] = t7;
|
|
380
|
+
} else {
|
|
381
|
+
t7 = $[9];
|
|
382
|
+
}
|
|
383
|
+
let t8;
|
|
384
|
+
if ($[10] !== reduceMotion) {
|
|
385
|
+
t8 = reduceMotion ? instantTransition : {
|
|
386
|
+
height: ARC_SPRING_SMOOTH,
|
|
387
|
+
opacity: { duration: ARC_DURATION.fast }
|
|
388
|
+
};
|
|
389
|
+
$[10] = reduceMotion;
|
|
390
|
+
$[11] = t8;
|
|
391
|
+
} else {
|
|
392
|
+
t8 = $[11];
|
|
393
|
+
}
|
|
394
|
+
const t9 = alert ? "field-error" : "field-description";
|
|
395
|
+
let t10;
|
|
396
|
+
if ($[12] !== className) {
|
|
397
|
+
t10 = cn("block pt-(--space-2) text-xs leading-(--leading-body)", className);
|
|
398
|
+
$[12] = className;
|
|
399
|
+
$[13] = t10;
|
|
400
|
+
} else {
|
|
401
|
+
t10 = $[13];
|
|
402
|
+
}
|
|
403
|
+
const t11 = alert ? "alert" : undefined;
|
|
404
|
+
let t12;
|
|
405
|
+
if ($[14] !== reduceMotion) {
|
|
406
|
+
t12 = reduceMotion ? false : {
|
|
407
|
+
y: `${FIELD_MESSAGE_WORD_OFFSET_EM.enter}em`,
|
|
408
|
+
filter: `blur(${ARC_BLUR.soft}px)`
|
|
409
|
+
};
|
|
410
|
+
$[14] = reduceMotion;
|
|
411
|
+
$[15] = t12;
|
|
412
|
+
} else {
|
|
413
|
+
t12 = $[15];
|
|
414
|
+
}
|
|
415
|
+
let t13;
|
|
416
|
+
if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
|
|
417
|
+
t13 = {
|
|
418
|
+
y: 0,
|
|
419
|
+
filter: "blur(0px)"
|
|
420
|
+
};
|
|
421
|
+
$[16] = t13;
|
|
422
|
+
} else {
|
|
423
|
+
t13 = $[16];
|
|
424
|
+
}
|
|
425
|
+
const t14 = reduceMotion ? 0 : ARC_DURATION.standard;
|
|
426
|
+
let t15;
|
|
427
|
+
if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
|
|
428
|
+
t15 = [...ARC_EASE.enter];
|
|
429
|
+
$[17] = t15;
|
|
430
|
+
} else {
|
|
431
|
+
t15 = $[17];
|
|
432
|
+
}
|
|
433
|
+
let t16;
|
|
434
|
+
if ($[18] !== t14) {
|
|
435
|
+
t16 = {
|
|
436
|
+
duration: t14,
|
|
437
|
+
ease: t15
|
|
438
|
+
};
|
|
439
|
+
$[18] = t14;
|
|
440
|
+
$[19] = t16;
|
|
441
|
+
} else {
|
|
442
|
+
t16 = $[19];
|
|
443
|
+
}
|
|
444
|
+
let t17;
|
|
445
|
+
if ($[20] !== text) {
|
|
446
|
+
t17 = /* @__PURE__ */ _jsx(MotionText, { text });
|
|
447
|
+
$[20] = text;
|
|
448
|
+
$[21] = t17;
|
|
449
|
+
} else {
|
|
450
|
+
t17 = $[21];
|
|
451
|
+
}
|
|
452
|
+
let t18;
|
|
453
|
+
if ($[22] !== id || $[23] !== t10 || $[24] !== t11 || $[25] !== t12 || $[26] !== t16 || $[27] !== t17 || $[28] !== t9) {
|
|
454
|
+
t18 = /* @__PURE__ */ _jsx(motion.span, {
|
|
455
|
+
ref: copyRef,
|
|
456
|
+
id,
|
|
457
|
+
"data-slot": t9,
|
|
458
|
+
className: t10,
|
|
459
|
+
role: t11,
|
|
460
|
+
initial: t12,
|
|
461
|
+
animate: t13,
|
|
462
|
+
transition: t16,
|
|
463
|
+
children: t17
|
|
464
|
+
});
|
|
465
|
+
$[22] = id;
|
|
466
|
+
$[23] = t10;
|
|
467
|
+
$[24] = t11;
|
|
468
|
+
$[25] = t12;
|
|
469
|
+
$[26] = t16;
|
|
470
|
+
$[27] = t17;
|
|
471
|
+
$[28] = t9;
|
|
472
|
+
$[29] = t18;
|
|
473
|
+
} else {
|
|
474
|
+
t18 = $[29];
|
|
475
|
+
}
|
|
476
|
+
let t19;
|
|
477
|
+
if ($[30] !== t18 || $[31] !== t4 || $[32] !== t5 || $[33] !== t7 || $[34] !== t8) {
|
|
478
|
+
t19 = /* @__PURE__ */ _jsx(motion.span, {
|
|
479
|
+
className: "block overflow-hidden",
|
|
480
|
+
initial: t4,
|
|
481
|
+
animate: t5,
|
|
482
|
+
exit: t7,
|
|
483
|
+
transition: t8,
|
|
484
|
+
children: t18
|
|
485
|
+
});
|
|
486
|
+
$[30] = t18;
|
|
487
|
+
$[31] = t4;
|
|
488
|
+
$[32] = t5;
|
|
489
|
+
$[33] = t7;
|
|
490
|
+
$[34] = t8;
|
|
491
|
+
$[35] = t19;
|
|
492
|
+
} else {
|
|
493
|
+
t19 = $[35];
|
|
494
|
+
}
|
|
495
|
+
return t19;
|
|
496
|
+
}
|
|
497
|
+
/** Mounts a message row while there is copy, and closes it when the copy goes away. */
|
|
498
|
+
function FieldMessage(t0) {
|
|
499
|
+
const $ = _c(8);
|
|
500
|
+
let props;
|
|
501
|
+
let text;
|
|
502
|
+
if ($[0] !== t0) {
|
|
503
|
+
({text, ...props} = t0);
|
|
504
|
+
$[0] = t0;
|
|
505
|
+
$[1] = props;
|
|
506
|
+
$[2] = text;
|
|
507
|
+
} else {
|
|
508
|
+
props = $[1];
|
|
509
|
+
text = $[2];
|
|
510
|
+
}
|
|
511
|
+
let t1;
|
|
512
|
+
if ($[3] !== props || $[4] !== text) {
|
|
513
|
+
t1 = text ? /* @__PURE__ */ _jsx(MessageRow, {
|
|
514
|
+
text,
|
|
515
|
+
...props
|
|
516
|
+
}, "message") : null;
|
|
517
|
+
$[3] = props;
|
|
518
|
+
$[4] = text;
|
|
519
|
+
$[5] = t1;
|
|
520
|
+
} else {
|
|
521
|
+
t1 = $[5];
|
|
522
|
+
}
|
|
523
|
+
let t2;
|
|
524
|
+
if ($[6] !== t1) {
|
|
525
|
+
t2 = /* @__PURE__ */ _jsx(AnimatePresence, {
|
|
526
|
+
initial: false,
|
|
527
|
+
children: t1
|
|
528
|
+
});
|
|
529
|
+
$[6] = t1;
|
|
530
|
+
$[7] = t2;
|
|
531
|
+
} else {
|
|
532
|
+
t2 = $[7];
|
|
533
|
+
}
|
|
534
|
+
return t2;
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Resolves the control id (the caller's or a generated one) and merges the helper and error ids into the caller's
|
|
538
|
+
* `aria-describedby`. An error always marks the control invalid.
|
|
539
|
+
* @param options - Field copy and the caller's id and ARIA attributes.
|
|
540
|
+
* @returns The ids and ARIA attributes for the control.
|
|
541
|
+
*/
|
|
542
|
+
export function useFieldAria(t0) {
|
|
543
|
+
const $ = _c(15);
|
|
544
|
+
let aria;
|
|
545
|
+
let description;
|
|
546
|
+
let error;
|
|
547
|
+
let id;
|
|
548
|
+
if ($[0] !== t0) {
|
|
549
|
+
({id, description, error, ...aria} = t0);
|
|
550
|
+
$[0] = t0;
|
|
551
|
+
$[1] = aria;
|
|
552
|
+
$[2] = description;
|
|
553
|
+
$[3] = error;
|
|
554
|
+
$[4] = id;
|
|
555
|
+
} else {
|
|
556
|
+
aria = $[1];
|
|
557
|
+
description = $[2];
|
|
558
|
+
error = $[3];
|
|
559
|
+
id = $[4];
|
|
560
|
+
}
|
|
561
|
+
const generatedId = useId();
|
|
562
|
+
const controlId = id ?? generatedId;
|
|
563
|
+
const descriptionId = `${controlId}-${FIELD_MESSAGE_ID_SUFFIX.description}`;
|
|
564
|
+
const errorId = `${controlId}-${FIELD_MESSAGE_ID_SUFFIX.error}`;
|
|
565
|
+
const t1 = aria["aria-describedby"];
|
|
566
|
+
const t2 = description ? descriptionId : undefined;
|
|
567
|
+
const t3 = error ? errorId : undefined;
|
|
568
|
+
let t4;
|
|
569
|
+
if ($[5] !== t1 || $[6] !== t2 || $[7] !== t3) {
|
|
570
|
+
t4 = [
|
|
571
|
+
t1,
|
|
572
|
+
t2,
|
|
573
|
+
t3
|
|
574
|
+
].filter(Boolean);
|
|
575
|
+
$[5] = t1;
|
|
576
|
+
$[6] = t2;
|
|
577
|
+
$[7] = t3;
|
|
578
|
+
$[8] = t4;
|
|
579
|
+
} else {
|
|
580
|
+
t4 = $[8];
|
|
581
|
+
}
|
|
582
|
+
const describedBy = t4.join(" ");
|
|
583
|
+
const t5 = describedBy || undefined;
|
|
584
|
+
const t6 = error ? true : aria["aria-invalid"];
|
|
585
|
+
let t7;
|
|
586
|
+
if ($[9] !== controlId || $[10] !== descriptionId || $[11] !== errorId || $[12] !== t5 || $[13] !== t6) {
|
|
587
|
+
t7 = {
|
|
588
|
+
controlId,
|
|
589
|
+
descriptionId,
|
|
590
|
+
errorId,
|
|
591
|
+
"aria-describedby": t5,
|
|
592
|
+
"aria-invalid": t6
|
|
593
|
+
};
|
|
594
|
+
$[9] = controlId;
|
|
595
|
+
$[10] = descriptionId;
|
|
596
|
+
$[11] = errorId;
|
|
597
|
+
$[12] = t5;
|
|
598
|
+
$[13] = t6;
|
|
599
|
+
$[14] = t7;
|
|
600
|
+
} else {
|
|
601
|
+
t7 = $[14];
|
|
602
|
+
}
|
|
603
|
+
return t7;
|
|
604
|
+
}
|
|
605
|
+
/** Props that turn a bare control into a labelled field. */
|
|
606
|
+
const FIELD_COPY_PROPS = [
|
|
607
|
+
"label",
|
|
608
|
+
"description",
|
|
609
|
+
"error"
|
|
610
|
+
];
|
|
611
|
+
/**
|
|
612
|
+
* Tells whether a control renders as a labelled field. It looks at which props were passed, not at their values, so a
|
|
613
|
+
* field whose error or description comes and goes keeps the same tree and its control never remounts (losing an
|
|
614
|
+
* uncontrolled value or the focus) when validation appears.
|
|
615
|
+
* @param props - Props passed to the control.
|
|
616
|
+
* @returns `true` when the caller passed `label`, `description` or `error`, even as `undefined`.
|
|
617
|
+
*/
|
|
618
|
+
export function usesFieldCopy(props) {
|
|
619
|
+
return FIELD_COPY_PROPS.some((propName) => propName in props);
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* Arc's field layout: label, control, then the helper and error rows. There is no row gap, because grid tracks clamp
|
|
623
|
+
* a negative margin at zero and a closed row would still pay it; each row carries its own space instead. The wrapper
|
|
624
|
+
* keeps the bare control's full-width contract, so a field fills a flex row like the control alone does.
|
|
625
|
+
*/
|
|
626
|
+
export function Field(t0) {
|
|
627
|
+
const $ = _c(17);
|
|
628
|
+
const { label, description, error, aria, className, children } = t0;
|
|
629
|
+
let t1;
|
|
630
|
+
if ($[0] !== className) {
|
|
631
|
+
t1 = cn("grid w-full min-w-0", className);
|
|
632
|
+
$[0] = className;
|
|
633
|
+
$[1] = t1;
|
|
634
|
+
} else {
|
|
635
|
+
t1 = $[1];
|
|
636
|
+
}
|
|
637
|
+
let t2;
|
|
638
|
+
if ($[2] !== aria.controlId || $[3] !== label) {
|
|
639
|
+
t2 = label ? /* @__PURE__ */ _jsx("label", {
|
|
640
|
+
"data-slot": "field-label",
|
|
641
|
+
htmlFor: aria.controlId,
|
|
642
|
+
className: "mb-(--space-2) text-sm leading-(--leading-body) font-medium text-foreground",
|
|
643
|
+
children: label
|
|
644
|
+
}) : null;
|
|
645
|
+
$[2] = aria.controlId;
|
|
646
|
+
$[3] = label;
|
|
647
|
+
$[4] = t2;
|
|
648
|
+
} else {
|
|
649
|
+
t2 = $[4];
|
|
650
|
+
}
|
|
651
|
+
let t3;
|
|
652
|
+
if ($[5] !== aria.descriptionId || $[6] !== description) {
|
|
653
|
+
t3 = /* @__PURE__ */ _jsx(FieldMessage, {
|
|
654
|
+
id: aria.descriptionId,
|
|
655
|
+
text: description,
|
|
656
|
+
className: "text-text-muted"
|
|
657
|
+
});
|
|
658
|
+
$[5] = aria.descriptionId;
|
|
659
|
+
$[6] = description;
|
|
660
|
+
$[7] = t3;
|
|
661
|
+
} else {
|
|
662
|
+
t3 = $[7];
|
|
663
|
+
}
|
|
664
|
+
let t4;
|
|
665
|
+
if ($[8] !== aria.errorId || $[9] !== error) {
|
|
666
|
+
t4 = /* @__PURE__ */ _jsx(FieldMessage, {
|
|
667
|
+
id: aria.errorId,
|
|
668
|
+
text: error,
|
|
669
|
+
className: "text-danger",
|
|
670
|
+
alert: true
|
|
671
|
+
});
|
|
672
|
+
$[8] = aria.errorId;
|
|
673
|
+
$[9] = error;
|
|
674
|
+
$[10] = t4;
|
|
675
|
+
} else {
|
|
676
|
+
t4 = $[10];
|
|
677
|
+
}
|
|
678
|
+
let t5;
|
|
679
|
+
if ($[11] !== children || $[12] !== t1 || $[13] !== t2 || $[14] !== t3 || $[15] !== t4) {
|
|
680
|
+
t5 = /* @__PURE__ */ _jsxs("div", {
|
|
681
|
+
"data-slot": "field",
|
|
682
|
+
className: t1,
|
|
683
|
+
children: [
|
|
684
|
+
t2,
|
|
685
|
+
children,
|
|
686
|
+
t3,
|
|
687
|
+
t4
|
|
688
|
+
]
|
|
689
|
+
});
|
|
690
|
+
$[11] = children;
|
|
691
|
+
$[12] = t1;
|
|
692
|
+
$[13] = t2;
|
|
693
|
+
$[14] = t3;
|
|
694
|
+
$[15] = t4;
|
|
695
|
+
$[16] = t5;
|
|
696
|
+
} else {
|
|
697
|
+
t5 = $[16];
|
|
698
|
+
}
|
|
699
|
+
return t5;
|
|
700
|
+
}
|
|
@@ -23,7 +23,7 @@ function InputGroup(t0) {
|
|
|
23
23
|
}
|
|
24
24
|
let t1;
|
|
25
25
|
if ($[3] !== className) {
|
|
26
|
-
t1 = cn("group/input-group relative flex h-
|
|
26
|
+
t1 = cn("group/input-group relative flex min-h-(--control-height-md) w-full min-w-0 items-center rounded-(--radius-control) border border-border-strong bg-surface transition-[color,background-color,border-color] duration-(--duration-fast) ease-(--ease-standard) outline-none motion-reduce:transition-none in-data-[slot=combobox-content]:focus-within:border-inherit has-disabled:bg-surface-muted has-disabled:opacity-50 hover-fine:not-has-disabled:not-has-[[data-slot][aria-invalid=true]]:border-foreground has-[[data-slot=input-group-control]:focus-visible]:border-foreground has-[[data-slot][aria-invalid=true]]:border-danger has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5", className);
|
|
27
27
|
$[3] = className;
|
|
28
28
|
$[4] = t1;
|
|
29
29
|
} else {
|
|
@@ -221,7 +221,7 @@ function InputGroupInput(t0) {
|
|
|
221
221
|
}
|
|
222
222
|
let t1;
|
|
223
223
|
if ($[3] !== className) {
|
|
224
|
-
t1 = cn("flex-1 rounded-none border-0 bg-transparent shadow-none
|
|
224
|
+
t1 = cn("min-h-0 flex-1 self-stretch rounded-none border-0 bg-transparent shadow-none disabled:bg-transparent", className);
|
|
225
225
|
$[3] = className;
|
|
226
226
|
$[4] = t1;
|
|
227
227
|
} else {
|
|
@@ -257,7 +257,7 @@ function InputGroupTextarea(t0) {
|
|
|
257
257
|
}
|
|
258
258
|
let t1;
|
|
259
259
|
if ($[3] !== className) {
|
|
260
|
-
t1 = cn("flex-1 resize-none rounded-none border-0 bg-transparent py-2 shadow-none
|
|
260
|
+
t1 = cn("min-h-16 flex-1 resize-none rounded-none border-0 bg-transparent py-2 shadow-none disabled:bg-transparent", className);
|
|
261
261
|
$[3] = className;
|
|
262
262
|
$[4] = t1;
|
|
263
263
|
} else {
|