@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/dist/index.js CHANGED
@@ -910,7 +910,8 @@ function useDataPanel(options = {}) {
910
910
  detachedPosition,
911
911
  detachedSize,
912
912
  pinnedSize,
913
- cardSnapIndex: 0
913
+ cardSnapIndex: 0,
914
+ tabOffset: 0
914
915
  });
915
916
  }, 300);
916
917
  }, [persistKey, mode, edge, isExpanded, detachedPosition, detachedSize, pinnedSize]);
@@ -1027,6 +1028,24 @@ var CloseIcon = () => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1027
1028
  ]
1028
1029
  }
1029
1030
  );
1031
+ var GripIcon = () => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1032
+ "svg",
1033
+ {
1034
+ xmlns: "http://www.w3.org/2000/svg",
1035
+ width: "16",
1036
+ height: "16",
1037
+ viewBox: "0 0 24 24",
1038
+ fill: "currentColor",
1039
+ children: [
1040
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("circle", { cx: "9", cy: "6", r: "1.5" }),
1041
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("circle", { cx: "15", cy: "6", r: "1.5" }),
1042
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("circle", { cx: "9", cy: "12", r: "1.5" }),
1043
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("circle", { cx: "15", cy: "12", r: "1.5" }),
1044
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("circle", { cx: "9", cy: "18", r: "1.5" }),
1045
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("circle", { cx: "15", cy: "18", r: "1.5" })
1046
+ ]
1047
+ }
1048
+ );
1030
1049
  var edgeLabels = {
1031
1050
  left: "Pin to left",
1032
1051
  right: "Pin to right",
@@ -1073,11 +1092,27 @@ var DataPanelHeader = React14.forwardRef(
1073
1092
  "button",
1074
1093
  {
1075
1094
  type: "button",
1076
- 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",
1077
- onClick: () => onExpandedChange?.(!isExpanded),
1095
+ className: "relative flex h-8 w-8 items-center justify-center rounded-md before:absolute before:-inset-1.5 before:content-[''] bg-transparent text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
1096
+ onClick: () => {
1097
+ if (mode === "detached") {
1098
+ onModeChange?.("pinned");
1099
+ onExpandedChange?.(false);
1100
+ } else {
1101
+ onExpandedChange?.(!isExpanded);
1102
+ }
1103
+ },
1078
1104
  "aria-label": isExpanded ? "Collapse panel" : "Expand panel",
1079
1105
  "aria-expanded": isExpanded,
1080
- children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: cn("transition-transform", !isExpanded && "rotate-180"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChevronUpIcon, {}) })
1106
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1107
+ "span",
1108
+ {
1109
+ className: cn(
1110
+ "transition-transform",
1111
+ { top: "", bottom: "rotate-180", left: "-rotate-90", right: "rotate-90" }[edge]
1112
+ ),
1113
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChevronUpIcon, {})
1114
+ }
1115
+ )
1081
1116
  }
1082
1117
  ),
1083
1118
  !disableModeSwitch && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(DropdownMenuPrimitive.Root, { children: [
@@ -1085,7 +1120,7 @@ var DataPanelHeader = React14.forwardRef(
1085
1120
  "button",
1086
1121
  {
1087
1122
  type: "button",
1088
- className: "flex h-8 w-8 items-center justify-center rounded-md bg-transparent text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
1123
+ className: "relative flex h-8 w-8 items-center justify-center rounded-md before:absolute before:-inset-1.5 before:content-[''] bg-transparent text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
1089
1124
  "aria-label": "Panel options",
1090
1125
  children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(MoreVerticalIcon, {})
1091
1126
  }
@@ -1133,7 +1168,7 @@ var DataPanelHeader = React14.forwardRef(
1133
1168
  "button",
1134
1169
  {
1135
1170
  type: "button",
1136
- className: "flex h-8 w-8 items-center justify-center rounded-md bg-transparent text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
1171
+ className: "relative flex h-8 w-8 items-center justify-center rounded-md before:absolute before:-inset-1.5 before:content-[''] bg-transparent text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
1137
1172
  onClick: onClose,
1138
1173
  "aria-label": "Close panel",
1139
1174
  children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CloseIcon, {})
@@ -1146,6 +1181,93 @@ var DataPanelHeader = React14.forwardRef(
1146
1181
  }
1147
1182
  );
1148
1183
  DataPanelHeader.displayName = "DataPanelHeader";
1184
+ function DataPanelCardHeader({
1185
+ title,
1186
+ subtitle,
1187
+ titleId,
1188
+ isExpanded,
1189
+ isMobile,
1190
+ showDragHandle,
1191
+ headerContent,
1192
+ headerActions,
1193
+ disableClose = false,
1194
+ onHeaderPointerDown,
1195
+ onToggleExpand,
1196
+ onClose
1197
+ }) {
1198
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1199
+ "div",
1200
+ {
1201
+ "data-panel-header": true,
1202
+ className: "relative flex items-center justify-between gap-2 border-b border-border bg-muted/30 px-4 pt-5 pb-3 cursor-pointer",
1203
+ onPointerDown: onHeaderPointerDown,
1204
+ children: [
1205
+ showDragHandle && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1206
+ "div",
1207
+ {
1208
+ className: "absolute top-1.5 left-1/2 -translate-x-1/2 w-10 h-1.5 rounded-full bg-muted-foreground/30 cursor-pointer touch-none",
1209
+ role: "button",
1210
+ tabIndex: 0,
1211
+ "aria-label": isExpanded ? "Collapse panel" : "Expand panel",
1212
+ "aria-expanded": isExpanded,
1213
+ onPointerDown: onHeaderPointerDown,
1214
+ onKeyDown: (e) => (e.key === "Enter" || e.key === " ") && onToggleExpand()
1215
+ }
1216
+ ),
1217
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1218
+ "div",
1219
+ {
1220
+ className: "flex-1 min-w-0",
1221
+ role: "button",
1222
+ tabIndex: 0,
1223
+ onKeyDown: (e) => (e.key === "Enter" || e.key === " ") && onToggleExpand(),
1224
+ children: headerContent ? headerContent : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
1225
+ subtitle && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "text-sm text-muted-foreground truncate", children: subtitle }),
1226
+ title && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h3", { id: titleId, className: "text-lg font-semibold truncate", children: title })
1227
+ ] })
1228
+ }
1229
+ ),
1230
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center gap-1 shrink-0", children: [
1231
+ headerActions,
1232
+ !isMobile && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1233
+ "button",
1234
+ {
1235
+ "data-card-drag-handle": true,
1236
+ type: "button",
1237
+ className: "relative flex h-8 w-8 items-center justify-center rounded-md before:absolute before:-inset-1.5 before:content-[''] text-muted-foreground hover:bg-accent hover:text-accent-foreground cursor-move touch-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
1238
+ "aria-label": "Drag to reposition panel",
1239
+ title: "Drag to move",
1240
+ onPointerDown: onHeaderPointerDown,
1241
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(GripIcon, {})
1242
+ }
1243
+ ),
1244
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1245
+ "button",
1246
+ {
1247
+ type: "button",
1248
+ className: "relative flex h-8 w-8 items-center justify-center rounded-md before:absolute before:-inset-1.5 before:content-[''] text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
1249
+ onClick: onToggleExpand,
1250
+ "aria-expanded": isExpanded,
1251
+ "aria-label": isExpanded ? "Collapse panel" : "Expand panel",
1252
+ title: isExpanded ? "Collapse" : "Expand",
1253
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: cn("inline-flex transition-transform", isExpanded && "rotate-180"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChevronUpIcon, {}) })
1254
+ }
1255
+ ),
1256
+ !disableClose && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1257
+ "button",
1258
+ {
1259
+ type: "button",
1260
+ className: "relative flex h-8 w-8 items-center justify-center rounded-md before:absolute before:-inset-1.5 before:content-[''] text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
1261
+ onClick: onClose,
1262
+ "aria-label": "Close panel",
1263
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CloseIcon, {})
1264
+ }
1265
+ )
1266
+ ] })
1267
+ ]
1268
+ }
1269
+ );
1270
+ }
1149
1271
  var DataPanelContent = React14.forwardRef(
1150
1272
  ({ children, className, "aria-label": ariaLabel = "Panel content" }, ref) => {
1151
1273
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
@@ -1198,36 +1320,178 @@ var DataPanelFooter = React14.forwardRef(
1198
1320
  );
1199
1321
  DataPanelFooter.displayName = "DataPanelFooter";
1200
1322
  var DataPanelTab = React14.forwardRef(
1201
- ({ title = "Panel", edge, onClick, className }, ref) => {
1202
- const positionClasses = {
1203
- left: "left-0 top-1/2 -translate-y-1/2 rounded-r-md border-l-0",
1204
- right: "right-0 top-1/2 -translate-y-1/2 rounded-l-md border-r-0",
1205
- top: "top-0 left-1/2 -translate-x-1/2 rounded-b-md border-t-0",
1206
- bottom: "bottom-0 left-1/2 -translate-x-1/2 rounded-t-md border-b-0"
1207
- }[edge];
1323
+ ({
1324
+ title = "Panel",
1325
+ subtitle,
1326
+ edge,
1327
+ onClick,
1328
+ onClose,
1329
+ disableClose = false,
1330
+ offset = 0,
1331
+ onOffsetChange,
1332
+ tabWidth = import_data_panel_core.DEFAULT_TAB_WIDTH,
1333
+ tabInset = 0,
1334
+ className
1335
+ }, ref) => {
1208
1336
  const isVertical = edge === "left" || edge === "right";
1209
- const iconRotation = {
1210
- left: "rotate-90",
1211
- right: "-rotate-90",
1212
- top: "rotate-180",
1213
- bottom: ""
1337
+ const positionClasses = {
1338
+ // Border classes are in the chip's pre-rotation frame: its bottom rotates
1339
+ // to the attached (edge) side and its top corners to the viewport-facing
1340
+ // corners, so both side edges drop the bottom border and round the top.
1341
+ // The anchored axis is set inline (see insetStyle) so tabInset can move it.
1342
+ left: "top-1/2 rounded-t-lg border-b-0",
1343
+ right: "top-1/2 rounded-t-lg border-b-0",
1344
+ top: "left-1/2 rounded-b-lg border-t-0",
1345
+ bottom: "left-1/2 rounded-t-lg border-b-0"
1214
1346
  }[edge];
1347
+ const insetStyle = { [edge]: tabInset };
1348
+ const innerRef = React14.useRef(null);
1349
+ const dragRef = React14.useRef({
1350
+ startX: 0,
1351
+ startY: 0,
1352
+ startOffset: 0,
1353
+ moved: false,
1354
+ pointerId: -1
1355
+ });
1356
+ const [dragOffset, setDragOffset] = React14.useState(null);
1357
+ const effectiveOffset = dragOffset ?? offset;
1358
+ const draggable = !!onOffsetChange;
1359
+ const tabTransform = (0, import_data_panel_core.getTabTransform)(edge, tabWidth, effectiveOffset);
1360
+ const tabBounds = (0, import_data_panel_core.getTabBounds)(edge, tabWidth);
1361
+ const setRefs = (node) => {
1362
+ innerRef.current = node;
1363
+ if (typeof ref === "function") ref(node);
1364
+ else if (ref) ref.current = node;
1365
+ };
1366
+ const handlePointerDown = (e) => {
1367
+ if (!draggable) return;
1368
+ if (e.pointerType === "mouse" && e.button !== 0) return;
1369
+ if (e.target.closest("[data-no-drag]")) return;
1370
+ dragRef.current = {
1371
+ startX: e.clientX,
1372
+ startY: e.clientY,
1373
+ startOffset: offset,
1374
+ moved: false,
1375
+ pointerId: e.pointerId
1376
+ };
1377
+ setDragOffset(offset);
1378
+ e.currentTarget.setPointerCapture(e.pointerId);
1379
+ };
1380
+ const handlePointerMove = (e) => {
1381
+ const d = dragRef.current;
1382
+ if (d.pointerId !== e.pointerId || !e.currentTarget.hasPointerCapture(e.pointerId)) return;
1383
+ const delta = isVertical ? e.clientY - d.startY : e.clientX - d.startX;
1384
+ if (Math.abs(delta) > 3) d.moved = true;
1385
+ setDragOffset(
1386
+ (0, import_data_panel_core.constrainTabOffset)(
1387
+ d.startOffset + delta,
1388
+ edge,
1389
+ tabBounds,
1390
+ window.innerWidth,
1391
+ window.innerHeight
1392
+ )
1393
+ );
1394
+ };
1395
+ const handlePointerUp = (e) => {
1396
+ const d = dragRef.current;
1397
+ if (d.pointerId !== e.pointerId) return;
1398
+ if (e.currentTarget.hasPointerCapture(e.pointerId)) {
1399
+ e.currentTarget.releasePointerCapture(e.pointerId);
1400
+ }
1401
+ d.pointerId = -1;
1402
+ if (d.moved) {
1403
+ onOffsetChange?.(dragOffset ?? offset);
1404
+ } else {
1405
+ onClick?.();
1406
+ }
1407
+ setDragOffset(null);
1408
+ };
1409
+ const handlePointerCancel = (e) => {
1410
+ const d = dragRef.current;
1411
+ if (d.pointerId !== e.pointerId) return;
1412
+ if (e.currentTarget.hasPointerCapture(e.pointerId)) {
1413
+ e.currentTarget.releasePointerCapture(e.pointerId);
1414
+ }
1415
+ d.pointerId = -1;
1416
+ d.moved = false;
1417
+ setDragOffset(null);
1418
+ };
1419
+ const handleExpandKeyDown = (e) => {
1420
+ if (e.key === "Enter" || e.key === " ") {
1421
+ e.preventDefault();
1422
+ onClick?.();
1423
+ }
1424
+ };
1425
+ React14.useEffect(() => {
1426
+ if (!onOffsetChange || dragOffset !== null) return;
1427
+ const reclamp = () => {
1428
+ const clamped = (0, import_data_panel_core.constrainTabOffset)(
1429
+ offset,
1430
+ edge,
1431
+ tabBounds,
1432
+ window.innerWidth,
1433
+ window.innerHeight
1434
+ );
1435
+ if (clamped !== offset) onOffsetChange(clamped);
1436
+ };
1437
+ reclamp();
1438
+ window.addEventListener("resize", reclamp);
1439
+ return () => window.removeEventListener("resize", reclamp);
1440
+ }, [edge, tabWidth, offset, onOffsetChange, dragOffset]);
1215
1441
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1216
- "button",
1442
+ "div",
1217
1443
  {
1218
- ref,
1219
- type: "button",
1444
+ ref: setRefs,
1220
1445
  className: cn(
1221
- "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",
1446
+ // Same layer as the expanded panel: the tab is the only way to bring
1447
+ // the panel back, so it must never sit under chrome the panel covers.
1448
+ "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",
1449
+ draggable && "cursor-grab touch-none active:cursor-grabbing",
1222
1450
  positionClasses,
1223
- isVertical && "[writing-mode:vertical-rl]",
1224
1451
  className
1225
1452
  ),
1226
- onClick,
1227
- "aria-label": `Expand ${title} panel`,
1453
+ style: {
1454
+ ...insetStyle,
1455
+ width: tabWidth,
1456
+ // Side tabs rotate, so they need a fixed thickness for a deterministic
1457
+ // edge hug; top/bottom stay content-height.
1458
+ height: isVertical ? import_data_panel_core.TAB_THICKNESS : void 0,
1459
+ transformOrigin: "0 0",
1460
+ transform: tabTransform
1461
+ },
1462
+ onPointerDown: handlePointerDown,
1463
+ onPointerMove: draggable ? handlePointerMove : void 0,
1464
+ onPointerUp: draggable ? handlePointerUp : void 0,
1465
+ onPointerCancel: draggable ? handlePointerCancel : void 0,
1228
1466
  children: [
1229
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: cn("shrink-0", iconRotation), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChevronUpIcon, {}) }),
1230
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: cn(isVertical && "rotate-180"), children: title })
1467
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1468
+ "button",
1469
+ {
1470
+ type: "button",
1471
+ "aria-label": `Expand ${title} panel`,
1472
+ 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",
1473
+ onClick: draggable ? void 0 : onClick,
1474
+ onKeyDown: handleExpandKeyDown,
1475
+ children: [
1476
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "truncate text-sm font-semibold", children: title }),
1477
+ subtitle && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "truncate text-xs text-muted-foreground", children: subtitle })
1478
+ ]
1479
+ }
1480
+ ),
1481
+ !disableClose && onClose && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1482
+ "button",
1483
+ {
1484
+ "data-no-drag": true,
1485
+ type: "button",
1486
+ 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",
1487
+ "aria-label": "Close panel",
1488
+ onClick: (e) => {
1489
+ e.stopPropagation();
1490
+ onClose();
1491
+ },
1492
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CloseIcon, {})
1493
+ }
1494
+ )
1231
1495
  ]
1232
1496
  }
1233
1497
  );
@@ -1239,62 +1503,76 @@ var KEYBOARD_RESIZE_STEP_LARGE = 50;
1239
1503
  function ResizeHandles({
1240
1504
  mode,
1241
1505
  edge,
1506
+ detachedPosition,
1242
1507
  detachedSize,
1243
1508
  pinnedSize,
1244
1509
  onResizeStart,
1245
- onSizeChange,
1510
+ onDetachedResize,
1246
1511
  onPinnedSizeChange,
1247
1512
  constraints
1248
1513
  }) {
1249
1514
  const handleDetachedKeyDown = React14.useCallback(
1250
1515
  (e, handle) => {
1251
1516
  const step = e.shiftKey ? KEYBOARD_RESIZE_STEP_LARGE : KEYBOARD_RESIZE_STEP;
1252
- let newSize = { ...detachedSize };
1517
+ let width = detachedSize.width;
1518
+ let height = detachedSize.height;
1253
1519
  let handled = false;
1254
1520
  switch (e.key) {
1255
1521
  case "ArrowUp":
1256
1522
  if (handle.includes("top")) {
1257
- newSize.height = Math.max(constraints.minHeight || 200, detachedSize.height + step);
1523
+ height += step;
1258
1524
  handled = true;
1259
1525
  } else if (handle.includes("bottom")) {
1260
- newSize.height = Math.max(constraints.minHeight || 200, detachedSize.height - step);
1526
+ height -= step;
1261
1527
  handled = true;
1262
1528
  }
1263
1529
  break;
1264
1530
  case "ArrowDown":
1265
1531
  if (handle.includes("top")) {
1266
- newSize.height = Math.max(constraints.minHeight || 200, detachedSize.height - step);
1532
+ height -= step;
1267
1533
  handled = true;
1268
1534
  } else if (handle.includes("bottom")) {
1269
- newSize.height = Math.min(constraints.maxHeight || 800, detachedSize.height + step);
1535
+ height += step;
1270
1536
  handled = true;
1271
1537
  }
1272
1538
  break;
1273
1539
  case "ArrowLeft":
1274
1540
  if (handle.includes("left")) {
1275
- newSize.width = Math.max(constraints.minWidth || 280, detachedSize.width + step);
1541
+ width += step;
1276
1542
  handled = true;
1277
1543
  } else if (handle.includes("right")) {
1278
- newSize.width = Math.max(constraints.minWidth || 280, detachedSize.width - step);
1544
+ width -= step;
1279
1545
  handled = true;
1280
1546
  }
1281
1547
  break;
1282
1548
  case "ArrowRight":
1283
1549
  if (handle.includes("left")) {
1284
- newSize.width = Math.max(constraints.minWidth || 280, detachedSize.width - step);
1550
+ width -= step;
1285
1551
  handled = true;
1286
1552
  } else if (handle.includes("right")) {
1287
- newSize.width = Math.min(constraints.maxWidth || 600, detachedSize.width + step);
1553
+ width += step;
1288
1554
  handled = true;
1289
1555
  }
1290
1556
  break;
1291
1557
  }
1292
1558
  if (handled) {
1293
1559
  e.preventDefault();
1294
- onSizeChange(newSize);
1560
+ const candidatePosition = {
1561
+ x: handle.includes("left") ? detachedPosition.x + (detachedSize.width - width) : detachedPosition.x,
1562
+ y: handle.includes("top") ? detachedPosition.y + (detachedSize.height - height) : detachedPosition.y
1563
+ };
1564
+ const { position, size } = (0, import_data_panel_core.constrainResize)(
1565
+ candidatePosition,
1566
+ { width, height },
1567
+ constraints,
1568
+ typeof window === "undefined" ? 1024 : window.innerWidth,
1569
+ typeof window === "undefined" ? 768 : window.innerHeight,
1570
+ handle
1571
+ );
1572
+ onDetachedResize(position, size);
1295
1573
  }
1296
1574
  },
1297
- [detachedSize, constraints, onSizeChange]
1575
+ [detachedPosition, detachedSize, constraints, onDetachedResize]
1298
1576
  );
1299
1577
  const handlePinnedKeyDown = React14.useCallback(
1300
1578
  (e) => {
@@ -1419,6 +1697,8 @@ var DataPanel = React14.forwardRef(
1419
1697
  onOpenChange,
1420
1698
  mode: controlledMode,
1421
1699
  onModeChange,
1700
+ variant: controlledVariant,
1701
+ cardConfig = {},
1422
1702
  edge: controlledEdge,
1423
1703
  onEdgeChange,
1424
1704
  expanded: controlledExpanded,
@@ -1428,6 +1708,8 @@ var DataPanel = React14.forwardRef(
1428
1708
  children,
1429
1709
  actions = [],
1430
1710
  constraints = {},
1711
+ tabWidth = import_data_panel_core.DEFAULT_TAB_WIDTH,
1712
+ tabInset = 0,
1431
1713
  disableClose = false,
1432
1714
  disableResize = false,
1433
1715
  disableDrag = false,
@@ -1441,11 +1723,21 @@ var DataPanel = React14.forwardRef(
1441
1723
  footerActions,
1442
1724
  className
1443
1725
  }, ref) => {
1444
- const resolvedConstraints = { ...import_data_panel_core.DEFAULT_CONSTRAINTS, ...constraints };
1726
+ const resolvedConstraints = React14.useMemo(
1727
+ () => ({ ...import_data_panel_core.DEFAULT_CONSTRAINTS, ...constraints }),
1728
+ [constraints]
1729
+ );
1730
+ const resolvedCardConfig = React14.useMemo(
1731
+ () => ({ ...import_data_panel_core.DEFAULT_CARD_CONFIG, ...cardConfig }),
1732
+ [cardConfig]
1733
+ );
1445
1734
  const panelId = React14.useId();
1446
1735
  const titleId = `${panelId}-title`;
1447
1736
  const [internalOpen, setInternalOpen] = React14.useState(true);
1448
1737
  const [internalMode, setInternalMode] = React14.useState(import_data_panel_core.DEFAULT_PANEL_STATE.mode);
1738
+ const [internalVariant, setInternalVariant] = React14.useState(
1739
+ import_data_panel_core.DEFAULT_PANEL_STATE.variant
1740
+ );
1449
1741
  const [internalEdge, setInternalEdge] = React14.useState(import_data_panel_core.DEFAULT_PANEL_STATE.edge);
1450
1742
  const [internalExpanded, setInternalExpanded] = React14.useState(
1451
1743
  import_data_panel_core.DEFAULT_PANEL_STATE.isExpanded
@@ -1455,6 +1747,23 @@ var DataPanel = React14.forwardRef(
1455
1747
  );
1456
1748
  const [detachedSize, setDetachedSize] = React14.useState(import_data_panel_core.DEFAULT_PANEL_STATE.detachedSize);
1457
1749
  const [pinnedSize, setPinnedSize] = React14.useState(import_data_panel_core.DEFAULT_PANEL_STATE.pinnedSize);
1750
+ const [tabOffset, setTabOffset] = React14.useState(import_data_panel_core.DEFAULT_PANEL_STATE.tabOffset);
1751
+ const [viewportWidth, setViewportWidth] = React14.useState(
1752
+ typeof window !== "undefined" ? window.innerWidth : 1024
1753
+ );
1754
+ const [viewportHeight, setViewportHeight] = React14.useState(
1755
+ typeof window !== "undefined" ? window.innerHeight : 768
1756
+ );
1757
+ const isMobile = viewportWidth < 640;
1758
+ const [cardHorizontalPosition, setCardHorizontalPosition] = React14.useState(0);
1759
+ const [cardExpandedHeight, setCardExpandedHeight] = React14.useState(0);
1760
+ const [cardWidth, setCardWidth] = React14.useState(null);
1761
+ const [cardDragCurrentHeight, setCardDragCurrentHeight] = React14.useState(import_data_panel_core.CARD_HEADER_HEIGHT);
1762
+ const [isCardVerticalDragging, setIsCardVerticalDragging] = React14.useState(false);
1763
+ const [isCardHorizontalDragging, setIsCardHorizontalDragging] = React14.useState(false);
1764
+ const [isCardHeightTransitioning, setIsCardHeightTransitioning] = React14.useState(false);
1765
+ const [isCardWidthResizing, setIsCardWidthResizing] = React14.useState(false);
1766
+ const [isCardTopResizing, setIsCardTopResizing] = React14.useState(false);
1458
1767
  const [isDragging, setIsDragging] = React14.useState(false);
1459
1768
  const [isResizing, setIsResizing] = React14.useState(false);
1460
1769
  const [snapPreview, setSnapPreview] = React14.useState(null);
@@ -1474,11 +1783,40 @@ var DataPanel = React14.forwardRef(
1474
1783
  startSize: { width: 0, height: 0 },
1475
1784
  startPanelPosition: { x: 0, y: 0 }
1476
1785
  });
1786
+ const cardDragStateRef = React14.useRef({
1787
+ startY: 0,
1788
+ startX: 0,
1789
+ startTime: 0,
1790
+ startExpanded: false,
1791
+ startHorizontalPosition: 0
1792
+ });
1793
+ const cardCurrentHeightRef = React14.useRef(import_data_panel_core.CARD_HEADER_HEIGHT);
1794
+ const cardTopResizeStartRef = React14.useRef({ startY: 0, startHeight: 0 });
1795
+ const cardWidthResizeStateRef = React14.useRef({
1796
+ handle: null,
1797
+ startX: 0,
1798
+ startWidth: 0,
1799
+ startLeft: 0
1800
+ });
1477
1801
  const open = controlledOpen ?? internalOpen;
1478
1802
  const mode = controlledMode ?? internalMode;
1803
+ const variant = controlledVariant ?? internalVariant;
1479
1804
  const edge = controlledEdge ?? internalEdge;
1480
1805
  const isExpanded = controlledExpanded ?? internalExpanded;
1806
+ const showContent = variant !== "card" || isExpanded || isCardVerticalDragging;
1481
1807
  const saveTimeoutRef = React14.useRef(null);
1808
+ const isMountedRef = React14.useRef(true);
1809
+ React14.useEffect(() => {
1810
+ isMountedRef.current = true;
1811
+ return () => {
1812
+ isMountedRef.current = false;
1813
+ if (saveTimeoutRef.current) clearTimeout(saveTimeoutRef.current);
1814
+ if (typeof document !== "undefined") {
1815
+ document.body.style.cursor = "";
1816
+ document.body.style.userSelect = "";
1817
+ }
1818
+ };
1819
+ }, []);
1482
1820
  const debouncedSave = React14.useCallback(() => {
1483
1821
  if (!persistKey) return;
1484
1822
  if (saveTimeoutRef.current) {
@@ -1487,32 +1825,48 @@ var DataPanel = React14.forwardRef(
1487
1825
  saveTimeoutRef.current = setTimeout(() => {
1488
1826
  (0, import_data_panel_core.savePanelState)(persistKey, {
1489
1827
  mode,
1490
- variant: "full",
1828
+ variant,
1491
1829
  edge,
1492
1830
  isExpanded,
1493
1831
  detachedPosition,
1494
1832
  detachedSize,
1495
1833
  pinnedSize,
1496
- cardSnapIndex: 0
1834
+ cardSnapIndex: 0,
1835
+ tabOffset
1497
1836
  });
1498
1837
  }, 300);
1499
- }, [persistKey, mode, edge, isExpanded, detachedPosition, detachedSize, pinnedSize]);
1838
+ }, [
1839
+ persistKey,
1840
+ mode,
1841
+ variant,
1842
+ edge,
1843
+ isExpanded,
1844
+ detachedPosition,
1845
+ detachedSize,
1846
+ pinnedSize,
1847
+ tabOffset
1848
+ ]);
1500
1849
  React14.useEffect(() => {
1501
1850
  debouncedSave();
1502
1851
  }, [debouncedSave]);
1852
+ const hasLoadedRef = React14.useRef(false);
1503
1853
  React14.useEffect(() => {
1504
- if (!persistKey) return;
1854
+ if (!persistKey || hasLoadedRef.current) return;
1855
+ hasLoadedRef.current = true;
1505
1856
  const persisted = (0, import_data_panel_core.loadPanelState)(persistKey);
1506
1857
  if (persisted) {
1507
1858
  if (controlledMode === void 0 && persisted.mode) setInternalMode(persisted.mode);
1859
+ if (controlledVariant === void 0 && persisted.variant)
1860
+ setInternalVariant(persisted.variant);
1508
1861
  if (controlledEdge === void 0 && persisted.edge) setInternalEdge(persisted.edge);
1509
1862
  if (controlledExpanded === void 0 && persisted.isExpanded !== void 0)
1510
1863
  setInternalExpanded(persisted.isExpanded);
1511
1864
  if (persisted.detachedPosition) setDetachedPosition(persisted.detachedPosition);
1512
1865
  if (persisted.detachedSize) setDetachedSize(persisted.detachedSize);
1513
1866
  if (persisted.pinnedSize) setPinnedSize(persisted.pinnedSize);
1867
+ if (persisted.tabOffset !== void 0) setTabOffset(persisted.tabOffset);
1514
1868
  }
1515
- }, [persistKey, controlledMode, controlledEdge, controlledExpanded]);
1869
+ }, [persistKey, controlledMode, controlledVariant, controlledEdge, controlledExpanded]);
1516
1870
  React14.useEffect(() => {
1517
1871
  if (mode === "detached" && detachedPosition.x === import_data_panel_core.DEFAULT_PANEL_STATE.detachedPosition.x && detachedPosition.y === import_data_panel_core.DEFAULT_PANEL_STATE.detachedPosition.y) {
1518
1872
  setDetachedPosition(
@@ -1526,13 +1880,13 @@ var DataPanel = React14.forwardRef(
1526
1880
  }
1527
1881
  onOpenChange?.(newOpen);
1528
1882
  };
1529
- const isDetachedDialog = open && mode === "detached";
1530
- const focusTrapRef = useFocusTrap({ active: isDetachedDialog });
1883
+ const isDialog = open && (mode === "detached" || variant === "card" && isExpanded && isMobile);
1884
+ const focusTrapRef = useFocusTrap({ active: isDialog });
1531
1885
  useEscapeKey(
1532
1886
  () => {
1533
1887
  if (!disableClose) handleOpenChange(false);
1534
1888
  },
1535
- { enabled: isDetachedDialog }
1889
+ { enabled: isDialog }
1536
1890
  );
1537
1891
  const setPanelRef = (node) => {
1538
1892
  focusTrapRef.current = node;
@@ -1542,24 +1896,34 @@ var DataPanel = React14.forwardRef(
1542
1896
  ref.current = node;
1543
1897
  }
1544
1898
  };
1545
- const handleModeChange = (newMode) => {
1546
- if (controlledMode === void 0) {
1547
- setInternalMode(newMode);
1548
- }
1549
- onModeChange?.(newMode);
1550
- };
1551
- const handleEdgeChange = (newEdge) => {
1552
- if (controlledEdge === void 0) {
1553
- setInternalEdge(newEdge);
1554
- }
1555
- onEdgeChange?.(newEdge);
1556
- };
1557
- const handleExpandedChange = (newExpanded) => {
1558
- if (controlledExpanded === void 0) {
1559
- setInternalExpanded(newExpanded);
1560
- }
1561
- onExpandedChange?.(newExpanded);
1562
- };
1899
+ const handleModeChange = React14.useCallback(
1900
+ (newMode) => {
1901
+ if (controlledMode === void 0) {
1902
+ setInternalMode(newMode);
1903
+ }
1904
+ onModeChange?.(newMode);
1905
+ },
1906
+ [controlledMode, onModeChange]
1907
+ );
1908
+ const handleEdgeChange = React14.useCallback(
1909
+ (newEdge) => {
1910
+ if (controlledEdge === void 0) {
1911
+ setInternalEdge(newEdge);
1912
+ }
1913
+ onEdgeChange?.(newEdge);
1914
+ },
1915
+ [controlledEdge, onEdgeChange]
1916
+ );
1917
+ const handleExpandedChange = React14.useCallback(
1918
+ (newExpanded) => {
1919
+ if (controlledExpanded === void 0) {
1920
+ setInternalExpanded(newExpanded);
1921
+ }
1922
+ onExpandedChange?.(newExpanded);
1923
+ },
1924
+ [controlledExpanded, onExpandedChange]
1925
+ );
1926
+ const handleToggleExpand = () => handleExpandedChange(!isExpanded);
1563
1927
  const handleDragStart = (e) => {
1564
1928
  if (disableDrag) return;
1565
1929
  const target = e.target;
@@ -1696,12 +2060,13 @@ var DataPanel = React14.forwardRef(
1696
2060
  },
1697
2061
  currentPos
1698
2062
  );
1699
- const constrainedSize = (0, import_data_panel_core.constrainSize)(result.size, resolvedConstraints);
1700
- const constrainedPosition = (0, import_data_panel_core.constrainPosition)(
2063
+ const { position: constrainedPosition, size: constrainedSize } = (0, import_data_panel_core.constrainResize)(
1701
2064
  result.position,
1702
- constrainedSize,
2065
+ result.size,
2066
+ resolvedConstraints,
1703
2067
  window.innerWidth,
1704
- window.innerHeight
2068
+ window.innerHeight,
2069
+ handle
1705
2070
  );
1706
2071
  setDetachedSize(constrainedSize);
1707
2072
  setDetachedPosition(constrainedPosition);
@@ -1725,13 +2090,269 @@ var DataPanel = React14.forwardRef(
1725
2090
  document.body.style.cursor = "";
1726
2091
  document.body.style.userSelect = "";
1727
2092
  }, [isResizing]);
2093
+ const handleCardHeaderPointerDown = (e) => {
2094
+ if (variant !== "card") return;
2095
+ const target = e.target;
2096
+ const isDragHandle = target.closest("[data-card-drag-handle]");
2097
+ if (!isDragHandle && target.closest("button")) return;
2098
+ const pos = (0, import_data_panel_core.getPointerPosition)(e.nativeEvent);
2099
+ cardDragStateRef.current = {
2100
+ startY: pos.y,
2101
+ startX: pos.x,
2102
+ startTime: Date.now(),
2103
+ startExpanded: isExpanded,
2104
+ startHorizontalPosition: cardHorizontalPosition
2105
+ };
2106
+ const startHeight = isExpanded ? cardExpandedHeight : import_data_panel_core.CARD_HEADER_HEIGHT;
2107
+ setCardDragCurrentHeight(startHeight);
2108
+ cardCurrentHeightRef.current = startHeight;
2109
+ if (isMobile) {
2110
+ setIsCardVerticalDragging(true);
2111
+ } else if (isDragHandle) {
2112
+ setIsCardHorizontalDragging(true);
2113
+ } else {
2114
+ setIsCardVerticalDragging(true);
2115
+ }
2116
+ document.body.style.userSelect = "none";
2117
+ };
2118
+ const handleCardPointerMove = React14.useCallback(
2119
+ (e) => {
2120
+ const currentPos = (0, import_data_panel_core.getPointerPosition)(e);
2121
+ if (isCardVerticalDragging) {
2122
+ const deltaY = cardDragStateRef.current.startY - currentPos.y;
2123
+ const startHeight = cardDragStateRef.current.startExpanded ? cardExpandedHeight : import_data_panel_core.CARD_HEADER_HEIGHT;
2124
+ const next = Math.max(
2125
+ import_data_panel_core.CARD_HEADER_HEIGHT,
2126
+ Math.min(viewportHeight * 0.95, startHeight + deltaY)
2127
+ );
2128
+ setCardDragCurrentHeight(next);
2129
+ cardCurrentHeightRef.current = next;
2130
+ }
2131
+ if (isCardHorizontalDragging && !isMobile) {
2132
+ const deltaX = currentPos.x - cardDragStateRef.current.startX;
2133
+ const cw = Math.min(
2134
+ viewportWidth - resolvedCardConfig.horizontalMargin * 2,
2135
+ resolvedCardConfig.maxWidth
2136
+ );
2137
+ const defaultLeftOffset = Math.max(
2138
+ resolvedCardConfig.horizontalMargin,
2139
+ (viewportWidth - cw) / 2
2140
+ );
2141
+ const minOffset = -(defaultLeftOffset - resolvedCardConfig.horizontalMargin);
2142
+ const maxOffset = viewportWidth - cw - defaultLeftOffset - resolvedCardConfig.horizontalMargin;
2143
+ const nextPos = cardDragStateRef.current.startHorizontalPosition + deltaX;
2144
+ setCardHorizontalPosition(Math.max(minOffset, Math.min(maxOffset, nextPos)));
2145
+ }
2146
+ },
2147
+ [
2148
+ isCardVerticalDragging,
2149
+ isCardHorizontalDragging,
2150
+ isMobile,
2151
+ viewportWidth,
2152
+ viewportHeight,
2153
+ cardExpandedHeight,
2154
+ resolvedCardConfig.horizontalMargin,
2155
+ resolvedCardConfig.maxWidth
2156
+ ]
2157
+ );
2158
+ const handleCardPointerUp = React14.useCallback(
2159
+ (e) => {
2160
+ const endTime = Date.now();
2161
+ const currentPos = (0, import_data_panel_core.getPointerPosition)(e);
2162
+ const st = cardDragStateRef.current;
2163
+ const deltaTime = endTime - st.startTime;
2164
+ const deltaY = st.startY - currentPos.y;
2165
+ document.body.style.userSelect = "";
2166
+ if (isCardVerticalDragging) {
2167
+ if (deltaTime < 200 && Math.abs(deltaY) < 10) {
2168
+ setIsCardVerticalDragging(false);
2169
+ handleExpandedChange(!isExpanded);
2170
+ return;
2171
+ }
2172
+ const velocity = deltaY / deltaTime;
2173
+ let newExpanded;
2174
+ if (Math.abs(velocity) > resolvedCardConfig.swipeVelocityThreshold) {
2175
+ newExpanded = velocity > 0;
2176
+ } else {
2177
+ const midpoint = (import_data_panel_core.CARD_HEADER_HEIGHT + cardExpandedHeight) / 2;
2178
+ newExpanded = cardCurrentHeightRef.current > midpoint;
2179
+ }
2180
+ const targetHeight = newExpanded ? cardExpandedHeight : import_data_panel_core.CARD_HEADER_HEIGHT;
2181
+ setIsCardVerticalDragging(false);
2182
+ setIsCardHeightTransitioning(true);
2183
+ handleExpandedChange(newExpanded);
2184
+ requestAnimationFrame(() => {
2185
+ if (!isMountedRef.current) return;
2186
+ setCardDragCurrentHeight(targetHeight);
2187
+ cardCurrentHeightRef.current = targetHeight;
2188
+ });
2189
+ }
2190
+ if (isCardHorizontalDragging) {
2191
+ setIsCardHorizontalDragging(false);
2192
+ debouncedSave();
2193
+ }
2194
+ },
2195
+ [
2196
+ isCardVerticalDragging,
2197
+ isCardHorizontalDragging,
2198
+ isExpanded,
2199
+ cardExpandedHeight,
2200
+ resolvedCardConfig.swipeVelocityThreshold,
2201
+ handleExpandedChange,
2202
+ debouncedSave
2203
+ ]
2204
+ );
2205
+ const handleCardResizeStart = (e) => {
2206
+ if (variant !== "card" || !isExpanded || disableResize || isMobile) return;
2207
+ e.preventDefault();
2208
+ e.stopPropagation();
2209
+ setIsCardTopResizing(true);
2210
+ const pos = (0, import_data_panel_core.getPointerPosition)(e.nativeEvent);
2211
+ cardTopResizeStartRef.current = { startY: pos.y, startHeight: cardExpandedHeight };
2212
+ document.body.style.cursor = "ns-resize";
2213
+ document.body.style.userSelect = "none";
2214
+ };
2215
+ const handleCardResizeMove = React14.useCallback(
2216
+ (e) => {
2217
+ if (!isCardTopResizing) return;
2218
+ const currentPos = (0, import_data_panel_core.getPointerPosition)(e);
2219
+ const deltaY = cardTopResizeStartRef.current.startY - currentPos.y;
2220
+ const newHeight = Math.max(
2221
+ import_data_panel_core.CARD_HEADER_HEIGHT * 2,
2222
+ Math.min(viewportHeight * 0.95, cardTopResizeStartRef.current.startHeight + deltaY)
2223
+ );
2224
+ setCardExpandedHeight(newHeight);
2225
+ },
2226
+ [isCardTopResizing, viewportHeight]
2227
+ );
2228
+ const handleCardResizeEnd = React14.useCallback(() => {
2229
+ if (!isCardTopResizing) return;
2230
+ setIsCardTopResizing(false);
2231
+ document.body.style.cursor = "";
2232
+ document.body.style.userSelect = "";
2233
+ debouncedSave();
2234
+ }, [isCardTopResizing, debouncedSave]);
2235
+ const handleCardWidthResizeStart = (e, handle) => {
2236
+ if (variant !== "card" || !isExpanded || disableResize || isMobile) return;
2237
+ e.preventDefault();
2238
+ e.stopPropagation();
2239
+ const pos = (0, import_data_panel_core.getPointerPosition)(e.nativeEvent);
2240
+ const defaultCardWidth = Math.min(
2241
+ viewportWidth - resolvedCardConfig.horizontalMargin * 2,
2242
+ resolvedCardConfig.maxWidth
2243
+ );
2244
+ const currentWidth = cardWidth ?? defaultCardWidth;
2245
+ const defaultLeftOffset = Math.max(
2246
+ resolvedCardConfig.horizontalMargin,
2247
+ (viewportWidth - defaultCardWidth) / 2
2248
+ );
2249
+ cardWidthResizeStateRef.current = {
2250
+ handle,
2251
+ startX: pos.x,
2252
+ startWidth: currentWidth,
2253
+ startLeft: defaultLeftOffset + cardHorizontalPosition
2254
+ };
2255
+ setIsCardWidthResizing(true);
2256
+ document.body.style.cursor = "ew-resize";
2257
+ document.body.style.userSelect = "none";
2258
+ };
2259
+ const handleCardWidthResizeMove = React14.useCallback(
2260
+ (e) => {
2261
+ const st = cardWidthResizeStateRef.current;
2262
+ if (!isCardWidthResizing || !st.handle) return;
2263
+ const currentPos = (0, import_data_panel_core.getPointerPosition)(e);
2264
+ const deltaX = currentPos.x - st.startX;
2265
+ if (st.handle === "right") {
2266
+ const newWidth = Math.max(
2267
+ import_data_panel_core.CARD_MIN_WIDTH,
2268
+ Math.min(
2269
+ resolvedCardConfig.maxWidth,
2270
+ viewportWidth - st.startLeft - resolvedCardConfig.horizontalMargin,
2271
+ st.startWidth + deltaX
2272
+ )
2273
+ );
2274
+ setCardWidth(newWidth);
2275
+ } else {
2276
+ const newLeft = st.startLeft + deltaX;
2277
+ const newWidth = st.startWidth - deltaX;
2278
+ if (newLeft >= resolvedCardConfig.horizontalMargin && newWidth >= import_data_panel_core.CARD_MIN_WIDTH) {
2279
+ setCardWidth(Math.min(newWidth, resolvedCardConfig.maxWidth));
2280
+ const defaultCardWidth = Math.min(
2281
+ viewportWidth - resolvedCardConfig.horizontalMargin * 2,
2282
+ resolvedCardConfig.maxWidth
2283
+ );
2284
+ const defaultLeftOffset = Math.max(
2285
+ resolvedCardConfig.horizontalMargin,
2286
+ (viewportWidth - defaultCardWidth) / 2
2287
+ );
2288
+ setCardHorizontalPosition(newLeft - defaultLeftOffset);
2289
+ }
2290
+ }
2291
+ },
2292
+ [
2293
+ isCardWidthResizing,
2294
+ viewportWidth,
2295
+ resolvedCardConfig.horizontalMargin,
2296
+ resolvedCardConfig.maxWidth
2297
+ ]
2298
+ );
2299
+ const handleCardWidthResizeEnd = React14.useCallback(() => {
2300
+ if (!isCardWidthResizing) return;
2301
+ setIsCardWidthResizing(false);
2302
+ cardWidthResizeStateRef.current.handle = null;
2303
+ document.body.style.cursor = "";
2304
+ document.body.style.userSelect = "";
2305
+ debouncedSave();
2306
+ }, [isCardWidthResizing, debouncedSave]);
2307
+ const cardDefaultWidth = Math.min(
2308
+ viewportWidth - resolvedCardConfig.horizontalMargin * 2,
2309
+ resolvedCardConfig.maxWidth
2310
+ );
2311
+ const cardCurrentWidth = cardWidth ?? cardDefaultWidth;
2312
+ const cardHeightMin = import_data_panel_core.CARD_HEADER_HEIGHT * 2;
2313
+ const cardHeightMax = Math.round(viewportHeight * 0.95);
2314
+ const handleCardResizeKeyDown = (e, kind) => {
2315
+ if (disableResize) return;
2316
+ const step = e.shiftKey ? KEYBOARD_RESIZE_STEP_LARGE : KEYBOARD_RESIZE_STEP;
2317
+ if (kind === "height") {
2318
+ let delta = 0;
2319
+ if (e.key === "ArrowUp") delta = step;
2320
+ else if (e.key === "ArrowDown") delta = -step;
2321
+ else return;
2322
+ e.preventDefault();
2323
+ setCardExpandedHeight((h) => Math.max(cardHeightMin, Math.min(cardHeightMax, h + delta)));
2324
+ debouncedSave();
2325
+ return;
2326
+ }
2327
+ let widthDelta = 0;
2328
+ if (kind === "width-right") {
2329
+ if (e.key === "ArrowRight") widthDelta = step;
2330
+ else if (e.key === "ArrowLeft") widthDelta = -step;
2331
+ } else {
2332
+ if (e.key === "ArrowLeft") widthDelta = step;
2333
+ else if (e.key === "ArrowRight") widthDelta = -step;
2334
+ }
2335
+ if (widthDelta === 0) return;
2336
+ e.preventDefault();
2337
+ const maxWidth = Math.min(
2338
+ resolvedCardConfig.maxWidth,
2339
+ viewportWidth - resolvedCardConfig.horizontalMargin * 2
2340
+ );
2341
+ const nextWidth = Math.max(import_data_panel_core.CARD_MIN_WIDTH, Math.min(maxWidth, cardCurrentWidth + widthDelta));
2342
+ const appliedDelta = nextWidth - cardCurrentWidth;
2343
+ setCardWidth(nextWidth);
2344
+ if (kind === "width-left") setCardHorizontalPosition((p) => p - appliedDelta);
2345
+ debouncedSave();
2346
+ };
1728
2347
  React14.useEffect(() => {
1729
2348
  if (isDragging) {
1730
2349
  window.addEventListener("pointermove", handleDragMove);
1731
2350
  window.addEventListener("pointerup", handleDragEnd);
2351
+ window.addEventListener("pointercancel", handleDragEnd);
1732
2352
  return () => {
1733
2353
  window.removeEventListener("pointermove", handleDragMove);
1734
2354
  window.removeEventListener("pointerup", handleDragEnd);
2355
+ window.removeEventListener("pointercancel", handleDragEnd);
1735
2356
  };
1736
2357
  }
1737
2358
  }, [isDragging, handleDragMove, handleDragEnd]);
@@ -1739,9 +2360,11 @@ var DataPanel = React14.forwardRef(
1739
2360
  if (isPinnedDragging) {
1740
2361
  window.addEventListener("pointermove", handlePinnedDragMove);
1741
2362
  window.addEventListener("pointerup", handlePinnedDragEnd);
2363
+ window.addEventListener("pointercancel", handlePinnedDragEnd);
1742
2364
  return () => {
1743
2365
  window.removeEventListener("pointermove", handlePinnedDragMove);
1744
2366
  window.removeEventListener("pointerup", handlePinnedDragEnd);
2367
+ window.removeEventListener("pointercancel", handlePinnedDragEnd);
1745
2368
  };
1746
2369
  }
1747
2370
  }, [isPinnedDragging, handlePinnedDragMove, handlePinnedDragEnd]);
@@ -1749,13 +2372,98 @@ var DataPanel = React14.forwardRef(
1749
2372
  if (isResizing) {
1750
2373
  window.addEventListener("pointermove", handleResizeMove);
1751
2374
  window.addEventListener("pointerup", handleResizeEnd);
2375
+ window.addEventListener("pointercancel", handleResizeEnd);
1752
2376
  return () => {
1753
2377
  window.removeEventListener("pointermove", handleResizeMove);
1754
2378
  window.removeEventListener("pointerup", handleResizeEnd);
2379
+ window.removeEventListener("pointercancel", handleResizeEnd);
1755
2380
  };
1756
2381
  }
1757
2382
  }, [isResizing, handleResizeMove, handleResizeEnd]);
2383
+ React14.useEffect(() => {
2384
+ if (isCardVerticalDragging || isCardHorizontalDragging) {
2385
+ window.addEventListener("pointermove", handleCardPointerMove);
2386
+ window.addEventListener("pointerup", handleCardPointerUp);
2387
+ window.addEventListener("pointercancel", handleCardPointerUp);
2388
+ return () => {
2389
+ window.removeEventListener("pointermove", handleCardPointerMove);
2390
+ window.removeEventListener("pointerup", handleCardPointerUp);
2391
+ window.removeEventListener("pointercancel", handleCardPointerUp);
2392
+ };
2393
+ }
2394
+ }, [
2395
+ isCardVerticalDragging,
2396
+ isCardHorizontalDragging,
2397
+ handleCardPointerMove,
2398
+ handleCardPointerUp
2399
+ ]);
2400
+ React14.useEffect(() => {
2401
+ if (isCardTopResizing) {
2402
+ window.addEventListener("pointermove", handleCardResizeMove);
2403
+ window.addEventListener("pointerup", handleCardResizeEnd);
2404
+ window.addEventListener("pointercancel", handleCardResizeEnd);
2405
+ return () => {
2406
+ window.removeEventListener("pointermove", handleCardResizeMove);
2407
+ window.removeEventListener("pointerup", handleCardResizeEnd);
2408
+ window.removeEventListener("pointercancel", handleCardResizeEnd);
2409
+ };
2410
+ }
2411
+ }, [isCardTopResizing, handleCardResizeMove, handleCardResizeEnd]);
2412
+ React14.useEffect(() => {
2413
+ if (isCardWidthResizing) {
2414
+ window.addEventListener("pointermove", handleCardWidthResizeMove);
2415
+ window.addEventListener("pointerup", handleCardWidthResizeEnd);
2416
+ window.addEventListener("pointercancel", handleCardWidthResizeEnd);
2417
+ return () => {
2418
+ window.removeEventListener("pointermove", handleCardWidthResizeMove);
2419
+ window.removeEventListener("pointerup", handleCardWidthResizeEnd);
2420
+ window.removeEventListener("pointercancel", handleCardWidthResizeEnd);
2421
+ };
2422
+ }
2423
+ }, [isCardWidthResizing, handleCardWidthResizeMove, handleCardWidthResizeEnd]);
2424
+ React14.useEffect(() => {
2425
+ const onResize = () => {
2426
+ setViewportWidth(window.innerWidth);
2427
+ setViewportHeight(window.innerHeight);
2428
+ setCardExpandedHeight(window.innerHeight * import_data_panel_core.CARD_EXPANDED_RATIO);
2429
+ };
2430
+ onResize();
2431
+ window.addEventListener("resize", onResize);
2432
+ return () => window.removeEventListener("resize", onResize);
2433
+ }, []);
2434
+ React14.useEffect(() => {
2435
+ if (isMobile && variant === "card") {
2436
+ setCardHorizontalPosition(0);
2437
+ setCardWidth(null);
2438
+ }
2439
+ }, [isMobile, variant]);
2440
+ React14.useEffect(() => {
2441
+ if (isCardHeightTransitioning) {
2442
+ const t = setTimeout(() => setIsCardHeightTransitioning(false), 350);
2443
+ return () => clearTimeout(t);
2444
+ }
2445
+ }, [isCardHeightTransitioning]);
1758
2446
  const panelStyles = React14.useMemo(() => {
2447
+ if (variant === "card") {
2448
+ const defaultCardWidth = Math.min(
2449
+ viewportWidth - resolvedCardConfig.horizontalMargin * 2,
2450
+ resolvedCardConfig.maxWidth
2451
+ );
2452
+ const actualCardWidth = cardWidth ?? defaultCardWidth;
2453
+ const defaultLeftOffset = Math.max(
2454
+ resolvedCardConfig.horizontalMargin,
2455
+ (viewportWidth - defaultCardWidth) / 2
2456
+ );
2457
+ const height = isCardVerticalDragging || isCardHeightTransitioning ? cardDragCurrentHeight : isExpanded ? cardExpandedHeight : import_data_panel_core.CARD_HEADER_HEIGHT;
2458
+ return {
2459
+ bottom: 0,
2460
+ left: defaultLeftOffset + cardHorizontalPosition,
2461
+ width: actualCardWidth,
2462
+ height,
2463
+ maxHeight: viewportHeight * 0.95,
2464
+ borderRadius: `${resolvedCardConfig.borderRadius}px ${resolvedCardConfig.borderRadius}px 0 0`
2465
+ };
2466
+ }
1759
2467
  if (mode === "pinned") {
1760
2468
  const baseStyles = (0, import_data_panel_core.getPinnedPositionStyles)(edge, pinnedSize);
1761
2469
  if (pullOffset > 0) {
@@ -1765,22 +2473,56 @@ var DataPanel = React14.forwardRef(
1765
2473
  return baseStyles;
1766
2474
  }
1767
2475
  return (0, import_data_panel_core.getDetachedPositionStyles)(detachedPosition, detachedSize);
1768
- }, [mode, edge, pinnedSize, detachedPosition, detachedSize, pullOffset]);
2476
+ }, [
2477
+ variant,
2478
+ mode,
2479
+ edge,
2480
+ pinnedSize,
2481
+ detachedPosition,
2482
+ detachedSize,
2483
+ pullOffset,
2484
+ viewportWidth,
2485
+ viewportHeight,
2486
+ cardWidth,
2487
+ cardHorizontalPosition,
2488
+ cardExpandedHeight,
2489
+ cardDragCurrentHeight,
2490
+ isCardVerticalDragging,
2491
+ isCardHeightTransitioning,
2492
+ isExpanded,
2493
+ resolvedCardConfig.horizontalMargin,
2494
+ resolvedCardConfig.maxWidth,
2495
+ resolvedCardConfig.borderRadius
2496
+ ]);
1769
2497
  const pinnedClasses = {
1770
2498
  left: "left-0 top-0 bottom-0 border-r",
1771
2499
  right: "right-0 top-0 bottom-0 border-l",
1772
2500
  top: "top-0 left-0 right-0 border-b",
1773
2501
  bottom: "bottom-0 left-0 right-0 border-t"
1774
2502
  }[edge];
1775
- const animationClass = mode === "pinned" ? {
2503
+ const animationClass = variant === "card" ? "animate-panel-slide-in-bottom" : mode === "pinned" ? {
1776
2504
  left: "animate-slide-right",
1777
2505
  right: "animate-slide-left",
1778
2506
  top: "animate-slide-down",
1779
2507
  bottom: "animate-slide-up"
1780
2508
  }[edge] : "animate-scale-in";
1781
2509
  if (!open) return null;
1782
- if (!isExpanded && mode === "pinned") {
1783
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(DataPanelTab, { title, edge, onClick: () => handleExpandedChange(true) });
2510
+ if (variant === "full" && !isExpanded && mode === "pinned") {
2511
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2512
+ DataPanelTab,
2513
+ {
2514
+ title,
2515
+ subtitle,
2516
+ edge,
2517
+ onClick: () => handleExpandedChange(true),
2518
+ onClose: () => handleOpenChange(false),
2519
+ disableClose,
2520
+ offset: tabOffset,
2521
+ onOffsetChange: setTabOffset,
2522
+ tabWidth,
2523
+ tabInset
2524
+ }
2525
+ );
1784
2526
  }
1785
2527
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
1786
2528
  snapPreview && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
@@ -1795,26 +2537,53 @@ var DataPanel = React14.forwardRef(
1795
2537
  )
1796
2538
  }
1797
2539
  ),
2540
+ variant === "card" && isExpanded && isMobile && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2541
+ "div",
2542
+ {
2543
+ className: "fixed inset-0 z-40 bg-black/50 transition-opacity",
2544
+ "aria-hidden": "true",
2545
+ onClick: handleToggleExpand
2546
+ }
2547
+ ),
1798
2548
  /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1799
2549
  "div",
1800
2550
  {
1801
2551
  ref: setPanelRef,
1802
2552
  className: cn(
1803
2553
  "fixed z-50 flex flex-col bg-background border border-border shadow-lg overflow-hidden",
1804
- mode === "pinned" && pinnedClasses,
1805
- mode === "detached" && "rounded-lg",
2554
+ variant === "full" && mode === "pinned" && pinnedClasses,
2555
+ variant === "full" && mode === "detached" && "rounded-lg",
2556
+ variant === "card" && "rounded-t-lg border-b-0",
1806
2557
  isPinnedDragging && pullOffset > 0 && "shadow-2xl",
2558
+ !isDragging && !isPinnedDragging && !isCardHorizontalDragging && !isCardVerticalDragging && !isResizing && !isCardTopResizing && !isCardWidthResizing && "transition-[height,left,width,transform] duration-300 ease-out",
1807
2559
  animationClass,
1808
2560
  className
1809
2561
  ),
1810
2562
  style: panelStyles,
1811
- role: mode === "detached" ? "dialog" : "complementary",
1812
- "aria-modal": mode === "detached" ? "true" : void 0,
2563
+ role: mode === "detached" || variant === "card" ? "dialog" : "complementary",
2564
+ "aria-modal": isDialog ? "true" : void 0,
1813
2565
  "aria-labelledby": title ? titleId : void 0,
1814
2566
  "aria-label": !title ? "Side panel" : void 0,
1815
- onPointerDown: handleDragStart,
2567
+ "aria-expanded": variant === "card" ? isExpanded : void 0,
2568
+ onPointerDown: variant === "full" ? handleDragStart : void 0,
1816
2569
  children: [
1817
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2570
+ variant === "card" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2571
+ DataPanelCardHeader,
2572
+ {
2573
+ title,
2574
+ subtitle,
2575
+ titleId,
2576
+ isExpanded,
2577
+ isMobile,
2578
+ showDragHandle: resolvedCardConfig.showDragHandle,
2579
+ headerContent,
2580
+ headerActions,
2581
+ disableClose,
2582
+ onHeaderPointerDown: handleCardHeaderPointerDown,
2583
+ onToggleExpand: handleToggleExpand,
2584
+ onClose: () => handleOpenChange(false)
2585
+ }
2586
+ ) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1818
2587
  DataPanelHeader,
1819
2588
  {
1820
2589
  title,
@@ -1834,24 +2603,30 @@ var DataPanel = React14.forwardRef(
1834
2603
  draggable: !disableDrag && (mode === "detached" || mode === "pinned" && detachThreshold > 0)
1835
2604
  }
1836
2605
  ),
1837
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(DataPanelContent, { children }),
1838
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1839
- DataPanelFooter,
1840
- {
1841
- actions,
1842
- footerContent,
1843
- footerActions
1844
- }
1845
- ),
1846
- !disableResize && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2606
+ showContent && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
2607
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(DataPanelContent, { children }),
2608
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2609
+ DataPanelFooter,
2610
+ {
2611
+ actions,
2612
+ footerContent,
2613
+ footerActions
2614
+ }
2615
+ )
2616
+ ] }),
2617
+ variant === "full" && !disableResize && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1847
2618
  ResizeHandles,
1848
2619
  {
1849
2620
  mode,
1850
2621
  edge,
2622
+ detachedPosition,
1851
2623
  detachedSize,
1852
2624
  pinnedSize,
1853
2625
  onResizeStart: handleResizeStart,
1854
- onSizeChange: (size) => setDetachedSize((0, import_data_panel_core.constrainSize)(size, resolvedConstraints)),
2626
+ onDetachedResize: (position, size) => {
2627
+ setDetachedSize(size);
2628
+ setDetachedPosition(position);
2629
+ },
1855
2630
  onPinnedSizeChange: (size) => {
1856
2631
  if (typeof window === "undefined") {
1857
2632
  setPinnedSize(size);
@@ -1867,7 +2642,57 @@ var DataPanel = React14.forwardRef(
1867
2642
  },
1868
2643
  constraints: resolvedConstraints
1869
2644
  }
1870
- )
2645
+ ),
2646
+ variant === "card" && isExpanded && !disableResize && !isMobile && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
2647
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2648
+ "div",
2649
+ {
2650
+ className: "resize-handle resize-handle--horizontal resize-handle--top",
2651
+ role: "slider",
2652
+ tabIndex: 0,
2653
+ "aria-orientation": "vertical",
2654
+ "aria-label": "Resize card height",
2655
+ "aria-valuenow": Math.round(cardExpandedHeight),
2656
+ "aria-valuemin": cardHeightMin,
2657
+ "aria-valuemax": cardHeightMax,
2658
+ "aria-valuetext": `${Math.round(cardExpandedHeight)} pixels`,
2659
+ onPointerDown: handleCardResizeStart,
2660
+ onKeyDown: (e) => handleCardResizeKeyDown(e, "height")
2661
+ }
2662
+ ),
2663
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2664
+ "div",
2665
+ {
2666
+ className: "resize-handle resize-handle--vertical resize-handle--left resize-handle--card-edge",
2667
+ role: "slider",
2668
+ tabIndex: 0,
2669
+ "aria-orientation": "horizontal",
2670
+ "aria-label": "Resize card width from left edge",
2671
+ "aria-valuenow": Math.round(cardCurrentWidth),
2672
+ "aria-valuemin": import_data_panel_core.CARD_MIN_WIDTH,
2673
+ "aria-valuemax": resolvedCardConfig.maxWidth,
2674
+ "aria-valuetext": `${Math.round(cardCurrentWidth)} pixels`,
2675
+ onPointerDown: (e) => handleCardWidthResizeStart(e, "left"),
2676
+ onKeyDown: (e) => handleCardResizeKeyDown(e, "width-left")
2677
+ }
2678
+ ),
2679
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2680
+ "div",
2681
+ {
2682
+ className: "resize-handle resize-handle--vertical resize-handle--right resize-handle--card-edge",
2683
+ role: "slider",
2684
+ tabIndex: 0,
2685
+ "aria-orientation": "horizontal",
2686
+ "aria-label": "Resize card width from right edge",
2687
+ "aria-valuenow": Math.round(cardCurrentWidth),
2688
+ "aria-valuemin": import_data_panel_core.CARD_MIN_WIDTH,
2689
+ "aria-valuemax": resolvedCardConfig.maxWidth,
2690
+ "aria-valuetext": `${Math.round(cardCurrentWidth)} pixels`,
2691
+ onPointerDown: (e) => handleCardWidthResizeStart(e, "right"),
2692
+ onKeyDown: (e) => handleCardResizeKeyDown(e, "width-right")
2693
+ }
2694
+ )
2695
+ ] })
1871
2696
  ]
1872
2697
  }
1873
2698
  )