@classic-homes/theme-react 0.1.55 → 0.1.56

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.
Files changed (3) hide show
  1. package/dist/index.js +230 -213
  2. package/dist/index.mjs +242 -225
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -749,8 +749,116 @@ var PageHeader = React12.forwardRef(
749
749
  PageHeader.displayName = "PageHeader";
750
750
 
751
751
  // src/components/DataPanel.tsx
752
- var React13 = __toESM(require("react"));
752
+ var React14 = __toESM(require("react"));
753
753
  var DropdownMenuPrimitive = __toESM(require("@radix-ui/react-dropdown-menu"));
754
+
755
+ // src/hooks/useFocusTrap.ts
756
+ var import_react = require("react");
757
+ var FOCUSABLE_SELECTOR = [
758
+ "a[href]",
759
+ "area[href]",
760
+ 'input:not([disabled]):not([type="hidden"])',
761
+ "select:not([disabled])",
762
+ "textarea:not([disabled])",
763
+ "button:not([disabled])",
764
+ "iframe",
765
+ "object",
766
+ "embed",
767
+ "[contenteditable]",
768
+ '[tabindex]:not([tabindex="-1"])'
769
+ ].join(",");
770
+ function getFocusableElements(container) {
771
+ const elements = container.querySelectorAll(FOCUSABLE_SELECTOR);
772
+ return Array.from(elements).filter(
773
+ (el) => el.offsetParent !== null && getComputedStyle(el).visibility !== "hidden"
774
+ );
775
+ }
776
+ function useFocusTrap(options = {}) {
777
+ const { active = true, returnFocusTo, initialFocus, preventScroll = false } = options;
778
+ const containerRef = (0, import_react.useRef)(null);
779
+ const previousActiveElementRef = (0, import_react.useRef)(null);
780
+ const handleKeyDown = (0, import_react.useCallback)(
781
+ (event) => {
782
+ if (!active || event.key !== "Tab") return;
783
+ const container = containerRef.current;
784
+ if (!container) return;
785
+ const focusableElements = getFocusableElements(container);
786
+ if (focusableElements.length === 0) return;
787
+ const firstElement = focusableElements[0];
788
+ const lastElement = focusableElements[focusableElements.length - 1];
789
+ if (event.shiftKey) {
790
+ if (document.activeElement === firstElement) {
791
+ event.preventDefault();
792
+ lastElement.focus({ preventScroll });
793
+ }
794
+ } else {
795
+ if (document.activeElement === lastElement) {
796
+ event.preventDefault();
797
+ firstElement.focus({ preventScroll });
798
+ }
799
+ }
800
+ },
801
+ [active, preventScroll]
802
+ );
803
+ (0, import_react.useEffect)(() => {
804
+ if (!active) return;
805
+ const container = containerRef.current;
806
+ if (!container) return;
807
+ previousActiveElementRef.current = document.activeElement;
808
+ const focusableElements = getFocusableElements(container);
809
+ if (focusableElements.length > 0) {
810
+ let elementToFocus = null;
811
+ if (initialFocus) {
812
+ elementToFocus = container.querySelector(initialFocus);
813
+ }
814
+ if (!elementToFocus) {
815
+ elementToFocus = focusableElements[0];
816
+ }
817
+ requestAnimationFrame(() => {
818
+ elementToFocus?.focus({ preventScroll });
819
+ });
820
+ }
821
+ document.addEventListener("keydown", handleKeyDown);
822
+ return () => {
823
+ document.removeEventListener("keydown", handleKeyDown);
824
+ const elementToReturn = returnFocusTo ?? previousActiveElementRef.current;
825
+ if (elementToReturn && typeof elementToReturn.focus === "function") {
826
+ elementToReturn.focus({ preventScroll });
827
+ }
828
+ };
829
+ }, [active, initialFocus, returnFocusTo, handleKeyDown, preventScroll]);
830
+ return containerRef;
831
+ }
832
+
833
+ // src/hooks/useEscapeKey.ts
834
+ var React13 = __toESM(require("react"));
835
+ function useEscapeKey(callback, options) {
836
+ const { enabled = true, preventDefault = true, stopPropagation = false } = options ?? {};
837
+ const callbackRef = React13.useRef(callback);
838
+ React13.useEffect(() => {
839
+ callbackRef.current = callback;
840
+ }, [callback]);
841
+ React13.useEffect(() => {
842
+ if (!enabled) return;
843
+ const handleKeyDown = (event) => {
844
+ if (event.key === "Escape") {
845
+ if (preventDefault) {
846
+ event.preventDefault();
847
+ }
848
+ if (stopPropagation) {
849
+ event.stopPropagation();
850
+ }
851
+ callbackRef.current(event);
852
+ }
853
+ };
854
+ document.addEventListener("keydown", handleKeyDown);
855
+ return () => {
856
+ document.removeEventListener("keydown", handleKeyDown);
857
+ };
858
+ }, [enabled, preventDefault, stopPropagation]);
859
+ }
860
+
861
+ // src/components/DataPanel.tsx
754
862
  var import_data_panel_core = require("@classic-homes/data-panel-core");
755
863
  var import_jsx_runtime12 = require("react/jsx-runtime");
756
864
  var DropdownTrigger = DropdownMenuPrimitive.Trigger;
@@ -767,28 +875,28 @@ function useDataPanel(options = {}) {
767
875
  constraints = {}
768
876
  } = options;
769
877
  const resolvedConstraints = { ...import_data_panel_core.DEFAULT_CONSTRAINTS, ...constraints };
770
- const [persistedState] = React13.useState(() => {
878
+ const [persistedState] = React14.useState(() => {
771
879
  if (persistKey && typeof window !== "undefined") {
772
880
  return (0, import_data_panel_core.loadPanelState)(persistKey);
773
881
  }
774
882
  return null;
775
883
  });
776
- const [mode, setMode] = React13.useState(persistedState?.mode ?? initialMode);
777
- const [edge, setEdge] = React13.useState(persistedState?.edge ?? initialEdge);
778
- const [isExpanded, setIsExpanded] = React13.useState(
884
+ const [mode, setMode] = React14.useState(persistedState?.mode ?? initialMode);
885
+ const [edge, setEdge] = React14.useState(persistedState?.edge ?? initialEdge);
886
+ const [isExpanded, setIsExpanded] = React14.useState(
779
887
  persistedState?.isExpanded ?? initialExpanded
780
888
  );
781
- const [detachedPosition, setDetachedPosition] = React13.useState(
889
+ const [detachedPosition, setDetachedPosition] = React14.useState(
782
890
  persistedState?.detachedPosition ?? import_data_panel_core.DEFAULT_PANEL_STATE.detachedPosition
783
891
  );
784
- const [detachedSize, setDetachedSize] = React13.useState(
892
+ const [detachedSize, setDetachedSize] = React14.useState(
785
893
  persistedState?.detachedSize ?? import_data_panel_core.DEFAULT_PANEL_STATE.detachedSize
786
894
  );
787
- const [pinnedSize, setPinnedSize] = React13.useState(
895
+ const [pinnedSize, setPinnedSize] = React14.useState(
788
896
  persistedState?.pinnedSize ?? import_data_panel_core.DEFAULT_PANEL_STATE.pinnedSize
789
897
  );
790
- const saveTimeoutRef = React13.useRef(null);
791
- const debouncedSave = React13.useCallback(() => {
898
+ const saveTimeoutRef = React14.useRef(null);
899
+ const debouncedSave = React14.useCallback(() => {
792
900
  if (!persistKey) return;
793
901
  if (saveTimeoutRef.current) {
794
902
  clearTimeout(saveTimeoutRef.current);
@@ -806,7 +914,7 @@ function useDataPanel(options = {}) {
806
914
  });
807
915
  }, 300);
808
916
  }, [persistKey, mode, edge, isExpanded, detachedPosition, detachedSize, pinnedSize]);
809
- const handleSetMode = React13.useCallback(
917
+ const handleSetMode = React14.useCallback(
810
918
  (newMode) => {
811
919
  setMode(newMode);
812
920
  if (newMode === "detached" && typeof window !== "undefined" && detachedPosition.x === import_data_panel_core.DEFAULT_PANEL_STATE.detachedPosition.x && detachedPosition.y === import_data_panel_core.DEFAULT_PANEL_STATE.detachedPosition.y) {
@@ -817,7 +925,7 @@ function useDataPanel(options = {}) {
817
925
  },
818
926
  [detachedPosition, detachedSize]
819
927
  );
820
- const handleSetDetachedPosition = React13.useCallback(
928
+ const handleSetDetachedPosition = React14.useCallback(
821
929
  (position) => {
822
930
  if (typeof window === "undefined") {
823
931
  setDetachedPosition(position);
@@ -829,13 +937,13 @@ function useDataPanel(options = {}) {
829
937
  },
830
938
  [detachedSize]
831
939
  );
832
- const handleSetDetachedSize = React13.useCallback(
940
+ const handleSetDetachedSize = React14.useCallback(
833
941
  (size) => {
834
942
  setDetachedSize((0, import_data_panel_core.constrainSize)(size, resolvedConstraints));
835
943
  },
836
944
  [resolvedConstraints]
837
945
  );
838
- const handleSetPinnedSize = React13.useCallback(
946
+ const handleSetPinnedSize = React14.useCallback(
839
947
  (size) => {
840
948
  if (typeof window === "undefined") {
841
949
  setPinnedSize(size);
@@ -849,7 +957,7 @@ function useDataPanel(options = {}) {
849
957
  },
850
958
  [edge, resolvedConstraints]
851
959
  );
852
- React13.useEffect(() => {
960
+ React14.useEffect(() => {
853
961
  debouncedSave();
854
962
  }, [debouncedSave]);
855
963
  return {
@@ -925,7 +1033,7 @@ var edgeLabels = {
925
1033
  top: "Pin to top",
926
1034
  bottom: "Pin to bottom"
927
1035
  };
928
- var DataPanelHeader = React13.forwardRef(
1036
+ var DataPanelHeader = React14.forwardRef(
929
1037
  ({
930
1038
  title,
931
1039
  subtitle,
@@ -1038,7 +1146,7 @@ var DataPanelHeader = React13.forwardRef(
1038
1146
  }
1039
1147
  );
1040
1148
  DataPanelHeader.displayName = "DataPanelHeader";
1041
- var DataPanelContent = React13.forwardRef(
1149
+ var DataPanelContent = React14.forwardRef(
1042
1150
  ({ children, className, "aria-label": ariaLabel = "Panel content" }, ref) => {
1043
1151
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1044
1152
  "div",
@@ -1053,7 +1161,7 @@ var DataPanelContent = React13.forwardRef(
1053
1161
  }
1054
1162
  );
1055
1163
  DataPanelContent.displayName = "DataPanelContent";
1056
- var DataPanelFooter = React13.forwardRef(
1164
+ var DataPanelFooter = React14.forwardRef(
1057
1165
  ({ actions = [], footerContent, footerActions, className }, ref) => {
1058
1166
  if (!footerContent && actions.length === 0 && !footerActions) {
1059
1167
  return null;
@@ -1089,7 +1197,7 @@ var DataPanelFooter = React13.forwardRef(
1089
1197
  }
1090
1198
  );
1091
1199
  DataPanelFooter.displayName = "DataPanelFooter";
1092
- var DataPanelTab = React13.forwardRef(
1200
+ var DataPanelTab = React14.forwardRef(
1093
1201
  ({ title = "Panel", edge, onClick, className }, ref) => {
1094
1202
  const positionClasses = {
1095
1203
  left: "left-0 top-1/2 -translate-y-1/2 rounded-r-md border-l-0",
@@ -1138,7 +1246,7 @@ function ResizeHandles({
1138
1246
  onPinnedSizeChange,
1139
1247
  constraints
1140
1248
  }) {
1141
- const handleDetachedKeyDown = React13.useCallback(
1249
+ const handleDetachedKeyDown = React14.useCallback(
1142
1250
  (e, handle) => {
1143
1251
  const step = e.shiftKey ? KEYBOARD_RESIZE_STEP_LARGE : KEYBOARD_RESIZE_STEP;
1144
1252
  let newSize = { ...detachedSize };
@@ -1188,7 +1296,7 @@ function ResizeHandles({
1188
1296
  },
1189
1297
  [detachedSize, constraints, onSizeChange]
1190
1298
  );
1191
- const handlePinnedKeyDown = React13.useCallback(
1299
+ const handlePinnedKeyDown = React14.useCallback(
1192
1300
  (e) => {
1193
1301
  const step = e.shiftKey ? KEYBOARD_RESIZE_STEP_LARGE : KEYBOARD_RESIZE_STEP;
1194
1302
  let newSize = pinnedSize;
@@ -1305,7 +1413,7 @@ function ResizeHandles({
1305
1413
  }
1306
1414
  );
1307
1415
  }
1308
- var DataPanel = React13.forwardRef(
1416
+ var DataPanel = React14.forwardRef(
1309
1417
  ({
1310
1418
  open: controlledOpen,
1311
1419
  onOpenChange,
@@ -1334,33 +1442,33 @@ var DataPanel = React13.forwardRef(
1334
1442
  className
1335
1443
  }, ref) => {
1336
1444
  const resolvedConstraints = { ...import_data_panel_core.DEFAULT_CONSTRAINTS, ...constraints };
1337
- const panelId = React13.useId();
1445
+ const panelId = React14.useId();
1338
1446
  const titleId = `${panelId}-title`;
1339
- const [internalOpen, setInternalOpen] = React13.useState(true);
1340
- const [internalMode, setInternalMode] = React13.useState(import_data_panel_core.DEFAULT_PANEL_STATE.mode);
1341
- const [internalEdge, setInternalEdge] = React13.useState(import_data_panel_core.DEFAULT_PANEL_STATE.edge);
1342
- const [internalExpanded, setInternalExpanded] = React13.useState(
1447
+ const [internalOpen, setInternalOpen] = React14.useState(true);
1448
+ const [internalMode, setInternalMode] = React14.useState(import_data_panel_core.DEFAULT_PANEL_STATE.mode);
1449
+ const [internalEdge, setInternalEdge] = React14.useState(import_data_panel_core.DEFAULT_PANEL_STATE.edge);
1450
+ const [internalExpanded, setInternalExpanded] = React14.useState(
1343
1451
  import_data_panel_core.DEFAULT_PANEL_STATE.isExpanded
1344
1452
  );
1345
- const [detachedPosition, setDetachedPosition] = React13.useState(
1453
+ const [detachedPosition, setDetachedPosition] = React14.useState(
1346
1454
  import_data_panel_core.DEFAULT_PANEL_STATE.detachedPosition
1347
1455
  );
1348
- const [detachedSize, setDetachedSize] = React13.useState(import_data_panel_core.DEFAULT_PANEL_STATE.detachedSize);
1349
- const [pinnedSize, setPinnedSize] = React13.useState(import_data_panel_core.DEFAULT_PANEL_STATE.pinnedSize);
1350
- const [isDragging, setIsDragging] = React13.useState(false);
1351
- const [isResizing, setIsResizing] = React13.useState(false);
1352
- const [snapPreview, setSnapPreview] = React13.useState(null);
1353
- const [isPinnedDragging, setIsPinnedDragging] = React13.useState(false);
1354
- const [pullOffset, setPullOffset] = React13.useState(0);
1355
- const dragStateRef = React13.useRef({
1456
+ const [detachedSize, setDetachedSize] = React14.useState(import_data_panel_core.DEFAULT_PANEL_STATE.detachedSize);
1457
+ const [pinnedSize, setPinnedSize] = React14.useState(import_data_panel_core.DEFAULT_PANEL_STATE.pinnedSize);
1458
+ const [isDragging, setIsDragging] = React14.useState(false);
1459
+ const [isResizing, setIsResizing] = React14.useState(false);
1460
+ const [snapPreview, setSnapPreview] = React14.useState(null);
1461
+ const [isPinnedDragging, setIsPinnedDragging] = React14.useState(false);
1462
+ const [pullOffset, setPullOffset] = React14.useState(0);
1463
+ const dragStateRef = React14.useRef({
1356
1464
  startPosition: { x: 0, y: 0 },
1357
1465
  startPanelPosition: { x: 0, y: 0 }
1358
1466
  });
1359
- const pinnedDragStateRef = React13.useRef({
1467
+ const pinnedDragStateRef = React14.useRef({
1360
1468
  startPosition: { x: 0, y: 0 },
1361
1469
  hasDetached: false
1362
1470
  });
1363
- const resizeStateRef = React13.useRef({
1471
+ const resizeStateRef = React14.useRef({
1364
1472
  handle: null,
1365
1473
  startPosition: { x: 0, y: 0 },
1366
1474
  startSize: { width: 0, height: 0 },
@@ -1370,34 +1478,29 @@ var DataPanel = React13.forwardRef(
1370
1478
  const mode = controlledMode ?? internalMode;
1371
1479
  const edge = controlledEdge ?? internalEdge;
1372
1480
  const isExpanded = controlledExpanded ?? internalExpanded;
1373
- const saveTimeoutRef = React13.useRef(null);
1374
- const debouncedSave = React13.useCallback(() => {
1481
+ const saveTimeoutRef = React14.useRef(null);
1482
+ const debouncedSave = React14.useCallback(() => {
1375
1483
  if (!persistKey) return;
1376
1484
  if (saveTimeoutRef.current) {
1377
1485
  clearTimeout(saveTimeoutRef.current);
1378
1486
  }
1379
1487
  saveTimeoutRef.current = setTimeout(() => {
1380
1488
  (0, import_data_panel_core.savePanelState)(persistKey, {
1381
- mode: internalMode,
1489
+ mode,
1382
1490
  variant: "full",
1383
- edge: internalEdge,
1384
- isExpanded: internalExpanded,
1491
+ edge,
1492
+ isExpanded,
1385
1493
  detachedPosition,
1386
1494
  detachedSize,
1387
1495
  pinnedSize,
1388
1496
  cardSnapIndex: 0
1389
1497
  });
1390
1498
  }, 300);
1391
- }, [
1392
- persistKey,
1393
- internalMode,
1394
- internalEdge,
1395
- internalExpanded,
1396
- detachedPosition,
1397
- detachedSize,
1398
- pinnedSize
1399
- ]);
1400
- React13.useEffect(() => {
1499
+ }, [persistKey, mode, edge, isExpanded, detachedPosition, detachedSize, pinnedSize]);
1500
+ React14.useEffect(() => {
1501
+ debouncedSave();
1502
+ }, [debouncedSave]);
1503
+ React14.useEffect(() => {
1401
1504
  if (!persistKey) return;
1402
1505
  const persisted = (0, import_data_panel_core.loadPanelState)(persistKey);
1403
1506
  if (persisted) {
@@ -1410,7 +1513,7 @@ var DataPanel = React13.forwardRef(
1410
1513
  if (persisted.pinnedSize) setPinnedSize(persisted.pinnedSize);
1411
1514
  }
1412
1515
  }, [persistKey, controlledMode, controlledEdge, controlledExpanded]);
1413
- React13.useEffect(() => {
1516
+ React14.useEffect(() => {
1414
1517
  if (mode === "detached" && detachedPosition.x === import_data_panel_core.DEFAULT_PANEL_STATE.detachedPosition.x && detachedPosition.y === import_data_panel_core.DEFAULT_PANEL_STATE.detachedPosition.y) {
1415
1518
  setDetachedPosition(
1416
1519
  (0, import_data_panel_core.getInitialDetachedPosition)(detachedSize, window.innerWidth, window.innerHeight)
@@ -1423,26 +1526,39 @@ var DataPanel = React13.forwardRef(
1423
1526
  }
1424
1527
  onOpenChange?.(newOpen);
1425
1528
  };
1529
+ const isDetachedDialog = open && mode === "detached";
1530
+ const focusTrapRef = useFocusTrap({ active: isDetachedDialog });
1531
+ useEscapeKey(
1532
+ () => {
1533
+ if (!disableClose) handleOpenChange(false);
1534
+ },
1535
+ { enabled: isDetachedDialog }
1536
+ );
1537
+ const setPanelRef = (node) => {
1538
+ focusTrapRef.current = node;
1539
+ if (typeof ref === "function") {
1540
+ ref(node);
1541
+ } else if (ref) {
1542
+ ref.current = node;
1543
+ }
1544
+ };
1426
1545
  const handleModeChange = (newMode) => {
1427
1546
  if (controlledMode === void 0) {
1428
1547
  setInternalMode(newMode);
1429
1548
  }
1430
1549
  onModeChange?.(newMode);
1431
- debouncedSave();
1432
1550
  };
1433
1551
  const handleEdgeChange = (newEdge) => {
1434
1552
  if (controlledEdge === void 0) {
1435
1553
  setInternalEdge(newEdge);
1436
1554
  }
1437
1555
  onEdgeChange?.(newEdge);
1438
- debouncedSave();
1439
1556
  };
1440
1557
  const handleExpandedChange = (newExpanded) => {
1441
1558
  if (controlledExpanded === void 0) {
1442
1559
  setInternalExpanded(newExpanded);
1443
1560
  }
1444
1561
  onExpandedChange?.(newExpanded);
1445
- debouncedSave();
1446
1562
  };
1447
1563
  const handleDragStart = (e) => {
1448
1564
  if (disableDrag) return;
@@ -1468,7 +1584,7 @@ var DataPanel = React13.forwardRef(
1468
1584
  document.body.style.userSelect = "none";
1469
1585
  }
1470
1586
  };
1471
- const handleDragMove = React13.useCallback(
1587
+ const handleDragMove = React14.useCallback(
1472
1588
  (e) => {
1473
1589
  if (!isDragging) return;
1474
1590
  const currentPos = (0, import_data_panel_core.getPointerPosition)(e);
@@ -1495,7 +1611,7 @@ var DataPanel = React13.forwardRef(
1495
1611
  },
1496
1612
  [isDragging, detachedSize, snapThreshold]
1497
1613
  );
1498
- const handleDragEnd = React13.useCallback(() => {
1614
+ const handleDragEnd = React14.useCallback(() => {
1499
1615
  if (!isDragging) return;
1500
1616
  setIsDragging(false);
1501
1617
  document.body.style.cursor = "";
@@ -1504,11 +1620,9 @@ var DataPanel = React13.forwardRef(
1504
1620
  handleModeChange("pinned");
1505
1621
  handleEdgeChange(snapPreview);
1506
1622
  setSnapPreview(null);
1507
- } else {
1508
- debouncedSave();
1509
1623
  }
1510
- }, [isDragging, snapPreview, handleModeChange, handleEdgeChange, debouncedSave]);
1511
- const handlePinnedDragMove = React13.useCallback(
1624
+ }, [isDragging, snapPreview, handleModeChange, handleEdgeChange]);
1625
+ const handlePinnedDragMove = React14.useCallback(
1512
1626
  (e) => {
1513
1627
  if (!isPinnedDragging) return;
1514
1628
  const currentPos = (0, import_data_panel_core.getPointerPosition)(e);
@@ -1544,7 +1658,7 @@ var DataPanel = React13.forwardRef(
1544
1658
  },
1545
1659
  [isPinnedDragging, edge, detachThreshold, pinnedSize, detachedSize, handleModeChange]
1546
1660
  );
1547
- const handlePinnedDragEnd = React13.useCallback(() => {
1661
+ const handlePinnedDragEnd = React14.useCallback(() => {
1548
1662
  if (!isPinnedDragging) return;
1549
1663
  setIsPinnedDragging(false);
1550
1664
  setPullOffset(0);
@@ -1566,7 +1680,7 @@ var DataPanel = React13.forwardRef(
1566
1680
  document.body.style.cursor = (0, import_data_panel_core.getResizeCursor)(handle);
1567
1681
  document.body.style.userSelect = "none";
1568
1682
  };
1569
- const handleResizeMove = React13.useCallback(
1683
+ const handleResizeMove = React14.useCallback(
1570
1684
  (e) => {
1571
1685
  if (!isResizing || !resizeStateRef.current.handle) return;
1572
1686
  const currentPos = (0, import_data_panel_core.getPointerPosition)(e);
@@ -1604,15 +1718,14 @@ var DataPanel = React13.forwardRef(
1604
1718
  },
1605
1719
  [isResizing, mode, edge, resolvedConstraints]
1606
1720
  );
1607
- const handleResizeEnd = React13.useCallback(() => {
1721
+ const handleResizeEnd = React14.useCallback(() => {
1608
1722
  if (!isResizing) return;
1609
1723
  setIsResizing(false);
1610
1724
  resizeStateRef.current.handle = null;
1611
1725
  document.body.style.cursor = "";
1612
1726
  document.body.style.userSelect = "";
1613
- debouncedSave();
1614
- }, [isResizing, debouncedSave]);
1615
- React13.useEffect(() => {
1727
+ }, [isResizing]);
1728
+ React14.useEffect(() => {
1616
1729
  if (isDragging) {
1617
1730
  window.addEventListener("pointermove", handleDragMove);
1618
1731
  window.addEventListener("pointerup", handleDragEnd);
@@ -1622,7 +1735,7 @@ var DataPanel = React13.forwardRef(
1622
1735
  };
1623
1736
  }
1624
1737
  }, [isDragging, handleDragMove, handleDragEnd]);
1625
- React13.useEffect(() => {
1738
+ React14.useEffect(() => {
1626
1739
  if (isPinnedDragging) {
1627
1740
  window.addEventListener("pointermove", handlePinnedDragMove);
1628
1741
  window.addEventListener("pointerup", handlePinnedDragEnd);
@@ -1632,7 +1745,7 @@ var DataPanel = React13.forwardRef(
1632
1745
  };
1633
1746
  }
1634
1747
  }, [isPinnedDragging, handlePinnedDragMove, handlePinnedDragEnd]);
1635
- React13.useEffect(() => {
1748
+ React14.useEffect(() => {
1636
1749
  if (isResizing) {
1637
1750
  window.addEventListener("pointermove", handleResizeMove);
1638
1751
  window.addEventListener("pointerup", handleResizeEnd);
@@ -1642,7 +1755,7 @@ var DataPanel = React13.forwardRef(
1642
1755
  };
1643
1756
  }
1644
1757
  }, [isResizing, handleResizeMove, handleResizeEnd]);
1645
- const panelStyles = React13.useMemo(() => {
1758
+ const panelStyles = React14.useMemo(() => {
1646
1759
  if (mode === "pinned") {
1647
1760
  const baseStyles = (0, import_data_panel_core.getPinnedPositionStyles)(edge, pinnedSize);
1648
1761
  if (pullOffset > 0) {
@@ -1685,7 +1798,7 @@ var DataPanel = React13.forwardRef(
1685
1798
  /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1686
1799
  "div",
1687
1800
  {
1688
- ref,
1801
+ ref: setPanelRef,
1689
1802
  className: cn(
1690
1803
  "fixed z-50 flex flex-col bg-background border border-border shadow-lg overflow-hidden",
1691
1804
  mode === "pinned" && pinnedClasses,
@@ -1764,7 +1877,7 @@ var DataPanel = React13.forwardRef(
1764
1877
  DataPanel.displayName = "DataPanel";
1765
1878
 
1766
1879
  // src/components/Skeleton.tsx
1767
- var React14 = __toESM(require("react"));
1880
+ var React15 = __toESM(require("react"));
1768
1881
  var import_class_variance_authority5 = require("class-variance-authority");
1769
1882
  var import_jsx_runtime13 = require("react/jsx-runtime");
1770
1883
  var skeletonVariants = (0, import_class_variance_authority5.cva)("rounded-md bg-muted", {
@@ -1782,7 +1895,7 @@ var skeletonVariants = (0, import_class_variance_authority5.cva)("rounded-md bg-
1782
1895
  variant: "default"
1783
1896
  }
1784
1897
  });
1785
- var Skeleton = React14.forwardRef(
1898
+ var Skeleton = React15.forwardRef(
1786
1899
  ({ className, variant, animation = "pulse", ...props }, ref) => {
1787
1900
  const animationClass = animation === "pulse" ? "animate-pulse" : animation === "shimmer" ? "animate-shimmer" : "";
1788
1901
  return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
@@ -1798,7 +1911,7 @@ var Skeleton = React14.forwardRef(
1798
1911
  Skeleton.displayName = "Skeleton";
1799
1912
 
1800
1913
  // src/components/Spinner.tsx
1801
- var React15 = __toESM(require("react"));
1914
+ var React16 = __toESM(require("react"));
1802
1915
  var import_class_variance_authority6 = require("class-variance-authority");
1803
1916
  var import_jsx_runtime14 = require("react/jsx-runtime");
1804
1917
  var spinnerVariants = (0, import_class_variance_authority6.cva)("animate-spin text-current", {
@@ -1814,7 +1927,7 @@ var spinnerVariants = (0, import_class_variance_authority6.cva)("animate-spin te
1814
1927
  size: "md"
1815
1928
  }
1816
1929
  });
1817
- var Spinner = React15.forwardRef(
1930
+ var Spinner = React16.forwardRef(
1818
1931
  ({ className, size, label = "Loading...", ...props }, ref) => {
1819
1932
  return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
1820
1933
  "svg",
@@ -1856,7 +1969,7 @@ var Spinner = React15.forwardRef(
1856
1969
  Spinner.displayName = "Spinner";
1857
1970
 
1858
1971
  // src/components/LoadingLogo.tsx
1859
- var React16 = __toESM(require("react"));
1972
+ var React17 = __toESM(require("react"));
1860
1973
  var import_jsx_runtime15 = require("react/jsx-runtime");
1861
1974
  var logoPaths = [
1862
1975
  "M9.902 16.6c.3.7 1.7.8 1-.6-.6-1.4-2.3-5.1-6.1-6.3-1.7-.5-3.7.4-4.3 1.6-.4.7-1.1 2.9.5 4.3.8.7 1.9 1.2 3.6 1 .4-.1.9-.5.6-.8-.5-.4-1.9-1.7-1.1-2.7.7-.8 1.4-.6 2-.3.4.2 2.1 1 3.7 3.6l.1.2z",
@@ -1879,7 +1992,7 @@ var colors = {
1879
1992
  stroke: "#ffffff"
1880
1993
  }
1881
1994
  };
1882
- var LoadingLogo = React16.forwardRef(
1995
+ var LoadingLogo = React17.forwardRef(
1883
1996
  ({ width = 40, height = 40, loading = false, variant = "dark", className, ...props }, ref) => {
1884
1997
  const currentColors = colors[variant];
1885
1998
  const fillColor = loading ? currentColors.fillLoading : currentColors.fill;
@@ -1928,7 +2041,7 @@ var LoadingLogo = React16.forwardRef(
1928
2041
  LoadingLogo.displayName = "LoadingLogo";
1929
2042
 
1930
2043
  // src/components/ProgressBar.tsx
1931
- var React17 = __toESM(require("react"));
2044
+ var React18 = __toESM(require("react"));
1932
2045
  var import_class_variance_authority7 = require("class-variance-authority");
1933
2046
  var import_jsx_runtime16 = require("react/jsx-runtime");
1934
2047
  var progressBarVariants = (0, import_class_variance_authority7.cva)("w-full overflow-hidden rounded-full bg-muted", {
@@ -1956,7 +2069,7 @@ var progressFillVariants = (0, import_class_variance_authority7.cva)("h-full rou
1956
2069
  variant: "default"
1957
2070
  }
1958
2071
  });
1959
- var ProgressBar = React17.forwardRef(
2072
+ var ProgressBar = React18.forwardRef(
1960
2073
  ({ className, size, variant, value, max = 100, label = "Progress", showValue = false, ...props }, ref) => {
1961
2074
  const isIndeterminate = value === void 0;
1962
2075
  const clampedValue = isIndeterminate ? 0 : Math.min(Math.max(0, value), max);
@@ -1995,11 +2108,11 @@ var ProgressBar = React17.forwardRef(
1995
2108
  ProgressBar.displayName = "ProgressBar";
1996
2109
 
1997
2110
  // src/components/LoadingOverlay.tsx
1998
- var React18 = __toESM(require("react"));
2111
+ var React19 = __toESM(require("react"));
1999
2112
  var import_jsx_runtime17 = require("react/jsx-runtime");
2000
2113
  var spinnerSizeMap = { sm: "sm", md: "md", lg: "lg", xl: "xl" };
2001
2114
  var logoSizeMap = { sm: 32, md: 40, lg: 56, xl: 80 };
2002
- var LoadingOverlay = React18.forwardRef(
2115
+ var LoadingOverlay = React19.forwardRef(
2003
2116
  ({
2004
2117
  loading = true,
2005
2118
  variant = "spinner",
@@ -2014,8 +2127,8 @@ var LoadingOverlay = React18.forwardRef(
2014
2127
  children,
2015
2128
  ...props
2016
2129
  }, ref) => {
2017
- const [visible, setVisible] = React18.useState(delay === 0 && loading);
2018
- React18.useEffect(() => {
2130
+ const [visible, setVisible] = React19.useState(delay === 0 && loading);
2131
+ React19.useEffect(() => {
2019
2132
  if (!loading) {
2020
2133
  setVisible(false);
2021
2134
  return;
@@ -2083,9 +2196,9 @@ var LoadingOverlay = React18.forwardRef(
2083
2196
  LoadingOverlay.displayName = "LoadingOverlay";
2084
2197
 
2085
2198
  // src/components/LoadingPage.tsx
2086
- var React19 = __toESM(require("react"));
2199
+ var React20 = __toESM(require("react"));
2087
2200
  var import_jsx_runtime18 = require("react/jsx-runtime");
2088
- var LoadingPage = React19.forwardRef(
2201
+ var LoadingPage = React20.forwardRef(
2089
2202
  ({
2090
2203
  loading = true,
2091
2204
  message,
@@ -2096,8 +2209,8 @@ var LoadingPage = React19.forwardRef(
2096
2209
  className,
2097
2210
  ...props
2098
2211
  }, ref) => {
2099
- const [visible, setVisible] = React19.useState(delay === 0 && loading);
2100
- React19.useEffect(() => {
2212
+ const [visible, setVisible] = React20.useState(delay === 0 && loading);
2213
+ React20.useEffect(() => {
2101
2214
  if (!loading) {
2102
2215
  setVisible(false);
2103
2216
  return;
@@ -2137,9 +2250,9 @@ var LoadingPage = React19.forwardRef(
2137
2250
  LoadingPage.displayName = "LoadingPage";
2138
2251
 
2139
2252
  // src/components/LoadingSection.tsx
2140
- var React20 = __toESM(require("react"));
2253
+ var React21 = __toESM(require("react"));
2141
2254
  var import_jsx_runtime19 = require("react/jsx-runtime");
2142
- var LoadingSection = React20.forwardRef(
2255
+ var LoadingSection = React21.forwardRef(
2143
2256
  ({
2144
2257
  loading = false,
2145
2258
  variant = "spinner",
@@ -2181,9 +2294,9 @@ var LoadingSection = React20.forwardRef(
2181
2294
  LoadingSection.displayName = "LoadingSection";
2182
2295
 
2183
2296
  // src/components/LiveRegion.tsx
2184
- var React21 = __toESM(require("react"));
2297
+ var React22 = __toESM(require("react"));
2185
2298
  var import_jsx_runtime20 = require("react/jsx-runtime");
2186
- var LiveRegion = React21.forwardRef(
2299
+ var LiveRegion = React22.forwardRef(
2187
2300
  ({ message, politeness = "polite", atomic = true, visuallyHidden = true, className, children }, ref) => {
2188
2301
  return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2189
2302
  "div",
@@ -2204,9 +2317,9 @@ var LiveRegion = React21.forwardRef(
2204
2317
  LiveRegion.displayName = "LiveRegion";
2205
2318
 
2206
2319
  // src/components/SkipLink.tsx
2207
- var React22 = __toESM(require("react"));
2320
+ var React23 = __toESM(require("react"));
2208
2321
  var import_jsx_runtime21 = require("react/jsx-runtime");
2209
- var SkipLink = React22.forwardRef(
2322
+ var SkipLink = React23.forwardRef(
2210
2323
  ({ targetId, className, children = "Skip to main content", ...props }, ref) => {
2211
2324
  const handleClick = (e) => {
2212
2325
  e.preventDefault();
@@ -2239,84 +2352,6 @@ var SkipLink = React22.forwardRef(
2239
2352
  );
2240
2353
  SkipLink.displayName = "SkipLink";
2241
2354
 
2242
- // src/hooks/useFocusTrap.ts
2243
- var import_react = require("react");
2244
- var FOCUSABLE_SELECTOR = [
2245
- "a[href]",
2246
- "area[href]",
2247
- 'input:not([disabled]):not([type="hidden"])',
2248
- "select:not([disabled])",
2249
- "textarea:not([disabled])",
2250
- "button:not([disabled])",
2251
- "iframe",
2252
- "object",
2253
- "embed",
2254
- "[contenteditable]",
2255
- '[tabindex]:not([tabindex="-1"])'
2256
- ].join(",");
2257
- function getFocusableElements(container) {
2258
- const elements = container.querySelectorAll(FOCUSABLE_SELECTOR);
2259
- return Array.from(elements).filter(
2260
- (el) => el.offsetParent !== null && getComputedStyle(el).visibility !== "hidden"
2261
- );
2262
- }
2263
- function useFocusTrap(options = {}) {
2264
- const { active = true, returnFocusTo, initialFocus, preventScroll = false } = options;
2265
- const containerRef = (0, import_react.useRef)(null);
2266
- const previousActiveElementRef = (0, import_react.useRef)(null);
2267
- const handleKeyDown = (0, import_react.useCallback)(
2268
- (event) => {
2269
- if (!active || event.key !== "Tab") return;
2270
- const container = containerRef.current;
2271
- if (!container) return;
2272
- const focusableElements = getFocusableElements(container);
2273
- if (focusableElements.length === 0) return;
2274
- const firstElement = focusableElements[0];
2275
- const lastElement = focusableElements[focusableElements.length - 1];
2276
- if (event.shiftKey) {
2277
- if (document.activeElement === firstElement) {
2278
- event.preventDefault();
2279
- lastElement.focus({ preventScroll });
2280
- }
2281
- } else {
2282
- if (document.activeElement === lastElement) {
2283
- event.preventDefault();
2284
- firstElement.focus({ preventScroll });
2285
- }
2286
- }
2287
- },
2288
- [active, preventScroll]
2289
- );
2290
- (0, import_react.useEffect)(() => {
2291
- if (!active) return;
2292
- const container = containerRef.current;
2293
- if (!container) return;
2294
- previousActiveElementRef.current = document.activeElement;
2295
- const focusableElements = getFocusableElements(container);
2296
- if (focusableElements.length > 0) {
2297
- let elementToFocus = null;
2298
- if (initialFocus) {
2299
- elementToFocus = container.querySelector(initialFocus);
2300
- }
2301
- if (!elementToFocus) {
2302
- elementToFocus = focusableElements[0];
2303
- }
2304
- requestAnimationFrame(() => {
2305
- elementToFocus?.focus({ preventScroll });
2306
- });
2307
- }
2308
- document.addEventListener("keydown", handleKeyDown);
2309
- return () => {
2310
- document.removeEventListener("keydown", handleKeyDown);
2311
- const elementToReturn = returnFocusTo ?? previousActiveElementRef.current;
2312
- if (elementToReturn && typeof elementToReturn.focus === "function") {
2313
- elementToReturn.focus({ preventScroll });
2314
- }
2315
- };
2316
- }, [active, initialFocus, returnFocusTo, handleKeyDown, preventScroll]);
2317
- return containerRef;
2318
- }
2319
-
2320
2355
  // src/hooks/useFocusRef.ts
2321
2356
  var import_react2 = require("react");
2322
2357
  function useFocusRef(options = {}) {
@@ -2370,6 +2405,11 @@ function useArrowNavigation(options = {}) {
2370
2405
  } = options;
2371
2406
  const containerRef = (0, import_react4.useRef)(null);
2372
2407
  const focusedIndexRef = (0, import_react4.useRef)(-1);
2408
+ const [focusedIndex, setFocusedIndexState] = (0, import_react4.useState)(-1);
2409
+ const setFocusedIndex = (0, import_react4.useCallback)((index) => {
2410
+ focusedIndexRef.current = index;
2411
+ setFocusedIndexState(index);
2412
+ }, []);
2373
2413
  const getFocusableItems = (0, import_react4.useCallback)(() => {
2374
2414
  if (!containerRef.current) return [];
2375
2415
  return Array.from(containerRef.current.querySelectorAll(itemSelector));
@@ -2388,11 +2428,11 @@ function useArrowNavigation(options = {}) {
2388
2428
  const element = items[targetIndex];
2389
2429
  if (element) {
2390
2430
  element.focus();
2391
- focusedIndexRef.current = targetIndex;
2431
+ setFocusedIndex(targetIndex);
2392
2432
  onFocusChange?.(targetIndex, element);
2393
2433
  }
2394
2434
  },
2395
- [getFocusableItems, loop, onFocusChange]
2435
+ [getFocusableItems, loop, onFocusChange, setFocusedIndex]
2396
2436
  );
2397
2437
  const handleKeyDown = (0, import_react4.useCallback)(
2398
2438
  (event) => {
@@ -2446,10 +2486,10 @@ function useArrowNavigation(options = {}) {
2446
2486
  const items = getFocusableItems();
2447
2487
  const index = items.indexOf(event.target);
2448
2488
  if (index !== -1) {
2449
- focusedIndexRef.current = index;
2489
+ setFocusedIndex(index);
2450
2490
  }
2451
2491
  },
2452
- [getFocusableItems]
2492
+ [getFocusableItems, setFocusedIndex]
2453
2493
  );
2454
2494
  const containerProps = {
2455
2495
  ref: (node) => {
@@ -2458,14 +2498,15 @@ function useArrowNavigation(options = {}) {
2458
2498
  onKeyDown: handleKeyDown,
2459
2499
  onFocus: handleFocus
2460
2500
  };
2501
+ const tabStopIndex = focusedIndex === -1 ? 0 : focusedIndex;
2461
2502
  const getItemProps = (0, import_react4.useCallback)(
2462
2503
  (index) => ({
2463
- tabIndex: index === 0 ? 0 : -1,
2504
+ tabIndex: index === tabStopIndex ? 0 : -1,
2464
2505
  onFocus: () => {
2465
- focusedIndexRef.current = index;
2506
+ setFocusedIndex(index);
2466
2507
  }
2467
2508
  }),
2468
- []
2509
+ [tabStopIndex, setFocusedIndex]
2469
2510
  );
2470
2511
  return {
2471
2512
  containerProps,
@@ -2583,34 +2624,6 @@ function useRovingTabindex(options = {}) {
2583
2624
  };
2584
2625
  }
2585
2626
 
2586
- // src/hooks/useEscapeKey.ts
2587
- var React23 = __toESM(require("react"));
2588
- function useEscapeKey(callback, options) {
2589
- const { enabled = true, preventDefault = true, stopPropagation = false } = options ?? {};
2590
- const callbackRef = React23.useRef(callback);
2591
- React23.useEffect(() => {
2592
- callbackRef.current = callback;
2593
- }, [callback]);
2594
- React23.useEffect(() => {
2595
- if (!enabled) return;
2596
- const handleKeyDown = (event) => {
2597
- if (event.key === "Escape") {
2598
- if (preventDefault) {
2599
- event.preventDefault();
2600
- }
2601
- if (stopPropagation) {
2602
- event.stopPropagation();
2603
- }
2604
- callbackRef.current(event);
2605
- }
2606
- };
2607
- document.addEventListener("keydown", handleKeyDown);
2608
- return () => {
2609
- document.removeEventListener("keydown", handleKeyDown);
2610
- };
2611
- }, [enabled, preventDefault, stopPropagation]);
2612
- }
2613
-
2614
2627
  // src/hooks/useClickOutside.ts
2615
2628
  var React24 = __toESM(require("react"));
2616
2629
  function useClickOutside(ref, callback, options) {
@@ -2620,9 +2633,12 @@ function useClickOutside(ref, callback, options) {
2620
2633
  ignoreElements = []
2621
2634
  } = options ?? {};
2622
2635
  const callbackRef = React24.useRef(callback);
2636
+ const ignoreElementsRef = React24.useRef(ignoreElements);
2623
2637
  React24.useEffect(() => {
2624
2638
  callbackRef.current = callback;
2625
- }, [callback]);
2639
+ ignoreElementsRef.current = ignoreElements;
2640
+ }, [callback, ignoreElements]);
2641
+ const eventsKey = events.join(",");
2626
2642
  React24.useEffect(() => {
2627
2643
  if (!enabled) return;
2628
2644
  const handleEvent = (event) => {
@@ -2630,22 +2646,23 @@ function useClickOutside(ref, callback, options) {
2630
2646
  if (ref.current?.contains(target)) {
2631
2647
  return;
2632
2648
  }
2633
- for (const ignoreRef of ignoreElements) {
2649
+ for (const ignoreRef of ignoreElementsRef.current) {
2634
2650
  if (ignoreRef.current?.contains(target)) {
2635
2651
  return;
2636
2652
  }
2637
2653
  }
2638
2654
  callbackRef.current(event);
2639
2655
  };
2640
- events.forEach((eventType) => {
2656
+ const eventTypes = eventsKey.split(",");
2657
+ eventTypes.forEach((eventType) => {
2641
2658
  document.addEventListener(eventType, handleEvent);
2642
2659
  });
2643
2660
  return () => {
2644
- events.forEach((eventType) => {
2661
+ eventTypes.forEach((eventType) => {
2645
2662
  document.removeEventListener(eventType, handleEvent);
2646
2663
  });
2647
2664
  };
2648
- }, [enabled, events, ignoreElements, ref]);
2665
+ }, [enabled, eventsKey, ref]);
2649
2666
  }
2650
2667
  // Annotate the CommonJS export names for ESM import in node:
2651
2668
  0 && (module.exports = {