@classic-homes/theme-react 0.2.3 → 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 +1779 -264
- package/dist/index.mjs +1793 -292
- 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,15 +2306,15 @@ import {
|
|
|
819
2306
|
calculateDetachedPositionFromPinned,
|
|
820
2307
|
getPinnedPullTransform
|
|
821
2308
|
} from "@classic-homes/data-panel-core";
|
|
822
|
-
import { Fragment, jsx as
|
|
2309
|
+
import { Fragment as Fragment5, jsx as jsx25, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
823
2310
|
function layoutViewportWidth() {
|
|
824
2311
|
return document.documentElement.clientWidth;
|
|
825
2312
|
}
|
|
826
|
-
var DropdownTrigger =
|
|
827
|
-
var DropdownContent =
|
|
828
|
-
var DropdownLabel =
|
|
829
|
-
var DropdownItem =
|
|
830
|
-
var DropdownSeparator =
|
|
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;
|
|
831
2318
|
function useDataPanel(options = {}) {
|
|
832
2319
|
const {
|
|
833
2320
|
persistKey,
|
|
@@ -837,28 +2324,28 @@ function useDataPanel(options = {}) {
|
|
|
837
2324
|
constraints = {}
|
|
838
2325
|
} = options;
|
|
839
2326
|
const resolvedConstraints = { ...DEFAULT_CONSTRAINTS, ...constraints };
|
|
840
|
-
const [persistedState] =
|
|
2327
|
+
const [persistedState] = React24.useState(() => {
|
|
841
2328
|
if (persistKey && typeof window !== "undefined") {
|
|
842
2329
|
return loadPanelState(persistKey);
|
|
843
2330
|
}
|
|
844
2331
|
return null;
|
|
845
2332
|
});
|
|
846
|
-
const [mode, setMode] =
|
|
847
|
-
const [edge, setEdge] =
|
|
848
|
-
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(
|
|
849
2336
|
persistedState?.isExpanded ?? initialExpanded
|
|
850
2337
|
);
|
|
851
|
-
const [detachedPosition, setDetachedPosition] =
|
|
2338
|
+
const [detachedPosition, setDetachedPosition] = React24.useState(
|
|
852
2339
|
persistedState?.detachedPosition ?? DEFAULT_PANEL_STATE.detachedPosition
|
|
853
2340
|
);
|
|
854
|
-
const [detachedSize, setDetachedSize] =
|
|
2341
|
+
const [detachedSize, setDetachedSize] = React24.useState(
|
|
855
2342
|
persistedState?.detachedSize ?? DEFAULT_PANEL_STATE.detachedSize
|
|
856
2343
|
);
|
|
857
|
-
const [pinnedSize, setPinnedSize] =
|
|
2344
|
+
const [pinnedSize, setPinnedSize] = React24.useState(
|
|
858
2345
|
persistedState?.pinnedSize ?? DEFAULT_PANEL_STATE.pinnedSize
|
|
859
2346
|
);
|
|
860
|
-
const saveTimeoutRef =
|
|
861
|
-
const debouncedSave =
|
|
2347
|
+
const saveTimeoutRef = React24.useRef(null);
|
|
2348
|
+
const debouncedSave = React24.useCallback(() => {
|
|
862
2349
|
if (!persistKey) return;
|
|
863
2350
|
if (saveTimeoutRef.current) {
|
|
864
2351
|
clearTimeout(saveTimeoutRef.current);
|
|
@@ -877,7 +2364,7 @@ function useDataPanel(options = {}) {
|
|
|
877
2364
|
});
|
|
878
2365
|
}, 300);
|
|
879
2366
|
}, [persistKey, mode, edge, isExpanded, detachedPosition, detachedSize, pinnedSize]);
|
|
880
|
-
const handleSetMode =
|
|
2367
|
+
const handleSetMode = React24.useCallback(
|
|
881
2368
|
(newMode) => {
|
|
882
2369
|
setMode(newMode);
|
|
883
2370
|
if (newMode === "detached" && typeof window !== "undefined" && detachedPosition.x === DEFAULT_PANEL_STATE.detachedPosition.x && detachedPosition.y === DEFAULT_PANEL_STATE.detachedPosition.y) {
|
|
@@ -888,7 +2375,7 @@ function useDataPanel(options = {}) {
|
|
|
888
2375
|
},
|
|
889
2376
|
[detachedPosition, detachedSize]
|
|
890
2377
|
);
|
|
891
|
-
const handleSetDetachedPosition =
|
|
2378
|
+
const handleSetDetachedPosition = React24.useCallback(
|
|
892
2379
|
(position) => {
|
|
893
2380
|
if (typeof window === "undefined") {
|
|
894
2381
|
setDetachedPosition(position);
|
|
@@ -900,13 +2387,13 @@ function useDataPanel(options = {}) {
|
|
|
900
2387
|
},
|
|
901
2388
|
[detachedSize]
|
|
902
2389
|
);
|
|
903
|
-
const handleSetDetachedSize =
|
|
2390
|
+
const handleSetDetachedSize = React24.useCallback(
|
|
904
2391
|
(size) => {
|
|
905
2392
|
setDetachedSize(constrainSize(size, resolvedConstraints));
|
|
906
2393
|
},
|
|
907
2394
|
[resolvedConstraints]
|
|
908
2395
|
);
|
|
909
|
-
const handleSetPinnedSize =
|
|
2396
|
+
const handleSetPinnedSize = React24.useCallback(
|
|
910
2397
|
(size) => {
|
|
911
2398
|
if (typeof window === "undefined") {
|
|
912
2399
|
setPinnedSize(size);
|
|
@@ -920,7 +2407,7 @@ function useDataPanel(options = {}) {
|
|
|
920
2407
|
},
|
|
921
2408
|
[edge, resolvedConstraints]
|
|
922
2409
|
);
|
|
923
|
-
|
|
2410
|
+
React24.useEffect(() => {
|
|
924
2411
|
debouncedSave();
|
|
925
2412
|
}, [debouncedSave]);
|
|
926
2413
|
return {
|
|
@@ -938,7 +2425,7 @@ function useDataPanel(options = {}) {
|
|
|
938
2425
|
setPinnedSize: handleSetPinnedSize
|
|
939
2426
|
};
|
|
940
2427
|
}
|
|
941
|
-
var ChevronUpIcon = () => /* @__PURE__ */
|
|
2428
|
+
var ChevronUpIcon = () => /* @__PURE__ */ jsx25(
|
|
942
2429
|
"svg",
|
|
943
2430
|
{
|
|
944
2431
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -950,10 +2437,10 @@ var ChevronUpIcon = () => /* @__PURE__ */ jsx12(
|
|
|
950
2437
|
strokeWidth: "2",
|
|
951
2438
|
strokeLinecap: "round",
|
|
952
2439
|
strokeLinejoin: "round",
|
|
953
|
-
children: /* @__PURE__ */
|
|
2440
|
+
children: /* @__PURE__ */ jsx25("path", { d: "m18 15-6-6-6 6" })
|
|
954
2441
|
}
|
|
955
2442
|
);
|
|
956
|
-
var MoreVerticalIcon = () => /* @__PURE__ */
|
|
2443
|
+
var MoreVerticalIcon = () => /* @__PURE__ */ jsxs17(
|
|
957
2444
|
"svg",
|
|
958
2445
|
{
|
|
959
2446
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -966,13 +2453,13 @@ var MoreVerticalIcon = () => /* @__PURE__ */ jsxs5(
|
|
|
966
2453
|
strokeLinecap: "round",
|
|
967
2454
|
strokeLinejoin: "round",
|
|
968
2455
|
children: [
|
|
969
|
-
/* @__PURE__ */
|
|
970
|
-
/* @__PURE__ */
|
|
971
|
-
/* @__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" })
|
|
972
2459
|
]
|
|
973
2460
|
}
|
|
974
2461
|
);
|
|
975
|
-
var CloseIcon = () => /* @__PURE__ */
|
|
2462
|
+
var CloseIcon = () => /* @__PURE__ */ jsxs17(
|
|
976
2463
|
"svg",
|
|
977
2464
|
{
|
|
978
2465
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -985,12 +2472,12 @@ var CloseIcon = () => /* @__PURE__ */ jsxs5(
|
|
|
985
2472
|
strokeLinecap: "round",
|
|
986
2473
|
strokeLinejoin: "round",
|
|
987
2474
|
children: [
|
|
988
|
-
/* @__PURE__ */
|
|
989
|
-
/* @__PURE__ */
|
|
2475
|
+
/* @__PURE__ */ jsx25("path", { d: "M18 6 6 18" }),
|
|
2476
|
+
/* @__PURE__ */ jsx25("path", { d: "m6 6 12 12" })
|
|
990
2477
|
]
|
|
991
2478
|
}
|
|
992
2479
|
);
|
|
993
|
-
var GripIcon = () => /* @__PURE__ */
|
|
2480
|
+
var GripIcon = () => /* @__PURE__ */ jsxs17(
|
|
994
2481
|
"svg",
|
|
995
2482
|
{
|
|
996
2483
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -999,12 +2486,12 @@ var GripIcon = () => /* @__PURE__ */ jsxs5(
|
|
|
999
2486
|
viewBox: "0 0 24 24",
|
|
1000
2487
|
fill: "currentColor",
|
|
1001
2488
|
children: [
|
|
1002
|
-
/* @__PURE__ */
|
|
1003
|
-
/* @__PURE__ */
|
|
1004
|
-
/* @__PURE__ */
|
|
1005
|
-
/* @__PURE__ */
|
|
1006
|
-
/* @__PURE__ */
|
|
1007
|
-
/* @__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" })
|
|
1008
2495
|
]
|
|
1009
2496
|
}
|
|
1010
2497
|
);
|
|
@@ -1014,7 +2501,7 @@ var edgeLabels = {
|
|
|
1014
2501
|
top: "Pin to top",
|
|
1015
2502
|
bottom: "Pin to bottom"
|
|
1016
2503
|
};
|
|
1017
|
-
var DataPanelHeader =
|
|
2504
|
+
var DataPanelHeader = React24.forwardRef(
|
|
1018
2505
|
({
|
|
1019
2506
|
title,
|
|
1020
2507
|
subtitle,
|
|
@@ -1033,7 +2520,7 @@ var DataPanelHeader = React14.forwardRef(
|
|
|
1033
2520
|
className,
|
|
1034
2521
|
draggable = false
|
|
1035
2522
|
}, ref) => {
|
|
1036
|
-
return /* @__PURE__ */
|
|
2523
|
+
return /* @__PURE__ */ jsxs17(
|
|
1037
2524
|
"div",
|
|
1038
2525
|
{
|
|
1039
2526
|
ref,
|
|
@@ -1044,13 +2531,13 @@ var DataPanelHeader = React14.forwardRef(
|
|
|
1044
2531
|
),
|
|
1045
2532
|
"data-panel-header": true,
|
|
1046
2533
|
children: [
|
|
1047
|
-
/* @__PURE__ */
|
|
1048
|
-
title && /* @__PURE__ */
|
|
1049
|
-
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 })
|
|
1050
2537
|
] }) }),
|
|
1051
|
-
/* @__PURE__ */
|
|
2538
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex items-center gap-1 shrink-0", children: [
|
|
1052
2539
|
headerActions,
|
|
1053
|
-
/* @__PURE__ */
|
|
2540
|
+
/* @__PURE__ */ jsx25(
|
|
1054
2541
|
"button",
|
|
1055
2542
|
{
|
|
1056
2543
|
type: "button",
|
|
@@ -1065,37 +2552,37 @@ var DataPanelHeader = React14.forwardRef(
|
|
|
1065
2552
|
},
|
|
1066
2553
|
"aria-label": isExpanded ? "Collapse panel" : "Expand panel",
|
|
1067
2554
|
"aria-expanded": isExpanded,
|
|
1068
|
-
children: /* @__PURE__ */
|
|
2555
|
+
children: /* @__PURE__ */ jsx25(
|
|
1069
2556
|
"span",
|
|
1070
2557
|
{
|
|
1071
2558
|
className: cn(
|
|
1072
2559
|
"transition-transform",
|
|
1073
2560
|
{ top: "", bottom: "rotate-180", left: "-rotate-90", right: "rotate-90" }[edge]
|
|
1074
2561
|
),
|
|
1075
|
-
children: /* @__PURE__ */
|
|
2562
|
+
children: /* @__PURE__ */ jsx25(ChevronUpIcon, {})
|
|
1076
2563
|
}
|
|
1077
2564
|
)
|
|
1078
2565
|
}
|
|
1079
2566
|
),
|
|
1080
|
-
!disableModeSwitch && /* @__PURE__ */
|
|
1081
|
-
/* @__PURE__ */
|
|
2567
|
+
!disableModeSwitch && /* @__PURE__ */ jsxs17(DropdownMenuPrimitive2.Root, { children: [
|
|
2568
|
+
/* @__PURE__ */ jsx25(DropdownTrigger, { asChild: true, children: /* @__PURE__ */ jsx25(
|
|
1082
2569
|
"button",
|
|
1083
2570
|
{
|
|
1084
2571
|
type: "button",
|
|
1085
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",
|
|
1086
2573
|
"aria-label": "Panel options",
|
|
1087
|
-
children: /* @__PURE__ */
|
|
2574
|
+
children: /* @__PURE__ */ jsx25(MoreVerticalIcon, {})
|
|
1088
2575
|
}
|
|
1089
2576
|
) }),
|
|
1090
|
-
/* @__PURE__ */
|
|
2577
|
+
/* @__PURE__ */ jsx25(DropdownMenuPrimitive2.Portal, { children: /* @__PURE__ */ jsxs17(
|
|
1091
2578
|
DropdownContent,
|
|
1092
2579
|
{
|
|
1093
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",
|
|
1094
2581
|
sideOffset: 4,
|
|
1095
2582
|
align: "end",
|
|
1096
2583
|
children: [
|
|
1097
|
-
/* @__PURE__ */
|
|
1098
|
-
["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(
|
|
1099
2586
|
DropdownItem,
|
|
1100
2587
|
{
|
|
1101
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",
|
|
@@ -1105,20 +2592,20 @@ var DataPanelHeader = React14.forwardRef(
|
|
|
1105
2592
|
},
|
|
1106
2593
|
children: [
|
|
1107
2594
|
edgeLabels[e],
|
|
1108
|
-
mode === "pinned" && edge === e && /* @__PURE__ */
|
|
2595
|
+
mode === "pinned" && edge === e && /* @__PURE__ */ jsx25("span", { className: "ml-auto text-xs", children: "\u2713" })
|
|
1109
2596
|
]
|
|
1110
2597
|
},
|
|
1111
2598
|
e
|
|
1112
2599
|
)),
|
|
1113
|
-
/* @__PURE__ */
|
|
1114
|
-
/* @__PURE__ */
|
|
2600
|
+
/* @__PURE__ */ jsx25(DropdownSeparator, { className: "-mx-1 my-1 h-px bg-muted" }),
|
|
2601
|
+
/* @__PURE__ */ jsxs17(
|
|
1115
2602
|
DropdownItem,
|
|
1116
2603
|
{
|
|
1117
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",
|
|
1118
2605
|
onSelect: () => onModeChange?.("detached"),
|
|
1119
2606
|
children: [
|
|
1120
2607
|
"Detach",
|
|
1121
|
-
mode === "detached" && /* @__PURE__ */
|
|
2608
|
+
mode === "detached" && /* @__PURE__ */ jsx25("span", { className: "ml-auto text-xs", children: "\u2713" })
|
|
1122
2609
|
]
|
|
1123
2610
|
}
|
|
1124
2611
|
)
|
|
@@ -1126,14 +2613,14 @@ var DataPanelHeader = React14.forwardRef(
|
|
|
1126
2613
|
}
|
|
1127
2614
|
) })
|
|
1128
2615
|
] }),
|
|
1129
|
-
!disableClose && /* @__PURE__ */
|
|
2616
|
+
!disableClose && /* @__PURE__ */ jsx25(
|
|
1130
2617
|
"button",
|
|
1131
2618
|
{
|
|
1132
2619
|
type: "button",
|
|
1133
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",
|
|
1134
2621
|
onClick: onClose,
|
|
1135
2622
|
"aria-label": "Close panel",
|
|
1136
|
-
children: /* @__PURE__ */
|
|
2623
|
+
children: /* @__PURE__ */ jsx25(CloseIcon, {})
|
|
1137
2624
|
}
|
|
1138
2625
|
)
|
|
1139
2626
|
] })
|
|
@@ -1157,14 +2644,14 @@ function DataPanelCardHeader({
|
|
|
1157
2644
|
onToggleExpand,
|
|
1158
2645
|
onClose
|
|
1159
2646
|
}) {
|
|
1160
|
-
return /* @__PURE__ */
|
|
2647
|
+
return /* @__PURE__ */ jsxs17(
|
|
1161
2648
|
"div",
|
|
1162
2649
|
{
|
|
1163
2650
|
"data-panel-header": true,
|
|
1164
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",
|
|
1165
2652
|
onPointerDown: onHeaderPointerDown,
|
|
1166
2653
|
children: [
|
|
1167
|
-
showDragHandle && /* @__PURE__ */
|
|
2654
|
+
showDragHandle && /* @__PURE__ */ jsx25(
|
|
1168
2655
|
"div",
|
|
1169
2656
|
{
|
|
1170
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",
|
|
@@ -1176,22 +2663,22 @@ function DataPanelCardHeader({
|
|
|
1176
2663
|
onKeyDown: (e) => (e.key === "Enter" || e.key === " ") && onToggleExpand()
|
|
1177
2664
|
}
|
|
1178
2665
|
),
|
|
1179
|
-
/* @__PURE__ */
|
|
2666
|
+
/* @__PURE__ */ jsx25(
|
|
1180
2667
|
"div",
|
|
1181
2668
|
{
|
|
1182
2669
|
className: "flex-1 min-w-0",
|
|
1183
2670
|
role: "button",
|
|
1184
2671
|
tabIndex: 0,
|
|
1185
2672
|
onKeyDown: (e) => (e.key === "Enter" || e.key === " ") && onToggleExpand(),
|
|
1186
|
-
children: headerContent ? headerContent : /* @__PURE__ */
|
|
1187
|
-
subtitle && /* @__PURE__ */
|
|
1188
|
-
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 })
|
|
1189
2676
|
] })
|
|
1190
2677
|
}
|
|
1191
2678
|
),
|
|
1192
|
-
/* @__PURE__ */
|
|
2679
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex items-center gap-1 shrink-0", children: [
|
|
1193
2680
|
headerActions,
|
|
1194
|
-
!isMobile && /* @__PURE__ */
|
|
2681
|
+
!isMobile && /* @__PURE__ */ jsx25(
|
|
1195
2682
|
"button",
|
|
1196
2683
|
{
|
|
1197
2684
|
"data-card-drag-handle": true,
|
|
@@ -1200,10 +2687,10 @@ function DataPanelCardHeader({
|
|
|
1200
2687
|
"aria-label": "Drag to reposition panel",
|
|
1201
2688
|
title: "Drag to move",
|
|
1202
2689
|
onPointerDown: onHeaderPointerDown,
|
|
1203
|
-
children: /* @__PURE__ */
|
|
2690
|
+
children: /* @__PURE__ */ jsx25(GripIcon, {})
|
|
1204
2691
|
}
|
|
1205
2692
|
),
|
|
1206
|
-
/* @__PURE__ */
|
|
2693
|
+
/* @__PURE__ */ jsx25(
|
|
1207
2694
|
"button",
|
|
1208
2695
|
{
|
|
1209
2696
|
type: "button",
|
|
@@ -1212,17 +2699,17 @@ function DataPanelCardHeader({
|
|
|
1212
2699
|
"aria-expanded": isExpanded,
|
|
1213
2700
|
"aria-label": isExpanded ? "Collapse panel" : "Expand panel",
|
|
1214
2701
|
title: isExpanded ? "Collapse" : "Expand",
|
|
1215
|
-
children: /* @__PURE__ */
|
|
2702
|
+
children: /* @__PURE__ */ jsx25("span", { className: cn("inline-flex transition-transform", isExpanded && "rotate-180"), children: /* @__PURE__ */ jsx25(ChevronUpIcon, {}) })
|
|
1216
2703
|
}
|
|
1217
2704
|
),
|
|
1218
|
-
!disableClose && /* @__PURE__ */
|
|
2705
|
+
!disableClose && /* @__PURE__ */ jsx25(
|
|
1219
2706
|
"button",
|
|
1220
2707
|
{
|
|
1221
2708
|
type: "button",
|
|
1222
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",
|
|
1223
2710
|
onClick: onClose,
|
|
1224
2711
|
"aria-label": "Close panel",
|
|
1225
|
-
children: /* @__PURE__ */
|
|
2712
|
+
children: /* @__PURE__ */ jsx25(CloseIcon, {})
|
|
1226
2713
|
}
|
|
1227
2714
|
)
|
|
1228
2715
|
] })
|
|
@@ -1230,9 +2717,9 @@ function DataPanelCardHeader({
|
|
|
1230
2717
|
}
|
|
1231
2718
|
);
|
|
1232
2719
|
}
|
|
1233
|
-
var DataPanelContent =
|
|
2720
|
+
var DataPanelContent = React24.forwardRef(
|
|
1234
2721
|
({ children, className, "aria-label": ariaLabel = "Panel content" }, ref) => {
|
|
1235
|
-
return /* @__PURE__ */
|
|
2722
|
+
return /* @__PURE__ */ jsx25(
|
|
1236
2723
|
"div",
|
|
1237
2724
|
{
|
|
1238
2725
|
ref,
|
|
@@ -1245,7 +2732,7 @@ var DataPanelContent = React14.forwardRef(
|
|
|
1245
2732
|
}
|
|
1246
2733
|
);
|
|
1247
2734
|
DataPanelContent.displayName = "DataPanelContent";
|
|
1248
|
-
var DataPanelFooter =
|
|
2735
|
+
var DataPanelFooter = React24.forwardRef(
|
|
1249
2736
|
({ actions = [], footerContent, footerActions, className }, ref) => {
|
|
1250
2737
|
if (!footerContent && actions.length === 0 && !footerActions) {
|
|
1251
2738
|
return null;
|
|
@@ -1254,7 +2741,7 @@ var DataPanelFooter = React14.forwardRef(
|
|
|
1254
2741
|
if (variant === "primary") return "default";
|
|
1255
2742
|
return variant ?? "default";
|
|
1256
2743
|
};
|
|
1257
|
-
return /* @__PURE__ */
|
|
2744
|
+
return /* @__PURE__ */ jsx25(
|
|
1258
2745
|
"div",
|
|
1259
2746
|
{
|
|
1260
2747
|
ref,
|
|
@@ -1262,9 +2749,9 @@ var DataPanelFooter = React14.forwardRef(
|
|
|
1262
2749
|
"flex items-center justify-end gap-2 border-t border-border bg-muted/30 px-4 py-3",
|
|
1263
2750
|
className
|
|
1264
2751
|
),
|
|
1265
|
-
children: footerContent ? footerContent : /* @__PURE__ */
|
|
2752
|
+
children: footerContent ? footerContent : /* @__PURE__ */ jsxs17(Fragment5, { children: [
|
|
1266
2753
|
footerActions,
|
|
1267
|
-
actions.map((action, index) => /* @__PURE__ */
|
|
2754
|
+
actions.map((action, index) => /* @__PURE__ */ jsx25(
|
|
1268
2755
|
Button,
|
|
1269
2756
|
{
|
|
1270
2757
|
variant: mapVariant(action.variant),
|
|
@@ -1281,7 +2768,7 @@ var DataPanelFooter = React14.forwardRef(
|
|
|
1281
2768
|
}
|
|
1282
2769
|
);
|
|
1283
2770
|
DataPanelFooter.displayName = "DataPanelFooter";
|
|
1284
|
-
var DataPanelTab =
|
|
2771
|
+
var DataPanelTab = React24.forwardRef(
|
|
1285
2772
|
({
|
|
1286
2773
|
title = "Panel",
|
|
1287
2774
|
subtitle,
|
|
@@ -1307,15 +2794,15 @@ var DataPanelTab = React14.forwardRef(
|
|
|
1307
2794
|
bottom: "left-1/2 rounded-t-lg border-b-0"
|
|
1308
2795
|
}[edge];
|
|
1309
2796
|
const insetStyle = { [edge]: tabInset };
|
|
1310
|
-
const innerRef =
|
|
1311
|
-
const dragRef =
|
|
2797
|
+
const innerRef = React24.useRef(null);
|
|
2798
|
+
const dragRef = React24.useRef({
|
|
1312
2799
|
startX: 0,
|
|
1313
2800
|
startY: 0,
|
|
1314
2801
|
startOffset: 0,
|
|
1315
2802
|
moved: false,
|
|
1316
2803
|
pointerId: -1
|
|
1317
2804
|
});
|
|
1318
|
-
const [dragOffset, setDragOffset] =
|
|
2805
|
+
const [dragOffset, setDragOffset] = React24.useState(null);
|
|
1319
2806
|
const effectiveOffset = dragOffset ?? offset;
|
|
1320
2807
|
const draggable = !!onOffsetChange;
|
|
1321
2808
|
const tabTransform = getTabTransform(edge, tabWidth, effectiveOffset);
|
|
@@ -1384,7 +2871,7 @@ var DataPanelTab = React14.forwardRef(
|
|
|
1384
2871
|
onClick?.();
|
|
1385
2872
|
}
|
|
1386
2873
|
};
|
|
1387
|
-
|
|
2874
|
+
React24.useEffect(() => {
|
|
1388
2875
|
if (!onOffsetChange || dragOffset !== null) return;
|
|
1389
2876
|
const reclamp = () => {
|
|
1390
2877
|
const clamped = constrainTabOffset(
|
|
@@ -1400,7 +2887,7 @@ var DataPanelTab = React14.forwardRef(
|
|
|
1400
2887
|
window.addEventListener("resize", reclamp);
|
|
1401
2888
|
return () => window.removeEventListener("resize", reclamp);
|
|
1402
2889
|
}, [edge, tabWidth, offset, onOffsetChange, dragOffset]);
|
|
1403
|
-
return /* @__PURE__ */
|
|
2890
|
+
return /* @__PURE__ */ jsxs17(
|
|
1404
2891
|
"div",
|
|
1405
2892
|
{
|
|
1406
2893
|
ref: setRefs,
|
|
@@ -1426,7 +2913,7 @@ var DataPanelTab = React14.forwardRef(
|
|
|
1426
2913
|
onPointerUp: draggable ? handlePointerUp : void 0,
|
|
1427
2914
|
onPointerCancel: draggable ? handlePointerCancel : void 0,
|
|
1428
2915
|
children: [
|
|
1429
|
-
/* @__PURE__ */
|
|
2916
|
+
/* @__PURE__ */ jsxs17(
|
|
1430
2917
|
"button",
|
|
1431
2918
|
{
|
|
1432
2919
|
type: "button",
|
|
@@ -1435,12 +2922,12 @@ var DataPanelTab = React14.forwardRef(
|
|
|
1435
2922
|
onClick: draggable ? void 0 : onClick,
|
|
1436
2923
|
onKeyDown: handleExpandKeyDown,
|
|
1437
2924
|
children: [
|
|
1438
|
-
/* @__PURE__ */
|
|
1439
|
-
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 })
|
|
1440
2927
|
]
|
|
1441
2928
|
}
|
|
1442
2929
|
),
|
|
1443
|
-
!disableClose && onClose && /* @__PURE__ */
|
|
2930
|
+
!disableClose && onClose && /* @__PURE__ */ jsx25(
|
|
1444
2931
|
"button",
|
|
1445
2932
|
{
|
|
1446
2933
|
"data-no-drag": true,
|
|
@@ -1451,7 +2938,7 @@ var DataPanelTab = React14.forwardRef(
|
|
|
1451
2938
|
e.stopPropagation();
|
|
1452
2939
|
onClose();
|
|
1453
2940
|
},
|
|
1454
|
-
children: /* @__PURE__ */
|
|
2941
|
+
children: /* @__PURE__ */ jsx25(CloseIcon, {})
|
|
1455
2942
|
}
|
|
1456
2943
|
)
|
|
1457
2944
|
]
|
|
@@ -1473,7 +2960,7 @@ function ResizeHandles({
|
|
|
1473
2960
|
onPinnedSizeChange,
|
|
1474
2961
|
constraints
|
|
1475
2962
|
}) {
|
|
1476
|
-
const handleDetachedKeyDown =
|
|
2963
|
+
const handleDetachedKeyDown = React24.useCallback(
|
|
1477
2964
|
(e, handle) => {
|
|
1478
2965
|
const step = e.shiftKey ? KEYBOARD_RESIZE_STEP_LARGE : KEYBOARD_RESIZE_STEP;
|
|
1479
2966
|
let width = detachedSize.width;
|
|
@@ -1536,7 +3023,7 @@ function ResizeHandles({
|
|
|
1536
3023
|
},
|
|
1537
3024
|
[detachedPosition, detachedSize, constraints, onDetachedResize]
|
|
1538
3025
|
);
|
|
1539
|
-
const handlePinnedKeyDown =
|
|
3026
|
+
const handlePinnedKeyDown = React24.useCallback(
|
|
1540
3027
|
(e) => {
|
|
1541
3028
|
const step = e.shiftKey ? KEYBOARD_RESIZE_STEP_LARGE : KEYBOARD_RESIZE_STEP;
|
|
1542
3029
|
let newSize = pinnedSize;
|
|
@@ -1596,12 +3083,12 @@ function ResizeHandles({
|
|
|
1596
3083
|
"bottom-left",
|
|
1597
3084
|
"bottom-right"
|
|
1598
3085
|
];
|
|
1599
|
-
return /* @__PURE__ */
|
|
3086
|
+
return /* @__PURE__ */ jsx25(Fragment5, { children: handles.map((handle) => {
|
|
1600
3087
|
const isCorner = handle.includes("-");
|
|
1601
3088
|
const isHorizontal2 = handle === "top" || handle === "bottom";
|
|
1602
3089
|
const isVertical = handle === "left" || handle === "right";
|
|
1603
3090
|
const { min: min2, max: max2 } = getAriaValueMinMax(handle);
|
|
1604
|
-
return /* @__PURE__ */
|
|
3091
|
+
return /* @__PURE__ */ jsx25(
|
|
1605
3092
|
"div",
|
|
1606
3093
|
{
|
|
1607
3094
|
className: cn(
|
|
@@ -1630,7 +3117,7 @@ function ResizeHandles({
|
|
|
1630
3117
|
const pinnedHandle = getPinnedResizeHandle(edge);
|
|
1631
3118
|
const isHorizontal = edge === "left" || edge === "right";
|
|
1632
3119
|
const { min, max } = getAriaValueMinMax(pinnedHandle);
|
|
1633
|
-
return /* @__PURE__ */
|
|
3120
|
+
return /* @__PURE__ */ jsx25(
|
|
1634
3121
|
"div",
|
|
1635
3122
|
{
|
|
1636
3123
|
className: cn(
|
|
@@ -1653,7 +3140,7 @@ function ResizeHandles({
|
|
|
1653
3140
|
}
|
|
1654
3141
|
);
|
|
1655
3142
|
}
|
|
1656
|
-
var DataPanel =
|
|
3143
|
+
var DataPanel = React24.forwardRef(
|
|
1657
3144
|
({
|
|
1658
3145
|
open: controlledOpen,
|
|
1659
3146
|
onOpenChange,
|
|
@@ -1685,76 +3172,76 @@ var DataPanel = React14.forwardRef(
|
|
|
1685
3172
|
footerActions,
|
|
1686
3173
|
className
|
|
1687
3174
|
}, ref) => {
|
|
1688
|
-
const resolvedConstraints =
|
|
3175
|
+
const resolvedConstraints = React24.useMemo(
|
|
1689
3176
|
() => ({ ...DEFAULT_CONSTRAINTS, ...constraints }),
|
|
1690
3177
|
[constraints]
|
|
1691
3178
|
);
|
|
1692
|
-
const resolvedCardConfig =
|
|
3179
|
+
const resolvedCardConfig = React24.useMemo(
|
|
1693
3180
|
() => ({ ...DEFAULT_CARD_CONFIG, ...cardConfig }),
|
|
1694
3181
|
[cardConfig]
|
|
1695
3182
|
);
|
|
1696
|
-
const panelId =
|
|
3183
|
+
const panelId = React24.useId();
|
|
1697
3184
|
const titleId = `${panelId}-title`;
|
|
1698
|
-
const [internalOpen, setInternalOpen] =
|
|
1699
|
-
const [internalMode, setInternalMode] =
|
|
1700
|
-
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(
|
|
1701
3188
|
DEFAULT_PANEL_STATE.variant
|
|
1702
3189
|
);
|
|
1703
|
-
const [internalEdge, setInternalEdge] =
|
|
1704
|
-
const [internalExpanded, setInternalExpanded] =
|
|
3190
|
+
const [internalEdge, setInternalEdge] = React24.useState(DEFAULT_PANEL_STATE.edge);
|
|
3191
|
+
const [internalExpanded, setInternalExpanded] = React24.useState(
|
|
1705
3192
|
DEFAULT_PANEL_STATE.isExpanded
|
|
1706
3193
|
);
|
|
1707
|
-
const [detachedPosition, setDetachedPosition] =
|
|
3194
|
+
const [detachedPosition, setDetachedPosition] = React24.useState(
|
|
1708
3195
|
DEFAULT_PANEL_STATE.detachedPosition
|
|
1709
3196
|
);
|
|
1710
|
-
const [detachedSize, setDetachedSize] =
|
|
1711
|
-
const [pinnedSize, setPinnedSize] =
|
|
1712
|
-
const [tabOffset, setTabOffset] =
|
|
1713
|
-
const [viewportWidth, setViewportWidth] =
|
|
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(
|
|
1714
3201
|
typeof window !== "undefined" ? layoutViewportWidth() : 1024
|
|
1715
3202
|
);
|
|
1716
|
-
const [viewportHeight, setViewportHeight] =
|
|
3203
|
+
const [viewportHeight, setViewportHeight] = React24.useState(
|
|
1717
3204
|
typeof window !== "undefined" ? window.innerHeight : 768
|
|
1718
3205
|
);
|
|
1719
3206
|
const isMobile = viewportWidth < 640;
|
|
1720
|
-
const [cardHorizontalPosition, setCardHorizontalPosition] =
|
|
1721
|
-
const [cardExpandedHeight, setCardExpandedHeight] =
|
|
1722
|
-
const [cardWidth, setCardWidth] =
|
|
1723
|
-
const [cardDragCurrentHeight, setCardDragCurrentHeight] =
|
|
1724
|
-
const [isCardVerticalDragging, setIsCardVerticalDragging] =
|
|
1725
|
-
const [isCardHorizontalDragging, setIsCardHorizontalDragging] =
|
|
1726
|
-
const [isCardHeightTransitioning, setIsCardHeightTransitioning] =
|
|
1727
|
-
const [isCardWidthResizing, setIsCardWidthResizing] =
|
|
1728
|
-
const [isCardTopResizing, setIsCardTopResizing] =
|
|
1729
|
-
const [isDragging, setIsDragging] =
|
|
1730
|
-
const [isResizing, setIsResizing] =
|
|
1731
|
-
const [snapPreview, setSnapPreview] =
|
|
1732
|
-
const [isPinnedDragging, setIsPinnedDragging] =
|
|
1733
|
-
const [pullOffset, setPullOffset] =
|
|
1734
|
-
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({
|
|
1735
3222
|
startPosition: { x: 0, y: 0 },
|
|
1736
3223
|
startPanelPosition: { x: 0, y: 0 }
|
|
1737
3224
|
});
|
|
1738
|
-
const pinnedDragStateRef =
|
|
3225
|
+
const pinnedDragStateRef = React24.useRef({
|
|
1739
3226
|
startPosition: { x: 0, y: 0 },
|
|
1740
3227
|
hasDetached: false
|
|
1741
3228
|
});
|
|
1742
|
-
const resizeStateRef =
|
|
3229
|
+
const resizeStateRef = React24.useRef({
|
|
1743
3230
|
handle: null,
|
|
1744
3231
|
startPosition: { x: 0, y: 0 },
|
|
1745
3232
|
startSize: { width: 0, height: 0 },
|
|
1746
3233
|
startPanelPosition: { x: 0, y: 0 }
|
|
1747
3234
|
});
|
|
1748
|
-
const cardDragStateRef =
|
|
3235
|
+
const cardDragStateRef = React24.useRef({
|
|
1749
3236
|
startY: 0,
|
|
1750
3237
|
startX: 0,
|
|
1751
3238
|
startTime: 0,
|
|
1752
3239
|
startExpanded: false,
|
|
1753
3240
|
startHorizontalPosition: 0
|
|
1754
3241
|
});
|
|
1755
|
-
const cardCurrentHeightRef =
|
|
1756
|
-
const cardTopResizeStartRef =
|
|
1757
|
-
const cardWidthResizeStateRef =
|
|
3242
|
+
const cardCurrentHeightRef = React24.useRef(CARD_HEADER_HEIGHT);
|
|
3243
|
+
const cardTopResizeStartRef = React24.useRef({ startY: 0, startHeight: 0 });
|
|
3244
|
+
const cardWidthResizeStateRef = React24.useRef({
|
|
1758
3245
|
handle: null,
|
|
1759
3246
|
startX: 0,
|
|
1760
3247
|
startWidth: 0,
|
|
@@ -1766,9 +3253,9 @@ var DataPanel = React14.forwardRef(
|
|
|
1766
3253
|
const edge = controlledEdge ?? internalEdge;
|
|
1767
3254
|
const isExpanded = controlledExpanded ?? internalExpanded;
|
|
1768
3255
|
const showContent = variant !== "card" || isExpanded || isCardVerticalDragging;
|
|
1769
|
-
const saveTimeoutRef =
|
|
1770
|
-
const isMountedRef =
|
|
1771
|
-
|
|
3256
|
+
const saveTimeoutRef = React24.useRef(null);
|
|
3257
|
+
const isMountedRef = React24.useRef(true);
|
|
3258
|
+
React24.useEffect(() => {
|
|
1772
3259
|
isMountedRef.current = true;
|
|
1773
3260
|
return () => {
|
|
1774
3261
|
isMountedRef.current = false;
|
|
@@ -1779,7 +3266,7 @@ var DataPanel = React14.forwardRef(
|
|
|
1779
3266
|
}
|
|
1780
3267
|
};
|
|
1781
3268
|
}, []);
|
|
1782
|
-
const debouncedSave =
|
|
3269
|
+
const debouncedSave = React24.useCallback(() => {
|
|
1783
3270
|
if (!persistKey) return;
|
|
1784
3271
|
if (saveTimeoutRef.current) {
|
|
1785
3272
|
clearTimeout(saveTimeoutRef.current);
|
|
@@ -1808,11 +3295,11 @@ var DataPanel = React14.forwardRef(
|
|
|
1808
3295
|
pinnedSize,
|
|
1809
3296
|
tabOffset
|
|
1810
3297
|
]);
|
|
1811
|
-
|
|
3298
|
+
React24.useEffect(() => {
|
|
1812
3299
|
debouncedSave();
|
|
1813
3300
|
}, [debouncedSave]);
|
|
1814
|
-
const hasLoadedRef =
|
|
1815
|
-
|
|
3301
|
+
const hasLoadedRef = React24.useRef(false);
|
|
3302
|
+
React24.useEffect(() => {
|
|
1816
3303
|
if (!persistKey || hasLoadedRef.current) return;
|
|
1817
3304
|
hasLoadedRef.current = true;
|
|
1818
3305
|
const persisted = loadPanelState(persistKey);
|
|
@@ -1829,7 +3316,7 @@ var DataPanel = React14.forwardRef(
|
|
|
1829
3316
|
if (persisted.tabOffset !== void 0) setTabOffset(persisted.tabOffset);
|
|
1830
3317
|
}
|
|
1831
3318
|
}, [persistKey, controlledMode, controlledVariant, controlledEdge, controlledExpanded]);
|
|
1832
|
-
|
|
3319
|
+
React24.useEffect(() => {
|
|
1833
3320
|
if (mode === "detached" && detachedPosition.x === DEFAULT_PANEL_STATE.detachedPosition.x && detachedPosition.y === DEFAULT_PANEL_STATE.detachedPosition.y) {
|
|
1834
3321
|
setDetachedPosition(
|
|
1835
3322
|
getInitialDetachedPosition(detachedSize, layoutViewportWidth(), window.innerHeight)
|
|
@@ -1858,7 +3345,7 @@ var DataPanel = React14.forwardRef(
|
|
|
1858
3345
|
ref.current = node;
|
|
1859
3346
|
}
|
|
1860
3347
|
};
|
|
1861
|
-
const handleModeChange =
|
|
3348
|
+
const handleModeChange = React24.useCallback(
|
|
1862
3349
|
(newMode) => {
|
|
1863
3350
|
if (controlledMode === void 0) {
|
|
1864
3351
|
setInternalMode(newMode);
|
|
@@ -1867,7 +3354,7 @@ var DataPanel = React14.forwardRef(
|
|
|
1867
3354
|
},
|
|
1868
3355
|
[controlledMode, onModeChange]
|
|
1869
3356
|
);
|
|
1870
|
-
const handleEdgeChange =
|
|
3357
|
+
const handleEdgeChange = React24.useCallback(
|
|
1871
3358
|
(newEdge) => {
|
|
1872
3359
|
if (controlledEdge === void 0) {
|
|
1873
3360
|
setInternalEdge(newEdge);
|
|
@@ -1876,7 +3363,7 @@ var DataPanel = React14.forwardRef(
|
|
|
1876
3363
|
},
|
|
1877
3364
|
[controlledEdge, onEdgeChange]
|
|
1878
3365
|
);
|
|
1879
|
-
const handleExpandedChange =
|
|
3366
|
+
const handleExpandedChange = React24.useCallback(
|
|
1880
3367
|
(newExpanded) => {
|
|
1881
3368
|
if (controlledExpanded === void 0) {
|
|
1882
3369
|
setInternalExpanded(newExpanded);
|
|
@@ -1910,7 +3397,7 @@ var DataPanel = React14.forwardRef(
|
|
|
1910
3397
|
document.body.style.userSelect = "none";
|
|
1911
3398
|
}
|
|
1912
3399
|
};
|
|
1913
|
-
const handleDragMove =
|
|
3400
|
+
const handleDragMove = React24.useCallback(
|
|
1914
3401
|
(e) => {
|
|
1915
3402
|
if (!isDragging) return;
|
|
1916
3403
|
const currentPos = getPointerPosition(e);
|
|
@@ -1937,7 +3424,7 @@ var DataPanel = React14.forwardRef(
|
|
|
1937
3424
|
},
|
|
1938
3425
|
[isDragging, detachedSize, snapThreshold]
|
|
1939
3426
|
);
|
|
1940
|
-
const handleDragEnd =
|
|
3427
|
+
const handleDragEnd = React24.useCallback(() => {
|
|
1941
3428
|
if (!isDragging) return;
|
|
1942
3429
|
setIsDragging(false);
|
|
1943
3430
|
document.body.style.cursor = "";
|
|
@@ -1948,7 +3435,7 @@ var DataPanel = React14.forwardRef(
|
|
|
1948
3435
|
setSnapPreview(null);
|
|
1949
3436
|
}
|
|
1950
3437
|
}, [isDragging, snapPreview, handleModeChange, handleEdgeChange]);
|
|
1951
|
-
const handlePinnedDragMove =
|
|
3438
|
+
const handlePinnedDragMove = React24.useCallback(
|
|
1952
3439
|
(e) => {
|
|
1953
3440
|
if (!isPinnedDragging) return;
|
|
1954
3441
|
const currentPos = getPointerPosition(e);
|
|
@@ -1984,7 +3471,7 @@ var DataPanel = React14.forwardRef(
|
|
|
1984
3471
|
},
|
|
1985
3472
|
[isPinnedDragging, edge, detachThreshold, pinnedSize, detachedSize, handleModeChange]
|
|
1986
3473
|
);
|
|
1987
|
-
const handlePinnedDragEnd =
|
|
3474
|
+
const handlePinnedDragEnd = React24.useCallback(() => {
|
|
1988
3475
|
if (!isPinnedDragging) return;
|
|
1989
3476
|
setIsPinnedDragging(false);
|
|
1990
3477
|
setPullOffset(0);
|
|
@@ -2006,7 +3493,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2006
3493
|
document.body.style.cursor = getResizeCursor(handle);
|
|
2007
3494
|
document.body.style.userSelect = "none";
|
|
2008
3495
|
};
|
|
2009
|
-
const handleResizeMove =
|
|
3496
|
+
const handleResizeMove = React24.useCallback(
|
|
2010
3497
|
(e) => {
|
|
2011
3498
|
if (!isResizing || !resizeStateRef.current.handle) return;
|
|
2012
3499
|
const currentPos = getPointerPosition(e);
|
|
@@ -2047,7 +3534,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2047
3534
|
},
|
|
2048
3535
|
[isResizing, mode, edge, resolvedConstraints]
|
|
2049
3536
|
);
|
|
2050
|
-
const handleResizeEnd =
|
|
3537
|
+
const handleResizeEnd = React24.useCallback(() => {
|
|
2051
3538
|
if (!isResizing) return;
|
|
2052
3539
|
setIsResizing(false);
|
|
2053
3540
|
resizeStateRef.current.handle = null;
|
|
@@ -2079,7 +3566,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2079
3566
|
}
|
|
2080
3567
|
document.body.style.userSelect = "none";
|
|
2081
3568
|
};
|
|
2082
|
-
const handleCardPointerMove =
|
|
3569
|
+
const handleCardPointerMove = React24.useCallback(
|
|
2083
3570
|
(e) => {
|
|
2084
3571
|
const currentPos = getPointerPosition(e);
|
|
2085
3572
|
if (isCardVerticalDragging) {
|
|
@@ -2119,7 +3606,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2119
3606
|
resolvedCardConfig.maxWidth
|
|
2120
3607
|
]
|
|
2121
3608
|
);
|
|
2122
|
-
const handleCardPointerUp =
|
|
3609
|
+
const handleCardPointerUp = React24.useCallback(
|
|
2123
3610
|
(e) => {
|
|
2124
3611
|
const endTime = Date.now();
|
|
2125
3612
|
const currentPos = getPointerPosition(e);
|
|
@@ -2176,7 +3663,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2176
3663
|
document.body.style.cursor = "ns-resize";
|
|
2177
3664
|
document.body.style.userSelect = "none";
|
|
2178
3665
|
};
|
|
2179
|
-
const handleCardResizeMove =
|
|
3666
|
+
const handleCardResizeMove = React24.useCallback(
|
|
2180
3667
|
(e) => {
|
|
2181
3668
|
if (!isCardTopResizing) return;
|
|
2182
3669
|
const currentPos = getPointerPosition(e);
|
|
@@ -2189,7 +3676,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2189
3676
|
},
|
|
2190
3677
|
[isCardTopResizing, viewportHeight]
|
|
2191
3678
|
);
|
|
2192
|
-
const handleCardResizeEnd =
|
|
3679
|
+
const handleCardResizeEnd = React24.useCallback(() => {
|
|
2193
3680
|
if (!isCardTopResizing) return;
|
|
2194
3681
|
setIsCardTopResizing(false);
|
|
2195
3682
|
document.body.style.cursor = "";
|
|
@@ -2220,7 +3707,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2220
3707
|
document.body.style.cursor = "ew-resize";
|
|
2221
3708
|
document.body.style.userSelect = "none";
|
|
2222
3709
|
};
|
|
2223
|
-
const handleCardWidthResizeMove =
|
|
3710
|
+
const handleCardWidthResizeMove = React24.useCallback(
|
|
2224
3711
|
(e) => {
|
|
2225
3712
|
const st = cardWidthResizeStateRef.current;
|
|
2226
3713
|
if (!isCardWidthResizing || !st.handle) return;
|
|
@@ -2260,7 +3747,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2260
3747
|
resolvedCardConfig.maxWidth
|
|
2261
3748
|
]
|
|
2262
3749
|
);
|
|
2263
|
-
const handleCardWidthResizeEnd =
|
|
3750
|
+
const handleCardWidthResizeEnd = React24.useCallback(() => {
|
|
2264
3751
|
if (!isCardWidthResizing) return;
|
|
2265
3752
|
setIsCardWidthResizing(false);
|
|
2266
3753
|
cardWidthResizeStateRef.current.handle = null;
|
|
@@ -2308,7 +3795,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2308
3795
|
if (kind === "width-left") setCardHorizontalPosition((p) => p - appliedDelta);
|
|
2309
3796
|
debouncedSave();
|
|
2310
3797
|
};
|
|
2311
|
-
|
|
3798
|
+
React24.useEffect(() => {
|
|
2312
3799
|
if (isDragging) {
|
|
2313
3800
|
window.addEventListener("pointermove", handleDragMove);
|
|
2314
3801
|
window.addEventListener("pointerup", handleDragEnd);
|
|
@@ -2320,7 +3807,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2320
3807
|
};
|
|
2321
3808
|
}
|
|
2322
3809
|
}, [isDragging, handleDragMove, handleDragEnd]);
|
|
2323
|
-
|
|
3810
|
+
React24.useEffect(() => {
|
|
2324
3811
|
if (isPinnedDragging) {
|
|
2325
3812
|
window.addEventListener("pointermove", handlePinnedDragMove);
|
|
2326
3813
|
window.addEventListener("pointerup", handlePinnedDragEnd);
|
|
@@ -2332,7 +3819,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2332
3819
|
};
|
|
2333
3820
|
}
|
|
2334
3821
|
}, [isPinnedDragging, handlePinnedDragMove, handlePinnedDragEnd]);
|
|
2335
|
-
|
|
3822
|
+
React24.useEffect(() => {
|
|
2336
3823
|
if (isResizing) {
|
|
2337
3824
|
window.addEventListener("pointermove", handleResizeMove);
|
|
2338
3825
|
window.addEventListener("pointerup", handleResizeEnd);
|
|
@@ -2344,7 +3831,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2344
3831
|
};
|
|
2345
3832
|
}
|
|
2346
3833
|
}, [isResizing, handleResizeMove, handleResizeEnd]);
|
|
2347
|
-
|
|
3834
|
+
React24.useEffect(() => {
|
|
2348
3835
|
if (isCardVerticalDragging || isCardHorizontalDragging) {
|
|
2349
3836
|
window.addEventListener("pointermove", handleCardPointerMove);
|
|
2350
3837
|
window.addEventListener("pointerup", handleCardPointerUp);
|
|
@@ -2361,7 +3848,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2361
3848
|
handleCardPointerMove,
|
|
2362
3849
|
handleCardPointerUp
|
|
2363
3850
|
]);
|
|
2364
|
-
|
|
3851
|
+
React24.useEffect(() => {
|
|
2365
3852
|
if (isCardTopResizing) {
|
|
2366
3853
|
window.addEventListener("pointermove", handleCardResizeMove);
|
|
2367
3854
|
window.addEventListener("pointerup", handleCardResizeEnd);
|
|
@@ -2373,7 +3860,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2373
3860
|
};
|
|
2374
3861
|
}
|
|
2375
3862
|
}, [isCardTopResizing, handleCardResizeMove, handleCardResizeEnd]);
|
|
2376
|
-
|
|
3863
|
+
React24.useEffect(() => {
|
|
2377
3864
|
if (isCardWidthResizing) {
|
|
2378
3865
|
window.addEventListener("pointermove", handleCardWidthResizeMove);
|
|
2379
3866
|
window.addEventListener("pointerup", handleCardWidthResizeEnd);
|
|
@@ -2385,7 +3872,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2385
3872
|
};
|
|
2386
3873
|
}
|
|
2387
3874
|
}, [isCardWidthResizing, handleCardWidthResizeMove, handleCardWidthResizeEnd]);
|
|
2388
|
-
|
|
3875
|
+
React24.useEffect(() => {
|
|
2389
3876
|
const onResize = () => {
|
|
2390
3877
|
setViewportWidth(layoutViewportWidth());
|
|
2391
3878
|
setViewportHeight(window.innerHeight);
|
|
@@ -2395,19 +3882,19 @@ var DataPanel = React14.forwardRef(
|
|
|
2395
3882
|
window.addEventListener("resize", onResize);
|
|
2396
3883
|
return () => window.removeEventListener("resize", onResize);
|
|
2397
3884
|
}, []);
|
|
2398
|
-
|
|
3885
|
+
React24.useEffect(() => {
|
|
2399
3886
|
if (isMobile && variant === "card") {
|
|
2400
3887
|
setCardHorizontalPosition(0);
|
|
2401
3888
|
setCardWidth(null);
|
|
2402
3889
|
}
|
|
2403
3890
|
}, [isMobile, variant]);
|
|
2404
|
-
|
|
3891
|
+
React24.useEffect(() => {
|
|
2405
3892
|
if (isCardHeightTransitioning) {
|
|
2406
3893
|
const t = setTimeout(() => setIsCardHeightTransitioning(false), 350);
|
|
2407
3894
|
return () => clearTimeout(t);
|
|
2408
3895
|
}
|
|
2409
3896
|
}, [isCardHeightTransitioning]);
|
|
2410
|
-
const panelStyles =
|
|
3897
|
+
const panelStyles = React24.useMemo(() => {
|
|
2411
3898
|
if (variant === "card") {
|
|
2412
3899
|
const defaultCardWidth = Math.min(
|
|
2413
3900
|
viewportWidth - resolvedCardConfig.horizontalMargin * 2,
|
|
@@ -2472,7 +3959,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2472
3959
|
}[edge] : "animate-scale-in";
|
|
2473
3960
|
if (!open) return null;
|
|
2474
3961
|
if (variant === "full" && !isExpanded && mode === "pinned") {
|
|
2475
|
-
return /* @__PURE__ */
|
|
3962
|
+
return /* @__PURE__ */ jsx25(
|
|
2476
3963
|
DataPanelTab,
|
|
2477
3964
|
{
|
|
2478
3965
|
title,
|
|
@@ -2488,8 +3975,8 @@ var DataPanel = React14.forwardRef(
|
|
|
2488
3975
|
}
|
|
2489
3976
|
);
|
|
2490
3977
|
}
|
|
2491
|
-
return /* @__PURE__ */
|
|
2492
|
-
snapPreview && /* @__PURE__ */
|
|
3978
|
+
return /* @__PURE__ */ jsxs17(Fragment5, { children: [
|
|
3979
|
+
snapPreview && /* @__PURE__ */ jsx25(
|
|
2493
3980
|
"div",
|
|
2494
3981
|
{
|
|
2495
3982
|
className: cn(
|
|
@@ -2501,7 +3988,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2501
3988
|
)
|
|
2502
3989
|
}
|
|
2503
3990
|
),
|
|
2504
|
-
variant === "card" && isExpanded && isMobile && /* @__PURE__ */
|
|
3991
|
+
variant === "card" && isExpanded && isMobile && /* @__PURE__ */ jsx25(
|
|
2505
3992
|
"div",
|
|
2506
3993
|
{
|
|
2507
3994
|
className: "fixed inset-0 z-40 bg-black/50 transition-opacity",
|
|
@@ -2509,7 +3996,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2509
3996
|
onClick: handleToggleExpand
|
|
2510
3997
|
}
|
|
2511
3998
|
),
|
|
2512
|
-
/* @__PURE__ */
|
|
3999
|
+
/* @__PURE__ */ jsxs17(
|
|
2513
4000
|
"div",
|
|
2514
4001
|
{
|
|
2515
4002
|
ref: setPanelRef,
|
|
@@ -2531,7 +4018,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2531
4018
|
"aria-expanded": variant === "card" ? isExpanded : void 0,
|
|
2532
4019
|
onPointerDown: variant === "full" ? handleDragStart : void 0,
|
|
2533
4020
|
children: [
|
|
2534
|
-
variant === "card" ? /* @__PURE__ */
|
|
4021
|
+
variant === "card" ? /* @__PURE__ */ jsx25(
|
|
2535
4022
|
DataPanelCardHeader,
|
|
2536
4023
|
{
|
|
2537
4024
|
title,
|
|
@@ -2547,7 +4034,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2547
4034
|
onToggleExpand: handleToggleExpand,
|
|
2548
4035
|
onClose: () => handleOpenChange(false)
|
|
2549
4036
|
}
|
|
2550
|
-
) : /* @__PURE__ */
|
|
4037
|
+
) : /* @__PURE__ */ jsx25(
|
|
2551
4038
|
DataPanelHeader,
|
|
2552
4039
|
{
|
|
2553
4040
|
title,
|
|
@@ -2567,9 +4054,9 @@ var DataPanel = React14.forwardRef(
|
|
|
2567
4054
|
draggable: !disableDrag && (mode === "detached" || mode === "pinned" && detachThreshold > 0)
|
|
2568
4055
|
}
|
|
2569
4056
|
),
|
|
2570
|
-
showContent && /* @__PURE__ */
|
|
2571
|
-
/* @__PURE__ */
|
|
2572
|
-
/* @__PURE__ */
|
|
4057
|
+
showContent && /* @__PURE__ */ jsxs17(Fragment5, { children: [
|
|
4058
|
+
/* @__PURE__ */ jsx25(DataPanelContent, { children }),
|
|
4059
|
+
/* @__PURE__ */ jsx25(
|
|
2573
4060
|
DataPanelFooter,
|
|
2574
4061
|
{
|
|
2575
4062
|
actions,
|
|
@@ -2578,7 +4065,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2578
4065
|
}
|
|
2579
4066
|
)
|
|
2580
4067
|
] }),
|
|
2581
|
-
variant === "full" && !disableResize && /* @__PURE__ */
|
|
4068
|
+
variant === "full" && !disableResize && /* @__PURE__ */ jsx25(
|
|
2582
4069
|
ResizeHandles,
|
|
2583
4070
|
{
|
|
2584
4071
|
mode,
|
|
@@ -2609,8 +4096,8 @@ var DataPanel = React14.forwardRef(
|
|
|
2609
4096
|
constraints: resolvedConstraints
|
|
2610
4097
|
}
|
|
2611
4098
|
),
|
|
2612
|
-
variant === "card" && isExpanded && !disableResize && !isMobile && /* @__PURE__ */
|
|
2613
|
-
/* @__PURE__ */
|
|
4099
|
+
variant === "card" && isExpanded && !disableResize && !isMobile && /* @__PURE__ */ jsxs17(Fragment5, { children: [
|
|
4100
|
+
/* @__PURE__ */ jsx25(
|
|
2614
4101
|
"div",
|
|
2615
4102
|
{
|
|
2616
4103
|
className: "resize-handle resize-handle--horizontal resize-handle--top",
|
|
@@ -2626,7 +4113,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2626
4113
|
onKeyDown: (e) => handleCardResizeKeyDown(e, "height")
|
|
2627
4114
|
}
|
|
2628
4115
|
),
|
|
2629
|
-
/* @__PURE__ */
|
|
4116
|
+
/* @__PURE__ */ jsx25(
|
|
2630
4117
|
"div",
|
|
2631
4118
|
{
|
|
2632
4119
|
className: "resize-handle resize-handle--vertical resize-handle--left resize-handle--card-edge",
|
|
@@ -2642,7 +4129,7 @@ var DataPanel = React14.forwardRef(
|
|
|
2642
4129
|
onKeyDown: (e) => handleCardResizeKeyDown(e, "width-left")
|
|
2643
4130
|
}
|
|
2644
4131
|
),
|
|
2645
|
-
/* @__PURE__ */
|
|
4132
|
+
/* @__PURE__ */ jsx25(
|
|
2646
4133
|
"div",
|
|
2647
4134
|
{
|
|
2648
4135
|
className: "resize-handle resize-handle--vertical resize-handle--right resize-handle--card-edge",
|
|
@@ -2668,10 +4155,10 @@ var DataPanel = React14.forwardRef(
|
|
|
2668
4155
|
DataPanel.displayName = "DataPanel";
|
|
2669
4156
|
|
|
2670
4157
|
// src/components/Skeleton.tsx
|
|
2671
|
-
import * as
|
|
2672
|
-
import { cva as
|
|
2673
|
-
import { jsx as
|
|
2674
|
-
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", {
|
|
2675
4162
|
variants: {
|
|
2676
4163
|
variant: {
|
|
2677
4164
|
default: "",
|
|
@@ -2686,10 +4173,10 @@ var skeletonVariants = cva5("rounded-md bg-muted", {
|
|
|
2686
4173
|
variant: "default"
|
|
2687
4174
|
}
|
|
2688
4175
|
});
|
|
2689
|
-
var Skeleton =
|
|
4176
|
+
var Skeleton = React25.forwardRef(
|
|
2690
4177
|
({ className, variant, animation = "pulse", ...props }, ref) => {
|
|
2691
4178
|
const animationClass = animation === "pulse" ? "animate-pulse" : animation === "shimmer" ? "animate-shimmer" : "";
|
|
2692
|
-
return /* @__PURE__ */
|
|
4179
|
+
return /* @__PURE__ */ jsx26(
|
|
2693
4180
|
"div",
|
|
2694
4181
|
{
|
|
2695
4182
|
ref,
|
|
@@ -2702,10 +4189,10 @@ var Skeleton = React15.forwardRef(
|
|
|
2702
4189
|
Skeleton.displayName = "Skeleton";
|
|
2703
4190
|
|
|
2704
4191
|
// src/components/Spinner.tsx
|
|
2705
|
-
import * as
|
|
2706
|
-
import { cva as
|
|
2707
|
-
import { jsx as
|
|
2708
|
-
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", {
|
|
2709
4196
|
variants: {
|
|
2710
4197
|
size: {
|
|
2711
4198
|
sm: "h-4 w-4",
|
|
@@ -2718,9 +4205,9 @@ var spinnerVariants = cva6("animate-spin text-current", {
|
|
|
2718
4205
|
size: "md"
|
|
2719
4206
|
}
|
|
2720
4207
|
});
|
|
2721
|
-
var Spinner =
|
|
4208
|
+
var Spinner = React26.forwardRef(
|
|
2722
4209
|
({ className, size, label = "Loading...", ...props }, ref) => {
|
|
2723
|
-
return /* @__PURE__ */
|
|
4210
|
+
return /* @__PURE__ */ jsxs18(
|
|
2724
4211
|
"svg",
|
|
2725
4212
|
{
|
|
2726
4213
|
ref,
|
|
@@ -2732,7 +4219,7 @@ var Spinner = React16.forwardRef(
|
|
|
2732
4219
|
role: "status",
|
|
2733
4220
|
...props,
|
|
2734
4221
|
children: [
|
|
2735
|
-
/* @__PURE__ */
|
|
4222
|
+
/* @__PURE__ */ jsx27(
|
|
2736
4223
|
"circle",
|
|
2737
4224
|
{
|
|
2738
4225
|
className: "opacity-25",
|
|
@@ -2743,7 +4230,7 @@ var Spinner = React16.forwardRef(
|
|
|
2743
4230
|
strokeWidth: "4"
|
|
2744
4231
|
}
|
|
2745
4232
|
),
|
|
2746
|
-
/* @__PURE__ */
|
|
4233
|
+
/* @__PURE__ */ jsx27(
|
|
2747
4234
|
"path",
|
|
2748
4235
|
{
|
|
2749
4236
|
className: "opacity-75",
|
|
@@ -2751,7 +4238,7 @@ var Spinner = React16.forwardRef(
|
|
|
2751
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"
|
|
2752
4239
|
}
|
|
2753
4240
|
),
|
|
2754
|
-
/* @__PURE__ */
|
|
4241
|
+
/* @__PURE__ */ jsx27("title", { children: label })
|
|
2755
4242
|
]
|
|
2756
4243
|
}
|
|
2757
4244
|
);
|
|
@@ -2760,8 +4247,8 @@ var Spinner = React16.forwardRef(
|
|
|
2760
4247
|
Spinner.displayName = "Spinner";
|
|
2761
4248
|
|
|
2762
4249
|
// src/components/LoadingLogo.tsx
|
|
2763
|
-
import * as
|
|
2764
|
-
import { jsx as
|
|
4250
|
+
import * as React27 from "react";
|
|
4251
|
+
import { jsx as jsx28, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
2765
4252
|
var logoPaths = [
|
|
2766
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",
|
|
2767
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",
|
|
@@ -2783,12 +4270,12 @@ var colors = {
|
|
|
2783
4270
|
stroke: "#ffffff"
|
|
2784
4271
|
}
|
|
2785
4272
|
};
|
|
2786
|
-
var LoadingLogo =
|
|
4273
|
+
var LoadingLogo = React27.forwardRef(
|
|
2787
4274
|
({ width = 40, height = 40, loading = false, variant = "dark", className, ...props }, ref) => {
|
|
2788
4275
|
const currentColors = colors[variant];
|
|
2789
4276
|
const fillColor = loading ? currentColors.fillLoading : currentColors.fill;
|
|
2790
4277
|
const strokeColor = currentColors.stroke;
|
|
2791
|
-
return /* @__PURE__ */
|
|
4278
|
+
return /* @__PURE__ */ jsxs19(
|
|
2792
4279
|
"div",
|
|
2793
4280
|
{
|
|
2794
4281
|
ref,
|
|
@@ -2798,7 +4285,7 @@ var LoadingLogo = React17.forwardRef(
|
|
|
2798
4285
|
"aria-label": loading ? "Loading" : "Classic Homes",
|
|
2799
4286
|
...props,
|
|
2800
4287
|
children: [
|
|
2801
|
-
/* @__PURE__ */
|
|
4288
|
+
/* @__PURE__ */ jsxs19(
|
|
2802
4289
|
"svg",
|
|
2803
4290
|
{
|
|
2804
4291
|
width: "100%",
|
|
@@ -2808,8 +4295,8 @@ var LoadingLogo = React17.forwardRef(
|
|
|
2808
4295
|
xmlns: "http://www.w3.org/2000/svg",
|
|
2809
4296
|
"aria-hidden": "true",
|
|
2810
4297
|
children: [
|
|
2811
|
-
/* @__PURE__ */
|
|
2812
|
-
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(
|
|
2813
4300
|
"g",
|
|
2814
4301
|
{
|
|
2815
4302
|
fill: "none",
|
|
@@ -2817,13 +4304,13 @@ var LoadingLogo = React17.forwardRef(
|
|
|
2817
4304
|
strokeWidth: "0.5",
|
|
2818
4305
|
strokeDasharray: "10 4",
|
|
2819
4306
|
className: "animate-trace",
|
|
2820
|
-
children: logoPaths.map((path, i) => /* @__PURE__ */
|
|
4307
|
+
children: logoPaths.map((path, i) => /* @__PURE__ */ jsx28("path", { d: path }, i))
|
|
2821
4308
|
}
|
|
2822
4309
|
)
|
|
2823
4310
|
]
|
|
2824
4311
|
}
|
|
2825
4312
|
),
|
|
2826
|
-
loading && /* @__PURE__ */
|
|
4313
|
+
loading && /* @__PURE__ */ jsx28("span", { className: "sr-only", children: "Loading" })
|
|
2827
4314
|
]
|
|
2828
4315
|
}
|
|
2829
4316
|
);
|
|
@@ -2832,10 +4319,10 @@ var LoadingLogo = React17.forwardRef(
|
|
|
2832
4319
|
LoadingLogo.displayName = "LoadingLogo";
|
|
2833
4320
|
|
|
2834
4321
|
// src/components/ProgressBar.tsx
|
|
2835
|
-
import * as
|
|
2836
|
-
import { cva as
|
|
2837
|
-
import { jsx as
|
|
2838
|
-
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", {
|
|
2839
4326
|
variants: {
|
|
2840
4327
|
size: {
|
|
2841
4328
|
sm: "h-1",
|
|
@@ -2847,7 +4334,7 @@ var progressBarVariants = cva7("w-full overflow-hidden rounded-full bg-muted", {
|
|
|
2847
4334
|
size: "md"
|
|
2848
4335
|
}
|
|
2849
4336
|
});
|
|
2850
|
-
var progressFillVariants =
|
|
4337
|
+
var progressFillVariants = cva8("h-full rounded-full transition-all duration-300", {
|
|
2851
4338
|
variants: {
|
|
2852
4339
|
variant: {
|
|
2853
4340
|
default: "bg-primary",
|
|
@@ -2860,12 +4347,12 @@ var progressFillVariants = cva7("h-full rounded-full transition-all duration-300
|
|
|
2860
4347
|
variant: "default"
|
|
2861
4348
|
}
|
|
2862
4349
|
});
|
|
2863
|
-
var ProgressBar =
|
|
4350
|
+
var ProgressBar = React28.forwardRef(
|
|
2864
4351
|
({ className, size, variant, value, max = 100, label = "Progress", showValue = false, ...props }, ref) => {
|
|
2865
4352
|
const isIndeterminate = value === void 0;
|
|
2866
4353
|
const clampedValue = isIndeterminate ? 0 : Math.min(Math.max(0, value), max);
|
|
2867
4354
|
const percentage = isIndeterminate ? 0 : Math.round(clampedValue / max * 100);
|
|
2868
|
-
return /* @__PURE__ */
|
|
4355
|
+
return /* @__PURE__ */ jsxs20(
|
|
2869
4356
|
"div",
|
|
2870
4357
|
{
|
|
2871
4358
|
ref,
|
|
@@ -2877,7 +4364,7 @@ var ProgressBar = React18.forwardRef(
|
|
|
2877
4364
|
className: cn("flex items-center gap-2", className),
|
|
2878
4365
|
...props,
|
|
2879
4366
|
children: [
|
|
2880
|
-
/* @__PURE__ */
|
|
4367
|
+
/* @__PURE__ */ jsx29("div", { className: cn(progressBarVariants({ size })), children: /* @__PURE__ */ jsx29(
|
|
2881
4368
|
"div",
|
|
2882
4369
|
{
|
|
2883
4370
|
className: cn(
|
|
@@ -2887,7 +4374,7 @@ var ProgressBar = React18.forwardRef(
|
|
|
2887
4374
|
style: isIndeterminate ? void 0 : { width: `${percentage}%` }
|
|
2888
4375
|
}
|
|
2889
4376
|
) }),
|
|
2890
|
-
showValue && !isIndeterminate && /* @__PURE__ */
|
|
4377
|
+
showValue && !isIndeterminate && /* @__PURE__ */ jsxs20("span", { className: "text-sm tabular-nums text-muted-foreground", children: [
|
|
2891
4378
|
percentage,
|
|
2892
4379
|
"%"
|
|
2893
4380
|
] })
|
|
@@ -2899,11 +4386,11 @@ var ProgressBar = React18.forwardRef(
|
|
|
2899
4386
|
ProgressBar.displayName = "ProgressBar";
|
|
2900
4387
|
|
|
2901
4388
|
// src/components/LoadingOverlay.tsx
|
|
2902
|
-
import * as
|
|
2903
|
-
import { Fragment as
|
|
4389
|
+
import * as React29 from "react";
|
|
4390
|
+
import { Fragment as Fragment6, jsx as jsx30, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
2904
4391
|
var spinnerSizeMap = { sm: "sm", md: "md", lg: "lg", xl: "xl" };
|
|
2905
4392
|
var logoSizeMap = { sm: 32, md: 40, lg: 56, xl: 80 };
|
|
2906
|
-
var LoadingOverlay =
|
|
4393
|
+
var LoadingOverlay = React29.forwardRef(
|
|
2907
4394
|
({
|
|
2908
4395
|
loading = true,
|
|
2909
4396
|
variant = "spinner",
|
|
@@ -2918,8 +4405,8 @@ var LoadingOverlay = React19.forwardRef(
|
|
|
2918
4405
|
children,
|
|
2919
4406
|
...props
|
|
2920
4407
|
}, ref) => {
|
|
2921
|
-
const [visible, setVisible] =
|
|
2922
|
-
|
|
4408
|
+
const [visible, setVisible] = React29.useState(delay === 0 && loading);
|
|
4409
|
+
React29.useEffect(() => {
|
|
2923
4410
|
if (!loading) {
|
|
2924
4411
|
setVisible(false);
|
|
2925
4412
|
return;
|
|
@@ -2932,23 +4419,23 @@ var LoadingOverlay = React19.forwardRef(
|
|
|
2932
4419
|
return () => clearTimeout(timer);
|
|
2933
4420
|
}, [loading, delay]);
|
|
2934
4421
|
if (!visible) {
|
|
2935
|
-
return mode === "inline" ? null : /* @__PURE__ */
|
|
4422
|
+
return mode === "inline" ? null : /* @__PURE__ */ jsx30(Fragment6, { children });
|
|
2936
4423
|
}
|
|
2937
|
-
const indicator = /* @__PURE__ */
|
|
2938
|
-
variant === "spinner" && /* @__PURE__ */
|
|
2939
|
-
variant === "logo" && /* @__PURE__ */
|
|
2940
|
-
variant === "progress" && /* @__PURE__ */
|
|
2941
|
-
variant === "skeleton" && /* @__PURE__ */
|
|
2942
|
-
/* @__PURE__ */
|
|
2943
|
-
/* @__PURE__ */
|
|
2944
|
-
/* @__PURE__ */
|
|
2945
|
-
/* @__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" })
|
|
2946
4433
|
] }),
|
|
2947
|
-
message && /* @__PURE__ */
|
|
2948
|
-
!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" })
|
|
2949
4436
|
] });
|
|
2950
4437
|
if (mode === "inline") {
|
|
2951
|
-
return /* @__PURE__ */
|
|
4438
|
+
return /* @__PURE__ */ jsx30(
|
|
2952
4439
|
"div",
|
|
2953
4440
|
{
|
|
2954
4441
|
ref,
|
|
@@ -2962,9 +4449,9 @@ var LoadingOverlay = React19.forwardRef(
|
|
|
2962
4449
|
}
|
|
2963
4450
|
const bgClass = opaque ? "bg-background" : mode === "fullscreen" ? "bg-background/80" : "bg-background/60";
|
|
2964
4451
|
const positionClass = mode === "fullscreen" ? "fixed inset-0 z-50" : "absolute inset-0 z-10";
|
|
2965
|
-
return /* @__PURE__ */
|
|
4452
|
+
return /* @__PURE__ */ jsxs21(Fragment6, { children: [
|
|
2966
4453
|
children,
|
|
2967
|
-
/* @__PURE__ */
|
|
4454
|
+
/* @__PURE__ */ jsx30(
|
|
2968
4455
|
"div",
|
|
2969
4456
|
{
|
|
2970
4457
|
ref,
|
|
@@ -2987,9 +4474,9 @@ var LoadingOverlay = React19.forwardRef(
|
|
|
2987
4474
|
LoadingOverlay.displayName = "LoadingOverlay";
|
|
2988
4475
|
|
|
2989
4476
|
// src/components/LoadingPage.tsx
|
|
2990
|
-
import * as
|
|
2991
|
-
import { jsx as
|
|
2992
|
-
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(
|
|
2993
4480
|
({
|
|
2994
4481
|
loading = true,
|
|
2995
4482
|
message,
|
|
@@ -3000,8 +4487,8 @@ var LoadingPage = React20.forwardRef(
|
|
|
3000
4487
|
className,
|
|
3001
4488
|
...props
|
|
3002
4489
|
}, ref) => {
|
|
3003
|
-
const [visible, setVisible] =
|
|
3004
|
-
|
|
4490
|
+
const [visible, setVisible] = React30.useState(delay === 0 && loading);
|
|
4491
|
+
React30.useEffect(() => {
|
|
3005
4492
|
if (!loading) {
|
|
3006
4493
|
setVisible(false);
|
|
3007
4494
|
return;
|
|
@@ -3014,7 +4501,7 @@ var LoadingPage = React20.forwardRef(
|
|
|
3014
4501
|
return () => clearTimeout(timer);
|
|
3015
4502
|
}, [loading, delay]);
|
|
3016
4503
|
if (!visible) return null;
|
|
3017
|
-
return /* @__PURE__ */
|
|
4504
|
+
return /* @__PURE__ */ jsxs22(
|
|
3018
4505
|
"div",
|
|
3019
4506
|
{
|
|
3020
4507
|
ref,
|
|
@@ -3026,10 +4513,10 @@ var LoadingPage = React20.forwardRef(
|
|
|
3026
4513
|
),
|
|
3027
4514
|
...props,
|
|
3028
4515
|
children: [
|
|
3029
|
-
showLogo ? /* @__PURE__ */
|
|
3030
|
-
progress !== void 0 && /* @__PURE__ */
|
|
3031
|
-
message && /* @__PURE__ */
|
|
3032
|
-
/* @__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: [
|
|
3033
4520
|
message || "Loading",
|
|
3034
4521
|
progress !== void 0 && `, ${Math.round(progress)}% complete`
|
|
3035
4522
|
] })
|
|
@@ -3041,9 +4528,9 @@ var LoadingPage = React20.forwardRef(
|
|
|
3041
4528
|
LoadingPage.displayName = "LoadingPage";
|
|
3042
4529
|
|
|
3043
4530
|
// src/components/LoadingSection.tsx
|
|
3044
|
-
import * as
|
|
3045
|
-
import { jsx as
|
|
3046
|
-
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(
|
|
3047
4534
|
({
|
|
3048
4535
|
loading = false,
|
|
3049
4536
|
variant = "spinner",
|
|
@@ -3056,7 +4543,7 @@ var LoadingSection = React21.forwardRef(
|
|
|
3056
4543
|
children,
|
|
3057
4544
|
...props
|
|
3058
4545
|
}, ref) => {
|
|
3059
|
-
return /* @__PURE__ */
|
|
4546
|
+
return /* @__PURE__ */ jsxs23(
|
|
3060
4547
|
"div",
|
|
3061
4548
|
{
|
|
3062
4549
|
ref,
|
|
@@ -3066,7 +4553,7 @@ var LoadingSection = React21.forwardRef(
|
|
|
3066
4553
|
...props,
|
|
3067
4554
|
children: [
|
|
3068
4555
|
children,
|
|
3069
|
-
loading && /* @__PURE__ */
|
|
4556
|
+
loading && /* @__PURE__ */ jsx32(
|
|
3070
4557
|
LoadingOverlay,
|
|
3071
4558
|
{
|
|
3072
4559
|
mode: "overlay",
|
|
@@ -3085,11 +4572,11 @@ var LoadingSection = React21.forwardRef(
|
|
|
3085
4572
|
LoadingSection.displayName = "LoadingSection";
|
|
3086
4573
|
|
|
3087
4574
|
// src/components/LiveRegion.tsx
|
|
3088
|
-
import * as
|
|
3089
|
-
import { jsx as
|
|
3090
|
-
var LiveRegion =
|
|
4575
|
+
import * as React32 from "react";
|
|
4576
|
+
import { jsx as jsx33 } from "react/jsx-runtime";
|
|
4577
|
+
var LiveRegion = React32.forwardRef(
|
|
3091
4578
|
({ message, politeness = "polite", atomic = true, visuallyHidden = true, className, children }, ref) => {
|
|
3092
|
-
return /* @__PURE__ */
|
|
4579
|
+
return /* @__PURE__ */ jsx33(
|
|
3093
4580
|
"div",
|
|
3094
4581
|
{
|
|
3095
4582
|
ref,
|
|
@@ -3108,9 +4595,9 @@ var LiveRegion = React22.forwardRef(
|
|
|
3108
4595
|
LiveRegion.displayName = "LiveRegion";
|
|
3109
4596
|
|
|
3110
4597
|
// src/components/SkipLink.tsx
|
|
3111
|
-
import * as
|
|
3112
|
-
import { jsx as
|
|
3113
|
-
var SkipLink =
|
|
4598
|
+
import * as React33 from "react";
|
|
4599
|
+
import { jsx as jsx34 } from "react/jsx-runtime";
|
|
4600
|
+
var SkipLink = React33.forwardRef(
|
|
3114
4601
|
({ targetId, className, children = "Skip to main content", ...props }, ref) => {
|
|
3115
4602
|
const handleClick = (e) => {
|
|
3116
4603
|
e.preventDefault();
|
|
@@ -3128,7 +4615,7 @@ var SkipLink = React23.forwardRef(
|
|
|
3128
4615
|
}
|
|
3129
4616
|
props.onClick?.(e);
|
|
3130
4617
|
};
|
|
3131
|
-
return /* @__PURE__ */
|
|
4618
|
+
return /* @__PURE__ */ jsx34(
|
|
3132
4619
|
"a",
|
|
3133
4620
|
{
|
|
3134
4621
|
ref,
|
|
@@ -3144,11 +4631,11 @@ var SkipLink = React23.forwardRef(
|
|
|
3144
4631
|
SkipLink.displayName = "SkipLink";
|
|
3145
4632
|
|
|
3146
4633
|
// src/hooks/useFocusRef.ts
|
|
3147
|
-
import { useRef as
|
|
4634
|
+
import { useRef as useRef10, useEffect as useEffect12 } from "react";
|
|
3148
4635
|
function useFocusRef(options = {}) {
|
|
3149
4636
|
const { focusOnMount = false, preventScroll = false, delay = 0 } = options;
|
|
3150
|
-
const ref =
|
|
3151
|
-
|
|
4637
|
+
const ref = useRef10(null);
|
|
4638
|
+
useEffect12(() => {
|
|
3152
4639
|
if (!focusOnMount) return;
|
|
3153
4640
|
const focus = () => {
|
|
3154
4641
|
if (ref.current && typeof ref.current.focus === "function") {
|
|
@@ -3167,10 +4654,10 @@ function useFocusRef(options = {}) {
|
|
|
3167
4654
|
}
|
|
3168
4655
|
|
|
3169
4656
|
// src/hooks/useReducedMotion.ts
|
|
3170
|
-
import { useState as
|
|
4657
|
+
import { useState as useState13, useEffect as useEffect13 } from "react";
|
|
3171
4658
|
function useReducedMotion() {
|
|
3172
|
-
const [reducedMotion, setReducedMotion] =
|
|
3173
|
-
|
|
4659
|
+
const [reducedMotion, setReducedMotion] = useState13(false);
|
|
4660
|
+
useEffect13(() => {
|
|
3174
4661
|
const mediaQuery = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
3175
4662
|
setReducedMotion(mediaQuery.matches);
|
|
3176
4663
|
const handleChange = (event) => {
|
|
@@ -3185,7 +4672,7 @@ function useReducedMotion() {
|
|
|
3185
4672
|
}
|
|
3186
4673
|
|
|
3187
4674
|
// src/hooks/useArrowNavigation.ts
|
|
3188
|
-
import { useCallback as
|
|
4675
|
+
import { useCallback as useCallback5, useRef as useRef11, useState as useState14 } from "react";
|
|
3189
4676
|
var DEFAULT_SELECTOR = '[role="menuitem"], [role="option"], [role="tab"], button, a, [tabindex]:not([tabindex="-1"])';
|
|
3190
4677
|
function useArrowNavigation(options = {}) {
|
|
3191
4678
|
const {
|
|
@@ -3194,18 +4681,18 @@ function useArrowNavigation(options = {}) {
|
|
|
3194
4681
|
itemSelector = DEFAULT_SELECTOR,
|
|
3195
4682
|
onFocusChange
|
|
3196
4683
|
} = options;
|
|
3197
|
-
const containerRef =
|
|
3198
|
-
const focusedIndexRef =
|
|
3199
|
-
const [focusedIndex, setFocusedIndexState] =
|
|
3200
|
-
const setFocusedIndex =
|
|
4684
|
+
const containerRef = useRef11(null);
|
|
4685
|
+
const focusedIndexRef = useRef11(-1);
|
|
4686
|
+
const [focusedIndex, setFocusedIndexState] = useState14(-1);
|
|
4687
|
+
const setFocusedIndex = useCallback5((index) => {
|
|
3201
4688
|
focusedIndexRef.current = index;
|
|
3202
4689
|
setFocusedIndexState(index);
|
|
3203
4690
|
}, []);
|
|
3204
|
-
const getFocusableItems =
|
|
4691
|
+
const getFocusableItems = useCallback5(() => {
|
|
3205
4692
|
if (!containerRef.current) return [];
|
|
3206
4693
|
return Array.from(containerRef.current.querySelectorAll(itemSelector));
|
|
3207
4694
|
}, [itemSelector]);
|
|
3208
|
-
const focusItem =
|
|
4695
|
+
const focusItem = useCallback5(
|
|
3209
4696
|
(index) => {
|
|
3210
4697
|
const items = getFocusableItems();
|
|
3211
4698
|
if (items.length === 0) return;
|
|
@@ -3225,7 +4712,7 @@ function useArrowNavigation(options = {}) {
|
|
|
3225
4712
|
},
|
|
3226
4713
|
[getFocusableItems, loop, onFocusChange, setFocusedIndex]
|
|
3227
4714
|
);
|
|
3228
|
-
const handleKeyDown =
|
|
4715
|
+
const handleKeyDown = useCallback5(
|
|
3229
4716
|
(event) => {
|
|
3230
4717
|
const items = getFocusableItems();
|
|
3231
4718
|
if (items.length === 0) return;
|
|
@@ -3272,7 +4759,7 @@ function useArrowNavigation(options = {}) {
|
|
|
3272
4759
|
},
|
|
3273
4760
|
[orientation, focusItem, getFocusableItems]
|
|
3274
4761
|
);
|
|
3275
|
-
const handleFocus =
|
|
4762
|
+
const handleFocus = useCallback5(
|
|
3276
4763
|
(event) => {
|
|
3277
4764
|
const items = getFocusableItems();
|
|
3278
4765
|
const index = items.indexOf(event.target);
|
|
@@ -3290,7 +4777,7 @@ function useArrowNavigation(options = {}) {
|
|
|
3290
4777
|
onFocus: handleFocus
|
|
3291
4778
|
};
|
|
3292
4779
|
const tabStopIndex = focusedIndex === -1 ? 0 : focusedIndex;
|
|
3293
|
-
const getItemProps =
|
|
4780
|
+
const getItemProps = useCallback5(
|
|
3294
4781
|
(index) => ({
|
|
3295
4782
|
tabIndex: index === tabStopIndex ? 0 : -1,
|
|
3296
4783
|
onFocus: () => {
|
|
@@ -3308,20 +4795,20 @@ function useArrowNavigation(options = {}) {
|
|
|
3308
4795
|
}
|
|
3309
4796
|
|
|
3310
4797
|
// src/hooks/useRovingTabindex.ts
|
|
3311
|
-
import { useState as
|
|
4798
|
+
import { useState as useState15, useCallback as useCallback6, useRef as useRef12 } from "react";
|
|
3312
4799
|
var DEFAULT_SELECTOR2 = "[data-roving-tabindex-item]";
|
|
3313
4800
|
function useRovingTabindex(options = {}) {
|
|
3314
4801
|
const { loop = true, itemSelector = DEFAULT_SELECTOR2, initialIndex = 0, onIndexChange } = options;
|
|
3315
|
-
const [activeIndex, setActiveIndex] =
|
|
3316
|
-
const containerRef =
|
|
3317
|
-
const itemsRef =
|
|
3318
|
-
const getItems =
|
|
4802
|
+
const [activeIndex, setActiveIndex] = useState15(initialIndex);
|
|
4803
|
+
const containerRef = useRef12(null);
|
|
4804
|
+
const itemsRef = useRef12(/* @__PURE__ */ new Map());
|
|
4805
|
+
const getItems = useCallback6(() => {
|
|
3319
4806
|
if (!containerRef.current) {
|
|
3320
4807
|
return Array.from(itemsRef.current.values());
|
|
3321
4808
|
}
|
|
3322
4809
|
return Array.from(containerRef.current.querySelectorAll(itemSelector));
|
|
3323
4810
|
}, [itemSelector]);
|
|
3324
|
-
const focusIndex =
|
|
4811
|
+
const focusIndex = useCallback6(
|
|
3325
4812
|
(index) => {
|
|
3326
4813
|
const items = getItems();
|
|
3327
4814
|
if (items.length === 0) return;
|
|
@@ -3341,7 +4828,7 @@ function useRovingTabindex(options = {}) {
|
|
|
3341
4828
|
},
|
|
3342
4829
|
[getItems, loop, onIndexChange]
|
|
3343
4830
|
);
|
|
3344
|
-
const handleKeyDown =
|
|
4831
|
+
const handleKeyDown = useCallback6(
|
|
3345
4832
|
(event) => {
|
|
3346
4833
|
const items = getItems();
|
|
3347
4834
|
if (items.length === 0) return;
|
|
@@ -3379,7 +4866,7 @@ function useRovingTabindex(options = {}) {
|
|
|
3379
4866
|
},
|
|
3380
4867
|
onKeyDown: handleKeyDown
|
|
3381
4868
|
};
|
|
3382
|
-
const getItemProps =
|
|
4869
|
+
const getItemProps = useCallback6(
|
|
3383
4870
|
(index) => ({
|
|
3384
4871
|
"data-roving-tabindex-item": true,
|
|
3385
4872
|
tabIndex: index === activeIndex ? 0 : -1,
|
|
@@ -3416,21 +4903,21 @@ function useRovingTabindex(options = {}) {
|
|
|
3416
4903
|
}
|
|
3417
4904
|
|
|
3418
4905
|
// src/hooks/useClickOutside.ts
|
|
3419
|
-
import * as
|
|
4906
|
+
import * as React34 from "react";
|
|
3420
4907
|
function useClickOutside(ref, callback, options) {
|
|
3421
4908
|
const {
|
|
3422
4909
|
enabled = true,
|
|
3423
4910
|
events = ["mousedown", "touchstart"],
|
|
3424
4911
|
ignoreElements = []
|
|
3425
4912
|
} = options ?? {};
|
|
3426
|
-
const callbackRef =
|
|
3427
|
-
const ignoreElementsRef =
|
|
3428
|
-
|
|
4913
|
+
const callbackRef = React34.useRef(callback);
|
|
4914
|
+
const ignoreElementsRef = React34.useRef(ignoreElements);
|
|
4915
|
+
React34.useEffect(() => {
|
|
3429
4916
|
callbackRef.current = callback;
|
|
3430
4917
|
ignoreElementsRef.current = ignoreElements;
|
|
3431
4918
|
}, [callback, ignoreElements]);
|
|
3432
4919
|
const eventsKey = events.join(",");
|
|
3433
|
-
|
|
4920
|
+
React34.useEffect(() => {
|
|
3434
4921
|
if (!enabled) return;
|
|
3435
4922
|
const handleEvent = (event) => {
|
|
3436
4923
|
const target = event.target;
|
|
@@ -3483,6 +4970,8 @@ export {
|
|
|
3483
4970
|
DialogTitle,
|
|
3484
4971
|
DialogTrigger,
|
|
3485
4972
|
Input,
|
|
4973
|
+
InsertPalette,
|
|
4974
|
+
IssuesButton,
|
|
3486
4975
|
Label,
|
|
3487
4976
|
LiveRegion,
|
|
3488
4977
|
LoadingLogo,
|
|
@@ -3492,10 +4981,21 @@ export {
|
|
|
3492
4981
|
PageHeader,
|
|
3493
4982
|
PasswordInput,
|
|
3494
4983
|
ProgressBar,
|
|
4984
|
+
SaveStatus,
|
|
3495
4985
|
Separator,
|
|
4986
|
+
Sheet,
|
|
3496
4987
|
Skeleton,
|
|
3497
4988
|
SkipLink,
|
|
4989
|
+
SortableList,
|
|
3498
4990
|
Spinner,
|
|
4991
|
+
Studio,
|
|
4992
|
+
StudioBar,
|
|
4993
|
+
StudioCanvas,
|
|
4994
|
+
StudioCanvasItem,
|
|
4995
|
+
StudioInspector,
|
|
4996
|
+
StudioInspectorSection,
|
|
4997
|
+
StudioOutline,
|
|
4998
|
+
StudioPage,
|
|
3499
4999
|
Switch,
|
|
3500
5000
|
badgeVariants,
|
|
3501
5001
|
buttonVariants,
|
|
@@ -3515,5 +5015,6 @@ export {
|
|
|
3515
5015
|
useFocusRef,
|
|
3516
5016
|
useFocusTrap,
|
|
3517
5017
|
useReducedMotion,
|
|
3518
|
-
useRovingTabindex
|
|
5018
|
+
useRovingTabindex,
|
|
5019
|
+
useStudio
|
|
3519
5020
|
};
|