@classic-homes/theme-react 0.1.55 → 0.1.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -0
- package/dist/index.css +37 -12
- package/dist/index.d.mts +18 -3
- package/dist/index.d.ts +18 -3
- package/dist/index.js +1132 -293
- package/dist/index.mjs +1150 -305
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -654,11 +654,123 @@ var PageHeader = React12.forwardRef(
|
|
|
654
654
|
PageHeader.displayName = "PageHeader";
|
|
655
655
|
|
|
656
656
|
// src/components/DataPanel.tsx
|
|
657
|
-
import * as
|
|
657
|
+
import * as React14 from "react";
|
|
658
658
|
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
|
659
|
+
|
|
660
|
+
// src/hooks/useFocusTrap.ts
|
|
661
|
+
import { useEffect as useEffect2, useRef as useRef2, useCallback as useCallback2 } from "react";
|
|
662
|
+
var FOCUSABLE_SELECTOR = [
|
|
663
|
+
"a[href]",
|
|
664
|
+
"area[href]",
|
|
665
|
+
'input:not([disabled]):not([type="hidden"])',
|
|
666
|
+
"select:not([disabled])",
|
|
667
|
+
"textarea:not([disabled])",
|
|
668
|
+
"button:not([disabled])",
|
|
669
|
+
"iframe",
|
|
670
|
+
"object",
|
|
671
|
+
"embed",
|
|
672
|
+
"[contenteditable]",
|
|
673
|
+
'[tabindex]:not([tabindex="-1"])'
|
|
674
|
+
].join(",");
|
|
675
|
+
function getFocusableElements(container) {
|
|
676
|
+
const elements = container.querySelectorAll(FOCUSABLE_SELECTOR);
|
|
677
|
+
return Array.from(elements).filter(
|
|
678
|
+
(el) => el.offsetParent !== null && getComputedStyle(el).visibility !== "hidden"
|
|
679
|
+
);
|
|
680
|
+
}
|
|
681
|
+
function useFocusTrap(options = {}) {
|
|
682
|
+
const { active = true, returnFocusTo, initialFocus, preventScroll = false } = options;
|
|
683
|
+
const containerRef = useRef2(null);
|
|
684
|
+
const previousActiveElementRef = useRef2(null);
|
|
685
|
+
const handleKeyDown = useCallback2(
|
|
686
|
+
(event) => {
|
|
687
|
+
if (!active || event.key !== "Tab") return;
|
|
688
|
+
const container = containerRef.current;
|
|
689
|
+
if (!container) return;
|
|
690
|
+
const focusableElements = getFocusableElements(container);
|
|
691
|
+
if (focusableElements.length === 0) return;
|
|
692
|
+
const firstElement = focusableElements[0];
|
|
693
|
+
const lastElement = focusableElements[focusableElements.length - 1];
|
|
694
|
+
if (event.shiftKey) {
|
|
695
|
+
if (document.activeElement === firstElement) {
|
|
696
|
+
event.preventDefault();
|
|
697
|
+
lastElement.focus({ preventScroll });
|
|
698
|
+
}
|
|
699
|
+
} else {
|
|
700
|
+
if (document.activeElement === lastElement) {
|
|
701
|
+
event.preventDefault();
|
|
702
|
+
firstElement.focus({ preventScroll });
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
},
|
|
706
|
+
[active, preventScroll]
|
|
707
|
+
);
|
|
708
|
+
useEffect2(() => {
|
|
709
|
+
if (!active) return;
|
|
710
|
+
const container = containerRef.current;
|
|
711
|
+
if (!container) return;
|
|
712
|
+
previousActiveElementRef.current = document.activeElement;
|
|
713
|
+
const focusableElements = getFocusableElements(container);
|
|
714
|
+
if (focusableElements.length > 0) {
|
|
715
|
+
let elementToFocus = null;
|
|
716
|
+
if (initialFocus) {
|
|
717
|
+
elementToFocus = container.querySelector(initialFocus);
|
|
718
|
+
}
|
|
719
|
+
if (!elementToFocus) {
|
|
720
|
+
elementToFocus = focusableElements[0];
|
|
721
|
+
}
|
|
722
|
+
requestAnimationFrame(() => {
|
|
723
|
+
elementToFocus?.focus({ preventScroll });
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
727
|
+
return () => {
|
|
728
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
729
|
+
const elementToReturn = returnFocusTo ?? previousActiveElementRef.current;
|
|
730
|
+
if (elementToReturn && typeof elementToReturn.focus === "function") {
|
|
731
|
+
elementToReturn.focus({ preventScroll });
|
|
732
|
+
}
|
|
733
|
+
};
|
|
734
|
+
}, [active, initialFocus, returnFocusTo, handleKeyDown, preventScroll]);
|
|
735
|
+
return containerRef;
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
// src/hooks/useEscapeKey.ts
|
|
739
|
+
import * as React13 from "react";
|
|
740
|
+
function useEscapeKey(callback, options) {
|
|
741
|
+
const { enabled = true, preventDefault = true, stopPropagation = false } = options ?? {};
|
|
742
|
+
const callbackRef = React13.useRef(callback);
|
|
743
|
+
React13.useEffect(() => {
|
|
744
|
+
callbackRef.current = callback;
|
|
745
|
+
}, [callback]);
|
|
746
|
+
React13.useEffect(() => {
|
|
747
|
+
if (!enabled) return;
|
|
748
|
+
const handleKeyDown = (event) => {
|
|
749
|
+
if (event.key === "Escape") {
|
|
750
|
+
if (preventDefault) {
|
|
751
|
+
event.preventDefault();
|
|
752
|
+
}
|
|
753
|
+
if (stopPropagation) {
|
|
754
|
+
event.stopPropagation();
|
|
755
|
+
}
|
|
756
|
+
callbackRef.current(event);
|
|
757
|
+
}
|
|
758
|
+
};
|
|
759
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
760
|
+
return () => {
|
|
761
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
762
|
+
};
|
|
763
|
+
}, [enabled, preventDefault, stopPropagation]);
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
// src/components/DataPanel.tsx
|
|
659
767
|
import {
|
|
660
768
|
DEFAULT_PANEL_STATE,
|
|
661
769
|
DEFAULT_CONSTRAINTS,
|
|
770
|
+
DEFAULT_CARD_CONFIG,
|
|
771
|
+
CARD_HEADER_HEIGHT,
|
|
772
|
+
CARD_EXPANDED_RATIO,
|
|
773
|
+
CARD_MIN_WIDTH,
|
|
662
774
|
loadPanelState,
|
|
663
775
|
savePanelState,
|
|
664
776
|
getPointerPosition,
|
|
@@ -668,6 +780,7 @@ import {
|
|
|
668
780
|
getPinnedResizeHandle,
|
|
669
781
|
constrainSize,
|
|
670
782
|
constrainPosition,
|
|
783
|
+
constrainResize,
|
|
671
784
|
constrainPinnedWidth,
|
|
672
785
|
constrainPinnedHeight,
|
|
673
786
|
detectEdgeSnap,
|
|
@@ -675,6 +788,7 @@ import {
|
|
|
675
788
|
getDetachedPositionStyles,
|
|
676
789
|
getInitialDetachedPosition,
|
|
677
790
|
isHorizontalEdge,
|
|
791
|
+
constrainTabOffset,
|
|
678
792
|
calculateDetachDistance,
|
|
679
793
|
calculatePullOffset,
|
|
680
794
|
calculateDetachedPositionFromPinned,
|
|
@@ -695,28 +809,28 @@ function useDataPanel(options = {}) {
|
|
|
695
809
|
constraints = {}
|
|
696
810
|
} = options;
|
|
697
811
|
const resolvedConstraints = { ...DEFAULT_CONSTRAINTS, ...constraints };
|
|
698
|
-
const [persistedState] =
|
|
812
|
+
const [persistedState] = React14.useState(() => {
|
|
699
813
|
if (persistKey && typeof window !== "undefined") {
|
|
700
814
|
return loadPanelState(persistKey);
|
|
701
815
|
}
|
|
702
816
|
return null;
|
|
703
817
|
});
|
|
704
|
-
const [mode, setMode] =
|
|
705
|
-
const [edge, setEdge] =
|
|
706
|
-
const [isExpanded, setIsExpanded] =
|
|
818
|
+
const [mode, setMode] = React14.useState(persistedState?.mode ?? initialMode);
|
|
819
|
+
const [edge, setEdge] = React14.useState(persistedState?.edge ?? initialEdge);
|
|
820
|
+
const [isExpanded, setIsExpanded] = React14.useState(
|
|
707
821
|
persistedState?.isExpanded ?? initialExpanded
|
|
708
822
|
);
|
|
709
|
-
const [detachedPosition, setDetachedPosition] =
|
|
823
|
+
const [detachedPosition, setDetachedPosition] = React14.useState(
|
|
710
824
|
persistedState?.detachedPosition ?? DEFAULT_PANEL_STATE.detachedPosition
|
|
711
825
|
);
|
|
712
|
-
const [detachedSize, setDetachedSize] =
|
|
826
|
+
const [detachedSize, setDetachedSize] = React14.useState(
|
|
713
827
|
persistedState?.detachedSize ?? DEFAULT_PANEL_STATE.detachedSize
|
|
714
828
|
);
|
|
715
|
-
const [pinnedSize, setPinnedSize] =
|
|
829
|
+
const [pinnedSize, setPinnedSize] = React14.useState(
|
|
716
830
|
persistedState?.pinnedSize ?? DEFAULT_PANEL_STATE.pinnedSize
|
|
717
831
|
);
|
|
718
|
-
const saveTimeoutRef =
|
|
719
|
-
const debouncedSave =
|
|
832
|
+
const saveTimeoutRef = React14.useRef(null);
|
|
833
|
+
const debouncedSave = React14.useCallback(() => {
|
|
720
834
|
if (!persistKey) return;
|
|
721
835
|
if (saveTimeoutRef.current) {
|
|
722
836
|
clearTimeout(saveTimeoutRef.current);
|
|
@@ -730,11 +844,12 @@ function useDataPanel(options = {}) {
|
|
|
730
844
|
detachedPosition,
|
|
731
845
|
detachedSize,
|
|
732
846
|
pinnedSize,
|
|
733
|
-
cardSnapIndex: 0
|
|
847
|
+
cardSnapIndex: 0,
|
|
848
|
+
tabOffset: 0
|
|
734
849
|
});
|
|
735
850
|
}, 300);
|
|
736
851
|
}, [persistKey, mode, edge, isExpanded, detachedPosition, detachedSize, pinnedSize]);
|
|
737
|
-
const handleSetMode =
|
|
852
|
+
const handleSetMode = React14.useCallback(
|
|
738
853
|
(newMode) => {
|
|
739
854
|
setMode(newMode);
|
|
740
855
|
if (newMode === "detached" && typeof window !== "undefined" && detachedPosition.x === DEFAULT_PANEL_STATE.detachedPosition.x && detachedPosition.y === DEFAULT_PANEL_STATE.detachedPosition.y) {
|
|
@@ -745,7 +860,7 @@ function useDataPanel(options = {}) {
|
|
|
745
860
|
},
|
|
746
861
|
[detachedPosition, detachedSize]
|
|
747
862
|
);
|
|
748
|
-
const handleSetDetachedPosition =
|
|
863
|
+
const handleSetDetachedPosition = React14.useCallback(
|
|
749
864
|
(position) => {
|
|
750
865
|
if (typeof window === "undefined") {
|
|
751
866
|
setDetachedPosition(position);
|
|
@@ -757,13 +872,13 @@ function useDataPanel(options = {}) {
|
|
|
757
872
|
},
|
|
758
873
|
[detachedSize]
|
|
759
874
|
);
|
|
760
|
-
const handleSetDetachedSize =
|
|
875
|
+
const handleSetDetachedSize = React14.useCallback(
|
|
761
876
|
(size) => {
|
|
762
877
|
setDetachedSize(constrainSize(size, resolvedConstraints));
|
|
763
878
|
},
|
|
764
879
|
[resolvedConstraints]
|
|
765
880
|
);
|
|
766
|
-
const handleSetPinnedSize =
|
|
881
|
+
const handleSetPinnedSize = React14.useCallback(
|
|
767
882
|
(size) => {
|
|
768
883
|
if (typeof window === "undefined") {
|
|
769
884
|
setPinnedSize(size);
|
|
@@ -777,7 +892,7 @@ function useDataPanel(options = {}) {
|
|
|
777
892
|
},
|
|
778
893
|
[edge, resolvedConstraints]
|
|
779
894
|
);
|
|
780
|
-
|
|
895
|
+
React14.useEffect(() => {
|
|
781
896
|
debouncedSave();
|
|
782
897
|
}, [debouncedSave]);
|
|
783
898
|
return {
|
|
@@ -847,13 +962,31 @@ var CloseIcon = () => /* @__PURE__ */ jsxs5(
|
|
|
847
962
|
]
|
|
848
963
|
}
|
|
849
964
|
);
|
|
965
|
+
var GripIcon = () => /* @__PURE__ */ jsxs5(
|
|
966
|
+
"svg",
|
|
967
|
+
{
|
|
968
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
969
|
+
width: "16",
|
|
970
|
+
height: "16",
|
|
971
|
+
viewBox: "0 0 24 24",
|
|
972
|
+
fill: "currentColor",
|
|
973
|
+
children: [
|
|
974
|
+
/* @__PURE__ */ jsx12("circle", { cx: "9", cy: "6", r: "1.5" }),
|
|
975
|
+
/* @__PURE__ */ jsx12("circle", { cx: "15", cy: "6", r: "1.5" }),
|
|
976
|
+
/* @__PURE__ */ jsx12("circle", { cx: "9", cy: "12", r: "1.5" }),
|
|
977
|
+
/* @__PURE__ */ jsx12("circle", { cx: "15", cy: "12", r: "1.5" }),
|
|
978
|
+
/* @__PURE__ */ jsx12("circle", { cx: "9", cy: "18", r: "1.5" }),
|
|
979
|
+
/* @__PURE__ */ jsx12("circle", { cx: "15", cy: "18", r: "1.5" })
|
|
980
|
+
]
|
|
981
|
+
}
|
|
982
|
+
);
|
|
850
983
|
var edgeLabels = {
|
|
851
984
|
left: "Pin to left",
|
|
852
985
|
right: "Pin to right",
|
|
853
986
|
top: "Pin to top",
|
|
854
987
|
bottom: "Pin to bottom"
|
|
855
988
|
};
|
|
856
|
-
var DataPanelHeader =
|
|
989
|
+
var DataPanelHeader = React14.forwardRef(
|
|
857
990
|
({
|
|
858
991
|
title,
|
|
859
992
|
subtitle,
|
|
@@ -893,11 +1026,27 @@ var DataPanelHeader = React13.forwardRef(
|
|
|
893
1026
|
"button",
|
|
894
1027
|
{
|
|
895
1028
|
type: "button",
|
|
896
|
-
className: "flex h-8 w-8 items-center justify-center rounded-md bg-transparent text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
897
|
-
onClick: () =>
|
|
1029
|
+
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",
|
|
1030
|
+
onClick: () => {
|
|
1031
|
+
if (mode === "detached") {
|
|
1032
|
+
onModeChange?.("pinned");
|
|
1033
|
+
onExpandedChange?.(false);
|
|
1034
|
+
} else {
|
|
1035
|
+
onExpandedChange?.(!isExpanded);
|
|
1036
|
+
}
|
|
1037
|
+
},
|
|
898
1038
|
"aria-label": isExpanded ? "Collapse panel" : "Expand panel",
|
|
899
1039
|
"aria-expanded": isExpanded,
|
|
900
|
-
children: /* @__PURE__ */ jsx12(
|
|
1040
|
+
children: /* @__PURE__ */ jsx12(
|
|
1041
|
+
"span",
|
|
1042
|
+
{
|
|
1043
|
+
className: cn(
|
|
1044
|
+
"transition-transform",
|
|
1045
|
+
{ top: "", bottom: "rotate-180", left: "-rotate-90", right: "rotate-90" }[edge]
|
|
1046
|
+
),
|
|
1047
|
+
children: /* @__PURE__ */ jsx12(ChevronUpIcon, {})
|
|
1048
|
+
}
|
|
1049
|
+
)
|
|
901
1050
|
}
|
|
902
1051
|
),
|
|
903
1052
|
!disableModeSwitch && /* @__PURE__ */ jsxs5(DropdownMenuPrimitive.Root, { children: [
|
|
@@ -905,7 +1054,7 @@ var DataPanelHeader = React13.forwardRef(
|
|
|
905
1054
|
"button",
|
|
906
1055
|
{
|
|
907
1056
|
type: "button",
|
|
908
|
-
className: "flex h-8 w-8 items-center justify-center rounded-md bg-transparent text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
1057
|
+
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",
|
|
909
1058
|
"aria-label": "Panel options",
|
|
910
1059
|
children: /* @__PURE__ */ jsx12(MoreVerticalIcon, {})
|
|
911
1060
|
}
|
|
@@ -953,7 +1102,7 @@ var DataPanelHeader = React13.forwardRef(
|
|
|
953
1102
|
"button",
|
|
954
1103
|
{
|
|
955
1104
|
type: "button",
|
|
956
|
-
className: "flex h-8 w-8 items-center justify-center rounded-md bg-transparent text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
1105
|
+
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",
|
|
957
1106
|
onClick: onClose,
|
|
958
1107
|
"aria-label": "Close panel",
|
|
959
1108
|
children: /* @__PURE__ */ jsx12(CloseIcon, {})
|
|
@@ -966,7 +1115,94 @@ var DataPanelHeader = React13.forwardRef(
|
|
|
966
1115
|
}
|
|
967
1116
|
);
|
|
968
1117
|
DataPanelHeader.displayName = "DataPanelHeader";
|
|
969
|
-
|
|
1118
|
+
function DataPanelCardHeader({
|
|
1119
|
+
title,
|
|
1120
|
+
subtitle,
|
|
1121
|
+
titleId,
|
|
1122
|
+
isExpanded,
|
|
1123
|
+
isMobile,
|
|
1124
|
+
showDragHandle,
|
|
1125
|
+
headerContent,
|
|
1126
|
+
headerActions,
|
|
1127
|
+
disableClose = false,
|
|
1128
|
+
onHeaderPointerDown,
|
|
1129
|
+
onToggleExpand,
|
|
1130
|
+
onClose
|
|
1131
|
+
}) {
|
|
1132
|
+
return /* @__PURE__ */ jsxs5(
|
|
1133
|
+
"div",
|
|
1134
|
+
{
|
|
1135
|
+
"data-panel-header": true,
|
|
1136
|
+
className: "relative flex items-center justify-between gap-2 border-b border-border bg-muted/30 px-4 pt-5 pb-3 cursor-pointer",
|
|
1137
|
+
onPointerDown: onHeaderPointerDown,
|
|
1138
|
+
children: [
|
|
1139
|
+
showDragHandle && /* @__PURE__ */ jsx12(
|
|
1140
|
+
"div",
|
|
1141
|
+
{
|
|
1142
|
+
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",
|
|
1143
|
+
role: "button",
|
|
1144
|
+
tabIndex: 0,
|
|
1145
|
+
"aria-label": isExpanded ? "Collapse panel" : "Expand panel",
|
|
1146
|
+
"aria-expanded": isExpanded,
|
|
1147
|
+
onPointerDown: onHeaderPointerDown,
|
|
1148
|
+
onKeyDown: (e) => (e.key === "Enter" || e.key === " ") && onToggleExpand()
|
|
1149
|
+
}
|
|
1150
|
+
),
|
|
1151
|
+
/* @__PURE__ */ jsx12(
|
|
1152
|
+
"div",
|
|
1153
|
+
{
|
|
1154
|
+
className: "flex-1 min-w-0",
|
|
1155
|
+
role: "button",
|
|
1156
|
+
tabIndex: 0,
|
|
1157
|
+
onKeyDown: (e) => (e.key === "Enter" || e.key === " ") && onToggleExpand(),
|
|
1158
|
+
children: headerContent ? headerContent : /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
1159
|
+
subtitle && /* @__PURE__ */ jsx12("p", { className: "text-sm text-muted-foreground truncate", children: subtitle }),
|
|
1160
|
+
title && /* @__PURE__ */ jsx12("h3", { id: titleId, className: "text-lg font-semibold truncate", children: title })
|
|
1161
|
+
] })
|
|
1162
|
+
}
|
|
1163
|
+
),
|
|
1164
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-1 shrink-0", children: [
|
|
1165
|
+
headerActions,
|
|
1166
|
+
!isMobile && /* @__PURE__ */ jsx12(
|
|
1167
|
+
"button",
|
|
1168
|
+
{
|
|
1169
|
+
"data-card-drag-handle": true,
|
|
1170
|
+
type: "button",
|
|
1171
|
+
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 cursor-move touch-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
1172
|
+
"aria-label": "Drag to reposition panel",
|
|
1173
|
+
title: "Drag to move",
|
|
1174
|
+
onPointerDown: onHeaderPointerDown,
|
|
1175
|
+
children: /* @__PURE__ */ jsx12(GripIcon, {})
|
|
1176
|
+
}
|
|
1177
|
+
),
|
|
1178
|
+
/* @__PURE__ */ jsx12(
|
|
1179
|
+
"button",
|
|
1180
|
+
{
|
|
1181
|
+
type: "button",
|
|
1182
|
+
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",
|
|
1183
|
+
onClick: onToggleExpand,
|
|
1184
|
+
"aria-expanded": isExpanded,
|
|
1185
|
+
"aria-label": isExpanded ? "Collapse panel" : "Expand panel",
|
|
1186
|
+
title: isExpanded ? "Collapse" : "Expand",
|
|
1187
|
+
children: /* @__PURE__ */ jsx12("span", { className: cn("inline-flex transition-transform", isExpanded && "rotate-180"), children: /* @__PURE__ */ jsx12(ChevronUpIcon, {}) })
|
|
1188
|
+
}
|
|
1189
|
+
),
|
|
1190
|
+
!disableClose && /* @__PURE__ */ jsx12(
|
|
1191
|
+
"button",
|
|
1192
|
+
{
|
|
1193
|
+
type: "button",
|
|
1194
|
+
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",
|
|
1195
|
+
onClick: onClose,
|
|
1196
|
+
"aria-label": "Close panel",
|
|
1197
|
+
children: /* @__PURE__ */ jsx12(CloseIcon, {})
|
|
1198
|
+
}
|
|
1199
|
+
)
|
|
1200
|
+
] })
|
|
1201
|
+
]
|
|
1202
|
+
}
|
|
1203
|
+
);
|
|
1204
|
+
}
|
|
1205
|
+
var DataPanelContent = React14.forwardRef(
|
|
970
1206
|
({ children, className, "aria-label": ariaLabel = "Panel content" }, ref) => {
|
|
971
1207
|
return /* @__PURE__ */ jsx12(
|
|
972
1208
|
"div",
|
|
@@ -981,7 +1217,7 @@ var DataPanelContent = React13.forwardRef(
|
|
|
981
1217
|
}
|
|
982
1218
|
);
|
|
983
1219
|
DataPanelContent.displayName = "DataPanelContent";
|
|
984
|
-
var DataPanelFooter =
|
|
1220
|
+
var DataPanelFooter = React14.forwardRef(
|
|
985
1221
|
({ actions = [], footerContent, footerActions, className }, ref) => {
|
|
986
1222
|
if (!footerContent && actions.length === 0 && !footerActions) {
|
|
987
1223
|
return null;
|
|
@@ -1017,37 +1253,180 @@ var DataPanelFooter = React13.forwardRef(
|
|
|
1017
1253
|
}
|
|
1018
1254
|
);
|
|
1019
1255
|
DataPanelFooter.displayName = "DataPanelFooter";
|
|
1020
|
-
var DataPanelTab =
|
|
1021
|
-
({
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1256
|
+
var DataPanelTab = React14.forwardRef(
|
|
1257
|
+
({
|
|
1258
|
+
title = "Panel",
|
|
1259
|
+
subtitle,
|
|
1260
|
+
edge,
|
|
1261
|
+
onClick,
|
|
1262
|
+
onClose,
|
|
1263
|
+
disableClose = false,
|
|
1264
|
+
offset = 0,
|
|
1265
|
+
onOffsetChange,
|
|
1266
|
+
className
|
|
1267
|
+
}, ref) => {
|
|
1028
1268
|
const isVertical = edge === "left" || edge === "right";
|
|
1029
|
-
const
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1269
|
+
const positionClasses = {
|
|
1270
|
+
// Side tabs are the whole chip rotated 90°, so they need a fixed thickness
|
|
1271
|
+
// (h-14 → 56px) for a deterministic edge hug; see tabTransform below. Border
|
|
1272
|
+
// classes are in the chip's pre-rotation frame: its bottom rotates to the
|
|
1273
|
+
// attached (edge) side and its top corners to the viewport-facing corners,
|
|
1274
|
+
// so both edges drop the bottom border and round the top.
|
|
1275
|
+
left: "left-0 top-1/2 h-14 rounded-t-lg border-b-0",
|
|
1276
|
+
right: "right-0 top-1/2 h-14 rounded-t-lg border-b-0",
|
|
1277
|
+
top: "top-0 left-1/2 rounded-b-lg border-t-0",
|
|
1278
|
+
bottom: "bottom-0 left-1/2 rounded-t-lg border-b-0"
|
|
1034
1279
|
}[edge];
|
|
1280
|
+
const innerRef = React14.useRef(null);
|
|
1281
|
+
const dragRef = React14.useRef({
|
|
1282
|
+
startX: 0,
|
|
1283
|
+
startY: 0,
|
|
1284
|
+
startOffset: 0,
|
|
1285
|
+
moved: false,
|
|
1286
|
+
pointerId: -1
|
|
1287
|
+
});
|
|
1288
|
+
const [dragOffset, setDragOffset] = React14.useState(null);
|
|
1289
|
+
const effectiveOffset = dragOffset ?? offset;
|
|
1290
|
+
const draggable = !!onOffsetChange;
|
|
1291
|
+
const SIDE_HALF = 28;
|
|
1292
|
+
const tabTransform = edge === "left" ? `translate(calc(-50% + ${SIDE_HALF}px), calc(-50% + ${effectiveOffset}px)) rotate(90deg)` : edge === "right" ? `translate(calc(50% - ${SIDE_HALF}px), calc(-50% + ${effectiveOffset}px)) rotate(-90deg)` : `translateX(calc(-50% + ${effectiveOffset}px))`;
|
|
1293
|
+
const setRefs = (node) => {
|
|
1294
|
+
innerRef.current = node;
|
|
1295
|
+
if (typeof ref === "function") ref(node);
|
|
1296
|
+
else if (ref) ref.current = node;
|
|
1297
|
+
};
|
|
1298
|
+
const handlePointerDown = (e) => {
|
|
1299
|
+
if (!draggable) return;
|
|
1300
|
+
if (e.pointerType === "mouse" && e.button !== 0) return;
|
|
1301
|
+
if (e.target.closest("[data-no-drag]")) return;
|
|
1302
|
+
dragRef.current = {
|
|
1303
|
+
startX: e.clientX,
|
|
1304
|
+
startY: e.clientY,
|
|
1305
|
+
startOffset: offset,
|
|
1306
|
+
moved: false,
|
|
1307
|
+
pointerId: e.pointerId
|
|
1308
|
+
};
|
|
1309
|
+
setDragOffset(offset);
|
|
1310
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
1311
|
+
};
|
|
1312
|
+
const handlePointerMove = (e) => {
|
|
1313
|
+
const d = dragRef.current;
|
|
1314
|
+
if (d.pointerId !== e.pointerId || !e.currentTarget.hasPointerCapture(e.pointerId)) return;
|
|
1315
|
+
const delta = isVertical ? e.clientY - d.startY : e.clientX - d.startX;
|
|
1316
|
+
if (Math.abs(delta) > 3) d.moved = true;
|
|
1317
|
+
const rect = innerRef.current?.getBoundingClientRect();
|
|
1318
|
+
const tabSize = { width: rect?.width ?? 160, height: rect?.height ?? 48 };
|
|
1319
|
+
setDragOffset(
|
|
1320
|
+
constrainTabOffset(
|
|
1321
|
+
d.startOffset + delta,
|
|
1322
|
+
edge,
|
|
1323
|
+
tabSize,
|
|
1324
|
+
window.innerWidth,
|
|
1325
|
+
window.innerHeight
|
|
1326
|
+
)
|
|
1327
|
+
);
|
|
1328
|
+
};
|
|
1329
|
+
const handlePointerUp = (e) => {
|
|
1330
|
+
const d = dragRef.current;
|
|
1331
|
+
if (d.pointerId !== e.pointerId) return;
|
|
1332
|
+
if (e.currentTarget.hasPointerCapture(e.pointerId)) {
|
|
1333
|
+
e.currentTarget.releasePointerCapture(e.pointerId);
|
|
1334
|
+
}
|
|
1335
|
+
d.pointerId = -1;
|
|
1336
|
+
if (d.moved) {
|
|
1337
|
+
onOffsetChange?.(dragOffset ?? offset);
|
|
1338
|
+
} else {
|
|
1339
|
+
onClick?.();
|
|
1340
|
+
}
|
|
1341
|
+
setDragOffset(null);
|
|
1342
|
+
};
|
|
1343
|
+
const handlePointerCancel = (e) => {
|
|
1344
|
+
const d = dragRef.current;
|
|
1345
|
+
if (d.pointerId !== e.pointerId) return;
|
|
1346
|
+
if (e.currentTarget.hasPointerCapture(e.pointerId)) {
|
|
1347
|
+
e.currentTarget.releasePointerCapture(e.pointerId);
|
|
1348
|
+
}
|
|
1349
|
+
d.pointerId = -1;
|
|
1350
|
+
d.moved = false;
|
|
1351
|
+
setDragOffset(null);
|
|
1352
|
+
};
|
|
1353
|
+
const handleExpandKeyDown = (e) => {
|
|
1354
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
1355
|
+
e.preventDefault();
|
|
1356
|
+
onClick?.();
|
|
1357
|
+
}
|
|
1358
|
+
};
|
|
1359
|
+
React14.useEffect(() => {
|
|
1360
|
+
if (!onOffsetChange || dragOffset !== null) return;
|
|
1361
|
+
const rect = innerRef.current?.getBoundingClientRect();
|
|
1362
|
+
if (!rect) return;
|
|
1363
|
+
const clamped = constrainTabOffset(
|
|
1364
|
+
offset,
|
|
1365
|
+
edge,
|
|
1366
|
+
{ width: rect.width, height: rect.height },
|
|
1367
|
+
window.innerWidth,
|
|
1368
|
+
window.innerHeight
|
|
1369
|
+
);
|
|
1370
|
+
if (clamped !== offset) onOffsetChange(clamped);
|
|
1371
|
+
const onResize = () => {
|
|
1372
|
+
const r = innerRef.current?.getBoundingClientRect();
|
|
1373
|
+
if (!r) return;
|
|
1374
|
+
const c = constrainTabOffset(
|
|
1375
|
+
offset,
|
|
1376
|
+
edge,
|
|
1377
|
+
{ width: r.width, height: r.height },
|
|
1378
|
+
window.innerWidth,
|
|
1379
|
+
window.innerHeight
|
|
1380
|
+
);
|
|
1381
|
+
if (c !== offset) onOffsetChange(c);
|
|
1382
|
+
};
|
|
1383
|
+
window.addEventListener("resize", onResize);
|
|
1384
|
+
return () => window.removeEventListener("resize", onResize);
|
|
1385
|
+
}, [edge, offset, onOffsetChange, dragOffset]);
|
|
1035
1386
|
return /* @__PURE__ */ jsxs5(
|
|
1036
|
-
"
|
|
1387
|
+
"div",
|
|
1037
1388
|
{
|
|
1038
|
-
ref,
|
|
1039
|
-
type: "button",
|
|
1389
|
+
ref: setRefs,
|
|
1040
1390
|
className: cn(
|
|
1041
|
-
"fixed z-40 flex
|
|
1391
|
+
"fixed z-40 flex max-w-[220px] items-center gap-2 border border-border bg-background px-2.5 py-1.5 shadow-md focus-within:ring-2 focus-within:ring-ring",
|
|
1392
|
+
draggable && "cursor-grab touch-none active:cursor-grabbing",
|
|
1042
1393
|
positionClasses,
|
|
1043
|
-
isVertical && "[writing-mode:vertical-rl]",
|
|
1044
1394
|
className
|
|
1045
1395
|
),
|
|
1046
|
-
|
|
1047
|
-
|
|
1396
|
+
style: { transform: tabTransform },
|
|
1397
|
+
onPointerDown: handlePointerDown,
|
|
1398
|
+
onPointerMove: draggable ? handlePointerMove : void 0,
|
|
1399
|
+
onPointerUp: draggable ? handlePointerUp : void 0,
|
|
1400
|
+
onPointerCancel: draggable ? handlePointerCancel : void 0,
|
|
1048
1401
|
children: [
|
|
1049
|
-
/* @__PURE__ */
|
|
1050
|
-
|
|
1402
|
+
/* @__PURE__ */ jsxs5(
|
|
1403
|
+
"button",
|
|
1404
|
+
{
|
|
1405
|
+
type: "button",
|
|
1406
|
+
"aria-label": `Expand ${title} panel`,
|
|
1407
|
+
className: "flex min-w-0 flex-1 flex-col text-left leading-tight hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
1408
|
+
onClick: draggable ? void 0 : onClick,
|
|
1409
|
+
onKeyDown: handleExpandKeyDown,
|
|
1410
|
+
children: [
|
|
1411
|
+
/* @__PURE__ */ jsx12("span", { className: "truncate text-sm font-semibold", children: title }),
|
|
1412
|
+
subtitle && /* @__PURE__ */ jsx12("span", { className: "truncate text-xs text-muted-foreground", children: subtitle })
|
|
1413
|
+
]
|
|
1414
|
+
}
|
|
1415
|
+
),
|
|
1416
|
+
!disableClose && onClose && /* @__PURE__ */ jsx12(
|
|
1417
|
+
"button",
|
|
1418
|
+
{
|
|
1419
|
+
"data-no-drag": true,
|
|
1420
|
+
type: "button",
|
|
1421
|
+
className: "relative ml-1 flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground before:absolute before:-inset-2.5 before:content-[''] hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
1422
|
+
"aria-label": "Close panel",
|
|
1423
|
+
onClick: (e) => {
|
|
1424
|
+
e.stopPropagation();
|
|
1425
|
+
onClose();
|
|
1426
|
+
},
|
|
1427
|
+
children: /* @__PURE__ */ jsx12(CloseIcon, {})
|
|
1428
|
+
}
|
|
1429
|
+
)
|
|
1051
1430
|
]
|
|
1052
1431
|
}
|
|
1053
1432
|
);
|
|
@@ -1059,64 +1438,78 @@ var KEYBOARD_RESIZE_STEP_LARGE = 50;
|
|
|
1059
1438
|
function ResizeHandles({
|
|
1060
1439
|
mode,
|
|
1061
1440
|
edge,
|
|
1441
|
+
detachedPosition,
|
|
1062
1442
|
detachedSize,
|
|
1063
1443
|
pinnedSize,
|
|
1064
1444
|
onResizeStart,
|
|
1065
|
-
|
|
1445
|
+
onDetachedResize,
|
|
1066
1446
|
onPinnedSizeChange,
|
|
1067
1447
|
constraints
|
|
1068
1448
|
}) {
|
|
1069
|
-
const handleDetachedKeyDown =
|
|
1449
|
+
const handleDetachedKeyDown = React14.useCallback(
|
|
1070
1450
|
(e, handle) => {
|
|
1071
1451
|
const step = e.shiftKey ? KEYBOARD_RESIZE_STEP_LARGE : KEYBOARD_RESIZE_STEP;
|
|
1072
|
-
let
|
|
1452
|
+
let width = detachedSize.width;
|
|
1453
|
+
let height = detachedSize.height;
|
|
1073
1454
|
let handled = false;
|
|
1074
1455
|
switch (e.key) {
|
|
1075
1456
|
case "ArrowUp":
|
|
1076
1457
|
if (handle.includes("top")) {
|
|
1077
|
-
|
|
1458
|
+
height += step;
|
|
1078
1459
|
handled = true;
|
|
1079
1460
|
} else if (handle.includes("bottom")) {
|
|
1080
|
-
|
|
1461
|
+
height -= step;
|
|
1081
1462
|
handled = true;
|
|
1082
1463
|
}
|
|
1083
1464
|
break;
|
|
1084
1465
|
case "ArrowDown":
|
|
1085
1466
|
if (handle.includes("top")) {
|
|
1086
|
-
|
|
1467
|
+
height -= step;
|
|
1087
1468
|
handled = true;
|
|
1088
1469
|
} else if (handle.includes("bottom")) {
|
|
1089
|
-
|
|
1470
|
+
height += step;
|
|
1090
1471
|
handled = true;
|
|
1091
1472
|
}
|
|
1092
1473
|
break;
|
|
1093
1474
|
case "ArrowLeft":
|
|
1094
1475
|
if (handle.includes("left")) {
|
|
1095
|
-
|
|
1476
|
+
width += step;
|
|
1096
1477
|
handled = true;
|
|
1097
1478
|
} else if (handle.includes("right")) {
|
|
1098
|
-
|
|
1479
|
+
width -= step;
|
|
1099
1480
|
handled = true;
|
|
1100
1481
|
}
|
|
1101
1482
|
break;
|
|
1102
1483
|
case "ArrowRight":
|
|
1103
1484
|
if (handle.includes("left")) {
|
|
1104
|
-
|
|
1485
|
+
width -= step;
|
|
1105
1486
|
handled = true;
|
|
1106
1487
|
} else if (handle.includes("right")) {
|
|
1107
|
-
|
|
1488
|
+
width += step;
|
|
1108
1489
|
handled = true;
|
|
1109
1490
|
}
|
|
1110
1491
|
break;
|
|
1111
1492
|
}
|
|
1112
1493
|
if (handled) {
|
|
1113
1494
|
e.preventDefault();
|
|
1114
|
-
|
|
1495
|
+
const candidatePosition = {
|
|
1496
|
+
x: handle.includes("left") ? detachedPosition.x + (detachedSize.width - width) : detachedPosition.x,
|
|
1497
|
+
y: handle.includes("top") ? detachedPosition.y + (detachedSize.height - height) : detachedPosition.y
|
|
1498
|
+
};
|
|
1499
|
+
const { position, size } = constrainResize(
|
|
1500
|
+
candidatePosition,
|
|
1501
|
+
{ width, height },
|
|
1502
|
+
constraints,
|
|
1503
|
+
typeof window === "undefined" ? 1024 : window.innerWidth,
|
|
1504
|
+
typeof window === "undefined" ? 768 : window.innerHeight,
|
|
1505
|
+
handle
|
|
1506
|
+
);
|
|
1507
|
+
onDetachedResize(position, size);
|
|
1115
1508
|
}
|
|
1116
1509
|
},
|
|
1117
|
-
[detachedSize, constraints,
|
|
1510
|
+
[detachedPosition, detachedSize, constraints, onDetachedResize]
|
|
1118
1511
|
);
|
|
1119
|
-
const handlePinnedKeyDown =
|
|
1512
|
+
const handlePinnedKeyDown = React14.useCallback(
|
|
1120
1513
|
(e) => {
|
|
1121
1514
|
const step = e.shiftKey ? KEYBOARD_RESIZE_STEP_LARGE : KEYBOARD_RESIZE_STEP;
|
|
1122
1515
|
let newSize = pinnedSize;
|
|
@@ -1233,12 +1626,14 @@ function ResizeHandles({
|
|
|
1233
1626
|
}
|
|
1234
1627
|
);
|
|
1235
1628
|
}
|
|
1236
|
-
var DataPanel =
|
|
1629
|
+
var DataPanel = React14.forwardRef(
|
|
1237
1630
|
({
|
|
1238
1631
|
open: controlledOpen,
|
|
1239
1632
|
onOpenChange,
|
|
1240
1633
|
mode: controlledMode,
|
|
1241
1634
|
onModeChange,
|
|
1635
|
+
variant: controlledVariant,
|
|
1636
|
+
cardConfig = {},
|
|
1242
1637
|
edge: controlledEdge,
|
|
1243
1638
|
onEdgeChange,
|
|
1244
1639
|
expanded: controlledExpanded,
|
|
@@ -1261,84 +1656,151 @@ var DataPanel = React13.forwardRef(
|
|
|
1261
1656
|
footerActions,
|
|
1262
1657
|
className
|
|
1263
1658
|
}, ref) => {
|
|
1264
|
-
const resolvedConstraints =
|
|
1265
|
-
|
|
1659
|
+
const resolvedConstraints = React14.useMemo(
|
|
1660
|
+
() => ({ ...DEFAULT_CONSTRAINTS, ...constraints }),
|
|
1661
|
+
[constraints]
|
|
1662
|
+
);
|
|
1663
|
+
const resolvedCardConfig = React14.useMemo(
|
|
1664
|
+
() => ({ ...DEFAULT_CARD_CONFIG, ...cardConfig }),
|
|
1665
|
+
[cardConfig]
|
|
1666
|
+
);
|
|
1667
|
+
const panelId = React14.useId();
|
|
1266
1668
|
const titleId = `${panelId}-title`;
|
|
1267
|
-
const [internalOpen, setInternalOpen] =
|
|
1268
|
-
const [internalMode, setInternalMode] =
|
|
1269
|
-
const [
|
|
1270
|
-
|
|
1669
|
+
const [internalOpen, setInternalOpen] = React14.useState(true);
|
|
1670
|
+
const [internalMode, setInternalMode] = React14.useState(DEFAULT_PANEL_STATE.mode);
|
|
1671
|
+
const [internalVariant, setInternalVariant] = React14.useState(
|
|
1672
|
+
DEFAULT_PANEL_STATE.variant
|
|
1673
|
+
);
|
|
1674
|
+
const [internalEdge, setInternalEdge] = React14.useState(DEFAULT_PANEL_STATE.edge);
|
|
1675
|
+
const [internalExpanded, setInternalExpanded] = React14.useState(
|
|
1271
1676
|
DEFAULT_PANEL_STATE.isExpanded
|
|
1272
1677
|
);
|
|
1273
|
-
const [detachedPosition, setDetachedPosition] =
|
|
1678
|
+
const [detachedPosition, setDetachedPosition] = React14.useState(
|
|
1274
1679
|
DEFAULT_PANEL_STATE.detachedPosition
|
|
1275
1680
|
);
|
|
1276
|
-
const [detachedSize, setDetachedSize] =
|
|
1277
|
-
const [pinnedSize, setPinnedSize] =
|
|
1278
|
-
const [
|
|
1279
|
-
const [
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
const [
|
|
1283
|
-
|
|
1681
|
+
const [detachedSize, setDetachedSize] = React14.useState(DEFAULT_PANEL_STATE.detachedSize);
|
|
1682
|
+
const [pinnedSize, setPinnedSize] = React14.useState(DEFAULT_PANEL_STATE.pinnedSize);
|
|
1683
|
+
const [tabOffset, setTabOffset] = React14.useState(DEFAULT_PANEL_STATE.tabOffset);
|
|
1684
|
+
const [viewportWidth, setViewportWidth] = React14.useState(
|
|
1685
|
+
typeof window !== "undefined" ? window.innerWidth : 1024
|
|
1686
|
+
);
|
|
1687
|
+
const [viewportHeight, setViewportHeight] = React14.useState(
|
|
1688
|
+
typeof window !== "undefined" ? window.innerHeight : 768
|
|
1689
|
+
);
|
|
1690
|
+
const isMobile = viewportWidth < 640;
|
|
1691
|
+
const [cardHorizontalPosition, setCardHorizontalPosition] = React14.useState(0);
|
|
1692
|
+
const [cardExpandedHeight, setCardExpandedHeight] = React14.useState(0);
|
|
1693
|
+
const [cardWidth, setCardWidth] = React14.useState(null);
|
|
1694
|
+
const [cardDragCurrentHeight, setCardDragCurrentHeight] = React14.useState(CARD_HEADER_HEIGHT);
|
|
1695
|
+
const [isCardVerticalDragging, setIsCardVerticalDragging] = React14.useState(false);
|
|
1696
|
+
const [isCardHorizontalDragging, setIsCardHorizontalDragging] = React14.useState(false);
|
|
1697
|
+
const [isCardHeightTransitioning, setIsCardHeightTransitioning] = React14.useState(false);
|
|
1698
|
+
const [isCardWidthResizing, setIsCardWidthResizing] = React14.useState(false);
|
|
1699
|
+
const [isCardTopResizing, setIsCardTopResizing] = React14.useState(false);
|
|
1700
|
+
const [isDragging, setIsDragging] = React14.useState(false);
|
|
1701
|
+
const [isResizing, setIsResizing] = React14.useState(false);
|
|
1702
|
+
const [snapPreview, setSnapPreview] = React14.useState(null);
|
|
1703
|
+
const [isPinnedDragging, setIsPinnedDragging] = React14.useState(false);
|
|
1704
|
+
const [pullOffset, setPullOffset] = React14.useState(0);
|
|
1705
|
+
const dragStateRef = React14.useRef({
|
|
1284
1706
|
startPosition: { x: 0, y: 0 },
|
|
1285
1707
|
startPanelPosition: { x: 0, y: 0 }
|
|
1286
1708
|
});
|
|
1287
|
-
const pinnedDragStateRef =
|
|
1709
|
+
const pinnedDragStateRef = React14.useRef({
|
|
1288
1710
|
startPosition: { x: 0, y: 0 },
|
|
1289
1711
|
hasDetached: false
|
|
1290
1712
|
});
|
|
1291
|
-
const resizeStateRef =
|
|
1713
|
+
const resizeStateRef = React14.useRef({
|
|
1292
1714
|
handle: null,
|
|
1293
1715
|
startPosition: { x: 0, y: 0 },
|
|
1294
1716
|
startSize: { width: 0, height: 0 },
|
|
1295
1717
|
startPanelPosition: { x: 0, y: 0 }
|
|
1296
1718
|
});
|
|
1719
|
+
const cardDragStateRef = React14.useRef({
|
|
1720
|
+
startY: 0,
|
|
1721
|
+
startX: 0,
|
|
1722
|
+
startTime: 0,
|
|
1723
|
+
startExpanded: false,
|
|
1724
|
+
startHorizontalPosition: 0
|
|
1725
|
+
});
|
|
1726
|
+
const cardCurrentHeightRef = React14.useRef(CARD_HEADER_HEIGHT);
|
|
1727
|
+
const cardTopResizeStartRef = React14.useRef({ startY: 0, startHeight: 0 });
|
|
1728
|
+
const cardWidthResizeStateRef = React14.useRef({
|
|
1729
|
+
handle: null,
|
|
1730
|
+
startX: 0,
|
|
1731
|
+
startWidth: 0,
|
|
1732
|
+
startLeft: 0
|
|
1733
|
+
});
|
|
1297
1734
|
const open = controlledOpen ?? internalOpen;
|
|
1298
1735
|
const mode = controlledMode ?? internalMode;
|
|
1736
|
+
const variant = controlledVariant ?? internalVariant;
|
|
1299
1737
|
const edge = controlledEdge ?? internalEdge;
|
|
1300
1738
|
const isExpanded = controlledExpanded ?? internalExpanded;
|
|
1301
|
-
const
|
|
1302
|
-
const
|
|
1739
|
+
const showContent = variant !== "card" || isExpanded || isCardVerticalDragging;
|
|
1740
|
+
const saveTimeoutRef = React14.useRef(null);
|
|
1741
|
+
const isMountedRef = React14.useRef(true);
|
|
1742
|
+
React14.useEffect(() => {
|
|
1743
|
+
isMountedRef.current = true;
|
|
1744
|
+
return () => {
|
|
1745
|
+
isMountedRef.current = false;
|
|
1746
|
+
if (saveTimeoutRef.current) clearTimeout(saveTimeoutRef.current);
|
|
1747
|
+
if (typeof document !== "undefined") {
|
|
1748
|
+
document.body.style.cursor = "";
|
|
1749
|
+
document.body.style.userSelect = "";
|
|
1750
|
+
}
|
|
1751
|
+
};
|
|
1752
|
+
}, []);
|
|
1753
|
+
const debouncedSave = React14.useCallback(() => {
|
|
1303
1754
|
if (!persistKey) return;
|
|
1304
1755
|
if (saveTimeoutRef.current) {
|
|
1305
1756
|
clearTimeout(saveTimeoutRef.current);
|
|
1306
1757
|
}
|
|
1307
1758
|
saveTimeoutRef.current = setTimeout(() => {
|
|
1308
1759
|
savePanelState(persistKey, {
|
|
1309
|
-
mode
|
|
1310
|
-
variant
|
|
1311
|
-
edge
|
|
1312
|
-
isExpanded
|
|
1760
|
+
mode,
|
|
1761
|
+
variant,
|
|
1762
|
+
edge,
|
|
1763
|
+
isExpanded,
|
|
1313
1764
|
detachedPosition,
|
|
1314
1765
|
detachedSize,
|
|
1315
1766
|
pinnedSize,
|
|
1316
|
-
cardSnapIndex: 0
|
|
1767
|
+
cardSnapIndex: 0,
|
|
1768
|
+
tabOffset
|
|
1317
1769
|
});
|
|
1318
1770
|
}, 300);
|
|
1319
1771
|
}, [
|
|
1320
1772
|
persistKey,
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1773
|
+
mode,
|
|
1774
|
+
variant,
|
|
1775
|
+
edge,
|
|
1776
|
+
isExpanded,
|
|
1324
1777
|
detachedPosition,
|
|
1325
1778
|
detachedSize,
|
|
1326
|
-
pinnedSize
|
|
1779
|
+
pinnedSize,
|
|
1780
|
+
tabOffset
|
|
1327
1781
|
]);
|
|
1328
|
-
|
|
1329
|
-
|
|
1782
|
+
React14.useEffect(() => {
|
|
1783
|
+
debouncedSave();
|
|
1784
|
+
}, [debouncedSave]);
|
|
1785
|
+
const hasLoadedRef = React14.useRef(false);
|
|
1786
|
+
React14.useEffect(() => {
|
|
1787
|
+
if (!persistKey || hasLoadedRef.current) return;
|
|
1788
|
+
hasLoadedRef.current = true;
|
|
1330
1789
|
const persisted = loadPanelState(persistKey);
|
|
1331
1790
|
if (persisted) {
|
|
1332
1791
|
if (controlledMode === void 0 && persisted.mode) setInternalMode(persisted.mode);
|
|
1792
|
+
if (controlledVariant === void 0 && persisted.variant)
|
|
1793
|
+
setInternalVariant(persisted.variant);
|
|
1333
1794
|
if (controlledEdge === void 0 && persisted.edge) setInternalEdge(persisted.edge);
|
|
1334
1795
|
if (controlledExpanded === void 0 && persisted.isExpanded !== void 0)
|
|
1335
1796
|
setInternalExpanded(persisted.isExpanded);
|
|
1336
1797
|
if (persisted.detachedPosition) setDetachedPosition(persisted.detachedPosition);
|
|
1337
1798
|
if (persisted.detachedSize) setDetachedSize(persisted.detachedSize);
|
|
1338
1799
|
if (persisted.pinnedSize) setPinnedSize(persisted.pinnedSize);
|
|
1800
|
+
if (persisted.tabOffset !== void 0) setTabOffset(persisted.tabOffset);
|
|
1339
1801
|
}
|
|
1340
|
-
}, [persistKey, controlledMode, controlledEdge, controlledExpanded]);
|
|
1341
|
-
|
|
1802
|
+
}, [persistKey, controlledMode, controlledVariant, controlledEdge, controlledExpanded]);
|
|
1803
|
+
React14.useEffect(() => {
|
|
1342
1804
|
if (mode === "detached" && detachedPosition.x === DEFAULT_PANEL_STATE.detachedPosition.x && detachedPosition.y === DEFAULT_PANEL_STATE.detachedPosition.y) {
|
|
1343
1805
|
setDetachedPosition(
|
|
1344
1806
|
getInitialDetachedPosition(detachedSize, window.innerWidth, window.innerHeight)
|
|
@@ -1351,27 +1813,50 @@ var DataPanel = React13.forwardRef(
|
|
|
1351
1813
|
}
|
|
1352
1814
|
onOpenChange?.(newOpen);
|
|
1353
1815
|
};
|
|
1354
|
-
const
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
const handleExpandedChange = (newExpanded) => {
|
|
1369
|
-
if (controlledExpanded === void 0) {
|
|
1370
|
-
setInternalExpanded(newExpanded);
|
|
1816
|
+
const isDialog = open && (mode === "detached" || variant === "card" && isExpanded && isMobile);
|
|
1817
|
+
const focusTrapRef = useFocusTrap({ active: isDialog });
|
|
1818
|
+
useEscapeKey(
|
|
1819
|
+
() => {
|
|
1820
|
+
if (!disableClose) handleOpenChange(false);
|
|
1821
|
+
},
|
|
1822
|
+
{ enabled: isDialog }
|
|
1823
|
+
);
|
|
1824
|
+
const setPanelRef = (node) => {
|
|
1825
|
+
focusTrapRef.current = node;
|
|
1826
|
+
if (typeof ref === "function") {
|
|
1827
|
+
ref(node);
|
|
1828
|
+
} else if (ref) {
|
|
1829
|
+
ref.current = node;
|
|
1371
1830
|
}
|
|
1372
|
-
onExpandedChange?.(newExpanded);
|
|
1373
|
-
debouncedSave();
|
|
1374
1831
|
};
|
|
1832
|
+
const handleModeChange = React14.useCallback(
|
|
1833
|
+
(newMode) => {
|
|
1834
|
+
if (controlledMode === void 0) {
|
|
1835
|
+
setInternalMode(newMode);
|
|
1836
|
+
}
|
|
1837
|
+
onModeChange?.(newMode);
|
|
1838
|
+
},
|
|
1839
|
+
[controlledMode, onModeChange]
|
|
1840
|
+
);
|
|
1841
|
+
const handleEdgeChange = React14.useCallback(
|
|
1842
|
+
(newEdge) => {
|
|
1843
|
+
if (controlledEdge === void 0) {
|
|
1844
|
+
setInternalEdge(newEdge);
|
|
1845
|
+
}
|
|
1846
|
+
onEdgeChange?.(newEdge);
|
|
1847
|
+
},
|
|
1848
|
+
[controlledEdge, onEdgeChange]
|
|
1849
|
+
);
|
|
1850
|
+
const handleExpandedChange = React14.useCallback(
|
|
1851
|
+
(newExpanded) => {
|
|
1852
|
+
if (controlledExpanded === void 0) {
|
|
1853
|
+
setInternalExpanded(newExpanded);
|
|
1854
|
+
}
|
|
1855
|
+
onExpandedChange?.(newExpanded);
|
|
1856
|
+
},
|
|
1857
|
+
[controlledExpanded, onExpandedChange]
|
|
1858
|
+
);
|
|
1859
|
+
const handleToggleExpand = () => handleExpandedChange(!isExpanded);
|
|
1375
1860
|
const handleDragStart = (e) => {
|
|
1376
1861
|
if (disableDrag) return;
|
|
1377
1862
|
const target = e.target;
|
|
@@ -1396,7 +1881,7 @@ var DataPanel = React13.forwardRef(
|
|
|
1396
1881
|
document.body.style.userSelect = "none";
|
|
1397
1882
|
}
|
|
1398
1883
|
};
|
|
1399
|
-
const handleDragMove =
|
|
1884
|
+
const handleDragMove = React14.useCallback(
|
|
1400
1885
|
(e) => {
|
|
1401
1886
|
if (!isDragging) return;
|
|
1402
1887
|
const currentPos = getPointerPosition(e);
|
|
@@ -1423,7 +1908,7 @@ var DataPanel = React13.forwardRef(
|
|
|
1423
1908
|
},
|
|
1424
1909
|
[isDragging, detachedSize, snapThreshold]
|
|
1425
1910
|
);
|
|
1426
|
-
const handleDragEnd =
|
|
1911
|
+
const handleDragEnd = React14.useCallback(() => {
|
|
1427
1912
|
if (!isDragging) return;
|
|
1428
1913
|
setIsDragging(false);
|
|
1429
1914
|
document.body.style.cursor = "";
|
|
@@ -1432,11 +1917,9 @@ var DataPanel = React13.forwardRef(
|
|
|
1432
1917
|
handleModeChange("pinned");
|
|
1433
1918
|
handleEdgeChange(snapPreview);
|
|
1434
1919
|
setSnapPreview(null);
|
|
1435
|
-
} else {
|
|
1436
|
-
debouncedSave();
|
|
1437
1920
|
}
|
|
1438
|
-
}, [isDragging, snapPreview, handleModeChange, handleEdgeChange
|
|
1439
|
-
const handlePinnedDragMove =
|
|
1921
|
+
}, [isDragging, snapPreview, handleModeChange, handleEdgeChange]);
|
|
1922
|
+
const handlePinnedDragMove = React14.useCallback(
|
|
1440
1923
|
(e) => {
|
|
1441
1924
|
if (!isPinnedDragging) return;
|
|
1442
1925
|
const currentPos = getPointerPosition(e);
|
|
@@ -1472,7 +1955,7 @@ var DataPanel = React13.forwardRef(
|
|
|
1472
1955
|
},
|
|
1473
1956
|
[isPinnedDragging, edge, detachThreshold, pinnedSize, detachedSize, handleModeChange]
|
|
1474
1957
|
);
|
|
1475
|
-
const handlePinnedDragEnd =
|
|
1958
|
+
const handlePinnedDragEnd = React14.useCallback(() => {
|
|
1476
1959
|
if (!isPinnedDragging) return;
|
|
1477
1960
|
setIsPinnedDragging(false);
|
|
1478
1961
|
setPullOffset(0);
|
|
@@ -1494,7 +1977,7 @@ var DataPanel = React13.forwardRef(
|
|
|
1494
1977
|
document.body.style.cursor = getResizeCursor(handle);
|
|
1495
1978
|
document.body.style.userSelect = "none";
|
|
1496
1979
|
};
|
|
1497
|
-
const handleResizeMove =
|
|
1980
|
+
const handleResizeMove = React14.useCallback(
|
|
1498
1981
|
(e) => {
|
|
1499
1982
|
if (!isResizing || !resizeStateRef.current.handle) return;
|
|
1500
1983
|
const currentPos = getPointerPosition(e);
|
|
@@ -1510,12 +1993,13 @@ var DataPanel = React13.forwardRef(
|
|
|
1510
1993
|
},
|
|
1511
1994
|
currentPos
|
|
1512
1995
|
);
|
|
1513
|
-
const constrainedSize =
|
|
1514
|
-
const constrainedPosition = constrainPosition(
|
|
1996
|
+
const { position: constrainedPosition, size: constrainedSize } = constrainResize(
|
|
1515
1997
|
result.position,
|
|
1516
|
-
|
|
1998
|
+
result.size,
|
|
1999
|
+
resolvedConstraints,
|
|
1517
2000
|
window.innerWidth,
|
|
1518
|
-
window.innerHeight
|
|
2001
|
+
window.innerHeight,
|
|
2002
|
+
handle
|
|
1519
2003
|
);
|
|
1520
2004
|
setDetachedSize(constrainedSize);
|
|
1521
2005
|
setDetachedPosition(constrainedPosition);
|
|
@@ -1532,45 +2016,387 @@ var DataPanel = React13.forwardRef(
|
|
|
1532
2016
|
},
|
|
1533
2017
|
[isResizing, mode, edge, resolvedConstraints]
|
|
1534
2018
|
);
|
|
1535
|
-
const handleResizeEnd =
|
|
2019
|
+
const handleResizeEnd = React14.useCallback(() => {
|
|
1536
2020
|
if (!isResizing) return;
|
|
1537
2021
|
setIsResizing(false);
|
|
1538
2022
|
resizeStateRef.current.handle = null;
|
|
1539
2023
|
document.body.style.cursor = "";
|
|
1540
2024
|
document.body.style.userSelect = "";
|
|
2025
|
+
}, [isResizing]);
|
|
2026
|
+
const handleCardHeaderPointerDown = (e) => {
|
|
2027
|
+
if (variant !== "card") return;
|
|
2028
|
+
const target = e.target;
|
|
2029
|
+
const isDragHandle = target.closest("[data-card-drag-handle]");
|
|
2030
|
+
if (!isDragHandle && target.closest("button")) return;
|
|
2031
|
+
const pos = getPointerPosition(e.nativeEvent);
|
|
2032
|
+
cardDragStateRef.current = {
|
|
2033
|
+
startY: pos.y,
|
|
2034
|
+
startX: pos.x,
|
|
2035
|
+
startTime: Date.now(),
|
|
2036
|
+
startExpanded: isExpanded,
|
|
2037
|
+
startHorizontalPosition: cardHorizontalPosition
|
|
2038
|
+
};
|
|
2039
|
+
const startHeight = isExpanded ? cardExpandedHeight : CARD_HEADER_HEIGHT;
|
|
2040
|
+
setCardDragCurrentHeight(startHeight);
|
|
2041
|
+
cardCurrentHeightRef.current = startHeight;
|
|
2042
|
+
if (isMobile) {
|
|
2043
|
+
setIsCardVerticalDragging(true);
|
|
2044
|
+
} else if (isDragHandle) {
|
|
2045
|
+
setIsCardHorizontalDragging(true);
|
|
2046
|
+
} else {
|
|
2047
|
+
setIsCardVerticalDragging(true);
|
|
2048
|
+
}
|
|
2049
|
+
document.body.style.userSelect = "none";
|
|
2050
|
+
};
|
|
2051
|
+
const handleCardPointerMove = React14.useCallback(
|
|
2052
|
+
(e) => {
|
|
2053
|
+
const currentPos = getPointerPosition(e);
|
|
2054
|
+
if (isCardVerticalDragging) {
|
|
2055
|
+
const deltaY = cardDragStateRef.current.startY - currentPos.y;
|
|
2056
|
+
const startHeight = cardDragStateRef.current.startExpanded ? cardExpandedHeight : CARD_HEADER_HEIGHT;
|
|
2057
|
+
const next = Math.max(
|
|
2058
|
+
CARD_HEADER_HEIGHT,
|
|
2059
|
+
Math.min(viewportHeight * 0.95, startHeight + deltaY)
|
|
2060
|
+
);
|
|
2061
|
+
setCardDragCurrentHeight(next);
|
|
2062
|
+
cardCurrentHeightRef.current = next;
|
|
2063
|
+
}
|
|
2064
|
+
if (isCardHorizontalDragging && !isMobile) {
|
|
2065
|
+
const deltaX = currentPos.x - cardDragStateRef.current.startX;
|
|
2066
|
+
const cw = Math.min(
|
|
2067
|
+
viewportWidth - resolvedCardConfig.horizontalMargin * 2,
|
|
2068
|
+
resolvedCardConfig.maxWidth
|
|
2069
|
+
);
|
|
2070
|
+
const defaultLeftOffset = Math.max(
|
|
2071
|
+
resolvedCardConfig.horizontalMargin,
|
|
2072
|
+
(viewportWidth - cw) / 2
|
|
2073
|
+
);
|
|
2074
|
+
const minOffset = -(defaultLeftOffset - resolvedCardConfig.horizontalMargin);
|
|
2075
|
+
const maxOffset = viewportWidth - cw - defaultLeftOffset - resolvedCardConfig.horizontalMargin;
|
|
2076
|
+
const nextPos = cardDragStateRef.current.startHorizontalPosition + deltaX;
|
|
2077
|
+
setCardHorizontalPosition(Math.max(minOffset, Math.min(maxOffset, nextPos)));
|
|
2078
|
+
}
|
|
2079
|
+
},
|
|
2080
|
+
[
|
|
2081
|
+
isCardVerticalDragging,
|
|
2082
|
+
isCardHorizontalDragging,
|
|
2083
|
+
isMobile,
|
|
2084
|
+
viewportWidth,
|
|
2085
|
+
viewportHeight,
|
|
2086
|
+
cardExpandedHeight,
|
|
2087
|
+
resolvedCardConfig.horizontalMargin,
|
|
2088
|
+
resolvedCardConfig.maxWidth
|
|
2089
|
+
]
|
|
2090
|
+
);
|
|
2091
|
+
const handleCardPointerUp = React14.useCallback(
|
|
2092
|
+
(e) => {
|
|
2093
|
+
const endTime = Date.now();
|
|
2094
|
+
const currentPos = getPointerPosition(e);
|
|
2095
|
+
const st = cardDragStateRef.current;
|
|
2096
|
+
const deltaTime = endTime - st.startTime;
|
|
2097
|
+
const deltaY = st.startY - currentPos.y;
|
|
2098
|
+
document.body.style.userSelect = "";
|
|
2099
|
+
if (isCardVerticalDragging) {
|
|
2100
|
+
if (deltaTime < 200 && Math.abs(deltaY) < 10) {
|
|
2101
|
+
setIsCardVerticalDragging(false);
|
|
2102
|
+
handleExpandedChange(!isExpanded);
|
|
2103
|
+
return;
|
|
2104
|
+
}
|
|
2105
|
+
const velocity = deltaY / deltaTime;
|
|
2106
|
+
let newExpanded;
|
|
2107
|
+
if (Math.abs(velocity) > resolvedCardConfig.swipeVelocityThreshold) {
|
|
2108
|
+
newExpanded = velocity > 0;
|
|
2109
|
+
} else {
|
|
2110
|
+
const midpoint = (CARD_HEADER_HEIGHT + cardExpandedHeight) / 2;
|
|
2111
|
+
newExpanded = cardCurrentHeightRef.current > midpoint;
|
|
2112
|
+
}
|
|
2113
|
+
const targetHeight = newExpanded ? cardExpandedHeight : CARD_HEADER_HEIGHT;
|
|
2114
|
+
setIsCardVerticalDragging(false);
|
|
2115
|
+
setIsCardHeightTransitioning(true);
|
|
2116
|
+
handleExpandedChange(newExpanded);
|
|
2117
|
+
requestAnimationFrame(() => {
|
|
2118
|
+
if (!isMountedRef.current) return;
|
|
2119
|
+
setCardDragCurrentHeight(targetHeight);
|
|
2120
|
+
cardCurrentHeightRef.current = targetHeight;
|
|
2121
|
+
});
|
|
2122
|
+
}
|
|
2123
|
+
if (isCardHorizontalDragging) {
|
|
2124
|
+
setIsCardHorizontalDragging(false);
|
|
2125
|
+
debouncedSave();
|
|
2126
|
+
}
|
|
2127
|
+
},
|
|
2128
|
+
[
|
|
2129
|
+
isCardVerticalDragging,
|
|
2130
|
+
isCardHorizontalDragging,
|
|
2131
|
+
isExpanded,
|
|
2132
|
+
cardExpandedHeight,
|
|
2133
|
+
resolvedCardConfig.swipeVelocityThreshold,
|
|
2134
|
+
handleExpandedChange,
|
|
2135
|
+
debouncedSave
|
|
2136
|
+
]
|
|
2137
|
+
);
|
|
2138
|
+
const handleCardResizeStart = (e) => {
|
|
2139
|
+
if (variant !== "card" || !isExpanded || disableResize || isMobile) return;
|
|
2140
|
+
e.preventDefault();
|
|
2141
|
+
e.stopPropagation();
|
|
2142
|
+
setIsCardTopResizing(true);
|
|
2143
|
+
const pos = getPointerPosition(e.nativeEvent);
|
|
2144
|
+
cardTopResizeStartRef.current = { startY: pos.y, startHeight: cardExpandedHeight };
|
|
2145
|
+
document.body.style.cursor = "ns-resize";
|
|
2146
|
+
document.body.style.userSelect = "none";
|
|
2147
|
+
};
|
|
2148
|
+
const handleCardResizeMove = React14.useCallback(
|
|
2149
|
+
(e) => {
|
|
2150
|
+
if (!isCardTopResizing) return;
|
|
2151
|
+
const currentPos = getPointerPosition(e);
|
|
2152
|
+
const deltaY = cardTopResizeStartRef.current.startY - currentPos.y;
|
|
2153
|
+
const newHeight = Math.max(
|
|
2154
|
+
CARD_HEADER_HEIGHT * 2,
|
|
2155
|
+
Math.min(viewportHeight * 0.95, cardTopResizeStartRef.current.startHeight + deltaY)
|
|
2156
|
+
);
|
|
2157
|
+
setCardExpandedHeight(newHeight);
|
|
2158
|
+
},
|
|
2159
|
+
[isCardTopResizing, viewportHeight]
|
|
2160
|
+
);
|
|
2161
|
+
const handleCardResizeEnd = React14.useCallback(() => {
|
|
2162
|
+
if (!isCardTopResizing) return;
|
|
2163
|
+
setIsCardTopResizing(false);
|
|
2164
|
+
document.body.style.cursor = "";
|
|
2165
|
+
document.body.style.userSelect = "";
|
|
1541
2166
|
debouncedSave();
|
|
1542
|
-
}, [
|
|
1543
|
-
|
|
2167
|
+
}, [isCardTopResizing, debouncedSave]);
|
|
2168
|
+
const handleCardWidthResizeStart = (e, handle) => {
|
|
2169
|
+
if (variant !== "card" || !isExpanded || disableResize || isMobile) return;
|
|
2170
|
+
e.preventDefault();
|
|
2171
|
+
e.stopPropagation();
|
|
2172
|
+
const pos = getPointerPosition(e.nativeEvent);
|
|
2173
|
+
const defaultCardWidth = Math.min(
|
|
2174
|
+
viewportWidth - resolvedCardConfig.horizontalMargin * 2,
|
|
2175
|
+
resolvedCardConfig.maxWidth
|
|
2176
|
+
);
|
|
2177
|
+
const currentWidth = cardWidth ?? defaultCardWidth;
|
|
2178
|
+
const defaultLeftOffset = Math.max(
|
|
2179
|
+
resolvedCardConfig.horizontalMargin,
|
|
2180
|
+
(viewportWidth - defaultCardWidth) / 2
|
|
2181
|
+
);
|
|
2182
|
+
cardWidthResizeStateRef.current = {
|
|
2183
|
+
handle,
|
|
2184
|
+
startX: pos.x,
|
|
2185
|
+
startWidth: currentWidth,
|
|
2186
|
+
startLeft: defaultLeftOffset + cardHorizontalPosition
|
|
2187
|
+
};
|
|
2188
|
+
setIsCardWidthResizing(true);
|
|
2189
|
+
document.body.style.cursor = "ew-resize";
|
|
2190
|
+
document.body.style.userSelect = "none";
|
|
2191
|
+
};
|
|
2192
|
+
const handleCardWidthResizeMove = React14.useCallback(
|
|
2193
|
+
(e) => {
|
|
2194
|
+
const st = cardWidthResizeStateRef.current;
|
|
2195
|
+
if (!isCardWidthResizing || !st.handle) return;
|
|
2196
|
+
const currentPos = getPointerPosition(e);
|
|
2197
|
+
const deltaX = currentPos.x - st.startX;
|
|
2198
|
+
if (st.handle === "right") {
|
|
2199
|
+
const newWidth = Math.max(
|
|
2200
|
+
CARD_MIN_WIDTH,
|
|
2201
|
+
Math.min(
|
|
2202
|
+
resolvedCardConfig.maxWidth,
|
|
2203
|
+
viewportWidth - st.startLeft - resolvedCardConfig.horizontalMargin,
|
|
2204
|
+
st.startWidth + deltaX
|
|
2205
|
+
)
|
|
2206
|
+
);
|
|
2207
|
+
setCardWidth(newWidth);
|
|
2208
|
+
} else {
|
|
2209
|
+
const newLeft = st.startLeft + deltaX;
|
|
2210
|
+
const newWidth = st.startWidth - deltaX;
|
|
2211
|
+
if (newLeft >= resolvedCardConfig.horizontalMargin && newWidth >= CARD_MIN_WIDTH) {
|
|
2212
|
+
setCardWidth(Math.min(newWidth, resolvedCardConfig.maxWidth));
|
|
2213
|
+
const defaultCardWidth = Math.min(
|
|
2214
|
+
viewportWidth - resolvedCardConfig.horizontalMargin * 2,
|
|
2215
|
+
resolvedCardConfig.maxWidth
|
|
2216
|
+
);
|
|
2217
|
+
const defaultLeftOffset = Math.max(
|
|
2218
|
+
resolvedCardConfig.horizontalMargin,
|
|
2219
|
+
(viewportWidth - defaultCardWidth) / 2
|
|
2220
|
+
);
|
|
2221
|
+
setCardHorizontalPosition(newLeft - defaultLeftOffset);
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2224
|
+
},
|
|
2225
|
+
[
|
|
2226
|
+
isCardWidthResizing,
|
|
2227
|
+
viewportWidth,
|
|
2228
|
+
resolvedCardConfig.horizontalMargin,
|
|
2229
|
+
resolvedCardConfig.maxWidth
|
|
2230
|
+
]
|
|
2231
|
+
);
|
|
2232
|
+
const handleCardWidthResizeEnd = React14.useCallback(() => {
|
|
2233
|
+
if (!isCardWidthResizing) return;
|
|
2234
|
+
setIsCardWidthResizing(false);
|
|
2235
|
+
cardWidthResizeStateRef.current.handle = null;
|
|
2236
|
+
document.body.style.cursor = "";
|
|
2237
|
+
document.body.style.userSelect = "";
|
|
2238
|
+
debouncedSave();
|
|
2239
|
+
}, [isCardWidthResizing, debouncedSave]);
|
|
2240
|
+
const cardDefaultWidth = Math.min(
|
|
2241
|
+
viewportWidth - resolvedCardConfig.horizontalMargin * 2,
|
|
2242
|
+
resolvedCardConfig.maxWidth
|
|
2243
|
+
);
|
|
2244
|
+
const cardCurrentWidth = cardWidth ?? cardDefaultWidth;
|
|
2245
|
+
const cardHeightMin = CARD_HEADER_HEIGHT * 2;
|
|
2246
|
+
const cardHeightMax = Math.round(viewportHeight * 0.95);
|
|
2247
|
+
const handleCardResizeKeyDown = (e, kind) => {
|
|
2248
|
+
if (disableResize) return;
|
|
2249
|
+
const step = e.shiftKey ? KEYBOARD_RESIZE_STEP_LARGE : KEYBOARD_RESIZE_STEP;
|
|
2250
|
+
if (kind === "height") {
|
|
2251
|
+
let delta = 0;
|
|
2252
|
+
if (e.key === "ArrowUp") delta = step;
|
|
2253
|
+
else if (e.key === "ArrowDown") delta = -step;
|
|
2254
|
+
else return;
|
|
2255
|
+
e.preventDefault();
|
|
2256
|
+
setCardExpandedHeight((h) => Math.max(cardHeightMin, Math.min(cardHeightMax, h + delta)));
|
|
2257
|
+
debouncedSave();
|
|
2258
|
+
return;
|
|
2259
|
+
}
|
|
2260
|
+
let widthDelta = 0;
|
|
2261
|
+
if (kind === "width-right") {
|
|
2262
|
+
if (e.key === "ArrowRight") widthDelta = step;
|
|
2263
|
+
else if (e.key === "ArrowLeft") widthDelta = -step;
|
|
2264
|
+
} else {
|
|
2265
|
+
if (e.key === "ArrowLeft") widthDelta = step;
|
|
2266
|
+
else if (e.key === "ArrowRight") widthDelta = -step;
|
|
2267
|
+
}
|
|
2268
|
+
if (widthDelta === 0) return;
|
|
2269
|
+
e.preventDefault();
|
|
2270
|
+
const maxWidth = Math.min(
|
|
2271
|
+
resolvedCardConfig.maxWidth,
|
|
2272
|
+
viewportWidth - resolvedCardConfig.horizontalMargin * 2
|
|
2273
|
+
);
|
|
2274
|
+
const nextWidth = Math.max(CARD_MIN_WIDTH, Math.min(maxWidth, cardCurrentWidth + widthDelta));
|
|
2275
|
+
const appliedDelta = nextWidth - cardCurrentWidth;
|
|
2276
|
+
setCardWidth(nextWidth);
|
|
2277
|
+
if (kind === "width-left") setCardHorizontalPosition((p) => p - appliedDelta);
|
|
2278
|
+
debouncedSave();
|
|
2279
|
+
};
|
|
2280
|
+
React14.useEffect(() => {
|
|
1544
2281
|
if (isDragging) {
|
|
1545
2282
|
window.addEventListener("pointermove", handleDragMove);
|
|
1546
2283
|
window.addEventListener("pointerup", handleDragEnd);
|
|
2284
|
+
window.addEventListener("pointercancel", handleDragEnd);
|
|
1547
2285
|
return () => {
|
|
1548
2286
|
window.removeEventListener("pointermove", handleDragMove);
|
|
1549
2287
|
window.removeEventListener("pointerup", handleDragEnd);
|
|
2288
|
+
window.removeEventListener("pointercancel", handleDragEnd);
|
|
1550
2289
|
};
|
|
1551
2290
|
}
|
|
1552
2291
|
}, [isDragging, handleDragMove, handleDragEnd]);
|
|
1553
|
-
|
|
2292
|
+
React14.useEffect(() => {
|
|
1554
2293
|
if (isPinnedDragging) {
|
|
1555
2294
|
window.addEventListener("pointermove", handlePinnedDragMove);
|
|
1556
2295
|
window.addEventListener("pointerup", handlePinnedDragEnd);
|
|
2296
|
+
window.addEventListener("pointercancel", handlePinnedDragEnd);
|
|
1557
2297
|
return () => {
|
|
1558
2298
|
window.removeEventListener("pointermove", handlePinnedDragMove);
|
|
1559
2299
|
window.removeEventListener("pointerup", handlePinnedDragEnd);
|
|
2300
|
+
window.removeEventListener("pointercancel", handlePinnedDragEnd);
|
|
1560
2301
|
};
|
|
1561
2302
|
}
|
|
1562
2303
|
}, [isPinnedDragging, handlePinnedDragMove, handlePinnedDragEnd]);
|
|
1563
|
-
|
|
2304
|
+
React14.useEffect(() => {
|
|
1564
2305
|
if (isResizing) {
|
|
1565
2306
|
window.addEventListener("pointermove", handleResizeMove);
|
|
1566
2307
|
window.addEventListener("pointerup", handleResizeEnd);
|
|
2308
|
+
window.addEventListener("pointercancel", handleResizeEnd);
|
|
1567
2309
|
return () => {
|
|
1568
2310
|
window.removeEventListener("pointermove", handleResizeMove);
|
|
1569
2311
|
window.removeEventListener("pointerup", handleResizeEnd);
|
|
2312
|
+
window.removeEventListener("pointercancel", handleResizeEnd);
|
|
1570
2313
|
};
|
|
1571
2314
|
}
|
|
1572
2315
|
}, [isResizing, handleResizeMove, handleResizeEnd]);
|
|
1573
|
-
|
|
2316
|
+
React14.useEffect(() => {
|
|
2317
|
+
if (isCardVerticalDragging || isCardHorizontalDragging) {
|
|
2318
|
+
window.addEventListener("pointermove", handleCardPointerMove);
|
|
2319
|
+
window.addEventListener("pointerup", handleCardPointerUp);
|
|
2320
|
+
window.addEventListener("pointercancel", handleCardPointerUp);
|
|
2321
|
+
return () => {
|
|
2322
|
+
window.removeEventListener("pointermove", handleCardPointerMove);
|
|
2323
|
+
window.removeEventListener("pointerup", handleCardPointerUp);
|
|
2324
|
+
window.removeEventListener("pointercancel", handleCardPointerUp);
|
|
2325
|
+
};
|
|
2326
|
+
}
|
|
2327
|
+
}, [
|
|
2328
|
+
isCardVerticalDragging,
|
|
2329
|
+
isCardHorizontalDragging,
|
|
2330
|
+
handleCardPointerMove,
|
|
2331
|
+
handleCardPointerUp
|
|
2332
|
+
]);
|
|
2333
|
+
React14.useEffect(() => {
|
|
2334
|
+
if (isCardTopResizing) {
|
|
2335
|
+
window.addEventListener("pointermove", handleCardResizeMove);
|
|
2336
|
+
window.addEventListener("pointerup", handleCardResizeEnd);
|
|
2337
|
+
window.addEventListener("pointercancel", handleCardResizeEnd);
|
|
2338
|
+
return () => {
|
|
2339
|
+
window.removeEventListener("pointermove", handleCardResizeMove);
|
|
2340
|
+
window.removeEventListener("pointerup", handleCardResizeEnd);
|
|
2341
|
+
window.removeEventListener("pointercancel", handleCardResizeEnd);
|
|
2342
|
+
};
|
|
2343
|
+
}
|
|
2344
|
+
}, [isCardTopResizing, handleCardResizeMove, handleCardResizeEnd]);
|
|
2345
|
+
React14.useEffect(() => {
|
|
2346
|
+
if (isCardWidthResizing) {
|
|
2347
|
+
window.addEventListener("pointermove", handleCardWidthResizeMove);
|
|
2348
|
+
window.addEventListener("pointerup", handleCardWidthResizeEnd);
|
|
2349
|
+
window.addEventListener("pointercancel", handleCardWidthResizeEnd);
|
|
2350
|
+
return () => {
|
|
2351
|
+
window.removeEventListener("pointermove", handleCardWidthResizeMove);
|
|
2352
|
+
window.removeEventListener("pointerup", handleCardWidthResizeEnd);
|
|
2353
|
+
window.removeEventListener("pointercancel", handleCardWidthResizeEnd);
|
|
2354
|
+
};
|
|
2355
|
+
}
|
|
2356
|
+
}, [isCardWidthResizing, handleCardWidthResizeMove, handleCardWidthResizeEnd]);
|
|
2357
|
+
React14.useEffect(() => {
|
|
2358
|
+
const onResize = () => {
|
|
2359
|
+
setViewportWidth(window.innerWidth);
|
|
2360
|
+
setViewportHeight(window.innerHeight);
|
|
2361
|
+
setCardExpandedHeight(window.innerHeight * CARD_EXPANDED_RATIO);
|
|
2362
|
+
};
|
|
2363
|
+
onResize();
|
|
2364
|
+
window.addEventListener("resize", onResize);
|
|
2365
|
+
return () => window.removeEventListener("resize", onResize);
|
|
2366
|
+
}, []);
|
|
2367
|
+
React14.useEffect(() => {
|
|
2368
|
+
if (isMobile && variant === "card") {
|
|
2369
|
+
setCardHorizontalPosition(0);
|
|
2370
|
+
setCardWidth(null);
|
|
2371
|
+
}
|
|
2372
|
+
}, [isMobile, variant]);
|
|
2373
|
+
React14.useEffect(() => {
|
|
2374
|
+
if (isCardHeightTransitioning) {
|
|
2375
|
+
const t = setTimeout(() => setIsCardHeightTransitioning(false), 350);
|
|
2376
|
+
return () => clearTimeout(t);
|
|
2377
|
+
}
|
|
2378
|
+
}, [isCardHeightTransitioning]);
|
|
2379
|
+
const panelStyles = React14.useMemo(() => {
|
|
2380
|
+
if (variant === "card") {
|
|
2381
|
+
const defaultCardWidth = Math.min(
|
|
2382
|
+
viewportWidth - resolvedCardConfig.horizontalMargin * 2,
|
|
2383
|
+
resolvedCardConfig.maxWidth
|
|
2384
|
+
);
|
|
2385
|
+
const actualCardWidth = cardWidth ?? defaultCardWidth;
|
|
2386
|
+
const defaultLeftOffset = Math.max(
|
|
2387
|
+
resolvedCardConfig.horizontalMargin,
|
|
2388
|
+
(viewportWidth - defaultCardWidth) / 2
|
|
2389
|
+
);
|
|
2390
|
+
const height = isCardVerticalDragging || isCardHeightTransitioning ? cardDragCurrentHeight : isExpanded ? cardExpandedHeight : CARD_HEADER_HEIGHT;
|
|
2391
|
+
return {
|
|
2392
|
+
bottom: 0,
|
|
2393
|
+
left: defaultLeftOffset + cardHorizontalPosition,
|
|
2394
|
+
width: actualCardWidth,
|
|
2395
|
+
height,
|
|
2396
|
+
maxHeight: viewportHeight * 0.95,
|
|
2397
|
+
borderRadius: `${resolvedCardConfig.borderRadius}px ${resolvedCardConfig.borderRadius}px 0 0`
|
|
2398
|
+
};
|
|
2399
|
+
}
|
|
1574
2400
|
if (mode === "pinned") {
|
|
1575
2401
|
const baseStyles = getPinnedPositionStyles(edge, pinnedSize);
|
|
1576
2402
|
if (pullOffset > 0) {
|
|
@@ -1580,22 +2406,54 @@ var DataPanel = React13.forwardRef(
|
|
|
1580
2406
|
return baseStyles;
|
|
1581
2407
|
}
|
|
1582
2408
|
return getDetachedPositionStyles(detachedPosition, detachedSize);
|
|
1583
|
-
}, [
|
|
2409
|
+
}, [
|
|
2410
|
+
variant,
|
|
2411
|
+
mode,
|
|
2412
|
+
edge,
|
|
2413
|
+
pinnedSize,
|
|
2414
|
+
detachedPosition,
|
|
2415
|
+
detachedSize,
|
|
2416
|
+
pullOffset,
|
|
2417
|
+
viewportWidth,
|
|
2418
|
+
viewportHeight,
|
|
2419
|
+
cardWidth,
|
|
2420
|
+
cardHorizontalPosition,
|
|
2421
|
+
cardExpandedHeight,
|
|
2422
|
+
cardDragCurrentHeight,
|
|
2423
|
+
isCardVerticalDragging,
|
|
2424
|
+
isCardHeightTransitioning,
|
|
2425
|
+
isExpanded,
|
|
2426
|
+
resolvedCardConfig.horizontalMargin,
|
|
2427
|
+
resolvedCardConfig.maxWidth,
|
|
2428
|
+
resolvedCardConfig.borderRadius
|
|
2429
|
+
]);
|
|
1584
2430
|
const pinnedClasses = {
|
|
1585
2431
|
left: "left-0 top-0 bottom-0 border-r",
|
|
1586
2432
|
right: "right-0 top-0 bottom-0 border-l",
|
|
1587
2433
|
top: "top-0 left-0 right-0 border-b",
|
|
1588
2434
|
bottom: "bottom-0 left-0 right-0 border-t"
|
|
1589
2435
|
}[edge];
|
|
1590
|
-
const animationClass = mode === "pinned" ? {
|
|
2436
|
+
const animationClass = variant === "card" ? "animate-panel-slide-in-bottom" : mode === "pinned" ? {
|
|
1591
2437
|
left: "animate-slide-right",
|
|
1592
2438
|
right: "animate-slide-left",
|
|
1593
2439
|
top: "animate-slide-down",
|
|
1594
2440
|
bottom: "animate-slide-up"
|
|
1595
2441
|
}[edge] : "animate-scale-in";
|
|
1596
2442
|
if (!open) return null;
|
|
1597
|
-
if (!isExpanded && mode === "pinned") {
|
|
1598
|
-
return /* @__PURE__ */ jsx12(
|
|
2443
|
+
if (variant === "full" && !isExpanded && mode === "pinned") {
|
|
2444
|
+
return /* @__PURE__ */ jsx12(
|
|
2445
|
+
DataPanelTab,
|
|
2446
|
+
{
|
|
2447
|
+
title,
|
|
2448
|
+
subtitle,
|
|
2449
|
+
edge,
|
|
2450
|
+
onClick: () => handleExpandedChange(true),
|
|
2451
|
+
onClose: () => handleOpenChange(false),
|
|
2452
|
+
disableClose,
|
|
2453
|
+
offset: tabOffset,
|
|
2454
|
+
onOffsetChange: setTabOffset
|
|
2455
|
+
}
|
|
2456
|
+
);
|
|
1599
2457
|
}
|
|
1600
2458
|
return /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
1601
2459
|
snapPreview && /* @__PURE__ */ jsx12(
|
|
@@ -1610,26 +2468,53 @@ var DataPanel = React13.forwardRef(
|
|
|
1610
2468
|
)
|
|
1611
2469
|
}
|
|
1612
2470
|
),
|
|
2471
|
+
variant === "card" && isExpanded && isMobile && /* @__PURE__ */ jsx12(
|
|
2472
|
+
"div",
|
|
2473
|
+
{
|
|
2474
|
+
className: "fixed inset-0 z-40 bg-black/50 transition-opacity",
|
|
2475
|
+
"aria-hidden": "true",
|
|
2476
|
+
onClick: handleToggleExpand
|
|
2477
|
+
}
|
|
2478
|
+
),
|
|
1613
2479
|
/* @__PURE__ */ jsxs5(
|
|
1614
2480
|
"div",
|
|
1615
2481
|
{
|
|
1616
|
-
ref,
|
|
2482
|
+
ref: setPanelRef,
|
|
1617
2483
|
className: cn(
|
|
1618
2484
|
"fixed z-50 flex flex-col bg-background border border-border shadow-lg overflow-hidden",
|
|
1619
|
-
mode === "pinned" && pinnedClasses,
|
|
1620
|
-
mode === "detached" && "rounded-lg",
|
|
2485
|
+
variant === "full" && mode === "pinned" && pinnedClasses,
|
|
2486
|
+
variant === "full" && mode === "detached" && "rounded-lg",
|
|
2487
|
+
variant === "card" && "rounded-t-lg border-b-0",
|
|
1621
2488
|
isPinnedDragging && pullOffset > 0 && "shadow-2xl",
|
|
2489
|
+
!isDragging && !isPinnedDragging && !isCardHorizontalDragging && !isCardVerticalDragging && !isResizing && !isCardTopResizing && !isCardWidthResizing && "transition-[height,left,width,transform] duration-300 ease-out",
|
|
1622
2490
|
animationClass,
|
|
1623
2491
|
className
|
|
1624
2492
|
),
|
|
1625
2493
|
style: panelStyles,
|
|
1626
|
-
role: mode === "detached" ? "dialog" : "complementary",
|
|
1627
|
-
"aria-modal":
|
|
2494
|
+
role: mode === "detached" || variant === "card" ? "dialog" : "complementary",
|
|
2495
|
+
"aria-modal": isDialog ? "true" : void 0,
|
|
1628
2496
|
"aria-labelledby": title ? titleId : void 0,
|
|
1629
2497
|
"aria-label": !title ? "Side panel" : void 0,
|
|
1630
|
-
|
|
2498
|
+
"aria-expanded": variant === "card" ? isExpanded : void 0,
|
|
2499
|
+
onPointerDown: variant === "full" ? handleDragStart : void 0,
|
|
1631
2500
|
children: [
|
|
1632
|
-
/* @__PURE__ */ jsx12(
|
|
2501
|
+
variant === "card" ? /* @__PURE__ */ jsx12(
|
|
2502
|
+
DataPanelCardHeader,
|
|
2503
|
+
{
|
|
2504
|
+
title,
|
|
2505
|
+
subtitle,
|
|
2506
|
+
titleId,
|
|
2507
|
+
isExpanded,
|
|
2508
|
+
isMobile,
|
|
2509
|
+
showDragHandle: resolvedCardConfig.showDragHandle,
|
|
2510
|
+
headerContent,
|
|
2511
|
+
headerActions,
|
|
2512
|
+
disableClose,
|
|
2513
|
+
onHeaderPointerDown: handleCardHeaderPointerDown,
|
|
2514
|
+
onToggleExpand: handleToggleExpand,
|
|
2515
|
+
onClose: () => handleOpenChange(false)
|
|
2516
|
+
}
|
|
2517
|
+
) : /* @__PURE__ */ jsx12(
|
|
1633
2518
|
DataPanelHeader,
|
|
1634
2519
|
{
|
|
1635
2520
|
title,
|
|
@@ -1649,24 +2534,30 @@ var DataPanel = React13.forwardRef(
|
|
|
1649
2534
|
draggable: !disableDrag && (mode === "detached" || mode === "pinned" && detachThreshold > 0)
|
|
1650
2535
|
}
|
|
1651
2536
|
),
|
|
1652
|
-
/* @__PURE__ */
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
2537
|
+
showContent && /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
2538
|
+
/* @__PURE__ */ jsx12(DataPanelContent, { children }),
|
|
2539
|
+
/* @__PURE__ */ jsx12(
|
|
2540
|
+
DataPanelFooter,
|
|
2541
|
+
{
|
|
2542
|
+
actions,
|
|
2543
|
+
footerContent,
|
|
2544
|
+
footerActions
|
|
2545
|
+
}
|
|
2546
|
+
)
|
|
2547
|
+
] }),
|
|
2548
|
+
variant === "full" && !disableResize && /* @__PURE__ */ jsx12(
|
|
1662
2549
|
ResizeHandles,
|
|
1663
2550
|
{
|
|
1664
2551
|
mode,
|
|
1665
2552
|
edge,
|
|
2553
|
+
detachedPosition,
|
|
1666
2554
|
detachedSize,
|
|
1667
2555
|
pinnedSize,
|
|
1668
2556
|
onResizeStart: handleResizeStart,
|
|
1669
|
-
|
|
2557
|
+
onDetachedResize: (position, size) => {
|
|
2558
|
+
setDetachedSize(size);
|
|
2559
|
+
setDetachedPosition(position);
|
|
2560
|
+
},
|
|
1670
2561
|
onPinnedSizeChange: (size) => {
|
|
1671
2562
|
if (typeof window === "undefined") {
|
|
1672
2563
|
setPinnedSize(size);
|
|
@@ -1682,7 +2573,57 @@ var DataPanel = React13.forwardRef(
|
|
|
1682
2573
|
},
|
|
1683
2574
|
constraints: resolvedConstraints
|
|
1684
2575
|
}
|
|
1685
|
-
)
|
|
2576
|
+
),
|
|
2577
|
+
variant === "card" && isExpanded && !disableResize && !isMobile && /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
2578
|
+
/* @__PURE__ */ jsx12(
|
|
2579
|
+
"div",
|
|
2580
|
+
{
|
|
2581
|
+
className: "resize-handle resize-handle--horizontal resize-handle--top",
|
|
2582
|
+
role: "slider",
|
|
2583
|
+
tabIndex: 0,
|
|
2584
|
+
"aria-orientation": "vertical",
|
|
2585
|
+
"aria-label": "Resize card height",
|
|
2586
|
+
"aria-valuenow": Math.round(cardExpandedHeight),
|
|
2587
|
+
"aria-valuemin": cardHeightMin,
|
|
2588
|
+
"aria-valuemax": cardHeightMax,
|
|
2589
|
+
"aria-valuetext": `${Math.round(cardExpandedHeight)} pixels`,
|
|
2590
|
+
onPointerDown: handleCardResizeStart,
|
|
2591
|
+
onKeyDown: (e) => handleCardResizeKeyDown(e, "height")
|
|
2592
|
+
}
|
|
2593
|
+
),
|
|
2594
|
+
/* @__PURE__ */ jsx12(
|
|
2595
|
+
"div",
|
|
2596
|
+
{
|
|
2597
|
+
className: "resize-handle resize-handle--vertical resize-handle--left resize-handle--card-edge",
|
|
2598
|
+
role: "slider",
|
|
2599
|
+
tabIndex: 0,
|
|
2600
|
+
"aria-orientation": "horizontal",
|
|
2601
|
+
"aria-label": "Resize card width from left edge",
|
|
2602
|
+
"aria-valuenow": Math.round(cardCurrentWidth),
|
|
2603
|
+
"aria-valuemin": CARD_MIN_WIDTH,
|
|
2604
|
+
"aria-valuemax": resolvedCardConfig.maxWidth,
|
|
2605
|
+
"aria-valuetext": `${Math.round(cardCurrentWidth)} pixels`,
|
|
2606
|
+
onPointerDown: (e) => handleCardWidthResizeStart(e, "left"),
|
|
2607
|
+
onKeyDown: (e) => handleCardResizeKeyDown(e, "width-left")
|
|
2608
|
+
}
|
|
2609
|
+
),
|
|
2610
|
+
/* @__PURE__ */ jsx12(
|
|
2611
|
+
"div",
|
|
2612
|
+
{
|
|
2613
|
+
className: "resize-handle resize-handle--vertical resize-handle--right resize-handle--card-edge",
|
|
2614
|
+
role: "slider",
|
|
2615
|
+
tabIndex: 0,
|
|
2616
|
+
"aria-orientation": "horizontal",
|
|
2617
|
+
"aria-label": "Resize card width from right edge",
|
|
2618
|
+
"aria-valuenow": Math.round(cardCurrentWidth),
|
|
2619
|
+
"aria-valuemin": CARD_MIN_WIDTH,
|
|
2620
|
+
"aria-valuemax": resolvedCardConfig.maxWidth,
|
|
2621
|
+
"aria-valuetext": `${Math.round(cardCurrentWidth)} pixels`,
|
|
2622
|
+
onPointerDown: (e) => handleCardWidthResizeStart(e, "right"),
|
|
2623
|
+
onKeyDown: (e) => handleCardResizeKeyDown(e, "width-right")
|
|
2624
|
+
}
|
|
2625
|
+
)
|
|
2626
|
+
] })
|
|
1686
2627
|
]
|
|
1687
2628
|
}
|
|
1688
2629
|
)
|
|
@@ -1692,7 +2633,7 @@ var DataPanel = React13.forwardRef(
|
|
|
1692
2633
|
DataPanel.displayName = "DataPanel";
|
|
1693
2634
|
|
|
1694
2635
|
// src/components/Skeleton.tsx
|
|
1695
|
-
import * as
|
|
2636
|
+
import * as React15 from "react";
|
|
1696
2637
|
import { cva as cva5 } from "class-variance-authority";
|
|
1697
2638
|
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
1698
2639
|
var skeletonVariants = cva5("rounded-md bg-muted", {
|
|
@@ -1710,7 +2651,7 @@ var skeletonVariants = cva5("rounded-md bg-muted", {
|
|
|
1710
2651
|
variant: "default"
|
|
1711
2652
|
}
|
|
1712
2653
|
});
|
|
1713
|
-
var Skeleton =
|
|
2654
|
+
var Skeleton = React15.forwardRef(
|
|
1714
2655
|
({ className, variant, animation = "pulse", ...props }, ref) => {
|
|
1715
2656
|
const animationClass = animation === "pulse" ? "animate-pulse" : animation === "shimmer" ? "animate-shimmer" : "";
|
|
1716
2657
|
return /* @__PURE__ */ jsx13(
|
|
@@ -1726,7 +2667,7 @@ var Skeleton = React14.forwardRef(
|
|
|
1726
2667
|
Skeleton.displayName = "Skeleton";
|
|
1727
2668
|
|
|
1728
2669
|
// src/components/Spinner.tsx
|
|
1729
|
-
import * as
|
|
2670
|
+
import * as React16 from "react";
|
|
1730
2671
|
import { cva as cva6 } from "class-variance-authority";
|
|
1731
2672
|
import { jsx as jsx14, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1732
2673
|
var spinnerVariants = cva6("animate-spin text-current", {
|
|
@@ -1742,7 +2683,7 @@ var spinnerVariants = cva6("animate-spin text-current", {
|
|
|
1742
2683
|
size: "md"
|
|
1743
2684
|
}
|
|
1744
2685
|
});
|
|
1745
|
-
var Spinner =
|
|
2686
|
+
var Spinner = React16.forwardRef(
|
|
1746
2687
|
({ className, size, label = "Loading...", ...props }, ref) => {
|
|
1747
2688
|
return /* @__PURE__ */ jsxs6(
|
|
1748
2689
|
"svg",
|
|
@@ -1784,7 +2725,7 @@ var Spinner = React15.forwardRef(
|
|
|
1784
2725
|
Spinner.displayName = "Spinner";
|
|
1785
2726
|
|
|
1786
2727
|
// src/components/LoadingLogo.tsx
|
|
1787
|
-
import * as
|
|
2728
|
+
import * as React17 from "react";
|
|
1788
2729
|
import { jsx as jsx15, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1789
2730
|
var logoPaths = [
|
|
1790
2731
|
"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",
|
|
@@ -1807,7 +2748,7 @@ var colors = {
|
|
|
1807
2748
|
stroke: "#ffffff"
|
|
1808
2749
|
}
|
|
1809
2750
|
};
|
|
1810
|
-
var LoadingLogo =
|
|
2751
|
+
var LoadingLogo = React17.forwardRef(
|
|
1811
2752
|
({ width = 40, height = 40, loading = false, variant = "dark", className, ...props }, ref) => {
|
|
1812
2753
|
const currentColors = colors[variant];
|
|
1813
2754
|
const fillColor = loading ? currentColors.fillLoading : currentColors.fill;
|
|
@@ -1856,7 +2797,7 @@ var LoadingLogo = React16.forwardRef(
|
|
|
1856
2797
|
LoadingLogo.displayName = "LoadingLogo";
|
|
1857
2798
|
|
|
1858
2799
|
// src/components/ProgressBar.tsx
|
|
1859
|
-
import * as
|
|
2800
|
+
import * as React18 from "react";
|
|
1860
2801
|
import { cva as cva7 } from "class-variance-authority";
|
|
1861
2802
|
import { jsx as jsx16, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1862
2803
|
var progressBarVariants = cva7("w-full overflow-hidden rounded-full bg-muted", {
|
|
@@ -1884,7 +2825,7 @@ var progressFillVariants = cva7("h-full rounded-full transition-all duration-300
|
|
|
1884
2825
|
variant: "default"
|
|
1885
2826
|
}
|
|
1886
2827
|
});
|
|
1887
|
-
var ProgressBar =
|
|
2828
|
+
var ProgressBar = React18.forwardRef(
|
|
1888
2829
|
({ className, size, variant, value, max = 100, label = "Progress", showValue = false, ...props }, ref) => {
|
|
1889
2830
|
const isIndeterminate = value === void 0;
|
|
1890
2831
|
const clampedValue = isIndeterminate ? 0 : Math.min(Math.max(0, value), max);
|
|
@@ -1923,11 +2864,11 @@ var ProgressBar = React17.forwardRef(
|
|
|
1923
2864
|
ProgressBar.displayName = "ProgressBar";
|
|
1924
2865
|
|
|
1925
2866
|
// src/components/LoadingOverlay.tsx
|
|
1926
|
-
import * as
|
|
2867
|
+
import * as React19 from "react";
|
|
1927
2868
|
import { Fragment as Fragment2, jsx as jsx17, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1928
2869
|
var spinnerSizeMap = { sm: "sm", md: "md", lg: "lg", xl: "xl" };
|
|
1929
2870
|
var logoSizeMap = { sm: 32, md: 40, lg: 56, xl: 80 };
|
|
1930
|
-
var LoadingOverlay =
|
|
2871
|
+
var LoadingOverlay = React19.forwardRef(
|
|
1931
2872
|
({
|
|
1932
2873
|
loading = true,
|
|
1933
2874
|
variant = "spinner",
|
|
@@ -1942,8 +2883,8 @@ var LoadingOverlay = React18.forwardRef(
|
|
|
1942
2883
|
children,
|
|
1943
2884
|
...props
|
|
1944
2885
|
}, ref) => {
|
|
1945
|
-
const [visible, setVisible] =
|
|
1946
|
-
|
|
2886
|
+
const [visible, setVisible] = React19.useState(delay === 0 && loading);
|
|
2887
|
+
React19.useEffect(() => {
|
|
1947
2888
|
if (!loading) {
|
|
1948
2889
|
setVisible(false);
|
|
1949
2890
|
return;
|
|
@@ -2011,9 +2952,9 @@ var LoadingOverlay = React18.forwardRef(
|
|
|
2011
2952
|
LoadingOverlay.displayName = "LoadingOverlay";
|
|
2012
2953
|
|
|
2013
2954
|
// src/components/LoadingPage.tsx
|
|
2014
|
-
import * as
|
|
2955
|
+
import * as React20 from "react";
|
|
2015
2956
|
import { jsx as jsx18, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
2016
|
-
var LoadingPage =
|
|
2957
|
+
var LoadingPage = React20.forwardRef(
|
|
2017
2958
|
({
|
|
2018
2959
|
loading = true,
|
|
2019
2960
|
message,
|
|
@@ -2024,8 +2965,8 @@ var LoadingPage = React19.forwardRef(
|
|
|
2024
2965
|
className,
|
|
2025
2966
|
...props
|
|
2026
2967
|
}, ref) => {
|
|
2027
|
-
const [visible, setVisible] =
|
|
2028
|
-
|
|
2968
|
+
const [visible, setVisible] = React20.useState(delay === 0 && loading);
|
|
2969
|
+
React20.useEffect(() => {
|
|
2029
2970
|
if (!loading) {
|
|
2030
2971
|
setVisible(false);
|
|
2031
2972
|
return;
|
|
@@ -2065,9 +3006,9 @@ var LoadingPage = React19.forwardRef(
|
|
|
2065
3006
|
LoadingPage.displayName = "LoadingPage";
|
|
2066
3007
|
|
|
2067
3008
|
// src/components/LoadingSection.tsx
|
|
2068
|
-
import * as
|
|
3009
|
+
import * as React21 from "react";
|
|
2069
3010
|
import { jsx as jsx19, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
2070
|
-
var LoadingSection =
|
|
3011
|
+
var LoadingSection = React21.forwardRef(
|
|
2071
3012
|
({
|
|
2072
3013
|
loading = false,
|
|
2073
3014
|
variant = "spinner",
|
|
@@ -2109,9 +3050,9 @@ var LoadingSection = React20.forwardRef(
|
|
|
2109
3050
|
LoadingSection.displayName = "LoadingSection";
|
|
2110
3051
|
|
|
2111
3052
|
// src/components/LiveRegion.tsx
|
|
2112
|
-
import * as
|
|
3053
|
+
import * as React22 from "react";
|
|
2113
3054
|
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
2114
|
-
var LiveRegion =
|
|
3055
|
+
var LiveRegion = React22.forwardRef(
|
|
2115
3056
|
({ message, politeness = "polite", atomic = true, visuallyHidden = true, className, children }, ref) => {
|
|
2116
3057
|
return /* @__PURE__ */ jsx20(
|
|
2117
3058
|
"div",
|
|
@@ -2132,9 +3073,9 @@ var LiveRegion = React21.forwardRef(
|
|
|
2132
3073
|
LiveRegion.displayName = "LiveRegion";
|
|
2133
3074
|
|
|
2134
3075
|
// src/components/SkipLink.tsx
|
|
2135
|
-
import * as
|
|
3076
|
+
import * as React23 from "react";
|
|
2136
3077
|
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
2137
|
-
var SkipLink =
|
|
3078
|
+
var SkipLink = React23.forwardRef(
|
|
2138
3079
|
({ targetId, className, children = "Skip to main content", ...props }, ref) => {
|
|
2139
3080
|
const handleClick = (e) => {
|
|
2140
3081
|
e.preventDefault();
|
|
@@ -2167,90 +3108,12 @@ var SkipLink = React22.forwardRef(
|
|
|
2167
3108
|
);
|
|
2168
3109
|
SkipLink.displayName = "SkipLink";
|
|
2169
3110
|
|
|
2170
|
-
// src/hooks/useFocusTrap.ts
|
|
2171
|
-
import { useEffect as useEffect5, useRef as useRef3, useCallback as useCallback3 } from "react";
|
|
2172
|
-
var FOCUSABLE_SELECTOR = [
|
|
2173
|
-
"a[href]",
|
|
2174
|
-
"area[href]",
|
|
2175
|
-
'input:not([disabled]):not([type="hidden"])',
|
|
2176
|
-
"select:not([disabled])",
|
|
2177
|
-
"textarea:not([disabled])",
|
|
2178
|
-
"button:not([disabled])",
|
|
2179
|
-
"iframe",
|
|
2180
|
-
"object",
|
|
2181
|
-
"embed",
|
|
2182
|
-
"[contenteditable]",
|
|
2183
|
-
'[tabindex]:not([tabindex="-1"])'
|
|
2184
|
-
].join(",");
|
|
2185
|
-
function getFocusableElements(container) {
|
|
2186
|
-
const elements = container.querySelectorAll(FOCUSABLE_SELECTOR);
|
|
2187
|
-
return Array.from(elements).filter(
|
|
2188
|
-
(el) => el.offsetParent !== null && getComputedStyle(el).visibility !== "hidden"
|
|
2189
|
-
);
|
|
2190
|
-
}
|
|
2191
|
-
function useFocusTrap(options = {}) {
|
|
2192
|
-
const { active = true, returnFocusTo, initialFocus, preventScroll = false } = options;
|
|
2193
|
-
const containerRef = useRef3(null);
|
|
2194
|
-
const previousActiveElementRef = useRef3(null);
|
|
2195
|
-
const handleKeyDown = useCallback3(
|
|
2196
|
-
(event) => {
|
|
2197
|
-
if (!active || event.key !== "Tab") return;
|
|
2198
|
-
const container = containerRef.current;
|
|
2199
|
-
if (!container) return;
|
|
2200
|
-
const focusableElements = getFocusableElements(container);
|
|
2201
|
-
if (focusableElements.length === 0) return;
|
|
2202
|
-
const firstElement = focusableElements[0];
|
|
2203
|
-
const lastElement = focusableElements[focusableElements.length - 1];
|
|
2204
|
-
if (event.shiftKey) {
|
|
2205
|
-
if (document.activeElement === firstElement) {
|
|
2206
|
-
event.preventDefault();
|
|
2207
|
-
lastElement.focus({ preventScroll });
|
|
2208
|
-
}
|
|
2209
|
-
} else {
|
|
2210
|
-
if (document.activeElement === lastElement) {
|
|
2211
|
-
event.preventDefault();
|
|
2212
|
-
firstElement.focus({ preventScroll });
|
|
2213
|
-
}
|
|
2214
|
-
}
|
|
2215
|
-
},
|
|
2216
|
-
[active, preventScroll]
|
|
2217
|
-
);
|
|
2218
|
-
useEffect5(() => {
|
|
2219
|
-
if (!active) return;
|
|
2220
|
-
const container = containerRef.current;
|
|
2221
|
-
if (!container) return;
|
|
2222
|
-
previousActiveElementRef.current = document.activeElement;
|
|
2223
|
-
const focusableElements = getFocusableElements(container);
|
|
2224
|
-
if (focusableElements.length > 0) {
|
|
2225
|
-
let elementToFocus = null;
|
|
2226
|
-
if (initialFocus) {
|
|
2227
|
-
elementToFocus = container.querySelector(initialFocus);
|
|
2228
|
-
}
|
|
2229
|
-
if (!elementToFocus) {
|
|
2230
|
-
elementToFocus = focusableElements[0];
|
|
2231
|
-
}
|
|
2232
|
-
requestAnimationFrame(() => {
|
|
2233
|
-
elementToFocus?.focus({ preventScroll });
|
|
2234
|
-
});
|
|
2235
|
-
}
|
|
2236
|
-
document.addEventListener("keydown", handleKeyDown);
|
|
2237
|
-
return () => {
|
|
2238
|
-
document.removeEventListener("keydown", handleKeyDown);
|
|
2239
|
-
const elementToReturn = returnFocusTo ?? previousActiveElementRef.current;
|
|
2240
|
-
if (elementToReturn && typeof elementToReturn.focus === "function") {
|
|
2241
|
-
elementToReturn.focus({ preventScroll });
|
|
2242
|
-
}
|
|
2243
|
-
};
|
|
2244
|
-
}, [active, initialFocus, returnFocusTo, handleKeyDown, preventScroll]);
|
|
2245
|
-
return containerRef;
|
|
2246
|
-
}
|
|
2247
|
-
|
|
2248
3111
|
// src/hooks/useFocusRef.ts
|
|
2249
|
-
import { useRef as
|
|
3112
|
+
import { useRef as useRef5, useEffect as useEffect7 } from "react";
|
|
2250
3113
|
function useFocusRef(options = {}) {
|
|
2251
3114
|
const { focusOnMount = false, preventScroll = false, delay = 0 } = options;
|
|
2252
|
-
const ref =
|
|
2253
|
-
|
|
3115
|
+
const ref = useRef5(null);
|
|
3116
|
+
useEffect7(() => {
|
|
2254
3117
|
if (!focusOnMount) return;
|
|
2255
3118
|
const focus = () => {
|
|
2256
3119
|
if (ref.current && typeof ref.current.focus === "function") {
|
|
@@ -2269,10 +3132,10 @@ function useFocusRef(options = {}) {
|
|
|
2269
3132
|
}
|
|
2270
3133
|
|
|
2271
3134
|
// src/hooks/useReducedMotion.ts
|
|
2272
|
-
import { useState as useState6, useEffect as
|
|
3135
|
+
import { useState as useState6, useEffect as useEffect8 } from "react";
|
|
2273
3136
|
function useReducedMotion() {
|
|
2274
3137
|
const [reducedMotion, setReducedMotion] = useState6(false);
|
|
2275
|
-
|
|
3138
|
+
useEffect8(() => {
|
|
2276
3139
|
const mediaQuery = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
2277
3140
|
setReducedMotion(mediaQuery.matches);
|
|
2278
3141
|
const handleChange = (event) => {
|
|
@@ -2287,7 +3150,7 @@ function useReducedMotion() {
|
|
|
2287
3150
|
}
|
|
2288
3151
|
|
|
2289
3152
|
// src/hooks/useArrowNavigation.ts
|
|
2290
|
-
import { useCallback as useCallback4, useRef as
|
|
3153
|
+
import { useCallback as useCallback4, useRef as useRef6, useState as useState7 } from "react";
|
|
2291
3154
|
var DEFAULT_SELECTOR = '[role="menuitem"], [role="option"], [role="tab"], button, a, [tabindex]:not([tabindex="-1"])';
|
|
2292
3155
|
function useArrowNavigation(options = {}) {
|
|
2293
3156
|
const {
|
|
@@ -2296,8 +3159,13 @@ function useArrowNavigation(options = {}) {
|
|
|
2296
3159
|
itemSelector = DEFAULT_SELECTOR,
|
|
2297
3160
|
onFocusChange
|
|
2298
3161
|
} = options;
|
|
2299
|
-
const containerRef =
|
|
2300
|
-
const focusedIndexRef =
|
|
3162
|
+
const containerRef = useRef6(null);
|
|
3163
|
+
const focusedIndexRef = useRef6(-1);
|
|
3164
|
+
const [focusedIndex, setFocusedIndexState] = useState7(-1);
|
|
3165
|
+
const setFocusedIndex = useCallback4((index) => {
|
|
3166
|
+
focusedIndexRef.current = index;
|
|
3167
|
+
setFocusedIndexState(index);
|
|
3168
|
+
}, []);
|
|
2301
3169
|
const getFocusableItems = useCallback4(() => {
|
|
2302
3170
|
if (!containerRef.current) return [];
|
|
2303
3171
|
return Array.from(containerRef.current.querySelectorAll(itemSelector));
|
|
@@ -2316,11 +3184,11 @@ function useArrowNavigation(options = {}) {
|
|
|
2316
3184
|
const element = items[targetIndex];
|
|
2317
3185
|
if (element) {
|
|
2318
3186
|
element.focus();
|
|
2319
|
-
|
|
3187
|
+
setFocusedIndex(targetIndex);
|
|
2320
3188
|
onFocusChange?.(targetIndex, element);
|
|
2321
3189
|
}
|
|
2322
3190
|
},
|
|
2323
|
-
[getFocusableItems, loop, onFocusChange]
|
|
3191
|
+
[getFocusableItems, loop, onFocusChange, setFocusedIndex]
|
|
2324
3192
|
);
|
|
2325
3193
|
const handleKeyDown = useCallback4(
|
|
2326
3194
|
(event) => {
|
|
@@ -2374,10 +3242,10 @@ function useArrowNavigation(options = {}) {
|
|
|
2374
3242
|
const items = getFocusableItems();
|
|
2375
3243
|
const index = items.indexOf(event.target);
|
|
2376
3244
|
if (index !== -1) {
|
|
2377
|
-
|
|
3245
|
+
setFocusedIndex(index);
|
|
2378
3246
|
}
|
|
2379
3247
|
},
|
|
2380
|
-
[getFocusableItems]
|
|
3248
|
+
[getFocusableItems, setFocusedIndex]
|
|
2381
3249
|
);
|
|
2382
3250
|
const containerProps = {
|
|
2383
3251
|
ref: (node) => {
|
|
@@ -2386,14 +3254,15 @@ function useArrowNavigation(options = {}) {
|
|
|
2386
3254
|
onKeyDown: handleKeyDown,
|
|
2387
3255
|
onFocus: handleFocus
|
|
2388
3256
|
};
|
|
3257
|
+
const tabStopIndex = focusedIndex === -1 ? 0 : focusedIndex;
|
|
2389
3258
|
const getItemProps = useCallback4(
|
|
2390
3259
|
(index) => ({
|
|
2391
|
-
tabIndex: index ===
|
|
3260
|
+
tabIndex: index === tabStopIndex ? 0 : -1,
|
|
2392
3261
|
onFocus: () => {
|
|
2393
|
-
|
|
3262
|
+
setFocusedIndex(index);
|
|
2394
3263
|
}
|
|
2395
3264
|
}),
|
|
2396
|
-
[]
|
|
3265
|
+
[tabStopIndex, setFocusedIndex]
|
|
2397
3266
|
);
|
|
2398
3267
|
return {
|
|
2399
3268
|
containerProps,
|
|
@@ -2404,13 +3273,13 @@ function useArrowNavigation(options = {}) {
|
|
|
2404
3273
|
}
|
|
2405
3274
|
|
|
2406
3275
|
// src/hooks/useRovingTabindex.ts
|
|
2407
|
-
import { useState as
|
|
3276
|
+
import { useState as useState8, useCallback as useCallback5, useRef as useRef7 } from "react";
|
|
2408
3277
|
var DEFAULT_SELECTOR2 = "[data-roving-tabindex-item]";
|
|
2409
3278
|
function useRovingTabindex(options = {}) {
|
|
2410
3279
|
const { loop = true, itemSelector = DEFAULT_SELECTOR2, initialIndex = 0, onIndexChange } = options;
|
|
2411
|
-
const [activeIndex, setActiveIndex] =
|
|
2412
|
-
const containerRef =
|
|
2413
|
-
const itemsRef =
|
|
3280
|
+
const [activeIndex, setActiveIndex] = useState8(initialIndex);
|
|
3281
|
+
const containerRef = useRef7(null);
|
|
3282
|
+
const itemsRef = useRef7(/* @__PURE__ */ new Map());
|
|
2414
3283
|
const getItems = useCallback5(() => {
|
|
2415
3284
|
if (!containerRef.current) {
|
|
2416
3285
|
return Array.from(itemsRef.current.values());
|
|
@@ -2511,34 +3380,6 @@ function useRovingTabindex(options = {}) {
|
|
|
2511
3380
|
};
|
|
2512
3381
|
}
|
|
2513
3382
|
|
|
2514
|
-
// src/hooks/useEscapeKey.ts
|
|
2515
|
-
import * as React23 from "react";
|
|
2516
|
-
function useEscapeKey(callback, options) {
|
|
2517
|
-
const { enabled = true, preventDefault = true, stopPropagation = false } = options ?? {};
|
|
2518
|
-
const callbackRef = React23.useRef(callback);
|
|
2519
|
-
React23.useEffect(() => {
|
|
2520
|
-
callbackRef.current = callback;
|
|
2521
|
-
}, [callback]);
|
|
2522
|
-
React23.useEffect(() => {
|
|
2523
|
-
if (!enabled) return;
|
|
2524
|
-
const handleKeyDown = (event) => {
|
|
2525
|
-
if (event.key === "Escape") {
|
|
2526
|
-
if (preventDefault) {
|
|
2527
|
-
event.preventDefault();
|
|
2528
|
-
}
|
|
2529
|
-
if (stopPropagation) {
|
|
2530
|
-
event.stopPropagation();
|
|
2531
|
-
}
|
|
2532
|
-
callbackRef.current(event);
|
|
2533
|
-
}
|
|
2534
|
-
};
|
|
2535
|
-
document.addEventListener("keydown", handleKeyDown);
|
|
2536
|
-
return () => {
|
|
2537
|
-
document.removeEventListener("keydown", handleKeyDown);
|
|
2538
|
-
};
|
|
2539
|
-
}, [enabled, preventDefault, stopPropagation]);
|
|
2540
|
-
}
|
|
2541
|
-
|
|
2542
3383
|
// src/hooks/useClickOutside.ts
|
|
2543
3384
|
import * as React24 from "react";
|
|
2544
3385
|
function useClickOutside(ref, callback, options) {
|
|
@@ -2548,9 +3389,12 @@ function useClickOutside(ref, callback, options) {
|
|
|
2548
3389
|
ignoreElements = []
|
|
2549
3390
|
} = options ?? {};
|
|
2550
3391
|
const callbackRef = React24.useRef(callback);
|
|
3392
|
+
const ignoreElementsRef = React24.useRef(ignoreElements);
|
|
2551
3393
|
React24.useEffect(() => {
|
|
2552
3394
|
callbackRef.current = callback;
|
|
2553
|
-
|
|
3395
|
+
ignoreElementsRef.current = ignoreElements;
|
|
3396
|
+
}, [callback, ignoreElements]);
|
|
3397
|
+
const eventsKey = events.join(",");
|
|
2554
3398
|
React24.useEffect(() => {
|
|
2555
3399
|
if (!enabled) return;
|
|
2556
3400
|
const handleEvent = (event) => {
|
|
@@ -2558,22 +3402,23 @@ function useClickOutside(ref, callback, options) {
|
|
|
2558
3402
|
if (ref.current?.contains(target)) {
|
|
2559
3403
|
return;
|
|
2560
3404
|
}
|
|
2561
|
-
for (const ignoreRef of
|
|
3405
|
+
for (const ignoreRef of ignoreElementsRef.current) {
|
|
2562
3406
|
if (ignoreRef.current?.contains(target)) {
|
|
2563
3407
|
return;
|
|
2564
3408
|
}
|
|
2565
3409
|
}
|
|
2566
3410
|
callbackRef.current(event);
|
|
2567
3411
|
};
|
|
2568
|
-
|
|
3412
|
+
const eventTypes = eventsKey.split(",");
|
|
3413
|
+
eventTypes.forEach((eventType) => {
|
|
2569
3414
|
document.addEventListener(eventType, handleEvent);
|
|
2570
3415
|
});
|
|
2571
3416
|
return () => {
|
|
2572
|
-
|
|
3417
|
+
eventTypes.forEach((eventType) => {
|
|
2573
3418
|
document.removeEventListener(eventType, handleEvent);
|
|
2574
3419
|
});
|
|
2575
3420
|
};
|
|
2576
|
-
}, [enabled,
|
|
3421
|
+
}, [enabled, eventsKey, ref]);
|
|
2577
3422
|
}
|
|
2578
3423
|
export {
|
|
2579
3424
|
Avatar,
|