@morze/ui 0.2.11 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +188 -22
- package/dist/form/index.cjs +128 -0
- package/dist/form/index.cjs.map +1 -0
- package/dist/form/index.d.cts +58 -0
- package/dist/form/index.d.ts +58 -0
- package/dist/form/index.js +99 -0
- package/dist/form/index.js.map +1 -0
- package/dist/index.cjs +1652 -168
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +346 -8
- package/dist/index.d.ts +346 -8
- package/dist/index.js +1583 -169
- package/dist/index.js.map +1 -1
- package/dist/label-Bf37KoRc.d.cts +6 -0
- package/dist/label-Bf37KoRc.d.ts +6 -0
- package/dist/locales/en.cjs +10 -1
- package/dist/locales/en.cjs.map +1 -1
- package/dist/locales/en.d.cts +4 -2
- package/dist/locales/en.d.ts +4 -2
- package/dist/locales/en.js +10 -2
- package/dist/locales/en.js.map +1 -1
- package/dist/locales/ru.cjs +10 -1
- package/dist/locales/ru.cjs.map +1 -1
- package/dist/locales/ru.d.cts +4 -2
- package/dist/locales/ru.d.ts +4 -2
- package/dist/locales/ru.js +10 -2
- package/dist/locales/ru.js.map +1 -1
- package/dist/morze-ui-tokens.css +1 -1
- package/dist/morze-ui.css +1 -1
- package/dist/types-B3pfG-Kz.d.cts +164 -0
- package/dist/types-B3pfG-Kz.d.ts +164 -0
- package/package.json +15 -3
- package/dist/types-B8jz2FF9.d.cts +0 -75
- package/dist/types-B8jz2FF9.d.ts +0 -75
package/dist/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { clsx } from 'clsx';
|
|
3
|
-
import * as
|
|
3
|
+
import * as React48 from 'react';
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
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,
|
|
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, DropdownMenu as DropdownMenu$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, Tooltip as Tooltip$1, AlertDialog as AlertDialog$1, ScrollArea as ScrollArea$1, Menubar as Menubar$1, NavigationMenu as NavigationMenu$1, Toast as Toast$1 } from 'radix-ui';
|
|
7
7
|
|
|
8
8
|
// src/lib/utils.ts
|
|
9
9
|
function cn(...inputs) {
|
|
10
10
|
return clsx(inputs);
|
|
11
11
|
}
|
|
12
|
-
var ThemeContext =
|
|
12
|
+
var ThemeContext = React48.createContext(null);
|
|
13
13
|
function readStored(key) {
|
|
14
14
|
if (!key || typeof window === "undefined") return null;
|
|
15
15
|
try {
|
|
@@ -37,15 +37,15 @@ function MorzeThemeProvider({
|
|
|
37
37
|
target = "html",
|
|
38
38
|
className
|
|
39
39
|
}) {
|
|
40
|
-
const [theme, setThemeState] =
|
|
41
|
-
const [resolved, setResolved] =
|
|
40
|
+
const [theme, setThemeState] = React48.useState(defaultTheme);
|
|
41
|
+
const [resolved, setResolved] = React48.useState(
|
|
42
42
|
defaultTheme === "system" ? "dark" : defaultTheme
|
|
43
43
|
);
|
|
44
|
-
|
|
44
|
+
React48.useEffect(() => {
|
|
45
45
|
const stored = readStored(storageKey);
|
|
46
46
|
if (stored) setThemeState(stored);
|
|
47
47
|
}, [storageKey]);
|
|
48
|
-
|
|
48
|
+
React48.useEffect(() => {
|
|
49
49
|
if (theme !== "system") {
|
|
50
50
|
setResolved(theme);
|
|
51
51
|
return;
|
|
@@ -56,18 +56,18 @@ function MorzeThemeProvider({
|
|
|
56
56
|
mql.addEventListener("change", onChange);
|
|
57
57
|
return () => mql.removeEventListener("change", onChange);
|
|
58
58
|
}, [theme]);
|
|
59
|
-
|
|
59
|
+
React48.useEffect(() => {
|
|
60
60
|
if (target !== "html" || typeof document === "undefined") return;
|
|
61
61
|
document.documentElement.setAttribute("data-mz-theme", resolved);
|
|
62
62
|
}, [resolved, target]);
|
|
63
|
-
const setTheme =
|
|
63
|
+
const setTheme = React48.useCallback(
|
|
64
64
|
(next) => {
|
|
65
65
|
setThemeState(next);
|
|
66
66
|
writeStored(storageKey, next);
|
|
67
67
|
},
|
|
68
68
|
[storageKey]
|
|
69
69
|
);
|
|
70
|
-
const value =
|
|
70
|
+
const value = React48.useMemo(
|
|
71
71
|
() => ({ theme, resolvedTheme: resolved, setTheme }),
|
|
72
72
|
[theme, resolved, setTheme]
|
|
73
73
|
);
|
|
@@ -82,7 +82,7 @@ function MorzeThemeProvider({
|
|
|
82
82
|
) });
|
|
83
83
|
}
|
|
84
84
|
function useMorzeTheme() {
|
|
85
|
-
const context =
|
|
85
|
+
const context = React48.useContext(ThemeContext);
|
|
86
86
|
if (!context) {
|
|
87
87
|
throw new Error("useMorzeTheme must be used inside <MorzeThemeProvider>");
|
|
88
88
|
}
|
|
@@ -115,6 +115,13 @@ var ChevronDownIcon = icon(/* @__PURE__ */ jsx("path", { d: "m6 9 6 6 6-6" }));
|
|
|
115
115
|
var ChevronUpIcon = icon(/* @__PURE__ */ jsx("path", { d: "m18 15-6-6-6 6" }));
|
|
116
116
|
var ChevronRightIcon = icon(/* @__PURE__ */ jsx("path", { d: "m9 18 6-6-6-6" }));
|
|
117
117
|
var DotIcon = icon(/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "4", fill: "currentColor" }));
|
|
118
|
+
var EllipsisIcon = icon(
|
|
119
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
120
|
+
/* @__PURE__ */ jsx("circle", { cx: "5", cy: "12", r: "1.5", fill: "currentColor", stroke: "none" }),
|
|
121
|
+
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "1.5", fill: "currentColor", stroke: "none" }),
|
|
122
|
+
/* @__PURE__ */ jsx("circle", { cx: "19", cy: "12", r: "1.5", fill: "currentColor", stroke: "none" })
|
|
123
|
+
] })
|
|
124
|
+
);
|
|
118
125
|
var SpinnerIcon = icon(
|
|
119
126
|
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
120
127
|
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "9", opacity: "0.25" }),
|
|
@@ -235,8 +242,8 @@ function Button({
|
|
|
235
242
|
] });
|
|
236
243
|
let content;
|
|
237
244
|
if (asChild) {
|
|
238
|
-
const child =
|
|
239
|
-
content =
|
|
245
|
+
const child = React48.Children.only(children);
|
|
246
|
+
content = React48.cloneElement(child, void 0, decorate(child.props.children));
|
|
240
247
|
} else {
|
|
241
248
|
content = decorate(children);
|
|
242
249
|
}
|
|
@@ -326,7 +333,7 @@ function Toggle({
|
|
|
326
333
|
}
|
|
327
334
|
);
|
|
328
335
|
}
|
|
329
|
-
var ToggleGroupContext =
|
|
336
|
+
var ToggleGroupContext = React48.createContext({
|
|
330
337
|
size: "md",
|
|
331
338
|
variant: "default"
|
|
332
339
|
});
|
|
@@ -367,7 +374,7 @@ function ToggleGroupItem({
|
|
|
367
374
|
size,
|
|
368
375
|
...props
|
|
369
376
|
}) {
|
|
370
|
-
const context =
|
|
377
|
+
const context = React48.useContext(ToggleGroupContext);
|
|
371
378
|
const resolvedVariant = variant ?? context.variant;
|
|
372
379
|
const resolvedSize = size ?? context.size;
|
|
373
380
|
return /* @__PURE__ */ jsx(
|
|
@@ -470,7 +477,7 @@ function Slider({
|
|
|
470
477
|
tone,
|
|
471
478
|
...props
|
|
472
479
|
}) {
|
|
473
|
-
const values =
|
|
480
|
+
const values = React48.useMemo(
|
|
474
481
|
() => Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min],
|
|
475
482
|
[value, defaultValue, min]
|
|
476
483
|
);
|
|
@@ -669,13 +676,192 @@ function SelectScrollDownButton({
|
|
|
669
676
|
}
|
|
670
677
|
);
|
|
671
678
|
}
|
|
679
|
+
function DropdownMenu({ ...props }) {
|
|
680
|
+
return /* @__PURE__ */ jsx(DropdownMenu$1.Root, { "data-slot": "dropdown-menu", ...props });
|
|
681
|
+
}
|
|
682
|
+
function DropdownMenuPortal({ ...props }) {
|
|
683
|
+
return /* @__PURE__ */ jsx(DropdownMenu$1.Portal, { "data-slot": "dropdown-menu-portal", ...props });
|
|
684
|
+
}
|
|
685
|
+
function DropdownMenuTrigger({
|
|
686
|
+
...props
|
|
687
|
+
}) {
|
|
688
|
+
return /* @__PURE__ */ jsx(DropdownMenu$1.Trigger, { "data-slot": "dropdown-menu-trigger", ...props });
|
|
689
|
+
}
|
|
690
|
+
function DropdownMenuContent({
|
|
691
|
+
className,
|
|
692
|
+
sideOffset = 6,
|
|
693
|
+
...props
|
|
694
|
+
}) {
|
|
695
|
+
return /* @__PURE__ */ jsx(DropdownMenu$1.Portal, { children: /* @__PURE__ */ jsx(
|
|
696
|
+
DropdownMenu$1.Content,
|
|
697
|
+
{
|
|
698
|
+
"data-slot": "dropdown-menu-content",
|
|
699
|
+
sideOffset,
|
|
700
|
+
className: cn("mz-panel mz-menu-content", className),
|
|
701
|
+
...props
|
|
702
|
+
}
|
|
703
|
+
) });
|
|
704
|
+
}
|
|
705
|
+
function DropdownMenuGroup({ ...props }) {
|
|
706
|
+
return /* @__PURE__ */ jsx(DropdownMenu$1.Group, { "data-slot": "dropdown-menu-group", ...props });
|
|
707
|
+
}
|
|
708
|
+
function DropdownMenuItem({
|
|
709
|
+
className,
|
|
710
|
+
inset,
|
|
711
|
+
variant = "default",
|
|
712
|
+
...props
|
|
713
|
+
}) {
|
|
714
|
+
return /* @__PURE__ */ jsx(
|
|
715
|
+
DropdownMenu$1.Item,
|
|
716
|
+
{
|
|
717
|
+
"data-slot": "dropdown-menu-item",
|
|
718
|
+
"data-inset": inset,
|
|
719
|
+
"data-variant": variant,
|
|
720
|
+
className: cn(
|
|
721
|
+
"mz-item",
|
|
722
|
+
inset ? "mz-item--inset" : "mz-item--plain",
|
|
723
|
+
variant === "destructive" && "mz-item--destructive",
|
|
724
|
+
className
|
|
725
|
+
),
|
|
726
|
+
...props
|
|
727
|
+
}
|
|
728
|
+
);
|
|
729
|
+
}
|
|
730
|
+
function DropdownMenuCheckboxItem({
|
|
731
|
+
className,
|
|
732
|
+
children,
|
|
733
|
+
checked,
|
|
734
|
+
...props
|
|
735
|
+
}) {
|
|
736
|
+
return /* @__PURE__ */ jsxs(
|
|
737
|
+
DropdownMenu$1.CheckboxItem,
|
|
738
|
+
{
|
|
739
|
+
"data-slot": "dropdown-menu-checkbox-item",
|
|
740
|
+
className: cn("mz-item", className),
|
|
741
|
+
checked,
|
|
742
|
+
...props,
|
|
743
|
+
children: [
|
|
744
|
+
/* @__PURE__ */ jsx("span", { className: "mz-item__indicator", children: /* @__PURE__ */ jsx(DropdownMenu$1.ItemIndicator, { children: /* @__PURE__ */ jsx(CheckIcon, {}) }) }),
|
|
745
|
+
children
|
|
746
|
+
]
|
|
747
|
+
}
|
|
748
|
+
);
|
|
749
|
+
}
|
|
750
|
+
function DropdownMenuRadioGroup({
|
|
751
|
+
...props
|
|
752
|
+
}) {
|
|
753
|
+
return /* @__PURE__ */ jsx(DropdownMenu$1.RadioGroup, { "data-slot": "dropdown-menu-radio-group", ...props });
|
|
754
|
+
}
|
|
755
|
+
function DropdownMenuRadioItem({
|
|
756
|
+
className,
|
|
757
|
+
children,
|
|
758
|
+
...props
|
|
759
|
+
}) {
|
|
760
|
+
return /* @__PURE__ */ jsxs(
|
|
761
|
+
DropdownMenu$1.RadioItem,
|
|
762
|
+
{
|
|
763
|
+
"data-slot": "dropdown-menu-radio-item",
|
|
764
|
+
className: cn("mz-item", className),
|
|
765
|
+
...props,
|
|
766
|
+
children: [
|
|
767
|
+
/* @__PURE__ */ jsx("span", { className: "mz-item__indicator", children: /* @__PURE__ */ jsx(DropdownMenu$1.ItemIndicator, { children: /* @__PURE__ */ jsx(DotIcon, {}) }) }),
|
|
768
|
+
children
|
|
769
|
+
]
|
|
770
|
+
}
|
|
771
|
+
);
|
|
772
|
+
}
|
|
773
|
+
function DropdownMenuLabel({
|
|
774
|
+
className,
|
|
775
|
+
inset,
|
|
776
|
+
...props
|
|
777
|
+
}) {
|
|
778
|
+
return /* @__PURE__ */ jsx(
|
|
779
|
+
DropdownMenu$1.Label,
|
|
780
|
+
{
|
|
781
|
+
"data-slot": "dropdown-menu-label",
|
|
782
|
+
"data-inset": inset,
|
|
783
|
+
className: cn("mz-menu-label", inset && "mz-menu-label--inset", className),
|
|
784
|
+
...props
|
|
785
|
+
}
|
|
786
|
+
);
|
|
787
|
+
}
|
|
788
|
+
function DropdownMenuSeparator({
|
|
789
|
+
className,
|
|
790
|
+
...props
|
|
791
|
+
}) {
|
|
792
|
+
return /* @__PURE__ */ jsx(
|
|
793
|
+
DropdownMenu$1.Separator,
|
|
794
|
+
{
|
|
795
|
+
"data-slot": "dropdown-menu-separator",
|
|
796
|
+
className: cn("mz-menu-separator", className),
|
|
797
|
+
...props
|
|
798
|
+
}
|
|
799
|
+
);
|
|
800
|
+
}
|
|
801
|
+
function DropdownMenuShortcut({ className, ...props }) {
|
|
802
|
+
return /* @__PURE__ */ jsx(
|
|
803
|
+
"span",
|
|
804
|
+
{
|
|
805
|
+
"data-slot": "dropdown-menu-shortcut",
|
|
806
|
+
className: cn("mz-menu-shortcut", className),
|
|
807
|
+
...props
|
|
808
|
+
}
|
|
809
|
+
);
|
|
810
|
+
}
|
|
811
|
+
function DropdownMenuSub({ ...props }) {
|
|
812
|
+
return /* @__PURE__ */ jsx(DropdownMenu$1.Sub, { "data-slot": "dropdown-menu-sub", ...props });
|
|
813
|
+
}
|
|
814
|
+
function DropdownMenuSubTrigger({
|
|
815
|
+
className,
|
|
816
|
+
inset,
|
|
817
|
+
children,
|
|
818
|
+
...props
|
|
819
|
+
}) {
|
|
820
|
+
return /* @__PURE__ */ jsxs(
|
|
821
|
+
DropdownMenu$1.SubTrigger,
|
|
822
|
+
{
|
|
823
|
+
"data-slot": "dropdown-menu-sub-trigger",
|
|
824
|
+
"data-inset": inset,
|
|
825
|
+
className: cn(
|
|
826
|
+
"mz-item mz-menu-sub-trigger",
|
|
827
|
+
inset ? "mz-item--inset" : "mz-item--plain",
|
|
828
|
+
className
|
|
829
|
+
),
|
|
830
|
+
...props,
|
|
831
|
+
children: [
|
|
832
|
+
children,
|
|
833
|
+
/* @__PURE__ */ jsx(ChevronRightIcon, { className: "mz-menu-sub-trigger__icon" })
|
|
834
|
+
]
|
|
835
|
+
}
|
|
836
|
+
);
|
|
837
|
+
}
|
|
838
|
+
function DropdownMenuSubContent({
|
|
839
|
+
className,
|
|
840
|
+
...props
|
|
841
|
+
}) {
|
|
842
|
+
return /* @__PURE__ */ jsx(
|
|
843
|
+
DropdownMenu$1.SubContent,
|
|
844
|
+
{
|
|
845
|
+
"data-slot": "dropdown-menu-sub-content",
|
|
846
|
+
className: cn("mz-panel mz-menu-content", className),
|
|
847
|
+
...props
|
|
848
|
+
}
|
|
849
|
+
);
|
|
850
|
+
}
|
|
672
851
|
function Tabs({ className, ...props }) {
|
|
673
852
|
return /* @__PURE__ */ jsx(Tabs$1.Root, { "data-slot": "tabs", className: cn("mz-tabs", className), ...props });
|
|
674
853
|
}
|
|
675
|
-
function TabsList({
|
|
854
|
+
function TabsList({ overflow = "wrap", overflowLabel, ...props }) {
|
|
855
|
+
if (overflow === "menu") {
|
|
856
|
+
return /* @__PURE__ */ jsx(TabsListWithMenu, { overflowLabel, ...props });
|
|
857
|
+
}
|
|
858
|
+
return /* @__PURE__ */ jsx(PlainTabsList, { overflow, ...props });
|
|
859
|
+
}
|
|
860
|
+
function PlainTabsList({
|
|
676
861
|
className,
|
|
677
862
|
variant = "default",
|
|
678
863
|
tone,
|
|
864
|
+
overflow = "wrap",
|
|
679
865
|
...props
|
|
680
866
|
}) {
|
|
681
867
|
return /* @__PURE__ */ jsx(
|
|
@@ -684,11 +870,146 @@ function TabsList({
|
|
|
684
870
|
"data-slot": "tabs-list",
|
|
685
871
|
"data-variant": variant,
|
|
686
872
|
"data-tone": tone,
|
|
687
|
-
|
|
873
|
+
"data-overflow": overflow,
|
|
874
|
+
className: cn(
|
|
875
|
+
"mz-tabs-list",
|
|
876
|
+
variant === "line" && "mz-tabs-list--line",
|
|
877
|
+
overflow === "scroll" && "mz-tabs-list--scroll",
|
|
878
|
+
className
|
|
879
|
+
),
|
|
688
880
|
...props
|
|
689
881
|
}
|
|
690
882
|
);
|
|
691
883
|
}
|
|
884
|
+
function TabsListWithMenu({
|
|
885
|
+
className,
|
|
886
|
+
variant = "default",
|
|
887
|
+
tone,
|
|
888
|
+
overflowLabel = "More",
|
|
889
|
+
children,
|
|
890
|
+
...props
|
|
891
|
+
}) {
|
|
892
|
+
const items = React48.useMemo(
|
|
893
|
+
() => React48.Children.toArray(children).filter(React48.isValidElement),
|
|
894
|
+
[children]
|
|
895
|
+
);
|
|
896
|
+
const containerRef = React48.useRef(null);
|
|
897
|
+
const triggerRefs = React48.useRef([]);
|
|
898
|
+
const mirrorRefs = React48.useRef([]);
|
|
899
|
+
const [containerWidth, setContainerWidth] = React48.useState(0);
|
|
900
|
+
const [widths, setWidths] = React48.useState([]);
|
|
901
|
+
React48.useEffect(() => {
|
|
902
|
+
const el = containerRef.current;
|
|
903
|
+
if (!el) return;
|
|
904
|
+
setContainerWidth(el.getBoundingClientRect().width);
|
|
905
|
+
const observer = new ResizeObserver((entries) => {
|
|
906
|
+
const entry = entries[0];
|
|
907
|
+
if (entry) setContainerWidth(entry.contentRect.width);
|
|
908
|
+
});
|
|
909
|
+
observer.observe(el);
|
|
910
|
+
return () => observer.disconnect();
|
|
911
|
+
}, []);
|
|
912
|
+
React48.useLayoutEffect(() => {
|
|
913
|
+
const measured = mirrorRefs.current.map((el) => el ? Math.ceil(el.getBoundingClientRect().width) : 0);
|
|
914
|
+
setWidths(
|
|
915
|
+
(prev) => prev.length === measured.length && prev.every((w, i) => w === measured[i]) ? prev : measured
|
|
916
|
+
);
|
|
917
|
+
}, [items]);
|
|
918
|
+
const visibleCount = React48.useMemo(() => {
|
|
919
|
+
if (!containerWidth || widths.length !== items.length) return items.length;
|
|
920
|
+
const total = widths.reduce((sum, w) => sum + w, 0);
|
|
921
|
+
if (total <= containerWidth) return items.length;
|
|
922
|
+
let used = 0;
|
|
923
|
+
let count = 0;
|
|
924
|
+
for (const width of widths) {
|
|
925
|
+
if (used + width + OVERFLOW_BUTTON_WIDTH > containerWidth) break;
|
|
926
|
+
used += width;
|
|
927
|
+
count++;
|
|
928
|
+
}
|
|
929
|
+
return count;
|
|
930
|
+
}, [containerWidth, widths, items.length]);
|
|
931
|
+
const hidden = items.slice(visibleCount);
|
|
932
|
+
const activeIsHidden = hidden.some(
|
|
933
|
+
(_, i) => triggerRefs.current[visibleCount + i]?.dataset.state === "active"
|
|
934
|
+
);
|
|
935
|
+
return /* @__PURE__ */ jsxs("div", { ref: containerRef, className: "mz-tabs-list-wrap", children: [
|
|
936
|
+
/* @__PURE__ */ jsx("div", { className: "mz-tabs-list__mirror", "aria-hidden": "true", children: items.map((item, i) => /* @__PURE__ */ jsx(
|
|
937
|
+
"span",
|
|
938
|
+
{
|
|
939
|
+
className: "mz-tabs-trigger",
|
|
940
|
+
ref: (el) => {
|
|
941
|
+
mirrorRefs.current[i] = el;
|
|
942
|
+
},
|
|
943
|
+
children: item.props.children
|
|
944
|
+
},
|
|
945
|
+
i
|
|
946
|
+
)) }),
|
|
947
|
+
/* @__PURE__ */ jsxs(
|
|
948
|
+
Tabs$1.List,
|
|
949
|
+
{
|
|
950
|
+
"data-slot": "tabs-list",
|
|
951
|
+
"data-variant": variant,
|
|
952
|
+
"data-tone": tone,
|
|
953
|
+
"data-overflow": "menu",
|
|
954
|
+
className: cn(
|
|
955
|
+
"mz-tabs-list mz-tabs-list--menu",
|
|
956
|
+
variant === "line" && "mz-tabs-list--line",
|
|
957
|
+
className
|
|
958
|
+
),
|
|
959
|
+
...props,
|
|
960
|
+
children: [
|
|
961
|
+
items.map(
|
|
962
|
+
(item, i) => React48.cloneElement(item, {
|
|
963
|
+
key: i,
|
|
964
|
+
ref: (el) => {
|
|
965
|
+
triggerRefs.current[i] = el;
|
|
966
|
+
},
|
|
967
|
+
style: {
|
|
968
|
+
...item.props.style ?? {},
|
|
969
|
+
...i >= visibleCount ? { display: "none" } : null
|
|
970
|
+
}
|
|
971
|
+
})
|
|
972
|
+
),
|
|
973
|
+
hidden.length > 0 ? /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
974
|
+
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
975
|
+
"button",
|
|
976
|
+
{
|
|
977
|
+
type: "button",
|
|
978
|
+
"data-slot": "tabs-overflow-trigger",
|
|
979
|
+
"data-active": activeIsHidden || void 0,
|
|
980
|
+
className: "mz-tabs-trigger mz-tabs-overflow mz-focusable",
|
|
981
|
+
"aria-label": `${overflowLabel} (${hidden.length})`,
|
|
982
|
+
children: [
|
|
983
|
+
/* @__PURE__ */ jsx(EllipsisIcon, { className: "mz-tabs-overflow__icon" }),
|
|
984
|
+
/* @__PURE__ */ jsxs("span", { className: "mz-tabs-overflow__label", children: [
|
|
985
|
+
overflowLabel,
|
|
986
|
+
" (",
|
|
987
|
+
hidden.length,
|
|
988
|
+
")"
|
|
989
|
+
] }),
|
|
990
|
+
/* @__PURE__ */ jsx(ChevronDownIcon, { className: "mz-tabs-overflow__caret" })
|
|
991
|
+
]
|
|
992
|
+
}
|
|
993
|
+
) }),
|
|
994
|
+
/* @__PURE__ */ jsx(DropdownMenuContent, { align: "end", children: hidden.map((item, i) => /* @__PURE__ */ jsx(
|
|
995
|
+
DropdownMenuItem,
|
|
996
|
+
{
|
|
997
|
+
onSelect: () => {
|
|
998
|
+
triggerRefs.current[visibleCount + i]?.dispatchEvent(
|
|
999
|
+
new MouseEvent("mousedown", { bubbles: true, cancelable: true, button: 0 })
|
|
1000
|
+
);
|
|
1001
|
+
},
|
|
1002
|
+
children: item.props.children
|
|
1003
|
+
},
|
|
1004
|
+
i
|
|
1005
|
+
)) })
|
|
1006
|
+
] }) : null
|
|
1007
|
+
]
|
|
1008
|
+
}
|
|
1009
|
+
)
|
|
1010
|
+
] });
|
|
1011
|
+
}
|
|
1012
|
+
var OVERFLOW_BUTTON_WIDTH = 116;
|
|
692
1013
|
function TabsTrigger({ className, ...props }) {
|
|
693
1014
|
return /* @__PURE__ */ jsx(
|
|
694
1015
|
Tabs$1.Trigger,
|
|
@@ -1079,45 +1400,393 @@ function PopoverDescription({ className, ...props }) {
|
|
|
1079
1400
|
}
|
|
1080
1401
|
);
|
|
1081
1402
|
}
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
return /* @__PURE__ */ jsx(DropdownMenu$1.Portal, { "data-slot": "dropdown-menu-portal", ...props });
|
|
1087
|
-
}
|
|
1088
|
-
function DropdownMenuTrigger({
|
|
1403
|
+
var TooltipProviderPresence = React48.createContext(false);
|
|
1404
|
+
function TooltipProvider({
|
|
1405
|
+
delayDuration = 200,
|
|
1406
|
+
children,
|
|
1089
1407
|
...props
|
|
1090
1408
|
}) {
|
|
1091
|
-
return /* @__PURE__ */ jsx(
|
|
1409
|
+
return /* @__PURE__ */ jsx(TooltipProviderPresence.Provider, { value: true, children: /* @__PURE__ */ jsx(
|
|
1410
|
+
Tooltip$1.Provider,
|
|
1411
|
+
{
|
|
1412
|
+
"data-slot": "tooltip-provider",
|
|
1413
|
+
delayDuration,
|
|
1414
|
+
...props,
|
|
1415
|
+
children
|
|
1416
|
+
}
|
|
1417
|
+
) });
|
|
1092
1418
|
}
|
|
1093
|
-
function
|
|
1419
|
+
function Tooltip({ ...props }) {
|
|
1420
|
+
const hasProvider = React48.useContext(TooltipProviderPresence);
|
|
1421
|
+
const root = /* @__PURE__ */ jsx(Tooltip$1.Root, { "data-slot": "tooltip", ...props });
|
|
1422
|
+
return hasProvider ? root : /* @__PURE__ */ jsx(TooltipProvider, { children: root });
|
|
1423
|
+
}
|
|
1424
|
+
function TooltipTrigger({ ...props }) {
|
|
1425
|
+
return /* @__PURE__ */ jsx(Tooltip$1.Trigger, { "data-slot": "tooltip-trigger", ...props });
|
|
1426
|
+
}
|
|
1427
|
+
function TooltipContent({
|
|
1094
1428
|
className,
|
|
1095
1429
|
sideOffset = 6,
|
|
1430
|
+
children,
|
|
1096
1431
|
...props
|
|
1097
1432
|
}) {
|
|
1098
|
-
return /* @__PURE__ */ jsx(
|
|
1099
|
-
|
|
1433
|
+
return /* @__PURE__ */ jsx(Tooltip$1.Portal, { children: /* @__PURE__ */ jsxs(
|
|
1434
|
+
Tooltip$1.Content,
|
|
1100
1435
|
{
|
|
1101
|
-
"data-slot": "
|
|
1436
|
+
"data-slot": "tooltip-content",
|
|
1102
1437
|
sideOffset,
|
|
1103
|
-
className: cn("mz-
|
|
1104
|
-
...props
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
}
|
|
1108
|
-
|
|
1109
|
-
|
|
1438
|
+
className: cn("mz-tooltip-content", className),
|
|
1439
|
+
...props,
|
|
1440
|
+
children: [
|
|
1441
|
+
children,
|
|
1442
|
+
/* @__PURE__ */ jsx(Tooltip$1.Arrow, { className: "mz-tooltip-arrow", width: 10, height: 5 })
|
|
1443
|
+
]
|
|
1444
|
+
}
|
|
1445
|
+
) });
|
|
1110
1446
|
}
|
|
1111
|
-
function
|
|
1447
|
+
function AlertDialog({ ...props }) {
|
|
1448
|
+
return /* @__PURE__ */ jsx(AlertDialog$1.Root, { "data-slot": "alert-dialog", ...props });
|
|
1449
|
+
}
|
|
1450
|
+
function AlertDialogTrigger({
|
|
1451
|
+
...props
|
|
1452
|
+
}) {
|
|
1453
|
+
return /* @__PURE__ */ jsx(AlertDialog$1.Trigger, { "data-slot": "alert-dialog-trigger", ...props });
|
|
1454
|
+
}
|
|
1455
|
+
function AlertDialogPortal({ ...props }) {
|
|
1456
|
+
return /* @__PURE__ */ jsx(AlertDialog$1.Portal, { "data-slot": "alert-dialog-portal", ...props });
|
|
1457
|
+
}
|
|
1458
|
+
function AlertDialogOverlay({
|
|
1459
|
+
className,
|
|
1460
|
+
...props
|
|
1461
|
+
}) {
|
|
1462
|
+
return /* @__PURE__ */ jsx(
|
|
1463
|
+
AlertDialog$1.Overlay,
|
|
1464
|
+
{
|
|
1465
|
+
"data-slot": "alert-dialog-overlay",
|
|
1466
|
+
className: cn("mz-dialog-overlay", className),
|
|
1467
|
+
...props
|
|
1468
|
+
}
|
|
1469
|
+
);
|
|
1470
|
+
}
|
|
1471
|
+
function AlertDialogContent({
|
|
1472
|
+
className,
|
|
1473
|
+
...props
|
|
1474
|
+
}) {
|
|
1475
|
+
return /* @__PURE__ */ jsxs(AlertDialogPortal, { children: [
|
|
1476
|
+
/* @__PURE__ */ jsx(AlertDialogOverlay, {}),
|
|
1477
|
+
/* @__PURE__ */ jsx(
|
|
1478
|
+
AlertDialog$1.Content,
|
|
1479
|
+
{
|
|
1480
|
+
"data-slot": "alert-dialog-content",
|
|
1481
|
+
className: cn("mz-panel mz-dialog-content mz-alert-dialog-content", className),
|
|
1482
|
+
...props
|
|
1483
|
+
}
|
|
1484
|
+
)
|
|
1485
|
+
] });
|
|
1486
|
+
}
|
|
1487
|
+
function AlertDialogHeader({ className, ...props }) {
|
|
1488
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "alert-dialog-header", className: cn("mz-dialog-header", className), ...props });
|
|
1489
|
+
}
|
|
1490
|
+
function AlertDialogFooter({ className, ...props }) {
|
|
1491
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "alert-dialog-footer", className: cn("mz-dialog-footer", className), ...props });
|
|
1492
|
+
}
|
|
1493
|
+
function AlertDialogTitle({
|
|
1494
|
+
className,
|
|
1495
|
+
...props
|
|
1496
|
+
}) {
|
|
1497
|
+
return /* @__PURE__ */ jsx(
|
|
1498
|
+
AlertDialog$1.Title,
|
|
1499
|
+
{
|
|
1500
|
+
"data-slot": "alert-dialog-title",
|
|
1501
|
+
className: cn("mz-dialog-title", className),
|
|
1502
|
+
...props
|
|
1503
|
+
}
|
|
1504
|
+
);
|
|
1505
|
+
}
|
|
1506
|
+
function AlertDialogDescription({
|
|
1507
|
+
className,
|
|
1508
|
+
...props
|
|
1509
|
+
}) {
|
|
1510
|
+
return /* @__PURE__ */ jsx(
|
|
1511
|
+
AlertDialog$1.Description,
|
|
1512
|
+
{
|
|
1513
|
+
"data-slot": "alert-dialog-description",
|
|
1514
|
+
className: cn("mz-dialog-description", className),
|
|
1515
|
+
...props
|
|
1516
|
+
}
|
|
1517
|
+
);
|
|
1518
|
+
}
|
|
1519
|
+
function AlertDialogAction({
|
|
1520
|
+
className,
|
|
1521
|
+
variant = "primary",
|
|
1522
|
+
size = "md",
|
|
1523
|
+
tone,
|
|
1524
|
+
...props
|
|
1525
|
+
}) {
|
|
1526
|
+
return /* @__PURE__ */ jsx(
|
|
1527
|
+
AlertDialog$1.Action,
|
|
1528
|
+
{
|
|
1529
|
+
"data-slot": "alert-dialog-action",
|
|
1530
|
+
"data-variant": variant,
|
|
1531
|
+
"data-size": size,
|
|
1532
|
+
"data-tone": tone,
|
|
1533
|
+
className: cn(buttonVariants({ variant, size }), className),
|
|
1534
|
+
...props
|
|
1535
|
+
}
|
|
1536
|
+
);
|
|
1537
|
+
}
|
|
1538
|
+
function AlertDialogCancel({
|
|
1539
|
+
className,
|
|
1540
|
+
variant = "outline",
|
|
1541
|
+
size = "md",
|
|
1542
|
+
tone,
|
|
1543
|
+
...props
|
|
1544
|
+
}) {
|
|
1545
|
+
return /* @__PURE__ */ jsx(
|
|
1546
|
+
AlertDialog$1.Cancel,
|
|
1547
|
+
{
|
|
1548
|
+
"data-slot": "alert-dialog-cancel",
|
|
1549
|
+
"data-variant": variant,
|
|
1550
|
+
"data-size": size,
|
|
1551
|
+
"data-tone": tone,
|
|
1552
|
+
className: cn(buttonVariants({ variant, size }), className),
|
|
1553
|
+
...props
|
|
1554
|
+
}
|
|
1555
|
+
);
|
|
1556
|
+
}
|
|
1557
|
+
function Breadcrumb({ className, ...props }) {
|
|
1558
|
+
return /* @__PURE__ */ jsx(
|
|
1559
|
+
"nav",
|
|
1560
|
+
{
|
|
1561
|
+
"data-slot": "breadcrumb",
|
|
1562
|
+
"aria-label": "breadcrumb",
|
|
1563
|
+
className: cn("mz-breadcrumb", className),
|
|
1564
|
+
...props
|
|
1565
|
+
}
|
|
1566
|
+
);
|
|
1567
|
+
}
|
|
1568
|
+
function BreadcrumbList({ className, ...props }) {
|
|
1569
|
+
return /* @__PURE__ */ jsx("ol", { "data-slot": "breadcrumb-list", className: cn("mz-breadcrumb__list", className), ...props });
|
|
1570
|
+
}
|
|
1571
|
+
function BreadcrumbItem({ className, ...props }) {
|
|
1572
|
+
return /* @__PURE__ */ jsx("li", { "data-slot": "breadcrumb-item", className: cn("mz-breadcrumb__item", className), ...props });
|
|
1573
|
+
}
|
|
1574
|
+
function BreadcrumbLink({
|
|
1575
|
+
className,
|
|
1576
|
+
asChild = false,
|
|
1577
|
+
...props
|
|
1578
|
+
}) {
|
|
1579
|
+
const Comp = asChild ? Slot.Root : "a";
|
|
1580
|
+
return /* @__PURE__ */ jsx(
|
|
1581
|
+
Comp,
|
|
1582
|
+
{
|
|
1583
|
+
"data-slot": "breadcrumb-link",
|
|
1584
|
+
className: cn("mz-breadcrumb__link mz-focusable", className),
|
|
1585
|
+
...props
|
|
1586
|
+
}
|
|
1587
|
+
);
|
|
1588
|
+
}
|
|
1589
|
+
function BreadcrumbPage({ className, ...props }) {
|
|
1590
|
+
return /* @__PURE__ */ jsx(
|
|
1591
|
+
"span",
|
|
1592
|
+
{
|
|
1593
|
+
"data-slot": "breadcrumb-page",
|
|
1594
|
+
role: "link",
|
|
1595
|
+
"aria-disabled": "true",
|
|
1596
|
+
"aria-current": "page",
|
|
1597
|
+
className: cn("mz-breadcrumb__page", className),
|
|
1598
|
+
...props
|
|
1599
|
+
}
|
|
1600
|
+
);
|
|
1601
|
+
}
|
|
1602
|
+
function BreadcrumbSeparator({ children, className, ...props }) {
|
|
1603
|
+
return /* @__PURE__ */ jsx(
|
|
1604
|
+
"li",
|
|
1605
|
+
{
|
|
1606
|
+
"data-slot": "breadcrumb-separator",
|
|
1607
|
+
role: "presentation",
|
|
1608
|
+
"aria-hidden": "true",
|
|
1609
|
+
className: cn("mz-breadcrumb__separator", className),
|
|
1610
|
+
...props,
|
|
1611
|
+
children: children ?? /* @__PURE__ */ jsx(ChevronRightIcon, {})
|
|
1612
|
+
}
|
|
1613
|
+
);
|
|
1614
|
+
}
|
|
1615
|
+
function BreadcrumbEllipsis({
|
|
1616
|
+
className,
|
|
1617
|
+
label = "More",
|
|
1618
|
+
...props
|
|
1619
|
+
}) {
|
|
1620
|
+
return /* @__PURE__ */ jsxs(
|
|
1621
|
+
"span",
|
|
1622
|
+
{
|
|
1623
|
+
"data-slot": "breadcrumb-ellipsis",
|
|
1624
|
+
role: "presentation",
|
|
1625
|
+
className: cn("mz-breadcrumb__ellipsis", className),
|
|
1626
|
+
...props,
|
|
1627
|
+
children: [
|
|
1628
|
+
/* @__PURE__ */ jsx(EllipsisIcon, {}),
|
|
1629
|
+
/* @__PURE__ */ jsx("span", { className: "mz-sr-only", children: label })
|
|
1630
|
+
]
|
|
1631
|
+
}
|
|
1632
|
+
);
|
|
1633
|
+
}
|
|
1634
|
+
function Table({
|
|
1635
|
+
className,
|
|
1636
|
+
containerClassName,
|
|
1637
|
+
containerRef,
|
|
1638
|
+
...props
|
|
1639
|
+
}) {
|
|
1640
|
+
return /* @__PURE__ */ jsx(
|
|
1641
|
+
"div",
|
|
1642
|
+
{
|
|
1643
|
+
ref: containerRef,
|
|
1644
|
+
"data-slot": "table-container",
|
|
1645
|
+
className: cn("mz-table-wrap", containerClassName),
|
|
1646
|
+
children: /* @__PURE__ */ jsx("table", { "data-slot": "table", className: cn("mz-table", className), ...props })
|
|
1647
|
+
}
|
|
1648
|
+
);
|
|
1649
|
+
}
|
|
1650
|
+
function TableHeader({ className, ...props }) {
|
|
1651
|
+
return /* @__PURE__ */ jsx("thead", { "data-slot": "table-header", className: cn("mz-table__head", className), ...props });
|
|
1652
|
+
}
|
|
1653
|
+
function TableBody({ className, ...props }) {
|
|
1654
|
+
return /* @__PURE__ */ jsx("tbody", { "data-slot": "table-body", className: cn("mz-table__body", className), ...props });
|
|
1655
|
+
}
|
|
1656
|
+
function TableFooter({ className, ...props }) {
|
|
1657
|
+
return /* @__PURE__ */ jsx("tfoot", { "data-slot": "table-footer", className: cn("mz-table__foot", className), ...props });
|
|
1658
|
+
}
|
|
1659
|
+
function TableRow({ className, ...props }) {
|
|
1660
|
+
return /* @__PURE__ */ jsx("tr", { "data-slot": "table-row", className: cn("mz-table__row", className), ...props });
|
|
1661
|
+
}
|
|
1662
|
+
function TableHead({ className, ...props }) {
|
|
1663
|
+
return /* @__PURE__ */ jsx("th", { "data-slot": "table-head", className: cn("mz-table__th", className), ...props });
|
|
1664
|
+
}
|
|
1665
|
+
function TableCell({ className, ...props }) {
|
|
1666
|
+
return /* @__PURE__ */ jsx("td", { "data-slot": "table-cell", className: cn("mz-table__td", className), ...props });
|
|
1667
|
+
}
|
|
1668
|
+
function TableCaption({ className, ...props }) {
|
|
1669
|
+
return /* @__PURE__ */ jsx("caption", { "data-slot": "table-caption", className: cn("mz-table__caption", className), ...props });
|
|
1670
|
+
}
|
|
1671
|
+
function ScrollArea({
|
|
1672
|
+
className,
|
|
1673
|
+
children,
|
|
1674
|
+
viewportClassName,
|
|
1675
|
+
viewportRef,
|
|
1676
|
+
...props
|
|
1677
|
+
}) {
|
|
1678
|
+
return /* @__PURE__ */ jsxs(
|
|
1679
|
+
ScrollArea$1.Root,
|
|
1680
|
+
{
|
|
1681
|
+
"data-slot": "scroll-area",
|
|
1682
|
+
className: cn("mz-scroll-area", className),
|
|
1683
|
+
...props,
|
|
1684
|
+
children: [
|
|
1685
|
+
/* @__PURE__ */ jsx(
|
|
1686
|
+
ScrollArea$1.Viewport,
|
|
1687
|
+
{
|
|
1688
|
+
"data-slot": "scroll-area-viewport",
|
|
1689
|
+
ref: viewportRef,
|
|
1690
|
+
className: cn("mz-scroll-area__viewport mz-focusable", viewportClassName),
|
|
1691
|
+
children
|
|
1692
|
+
}
|
|
1693
|
+
),
|
|
1694
|
+
/* @__PURE__ */ jsx(ScrollBar, {}),
|
|
1695
|
+
/* @__PURE__ */ jsx(ScrollArea$1.Corner, { className: "mz-scroll-area__corner" })
|
|
1696
|
+
]
|
|
1697
|
+
}
|
|
1698
|
+
);
|
|
1699
|
+
}
|
|
1700
|
+
function ScrollBar({
|
|
1701
|
+
className,
|
|
1702
|
+
orientation = "vertical",
|
|
1703
|
+
...props
|
|
1704
|
+
}) {
|
|
1705
|
+
return /* @__PURE__ */ jsx(
|
|
1706
|
+
ScrollArea$1.ScrollAreaScrollbar,
|
|
1707
|
+
{
|
|
1708
|
+
"data-slot": "scroll-area-scrollbar",
|
|
1709
|
+
orientation,
|
|
1710
|
+
className: cn(
|
|
1711
|
+
"mz-scrollbar",
|
|
1712
|
+
orientation === "horizontal" && "mz-scrollbar--horizontal",
|
|
1713
|
+
className
|
|
1714
|
+
),
|
|
1715
|
+
...props,
|
|
1716
|
+
children: /* @__PURE__ */ jsx(
|
|
1717
|
+
ScrollArea$1.ScrollAreaThumb,
|
|
1718
|
+
{
|
|
1719
|
+
"data-slot": "scroll-area-thumb",
|
|
1720
|
+
className: "mz-scrollbar__thumb"
|
|
1721
|
+
}
|
|
1722
|
+
)
|
|
1723
|
+
}
|
|
1724
|
+
);
|
|
1725
|
+
}
|
|
1726
|
+
function Menubar({ className, ...props }) {
|
|
1727
|
+
return /* @__PURE__ */ jsx(
|
|
1728
|
+
Menubar$1.Root,
|
|
1729
|
+
{
|
|
1730
|
+
"data-slot": "menubar",
|
|
1731
|
+
className: cn("mz-menubar", className),
|
|
1732
|
+
...props
|
|
1733
|
+
}
|
|
1734
|
+
);
|
|
1735
|
+
}
|
|
1736
|
+
function MenubarMenu({ ...props }) {
|
|
1737
|
+
return /* @__PURE__ */ jsx(Menubar$1.Menu, { "data-slot": "menubar-menu", ...props });
|
|
1738
|
+
}
|
|
1739
|
+
function MenubarGroup({ ...props }) {
|
|
1740
|
+
return /* @__PURE__ */ jsx(Menubar$1.Group, { "data-slot": "menubar-group", ...props });
|
|
1741
|
+
}
|
|
1742
|
+
function MenubarPortal({ ...props }) {
|
|
1743
|
+
return /* @__PURE__ */ jsx(Menubar$1.Portal, { "data-slot": "menubar-portal", ...props });
|
|
1744
|
+
}
|
|
1745
|
+
function MenubarRadioGroup({ ...props }) {
|
|
1746
|
+
return /* @__PURE__ */ jsx(Menubar$1.RadioGroup, { "data-slot": "menubar-radio-group", ...props });
|
|
1747
|
+
}
|
|
1748
|
+
function MenubarTrigger({
|
|
1749
|
+
className,
|
|
1750
|
+
...props
|
|
1751
|
+
}) {
|
|
1752
|
+
return /* @__PURE__ */ jsx(
|
|
1753
|
+
Menubar$1.Trigger,
|
|
1754
|
+
{
|
|
1755
|
+
"data-slot": "menubar-trigger",
|
|
1756
|
+
className: cn("mz-menubar__trigger mz-focusable", className),
|
|
1757
|
+
...props
|
|
1758
|
+
}
|
|
1759
|
+
);
|
|
1760
|
+
}
|
|
1761
|
+
function MenubarContent({
|
|
1762
|
+
className,
|
|
1763
|
+
align = "start",
|
|
1764
|
+
alignOffset = -4,
|
|
1765
|
+
sideOffset = 8,
|
|
1766
|
+
...props
|
|
1767
|
+
}) {
|
|
1768
|
+
return /* @__PURE__ */ jsx(MenubarPortal, { children: /* @__PURE__ */ jsx(
|
|
1769
|
+
Menubar$1.Content,
|
|
1770
|
+
{
|
|
1771
|
+
"data-slot": "menubar-content",
|
|
1772
|
+
align,
|
|
1773
|
+
alignOffset,
|
|
1774
|
+
sideOffset,
|
|
1775
|
+
className: cn("mz-panel mz-menu-content", className),
|
|
1776
|
+
...props
|
|
1777
|
+
}
|
|
1778
|
+
) });
|
|
1779
|
+
}
|
|
1780
|
+
function MenubarItem({
|
|
1112
1781
|
className,
|
|
1113
1782
|
inset,
|
|
1114
1783
|
variant = "default",
|
|
1115
1784
|
...props
|
|
1116
1785
|
}) {
|
|
1117
1786
|
return /* @__PURE__ */ jsx(
|
|
1118
|
-
|
|
1787
|
+
Menubar$1.Item,
|
|
1119
1788
|
{
|
|
1120
|
-
"data-slot": "
|
|
1789
|
+
"data-slot": "menubar-item",
|
|
1121
1790
|
"data-inset": inset,
|
|
1122
1791
|
"data-variant": variant,
|
|
1123
1792
|
className: cn(
|
|
@@ -1130,100 +1799,88 @@ function DropdownMenuItem({
|
|
|
1130
1799
|
}
|
|
1131
1800
|
);
|
|
1132
1801
|
}
|
|
1133
|
-
function
|
|
1802
|
+
function MenubarCheckboxItem({
|
|
1134
1803
|
className,
|
|
1135
1804
|
children,
|
|
1136
1805
|
checked,
|
|
1137
1806
|
...props
|
|
1138
1807
|
}) {
|
|
1139
1808
|
return /* @__PURE__ */ jsxs(
|
|
1140
|
-
|
|
1809
|
+
Menubar$1.CheckboxItem,
|
|
1141
1810
|
{
|
|
1142
|
-
"data-slot": "
|
|
1811
|
+
"data-slot": "menubar-checkbox-item",
|
|
1143
1812
|
className: cn("mz-item", className),
|
|
1144
1813
|
checked,
|
|
1145
1814
|
...props,
|
|
1146
1815
|
children: [
|
|
1147
|
-
/* @__PURE__ */ jsx("span", { className: "mz-item__indicator", children: /* @__PURE__ */ jsx(
|
|
1816
|
+
/* @__PURE__ */ jsx("span", { className: "mz-item__indicator", children: /* @__PURE__ */ jsx(Menubar$1.ItemIndicator, { children: /* @__PURE__ */ jsx(CheckIcon, {}) }) }),
|
|
1148
1817
|
children
|
|
1149
1818
|
]
|
|
1150
1819
|
}
|
|
1151
1820
|
);
|
|
1152
1821
|
}
|
|
1153
|
-
function
|
|
1154
|
-
...props
|
|
1155
|
-
}) {
|
|
1156
|
-
return /* @__PURE__ */ jsx(DropdownMenu$1.RadioGroup, { "data-slot": "dropdown-menu-radio-group", ...props });
|
|
1157
|
-
}
|
|
1158
|
-
function DropdownMenuRadioItem({
|
|
1822
|
+
function MenubarRadioItem({
|
|
1159
1823
|
className,
|
|
1160
1824
|
children,
|
|
1161
1825
|
...props
|
|
1162
1826
|
}) {
|
|
1163
1827
|
return /* @__PURE__ */ jsxs(
|
|
1164
|
-
|
|
1828
|
+
Menubar$1.RadioItem,
|
|
1165
1829
|
{
|
|
1166
|
-
"data-slot": "
|
|
1830
|
+
"data-slot": "menubar-radio-item",
|
|
1167
1831
|
className: cn("mz-item", className),
|
|
1168
1832
|
...props,
|
|
1169
1833
|
children: [
|
|
1170
|
-
/* @__PURE__ */ jsx("span", { className: "mz-item__indicator", children: /* @__PURE__ */ jsx(
|
|
1834
|
+
/* @__PURE__ */ jsx("span", { className: "mz-item__indicator", children: /* @__PURE__ */ jsx(Menubar$1.ItemIndicator, { children: /* @__PURE__ */ jsx(DotIcon, {}) }) }),
|
|
1171
1835
|
children
|
|
1172
1836
|
]
|
|
1173
1837
|
}
|
|
1174
1838
|
);
|
|
1175
1839
|
}
|
|
1176
|
-
function
|
|
1840
|
+
function MenubarLabel({
|
|
1177
1841
|
className,
|
|
1178
1842
|
inset,
|
|
1179
1843
|
...props
|
|
1180
1844
|
}) {
|
|
1181
1845
|
return /* @__PURE__ */ jsx(
|
|
1182
|
-
|
|
1846
|
+
Menubar$1.Label,
|
|
1183
1847
|
{
|
|
1184
|
-
"data-slot": "
|
|
1848
|
+
"data-slot": "menubar-label",
|
|
1185
1849
|
"data-inset": inset,
|
|
1186
1850
|
className: cn("mz-menu-label", inset && "mz-menu-label--inset", className),
|
|
1187
1851
|
...props
|
|
1188
1852
|
}
|
|
1189
1853
|
);
|
|
1190
1854
|
}
|
|
1191
|
-
function
|
|
1855
|
+
function MenubarSeparator({
|
|
1192
1856
|
className,
|
|
1193
1857
|
...props
|
|
1194
1858
|
}) {
|
|
1195
1859
|
return /* @__PURE__ */ jsx(
|
|
1196
|
-
|
|
1860
|
+
Menubar$1.Separator,
|
|
1197
1861
|
{
|
|
1198
|
-
"data-slot": "
|
|
1862
|
+
"data-slot": "menubar-separator",
|
|
1199
1863
|
className: cn("mz-menu-separator", className),
|
|
1200
1864
|
...props
|
|
1201
1865
|
}
|
|
1202
1866
|
);
|
|
1203
1867
|
}
|
|
1204
|
-
function
|
|
1205
|
-
return /* @__PURE__ */ jsx(
|
|
1206
|
-
"span",
|
|
1207
|
-
{
|
|
1208
|
-
"data-slot": "dropdown-menu-shortcut",
|
|
1209
|
-
className: cn("mz-menu-shortcut", className),
|
|
1210
|
-
...props
|
|
1211
|
-
}
|
|
1212
|
-
);
|
|
1868
|
+
function MenubarShortcut({ className, ...props }) {
|
|
1869
|
+
return /* @__PURE__ */ jsx("span", { "data-slot": "menubar-shortcut", className: cn("mz-menu-shortcut", className), ...props });
|
|
1213
1870
|
}
|
|
1214
|
-
function
|
|
1215
|
-
return /* @__PURE__ */ jsx(
|
|
1871
|
+
function MenubarSub({ ...props }) {
|
|
1872
|
+
return /* @__PURE__ */ jsx(Menubar$1.Sub, { "data-slot": "menubar-sub", ...props });
|
|
1216
1873
|
}
|
|
1217
|
-
function
|
|
1874
|
+
function MenubarSubTrigger({
|
|
1218
1875
|
className,
|
|
1219
1876
|
inset,
|
|
1220
1877
|
children,
|
|
1221
1878
|
...props
|
|
1222
1879
|
}) {
|
|
1223
1880
|
return /* @__PURE__ */ jsxs(
|
|
1224
|
-
|
|
1881
|
+
Menubar$1.SubTrigger,
|
|
1225
1882
|
{
|
|
1226
|
-
"data-slot": "
|
|
1883
|
+
"data-slot": "menubar-sub-trigger",
|
|
1227
1884
|
"data-inset": inset,
|
|
1228
1885
|
className: cn(
|
|
1229
1886
|
"mz-item mz-menu-sub-trigger",
|
|
@@ -1238,63 +1895,820 @@ function DropdownMenuSubTrigger({
|
|
|
1238
1895
|
}
|
|
1239
1896
|
);
|
|
1240
1897
|
}
|
|
1241
|
-
function
|
|
1898
|
+
function MenubarSubContent({
|
|
1242
1899
|
className,
|
|
1243
1900
|
...props
|
|
1244
1901
|
}) {
|
|
1245
1902
|
return /* @__PURE__ */ jsx(
|
|
1246
|
-
|
|
1903
|
+
Menubar$1.SubContent,
|
|
1247
1904
|
{
|
|
1248
|
-
"data-slot": "
|
|
1905
|
+
"data-slot": "menubar-sub-content",
|
|
1249
1906
|
className: cn("mz-panel mz-menu-content", className),
|
|
1250
1907
|
...props
|
|
1251
1908
|
}
|
|
1252
1909
|
);
|
|
1253
1910
|
}
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
delayDuration = 200,
|
|
1911
|
+
function NavigationMenu({
|
|
1912
|
+
className,
|
|
1257
1913
|
children,
|
|
1914
|
+
viewport = true,
|
|
1258
1915
|
...props
|
|
1259
1916
|
}) {
|
|
1260
|
-
return /* @__PURE__ */
|
|
1261
|
-
|
|
1917
|
+
return /* @__PURE__ */ jsxs(
|
|
1918
|
+
NavigationMenu$1.Root,
|
|
1262
1919
|
{
|
|
1263
|
-
"data-slot": "
|
|
1264
|
-
|
|
1920
|
+
"data-slot": "navigation-menu",
|
|
1921
|
+
"data-viewport": viewport,
|
|
1922
|
+
className: cn("mz-navmenu", className),
|
|
1265
1923
|
...props,
|
|
1266
|
-
children
|
|
1924
|
+
children: [
|
|
1925
|
+
children,
|
|
1926
|
+
viewport ? /* @__PURE__ */ jsx(NavigationMenuViewport, {}) : null
|
|
1927
|
+
]
|
|
1267
1928
|
}
|
|
1268
|
-
)
|
|
1929
|
+
);
|
|
1269
1930
|
}
|
|
1270
|
-
function
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1931
|
+
function NavigationMenuList({
|
|
1932
|
+
className,
|
|
1933
|
+
...props
|
|
1934
|
+
}) {
|
|
1935
|
+
return /* @__PURE__ */ jsx(
|
|
1936
|
+
NavigationMenu$1.List,
|
|
1937
|
+
{
|
|
1938
|
+
"data-slot": "navigation-menu-list",
|
|
1939
|
+
className: cn("mz-navmenu__list", className),
|
|
1940
|
+
...props
|
|
1941
|
+
}
|
|
1942
|
+
);
|
|
1274
1943
|
}
|
|
1275
|
-
function
|
|
1276
|
-
|
|
1944
|
+
function NavigationMenuItem({
|
|
1945
|
+
className,
|
|
1946
|
+
...props
|
|
1947
|
+
}) {
|
|
1948
|
+
return /* @__PURE__ */ jsx(
|
|
1949
|
+
NavigationMenu$1.Item,
|
|
1950
|
+
{
|
|
1951
|
+
"data-slot": "navigation-menu-item",
|
|
1952
|
+
className: cn("mz-navmenu__item", className),
|
|
1953
|
+
...props
|
|
1954
|
+
}
|
|
1955
|
+
);
|
|
1277
1956
|
}
|
|
1278
|
-
|
|
1957
|
+
var navigationMenuTriggerStyle = cva("mz-navmenu__trigger mz-focusable");
|
|
1958
|
+
function NavigationMenuTrigger({
|
|
1279
1959
|
className,
|
|
1280
|
-
sideOffset = 6,
|
|
1281
1960
|
children,
|
|
1282
1961
|
...props
|
|
1283
1962
|
}) {
|
|
1284
|
-
return /* @__PURE__ */
|
|
1285
|
-
|
|
1963
|
+
return /* @__PURE__ */ jsxs(
|
|
1964
|
+
NavigationMenu$1.Trigger,
|
|
1286
1965
|
{
|
|
1287
|
-
"data-slot": "
|
|
1288
|
-
|
|
1289
|
-
className: cn("mz-tooltip-content", className),
|
|
1966
|
+
"data-slot": "navigation-menu-trigger",
|
|
1967
|
+
className: cn(navigationMenuTriggerStyle(), className),
|
|
1290
1968
|
...props,
|
|
1291
1969
|
children: [
|
|
1292
1970
|
children,
|
|
1293
|
-
/* @__PURE__ */ jsx(
|
|
1971
|
+
/* @__PURE__ */ jsx(ChevronDownIcon, { className: "mz-navmenu__trigger-icon", "aria-hidden": "true" })
|
|
1972
|
+
]
|
|
1973
|
+
}
|
|
1974
|
+
);
|
|
1975
|
+
}
|
|
1976
|
+
function NavigationMenuContent({
|
|
1977
|
+
className,
|
|
1978
|
+
...props
|
|
1979
|
+
}) {
|
|
1980
|
+
return /* @__PURE__ */ jsx(
|
|
1981
|
+
NavigationMenu$1.Content,
|
|
1982
|
+
{
|
|
1983
|
+
"data-slot": "navigation-menu-content",
|
|
1984
|
+
className: cn("mz-navmenu__content", className),
|
|
1985
|
+
...props
|
|
1986
|
+
}
|
|
1987
|
+
);
|
|
1988
|
+
}
|
|
1989
|
+
function NavigationMenuViewport({
|
|
1990
|
+
className,
|
|
1991
|
+
...props
|
|
1992
|
+
}) {
|
|
1993
|
+
return /* @__PURE__ */ jsx("div", { className: "mz-navmenu__viewport-wrap", children: /* @__PURE__ */ jsx(
|
|
1994
|
+
NavigationMenu$1.Viewport,
|
|
1995
|
+
{
|
|
1996
|
+
"data-slot": "navigation-menu-viewport",
|
|
1997
|
+
className: cn("mz-panel mz-navmenu__viewport", className),
|
|
1998
|
+
...props
|
|
1999
|
+
}
|
|
2000
|
+
) });
|
|
2001
|
+
}
|
|
2002
|
+
function NavigationMenuLink({
|
|
2003
|
+
className,
|
|
2004
|
+
...props
|
|
2005
|
+
}) {
|
|
2006
|
+
return /* @__PURE__ */ jsx(
|
|
2007
|
+
NavigationMenu$1.Link,
|
|
2008
|
+
{
|
|
2009
|
+
"data-slot": "navigation-menu-link",
|
|
2010
|
+
className: cn("mz-navmenu__link mz-focusable", className),
|
|
2011
|
+
...props
|
|
2012
|
+
}
|
|
2013
|
+
);
|
|
2014
|
+
}
|
|
2015
|
+
function NavigationMenuIndicator({
|
|
2016
|
+
className,
|
|
2017
|
+
...props
|
|
2018
|
+
}) {
|
|
2019
|
+
return /* @__PURE__ */ jsx(
|
|
2020
|
+
NavigationMenu$1.Indicator,
|
|
2021
|
+
{
|
|
2022
|
+
"data-slot": "navigation-menu-indicator",
|
|
2023
|
+
className: cn("mz-navmenu__indicator", className),
|
|
2024
|
+
...props,
|
|
2025
|
+
children: /* @__PURE__ */ jsx("div", { className: "mz-navmenu__arrow" })
|
|
2026
|
+
}
|
|
2027
|
+
);
|
|
2028
|
+
}
|
|
2029
|
+
var queue = [];
|
|
2030
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
2031
|
+
var counter = 0;
|
|
2032
|
+
function emit() {
|
|
2033
|
+
for (const listener of listeners) listener();
|
|
2034
|
+
}
|
|
2035
|
+
function subscribe(listener) {
|
|
2036
|
+
listeners.add(listener);
|
|
2037
|
+
return () => {
|
|
2038
|
+
listeners.delete(listener);
|
|
2039
|
+
};
|
|
2040
|
+
}
|
|
2041
|
+
var getSnapshot = () => queue;
|
|
2042
|
+
var emptyQueue = [];
|
|
2043
|
+
var getServerSnapshot = () => emptyQueue;
|
|
2044
|
+
function dismissToast(id) {
|
|
2045
|
+
const next = queue.filter((t) => t.id !== id);
|
|
2046
|
+
if (next.length === queue.length) return;
|
|
2047
|
+
queue = next;
|
|
2048
|
+
emit();
|
|
2049
|
+
}
|
|
2050
|
+
function toast(options) {
|
|
2051
|
+
const id = `mz-toast-${++counter}`;
|
|
2052
|
+
queue = [...queue, { ...options, id }].slice(-3);
|
|
2053
|
+
emit();
|
|
2054
|
+
return {
|
|
2055
|
+
id,
|
|
2056
|
+
dismiss: () => dismissToast(id),
|
|
2057
|
+
update: (next) => {
|
|
2058
|
+
queue = queue.map((t) => t.id === id ? { ...t, ...next, id } : t);
|
|
2059
|
+
emit();
|
|
2060
|
+
}
|
|
2061
|
+
};
|
|
2062
|
+
}
|
|
2063
|
+
function dismiss(id) {
|
|
2064
|
+
if (id) return dismissToast(id);
|
|
2065
|
+
if (queue.length === 0) return;
|
|
2066
|
+
queue = [];
|
|
2067
|
+
emit();
|
|
2068
|
+
}
|
|
2069
|
+
function useToast() {
|
|
2070
|
+
const toasts = React48.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
2071
|
+
return { toasts, toast, dismiss };
|
|
2072
|
+
}
|
|
2073
|
+
function ToastProvider({ ...props }) {
|
|
2074
|
+
return /* @__PURE__ */ jsx(Toast$1.Provider, { ...props });
|
|
2075
|
+
}
|
|
2076
|
+
function ToastViewport({
|
|
2077
|
+
className,
|
|
2078
|
+
...props
|
|
2079
|
+
}) {
|
|
2080
|
+
return /* @__PURE__ */ jsx(
|
|
2081
|
+
Toast$1.Viewport,
|
|
2082
|
+
{
|
|
2083
|
+
"data-slot": "toast-viewport",
|
|
2084
|
+
className: cn("mz-toast-viewport", className),
|
|
2085
|
+
...props
|
|
2086
|
+
}
|
|
2087
|
+
);
|
|
2088
|
+
}
|
|
2089
|
+
function Toast({
|
|
2090
|
+
className,
|
|
2091
|
+
tone,
|
|
2092
|
+
...props
|
|
2093
|
+
}) {
|
|
2094
|
+
return /* @__PURE__ */ jsx(
|
|
2095
|
+
Toast$1.Root,
|
|
2096
|
+
{
|
|
2097
|
+
"data-slot": "toast",
|
|
2098
|
+
"data-tone": tone,
|
|
2099
|
+
className: cn("mz-panel mz-toast", className),
|
|
2100
|
+
...props
|
|
2101
|
+
}
|
|
2102
|
+
);
|
|
2103
|
+
}
|
|
2104
|
+
function ToastTitle({ className, ...props }) {
|
|
2105
|
+
return /* @__PURE__ */ jsx(
|
|
2106
|
+
Toast$1.Title,
|
|
2107
|
+
{
|
|
2108
|
+
"data-slot": "toast-title",
|
|
2109
|
+
className: cn("mz-toast__title", className),
|
|
2110
|
+
...props
|
|
2111
|
+
}
|
|
2112
|
+
);
|
|
2113
|
+
}
|
|
2114
|
+
function ToastDescription({
|
|
2115
|
+
className,
|
|
2116
|
+
...props
|
|
2117
|
+
}) {
|
|
2118
|
+
return /* @__PURE__ */ jsx(
|
|
2119
|
+
Toast$1.Description,
|
|
2120
|
+
{
|
|
2121
|
+
"data-slot": "toast-description",
|
|
2122
|
+
className: cn("mz-toast__description", className),
|
|
2123
|
+
...props
|
|
2124
|
+
}
|
|
2125
|
+
);
|
|
2126
|
+
}
|
|
2127
|
+
function ToastAction({ className, ...props }) {
|
|
2128
|
+
return /* @__PURE__ */ jsx(
|
|
2129
|
+
Toast$1.Action,
|
|
2130
|
+
{
|
|
2131
|
+
"data-slot": "toast-action",
|
|
2132
|
+
className: cn("mz-toast__action mz-focusable", className),
|
|
2133
|
+
...props
|
|
2134
|
+
}
|
|
2135
|
+
);
|
|
2136
|
+
}
|
|
2137
|
+
function ToastClose({
|
|
2138
|
+
className,
|
|
2139
|
+
label = "Close",
|
|
2140
|
+
...props
|
|
2141
|
+
}) {
|
|
2142
|
+
return /* @__PURE__ */ jsxs(
|
|
2143
|
+
Toast$1.Close,
|
|
2144
|
+
{
|
|
2145
|
+
"data-slot": "toast-close",
|
|
2146
|
+
className: cn("mz-toast__close mz-focusable", className),
|
|
2147
|
+
...props,
|
|
2148
|
+
children: [
|
|
2149
|
+
/* @__PURE__ */ jsx(XIcon, {}),
|
|
2150
|
+
/* @__PURE__ */ jsx("span", { className: "mz-sr-only", children: label })
|
|
2151
|
+
]
|
|
2152
|
+
}
|
|
2153
|
+
);
|
|
2154
|
+
}
|
|
2155
|
+
function Toaster({
|
|
2156
|
+
duration = 5e3,
|
|
2157
|
+
position = "bottom-right",
|
|
2158
|
+
closeLabel = "Close",
|
|
2159
|
+
hotkey,
|
|
2160
|
+
className
|
|
2161
|
+
}) {
|
|
2162
|
+
const toasts = React48.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
2163
|
+
return /* @__PURE__ */ jsxs(ToastProvider, { duration, swipeDirection: "right", ...hotkey ? { hotkey } : {}, children: [
|
|
2164
|
+
toasts.map(({ id, title, description, tone, action, duration: own, onOpenChange }) => /* @__PURE__ */ jsxs(
|
|
2165
|
+
Toast,
|
|
2166
|
+
{
|
|
2167
|
+
tone,
|
|
2168
|
+
duration: own === Infinity ? 1e3 * 60 * 60 * 24 : own,
|
|
2169
|
+
onOpenChange: (open) => {
|
|
2170
|
+
onOpenChange?.(open);
|
|
2171
|
+
if (!open) dismissToast(id);
|
|
2172
|
+
},
|
|
2173
|
+
children: [
|
|
2174
|
+
/* @__PURE__ */ jsxs("div", { className: "mz-toast__body", children: [
|
|
2175
|
+
title ? /* @__PURE__ */ jsx(ToastTitle, { children: title }) : null,
|
|
2176
|
+
description ? /* @__PURE__ */ jsx(ToastDescription, { children: description }) : null
|
|
2177
|
+
] }),
|
|
2178
|
+
action,
|
|
2179
|
+
/* @__PURE__ */ jsx(ToastClose, { label: closeLabel })
|
|
2180
|
+
]
|
|
2181
|
+
},
|
|
2182
|
+
id
|
|
2183
|
+
)),
|
|
2184
|
+
/* @__PURE__ */ jsx(ToastViewport, { className: cn(`mz-toast-viewport--${position}`, className) })
|
|
2185
|
+
] });
|
|
2186
|
+
}
|
|
2187
|
+
|
|
2188
|
+
// src/lib/date.ts
|
|
2189
|
+
function startOfDay(date) {
|
|
2190
|
+
const d = new Date(date);
|
|
2191
|
+
d.setHours(0, 0, 0, 0);
|
|
2192
|
+
return d;
|
|
2193
|
+
}
|
|
2194
|
+
function isSameDay(a, b) {
|
|
2195
|
+
if (!a || !b) return false;
|
|
2196
|
+
return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
2197
|
+
}
|
|
2198
|
+
function isSameMonth(a, b) {
|
|
2199
|
+
return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth();
|
|
2200
|
+
}
|
|
2201
|
+
function startOfMonth(date) {
|
|
2202
|
+
return new Date(date.getFullYear(), date.getMonth(), 1);
|
|
2203
|
+
}
|
|
2204
|
+
function addDays(date, amount) {
|
|
2205
|
+
const d = new Date(date);
|
|
2206
|
+
d.setDate(d.getDate() + amount);
|
|
2207
|
+
return d;
|
|
2208
|
+
}
|
|
2209
|
+
function addMonths(date, amount) {
|
|
2210
|
+
const target = new Date(date.getFullYear(), date.getMonth() + amount, 1);
|
|
2211
|
+
const lastDay = new Date(target.getFullYear(), target.getMonth() + 1, 0).getDate();
|
|
2212
|
+
target.setDate(Math.min(date.getDate(), lastDay));
|
|
2213
|
+
return target;
|
|
2214
|
+
}
|
|
2215
|
+
function differenceInMonths(a, b) {
|
|
2216
|
+
return (a.getFullYear() - b.getFullYear()) * 12 + (a.getMonth() - b.getMonth());
|
|
2217
|
+
}
|
|
2218
|
+
function isBefore(a, b) {
|
|
2219
|
+
return startOfDay(a).getTime() < startOfDay(b).getTime();
|
|
2220
|
+
}
|
|
2221
|
+
function isAfter(a, b) {
|
|
2222
|
+
return startOfDay(a).getTime() > startOfDay(b).getTime();
|
|
2223
|
+
}
|
|
2224
|
+
function isWithin(date, from, to) {
|
|
2225
|
+
const t = startOfDay(date).getTime();
|
|
2226
|
+
return t >= startOfDay(from).getTime() && t <= startOfDay(to).getTime();
|
|
2227
|
+
}
|
|
2228
|
+
var SUNDAY_FIRST = /^(en-US|en-CA|en-AU|en-PH|en-ZA|ja|ko|zh|he|ar|pt-BR)\b/i;
|
|
2229
|
+
function localeWeekStart(locale) {
|
|
2230
|
+
if (!locale) return 1;
|
|
2231
|
+
try {
|
|
2232
|
+
const info = new Intl.Locale(locale).getWeekInfo?.();
|
|
2233
|
+
if (info) return info.firstDay % 7;
|
|
2234
|
+
} catch {
|
|
2235
|
+
}
|
|
2236
|
+
return SUNDAY_FIRST.test(locale) ? 0 : 1;
|
|
2237
|
+
}
|
|
2238
|
+
function monthGrid(month, weekStartsOn) {
|
|
2239
|
+
const first = startOfMonth(month);
|
|
2240
|
+
const lead = (first.getDay() - weekStartsOn + 7) % 7;
|
|
2241
|
+
const start = addDays(first, -lead);
|
|
2242
|
+
return Array.from({ length: 42 }, (_, i) => addDays(start, i));
|
|
2243
|
+
}
|
|
2244
|
+
function isoWeek(date) {
|
|
2245
|
+
const d = startOfDay(date);
|
|
2246
|
+
d.setDate(d.getDate() + 3 - (d.getDay() + 6) % 7);
|
|
2247
|
+
const firstThursday = new Date(d.getFullYear(), 0, 4);
|
|
2248
|
+
firstThursday.setDate(firstThursday.getDate() + 3 - (firstThursday.getDay() + 6) % 7);
|
|
2249
|
+
return 1 + Math.round((d.getTime() - firstThursday.getTime()) / (7 * 864e5));
|
|
2250
|
+
}
|
|
2251
|
+
var defaultLabels = {
|
|
2252
|
+
previousMonth: "Previous month",
|
|
2253
|
+
nextMonth: "Next month",
|
|
2254
|
+
month: "Month",
|
|
2255
|
+
year: "Year",
|
|
2256
|
+
weekNumber: "Week"
|
|
2257
|
+
};
|
|
2258
|
+
function matches(date, matcher) {
|
|
2259
|
+
if (!matcher) return false;
|
|
2260
|
+
if (typeof matcher === "function") return matcher(date);
|
|
2261
|
+
if (matcher instanceof Date) return isSameDay(date, matcher);
|
|
2262
|
+
if (Array.isArray(matcher)) return matcher.some((d) => isSameDay(date, d));
|
|
2263
|
+
if ("from" in matcher && matcher.from && matcher.to) return isWithin(date, matcher.from, matcher.to);
|
|
2264
|
+
const bounds = matcher;
|
|
2265
|
+
if (bounds.before && isBefore(date, bounds.before)) return true;
|
|
2266
|
+
if (bounds.after && isAfter(date, bounds.after)) return true;
|
|
2267
|
+
return false;
|
|
2268
|
+
}
|
|
2269
|
+
function Calendar({
|
|
2270
|
+
month: monthProp,
|
|
2271
|
+
defaultMonth,
|
|
2272
|
+
onMonthChange,
|
|
2273
|
+
numberOfMonths = 1,
|
|
2274
|
+
locale,
|
|
2275
|
+
weekStartsOn,
|
|
2276
|
+
disabled,
|
|
2277
|
+
fromDate,
|
|
2278
|
+
toDate,
|
|
2279
|
+
showOutsideDays = true,
|
|
2280
|
+
showWeekNumbers = false,
|
|
2281
|
+
captionLayout = "label",
|
|
2282
|
+
fromYear,
|
|
2283
|
+
toYear,
|
|
2284
|
+
today: todayProp,
|
|
2285
|
+
labels: labelsProp,
|
|
2286
|
+
className,
|
|
2287
|
+
id,
|
|
2288
|
+
...selection
|
|
2289
|
+
}) {
|
|
2290
|
+
const labels = { ...defaultLabels, ...labelsProp };
|
|
2291
|
+
const today = React48.useMemo(() => startOfDay(todayProp ?? /* @__PURE__ */ new Date()), [todayProp]);
|
|
2292
|
+
const firstDayOfWeek = weekStartsOn ?? localeWeekStart(locale);
|
|
2293
|
+
const initialMonth = React48.useMemo(
|
|
2294
|
+
() => startOfMonth(monthProp ?? defaultMonth ?? selectedAnchor(selection) ?? today),
|
|
2295
|
+
// Only the mount value matters; afterwards the month is state or a prop.
|
|
2296
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2297
|
+
[]
|
|
2298
|
+
);
|
|
2299
|
+
const [monthState, setMonthState] = React48.useState(initialMonth);
|
|
2300
|
+
const month = monthProp ? startOfMonth(monthProp) : monthState;
|
|
2301
|
+
const goToMonth = React48.useCallback(
|
|
2302
|
+
(next) => {
|
|
2303
|
+
const clamped = clampMonth(next, fromDate, toDate);
|
|
2304
|
+
if (!monthProp) setMonthState(clamped);
|
|
2305
|
+
onMonthChange?.(clamped);
|
|
2306
|
+
},
|
|
2307
|
+
[fromDate, toDate, monthProp, onMonthChange]
|
|
2308
|
+
);
|
|
2309
|
+
const monthCount = Math.max(1, numberOfMonths);
|
|
2310
|
+
const months = React48.useMemo(
|
|
2311
|
+
() => Array.from({ length: monthCount }, (_, i) => addMonths(month, i)),
|
|
2312
|
+
[month, monthCount]
|
|
2313
|
+
);
|
|
2314
|
+
const leadMonth = month;
|
|
2315
|
+
const lastMonth = addMonths(month, monthCount - 1);
|
|
2316
|
+
const canGoBack = !fromDate || differenceInMonths(month, startOfMonth(fromDate)) > 0;
|
|
2317
|
+
const canGoForward = !toDate || differenceInMonths(startOfMonth(toDate), lastMonth) > 0;
|
|
2318
|
+
const isDisabled = React48.useCallback(
|
|
2319
|
+
(date) => {
|
|
2320
|
+
if (fromDate && isBefore(date, fromDate)) return true;
|
|
2321
|
+
if (toDate && isAfter(date, toDate)) return true;
|
|
2322
|
+
return matches(date, disabled);
|
|
2323
|
+
},
|
|
2324
|
+
[disabled, fromDate, toDate]
|
|
2325
|
+
);
|
|
2326
|
+
const [previewDay, setPreviewDay] = React48.useState();
|
|
2327
|
+
const handleSelect = (date) => {
|
|
2328
|
+
if (isDisabled(date)) return;
|
|
2329
|
+
if (selection.mode === "multiple") {
|
|
2330
|
+
const current = selection.selected ?? [];
|
|
2331
|
+
const next = current.some((d) => isSameDay(d, date)) ? current.filter((d) => !isSameDay(d, date)) : [...current, date];
|
|
2332
|
+
selection.onSelect?.(next);
|
|
2333
|
+
return;
|
|
2334
|
+
}
|
|
2335
|
+
if (selection.mode === "range") {
|
|
2336
|
+
const current = selection.selected;
|
|
2337
|
+
if (current?.from && !current.to) {
|
|
2338
|
+
const [from, to] = isBefore(date, current.from) ? [date, current.from] : [current.from, date];
|
|
2339
|
+
selection.onSelect?.({ from, to });
|
|
2340
|
+
setPreviewDay(void 0);
|
|
2341
|
+
} else {
|
|
2342
|
+
selection.onSelect?.({ from: date, to: void 0 });
|
|
2343
|
+
}
|
|
2344
|
+
return;
|
|
2345
|
+
}
|
|
2346
|
+
const single = selection;
|
|
2347
|
+
const isSame = isSameDay(single.selected, date);
|
|
2348
|
+
single.onSelect?.(isSame && !single.required ? void 0 : date);
|
|
2349
|
+
};
|
|
2350
|
+
const selectionStateOf = (date) => {
|
|
2351
|
+
if (selection.mode === "multiple") {
|
|
2352
|
+
return { selected: (selection.selected ?? []).some((d) => isSameDay(d, date)) };
|
|
2353
|
+
}
|
|
2354
|
+
if (selection.mode === "range") {
|
|
2355
|
+
const { from, to } = selection.selected ?? {};
|
|
2356
|
+
const tentative = Boolean(from && !to && previewDay);
|
|
2357
|
+
const other = to ?? (tentative ? previewDay : void 0);
|
|
2358
|
+
const [start, end] = from && other && isBefore(other, from) ? [other, from] : [from, other];
|
|
2359
|
+
const isStart = isSameDay(date, start);
|
|
2360
|
+
const isEnd = Boolean(end) && isSameDay(date, end);
|
|
2361
|
+
const inside = Boolean(start && end) && !isStart && !isEnd && isWithin(date, start, end);
|
|
2362
|
+
return {
|
|
2363
|
+
// Only a committed end reads as selected; the hovered one is a preview.
|
|
2364
|
+
selected: isSameDay(date, from) || isSameDay(date, to),
|
|
2365
|
+
rangeStart: isStart,
|
|
2366
|
+
rangeEnd: isEnd,
|
|
2367
|
+
rangeMiddle: inside,
|
|
2368
|
+
preview: tentative && (inside || (isStart || isEnd) && !isSameDay(date, from))
|
|
2369
|
+
};
|
|
2370
|
+
}
|
|
2371
|
+
return { selected: isSameDay(selection.selected, date) };
|
|
2372
|
+
};
|
|
2373
|
+
const rootRef = React48.useRef(null);
|
|
2374
|
+
const [focusedDay, setFocusedDay] = React48.useState();
|
|
2375
|
+
const tabbableDay = React48.useMemo(() => {
|
|
2376
|
+
const candidates = [focusedDay, selectedAnchor(selection), today].filter(Boolean);
|
|
2377
|
+
const visible = candidates.find((d) => months.some((m) => isSameMonth(m, d)));
|
|
2378
|
+
return visible ?? startOfMonth(leadMonth);
|
|
2379
|
+
}, [focusedDay, selection, today, months, leadMonth]);
|
|
2380
|
+
React48.useEffect(() => {
|
|
2381
|
+
if (!focusedDay || !rootRef.current) return;
|
|
2382
|
+
if (!rootRef.current.contains(document.activeElement)) return;
|
|
2383
|
+
const target = rootRef.current.querySelector(
|
|
2384
|
+
`[data-day="${dayKey(focusedDay)}"]`
|
|
2385
|
+
);
|
|
2386
|
+
target?.focus();
|
|
2387
|
+
}, [focusedDay, month]);
|
|
2388
|
+
const moveFocus = (from, delta) => {
|
|
2389
|
+
const next = addDays(from, delta);
|
|
2390
|
+
setFocusedDay(next);
|
|
2391
|
+
if (!months.some((m) => isSameMonth(m, next))) {
|
|
2392
|
+
goToMonth(isBefore(next, leadMonth) ? next : addMonths(next, -(monthCount - 1)));
|
|
2393
|
+
}
|
|
2394
|
+
};
|
|
2395
|
+
const onKeyDown = (event, date) => {
|
|
2396
|
+
const step = {
|
|
2397
|
+
ArrowLeft: -1,
|
|
2398
|
+
ArrowRight: 1,
|
|
2399
|
+
ArrowUp: -7,
|
|
2400
|
+
ArrowDown: 7
|
|
2401
|
+
};
|
|
2402
|
+
const delta = step[event.key];
|
|
2403
|
+
if (delta !== void 0) {
|
|
2404
|
+
event.preventDefault();
|
|
2405
|
+
moveFocus(date, delta);
|
|
2406
|
+
return;
|
|
2407
|
+
}
|
|
2408
|
+
if (event.key === "Home" || event.key === "End") {
|
|
2409
|
+
event.preventDefault();
|
|
2410
|
+
const offset = (date.getDay() - firstDayOfWeek + 7) % 7;
|
|
2411
|
+
moveFocus(date, event.key === "Home" ? -offset : 6 - offset);
|
|
2412
|
+
return;
|
|
2413
|
+
}
|
|
2414
|
+
if (event.key === "PageUp" || event.key === "PageDown") {
|
|
2415
|
+
event.preventDefault();
|
|
2416
|
+
const next = addMonths(date, event.key === "PageUp" ? -1 : 1);
|
|
2417
|
+
setFocusedDay(next);
|
|
2418
|
+
goToMonth(next);
|
|
2419
|
+
}
|
|
2420
|
+
};
|
|
2421
|
+
const fmt = React48.useMemo(
|
|
2422
|
+
() => ({
|
|
2423
|
+
caption: new Intl.DateTimeFormat(locale, { month: "long", year: "numeric" }),
|
|
2424
|
+
monthName: new Intl.DateTimeFormat(locale, { month: "long" }),
|
|
2425
|
+
weekday: new Intl.DateTimeFormat(locale, { weekday: "short" }),
|
|
2426
|
+
weekdayLong: new Intl.DateTimeFormat(locale, { weekday: "long" }),
|
|
2427
|
+
day: new Intl.DateTimeFormat(locale, {
|
|
2428
|
+
weekday: "long",
|
|
2429
|
+
day: "numeric",
|
|
2430
|
+
month: "long",
|
|
2431
|
+
year: "numeric"
|
|
2432
|
+
})
|
|
2433
|
+
}),
|
|
2434
|
+
[locale]
|
|
2435
|
+
);
|
|
2436
|
+
const weekdays = React48.useMemo(() => {
|
|
2437
|
+
const sunday = new Date(2021, 7, 1);
|
|
2438
|
+
return Array.from({ length: 7 }, (_, i) => addDays(sunday, (firstDayOfWeek + i) % 7));
|
|
2439
|
+
}, [firstDayOfWeek]);
|
|
2440
|
+
const years = React48.useMemo(() => {
|
|
2441
|
+
const start = fromYear ?? (fromDate ? fromDate.getFullYear() : today.getFullYear() - 10);
|
|
2442
|
+
const end = toYear ?? (toDate ? toDate.getFullYear() : today.getFullYear() + 10);
|
|
2443
|
+
return Array.from({ length: Math.max(1, end - start + 1) }, (_, i) => start + i);
|
|
2444
|
+
}, [fromYear, toYear, fromDate, toDate, today]);
|
|
2445
|
+
return /* @__PURE__ */ jsxs(
|
|
2446
|
+
"div",
|
|
2447
|
+
{
|
|
2448
|
+
ref: rootRef,
|
|
2449
|
+
id,
|
|
2450
|
+
"data-slot": "calendar",
|
|
2451
|
+
className: cn("mz-calendar", className),
|
|
2452
|
+
onMouseLeave: () => setPreviewDay(void 0),
|
|
2453
|
+
children: [
|
|
2454
|
+
/* @__PURE__ */ jsxs("div", { className: "mz-calendar__nav", children: [
|
|
2455
|
+
/* @__PURE__ */ jsx(
|
|
2456
|
+
"button",
|
|
2457
|
+
{
|
|
2458
|
+
type: "button",
|
|
2459
|
+
"data-slot": "calendar-previous",
|
|
2460
|
+
className: "mz-calendar__nav-button mz-focusable",
|
|
2461
|
+
"aria-label": labels.previousMonth,
|
|
2462
|
+
disabled: !canGoBack,
|
|
2463
|
+
onClick: () => goToMonth(addMonths(month, -1)),
|
|
2464
|
+
children: /* @__PURE__ */ jsx(ChevronLeftIcon, {})
|
|
2465
|
+
}
|
|
2466
|
+
),
|
|
2467
|
+
/* @__PURE__ */ jsx(
|
|
2468
|
+
"button",
|
|
2469
|
+
{
|
|
2470
|
+
type: "button",
|
|
2471
|
+
"data-slot": "calendar-next",
|
|
2472
|
+
className: "mz-calendar__nav-button mz-focusable",
|
|
2473
|
+
"aria-label": labels.nextMonth,
|
|
2474
|
+
disabled: !canGoForward,
|
|
2475
|
+
onClick: () => goToMonth(addMonths(month, 1)),
|
|
2476
|
+
children: /* @__PURE__ */ jsx(ChevronRightIcon, {})
|
|
2477
|
+
}
|
|
2478
|
+
)
|
|
2479
|
+
] }),
|
|
2480
|
+
/* @__PURE__ */ jsx("div", { className: "mz-calendar__months", children: months.map((displayed, index) => /* @__PURE__ */ jsxs("div", { className: "mz-calendar__month", children: [
|
|
2481
|
+
captionLayout === "dropdown" && index === 0 ? /* @__PURE__ */ jsxs("div", { className: "mz-calendar__caption mz-calendar__caption--dropdown", children: [
|
|
2482
|
+
/* @__PURE__ */ jsx(
|
|
2483
|
+
"select",
|
|
2484
|
+
{
|
|
2485
|
+
className: "mz-calendar__dropdown mz-focusable",
|
|
2486
|
+
"aria-label": labels.month,
|
|
2487
|
+
value: displayed.getMonth(),
|
|
2488
|
+
onChange: (e) => goToMonth(new Date(displayed.getFullYear(), Number(e.target.value), 1)),
|
|
2489
|
+
children: Array.from({ length: 12 }, (_, m) => /* @__PURE__ */ jsx("option", { value: m, children: fmt.monthName.format(new Date(2021, m, 1)) }, m))
|
|
2490
|
+
}
|
|
2491
|
+
),
|
|
2492
|
+
/* @__PURE__ */ jsx(
|
|
2493
|
+
"select",
|
|
2494
|
+
{
|
|
2495
|
+
className: "mz-calendar__dropdown mz-focusable",
|
|
2496
|
+
"aria-label": labels.year,
|
|
2497
|
+
value: displayed.getFullYear(),
|
|
2498
|
+
onChange: (e) => goToMonth(new Date(Number(e.target.value), displayed.getMonth(), 1)),
|
|
2499
|
+
children: years.map((y) => /* @__PURE__ */ jsx("option", { value: y, children: y }, y))
|
|
2500
|
+
}
|
|
2501
|
+
)
|
|
2502
|
+
] }) : /* @__PURE__ */ jsx("div", { className: "mz-calendar__caption", "aria-live": "polite", children: fmt.caption.format(displayed) }),
|
|
2503
|
+
/* @__PURE__ */ jsxs("table", { className: "mz-calendar__grid", role: "grid", children: [
|
|
2504
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { className: "mz-calendar__weekdays", children: [
|
|
2505
|
+
showWeekNumbers ? /* @__PURE__ */ jsx("th", { scope: "col", className: "mz-calendar__weeknum-head", children: /* @__PURE__ */ jsx("span", { className: "mz-sr-only", children: labels.weekNumber }) }) : null,
|
|
2506
|
+
weekdays.map((d) => /* @__PURE__ */ jsxs("th", { scope: "col", className: "mz-calendar__weekday", children: [
|
|
2507
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: fmt.weekday.format(d) }),
|
|
2508
|
+
/* @__PURE__ */ jsx("span", { className: "mz-sr-only", children: fmt.weekdayLong.format(d) })
|
|
2509
|
+
] }, d.getDay()))
|
|
2510
|
+
] }) }),
|
|
2511
|
+
/* @__PURE__ */ jsx("tbody", { children: chunk(monthGrid(displayed, firstDayOfWeek), 7).map((week, weekIndex) => {
|
|
2512
|
+
const weekStart = week[0];
|
|
2513
|
+
return /* @__PURE__ */ jsxs("tr", { className: "mz-calendar__week", children: [
|
|
2514
|
+
showWeekNumbers && weekStart ? /* @__PURE__ */ jsx("td", { className: "mz-calendar__weeknum", children: isoWeek(weekStart) }) : null,
|
|
2515
|
+
week.map((date) => {
|
|
2516
|
+
const outside = !isSameMonth(date, displayed);
|
|
2517
|
+
const state = selectionStateOf(date);
|
|
2518
|
+
const dayDisabled = isDisabled(date);
|
|
2519
|
+
if (outside && !showOutsideDays) {
|
|
2520
|
+
return /* @__PURE__ */ jsx("td", { className: "mz-calendar__cell" }, date.getTime());
|
|
2521
|
+
}
|
|
2522
|
+
return /* @__PURE__ */ jsx("td", { className: "mz-calendar__cell", role: "gridcell", children: /* @__PURE__ */ jsx(
|
|
2523
|
+
"button",
|
|
2524
|
+
{
|
|
2525
|
+
type: "button",
|
|
2526
|
+
"data-slot": "calendar-day",
|
|
2527
|
+
"data-day": dayKey(date),
|
|
2528
|
+
"data-outside": outside || void 0,
|
|
2529
|
+
"data-today": isSameDay(date, today) || void 0,
|
|
2530
|
+
"data-selected": state.selected || void 0,
|
|
2531
|
+
"data-range-start": state.rangeStart || void 0,
|
|
2532
|
+
"data-range-end": state.rangeEnd || void 0,
|
|
2533
|
+
"data-range-middle": state.rangeMiddle || void 0,
|
|
2534
|
+
"data-preview": state.preview || void 0,
|
|
2535
|
+
className: "mz-calendar__day mz-focusable",
|
|
2536
|
+
tabIndex: isSameDay(date, tabbableDay) ? 0 : -1,
|
|
2537
|
+
"aria-selected": state.selected || void 0,
|
|
2538
|
+
"aria-label": fmt.day.format(date),
|
|
2539
|
+
disabled: dayDisabled,
|
|
2540
|
+
onClick: () => handleSelect(date),
|
|
2541
|
+
onFocus: () => setFocusedDay(date),
|
|
2542
|
+
onMouseEnter: () => setPreviewDay(date),
|
|
2543
|
+
onKeyDown: (e) => onKeyDown(e, date),
|
|
2544
|
+
children: date.getDate()
|
|
2545
|
+
}
|
|
2546
|
+
) }, date.getTime());
|
|
2547
|
+
})
|
|
2548
|
+
] }, weekStart ? weekStart.getTime() : weekIndex);
|
|
2549
|
+
}) })
|
|
2550
|
+
] })
|
|
2551
|
+
] }, displayed.getTime())) })
|
|
2552
|
+
]
|
|
2553
|
+
}
|
|
2554
|
+
);
|
|
2555
|
+
}
|
|
2556
|
+
function dayKey(date) {
|
|
2557
|
+
return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`;
|
|
2558
|
+
}
|
|
2559
|
+
function chunk(items, size) {
|
|
2560
|
+
const out = [];
|
|
2561
|
+
for (let i = 0; i < items.length; i += size) out.push(items.slice(i, i + size));
|
|
2562
|
+
return out;
|
|
2563
|
+
}
|
|
2564
|
+
function selectedAnchor(selection) {
|
|
2565
|
+
if (selection.mode === "multiple") return selection.selected?.[0];
|
|
2566
|
+
if (selection.mode === "range") return selection.selected?.from;
|
|
2567
|
+
return selection.selected;
|
|
2568
|
+
}
|
|
2569
|
+
function clampMonth(month, fromDate, toDate) {
|
|
2570
|
+
const m = startOfMonth(month);
|
|
2571
|
+
if (fromDate && differenceInMonths(m, startOfMonth(fromDate)) < 0) return startOfMonth(fromDate);
|
|
2572
|
+
if (toDate && differenceInMonths(m, startOfMonth(toDate)) > 0) return startOfMonth(toDate);
|
|
2573
|
+
return m;
|
|
2574
|
+
}
|
|
2575
|
+
var ChartContext = React48.createContext(null);
|
|
2576
|
+
function useChart() {
|
|
2577
|
+
const context = React48.useContext(ChartContext);
|
|
2578
|
+
if (!context) throw new Error("useChart must be used inside a <ChartContainer>");
|
|
2579
|
+
return context;
|
|
2580
|
+
}
|
|
2581
|
+
function ChartStyle({ id, config }) {
|
|
2582
|
+
const entries = Object.entries(config).filter(([, item]) => item.theme || item.color);
|
|
2583
|
+
if (entries.length === 0) return null;
|
|
2584
|
+
const block = (theme) => entries.map(([key, item]) => {
|
|
2585
|
+
const color = item.theme ? item.theme[theme] : item.color;
|
|
2586
|
+
return color && isSafeColor(color) ? ` --color-${cssIdent(key)}: ${color};` : null;
|
|
2587
|
+
}).filter(Boolean).join("\n");
|
|
2588
|
+
return /* @__PURE__ */ jsx(
|
|
2589
|
+
"style",
|
|
2590
|
+
{
|
|
2591
|
+
dangerouslySetInnerHTML: {
|
|
2592
|
+
__html: [
|
|
2593
|
+
`[data-chart='${id}'] {
|
|
2594
|
+
${block("light")}
|
|
2595
|
+
}`,
|
|
2596
|
+
`[data-mz-theme='dark'] [data-chart='${id}'],`,
|
|
2597
|
+
`.mz-theme-dark [data-chart='${id}'],`,
|
|
2598
|
+
`.dark [data-chart='${id}'] {
|
|
2599
|
+
${block("dark")}
|
|
2600
|
+
}`
|
|
2601
|
+
].join("\n")
|
|
2602
|
+
}
|
|
2603
|
+
}
|
|
2604
|
+
);
|
|
2605
|
+
}
|
|
2606
|
+
function ChartContainer({
|
|
2607
|
+
id,
|
|
2608
|
+
className,
|
|
2609
|
+
children,
|
|
2610
|
+
config,
|
|
2611
|
+
...props
|
|
2612
|
+
}) {
|
|
2613
|
+
const uid = React48.useId();
|
|
2614
|
+
const chartId = `mz-chart-${(id ?? uid).replace(/:/g, "")}`;
|
|
2615
|
+
return /* @__PURE__ */ jsx(ChartContext.Provider, { value: { config }, children: /* @__PURE__ */ jsxs(
|
|
2616
|
+
"div",
|
|
2617
|
+
{
|
|
2618
|
+
"data-slot": "chart",
|
|
2619
|
+
"data-chart": chartId,
|
|
2620
|
+
className: cn("mz-chart", className),
|
|
2621
|
+
...props,
|
|
2622
|
+
children: [
|
|
2623
|
+
/* @__PURE__ */ jsx(ChartStyle, { id: chartId, config }),
|
|
2624
|
+
children
|
|
1294
2625
|
]
|
|
1295
2626
|
}
|
|
1296
2627
|
) });
|
|
1297
2628
|
}
|
|
2629
|
+
function configKeyOf(item, explicitKey, fallback) {
|
|
2630
|
+
if (!explicitKey) return fallback;
|
|
2631
|
+
const fromItem = item[explicitKey];
|
|
2632
|
+
if (typeof fromItem === "string") return fromItem;
|
|
2633
|
+
const fromDatum = item.payload?.[explicitKey];
|
|
2634
|
+
if (typeof fromDatum === "string") return fromDatum;
|
|
2635
|
+
return explicitKey;
|
|
2636
|
+
}
|
|
2637
|
+
function ChartTooltipContent({
|
|
2638
|
+
active,
|
|
2639
|
+
payload = [],
|
|
2640
|
+
label,
|
|
2641
|
+
labelFormatter,
|
|
2642
|
+
formatter,
|
|
2643
|
+
hideLabel = false,
|
|
2644
|
+
hideIndicator = false,
|
|
2645
|
+
indicator = "dot",
|
|
2646
|
+
nameKey,
|
|
2647
|
+
labelKey,
|
|
2648
|
+
className
|
|
2649
|
+
}) {
|
|
2650
|
+
const { config } = useChart();
|
|
2651
|
+
if (!active || payload.length === 0) return null;
|
|
2652
|
+
const first = payload[0];
|
|
2653
|
+
const labelled = labelKey && first ? config[configKeyOf(first, labelKey, labelKey)]?.label : void 0;
|
|
2654
|
+
const rawLabel = labelled ?? (typeof label === "string" ? config[label]?.label ?? label : label);
|
|
2655
|
+
const heading = labelFormatter ? labelFormatter(rawLabel, payload) : rawLabel;
|
|
2656
|
+
return /* @__PURE__ */ jsxs("div", { "data-slot": "chart-tooltip", className: cn("mz-panel mz-chart__tooltip", className), children: [
|
|
2657
|
+
!hideLabel && heading != null ? /* @__PURE__ */ jsx("div", { className: "mz-chart__tooltip-label", children: heading }) : null,
|
|
2658
|
+
/* @__PURE__ */ jsx("div", { className: "mz-chart__tooltip-items", children: payload.map((item, index) => {
|
|
2659
|
+
const key = configKeyOf(item, nameKey, String(item.dataKey ?? item.name ?? index));
|
|
2660
|
+
const series = config[key];
|
|
2661
|
+
const color = item.color ?? item.fill ?? `var(--color-${cssIdent(key)})`;
|
|
2662
|
+
const name = series?.label ?? item.name ?? key;
|
|
2663
|
+
return /* @__PURE__ */ jsxs("div", { className: "mz-chart__tooltip-item", children: [
|
|
2664
|
+
!hideIndicator ? series?.icon ? /* @__PURE__ */ jsx(series.icon, { className: "mz-chart__tooltip-icon" }) : /* @__PURE__ */ jsx(
|
|
2665
|
+
"span",
|
|
2666
|
+
{
|
|
2667
|
+
className: cn("mz-chart__swatch", `mz-chart__swatch--${indicator}`),
|
|
2668
|
+
style: { "--mz-chart-color": color }
|
|
2669
|
+
}
|
|
2670
|
+
) : null,
|
|
2671
|
+
/* @__PURE__ */ jsx("span", { className: "mz-chart__tooltip-name", children: name }),
|
|
2672
|
+
/* @__PURE__ */ jsx("span", { className: "mz-chart__tooltip-value", children: formatter ? formatter(item.value, name, item) : item.value })
|
|
2673
|
+
] }, key + index);
|
|
2674
|
+
}) })
|
|
2675
|
+
] });
|
|
2676
|
+
}
|
|
2677
|
+
function ChartLegendContent({
|
|
2678
|
+
payload = [],
|
|
2679
|
+
hideIcon = false,
|
|
2680
|
+
nameKey,
|
|
2681
|
+
className
|
|
2682
|
+
}) {
|
|
2683
|
+
const { config } = useChart();
|
|
2684
|
+
if (payload.length === 0) return null;
|
|
2685
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "chart-legend", className: cn("mz-chart__legend", className), children: payload.map((item, index) => {
|
|
2686
|
+
const key = configKeyOf(item, nameKey, String(item.dataKey ?? item.name ?? index));
|
|
2687
|
+
const series = config[key];
|
|
2688
|
+
const color = item.color ?? item.fill ?? `var(--color-${cssIdent(key)})`;
|
|
2689
|
+
return /* @__PURE__ */ jsxs("div", { className: "mz-chart__legend-item", children: [
|
|
2690
|
+
!hideIcon ? series?.icon ? /* @__PURE__ */ jsx(series.icon, { className: "mz-chart__tooltip-icon" }) : /* @__PURE__ */ jsx(
|
|
2691
|
+
"span",
|
|
2692
|
+
{
|
|
2693
|
+
className: "mz-chart__swatch mz-chart__swatch--dot",
|
|
2694
|
+
style: { "--mz-chart-color": color }
|
|
2695
|
+
}
|
|
2696
|
+
) : null,
|
|
2697
|
+
series?.label ?? item.name ?? key
|
|
2698
|
+
] }, key + index);
|
|
2699
|
+
}) });
|
|
2700
|
+
}
|
|
2701
|
+
function cssIdent(key) {
|
|
2702
|
+
return key.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
2703
|
+
}
|
|
2704
|
+
function isSafeColor(value) {
|
|
2705
|
+
if (value.length > 128) return false;
|
|
2706
|
+
if (/[;{}<>\\]/.test(value)) return false;
|
|
2707
|
+
if (/url\s*\(|expression\s*\(|@import/i.test(value)) return false;
|
|
2708
|
+
return /^(#[0-9a-f]{3,8}|(rgb|rgba|hsl|hsla|oklch|oklab|lab|lch|color|color-mix|var)\s*\(.*\)|[a-z-]+)$/i.test(
|
|
2709
|
+
value.trim()
|
|
2710
|
+
);
|
|
2711
|
+
}
|
|
1298
2712
|
function Sheet({ ...props }) {
|
|
1299
2713
|
return /* @__PURE__ */ jsx(Dialog$1.Root, { "data-slot": "sheet", ...props });
|
|
1300
2714
|
}
|
|
@@ -1375,8 +2789,8 @@ function SheetDescription({
|
|
|
1375
2789
|
);
|
|
1376
2790
|
}
|
|
1377
2791
|
function useIsMobile(breakpoint = 768) {
|
|
1378
|
-
const [isMobile, setIsMobile] =
|
|
1379
|
-
|
|
2792
|
+
const [isMobile, setIsMobile] = React48.useState(false);
|
|
2793
|
+
React48.useEffect(() => {
|
|
1380
2794
|
const query = window.matchMedia(`(max-width: ${breakpoint - 1}px)`);
|
|
1381
2795
|
const update = () => setIsMobile(query.matches);
|
|
1382
2796
|
update();
|
|
@@ -1387,9 +2801,9 @@ function useIsMobile(breakpoint = 768) {
|
|
|
1387
2801
|
}
|
|
1388
2802
|
var STORAGE_KEY = "morze-ui-sidebar";
|
|
1389
2803
|
var SHORTCUT = "b";
|
|
1390
|
-
var SidebarContext =
|
|
2804
|
+
var SidebarContext = React48.createContext(null);
|
|
1391
2805
|
function useSidebar() {
|
|
1392
|
-
const context =
|
|
2806
|
+
const context = React48.useContext(SidebarContext);
|
|
1393
2807
|
if (!context) throw new Error("useSidebar must be used inside <SidebarProvider>");
|
|
1394
2808
|
return context;
|
|
1395
2809
|
}
|
|
@@ -1414,14 +2828,14 @@ function SidebarProvider({
|
|
|
1414
2828
|
...props
|
|
1415
2829
|
}) {
|
|
1416
2830
|
const isMobile = useIsMobile(mobileBreakpoint);
|
|
1417
|
-
const [openMobile, setOpenMobile] =
|
|
1418
|
-
const [internalOpen, setInternalOpen] =
|
|
1419
|
-
|
|
2831
|
+
const [openMobile, setOpenMobile] = React48.useState(false);
|
|
2832
|
+
const [internalOpen, setInternalOpen] = React48.useState(defaultOpen);
|
|
2833
|
+
React48.useEffect(() => {
|
|
1420
2834
|
const stored = readStored2(storageKey);
|
|
1421
2835
|
if (stored !== null) setInternalOpen(stored);
|
|
1422
2836
|
}, [storageKey]);
|
|
1423
2837
|
const open = openProp ?? internalOpen;
|
|
1424
|
-
const setOpen =
|
|
2838
|
+
const setOpen = React48.useCallback(
|
|
1425
2839
|
(next) => {
|
|
1426
2840
|
if (openProp === void 0) setInternalOpen(next);
|
|
1427
2841
|
onOpenChange?.(next);
|
|
@@ -1433,11 +2847,11 @@ function SidebarProvider({
|
|
|
1433
2847
|
},
|
|
1434
2848
|
[openProp, onOpenChange, storageKey]
|
|
1435
2849
|
);
|
|
1436
|
-
const toggleSidebar =
|
|
2850
|
+
const toggleSidebar = React48.useCallback(() => {
|
|
1437
2851
|
if (isMobile) setOpenMobile((current) => !current);
|
|
1438
2852
|
else setOpen(!open);
|
|
1439
2853
|
}, [isMobile, open, setOpen]);
|
|
1440
|
-
|
|
2854
|
+
React48.useEffect(() => {
|
|
1441
2855
|
const onKeyDown = (event) => {
|
|
1442
2856
|
if (event.key.toLowerCase() !== SHORTCUT || !(event.metaKey || event.ctrlKey)) return;
|
|
1443
2857
|
event.preventDefault();
|
|
@@ -1446,7 +2860,7 @@ function SidebarProvider({
|
|
|
1446
2860
|
window.addEventListener("keydown", onKeyDown);
|
|
1447
2861
|
return () => window.removeEventListener("keydown", onKeyDown);
|
|
1448
2862
|
}, [toggleSidebar]);
|
|
1449
|
-
const value =
|
|
2863
|
+
const value = React48.useMemo(
|
|
1450
2864
|
() => ({
|
|
1451
2865
|
state: open ? "expanded" : "collapsed",
|
|
1452
2866
|
open,
|
|
@@ -1672,7 +3086,7 @@ function SidebarMenuSkeleton({
|
|
|
1672
3086
|
showIcon = false,
|
|
1673
3087
|
...props
|
|
1674
3088
|
}) {
|
|
1675
|
-
const width =
|
|
3089
|
+
const width = React48.useMemo(() => `${Math.floor(Math.random() * 40) + 50}%`, []);
|
|
1676
3090
|
return /* @__PURE__ */ jsxs(
|
|
1677
3091
|
"div",
|
|
1678
3092
|
{
|
|
@@ -1717,9 +3131,9 @@ function CellEditor({
|
|
|
1717
3131
|
onDone
|
|
1718
3132
|
}) {
|
|
1719
3133
|
const initial = def.value(row);
|
|
1720
|
-
const [value, setValue] =
|
|
1721
|
-
const [saving, setSaving] =
|
|
1722
|
-
const [error, setError] =
|
|
3134
|
+
const [value, setValue] = React48.useState(initial);
|
|
3135
|
+
const [saving, setSaving] = React48.useState(false);
|
|
3136
|
+
const [error, setError] = React48.useState(null);
|
|
1723
3137
|
const commit = async () => {
|
|
1724
3138
|
if (value === initial) return onDone();
|
|
1725
3139
|
setSaving(true);
|
|
@@ -1893,9 +3307,9 @@ function parseSort(raw) {
|
|
|
1893
3307
|
}
|
|
1894
3308
|
function ColumnFilter({ columnLabel, def, value, onApply, labels: labelsProp }) {
|
|
1895
3309
|
const labels = resolveLabels(labelsProp);
|
|
1896
|
-
const [open, setOpen] =
|
|
1897
|
-
const [draft, setDraft] =
|
|
1898
|
-
|
|
3310
|
+
const [open, setOpen] = React48.useState(false);
|
|
3311
|
+
const [draft, setDraft] = React48.useState(value);
|
|
3312
|
+
React48.useEffect(() => {
|
|
1899
3313
|
if (open) setDraft(value);
|
|
1900
3314
|
}, [open, value]);
|
|
1901
3315
|
const active = isFilterActive(value);
|
|
@@ -2103,9 +3517,9 @@ function ColumnManager({
|
|
|
2103
3517
|
labels: labelsProp
|
|
2104
3518
|
}) {
|
|
2105
3519
|
const labels = resolveLabels(labelsProp);
|
|
2106
|
-
const [dragging, setDragging] =
|
|
2107
|
-
const [dropTarget, setDropTarget] =
|
|
2108
|
-
const entries =
|
|
3520
|
+
const [dragging, setDragging] = React48.useState(null);
|
|
3521
|
+
const [dropTarget, setDropTarget] = React48.useState(null);
|
|
3522
|
+
const entries = React48.useMemo(() => {
|
|
2109
3523
|
const byId = new Map(columns.map((c, index) => [c.id, { column: c, declaredIndex: index }]));
|
|
2110
3524
|
const ordered = layout.order.map((id) => byId.get(id)).filter((e) => Boolean(e));
|
|
2111
3525
|
const side = (id) => layout.pinned[id];
|
|
@@ -2339,9 +3753,9 @@ function DataTablePagination({
|
|
|
2339
3753
|
}
|
|
2340
3754
|
function useColumnResize(options) {
|
|
2341
3755
|
const { rootRef, widthOf, minWidthOf, onCommit } = options;
|
|
2342
|
-
const [resizing, setResizing] =
|
|
3756
|
+
const [resizing, setResizing] = React48.useState(null);
|
|
2343
3757
|
const varName = (id) => `--mz-dt-w-${cssSafe(id)}`;
|
|
2344
|
-
const start =
|
|
3758
|
+
const start = React48.useCallback(
|
|
2345
3759
|
(event, id) => {
|
|
2346
3760
|
if (event.button !== 0) return;
|
|
2347
3761
|
event.preventDefault();
|
|
@@ -2373,7 +3787,7 @@ function useColumnResize(options) {
|
|
|
2373
3787
|
},
|
|
2374
3788
|
[rootRef, widthOf, minWidthOf, onCommit]
|
|
2375
3789
|
);
|
|
2376
|
-
const autoFit =
|
|
3790
|
+
const autoFit = React48.useCallback(
|
|
2377
3791
|
(id) => {
|
|
2378
3792
|
const root = rootRef.current;
|
|
2379
3793
|
if (!root) return;
|
|
@@ -2390,7 +3804,7 @@ function useColumnResize(options) {
|
|
|
2390
3804
|
},
|
|
2391
3805
|
[rootRef, minWidthOf, onCommit]
|
|
2392
3806
|
);
|
|
2393
|
-
const onKeyDown =
|
|
3807
|
+
const onKeyDown = React48.useCallback(
|
|
2394
3808
|
(event, id) => {
|
|
2395
3809
|
const step = event.shiftKey ? 32 : 8;
|
|
2396
3810
|
if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
|
|
@@ -2433,7 +3847,7 @@ function useColumnLayout({
|
|
|
2433
3847
|
layout: controlled,
|
|
2434
3848
|
onLayoutChange
|
|
2435
3849
|
}) {
|
|
2436
|
-
const baseline =
|
|
3850
|
+
const baseline = React48.useMemo(
|
|
2437
3851
|
() => ({
|
|
2438
3852
|
order: columns.map((c) => c.id),
|
|
2439
3853
|
hidden: [],
|
|
@@ -2445,27 +3859,27 @@ function useColumnLayout({
|
|
|
2445
3859
|
}),
|
|
2446
3860
|
[columns]
|
|
2447
3861
|
);
|
|
2448
|
-
const [internal, setInternal] =
|
|
2449
|
-
|
|
3862
|
+
const [internal, setInternal] = React48.useState(baseline);
|
|
3863
|
+
React48.useEffect(() => {
|
|
2450
3864
|
const stored = readStored3(persistKey);
|
|
2451
3865
|
if (stored) setInternal((current) => merge(current, stored, baseline));
|
|
2452
3866
|
}, [persistKey]);
|
|
2453
|
-
|
|
3867
|
+
React48.useEffect(() => {
|
|
2454
3868
|
setInternal((current) => merge(baseline, current, baseline));
|
|
2455
3869
|
}, [baseline]);
|
|
2456
|
-
const layout =
|
|
3870
|
+
const layout = React48.useMemo(
|
|
2457
3871
|
() => controlled ? merge(baseline, controlled, baseline) : internal,
|
|
2458
3872
|
[controlled, internal, baseline]
|
|
2459
3873
|
);
|
|
2460
|
-
const onLayoutChangeRef =
|
|
2461
|
-
|
|
3874
|
+
const onLayoutChangeRef = React48.useRef(onLayoutChange);
|
|
3875
|
+
React48.useEffect(() => {
|
|
2462
3876
|
onLayoutChangeRef.current = onLayoutChange;
|
|
2463
3877
|
});
|
|
2464
|
-
const internalRef =
|
|
2465
|
-
|
|
3878
|
+
const internalRef = React48.useRef(internal);
|
|
3879
|
+
React48.useEffect(() => {
|
|
2466
3880
|
internalRef.current = internal;
|
|
2467
3881
|
}, [internal]);
|
|
2468
|
-
const update =
|
|
3882
|
+
const update = React48.useCallback(
|
|
2469
3883
|
(patch, options) => {
|
|
2470
3884
|
const base = controlled ? merge(baseline, controlled, baseline) : internalRef.current;
|
|
2471
3885
|
const next = patch(base);
|
|
@@ -2479,11 +3893,11 @@ function useColumnLayout({
|
|
|
2479
3893
|
},
|
|
2480
3894
|
[controlled, baseline, persistKey]
|
|
2481
3895
|
);
|
|
2482
|
-
const byId =
|
|
3896
|
+
const byId = React48.useMemo(
|
|
2483
3897
|
() => new Map(columns.map((c) => [c.id, c])),
|
|
2484
3898
|
[columns]
|
|
2485
3899
|
);
|
|
2486
|
-
const visible =
|
|
3900
|
+
const visible = React48.useMemo(() => {
|
|
2487
3901
|
const ordered = layout.order.map((id) => byId.get(id)).filter((c) => Boolean(c) && !layout.hidden.includes(c.id));
|
|
2488
3902
|
const side = (id) => layout.pinned[id];
|
|
2489
3903
|
return [
|
|
@@ -2492,15 +3906,15 @@ function useColumnLayout({
|
|
|
2492
3906
|
...ordered.filter((c) => side(c.id) === "right")
|
|
2493
3907
|
];
|
|
2494
3908
|
}, [layout, byId]);
|
|
2495
|
-
const widthOf =
|
|
3909
|
+
const widthOf = React48.useCallback(
|
|
2496
3910
|
(id) => layout.widths[id] ?? byId.get(id)?.width ?? DEFAULT_WIDTH,
|
|
2497
3911
|
[layout.widths, byId]
|
|
2498
3912
|
);
|
|
2499
|
-
const minWidthOf =
|
|
3913
|
+
const minWidthOf = React48.useCallback(
|
|
2500
3914
|
(id) => byId.get(id)?.minWidth ?? DEFAULT_MIN,
|
|
2501
3915
|
[byId]
|
|
2502
3916
|
);
|
|
2503
|
-
const fitTo =
|
|
3917
|
+
const fitTo = React48.useCallback(
|
|
2504
3918
|
(available) => update(
|
|
2505
3919
|
(current) => {
|
|
2506
3920
|
const shown = current.order.map((id) => byId.get(id)).filter((c) => Boolean(c) && !current.hidden.includes(c.id));
|
|
@@ -2613,8 +4027,8 @@ function merge(base, patch, fallback) {
|
|
|
2613
4027
|
}
|
|
2614
4028
|
function useRowSelection(options) {
|
|
2615
4029
|
const { value, onChange, pageKeys } = options;
|
|
2616
|
-
const anchor =
|
|
2617
|
-
const selected =
|
|
4030
|
+
const anchor = React48.useRef(null);
|
|
4031
|
+
const selected = React48.useMemo(() => new Set(value.keys), [value.keys]);
|
|
2618
4032
|
const setKeys = (keys, allMatching = false) => onChange({ keys, allMatching });
|
|
2619
4033
|
const toggle = (key, event) => {
|
|
2620
4034
|
if (event?.shiftKey && anchor.current) {
|
|
@@ -2699,11 +4113,11 @@ function DataTable({
|
|
|
2699
4113
|
className
|
|
2700
4114
|
}) {
|
|
2701
4115
|
const labels = resolveLabels(labelsProp);
|
|
2702
|
-
const rootRef =
|
|
2703
|
-
const scrollerRef =
|
|
2704
|
-
const [scrolled, setScrolled] =
|
|
2705
|
-
const [expanded, setExpanded] =
|
|
2706
|
-
const [editing, setEditing] =
|
|
4116
|
+
const rootRef = React48.useRef(null);
|
|
4117
|
+
const scrollerRef = React48.useRef(null);
|
|
4118
|
+
const [scrolled, setScrolled] = React48.useState({ left: false, right: false });
|
|
4119
|
+
const [expanded, setExpanded] = React48.useState(/* @__PURE__ */ new Set());
|
|
4120
|
+
const [editing, setEditing] = React48.useState(null);
|
|
2707
4121
|
const {
|
|
2708
4122
|
layout,
|
|
2709
4123
|
visible,
|
|
@@ -2718,17 +4132,17 @@ function DataTable({
|
|
|
2718
4132
|
} = useColumnLayout({ columns, persistKey, layout: controlledLayout, onLayoutChange });
|
|
2719
4133
|
const resize = useColumnResize({ rootRef, widthOf, minWidthOf, onCommit: setWidth });
|
|
2720
4134
|
const selectable = Boolean(selection && onSelectionChange);
|
|
2721
|
-
const pageKeys =
|
|
4135
|
+
const pageKeys = React48.useMemo(() => data.map(rowKey), [data, rowKey]);
|
|
2722
4136
|
const rows = useRowSelection({
|
|
2723
4137
|
value: selection ?? { keys: [], allMatching: false },
|
|
2724
4138
|
onChange: onSelectionChange ?? (() => {
|
|
2725
4139
|
}),
|
|
2726
4140
|
pageKeys
|
|
2727
4141
|
});
|
|
2728
|
-
const recentFits =
|
|
4142
|
+
const recentFits = React48.useRef([]);
|
|
2729
4143
|
const hiddenKey = layout.hidden.join("\0");
|
|
2730
4144
|
const orderKey = layout.order.join("\0");
|
|
2731
|
-
|
|
4145
|
+
React48.useEffect(() => {
|
|
2732
4146
|
const scroller = scrollerRef.current;
|
|
2733
4147
|
if (!scroller || !autoFit) return;
|
|
2734
4148
|
const controls = (selectable ? SELECT_WIDTH : 0) + (renderExpanded ? EXPAND_WIDTH : 0);
|
|
@@ -2747,7 +4161,7 @@ function DataTable({
|
|
|
2747
4161
|
observer.observe(scroller);
|
|
2748
4162
|
return () => observer.disconnect();
|
|
2749
4163
|
}, [autoFit, fitTo, selectable, renderExpanded, hiddenKey, orderKey]);
|
|
2750
|
-
|
|
4164
|
+
React48.useEffect(() => {
|
|
2751
4165
|
const scroller = scrollerRef.current;
|
|
2752
4166
|
if (!scroller) return;
|
|
2753
4167
|
const update = () => {
|
|
@@ -2767,12 +4181,12 @@ function DataTable({
|
|
|
2767
4181
|
observer.disconnect();
|
|
2768
4182
|
};
|
|
2769
4183
|
}, [visible.length, data.length]);
|
|
2770
|
-
const moreRef =
|
|
2771
|
-
const onLoadMoreRef =
|
|
2772
|
-
|
|
4184
|
+
const moreRef = React48.useRef(null);
|
|
4185
|
+
const onLoadMoreRef = React48.useRef(onLoadMore);
|
|
4186
|
+
React48.useEffect(() => {
|
|
2773
4187
|
onLoadMoreRef.current = onLoadMore;
|
|
2774
4188
|
});
|
|
2775
|
-
const askedAt =
|
|
4189
|
+
const askedAt = React48.useRef(-1);
|
|
2776
4190
|
const canLoadMore = Boolean(onLoadMore) && (hasMore ?? (total === void 0 || data.length < total));
|
|
2777
4191
|
const showLoadMore = canLoadMore && !error && data.length > 0;
|
|
2778
4192
|
const showPager = pagination ?? !onLoadMore;
|
|
@@ -2781,7 +4195,7 @@ function DataTable({
|
|
|
2781
4195
|
askedAt.current = data.length;
|
|
2782
4196
|
onLoadMoreRef.current?.();
|
|
2783
4197
|
};
|
|
2784
|
-
|
|
4198
|
+
React48.useEffect(() => {
|
|
2785
4199
|
const sentinel = moreRef.current;
|
|
2786
4200
|
const scroller = scrollerRef.current;
|
|
2787
4201
|
if (!sentinel || !scroller || !showLoadMore || !autoLoadMore || loading) return;
|
|
@@ -2795,7 +4209,7 @@ function DataTable({
|
|
|
2795
4209
|
observer.observe(sentinel);
|
|
2796
4210
|
return () => observer.disconnect();
|
|
2797
4211
|
}, [showLoadMore, autoLoadMore, loading, data.length]);
|
|
2798
|
-
const offsets =
|
|
4212
|
+
const offsets = React48.useMemo(() => {
|
|
2799
4213
|
const result = /* @__PURE__ */ new Map();
|
|
2800
4214
|
let leftParts = selectable ? [`${SELECT_WIDTH}px`] : [];
|
|
2801
4215
|
if (renderExpanded) leftParts = [...leftParts, `${EXPAND_WIDTH}px`];
|
|
@@ -2812,7 +4226,7 @@ function DataTable({
|
|
|
2812
4226
|
}
|
|
2813
4227
|
return result;
|
|
2814
4228
|
}, [visible, layout.pinned, widthOf, selectable, renderExpanded]);
|
|
2815
|
-
const widthVars =
|
|
4229
|
+
const widthVars = React48.useMemo(() => {
|
|
2816
4230
|
const style = {};
|
|
2817
4231
|
for (const column of visible) {
|
|
2818
4232
|
style[`--mz-dt-w-${cssSafe(column.id)}`] = `${widthOf(column.id)}px`;
|
|
@@ -2826,7 +4240,7 @@ function DataTable({
|
|
|
2826
4240
|
const pinEdgeOf = (id) => id === lastLeftPinned ? "left" : id === firstRightPinned ? "right" : void 0;
|
|
2827
4241
|
const controlPinEdge = leftPinned.length === 0 ? "left" : void 0;
|
|
2828
4242
|
const chips = activeFilters(query.filters);
|
|
2829
|
-
const columnById =
|
|
4243
|
+
const columnById = React48.useMemo(() => new Map(columns.map((c) => [c.id, c])), [columns]);
|
|
2830
4244
|
const labelOf = (id) => {
|
|
2831
4245
|
const column = columnById.get(id);
|
|
2832
4246
|
return column?.label ?? (typeof column?.header === "string" ? column.header : id);
|
|
@@ -3053,7 +4467,7 @@ function DataTable({
|
|
|
3053
4467
|
const context = { rowIndex };
|
|
3054
4468
|
const hostClass = rowClassName?.(row, context);
|
|
3055
4469
|
const hostProps = rowProps?.(row, context);
|
|
3056
|
-
return /* @__PURE__ */ jsxs(
|
|
4470
|
+
return /* @__PURE__ */ jsxs(React48.Fragment, { children: [
|
|
3057
4471
|
/* @__PURE__ */ jsxs(
|
|
3058
4472
|
"tr",
|
|
3059
4473
|
{
|
|
@@ -3242,13 +4656,13 @@ function useTableQuery({
|
|
|
3242
4656
|
urlKey = null,
|
|
3243
4657
|
history = "replace"
|
|
3244
4658
|
} = {}) {
|
|
3245
|
-
const base =
|
|
3246
|
-
const [query, setQuery] =
|
|
3247
|
-
|
|
4659
|
+
const base = React48.useMemo(() => ({ ...emptyQuery, ...initial }), [initial]);
|
|
4660
|
+
const [query, setQuery] = React48.useState(base);
|
|
4661
|
+
React48.useEffect(() => {
|
|
3248
4662
|
if (urlKey === null || typeof window === "undefined") return;
|
|
3249
4663
|
setQuery(decode(urlKey, base));
|
|
3250
4664
|
}, [urlKey]);
|
|
3251
|
-
|
|
4665
|
+
React48.useEffect(() => {
|
|
3252
4666
|
if (urlKey === null || typeof window === "undefined") return;
|
|
3253
4667
|
const params = encode(query, urlKey);
|
|
3254
4668
|
const search = params.toString();
|
|
@@ -3256,13 +4670,13 @@ function useTableQuery({
|
|
|
3256
4670
|
if (next === `${window.location.pathname}${window.location.search}${window.location.hash}`) return;
|
|
3257
4671
|
window.history[history === "push" ? "pushState" : "replaceState"](null, "", next);
|
|
3258
4672
|
}, [query, urlKey, history]);
|
|
3259
|
-
|
|
4673
|
+
React48.useEffect(() => {
|
|
3260
4674
|
if (urlKey === null || typeof window === "undefined") return;
|
|
3261
4675
|
const onPop = () => setQuery(decode(urlKey, base));
|
|
3262
4676
|
window.addEventListener("popstate", onPop);
|
|
3263
4677
|
return () => window.removeEventListener("popstate", onPop);
|
|
3264
4678
|
}, [urlKey, base]);
|
|
3265
|
-
const reset =
|
|
4679
|
+
const reset = React48.useCallback(() => setQuery(base), [base]);
|
|
3266
4680
|
return { query, setQuery, reset };
|
|
3267
4681
|
}
|
|
3268
4682
|
function useSavedViews({
|
|
@@ -3270,8 +4684,8 @@ function useSavedViews({
|
|
|
3270
4684
|
views: controlled,
|
|
3271
4685
|
onViewsChange
|
|
3272
4686
|
} = {}) {
|
|
3273
|
-
const [internal, setInternal] =
|
|
3274
|
-
|
|
4687
|
+
const [internal, setInternal] = React48.useState([]);
|
|
4688
|
+
React48.useEffect(() => {
|
|
3275
4689
|
if (!storageKey || typeof window === "undefined") return;
|
|
3276
4690
|
try {
|
|
3277
4691
|
const raw = window.localStorage.getItem(storageKey);
|
|
@@ -3280,7 +4694,7 @@ function useSavedViews({
|
|
|
3280
4694
|
}
|
|
3281
4695
|
}, [storageKey]);
|
|
3282
4696
|
const views = controlled ?? internal;
|
|
3283
|
-
const persist =
|
|
4697
|
+
const persist = React48.useCallback(
|
|
3284
4698
|
(next) => {
|
|
3285
4699
|
setInternal(next);
|
|
3286
4700
|
onViewsChange?.(next);
|
|
@@ -3299,6 +4713,6 @@ function useSavedViews({
|
|
|
3299
4713
|
};
|
|
3300
4714
|
}
|
|
3301
4715
|
|
|
3302
|
-
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertTitle, Avatar, AvatarFallback, AvatarGroup, 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 };
|
|
4716
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, Avatar, AvatarFallback, AvatarGroup, AvatarImage, Badge, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Calendar, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, ChartContainer, ChartLegendContent, ChartStyle, ChartTooltipContent, 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, Menubar, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, MenubarPortal, MenubarRadioGroup, MenubarRadioItem, MenubarSeparator, MenubarShortcut, MenubarSub, MenubarSubContent, MenubarSubTrigger, MenubarTrigger, MorzeThemeProvider, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, Popover, PopoverAnchor, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger, Progress, RadioGroup, RadioGroupItem, ScrollArea, ScrollBar, 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, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toast, ToastAction, ToastClose, ToastDescription, ToastProvider, ToastTitle, ToastViewport, Toaster, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, activeFilters, badgeVariants, buttonVariants, cn, defaultDataTableLabels, dismiss, emptyQuery, isFilterActive, navigationMenuTriggerStyle, pageCount, parseSort, resolveLabels, serializeSort, setFilter, sortStateOf, toast, toggleSort, toggleVariants, useChart, useColumnLayout, useIsMobile, useMorzeTheme, useRowSelection, useSavedViews, useSidebar, useTableQuery, useToast };
|
|
3303
4717
|
//# sourceMappingURL=index.js.map
|
|
3304
4718
|
//# sourceMappingURL=index.js.map
|