@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.js
CHANGED
|
@@ -749,8 +749,116 @@ var PageHeader = React12.forwardRef(
|
|
|
749
749
|
PageHeader.displayName = "PageHeader";
|
|
750
750
|
|
|
751
751
|
// src/components/DataPanel.tsx
|
|
752
|
-
var
|
|
752
|
+
var React14 = __toESM(require("react"));
|
|
753
753
|
var DropdownMenuPrimitive = __toESM(require("@radix-ui/react-dropdown-menu"));
|
|
754
|
+
|
|
755
|
+
// src/hooks/useFocusTrap.ts
|
|
756
|
+
var import_react = require("react");
|
|
757
|
+
var FOCUSABLE_SELECTOR = [
|
|
758
|
+
"a[href]",
|
|
759
|
+
"area[href]",
|
|
760
|
+
'input:not([disabled]):not([type="hidden"])',
|
|
761
|
+
"select:not([disabled])",
|
|
762
|
+
"textarea:not([disabled])",
|
|
763
|
+
"button:not([disabled])",
|
|
764
|
+
"iframe",
|
|
765
|
+
"object",
|
|
766
|
+
"embed",
|
|
767
|
+
"[contenteditable]",
|
|
768
|
+
'[tabindex]:not([tabindex="-1"])'
|
|
769
|
+
].join(",");
|
|
770
|
+
function getFocusableElements(container) {
|
|
771
|
+
const elements = container.querySelectorAll(FOCUSABLE_SELECTOR);
|
|
772
|
+
return Array.from(elements).filter(
|
|
773
|
+
(el) => el.offsetParent !== null && getComputedStyle(el).visibility !== "hidden"
|
|
774
|
+
);
|
|
775
|
+
}
|
|
776
|
+
function useFocusTrap(options = {}) {
|
|
777
|
+
const { active = true, returnFocusTo, initialFocus, preventScroll = false } = options;
|
|
778
|
+
const containerRef = (0, import_react.useRef)(null);
|
|
779
|
+
const previousActiveElementRef = (0, import_react.useRef)(null);
|
|
780
|
+
const handleKeyDown = (0, import_react.useCallback)(
|
|
781
|
+
(event) => {
|
|
782
|
+
if (!active || event.key !== "Tab") return;
|
|
783
|
+
const container = containerRef.current;
|
|
784
|
+
if (!container) return;
|
|
785
|
+
const focusableElements = getFocusableElements(container);
|
|
786
|
+
if (focusableElements.length === 0) return;
|
|
787
|
+
const firstElement = focusableElements[0];
|
|
788
|
+
const lastElement = focusableElements[focusableElements.length - 1];
|
|
789
|
+
if (event.shiftKey) {
|
|
790
|
+
if (document.activeElement === firstElement) {
|
|
791
|
+
event.preventDefault();
|
|
792
|
+
lastElement.focus({ preventScroll });
|
|
793
|
+
}
|
|
794
|
+
} else {
|
|
795
|
+
if (document.activeElement === lastElement) {
|
|
796
|
+
event.preventDefault();
|
|
797
|
+
firstElement.focus({ preventScroll });
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
},
|
|
801
|
+
[active, preventScroll]
|
|
802
|
+
);
|
|
803
|
+
(0, import_react.useEffect)(() => {
|
|
804
|
+
if (!active) return;
|
|
805
|
+
const container = containerRef.current;
|
|
806
|
+
if (!container) return;
|
|
807
|
+
previousActiveElementRef.current = document.activeElement;
|
|
808
|
+
const focusableElements = getFocusableElements(container);
|
|
809
|
+
if (focusableElements.length > 0) {
|
|
810
|
+
let elementToFocus = null;
|
|
811
|
+
if (initialFocus) {
|
|
812
|
+
elementToFocus = container.querySelector(initialFocus);
|
|
813
|
+
}
|
|
814
|
+
if (!elementToFocus) {
|
|
815
|
+
elementToFocus = focusableElements[0];
|
|
816
|
+
}
|
|
817
|
+
requestAnimationFrame(() => {
|
|
818
|
+
elementToFocus?.focus({ preventScroll });
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
822
|
+
return () => {
|
|
823
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
824
|
+
const elementToReturn = returnFocusTo ?? previousActiveElementRef.current;
|
|
825
|
+
if (elementToReturn && typeof elementToReturn.focus === "function") {
|
|
826
|
+
elementToReturn.focus({ preventScroll });
|
|
827
|
+
}
|
|
828
|
+
};
|
|
829
|
+
}, [active, initialFocus, returnFocusTo, handleKeyDown, preventScroll]);
|
|
830
|
+
return containerRef;
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
// src/hooks/useEscapeKey.ts
|
|
834
|
+
var React13 = __toESM(require("react"));
|
|
835
|
+
function useEscapeKey(callback, options) {
|
|
836
|
+
const { enabled = true, preventDefault = true, stopPropagation = false } = options ?? {};
|
|
837
|
+
const callbackRef = React13.useRef(callback);
|
|
838
|
+
React13.useEffect(() => {
|
|
839
|
+
callbackRef.current = callback;
|
|
840
|
+
}, [callback]);
|
|
841
|
+
React13.useEffect(() => {
|
|
842
|
+
if (!enabled) return;
|
|
843
|
+
const handleKeyDown = (event) => {
|
|
844
|
+
if (event.key === "Escape") {
|
|
845
|
+
if (preventDefault) {
|
|
846
|
+
event.preventDefault();
|
|
847
|
+
}
|
|
848
|
+
if (stopPropagation) {
|
|
849
|
+
event.stopPropagation();
|
|
850
|
+
}
|
|
851
|
+
callbackRef.current(event);
|
|
852
|
+
}
|
|
853
|
+
};
|
|
854
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
855
|
+
return () => {
|
|
856
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
857
|
+
};
|
|
858
|
+
}, [enabled, preventDefault, stopPropagation]);
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
// src/components/DataPanel.tsx
|
|
754
862
|
var import_data_panel_core = require("@classic-homes/data-panel-core");
|
|
755
863
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
756
864
|
var DropdownTrigger = DropdownMenuPrimitive.Trigger;
|
|
@@ -767,28 +875,28 @@ function useDataPanel(options = {}) {
|
|
|
767
875
|
constraints = {}
|
|
768
876
|
} = options;
|
|
769
877
|
const resolvedConstraints = { ...import_data_panel_core.DEFAULT_CONSTRAINTS, ...constraints };
|
|
770
|
-
const [persistedState] =
|
|
878
|
+
const [persistedState] = React14.useState(() => {
|
|
771
879
|
if (persistKey && typeof window !== "undefined") {
|
|
772
880
|
return (0, import_data_panel_core.loadPanelState)(persistKey);
|
|
773
881
|
}
|
|
774
882
|
return null;
|
|
775
883
|
});
|
|
776
|
-
const [mode, setMode] =
|
|
777
|
-
const [edge, setEdge] =
|
|
778
|
-
const [isExpanded, setIsExpanded] =
|
|
884
|
+
const [mode, setMode] = React14.useState(persistedState?.mode ?? initialMode);
|
|
885
|
+
const [edge, setEdge] = React14.useState(persistedState?.edge ?? initialEdge);
|
|
886
|
+
const [isExpanded, setIsExpanded] = React14.useState(
|
|
779
887
|
persistedState?.isExpanded ?? initialExpanded
|
|
780
888
|
);
|
|
781
|
-
const [detachedPosition, setDetachedPosition] =
|
|
889
|
+
const [detachedPosition, setDetachedPosition] = React14.useState(
|
|
782
890
|
persistedState?.detachedPosition ?? import_data_panel_core.DEFAULT_PANEL_STATE.detachedPosition
|
|
783
891
|
);
|
|
784
|
-
const [detachedSize, setDetachedSize] =
|
|
892
|
+
const [detachedSize, setDetachedSize] = React14.useState(
|
|
785
893
|
persistedState?.detachedSize ?? import_data_panel_core.DEFAULT_PANEL_STATE.detachedSize
|
|
786
894
|
);
|
|
787
|
-
const [pinnedSize, setPinnedSize] =
|
|
895
|
+
const [pinnedSize, setPinnedSize] = React14.useState(
|
|
788
896
|
persistedState?.pinnedSize ?? import_data_panel_core.DEFAULT_PANEL_STATE.pinnedSize
|
|
789
897
|
);
|
|
790
|
-
const saveTimeoutRef =
|
|
791
|
-
const debouncedSave =
|
|
898
|
+
const saveTimeoutRef = React14.useRef(null);
|
|
899
|
+
const debouncedSave = React14.useCallback(() => {
|
|
792
900
|
if (!persistKey) return;
|
|
793
901
|
if (saveTimeoutRef.current) {
|
|
794
902
|
clearTimeout(saveTimeoutRef.current);
|
|
@@ -802,11 +910,12 @@ function useDataPanel(options = {}) {
|
|
|
802
910
|
detachedPosition,
|
|
803
911
|
detachedSize,
|
|
804
912
|
pinnedSize,
|
|
805
|
-
cardSnapIndex: 0
|
|
913
|
+
cardSnapIndex: 0,
|
|
914
|
+
tabOffset: 0
|
|
806
915
|
});
|
|
807
916
|
}, 300);
|
|
808
917
|
}, [persistKey, mode, edge, isExpanded, detachedPosition, detachedSize, pinnedSize]);
|
|
809
|
-
const handleSetMode =
|
|
918
|
+
const handleSetMode = React14.useCallback(
|
|
810
919
|
(newMode) => {
|
|
811
920
|
setMode(newMode);
|
|
812
921
|
if (newMode === "detached" && typeof window !== "undefined" && detachedPosition.x === import_data_panel_core.DEFAULT_PANEL_STATE.detachedPosition.x && detachedPosition.y === import_data_panel_core.DEFAULT_PANEL_STATE.detachedPosition.y) {
|
|
@@ -817,7 +926,7 @@ function useDataPanel(options = {}) {
|
|
|
817
926
|
},
|
|
818
927
|
[detachedPosition, detachedSize]
|
|
819
928
|
);
|
|
820
|
-
const handleSetDetachedPosition =
|
|
929
|
+
const handleSetDetachedPosition = React14.useCallback(
|
|
821
930
|
(position) => {
|
|
822
931
|
if (typeof window === "undefined") {
|
|
823
932
|
setDetachedPosition(position);
|
|
@@ -829,13 +938,13 @@ function useDataPanel(options = {}) {
|
|
|
829
938
|
},
|
|
830
939
|
[detachedSize]
|
|
831
940
|
);
|
|
832
|
-
const handleSetDetachedSize =
|
|
941
|
+
const handleSetDetachedSize = React14.useCallback(
|
|
833
942
|
(size) => {
|
|
834
943
|
setDetachedSize((0, import_data_panel_core.constrainSize)(size, resolvedConstraints));
|
|
835
944
|
},
|
|
836
945
|
[resolvedConstraints]
|
|
837
946
|
);
|
|
838
|
-
const handleSetPinnedSize =
|
|
947
|
+
const handleSetPinnedSize = React14.useCallback(
|
|
839
948
|
(size) => {
|
|
840
949
|
if (typeof window === "undefined") {
|
|
841
950
|
setPinnedSize(size);
|
|
@@ -849,7 +958,7 @@ function useDataPanel(options = {}) {
|
|
|
849
958
|
},
|
|
850
959
|
[edge, resolvedConstraints]
|
|
851
960
|
);
|
|
852
|
-
|
|
961
|
+
React14.useEffect(() => {
|
|
853
962
|
debouncedSave();
|
|
854
963
|
}, [debouncedSave]);
|
|
855
964
|
return {
|
|
@@ -919,13 +1028,31 @@ var CloseIcon = () => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
|
919
1028
|
]
|
|
920
1029
|
}
|
|
921
1030
|
);
|
|
1031
|
+
var GripIcon = () => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
1032
|
+
"svg",
|
|
1033
|
+
{
|
|
1034
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1035
|
+
width: "16",
|
|
1036
|
+
height: "16",
|
|
1037
|
+
viewBox: "0 0 24 24",
|
|
1038
|
+
fill: "currentColor",
|
|
1039
|
+
children: [
|
|
1040
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("circle", { cx: "9", cy: "6", r: "1.5" }),
|
|
1041
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("circle", { cx: "15", cy: "6", r: "1.5" }),
|
|
1042
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("circle", { cx: "9", cy: "12", r: "1.5" }),
|
|
1043
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("circle", { cx: "15", cy: "12", r: "1.5" }),
|
|
1044
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("circle", { cx: "9", cy: "18", r: "1.5" }),
|
|
1045
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("circle", { cx: "15", cy: "18", r: "1.5" })
|
|
1046
|
+
]
|
|
1047
|
+
}
|
|
1048
|
+
);
|
|
922
1049
|
var edgeLabels = {
|
|
923
1050
|
left: "Pin to left",
|
|
924
1051
|
right: "Pin to right",
|
|
925
1052
|
top: "Pin to top",
|
|
926
1053
|
bottom: "Pin to bottom"
|
|
927
1054
|
};
|
|
928
|
-
var DataPanelHeader =
|
|
1055
|
+
var DataPanelHeader = React14.forwardRef(
|
|
929
1056
|
({
|
|
930
1057
|
title,
|
|
931
1058
|
subtitle,
|
|
@@ -965,11 +1092,27 @@ var DataPanelHeader = React13.forwardRef(
|
|
|
965
1092
|
"button",
|
|
966
1093
|
{
|
|
967
1094
|
type: "button",
|
|
968
|
-
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",
|
|
969
|
-
onClick: () =>
|
|
1095
|
+
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",
|
|
1096
|
+
onClick: () => {
|
|
1097
|
+
if (mode === "detached") {
|
|
1098
|
+
onModeChange?.("pinned");
|
|
1099
|
+
onExpandedChange?.(false);
|
|
1100
|
+
} else {
|
|
1101
|
+
onExpandedChange?.(!isExpanded);
|
|
1102
|
+
}
|
|
1103
|
+
},
|
|
970
1104
|
"aria-label": isExpanded ? "Collapse panel" : "Expand panel",
|
|
971
1105
|
"aria-expanded": isExpanded,
|
|
972
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1106
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1107
|
+
"span",
|
|
1108
|
+
{
|
|
1109
|
+
className: cn(
|
|
1110
|
+
"transition-transform",
|
|
1111
|
+
{ top: "", bottom: "rotate-180", left: "-rotate-90", right: "rotate-90" }[edge]
|
|
1112
|
+
),
|
|
1113
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChevronUpIcon, {})
|
|
1114
|
+
}
|
|
1115
|
+
)
|
|
973
1116
|
}
|
|
974
1117
|
),
|
|
975
1118
|
!disableModeSwitch && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(DropdownMenuPrimitive.Root, { children: [
|
|
@@ -977,7 +1120,7 @@ var DataPanelHeader = React13.forwardRef(
|
|
|
977
1120
|
"button",
|
|
978
1121
|
{
|
|
979
1122
|
type: "button",
|
|
980
|
-
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",
|
|
1123
|
+
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",
|
|
981
1124
|
"aria-label": "Panel options",
|
|
982
1125
|
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(MoreVerticalIcon, {})
|
|
983
1126
|
}
|
|
@@ -1025,7 +1168,7 @@ var DataPanelHeader = React13.forwardRef(
|
|
|
1025
1168
|
"button",
|
|
1026
1169
|
{
|
|
1027
1170
|
type: "button",
|
|
1028
|
-
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",
|
|
1171
|
+
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",
|
|
1029
1172
|
onClick: onClose,
|
|
1030
1173
|
"aria-label": "Close panel",
|
|
1031
1174
|
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CloseIcon, {})
|
|
@@ -1038,7 +1181,94 @@ var DataPanelHeader = React13.forwardRef(
|
|
|
1038
1181
|
}
|
|
1039
1182
|
);
|
|
1040
1183
|
DataPanelHeader.displayName = "DataPanelHeader";
|
|
1041
|
-
|
|
1184
|
+
function DataPanelCardHeader({
|
|
1185
|
+
title,
|
|
1186
|
+
subtitle,
|
|
1187
|
+
titleId,
|
|
1188
|
+
isExpanded,
|
|
1189
|
+
isMobile,
|
|
1190
|
+
showDragHandle,
|
|
1191
|
+
headerContent,
|
|
1192
|
+
headerActions,
|
|
1193
|
+
disableClose = false,
|
|
1194
|
+
onHeaderPointerDown,
|
|
1195
|
+
onToggleExpand,
|
|
1196
|
+
onClose
|
|
1197
|
+
}) {
|
|
1198
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
1199
|
+
"div",
|
|
1200
|
+
{
|
|
1201
|
+
"data-panel-header": true,
|
|
1202
|
+
className: "relative flex items-center justify-between gap-2 border-b border-border bg-muted/30 px-4 pt-5 pb-3 cursor-pointer",
|
|
1203
|
+
onPointerDown: onHeaderPointerDown,
|
|
1204
|
+
children: [
|
|
1205
|
+
showDragHandle && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1206
|
+
"div",
|
|
1207
|
+
{
|
|
1208
|
+
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",
|
|
1209
|
+
role: "button",
|
|
1210
|
+
tabIndex: 0,
|
|
1211
|
+
"aria-label": isExpanded ? "Collapse panel" : "Expand panel",
|
|
1212
|
+
"aria-expanded": isExpanded,
|
|
1213
|
+
onPointerDown: onHeaderPointerDown,
|
|
1214
|
+
onKeyDown: (e) => (e.key === "Enter" || e.key === " ") && onToggleExpand()
|
|
1215
|
+
}
|
|
1216
|
+
),
|
|
1217
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1218
|
+
"div",
|
|
1219
|
+
{
|
|
1220
|
+
className: "flex-1 min-w-0",
|
|
1221
|
+
role: "button",
|
|
1222
|
+
tabIndex: 0,
|
|
1223
|
+
onKeyDown: (e) => (e.key === "Enter" || e.key === " ") && onToggleExpand(),
|
|
1224
|
+
children: headerContent ? headerContent : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
1225
|
+
subtitle && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "text-sm text-muted-foreground truncate", children: subtitle }),
|
|
1226
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h3", { id: titleId, className: "text-lg font-semibold truncate", children: title })
|
|
1227
|
+
] })
|
|
1228
|
+
}
|
|
1229
|
+
),
|
|
1230
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center gap-1 shrink-0", children: [
|
|
1231
|
+
headerActions,
|
|
1232
|
+
!isMobile && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1233
|
+
"button",
|
|
1234
|
+
{
|
|
1235
|
+
"data-card-drag-handle": true,
|
|
1236
|
+
type: "button",
|
|
1237
|
+
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",
|
|
1238
|
+
"aria-label": "Drag to reposition panel",
|
|
1239
|
+
title: "Drag to move",
|
|
1240
|
+
onPointerDown: onHeaderPointerDown,
|
|
1241
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(GripIcon, {})
|
|
1242
|
+
}
|
|
1243
|
+
),
|
|
1244
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1245
|
+
"button",
|
|
1246
|
+
{
|
|
1247
|
+
type: "button",
|
|
1248
|
+
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",
|
|
1249
|
+
onClick: onToggleExpand,
|
|
1250
|
+
"aria-expanded": isExpanded,
|
|
1251
|
+
"aria-label": isExpanded ? "Collapse panel" : "Expand panel",
|
|
1252
|
+
title: isExpanded ? "Collapse" : "Expand",
|
|
1253
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: cn("inline-flex transition-transform", isExpanded && "rotate-180"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChevronUpIcon, {}) })
|
|
1254
|
+
}
|
|
1255
|
+
),
|
|
1256
|
+
!disableClose && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1257
|
+
"button",
|
|
1258
|
+
{
|
|
1259
|
+
type: "button",
|
|
1260
|
+
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",
|
|
1261
|
+
onClick: onClose,
|
|
1262
|
+
"aria-label": "Close panel",
|
|
1263
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CloseIcon, {})
|
|
1264
|
+
}
|
|
1265
|
+
)
|
|
1266
|
+
] })
|
|
1267
|
+
]
|
|
1268
|
+
}
|
|
1269
|
+
);
|
|
1270
|
+
}
|
|
1271
|
+
var DataPanelContent = React14.forwardRef(
|
|
1042
1272
|
({ children, className, "aria-label": ariaLabel = "Panel content" }, ref) => {
|
|
1043
1273
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1044
1274
|
"div",
|
|
@@ -1053,7 +1283,7 @@ var DataPanelContent = React13.forwardRef(
|
|
|
1053
1283
|
}
|
|
1054
1284
|
);
|
|
1055
1285
|
DataPanelContent.displayName = "DataPanelContent";
|
|
1056
|
-
var DataPanelFooter =
|
|
1286
|
+
var DataPanelFooter = React14.forwardRef(
|
|
1057
1287
|
({ actions = [], footerContent, footerActions, className }, ref) => {
|
|
1058
1288
|
if (!footerContent && actions.length === 0 && !footerActions) {
|
|
1059
1289
|
return null;
|
|
@@ -1089,37 +1319,180 @@ var DataPanelFooter = React13.forwardRef(
|
|
|
1089
1319
|
}
|
|
1090
1320
|
);
|
|
1091
1321
|
DataPanelFooter.displayName = "DataPanelFooter";
|
|
1092
|
-
var DataPanelTab =
|
|
1093
|
-
({
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1322
|
+
var DataPanelTab = React14.forwardRef(
|
|
1323
|
+
({
|
|
1324
|
+
title = "Panel",
|
|
1325
|
+
subtitle,
|
|
1326
|
+
edge,
|
|
1327
|
+
onClick,
|
|
1328
|
+
onClose,
|
|
1329
|
+
disableClose = false,
|
|
1330
|
+
offset = 0,
|
|
1331
|
+
onOffsetChange,
|
|
1332
|
+
className
|
|
1333
|
+
}, ref) => {
|
|
1100
1334
|
const isVertical = edge === "left" || edge === "right";
|
|
1101
|
-
const
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1335
|
+
const positionClasses = {
|
|
1336
|
+
// Side tabs are the whole chip rotated 90°, so they need a fixed thickness
|
|
1337
|
+
// (h-14 → 56px) for a deterministic edge hug; see tabTransform below. Border
|
|
1338
|
+
// classes are in the chip's pre-rotation frame: its bottom rotates to the
|
|
1339
|
+
// attached (edge) side and its top corners to the viewport-facing corners,
|
|
1340
|
+
// so both edges drop the bottom border and round the top.
|
|
1341
|
+
left: "left-0 top-1/2 h-14 rounded-t-lg border-b-0",
|
|
1342
|
+
right: "right-0 top-1/2 h-14 rounded-t-lg border-b-0",
|
|
1343
|
+
top: "top-0 left-1/2 rounded-b-lg border-t-0",
|
|
1344
|
+
bottom: "bottom-0 left-1/2 rounded-t-lg border-b-0"
|
|
1106
1345
|
}[edge];
|
|
1346
|
+
const innerRef = React14.useRef(null);
|
|
1347
|
+
const dragRef = React14.useRef({
|
|
1348
|
+
startX: 0,
|
|
1349
|
+
startY: 0,
|
|
1350
|
+
startOffset: 0,
|
|
1351
|
+
moved: false,
|
|
1352
|
+
pointerId: -1
|
|
1353
|
+
});
|
|
1354
|
+
const [dragOffset, setDragOffset] = React14.useState(null);
|
|
1355
|
+
const effectiveOffset = dragOffset ?? offset;
|
|
1356
|
+
const draggable = !!onOffsetChange;
|
|
1357
|
+
const SIDE_HALF = 28;
|
|
1358
|
+
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))`;
|
|
1359
|
+
const setRefs = (node) => {
|
|
1360
|
+
innerRef.current = node;
|
|
1361
|
+
if (typeof ref === "function") ref(node);
|
|
1362
|
+
else if (ref) ref.current = node;
|
|
1363
|
+
};
|
|
1364
|
+
const handlePointerDown = (e) => {
|
|
1365
|
+
if (!draggable) return;
|
|
1366
|
+
if (e.pointerType === "mouse" && e.button !== 0) return;
|
|
1367
|
+
if (e.target.closest("[data-no-drag]")) return;
|
|
1368
|
+
dragRef.current = {
|
|
1369
|
+
startX: e.clientX,
|
|
1370
|
+
startY: e.clientY,
|
|
1371
|
+
startOffset: offset,
|
|
1372
|
+
moved: false,
|
|
1373
|
+
pointerId: e.pointerId
|
|
1374
|
+
};
|
|
1375
|
+
setDragOffset(offset);
|
|
1376
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
1377
|
+
};
|
|
1378
|
+
const handlePointerMove = (e) => {
|
|
1379
|
+
const d = dragRef.current;
|
|
1380
|
+
if (d.pointerId !== e.pointerId || !e.currentTarget.hasPointerCapture(e.pointerId)) return;
|
|
1381
|
+
const delta = isVertical ? e.clientY - d.startY : e.clientX - d.startX;
|
|
1382
|
+
if (Math.abs(delta) > 3) d.moved = true;
|
|
1383
|
+
const rect = innerRef.current?.getBoundingClientRect();
|
|
1384
|
+
const tabSize = { width: rect?.width ?? 160, height: rect?.height ?? 48 };
|
|
1385
|
+
setDragOffset(
|
|
1386
|
+
(0, import_data_panel_core.constrainTabOffset)(
|
|
1387
|
+
d.startOffset + delta,
|
|
1388
|
+
edge,
|
|
1389
|
+
tabSize,
|
|
1390
|
+
window.innerWidth,
|
|
1391
|
+
window.innerHeight
|
|
1392
|
+
)
|
|
1393
|
+
);
|
|
1394
|
+
};
|
|
1395
|
+
const handlePointerUp = (e) => {
|
|
1396
|
+
const d = dragRef.current;
|
|
1397
|
+
if (d.pointerId !== e.pointerId) return;
|
|
1398
|
+
if (e.currentTarget.hasPointerCapture(e.pointerId)) {
|
|
1399
|
+
e.currentTarget.releasePointerCapture(e.pointerId);
|
|
1400
|
+
}
|
|
1401
|
+
d.pointerId = -1;
|
|
1402
|
+
if (d.moved) {
|
|
1403
|
+
onOffsetChange?.(dragOffset ?? offset);
|
|
1404
|
+
} else {
|
|
1405
|
+
onClick?.();
|
|
1406
|
+
}
|
|
1407
|
+
setDragOffset(null);
|
|
1408
|
+
};
|
|
1409
|
+
const handlePointerCancel = (e) => {
|
|
1410
|
+
const d = dragRef.current;
|
|
1411
|
+
if (d.pointerId !== e.pointerId) return;
|
|
1412
|
+
if (e.currentTarget.hasPointerCapture(e.pointerId)) {
|
|
1413
|
+
e.currentTarget.releasePointerCapture(e.pointerId);
|
|
1414
|
+
}
|
|
1415
|
+
d.pointerId = -1;
|
|
1416
|
+
d.moved = false;
|
|
1417
|
+
setDragOffset(null);
|
|
1418
|
+
};
|
|
1419
|
+
const handleExpandKeyDown = (e) => {
|
|
1420
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
1421
|
+
e.preventDefault();
|
|
1422
|
+
onClick?.();
|
|
1423
|
+
}
|
|
1424
|
+
};
|
|
1425
|
+
React14.useEffect(() => {
|
|
1426
|
+
if (!onOffsetChange || dragOffset !== null) return;
|
|
1427
|
+
const rect = innerRef.current?.getBoundingClientRect();
|
|
1428
|
+
if (!rect) return;
|
|
1429
|
+
const clamped = (0, import_data_panel_core.constrainTabOffset)(
|
|
1430
|
+
offset,
|
|
1431
|
+
edge,
|
|
1432
|
+
{ width: rect.width, height: rect.height },
|
|
1433
|
+
window.innerWidth,
|
|
1434
|
+
window.innerHeight
|
|
1435
|
+
);
|
|
1436
|
+
if (clamped !== offset) onOffsetChange(clamped);
|
|
1437
|
+
const onResize = () => {
|
|
1438
|
+
const r = innerRef.current?.getBoundingClientRect();
|
|
1439
|
+
if (!r) return;
|
|
1440
|
+
const c = (0, import_data_panel_core.constrainTabOffset)(
|
|
1441
|
+
offset,
|
|
1442
|
+
edge,
|
|
1443
|
+
{ width: r.width, height: r.height },
|
|
1444
|
+
window.innerWidth,
|
|
1445
|
+
window.innerHeight
|
|
1446
|
+
);
|
|
1447
|
+
if (c !== offset) onOffsetChange(c);
|
|
1448
|
+
};
|
|
1449
|
+
window.addEventListener("resize", onResize);
|
|
1450
|
+
return () => window.removeEventListener("resize", onResize);
|
|
1451
|
+
}, [edge, offset, onOffsetChange, dragOffset]);
|
|
1107
1452
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
1108
|
-
"
|
|
1453
|
+
"div",
|
|
1109
1454
|
{
|
|
1110
|
-
ref,
|
|
1111
|
-
type: "button",
|
|
1455
|
+
ref: setRefs,
|
|
1112
1456
|
className: cn(
|
|
1113
|
-
"fixed z-40 flex
|
|
1457
|
+
"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",
|
|
1458
|
+
draggable && "cursor-grab touch-none active:cursor-grabbing",
|
|
1114
1459
|
positionClasses,
|
|
1115
|
-
isVertical && "[writing-mode:vertical-rl]",
|
|
1116
1460
|
className
|
|
1117
1461
|
),
|
|
1118
|
-
|
|
1119
|
-
|
|
1462
|
+
style: { transform: tabTransform },
|
|
1463
|
+
onPointerDown: handlePointerDown,
|
|
1464
|
+
onPointerMove: draggable ? handlePointerMove : void 0,
|
|
1465
|
+
onPointerUp: draggable ? handlePointerUp : void 0,
|
|
1466
|
+
onPointerCancel: draggable ? handlePointerCancel : void 0,
|
|
1120
1467
|
children: [
|
|
1121
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.
|
|
1122
|
-
|
|
1468
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
1469
|
+
"button",
|
|
1470
|
+
{
|
|
1471
|
+
type: "button",
|
|
1472
|
+
"aria-label": `Expand ${title} panel`,
|
|
1473
|
+
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",
|
|
1474
|
+
onClick: draggable ? void 0 : onClick,
|
|
1475
|
+
onKeyDown: handleExpandKeyDown,
|
|
1476
|
+
children: [
|
|
1477
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "truncate text-sm font-semibold", children: title }),
|
|
1478
|
+
subtitle && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "truncate text-xs text-muted-foreground", children: subtitle })
|
|
1479
|
+
]
|
|
1480
|
+
}
|
|
1481
|
+
),
|
|
1482
|
+
!disableClose && onClose && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1483
|
+
"button",
|
|
1484
|
+
{
|
|
1485
|
+
"data-no-drag": true,
|
|
1486
|
+
type: "button",
|
|
1487
|
+
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",
|
|
1488
|
+
"aria-label": "Close panel",
|
|
1489
|
+
onClick: (e) => {
|
|
1490
|
+
e.stopPropagation();
|
|
1491
|
+
onClose();
|
|
1492
|
+
},
|
|
1493
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CloseIcon, {})
|
|
1494
|
+
}
|
|
1495
|
+
)
|
|
1123
1496
|
]
|
|
1124
1497
|
}
|
|
1125
1498
|
);
|
|
@@ -1131,64 +1504,78 @@ var KEYBOARD_RESIZE_STEP_LARGE = 50;
|
|
|
1131
1504
|
function ResizeHandles({
|
|
1132
1505
|
mode,
|
|
1133
1506
|
edge,
|
|
1507
|
+
detachedPosition,
|
|
1134
1508
|
detachedSize,
|
|
1135
1509
|
pinnedSize,
|
|
1136
1510
|
onResizeStart,
|
|
1137
|
-
|
|
1511
|
+
onDetachedResize,
|
|
1138
1512
|
onPinnedSizeChange,
|
|
1139
1513
|
constraints
|
|
1140
1514
|
}) {
|
|
1141
|
-
const handleDetachedKeyDown =
|
|
1515
|
+
const handleDetachedKeyDown = React14.useCallback(
|
|
1142
1516
|
(e, handle) => {
|
|
1143
1517
|
const step = e.shiftKey ? KEYBOARD_RESIZE_STEP_LARGE : KEYBOARD_RESIZE_STEP;
|
|
1144
|
-
let
|
|
1518
|
+
let width = detachedSize.width;
|
|
1519
|
+
let height = detachedSize.height;
|
|
1145
1520
|
let handled = false;
|
|
1146
1521
|
switch (e.key) {
|
|
1147
1522
|
case "ArrowUp":
|
|
1148
1523
|
if (handle.includes("top")) {
|
|
1149
|
-
|
|
1524
|
+
height += step;
|
|
1150
1525
|
handled = true;
|
|
1151
1526
|
} else if (handle.includes("bottom")) {
|
|
1152
|
-
|
|
1527
|
+
height -= step;
|
|
1153
1528
|
handled = true;
|
|
1154
1529
|
}
|
|
1155
1530
|
break;
|
|
1156
1531
|
case "ArrowDown":
|
|
1157
1532
|
if (handle.includes("top")) {
|
|
1158
|
-
|
|
1533
|
+
height -= step;
|
|
1159
1534
|
handled = true;
|
|
1160
1535
|
} else if (handle.includes("bottom")) {
|
|
1161
|
-
|
|
1536
|
+
height += step;
|
|
1162
1537
|
handled = true;
|
|
1163
1538
|
}
|
|
1164
1539
|
break;
|
|
1165
1540
|
case "ArrowLeft":
|
|
1166
1541
|
if (handle.includes("left")) {
|
|
1167
|
-
|
|
1542
|
+
width += step;
|
|
1168
1543
|
handled = true;
|
|
1169
1544
|
} else if (handle.includes("right")) {
|
|
1170
|
-
|
|
1545
|
+
width -= step;
|
|
1171
1546
|
handled = true;
|
|
1172
1547
|
}
|
|
1173
1548
|
break;
|
|
1174
1549
|
case "ArrowRight":
|
|
1175
1550
|
if (handle.includes("left")) {
|
|
1176
|
-
|
|
1551
|
+
width -= step;
|
|
1177
1552
|
handled = true;
|
|
1178
1553
|
} else if (handle.includes("right")) {
|
|
1179
|
-
|
|
1554
|
+
width += step;
|
|
1180
1555
|
handled = true;
|
|
1181
1556
|
}
|
|
1182
1557
|
break;
|
|
1183
1558
|
}
|
|
1184
1559
|
if (handled) {
|
|
1185
1560
|
e.preventDefault();
|
|
1186
|
-
|
|
1561
|
+
const candidatePosition = {
|
|
1562
|
+
x: handle.includes("left") ? detachedPosition.x + (detachedSize.width - width) : detachedPosition.x,
|
|
1563
|
+
y: handle.includes("top") ? detachedPosition.y + (detachedSize.height - height) : detachedPosition.y
|
|
1564
|
+
};
|
|
1565
|
+
const { position, size } = (0, import_data_panel_core.constrainResize)(
|
|
1566
|
+
candidatePosition,
|
|
1567
|
+
{ width, height },
|
|
1568
|
+
constraints,
|
|
1569
|
+
typeof window === "undefined" ? 1024 : window.innerWidth,
|
|
1570
|
+
typeof window === "undefined" ? 768 : window.innerHeight,
|
|
1571
|
+
handle
|
|
1572
|
+
);
|
|
1573
|
+
onDetachedResize(position, size);
|
|
1187
1574
|
}
|
|
1188
1575
|
},
|
|
1189
|
-
[detachedSize, constraints,
|
|
1576
|
+
[detachedPosition, detachedSize, constraints, onDetachedResize]
|
|
1190
1577
|
);
|
|
1191
|
-
const handlePinnedKeyDown =
|
|
1578
|
+
const handlePinnedKeyDown = React14.useCallback(
|
|
1192
1579
|
(e) => {
|
|
1193
1580
|
const step = e.shiftKey ? KEYBOARD_RESIZE_STEP_LARGE : KEYBOARD_RESIZE_STEP;
|
|
1194
1581
|
let newSize = pinnedSize;
|
|
@@ -1305,12 +1692,14 @@ function ResizeHandles({
|
|
|
1305
1692
|
}
|
|
1306
1693
|
);
|
|
1307
1694
|
}
|
|
1308
|
-
var DataPanel =
|
|
1695
|
+
var DataPanel = React14.forwardRef(
|
|
1309
1696
|
({
|
|
1310
1697
|
open: controlledOpen,
|
|
1311
1698
|
onOpenChange,
|
|
1312
1699
|
mode: controlledMode,
|
|
1313
1700
|
onModeChange,
|
|
1701
|
+
variant: controlledVariant,
|
|
1702
|
+
cardConfig = {},
|
|
1314
1703
|
edge: controlledEdge,
|
|
1315
1704
|
onEdgeChange,
|
|
1316
1705
|
expanded: controlledExpanded,
|
|
@@ -1333,84 +1722,151 @@ var DataPanel = React13.forwardRef(
|
|
|
1333
1722
|
footerActions,
|
|
1334
1723
|
className
|
|
1335
1724
|
}, ref) => {
|
|
1336
|
-
const resolvedConstraints =
|
|
1337
|
-
|
|
1725
|
+
const resolvedConstraints = React14.useMemo(
|
|
1726
|
+
() => ({ ...import_data_panel_core.DEFAULT_CONSTRAINTS, ...constraints }),
|
|
1727
|
+
[constraints]
|
|
1728
|
+
);
|
|
1729
|
+
const resolvedCardConfig = React14.useMemo(
|
|
1730
|
+
() => ({ ...import_data_panel_core.DEFAULT_CARD_CONFIG, ...cardConfig }),
|
|
1731
|
+
[cardConfig]
|
|
1732
|
+
);
|
|
1733
|
+
const panelId = React14.useId();
|
|
1338
1734
|
const titleId = `${panelId}-title`;
|
|
1339
|
-
const [internalOpen, setInternalOpen] =
|
|
1340
|
-
const [internalMode, setInternalMode] =
|
|
1341
|
-
const [
|
|
1342
|
-
|
|
1735
|
+
const [internalOpen, setInternalOpen] = React14.useState(true);
|
|
1736
|
+
const [internalMode, setInternalMode] = React14.useState(import_data_panel_core.DEFAULT_PANEL_STATE.mode);
|
|
1737
|
+
const [internalVariant, setInternalVariant] = React14.useState(
|
|
1738
|
+
import_data_panel_core.DEFAULT_PANEL_STATE.variant
|
|
1739
|
+
);
|
|
1740
|
+
const [internalEdge, setInternalEdge] = React14.useState(import_data_panel_core.DEFAULT_PANEL_STATE.edge);
|
|
1741
|
+
const [internalExpanded, setInternalExpanded] = React14.useState(
|
|
1343
1742
|
import_data_panel_core.DEFAULT_PANEL_STATE.isExpanded
|
|
1344
1743
|
);
|
|
1345
|
-
const [detachedPosition, setDetachedPosition] =
|
|
1744
|
+
const [detachedPosition, setDetachedPosition] = React14.useState(
|
|
1346
1745
|
import_data_panel_core.DEFAULT_PANEL_STATE.detachedPosition
|
|
1347
1746
|
);
|
|
1348
|
-
const [detachedSize, setDetachedSize] =
|
|
1349
|
-
const [pinnedSize, setPinnedSize] =
|
|
1350
|
-
const [
|
|
1351
|
-
const [
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
const [
|
|
1355
|
-
|
|
1747
|
+
const [detachedSize, setDetachedSize] = React14.useState(import_data_panel_core.DEFAULT_PANEL_STATE.detachedSize);
|
|
1748
|
+
const [pinnedSize, setPinnedSize] = React14.useState(import_data_panel_core.DEFAULT_PANEL_STATE.pinnedSize);
|
|
1749
|
+
const [tabOffset, setTabOffset] = React14.useState(import_data_panel_core.DEFAULT_PANEL_STATE.tabOffset);
|
|
1750
|
+
const [viewportWidth, setViewportWidth] = React14.useState(
|
|
1751
|
+
typeof window !== "undefined" ? window.innerWidth : 1024
|
|
1752
|
+
);
|
|
1753
|
+
const [viewportHeight, setViewportHeight] = React14.useState(
|
|
1754
|
+
typeof window !== "undefined" ? window.innerHeight : 768
|
|
1755
|
+
);
|
|
1756
|
+
const isMobile = viewportWidth < 640;
|
|
1757
|
+
const [cardHorizontalPosition, setCardHorizontalPosition] = React14.useState(0);
|
|
1758
|
+
const [cardExpandedHeight, setCardExpandedHeight] = React14.useState(0);
|
|
1759
|
+
const [cardWidth, setCardWidth] = React14.useState(null);
|
|
1760
|
+
const [cardDragCurrentHeight, setCardDragCurrentHeight] = React14.useState(import_data_panel_core.CARD_HEADER_HEIGHT);
|
|
1761
|
+
const [isCardVerticalDragging, setIsCardVerticalDragging] = React14.useState(false);
|
|
1762
|
+
const [isCardHorizontalDragging, setIsCardHorizontalDragging] = React14.useState(false);
|
|
1763
|
+
const [isCardHeightTransitioning, setIsCardHeightTransitioning] = React14.useState(false);
|
|
1764
|
+
const [isCardWidthResizing, setIsCardWidthResizing] = React14.useState(false);
|
|
1765
|
+
const [isCardTopResizing, setIsCardTopResizing] = React14.useState(false);
|
|
1766
|
+
const [isDragging, setIsDragging] = React14.useState(false);
|
|
1767
|
+
const [isResizing, setIsResizing] = React14.useState(false);
|
|
1768
|
+
const [snapPreview, setSnapPreview] = React14.useState(null);
|
|
1769
|
+
const [isPinnedDragging, setIsPinnedDragging] = React14.useState(false);
|
|
1770
|
+
const [pullOffset, setPullOffset] = React14.useState(0);
|
|
1771
|
+
const dragStateRef = React14.useRef({
|
|
1356
1772
|
startPosition: { x: 0, y: 0 },
|
|
1357
1773
|
startPanelPosition: { x: 0, y: 0 }
|
|
1358
1774
|
});
|
|
1359
|
-
const pinnedDragStateRef =
|
|
1775
|
+
const pinnedDragStateRef = React14.useRef({
|
|
1360
1776
|
startPosition: { x: 0, y: 0 },
|
|
1361
1777
|
hasDetached: false
|
|
1362
1778
|
});
|
|
1363
|
-
const resizeStateRef =
|
|
1779
|
+
const resizeStateRef = React14.useRef({
|
|
1364
1780
|
handle: null,
|
|
1365
1781
|
startPosition: { x: 0, y: 0 },
|
|
1366
1782
|
startSize: { width: 0, height: 0 },
|
|
1367
1783
|
startPanelPosition: { x: 0, y: 0 }
|
|
1368
1784
|
});
|
|
1785
|
+
const cardDragStateRef = React14.useRef({
|
|
1786
|
+
startY: 0,
|
|
1787
|
+
startX: 0,
|
|
1788
|
+
startTime: 0,
|
|
1789
|
+
startExpanded: false,
|
|
1790
|
+
startHorizontalPosition: 0
|
|
1791
|
+
});
|
|
1792
|
+
const cardCurrentHeightRef = React14.useRef(import_data_panel_core.CARD_HEADER_HEIGHT);
|
|
1793
|
+
const cardTopResizeStartRef = React14.useRef({ startY: 0, startHeight: 0 });
|
|
1794
|
+
const cardWidthResizeStateRef = React14.useRef({
|
|
1795
|
+
handle: null,
|
|
1796
|
+
startX: 0,
|
|
1797
|
+
startWidth: 0,
|
|
1798
|
+
startLeft: 0
|
|
1799
|
+
});
|
|
1369
1800
|
const open = controlledOpen ?? internalOpen;
|
|
1370
1801
|
const mode = controlledMode ?? internalMode;
|
|
1802
|
+
const variant = controlledVariant ?? internalVariant;
|
|
1371
1803
|
const edge = controlledEdge ?? internalEdge;
|
|
1372
1804
|
const isExpanded = controlledExpanded ?? internalExpanded;
|
|
1373
|
-
const
|
|
1374
|
-
const
|
|
1805
|
+
const showContent = variant !== "card" || isExpanded || isCardVerticalDragging;
|
|
1806
|
+
const saveTimeoutRef = React14.useRef(null);
|
|
1807
|
+
const isMountedRef = React14.useRef(true);
|
|
1808
|
+
React14.useEffect(() => {
|
|
1809
|
+
isMountedRef.current = true;
|
|
1810
|
+
return () => {
|
|
1811
|
+
isMountedRef.current = false;
|
|
1812
|
+
if (saveTimeoutRef.current) clearTimeout(saveTimeoutRef.current);
|
|
1813
|
+
if (typeof document !== "undefined") {
|
|
1814
|
+
document.body.style.cursor = "";
|
|
1815
|
+
document.body.style.userSelect = "";
|
|
1816
|
+
}
|
|
1817
|
+
};
|
|
1818
|
+
}, []);
|
|
1819
|
+
const debouncedSave = React14.useCallback(() => {
|
|
1375
1820
|
if (!persistKey) return;
|
|
1376
1821
|
if (saveTimeoutRef.current) {
|
|
1377
1822
|
clearTimeout(saveTimeoutRef.current);
|
|
1378
1823
|
}
|
|
1379
1824
|
saveTimeoutRef.current = setTimeout(() => {
|
|
1380
1825
|
(0, import_data_panel_core.savePanelState)(persistKey, {
|
|
1381
|
-
mode
|
|
1382
|
-
variant
|
|
1383
|
-
edge
|
|
1384
|
-
isExpanded
|
|
1826
|
+
mode,
|
|
1827
|
+
variant,
|
|
1828
|
+
edge,
|
|
1829
|
+
isExpanded,
|
|
1385
1830
|
detachedPosition,
|
|
1386
1831
|
detachedSize,
|
|
1387
1832
|
pinnedSize,
|
|
1388
|
-
cardSnapIndex: 0
|
|
1833
|
+
cardSnapIndex: 0,
|
|
1834
|
+
tabOffset
|
|
1389
1835
|
});
|
|
1390
1836
|
}, 300);
|
|
1391
1837
|
}, [
|
|
1392
1838
|
persistKey,
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1839
|
+
mode,
|
|
1840
|
+
variant,
|
|
1841
|
+
edge,
|
|
1842
|
+
isExpanded,
|
|
1396
1843
|
detachedPosition,
|
|
1397
1844
|
detachedSize,
|
|
1398
|
-
pinnedSize
|
|
1845
|
+
pinnedSize,
|
|
1846
|
+
tabOffset
|
|
1399
1847
|
]);
|
|
1400
|
-
|
|
1401
|
-
|
|
1848
|
+
React14.useEffect(() => {
|
|
1849
|
+
debouncedSave();
|
|
1850
|
+
}, [debouncedSave]);
|
|
1851
|
+
const hasLoadedRef = React14.useRef(false);
|
|
1852
|
+
React14.useEffect(() => {
|
|
1853
|
+
if (!persistKey || hasLoadedRef.current) return;
|
|
1854
|
+
hasLoadedRef.current = true;
|
|
1402
1855
|
const persisted = (0, import_data_panel_core.loadPanelState)(persistKey);
|
|
1403
1856
|
if (persisted) {
|
|
1404
1857
|
if (controlledMode === void 0 && persisted.mode) setInternalMode(persisted.mode);
|
|
1858
|
+
if (controlledVariant === void 0 && persisted.variant)
|
|
1859
|
+
setInternalVariant(persisted.variant);
|
|
1405
1860
|
if (controlledEdge === void 0 && persisted.edge) setInternalEdge(persisted.edge);
|
|
1406
1861
|
if (controlledExpanded === void 0 && persisted.isExpanded !== void 0)
|
|
1407
1862
|
setInternalExpanded(persisted.isExpanded);
|
|
1408
1863
|
if (persisted.detachedPosition) setDetachedPosition(persisted.detachedPosition);
|
|
1409
1864
|
if (persisted.detachedSize) setDetachedSize(persisted.detachedSize);
|
|
1410
1865
|
if (persisted.pinnedSize) setPinnedSize(persisted.pinnedSize);
|
|
1866
|
+
if (persisted.tabOffset !== void 0) setTabOffset(persisted.tabOffset);
|
|
1411
1867
|
}
|
|
1412
|
-
}, [persistKey, controlledMode, controlledEdge, controlledExpanded]);
|
|
1413
|
-
|
|
1868
|
+
}, [persistKey, controlledMode, controlledVariant, controlledEdge, controlledExpanded]);
|
|
1869
|
+
React14.useEffect(() => {
|
|
1414
1870
|
if (mode === "detached" && detachedPosition.x === import_data_panel_core.DEFAULT_PANEL_STATE.detachedPosition.x && detachedPosition.y === import_data_panel_core.DEFAULT_PANEL_STATE.detachedPosition.y) {
|
|
1415
1871
|
setDetachedPosition(
|
|
1416
1872
|
(0, import_data_panel_core.getInitialDetachedPosition)(detachedSize, window.innerWidth, window.innerHeight)
|
|
@@ -1423,27 +1879,50 @@ var DataPanel = React13.forwardRef(
|
|
|
1423
1879
|
}
|
|
1424
1880
|
onOpenChange?.(newOpen);
|
|
1425
1881
|
};
|
|
1426
|
-
const
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
const handleExpandedChange = (newExpanded) => {
|
|
1441
|
-
if (controlledExpanded === void 0) {
|
|
1442
|
-
setInternalExpanded(newExpanded);
|
|
1882
|
+
const isDialog = open && (mode === "detached" || variant === "card" && isExpanded && isMobile);
|
|
1883
|
+
const focusTrapRef = useFocusTrap({ active: isDialog });
|
|
1884
|
+
useEscapeKey(
|
|
1885
|
+
() => {
|
|
1886
|
+
if (!disableClose) handleOpenChange(false);
|
|
1887
|
+
},
|
|
1888
|
+
{ enabled: isDialog }
|
|
1889
|
+
);
|
|
1890
|
+
const setPanelRef = (node) => {
|
|
1891
|
+
focusTrapRef.current = node;
|
|
1892
|
+
if (typeof ref === "function") {
|
|
1893
|
+
ref(node);
|
|
1894
|
+
} else if (ref) {
|
|
1895
|
+
ref.current = node;
|
|
1443
1896
|
}
|
|
1444
|
-
onExpandedChange?.(newExpanded);
|
|
1445
|
-
debouncedSave();
|
|
1446
1897
|
};
|
|
1898
|
+
const handleModeChange = React14.useCallback(
|
|
1899
|
+
(newMode) => {
|
|
1900
|
+
if (controlledMode === void 0) {
|
|
1901
|
+
setInternalMode(newMode);
|
|
1902
|
+
}
|
|
1903
|
+
onModeChange?.(newMode);
|
|
1904
|
+
},
|
|
1905
|
+
[controlledMode, onModeChange]
|
|
1906
|
+
);
|
|
1907
|
+
const handleEdgeChange = React14.useCallback(
|
|
1908
|
+
(newEdge) => {
|
|
1909
|
+
if (controlledEdge === void 0) {
|
|
1910
|
+
setInternalEdge(newEdge);
|
|
1911
|
+
}
|
|
1912
|
+
onEdgeChange?.(newEdge);
|
|
1913
|
+
},
|
|
1914
|
+
[controlledEdge, onEdgeChange]
|
|
1915
|
+
);
|
|
1916
|
+
const handleExpandedChange = React14.useCallback(
|
|
1917
|
+
(newExpanded) => {
|
|
1918
|
+
if (controlledExpanded === void 0) {
|
|
1919
|
+
setInternalExpanded(newExpanded);
|
|
1920
|
+
}
|
|
1921
|
+
onExpandedChange?.(newExpanded);
|
|
1922
|
+
},
|
|
1923
|
+
[controlledExpanded, onExpandedChange]
|
|
1924
|
+
);
|
|
1925
|
+
const handleToggleExpand = () => handleExpandedChange(!isExpanded);
|
|
1447
1926
|
const handleDragStart = (e) => {
|
|
1448
1927
|
if (disableDrag) return;
|
|
1449
1928
|
const target = e.target;
|
|
@@ -1468,7 +1947,7 @@ var DataPanel = React13.forwardRef(
|
|
|
1468
1947
|
document.body.style.userSelect = "none";
|
|
1469
1948
|
}
|
|
1470
1949
|
};
|
|
1471
|
-
const handleDragMove =
|
|
1950
|
+
const handleDragMove = React14.useCallback(
|
|
1472
1951
|
(e) => {
|
|
1473
1952
|
if (!isDragging) return;
|
|
1474
1953
|
const currentPos = (0, import_data_panel_core.getPointerPosition)(e);
|
|
@@ -1495,7 +1974,7 @@ var DataPanel = React13.forwardRef(
|
|
|
1495
1974
|
},
|
|
1496
1975
|
[isDragging, detachedSize, snapThreshold]
|
|
1497
1976
|
);
|
|
1498
|
-
const handleDragEnd =
|
|
1977
|
+
const handleDragEnd = React14.useCallback(() => {
|
|
1499
1978
|
if (!isDragging) return;
|
|
1500
1979
|
setIsDragging(false);
|
|
1501
1980
|
document.body.style.cursor = "";
|
|
@@ -1504,11 +1983,9 @@ var DataPanel = React13.forwardRef(
|
|
|
1504
1983
|
handleModeChange("pinned");
|
|
1505
1984
|
handleEdgeChange(snapPreview);
|
|
1506
1985
|
setSnapPreview(null);
|
|
1507
|
-
} else {
|
|
1508
|
-
debouncedSave();
|
|
1509
1986
|
}
|
|
1510
|
-
}, [isDragging, snapPreview, handleModeChange, handleEdgeChange
|
|
1511
|
-
const handlePinnedDragMove =
|
|
1987
|
+
}, [isDragging, snapPreview, handleModeChange, handleEdgeChange]);
|
|
1988
|
+
const handlePinnedDragMove = React14.useCallback(
|
|
1512
1989
|
(e) => {
|
|
1513
1990
|
if (!isPinnedDragging) return;
|
|
1514
1991
|
const currentPos = (0, import_data_panel_core.getPointerPosition)(e);
|
|
@@ -1544,7 +2021,7 @@ var DataPanel = React13.forwardRef(
|
|
|
1544
2021
|
},
|
|
1545
2022
|
[isPinnedDragging, edge, detachThreshold, pinnedSize, detachedSize, handleModeChange]
|
|
1546
2023
|
);
|
|
1547
|
-
const handlePinnedDragEnd =
|
|
2024
|
+
const handlePinnedDragEnd = React14.useCallback(() => {
|
|
1548
2025
|
if (!isPinnedDragging) return;
|
|
1549
2026
|
setIsPinnedDragging(false);
|
|
1550
2027
|
setPullOffset(0);
|
|
@@ -1566,7 +2043,7 @@ var DataPanel = React13.forwardRef(
|
|
|
1566
2043
|
document.body.style.cursor = (0, import_data_panel_core.getResizeCursor)(handle);
|
|
1567
2044
|
document.body.style.userSelect = "none";
|
|
1568
2045
|
};
|
|
1569
|
-
const handleResizeMove =
|
|
2046
|
+
const handleResizeMove = React14.useCallback(
|
|
1570
2047
|
(e) => {
|
|
1571
2048
|
if (!isResizing || !resizeStateRef.current.handle) return;
|
|
1572
2049
|
const currentPos = (0, import_data_panel_core.getPointerPosition)(e);
|
|
@@ -1582,12 +2059,13 @@ var DataPanel = React13.forwardRef(
|
|
|
1582
2059
|
},
|
|
1583
2060
|
currentPos
|
|
1584
2061
|
);
|
|
1585
|
-
const constrainedSize = (0, import_data_panel_core.
|
|
1586
|
-
const constrainedPosition = (0, import_data_panel_core.constrainPosition)(
|
|
2062
|
+
const { position: constrainedPosition, size: constrainedSize } = (0, import_data_panel_core.constrainResize)(
|
|
1587
2063
|
result.position,
|
|
1588
|
-
|
|
2064
|
+
result.size,
|
|
2065
|
+
resolvedConstraints,
|
|
1589
2066
|
window.innerWidth,
|
|
1590
|
-
window.innerHeight
|
|
2067
|
+
window.innerHeight,
|
|
2068
|
+
handle
|
|
1591
2069
|
);
|
|
1592
2070
|
setDetachedSize(constrainedSize);
|
|
1593
2071
|
setDetachedPosition(constrainedPosition);
|
|
@@ -1604,45 +2082,387 @@ var DataPanel = React13.forwardRef(
|
|
|
1604
2082
|
},
|
|
1605
2083
|
[isResizing, mode, edge, resolvedConstraints]
|
|
1606
2084
|
);
|
|
1607
|
-
const handleResizeEnd =
|
|
2085
|
+
const handleResizeEnd = React14.useCallback(() => {
|
|
1608
2086
|
if (!isResizing) return;
|
|
1609
2087
|
setIsResizing(false);
|
|
1610
2088
|
resizeStateRef.current.handle = null;
|
|
1611
2089
|
document.body.style.cursor = "";
|
|
1612
2090
|
document.body.style.userSelect = "";
|
|
2091
|
+
}, [isResizing]);
|
|
2092
|
+
const handleCardHeaderPointerDown = (e) => {
|
|
2093
|
+
if (variant !== "card") return;
|
|
2094
|
+
const target = e.target;
|
|
2095
|
+
const isDragHandle = target.closest("[data-card-drag-handle]");
|
|
2096
|
+
if (!isDragHandle && target.closest("button")) return;
|
|
2097
|
+
const pos = (0, import_data_panel_core.getPointerPosition)(e.nativeEvent);
|
|
2098
|
+
cardDragStateRef.current = {
|
|
2099
|
+
startY: pos.y,
|
|
2100
|
+
startX: pos.x,
|
|
2101
|
+
startTime: Date.now(),
|
|
2102
|
+
startExpanded: isExpanded,
|
|
2103
|
+
startHorizontalPosition: cardHorizontalPosition
|
|
2104
|
+
};
|
|
2105
|
+
const startHeight = isExpanded ? cardExpandedHeight : import_data_panel_core.CARD_HEADER_HEIGHT;
|
|
2106
|
+
setCardDragCurrentHeight(startHeight);
|
|
2107
|
+
cardCurrentHeightRef.current = startHeight;
|
|
2108
|
+
if (isMobile) {
|
|
2109
|
+
setIsCardVerticalDragging(true);
|
|
2110
|
+
} else if (isDragHandle) {
|
|
2111
|
+
setIsCardHorizontalDragging(true);
|
|
2112
|
+
} else {
|
|
2113
|
+
setIsCardVerticalDragging(true);
|
|
2114
|
+
}
|
|
2115
|
+
document.body.style.userSelect = "none";
|
|
2116
|
+
};
|
|
2117
|
+
const handleCardPointerMove = React14.useCallback(
|
|
2118
|
+
(e) => {
|
|
2119
|
+
const currentPos = (0, import_data_panel_core.getPointerPosition)(e);
|
|
2120
|
+
if (isCardVerticalDragging) {
|
|
2121
|
+
const deltaY = cardDragStateRef.current.startY - currentPos.y;
|
|
2122
|
+
const startHeight = cardDragStateRef.current.startExpanded ? cardExpandedHeight : import_data_panel_core.CARD_HEADER_HEIGHT;
|
|
2123
|
+
const next = Math.max(
|
|
2124
|
+
import_data_panel_core.CARD_HEADER_HEIGHT,
|
|
2125
|
+
Math.min(viewportHeight * 0.95, startHeight + deltaY)
|
|
2126
|
+
);
|
|
2127
|
+
setCardDragCurrentHeight(next);
|
|
2128
|
+
cardCurrentHeightRef.current = next;
|
|
2129
|
+
}
|
|
2130
|
+
if (isCardHorizontalDragging && !isMobile) {
|
|
2131
|
+
const deltaX = currentPos.x - cardDragStateRef.current.startX;
|
|
2132
|
+
const cw = Math.min(
|
|
2133
|
+
viewportWidth - resolvedCardConfig.horizontalMargin * 2,
|
|
2134
|
+
resolvedCardConfig.maxWidth
|
|
2135
|
+
);
|
|
2136
|
+
const defaultLeftOffset = Math.max(
|
|
2137
|
+
resolvedCardConfig.horizontalMargin,
|
|
2138
|
+
(viewportWidth - cw) / 2
|
|
2139
|
+
);
|
|
2140
|
+
const minOffset = -(defaultLeftOffset - resolvedCardConfig.horizontalMargin);
|
|
2141
|
+
const maxOffset = viewportWidth - cw - defaultLeftOffset - resolvedCardConfig.horizontalMargin;
|
|
2142
|
+
const nextPos = cardDragStateRef.current.startHorizontalPosition + deltaX;
|
|
2143
|
+
setCardHorizontalPosition(Math.max(minOffset, Math.min(maxOffset, nextPos)));
|
|
2144
|
+
}
|
|
2145
|
+
},
|
|
2146
|
+
[
|
|
2147
|
+
isCardVerticalDragging,
|
|
2148
|
+
isCardHorizontalDragging,
|
|
2149
|
+
isMobile,
|
|
2150
|
+
viewportWidth,
|
|
2151
|
+
viewportHeight,
|
|
2152
|
+
cardExpandedHeight,
|
|
2153
|
+
resolvedCardConfig.horizontalMargin,
|
|
2154
|
+
resolvedCardConfig.maxWidth
|
|
2155
|
+
]
|
|
2156
|
+
);
|
|
2157
|
+
const handleCardPointerUp = React14.useCallback(
|
|
2158
|
+
(e) => {
|
|
2159
|
+
const endTime = Date.now();
|
|
2160
|
+
const currentPos = (0, import_data_panel_core.getPointerPosition)(e);
|
|
2161
|
+
const st = cardDragStateRef.current;
|
|
2162
|
+
const deltaTime = endTime - st.startTime;
|
|
2163
|
+
const deltaY = st.startY - currentPos.y;
|
|
2164
|
+
document.body.style.userSelect = "";
|
|
2165
|
+
if (isCardVerticalDragging) {
|
|
2166
|
+
if (deltaTime < 200 && Math.abs(deltaY) < 10) {
|
|
2167
|
+
setIsCardVerticalDragging(false);
|
|
2168
|
+
handleExpandedChange(!isExpanded);
|
|
2169
|
+
return;
|
|
2170
|
+
}
|
|
2171
|
+
const velocity = deltaY / deltaTime;
|
|
2172
|
+
let newExpanded;
|
|
2173
|
+
if (Math.abs(velocity) > resolvedCardConfig.swipeVelocityThreshold) {
|
|
2174
|
+
newExpanded = velocity > 0;
|
|
2175
|
+
} else {
|
|
2176
|
+
const midpoint = (import_data_panel_core.CARD_HEADER_HEIGHT + cardExpandedHeight) / 2;
|
|
2177
|
+
newExpanded = cardCurrentHeightRef.current > midpoint;
|
|
2178
|
+
}
|
|
2179
|
+
const targetHeight = newExpanded ? cardExpandedHeight : import_data_panel_core.CARD_HEADER_HEIGHT;
|
|
2180
|
+
setIsCardVerticalDragging(false);
|
|
2181
|
+
setIsCardHeightTransitioning(true);
|
|
2182
|
+
handleExpandedChange(newExpanded);
|
|
2183
|
+
requestAnimationFrame(() => {
|
|
2184
|
+
if (!isMountedRef.current) return;
|
|
2185
|
+
setCardDragCurrentHeight(targetHeight);
|
|
2186
|
+
cardCurrentHeightRef.current = targetHeight;
|
|
2187
|
+
});
|
|
2188
|
+
}
|
|
2189
|
+
if (isCardHorizontalDragging) {
|
|
2190
|
+
setIsCardHorizontalDragging(false);
|
|
2191
|
+
debouncedSave();
|
|
2192
|
+
}
|
|
2193
|
+
},
|
|
2194
|
+
[
|
|
2195
|
+
isCardVerticalDragging,
|
|
2196
|
+
isCardHorizontalDragging,
|
|
2197
|
+
isExpanded,
|
|
2198
|
+
cardExpandedHeight,
|
|
2199
|
+
resolvedCardConfig.swipeVelocityThreshold,
|
|
2200
|
+
handleExpandedChange,
|
|
2201
|
+
debouncedSave
|
|
2202
|
+
]
|
|
2203
|
+
);
|
|
2204
|
+
const handleCardResizeStart = (e) => {
|
|
2205
|
+
if (variant !== "card" || !isExpanded || disableResize || isMobile) return;
|
|
2206
|
+
e.preventDefault();
|
|
2207
|
+
e.stopPropagation();
|
|
2208
|
+
setIsCardTopResizing(true);
|
|
2209
|
+
const pos = (0, import_data_panel_core.getPointerPosition)(e.nativeEvent);
|
|
2210
|
+
cardTopResizeStartRef.current = { startY: pos.y, startHeight: cardExpandedHeight };
|
|
2211
|
+
document.body.style.cursor = "ns-resize";
|
|
2212
|
+
document.body.style.userSelect = "none";
|
|
2213
|
+
};
|
|
2214
|
+
const handleCardResizeMove = React14.useCallback(
|
|
2215
|
+
(e) => {
|
|
2216
|
+
if (!isCardTopResizing) return;
|
|
2217
|
+
const currentPos = (0, import_data_panel_core.getPointerPosition)(e);
|
|
2218
|
+
const deltaY = cardTopResizeStartRef.current.startY - currentPos.y;
|
|
2219
|
+
const newHeight = Math.max(
|
|
2220
|
+
import_data_panel_core.CARD_HEADER_HEIGHT * 2,
|
|
2221
|
+
Math.min(viewportHeight * 0.95, cardTopResizeStartRef.current.startHeight + deltaY)
|
|
2222
|
+
);
|
|
2223
|
+
setCardExpandedHeight(newHeight);
|
|
2224
|
+
},
|
|
2225
|
+
[isCardTopResizing, viewportHeight]
|
|
2226
|
+
);
|
|
2227
|
+
const handleCardResizeEnd = React14.useCallback(() => {
|
|
2228
|
+
if (!isCardTopResizing) return;
|
|
2229
|
+
setIsCardTopResizing(false);
|
|
2230
|
+
document.body.style.cursor = "";
|
|
2231
|
+
document.body.style.userSelect = "";
|
|
2232
|
+
debouncedSave();
|
|
2233
|
+
}, [isCardTopResizing, debouncedSave]);
|
|
2234
|
+
const handleCardWidthResizeStart = (e, handle) => {
|
|
2235
|
+
if (variant !== "card" || !isExpanded || disableResize || isMobile) return;
|
|
2236
|
+
e.preventDefault();
|
|
2237
|
+
e.stopPropagation();
|
|
2238
|
+
const pos = (0, import_data_panel_core.getPointerPosition)(e.nativeEvent);
|
|
2239
|
+
const defaultCardWidth = Math.min(
|
|
2240
|
+
viewportWidth - resolvedCardConfig.horizontalMargin * 2,
|
|
2241
|
+
resolvedCardConfig.maxWidth
|
|
2242
|
+
);
|
|
2243
|
+
const currentWidth = cardWidth ?? defaultCardWidth;
|
|
2244
|
+
const defaultLeftOffset = Math.max(
|
|
2245
|
+
resolvedCardConfig.horizontalMargin,
|
|
2246
|
+
(viewportWidth - defaultCardWidth) / 2
|
|
2247
|
+
);
|
|
2248
|
+
cardWidthResizeStateRef.current = {
|
|
2249
|
+
handle,
|
|
2250
|
+
startX: pos.x,
|
|
2251
|
+
startWidth: currentWidth,
|
|
2252
|
+
startLeft: defaultLeftOffset + cardHorizontalPosition
|
|
2253
|
+
};
|
|
2254
|
+
setIsCardWidthResizing(true);
|
|
2255
|
+
document.body.style.cursor = "ew-resize";
|
|
2256
|
+
document.body.style.userSelect = "none";
|
|
2257
|
+
};
|
|
2258
|
+
const handleCardWidthResizeMove = React14.useCallback(
|
|
2259
|
+
(e) => {
|
|
2260
|
+
const st = cardWidthResizeStateRef.current;
|
|
2261
|
+
if (!isCardWidthResizing || !st.handle) return;
|
|
2262
|
+
const currentPos = (0, import_data_panel_core.getPointerPosition)(e);
|
|
2263
|
+
const deltaX = currentPos.x - st.startX;
|
|
2264
|
+
if (st.handle === "right") {
|
|
2265
|
+
const newWidth = Math.max(
|
|
2266
|
+
import_data_panel_core.CARD_MIN_WIDTH,
|
|
2267
|
+
Math.min(
|
|
2268
|
+
resolvedCardConfig.maxWidth,
|
|
2269
|
+
viewportWidth - st.startLeft - resolvedCardConfig.horizontalMargin,
|
|
2270
|
+
st.startWidth + deltaX
|
|
2271
|
+
)
|
|
2272
|
+
);
|
|
2273
|
+
setCardWidth(newWidth);
|
|
2274
|
+
} else {
|
|
2275
|
+
const newLeft = st.startLeft + deltaX;
|
|
2276
|
+
const newWidth = st.startWidth - deltaX;
|
|
2277
|
+
if (newLeft >= resolvedCardConfig.horizontalMargin && newWidth >= import_data_panel_core.CARD_MIN_WIDTH) {
|
|
2278
|
+
setCardWidth(Math.min(newWidth, resolvedCardConfig.maxWidth));
|
|
2279
|
+
const defaultCardWidth = Math.min(
|
|
2280
|
+
viewportWidth - resolvedCardConfig.horizontalMargin * 2,
|
|
2281
|
+
resolvedCardConfig.maxWidth
|
|
2282
|
+
);
|
|
2283
|
+
const defaultLeftOffset = Math.max(
|
|
2284
|
+
resolvedCardConfig.horizontalMargin,
|
|
2285
|
+
(viewportWidth - defaultCardWidth) / 2
|
|
2286
|
+
);
|
|
2287
|
+
setCardHorizontalPosition(newLeft - defaultLeftOffset);
|
|
2288
|
+
}
|
|
2289
|
+
}
|
|
2290
|
+
},
|
|
2291
|
+
[
|
|
2292
|
+
isCardWidthResizing,
|
|
2293
|
+
viewportWidth,
|
|
2294
|
+
resolvedCardConfig.horizontalMargin,
|
|
2295
|
+
resolvedCardConfig.maxWidth
|
|
2296
|
+
]
|
|
2297
|
+
);
|
|
2298
|
+
const handleCardWidthResizeEnd = React14.useCallback(() => {
|
|
2299
|
+
if (!isCardWidthResizing) return;
|
|
2300
|
+
setIsCardWidthResizing(false);
|
|
2301
|
+
cardWidthResizeStateRef.current.handle = null;
|
|
2302
|
+
document.body.style.cursor = "";
|
|
2303
|
+
document.body.style.userSelect = "";
|
|
2304
|
+
debouncedSave();
|
|
2305
|
+
}, [isCardWidthResizing, debouncedSave]);
|
|
2306
|
+
const cardDefaultWidth = Math.min(
|
|
2307
|
+
viewportWidth - resolvedCardConfig.horizontalMargin * 2,
|
|
2308
|
+
resolvedCardConfig.maxWidth
|
|
2309
|
+
);
|
|
2310
|
+
const cardCurrentWidth = cardWidth ?? cardDefaultWidth;
|
|
2311
|
+
const cardHeightMin = import_data_panel_core.CARD_HEADER_HEIGHT * 2;
|
|
2312
|
+
const cardHeightMax = Math.round(viewportHeight * 0.95);
|
|
2313
|
+
const handleCardResizeKeyDown = (e, kind) => {
|
|
2314
|
+
if (disableResize) return;
|
|
2315
|
+
const step = e.shiftKey ? KEYBOARD_RESIZE_STEP_LARGE : KEYBOARD_RESIZE_STEP;
|
|
2316
|
+
if (kind === "height") {
|
|
2317
|
+
let delta = 0;
|
|
2318
|
+
if (e.key === "ArrowUp") delta = step;
|
|
2319
|
+
else if (e.key === "ArrowDown") delta = -step;
|
|
2320
|
+
else return;
|
|
2321
|
+
e.preventDefault();
|
|
2322
|
+
setCardExpandedHeight((h) => Math.max(cardHeightMin, Math.min(cardHeightMax, h + delta)));
|
|
2323
|
+
debouncedSave();
|
|
2324
|
+
return;
|
|
2325
|
+
}
|
|
2326
|
+
let widthDelta = 0;
|
|
2327
|
+
if (kind === "width-right") {
|
|
2328
|
+
if (e.key === "ArrowRight") widthDelta = step;
|
|
2329
|
+
else if (e.key === "ArrowLeft") widthDelta = -step;
|
|
2330
|
+
} else {
|
|
2331
|
+
if (e.key === "ArrowLeft") widthDelta = step;
|
|
2332
|
+
else if (e.key === "ArrowRight") widthDelta = -step;
|
|
2333
|
+
}
|
|
2334
|
+
if (widthDelta === 0) return;
|
|
2335
|
+
e.preventDefault();
|
|
2336
|
+
const maxWidth = Math.min(
|
|
2337
|
+
resolvedCardConfig.maxWidth,
|
|
2338
|
+
viewportWidth - resolvedCardConfig.horizontalMargin * 2
|
|
2339
|
+
);
|
|
2340
|
+
const nextWidth = Math.max(import_data_panel_core.CARD_MIN_WIDTH, Math.min(maxWidth, cardCurrentWidth + widthDelta));
|
|
2341
|
+
const appliedDelta = nextWidth - cardCurrentWidth;
|
|
2342
|
+
setCardWidth(nextWidth);
|
|
2343
|
+
if (kind === "width-left") setCardHorizontalPosition((p) => p - appliedDelta);
|
|
1613
2344
|
debouncedSave();
|
|
1614
|
-
}
|
|
1615
|
-
|
|
2345
|
+
};
|
|
2346
|
+
React14.useEffect(() => {
|
|
1616
2347
|
if (isDragging) {
|
|
1617
2348
|
window.addEventListener("pointermove", handleDragMove);
|
|
1618
2349
|
window.addEventListener("pointerup", handleDragEnd);
|
|
2350
|
+
window.addEventListener("pointercancel", handleDragEnd);
|
|
1619
2351
|
return () => {
|
|
1620
2352
|
window.removeEventListener("pointermove", handleDragMove);
|
|
1621
2353
|
window.removeEventListener("pointerup", handleDragEnd);
|
|
2354
|
+
window.removeEventListener("pointercancel", handleDragEnd);
|
|
1622
2355
|
};
|
|
1623
2356
|
}
|
|
1624
2357
|
}, [isDragging, handleDragMove, handleDragEnd]);
|
|
1625
|
-
|
|
2358
|
+
React14.useEffect(() => {
|
|
1626
2359
|
if (isPinnedDragging) {
|
|
1627
2360
|
window.addEventListener("pointermove", handlePinnedDragMove);
|
|
1628
2361
|
window.addEventListener("pointerup", handlePinnedDragEnd);
|
|
2362
|
+
window.addEventListener("pointercancel", handlePinnedDragEnd);
|
|
1629
2363
|
return () => {
|
|
1630
2364
|
window.removeEventListener("pointermove", handlePinnedDragMove);
|
|
1631
2365
|
window.removeEventListener("pointerup", handlePinnedDragEnd);
|
|
2366
|
+
window.removeEventListener("pointercancel", handlePinnedDragEnd);
|
|
1632
2367
|
};
|
|
1633
2368
|
}
|
|
1634
2369
|
}, [isPinnedDragging, handlePinnedDragMove, handlePinnedDragEnd]);
|
|
1635
|
-
|
|
2370
|
+
React14.useEffect(() => {
|
|
1636
2371
|
if (isResizing) {
|
|
1637
2372
|
window.addEventListener("pointermove", handleResizeMove);
|
|
1638
2373
|
window.addEventListener("pointerup", handleResizeEnd);
|
|
2374
|
+
window.addEventListener("pointercancel", handleResizeEnd);
|
|
1639
2375
|
return () => {
|
|
1640
2376
|
window.removeEventListener("pointermove", handleResizeMove);
|
|
1641
2377
|
window.removeEventListener("pointerup", handleResizeEnd);
|
|
2378
|
+
window.removeEventListener("pointercancel", handleResizeEnd);
|
|
1642
2379
|
};
|
|
1643
2380
|
}
|
|
1644
2381
|
}, [isResizing, handleResizeMove, handleResizeEnd]);
|
|
1645
|
-
|
|
2382
|
+
React14.useEffect(() => {
|
|
2383
|
+
if (isCardVerticalDragging || isCardHorizontalDragging) {
|
|
2384
|
+
window.addEventListener("pointermove", handleCardPointerMove);
|
|
2385
|
+
window.addEventListener("pointerup", handleCardPointerUp);
|
|
2386
|
+
window.addEventListener("pointercancel", handleCardPointerUp);
|
|
2387
|
+
return () => {
|
|
2388
|
+
window.removeEventListener("pointermove", handleCardPointerMove);
|
|
2389
|
+
window.removeEventListener("pointerup", handleCardPointerUp);
|
|
2390
|
+
window.removeEventListener("pointercancel", handleCardPointerUp);
|
|
2391
|
+
};
|
|
2392
|
+
}
|
|
2393
|
+
}, [
|
|
2394
|
+
isCardVerticalDragging,
|
|
2395
|
+
isCardHorizontalDragging,
|
|
2396
|
+
handleCardPointerMove,
|
|
2397
|
+
handleCardPointerUp
|
|
2398
|
+
]);
|
|
2399
|
+
React14.useEffect(() => {
|
|
2400
|
+
if (isCardTopResizing) {
|
|
2401
|
+
window.addEventListener("pointermove", handleCardResizeMove);
|
|
2402
|
+
window.addEventListener("pointerup", handleCardResizeEnd);
|
|
2403
|
+
window.addEventListener("pointercancel", handleCardResizeEnd);
|
|
2404
|
+
return () => {
|
|
2405
|
+
window.removeEventListener("pointermove", handleCardResizeMove);
|
|
2406
|
+
window.removeEventListener("pointerup", handleCardResizeEnd);
|
|
2407
|
+
window.removeEventListener("pointercancel", handleCardResizeEnd);
|
|
2408
|
+
};
|
|
2409
|
+
}
|
|
2410
|
+
}, [isCardTopResizing, handleCardResizeMove, handleCardResizeEnd]);
|
|
2411
|
+
React14.useEffect(() => {
|
|
2412
|
+
if (isCardWidthResizing) {
|
|
2413
|
+
window.addEventListener("pointermove", handleCardWidthResizeMove);
|
|
2414
|
+
window.addEventListener("pointerup", handleCardWidthResizeEnd);
|
|
2415
|
+
window.addEventListener("pointercancel", handleCardWidthResizeEnd);
|
|
2416
|
+
return () => {
|
|
2417
|
+
window.removeEventListener("pointermove", handleCardWidthResizeMove);
|
|
2418
|
+
window.removeEventListener("pointerup", handleCardWidthResizeEnd);
|
|
2419
|
+
window.removeEventListener("pointercancel", handleCardWidthResizeEnd);
|
|
2420
|
+
};
|
|
2421
|
+
}
|
|
2422
|
+
}, [isCardWidthResizing, handleCardWidthResizeMove, handleCardWidthResizeEnd]);
|
|
2423
|
+
React14.useEffect(() => {
|
|
2424
|
+
const onResize = () => {
|
|
2425
|
+
setViewportWidth(window.innerWidth);
|
|
2426
|
+
setViewportHeight(window.innerHeight);
|
|
2427
|
+
setCardExpandedHeight(window.innerHeight * import_data_panel_core.CARD_EXPANDED_RATIO);
|
|
2428
|
+
};
|
|
2429
|
+
onResize();
|
|
2430
|
+
window.addEventListener("resize", onResize);
|
|
2431
|
+
return () => window.removeEventListener("resize", onResize);
|
|
2432
|
+
}, []);
|
|
2433
|
+
React14.useEffect(() => {
|
|
2434
|
+
if (isMobile && variant === "card") {
|
|
2435
|
+
setCardHorizontalPosition(0);
|
|
2436
|
+
setCardWidth(null);
|
|
2437
|
+
}
|
|
2438
|
+
}, [isMobile, variant]);
|
|
2439
|
+
React14.useEffect(() => {
|
|
2440
|
+
if (isCardHeightTransitioning) {
|
|
2441
|
+
const t = setTimeout(() => setIsCardHeightTransitioning(false), 350);
|
|
2442
|
+
return () => clearTimeout(t);
|
|
2443
|
+
}
|
|
2444
|
+
}, [isCardHeightTransitioning]);
|
|
2445
|
+
const panelStyles = React14.useMemo(() => {
|
|
2446
|
+
if (variant === "card") {
|
|
2447
|
+
const defaultCardWidth = Math.min(
|
|
2448
|
+
viewportWidth - resolvedCardConfig.horizontalMargin * 2,
|
|
2449
|
+
resolvedCardConfig.maxWidth
|
|
2450
|
+
);
|
|
2451
|
+
const actualCardWidth = cardWidth ?? defaultCardWidth;
|
|
2452
|
+
const defaultLeftOffset = Math.max(
|
|
2453
|
+
resolvedCardConfig.horizontalMargin,
|
|
2454
|
+
(viewportWidth - defaultCardWidth) / 2
|
|
2455
|
+
);
|
|
2456
|
+
const height = isCardVerticalDragging || isCardHeightTransitioning ? cardDragCurrentHeight : isExpanded ? cardExpandedHeight : import_data_panel_core.CARD_HEADER_HEIGHT;
|
|
2457
|
+
return {
|
|
2458
|
+
bottom: 0,
|
|
2459
|
+
left: defaultLeftOffset + cardHorizontalPosition,
|
|
2460
|
+
width: actualCardWidth,
|
|
2461
|
+
height,
|
|
2462
|
+
maxHeight: viewportHeight * 0.95,
|
|
2463
|
+
borderRadius: `${resolvedCardConfig.borderRadius}px ${resolvedCardConfig.borderRadius}px 0 0`
|
|
2464
|
+
};
|
|
2465
|
+
}
|
|
1646
2466
|
if (mode === "pinned") {
|
|
1647
2467
|
const baseStyles = (0, import_data_panel_core.getPinnedPositionStyles)(edge, pinnedSize);
|
|
1648
2468
|
if (pullOffset > 0) {
|
|
@@ -1652,22 +2472,54 @@ var DataPanel = React13.forwardRef(
|
|
|
1652
2472
|
return baseStyles;
|
|
1653
2473
|
}
|
|
1654
2474
|
return (0, import_data_panel_core.getDetachedPositionStyles)(detachedPosition, detachedSize);
|
|
1655
|
-
}, [
|
|
2475
|
+
}, [
|
|
2476
|
+
variant,
|
|
2477
|
+
mode,
|
|
2478
|
+
edge,
|
|
2479
|
+
pinnedSize,
|
|
2480
|
+
detachedPosition,
|
|
2481
|
+
detachedSize,
|
|
2482
|
+
pullOffset,
|
|
2483
|
+
viewportWidth,
|
|
2484
|
+
viewportHeight,
|
|
2485
|
+
cardWidth,
|
|
2486
|
+
cardHorizontalPosition,
|
|
2487
|
+
cardExpandedHeight,
|
|
2488
|
+
cardDragCurrentHeight,
|
|
2489
|
+
isCardVerticalDragging,
|
|
2490
|
+
isCardHeightTransitioning,
|
|
2491
|
+
isExpanded,
|
|
2492
|
+
resolvedCardConfig.horizontalMargin,
|
|
2493
|
+
resolvedCardConfig.maxWidth,
|
|
2494
|
+
resolvedCardConfig.borderRadius
|
|
2495
|
+
]);
|
|
1656
2496
|
const pinnedClasses = {
|
|
1657
2497
|
left: "left-0 top-0 bottom-0 border-r",
|
|
1658
2498
|
right: "right-0 top-0 bottom-0 border-l",
|
|
1659
2499
|
top: "top-0 left-0 right-0 border-b",
|
|
1660
2500
|
bottom: "bottom-0 left-0 right-0 border-t"
|
|
1661
2501
|
}[edge];
|
|
1662
|
-
const animationClass = mode === "pinned" ? {
|
|
2502
|
+
const animationClass = variant === "card" ? "animate-panel-slide-in-bottom" : mode === "pinned" ? {
|
|
1663
2503
|
left: "animate-slide-right",
|
|
1664
2504
|
right: "animate-slide-left",
|
|
1665
2505
|
top: "animate-slide-down",
|
|
1666
2506
|
bottom: "animate-slide-up"
|
|
1667
2507
|
}[edge] : "animate-scale-in";
|
|
1668
2508
|
if (!open) return null;
|
|
1669
|
-
if (!isExpanded && mode === "pinned") {
|
|
1670
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2509
|
+
if (variant === "full" && !isExpanded && mode === "pinned") {
|
|
2510
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2511
|
+
DataPanelTab,
|
|
2512
|
+
{
|
|
2513
|
+
title,
|
|
2514
|
+
subtitle,
|
|
2515
|
+
edge,
|
|
2516
|
+
onClick: () => handleExpandedChange(true),
|
|
2517
|
+
onClose: () => handleOpenChange(false),
|
|
2518
|
+
disableClose,
|
|
2519
|
+
offset: tabOffset,
|
|
2520
|
+
onOffsetChange: setTabOffset
|
|
2521
|
+
}
|
|
2522
|
+
);
|
|
1671
2523
|
}
|
|
1672
2524
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
1673
2525
|
snapPreview && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
@@ -1682,26 +2534,53 @@ var DataPanel = React13.forwardRef(
|
|
|
1682
2534
|
)
|
|
1683
2535
|
}
|
|
1684
2536
|
),
|
|
2537
|
+
variant === "card" && isExpanded && isMobile && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2538
|
+
"div",
|
|
2539
|
+
{
|
|
2540
|
+
className: "fixed inset-0 z-40 bg-black/50 transition-opacity",
|
|
2541
|
+
"aria-hidden": "true",
|
|
2542
|
+
onClick: handleToggleExpand
|
|
2543
|
+
}
|
|
2544
|
+
),
|
|
1685
2545
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
1686
2546
|
"div",
|
|
1687
2547
|
{
|
|
1688
|
-
ref,
|
|
2548
|
+
ref: setPanelRef,
|
|
1689
2549
|
className: cn(
|
|
1690
2550
|
"fixed z-50 flex flex-col bg-background border border-border shadow-lg overflow-hidden",
|
|
1691
|
-
mode === "pinned" && pinnedClasses,
|
|
1692
|
-
mode === "detached" && "rounded-lg",
|
|
2551
|
+
variant === "full" && mode === "pinned" && pinnedClasses,
|
|
2552
|
+
variant === "full" && mode === "detached" && "rounded-lg",
|
|
2553
|
+
variant === "card" && "rounded-t-lg border-b-0",
|
|
1693
2554
|
isPinnedDragging && pullOffset > 0 && "shadow-2xl",
|
|
2555
|
+
!isDragging && !isPinnedDragging && !isCardHorizontalDragging && !isCardVerticalDragging && !isResizing && !isCardTopResizing && !isCardWidthResizing && "transition-[height,left,width,transform] duration-300 ease-out",
|
|
1694
2556
|
animationClass,
|
|
1695
2557
|
className
|
|
1696
2558
|
),
|
|
1697
2559
|
style: panelStyles,
|
|
1698
|
-
role: mode === "detached" ? "dialog" : "complementary",
|
|
1699
|
-
"aria-modal":
|
|
2560
|
+
role: mode === "detached" || variant === "card" ? "dialog" : "complementary",
|
|
2561
|
+
"aria-modal": isDialog ? "true" : void 0,
|
|
1700
2562
|
"aria-labelledby": title ? titleId : void 0,
|
|
1701
2563
|
"aria-label": !title ? "Side panel" : void 0,
|
|
1702
|
-
|
|
2564
|
+
"aria-expanded": variant === "card" ? isExpanded : void 0,
|
|
2565
|
+
onPointerDown: variant === "full" ? handleDragStart : void 0,
|
|
1703
2566
|
children: [
|
|
1704
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2567
|
+
variant === "card" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2568
|
+
DataPanelCardHeader,
|
|
2569
|
+
{
|
|
2570
|
+
title,
|
|
2571
|
+
subtitle,
|
|
2572
|
+
titleId,
|
|
2573
|
+
isExpanded,
|
|
2574
|
+
isMobile,
|
|
2575
|
+
showDragHandle: resolvedCardConfig.showDragHandle,
|
|
2576
|
+
headerContent,
|
|
2577
|
+
headerActions,
|
|
2578
|
+
disableClose,
|
|
2579
|
+
onHeaderPointerDown: handleCardHeaderPointerDown,
|
|
2580
|
+
onToggleExpand: handleToggleExpand,
|
|
2581
|
+
onClose: () => handleOpenChange(false)
|
|
2582
|
+
}
|
|
2583
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1705
2584
|
DataPanelHeader,
|
|
1706
2585
|
{
|
|
1707
2586
|
title,
|
|
@@ -1721,24 +2600,30 @@ var DataPanel = React13.forwardRef(
|
|
|
1721
2600
|
draggable: !disableDrag && (mode === "detached" || mode === "pinned" && detachThreshold > 0)
|
|
1722
2601
|
}
|
|
1723
2602
|
),
|
|
1724
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
2603
|
+
showContent && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
2604
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(DataPanelContent, { children }),
|
|
2605
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2606
|
+
DataPanelFooter,
|
|
2607
|
+
{
|
|
2608
|
+
actions,
|
|
2609
|
+
footerContent,
|
|
2610
|
+
footerActions
|
|
2611
|
+
}
|
|
2612
|
+
)
|
|
2613
|
+
] }),
|
|
2614
|
+
variant === "full" && !disableResize && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1734
2615
|
ResizeHandles,
|
|
1735
2616
|
{
|
|
1736
2617
|
mode,
|
|
1737
2618
|
edge,
|
|
2619
|
+
detachedPosition,
|
|
1738
2620
|
detachedSize,
|
|
1739
2621
|
pinnedSize,
|
|
1740
2622
|
onResizeStart: handleResizeStart,
|
|
1741
|
-
|
|
2623
|
+
onDetachedResize: (position, size) => {
|
|
2624
|
+
setDetachedSize(size);
|
|
2625
|
+
setDetachedPosition(position);
|
|
2626
|
+
},
|
|
1742
2627
|
onPinnedSizeChange: (size) => {
|
|
1743
2628
|
if (typeof window === "undefined") {
|
|
1744
2629
|
setPinnedSize(size);
|
|
@@ -1754,7 +2639,57 @@ var DataPanel = React13.forwardRef(
|
|
|
1754
2639
|
},
|
|
1755
2640
|
constraints: resolvedConstraints
|
|
1756
2641
|
}
|
|
1757
|
-
)
|
|
2642
|
+
),
|
|
2643
|
+
variant === "card" && isExpanded && !disableResize && !isMobile && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
2644
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2645
|
+
"div",
|
|
2646
|
+
{
|
|
2647
|
+
className: "resize-handle resize-handle--horizontal resize-handle--top",
|
|
2648
|
+
role: "slider",
|
|
2649
|
+
tabIndex: 0,
|
|
2650
|
+
"aria-orientation": "vertical",
|
|
2651
|
+
"aria-label": "Resize card height",
|
|
2652
|
+
"aria-valuenow": Math.round(cardExpandedHeight),
|
|
2653
|
+
"aria-valuemin": cardHeightMin,
|
|
2654
|
+
"aria-valuemax": cardHeightMax,
|
|
2655
|
+
"aria-valuetext": `${Math.round(cardExpandedHeight)} pixels`,
|
|
2656
|
+
onPointerDown: handleCardResizeStart,
|
|
2657
|
+
onKeyDown: (e) => handleCardResizeKeyDown(e, "height")
|
|
2658
|
+
}
|
|
2659
|
+
),
|
|
2660
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2661
|
+
"div",
|
|
2662
|
+
{
|
|
2663
|
+
className: "resize-handle resize-handle--vertical resize-handle--left resize-handle--card-edge",
|
|
2664
|
+
role: "slider",
|
|
2665
|
+
tabIndex: 0,
|
|
2666
|
+
"aria-orientation": "horizontal",
|
|
2667
|
+
"aria-label": "Resize card width from left edge",
|
|
2668
|
+
"aria-valuenow": Math.round(cardCurrentWidth),
|
|
2669
|
+
"aria-valuemin": import_data_panel_core.CARD_MIN_WIDTH,
|
|
2670
|
+
"aria-valuemax": resolvedCardConfig.maxWidth,
|
|
2671
|
+
"aria-valuetext": `${Math.round(cardCurrentWidth)} pixels`,
|
|
2672
|
+
onPointerDown: (e) => handleCardWidthResizeStart(e, "left"),
|
|
2673
|
+
onKeyDown: (e) => handleCardResizeKeyDown(e, "width-left")
|
|
2674
|
+
}
|
|
2675
|
+
),
|
|
2676
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2677
|
+
"div",
|
|
2678
|
+
{
|
|
2679
|
+
className: "resize-handle resize-handle--vertical resize-handle--right resize-handle--card-edge",
|
|
2680
|
+
role: "slider",
|
|
2681
|
+
tabIndex: 0,
|
|
2682
|
+
"aria-orientation": "horizontal",
|
|
2683
|
+
"aria-label": "Resize card width from right edge",
|
|
2684
|
+
"aria-valuenow": Math.round(cardCurrentWidth),
|
|
2685
|
+
"aria-valuemin": import_data_panel_core.CARD_MIN_WIDTH,
|
|
2686
|
+
"aria-valuemax": resolvedCardConfig.maxWidth,
|
|
2687
|
+
"aria-valuetext": `${Math.round(cardCurrentWidth)} pixels`,
|
|
2688
|
+
onPointerDown: (e) => handleCardWidthResizeStart(e, "right"),
|
|
2689
|
+
onKeyDown: (e) => handleCardResizeKeyDown(e, "width-right")
|
|
2690
|
+
}
|
|
2691
|
+
)
|
|
2692
|
+
] })
|
|
1758
2693
|
]
|
|
1759
2694
|
}
|
|
1760
2695
|
)
|
|
@@ -1764,7 +2699,7 @@ var DataPanel = React13.forwardRef(
|
|
|
1764
2699
|
DataPanel.displayName = "DataPanel";
|
|
1765
2700
|
|
|
1766
2701
|
// src/components/Skeleton.tsx
|
|
1767
|
-
var
|
|
2702
|
+
var React15 = __toESM(require("react"));
|
|
1768
2703
|
var import_class_variance_authority5 = require("class-variance-authority");
|
|
1769
2704
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1770
2705
|
var skeletonVariants = (0, import_class_variance_authority5.cva)("rounded-md bg-muted", {
|
|
@@ -1782,7 +2717,7 @@ var skeletonVariants = (0, import_class_variance_authority5.cva)("rounded-md bg-
|
|
|
1782
2717
|
variant: "default"
|
|
1783
2718
|
}
|
|
1784
2719
|
});
|
|
1785
|
-
var Skeleton =
|
|
2720
|
+
var Skeleton = React15.forwardRef(
|
|
1786
2721
|
({ className, variant, animation = "pulse", ...props }, ref) => {
|
|
1787
2722
|
const animationClass = animation === "pulse" ? "animate-pulse" : animation === "shimmer" ? "animate-shimmer" : "";
|
|
1788
2723
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
@@ -1798,7 +2733,7 @@ var Skeleton = React14.forwardRef(
|
|
|
1798
2733
|
Skeleton.displayName = "Skeleton";
|
|
1799
2734
|
|
|
1800
2735
|
// src/components/Spinner.tsx
|
|
1801
|
-
var
|
|
2736
|
+
var React16 = __toESM(require("react"));
|
|
1802
2737
|
var import_class_variance_authority6 = require("class-variance-authority");
|
|
1803
2738
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1804
2739
|
var spinnerVariants = (0, import_class_variance_authority6.cva)("animate-spin text-current", {
|
|
@@ -1814,7 +2749,7 @@ var spinnerVariants = (0, import_class_variance_authority6.cva)("animate-spin te
|
|
|
1814
2749
|
size: "md"
|
|
1815
2750
|
}
|
|
1816
2751
|
});
|
|
1817
|
-
var Spinner =
|
|
2752
|
+
var Spinner = React16.forwardRef(
|
|
1818
2753
|
({ className, size, label = "Loading...", ...props }, ref) => {
|
|
1819
2754
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1820
2755
|
"svg",
|
|
@@ -1856,7 +2791,7 @@ var Spinner = React15.forwardRef(
|
|
|
1856
2791
|
Spinner.displayName = "Spinner";
|
|
1857
2792
|
|
|
1858
2793
|
// src/components/LoadingLogo.tsx
|
|
1859
|
-
var
|
|
2794
|
+
var React17 = __toESM(require("react"));
|
|
1860
2795
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1861
2796
|
var logoPaths = [
|
|
1862
2797
|
"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",
|
|
@@ -1879,7 +2814,7 @@ var colors = {
|
|
|
1879
2814
|
stroke: "#ffffff"
|
|
1880
2815
|
}
|
|
1881
2816
|
};
|
|
1882
|
-
var LoadingLogo =
|
|
2817
|
+
var LoadingLogo = React17.forwardRef(
|
|
1883
2818
|
({ width = 40, height = 40, loading = false, variant = "dark", className, ...props }, ref) => {
|
|
1884
2819
|
const currentColors = colors[variant];
|
|
1885
2820
|
const fillColor = loading ? currentColors.fillLoading : currentColors.fill;
|
|
@@ -1928,7 +2863,7 @@ var LoadingLogo = React16.forwardRef(
|
|
|
1928
2863
|
LoadingLogo.displayName = "LoadingLogo";
|
|
1929
2864
|
|
|
1930
2865
|
// src/components/ProgressBar.tsx
|
|
1931
|
-
var
|
|
2866
|
+
var React18 = __toESM(require("react"));
|
|
1932
2867
|
var import_class_variance_authority7 = require("class-variance-authority");
|
|
1933
2868
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1934
2869
|
var progressBarVariants = (0, import_class_variance_authority7.cva)("w-full overflow-hidden rounded-full bg-muted", {
|
|
@@ -1956,7 +2891,7 @@ var progressFillVariants = (0, import_class_variance_authority7.cva)("h-full rou
|
|
|
1956
2891
|
variant: "default"
|
|
1957
2892
|
}
|
|
1958
2893
|
});
|
|
1959
|
-
var ProgressBar =
|
|
2894
|
+
var ProgressBar = React18.forwardRef(
|
|
1960
2895
|
({ className, size, variant, value, max = 100, label = "Progress", showValue = false, ...props }, ref) => {
|
|
1961
2896
|
const isIndeterminate = value === void 0;
|
|
1962
2897
|
const clampedValue = isIndeterminate ? 0 : Math.min(Math.max(0, value), max);
|
|
@@ -1995,11 +2930,11 @@ var ProgressBar = React17.forwardRef(
|
|
|
1995
2930
|
ProgressBar.displayName = "ProgressBar";
|
|
1996
2931
|
|
|
1997
2932
|
// src/components/LoadingOverlay.tsx
|
|
1998
|
-
var
|
|
2933
|
+
var React19 = __toESM(require("react"));
|
|
1999
2934
|
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
2000
2935
|
var spinnerSizeMap = { sm: "sm", md: "md", lg: "lg", xl: "xl" };
|
|
2001
2936
|
var logoSizeMap = { sm: 32, md: 40, lg: 56, xl: 80 };
|
|
2002
|
-
var LoadingOverlay =
|
|
2937
|
+
var LoadingOverlay = React19.forwardRef(
|
|
2003
2938
|
({
|
|
2004
2939
|
loading = true,
|
|
2005
2940
|
variant = "spinner",
|
|
@@ -2014,8 +2949,8 @@ var LoadingOverlay = React18.forwardRef(
|
|
|
2014
2949
|
children,
|
|
2015
2950
|
...props
|
|
2016
2951
|
}, ref) => {
|
|
2017
|
-
const [visible, setVisible] =
|
|
2018
|
-
|
|
2952
|
+
const [visible, setVisible] = React19.useState(delay === 0 && loading);
|
|
2953
|
+
React19.useEffect(() => {
|
|
2019
2954
|
if (!loading) {
|
|
2020
2955
|
setVisible(false);
|
|
2021
2956
|
return;
|
|
@@ -2083,9 +3018,9 @@ var LoadingOverlay = React18.forwardRef(
|
|
|
2083
3018
|
LoadingOverlay.displayName = "LoadingOverlay";
|
|
2084
3019
|
|
|
2085
3020
|
// src/components/LoadingPage.tsx
|
|
2086
|
-
var
|
|
3021
|
+
var React20 = __toESM(require("react"));
|
|
2087
3022
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2088
|
-
var LoadingPage =
|
|
3023
|
+
var LoadingPage = React20.forwardRef(
|
|
2089
3024
|
({
|
|
2090
3025
|
loading = true,
|
|
2091
3026
|
message,
|
|
@@ -2096,8 +3031,8 @@ var LoadingPage = React19.forwardRef(
|
|
|
2096
3031
|
className,
|
|
2097
3032
|
...props
|
|
2098
3033
|
}, ref) => {
|
|
2099
|
-
const [visible, setVisible] =
|
|
2100
|
-
|
|
3034
|
+
const [visible, setVisible] = React20.useState(delay === 0 && loading);
|
|
3035
|
+
React20.useEffect(() => {
|
|
2101
3036
|
if (!loading) {
|
|
2102
3037
|
setVisible(false);
|
|
2103
3038
|
return;
|
|
@@ -2137,9 +3072,9 @@ var LoadingPage = React19.forwardRef(
|
|
|
2137
3072
|
LoadingPage.displayName = "LoadingPage";
|
|
2138
3073
|
|
|
2139
3074
|
// src/components/LoadingSection.tsx
|
|
2140
|
-
var
|
|
3075
|
+
var React21 = __toESM(require("react"));
|
|
2141
3076
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2142
|
-
var LoadingSection =
|
|
3077
|
+
var LoadingSection = React21.forwardRef(
|
|
2143
3078
|
({
|
|
2144
3079
|
loading = false,
|
|
2145
3080
|
variant = "spinner",
|
|
@@ -2181,9 +3116,9 @@ var LoadingSection = React20.forwardRef(
|
|
|
2181
3116
|
LoadingSection.displayName = "LoadingSection";
|
|
2182
3117
|
|
|
2183
3118
|
// src/components/LiveRegion.tsx
|
|
2184
|
-
var
|
|
3119
|
+
var React22 = __toESM(require("react"));
|
|
2185
3120
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2186
|
-
var LiveRegion =
|
|
3121
|
+
var LiveRegion = React22.forwardRef(
|
|
2187
3122
|
({ message, politeness = "polite", atomic = true, visuallyHidden = true, className, children }, ref) => {
|
|
2188
3123
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2189
3124
|
"div",
|
|
@@ -2204,9 +3139,9 @@ var LiveRegion = React21.forwardRef(
|
|
|
2204
3139
|
LiveRegion.displayName = "LiveRegion";
|
|
2205
3140
|
|
|
2206
3141
|
// src/components/SkipLink.tsx
|
|
2207
|
-
var
|
|
3142
|
+
var React23 = __toESM(require("react"));
|
|
2208
3143
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2209
|
-
var SkipLink =
|
|
3144
|
+
var SkipLink = React23.forwardRef(
|
|
2210
3145
|
({ targetId, className, children = "Skip to main content", ...props }, ref) => {
|
|
2211
3146
|
const handleClick = (e) => {
|
|
2212
3147
|
e.preventDefault();
|
|
@@ -2239,84 +3174,6 @@ var SkipLink = React22.forwardRef(
|
|
|
2239
3174
|
);
|
|
2240
3175
|
SkipLink.displayName = "SkipLink";
|
|
2241
3176
|
|
|
2242
|
-
// src/hooks/useFocusTrap.ts
|
|
2243
|
-
var import_react = require("react");
|
|
2244
|
-
var FOCUSABLE_SELECTOR = [
|
|
2245
|
-
"a[href]",
|
|
2246
|
-
"area[href]",
|
|
2247
|
-
'input:not([disabled]):not([type="hidden"])',
|
|
2248
|
-
"select:not([disabled])",
|
|
2249
|
-
"textarea:not([disabled])",
|
|
2250
|
-
"button:not([disabled])",
|
|
2251
|
-
"iframe",
|
|
2252
|
-
"object",
|
|
2253
|
-
"embed",
|
|
2254
|
-
"[contenteditable]",
|
|
2255
|
-
'[tabindex]:not([tabindex="-1"])'
|
|
2256
|
-
].join(",");
|
|
2257
|
-
function getFocusableElements(container) {
|
|
2258
|
-
const elements = container.querySelectorAll(FOCUSABLE_SELECTOR);
|
|
2259
|
-
return Array.from(elements).filter(
|
|
2260
|
-
(el) => el.offsetParent !== null && getComputedStyle(el).visibility !== "hidden"
|
|
2261
|
-
);
|
|
2262
|
-
}
|
|
2263
|
-
function useFocusTrap(options = {}) {
|
|
2264
|
-
const { active = true, returnFocusTo, initialFocus, preventScroll = false } = options;
|
|
2265
|
-
const containerRef = (0, import_react.useRef)(null);
|
|
2266
|
-
const previousActiveElementRef = (0, import_react.useRef)(null);
|
|
2267
|
-
const handleKeyDown = (0, import_react.useCallback)(
|
|
2268
|
-
(event) => {
|
|
2269
|
-
if (!active || event.key !== "Tab") return;
|
|
2270
|
-
const container = containerRef.current;
|
|
2271
|
-
if (!container) return;
|
|
2272
|
-
const focusableElements = getFocusableElements(container);
|
|
2273
|
-
if (focusableElements.length === 0) return;
|
|
2274
|
-
const firstElement = focusableElements[0];
|
|
2275
|
-
const lastElement = focusableElements[focusableElements.length - 1];
|
|
2276
|
-
if (event.shiftKey) {
|
|
2277
|
-
if (document.activeElement === firstElement) {
|
|
2278
|
-
event.preventDefault();
|
|
2279
|
-
lastElement.focus({ preventScroll });
|
|
2280
|
-
}
|
|
2281
|
-
} else {
|
|
2282
|
-
if (document.activeElement === lastElement) {
|
|
2283
|
-
event.preventDefault();
|
|
2284
|
-
firstElement.focus({ preventScroll });
|
|
2285
|
-
}
|
|
2286
|
-
}
|
|
2287
|
-
},
|
|
2288
|
-
[active, preventScroll]
|
|
2289
|
-
);
|
|
2290
|
-
(0, import_react.useEffect)(() => {
|
|
2291
|
-
if (!active) return;
|
|
2292
|
-
const container = containerRef.current;
|
|
2293
|
-
if (!container) return;
|
|
2294
|
-
previousActiveElementRef.current = document.activeElement;
|
|
2295
|
-
const focusableElements = getFocusableElements(container);
|
|
2296
|
-
if (focusableElements.length > 0) {
|
|
2297
|
-
let elementToFocus = null;
|
|
2298
|
-
if (initialFocus) {
|
|
2299
|
-
elementToFocus = container.querySelector(initialFocus);
|
|
2300
|
-
}
|
|
2301
|
-
if (!elementToFocus) {
|
|
2302
|
-
elementToFocus = focusableElements[0];
|
|
2303
|
-
}
|
|
2304
|
-
requestAnimationFrame(() => {
|
|
2305
|
-
elementToFocus?.focus({ preventScroll });
|
|
2306
|
-
});
|
|
2307
|
-
}
|
|
2308
|
-
document.addEventListener("keydown", handleKeyDown);
|
|
2309
|
-
return () => {
|
|
2310
|
-
document.removeEventListener("keydown", handleKeyDown);
|
|
2311
|
-
const elementToReturn = returnFocusTo ?? previousActiveElementRef.current;
|
|
2312
|
-
if (elementToReturn && typeof elementToReturn.focus === "function") {
|
|
2313
|
-
elementToReturn.focus({ preventScroll });
|
|
2314
|
-
}
|
|
2315
|
-
};
|
|
2316
|
-
}, [active, initialFocus, returnFocusTo, handleKeyDown, preventScroll]);
|
|
2317
|
-
return containerRef;
|
|
2318
|
-
}
|
|
2319
|
-
|
|
2320
3177
|
// src/hooks/useFocusRef.ts
|
|
2321
3178
|
var import_react2 = require("react");
|
|
2322
3179
|
function useFocusRef(options = {}) {
|
|
@@ -2370,6 +3227,11 @@ function useArrowNavigation(options = {}) {
|
|
|
2370
3227
|
} = options;
|
|
2371
3228
|
const containerRef = (0, import_react4.useRef)(null);
|
|
2372
3229
|
const focusedIndexRef = (0, import_react4.useRef)(-1);
|
|
3230
|
+
const [focusedIndex, setFocusedIndexState] = (0, import_react4.useState)(-1);
|
|
3231
|
+
const setFocusedIndex = (0, import_react4.useCallback)((index) => {
|
|
3232
|
+
focusedIndexRef.current = index;
|
|
3233
|
+
setFocusedIndexState(index);
|
|
3234
|
+
}, []);
|
|
2373
3235
|
const getFocusableItems = (0, import_react4.useCallback)(() => {
|
|
2374
3236
|
if (!containerRef.current) return [];
|
|
2375
3237
|
return Array.from(containerRef.current.querySelectorAll(itemSelector));
|
|
@@ -2388,11 +3250,11 @@ function useArrowNavigation(options = {}) {
|
|
|
2388
3250
|
const element = items[targetIndex];
|
|
2389
3251
|
if (element) {
|
|
2390
3252
|
element.focus();
|
|
2391
|
-
|
|
3253
|
+
setFocusedIndex(targetIndex);
|
|
2392
3254
|
onFocusChange?.(targetIndex, element);
|
|
2393
3255
|
}
|
|
2394
3256
|
},
|
|
2395
|
-
[getFocusableItems, loop, onFocusChange]
|
|
3257
|
+
[getFocusableItems, loop, onFocusChange, setFocusedIndex]
|
|
2396
3258
|
);
|
|
2397
3259
|
const handleKeyDown = (0, import_react4.useCallback)(
|
|
2398
3260
|
(event) => {
|
|
@@ -2446,10 +3308,10 @@ function useArrowNavigation(options = {}) {
|
|
|
2446
3308
|
const items = getFocusableItems();
|
|
2447
3309
|
const index = items.indexOf(event.target);
|
|
2448
3310
|
if (index !== -1) {
|
|
2449
|
-
|
|
3311
|
+
setFocusedIndex(index);
|
|
2450
3312
|
}
|
|
2451
3313
|
},
|
|
2452
|
-
[getFocusableItems]
|
|
3314
|
+
[getFocusableItems, setFocusedIndex]
|
|
2453
3315
|
);
|
|
2454
3316
|
const containerProps = {
|
|
2455
3317
|
ref: (node) => {
|
|
@@ -2458,14 +3320,15 @@ function useArrowNavigation(options = {}) {
|
|
|
2458
3320
|
onKeyDown: handleKeyDown,
|
|
2459
3321
|
onFocus: handleFocus
|
|
2460
3322
|
};
|
|
3323
|
+
const tabStopIndex = focusedIndex === -1 ? 0 : focusedIndex;
|
|
2461
3324
|
const getItemProps = (0, import_react4.useCallback)(
|
|
2462
3325
|
(index) => ({
|
|
2463
|
-
tabIndex: index ===
|
|
3326
|
+
tabIndex: index === tabStopIndex ? 0 : -1,
|
|
2464
3327
|
onFocus: () => {
|
|
2465
|
-
|
|
3328
|
+
setFocusedIndex(index);
|
|
2466
3329
|
}
|
|
2467
3330
|
}),
|
|
2468
|
-
[]
|
|
3331
|
+
[tabStopIndex, setFocusedIndex]
|
|
2469
3332
|
);
|
|
2470
3333
|
return {
|
|
2471
3334
|
containerProps,
|
|
@@ -2583,34 +3446,6 @@ function useRovingTabindex(options = {}) {
|
|
|
2583
3446
|
};
|
|
2584
3447
|
}
|
|
2585
3448
|
|
|
2586
|
-
// src/hooks/useEscapeKey.ts
|
|
2587
|
-
var React23 = __toESM(require("react"));
|
|
2588
|
-
function useEscapeKey(callback, options) {
|
|
2589
|
-
const { enabled = true, preventDefault = true, stopPropagation = false } = options ?? {};
|
|
2590
|
-
const callbackRef = React23.useRef(callback);
|
|
2591
|
-
React23.useEffect(() => {
|
|
2592
|
-
callbackRef.current = callback;
|
|
2593
|
-
}, [callback]);
|
|
2594
|
-
React23.useEffect(() => {
|
|
2595
|
-
if (!enabled) return;
|
|
2596
|
-
const handleKeyDown = (event) => {
|
|
2597
|
-
if (event.key === "Escape") {
|
|
2598
|
-
if (preventDefault) {
|
|
2599
|
-
event.preventDefault();
|
|
2600
|
-
}
|
|
2601
|
-
if (stopPropagation) {
|
|
2602
|
-
event.stopPropagation();
|
|
2603
|
-
}
|
|
2604
|
-
callbackRef.current(event);
|
|
2605
|
-
}
|
|
2606
|
-
};
|
|
2607
|
-
document.addEventListener("keydown", handleKeyDown);
|
|
2608
|
-
return () => {
|
|
2609
|
-
document.removeEventListener("keydown", handleKeyDown);
|
|
2610
|
-
};
|
|
2611
|
-
}, [enabled, preventDefault, stopPropagation]);
|
|
2612
|
-
}
|
|
2613
|
-
|
|
2614
3449
|
// src/hooks/useClickOutside.ts
|
|
2615
3450
|
var React24 = __toESM(require("react"));
|
|
2616
3451
|
function useClickOutside(ref, callback, options) {
|
|
@@ -2620,9 +3455,12 @@ function useClickOutside(ref, callback, options) {
|
|
|
2620
3455
|
ignoreElements = []
|
|
2621
3456
|
} = options ?? {};
|
|
2622
3457
|
const callbackRef = React24.useRef(callback);
|
|
3458
|
+
const ignoreElementsRef = React24.useRef(ignoreElements);
|
|
2623
3459
|
React24.useEffect(() => {
|
|
2624
3460
|
callbackRef.current = callback;
|
|
2625
|
-
|
|
3461
|
+
ignoreElementsRef.current = ignoreElements;
|
|
3462
|
+
}, [callback, ignoreElements]);
|
|
3463
|
+
const eventsKey = events.join(",");
|
|
2626
3464
|
React24.useEffect(() => {
|
|
2627
3465
|
if (!enabled) return;
|
|
2628
3466
|
const handleEvent = (event) => {
|
|
@@ -2630,22 +3468,23 @@ function useClickOutside(ref, callback, options) {
|
|
|
2630
3468
|
if (ref.current?.contains(target)) {
|
|
2631
3469
|
return;
|
|
2632
3470
|
}
|
|
2633
|
-
for (const ignoreRef of
|
|
3471
|
+
for (const ignoreRef of ignoreElementsRef.current) {
|
|
2634
3472
|
if (ignoreRef.current?.contains(target)) {
|
|
2635
3473
|
return;
|
|
2636
3474
|
}
|
|
2637
3475
|
}
|
|
2638
3476
|
callbackRef.current(event);
|
|
2639
3477
|
};
|
|
2640
|
-
|
|
3478
|
+
const eventTypes = eventsKey.split(",");
|
|
3479
|
+
eventTypes.forEach((eventType) => {
|
|
2641
3480
|
document.addEventListener(eventType, handleEvent);
|
|
2642
3481
|
});
|
|
2643
3482
|
return () => {
|
|
2644
|
-
|
|
3483
|
+
eventTypes.forEach((eventType) => {
|
|
2645
3484
|
document.removeEventListener(eventType, handleEvent);
|
|
2646
3485
|
});
|
|
2647
3486
|
};
|
|
2648
|
-
}, [enabled,
|
|
3487
|
+
}, [enabled, eventsKey, ref]);
|
|
2649
3488
|
}
|
|
2650
3489
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2651
3490
|
0 && (module.exports = {
|