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