@classic-homes/theme-react 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +419 -1
- package/dist/index.d.ts +419 -1
- package/dist/index.js +1801 -279
- package/dist/index.mjs +1815 -307
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -674,12 +674,1499 @@ var PageHeader = React12.forwardRef(
|
|
|
674
674
|
);
|
|
675
675
|
PageHeader.displayName = "PageHeader";
|
|
676
676
|
|
|
677
|
-
// src/components/
|
|
677
|
+
// src/components/Sheet.tsx
|
|
678
|
+
import * as DialogPrimitive2 from "@radix-ui/react-dialog";
|
|
679
|
+
import { cva as cva5 } from "class-variance-authority";
|
|
680
|
+
|
|
681
|
+
// src/components/studio/icons.tsx
|
|
682
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
683
|
+
var PATHS = {
|
|
684
|
+
close: "M18 6 6 18M6 6l12 12",
|
|
685
|
+
plus: "M12 5v14M5 12h14",
|
|
686
|
+
"arrow-left": "M19 12H5M12 19l-7-7 7-7",
|
|
687
|
+
"arrow-up": "M12 19V5M5 12l7-7 7 7",
|
|
688
|
+
"arrow-down": "M12 5v14M19 12l-7 7-7-7",
|
|
689
|
+
"chevron-down": "m6 9 6 6 6-6",
|
|
690
|
+
"chevron-right": "m9 18 6-6-6-6",
|
|
691
|
+
"alert-triangle": "M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0zM12 9v4M12 17h.01",
|
|
692
|
+
"alert-circle": "M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20zM12 8v4M12 16h.01",
|
|
693
|
+
info: "M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20zM12 16v-4M12 8h.01",
|
|
694
|
+
"check-circle": "M22 11.08V12a10 10 0 1 1-5.93-9.14M22 4 12 14.01l-3-3",
|
|
695
|
+
loader: "M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83",
|
|
696
|
+
edit: "M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z",
|
|
697
|
+
"wifi-off": "M2 2l20 20M8.5 16.5a5 5 0 0 1 7 0M2 8.82a15 15 0 0 1 4.17-2.65M10.66 5c4.01-.36 8.14.9 11.34 3.76M16.85 11.25a10 10 0 0 1 2.22 1.68M5 13a10 10 0 0 1 5.24-2.76M12 20h.01",
|
|
698
|
+
eye: "M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7ZM12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z",
|
|
699
|
+
refresh: "M3 12a9 9 0 0 1 15-6.7L21 8M21 3v5h-5M21 12a9 9 0 0 1-15 6.7L3 16M3 21v-5h5",
|
|
700
|
+
list: "M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01",
|
|
701
|
+
settings: "M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z",
|
|
702
|
+
search: "M11 19a8 8 0 1 0 0-16 8 8 0 0 0 0 16zM21 21l-4.35-4.35",
|
|
703
|
+
monitor: "M4 3h16a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2zM8 21h8M12 17v4",
|
|
704
|
+
smartphone: "M7 2h10a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2zM12 18h.01"
|
|
705
|
+
};
|
|
706
|
+
var DOTS = {
|
|
707
|
+
grip: [
|
|
708
|
+
[9, 5],
|
|
709
|
+
[15, 5],
|
|
710
|
+
[9, 12],
|
|
711
|
+
[15, 12],
|
|
712
|
+
[9, 19],
|
|
713
|
+
[15, 19]
|
|
714
|
+
],
|
|
715
|
+
"more-horizontal": [
|
|
716
|
+
[5, 12],
|
|
717
|
+
[12, 12],
|
|
718
|
+
[19, 12]
|
|
719
|
+
]
|
|
720
|
+
};
|
|
721
|
+
function StudioIcon({
|
|
722
|
+
name,
|
|
723
|
+
size = 16,
|
|
724
|
+
className
|
|
725
|
+
}) {
|
|
726
|
+
const dots = name === "grip" || name === "more-horizontal" ? DOTS[name] : null;
|
|
727
|
+
return /* @__PURE__ */ jsx12(
|
|
728
|
+
"svg",
|
|
729
|
+
{
|
|
730
|
+
width: size,
|
|
731
|
+
height: size,
|
|
732
|
+
viewBox: "0 0 24 24",
|
|
733
|
+
fill: dots ? "currentColor" : "none",
|
|
734
|
+
stroke: dots ? "none" : "currentColor",
|
|
735
|
+
strokeWidth: 2,
|
|
736
|
+
strokeLinecap: "round",
|
|
737
|
+
strokeLinejoin: "round",
|
|
738
|
+
"aria-hidden": "true",
|
|
739
|
+
className: cn("shrink-0", className),
|
|
740
|
+
children: dots ? dots.map(([cx, cy]) => /* @__PURE__ */ jsx12("circle", { cx, cy, r: 1.6 }, `${cx}-${cy}`)) : /* @__PURE__ */ jsx12("path", { d: PATHS[name] })
|
|
741
|
+
}
|
|
742
|
+
);
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
// src/components/Sheet.tsx
|
|
746
|
+
import { Fragment, jsx as jsx13, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
747
|
+
var sheetVariants = cva5(
|
|
748
|
+
"fixed z-50 flex flex-col border-border bg-background shadow-lg outline-none duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out",
|
|
749
|
+
{
|
|
750
|
+
variants: {
|
|
751
|
+
side: {
|
|
752
|
+
right: "inset-y-0 right-0 h-dvh w-full border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right",
|
|
753
|
+
left: "inset-y-0 left-0 h-dvh w-full border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left",
|
|
754
|
+
bottom: "inset-x-0 bottom-0 max-h-[85dvh] w-full rounded-t-xl border-t pb-[env(safe-area-inset-bottom)] data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom"
|
|
755
|
+
},
|
|
756
|
+
size: { sm: "", md: "", lg: "" }
|
|
757
|
+
},
|
|
758
|
+
compoundVariants: [
|
|
759
|
+
{ side: ["left", "right"], size: "sm", className: "sm:max-w-xs" },
|
|
760
|
+
{ side: ["left", "right"], size: "md", className: "sm:max-w-md" },
|
|
761
|
+
{ side: ["left", "right"], size: "lg", className: "sm:max-w-xl" }
|
|
762
|
+
],
|
|
763
|
+
defaultVariants: { side: "right", size: "md" }
|
|
764
|
+
}
|
|
765
|
+
);
|
|
766
|
+
var closeClass = "flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground hover:bg-muted-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring";
|
|
767
|
+
function Sheet({
|
|
768
|
+
open,
|
|
769
|
+
onOpenChange,
|
|
770
|
+
side = "right",
|
|
771
|
+
size = "md",
|
|
772
|
+
title,
|
|
773
|
+
hideTitle = false,
|
|
774
|
+
description,
|
|
775
|
+
headerActions,
|
|
776
|
+
footer,
|
|
777
|
+
children,
|
|
778
|
+
className
|
|
779
|
+
}) {
|
|
780
|
+
const close = /* @__PURE__ */ jsx13(DialogPrimitive2.Close, { className: closeClass, "aria-label": "Close", children: /* @__PURE__ */ jsx13(StudioIcon, { name: "close", size: 18 }) });
|
|
781
|
+
return /* @__PURE__ */ jsx13(DialogPrimitive2.Root, { open, onOpenChange, children: /* @__PURE__ */ jsxs5(DialogPrimitive2.Portal, { children: [
|
|
782
|
+
/* @__PURE__ */ jsx13(DialogPrimitive2.Overlay, { className: "fixed inset-0 z-50 bg-foreground/60 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0" }),
|
|
783
|
+
/* @__PURE__ */ jsxs5(
|
|
784
|
+
DialogPrimitive2.Content,
|
|
785
|
+
{
|
|
786
|
+
className: cn(sheetVariants({ side, size }), className),
|
|
787
|
+
...description ? {} : { "aria-describedby": void 0 },
|
|
788
|
+
children: [
|
|
789
|
+
side === "bottom" && /* @__PURE__ */ jsxs5("div", { className: "relative flex h-6 shrink-0 items-center justify-center", children: [
|
|
790
|
+
/* @__PURE__ */ jsx13("div", { className: "h-1.5 w-10 rounded-full bg-muted", "aria-hidden": "true" }),
|
|
791
|
+
hideTitle && /* @__PURE__ */ jsx13("div", { className: "absolute right-2 top-1", children: close })
|
|
792
|
+
] }),
|
|
793
|
+
hideTitle ? /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
794
|
+
/* @__PURE__ */ jsx13(DialogPrimitive2.Title, { className: "sr-only", children: title }),
|
|
795
|
+
description && /* @__PURE__ */ jsx13(DialogPrimitive2.Description, { className: "sr-only", children: description }),
|
|
796
|
+
side !== "bottom" && /* @__PURE__ */ jsx13("div", { className: "absolute right-2 top-2 z-10", children: close })
|
|
797
|
+
] }) : /* @__PURE__ */ jsxs5("div", { className: "flex shrink-0 items-start gap-3 border-b border-border px-4 py-3", children: [
|
|
798
|
+
/* @__PURE__ */ jsxs5("div", { className: "min-w-0 flex-1", children: [
|
|
799
|
+
/* @__PURE__ */ jsx13(DialogPrimitive2.Title, { className: "text-base font-semibold leading-tight", children: title }),
|
|
800
|
+
description && /* @__PURE__ */ jsx13(DialogPrimitive2.Description, { className: "mt-1 text-sm text-muted-foreground", children: description })
|
|
801
|
+
] }),
|
|
802
|
+
/* @__PURE__ */ jsxs5("div", { className: "-mr-1 ml-auto flex shrink-0 items-center gap-1", children: [
|
|
803
|
+
headerActions,
|
|
804
|
+
close
|
|
805
|
+
] })
|
|
806
|
+
] }),
|
|
807
|
+
/* @__PURE__ */ jsx13("div", { className: "min-h-0 flex-1 overflow-y-auto overscroll-contain", children }),
|
|
808
|
+
footer && /* @__PURE__ */ jsx13("div", { className: "flex shrink-0 items-center justify-end gap-2 border-t border-border px-4 py-3", children: footer })
|
|
809
|
+
]
|
|
810
|
+
}
|
|
811
|
+
)
|
|
812
|
+
] }) });
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
// src/components/SortableList.tsx
|
|
816
|
+
import * as React13 from "react";
|
|
817
|
+
import { Fragment as Fragment2, jsx as jsx14, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
818
|
+
function SortableList({
|
|
819
|
+
items,
|
|
820
|
+
getKey,
|
|
821
|
+
onReorder,
|
|
822
|
+
renderItem,
|
|
823
|
+
label,
|
|
824
|
+
getItemLabel = (_item, index) => `Item ${index + 1}`,
|
|
825
|
+
disabled = false,
|
|
826
|
+
className,
|
|
827
|
+
itemClassName
|
|
828
|
+
}) {
|
|
829
|
+
const instructionsId = `${React13.useId()}-sortable-help`;
|
|
830
|
+
const listRef = React13.useRef(null);
|
|
831
|
+
const [announcement, setAnnouncement] = React13.useState("");
|
|
832
|
+
const [drag, setDrag] = React13.useState(
|
|
833
|
+
null
|
|
834
|
+
);
|
|
835
|
+
const rects = React13.useRef([]);
|
|
836
|
+
const startY = React13.useRef(0);
|
|
837
|
+
const [grabbed, setGrabbed] = React13.useState(null);
|
|
838
|
+
const grabbedFrom = React13.useRef(0);
|
|
839
|
+
const moving = React13.useRef(false);
|
|
840
|
+
const pendingFocus = React13.useRef(null);
|
|
841
|
+
React13.useLayoutEffect(() => {
|
|
842
|
+
if (pendingFocus.current === null) return;
|
|
843
|
+
const handles = listRef.current?.querySelectorAll(
|
|
844
|
+
":scope > li [data-sortable-handle]"
|
|
845
|
+
);
|
|
846
|
+
handles?.[pendingFocus.current]?.focus();
|
|
847
|
+
pendingFocus.current = null;
|
|
848
|
+
moving.current = false;
|
|
849
|
+
});
|
|
850
|
+
const announce = (message) => {
|
|
851
|
+
setAnnouncement("");
|
|
852
|
+
queueMicrotask(() => setAnnouncement(message));
|
|
853
|
+
};
|
|
854
|
+
const positionText = (index) => `position ${index + 1} of ${items.length}`;
|
|
855
|
+
const move = (from, to, keepFocus = true) => {
|
|
856
|
+
if (to < 0 || to >= items.length || from === to) return;
|
|
857
|
+
const name = getItemLabel(items[from], from);
|
|
858
|
+
moving.current = keepFocus;
|
|
859
|
+
if (keepFocus) pendingFocus.current = to;
|
|
860
|
+
onReorder(from, to);
|
|
861
|
+
setGrabbed((g) => g === from ? to : g);
|
|
862
|
+
announce(`${name} moved to ${positionText(to)}.`);
|
|
863
|
+
};
|
|
864
|
+
const shiftFor = (index) => {
|
|
865
|
+
if (!drag) return 0;
|
|
866
|
+
const { from, over, offset } = drag;
|
|
867
|
+
if (index === from) return offset;
|
|
868
|
+
const r = rects.current;
|
|
869
|
+
const height = r[from]?.height ?? 0;
|
|
870
|
+
const gap = r.length > 1 ? Math.max(0, r[1].top - r[0].bottom) : 0;
|
|
871
|
+
if (from < over && index > from && index <= over) return -(height + gap);
|
|
872
|
+
if (from > over && index >= over && index < from) return height + gap;
|
|
873
|
+
return 0;
|
|
874
|
+
};
|
|
875
|
+
const endDrag = (commit) => {
|
|
876
|
+
const current = drag;
|
|
877
|
+
setDrag(null);
|
|
878
|
+
rects.current = [];
|
|
879
|
+
if (commit && current && current.from !== current.over) move(current.from, current.over, false);
|
|
880
|
+
};
|
|
881
|
+
const handleProps = (index, key, name) => ({
|
|
882
|
+
type: "button",
|
|
883
|
+
"aria-label": `Reorder ${name}`,
|
|
884
|
+
"aria-roledescription": "sortable handle",
|
|
885
|
+
"aria-describedby": instructionsId,
|
|
886
|
+
"aria-pressed": grabbed === index,
|
|
887
|
+
"data-sortable-handle": String(key),
|
|
888
|
+
onPointerDown(event) {
|
|
889
|
+
if (disabled || event.button !== 0 || !listRef.current) return;
|
|
890
|
+
event.preventDefault();
|
|
891
|
+
event.currentTarget.setPointerCapture?.(event.pointerId);
|
|
892
|
+
rects.current = Array.from(listRef.current.children, (c) => c.getBoundingClientRect());
|
|
893
|
+
startY.current = event.clientY;
|
|
894
|
+
setDrag({ from: index, over: index, offset: 0 });
|
|
895
|
+
},
|
|
896
|
+
onPointerMove(event) {
|
|
897
|
+
if (!drag) return;
|
|
898
|
+
const offset = event.clientY - startY.current;
|
|
899
|
+
const origin = rects.current[drag.from];
|
|
900
|
+
const center = origin.top + origin.height / 2 + offset;
|
|
901
|
+
const over = rects.current.filter(
|
|
902
|
+
(r, i) => i !== drag.from && r.top + r.height / 2 < center
|
|
903
|
+
).length;
|
|
904
|
+
setDrag({ ...drag, over, offset });
|
|
905
|
+
},
|
|
906
|
+
onPointerUp() {
|
|
907
|
+
endDrag(true);
|
|
908
|
+
},
|
|
909
|
+
onPointerCancel() {
|
|
910
|
+
endDrag(false);
|
|
911
|
+
},
|
|
912
|
+
onKeyDown(event) {
|
|
913
|
+
if (disabled) return;
|
|
914
|
+
const picked = grabbed === index;
|
|
915
|
+
if (event.key === " " || event.key === "Enter") {
|
|
916
|
+
event.preventDefault();
|
|
917
|
+
if (picked) {
|
|
918
|
+
setGrabbed(null);
|
|
919
|
+
announce(`${name} dropped at ${positionText(index)}.`);
|
|
920
|
+
} else {
|
|
921
|
+
setGrabbed(index);
|
|
922
|
+
grabbedFrom.current = index;
|
|
923
|
+
announce(`${name} picked up at ${positionText(index)}. Use the arrow keys to move it.`);
|
|
924
|
+
}
|
|
925
|
+
} else if (event.key === "Escape" && picked) {
|
|
926
|
+
event.preventDefault();
|
|
927
|
+
event.stopPropagation();
|
|
928
|
+
setGrabbed(null);
|
|
929
|
+
if (index !== grabbedFrom.current) {
|
|
930
|
+
moving.current = true;
|
|
931
|
+
pendingFocus.current = grabbedFrom.current;
|
|
932
|
+
onReorder(index, grabbedFrom.current);
|
|
933
|
+
}
|
|
934
|
+
announce(`Reorder cancelled. ${name} is back at ${positionText(grabbedFrom.current)}.`);
|
|
935
|
+
} else if ((picked || event.altKey) && (event.key === "ArrowUp" || event.key === "ArrowDown")) {
|
|
936
|
+
event.preventDefault();
|
|
937
|
+
move(index, event.key === "ArrowUp" ? index - 1 : index + 1);
|
|
938
|
+
} else if (picked && (event.key === "Home" || event.key === "End")) {
|
|
939
|
+
event.preventDefault();
|
|
940
|
+
move(index, event.key === "Home" ? 0 : items.length - 1);
|
|
941
|
+
}
|
|
942
|
+
},
|
|
943
|
+
onBlur() {
|
|
944
|
+
if (!moving.current && grabbed === index) setGrabbed(null);
|
|
945
|
+
}
|
|
946
|
+
});
|
|
947
|
+
return /* @__PURE__ */ jsxs6(Fragment2, { children: [
|
|
948
|
+
/* @__PURE__ */ jsx14("ul", { ref: listRef, "aria-label": label, className: cn("relative", className), children: items.map((item, index) => {
|
|
949
|
+
const key = getKey(item, index);
|
|
950
|
+
const dragging = drag?.from === index || grabbed === index;
|
|
951
|
+
const shift = shiftFor(index);
|
|
952
|
+
return /* @__PURE__ */ jsx14(
|
|
953
|
+
"li",
|
|
954
|
+
{
|
|
955
|
+
className: cn(
|
|
956
|
+
"relative",
|
|
957
|
+
drag && drag.from !== index && "transition-transform duration-150",
|
|
958
|
+
drag?.from === index && "z-10 opacity-90 shadow-lg",
|
|
959
|
+
itemClassName
|
|
960
|
+
),
|
|
961
|
+
style: shift ? { transform: `translateY(${shift}px)` } : void 0,
|
|
962
|
+
"data-dragging": dragging || void 0,
|
|
963
|
+
children: renderItem({
|
|
964
|
+
item,
|
|
965
|
+
index,
|
|
966
|
+
handle: handleProps(index, key, getItemLabel(item, index)),
|
|
967
|
+
dragging
|
|
968
|
+
})
|
|
969
|
+
},
|
|
970
|
+
key
|
|
971
|
+
);
|
|
972
|
+
}) }),
|
|
973
|
+
/* @__PURE__ */ jsx14("p", { id: instructionsId, className: "sr-only", children: "Press Space or Enter to pick up, use the arrow keys to move, Space or Enter to drop, Escape to cancel." }),
|
|
974
|
+
/* @__PURE__ */ jsx14("div", { className: "sr-only", role: "status", "aria-live": "assertive", "aria-atomic": "true", children: announcement })
|
|
975
|
+
] });
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
// src/components/studio/Studio.tsx
|
|
979
|
+
import * as React15 from "react";
|
|
980
|
+
|
|
981
|
+
// src/components/studio/context.ts
|
|
678
982
|
import * as React14 from "react";
|
|
983
|
+
var StudioContext = React14.createContext(void 0);
|
|
984
|
+
function useStudio() {
|
|
985
|
+
return React14.useContext(StudioContext);
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
// src/components/studio/Studio.tsx
|
|
989
|
+
import { jsx as jsx15, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
990
|
+
function useLayout() {
|
|
991
|
+
const [layout, setLayout] = React15.useState("wide");
|
|
992
|
+
React15.useEffect(() => {
|
|
993
|
+
const wide = window.matchMedia("(min-width: 1280px)");
|
|
994
|
+
const medium = window.matchMedia("(min-width: 768px)");
|
|
995
|
+
const update = () => setLayout(wide.matches ? "wide" : medium.matches ? "medium" : "compact");
|
|
996
|
+
update();
|
|
997
|
+
wide.addEventListener("change", update);
|
|
998
|
+
medium.addEventListener("change", update);
|
|
999
|
+
return () => {
|
|
1000
|
+
wide.removeEventListener("change", update);
|
|
1001
|
+
medium.removeEventListener("change", update);
|
|
1002
|
+
};
|
|
1003
|
+
}, []);
|
|
1004
|
+
return layout;
|
|
1005
|
+
}
|
|
1006
|
+
function useControllable(value, onChange) {
|
|
1007
|
+
const [inner, setInner] = React15.useState(false);
|
|
1008
|
+
const current = value ?? inner;
|
|
1009
|
+
const set = React15.useCallback(
|
|
1010
|
+
(next) => {
|
|
1011
|
+
if (value === void 0) setInner(next);
|
|
1012
|
+
onChange?.(next);
|
|
1013
|
+
},
|
|
1014
|
+
[value, onChange]
|
|
1015
|
+
);
|
|
1016
|
+
return [current, set];
|
|
1017
|
+
}
|
|
1018
|
+
var floatingButton = "pointer-events-auto inline-flex h-9 items-center gap-2 rounded-full border border-border bg-background px-3 text-sm font-medium shadow-md hover:bg-muted-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring";
|
|
1019
|
+
function Studio({
|
|
1020
|
+
bar,
|
|
1021
|
+
banner,
|
|
1022
|
+
rail,
|
|
1023
|
+
canvas,
|
|
1024
|
+
inspector,
|
|
1025
|
+
railLabel = "Outline",
|
|
1026
|
+
inspectorLabel = "Properties",
|
|
1027
|
+
railOpen: railOpenProp,
|
|
1028
|
+
onRailOpenChange,
|
|
1029
|
+
inspectorOpen: inspectorOpenProp,
|
|
1030
|
+
onInspectorOpenChange,
|
|
1031
|
+
className
|
|
1032
|
+
}) {
|
|
1033
|
+
const layout = useLayout();
|
|
1034
|
+
const [railOpen, setRailOpen] = useControllable(railOpenProp, onRailOpenChange);
|
|
1035
|
+
const [inspectorOpen, setInspectorOpen] = useControllable(
|
|
1036
|
+
inspectorOpenProp,
|
|
1037
|
+
onInspectorOpenChange
|
|
1038
|
+
);
|
|
1039
|
+
const railInSheet = !!rail && layout !== "wide";
|
|
1040
|
+
const inspectorInSheet = !!inspector && layout === "compact";
|
|
1041
|
+
React15.useEffect(() => {
|
|
1042
|
+
if (layout === "wide" && railOpen) setRailOpen(false);
|
|
1043
|
+
if (layout !== "compact" && inspectorOpen) setInspectorOpen(false);
|
|
1044
|
+
}, [layout, railOpen, inspectorOpen, setRailOpen, setInspectorOpen]);
|
|
1045
|
+
const context = React15.useMemo(
|
|
1046
|
+
() => ({
|
|
1047
|
+
layout,
|
|
1048
|
+
railInSheet,
|
|
1049
|
+
inspectorInSheet,
|
|
1050
|
+
openRail: () => railInSheet && setRailOpen(true),
|
|
1051
|
+
closeRail: () => setRailOpen(false),
|
|
1052
|
+
revealInspector: () => {
|
|
1053
|
+
setRailOpen(false);
|
|
1054
|
+
if (inspectorInSheet) setInspectorOpen(true);
|
|
1055
|
+
},
|
|
1056
|
+
closeInspector: () => setInspectorOpen(false)
|
|
1057
|
+
}),
|
|
1058
|
+
[layout, railInSheet, inspectorInSheet, setRailOpen, setInspectorOpen]
|
|
1059
|
+
);
|
|
1060
|
+
return /* @__PURE__ */ jsxs7(StudioContext.Provider, { value: context, children: [
|
|
1061
|
+
/* @__PURE__ */ jsxs7(
|
|
1062
|
+
"div",
|
|
1063
|
+
{
|
|
1064
|
+
className: cn(
|
|
1065
|
+
"flex h-dvh flex-col overflow-hidden bg-background text-foreground",
|
|
1066
|
+
className
|
|
1067
|
+
),
|
|
1068
|
+
children: [
|
|
1069
|
+
bar,
|
|
1070
|
+
banner && /* @__PURE__ */ jsx15("div", { className: "shrink-0", children: banner }),
|
|
1071
|
+
/* @__PURE__ */ jsxs7("div", { className: "relative flex min-h-0 flex-1", children: [
|
|
1072
|
+
rail && !railInSheet && /* @__PURE__ */ jsx15(
|
|
1073
|
+
"aside",
|
|
1074
|
+
{
|
|
1075
|
+
"aria-label": railLabel,
|
|
1076
|
+
className: "hidden w-64 shrink-0 flex-col overflow-hidden border-r border-border bg-background xl:flex",
|
|
1077
|
+
children: rail
|
|
1078
|
+
}
|
|
1079
|
+
),
|
|
1080
|
+
/* @__PURE__ */ jsxs7("div", { className: "relative min-w-0 flex-1 overflow-hidden bg-muted/40", children: [
|
|
1081
|
+
canvas,
|
|
1082
|
+
(railInSheet || inspectorInSheet) && /* @__PURE__ */ jsxs7("div", { className: "pointer-events-none absolute inset-x-3 bottom-3 z-10 flex items-end justify-between gap-2", children: [
|
|
1083
|
+
railInSheet ? /* @__PURE__ */ jsxs7(
|
|
1084
|
+
"button",
|
|
1085
|
+
{
|
|
1086
|
+
type: "button",
|
|
1087
|
+
className: floatingButton,
|
|
1088
|
+
"aria-expanded": railOpen,
|
|
1089
|
+
onClick: () => setRailOpen(true),
|
|
1090
|
+
children: [
|
|
1091
|
+
/* @__PURE__ */ jsx15(StudioIcon, { name: "list" }),
|
|
1092
|
+
railLabel
|
|
1093
|
+
]
|
|
1094
|
+
}
|
|
1095
|
+
) : /* @__PURE__ */ jsx15("span", {}),
|
|
1096
|
+
inspectorInSheet && /* @__PURE__ */ jsxs7(
|
|
1097
|
+
"button",
|
|
1098
|
+
{
|
|
1099
|
+
type: "button",
|
|
1100
|
+
className: floatingButton,
|
|
1101
|
+
"aria-expanded": inspectorOpen,
|
|
1102
|
+
onClick: () => setInspectorOpen(true),
|
|
1103
|
+
children: [
|
|
1104
|
+
/* @__PURE__ */ jsx15(StudioIcon, { name: "settings" }),
|
|
1105
|
+
inspectorLabel
|
|
1106
|
+
]
|
|
1107
|
+
}
|
|
1108
|
+
)
|
|
1109
|
+
] })
|
|
1110
|
+
] }),
|
|
1111
|
+
inspector && !inspectorInSheet && /* @__PURE__ */ jsx15(
|
|
1112
|
+
"aside",
|
|
1113
|
+
{
|
|
1114
|
+
"aria-label": inspectorLabel,
|
|
1115
|
+
className: "hidden w-80 shrink-0 flex-col overflow-hidden border-l border-border bg-background md:flex 2xl:w-96",
|
|
1116
|
+
children: inspector
|
|
1117
|
+
}
|
|
1118
|
+
)
|
|
1119
|
+
] })
|
|
1120
|
+
]
|
|
1121
|
+
}
|
|
1122
|
+
),
|
|
1123
|
+
rail && railInSheet && /* @__PURE__ */ jsx15(Sheet, { open: railOpen, onOpenChange: setRailOpen, side: "left", size: "sm", title: railLabel, children: /* @__PURE__ */ jsx15("div", { className: "flex h-full flex-col", children: rail }) }),
|
|
1124
|
+
inspector && inspectorInSheet && /* @__PURE__ */ jsx15(
|
|
1125
|
+
Sheet,
|
|
1126
|
+
{
|
|
1127
|
+
open: inspectorOpen,
|
|
1128
|
+
onOpenChange: setInspectorOpen,
|
|
1129
|
+
side: "bottom",
|
|
1130
|
+
title: inspectorLabel,
|
|
1131
|
+
hideTitle: true,
|
|
1132
|
+
children: inspector
|
|
1133
|
+
}
|
|
1134
|
+
)
|
|
1135
|
+
] });
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
// src/components/studio/StudioBar.tsx
|
|
1139
|
+
import * as React16 from "react";
|
|
1140
|
+
|
|
1141
|
+
// src/components/studio/menu.tsx
|
|
679
1142
|
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
|
1143
|
+
import { jsx as jsx16, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1144
|
+
function StudioMenu({
|
|
1145
|
+
items,
|
|
1146
|
+
label,
|
|
1147
|
+
triggerClassName,
|
|
1148
|
+
children
|
|
1149
|
+
}) {
|
|
1150
|
+
return /* @__PURE__ */ jsxs8(DropdownMenuPrimitive.Root, { children: [
|
|
1151
|
+
/* @__PURE__ */ jsx16(DropdownMenuPrimitive.Trigger, { className: triggerClassName, "aria-label": label, children }),
|
|
1152
|
+
/* @__PURE__ */ jsx16(DropdownMenuPrimitive.Portal, { children: /* @__PURE__ */ jsx16(
|
|
1153
|
+
DropdownMenuPrimitive.Content,
|
|
1154
|
+
{
|
|
1155
|
+
align: "end",
|
|
1156
|
+
sideOffset: 4,
|
|
1157
|
+
collisionPadding: 8,
|
|
1158
|
+
className: "z-50 min-w-[10rem] overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",
|
|
1159
|
+
children: items.map(
|
|
1160
|
+
(item, i) => item.type === "separator" ? /* @__PURE__ */ jsx16(DropdownMenuPrimitive.Separator, { className: "-mx-1 my-1 h-px bg-muted" }, i) : /* @__PURE__ */ jsxs8(
|
|
1161
|
+
DropdownMenuPrimitive.Item,
|
|
1162
|
+
{
|
|
1163
|
+
disabled: item.disabled,
|
|
1164
|
+
onSelect: () => item.onSelect?.(),
|
|
1165
|
+
className: cn(
|
|
1166
|
+
"relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled]:pointer-events-none data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[disabled]:opacity-50",
|
|
1167
|
+
item.destructive && "text-destructive data-[highlighted]:text-destructive"
|
|
1168
|
+
),
|
|
1169
|
+
children: [
|
|
1170
|
+
item.icon,
|
|
1171
|
+
item.label
|
|
1172
|
+
]
|
|
1173
|
+
},
|
|
1174
|
+
i
|
|
1175
|
+
)
|
|
1176
|
+
)
|
|
1177
|
+
}
|
|
1178
|
+
) })
|
|
1179
|
+
] });
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
// src/components/studio/StudioBar.tsx
|
|
1183
|
+
import { jsx as jsx17, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1184
|
+
function ModeSwitch({
|
|
1185
|
+
modes,
|
|
1186
|
+
value,
|
|
1187
|
+
onChange
|
|
1188
|
+
}) {
|
|
1189
|
+
const refs = React16.useRef([]);
|
|
1190
|
+
const keyDown = (event, index) => {
|
|
1191
|
+
const step = event.key === "ArrowRight" || event.key === "ArrowDown" ? 1 : event.key === "ArrowLeft" || event.key === "ArrowUp" ? -1 : 0;
|
|
1192
|
+
if (!step) return;
|
|
1193
|
+
event.preventDefault();
|
|
1194
|
+
const next = (index + step + modes.length) % modes.length;
|
|
1195
|
+
onChange(modes[next].value);
|
|
1196
|
+
refs.current[next]?.focus();
|
|
1197
|
+
};
|
|
1198
|
+
return /* @__PURE__ */ jsx17(
|
|
1199
|
+
"div",
|
|
1200
|
+
{
|
|
1201
|
+
role: "radiogroup",
|
|
1202
|
+
"aria-label": "Editor mode",
|
|
1203
|
+
className: "flex h-9 w-full items-center gap-1 rounded-lg bg-muted p-1 text-muted-foreground md:w-auto",
|
|
1204
|
+
children: modes.map((m, i) => {
|
|
1205
|
+
const checked = m.value === value;
|
|
1206
|
+
return /* @__PURE__ */ jsxs9(
|
|
1207
|
+
"button",
|
|
1208
|
+
{
|
|
1209
|
+
ref: (el) => {
|
|
1210
|
+
refs.current[i] = el;
|
|
1211
|
+
},
|
|
1212
|
+
type: "button",
|
|
1213
|
+
role: "radio",
|
|
1214
|
+
"aria-checked": checked,
|
|
1215
|
+
tabIndex: checked ? 0 : -1,
|
|
1216
|
+
onClick: () => onChange(m.value),
|
|
1217
|
+
onKeyDown: (e) => keyDown(e, i),
|
|
1218
|
+
className: cn(
|
|
1219
|
+
"inline-flex h-7 flex-1 items-center justify-center gap-1.5 whitespace-nowrap rounded-md px-2.5 text-sm font-medium hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring md:flex-none",
|
|
1220
|
+
checked && "bg-background text-foreground shadow-sm"
|
|
1221
|
+
),
|
|
1222
|
+
children: [
|
|
1223
|
+
m.icon,
|
|
1224
|
+
m.label
|
|
1225
|
+
]
|
|
1226
|
+
},
|
|
1227
|
+
m.value
|
|
1228
|
+
);
|
|
1229
|
+
})
|
|
1230
|
+
}
|
|
1231
|
+
);
|
|
1232
|
+
}
|
|
1233
|
+
function StudioBar({
|
|
1234
|
+
title,
|
|
1235
|
+
onTitleInput,
|
|
1236
|
+
onTitleChange,
|
|
1237
|
+
titleReadonly = false,
|
|
1238
|
+
titlePlaceholder = "Untitled",
|
|
1239
|
+
subtitle,
|
|
1240
|
+
backHref,
|
|
1241
|
+
backLabel = "Back",
|
|
1242
|
+
modes,
|
|
1243
|
+
mode,
|
|
1244
|
+
onModeChange,
|
|
1245
|
+
status,
|
|
1246
|
+
issues,
|
|
1247
|
+
actions,
|
|
1248
|
+
menuItems,
|
|
1249
|
+
menuLabel = "More actions",
|
|
1250
|
+
className
|
|
1251
|
+
}) {
|
|
1252
|
+
const [draft, setDraft] = React16.useState(title);
|
|
1253
|
+
const atFocus = React16.useRef(title);
|
|
1254
|
+
React16.useEffect(() => setDraft(title), [title]);
|
|
1255
|
+
const commit = () => {
|
|
1256
|
+
const next = draft.trim();
|
|
1257
|
+
if (!next) {
|
|
1258
|
+
setDraft(atFocus.current);
|
|
1259
|
+
onTitleInput?.(atFocus.current);
|
|
1260
|
+
return;
|
|
1261
|
+
}
|
|
1262
|
+
if (next !== atFocus.current) onTitleChange?.(next);
|
|
1263
|
+
atFocus.current = next;
|
|
1264
|
+
};
|
|
1265
|
+
return /* @__PURE__ */ jsxs9(
|
|
1266
|
+
"header",
|
|
1267
|
+
{
|
|
1268
|
+
className: cn(
|
|
1269
|
+
"flex shrink-0 flex-wrap items-center gap-x-2 gap-y-2 border-b border-border bg-background px-2 py-2 md:h-14 md:flex-nowrap md:gap-x-3 md:px-3 md:py-0",
|
|
1270
|
+
className
|
|
1271
|
+
),
|
|
1272
|
+
children: [
|
|
1273
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex min-w-0 flex-1 items-center gap-1 md:basis-0", children: [
|
|
1274
|
+
backHref && /* @__PURE__ */ jsx17(
|
|
1275
|
+
"a",
|
|
1276
|
+
{
|
|
1277
|
+
href: backHref,
|
|
1278
|
+
"aria-label": backLabel,
|
|
1279
|
+
title: backLabel,
|
|
1280
|
+
className: "flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-muted-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
1281
|
+
children: /* @__PURE__ */ jsx17(StudioIcon, { name: "arrow-left", size: 18 })
|
|
1282
|
+
}
|
|
1283
|
+
),
|
|
1284
|
+
/* @__PURE__ */ jsxs9("div", { className: "min-w-0 flex-1", children: [
|
|
1285
|
+
/* @__PURE__ */ jsx17("h1", { className: titleReadonly ? "truncate px-1.5 text-base font-semibold" : "sr-only", children: title || titlePlaceholder }),
|
|
1286
|
+
!titleReadonly && /* @__PURE__ */ jsx17(
|
|
1287
|
+
"input",
|
|
1288
|
+
{
|
|
1289
|
+
value: draft,
|
|
1290
|
+
"aria-label": "Title",
|
|
1291
|
+
placeholder: titlePlaceholder,
|
|
1292
|
+
className: "block w-full max-w-md truncate rounded-md border border-transparent bg-transparent px-1.5 py-0.5 text-base font-semibold leading-tight outline-none hover:border-border focus:border-input focus:bg-background focus:ring-2 focus:ring-ring",
|
|
1293
|
+
onChange: (e) => {
|
|
1294
|
+
setDraft(e.target.value);
|
|
1295
|
+
onTitleInput?.(e.target.value);
|
|
1296
|
+
},
|
|
1297
|
+
onFocus: (e) => atFocus.current = e.target.value,
|
|
1298
|
+
onBlur: commit,
|
|
1299
|
+
onKeyDown: (e) => {
|
|
1300
|
+
if (e.key === "Enter") {
|
|
1301
|
+
e.preventDefault();
|
|
1302
|
+
e.currentTarget.blur();
|
|
1303
|
+
} else if (e.key === "Escape") {
|
|
1304
|
+
e.preventDefault();
|
|
1305
|
+
setDraft(atFocus.current);
|
|
1306
|
+
onTitleInput?.(atFocus.current);
|
|
1307
|
+
const input = e.currentTarget;
|
|
1308
|
+
requestAnimationFrame(() => input.blur());
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
),
|
|
1313
|
+
subtitle && /* @__PURE__ */ jsx17("p", { className: "truncate px-1.5 text-xs text-muted-foreground", children: subtitle })
|
|
1314
|
+
] })
|
|
1315
|
+
] }),
|
|
1316
|
+
modes && modes.length > 1 && /* @__PURE__ */ jsx17("div", { className: "order-last flex w-full justify-center md:order-none md:w-auto", children: /* @__PURE__ */ jsx17(
|
|
1317
|
+
ModeSwitch,
|
|
1318
|
+
{
|
|
1319
|
+
modes,
|
|
1320
|
+
value: mode ?? modes[0].value,
|
|
1321
|
+
onChange: (v) => v !== mode && onModeChange?.(v)
|
|
1322
|
+
}
|
|
1323
|
+
) }),
|
|
1324
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex shrink-0 items-center justify-end gap-1 md:flex-1 md:basis-0 md:gap-2", children: [
|
|
1325
|
+
status,
|
|
1326
|
+
issues,
|
|
1327
|
+
actions,
|
|
1328
|
+
menuItems && menuItems.length > 0 && /* @__PURE__ */ jsx17(
|
|
1329
|
+
StudioMenu,
|
|
1330
|
+
{
|
|
1331
|
+
items: menuItems,
|
|
1332
|
+
label: menuLabel,
|
|
1333
|
+
triggerClassName: "flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground hover:bg-muted-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
1334
|
+
children: /* @__PURE__ */ jsx17(StudioIcon, { name: "more-horizontal", size: 18 })
|
|
1335
|
+
}
|
|
1336
|
+
)
|
|
1337
|
+
] })
|
|
1338
|
+
]
|
|
1339
|
+
}
|
|
1340
|
+
);
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
// src/components/studio/StudioOutline.tsx
|
|
1344
|
+
import * as React17 from "react";
|
|
1345
|
+
import { jsx as jsx18, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1346
|
+
function StudioOutline({
|
|
1347
|
+
items,
|
|
1348
|
+
selected = null,
|
|
1349
|
+
onSelect,
|
|
1350
|
+
onReorder,
|
|
1351
|
+
menuItems,
|
|
1352
|
+
onAdd,
|
|
1353
|
+
addLabel = "Add",
|
|
1354
|
+
label = "Items",
|
|
1355
|
+
numbered = true,
|
|
1356
|
+
renderThumbnail,
|
|
1357
|
+
header,
|
|
1358
|
+
empty,
|
|
1359
|
+
className
|
|
1360
|
+
}) {
|
|
1361
|
+
const studio = useStudio();
|
|
1362
|
+
const listHost = React17.useRef(null);
|
|
1363
|
+
const focusIndex = Math.max(
|
|
1364
|
+
0,
|
|
1365
|
+
items.findIndex((i) => i.id === selected)
|
|
1366
|
+
);
|
|
1367
|
+
React17.useEffect(() => {
|
|
1368
|
+
if (!selected) return;
|
|
1369
|
+
listHost.current?.querySelector(`[data-outline-id="${CSS.escape(selected)}"]`)?.scrollIntoView?.({ block: "nearest" });
|
|
1370
|
+
}, [selected]);
|
|
1371
|
+
const select = (id) => {
|
|
1372
|
+
onSelect?.(id);
|
|
1373
|
+
studio?.revealInspector();
|
|
1374
|
+
};
|
|
1375
|
+
const rowKeyDown = (event, index) => {
|
|
1376
|
+
const rows = Array.from(
|
|
1377
|
+
listHost.current?.querySelectorAll("[data-outline-row]") ?? []
|
|
1378
|
+
);
|
|
1379
|
+
const next = event.key === "ArrowDown" ? Math.min(index + 1, rows.length - 1) : event.key === "ArrowUp" ? Math.max(index - 1, 0) : event.key === "Home" ? 0 : event.key === "End" ? rows.length - 1 : -1;
|
|
1380
|
+
if (next < 0) return;
|
|
1381
|
+
event.preventDefault();
|
|
1382
|
+
rows[next]?.focus();
|
|
1383
|
+
};
|
|
1384
|
+
const rowMenu = (entry, index) => {
|
|
1385
|
+
const own = menuItems?.(entry, index) ?? [];
|
|
1386
|
+
if (!onReorder) return own;
|
|
1387
|
+
const moves = [
|
|
1388
|
+
{
|
|
1389
|
+
label: "Move up",
|
|
1390
|
+
icon: /* @__PURE__ */ jsx18(StudioIcon, { name: "arrow-up" }),
|
|
1391
|
+
disabled: index === 0,
|
|
1392
|
+
onSelect: () => onReorder(index, index - 1)
|
|
1393
|
+
},
|
|
1394
|
+
{
|
|
1395
|
+
label: "Move down",
|
|
1396
|
+
icon: /* @__PURE__ */ jsx18(StudioIcon, { name: "arrow-down" }),
|
|
1397
|
+
disabled: index === items.length - 1,
|
|
1398
|
+
onSelect: () => onReorder(index, index + 1)
|
|
1399
|
+
}
|
|
1400
|
+
];
|
|
1401
|
+
return own.length ? [...moves, { type: "separator" }, ...own] : moves;
|
|
1402
|
+
};
|
|
1403
|
+
const row = (entry, index, handle) => {
|
|
1404
|
+
const active = entry.id === selected;
|
|
1405
|
+
const menu = rowMenu(entry, index);
|
|
1406
|
+
return /* @__PURE__ */ jsxs10(
|
|
1407
|
+
"div",
|
|
1408
|
+
{
|
|
1409
|
+
"data-outline-id": entry.id,
|
|
1410
|
+
className: cn(
|
|
1411
|
+
"group relative flex items-stretch gap-0.5 rounded-md",
|
|
1412
|
+
active ? "bg-primary/10 ring-1 ring-inset ring-primary/40" : "hover:bg-muted-hover"
|
|
1413
|
+
),
|
|
1414
|
+
children: [
|
|
1415
|
+
handle && /* @__PURE__ */ jsx18(
|
|
1416
|
+
"button",
|
|
1417
|
+
{
|
|
1418
|
+
...handle,
|
|
1419
|
+
className: cn(
|
|
1420
|
+
"flex w-6 shrink-0 cursor-grab touch-none items-center justify-center rounded-l-md text-muted-foreground opacity-0 hover:text-foreground focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring active:cursor-grabbing group-hover:opacity-100 aria-pressed:opacity-100 [@media(hover:none)]:opacity-100",
|
|
1421
|
+
active && "opacity-100"
|
|
1422
|
+
),
|
|
1423
|
+
children: /* @__PURE__ */ jsx18(StudioIcon, { name: "grip", size: 14 })
|
|
1424
|
+
}
|
|
1425
|
+
),
|
|
1426
|
+
/* @__PURE__ */ jsxs10(
|
|
1427
|
+
"button",
|
|
1428
|
+
{
|
|
1429
|
+
type: "button",
|
|
1430
|
+
"data-outline-row": "",
|
|
1431
|
+
tabIndex: index === focusIndex ? 0 : -1,
|
|
1432
|
+
"aria-current": active ? "true" : void 0,
|
|
1433
|
+
className: cn(
|
|
1434
|
+
"flex min-w-0 flex-1 flex-col gap-1.5 rounded-md py-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
1435
|
+
!handle && "pl-2",
|
|
1436
|
+
entry.muted && "opacity-60"
|
|
1437
|
+
),
|
|
1438
|
+
onClick: () => select(entry.id),
|
|
1439
|
+
onKeyDown: (e) => rowKeyDown(e, index),
|
|
1440
|
+
children: [
|
|
1441
|
+
renderThumbnail && /* @__PURE__ */ jsx18("div", { className: "w-full overflow-hidden rounded border border-border bg-background", children: renderThumbnail(entry, index) }),
|
|
1442
|
+
/* @__PURE__ */ jsxs10("span", { className: "flex min-w-0 items-start gap-2", children: [
|
|
1443
|
+
numbered && /* @__PURE__ */ jsx18("span", { className: "w-5 shrink-0 pt-px text-right text-xs tabular-nums text-muted-foreground", children: index + 1 }),
|
|
1444
|
+
entry.icon && !renderThumbnail && /* @__PURE__ */ jsx18("span", { className: "mt-px shrink-0 text-muted-foreground", "aria-hidden": "true", children: entry.icon }),
|
|
1445
|
+
/* @__PURE__ */ jsxs10("span", { className: "min-w-0 flex-1", children: [
|
|
1446
|
+
/* @__PURE__ */ jsx18(
|
|
1447
|
+
"span",
|
|
1448
|
+
{
|
|
1449
|
+
className: cn("block truncate text-sm text-foreground", active && "font-medium"),
|
|
1450
|
+
children: entry.title || "Untitled"
|
|
1451
|
+
}
|
|
1452
|
+
),
|
|
1453
|
+
entry.subtitle && /* @__PURE__ */ jsx18("span", { className: "block truncate text-xs text-muted-foreground", children: entry.subtitle })
|
|
1454
|
+
] }),
|
|
1455
|
+
entry.badge && /* @__PURE__ */ jsx18("span", { className: "shrink-0 rounded bg-muted px-1.5 py-px text-[0.6875rem] text-muted-foreground", children: entry.badge }),
|
|
1456
|
+
!!entry.issues && /* @__PURE__ */ jsxs10("span", { className: "inline-flex shrink-0 items-center gap-0.5 text-xs font-medium tabular-nums", children: [
|
|
1457
|
+
/* @__PURE__ */ jsx18(
|
|
1458
|
+
StudioIcon,
|
|
1459
|
+
{
|
|
1460
|
+
name: "alert-triangle",
|
|
1461
|
+
size: 12,
|
|
1462
|
+
className: entry.issueSeverity === "warning" ? "text-warning" : "text-destructive"
|
|
1463
|
+
}
|
|
1464
|
+
),
|
|
1465
|
+
entry.issues,
|
|
1466
|
+
/* @__PURE__ */ jsx18("span", { className: "sr-only", children: entry.issues === 1 ? "issue" : "issues" })
|
|
1467
|
+
] })
|
|
1468
|
+
] })
|
|
1469
|
+
]
|
|
1470
|
+
}
|
|
1471
|
+
),
|
|
1472
|
+
menu.length > 0 && /* @__PURE__ */ jsx18(
|
|
1473
|
+
"div",
|
|
1474
|
+
{
|
|
1475
|
+
className: cn(
|
|
1476
|
+
"flex shrink-0 items-start pt-1 opacity-0 focus-within:opacity-100 group-hover:opacity-100 [@media(hover:none)]:opacity-100",
|
|
1477
|
+
active && "opacity-100"
|
|
1478
|
+
),
|
|
1479
|
+
children: /* @__PURE__ */ jsx18(
|
|
1480
|
+
StudioMenu,
|
|
1481
|
+
{
|
|
1482
|
+
items: menu,
|
|
1483
|
+
label: `Actions for ${entry.title || `item ${index + 1}`}`,
|
|
1484
|
+
triggerClassName: "flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-muted-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
1485
|
+
children: /* @__PURE__ */ jsx18(StudioIcon, { name: "more-horizontal" })
|
|
1486
|
+
}
|
|
1487
|
+
)
|
|
1488
|
+
}
|
|
1489
|
+
)
|
|
1490
|
+
]
|
|
1491
|
+
}
|
|
1492
|
+
);
|
|
1493
|
+
};
|
|
1494
|
+
return /* @__PURE__ */ jsxs10("div", { className: cn("flex h-full min-h-0 flex-col", className), children: [
|
|
1495
|
+
header && /* @__PURE__ */ jsx18("div", { className: "shrink-0 border-b border-border px-3 py-2", children: header }),
|
|
1496
|
+
/* @__PURE__ */ jsx18("div", { ref: listHost, className: "min-h-0 flex-1 overflow-y-auto p-2", children: items.length === 0 ? empty ?? /* @__PURE__ */ jsx18("p", { className: "px-2 py-6 text-center text-sm text-muted-foreground", children: "Nothing here yet." }) : onReorder ? /* @__PURE__ */ jsx18(
|
|
1497
|
+
SortableList,
|
|
1498
|
+
{
|
|
1499
|
+
items,
|
|
1500
|
+
getKey: (e) => e.id,
|
|
1501
|
+
onReorder,
|
|
1502
|
+
label,
|
|
1503
|
+
getItemLabel: (e, i) => e.title || `item ${i + 1}`,
|
|
1504
|
+
className: "space-y-0.5",
|
|
1505
|
+
renderItem: ({ item, index, handle }) => row(item, index, handle)
|
|
1506
|
+
}
|
|
1507
|
+
) : /* @__PURE__ */ jsx18("ul", { "aria-label": label, className: "space-y-0.5", children: items.map((entry, index) => /* @__PURE__ */ jsx18("li", { children: row(entry, index) }, entry.id)) }) }),
|
|
1508
|
+
onAdd && /* @__PURE__ */ jsx18("div", { className: "shrink-0 border-t border-border p-2", children: /* @__PURE__ */ jsxs10(
|
|
1509
|
+
"button",
|
|
1510
|
+
{
|
|
1511
|
+
type: "button",
|
|
1512
|
+
onClick: onAdd,
|
|
1513
|
+
className: "flex h-9 w-full items-center justify-center gap-2 rounded-md border border-dashed border-border text-sm font-medium text-muted-foreground hover:border-primary hover:bg-primary/5 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
1514
|
+
children: [
|
|
1515
|
+
/* @__PURE__ */ jsx18(StudioIcon, { name: "plus" }),
|
|
1516
|
+
addLabel
|
|
1517
|
+
]
|
|
1518
|
+
}
|
|
1519
|
+
) })
|
|
1520
|
+
] });
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
// src/components/studio/StudioCanvas.tsx
|
|
1524
|
+
import * as React18 from "react";
|
|
1525
|
+
import { jsx as jsx19, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1526
|
+
function StudioCanvas({
|
|
1527
|
+
children,
|
|
1528
|
+
deviceToggle = false,
|
|
1529
|
+
device: deviceProp,
|
|
1530
|
+
onDeviceChange,
|
|
1531
|
+
maxWidth = "48rem",
|
|
1532
|
+
toolbar,
|
|
1533
|
+
label = "Canvas",
|
|
1534
|
+
onBackgroundClick,
|
|
1535
|
+
frameClassName,
|
|
1536
|
+
className
|
|
1537
|
+
}) {
|
|
1538
|
+
const studio = useStudio();
|
|
1539
|
+
const [innerDevice, setInnerDevice] = React18.useState("desktop");
|
|
1540
|
+
const device = deviceProp ?? innerDevice;
|
|
1541
|
+
const setDevice = (d) => {
|
|
1542
|
+
if (deviceProp === void 0) setInnerDevice(d);
|
|
1543
|
+
onDeviceChange?.(d);
|
|
1544
|
+
};
|
|
1545
|
+
const showDevices = deviceToggle && studio?.layout !== "compact";
|
|
1546
|
+
const width = device === "phone" && showDevices ? "390px" : maxWidth;
|
|
1547
|
+
return /* @__PURE__ */ jsxs11("section", { "aria-label": label, className: cn("flex h-full flex-col", className), children: [
|
|
1548
|
+
(showDevices || toolbar) && /* @__PURE__ */ jsxs11("div", { className: "flex shrink-0 items-center justify-end gap-2 px-3 pt-3", children: [
|
|
1549
|
+
toolbar,
|
|
1550
|
+
showDevices && /* @__PURE__ */ jsx19(
|
|
1551
|
+
"div",
|
|
1552
|
+
{
|
|
1553
|
+
role: "radiogroup",
|
|
1554
|
+
"aria-label": "Preview size",
|
|
1555
|
+
className: "inline-flex h-9 items-center gap-1 rounded-lg bg-muted p-1 text-muted-foreground",
|
|
1556
|
+
children: ["desktop", "phone"].map((d) => /* @__PURE__ */ jsxs11(
|
|
1557
|
+
"button",
|
|
1558
|
+
{
|
|
1559
|
+
type: "button",
|
|
1560
|
+
role: "radio",
|
|
1561
|
+
"aria-checked": device === d,
|
|
1562
|
+
onClick: () => setDevice(d),
|
|
1563
|
+
className: cn(
|
|
1564
|
+
"inline-flex h-7 items-center gap-1.5 rounded-md px-2.5 text-sm font-medium hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
1565
|
+
device === d && "bg-background text-foreground shadow-sm"
|
|
1566
|
+
),
|
|
1567
|
+
children: [
|
|
1568
|
+
/* @__PURE__ */ jsx19(StudioIcon, { name: d === "desktop" ? "monitor" : "smartphone" }),
|
|
1569
|
+
d === "desktop" ? "Desktop" : "Phone"
|
|
1570
|
+
]
|
|
1571
|
+
},
|
|
1572
|
+
d
|
|
1573
|
+
))
|
|
1574
|
+
}
|
|
1575
|
+
)
|
|
1576
|
+
] }),
|
|
1577
|
+
/* @__PURE__ */ jsx19(
|
|
1578
|
+
"div",
|
|
1579
|
+
{
|
|
1580
|
+
className: "min-h-0 flex-1 overflow-y-auto px-3 pb-20 pt-3 md:px-6 md:pb-10",
|
|
1581
|
+
onClick: (e) => {
|
|
1582
|
+
if (e.target === e.currentTarget) onBackgroundClick?.();
|
|
1583
|
+
},
|
|
1584
|
+
children: /* @__PURE__ */ jsx19(
|
|
1585
|
+
"div",
|
|
1586
|
+
{
|
|
1587
|
+
className: cn(
|
|
1588
|
+
"mx-auto w-full rounded-lg border border-border bg-background shadow-sm transition-[max-width] duration-200",
|
|
1589
|
+
frameClassName
|
|
1590
|
+
),
|
|
1591
|
+
style: { maxWidth: width },
|
|
1592
|
+
children
|
|
1593
|
+
}
|
|
1594
|
+
)
|
|
1595
|
+
}
|
|
1596
|
+
)
|
|
1597
|
+
] });
|
|
1598
|
+
}
|
|
1599
|
+
|
|
1600
|
+
// src/components/studio/StudioCanvasItem.tsx
|
|
1601
|
+
import * as React19 from "react";
|
|
1602
|
+
import { jsx as jsx20, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1603
|
+
function StudioCanvasItem({
|
|
1604
|
+
children,
|
|
1605
|
+
selected = false,
|
|
1606
|
+
onSelect,
|
|
1607
|
+
label,
|
|
1608
|
+
toolbar,
|
|
1609
|
+
onInsert,
|
|
1610
|
+
insertLabel,
|
|
1611
|
+
invalid = false,
|
|
1612
|
+
className
|
|
1613
|
+
}) {
|
|
1614
|
+
const studio = useStudio();
|
|
1615
|
+
const ref = React19.useRef(null);
|
|
1616
|
+
const select = (reveal) => {
|
|
1617
|
+
if (!selected) onSelect?.();
|
|
1618
|
+
if (reveal) studio?.revealInspector();
|
|
1619
|
+
};
|
|
1620
|
+
React19.useEffect(() => {
|
|
1621
|
+
const el = ref.current;
|
|
1622
|
+
if (!selected || !el || el.contains(document.activeElement)) return;
|
|
1623
|
+
const reduce = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
1624
|
+
el.scrollIntoView?.({ block: "nearest", behavior: reduce ? "auto" : "smooth" });
|
|
1625
|
+
}, [selected]);
|
|
1626
|
+
return /* @__PURE__ */ jsxs12(
|
|
1627
|
+
"div",
|
|
1628
|
+
{
|
|
1629
|
+
ref,
|
|
1630
|
+
role: "group",
|
|
1631
|
+
"aria-label": label,
|
|
1632
|
+
"aria-current": selected ? "true" : void 0,
|
|
1633
|
+
"data-selected": selected || void 0,
|
|
1634
|
+
className: cn(
|
|
1635
|
+
"group/item relative scroll-my-6 rounded-lg transition-shadow",
|
|
1636
|
+
// Problems are a dashed amber outline: with a red brand primary, a red
|
|
1637
|
+
// ring would read as "selected"
|
|
1638
|
+
selected ? "ring-2 ring-primary" : "hover:ring-1 hover:ring-border",
|
|
1639
|
+
invalid && "-outline-offset-2 outline-dashed outline-2 outline-warning/70",
|
|
1640
|
+
className
|
|
1641
|
+
),
|
|
1642
|
+
onClickCapture: (e) => select(!e.target.closest?.("[data-studio-quick-action]")),
|
|
1643
|
+
onFocus: () => select(false),
|
|
1644
|
+
children: [
|
|
1645
|
+
!selected && /* @__PURE__ */ jsxs12(
|
|
1646
|
+
"button",
|
|
1647
|
+
{
|
|
1648
|
+
type: "button",
|
|
1649
|
+
className: "sr-only left-2 top-2 z-10 rounded-md bg-primary px-2 py-1 text-xs font-medium text-primary-foreground focus:not-sr-only focus:absolute",
|
|
1650
|
+
onClick: () => select(true),
|
|
1651
|
+
children: [
|
|
1652
|
+
"Edit ",
|
|
1653
|
+
label
|
|
1654
|
+
]
|
|
1655
|
+
}
|
|
1656
|
+
),
|
|
1657
|
+
selected && toolbar && /* @__PURE__ */ jsx20(
|
|
1658
|
+
"div",
|
|
1659
|
+
{
|
|
1660
|
+
"data-studio-quick-action": "",
|
|
1661
|
+
className: "absolute -top-4 right-3 z-10 flex items-center gap-0.5 rounded-md border border-border bg-background p-0.5 shadow-md",
|
|
1662
|
+
children: toolbar
|
|
1663
|
+
}
|
|
1664
|
+
),
|
|
1665
|
+
children,
|
|
1666
|
+
onInsert && /* @__PURE__ */ jsx20("div", { className: "relative h-0", "data-studio-quick-action": "", children: /* @__PURE__ */ jsx20(
|
|
1667
|
+
"button",
|
|
1668
|
+
{
|
|
1669
|
+
type: "button",
|
|
1670
|
+
"aria-label": insertLabel ?? `Add below ${label}`,
|
|
1671
|
+
title: insertLabel ?? "Add below",
|
|
1672
|
+
className: cn(
|
|
1673
|
+
"absolute left-1/2 top-0 z-10 flex h-7 w-7 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full border border-border bg-background text-muted-foreground opacity-0 shadow-sm hover:border-primary hover:text-primary focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring group-hover/item:opacity-100 [@media(hover:none)]:opacity-100",
|
|
1674
|
+
selected && "opacity-100"
|
|
1675
|
+
),
|
|
1676
|
+
onClick: (e) => {
|
|
1677
|
+
e.stopPropagation();
|
|
1678
|
+
onInsert();
|
|
1679
|
+
},
|
|
1680
|
+
children: /* @__PURE__ */ jsx20(StudioIcon, { name: "plus", size: 14 })
|
|
1681
|
+
}
|
|
1682
|
+
) })
|
|
1683
|
+
]
|
|
1684
|
+
}
|
|
1685
|
+
);
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
// src/components/studio/StudioInspector.tsx
|
|
1689
|
+
import * as React20 from "react";
|
|
1690
|
+
import { jsx as jsx21, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1691
|
+
function StudioInspector({
|
|
1692
|
+
title,
|
|
1693
|
+
description,
|
|
1694
|
+
headerActions,
|
|
1695
|
+
tabs,
|
|
1696
|
+
tab: tabProp,
|
|
1697
|
+
onTabChange,
|
|
1698
|
+
children,
|
|
1699
|
+
footer,
|
|
1700
|
+
className
|
|
1701
|
+
}) {
|
|
1702
|
+
const uid = React20.useId();
|
|
1703
|
+
const [innerTab, setInnerTab] = React20.useState(tabs?.[0]?.id ?? "");
|
|
1704
|
+
const tab = tabProp ?? innerTab;
|
|
1705
|
+
const hasTabs = !!tabs && tabs.length > 1;
|
|
1706
|
+
const choose = (id) => {
|
|
1707
|
+
if (id === tab) return;
|
|
1708
|
+
if (tabProp === void 0) setInnerTab(id);
|
|
1709
|
+
onTabChange?.(id);
|
|
1710
|
+
};
|
|
1711
|
+
const keyDown = (event, index) => {
|
|
1712
|
+
if (!tabs) return;
|
|
1713
|
+
const step = event.key === "ArrowRight" ? 1 : event.key === "ArrowLeft" ? -1 : 0;
|
|
1714
|
+
if (!step) return;
|
|
1715
|
+
event.preventDefault();
|
|
1716
|
+
const next = tabs[(index + step + tabs.length) % tabs.length];
|
|
1717
|
+
choose(next.id);
|
|
1718
|
+
document.getElementById(`${uid}-tab-${next.id}`)?.focus();
|
|
1719
|
+
};
|
|
1720
|
+
return /* @__PURE__ */ jsxs13("div", { className: cn("flex h-full min-h-0 flex-col", className), children: [
|
|
1721
|
+
(title || headerActions) && /* @__PURE__ */ jsxs13("div", { className: "flex shrink-0 items-start gap-2 border-b border-border px-4 py-3", children: [
|
|
1722
|
+
/* @__PURE__ */ jsxs13("div", { className: "min-w-0 flex-1", children: [
|
|
1723
|
+
title && /* @__PURE__ */ jsx21("h2", { className: "truncate text-sm font-semibold", children: title }),
|
|
1724
|
+
description && /* @__PURE__ */ jsx21("p", { className: "truncate text-xs text-muted-foreground", children: description })
|
|
1725
|
+
] }),
|
|
1726
|
+
headerActions && /* @__PURE__ */ jsx21("div", { className: "flex shrink-0 items-center gap-1", children: headerActions })
|
|
1727
|
+
] }),
|
|
1728
|
+
hasTabs && /* @__PURE__ */ jsx21(
|
|
1729
|
+
"div",
|
|
1730
|
+
{
|
|
1731
|
+
role: "tablist",
|
|
1732
|
+
"aria-label": title ?? "Inspector",
|
|
1733
|
+
className: "flex shrink-0 gap-4 border-b border-border px-4",
|
|
1734
|
+
children: tabs.map((t, index) => /* @__PURE__ */ jsxs13(
|
|
1735
|
+
"button",
|
|
1736
|
+
{
|
|
1737
|
+
type: "button",
|
|
1738
|
+
role: "tab",
|
|
1739
|
+
id: `${uid}-tab-${t.id}`,
|
|
1740
|
+
"aria-selected": t.id === tab,
|
|
1741
|
+
"aria-controls": `${uid}-panel`,
|
|
1742
|
+
tabIndex: t.id === tab ? 0 : -1,
|
|
1743
|
+
onClick: () => choose(t.id),
|
|
1744
|
+
onKeyDown: (e) => keyDown(e, index),
|
|
1745
|
+
className: cn(
|
|
1746
|
+
"-mb-px border-b-2 py-2 text-sm font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
1747
|
+
t.id === tab ? "border-primary text-foreground" : "border-transparent text-muted-foreground hover:text-foreground"
|
|
1748
|
+
),
|
|
1749
|
+
children: [
|
|
1750
|
+
t.label,
|
|
1751
|
+
!!t.count && /* @__PURE__ */ jsx21("span", { className: "ml-1 rounded-full bg-muted px-1.5 text-xs tabular-nums", children: t.count })
|
|
1752
|
+
]
|
|
1753
|
+
},
|
|
1754
|
+
t.id
|
|
1755
|
+
))
|
|
1756
|
+
}
|
|
1757
|
+
),
|
|
1758
|
+
/* @__PURE__ */ jsx21(
|
|
1759
|
+
"div",
|
|
1760
|
+
{
|
|
1761
|
+
className: "min-h-0 flex-1 overflow-y-auto",
|
|
1762
|
+
id: hasTabs ? `${uid}-panel` : void 0,
|
|
1763
|
+
role: hasTabs ? "tabpanel" : void 0,
|
|
1764
|
+
"aria-labelledby": hasTabs ? `${uid}-tab-${tab}` : void 0,
|
|
1765
|
+
children
|
|
1766
|
+
}
|
|
1767
|
+
),
|
|
1768
|
+
footer && /* @__PURE__ */ jsx21("div", { className: "shrink-0 border-t border-border px-4 py-3", children: footer })
|
|
1769
|
+
] });
|
|
1770
|
+
}
|
|
1771
|
+
function StudioInspectorSection({
|
|
1772
|
+
title,
|
|
1773
|
+
description,
|
|
1774
|
+
collapsible = false,
|
|
1775
|
+
defaultOpen = false,
|
|
1776
|
+
summary,
|
|
1777
|
+
children,
|
|
1778
|
+
className
|
|
1779
|
+
}) {
|
|
1780
|
+
const uid = React20.useId();
|
|
1781
|
+
const [open, setOpen] = React20.useState(defaultOpen);
|
|
1782
|
+
const expanded = !collapsible || open;
|
|
1783
|
+
return /* @__PURE__ */ jsxs13(
|
|
1784
|
+
"section",
|
|
1785
|
+
{
|
|
1786
|
+
className: cn("border-b border-border px-4 py-4 last:border-b-0", className),
|
|
1787
|
+
"aria-labelledby": title ? `${uid}-title` : void 0,
|
|
1788
|
+
children: [
|
|
1789
|
+
title && (collapsible ? /* @__PURE__ */ jsx21("h3", { id: `${uid}-title`, className: "-my-1", children: /* @__PURE__ */ jsxs13(
|
|
1790
|
+
"button",
|
|
1791
|
+
{
|
|
1792
|
+
type: "button",
|
|
1793
|
+
"aria-expanded": open,
|
|
1794
|
+
"aria-controls": `${uid}-body`,
|
|
1795
|
+
onClick: () => setOpen(!open),
|
|
1796
|
+
className: "flex w-full items-center gap-2 rounded-md py-1 text-left text-sm font-semibold focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
1797
|
+
children: [
|
|
1798
|
+
/* @__PURE__ */ jsx21(
|
|
1799
|
+
StudioIcon,
|
|
1800
|
+
{
|
|
1801
|
+
name: "chevron-right",
|
|
1802
|
+
className: cn("text-muted-foreground transition-transform", open && "rotate-90")
|
|
1803
|
+
}
|
|
1804
|
+
),
|
|
1805
|
+
/* @__PURE__ */ jsx21("span", { className: "flex-1", children: title }),
|
|
1806
|
+
summary && !open && /* @__PURE__ */ jsx21("span", { className: "text-xs font-normal text-muted-foreground", children: summary })
|
|
1807
|
+
]
|
|
1808
|
+
}
|
|
1809
|
+
) }) : /* @__PURE__ */ jsx21("h3", { id: `${uid}-title`, className: "text-sm font-semibold", children: title })),
|
|
1810
|
+
title && description && expanded && /* @__PURE__ */ jsx21("p", { className: "mt-1 text-xs text-muted-foreground", children: description }),
|
|
1811
|
+
expanded && /* @__PURE__ */ jsx21("div", { id: `${uid}-body`, className: cn("space-y-4", title && "mt-3"), children })
|
|
1812
|
+
]
|
|
1813
|
+
}
|
|
1814
|
+
);
|
|
1815
|
+
}
|
|
1816
|
+
function StudioPage({
|
|
1817
|
+
title,
|
|
1818
|
+
description,
|
|
1819
|
+
children,
|
|
1820
|
+
maxWidth = "42rem",
|
|
1821
|
+
className
|
|
1822
|
+
}) {
|
|
1823
|
+
return /* @__PURE__ */ jsx21("div", { className: "h-full overflow-y-auto bg-muted/40", children: /* @__PURE__ */ jsxs13(
|
|
1824
|
+
"div",
|
|
1825
|
+
{
|
|
1826
|
+
className: cn("mx-auto w-full space-y-6 px-4 py-6 md:py-10", className),
|
|
1827
|
+
style: { maxWidth },
|
|
1828
|
+
children: [
|
|
1829
|
+
(title || description) && /* @__PURE__ */ jsxs13("div", { children: [
|
|
1830
|
+
title && /* @__PURE__ */ jsx21("h2", { className: "text-xl font-semibold", children: title }),
|
|
1831
|
+
description && /* @__PURE__ */ jsx21("p", { className: "mt-1 text-sm text-muted-foreground", children: description })
|
|
1832
|
+
] }),
|
|
1833
|
+
children
|
|
1834
|
+
]
|
|
1835
|
+
}
|
|
1836
|
+
) });
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1839
|
+
// src/components/studio/SaveStatus.tsx
|
|
1840
|
+
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
1841
|
+
import { Fragment as Fragment3, jsx as jsx22, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1842
|
+
var META = {
|
|
1843
|
+
saved: { label: "Saved", icon: "check-circle", tone: "text-muted-foreground" },
|
|
1844
|
+
saving: { label: "Saving\u2026", icon: "loader", tone: "text-muted-foreground" },
|
|
1845
|
+
unsaved: { label: "Unsaved", icon: "edit", tone: "text-muted-foreground" },
|
|
1846
|
+
error: { label: "Not saved", icon: "alert-circle", tone: "text-destructive" },
|
|
1847
|
+
offline: { label: "Offline", icon: "wifi-off", tone: "text-warning" },
|
|
1848
|
+
conflict: { label: "Conflict", icon: "alert-triangle", tone: "text-destructive" },
|
|
1849
|
+
invalid: { label: "Needs fixes", icon: "alert-triangle", tone: "text-warning" },
|
|
1850
|
+
readonly: { label: "View only", icon: "eye", tone: "text-muted-foreground" }
|
|
1851
|
+
};
|
|
1852
|
+
var chip = "inline-flex h-8 items-center gap-1.5 rounded-md px-2 text-sm font-medium text-foreground";
|
|
1853
|
+
function SaveStatus({ state, detail, onRetry, label, className }) {
|
|
1854
|
+
const meta = META[state];
|
|
1855
|
+
const text = label ?? meta.label;
|
|
1856
|
+
const canRetry = !!onRetry && (state === "error" || state === "offline");
|
|
1857
|
+
const announced = ["error", "offline", "conflict", "invalid"].includes(state);
|
|
1858
|
+
const content = /* @__PURE__ */ jsxs14(Fragment3, { children: [
|
|
1859
|
+
/* @__PURE__ */ jsx22(
|
|
1860
|
+
StudioIcon,
|
|
1861
|
+
{
|
|
1862
|
+
name: meta.icon,
|
|
1863
|
+
className: cn(meta.tone, state === "saving" && "animate-spin")
|
|
1864
|
+
}
|
|
1865
|
+
),
|
|
1866
|
+
/* @__PURE__ */ jsx22("span", { className: "sr-only sm:not-sr-only", children: text })
|
|
1867
|
+
] });
|
|
1868
|
+
return /* @__PURE__ */ jsxs14("div", { className: cn("inline-flex", className), children: [
|
|
1869
|
+
detail || canRetry ? /* @__PURE__ */ jsxs14(PopoverPrimitive.Root, { children: [
|
|
1870
|
+
/* @__PURE__ */ jsxs14(
|
|
1871
|
+
PopoverPrimitive.Trigger,
|
|
1872
|
+
{
|
|
1873
|
+
className: cn(
|
|
1874
|
+
chip,
|
|
1875
|
+
"hover:bg-muted-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
1876
|
+
),
|
|
1877
|
+
"aria-label": `Save status: ${text}. Show details`,
|
|
1878
|
+
children: [
|
|
1879
|
+
content,
|
|
1880
|
+
/* @__PURE__ */ jsx22(StudioIcon, { name: "chevron-down", size: 14, className: "text-muted-foreground" })
|
|
1881
|
+
]
|
|
1882
|
+
}
|
|
1883
|
+
),
|
|
1884
|
+
/* @__PURE__ */ jsx22(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsxs14(
|
|
1885
|
+
PopoverPrimitive.Content,
|
|
1886
|
+
{
|
|
1887
|
+
align: "end",
|
|
1888
|
+
sideOffset: 6,
|
|
1889
|
+
collisionPadding: 8,
|
|
1890
|
+
className: "z-50 w-72 rounded-md border border-border bg-popover p-3 text-sm text-popover-foreground shadow-md",
|
|
1891
|
+
children: [
|
|
1892
|
+
/* @__PURE__ */ jsx22("p", { className: "font-medium", children: text }),
|
|
1893
|
+
detail && /* @__PURE__ */ jsx22("p", { className: "mt-1 text-muted-foreground", children: detail }),
|
|
1894
|
+
canRetry && /* @__PURE__ */ jsxs14(
|
|
1895
|
+
"button",
|
|
1896
|
+
{
|
|
1897
|
+
type: "button",
|
|
1898
|
+
onClick: onRetry,
|
|
1899
|
+
className: "mt-3 inline-flex h-9 items-center gap-2 rounded-md border-2 border-secondary-border bg-secondary px-3 text-sm font-medium text-secondary-foreground hover:bg-secondary-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
1900
|
+
children: [
|
|
1901
|
+
/* @__PURE__ */ jsx22(StudioIcon, { name: "refresh", size: 14 }),
|
|
1902
|
+
"Retry"
|
|
1903
|
+
]
|
|
1904
|
+
}
|
|
1905
|
+
)
|
|
1906
|
+
]
|
|
1907
|
+
}
|
|
1908
|
+
) })
|
|
1909
|
+
] }) : /* @__PURE__ */ jsx22("span", { className: chip, children: content }),
|
|
1910
|
+
/* @__PURE__ */ jsx22("span", { className: "sr-only", role: "status", "aria-live": "polite", children: announced ? text : "" })
|
|
1911
|
+
] });
|
|
1912
|
+
}
|
|
1913
|
+
|
|
1914
|
+
// src/components/studio/IssuesButton.tsx
|
|
1915
|
+
import * as React21 from "react";
|
|
1916
|
+
import * as PopoverPrimitive2 from "@radix-ui/react-popover";
|
|
1917
|
+
import { Fragment as Fragment4, jsx as jsx23, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1918
|
+
var plural = (n, one, many) => `${n} ${n === 1 ? one : many}`;
|
|
1919
|
+
function IssuesButton({
|
|
1920
|
+
issues,
|
|
1921
|
+
onSelect,
|
|
1922
|
+
open: openProp,
|
|
1923
|
+
onOpenChange,
|
|
1924
|
+
title = "Before you publish",
|
|
1925
|
+
showWhenEmpty = false,
|
|
1926
|
+
className
|
|
1927
|
+
}) {
|
|
1928
|
+
const [innerOpen, setInnerOpen] = React21.useState(false);
|
|
1929
|
+
const open = openProp ?? innerOpen;
|
|
1930
|
+
const setOpen = (next) => {
|
|
1931
|
+
if (openProp === void 0) setInnerOpen(next);
|
|
1932
|
+
onOpenChange?.(next);
|
|
1933
|
+
};
|
|
1934
|
+
const errors = issues.filter((i) => (i.severity ?? "error") === "error");
|
|
1935
|
+
const warnings = issues.filter((i) => i.severity === "warning");
|
|
1936
|
+
const countLabel = [
|
|
1937
|
+
errors.length ? `${plural(errors.length, "issue", "issues")} to fix` : "",
|
|
1938
|
+
warnings.length ? plural(warnings.length, "suggestion", "suggestions") : ""
|
|
1939
|
+
].filter(Boolean).join(", ");
|
|
1940
|
+
if (issues.length === 0) {
|
|
1941
|
+
return showWhenEmpty ? /* @__PURE__ */ jsxs15(
|
|
1942
|
+
"span",
|
|
1943
|
+
{
|
|
1944
|
+
className: cn(
|
|
1945
|
+
"inline-flex h-8 items-center gap-1.5 px-2 text-sm text-muted-foreground",
|
|
1946
|
+
className
|
|
1947
|
+
),
|
|
1948
|
+
children: [
|
|
1949
|
+
/* @__PURE__ */ jsx23(StudioIcon, { name: "check-circle", className: "text-success" }),
|
|
1950
|
+
/* @__PURE__ */ jsx23("span", { className: "sr-only sm:not-sr-only", children: "No issues" })
|
|
1951
|
+
]
|
|
1952
|
+
}
|
|
1953
|
+
) : null;
|
|
1954
|
+
}
|
|
1955
|
+
const group = (list, heading, error) => list.length > 0 && /* @__PURE__ */ jsxs15(Fragment4, { children: [
|
|
1956
|
+
/* @__PURE__ */ jsx23("p", { className: "px-3 pb-1 pt-2 text-xs font-medium uppercase tracking-wide text-muted-foreground", children: heading }),
|
|
1957
|
+
/* @__PURE__ */ jsx23("ul", { className: "pb-1", children: list.map((issue) => /* @__PURE__ */ jsx23("li", { children: /* @__PURE__ */ jsxs15(
|
|
1958
|
+
"button",
|
|
1959
|
+
{
|
|
1960
|
+
type: "button",
|
|
1961
|
+
className: "flex w-full items-start gap-2 px-3 py-2 text-left text-sm hover:bg-muted-hover focus-visible:bg-muted-hover focus-visible:outline-none",
|
|
1962
|
+
onClick: () => {
|
|
1963
|
+
setOpen(false);
|
|
1964
|
+
onSelect?.(issue);
|
|
1965
|
+
},
|
|
1966
|
+
children: [
|
|
1967
|
+
/* @__PURE__ */ jsx23(
|
|
1968
|
+
StudioIcon,
|
|
1969
|
+
{
|
|
1970
|
+
name: error ? "alert-circle" : "info",
|
|
1971
|
+
className: cn("mt-0.5", error ? "text-destructive" : "text-warning")
|
|
1972
|
+
}
|
|
1973
|
+
),
|
|
1974
|
+
/* @__PURE__ */ jsxs15("span", { className: "min-w-0 flex-1", children: [
|
|
1975
|
+
issue.location && /* @__PURE__ */ jsx23("span", { className: "block text-xs text-muted-foreground", children: issue.location }),
|
|
1976
|
+
issue.message
|
|
1977
|
+
] })
|
|
1978
|
+
]
|
|
1979
|
+
}
|
|
1980
|
+
) }, issue.id)) })
|
|
1981
|
+
] });
|
|
1982
|
+
return /* @__PURE__ */ jsxs15(PopoverPrimitive2.Root, { open, onOpenChange: setOpen, children: [
|
|
1983
|
+
/* @__PURE__ */ jsxs15(
|
|
1984
|
+
PopoverPrimitive2.Trigger,
|
|
1985
|
+
{
|
|
1986
|
+
"aria-label": countLabel,
|
|
1987
|
+
className: cn(
|
|
1988
|
+
"inline-flex h-8 items-center gap-1.5 rounded-md px-2 text-sm font-medium hover:bg-muted-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
1989
|
+
className
|
|
1990
|
+
),
|
|
1991
|
+
children: [
|
|
1992
|
+
/* @__PURE__ */ jsx23(
|
|
1993
|
+
StudioIcon,
|
|
1994
|
+
{
|
|
1995
|
+
name: "alert-triangle",
|
|
1996
|
+
className: errors.length ? "text-destructive" : "text-warning"
|
|
1997
|
+
}
|
|
1998
|
+
),
|
|
1999
|
+
/* @__PURE__ */ jsx23("span", { "aria-hidden": "true", children: issues.length })
|
|
2000
|
+
]
|
|
2001
|
+
}
|
|
2002
|
+
),
|
|
2003
|
+
/* @__PURE__ */ jsx23(PopoverPrimitive2.Portal, { children: /* @__PURE__ */ jsxs15(
|
|
2004
|
+
PopoverPrimitive2.Content,
|
|
2005
|
+
{
|
|
2006
|
+
align: "end",
|
|
2007
|
+
sideOffset: 6,
|
|
2008
|
+
collisionPadding: 8,
|
|
2009
|
+
className: "z-50 flex max-h-[min(28rem,70dvh)] w-80 flex-col overflow-hidden rounded-md border border-border bg-popover text-popover-foreground shadow-md",
|
|
2010
|
+
children: [
|
|
2011
|
+
/* @__PURE__ */ jsxs15("div", { className: "border-b border-border px-3 py-2", children: [
|
|
2012
|
+
/* @__PURE__ */ jsx23("p", { className: "text-sm font-semibold", children: title }),
|
|
2013
|
+
/* @__PURE__ */ jsx23("p", { className: "text-xs text-muted-foreground", children: countLabel })
|
|
2014
|
+
] }),
|
|
2015
|
+
/* @__PURE__ */ jsxs15("div", { className: "overflow-y-auto", children: [
|
|
2016
|
+
group(errors, "Must fix", true),
|
|
2017
|
+
group(warnings, "Suggestions", false)
|
|
2018
|
+
] })
|
|
2019
|
+
]
|
|
2020
|
+
}
|
|
2021
|
+
) })
|
|
2022
|
+
] });
|
|
2023
|
+
}
|
|
2024
|
+
|
|
2025
|
+
// src/components/studio/InsertPalette.tsx
|
|
2026
|
+
import * as React22 from "react";
|
|
2027
|
+
import { jsx as jsx24, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2028
|
+
function InsertPalette({
|
|
2029
|
+
open,
|
|
2030
|
+
onOpenChange,
|
|
2031
|
+
groups,
|
|
2032
|
+
onSelect,
|
|
2033
|
+
title = "Add",
|
|
2034
|
+
description,
|
|
2035
|
+
searchPlaceholder = "Search",
|
|
2036
|
+
renderThumbnail
|
|
2037
|
+
}) {
|
|
2038
|
+
const [query, setQuery] = React22.useState("");
|
|
2039
|
+
const listRef = React22.useRef(null);
|
|
2040
|
+
const searchRef = React22.useRef(null);
|
|
2041
|
+
React22.useEffect(() => {
|
|
2042
|
+
if (open) setQuery("");
|
|
2043
|
+
}, [open]);
|
|
2044
|
+
const q = query.trim().toLowerCase();
|
|
2045
|
+
const filtered = q ? groups.map((g) => ({
|
|
2046
|
+
...g,
|
|
2047
|
+
items: g.items.filter(
|
|
2048
|
+
(item) => [item.label, item.description ?? "", ...item.keywords ?? []].some(
|
|
2049
|
+
(t) => t.toLowerCase().includes(q)
|
|
2050
|
+
)
|
|
2051
|
+
)
|
|
2052
|
+
})).filter((g) => g.items.length > 0) : groups;
|
|
2053
|
+
const firstMatch = filtered.flatMap((g) => g.items).find((i) => !i.disabled);
|
|
2054
|
+
const choose = (item) => {
|
|
2055
|
+
if (item.disabled) return;
|
|
2056
|
+
onOpenChange(false);
|
|
2057
|
+
onSelect(item.id);
|
|
2058
|
+
};
|
|
2059
|
+
const entries = () => Array.from(listRef.current?.querySelectorAll("[data-palette-item]") ?? []);
|
|
2060
|
+
return /* @__PURE__ */ jsx24(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxs16(
|
|
2061
|
+
DialogContent,
|
|
2062
|
+
{
|
|
2063
|
+
size: renderThumbnail ? "2xl" : "xl",
|
|
2064
|
+
className: "max-h-[calc(100dvh-2rem)] overflow-y-auto",
|
|
2065
|
+
onOpenAutoFocus: (e) => {
|
|
2066
|
+
e.preventDefault();
|
|
2067
|
+
searchRef.current?.focus();
|
|
2068
|
+
},
|
|
2069
|
+
...description ? {} : { "aria-describedby": void 0 },
|
|
2070
|
+
children: [
|
|
2071
|
+
/* @__PURE__ */ jsx24(DialogTitle, { children: title }),
|
|
2072
|
+
description && /* @__PURE__ */ jsx24(DialogDescription, { children: description }),
|
|
2073
|
+
/* @__PURE__ */ jsxs16("div", { className: "relative", children: [
|
|
2074
|
+
/* @__PURE__ */ jsx24(
|
|
2075
|
+
StudioIcon,
|
|
2076
|
+
{
|
|
2077
|
+
name: "search",
|
|
2078
|
+
className: "pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"
|
|
2079
|
+
}
|
|
2080
|
+
),
|
|
2081
|
+
/* @__PURE__ */ jsx24(
|
|
2082
|
+
"input",
|
|
2083
|
+
{
|
|
2084
|
+
ref: searchRef,
|
|
2085
|
+
type: "search",
|
|
2086
|
+
value: query,
|
|
2087
|
+
onChange: (e) => setQuery(e.target.value),
|
|
2088
|
+
"aria-label": searchPlaceholder,
|
|
2089
|
+
placeholder: searchPlaceholder,
|
|
2090
|
+
className: "h-10 w-full rounded-md border border-input bg-background pl-9 pr-3 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
2091
|
+
onKeyDown: (e) => {
|
|
2092
|
+
if (e.key === "Enter" && firstMatch) {
|
|
2093
|
+
e.preventDefault();
|
|
2094
|
+
choose(firstMatch);
|
|
2095
|
+
} else if (e.key === "ArrowDown") {
|
|
2096
|
+
e.preventDefault();
|
|
2097
|
+
entries()[0]?.focus();
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
2101
|
+
)
|
|
2102
|
+
] }),
|
|
2103
|
+
/* @__PURE__ */ jsxs16("div", { ref: listRef, className: "space-y-5", children: [
|
|
2104
|
+
filtered.length === 0 && /* @__PURE__ */ jsxs16("p", { className: "py-8 text-center text-sm text-muted-foreground", children: [
|
|
2105
|
+
"Nothing matches \u201C",
|
|
2106
|
+
query,
|
|
2107
|
+
"\u201D."
|
|
2108
|
+
] }),
|
|
2109
|
+
filtered.map((group) => /* @__PURE__ */ jsxs16("section", { "aria-label": group.label, children: [
|
|
2110
|
+
/* @__PURE__ */ jsx24("h3", { className: "mb-2 text-xs font-medium uppercase tracking-wide text-muted-foreground", children: group.label }),
|
|
2111
|
+
/* @__PURE__ */ jsx24(
|
|
2112
|
+
"ul",
|
|
2113
|
+
{
|
|
2114
|
+
className: cn(
|
|
2115
|
+
"grid gap-2",
|
|
2116
|
+
renderThumbnail ? "grid-cols-2 sm:grid-cols-3" : "grid-cols-1 sm:grid-cols-2"
|
|
2117
|
+
),
|
|
2118
|
+
children: group.items.map((item) => /* @__PURE__ */ jsx24("li", { children: /* @__PURE__ */ jsxs16(
|
|
2119
|
+
"button",
|
|
2120
|
+
{
|
|
2121
|
+
type: "button",
|
|
2122
|
+
"data-palette-item": "",
|
|
2123
|
+
disabled: item.disabled,
|
|
2124
|
+
onClick: () => choose(item),
|
|
2125
|
+
onKeyDown: (e) => {
|
|
2126
|
+
const all = entries();
|
|
2127
|
+
const index = all.indexOf(e.currentTarget);
|
|
2128
|
+
const step = e.key === "ArrowDown" || e.key === "ArrowRight" ? 1 : e.key === "ArrowUp" || e.key === "ArrowLeft" ? -1 : 0;
|
|
2129
|
+
if (!step) return;
|
|
2130
|
+
e.preventDefault();
|
|
2131
|
+
const next = index + step;
|
|
2132
|
+
if (next < 0) searchRef.current?.focus();
|
|
2133
|
+
else all[Math.min(next, all.length - 1)]?.focus();
|
|
2134
|
+
},
|
|
2135
|
+
className: cn(
|
|
2136
|
+
"flex h-full w-full gap-3 rounded-md border border-border p-3 text-left hover:border-primary hover:bg-primary/5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",
|
|
2137
|
+
renderThumbnail ? "flex-col" : "items-start"
|
|
2138
|
+
),
|
|
2139
|
+
children: [
|
|
2140
|
+
renderThumbnail ? /* @__PURE__ */ jsx24("span", { className: "block overflow-hidden rounded border border-border bg-muted", children: renderThumbnail(item) }) : item.icon && /* @__PURE__ */ jsx24(
|
|
2141
|
+
"span",
|
|
2142
|
+
{
|
|
2143
|
+
className: "flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-muted text-foreground",
|
|
2144
|
+
"aria-hidden": "true",
|
|
2145
|
+
children: item.icon
|
|
2146
|
+
}
|
|
2147
|
+
),
|
|
2148
|
+
/* @__PURE__ */ jsxs16("span", { className: "min-w-0", children: [
|
|
2149
|
+
/* @__PURE__ */ jsx24("span", { className: "block text-sm font-medium", children: item.label }),
|
|
2150
|
+
item.description && /* @__PURE__ */ jsx24("span", { className: "mt-0.5 block text-xs text-muted-foreground", children: item.description })
|
|
2151
|
+
] })
|
|
2152
|
+
]
|
|
2153
|
+
}
|
|
2154
|
+
) }, item.id))
|
|
2155
|
+
}
|
|
2156
|
+
)
|
|
2157
|
+
] }, group.label))
|
|
2158
|
+
] })
|
|
2159
|
+
]
|
|
2160
|
+
}
|
|
2161
|
+
) });
|
|
2162
|
+
}
|
|
2163
|
+
|
|
2164
|
+
// src/components/DataPanel.tsx
|
|
2165
|
+
import * as React24 from "react";
|
|
2166
|
+
import * as DropdownMenuPrimitive2 from "@radix-ui/react-dropdown-menu";
|
|
680
2167
|
|
|
681
2168
|
// src/hooks/useFocusTrap.ts
|
|
682
|
-
import { useEffect as
|
|
2169
|
+
import { useEffect as useEffect7, useRef as useRef7, useCallback as useCallback3 } from "react";
|
|
683
2170
|
var FOCUSABLE_SELECTOR = [
|
|
684
2171
|
"a[href]",
|
|
685
2172
|
"area[href]",
|
|
@@ -701,9 +2188,9 @@ function getFocusableElements(container) {
|
|
|
701
2188
|
}
|
|
702
2189
|
function useFocusTrap(options = {}) {
|
|
703
2190
|
const { active = true, returnFocusTo, initialFocus, preventScroll = false } = options;
|
|
704
|
-
const containerRef =
|
|
705
|
-
const previousActiveElementRef =
|
|
706
|
-
const handleKeyDown =
|
|
2191
|
+
const containerRef = useRef7(null);
|
|
2192
|
+
const previousActiveElementRef = useRef7(null);
|
|
2193
|
+
const handleKeyDown = useCallback3(
|
|
707
2194
|
(event) => {
|
|
708
2195
|
if (!active || event.key !== "Tab") return;
|
|
709
2196
|
const container = containerRef.current;
|
|
@@ -726,7 +2213,7 @@ function useFocusTrap(options = {}) {
|
|
|
726
2213
|
},
|
|
727
2214
|
[active, preventScroll]
|
|
728
2215
|
);
|
|
729
|
-
|
|
2216
|
+
useEffect7(() => {
|
|
730
2217
|
if (!active) return;
|
|
731
2218
|
const container = containerRef.current;
|
|
732
2219
|
if (!container) return;
|
|
@@ -757,14 +2244,14 @@ function useFocusTrap(options = {}) {
|
|
|
757
2244
|
}
|
|
758
2245
|
|
|
759
2246
|
// src/hooks/useEscapeKey.ts
|
|
760
|
-
import * as
|
|
2247
|
+
import * as React23 from "react";
|
|
761
2248
|
function useEscapeKey(callback, options) {
|
|
762
2249
|
const { enabled = true, preventDefault = true, stopPropagation = false } = options ?? {};
|
|
763
|
-
const callbackRef =
|
|
764
|
-
|
|
2250
|
+
const callbackRef = React23.useRef(callback);
|
|
2251
|
+
React23.useEffect(() => {
|
|
765
2252
|
callbackRef.current = callback;
|
|
766
2253
|
}, [callback]);
|
|
767
|
-
|
|
2254
|
+
React23.useEffect(() => {
|
|
768
2255
|
if (!enabled) return;
|
|
769
2256
|
const handleKeyDown = (event) => {
|
|
770
2257
|
if (event.key === "Escape") {
|
|
@@ -819,12 +2306,15 @@ import {
|
|
|
819
2306
|
calculateDetachedPositionFromPinned,
|
|
820
2307
|
getPinnedPullTransform
|
|
821
2308
|
} from "@classic-homes/data-panel-core";
|
|
822
|
-
import { Fragment, jsx as
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
var
|
|
827
|
-
var
|
|
2309
|
+
import { Fragment as Fragment5, jsx as jsx25, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2310
|
+
function layoutViewportWidth() {
|
|
2311
|
+
return document.documentElement.clientWidth;
|
|
2312
|
+
}
|
|
2313
|
+
var DropdownTrigger = DropdownMenuPrimitive2.Trigger;
|
|
2314
|
+
var DropdownContent = DropdownMenuPrimitive2.Content;
|
|
2315
|
+
var DropdownLabel = DropdownMenuPrimitive2.Label;
|
|
2316
|
+
var DropdownItem = DropdownMenuPrimitive2.Item;
|
|
2317
|
+
var DropdownSeparator = DropdownMenuPrimitive2.Separator;
|
|
828
2318
|
function useDataPanel(options = {}) {
|
|
829
2319
|
const {
|
|
830
2320
|
persistKey,
|
|
@@ -834,28 +2324,28 @@ function useDataPanel(options = {}) {
|
|
|
834
2324
|
constraints = {}
|
|
835
2325
|
} = options;
|
|
836
2326
|
const resolvedConstraints = { ...DEFAULT_CONSTRAINTS, ...constraints };
|
|
837
|
-
const [persistedState] =
|
|
2327
|
+
const [persistedState] = React24.useState(() => {
|
|
838
2328
|
if (persistKey && typeof window !== "undefined") {
|
|
839
2329
|
return loadPanelState(persistKey);
|
|
840
2330
|
}
|
|
841
2331
|
return null;
|
|
842
2332
|
});
|
|
843
|
-
const [mode, setMode] =
|
|
844
|
-
const [edge, setEdge] =
|
|
845
|
-
const [isExpanded, setIsExpanded] =
|
|
2333
|
+
const [mode, setMode] = React24.useState(persistedState?.mode ?? initialMode);
|
|
2334
|
+
const [edge, setEdge] = React24.useState(persistedState?.edge ?? initialEdge);
|
|
2335
|
+
const [isExpanded, setIsExpanded] = React24.useState(
|
|
846
2336
|
persistedState?.isExpanded ?? initialExpanded
|
|
847
2337
|
);
|
|
848
|
-
const [detachedPosition, setDetachedPosition] =
|
|
2338
|
+
const [detachedPosition, setDetachedPosition] = React24.useState(
|
|
849
2339
|
persistedState?.detachedPosition ?? DEFAULT_PANEL_STATE.detachedPosition
|
|
850
2340
|
);
|
|
851
|
-
const [detachedSize, setDetachedSize] =
|
|
2341
|
+
const [detachedSize, setDetachedSize] = React24.useState(
|
|
852
2342
|
persistedState?.detachedSize ?? DEFAULT_PANEL_STATE.detachedSize
|
|
853
2343
|
);
|
|
854
|
-
const [pinnedSize, setPinnedSize] =
|
|
2344
|
+
const [pinnedSize, setPinnedSize] = React24.useState(
|
|
855
2345
|
persistedState?.pinnedSize ?? DEFAULT_PANEL_STATE.pinnedSize
|
|
856
2346
|
);
|
|
857
|
-
const saveTimeoutRef =
|
|
858
|
-
const debouncedSave =
|
|
2347
|
+
const saveTimeoutRef = React24.useRef(null);
|
|
2348
|
+
const debouncedSave = React24.useCallback(() => {
|
|
859
2349
|
if (!persistKey) return;
|
|
860
2350
|
if (saveTimeoutRef.current) {
|
|
861
2351
|
clearTimeout(saveTimeoutRef.current);
|
|
@@ -874,50 +2364,50 @@ function useDataPanel(options = {}) {
|
|
|
874
2364
|
});
|
|
875
2365
|
}, 300);
|
|
876
2366
|
}, [persistKey, mode, edge, isExpanded, detachedPosition, detachedSize, pinnedSize]);
|
|
877
|
-
const handleSetMode =
|
|
2367
|
+
const handleSetMode = React24.useCallback(
|
|
878
2368
|
(newMode) => {
|
|
879
2369
|
setMode(newMode);
|
|
880
2370
|
if (newMode === "detached" && typeof window !== "undefined" && detachedPosition.x === DEFAULT_PANEL_STATE.detachedPosition.x && detachedPosition.y === DEFAULT_PANEL_STATE.detachedPosition.y) {
|
|
881
2371
|
setDetachedPosition(
|
|
882
|
-
getInitialDetachedPosition(detachedSize,
|
|
2372
|
+
getInitialDetachedPosition(detachedSize, layoutViewportWidth(), window.innerHeight)
|
|
883
2373
|
);
|
|
884
2374
|
}
|
|
885
2375
|
},
|
|
886
2376
|
[detachedPosition, detachedSize]
|
|
887
2377
|
);
|
|
888
|
-
const handleSetDetachedPosition =
|
|
2378
|
+
const handleSetDetachedPosition = React24.useCallback(
|
|
889
2379
|
(position) => {
|
|
890
2380
|
if (typeof window === "undefined") {
|
|
891
2381
|
setDetachedPosition(position);
|
|
892
2382
|
return;
|
|
893
2383
|
}
|
|
894
2384
|
setDetachedPosition(
|
|
895
|
-
constrainPosition(position, detachedSize,
|
|
2385
|
+
constrainPosition(position, detachedSize, layoutViewportWidth(), window.innerHeight)
|
|
896
2386
|
);
|
|
897
2387
|
},
|
|
898
2388
|
[detachedSize]
|
|
899
2389
|
);
|
|
900
|
-
const handleSetDetachedSize =
|
|
2390
|
+
const handleSetDetachedSize = React24.useCallback(
|
|
901
2391
|
(size) => {
|
|
902
2392
|
setDetachedSize(constrainSize(size, resolvedConstraints));
|
|
903
2393
|
},
|
|
904
2394
|
[resolvedConstraints]
|
|
905
2395
|
);
|
|
906
|
-
const handleSetPinnedSize =
|
|
2396
|
+
const handleSetPinnedSize = React24.useCallback(
|
|
907
2397
|
(size) => {
|
|
908
2398
|
if (typeof window === "undefined") {
|
|
909
2399
|
setPinnedSize(size);
|
|
910
2400
|
return;
|
|
911
2401
|
}
|
|
912
2402
|
if (isHorizontalEdge(edge)) {
|
|
913
|
-
setPinnedSize(constrainPinnedWidth(size, resolvedConstraints,
|
|
2403
|
+
setPinnedSize(constrainPinnedWidth(size, resolvedConstraints, layoutViewportWidth()));
|
|
914
2404
|
} else {
|
|
915
2405
|
setPinnedSize(constrainPinnedHeight(size, resolvedConstraints, window.innerHeight));
|
|
916
2406
|
}
|
|
917
2407
|
},
|
|
918
2408
|
[edge, resolvedConstraints]
|
|
919
2409
|
);
|
|
920
|
-
|
|
2410
|
+
React24.useEffect(() => {
|
|
921
2411
|
debouncedSave();
|
|
922
2412
|
}, [debouncedSave]);
|
|
923
2413
|
return {
|
|
@@ -935,7 +2425,7 @@ function useDataPanel(options = {}) {
|
|
|
935
2425
|
setPinnedSize: handleSetPinnedSize
|
|
936
2426
|
};
|
|
937
2427
|
}
|
|
938
|
-
var ChevronUpIcon = () => /* @__PURE__ */
|
|
2428
|
+
var ChevronUpIcon = () => /* @__PURE__ */ jsx25(
|
|
939
2429
|
"svg",
|
|
940
2430
|
{
|
|
941
2431
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -947,10 +2437,10 @@ var ChevronUpIcon = () => /* @__PURE__ */ jsx12(
|
|
|
947
2437
|
strokeWidth: "2",
|
|
948
2438
|
strokeLinecap: "round",
|
|
949
2439
|
strokeLinejoin: "round",
|
|
950
|
-
children: /* @__PURE__ */
|
|
2440
|
+
children: /* @__PURE__ */ jsx25("path", { d: "m18 15-6-6-6 6" })
|
|
951
2441
|
}
|
|
952
2442
|
);
|
|
953
|
-
var MoreVerticalIcon = () => /* @__PURE__ */
|
|
2443
|
+
var MoreVerticalIcon = () => /* @__PURE__ */ jsxs17(
|
|
954
2444
|
"svg",
|
|
955
2445
|
{
|
|
956
2446
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -963,13 +2453,13 @@ var MoreVerticalIcon = () => /* @__PURE__ */ jsxs5(
|
|
|
963
2453
|
strokeLinecap: "round",
|
|
964
2454
|
strokeLinejoin: "round",
|
|
965
2455
|
children: [
|
|
966
|
-
/* @__PURE__ */
|
|
967
|
-
/* @__PURE__ */
|
|
968
|
-
/* @__PURE__ */
|
|
2456
|
+
/* @__PURE__ */ jsx25("circle", { cx: "12", cy: "12", r: "1" }),
|
|
2457
|
+
/* @__PURE__ */ jsx25("circle", { cx: "12", cy: "5", r: "1" }),
|
|
2458
|
+
/* @__PURE__ */ jsx25("circle", { cx: "12", cy: "19", r: "1" })
|
|
969
2459
|
]
|
|
970
2460
|
}
|
|
971
2461
|
);
|
|
972
|
-
var CloseIcon = () => /* @__PURE__ */
|
|
2462
|
+
var CloseIcon = () => /* @__PURE__ */ jsxs17(
|
|
973
2463
|
"svg",
|
|
974
2464
|
{
|
|
975
2465
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -982,12 +2472,12 @@ var CloseIcon = () => /* @__PURE__ */ jsxs5(
|
|
|
982
2472
|
strokeLinecap: "round",
|
|
983
2473
|
strokeLinejoin: "round",
|
|
984
2474
|
children: [
|
|
985
|
-
/* @__PURE__ */
|
|
986
|
-
/* @__PURE__ */
|
|
2475
|
+
/* @__PURE__ */ jsx25("path", { d: "M18 6 6 18" }),
|
|
2476
|
+
/* @__PURE__ */ jsx25("path", { d: "m6 6 12 12" })
|
|
987
2477
|
]
|
|
988
2478
|
}
|
|
989
2479
|
);
|
|
990
|
-
var GripIcon = () => /* @__PURE__ */
|
|
2480
|
+
var GripIcon = () => /* @__PURE__ */ jsxs17(
|
|
991
2481
|
"svg",
|
|
992
2482
|
{
|
|
993
2483
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -996,12 +2486,12 @@ var GripIcon = () => /* @__PURE__ */ jsxs5(
|
|
|
996
2486
|
viewBox: "0 0 24 24",
|
|
997
2487
|
fill: "currentColor",
|
|
998
2488
|
children: [
|
|
999
|
-
/* @__PURE__ */
|
|
1000
|
-
/* @__PURE__ */
|
|
1001
|
-
/* @__PURE__ */
|
|
1002
|
-
/* @__PURE__ */
|
|
1003
|
-
/* @__PURE__ */
|
|
1004
|
-
/* @__PURE__ */
|
|
2489
|
+
/* @__PURE__ */ jsx25("circle", { cx: "9", cy: "6", r: "1.5" }),
|
|
2490
|
+
/* @__PURE__ */ jsx25("circle", { cx: "15", cy: "6", r: "1.5" }),
|
|
2491
|
+
/* @__PURE__ */ jsx25("circle", { cx: "9", cy: "12", r: "1.5" }),
|
|
2492
|
+
/* @__PURE__ */ jsx25("circle", { cx: "15", cy: "12", r: "1.5" }),
|
|
2493
|
+
/* @__PURE__ */ jsx25("circle", { cx: "9", cy: "18", r: "1.5" }),
|
|
2494
|
+
/* @__PURE__ */ jsx25("circle", { cx: "15", cy: "18", r: "1.5" })
|
|
1005
2495
|
]
|
|
1006
2496
|
}
|
|
1007
2497
|
);
|
|
@@ -1011,7 +2501,7 @@ var edgeLabels = {
|
|
|
1011
2501
|
top: "Pin to top",
|
|
1012
2502
|
bottom: "Pin to bottom"
|
|
1013
2503
|
};
|
|
1014
|
-
var DataPanelHeader =
|
|
2504
|
+
var DataPanelHeader = React24.forwardRef(
|
|
1015
2505
|
({
|
|
1016
2506
|
title,
|
|
1017
2507
|
subtitle,
|
|
@@ -1030,7 +2520,7 @@ var DataPanelHeader = React14.forwardRef(
|
|
|
1030
2520
|
className,
|
|
1031
2521
|
draggable = false
|
|
1032
2522
|
}, ref) => {
|
|
1033
|
-
return /* @__PURE__ */
|
|
2523
|
+
return /* @__PURE__ */ jsxs17(
|
|
1034
2524
|
"div",
|
|
1035
2525
|
{
|
|
1036
2526
|
ref,
|
|
@@ -1041,13 +2531,13 @@ var DataPanelHeader = React14.forwardRef(
|
|
|
1041
2531
|
),
|
|
1042
2532
|
"data-panel-header": true,
|
|
1043
2533
|
children: [
|
|
1044
|
-
/* @__PURE__ */
|
|
1045
|
-
title && /* @__PURE__ */
|
|
1046
|
-
subtitle && /* @__PURE__ */
|
|
2534
|
+
/* @__PURE__ */ jsx25("div", { className: "flex flex-col min-w-0 flex-1", children: headerContent ? headerContent : /* @__PURE__ */ jsxs17(Fragment5, { children: [
|
|
2535
|
+
title && /* @__PURE__ */ jsx25("h3", { id: titleId, className: "text-sm font-semibold leading-none truncate", children: title }),
|
|
2536
|
+
subtitle && /* @__PURE__ */ jsx25("p", { className: "text-xs text-muted-foreground mt-1 truncate", children: subtitle })
|
|
1047
2537
|
] }) }),
|
|
1048
|
-
/* @__PURE__ */
|
|
2538
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex items-center gap-1 shrink-0", children: [
|
|
1049
2539
|
headerActions,
|
|
1050
|
-
/* @__PURE__ */
|
|
2540
|
+
/* @__PURE__ */ jsx25(
|
|
1051
2541
|
"button",
|
|
1052
2542
|
{
|
|
1053
2543
|
type: "button",
|
|
@@ -1062,37 +2552,37 @@ var DataPanelHeader = React14.forwardRef(
|
|
|
1062
2552
|
},
|
|
1063
2553
|
"aria-label": isExpanded ? "Collapse panel" : "Expand panel",
|
|
1064
2554
|
"aria-expanded": isExpanded,
|
|
1065
|
-
children: /* @__PURE__ */
|
|
2555
|
+
children: /* @__PURE__ */ jsx25(
|
|
1066
2556
|
"span",
|
|
1067
2557
|
{
|
|
1068
2558
|
className: cn(
|
|
1069
2559
|
"transition-transform",
|
|
1070
2560
|
{ top: "", bottom: "rotate-180", left: "-rotate-90", right: "rotate-90" }[edge]
|
|
1071
2561
|
),
|
|
1072
|
-
children: /* @__PURE__ */
|
|
2562
|
+
children: /* @__PURE__ */ jsx25(ChevronUpIcon, {})
|
|
1073
2563
|
}
|
|
1074
2564
|
)
|
|
1075
2565
|
}
|
|
1076
2566
|
),
|
|
1077
|
-
!disableModeSwitch && /* @__PURE__ */
|
|
1078
|
-
/* @__PURE__ */
|
|
2567
|
+
!disableModeSwitch && /* @__PURE__ */ jsxs17(DropdownMenuPrimitive2.Root, { children: [
|
|
2568
|
+
/* @__PURE__ */ jsx25(DropdownTrigger, { asChild: true, children: /* @__PURE__ */ jsx25(
|
|
1079
2569
|
"button",
|
|
1080
2570
|
{
|
|
1081
2571
|
type: "button",
|
|
1082
2572
|
className: "relative flex h-8 w-8 items-center justify-center rounded-md before:absolute before:-inset-1.5 before:content-[''] bg-transparent text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
1083
2573
|
"aria-label": "Panel options",
|
|
1084
|
-
children: /* @__PURE__ */
|
|
2574
|
+
children: /* @__PURE__ */ jsx25(MoreVerticalIcon, {})
|
|
1085
2575
|
}
|
|
1086
2576
|
) }),
|
|
1087
|
-
/* @__PURE__ */
|
|
2577
|
+
/* @__PURE__ */ jsx25(DropdownMenuPrimitive2.Portal, { children: /* @__PURE__ */ jsxs17(
|
|
1088
2578
|
DropdownContent,
|
|
1089
2579
|
{
|
|
1090
2580
|
className: "z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95",
|
|
1091
2581
|
sideOffset: 4,
|
|
1092
2582
|
align: "end",
|
|
1093
2583
|
children: [
|
|
1094
|
-
/* @__PURE__ */
|
|
1095
|
-
["left", "right", "top", "bottom"].map((e) => /* @__PURE__ */
|
|
2584
|
+
/* @__PURE__ */ jsx25(DropdownLabel, { className: "px-2 py-1.5 text-sm font-semibold", children: "Panel Position" }),
|
|
2585
|
+
["left", "right", "top", "bottom"].map((e) => /* @__PURE__ */ jsxs17(
|
|
1096
2586
|
DropdownItem,
|
|
1097
2587
|
{
|
|
1098
2588
|
className: "relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none bg-popover focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
@@ -1102,20 +2592,20 @@ var DataPanelHeader = React14.forwardRef(
|
|
|
1102
2592
|
},
|
|
1103
2593
|
children: [
|
|
1104
2594
|
edgeLabels[e],
|
|
1105
|
-
mode === "pinned" && edge === e && /* @__PURE__ */
|
|
2595
|
+
mode === "pinned" && edge === e && /* @__PURE__ */ jsx25("span", { className: "ml-auto text-xs", children: "\u2713" })
|
|
1106
2596
|
]
|
|
1107
2597
|
},
|
|
1108
2598
|
e
|
|
1109
2599
|
)),
|
|
1110
|
-
/* @__PURE__ */
|
|
1111
|
-
/* @__PURE__ */
|
|
2600
|
+
/* @__PURE__ */ jsx25(DropdownSeparator, { className: "-mx-1 my-1 h-px bg-muted" }),
|
|
2601
|
+
/* @__PURE__ */ jsxs17(
|
|
1112
2602
|
DropdownItem,
|
|
1113
2603
|
{
|
|
1114
2604
|
className: "relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none bg-popover focus:bg-accent focus:text-accent-foreground",
|
|
1115
2605
|
onSelect: () => onModeChange?.("detached"),
|
|
1116
2606
|
children: [
|
|
1117
2607
|
"Detach",
|
|
1118
|
-
mode === "detached" && /* @__PURE__ */
|
|
2608
|
+
mode === "detached" && /* @__PURE__ */ jsx25("span", { className: "ml-auto text-xs", children: "\u2713" })
|
|
1119
2609
|
]
|
|
1120
2610
|
}
|
|
1121
2611
|
)
|
|
@@ -1123,14 +2613,14 @@ var DataPanelHeader = React14.forwardRef(
|
|
|
1123
2613
|
}
|
|
1124
2614
|
) })
|
|
1125
2615
|
] }),
|
|
1126
|
-
!disableClose && /* @__PURE__ */
|
|
2616
|
+
!disableClose && /* @__PURE__ */ jsx25(
|
|
1127
2617
|
"button",
|
|
1128
2618
|
{
|
|
1129
2619
|
type: "button",
|
|
1130
2620
|
className: "relative flex h-8 w-8 items-center justify-center rounded-md before:absolute before:-inset-1.5 before:content-[''] bg-transparent text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
1131
2621
|
onClick: onClose,
|
|
1132
2622
|
"aria-label": "Close panel",
|
|
1133
|
-
children: /* @__PURE__ */
|
|
2623
|
+
children: /* @__PURE__ */ jsx25(CloseIcon, {})
|
|
1134
2624
|
}
|
|
1135
2625
|
)
|
|
1136
2626
|
] })
|
|
@@ -1154,14 +2644,14 @@ function DataPanelCardHeader({
|
|
|
1154
2644
|
onToggleExpand,
|
|
1155
2645
|
onClose
|
|
1156
2646
|
}) {
|
|
1157
|
-
return /* @__PURE__ */
|
|
2647
|
+
return /* @__PURE__ */ jsxs17(
|
|
1158
2648
|
"div",
|
|
1159
2649
|
{
|
|
1160
2650
|
"data-panel-header": true,
|
|
1161
2651
|
className: "relative flex items-center justify-between gap-2 border-b border-border bg-muted/30 px-4 pt-5 pb-3 cursor-pointer",
|
|
1162
2652
|
onPointerDown: onHeaderPointerDown,
|
|
1163
2653
|
children: [
|
|
1164
|
-
showDragHandle && /* @__PURE__ */
|
|
2654
|
+
showDragHandle && /* @__PURE__ */ jsx25(
|
|
1165
2655
|
"div",
|
|
1166
2656
|
{
|
|
1167
2657
|
className: "absolute top-1.5 left-1/2 -translate-x-1/2 w-10 h-1.5 rounded-full bg-muted-foreground/30 cursor-pointer touch-none",
|
|
@@ -1173,22 +2663,22 @@ function DataPanelCardHeader({
|
|
|
1173
2663
|
onKeyDown: (e) => (e.key === "Enter" || e.key === " ") && onToggleExpand()
|
|
1174
2664
|
}
|
|
1175
2665
|
),
|
|
1176
|
-
/* @__PURE__ */
|
|
2666
|
+
/* @__PURE__ */ jsx25(
|
|
1177
2667
|
"div",
|
|
1178
2668
|
{
|
|
1179
2669
|
className: "flex-1 min-w-0",
|
|
1180
2670
|
role: "button",
|
|
1181
2671
|
tabIndex: 0,
|
|
1182
2672
|
onKeyDown: (e) => (e.key === "Enter" || e.key === " ") && onToggleExpand(),
|
|
1183
|
-
children: headerContent ? headerContent : /* @__PURE__ */
|
|
1184
|
-
subtitle && /* @__PURE__ */
|
|
1185
|
-
title && /* @__PURE__ */
|
|
2673
|
+
children: headerContent ? headerContent : /* @__PURE__ */ jsxs17(Fragment5, { children: [
|
|
2674
|
+
subtitle && /* @__PURE__ */ jsx25("p", { className: "text-sm text-muted-foreground truncate", children: subtitle }),
|
|
2675
|
+
title && /* @__PURE__ */ jsx25("h3", { id: titleId, className: "text-lg font-semibold truncate", children: title })
|
|
1186
2676
|
] })
|
|
1187
2677
|
}
|
|
1188
2678
|
),
|
|
1189
|
-
/* @__PURE__ */
|
|
2679
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex items-center gap-1 shrink-0", children: [
|
|
1190
2680
|
headerActions,
|
|
1191
|
-
!isMobile && /* @__PURE__ */
|
|
2681
|
+
!isMobile && /* @__PURE__ */ jsx25(
|
|
1192
2682
|
"button",
|
|
1193
2683
|
{
|
|
1194
2684
|
"data-card-drag-handle": true,
|
|
@@ -1197,10 +2687,10 @@ function DataPanelCardHeader({
|
|
|
1197
2687
|
"aria-label": "Drag to reposition panel",
|
|
1198
2688
|
title: "Drag to move",
|
|
1199
2689
|
onPointerDown: onHeaderPointerDown,
|
|
1200
|
-
children: /* @__PURE__ */
|
|
2690
|
+
children: /* @__PURE__ */ jsx25(GripIcon, {})
|
|
1201
2691
|
}
|
|
1202
2692
|
),
|
|
1203
|
-
/* @__PURE__ */
|
|
2693
|
+
/* @__PURE__ */ jsx25(
|
|
1204
2694
|
"button",
|
|
1205
2695
|
{
|
|
1206
2696
|
type: "button",
|
|
@@ -1209,17 +2699,17 @@ function DataPanelCardHeader({
|
|
|
1209
2699
|
"aria-expanded": isExpanded,
|
|
1210
2700
|
"aria-label": isExpanded ? "Collapse panel" : "Expand panel",
|
|
1211
2701
|
title: isExpanded ? "Collapse" : "Expand",
|
|
1212
|
-
children: /* @__PURE__ */
|
|
2702
|
+
children: /* @__PURE__ */ jsx25("span", { className: cn("inline-flex transition-transform", isExpanded && "rotate-180"), children: /* @__PURE__ */ jsx25(ChevronUpIcon, {}) })
|
|
1213
2703
|
}
|
|
1214
2704
|
),
|
|
1215
|
-
!disableClose && /* @__PURE__ */
|
|
2705
|
+
!disableClose && /* @__PURE__ */ jsx25(
|
|
1216
2706
|
"button",
|
|
1217
2707
|
{
|
|
1218
2708
|
type: "button",
|
|
1219
2709
|
className: "relative flex h-8 w-8 items-center justify-center rounded-md before:absolute before:-inset-1.5 before:content-[''] text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
1220
2710
|
onClick: onClose,
|
|
1221
2711
|
"aria-label": "Close panel",
|
|
1222
|
-
children: /* @__PURE__ */
|
|
2712
|
+
children: /* @__PURE__ */ jsx25(CloseIcon, {})
|
|
1223
2713
|
}
|
|
1224
2714
|
)
|
|
1225
2715
|
] })
|
|
@@ -1227,9 +2717,9 @@ function DataPanelCardHeader({
|
|
|
1227
2717
|
}
|
|
1228
2718
|
);
|
|
1229
2719
|
}
|
|
1230
|
-
var DataPanelContent =
|
|
2720
|
+
var DataPanelContent = React24.forwardRef(
|
|
1231
2721
|
({ children, className, "aria-label": ariaLabel = "Panel content" }, ref) => {
|
|
1232
|
-
return /* @__PURE__ */
|
|
2722
|
+
return /* @__PURE__ */ jsx25(
|
|
1233
2723
|
"div",
|
|
1234
2724
|
{
|
|
1235
2725
|
ref,
|
|
@@ -1242,7 +2732,7 @@ var DataPanelContent = React14.forwardRef(
|
|
|
1242
2732
|
}
|
|
1243
2733
|
);
|
|
1244
2734
|
DataPanelContent.displayName = "DataPanelContent";
|
|
1245
|
-
var DataPanelFooter =
|
|
2735
|
+
var DataPanelFooter = React24.forwardRef(
|
|
1246
2736
|
({ actions = [], footerContent, footerActions, className }, ref) => {
|
|
1247
2737
|
if (!footerContent && actions.length === 0 && !footerActions) {
|
|
1248
2738
|
return null;
|
|
@@ -1251,7 +2741,7 @@ var DataPanelFooter = React14.forwardRef(
|
|
|
1251
2741
|
if (variant === "primary") return "default";
|
|
1252
2742
|
return variant ?? "default";
|
|
1253
2743
|
};
|
|
1254
|
-
return /* @__PURE__ */
|
|
2744
|
+
return /* @__PURE__ */ jsx25(
|
|
1255
2745
|
"div",
|
|
1256
2746
|
{
|
|
1257
2747
|
ref,
|
|
@@ -1259,9 +2749,9 @@ var DataPanelFooter = React14.forwardRef(
|
|
|
1259
2749
|
"flex items-center justify-end gap-2 border-t border-border bg-muted/30 px-4 py-3",
|
|
1260
2750
|
className
|
|
1261
2751
|
),
|
|
1262
|
-
children: footerContent ? footerContent : /* @__PURE__ */
|
|
2752
|
+
children: footerContent ? footerContent : /* @__PURE__ */ jsxs17(Fragment5, { children: [
|
|
1263
2753
|
footerActions,
|
|
1264
|
-
actions.map((action, index) => /* @__PURE__ */
|
|
2754
|
+
actions.map((action, index) => /* @__PURE__ */ jsx25(
|
|
1265
2755
|
Button,
|
|
1266
2756
|
{
|
|
1267
2757
|
variant: mapVariant(action.variant),
|
|
@@ -1278,7 +2768,7 @@ var DataPanelFooter = React14.forwardRef(
|
|
|
1278
2768
|
}
|
|
1279
2769
|
);
|
|
1280
2770
|
DataPanelFooter.displayName = "DataPanelFooter";
|
|
1281
|
-
var DataPanelTab =
|
|
2771
|
+
var DataPanelTab = React24.forwardRef(
|
|
1282
2772
|
({
|
|
1283
2773
|
title = "Panel",
|
|
1284
2774
|
subtitle,
|
|
@@ -1304,15 +2794,15 @@ var DataPanelTab = React14.forwardRef(
|
|
|
1304
2794
|
bottom: "left-1/2 rounded-t-lg border-b-0"
|
|
1305
2795
|
}[edge];
|
|
1306
2796
|
const insetStyle = { [edge]: tabInset };
|
|
1307
|
-
const innerRef =
|
|
1308
|
-
const dragRef =
|
|
2797
|
+
const innerRef = React24.useRef(null);
|
|
2798
|
+
const dragRef = React24.useRef({
|
|
1309
2799
|
startX: 0,
|
|
1310
2800
|
startY: 0,
|
|
1311
2801
|
startOffset: 0,
|
|
1312
2802
|
moved: false,
|
|
1313
2803
|
pointerId: -1
|
|
1314
2804
|
});
|
|
1315
|
-
const [dragOffset, setDragOffset] =
|
|
2805
|
+
const [dragOffset, setDragOffset] = React24.useState(null);
|
|
1316
2806
|
const effectiveOffset = dragOffset ?? offset;
|
|
1317
2807
|
const draggable = !!onOffsetChange;
|
|
1318
2808
|
const tabTransform = getTabTransform(edge, tabWidth, effectiveOffset);
|
|
@@ -1346,7 +2836,7 @@ var DataPanelTab = React14.forwardRef(
|
|
|
1346
2836
|
d.startOffset + delta,
|
|
1347
2837
|
edge,
|
|
1348
2838
|
tabBounds,
|
|
1349
|
-
|
|
2839
|
+
layoutViewportWidth(),
|
|
1350
2840
|
window.innerHeight
|
|
1351
2841
|
)
|
|
1352
2842
|
);
|
|
@@ -1381,14 +2871,14 @@ var DataPanelTab = React14.forwardRef(
|
|
|
1381
2871
|
onClick?.();
|
|
1382
2872
|
}
|
|
1383
2873
|
};
|
|
1384
|
-
|
|
2874
|
+
React24.useEffect(() => {
|
|
1385
2875
|
if (!onOffsetChange || dragOffset !== null) return;
|
|
1386
2876
|
const reclamp = () => {
|
|
1387
2877
|
const clamped = constrainTabOffset(
|
|
1388
2878
|
offset,
|
|
1389
2879
|
edge,
|
|
1390
2880
|
tabBounds,
|
|
1391
|
-
|
|
2881
|
+
layoutViewportWidth(),
|
|
1392
2882
|
window.innerHeight
|
|
1393
2883
|
);
|
|
1394
2884
|
if (clamped !== offset) onOffsetChange(clamped);
|
|
@@ -1397,7 +2887,7 @@ var DataPanelTab = React14.forwardRef(
|
|
|
1397
2887
|
window.addEventListener("resize", reclamp);
|
|
1398
2888
|
return () => window.removeEventListener("resize", reclamp);
|
|
1399
2889
|
}, [edge, tabWidth, offset, onOffsetChange, dragOffset]);
|
|
1400
|
-
return /* @__PURE__ */
|
|
2890
|
+
return /* @__PURE__ */ jsxs17(
|
|
1401
2891
|
"div",
|
|
1402
2892
|
{
|
|
1403
2893
|
ref: setRefs,
|
|
@@ -1423,7 +2913,7 @@ var DataPanelTab = React14.forwardRef(
|
|
|
1423
2913
|
onPointerUp: draggable ? handlePointerUp : void 0,
|
|
1424
2914
|
onPointerCancel: draggable ? handlePointerCancel : void 0,
|
|
1425
2915
|
children: [
|
|
1426
|
-
/* @__PURE__ */
|
|
2916
|
+
/* @__PURE__ */ jsxs17(
|
|
1427
2917
|
"button",
|
|
1428
2918
|
{
|
|
1429
2919
|
type: "button",
|
|
@@ -1432,12 +2922,12 @@ var DataPanelTab = React14.forwardRef(
|
|
|
1432
2922
|
onClick: draggable ? void 0 : onClick,
|
|
1433
2923
|
onKeyDown: handleExpandKeyDown,
|
|
1434
2924
|
children: [
|
|
1435
|
-
/* @__PURE__ */
|
|
1436
|
-
subtitle && /* @__PURE__ */
|
|
2925
|
+
/* @__PURE__ */ jsx25("span", { className: "truncate text-sm font-semibold", children: title }),
|
|
2926
|
+
subtitle && /* @__PURE__ */ jsx25("span", { className: "truncate text-xs text-muted-foreground", children: subtitle })
|
|
1437
2927
|
]
|
|
1438
2928
|
}
|
|
1439
2929
|
),
|
|
1440
|
-
!disableClose && onClose && /* @__PURE__ */
|
|
2930
|
+
!disableClose && onClose && /* @__PURE__ */ jsx25(
|
|
1441
2931
|
"button",
|
|
1442
2932
|
{
|
|
1443
2933
|
"data-no-drag": true,
|
|
@@ -1448,7 +2938,7 @@ var DataPanelTab = React14.forwardRef(
|
|
|
1448
2938
|
e.stopPropagation();
|
|
1449
2939
|
onClose();
|
|
1450
2940
|
},
|
|
1451
|
-
children: /* @__PURE__ */
|
|
2941
|
+
children: /* @__PURE__ */ jsx25(CloseIcon, {})
|
|
1452
2942
|
}
|
|
1453
2943
|
)
|
|
1454
2944
|
]
|
|
@@ -1470,7 +2960,7 @@ function ResizeHandles({
|
|
|
1470
2960
|
onPinnedSizeChange,
|
|
1471
2961
|
constraints
|
|
1472
2962
|
}) {
|
|
1473
|
-
const handleDetachedKeyDown =
|
|
2963
|
+
const handleDetachedKeyDown = React24.useCallback(
|
|
1474
2964
|
(e, handle) => {
|
|
1475
2965
|
const step = e.shiftKey ? KEYBOARD_RESIZE_STEP_LARGE : KEYBOARD_RESIZE_STEP;
|
|
1476
2966
|
let width = detachedSize.width;
|
|
@@ -1524,7 +3014,7 @@ function ResizeHandles({
|
|
|
1524
3014
|
candidatePosition,
|
|
1525
3015
|
{ width, height },
|
|
1526
3016
|
constraints,
|
|
1527
|
-
typeof window === "undefined" ? 1024 :
|
|
3017
|
+
typeof window === "undefined" ? 1024 : layoutViewportWidth(),
|
|
1528
3018
|
typeof window === "undefined" ? 768 : window.innerHeight,
|
|
1529
3019
|
handle
|
|
1530
3020
|
);
|
|
@@ -1533,7 +3023,7 @@ function ResizeHandles({
|
|
|
1533
3023
|
},
|
|
1534
3024
|
[detachedPosition, detachedSize, constraints, onDetachedResize]
|
|
1535
3025
|
);
|
|
1536
|
-
const handlePinnedKeyDown =
|
|
3026
|
+
const handlePinnedKeyDown = React24.useCallback(
|
|
1537
3027
|
(e) => {
|
|
1538
3028
|
const step = e.shiftKey ? KEYBOARD_RESIZE_STEP_LARGE : KEYBOARD_RESIZE_STEP;
|
|
1539
3029
|
let newSize = pinnedSize;
|
|
@@ -1593,12 +3083,12 @@ function ResizeHandles({
|
|
|
1593
3083
|
"bottom-left",
|
|
1594
3084
|
"bottom-right"
|
|
1595
3085
|
];
|
|
1596
|
-
return /* @__PURE__ */
|
|
3086
|
+
return /* @__PURE__ */ jsx25(Fragment5, { children: handles.map((handle) => {
|
|
1597
3087
|
const isCorner = handle.includes("-");
|
|
1598
3088
|
const isHorizontal2 = handle === "top" || handle === "bottom";
|
|
1599
3089
|
const isVertical = handle === "left" || handle === "right";
|
|
1600
3090
|
const { min: min2, max: max2 } = getAriaValueMinMax(handle);
|
|
1601
|
-
return /* @__PURE__ */
|
|
3091
|
+
return /* @__PURE__ */ jsx25(
|
|
1602
3092
|
"div",
|
|
1603
3093
|
{
|
|
1604
3094
|
className: cn(
|
|
@@ -1627,7 +3117,7 @@ function ResizeHandles({
|
|
|
1627
3117
|
const pinnedHandle = getPinnedResizeHandle(edge);
|
|
1628
3118
|
const isHorizontal = edge === "left" || edge === "right";
|
|
1629
3119
|
const { min, max } = getAriaValueMinMax(pinnedHandle);
|
|
1630
|
-
return /* @__PURE__ */
|
|
3120
|
+
return /* @__PURE__ */ jsx25(
|
|
1631
3121
|
"div",
|
|
1632
3122
|
{
|
|
1633
3123
|
className: cn(
|
|
@@ -1650,7 +3140,7 @@ function ResizeHandles({
|
|
|
1650
3140
|
}
|
|
1651
3141
|
);
|
|
1652
3142
|
}
|
|
1653
|
-
var DataPanel =
|
|
3143
|
+
var DataPanel = React24.forwardRef(
|
|
1654
3144
|
({
|
|
1655
3145
|
open: controlledOpen,
|
|
1656
3146
|
onOpenChange,
|
|
@@ -1682,76 +3172,76 @@ var DataPanel = React14.forwardRef(
|
|
|
1682
3172
|
footerActions,
|
|
1683
3173
|
className
|
|
1684
3174
|
}, ref) => {
|
|
1685
|
-
const resolvedConstraints =
|
|
3175
|
+
const resolvedConstraints = React24.useMemo(
|
|
1686
3176
|
() => ({ ...DEFAULT_CONSTRAINTS, ...constraints }),
|
|
1687
3177
|
[constraints]
|
|
1688
3178
|
);
|
|
1689
|
-
const resolvedCardConfig =
|
|
3179
|
+
const resolvedCardConfig = React24.useMemo(
|
|
1690
3180
|
() => ({ ...DEFAULT_CARD_CONFIG, ...cardConfig }),
|
|
1691
3181
|
[cardConfig]
|
|
1692
3182
|
);
|
|
1693
|
-
const panelId =
|
|
3183
|
+
const panelId = React24.useId();
|
|
1694
3184
|
const titleId = `${panelId}-title`;
|
|
1695
|
-
const [internalOpen, setInternalOpen] =
|
|
1696
|
-
const [internalMode, setInternalMode] =
|
|
1697
|
-
const [internalVariant, setInternalVariant] =
|
|
3185
|
+
const [internalOpen, setInternalOpen] = React24.useState(true);
|
|
3186
|
+
const [internalMode, setInternalMode] = React24.useState(DEFAULT_PANEL_STATE.mode);
|
|
3187
|
+
const [internalVariant, setInternalVariant] = React24.useState(
|
|
1698
3188
|
DEFAULT_PANEL_STATE.variant
|
|
1699
3189
|
);
|
|
1700
|
-
const [internalEdge, setInternalEdge] =
|
|
1701
|
-
const [internalExpanded, setInternalExpanded] =
|
|
3190
|
+
const [internalEdge, setInternalEdge] = React24.useState(DEFAULT_PANEL_STATE.edge);
|
|
3191
|
+
const [internalExpanded, setInternalExpanded] = React24.useState(
|
|
1702
3192
|
DEFAULT_PANEL_STATE.isExpanded
|
|
1703
3193
|
);
|
|
1704
|
-
const [detachedPosition, setDetachedPosition] =
|
|
3194
|
+
const [detachedPosition, setDetachedPosition] = React24.useState(
|
|
1705
3195
|
DEFAULT_PANEL_STATE.detachedPosition
|
|
1706
3196
|
);
|
|
1707
|
-
const [detachedSize, setDetachedSize] =
|
|
1708
|
-
const [pinnedSize, setPinnedSize] =
|
|
1709
|
-
const [tabOffset, setTabOffset] =
|
|
1710
|
-
const [viewportWidth, setViewportWidth] =
|
|
1711
|
-
typeof window !== "undefined" ?
|
|
3197
|
+
const [detachedSize, setDetachedSize] = React24.useState(DEFAULT_PANEL_STATE.detachedSize);
|
|
3198
|
+
const [pinnedSize, setPinnedSize] = React24.useState(DEFAULT_PANEL_STATE.pinnedSize);
|
|
3199
|
+
const [tabOffset, setTabOffset] = React24.useState(DEFAULT_PANEL_STATE.tabOffset);
|
|
3200
|
+
const [viewportWidth, setViewportWidth] = React24.useState(
|
|
3201
|
+
typeof window !== "undefined" ? layoutViewportWidth() : 1024
|
|
1712
3202
|
);
|
|
1713
|
-
const [viewportHeight, setViewportHeight] =
|
|
3203
|
+
const [viewportHeight, setViewportHeight] = React24.useState(
|
|
1714
3204
|
typeof window !== "undefined" ? window.innerHeight : 768
|
|
1715
3205
|
);
|
|
1716
3206
|
const isMobile = viewportWidth < 640;
|
|
1717
|
-
const [cardHorizontalPosition, setCardHorizontalPosition] =
|
|
1718
|
-
const [cardExpandedHeight, setCardExpandedHeight] =
|
|
1719
|
-
const [cardWidth, setCardWidth] =
|
|
1720
|
-
const [cardDragCurrentHeight, setCardDragCurrentHeight] =
|
|
1721
|
-
const [isCardVerticalDragging, setIsCardVerticalDragging] =
|
|
1722
|
-
const [isCardHorizontalDragging, setIsCardHorizontalDragging] =
|
|
1723
|
-
const [isCardHeightTransitioning, setIsCardHeightTransitioning] =
|
|
1724
|
-
const [isCardWidthResizing, setIsCardWidthResizing] =
|
|
1725
|
-
const [isCardTopResizing, setIsCardTopResizing] =
|
|
1726
|
-
const [isDragging, setIsDragging] =
|
|
1727
|
-
const [isResizing, setIsResizing] =
|
|
1728
|
-
const [snapPreview, setSnapPreview] =
|
|
1729
|
-
const [isPinnedDragging, setIsPinnedDragging] =
|
|
1730
|
-
const [pullOffset, setPullOffset] =
|
|
1731
|
-
const dragStateRef =
|
|
3207
|
+
const [cardHorizontalPosition, setCardHorizontalPosition] = React24.useState(0);
|
|
3208
|
+
const [cardExpandedHeight, setCardExpandedHeight] = React24.useState(0);
|
|
3209
|
+
const [cardWidth, setCardWidth] = React24.useState(null);
|
|
3210
|
+
const [cardDragCurrentHeight, setCardDragCurrentHeight] = React24.useState(CARD_HEADER_HEIGHT);
|
|
3211
|
+
const [isCardVerticalDragging, setIsCardVerticalDragging] = React24.useState(false);
|
|
3212
|
+
const [isCardHorizontalDragging, setIsCardHorizontalDragging] = React24.useState(false);
|
|
3213
|
+
const [isCardHeightTransitioning, setIsCardHeightTransitioning] = React24.useState(false);
|
|
3214
|
+
const [isCardWidthResizing, setIsCardWidthResizing] = React24.useState(false);
|
|
3215
|
+
const [isCardTopResizing, setIsCardTopResizing] = React24.useState(false);
|
|
3216
|
+
const [isDragging, setIsDragging] = React24.useState(false);
|
|
3217
|
+
const [isResizing, setIsResizing] = React24.useState(false);
|
|
3218
|
+
const [snapPreview, setSnapPreview] = React24.useState(null);
|
|
3219
|
+
const [isPinnedDragging, setIsPinnedDragging] = React24.useState(false);
|
|
3220
|
+
const [pullOffset, setPullOffset] = React24.useState(0);
|
|
3221
|
+
const dragStateRef = React24.useRef({
|
|
1732
3222
|
startPosition: { x: 0, y: 0 },
|
|
1733
3223
|
startPanelPosition: { x: 0, y: 0 }
|
|
1734
3224
|
});
|
|
1735
|
-
const pinnedDragStateRef =
|
|
3225
|
+
const pinnedDragStateRef = React24.useRef({
|
|
1736
3226
|
startPosition: { x: 0, y: 0 },
|
|
1737
3227
|
hasDetached: false
|
|
1738
3228
|
});
|
|
1739
|
-
const resizeStateRef =
|
|
3229
|
+
const resizeStateRef = React24.useRef({
|
|
1740
3230
|
handle: null,
|
|
1741
3231
|
startPosition: { x: 0, y: 0 },
|
|
1742
3232
|
startSize: { width: 0, height: 0 },
|
|
1743
3233
|
startPanelPosition: { x: 0, y: 0 }
|
|
1744
3234
|
});
|
|
1745
|
-
const cardDragStateRef =
|
|
3235
|
+
const cardDragStateRef = React24.useRef({
|
|
1746
3236
|
startY: 0,
|
|
1747
3237
|
startX: 0,
|
|
1748
3238
|
startTime: 0,
|
|
1749
3239
|
startExpanded: false,
|
|
1750
3240
|
startHorizontalPosition: 0
|
|
1751
3241
|
});
|
|
1752
|
-
const cardCurrentHeightRef =
|
|
1753
|
-
const cardTopResizeStartRef =
|
|
1754
|
-
const cardWidthResizeStateRef =
|
|
3242
|
+
const cardCurrentHeightRef = React24.useRef(CARD_HEADER_HEIGHT);
|
|
3243
|
+
const cardTopResizeStartRef = React24.useRef({ startY: 0, startHeight: 0 });
|
|
3244
|
+
const cardWidthResizeStateRef = React24.useRef({
|
|
1755
3245
|
handle: null,
|
|
1756
3246
|
startX: 0,
|
|
1757
3247
|
startWidth: 0,
|
|
@@ -1763,9 +3253,9 @@ var DataPanel = React14.forwardRef(
|
|
|
1763
3253
|
const edge = controlledEdge ?? internalEdge;
|
|
1764
3254
|
const isExpanded = controlledExpanded ?? internalExpanded;
|
|
1765
3255
|
const showContent = variant !== "card" || isExpanded || isCardVerticalDragging;
|
|
1766
|
-
const saveTimeoutRef =
|
|
1767
|
-
const isMountedRef =
|
|
1768
|
-
|
|
3256
|
+
const saveTimeoutRef = React24.useRef(null);
|
|
3257
|
+
const isMountedRef = React24.useRef(true);
|
|
3258
|
+
React24.useEffect(() => {
|
|
1769
3259
|
isMountedRef.current = true;
|
|
1770
3260
|
return () => {
|
|
1771
3261
|
isMountedRef.current = false;
|
|
@@ -1776,7 +3266,7 @@ var DataPanel = React14.forwardRef(
|
|
|
1776
3266
|
}
|
|
1777
3267
|
};
|
|
1778
3268
|
}, []);
|
|
1779
|
-
const debouncedSave =
|
|
3269
|
+
const debouncedSave = React24.useCallback(() => {
|
|
1780
3270
|
if (!persistKey) return;
|
|
1781
3271
|
if (saveTimeoutRef.current) {
|
|
1782
3272
|
clearTimeout(saveTimeoutRef.current);
|
|
@@ -1805,11 +3295,11 @@ var DataPanel = React14.forwardRef(
|
|
|
1805
3295
|
pinnedSize,
|
|
1806
3296
|
tabOffset
|
|
1807
3297
|
]);
|
|
1808
|
-
|
|
3298
|
+
React24.useEffect(() => {
|
|
1809
3299
|
debouncedSave();
|
|
1810
3300
|
}, [debouncedSave]);
|
|
1811
|
-
const hasLoadedRef =
|
|
1812
|
-
|
|
3301
|
+
const hasLoadedRef = React24.useRef(false);
|
|
3302
|
+
React24.useEffect(() => {
|
|
1813
3303
|
if (!persistKey || hasLoadedRef.current) return;
|
|
1814
3304
|
hasLoadedRef.current = true;
|
|
1815
3305
|
const persisted = loadPanelState(persistKey);
|
|
@@ -1826,10 +3316,10 @@ var DataPanel = React14.forwardRef(
|
|
|
1826
3316
|
if (persisted.tabOffset !== void 0) setTabOffset(persisted.tabOffset);
|
|
1827
3317
|
}
|
|
1828
3318
|
}, [persistKey, controlledMode, controlledVariant, controlledEdge, controlledExpanded]);
|
|
1829
|
-
|
|
3319
|
+
React24.useEffect(() => {
|
|
1830
3320
|
if (mode === "detached" && detachedPosition.x === DEFAULT_PANEL_STATE.detachedPosition.x && detachedPosition.y === DEFAULT_PANEL_STATE.detachedPosition.y) {
|
|
1831
3321
|
setDetachedPosition(
|
|
1832
|
-
getInitialDetachedPosition(detachedSize,
|
|
3322
|
+
getInitialDetachedPosition(detachedSize, layoutViewportWidth(), window.innerHeight)
|
|
1833
3323
|
);
|
|
1834
3324
|
}
|
|
1835
3325
|
}, [mode, detachedPosition, detachedSize]);
|
|
@@ -1855,7 +3345,7 @@ var DataPanel = React14.forwardRef(
|
|
|
1855
3345
|
ref.current = node;
|
|
1856
3346
|
}
|
|
1857
3347
|
};
|
|
1858
|
-
const handleModeChange =
|
|
3348
|
+
const handleModeChange = React24.useCallback(
|
|
1859
3349
|
(newMode) => {
|
|
1860
3350
|
if (controlledMode === void 0) {
|
|
1861
3351
|
setInternalMode(newMode);
|
|
@@ -1864,7 +3354,7 @@ var DataPanel = React14.forwardRef(
|
|
|
1864
3354
|
},
|
|
1865
3355
|
[controlledMode, onModeChange]
|
|
1866
3356
|
);
|
|
1867
|
-
const handleEdgeChange =
|
|
3357
|
+
const handleEdgeChange = React24.useCallback(
|
|
1868
3358
|
(newEdge) => {
|
|
1869
3359
|
if (controlledEdge === void 0) {
|
|
1870
3360
|
setInternalEdge(newEdge);
|
|
@@ -1873,7 +3363,7 @@ var DataPanel = React14.forwardRef(
|
|
|
1873
3363
|
},
|
|
1874
3364
|
[controlledEdge, onEdgeChange]
|
|
1875
3365
|
);
|
|
1876
|
-
const handleExpandedChange =
|
|
3366
|
+
const handleExpandedChange = React24.useCallback(
|
|
1877
3367
|
(newExpanded) => {
|
|
1878
3368
|
if (controlledExpanded === void 0) {
|
|
1879
3369
|
setInternalExpanded(newExpanded);
|
|
@@ -1907,7 +3397,7 @@ var DataPanel = React14.forwardRef(
|
|
|
1907
3397
|
document.body.style.userSelect = "none";
|
|
1908
3398
|
}
|
|
1909
3399
|
};
|
|
1910
|
-
const handleDragMove =
|
|
3400
|
+
const handleDragMove = React24.useCallback(
|
|
1911
3401
|
(e) => {
|
|
1912
3402
|
if (!isDragging) return;
|
|
1913
3403
|
const currentPos = getPointerPosition(e);
|
|
@@ -1923,18 +3413,18 @@ var DataPanel = React14.forwardRef(
|
|
|
1923
3413
|
const snap = detectEdgeSnap(
|
|
1924
3414
|
newPosition,
|
|
1925
3415
|
detachedSize,
|
|
1926
|
-
|
|
3416
|
+
layoutViewportWidth(),
|
|
1927
3417
|
window.innerHeight,
|
|
1928
3418
|
snapThreshold
|
|
1929
3419
|
);
|
|
1930
3420
|
setSnapPreview(snap.shouldSnap ? snap.edge : null);
|
|
1931
3421
|
setDetachedPosition(
|
|
1932
|
-
constrainPosition(newPosition, detachedSize,
|
|
3422
|
+
constrainPosition(newPosition, detachedSize, layoutViewportWidth(), window.innerHeight)
|
|
1933
3423
|
);
|
|
1934
3424
|
},
|
|
1935
3425
|
[isDragging, detachedSize, snapThreshold]
|
|
1936
3426
|
);
|
|
1937
|
-
const handleDragEnd =
|
|
3427
|
+
const handleDragEnd = React24.useCallback(() => {
|
|
1938
3428
|
if (!isDragging) return;
|
|
1939
3429
|
setIsDragging(false);
|
|
1940
3430
|
document.body.style.cursor = "";
|
|
@@ -1945,7 +3435,7 @@ var DataPanel = React14.forwardRef(
|
|
|
1945
3435
|
setSnapPreview(null);
|
|
1946
3436
|
}
|
|
1947
3437
|
}, [isDragging, snapPreview, handleModeChange, handleEdgeChange]);
|
|
1948
|
-
const handlePinnedDragMove =
|
|
3438
|
+
const handlePinnedDragMove = React24.useCallback(
|
|
1949
3439
|
(e) => {
|
|
1950
3440
|
if (!isPinnedDragging) return;
|
|
1951
3441
|
const currentPos = getPointerPosition(e);
|
|
@@ -1963,7 +3453,7 @@ var DataPanel = React14.forwardRef(
|
|
|
1963
3453
|
pinnedSize,
|
|
1964
3454
|
detachedSize,
|
|
1965
3455
|
edge,
|
|
1966
|
-
|
|
3456
|
+
layoutViewportWidth(),
|
|
1967
3457
|
window.innerHeight
|
|
1968
3458
|
);
|
|
1969
3459
|
setDetachedPosition(newPosition);
|
|
@@ -1981,7 +3471,7 @@ var DataPanel = React14.forwardRef(
|
|
|
1981
3471
|
},
|
|
1982
3472
|
[isPinnedDragging, edge, detachThreshold, pinnedSize, detachedSize, handleModeChange]
|
|
1983
3473
|
);
|
|
1984
|
-
const handlePinnedDragEnd =
|
|
3474
|
+
const handlePinnedDragEnd = React24.useCallback(() => {
|
|
1985
3475
|
if (!isPinnedDragging) return;
|
|
1986
3476
|
setIsPinnedDragging(false);
|
|
1987
3477
|
setPullOffset(0);
|
|
@@ -2003,7 +3493,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2003
3493
|
document.body.style.cursor = getResizeCursor(handle);
|
|
2004
3494
|
document.body.style.userSelect = "none";
|
|
2005
3495
|
};
|
|
2006
|
-
const handleResizeMove =
|
|
3496
|
+
const handleResizeMove = React24.useCallback(
|
|
2007
3497
|
(e) => {
|
|
2008
3498
|
if (!isResizing || !resizeStateRef.current.handle) return;
|
|
2009
3499
|
const currentPos = getPointerPosition(e);
|
|
@@ -2023,7 +3513,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2023
3513
|
result.position,
|
|
2024
3514
|
result.size,
|
|
2025
3515
|
resolvedConstraints,
|
|
2026
|
-
|
|
3516
|
+
layoutViewportWidth(),
|
|
2027
3517
|
window.innerHeight,
|
|
2028
3518
|
handle
|
|
2029
3519
|
);
|
|
@@ -2034,7 +3524,9 @@ var DataPanel = React14.forwardRef(
|
|
|
2034
3524
|
const direction = edge === "left" || edge === "top" ? 1 : -1;
|
|
2035
3525
|
const newSize = startSize.width + delta * direction;
|
|
2036
3526
|
if (isHorizontalEdge(edge)) {
|
|
2037
|
-
setPinnedSize(
|
|
3527
|
+
setPinnedSize(
|
|
3528
|
+
constrainPinnedWidth(newSize, resolvedConstraints, layoutViewportWidth())
|
|
3529
|
+
);
|
|
2038
3530
|
} else {
|
|
2039
3531
|
setPinnedSize(constrainPinnedHeight(newSize, resolvedConstraints, window.innerHeight));
|
|
2040
3532
|
}
|
|
@@ -2042,7 +3534,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2042
3534
|
},
|
|
2043
3535
|
[isResizing, mode, edge, resolvedConstraints]
|
|
2044
3536
|
);
|
|
2045
|
-
const handleResizeEnd =
|
|
3537
|
+
const handleResizeEnd = React24.useCallback(() => {
|
|
2046
3538
|
if (!isResizing) return;
|
|
2047
3539
|
setIsResizing(false);
|
|
2048
3540
|
resizeStateRef.current.handle = null;
|
|
@@ -2074,7 +3566,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2074
3566
|
}
|
|
2075
3567
|
document.body.style.userSelect = "none";
|
|
2076
3568
|
};
|
|
2077
|
-
const handleCardPointerMove =
|
|
3569
|
+
const handleCardPointerMove = React24.useCallback(
|
|
2078
3570
|
(e) => {
|
|
2079
3571
|
const currentPos = getPointerPosition(e);
|
|
2080
3572
|
if (isCardVerticalDragging) {
|
|
@@ -2114,7 +3606,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2114
3606
|
resolvedCardConfig.maxWidth
|
|
2115
3607
|
]
|
|
2116
3608
|
);
|
|
2117
|
-
const handleCardPointerUp =
|
|
3609
|
+
const handleCardPointerUp = React24.useCallback(
|
|
2118
3610
|
(e) => {
|
|
2119
3611
|
const endTime = Date.now();
|
|
2120
3612
|
const currentPos = getPointerPosition(e);
|
|
@@ -2171,7 +3663,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2171
3663
|
document.body.style.cursor = "ns-resize";
|
|
2172
3664
|
document.body.style.userSelect = "none";
|
|
2173
3665
|
};
|
|
2174
|
-
const handleCardResizeMove =
|
|
3666
|
+
const handleCardResizeMove = React24.useCallback(
|
|
2175
3667
|
(e) => {
|
|
2176
3668
|
if (!isCardTopResizing) return;
|
|
2177
3669
|
const currentPos = getPointerPosition(e);
|
|
@@ -2184,7 +3676,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2184
3676
|
},
|
|
2185
3677
|
[isCardTopResizing, viewportHeight]
|
|
2186
3678
|
);
|
|
2187
|
-
const handleCardResizeEnd =
|
|
3679
|
+
const handleCardResizeEnd = React24.useCallback(() => {
|
|
2188
3680
|
if (!isCardTopResizing) return;
|
|
2189
3681
|
setIsCardTopResizing(false);
|
|
2190
3682
|
document.body.style.cursor = "";
|
|
@@ -2215,7 +3707,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2215
3707
|
document.body.style.cursor = "ew-resize";
|
|
2216
3708
|
document.body.style.userSelect = "none";
|
|
2217
3709
|
};
|
|
2218
|
-
const handleCardWidthResizeMove =
|
|
3710
|
+
const handleCardWidthResizeMove = React24.useCallback(
|
|
2219
3711
|
(e) => {
|
|
2220
3712
|
const st = cardWidthResizeStateRef.current;
|
|
2221
3713
|
if (!isCardWidthResizing || !st.handle) return;
|
|
@@ -2255,7 +3747,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2255
3747
|
resolvedCardConfig.maxWidth
|
|
2256
3748
|
]
|
|
2257
3749
|
);
|
|
2258
|
-
const handleCardWidthResizeEnd =
|
|
3750
|
+
const handleCardWidthResizeEnd = React24.useCallback(() => {
|
|
2259
3751
|
if (!isCardWidthResizing) return;
|
|
2260
3752
|
setIsCardWidthResizing(false);
|
|
2261
3753
|
cardWidthResizeStateRef.current.handle = null;
|
|
@@ -2303,7 +3795,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2303
3795
|
if (kind === "width-left") setCardHorizontalPosition((p) => p - appliedDelta);
|
|
2304
3796
|
debouncedSave();
|
|
2305
3797
|
};
|
|
2306
|
-
|
|
3798
|
+
React24.useEffect(() => {
|
|
2307
3799
|
if (isDragging) {
|
|
2308
3800
|
window.addEventListener("pointermove", handleDragMove);
|
|
2309
3801
|
window.addEventListener("pointerup", handleDragEnd);
|
|
@@ -2315,7 +3807,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2315
3807
|
};
|
|
2316
3808
|
}
|
|
2317
3809
|
}, [isDragging, handleDragMove, handleDragEnd]);
|
|
2318
|
-
|
|
3810
|
+
React24.useEffect(() => {
|
|
2319
3811
|
if (isPinnedDragging) {
|
|
2320
3812
|
window.addEventListener("pointermove", handlePinnedDragMove);
|
|
2321
3813
|
window.addEventListener("pointerup", handlePinnedDragEnd);
|
|
@@ -2327,7 +3819,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2327
3819
|
};
|
|
2328
3820
|
}
|
|
2329
3821
|
}, [isPinnedDragging, handlePinnedDragMove, handlePinnedDragEnd]);
|
|
2330
|
-
|
|
3822
|
+
React24.useEffect(() => {
|
|
2331
3823
|
if (isResizing) {
|
|
2332
3824
|
window.addEventListener("pointermove", handleResizeMove);
|
|
2333
3825
|
window.addEventListener("pointerup", handleResizeEnd);
|
|
@@ -2339,7 +3831,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2339
3831
|
};
|
|
2340
3832
|
}
|
|
2341
3833
|
}, [isResizing, handleResizeMove, handleResizeEnd]);
|
|
2342
|
-
|
|
3834
|
+
React24.useEffect(() => {
|
|
2343
3835
|
if (isCardVerticalDragging || isCardHorizontalDragging) {
|
|
2344
3836
|
window.addEventListener("pointermove", handleCardPointerMove);
|
|
2345
3837
|
window.addEventListener("pointerup", handleCardPointerUp);
|
|
@@ -2356,7 +3848,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2356
3848
|
handleCardPointerMove,
|
|
2357
3849
|
handleCardPointerUp
|
|
2358
3850
|
]);
|
|
2359
|
-
|
|
3851
|
+
React24.useEffect(() => {
|
|
2360
3852
|
if (isCardTopResizing) {
|
|
2361
3853
|
window.addEventListener("pointermove", handleCardResizeMove);
|
|
2362
3854
|
window.addEventListener("pointerup", handleCardResizeEnd);
|
|
@@ -2368,7 +3860,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2368
3860
|
};
|
|
2369
3861
|
}
|
|
2370
3862
|
}, [isCardTopResizing, handleCardResizeMove, handleCardResizeEnd]);
|
|
2371
|
-
|
|
3863
|
+
React24.useEffect(() => {
|
|
2372
3864
|
if (isCardWidthResizing) {
|
|
2373
3865
|
window.addEventListener("pointermove", handleCardWidthResizeMove);
|
|
2374
3866
|
window.addEventListener("pointerup", handleCardWidthResizeEnd);
|
|
@@ -2380,9 +3872,9 @@ var DataPanel = React14.forwardRef(
|
|
|
2380
3872
|
};
|
|
2381
3873
|
}
|
|
2382
3874
|
}, [isCardWidthResizing, handleCardWidthResizeMove, handleCardWidthResizeEnd]);
|
|
2383
|
-
|
|
3875
|
+
React24.useEffect(() => {
|
|
2384
3876
|
const onResize = () => {
|
|
2385
|
-
setViewportWidth(
|
|
3877
|
+
setViewportWidth(layoutViewportWidth());
|
|
2386
3878
|
setViewportHeight(window.innerHeight);
|
|
2387
3879
|
setCardExpandedHeight(window.innerHeight * CARD_EXPANDED_RATIO);
|
|
2388
3880
|
};
|
|
@@ -2390,19 +3882,19 @@ var DataPanel = React14.forwardRef(
|
|
|
2390
3882
|
window.addEventListener("resize", onResize);
|
|
2391
3883
|
return () => window.removeEventListener("resize", onResize);
|
|
2392
3884
|
}, []);
|
|
2393
|
-
|
|
3885
|
+
React24.useEffect(() => {
|
|
2394
3886
|
if (isMobile && variant === "card") {
|
|
2395
3887
|
setCardHorizontalPosition(0);
|
|
2396
3888
|
setCardWidth(null);
|
|
2397
3889
|
}
|
|
2398
3890
|
}, [isMobile, variant]);
|
|
2399
|
-
|
|
3891
|
+
React24.useEffect(() => {
|
|
2400
3892
|
if (isCardHeightTransitioning) {
|
|
2401
3893
|
const t = setTimeout(() => setIsCardHeightTransitioning(false), 350);
|
|
2402
3894
|
return () => clearTimeout(t);
|
|
2403
3895
|
}
|
|
2404
3896
|
}, [isCardHeightTransitioning]);
|
|
2405
|
-
const panelStyles =
|
|
3897
|
+
const panelStyles = React24.useMemo(() => {
|
|
2406
3898
|
if (variant === "card") {
|
|
2407
3899
|
const defaultCardWidth = Math.min(
|
|
2408
3900
|
viewportWidth - resolvedCardConfig.horizontalMargin * 2,
|
|
@@ -2467,7 +3959,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2467
3959
|
}[edge] : "animate-scale-in";
|
|
2468
3960
|
if (!open) return null;
|
|
2469
3961
|
if (variant === "full" && !isExpanded && mode === "pinned") {
|
|
2470
|
-
return /* @__PURE__ */
|
|
3962
|
+
return /* @__PURE__ */ jsx25(
|
|
2471
3963
|
DataPanelTab,
|
|
2472
3964
|
{
|
|
2473
3965
|
title,
|
|
@@ -2483,8 +3975,8 @@ var DataPanel = React14.forwardRef(
|
|
|
2483
3975
|
}
|
|
2484
3976
|
);
|
|
2485
3977
|
}
|
|
2486
|
-
return /* @__PURE__ */
|
|
2487
|
-
snapPreview && /* @__PURE__ */
|
|
3978
|
+
return /* @__PURE__ */ jsxs17(Fragment5, { children: [
|
|
3979
|
+
snapPreview && /* @__PURE__ */ jsx25(
|
|
2488
3980
|
"div",
|
|
2489
3981
|
{
|
|
2490
3982
|
className: cn(
|
|
@@ -2496,7 +3988,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2496
3988
|
)
|
|
2497
3989
|
}
|
|
2498
3990
|
),
|
|
2499
|
-
variant === "card" && isExpanded && isMobile && /* @__PURE__ */
|
|
3991
|
+
variant === "card" && isExpanded && isMobile && /* @__PURE__ */ jsx25(
|
|
2500
3992
|
"div",
|
|
2501
3993
|
{
|
|
2502
3994
|
className: "fixed inset-0 z-40 bg-black/50 transition-opacity",
|
|
@@ -2504,7 +3996,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2504
3996
|
onClick: handleToggleExpand
|
|
2505
3997
|
}
|
|
2506
3998
|
),
|
|
2507
|
-
/* @__PURE__ */
|
|
3999
|
+
/* @__PURE__ */ jsxs17(
|
|
2508
4000
|
"div",
|
|
2509
4001
|
{
|
|
2510
4002
|
ref: setPanelRef,
|
|
@@ -2526,7 +4018,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2526
4018
|
"aria-expanded": variant === "card" ? isExpanded : void 0,
|
|
2527
4019
|
onPointerDown: variant === "full" ? handleDragStart : void 0,
|
|
2528
4020
|
children: [
|
|
2529
|
-
variant === "card" ? /* @__PURE__ */
|
|
4021
|
+
variant === "card" ? /* @__PURE__ */ jsx25(
|
|
2530
4022
|
DataPanelCardHeader,
|
|
2531
4023
|
{
|
|
2532
4024
|
title,
|
|
@@ -2542,7 +4034,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2542
4034
|
onToggleExpand: handleToggleExpand,
|
|
2543
4035
|
onClose: () => handleOpenChange(false)
|
|
2544
4036
|
}
|
|
2545
|
-
) : /* @__PURE__ */
|
|
4037
|
+
) : /* @__PURE__ */ jsx25(
|
|
2546
4038
|
DataPanelHeader,
|
|
2547
4039
|
{
|
|
2548
4040
|
title,
|
|
@@ -2562,9 +4054,9 @@ var DataPanel = React14.forwardRef(
|
|
|
2562
4054
|
draggable: !disableDrag && (mode === "detached" || mode === "pinned" && detachThreshold > 0)
|
|
2563
4055
|
}
|
|
2564
4056
|
),
|
|
2565
|
-
showContent && /* @__PURE__ */
|
|
2566
|
-
/* @__PURE__ */
|
|
2567
|
-
/* @__PURE__ */
|
|
4057
|
+
showContent && /* @__PURE__ */ jsxs17(Fragment5, { children: [
|
|
4058
|
+
/* @__PURE__ */ jsx25(DataPanelContent, { children }),
|
|
4059
|
+
/* @__PURE__ */ jsx25(
|
|
2568
4060
|
DataPanelFooter,
|
|
2569
4061
|
{
|
|
2570
4062
|
actions,
|
|
@@ -2573,7 +4065,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2573
4065
|
}
|
|
2574
4066
|
)
|
|
2575
4067
|
] }),
|
|
2576
|
-
variant === "full" && !disableResize && /* @__PURE__ */
|
|
4068
|
+
variant === "full" && !disableResize && /* @__PURE__ */ jsx25(
|
|
2577
4069
|
ResizeHandles,
|
|
2578
4070
|
{
|
|
2579
4071
|
mode,
|
|
@@ -2592,7 +4084,9 @@ var DataPanel = React14.forwardRef(
|
|
|
2592
4084
|
return;
|
|
2593
4085
|
}
|
|
2594
4086
|
if (isHorizontalEdge(edge)) {
|
|
2595
|
-
setPinnedSize(
|
|
4087
|
+
setPinnedSize(
|
|
4088
|
+
constrainPinnedWidth(size, resolvedConstraints, layoutViewportWidth())
|
|
4089
|
+
);
|
|
2596
4090
|
} else {
|
|
2597
4091
|
setPinnedSize(
|
|
2598
4092
|
constrainPinnedHeight(size, resolvedConstraints, window.innerHeight)
|
|
@@ -2602,8 +4096,8 @@ var DataPanel = React14.forwardRef(
|
|
|
2602
4096
|
constraints: resolvedConstraints
|
|
2603
4097
|
}
|
|
2604
4098
|
),
|
|
2605
|
-
variant === "card" && isExpanded && !disableResize && !isMobile && /* @__PURE__ */
|
|
2606
|
-
/* @__PURE__ */
|
|
4099
|
+
variant === "card" && isExpanded && !disableResize && !isMobile && /* @__PURE__ */ jsxs17(Fragment5, { children: [
|
|
4100
|
+
/* @__PURE__ */ jsx25(
|
|
2607
4101
|
"div",
|
|
2608
4102
|
{
|
|
2609
4103
|
className: "resize-handle resize-handle--horizontal resize-handle--top",
|
|
@@ -2619,7 +4113,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2619
4113
|
onKeyDown: (e) => handleCardResizeKeyDown(e, "height")
|
|
2620
4114
|
}
|
|
2621
4115
|
),
|
|
2622
|
-
/* @__PURE__ */
|
|
4116
|
+
/* @__PURE__ */ jsx25(
|
|
2623
4117
|
"div",
|
|
2624
4118
|
{
|
|
2625
4119
|
className: "resize-handle resize-handle--vertical resize-handle--left resize-handle--card-edge",
|
|
@@ -2635,7 +4129,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2635
4129
|
onKeyDown: (e) => handleCardResizeKeyDown(e, "width-left")
|
|
2636
4130
|
}
|
|
2637
4131
|
),
|
|
2638
|
-
/* @__PURE__ */
|
|
4132
|
+
/* @__PURE__ */ jsx25(
|
|
2639
4133
|
"div",
|
|
2640
4134
|
{
|
|
2641
4135
|
className: "resize-handle resize-handle--vertical resize-handle--right resize-handle--card-edge",
|
|
@@ -2661,10 +4155,10 @@ var DataPanel = React14.forwardRef(
|
|
|
2661
4155
|
DataPanel.displayName = "DataPanel";
|
|
2662
4156
|
|
|
2663
4157
|
// src/components/Skeleton.tsx
|
|
2664
|
-
import * as
|
|
2665
|
-
import { cva as
|
|
2666
|
-
import { jsx as
|
|
2667
|
-
var skeletonVariants =
|
|
4158
|
+
import * as React25 from "react";
|
|
4159
|
+
import { cva as cva6 } from "class-variance-authority";
|
|
4160
|
+
import { jsx as jsx26 } from "react/jsx-runtime";
|
|
4161
|
+
var skeletonVariants = cva6("rounded-md bg-muted", {
|
|
2668
4162
|
variants: {
|
|
2669
4163
|
variant: {
|
|
2670
4164
|
default: "",
|
|
@@ -2679,10 +4173,10 @@ var skeletonVariants = cva5("rounded-md bg-muted", {
|
|
|
2679
4173
|
variant: "default"
|
|
2680
4174
|
}
|
|
2681
4175
|
});
|
|
2682
|
-
var Skeleton =
|
|
4176
|
+
var Skeleton = React25.forwardRef(
|
|
2683
4177
|
({ className, variant, animation = "pulse", ...props }, ref) => {
|
|
2684
4178
|
const animationClass = animation === "pulse" ? "animate-pulse" : animation === "shimmer" ? "animate-shimmer" : "";
|
|
2685
|
-
return /* @__PURE__ */
|
|
4179
|
+
return /* @__PURE__ */ jsx26(
|
|
2686
4180
|
"div",
|
|
2687
4181
|
{
|
|
2688
4182
|
ref,
|
|
@@ -2695,10 +4189,10 @@ var Skeleton = React15.forwardRef(
|
|
|
2695
4189
|
Skeleton.displayName = "Skeleton";
|
|
2696
4190
|
|
|
2697
4191
|
// src/components/Spinner.tsx
|
|
2698
|
-
import * as
|
|
2699
|
-
import { cva as
|
|
2700
|
-
import { jsx as
|
|
2701
|
-
var spinnerVariants =
|
|
4192
|
+
import * as React26 from "react";
|
|
4193
|
+
import { cva as cva7 } from "class-variance-authority";
|
|
4194
|
+
import { jsx as jsx27, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
4195
|
+
var spinnerVariants = cva7("animate-spin text-current", {
|
|
2702
4196
|
variants: {
|
|
2703
4197
|
size: {
|
|
2704
4198
|
sm: "h-4 w-4",
|
|
@@ -2711,9 +4205,9 @@ var spinnerVariants = cva6("animate-spin text-current", {
|
|
|
2711
4205
|
size: "md"
|
|
2712
4206
|
}
|
|
2713
4207
|
});
|
|
2714
|
-
var Spinner =
|
|
4208
|
+
var Spinner = React26.forwardRef(
|
|
2715
4209
|
({ className, size, label = "Loading...", ...props }, ref) => {
|
|
2716
|
-
return /* @__PURE__ */
|
|
4210
|
+
return /* @__PURE__ */ jsxs18(
|
|
2717
4211
|
"svg",
|
|
2718
4212
|
{
|
|
2719
4213
|
ref,
|
|
@@ -2725,7 +4219,7 @@ var Spinner = React16.forwardRef(
|
|
|
2725
4219
|
role: "status",
|
|
2726
4220
|
...props,
|
|
2727
4221
|
children: [
|
|
2728
|
-
/* @__PURE__ */
|
|
4222
|
+
/* @__PURE__ */ jsx27(
|
|
2729
4223
|
"circle",
|
|
2730
4224
|
{
|
|
2731
4225
|
className: "opacity-25",
|
|
@@ -2736,7 +4230,7 @@ var Spinner = React16.forwardRef(
|
|
|
2736
4230
|
strokeWidth: "4"
|
|
2737
4231
|
}
|
|
2738
4232
|
),
|
|
2739
|
-
/* @__PURE__ */
|
|
4233
|
+
/* @__PURE__ */ jsx27(
|
|
2740
4234
|
"path",
|
|
2741
4235
|
{
|
|
2742
4236
|
className: "opacity-75",
|
|
@@ -2744,7 +4238,7 @@ var Spinner = React16.forwardRef(
|
|
|
2744
4238
|
d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
|
2745
4239
|
}
|
|
2746
4240
|
),
|
|
2747
|
-
/* @__PURE__ */
|
|
4241
|
+
/* @__PURE__ */ jsx27("title", { children: label })
|
|
2748
4242
|
]
|
|
2749
4243
|
}
|
|
2750
4244
|
);
|
|
@@ -2753,8 +4247,8 @@ var Spinner = React16.forwardRef(
|
|
|
2753
4247
|
Spinner.displayName = "Spinner";
|
|
2754
4248
|
|
|
2755
4249
|
// src/components/LoadingLogo.tsx
|
|
2756
|
-
import * as
|
|
2757
|
-
import { jsx as
|
|
4250
|
+
import * as React27 from "react";
|
|
4251
|
+
import { jsx as jsx28, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
2758
4252
|
var logoPaths = [
|
|
2759
4253
|
"M9.902 16.6c.3.7 1.7.8 1-.6-.6-1.4-2.3-5.1-6.1-6.3-1.7-.5-3.7.4-4.3 1.6-.4.7-1.1 2.9.5 4.3.8.7 1.9 1.2 3.6 1 .4-.1.9-.5.6-.8-.5-.4-1.9-1.7-1.1-2.7.7-.8 1.4-.6 2-.3.4.2 2.1 1 3.7 3.6l.1.2z",
|
|
2760
4254
|
"M14.602 16.6c-.3.7-1.7.8-1-.6.6-1.4 2.3-5.1 6.1-6.3 1.7-.5 3.7.4 4.3 1.6.4.7 1.1 2.9-.5 4.3-.8.7-1.9 1.2-3.6 1-.4-.1-.9-.5-.6-.8.5-.4 1.9-1.7 1.1-2.7-.7-.8-1.4-.6-2-.3-.4.2-2.1 1-3.7 3.6l-.1.2z",
|
|
@@ -2776,12 +4270,12 @@ var colors = {
|
|
|
2776
4270
|
stroke: "#ffffff"
|
|
2777
4271
|
}
|
|
2778
4272
|
};
|
|
2779
|
-
var LoadingLogo =
|
|
4273
|
+
var LoadingLogo = React27.forwardRef(
|
|
2780
4274
|
({ width = 40, height = 40, loading = false, variant = "dark", className, ...props }, ref) => {
|
|
2781
4275
|
const currentColors = colors[variant];
|
|
2782
4276
|
const fillColor = loading ? currentColors.fillLoading : currentColors.fill;
|
|
2783
4277
|
const strokeColor = currentColors.stroke;
|
|
2784
|
-
return /* @__PURE__ */
|
|
4278
|
+
return /* @__PURE__ */ jsxs19(
|
|
2785
4279
|
"div",
|
|
2786
4280
|
{
|
|
2787
4281
|
ref,
|
|
@@ -2791,7 +4285,7 @@ var LoadingLogo = React17.forwardRef(
|
|
|
2791
4285
|
"aria-label": loading ? "Loading" : "Classic Homes",
|
|
2792
4286
|
...props,
|
|
2793
4287
|
children: [
|
|
2794
|
-
/* @__PURE__ */
|
|
4288
|
+
/* @__PURE__ */ jsxs19(
|
|
2795
4289
|
"svg",
|
|
2796
4290
|
{
|
|
2797
4291
|
width: "100%",
|
|
@@ -2801,8 +4295,8 @@ var LoadingLogo = React17.forwardRef(
|
|
|
2801
4295
|
xmlns: "http://www.w3.org/2000/svg",
|
|
2802
4296
|
"aria-hidden": "true",
|
|
2803
4297
|
children: [
|
|
2804
|
-
/* @__PURE__ */
|
|
2805
|
-
loading && /* @__PURE__ */
|
|
4298
|
+
/* @__PURE__ */ jsx28("g", { fill: fillColor, className: "transition-all duration-300", children: logoPaths.map((path, i) => /* @__PURE__ */ jsx28("path", { d: path }, i)) }),
|
|
4299
|
+
loading && /* @__PURE__ */ jsx28(
|
|
2806
4300
|
"g",
|
|
2807
4301
|
{
|
|
2808
4302
|
fill: "none",
|
|
@@ -2810,13 +4304,13 @@ var LoadingLogo = React17.forwardRef(
|
|
|
2810
4304
|
strokeWidth: "0.5",
|
|
2811
4305
|
strokeDasharray: "10 4",
|
|
2812
4306
|
className: "animate-trace",
|
|
2813
|
-
children: logoPaths.map((path, i) => /* @__PURE__ */
|
|
4307
|
+
children: logoPaths.map((path, i) => /* @__PURE__ */ jsx28("path", { d: path }, i))
|
|
2814
4308
|
}
|
|
2815
4309
|
)
|
|
2816
4310
|
]
|
|
2817
4311
|
}
|
|
2818
4312
|
),
|
|
2819
|
-
loading && /* @__PURE__ */
|
|
4313
|
+
loading && /* @__PURE__ */ jsx28("span", { className: "sr-only", children: "Loading" })
|
|
2820
4314
|
]
|
|
2821
4315
|
}
|
|
2822
4316
|
);
|
|
@@ -2825,10 +4319,10 @@ var LoadingLogo = React17.forwardRef(
|
|
|
2825
4319
|
LoadingLogo.displayName = "LoadingLogo";
|
|
2826
4320
|
|
|
2827
4321
|
// src/components/ProgressBar.tsx
|
|
2828
|
-
import * as
|
|
2829
|
-
import { cva as
|
|
2830
|
-
import { jsx as
|
|
2831
|
-
var progressBarVariants =
|
|
4322
|
+
import * as React28 from "react";
|
|
4323
|
+
import { cva as cva8 } from "class-variance-authority";
|
|
4324
|
+
import { jsx as jsx29, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
4325
|
+
var progressBarVariants = cva8("w-full overflow-hidden rounded-full bg-muted", {
|
|
2832
4326
|
variants: {
|
|
2833
4327
|
size: {
|
|
2834
4328
|
sm: "h-1",
|
|
@@ -2840,7 +4334,7 @@ var progressBarVariants = cva7("w-full overflow-hidden rounded-full bg-muted", {
|
|
|
2840
4334
|
size: "md"
|
|
2841
4335
|
}
|
|
2842
4336
|
});
|
|
2843
|
-
var progressFillVariants =
|
|
4337
|
+
var progressFillVariants = cva8("h-full rounded-full transition-all duration-300", {
|
|
2844
4338
|
variants: {
|
|
2845
4339
|
variant: {
|
|
2846
4340
|
default: "bg-primary",
|
|
@@ -2853,12 +4347,12 @@ var progressFillVariants = cva7("h-full rounded-full transition-all duration-300
|
|
|
2853
4347
|
variant: "default"
|
|
2854
4348
|
}
|
|
2855
4349
|
});
|
|
2856
|
-
var ProgressBar =
|
|
4350
|
+
var ProgressBar = React28.forwardRef(
|
|
2857
4351
|
({ className, size, variant, value, max = 100, label = "Progress", showValue = false, ...props }, ref) => {
|
|
2858
4352
|
const isIndeterminate = value === void 0;
|
|
2859
4353
|
const clampedValue = isIndeterminate ? 0 : Math.min(Math.max(0, value), max);
|
|
2860
4354
|
const percentage = isIndeterminate ? 0 : Math.round(clampedValue / max * 100);
|
|
2861
|
-
return /* @__PURE__ */
|
|
4355
|
+
return /* @__PURE__ */ jsxs20(
|
|
2862
4356
|
"div",
|
|
2863
4357
|
{
|
|
2864
4358
|
ref,
|
|
@@ -2870,7 +4364,7 @@ var ProgressBar = React18.forwardRef(
|
|
|
2870
4364
|
className: cn("flex items-center gap-2", className),
|
|
2871
4365
|
...props,
|
|
2872
4366
|
children: [
|
|
2873
|
-
/* @__PURE__ */
|
|
4367
|
+
/* @__PURE__ */ jsx29("div", { className: cn(progressBarVariants({ size })), children: /* @__PURE__ */ jsx29(
|
|
2874
4368
|
"div",
|
|
2875
4369
|
{
|
|
2876
4370
|
className: cn(
|
|
@@ -2880,7 +4374,7 @@ var ProgressBar = React18.forwardRef(
|
|
|
2880
4374
|
style: isIndeterminate ? void 0 : { width: `${percentage}%` }
|
|
2881
4375
|
}
|
|
2882
4376
|
) }),
|
|
2883
|
-
showValue && !isIndeterminate && /* @__PURE__ */
|
|
4377
|
+
showValue && !isIndeterminate && /* @__PURE__ */ jsxs20("span", { className: "text-sm tabular-nums text-muted-foreground", children: [
|
|
2884
4378
|
percentage,
|
|
2885
4379
|
"%"
|
|
2886
4380
|
] })
|
|
@@ -2892,11 +4386,11 @@ var ProgressBar = React18.forwardRef(
|
|
|
2892
4386
|
ProgressBar.displayName = "ProgressBar";
|
|
2893
4387
|
|
|
2894
4388
|
// src/components/LoadingOverlay.tsx
|
|
2895
|
-
import * as
|
|
2896
|
-
import { Fragment as
|
|
4389
|
+
import * as React29 from "react";
|
|
4390
|
+
import { Fragment as Fragment6, jsx as jsx30, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
2897
4391
|
var spinnerSizeMap = { sm: "sm", md: "md", lg: "lg", xl: "xl" };
|
|
2898
4392
|
var logoSizeMap = { sm: 32, md: 40, lg: 56, xl: 80 };
|
|
2899
|
-
var LoadingOverlay =
|
|
4393
|
+
var LoadingOverlay = React29.forwardRef(
|
|
2900
4394
|
({
|
|
2901
4395
|
loading = true,
|
|
2902
4396
|
variant = "spinner",
|
|
@@ -2911,8 +4405,8 @@ var LoadingOverlay = React19.forwardRef(
|
|
|
2911
4405
|
children,
|
|
2912
4406
|
...props
|
|
2913
4407
|
}, ref) => {
|
|
2914
|
-
const [visible, setVisible] =
|
|
2915
|
-
|
|
4408
|
+
const [visible, setVisible] = React29.useState(delay === 0 && loading);
|
|
4409
|
+
React29.useEffect(() => {
|
|
2916
4410
|
if (!loading) {
|
|
2917
4411
|
setVisible(false);
|
|
2918
4412
|
return;
|
|
@@ -2925,23 +4419,23 @@ var LoadingOverlay = React19.forwardRef(
|
|
|
2925
4419
|
return () => clearTimeout(timer);
|
|
2926
4420
|
}, [loading, delay]);
|
|
2927
4421
|
if (!visible) {
|
|
2928
|
-
return mode === "inline" ? null : /* @__PURE__ */
|
|
4422
|
+
return mode === "inline" ? null : /* @__PURE__ */ jsx30(Fragment6, { children });
|
|
2929
4423
|
}
|
|
2930
|
-
const indicator = /* @__PURE__ */
|
|
2931
|
-
variant === "spinner" && /* @__PURE__ */
|
|
2932
|
-
variant === "logo" && /* @__PURE__ */
|
|
2933
|
-
variant === "progress" && /* @__PURE__ */
|
|
2934
|
-
variant === "skeleton" && /* @__PURE__ */
|
|
2935
|
-
/* @__PURE__ */
|
|
2936
|
-
/* @__PURE__ */
|
|
2937
|
-
/* @__PURE__ */
|
|
2938
|
-
/* @__PURE__ */
|
|
4424
|
+
const indicator = /* @__PURE__ */ jsxs21(Fragment6, { children: [
|
|
4425
|
+
variant === "spinner" && /* @__PURE__ */ jsx30(Spinner, { size: spinnerSizeMap[size] }),
|
|
4426
|
+
variant === "logo" && /* @__PURE__ */ jsx30(LoadingLogo, { loading: true, width: logoSizeMap[size], height: logoSizeMap[size] }),
|
|
4427
|
+
variant === "progress" && /* @__PURE__ */ jsx30(ProgressBar, { value: progress, className: "w-48 max-w-full" }),
|
|
4428
|
+
variant === "skeleton" && /* @__PURE__ */ jsxs21("div", { className: "w-full space-y-3", children: [
|
|
4429
|
+
/* @__PURE__ */ jsx30(Skeleton, { variant: "title" }),
|
|
4430
|
+
/* @__PURE__ */ jsx30(Skeleton, { variant: "text" }),
|
|
4431
|
+
/* @__PURE__ */ jsx30(Skeleton, { variant: "text" }),
|
|
4432
|
+
/* @__PURE__ */ jsx30(Skeleton, { variant: "text", className: "w-2/3" })
|
|
2939
4433
|
] }),
|
|
2940
|
-
message && /* @__PURE__ */
|
|
2941
|
-
!message && /* @__PURE__ */
|
|
4434
|
+
message && /* @__PURE__ */ jsx30("p", { className: "mt-2 text-sm text-muted-foreground animate-pulse-subtle", children: message }),
|
|
4435
|
+
!message && /* @__PURE__ */ jsx30("span", { className: "sr-only", children: "Loading" })
|
|
2942
4436
|
] });
|
|
2943
4437
|
if (mode === "inline") {
|
|
2944
|
-
return /* @__PURE__ */
|
|
4438
|
+
return /* @__PURE__ */ jsx30(
|
|
2945
4439
|
"div",
|
|
2946
4440
|
{
|
|
2947
4441
|
ref,
|
|
@@ -2955,9 +4449,9 @@ var LoadingOverlay = React19.forwardRef(
|
|
|
2955
4449
|
}
|
|
2956
4450
|
const bgClass = opaque ? "bg-background" : mode === "fullscreen" ? "bg-background/80" : "bg-background/60";
|
|
2957
4451
|
const positionClass = mode === "fullscreen" ? "fixed inset-0 z-50" : "absolute inset-0 z-10";
|
|
2958
|
-
return /* @__PURE__ */
|
|
4452
|
+
return /* @__PURE__ */ jsxs21(Fragment6, { children: [
|
|
2959
4453
|
children,
|
|
2960
|
-
/* @__PURE__ */
|
|
4454
|
+
/* @__PURE__ */ jsx30(
|
|
2961
4455
|
"div",
|
|
2962
4456
|
{
|
|
2963
4457
|
ref,
|
|
@@ -2980,9 +4474,9 @@ var LoadingOverlay = React19.forwardRef(
|
|
|
2980
4474
|
LoadingOverlay.displayName = "LoadingOverlay";
|
|
2981
4475
|
|
|
2982
4476
|
// src/components/LoadingPage.tsx
|
|
2983
|
-
import * as
|
|
2984
|
-
import { jsx as
|
|
2985
|
-
var LoadingPage =
|
|
4477
|
+
import * as React30 from "react";
|
|
4478
|
+
import { jsx as jsx31, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
4479
|
+
var LoadingPage = React30.forwardRef(
|
|
2986
4480
|
({
|
|
2987
4481
|
loading = true,
|
|
2988
4482
|
message,
|
|
@@ -2993,8 +4487,8 @@ var LoadingPage = React20.forwardRef(
|
|
|
2993
4487
|
className,
|
|
2994
4488
|
...props
|
|
2995
4489
|
}, ref) => {
|
|
2996
|
-
const [visible, setVisible] =
|
|
2997
|
-
|
|
4490
|
+
const [visible, setVisible] = React30.useState(delay === 0 && loading);
|
|
4491
|
+
React30.useEffect(() => {
|
|
2998
4492
|
if (!loading) {
|
|
2999
4493
|
setVisible(false);
|
|
3000
4494
|
return;
|
|
@@ -3007,7 +4501,7 @@ var LoadingPage = React20.forwardRef(
|
|
|
3007
4501
|
return () => clearTimeout(timer);
|
|
3008
4502
|
}, [loading, delay]);
|
|
3009
4503
|
if (!visible) return null;
|
|
3010
|
-
return /* @__PURE__ */
|
|
4504
|
+
return /* @__PURE__ */ jsxs22(
|
|
3011
4505
|
"div",
|
|
3012
4506
|
{
|
|
3013
4507
|
ref,
|
|
@@ -3019,10 +4513,10 @@ var LoadingPage = React20.forwardRef(
|
|
|
3019
4513
|
),
|
|
3020
4514
|
...props,
|
|
3021
4515
|
children: [
|
|
3022
|
-
showLogo ? /* @__PURE__ */
|
|
3023
|
-
progress !== void 0 && /* @__PURE__ */
|
|
3024
|
-
message && /* @__PURE__ */
|
|
3025
|
-
/* @__PURE__ */
|
|
4516
|
+
showLogo ? /* @__PURE__ */ jsx31(LoadingLogo, { loading: true, width: 64, height: 64, variant: logoVariant }) : /* @__PURE__ */ jsx31(Spinner, { size: "xl" }),
|
|
4517
|
+
progress !== void 0 && /* @__PURE__ */ jsx31(ProgressBar, { value: progress, className: "mt-6 w-48 max-w-full" }),
|
|
4518
|
+
message && /* @__PURE__ */ jsx31("p", { className: "mt-4 text-sm text-muted-foreground animate-pulse-subtle", children: message }),
|
|
4519
|
+
/* @__PURE__ */ jsxs22("span", { className: "sr-only", children: [
|
|
3026
4520
|
message || "Loading",
|
|
3027
4521
|
progress !== void 0 && `, ${Math.round(progress)}% complete`
|
|
3028
4522
|
] })
|
|
@@ -3034,9 +4528,9 @@ var LoadingPage = React20.forwardRef(
|
|
|
3034
4528
|
LoadingPage.displayName = "LoadingPage";
|
|
3035
4529
|
|
|
3036
4530
|
// src/components/LoadingSection.tsx
|
|
3037
|
-
import * as
|
|
3038
|
-
import { jsx as
|
|
3039
|
-
var LoadingSection =
|
|
4531
|
+
import * as React31 from "react";
|
|
4532
|
+
import { jsx as jsx32, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
4533
|
+
var LoadingSection = React31.forwardRef(
|
|
3040
4534
|
({
|
|
3041
4535
|
loading = false,
|
|
3042
4536
|
variant = "spinner",
|
|
@@ -3049,7 +4543,7 @@ var LoadingSection = React21.forwardRef(
|
|
|
3049
4543
|
children,
|
|
3050
4544
|
...props
|
|
3051
4545
|
}, ref) => {
|
|
3052
|
-
return /* @__PURE__ */
|
|
4546
|
+
return /* @__PURE__ */ jsxs23(
|
|
3053
4547
|
"div",
|
|
3054
4548
|
{
|
|
3055
4549
|
ref,
|
|
@@ -3059,7 +4553,7 @@ var LoadingSection = React21.forwardRef(
|
|
|
3059
4553
|
...props,
|
|
3060
4554
|
children: [
|
|
3061
4555
|
children,
|
|
3062
|
-
loading && /* @__PURE__ */
|
|
4556
|
+
loading && /* @__PURE__ */ jsx32(
|
|
3063
4557
|
LoadingOverlay,
|
|
3064
4558
|
{
|
|
3065
4559
|
mode: "overlay",
|
|
@@ -3078,11 +4572,11 @@ var LoadingSection = React21.forwardRef(
|
|
|
3078
4572
|
LoadingSection.displayName = "LoadingSection";
|
|
3079
4573
|
|
|
3080
4574
|
// src/components/LiveRegion.tsx
|
|
3081
|
-
import * as
|
|
3082
|
-
import { jsx as
|
|
3083
|
-
var LiveRegion =
|
|
4575
|
+
import * as React32 from "react";
|
|
4576
|
+
import { jsx as jsx33 } from "react/jsx-runtime";
|
|
4577
|
+
var LiveRegion = React32.forwardRef(
|
|
3084
4578
|
({ message, politeness = "polite", atomic = true, visuallyHidden = true, className, children }, ref) => {
|
|
3085
|
-
return /* @__PURE__ */
|
|
4579
|
+
return /* @__PURE__ */ jsx33(
|
|
3086
4580
|
"div",
|
|
3087
4581
|
{
|
|
3088
4582
|
ref,
|
|
@@ -3101,9 +4595,9 @@ var LiveRegion = React22.forwardRef(
|
|
|
3101
4595
|
LiveRegion.displayName = "LiveRegion";
|
|
3102
4596
|
|
|
3103
4597
|
// src/components/SkipLink.tsx
|
|
3104
|
-
import * as
|
|
3105
|
-
import { jsx as
|
|
3106
|
-
var SkipLink =
|
|
4598
|
+
import * as React33 from "react";
|
|
4599
|
+
import { jsx as jsx34 } from "react/jsx-runtime";
|
|
4600
|
+
var SkipLink = React33.forwardRef(
|
|
3107
4601
|
({ targetId, className, children = "Skip to main content", ...props }, ref) => {
|
|
3108
4602
|
const handleClick = (e) => {
|
|
3109
4603
|
e.preventDefault();
|
|
@@ -3121,7 +4615,7 @@ var SkipLink = React23.forwardRef(
|
|
|
3121
4615
|
}
|
|
3122
4616
|
props.onClick?.(e);
|
|
3123
4617
|
};
|
|
3124
|
-
return /* @__PURE__ */
|
|
4618
|
+
return /* @__PURE__ */ jsx34(
|
|
3125
4619
|
"a",
|
|
3126
4620
|
{
|
|
3127
4621
|
ref,
|
|
@@ -3137,11 +4631,11 @@ var SkipLink = React23.forwardRef(
|
|
|
3137
4631
|
SkipLink.displayName = "SkipLink";
|
|
3138
4632
|
|
|
3139
4633
|
// src/hooks/useFocusRef.ts
|
|
3140
|
-
import { useRef as
|
|
4634
|
+
import { useRef as useRef10, useEffect as useEffect12 } from "react";
|
|
3141
4635
|
function useFocusRef(options = {}) {
|
|
3142
4636
|
const { focusOnMount = false, preventScroll = false, delay = 0 } = options;
|
|
3143
|
-
const ref =
|
|
3144
|
-
|
|
4637
|
+
const ref = useRef10(null);
|
|
4638
|
+
useEffect12(() => {
|
|
3145
4639
|
if (!focusOnMount) return;
|
|
3146
4640
|
const focus = () => {
|
|
3147
4641
|
if (ref.current && typeof ref.current.focus === "function") {
|
|
@@ -3160,10 +4654,10 @@ function useFocusRef(options = {}) {
|
|
|
3160
4654
|
}
|
|
3161
4655
|
|
|
3162
4656
|
// src/hooks/useReducedMotion.ts
|
|
3163
|
-
import { useState as
|
|
4657
|
+
import { useState as useState13, useEffect as useEffect13 } from "react";
|
|
3164
4658
|
function useReducedMotion() {
|
|
3165
|
-
const [reducedMotion, setReducedMotion] =
|
|
3166
|
-
|
|
4659
|
+
const [reducedMotion, setReducedMotion] = useState13(false);
|
|
4660
|
+
useEffect13(() => {
|
|
3167
4661
|
const mediaQuery = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
3168
4662
|
setReducedMotion(mediaQuery.matches);
|
|
3169
4663
|
const handleChange = (event) => {
|
|
@@ -3178,7 +4672,7 @@ function useReducedMotion() {
|
|
|
3178
4672
|
}
|
|
3179
4673
|
|
|
3180
4674
|
// src/hooks/useArrowNavigation.ts
|
|
3181
|
-
import { useCallback as
|
|
4675
|
+
import { useCallback as useCallback5, useRef as useRef11, useState as useState14 } from "react";
|
|
3182
4676
|
var DEFAULT_SELECTOR = '[role="menuitem"], [role="option"], [role="tab"], button, a, [tabindex]:not([tabindex="-1"])';
|
|
3183
4677
|
function useArrowNavigation(options = {}) {
|
|
3184
4678
|
const {
|
|
@@ -3187,18 +4681,18 @@ function useArrowNavigation(options = {}) {
|
|
|
3187
4681
|
itemSelector = DEFAULT_SELECTOR,
|
|
3188
4682
|
onFocusChange
|
|
3189
4683
|
} = options;
|
|
3190
|
-
const containerRef =
|
|
3191
|
-
const focusedIndexRef =
|
|
3192
|
-
const [focusedIndex, setFocusedIndexState] =
|
|
3193
|
-
const setFocusedIndex =
|
|
4684
|
+
const containerRef = useRef11(null);
|
|
4685
|
+
const focusedIndexRef = useRef11(-1);
|
|
4686
|
+
const [focusedIndex, setFocusedIndexState] = useState14(-1);
|
|
4687
|
+
const setFocusedIndex = useCallback5((index) => {
|
|
3194
4688
|
focusedIndexRef.current = index;
|
|
3195
4689
|
setFocusedIndexState(index);
|
|
3196
4690
|
}, []);
|
|
3197
|
-
const getFocusableItems =
|
|
4691
|
+
const getFocusableItems = useCallback5(() => {
|
|
3198
4692
|
if (!containerRef.current) return [];
|
|
3199
4693
|
return Array.from(containerRef.current.querySelectorAll(itemSelector));
|
|
3200
4694
|
}, [itemSelector]);
|
|
3201
|
-
const focusItem =
|
|
4695
|
+
const focusItem = useCallback5(
|
|
3202
4696
|
(index) => {
|
|
3203
4697
|
const items = getFocusableItems();
|
|
3204
4698
|
if (items.length === 0) return;
|
|
@@ -3218,7 +4712,7 @@ function useArrowNavigation(options = {}) {
|
|
|
3218
4712
|
},
|
|
3219
4713
|
[getFocusableItems, loop, onFocusChange, setFocusedIndex]
|
|
3220
4714
|
);
|
|
3221
|
-
const handleKeyDown =
|
|
4715
|
+
const handleKeyDown = useCallback5(
|
|
3222
4716
|
(event) => {
|
|
3223
4717
|
const items = getFocusableItems();
|
|
3224
4718
|
if (items.length === 0) return;
|
|
@@ -3265,7 +4759,7 @@ function useArrowNavigation(options = {}) {
|
|
|
3265
4759
|
},
|
|
3266
4760
|
[orientation, focusItem, getFocusableItems]
|
|
3267
4761
|
);
|
|
3268
|
-
const handleFocus =
|
|
4762
|
+
const handleFocus = useCallback5(
|
|
3269
4763
|
(event) => {
|
|
3270
4764
|
const items = getFocusableItems();
|
|
3271
4765
|
const index = items.indexOf(event.target);
|
|
@@ -3283,7 +4777,7 @@ function useArrowNavigation(options = {}) {
|
|
|
3283
4777
|
onFocus: handleFocus
|
|
3284
4778
|
};
|
|
3285
4779
|
const tabStopIndex = focusedIndex === -1 ? 0 : focusedIndex;
|
|
3286
|
-
const getItemProps =
|
|
4780
|
+
const getItemProps = useCallback5(
|
|
3287
4781
|
(index) => ({
|
|
3288
4782
|
tabIndex: index === tabStopIndex ? 0 : -1,
|
|
3289
4783
|
onFocus: () => {
|
|
@@ -3301,20 +4795,20 @@ function useArrowNavigation(options = {}) {
|
|
|
3301
4795
|
}
|
|
3302
4796
|
|
|
3303
4797
|
// src/hooks/useRovingTabindex.ts
|
|
3304
|
-
import { useState as
|
|
4798
|
+
import { useState as useState15, useCallback as useCallback6, useRef as useRef12 } from "react";
|
|
3305
4799
|
var DEFAULT_SELECTOR2 = "[data-roving-tabindex-item]";
|
|
3306
4800
|
function useRovingTabindex(options = {}) {
|
|
3307
4801
|
const { loop = true, itemSelector = DEFAULT_SELECTOR2, initialIndex = 0, onIndexChange } = options;
|
|
3308
|
-
const [activeIndex, setActiveIndex] =
|
|
3309
|
-
const containerRef =
|
|
3310
|
-
const itemsRef =
|
|
3311
|
-
const getItems =
|
|
4802
|
+
const [activeIndex, setActiveIndex] = useState15(initialIndex);
|
|
4803
|
+
const containerRef = useRef12(null);
|
|
4804
|
+
const itemsRef = useRef12(/* @__PURE__ */ new Map());
|
|
4805
|
+
const getItems = useCallback6(() => {
|
|
3312
4806
|
if (!containerRef.current) {
|
|
3313
4807
|
return Array.from(itemsRef.current.values());
|
|
3314
4808
|
}
|
|
3315
4809
|
return Array.from(containerRef.current.querySelectorAll(itemSelector));
|
|
3316
4810
|
}, [itemSelector]);
|
|
3317
|
-
const focusIndex =
|
|
4811
|
+
const focusIndex = useCallback6(
|
|
3318
4812
|
(index) => {
|
|
3319
4813
|
const items = getItems();
|
|
3320
4814
|
if (items.length === 0) return;
|
|
@@ -3334,7 +4828,7 @@ function useRovingTabindex(options = {}) {
|
|
|
3334
4828
|
},
|
|
3335
4829
|
[getItems, loop, onIndexChange]
|
|
3336
4830
|
);
|
|
3337
|
-
const handleKeyDown =
|
|
4831
|
+
const handleKeyDown = useCallback6(
|
|
3338
4832
|
(event) => {
|
|
3339
4833
|
const items = getItems();
|
|
3340
4834
|
if (items.length === 0) return;
|
|
@@ -3372,7 +4866,7 @@ function useRovingTabindex(options = {}) {
|
|
|
3372
4866
|
},
|
|
3373
4867
|
onKeyDown: handleKeyDown
|
|
3374
4868
|
};
|
|
3375
|
-
const getItemProps =
|
|
4869
|
+
const getItemProps = useCallback6(
|
|
3376
4870
|
(index) => ({
|
|
3377
4871
|
"data-roving-tabindex-item": true,
|
|
3378
4872
|
tabIndex: index === activeIndex ? 0 : -1,
|
|
@@ -3409,21 +4903,21 @@ function useRovingTabindex(options = {}) {
|
|
|
3409
4903
|
}
|
|
3410
4904
|
|
|
3411
4905
|
// src/hooks/useClickOutside.ts
|
|
3412
|
-
import * as
|
|
4906
|
+
import * as React34 from "react";
|
|
3413
4907
|
function useClickOutside(ref, callback, options) {
|
|
3414
4908
|
const {
|
|
3415
4909
|
enabled = true,
|
|
3416
4910
|
events = ["mousedown", "touchstart"],
|
|
3417
4911
|
ignoreElements = []
|
|
3418
4912
|
} = options ?? {};
|
|
3419
|
-
const callbackRef =
|
|
3420
|
-
const ignoreElementsRef =
|
|
3421
|
-
|
|
4913
|
+
const callbackRef = React34.useRef(callback);
|
|
4914
|
+
const ignoreElementsRef = React34.useRef(ignoreElements);
|
|
4915
|
+
React34.useEffect(() => {
|
|
3422
4916
|
callbackRef.current = callback;
|
|
3423
4917
|
ignoreElementsRef.current = ignoreElements;
|
|
3424
4918
|
}, [callback, ignoreElements]);
|
|
3425
4919
|
const eventsKey = events.join(",");
|
|
3426
|
-
|
|
4920
|
+
React34.useEffect(() => {
|
|
3427
4921
|
if (!enabled) return;
|
|
3428
4922
|
const handleEvent = (event) => {
|
|
3429
4923
|
const target = event.target;
|
|
@@ -3476,6 +4970,8 @@ export {
|
|
|
3476
4970
|
DialogTitle,
|
|
3477
4971
|
DialogTrigger,
|
|
3478
4972
|
Input,
|
|
4973
|
+
InsertPalette,
|
|
4974
|
+
IssuesButton,
|
|
3479
4975
|
Label,
|
|
3480
4976
|
LiveRegion,
|
|
3481
4977
|
LoadingLogo,
|
|
@@ -3485,10 +4981,21 @@ export {
|
|
|
3485
4981
|
PageHeader,
|
|
3486
4982
|
PasswordInput,
|
|
3487
4983
|
ProgressBar,
|
|
4984
|
+
SaveStatus,
|
|
3488
4985
|
Separator,
|
|
4986
|
+
Sheet,
|
|
3489
4987
|
Skeleton,
|
|
3490
4988
|
SkipLink,
|
|
4989
|
+
SortableList,
|
|
3491
4990
|
Spinner,
|
|
4991
|
+
Studio,
|
|
4992
|
+
StudioBar,
|
|
4993
|
+
StudioCanvas,
|
|
4994
|
+
StudioCanvasItem,
|
|
4995
|
+
StudioInspector,
|
|
4996
|
+
StudioInspectorSection,
|
|
4997
|
+
StudioOutline,
|
|
4998
|
+
StudioPage,
|
|
3492
4999
|
Switch,
|
|
3493
5000
|
badgeVariants,
|
|
3494
5001
|
buttonVariants,
|
|
@@ -3508,5 +5015,6 @@ export {
|
|
|
3508
5015
|
useFocusRef,
|
|
3509
5016
|
useFocusTrap,
|
|
3510
5017
|
useReducedMotion,
|
|
3511
|
-
useRovingTabindex
|
|
5018
|
+
useRovingTabindex,
|
|
5019
|
+
useStudio
|
|
3512
5020
|
};
|