@voltstack/bravais 1.0.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 +47 -0
- package/dist/index.css +3647 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.ts +1318 -0
- package/dist/index.js +4717 -0
- package/dist/index.js.map +1 -0
- package/dist/styles.css +800 -0
- package/dist/styles.css.map +1 -0
- package/dist/styles.d.ts +2 -0
- package/package.json +52 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,4717 @@
|
|
|
1
|
+
import React, { forwardRef, useId, useRef, Children, createContext, useState, useMemo, useEffect, useCallback, memo, useImperativeHandle, useLayoutEffect, isValidElement, useContext, cloneElement } from 'react';
|
|
2
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
|
+
import { Link } from 'react-router-dom';
|
|
4
|
+
import { X, Search, Minus, Check, ChevronDown, AlertCircle, Plus, Copy, ChevronUp, ChevronRight, Trash2, Info, CircleAlert, TriangleAlert, CircleCheck, Bell } from 'lucide-react';
|
|
5
|
+
import { useFloating, autoUpdate, offset, flip, shift, useClick, useDismiss, useRole, useListNavigation, useTypeahead, useInteractions, FloatingPortal, FloatingFocusManager, size, useHover, useFocus } from '@floating-ui/react';
|
|
6
|
+
import { motion, AnimatePresence } from 'framer-motion';
|
|
7
|
+
import { ResponsiveContainer, AreaChart, YAxis, Area } from 'recharts';
|
|
8
|
+
|
|
9
|
+
// src/shared/presentation/primitives/types.ts
|
|
10
|
+
var STATUS_TONE_VARS = {
|
|
11
|
+
neutral: { fg: "var(--color-text-secondary)", bg: "var(--color-surface-2)", border: "var(--color-border-soft)" },
|
|
12
|
+
brand: { fg: "var(--color-brand-primary)", bg: "color-mix(in srgb, var(--color-brand-primary) 12%, transparent)", border: "color-mix(in srgb, var(--color-brand-primary) 24%, transparent)" },
|
|
13
|
+
success: { fg: "var(--status-success)", bg: "var(--status-success-bg)", border: "var(--status-success-border)" },
|
|
14
|
+
warning: { fg: "var(--status-warning)", bg: "var(--status-warning-bg)", border: "var(--status-warning-border)" },
|
|
15
|
+
danger: { fg: "var(--status-error)", bg: "var(--status-error-bg)", border: "var(--status-error-border)" },
|
|
16
|
+
info: { fg: "var(--status-info)", bg: "var(--status-info-bg)", border: "var(--status-info-border)" }
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// src/shared/presentation/primitives/buildBoxClasses.ts
|
|
20
|
+
var alignMap = {
|
|
21
|
+
start: "items-start",
|
|
22
|
+
center: "items-center",
|
|
23
|
+
end: "items-end"
|
|
24
|
+
};
|
|
25
|
+
var justifyMap = {
|
|
26
|
+
start: "",
|
|
27
|
+
center: "content-center",
|
|
28
|
+
end: "content-end",
|
|
29
|
+
between: "content-between",
|
|
30
|
+
around: "content-around"
|
|
31
|
+
};
|
|
32
|
+
var displayMap = {
|
|
33
|
+
flex: "d-flex",
|
|
34
|
+
grid: "d-grid",
|
|
35
|
+
block: "d-block",
|
|
36
|
+
none: "d-none"
|
|
37
|
+
};
|
|
38
|
+
var directionMap = {
|
|
39
|
+
row: "",
|
|
40
|
+
column: "column",
|
|
41
|
+
"row-reverse": "row-reverse"
|
|
42
|
+
};
|
|
43
|
+
var textAlignMap = {
|
|
44
|
+
left: "",
|
|
45
|
+
center: "text-center",
|
|
46
|
+
right: "text-right"
|
|
47
|
+
};
|
|
48
|
+
var borderMap = {
|
|
49
|
+
soft: "b-soft",
|
|
50
|
+
none: "b-none",
|
|
51
|
+
"bottom-soft": "border-bottom-soft",
|
|
52
|
+
"top-soft": "border-top-soft"
|
|
53
|
+
};
|
|
54
|
+
var widthMap = {
|
|
55
|
+
max: "w-max",
|
|
56
|
+
"50": "w-50",
|
|
57
|
+
"vw-max": "wh-max"
|
|
58
|
+
};
|
|
59
|
+
var heightMap = {
|
|
60
|
+
max: "h-max",
|
|
61
|
+
"vh-max": "vh-max"
|
|
62
|
+
};
|
|
63
|
+
var buildBoxClasses = (props) => {
|
|
64
|
+
const classes = [];
|
|
65
|
+
if (props.display) classes.push(displayMap[props.display]);
|
|
66
|
+
if (props.direction) {
|
|
67
|
+
const directionClass = directionMap[props.direction];
|
|
68
|
+
if (directionClass) classes.push(directionClass);
|
|
69
|
+
}
|
|
70
|
+
if (props.align) classes.push(alignMap[props.align]);
|
|
71
|
+
if (props.justify) {
|
|
72
|
+
const justifyClass = justifyMap[props.justify];
|
|
73
|
+
if (justifyClass) classes.push(justifyClass);
|
|
74
|
+
}
|
|
75
|
+
if (props.wrap) classes.push("flex-wrap");
|
|
76
|
+
if (props.gap) classes.push(`gap-${props.gap}`);
|
|
77
|
+
if (props.p !== void 0) classes.push(`p-${props.p}`);
|
|
78
|
+
if (props.px) classes.push(`px-${props.px}`);
|
|
79
|
+
if (props.m !== void 0) classes.push(`m-${props.m}`);
|
|
80
|
+
if (props.mt) classes.push(`mt-${props.mt}`);
|
|
81
|
+
if (props.mb) classes.push(`mb-${props.mb}`);
|
|
82
|
+
if (props.mx) classes.push(`mx-${props.mx}`);
|
|
83
|
+
if (props.radius) classes.push(`radius-${props.radius}`);
|
|
84
|
+
if (props.border) classes.push(borderMap[props.border]);
|
|
85
|
+
if (props.position) classes.push(`p-${props.position}`);
|
|
86
|
+
if (props.overflow) classes.push(`${props.overflow}`.includes("-") ? props.overflow : `overflow-${props.overflow}`);
|
|
87
|
+
if (props.width) classes.push(widthMap[props.width]);
|
|
88
|
+
if (props.height) classes.push(heightMap[props.height]);
|
|
89
|
+
if (props.flex) classes.push(`flex-${props.flex}`);
|
|
90
|
+
if (props.textAlign) {
|
|
91
|
+
const taClass = textAlignMap[props.textAlign];
|
|
92
|
+
if (taClass) classes.push(taClass);
|
|
93
|
+
}
|
|
94
|
+
if (props.shrink === "0") classes.push("f-shrink-0");
|
|
95
|
+
if (props.minH === "0") classes.push("min-h-0");
|
|
96
|
+
if (props.minW === "0") classes.push("min-w-0");
|
|
97
|
+
if (props.inset === "0") classes.push("inset-0");
|
|
98
|
+
if (props.top !== void 0) classes.push(`top-${props.top}`);
|
|
99
|
+
if (props.left !== void 0) classes.push(`left-${props.left}`);
|
|
100
|
+
if (props.bottom !== void 0) classes.push(`bottom-${props.bottom}`);
|
|
101
|
+
if (props.right !== void 0) classes.push(`right-${props.right}`);
|
|
102
|
+
if (props.zIndex) classes.push(`z-${props.zIndex}`);
|
|
103
|
+
if (props.transition) classes.push(`transition-${props.transition}`);
|
|
104
|
+
if (props.cursor === "pointer") classes.push("cursor-pointer");
|
|
105
|
+
if (props.selectNone) classes.push("u-select-none");
|
|
106
|
+
return classes;
|
|
107
|
+
};
|
|
108
|
+
var BOX_STYLE_KEYS = [
|
|
109
|
+
"display",
|
|
110
|
+
"direction",
|
|
111
|
+
"align",
|
|
112
|
+
"justify",
|
|
113
|
+
"wrap",
|
|
114
|
+
"gap",
|
|
115
|
+
"p",
|
|
116
|
+
"px",
|
|
117
|
+
"m",
|
|
118
|
+
"mt",
|
|
119
|
+
"mb",
|
|
120
|
+
"mx",
|
|
121
|
+
"radius",
|
|
122
|
+
"border",
|
|
123
|
+
"position",
|
|
124
|
+
"overflow",
|
|
125
|
+
"width",
|
|
126
|
+
"height",
|
|
127
|
+
"flex",
|
|
128
|
+
"textAlign",
|
|
129
|
+
"shrink",
|
|
130
|
+
"minH",
|
|
131
|
+
"minW",
|
|
132
|
+
"inset",
|
|
133
|
+
"top",
|
|
134
|
+
"left",
|
|
135
|
+
"bottom",
|
|
136
|
+
"right",
|
|
137
|
+
"zIndex",
|
|
138
|
+
"transition",
|
|
139
|
+
"cursor",
|
|
140
|
+
"selectNone"
|
|
141
|
+
];
|
|
142
|
+
var splitBoxProps = (props) => {
|
|
143
|
+
const styleProps = {};
|
|
144
|
+
const rest = {};
|
|
145
|
+
for (const key of Object.keys(props)) {
|
|
146
|
+
if (BOX_STYLE_KEYS.includes(key)) {
|
|
147
|
+
styleProps[key] = props[key];
|
|
148
|
+
} else {
|
|
149
|
+
rest[key] = props[key];
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return {
|
|
153
|
+
styleProps,
|
|
154
|
+
rest
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
// src/shared/utils/cn.ts
|
|
159
|
+
var cn = (...classes) => {
|
|
160
|
+
return classes.filter(Boolean).join(" ");
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
// src/shared/presentation/primitives/typography.ts
|
|
164
|
+
var sizeMap = {
|
|
165
|
+
xs: "font-size-05",
|
|
166
|
+
sm: "font-size-1",
|
|
167
|
+
md: "font-size-2",
|
|
168
|
+
lg: "font-size-3",
|
|
169
|
+
xl: "font-size-4",
|
|
170
|
+
"2xl": "font-size-5",
|
|
171
|
+
"3xl": "font-size-6"
|
|
172
|
+
};
|
|
173
|
+
var weightMap = {
|
|
174
|
+
regular: "font-weight-4",
|
|
175
|
+
medium: "font-weight-5",
|
|
176
|
+
semibold: "font-weight-5-5",
|
|
177
|
+
bold: "font-weight-6"
|
|
178
|
+
};
|
|
179
|
+
var toneMap = {
|
|
180
|
+
primary: "color-primary",
|
|
181
|
+
secondary: "color-secondary",
|
|
182
|
+
muted: "color-muted",
|
|
183
|
+
"muted-foreground": "color-muted-foreground"
|
|
184
|
+
};
|
|
185
|
+
var alignMap2 = {
|
|
186
|
+
left: "",
|
|
187
|
+
center: "text-center",
|
|
188
|
+
right: "text-right"
|
|
189
|
+
};
|
|
190
|
+
var buildTypographyClasses = ({
|
|
191
|
+
size: size2,
|
|
192
|
+
weight,
|
|
193
|
+
tone,
|
|
194
|
+
align,
|
|
195
|
+
truncate,
|
|
196
|
+
lineHeight,
|
|
197
|
+
className
|
|
198
|
+
}) => cn(
|
|
199
|
+
size2 ? sizeMap[size2] : void 0,
|
|
200
|
+
weight ? weightMap[weight] : void 0,
|
|
201
|
+
tone ? toneMap[tone] : void 0,
|
|
202
|
+
align ? alignMap2[align] : void 0,
|
|
203
|
+
truncate ? "text-truncate" : void 0,
|
|
204
|
+
lineHeight ? `line-height-${lineHeight}` : void 0,
|
|
205
|
+
className
|
|
206
|
+
);
|
|
207
|
+
var BoxImpl = ({ as, className, children, ...props }, ref) => {
|
|
208
|
+
const Component = as ?? "div";
|
|
209
|
+
const { styleProps, rest } = splitBoxProps(props);
|
|
210
|
+
const classes = cn(...buildBoxClasses(styleProps), className);
|
|
211
|
+
return /* @__PURE__ */ jsx(Component, { ref, className: classes, ...rest, children });
|
|
212
|
+
};
|
|
213
|
+
var Box = forwardRef(BoxImpl);
|
|
214
|
+
var Box_default = Box;
|
|
215
|
+
var Stack = forwardRef(function Stack2(props, ref) {
|
|
216
|
+
return /* @__PURE__ */ jsx(
|
|
217
|
+
Box_default,
|
|
218
|
+
{
|
|
219
|
+
ref,
|
|
220
|
+
display: "flex",
|
|
221
|
+
direction: "column",
|
|
222
|
+
...props
|
|
223
|
+
}
|
|
224
|
+
);
|
|
225
|
+
});
|
|
226
|
+
var Stack_default = Stack;
|
|
227
|
+
var Row = forwardRef(function Row2({ reverse, align = "center", ...props }, ref) {
|
|
228
|
+
return /* @__PURE__ */ jsx(
|
|
229
|
+
Box_default,
|
|
230
|
+
{
|
|
231
|
+
ref,
|
|
232
|
+
display: "flex",
|
|
233
|
+
direction: reverse ? "row-reverse" : "row",
|
|
234
|
+
align,
|
|
235
|
+
...props
|
|
236
|
+
}
|
|
237
|
+
);
|
|
238
|
+
});
|
|
239
|
+
var Row_default = Row;
|
|
240
|
+
var columnsClass = {
|
|
241
|
+
"2": "grid-cols-2",
|
|
242
|
+
"3": "grid-cols-3",
|
|
243
|
+
"4": "grid-cols-4",
|
|
244
|
+
"auto-fit": "grid-auto-fit",
|
|
245
|
+
"auto-fill": "grid-auto-fill"
|
|
246
|
+
};
|
|
247
|
+
var Grid = forwardRef(function Grid2({ columns, minColumnWidth, className, style, ...props }, ref) {
|
|
248
|
+
const colClass = columns !== void 0 ? columnsClass[String(columns)] : void 0;
|
|
249
|
+
const mergedStyle = minColumnWidth ? { ...style, "--grid-min": minColumnWidth } : style;
|
|
250
|
+
return /* @__PURE__ */ jsx(
|
|
251
|
+
Box_default,
|
|
252
|
+
{
|
|
253
|
+
ref,
|
|
254
|
+
display: "grid",
|
|
255
|
+
className: [colClass, className].filter(Boolean).join(" ") || void 0,
|
|
256
|
+
style: mergedStyle,
|
|
257
|
+
...props
|
|
258
|
+
}
|
|
259
|
+
);
|
|
260
|
+
});
|
|
261
|
+
var Grid_default = Grid;
|
|
262
|
+
var variantMap = {
|
|
263
|
+
primary: "primary-surface",
|
|
264
|
+
glass: "glass-bg",
|
|
265
|
+
elevated: "card-elevated",
|
|
266
|
+
danger: "zone-danger",
|
|
267
|
+
warning: "zone-warning"
|
|
268
|
+
};
|
|
269
|
+
var Surface = forwardRef(({
|
|
270
|
+
as,
|
|
271
|
+
variant,
|
|
272
|
+
className,
|
|
273
|
+
children,
|
|
274
|
+
...props
|
|
275
|
+
}, ref) => {
|
|
276
|
+
const Component = as ?? "div";
|
|
277
|
+
const { styleProps, rest } = splitBoxProps(props);
|
|
278
|
+
const classes = cn(
|
|
279
|
+
variant ? variantMap[variant] : void 0,
|
|
280
|
+
...buildBoxClasses(styleProps),
|
|
281
|
+
className
|
|
282
|
+
);
|
|
283
|
+
return /* @__PURE__ */ jsx(Component, { ref, className: classes, ...rest, children });
|
|
284
|
+
});
|
|
285
|
+
Surface.displayName = "Surface";
|
|
286
|
+
var Surface_default = Surface;
|
|
287
|
+
var Divider = forwardRef(({
|
|
288
|
+
orientation = "horizontal",
|
|
289
|
+
className,
|
|
290
|
+
...rest
|
|
291
|
+
}, ref) => {
|
|
292
|
+
const classes = cn(
|
|
293
|
+
"volt-divider",
|
|
294
|
+
`volt-divider--${orientation}`,
|
|
295
|
+
className
|
|
296
|
+
);
|
|
297
|
+
return /* @__PURE__ */ jsx(
|
|
298
|
+
"div",
|
|
299
|
+
{
|
|
300
|
+
ref,
|
|
301
|
+
role: "separator",
|
|
302
|
+
"aria-orientation": orientation,
|
|
303
|
+
className: classes,
|
|
304
|
+
...rest
|
|
305
|
+
}
|
|
306
|
+
);
|
|
307
|
+
});
|
|
308
|
+
Divider.displayName = "Divider";
|
|
309
|
+
var Divider_default = Divider;
|
|
310
|
+
var Text = forwardRef(({
|
|
311
|
+
as = "span",
|
|
312
|
+
size: size2,
|
|
313
|
+
weight,
|
|
314
|
+
tone,
|
|
315
|
+
align,
|
|
316
|
+
truncate,
|
|
317
|
+
lineHeight,
|
|
318
|
+
className,
|
|
319
|
+
children,
|
|
320
|
+
...rest
|
|
321
|
+
}, ref) => {
|
|
322
|
+
const Component = as;
|
|
323
|
+
const classes = buildTypographyClasses({ size: size2, weight, tone, align, truncate, lineHeight, className });
|
|
324
|
+
return /* @__PURE__ */ jsx(Component, { ref, className: classes, ...rest, children });
|
|
325
|
+
});
|
|
326
|
+
Text.displayName = "Text";
|
|
327
|
+
var Text_default = Text;
|
|
328
|
+
var Heading = forwardRef(({
|
|
329
|
+
level,
|
|
330
|
+
size: size2 = "lg",
|
|
331
|
+
weight = "medium",
|
|
332
|
+
tone = "primary",
|
|
333
|
+
truncate,
|
|
334
|
+
className,
|
|
335
|
+
children,
|
|
336
|
+
...rest
|
|
337
|
+
}, ref) => {
|
|
338
|
+
const Component = `h${level}`;
|
|
339
|
+
const classes = buildTypographyClasses({ size: size2, weight, tone, truncate, className });
|
|
340
|
+
return /* @__PURE__ */ jsx(Component, { ref, className: classes, ...rest, children });
|
|
341
|
+
});
|
|
342
|
+
Heading.displayName = "Heading";
|
|
343
|
+
var Heading_default = Heading;
|
|
344
|
+
var SectionLabel = forwardRef(({
|
|
345
|
+
className,
|
|
346
|
+
children,
|
|
347
|
+
...rest
|
|
348
|
+
}, ref) => {
|
|
349
|
+
return /* @__PURE__ */ jsx("span", { ref, className: cn("text-eyebrow", className), ...rest, children });
|
|
350
|
+
});
|
|
351
|
+
SectionLabel.displayName = "SectionLabel";
|
|
352
|
+
var SectionLabel_default = SectionLabel;
|
|
353
|
+
var Loader = forwardRef(({
|
|
354
|
+
scale,
|
|
355
|
+
isFixed = true,
|
|
356
|
+
fillParent = false,
|
|
357
|
+
className = "",
|
|
358
|
+
label,
|
|
359
|
+
announce = false,
|
|
360
|
+
reducedMotionLabel = "Loading"
|
|
361
|
+
}, ref) => {
|
|
362
|
+
const loaderItems = Array.from({ length: 12 }, (_, index) => index + 1);
|
|
363
|
+
const statusId = useId();
|
|
364
|
+
const statusLabel = label ?? "Loading";
|
|
365
|
+
let accessibilityProps = {};
|
|
366
|
+
if (announce) {
|
|
367
|
+
accessibilityProps = {
|
|
368
|
+
role: "status",
|
|
369
|
+
"aria-live": "polite",
|
|
370
|
+
"aria-atomic": true,
|
|
371
|
+
"aria-label": label ? void 0 : statusLabel,
|
|
372
|
+
"aria-labelledby": label ? statusId : void 0
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
const positioningClass = fillParent ? "loader-fill-parent" : isFixed ? "p-fixed inset-0" : "";
|
|
376
|
+
return /* @__PURE__ */ jsx("div", { ref, className: `d-flex flex-center ${positioningClass} ${className}`, ...accessibilityProps, children: /* @__PURE__ */ jsxs("div", { className: "d-flex column items-center gap-2 loader-content", children: [
|
|
377
|
+
/* @__PURE__ */ jsx("div", { className: "p-relative loader-visual", style: { transform: `scale(${scale})` }, children: loaderItems.map((item) => /* @__PURE__ */ jsx("div", { className: `p-absolute Loader-Item Loader-Item-${item}` }, item)) }),
|
|
378
|
+
label && /* @__PURE__ */ jsx("span", { id: statusId, className: "loader-label font-size-2 color-secondary text-center line-height-5", children: label }),
|
|
379
|
+
/* @__PURE__ */ jsx("span", { className: "loader-reduced-motion-label", children: reducedMotionLabel })
|
|
380
|
+
] }) });
|
|
381
|
+
});
|
|
382
|
+
Loader.displayName = "Loader";
|
|
383
|
+
var Loader_default = Loader;
|
|
384
|
+
var MISSING_ICON_ONLY_LABEL_ERROR = "Button with iconOnly requires an accessible name via aria-label, title, or text children.";
|
|
385
|
+
var FALLBACK_ICON_ONLY_LABEL = "Icon button";
|
|
386
|
+
var Button = forwardRef(({
|
|
387
|
+
className = "",
|
|
388
|
+
variant = "solid",
|
|
389
|
+
intent = "neutral",
|
|
390
|
+
size: size2 = "md",
|
|
391
|
+
shape = "rounded",
|
|
392
|
+
block = false,
|
|
393
|
+
align = "center",
|
|
394
|
+
isLoading = false,
|
|
395
|
+
to,
|
|
396
|
+
disabled,
|
|
397
|
+
leftIcon,
|
|
398
|
+
rightIcon,
|
|
399
|
+
iconOnly = false,
|
|
400
|
+
iconSize,
|
|
401
|
+
premium = false,
|
|
402
|
+
children,
|
|
403
|
+
onClick,
|
|
404
|
+
style,
|
|
405
|
+
title,
|
|
406
|
+
type = "button",
|
|
407
|
+
"aria-label": ariaLabel,
|
|
408
|
+
"aria-labelledby": ariaLabelledBy,
|
|
409
|
+
"aria-describedby": ariaDescribedBy,
|
|
410
|
+
"aria-controls": ariaControls,
|
|
411
|
+
"aria-expanded": ariaExpanded,
|
|
412
|
+
id,
|
|
413
|
+
role,
|
|
414
|
+
tabIndex,
|
|
415
|
+
...props
|
|
416
|
+
}, ref) => {
|
|
417
|
+
const hasWarnedForMissingLabelRef = useRef(false);
|
|
418
|
+
const isDisabled = disabled || isLoading;
|
|
419
|
+
const textContent = Children.toArray(children).filter((child) => typeof child === "string" || typeof child === "number").join(" ").trim();
|
|
420
|
+
const resolvedTextContent = textContent || void 0;
|
|
421
|
+
const normalizedAriaLabel = ariaLabel?.trim() || void 0;
|
|
422
|
+
const normalizedTitle = title?.trim() || void 0;
|
|
423
|
+
let resolvedAriaLabel = normalizedAriaLabel;
|
|
424
|
+
if (iconOnly && !resolvedAriaLabel) {
|
|
425
|
+
resolvedAriaLabel = normalizedTitle ?? resolvedTextContent;
|
|
426
|
+
}
|
|
427
|
+
if (iconOnly && !resolvedAriaLabel) {
|
|
428
|
+
if (!hasWarnedForMissingLabelRef.current) {
|
|
429
|
+
console.warn(MISSING_ICON_ONLY_LABEL_ERROR);
|
|
430
|
+
hasWarnedForMissingLabelRef.current = true;
|
|
431
|
+
}
|
|
432
|
+
resolvedAriaLabel = FALLBACK_ICON_ONLY_LABEL;
|
|
433
|
+
}
|
|
434
|
+
const resolvedStyle = {
|
|
435
|
+
...style,
|
|
436
|
+
...iconSize ? { "--button-icon-size": `${iconSize}px` } : {}
|
|
437
|
+
};
|
|
438
|
+
const resolvedTitle = normalizedTitle ?? (iconOnly ? resolvedAriaLabel : void 0);
|
|
439
|
+
const classes = cn(
|
|
440
|
+
"button",
|
|
441
|
+
`variant-${variant}`,
|
|
442
|
+
`intent-${intent}`,
|
|
443
|
+
`size-${size2}`,
|
|
444
|
+
`shape-${shape}`,
|
|
445
|
+
block && "block",
|
|
446
|
+
align !== "center" && `align-${align}`,
|
|
447
|
+
isLoading && "is-loading",
|
|
448
|
+
iconOnly && "icon-only",
|
|
449
|
+
premium && "premium",
|
|
450
|
+
"p-relative",
|
|
451
|
+
"items-center",
|
|
452
|
+
"content-center",
|
|
453
|
+
"font-weight-5",
|
|
454
|
+
"u-select-none",
|
|
455
|
+
"cursor-pointer",
|
|
456
|
+
"transition-fast",
|
|
457
|
+
className
|
|
458
|
+
);
|
|
459
|
+
const handleButtonClick = (event) => {
|
|
460
|
+
if (isDisabled) {
|
|
461
|
+
event.preventDefault();
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
onClick?.(event);
|
|
465
|
+
};
|
|
466
|
+
const handleLinkClick = (event) => {
|
|
467
|
+
if (isDisabled) {
|
|
468
|
+
event.preventDefault();
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
onClick?.(event);
|
|
472
|
+
};
|
|
473
|
+
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
474
|
+
isLoading && /* @__PURE__ */ jsx("div", { className: "button-loader p-absolute d-flex items-center content-center", children: /* @__PURE__ */ jsx(Loader_default, { scale: 0.6, isFixed: false }) }),
|
|
475
|
+
leftIcon && /* @__PURE__ */ jsx("span", { className: "button-icon-left font-size-4", "aria-hidden": "true", children: leftIcon }),
|
|
476
|
+
iconOnly ? /* @__PURE__ */ jsx("span", { className: "button-icon-only-content d-flex items-center content-center", "aria-hidden": "true", children }) : children,
|
|
477
|
+
rightIcon && /* @__PURE__ */ jsx("span", { className: "button-icon-right", "aria-hidden": "true", children: rightIcon })
|
|
478
|
+
] });
|
|
479
|
+
if (to) {
|
|
480
|
+
return /* @__PURE__ */ jsx(
|
|
481
|
+
Link,
|
|
482
|
+
{
|
|
483
|
+
to,
|
|
484
|
+
id,
|
|
485
|
+
className: classes,
|
|
486
|
+
role,
|
|
487
|
+
onClick: handleLinkClick,
|
|
488
|
+
title: resolvedTitle,
|
|
489
|
+
"aria-label": resolvedAriaLabel,
|
|
490
|
+
"aria-labelledby": ariaLabelledBy,
|
|
491
|
+
"aria-describedby": ariaDescribedBy,
|
|
492
|
+
"aria-controls": ariaControls,
|
|
493
|
+
"aria-expanded": ariaExpanded,
|
|
494
|
+
"aria-busy": isLoading || void 0,
|
|
495
|
+
"aria-disabled": isDisabled || void 0,
|
|
496
|
+
tabIndex: isDisabled ? -1 : tabIndex,
|
|
497
|
+
style: resolvedStyle,
|
|
498
|
+
children: content
|
|
499
|
+
}
|
|
500
|
+
);
|
|
501
|
+
}
|
|
502
|
+
return /* @__PURE__ */ jsx(
|
|
503
|
+
"button",
|
|
504
|
+
{
|
|
505
|
+
ref,
|
|
506
|
+
type,
|
|
507
|
+
className: classes,
|
|
508
|
+
disabled: isDisabled,
|
|
509
|
+
onClick: handleButtonClick,
|
|
510
|
+
title: resolvedTitle,
|
|
511
|
+
"aria-label": resolvedAriaLabel,
|
|
512
|
+
"aria-labelledby": ariaLabelledBy,
|
|
513
|
+
"aria-describedby": ariaDescribedBy,
|
|
514
|
+
"aria-controls": ariaControls,
|
|
515
|
+
"aria-expanded": ariaExpanded,
|
|
516
|
+
"aria-busy": isLoading || void 0,
|
|
517
|
+
id,
|
|
518
|
+
role,
|
|
519
|
+
tabIndex,
|
|
520
|
+
style: resolvedStyle,
|
|
521
|
+
...props,
|
|
522
|
+
children: content
|
|
523
|
+
}
|
|
524
|
+
);
|
|
525
|
+
});
|
|
526
|
+
Button.displayName = "Button";
|
|
527
|
+
var Button_default = Button;
|
|
528
|
+
var MISSING_ICON_BUTTON_LABEL_ERROR = "IconButton requires an accessible name via aria-label, aria-labelledby, or title.";
|
|
529
|
+
var FALLBACK_ICON_BUTTON_LABEL = "Icon button";
|
|
530
|
+
var IconButton = forwardRef(({
|
|
531
|
+
children,
|
|
532
|
+
className = "",
|
|
533
|
+
variant = "default",
|
|
534
|
+
size: size2 = "md",
|
|
535
|
+
disabled,
|
|
536
|
+
title,
|
|
537
|
+
"aria-label": ariaLabel,
|
|
538
|
+
"aria-labelledby": ariaLabelledBy,
|
|
539
|
+
onClick,
|
|
540
|
+
...props
|
|
541
|
+
}, ref) => {
|
|
542
|
+
const hasWarnedForMissingLabelRef = useRef(false);
|
|
543
|
+
const textContent = Children.toArray(children).filter((child) => typeof child === "string" || typeof child === "number").join(" ").trim();
|
|
544
|
+
const resolvedTitle = title?.trim() || void 0;
|
|
545
|
+
const labelledBy = ariaLabelledBy?.trim() || void 0;
|
|
546
|
+
let resolvedAriaLabel = ariaLabel?.trim() || resolvedTitle || textContent || void 0;
|
|
547
|
+
if (!labelledBy && !resolvedAriaLabel) {
|
|
548
|
+
if (!hasWarnedForMissingLabelRef.current) {
|
|
549
|
+
console.warn(MISSING_ICON_BUTTON_LABEL_ERROR);
|
|
550
|
+
hasWarnedForMissingLabelRef.current = true;
|
|
551
|
+
}
|
|
552
|
+
resolvedAriaLabel = FALLBACK_ICON_BUTTON_LABEL;
|
|
553
|
+
}
|
|
554
|
+
const handleClick = (event) => {
|
|
555
|
+
if (disabled) {
|
|
556
|
+
event.preventDefault();
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
onClick?.(event);
|
|
560
|
+
};
|
|
561
|
+
const classes = [
|
|
562
|
+
"volt-icon-button",
|
|
563
|
+
"flex-center",
|
|
564
|
+
"transition-fast",
|
|
565
|
+
`volt-icon-button--${variant}`,
|
|
566
|
+
`volt-icon-button--${size2}`,
|
|
567
|
+
disabled && "volt-icon-button--disabled",
|
|
568
|
+
className
|
|
569
|
+
].filter(Boolean).join(" ");
|
|
570
|
+
return /* @__PURE__ */ jsx(
|
|
571
|
+
"button",
|
|
572
|
+
{
|
|
573
|
+
ref,
|
|
574
|
+
className: classes,
|
|
575
|
+
disabled,
|
|
576
|
+
type: "button",
|
|
577
|
+
title: resolvedTitle ?? resolvedAriaLabel,
|
|
578
|
+
"aria-label": resolvedAriaLabel,
|
|
579
|
+
"aria-labelledby": labelledBy,
|
|
580
|
+
onClick: handleClick,
|
|
581
|
+
...props,
|
|
582
|
+
children
|
|
583
|
+
}
|
|
584
|
+
);
|
|
585
|
+
});
|
|
586
|
+
IconButton.displayName = "IconButton";
|
|
587
|
+
var IconButton_default = IconButton;
|
|
588
|
+
var CloseButton = forwardRef(({
|
|
589
|
+
onClick,
|
|
590
|
+
command,
|
|
591
|
+
commandfor,
|
|
592
|
+
"aria-label": ariaLabel = "Close"
|
|
593
|
+
}, ref) => {
|
|
594
|
+
return /* @__PURE__ */ jsx(
|
|
595
|
+
Button_default,
|
|
596
|
+
{
|
|
597
|
+
ref,
|
|
598
|
+
variant: "ghost",
|
|
599
|
+
intent: "neutral",
|
|
600
|
+
iconOnly: true,
|
|
601
|
+
size: "sm",
|
|
602
|
+
onClick,
|
|
603
|
+
command,
|
|
604
|
+
commandfor,
|
|
605
|
+
"aria-label": ariaLabel,
|
|
606
|
+
children: /* @__PURE__ */ jsx(X, { size: 20 })
|
|
607
|
+
}
|
|
608
|
+
);
|
|
609
|
+
});
|
|
610
|
+
CloseButton.displayName = "CloseButton";
|
|
611
|
+
var CloseButton_default = CloseButton;
|
|
612
|
+
var MISSING_SEARCH_INPUT_NAME_ERROR = "SearchInput requires an accessible name via aria-label, aria-labelledby, or an external label bound to its id.";
|
|
613
|
+
var FALLBACK_SEARCH_LABEL = "Search";
|
|
614
|
+
var SearchInput = forwardRef(({
|
|
615
|
+
containerClassName,
|
|
616
|
+
variant = "default",
|
|
617
|
+
className,
|
|
618
|
+
placeholder = "Search\u2026",
|
|
619
|
+
overlayContent,
|
|
620
|
+
overlayVisible = false,
|
|
621
|
+
id,
|
|
622
|
+
title,
|
|
623
|
+
autoComplete = "off",
|
|
624
|
+
"aria-label": ariaLabel,
|
|
625
|
+
"aria-labelledby": ariaLabelledBy,
|
|
626
|
+
...props
|
|
627
|
+
}, ref) => {
|
|
628
|
+
const hasWarnedForMissingNameRef = useRef(false);
|
|
629
|
+
const resolvedAriaLabel = ariaLabel?.trim() || void 0;
|
|
630
|
+
const resolvedAriaLabelledBy = ariaLabelledBy?.trim() || void 0;
|
|
631
|
+
const resolvedTitle = title?.trim() || void 0;
|
|
632
|
+
const hasExternalLabelContract = Boolean(id);
|
|
633
|
+
let accessibleName = resolvedAriaLabel ?? resolvedTitle;
|
|
634
|
+
if (!resolvedAriaLabelledBy && !accessibleName && !hasExternalLabelContract) {
|
|
635
|
+
if (!hasWarnedForMissingNameRef.current) {
|
|
636
|
+
console.warn(MISSING_SEARCH_INPUT_NAME_ERROR);
|
|
637
|
+
hasWarnedForMissingNameRef.current = true;
|
|
638
|
+
}
|
|
639
|
+
accessibleName = FALLBACK_SEARCH_LABEL;
|
|
640
|
+
}
|
|
641
|
+
return /* @__PURE__ */ jsxs("div", { className: `${cn("search-input-container d-flex items-center gap-05", variant === "small" && "search-input-container--small", containerClassName)}`, children: [
|
|
642
|
+
/* @__PURE__ */ jsx(Search, { "aria-hidden": "true", className: cn("search-input-icon color-muted f-shrink-0", variant === "small" && "search-input-icon--small") }),
|
|
643
|
+
/* @__PURE__ */ jsxs("div", { className: "search-input-content p-relative flex-1", children: [
|
|
644
|
+
overlayVisible && overlayContent && /* @__PURE__ */ jsx("div", { className: "search-input-overlay d-flex items-center", children: overlayContent }),
|
|
645
|
+
/* @__PURE__ */ jsx(
|
|
646
|
+
"input",
|
|
647
|
+
{
|
|
648
|
+
ref,
|
|
649
|
+
id,
|
|
650
|
+
type: "search",
|
|
651
|
+
title: resolvedTitle,
|
|
652
|
+
"aria-label": accessibleName,
|
|
653
|
+
"aria-labelledby": resolvedAriaLabelledBy,
|
|
654
|
+
autoComplete,
|
|
655
|
+
placeholder: overlayVisible ? "" : placeholder || "Search\u2026",
|
|
656
|
+
className: cn("search-input font-size-2 color-primary flex-1", variant === "small" && "search-input--small", className, overlayVisible && "search-input--with-overlay"),
|
|
657
|
+
...props
|
|
658
|
+
}
|
|
659
|
+
)
|
|
660
|
+
] })
|
|
661
|
+
] });
|
|
662
|
+
});
|
|
663
|
+
SearchInput.displayName = "SearchInput";
|
|
664
|
+
var SearchInput_default = SearchInput;
|
|
665
|
+
var FloatingRootContext = createContext(void 0);
|
|
666
|
+
var TopLayerRootContext = createContext(void 0);
|
|
667
|
+
var FloatingOwnerIdsContext = createContext([]);
|
|
668
|
+
var FLOATING_OWNER_IDS_ATTRIBUTE = "data-floating-owner-ids";
|
|
669
|
+
var useFloatingRoot = () => {
|
|
670
|
+
return useContext(FloatingRootContext);
|
|
671
|
+
};
|
|
672
|
+
var useTopLayerRoot = () => {
|
|
673
|
+
return useContext(TopLayerRootContext);
|
|
674
|
+
};
|
|
675
|
+
var useFloatingOwnerIds = () => {
|
|
676
|
+
return useContext(FloatingOwnerIdsContext);
|
|
677
|
+
};
|
|
678
|
+
var appendFloatingOwnerIds = (ownerIds, ownerId) => {
|
|
679
|
+
if (!ownerId) {
|
|
680
|
+
return ownerIds;
|
|
681
|
+
}
|
|
682
|
+
return [...ownerIds, ownerId];
|
|
683
|
+
};
|
|
684
|
+
var getFloatingOwnerIdsAttribute = (ownerIds) => {
|
|
685
|
+
if (!ownerIds.length) {
|
|
686
|
+
return void 0;
|
|
687
|
+
}
|
|
688
|
+
return ownerIds.join(" ");
|
|
689
|
+
};
|
|
690
|
+
var hasFloatingOwnerId = (element, ownerId) => {
|
|
691
|
+
if (!element || !ownerId) {
|
|
692
|
+
return false;
|
|
693
|
+
}
|
|
694
|
+
const ownerIdsValue = element.closest(`[${FLOATING_OWNER_IDS_ATTRIBUTE}]`)?.getAttribute(FLOATING_OWNER_IDS_ATTRIBUTE);
|
|
695
|
+
if (!ownerIdsValue) {
|
|
696
|
+
return false;
|
|
697
|
+
}
|
|
698
|
+
return ownerIdsValue.split(/\s+/).includes(ownerId);
|
|
699
|
+
};
|
|
700
|
+
var FloatingRootContext_default = FloatingRootContext;
|
|
701
|
+
var matchReferenceWidth = (padding = 8) => {
|
|
702
|
+
return size({
|
|
703
|
+
apply({ rects, elements }) {
|
|
704
|
+
Object.assign(elements.floating.style, {
|
|
705
|
+
minWidth: `${rects.reference.width}px`
|
|
706
|
+
});
|
|
707
|
+
},
|
|
708
|
+
padding
|
|
709
|
+
});
|
|
710
|
+
};
|
|
711
|
+
var useFloatingLayerRoot = () => {
|
|
712
|
+
const floatingRoot = useTopLayerRoot();
|
|
713
|
+
const floatingOwnerIds = useFloatingOwnerIds();
|
|
714
|
+
const floatingOwnerIdsAttribute = getFloatingOwnerIdsAttribute(floatingOwnerIds);
|
|
715
|
+
return {
|
|
716
|
+
floatingRoot,
|
|
717
|
+
floatingOwnerIdsAttribute
|
|
718
|
+
};
|
|
719
|
+
};
|
|
720
|
+
var Select = forwardRef(({
|
|
721
|
+
options,
|
|
722
|
+
id,
|
|
723
|
+
value = null,
|
|
724
|
+
onChange,
|
|
725
|
+
disabled = false,
|
|
726
|
+
onDark = false,
|
|
727
|
+
placeholder = "Select\u2026",
|
|
728
|
+
className = "",
|
|
729
|
+
style,
|
|
730
|
+
optionClassName = "",
|
|
731
|
+
showSelectionIcon = true,
|
|
732
|
+
isLoading = false,
|
|
733
|
+
onScrollEnd,
|
|
734
|
+
renderOptionAction,
|
|
735
|
+
isEditable = false,
|
|
736
|
+
inputClassName = "",
|
|
737
|
+
title,
|
|
738
|
+
onFocusCapture,
|
|
739
|
+
isMulti = false,
|
|
740
|
+
selectedValues,
|
|
741
|
+
onMultiChange,
|
|
742
|
+
allOption,
|
|
743
|
+
renderTriggerLabel,
|
|
744
|
+
hasSearch = false,
|
|
745
|
+
searchPlaceholder = "Search\u2026",
|
|
746
|
+
"aria-label": ariaLabel,
|
|
747
|
+
"aria-labelledby": ariaLabelledBy,
|
|
748
|
+
"aria-describedby": ariaDescribedBy,
|
|
749
|
+
"aria-invalid": ariaInvalid,
|
|
750
|
+
"aria-errormessage": ariaErrorMessage
|
|
751
|
+
}, ref) => {
|
|
752
|
+
const uid = useId();
|
|
753
|
+
const { floatingRoot, floatingOwnerIdsAttribute } = useFloatingLayerRoot();
|
|
754
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
755
|
+
const [activeIndex, setActiveIndex] = useState(null);
|
|
756
|
+
const [searchQuery, setSearchQuery] = useState("");
|
|
757
|
+
const listRef = useRef([]);
|
|
758
|
+
const listContentRef = useRef([]);
|
|
759
|
+
const inputRef = useRef(null);
|
|
760
|
+
const selectedValuesSet = useMemo(() => new Set(selectedValues ?? []), [selectedValues]);
|
|
761
|
+
const selectedOption = useMemo(() => {
|
|
762
|
+
if (!value) return null;
|
|
763
|
+
return options.find((option) => option.value === value) || null;
|
|
764
|
+
}, [options, value]);
|
|
765
|
+
const filteredOptions = useMemo(() => {
|
|
766
|
+
if (!isEditable && !hasSearch || !searchQuery) return options;
|
|
767
|
+
const lowerQuery = searchQuery.toLowerCase();
|
|
768
|
+
return options.filter((option) => option.title.toLowerCase().includes(lowerQuery));
|
|
769
|
+
}, [options, isEditable, hasSearch, searchQuery]);
|
|
770
|
+
const displayOptions = useMemo(() => {
|
|
771
|
+
if (isMulti && allOption) {
|
|
772
|
+
return [{ value: allOption.value, title: allOption.title }, ...filteredOptions];
|
|
773
|
+
}
|
|
774
|
+
return filteredOptions;
|
|
775
|
+
}, [isMulti, allOption, filteredOptions]);
|
|
776
|
+
const selectedIndex = useMemo(() => {
|
|
777
|
+
if (isMulti) return null;
|
|
778
|
+
if (!value) return null;
|
|
779
|
+
const optionIndex = displayOptions.findIndex((option) => option.value === value);
|
|
780
|
+
if (optionIndex < 0) return null;
|
|
781
|
+
return optionIndex;
|
|
782
|
+
}, [isMulti, displayOptions, value]);
|
|
783
|
+
listContentRef.current = displayOptions.map((option) => option.title);
|
|
784
|
+
useEffect(() => {
|
|
785
|
+
if (!isOpen) {
|
|
786
|
+
setActiveIndex(null);
|
|
787
|
+
setSearchQuery("");
|
|
788
|
+
return;
|
|
789
|
+
}
|
|
790
|
+
if (selectedIndex !== null) {
|
|
791
|
+
setActiveIndex(selectedIndex);
|
|
792
|
+
return;
|
|
793
|
+
}
|
|
794
|
+
if (displayOptions.length > 0) {
|
|
795
|
+
setActiveIndex(0);
|
|
796
|
+
}
|
|
797
|
+
}, [isOpen, displayOptions.length, selectedIndex]);
|
|
798
|
+
const { refs, floatingStyles, context } = useFloating({
|
|
799
|
+
open: isOpen,
|
|
800
|
+
onOpenChange: setIsOpen,
|
|
801
|
+
placement: "bottom-start",
|
|
802
|
+
middleware: [
|
|
803
|
+
offset(6),
|
|
804
|
+
flip({ padding: 8 }),
|
|
805
|
+
shift({ padding: 8 }),
|
|
806
|
+
matchReferenceWidth()
|
|
807
|
+
],
|
|
808
|
+
whileElementsMounted: autoUpdate
|
|
809
|
+
});
|
|
810
|
+
const click = useClick(context, { keyboardHandlers: !isEditable });
|
|
811
|
+
const dismiss = useDismiss(context);
|
|
812
|
+
const role = useRole(context, { role: "listbox" });
|
|
813
|
+
const listNavigation = useListNavigation(context, {
|
|
814
|
+
listRef,
|
|
815
|
+
activeIndex,
|
|
816
|
+
selectedIndex: selectedIndex ?? void 0,
|
|
817
|
+
onNavigate: setActiveIndex,
|
|
818
|
+
loop: true
|
|
819
|
+
});
|
|
820
|
+
const typeahead = useTypeahead(context, {
|
|
821
|
+
listRef: listContentRef,
|
|
822
|
+
activeIndex,
|
|
823
|
+
selectedIndex: selectedIndex ?? void 0,
|
|
824
|
+
onMatch: setActiveIndex,
|
|
825
|
+
enabled: !isEditable && !isMulti
|
|
826
|
+
});
|
|
827
|
+
const { getReferenceProps, getFloatingProps, getItemProps } = useInteractions([
|
|
828
|
+
click,
|
|
829
|
+
dismiss,
|
|
830
|
+
role,
|
|
831
|
+
listNavigation,
|
|
832
|
+
typeahead
|
|
833
|
+
]);
|
|
834
|
+
const handleSelect = useCallback((optionValue) => {
|
|
835
|
+
if (isMulti) {
|
|
836
|
+
if (allOption && optionValue === allOption.value) {
|
|
837
|
+
onMultiChange?.([]);
|
|
838
|
+
} else {
|
|
839
|
+
const currentValues = selectedValues ?? [];
|
|
840
|
+
const isSelected = currentValues.includes(optionValue);
|
|
841
|
+
const nextValues = isSelected ? currentValues.filter((v) => v !== optionValue) : [...currentValues, optionValue];
|
|
842
|
+
onMultiChange?.(nextValues);
|
|
843
|
+
}
|
|
844
|
+
return;
|
|
845
|
+
}
|
|
846
|
+
onChange?.(optionValue);
|
|
847
|
+
setIsOpen(false);
|
|
848
|
+
}, [isMulti, allOption, selectedValues, onMultiChange, onChange]);
|
|
849
|
+
const handleScroll = useCallback((event) => {
|
|
850
|
+
if (!onScrollEnd) return;
|
|
851
|
+
const target = event.currentTarget;
|
|
852
|
+
const threshold = 50;
|
|
853
|
+
const isNearBottom = target.scrollHeight - target.scrollTop - target.clientHeight < threshold;
|
|
854
|
+
if (isNearBottom && !isLoading) {
|
|
855
|
+
onScrollEnd();
|
|
856
|
+
}
|
|
857
|
+
}, [onScrollEnd, isLoading]);
|
|
858
|
+
const handleInputChange = useCallback((e) => {
|
|
859
|
+
setSearchQuery(e.target.value);
|
|
860
|
+
if (!isOpen) {
|
|
861
|
+
setIsOpen(true);
|
|
862
|
+
}
|
|
863
|
+
}, [isOpen]);
|
|
864
|
+
const handleInputFocus = useCallback(() => {
|
|
865
|
+
setSearchQuery("");
|
|
866
|
+
setIsOpen(true);
|
|
867
|
+
requestAnimationFrame(() => inputRef.current?.select());
|
|
868
|
+
}, []);
|
|
869
|
+
const handleInputKeyDown = useCallback((e) => {
|
|
870
|
+
if (e.key === "Enter") {
|
|
871
|
+
e.preventDefault();
|
|
872
|
+
if (activeIndex !== null && filteredOptions[activeIndex]) {
|
|
873
|
+
handleSelect(filteredOptions[activeIndex].value);
|
|
874
|
+
} else if (filteredOptions.length === 1) {
|
|
875
|
+
handleSelect(filteredOptions[0].value);
|
|
876
|
+
}
|
|
877
|
+
return;
|
|
878
|
+
}
|
|
879
|
+
if (e.key === "Escape") {
|
|
880
|
+
setIsOpen(false);
|
|
881
|
+
setSearchQuery("");
|
|
882
|
+
}
|
|
883
|
+
}, [activeIndex, filteredOptions, handleSelect]);
|
|
884
|
+
const setInputReference = useCallback((node) => {
|
|
885
|
+
refs.setReference(node);
|
|
886
|
+
inputRef.current = node;
|
|
887
|
+
if (typeof ref === "function") {
|
|
888
|
+
ref(node);
|
|
889
|
+
} else if (ref) {
|
|
890
|
+
ref.current = node;
|
|
891
|
+
}
|
|
892
|
+
}, [refs, ref]);
|
|
893
|
+
const inputDisplayValue = isOpen ? searchQuery : selectedOption?.title ?? "";
|
|
894
|
+
const multiTriggerLabel = useMemo(() => {
|
|
895
|
+
const count = selectedValues?.length ?? 0;
|
|
896
|
+
if (renderTriggerLabel) {
|
|
897
|
+
return renderTriggerLabel(count, options.length);
|
|
898
|
+
}
|
|
899
|
+
if (count === 0) return placeholder;
|
|
900
|
+
return `${count} selected`;
|
|
901
|
+
}, [selectedValues, renderTriggerLabel, options.length, placeholder]);
|
|
902
|
+
const renderOption = (option, index) => {
|
|
903
|
+
let isSelected;
|
|
904
|
+
if (isMulti) {
|
|
905
|
+
if (allOption && option.value === allOption.value) {
|
|
906
|
+
isSelected = (selectedValues?.length ?? 0) === 0;
|
|
907
|
+
} else {
|
|
908
|
+
isSelected = selectedValuesSet.has(option.value);
|
|
909
|
+
}
|
|
910
|
+
} else {
|
|
911
|
+
isSelected = option.value === value;
|
|
912
|
+
}
|
|
913
|
+
const handleOptionKeyDown = (event) => {
|
|
914
|
+
if (event.key !== "Enter" && event.key !== " ") {
|
|
915
|
+
return;
|
|
916
|
+
}
|
|
917
|
+
event.preventDefault();
|
|
918
|
+
handleSelect(option.value);
|
|
919
|
+
};
|
|
920
|
+
return /* @__PURE__ */ jsxs(
|
|
921
|
+
"div",
|
|
922
|
+
{
|
|
923
|
+
ref: (node) => {
|
|
924
|
+
listRef.current[index] = node;
|
|
925
|
+
},
|
|
926
|
+
role: "option",
|
|
927
|
+
tabIndex: activeIndex === index ? 0 : -1,
|
|
928
|
+
"aria-selected": isSelected,
|
|
929
|
+
className: `select-option d-flex items-center content-between gap-05 ${optionClassName} ${isSelected ? "selected" : ""} ${activeIndex === index ? "active" : ""} color-primary cursor-pointer`,
|
|
930
|
+
...getItemProps({
|
|
931
|
+
onClick: () => handleSelect(option.value),
|
|
932
|
+
onKeyDown: handleOptionKeyDown
|
|
933
|
+
}),
|
|
934
|
+
children: [
|
|
935
|
+
/* @__PURE__ */ jsxs("div", { className: "d-flex column", children: [
|
|
936
|
+
/* @__PURE__ */ jsx("p", { className: "font-size-2", children: option.title }),
|
|
937
|
+
option.description && /* @__PURE__ */ jsx("p", { className: "select-option-description color-muted font-size-1", children: option.description })
|
|
938
|
+
] }),
|
|
939
|
+
showSelectionIcon && isSelected && /* @__PURE__ */ jsx(
|
|
940
|
+
"svg",
|
|
941
|
+
{
|
|
942
|
+
className: "select-option-check color-muted",
|
|
943
|
+
width: "16",
|
|
944
|
+
height: "16",
|
|
945
|
+
viewBox: "0 0 24 24",
|
|
946
|
+
"aria-hidden": "true",
|
|
947
|
+
children: /* @__PURE__ */ jsx(
|
|
948
|
+
"path",
|
|
949
|
+
{
|
|
950
|
+
d: "M20 6L9 17l-5-5",
|
|
951
|
+
fill: "none",
|
|
952
|
+
stroke: "currentColor",
|
|
953
|
+
strokeWidth: "2"
|
|
954
|
+
}
|
|
955
|
+
)
|
|
956
|
+
}
|
|
957
|
+
),
|
|
958
|
+
renderOptionAction?.(option, isSelected)
|
|
959
|
+
]
|
|
960
|
+
},
|
|
961
|
+
option.value
|
|
962
|
+
);
|
|
963
|
+
};
|
|
964
|
+
const renderTrigger = () => {
|
|
965
|
+
const triggerAriaProps = {
|
|
966
|
+
"aria-haspopup": "listbox",
|
|
967
|
+
"aria-expanded": isOpen,
|
|
968
|
+
"aria-label": ariaLabel,
|
|
969
|
+
"aria-labelledby": ariaLabelledBy,
|
|
970
|
+
"aria-describedby": ariaDescribedBy,
|
|
971
|
+
"aria-invalid": ariaInvalid,
|
|
972
|
+
"aria-errormessage": ariaErrorMessage
|
|
973
|
+
};
|
|
974
|
+
if (isEditable) {
|
|
975
|
+
return /* @__PURE__ */ jsx(
|
|
976
|
+
"input",
|
|
977
|
+
{
|
|
978
|
+
ref: setInputReference,
|
|
979
|
+
id: id ?? uid,
|
|
980
|
+
type: "text",
|
|
981
|
+
value: inputDisplayValue,
|
|
982
|
+
placeholder,
|
|
983
|
+
onChange: handleInputChange,
|
|
984
|
+
onFocus: handleInputFocus,
|
|
985
|
+
onKeyDown: handleInputKeyDown,
|
|
986
|
+
className: `select-trigger select-trigger--editable ${className} ${inputClassName} ${isOpen ? "open" : ""}`,
|
|
987
|
+
style,
|
|
988
|
+
disabled,
|
|
989
|
+
title,
|
|
990
|
+
...triggerAriaProps,
|
|
991
|
+
onFocusCapture,
|
|
992
|
+
...getReferenceProps()
|
|
993
|
+
}
|
|
994
|
+
);
|
|
995
|
+
}
|
|
996
|
+
const label = isMulti ? multiTriggerLabel : selectedOption ? selectedOption.title : /* @__PURE__ */ jsx("span", { className: "color-muted", children: placeholder });
|
|
997
|
+
const setButtonReference = (node) => {
|
|
998
|
+
refs.setReference(node);
|
|
999
|
+
if (typeof ref === "function") {
|
|
1000
|
+
ref(node);
|
|
1001
|
+
} else if (ref) {
|
|
1002
|
+
ref.current = node;
|
|
1003
|
+
}
|
|
1004
|
+
};
|
|
1005
|
+
return /* @__PURE__ */ jsxs(
|
|
1006
|
+
"button",
|
|
1007
|
+
{
|
|
1008
|
+
ref: setButtonReference,
|
|
1009
|
+
id: id ?? uid,
|
|
1010
|
+
type: "button",
|
|
1011
|
+
className: `select-trigger d-flex items-center gap-05 ${onDark ? "on-dark" : ""} ${className} ${isOpen ? "open" : ""} overflow-hidden cursor-pointer`,
|
|
1012
|
+
style,
|
|
1013
|
+
disabled,
|
|
1014
|
+
title,
|
|
1015
|
+
...triggerAriaProps,
|
|
1016
|
+
onFocusCapture,
|
|
1017
|
+
...getReferenceProps(),
|
|
1018
|
+
children: [
|
|
1019
|
+
/* @__PURE__ */ jsx("span", { className: "select-value overflow-hidden", children: label }),
|
|
1020
|
+
/* @__PURE__ */ jsx(
|
|
1021
|
+
"svg",
|
|
1022
|
+
{
|
|
1023
|
+
className: `select-chevron ${isOpen ? "rotated" : ""}`,
|
|
1024
|
+
width: "18",
|
|
1025
|
+
height: "18",
|
|
1026
|
+
viewBox: "0 0 24 24",
|
|
1027
|
+
"aria-hidden": "true",
|
|
1028
|
+
children: /* @__PURE__ */ jsx(
|
|
1029
|
+
"path",
|
|
1030
|
+
{
|
|
1031
|
+
d: "M7 10l5 5 5-5",
|
|
1032
|
+
fill: "none",
|
|
1033
|
+
stroke: "currentColor",
|
|
1034
|
+
strokeWidth: "2"
|
|
1035
|
+
}
|
|
1036
|
+
)
|
|
1037
|
+
}
|
|
1038
|
+
)
|
|
1039
|
+
]
|
|
1040
|
+
}
|
|
1041
|
+
);
|
|
1042
|
+
};
|
|
1043
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1044
|
+
renderTrigger(),
|
|
1045
|
+
isOpen && /* @__PURE__ */ jsx(FloatingPortal, { root: floatingRoot, children: /* @__PURE__ */ jsx(FloatingFocusManager, { context, modal: false, children: /* @__PURE__ */ jsxs(
|
|
1046
|
+
"div",
|
|
1047
|
+
{
|
|
1048
|
+
ref: refs.setFloating,
|
|
1049
|
+
className: "select-dropdown y-auto glass-bg",
|
|
1050
|
+
"data-floating-owner-ids": floatingOwnerIdsAttribute,
|
|
1051
|
+
style: floatingStyles,
|
|
1052
|
+
onScroll: handleScroll,
|
|
1053
|
+
...getFloatingProps(),
|
|
1054
|
+
children: [
|
|
1055
|
+
hasSearch && /* @__PURE__ */ jsx(
|
|
1056
|
+
SearchInput_default,
|
|
1057
|
+
{
|
|
1058
|
+
variant: "small",
|
|
1059
|
+
value: searchQuery,
|
|
1060
|
+
onChange: (e) => setSearchQuery(e.target.value),
|
|
1061
|
+
placeholder: searchPlaceholder,
|
|
1062
|
+
"aria-label": "Search options",
|
|
1063
|
+
containerClassName: "select-dropdown-search"
|
|
1064
|
+
}
|
|
1065
|
+
),
|
|
1066
|
+
displayOptions.map(renderOption),
|
|
1067
|
+
isLoading && /* @__PURE__ */ jsx("div", { className: "select-option-loading d-flex items-center content-center", children: /* @__PURE__ */ jsx("p", { className: "color-muted font-size-1", children: "Loading\u2026" }) })
|
|
1068
|
+
]
|
|
1069
|
+
}
|
|
1070
|
+
) }) })
|
|
1071
|
+
] });
|
|
1072
|
+
});
|
|
1073
|
+
Select.displayName = "Select";
|
|
1074
|
+
var Select_default = Select;
|
|
1075
|
+
var supportsMatchMedia = () => {
|
|
1076
|
+
return typeof window.matchMedia === "function";
|
|
1077
|
+
};
|
|
1078
|
+
var getInitialMatch = (query) => {
|
|
1079
|
+
if (!supportsMatchMedia()) {
|
|
1080
|
+
return false;
|
|
1081
|
+
}
|
|
1082
|
+
return window.matchMedia(query).matches;
|
|
1083
|
+
};
|
|
1084
|
+
var useMedia = (query) => {
|
|
1085
|
+
const [matches, setMatches] = useState(() => getInitialMatch(query));
|
|
1086
|
+
useEffect(() => {
|
|
1087
|
+
if (!supportsMatchMedia()) {
|
|
1088
|
+
return;
|
|
1089
|
+
}
|
|
1090
|
+
const mediaQueryList = window.matchMedia(query);
|
|
1091
|
+
const handleChange = (event) => setMatches(event.matches);
|
|
1092
|
+
setMatches(mediaQueryList.matches);
|
|
1093
|
+
mediaQueryList.addEventListener("change", handleChange);
|
|
1094
|
+
return () => mediaQueryList.removeEventListener("change", handleChange);
|
|
1095
|
+
}, [query]);
|
|
1096
|
+
return matches;
|
|
1097
|
+
};
|
|
1098
|
+
var use_media_default = useMedia;
|
|
1099
|
+
|
|
1100
|
+
// src/shared/presentation/hooks/use-prefers-reduced-motion.ts
|
|
1101
|
+
var REDUCED_MOTION_MEDIA_QUERY = "(prefers-reduced-motion: reduce)";
|
|
1102
|
+
var usePrefersReducedMotion = () => use_media_default(REDUCED_MOTION_MEDIA_QUERY);
|
|
1103
|
+
var SegmentedTabs = forwardRef(function SegmentedTabs2({
|
|
1104
|
+
tabs,
|
|
1105
|
+
activeTab,
|
|
1106
|
+
onChange,
|
|
1107
|
+
ariaLabel,
|
|
1108
|
+
layoutId,
|
|
1109
|
+
size: size2 = "md",
|
|
1110
|
+
fullWidth = false,
|
|
1111
|
+
className = ""
|
|
1112
|
+
}, ref) {
|
|
1113
|
+
const prefersReducedMotion = usePrefersReducedMotion();
|
|
1114
|
+
const autoLayoutId = useId();
|
|
1115
|
+
const resolvedLayoutId = layoutId ?? autoLayoutId;
|
|
1116
|
+
const containerClassName = [
|
|
1117
|
+
"segmented-tabs",
|
|
1118
|
+
`segmented-tabs--${size2}`,
|
|
1119
|
+
fullWidth ? "segmented-tabs--full" : "",
|
|
1120
|
+
className
|
|
1121
|
+
].filter(Boolean).join(" ");
|
|
1122
|
+
return /* @__PURE__ */ jsx("div", { ref, className: `${containerClassName}`, role: "tablist", "aria-label": ariaLabel, children: tabs.map((tab) => {
|
|
1123
|
+
const isActive = activeTab === tab.id;
|
|
1124
|
+
return /* @__PURE__ */ jsxs(
|
|
1125
|
+
"button",
|
|
1126
|
+
{
|
|
1127
|
+
type: "button",
|
|
1128
|
+
role: "tab",
|
|
1129
|
+
"aria-selected": isActive,
|
|
1130
|
+
tabIndex: isActive ? 0 : -1,
|
|
1131
|
+
className: `segmented-tabs__tab ${isActive ? "is-active" : ""}`,
|
|
1132
|
+
onClick: () => onChange(tab.id),
|
|
1133
|
+
children: [
|
|
1134
|
+
isActive && /* @__PURE__ */ jsx(
|
|
1135
|
+
motion.span,
|
|
1136
|
+
{
|
|
1137
|
+
layoutId: `${resolvedLayoutId}-pill`,
|
|
1138
|
+
className: "segmented-tabs__pill",
|
|
1139
|
+
transition: prefersReducedMotion ? { duration: 0 } : { type: "spring", stiffness: 420, damping: 36 }
|
|
1140
|
+
}
|
|
1141
|
+
),
|
|
1142
|
+
/* @__PURE__ */ jsxs("span", { className: "segmented-tabs__label", children: [
|
|
1143
|
+
tab.icon ? /* @__PURE__ */ jsx("span", { className: "segmented-tabs__icon d-flex flex-center", children: tab.icon }) : null,
|
|
1144
|
+
tab.label
|
|
1145
|
+
] })
|
|
1146
|
+
]
|
|
1147
|
+
},
|
|
1148
|
+
tab.id
|
|
1149
|
+
);
|
|
1150
|
+
}) });
|
|
1151
|
+
});
|
|
1152
|
+
SegmentedTabs.displayName = "SegmentedTabs";
|
|
1153
|
+
var SegmentedTabs_default = SegmentedTabs;
|
|
1154
|
+
var clamp = (v, min, max) => Math.min(max, Math.max(min, v));
|
|
1155
|
+
var getStepDecimals = (step) => {
|
|
1156
|
+
const s = step.toString();
|
|
1157
|
+
if (s.includes("e-")) return parseInt(s.split("e-")[1], 10);
|
|
1158
|
+
const i = s.indexOf(".");
|
|
1159
|
+
return i === -1 ? 0 : s.length - i - 1;
|
|
1160
|
+
};
|
|
1161
|
+
var snapToStep = (raw, min, step, decimals) => Number((Math.round((raw - min) / step) * step + min).toFixed(decimals));
|
|
1162
|
+
var Slider = forwardRef(({
|
|
1163
|
+
min,
|
|
1164
|
+
max,
|
|
1165
|
+
value,
|
|
1166
|
+
onChange,
|
|
1167
|
+
step = 1,
|
|
1168
|
+
disabled = false,
|
|
1169
|
+
className = "",
|
|
1170
|
+
style
|
|
1171
|
+
}, ref) => {
|
|
1172
|
+
const trackRef = useRef(null);
|
|
1173
|
+
const auraKeyRef = useRef(0);
|
|
1174
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
1175
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
1176
|
+
const [auraPulseKey, setAuraPulseKey] = useState(0);
|
|
1177
|
+
const prefersReducedMotion = usePrefersReducedMotion();
|
|
1178
|
+
const decimals = useMemo(() => getStepDecimals(step), [step]);
|
|
1179
|
+
const ratioFromValue = useCallback(
|
|
1180
|
+
(v) => max === min ? 0 : clamp((v - min) / (max - min), 0, 1),
|
|
1181
|
+
[min, max]
|
|
1182
|
+
);
|
|
1183
|
+
const ratio = ratioFromValue(value);
|
|
1184
|
+
const updateFromClientX = useCallback((clientX) => {
|
|
1185
|
+
if (!trackRef.current || disabled) return;
|
|
1186
|
+
const rect = trackRef.current.getBoundingClientRect();
|
|
1187
|
+
const r = clamp((clientX - rect.left) / rect.width, 0, 1);
|
|
1188
|
+
const raw = min + r * (max - min);
|
|
1189
|
+
const next = clamp(snapToStep(raw, min, step, decimals), min, max);
|
|
1190
|
+
onChange(next);
|
|
1191
|
+
}, [disabled, min, max, step, decimals, onChange]);
|
|
1192
|
+
const onPointerDown = useCallback((e) => {
|
|
1193
|
+
if (disabled) return;
|
|
1194
|
+
e.currentTarget.setPointerCapture?.(e.pointerId);
|
|
1195
|
+
setIsDragging(true);
|
|
1196
|
+
updateFromClientX(e.clientX);
|
|
1197
|
+
}, [disabled, updateFromClientX]);
|
|
1198
|
+
const onPointerMove = useCallback((e) => {
|
|
1199
|
+
if (!isDragging || disabled) return;
|
|
1200
|
+
updateFromClientX(e.clientX);
|
|
1201
|
+
}, [isDragging, disabled, updateFromClientX]);
|
|
1202
|
+
const finishDrag = useCallback((target, pointerId) => {
|
|
1203
|
+
target.releasePointerCapture?.(pointerId);
|
|
1204
|
+
setIsDragging(false);
|
|
1205
|
+
}, []);
|
|
1206
|
+
const onPointerUp = useCallback((e) => {
|
|
1207
|
+
if (!isDragging) return;
|
|
1208
|
+
finishDrag(e.currentTarget, e.pointerId);
|
|
1209
|
+
}, [isDragging, finishDrag]);
|
|
1210
|
+
const onPointerCancel = useCallback((e) => {
|
|
1211
|
+
if (!isDragging) return;
|
|
1212
|
+
finishDrag(e.currentTarget, e.pointerId);
|
|
1213
|
+
}, [isDragging, finishDrag]);
|
|
1214
|
+
const onLostCapture = useCallback(() => {
|
|
1215
|
+
if (isDragging) setIsDragging(false);
|
|
1216
|
+
}, [isDragging]);
|
|
1217
|
+
const onMouseEnter = useCallback(() => {
|
|
1218
|
+
if (disabled || isDragging) return;
|
|
1219
|
+
setIsHovered(true);
|
|
1220
|
+
}, [disabled, isDragging]);
|
|
1221
|
+
const onMouseLeave = useCallback(() => {
|
|
1222
|
+
if (disabled || isDragging) return;
|
|
1223
|
+
setIsHovered(false);
|
|
1224
|
+
}, [disabled, isDragging]);
|
|
1225
|
+
const triggerAuraPulse = useCallback(() => {
|
|
1226
|
+
if (prefersReducedMotion) return;
|
|
1227
|
+
auraKeyRef.current += 1;
|
|
1228
|
+
setAuraPulseKey(auraKeyRef.current);
|
|
1229
|
+
}, [prefersReducedMotion]);
|
|
1230
|
+
const onKeyDown = useCallback((e) => {
|
|
1231
|
+
if (disabled) return;
|
|
1232
|
+
let next = value;
|
|
1233
|
+
const coarse = step * 10;
|
|
1234
|
+
switch (e.key) {
|
|
1235
|
+
case "ArrowLeft":
|
|
1236
|
+
case "ArrowDown":
|
|
1237
|
+
e.preventDefault();
|
|
1238
|
+
next = clamp(value - step, min, max);
|
|
1239
|
+
break;
|
|
1240
|
+
case "ArrowRight":
|
|
1241
|
+
case "ArrowUp":
|
|
1242
|
+
e.preventDefault();
|
|
1243
|
+
next = clamp(value + step, min, max);
|
|
1244
|
+
break;
|
|
1245
|
+
case "PageDown":
|
|
1246
|
+
e.preventDefault();
|
|
1247
|
+
next = clamp(value - coarse, min, max);
|
|
1248
|
+
break;
|
|
1249
|
+
case "PageUp":
|
|
1250
|
+
e.preventDefault();
|
|
1251
|
+
next = clamp(value + coarse, min, max);
|
|
1252
|
+
break;
|
|
1253
|
+
case "Home":
|
|
1254
|
+
e.preventDefault();
|
|
1255
|
+
next = min;
|
|
1256
|
+
break;
|
|
1257
|
+
case "End":
|
|
1258
|
+
e.preventDefault();
|
|
1259
|
+
next = max;
|
|
1260
|
+
break;
|
|
1261
|
+
default:
|
|
1262
|
+
return;
|
|
1263
|
+
}
|
|
1264
|
+
next = snapToStep(next, min, step, decimals);
|
|
1265
|
+
triggerAuraPulse();
|
|
1266
|
+
onChange(next);
|
|
1267
|
+
}, [disabled, value, step, min, max, decimals, onChange, triggerAuraPulse]);
|
|
1268
|
+
useEffect(() => {
|
|
1269
|
+
if (disabled) {
|
|
1270
|
+
setIsHovered(false);
|
|
1271
|
+
setIsDragging(false);
|
|
1272
|
+
}
|
|
1273
|
+
}, [disabled]);
|
|
1274
|
+
const trackStyle = {
|
|
1275
|
+
"--slider-ratio": ratio,
|
|
1276
|
+
"--slider-ring-a": isDragging ? 1 : isHovered ? 0.5 : 0,
|
|
1277
|
+
"--slider-ring-b": isDragging ? 1 : 0,
|
|
1278
|
+
"--slider-elev": isDragging ? 1 : 0,
|
|
1279
|
+
"--slider-scale": isDragging ? 1.05 : isHovered ? 1.02 : 1,
|
|
1280
|
+
"--slider-aura-opacity": isDragging ? 1 : 0,
|
|
1281
|
+
"--slider-aura-scale": isDragging ? 1.1 : 1,
|
|
1282
|
+
"--slider-aura-intensity": isDragging ? 0.5 : 0,
|
|
1283
|
+
"--slider-sheen-opacity": isDragging ? 1 : 0
|
|
1284
|
+
};
|
|
1285
|
+
return /* @__PURE__ */ jsx("div", { ref, className: `slider slider--ios ${disabled ? "slider--disabled" : ""} ${className || ""} u-select-none`, style, "aria-disabled": disabled || void 0, "data-disabled": disabled || void 0, children: /* @__PURE__ */ jsx(
|
|
1286
|
+
"div",
|
|
1287
|
+
{
|
|
1288
|
+
ref: trackRef,
|
|
1289
|
+
className: "slider__track p-relative w-max overflow-hidden cursor-pointer",
|
|
1290
|
+
role: "slider",
|
|
1291
|
+
"aria-valuemin": min,
|
|
1292
|
+
"aria-valuemax": max,
|
|
1293
|
+
"aria-valuenow": value,
|
|
1294
|
+
"aria-valuetext": `${value}`,
|
|
1295
|
+
tabIndex: disabled ? -1 : 0,
|
|
1296
|
+
"data-dragging": isDragging || void 0,
|
|
1297
|
+
"data-hovered": isHovered || void 0,
|
|
1298
|
+
style: trackStyle,
|
|
1299
|
+
onPointerDown,
|
|
1300
|
+
onPointerMove,
|
|
1301
|
+
onPointerUp,
|
|
1302
|
+
onPointerCancel,
|
|
1303
|
+
onLostPointerCapture: onLostCapture,
|
|
1304
|
+
onKeyDown,
|
|
1305
|
+
onMouseEnter,
|
|
1306
|
+
onMouseLeave,
|
|
1307
|
+
children: /* @__PURE__ */ jsxs("div", { className: "slider__progress p-absolute inset-0", children: [
|
|
1308
|
+
/* @__PURE__ */ jsx("div", { className: "slider__gloss p-absolute" }),
|
|
1309
|
+
/* @__PURE__ */ jsx("div", { className: "slider__sheen p-absolute", "data-running": isDragging || void 0 }),
|
|
1310
|
+
/* @__PURE__ */ jsx(
|
|
1311
|
+
"div",
|
|
1312
|
+
{
|
|
1313
|
+
className: "slider__aura p-absolute",
|
|
1314
|
+
"data-pulse": auraPulseKey > 0 || void 0
|
|
1315
|
+
},
|
|
1316
|
+
auraPulseKey
|
|
1317
|
+
),
|
|
1318
|
+
/* @__PURE__ */ jsxs("div", { className: "slider__sparkles p-absolute overflow-hidden inset-0", children: [
|
|
1319
|
+
/* @__PURE__ */ jsx("span", {}),
|
|
1320
|
+
/* @__PURE__ */ jsx("span", {}),
|
|
1321
|
+
/* @__PURE__ */ jsx("span", {}),
|
|
1322
|
+
/* @__PURE__ */ jsx("span", {}),
|
|
1323
|
+
/* @__PURE__ */ jsx("span", {}),
|
|
1324
|
+
/* @__PURE__ */ jsx("span", {}),
|
|
1325
|
+
/* @__PURE__ */ jsx("span", {}),
|
|
1326
|
+
/* @__PURE__ */ jsx("span", {})
|
|
1327
|
+
] }),
|
|
1328
|
+
/* @__PURE__ */ jsx("div", { className: "slider__noise p-absolute inset-0" })
|
|
1329
|
+
] })
|
|
1330
|
+
}
|
|
1331
|
+
) });
|
|
1332
|
+
});
|
|
1333
|
+
Slider.displayName = "Slider";
|
|
1334
|
+
var Slider_default = memo(Slider);
|
|
1335
|
+
var LiquidToggle = forwardRef(({
|
|
1336
|
+
className,
|
|
1337
|
+
id,
|
|
1338
|
+
pressed,
|
|
1339
|
+
defaultPressed = false,
|
|
1340
|
+
onChange,
|
|
1341
|
+
bounce = true,
|
|
1342
|
+
disabled = false,
|
|
1343
|
+
"aria-label": ariaLabel = "toggle",
|
|
1344
|
+
"aria-labelledby": ariaLabelledBy,
|
|
1345
|
+
"aria-describedby": ariaDescribedBy,
|
|
1346
|
+
"aria-invalid": ariaInvalid,
|
|
1347
|
+
"aria-errormessage": ariaErrorMessage
|
|
1348
|
+
}, ref) => {
|
|
1349
|
+
const btnRef = useRef(null);
|
|
1350
|
+
const isControlled = typeof pressed === "boolean";
|
|
1351
|
+
const [internalPressed, setInternalPressed] = useState(defaultPressed);
|
|
1352
|
+
const effectivePressed = isControlled ? pressed : internalPressed;
|
|
1353
|
+
const [active, setActive] = useState(false);
|
|
1354
|
+
const [complete, setComplete] = useState(effectivePressed ? 100 : 0);
|
|
1355
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
1356
|
+
const [dragStart, setDragStart] = useState(null);
|
|
1357
|
+
const [dragBounds, setDragBounds] = useState(0);
|
|
1358
|
+
const pressTimeRef = useRef(0);
|
|
1359
|
+
usePrefersReducedMotion();
|
|
1360
|
+
const completeRef = useRef(effectivePressed ? 100 : 0);
|
|
1361
|
+
const commitPressedState = useCallback((nextPressed) => {
|
|
1362
|
+
const targetComplete = nextPressed ? 100 : 0;
|
|
1363
|
+
setActive(false);
|
|
1364
|
+
setComplete(targetComplete);
|
|
1365
|
+
completeRef.current = targetComplete;
|
|
1366
|
+
if (btnRef.current) {
|
|
1367
|
+
btnRef.current.setAttribute("aria-pressed", String(nextPressed));
|
|
1368
|
+
}
|
|
1369
|
+
onChange?.(nextPressed);
|
|
1370
|
+
if (!isControlled) {
|
|
1371
|
+
setInternalPressed(nextPressed);
|
|
1372
|
+
}
|
|
1373
|
+
}, [isControlled, onChange]);
|
|
1374
|
+
useEffect(() => {
|
|
1375
|
+
document.documentElement.dataset.bounce = String(bounce);
|
|
1376
|
+
}, [bounce]);
|
|
1377
|
+
useEffect(() => {
|
|
1378
|
+
if (btnRef.current) {
|
|
1379
|
+
btnRef.current.style.setProperty("--complete", String(complete));
|
|
1380
|
+
completeRef.current = complete;
|
|
1381
|
+
}
|
|
1382
|
+
}, [complete]);
|
|
1383
|
+
useEffect(() => {
|
|
1384
|
+
if (!isControlled) return;
|
|
1385
|
+
const targetComplete = pressed ? 100 : 0;
|
|
1386
|
+
setComplete(targetComplete);
|
|
1387
|
+
if (btnRef.current) {
|
|
1388
|
+
btnRef.current.setAttribute("aria-pressed", String(pressed));
|
|
1389
|
+
}
|
|
1390
|
+
}, [isControlled, pressed]);
|
|
1391
|
+
const toggleTimeline = useCallback(() => {
|
|
1392
|
+
if (!btnRef.current || disabled) return;
|
|
1393
|
+
const el = btnRef.current;
|
|
1394
|
+
const wasPressed = el.getAttribute("aria-pressed") === "true";
|
|
1395
|
+
const nextPressed = !wasPressed;
|
|
1396
|
+
setActive(true);
|
|
1397
|
+
commitPressedState(nextPressed);
|
|
1398
|
+
}, [commitPressedState, disabled]);
|
|
1399
|
+
const handlePointerDown = useCallback((e) => {
|
|
1400
|
+
if (!btnRef.current || disabled) return;
|
|
1401
|
+
pressTimeRef.current = Date.now();
|
|
1402
|
+
const rect = btnRef.current.getBoundingClientRect();
|
|
1403
|
+
const isOn = btnRef.current.getAttribute("aria-pressed") === "true";
|
|
1404
|
+
setDragStart({ x: e.clientX, y: e.clientY });
|
|
1405
|
+
setDragBounds(isOn ? rect.left - e.clientX : rect.left + rect.width - e.clientX);
|
|
1406
|
+
setActive(true);
|
|
1407
|
+
btnRef.current.setPointerCapture(e.pointerId);
|
|
1408
|
+
}, [disabled]);
|
|
1409
|
+
const handlePointerMove = useCallback((e) => {
|
|
1410
|
+
if (disabled) return;
|
|
1411
|
+
if (!dragStart) return;
|
|
1412
|
+
if (!isDragging) {
|
|
1413
|
+
const distance = Math.abs(e.clientX - dragStart.x);
|
|
1414
|
+
if (distance > 4) setIsDragging(true);
|
|
1415
|
+
}
|
|
1416
|
+
if (isDragging && btnRef.current) {
|
|
1417
|
+
const isOn = btnRef.current.getAttribute("aria-pressed") === "true";
|
|
1418
|
+
const dragged = e.clientX - dragStart.x;
|
|
1419
|
+
let rawComplete;
|
|
1420
|
+
if (isOn) {
|
|
1421
|
+
rawComplete = (dragBounds - dragged) / Math.abs(dragBounds) * 100;
|
|
1422
|
+
} else {
|
|
1423
|
+
rawComplete = dragged / Math.abs(dragBounds) * 100;
|
|
1424
|
+
}
|
|
1425
|
+
const clampedComplete = Math.max(0, Math.min(100, rawComplete));
|
|
1426
|
+
setComplete(clampedComplete);
|
|
1427
|
+
completeRef.current = clampedComplete;
|
|
1428
|
+
}
|
|
1429
|
+
}, [disabled, isDragging, dragStart, dragBounds]);
|
|
1430
|
+
const handlePointerUp = useCallback((e) => {
|
|
1431
|
+
if (disabled) return;
|
|
1432
|
+
const releaseTime = Date.now();
|
|
1433
|
+
const pressDuration = releaseTime - pressTimeRef.current;
|
|
1434
|
+
if (isDragging) {
|
|
1435
|
+
const targetComplete = complete >= 50 ? 100 : 0;
|
|
1436
|
+
commitPressedState(targetComplete >= 50);
|
|
1437
|
+
} else if (pressDuration <= 150) {
|
|
1438
|
+
toggleTimeline();
|
|
1439
|
+
} else {
|
|
1440
|
+
setActive(false);
|
|
1441
|
+
}
|
|
1442
|
+
setIsDragging(false);
|
|
1443
|
+
setDragStart(null);
|
|
1444
|
+
if (btnRef.current) {
|
|
1445
|
+
btnRef.current.releasePointerCapture(e.pointerId);
|
|
1446
|
+
}
|
|
1447
|
+
}, [commitPressedState, disabled, isDragging, complete, toggleTimeline]);
|
|
1448
|
+
const onClick = useCallback((e) => {
|
|
1449
|
+
if (isDragging) e.preventDefault();
|
|
1450
|
+
}, [isDragging]);
|
|
1451
|
+
const onKeyDown = useCallback((e) => {
|
|
1452
|
+
if (disabled) return;
|
|
1453
|
+
if (e.key === " ") e.preventDefault();
|
|
1454
|
+
if (e.key === "Enter") toggleTimeline();
|
|
1455
|
+
}, [disabled, toggleTimeline]);
|
|
1456
|
+
const onKeyUp = useCallback((e) => {
|
|
1457
|
+
if (disabled) return;
|
|
1458
|
+
if (e.key === " ") toggleTimeline();
|
|
1459
|
+
}, [disabled, toggleTimeline]);
|
|
1460
|
+
return /* @__PURE__ */ jsx("div", { ref, className: "liquid-toggle-wrapper", children: /* @__PURE__ */ jsxs(
|
|
1461
|
+
"button",
|
|
1462
|
+
{
|
|
1463
|
+
ref: btnRef,
|
|
1464
|
+
id,
|
|
1465
|
+
"aria-label": ariaLabel,
|
|
1466
|
+
"aria-labelledby": ariaLabelledBy,
|
|
1467
|
+
"aria-describedby": ariaDescribedBy,
|
|
1468
|
+
"aria-invalid": ariaInvalid,
|
|
1469
|
+
"aria-errormessage": ariaErrorMessage,
|
|
1470
|
+
"aria-pressed": effectivePressed,
|
|
1471
|
+
className: `liquid-toggle${className ? ` ${className}` : ""}`,
|
|
1472
|
+
"data-active": String(active),
|
|
1473
|
+
type: "button",
|
|
1474
|
+
disabled,
|
|
1475
|
+
onKeyDown,
|
|
1476
|
+
onKeyUp,
|
|
1477
|
+
onClick,
|
|
1478
|
+
onPointerDown: handlePointerDown,
|
|
1479
|
+
onPointerMove: handlePointerMove,
|
|
1480
|
+
onPointerUp: handlePointerUp,
|
|
1481
|
+
style: { touchAction: "none" },
|
|
1482
|
+
children: [
|
|
1483
|
+
/* @__PURE__ */ jsx("div", { className: "knockout", children: /* @__PURE__ */ jsx("div", { className: "indicator indicator--masked", children: /* @__PURE__ */ jsx("div", { className: "mask" }) }) }),
|
|
1484
|
+
/* @__PURE__ */ jsxs("div", { className: "indicator__liquid", children: [
|
|
1485
|
+
/* @__PURE__ */ jsx("div", { className: "shadow" }),
|
|
1486
|
+
/* @__PURE__ */ jsx("div", { className: "wrapper", children: /* @__PURE__ */ jsxs("div", { className: "liquids", children: [
|
|
1487
|
+
/* @__PURE__ */ jsx("div", { className: "liquid__shadow" }),
|
|
1488
|
+
/* @__PURE__ */ jsx("div", { className: "liquid__track" })
|
|
1489
|
+
] }) }),
|
|
1490
|
+
/* @__PURE__ */ jsx("div", { className: "cover" })
|
|
1491
|
+
] })
|
|
1492
|
+
]
|
|
1493
|
+
}
|
|
1494
|
+
) });
|
|
1495
|
+
});
|
|
1496
|
+
LiquidToggle.displayName = "LiquidToggle";
|
|
1497
|
+
var LiquidToggle_default = LiquidToggle;
|
|
1498
|
+
var variants = {
|
|
1499
|
+
enter: (direction) => ({
|
|
1500
|
+
x: direction === "forward" ? 20 : -20,
|
|
1501
|
+
opacity: 0
|
|
1502
|
+
}),
|
|
1503
|
+
center: {
|
|
1504
|
+
x: 0,
|
|
1505
|
+
opacity: 1
|
|
1506
|
+
},
|
|
1507
|
+
exit: (direction) => ({
|
|
1508
|
+
x: direction === "forward" ? -20 : 20,
|
|
1509
|
+
opacity: 0
|
|
1510
|
+
})
|
|
1511
|
+
};
|
|
1512
|
+
var reducedMotionVariants = {
|
|
1513
|
+
enter: {
|
|
1514
|
+
x: 0,
|
|
1515
|
+
opacity: 0
|
|
1516
|
+
},
|
|
1517
|
+
center: {
|
|
1518
|
+
x: 0,
|
|
1519
|
+
opacity: 1
|
|
1520
|
+
},
|
|
1521
|
+
exit: {
|
|
1522
|
+
x: 0,
|
|
1523
|
+
opacity: 0
|
|
1524
|
+
}
|
|
1525
|
+
};
|
|
1526
|
+
var Stepper = forwardRef(function Stepper2({
|
|
1527
|
+
steps,
|
|
1528
|
+
activeStep,
|
|
1529
|
+
className = "",
|
|
1530
|
+
indicators,
|
|
1531
|
+
onStepClick,
|
|
1532
|
+
canNavigateTo
|
|
1533
|
+
}, ref) {
|
|
1534
|
+
const [prevStep, setPrevStep] = useState(activeStep);
|
|
1535
|
+
const prefersReducedMotion = usePrefersReducedMotion();
|
|
1536
|
+
const stepperId = useId();
|
|
1537
|
+
const stepIndicators = indicators ?? [];
|
|
1538
|
+
const stepVariants = prefersReducedMotion ? reducedMotionVariants : variants;
|
|
1539
|
+
const currentIndex = steps.findIndex((step) => step.key === activeStep);
|
|
1540
|
+
const prevIndex = steps.findIndex((step) => step.key === prevStep);
|
|
1541
|
+
const direction = currentIndex >= prevIndex ? "forward" : "backward";
|
|
1542
|
+
useEffect(() => {
|
|
1543
|
+
if (activeStep !== prevStep) {
|
|
1544
|
+
setPrevStep(activeStep);
|
|
1545
|
+
}
|
|
1546
|
+
}, [activeStep, prevStep]);
|
|
1547
|
+
const currentStep = steps.find((state) => state.key === activeStep);
|
|
1548
|
+
const activePanelId = `${stepperId}-${activeStep}-panel`;
|
|
1549
|
+
const handleIndicatorClick = (key) => {
|
|
1550
|
+
if (!onStepClick) return;
|
|
1551
|
+
if (canNavigateTo && !canNavigateTo(key)) return;
|
|
1552
|
+
onStepClick(key);
|
|
1553
|
+
};
|
|
1554
|
+
const getNavigableIndex = (startIndex, increment) => {
|
|
1555
|
+
let nextIndex = startIndex;
|
|
1556
|
+
while (nextIndex >= 0 && nextIndex < stepIndicators.length) {
|
|
1557
|
+
const nextIndicator = stepIndicators[nextIndex];
|
|
1558
|
+
if (!nextIndicator) {
|
|
1559
|
+
return null;
|
|
1560
|
+
}
|
|
1561
|
+
if (!canNavigateTo || canNavigateTo(nextIndicator.key)) {
|
|
1562
|
+
return nextIndex;
|
|
1563
|
+
}
|
|
1564
|
+
nextIndex += increment;
|
|
1565
|
+
}
|
|
1566
|
+
return null;
|
|
1567
|
+
};
|
|
1568
|
+
const handleIndicatorKeyDown = (event, index) => {
|
|
1569
|
+
if (!indicators || !onStepClick) {
|
|
1570
|
+
return;
|
|
1571
|
+
}
|
|
1572
|
+
if (event.key === "ArrowDown" || event.key === "ArrowRight") {
|
|
1573
|
+
event.preventDefault();
|
|
1574
|
+
const nextIndex = getNavigableIndex(index + 1, 1);
|
|
1575
|
+
if (nextIndex !== null) {
|
|
1576
|
+
handleIndicatorClick(stepIndicators[nextIndex].key);
|
|
1577
|
+
}
|
|
1578
|
+
return;
|
|
1579
|
+
}
|
|
1580
|
+
if (event.key === "ArrowUp" || event.key === "ArrowLeft") {
|
|
1581
|
+
event.preventDefault();
|
|
1582
|
+
const nextIndex = getNavigableIndex(index - 1, -1);
|
|
1583
|
+
if (nextIndex !== null) {
|
|
1584
|
+
handleIndicatorClick(stepIndicators[nextIndex].key);
|
|
1585
|
+
}
|
|
1586
|
+
return;
|
|
1587
|
+
}
|
|
1588
|
+
if (event.key === "Home") {
|
|
1589
|
+
event.preventDefault();
|
|
1590
|
+
const nextIndex = getNavigableIndex(0, 1);
|
|
1591
|
+
if (nextIndex !== null) {
|
|
1592
|
+
handleIndicatorClick(stepIndicators[nextIndex].key);
|
|
1593
|
+
}
|
|
1594
|
+
return;
|
|
1595
|
+
}
|
|
1596
|
+
if (event.key === "End") {
|
|
1597
|
+
event.preventDefault();
|
|
1598
|
+
const nextIndex = getNavigableIndex(stepIndicators.length - 1, -1);
|
|
1599
|
+
if (nextIndex !== null) {
|
|
1600
|
+
handleIndicatorClick(stepIndicators[nextIndex].key);
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1603
|
+
};
|
|
1604
|
+
const renderStepContent = () => /* @__PURE__ */ jsx(
|
|
1605
|
+
AnimatePresence,
|
|
1606
|
+
{
|
|
1607
|
+
mode: "wait",
|
|
1608
|
+
custom: direction,
|
|
1609
|
+
initial: false,
|
|
1610
|
+
children: /* @__PURE__ */ jsx(
|
|
1611
|
+
motion.div,
|
|
1612
|
+
{
|
|
1613
|
+
custom: direction,
|
|
1614
|
+
variants: stepVariants,
|
|
1615
|
+
initial: "enter",
|
|
1616
|
+
animate: "center",
|
|
1617
|
+
exit: "exit",
|
|
1618
|
+
transition: { duration: prefersReducedMotion ? 0 : 0.25 },
|
|
1619
|
+
className: `stepper-step ${className}`,
|
|
1620
|
+
id: activePanelId,
|
|
1621
|
+
role: indicators ? "tabpanel" : void 0,
|
|
1622
|
+
"aria-labelledby": indicators ? `${stepperId}-${activeStep}-tab` : void 0,
|
|
1623
|
+
tabIndex: 0,
|
|
1624
|
+
children: currentStep?.content
|
|
1625
|
+
},
|
|
1626
|
+
activeStep
|
|
1627
|
+
)
|
|
1628
|
+
}
|
|
1629
|
+
);
|
|
1630
|
+
if (!indicators) {
|
|
1631
|
+
return /* @__PURE__ */ jsx("div", { ref, className: "stepper-standalone", children: renderStepContent() });
|
|
1632
|
+
}
|
|
1633
|
+
return /* @__PURE__ */ jsxs("div", { ref, className: "stepper-with-sidebar d-flex overflow-hidden flex-1", children: [
|
|
1634
|
+
/* @__PURE__ */ jsx("div", { className: "stepper-sidebar d-flex column gap-05", role: "tablist", "aria-orientation": "vertical", children: stepIndicators.map((indicator, index) => {
|
|
1635
|
+
const indicatorIndex = steps.findIndex((s) => s.key === indicator.key);
|
|
1636
|
+
const isActive = indicator.key === activeStep;
|
|
1637
|
+
const isComplete = indicatorIndex < currentIndex;
|
|
1638
|
+
const isClickable = !canNavigateTo || canNavigateTo(indicator.key);
|
|
1639
|
+
const tabId2 = `${stepperId}-${indicator.key}-tab`;
|
|
1640
|
+
const panelId2 = `${stepperId}-${indicator.key}-panel`;
|
|
1641
|
+
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
1642
|
+
/* @__PURE__ */ jsxs(
|
|
1643
|
+
"button",
|
|
1644
|
+
{
|
|
1645
|
+
id: tabId2,
|
|
1646
|
+
type: "button",
|
|
1647
|
+
role: "tab",
|
|
1648
|
+
"aria-selected": isActive,
|
|
1649
|
+
"aria-controls": panelId2,
|
|
1650
|
+
tabIndex: isActive ? 0 : -1,
|
|
1651
|
+
className: `stepper-indicator d-flex items-center gap-1 ${isActive ? "active" : ""} ${isComplete ? "complete" : ""} ${isClickable && onStepClick ? "cursor-pointer" : ""}`,
|
|
1652
|
+
disabled: !isClickable || !onStepClick,
|
|
1653
|
+
onClick: () => handleIndicatorClick(indicator.key),
|
|
1654
|
+
onKeyDown: (event) => handleIndicatorKeyDown(event, index),
|
|
1655
|
+
children: [
|
|
1656
|
+
/* @__PURE__ */ jsx("div", { className: "stepper-indicator-number d-flex flex-center font-weight-6", children: index + 1 }),
|
|
1657
|
+
/* @__PURE__ */ jsxs("div", { className: "stepper-indicator-label d-flex column gap-025", children: [
|
|
1658
|
+
/* @__PURE__ */ jsx("span", { className: "stepper-indicator-title", children: indicator.label }),
|
|
1659
|
+
indicator.description && /* @__PURE__ */ jsx("small", { className: "stepper-indicator-desc", children: indicator.description })
|
|
1660
|
+
] })
|
|
1661
|
+
]
|
|
1662
|
+
}
|
|
1663
|
+
),
|
|
1664
|
+
index < stepIndicators.length - 1 && /* @__PURE__ */ jsx("div", { className: `stepper-line ${indicatorIndex < currentIndex ? "active" : ""}` })
|
|
1665
|
+
] }, indicator.key);
|
|
1666
|
+
}) }),
|
|
1667
|
+
/* @__PURE__ */ jsx("div", { className: "stepper-content y-auto flex-1", children: renderStepContent() })
|
|
1668
|
+
] });
|
|
1669
|
+
});
|
|
1670
|
+
Stepper.displayName = "Stepper";
|
|
1671
|
+
var Stepper_default = Stepper;
|
|
1672
|
+
var MISSING_TEXT_INPUT_NAME_ERROR = "TextInput requires an accessible name via aria-label, aria-labelledby, or an external label bound to its id.";
|
|
1673
|
+
var TextInput = forwardRef(({
|
|
1674
|
+
size: size2 = "md",
|
|
1675
|
+
hasError = false,
|
|
1676
|
+
leftIcon,
|
|
1677
|
+
rightIcon,
|
|
1678
|
+
fullWidth = false,
|
|
1679
|
+
containerClassName,
|
|
1680
|
+
className,
|
|
1681
|
+
disabled,
|
|
1682
|
+
type = "text",
|
|
1683
|
+
id,
|
|
1684
|
+
title,
|
|
1685
|
+
onFocus,
|
|
1686
|
+
onBlur,
|
|
1687
|
+
"aria-label": ariaLabel,
|
|
1688
|
+
"aria-labelledby": ariaLabelledBy,
|
|
1689
|
+
"aria-invalid": ariaInvalid,
|
|
1690
|
+
...props
|
|
1691
|
+
}, ref) => {
|
|
1692
|
+
const hasWarnedForMissingNameRef = useRef(false);
|
|
1693
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
1694
|
+
const resolvedAriaLabel = ariaLabel?.trim() || void 0;
|
|
1695
|
+
const resolvedAriaLabelledBy = ariaLabelledBy?.trim() || void 0;
|
|
1696
|
+
const resolvedTitle = title?.trim() || void 0;
|
|
1697
|
+
const hasExternalLabelContract = Boolean(id);
|
|
1698
|
+
const accessibleName = resolvedAriaLabel ?? resolvedTitle;
|
|
1699
|
+
if (!resolvedAriaLabelledBy && !accessibleName && !hasExternalLabelContract) {
|
|
1700
|
+
if (!hasWarnedForMissingNameRef.current) {
|
|
1701
|
+
console.warn(MISSING_TEXT_INPUT_NAME_ERROR);
|
|
1702
|
+
hasWarnedForMissingNameRef.current = true;
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
const handleFocus = (event) => {
|
|
1706
|
+
setIsFocused(true);
|
|
1707
|
+
onFocus?.(event);
|
|
1708
|
+
};
|
|
1709
|
+
const handleBlur = (event) => {
|
|
1710
|
+
setIsFocused(false);
|
|
1711
|
+
onBlur?.(event);
|
|
1712
|
+
};
|
|
1713
|
+
const containerClasses = cn(
|
|
1714
|
+
"volt-text-input",
|
|
1715
|
+
`volt-text-input--${size2}`,
|
|
1716
|
+
fullWidth && "volt-text-input--full-width",
|
|
1717
|
+
hasError && "volt-text-input--error",
|
|
1718
|
+
isFocused && "volt-text-input--focused",
|
|
1719
|
+
disabled && "volt-text-input--disabled",
|
|
1720
|
+
containerClassName
|
|
1721
|
+
);
|
|
1722
|
+
return /* @__PURE__ */ jsxs("div", { className: containerClasses, children: [
|
|
1723
|
+
leftIcon && /* @__PURE__ */ jsx("span", { className: "volt-text-input__affix volt-text-input__affix--left", "aria-hidden": "true", children: leftIcon }),
|
|
1724
|
+
/* @__PURE__ */ jsx(
|
|
1725
|
+
"input",
|
|
1726
|
+
{
|
|
1727
|
+
ref,
|
|
1728
|
+
id,
|
|
1729
|
+
type,
|
|
1730
|
+
disabled,
|
|
1731
|
+
title: resolvedTitle,
|
|
1732
|
+
"aria-label": accessibleName,
|
|
1733
|
+
"aria-labelledby": resolvedAriaLabelledBy,
|
|
1734
|
+
"aria-invalid": ariaInvalid ?? (hasError || void 0),
|
|
1735
|
+
onFocus: handleFocus,
|
|
1736
|
+
onBlur: handleBlur,
|
|
1737
|
+
className: cn("volt-text-input__field", className),
|
|
1738
|
+
...props
|
|
1739
|
+
}
|
|
1740
|
+
),
|
|
1741
|
+
rightIcon && /* @__PURE__ */ jsx("span", { className: "volt-text-input__affix volt-text-input__affix--right", "aria-hidden": "true", children: rightIcon })
|
|
1742
|
+
] });
|
|
1743
|
+
});
|
|
1744
|
+
TextInput.displayName = "TextInput";
|
|
1745
|
+
var TextInput_default = TextInput;
|
|
1746
|
+
var MISSING_TEXTAREA_NAME_ERROR = "Textarea requires an accessible name via aria-label, aria-labelledby, or an external label bound to its id.";
|
|
1747
|
+
var Textarea = forwardRef(({
|
|
1748
|
+
size: size2 = "md",
|
|
1749
|
+
hasError = false,
|
|
1750
|
+
autosize = false,
|
|
1751
|
+
minRows = 2,
|
|
1752
|
+
maxRows = 8,
|
|
1753
|
+
className,
|
|
1754
|
+
disabled,
|
|
1755
|
+
id,
|
|
1756
|
+
title,
|
|
1757
|
+
value,
|
|
1758
|
+
onChange,
|
|
1759
|
+
"aria-label": ariaLabel,
|
|
1760
|
+
"aria-labelledby": ariaLabelledBy,
|
|
1761
|
+
"aria-invalid": ariaInvalid,
|
|
1762
|
+
...props
|
|
1763
|
+
}, ref) => {
|
|
1764
|
+
const hasWarnedForMissingNameRef = useRef(false);
|
|
1765
|
+
const innerRef = useRef(null);
|
|
1766
|
+
useImperativeHandle(ref, () => innerRef.current, []);
|
|
1767
|
+
const resolvedAriaLabel = ariaLabel?.trim() || void 0;
|
|
1768
|
+
const resolvedAriaLabelledBy = ariaLabelledBy?.trim() || void 0;
|
|
1769
|
+
const resolvedTitle = title?.trim() || void 0;
|
|
1770
|
+
const hasExternalLabelContract = Boolean(id);
|
|
1771
|
+
const accessibleName = resolvedAriaLabel ?? resolvedTitle;
|
|
1772
|
+
if (!resolvedAriaLabelledBy && !accessibleName && !hasExternalLabelContract) {
|
|
1773
|
+
if (!hasWarnedForMissingNameRef.current) {
|
|
1774
|
+
console.warn(MISSING_TEXTAREA_NAME_ERROR);
|
|
1775
|
+
hasWarnedForMissingNameRef.current = true;
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
const resize = useCallback(() => {
|
|
1779
|
+
const node = innerRef.current;
|
|
1780
|
+
if (!node || !autosize) return;
|
|
1781
|
+
const computed = window.getComputedStyle(node);
|
|
1782
|
+
const lineHeight = parseFloat(computed.lineHeight) || 20;
|
|
1783
|
+
const paddingY = parseFloat(computed.paddingTop) + parseFloat(computed.paddingBottom);
|
|
1784
|
+
const borderY = parseFloat(computed.borderTopWidth) + parseFloat(computed.borderBottomWidth);
|
|
1785
|
+
const verticalChrome = paddingY + borderY;
|
|
1786
|
+
node.style.height = "auto";
|
|
1787
|
+
const minHeight = minRows * lineHeight + verticalChrome;
|
|
1788
|
+
const maxHeight = maxRows * lineHeight + verticalChrome;
|
|
1789
|
+
const next = Math.min(Math.max(node.scrollHeight, minHeight), maxHeight);
|
|
1790
|
+
node.style.height = `${next}px`;
|
|
1791
|
+
}, [autosize, minRows, maxRows]);
|
|
1792
|
+
useLayoutEffect(() => {
|
|
1793
|
+
resize();
|
|
1794
|
+
}, [resize, value]);
|
|
1795
|
+
useEffect(() => {
|
|
1796
|
+
if (!autosize) return;
|
|
1797
|
+
window.addEventListener("resize", resize);
|
|
1798
|
+
return () => window.removeEventListener("resize", resize);
|
|
1799
|
+
}, [autosize, resize]);
|
|
1800
|
+
const handleChange = (event) => {
|
|
1801
|
+
onChange?.(event);
|
|
1802
|
+
if (autosize) resize();
|
|
1803
|
+
};
|
|
1804
|
+
const classes = cn(
|
|
1805
|
+
"volt-textarea",
|
|
1806
|
+
`volt-textarea--${size2}`,
|
|
1807
|
+
autosize && "volt-textarea--autosize",
|
|
1808
|
+
hasError && "volt-textarea--error",
|
|
1809
|
+
className
|
|
1810
|
+
);
|
|
1811
|
+
return /* @__PURE__ */ jsx(
|
|
1812
|
+
"textarea",
|
|
1813
|
+
{
|
|
1814
|
+
ref: innerRef,
|
|
1815
|
+
id,
|
|
1816
|
+
rows: minRows,
|
|
1817
|
+
disabled,
|
|
1818
|
+
title: resolvedTitle,
|
|
1819
|
+
"aria-label": accessibleName,
|
|
1820
|
+
"aria-labelledby": resolvedAriaLabelledBy,
|
|
1821
|
+
"aria-invalid": ariaInvalid ?? (hasError || void 0),
|
|
1822
|
+
value,
|
|
1823
|
+
onChange: handleChange,
|
|
1824
|
+
className: classes,
|
|
1825
|
+
...props
|
|
1826
|
+
}
|
|
1827
|
+
);
|
|
1828
|
+
});
|
|
1829
|
+
Textarea.displayName = "Textarea";
|
|
1830
|
+
var Textarea_default = Textarea;
|
|
1831
|
+
var clamp2 = (value, min, max) => {
|
|
1832
|
+
let next = value;
|
|
1833
|
+
if (typeof min === "number") next = Math.max(next, min);
|
|
1834
|
+
if (typeof max === "number") next = Math.min(next, max);
|
|
1835
|
+
return next;
|
|
1836
|
+
};
|
|
1837
|
+
var NumberInput = forwardRef(({
|
|
1838
|
+
min,
|
|
1839
|
+
max,
|
|
1840
|
+
step = 1,
|
|
1841
|
+
value,
|
|
1842
|
+
defaultValue,
|
|
1843
|
+
onChange,
|
|
1844
|
+
onValueChange,
|
|
1845
|
+
showSteppers = true,
|
|
1846
|
+
disabled,
|
|
1847
|
+
containerClassName,
|
|
1848
|
+
rightIcon,
|
|
1849
|
+
...props
|
|
1850
|
+
}, ref) => {
|
|
1851
|
+
const innerRef = useRef(null);
|
|
1852
|
+
const setRefs = useCallback((node) => {
|
|
1853
|
+
innerRef.current = node;
|
|
1854
|
+
if (typeof ref === "function") ref(node);
|
|
1855
|
+
else if (ref) ref.current = node;
|
|
1856
|
+
}, [ref]);
|
|
1857
|
+
const emitValue = useCallback((next) => {
|
|
1858
|
+
onValueChange?.(next);
|
|
1859
|
+
}, [onValueChange]);
|
|
1860
|
+
const handleChange = (event) => {
|
|
1861
|
+
onChange?.(event);
|
|
1862
|
+
const raw = event.target.value;
|
|
1863
|
+
emitValue(raw === "" ? Number.NaN : Number(raw));
|
|
1864
|
+
};
|
|
1865
|
+
const stepBy = useCallback((direction) => {
|
|
1866
|
+
if (disabled) return;
|
|
1867
|
+
const current = (() => {
|
|
1868
|
+
if (typeof value === "number") return value;
|
|
1869
|
+
const parsed = Number(innerRef.current?.value);
|
|
1870
|
+
return Number.isFinite(parsed) ? parsed : min ?? 0;
|
|
1871
|
+
})();
|
|
1872
|
+
const next = clamp2(current + direction * step, min, max);
|
|
1873
|
+
emitValue(next);
|
|
1874
|
+
if (value === void 0 && innerRef.current) {
|
|
1875
|
+
innerRef.current.value = String(next);
|
|
1876
|
+
}
|
|
1877
|
+
}, [disabled, value, min, max, step, emitValue]);
|
|
1878
|
+
const steppers = showSteppers ? /* @__PURE__ */ jsxs("span", { className: "volt-number-input__steppers", "aria-hidden": "true", children: [
|
|
1879
|
+
/* @__PURE__ */ jsx(
|
|
1880
|
+
IconButton_default,
|
|
1881
|
+
{
|
|
1882
|
+
tabIndex: -1,
|
|
1883
|
+
"aria-label": "Increment value",
|
|
1884
|
+
className: "volt-number-input__stepper",
|
|
1885
|
+
disabled: disabled || typeof max === "number" && typeof value === "number" && value >= max,
|
|
1886
|
+
onClick: () => stepBy(1),
|
|
1887
|
+
children: /* @__PURE__ */ jsx(ChevronUp, {})
|
|
1888
|
+
}
|
|
1889
|
+
),
|
|
1890
|
+
/* @__PURE__ */ jsx(
|
|
1891
|
+
IconButton_default,
|
|
1892
|
+
{
|
|
1893
|
+
tabIndex: -1,
|
|
1894
|
+
"aria-label": "Decrement value",
|
|
1895
|
+
className: "volt-number-input__stepper",
|
|
1896
|
+
disabled: disabled || typeof min === "number" && typeof value === "number" && value <= min,
|
|
1897
|
+
onClick: () => stepBy(-1),
|
|
1898
|
+
children: /* @__PURE__ */ jsx(ChevronDown, {})
|
|
1899
|
+
}
|
|
1900
|
+
)
|
|
1901
|
+
] }) : null;
|
|
1902
|
+
return /* @__PURE__ */ jsx(
|
|
1903
|
+
TextInput_default,
|
|
1904
|
+
{
|
|
1905
|
+
ref: setRefs,
|
|
1906
|
+
type: "number",
|
|
1907
|
+
inputMode: "decimal",
|
|
1908
|
+
min,
|
|
1909
|
+
max,
|
|
1910
|
+
step,
|
|
1911
|
+
value,
|
|
1912
|
+
defaultValue,
|
|
1913
|
+
disabled,
|
|
1914
|
+
onChange: handleChange,
|
|
1915
|
+
containerClassName: cn("volt-number-input", containerClassName),
|
|
1916
|
+
rightIcon: steppers ?? rightIcon,
|
|
1917
|
+
...props
|
|
1918
|
+
}
|
|
1919
|
+
);
|
|
1920
|
+
});
|
|
1921
|
+
NumberInput.displayName = "NumberInput";
|
|
1922
|
+
var NumberInput_default = NumberInput;
|
|
1923
|
+
var FormField = forwardRef(({
|
|
1924
|
+
label,
|
|
1925
|
+
htmlFor,
|
|
1926
|
+
required = false,
|
|
1927
|
+
error,
|
|
1928
|
+
helpText,
|
|
1929
|
+
layout = "stacked",
|
|
1930
|
+
children,
|
|
1931
|
+
className,
|
|
1932
|
+
id,
|
|
1933
|
+
...rest
|
|
1934
|
+
}, ref) => {
|
|
1935
|
+
const reactId = useId();
|
|
1936
|
+
const baseId = id ?? `volt-form-field-${reactId}`;
|
|
1937
|
+
const messageId = `${baseId}-message`;
|
|
1938
|
+
const hasLabel = label != null && label !== "";
|
|
1939
|
+
const hasError = error != null && error !== "";
|
|
1940
|
+
const hasHelp = !hasError && helpText != null && helpText !== "";
|
|
1941
|
+
const message = hasError ? error : helpText;
|
|
1942
|
+
const hasMessage = hasError || hasHelp;
|
|
1943
|
+
const labelText = /* @__PURE__ */ jsxs(Text_default, { as: "span", size: "sm", weight: "medium", tone: "secondary", children: [
|
|
1944
|
+
label,
|
|
1945
|
+
required && /* @__PURE__ */ jsx("span", { className: "volt-form-field__required", "aria-hidden": "true", children: "*" })
|
|
1946
|
+
] });
|
|
1947
|
+
const labelNode = hasLabel ? htmlFor ? /* @__PURE__ */ jsx("label", { htmlFor, className: "volt-form-field__label", children: labelText }) : /* @__PURE__ */ jsx("div", { className: "volt-form-field__label", children: labelText }) : null;
|
|
1948
|
+
const messageNode = hasMessage ? /* @__PURE__ */ jsx(
|
|
1949
|
+
Text_default,
|
|
1950
|
+
{
|
|
1951
|
+
id: messageId,
|
|
1952
|
+
as: "small",
|
|
1953
|
+
size: "xs",
|
|
1954
|
+
tone: hasError ? void 0 : "muted",
|
|
1955
|
+
className: cn("volt-form-field__message", hasError && "volt-form-field__message--error"),
|
|
1956
|
+
role: hasError ? "alert" : void 0,
|
|
1957
|
+
children: message
|
|
1958
|
+
}
|
|
1959
|
+
) : null;
|
|
1960
|
+
if (layout === "inline") {
|
|
1961
|
+
return /* @__PURE__ */ jsxs(
|
|
1962
|
+
"div",
|
|
1963
|
+
{
|
|
1964
|
+
ref,
|
|
1965
|
+
id: baseId,
|
|
1966
|
+
className: cn(
|
|
1967
|
+
"volt-form-field volt-form-field--inline",
|
|
1968
|
+
!hasLabel && "volt-form-field--no-label",
|
|
1969
|
+
className
|
|
1970
|
+
),
|
|
1971
|
+
...rest,
|
|
1972
|
+
children: [
|
|
1973
|
+
labelNode,
|
|
1974
|
+
/* @__PURE__ */ jsxs("div", { className: "volt-form-field__body", children: [
|
|
1975
|
+
/* @__PURE__ */ jsx("div", { className: "volt-form-field__control", children }),
|
|
1976
|
+
messageNode
|
|
1977
|
+
] })
|
|
1978
|
+
]
|
|
1979
|
+
}
|
|
1980
|
+
);
|
|
1981
|
+
}
|
|
1982
|
+
return /* @__PURE__ */ jsxs(
|
|
1983
|
+
Stack_default,
|
|
1984
|
+
{
|
|
1985
|
+
ref,
|
|
1986
|
+
id: baseId,
|
|
1987
|
+
className: cn("volt-form-field", className),
|
|
1988
|
+
...rest,
|
|
1989
|
+
children: [
|
|
1990
|
+
labelNode,
|
|
1991
|
+
/* @__PURE__ */ jsx("div", { className: "volt-form-field__control", children }),
|
|
1992
|
+
messageNode
|
|
1993
|
+
]
|
|
1994
|
+
}
|
|
1995
|
+
);
|
|
1996
|
+
});
|
|
1997
|
+
FormField.displayName = "FormField";
|
|
1998
|
+
var FormField_default = FormField;
|
|
1999
|
+
var MISSING_CHECKBOX_NAME_ERROR = "Checkbox requires an accessible name via the `label` prop, `aria-label`, `aria-labelledby`, or an external label bound to its id.";
|
|
2000
|
+
var Checkbox = forwardRef(({
|
|
2001
|
+
checked,
|
|
2002
|
+
onChange,
|
|
2003
|
+
label,
|
|
2004
|
+
indeterminate = false,
|
|
2005
|
+
disabled = false,
|
|
2006
|
+
size: size2 = "md",
|
|
2007
|
+
className,
|
|
2008
|
+
containerClassName,
|
|
2009
|
+
id,
|
|
2010
|
+
title,
|
|
2011
|
+
"aria-label": ariaLabel,
|
|
2012
|
+
"aria-labelledby": ariaLabelledBy,
|
|
2013
|
+
...props
|
|
2014
|
+
}, ref) => {
|
|
2015
|
+
const innerRef = useRef(null);
|
|
2016
|
+
const hasWarnedForMissingNameRef = useRef(false);
|
|
2017
|
+
const reactId = useId();
|
|
2018
|
+
const inputId = id ?? `volt-checkbox-${reactId}`;
|
|
2019
|
+
useEffect(() => {
|
|
2020
|
+
if (innerRef.current) {
|
|
2021
|
+
innerRef.current.indeterminate = indeterminate;
|
|
2022
|
+
}
|
|
2023
|
+
}, [indeterminate]);
|
|
2024
|
+
const setRefs = (node) => {
|
|
2025
|
+
innerRef.current = node;
|
|
2026
|
+
if (typeof ref === "function") ref(node);
|
|
2027
|
+
else if (ref) ref.current = node;
|
|
2028
|
+
};
|
|
2029
|
+
const hasVisibleLabel = label != null && label !== "";
|
|
2030
|
+
const resolvedAriaLabel = ariaLabel?.trim() || void 0;
|
|
2031
|
+
const resolvedAriaLabelledBy = ariaLabelledBy?.trim() || void 0;
|
|
2032
|
+
const resolvedTitle = title?.trim() || void 0;
|
|
2033
|
+
if (!hasVisibleLabel && !resolvedAriaLabel && !resolvedAriaLabelledBy && !resolvedTitle) {
|
|
2034
|
+
if (!hasWarnedForMissingNameRef.current) {
|
|
2035
|
+
console.warn(MISSING_CHECKBOX_NAME_ERROR);
|
|
2036
|
+
hasWarnedForMissingNameRef.current = true;
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
return /* @__PURE__ */ jsxs(
|
|
2040
|
+
"label",
|
|
2041
|
+
{
|
|
2042
|
+
htmlFor: inputId,
|
|
2043
|
+
className: cn(
|
|
2044
|
+
"volt-checkbox",
|
|
2045
|
+
`volt-checkbox--${size2}`,
|
|
2046
|
+
checked && "volt-checkbox--checked",
|
|
2047
|
+
indeterminate && "volt-checkbox--indeterminate",
|
|
2048
|
+
disabled && "volt-checkbox--disabled",
|
|
2049
|
+
containerClassName
|
|
2050
|
+
),
|
|
2051
|
+
title: resolvedTitle,
|
|
2052
|
+
children: [
|
|
2053
|
+
/* @__PURE__ */ jsx(
|
|
2054
|
+
"input",
|
|
2055
|
+
{
|
|
2056
|
+
ref: setRefs,
|
|
2057
|
+
id: inputId,
|
|
2058
|
+
type: "checkbox",
|
|
2059
|
+
className: cn("volt-checkbox__input", className),
|
|
2060
|
+
checked,
|
|
2061
|
+
onChange,
|
|
2062
|
+
disabled,
|
|
2063
|
+
"aria-checked": indeterminate ? "mixed" : void 0,
|
|
2064
|
+
"aria-label": !hasVisibleLabel ? resolvedAriaLabel : void 0,
|
|
2065
|
+
"aria-labelledby": resolvedAriaLabelledBy,
|
|
2066
|
+
...props
|
|
2067
|
+
}
|
|
2068
|
+
),
|
|
2069
|
+
/* @__PURE__ */ jsx("span", { className: "volt-checkbox__box", "aria-hidden": "true", children: indeterminate ? /* @__PURE__ */ jsx(Minus, { className: "volt-checkbox__indicator", strokeWidth: 3 }) : /* @__PURE__ */ jsx(Check, { className: "volt-checkbox__indicator", strokeWidth: 3 }) }),
|
|
2070
|
+
hasVisibleLabel && /* @__PURE__ */ jsx(Text_default, { as: "span", size: "sm", tone: "primary", className: "volt-checkbox__label", children: label })
|
|
2071
|
+
]
|
|
2072
|
+
}
|
|
2073
|
+
);
|
|
2074
|
+
});
|
|
2075
|
+
Checkbox.displayName = "Checkbox";
|
|
2076
|
+
var Checkbox_default = Checkbox;
|
|
2077
|
+
var MISSING_RADIO_NAME_ERROR = "Radio requires an accessible name via the `label` prop, `aria-label`, `aria-labelledby`, or an external label bound to its id.";
|
|
2078
|
+
var Radio = forwardRef(({
|
|
2079
|
+
checked,
|
|
2080
|
+
onChange,
|
|
2081
|
+
label,
|
|
2082
|
+
name,
|
|
2083
|
+
value,
|
|
2084
|
+
disabled = false,
|
|
2085
|
+
size: size2 = "md",
|
|
2086
|
+
className,
|
|
2087
|
+
containerClassName,
|
|
2088
|
+
id,
|
|
2089
|
+
title,
|
|
2090
|
+
"aria-label": ariaLabel,
|
|
2091
|
+
"aria-labelledby": ariaLabelledBy,
|
|
2092
|
+
...props
|
|
2093
|
+
}, ref) => {
|
|
2094
|
+
const hasWarnedForMissingNameRef = useRef(false);
|
|
2095
|
+
const reactId = useId();
|
|
2096
|
+
const inputId = id ?? `volt-radio-${reactId}`;
|
|
2097
|
+
const hasVisibleLabel = label != null && label !== "";
|
|
2098
|
+
const resolvedAriaLabel = ariaLabel?.trim() || void 0;
|
|
2099
|
+
const resolvedAriaLabelledBy = ariaLabelledBy?.trim() || void 0;
|
|
2100
|
+
const resolvedTitle = title?.trim() || void 0;
|
|
2101
|
+
if (!hasVisibleLabel && !resolvedAriaLabel && !resolvedAriaLabelledBy && !resolvedTitle) {
|
|
2102
|
+
if (!hasWarnedForMissingNameRef.current) {
|
|
2103
|
+
console.warn(MISSING_RADIO_NAME_ERROR);
|
|
2104
|
+
hasWarnedForMissingNameRef.current = true;
|
|
2105
|
+
}
|
|
2106
|
+
}
|
|
2107
|
+
return /* @__PURE__ */ jsxs(
|
|
2108
|
+
"label",
|
|
2109
|
+
{
|
|
2110
|
+
htmlFor: inputId,
|
|
2111
|
+
className: cn(
|
|
2112
|
+
"volt-radio",
|
|
2113
|
+
`volt-radio--${size2}`,
|
|
2114
|
+
checked && "volt-radio--checked",
|
|
2115
|
+
disabled && "volt-radio--disabled",
|
|
2116
|
+
containerClassName
|
|
2117
|
+
),
|
|
2118
|
+
title: resolvedTitle,
|
|
2119
|
+
children: [
|
|
2120
|
+
/* @__PURE__ */ jsx(
|
|
2121
|
+
"input",
|
|
2122
|
+
{
|
|
2123
|
+
ref,
|
|
2124
|
+
id: inputId,
|
|
2125
|
+
type: "radio",
|
|
2126
|
+
className: cn("volt-radio__input", className),
|
|
2127
|
+
checked,
|
|
2128
|
+
onChange,
|
|
2129
|
+
name,
|
|
2130
|
+
value,
|
|
2131
|
+
disabled,
|
|
2132
|
+
"aria-label": !hasVisibleLabel ? resolvedAriaLabel : void 0,
|
|
2133
|
+
"aria-labelledby": resolvedAriaLabelledBy,
|
|
2134
|
+
...props
|
|
2135
|
+
}
|
|
2136
|
+
),
|
|
2137
|
+
/* @__PURE__ */ jsx("span", { className: "volt-radio__box", "aria-hidden": "true", children: /* @__PURE__ */ jsx("span", { className: "volt-radio__indicator" }) }),
|
|
2138
|
+
hasVisibleLabel && /* @__PURE__ */ jsx(Text_default, { as: "span", size: "sm", tone: "primary", className: "volt-radio__label", children: label })
|
|
2139
|
+
]
|
|
2140
|
+
}
|
|
2141
|
+
);
|
|
2142
|
+
});
|
|
2143
|
+
Radio.displayName = "Radio";
|
|
2144
|
+
var Radio_default = Radio;
|
|
2145
|
+
var MISSING_TABS_LABEL_ERROR = "Tabs.List requires an accessible name via aria-label or aria-labelledby so assistive tech can announce the tab group.";
|
|
2146
|
+
var TabsContext = createContext(null);
|
|
2147
|
+
var useTabsContext = (component) => {
|
|
2148
|
+
const ctx = useContext(TabsContext);
|
|
2149
|
+
if (!ctx) {
|
|
2150
|
+
throw new Error(`${component} must be rendered inside <Tabs>.`);
|
|
2151
|
+
}
|
|
2152
|
+
return ctx;
|
|
2153
|
+
};
|
|
2154
|
+
var tabId = (baseId, value) => `${baseId}-tab-${value}`;
|
|
2155
|
+
var panelId = (baseId, value) => `${baseId}-panel-${value}`;
|
|
2156
|
+
var TabsRoot = forwardRef(({
|
|
2157
|
+
value: controlledValue,
|
|
2158
|
+
defaultValue,
|
|
2159
|
+
onChange,
|
|
2160
|
+
size: size2 = "md",
|
|
2161
|
+
className,
|
|
2162
|
+
children,
|
|
2163
|
+
...rest
|
|
2164
|
+
}, ref) => {
|
|
2165
|
+
const baseId = useId();
|
|
2166
|
+
const isControlled = controlledValue !== void 0;
|
|
2167
|
+
const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue);
|
|
2168
|
+
const value = isControlled ? controlledValue : uncontrolledValue;
|
|
2169
|
+
const registryRef = useRef(/* @__PURE__ */ new Map());
|
|
2170
|
+
const orderedValuesRef = useRef([]);
|
|
2171
|
+
const tabNodesRef = useRef(/* @__PURE__ */ new Map());
|
|
2172
|
+
const recomputeOrder = useCallback(() => {
|
|
2173
|
+
orderedValuesRef.current = Array.from(registryRef.current.entries()).filter(([, disabled]) => !disabled).map(([tabValue]) => tabValue);
|
|
2174
|
+
}, []);
|
|
2175
|
+
const registerTab = useCallback((tabValue, disabled) => {
|
|
2176
|
+
registryRef.current.set(tabValue, disabled);
|
|
2177
|
+
recomputeOrder();
|
|
2178
|
+
}, [recomputeOrder]);
|
|
2179
|
+
const unregisterTab = useCallback((tabValue) => {
|
|
2180
|
+
registryRef.current.delete(tabValue);
|
|
2181
|
+
tabNodesRef.current.delete(tabValue);
|
|
2182
|
+
recomputeOrder();
|
|
2183
|
+
}, [recomputeOrder]);
|
|
2184
|
+
const selectValue = useCallback((next) => {
|
|
2185
|
+
if (!isControlled) {
|
|
2186
|
+
setUncontrolledValue(next);
|
|
2187
|
+
}
|
|
2188
|
+
onChange?.(next);
|
|
2189
|
+
}, [isControlled, onChange]);
|
|
2190
|
+
const focusTab = useCallback((tabValue) => {
|
|
2191
|
+
tabNodesRef.current.get(tabValue)?.focus();
|
|
2192
|
+
}, []);
|
|
2193
|
+
const contextValue = useMemo(() => ({
|
|
2194
|
+
baseId,
|
|
2195
|
+
value,
|
|
2196
|
+
selectValue,
|
|
2197
|
+
size: size2,
|
|
2198
|
+
registerTab,
|
|
2199
|
+
unregisterTab,
|
|
2200
|
+
focusTab,
|
|
2201
|
+
orderedValuesRef,
|
|
2202
|
+
tabNodesRef
|
|
2203
|
+
}), [baseId, value, selectValue, size2, registerTab, unregisterTab, focusTab]);
|
|
2204
|
+
return /* @__PURE__ */ jsx(TabsContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(
|
|
2205
|
+
"div",
|
|
2206
|
+
{
|
|
2207
|
+
ref,
|
|
2208
|
+
className: cn("volt-tabs", `volt-tabs--${size2}`, className),
|
|
2209
|
+
...rest,
|
|
2210
|
+
children
|
|
2211
|
+
}
|
|
2212
|
+
) });
|
|
2213
|
+
});
|
|
2214
|
+
TabsRoot.displayName = "Tabs";
|
|
2215
|
+
var TabsList = forwardRef(({
|
|
2216
|
+
className,
|
|
2217
|
+
children,
|
|
2218
|
+
"aria-label": ariaLabel,
|
|
2219
|
+
"aria-labelledby": ariaLabelledBy,
|
|
2220
|
+
...rest
|
|
2221
|
+
}, ref) => {
|
|
2222
|
+
const { size: size2 } = useTabsContext("Tabs.List");
|
|
2223
|
+
const hasWarnedForMissingNameRef = useRef(false);
|
|
2224
|
+
const resolvedAriaLabel = ariaLabel?.trim() || void 0;
|
|
2225
|
+
const resolvedAriaLabelledBy = ariaLabelledBy?.trim() || void 0;
|
|
2226
|
+
if (!resolvedAriaLabel && !resolvedAriaLabelledBy && !hasWarnedForMissingNameRef.current) {
|
|
2227
|
+
console.warn(MISSING_TABS_LABEL_ERROR);
|
|
2228
|
+
hasWarnedForMissingNameRef.current = true;
|
|
2229
|
+
}
|
|
2230
|
+
return /* @__PURE__ */ jsx(
|
|
2231
|
+
"div",
|
|
2232
|
+
{
|
|
2233
|
+
ref,
|
|
2234
|
+
role: "tablist",
|
|
2235
|
+
"aria-label": resolvedAriaLabel,
|
|
2236
|
+
"aria-labelledby": resolvedAriaLabelledBy,
|
|
2237
|
+
"aria-orientation": "horizontal",
|
|
2238
|
+
className: cn("volt-tabs__list", "d-flex", "items-end", "border-bottom-soft", `volt-tabs__list--${size2}`, className),
|
|
2239
|
+
...rest,
|
|
2240
|
+
children
|
|
2241
|
+
}
|
|
2242
|
+
);
|
|
2243
|
+
});
|
|
2244
|
+
TabsList.displayName = "Tabs.List";
|
|
2245
|
+
var Tab = forwardRef(({
|
|
2246
|
+
value,
|
|
2247
|
+
children,
|
|
2248
|
+
leftIcon,
|
|
2249
|
+
disabled = false,
|
|
2250
|
+
className,
|
|
2251
|
+
id,
|
|
2252
|
+
onKeyDown,
|
|
2253
|
+
...rest
|
|
2254
|
+
}, ref) => {
|
|
2255
|
+
const {
|
|
2256
|
+
baseId,
|
|
2257
|
+
value: selectedValue,
|
|
2258
|
+
selectValue,
|
|
2259
|
+
size: size2,
|
|
2260
|
+
registerTab,
|
|
2261
|
+
unregisterTab,
|
|
2262
|
+
focusTab,
|
|
2263
|
+
orderedValuesRef,
|
|
2264
|
+
tabNodesRef
|
|
2265
|
+
} = useTabsContext("Tabs.Tab");
|
|
2266
|
+
const isSelected = selectedValue === value;
|
|
2267
|
+
const resolvedTabId = id ?? tabId(baseId, value);
|
|
2268
|
+
const resolvedPanelId = panelId(baseId, value);
|
|
2269
|
+
const setNodeRef = useCallback((node) => {
|
|
2270
|
+
if (node) {
|
|
2271
|
+
tabNodesRef.current.set(value, node);
|
|
2272
|
+
registerTab(value, disabled);
|
|
2273
|
+
} else {
|
|
2274
|
+
unregisterTab(value);
|
|
2275
|
+
}
|
|
2276
|
+
if (typeof ref === "function") {
|
|
2277
|
+
ref(node);
|
|
2278
|
+
} else if (ref) {
|
|
2279
|
+
ref.current = node;
|
|
2280
|
+
}
|
|
2281
|
+
}, [value, disabled, registerTab, unregisterTab, tabNodesRef, ref]);
|
|
2282
|
+
const handleKeyDown = (event) => {
|
|
2283
|
+
onKeyDown?.(event);
|
|
2284
|
+
if (event.defaultPrevented) {
|
|
2285
|
+
return;
|
|
2286
|
+
}
|
|
2287
|
+
const order = orderedValuesRef.current;
|
|
2288
|
+
const currentIndex = order.indexOf(value);
|
|
2289
|
+
if (currentIndex === -1) {
|
|
2290
|
+
return;
|
|
2291
|
+
}
|
|
2292
|
+
let nextValue;
|
|
2293
|
+
switch (event.key) {
|
|
2294
|
+
case "ArrowRight":
|
|
2295
|
+
case "ArrowDown":
|
|
2296
|
+
nextValue = order[(currentIndex + 1) % order.length];
|
|
2297
|
+
break;
|
|
2298
|
+
case "ArrowLeft":
|
|
2299
|
+
case "ArrowUp":
|
|
2300
|
+
nextValue = order[(currentIndex - 1 + order.length) % order.length];
|
|
2301
|
+
break;
|
|
2302
|
+
case "Home":
|
|
2303
|
+
nextValue = order[0];
|
|
2304
|
+
break;
|
|
2305
|
+
case "End":
|
|
2306
|
+
nextValue = order[order.length - 1];
|
|
2307
|
+
break;
|
|
2308
|
+
default:
|
|
2309
|
+
return;
|
|
2310
|
+
}
|
|
2311
|
+
if (nextValue !== void 0) {
|
|
2312
|
+
event.preventDefault();
|
|
2313
|
+
selectValue(nextValue);
|
|
2314
|
+
focusTab(nextValue);
|
|
2315
|
+
}
|
|
2316
|
+
};
|
|
2317
|
+
return /* @__PURE__ */ jsxs(
|
|
2318
|
+
"button",
|
|
2319
|
+
{
|
|
2320
|
+
ref: setNodeRef,
|
|
2321
|
+
type: "button",
|
|
2322
|
+
role: "tab",
|
|
2323
|
+
id: resolvedTabId,
|
|
2324
|
+
"aria-selected": isSelected,
|
|
2325
|
+
"aria-controls": resolvedPanelId,
|
|
2326
|
+
tabIndex: isSelected ? 0 : -1,
|
|
2327
|
+
disabled,
|
|
2328
|
+
className: cn(
|
|
2329
|
+
"volt-tabs__tab",
|
|
2330
|
+
"d-flex",
|
|
2331
|
+
"items-center",
|
|
2332
|
+
"transition-fast",
|
|
2333
|
+
`volt-tabs__tab--${size2}`,
|
|
2334
|
+
isSelected && "is-selected",
|
|
2335
|
+
disabled && "is-disabled",
|
|
2336
|
+
className
|
|
2337
|
+
),
|
|
2338
|
+
onClick: () => {
|
|
2339
|
+
if (disabled) return;
|
|
2340
|
+
selectValue(value);
|
|
2341
|
+
},
|
|
2342
|
+
onKeyDown: handleKeyDown,
|
|
2343
|
+
...rest,
|
|
2344
|
+
children: [
|
|
2345
|
+
leftIcon && /* @__PURE__ */ jsx("span", { className: "volt-tabs__tab-icon d-flex flex-center", "aria-hidden": "true", children: leftIcon }),
|
|
2346
|
+
/* @__PURE__ */ jsx("span", { className: "volt-tabs__tab-label", children }),
|
|
2347
|
+
/* @__PURE__ */ jsx("span", { className: "volt-tabs__indicator", "aria-hidden": "true" })
|
|
2348
|
+
]
|
|
2349
|
+
}
|
|
2350
|
+
);
|
|
2351
|
+
});
|
|
2352
|
+
Tab.displayName = "Tabs.Tab";
|
|
2353
|
+
var TabsPanel = forwardRef(({
|
|
2354
|
+
value,
|
|
2355
|
+
children,
|
|
2356
|
+
keepMounted = false,
|
|
2357
|
+
className,
|
|
2358
|
+
id,
|
|
2359
|
+
...rest
|
|
2360
|
+
}, ref) => {
|
|
2361
|
+
const { baseId, value: selectedValue } = useTabsContext("Tabs.Panel");
|
|
2362
|
+
const isSelected = selectedValue === value;
|
|
2363
|
+
if (!isSelected && !keepMounted) {
|
|
2364
|
+
return null;
|
|
2365
|
+
}
|
|
2366
|
+
return /* @__PURE__ */ jsx(
|
|
2367
|
+
"div",
|
|
2368
|
+
{
|
|
2369
|
+
ref,
|
|
2370
|
+
role: "tabpanel",
|
|
2371
|
+
id: id ?? panelId(baseId, value),
|
|
2372
|
+
"aria-labelledby": tabId(baseId, value),
|
|
2373
|
+
hidden: !isSelected,
|
|
2374
|
+
tabIndex: 0,
|
|
2375
|
+
className: cn("volt-tabs__panel", className),
|
|
2376
|
+
...rest,
|
|
2377
|
+
children
|
|
2378
|
+
}
|
|
2379
|
+
);
|
|
2380
|
+
});
|
|
2381
|
+
TabsPanel.displayName = "Tabs.Panel";
|
|
2382
|
+
var Tabs = TabsRoot;
|
|
2383
|
+
Tabs.List = TabsList;
|
|
2384
|
+
Tabs.Tab = Tab;
|
|
2385
|
+
Tabs.Panel = TabsPanel;
|
|
2386
|
+
var Tabs_default = Tabs;
|
|
2387
|
+
var MAX_BREADCRUMB_LABEL_LENGTH = 24;
|
|
2388
|
+
var truncateBreadcrumbLabel = (label) => {
|
|
2389
|
+
if (label.length <= MAX_BREADCRUMB_LABEL_LENGTH) {
|
|
2390
|
+
return label;
|
|
2391
|
+
}
|
|
2392
|
+
return `${label.slice(0, MAX_BREADCRUMB_LABEL_LENGTH - 1)}\u2026`;
|
|
2393
|
+
};
|
|
2394
|
+
var Breadcrumbs = forwardRef(({
|
|
2395
|
+
items,
|
|
2396
|
+
variant = "default",
|
|
2397
|
+
separator,
|
|
2398
|
+
ariaLabel = "Breadcrumbs",
|
|
2399
|
+
title,
|
|
2400
|
+
className,
|
|
2401
|
+
onItemClick
|
|
2402
|
+
}, ref) => {
|
|
2403
|
+
if (!items.length) {
|
|
2404
|
+
return null;
|
|
2405
|
+
}
|
|
2406
|
+
const resolvedSeparator = separator ?? (variant === "compact" ? /* @__PURE__ */ jsx("span", { className: "volt-breadcrumbs__separator", children: "/" }) : /* @__PURE__ */ jsx(ChevronRight, { size: 12, className: "volt-breadcrumbs__separator", "aria-hidden": "true" }));
|
|
2407
|
+
return /* @__PURE__ */ jsx(
|
|
2408
|
+
"nav",
|
|
2409
|
+
{
|
|
2410
|
+
ref,
|
|
2411
|
+
className: cn("volt-breadcrumbs", `volt-breadcrumbs--${variant}`, className),
|
|
2412
|
+
"aria-label": ariaLabel,
|
|
2413
|
+
title,
|
|
2414
|
+
children: /* @__PURE__ */ jsx("ol", { className: "volt-breadcrumbs__list", children: items.map((item, index) => {
|
|
2415
|
+
const isCurrent = index === items.length - 1;
|
|
2416
|
+
const displayTitle = variant === "compact" ? truncateBreadcrumbLabel(item.title) : item.title;
|
|
2417
|
+
const handleClick = () => {
|
|
2418
|
+
item.onClick?.();
|
|
2419
|
+
onItemClick?.(item, index);
|
|
2420
|
+
};
|
|
2421
|
+
return /* @__PURE__ */ jsxs("li", { className: "volt-breadcrumbs__item", children: [
|
|
2422
|
+
index > 0 && resolvedSeparator,
|
|
2423
|
+
isCurrent ? /* @__PURE__ */ jsxs(
|
|
2424
|
+
"span",
|
|
2425
|
+
{
|
|
2426
|
+
className: "volt-breadcrumbs__current",
|
|
2427
|
+
"aria-current": "page",
|
|
2428
|
+
title: item.title,
|
|
2429
|
+
children: [
|
|
2430
|
+
item.leftIcon && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: item.leftIcon }),
|
|
2431
|
+
displayTitle
|
|
2432
|
+
]
|
|
2433
|
+
}
|
|
2434
|
+
) : /* @__PURE__ */ jsxs(
|
|
2435
|
+
"button",
|
|
2436
|
+
{
|
|
2437
|
+
type: "button",
|
|
2438
|
+
className: "volt-breadcrumbs__trigger",
|
|
2439
|
+
onClick: handleClick,
|
|
2440
|
+
title: item.title,
|
|
2441
|
+
"aria-label": `Open ${item.title}`,
|
|
2442
|
+
children: [
|
|
2443
|
+
item.leftIcon && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: item.leftIcon }),
|
|
2444
|
+
displayTitle
|
|
2445
|
+
]
|
|
2446
|
+
}
|
|
2447
|
+
)
|
|
2448
|
+
] }, item.id);
|
|
2449
|
+
}) })
|
|
2450
|
+
}
|
|
2451
|
+
);
|
|
2452
|
+
});
|
|
2453
|
+
Breadcrumbs.displayName = "Breadcrumbs";
|
|
2454
|
+
var Breadcrumbs_default = Breadcrumbs;
|
|
2455
|
+
var CollapsibleSection = forwardRef(({
|
|
2456
|
+
title,
|
|
2457
|
+
children,
|
|
2458
|
+
defaultExpanded = false,
|
|
2459
|
+
expanded,
|
|
2460
|
+
onExpandedChange,
|
|
2461
|
+
className = "",
|
|
2462
|
+
headerClassName = "",
|
|
2463
|
+
titleClassName = "",
|
|
2464
|
+
bodyClassName = "",
|
|
2465
|
+
contentClassName = "",
|
|
2466
|
+
noSpacing = false,
|
|
2467
|
+
arrowSize = 20,
|
|
2468
|
+
useDefaultHeaderStyles = true,
|
|
2469
|
+
useDefaultTitleStyles = true,
|
|
2470
|
+
onDelete,
|
|
2471
|
+
deleteActionLabel = "Delete section",
|
|
2472
|
+
deleteActionAlwaysVisible = false,
|
|
2473
|
+
onAdd,
|
|
2474
|
+
headerAction,
|
|
2475
|
+
collapsible = true,
|
|
2476
|
+
titleAs = "h3"
|
|
2477
|
+
}, ref) => {
|
|
2478
|
+
const [isExpanded, setIsExpanded] = useState(defaultExpanded);
|
|
2479
|
+
const [hasBeenExpanded, setHasBeenExpanded] = useState(defaultExpanded);
|
|
2480
|
+
const [height, setHeight] = useState(defaultExpanded ? "auto" : 0);
|
|
2481
|
+
const reactId = useId();
|
|
2482
|
+
const isControlled = typeof expanded === "boolean";
|
|
2483
|
+
const actualExpanded = isControlled ? expanded : isExpanded;
|
|
2484
|
+
const headerBaseClass = useDefaultHeaderStyles ? "collapsible-section-header" : "";
|
|
2485
|
+
const titleBaseClass = useDefaultTitleStyles ? "collapsible-section-title font-weight-6 color-primary" : "collapsible-section-title";
|
|
2486
|
+
const bodyId = `collapsible-section-body-${reactId}`;
|
|
2487
|
+
const headingId = `collapsible-section-heading-${reactId}`;
|
|
2488
|
+
const triggerId = `collapsible-section-trigger-${reactId}`;
|
|
2489
|
+
const TitleTag = titleAs;
|
|
2490
|
+
useEffect(() => {
|
|
2491
|
+
if (actualExpanded && !hasBeenExpanded) {
|
|
2492
|
+
setHasBeenExpanded(true);
|
|
2493
|
+
}
|
|
2494
|
+
}, [actualExpanded, hasBeenExpanded]);
|
|
2495
|
+
useEffect(() => {
|
|
2496
|
+
setHeight(actualExpanded ? "auto" : 0);
|
|
2497
|
+
}, [actualExpanded]);
|
|
2498
|
+
const handleToggle = () => {
|
|
2499
|
+
if (!collapsible) return;
|
|
2500
|
+
const next = !actualExpanded;
|
|
2501
|
+
if (isControlled) {
|
|
2502
|
+
onExpandedChange?.(next);
|
|
2503
|
+
return;
|
|
2504
|
+
}
|
|
2505
|
+
setIsExpanded(next);
|
|
2506
|
+
};
|
|
2507
|
+
const handleDelete = (e) => {
|
|
2508
|
+
e.stopPropagation();
|
|
2509
|
+
onDelete?.();
|
|
2510
|
+
};
|
|
2511
|
+
const handleAdd = (e) => {
|
|
2512
|
+
e.stopPropagation();
|
|
2513
|
+
onAdd?.();
|
|
2514
|
+
};
|
|
2515
|
+
const actions = /* @__PURE__ */ jsxs(Row_default, { gap: "025", className: "collapsible-section-actions", children: [
|
|
2516
|
+
headerAction,
|
|
2517
|
+
onAdd && /* @__PURE__ */ jsx(
|
|
2518
|
+
IconButton_default,
|
|
2519
|
+
{
|
|
2520
|
+
size: "sm",
|
|
2521
|
+
variant: "ghost",
|
|
2522
|
+
onClick: handleAdd,
|
|
2523
|
+
className: "collapsible-section-action--add",
|
|
2524
|
+
title: "Add item",
|
|
2525
|
+
children: /* @__PURE__ */ jsx(Plus, { size: 16 })
|
|
2526
|
+
}
|
|
2527
|
+
),
|
|
2528
|
+
onDelete && /* @__PURE__ */ jsx(
|
|
2529
|
+
IconButton_default,
|
|
2530
|
+
{
|
|
2531
|
+
size: "sm",
|
|
2532
|
+
variant: "ghost",
|
|
2533
|
+
onClick: handleDelete,
|
|
2534
|
+
className: `collapsible-section-action--delete ${deleteActionAlwaysVisible ? "collapsible-section-action--delete-visible" : ""}`,
|
|
2535
|
+
title: deleteActionLabel,
|
|
2536
|
+
"aria-label": deleteActionLabel,
|
|
2537
|
+
children: /* @__PURE__ */ jsx(Trash2, { size: 16 })
|
|
2538
|
+
}
|
|
2539
|
+
)
|
|
2540
|
+
] });
|
|
2541
|
+
return /* @__PURE__ */ jsxs(Stack_default, { ref, mb: noSpacing ? void 0 : "1-5", className, children: [
|
|
2542
|
+
/* @__PURE__ */ jsx(Row_default, { justify: "between", gap: "05", className: `${headerBaseClass} ${headerClassName}`, children: /* @__PURE__ */ jsx(TitleTag, { id: headingId, className: "collapsible-section-heading", children: collapsible ? /* @__PURE__ */ jsxs(Row_default, { gap: "05", className: "collapsible-section-header-row", children: [
|
|
2543
|
+
/* @__PURE__ */ jsx(
|
|
2544
|
+
"button",
|
|
2545
|
+
{
|
|
2546
|
+
id: triggerId,
|
|
2547
|
+
type: "button",
|
|
2548
|
+
className: "collapsible-section-trigger d-flex items-center gap-05 u-select-none",
|
|
2549
|
+
onClick: handleToggle,
|
|
2550
|
+
"aria-expanded": actualExpanded,
|
|
2551
|
+
"aria-controls": bodyId,
|
|
2552
|
+
children: /* @__PURE__ */ jsx(Row_default, { gap: "05", className: "collapsible-section-trigger-content", children: /* @__PURE__ */ jsx("span", { className: `${titleBaseClass} ${titleClassName}`, children: title }) })
|
|
2553
|
+
}
|
|
2554
|
+
),
|
|
2555
|
+
actions,
|
|
2556
|
+
/* @__PURE__ */ jsx(
|
|
2557
|
+
"button",
|
|
2558
|
+
{
|
|
2559
|
+
type: "button",
|
|
2560
|
+
className: "collapsible-section-chevron-trigger d-flex flex-center color-muted",
|
|
2561
|
+
onClick: handleToggle,
|
|
2562
|
+
"aria-expanded": actualExpanded,
|
|
2563
|
+
"aria-controls": bodyId,
|
|
2564
|
+
"aria-label": `${actualExpanded ? "Collapse" : "Expand"} ${title}`,
|
|
2565
|
+
children: /* @__PURE__ */ jsx("div", { className: `collapsible-section-arrow d-flex flex-center ${!actualExpanded ? "collapsible-section-arrow--collapsed" : ""}`, "aria-hidden": "true", children: /* @__PURE__ */ jsx(ChevronDown, { size: arrowSize }) })
|
|
2566
|
+
}
|
|
2567
|
+
)
|
|
2568
|
+
] }) : /* @__PURE__ */ jsxs(Row_default, { gap: "05", className: "collapsible-section-title-row", children: [
|
|
2569
|
+
/* @__PURE__ */ jsx(Row_default, { gap: "05", className: "collapsible-section-trigger-content", children: /* @__PURE__ */ jsx("span", { className: `${titleBaseClass} ${titleClassName}`, children: title }) }),
|
|
2570
|
+
actions
|
|
2571
|
+
] }) }) }),
|
|
2572
|
+
collapsible && /* @__PURE__ */ jsx(
|
|
2573
|
+
"div",
|
|
2574
|
+
{
|
|
2575
|
+
id: bodyId,
|
|
2576
|
+
className: `collapsible-section-body ${bodyClassName}`,
|
|
2577
|
+
style: { height },
|
|
2578
|
+
role: "region",
|
|
2579
|
+
"aria-labelledby": triggerId,
|
|
2580
|
+
children: /* @__PURE__ */ jsx(Stack_default, { className: `collapsible-section-content ${contentClassName}`, children: hasBeenExpanded ? children : null })
|
|
2581
|
+
}
|
|
2582
|
+
),
|
|
2583
|
+
!collapsible && /* @__PURE__ */ jsx("div", { id: bodyId, className: `collapsible-section-body collapsible-section-body--static ${bodyClassName}`, role: "region", "aria-labelledby": headingId, children: /* @__PURE__ */ jsx(Stack_default, { className: `collapsible-section-content ${contentClassName}`, children }) })
|
|
2584
|
+
] });
|
|
2585
|
+
});
|
|
2586
|
+
CollapsibleSection.displayName = "CollapsibleSection";
|
|
2587
|
+
var CollapsibleSection_default = memo(CollapsibleSection);
|
|
2588
|
+
var COARSE_POINTER_MEDIA_QUERY = "(pointer: coarse)";
|
|
2589
|
+
var LAZY_MOUNT_UNMOUNT_DELAY_MS = 250;
|
|
2590
|
+
var isDialogElement = (element) => {
|
|
2591
|
+
return element instanceof HTMLDialogElement;
|
|
2592
|
+
};
|
|
2593
|
+
var getFocusableElements = (dialog) => {
|
|
2594
|
+
const selector = [
|
|
2595
|
+
"button:not([disabled])",
|
|
2596
|
+
"[href]",
|
|
2597
|
+
"input:not([disabled])",
|
|
2598
|
+
"select:not([disabled])",
|
|
2599
|
+
"textarea:not([disabled])",
|
|
2600
|
+
'[tabindex]:not([tabindex="-1"])'
|
|
2601
|
+
].join(",");
|
|
2602
|
+
const focusableElements = dialog.querySelectorAll(selector);
|
|
2603
|
+
return Array.from(focusableElements).filter((element) => {
|
|
2604
|
+
return !element.hasAttribute("hidden") && element.getAttribute("aria-hidden") !== "true";
|
|
2605
|
+
});
|
|
2606
|
+
};
|
|
2607
|
+
var getInitialFocusTarget = (dialog, isCoarsePointer) => {
|
|
2608
|
+
if (isCoarsePointer) {
|
|
2609
|
+
return dialog;
|
|
2610
|
+
}
|
|
2611
|
+
const preferredFocusTarget = dialog.querySelector('[data-modal-initial-focus="true"]');
|
|
2612
|
+
if (preferredFocusTarget && !preferredFocusTarget.hasAttribute("disabled")) {
|
|
2613
|
+
return preferredFocusTarget;
|
|
2614
|
+
}
|
|
2615
|
+
const autofocusElement = dialog.querySelector("[autofocus]");
|
|
2616
|
+
if (autofocusElement && !autofocusElement.hasAttribute("disabled")) {
|
|
2617
|
+
return autofocusElement;
|
|
2618
|
+
}
|
|
2619
|
+
return getFocusableElements(dialog)[0] ?? dialog;
|
|
2620
|
+
};
|
|
2621
|
+
var Modal = ({
|
|
2622
|
+
id,
|
|
2623
|
+
trigger,
|
|
2624
|
+
title,
|
|
2625
|
+
description,
|
|
2626
|
+
children,
|
|
2627
|
+
footer,
|
|
2628
|
+
className = "",
|
|
2629
|
+
width,
|
|
2630
|
+
onClose,
|
|
2631
|
+
dismissible = true,
|
|
2632
|
+
lazyMount = false
|
|
2633
|
+
}) => {
|
|
2634
|
+
const [dialogElement, setDialogElement] = useState(null);
|
|
2635
|
+
const [shouldRenderContents, setShouldRenderContents] = useState(!lazyMount);
|
|
2636
|
+
const restoreFocusElementRef = useRef(null);
|
|
2637
|
+
const isCoarsePointer = use_media_default(COARSE_POINTER_MEDIA_QUERY);
|
|
2638
|
+
const titleId = title ? `${id}-title` : void 0;
|
|
2639
|
+
const descriptionId = description ? `${id}-description` : void 0;
|
|
2640
|
+
useEffect(() => {
|
|
2641
|
+
if (!dialogElement) {
|
|
2642
|
+
return;
|
|
2643
|
+
}
|
|
2644
|
+
let unmountTimeoutId = null;
|
|
2645
|
+
const clearUnmountTimer = () => {
|
|
2646
|
+
if (unmountTimeoutId !== null) {
|
|
2647
|
+
clearTimeout(unmountTimeoutId);
|
|
2648
|
+
unmountTimeoutId = null;
|
|
2649
|
+
}
|
|
2650
|
+
};
|
|
2651
|
+
const syncDialogState = () => {
|
|
2652
|
+
if (dialogElement.open) {
|
|
2653
|
+
if (lazyMount) {
|
|
2654
|
+
clearUnmountTimer();
|
|
2655
|
+
setShouldRenderContents(true);
|
|
2656
|
+
}
|
|
2657
|
+
if (!restoreFocusElementRef.current && document.activeElement instanceof HTMLElement) {
|
|
2658
|
+
restoreFocusElementRef.current = document.activeElement;
|
|
2659
|
+
}
|
|
2660
|
+
window.requestAnimationFrame(() => {
|
|
2661
|
+
if (!dialogElement.open) {
|
|
2662
|
+
return;
|
|
2663
|
+
}
|
|
2664
|
+
const focusTarget = getInitialFocusTarget(dialogElement, isCoarsePointer);
|
|
2665
|
+
focusTarget.focus({ preventScroll: true });
|
|
2666
|
+
});
|
|
2667
|
+
return;
|
|
2668
|
+
}
|
|
2669
|
+
if (lazyMount) {
|
|
2670
|
+
clearUnmountTimer();
|
|
2671
|
+
unmountTimeoutId = setTimeout(() => {
|
|
2672
|
+
setShouldRenderContents(false);
|
|
2673
|
+
unmountTimeoutId = null;
|
|
2674
|
+
}, LAZY_MOUNT_UNMOUNT_DELAY_MS);
|
|
2675
|
+
}
|
|
2676
|
+
if (restoreFocusElementRef.current?.isConnected) {
|
|
2677
|
+
restoreFocusElementRef.current.focus({ preventScroll: true });
|
|
2678
|
+
}
|
|
2679
|
+
restoreFocusElementRef.current = null;
|
|
2680
|
+
};
|
|
2681
|
+
const observer = new MutationObserver(syncDialogState);
|
|
2682
|
+
observer.observe(dialogElement, { attributes: true, attributeFilter: ["open"] });
|
|
2683
|
+
syncDialogState();
|
|
2684
|
+
return () => {
|
|
2685
|
+
observer.disconnect();
|
|
2686
|
+
clearUnmountTimer();
|
|
2687
|
+
restoreFocusElementRef.current = null;
|
|
2688
|
+
};
|
|
2689
|
+
}, [dialogElement, isCoarsePointer, lazyMount]);
|
|
2690
|
+
const handleBackdropClick = (event) => {
|
|
2691
|
+
if (!dismissible) {
|
|
2692
|
+
return;
|
|
2693
|
+
}
|
|
2694
|
+
const dialog = event.currentTarget;
|
|
2695
|
+
const rect = dialog.getBoundingClientRect();
|
|
2696
|
+
const isInDialog = rect.top <= event.clientY && event.clientY <= rect.top + rect.height && rect.left <= event.clientX && event.clientX <= rect.left + rect.width;
|
|
2697
|
+
if (!isInDialog) {
|
|
2698
|
+
dialog.close();
|
|
2699
|
+
}
|
|
2700
|
+
};
|
|
2701
|
+
const handleCancel = (event) => {
|
|
2702
|
+
if (!dismissible) {
|
|
2703
|
+
event.preventDefault();
|
|
2704
|
+
}
|
|
2705
|
+
};
|
|
2706
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2707
|
+
trigger && React.isValidElement(trigger) ? React.cloneElement(trigger, {
|
|
2708
|
+
command: "show-modal",
|
|
2709
|
+
commandfor: id,
|
|
2710
|
+
"aria-controls": id,
|
|
2711
|
+
"aria-haspopup": "dialog",
|
|
2712
|
+
type: "button"
|
|
2713
|
+
}) : null,
|
|
2714
|
+
/* @__PURE__ */ jsx(
|
|
2715
|
+
"dialog",
|
|
2716
|
+
{
|
|
2717
|
+
ref: setDialogElement,
|
|
2718
|
+
id,
|
|
2719
|
+
className: `volt-modal ${className}`,
|
|
2720
|
+
style: width ? { maxWidth: width } : void 0,
|
|
2721
|
+
onClick: handleBackdropClick,
|
|
2722
|
+
onCancel: handleCancel,
|
|
2723
|
+
onClose,
|
|
2724
|
+
"aria-modal": "true",
|
|
2725
|
+
"aria-labelledby": titleId,
|
|
2726
|
+
"aria-describedby": descriptionId,
|
|
2727
|
+
tabIndex: -1,
|
|
2728
|
+
children: /* @__PURE__ */ jsx(TopLayerRootContext.Provider, { value: dialogElement ?? void 0, children: /* @__PURE__ */ jsx(FloatingRootContext_default.Provider, { value: dialogElement ?? void 0, children: shouldRenderContents && /* @__PURE__ */ jsxs("div", { className: "d-flex column w-max", children: [
|
|
2729
|
+
(title || description) && /* @__PURE__ */ jsxs("div", { className: "d-flex items-start content-between volt-modal-header", children: [
|
|
2730
|
+
/* @__PURE__ */ jsxs("div", { className: "d-flex column gap-025", children: [
|
|
2731
|
+
title && /* @__PURE__ */ jsx("h3", { id: titleId, className: "font-size-4 font-weight-6", children: title }),
|
|
2732
|
+
description && /* @__PURE__ */ jsx("p", { id: descriptionId, className: "font-size-2 color-secondary", children: description })
|
|
2733
|
+
] }),
|
|
2734
|
+
dismissible && /* @__PURE__ */ jsx(
|
|
2735
|
+
CloseButton_default,
|
|
2736
|
+
{
|
|
2737
|
+
commandfor: id,
|
|
2738
|
+
command: "close",
|
|
2739
|
+
"aria-label": "Close modal"
|
|
2740
|
+
}
|
|
2741
|
+
)
|
|
2742
|
+
] }),
|
|
2743
|
+
/* @__PURE__ */ jsx("div", { className: "volt-modal-body", children }),
|
|
2744
|
+
footer && /* @__PURE__ */ jsx("div", { className: "d-flex items-center content-end gap-05 volt-modal-footer", children: footer })
|
|
2745
|
+
] }) }) })
|
|
2746
|
+
}
|
|
2747
|
+
)
|
|
2748
|
+
] });
|
|
2749
|
+
};
|
|
2750
|
+
var Modal_default = Modal;
|
|
2751
|
+
var openModal = (id) => {
|
|
2752
|
+
const element = document.getElementById(id);
|
|
2753
|
+
if (isDialogElement(element) && !element.open) {
|
|
2754
|
+
element.showModal();
|
|
2755
|
+
const toaster = document.getElementById("app-toaster-popover");
|
|
2756
|
+
if (toaster) {
|
|
2757
|
+
toaster.hidePopover();
|
|
2758
|
+
toaster.showPopover();
|
|
2759
|
+
}
|
|
2760
|
+
}
|
|
2761
|
+
};
|
|
2762
|
+
var closeModal = (id) => {
|
|
2763
|
+
const element = document.getElementById(id);
|
|
2764
|
+
if (isDialogElement(element) && element.open) {
|
|
2765
|
+
element.close();
|
|
2766
|
+
}
|
|
2767
|
+
};
|
|
2768
|
+
var resetModal = (id, reset, delay = 300) => {
|
|
2769
|
+
closeModal(id);
|
|
2770
|
+
window.setTimeout(reset, delay);
|
|
2771
|
+
};
|
|
2772
|
+
|
|
2773
|
+
// src/shared/presentation/utilities/compose-refs.ts
|
|
2774
|
+
var setRef = (ref, value) => {
|
|
2775
|
+
if (typeof ref === "function") {
|
|
2776
|
+
ref(value);
|
|
2777
|
+
return;
|
|
2778
|
+
}
|
|
2779
|
+
if (ref && typeof ref === "object") {
|
|
2780
|
+
Object.assign(ref, { current: value });
|
|
2781
|
+
}
|
|
2782
|
+
};
|
|
2783
|
+
var composeRefs = (...refs) => {
|
|
2784
|
+
return (node) => {
|
|
2785
|
+
refs.forEach((ref) => {
|
|
2786
|
+
setRef(ref, node);
|
|
2787
|
+
});
|
|
2788
|
+
};
|
|
2789
|
+
};
|
|
2790
|
+
var compose_refs_default = composeRefs;
|
|
2791
|
+
var Popover = ({
|
|
2792
|
+
id,
|
|
2793
|
+
trigger,
|
|
2794
|
+
children,
|
|
2795
|
+
className = "",
|
|
2796
|
+
noPadding = false,
|
|
2797
|
+
triggerAction = "click",
|
|
2798
|
+
onOpenChange,
|
|
2799
|
+
placement = "bottom-start",
|
|
2800
|
+
role: popoverRole = "dialog",
|
|
2801
|
+
triggerAriaHaspopup,
|
|
2802
|
+
ariaLabel,
|
|
2803
|
+
ariaLabelledBy,
|
|
2804
|
+
ariaDescribedBy,
|
|
2805
|
+
shouldOpenOnContextMenu
|
|
2806
|
+
}) => {
|
|
2807
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
2808
|
+
const [contextMenuPosition, setContextMenuPosition] = useState(null);
|
|
2809
|
+
const [floatingElement, setFloatingElement] = useState(null);
|
|
2810
|
+
const floatingRoot = useFloatingRoot();
|
|
2811
|
+
const floatingOwnerIds = useFloatingOwnerIds();
|
|
2812
|
+
const onOpenChangeRef = React.useRef(onOpenChange);
|
|
2813
|
+
const nextFloatingOwnerIds = useMemo(() => appendFloatingOwnerIds(floatingOwnerIds, id), [floatingOwnerIds, id]);
|
|
2814
|
+
useLayoutEffect(() => {
|
|
2815
|
+
onOpenChangeRef.current = onOpenChange;
|
|
2816
|
+
});
|
|
2817
|
+
const handleOpenChange = useCallback((nextOpen) => {
|
|
2818
|
+
setIsOpen(nextOpen);
|
|
2819
|
+
if (!nextOpen) {
|
|
2820
|
+
setContextMenuPosition(null);
|
|
2821
|
+
}
|
|
2822
|
+
onOpenChangeRef.current?.(nextOpen);
|
|
2823
|
+
}, []);
|
|
2824
|
+
const { refs, floatingStyles, context } = useFloating({
|
|
2825
|
+
open: isOpen,
|
|
2826
|
+
onOpenChange: handleOpenChange,
|
|
2827
|
+
placement,
|
|
2828
|
+
middleware: [
|
|
2829
|
+
offset(8),
|
|
2830
|
+
flip({ padding: 16 }),
|
|
2831
|
+
shift({ padding: 16 })
|
|
2832
|
+
],
|
|
2833
|
+
whileElementsMounted: autoUpdate
|
|
2834
|
+
});
|
|
2835
|
+
const positionReference = useMemo(() => {
|
|
2836
|
+
if (triggerAction !== "contextmenu" || !contextMenuPosition) {
|
|
2837
|
+
return null;
|
|
2838
|
+
}
|
|
2839
|
+
return {
|
|
2840
|
+
getBoundingClientRect() {
|
|
2841
|
+
return {
|
|
2842
|
+
width: 0,
|
|
2843
|
+
height: 0,
|
|
2844
|
+
x: contextMenuPosition.x,
|
|
2845
|
+
y: contextMenuPosition.y,
|
|
2846
|
+
top: contextMenuPosition.y,
|
|
2847
|
+
right: contextMenuPosition.x,
|
|
2848
|
+
bottom: contextMenuPosition.y,
|
|
2849
|
+
left: contextMenuPosition.x
|
|
2850
|
+
};
|
|
2851
|
+
}
|
|
2852
|
+
};
|
|
2853
|
+
}, [contextMenuPosition, triggerAction]);
|
|
2854
|
+
useLayoutEffect(() => {
|
|
2855
|
+
if (positionReference) {
|
|
2856
|
+
refs.setPositionReference(positionReference);
|
|
2857
|
+
return;
|
|
2858
|
+
}
|
|
2859
|
+
const referenceElement = refs.domReference.current;
|
|
2860
|
+
if (referenceElement) {
|
|
2861
|
+
refs.setPositionReference(referenceElement);
|
|
2862
|
+
}
|
|
2863
|
+
}, [positionReference, refs]);
|
|
2864
|
+
const click = useClick(context, {
|
|
2865
|
+
enabled: triggerAction === "click"
|
|
2866
|
+
});
|
|
2867
|
+
const dismiss = useDismiss(context, {
|
|
2868
|
+
outsidePress: (event) => {
|
|
2869
|
+
return !hasFloatingOwnerId(event.target instanceof Element ? event.target : null, id);
|
|
2870
|
+
}
|
|
2871
|
+
});
|
|
2872
|
+
const role = useRole(context, { role: popoverRole });
|
|
2873
|
+
const { getReferenceProps, getFloatingProps } = useInteractions([
|
|
2874
|
+
click,
|
|
2875
|
+
dismiss,
|
|
2876
|
+
role
|
|
2877
|
+
]);
|
|
2878
|
+
const close = useCallback(() => {
|
|
2879
|
+
handleOpenChange(false);
|
|
2880
|
+
}, [handleOpenChange]);
|
|
2881
|
+
const handleFloatingRef = useCallback((node) => {
|
|
2882
|
+
refs.setFloating(node);
|
|
2883
|
+
setFloatingElement(node);
|
|
2884
|
+
}, [refs]);
|
|
2885
|
+
const handleContextMenu = useCallback((event) => {
|
|
2886
|
+
if (triggerAction !== "contextmenu") return;
|
|
2887
|
+
if (event.defaultPrevented) return;
|
|
2888
|
+
if (shouldOpenOnContextMenu && !shouldOpenOnContextMenu(event)) return;
|
|
2889
|
+
event.preventDefault();
|
|
2890
|
+
event.stopPropagation();
|
|
2891
|
+
setContextMenuPosition({
|
|
2892
|
+
x: event.clientX,
|
|
2893
|
+
y: event.clientY
|
|
2894
|
+
});
|
|
2895
|
+
handleOpenChange(true);
|
|
2896
|
+
}, [triggerAction, handleOpenChange, shouldOpenOnContextMenu]);
|
|
2897
|
+
const renderChildren = () => {
|
|
2898
|
+
if (typeof children === "function") {
|
|
2899
|
+
return children(close);
|
|
2900
|
+
}
|
|
2901
|
+
return children;
|
|
2902
|
+
};
|
|
2903
|
+
const triggerElement = trigger && isValidElement(trigger) ? cloneElement(trigger, {
|
|
2904
|
+
...triggerAction === "contextmenu" ? {} : {
|
|
2905
|
+
ref: compose_refs_default(
|
|
2906
|
+
refs.setReference,
|
|
2907
|
+
trigger.props.ref
|
|
2908
|
+
)
|
|
2909
|
+
},
|
|
2910
|
+
"data-popover-trigger": id,
|
|
2911
|
+
"aria-controls": isOpen ? id : void 0,
|
|
2912
|
+
"aria-expanded": triggerAction === "click" ? isOpen : void 0,
|
|
2913
|
+
"aria-haspopup": triggerAriaHaspopup ?? (popoverRole === "menu" ? "menu" : "dialog"),
|
|
2914
|
+
...getReferenceProps({
|
|
2915
|
+
onContextMenu: handleContextMenu
|
|
2916
|
+
})
|
|
2917
|
+
}) : null;
|
|
2918
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2919
|
+
triggerElement,
|
|
2920
|
+
isOpen && /* @__PURE__ */ jsx(FloatingPortal, { root: floatingRoot, children: /* @__PURE__ */ jsx(FloatingFocusManager, { context, modal: false, children: /* @__PURE__ */ jsx("div", { ref: handleFloatingRef, id, className: `popover ${noPadding ? "popover--no-padding" : ""} radius-lg d-flex column glass-bg ${className} color-primary`, style: floatingStyles, onClick: (event) => event.stopPropagation(), "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, tabIndex: -1, ...getFloatingProps(), children: /* @__PURE__ */ jsx(FloatingOwnerIdsContext.Provider, { value: nextFloatingOwnerIds, children: /* @__PURE__ */ jsx(FloatingRootContext_default.Provider, { value: floatingElement ?? floatingRoot, children: renderChildren() }) }) }) }) })
|
|
2921
|
+
] });
|
|
2922
|
+
};
|
|
2923
|
+
var Popover_default = Popover;
|
|
2924
|
+
var MENU_ITEM_SELECTOR = '[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"]';
|
|
2925
|
+
var getMenuItems = (menuElement) => {
|
|
2926
|
+
if (!menuElement) {
|
|
2927
|
+
return [];
|
|
2928
|
+
}
|
|
2929
|
+
const items = Array.from(menuElement.querySelectorAll(MENU_ITEM_SELECTOR));
|
|
2930
|
+
return items.filter((item) => {
|
|
2931
|
+
return item.closest('[role="menu"]') === menuElement && !item.hasAttribute("disabled") && item.getAttribute("aria-disabled") !== "true";
|
|
2932
|
+
});
|
|
2933
|
+
};
|
|
2934
|
+
var PopoverMenu = forwardRef(({ children, label = "Menu", onClose }, ref) => {
|
|
2935
|
+
const menuRef = useRef(null);
|
|
2936
|
+
const setRefs = (node) => {
|
|
2937
|
+
menuRef.current = node;
|
|
2938
|
+
if (typeof ref === "function") {
|
|
2939
|
+
ref(node);
|
|
2940
|
+
} else if (ref) {
|
|
2941
|
+
ref.current = node;
|
|
2942
|
+
}
|
|
2943
|
+
};
|
|
2944
|
+
useEffect(() => {
|
|
2945
|
+
const focusTimer = window.requestAnimationFrame(() => {
|
|
2946
|
+
const menuItems = getMenuItems(menuRef.current);
|
|
2947
|
+
menuItems[0]?.focus();
|
|
2948
|
+
});
|
|
2949
|
+
return () => {
|
|
2950
|
+
window.cancelAnimationFrame(focusTimer);
|
|
2951
|
+
};
|
|
2952
|
+
}, []);
|
|
2953
|
+
const handleKeyDown = (event) => {
|
|
2954
|
+
const menuItems = getMenuItems(menuRef.current);
|
|
2955
|
+
const activeElement = document.activeElement;
|
|
2956
|
+
const currentIndex = menuItems.findIndex((item) => item === activeElement || item.contains(activeElement));
|
|
2957
|
+
if (event.key === "Escape") {
|
|
2958
|
+
event.preventDefault();
|
|
2959
|
+
onClose?.();
|
|
2960
|
+
return;
|
|
2961
|
+
}
|
|
2962
|
+
if (menuItems.length === 0) {
|
|
2963
|
+
return;
|
|
2964
|
+
}
|
|
2965
|
+
if (event.key === "ArrowDown") {
|
|
2966
|
+
event.preventDefault();
|
|
2967
|
+
const nextIndex = currentIndex < 0 ? 0 : (currentIndex + 1) % menuItems.length;
|
|
2968
|
+
menuItems[nextIndex]?.focus();
|
|
2969
|
+
return;
|
|
2970
|
+
}
|
|
2971
|
+
if (event.key === "ArrowUp") {
|
|
2972
|
+
event.preventDefault();
|
|
2973
|
+
const nextIndex = currentIndex < 0 ? menuItems.length - 1 : (currentIndex - 1 + menuItems.length) % menuItems.length;
|
|
2974
|
+
menuItems[nextIndex]?.focus();
|
|
2975
|
+
return;
|
|
2976
|
+
}
|
|
2977
|
+
if (event.key === "Home") {
|
|
2978
|
+
event.preventDefault();
|
|
2979
|
+
menuItems[0]?.focus();
|
|
2980
|
+
return;
|
|
2981
|
+
}
|
|
2982
|
+
if (event.key === "End") {
|
|
2983
|
+
event.preventDefault();
|
|
2984
|
+
menuItems[menuItems.length - 1]?.focus();
|
|
2985
|
+
}
|
|
2986
|
+
};
|
|
2987
|
+
return /* @__PURE__ */ jsx("div", { ref: setRefs, className: "popover-menu d-flex column gap-025", role: "menu", "aria-label": label, "aria-orientation": "vertical", onKeyDown: handleKeyDown, children });
|
|
2988
|
+
});
|
|
2989
|
+
PopoverMenu.displayName = "PopoverMenu";
|
|
2990
|
+
var PopoverMenu_default = PopoverMenu;
|
|
2991
|
+
var PopoverMenuItem = forwardRef(({
|
|
2992
|
+
icon,
|
|
2993
|
+
label,
|
|
2994
|
+
children,
|
|
2995
|
+
onClick,
|
|
2996
|
+
variant = "default",
|
|
2997
|
+
size: size2 = "md",
|
|
2998
|
+
disabled = false,
|
|
2999
|
+
isLoading = false,
|
|
3000
|
+
rightAdornment,
|
|
3001
|
+
role = "menuitem",
|
|
3002
|
+
ariaHaspopup,
|
|
3003
|
+
ariaExpanded,
|
|
3004
|
+
ariaControls,
|
|
3005
|
+
tabIndex = -1,
|
|
3006
|
+
onKeyDown,
|
|
3007
|
+
onBlur,
|
|
3008
|
+
onMouseEnter,
|
|
3009
|
+
onMouseLeave
|
|
3010
|
+
}, ref) => {
|
|
3011
|
+
const content = children ?? label;
|
|
3012
|
+
return /* @__PURE__ */ jsx(
|
|
3013
|
+
Button_default,
|
|
3014
|
+
{
|
|
3015
|
+
ref,
|
|
3016
|
+
variant: "ghost",
|
|
3017
|
+
intent: variant === "danger" ? "danger" : "neutral",
|
|
3018
|
+
size: size2,
|
|
3019
|
+
block: true,
|
|
3020
|
+
align: "start",
|
|
3021
|
+
className: `popover-menu-item popover-menu-item--${size2} radius-sm color-primary u-select-none cursor-pointer`,
|
|
3022
|
+
onClick: isLoading ? void 0 : onClick,
|
|
3023
|
+
disabled: disabled || isLoading,
|
|
3024
|
+
isLoading,
|
|
3025
|
+
role,
|
|
3026
|
+
"aria-haspopup": ariaHaspopup,
|
|
3027
|
+
"aria-expanded": ariaExpanded,
|
|
3028
|
+
"aria-controls": ariaControls,
|
|
3029
|
+
"aria-disabled": disabled || isLoading,
|
|
3030
|
+
tabIndex,
|
|
3031
|
+
onKeyDown,
|
|
3032
|
+
onBlur,
|
|
3033
|
+
onMouseEnter,
|
|
3034
|
+
onMouseLeave,
|
|
3035
|
+
"data-popover-menu-item": "true",
|
|
3036
|
+
leftIcon: icon ? /* @__PURE__ */ jsx("span", { className: "popover-menu-item-icon d-flex items-center content-center f-shrink-0", children: icon }) : void 0,
|
|
3037
|
+
children: /* @__PURE__ */ jsxs("span", { className: "popover-menu-item-content d-flex items-center content-between gap-05 w-max", children: [
|
|
3038
|
+
/* @__PURE__ */ jsx("span", { className: "popover-menu-item-label", children: content }),
|
|
3039
|
+
rightAdornment ? /* @__PURE__ */ jsx("span", { className: "popover-menu-item-adornment d-flex items-center content-center f-shrink-0", children: rightAdornment }) : null
|
|
3040
|
+
] })
|
|
3041
|
+
}
|
|
3042
|
+
);
|
|
3043
|
+
});
|
|
3044
|
+
PopoverMenuItem.displayName = "PopoverMenuItem";
|
|
3045
|
+
var PopoverMenuItem_default = PopoverMenuItem;
|
|
3046
|
+
var MISSING_MENU_NAME_ERROR = "Menu requires an accessible name via ariaLabel (or menuLabel) so assistive tech can announce the menu.";
|
|
3047
|
+
var FALLBACK_MENU_LABEL = "Menu";
|
|
3048
|
+
var isRenderProp = (value) => typeof value === "function";
|
|
3049
|
+
var Menu = forwardRef(({
|
|
3050
|
+
trigger,
|
|
3051
|
+
items,
|
|
3052
|
+
placement = "bottom-start",
|
|
3053
|
+
size: size2 = "md",
|
|
3054
|
+
id,
|
|
3055
|
+
ariaLabel,
|
|
3056
|
+
menuLabel = "Menu",
|
|
3057
|
+
triggerAriaLabel,
|
|
3058
|
+
emptyContent,
|
|
3059
|
+
onOpenChange,
|
|
3060
|
+
className,
|
|
3061
|
+
triggerClassName
|
|
3062
|
+
}, ref) => {
|
|
3063
|
+
const generatedId = useId();
|
|
3064
|
+
const popoverId = id ?? `menu-${generatedId}`;
|
|
3065
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
3066
|
+
const hasWarnedForMissingNameRef = useRef(false);
|
|
3067
|
+
const resolvedAriaLabel = ariaLabel?.trim() || menuLabel?.trim() || void 0;
|
|
3068
|
+
let accessibleName = resolvedAriaLabel;
|
|
3069
|
+
if (!accessibleName) {
|
|
3070
|
+
if (!hasWarnedForMissingNameRef.current) {
|
|
3071
|
+
console.warn(MISSING_MENU_NAME_ERROR);
|
|
3072
|
+
hasWarnedForMissingNameRef.current = true;
|
|
3073
|
+
}
|
|
3074
|
+
accessibleName = FALLBACK_MENU_LABEL;
|
|
3075
|
+
}
|
|
3076
|
+
const handleOpenChange = (nextOpen) => {
|
|
3077
|
+
setIsOpen(nextOpen);
|
|
3078
|
+
onOpenChange?.(nextOpen);
|
|
3079
|
+
};
|
|
3080
|
+
const triggerNode = isRenderProp(trigger) ? trigger({ isOpen }) : trigger;
|
|
3081
|
+
const triggerElement = /* @__PURE__ */ jsx(
|
|
3082
|
+
"span",
|
|
3083
|
+
{
|
|
3084
|
+
ref,
|
|
3085
|
+
className: cn("menu-trigger u-select-none cursor-pointer", triggerClassName),
|
|
3086
|
+
role: "button",
|
|
3087
|
+
tabIndex: isValidElement(triggerNode) ? -1 : 0,
|
|
3088
|
+
"aria-label": triggerAriaLabel,
|
|
3089
|
+
children: triggerNode
|
|
3090
|
+
}
|
|
3091
|
+
);
|
|
3092
|
+
const actionableItems = items.filter((item) => !item.divider);
|
|
3093
|
+
return /* @__PURE__ */ jsx(
|
|
3094
|
+
Popover_default,
|
|
3095
|
+
{
|
|
3096
|
+
id: popoverId,
|
|
3097
|
+
trigger: triggerElement,
|
|
3098
|
+
placement,
|
|
3099
|
+
role: "menu",
|
|
3100
|
+
triggerAriaHaspopup: "menu",
|
|
3101
|
+
ariaLabel: accessibleName,
|
|
3102
|
+
noPadding: true,
|
|
3103
|
+
className: cn("menu-popover", className),
|
|
3104
|
+
onOpenChange: handleOpenChange,
|
|
3105
|
+
children: (close) => /* @__PURE__ */ jsx(PopoverMenu_default, { label: accessibleName, onClose: close, children: actionableItems.length === 0 ? emptyContent ?? /* @__PURE__ */ jsx(Text_default, { as: "p", size: "sm", className: "menu-empty color-muted", role: "status", "aria-live": "polite", children: "No actions available" }) : items.map((item) => {
|
|
3106
|
+
if (item.divider) {
|
|
3107
|
+
return /* @__PURE__ */ jsx("div", { className: "menu-separator", role: "separator", "aria-hidden": "true" }, item.id);
|
|
3108
|
+
}
|
|
3109
|
+
return /* @__PURE__ */ jsx(
|
|
3110
|
+
PopoverMenuItem_default,
|
|
3111
|
+
{
|
|
3112
|
+
icon: item.icon,
|
|
3113
|
+
size: size2,
|
|
3114
|
+
variant: item.tone === "danger" ? "danger" : "default",
|
|
3115
|
+
disabled: item.disabled,
|
|
3116
|
+
onClick: () => {
|
|
3117
|
+
item.onSelect?.();
|
|
3118
|
+
close();
|
|
3119
|
+
},
|
|
3120
|
+
children: item.label
|
|
3121
|
+
},
|
|
3122
|
+
item.id
|
|
3123
|
+
);
|
|
3124
|
+
}) })
|
|
3125
|
+
}
|
|
3126
|
+
);
|
|
3127
|
+
});
|
|
3128
|
+
Menu.displayName = "Menu";
|
|
3129
|
+
var Menu_default = Menu;
|
|
3130
|
+
var Tooltip = ({
|
|
3131
|
+
children,
|
|
3132
|
+
content,
|
|
3133
|
+
placement = "top",
|
|
3134
|
+
delay = 300,
|
|
3135
|
+
disabled = false,
|
|
3136
|
+
className = ""
|
|
3137
|
+
}) => {
|
|
3138
|
+
const [isVisible, setIsVisible] = useState(false);
|
|
3139
|
+
const floatingRoot = useFloatingRoot();
|
|
3140
|
+
const tooltipId = useId();
|
|
3141
|
+
const { refs, floatingStyles, context, placement: actualPlacement } = useFloating({
|
|
3142
|
+
open: isVisible,
|
|
3143
|
+
onOpenChange: setIsVisible,
|
|
3144
|
+
placement,
|
|
3145
|
+
middleware: [
|
|
3146
|
+
offset(8),
|
|
3147
|
+
flip({ padding: 8 }),
|
|
3148
|
+
shift({ padding: 8 })
|
|
3149
|
+
],
|
|
3150
|
+
whileElementsMounted: autoUpdate
|
|
3151
|
+
});
|
|
3152
|
+
const hover = useHover(context, {
|
|
3153
|
+
delay: {
|
|
3154
|
+
open: delay,
|
|
3155
|
+
close: 0
|
|
3156
|
+
},
|
|
3157
|
+
enabled: !disabled
|
|
3158
|
+
});
|
|
3159
|
+
const focus = useFocus(context, {
|
|
3160
|
+
enabled: !disabled
|
|
3161
|
+
});
|
|
3162
|
+
const dismiss = useDismiss(context);
|
|
3163
|
+
const role = useRole(context, { role: "tooltip" });
|
|
3164
|
+
const { getReferenceProps, getFloatingProps } = useInteractions([
|
|
3165
|
+
hover,
|
|
3166
|
+
focus,
|
|
3167
|
+
dismiss,
|
|
3168
|
+
role
|
|
3169
|
+
]);
|
|
3170
|
+
if (!content) return /* @__PURE__ */ jsx(Fragment, { children });
|
|
3171
|
+
const child = React.Children.only(children);
|
|
3172
|
+
if (!isValidElement(child)) {
|
|
3173
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
3174
|
+
}
|
|
3175
|
+
const triggerElement = child;
|
|
3176
|
+
const placementSide = actualPlacement.split("-")[0];
|
|
3177
|
+
const childProps = triggerElement.props;
|
|
3178
|
+
const originalRef = childProps.ref;
|
|
3179
|
+
const childDescribedBy = typeof childProps["aria-describedby"] === "string" ? childProps["aria-describedby"] : void 0;
|
|
3180
|
+
const describedBy = [childDescribedBy, tooltipId].filter(Boolean).join(" ") || void 0;
|
|
3181
|
+
const clonedChild = cloneElement(triggerElement, {
|
|
3182
|
+
ref: compose_refs_default(refs.setReference, originalRef),
|
|
3183
|
+
"aria-describedby": describedBy,
|
|
3184
|
+
...getReferenceProps(childProps)
|
|
3185
|
+
});
|
|
3186
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3187
|
+
clonedChild,
|
|
3188
|
+
isVisible && /* @__PURE__ */ jsx(FloatingPortal, { root: floatingRoot, children: /* @__PURE__ */ jsx(
|
|
3189
|
+
"div",
|
|
3190
|
+
{
|
|
3191
|
+
ref: refs.setFloating,
|
|
3192
|
+
id: tooltipId,
|
|
3193
|
+
className: `volt-tooltip volt-tooltip-${placementSide} ${className} overflow-hidden`,
|
|
3194
|
+
style: floatingStyles,
|
|
3195
|
+
role: "tooltip",
|
|
3196
|
+
...getFloatingProps(),
|
|
3197
|
+
children: content
|
|
3198
|
+
}
|
|
3199
|
+
) })
|
|
3200
|
+
] });
|
|
3201
|
+
};
|
|
3202
|
+
var Tooltip_default = Tooltip;
|
|
3203
|
+
var createVirtualCursorRect = (x, y) => ({
|
|
3204
|
+
x,
|
|
3205
|
+
y,
|
|
3206
|
+
top: y,
|
|
3207
|
+
right: x,
|
|
3208
|
+
bottom: y,
|
|
3209
|
+
left: x,
|
|
3210
|
+
width: 0,
|
|
3211
|
+
height: 0
|
|
3212
|
+
});
|
|
3213
|
+
var CursorTooltip = ({
|
|
3214
|
+
isOpen,
|
|
3215
|
+
x,
|
|
3216
|
+
y,
|
|
3217
|
+
content,
|
|
3218
|
+
className = "",
|
|
3219
|
+
autoPosition = true,
|
|
3220
|
+
interactive = false,
|
|
3221
|
+
offset: cursorOffset = 16,
|
|
3222
|
+
ariaLabel = "Additional details"
|
|
3223
|
+
}) => {
|
|
3224
|
+
const arrowOffset = cursorOffset;
|
|
3225
|
+
const floatingRoot = useFloatingRoot();
|
|
3226
|
+
const prefersReducedMotion = usePrefersReducedMotion();
|
|
3227
|
+
const reactId = useId();
|
|
3228
|
+
const tooltipId = `cursor-tooltip-${reactId}`;
|
|
3229
|
+
const virtualElementRef = useRef({
|
|
3230
|
+
getBoundingClientRect: () => createVirtualCursorRect(x, y)
|
|
3231
|
+
});
|
|
3232
|
+
const middleware = [offset({ mainAxis: arrowOffset, crossAxis: arrowOffset })];
|
|
3233
|
+
if (autoPosition) {
|
|
3234
|
+
middleware.push(flip({ padding: 16 }));
|
|
3235
|
+
middleware.push(shift({ padding: 16 }));
|
|
3236
|
+
}
|
|
3237
|
+
const { refs, floatingStyles } = useFloating({
|
|
3238
|
+
open: isOpen,
|
|
3239
|
+
placement: "right-start",
|
|
3240
|
+
middleware,
|
|
3241
|
+
whileElementsMounted: autoUpdate
|
|
3242
|
+
});
|
|
3243
|
+
useEffect(() => {
|
|
3244
|
+
virtualElementRef.current.getBoundingClientRect = () => createVirtualCursorRect(x, y);
|
|
3245
|
+
refs.setPositionReference(virtualElementRef.current);
|
|
3246
|
+
}, [x, y, refs]);
|
|
3247
|
+
if (!isOpen) return null;
|
|
3248
|
+
return /* @__PURE__ */ jsx(FloatingPortal, { root: floatingRoot, children: /* @__PURE__ */ jsx(
|
|
3249
|
+
"div",
|
|
3250
|
+
{
|
|
3251
|
+
ref: refs.setFloating,
|
|
3252
|
+
className: `cursor-tooltip visible ${interactive ? "interactive" : ""} ${className}`,
|
|
3253
|
+
style: floatingStyles,
|
|
3254
|
+
id: tooltipId,
|
|
3255
|
+
role: interactive ? "dialog" : "tooltip",
|
|
3256
|
+
"aria-label": interactive ? ariaLabel : void 0,
|
|
3257
|
+
"aria-modal": interactive ? false : void 0,
|
|
3258
|
+
tabIndex: interactive ? -1 : void 0,
|
|
3259
|
+
"data-reduced-motion": prefersReducedMotion ? "true" : "false",
|
|
3260
|
+
children: content
|
|
3261
|
+
}
|
|
3262
|
+
) });
|
|
3263
|
+
};
|
|
3264
|
+
var CursorTooltip_default = CursorTooltip;
|
|
3265
|
+
var FloatingToolbar = forwardRef(({
|
|
3266
|
+
placement = "top",
|
|
3267
|
+
align = "center",
|
|
3268
|
+
offset: offset5 = 1,
|
|
3269
|
+
className,
|
|
3270
|
+
style,
|
|
3271
|
+
children,
|
|
3272
|
+
role = "toolbar",
|
|
3273
|
+
...rest
|
|
3274
|
+
}, ref) => {
|
|
3275
|
+
const classes = cn(
|
|
3276
|
+
"volt-floating-toolbar",
|
|
3277
|
+
`volt-floating-toolbar--${placement}`,
|
|
3278
|
+
`volt-floating-toolbar--align-${align}`,
|
|
3279
|
+
"glass-bg",
|
|
3280
|
+
className
|
|
3281
|
+
);
|
|
3282
|
+
const anchorStyle = {
|
|
3283
|
+
...style,
|
|
3284
|
+
[placement]: `${offset5}rem`
|
|
3285
|
+
};
|
|
3286
|
+
return /* @__PURE__ */ jsx("div", { ref, role, className: classes, style: anchorStyle, ...rest, children });
|
|
3287
|
+
});
|
|
3288
|
+
FloatingToolbar.displayName = "FloatingToolbar";
|
|
3289
|
+
var FloatingToolbar_default = FloatingToolbar;
|
|
3290
|
+
var Tag = forwardRef(({
|
|
3291
|
+
tone = "neutral",
|
|
3292
|
+
size: size2 = "sm",
|
|
3293
|
+
variant = "soft",
|
|
3294
|
+
shape = "pill",
|
|
3295
|
+
leftIcon,
|
|
3296
|
+
rightIcon,
|
|
3297
|
+
className,
|
|
3298
|
+
children,
|
|
3299
|
+
...rest
|
|
3300
|
+
}, ref) => {
|
|
3301
|
+
const classes = cn(
|
|
3302
|
+
"volt-tag",
|
|
3303
|
+
`volt-tag--tone-${tone}`,
|
|
3304
|
+
`volt-tag--size-${size2}`,
|
|
3305
|
+
`volt-tag--variant-${variant}`,
|
|
3306
|
+
`volt-tag--shape-${shape}`,
|
|
3307
|
+
className
|
|
3308
|
+
);
|
|
3309
|
+
return /* @__PURE__ */ jsxs("span", { ref, className: classes, ...rest, children: [
|
|
3310
|
+
leftIcon && /* @__PURE__ */ jsx("span", { className: "volt-tag__icon", "aria-hidden": "true", children: leftIcon }),
|
|
3311
|
+
/* @__PURE__ */ jsx("span", { className: "volt-tag__label", children }),
|
|
3312
|
+
rightIcon && /* @__PURE__ */ jsx("span", { className: "volt-tag__icon", "aria-hidden": "true", children: rightIcon })
|
|
3313
|
+
] });
|
|
3314
|
+
});
|
|
3315
|
+
Tag.displayName = "Tag";
|
|
3316
|
+
var Tag_default = Tag;
|
|
3317
|
+
var STATUS_VARIANTS = {
|
|
3318
|
+
ready: "success",
|
|
3319
|
+
completed: "success",
|
|
3320
|
+
success: "success",
|
|
3321
|
+
active: "success",
|
|
3322
|
+
published: "success",
|
|
3323
|
+
healthy: "success",
|
|
3324
|
+
online: "success",
|
|
3325
|
+
accepted: "success",
|
|
3326
|
+
connected: "success",
|
|
3327
|
+
processing: "warning",
|
|
3328
|
+
queued: "warning",
|
|
3329
|
+
rendering: "warning",
|
|
3330
|
+
warning: "warning",
|
|
3331
|
+
pending: "warning",
|
|
3332
|
+
"waiting-for-process": "warning",
|
|
3333
|
+
analyzing: "warning",
|
|
3334
|
+
running: "active",
|
|
3335
|
+
failed: "danger",
|
|
3336
|
+
error: "danger",
|
|
3337
|
+
danger: "danger",
|
|
3338
|
+
critical: "danger",
|
|
3339
|
+
rejected: "danger",
|
|
3340
|
+
inactive: "inactive",
|
|
3341
|
+
draft: "inactive",
|
|
3342
|
+
disabled: "inactive",
|
|
3343
|
+
offline: "inactive",
|
|
3344
|
+
disconnected: "inactive",
|
|
3345
|
+
brand: "brand",
|
|
3346
|
+
primary: "primary"
|
|
3347
|
+
};
|
|
3348
|
+
var statusToVariant = (status) => {
|
|
3349
|
+
return STATUS_VARIANTS[status.toLowerCase()] ?? "neutral";
|
|
3350
|
+
};
|
|
3351
|
+
var StatusBadge = forwardRef(({ status, variant, size: size2 = "default", children, className = "" }, ref) => {
|
|
3352
|
+
const computedVariant = variant ?? (status ? statusToVariant(status) : "neutral");
|
|
3353
|
+
const content = children ?? status;
|
|
3354
|
+
const classes = cn(
|
|
3355
|
+
"status-badge",
|
|
3356
|
+
"radius-full",
|
|
3357
|
+
`variant-${computedVariant}`,
|
|
3358
|
+
size2 !== "default" && `size-${size2}`,
|
|
3359
|
+
"gap-025",
|
|
3360
|
+
"font-size-1",
|
|
3361
|
+
"font-weight-5",
|
|
3362
|
+
className
|
|
3363
|
+
);
|
|
3364
|
+
return /* @__PURE__ */ jsx("span", { ref, className: classes, children: content });
|
|
3365
|
+
});
|
|
3366
|
+
StatusBadge.displayName = "StatusBadge";
|
|
3367
|
+
var StatusBadge_default = StatusBadge;
|
|
3368
|
+
var StatusDot = forwardRef(({
|
|
3369
|
+
tone = "neutral",
|
|
3370
|
+
size: size2 = "sm",
|
|
3371
|
+
className = "",
|
|
3372
|
+
label,
|
|
3373
|
+
pulse = false,
|
|
3374
|
+
glow = false
|
|
3375
|
+
}, ref) => {
|
|
3376
|
+
const classes = cn(
|
|
3377
|
+
"status-dot",
|
|
3378
|
+
"radius-full",
|
|
3379
|
+
"f-shrink-0",
|
|
3380
|
+
`size-${size2}`,
|
|
3381
|
+
`status-dot--tone-${tone}`,
|
|
3382
|
+
pulse && "status-dot--pulse",
|
|
3383
|
+
glow && "status-dot--glow",
|
|
3384
|
+
className
|
|
3385
|
+
);
|
|
3386
|
+
return /* @__PURE__ */ jsx(
|
|
3387
|
+
"span",
|
|
3388
|
+
{
|
|
3389
|
+
ref,
|
|
3390
|
+
className: classes,
|
|
3391
|
+
role: "status",
|
|
3392
|
+
"aria-label": label ?? `${tone} status`
|
|
3393
|
+
}
|
|
3394
|
+
);
|
|
3395
|
+
});
|
|
3396
|
+
StatusDot.displayName = "StatusDot";
|
|
3397
|
+
var StatusDot_default = StatusDot;
|
|
3398
|
+
var toneClass = {
|
|
3399
|
+
neutral: "color-primary",
|
|
3400
|
+
muted: "color-muted",
|
|
3401
|
+
success: "status-success",
|
|
3402
|
+
warning: "status-warning",
|
|
3403
|
+
danger: "status-error"
|
|
3404
|
+
};
|
|
3405
|
+
var InlineStatus = forwardRef(({
|
|
3406
|
+
tone = "neutral",
|
|
3407
|
+
icon,
|
|
3408
|
+
live = "polite",
|
|
3409
|
+
severity = "status",
|
|
3410
|
+
className,
|
|
3411
|
+
children,
|
|
3412
|
+
...rest
|
|
3413
|
+
}, ref) => {
|
|
3414
|
+
const textTone = tone === "muted" ? "muted" : tone === "neutral" ? "secondary" : void 0;
|
|
3415
|
+
const inlineStyle = tone !== "neutral" && tone !== "muted" ? { color: `var(--${toneClass[tone]})` } : void 0;
|
|
3416
|
+
return /* @__PURE__ */ jsxs(
|
|
3417
|
+
Row_default,
|
|
3418
|
+
{
|
|
3419
|
+
ref,
|
|
3420
|
+
gap: "05",
|
|
3421
|
+
role: severity,
|
|
3422
|
+
"aria-live": live,
|
|
3423
|
+
"aria-atomic": "true",
|
|
3424
|
+
className: cn("font-size-1", className),
|
|
3425
|
+
style: inlineStyle,
|
|
3426
|
+
...rest,
|
|
3427
|
+
children: [
|
|
3428
|
+
icon && /* @__PURE__ */ jsx("span", { className: "d-flex items-center", "aria-hidden": "true", children: icon }),
|
|
3429
|
+
/* @__PURE__ */ jsx(Text_default, { as: "span", size: "sm", tone: textTone, children })
|
|
3430
|
+
]
|
|
3431
|
+
}
|
|
3432
|
+
);
|
|
3433
|
+
});
|
|
3434
|
+
InlineStatus.displayName = "InlineStatus";
|
|
3435
|
+
var InlineStatus_default = InlineStatus;
|
|
3436
|
+
var SaveStatusIndicator = forwardRef(({
|
|
3437
|
+
status,
|
|
3438
|
+
savingLabel = "Saving\u2026",
|
|
3439
|
+
savedLabel = "Saved",
|
|
3440
|
+
errorLabel = "Save failed",
|
|
3441
|
+
hideIdle = true,
|
|
3442
|
+
className,
|
|
3443
|
+
...rest
|
|
3444
|
+
}, ref) => {
|
|
3445
|
+
if (hideIdle && status === "idle") return null;
|
|
3446
|
+
const tone = status === "saved" ? "muted" : "secondary";
|
|
3447
|
+
const errorStyle = status === "error" ? { color: "var(--status-error)" } : void 0;
|
|
3448
|
+
return /* @__PURE__ */ jsxs(
|
|
3449
|
+
Row_default,
|
|
3450
|
+
{
|
|
3451
|
+
ref,
|
|
3452
|
+
gap: "025",
|
|
3453
|
+
role: "status",
|
|
3454
|
+
"aria-live": "polite",
|
|
3455
|
+
"aria-atomic": "true",
|
|
3456
|
+
className: cn("font-size-1", className),
|
|
3457
|
+
style: errorStyle,
|
|
3458
|
+
...rest,
|
|
3459
|
+
children: [
|
|
3460
|
+
status === "saving" && /* @__PURE__ */ jsx(Loader_default, { scale: 0.35, isFixed: false }),
|
|
3461
|
+
status === "saved" && /* @__PURE__ */ jsx(Check, { size: 12, "aria-hidden": "true" }),
|
|
3462
|
+
status === "error" && /* @__PURE__ */ jsx(AlertCircle, { size: 12, "aria-hidden": "true" }),
|
|
3463
|
+
/* @__PURE__ */ jsxs(Text_default, { as: "span", size: "sm", tone: status === "error" ? void 0 : tone, children: [
|
|
3464
|
+
status === "saving" && savingLabel,
|
|
3465
|
+
status === "saved" && savedLabel,
|
|
3466
|
+
status === "error" && errorLabel
|
|
3467
|
+
] })
|
|
3468
|
+
]
|
|
3469
|
+
}
|
|
3470
|
+
);
|
|
3471
|
+
});
|
|
3472
|
+
SaveStatusIndicator.displayName = "SaveStatusIndicator";
|
|
3473
|
+
var SaveStatusIndicator_default = SaveStatusIndicator;
|
|
3474
|
+
|
|
3475
|
+
// src/shared/utils/user.ts
|
|
3476
|
+
var getInitialsFromUser = (user) => {
|
|
3477
|
+
if (!user || typeof user === "string") return "?";
|
|
3478
|
+
if (user.firstName && user.lastName) {
|
|
3479
|
+
return (user.firstName[0] + user.lastName[0]).toUpperCase();
|
|
3480
|
+
}
|
|
3481
|
+
if (user.email) {
|
|
3482
|
+
const parts = user.email.split("@")[0].split(".");
|
|
3483
|
+
if (parts.length >= 2) {
|
|
3484
|
+
return (parts[0][0] + parts[1][0]).toUpperCase();
|
|
3485
|
+
}
|
|
3486
|
+
return user.email[0].toUpperCase();
|
|
3487
|
+
}
|
|
3488
|
+
return "?";
|
|
3489
|
+
};
|
|
3490
|
+
var Avatar = forwardRef(({
|
|
3491
|
+
src,
|
|
3492
|
+
alt,
|
|
3493
|
+
fallback,
|
|
3494
|
+
user,
|
|
3495
|
+
size: size2 = "md",
|
|
3496
|
+
className = "",
|
|
3497
|
+
isOnline = false,
|
|
3498
|
+
showStatus = false,
|
|
3499
|
+
icon
|
|
3500
|
+
}, ref) => {
|
|
3501
|
+
const imageSrc = src ?? user?.avatar;
|
|
3502
|
+
const initials = fallback ?? (user ? getInitialsFromUser(user) : "?");
|
|
3503
|
+
const altText = alt ?? (user ? `${user.firstName ?? ""} ${user.lastName ?? ""}`.trim() : "Avatar");
|
|
3504
|
+
return /* @__PURE__ */ jsxs("div", { ref, className: `${cn("avatar", `avatar-${size2}`, "d-flex flex-center radius-full overflow-hidden f-shrink-0 p-relative", className)}`, children: [
|
|
3505
|
+
icon ? /* @__PURE__ */ jsx("div", { className: "avatar-icon d-flex flex-center", children: icon }) : imageSrc ? /* @__PURE__ */ jsx("img", { src: imageSrc, alt: altText, className: "w-max h-max avatar-image" }) : /* @__PURE__ */ jsx("p", { className: "avatar-initials font-weight-6", children: initials }),
|
|
3506
|
+
showStatus && /* @__PURE__ */ jsx(StatusDot_default, { tone: isOnline ? "success" : "neutral", className: "avatar-status p-absolute bottom-0 right-0" })
|
|
3507
|
+
] });
|
|
3508
|
+
});
|
|
3509
|
+
Avatar.displayName = "Avatar";
|
|
3510
|
+
var Avatar_default = Avatar;
|
|
3511
|
+
var AvatarStack = forwardRef(({ users, maxDisplay = 3, size: size2 = "sm", className = "" }, ref) => {
|
|
3512
|
+
if (users.length === 0) return null;
|
|
3513
|
+
const displayedUsers = users.slice(0, maxDisplay);
|
|
3514
|
+
const remainingCount = users.length - maxDisplay;
|
|
3515
|
+
return /* @__PURE__ */ jsxs(Row_default, { ref, className: `avatar-stack ${className}`, children: [
|
|
3516
|
+
displayedUsers.map((user, index) => /* @__PURE__ */ jsx(
|
|
3517
|
+
Avatar_default,
|
|
3518
|
+
{
|
|
3519
|
+
user,
|
|
3520
|
+
size: size2,
|
|
3521
|
+
className: "avatar-stack-item"
|
|
3522
|
+
},
|
|
3523
|
+
user._id ?? user.id ?? index
|
|
3524
|
+
)),
|
|
3525
|
+
remainingCount > 0 && /* @__PURE__ */ jsx("div", { className: `avatar-stack-overflow avatar avatar-${size2} d-flex flex-center radius-full`, children: /* @__PURE__ */ jsxs(Text_default, { as: "p", weight: "bold", className: "avatar-initials", children: [
|
|
3526
|
+
"+",
|
|
3527
|
+
remainingCount
|
|
3528
|
+
] }) })
|
|
3529
|
+
] });
|
|
3530
|
+
});
|
|
3531
|
+
AvatarStack.displayName = "AvatarStack";
|
|
3532
|
+
var AvatarStack_default = AvatarStack;
|
|
3533
|
+
var IconFrame = forwardRef(({
|
|
3534
|
+
size: size2 = "md",
|
|
3535
|
+
tone = "neutral",
|
|
3536
|
+
shape = "square",
|
|
3537
|
+
className,
|
|
3538
|
+
children,
|
|
3539
|
+
...rest
|
|
3540
|
+
}, ref) => {
|
|
3541
|
+
const classes = cn(
|
|
3542
|
+
"volt-icon-frame",
|
|
3543
|
+
`volt-icon-frame--size-${size2}`,
|
|
3544
|
+
`volt-icon-frame--tone-${tone}`,
|
|
3545
|
+
`volt-icon-frame--shape-${shape}`,
|
|
3546
|
+
className
|
|
3547
|
+
);
|
|
3548
|
+
return /* @__PURE__ */ jsx("div", { ref, className: classes, "aria-hidden": "true", ...rest, children });
|
|
3549
|
+
});
|
|
3550
|
+
IconFrame.displayName = "IconFrame";
|
|
3551
|
+
var IconFrame_default = IconFrame;
|
|
3552
|
+
var MISSING_INTERACTIVE_NAME_ERROR = "Card with `interactive` requires an accessible name via aria-label or aria-labelledby.";
|
|
3553
|
+
var SURFACE_VARIANT = {
|
|
3554
|
+
elevated: "elevated",
|
|
3555
|
+
glass: "glass",
|
|
3556
|
+
plain: void 0
|
|
3557
|
+
};
|
|
3558
|
+
var Card = forwardRef(({
|
|
3559
|
+
variant = "elevated",
|
|
3560
|
+
interactive = false,
|
|
3561
|
+
selected = false,
|
|
3562
|
+
padding = "none",
|
|
3563
|
+
as,
|
|
3564
|
+
className,
|
|
3565
|
+
children,
|
|
3566
|
+
onKeyDown,
|
|
3567
|
+
role,
|
|
3568
|
+
tabIndex,
|
|
3569
|
+
"aria-label": ariaLabel,
|
|
3570
|
+
"aria-labelledby": ariaLabelledBy,
|
|
3571
|
+
...rest
|
|
3572
|
+
}, ref) => {
|
|
3573
|
+
const hasWarnedForMissingNameRef = useRef(false);
|
|
3574
|
+
const Component = as ?? (interactive ? "button" : "div");
|
|
3575
|
+
const isNativeButton = interactive && Component === "button";
|
|
3576
|
+
const resolvedAriaLabel = ariaLabel?.trim() || void 0;
|
|
3577
|
+
const resolvedAriaLabelledBy = ariaLabelledBy?.trim() || void 0;
|
|
3578
|
+
if (interactive && !resolvedAriaLabel && !resolvedAriaLabelledBy) {
|
|
3579
|
+
if (!hasWarnedForMissingNameRef.current) {
|
|
3580
|
+
console.warn(MISSING_INTERACTIVE_NAME_ERROR);
|
|
3581
|
+
hasWarnedForMissingNameRef.current = true;
|
|
3582
|
+
}
|
|
3583
|
+
}
|
|
3584
|
+
const classes = cn(
|
|
3585
|
+
"volt-card",
|
|
3586
|
+
`volt-card--${variant}`,
|
|
3587
|
+
interactive && "volt-card--interactive",
|
|
3588
|
+
selected && "volt-card--selected",
|
|
3589
|
+
padding !== "none" && `volt-card--pad-${padding}`,
|
|
3590
|
+
className
|
|
3591
|
+
);
|
|
3592
|
+
const needsButtonSemantics = interactive && !isNativeButton;
|
|
3593
|
+
const handleKeyDown = needsButtonSemantics ? (event) => {
|
|
3594
|
+
onKeyDown?.(event);
|
|
3595
|
+
if (event.defaultPrevented) return;
|
|
3596
|
+
if (event.key === "Enter" || event.key === " " || event.key === "Spacebar") {
|
|
3597
|
+
event.preventDefault();
|
|
3598
|
+
event.currentTarget.click();
|
|
3599
|
+
}
|
|
3600
|
+
} : onKeyDown;
|
|
3601
|
+
const interactiveProps = interactive ? {
|
|
3602
|
+
role: needsButtonSemantics ? role ?? "button" : role,
|
|
3603
|
+
tabIndex: needsButtonSemantics ? tabIndex ?? 0 : tabIndex,
|
|
3604
|
+
...isNativeButton ? { type: "button" } : {},
|
|
3605
|
+
"aria-label": resolvedAriaLabel,
|
|
3606
|
+
"aria-labelledby": resolvedAriaLabelledBy,
|
|
3607
|
+
"aria-selected": selected || void 0,
|
|
3608
|
+
onKeyDown: handleKeyDown
|
|
3609
|
+
} : {
|
|
3610
|
+
role,
|
|
3611
|
+
tabIndex,
|
|
3612
|
+
"aria-label": resolvedAriaLabel,
|
|
3613
|
+
"aria-labelledby": resolvedAriaLabelledBy,
|
|
3614
|
+
onKeyDown
|
|
3615
|
+
};
|
|
3616
|
+
return /* @__PURE__ */ jsx(
|
|
3617
|
+
Surface_default,
|
|
3618
|
+
{
|
|
3619
|
+
ref,
|
|
3620
|
+
as: Component,
|
|
3621
|
+
variant: SURFACE_VARIANT[variant],
|
|
3622
|
+
className: classes,
|
|
3623
|
+
...interactiveProps,
|
|
3624
|
+
...rest,
|
|
3625
|
+
children
|
|
3626
|
+
}
|
|
3627
|
+
);
|
|
3628
|
+
});
|
|
3629
|
+
Card.displayName = "Card";
|
|
3630
|
+
var CardHeader = forwardRef(({
|
|
3631
|
+
as,
|
|
3632
|
+
className,
|
|
3633
|
+
children,
|
|
3634
|
+
...rest
|
|
3635
|
+
}, ref) => {
|
|
3636
|
+
const Component = as ?? "div";
|
|
3637
|
+
return /* @__PURE__ */ jsx(
|
|
3638
|
+
Component,
|
|
3639
|
+
{
|
|
3640
|
+
ref,
|
|
3641
|
+
className: cn("volt-card__header", "panel-header-bordered", className),
|
|
3642
|
+
...rest,
|
|
3643
|
+
children
|
|
3644
|
+
}
|
|
3645
|
+
);
|
|
3646
|
+
});
|
|
3647
|
+
CardHeader.displayName = "Card.Header";
|
|
3648
|
+
var CardBody = forwardRef(({
|
|
3649
|
+
as,
|
|
3650
|
+
padding = "md",
|
|
3651
|
+
className,
|
|
3652
|
+
children,
|
|
3653
|
+
...rest
|
|
3654
|
+
}, ref) => {
|
|
3655
|
+
const Component = as ?? "div";
|
|
3656
|
+
return /* @__PURE__ */ jsx(
|
|
3657
|
+
Component,
|
|
3658
|
+
{
|
|
3659
|
+
ref,
|
|
3660
|
+
className: cn(
|
|
3661
|
+
"volt-card__body",
|
|
3662
|
+
padding !== "none" && `volt-card__body--pad-${padding}`,
|
|
3663
|
+
className
|
|
3664
|
+
),
|
|
3665
|
+
...rest,
|
|
3666
|
+
children
|
|
3667
|
+
}
|
|
3668
|
+
);
|
|
3669
|
+
});
|
|
3670
|
+
CardBody.displayName = "Card.Body";
|
|
3671
|
+
var CardFooter = forwardRef(({
|
|
3672
|
+
as,
|
|
3673
|
+
className,
|
|
3674
|
+
children,
|
|
3675
|
+
...rest
|
|
3676
|
+
}, ref) => {
|
|
3677
|
+
const Component = as ?? "div";
|
|
3678
|
+
return /* @__PURE__ */ jsx(
|
|
3679
|
+
Component,
|
|
3680
|
+
{
|
|
3681
|
+
ref,
|
|
3682
|
+
className: cn("volt-card__footer", "panel-footer-bordered", className),
|
|
3683
|
+
...rest,
|
|
3684
|
+
children
|
|
3685
|
+
}
|
|
3686
|
+
);
|
|
3687
|
+
});
|
|
3688
|
+
CardFooter.displayName = "Card.Footer";
|
|
3689
|
+
var CardWithSlots = Card;
|
|
3690
|
+
CardWithSlots.Header = CardHeader;
|
|
3691
|
+
CardWithSlots.Body = CardBody;
|
|
3692
|
+
CardWithSlots.Footer = CardFooter;
|
|
3693
|
+
var Card_default = CardWithSlots;
|
|
3694
|
+
var toCssSize = (value) => {
|
|
3695
|
+
if (value === void 0) return void 0;
|
|
3696
|
+
if (typeof value === "number") return `${value}px`;
|
|
3697
|
+
return value;
|
|
3698
|
+
};
|
|
3699
|
+
var Skeleton = forwardRef(({
|
|
3700
|
+
variant = "text",
|
|
3701
|
+
animation = "pulse",
|
|
3702
|
+
width,
|
|
3703
|
+
height,
|
|
3704
|
+
className = "",
|
|
3705
|
+
style
|
|
3706
|
+
}, ref) => {
|
|
3707
|
+
const classes = cn(
|
|
3708
|
+
"volt-skeleton",
|
|
3709
|
+
`volt-skeleton--${variant}`,
|
|
3710
|
+
`volt-skeleton--${animation}`,
|
|
3711
|
+
className
|
|
3712
|
+
);
|
|
3713
|
+
const resolvedStyle = {
|
|
3714
|
+
...style,
|
|
3715
|
+
width: toCssSize(width) ?? style?.width,
|
|
3716
|
+
height: toCssSize(height) ?? style?.height
|
|
3717
|
+
};
|
|
3718
|
+
return /* @__PURE__ */ jsx(
|
|
3719
|
+
"span",
|
|
3720
|
+
{
|
|
3721
|
+
ref,
|
|
3722
|
+
className: classes,
|
|
3723
|
+
style: resolvedStyle,
|
|
3724
|
+
"aria-hidden": "true",
|
|
3725
|
+
"data-variant": variant,
|
|
3726
|
+
"data-animation": animation
|
|
3727
|
+
}
|
|
3728
|
+
);
|
|
3729
|
+
});
|
|
3730
|
+
Skeleton.displayName = "Skeleton";
|
|
3731
|
+
var Skeleton_default = Skeleton;
|
|
3732
|
+
var StatCard = forwardRef(({
|
|
3733
|
+
label,
|
|
3734
|
+
value,
|
|
3735
|
+
unit,
|
|
3736
|
+
icon,
|
|
3737
|
+
trend,
|
|
3738
|
+
footer,
|
|
3739
|
+
tone = "neutral",
|
|
3740
|
+
state = "ready",
|
|
3741
|
+
tabular = true,
|
|
3742
|
+
surface = "soft",
|
|
3743
|
+
className,
|
|
3744
|
+
...rest
|
|
3745
|
+
}, ref) => {
|
|
3746
|
+
const classes = cn(
|
|
3747
|
+
"volt-stat-card",
|
|
3748
|
+
`volt-stat-card--tone-${tone}`,
|
|
3749
|
+
surface === "elevated" ? "card-elevated" : "b-soft radius-md",
|
|
3750
|
+
"p-1-5",
|
|
3751
|
+
className
|
|
3752
|
+
);
|
|
3753
|
+
return /* @__PURE__ */ jsxs(Stack_default, { ref, gap: "075", className: classes, ...rest, children: [
|
|
3754
|
+
/* @__PURE__ */ jsxs(Row_default, { gap: "05", align: "center", children: [
|
|
3755
|
+
icon && /* @__PURE__ */ jsx("span", { className: "volt-stat-card__icon", "aria-hidden": "true", children: icon }),
|
|
3756
|
+
/* @__PURE__ */ jsx(SectionLabel_default, { className: "volt-stat-card__label", children: label })
|
|
3757
|
+
] }),
|
|
3758
|
+
state === "loading" ? /* @__PURE__ */ jsx(Skeleton_default, { variant: "text", width: "60%", height: 28, animation: "wave" }) : /* @__PURE__ */ jsxs(Row_default, { gap: "05", className: cn("items-baseline", tabular && "tabular-nums"), children: [
|
|
3759
|
+
value !== void 0 && value !== null && /* @__PURE__ */ jsx(Text_default, { as: "span", size: "3xl", weight: "bold", tone: "primary", className: "volt-stat-card__value", children: value }),
|
|
3760
|
+
unit && /* @__PURE__ */ jsx(Text_default, { as: "span", size: "md", tone: "muted", className: "volt-stat-card__unit", children: unit }),
|
|
3761
|
+
trend && /* @__PURE__ */ jsx("span", { className: "volt-stat-card__trend", children: trend })
|
|
3762
|
+
] }),
|
|
3763
|
+
footer && /* @__PURE__ */ jsx("div", { className: "volt-stat-card__footer", children: footer })
|
|
3764
|
+
] });
|
|
3765
|
+
});
|
|
3766
|
+
StatCard.displayName = "StatCard";
|
|
3767
|
+
var StatCard_default = StatCard;
|
|
3768
|
+
var SelectableCard = forwardRef(({
|
|
3769
|
+
title,
|
|
3770
|
+
description,
|
|
3771
|
+
icon,
|
|
3772
|
+
iconTone = "brand",
|
|
3773
|
+
selected = false,
|
|
3774
|
+
badge,
|
|
3775
|
+
selectionRole,
|
|
3776
|
+
onSelect,
|
|
3777
|
+
onClick,
|
|
3778
|
+
className,
|
|
3779
|
+
children,
|
|
3780
|
+
type = "button",
|
|
3781
|
+
...rest
|
|
3782
|
+
}, ref) => {
|
|
3783
|
+
const classes = cn(
|
|
3784
|
+
"volt-selectable-card",
|
|
3785
|
+
selected && "volt-selectable-card--selected",
|
|
3786
|
+
className
|
|
3787
|
+
);
|
|
3788
|
+
const ariaProps = selectionRole === "radio" ? { role: "radio", "aria-checked": selected } : selectionRole === "checkbox" ? { role: "checkbox", "aria-checked": selected } : { "aria-pressed": selected };
|
|
3789
|
+
return /* @__PURE__ */ jsxs(
|
|
3790
|
+
"button",
|
|
3791
|
+
{
|
|
3792
|
+
ref,
|
|
3793
|
+
type,
|
|
3794
|
+
className: classes,
|
|
3795
|
+
onClick: (event) => {
|
|
3796
|
+
onSelect?.();
|
|
3797
|
+
onClick?.(event);
|
|
3798
|
+
},
|
|
3799
|
+
...ariaProps,
|
|
3800
|
+
...rest,
|
|
3801
|
+
children: [
|
|
3802
|
+
badge && /* @__PURE__ */ jsx("span", { className: "volt-selectable-card__badge", children: badge }),
|
|
3803
|
+
/* @__PURE__ */ jsxs(Stack_default, { align: "center", gap: "075", textAlign: "center", children: [
|
|
3804
|
+
icon && /* @__PURE__ */ jsx(IconFrame_default, { size: "lg", tone: iconTone, children: icon }),
|
|
3805
|
+
/* @__PURE__ */ jsx(Heading_default, { level: 3, size: "md", weight: "semibold", children: title }),
|
|
3806
|
+
description && /* @__PURE__ */ jsx(Text_default, { size: "sm", tone: "secondary", lineHeight: "5", children: description }),
|
|
3807
|
+
children
|
|
3808
|
+
] })
|
|
3809
|
+
]
|
|
3810
|
+
}
|
|
3811
|
+
);
|
|
3812
|
+
});
|
|
3813
|
+
SelectableCard.displayName = "SelectableCard";
|
|
3814
|
+
var SelectableCard_default = SelectableCard;
|
|
3815
|
+
var DashedActionBox = forwardRef(({
|
|
3816
|
+
icon,
|
|
3817
|
+
label,
|
|
3818
|
+
tone = "muted",
|
|
3819
|
+
size: size2 = "md",
|
|
3820
|
+
block = false,
|
|
3821
|
+
className,
|
|
3822
|
+
children,
|
|
3823
|
+
type = "button",
|
|
3824
|
+
...rest
|
|
3825
|
+
}, ref) => {
|
|
3826
|
+
const classes = cn(
|
|
3827
|
+
"volt-dashed-action",
|
|
3828
|
+
`volt-dashed-action--tone-${tone}`,
|
|
3829
|
+
`volt-dashed-action--size-${size2}`,
|
|
3830
|
+
block && "volt-dashed-action--block",
|
|
3831
|
+
className
|
|
3832
|
+
);
|
|
3833
|
+
return /* @__PURE__ */ jsxs("button", { ref, type, className: classes, ...rest, children: [
|
|
3834
|
+
/* @__PURE__ */ jsx("span", { className: "volt-dashed-action__icon", "aria-hidden": "true", children: icon ?? /* @__PURE__ */ jsx(Plus, { size: 16 }) }),
|
|
3835
|
+
/* @__PURE__ */ jsx("span", { className: "volt-dashed-action__label", children: label }),
|
|
3836
|
+
children
|
|
3837
|
+
] });
|
|
3838
|
+
});
|
|
3839
|
+
DashedActionBox.displayName = "DashedActionBox";
|
|
3840
|
+
var DashedActionBox_default = DashedActionBox;
|
|
3841
|
+
|
|
3842
|
+
// node_modules/sileo/dist/cc-B6peeNak.mjs
|
|
3843
|
+
function _extends() {
|
|
3844
|
+
_extends = Object.assign || function assign(target) {
|
|
3845
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
3846
|
+
var source = arguments[i];
|
|
3847
|
+
for (var key in source) if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
|
|
3848
|
+
}
|
|
3849
|
+
return target;
|
|
3850
|
+
};
|
|
3851
|
+
return _extends.apply(this, arguments);
|
|
3852
|
+
}
|
|
3853
|
+
function __insertCSS(code) {
|
|
3854
|
+
if (typeof document == "undefined") return;
|
|
3855
|
+
let head = document.head || document.getElementsByTagName("head")[0];
|
|
3856
|
+
let style = document.createElement("style");
|
|
3857
|
+
style.type = "text/css";
|
|
3858
|
+
head.appendChild(style);
|
|
3859
|
+
style.styleSheet ? style.styleSheet.cssText = code : style.appendChild(document.createTextNode(code));
|
|
3860
|
+
}
|
|
3861
|
+
__insertCSS(":root{--sileo-spring-easing:linear(\n 0,\n 0.002 0.6%,\n 0.007 1.2%,\n 0.015 1.8%,\n 0.026 2.4%,\n 0.041 3.1%,\n 0.06 3.8%,\n 0.108 5.3%,\n 0.157 6.6%,\n 0.214 8%,\n 0.467 13.7%,\n 0.577 16.3%,\n 0.631 17.7%,\n 0.682 19.1%,\n 0.73 20.5%,\n 0.771 21.8%,\n 0.808 23.1%,\n 0.844 24.5%,\n 0.874 25.8%,\n 0.903 27.2%,\n 0.928 28.6%,\n 0.952 30.1%,\n 0.972 31.6%,\n 0.988 33.1%,\n 1.01 35.7%,\n 1.025 38.5%,\n 1.034 41.6%,\n 1.038 45%,\n 1.035 50.1%,\n 1.012 64.2%,\n 1.003 73%,\n 0.999 83.7%,\n 1\n );--sileo-duration:600ms;--sileo-height:40px;--sileo-width:350px;--sileo-state-success:oklch(0.723 0.219 142.136);--sileo-state-loading:oklch(0.556 0 0);--sileo-state-error:oklch(0.637 0.237 25.331);--sileo-state-warning:oklch(0.795 0.184 86.047);--sileo-state-info:oklch(0.685 0.169 237.323);--sileo-state-action:oklch(0.623 0.214 259.815)}[data-sileo-toast]{position:relative;cursor:pointer;pointer-events:auto;touch-action:none;border:0;background:0 0;padding:0;width:var(--sileo-width);height:var(--_h,var(--sileo-height));opacity:0;transform:translateZ(0) scale(.95);transform-origin:center;contain:layout style;overflow:visible}[data-sileo-toast][data-state=loading]{cursor:default}[data-sileo-toast][data-ready=true]{opacity:1;transform:translateZ(0) scale(1);transition:transform calc(var(--sileo-duration) * .66) var(--sileo-spring-easing),opacity calc(var(--sileo-duration) * .66) var(--sileo-spring-easing),margin-bottom calc(var(--sileo-duration) * .66) var(--sileo-spring-easing),margin-top calc(var(--sileo-duration) * .66) var(--sileo-spring-easing),height var(--sileo-duration) var(--sileo-spring-easing)}[data-sileo-viewport][data-position^=top] [data-sileo-toast]:not([data-ready=true]){transform:translateY(-6px) scale(.95)}[data-sileo-viewport][data-position^=bottom] [data-sileo-toast]:not([data-ready=true]){transform:translateY(6px) scale(.95)}[data-sileo-toast][data-ready=true][data-exiting=true]{opacity:0;pointer-events:none}[data-sileo-viewport][data-position^=top] [data-sileo-toast][data-ready=true][data-exiting=true]{transform:translateY(-6px) scale(.95)}[data-sileo-viewport][data-position^=bottom] [data-sileo-toast][data-ready=true][data-exiting=true]{transform:translateY(6px) scale(.95)}[data-sileo-canvas]{position:absolute;left:0;right:0;pointer-events:none;transform:translateZ(0);contain:layout style;overflow:visible}[data-sileo-canvas][data-edge=top]{bottom:0;transform:scaleY(-1) translateZ(0)}[data-sileo-canvas][data-edge=bottom]{top:0}[data-sileo-svg]{overflow:visible}[data-sileo-header]{position:absolute;z-index:20;display:flex;align-items:center;padding:.5rem;height:var(--sileo-height);overflow:hidden;left:var(--_px,0);transform:var(--_ht);max-width:var(--_pw)}[data-sileo-toast][data-ready=true] [data-sileo-header]{transition:transform var(--sileo-duration) var(--sileo-spring-easing),left var(--sileo-duration) var(--sileo-spring-easing),max-width var(--sileo-duration) var(--sileo-spring-easing)}[data-sileo-header][data-edge=top]{bottom:0}[data-sileo-header][data-edge=bottom]{top:0}[data-sileo-header-stack]{position:relative;display:inline-flex;align-items:center;height:100%}[data-sileo-header-inner]{display:flex;align-items:center;gap:.5rem;white-space:nowrap;opacity:1;filter:blur(0px);transform:translateZ(0)}[data-sileo-header-inner][data-layer=current]{position:relative;z-index:1;animation:sileo-header-enter var(--sileo-duration) var(--sileo-spring-easing) both}[data-sileo-header-inner][data-exiting=true],[data-sileo-header-inner][data-layer=current]:not(:only-child){will-change:opacity,filter}[data-sileo-header-inner][data-layer=prev]{position:absolute;left:0;top:0;z-index:0;pointer-events:none}[data-sileo-header-inner][data-exiting=true]{animation:sileo-header-exit calc(var(--sileo-duration) * .7) ease forwards}[data-sileo-badge]{display:flex;height:24px;width:24px;flex-shrink:0;align-items:center;justify-content:center;padding:2px;box-sizing:border-box;border-radius:9999px;color:var(--sileo-tone,currentColor);background-color:var(--sileo-tone-bg,transparent)}[data-sileo-title]{font-size:.825rem;line-height:1rem;font-weight:500;text-transform:capitalize;color:var(--sileo-tone,currentColor)}:is([data-sileo-badge],[data-sileo-title],[data-sileo-button])[data-state]{--_c:var(--sileo-state-success)}:is(\n[data-sileo-badge],[data-sileo-title],[data-sileo-button]\n)[data-state=loading]{--_c:var(--sileo-state-loading)}:is(\n[data-sileo-badge],[data-sileo-title],[data-sileo-button]\n)[data-state=error]{--_c:var(--sileo-state-error)}:is(\n[data-sileo-badge],[data-sileo-title],[data-sileo-button]\n)[data-state=warning]{--_c:var(--sileo-state-warning)}:is(\n[data-sileo-badge],[data-sileo-title],[data-sileo-button]\n)[data-state=info]{--_c:var(--sileo-state-info)}:is(\n[data-sileo-badge],[data-sileo-title],[data-sileo-button]\n)[data-state=action]{--_c:var(--sileo-state-action)}:is([data-sileo-badge],[data-sileo-title])[data-state]{--sileo-tone:var(--_c);--sileo-tone-bg:color-mix(in oklch, var(--_c) 20%, transparent)}[data-sileo-content]{position:absolute;left:0;z-index:10;width:100%;pointer-events:none;opacity:var(--_co, 0)}[data-sileo-content]:not([data-visible=true]){content-visibility:hidden}[data-sileo-toast][data-ready=true] [data-sileo-content]{transition:opacity calc(var(--sileo-duration) * .08) ease calc(var(--sileo-duration) * .04)}[data-sileo-content][data-edge=top]{top:0}[data-sileo-content][data-edge=bottom]{top:var(--sileo-height)}[data-sileo-content][data-visible=true]{pointer-events:auto}[data-sileo-toast][data-ready=true] [data-sileo-content][data-visible=true]{transition:opacity calc(var(--sileo-duration) * .6) ease calc(var(--sileo-duration) * .3)}[data-sileo-description]{width:100%;text-align:left;padding:1rem;font-size:.875rem;line-height:1.25rem;contain:layout style paint;content-visibility:auto}[data-sileo-button]{display:flex;align-items:center;justify-content:center;height:1.75rem;padding:0 .625rem;margin-top:.75rem;border-radius:9999px;border:0;font-size:.75rem;font-weight:500;cursor:pointer;color:var(--sileo-btn-color,currentColor);background-color:var(--sileo-btn-bg,transparent);transition:background-color 150ms ease}[data-sileo-button]:hover{background-color:var(--sileo-btn-bg-hover,transparent)}[data-sileo-button][data-state]{--sileo-btn-color:var(--_c);--sileo-btn-bg:color-mix(in oklch, var(--_c) 15%, transparent);--sileo-btn-bg-hover:color-mix(in oklch, var(--_c) 25%, transparent)}[data-sileo-icon=spin]{animation:sileo-spin 1s linear infinite}@keyframes sileo-spin{to{transform:rotate(360deg)}}@keyframes sileo-header-enter{from{opacity:0;filter:blur(6px)}to{opacity:1;filter:blur(0px)}}@keyframes sileo-header-exit{from{opacity:1;filter:blur(0px)}to{opacity:0;filter:blur(6px)}}[data-sileo-viewport]{position:fixed;z-index:50;display:flex;gap:.75rem;padding:.75rem;pointer-events:none;max-width:calc(100vw - 1.5rem);contain:layout style}[data-sileo-viewport][data-position^=top] [data-sileo-toast]:not([data-ready=true]){margin-bottom:calc(-1 * (var(--sileo-height) + .75rem))}[data-sileo-viewport][data-position^=bottom] [data-sileo-toast]:not([data-ready=true]){margin-top:calc(-1 * (var(--sileo-height) + .75rem))}[data-sileo-viewport][data-position^=top]{top:0;flex-direction:column-reverse}[data-sileo-viewport][data-position^=bottom]{bottom:0;flex-direction:column}[data-sileo-viewport][data-position$=left]{left:0;align-items:flex-start}[data-sileo-viewport][data-position$=right]{right:0;align-items:flex-end}[data-sileo-viewport][data-position$=center]{left:50%;transform:translateX(-50%);align-items:center}@media (prefers-reduced-motion:no-preference){[data-sileo-toast][data-ready=true]:hover,[data-sileo-toast][data-ready=true][data-exiting=true]{will-change:transform,opacity,height}}@media (prefers-reduced-motion:reduce){[data-sileo-viewport],[data-sileo-viewport] *,[data-sileo-viewport] ::after,[data-sileo-viewport] ::before{animation-duration:0s;animation-iteration-count:1;transition-duration:0s}}[data-sileo-viewport][data-theme=dark] [data-sileo-description]{color:rgba(0,0,0,.5)}[data-sileo-viewport][data-theme=light] [data-sileo-description]{color:rgba(255,255,255,.5)}");
|
|
3862
|
+
var DEFAULT_TOAST_DURATION = 6e3;
|
|
3863
|
+
var EXIT_DURATION = DEFAULT_TOAST_DURATION * 0.1;
|
|
3864
|
+
var AUTO_EXPAND_DELAY = DEFAULT_TOAST_DURATION * 0.025;
|
|
3865
|
+
var AUTO_COLLAPSE_DELAY = DEFAULT_TOAST_DURATION - 2e3;
|
|
3866
|
+
var store = {
|
|
3867
|
+
toasts: [],
|
|
3868
|
+
listeners: /* @__PURE__ */ new Set(),
|
|
3869
|
+
position: "top-right",
|
|
3870
|
+
options: void 0,
|
|
3871
|
+
emit() {
|
|
3872
|
+
for (const fn of this.listeners) fn(this.toasts);
|
|
3873
|
+
},
|
|
3874
|
+
update(fn) {
|
|
3875
|
+
this.toasts = fn(this.toasts);
|
|
3876
|
+
this.emit();
|
|
3877
|
+
}
|
|
3878
|
+
};
|
|
3879
|
+
var idCounter = 0;
|
|
3880
|
+
var generateId = () => `${++idCounter}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
|
3881
|
+
var dismissToast = (id) => {
|
|
3882
|
+
const item = store.toasts.find((t) => t.id === id);
|
|
3883
|
+
if (!item || item.exiting) return;
|
|
3884
|
+
store.update((prev) => prev.map((t) => t.id === id ? _extends({}, t, {
|
|
3885
|
+
exiting: true
|
|
3886
|
+
}) : t));
|
|
3887
|
+
setTimeout(() => store.update((prev) => prev.filter((t) => t.id !== id)), EXIT_DURATION);
|
|
3888
|
+
};
|
|
3889
|
+
var resolveAutopilot = (opts, duration) => {
|
|
3890
|
+
var _ref, _ref1;
|
|
3891
|
+
if (opts.autopilot === false || !duration || duration <= 0) return {};
|
|
3892
|
+
const cfg = typeof opts.autopilot === "object" ? opts.autopilot : void 0;
|
|
3893
|
+
const clamp4 = (v) => Math.min(duration, Math.max(0, v));
|
|
3894
|
+
return {
|
|
3895
|
+
expandDelayMs: clamp4((_ref = cfg == null ? void 0 : cfg.expand) != null ? _ref : AUTO_EXPAND_DELAY),
|
|
3896
|
+
collapseDelayMs: clamp4((_ref1 = cfg == null ? void 0 : cfg.collapse) != null ? _ref1 : AUTO_COLLAPSE_DELAY)
|
|
3897
|
+
};
|
|
3898
|
+
};
|
|
3899
|
+
var mergeOptions = (options) => {
|
|
3900
|
+
var _store_options;
|
|
3901
|
+
return _extends({}, store.options, options, {
|
|
3902
|
+
styles: _extends({}, (_store_options = store.options) == null ? void 0 : _store_options.styles, options.styles)
|
|
3903
|
+
});
|
|
3904
|
+
};
|
|
3905
|
+
var buildSileoItem = (merged, id, fallbackPosition) => {
|
|
3906
|
+
var _merged_duration, _ref, _merged_position;
|
|
3907
|
+
const duration = (_merged_duration = merged.duration) != null ? _merged_duration : DEFAULT_TOAST_DURATION;
|
|
3908
|
+
const auto = resolveAutopilot(merged, duration);
|
|
3909
|
+
return _extends({}, merged, {
|
|
3910
|
+
id,
|
|
3911
|
+
instanceId: generateId(),
|
|
3912
|
+
position: (_ref = (_merged_position = merged.position) != null ? _merged_position : fallbackPosition) != null ? _ref : store.position,
|
|
3913
|
+
autoExpandDelayMs: auto.expandDelayMs,
|
|
3914
|
+
autoCollapseDelayMs: auto.collapseDelayMs
|
|
3915
|
+
});
|
|
3916
|
+
};
|
|
3917
|
+
var createToast = (options) => {
|
|
3918
|
+
var _merged_id, _merged_duration;
|
|
3919
|
+
const live = store.toasts.filter((t) => !t.exiting);
|
|
3920
|
+
const merged = mergeOptions(options);
|
|
3921
|
+
const id = (_merged_id = merged.id) != null ? _merged_id : "sileo-default";
|
|
3922
|
+
const prev = live.find((t) => t.id === id);
|
|
3923
|
+
const item = buildSileoItem(merged, id, prev == null ? void 0 : prev.position);
|
|
3924
|
+
if (prev) {
|
|
3925
|
+
store.update((p) => p.map((t) => t.id === id ? item : t));
|
|
3926
|
+
} else {
|
|
3927
|
+
store.update((p) => [
|
|
3928
|
+
...p.filter((t) => t.id !== id),
|
|
3929
|
+
item
|
|
3930
|
+
]);
|
|
3931
|
+
}
|
|
3932
|
+
return {
|
|
3933
|
+
id,
|
|
3934
|
+
duration: (_merged_duration = merged.duration) != null ? _merged_duration : DEFAULT_TOAST_DURATION
|
|
3935
|
+
};
|
|
3936
|
+
};
|
|
3937
|
+
var updateToast = (id, options) => {
|
|
3938
|
+
const existing = store.toasts.find((t) => t.id === id);
|
|
3939
|
+
if (!existing) return;
|
|
3940
|
+
const item = buildSileoItem(mergeOptions(options), id, existing.position);
|
|
3941
|
+
store.update((prev) => prev.map((t) => t.id === id ? item : t));
|
|
3942
|
+
};
|
|
3943
|
+
var sileo = {
|
|
3944
|
+
show: (opts) => createToast(_extends({}, opts, {
|
|
3945
|
+
state: opts.type
|
|
3946
|
+
})).id,
|
|
3947
|
+
success: (opts) => createToast(_extends({}, opts, {
|
|
3948
|
+
state: "success"
|
|
3949
|
+
})).id,
|
|
3950
|
+
error: (opts) => createToast(_extends({}, opts, {
|
|
3951
|
+
state: "error"
|
|
3952
|
+
})).id,
|
|
3953
|
+
warning: (opts) => createToast(_extends({}, opts, {
|
|
3954
|
+
state: "warning"
|
|
3955
|
+
})).id,
|
|
3956
|
+
info: (opts) => createToast(_extends({}, opts, {
|
|
3957
|
+
state: "info"
|
|
3958
|
+
})).id,
|
|
3959
|
+
action: (opts) => createToast(_extends({}, opts, {
|
|
3960
|
+
state: "action"
|
|
3961
|
+
})).id,
|
|
3962
|
+
promise: (promise, opts) => {
|
|
3963
|
+
const { id } = createToast(_extends({}, opts.loading, {
|
|
3964
|
+
state: "loading",
|
|
3965
|
+
duration: null,
|
|
3966
|
+
position: opts.position
|
|
3967
|
+
}));
|
|
3968
|
+
const p = typeof promise === "function" ? promise() : promise;
|
|
3969
|
+
p.then((data) => {
|
|
3970
|
+
if (opts.action) {
|
|
3971
|
+
const actionOpts = typeof opts.action === "function" ? opts.action(data) : opts.action;
|
|
3972
|
+
updateToast(id, _extends({}, actionOpts, {
|
|
3973
|
+
state: "action",
|
|
3974
|
+
id
|
|
3975
|
+
}));
|
|
3976
|
+
} else {
|
|
3977
|
+
const successOpts = typeof opts.success === "function" ? opts.success(data) : opts.success;
|
|
3978
|
+
updateToast(id, _extends({}, successOpts, {
|
|
3979
|
+
state: "success",
|
|
3980
|
+
id
|
|
3981
|
+
}));
|
|
3982
|
+
}
|
|
3983
|
+
}).catch((err) => {
|
|
3984
|
+
const errorOpts = typeof opts.error === "function" ? opts.error(err) : opts.error;
|
|
3985
|
+
updateToast(id, _extends({}, errorOpts, {
|
|
3986
|
+
state: "error",
|
|
3987
|
+
id
|
|
3988
|
+
}));
|
|
3989
|
+
});
|
|
3990
|
+
return p;
|
|
3991
|
+
},
|
|
3992
|
+
dismiss: dismissToast,
|
|
3993
|
+
clear: (position) => store.update((prev) => position ? prev.filter((t) => t.position !== position) : [])
|
|
3994
|
+
};
|
|
3995
|
+
|
|
3996
|
+
// src/shared/presentation/utilities/copy-to-clipboard.ts
|
|
3997
|
+
var DEFAULT_SUCCESS_MESSAGE = "Copied to clipboard";
|
|
3998
|
+
var DEFAULT_ERROR_MESSAGE = "Failed to copy to clipboard";
|
|
3999
|
+
var copyTextToClipboard = async (text, {
|
|
4000
|
+
successMessage = DEFAULT_SUCCESS_MESSAGE,
|
|
4001
|
+
errorMessage = DEFAULT_ERROR_MESSAGE
|
|
4002
|
+
} = {}) => {
|
|
4003
|
+
try {
|
|
4004
|
+
await navigator.clipboard.writeText(text);
|
|
4005
|
+
sileo.success({ title: successMessage });
|
|
4006
|
+
return true;
|
|
4007
|
+
} catch {
|
|
4008
|
+
sileo.error({ title: errorMessage });
|
|
4009
|
+
return false;
|
|
4010
|
+
}
|
|
4011
|
+
};
|
|
4012
|
+
var KeyValueRow = forwardRef(({
|
|
4013
|
+
label,
|
|
4014
|
+
value,
|
|
4015
|
+
copyValue,
|
|
4016
|
+
action,
|
|
4017
|
+
tabular = false,
|
|
4018
|
+
className,
|
|
4019
|
+
...rest
|
|
4020
|
+
}, ref) => {
|
|
4021
|
+
const [copied, setCopied] = useState(false);
|
|
4022
|
+
const handleCopy = useCallback(async () => {
|
|
4023
|
+
if (!copyValue) return;
|
|
4024
|
+
const ok = await copyTextToClipboard(copyValue);
|
|
4025
|
+
if (ok) {
|
|
4026
|
+
setCopied(true);
|
|
4027
|
+
setTimeout(() => setCopied(false), 1400);
|
|
4028
|
+
}
|
|
4029
|
+
}, [copyValue]);
|
|
4030
|
+
return /* @__PURE__ */ jsxs("div", { ref, className: cn("volt-kv-row", className), ...rest, children: [
|
|
4031
|
+
/* @__PURE__ */ jsx(Text_default, { as: "span", size: "sm", tone: "secondary", className: "volt-kv-row__label", children: label }),
|
|
4032
|
+
/* @__PURE__ */ jsxs(Row_default, { gap: "05", align: "center", className: "volt-kv-row__value-group", children: [
|
|
4033
|
+
/* @__PURE__ */ jsx(
|
|
4034
|
+
Text_default,
|
|
4035
|
+
{
|
|
4036
|
+
as: "span",
|
|
4037
|
+
size: "sm",
|
|
4038
|
+
tone: "primary",
|
|
4039
|
+
weight: "medium",
|
|
4040
|
+
className: cn("volt-kv-row__value", tabular && "tabular-nums"),
|
|
4041
|
+
children: value
|
|
4042
|
+
}
|
|
4043
|
+
),
|
|
4044
|
+
copyValue && /* @__PURE__ */ jsx(
|
|
4045
|
+
IconButton_default,
|
|
4046
|
+
{
|
|
4047
|
+
size: "sm",
|
|
4048
|
+
variant: "ghost",
|
|
4049
|
+
onClick: handleCopy,
|
|
4050
|
+
"aria-label": copied ? "Copied" : "Copy value",
|
|
4051
|
+
children: copied ? /* @__PURE__ */ jsx(Check, { size: 14 }) : /* @__PURE__ */ jsx(Copy, { size: 14 })
|
|
4052
|
+
}
|
|
4053
|
+
),
|
|
4054
|
+
action
|
|
4055
|
+
] })
|
|
4056
|
+
] });
|
|
4057
|
+
});
|
|
4058
|
+
KeyValueRow.displayName = "KeyValueRow";
|
|
4059
|
+
var KeyValueList = forwardRef(({
|
|
4060
|
+
dividers = true,
|
|
4061
|
+
className,
|
|
4062
|
+
children,
|
|
4063
|
+
...rest
|
|
4064
|
+
}, ref) => {
|
|
4065
|
+
return /* @__PURE__ */ jsx(
|
|
4066
|
+
Stack_default,
|
|
4067
|
+
{
|
|
4068
|
+
ref,
|
|
4069
|
+
className: cn("volt-kv-list", dividers && "volt-kv-list--dividers", className),
|
|
4070
|
+
...rest,
|
|
4071
|
+
children
|
|
4072
|
+
}
|
|
4073
|
+
);
|
|
4074
|
+
});
|
|
4075
|
+
KeyValueList.displayName = "KeyValueList";
|
|
4076
|
+
var KeyValueList_default = KeyValueList;
|
|
4077
|
+
var ListRow = forwardRef(({
|
|
4078
|
+
leading,
|
|
4079
|
+
title,
|
|
4080
|
+
subtitle,
|
|
4081
|
+
meta,
|
|
4082
|
+
trailing,
|
|
4083
|
+
selected = false,
|
|
4084
|
+
active = false,
|
|
4085
|
+
onClick,
|
|
4086
|
+
to,
|
|
4087
|
+
as,
|
|
4088
|
+
disabled,
|
|
4089
|
+
className,
|
|
4090
|
+
...rest
|
|
4091
|
+
}, ref) => {
|
|
4092
|
+
const classes = cn(
|
|
4093
|
+
"volt-list-row",
|
|
4094
|
+
"list-item-hoverable",
|
|
4095
|
+
selected && "volt-list-row--selected",
|
|
4096
|
+
active && "volt-list-row--active",
|
|
4097
|
+
disabled && "volt-list-row--disabled",
|
|
4098
|
+
className
|
|
4099
|
+
);
|
|
4100
|
+
const inner = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4101
|
+
leading && /* @__PURE__ */ jsx("div", { className: "volt-list-row__leading", "aria-hidden": "true", children: leading }),
|
|
4102
|
+
/* @__PURE__ */ jsxs("div", { className: "volt-list-row__content", children: [
|
|
4103
|
+
title && /* @__PURE__ */ jsx(Text_default, { as: "span", size: "md", weight: "medium", tone: "primary", truncate: true, children: title }),
|
|
4104
|
+
subtitle && /* @__PURE__ */ jsx(Text_default, { as: "span", size: "sm", tone: "muted", truncate: true, children: subtitle }),
|
|
4105
|
+
meta
|
|
4106
|
+
] }),
|
|
4107
|
+
trailing && /* @__PURE__ */ jsx("div", { className: "volt-list-row__trailing", children: trailing })
|
|
4108
|
+
] });
|
|
4109
|
+
if (to) {
|
|
4110
|
+
return /* @__PURE__ */ jsx(
|
|
4111
|
+
Link,
|
|
4112
|
+
{
|
|
4113
|
+
ref,
|
|
4114
|
+
to,
|
|
4115
|
+
className: classes,
|
|
4116
|
+
"aria-current": selected ? "page" : void 0,
|
|
4117
|
+
...rest,
|
|
4118
|
+
children: inner
|
|
4119
|
+
}
|
|
4120
|
+
);
|
|
4121
|
+
}
|
|
4122
|
+
if (onClick || as === "button") {
|
|
4123
|
+
return /* @__PURE__ */ jsx(
|
|
4124
|
+
"button",
|
|
4125
|
+
{
|
|
4126
|
+
ref,
|
|
4127
|
+
type: "button",
|
|
4128
|
+
className: classes,
|
|
4129
|
+
onClick,
|
|
4130
|
+
disabled,
|
|
4131
|
+
"aria-pressed": selected || void 0,
|
|
4132
|
+
...rest,
|
|
4133
|
+
children: inner
|
|
4134
|
+
}
|
|
4135
|
+
);
|
|
4136
|
+
}
|
|
4137
|
+
const Component = as ?? "div";
|
|
4138
|
+
return /* @__PURE__ */ jsx(
|
|
4139
|
+
Component,
|
|
4140
|
+
{
|
|
4141
|
+
ref,
|
|
4142
|
+
className: classes,
|
|
4143
|
+
...rest,
|
|
4144
|
+
children: inner
|
|
4145
|
+
}
|
|
4146
|
+
);
|
|
4147
|
+
});
|
|
4148
|
+
ListRow.displayName = "ListRow";
|
|
4149
|
+
var ListRow_default = ListRow;
|
|
4150
|
+
|
|
4151
|
+
// src/shared/utils/format.ts
|
|
4152
|
+
var formatUnknownValue = (value) => {
|
|
4153
|
+
if (value === null || value === void 0) return "-";
|
|
4154
|
+
if (typeof value === "string") return value;
|
|
4155
|
+
if (typeof value === "number" || typeof value === "bigint" || typeof value === "boolean") {
|
|
4156
|
+
return String(value);
|
|
4157
|
+
}
|
|
4158
|
+
if (value instanceof Date) return value.toISOString();
|
|
4159
|
+
if (Array.isArray(value)) {
|
|
4160
|
+
if (value.length === 0) return "[]";
|
|
4161
|
+
const preview = value.slice(0, 3).map(formatUnknownValue).join(", ");
|
|
4162
|
+
return value.length > 3 ? `[${preview}, ...]` : `[${preview}]`;
|
|
4163
|
+
}
|
|
4164
|
+
if (typeof value === "object") {
|
|
4165
|
+
const entries = Object.entries(value);
|
|
4166
|
+
if (entries.length === 0) return "{}";
|
|
4167
|
+
const preview = entries.slice(0, 3).map(([key, entry]) => `${key}: ${formatUnknownValue(entry)}`).join(", ");
|
|
4168
|
+
return entries.length > 3 ? `{${preview}, ...}` : `{${preview}}`;
|
|
4169
|
+
}
|
|
4170
|
+
try {
|
|
4171
|
+
const serialized = JSON.stringify(value);
|
|
4172
|
+
return typeof serialized === "string" ? serialized : String(value);
|
|
4173
|
+
} catch {
|
|
4174
|
+
return String(value);
|
|
4175
|
+
}
|
|
4176
|
+
};
|
|
4177
|
+
var TableSortDirection = /* @__PURE__ */ ((TableSortDirection2) => {
|
|
4178
|
+
TableSortDirection2["Ascending"] = "ascending";
|
|
4179
|
+
TableSortDirection2["Descending"] = "descending";
|
|
4180
|
+
TableSortDirection2["None"] = "none";
|
|
4181
|
+
return TableSortDirection2;
|
|
4182
|
+
})(TableSortDirection || {});
|
|
4183
|
+
var TableImpl = ({
|
|
4184
|
+
columns,
|
|
4185
|
+
data,
|
|
4186
|
+
getRowKey,
|
|
4187
|
+
isLoading = false,
|
|
4188
|
+
skeletonRows = 5,
|
|
4189
|
+
onRowClick,
|
|
4190
|
+
rowClassName,
|
|
4191
|
+
className = "",
|
|
4192
|
+
getAriaSort = () => "none" /* None */,
|
|
4193
|
+
onSort,
|
|
4194
|
+
caption
|
|
4195
|
+
}, ref) => {
|
|
4196
|
+
const getRowClass = useCallback((row) => {
|
|
4197
|
+
const base = onRowClick ? "clickable" : "";
|
|
4198
|
+
if (!rowClassName) return base;
|
|
4199
|
+
if (typeof rowClassName === "string") return `${base} ${rowClassName}`;
|
|
4200
|
+
return `${base} ${rowClassName(row)}`;
|
|
4201
|
+
}, [onRowClick, rowClassName]);
|
|
4202
|
+
const renderSkeletonRows = () => Array.from({ length: skeletonRows }).map((_, i) => /* @__PURE__ */ jsx("tr", { "aria-hidden": "true", children: columns.map((col) => /* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsx(Skeleton_default, { variant: "text", width: "70%", height: 20, animation: "wave" }) }, col.key)) }, `skeleton-${i}`));
|
|
4203
|
+
const renderCell = (row, col) => {
|
|
4204
|
+
if (col.render) return col.render(row);
|
|
4205
|
+
return formatUnknownValue(row[col.key]);
|
|
4206
|
+
};
|
|
4207
|
+
const renderHeaderCell = (col) => {
|
|
4208
|
+
if (!col.sortable || !onSort) {
|
|
4209
|
+
return col.header;
|
|
4210
|
+
}
|
|
4211
|
+
return /* @__PURE__ */ jsx(
|
|
4212
|
+
"button",
|
|
4213
|
+
{
|
|
4214
|
+
type: "button",
|
|
4215
|
+
className: "table-sort-button",
|
|
4216
|
+
onClick: () => onSort(col),
|
|
4217
|
+
"aria-label": `Sort by ${col.header}`,
|
|
4218
|
+
children: col.header
|
|
4219
|
+
}
|
|
4220
|
+
);
|
|
4221
|
+
};
|
|
4222
|
+
return /* @__PURE__ */ jsx("div", { ref, className: "table-scroll-wrapper", children: /* @__PURE__ */ jsxs("table", { className: `table ${className}`, children: [
|
|
4223
|
+
caption && /* @__PURE__ */ jsx("caption", { className: "table-caption", children: caption }),
|
|
4224
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: columns.map((col) => /* @__PURE__ */ jsx("th", { scope: "col", className: col.headerClassName, "aria-sort": getAriaSort(col), children: renderHeaderCell(col) }, col.key)) }) }),
|
|
4225
|
+
/* @__PURE__ */ jsx("tbody", { children: isLoading ? renderSkeletonRows() : data.map((row, index) => /* @__PURE__ */ jsx(
|
|
4226
|
+
"tr",
|
|
4227
|
+
{
|
|
4228
|
+
className: getRowClass(row),
|
|
4229
|
+
onClick: onRowClick ? () => onRowClick(row) : void 0,
|
|
4230
|
+
children: columns.map((col) => /* @__PURE__ */ jsx("td", { className: col.cellClassName, children: renderCell(row, col) }, col.key))
|
|
4231
|
+
},
|
|
4232
|
+
getRowKey(row, index)
|
|
4233
|
+
)) })
|
|
4234
|
+
] }) });
|
|
4235
|
+
};
|
|
4236
|
+
var Table = forwardRef(TableImpl);
|
|
4237
|
+
Table.displayName = "Table";
|
|
4238
|
+
var Table_default = Table;
|
|
4239
|
+
var TimelineItem = forwardRef(({
|
|
4240
|
+
icon,
|
|
4241
|
+
tone = "neutral",
|
|
4242
|
+
connector = true,
|
|
4243
|
+
className,
|
|
4244
|
+
children,
|
|
4245
|
+
...rest
|
|
4246
|
+
}, ref) => {
|
|
4247
|
+
return /* @__PURE__ */ jsxs(
|
|
4248
|
+
"li",
|
|
4249
|
+
{
|
|
4250
|
+
ref,
|
|
4251
|
+
className: cn("volt-timeline-item", `volt-timeline-item--tone-${tone}`, className),
|
|
4252
|
+
...rest,
|
|
4253
|
+
children: [
|
|
4254
|
+
/* @__PURE__ */ jsxs("span", { className: "volt-timeline-item__rail", "aria-hidden": "true", children: [
|
|
4255
|
+
/* @__PURE__ */ jsx("span", { className: "volt-timeline-item__dot", children: icon }),
|
|
4256
|
+
connector && /* @__PURE__ */ jsx("span", { className: "volt-timeline-item__line" })
|
|
4257
|
+
] }),
|
|
4258
|
+
/* @__PURE__ */ jsx("div", { className: "volt-timeline-item__content", children })
|
|
4259
|
+
]
|
|
4260
|
+
}
|
|
4261
|
+
);
|
|
4262
|
+
});
|
|
4263
|
+
TimelineItem.displayName = "TimelineItem";
|
|
4264
|
+
var Timeline = forwardRef(({
|
|
4265
|
+
className,
|
|
4266
|
+
children,
|
|
4267
|
+
...rest
|
|
4268
|
+
}, ref) => {
|
|
4269
|
+
return /* @__PURE__ */ jsx("ol", { ref, className: cn("volt-timeline", className), ...rest, children });
|
|
4270
|
+
});
|
|
4271
|
+
Timeline.displayName = "Timeline";
|
|
4272
|
+
var Timeline_default = Timeline;
|
|
4273
|
+
var Sparkline = ({
|
|
4274
|
+
color,
|
|
4275
|
+
values,
|
|
4276
|
+
labels,
|
|
4277
|
+
yDomain,
|
|
4278
|
+
width = "100%",
|
|
4279
|
+
height = 80,
|
|
4280
|
+
strokeWidth = 2,
|
|
4281
|
+
fillOpacityStart = 0.25,
|
|
4282
|
+
fillOpacityEnd = 0.25,
|
|
4283
|
+
interpolation = "linear",
|
|
4284
|
+
animate,
|
|
4285
|
+
minDataMax
|
|
4286
|
+
}) => {
|
|
4287
|
+
const prefersReducedMotion = usePrefersReducedMotion();
|
|
4288
|
+
const gradientId = useId();
|
|
4289
|
+
const fillId = `${gradientId}-sparkline-fill`;
|
|
4290
|
+
const chartData = useMemo(() => {
|
|
4291
|
+
if (!values.length) {
|
|
4292
|
+
return [{ label: "", value: 0 }, { label: "", value: 0 }];
|
|
4293
|
+
}
|
|
4294
|
+
if (values.length === 1) {
|
|
4295
|
+
const only = Number.isFinite(values[0]) ? values[0] : 0;
|
|
4296
|
+
return [{ label: labels?.[0] ?? "", value: only }, { label: labels?.[0] ?? "", value: only }];
|
|
4297
|
+
}
|
|
4298
|
+
const length = Math.max(labels?.length || 0, values.length);
|
|
4299
|
+
return Array.from({ length }, (_, i) => {
|
|
4300
|
+
const raw = Number(values[i]);
|
|
4301
|
+
return {
|
|
4302
|
+
label: labels?.[i] ?? "",
|
|
4303
|
+
value: Number.isFinite(raw) ? raw : 0
|
|
4304
|
+
};
|
|
4305
|
+
});
|
|
4306
|
+
}, [values, labels]);
|
|
4307
|
+
const yAxisDomain = yDomain ? [yDomain.min, yDomain.max] : minDataMax !== void 0 ? ["dataMin", (max) => Math.max(max, minDataMax)] : ["auto", "auto"];
|
|
4308
|
+
const isAnimationActive = animate !== void 0 ? animate : !prefersReducedMotion;
|
|
4309
|
+
return /* @__PURE__ */ jsx(ResponsiveContainer, { width, height, children: /* @__PURE__ */ jsxs(
|
|
4310
|
+
AreaChart,
|
|
4311
|
+
{
|
|
4312
|
+
data: chartData,
|
|
4313
|
+
margin: { top: 2, right: 0, left: 0, bottom: 0 },
|
|
4314
|
+
children: [
|
|
4315
|
+
/* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("linearGradient", { id: fillId, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
|
4316
|
+
/* @__PURE__ */ jsx("stop", { offset: "0%", stopColor: color, stopOpacity: fillOpacityStart }),
|
|
4317
|
+
/* @__PURE__ */ jsx("stop", { offset: "100%", stopColor: color, stopOpacity: fillOpacityEnd })
|
|
4318
|
+
] }) }),
|
|
4319
|
+
/* @__PURE__ */ jsx(YAxis, { hide: true, domain: yAxisDomain }),
|
|
4320
|
+
/* @__PURE__ */ jsx(
|
|
4321
|
+
Area,
|
|
4322
|
+
{
|
|
4323
|
+
type: interpolation,
|
|
4324
|
+
dataKey: "value",
|
|
4325
|
+
stroke: color,
|
|
4326
|
+
strokeWidth,
|
|
4327
|
+
fill: `url(#${fillId})`,
|
|
4328
|
+
fillOpacity: 1,
|
|
4329
|
+
dot: false,
|
|
4330
|
+
activeDot: false,
|
|
4331
|
+
isAnimationActive
|
|
4332
|
+
}
|
|
4333
|
+
)
|
|
4334
|
+
]
|
|
4335
|
+
}
|
|
4336
|
+
) });
|
|
4337
|
+
};
|
|
4338
|
+
var Sparkline_default = Sparkline;
|
|
4339
|
+
var toneToIntent = {
|
|
4340
|
+
danger: "danger",
|
|
4341
|
+
warning: "neutral",
|
|
4342
|
+
info: "brand",
|
|
4343
|
+
success: "success"
|
|
4344
|
+
};
|
|
4345
|
+
var Callout = forwardRef(({
|
|
4346
|
+
tone,
|
|
4347
|
+
title,
|
|
4348
|
+
description,
|
|
4349
|
+
message,
|
|
4350
|
+
icon,
|
|
4351
|
+
action,
|
|
4352
|
+
children,
|
|
4353
|
+
className,
|
|
4354
|
+
ariaLabel,
|
|
4355
|
+
role,
|
|
4356
|
+
ariaLive
|
|
4357
|
+
}, ref) => {
|
|
4358
|
+
const hasHeaderContent = Boolean(title || description);
|
|
4359
|
+
const layout = hasHeaderContent ? "stacked" : "inline";
|
|
4360
|
+
const resolvedRole = role ?? (hasHeaderContent ? "region" : "status");
|
|
4361
|
+
const resolvedAriaLive = ariaLive ?? (hasHeaderContent ? void 0 : "polite");
|
|
4362
|
+
const resolvedAriaLabel = ariaLabel ?? title;
|
|
4363
|
+
const classes = cn(
|
|
4364
|
+
"volt-callout",
|
|
4365
|
+
`volt-callout--tone-${tone}`,
|
|
4366
|
+
`volt-callout--layout-${layout}`,
|
|
4367
|
+
className
|
|
4368
|
+
);
|
|
4369
|
+
if (layout === "inline") {
|
|
4370
|
+
return /* @__PURE__ */ jsx(
|
|
4371
|
+
"div",
|
|
4372
|
+
{
|
|
4373
|
+
ref,
|
|
4374
|
+
className: classes,
|
|
4375
|
+
role: resolvedRole,
|
|
4376
|
+
"aria-live": resolvedAriaLive,
|
|
4377
|
+
"aria-label": resolvedAriaLabel,
|
|
4378
|
+
children: /* @__PURE__ */ jsxs(Row_default, { gap: "05", className: "font-size-2", children: [
|
|
4379
|
+
icon && /* @__PURE__ */ jsx("span", { className: "volt-callout__icon", children: icon }),
|
|
4380
|
+
/* @__PURE__ */ jsx("div", { className: "volt-callout__body", children: message ?? children })
|
|
4381
|
+
] })
|
|
4382
|
+
}
|
|
4383
|
+
);
|
|
4384
|
+
}
|
|
4385
|
+
return /* @__PURE__ */ jsx(
|
|
4386
|
+
"div",
|
|
4387
|
+
{
|
|
4388
|
+
ref,
|
|
4389
|
+
className: classes,
|
|
4390
|
+
role: resolvedRole,
|
|
4391
|
+
"aria-live": resolvedAriaLive,
|
|
4392
|
+
"aria-label": resolvedAriaLabel,
|
|
4393
|
+
children: /* @__PURE__ */ jsxs(Row_default, { justify: "between", gap: "1", children: [
|
|
4394
|
+
/* @__PURE__ */ jsxs(Stack_default, { gap: "025", children: [
|
|
4395
|
+
title && /* @__PURE__ */ jsx(Heading_default, { level: 2, size: "md", weight: "bold", children: title }),
|
|
4396
|
+
description && /* @__PURE__ */ jsx(Text_default, { as: "p", tone: "muted", size: "sm", children: description }),
|
|
4397
|
+
children
|
|
4398
|
+
] }),
|
|
4399
|
+
action && /* @__PURE__ */ jsx(
|
|
4400
|
+
Button_default,
|
|
4401
|
+
{
|
|
4402
|
+
intent: toneToIntent[tone],
|
|
4403
|
+
variant: "outline",
|
|
4404
|
+
size: "sm",
|
|
4405
|
+
leftIcon: action.icon,
|
|
4406
|
+
onClick: action.onClick,
|
|
4407
|
+
isLoading: action.isLoading,
|
|
4408
|
+
disabled: action.disabled,
|
|
4409
|
+
children: action.label
|
|
4410
|
+
}
|
|
4411
|
+
)
|
|
4412
|
+
] })
|
|
4413
|
+
}
|
|
4414
|
+
);
|
|
4415
|
+
});
|
|
4416
|
+
Callout.displayName = "Callout";
|
|
4417
|
+
var Callout_default = Callout;
|
|
4418
|
+
var EmptyState = forwardRef(({
|
|
4419
|
+
title,
|
|
4420
|
+
description,
|
|
4421
|
+
icon,
|
|
4422
|
+
buttonText,
|
|
4423
|
+
buttonOnClick,
|
|
4424
|
+
buttonIsLoading = false,
|
|
4425
|
+
className,
|
|
4426
|
+
headingLevel = "h2",
|
|
4427
|
+
announce = false
|
|
4428
|
+
}, ref) => {
|
|
4429
|
+
const headingId = useId();
|
|
4430
|
+
const level = Number(headingLevel.slice(1));
|
|
4431
|
+
return /* @__PURE__ */ jsx("section", { ref, "aria-labelledby": headingId, className: `d-flex items-center content-center w-max h-max empty-state-container ${className || ""}`, children: /* @__PURE__ */ jsxs(Stack_default, { align: "center", gap: "1-5", textAlign: "center", className: "empty-state-content", children: [
|
|
4432
|
+
announce && /* @__PURE__ */ jsxs("span", { className: "empty-state-live-region", "aria-live": "polite", "aria-atomic": "true", children: [
|
|
4433
|
+
title,
|
|
4434
|
+
". ",
|
|
4435
|
+
description
|
|
4436
|
+
] }),
|
|
4437
|
+
icon && /* @__PURE__ */ jsx(Stack_default, { align: "center", justify: "center", className: "empty-state-icon color-muted", children: icon }),
|
|
4438
|
+
/* @__PURE__ */ jsxs(Stack_default, { gap: "05", textAlign: "center", children: [
|
|
4439
|
+
/* @__PURE__ */ jsx(Heading_default, { level, id: headingId, children: title }),
|
|
4440
|
+
/* @__PURE__ */ jsx(Text_default, { size: "md", tone: "secondary", lineHeight: "5", children: description })
|
|
4441
|
+
] }),
|
|
4442
|
+
buttonText && buttonOnClick && /* @__PURE__ */ jsx(
|
|
4443
|
+
Button_default,
|
|
4444
|
+
{
|
|
4445
|
+
variant: "solid",
|
|
4446
|
+
intent: "brand",
|
|
4447
|
+
size: "sm",
|
|
4448
|
+
onClick: buttonOnClick,
|
|
4449
|
+
isLoading: buttonIsLoading,
|
|
4450
|
+
className: "mt-05",
|
|
4451
|
+
children: buttonText
|
|
4452
|
+
}
|
|
4453
|
+
)
|
|
4454
|
+
] }) });
|
|
4455
|
+
});
|
|
4456
|
+
EmptyState.displayName = "EmptyState";
|
|
4457
|
+
var EmptyState_default = EmptyState;
|
|
4458
|
+
var DEFAULT_TONE_ICON = {
|
|
4459
|
+
neutral: /* @__PURE__ */ jsx(Bell, { size: 18 }),
|
|
4460
|
+
brand: /* @__PURE__ */ jsx(Info, { size: 18 }),
|
|
4461
|
+
success: /* @__PURE__ */ jsx(CircleCheck, { size: 18 }),
|
|
4462
|
+
warning: /* @__PURE__ */ jsx(TriangleAlert, { size: 18 }),
|
|
4463
|
+
danger: /* @__PURE__ */ jsx(CircleAlert, { size: 18 }),
|
|
4464
|
+
info: /* @__PURE__ */ jsx(Info, { size: 18 })
|
|
4465
|
+
};
|
|
4466
|
+
var Toast = forwardRef(({
|
|
4467
|
+
tone = "neutral",
|
|
4468
|
+
title,
|
|
4469
|
+
message,
|
|
4470
|
+
icon,
|
|
4471
|
+
onDismiss,
|
|
4472
|
+
action,
|
|
4473
|
+
dismissLabel = "Dismiss notification",
|
|
4474
|
+
ariaLive,
|
|
4475
|
+
className
|
|
4476
|
+
}, ref) => {
|
|
4477
|
+
const resolvedAriaLive = ariaLive ?? (tone === "danger" ? "assertive" : "polite");
|
|
4478
|
+
const showIcon = icon !== null;
|
|
4479
|
+
const resolvedIcon = icon ?? DEFAULT_TONE_ICON[tone];
|
|
4480
|
+
return /* @__PURE__ */ jsx(
|
|
4481
|
+
Surface_default,
|
|
4482
|
+
{
|
|
4483
|
+
ref,
|
|
4484
|
+
variant: "elevated",
|
|
4485
|
+
role: "status",
|
|
4486
|
+
"aria-live": resolvedAriaLive,
|
|
4487
|
+
"aria-atomic": "true",
|
|
4488
|
+
className: cn("volt-toast", `volt-toast--tone-${tone}`, className),
|
|
4489
|
+
children: /* @__PURE__ */ jsxs(Row_default, { align: "start", gap: "075", className: "volt-toast__layout", children: [
|
|
4490
|
+
showIcon && /* @__PURE__ */ jsx(IconFrame_default, { tone, size: "sm", className: "volt-toast__icon", children: resolvedIcon }),
|
|
4491
|
+
/* @__PURE__ */ jsxs(Stack_default, { gap: "025", className: "volt-toast__body", children: [
|
|
4492
|
+
title && /* @__PURE__ */ jsx(Text_default, { as: "p", size: "sm", weight: "semibold", tone: "primary", children: title }),
|
|
4493
|
+
/* @__PURE__ */ jsx(Text_default, { as: "div", size: "sm", tone: title ? "secondary" : "primary", children: message }),
|
|
4494
|
+
action && /* @__PURE__ */ jsx(Row_default, { gap: "05", className: "volt-toast__actions", children: action })
|
|
4495
|
+
] }),
|
|
4496
|
+
onDismiss && /* @__PURE__ */ jsx("div", { className: "volt-toast__dismiss", children: /* @__PURE__ */ jsx(CloseButton_default, { onClick: onDismiss, "aria-label": dismissLabel }) })
|
|
4497
|
+
] })
|
|
4498
|
+
}
|
|
4499
|
+
);
|
|
4500
|
+
});
|
|
4501
|
+
Toast.displayName = "Toast";
|
|
4502
|
+
var Toast_default = Toast;
|
|
4503
|
+
var ThinkingDots = forwardRef(({
|
|
4504
|
+
label = "Thinking",
|
|
4505
|
+
size: size2 = "md",
|
|
4506
|
+
className,
|
|
4507
|
+
...rest
|
|
4508
|
+
}, ref) => {
|
|
4509
|
+
return /* @__PURE__ */ jsxs(
|
|
4510
|
+
"span",
|
|
4511
|
+
{
|
|
4512
|
+
ref,
|
|
4513
|
+
role: "status",
|
|
4514
|
+
"aria-live": "polite",
|
|
4515
|
+
className: cn("volt-thinking-dots", `volt-thinking-dots--${size2}`, className),
|
|
4516
|
+
...rest,
|
|
4517
|
+
children: [
|
|
4518
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: label }),
|
|
4519
|
+
/* @__PURE__ */ jsx("span", { className: "volt-thinking-dots__dot", "aria-hidden": "true" }),
|
|
4520
|
+
/* @__PURE__ */ jsx("span", { className: "volt-thinking-dots__dot", "aria-hidden": "true" }),
|
|
4521
|
+
/* @__PURE__ */ jsx("span", { className: "volt-thinking-dots__dot", "aria-hidden": "true" })
|
|
4522
|
+
]
|
|
4523
|
+
}
|
|
4524
|
+
);
|
|
4525
|
+
});
|
|
4526
|
+
ThinkingDots.displayName = "ThinkingDots";
|
|
4527
|
+
var ThinkingDots_default = ThinkingDots;
|
|
4528
|
+
var MISSING_PROGRESS_NAME_WARNING = "ProgressBar requires an accessible name via `label`, `aria-label`, or `aria-labelledby`.";
|
|
4529
|
+
var clampPercent = (value) => {
|
|
4530
|
+
if (Number.isNaN(value)) return 0;
|
|
4531
|
+
if (value < 0) return 0;
|
|
4532
|
+
if (value > 100) return 100;
|
|
4533
|
+
return value;
|
|
4534
|
+
};
|
|
4535
|
+
var ProgressBar = forwardRef(({
|
|
4536
|
+
value = 0,
|
|
4537
|
+
tone = "brand",
|
|
4538
|
+
size: size2 = "md",
|
|
4539
|
+
label,
|
|
4540
|
+
showValue = false,
|
|
4541
|
+
indeterminate = false,
|
|
4542
|
+
className,
|
|
4543
|
+
id,
|
|
4544
|
+
style,
|
|
4545
|
+
"aria-label": ariaLabel,
|
|
4546
|
+
"aria-labelledby": ariaLabelledBy,
|
|
4547
|
+
"aria-describedby": ariaDescribedBy,
|
|
4548
|
+
...rest
|
|
4549
|
+
}, ref) => {
|
|
4550
|
+
const hasWarnedForMissingNameRef = useRef(false);
|
|
4551
|
+
const generatedId = useId();
|
|
4552
|
+
const labelId = `${generatedId}-label`;
|
|
4553
|
+
const percent = clampPercent(value);
|
|
4554
|
+
const rounded = Math.round(percent);
|
|
4555
|
+
const resolvedAriaLabel = ariaLabel?.trim() || void 0;
|
|
4556
|
+
const resolvedAriaLabelledBy = ariaLabelledBy?.trim() || void 0;
|
|
4557
|
+
const hasVisibleLabel = label !== void 0 && label !== null && label !== false;
|
|
4558
|
+
const computedLabelledBy = resolvedAriaLabelledBy ?? (hasVisibleLabel ? labelId : void 0);
|
|
4559
|
+
if (!computedLabelledBy && !resolvedAriaLabel) {
|
|
4560
|
+
if (!hasWarnedForMissingNameRef.current) {
|
|
4561
|
+
console.warn(MISSING_PROGRESS_NAME_WARNING);
|
|
4562
|
+
hasWarnedForMissingNameRef.current = true;
|
|
4563
|
+
}
|
|
4564
|
+
}
|
|
4565
|
+
const fill = tone === "brand" ? "var(--color-brand-primary)" : STATUS_TONE_VARS[tone].fg;
|
|
4566
|
+
const resolvedStyle = {
|
|
4567
|
+
...style,
|
|
4568
|
+
"--progress-fill": fill,
|
|
4569
|
+
"--progress-value": `${percent}%`
|
|
4570
|
+
};
|
|
4571
|
+
const classes = cn(
|
|
4572
|
+
"volt-progress",
|
|
4573
|
+
`volt-progress--size-${size2}`,
|
|
4574
|
+
indeterminate && "volt-progress--indeterminate"
|
|
4575
|
+
);
|
|
4576
|
+
const showHeader = hasVisibleLabel || showValue && !indeterminate;
|
|
4577
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("volt-progress-root", className), children: [
|
|
4578
|
+
showHeader && /* @__PURE__ */ jsxs(Row_default, { justify: "between", align: "center", gap: "05", className: "volt-progress-header", children: [
|
|
4579
|
+
hasVisibleLabel ? /* @__PURE__ */ jsx(Text_default, { as: "span", id: labelId, size: "sm", tone: "secondary", children: label }) : /* @__PURE__ */ jsx("span", {}),
|
|
4580
|
+
showValue && !indeterminate && /* @__PURE__ */ jsxs(Text_default, { as: "span", size: "sm", tone: "muted", className: "volt-progress-value", children: [
|
|
4581
|
+
rounded,
|
|
4582
|
+
"%"
|
|
4583
|
+
] })
|
|
4584
|
+
] }),
|
|
4585
|
+
/* @__PURE__ */ jsx(
|
|
4586
|
+
"div",
|
|
4587
|
+
{
|
|
4588
|
+
ref,
|
|
4589
|
+
id,
|
|
4590
|
+
role: "progressbar",
|
|
4591
|
+
className: classes,
|
|
4592
|
+
style: resolvedStyle,
|
|
4593
|
+
"aria-label": resolvedAriaLabel,
|
|
4594
|
+
"aria-labelledby": computedLabelledBy,
|
|
4595
|
+
"aria-describedby": ariaDescribedBy,
|
|
4596
|
+
"aria-valuemin": indeterminate ? void 0 : 0,
|
|
4597
|
+
"aria-valuemax": indeterminate ? void 0 : 100,
|
|
4598
|
+
"aria-valuenow": indeterminate ? void 0 : rounded,
|
|
4599
|
+
"aria-valuetext": indeterminate ? void 0 : `${rounded}%`,
|
|
4600
|
+
"aria-busy": indeterminate || void 0,
|
|
4601
|
+
...rest,
|
|
4602
|
+
children: /* @__PURE__ */ jsx("div", { className: "volt-progress-fill", "aria-hidden": "true" })
|
|
4603
|
+
}
|
|
4604
|
+
)
|
|
4605
|
+
] });
|
|
4606
|
+
});
|
|
4607
|
+
ProgressBar.displayName = "ProgressBar";
|
|
4608
|
+
var ProgressBar_default = ProgressBar;
|
|
4609
|
+
var MISSING_METER_NAME_WARNING = "Meter requires an accessible name via `label`, `aria-label`, or `aria-labelledby`.";
|
|
4610
|
+
var clamp3 = (value, min, max) => {
|
|
4611
|
+
if (Number.isNaN(value)) return min;
|
|
4612
|
+
if (value < min) return min;
|
|
4613
|
+
if (value > max) return max;
|
|
4614
|
+
return value;
|
|
4615
|
+
};
|
|
4616
|
+
var Meter = forwardRef(({
|
|
4617
|
+
value,
|
|
4618
|
+
min = 0,
|
|
4619
|
+
max = 100,
|
|
4620
|
+
tone = "brand",
|
|
4621
|
+
label,
|
|
4622
|
+
showValue = false,
|
|
4623
|
+
formatValue,
|
|
4624
|
+
className,
|
|
4625
|
+
id,
|
|
4626
|
+
style,
|
|
4627
|
+
"aria-label": ariaLabel,
|
|
4628
|
+
"aria-labelledby": ariaLabelledBy,
|
|
4629
|
+
"aria-describedby": ariaDescribedBy,
|
|
4630
|
+
...rest
|
|
4631
|
+
}, ref) => {
|
|
4632
|
+
const hasWarnedForMissingNameRef = useRef(false);
|
|
4633
|
+
const generatedId = useId();
|
|
4634
|
+
const labelId = `${generatedId}-label`;
|
|
4635
|
+
const safeMax = max > min ? max : min + 1;
|
|
4636
|
+
const clamped = clamp3(value, min, safeMax);
|
|
4637
|
+
const percent = (clamped - min) / (safeMax - min) * 100;
|
|
4638
|
+
const resolvedAriaLabel = ariaLabel?.trim() || void 0;
|
|
4639
|
+
const resolvedAriaLabelledBy = ariaLabelledBy?.trim() || void 0;
|
|
4640
|
+
const hasVisibleLabel = label !== void 0 && label !== null && label !== false;
|
|
4641
|
+
const computedLabelledBy = resolvedAriaLabelledBy ?? (hasVisibleLabel ? labelId : void 0);
|
|
4642
|
+
if (!computedLabelledBy && !resolvedAriaLabel) {
|
|
4643
|
+
if (!hasWarnedForMissingNameRef.current) {
|
|
4644
|
+
console.warn(MISSING_METER_NAME_WARNING);
|
|
4645
|
+
hasWarnedForMissingNameRef.current = true;
|
|
4646
|
+
}
|
|
4647
|
+
}
|
|
4648
|
+
const fill = tone === "brand" ? "var(--color-brand-primary)" : STATUS_TONE_VARS[tone].fg;
|
|
4649
|
+
const resolvedStyle = {
|
|
4650
|
+
...style,
|
|
4651
|
+
"--progress-fill": fill,
|
|
4652
|
+
"--progress-value": `${percent}%`
|
|
4653
|
+
};
|
|
4654
|
+
const formattedValue = formatValue ? formatValue(clamped, min, safeMax) : clamped;
|
|
4655
|
+
return /* @__PURE__ */ jsxs(
|
|
4656
|
+
Row_default,
|
|
4657
|
+
{
|
|
4658
|
+
align: "center",
|
|
4659
|
+
gap: "05",
|
|
4660
|
+
className: cn("volt-meter", className),
|
|
4661
|
+
children: [
|
|
4662
|
+
hasVisibleLabel && /* @__PURE__ */ jsx(Text_default, { as: "span", id: labelId, size: "sm", tone: "secondary", className: "volt-meter-label", children: label }),
|
|
4663
|
+
/* @__PURE__ */ jsx(
|
|
4664
|
+
"div",
|
|
4665
|
+
{
|
|
4666
|
+
ref,
|
|
4667
|
+
id,
|
|
4668
|
+
role: "meter",
|
|
4669
|
+
className: "volt-meter-track",
|
|
4670
|
+
style: resolvedStyle,
|
|
4671
|
+
"aria-label": resolvedAriaLabel,
|
|
4672
|
+
"aria-labelledby": computedLabelledBy,
|
|
4673
|
+
"aria-describedby": ariaDescribedBy,
|
|
4674
|
+
"aria-valuemin": min,
|
|
4675
|
+
"aria-valuemax": safeMax,
|
|
4676
|
+
"aria-valuenow": clamped,
|
|
4677
|
+
...rest,
|
|
4678
|
+
children: /* @__PURE__ */ jsx("div", { className: "volt-meter-fill", "aria-hidden": "true" })
|
|
4679
|
+
}
|
|
4680
|
+
),
|
|
4681
|
+
showValue && /* @__PURE__ */ jsx(Text_default, { as: "span", size: "sm", tone: "muted", className: "volt-meter-value", children: formattedValue })
|
|
4682
|
+
]
|
|
4683
|
+
}
|
|
4684
|
+
);
|
|
4685
|
+
});
|
|
4686
|
+
Meter.displayName = "Meter";
|
|
4687
|
+
var Meter_default = Meter;
|
|
4688
|
+
var AsyncBoundary = ({
|
|
4689
|
+
state,
|
|
4690
|
+
loading,
|
|
4691
|
+
error,
|
|
4692
|
+
accessDenied,
|
|
4693
|
+
empty,
|
|
4694
|
+
children
|
|
4695
|
+
}) => {
|
|
4696
|
+
if (state.accessDenied && accessDenied) return /* @__PURE__ */ jsx(Fragment, { children: accessDenied });
|
|
4697
|
+
if (state.error !== void 0 && state.error !== null) return /* @__PURE__ */ jsx(Fragment, { children: error(state.error) });
|
|
4698
|
+
if (state.loading) return /* @__PURE__ */ jsx(Fragment, { children: loading });
|
|
4699
|
+
if (state.empty && empty !== void 0) return /* @__PURE__ */ jsx(Fragment, { children: empty });
|
|
4700
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
4701
|
+
};
|
|
4702
|
+
var AsyncBoundary_default = AsyncBoundary;
|
|
4703
|
+
var VisuallyHidden = forwardRef(({
|
|
4704
|
+
as,
|
|
4705
|
+
className,
|
|
4706
|
+
children,
|
|
4707
|
+
...rest
|
|
4708
|
+
}, ref) => {
|
|
4709
|
+
const Component = as ?? "span";
|
|
4710
|
+
return /* @__PURE__ */ jsx(Component, { ref, className: cn("sr-only", className), ...rest, children });
|
|
4711
|
+
});
|
|
4712
|
+
VisuallyHidden.displayName = "VisuallyHidden";
|
|
4713
|
+
var VisuallyHidden_default = VisuallyHidden;
|
|
4714
|
+
|
|
4715
|
+
export { AsyncBoundary_default as AsyncBoundary, Avatar_default as Avatar, AvatarStack_default as AvatarStack, BOX_STYLE_KEYS, Box_default as Box, Breadcrumbs_default as Breadcrumbs, Button_default as Button, Callout_default as Callout, Card_default as Card, CardBody, CardFooter, CardHeader, Checkbox_default as Checkbox, CloseButton_default as CloseButton, CollapsibleSection_default as CollapsibleSection, CursorTooltip_default as CursorTooltip, DashedActionBox_default as DashedActionBox, Divider_default as Divider, EmptyState_default as EmptyState, FloatingToolbar_default as FloatingToolbar, FormField_default as FormField, Grid_default as Grid, Heading_default as Heading, IconButton_default as IconButton, IconFrame_default as IconFrame, InlineStatus_default as InlineStatus, KeyValueList_default as KeyValueList, KeyValueRow, LiquidToggle_default as LiquidToggle, ListRow_default as ListRow, Loader_default as Loader, Menu_default as Menu, Meter_default as Meter, Modal_default as Modal, NumberInput_default as NumberInput, Popover_default as Popover, PopoverMenu_default as PopoverMenu, PopoverMenuItem_default as PopoverMenuItem, ProgressBar_default as ProgressBar, Radio_default as Radio, Row_default as Row, STATUS_TONE_VARS, SaveStatusIndicator_default as SaveStatusIndicator, SearchInput_default as SearchInput, SectionLabel_default as SectionLabel, SegmentedTabs_default as SegmentedTabs, Select_default as Select, SelectableCard_default as SelectableCard, Skeleton_default as Skeleton, Slider_default as Slider, Sparkline_default as Sparkline, Stack_default as Stack, StatCard_default as StatCard, StatusBadge_default as StatusBadge, StatusDot_default as StatusDot, Stepper_default as Stepper, Surface_default as Surface, Tab, Table_default as Table, TableSortDirection, Tabs_default as Tabs, TabsList, TabsPanel, Tag_default as Tag, Text_default as Text, TextInput_default as TextInput, Textarea_default as Textarea, ThinkingDots_default as ThinkingDots, Timeline_default as Timeline, TimelineItem, Toast_default as Toast, Tooltip_default as Tooltip, VisuallyHidden_default as VisuallyHidden, buildBoxClasses, buildTypographyClasses, closeModal, openModal, resetModal, splitBoxProps };
|
|
4716
|
+
//# sourceMappingURL=index.js.map
|
|
4717
|
+
//# sourceMappingURL=index.js.map
|