@morze/ui 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/LICENSE +21 -0
- package/README.md +455 -0
- package/dist/index.cjs +3331 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +692 -0
- package/dist/index.d.ts +692 -0
- package/dist/index.js +3161 -0
- package/dist/index.js.map +1 -0
- package/dist/morze-ui-tokens.css +1 -0
- package/dist/morze-ui.css +1 -0
- package/package.json +89 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,3161 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { clsx } from 'clsx';
|
|
3
|
+
import * as React39 from 'react';
|
|
4
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
|
+
import { cva } from 'class-variance-authority';
|
|
6
|
+
import { Slot, Toggle as Toggle$1, ToggleGroup as ToggleGroup$1, Checkbox as Checkbox$1, RadioGroup as RadioGroup$1, Switch as Switch$1, Slider as Slider$1, Label as Label$1, Select as Select$1, Tabs as Tabs$1, Accordion as Accordion$1, Progress as Progress$1, Avatar as Avatar$1, Separator as Separator$1, Dialog as Dialog$1, Popover as Popover$1, DropdownMenu as DropdownMenu$1, Tooltip as Tooltip$1 } from 'radix-ui';
|
|
7
|
+
|
|
8
|
+
// src/lib/utils.ts
|
|
9
|
+
function cn(...inputs) {
|
|
10
|
+
return clsx(inputs);
|
|
11
|
+
}
|
|
12
|
+
var ThemeContext = React39.createContext(null);
|
|
13
|
+
function readStored(key) {
|
|
14
|
+
if (!key || typeof window === "undefined") return null;
|
|
15
|
+
try {
|
|
16
|
+
const stored = window.localStorage.getItem(key);
|
|
17
|
+
return stored === "dark" || stored === "light" || stored === "system" ? stored : null;
|
|
18
|
+
} catch {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function writeStored(key, theme) {
|
|
23
|
+
if (!key || typeof window === "undefined") return;
|
|
24
|
+
try {
|
|
25
|
+
window.localStorage.setItem(key, theme);
|
|
26
|
+
} catch {
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function systemTheme() {
|
|
30
|
+
if (typeof window === "undefined" || !window.matchMedia) return "dark";
|
|
31
|
+
return window.matchMedia("(prefers-color-scheme: light)").matches ? "light" : "dark";
|
|
32
|
+
}
|
|
33
|
+
function MorzeThemeProvider({
|
|
34
|
+
children,
|
|
35
|
+
defaultTheme = "dark",
|
|
36
|
+
storageKey = "morze-ui-theme",
|
|
37
|
+
target = "html",
|
|
38
|
+
className
|
|
39
|
+
}) {
|
|
40
|
+
const [theme, setThemeState] = React39.useState(defaultTheme);
|
|
41
|
+
const [resolved, setResolved] = React39.useState(
|
|
42
|
+
defaultTheme === "system" ? "dark" : defaultTheme
|
|
43
|
+
);
|
|
44
|
+
React39.useEffect(() => {
|
|
45
|
+
const stored = readStored(storageKey);
|
|
46
|
+
if (stored) setThemeState(stored);
|
|
47
|
+
}, [storageKey]);
|
|
48
|
+
React39.useEffect(() => {
|
|
49
|
+
if (theme !== "system") {
|
|
50
|
+
setResolved(theme);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
setResolved(systemTheme());
|
|
54
|
+
const mql = window.matchMedia("(prefers-color-scheme: light)");
|
|
55
|
+
const onChange = () => setResolved(systemTheme());
|
|
56
|
+
mql.addEventListener("change", onChange);
|
|
57
|
+
return () => mql.removeEventListener("change", onChange);
|
|
58
|
+
}, [theme]);
|
|
59
|
+
React39.useEffect(() => {
|
|
60
|
+
if (target !== "html" || typeof document === "undefined") return;
|
|
61
|
+
document.documentElement.setAttribute("data-mz-theme", resolved);
|
|
62
|
+
}, [resolved, target]);
|
|
63
|
+
const setTheme = React39.useCallback(
|
|
64
|
+
(next) => {
|
|
65
|
+
setThemeState(next);
|
|
66
|
+
writeStored(storageKey, next);
|
|
67
|
+
},
|
|
68
|
+
[storageKey]
|
|
69
|
+
);
|
|
70
|
+
const value = React39.useMemo(
|
|
71
|
+
() => ({ theme, resolvedTheme: resolved, setTheme }),
|
|
72
|
+
[theme, resolved, setTheme]
|
|
73
|
+
);
|
|
74
|
+
return /* @__PURE__ */ jsx(ThemeContext.Provider, { value, children: /* @__PURE__ */ jsx(
|
|
75
|
+
"div",
|
|
76
|
+
{
|
|
77
|
+
"data-slot": "morze-root",
|
|
78
|
+
"data-mz-theme": target === "element" ? resolved : void 0,
|
|
79
|
+
className: ["mz-root", className].filter(Boolean).join(" "),
|
|
80
|
+
children
|
|
81
|
+
}
|
|
82
|
+
) });
|
|
83
|
+
}
|
|
84
|
+
function useMorzeTheme() {
|
|
85
|
+
const context = React39.useContext(ThemeContext);
|
|
86
|
+
if (!context) {
|
|
87
|
+
throw new Error("useMorzeTheme must be used inside <MorzeThemeProvider>");
|
|
88
|
+
}
|
|
89
|
+
return context;
|
|
90
|
+
}
|
|
91
|
+
function icon(path, extra) {
|
|
92
|
+
return function Icon(props) {
|
|
93
|
+
return /* @__PURE__ */ jsx(
|
|
94
|
+
"svg",
|
|
95
|
+
{
|
|
96
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
97
|
+
viewBox: "0 0 24 24",
|
|
98
|
+
fill: "none",
|
|
99
|
+
stroke: "currentColor",
|
|
100
|
+
strokeWidth: 2,
|
|
101
|
+
strokeLinecap: "round",
|
|
102
|
+
strokeLinejoin: "round",
|
|
103
|
+
"aria-hidden": "true",
|
|
104
|
+
...extra,
|
|
105
|
+
...props,
|
|
106
|
+
children: path
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
var CheckIcon = icon(/* @__PURE__ */ jsx("path", { d: "M20 6 9 17l-5-5" }));
|
|
112
|
+
var MinusIcon = icon(/* @__PURE__ */ jsx("path", { d: "M5 12h14" }));
|
|
113
|
+
var XIcon = icon(/* @__PURE__ */ jsx("path", { d: "M18 6 6 18M6 6l12 12" }));
|
|
114
|
+
var ChevronDownIcon = icon(/* @__PURE__ */ jsx("path", { d: "m6 9 6 6 6-6" }));
|
|
115
|
+
var ChevronUpIcon = icon(/* @__PURE__ */ jsx("path", { d: "m18 15-6-6-6 6" }));
|
|
116
|
+
var ChevronRightIcon = icon(/* @__PURE__ */ jsx("path", { d: "m9 18 6-6-6-6" }));
|
|
117
|
+
var DotIcon = icon(/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "4", fill: "currentColor" }));
|
|
118
|
+
var SpinnerIcon = icon(
|
|
119
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
120
|
+
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "9", opacity: "0.25" }),
|
|
121
|
+
/* @__PURE__ */ jsx("path", { d: "M21 12a9 9 0 0 0-9-9" })
|
|
122
|
+
] })
|
|
123
|
+
);
|
|
124
|
+
var ChevronLeftIcon = icon(/* @__PURE__ */ jsx("path", { d: "m15 18-6-6 6-6" }));
|
|
125
|
+
var ChevronsLeftIcon = icon(
|
|
126
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
127
|
+
/* @__PURE__ */ jsx("path", { d: "m11 17-5-5 5-5" }),
|
|
128
|
+
/* @__PURE__ */ jsx("path", { d: "m18 17-5-5 5-5" })
|
|
129
|
+
] })
|
|
130
|
+
);
|
|
131
|
+
var ChevronsRightIcon = icon(
|
|
132
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
133
|
+
/* @__PURE__ */ jsx("path", { d: "m13 17 5-5-5-5" }),
|
|
134
|
+
/* @__PURE__ */ jsx("path", { d: "m6 17 5-5-5-5" })
|
|
135
|
+
] })
|
|
136
|
+
);
|
|
137
|
+
var ArrowUpIcon = icon(/* @__PURE__ */ jsx("path", { d: "M12 19V5m-7 7 7-7 7 7" }));
|
|
138
|
+
var ArrowDownIcon = icon(/* @__PURE__ */ jsx("path", { d: "M12 5v14m7-7-7 7-7-7" }));
|
|
139
|
+
var SortIcon = icon(
|
|
140
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
141
|
+
/* @__PURE__ */ jsx("path", { d: "m7 15 3 3 3-3", opacity: "0.9" }),
|
|
142
|
+
/* @__PURE__ */ jsx("path", { d: "m7 9 3-3 3 3", opacity: "0.9" })
|
|
143
|
+
] })
|
|
144
|
+
);
|
|
145
|
+
var FilterIcon = icon(/* @__PURE__ */ jsx("path", { d: "M4 5h16l-6.5 7.5V19l-3 2v-8.5L4 5Z" }));
|
|
146
|
+
var ColumnsIcon = icon(
|
|
147
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
148
|
+
/* @__PURE__ */ jsx("rect", { x: "3", y: "4", width: "18", height: "16", rx: "2" }),
|
|
149
|
+
/* @__PURE__ */ jsx("path", { d: "M9 4v16M15 4v16" })
|
|
150
|
+
] })
|
|
151
|
+
);
|
|
152
|
+
var GripIcon = icon(
|
|
153
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
154
|
+
/* @__PURE__ */ jsx("circle", { cx: "9", cy: "7", r: "1.4", fill: "currentColor" }),
|
|
155
|
+
/* @__PURE__ */ jsx("circle", { cx: "9", cy: "12", r: "1.4", fill: "currentColor" }),
|
|
156
|
+
/* @__PURE__ */ jsx("circle", { cx: "9", cy: "17", r: "1.4", fill: "currentColor" }),
|
|
157
|
+
/* @__PURE__ */ jsx("circle", { cx: "15", cy: "7", r: "1.4", fill: "currentColor" }),
|
|
158
|
+
/* @__PURE__ */ jsx("circle", { cx: "15", cy: "12", r: "1.4", fill: "currentColor" }),
|
|
159
|
+
/* @__PURE__ */ jsx("circle", { cx: "15", cy: "17", r: "1.4", fill: "currentColor" })
|
|
160
|
+
] })
|
|
161
|
+
);
|
|
162
|
+
var PinIcon = icon(/* @__PURE__ */ jsx("path", { d: "M15 3 21 9l-4 1-4 4-1 5-6-6 5-1 4-4 1-4Z" }));
|
|
163
|
+
var EyeIcon = icon(
|
|
164
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
165
|
+
/* @__PURE__ */ jsx("path", { d: "M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7Z" }),
|
|
166
|
+
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "3" })
|
|
167
|
+
] })
|
|
168
|
+
);
|
|
169
|
+
var EyeOffIcon = icon(
|
|
170
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
171
|
+
/* @__PURE__ */ jsx("path", { d: "M10.6 5.2A9.8 9.8 0 0 1 12 5c6.5 0 10 7 10 7a17 17 0 0 1-3 3.9M6.2 6.2A17 17 0 0 0 2 12s3.5 7 10 7c1.9 0 3.5-.6 4.9-1.4" }),
|
|
172
|
+
/* @__PURE__ */ jsx("path", { d: "m3 3 18 18" })
|
|
173
|
+
] })
|
|
174
|
+
);
|
|
175
|
+
var InboxIcon = icon(
|
|
176
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
177
|
+
/* @__PURE__ */ jsx("path", { d: "M3 12h5l2 3h4l2-3h5" }),
|
|
178
|
+
/* @__PURE__ */ jsx("path", { d: "M5.5 5h13l2.5 7v5a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-5l2.5-7Z" })
|
|
179
|
+
] })
|
|
180
|
+
);
|
|
181
|
+
var AlertIcon = icon(
|
|
182
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
183
|
+
/* @__PURE__ */ jsx("path", { d: "M12 9v4M12 17h.01" }),
|
|
184
|
+
/* @__PURE__ */ jsx("path", { d: "M10.3 3.9 2.6 17a2 2 0 0 0 1.7 3h15.4a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0Z" })
|
|
185
|
+
] })
|
|
186
|
+
);
|
|
187
|
+
var buttonVariants = cva("mz-btn mz-focusable", {
|
|
188
|
+
variants: {
|
|
189
|
+
variant: {
|
|
190
|
+
primary: "mz-btn--primary",
|
|
191
|
+
secondary: "mz-btn--secondary",
|
|
192
|
+
outline: "mz-btn--outline",
|
|
193
|
+
ghost: "mz-btn--ghost",
|
|
194
|
+
destructive: "mz-btn--destructive",
|
|
195
|
+
link: "mz-btn--link"
|
|
196
|
+
},
|
|
197
|
+
size: {
|
|
198
|
+
xs: "mz-btn--xs",
|
|
199
|
+
sm: "mz-btn--sm",
|
|
200
|
+
md: "mz-btn--md",
|
|
201
|
+
lg: "mz-btn--lg",
|
|
202
|
+
"icon-xs": "mz-btn--icon-xs",
|
|
203
|
+
"icon-sm": "mz-btn--icon-sm",
|
|
204
|
+
icon: "mz-btn--icon",
|
|
205
|
+
"icon-lg": "mz-btn--icon-lg"
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
defaultVariants: {
|
|
209
|
+
variant: "primary",
|
|
210
|
+
size: "md"
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
function Button({
|
|
214
|
+
className,
|
|
215
|
+
variant = "primary",
|
|
216
|
+
size = "md",
|
|
217
|
+
asChild = false,
|
|
218
|
+
tone,
|
|
219
|
+
loading = false,
|
|
220
|
+
dot = false,
|
|
221
|
+
disabled,
|
|
222
|
+
children,
|
|
223
|
+
...props
|
|
224
|
+
}) {
|
|
225
|
+
const Comp = asChild ? Slot.Root : "button";
|
|
226
|
+
const isDisabled = disabled || loading;
|
|
227
|
+
const decorate = (label) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
228
|
+
dot ? /* @__PURE__ */ jsx("span", { className: "mz-btn__dot", "aria-hidden": "true" }) : null,
|
|
229
|
+
label,
|
|
230
|
+
loading ? /* @__PURE__ */ jsx("span", { className: "mz-btn__spinner", "aria-hidden": "true", children: /* @__PURE__ */ jsx(SpinnerIcon, {}) }) : null
|
|
231
|
+
] });
|
|
232
|
+
let content;
|
|
233
|
+
if (asChild) {
|
|
234
|
+
const child = React39.Children.only(children);
|
|
235
|
+
content = React39.cloneElement(child, void 0, decorate(child.props.children));
|
|
236
|
+
} else {
|
|
237
|
+
content = decorate(children);
|
|
238
|
+
}
|
|
239
|
+
return /* @__PURE__ */ jsx(
|
|
240
|
+
Comp,
|
|
241
|
+
{
|
|
242
|
+
"data-slot": "button",
|
|
243
|
+
"data-variant": variant,
|
|
244
|
+
"data-size": size,
|
|
245
|
+
"data-tone": tone,
|
|
246
|
+
"data-loading": loading || void 0,
|
|
247
|
+
className: cn(buttonVariants({ variant, size }), className),
|
|
248
|
+
disabled: asChild ? void 0 : isDisabled,
|
|
249
|
+
"aria-disabled": asChild && isDisabled ? true : void 0,
|
|
250
|
+
"aria-busy": loading || void 0,
|
|
251
|
+
...props,
|
|
252
|
+
children: content
|
|
253
|
+
}
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
var badgeVariants = cva("mz-badge", {
|
|
257
|
+
variants: {
|
|
258
|
+
variant: {
|
|
259
|
+
solid: "mz-badge--solid",
|
|
260
|
+
soft: "mz-badge--soft",
|
|
261
|
+
outline: "mz-badge--outline"
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
defaultVariants: {
|
|
265
|
+
variant: "solid"
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
function Badge({
|
|
269
|
+
className,
|
|
270
|
+
variant = "solid",
|
|
271
|
+
tone,
|
|
272
|
+
dot = false,
|
|
273
|
+
asChild = false,
|
|
274
|
+
children,
|
|
275
|
+
...props
|
|
276
|
+
}) {
|
|
277
|
+
const Comp = asChild ? Slot.Root : "span";
|
|
278
|
+
return /* @__PURE__ */ jsx(
|
|
279
|
+
Comp,
|
|
280
|
+
{
|
|
281
|
+
"data-slot": "badge",
|
|
282
|
+
"data-variant": variant,
|
|
283
|
+
"data-tone": tone,
|
|
284
|
+
className: cn(badgeVariants({ variant }), className),
|
|
285
|
+
...props,
|
|
286
|
+
children: asChild ? children : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
287
|
+
dot ? /* @__PURE__ */ jsx("span", { className: "mz-badge__dot", "aria-hidden": "true" }) : null,
|
|
288
|
+
children
|
|
289
|
+
] })
|
|
290
|
+
}
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
var toggleVariants = cva("mz-toggle", {
|
|
294
|
+
variants: {
|
|
295
|
+
variant: {
|
|
296
|
+
default: "",
|
|
297
|
+
outline: "mz-toggle--outline"
|
|
298
|
+
},
|
|
299
|
+
size: {
|
|
300
|
+
sm: "mz-toggle--sm",
|
|
301
|
+
md: "mz-toggle--md",
|
|
302
|
+
lg: "mz-toggle--lg"
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
defaultVariants: {
|
|
306
|
+
variant: "default",
|
|
307
|
+
size: "md"
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
function Toggle({
|
|
311
|
+
className,
|
|
312
|
+
variant = "default",
|
|
313
|
+
size = "md",
|
|
314
|
+
tone,
|
|
315
|
+
...props
|
|
316
|
+
}) {
|
|
317
|
+
return /* @__PURE__ */ jsx(
|
|
318
|
+
Toggle$1.Root,
|
|
319
|
+
{
|
|
320
|
+
"data-slot": "toggle",
|
|
321
|
+
"data-variant": variant,
|
|
322
|
+
"data-size": size,
|
|
323
|
+
"data-tone": tone,
|
|
324
|
+
className: cn(toggleVariants({ variant, size }), "mz-focusable", className),
|
|
325
|
+
...props
|
|
326
|
+
}
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
var ToggleGroupContext = React39.createContext({
|
|
330
|
+
size: "md",
|
|
331
|
+
variant: "default"
|
|
332
|
+
});
|
|
333
|
+
function ToggleGroup({
|
|
334
|
+
className,
|
|
335
|
+
variant = "default",
|
|
336
|
+
size = "md",
|
|
337
|
+
tone,
|
|
338
|
+
appearance = "segmented",
|
|
339
|
+
style,
|
|
340
|
+
children,
|
|
341
|
+
...props
|
|
342
|
+
}) {
|
|
343
|
+
return /* @__PURE__ */ jsx(
|
|
344
|
+
ToggleGroup$1.Root,
|
|
345
|
+
{
|
|
346
|
+
"data-slot": "toggle-group",
|
|
347
|
+
"data-variant": variant,
|
|
348
|
+
"data-size": size,
|
|
349
|
+
"data-tone": tone,
|
|
350
|
+
"data-appearance": appearance,
|
|
351
|
+
className: cn(
|
|
352
|
+
"mz-toggle-group",
|
|
353
|
+
appearance === "segmented" && "mz-toggle-group--segmented",
|
|
354
|
+
appearance === "joined" && "mz-toggle-group--joined",
|
|
355
|
+
className
|
|
356
|
+
),
|
|
357
|
+
style: appearance === "spaced" ? { "--mz-toggle-group-gap": "8px", ...style } : style,
|
|
358
|
+
...props,
|
|
359
|
+
children: /* @__PURE__ */ jsx(ToggleGroupContext.Provider, { value: { variant, size, tone }, children })
|
|
360
|
+
}
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
function ToggleGroupItem({
|
|
364
|
+
className,
|
|
365
|
+
children,
|
|
366
|
+
variant,
|
|
367
|
+
size,
|
|
368
|
+
...props
|
|
369
|
+
}) {
|
|
370
|
+
const context = React39.useContext(ToggleGroupContext);
|
|
371
|
+
const resolvedVariant = variant ?? context.variant;
|
|
372
|
+
const resolvedSize = size ?? context.size;
|
|
373
|
+
return /* @__PURE__ */ jsx(
|
|
374
|
+
ToggleGroup$1.Item,
|
|
375
|
+
{
|
|
376
|
+
"data-slot": "toggle-group-item",
|
|
377
|
+
"data-variant": resolvedVariant,
|
|
378
|
+
"data-size": resolvedSize,
|
|
379
|
+
"data-tone": context.tone,
|
|
380
|
+
className: cn(
|
|
381
|
+
toggleVariants({ variant: resolvedVariant, size: resolvedSize }),
|
|
382
|
+
"mz-focusable",
|
|
383
|
+
className
|
|
384
|
+
),
|
|
385
|
+
...props,
|
|
386
|
+
children
|
|
387
|
+
}
|
|
388
|
+
);
|
|
389
|
+
}
|
|
390
|
+
function Checkbox({ className, size = "md", tone, ...props }) {
|
|
391
|
+
return /* @__PURE__ */ jsx(
|
|
392
|
+
Checkbox$1.Root,
|
|
393
|
+
{
|
|
394
|
+
"data-slot": "checkbox",
|
|
395
|
+
"data-size": size,
|
|
396
|
+
"data-tone": tone,
|
|
397
|
+
className: cn(
|
|
398
|
+
"mz-checkbox mz-focusable",
|
|
399
|
+
size === "sm" && "mz-checkbox--sm",
|
|
400
|
+
size === "lg" && "mz-checkbox--lg",
|
|
401
|
+
className
|
|
402
|
+
),
|
|
403
|
+
...props,
|
|
404
|
+
children: /* @__PURE__ */ jsxs(Checkbox$1.Indicator, { "data-slot": "checkbox-indicator", className: "mz-checkbox__indicator", children: [
|
|
405
|
+
/* @__PURE__ */ jsx(CheckIcon, { className: "mz-checkbox__check" }),
|
|
406
|
+
/* @__PURE__ */ jsx(MinusIcon, { className: "mz-checkbox__dash" })
|
|
407
|
+
] })
|
|
408
|
+
}
|
|
409
|
+
);
|
|
410
|
+
}
|
|
411
|
+
function RadioGroup({
|
|
412
|
+
className,
|
|
413
|
+
...props
|
|
414
|
+
}) {
|
|
415
|
+
return /* @__PURE__ */ jsx(
|
|
416
|
+
RadioGroup$1.Root,
|
|
417
|
+
{
|
|
418
|
+
"data-slot": "radio-group",
|
|
419
|
+
className: cn("mz-radio-group", className),
|
|
420
|
+
...props
|
|
421
|
+
}
|
|
422
|
+
);
|
|
423
|
+
}
|
|
424
|
+
function RadioGroupItem({
|
|
425
|
+
className,
|
|
426
|
+
tone,
|
|
427
|
+
...props
|
|
428
|
+
}) {
|
|
429
|
+
return /* @__PURE__ */ jsx(
|
|
430
|
+
RadioGroup$1.Item,
|
|
431
|
+
{
|
|
432
|
+
"data-slot": "radio-group-item",
|
|
433
|
+
"data-tone": tone,
|
|
434
|
+
className: cn("mz-radio mz-focusable", className),
|
|
435
|
+
...props,
|
|
436
|
+
children: /* @__PURE__ */ jsx(
|
|
437
|
+
RadioGroup$1.Indicator,
|
|
438
|
+
{
|
|
439
|
+
"data-slot": "radio-group-indicator",
|
|
440
|
+
className: "mz-radio__indicator"
|
|
441
|
+
}
|
|
442
|
+
)
|
|
443
|
+
}
|
|
444
|
+
);
|
|
445
|
+
}
|
|
446
|
+
function Switch({ className, size = "md", tone, ...props }) {
|
|
447
|
+
return /* @__PURE__ */ jsx(
|
|
448
|
+
Switch$1.Root,
|
|
449
|
+
{
|
|
450
|
+
"data-slot": "switch",
|
|
451
|
+
"data-size": size,
|
|
452
|
+
"data-tone": tone,
|
|
453
|
+
className: cn(
|
|
454
|
+
"mz-switch mz-focusable",
|
|
455
|
+
size === "sm" && "mz-switch--sm",
|
|
456
|
+
size === "lg" && "mz-switch--lg",
|
|
457
|
+
className
|
|
458
|
+
),
|
|
459
|
+
...props,
|
|
460
|
+
children: /* @__PURE__ */ jsx(Switch$1.Thumb, { "data-slot": "switch-thumb", className: "mz-switch__thumb" })
|
|
461
|
+
}
|
|
462
|
+
);
|
|
463
|
+
}
|
|
464
|
+
function Slider({
|
|
465
|
+
className,
|
|
466
|
+
defaultValue,
|
|
467
|
+
value,
|
|
468
|
+
min = 0,
|
|
469
|
+
max = 100,
|
|
470
|
+
tone,
|
|
471
|
+
...props
|
|
472
|
+
}) {
|
|
473
|
+
const values = React39.useMemo(
|
|
474
|
+
() => Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min],
|
|
475
|
+
[value, defaultValue, min]
|
|
476
|
+
);
|
|
477
|
+
return /* @__PURE__ */ jsxs(
|
|
478
|
+
Slider$1.Root,
|
|
479
|
+
{
|
|
480
|
+
"data-slot": "slider",
|
|
481
|
+
"data-tone": tone,
|
|
482
|
+
defaultValue,
|
|
483
|
+
value,
|
|
484
|
+
min,
|
|
485
|
+
max,
|
|
486
|
+
className: cn("mz-slider", className),
|
|
487
|
+
...props,
|
|
488
|
+
children: [
|
|
489
|
+
/* @__PURE__ */ jsx(Slider$1.Track, { "data-slot": "slider-track", className: "mz-slider__track", children: /* @__PURE__ */ jsx(Slider$1.Range, { "data-slot": "slider-range", className: "mz-slider__range" }) }),
|
|
490
|
+
Array.from({ length: values.length }, (_, index) => /* @__PURE__ */ jsx(
|
|
491
|
+
Slider$1.Thumb,
|
|
492
|
+
{
|
|
493
|
+
"data-slot": "slider-thumb",
|
|
494
|
+
className: "mz-slider__thumb mz-focusable"
|
|
495
|
+
},
|
|
496
|
+
index
|
|
497
|
+
))
|
|
498
|
+
]
|
|
499
|
+
}
|
|
500
|
+
);
|
|
501
|
+
}
|
|
502
|
+
function Input({ className, type, inputSize = "md", ...props }) {
|
|
503
|
+
return /* @__PURE__ */ jsx(
|
|
504
|
+
"input",
|
|
505
|
+
{
|
|
506
|
+
type,
|
|
507
|
+
"data-slot": "input",
|
|
508
|
+
"data-size": inputSize,
|
|
509
|
+
className: cn(
|
|
510
|
+
"mz-input",
|
|
511
|
+
inputSize === "sm" && "mz-input--sm",
|
|
512
|
+
inputSize === "lg" && "mz-input--lg",
|
|
513
|
+
className
|
|
514
|
+
),
|
|
515
|
+
...props
|
|
516
|
+
}
|
|
517
|
+
);
|
|
518
|
+
}
|
|
519
|
+
function Textarea({ className, ...props }) {
|
|
520
|
+
return /* @__PURE__ */ jsx("textarea", { "data-slot": "textarea", className: cn("mz-textarea", className), ...props });
|
|
521
|
+
}
|
|
522
|
+
function Label({ className, ...props }) {
|
|
523
|
+
return /* @__PURE__ */ jsx(Label$1.Root, { "data-slot": "label", className: cn("mz-label", className), ...props });
|
|
524
|
+
}
|
|
525
|
+
function Field({ className, ...props }) {
|
|
526
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "field", className: cn("mz-field", className), ...props });
|
|
527
|
+
}
|
|
528
|
+
function FieldHint({ className, ...props }) {
|
|
529
|
+
return /* @__PURE__ */ jsx("p", { "data-slot": "field-hint", className: cn("mz-field__hint", className), ...props });
|
|
530
|
+
}
|
|
531
|
+
function FieldError({ className, ...props }) {
|
|
532
|
+
return /* @__PURE__ */ jsx(
|
|
533
|
+
"p",
|
|
534
|
+
{
|
|
535
|
+
"data-slot": "field-error",
|
|
536
|
+
role: "alert",
|
|
537
|
+
className: cn("mz-field__error", className),
|
|
538
|
+
...props
|
|
539
|
+
}
|
|
540
|
+
);
|
|
541
|
+
}
|
|
542
|
+
function Select({ ...props }) {
|
|
543
|
+
return /* @__PURE__ */ jsx(Select$1.Root, { "data-slot": "select", ...props });
|
|
544
|
+
}
|
|
545
|
+
function SelectGroup({ ...props }) {
|
|
546
|
+
return /* @__PURE__ */ jsx(Select$1.Group, { "data-slot": "select-group", ...props });
|
|
547
|
+
}
|
|
548
|
+
function SelectValue({ ...props }) {
|
|
549
|
+
return /* @__PURE__ */ jsx(Select$1.Value, { "data-slot": "select-value", ...props });
|
|
550
|
+
}
|
|
551
|
+
function SelectTrigger({
|
|
552
|
+
className,
|
|
553
|
+
size = "md",
|
|
554
|
+
tone,
|
|
555
|
+
children,
|
|
556
|
+
...props
|
|
557
|
+
}) {
|
|
558
|
+
return /* @__PURE__ */ jsxs(
|
|
559
|
+
Select$1.Trigger,
|
|
560
|
+
{
|
|
561
|
+
"data-slot": "select-trigger",
|
|
562
|
+
"data-size": size,
|
|
563
|
+
"data-tone": tone,
|
|
564
|
+
className: cn(
|
|
565
|
+
"mz-select-trigger mz-focusable",
|
|
566
|
+
size === "sm" && "mz-select-trigger--sm",
|
|
567
|
+
className
|
|
568
|
+
),
|
|
569
|
+
...props,
|
|
570
|
+
children: [
|
|
571
|
+
children,
|
|
572
|
+
/* @__PURE__ */ jsx(Select$1.Icon, { asChild: true, children: /* @__PURE__ */ jsx(ChevronDownIcon, { className: "mz-select-trigger__icon" }) })
|
|
573
|
+
]
|
|
574
|
+
}
|
|
575
|
+
);
|
|
576
|
+
}
|
|
577
|
+
function SelectContent({
|
|
578
|
+
className,
|
|
579
|
+
children,
|
|
580
|
+
position = "popper",
|
|
581
|
+
...props
|
|
582
|
+
}) {
|
|
583
|
+
return /* @__PURE__ */ jsx(Select$1.Portal, { children: /* @__PURE__ */ jsxs(
|
|
584
|
+
Select$1.Content,
|
|
585
|
+
{
|
|
586
|
+
"data-slot": "select-content",
|
|
587
|
+
className: cn(
|
|
588
|
+
"mz-panel mz-select-content",
|
|
589
|
+
position === "popper" && "mz-select-content--popper",
|
|
590
|
+
className
|
|
591
|
+
),
|
|
592
|
+
position,
|
|
593
|
+
...props,
|
|
594
|
+
children: [
|
|
595
|
+
/* @__PURE__ */ jsx(SelectScrollUpButton, {}),
|
|
596
|
+
/* @__PURE__ */ jsx(
|
|
597
|
+
Select$1.Viewport,
|
|
598
|
+
{
|
|
599
|
+
className: cn(
|
|
600
|
+
"mz-select-viewport",
|
|
601
|
+
position === "popper" && "mz-select-viewport--popper"
|
|
602
|
+
),
|
|
603
|
+
children
|
|
604
|
+
}
|
|
605
|
+
),
|
|
606
|
+
/* @__PURE__ */ jsx(SelectScrollDownButton, {})
|
|
607
|
+
]
|
|
608
|
+
}
|
|
609
|
+
) });
|
|
610
|
+
}
|
|
611
|
+
function SelectLabel({ className, ...props }) {
|
|
612
|
+
return /* @__PURE__ */ jsx(
|
|
613
|
+
Select$1.Label,
|
|
614
|
+
{
|
|
615
|
+
"data-slot": "select-label",
|
|
616
|
+
className: cn("mz-menu-label", className),
|
|
617
|
+
...props
|
|
618
|
+
}
|
|
619
|
+
);
|
|
620
|
+
}
|
|
621
|
+
function SelectItem({
|
|
622
|
+
className,
|
|
623
|
+
children,
|
|
624
|
+
...props
|
|
625
|
+
}) {
|
|
626
|
+
return /* @__PURE__ */ jsxs(Select$1.Item, { "data-slot": "select-item", className: cn("mz-item", className), ...props, children: [
|
|
627
|
+
/* @__PURE__ */ jsx("span", { className: "mz-item__indicator", children: /* @__PURE__ */ jsx(Select$1.ItemIndicator, { children: /* @__PURE__ */ jsx(CheckIcon, {}) }) }),
|
|
628
|
+
/* @__PURE__ */ jsx(Select$1.ItemText, { children })
|
|
629
|
+
] });
|
|
630
|
+
}
|
|
631
|
+
function SelectSeparator({
|
|
632
|
+
className,
|
|
633
|
+
...props
|
|
634
|
+
}) {
|
|
635
|
+
return /* @__PURE__ */ jsx(
|
|
636
|
+
Select$1.Separator,
|
|
637
|
+
{
|
|
638
|
+
"data-slot": "select-separator",
|
|
639
|
+
className: cn("mz-menu-separator", className),
|
|
640
|
+
...props
|
|
641
|
+
}
|
|
642
|
+
);
|
|
643
|
+
}
|
|
644
|
+
function SelectScrollUpButton({
|
|
645
|
+
className,
|
|
646
|
+
...props
|
|
647
|
+
}) {
|
|
648
|
+
return /* @__PURE__ */ jsx(
|
|
649
|
+
Select$1.ScrollUpButton,
|
|
650
|
+
{
|
|
651
|
+
"data-slot": "select-scroll-up-button",
|
|
652
|
+
className: cn("mz-select-scroll-button", className),
|
|
653
|
+
...props,
|
|
654
|
+
children: /* @__PURE__ */ jsx(ChevronUpIcon, { width: 16, height: 16 })
|
|
655
|
+
}
|
|
656
|
+
);
|
|
657
|
+
}
|
|
658
|
+
function SelectScrollDownButton({
|
|
659
|
+
className,
|
|
660
|
+
...props
|
|
661
|
+
}) {
|
|
662
|
+
return /* @__PURE__ */ jsx(
|
|
663
|
+
Select$1.ScrollDownButton,
|
|
664
|
+
{
|
|
665
|
+
"data-slot": "select-scroll-down-button",
|
|
666
|
+
className: cn("mz-select-scroll-button", className),
|
|
667
|
+
...props,
|
|
668
|
+
children: /* @__PURE__ */ jsx(ChevronDownIcon, { width: 16, height: 16 })
|
|
669
|
+
}
|
|
670
|
+
);
|
|
671
|
+
}
|
|
672
|
+
function Tabs({ className, ...props }) {
|
|
673
|
+
return /* @__PURE__ */ jsx(Tabs$1.Root, { "data-slot": "tabs", className: cn("mz-tabs", className), ...props });
|
|
674
|
+
}
|
|
675
|
+
function TabsList({
|
|
676
|
+
className,
|
|
677
|
+
variant = "default",
|
|
678
|
+
tone,
|
|
679
|
+
...props
|
|
680
|
+
}) {
|
|
681
|
+
return /* @__PURE__ */ jsx(
|
|
682
|
+
Tabs$1.List,
|
|
683
|
+
{
|
|
684
|
+
"data-slot": "tabs-list",
|
|
685
|
+
"data-variant": variant,
|
|
686
|
+
"data-tone": tone,
|
|
687
|
+
className: cn("mz-tabs-list", variant === "line" && "mz-tabs-list--line", className),
|
|
688
|
+
...props
|
|
689
|
+
}
|
|
690
|
+
);
|
|
691
|
+
}
|
|
692
|
+
function TabsTrigger({ className, ...props }) {
|
|
693
|
+
return /* @__PURE__ */ jsx(
|
|
694
|
+
Tabs$1.Trigger,
|
|
695
|
+
{
|
|
696
|
+
"data-slot": "tabs-trigger",
|
|
697
|
+
className: cn("mz-tabs-trigger mz-focusable", className),
|
|
698
|
+
...props
|
|
699
|
+
}
|
|
700
|
+
);
|
|
701
|
+
}
|
|
702
|
+
function TabsContent({ className, ...props }) {
|
|
703
|
+
return /* @__PURE__ */ jsx(
|
|
704
|
+
Tabs$1.Content,
|
|
705
|
+
{
|
|
706
|
+
"data-slot": "tabs-content",
|
|
707
|
+
className: cn("mz-tabs-content", className),
|
|
708
|
+
...props
|
|
709
|
+
}
|
|
710
|
+
);
|
|
711
|
+
}
|
|
712
|
+
function Card({
|
|
713
|
+
className,
|
|
714
|
+
interactive = false,
|
|
715
|
+
onClick,
|
|
716
|
+
onKeyDown,
|
|
717
|
+
...props
|
|
718
|
+
}) {
|
|
719
|
+
const clickable = interactive && Boolean(onClick);
|
|
720
|
+
const handleKeyDown = clickable ? (event) => {
|
|
721
|
+
onKeyDown?.(event);
|
|
722
|
+
if (event.defaultPrevented) return;
|
|
723
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
724
|
+
event.preventDefault();
|
|
725
|
+
event.currentTarget.click();
|
|
726
|
+
}
|
|
727
|
+
} : onKeyDown;
|
|
728
|
+
return /* @__PURE__ */ jsx(
|
|
729
|
+
"div",
|
|
730
|
+
{
|
|
731
|
+
"data-slot": "card",
|
|
732
|
+
role: clickable ? "button" : void 0,
|
|
733
|
+
tabIndex: clickable ? 0 : void 0,
|
|
734
|
+
className: cn(
|
|
735
|
+
"mz-card",
|
|
736
|
+
interactive && "mz-card--interactive",
|
|
737
|
+
clickable && "mz-focusable",
|
|
738
|
+
className
|
|
739
|
+
),
|
|
740
|
+
onClick,
|
|
741
|
+
onKeyDown: handleKeyDown,
|
|
742
|
+
...props
|
|
743
|
+
}
|
|
744
|
+
);
|
|
745
|
+
}
|
|
746
|
+
function CardHeader({ className, ...props }) {
|
|
747
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "card-header", className: cn("mz-card-header", className), ...props });
|
|
748
|
+
}
|
|
749
|
+
function CardTitle({ className, ...props }) {
|
|
750
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "card-title", className: cn("mz-card-title", className), ...props });
|
|
751
|
+
}
|
|
752
|
+
function CardDescription({ className, ...props }) {
|
|
753
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "card-description", className: cn("mz-card-description", className), ...props });
|
|
754
|
+
}
|
|
755
|
+
function CardAction({ className, ...props }) {
|
|
756
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "card-action", className: cn("mz-card-action", className), ...props });
|
|
757
|
+
}
|
|
758
|
+
function CardContent({ className, ...props }) {
|
|
759
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "card-content", className: cn("mz-card-content", className), ...props });
|
|
760
|
+
}
|
|
761
|
+
function CardFooter({ className, ...props }) {
|
|
762
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "card-footer", className: cn("mz-card-footer", className), ...props });
|
|
763
|
+
}
|
|
764
|
+
function Alert({
|
|
765
|
+
className,
|
|
766
|
+
tone = "primary",
|
|
767
|
+
...props
|
|
768
|
+
}) {
|
|
769
|
+
return /* @__PURE__ */ jsx(
|
|
770
|
+
"div",
|
|
771
|
+
{
|
|
772
|
+
"data-slot": "alert",
|
|
773
|
+
"data-tone": tone,
|
|
774
|
+
role: "alert",
|
|
775
|
+
className: cn("mz-alert", className),
|
|
776
|
+
...props
|
|
777
|
+
}
|
|
778
|
+
);
|
|
779
|
+
}
|
|
780
|
+
function AlertTitle({ className, ...props }) {
|
|
781
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "alert-title", className: cn("mz-alert-title", className), ...props });
|
|
782
|
+
}
|
|
783
|
+
function AlertDescription({ className, ...props }) {
|
|
784
|
+
return /* @__PURE__ */ jsx(
|
|
785
|
+
"div",
|
|
786
|
+
{
|
|
787
|
+
"data-slot": "alert-description",
|
|
788
|
+
className: cn("mz-alert-description", className),
|
|
789
|
+
...props
|
|
790
|
+
}
|
|
791
|
+
);
|
|
792
|
+
}
|
|
793
|
+
function Accordion({ className, ...props }) {
|
|
794
|
+
return /* @__PURE__ */ jsx(
|
|
795
|
+
Accordion$1.Root,
|
|
796
|
+
{
|
|
797
|
+
"data-slot": "accordion",
|
|
798
|
+
className: cn("mz-accordion", className),
|
|
799
|
+
...props
|
|
800
|
+
}
|
|
801
|
+
);
|
|
802
|
+
}
|
|
803
|
+
function AccordionItem({
|
|
804
|
+
className,
|
|
805
|
+
...props
|
|
806
|
+
}) {
|
|
807
|
+
return /* @__PURE__ */ jsx(
|
|
808
|
+
Accordion$1.Item,
|
|
809
|
+
{
|
|
810
|
+
"data-slot": "accordion-item",
|
|
811
|
+
className: cn("mz-accordion-item", className),
|
|
812
|
+
...props
|
|
813
|
+
}
|
|
814
|
+
);
|
|
815
|
+
}
|
|
816
|
+
function AccordionTrigger({
|
|
817
|
+
className,
|
|
818
|
+
children,
|
|
819
|
+
...props
|
|
820
|
+
}) {
|
|
821
|
+
return /* @__PURE__ */ jsx(Accordion$1.Header, { className: "mz-accordion-header", children: /* @__PURE__ */ jsxs(
|
|
822
|
+
Accordion$1.Trigger,
|
|
823
|
+
{
|
|
824
|
+
"data-slot": "accordion-trigger",
|
|
825
|
+
className: cn("mz-accordion-trigger mz-focusable", className),
|
|
826
|
+
...props,
|
|
827
|
+
children: [
|
|
828
|
+
children,
|
|
829
|
+
/* @__PURE__ */ jsx("span", { className: "mz-accordion-trigger__icon", "aria-hidden": "true", children: /* @__PURE__ */ jsx(ChevronDownIcon, {}) })
|
|
830
|
+
]
|
|
831
|
+
}
|
|
832
|
+
) });
|
|
833
|
+
}
|
|
834
|
+
function AccordionContent({
|
|
835
|
+
className,
|
|
836
|
+
children,
|
|
837
|
+
...props
|
|
838
|
+
}) {
|
|
839
|
+
return /* @__PURE__ */ jsx(
|
|
840
|
+
Accordion$1.Content,
|
|
841
|
+
{
|
|
842
|
+
"data-slot": "accordion-content",
|
|
843
|
+
className: cn("mz-accordion-content", className),
|
|
844
|
+
...props,
|
|
845
|
+
children: /* @__PURE__ */ jsx("div", { className: "mz-accordion-content__inner", children })
|
|
846
|
+
}
|
|
847
|
+
);
|
|
848
|
+
}
|
|
849
|
+
function Progress({
|
|
850
|
+
className,
|
|
851
|
+
value,
|
|
852
|
+
max = 100,
|
|
853
|
+
tone,
|
|
854
|
+
...props
|
|
855
|
+
}) {
|
|
856
|
+
const percent = max > 0 ? Math.min(Math.max(value ?? 0, 0), max) / max * 100 : 0;
|
|
857
|
+
return /* @__PURE__ */ jsx(
|
|
858
|
+
Progress$1.Root,
|
|
859
|
+
{
|
|
860
|
+
"data-slot": "progress",
|
|
861
|
+
"data-tone": tone,
|
|
862
|
+
value,
|
|
863
|
+
max,
|
|
864
|
+
className: cn("mz-progress", className),
|
|
865
|
+
...props,
|
|
866
|
+
children: /* @__PURE__ */ jsx(
|
|
867
|
+
Progress$1.Indicator,
|
|
868
|
+
{
|
|
869
|
+
"data-slot": "progress-indicator",
|
|
870
|
+
className: "mz-progress__indicator",
|
|
871
|
+
style: { transform: `translateX(-${100 - percent}%)` }
|
|
872
|
+
}
|
|
873
|
+
)
|
|
874
|
+
}
|
|
875
|
+
);
|
|
876
|
+
}
|
|
877
|
+
function Avatar({
|
|
878
|
+
className,
|
|
879
|
+
size = "md",
|
|
880
|
+
...props
|
|
881
|
+
}) {
|
|
882
|
+
return /* @__PURE__ */ jsx(
|
|
883
|
+
Avatar$1.Root,
|
|
884
|
+
{
|
|
885
|
+
"data-slot": "avatar",
|
|
886
|
+
"data-size": size,
|
|
887
|
+
className: cn(
|
|
888
|
+
"mz-avatar",
|
|
889
|
+
size === "sm" && "mz-avatar--sm",
|
|
890
|
+
size === "lg" && "mz-avatar--lg",
|
|
891
|
+
className
|
|
892
|
+
),
|
|
893
|
+
...props
|
|
894
|
+
}
|
|
895
|
+
);
|
|
896
|
+
}
|
|
897
|
+
function AvatarImage({ className, ...props }) {
|
|
898
|
+
return /* @__PURE__ */ jsx(
|
|
899
|
+
Avatar$1.Image,
|
|
900
|
+
{
|
|
901
|
+
"data-slot": "avatar-image",
|
|
902
|
+
className: cn("mz-avatar__image", className),
|
|
903
|
+
...props
|
|
904
|
+
}
|
|
905
|
+
);
|
|
906
|
+
}
|
|
907
|
+
function AvatarFallback({
|
|
908
|
+
className,
|
|
909
|
+
...props
|
|
910
|
+
}) {
|
|
911
|
+
return /* @__PURE__ */ jsx(
|
|
912
|
+
Avatar$1.Fallback,
|
|
913
|
+
{
|
|
914
|
+
"data-slot": "avatar-fallback",
|
|
915
|
+
className: cn("mz-avatar__fallback", className),
|
|
916
|
+
...props
|
|
917
|
+
}
|
|
918
|
+
);
|
|
919
|
+
}
|
|
920
|
+
function Separator({
|
|
921
|
+
className,
|
|
922
|
+
orientation = "horizontal",
|
|
923
|
+
decorative = true,
|
|
924
|
+
...props
|
|
925
|
+
}) {
|
|
926
|
+
return /* @__PURE__ */ jsx(
|
|
927
|
+
Separator$1.Root,
|
|
928
|
+
{
|
|
929
|
+
"data-slot": "separator",
|
|
930
|
+
decorative,
|
|
931
|
+
orientation,
|
|
932
|
+
className: cn("mz-separator", className),
|
|
933
|
+
...props
|
|
934
|
+
}
|
|
935
|
+
);
|
|
936
|
+
}
|
|
937
|
+
function Skeleton({ className, ...props }) {
|
|
938
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "skeleton", className: cn("mz-skeleton", className), ...props });
|
|
939
|
+
}
|
|
940
|
+
function Spinner({ className, label = "Loading", children, ...props }) {
|
|
941
|
+
return /* @__PURE__ */ jsxs(
|
|
942
|
+
"span",
|
|
943
|
+
{
|
|
944
|
+
"data-slot": "spinner",
|
|
945
|
+
role: label === null ? void 0 : "status",
|
|
946
|
+
"aria-hidden": label === null ? true : void 0,
|
|
947
|
+
className: cn("mz-spinner", className),
|
|
948
|
+
...props,
|
|
949
|
+
children: [
|
|
950
|
+
/* @__PURE__ */ jsx(SpinnerIcon, {}),
|
|
951
|
+
label === null ? null : /* @__PURE__ */ jsx("span", { className: "mz-sr-only", children: label }),
|
|
952
|
+
children
|
|
953
|
+
]
|
|
954
|
+
}
|
|
955
|
+
);
|
|
956
|
+
}
|
|
957
|
+
function Dialog({ ...props }) {
|
|
958
|
+
return /* @__PURE__ */ jsx(Dialog$1.Root, { "data-slot": "dialog", ...props });
|
|
959
|
+
}
|
|
960
|
+
function DialogTrigger({ ...props }) {
|
|
961
|
+
return /* @__PURE__ */ jsx(Dialog$1.Trigger, { "data-slot": "dialog-trigger", ...props });
|
|
962
|
+
}
|
|
963
|
+
function DialogPortal({ ...props }) {
|
|
964
|
+
return /* @__PURE__ */ jsx(Dialog$1.Portal, { "data-slot": "dialog-portal", ...props });
|
|
965
|
+
}
|
|
966
|
+
function DialogClose({ ...props }) {
|
|
967
|
+
return /* @__PURE__ */ jsx(Dialog$1.Close, { "data-slot": "dialog-close", ...props });
|
|
968
|
+
}
|
|
969
|
+
function DialogOverlay({
|
|
970
|
+
className,
|
|
971
|
+
...props
|
|
972
|
+
}) {
|
|
973
|
+
return /* @__PURE__ */ jsx(
|
|
974
|
+
Dialog$1.Overlay,
|
|
975
|
+
{
|
|
976
|
+
"data-slot": "dialog-overlay",
|
|
977
|
+
className: cn("mz-dialog-overlay", className),
|
|
978
|
+
...props
|
|
979
|
+
}
|
|
980
|
+
);
|
|
981
|
+
}
|
|
982
|
+
function DialogContent({
|
|
983
|
+
className,
|
|
984
|
+
children,
|
|
985
|
+
showCloseButton = true,
|
|
986
|
+
closeLabel = "Close",
|
|
987
|
+
...props
|
|
988
|
+
}) {
|
|
989
|
+
return /* @__PURE__ */ jsxs(DialogPortal, { children: [
|
|
990
|
+
/* @__PURE__ */ jsx(DialogOverlay, {}),
|
|
991
|
+
/* @__PURE__ */ jsxs(
|
|
992
|
+
Dialog$1.Content,
|
|
993
|
+
{
|
|
994
|
+
"data-slot": "dialog-content",
|
|
995
|
+
className: cn("mz-panel mz-dialog-content", className),
|
|
996
|
+
...props,
|
|
997
|
+
children: [
|
|
998
|
+
children,
|
|
999
|
+
showCloseButton ? /* @__PURE__ */ jsxs(Dialog$1.Close, { "data-slot": "dialog-close", className: "mz-dialog-close mz-focusable", children: [
|
|
1000
|
+
/* @__PURE__ */ jsx(XIcon, {}),
|
|
1001
|
+
/* @__PURE__ */ jsx("span", { className: "mz-sr-only", children: closeLabel })
|
|
1002
|
+
] }) : null
|
|
1003
|
+
]
|
|
1004
|
+
}
|
|
1005
|
+
)
|
|
1006
|
+
] });
|
|
1007
|
+
}
|
|
1008
|
+
function DialogHeader({ className, ...props }) {
|
|
1009
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "dialog-header", className: cn("mz-dialog-header", className), ...props });
|
|
1010
|
+
}
|
|
1011
|
+
function DialogFooter({ className, ...props }) {
|
|
1012
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "dialog-footer", className: cn("mz-dialog-footer", className), ...props });
|
|
1013
|
+
}
|
|
1014
|
+
function DialogTitle({ className, ...props }) {
|
|
1015
|
+
return /* @__PURE__ */ jsx(
|
|
1016
|
+
Dialog$1.Title,
|
|
1017
|
+
{
|
|
1018
|
+
"data-slot": "dialog-title",
|
|
1019
|
+
className: cn("mz-dialog-title", className),
|
|
1020
|
+
...props
|
|
1021
|
+
}
|
|
1022
|
+
);
|
|
1023
|
+
}
|
|
1024
|
+
function DialogDescription({
|
|
1025
|
+
className,
|
|
1026
|
+
...props
|
|
1027
|
+
}) {
|
|
1028
|
+
return /* @__PURE__ */ jsx(
|
|
1029
|
+
Dialog$1.Description,
|
|
1030
|
+
{
|
|
1031
|
+
"data-slot": "dialog-description",
|
|
1032
|
+
className: cn("mz-dialog-description", className),
|
|
1033
|
+
...props
|
|
1034
|
+
}
|
|
1035
|
+
);
|
|
1036
|
+
}
|
|
1037
|
+
function Popover({ ...props }) {
|
|
1038
|
+
return /* @__PURE__ */ jsx(Popover$1.Root, { "data-slot": "popover", ...props });
|
|
1039
|
+
}
|
|
1040
|
+
function PopoverTrigger({ ...props }) {
|
|
1041
|
+
return /* @__PURE__ */ jsx(Popover$1.Trigger, { "data-slot": "popover-trigger", ...props });
|
|
1042
|
+
}
|
|
1043
|
+
function PopoverAnchor({ ...props }) {
|
|
1044
|
+
return /* @__PURE__ */ jsx(Popover$1.Anchor, { "data-slot": "popover-anchor", ...props });
|
|
1045
|
+
}
|
|
1046
|
+
function PopoverContent({
|
|
1047
|
+
className,
|
|
1048
|
+
align = "center",
|
|
1049
|
+
sideOffset = 6,
|
|
1050
|
+
...props
|
|
1051
|
+
}) {
|
|
1052
|
+
return /* @__PURE__ */ jsx(Popover$1.Portal, { children: /* @__PURE__ */ jsx(
|
|
1053
|
+
Popover$1.Content,
|
|
1054
|
+
{
|
|
1055
|
+
"data-slot": "popover-content",
|
|
1056
|
+
align,
|
|
1057
|
+
sideOffset,
|
|
1058
|
+
className: cn("mz-panel mz-popover-content", className),
|
|
1059
|
+
...props
|
|
1060
|
+
}
|
|
1061
|
+
) });
|
|
1062
|
+
}
|
|
1063
|
+
function PopoverHeader({ className, ...props }) {
|
|
1064
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "popover-header", className: cn("mz-popover-header", className), ...props });
|
|
1065
|
+
}
|
|
1066
|
+
function PopoverTitle({ className, ...props }) {
|
|
1067
|
+
return /* @__PURE__ */ jsx("h2", { "data-slot": "popover-title", className: cn("mz-popover-title", className), ...props });
|
|
1068
|
+
}
|
|
1069
|
+
function PopoverDescription({ className, ...props }) {
|
|
1070
|
+
return /* @__PURE__ */ jsx(
|
|
1071
|
+
"p",
|
|
1072
|
+
{
|
|
1073
|
+
"data-slot": "popover-description",
|
|
1074
|
+
className: cn("mz-popover-description", className),
|
|
1075
|
+
...props
|
|
1076
|
+
}
|
|
1077
|
+
);
|
|
1078
|
+
}
|
|
1079
|
+
function DropdownMenu({ ...props }) {
|
|
1080
|
+
return /* @__PURE__ */ jsx(DropdownMenu$1.Root, { "data-slot": "dropdown-menu", ...props });
|
|
1081
|
+
}
|
|
1082
|
+
function DropdownMenuPortal({ ...props }) {
|
|
1083
|
+
return /* @__PURE__ */ jsx(DropdownMenu$1.Portal, { "data-slot": "dropdown-menu-portal", ...props });
|
|
1084
|
+
}
|
|
1085
|
+
function DropdownMenuTrigger({
|
|
1086
|
+
...props
|
|
1087
|
+
}) {
|
|
1088
|
+
return /* @__PURE__ */ jsx(DropdownMenu$1.Trigger, { "data-slot": "dropdown-menu-trigger", ...props });
|
|
1089
|
+
}
|
|
1090
|
+
function DropdownMenuContent({
|
|
1091
|
+
className,
|
|
1092
|
+
sideOffset = 6,
|
|
1093
|
+
...props
|
|
1094
|
+
}) {
|
|
1095
|
+
return /* @__PURE__ */ jsx(DropdownMenu$1.Portal, { children: /* @__PURE__ */ jsx(
|
|
1096
|
+
DropdownMenu$1.Content,
|
|
1097
|
+
{
|
|
1098
|
+
"data-slot": "dropdown-menu-content",
|
|
1099
|
+
sideOffset,
|
|
1100
|
+
className: cn("mz-panel mz-menu-content", className),
|
|
1101
|
+
...props
|
|
1102
|
+
}
|
|
1103
|
+
) });
|
|
1104
|
+
}
|
|
1105
|
+
function DropdownMenuGroup({ ...props }) {
|
|
1106
|
+
return /* @__PURE__ */ jsx(DropdownMenu$1.Group, { "data-slot": "dropdown-menu-group", ...props });
|
|
1107
|
+
}
|
|
1108
|
+
function DropdownMenuItem({
|
|
1109
|
+
className,
|
|
1110
|
+
inset,
|
|
1111
|
+
variant = "default",
|
|
1112
|
+
...props
|
|
1113
|
+
}) {
|
|
1114
|
+
return /* @__PURE__ */ jsx(
|
|
1115
|
+
DropdownMenu$1.Item,
|
|
1116
|
+
{
|
|
1117
|
+
"data-slot": "dropdown-menu-item",
|
|
1118
|
+
"data-inset": inset,
|
|
1119
|
+
"data-variant": variant,
|
|
1120
|
+
className: cn(
|
|
1121
|
+
"mz-item",
|
|
1122
|
+
inset ? "mz-item--inset" : "mz-item--plain",
|
|
1123
|
+
variant === "destructive" && "mz-item--destructive",
|
|
1124
|
+
className
|
|
1125
|
+
),
|
|
1126
|
+
...props
|
|
1127
|
+
}
|
|
1128
|
+
);
|
|
1129
|
+
}
|
|
1130
|
+
function DropdownMenuCheckboxItem({
|
|
1131
|
+
className,
|
|
1132
|
+
children,
|
|
1133
|
+
checked,
|
|
1134
|
+
...props
|
|
1135
|
+
}) {
|
|
1136
|
+
return /* @__PURE__ */ jsxs(
|
|
1137
|
+
DropdownMenu$1.CheckboxItem,
|
|
1138
|
+
{
|
|
1139
|
+
"data-slot": "dropdown-menu-checkbox-item",
|
|
1140
|
+
className: cn("mz-item", className),
|
|
1141
|
+
checked,
|
|
1142
|
+
...props,
|
|
1143
|
+
children: [
|
|
1144
|
+
/* @__PURE__ */ jsx("span", { className: "mz-item__indicator", children: /* @__PURE__ */ jsx(DropdownMenu$1.ItemIndicator, { children: /* @__PURE__ */ jsx(CheckIcon, {}) }) }),
|
|
1145
|
+
children
|
|
1146
|
+
]
|
|
1147
|
+
}
|
|
1148
|
+
);
|
|
1149
|
+
}
|
|
1150
|
+
function DropdownMenuRadioGroup({
|
|
1151
|
+
...props
|
|
1152
|
+
}) {
|
|
1153
|
+
return /* @__PURE__ */ jsx(DropdownMenu$1.RadioGroup, { "data-slot": "dropdown-menu-radio-group", ...props });
|
|
1154
|
+
}
|
|
1155
|
+
function DropdownMenuRadioItem({
|
|
1156
|
+
className,
|
|
1157
|
+
children,
|
|
1158
|
+
...props
|
|
1159
|
+
}) {
|
|
1160
|
+
return /* @__PURE__ */ jsxs(
|
|
1161
|
+
DropdownMenu$1.RadioItem,
|
|
1162
|
+
{
|
|
1163
|
+
"data-slot": "dropdown-menu-radio-item",
|
|
1164
|
+
className: cn("mz-item", className),
|
|
1165
|
+
...props,
|
|
1166
|
+
children: [
|
|
1167
|
+
/* @__PURE__ */ jsx("span", { className: "mz-item__indicator", children: /* @__PURE__ */ jsx(DropdownMenu$1.ItemIndicator, { children: /* @__PURE__ */ jsx(DotIcon, {}) }) }),
|
|
1168
|
+
children
|
|
1169
|
+
]
|
|
1170
|
+
}
|
|
1171
|
+
);
|
|
1172
|
+
}
|
|
1173
|
+
function DropdownMenuLabel({
|
|
1174
|
+
className,
|
|
1175
|
+
inset,
|
|
1176
|
+
...props
|
|
1177
|
+
}) {
|
|
1178
|
+
return /* @__PURE__ */ jsx(
|
|
1179
|
+
DropdownMenu$1.Label,
|
|
1180
|
+
{
|
|
1181
|
+
"data-slot": "dropdown-menu-label",
|
|
1182
|
+
"data-inset": inset,
|
|
1183
|
+
className: cn("mz-menu-label", inset && "mz-menu-label--inset", className),
|
|
1184
|
+
...props
|
|
1185
|
+
}
|
|
1186
|
+
);
|
|
1187
|
+
}
|
|
1188
|
+
function DropdownMenuSeparator({
|
|
1189
|
+
className,
|
|
1190
|
+
...props
|
|
1191
|
+
}) {
|
|
1192
|
+
return /* @__PURE__ */ jsx(
|
|
1193
|
+
DropdownMenu$1.Separator,
|
|
1194
|
+
{
|
|
1195
|
+
"data-slot": "dropdown-menu-separator",
|
|
1196
|
+
className: cn("mz-menu-separator", className),
|
|
1197
|
+
...props
|
|
1198
|
+
}
|
|
1199
|
+
);
|
|
1200
|
+
}
|
|
1201
|
+
function DropdownMenuShortcut({ className, ...props }) {
|
|
1202
|
+
return /* @__PURE__ */ jsx(
|
|
1203
|
+
"span",
|
|
1204
|
+
{
|
|
1205
|
+
"data-slot": "dropdown-menu-shortcut",
|
|
1206
|
+
className: cn("mz-menu-shortcut", className),
|
|
1207
|
+
...props
|
|
1208
|
+
}
|
|
1209
|
+
);
|
|
1210
|
+
}
|
|
1211
|
+
function DropdownMenuSub({ ...props }) {
|
|
1212
|
+
return /* @__PURE__ */ jsx(DropdownMenu$1.Sub, { "data-slot": "dropdown-menu-sub", ...props });
|
|
1213
|
+
}
|
|
1214
|
+
function DropdownMenuSubTrigger({
|
|
1215
|
+
className,
|
|
1216
|
+
inset,
|
|
1217
|
+
children,
|
|
1218
|
+
...props
|
|
1219
|
+
}) {
|
|
1220
|
+
return /* @__PURE__ */ jsxs(
|
|
1221
|
+
DropdownMenu$1.SubTrigger,
|
|
1222
|
+
{
|
|
1223
|
+
"data-slot": "dropdown-menu-sub-trigger",
|
|
1224
|
+
"data-inset": inset,
|
|
1225
|
+
className: cn(
|
|
1226
|
+
"mz-item mz-menu-sub-trigger",
|
|
1227
|
+
inset ? "mz-item--inset" : "mz-item--plain",
|
|
1228
|
+
className
|
|
1229
|
+
),
|
|
1230
|
+
...props,
|
|
1231
|
+
children: [
|
|
1232
|
+
children,
|
|
1233
|
+
/* @__PURE__ */ jsx(ChevronRightIcon, { className: "mz-menu-sub-trigger__icon" })
|
|
1234
|
+
]
|
|
1235
|
+
}
|
|
1236
|
+
);
|
|
1237
|
+
}
|
|
1238
|
+
function DropdownMenuSubContent({
|
|
1239
|
+
className,
|
|
1240
|
+
...props
|
|
1241
|
+
}) {
|
|
1242
|
+
return /* @__PURE__ */ jsx(
|
|
1243
|
+
DropdownMenu$1.SubContent,
|
|
1244
|
+
{
|
|
1245
|
+
"data-slot": "dropdown-menu-sub-content",
|
|
1246
|
+
className: cn("mz-panel mz-menu-content", className),
|
|
1247
|
+
...props
|
|
1248
|
+
}
|
|
1249
|
+
);
|
|
1250
|
+
}
|
|
1251
|
+
var TooltipProviderPresence = React39.createContext(false);
|
|
1252
|
+
function TooltipProvider({
|
|
1253
|
+
delayDuration = 200,
|
|
1254
|
+
children,
|
|
1255
|
+
...props
|
|
1256
|
+
}) {
|
|
1257
|
+
return /* @__PURE__ */ jsx(TooltipProviderPresence.Provider, { value: true, children: /* @__PURE__ */ jsx(
|
|
1258
|
+
Tooltip$1.Provider,
|
|
1259
|
+
{
|
|
1260
|
+
"data-slot": "tooltip-provider",
|
|
1261
|
+
delayDuration,
|
|
1262
|
+
...props,
|
|
1263
|
+
children
|
|
1264
|
+
}
|
|
1265
|
+
) });
|
|
1266
|
+
}
|
|
1267
|
+
function Tooltip({ ...props }) {
|
|
1268
|
+
const hasProvider = React39.useContext(TooltipProviderPresence);
|
|
1269
|
+
const root = /* @__PURE__ */ jsx(Tooltip$1.Root, { "data-slot": "tooltip", ...props });
|
|
1270
|
+
return hasProvider ? root : /* @__PURE__ */ jsx(TooltipProvider, { children: root });
|
|
1271
|
+
}
|
|
1272
|
+
function TooltipTrigger({ ...props }) {
|
|
1273
|
+
return /* @__PURE__ */ jsx(Tooltip$1.Trigger, { "data-slot": "tooltip-trigger", ...props });
|
|
1274
|
+
}
|
|
1275
|
+
function TooltipContent({
|
|
1276
|
+
className,
|
|
1277
|
+
sideOffset = 6,
|
|
1278
|
+
children,
|
|
1279
|
+
...props
|
|
1280
|
+
}) {
|
|
1281
|
+
return /* @__PURE__ */ jsx(Tooltip$1.Portal, { children: /* @__PURE__ */ jsxs(
|
|
1282
|
+
Tooltip$1.Content,
|
|
1283
|
+
{
|
|
1284
|
+
"data-slot": "tooltip-content",
|
|
1285
|
+
sideOffset,
|
|
1286
|
+
className: cn("mz-tooltip-content", className),
|
|
1287
|
+
...props,
|
|
1288
|
+
children: [
|
|
1289
|
+
children,
|
|
1290
|
+
/* @__PURE__ */ jsx(Tooltip$1.Arrow, { className: "mz-tooltip-arrow", width: 10, height: 5 })
|
|
1291
|
+
]
|
|
1292
|
+
}
|
|
1293
|
+
) });
|
|
1294
|
+
}
|
|
1295
|
+
function Sheet({ ...props }) {
|
|
1296
|
+
return /* @__PURE__ */ jsx(Dialog$1.Root, { "data-slot": "sheet", ...props });
|
|
1297
|
+
}
|
|
1298
|
+
function SheetTrigger({ ...props }) {
|
|
1299
|
+
return /* @__PURE__ */ jsx(Dialog$1.Trigger, { "data-slot": "sheet-trigger", ...props });
|
|
1300
|
+
}
|
|
1301
|
+
function SheetClose({ ...props }) {
|
|
1302
|
+
return /* @__PURE__ */ jsx(Dialog$1.Close, { "data-slot": "sheet-close", ...props });
|
|
1303
|
+
}
|
|
1304
|
+
function SheetPortal({ ...props }) {
|
|
1305
|
+
return /* @__PURE__ */ jsx(Dialog$1.Portal, { "data-slot": "sheet-portal", ...props });
|
|
1306
|
+
}
|
|
1307
|
+
function SheetOverlay({ className, ...props }) {
|
|
1308
|
+
return /* @__PURE__ */ jsx(
|
|
1309
|
+
Dialog$1.Overlay,
|
|
1310
|
+
{
|
|
1311
|
+
"data-slot": "sheet-overlay",
|
|
1312
|
+
className: cn("mz-dialog-overlay", className),
|
|
1313
|
+
...props
|
|
1314
|
+
}
|
|
1315
|
+
);
|
|
1316
|
+
}
|
|
1317
|
+
function SheetContent({
|
|
1318
|
+
className,
|
|
1319
|
+
children,
|
|
1320
|
+
side = "right",
|
|
1321
|
+
showCloseButton = true,
|
|
1322
|
+
closeLabel = "Close",
|
|
1323
|
+
...props
|
|
1324
|
+
}) {
|
|
1325
|
+
return /* @__PURE__ */ jsxs(SheetPortal, { children: [
|
|
1326
|
+
/* @__PURE__ */ jsx(SheetOverlay, {}),
|
|
1327
|
+
/* @__PURE__ */ jsxs(
|
|
1328
|
+
Dialog$1.Content,
|
|
1329
|
+
{
|
|
1330
|
+
"data-slot": "sheet-content",
|
|
1331
|
+
"data-side": side,
|
|
1332
|
+
className: cn("mz-sheet", className),
|
|
1333
|
+
...props,
|
|
1334
|
+
children: [
|
|
1335
|
+
children,
|
|
1336
|
+
showCloseButton ? /* @__PURE__ */ jsxs(Dialog$1.Close, { "data-slot": "sheet-close", className: "mz-dialog-close mz-focusable", children: [
|
|
1337
|
+
/* @__PURE__ */ jsx(XIcon, {}),
|
|
1338
|
+
/* @__PURE__ */ jsx("span", { className: "mz-sr-only", children: closeLabel })
|
|
1339
|
+
] }) : null
|
|
1340
|
+
]
|
|
1341
|
+
}
|
|
1342
|
+
)
|
|
1343
|
+
] });
|
|
1344
|
+
}
|
|
1345
|
+
function SheetHeader({ className, ...props }) {
|
|
1346
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "sheet-header", className: cn("mz-sheet__header", className), ...props });
|
|
1347
|
+
}
|
|
1348
|
+
function SheetFooter({ className, ...props }) {
|
|
1349
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "sheet-footer", className: cn("mz-sheet__footer", className), ...props });
|
|
1350
|
+
}
|
|
1351
|
+
function SheetTitle({ className, ...props }) {
|
|
1352
|
+
return /* @__PURE__ */ jsx(
|
|
1353
|
+
Dialog$1.Title,
|
|
1354
|
+
{
|
|
1355
|
+
"data-slot": "sheet-title",
|
|
1356
|
+
className: cn("mz-dialog-title", className),
|
|
1357
|
+
...props
|
|
1358
|
+
}
|
|
1359
|
+
);
|
|
1360
|
+
}
|
|
1361
|
+
function SheetDescription({
|
|
1362
|
+
className,
|
|
1363
|
+
...props
|
|
1364
|
+
}) {
|
|
1365
|
+
return /* @__PURE__ */ jsx(
|
|
1366
|
+
Dialog$1.Description,
|
|
1367
|
+
{
|
|
1368
|
+
"data-slot": "sheet-description",
|
|
1369
|
+
className: cn("mz-dialog-description", className),
|
|
1370
|
+
...props
|
|
1371
|
+
}
|
|
1372
|
+
);
|
|
1373
|
+
}
|
|
1374
|
+
function useIsMobile(breakpoint = 768) {
|
|
1375
|
+
const [isMobile, setIsMobile] = React39.useState(false);
|
|
1376
|
+
React39.useEffect(() => {
|
|
1377
|
+
const query = window.matchMedia(`(max-width: ${breakpoint - 1}px)`);
|
|
1378
|
+
const update = () => setIsMobile(query.matches);
|
|
1379
|
+
update();
|
|
1380
|
+
query.addEventListener("change", update);
|
|
1381
|
+
return () => query.removeEventListener("change", update);
|
|
1382
|
+
}, [breakpoint]);
|
|
1383
|
+
return isMobile;
|
|
1384
|
+
}
|
|
1385
|
+
var STORAGE_KEY = "morze-ui-sidebar";
|
|
1386
|
+
var SHORTCUT = "b";
|
|
1387
|
+
var SidebarContext = React39.createContext(null);
|
|
1388
|
+
function useSidebar() {
|
|
1389
|
+
const context = React39.useContext(SidebarContext);
|
|
1390
|
+
if (!context) throw new Error("useSidebar must be used inside <SidebarProvider>");
|
|
1391
|
+
return context;
|
|
1392
|
+
}
|
|
1393
|
+
function readStored2(key) {
|
|
1394
|
+
if (!key || typeof window === "undefined") return null;
|
|
1395
|
+
try {
|
|
1396
|
+
const raw = window.localStorage.getItem(key);
|
|
1397
|
+
return raw === null ? null : raw === "true";
|
|
1398
|
+
} catch {
|
|
1399
|
+
return null;
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
function SidebarProvider({
|
|
1403
|
+
defaultOpen = true,
|
|
1404
|
+
open: openProp,
|
|
1405
|
+
onOpenChange,
|
|
1406
|
+
storageKey = STORAGE_KEY,
|
|
1407
|
+
mobileBreakpoint = 768,
|
|
1408
|
+
className,
|
|
1409
|
+
style,
|
|
1410
|
+
children,
|
|
1411
|
+
...props
|
|
1412
|
+
}) {
|
|
1413
|
+
const isMobile = useIsMobile(mobileBreakpoint);
|
|
1414
|
+
const [openMobile, setOpenMobile] = React39.useState(false);
|
|
1415
|
+
const [internalOpen, setInternalOpen] = React39.useState(defaultOpen);
|
|
1416
|
+
React39.useEffect(() => {
|
|
1417
|
+
const stored = readStored2(storageKey);
|
|
1418
|
+
if (stored !== null) setInternalOpen(stored);
|
|
1419
|
+
}, [storageKey]);
|
|
1420
|
+
const open = openProp ?? internalOpen;
|
|
1421
|
+
const setOpen = React39.useCallback(
|
|
1422
|
+
(next) => {
|
|
1423
|
+
if (openProp === void 0) setInternalOpen(next);
|
|
1424
|
+
onOpenChange?.(next);
|
|
1425
|
+
if (!storageKey || typeof window === "undefined") return;
|
|
1426
|
+
try {
|
|
1427
|
+
window.localStorage.setItem(storageKey, String(next));
|
|
1428
|
+
} catch {
|
|
1429
|
+
}
|
|
1430
|
+
},
|
|
1431
|
+
[openProp, onOpenChange, storageKey]
|
|
1432
|
+
);
|
|
1433
|
+
const toggleSidebar = React39.useCallback(() => {
|
|
1434
|
+
if (isMobile) setOpenMobile((current) => !current);
|
|
1435
|
+
else setOpen(!open);
|
|
1436
|
+
}, [isMobile, open, setOpen]);
|
|
1437
|
+
React39.useEffect(() => {
|
|
1438
|
+
const onKeyDown = (event) => {
|
|
1439
|
+
if (event.key.toLowerCase() !== SHORTCUT || !(event.metaKey || event.ctrlKey)) return;
|
|
1440
|
+
event.preventDefault();
|
|
1441
|
+
toggleSidebar();
|
|
1442
|
+
};
|
|
1443
|
+
window.addEventListener("keydown", onKeyDown);
|
|
1444
|
+
return () => window.removeEventListener("keydown", onKeyDown);
|
|
1445
|
+
}, [toggleSidebar]);
|
|
1446
|
+
const value = React39.useMemo(
|
|
1447
|
+
() => ({
|
|
1448
|
+
state: open ? "expanded" : "collapsed",
|
|
1449
|
+
open,
|
|
1450
|
+
setOpen,
|
|
1451
|
+
openMobile,
|
|
1452
|
+
setOpenMobile,
|
|
1453
|
+
isMobile,
|
|
1454
|
+
toggleSidebar
|
|
1455
|
+
}),
|
|
1456
|
+
[open, setOpen, openMobile, isMobile, toggleSidebar]
|
|
1457
|
+
);
|
|
1458
|
+
return /* @__PURE__ */ jsx(SidebarContext.Provider, { value, children: /* @__PURE__ */ jsx(
|
|
1459
|
+
"div",
|
|
1460
|
+
{
|
|
1461
|
+
"data-slot": "sidebar-wrapper",
|
|
1462
|
+
"data-state": value.state,
|
|
1463
|
+
className: cn("mz-sidebar-layout", className),
|
|
1464
|
+
style,
|
|
1465
|
+
...props,
|
|
1466
|
+
children
|
|
1467
|
+
}
|
|
1468
|
+
) });
|
|
1469
|
+
}
|
|
1470
|
+
function Sidebar({
|
|
1471
|
+
side = "left",
|
|
1472
|
+
variant = "inset",
|
|
1473
|
+
collapsible = "icon",
|
|
1474
|
+
mobileTitle = "Navigation",
|
|
1475
|
+
mobileDescription = "Application sections",
|
|
1476
|
+
className,
|
|
1477
|
+
children,
|
|
1478
|
+
...props
|
|
1479
|
+
}) {
|
|
1480
|
+
const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
|
|
1481
|
+
if (isMobile && collapsible !== "none") {
|
|
1482
|
+
return /* @__PURE__ */ jsx(Sheet, { open: openMobile, onOpenChange: setOpenMobile, children: /* @__PURE__ */ jsxs(
|
|
1483
|
+
SheetContent,
|
|
1484
|
+
{
|
|
1485
|
+
side,
|
|
1486
|
+
showCloseButton: false,
|
|
1487
|
+
"data-slot": "sidebar",
|
|
1488
|
+
"data-mobile": "true",
|
|
1489
|
+
className: cn("mz-sidebar--mobile", className),
|
|
1490
|
+
children: [
|
|
1491
|
+
/* @__PURE__ */ jsxs(SheetHeader, { className: "mz-sr-only", children: [
|
|
1492
|
+
/* @__PURE__ */ jsx(SheetTitle, { children: mobileTitle }),
|
|
1493
|
+
/* @__PURE__ */ jsx(SheetDescription, { children: mobileDescription })
|
|
1494
|
+
] }),
|
|
1495
|
+
/* @__PURE__ */ jsx("div", { className: "mz-sidebar__inner", children })
|
|
1496
|
+
]
|
|
1497
|
+
}
|
|
1498
|
+
) });
|
|
1499
|
+
}
|
|
1500
|
+
return /* @__PURE__ */ jsx(
|
|
1501
|
+
"div",
|
|
1502
|
+
{
|
|
1503
|
+
"data-slot": "sidebar",
|
|
1504
|
+
"data-state": state,
|
|
1505
|
+
"data-side": side,
|
|
1506
|
+
"data-variant": variant,
|
|
1507
|
+
"data-collapsible": collapsible === "none" ? void 0 : collapsible,
|
|
1508
|
+
className: cn("mz-sidebar", className),
|
|
1509
|
+
...props,
|
|
1510
|
+
children: /* @__PURE__ */ jsx("div", { className: "mz-sidebar__inner", children })
|
|
1511
|
+
}
|
|
1512
|
+
);
|
|
1513
|
+
}
|
|
1514
|
+
function SidebarTrigger({
|
|
1515
|
+
className,
|
|
1516
|
+
onClick,
|
|
1517
|
+
label = "Toggle sidebar",
|
|
1518
|
+
...props
|
|
1519
|
+
}) {
|
|
1520
|
+
const { toggleSidebar, state } = useSidebar();
|
|
1521
|
+
return /* @__PURE__ */ jsx(
|
|
1522
|
+
"button",
|
|
1523
|
+
{
|
|
1524
|
+
type: "button",
|
|
1525
|
+
"data-slot": "sidebar-trigger",
|
|
1526
|
+
"data-state": state,
|
|
1527
|
+
"aria-label": label,
|
|
1528
|
+
title: label,
|
|
1529
|
+
className: cn("mz-sidebar__trigger mz-focusable", className),
|
|
1530
|
+
onClick: (event) => {
|
|
1531
|
+
onClick?.(event);
|
|
1532
|
+
if (!event.defaultPrevented) toggleSidebar();
|
|
1533
|
+
},
|
|
1534
|
+
...props,
|
|
1535
|
+
children: /* @__PURE__ */ jsx(ChevronLeftIcon, {})
|
|
1536
|
+
}
|
|
1537
|
+
);
|
|
1538
|
+
}
|
|
1539
|
+
function SidebarRail({
|
|
1540
|
+
className,
|
|
1541
|
+
label = "Toggle sidebar",
|
|
1542
|
+
...props
|
|
1543
|
+
}) {
|
|
1544
|
+
const { toggleSidebar } = useSidebar();
|
|
1545
|
+
return /* @__PURE__ */ jsx(
|
|
1546
|
+
"button",
|
|
1547
|
+
{
|
|
1548
|
+
type: "button",
|
|
1549
|
+
"data-slot": "sidebar-rail",
|
|
1550
|
+
"aria-label": label,
|
|
1551
|
+
tabIndex: -1,
|
|
1552
|
+
className: cn("mz-sidebar__rail", className),
|
|
1553
|
+
onClick: toggleSidebar,
|
|
1554
|
+
...props
|
|
1555
|
+
}
|
|
1556
|
+
);
|
|
1557
|
+
}
|
|
1558
|
+
function SidebarInset({ className, ...props }) {
|
|
1559
|
+
return /* @__PURE__ */ jsx("main", { "data-slot": "sidebar-inset", className: cn("mz-sidebar-inset", className), ...props });
|
|
1560
|
+
}
|
|
1561
|
+
function SidebarPanel({ className, ...props }) {
|
|
1562
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "sidebar-panel", className: cn("mz-sidebar-panel", className), ...props });
|
|
1563
|
+
}
|
|
1564
|
+
function SidebarInput({ className, ...props }) {
|
|
1565
|
+
return /* @__PURE__ */ jsx(Input, { "data-slot": "sidebar-input", inputSize: "sm", className: cn("mz-sidebar__input", className), ...props });
|
|
1566
|
+
}
|
|
1567
|
+
function SidebarHeader({ className, ...props }) {
|
|
1568
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "sidebar-header", className: cn("mz-sidebar__header", className), ...props });
|
|
1569
|
+
}
|
|
1570
|
+
function SidebarFooter({ className, ...props }) {
|
|
1571
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "sidebar-footer", className: cn("mz-sidebar__footer", className), ...props });
|
|
1572
|
+
}
|
|
1573
|
+
function SidebarSeparator({ className, ...props }) {
|
|
1574
|
+
return /* @__PURE__ */ jsx(
|
|
1575
|
+
Separator,
|
|
1576
|
+
{
|
|
1577
|
+
"data-slot": "sidebar-separator",
|
|
1578
|
+
className: cn("mz-sidebar__separator", className),
|
|
1579
|
+
...props
|
|
1580
|
+
}
|
|
1581
|
+
);
|
|
1582
|
+
}
|
|
1583
|
+
function SidebarContent({ className, ...props }) {
|
|
1584
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "sidebar-content", className: cn("mz-sidebar__content", className), ...props });
|
|
1585
|
+
}
|
|
1586
|
+
function SidebarGroup({ className, ...props }) {
|
|
1587
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "sidebar-group", className: cn("mz-sidebar__group", className), ...props });
|
|
1588
|
+
}
|
|
1589
|
+
function SidebarGroupLabel({
|
|
1590
|
+
className,
|
|
1591
|
+
asChild = false,
|
|
1592
|
+
...props
|
|
1593
|
+
}) {
|
|
1594
|
+
const Comp = asChild ? Slot.Root : "div";
|
|
1595
|
+
return /* @__PURE__ */ jsx(Comp, { "data-slot": "sidebar-group-label", className: cn("mz-sidebar__group-label", className), ...props });
|
|
1596
|
+
}
|
|
1597
|
+
function SidebarGroupAction({
|
|
1598
|
+
className,
|
|
1599
|
+
asChild = false,
|
|
1600
|
+
...props
|
|
1601
|
+
}) {
|
|
1602
|
+
const Comp = asChild ? Slot.Root : "button";
|
|
1603
|
+
return /* @__PURE__ */ jsx(
|
|
1604
|
+
Comp,
|
|
1605
|
+
{
|
|
1606
|
+
"data-slot": "sidebar-group-action",
|
|
1607
|
+
className: cn("mz-sidebar__group-action mz-focusable", className),
|
|
1608
|
+
...props
|
|
1609
|
+
}
|
|
1610
|
+
);
|
|
1611
|
+
}
|
|
1612
|
+
function SidebarGroupContent({ className, ...props }) {
|
|
1613
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "sidebar-group-content", className: cn("mz-sidebar__group-content", className), ...props });
|
|
1614
|
+
}
|
|
1615
|
+
function SidebarMenu({ className, ...props }) {
|
|
1616
|
+
return /* @__PURE__ */ jsx("ul", { "data-slot": "sidebar-menu", className: cn("mz-sidebar__menu", className), ...props });
|
|
1617
|
+
}
|
|
1618
|
+
function SidebarMenuItem({ className, ...props }) {
|
|
1619
|
+
return /* @__PURE__ */ jsx("li", { "data-slot": "sidebar-menu-item", className: cn("mz-sidebar__menu-item", className), ...props });
|
|
1620
|
+
}
|
|
1621
|
+
function SidebarMenuButton({
|
|
1622
|
+
asChild = false,
|
|
1623
|
+
isActive = false,
|
|
1624
|
+
size = "md",
|
|
1625
|
+
tooltip,
|
|
1626
|
+
className,
|
|
1627
|
+
...props
|
|
1628
|
+
}) {
|
|
1629
|
+
const Comp = asChild ? Slot.Root : "button";
|
|
1630
|
+
const { isMobile, state } = useSidebar();
|
|
1631
|
+
const button = /* @__PURE__ */ jsx(
|
|
1632
|
+
Comp,
|
|
1633
|
+
{
|
|
1634
|
+
"data-slot": "sidebar-menu-button",
|
|
1635
|
+
"data-size": size,
|
|
1636
|
+
"data-active": isActive || void 0,
|
|
1637
|
+
className: cn("mz-sidebar__menu-button mz-focusable", className),
|
|
1638
|
+
...props
|
|
1639
|
+
}
|
|
1640
|
+
);
|
|
1641
|
+
if (!tooltip || state !== "collapsed" || isMobile) return button;
|
|
1642
|
+
return /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
1643
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: button }),
|
|
1644
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "right", align: "center", children: tooltip })
|
|
1645
|
+
] });
|
|
1646
|
+
}
|
|
1647
|
+
function SidebarMenuAction({
|
|
1648
|
+
className,
|
|
1649
|
+
asChild = false,
|
|
1650
|
+
showOnHover = false,
|
|
1651
|
+
...props
|
|
1652
|
+
}) {
|
|
1653
|
+
const Comp = asChild ? Slot.Root : "button";
|
|
1654
|
+
return /* @__PURE__ */ jsx(
|
|
1655
|
+
Comp,
|
|
1656
|
+
{
|
|
1657
|
+
"data-slot": "sidebar-menu-action",
|
|
1658
|
+
"data-hover-only": showOnHover || void 0,
|
|
1659
|
+
className: cn("mz-sidebar__menu-action mz-focusable", className),
|
|
1660
|
+
...props
|
|
1661
|
+
}
|
|
1662
|
+
);
|
|
1663
|
+
}
|
|
1664
|
+
function SidebarMenuBadge({ className, ...props }) {
|
|
1665
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "sidebar-menu-badge", className: cn("mz-sidebar__menu-badge", className), ...props });
|
|
1666
|
+
}
|
|
1667
|
+
function SidebarMenuSkeleton({
|
|
1668
|
+
className,
|
|
1669
|
+
showIcon = false,
|
|
1670
|
+
...props
|
|
1671
|
+
}) {
|
|
1672
|
+
const width = React39.useMemo(() => `${Math.floor(Math.random() * 40) + 50}%`, []);
|
|
1673
|
+
return /* @__PURE__ */ jsxs(
|
|
1674
|
+
"div",
|
|
1675
|
+
{
|
|
1676
|
+
"data-slot": "sidebar-menu-skeleton",
|
|
1677
|
+
className: cn("mz-sidebar__menu-skeleton", className),
|
|
1678
|
+
...props,
|
|
1679
|
+
children: [
|
|
1680
|
+
showIcon ? /* @__PURE__ */ jsx(Skeleton, { className: "mz-sidebar__menu-skeleton-icon" }) : null,
|
|
1681
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "mz-sidebar__menu-skeleton-text", style: { width } })
|
|
1682
|
+
]
|
|
1683
|
+
}
|
|
1684
|
+
);
|
|
1685
|
+
}
|
|
1686
|
+
function SidebarMenuSub({ className, ...props }) {
|
|
1687
|
+
return /* @__PURE__ */ jsx("ul", { "data-slot": "sidebar-menu-sub", className: cn("mz-sidebar__menu-sub", className), ...props });
|
|
1688
|
+
}
|
|
1689
|
+
function SidebarMenuSubItem({ className, ...props }) {
|
|
1690
|
+
return /* @__PURE__ */ jsx("li", { "data-slot": "sidebar-menu-sub-item", className: cn("mz-sidebar__menu-sub-item", className), ...props });
|
|
1691
|
+
}
|
|
1692
|
+
function SidebarMenuSubButton({
|
|
1693
|
+
asChild = false,
|
|
1694
|
+
isActive = false,
|
|
1695
|
+
size = "md",
|
|
1696
|
+
className,
|
|
1697
|
+
...props
|
|
1698
|
+
}) {
|
|
1699
|
+
const Comp = asChild ? Slot.Root : "a";
|
|
1700
|
+
return /* @__PURE__ */ jsx(
|
|
1701
|
+
Comp,
|
|
1702
|
+
{
|
|
1703
|
+
"data-slot": "sidebar-menu-sub-button",
|
|
1704
|
+
"data-size": size,
|
|
1705
|
+
"data-active": isActive || void 0,
|
|
1706
|
+
className: cn("mz-sidebar__menu-sub-button mz-focusable", className),
|
|
1707
|
+
...props
|
|
1708
|
+
}
|
|
1709
|
+
);
|
|
1710
|
+
}
|
|
1711
|
+
function CellEditor({
|
|
1712
|
+
row,
|
|
1713
|
+
def,
|
|
1714
|
+
onDone
|
|
1715
|
+
}) {
|
|
1716
|
+
const initial = def.value(row);
|
|
1717
|
+
const [value, setValue] = React39.useState(initial);
|
|
1718
|
+
const [saving, setSaving] = React39.useState(false);
|
|
1719
|
+
const [error, setError] = React39.useState(null);
|
|
1720
|
+
const commit = async () => {
|
|
1721
|
+
if (value === initial) return onDone();
|
|
1722
|
+
setSaving(true);
|
|
1723
|
+
try {
|
|
1724
|
+
await def.onSave(row, value);
|
|
1725
|
+
onDone();
|
|
1726
|
+
} catch (cause) {
|
|
1727
|
+
setValue(initial);
|
|
1728
|
+
setError(cause instanceof Error ? cause.message : "Could not save");
|
|
1729
|
+
setSaving(false);
|
|
1730
|
+
}
|
|
1731
|
+
};
|
|
1732
|
+
const onKeyDown = (event) => {
|
|
1733
|
+
if (event.key === "Enter") {
|
|
1734
|
+
event.preventDefault();
|
|
1735
|
+
void commit();
|
|
1736
|
+
}
|
|
1737
|
+
if (event.key === "Escape") {
|
|
1738
|
+
event.preventDefault();
|
|
1739
|
+
onDone();
|
|
1740
|
+
}
|
|
1741
|
+
};
|
|
1742
|
+
if (def.type === "select") {
|
|
1743
|
+
return /* @__PURE__ */ jsxs(
|
|
1744
|
+
Select,
|
|
1745
|
+
{
|
|
1746
|
+
open: true,
|
|
1747
|
+
value,
|
|
1748
|
+
onValueChange: async (next) => {
|
|
1749
|
+
setValue(next);
|
|
1750
|
+
setSaving(true);
|
|
1751
|
+
try {
|
|
1752
|
+
await def.onSave(row, next);
|
|
1753
|
+
onDone();
|
|
1754
|
+
} catch {
|
|
1755
|
+
setValue(initial);
|
|
1756
|
+
setSaving(false);
|
|
1757
|
+
}
|
|
1758
|
+
},
|
|
1759
|
+
onOpenChange: (open) => !open && onDone(),
|
|
1760
|
+
children: [
|
|
1761
|
+
/* @__PURE__ */ jsx(SelectTrigger, { size: "sm", className: "mz-dt__editor", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
|
|
1762
|
+
/* @__PURE__ */ jsx(SelectContent, { children: (def.options ?? []).map((option) => /* @__PURE__ */ jsx(SelectItem, { value: option.value, children: option.label }, option.value)) })
|
|
1763
|
+
]
|
|
1764
|
+
}
|
|
1765
|
+
);
|
|
1766
|
+
}
|
|
1767
|
+
return /* @__PURE__ */ jsx(
|
|
1768
|
+
Input,
|
|
1769
|
+
{
|
|
1770
|
+
autoFocus: true,
|
|
1771
|
+
inputSize: "sm",
|
|
1772
|
+
type: def.type === "number" ? "number" : "text",
|
|
1773
|
+
className: "mz-dt__editor",
|
|
1774
|
+
value,
|
|
1775
|
+
disabled: saving,
|
|
1776
|
+
"aria-invalid": error ? true : void 0,
|
|
1777
|
+
title: error ?? void 0,
|
|
1778
|
+
onChange: (event) => setValue(event.target.value),
|
|
1779
|
+
onKeyDown,
|
|
1780
|
+
onBlur: () => void commit()
|
|
1781
|
+
}
|
|
1782
|
+
);
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1785
|
+
// src/components/data-table/labels.ts
|
|
1786
|
+
var defaultDataTableLabels = {
|
|
1787
|
+
filter: "Filter",
|
|
1788
|
+
filterFor: (column) => `Filter: ${column}`,
|
|
1789
|
+
filterActive: "active",
|
|
1790
|
+
contains: "Contains\u2026",
|
|
1791
|
+
apply: "Apply",
|
|
1792
|
+
reset: "Reset",
|
|
1793
|
+
resetAll: "Reset all",
|
|
1794
|
+
resetFilters: "Reset filters",
|
|
1795
|
+
clearFilter: "Clear filter",
|
|
1796
|
+
rangeFrom: "from",
|
|
1797
|
+
rangeTo: "to",
|
|
1798
|
+
dateFrom: "From",
|
|
1799
|
+
dateTo: "To",
|
|
1800
|
+
yes: "Yes",
|
|
1801
|
+
no: "No",
|
|
1802
|
+
columns: "Columns",
|
|
1803
|
+
moveUp: (column) => `Move \u201C${column}\u201D up`,
|
|
1804
|
+
moveDown: (column) => `Move \u201C${column}\u201D down`,
|
|
1805
|
+
pinning: (column, side) => `Pinning for \u201C${column}\u201D: ${side}`,
|
|
1806
|
+
pinnedLeft: "Left",
|
|
1807
|
+
pinnedRight: "Right",
|
|
1808
|
+
notPinned: "Not pinned",
|
|
1809
|
+
show: (column) => `Show \u201C${column}\u201D`,
|
|
1810
|
+
hide: (column) => `Hide \u201C${column}\u201D`,
|
|
1811
|
+
sortBy: (column) => `Sort by \u201C${column}\u201D (Shift to add to the sort)`,
|
|
1812
|
+
columnWidth: (column) => `Width of column \u201C${column}\u201D`,
|
|
1813
|
+
selectPage: "Select page",
|
|
1814
|
+
selectRow: "Select row",
|
|
1815
|
+
expandRow: "Expand",
|
|
1816
|
+
collapseRow: "Collapse",
|
|
1817
|
+
details: "Details",
|
|
1818
|
+
empty: "Nothing found",
|
|
1819
|
+
retry: "Retry",
|
|
1820
|
+
rowsPerPage: "Rows per page",
|
|
1821
|
+
nothingFound: "Nothing found",
|
|
1822
|
+
of: "of",
|
|
1823
|
+
firstPage: "First page",
|
|
1824
|
+
previousPage: "Previous page",
|
|
1825
|
+
nextPage: "Next page",
|
|
1826
|
+
lastPage: "Last page",
|
|
1827
|
+
selectedCount: (count) => `Selected: ${count}`,
|
|
1828
|
+
allMatchingSuffix: " (all matching)",
|
|
1829
|
+
selectAllMatching: (total) => `Select all ${total}`,
|
|
1830
|
+
clearSelection: "Clear selection",
|
|
1831
|
+
bulkActions: "Actions for the selected rows"
|
|
1832
|
+
};
|
|
1833
|
+
function resolveLabels(labels) {
|
|
1834
|
+
return labels ? { ...defaultDataTableLabels, ...labels } : defaultDataTableLabels;
|
|
1835
|
+
}
|
|
1836
|
+
|
|
1837
|
+
// src/components/data-table/utils.ts
|
|
1838
|
+
function isFilterActive(value) {
|
|
1839
|
+
if (!value) return false;
|
|
1840
|
+
switch (value.type) {
|
|
1841
|
+
case "text":
|
|
1842
|
+
return value.value.trim().length > 0;
|
|
1843
|
+
case "select":
|
|
1844
|
+
return value.value.length > 0;
|
|
1845
|
+
case "number-range":
|
|
1846
|
+
return value.min !== void 0 || value.max !== void 0;
|
|
1847
|
+
case "date-range":
|
|
1848
|
+
return Boolean(value.from || value.to);
|
|
1849
|
+
case "boolean":
|
|
1850
|
+
return true;
|
|
1851
|
+
}
|
|
1852
|
+
}
|
|
1853
|
+
function activeFilters(filters) {
|
|
1854
|
+
return Object.entries(filters).filter(([, value]) => isFilterActive(value));
|
|
1855
|
+
}
|
|
1856
|
+
function setFilter(query, id, value) {
|
|
1857
|
+
const filters = { ...query.filters };
|
|
1858
|
+
if (isFilterActive(value)) filters[id] = value;
|
|
1859
|
+
else delete filters[id];
|
|
1860
|
+
return { ...query, filters, page: 1 };
|
|
1861
|
+
}
|
|
1862
|
+
function toggleSort(query, id, additive = false) {
|
|
1863
|
+
const existing = query.sort.find((s) => s.id === id);
|
|
1864
|
+
const next = additive ? query.sort.filter((s) => s.id !== id) : [];
|
|
1865
|
+
if (!existing) next.push({ id, dir: "asc" });
|
|
1866
|
+
else if (existing.dir === "asc") next.push({ id, dir: "desc" });
|
|
1867
|
+
return { ...query, sort: next, page: 1 };
|
|
1868
|
+
}
|
|
1869
|
+
function sortStateOf(query, id) {
|
|
1870
|
+
const index = query.sort.findIndex((s) => s.id === id);
|
|
1871
|
+
if (index < 0) return { dir: void 0, index: void 0 };
|
|
1872
|
+
return { dir: query.sort[index].dir, index: query.sort.length > 1 ? index + 1 : void 0 };
|
|
1873
|
+
}
|
|
1874
|
+
function pageCount(total, pageSize) {
|
|
1875
|
+
if (!total || pageSize <= 0) return 1;
|
|
1876
|
+
return Math.max(1, Math.ceil(total / pageSize));
|
|
1877
|
+
}
|
|
1878
|
+
function serializeSort(sort) {
|
|
1879
|
+
return sort.map((s) => s.dir === "desc" ? `-${s.id}` : s.id).join(",");
|
|
1880
|
+
}
|
|
1881
|
+
function parseSort(raw) {
|
|
1882
|
+
if (!raw) return [];
|
|
1883
|
+
return raw.split(",").filter(Boolean).map(
|
|
1884
|
+
(token) => token.startsWith("-") ? { id: token.slice(1), dir: "desc" } : { id: token, dir: "asc" }
|
|
1885
|
+
);
|
|
1886
|
+
}
|
|
1887
|
+
function ColumnFilter({ columnLabel, def, value, onApply, labels: labelsProp }) {
|
|
1888
|
+
const labels = resolveLabels(labelsProp);
|
|
1889
|
+
const [open, setOpen] = React39.useState(false);
|
|
1890
|
+
const [draft, setDraft] = React39.useState(value);
|
|
1891
|
+
React39.useEffect(() => {
|
|
1892
|
+
if (open) setDraft(value);
|
|
1893
|
+
}, [open, value]);
|
|
1894
|
+
const active = isFilterActive(value);
|
|
1895
|
+
const commit = (next) => {
|
|
1896
|
+
onApply(isFilterActive(next) ? next : void 0);
|
|
1897
|
+
setOpen(false);
|
|
1898
|
+
};
|
|
1899
|
+
return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
|
|
1900
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
1901
|
+
"button",
|
|
1902
|
+
{
|
|
1903
|
+
type: "button",
|
|
1904
|
+
"data-slot": "data-table-filter-trigger",
|
|
1905
|
+
"data-active": active || void 0,
|
|
1906
|
+
className: "mz-dt__filter mz-focusable",
|
|
1907
|
+
"aria-label": `${labels.filterFor(columnLabel)}${active ? ` (${labels.filterActive})` : ""}`,
|
|
1908
|
+
title: labels.filterFor(columnLabel),
|
|
1909
|
+
children: /* @__PURE__ */ jsx(FilterIcon, {})
|
|
1910
|
+
}
|
|
1911
|
+
) }),
|
|
1912
|
+
/* @__PURE__ */ jsxs(PopoverContent, { align: "start", className: "mz-dt__filter-panel", children: [
|
|
1913
|
+
/* @__PURE__ */ jsx("div", { className: "mz-dt__filter-head", children: columnLabel }),
|
|
1914
|
+
/* @__PURE__ */ jsx(
|
|
1915
|
+
FilterBody,
|
|
1916
|
+
{
|
|
1917
|
+
def,
|
|
1918
|
+
draft,
|
|
1919
|
+
setDraft,
|
|
1920
|
+
labels,
|
|
1921
|
+
onSubmit: () => commit(draft)
|
|
1922
|
+
}
|
|
1923
|
+
),
|
|
1924
|
+
/* @__PURE__ */ jsxs("div", { className: "mz-dt__filter-actions", children: [
|
|
1925
|
+
/* @__PURE__ */ jsx(Button, { size: "sm", variant: "ghost", onClick: () => commit(void 0), children: labels.reset }),
|
|
1926
|
+
/* @__PURE__ */ jsx(Button, { size: "sm", onClick: () => commit(draft), children: labels.apply })
|
|
1927
|
+
] })
|
|
1928
|
+
] })
|
|
1929
|
+
] });
|
|
1930
|
+
}
|
|
1931
|
+
function FilterBody({
|
|
1932
|
+
def,
|
|
1933
|
+
draft,
|
|
1934
|
+
setDraft,
|
|
1935
|
+
labels,
|
|
1936
|
+
onSubmit
|
|
1937
|
+
}) {
|
|
1938
|
+
const submitOnEnter = (event) => {
|
|
1939
|
+
if (event.key === "Enter") {
|
|
1940
|
+
event.preventDefault();
|
|
1941
|
+
onSubmit();
|
|
1942
|
+
}
|
|
1943
|
+
};
|
|
1944
|
+
if (def.type === "text") {
|
|
1945
|
+
const current2 = draft?.type === "text" ? draft.value : "";
|
|
1946
|
+
return /* @__PURE__ */ jsx(
|
|
1947
|
+
Input,
|
|
1948
|
+
{
|
|
1949
|
+
autoFocus: true,
|
|
1950
|
+
inputSize: "sm",
|
|
1951
|
+
placeholder: def.placeholder ?? labels.contains,
|
|
1952
|
+
value: current2,
|
|
1953
|
+
onKeyDown: submitOnEnter,
|
|
1954
|
+
onChange: (e) => setDraft({ type: "text", value: e.target.value })
|
|
1955
|
+
}
|
|
1956
|
+
);
|
|
1957
|
+
}
|
|
1958
|
+
if (def.type === "select") {
|
|
1959
|
+
const current2 = draft?.type === "select" ? draft.value : [];
|
|
1960
|
+
const toggle = (option) => {
|
|
1961
|
+
if (def.multiple === false) {
|
|
1962
|
+
setDraft({ type: "select", value: current2.includes(option) ? [] : [option] });
|
|
1963
|
+
return;
|
|
1964
|
+
}
|
|
1965
|
+
setDraft({
|
|
1966
|
+
type: "select",
|
|
1967
|
+
value: current2.includes(option) ? current2.filter((v) => v !== option) : [...current2, option]
|
|
1968
|
+
});
|
|
1969
|
+
};
|
|
1970
|
+
return /* @__PURE__ */ jsx("div", { className: "mz-dt__filter-options", role: "group", children: def.options.map((option) => /* @__PURE__ */ jsxs("label", { className: "mz-dt__filter-option", children: [
|
|
1971
|
+
/* @__PURE__ */ jsx(
|
|
1972
|
+
Checkbox,
|
|
1973
|
+
{
|
|
1974
|
+
size: "sm",
|
|
1975
|
+
checked: current2.includes(option.value),
|
|
1976
|
+
onCheckedChange: () => toggle(option.value)
|
|
1977
|
+
}
|
|
1978
|
+
),
|
|
1979
|
+
/* @__PURE__ */ jsx("span", { children: option.label })
|
|
1980
|
+
] }, option.value)) });
|
|
1981
|
+
}
|
|
1982
|
+
if (def.type === "number-range") {
|
|
1983
|
+
const current2 = draft?.type === "number-range" ? draft : { };
|
|
1984
|
+
const patch = (part) => setDraft({ type: "number-range", min: current2.min, max: current2.max, ...part });
|
|
1985
|
+
return /* @__PURE__ */ jsxs("div", { className: "mz-dt__filter-range", children: [
|
|
1986
|
+
/* @__PURE__ */ jsx(
|
|
1987
|
+
Input,
|
|
1988
|
+
{
|
|
1989
|
+
autoFocus: true,
|
|
1990
|
+
inputSize: "sm",
|
|
1991
|
+
type: "number",
|
|
1992
|
+
step: def.step,
|
|
1993
|
+
placeholder: labels.rangeFrom,
|
|
1994
|
+
value: current2.min ?? "",
|
|
1995
|
+
onKeyDown: submitOnEnter,
|
|
1996
|
+
onChange: (e) => patch({ min: e.target.value === "" ? void 0 : Number(e.target.value) })
|
|
1997
|
+
}
|
|
1998
|
+
),
|
|
1999
|
+
/* @__PURE__ */ jsx("span", { className: "mz-dt__filter-dash", children: "\u2014" }),
|
|
2000
|
+
/* @__PURE__ */ jsx(
|
|
2001
|
+
Input,
|
|
2002
|
+
{
|
|
2003
|
+
inputSize: "sm",
|
|
2004
|
+
type: "number",
|
|
2005
|
+
step: def.step,
|
|
2006
|
+
placeholder: labels.rangeTo,
|
|
2007
|
+
value: current2.max ?? "",
|
|
2008
|
+
onKeyDown: submitOnEnter,
|
|
2009
|
+
onChange: (e) => patch({ max: e.target.value === "" ? void 0 : Number(e.target.value) })
|
|
2010
|
+
}
|
|
2011
|
+
)
|
|
2012
|
+
] });
|
|
2013
|
+
}
|
|
2014
|
+
if (def.type === "date-range") {
|
|
2015
|
+
const current2 = draft?.type === "date-range" ? draft : { };
|
|
2016
|
+
const patch = (part) => setDraft({ type: "date-range", from: current2.from, to: current2.to, ...part });
|
|
2017
|
+
return /* @__PURE__ */ jsxs("div", { className: "mz-dt__filter-range mz-dt__filter-range--stacked", children: [
|
|
2018
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: "mz-dt-from", children: labels.dateFrom }),
|
|
2019
|
+
/* @__PURE__ */ jsx(
|
|
2020
|
+
Input,
|
|
2021
|
+
{
|
|
2022
|
+
id: "mz-dt-from",
|
|
2023
|
+
inputSize: "sm",
|
|
2024
|
+
type: "date",
|
|
2025
|
+
value: current2.from ?? "",
|
|
2026
|
+
onKeyDown: submitOnEnter,
|
|
2027
|
+
onChange: (e) => patch({ from: e.target.value || void 0 })
|
|
2028
|
+
}
|
|
2029
|
+
),
|
|
2030
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: "mz-dt-to", children: labels.dateTo }),
|
|
2031
|
+
/* @__PURE__ */ jsx(
|
|
2032
|
+
Input,
|
|
2033
|
+
{
|
|
2034
|
+
id: "mz-dt-to",
|
|
2035
|
+
inputSize: "sm",
|
|
2036
|
+
type: "date",
|
|
2037
|
+
value: current2.to ?? "",
|
|
2038
|
+
onKeyDown: submitOnEnter,
|
|
2039
|
+
onChange: (e) => patch({ to: e.target.value || void 0 })
|
|
2040
|
+
}
|
|
2041
|
+
)
|
|
2042
|
+
] });
|
|
2043
|
+
}
|
|
2044
|
+
const current = draft?.type === "boolean" ? draft.value : void 0;
|
|
2045
|
+
return /* @__PURE__ */ jsx("div", { className: "mz-dt__filter-options", role: "radiogroup", children: [
|
|
2046
|
+
{ value: true, label: def.trueLabel ?? labels.yes },
|
|
2047
|
+
{ value: false, label: def.falseLabel ?? labels.no }
|
|
2048
|
+
].map((option) => /* @__PURE__ */ jsxs("label", { className: "mz-dt__filter-option", children: [
|
|
2049
|
+
/* @__PURE__ */ jsx(
|
|
2050
|
+
Checkbox,
|
|
2051
|
+
{
|
|
2052
|
+
size: "sm",
|
|
2053
|
+
checked: current === option.value,
|
|
2054
|
+
onCheckedChange: (checked) => setDraft(checked ? { type: "boolean", value: option.value } : void 0)
|
|
2055
|
+
}
|
|
2056
|
+
),
|
|
2057
|
+
/* @__PURE__ */ jsx("span", { children: option.label })
|
|
2058
|
+
] }, String(option.value))) });
|
|
2059
|
+
}
|
|
2060
|
+
function FilterChip({
|
|
2061
|
+
label,
|
|
2062
|
+
onClear,
|
|
2063
|
+
clearLabel = defaultDataTableLabels.clearFilter,
|
|
2064
|
+
className
|
|
2065
|
+
}) {
|
|
2066
|
+
return /* @__PURE__ */ jsxs("span", { className: cn("mz-dt__chip", className), children: [
|
|
2067
|
+
label,
|
|
2068
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: onClear, "aria-label": clearLabel, className: "mz-focusable", children: "\xD7" })
|
|
2069
|
+
] });
|
|
2070
|
+
}
|
|
2071
|
+
function ColumnManager({
|
|
2072
|
+
columns,
|
|
2073
|
+
layout,
|
|
2074
|
+
onToggleHidden,
|
|
2075
|
+
onSetPinned,
|
|
2076
|
+
onMove,
|
|
2077
|
+
onMoveTo,
|
|
2078
|
+
onReset,
|
|
2079
|
+
labels: labelsProp
|
|
2080
|
+
}) {
|
|
2081
|
+
const labels = resolveLabels(labelsProp);
|
|
2082
|
+
const [dragging, setDragging] = React39.useState(null);
|
|
2083
|
+
const byId = React39.useMemo(() => new Map(columns.map((c) => [c.id, c])), [columns]);
|
|
2084
|
+
const ordered = layout.order.map((id) => byId.get(id)).filter((c) => Boolean(c));
|
|
2085
|
+
const hiddenCount = layout.hidden.length;
|
|
2086
|
+
return /* @__PURE__ */ jsxs(Popover, { children: [
|
|
2087
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { variant: "secondary", size: "sm", children: [
|
|
2088
|
+
/* @__PURE__ */ jsx(ColumnsIcon, {}),
|
|
2089
|
+
labels.columns,
|
|
2090
|
+
hiddenCount > 0 ? /* @__PURE__ */ jsx("span", { className: "mz-dt__count", children: ordered.length - hiddenCount }) : null
|
|
2091
|
+
] }) }),
|
|
2092
|
+
/* @__PURE__ */ jsxs(PopoverContent, { align: "end", className: "mz-dt__columns", children: [
|
|
2093
|
+
/* @__PURE__ */ jsxs("div", { className: "mz-dt__columns-head", children: [
|
|
2094
|
+
/* @__PURE__ */ jsx("span", { children: labels.columns }),
|
|
2095
|
+
/* @__PURE__ */ jsx(Button, { variant: "link", size: "xs", onClick: onReset, children: labels.reset })
|
|
2096
|
+
] }),
|
|
2097
|
+
/* @__PURE__ */ jsx(Separator, {}),
|
|
2098
|
+
/* @__PURE__ */ jsx("ul", { className: "mz-dt__columns-list", children: ordered.map((column, index) => {
|
|
2099
|
+
const hidden = layout.hidden.includes(column.id);
|
|
2100
|
+
const pinned = layout.pinned[column.id];
|
|
2101
|
+
const label = column.label ?? (typeof column.header === "string" ? column.header : column.id);
|
|
2102
|
+
return /* @__PURE__ */ jsxs(
|
|
2103
|
+
"li",
|
|
2104
|
+
{
|
|
2105
|
+
className: "mz-dt__columns-item",
|
|
2106
|
+
"data-dragging": dragging === column.id || void 0,
|
|
2107
|
+
draggable: true,
|
|
2108
|
+
onDragStart: () => setDragging(column.id),
|
|
2109
|
+
onDragEnd: () => setDragging(null),
|
|
2110
|
+
onDragOver: (event) => event.preventDefault(),
|
|
2111
|
+
onDrop: () => {
|
|
2112
|
+
if (dragging && dragging !== column.id) onMoveTo(dragging, column.id);
|
|
2113
|
+
setDragging(null);
|
|
2114
|
+
},
|
|
2115
|
+
children: [
|
|
2116
|
+
/* @__PURE__ */ jsx("span", { className: "mz-dt__columns-grip", "aria-hidden": "true", children: /* @__PURE__ */ jsx(GripIcon, {}) }),
|
|
2117
|
+
/* @__PURE__ */ jsx("span", { className: "mz-dt__columns-label", children: label }),
|
|
2118
|
+
/* @__PURE__ */ jsxs("div", { className: "mz-dt__columns-controls", children: [
|
|
2119
|
+
/* @__PURE__ */ jsx(
|
|
2120
|
+
"button",
|
|
2121
|
+
{
|
|
2122
|
+
type: "button",
|
|
2123
|
+
className: "mz-dt__icon-btn mz-focusable",
|
|
2124
|
+
disabled: index === 0,
|
|
2125
|
+
onClick: () => onMove(column.id, -1),
|
|
2126
|
+
"aria-label": labels.moveUp(label),
|
|
2127
|
+
children: "\u2191"
|
|
2128
|
+
}
|
|
2129
|
+
),
|
|
2130
|
+
/* @__PURE__ */ jsx(
|
|
2131
|
+
"button",
|
|
2132
|
+
{
|
|
2133
|
+
type: "button",
|
|
2134
|
+
className: "mz-dt__icon-btn mz-focusable",
|
|
2135
|
+
disabled: index === ordered.length - 1,
|
|
2136
|
+
onClick: () => onMove(column.id, 1),
|
|
2137
|
+
"aria-label": labels.moveDown(label),
|
|
2138
|
+
children: "\u2193"
|
|
2139
|
+
}
|
|
2140
|
+
),
|
|
2141
|
+
/* @__PURE__ */ jsx(
|
|
2142
|
+
"button",
|
|
2143
|
+
{
|
|
2144
|
+
type: "button",
|
|
2145
|
+
className: "mz-dt__icon-btn mz-focusable",
|
|
2146
|
+
"data-active": pinned ? true : void 0,
|
|
2147
|
+
onClick: () => onSetPinned(column.id, pinned === "left" ? "right" : pinned === "right" ? void 0 : "left"),
|
|
2148
|
+
"aria-label": labels.pinning(
|
|
2149
|
+
label,
|
|
2150
|
+
pinned === "left" ? labels.pinnedLeft : pinned === "right" ? labels.pinnedRight : labels.notPinned
|
|
2151
|
+
),
|
|
2152
|
+
title: pinned === "left" ? labels.pinnedLeft : pinned === "right" ? labels.pinnedRight : labels.notPinned,
|
|
2153
|
+
children: /* @__PURE__ */ jsx(PinIcon, {})
|
|
2154
|
+
}
|
|
2155
|
+
),
|
|
2156
|
+
/* @__PURE__ */ jsx(
|
|
2157
|
+
"button",
|
|
2158
|
+
{
|
|
2159
|
+
type: "button",
|
|
2160
|
+
className: "mz-dt__icon-btn mz-focusable",
|
|
2161
|
+
disabled: column.hideable === false,
|
|
2162
|
+
onClick: () => onToggleHidden(column.id),
|
|
2163
|
+
"aria-label": hidden ? labels.show(label) : labels.hide(label),
|
|
2164
|
+
children: hidden ? /* @__PURE__ */ jsx(EyeOffIcon, {}) : /* @__PURE__ */ jsx(EyeIcon, {})
|
|
2165
|
+
}
|
|
2166
|
+
)
|
|
2167
|
+
] })
|
|
2168
|
+
]
|
|
2169
|
+
},
|
|
2170
|
+
column.id
|
|
2171
|
+
);
|
|
2172
|
+
}) })
|
|
2173
|
+
] })
|
|
2174
|
+
] });
|
|
2175
|
+
}
|
|
2176
|
+
function DataTablePagination({
|
|
2177
|
+
query,
|
|
2178
|
+
total,
|
|
2179
|
+
rowsOnPage,
|
|
2180
|
+
pageSizeOptions = [10, 25, 50, 100],
|
|
2181
|
+
labels: labelsProp,
|
|
2182
|
+
locale,
|
|
2183
|
+
onQueryChange
|
|
2184
|
+
}) {
|
|
2185
|
+
const labels = resolveLabels(labelsProp);
|
|
2186
|
+
const pages = pageCount(total, query.pageSize);
|
|
2187
|
+
const from = total === 0 ? 0 : (query.page - 1) * query.pageSize + 1;
|
|
2188
|
+
const to = total === void 0 ? from + rowsOnPage - 1 : Math.min(query.page * query.pageSize, total);
|
|
2189
|
+
const go = (page) => onQueryChange({ ...query, page: Math.min(Math.max(page, 1), pages) });
|
|
2190
|
+
return /* @__PURE__ */ jsxs("div", { className: "mz-dt__pagination", "data-slot": "data-table-pagination", children: [
|
|
2191
|
+
/* @__PURE__ */ jsx("div", { className: "mz-dt__pagination-info", children: total === 0 ? labels.nothingFound : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2192
|
+
from,
|
|
2193
|
+
"\u2013",
|
|
2194
|
+
to,
|
|
2195
|
+
total !== void 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2196
|
+
" ",
|
|
2197
|
+
labels.of,
|
|
2198
|
+
" ",
|
|
2199
|
+
total.toLocaleString(locale)
|
|
2200
|
+
] }) : null
|
|
2201
|
+
] }) }),
|
|
2202
|
+
/* @__PURE__ */ jsxs("div", { className: "mz-dt__pagination-size", children: [
|
|
2203
|
+
/* @__PURE__ */ jsx("span", { children: labels.rowsPerPage }),
|
|
2204
|
+
/* @__PURE__ */ jsxs(
|
|
2205
|
+
Select,
|
|
2206
|
+
{
|
|
2207
|
+
value: String(query.pageSize),
|
|
2208
|
+
onValueChange: (value) => onQueryChange({ ...query, pageSize: Number(value), page: 1 }),
|
|
2209
|
+
children: [
|
|
2210
|
+
/* @__PURE__ */ jsx(SelectTrigger, { size: "sm", className: "mz-dt__pagination-select", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
|
|
2211
|
+
/* @__PURE__ */ jsx(SelectContent, { children: pageSizeOptions.map((size) => /* @__PURE__ */ jsx(SelectItem, { value: String(size), children: size }, size)) })
|
|
2212
|
+
]
|
|
2213
|
+
}
|
|
2214
|
+
)
|
|
2215
|
+
] }),
|
|
2216
|
+
/* @__PURE__ */ jsxs("div", { className: "mz-dt__pagination-nav", children: [
|
|
2217
|
+
/* @__PURE__ */ jsxs("span", { className: "mz-dt__pagination-page", children: [
|
|
2218
|
+
query.page,
|
|
2219
|
+
" / ",
|
|
2220
|
+
pages
|
|
2221
|
+
] }),
|
|
2222
|
+
/* @__PURE__ */ jsx(
|
|
2223
|
+
Button,
|
|
2224
|
+
{
|
|
2225
|
+
variant: "secondary",
|
|
2226
|
+
size: "icon-sm",
|
|
2227
|
+
disabled: query.page <= 1,
|
|
2228
|
+
onClick: () => go(1),
|
|
2229
|
+
"aria-label": labels.firstPage,
|
|
2230
|
+
children: /* @__PURE__ */ jsx(ChevronsLeftIcon, {})
|
|
2231
|
+
}
|
|
2232
|
+
),
|
|
2233
|
+
/* @__PURE__ */ jsx(
|
|
2234
|
+
Button,
|
|
2235
|
+
{
|
|
2236
|
+
variant: "secondary",
|
|
2237
|
+
size: "icon-sm",
|
|
2238
|
+
disabled: query.page <= 1,
|
|
2239
|
+
onClick: () => go(query.page - 1),
|
|
2240
|
+
"aria-label": labels.previousPage,
|
|
2241
|
+
children: /* @__PURE__ */ jsx(ChevronLeftIcon, {})
|
|
2242
|
+
}
|
|
2243
|
+
),
|
|
2244
|
+
/* @__PURE__ */ jsx(
|
|
2245
|
+
Button,
|
|
2246
|
+
{
|
|
2247
|
+
variant: "secondary",
|
|
2248
|
+
size: "icon-sm",
|
|
2249
|
+
disabled: query.page >= pages,
|
|
2250
|
+
onClick: () => go(query.page + 1),
|
|
2251
|
+
"aria-label": labels.nextPage,
|
|
2252
|
+
children: /* @__PURE__ */ jsx(ChevronRightIcon, {})
|
|
2253
|
+
}
|
|
2254
|
+
),
|
|
2255
|
+
/* @__PURE__ */ jsx(
|
|
2256
|
+
Button,
|
|
2257
|
+
{
|
|
2258
|
+
variant: "secondary",
|
|
2259
|
+
size: "icon-sm",
|
|
2260
|
+
disabled: query.page >= pages,
|
|
2261
|
+
onClick: () => go(pages),
|
|
2262
|
+
"aria-label": labels.lastPage,
|
|
2263
|
+
children: /* @__PURE__ */ jsx(ChevronsRightIcon, {})
|
|
2264
|
+
}
|
|
2265
|
+
)
|
|
2266
|
+
] })
|
|
2267
|
+
] });
|
|
2268
|
+
}
|
|
2269
|
+
function useColumnResize(options) {
|
|
2270
|
+
const { rootRef, widthOf, minWidthOf, onCommit } = options;
|
|
2271
|
+
const [resizing, setResizing] = React39.useState(null);
|
|
2272
|
+
const varName = (id) => `--mz-dt-w-${cssSafe(id)}`;
|
|
2273
|
+
const start = React39.useCallback(
|
|
2274
|
+
(event, id) => {
|
|
2275
|
+
if (event.button !== 0) return;
|
|
2276
|
+
event.preventDefault();
|
|
2277
|
+
event.stopPropagation();
|
|
2278
|
+
const root = rootRef.current;
|
|
2279
|
+
if (!root) return;
|
|
2280
|
+
const handle = event.currentTarget;
|
|
2281
|
+
const startX = event.clientX;
|
|
2282
|
+
const startWidth = widthOf(id);
|
|
2283
|
+
const min = minWidthOf(id);
|
|
2284
|
+
let width = startWidth;
|
|
2285
|
+
handle.setPointerCapture(event.pointerId);
|
|
2286
|
+
setResizing(id);
|
|
2287
|
+
const onMove = (moveEvent) => {
|
|
2288
|
+
width = Math.max(min, Math.round(startWidth + moveEvent.clientX - startX));
|
|
2289
|
+
root.style.setProperty(varName(id), `${width}px`);
|
|
2290
|
+
};
|
|
2291
|
+
const finish = () => {
|
|
2292
|
+
handle.releasePointerCapture?.(event.pointerId);
|
|
2293
|
+
handle.removeEventListener("pointermove", onMove);
|
|
2294
|
+
handle.removeEventListener("pointerup", finish);
|
|
2295
|
+
handle.removeEventListener("pointercancel", finish);
|
|
2296
|
+
setResizing(null);
|
|
2297
|
+
if (width !== startWidth) onCommit(id, width);
|
|
2298
|
+
};
|
|
2299
|
+
handle.addEventListener("pointermove", onMove);
|
|
2300
|
+
handle.addEventListener("pointerup", finish);
|
|
2301
|
+
handle.addEventListener("pointercancel", finish);
|
|
2302
|
+
},
|
|
2303
|
+
[rootRef, widthOf, minWidthOf, onCommit]
|
|
2304
|
+
);
|
|
2305
|
+
const autoFit = React39.useCallback(
|
|
2306
|
+
(id) => {
|
|
2307
|
+
const root = rootRef.current;
|
|
2308
|
+
if (!root) return;
|
|
2309
|
+
const cells = root.querySelectorAll(`[data-col="${CSS.escape(id)}"]`);
|
|
2310
|
+
let widest = minWidthOf(id);
|
|
2311
|
+
cells.forEach((cell) => {
|
|
2312
|
+
const content = cell.firstElementChild;
|
|
2313
|
+
const padding = 26;
|
|
2314
|
+
widest = Math.max(widest, (content?.scrollWidth ?? cell.scrollWidth) + padding);
|
|
2315
|
+
});
|
|
2316
|
+
const width = Math.min(widest, 640);
|
|
2317
|
+
root.style.setProperty(varName(id), `${width}px`);
|
|
2318
|
+
onCommit(id, width);
|
|
2319
|
+
},
|
|
2320
|
+
[rootRef, minWidthOf, onCommit]
|
|
2321
|
+
);
|
|
2322
|
+
const onKeyDown = React39.useCallback(
|
|
2323
|
+
(event, id) => {
|
|
2324
|
+
const step = event.shiftKey ? 32 : 8;
|
|
2325
|
+
if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
|
|
2326
|
+
event.preventDefault();
|
|
2327
|
+
const next = Math.max(
|
|
2328
|
+
minWidthOf(id),
|
|
2329
|
+
widthOf(id) + (event.key === "ArrowRight" ? step : -step)
|
|
2330
|
+
);
|
|
2331
|
+
rootRef.current?.style.setProperty(varName(id), `${next}px`);
|
|
2332
|
+
onCommit(id, next);
|
|
2333
|
+
},
|
|
2334
|
+
[rootRef, widthOf, minWidthOf, onCommit]
|
|
2335
|
+
);
|
|
2336
|
+
return { start, autoFit, onKeyDown, resizing, varName };
|
|
2337
|
+
}
|
|
2338
|
+
function cssSafe(id) {
|
|
2339
|
+
return id.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
2340
|
+
}
|
|
2341
|
+
var DEFAULT_WIDTH = 168;
|
|
2342
|
+
var DEFAULT_MIN = 72;
|
|
2343
|
+
function readStored3(key) {
|
|
2344
|
+
if (!key || typeof window === "undefined") return null;
|
|
2345
|
+
try {
|
|
2346
|
+
const raw = window.localStorage.getItem(key);
|
|
2347
|
+
return raw ? JSON.parse(raw) : null;
|
|
2348
|
+
} catch {
|
|
2349
|
+
return null;
|
|
2350
|
+
}
|
|
2351
|
+
}
|
|
2352
|
+
function writeStored2(key, layout) {
|
|
2353
|
+
if (!key || typeof window === "undefined") return;
|
|
2354
|
+
try {
|
|
2355
|
+
window.localStorage.setItem(key, JSON.stringify(layout));
|
|
2356
|
+
} catch {
|
|
2357
|
+
}
|
|
2358
|
+
}
|
|
2359
|
+
function useColumnLayout({
|
|
2360
|
+
columns,
|
|
2361
|
+
persistKey = null,
|
|
2362
|
+
layout: controlled,
|
|
2363
|
+
onLayoutChange
|
|
2364
|
+
}) {
|
|
2365
|
+
const baseline = React39.useMemo(
|
|
2366
|
+
() => ({
|
|
2367
|
+
order: columns.map((c) => c.id),
|
|
2368
|
+
hidden: [],
|
|
2369
|
+
widths: Object.fromEntries(
|
|
2370
|
+
columns.map((c) => [c.id, c.width ?? DEFAULT_WIDTH])
|
|
2371
|
+
),
|
|
2372
|
+
pinned: Object.fromEntries(columns.map((c) => [c.id, c.pinned])),
|
|
2373
|
+
sized: []
|
|
2374
|
+
}),
|
|
2375
|
+
[columns]
|
|
2376
|
+
);
|
|
2377
|
+
const [internal, setInternal] = React39.useState(baseline);
|
|
2378
|
+
React39.useEffect(() => {
|
|
2379
|
+
const stored = readStored3(persistKey);
|
|
2380
|
+
if (stored) setInternal((current) => merge(current, stored, baseline));
|
|
2381
|
+
}, [persistKey]);
|
|
2382
|
+
React39.useEffect(() => {
|
|
2383
|
+
setInternal((current) => merge(baseline, current, baseline));
|
|
2384
|
+
}, [baseline]);
|
|
2385
|
+
const layout = React39.useMemo(
|
|
2386
|
+
() => controlled ? merge(baseline, controlled, baseline) : internal,
|
|
2387
|
+
[controlled, internal, baseline]
|
|
2388
|
+
);
|
|
2389
|
+
const update = React39.useCallback(
|
|
2390
|
+
(patch, options) => {
|
|
2391
|
+
setInternal((current) => {
|
|
2392
|
+
const base = controlled ? merge(baseline, controlled, baseline) : current;
|
|
2393
|
+
const next = patch(base);
|
|
2394
|
+
if (next === base) return current;
|
|
2395
|
+
if (options?.persist !== false) {
|
|
2396
|
+
writeStored2(persistKey, next);
|
|
2397
|
+
onLayoutChange?.(next);
|
|
2398
|
+
}
|
|
2399
|
+
return next;
|
|
2400
|
+
});
|
|
2401
|
+
},
|
|
2402
|
+
[controlled, baseline, persistKey, onLayoutChange]
|
|
2403
|
+
);
|
|
2404
|
+
const byId = React39.useMemo(
|
|
2405
|
+
() => new Map(columns.map((c) => [c.id, c])),
|
|
2406
|
+
[columns]
|
|
2407
|
+
);
|
|
2408
|
+
const visible = React39.useMemo(() => {
|
|
2409
|
+
const ordered = layout.order.map((id) => byId.get(id)).filter((c) => Boolean(c) && !layout.hidden.includes(c.id));
|
|
2410
|
+
const side = (id) => layout.pinned[id];
|
|
2411
|
+
return [
|
|
2412
|
+
...ordered.filter((c) => side(c.id) === "left"),
|
|
2413
|
+
...ordered.filter((c) => !side(c.id)),
|
|
2414
|
+
...ordered.filter((c) => side(c.id) === "right")
|
|
2415
|
+
];
|
|
2416
|
+
}, [layout, byId]);
|
|
2417
|
+
const widthOf = React39.useCallback(
|
|
2418
|
+
(id) => layout.widths[id] ?? byId.get(id)?.width ?? DEFAULT_WIDTH,
|
|
2419
|
+
[layout.widths, byId]
|
|
2420
|
+
);
|
|
2421
|
+
const minWidthOf = React39.useCallback(
|
|
2422
|
+
(id) => byId.get(id)?.minWidth ?? DEFAULT_MIN,
|
|
2423
|
+
[byId]
|
|
2424
|
+
);
|
|
2425
|
+
const fitTo = React39.useCallback(
|
|
2426
|
+
(available) => update(
|
|
2427
|
+
(current) => {
|
|
2428
|
+
const shown = current.order.map((id) => byId.get(id)).filter((c) => Boolean(c) && !current.hidden.includes(c.id));
|
|
2429
|
+
if (!shown.length || available <= 0) return current;
|
|
2430
|
+
const baseOf = (c) => c.width ?? DEFAULT_WIDTH;
|
|
2431
|
+
const isFlexible = (c) => c.flex !== false && !current.sized.includes(c.id);
|
|
2432
|
+
const flexible = shown.filter(isFlexible);
|
|
2433
|
+
if (!flexible.length) return current;
|
|
2434
|
+
const fixedTotal = shown.filter((c) => !isFlexible(c)).reduce((sum, c) => sum + (current.widths[c.id] ?? baseOf(c)), 0);
|
|
2435
|
+
const flexBaseTotal = flexible.reduce((sum, c) => sum + baseOf(c), 0);
|
|
2436
|
+
const target = available - fixedTotal;
|
|
2437
|
+
const next = { ...current.widths };
|
|
2438
|
+
if (target <= flexBaseTotal) {
|
|
2439
|
+
for (const column of flexible) {
|
|
2440
|
+
next[column.id] = Math.max(baseOf(column), column.minWidth ?? DEFAULT_MIN);
|
|
2441
|
+
}
|
|
2442
|
+
} else {
|
|
2443
|
+
let remaining = target;
|
|
2444
|
+
let pool = flexBaseTotal;
|
|
2445
|
+
const growing = [...flexible];
|
|
2446
|
+
for (let pass = 0; pass < 3 && growing.length; pass += 1) {
|
|
2447
|
+
const scale = remaining / pool;
|
|
2448
|
+
const clamped = [];
|
|
2449
|
+
for (const column of growing) {
|
|
2450
|
+
const min = column.minWidth ?? DEFAULT_MIN;
|
|
2451
|
+
const max = column.maxWidth ?? Infinity;
|
|
2452
|
+
const scaled = baseOf(column) * scale;
|
|
2453
|
+
const bounded = Math.min(Math.max(scaled, min), max);
|
|
2454
|
+
if (bounded !== scaled) {
|
|
2455
|
+
next[column.id] = Math.round(bounded);
|
|
2456
|
+
remaining -= bounded;
|
|
2457
|
+
pool -= baseOf(column);
|
|
2458
|
+
clamped.push(column);
|
|
2459
|
+
}
|
|
2460
|
+
}
|
|
2461
|
+
if (!clamped.length) break;
|
|
2462
|
+
growing.splice(0, growing.length, ...growing.filter((c) => !clamped.includes(c)));
|
|
2463
|
+
}
|
|
2464
|
+
if (growing.length) {
|
|
2465
|
+
const scale = remaining / pool;
|
|
2466
|
+
let used = 0;
|
|
2467
|
+
growing.forEach((column, index) => {
|
|
2468
|
+
if (index === growing.length - 1) {
|
|
2469
|
+
next[column.id] = Math.round(remaining - used);
|
|
2470
|
+
} else {
|
|
2471
|
+
const width = Math.round(baseOf(column) * scale);
|
|
2472
|
+
next[column.id] = width;
|
|
2473
|
+
used += width;
|
|
2474
|
+
}
|
|
2475
|
+
});
|
|
2476
|
+
}
|
|
2477
|
+
}
|
|
2478
|
+
const changed = shown.some(
|
|
2479
|
+
(c) => Math.abs((next[c.id] ?? 0) - (current.widths[c.id] ?? baseOf(c))) > 0.5
|
|
2480
|
+
);
|
|
2481
|
+
return changed ? { ...current, widths: next } : current;
|
|
2482
|
+
},
|
|
2483
|
+
{ persist: false }
|
|
2484
|
+
),
|
|
2485
|
+
[update, byId]
|
|
2486
|
+
);
|
|
2487
|
+
return {
|
|
2488
|
+
layout,
|
|
2489
|
+
visible,
|
|
2490
|
+
widthOf,
|
|
2491
|
+
minWidthOf,
|
|
2492
|
+
setWidth: (id, width) => update((c) => ({
|
|
2493
|
+
...c,
|
|
2494
|
+
widths: { ...c.widths, [id]: width },
|
|
2495
|
+
sized: c.sized.includes(id) ? c.sized : [...c.sized, id]
|
|
2496
|
+
})),
|
|
2497
|
+
fitTo,
|
|
2498
|
+
toggleHidden: (id) => update((c) => ({
|
|
2499
|
+
...c,
|
|
2500
|
+
hidden: c.hidden.includes(id) ? c.hidden.filter((h) => h !== id) : [...c.hidden, id]
|
|
2501
|
+
})),
|
|
2502
|
+
setPinned: (id, side) => update((c) => ({ ...c, pinned: { ...c.pinned, [id]: side } })),
|
|
2503
|
+
move: (id, delta) => update((c) => {
|
|
2504
|
+
const order = [...c.order];
|
|
2505
|
+
const from = order.indexOf(id);
|
|
2506
|
+
const to = Math.min(Math.max(from + delta, 0), order.length - 1);
|
|
2507
|
+
if (from < 0 || from === to) return c;
|
|
2508
|
+
order.splice(to, 0, ...order.splice(from, 1));
|
|
2509
|
+
return { ...c, order };
|
|
2510
|
+
}),
|
|
2511
|
+
moveTo: (id, targetId) => update((c) => {
|
|
2512
|
+
const order = [...c.order];
|
|
2513
|
+
const from = order.indexOf(id);
|
|
2514
|
+
const to = order.indexOf(targetId);
|
|
2515
|
+
if (from < 0 || to < 0 || from === to) return c;
|
|
2516
|
+
order.splice(to, 0, ...order.splice(from, 1));
|
|
2517
|
+
return { ...c, order };
|
|
2518
|
+
}),
|
|
2519
|
+
reset: () => update(() => baseline)
|
|
2520
|
+
};
|
|
2521
|
+
}
|
|
2522
|
+
function merge(base, patch, fallback) {
|
|
2523
|
+
const known = new Set(fallback.order);
|
|
2524
|
+
const order = [
|
|
2525
|
+
...(patch.order ?? base.order).filter((id) => known.has(id)),
|
|
2526
|
+
...fallback.order.filter((id) => !(patch.order ?? base.order).includes(id))
|
|
2527
|
+
];
|
|
2528
|
+
return {
|
|
2529
|
+
order,
|
|
2530
|
+
hidden: (patch.hidden ?? base.hidden).filter((id) => known.has(id)),
|
|
2531
|
+
widths: { ...fallback.widths, ...base.widths, ...patch.widths },
|
|
2532
|
+
pinned: { ...fallback.pinned, ...base.pinned, ...patch.pinned },
|
|
2533
|
+
sized: (patch.sized ?? base.sized ?? []).filter((id) => known.has(id))
|
|
2534
|
+
};
|
|
2535
|
+
}
|
|
2536
|
+
function useRowSelection(options) {
|
|
2537
|
+
const { value, onChange, pageKeys } = options;
|
|
2538
|
+
const anchor = React39.useRef(null);
|
|
2539
|
+
const selected = React39.useMemo(() => new Set(value.keys), [value.keys]);
|
|
2540
|
+
const setKeys = (keys, allMatching = false) => onChange({ keys, allMatching });
|
|
2541
|
+
const toggle = (key, event) => {
|
|
2542
|
+
if (event?.shiftKey && anchor.current) {
|
|
2543
|
+
const from = pageKeys.indexOf(anchor.current);
|
|
2544
|
+
const to = pageKeys.indexOf(key);
|
|
2545
|
+
if (from >= 0 && to >= 0) {
|
|
2546
|
+
const range = pageKeys.slice(Math.min(from, to), Math.max(from, to) + 1);
|
|
2547
|
+
const next2 = new Set(selected);
|
|
2548
|
+
const turningOn = !selected.has(key);
|
|
2549
|
+
range.forEach((id) => turningOn ? next2.add(id) : next2.delete(id));
|
|
2550
|
+
setKeys([...next2]);
|
|
2551
|
+
return;
|
|
2552
|
+
}
|
|
2553
|
+
}
|
|
2554
|
+
anchor.current = key;
|
|
2555
|
+
const next = new Set(selected);
|
|
2556
|
+
if (next.has(key)) next.delete(key);
|
|
2557
|
+
else next.add(key);
|
|
2558
|
+
setKeys([...next]);
|
|
2559
|
+
};
|
|
2560
|
+
const pageSelected = pageKeys.length > 0 && pageKeys.every((key) => selected.has(key));
|
|
2561
|
+
const pagePartial = !pageSelected && pageKeys.some((key) => selected.has(key));
|
|
2562
|
+
const togglePage = () => {
|
|
2563
|
+
const next = new Set(selected);
|
|
2564
|
+
if (pageSelected) pageKeys.forEach((key) => next.delete(key));
|
|
2565
|
+
else pageKeys.forEach((key) => next.add(key));
|
|
2566
|
+
setKeys([...next]);
|
|
2567
|
+
};
|
|
2568
|
+
return {
|
|
2569
|
+
selected,
|
|
2570
|
+
count: value.allMatching ? void 0 : value.keys.length,
|
|
2571
|
+
allMatching: value.allMatching,
|
|
2572
|
+
pageSelected,
|
|
2573
|
+
pagePartial,
|
|
2574
|
+
toggle,
|
|
2575
|
+
togglePage,
|
|
2576
|
+
/** Escalates from "this page" to "everything the filter matches". */
|
|
2577
|
+
selectAllMatching: () => onChange({ keys: value.keys, allMatching: true }),
|
|
2578
|
+
clear: () => {
|
|
2579
|
+
anchor.current = null;
|
|
2580
|
+
onChange({ keys: [], allMatching: false });
|
|
2581
|
+
}
|
|
2582
|
+
};
|
|
2583
|
+
}
|
|
2584
|
+
var SELECT_WIDTH = 44;
|
|
2585
|
+
var EXPAND_WIDTH = 40;
|
|
2586
|
+
function DataTable({
|
|
2587
|
+
columns,
|
|
2588
|
+
data,
|
|
2589
|
+
rowKey,
|
|
2590
|
+
total,
|
|
2591
|
+
loading = false,
|
|
2592
|
+
error,
|
|
2593
|
+
onRetry,
|
|
2594
|
+
query,
|
|
2595
|
+
onQueryChange,
|
|
2596
|
+
selection,
|
|
2597
|
+
onSelectionChange,
|
|
2598
|
+
bulkActions,
|
|
2599
|
+
renderExpanded,
|
|
2600
|
+
onRowClick,
|
|
2601
|
+
layout: controlledLayout,
|
|
2602
|
+
onLayoutChange,
|
|
2603
|
+
persistKey = null,
|
|
2604
|
+
toolbar,
|
|
2605
|
+
autoFit = true,
|
|
2606
|
+
density = "normal",
|
|
2607
|
+
stickyHeader = true,
|
|
2608
|
+
emptyState,
|
|
2609
|
+
pageSizeOptions,
|
|
2610
|
+
labels: labelsProp,
|
|
2611
|
+
locale,
|
|
2612
|
+
caption,
|
|
2613
|
+
className
|
|
2614
|
+
}) {
|
|
2615
|
+
const labels = resolveLabels(labelsProp);
|
|
2616
|
+
const rootRef = React39.useRef(null);
|
|
2617
|
+
const scrollerRef = React39.useRef(null);
|
|
2618
|
+
const [scrolled, setScrolled] = React39.useState({ left: false, right: false });
|
|
2619
|
+
const [expanded, setExpanded] = React39.useState(/* @__PURE__ */ new Set());
|
|
2620
|
+
const [editing, setEditing] = React39.useState(null);
|
|
2621
|
+
const {
|
|
2622
|
+
layout,
|
|
2623
|
+
visible,
|
|
2624
|
+
widthOf,
|
|
2625
|
+
minWidthOf,
|
|
2626
|
+
setWidth,
|
|
2627
|
+
toggleHidden,
|
|
2628
|
+
setPinned,
|
|
2629
|
+
move,
|
|
2630
|
+
moveTo,
|
|
2631
|
+
reset,
|
|
2632
|
+
fitTo
|
|
2633
|
+
} = useColumnLayout({ columns, persistKey, layout: controlledLayout, onLayoutChange });
|
|
2634
|
+
const resize = useColumnResize({ rootRef, widthOf, minWidthOf, onCommit: setWidth });
|
|
2635
|
+
const selectable = Boolean(selection && onSelectionChange);
|
|
2636
|
+
const pageKeys = React39.useMemo(() => data.map(rowKey), [data, rowKey]);
|
|
2637
|
+
const rows = useRowSelection({
|
|
2638
|
+
value: selection ?? { keys: [], allMatching: false },
|
|
2639
|
+
onChange: onSelectionChange ?? (() => {
|
|
2640
|
+
}),
|
|
2641
|
+
pageKeys
|
|
2642
|
+
});
|
|
2643
|
+
const lastFitWidth = React39.useRef(0);
|
|
2644
|
+
React39.useEffect(() => {
|
|
2645
|
+
const scroller = scrollerRef.current;
|
|
2646
|
+
if (!scroller || !autoFit) return;
|
|
2647
|
+
const controls = (selectable ? SELECT_WIDTH : 0) + (renderExpanded ? EXPAND_WIDTH : 0);
|
|
2648
|
+
const run = () => {
|
|
2649
|
+
const available = scroller.clientWidth - controls - 2;
|
|
2650
|
+
if (Math.abs(available - lastFitWidth.current) < 1) return;
|
|
2651
|
+
lastFitWidth.current = available;
|
|
2652
|
+
fitTo(available);
|
|
2653
|
+
};
|
|
2654
|
+
run();
|
|
2655
|
+
const observer = new ResizeObserver(run);
|
|
2656
|
+
observer.observe(scroller);
|
|
2657
|
+
return () => observer.disconnect();
|
|
2658
|
+
}, [autoFit, fitTo, selectable, renderExpanded, layout.hidden, layout.order]);
|
|
2659
|
+
React39.useEffect(() => {
|
|
2660
|
+
const scroller = scrollerRef.current;
|
|
2661
|
+
if (!scroller) return;
|
|
2662
|
+
const update = () => {
|
|
2663
|
+
const max = scroller.scrollWidth - scroller.clientWidth;
|
|
2664
|
+
setScrolled({ left: scroller.scrollLeft > 1, right: scroller.scrollLeft < max - 1 });
|
|
2665
|
+
};
|
|
2666
|
+
update();
|
|
2667
|
+
scroller.addEventListener("scroll", update, { passive: true });
|
|
2668
|
+
const observer = new ResizeObserver(update);
|
|
2669
|
+
observer.observe(scroller);
|
|
2670
|
+
return () => {
|
|
2671
|
+
scroller.removeEventListener("scroll", update);
|
|
2672
|
+
observer.disconnect();
|
|
2673
|
+
};
|
|
2674
|
+
}, [visible.length, data.length]);
|
|
2675
|
+
const offsets = React39.useMemo(() => {
|
|
2676
|
+
const result = /* @__PURE__ */ new Map();
|
|
2677
|
+
let leftParts = selectable ? [`${SELECT_WIDTH}px`] : [];
|
|
2678
|
+
if (renderExpanded) leftParts = [...leftParts, `${EXPAND_WIDTH}px`];
|
|
2679
|
+
for (const column of visible) {
|
|
2680
|
+
if (layout.pinned[column.id] !== "left") continue;
|
|
2681
|
+
result.set(column.id, leftParts.length ? `calc(${leftParts.join(" + ")})` : "0px");
|
|
2682
|
+
leftParts.push(`var(--mz-dt-w-${cssSafe(column.id)}, ${widthOf(column.id)}px)`);
|
|
2683
|
+
}
|
|
2684
|
+
const rightParts = [];
|
|
2685
|
+
for (const column of [...visible].reverse()) {
|
|
2686
|
+
if (layout.pinned[column.id] !== "right") continue;
|
|
2687
|
+
result.set(column.id, rightParts.length ? `calc(${rightParts.join(" + ")})` : "0px");
|
|
2688
|
+
rightParts.push(`var(--mz-dt-w-${cssSafe(column.id)}, ${widthOf(column.id)}px)`);
|
|
2689
|
+
}
|
|
2690
|
+
return result;
|
|
2691
|
+
}, [visible, layout.pinned, widthOf, selectable, renderExpanded]);
|
|
2692
|
+
const widthVars = React39.useMemo(() => {
|
|
2693
|
+
const style = {};
|
|
2694
|
+
for (const column of visible) {
|
|
2695
|
+
style[`--mz-dt-w-${cssSafe(column.id)}`] = `${widthOf(column.id)}px`;
|
|
2696
|
+
}
|
|
2697
|
+
return style;
|
|
2698
|
+
}, [visible, widthOf]);
|
|
2699
|
+
const leftPinned = visible.filter((c) => layout.pinned[c.id] === "left");
|
|
2700
|
+
const rightPinned = visible.filter((c) => layout.pinned[c.id] === "right");
|
|
2701
|
+
const lastLeftPinned = leftPinned[leftPinned.length - 1]?.id;
|
|
2702
|
+
const firstRightPinned = rightPinned[0]?.id;
|
|
2703
|
+
const pinEdgeOf = (id) => id === lastLeftPinned ? "left" : id === firstRightPinned ? "right" : void 0;
|
|
2704
|
+
const controlPinEdge = leftPinned.length === 0 ? "left" : void 0;
|
|
2705
|
+
const chips = activeFilters(query.filters);
|
|
2706
|
+
const columnById = React39.useMemo(() => new Map(columns.map((c) => [c.id, c])), [columns]);
|
|
2707
|
+
const labelOf = (id) => {
|
|
2708
|
+
const column = columnById.get(id);
|
|
2709
|
+
return column?.label ?? (typeof column?.header === "string" ? column.header : id);
|
|
2710
|
+
};
|
|
2711
|
+
const toggleExpanded = (key) => setExpanded((current) => {
|
|
2712
|
+
const next = new Set(current);
|
|
2713
|
+
if (next.has(key)) next.delete(key);
|
|
2714
|
+
else next.add(key);
|
|
2715
|
+
return next;
|
|
2716
|
+
});
|
|
2717
|
+
const fillerIndex = visible.length - rightPinned.length;
|
|
2718
|
+
const colSpan = visible.length + 1 + (selectable ? 1 : 0) + (renderExpanded ? 1 : 0);
|
|
2719
|
+
const selectionCount = rows.allMatching ? total : rows.count;
|
|
2720
|
+
const renderHeaderCells = (list) => list.map((column) => {
|
|
2721
|
+
const { dir, index } = sortStateOf(query, column.id);
|
|
2722
|
+
const pinned = layout.pinned[column.id];
|
|
2723
|
+
const label = labelOf(column.id);
|
|
2724
|
+
return /* @__PURE__ */ jsxs(
|
|
2725
|
+
"th",
|
|
2726
|
+
{
|
|
2727
|
+
"data-col": column.id,
|
|
2728
|
+
"data-pinned": pinned,
|
|
2729
|
+
"data-pin-edge": pinEdgeOf(column.id),
|
|
2730
|
+
"data-align": column.align,
|
|
2731
|
+
"aria-sort": dir === "asc" ? "ascending" : dir === "desc" ? "descending" : "none",
|
|
2732
|
+
className: "mz-dt__th",
|
|
2733
|
+
style: pinned ? { [pinned]: offsets.get(column.id) } : void 0,
|
|
2734
|
+
children: [
|
|
2735
|
+
/* @__PURE__ */ jsxs("div", { className: "mz-dt__th-inner", children: [
|
|
2736
|
+
column.sortable ? /* @__PURE__ */ jsxs(
|
|
2737
|
+
"button",
|
|
2738
|
+
{
|
|
2739
|
+
type: "button",
|
|
2740
|
+
className: "mz-dt__sort mz-focusable",
|
|
2741
|
+
title: labels.sortBy(label),
|
|
2742
|
+
onClick: (event) => onQueryChange(toggleSort(query, column.id, event.shiftKey)),
|
|
2743
|
+
children: [
|
|
2744
|
+
/* @__PURE__ */ jsx("span", { className: "mz-dt__th-label", children: column.header }),
|
|
2745
|
+
/* @__PURE__ */ jsxs("span", { className: "mz-dt__sort-icon", "data-active": dir ? true : void 0, children: [
|
|
2746
|
+
dir === "asc" ? /* @__PURE__ */ jsx(ArrowUpIcon, {}) : dir === "desc" ? /* @__PURE__ */ jsx(ArrowDownIcon, {}) : /* @__PURE__ */ jsx(SortIcon, {}),
|
|
2747
|
+
index ? /* @__PURE__ */ jsx("b", { children: index }) : null
|
|
2748
|
+
] })
|
|
2749
|
+
]
|
|
2750
|
+
}
|
|
2751
|
+
) : /* @__PURE__ */ jsx("span", { className: "mz-dt__th-label", title: column.headerTitle, children: column.header }),
|
|
2752
|
+
column.filter ? /* @__PURE__ */ jsx(
|
|
2753
|
+
ColumnFilter,
|
|
2754
|
+
{
|
|
2755
|
+
columnLabel: label,
|
|
2756
|
+
def: column.filter,
|
|
2757
|
+
value: query.filters[column.id],
|
|
2758
|
+
onApply: (value) => onQueryChange(setFilter(query, column.id, value))
|
|
2759
|
+
}
|
|
2760
|
+
) : null
|
|
2761
|
+
] }),
|
|
2762
|
+
column.resizable === false ? null : /* @__PURE__ */ jsx(
|
|
2763
|
+
"span",
|
|
2764
|
+
{
|
|
2765
|
+
role: "separator",
|
|
2766
|
+
"aria-orientation": "vertical",
|
|
2767
|
+
"aria-label": labels.columnWidth(label),
|
|
2768
|
+
tabIndex: 0,
|
|
2769
|
+
className: "mz-dt__resizer mz-focusable",
|
|
2770
|
+
"data-resizing": resize.resizing === column.id || void 0,
|
|
2771
|
+
onPointerDown: (event) => resize.start(event, column.id),
|
|
2772
|
+
onDoubleClick: () => resize.autoFit(column.id),
|
|
2773
|
+
onKeyDown: (event) => resize.onKeyDown(event, column.id)
|
|
2774
|
+
}
|
|
2775
|
+
)
|
|
2776
|
+
]
|
|
2777
|
+
},
|
|
2778
|
+
column.id
|
|
2779
|
+
);
|
|
2780
|
+
});
|
|
2781
|
+
const renderBodyCells = (row, rowIndex, list) => {
|
|
2782
|
+
const key = rowKey(row);
|
|
2783
|
+
return list.map((column) => {
|
|
2784
|
+
const pinned = layout.pinned[column.id];
|
|
2785
|
+
const isEditing = editing?.key === key && editing.col === column.id;
|
|
2786
|
+
return /* @__PURE__ */ jsx(
|
|
2787
|
+
"td",
|
|
2788
|
+
{
|
|
2789
|
+
"data-col": column.id,
|
|
2790
|
+
"data-pinned": pinned,
|
|
2791
|
+
"data-pin-edge": pinEdgeOf(column.id),
|
|
2792
|
+
"data-align": column.align,
|
|
2793
|
+
"data-editable": column.editable ? true : void 0,
|
|
2794
|
+
className: "mz-dt__td",
|
|
2795
|
+
style: pinned ? { [pinned]: offsets.get(column.id) } : void 0,
|
|
2796
|
+
onDoubleClick: column.editable ? (event) => {
|
|
2797
|
+
event.stopPropagation();
|
|
2798
|
+
setEditing({ key, col: column.id });
|
|
2799
|
+
} : void 0,
|
|
2800
|
+
children: isEditing && column.editable ? /* @__PURE__ */ jsx(
|
|
2801
|
+
CellEditor,
|
|
2802
|
+
{
|
|
2803
|
+
row,
|
|
2804
|
+
def: column.editable,
|
|
2805
|
+
onDone: () => setEditing(null)
|
|
2806
|
+
}
|
|
2807
|
+
) : /* @__PURE__ */ jsx("div", { className: "mz-dt__cell", children: column.cell ? column.cell(row, { rowIndex }) : column.accessor?.(row) })
|
|
2808
|
+
},
|
|
2809
|
+
column.id
|
|
2810
|
+
);
|
|
2811
|
+
});
|
|
2812
|
+
};
|
|
2813
|
+
return /* @__PURE__ */ jsxs(
|
|
2814
|
+
"div",
|
|
2815
|
+
{
|
|
2816
|
+
ref: rootRef,
|
|
2817
|
+
"data-slot": "data-table",
|
|
2818
|
+
"data-density": density,
|
|
2819
|
+
className: cn("mz-dt", className),
|
|
2820
|
+
style: widthVars,
|
|
2821
|
+
children: [
|
|
2822
|
+
(toolbar || chips.length > 0 || columns.some((c) => c.hideable !== false)) && /* @__PURE__ */ jsxs("div", { className: "mz-dt__toolbar", children: [
|
|
2823
|
+
/* @__PURE__ */ jsx("div", { className: "mz-dt__toolbar-main", children: toolbar }),
|
|
2824
|
+
/* @__PURE__ */ jsx("div", { className: "mz-dt__toolbar-side", children: /* @__PURE__ */ jsx(
|
|
2825
|
+
ColumnManager,
|
|
2826
|
+
{
|
|
2827
|
+
columns,
|
|
2828
|
+
layout,
|
|
2829
|
+
labels: labelsProp,
|
|
2830
|
+
onToggleHidden: toggleHidden,
|
|
2831
|
+
onSetPinned: setPinned,
|
|
2832
|
+
onMove: move,
|
|
2833
|
+
onMoveTo: moveTo,
|
|
2834
|
+
onReset: reset
|
|
2835
|
+
}
|
|
2836
|
+
) })
|
|
2837
|
+
] }),
|
|
2838
|
+
chips.length > 0 && /* @__PURE__ */ jsxs("div", { className: "mz-dt__chips", children: [
|
|
2839
|
+
chips.map(([id, value]) => /* @__PURE__ */ jsx(
|
|
2840
|
+
FilterChip,
|
|
2841
|
+
{
|
|
2842
|
+
label: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2843
|
+
/* @__PURE__ */ jsx("b", { children: labelOf(id) }),
|
|
2844
|
+
describeFilter(value, columnById.get(id)?.filter, labels)
|
|
2845
|
+
] }),
|
|
2846
|
+
clearLabel: labels.clearFilter,
|
|
2847
|
+
onClear: () => onQueryChange(setFilter(query, id, void 0))
|
|
2848
|
+
},
|
|
2849
|
+
id
|
|
2850
|
+
)),
|
|
2851
|
+
/* @__PURE__ */ jsx(
|
|
2852
|
+
Button,
|
|
2853
|
+
{
|
|
2854
|
+
variant: "link",
|
|
2855
|
+
size: "xs",
|
|
2856
|
+
onClick: () => onQueryChange({ ...query, filters: {}, page: 1 }),
|
|
2857
|
+
children: labels.resetAll
|
|
2858
|
+
}
|
|
2859
|
+
)
|
|
2860
|
+
] }),
|
|
2861
|
+
/* @__PURE__ */ jsxs(
|
|
2862
|
+
"div",
|
|
2863
|
+
{
|
|
2864
|
+
ref: scrollerRef,
|
|
2865
|
+
className: "mz-dt__scroller",
|
|
2866
|
+
"data-scrolled-left": scrolled.left || void 0,
|
|
2867
|
+
"data-scrolled-right": scrolled.right || void 0,
|
|
2868
|
+
children: [
|
|
2869
|
+
/* @__PURE__ */ jsxs("table", { className: "mz-dt__table", "data-sticky": stickyHeader || void 0, children: [
|
|
2870
|
+
caption ? /* @__PURE__ */ jsx("caption", { className: "mz-sr-only", children: caption }) : null,
|
|
2871
|
+
/* @__PURE__ */ jsxs("colgroup", { children: [
|
|
2872
|
+
selectable ? /* @__PURE__ */ jsx("col", { style: { width: SELECT_WIDTH } }) : null,
|
|
2873
|
+
renderExpanded ? /* @__PURE__ */ jsx("col", { style: { width: EXPAND_WIDTH } }) : null,
|
|
2874
|
+
visible.slice(0, fillerIndex).map((column) => /* @__PURE__ */ jsx(
|
|
2875
|
+
"col",
|
|
2876
|
+
{
|
|
2877
|
+
style: { width: `var(--mz-dt-w-${cssSafe(column.id)}, ${widthOf(column.id)}px)` }
|
|
2878
|
+
},
|
|
2879
|
+
column.id
|
|
2880
|
+
)),
|
|
2881
|
+
/* @__PURE__ */ jsx("col", { className: "mz-dt__col-filler" }),
|
|
2882
|
+
visible.slice(fillerIndex).map((column) => /* @__PURE__ */ jsx(
|
|
2883
|
+
"col",
|
|
2884
|
+
{
|
|
2885
|
+
style: { width: `var(--mz-dt-w-${cssSafe(column.id)}, ${widthOf(column.id)}px)` }
|
|
2886
|
+
},
|
|
2887
|
+
column.id
|
|
2888
|
+
))
|
|
2889
|
+
] }),
|
|
2890
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
2891
|
+
selectable ? /* @__PURE__ */ jsx(
|
|
2892
|
+
"th",
|
|
2893
|
+
{
|
|
2894
|
+
className: "mz-dt__th mz-dt__th--control",
|
|
2895
|
+
"data-pinned": "left",
|
|
2896
|
+
"data-pin-edge": renderExpanded ? void 0 : controlPinEdge,
|
|
2897
|
+
style: { left: 0 },
|
|
2898
|
+
children: /* @__PURE__ */ jsx(
|
|
2899
|
+
Checkbox,
|
|
2900
|
+
{
|
|
2901
|
+
size: "sm",
|
|
2902
|
+
"aria-label": labels.selectPage,
|
|
2903
|
+
checked: rows.pageSelected ? true : rows.pagePartial ? "indeterminate" : false,
|
|
2904
|
+
onCheckedChange: rows.togglePage
|
|
2905
|
+
}
|
|
2906
|
+
)
|
|
2907
|
+
}
|
|
2908
|
+
) : null,
|
|
2909
|
+
renderExpanded ? /* @__PURE__ */ jsx(
|
|
2910
|
+
"th",
|
|
2911
|
+
{
|
|
2912
|
+
className: "mz-dt__th mz-dt__th--control",
|
|
2913
|
+
"data-pinned": "left",
|
|
2914
|
+
"data-pin-edge": controlPinEdge,
|
|
2915
|
+
style: { left: selectable ? SELECT_WIDTH : 0 },
|
|
2916
|
+
children: /* @__PURE__ */ jsx("span", { className: "mz-sr-only", children: labels.details })
|
|
2917
|
+
}
|
|
2918
|
+
) : null,
|
|
2919
|
+
renderHeaderCells(visible.slice(0, fillerIndex)),
|
|
2920
|
+
/* @__PURE__ */ jsx("th", { className: "mz-dt__th mz-dt__th--filler", "aria-hidden": "true" }),
|
|
2921
|
+
renderHeaderCells(visible.slice(fillerIndex))
|
|
2922
|
+
] }) }),
|
|
2923
|
+
/* @__PURE__ */ jsx("tbody", { children: loading && data.length === 0 ? Array.from({ length: Math.min(query.pageSize, 8) }, (_, index) => /* @__PURE__ */ jsx("tr", { className: "mz-dt__row", children: /* @__PURE__ */ jsx("td", { className: "mz-dt__td", colSpan, children: /* @__PURE__ */ jsx(Skeleton, { style: { height: 14, width: `${60 + index * 13 % 35}%` } }) }) }, `skeleton-${index}`)) : data.map((row, rowIndex) => {
|
|
2924
|
+
const key = rowKey(row);
|
|
2925
|
+
const isOpen = expanded.has(key);
|
|
2926
|
+
return /* @__PURE__ */ jsxs(React39.Fragment, { children: [
|
|
2927
|
+
/* @__PURE__ */ jsxs(
|
|
2928
|
+
"tr",
|
|
2929
|
+
{
|
|
2930
|
+
className: "mz-dt__row",
|
|
2931
|
+
"data-selected": rows.selected.has(key) || rows.allMatching || void 0,
|
|
2932
|
+
"data-clickable": onRowClick ? true : void 0,
|
|
2933
|
+
onClick: onRowClick ? () => onRowClick(row) : void 0,
|
|
2934
|
+
children: [
|
|
2935
|
+
selectable ? /* @__PURE__ */ jsx(
|
|
2936
|
+
"td",
|
|
2937
|
+
{
|
|
2938
|
+
className: "mz-dt__td mz-dt__td--control",
|
|
2939
|
+
"data-pinned": "left",
|
|
2940
|
+
"data-pin-edge": renderExpanded ? void 0 : controlPinEdge,
|
|
2941
|
+
style: { left: 0 },
|
|
2942
|
+
onClick: (event) => event.stopPropagation(),
|
|
2943
|
+
children: /* @__PURE__ */ jsx(
|
|
2944
|
+
Checkbox,
|
|
2945
|
+
{
|
|
2946
|
+
size: "sm",
|
|
2947
|
+
"aria-label": labels.selectRow,
|
|
2948
|
+
checked: rows.selected.has(key) || rows.allMatching,
|
|
2949
|
+
onClick: (event) => rows.toggle(key, { shiftKey: event.shiftKey })
|
|
2950
|
+
}
|
|
2951
|
+
)
|
|
2952
|
+
}
|
|
2953
|
+
) : null,
|
|
2954
|
+
renderExpanded ? /* @__PURE__ */ jsx(
|
|
2955
|
+
"td",
|
|
2956
|
+
{
|
|
2957
|
+
className: "mz-dt__td mz-dt__td--control",
|
|
2958
|
+
"data-pinned": "left",
|
|
2959
|
+
"data-pin-edge": controlPinEdge,
|
|
2960
|
+
style: { left: selectable ? SELECT_WIDTH : 0 },
|
|
2961
|
+
onClick: (event) => event.stopPropagation(),
|
|
2962
|
+
children: /* @__PURE__ */ jsx(
|
|
2963
|
+
"button",
|
|
2964
|
+
{
|
|
2965
|
+
type: "button",
|
|
2966
|
+
className: "mz-dt__expand mz-focusable",
|
|
2967
|
+
"data-open": isOpen || void 0,
|
|
2968
|
+
"aria-expanded": isOpen,
|
|
2969
|
+
"aria-label": isOpen ? labels.collapseRow : labels.expandRow,
|
|
2970
|
+
onClick: () => toggleExpanded(key),
|
|
2971
|
+
children: /* @__PURE__ */ jsx(ChevronRightIcon, {})
|
|
2972
|
+
}
|
|
2973
|
+
)
|
|
2974
|
+
}
|
|
2975
|
+
) : null,
|
|
2976
|
+
renderBodyCells(row, rowIndex, visible.slice(0, fillerIndex)),
|
|
2977
|
+
/* @__PURE__ */ jsx("td", { className: "mz-dt__td mz-dt__td--filler", "aria-hidden": "true" }),
|
|
2978
|
+
renderBodyCells(row, rowIndex, visible.slice(fillerIndex))
|
|
2979
|
+
]
|
|
2980
|
+
}
|
|
2981
|
+
),
|
|
2982
|
+
isOpen && renderExpanded ? /* @__PURE__ */ jsx("tr", { className: "mz-dt__row mz-dt__row--expanded", children: /* @__PURE__ */ jsx("td", { className: "mz-dt__td mz-dt__td--expanded", colSpan, children: renderExpanded(row) }) }) : null
|
|
2983
|
+
] }, key);
|
|
2984
|
+
}) })
|
|
2985
|
+
] }),
|
|
2986
|
+
!loading && !error && data.length === 0 ? /* @__PURE__ */ jsx("div", { className: "mz-dt__state", children: emptyState ?? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2987
|
+
/* @__PURE__ */ jsx(InboxIcon, {}),
|
|
2988
|
+
/* @__PURE__ */ jsx("p", { children: labels.empty }),
|
|
2989
|
+
chips.length > 0 ? /* @__PURE__ */ jsx(
|
|
2990
|
+
Button,
|
|
2991
|
+
{
|
|
2992
|
+
size: "sm",
|
|
2993
|
+
variant: "secondary",
|
|
2994
|
+
onClick: () => onQueryChange({ ...query, filters: {}, page: 1 }),
|
|
2995
|
+
children: labels.resetFilters
|
|
2996
|
+
}
|
|
2997
|
+
) : null
|
|
2998
|
+
] }) }) : null,
|
|
2999
|
+
error ? /* @__PURE__ */ jsxs("div", { className: "mz-dt__state", "data-tone": "danger", children: [
|
|
3000
|
+
/* @__PURE__ */ jsx(AlertIcon, {}),
|
|
3001
|
+
/* @__PURE__ */ jsx("p", { children: error }),
|
|
3002
|
+
onRetry ? /* @__PURE__ */ jsx(Button, { size: "sm", variant: "secondary", onClick: onRetry, children: labels.retry }) : null
|
|
3003
|
+
] }) : null,
|
|
3004
|
+
loading && data.length > 0 ? /* @__PURE__ */ jsx("div", { className: "mz-dt__loading-bar", "aria-hidden": "true" }) : null
|
|
3005
|
+
]
|
|
3006
|
+
}
|
|
3007
|
+
),
|
|
3008
|
+
/* @__PURE__ */ jsx(
|
|
3009
|
+
DataTablePagination,
|
|
3010
|
+
{
|
|
3011
|
+
query,
|
|
3012
|
+
total,
|
|
3013
|
+
rowsOnPage: data.length,
|
|
3014
|
+
pageSizeOptions,
|
|
3015
|
+
labels: labelsProp,
|
|
3016
|
+
locale,
|
|
3017
|
+
onQueryChange
|
|
3018
|
+
}
|
|
3019
|
+
),
|
|
3020
|
+
selectable && (rows.count ?? 0) > 0 ? /* @__PURE__ */ jsxs("div", { className: "mz-dt__bulkbar", role: "region", "aria-label": labels.bulkActions, children: [
|
|
3021
|
+
/* @__PURE__ */ jsxs("span", { className: "mz-dt__bulkbar-count", children: [
|
|
3022
|
+
labels.selectedCount(
|
|
3023
|
+
selectionCount?.toLocaleString(locale) ?? String(rows.count ?? 0)
|
|
3024
|
+
),
|
|
3025
|
+
rows.allMatching ? labels.allMatchingSuffix : null
|
|
3026
|
+
] }),
|
|
3027
|
+
!rows.allMatching && total !== void 0 && rows.pageSelected && total > data.length ? /* @__PURE__ */ jsx(Button, { variant: "link", size: "xs", onClick: rows.selectAllMatching, children: labels.selectAllMatching(total.toLocaleString(locale)) }) : null,
|
|
3028
|
+
/* @__PURE__ */ jsxs("div", { className: "mz-dt__bulkbar-actions", children: [
|
|
3029
|
+
bulkActions?.(selection ?? { keys: [], allMatching: false }),
|
|
3030
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", onClick: rows.clear, children: labels.clearSelection })
|
|
3031
|
+
] })
|
|
3032
|
+
] }) : null
|
|
3033
|
+
]
|
|
3034
|
+
}
|
|
3035
|
+
);
|
|
3036
|
+
}
|
|
3037
|
+
function describeFilter(value, def, labels) {
|
|
3038
|
+
switch (value.type) {
|
|
3039
|
+
case "text":
|
|
3040
|
+
return `: \u201C${value.value}\u201D`;
|
|
3041
|
+
case "select": {
|
|
3042
|
+
const options = def?.type === "select" ? def.options : [];
|
|
3043
|
+
const labels2 = value.value.map(
|
|
3044
|
+
(v) => options.find((option) => option.value === v)?.label ?? v
|
|
3045
|
+
);
|
|
3046
|
+
return `: ${labels2.join(", ")}`;
|
|
3047
|
+
}
|
|
3048
|
+
case "number-range":
|
|
3049
|
+
return `: ${value.min ?? "\u2026"}\u2013${value.max ?? "\u2026"}`;
|
|
3050
|
+
case "date-range":
|
|
3051
|
+
return `: ${value.from ?? "\u2026"} \u2013 ${value.to ?? "\u2026"}`;
|
|
3052
|
+
case "boolean":
|
|
3053
|
+
return `: ${value.value ? labels.yes.toLowerCase() : labels.no.toLowerCase()}`;
|
|
3054
|
+
}
|
|
3055
|
+
}
|
|
3056
|
+
|
|
3057
|
+
// src/components/data-table/types.ts
|
|
3058
|
+
var emptyQuery = {
|
|
3059
|
+
sort: [],
|
|
3060
|
+
filters: {},
|
|
3061
|
+
page: 1,
|
|
3062
|
+
pageSize: 25
|
|
3063
|
+
};
|
|
3064
|
+
|
|
3065
|
+
// src/components/data-table/use-table-query.ts
|
|
3066
|
+
function encode(query, prefix) {
|
|
3067
|
+
const params = new URLSearchParams(window.location.search);
|
|
3068
|
+
const set = (key, value) => {
|
|
3069
|
+
if (value) params.set(prefix + key, value);
|
|
3070
|
+
else params.delete(prefix + key);
|
|
3071
|
+
};
|
|
3072
|
+
set("sort", serializeSort(query.sort) || void 0);
|
|
3073
|
+
set("page", query.page > 1 ? String(query.page) : void 0);
|
|
3074
|
+
set("size", String(query.pageSize));
|
|
3075
|
+
set("f", Object.keys(query.filters).length ? JSON.stringify(query.filters) : void 0);
|
|
3076
|
+
return params;
|
|
3077
|
+
}
|
|
3078
|
+
function decode(prefix, fallback) {
|
|
3079
|
+
const params = new URLSearchParams(window.location.search);
|
|
3080
|
+
const get = (key) => params.get(prefix + key);
|
|
3081
|
+
let filters = fallback.filters;
|
|
3082
|
+
const rawFilters = get("f");
|
|
3083
|
+
if (rawFilters) {
|
|
3084
|
+
try {
|
|
3085
|
+
filters = JSON.parse(rawFilters);
|
|
3086
|
+
} catch {
|
|
3087
|
+
filters = {};
|
|
3088
|
+
}
|
|
3089
|
+
}
|
|
3090
|
+
return {
|
|
3091
|
+
sort: get("sort") ? parseSort(get("sort")) : fallback.sort,
|
|
3092
|
+
filters,
|
|
3093
|
+
page: Number(get("page") ?? fallback.page) || 1,
|
|
3094
|
+
pageSize: Number(get("size") ?? fallback.pageSize) || fallback.pageSize
|
|
3095
|
+
};
|
|
3096
|
+
}
|
|
3097
|
+
function useTableQuery({
|
|
3098
|
+
initial,
|
|
3099
|
+
urlKey = null,
|
|
3100
|
+
history = "replace"
|
|
3101
|
+
} = {}) {
|
|
3102
|
+
const base = React39.useMemo(() => ({ ...emptyQuery, ...initial }), [initial]);
|
|
3103
|
+
const [query, setQuery] = React39.useState(base);
|
|
3104
|
+
React39.useEffect(() => {
|
|
3105
|
+
if (urlKey === null || typeof window === "undefined") return;
|
|
3106
|
+
setQuery(decode(urlKey, base));
|
|
3107
|
+
}, [urlKey]);
|
|
3108
|
+
React39.useEffect(() => {
|
|
3109
|
+
if (urlKey === null || typeof window === "undefined") return;
|
|
3110
|
+
const params = encode(query, urlKey);
|
|
3111
|
+
const search = params.toString();
|
|
3112
|
+
const next = `${window.location.pathname}${search ? `?${search}` : ""}${window.location.hash}`;
|
|
3113
|
+
if (next === `${window.location.pathname}${window.location.search}${window.location.hash}`) return;
|
|
3114
|
+
window.history[history === "push" ? "pushState" : "replaceState"](null, "", next);
|
|
3115
|
+
}, [query, urlKey, history]);
|
|
3116
|
+
React39.useEffect(() => {
|
|
3117
|
+
if (urlKey === null || typeof window === "undefined") return;
|
|
3118
|
+
const onPop = () => setQuery(decode(urlKey, base));
|
|
3119
|
+
window.addEventListener("popstate", onPop);
|
|
3120
|
+
return () => window.removeEventListener("popstate", onPop);
|
|
3121
|
+
}, [urlKey, base]);
|
|
3122
|
+
const reset = React39.useCallback(() => setQuery(base), [base]);
|
|
3123
|
+
return { query, setQuery, reset };
|
|
3124
|
+
}
|
|
3125
|
+
function useSavedViews({
|
|
3126
|
+
storageKey = null,
|
|
3127
|
+
views: controlled,
|
|
3128
|
+
onViewsChange
|
|
3129
|
+
} = {}) {
|
|
3130
|
+
const [internal, setInternal] = React39.useState([]);
|
|
3131
|
+
React39.useEffect(() => {
|
|
3132
|
+
if (!storageKey || typeof window === "undefined") return;
|
|
3133
|
+
try {
|
|
3134
|
+
const raw = window.localStorage.getItem(storageKey);
|
|
3135
|
+
if (raw) setInternal(JSON.parse(raw));
|
|
3136
|
+
} catch {
|
|
3137
|
+
}
|
|
3138
|
+
}, [storageKey]);
|
|
3139
|
+
const views = controlled ?? internal;
|
|
3140
|
+
const persist = React39.useCallback(
|
|
3141
|
+
(next) => {
|
|
3142
|
+
setInternal(next);
|
|
3143
|
+
onViewsChange?.(next);
|
|
3144
|
+
if (!storageKey || typeof window === "undefined") return;
|
|
3145
|
+
try {
|
|
3146
|
+
window.localStorage.setItem(storageKey, JSON.stringify(next));
|
|
3147
|
+
} catch {
|
|
3148
|
+
}
|
|
3149
|
+
},
|
|
3150
|
+
[storageKey, onViewsChange]
|
|
3151
|
+
);
|
|
3152
|
+
return {
|
|
3153
|
+
views,
|
|
3154
|
+
save: (view) => persist([...views.filter((v) => v.id !== view.id), view]),
|
|
3155
|
+
remove: (id) => persist(views.filter((v) => v.id !== id))
|
|
3156
|
+
};
|
|
3157
|
+
}
|
|
3158
|
+
|
|
3159
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertTitle, Avatar, AvatarFallback, AvatarImage, Badge, Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, ColumnFilter, ColumnManager, DataTable, DataTablePagination, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Field, FieldError, FieldHint, FilterChip, Input, Label, MorzeThemeProvider, Popover, PopoverAnchor, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger, Progress, RadioGroup, RadioGroupItem, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarPanel, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Slider, Spinner, Switch, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, activeFilters, badgeVariants, buttonVariants, cn, defaultDataTableLabels, emptyQuery, isFilterActive, pageCount, parseSort, resolveLabels, serializeSort, setFilter, sortStateOf, toggleSort, toggleVariants, useColumnLayout, useIsMobile, useMorzeTheme, useRowSelection, useSavedViews, useSidebar, useTableQuery };
|
|
3160
|
+
//# sourceMappingURL=index.js.map
|
|
3161
|
+
//# sourceMappingURL=index.js.map
|