@cocliny/ui-library 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1346 -0
- package/dist/index.js +3611 -0
- package/dist/index.js.map +1 -0
- package/dist/styles.css +3212 -0
- package/package.json +73 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,3611 @@
|
|
|
1
|
+
import { clsx } from 'clsx';
|
|
2
|
+
import { extendTailwindMerge } from 'tailwind-merge';
|
|
3
|
+
import * as React5 from 'react';
|
|
4
|
+
import { createContext, forwardRef, useState, useContext, useEffect, useCallback, useMemo, useId, useRef, Fragment as Fragment$1 } from 'react';
|
|
5
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
6
|
+
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
7
|
+
import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';
|
|
8
|
+
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
9
|
+
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
10
|
+
import * as ToastPrimitives from '@radix-ui/react-toast';
|
|
11
|
+
import { useControllableState } from '@cocliny/util-library/react';
|
|
12
|
+
import { DayPicker } from 'react-day-picker';
|
|
13
|
+
import { format } from 'date-fns';
|
|
14
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
15
|
+
import { useFormContext, FormProvider, Controller } from 'react-hook-form';
|
|
16
|
+
import * as ToggleGroupPrimitive from '@radix-ui/react-toggle-group';
|
|
17
|
+
import { Command as Command$1 } from 'cmdk';
|
|
18
|
+
import { pageRange, PAGE_ELLIPSIS } from '@cocliny/util-library';
|
|
19
|
+
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
20
|
+
import * as AccordionPrimitive from '@radix-ui/react-accordion';
|
|
21
|
+
import * as AvatarPrimitive from '@radix-ui/react-avatar';
|
|
22
|
+
import { useReactTable, getSortedRowModel, getCoreRowModel, flexRender } from '@tanstack/react-table';
|
|
23
|
+
import { ResponsiveContainer, LineChart as LineChart$1, Line, BarChart as BarChart$1, Bar, AreaChart as AreaChart$1, Area, CartesianGrid, XAxis, YAxis, Tooltip as Tooltip$1, Legend } from 'recharts';
|
|
24
|
+
|
|
25
|
+
// src/foundation/cn.ts
|
|
26
|
+
var twMerge = extendTailwindMerge({
|
|
27
|
+
extend: {
|
|
28
|
+
classGroups: {
|
|
29
|
+
"focus-ring": ["focus-ring"]
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
function cn(...inputs) {
|
|
34
|
+
return twMerge(clsx(inputs));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// src/foundation/variants.ts
|
|
38
|
+
function defineVariants(config) {
|
|
39
|
+
const { base, variants, compoundVariants = [], defaultVariants = {} } = config;
|
|
40
|
+
const variantKeys = Object.keys(variants);
|
|
41
|
+
return (selection = {}) => {
|
|
42
|
+
const resolved = { ...defaultVariants };
|
|
43
|
+
for (const key of variantKeys) {
|
|
44
|
+
const value = selection[key];
|
|
45
|
+
if (value !== void 0) {
|
|
46
|
+
resolved[key] = value;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const classes = [base];
|
|
50
|
+
for (const key of variantKeys) {
|
|
51
|
+
const value = resolved[key];
|
|
52
|
+
if (value !== void 0) classes.push(variants[key]?.[String(value)]);
|
|
53
|
+
}
|
|
54
|
+
for (const compound of compoundVariants) {
|
|
55
|
+
let matches = true;
|
|
56
|
+
for (const key of variantKeys) {
|
|
57
|
+
const condition = compound[key];
|
|
58
|
+
if (condition !== void 0 && String(resolved[key]) !== String(condition)) {
|
|
59
|
+
matches = false;
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (matches) classes.push(compound.className);
|
|
64
|
+
}
|
|
65
|
+
classes.push(selection.className);
|
|
66
|
+
return cn(...classes);
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// src/foundation/theme/tokens.ts
|
|
71
|
+
var TOKEN_CSS_VARS = {
|
|
72
|
+
background: "--ml-background",
|
|
73
|
+
surface: "--ml-surface",
|
|
74
|
+
surfaceRaised: "--ml-surface-raised",
|
|
75
|
+
surfaceSunken: "--ml-surface-sunken",
|
|
76
|
+
overlay: "--ml-overlay",
|
|
77
|
+
border: "--ml-border",
|
|
78
|
+
borderStrong: "--ml-border-strong",
|
|
79
|
+
fg: "--ml-fg",
|
|
80
|
+
fgMuted: "--ml-fg-muted",
|
|
81
|
+
fgSubtle: "--ml-fg-subtle",
|
|
82
|
+
fgDisabled: "--ml-fg-disabled",
|
|
83
|
+
fgInverted: "--ml-fg-inverted",
|
|
84
|
+
primary: "--ml-primary",
|
|
85
|
+
primaryHover: "--ml-primary-hover",
|
|
86
|
+
primaryActive: "--ml-primary-active",
|
|
87
|
+
primaryFg: "--ml-primary-fg",
|
|
88
|
+
primarySubtle: "--ml-primary-subtle",
|
|
89
|
+
primarySubtleFg: "--ml-primary-subtle-fg",
|
|
90
|
+
success: "--ml-success",
|
|
91
|
+
successFg: "--ml-success-fg",
|
|
92
|
+
successSubtle: "--ml-success-subtle",
|
|
93
|
+
successSubtleFg: "--ml-success-subtle-fg",
|
|
94
|
+
warning: "--ml-warning",
|
|
95
|
+
warningFg: "--ml-warning-fg",
|
|
96
|
+
warningSubtle: "--ml-warning-subtle",
|
|
97
|
+
warningSubtleFg: "--ml-warning-subtle-fg",
|
|
98
|
+
danger: "--ml-danger",
|
|
99
|
+
dangerFg: "--ml-danger-fg",
|
|
100
|
+
dangerSubtle: "--ml-danger-subtle",
|
|
101
|
+
dangerSubtleFg: "--ml-danger-subtle-fg",
|
|
102
|
+
info: "--ml-info",
|
|
103
|
+
infoFg: "--ml-info-fg",
|
|
104
|
+
infoSubtle: "--ml-info-subtle",
|
|
105
|
+
infoSubtleFg: "--ml-info-subtle-fg",
|
|
106
|
+
focusRing: "--ml-focus-ring",
|
|
107
|
+
focusRingWidth: "--ml-focus-ring-width",
|
|
108
|
+
focusRingOffset: "--ml-focus-ring-offset",
|
|
109
|
+
durationFast: "--ml-duration-fast",
|
|
110
|
+
durationNormal: "--ml-duration-normal",
|
|
111
|
+
durationSlow: "--ml-duration-slow"
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
// src/foundation/theme/cssVars.ts
|
|
115
|
+
function declarations(values) {
|
|
116
|
+
return Object.keys(values).map((token) => {
|
|
117
|
+
const value = values[token];
|
|
118
|
+
return value === void 0 ? null : `${TOKEN_CSS_VARS[token]}: ${value};`;
|
|
119
|
+
}).filter((d) => d !== null).join(" ");
|
|
120
|
+
}
|
|
121
|
+
function themeOverridesToCss(overrides, scope = ":root") {
|
|
122
|
+
const rules = [];
|
|
123
|
+
const light = { ...overrides.common, ...overrides.light };
|
|
124
|
+
const dark = { ...overrides.common, ...overrides.dark };
|
|
125
|
+
const lightDecls = declarations(light);
|
|
126
|
+
if (lightDecls) rules.push(`${scope} { ${lightDecls} }`);
|
|
127
|
+
const darkDecls = declarations(dark);
|
|
128
|
+
if (darkDecls) {
|
|
129
|
+
const darkScope = scope === ":root" ? `[data-theme="dark"]` : `[data-theme="dark"] ${scope}, ${scope}[data-theme="dark"]`;
|
|
130
|
+
rules.push(`${darkScope} { ${darkDecls} }`);
|
|
131
|
+
}
|
|
132
|
+
return rules.join("\n");
|
|
133
|
+
}
|
|
134
|
+
var DEFAULT_STORAGE_KEY = "ml-color-scheme";
|
|
135
|
+
var ThemeContext = createContext(null);
|
|
136
|
+
function systemScheme() {
|
|
137
|
+
if (typeof window === "undefined") return "light";
|
|
138
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
139
|
+
}
|
|
140
|
+
function readStoredScheme(storageKey) {
|
|
141
|
+
if (storageKey === null || typeof window === "undefined") return null;
|
|
142
|
+
try {
|
|
143
|
+
const raw = window.localStorage.getItem(storageKey);
|
|
144
|
+
return raw === "light" || raw === "dark" || raw === "system" ? raw : null;
|
|
145
|
+
} catch {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function ThemeProvider({
|
|
150
|
+
children,
|
|
151
|
+
defaultColorScheme = "system",
|
|
152
|
+
defaultDensity = "comfortable",
|
|
153
|
+
overrides,
|
|
154
|
+
storageKey = DEFAULT_STORAGE_KEY
|
|
155
|
+
}) {
|
|
156
|
+
const [colorScheme, setColorSchemeState] = useState(defaultColorScheme);
|
|
157
|
+
const [resolvedColorScheme, setResolvedColorScheme] = useState(
|
|
158
|
+
defaultColorScheme === "dark" ? "dark" : "light"
|
|
159
|
+
);
|
|
160
|
+
const [density, setDensityState] = useState(defaultDensity);
|
|
161
|
+
useEffect(() => {
|
|
162
|
+
const stored = readStoredScheme(storageKey);
|
|
163
|
+
if (stored !== null) setColorSchemeState(stored);
|
|
164
|
+
}, []);
|
|
165
|
+
useEffect(() => {
|
|
166
|
+
const apply = () => {
|
|
167
|
+
const resolved = colorScheme === "system" ? systemScheme() : colorScheme;
|
|
168
|
+
setResolvedColorScheme(resolved);
|
|
169
|
+
document.documentElement.setAttribute("data-theme", resolved);
|
|
170
|
+
};
|
|
171
|
+
apply();
|
|
172
|
+
if (colorScheme !== "system") return;
|
|
173
|
+
const media = window.matchMedia("(prefers-color-scheme: dark)");
|
|
174
|
+
media.addEventListener("change", apply);
|
|
175
|
+
return () => {
|
|
176
|
+
media.removeEventListener("change", apply);
|
|
177
|
+
};
|
|
178
|
+
}, [colorScheme]);
|
|
179
|
+
useEffect(() => {
|
|
180
|
+
document.documentElement.setAttribute("data-density", density);
|
|
181
|
+
}, [density]);
|
|
182
|
+
const setColorScheme = useCallback(
|
|
183
|
+
(scheme) => {
|
|
184
|
+
setColorSchemeState(scheme);
|
|
185
|
+
if (storageKey !== null) {
|
|
186
|
+
try {
|
|
187
|
+
window.localStorage.setItem(storageKey, scheme);
|
|
188
|
+
} catch {
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
[storageKey]
|
|
193
|
+
);
|
|
194
|
+
const setDensity = useCallback((next) => {
|
|
195
|
+
setDensityState(next);
|
|
196
|
+
}, []);
|
|
197
|
+
const value = useMemo(
|
|
198
|
+
() => ({ colorScheme, resolvedColorScheme, setColorScheme, density, setDensity }),
|
|
199
|
+
[colorScheme, resolvedColorScheme, setColorScheme, density, setDensity]
|
|
200
|
+
);
|
|
201
|
+
const overrideCss = useMemo(
|
|
202
|
+
() => overrides ? themeOverridesToCss(overrides) : "",
|
|
203
|
+
[overrides]
|
|
204
|
+
);
|
|
205
|
+
return /* @__PURE__ */ jsxs(ThemeContext.Provider, { value, children: [
|
|
206
|
+
overrideCss ? /* @__PURE__ */ jsx("style", { "data-ml-theme-overrides": "", children: overrideCss }) : null,
|
|
207
|
+
children
|
|
208
|
+
] });
|
|
209
|
+
}
|
|
210
|
+
function useTheme() {
|
|
211
|
+
const ctx = useContext(ThemeContext);
|
|
212
|
+
if (ctx === null) {
|
|
213
|
+
throw new Error("useTheme must be used within a <ThemeProvider>.");
|
|
214
|
+
}
|
|
215
|
+
return ctx;
|
|
216
|
+
}
|
|
217
|
+
function getThemeInitScript(storageKey = DEFAULT_STORAGE_KEY) {
|
|
218
|
+
return `(function(){try{var k=${JSON.stringify(storageKey)};var s=localStorage.getItem(k);if(s!=="light"&&s!=="dark")s=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";document.documentElement.setAttribute("data-theme",s);}catch(e){}})();`;
|
|
219
|
+
}
|
|
220
|
+
var text = defineVariants({
|
|
221
|
+
variants: {
|
|
222
|
+
size: {
|
|
223
|
+
xs: "text-xs",
|
|
224
|
+
sm: "text-sm",
|
|
225
|
+
md: "text-base",
|
|
226
|
+
lg: "text-lg",
|
|
227
|
+
xl: "text-xl"
|
|
228
|
+
},
|
|
229
|
+
weight: {
|
|
230
|
+
regular: "font-normal",
|
|
231
|
+
medium: "font-medium",
|
|
232
|
+
semibold: "font-semibold",
|
|
233
|
+
bold: "font-bold"
|
|
234
|
+
},
|
|
235
|
+
tone: {
|
|
236
|
+
default: "text-fg",
|
|
237
|
+
muted: "text-fg-muted",
|
|
238
|
+
subtle: "text-fg-subtle",
|
|
239
|
+
disabled: "text-fg-disabled",
|
|
240
|
+
danger: "text-danger-subtle-fg",
|
|
241
|
+
success: "text-success-subtle-fg",
|
|
242
|
+
inverted: "text-fg-inverted"
|
|
243
|
+
},
|
|
244
|
+
align: {
|
|
245
|
+
left: "text-left",
|
|
246
|
+
center: "text-center",
|
|
247
|
+
right: "text-right"
|
|
248
|
+
},
|
|
249
|
+
truncate: {
|
|
250
|
+
true: "block max-w-full truncate",
|
|
251
|
+
false: ""
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
defaultVariants: { size: "md", weight: "regular", tone: "default", align: "left", truncate: false }
|
|
255
|
+
});
|
|
256
|
+
function Text(props) {
|
|
257
|
+
const { as, size, weight, tone, align, truncate, className, ...rest } = props;
|
|
258
|
+
const Component = as ?? "span";
|
|
259
|
+
return /* @__PURE__ */ jsx(
|
|
260
|
+
Component,
|
|
261
|
+
{
|
|
262
|
+
className: text({ size, weight, tone, align, truncate, className }),
|
|
263
|
+
...rest
|
|
264
|
+
}
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
var heading = defineVariants({
|
|
268
|
+
base: "text-fg font-bold tracking-tight",
|
|
269
|
+
variants: {
|
|
270
|
+
size: {
|
|
271
|
+
xs: "text-sm",
|
|
272
|
+
sm: "text-base",
|
|
273
|
+
md: "text-lg",
|
|
274
|
+
lg: "text-xl",
|
|
275
|
+
xl: "text-2xl",
|
|
276
|
+
"2xl": "text-3xl"
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
defaultVariants: { size: "lg" }
|
|
280
|
+
});
|
|
281
|
+
function Heading(props) {
|
|
282
|
+
const { as, level = 2, size, className, ...rest } = props;
|
|
283
|
+
const Component = as ?? `h${String(level)}`;
|
|
284
|
+
return /* @__PURE__ */ jsx(Component, { className: heading({ size, className }), ...rest });
|
|
285
|
+
}
|
|
286
|
+
function Label({ required = false, className, children, ...rest }) {
|
|
287
|
+
return /* @__PURE__ */ jsxs("label", { className: cn("inline-flex items-center gap-1 text-sm font-medium text-fg", className), ...rest, children: [
|
|
288
|
+
children,
|
|
289
|
+
required && /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "text-danger-subtle-fg", children: "*" }),
|
|
290
|
+
required && /* @__PURE__ */ jsx("span", { className: "sr-only", children: "(required)" })
|
|
291
|
+
] });
|
|
292
|
+
}
|
|
293
|
+
function Code({ block = false, className, children, ...rest }) {
|
|
294
|
+
if (block) {
|
|
295
|
+
return /* @__PURE__ */ jsx("pre", { className: cn("overflow-x-auto rounded-md border border-line bg-surface-sunken p-3 font-mono text-sm text-fg", className), children: /* @__PURE__ */ jsx("code", { ...rest, children }) });
|
|
296
|
+
}
|
|
297
|
+
return /* @__PURE__ */ jsx(
|
|
298
|
+
"code",
|
|
299
|
+
{
|
|
300
|
+
className: cn("rounded-xs border border-line bg-surface-sunken px-1 py-0.5 font-mono text-[0.85em] text-fg", className),
|
|
301
|
+
...rest,
|
|
302
|
+
children
|
|
303
|
+
}
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
var link = defineVariants({
|
|
307
|
+
base: "focus-ring rounded-xs font-medium underline-offset-2 transition-colors duration-(--ml-duration-fast)",
|
|
308
|
+
variants: {
|
|
309
|
+
variant: {
|
|
310
|
+
/** Colored, underline on hover — default for inline links. */
|
|
311
|
+
default: "text-primary-subtle-fg hover:underline",
|
|
312
|
+
/** Always underlined — for body copy where color alone is insufficient. */
|
|
313
|
+
underline: "text-primary-subtle-fg underline hover:text-primary",
|
|
314
|
+
/** Inherits color — for links inside already-colored contexts. */
|
|
315
|
+
inherit: "text-inherit underline hover:no-underline"
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
defaultVariants: { variant: "default" }
|
|
319
|
+
});
|
|
320
|
+
function Link(props) {
|
|
321
|
+
const { as, variant, className, ...rest } = props;
|
|
322
|
+
const Component = as ?? "a";
|
|
323
|
+
return /* @__PURE__ */ jsx(Component, { className: link({ variant, className }), ...rest });
|
|
324
|
+
}
|
|
325
|
+
var spinner = defineVariants({
|
|
326
|
+
base: "inline-block animate-spin rounded-full border-2 border-current border-t-transparent",
|
|
327
|
+
variants: {
|
|
328
|
+
size: {
|
|
329
|
+
xs: "size-3",
|
|
330
|
+
sm: "size-4",
|
|
331
|
+
md: "size-5",
|
|
332
|
+
lg: "size-8"
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
defaultVariants: { size: "md" }
|
|
336
|
+
});
|
|
337
|
+
function Spinner({ size, label = "Loading", className }) {
|
|
338
|
+
return /* @__PURE__ */ jsxs(
|
|
339
|
+
"span",
|
|
340
|
+
{
|
|
341
|
+
role: label === null ? void 0 : "status",
|
|
342
|
+
"aria-hidden": label === null ? true : void 0,
|
|
343
|
+
className: cn("inline-flex", className),
|
|
344
|
+
children: [
|
|
345
|
+
/* @__PURE__ */ jsx("span", { className: spinner({ size }) }),
|
|
346
|
+
label !== null && /* @__PURE__ */ jsx("span", { className: "sr-only", children: label })
|
|
347
|
+
]
|
|
348
|
+
}
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
var button = defineVariants({
|
|
352
|
+
base: "focus-ring inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md font-semibold transition-colors duration-(--ml-duration-fast) disabled:cursor-not-allowed disabled:opacity-55 aria-busy:cursor-wait",
|
|
353
|
+
variants: {
|
|
354
|
+
variant: {
|
|
355
|
+
solid: "",
|
|
356
|
+
outline: "border bg-transparent",
|
|
357
|
+
ghost: "bg-transparent",
|
|
358
|
+
subtle: ""
|
|
359
|
+
},
|
|
360
|
+
intent: {
|
|
361
|
+
primary: "",
|
|
362
|
+
neutral: "",
|
|
363
|
+
success: "",
|
|
364
|
+
warning: "",
|
|
365
|
+
danger: ""
|
|
366
|
+
},
|
|
367
|
+
size: {
|
|
368
|
+
sm: "h-(--ml-control-h-sm) px-3 text-sm",
|
|
369
|
+
md: "h-(--ml-control-h-md) px-(--ml-control-px) text-sm",
|
|
370
|
+
lg: "h-(--ml-control-h-lg) px-5 text-base"
|
|
371
|
+
},
|
|
372
|
+
fullWidth: { true: "w-full", false: "" }
|
|
373
|
+
},
|
|
374
|
+
compoundVariants: [
|
|
375
|
+
// solid
|
|
376
|
+
{ variant: "solid", intent: "primary", className: "bg-primary text-primary-fg hover:bg-primary-hover active:bg-primary-active" },
|
|
377
|
+
{ variant: "solid", intent: "neutral", className: "bg-surface-sunken text-fg hover:bg-line" },
|
|
378
|
+
{ variant: "solid", intent: "success", className: "bg-success text-success-fg hover:opacity-90" },
|
|
379
|
+
{ variant: "solid", intent: "warning", className: "bg-warning text-warning-fg hover:opacity-90" },
|
|
380
|
+
{ variant: "solid", intent: "danger", className: "bg-danger text-danger-fg hover:opacity-90" },
|
|
381
|
+
// outline
|
|
382
|
+
{ variant: "outline", intent: "primary", className: "border-line-strong text-primary-subtle-fg hover:bg-primary-subtle" },
|
|
383
|
+
{ variant: "outline", intent: "neutral", className: "border-line-strong text-fg hover:bg-surface-sunken" },
|
|
384
|
+
{ variant: "outline", intent: "success", className: "border-line-strong text-success-subtle-fg hover:bg-success-subtle" },
|
|
385
|
+
{ variant: "outline", intent: "warning", className: "border-line-strong text-warning-subtle-fg hover:bg-warning-subtle" },
|
|
386
|
+
{ variant: "outline", intent: "danger", className: "border-line-strong text-danger-subtle-fg hover:bg-danger-subtle" },
|
|
387
|
+
// ghost
|
|
388
|
+
{ variant: "ghost", intent: "primary", className: "text-primary-subtle-fg hover:bg-primary-subtle" },
|
|
389
|
+
{ variant: "ghost", intent: "neutral", className: "text-fg-muted hover:bg-surface-sunken hover:text-fg" },
|
|
390
|
+
{ variant: "ghost", intent: "success", className: "text-success-subtle-fg hover:bg-success-subtle" },
|
|
391
|
+
{ variant: "ghost", intent: "warning", className: "text-warning-subtle-fg hover:bg-warning-subtle" },
|
|
392
|
+
{ variant: "ghost", intent: "danger", className: "text-danger-subtle-fg hover:bg-danger-subtle" },
|
|
393
|
+
// subtle (tinted fill)
|
|
394
|
+
{ variant: "subtle", intent: "primary", className: "bg-primary-subtle text-primary-subtle-fg hover:bg-primary-subtle/80" },
|
|
395
|
+
{ variant: "subtle", intent: "neutral", className: "bg-surface-sunken text-fg hover:bg-line" },
|
|
396
|
+
{ variant: "subtle", intent: "success", className: "bg-success-subtle text-success-subtle-fg hover:bg-success-subtle/80" },
|
|
397
|
+
{ variant: "subtle", intent: "warning", className: "bg-warning-subtle text-warning-subtle-fg hover:bg-warning-subtle/80" },
|
|
398
|
+
{ variant: "subtle", intent: "danger", className: "bg-danger-subtle text-danger-subtle-fg hover:bg-danger-subtle/80" }
|
|
399
|
+
],
|
|
400
|
+
defaultVariants: { variant: "solid", intent: "primary", size: "md", fullWidth: false }
|
|
401
|
+
});
|
|
402
|
+
var Button = forwardRef(function Button2({
|
|
403
|
+
variant,
|
|
404
|
+
intent,
|
|
405
|
+
size,
|
|
406
|
+
loading = false,
|
|
407
|
+
startIcon,
|
|
408
|
+
endIcon,
|
|
409
|
+
fullWidth,
|
|
410
|
+
disabled = false,
|
|
411
|
+
type = "button",
|
|
412
|
+
className,
|
|
413
|
+
children,
|
|
414
|
+
onClick,
|
|
415
|
+
...rest
|
|
416
|
+
}, ref) {
|
|
417
|
+
return /* @__PURE__ */ jsxs(
|
|
418
|
+
"button",
|
|
419
|
+
{
|
|
420
|
+
ref,
|
|
421
|
+
type,
|
|
422
|
+
disabled: disabled || loading,
|
|
423
|
+
"aria-busy": loading || void 0,
|
|
424
|
+
onClick: loading ? void 0 : onClick,
|
|
425
|
+
className: button({ variant, intent, size, fullWidth, className }),
|
|
426
|
+
...rest,
|
|
427
|
+
children: [
|
|
428
|
+
loading ? /* @__PURE__ */ jsx(Spinner, { size: "sm", label: null }) : startIcon,
|
|
429
|
+
children,
|
|
430
|
+
!loading && endIcon
|
|
431
|
+
]
|
|
432
|
+
}
|
|
433
|
+
);
|
|
434
|
+
});
|
|
435
|
+
var SQUARE_BY_SIZE = {
|
|
436
|
+
sm: "w-(--ml-control-h-sm) px-0",
|
|
437
|
+
md: "w-(--ml-control-h-md) px-0",
|
|
438
|
+
lg: "w-(--ml-control-h-lg) px-0"
|
|
439
|
+
};
|
|
440
|
+
var IconButton = forwardRef(function IconButton2({ icon, size = "md", className, ...rest }, ref) {
|
|
441
|
+
return /* @__PURE__ */ jsx(Button, { ref, size, className: cn(SQUARE_BY_SIZE[size], className), ...rest, children: icon });
|
|
442
|
+
});
|
|
443
|
+
function ButtonGroup({ className, children, ...rest }) {
|
|
444
|
+
return /* @__PURE__ */ jsx(
|
|
445
|
+
"div",
|
|
446
|
+
{
|
|
447
|
+
role: "group",
|
|
448
|
+
className: cn(
|
|
449
|
+
"inline-flex items-stretch",
|
|
450
|
+
"[&>*]:rounded-none [&>*:first-child]:rounded-l-md [&>*:last-child]:rounded-r-md",
|
|
451
|
+
"[&>*:not(:first-child)]:-ml-px",
|
|
452
|
+
className
|
|
453
|
+
),
|
|
454
|
+
...rest,
|
|
455
|
+
children
|
|
456
|
+
}
|
|
457
|
+
);
|
|
458
|
+
}
|
|
459
|
+
function Skeleton({ variant = "rect", className, ...rest }) {
|
|
460
|
+
return /* @__PURE__ */ jsx(
|
|
461
|
+
"div",
|
|
462
|
+
{
|
|
463
|
+
"aria-hidden": true,
|
|
464
|
+
className: cn(
|
|
465
|
+
"animate-pulse bg-surface-sunken motion-reduce:animate-none",
|
|
466
|
+
variant === "circle" ? "rounded-full" : "rounded-md",
|
|
467
|
+
variant === "text" && "h-[1em] w-full",
|
|
468
|
+
className
|
|
469
|
+
),
|
|
470
|
+
...rest
|
|
471
|
+
}
|
|
472
|
+
);
|
|
473
|
+
}
|
|
474
|
+
var alert = defineVariants({
|
|
475
|
+
base: "rounded-md border px-4 py-3",
|
|
476
|
+
variants: {
|
|
477
|
+
intent: {
|
|
478
|
+
info: "border-info-subtle bg-info-subtle text-info-subtle-fg",
|
|
479
|
+
success: "border-success-subtle bg-success-subtle text-success-subtle-fg",
|
|
480
|
+
warning: "border-warning-subtle bg-warning-subtle text-warning-subtle-fg",
|
|
481
|
+
danger: "border-danger-subtle bg-danger-subtle text-danger-subtle-fg"
|
|
482
|
+
}
|
|
483
|
+
},
|
|
484
|
+
defaultVariants: { intent: "info" }
|
|
485
|
+
});
|
|
486
|
+
function Alert({ intent = "info", title, icon, actions, className, children, ...rest }) {
|
|
487
|
+
const assertive = intent === "danger" || intent === "warning";
|
|
488
|
+
return /* @__PURE__ */ jsx("div", { role: assertive ? "alert" : "status", className: alert({ intent, className }), ...rest, children: /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
|
|
489
|
+
icon && /* @__PURE__ */ jsx("span", { className: "mt-0.5 shrink-0", children: icon }),
|
|
490
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1 text-sm", children: [
|
|
491
|
+
title !== void 0 && /* @__PURE__ */ jsx("p", { className: "m-0 font-semibold", children: title }),
|
|
492
|
+
children !== void 0 && /* @__PURE__ */ jsx("div", { className: title !== void 0 ? "mt-1" : "", children })
|
|
493
|
+
] }),
|
|
494
|
+
actions && /* @__PURE__ */ jsx("div", { className: "flex shrink-0 items-center gap-2", children: actions })
|
|
495
|
+
] }) });
|
|
496
|
+
}
|
|
497
|
+
function Progress({ value, max = 100, size = "md", className, ...rest }) {
|
|
498
|
+
const indeterminate = value === void 0;
|
|
499
|
+
const fraction = indeterminate ? 0 : Math.min(Math.max(value / max, 0), 1);
|
|
500
|
+
return /* @__PURE__ */ jsx(
|
|
501
|
+
"div",
|
|
502
|
+
{
|
|
503
|
+
role: "progressbar",
|
|
504
|
+
"aria-valuemin": 0,
|
|
505
|
+
"aria-valuemax": max,
|
|
506
|
+
"aria-valuenow": indeterminate ? void 0 : Math.round(fraction * max),
|
|
507
|
+
className: cn(
|
|
508
|
+
"w-full overflow-hidden rounded-pill bg-surface-sunken",
|
|
509
|
+
size === "sm" ? "h-1.5" : "h-2.5",
|
|
510
|
+
className
|
|
511
|
+
),
|
|
512
|
+
...rest,
|
|
513
|
+
children: /* @__PURE__ */ jsx(
|
|
514
|
+
"div",
|
|
515
|
+
{
|
|
516
|
+
className: cn(
|
|
517
|
+
"h-full rounded-pill bg-primary transition-[width] duration-(--ml-duration-normal)",
|
|
518
|
+
indeterminate && "w-1/3 animate-pulse motion-reduce:animate-none"
|
|
519
|
+
),
|
|
520
|
+
style: indeterminate ? void 0 : { width: `${String(fraction * 100)}%` }
|
|
521
|
+
}
|
|
522
|
+
)
|
|
523
|
+
}
|
|
524
|
+
);
|
|
525
|
+
}
|
|
526
|
+
var statusBadge = defineVariants({
|
|
527
|
+
base: "inline-flex items-center gap-1.5 whitespace-nowrap rounded-pill border px-2.5 py-0.5 text-xs font-semibold",
|
|
528
|
+
variants: {
|
|
529
|
+
intent: {
|
|
530
|
+
neutral: "border-line bg-surface-sunken text-fg-muted",
|
|
531
|
+
primary: "border-primary-subtle bg-primary-subtle text-primary-subtle-fg",
|
|
532
|
+
success: "border-success-subtle bg-success-subtle text-success-subtle-fg",
|
|
533
|
+
warning: "border-warning-subtle bg-warning-subtle text-warning-subtle-fg",
|
|
534
|
+
danger: "border-danger-subtle bg-danger-subtle text-danger-subtle-fg",
|
|
535
|
+
info: "border-info-subtle bg-info-subtle text-info-subtle-fg"
|
|
536
|
+
}
|
|
537
|
+
},
|
|
538
|
+
defaultVariants: { intent: "neutral" }
|
|
539
|
+
});
|
|
540
|
+
function StatusIndicator({
|
|
541
|
+
intent = "neutral",
|
|
542
|
+
withDot = true,
|
|
543
|
+
className,
|
|
544
|
+
children,
|
|
545
|
+
...rest
|
|
546
|
+
}) {
|
|
547
|
+
return /* @__PURE__ */ jsxs("span", { className: statusBadge({ intent, className }), ...rest, children: [
|
|
548
|
+
withDot && /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "size-1.5 rounded-full bg-current" }),
|
|
549
|
+
children
|
|
550
|
+
] });
|
|
551
|
+
}
|
|
552
|
+
function EmptyState({ title, description, icon, actions, className, ...rest }) {
|
|
553
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col items-center gap-3 px-6 py-12 text-center", className), ...rest, children: [
|
|
554
|
+
icon && /* @__PURE__ */ jsx("div", { className: "text-fg-subtle [&_svg]:size-10", children: icon }),
|
|
555
|
+
/* @__PURE__ */ jsx("p", { className: "m-0 text-base font-semibold text-fg", children: title }),
|
|
556
|
+
description !== void 0 && /* @__PURE__ */ jsx("p", { className: "m-0 max-w-md text-sm text-fg-muted", children: description }),
|
|
557
|
+
actions && /* @__PURE__ */ jsx("div", { className: "mt-2 flex items-center gap-2", children: actions })
|
|
558
|
+
] });
|
|
559
|
+
}
|
|
560
|
+
function ErrorState(props) {
|
|
561
|
+
return /* @__PURE__ */ jsx(EmptyState, { role: "alert", ...props });
|
|
562
|
+
}
|
|
563
|
+
function SuccessState(props) {
|
|
564
|
+
return /* @__PURE__ */ jsx(EmptyState, { role: "status", ...props });
|
|
565
|
+
}
|
|
566
|
+
function LoadingOverlay({ visible, label = "Loading", className, ...rest }) {
|
|
567
|
+
if (!visible) return null;
|
|
568
|
+
return /* @__PURE__ */ jsxs(
|
|
569
|
+
"div",
|
|
570
|
+
{
|
|
571
|
+
role: "status",
|
|
572
|
+
"aria-live": "polite",
|
|
573
|
+
className: cn(
|
|
574
|
+
"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2",
|
|
575
|
+
"bg-surface/70 backdrop-blur-[1px]",
|
|
576
|
+
className
|
|
577
|
+
),
|
|
578
|
+
...rest,
|
|
579
|
+
children: [
|
|
580
|
+
/* @__PURE__ */ jsx(Spinner, { size: "lg", label: null }),
|
|
581
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm font-medium text-fg-muted", children: label })
|
|
582
|
+
]
|
|
583
|
+
}
|
|
584
|
+
);
|
|
585
|
+
}
|
|
586
|
+
var Dialog = DialogPrimitive.Root;
|
|
587
|
+
var DialogTrigger = DialogPrimitive.Trigger;
|
|
588
|
+
var DialogPortal = DialogPrimitive.Portal;
|
|
589
|
+
var DialogClose = DialogPrimitive.Close;
|
|
590
|
+
var DialogOverlay = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
591
|
+
DialogPrimitive.Overlay,
|
|
592
|
+
{
|
|
593
|
+
ref,
|
|
594
|
+
className: cn(
|
|
595
|
+
"fixed inset-0 z-(--ml-z-modal) bg-overlay backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
596
|
+
className
|
|
597
|
+
),
|
|
598
|
+
...props
|
|
599
|
+
}
|
|
600
|
+
));
|
|
601
|
+
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
602
|
+
var DialogContent = forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(DialogPortal, { children: [
|
|
603
|
+
/* @__PURE__ */ jsx(DialogOverlay, {}),
|
|
604
|
+
/* @__PURE__ */ jsxs(
|
|
605
|
+
DialogPrimitive.Content,
|
|
606
|
+
{
|
|
607
|
+
ref,
|
|
608
|
+
className: cn(
|
|
609
|
+
"fixed left-[50%] top-[50%] z-(--ml-z-modal) grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-line bg-surface p-6 shadow-modal duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-xl",
|
|
610
|
+
className
|
|
611
|
+
),
|
|
612
|
+
...props,
|
|
613
|
+
children: [
|
|
614
|
+
children,
|
|
615
|
+
/* @__PURE__ */ jsxs(DialogPrimitive.Close, { className: "absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus-ring disabled:pointer-events-none data-[state=open]:bg-surface-sunken data-[state=open]:text-fg-muted", children: [
|
|
616
|
+
/* @__PURE__ */ jsxs(
|
|
617
|
+
"svg",
|
|
618
|
+
{
|
|
619
|
+
width: "16",
|
|
620
|
+
height: "16",
|
|
621
|
+
viewBox: "0 0 24 24",
|
|
622
|
+
fill: "none",
|
|
623
|
+
stroke: "currentColor",
|
|
624
|
+
strokeWidth: "2",
|
|
625
|
+
strokeLinecap: "round",
|
|
626
|
+
strokeLinejoin: "round",
|
|
627
|
+
className: "h-4 w-4",
|
|
628
|
+
children: [
|
|
629
|
+
/* @__PURE__ */ jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
630
|
+
/* @__PURE__ */ jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
631
|
+
]
|
|
632
|
+
}
|
|
633
|
+
),
|
|
634
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
|
|
635
|
+
] })
|
|
636
|
+
]
|
|
637
|
+
}
|
|
638
|
+
)
|
|
639
|
+
] }));
|
|
640
|
+
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
641
|
+
var DialogHeader = ({
|
|
642
|
+
className,
|
|
643
|
+
...props
|
|
644
|
+
}) => /* @__PURE__ */ jsx(
|
|
645
|
+
"div",
|
|
646
|
+
{
|
|
647
|
+
className: cn("flex flex-col space-y-1.5 text-center sm:text-left", className),
|
|
648
|
+
...props
|
|
649
|
+
}
|
|
650
|
+
);
|
|
651
|
+
DialogHeader.displayName = "DialogHeader";
|
|
652
|
+
var DialogFooter = ({
|
|
653
|
+
className,
|
|
654
|
+
...props
|
|
655
|
+
}) => /* @__PURE__ */ jsx(
|
|
656
|
+
"div",
|
|
657
|
+
{
|
|
658
|
+
className: cn(
|
|
659
|
+
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
|
660
|
+
className
|
|
661
|
+
),
|
|
662
|
+
...props
|
|
663
|
+
}
|
|
664
|
+
);
|
|
665
|
+
DialogFooter.displayName = "DialogFooter";
|
|
666
|
+
var DialogTitle = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
667
|
+
DialogPrimitive.Title,
|
|
668
|
+
{
|
|
669
|
+
ref,
|
|
670
|
+
className: cn("text-lg font-semibold leading-none tracking-tight text-fg-strong", className),
|
|
671
|
+
...props
|
|
672
|
+
}
|
|
673
|
+
));
|
|
674
|
+
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
675
|
+
var DialogDescription = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
676
|
+
DialogPrimitive.Description,
|
|
677
|
+
{
|
|
678
|
+
ref,
|
|
679
|
+
className: cn("text-sm text-fg-muted", className),
|
|
680
|
+
...props
|
|
681
|
+
}
|
|
682
|
+
));
|
|
683
|
+
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
684
|
+
var Drawer = DialogPrimitive.Root;
|
|
685
|
+
var DrawerTrigger = DialogPrimitive.Trigger;
|
|
686
|
+
var DrawerPortal = DialogPrimitive.Portal;
|
|
687
|
+
var DrawerClose = DialogPrimitive.Close;
|
|
688
|
+
var DrawerOverlay = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
689
|
+
DialogPrimitive.Overlay,
|
|
690
|
+
{
|
|
691
|
+
ref,
|
|
692
|
+
className: cn(
|
|
693
|
+
"fixed inset-0 z-(--ml-z-drawer) bg-overlay backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
694
|
+
className
|
|
695
|
+
),
|
|
696
|
+
...props
|
|
697
|
+
}
|
|
698
|
+
));
|
|
699
|
+
DrawerOverlay.displayName = "DrawerOverlay";
|
|
700
|
+
var drawerContent = defineVariants({
|
|
701
|
+
base: "fixed z-(--ml-z-drawer) flex flex-col gap-4 overflow-y-auto bg-surface p-6 shadow-modal transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-200 data-[state=open]:duration-300",
|
|
702
|
+
variants: {
|
|
703
|
+
side: {
|
|
704
|
+
left: "inset-y-0 left-0 h-full w-3/4 max-w-sm border-r border-line data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left",
|
|
705
|
+
right: "inset-y-0 right-0 h-full w-3/4 max-w-sm border-l border-line data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right",
|
|
706
|
+
top: "inset-x-0 top-0 border-b border-line data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
|
|
707
|
+
bottom: "inset-x-0 bottom-0 border-t border-line data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom"
|
|
708
|
+
}
|
|
709
|
+
},
|
|
710
|
+
defaultVariants: { side: "left" }
|
|
711
|
+
});
|
|
712
|
+
var DrawerContent = forwardRef(({ className, children, side, hideCloseButton = false, ...props }, ref) => /* @__PURE__ */ jsxs(DrawerPortal, { children: [
|
|
713
|
+
/* @__PURE__ */ jsx(DrawerOverlay, {}),
|
|
714
|
+
/* @__PURE__ */ jsxs(
|
|
715
|
+
DialogPrimitive.Content,
|
|
716
|
+
{
|
|
717
|
+
ref,
|
|
718
|
+
className: drawerContent({ side, className }),
|
|
719
|
+
...props,
|
|
720
|
+
children: [
|
|
721
|
+
children,
|
|
722
|
+
!hideCloseButton && /* @__PURE__ */ jsxs(DialogPrimitive.Close, { className: "absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus-ring disabled:pointer-events-none", children: [
|
|
723
|
+
/* @__PURE__ */ jsxs(
|
|
724
|
+
"svg",
|
|
725
|
+
{
|
|
726
|
+
width: "16",
|
|
727
|
+
height: "16",
|
|
728
|
+
viewBox: "0 0 24 24",
|
|
729
|
+
fill: "none",
|
|
730
|
+
stroke: "currentColor",
|
|
731
|
+
strokeWidth: "2",
|
|
732
|
+
strokeLinecap: "round",
|
|
733
|
+
strokeLinejoin: "round",
|
|
734
|
+
className: "h-4 w-4",
|
|
735
|
+
children: [
|
|
736
|
+
/* @__PURE__ */ jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
737
|
+
/* @__PURE__ */ jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
738
|
+
]
|
|
739
|
+
}
|
|
740
|
+
),
|
|
741
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
|
|
742
|
+
] })
|
|
743
|
+
]
|
|
744
|
+
}
|
|
745
|
+
)
|
|
746
|
+
] }));
|
|
747
|
+
DrawerContent.displayName = "DrawerContent";
|
|
748
|
+
var DrawerHeader = ({
|
|
749
|
+
className,
|
|
750
|
+
...props
|
|
751
|
+
}) => /* @__PURE__ */ jsx("div", { className: cn("flex flex-col space-y-1.5", className), ...props });
|
|
752
|
+
DrawerHeader.displayName = "DrawerHeader";
|
|
753
|
+
var DrawerFooter = ({
|
|
754
|
+
className,
|
|
755
|
+
...props
|
|
756
|
+
}) => /* @__PURE__ */ jsx("div", { className: cn("mt-auto flex flex-col gap-2", className), ...props });
|
|
757
|
+
DrawerFooter.displayName = "DrawerFooter";
|
|
758
|
+
var DrawerTitle = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
759
|
+
DialogPrimitive.Title,
|
|
760
|
+
{
|
|
761
|
+
ref,
|
|
762
|
+
className: cn("text-lg font-semibold leading-none tracking-tight text-fg", className),
|
|
763
|
+
...props
|
|
764
|
+
}
|
|
765
|
+
));
|
|
766
|
+
DrawerTitle.displayName = "DrawerTitle";
|
|
767
|
+
var DrawerDescription = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
768
|
+
DialogPrimitive.Description,
|
|
769
|
+
{
|
|
770
|
+
ref,
|
|
771
|
+
className: cn("text-sm text-fg-muted", className),
|
|
772
|
+
...props
|
|
773
|
+
}
|
|
774
|
+
));
|
|
775
|
+
DrawerDescription.displayName = "DrawerDescription";
|
|
776
|
+
var AlertDialog = AlertDialogPrimitive.Root;
|
|
777
|
+
var AlertDialogTrigger = AlertDialogPrimitive.Trigger;
|
|
778
|
+
var AlertDialogPortal = AlertDialogPrimitive.Portal;
|
|
779
|
+
var AlertDialogOverlay = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
780
|
+
AlertDialogPrimitive.Overlay,
|
|
781
|
+
{
|
|
782
|
+
ref,
|
|
783
|
+
className: cn(
|
|
784
|
+
"fixed inset-0 z-(--ml-z-modal) bg-overlay backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
785
|
+
className
|
|
786
|
+
),
|
|
787
|
+
...props
|
|
788
|
+
}
|
|
789
|
+
));
|
|
790
|
+
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;
|
|
791
|
+
var AlertDialogContent = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxs(AlertDialogPortal, { children: [
|
|
792
|
+
/* @__PURE__ */ jsx(AlertDialogOverlay, {}),
|
|
793
|
+
/* @__PURE__ */ jsx(
|
|
794
|
+
AlertDialogPrimitive.Content,
|
|
795
|
+
{
|
|
796
|
+
ref,
|
|
797
|
+
className: cn(
|
|
798
|
+
"fixed left-[50%] top-[50%] z-(--ml-z-modal) grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-line bg-surface p-6 shadow-modal duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-xl",
|
|
799
|
+
className
|
|
800
|
+
),
|
|
801
|
+
...props
|
|
802
|
+
}
|
|
803
|
+
)
|
|
804
|
+
] }));
|
|
805
|
+
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;
|
|
806
|
+
var AlertDialogHeader = ({
|
|
807
|
+
className,
|
|
808
|
+
...props
|
|
809
|
+
}) => /* @__PURE__ */ jsx(
|
|
810
|
+
"div",
|
|
811
|
+
{
|
|
812
|
+
className: cn("flex flex-col space-y-2 text-center sm:text-left", className),
|
|
813
|
+
...props
|
|
814
|
+
}
|
|
815
|
+
);
|
|
816
|
+
AlertDialogHeader.displayName = "AlertDialogHeader";
|
|
817
|
+
var AlertDialogFooter = ({
|
|
818
|
+
className,
|
|
819
|
+
...props
|
|
820
|
+
}) => /* @__PURE__ */ jsx(
|
|
821
|
+
"div",
|
|
822
|
+
{
|
|
823
|
+
className: cn(
|
|
824
|
+
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
|
825
|
+
className
|
|
826
|
+
),
|
|
827
|
+
...props
|
|
828
|
+
}
|
|
829
|
+
);
|
|
830
|
+
AlertDialogFooter.displayName = "AlertDialogFooter";
|
|
831
|
+
var AlertDialogTitle = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
832
|
+
AlertDialogPrimitive.Title,
|
|
833
|
+
{
|
|
834
|
+
ref,
|
|
835
|
+
className: cn("text-lg font-semibold text-fg-strong", className),
|
|
836
|
+
...props
|
|
837
|
+
}
|
|
838
|
+
));
|
|
839
|
+
AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;
|
|
840
|
+
var AlertDialogDescription = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
841
|
+
AlertDialogPrimitive.Description,
|
|
842
|
+
{
|
|
843
|
+
ref,
|
|
844
|
+
className: cn("text-sm text-fg-muted", className),
|
|
845
|
+
...props
|
|
846
|
+
}
|
|
847
|
+
));
|
|
848
|
+
AlertDialogDescription.displayName = AlertDialogPrimitive.Description.displayName;
|
|
849
|
+
var AlertDialogAction = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(AlertDialogPrimitive.Action, { ref, className, ...props }));
|
|
850
|
+
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;
|
|
851
|
+
var AlertDialogCancel = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(AlertDialogPrimitive.Cancel, { ref, className, ...props }));
|
|
852
|
+
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;
|
|
853
|
+
var Popover = PopoverPrimitive.Root;
|
|
854
|
+
var PopoverTrigger = PopoverPrimitive.Trigger;
|
|
855
|
+
var PopoverAnchor = PopoverPrimitive.Anchor;
|
|
856
|
+
var PopoverContent = forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx(
|
|
857
|
+
PopoverPrimitive.Content,
|
|
858
|
+
{
|
|
859
|
+
ref,
|
|
860
|
+
align,
|
|
861
|
+
sideOffset,
|
|
862
|
+
className: cn(
|
|
863
|
+
"z-(--ml-z-popover) w-72 rounded-md border border-line bg-surface p-4 text-fg shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
864
|
+
className
|
|
865
|
+
),
|
|
866
|
+
...props
|
|
867
|
+
}
|
|
868
|
+
) }));
|
|
869
|
+
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
|
870
|
+
var TooltipProvider = TooltipPrimitive.Provider;
|
|
871
|
+
var Tooltip = TooltipPrimitive.Root;
|
|
872
|
+
var TooltipTrigger = TooltipPrimitive.Trigger;
|
|
873
|
+
var TooltipContent = forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(TooltipPrimitive.Portal, { children: /* @__PURE__ */ jsx(
|
|
874
|
+
TooltipPrimitive.Content,
|
|
875
|
+
{
|
|
876
|
+
ref,
|
|
877
|
+
sideOffset,
|
|
878
|
+
className: cn(
|
|
879
|
+
"z-(--ml-z-tooltip) overflow-hidden rounded-md bg-fg px-3 py-1.5 text-xs text-fg-inverted shadow-sm animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
880
|
+
className
|
|
881
|
+
),
|
|
882
|
+
...props
|
|
883
|
+
}
|
|
884
|
+
) }));
|
|
885
|
+
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
|
|
886
|
+
var ToastProvider = ToastPrimitives.Provider;
|
|
887
|
+
var ToastViewport = React5.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
888
|
+
ToastPrimitives.Viewport,
|
|
889
|
+
{
|
|
890
|
+
ref,
|
|
891
|
+
className: cn(
|
|
892
|
+
"fixed top-0 z-(--ml-z-toast) flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",
|
|
893
|
+
className
|
|
894
|
+
),
|
|
895
|
+
...props
|
|
896
|
+
}
|
|
897
|
+
));
|
|
898
|
+
ToastViewport.displayName = ToastPrimitives.Viewport.displayName;
|
|
899
|
+
var Toast = React5.forwardRef(({ className, variant = "default", ...props }, ref) => {
|
|
900
|
+
return /* @__PURE__ */ jsx(
|
|
901
|
+
ToastPrimitives.Root,
|
|
902
|
+
{
|
|
903
|
+
ref,
|
|
904
|
+
className: cn(
|
|
905
|
+
"group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",
|
|
906
|
+
{
|
|
907
|
+
"border-line bg-surface text-fg": variant === "default",
|
|
908
|
+
"border-success-subtle bg-success-subtle text-success-subtle-fg": variant === "success",
|
|
909
|
+
"border-danger-subtle bg-danger-subtle text-danger-subtle-fg": variant === "danger",
|
|
910
|
+
"border-warning-subtle bg-warning-subtle text-warning-subtle-fg": variant === "warning"
|
|
911
|
+
},
|
|
912
|
+
className
|
|
913
|
+
),
|
|
914
|
+
...props
|
|
915
|
+
}
|
|
916
|
+
);
|
|
917
|
+
});
|
|
918
|
+
Toast.displayName = ToastPrimitives.Root.displayName;
|
|
919
|
+
var ToastAction = React5.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
920
|
+
ToastPrimitives.Action,
|
|
921
|
+
{
|
|
922
|
+
ref,
|
|
923
|
+
className: cn(
|
|
924
|
+
"inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-surface-sunken focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.border-danger-subtle]:border-danger/30 group-[.border-danger-subtle]:hover:border-danger/30 group-[.border-danger-subtle]:hover:bg-danger group-[.border-danger-subtle]:hover:text-danger-fg group-[.border-danger-subtle]:focus:ring-danger",
|
|
925
|
+
className
|
|
926
|
+
),
|
|
927
|
+
...props
|
|
928
|
+
}
|
|
929
|
+
));
|
|
930
|
+
ToastAction.displayName = ToastPrimitives.Action.displayName;
|
|
931
|
+
var ToastClose = React5.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
932
|
+
ToastPrimitives.Close,
|
|
933
|
+
{
|
|
934
|
+
ref,
|
|
935
|
+
className: cn(
|
|
936
|
+
"absolute right-2 top-2 rounded-md p-1 text-fg/50 opacity-0 transition-opacity hover:text-fg focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.border-danger-subtle]:text-danger-subtle-fg group-[.border-danger-subtle]:hover:text-danger-subtle-fg",
|
|
937
|
+
className
|
|
938
|
+
),
|
|
939
|
+
"toast-close": "",
|
|
940
|
+
...props,
|
|
941
|
+
children: /* @__PURE__ */ jsxs(
|
|
942
|
+
"svg",
|
|
943
|
+
{
|
|
944
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
945
|
+
width: "24",
|
|
946
|
+
height: "24",
|
|
947
|
+
viewBox: "0 0 24 24",
|
|
948
|
+
fill: "none",
|
|
949
|
+
stroke: "currentColor",
|
|
950
|
+
strokeWidth: "2",
|
|
951
|
+
strokeLinecap: "round",
|
|
952
|
+
strokeLinejoin: "round",
|
|
953
|
+
className: "h-4 w-4",
|
|
954
|
+
children: [
|
|
955
|
+
/* @__PURE__ */ jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
956
|
+
/* @__PURE__ */ jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
957
|
+
]
|
|
958
|
+
}
|
|
959
|
+
)
|
|
960
|
+
}
|
|
961
|
+
));
|
|
962
|
+
ToastClose.displayName = ToastPrimitives.Close.displayName;
|
|
963
|
+
var ToastTitle = React5.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
964
|
+
ToastPrimitives.Title,
|
|
965
|
+
{
|
|
966
|
+
ref,
|
|
967
|
+
className: cn("text-sm font-semibold", className),
|
|
968
|
+
...props
|
|
969
|
+
}
|
|
970
|
+
));
|
|
971
|
+
ToastTitle.displayName = ToastPrimitives.Title.displayName;
|
|
972
|
+
var ToastDescription = React5.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
973
|
+
ToastPrimitives.Description,
|
|
974
|
+
{
|
|
975
|
+
ref,
|
|
976
|
+
className: cn("text-sm opacity-90", className),
|
|
977
|
+
...props
|
|
978
|
+
}
|
|
979
|
+
));
|
|
980
|
+
ToastDescription.displayName = ToastPrimitives.Description.displayName;
|
|
981
|
+
var FieldContext = createContext(null);
|
|
982
|
+
var FieldProvider = FieldContext.Provider;
|
|
983
|
+
function useFieldContext() {
|
|
984
|
+
return useContext(FieldContext);
|
|
985
|
+
}
|
|
986
|
+
function useFieldInputProps(own) {
|
|
987
|
+
const field = useFieldContext();
|
|
988
|
+
const describedBy = own["aria-describedby"] ?? ([field?.errorId, field?.descriptionId].filter(Boolean).join(" ") || void 0);
|
|
989
|
+
const invalid = own["aria-invalid"] ?? (field?.invalid ? true : void 0);
|
|
990
|
+
return {
|
|
991
|
+
id: own.id ?? field?.inputId,
|
|
992
|
+
"aria-describedby": describedBy,
|
|
993
|
+
// Any truthy aria-invalid form (true/"true"/"grammar"/"spelling") marks invalid.
|
|
994
|
+
"aria-invalid": invalid !== void 0 && invalid !== false && invalid !== "false" ? true : void 0,
|
|
995
|
+
disabled: own.disabled ?? (field?.disabled ? true : void 0),
|
|
996
|
+
required: own.required ?? (field?.required ? true : void 0)
|
|
997
|
+
};
|
|
998
|
+
}
|
|
999
|
+
function Field({
|
|
1000
|
+
label,
|
|
1001
|
+
description,
|
|
1002
|
+
error,
|
|
1003
|
+
required = false,
|
|
1004
|
+
disabled = false,
|
|
1005
|
+
className,
|
|
1006
|
+
children,
|
|
1007
|
+
...rest
|
|
1008
|
+
}) {
|
|
1009
|
+
const baseId = useId();
|
|
1010
|
+
const inputId = `${baseId}-input`;
|
|
1011
|
+
const descriptionId = description !== void 0 ? `${baseId}-description` : void 0;
|
|
1012
|
+
const errorId = error !== void 0 && error !== null ? `${baseId}-error` : void 0;
|
|
1013
|
+
const invalid = errorId !== void 0;
|
|
1014
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col gap-1.5", className), ...rest, children: [
|
|
1015
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: inputId, required, className: disabled ? "text-fg-disabled" : void 0, children: label }),
|
|
1016
|
+
/* @__PURE__ */ jsx(FieldProvider, { value: { inputId, descriptionId, errorId, invalid, required, disabled }, children }),
|
|
1017
|
+
invalid ? /* @__PURE__ */ jsx("p", { id: errorId, role: "alert", className: "m-0 text-sm text-danger-subtle-fg", children: error }) : description !== void 0 && /* @__PURE__ */ jsx("p", { id: descriptionId, className: "m-0 text-sm text-fg-subtle", children: description })
|
|
1018
|
+
] });
|
|
1019
|
+
}
|
|
1020
|
+
var inputClassName = (invalid, className) => cn(
|
|
1021
|
+
"focus-ring h-(--ml-control-h-md) w-full rounded-md border bg-surface px-(--ml-control-px) text-sm text-fg",
|
|
1022
|
+
"placeholder:text-fg-subtle",
|
|
1023
|
+
"disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:text-fg-disabled",
|
|
1024
|
+
invalid ? "border-danger" : "border-line-strong",
|
|
1025
|
+
className
|
|
1026
|
+
);
|
|
1027
|
+
var TextInput = forwardRef(function TextInput2({ startAdornment, endAdornment, className, ...rest }, ref) {
|
|
1028
|
+
const field = useFieldInputProps(rest);
|
|
1029
|
+
const invalid = field["aria-invalid"] === true;
|
|
1030
|
+
if (startAdornment === void 0 && endAdornment === void 0) {
|
|
1031
|
+
return /* @__PURE__ */ jsx("input", { ref, type: "text", ...rest, ...field, className: inputClassName(invalid, className) });
|
|
1032
|
+
}
|
|
1033
|
+
return /* @__PURE__ */ jsxs("div", { className: "relative flex items-center", children: [
|
|
1034
|
+
startAdornment !== void 0 && /* @__PURE__ */ jsx("span", { className: "pointer-events-none absolute left-3 text-fg-subtle [&_svg]:size-(--size-icon-sm)", children: startAdornment }),
|
|
1035
|
+
/* @__PURE__ */ jsx(
|
|
1036
|
+
"input",
|
|
1037
|
+
{
|
|
1038
|
+
ref,
|
|
1039
|
+
type: "text",
|
|
1040
|
+
...rest,
|
|
1041
|
+
...field,
|
|
1042
|
+
className: cn(
|
|
1043
|
+
inputClassName(invalid, className),
|
|
1044
|
+
startAdornment !== void 0 && "pl-9",
|
|
1045
|
+
endAdornment !== void 0 && "pr-9"
|
|
1046
|
+
)
|
|
1047
|
+
}
|
|
1048
|
+
),
|
|
1049
|
+
endAdornment !== void 0 && /* @__PURE__ */ jsx("span", { className: "absolute right-3 text-fg-subtle [&_svg]:size-(--size-icon-sm)", children: endAdornment })
|
|
1050
|
+
] });
|
|
1051
|
+
});
|
|
1052
|
+
var PasswordInput = forwardRef(function PasswordInput2(props, ref) {
|
|
1053
|
+
const [visible, setVisible] = useState(false);
|
|
1054
|
+
return /* @__PURE__ */ jsx(
|
|
1055
|
+
TextInput,
|
|
1056
|
+
{
|
|
1057
|
+
ref,
|
|
1058
|
+
...props,
|
|
1059
|
+
type: visible ? "text" : "password",
|
|
1060
|
+
endAdornment: /* @__PURE__ */ jsx(
|
|
1061
|
+
"button",
|
|
1062
|
+
{
|
|
1063
|
+
type: "button",
|
|
1064
|
+
"aria-label": visible ? "Hide password" : "Show password",
|
|
1065
|
+
"aria-pressed": visible,
|
|
1066
|
+
onClick: () => {
|
|
1067
|
+
setVisible((v) => !v);
|
|
1068
|
+
},
|
|
1069
|
+
className: "focus-ring pointer-events-auto -m-1 rounded-xs p-1 text-fg-subtle hover:text-fg",
|
|
1070
|
+
children: /* @__PURE__ */ jsx(EyeIcon, { crossed: visible })
|
|
1071
|
+
}
|
|
1072
|
+
)
|
|
1073
|
+
}
|
|
1074
|
+
);
|
|
1075
|
+
});
|
|
1076
|
+
function EyeIcon({ crossed }) {
|
|
1077
|
+
return /* @__PURE__ */ jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: [
|
|
1078
|
+
/* @__PURE__ */ jsx("path", { d: "M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7Z" }),
|
|
1079
|
+
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "3" }),
|
|
1080
|
+
crossed && /* @__PURE__ */ jsx("line", { x1: "3", y1: "21", x2: "21", y2: "3" })
|
|
1081
|
+
] });
|
|
1082
|
+
}
|
|
1083
|
+
var SearchInput = forwardRef(function SearchInput2(props, ref) {
|
|
1084
|
+
return /* @__PURE__ */ jsx(TextInput, { ref, ...props, type: "search", startAdornment: /* @__PURE__ */ jsx(SearchIcon, {}) });
|
|
1085
|
+
});
|
|
1086
|
+
function SearchIcon() {
|
|
1087
|
+
return /* @__PURE__ */ jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: [
|
|
1088
|
+
/* @__PURE__ */ jsx("circle", { cx: "11", cy: "11", r: "8" }),
|
|
1089
|
+
/* @__PURE__ */ jsx("line", { x1: "21", y1: "21", x2: "16.65", y2: "16.65" })
|
|
1090
|
+
] });
|
|
1091
|
+
}
|
|
1092
|
+
var Textarea = forwardRef(function Textarea2({ className, rows = 3, ...rest }, ref) {
|
|
1093
|
+
const field = useFieldInputProps(rest);
|
|
1094
|
+
const invalid = field["aria-invalid"] === true;
|
|
1095
|
+
return /* @__PURE__ */ jsx(
|
|
1096
|
+
"textarea",
|
|
1097
|
+
{
|
|
1098
|
+
ref,
|
|
1099
|
+
rows,
|
|
1100
|
+
...rest,
|
|
1101
|
+
...field,
|
|
1102
|
+
className: cn(
|
|
1103
|
+
"focus-ring w-full resize-y rounded-md border bg-surface px-(--ml-control-px) py-2 text-sm text-fg",
|
|
1104
|
+
"placeholder:text-fg-subtle",
|
|
1105
|
+
"disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:text-fg-disabled",
|
|
1106
|
+
invalid ? "border-danger" : "border-line-strong",
|
|
1107
|
+
className
|
|
1108
|
+
)
|
|
1109
|
+
}
|
|
1110
|
+
);
|
|
1111
|
+
});
|
|
1112
|
+
var Checkbox = forwardRef(function Checkbox2({ label, description, className, disabled, ...rest }, ref) {
|
|
1113
|
+
const box = /* @__PURE__ */ jsx(
|
|
1114
|
+
"input",
|
|
1115
|
+
{
|
|
1116
|
+
ref,
|
|
1117
|
+
type: "checkbox",
|
|
1118
|
+
disabled,
|
|
1119
|
+
className: cn(
|
|
1120
|
+
"focus-ring size-4 shrink-0 cursor-pointer rounded-xs border-line-strong accent-(--ml-primary)",
|
|
1121
|
+
"disabled:cursor-not-allowed",
|
|
1122
|
+
label === void 0 && className
|
|
1123
|
+
),
|
|
1124
|
+
...rest
|
|
1125
|
+
}
|
|
1126
|
+
);
|
|
1127
|
+
if (label === void 0) return box;
|
|
1128
|
+
return /* @__PURE__ */ jsxs(
|
|
1129
|
+
"label",
|
|
1130
|
+
{
|
|
1131
|
+
className: cn(
|
|
1132
|
+
"flex cursor-pointer items-start gap-2.5",
|
|
1133
|
+
disabled && "cursor-not-allowed opacity-60",
|
|
1134
|
+
className
|
|
1135
|
+
),
|
|
1136
|
+
children: [
|
|
1137
|
+
/* @__PURE__ */ jsx("span", { className: "flex h-5 items-center", children: box }),
|
|
1138
|
+
/* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-col gap-0.5", children: [
|
|
1139
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm font-medium text-fg", children: label }),
|
|
1140
|
+
description !== void 0 && /* @__PURE__ */ jsx("span", { className: "text-sm text-fg-muted", children: description })
|
|
1141
|
+
] })
|
|
1142
|
+
]
|
|
1143
|
+
}
|
|
1144
|
+
);
|
|
1145
|
+
});
|
|
1146
|
+
var CodeInput = React5.forwardRef(
|
|
1147
|
+
({
|
|
1148
|
+
length = 6,
|
|
1149
|
+
value: valueProp,
|
|
1150
|
+
defaultValue = "",
|
|
1151
|
+
onChange,
|
|
1152
|
+
onComplete,
|
|
1153
|
+
disabled = false,
|
|
1154
|
+
error = false,
|
|
1155
|
+
autoFocus = false,
|
|
1156
|
+
"aria-label": ariaLabel = "Verification code",
|
|
1157
|
+
name,
|
|
1158
|
+
className
|
|
1159
|
+
}, ref) => {
|
|
1160
|
+
const [value, setValue] = useControllableState({
|
|
1161
|
+
value: valueProp,
|
|
1162
|
+
defaultValue,
|
|
1163
|
+
onChange
|
|
1164
|
+
});
|
|
1165
|
+
const inputsRef = React5.useRef([]);
|
|
1166
|
+
const focusCell = (index) => {
|
|
1167
|
+
inputsRef.current[Math.max(0, Math.min(index, length - 1))]?.focus();
|
|
1168
|
+
};
|
|
1169
|
+
const commit = (next) => {
|
|
1170
|
+
const clean = next.replace(/\D/g, "").slice(0, length);
|
|
1171
|
+
setValue(clean);
|
|
1172
|
+
if (clean.length === length) onComplete?.(clean);
|
|
1173
|
+
};
|
|
1174
|
+
const handleChange = (index, raw) => {
|
|
1175
|
+
const digit = raw.replace(/\D/g, "").slice(-1);
|
|
1176
|
+
if (!digit) return;
|
|
1177
|
+
const chars = value.padEnd(index, " ").split("");
|
|
1178
|
+
chars[index] = digit;
|
|
1179
|
+
commit(chars.join("").trimEnd());
|
|
1180
|
+
focusCell(index + 1);
|
|
1181
|
+
};
|
|
1182
|
+
const handleKeyDown = (index, event) => {
|
|
1183
|
+
if (event.key === "Backspace") {
|
|
1184
|
+
event.preventDefault();
|
|
1185
|
+
if (value[index]) {
|
|
1186
|
+
commit(value.slice(0, index) + value.slice(index + 1));
|
|
1187
|
+
} else {
|
|
1188
|
+
commit(value.slice(0, Math.max(0, index - 1)));
|
|
1189
|
+
focusCell(index - 1);
|
|
1190
|
+
}
|
|
1191
|
+
} else if (event.key === "ArrowLeft") {
|
|
1192
|
+
event.preventDefault();
|
|
1193
|
+
focusCell(index - 1);
|
|
1194
|
+
} else if (event.key === "ArrowRight") {
|
|
1195
|
+
event.preventDefault();
|
|
1196
|
+
focusCell(index + 1);
|
|
1197
|
+
}
|
|
1198
|
+
};
|
|
1199
|
+
const handlePaste = (event) => {
|
|
1200
|
+
event.preventDefault();
|
|
1201
|
+
const pasted = event.clipboardData.getData("text");
|
|
1202
|
+
commit(pasted);
|
|
1203
|
+
focusCell(Math.min(pasted.replace(/\D/g, "").length, length - 1));
|
|
1204
|
+
};
|
|
1205
|
+
return /* @__PURE__ */ jsxs(
|
|
1206
|
+
"div",
|
|
1207
|
+
{
|
|
1208
|
+
ref,
|
|
1209
|
+
role: "group",
|
|
1210
|
+
"aria-label": ariaLabel,
|
|
1211
|
+
className: cn("flex items-center justify-center gap-2", className),
|
|
1212
|
+
children: [
|
|
1213
|
+
Array.from({ length }, (_, index) => /* @__PURE__ */ jsx(
|
|
1214
|
+
"input",
|
|
1215
|
+
{
|
|
1216
|
+
ref: (el) => {
|
|
1217
|
+
inputsRef.current[index] = el;
|
|
1218
|
+
},
|
|
1219
|
+
type: "text",
|
|
1220
|
+
inputMode: "numeric",
|
|
1221
|
+
autoComplete: index === 0 ? "one-time-code" : "off",
|
|
1222
|
+
autoFocus: autoFocus && index === 0,
|
|
1223
|
+
"aria-label": `Digit ${String(index + 1)} of ${String(length)}`,
|
|
1224
|
+
"aria-invalid": error || void 0,
|
|
1225
|
+
disabled,
|
|
1226
|
+
maxLength: 1,
|
|
1227
|
+
value: value[index] ?? "",
|
|
1228
|
+
onChange: (e) => {
|
|
1229
|
+
handleChange(index, e.target.value);
|
|
1230
|
+
},
|
|
1231
|
+
onKeyDown: (e) => {
|
|
1232
|
+
handleKeyDown(index, e);
|
|
1233
|
+
},
|
|
1234
|
+
onPaste: handlePaste,
|
|
1235
|
+
className: cn(
|
|
1236
|
+
"h-12 w-10 rounded-md border bg-surface text-center text-lg font-semibold text-fg transition-colors duration-(--ml-duration-fast) focus-ring disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:text-fg-disabled",
|
|
1237
|
+
error ? "border-danger" : "border-line hover:border-line-strong"
|
|
1238
|
+
)
|
|
1239
|
+
},
|
|
1240
|
+
index
|
|
1241
|
+
)),
|
|
1242
|
+
name && /* @__PURE__ */ jsx("input", { type: "hidden", name, value })
|
|
1243
|
+
]
|
|
1244
|
+
}
|
|
1245
|
+
);
|
|
1246
|
+
}
|
|
1247
|
+
);
|
|
1248
|
+
CodeInput.displayName = "CodeInput";
|
|
1249
|
+
var Switch = forwardRef(function Switch2({ label, className, disabled, ...rest }, ref) {
|
|
1250
|
+
const control = /* @__PURE__ */ jsxs("span", { className: "relative inline-flex", children: [
|
|
1251
|
+
/* @__PURE__ */ jsx(
|
|
1252
|
+
"input",
|
|
1253
|
+
{
|
|
1254
|
+
ref,
|
|
1255
|
+
type: "checkbox",
|
|
1256
|
+
role: "switch",
|
|
1257
|
+
disabled,
|
|
1258
|
+
className: "peer absolute inset-0 cursor-pointer opacity-0 disabled:cursor-not-allowed",
|
|
1259
|
+
...rest
|
|
1260
|
+
}
|
|
1261
|
+
),
|
|
1262
|
+
/* @__PURE__ */ jsx(
|
|
1263
|
+
"span",
|
|
1264
|
+
{
|
|
1265
|
+
"aria-hidden": true,
|
|
1266
|
+
className: cn(
|
|
1267
|
+
"h-5 w-9 rounded-pill bg-line-strong transition-colors duration-(--ml-duration-fast)",
|
|
1268
|
+
"peer-checked:bg-primary",
|
|
1269
|
+
"peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-(--ml-focus-ring)",
|
|
1270
|
+
"after:absolute after:left-0.5 after:top-0.5 after:size-4 after:rounded-full after:bg-white after:shadow-raised",
|
|
1271
|
+
"after:transition-transform after:duration-(--ml-duration-fast) peer-checked:after:translate-x-4"
|
|
1272
|
+
)
|
|
1273
|
+
}
|
|
1274
|
+
)
|
|
1275
|
+
] });
|
|
1276
|
+
if (label === void 0) return control;
|
|
1277
|
+
return /* @__PURE__ */ jsxs(
|
|
1278
|
+
"label",
|
|
1279
|
+
{
|
|
1280
|
+
className: cn(
|
|
1281
|
+
"inline-flex cursor-pointer items-center gap-2.5",
|
|
1282
|
+
disabled && "cursor-not-allowed opacity-60",
|
|
1283
|
+
className
|
|
1284
|
+
),
|
|
1285
|
+
children: [
|
|
1286
|
+
control,
|
|
1287
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm font-medium text-fg", children: label })
|
|
1288
|
+
]
|
|
1289
|
+
}
|
|
1290
|
+
);
|
|
1291
|
+
});
|
|
1292
|
+
function RadioGroup({
|
|
1293
|
+
options,
|
|
1294
|
+
value,
|
|
1295
|
+
defaultValue,
|
|
1296
|
+
onChange,
|
|
1297
|
+
name,
|
|
1298
|
+
orientation = "vertical",
|
|
1299
|
+
disabled = false,
|
|
1300
|
+
className,
|
|
1301
|
+
...rest
|
|
1302
|
+
}) {
|
|
1303
|
+
const generatedName = useId();
|
|
1304
|
+
const groupName = name ?? generatedName;
|
|
1305
|
+
const [current, setCurrent] = useControllableState({
|
|
1306
|
+
value,
|
|
1307
|
+
defaultValue,
|
|
1308
|
+
onChange
|
|
1309
|
+
});
|
|
1310
|
+
return /* @__PURE__ */ jsx(
|
|
1311
|
+
"div",
|
|
1312
|
+
{
|
|
1313
|
+
role: "radiogroup",
|
|
1314
|
+
className: cn("flex gap-3", orientation === "vertical" ? "flex-col" : "flex-row flex-wrap", className),
|
|
1315
|
+
...rest,
|
|
1316
|
+
children: options.map((option) => {
|
|
1317
|
+
const isDisabled = disabled || option.disabled === true;
|
|
1318
|
+
return /* @__PURE__ */ jsxs(
|
|
1319
|
+
"label",
|
|
1320
|
+
{
|
|
1321
|
+
className: cn(
|
|
1322
|
+
"flex cursor-pointer items-start gap-2.5",
|
|
1323
|
+
isDisabled && "cursor-not-allowed opacity-60"
|
|
1324
|
+
),
|
|
1325
|
+
children: [
|
|
1326
|
+
/* @__PURE__ */ jsx("span", { className: "flex h-5 items-center", children: /* @__PURE__ */ jsx(
|
|
1327
|
+
"input",
|
|
1328
|
+
{
|
|
1329
|
+
type: "radio",
|
|
1330
|
+
name: groupName,
|
|
1331
|
+
value: option.value,
|
|
1332
|
+
checked: current === option.value,
|
|
1333
|
+
disabled: isDisabled,
|
|
1334
|
+
onChange: () => {
|
|
1335
|
+
setCurrent(option.value);
|
|
1336
|
+
},
|
|
1337
|
+
className: "focus-ring size-4 cursor-pointer border-line-strong accent-(--ml-primary) disabled:cursor-not-allowed"
|
|
1338
|
+
}
|
|
1339
|
+
) }),
|
|
1340
|
+
/* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-col gap-0.5", children: [
|
|
1341
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm font-medium text-fg", children: option.label }),
|
|
1342
|
+
option.description !== void 0 && /* @__PURE__ */ jsx("span", { className: "text-sm text-fg-muted", children: option.description })
|
|
1343
|
+
] })
|
|
1344
|
+
]
|
|
1345
|
+
},
|
|
1346
|
+
option.value
|
|
1347
|
+
);
|
|
1348
|
+
})
|
|
1349
|
+
}
|
|
1350
|
+
);
|
|
1351
|
+
}
|
|
1352
|
+
var Select = forwardRef(function Select2({ options, placeholder, className, children, ...rest }, ref) {
|
|
1353
|
+
const field = useFieldInputProps(rest);
|
|
1354
|
+
const invalid = field["aria-invalid"] === true;
|
|
1355
|
+
return /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
1356
|
+
/* @__PURE__ */ jsxs(
|
|
1357
|
+
"select",
|
|
1358
|
+
{
|
|
1359
|
+
ref,
|
|
1360
|
+
...rest,
|
|
1361
|
+
...field,
|
|
1362
|
+
className: cn(
|
|
1363
|
+
"focus-ring h-(--ml-control-h-md) w-full cursor-pointer appearance-none rounded-md border bg-surface pl-(--ml-control-px) pr-9 text-sm text-fg",
|
|
1364
|
+
"disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:text-fg-disabled",
|
|
1365
|
+
invalid ? "border-danger" : "border-line-strong",
|
|
1366
|
+
className
|
|
1367
|
+
),
|
|
1368
|
+
children: [
|
|
1369
|
+
placeholder !== void 0 && /* @__PURE__ */ jsx("option", { value: "", disabled: true, children: placeholder }),
|
|
1370
|
+
options?.map((o) => /* @__PURE__ */ jsx("option", { value: o.value, disabled: o.disabled, children: o.label }, o.value)),
|
|
1371
|
+
children
|
|
1372
|
+
]
|
|
1373
|
+
}
|
|
1374
|
+
),
|
|
1375
|
+
/* @__PURE__ */ jsx(
|
|
1376
|
+
"svg",
|
|
1377
|
+
{
|
|
1378
|
+
"aria-hidden": true,
|
|
1379
|
+
className: "pointer-events-none absolute right-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle",
|
|
1380
|
+
viewBox: "0 0 24 24",
|
|
1381
|
+
fill: "none",
|
|
1382
|
+
stroke: "currentColor",
|
|
1383
|
+
strokeWidth: "2",
|
|
1384
|
+
strokeLinecap: "round",
|
|
1385
|
+
strokeLinejoin: "round",
|
|
1386
|
+
children: /* @__PURE__ */ jsx("polyline", { points: "6 9 12 15 18 9" })
|
|
1387
|
+
}
|
|
1388
|
+
)
|
|
1389
|
+
] });
|
|
1390
|
+
});
|
|
1391
|
+
function Calendar({
|
|
1392
|
+
className,
|
|
1393
|
+
classNames,
|
|
1394
|
+
showOutsideDays = true,
|
|
1395
|
+
...props
|
|
1396
|
+
}) {
|
|
1397
|
+
return /* @__PURE__ */ jsx(
|
|
1398
|
+
DayPicker,
|
|
1399
|
+
{
|
|
1400
|
+
showOutsideDays,
|
|
1401
|
+
className: cn("p-3", className),
|
|
1402
|
+
classNames: {
|
|
1403
|
+
months: "flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",
|
|
1404
|
+
month: "space-y-4",
|
|
1405
|
+
caption: "flex justify-center pt-1 relative items-center",
|
|
1406
|
+
caption_label: "text-sm font-medium",
|
|
1407
|
+
nav: "space-x-1 flex items-center",
|
|
1408
|
+
nav_button: cn(
|
|
1409
|
+
"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100 flex items-center justify-center rounded-md hover:bg-surface-sunken"
|
|
1410
|
+
),
|
|
1411
|
+
nav_button_previous: "absolute left-1",
|
|
1412
|
+
nav_button_next: "absolute right-1",
|
|
1413
|
+
table: "w-full border-collapse space-y-1",
|
|
1414
|
+
head_row: "flex",
|
|
1415
|
+
head_cell: "text-fg-muted rounded-md w-9 font-normal text-[0.8rem]",
|
|
1416
|
+
row: "flex w-full mt-2",
|
|
1417
|
+
cell: "h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-surface-sunken/50 [&:has([aria-selected])]:bg-surface-sunken first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",
|
|
1418
|
+
day: cn(
|
|
1419
|
+
"h-9 w-9 p-0 font-normal aria-selected:opacity-100 flex items-center justify-center rounded-md hover:bg-surface-sunken hover:text-fg"
|
|
1420
|
+
),
|
|
1421
|
+
day_range_end: "day-range-end",
|
|
1422
|
+
day_selected: "bg-primary text-primary-fg hover:bg-primary hover:text-primary-fg focus:bg-primary focus:text-primary-fg",
|
|
1423
|
+
day_today: "bg-surface-sunken text-fg",
|
|
1424
|
+
day_outside: "day-outside text-fg-muted opacity-50 aria-selected:bg-surface-sunken/50 aria-selected:text-fg-muted aria-selected:opacity-30",
|
|
1425
|
+
day_disabled: "text-fg-muted opacity-50",
|
|
1426
|
+
day_range_middle: "aria-selected:bg-surface-sunken aria-selected:text-fg",
|
|
1427
|
+
day_hidden: "invisible",
|
|
1428
|
+
...classNames
|
|
1429
|
+
},
|
|
1430
|
+
components: {
|
|
1431
|
+
IconLeft: () => /* @__PURE__ */ jsx("svg", { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: "h-4 w-4", children: /* @__PURE__ */ jsx("path", { d: "M8.84182 3.13514C9.04327 3.32401 9.05348 3.64042 8.86462 3.84188L5.43521 7.49991L8.86462 11.1579C9.05348 11.3594 9.04327 11.6758 8.84182 11.8647C8.64036 12.0535 8.32394 12.0433 8.13508 11.8419L4.38508 7.84188C4.20477 7.64955 4.20477 7.35027 4.38508 7.15794L8.13508 3.15794C8.32394 2.95648 8.64036 2.94628 8.84182 3.13514Z", fill: "currentColor", fillRule: "evenodd", clipRule: "evenodd" }) }),
|
|
1432
|
+
IconRight: () => /* @__PURE__ */ jsx("svg", { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: "h-4 w-4", children: /* @__PURE__ */ jsx("path", { d: "M6.1584 3.13508C5.95698 3.32401 5.9468 3.64042 6.13573 3.84184L9.56496 7.49991L6.13573 11.158C5.9468 11.3594 5.95698 11.6758 6.1584 11.8647C6.35983 12.0537 6.67625 12.0435 6.86518 11.8421L10.6152 7.84206C10.7955 7.64974 10.7955 7.35008 10.6152 7.15777L6.86518 3.15777C6.67625 2.95634 6.35983 2.94614 6.1584 3.13508Z", fill: "currentColor", fillRule: "evenodd", clipRule: "evenodd" }) })
|
|
1433
|
+
},
|
|
1434
|
+
...props
|
|
1435
|
+
}
|
|
1436
|
+
);
|
|
1437
|
+
}
|
|
1438
|
+
function DatePicker({
|
|
1439
|
+
value,
|
|
1440
|
+
onChange,
|
|
1441
|
+
placeholder = "Pick a date",
|
|
1442
|
+
disabled,
|
|
1443
|
+
className
|
|
1444
|
+
}) {
|
|
1445
|
+
const [open, setOpen] = React5.useState(false);
|
|
1446
|
+
return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
|
|
1447
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
1448
|
+
"button",
|
|
1449
|
+
{
|
|
1450
|
+
disabled,
|
|
1451
|
+
className: cn(
|
|
1452
|
+
"flex h-9 w-full items-center justify-between rounded-md border border-line bg-surface px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-fg-muted focus:outline-none focus:ring-1 focus:ring-primary disabled:cursor-not-allowed disabled:opacity-50",
|
|
1453
|
+
!value && "text-fg-muted",
|
|
1454
|
+
className
|
|
1455
|
+
),
|
|
1456
|
+
children: [
|
|
1457
|
+
value ? format(value, "PPP") : /* @__PURE__ */ jsx("span", { children: placeholder }),
|
|
1458
|
+
/* @__PURE__ */ jsx("svg", { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: "h-4 w-4 opacity-50", children: /* @__PURE__ */ jsx("path", { d: "M4.125 1.5C4.125 1.29289 3.95711 1.125 3.75 1.125C3.54289 1.125 3.375 1.29289 3.375 1.5V2.25H1.5C0.671573 2.25 0 2.92157 0 3.75V13.5C0 14.3284 0.671573 15 1.5 15H13.5C14.3284 15 15 14.3284 15 13.5V3.75C15 2.92157 14.3284 2.25 13.5 2.25H11.625V1.5C11.625 1.29289 11.4571 1.125 11.25 1.125C11.0429 1.125 10.875 1.29289 10.875 1.5V2.25H4.125V1.5ZM1.5 3.375H3.375V4.125C3.375 4.33211 3.54289 4.5 3.75 4.5C3.95711 4.5 4.125 4.33211 4.125 4.125V3.375H10.875V4.125C10.875 4.33211 11.0429 4.5 11.25 4.5C11.4571 4.5 11.625 4.33211 11.625 4.125V3.375H13.5C13.7071 3.375 13.875 3.54289 13.875 3.75V5.25H1.125V3.75C1.125 3.54289 1.29289 3.375 1.5 3.375ZM1.125 6.375V13.5C1.125 13.7071 1.29289 13.875 1.5 13.875H13.5C13.7071 13.875 13.875 13.7071 13.875 13.5V6.375H1.125Z", fill: "currentColor", fillRule: "evenodd", clipRule: "evenodd" }) })
|
|
1459
|
+
]
|
|
1460
|
+
}
|
|
1461
|
+
) }),
|
|
1462
|
+
/* @__PURE__ */ jsx(PopoverContent, { className: "w-auto p-0", align: "start", children: /* @__PURE__ */ jsx(
|
|
1463
|
+
Calendar,
|
|
1464
|
+
{
|
|
1465
|
+
mode: "single",
|
|
1466
|
+
selected: value,
|
|
1467
|
+
onSelect: (date) => {
|
|
1468
|
+
onChange?.(date);
|
|
1469
|
+
setOpen(false);
|
|
1470
|
+
},
|
|
1471
|
+
initialFocus: true
|
|
1472
|
+
}
|
|
1473
|
+
) })
|
|
1474
|
+
] });
|
|
1475
|
+
}
|
|
1476
|
+
var Form = FormProvider;
|
|
1477
|
+
var FormFieldContext = React5.createContext(null);
|
|
1478
|
+
var FormField = ({
|
|
1479
|
+
...props
|
|
1480
|
+
}) => {
|
|
1481
|
+
return /* @__PURE__ */ jsx(FormFieldContext.Provider, { value: { name: props.name }, children: /* @__PURE__ */ jsx(Controller, { ...props }) });
|
|
1482
|
+
};
|
|
1483
|
+
var FormItemContext = React5.createContext(
|
|
1484
|
+
{}
|
|
1485
|
+
);
|
|
1486
|
+
var FormItem = React5.forwardRef(({ className, ...props }, ref) => {
|
|
1487
|
+
const id = React5.useId();
|
|
1488
|
+
return /* @__PURE__ */ jsx(FormItemContext.Provider, { value: { id }, children: /* @__PURE__ */ jsx("div", { ref, className: cn("space-y-2", className), ...props }) });
|
|
1489
|
+
});
|
|
1490
|
+
FormItem.displayName = "FormItem";
|
|
1491
|
+
var useFormField = () => {
|
|
1492
|
+
const fieldContext = React5.useContext(FormFieldContext);
|
|
1493
|
+
const itemContext = React5.useContext(FormItemContext);
|
|
1494
|
+
const { getFieldState, formState } = useFormContext();
|
|
1495
|
+
if (!fieldContext) {
|
|
1496
|
+
throw new Error("useFormField should be used within <FormField>");
|
|
1497
|
+
}
|
|
1498
|
+
const fieldState = getFieldState(fieldContext.name, formState);
|
|
1499
|
+
const { id } = itemContext;
|
|
1500
|
+
return {
|
|
1501
|
+
id,
|
|
1502
|
+
name: fieldContext.name,
|
|
1503
|
+
formItemId: `${id}-form-item`,
|
|
1504
|
+
formDescriptionId: `${id}-form-item-description`,
|
|
1505
|
+
formMessageId: `${id}-form-item-message`,
|
|
1506
|
+
...fieldState
|
|
1507
|
+
};
|
|
1508
|
+
};
|
|
1509
|
+
var FormLabel = ({
|
|
1510
|
+
className,
|
|
1511
|
+
required,
|
|
1512
|
+
...props
|
|
1513
|
+
}) => {
|
|
1514
|
+
const { formItemId } = useFormField();
|
|
1515
|
+
return /* @__PURE__ */ jsx(
|
|
1516
|
+
Label,
|
|
1517
|
+
{
|
|
1518
|
+
htmlFor: formItemId,
|
|
1519
|
+
required,
|
|
1520
|
+
className,
|
|
1521
|
+
...props
|
|
1522
|
+
}
|
|
1523
|
+
);
|
|
1524
|
+
};
|
|
1525
|
+
FormLabel.displayName = "FormLabel";
|
|
1526
|
+
var FormControl = React5.forwardRef(({ ...props }, ref) => {
|
|
1527
|
+
const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
|
|
1528
|
+
return /* @__PURE__ */ jsx(
|
|
1529
|
+
Slot,
|
|
1530
|
+
{
|
|
1531
|
+
ref,
|
|
1532
|
+
id: formItemId,
|
|
1533
|
+
"aria-describedby": !error ? formDescriptionId : `${formDescriptionId} ${formMessageId}`,
|
|
1534
|
+
"aria-invalid": !!error,
|
|
1535
|
+
"data-error": !!error,
|
|
1536
|
+
...props
|
|
1537
|
+
}
|
|
1538
|
+
);
|
|
1539
|
+
});
|
|
1540
|
+
FormControl.displayName = "FormControl";
|
|
1541
|
+
var FormDescription = React5.forwardRef(({ className, ...props }, ref) => {
|
|
1542
|
+
const { formDescriptionId } = useFormField();
|
|
1543
|
+
return /* @__PURE__ */ jsx(
|
|
1544
|
+
"p",
|
|
1545
|
+
{
|
|
1546
|
+
ref,
|
|
1547
|
+
id: formDescriptionId,
|
|
1548
|
+
className: cn("text-[0.8rem] text-fg-muted", className),
|
|
1549
|
+
...props
|
|
1550
|
+
}
|
|
1551
|
+
);
|
|
1552
|
+
});
|
|
1553
|
+
FormDescription.displayName = "FormDescription";
|
|
1554
|
+
var FormMessage = React5.forwardRef(({ className, children, ...props }, ref) => {
|
|
1555
|
+
const { error, formMessageId } = useFormField();
|
|
1556
|
+
const body = error ? String(error.message) : children;
|
|
1557
|
+
if (!body) {
|
|
1558
|
+
return null;
|
|
1559
|
+
}
|
|
1560
|
+
return /* @__PURE__ */ jsx(
|
|
1561
|
+
"p",
|
|
1562
|
+
{
|
|
1563
|
+
ref,
|
|
1564
|
+
id: formMessageId,
|
|
1565
|
+
className: cn("text-[0.8rem] font-medium text-danger", className),
|
|
1566
|
+
...props,
|
|
1567
|
+
children: body
|
|
1568
|
+
}
|
|
1569
|
+
);
|
|
1570
|
+
});
|
|
1571
|
+
FormMessage.displayName = "FormMessage";
|
|
1572
|
+
var ToggleGroup = React5.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1573
|
+
ToggleGroupPrimitive.Root,
|
|
1574
|
+
{
|
|
1575
|
+
ref,
|
|
1576
|
+
className: cn("flex items-center gap-1", className),
|
|
1577
|
+
...props
|
|
1578
|
+
}
|
|
1579
|
+
));
|
|
1580
|
+
ToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName;
|
|
1581
|
+
var ToggleGroupItem = React5.forwardRef(({ className, children, badge, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
1582
|
+
ToggleGroupPrimitive.Item,
|
|
1583
|
+
{
|
|
1584
|
+
ref,
|
|
1585
|
+
className: cn(
|
|
1586
|
+
"focus-ring inline-flex h-8 items-center justify-center rounded-full px-4 text-sm font-medium transition-colors hover:bg-surface-sunken hover:text-fg disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-primary data-[state=on]:text-primary-fg text-fg-muted",
|
|
1587
|
+
className
|
|
1588
|
+
),
|
|
1589
|
+
...props,
|
|
1590
|
+
children: [
|
|
1591
|
+
children,
|
|
1592
|
+
badge && /* @__PURE__ */ jsx("span", { className: "ml-1.5 inline-flex items-center justify-center rounded-full bg-fg-muted/20 px-1.5 py-0.5 text-[10px] leading-none group-data-[state=on]:bg-white/20", children: badge })
|
|
1593
|
+
]
|
|
1594
|
+
}
|
|
1595
|
+
));
|
|
1596
|
+
ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName;
|
|
1597
|
+
var Command = React5.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1598
|
+
Command$1,
|
|
1599
|
+
{
|
|
1600
|
+
ref,
|
|
1601
|
+
className: cn(
|
|
1602
|
+
"flex h-full w-full flex-col overflow-hidden rounded-md bg-surface text-fg",
|
|
1603
|
+
className
|
|
1604
|
+
),
|
|
1605
|
+
...props
|
|
1606
|
+
}
|
|
1607
|
+
));
|
|
1608
|
+
Command.displayName = Command$1.displayName;
|
|
1609
|
+
var CommandDialog = ({ children, ...props }) => {
|
|
1610
|
+
return /* @__PURE__ */ jsx(Dialog, { ...props, children: /* @__PURE__ */ jsx(DialogContent, { className: "overflow-hidden p-0 shadow-lg", children: /* @__PURE__ */ jsx(Command, { className: "[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-fg-muted [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5", children }) }) });
|
|
1611
|
+
};
|
|
1612
|
+
var CommandInput = React5.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxs("div", { className: "flex items-center border-b border-line px-3", "cmdk-input-wrapper": "", children: [
|
|
1613
|
+
/* @__PURE__ */ jsx(
|
|
1614
|
+
"svg",
|
|
1615
|
+
{
|
|
1616
|
+
width: "15",
|
|
1617
|
+
height: "15",
|
|
1618
|
+
viewBox: "0 0 15 15",
|
|
1619
|
+
fill: "none",
|
|
1620
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1621
|
+
className: "mr-2 h-4 w-4 shrink-0 opacity-50",
|
|
1622
|
+
children: /* @__PURE__ */ jsx(
|
|
1623
|
+
"path",
|
|
1624
|
+
{
|
|
1625
|
+
d: "M10 6.5C10 8.433 8.433 10 6.5 10C4.567 10 3 8.433 3 6.5C3 4.567 4.567 3 6.5 3C8.433 3 10 4.567 10 6.5ZM9.30884 10.0159C8.53901 10.6318 7.56251 11 6.5 11C4.01472 11 2 8.98528 2 6.5C2 4.01472 4.01472 2 6.5 2C8.98528 2 11 4.01472 11 6.5C11 7.56251 10.6318 8.53901 10.0159 9.30884L12.8536 12.1464C13.0488 12.3417 13.0488 12.6583 12.8536 12.8536C12.6583 13.0488 12.3417 13.0488 12.1464 12.8536L9.30884 10.0159Z",
|
|
1626
|
+
fill: "currentColor",
|
|
1627
|
+
fillRule: "evenodd",
|
|
1628
|
+
clipRule: "evenodd"
|
|
1629
|
+
}
|
|
1630
|
+
)
|
|
1631
|
+
}
|
|
1632
|
+
),
|
|
1633
|
+
/* @__PURE__ */ jsx(
|
|
1634
|
+
Command$1.Input,
|
|
1635
|
+
{
|
|
1636
|
+
ref,
|
|
1637
|
+
className: cn(
|
|
1638
|
+
"flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-fg-muted disabled:cursor-not-allowed disabled:opacity-50",
|
|
1639
|
+
className
|
|
1640
|
+
),
|
|
1641
|
+
...props
|
|
1642
|
+
}
|
|
1643
|
+
)
|
|
1644
|
+
] }));
|
|
1645
|
+
CommandInput.displayName = Command$1.Input.displayName;
|
|
1646
|
+
var CommandList = React5.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1647
|
+
Command$1.List,
|
|
1648
|
+
{
|
|
1649
|
+
ref,
|
|
1650
|
+
className: cn("max-h-[300px] overflow-y-auto overflow-x-hidden", className),
|
|
1651
|
+
...props
|
|
1652
|
+
}
|
|
1653
|
+
));
|
|
1654
|
+
CommandList.displayName = Command$1.List.displayName;
|
|
1655
|
+
var CommandEmpty = React5.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1656
|
+
Command$1.Empty,
|
|
1657
|
+
{
|
|
1658
|
+
ref,
|
|
1659
|
+
className: cn("py-6 text-center text-sm", className),
|
|
1660
|
+
...props
|
|
1661
|
+
}
|
|
1662
|
+
));
|
|
1663
|
+
CommandEmpty.displayName = Command$1.Empty.displayName;
|
|
1664
|
+
var CommandGroup = React5.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1665
|
+
Command$1.Group,
|
|
1666
|
+
{
|
|
1667
|
+
ref,
|
|
1668
|
+
className: cn(
|
|
1669
|
+
"overflow-hidden p-1 text-fg [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-fg-muted",
|
|
1670
|
+
className
|
|
1671
|
+
),
|
|
1672
|
+
...props
|
|
1673
|
+
}
|
|
1674
|
+
));
|
|
1675
|
+
CommandGroup.displayName = Command$1.Group.displayName;
|
|
1676
|
+
var CommandSeparator = React5.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1677
|
+
Command$1.Separator,
|
|
1678
|
+
{
|
|
1679
|
+
ref,
|
|
1680
|
+
className: cn("-mx-1 h-px bg-line", className),
|
|
1681
|
+
...props
|
|
1682
|
+
}
|
|
1683
|
+
));
|
|
1684
|
+
CommandSeparator.displayName = Command$1.Separator.displayName;
|
|
1685
|
+
var CommandItem = React5.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1686
|
+
Command$1.Item,
|
|
1687
|
+
{
|
|
1688
|
+
ref,
|
|
1689
|
+
className: cn(
|
|
1690
|
+
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-surface-sunken aria-selected:text-fg data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
1691
|
+
className
|
|
1692
|
+
),
|
|
1693
|
+
...props
|
|
1694
|
+
}
|
|
1695
|
+
));
|
|
1696
|
+
CommandItem.displayName = Command$1.Item.displayName;
|
|
1697
|
+
var CommandShortcut = ({
|
|
1698
|
+
className,
|
|
1699
|
+
...props
|
|
1700
|
+
}) => {
|
|
1701
|
+
return /* @__PURE__ */ jsx(
|
|
1702
|
+
"span",
|
|
1703
|
+
{
|
|
1704
|
+
className: cn(
|
|
1705
|
+
"ml-auto text-xs tracking-widest text-fg-muted",
|
|
1706
|
+
className
|
|
1707
|
+
),
|
|
1708
|
+
...props
|
|
1709
|
+
}
|
|
1710
|
+
);
|
|
1711
|
+
};
|
|
1712
|
+
CommandShortcut.displayName = "CommandShortcut";
|
|
1713
|
+
function Combobox({
|
|
1714
|
+
options,
|
|
1715
|
+
value,
|
|
1716
|
+
onChange,
|
|
1717
|
+
placeholder = "Select option...",
|
|
1718
|
+
emptyText = "No results found.",
|
|
1719
|
+
className,
|
|
1720
|
+
disabled = false
|
|
1721
|
+
}) {
|
|
1722
|
+
const [open, setOpen] = React5.useState(false);
|
|
1723
|
+
return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
|
|
1724
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
1725
|
+
Button,
|
|
1726
|
+
{
|
|
1727
|
+
variant: "outline",
|
|
1728
|
+
role: "combobox",
|
|
1729
|
+
"aria-expanded": open,
|
|
1730
|
+
className: cn("w-full justify-between font-normal", className),
|
|
1731
|
+
disabled,
|
|
1732
|
+
children: [
|
|
1733
|
+
value ? options.find((option) => option.value === value)?.label : /* @__PURE__ */ jsx("span", { className: "text-fg-muted", children: placeholder }),
|
|
1734
|
+
/* @__PURE__ */ jsx(
|
|
1735
|
+
"svg",
|
|
1736
|
+
{
|
|
1737
|
+
width: "15",
|
|
1738
|
+
height: "15",
|
|
1739
|
+
viewBox: "0 0 15 15",
|
|
1740
|
+
fill: "none",
|
|
1741
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1742
|
+
className: "ml-2 h-4 w-4 shrink-0 opacity-50",
|
|
1743
|
+
children: /* @__PURE__ */ jsx(
|
|
1744
|
+
"path",
|
|
1745
|
+
{
|
|
1746
|
+
d: "M4.93179 5.43179C4.75605 5.60753 4.75605 5.89245 4.93179 6.06819C5.10753 6.24392 5.39245 6.24392 5.56819 6.06819L7.49999 4.13638L9.43179 6.06819C9.60753 6.24392 9.89245 6.24392 10.0682 6.06819C10.2439 5.89245 10.2439 5.60753 10.0682 5.43179L7.81819 3.18179C7.73379 3.0974 7.61933 3.05001 7.49999 3.05001C7.38064 3.05001 7.26618 3.0974 7.18179 3.18179L4.93179 5.43179ZM10.0682 9.56819C10.2439 9.39245 10.2439 9.10753 10.0682 8.93179C9.89245 8.75605 9.60753 8.75605 9.43179 8.93179L7.49999 10.8636L5.56819 8.93179C5.39245 8.75605 5.10753 8.75605 4.93179 8.93179C4.75605 9.10753 4.75605 9.39245 4.93179 9.56819L7.18179 11.8182C7.26618 11.9026 7.38064 11.95 7.49999 11.95C7.61933 11.95 7.73379 11.9026 7.81819 11.8182L10.0682 9.56819Z",
|
|
1747
|
+
fill: "currentColor",
|
|
1748
|
+
fillRule: "evenodd",
|
|
1749
|
+
clipRule: "evenodd"
|
|
1750
|
+
}
|
|
1751
|
+
)
|
|
1752
|
+
}
|
|
1753
|
+
)
|
|
1754
|
+
]
|
|
1755
|
+
}
|
|
1756
|
+
) }),
|
|
1757
|
+
/* @__PURE__ */ jsx(PopoverContent, { className: "w-[--radix-popover-trigger-width] p-0", children: /* @__PURE__ */ jsxs(Command, { children: [
|
|
1758
|
+
/* @__PURE__ */ jsx(CommandInput, { placeholder: "Search..." }),
|
|
1759
|
+
/* @__PURE__ */ jsxs(CommandList, { children: [
|
|
1760
|
+
/* @__PURE__ */ jsx(CommandEmpty, { children: emptyText }),
|
|
1761
|
+
/* @__PURE__ */ jsx(CommandGroup, { children: options.map((option) => /* @__PURE__ */ jsxs(
|
|
1762
|
+
CommandItem,
|
|
1763
|
+
{
|
|
1764
|
+
value: option.label,
|
|
1765
|
+
onSelect: () => {
|
|
1766
|
+
onChange?.(option.value === value ? "" : option.value);
|
|
1767
|
+
setOpen(false);
|
|
1768
|
+
},
|
|
1769
|
+
children: [
|
|
1770
|
+
/* @__PURE__ */ jsx(
|
|
1771
|
+
"svg",
|
|
1772
|
+
{
|
|
1773
|
+
width: "15",
|
|
1774
|
+
height: "15",
|
|
1775
|
+
viewBox: "0 0 15 15",
|
|
1776
|
+
fill: "none",
|
|
1777
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1778
|
+
className: cn(
|
|
1779
|
+
"mr-2 h-4 w-4",
|
|
1780
|
+
value === option.value ? "opacity-100" : "opacity-0"
|
|
1781
|
+
),
|
|
1782
|
+
children: /* @__PURE__ */ jsx(
|
|
1783
|
+
"path",
|
|
1784
|
+
{
|
|
1785
|
+
d: "M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z",
|
|
1786
|
+
fill: "currentColor",
|
|
1787
|
+
fillRule: "evenodd",
|
|
1788
|
+
clipRule: "evenodd"
|
|
1789
|
+
}
|
|
1790
|
+
)
|
|
1791
|
+
}
|
|
1792
|
+
),
|
|
1793
|
+
option.label
|
|
1794
|
+
]
|
|
1795
|
+
},
|
|
1796
|
+
option.value
|
|
1797
|
+
)) })
|
|
1798
|
+
] })
|
|
1799
|
+
] }) })
|
|
1800
|
+
] });
|
|
1801
|
+
}
|
|
1802
|
+
var variantStyles = {
|
|
1803
|
+
default: "bg-primary text-primary-fg hover:bg-primary-hover border-transparent",
|
|
1804
|
+
secondary: "bg-surface-sunken text-fg hover:bg-surface-sunken/80 border-transparent",
|
|
1805
|
+
success: "bg-success text-success-fg hover:bg-success/80 border-transparent",
|
|
1806
|
+
warning: "bg-warning text-warning-fg hover:bg-warning/80 border-transparent",
|
|
1807
|
+
danger: "bg-danger text-danger-fg hover:bg-danger/80 border-transparent",
|
|
1808
|
+
info: "bg-info text-info-fg hover:bg-info/80 border-transparent",
|
|
1809
|
+
outline: "text-fg border-line hover:bg-surface-sunken",
|
|
1810
|
+
"primary-subtle": "bg-primary-subtle text-primary-subtle-fg hover:bg-primary-subtle/80 border-transparent",
|
|
1811
|
+
"success-subtle": "bg-success-subtle text-success-subtle-fg hover:bg-success-subtle/80 border-transparent",
|
|
1812
|
+
"warning-subtle": "bg-warning-subtle text-warning-subtle-fg hover:bg-warning-subtle/80 border-transparent",
|
|
1813
|
+
"danger-subtle": "bg-danger-subtle text-danger-subtle-fg hover:bg-danger-subtle/80 border-transparent",
|
|
1814
|
+
"info-subtle": "bg-info-subtle text-info-subtle-fg hover:bg-info-subtle/80 border-transparent"
|
|
1815
|
+
};
|
|
1816
|
+
var dotStyles = {
|
|
1817
|
+
default: "bg-primary-fg",
|
|
1818
|
+
secondary: "bg-fg-muted",
|
|
1819
|
+
success: "bg-success-fg",
|
|
1820
|
+
warning: "bg-warning-fg",
|
|
1821
|
+
danger: "bg-danger-fg",
|
|
1822
|
+
info: "bg-info-fg",
|
|
1823
|
+
outline: "bg-fg-muted",
|
|
1824
|
+
"primary-subtle": "bg-primary",
|
|
1825
|
+
"success-subtle": "bg-success",
|
|
1826
|
+
"warning-subtle": "bg-warning",
|
|
1827
|
+
"danger-subtle": "bg-danger",
|
|
1828
|
+
"info-subtle": "bg-info"
|
|
1829
|
+
};
|
|
1830
|
+
var Badge = forwardRef(function Badge2({ className, variant = "default", dot = false, children, ...props }, ref) {
|
|
1831
|
+
return /* @__PURE__ */ jsxs(
|
|
1832
|
+
"div",
|
|
1833
|
+
{
|
|
1834
|
+
ref,
|
|
1835
|
+
className: cn(
|
|
1836
|
+
"inline-flex items-center gap-1.5 rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus-ring",
|
|
1837
|
+
variantStyles[variant],
|
|
1838
|
+
className
|
|
1839
|
+
),
|
|
1840
|
+
...props,
|
|
1841
|
+
children: [
|
|
1842
|
+
dot && /* @__PURE__ */ jsx("span", { className: cn("h-1.5 w-1.5 rounded-full", dotStyles[variant]), "aria-hidden": "true" }),
|
|
1843
|
+
children
|
|
1844
|
+
]
|
|
1845
|
+
}
|
|
1846
|
+
);
|
|
1847
|
+
});
|
|
1848
|
+
var MultiSelect = React5.forwardRef(
|
|
1849
|
+
({ options, value, onChange, placeholder = "Select...", disabled, className, ...props }, ref) => {
|
|
1850
|
+
const field = useFieldInputProps({});
|
|
1851
|
+
const invalid = field["aria-invalid"] === true;
|
|
1852
|
+
const [isOpen, setIsOpen] = React5.useState(false);
|
|
1853
|
+
const containerRef = React5.useRef(null);
|
|
1854
|
+
React5.useImperativeHandle(ref, () => containerRef.current);
|
|
1855
|
+
const handleSelect = (optionValue) => {
|
|
1856
|
+
if (disabled) return;
|
|
1857
|
+
if (value.includes(optionValue)) {
|
|
1858
|
+
onChange(value.filter((v) => v !== optionValue));
|
|
1859
|
+
} else {
|
|
1860
|
+
onChange([...value, optionValue]);
|
|
1861
|
+
}
|
|
1862
|
+
};
|
|
1863
|
+
const handleRemove = (e, optionValue) => {
|
|
1864
|
+
e.stopPropagation();
|
|
1865
|
+
if (disabled) return;
|
|
1866
|
+
onChange(value.filter((v) => v !== optionValue));
|
|
1867
|
+
};
|
|
1868
|
+
React5.useEffect(() => {
|
|
1869
|
+
const handleClickOutside = (event) => {
|
|
1870
|
+
if (containerRef.current && !containerRef.current.contains(event.target)) {
|
|
1871
|
+
setIsOpen(false);
|
|
1872
|
+
}
|
|
1873
|
+
};
|
|
1874
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
1875
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
1876
|
+
}, []);
|
|
1877
|
+
const selectedOptions = options.filter((o) => value.includes(o.value));
|
|
1878
|
+
return /* @__PURE__ */ jsxs(
|
|
1879
|
+
"div",
|
|
1880
|
+
{
|
|
1881
|
+
ref: containerRef,
|
|
1882
|
+
className: cn("relative w-full", className),
|
|
1883
|
+
...props,
|
|
1884
|
+
children: [
|
|
1885
|
+
/* @__PURE__ */ jsxs(
|
|
1886
|
+
"div",
|
|
1887
|
+
{
|
|
1888
|
+
className: cn(
|
|
1889
|
+
"flex min-h-[--ml-control-h-md] w-full cursor-pointer flex-wrap items-center gap-1.5 rounded-md border bg-surface p-1.5 text-sm text-fg transition-colors",
|
|
1890
|
+
disabled && "cursor-not-allowed bg-surface-sunken text-fg-disabled",
|
|
1891
|
+
invalid ? "border-danger" : "border-line-strong",
|
|
1892
|
+
isOpen && !invalid && "border-primary ring-1 ring-primary/20"
|
|
1893
|
+
),
|
|
1894
|
+
onClick: () => !disabled && setIsOpen(!isOpen),
|
|
1895
|
+
...field,
|
|
1896
|
+
children: [
|
|
1897
|
+
selectedOptions.length === 0 && /* @__PURE__ */ jsx("span", { className: "px-2 text-fg-subtle", children: placeholder }),
|
|
1898
|
+
selectedOptions.map((option) => /* @__PURE__ */ jsxs(Badge, { variant: "secondary", className: "gap-1 px-1.5 py-0.5", children: [
|
|
1899
|
+
option.label,
|
|
1900
|
+
/* @__PURE__ */ jsx(
|
|
1901
|
+
"button",
|
|
1902
|
+
{
|
|
1903
|
+
type: "button",
|
|
1904
|
+
className: "hover:text-danger rounded-full focus:outline-none",
|
|
1905
|
+
onClick: (e) => handleRemove(e, option.value),
|
|
1906
|
+
children: /* @__PURE__ */ jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
1907
|
+
/* @__PURE__ */ jsx("path", { d: "M18 6 6 18" }),
|
|
1908
|
+
/* @__PURE__ */ jsx("path", { d: "m6 6 12 12" })
|
|
1909
|
+
] })
|
|
1910
|
+
}
|
|
1911
|
+
)
|
|
1912
|
+
] }, option.value)),
|
|
1913
|
+
/* @__PURE__ */ jsx("div", { className: "ml-auto px-2", children: /* @__PURE__ */ jsx(
|
|
1914
|
+
"svg",
|
|
1915
|
+
{
|
|
1916
|
+
className: "size-4 text-fg-subtle",
|
|
1917
|
+
viewBox: "0 0 24 24",
|
|
1918
|
+
fill: "none",
|
|
1919
|
+
stroke: "currentColor",
|
|
1920
|
+
strokeWidth: "2",
|
|
1921
|
+
strokeLinecap: "round",
|
|
1922
|
+
strokeLinejoin: "round",
|
|
1923
|
+
children: /* @__PURE__ */ jsx("polyline", { points: "6 9 12 15 18 9" })
|
|
1924
|
+
}
|
|
1925
|
+
) })
|
|
1926
|
+
]
|
|
1927
|
+
}
|
|
1928
|
+
),
|
|
1929
|
+
isOpen && /* @__PURE__ */ jsx("div", { className: "absolute z-50 mt-1 max-h-60 w-full overflow-auto rounded-md border border-line bg-surface p-1 shadow-lg", children: options.map((option) => {
|
|
1930
|
+
const isSelected = value.includes(option.value);
|
|
1931
|
+
return /* @__PURE__ */ jsxs(
|
|
1932
|
+
"div",
|
|
1933
|
+
{
|
|
1934
|
+
className: cn(
|
|
1935
|
+
"flex cursor-pointer items-center justify-between rounded-sm px-2 py-1.5 text-sm text-fg hover:bg-surface-sunken",
|
|
1936
|
+
isSelected && "bg-primary/10 text-primary font-medium"
|
|
1937
|
+
),
|
|
1938
|
+
onClick: () => handleSelect(option.value),
|
|
1939
|
+
children: [
|
|
1940
|
+
/* @__PURE__ */ jsx("span", { children: option.label }),
|
|
1941
|
+
isSelected && /* @__PURE__ */ jsx("svg", { className: "size-4", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "M20 6 9 17l-5-5" }) })
|
|
1942
|
+
]
|
|
1943
|
+
},
|
|
1944
|
+
option.value
|
|
1945
|
+
);
|
|
1946
|
+
}) })
|
|
1947
|
+
]
|
|
1948
|
+
}
|
|
1949
|
+
);
|
|
1950
|
+
}
|
|
1951
|
+
);
|
|
1952
|
+
MultiSelect.displayName = "MultiSelect";
|
|
1953
|
+
var FileUpload = React5.forwardRef(
|
|
1954
|
+
({ onChange, accept, multiple = false, disabled = false, maxSize, className, ...props }, ref) => {
|
|
1955
|
+
const field = useFieldInputProps({});
|
|
1956
|
+
const invalid = field["aria-invalid"] === true;
|
|
1957
|
+
const inputRef = React5.useRef(null);
|
|
1958
|
+
const [isDragging, setIsDragging] = React5.useState(false);
|
|
1959
|
+
const [selectedFiles, setSelectedFiles] = React5.useState([]);
|
|
1960
|
+
React5.useImperativeHandle(ref, () => inputRef.current);
|
|
1961
|
+
const handleFiles = (newFiles) => {
|
|
1962
|
+
if (!newFiles || disabled) return;
|
|
1963
|
+
const validFiles = Array.from(newFiles).filter((file) => {
|
|
1964
|
+
if (maxSize && file.size > maxSize) return false;
|
|
1965
|
+
return true;
|
|
1966
|
+
});
|
|
1967
|
+
const updatedFiles = multiple ? [...selectedFiles, ...validFiles] : validFiles.slice(0, 1);
|
|
1968
|
+
setSelectedFiles(updatedFiles);
|
|
1969
|
+
onChange?.(updatedFiles);
|
|
1970
|
+
};
|
|
1971
|
+
const handleDragEnter = (e) => {
|
|
1972
|
+
e.preventDefault();
|
|
1973
|
+
e.stopPropagation();
|
|
1974
|
+
if (!disabled) setIsDragging(true);
|
|
1975
|
+
};
|
|
1976
|
+
const handleDragLeave = (e) => {
|
|
1977
|
+
e.preventDefault();
|
|
1978
|
+
e.stopPropagation();
|
|
1979
|
+
setIsDragging(false);
|
|
1980
|
+
};
|
|
1981
|
+
const handleDragOver = (e) => {
|
|
1982
|
+
e.preventDefault();
|
|
1983
|
+
e.stopPropagation();
|
|
1984
|
+
if (!disabled) setIsDragging(true);
|
|
1985
|
+
};
|
|
1986
|
+
const handleDrop = (e) => {
|
|
1987
|
+
e.preventDefault();
|
|
1988
|
+
e.stopPropagation();
|
|
1989
|
+
setIsDragging(false);
|
|
1990
|
+
handleFiles(e.dataTransfer.files);
|
|
1991
|
+
};
|
|
1992
|
+
const handleRemove = (index) => {
|
|
1993
|
+
const updatedFiles = [...selectedFiles];
|
|
1994
|
+
updatedFiles.splice(index, 1);
|
|
1995
|
+
setSelectedFiles(updatedFiles);
|
|
1996
|
+
onChange?.(updatedFiles);
|
|
1997
|
+
if (inputRef.current) inputRef.current.value = "";
|
|
1998
|
+
};
|
|
1999
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("w-full", className), ...props, children: [
|
|
2000
|
+
/* @__PURE__ */ jsxs(
|
|
2001
|
+
"div",
|
|
2002
|
+
{
|
|
2003
|
+
className: cn(
|
|
2004
|
+
"relative flex cursor-pointer flex-col items-center justify-center rounded-lg border-2 border-dashed p-6 transition-colors",
|
|
2005
|
+
isDragging ? "border-primary bg-primary/5" : "border-line-strong bg-surface hover:bg-surface-sunken",
|
|
2006
|
+
disabled && "cursor-not-allowed bg-surface-sunken opacity-60 hover:bg-surface-sunken",
|
|
2007
|
+
invalid && !isDragging && "border-danger bg-danger/5"
|
|
2008
|
+
),
|
|
2009
|
+
onClick: () => !disabled && inputRef.current?.click(),
|
|
2010
|
+
onDragEnter: handleDragEnter,
|
|
2011
|
+
onDragLeave: handleDragLeave,
|
|
2012
|
+
onDragOver: handleDragOver,
|
|
2013
|
+
onDrop: handleDrop,
|
|
2014
|
+
...field,
|
|
2015
|
+
children: [
|
|
2016
|
+
/* @__PURE__ */ jsx(
|
|
2017
|
+
"input",
|
|
2018
|
+
{
|
|
2019
|
+
ref: inputRef,
|
|
2020
|
+
type: "file",
|
|
2021
|
+
accept,
|
|
2022
|
+
multiple,
|
|
2023
|
+
disabled,
|
|
2024
|
+
className: "hidden",
|
|
2025
|
+
onChange: (e) => handleFiles(e.target.files)
|
|
2026
|
+
}
|
|
2027
|
+
),
|
|
2028
|
+
/* @__PURE__ */ jsxs("svg", { className: "mb-3 size-8 text-fg-subtle", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
2029
|
+
/* @__PURE__ */ jsx("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }),
|
|
2030
|
+
/* @__PURE__ */ jsx("polyline", { points: "17 8 12 3 7 8" }),
|
|
2031
|
+
/* @__PURE__ */ jsx("line", { x1: "12", y1: "3", x2: "12", y2: "15" })
|
|
2032
|
+
] }),
|
|
2033
|
+
/* @__PURE__ */ jsxs("div", { className: "text-center", children: [
|
|
2034
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-fg", children: "Click to upload or drag and drop" }),
|
|
2035
|
+
/* @__PURE__ */ jsxs("p", { className: "mt-1 text-xs text-fg-muted", children: [
|
|
2036
|
+
accept ? `Supported: ${accept}` : "All files supported",
|
|
2037
|
+
maxSize && ` (Max: ${Math.round(maxSize / 1024 / 1024)}MB)`
|
|
2038
|
+
] })
|
|
2039
|
+
] })
|
|
2040
|
+
]
|
|
2041
|
+
}
|
|
2042
|
+
),
|
|
2043
|
+
selectedFiles.length > 0 && /* @__PURE__ */ jsx("ul", { className: "mt-4 flex flex-col gap-2", children: selectedFiles.map((file, i) => /* @__PURE__ */ jsxs("li", { className: "flex items-center justify-between rounded-md border border-line bg-surface p-3 shadow-sm", children: [
|
|
2044
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 overflow-hidden", children: [
|
|
2045
|
+
/* @__PURE__ */ jsxs("svg", { className: "size-5 shrink-0 text-primary", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
2046
|
+
/* @__PURE__ */ jsx("path", { d: "M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z" }),
|
|
2047
|
+
/* @__PURE__ */ jsx("polyline", { points: "13 2 13 9 20 9" })
|
|
2048
|
+
] }),
|
|
2049
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col truncate", children: [
|
|
2050
|
+
/* @__PURE__ */ jsx("span", { className: "truncate text-sm font-medium text-fg", children: file.name }),
|
|
2051
|
+
/* @__PURE__ */ jsxs("span", { className: "text-xs text-fg-muted", children: [
|
|
2052
|
+
(file.size / 1024).toFixed(1),
|
|
2053
|
+
" KB"
|
|
2054
|
+
] })
|
|
2055
|
+
] })
|
|
2056
|
+
] }),
|
|
2057
|
+
/* @__PURE__ */ jsx(
|
|
2058
|
+
"button",
|
|
2059
|
+
{
|
|
2060
|
+
type: "button",
|
|
2061
|
+
className: "ml-4 rounded p-1 text-fg-subtle hover:bg-surface-sunken hover:text-danger focus:outline-none",
|
|
2062
|
+
onClick: () => handleRemove(i),
|
|
2063
|
+
disabled,
|
|
2064
|
+
children: /* @__PURE__ */ jsxs("svg", { className: "size-4", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
2065
|
+
/* @__PURE__ */ jsx("polyline", { points: "3 6 5 6 21 6" }),
|
|
2066
|
+
/* @__PURE__ */ jsx("path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" }),
|
|
2067
|
+
/* @__PURE__ */ jsx("line", { x1: "10", y1: "11", x2: "10", y2: "17" }),
|
|
2068
|
+
/* @__PURE__ */ jsx("line", { x1: "14", y1: "11", x2: "14", y2: "17" })
|
|
2069
|
+
] })
|
|
2070
|
+
}
|
|
2071
|
+
)
|
|
2072
|
+
] }, `${file.name}-${i}`)) })
|
|
2073
|
+
] });
|
|
2074
|
+
}
|
|
2075
|
+
);
|
|
2076
|
+
FileUpload.displayName = "FileUpload";
|
|
2077
|
+
function DateRangePicker({
|
|
2078
|
+
value,
|
|
2079
|
+
onChange,
|
|
2080
|
+
placeholder = "Pick a date range",
|
|
2081
|
+
disabled,
|
|
2082
|
+
className
|
|
2083
|
+
}) {
|
|
2084
|
+
const [open, setOpen] = React5.useState(false);
|
|
2085
|
+
return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
|
|
2086
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
2087
|
+
"button",
|
|
2088
|
+
{
|
|
2089
|
+
disabled,
|
|
2090
|
+
className: cn(
|
|
2091
|
+
"flex h-9 w-full items-center justify-between rounded-md border border-line bg-surface px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-fg-muted focus:outline-none focus:ring-1 focus:ring-primary disabled:cursor-not-allowed disabled:opacity-50",
|
|
2092
|
+
!value?.from && "text-fg-muted",
|
|
2093
|
+
className
|
|
2094
|
+
),
|
|
2095
|
+
children: [
|
|
2096
|
+
/* @__PURE__ */ jsx("span", { children: value?.from ? value.to ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2097
|
+
format(value.from, "LLL dd, y"),
|
|
2098
|
+
" - ",
|
|
2099
|
+
format(value.to, "LLL dd, y")
|
|
2100
|
+
] }) : format(value.from, "LLL dd, y") : placeholder }),
|
|
2101
|
+
/* @__PURE__ */ jsx("svg", { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: "h-4 w-4 opacity-50", children: /* @__PURE__ */ jsx("path", { d: "M4.125 1.5C4.125 1.29289 3.95711 1.125 3.75 1.125C3.54289 1.125 3.375 1.29289 3.375 1.5V2.25H1.5C0.671573 2.25 0 2.92157 0 3.75V13.5C0 14.3284 0.671573 15 1.5 15H13.5C14.3284 15 15 14.3284 15 13.5V3.75C15 2.92157 14.3284 2.25 13.5 2.25H11.625V1.5C11.625 1.29289 11.4571 1.125 11.25 1.125C11.0429 1.125 10.875 1.29289 10.875 1.5V2.25H4.125V1.5ZM1.5 3.375H3.375V4.125C3.375 4.33211 3.54289 4.5 3.75 4.5C3.95711 4.5 4.125 4.33211 4.125 4.125V3.375H10.875V4.125C10.875 4.33211 11.0429 4.5 11.25 4.5C11.4571 4.5 11.625 4.33211 11.625 4.125V3.375H13.5C13.7071 3.375 13.875 3.54289 13.875 3.75V5.25H1.125V3.75C1.125 3.54289 1.29289 3.375 1.5 3.375ZM1.125 6.375V13.5C1.125 13.7071 1.29289 13.875 1.5 13.875H13.5C13.7071 13.875 13.875 13.7071 13.875 13.5V6.375H1.125Z", fill: "currentColor", fillRule: "evenodd", clipRule: "evenodd" }) })
|
|
2102
|
+
]
|
|
2103
|
+
}
|
|
2104
|
+
) }),
|
|
2105
|
+
/* @__PURE__ */ jsx(PopoverContent, { className: "w-auto p-0", align: "start", children: /* @__PURE__ */ jsx(
|
|
2106
|
+
Calendar,
|
|
2107
|
+
{
|
|
2108
|
+
initialFocus: true,
|
|
2109
|
+
mode: "range",
|
|
2110
|
+
defaultMonth: value?.from,
|
|
2111
|
+
selected: value,
|
|
2112
|
+
onSelect: onChange,
|
|
2113
|
+
numberOfMonths: 2
|
|
2114
|
+
}
|
|
2115
|
+
) })
|
|
2116
|
+
] });
|
|
2117
|
+
}
|
|
2118
|
+
var Slider = React5.forwardRef(
|
|
2119
|
+
({
|
|
2120
|
+
value,
|
|
2121
|
+
defaultValue,
|
|
2122
|
+
min = 0,
|
|
2123
|
+
max = 100,
|
|
2124
|
+
step = 1,
|
|
2125
|
+
onChange,
|
|
2126
|
+
showTicks = false,
|
|
2127
|
+
className,
|
|
2128
|
+
disabled,
|
|
2129
|
+
...props
|
|
2130
|
+
}, ref) => {
|
|
2131
|
+
const field = useFieldInputProps({});
|
|
2132
|
+
const invalid = field["aria-invalid"] === true;
|
|
2133
|
+
const [internalValue, setInternalValue] = React5.useState(
|
|
2134
|
+
value ?? defaultValue ?? min
|
|
2135
|
+
);
|
|
2136
|
+
const isControlled = value !== void 0;
|
|
2137
|
+
const currentValue = isControlled ? value : internalValue;
|
|
2138
|
+
const handleChange = (e) => {
|
|
2139
|
+
const val = Number(e.target.value);
|
|
2140
|
+
if (!isControlled) {
|
|
2141
|
+
setInternalValue(val);
|
|
2142
|
+
}
|
|
2143
|
+
onChange?.(val);
|
|
2144
|
+
};
|
|
2145
|
+
const percentage = (currentValue - min) / (max - min) * 100;
|
|
2146
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("relative w-full", className), children: [
|
|
2147
|
+
/* @__PURE__ */ jsxs("div", { className: "relative flex h-6 w-full items-center", children: [
|
|
2148
|
+
/* @__PURE__ */ jsx("div", { className: "absolute h-1.5 w-full overflow-hidden rounded-full bg-surface-sunken", children: /* @__PURE__ */ jsx(
|
|
2149
|
+
"div",
|
|
2150
|
+
{
|
|
2151
|
+
className: cn(
|
|
2152
|
+
"h-full bg-primary",
|
|
2153
|
+
disabled && "bg-fg-muted",
|
|
2154
|
+
invalid && "bg-danger"
|
|
2155
|
+
),
|
|
2156
|
+
style: { width: `${percentage}%` }
|
|
2157
|
+
}
|
|
2158
|
+
) }),
|
|
2159
|
+
/* @__PURE__ */ jsx(
|
|
2160
|
+
"input",
|
|
2161
|
+
{
|
|
2162
|
+
ref,
|
|
2163
|
+
type: "range",
|
|
2164
|
+
min,
|
|
2165
|
+
max,
|
|
2166
|
+
step,
|
|
2167
|
+
value: currentValue,
|
|
2168
|
+
onChange: handleChange,
|
|
2169
|
+
...field,
|
|
2170
|
+
...props,
|
|
2171
|
+
disabled: disabled || field.disabled,
|
|
2172
|
+
className: cn(
|
|
2173
|
+
"absolute h-full w-full cursor-pointer appearance-none bg-transparent outline-none",
|
|
2174
|
+
"[&::-webkit-slider-thumb]:pointer-events-auto [&::-webkit-slider-thumb]:size-5 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:border-2 [&::-webkit-slider-thumb]:border-primary [&::-webkit-slider-thumb]:bg-surface [&::-webkit-slider-thumb]:shadow-md [&::-webkit-slider-thumb]:transition-colors",
|
|
2175
|
+
"[&::-moz-range-thumb]:pointer-events-auto [&::-moz-range-thumb]:size-5 [&::-moz-range-thumb]:appearance-none [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-2 [&::-moz-range-thumb]:border-primary [&::-moz-range-thumb]:bg-surface [&::-moz-range-thumb]:shadow-md [&::-moz-range-thumb]:transition-colors",
|
|
2176
|
+
"focus-visible:[&::-webkit-slider-thumb]:ring-2 focus-visible:[&::-webkit-slider-thumb]:ring-primary focus-visible:[&::-webkit-slider-thumb]:ring-offset-2",
|
|
2177
|
+
"focus-visible:[&::-moz-range-thumb]:ring-2 focus-visible:[&::-moz-range-thumb]:ring-primary focus-visible:[&::-moz-range-thumb]:ring-offset-2",
|
|
2178
|
+
disabled && "cursor-not-allowed [&::-webkit-slider-thumb]:border-fg-muted [&::-webkit-slider-thumb]:bg-surface-sunken [&::-moz-range-thumb]:border-fg-muted [&::-moz-range-thumb]:bg-surface-sunken",
|
|
2179
|
+
invalid && "[&::-webkit-slider-thumb]:border-danger [&::-moz-range-thumb]:border-danger"
|
|
2180
|
+
)
|
|
2181
|
+
}
|
|
2182
|
+
)
|
|
2183
|
+
] }),
|
|
2184
|
+
showTicks && /* @__PURE__ */ jsxs("div", { className: "mt-2 flex justify-between text-xs text-fg-muted px-1", children: [
|
|
2185
|
+
/* @__PURE__ */ jsx("span", { children: min }),
|
|
2186
|
+
/* @__PURE__ */ jsx("span", { children: max })
|
|
2187
|
+
] })
|
|
2188
|
+
] });
|
|
2189
|
+
}
|
|
2190
|
+
);
|
|
2191
|
+
Slider.displayName = "Slider";
|
|
2192
|
+
var SignatureInput = React5.forwardRef(
|
|
2193
|
+
({ onChange, disabled, className, ...props }, ref) => {
|
|
2194
|
+
const field = useFieldInputProps({});
|
|
2195
|
+
const invalid = field["aria-invalid"] === true;
|
|
2196
|
+
const canvasRef = React5.useRef(null);
|
|
2197
|
+
const [isDrawing, setIsDrawing] = React5.useState(false);
|
|
2198
|
+
const [hasSignature, setHasSignature] = React5.useState(false);
|
|
2199
|
+
const getCoordinates = (e) => {
|
|
2200
|
+
if (!canvasRef.current) return;
|
|
2201
|
+
const canvas = canvasRef.current;
|
|
2202
|
+
const rect = canvas.getBoundingClientRect();
|
|
2203
|
+
let clientX, clientY;
|
|
2204
|
+
if ("touches" in e) {
|
|
2205
|
+
const touch = e.touches[0];
|
|
2206
|
+
if (!touch) return;
|
|
2207
|
+
clientX = touch.clientX;
|
|
2208
|
+
clientY = touch.clientY;
|
|
2209
|
+
} else {
|
|
2210
|
+
clientX = e.clientX;
|
|
2211
|
+
clientY = e.clientY;
|
|
2212
|
+
}
|
|
2213
|
+
return {
|
|
2214
|
+
x: clientX - rect.left,
|
|
2215
|
+
y: clientY - rect.top
|
|
2216
|
+
};
|
|
2217
|
+
};
|
|
2218
|
+
const startDrawing = (e) => {
|
|
2219
|
+
if (disabled || !canvasRef.current) return;
|
|
2220
|
+
const coords = getCoordinates(e);
|
|
2221
|
+
if (!coords) return;
|
|
2222
|
+
const ctx = canvasRef.current.getContext("2d");
|
|
2223
|
+
if (!ctx) return;
|
|
2224
|
+
ctx.beginPath();
|
|
2225
|
+
ctx.moveTo(coords.x, coords.y);
|
|
2226
|
+
setIsDrawing(true);
|
|
2227
|
+
};
|
|
2228
|
+
const draw = (e) => {
|
|
2229
|
+
if (!isDrawing || disabled || !canvasRef.current) return;
|
|
2230
|
+
const coords = getCoordinates(e);
|
|
2231
|
+
if (!coords) return;
|
|
2232
|
+
const ctx = canvasRef.current.getContext("2d");
|
|
2233
|
+
if (!ctx) return;
|
|
2234
|
+
ctx.lineTo(coords.x, coords.y);
|
|
2235
|
+
ctx.stroke();
|
|
2236
|
+
setHasSignature(true);
|
|
2237
|
+
};
|
|
2238
|
+
const stopDrawing = () => {
|
|
2239
|
+
if (isDrawing && canvasRef.current) {
|
|
2240
|
+
setIsDrawing(false);
|
|
2241
|
+
const dataUrl = canvasRef.current.toDataURL("image/png");
|
|
2242
|
+
onChange?.(dataUrl);
|
|
2243
|
+
}
|
|
2244
|
+
};
|
|
2245
|
+
const clearSignature = () => {
|
|
2246
|
+
if (disabled || !canvasRef.current) return;
|
|
2247
|
+
const ctx = canvasRef.current.getContext("2d");
|
|
2248
|
+
if (ctx) {
|
|
2249
|
+
ctx.clearRect(0, 0, canvasRef.current.width, canvasRef.current.height);
|
|
2250
|
+
setHasSignature(false);
|
|
2251
|
+
onChange?.(null);
|
|
2252
|
+
}
|
|
2253
|
+
};
|
|
2254
|
+
React5.useEffect(() => {
|
|
2255
|
+
const canvas = canvasRef.current;
|
|
2256
|
+
if (canvas) {
|
|
2257
|
+
const ctx = canvas.getContext("2d");
|
|
2258
|
+
if (ctx) {
|
|
2259
|
+
ctx.strokeStyle = "#000";
|
|
2260
|
+
ctx.lineWidth = 2;
|
|
2261
|
+
ctx.lineCap = "round";
|
|
2262
|
+
ctx.lineJoin = "round";
|
|
2263
|
+
}
|
|
2264
|
+
}
|
|
2265
|
+
}, []);
|
|
2266
|
+
return /* @__PURE__ */ jsxs(
|
|
2267
|
+
"div",
|
|
2268
|
+
{
|
|
2269
|
+
ref,
|
|
2270
|
+
className: cn("flex flex-col gap-2 w-full", className),
|
|
2271
|
+
...props,
|
|
2272
|
+
children: [
|
|
2273
|
+
/* @__PURE__ */ jsxs(
|
|
2274
|
+
"div",
|
|
2275
|
+
{
|
|
2276
|
+
className: cn(
|
|
2277
|
+
"relative w-full rounded-md border bg-surface overflow-hidden",
|
|
2278
|
+
invalid ? "border-danger" : "border-line-strong",
|
|
2279
|
+
disabled ? "opacity-50 cursor-not-allowed bg-surface-sunken" : "cursor-crosshair",
|
|
2280
|
+
"h-[150px]"
|
|
2281
|
+
// Fixed height for signature pad
|
|
2282
|
+
),
|
|
2283
|
+
...field,
|
|
2284
|
+
children: [
|
|
2285
|
+
!hasSignature && !disabled && /* @__PURE__ */ jsx("div", { className: "absolute inset-0 flex items-center justify-center pointer-events-none text-fg-muted opacity-50 text-sm", children: "Sign here" }),
|
|
2286
|
+
/* @__PURE__ */ jsx(
|
|
2287
|
+
"canvas",
|
|
2288
|
+
{
|
|
2289
|
+
ref: canvasRef,
|
|
2290
|
+
width: 400,
|
|
2291
|
+
height: 150,
|
|
2292
|
+
className: "w-full h-full block",
|
|
2293
|
+
onMouseDown: startDrawing,
|
|
2294
|
+
onMouseMove: draw,
|
|
2295
|
+
onMouseUp: stopDrawing,
|
|
2296
|
+
onMouseOut: stopDrawing,
|
|
2297
|
+
onTouchStart: (e) => {
|
|
2298
|
+
if (e.target === canvasRef.current) e.preventDefault();
|
|
2299
|
+
startDrawing(e);
|
|
2300
|
+
},
|
|
2301
|
+
onTouchMove: (e) => {
|
|
2302
|
+
if (e.target === canvasRef.current) e.preventDefault();
|
|
2303
|
+
draw(e);
|
|
2304
|
+
},
|
|
2305
|
+
onTouchEnd: stopDrawing
|
|
2306
|
+
}
|
|
2307
|
+
),
|
|
2308
|
+
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 left-4 text-xs text-fg-subtle border-t border-line-strong w-[calc(100%-2rem)] pt-1", children: "X" })
|
|
2309
|
+
]
|
|
2310
|
+
}
|
|
2311
|
+
),
|
|
2312
|
+
/* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(
|
|
2313
|
+
"button",
|
|
2314
|
+
{
|
|
2315
|
+
type: "button",
|
|
2316
|
+
onClick: clearSignature,
|
|
2317
|
+
disabled: disabled || !hasSignature,
|
|
2318
|
+
className: "text-xs font-medium text-primary hover:text-primary-hover disabled:opacity-50 disabled:cursor-not-allowed focus:outline-none",
|
|
2319
|
+
children: "Clear signature"
|
|
2320
|
+
}
|
|
2321
|
+
) })
|
|
2322
|
+
]
|
|
2323
|
+
}
|
|
2324
|
+
);
|
|
2325
|
+
}
|
|
2326
|
+
);
|
|
2327
|
+
SignatureInput.displayName = "SignatureInput";
|
|
2328
|
+
var stack = defineVariants({
|
|
2329
|
+
base: "flex",
|
|
2330
|
+
variants: {
|
|
2331
|
+
direction: {
|
|
2332
|
+
column: "flex-col",
|
|
2333
|
+
row: "flex-row"
|
|
2334
|
+
},
|
|
2335
|
+
gap: {
|
|
2336
|
+
none: "gap-0",
|
|
2337
|
+
xs: "gap-1",
|
|
2338
|
+
sm: "gap-2",
|
|
2339
|
+
md: "gap-4",
|
|
2340
|
+
lg: "gap-6",
|
|
2341
|
+
xl: "gap-10"
|
|
2342
|
+
},
|
|
2343
|
+
align: {
|
|
2344
|
+
stretch: "items-stretch",
|
|
2345
|
+
start: "items-start",
|
|
2346
|
+
center: "items-center",
|
|
2347
|
+
end: "items-end"
|
|
2348
|
+
},
|
|
2349
|
+
wrap: { true: "flex-wrap", false: "" }
|
|
2350
|
+
},
|
|
2351
|
+
defaultVariants: { direction: "column", gap: "md", align: "stretch", wrap: false }
|
|
2352
|
+
});
|
|
2353
|
+
function Stack(props) {
|
|
2354
|
+
const { as, direction, gap, align, wrap, className, ...rest } = props;
|
|
2355
|
+
const Component = as ?? "div";
|
|
2356
|
+
return /* @__PURE__ */ jsx(Component, { className: stack({ direction, gap, align, wrap, className }), ...rest });
|
|
2357
|
+
}
|
|
2358
|
+
var flex = defineVariants({
|
|
2359
|
+
base: "flex",
|
|
2360
|
+
variants: {
|
|
2361
|
+
align: {
|
|
2362
|
+
stretch: "items-stretch",
|
|
2363
|
+
start: "items-start",
|
|
2364
|
+
center: "items-center",
|
|
2365
|
+
end: "items-end",
|
|
2366
|
+
baseline: "items-baseline"
|
|
2367
|
+
},
|
|
2368
|
+
justify: {
|
|
2369
|
+
start: "justify-start",
|
|
2370
|
+
center: "justify-center",
|
|
2371
|
+
end: "justify-end",
|
|
2372
|
+
between: "justify-between",
|
|
2373
|
+
around: "justify-around"
|
|
2374
|
+
},
|
|
2375
|
+
gap: {
|
|
2376
|
+
none: "gap-0",
|
|
2377
|
+
xs: "gap-1",
|
|
2378
|
+
sm: "gap-2",
|
|
2379
|
+
md: "gap-4",
|
|
2380
|
+
lg: "gap-6",
|
|
2381
|
+
xl: "gap-10"
|
|
2382
|
+
},
|
|
2383
|
+
wrap: { true: "flex-wrap", false: "" }
|
|
2384
|
+
},
|
|
2385
|
+
defaultVariants: { align: "center", justify: "start", gap: "sm", wrap: false }
|
|
2386
|
+
});
|
|
2387
|
+
function Flex(props) {
|
|
2388
|
+
const { as, align, justify, gap, wrap, className, ...rest } = props;
|
|
2389
|
+
const Component = as ?? "div";
|
|
2390
|
+
return /* @__PURE__ */ jsx(Component, { className: flex({ align, justify, gap, wrap, className }), ...rest });
|
|
2391
|
+
}
|
|
2392
|
+
var grid = defineVariants({
|
|
2393
|
+
base: "grid",
|
|
2394
|
+
variants: {
|
|
2395
|
+
gap: {
|
|
2396
|
+
none: "gap-0",
|
|
2397
|
+
xs: "gap-1",
|
|
2398
|
+
sm: "gap-2",
|
|
2399
|
+
md: "gap-4",
|
|
2400
|
+
lg: "gap-6",
|
|
2401
|
+
xl: "gap-10"
|
|
2402
|
+
}
|
|
2403
|
+
},
|
|
2404
|
+
defaultVariants: { gap: "md" }
|
|
2405
|
+
});
|
|
2406
|
+
function Grid(props) {
|
|
2407
|
+
const { as, columns = 2, gap, className, style, ...rest } = props;
|
|
2408
|
+
const Component = as ?? "div";
|
|
2409
|
+
const gridTemplateColumns = typeof columns === "number" ? `repeat(${String(columns)}, minmax(0, 1fr))` : `repeat(auto-fit, minmax(min(${columns.min}, 100%), 1fr))`;
|
|
2410
|
+
return /* @__PURE__ */ jsx(
|
|
2411
|
+
Component,
|
|
2412
|
+
{
|
|
2413
|
+
className: grid({ gap, className }),
|
|
2414
|
+
style: { gridTemplateColumns, ...style },
|
|
2415
|
+
...rest
|
|
2416
|
+
}
|
|
2417
|
+
);
|
|
2418
|
+
}
|
|
2419
|
+
var container = defineVariants({
|
|
2420
|
+
base: "mx-auto w-full px-4 sm:px-6",
|
|
2421
|
+
variants: {
|
|
2422
|
+
size: {
|
|
2423
|
+
sm: "max-w-screen-sm",
|
|
2424
|
+
md: "max-w-screen-md",
|
|
2425
|
+
lg: "max-w-screen-lg",
|
|
2426
|
+
xl: "max-w-screen-xl",
|
|
2427
|
+
/** Edge-to-edge with side padding only. */
|
|
2428
|
+
full: "max-w-none"
|
|
2429
|
+
}
|
|
2430
|
+
},
|
|
2431
|
+
defaultVariants: { size: "xl" }
|
|
2432
|
+
});
|
|
2433
|
+
function Container(props) {
|
|
2434
|
+
const { as, size, className, ...rest } = props;
|
|
2435
|
+
const Component = as ?? "div";
|
|
2436
|
+
return /* @__PURE__ */ jsx(Component, { className: container({ size, className }), ...rest });
|
|
2437
|
+
}
|
|
2438
|
+
var panel = defineVariants({
|
|
2439
|
+
base: "rounded-lg border border-line bg-surface",
|
|
2440
|
+
variants: {
|
|
2441
|
+
padding: {
|
|
2442
|
+
none: "p-0",
|
|
2443
|
+
sm: "p-3",
|
|
2444
|
+
md: "p-4",
|
|
2445
|
+
lg: "p-6"
|
|
2446
|
+
},
|
|
2447
|
+
elevation: {
|
|
2448
|
+
flat: "",
|
|
2449
|
+
raised: "shadow-raised",
|
|
2450
|
+
overlay: "shadow-overlay"
|
|
2451
|
+
}
|
|
2452
|
+
},
|
|
2453
|
+
defaultVariants: { padding: "md", elevation: "raised" }
|
|
2454
|
+
});
|
|
2455
|
+
function Panel(props) {
|
|
2456
|
+
const { as, padding, elevation, className, ...rest } = props;
|
|
2457
|
+
const Component = as ?? "div";
|
|
2458
|
+
return /* @__PURE__ */ jsx(Component, { className: panel({ padding, elevation, className }), ...rest });
|
|
2459
|
+
}
|
|
2460
|
+
function Divider({ orientation = "horizontal", label, className, ...rest }) {
|
|
2461
|
+
if (orientation === "vertical") {
|
|
2462
|
+
return /* @__PURE__ */ jsx(
|
|
2463
|
+
"div",
|
|
2464
|
+
{
|
|
2465
|
+
role: "separator",
|
|
2466
|
+
"aria-orientation": "vertical",
|
|
2467
|
+
className: cn("h-full w-px self-stretch bg-line", className),
|
|
2468
|
+
...rest
|
|
2469
|
+
}
|
|
2470
|
+
);
|
|
2471
|
+
}
|
|
2472
|
+
if (label !== void 0) {
|
|
2473
|
+
return /* @__PURE__ */ jsxs("div", { role: "separator", className: cn("flex items-center gap-3", className), ...rest, children: [
|
|
2474
|
+
/* @__PURE__ */ jsx("span", { className: "h-px flex-1 bg-line" }),
|
|
2475
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-fg-subtle", children: label }),
|
|
2476
|
+
/* @__PURE__ */ jsx("span", { className: "h-px flex-1 bg-line" })
|
|
2477
|
+
] });
|
|
2478
|
+
}
|
|
2479
|
+
return /* @__PURE__ */ jsx("div", { role: "separator", className: cn("h-px w-full bg-line", className), ...rest });
|
|
2480
|
+
}
|
|
2481
|
+
var PageHeader = forwardRef(function PageHeader2({ title, description, actions, breadcrumbs, className, ...props }, ref) {
|
|
2482
|
+
return /* @__PURE__ */ jsxs(
|
|
2483
|
+
"header",
|
|
2484
|
+
{
|
|
2485
|
+
ref,
|
|
2486
|
+
className: cn("flex flex-col gap-4 pb-6 pt-4", className),
|
|
2487
|
+
...props,
|
|
2488
|
+
children: [
|
|
2489
|
+
breadcrumbs && /* @__PURE__ */ jsx("div", { className: "mb-2", children: breadcrumbs }),
|
|
2490
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center justify-between gap-4", children: [
|
|
2491
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
2492
|
+
/* @__PURE__ */ jsx("h1", { className: "text-2xl font-bold tracking-tight text-fg", children: title }),
|
|
2493
|
+
description && /* @__PURE__ */ jsx("p", { className: "text-sm text-fg-muted", children: description })
|
|
2494
|
+
] }),
|
|
2495
|
+
actions && /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: actions })
|
|
2496
|
+
] })
|
|
2497
|
+
]
|
|
2498
|
+
}
|
|
2499
|
+
);
|
|
2500
|
+
});
|
|
2501
|
+
function Tabs({
|
|
2502
|
+
tabs,
|
|
2503
|
+
value,
|
|
2504
|
+
defaultValue,
|
|
2505
|
+
onChange,
|
|
2506
|
+
renderPanel,
|
|
2507
|
+
className,
|
|
2508
|
+
...rest
|
|
2509
|
+
}) {
|
|
2510
|
+
const firstEnabled = tabs.find((t) => t.disabled !== true)?.key;
|
|
2511
|
+
const [active, setActive] = useControllableState({
|
|
2512
|
+
value,
|
|
2513
|
+
defaultValue: defaultValue ?? firstEnabled,
|
|
2514
|
+
onChange
|
|
2515
|
+
});
|
|
2516
|
+
const refs = useRef(/* @__PURE__ */ new Map());
|
|
2517
|
+
const enabled = tabs.filter((t) => t.disabled !== true);
|
|
2518
|
+
const onKeyDown = (event, key) => {
|
|
2519
|
+
const index = enabled.findIndex((t) => t.key === key);
|
|
2520
|
+
if (index === -1) return;
|
|
2521
|
+
let next;
|
|
2522
|
+
if (event.key === "ArrowRight") next = enabled[(index + 1) % enabled.length]?.key;
|
|
2523
|
+
else if (event.key === "ArrowLeft") next = enabled[(index - 1 + enabled.length) % enabled.length]?.key;
|
|
2524
|
+
else if (event.key === "Home") next = enabled[0]?.key;
|
|
2525
|
+
else if (event.key === "End") next = enabled[enabled.length - 1]?.key;
|
|
2526
|
+
if (next !== void 0) {
|
|
2527
|
+
event.preventDefault();
|
|
2528
|
+
setActive(next);
|
|
2529
|
+
refs.current.get(next)?.focus();
|
|
2530
|
+
}
|
|
2531
|
+
};
|
|
2532
|
+
return /* @__PURE__ */ jsxs("div", { className, children: [
|
|
2533
|
+
/* @__PURE__ */ jsx("div", { role: "tablist", className: "flex items-stretch gap-1 overflow-x-auto overflow-y-hidden border-b border-line", ...rest, children: tabs.map((tab) => {
|
|
2534
|
+
const selected = active === tab.key;
|
|
2535
|
+
return /* @__PURE__ */ jsxs(
|
|
2536
|
+
"button",
|
|
2537
|
+
{
|
|
2538
|
+
ref: (el) => {
|
|
2539
|
+
if (el) refs.current.set(tab.key, el);
|
|
2540
|
+
else refs.current.delete(tab.key);
|
|
2541
|
+
},
|
|
2542
|
+
role: "tab",
|
|
2543
|
+
type: "button",
|
|
2544
|
+
"aria-selected": selected,
|
|
2545
|
+
"aria-controls": renderPanel ? `panel-${tab.key}` : void 0,
|
|
2546
|
+
tabIndex: selected ? 0 : -1,
|
|
2547
|
+
disabled: tab.disabled,
|
|
2548
|
+
onClick: () => {
|
|
2549
|
+
setActive(tab.key);
|
|
2550
|
+
},
|
|
2551
|
+
onKeyDown: (e) => {
|
|
2552
|
+
onKeyDown(e, tab.key);
|
|
2553
|
+
},
|
|
2554
|
+
className: cn(
|
|
2555
|
+
"focus-ring -mb-px inline-flex items-center gap-2 whitespace-nowrap border-b-2 px-3.5 py-2.5 text-sm font-semibold",
|
|
2556
|
+
"transition-colors duration-(--ml-duration-fast)",
|
|
2557
|
+
"disabled:cursor-not-allowed disabled:text-fg-disabled",
|
|
2558
|
+
selected ? "border-primary text-primary-subtle-fg" : "border-transparent text-fg-muted hover:text-fg"
|
|
2559
|
+
),
|
|
2560
|
+
children: [
|
|
2561
|
+
tab.icon && /* @__PURE__ */ jsx("span", { className: "[&_svg]:size-(--size-icon-sm)", children: tab.icon }),
|
|
2562
|
+
tab.label,
|
|
2563
|
+
tab.badge
|
|
2564
|
+
]
|
|
2565
|
+
},
|
|
2566
|
+
tab.key
|
|
2567
|
+
);
|
|
2568
|
+
}) }),
|
|
2569
|
+
renderPanel && active !== void 0 && /* @__PURE__ */ jsx("div", { role: "tabpanel", id: `panel-${active}`, tabIndex: 0, className: "focus-ring pt-4", children: renderPanel(active) })
|
|
2570
|
+
] });
|
|
2571
|
+
}
|
|
2572
|
+
function Breadcrumbs({
|
|
2573
|
+
items,
|
|
2574
|
+
linkComponent: LinkComponent = "a",
|
|
2575
|
+
separator = "/",
|
|
2576
|
+
className
|
|
2577
|
+
}) {
|
|
2578
|
+
return /* @__PURE__ */ jsx("nav", { "aria-label": "Breadcrumb", className, children: /* @__PURE__ */ jsx("ol", { className: "m-0 flex list-none flex-wrap items-center gap-1.5 p-0 text-sm", children: items.map((item, index) => {
|
|
2579
|
+
const isLast = index === items.length - 1;
|
|
2580
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
2581
|
+
index > 0 && /* @__PURE__ */ jsx("li", { "aria-hidden": true, className: "text-fg-subtle", children: separator }),
|
|
2582
|
+
/* @__PURE__ */ jsx("li", { className: cn("min-w-0", isLast && "truncate"), children: item.href !== void 0 && !isLast ? /* @__PURE__ */ jsx(
|
|
2583
|
+
LinkComponent,
|
|
2584
|
+
{
|
|
2585
|
+
href: item.href,
|
|
2586
|
+
className: "focus-ring rounded-xs font-medium text-fg-muted no-underline hover:text-fg hover:underline",
|
|
2587
|
+
children: item.label
|
|
2588
|
+
}
|
|
2589
|
+
) : /* @__PURE__ */ jsx("span", { "aria-current": isLast ? "page" : void 0, className: "font-semibold text-fg", children: item.label }) })
|
|
2590
|
+
] }, index);
|
|
2591
|
+
}) }) });
|
|
2592
|
+
}
|
|
2593
|
+
function Pagination({ page, pageCount, onPageChange, siblingCount = 1, className }) {
|
|
2594
|
+
if (pageCount <= 1) return null;
|
|
2595
|
+
const items = pageRange(page, pageCount, siblingCount);
|
|
2596
|
+
const pageButton = (target) => {
|
|
2597
|
+
const isCurrent = target === page;
|
|
2598
|
+
return /* @__PURE__ */ jsx(
|
|
2599
|
+
"button",
|
|
2600
|
+
{
|
|
2601
|
+
type: "button",
|
|
2602
|
+
"aria-current": isCurrent ? "page" : void 0,
|
|
2603
|
+
"aria-label": `Page ${String(target)}`,
|
|
2604
|
+
onClick: () => {
|
|
2605
|
+
if (!isCurrent) onPageChange(target);
|
|
2606
|
+
},
|
|
2607
|
+
className: cn(
|
|
2608
|
+
"focus-ring inline-flex h-(--ml-control-h-sm) min-w-(--ml-control-h-sm) items-center justify-center rounded-md px-2 text-sm font-semibold tabular-nums",
|
|
2609
|
+
"transition-colors duration-(--ml-duration-fast)",
|
|
2610
|
+
isCurrent ? "bg-primary text-primary-fg" : "text-fg-muted hover:bg-surface-sunken hover:text-fg"
|
|
2611
|
+
),
|
|
2612
|
+
children: target
|
|
2613
|
+
},
|
|
2614
|
+
target
|
|
2615
|
+
);
|
|
2616
|
+
};
|
|
2617
|
+
return /* @__PURE__ */ jsxs("nav", { "aria-label": "Pagination", className: cn("flex items-center gap-1", className), children: [
|
|
2618
|
+
/* @__PURE__ */ jsx(
|
|
2619
|
+
ArrowButton,
|
|
2620
|
+
{
|
|
2621
|
+
label: "Previous page",
|
|
2622
|
+
disabled: page <= 1,
|
|
2623
|
+
onClick: () => {
|
|
2624
|
+
onPageChange(page - 1);
|
|
2625
|
+
},
|
|
2626
|
+
direction: "left"
|
|
2627
|
+
}
|
|
2628
|
+
),
|
|
2629
|
+
items.map(
|
|
2630
|
+
(item, index) => item === PAGE_ELLIPSIS ? /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "px-1 text-fg-subtle", children: "\u2026" }, `e-${String(index)}`) : pageButton(item)
|
|
2631
|
+
),
|
|
2632
|
+
/* @__PURE__ */ jsx(
|
|
2633
|
+
ArrowButton,
|
|
2634
|
+
{
|
|
2635
|
+
label: "Next page",
|
|
2636
|
+
disabled: page >= pageCount,
|
|
2637
|
+
onClick: () => {
|
|
2638
|
+
onPageChange(page + 1);
|
|
2639
|
+
},
|
|
2640
|
+
direction: "right"
|
|
2641
|
+
}
|
|
2642
|
+
)
|
|
2643
|
+
] });
|
|
2644
|
+
}
|
|
2645
|
+
function ArrowButton({
|
|
2646
|
+
label,
|
|
2647
|
+
disabled,
|
|
2648
|
+
onClick,
|
|
2649
|
+
direction
|
|
2650
|
+
}) {
|
|
2651
|
+
return /* @__PURE__ */ jsx(
|
|
2652
|
+
"button",
|
|
2653
|
+
{
|
|
2654
|
+
type: "button",
|
|
2655
|
+
"aria-label": label,
|
|
2656
|
+
disabled,
|
|
2657
|
+
onClick,
|
|
2658
|
+
className: cn(
|
|
2659
|
+
"focus-ring inline-flex h-(--ml-control-h-sm) w-(--ml-control-h-sm) items-center justify-center rounded-md text-fg-muted",
|
|
2660
|
+
"transition-colors duration-(--ml-duration-fast) hover:bg-surface-sunken hover:text-fg",
|
|
2661
|
+
"disabled:cursor-not-allowed disabled:text-fg-disabled disabled:hover:bg-transparent"
|
|
2662
|
+
),
|
|
2663
|
+
children: /* @__PURE__ */ jsx(
|
|
2664
|
+
"svg",
|
|
2665
|
+
{
|
|
2666
|
+
"aria-hidden": true,
|
|
2667
|
+
viewBox: "0 0 24 24",
|
|
2668
|
+
fill: "none",
|
|
2669
|
+
stroke: "currentColor",
|
|
2670
|
+
strokeWidth: "2",
|
|
2671
|
+
strokeLinecap: "round",
|
|
2672
|
+
strokeLinejoin: "round",
|
|
2673
|
+
className: cn("size-4", direction === "left" && "rotate-180"),
|
|
2674
|
+
children: /* @__PURE__ */ jsx("polyline", { points: "9 18 15 12 9 6" })
|
|
2675
|
+
}
|
|
2676
|
+
)
|
|
2677
|
+
}
|
|
2678
|
+
);
|
|
2679
|
+
}
|
|
2680
|
+
var DropdownMenu = DropdownMenuPrimitive.Root;
|
|
2681
|
+
var DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
|
|
2682
|
+
var DropdownMenuGroup = DropdownMenuPrimitive.Group;
|
|
2683
|
+
var DropdownMenuPortal = DropdownMenuPrimitive.Portal;
|
|
2684
|
+
var DropdownMenuSub = DropdownMenuPrimitive.Sub;
|
|
2685
|
+
var DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
|
|
2686
|
+
var DropdownMenuSubTrigger = forwardRef(({ className, inset, children, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
2687
|
+
DropdownMenuPrimitive.SubTrigger,
|
|
2688
|
+
{
|
|
2689
|
+
ref,
|
|
2690
|
+
className: cn(
|
|
2691
|
+
"flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-surface-sunken data-[state=open]:bg-surface-sunken",
|
|
2692
|
+
inset && "pl-8",
|
|
2693
|
+
className
|
|
2694
|
+
),
|
|
2695
|
+
...props,
|
|
2696
|
+
children: [
|
|
2697
|
+
children,
|
|
2698
|
+
/* @__PURE__ */ jsx(
|
|
2699
|
+
"svg",
|
|
2700
|
+
{
|
|
2701
|
+
className: "ml-auto h-4 w-4",
|
|
2702
|
+
fill: "none",
|
|
2703
|
+
stroke: "currentColor",
|
|
2704
|
+
viewBox: "0 0 24 24",
|
|
2705
|
+
strokeWidth: 2,
|
|
2706
|
+
children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M9 5l7 7-7 7" })
|
|
2707
|
+
}
|
|
2708
|
+
)
|
|
2709
|
+
]
|
|
2710
|
+
}
|
|
2711
|
+
));
|
|
2712
|
+
DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName;
|
|
2713
|
+
var DropdownMenuSubContent = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2714
|
+
DropdownMenuPrimitive.SubContent,
|
|
2715
|
+
{
|
|
2716
|
+
ref,
|
|
2717
|
+
className: cn(
|
|
2718
|
+
"z-(--ml-z-popover) min-w-[8rem] overflow-hidden rounded-md border border-line bg-surface p-1 text-fg shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
2719
|
+
className
|
|
2720
|
+
),
|
|
2721
|
+
...props
|
|
2722
|
+
}
|
|
2723
|
+
));
|
|
2724
|
+
DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName;
|
|
2725
|
+
var DropdownMenuContent = forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(DropdownMenuPrimitive.Portal, { children: /* @__PURE__ */ jsx(
|
|
2726
|
+
DropdownMenuPrimitive.Content,
|
|
2727
|
+
{
|
|
2728
|
+
ref,
|
|
2729
|
+
sideOffset,
|
|
2730
|
+
className: cn(
|
|
2731
|
+
"z-(--ml-z-popover) min-w-[8rem] overflow-hidden rounded-md border border-line bg-surface p-1 text-fg shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
2732
|
+
className
|
|
2733
|
+
),
|
|
2734
|
+
...props
|
|
2735
|
+
}
|
|
2736
|
+
) }));
|
|
2737
|
+
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
|
|
2738
|
+
var DropdownMenuItem = forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2739
|
+
DropdownMenuPrimitive.Item,
|
|
2740
|
+
{
|
|
2741
|
+
ref,
|
|
2742
|
+
className: cn(
|
|
2743
|
+
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-surface-sunken focus:text-fg data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
2744
|
+
inset && "pl-8",
|
|
2745
|
+
className
|
|
2746
|
+
),
|
|
2747
|
+
...props
|
|
2748
|
+
}
|
|
2749
|
+
));
|
|
2750
|
+
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
|
|
2751
|
+
var DropdownMenuCheckboxItem = forwardRef(({ className, children, checked, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
2752
|
+
DropdownMenuPrimitive.CheckboxItem,
|
|
2753
|
+
{
|
|
2754
|
+
ref,
|
|
2755
|
+
className: cn(
|
|
2756
|
+
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-surface-sunken focus:text-fg data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
2757
|
+
className
|
|
2758
|
+
),
|
|
2759
|
+
checked,
|
|
2760
|
+
...props,
|
|
2761
|
+
children: [
|
|
2762
|
+
/* @__PURE__ */ jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx(DropdownMenuPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(
|
|
2763
|
+
"svg",
|
|
2764
|
+
{
|
|
2765
|
+
width: "15",
|
|
2766
|
+
height: "15",
|
|
2767
|
+
viewBox: "0 0 15 15",
|
|
2768
|
+
fill: "none",
|
|
2769
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2770
|
+
className: "h-4 w-4 fill-current",
|
|
2771
|
+
children: /* @__PURE__ */ jsx(
|
|
2772
|
+
"path",
|
|
2773
|
+
{
|
|
2774
|
+
d: "M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z",
|
|
2775
|
+
fill: "currentColor",
|
|
2776
|
+
fillRule: "evenodd",
|
|
2777
|
+
clipRule: "evenodd"
|
|
2778
|
+
}
|
|
2779
|
+
)
|
|
2780
|
+
}
|
|
2781
|
+
) }) }),
|
|
2782
|
+
children
|
|
2783
|
+
]
|
|
2784
|
+
}
|
|
2785
|
+
));
|
|
2786
|
+
DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName;
|
|
2787
|
+
var DropdownMenuRadioItem = forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
2788
|
+
DropdownMenuPrimitive.RadioItem,
|
|
2789
|
+
{
|
|
2790
|
+
ref,
|
|
2791
|
+
className: cn(
|
|
2792
|
+
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-surface-sunken focus:text-fg data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
2793
|
+
className
|
|
2794
|
+
),
|
|
2795
|
+
...props,
|
|
2796
|
+
children: [
|
|
2797
|
+
/* @__PURE__ */ jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx(DropdownMenuPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx("div", { className: "h-2 w-2 rounded-full bg-current" }) }) }),
|
|
2798
|
+
children
|
|
2799
|
+
]
|
|
2800
|
+
}
|
|
2801
|
+
));
|
|
2802
|
+
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
|
|
2803
|
+
var DropdownMenuLabel = forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2804
|
+
DropdownMenuPrimitive.Label,
|
|
2805
|
+
{
|
|
2806
|
+
ref,
|
|
2807
|
+
className: cn(
|
|
2808
|
+
"px-2 py-1.5 text-sm font-semibold text-fg",
|
|
2809
|
+
inset && "pl-8",
|
|
2810
|
+
className
|
|
2811
|
+
),
|
|
2812
|
+
...props
|
|
2813
|
+
}
|
|
2814
|
+
));
|
|
2815
|
+
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
|
|
2816
|
+
var DropdownMenuSeparator = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2817
|
+
DropdownMenuPrimitive.Separator,
|
|
2818
|
+
{
|
|
2819
|
+
ref,
|
|
2820
|
+
className: cn("-mx-1 my-1 h-px bg-line", className),
|
|
2821
|
+
...props
|
|
2822
|
+
}
|
|
2823
|
+
));
|
|
2824
|
+
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
|
|
2825
|
+
var DropdownMenuShortcut = ({
|
|
2826
|
+
className,
|
|
2827
|
+
...props
|
|
2828
|
+
}) => {
|
|
2829
|
+
return /* @__PURE__ */ jsx(
|
|
2830
|
+
"span",
|
|
2831
|
+
{
|
|
2832
|
+
className: cn("ml-auto text-xs tracking-widest text-fg-muted", className),
|
|
2833
|
+
...props
|
|
2834
|
+
}
|
|
2835
|
+
);
|
|
2836
|
+
};
|
|
2837
|
+
DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
|
|
2838
|
+
var Accordion = AccordionPrimitive.Root;
|
|
2839
|
+
var AccordionItem = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2840
|
+
AccordionPrimitive.Item,
|
|
2841
|
+
{
|
|
2842
|
+
ref,
|
|
2843
|
+
className: cn("border-b border-line", className),
|
|
2844
|
+
...props
|
|
2845
|
+
}
|
|
2846
|
+
));
|
|
2847
|
+
AccordionItem.displayName = "AccordionItem";
|
|
2848
|
+
var AccordionTrigger = forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsx(AccordionPrimitive.Header, { className: "flex", children: /* @__PURE__ */ jsxs(
|
|
2849
|
+
AccordionPrimitive.Trigger,
|
|
2850
|
+
{
|
|
2851
|
+
ref,
|
|
2852
|
+
className: cn(
|
|
2853
|
+
"flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline focus-ring [&[data-state=open]>svg]:rotate-180",
|
|
2854
|
+
className
|
|
2855
|
+
),
|
|
2856
|
+
...props,
|
|
2857
|
+
children: [
|
|
2858
|
+
children,
|
|
2859
|
+
/* @__PURE__ */ jsx(
|
|
2860
|
+
"svg",
|
|
2861
|
+
{
|
|
2862
|
+
width: "16",
|
|
2863
|
+
height: "16",
|
|
2864
|
+
viewBox: "0 0 24 24",
|
|
2865
|
+
fill: "none",
|
|
2866
|
+
stroke: "currentColor",
|
|
2867
|
+
strokeWidth: "2",
|
|
2868
|
+
strokeLinecap: "round",
|
|
2869
|
+
strokeLinejoin: "round",
|
|
2870
|
+
className: "h-4 w-4 shrink-0 transition-transform duration-200",
|
|
2871
|
+
"aria-hidden": true,
|
|
2872
|
+
children: /* @__PURE__ */ jsx("polyline", { points: "6 9 12 15 18 9" })
|
|
2873
|
+
}
|
|
2874
|
+
)
|
|
2875
|
+
]
|
|
2876
|
+
}
|
|
2877
|
+
) }));
|
|
2878
|
+
AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName;
|
|
2879
|
+
var AccordionContent = forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2880
|
+
AccordionPrimitive.Content,
|
|
2881
|
+
{
|
|
2882
|
+
ref,
|
|
2883
|
+
className: "overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",
|
|
2884
|
+
...props,
|
|
2885
|
+
children: /* @__PURE__ */ jsx("div", { className: cn("pb-4 pt-0", className), children })
|
|
2886
|
+
}
|
|
2887
|
+
));
|
|
2888
|
+
AccordionContent.displayName = AccordionPrimitive.Content.displayName;
|
|
2889
|
+
var Avatar = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2890
|
+
AvatarPrimitive.Root,
|
|
2891
|
+
{
|
|
2892
|
+
ref,
|
|
2893
|
+
className: cn(
|
|
2894
|
+
"relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",
|
|
2895
|
+
className
|
|
2896
|
+
),
|
|
2897
|
+
...props
|
|
2898
|
+
}
|
|
2899
|
+
));
|
|
2900
|
+
Avatar.displayName = AvatarPrimitive.Root.displayName;
|
|
2901
|
+
var AvatarImage = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2902
|
+
AvatarPrimitive.Image,
|
|
2903
|
+
{
|
|
2904
|
+
ref,
|
|
2905
|
+
className: cn("aspect-square h-full w-full", className),
|
|
2906
|
+
...props
|
|
2907
|
+
}
|
|
2908
|
+
));
|
|
2909
|
+
AvatarImage.displayName = AvatarPrimitive.Image.displayName;
|
|
2910
|
+
var AvatarFallback = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2911
|
+
AvatarPrimitive.Fallback,
|
|
2912
|
+
{
|
|
2913
|
+
ref,
|
|
2914
|
+
className: cn(
|
|
2915
|
+
"flex h-full w-full items-center justify-center rounded-full bg-surface-sunken text-fg-muted",
|
|
2916
|
+
className
|
|
2917
|
+
),
|
|
2918
|
+
...props
|
|
2919
|
+
}
|
|
2920
|
+
));
|
|
2921
|
+
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
|
|
2922
|
+
var Card = forwardRef(
|
|
2923
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2924
|
+
"div",
|
|
2925
|
+
{
|
|
2926
|
+
ref,
|
|
2927
|
+
className: cn(
|
|
2928
|
+
"rounded-xl border border-line bg-surface text-fg shadow-sm",
|
|
2929
|
+
className
|
|
2930
|
+
),
|
|
2931
|
+
...props
|
|
2932
|
+
}
|
|
2933
|
+
)
|
|
2934
|
+
);
|
|
2935
|
+
Card.displayName = "Card";
|
|
2936
|
+
var CardHeader = forwardRef(
|
|
2937
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2938
|
+
"div",
|
|
2939
|
+
{
|
|
2940
|
+
ref,
|
|
2941
|
+
className: cn("flex flex-col space-y-1.5 p-6", className),
|
|
2942
|
+
...props
|
|
2943
|
+
}
|
|
2944
|
+
)
|
|
2945
|
+
);
|
|
2946
|
+
CardHeader.displayName = "CardHeader";
|
|
2947
|
+
var CardTitle = forwardRef(
|
|
2948
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2949
|
+
"h3",
|
|
2950
|
+
{
|
|
2951
|
+
ref,
|
|
2952
|
+
className: cn(
|
|
2953
|
+
"font-semibold leading-none tracking-tight text-fg",
|
|
2954
|
+
className
|
|
2955
|
+
),
|
|
2956
|
+
...props
|
|
2957
|
+
}
|
|
2958
|
+
)
|
|
2959
|
+
);
|
|
2960
|
+
CardTitle.displayName = "CardTitle";
|
|
2961
|
+
var CardDescription = forwardRef(
|
|
2962
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2963
|
+
"p",
|
|
2964
|
+
{
|
|
2965
|
+
ref,
|
|
2966
|
+
className: cn("text-sm text-fg-muted", className),
|
|
2967
|
+
...props
|
|
2968
|
+
}
|
|
2969
|
+
)
|
|
2970
|
+
);
|
|
2971
|
+
CardDescription.displayName = "CardDescription";
|
|
2972
|
+
var CardContent = forwardRef(
|
|
2973
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("p-6 pt-0", className), ...props })
|
|
2974
|
+
);
|
|
2975
|
+
CardContent.displayName = "CardContent";
|
|
2976
|
+
var CardFooter = forwardRef(
|
|
2977
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2978
|
+
"div",
|
|
2979
|
+
{
|
|
2980
|
+
ref,
|
|
2981
|
+
className: cn("flex items-center p-6 pt-0", className),
|
|
2982
|
+
...props
|
|
2983
|
+
}
|
|
2984
|
+
)
|
|
2985
|
+
);
|
|
2986
|
+
CardFooter.displayName = "CardFooter";
|
|
2987
|
+
function DataTable({
|
|
2988
|
+
columns,
|
|
2989
|
+
data,
|
|
2990
|
+
className
|
|
2991
|
+
}) {
|
|
2992
|
+
const [sorting, setSorting] = useState([]);
|
|
2993
|
+
const table = useReactTable({
|
|
2994
|
+
data,
|
|
2995
|
+
columns,
|
|
2996
|
+
state: {
|
|
2997
|
+
sorting
|
|
2998
|
+
},
|
|
2999
|
+
onSortingChange: setSorting,
|
|
3000
|
+
getCoreRowModel: getCoreRowModel(),
|
|
3001
|
+
getSortedRowModel: getSortedRowModel()
|
|
3002
|
+
});
|
|
3003
|
+
return /* @__PURE__ */ jsx("div", { className: cn("rounded-md border border-line overflow-hidden", className), children: /* @__PURE__ */ jsxs("table", { className: "w-full caption-bottom text-sm", children: [
|
|
3004
|
+
/* @__PURE__ */ jsx("thead", { className: "[&_tr]:border-b [&_tr]:border-line bg-surface-sunken", children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx(
|
|
3005
|
+
"tr",
|
|
3006
|
+
{
|
|
3007
|
+
className: "border-b border-line transition-colors hover:bg-surface-sunken/50 data-[state=selected]:bg-surface-sunken",
|
|
3008
|
+
children: headerGroup.headers.map((header) => {
|
|
3009
|
+
return /* @__PURE__ */ jsx(
|
|
3010
|
+
"th",
|
|
3011
|
+
{
|
|
3012
|
+
className: "h-10 px-4 text-left align-middle font-medium text-fg-muted [&:has([role=checkbox])]:pr-0",
|
|
3013
|
+
children: header.isPlaceholder ? null : flexRender(
|
|
3014
|
+
header.column.columnDef.header,
|
|
3015
|
+
header.getContext()
|
|
3016
|
+
)
|
|
3017
|
+
},
|
|
3018
|
+
header.id
|
|
3019
|
+
);
|
|
3020
|
+
})
|
|
3021
|
+
},
|
|
3022
|
+
headerGroup.id
|
|
3023
|
+
)) }),
|
|
3024
|
+
/* @__PURE__ */ jsx("tbody", { className: "[&_tr:last-child]:border-0 bg-surface text-fg", children: table.getRowModel().rows.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ jsx(
|
|
3025
|
+
"tr",
|
|
3026
|
+
{
|
|
3027
|
+
"data-state": row.getIsSelected() && "selected",
|
|
3028
|
+
className: "border-b border-line transition-colors hover:bg-surface-sunken/50 data-[state=selected]:bg-surface-sunken",
|
|
3029
|
+
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx(
|
|
3030
|
+
"td",
|
|
3031
|
+
{
|
|
3032
|
+
className: "p-4 align-middle [&:has([role=checkbox])]:pr-0",
|
|
3033
|
+
children: flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
3034
|
+
},
|
|
3035
|
+
cell.id
|
|
3036
|
+
))
|
|
3037
|
+
},
|
|
3038
|
+
row.id
|
|
3039
|
+
)) : /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx(
|
|
3040
|
+
"td",
|
|
3041
|
+
{
|
|
3042
|
+
colSpan: columns.length,
|
|
3043
|
+
className: "h-24 text-center text-fg-muted",
|
|
3044
|
+
children: "No results."
|
|
3045
|
+
}
|
|
3046
|
+
) }) })
|
|
3047
|
+
] }) });
|
|
3048
|
+
}
|
|
3049
|
+
var Timeline = React5.forwardRef(
|
|
3050
|
+
({ className, children, ...props }, ref) => {
|
|
3051
|
+
return /* @__PURE__ */ jsx(
|
|
3052
|
+
"ol",
|
|
3053
|
+
{
|
|
3054
|
+
ref,
|
|
3055
|
+
className: cn("relative border-l border-line ml-3.5 space-y-6", className),
|
|
3056
|
+
...props,
|
|
3057
|
+
children
|
|
3058
|
+
}
|
|
3059
|
+
);
|
|
3060
|
+
}
|
|
3061
|
+
);
|
|
3062
|
+
Timeline.displayName = "Timeline";
|
|
3063
|
+
var TimelineItem = React5.forwardRef(
|
|
3064
|
+
({ className, children, ...props }, ref) => {
|
|
3065
|
+
return /* @__PURE__ */ jsx(
|
|
3066
|
+
"li",
|
|
3067
|
+
{
|
|
3068
|
+
ref,
|
|
3069
|
+
className: cn("relative ml-6", className),
|
|
3070
|
+
...props,
|
|
3071
|
+
children
|
|
3072
|
+
}
|
|
3073
|
+
);
|
|
3074
|
+
}
|
|
3075
|
+
);
|
|
3076
|
+
TimelineItem.displayName = "TimelineItem";
|
|
3077
|
+
var TimelineDot = React5.forwardRef(
|
|
3078
|
+
({ className, intent = "default", ...props }, ref) => {
|
|
3079
|
+
return /* @__PURE__ */ jsx(
|
|
3080
|
+
"div",
|
|
3081
|
+
{
|
|
3082
|
+
ref,
|
|
3083
|
+
className: cn(
|
|
3084
|
+
"absolute -left-[1.8125rem] mt-0.5 flex h-6 w-6 items-center justify-center rounded-full bg-surface ring-4 ring-surface",
|
|
3085
|
+
className
|
|
3086
|
+
),
|
|
3087
|
+
...props,
|
|
3088
|
+
children: /* @__PURE__ */ jsx(
|
|
3089
|
+
"div",
|
|
3090
|
+
{
|
|
3091
|
+
className: cn("h-2.5 w-2.5 rounded-full border shadow-sm", {
|
|
3092
|
+
"border-line-strong bg-surface-sunken": intent === "default",
|
|
3093
|
+
"border-primary bg-primary": intent === "primary",
|
|
3094
|
+
"border-success bg-success": intent === "success",
|
|
3095
|
+
"border-warning bg-warning": intent === "warning",
|
|
3096
|
+
"border-danger bg-danger": intent === "danger",
|
|
3097
|
+
"border-info bg-info": intent === "info"
|
|
3098
|
+
})
|
|
3099
|
+
}
|
|
3100
|
+
)
|
|
3101
|
+
}
|
|
3102
|
+
);
|
|
3103
|
+
}
|
|
3104
|
+
);
|
|
3105
|
+
TimelineDot.displayName = "TimelineDot";
|
|
3106
|
+
var TimelineContent = React5.forwardRef(
|
|
3107
|
+
({ className, ...props }, ref) => {
|
|
3108
|
+
return /* @__PURE__ */ jsx(
|
|
3109
|
+
"div",
|
|
3110
|
+
{
|
|
3111
|
+
ref,
|
|
3112
|
+
className: cn("flex flex-col space-y-1", className),
|
|
3113
|
+
...props
|
|
3114
|
+
}
|
|
3115
|
+
);
|
|
3116
|
+
}
|
|
3117
|
+
);
|
|
3118
|
+
TimelineContent.displayName = "TimelineContent";
|
|
3119
|
+
var TimelineTime = React5.forwardRef(
|
|
3120
|
+
({ className, ...props }, ref) => {
|
|
3121
|
+
return /* @__PURE__ */ jsx(
|
|
3122
|
+
"time",
|
|
3123
|
+
{
|
|
3124
|
+
ref,
|
|
3125
|
+
className: cn("text-xs font-medium tracking-wide text-fg-subtle uppercase", className),
|
|
3126
|
+
...props
|
|
3127
|
+
}
|
|
3128
|
+
);
|
|
3129
|
+
}
|
|
3130
|
+
);
|
|
3131
|
+
TimelineTime.displayName = "TimelineTime";
|
|
3132
|
+
var TimelineTitle = React5.forwardRef(
|
|
3133
|
+
({ className, ...props }, ref) => {
|
|
3134
|
+
return /* @__PURE__ */ jsx(
|
|
3135
|
+
"h3",
|
|
3136
|
+
{
|
|
3137
|
+
ref,
|
|
3138
|
+
className: cn("text-base font-medium text-fg", className),
|
|
3139
|
+
...props
|
|
3140
|
+
}
|
|
3141
|
+
);
|
|
3142
|
+
}
|
|
3143
|
+
);
|
|
3144
|
+
TimelineTitle.displayName = "TimelineTitle";
|
|
3145
|
+
var TimelineDescription = React5.forwardRef(
|
|
3146
|
+
({ className, ...props }, ref) => {
|
|
3147
|
+
return /* @__PURE__ */ jsx(
|
|
3148
|
+
"p",
|
|
3149
|
+
{
|
|
3150
|
+
ref,
|
|
3151
|
+
className: cn("text-sm text-fg-muted", className),
|
|
3152
|
+
...props
|
|
3153
|
+
}
|
|
3154
|
+
);
|
|
3155
|
+
}
|
|
3156
|
+
);
|
|
3157
|
+
TimelineDescription.displayName = "TimelineDescription";
|
|
3158
|
+
var Steps = React5.forwardRef(
|
|
3159
|
+
({ className, steps, activeStep = 0, ...props }, ref) => {
|
|
3160
|
+
return /* @__PURE__ */ jsx(
|
|
3161
|
+
"div",
|
|
3162
|
+
{
|
|
3163
|
+
ref,
|
|
3164
|
+
className: cn("flex w-full items-center", className),
|
|
3165
|
+
...props,
|
|
3166
|
+
children: steps.map((step, index) => {
|
|
3167
|
+
const isCompleted = index < activeStep;
|
|
3168
|
+
const isActive = index === activeStep;
|
|
3169
|
+
return /* @__PURE__ */ jsxs(
|
|
3170
|
+
"div",
|
|
3171
|
+
{
|
|
3172
|
+
className: cn(
|
|
3173
|
+
"relative flex flex-1 flex-col items-center text-center",
|
|
3174
|
+
index !== steps.length - 1 ? "after:absolute after:left-[50%] after:top-[9px] after:h-[2px] after:w-full after:bg-line" : "",
|
|
3175
|
+
isCompleted && index !== steps.length - 1 ? "after:bg-primary" : ""
|
|
3176
|
+
),
|
|
3177
|
+
children: [
|
|
3178
|
+
/* @__PURE__ */ jsxs(
|
|
3179
|
+
"div",
|
|
3180
|
+
{
|
|
3181
|
+
className: cn(
|
|
3182
|
+
"relative z-10 flex h-5 w-5 items-center justify-center rounded-full border-2 bg-surface transition-all duration-200",
|
|
3183
|
+
isCompleted ? "border-primary bg-primary" : isActive ? "border-primary ring-4 ring-primary/20" : "border-line-strong bg-surface-sunken"
|
|
3184
|
+
),
|
|
3185
|
+
children: [
|
|
3186
|
+
isActive && /* @__PURE__ */ jsx("div", { className: "h-2 w-2 rounded-full bg-primary" }),
|
|
3187
|
+
isCompleted && /* @__PURE__ */ jsx("svg", { className: "h-3 w-3 text-primary-fg", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 3, children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M5 13l4 4L19 7" }) })
|
|
3188
|
+
]
|
|
3189
|
+
}
|
|
3190
|
+
),
|
|
3191
|
+
/* @__PURE__ */ jsxs("div", { className: "mt-3 flex flex-col items-center", children: [
|
|
3192
|
+
/* @__PURE__ */ jsx("span", { className: cn("text-sm font-semibold", isActive || isCompleted ? "text-fg" : "text-fg-muted"), children: step.label }),
|
|
3193
|
+
step.description && /* @__PURE__ */ jsx("span", { className: "text-xs text-fg-subtle mt-0.5", children: step.description })
|
|
3194
|
+
] })
|
|
3195
|
+
]
|
|
3196
|
+
},
|
|
3197
|
+
index
|
|
3198
|
+
);
|
|
3199
|
+
})
|
|
3200
|
+
}
|
|
3201
|
+
);
|
|
3202
|
+
}
|
|
3203
|
+
);
|
|
3204
|
+
Steps.displayName = "Steps";
|
|
3205
|
+
var StatCard = React5.forwardRef(
|
|
3206
|
+
({ className, title, value, trend, icon, ...props }, ref) => {
|
|
3207
|
+
return /* @__PURE__ */ jsxs(Card, { ref, className: cn("p-6", className), ...props, children: [
|
|
3208
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
3209
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-fg-muted", children: title }),
|
|
3210
|
+
icon && /* @__PURE__ */ jsx("div", { className: "text-fg-subtle [&_svg]:h-4 [&_svg]:w-4", children: icon })
|
|
3211
|
+
] }),
|
|
3212
|
+
/* @__PURE__ */ jsxs("div", { className: "mt-2 flex items-baseline gap-2", children: [
|
|
3213
|
+
/* @__PURE__ */ jsx("h2", { className: "text-3xl font-bold tracking-tight text-fg", children: value }),
|
|
3214
|
+
trend && /* @__PURE__ */ jsxs(
|
|
3215
|
+
"span",
|
|
3216
|
+
{
|
|
3217
|
+
className: cn(
|
|
3218
|
+
"inline-flex items-center text-sm font-medium",
|
|
3219
|
+
trend.isPositive === true ? "text-success" : trend.isPositive === false ? "text-danger" : "text-fg-muted"
|
|
3220
|
+
),
|
|
3221
|
+
children: [
|
|
3222
|
+
trend.isPositive === true && /* @__PURE__ */ jsx(
|
|
3223
|
+
"svg",
|
|
3224
|
+
{
|
|
3225
|
+
className: "mr-1 h-3 w-3",
|
|
3226
|
+
fill: "none",
|
|
3227
|
+
viewBox: "0 0 24 24",
|
|
3228
|
+
stroke: "currentColor",
|
|
3229
|
+
strokeWidth: 3,
|
|
3230
|
+
children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M5 15l7-7 7 7" })
|
|
3231
|
+
}
|
|
3232
|
+
),
|
|
3233
|
+
trend.isPositive === false && /* @__PURE__ */ jsx(
|
|
3234
|
+
"svg",
|
|
3235
|
+
{
|
|
3236
|
+
className: "mr-1 h-3 w-3",
|
|
3237
|
+
fill: "none",
|
|
3238
|
+
viewBox: "0 0 24 24",
|
|
3239
|
+
stroke: "currentColor",
|
|
3240
|
+
strokeWidth: 3,
|
|
3241
|
+
children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19 9l-7 7-7-7" })
|
|
3242
|
+
}
|
|
3243
|
+
),
|
|
3244
|
+
trend.value
|
|
3245
|
+
]
|
|
3246
|
+
}
|
|
3247
|
+
)
|
|
3248
|
+
] }),
|
|
3249
|
+
trend?.label && /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-fg-subtle", children: trend.label })
|
|
3250
|
+
] });
|
|
3251
|
+
}
|
|
3252
|
+
);
|
|
3253
|
+
StatCard.displayName = "StatCard";
|
|
3254
|
+
|
|
3255
|
+
// src/components/data-display/Chart/Chart.utils.ts
|
|
3256
|
+
var CHART_PALETTE_SIZE = 8;
|
|
3257
|
+
function chartColor(position) {
|
|
3258
|
+
return `var(--ml-chart-${String(position % CHART_PALETTE_SIZE + 1)})`;
|
|
3259
|
+
}
|
|
3260
|
+
function resolveSeries(series) {
|
|
3261
|
+
return series.map((entry, position) => {
|
|
3262
|
+
const config = typeof entry === "string" ? { dataKey: entry } : entry;
|
|
3263
|
+
return {
|
|
3264
|
+
dataKey: config.dataKey,
|
|
3265
|
+
label: config.label ?? config.dataKey,
|
|
3266
|
+
color: config.color ?? chartColor(position)
|
|
3267
|
+
};
|
|
3268
|
+
});
|
|
3269
|
+
}
|
|
3270
|
+
function ChartTooltipContent({
|
|
3271
|
+
active,
|
|
3272
|
+
label,
|
|
3273
|
+
payload,
|
|
3274
|
+
valueFormatter,
|
|
3275
|
+
indexFormatter,
|
|
3276
|
+
className
|
|
3277
|
+
}) {
|
|
3278
|
+
if (!active || !payload || payload.length === 0) return null;
|
|
3279
|
+
return /* @__PURE__ */ jsxs(
|
|
3280
|
+
"div",
|
|
3281
|
+
{
|
|
3282
|
+
className: cn(
|
|
3283
|
+
"min-w-32 rounded-md border border-line bg-surface-raised px-3 py-2 text-xs shadow-overlay",
|
|
3284
|
+
className
|
|
3285
|
+
),
|
|
3286
|
+
children: [
|
|
3287
|
+
label !== void 0 && /* @__PURE__ */ jsx("p", { className: "mb-1.5 font-medium text-fg", children: indexFormatter ? indexFormatter(label) : label }),
|
|
3288
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: payload.map((entry) => /* @__PURE__ */ jsxs(
|
|
3289
|
+
"div",
|
|
3290
|
+
{
|
|
3291
|
+
className: "flex items-center justify-between gap-4",
|
|
3292
|
+
children: [
|
|
3293
|
+
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1.5 text-fg-muted", children: [
|
|
3294
|
+
/* @__PURE__ */ jsx(
|
|
3295
|
+
"span",
|
|
3296
|
+
{
|
|
3297
|
+
"aria-hidden": true,
|
|
3298
|
+
className: "size-2 shrink-0 rounded-[2px]",
|
|
3299
|
+
style: { backgroundColor: entry.color }
|
|
3300
|
+
}
|
|
3301
|
+
),
|
|
3302
|
+
entry.name
|
|
3303
|
+
] }),
|
|
3304
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium tabular-nums text-fg", children: typeof entry.value === "number" && valueFormatter ? valueFormatter(entry.value) : String(entry.value) })
|
|
3305
|
+
]
|
|
3306
|
+
},
|
|
3307
|
+
String(entry.dataKey ?? entry.name)
|
|
3308
|
+
)) })
|
|
3309
|
+
]
|
|
3310
|
+
}
|
|
3311
|
+
);
|
|
3312
|
+
}
|
|
3313
|
+
function ChartLegendContent({ payload, className }) {
|
|
3314
|
+
if (!payload || payload.length === 0) return null;
|
|
3315
|
+
return /* @__PURE__ */ jsx("div", { className: cn("flex flex-wrap items-center justify-center gap-x-4 gap-y-1 pt-3", className), children: payload.map((entry) => /* @__PURE__ */ jsxs(
|
|
3316
|
+
"span",
|
|
3317
|
+
{
|
|
3318
|
+
className: "flex items-center gap-1.5 text-xs text-fg-muted",
|
|
3319
|
+
children: [
|
|
3320
|
+
/* @__PURE__ */ jsx(
|
|
3321
|
+
"span",
|
|
3322
|
+
{
|
|
3323
|
+
"aria-hidden": true,
|
|
3324
|
+
className: "size-2 shrink-0 rounded-[2px]",
|
|
3325
|
+
style: { backgroundColor: entry.color }
|
|
3326
|
+
}
|
|
3327
|
+
),
|
|
3328
|
+
entry.value
|
|
3329
|
+
]
|
|
3330
|
+
},
|
|
3331
|
+
String(entry.dataKey ?? entry.value)
|
|
3332
|
+
)) });
|
|
3333
|
+
}
|
|
3334
|
+
var DEFAULT_CHART_HEIGHT = 300;
|
|
3335
|
+
var ChartRoot = React5.forwardRef(({ className, height, style, children, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
3336
|
+
"div",
|
|
3337
|
+
{
|
|
3338
|
+
ref,
|
|
3339
|
+
role: "img",
|
|
3340
|
+
className: cn("w-full text-xs", className),
|
|
3341
|
+
style: { height, ...style },
|
|
3342
|
+
...props,
|
|
3343
|
+
children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children })
|
|
3344
|
+
}
|
|
3345
|
+
));
|
|
3346
|
+
ChartRoot.displayName = "ChartRoot";
|
|
3347
|
+
function renderCartesianScaffold(props, options = {}) {
|
|
3348
|
+
const {
|
|
3349
|
+
index,
|
|
3350
|
+
series,
|
|
3351
|
+
valueFormatter,
|
|
3352
|
+
indexFormatter,
|
|
3353
|
+
showGrid = true,
|
|
3354
|
+
showTooltip = true,
|
|
3355
|
+
showLegend = series.length > 1,
|
|
3356
|
+
showXAxis = true,
|
|
3357
|
+
showYAxis = true
|
|
3358
|
+
} = props;
|
|
3359
|
+
const children = [];
|
|
3360
|
+
if (showGrid) {
|
|
3361
|
+
children.push(
|
|
3362
|
+
/* @__PURE__ */ jsx(
|
|
3363
|
+
CartesianGrid,
|
|
3364
|
+
{
|
|
3365
|
+
stroke: "var(--ml-chart-grid)",
|
|
3366
|
+
strokeDasharray: "4 4",
|
|
3367
|
+
vertical: false
|
|
3368
|
+
},
|
|
3369
|
+
"grid"
|
|
3370
|
+
)
|
|
3371
|
+
);
|
|
3372
|
+
}
|
|
3373
|
+
if (showXAxis) {
|
|
3374
|
+
children.push(
|
|
3375
|
+
/* @__PURE__ */ jsx(
|
|
3376
|
+
XAxis,
|
|
3377
|
+
{
|
|
3378
|
+
dataKey: index,
|
|
3379
|
+
stroke: "var(--ml-chart-label)",
|
|
3380
|
+
tick: { fill: "var(--ml-chart-label)", fontSize: 12 },
|
|
3381
|
+
tickLine: false,
|
|
3382
|
+
axisLine: false,
|
|
3383
|
+
tickMargin: 8,
|
|
3384
|
+
tickFormatter: indexFormatter
|
|
3385
|
+
},
|
|
3386
|
+
"x"
|
|
3387
|
+
)
|
|
3388
|
+
);
|
|
3389
|
+
}
|
|
3390
|
+
if (showYAxis) {
|
|
3391
|
+
children.push(
|
|
3392
|
+
/* @__PURE__ */ jsx(
|
|
3393
|
+
YAxis,
|
|
3394
|
+
{
|
|
3395
|
+
width: 48,
|
|
3396
|
+
stroke: "var(--ml-chart-label)",
|
|
3397
|
+
tick: { fill: "var(--ml-chart-label)", fontSize: 12 },
|
|
3398
|
+
tickLine: false,
|
|
3399
|
+
axisLine: false,
|
|
3400
|
+
tickFormatter: valueFormatter
|
|
3401
|
+
},
|
|
3402
|
+
"y"
|
|
3403
|
+
)
|
|
3404
|
+
);
|
|
3405
|
+
}
|
|
3406
|
+
if (showTooltip) {
|
|
3407
|
+
children.push(
|
|
3408
|
+
/* @__PURE__ */ jsx(
|
|
3409
|
+
Tooltip$1,
|
|
3410
|
+
{
|
|
3411
|
+
cursor: options.tooltipCursor ?? { stroke: "var(--ml-chart-grid)" },
|
|
3412
|
+
content: /* @__PURE__ */ jsx(
|
|
3413
|
+
ChartTooltipContent,
|
|
3414
|
+
{
|
|
3415
|
+
valueFormatter,
|
|
3416
|
+
indexFormatter
|
|
3417
|
+
}
|
|
3418
|
+
)
|
|
3419
|
+
},
|
|
3420
|
+
"tooltip"
|
|
3421
|
+
)
|
|
3422
|
+
);
|
|
3423
|
+
}
|
|
3424
|
+
if (showLegend) {
|
|
3425
|
+
children.push(/* @__PURE__ */ jsx(Legend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}) }, "legend"));
|
|
3426
|
+
}
|
|
3427
|
+
return children;
|
|
3428
|
+
}
|
|
3429
|
+
function LineChart({
|
|
3430
|
+
data,
|
|
3431
|
+
index,
|
|
3432
|
+
series,
|
|
3433
|
+
height = DEFAULT_CHART_HEIGHT,
|
|
3434
|
+
valueFormatter,
|
|
3435
|
+
indexFormatter,
|
|
3436
|
+
showGrid,
|
|
3437
|
+
showTooltip,
|
|
3438
|
+
showLegend,
|
|
3439
|
+
showXAxis,
|
|
3440
|
+
showYAxis,
|
|
3441
|
+
curve = "monotone",
|
|
3442
|
+
showDots = false,
|
|
3443
|
+
...rootProps
|
|
3444
|
+
}) {
|
|
3445
|
+
const resolved = resolveSeries(series);
|
|
3446
|
+
return /* @__PURE__ */ jsx(ChartRoot, { height, ...rootProps, children: /* @__PURE__ */ jsxs(
|
|
3447
|
+
LineChart$1,
|
|
3448
|
+
{
|
|
3449
|
+
data: data.slice(),
|
|
3450
|
+
margin: { top: 8, right: 8, left: 0, bottom: 0 },
|
|
3451
|
+
accessibilityLayer: true,
|
|
3452
|
+
children: [
|
|
3453
|
+
renderCartesianScaffold({
|
|
3454
|
+
index,
|
|
3455
|
+
series,
|
|
3456
|
+
valueFormatter,
|
|
3457
|
+
indexFormatter,
|
|
3458
|
+
showGrid,
|
|
3459
|
+
showTooltip,
|
|
3460
|
+
showLegend,
|
|
3461
|
+
showXAxis,
|
|
3462
|
+
showYAxis
|
|
3463
|
+
}),
|
|
3464
|
+
resolved.map((s) => /* @__PURE__ */ jsx(
|
|
3465
|
+
Line,
|
|
3466
|
+
{
|
|
3467
|
+
type: curve,
|
|
3468
|
+
dataKey: s.dataKey,
|
|
3469
|
+
name: s.label,
|
|
3470
|
+
stroke: s.color,
|
|
3471
|
+
strokeWidth: 2,
|
|
3472
|
+
dot: showDots ? { r: 3, fill: s.color, strokeWidth: 0 } : false,
|
|
3473
|
+
activeDot: { r: 4 }
|
|
3474
|
+
},
|
|
3475
|
+
s.dataKey
|
|
3476
|
+
))
|
|
3477
|
+
]
|
|
3478
|
+
}
|
|
3479
|
+
) });
|
|
3480
|
+
}
|
|
3481
|
+
function BarChart({
|
|
3482
|
+
data,
|
|
3483
|
+
index,
|
|
3484
|
+
series,
|
|
3485
|
+
height = DEFAULT_CHART_HEIGHT,
|
|
3486
|
+
valueFormatter,
|
|
3487
|
+
indexFormatter,
|
|
3488
|
+
showGrid,
|
|
3489
|
+
showTooltip,
|
|
3490
|
+
showLegend,
|
|
3491
|
+
showXAxis,
|
|
3492
|
+
showYAxis,
|
|
3493
|
+
stacked = false,
|
|
3494
|
+
...rootProps
|
|
3495
|
+
}) {
|
|
3496
|
+
const resolved = resolveSeries(series);
|
|
3497
|
+
const isLast = (position) => position === resolved.length - 1;
|
|
3498
|
+
return /* @__PURE__ */ jsx(ChartRoot, { height, ...rootProps, children: /* @__PURE__ */ jsxs(
|
|
3499
|
+
BarChart$1,
|
|
3500
|
+
{
|
|
3501
|
+
data: data.slice(),
|
|
3502
|
+
margin: { top: 8, right: 8, left: 0, bottom: 0 },
|
|
3503
|
+
accessibilityLayer: true,
|
|
3504
|
+
children: [
|
|
3505
|
+
renderCartesianScaffold(
|
|
3506
|
+
{
|
|
3507
|
+
index,
|
|
3508
|
+
series,
|
|
3509
|
+
valueFormatter,
|
|
3510
|
+
indexFormatter,
|
|
3511
|
+
showGrid,
|
|
3512
|
+
showTooltip,
|
|
3513
|
+
showLegend,
|
|
3514
|
+
showXAxis,
|
|
3515
|
+
showYAxis
|
|
3516
|
+
},
|
|
3517
|
+
{ tooltipCursor: { fill: "var(--ml-surface-sunken)", opacity: 0.6 } }
|
|
3518
|
+
),
|
|
3519
|
+
resolved.map((s, position) => /* @__PURE__ */ jsx(
|
|
3520
|
+
Bar,
|
|
3521
|
+
{
|
|
3522
|
+
dataKey: s.dataKey,
|
|
3523
|
+
name: s.label,
|
|
3524
|
+
fill: s.color,
|
|
3525
|
+
stackId: stacked ? "stack" : void 0,
|
|
3526
|
+
radius: !stacked || isLast(position) ? [4, 4, 0, 0] : [0, 0, 0, 0],
|
|
3527
|
+
maxBarSize: 48
|
|
3528
|
+
},
|
|
3529
|
+
s.dataKey
|
|
3530
|
+
))
|
|
3531
|
+
]
|
|
3532
|
+
}
|
|
3533
|
+
) });
|
|
3534
|
+
}
|
|
3535
|
+
function AreaChart({
|
|
3536
|
+
data,
|
|
3537
|
+
index,
|
|
3538
|
+
series,
|
|
3539
|
+
height = DEFAULT_CHART_HEIGHT,
|
|
3540
|
+
valueFormatter,
|
|
3541
|
+
indexFormatter,
|
|
3542
|
+
showGrid,
|
|
3543
|
+
showTooltip,
|
|
3544
|
+
showLegend,
|
|
3545
|
+
showXAxis,
|
|
3546
|
+
showYAxis,
|
|
3547
|
+
curve = "monotone",
|
|
3548
|
+
stacked = false,
|
|
3549
|
+
...rootProps
|
|
3550
|
+
}) {
|
|
3551
|
+
const resolved = resolveSeries(series);
|
|
3552
|
+
const gradientPrefix = React5.useId().replace(/[^a-zA-Z0-9]/g, "");
|
|
3553
|
+
return /* @__PURE__ */ jsx(ChartRoot, { height, ...rootProps, children: /* @__PURE__ */ jsxs(
|
|
3554
|
+
AreaChart$1,
|
|
3555
|
+
{
|
|
3556
|
+
data: data.slice(),
|
|
3557
|
+
margin: { top: 8, right: 8, left: 0, bottom: 0 },
|
|
3558
|
+
accessibilityLayer: true,
|
|
3559
|
+
children: [
|
|
3560
|
+
/* @__PURE__ */ jsx("defs", { children: resolved.map((s) => /* @__PURE__ */ jsxs(
|
|
3561
|
+
"linearGradient",
|
|
3562
|
+
{
|
|
3563
|
+
id: `${gradientPrefix}-${s.dataKey}`,
|
|
3564
|
+
x1: "0",
|
|
3565
|
+
y1: "0",
|
|
3566
|
+
x2: "0",
|
|
3567
|
+
y2: "1",
|
|
3568
|
+
children: [
|
|
3569
|
+
/* @__PURE__ */ jsx("stop", { offset: "5%", stopColor: s.color, stopOpacity: 0.32 }),
|
|
3570
|
+
/* @__PURE__ */ jsx("stop", { offset: "95%", stopColor: s.color, stopOpacity: 0.04 })
|
|
3571
|
+
]
|
|
3572
|
+
},
|
|
3573
|
+
s.dataKey
|
|
3574
|
+
)) }),
|
|
3575
|
+
renderCartesianScaffold({
|
|
3576
|
+
index,
|
|
3577
|
+
series,
|
|
3578
|
+
valueFormatter,
|
|
3579
|
+
indexFormatter,
|
|
3580
|
+
showGrid,
|
|
3581
|
+
showTooltip,
|
|
3582
|
+
showLegend,
|
|
3583
|
+
showXAxis,
|
|
3584
|
+
showYAxis
|
|
3585
|
+
}),
|
|
3586
|
+
resolved.map((s) => /* @__PURE__ */ jsx(
|
|
3587
|
+
Area,
|
|
3588
|
+
{
|
|
3589
|
+
type: curve,
|
|
3590
|
+
dataKey: s.dataKey,
|
|
3591
|
+
name: s.label,
|
|
3592
|
+
stroke: s.color,
|
|
3593
|
+
strokeWidth: 2,
|
|
3594
|
+
fill: `url(#${gradientPrefix}-${s.dataKey})`,
|
|
3595
|
+
stackId: stacked ? "stack" : void 0,
|
|
3596
|
+
dot: false,
|
|
3597
|
+
activeDot: { r: 4 }
|
|
3598
|
+
},
|
|
3599
|
+
s.dataKey
|
|
3600
|
+
))
|
|
3601
|
+
]
|
|
3602
|
+
}
|
|
3603
|
+
) });
|
|
3604
|
+
}
|
|
3605
|
+
|
|
3606
|
+
// src/index.ts
|
|
3607
|
+
var UI_LIBRARY_VERSION = "0.0.0";
|
|
3608
|
+
|
|
3609
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AreaChart, Avatar, AvatarFallback, AvatarImage, Badge, BarChart, Breadcrumbs, Button, ButtonGroup, CHART_PALETTE_SIZE, Calendar, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, ChartLegendContent, ChartTooltipContent, Checkbox, Code, CodeInput, Combobox, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, Container, DataTable, DatePicker, DateRangePicker, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Divider, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmptyState, ErrorState, Field, FileUpload, Flex, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, Grid, Heading, IconButton, Label, LineChart, Link, LoadingOverlay, MultiSelect, PageHeader, Pagination, Panel, PasswordInput, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, Progress, RadioGroup, SearchInput, Select, SignatureInput, Skeleton, Slider, Spinner, Stack, StatCard, StatusIndicator, Steps, SuccessState, Switch, TOKEN_CSS_VARS, Tabs, Text, TextInput, Textarea, ThemeProvider, Timeline, TimelineContent, TimelineDescription, TimelineDot, TimelineItem, TimelineTime, TimelineTitle, Toast, ToastAction, ToastClose, ToastDescription, ToastProvider, ToastTitle, ToastViewport, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, UI_LIBRARY_VERSION, chartColor, cn, defineVariants, getThemeInitScript, inputClassName, resolveSeries, themeOverridesToCss, useFieldContext, useFieldInputProps, useFormField, useTheme };
|
|
3610
|
+
//# sourceMappingURL=index.js.map
|
|
3611
|
+
//# sourceMappingURL=index.js.map
|