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