@classic-homes/theme-react 0.1.56 → 0.1.58
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 +41 -3
- package/dist/index.d.ts +41 -3
- package/dist/index.js +917 -92
- package/dist/index.mjs +927 -92
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -767,6 +767,10 @@ function useEscapeKey(callback, options) {
|
|
|
767
767
|
import {
|
|
768
768
|
DEFAULT_PANEL_STATE,
|
|
769
769
|
DEFAULT_CONSTRAINTS,
|
|
770
|
+
DEFAULT_CARD_CONFIG,
|
|
771
|
+
CARD_HEADER_HEIGHT,
|
|
772
|
+
CARD_EXPANDED_RATIO,
|
|
773
|
+
CARD_MIN_WIDTH,
|
|
770
774
|
loadPanelState,
|
|
771
775
|
savePanelState,
|
|
772
776
|
getPointerPosition,
|
|
@@ -776,6 +780,7 @@ import {
|
|
|
776
780
|
getPinnedResizeHandle,
|
|
777
781
|
constrainSize,
|
|
778
782
|
constrainPosition,
|
|
783
|
+
constrainResize,
|
|
779
784
|
constrainPinnedWidth,
|
|
780
785
|
constrainPinnedHeight,
|
|
781
786
|
detectEdgeSnap,
|
|
@@ -783,6 +788,11 @@ import {
|
|
|
783
788
|
getDetachedPositionStyles,
|
|
784
789
|
getInitialDetachedPosition,
|
|
785
790
|
isHorizontalEdge,
|
|
791
|
+
constrainTabOffset,
|
|
792
|
+
getTabTransform,
|
|
793
|
+
getTabBounds,
|
|
794
|
+
TAB_THICKNESS,
|
|
795
|
+
DEFAULT_TAB_WIDTH,
|
|
786
796
|
calculateDetachDistance,
|
|
787
797
|
calculatePullOffset,
|
|
788
798
|
calculateDetachedPositionFromPinned,
|
|
@@ -838,7 +848,8 @@ function useDataPanel(options = {}) {
|
|
|
838
848
|
detachedPosition,
|
|
839
849
|
detachedSize,
|
|
840
850
|
pinnedSize,
|
|
841
|
-
cardSnapIndex: 0
|
|
851
|
+
cardSnapIndex: 0,
|
|
852
|
+
tabOffset: 0
|
|
842
853
|
});
|
|
843
854
|
}, 300);
|
|
844
855
|
}, [persistKey, mode, edge, isExpanded, detachedPosition, detachedSize, pinnedSize]);
|
|
@@ -955,6 +966,24 @@ var CloseIcon = () => /* @__PURE__ */ jsxs5(
|
|
|
955
966
|
]
|
|
956
967
|
}
|
|
957
968
|
);
|
|
969
|
+
var GripIcon = () => /* @__PURE__ */ jsxs5(
|
|
970
|
+
"svg",
|
|
971
|
+
{
|
|
972
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
973
|
+
width: "16",
|
|
974
|
+
height: "16",
|
|
975
|
+
viewBox: "0 0 24 24",
|
|
976
|
+
fill: "currentColor",
|
|
977
|
+
children: [
|
|
978
|
+
/* @__PURE__ */ jsx12("circle", { cx: "9", cy: "6", r: "1.5" }),
|
|
979
|
+
/* @__PURE__ */ jsx12("circle", { cx: "15", cy: "6", r: "1.5" }),
|
|
980
|
+
/* @__PURE__ */ jsx12("circle", { cx: "9", cy: "12", r: "1.5" }),
|
|
981
|
+
/* @__PURE__ */ jsx12("circle", { cx: "15", cy: "12", r: "1.5" }),
|
|
982
|
+
/* @__PURE__ */ jsx12("circle", { cx: "9", cy: "18", r: "1.5" }),
|
|
983
|
+
/* @__PURE__ */ jsx12("circle", { cx: "15", cy: "18", r: "1.5" })
|
|
984
|
+
]
|
|
985
|
+
}
|
|
986
|
+
);
|
|
958
987
|
var edgeLabels = {
|
|
959
988
|
left: "Pin to left",
|
|
960
989
|
right: "Pin to right",
|
|
@@ -1001,11 +1030,27 @@ var DataPanelHeader = React14.forwardRef(
|
|
|
1001
1030
|
"button",
|
|
1002
1031
|
{
|
|
1003
1032
|
type: "button",
|
|
1004
|
-
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",
|
|
1005
|
-
onClick: () =>
|
|
1033
|
+
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",
|
|
1034
|
+
onClick: () => {
|
|
1035
|
+
if (mode === "detached") {
|
|
1036
|
+
onModeChange?.("pinned");
|
|
1037
|
+
onExpandedChange?.(false);
|
|
1038
|
+
} else {
|
|
1039
|
+
onExpandedChange?.(!isExpanded);
|
|
1040
|
+
}
|
|
1041
|
+
},
|
|
1006
1042
|
"aria-label": isExpanded ? "Collapse panel" : "Expand panel",
|
|
1007
1043
|
"aria-expanded": isExpanded,
|
|
1008
|
-
children: /* @__PURE__ */ jsx12(
|
|
1044
|
+
children: /* @__PURE__ */ jsx12(
|
|
1045
|
+
"span",
|
|
1046
|
+
{
|
|
1047
|
+
className: cn(
|
|
1048
|
+
"transition-transform",
|
|
1049
|
+
{ top: "", bottom: "rotate-180", left: "-rotate-90", right: "rotate-90" }[edge]
|
|
1050
|
+
),
|
|
1051
|
+
children: /* @__PURE__ */ jsx12(ChevronUpIcon, {})
|
|
1052
|
+
}
|
|
1053
|
+
)
|
|
1009
1054
|
}
|
|
1010
1055
|
),
|
|
1011
1056
|
!disableModeSwitch && /* @__PURE__ */ jsxs5(DropdownMenuPrimitive.Root, { children: [
|
|
@@ -1013,7 +1058,7 @@ var DataPanelHeader = React14.forwardRef(
|
|
|
1013
1058
|
"button",
|
|
1014
1059
|
{
|
|
1015
1060
|
type: "button",
|
|
1016
|
-
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",
|
|
1061
|
+
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",
|
|
1017
1062
|
"aria-label": "Panel options",
|
|
1018
1063
|
children: /* @__PURE__ */ jsx12(MoreVerticalIcon, {})
|
|
1019
1064
|
}
|
|
@@ -1061,7 +1106,7 @@ var DataPanelHeader = React14.forwardRef(
|
|
|
1061
1106
|
"button",
|
|
1062
1107
|
{
|
|
1063
1108
|
type: "button",
|
|
1064
|
-
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",
|
|
1109
|
+
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",
|
|
1065
1110
|
onClick: onClose,
|
|
1066
1111
|
"aria-label": "Close panel",
|
|
1067
1112
|
children: /* @__PURE__ */ jsx12(CloseIcon, {})
|
|
@@ -1074,6 +1119,93 @@ var DataPanelHeader = React14.forwardRef(
|
|
|
1074
1119
|
}
|
|
1075
1120
|
);
|
|
1076
1121
|
DataPanelHeader.displayName = "DataPanelHeader";
|
|
1122
|
+
function DataPanelCardHeader({
|
|
1123
|
+
title,
|
|
1124
|
+
subtitle,
|
|
1125
|
+
titleId,
|
|
1126
|
+
isExpanded,
|
|
1127
|
+
isMobile,
|
|
1128
|
+
showDragHandle,
|
|
1129
|
+
headerContent,
|
|
1130
|
+
headerActions,
|
|
1131
|
+
disableClose = false,
|
|
1132
|
+
onHeaderPointerDown,
|
|
1133
|
+
onToggleExpand,
|
|
1134
|
+
onClose
|
|
1135
|
+
}) {
|
|
1136
|
+
return /* @__PURE__ */ jsxs5(
|
|
1137
|
+
"div",
|
|
1138
|
+
{
|
|
1139
|
+
"data-panel-header": true,
|
|
1140
|
+
className: "relative flex items-center justify-between gap-2 border-b border-border bg-muted/30 px-4 pt-5 pb-3 cursor-pointer",
|
|
1141
|
+
onPointerDown: onHeaderPointerDown,
|
|
1142
|
+
children: [
|
|
1143
|
+
showDragHandle && /* @__PURE__ */ jsx12(
|
|
1144
|
+
"div",
|
|
1145
|
+
{
|
|
1146
|
+
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",
|
|
1147
|
+
role: "button",
|
|
1148
|
+
tabIndex: 0,
|
|
1149
|
+
"aria-label": isExpanded ? "Collapse panel" : "Expand panel",
|
|
1150
|
+
"aria-expanded": isExpanded,
|
|
1151
|
+
onPointerDown: onHeaderPointerDown,
|
|
1152
|
+
onKeyDown: (e) => (e.key === "Enter" || e.key === " ") && onToggleExpand()
|
|
1153
|
+
}
|
|
1154
|
+
),
|
|
1155
|
+
/* @__PURE__ */ jsx12(
|
|
1156
|
+
"div",
|
|
1157
|
+
{
|
|
1158
|
+
className: "flex-1 min-w-0",
|
|
1159
|
+
role: "button",
|
|
1160
|
+
tabIndex: 0,
|
|
1161
|
+
onKeyDown: (e) => (e.key === "Enter" || e.key === " ") && onToggleExpand(),
|
|
1162
|
+
children: headerContent ? headerContent : /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
1163
|
+
subtitle && /* @__PURE__ */ jsx12("p", { className: "text-sm text-muted-foreground truncate", children: subtitle }),
|
|
1164
|
+
title && /* @__PURE__ */ jsx12("h3", { id: titleId, className: "text-lg font-semibold truncate", children: title })
|
|
1165
|
+
] })
|
|
1166
|
+
}
|
|
1167
|
+
),
|
|
1168
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-1 shrink-0", children: [
|
|
1169
|
+
headerActions,
|
|
1170
|
+
!isMobile && /* @__PURE__ */ jsx12(
|
|
1171
|
+
"button",
|
|
1172
|
+
{
|
|
1173
|
+
"data-card-drag-handle": true,
|
|
1174
|
+
type: "button",
|
|
1175
|
+
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",
|
|
1176
|
+
"aria-label": "Drag to reposition panel",
|
|
1177
|
+
title: "Drag to move",
|
|
1178
|
+
onPointerDown: onHeaderPointerDown,
|
|
1179
|
+
children: /* @__PURE__ */ jsx12(GripIcon, {})
|
|
1180
|
+
}
|
|
1181
|
+
),
|
|
1182
|
+
/* @__PURE__ */ jsx12(
|
|
1183
|
+
"button",
|
|
1184
|
+
{
|
|
1185
|
+
type: "button",
|
|
1186
|
+
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",
|
|
1187
|
+
onClick: onToggleExpand,
|
|
1188
|
+
"aria-expanded": isExpanded,
|
|
1189
|
+
"aria-label": isExpanded ? "Collapse panel" : "Expand panel",
|
|
1190
|
+
title: isExpanded ? "Collapse" : "Expand",
|
|
1191
|
+
children: /* @__PURE__ */ jsx12("span", { className: cn("inline-flex transition-transform", isExpanded && "rotate-180"), children: /* @__PURE__ */ jsx12(ChevronUpIcon, {}) })
|
|
1192
|
+
}
|
|
1193
|
+
),
|
|
1194
|
+
!disableClose && /* @__PURE__ */ jsx12(
|
|
1195
|
+
"button",
|
|
1196
|
+
{
|
|
1197
|
+
type: "button",
|
|
1198
|
+
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",
|
|
1199
|
+
onClick: onClose,
|
|
1200
|
+
"aria-label": "Close panel",
|
|
1201
|
+
children: /* @__PURE__ */ jsx12(CloseIcon, {})
|
|
1202
|
+
}
|
|
1203
|
+
)
|
|
1204
|
+
] })
|
|
1205
|
+
]
|
|
1206
|
+
}
|
|
1207
|
+
);
|
|
1208
|
+
}
|
|
1077
1209
|
var DataPanelContent = React14.forwardRef(
|
|
1078
1210
|
({ children, className, "aria-label": ariaLabel = "Panel content" }, ref) => {
|
|
1079
1211
|
return /* @__PURE__ */ jsx12(
|
|
@@ -1126,36 +1258,178 @@ var DataPanelFooter = React14.forwardRef(
|
|
|
1126
1258
|
);
|
|
1127
1259
|
DataPanelFooter.displayName = "DataPanelFooter";
|
|
1128
1260
|
var DataPanelTab = React14.forwardRef(
|
|
1129
|
-
({
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1261
|
+
({
|
|
1262
|
+
title = "Panel",
|
|
1263
|
+
subtitle,
|
|
1264
|
+
edge,
|
|
1265
|
+
onClick,
|
|
1266
|
+
onClose,
|
|
1267
|
+
disableClose = false,
|
|
1268
|
+
offset = 0,
|
|
1269
|
+
onOffsetChange,
|
|
1270
|
+
tabWidth = DEFAULT_TAB_WIDTH,
|
|
1271
|
+
tabInset = 0,
|
|
1272
|
+
className
|
|
1273
|
+
}, ref) => {
|
|
1136
1274
|
const isVertical = edge === "left" || edge === "right";
|
|
1137
|
-
const
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1275
|
+
const positionClasses = {
|
|
1276
|
+
// Border classes are in the chip's pre-rotation frame: its bottom rotates
|
|
1277
|
+
// to the attached (edge) side and its top corners to the viewport-facing
|
|
1278
|
+
// corners, so both side edges drop the bottom border and round the top.
|
|
1279
|
+
// The anchored axis is set inline (see insetStyle) so tabInset can move it.
|
|
1280
|
+
left: "top-1/2 rounded-t-lg border-b-0",
|
|
1281
|
+
right: "top-1/2 rounded-t-lg border-b-0",
|
|
1282
|
+
top: "left-1/2 rounded-b-lg border-t-0",
|
|
1283
|
+
bottom: "left-1/2 rounded-t-lg border-b-0"
|
|
1142
1284
|
}[edge];
|
|
1285
|
+
const insetStyle = { [edge]: tabInset };
|
|
1286
|
+
const innerRef = React14.useRef(null);
|
|
1287
|
+
const dragRef = React14.useRef({
|
|
1288
|
+
startX: 0,
|
|
1289
|
+
startY: 0,
|
|
1290
|
+
startOffset: 0,
|
|
1291
|
+
moved: false,
|
|
1292
|
+
pointerId: -1
|
|
1293
|
+
});
|
|
1294
|
+
const [dragOffset, setDragOffset] = React14.useState(null);
|
|
1295
|
+
const effectiveOffset = dragOffset ?? offset;
|
|
1296
|
+
const draggable = !!onOffsetChange;
|
|
1297
|
+
const tabTransform = getTabTransform(edge, tabWidth, effectiveOffset);
|
|
1298
|
+
const tabBounds = getTabBounds(edge, tabWidth);
|
|
1299
|
+
const setRefs = (node) => {
|
|
1300
|
+
innerRef.current = node;
|
|
1301
|
+
if (typeof ref === "function") ref(node);
|
|
1302
|
+
else if (ref) ref.current = node;
|
|
1303
|
+
};
|
|
1304
|
+
const handlePointerDown = (e) => {
|
|
1305
|
+
if (!draggable) return;
|
|
1306
|
+
if (e.pointerType === "mouse" && e.button !== 0) return;
|
|
1307
|
+
if (e.target.closest("[data-no-drag]")) return;
|
|
1308
|
+
dragRef.current = {
|
|
1309
|
+
startX: e.clientX,
|
|
1310
|
+
startY: e.clientY,
|
|
1311
|
+
startOffset: offset,
|
|
1312
|
+
moved: false,
|
|
1313
|
+
pointerId: e.pointerId
|
|
1314
|
+
};
|
|
1315
|
+
setDragOffset(offset);
|
|
1316
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
1317
|
+
};
|
|
1318
|
+
const handlePointerMove = (e) => {
|
|
1319
|
+
const d = dragRef.current;
|
|
1320
|
+
if (d.pointerId !== e.pointerId || !e.currentTarget.hasPointerCapture(e.pointerId)) return;
|
|
1321
|
+
const delta = isVertical ? e.clientY - d.startY : e.clientX - d.startX;
|
|
1322
|
+
if (Math.abs(delta) > 3) d.moved = true;
|
|
1323
|
+
setDragOffset(
|
|
1324
|
+
constrainTabOffset(
|
|
1325
|
+
d.startOffset + delta,
|
|
1326
|
+
edge,
|
|
1327
|
+
tabBounds,
|
|
1328
|
+
window.innerWidth,
|
|
1329
|
+
window.innerHeight
|
|
1330
|
+
)
|
|
1331
|
+
);
|
|
1332
|
+
};
|
|
1333
|
+
const handlePointerUp = (e) => {
|
|
1334
|
+
const d = dragRef.current;
|
|
1335
|
+
if (d.pointerId !== e.pointerId) return;
|
|
1336
|
+
if (e.currentTarget.hasPointerCapture(e.pointerId)) {
|
|
1337
|
+
e.currentTarget.releasePointerCapture(e.pointerId);
|
|
1338
|
+
}
|
|
1339
|
+
d.pointerId = -1;
|
|
1340
|
+
if (d.moved) {
|
|
1341
|
+
onOffsetChange?.(dragOffset ?? offset);
|
|
1342
|
+
} else {
|
|
1343
|
+
onClick?.();
|
|
1344
|
+
}
|
|
1345
|
+
setDragOffset(null);
|
|
1346
|
+
};
|
|
1347
|
+
const handlePointerCancel = (e) => {
|
|
1348
|
+
const d = dragRef.current;
|
|
1349
|
+
if (d.pointerId !== e.pointerId) return;
|
|
1350
|
+
if (e.currentTarget.hasPointerCapture(e.pointerId)) {
|
|
1351
|
+
e.currentTarget.releasePointerCapture(e.pointerId);
|
|
1352
|
+
}
|
|
1353
|
+
d.pointerId = -1;
|
|
1354
|
+
d.moved = false;
|
|
1355
|
+
setDragOffset(null);
|
|
1356
|
+
};
|
|
1357
|
+
const handleExpandKeyDown = (e) => {
|
|
1358
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
1359
|
+
e.preventDefault();
|
|
1360
|
+
onClick?.();
|
|
1361
|
+
}
|
|
1362
|
+
};
|
|
1363
|
+
React14.useEffect(() => {
|
|
1364
|
+
if (!onOffsetChange || dragOffset !== null) return;
|
|
1365
|
+
const reclamp = () => {
|
|
1366
|
+
const clamped = constrainTabOffset(
|
|
1367
|
+
offset,
|
|
1368
|
+
edge,
|
|
1369
|
+
tabBounds,
|
|
1370
|
+
window.innerWidth,
|
|
1371
|
+
window.innerHeight
|
|
1372
|
+
);
|
|
1373
|
+
if (clamped !== offset) onOffsetChange(clamped);
|
|
1374
|
+
};
|
|
1375
|
+
reclamp();
|
|
1376
|
+
window.addEventListener("resize", reclamp);
|
|
1377
|
+
return () => window.removeEventListener("resize", reclamp);
|
|
1378
|
+
}, [edge, tabWidth, offset, onOffsetChange, dragOffset]);
|
|
1143
1379
|
return /* @__PURE__ */ jsxs5(
|
|
1144
|
-
"
|
|
1380
|
+
"div",
|
|
1145
1381
|
{
|
|
1146
|
-
ref,
|
|
1147
|
-
type: "button",
|
|
1382
|
+
ref: setRefs,
|
|
1148
1383
|
className: cn(
|
|
1149
|
-
|
|
1384
|
+
// Same layer as the expanded panel: the tab is the only way to bring
|
|
1385
|
+
// the panel back, so it must never sit under chrome the panel covers.
|
|
1386
|
+
"fixed z-50 flex 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",
|
|
1387
|
+
draggable && "cursor-grab touch-none active:cursor-grabbing",
|
|
1150
1388
|
positionClasses,
|
|
1151
|
-
isVertical && "[writing-mode:vertical-rl]",
|
|
1152
1389
|
className
|
|
1153
1390
|
),
|
|
1154
|
-
|
|
1155
|
-
|
|
1391
|
+
style: {
|
|
1392
|
+
...insetStyle,
|
|
1393
|
+
width: tabWidth,
|
|
1394
|
+
// Side tabs rotate, so they need a fixed thickness for a deterministic
|
|
1395
|
+
// edge hug; top/bottom stay content-height.
|
|
1396
|
+
height: isVertical ? TAB_THICKNESS : void 0,
|
|
1397
|
+
transformOrigin: "0 0",
|
|
1398
|
+
transform: tabTransform
|
|
1399
|
+
},
|
|
1400
|
+
onPointerDown: handlePointerDown,
|
|
1401
|
+
onPointerMove: draggable ? handlePointerMove : void 0,
|
|
1402
|
+
onPointerUp: draggable ? handlePointerUp : void 0,
|
|
1403
|
+
onPointerCancel: draggable ? handlePointerCancel : void 0,
|
|
1156
1404
|
children: [
|
|
1157
|
-
/* @__PURE__ */
|
|
1158
|
-
|
|
1405
|
+
/* @__PURE__ */ jsxs5(
|
|
1406
|
+
"button",
|
|
1407
|
+
{
|
|
1408
|
+
type: "button",
|
|
1409
|
+
"aria-label": `Expand ${title} panel`,
|
|
1410
|
+
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",
|
|
1411
|
+
onClick: draggable ? void 0 : onClick,
|
|
1412
|
+
onKeyDown: handleExpandKeyDown,
|
|
1413
|
+
children: [
|
|
1414
|
+
/* @__PURE__ */ jsx12("span", { className: "truncate text-sm font-semibold", children: title }),
|
|
1415
|
+
subtitle && /* @__PURE__ */ jsx12("span", { className: "truncate text-xs text-muted-foreground", children: subtitle })
|
|
1416
|
+
]
|
|
1417
|
+
}
|
|
1418
|
+
),
|
|
1419
|
+
!disableClose && onClose && /* @__PURE__ */ jsx12(
|
|
1420
|
+
"button",
|
|
1421
|
+
{
|
|
1422
|
+
"data-no-drag": true,
|
|
1423
|
+
type: "button",
|
|
1424
|
+
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",
|
|
1425
|
+
"aria-label": "Close panel",
|
|
1426
|
+
onClick: (e) => {
|
|
1427
|
+
e.stopPropagation();
|
|
1428
|
+
onClose();
|
|
1429
|
+
},
|
|
1430
|
+
children: /* @__PURE__ */ jsx12(CloseIcon, {})
|
|
1431
|
+
}
|
|
1432
|
+
)
|
|
1159
1433
|
]
|
|
1160
1434
|
}
|
|
1161
1435
|
);
|
|
@@ -1167,62 +1441,76 @@ var KEYBOARD_RESIZE_STEP_LARGE = 50;
|
|
|
1167
1441
|
function ResizeHandles({
|
|
1168
1442
|
mode,
|
|
1169
1443
|
edge,
|
|
1444
|
+
detachedPosition,
|
|
1170
1445
|
detachedSize,
|
|
1171
1446
|
pinnedSize,
|
|
1172
1447
|
onResizeStart,
|
|
1173
|
-
|
|
1448
|
+
onDetachedResize,
|
|
1174
1449
|
onPinnedSizeChange,
|
|
1175
1450
|
constraints
|
|
1176
1451
|
}) {
|
|
1177
1452
|
const handleDetachedKeyDown = React14.useCallback(
|
|
1178
1453
|
(e, handle) => {
|
|
1179
1454
|
const step = e.shiftKey ? KEYBOARD_RESIZE_STEP_LARGE : KEYBOARD_RESIZE_STEP;
|
|
1180
|
-
let
|
|
1455
|
+
let width = detachedSize.width;
|
|
1456
|
+
let height = detachedSize.height;
|
|
1181
1457
|
let handled = false;
|
|
1182
1458
|
switch (e.key) {
|
|
1183
1459
|
case "ArrowUp":
|
|
1184
1460
|
if (handle.includes("top")) {
|
|
1185
|
-
|
|
1461
|
+
height += step;
|
|
1186
1462
|
handled = true;
|
|
1187
1463
|
} else if (handle.includes("bottom")) {
|
|
1188
|
-
|
|
1464
|
+
height -= step;
|
|
1189
1465
|
handled = true;
|
|
1190
1466
|
}
|
|
1191
1467
|
break;
|
|
1192
1468
|
case "ArrowDown":
|
|
1193
1469
|
if (handle.includes("top")) {
|
|
1194
|
-
|
|
1470
|
+
height -= step;
|
|
1195
1471
|
handled = true;
|
|
1196
1472
|
} else if (handle.includes("bottom")) {
|
|
1197
|
-
|
|
1473
|
+
height += step;
|
|
1198
1474
|
handled = true;
|
|
1199
1475
|
}
|
|
1200
1476
|
break;
|
|
1201
1477
|
case "ArrowLeft":
|
|
1202
1478
|
if (handle.includes("left")) {
|
|
1203
|
-
|
|
1479
|
+
width += step;
|
|
1204
1480
|
handled = true;
|
|
1205
1481
|
} else if (handle.includes("right")) {
|
|
1206
|
-
|
|
1482
|
+
width -= step;
|
|
1207
1483
|
handled = true;
|
|
1208
1484
|
}
|
|
1209
1485
|
break;
|
|
1210
1486
|
case "ArrowRight":
|
|
1211
1487
|
if (handle.includes("left")) {
|
|
1212
|
-
|
|
1488
|
+
width -= step;
|
|
1213
1489
|
handled = true;
|
|
1214
1490
|
} else if (handle.includes("right")) {
|
|
1215
|
-
|
|
1491
|
+
width += step;
|
|
1216
1492
|
handled = true;
|
|
1217
1493
|
}
|
|
1218
1494
|
break;
|
|
1219
1495
|
}
|
|
1220
1496
|
if (handled) {
|
|
1221
1497
|
e.preventDefault();
|
|
1222
|
-
|
|
1498
|
+
const candidatePosition = {
|
|
1499
|
+
x: handle.includes("left") ? detachedPosition.x + (detachedSize.width - width) : detachedPosition.x,
|
|
1500
|
+
y: handle.includes("top") ? detachedPosition.y + (detachedSize.height - height) : detachedPosition.y
|
|
1501
|
+
};
|
|
1502
|
+
const { position, size } = constrainResize(
|
|
1503
|
+
candidatePosition,
|
|
1504
|
+
{ width, height },
|
|
1505
|
+
constraints,
|
|
1506
|
+
typeof window === "undefined" ? 1024 : window.innerWidth,
|
|
1507
|
+
typeof window === "undefined" ? 768 : window.innerHeight,
|
|
1508
|
+
handle
|
|
1509
|
+
);
|
|
1510
|
+
onDetachedResize(position, size);
|
|
1223
1511
|
}
|
|
1224
1512
|
},
|
|
1225
|
-
[detachedSize, constraints,
|
|
1513
|
+
[detachedPosition, detachedSize, constraints, onDetachedResize]
|
|
1226
1514
|
);
|
|
1227
1515
|
const handlePinnedKeyDown = React14.useCallback(
|
|
1228
1516
|
(e) => {
|
|
@@ -1347,6 +1635,8 @@ var DataPanel = React14.forwardRef(
|
|
|
1347
1635
|
onOpenChange,
|
|
1348
1636
|
mode: controlledMode,
|
|
1349
1637
|
onModeChange,
|
|
1638
|
+
variant: controlledVariant,
|
|
1639
|
+
cardConfig = {},
|
|
1350
1640
|
edge: controlledEdge,
|
|
1351
1641
|
onEdgeChange,
|
|
1352
1642
|
expanded: controlledExpanded,
|
|
@@ -1356,6 +1646,8 @@ var DataPanel = React14.forwardRef(
|
|
|
1356
1646
|
children,
|
|
1357
1647
|
actions = [],
|
|
1358
1648
|
constraints = {},
|
|
1649
|
+
tabWidth = DEFAULT_TAB_WIDTH,
|
|
1650
|
+
tabInset = 0,
|
|
1359
1651
|
disableClose = false,
|
|
1360
1652
|
disableResize = false,
|
|
1361
1653
|
disableDrag = false,
|
|
@@ -1369,11 +1661,21 @@ var DataPanel = React14.forwardRef(
|
|
|
1369
1661
|
footerActions,
|
|
1370
1662
|
className
|
|
1371
1663
|
}, ref) => {
|
|
1372
|
-
const resolvedConstraints =
|
|
1664
|
+
const resolvedConstraints = React14.useMemo(
|
|
1665
|
+
() => ({ ...DEFAULT_CONSTRAINTS, ...constraints }),
|
|
1666
|
+
[constraints]
|
|
1667
|
+
);
|
|
1668
|
+
const resolvedCardConfig = React14.useMemo(
|
|
1669
|
+
() => ({ ...DEFAULT_CARD_CONFIG, ...cardConfig }),
|
|
1670
|
+
[cardConfig]
|
|
1671
|
+
);
|
|
1373
1672
|
const panelId = React14.useId();
|
|
1374
1673
|
const titleId = `${panelId}-title`;
|
|
1375
1674
|
const [internalOpen, setInternalOpen] = React14.useState(true);
|
|
1376
1675
|
const [internalMode, setInternalMode] = React14.useState(DEFAULT_PANEL_STATE.mode);
|
|
1676
|
+
const [internalVariant, setInternalVariant] = React14.useState(
|
|
1677
|
+
DEFAULT_PANEL_STATE.variant
|
|
1678
|
+
);
|
|
1377
1679
|
const [internalEdge, setInternalEdge] = React14.useState(DEFAULT_PANEL_STATE.edge);
|
|
1378
1680
|
const [internalExpanded, setInternalExpanded] = React14.useState(
|
|
1379
1681
|
DEFAULT_PANEL_STATE.isExpanded
|
|
@@ -1383,6 +1685,23 @@ var DataPanel = React14.forwardRef(
|
|
|
1383
1685
|
);
|
|
1384
1686
|
const [detachedSize, setDetachedSize] = React14.useState(DEFAULT_PANEL_STATE.detachedSize);
|
|
1385
1687
|
const [pinnedSize, setPinnedSize] = React14.useState(DEFAULT_PANEL_STATE.pinnedSize);
|
|
1688
|
+
const [tabOffset, setTabOffset] = React14.useState(DEFAULT_PANEL_STATE.tabOffset);
|
|
1689
|
+
const [viewportWidth, setViewportWidth] = React14.useState(
|
|
1690
|
+
typeof window !== "undefined" ? window.innerWidth : 1024
|
|
1691
|
+
);
|
|
1692
|
+
const [viewportHeight, setViewportHeight] = React14.useState(
|
|
1693
|
+
typeof window !== "undefined" ? window.innerHeight : 768
|
|
1694
|
+
);
|
|
1695
|
+
const isMobile = viewportWidth < 640;
|
|
1696
|
+
const [cardHorizontalPosition, setCardHorizontalPosition] = React14.useState(0);
|
|
1697
|
+
const [cardExpandedHeight, setCardExpandedHeight] = React14.useState(0);
|
|
1698
|
+
const [cardWidth, setCardWidth] = React14.useState(null);
|
|
1699
|
+
const [cardDragCurrentHeight, setCardDragCurrentHeight] = React14.useState(CARD_HEADER_HEIGHT);
|
|
1700
|
+
const [isCardVerticalDragging, setIsCardVerticalDragging] = React14.useState(false);
|
|
1701
|
+
const [isCardHorizontalDragging, setIsCardHorizontalDragging] = React14.useState(false);
|
|
1702
|
+
const [isCardHeightTransitioning, setIsCardHeightTransitioning] = React14.useState(false);
|
|
1703
|
+
const [isCardWidthResizing, setIsCardWidthResizing] = React14.useState(false);
|
|
1704
|
+
const [isCardTopResizing, setIsCardTopResizing] = React14.useState(false);
|
|
1386
1705
|
const [isDragging, setIsDragging] = React14.useState(false);
|
|
1387
1706
|
const [isResizing, setIsResizing] = React14.useState(false);
|
|
1388
1707
|
const [snapPreview, setSnapPreview] = React14.useState(null);
|
|
@@ -1402,11 +1721,40 @@ var DataPanel = React14.forwardRef(
|
|
|
1402
1721
|
startSize: { width: 0, height: 0 },
|
|
1403
1722
|
startPanelPosition: { x: 0, y: 0 }
|
|
1404
1723
|
});
|
|
1724
|
+
const cardDragStateRef = React14.useRef({
|
|
1725
|
+
startY: 0,
|
|
1726
|
+
startX: 0,
|
|
1727
|
+
startTime: 0,
|
|
1728
|
+
startExpanded: false,
|
|
1729
|
+
startHorizontalPosition: 0
|
|
1730
|
+
});
|
|
1731
|
+
const cardCurrentHeightRef = React14.useRef(CARD_HEADER_HEIGHT);
|
|
1732
|
+
const cardTopResizeStartRef = React14.useRef({ startY: 0, startHeight: 0 });
|
|
1733
|
+
const cardWidthResizeStateRef = React14.useRef({
|
|
1734
|
+
handle: null,
|
|
1735
|
+
startX: 0,
|
|
1736
|
+
startWidth: 0,
|
|
1737
|
+
startLeft: 0
|
|
1738
|
+
});
|
|
1405
1739
|
const open = controlledOpen ?? internalOpen;
|
|
1406
1740
|
const mode = controlledMode ?? internalMode;
|
|
1741
|
+
const variant = controlledVariant ?? internalVariant;
|
|
1407
1742
|
const edge = controlledEdge ?? internalEdge;
|
|
1408
1743
|
const isExpanded = controlledExpanded ?? internalExpanded;
|
|
1744
|
+
const showContent = variant !== "card" || isExpanded || isCardVerticalDragging;
|
|
1409
1745
|
const saveTimeoutRef = React14.useRef(null);
|
|
1746
|
+
const isMountedRef = React14.useRef(true);
|
|
1747
|
+
React14.useEffect(() => {
|
|
1748
|
+
isMountedRef.current = true;
|
|
1749
|
+
return () => {
|
|
1750
|
+
isMountedRef.current = false;
|
|
1751
|
+
if (saveTimeoutRef.current) clearTimeout(saveTimeoutRef.current);
|
|
1752
|
+
if (typeof document !== "undefined") {
|
|
1753
|
+
document.body.style.cursor = "";
|
|
1754
|
+
document.body.style.userSelect = "";
|
|
1755
|
+
}
|
|
1756
|
+
};
|
|
1757
|
+
}, []);
|
|
1410
1758
|
const debouncedSave = React14.useCallback(() => {
|
|
1411
1759
|
if (!persistKey) return;
|
|
1412
1760
|
if (saveTimeoutRef.current) {
|
|
@@ -1415,32 +1763,48 @@ var DataPanel = React14.forwardRef(
|
|
|
1415
1763
|
saveTimeoutRef.current = setTimeout(() => {
|
|
1416
1764
|
savePanelState(persistKey, {
|
|
1417
1765
|
mode,
|
|
1418
|
-
variant
|
|
1766
|
+
variant,
|
|
1419
1767
|
edge,
|
|
1420
1768
|
isExpanded,
|
|
1421
1769
|
detachedPosition,
|
|
1422
1770
|
detachedSize,
|
|
1423
1771
|
pinnedSize,
|
|
1424
|
-
cardSnapIndex: 0
|
|
1772
|
+
cardSnapIndex: 0,
|
|
1773
|
+
tabOffset
|
|
1425
1774
|
});
|
|
1426
1775
|
}, 300);
|
|
1427
|
-
}, [
|
|
1776
|
+
}, [
|
|
1777
|
+
persistKey,
|
|
1778
|
+
mode,
|
|
1779
|
+
variant,
|
|
1780
|
+
edge,
|
|
1781
|
+
isExpanded,
|
|
1782
|
+
detachedPosition,
|
|
1783
|
+
detachedSize,
|
|
1784
|
+
pinnedSize,
|
|
1785
|
+
tabOffset
|
|
1786
|
+
]);
|
|
1428
1787
|
React14.useEffect(() => {
|
|
1429
1788
|
debouncedSave();
|
|
1430
1789
|
}, [debouncedSave]);
|
|
1790
|
+
const hasLoadedRef = React14.useRef(false);
|
|
1431
1791
|
React14.useEffect(() => {
|
|
1432
|
-
if (!persistKey) return;
|
|
1792
|
+
if (!persistKey || hasLoadedRef.current) return;
|
|
1793
|
+
hasLoadedRef.current = true;
|
|
1433
1794
|
const persisted = loadPanelState(persistKey);
|
|
1434
1795
|
if (persisted) {
|
|
1435
1796
|
if (controlledMode === void 0 && persisted.mode) setInternalMode(persisted.mode);
|
|
1797
|
+
if (controlledVariant === void 0 && persisted.variant)
|
|
1798
|
+
setInternalVariant(persisted.variant);
|
|
1436
1799
|
if (controlledEdge === void 0 && persisted.edge) setInternalEdge(persisted.edge);
|
|
1437
1800
|
if (controlledExpanded === void 0 && persisted.isExpanded !== void 0)
|
|
1438
1801
|
setInternalExpanded(persisted.isExpanded);
|
|
1439
1802
|
if (persisted.detachedPosition) setDetachedPosition(persisted.detachedPosition);
|
|
1440
1803
|
if (persisted.detachedSize) setDetachedSize(persisted.detachedSize);
|
|
1441
1804
|
if (persisted.pinnedSize) setPinnedSize(persisted.pinnedSize);
|
|
1805
|
+
if (persisted.tabOffset !== void 0) setTabOffset(persisted.tabOffset);
|
|
1442
1806
|
}
|
|
1443
|
-
}, [persistKey, controlledMode, controlledEdge, controlledExpanded]);
|
|
1807
|
+
}, [persistKey, controlledMode, controlledVariant, controlledEdge, controlledExpanded]);
|
|
1444
1808
|
React14.useEffect(() => {
|
|
1445
1809
|
if (mode === "detached" && detachedPosition.x === DEFAULT_PANEL_STATE.detachedPosition.x && detachedPosition.y === DEFAULT_PANEL_STATE.detachedPosition.y) {
|
|
1446
1810
|
setDetachedPosition(
|
|
@@ -1454,13 +1818,13 @@ var DataPanel = React14.forwardRef(
|
|
|
1454
1818
|
}
|
|
1455
1819
|
onOpenChange?.(newOpen);
|
|
1456
1820
|
};
|
|
1457
|
-
const
|
|
1458
|
-
const focusTrapRef = useFocusTrap({ active:
|
|
1821
|
+
const isDialog = open && (mode === "detached" || variant === "card" && isExpanded && isMobile);
|
|
1822
|
+
const focusTrapRef = useFocusTrap({ active: isDialog });
|
|
1459
1823
|
useEscapeKey(
|
|
1460
1824
|
() => {
|
|
1461
1825
|
if (!disableClose) handleOpenChange(false);
|
|
1462
1826
|
},
|
|
1463
|
-
{ enabled:
|
|
1827
|
+
{ enabled: isDialog }
|
|
1464
1828
|
);
|
|
1465
1829
|
const setPanelRef = (node) => {
|
|
1466
1830
|
focusTrapRef.current = node;
|
|
@@ -1470,24 +1834,34 @@ var DataPanel = React14.forwardRef(
|
|
|
1470
1834
|
ref.current = node;
|
|
1471
1835
|
}
|
|
1472
1836
|
};
|
|
1473
|
-
const handleModeChange = (
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
}
|
|
1489
|
-
|
|
1490
|
-
|
|
1837
|
+
const handleModeChange = React14.useCallback(
|
|
1838
|
+
(newMode) => {
|
|
1839
|
+
if (controlledMode === void 0) {
|
|
1840
|
+
setInternalMode(newMode);
|
|
1841
|
+
}
|
|
1842
|
+
onModeChange?.(newMode);
|
|
1843
|
+
},
|
|
1844
|
+
[controlledMode, onModeChange]
|
|
1845
|
+
);
|
|
1846
|
+
const handleEdgeChange = React14.useCallback(
|
|
1847
|
+
(newEdge) => {
|
|
1848
|
+
if (controlledEdge === void 0) {
|
|
1849
|
+
setInternalEdge(newEdge);
|
|
1850
|
+
}
|
|
1851
|
+
onEdgeChange?.(newEdge);
|
|
1852
|
+
},
|
|
1853
|
+
[controlledEdge, onEdgeChange]
|
|
1854
|
+
);
|
|
1855
|
+
const handleExpandedChange = React14.useCallback(
|
|
1856
|
+
(newExpanded) => {
|
|
1857
|
+
if (controlledExpanded === void 0) {
|
|
1858
|
+
setInternalExpanded(newExpanded);
|
|
1859
|
+
}
|
|
1860
|
+
onExpandedChange?.(newExpanded);
|
|
1861
|
+
},
|
|
1862
|
+
[controlledExpanded, onExpandedChange]
|
|
1863
|
+
);
|
|
1864
|
+
const handleToggleExpand = () => handleExpandedChange(!isExpanded);
|
|
1491
1865
|
const handleDragStart = (e) => {
|
|
1492
1866
|
if (disableDrag) return;
|
|
1493
1867
|
const target = e.target;
|
|
@@ -1624,12 +1998,13 @@ var DataPanel = React14.forwardRef(
|
|
|
1624
1998
|
},
|
|
1625
1999
|
currentPos
|
|
1626
2000
|
);
|
|
1627
|
-
const constrainedSize =
|
|
1628
|
-
const constrainedPosition = constrainPosition(
|
|
2001
|
+
const { position: constrainedPosition, size: constrainedSize } = constrainResize(
|
|
1629
2002
|
result.position,
|
|
1630
|
-
|
|
2003
|
+
result.size,
|
|
2004
|
+
resolvedConstraints,
|
|
1631
2005
|
window.innerWidth,
|
|
1632
|
-
window.innerHeight
|
|
2006
|
+
window.innerHeight,
|
|
2007
|
+
handle
|
|
1633
2008
|
);
|
|
1634
2009
|
setDetachedSize(constrainedSize);
|
|
1635
2010
|
setDetachedPosition(constrainedPosition);
|
|
@@ -1653,13 +2028,269 @@ var DataPanel = React14.forwardRef(
|
|
|
1653
2028
|
document.body.style.cursor = "";
|
|
1654
2029
|
document.body.style.userSelect = "";
|
|
1655
2030
|
}, [isResizing]);
|
|
2031
|
+
const handleCardHeaderPointerDown = (e) => {
|
|
2032
|
+
if (variant !== "card") return;
|
|
2033
|
+
const target = e.target;
|
|
2034
|
+
const isDragHandle = target.closest("[data-card-drag-handle]");
|
|
2035
|
+
if (!isDragHandle && target.closest("button")) return;
|
|
2036
|
+
const pos = getPointerPosition(e.nativeEvent);
|
|
2037
|
+
cardDragStateRef.current = {
|
|
2038
|
+
startY: pos.y,
|
|
2039
|
+
startX: pos.x,
|
|
2040
|
+
startTime: Date.now(),
|
|
2041
|
+
startExpanded: isExpanded,
|
|
2042
|
+
startHorizontalPosition: cardHorizontalPosition
|
|
2043
|
+
};
|
|
2044
|
+
const startHeight = isExpanded ? cardExpandedHeight : CARD_HEADER_HEIGHT;
|
|
2045
|
+
setCardDragCurrentHeight(startHeight);
|
|
2046
|
+
cardCurrentHeightRef.current = startHeight;
|
|
2047
|
+
if (isMobile) {
|
|
2048
|
+
setIsCardVerticalDragging(true);
|
|
2049
|
+
} else if (isDragHandle) {
|
|
2050
|
+
setIsCardHorizontalDragging(true);
|
|
2051
|
+
} else {
|
|
2052
|
+
setIsCardVerticalDragging(true);
|
|
2053
|
+
}
|
|
2054
|
+
document.body.style.userSelect = "none";
|
|
2055
|
+
};
|
|
2056
|
+
const handleCardPointerMove = React14.useCallback(
|
|
2057
|
+
(e) => {
|
|
2058
|
+
const currentPos = getPointerPosition(e);
|
|
2059
|
+
if (isCardVerticalDragging) {
|
|
2060
|
+
const deltaY = cardDragStateRef.current.startY - currentPos.y;
|
|
2061
|
+
const startHeight = cardDragStateRef.current.startExpanded ? cardExpandedHeight : CARD_HEADER_HEIGHT;
|
|
2062
|
+
const next = Math.max(
|
|
2063
|
+
CARD_HEADER_HEIGHT,
|
|
2064
|
+
Math.min(viewportHeight * 0.95, startHeight + deltaY)
|
|
2065
|
+
);
|
|
2066
|
+
setCardDragCurrentHeight(next);
|
|
2067
|
+
cardCurrentHeightRef.current = next;
|
|
2068
|
+
}
|
|
2069
|
+
if (isCardHorizontalDragging && !isMobile) {
|
|
2070
|
+
const deltaX = currentPos.x - cardDragStateRef.current.startX;
|
|
2071
|
+
const cw = Math.min(
|
|
2072
|
+
viewportWidth - resolvedCardConfig.horizontalMargin * 2,
|
|
2073
|
+
resolvedCardConfig.maxWidth
|
|
2074
|
+
);
|
|
2075
|
+
const defaultLeftOffset = Math.max(
|
|
2076
|
+
resolvedCardConfig.horizontalMargin,
|
|
2077
|
+
(viewportWidth - cw) / 2
|
|
2078
|
+
);
|
|
2079
|
+
const minOffset = -(defaultLeftOffset - resolvedCardConfig.horizontalMargin);
|
|
2080
|
+
const maxOffset = viewportWidth - cw - defaultLeftOffset - resolvedCardConfig.horizontalMargin;
|
|
2081
|
+
const nextPos = cardDragStateRef.current.startHorizontalPosition + deltaX;
|
|
2082
|
+
setCardHorizontalPosition(Math.max(minOffset, Math.min(maxOffset, nextPos)));
|
|
2083
|
+
}
|
|
2084
|
+
},
|
|
2085
|
+
[
|
|
2086
|
+
isCardVerticalDragging,
|
|
2087
|
+
isCardHorizontalDragging,
|
|
2088
|
+
isMobile,
|
|
2089
|
+
viewportWidth,
|
|
2090
|
+
viewportHeight,
|
|
2091
|
+
cardExpandedHeight,
|
|
2092
|
+
resolvedCardConfig.horizontalMargin,
|
|
2093
|
+
resolvedCardConfig.maxWidth
|
|
2094
|
+
]
|
|
2095
|
+
);
|
|
2096
|
+
const handleCardPointerUp = React14.useCallback(
|
|
2097
|
+
(e) => {
|
|
2098
|
+
const endTime = Date.now();
|
|
2099
|
+
const currentPos = getPointerPosition(e);
|
|
2100
|
+
const st = cardDragStateRef.current;
|
|
2101
|
+
const deltaTime = endTime - st.startTime;
|
|
2102
|
+
const deltaY = st.startY - currentPos.y;
|
|
2103
|
+
document.body.style.userSelect = "";
|
|
2104
|
+
if (isCardVerticalDragging) {
|
|
2105
|
+
if (deltaTime < 200 && Math.abs(deltaY) < 10) {
|
|
2106
|
+
setIsCardVerticalDragging(false);
|
|
2107
|
+
handleExpandedChange(!isExpanded);
|
|
2108
|
+
return;
|
|
2109
|
+
}
|
|
2110
|
+
const velocity = deltaY / deltaTime;
|
|
2111
|
+
let newExpanded;
|
|
2112
|
+
if (Math.abs(velocity) > resolvedCardConfig.swipeVelocityThreshold) {
|
|
2113
|
+
newExpanded = velocity > 0;
|
|
2114
|
+
} else {
|
|
2115
|
+
const midpoint = (CARD_HEADER_HEIGHT + cardExpandedHeight) / 2;
|
|
2116
|
+
newExpanded = cardCurrentHeightRef.current > midpoint;
|
|
2117
|
+
}
|
|
2118
|
+
const targetHeight = newExpanded ? cardExpandedHeight : CARD_HEADER_HEIGHT;
|
|
2119
|
+
setIsCardVerticalDragging(false);
|
|
2120
|
+
setIsCardHeightTransitioning(true);
|
|
2121
|
+
handleExpandedChange(newExpanded);
|
|
2122
|
+
requestAnimationFrame(() => {
|
|
2123
|
+
if (!isMountedRef.current) return;
|
|
2124
|
+
setCardDragCurrentHeight(targetHeight);
|
|
2125
|
+
cardCurrentHeightRef.current = targetHeight;
|
|
2126
|
+
});
|
|
2127
|
+
}
|
|
2128
|
+
if (isCardHorizontalDragging) {
|
|
2129
|
+
setIsCardHorizontalDragging(false);
|
|
2130
|
+
debouncedSave();
|
|
2131
|
+
}
|
|
2132
|
+
},
|
|
2133
|
+
[
|
|
2134
|
+
isCardVerticalDragging,
|
|
2135
|
+
isCardHorizontalDragging,
|
|
2136
|
+
isExpanded,
|
|
2137
|
+
cardExpandedHeight,
|
|
2138
|
+
resolvedCardConfig.swipeVelocityThreshold,
|
|
2139
|
+
handleExpandedChange,
|
|
2140
|
+
debouncedSave
|
|
2141
|
+
]
|
|
2142
|
+
);
|
|
2143
|
+
const handleCardResizeStart = (e) => {
|
|
2144
|
+
if (variant !== "card" || !isExpanded || disableResize || isMobile) return;
|
|
2145
|
+
e.preventDefault();
|
|
2146
|
+
e.stopPropagation();
|
|
2147
|
+
setIsCardTopResizing(true);
|
|
2148
|
+
const pos = getPointerPosition(e.nativeEvent);
|
|
2149
|
+
cardTopResizeStartRef.current = { startY: pos.y, startHeight: cardExpandedHeight };
|
|
2150
|
+
document.body.style.cursor = "ns-resize";
|
|
2151
|
+
document.body.style.userSelect = "none";
|
|
2152
|
+
};
|
|
2153
|
+
const handleCardResizeMove = React14.useCallback(
|
|
2154
|
+
(e) => {
|
|
2155
|
+
if (!isCardTopResizing) return;
|
|
2156
|
+
const currentPos = getPointerPosition(e);
|
|
2157
|
+
const deltaY = cardTopResizeStartRef.current.startY - currentPos.y;
|
|
2158
|
+
const newHeight = Math.max(
|
|
2159
|
+
CARD_HEADER_HEIGHT * 2,
|
|
2160
|
+
Math.min(viewportHeight * 0.95, cardTopResizeStartRef.current.startHeight + deltaY)
|
|
2161
|
+
);
|
|
2162
|
+
setCardExpandedHeight(newHeight);
|
|
2163
|
+
},
|
|
2164
|
+
[isCardTopResizing, viewportHeight]
|
|
2165
|
+
);
|
|
2166
|
+
const handleCardResizeEnd = React14.useCallback(() => {
|
|
2167
|
+
if (!isCardTopResizing) return;
|
|
2168
|
+
setIsCardTopResizing(false);
|
|
2169
|
+
document.body.style.cursor = "";
|
|
2170
|
+
document.body.style.userSelect = "";
|
|
2171
|
+
debouncedSave();
|
|
2172
|
+
}, [isCardTopResizing, debouncedSave]);
|
|
2173
|
+
const handleCardWidthResizeStart = (e, handle) => {
|
|
2174
|
+
if (variant !== "card" || !isExpanded || disableResize || isMobile) return;
|
|
2175
|
+
e.preventDefault();
|
|
2176
|
+
e.stopPropagation();
|
|
2177
|
+
const pos = getPointerPosition(e.nativeEvent);
|
|
2178
|
+
const defaultCardWidth = Math.min(
|
|
2179
|
+
viewportWidth - resolvedCardConfig.horizontalMargin * 2,
|
|
2180
|
+
resolvedCardConfig.maxWidth
|
|
2181
|
+
);
|
|
2182
|
+
const currentWidth = cardWidth ?? defaultCardWidth;
|
|
2183
|
+
const defaultLeftOffset = Math.max(
|
|
2184
|
+
resolvedCardConfig.horizontalMargin,
|
|
2185
|
+
(viewportWidth - defaultCardWidth) / 2
|
|
2186
|
+
);
|
|
2187
|
+
cardWidthResizeStateRef.current = {
|
|
2188
|
+
handle,
|
|
2189
|
+
startX: pos.x,
|
|
2190
|
+
startWidth: currentWidth,
|
|
2191
|
+
startLeft: defaultLeftOffset + cardHorizontalPosition
|
|
2192
|
+
};
|
|
2193
|
+
setIsCardWidthResizing(true);
|
|
2194
|
+
document.body.style.cursor = "ew-resize";
|
|
2195
|
+
document.body.style.userSelect = "none";
|
|
2196
|
+
};
|
|
2197
|
+
const handleCardWidthResizeMove = React14.useCallback(
|
|
2198
|
+
(e) => {
|
|
2199
|
+
const st = cardWidthResizeStateRef.current;
|
|
2200
|
+
if (!isCardWidthResizing || !st.handle) return;
|
|
2201
|
+
const currentPos = getPointerPosition(e);
|
|
2202
|
+
const deltaX = currentPos.x - st.startX;
|
|
2203
|
+
if (st.handle === "right") {
|
|
2204
|
+
const newWidth = Math.max(
|
|
2205
|
+
CARD_MIN_WIDTH,
|
|
2206
|
+
Math.min(
|
|
2207
|
+
resolvedCardConfig.maxWidth,
|
|
2208
|
+
viewportWidth - st.startLeft - resolvedCardConfig.horizontalMargin,
|
|
2209
|
+
st.startWidth + deltaX
|
|
2210
|
+
)
|
|
2211
|
+
);
|
|
2212
|
+
setCardWidth(newWidth);
|
|
2213
|
+
} else {
|
|
2214
|
+
const newLeft = st.startLeft + deltaX;
|
|
2215
|
+
const newWidth = st.startWidth - deltaX;
|
|
2216
|
+
if (newLeft >= resolvedCardConfig.horizontalMargin && newWidth >= CARD_MIN_WIDTH) {
|
|
2217
|
+
setCardWidth(Math.min(newWidth, resolvedCardConfig.maxWidth));
|
|
2218
|
+
const defaultCardWidth = Math.min(
|
|
2219
|
+
viewportWidth - resolvedCardConfig.horizontalMargin * 2,
|
|
2220
|
+
resolvedCardConfig.maxWidth
|
|
2221
|
+
);
|
|
2222
|
+
const defaultLeftOffset = Math.max(
|
|
2223
|
+
resolvedCardConfig.horizontalMargin,
|
|
2224
|
+
(viewportWidth - defaultCardWidth) / 2
|
|
2225
|
+
);
|
|
2226
|
+
setCardHorizontalPosition(newLeft - defaultLeftOffset);
|
|
2227
|
+
}
|
|
2228
|
+
}
|
|
2229
|
+
},
|
|
2230
|
+
[
|
|
2231
|
+
isCardWidthResizing,
|
|
2232
|
+
viewportWidth,
|
|
2233
|
+
resolvedCardConfig.horizontalMargin,
|
|
2234
|
+
resolvedCardConfig.maxWidth
|
|
2235
|
+
]
|
|
2236
|
+
);
|
|
2237
|
+
const handleCardWidthResizeEnd = React14.useCallback(() => {
|
|
2238
|
+
if (!isCardWidthResizing) return;
|
|
2239
|
+
setIsCardWidthResizing(false);
|
|
2240
|
+
cardWidthResizeStateRef.current.handle = null;
|
|
2241
|
+
document.body.style.cursor = "";
|
|
2242
|
+
document.body.style.userSelect = "";
|
|
2243
|
+
debouncedSave();
|
|
2244
|
+
}, [isCardWidthResizing, debouncedSave]);
|
|
2245
|
+
const cardDefaultWidth = Math.min(
|
|
2246
|
+
viewportWidth - resolvedCardConfig.horizontalMargin * 2,
|
|
2247
|
+
resolvedCardConfig.maxWidth
|
|
2248
|
+
);
|
|
2249
|
+
const cardCurrentWidth = cardWidth ?? cardDefaultWidth;
|
|
2250
|
+
const cardHeightMin = CARD_HEADER_HEIGHT * 2;
|
|
2251
|
+
const cardHeightMax = Math.round(viewportHeight * 0.95);
|
|
2252
|
+
const handleCardResizeKeyDown = (e, kind) => {
|
|
2253
|
+
if (disableResize) return;
|
|
2254
|
+
const step = e.shiftKey ? KEYBOARD_RESIZE_STEP_LARGE : KEYBOARD_RESIZE_STEP;
|
|
2255
|
+
if (kind === "height") {
|
|
2256
|
+
let delta = 0;
|
|
2257
|
+
if (e.key === "ArrowUp") delta = step;
|
|
2258
|
+
else if (e.key === "ArrowDown") delta = -step;
|
|
2259
|
+
else return;
|
|
2260
|
+
e.preventDefault();
|
|
2261
|
+
setCardExpandedHeight((h) => Math.max(cardHeightMin, Math.min(cardHeightMax, h + delta)));
|
|
2262
|
+
debouncedSave();
|
|
2263
|
+
return;
|
|
2264
|
+
}
|
|
2265
|
+
let widthDelta = 0;
|
|
2266
|
+
if (kind === "width-right") {
|
|
2267
|
+
if (e.key === "ArrowRight") widthDelta = step;
|
|
2268
|
+
else if (e.key === "ArrowLeft") widthDelta = -step;
|
|
2269
|
+
} else {
|
|
2270
|
+
if (e.key === "ArrowLeft") widthDelta = step;
|
|
2271
|
+
else if (e.key === "ArrowRight") widthDelta = -step;
|
|
2272
|
+
}
|
|
2273
|
+
if (widthDelta === 0) return;
|
|
2274
|
+
e.preventDefault();
|
|
2275
|
+
const maxWidth = Math.min(
|
|
2276
|
+
resolvedCardConfig.maxWidth,
|
|
2277
|
+
viewportWidth - resolvedCardConfig.horizontalMargin * 2
|
|
2278
|
+
);
|
|
2279
|
+
const nextWidth = Math.max(CARD_MIN_WIDTH, Math.min(maxWidth, cardCurrentWidth + widthDelta));
|
|
2280
|
+
const appliedDelta = nextWidth - cardCurrentWidth;
|
|
2281
|
+
setCardWidth(nextWidth);
|
|
2282
|
+
if (kind === "width-left") setCardHorizontalPosition((p) => p - appliedDelta);
|
|
2283
|
+
debouncedSave();
|
|
2284
|
+
};
|
|
1656
2285
|
React14.useEffect(() => {
|
|
1657
2286
|
if (isDragging) {
|
|
1658
2287
|
window.addEventListener("pointermove", handleDragMove);
|
|
1659
2288
|
window.addEventListener("pointerup", handleDragEnd);
|
|
2289
|
+
window.addEventListener("pointercancel", handleDragEnd);
|
|
1660
2290
|
return () => {
|
|
1661
2291
|
window.removeEventListener("pointermove", handleDragMove);
|
|
1662
2292
|
window.removeEventListener("pointerup", handleDragEnd);
|
|
2293
|
+
window.removeEventListener("pointercancel", handleDragEnd);
|
|
1663
2294
|
};
|
|
1664
2295
|
}
|
|
1665
2296
|
}, [isDragging, handleDragMove, handleDragEnd]);
|
|
@@ -1667,9 +2298,11 @@ var DataPanel = React14.forwardRef(
|
|
|
1667
2298
|
if (isPinnedDragging) {
|
|
1668
2299
|
window.addEventListener("pointermove", handlePinnedDragMove);
|
|
1669
2300
|
window.addEventListener("pointerup", handlePinnedDragEnd);
|
|
2301
|
+
window.addEventListener("pointercancel", handlePinnedDragEnd);
|
|
1670
2302
|
return () => {
|
|
1671
2303
|
window.removeEventListener("pointermove", handlePinnedDragMove);
|
|
1672
2304
|
window.removeEventListener("pointerup", handlePinnedDragEnd);
|
|
2305
|
+
window.removeEventListener("pointercancel", handlePinnedDragEnd);
|
|
1673
2306
|
};
|
|
1674
2307
|
}
|
|
1675
2308
|
}, [isPinnedDragging, handlePinnedDragMove, handlePinnedDragEnd]);
|
|
@@ -1677,13 +2310,98 @@ var DataPanel = React14.forwardRef(
|
|
|
1677
2310
|
if (isResizing) {
|
|
1678
2311
|
window.addEventListener("pointermove", handleResizeMove);
|
|
1679
2312
|
window.addEventListener("pointerup", handleResizeEnd);
|
|
2313
|
+
window.addEventListener("pointercancel", handleResizeEnd);
|
|
1680
2314
|
return () => {
|
|
1681
2315
|
window.removeEventListener("pointermove", handleResizeMove);
|
|
1682
2316
|
window.removeEventListener("pointerup", handleResizeEnd);
|
|
2317
|
+
window.removeEventListener("pointercancel", handleResizeEnd);
|
|
1683
2318
|
};
|
|
1684
2319
|
}
|
|
1685
2320
|
}, [isResizing, handleResizeMove, handleResizeEnd]);
|
|
2321
|
+
React14.useEffect(() => {
|
|
2322
|
+
if (isCardVerticalDragging || isCardHorizontalDragging) {
|
|
2323
|
+
window.addEventListener("pointermove", handleCardPointerMove);
|
|
2324
|
+
window.addEventListener("pointerup", handleCardPointerUp);
|
|
2325
|
+
window.addEventListener("pointercancel", handleCardPointerUp);
|
|
2326
|
+
return () => {
|
|
2327
|
+
window.removeEventListener("pointermove", handleCardPointerMove);
|
|
2328
|
+
window.removeEventListener("pointerup", handleCardPointerUp);
|
|
2329
|
+
window.removeEventListener("pointercancel", handleCardPointerUp);
|
|
2330
|
+
};
|
|
2331
|
+
}
|
|
2332
|
+
}, [
|
|
2333
|
+
isCardVerticalDragging,
|
|
2334
|
+
isCardHorizontalDragging,
|
|
2335
|
+
handleCardPointerMove,
|
|
2336
|
+
handleCardPointerUp
|
|
2337
|
+
]);
|
|
2338
|
+
React14.useEffect(() => {
|
|
2339
|
+
if (isCardTopResizing) {
|
|
2340
|
+
window.addEventListener("pointermove", handleCardResizeMove);
|
|
2341
|
+
window.addEventListener("pointerup", handleCardResizeEnd);
|
|
2342
|
+
window.addEventListener("pointercancel", handleCardResizeEnd);
|
|
2343
|
+
return () => {
|
|
2344
|
+
window.removeEventListener("pointermove", handleCardResizeMove);
|
|
2345
|
+
window.removeEventListener("pointerup", handleCardResizeEnd);
|
|
2346
|
+
window.removeEventListener("pointercancel", handleCardResizeEnd);
|
|
2347
|
+
};
|
|
2348
|
+
}
|
|
2349
|
+
}, [isCardTopResizing, handleCardResizeMove, handleCardResizeEnd]);
|
|
2350
|
+
React14.useEffect(() => {
|
|
2351
|
+
if (isCardWidthResizing) {
|
|
2352
|
+
window.addEventListener("pointermove", handleCardWidthResizeMove);
|
|
2353
|
+
window.addEventListener("pointerup", handleCardWidthResizeEnd);
|
|
2354
|
+
window.addEventListener("pointercancel", handleCardWidthResizeEnd);
|
|
2355
|
+
return () => {
|
|
2356
|
+
window.removeEventListener("pointermove", handleCardWidthResizeMove);
|
|
2357
|
+
window.removeEventListener("pointerup", handleCardWidthResizeEnd);
|
|
2358
|
+
window.removeEventListener("pointercancel", handleCardWidthResizeEnd);
|
|
2359
|
+
};
|
|
2360
|
+
}
|
|
2361
|
+
}, [isCardWidthResizing, handleCardWidthResizeMove, handleCardWidthResizeEnd]);
|
|
2362
|
+
React14.useEffect(() => {
|
|
2363
|
+
const onResize = () => {
|
|
2364
|
+
setViewportWidth(window.innerWidth);
|
|
2365
|
+
setViewportHeight(window.innerHeight);
|
|
2366
|
+
setCardExpandedHeight(window.innerHeight * CARD_EXPANDED_RATIO);
|
|
2367
|
+
};
|
|
2368
|
+
onResize();
|
|
2369
|
+
window.addEventListener("resize", onResize);
|
|
2370
|
+
return () => window.removeEventListener("resize", onResize);
|
|
2371
|
+
}, []);
|
|
2372
|
+
React14.useEffect(() => {
|
|
2373
|
+
if (isMobile && variant === "card") {
|
|
2374
|
+
setCardHorizontalPosition(0);
|
|
2375
|
+
setCardWidth(null);
|
|
2376
|
+
}
|
|
2377
|
+
}, [isMobile, variant]);
|
|
2378
|
+
React14.useEffect(() => {
|
|
2379
|
+
if (isCardHeightTransitioning) {
|
|
2380
|
+
const t = setTimeout(() => setIsCardHeightTransitioning(false), 350);
|
|
2381
|
+
return () => clearTimeout(t);
|
|
2382
|
+
}
|
|
2383
|
+
}, [isCardHeightTransitioning]);
|
|
1686
2384
|
const panelStyles = React14.useMemo(() => {
|
|
2385
|
+
if (variant === "card") {
|
|
2386
|
+
const defaultCardWidth = Math.min(
|
|
2387
|
+
viewportWidth - resolvedCardConfig.horizontalMargin * 2,
|
|
2388
|
+
resolvedCardConfig.maxWidth
|
|
2389
|
+
);
|
|
2390
|
+
const actualCardWidth = cardWidth ?? defaultCardWidth;
|
|
2391
|
+
const defaultLeftOffset = Math.max(
|
|
2392
|
+
resolvedCardConfig.horizontalMargin,
|
|
2393
|
+
(viewportWidth - defaultCardWidth) / 2
|
|
2394
|
+
);
|
|
2395
|
+
const height = isCardVerticalDragging || isCardHeightTransitioning ? cardDragCurrentHeight : isExpanded ? cardExpandedHeight : CARD_HEADER_HEIGHT;
|
|
2396
|
+
return {
|
|
2397
|
+
bottom: 0,
|
|
2398
|
+
left: defaultLeftOffset + cardHorizontalPosition,
|
|
2399
|
+
width: actualCardWidth,
|
|
2400
|
+
height,
|
|
2401
|
+
maxHeight: viewportHeight * 0.95,
|
|
2402
|
+
borderRadius: `${resolvedCardConfig.borderRadius}px ${resolvedCardConfig.borderRadius}px 0 0`
|
|
2403
|
+
};
|
|
2404
|
+
}
|
|
1687
2405
|
if (mode === "pinned") {
|
|
1688
2406
|
const baseStyles = getPinnedPositionStyles(edge, pinnedSize);
|
|
1689
2407
|
if (pullOffset > 0) {
|
|
@@ -1693,22 +2411,56 @@ var DataPanel = React14.forwardRef(
|
|
|
1693
2411
|
return baseStyles;
|
|
1694
2412
|
}
|
|
1695
2413
|
return getDetachedPositionStyles(detachedPosition, detachedSize);
|
|
1696
|
-
}, [
|
|
2414
|
+
}, [
|
|
2415
|
+
variant,
|
|
2416
|
+
mode,
|
|
2417
|
+
edge,
|
|
2418
|
+
pinnedSize,
|
|
2419
|
+
detachedPosition,
|
|
2420
|
+
detachedSize,
|
|
2421
|
+
pullOffset,
|
|
2422
|
+
viewportWidth,
|
|
2423
|
+
viewportHeight,
|
|
2424
|
+
cardWidth,
|
|
2425
|
+
cardHorizontalPosition,
|
|
2426
|
+
cardExpandedHeight,
|
|
2427
|
+
cardDragCurrentHeight,
|
|
2428
|
+
isCardVerticalDragging,
|
|
2429
|
+
isCardHeightTransitioning,
|
|
2430
|
+
isExpanded,
|
|
2431
|
+
resolvedCardConfig.horizontalMargin,
|
|
2432
|
+
resolvedCardConfig.maxWidth,
|
|
2433
|
+
resolvedCardConfig.borderRadius
|
|
2434
|
+
]);
|
|
1697
2435
|
const pinnedClasses = {
|
|
1698
2436
|
left: "left-0 top-0 bottom-0 border-r",
|
|
1699
2437
|
right: "right-0 top-0 bottom-0 border-l",
|
|
1700
2438
|
top: "top-0 left-0 right-0 border-b",
|
|
1701
2439
|
bottom: "bottom-0 left-0 right-0 border-t"
|
|
1702
2440
|
}[edge];
|
|
1703
|
-
const animationClass = mode === "pinned" ? {
|
|
2441
|
+
const animationClass = variant === "card" ? "animate-panel-slide-in-bottom" : mode === "pinned" ? {
|
|
1704
2442
|
left: "animate-slide-right",
|
|
1705
2443
|
right: "animate-slide-left",
|
|
1706
2444
|
top: "animate-slide-down",
|
|
1707
2445
|
bottom: "animate-slide-up"
|
|
1708
2446
|
}[edge] : "animate-scale-in";
|
|
1709
2447
|
if (!open) return null;
|
|
1710
|
-
if (!isExpanded && mode === "pinned") {
|
|
1711
|
-
return /* @__PURE__ */ jsx12(
|
|
2448
|
+
if (variant === "full" && !isExpanded && mode === "pinned") {
|
|
2449
|
+
return /* @__PURE__ */ jsx12(
|
|
2450
|
+
DataPanelTab,
|
|
2451
|
+
{
|
|
2452
|
+
title,
|
|
2453
|
+
subtitle,
|
|
2454
|
+
edge,
|
|
2455
|
+
onClick: () => handleExpandedChange(true),
|
|
2456
|
+
onClose: () => handleOpenChange(false),
|
|
2457
|
+
disableClose,
|
|
2458
|
+
offset: tabOffset,
|
|
2459
|
+
onOffsetChange: setTabOffset,
|
|
2460
|
+
tabWidth,
|
|
2461
|
+
tabInset
|
|
2462
|
+
}
|
|
2463
|
+
);
|
|
1712
2464
|
}
|
|
1713
2465
|
return /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
1714
2466
|
snapPreview && /* @__PURE__ */ jsx12(
|
|
@@ -1723,26 +2475,53 @@ var DataPanel = React14.forwardRef(
|
|
|
1723
2475
|
)
|
|
1724
2476
|
}
|
|
1725
2477
|
),
|
|
2478
|
+
variant === "card" && isExpanded && isMobile && /* @__PURE__ */ jsx12(
|
|
2479
|
+
"div",
|
|
2480
|
+
{
|
|
2481
|
+
className: "fixed inset-0 z-40 bg-black/50 transition-opacity",
|
|
2482
|
+
"aria-hidden": "true",
|
|
2483
|
+
onClick: handleToggleExpand
|
|
2484
|
+
}
|
|
2485
|
+
),
|
|
1726
2486
|
/* @__PURE__ */ jsxs5(
|
|
1727
2487
|
"div",
|
|
1728
2488
|
{
|
|
1729
2489
|
ref: setPanelRef,
|
|
1730
2490
|
className: cn(
|
|
1731
2491
|
"fixed z-50 flex flex-col bg-background border border-border shadow-lg overflow-hidden",
|
|
1732
|
-
mode === "pinned" && pinnedClasses,
|
|
1733
|
-
mode === "detached" && "rounded-lg",
|
|
2492
|
+
variant === "full" && mode === "pinned" && pinnedClasses,
|
|
2493
|
+
variant === "full" && mode === "detached" && "rounded-lg",
|
|
2494
|
+
variant === "card" && "rounded-t-lg border-b-0",
|
|
1734
2495
|
isPinnedDragging && pullOffset > 0 && "shadow-2xl",
|
|
2496
|
+
!isDragging && !isPinnedDragging && !isCardHorizontalDragging && !isCardVerticalDragging && !isResizing && !isCardTopResizing && !isCardWidthResizing && "transition-[height,left,width,transform] duration-300 ease-out",
|
|
1735
2497
|
animationClass,
|
|
1736
2498
|
className
|
|
1737
2499
|
),
|
|
1738
2500
|
style: panelStyles,
|
|
1739
|
-
role: mode === "detached" ? "dialog" : "complementary",
|
|
1740
|
-
"aria-modal":
|
|
2501
|
+
role: mode === "detached" || variant === "card" ? "dialog" : "complementary",
|
|
2502
|
+
"aria-modal": isDialog ? "true" : void 0,
|
|
1741
2503
|
"aria-labelledby": title ? titleId : void 0,
|
|
1742
2504
|
"aria-label": !title ? "Side panel" : void 0,
|
|
1743
|
-
|
|
2505
|
+
"aria-expanded": variant === "card" ? isExpanded : void 0,
|
|
2506
|
+
onPointerDown: variant === "full" ? handleDragStart : void 0,
|
|
1744
2507
|
children: [
|
|
1745
|
-
/* @__PURE__ */ jsx12(
|
|
2508
|
+
variant === "card" ? /* @__PURE__ */ jsx12(
|
|
2509
|
+
DataPanelCardHeader,
|
|
2510
|
+
{
|
|
2511
|
+
title,
|
|
2512
|
+
subtitle,
|
|
2513
|
+
titleId,
|
|
2514
|
+
isExpanded,
|
|
2515
|
+
isMobile,
|
|
2516
|
+
showDragHandle: resolvedCardConfig.showDragHandle,
|
|
2517
|
+
headerContent,
|
|
2518
|
+
headerActions,
|
|
2519
|
+
disableClose,
|
|
2520
|
+
onHeaderPointerDown: handleCardHeaderPointerDown,
|
|
2521
|
+
onToggleExpand: handleToggleExpand,
|
|
2522
|
+
onClose: () => handleOpenChange(false)
|
|
2523
|
+
}
|
|
2524
|
+
) : /* @__PURE__ */ jsx12(
|
|
1746
2525
|
DataPanelHeader,
|
|
1747
2526
|
{
|
|
1748
2527
|
title,
|
|
@@ -1762,24 +2541,30 @@ var DataPanel = React14.forwardRef(
|
|
|
1762
2541
|
draggable: !disableDrag && (mode === "detached" || mode === "pinned" && detachThreshold > 0)
|
|
1763
2542
|
}
|
|
1764
2543
|
),
|
|
1765
|
-
/* @__PURE__ */
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
2544
|
+
showContent && /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
2545
|
+
/* @__PURE__ */ jsx12(DataPanelContent, { children }),
|
|
2546
|
+
/* @__PURE__ */ jsx12(
|
|
2547
|
+
DataPanelFooter,
|
|
2548
|
+
{
|
|
2549
|
+
actions,
|
|
2550
|
+
footerContent,
|
|
2551
|
+
footerActions
|
|
2552
|
+
}
|
|
2553
|
+
)
|
|
2554
|
+
] }),
|
|
2555
|
+
variant === "full" && !disableResize && /* @__PURE__ */ jsx12(
|
|
1775
2556
|
ResizeHandles,
|
|
1776
2557
|
{
|
|
1777
2558
|
mode,
|
|
1778
2559
|
edge,
|
|
2560
|
+
detachedPosition,
|
|
1779
2561
|
detachedSize,
|
|
1780
2562
|
pinnedSize,
|
|
1781
2563
|
onResizeStart: handleResizeStart,
|
|
1782
|
-
|
|
2564
|
+
onDetachedResize: (position, size) => {
|
|
2565
|
+
setDetachedSize(size);
|
|
2566
|
+
setDetachedPosition(position);
|
|
2567
|
+
},
|
|
1783
2568
|
onPinnedSizeChange: (size) => {
|
|
1784
2569
|
if (typeof window === "undefined") {
|
|
1785
2570
|
setPinnedSize(size);
|
|
@@ -1795,7 +2580,57 @@ var DataPanel = React14.forwardRef(
|
|
|
1795
2580
|
},
|
|
1796
2581
|
constraints: resolvedConstraints
|
|
1797
2582
|
}
|
|
1798
|
-
)
|
|
2583
|
+
),
|
|
2584
|
+
variant === "card" && isExpanded && !disableResize && !isMobile && /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
2585
|
+
/* @__PURE__ */ jsx12(
|
|
2586
|
+
"div",
|
|
2587
|
+
{
|
|
2588
|
+
className: "resize-handle resize-handle--horizontal resize-handle--top",
|
|
2589
|
+
role: "slider",
|
|
2590
|
+
tabIndex: 0,
|
|
2591
|
+
"aria-orientation": "vertical",
|
|
2592
|
+
"aria-label": "Resize card height",
|
|
2593
|
+
"aria-valuenow": Math.round(cardExpandedHeight),
|
|
2594
|
+
"aria-valuemin": cardHeightMin,
|
|
2595
|
+
"aria-valuemax": cardHeightMax,
|
|
2596
|
+
"aria-valuetext": `${Math.round(cardExpandedHeight)} pixels`,
|
|
2597
|
+
onPointerDown: handleCardResizeStart,
|
|
2598
|
+
onKeyDown: (e) => handleCardResizeKeyDown(e, "height")
|
|
2599
|
+
}
|
|
2600
|
+
),
|
|
2601
|
+
/* @__PURE__ */ jsx12(
|
|
2602
|
+
"div",
|
|
2603
|
+
{
|
|
2604
|
+
className: "resize-handle resize-handle--vertical resize-handle--left resize-handle--card-edge",
|
|
2605
|
+
role: "slider",
|
|
2606
|
+
tabIndex: 0,
|
|
2607
|
+
"aria-orientation": "horizontal",
|
|
2608
|
+
"aria-label": "Resize card width from left edge",
|
|
2609
|
+
"aria-valuenow": Math.round(cardCurrentWidth),
|
|
2610
|
+
"aria-valuemin": CARD_MIN_WIDTH,
|
|
2611
|
+
"aria-valuemax": resolvedCardConfig.maxWidth,
|
|
2612
|
+
"aria-valuetext": `${Math.round(cardCurrentWidth)} pixels`,
|
|
2613
|
+
onPointerDown: (e) => handleCardWidthResizeStart(e, "left"),
|
|
2614
|
+
onKeyDown: (e) => handleCardResizeKeyDown(e, "width-left")
|
|
2615
|
+
}
|
|
2616
|
+
),
|
|
2617
|
+
/* @__PURE__ */ jsx12(
|
|
2618
|
+
"div",
|
|
2619
|
+
{
|
|
2620
|
+
className: "resize-handle resize-handle--vertical resize-handle--right resize-handle--card-edge",
|
|
2621
|
+
role: "slider",
|
|
2622
|
+
tabIndex: 0,
|
|
2623
|
+
"aria-orientation": "horizontal",
|
|
2624
|
+
"aria-label": "Resize card width from right edge",
|
|
2625
|
+
"aria-valuenow": Math.round(cardCurrentWidth),
|
|
2626
|
+
"aria-valuemin": CARD_MIN_WIDTH,
|
|
2627
|
+
"aria-valuemax": resolvedCardConfig.maxWidth,
|
|
2628
|
+
"aria-valuetext": `${Math.round(cardCurrentWidth)} pixels`,
|
|
2629
|
+
onPointerDown: (e) => handleCardWidthResizeStart(e, "right"),
|
|
2630
|
+
onKeyDown: (e) => handleCardResizeKeyDown(e, "width-right")
|
|
2631
|
+
}
|
|
2632
|
+
)
|
|
2633
|
+
] })
|
|
1799
2634
|
]
|
|
1800
2635
|
}
|
|
1801
2636
|
)
|