react-resizable-panels 2.1.7 → 2.1.9

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 (27) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +4 -0
  3. package/dist/declarations/src/Panel.d.ts +1 -1
  4. package/dist/declarations/src/PanelGroup.d.ts +1 -1
  5. package/dist/declarations/src/PanelResizeHandle.d.ts +6 -3
  6. package/dist/declarations/src/constants.d.ts +15 -0
  7. package/dist/declarations/src/index.d.ts +3 -2
  8. package/dist/react-resizable-panels.browser.cjs.js +202 -176
  9. package/dist/react-resizable-panels.browser.cjs.mjs +1 -0
  10. package/dist/react-resizable-panels.browser.development.cjs.js +202 -176
  11. package/dist/react-resizable-panels.browser.development.cjs.mjs +1 -0
  12. package/dist/react-resizable-panels.browser.development.esm.js +150 -124
  13. package/dist/react-resizable-panels.browser.esm.js +150 -124
  14. package/dist/react-resizable-panels.cjs.js +202 -176
  15. package/dist/react-resizable-panels.cjs.mjs +1 -0
  16. package/dist/react-resizable-panels.development.cjs.js +202 -176
  17. package/dist/react-resizable-panels.development.cjs.mjs +1 -0
  18. package/dist/react-resizable-panels.development.esm.js +150 -124
  19. package/dist/react-resizable-panels.development.node.cjs.js +201 -174
  20. package/dist/react-resizable-panels.development.node.cjs.mjs +1 -0
  21. package/dist/react-resizable-panels.development.node.esm.js +149 -122
  22. package/dist/react-resizable-panels.esm.js +150 -124
  23. package/dist/react-resizable-panels.node.cjs.js +201 -174
  24. package/dist/react-resizable-panels.node.cjs.mjs +1 -0
  25. package/dist/react-resizable-panels.node.esm.js +149 -122
  26. package/package.json +12 -13
  27. package/dist/declarations/src/vendor/react.d.ts +0 -7
@@ -26,41 +26,35 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
26
26
 
27
27
  const isBrowser = typeof window !== "undefined";
28
28
 
29
- // This module exists to work around Webpack issue https://github.com/webpack/webpack/issues/14814
30
-
31
- // eslint-disable-next-line no-restricted-imports
32
-
33
- const {
34
- createElement,
35
- createContext,
36
- createRef,
37
- forwardRef,
38
- useCallback,
39
- useContext,
40
- useEffect,
41
- useImperativeHandle,
42
- useLayoutEffect,
43
- useMemo,
44
- useRef,
45
- useState
46
- } = React__namespace;
47
-
48
- // `Math.random()` and `.slice(0, 5)` prevents bundlers from trying to `import { useId } from 'react'`
49
- const useId = React__namespace[`useId${Math.random()}`.slice(0, 5)];
50
- const useLayoutEffect_do_not_use_directly = useLayoutEffect;
51
-
52
29
  // The "contextmenu" event is not supported as a PointerEvent in all browsers yet, so MouseEvent still need to be handled
53
30
 
54
- const PanelGroupContext = createContext(null);
31
+ const PanelGroupContext = React.createContext(null);
55
32
  PanelGroupContext.displayName = "PanelGroupContext";
56
33
 
57
- const useIsomorphicLayoutEffect = isBrowser ? useLayoutEffect_do_not_use_directly : () => {};
34
+ const DATA_ATTRIBUTES = {
35
+ group: "data-panel-group",
36
+ groupDirection: "data-panel-group-direction",
37
+ groupId: "data-panel-group-id",
38
+ panel: "data-panel",
39
+ panelCollapsible: "data-panel-collapsible",
40
+ panelId: "data-panel-id",
41
+ panelSize: "data-panel-size",
42
+ resizeHandle: "data-resize-handle",
43
+ resizeHandleActive: "data-resize-handle-active",
44
+ resizeHandleEnabled: "data-panel-resize-handle-enabled",
45
+ resizeHandleId: "data-panel-resize-handle-id",
46
+ resizeHandleState: "data-resize-handle-state"
47
+ };
48
+ const PRECISION = 10;
49
+
50
+ const useIsomorphicLayoutEffect = isBrowser ? React.useLayoutEffect : () => {};
58
51
 
52
+ const useId = React__namespace["useId".toString()];
59
53
  const wrappedUseId = typeof useId === "function" ? useId : () => null;
60
54
  let counter = 0;
61
55
  function useUniqueId(idFromParams = null) {
62
56
  const idFromUseId = wrappedUseId();
63
- const idRef = useRef(idFromParams || idFromUseId || null);
57
+ const idRef = React.useRef(idFromParams || idFromUseId || null);
64
58
  if (idRef.current === null) {
65
59
  idRef.current = "" + counter++;
66
60
  }
@@ -85,7 +79,7 @@ function PanelWithForwardedRef({
85
79
  tagName: Type = "div",
86
80
  ...rest
87
81
  }) {
88
- const context = useContext(PanelGroupContext);
82
+ const context = React.useContext(PanelGroupContext);
89
83
  if (context === null) {
90
84
  throw Error(`Panel components must be rendered within a PanelGroup container`);
91
85
  }
@@ -102,7 +96,7 @@ function PanelWithForwardedRef({
102
96
  unregisterPanel
103
97
  } = context;
104
98
  const panelId = useUniqueId(idFromProps);
105
- const panelDataRef = useRef({
99
+ const panelDataRef = React.useRef({
106
100
  callbacks: {
107
101
  onCollapse,
108
102
  onExpand,
@@ -119,7 +113,7 @@ function PanelWithForwardedRef({
119
113
  idIsFromProps: idFromProps !== undefined,
120
114
  order
121
115
  });
122
- useRef({
116
+ React.useRef({
123
117
  didLogMissingDefaultSizeWarning: false
124
118
  });
125
119
  useIsomorphicLayoutEffect(() => {
@@ -155,7 +149,7 @@ function PanelWithForwardedRef({
155
149
  unregisterPanel(panelData);
156
150
  };
157
151
  }, [order, panelId, registerPanel, unregisterPanel]);
158
- useImperativeHandle(forwardedRef, () => ({
152
+ React.useImperativeHandle(forwardedRef, () => ({
159
153
  collapse: () => {
160
154
  collapsePanel(panelDataRef.current);
161
155
  },
@@ -179,24 +173,24 @@ function PanelWithForwardedRef({
179
173
  }
180
174
  }), [collapsePanel, expandPanel, getPanelSize, isPanelCollapsed, panelId, resizePanel]);
181
175
  const style = getPanelStyle(panelDataRef.current, defaultSize);
182
- return createElement(Type, {
176
+ return React.createElement(Type, {
183
177
  ...rest,
184
178
  children,
185
179
  className: classNameFromProps,
186
- id: idFromProps,
180
+ id: panelId,
187
181
  style: {
188
182
  ...style,
189
183
  ...styleFromProps
190
184
  },
191
185
  // CSS selectors
192
- "data-panel": "",
193
- "data-panel-collapsible": collapsible || undefined,
194
- "data-panel-group-id": groupId,
195
- "data-panel-id": panelId,
196
- "data-panel-size": parseFloat("" + style.flexGrow).toFixed(1)
186
+ [DATA_ATTRIBUTES.groupId]: groupId,
187
+ [DATA_ATTRIBUTES.panel]: "",
188
+ [DATA_ATTRIBUTES.panelCollapsible]: collapsible || undefined,
189
+ [DATA_ATTRIBUTES.panelId]: panelId,
190
+ [DATA_ATTRIBUTES.panelSize]: parseFloat("" + style.flexGrow).toFixed(1)
197
191
  });
198
192
  }
199
- const Panel = forwardRef((props, ref) => createElement(PanelWithForwardedRef, {
193
+ const Panel = React.forwardRef((props, ref) => React.createElement(PanelWithForwardedRef, {
200
194
  ...props,
201
195
  forwardedRef: ref
202
196
  }));
@@ -213,6 +207,7 @@ function setNonce(value) {
213
207
 
214
208
  let currentCursorStyle = null;
215
209
  let enabled = true;
210
+ let prevRuleIndex = -1;
216
211
  let styleElement = null;
217
212
  function disableGlobalCursorStyles() {
218
213
  enabled = false;
@@ -262,9 +257,11 @@ function resetGlobalCursorStyle() {
262
257
  document.head.removeChild(styleElement);
263
258
  currentCursorStyle = null;
264
259
  styleElement = null;
260
+ prevRuleIndex = -1;
265
261
  }
266
262
  }
267
263
  function setGlobalCursorStyle(state, constraintFlags) {
264
+ var _styleElement$sheet$i, _styleElement$sheet2;
268
265
  if (!enabled) {
269
266
  return;
270
267
  }
@@ -281,7 +278,11 @@ function setGlobalCursorStyle(state, constraintFlags) {
281
278
  }
282
279
  document.head.appendChild(styleElement);
283
280
  }
284
- styleElement.innerHTML = `*{cursor: ${style}!important;}`;
281
+ if (prevRuleIndex >= 0) {
282
+ var _styleElement$sheet;
283
+ (_styleElement$sheet = styleElement.sheet) === null || _styleElement$sheet === void 0 ? void 0 : _styleElement$sheet.removeRule(prevRuleIndex);
284
+ }
285
+ prevRuleIndex = (_styleElement$sheet$i = (_styleElement$sheet2 = styleElement.sheet) === null || _styleElement$sheet2 === void 0 ? void 0 : _styleElement$sheet2.insertRule(`*{cursor: ${style} !important;}`)) !== null && _styleElement$sheet$i !== void 0 ? _styleElement$sheet$i : -1;
285
286
  }
286
287
 
287
288
  function isKeyDown(event) {
@@ -512,7 +513,9 @@ function handlePointerDown(event) {
512
513
  if (intersectingHandles.length > 0) {
513
514
  updateResizeHandlerStates("down", event);
514
515
  event.preventDefault();
515
- event.stopPropagation();
516
+ if (!isWithinResizeHandle(target)) {
517
+ event.stopImmediatePropagation();
518
+ }
516
519
  }
517
520
  }
518
521
  function handlePointerMove(event) {
@@ -561,6 +564,9 @@ function handlePointerUp(event) {
561
564
  isPointerDown = false;
562
565
  if (intersectingHandles.length > 0) {
563
566
  event.preventDefault();
567
+ if (!isWithinResizeHandle(target)) {
568
+ event.stopImmediatePropagation();
569
+ }
564
570
  }
565
571
  updateResizeHandlerStates("up", event);
566
572
  recalculateIntersectingHandles({
@@ -571,6 +577,16 @@ function handlePointerUp(event) {
571
577
  updateCursor();
572
578
  updateListeners();
573
579
  }
580
+ function isWithinResizeHandle(element) {
581
+ let currentElement = element;
582
+ while (currentElement) {
583
+ if (currentElement.hasAttribute(DATA_ATTRIBUTES.resizeHandle)) {
584
+ return true;
585
+ }
586
+ currentElement = currentElement.parentElement;
587
+ }
588
+ return false;
589
+ }
574
590
  function recalculateIntersectingHandles({
575
591
  target,
576
592
  x,
@@ -662,47 +678,42 @@ function updateCursor() {
662
678
  resetGlobalCursorStyle();
663
679
  }
664
680
  }
681
+ let listenersAbortController = new AbortController();
665
682
  function updateListeners() {
666
- ownerDocumentCounts.forEach((_, ownerDocument) => {
667
- const {
668
- body
669
- } = ownerDocument;
670
- body.removeEventListener("contextmenu", handlePointerUp);
671
- body.removeEventListener("pointerdown", handlePointerDown);
672
- body.removeEventListener("pointerleave", handlePointerMove);
673
- body.removeEventListener("pointermove", handlePointerMove);
674
- });
675
- window.removeEventListener("pointerup", handlePointerUp);
676
- window.removeEventListener("pointercancel", handlePointerUp);
677
- if (registeredResizeHandlers.size > 0) {
678
- if (isPointerDown) {
679
- if (intersectingHandles.length > 0) {
680
- ownerDocumentCounts.forEach((count, ownerDocument) => {
681
- const {
682
- body
683
- } = ownerDocument;
684
- if (count > 0) {
685
- body.addEventListener("contextmenu", handlePointerUp);
686
- body.addEventListener("pointerleave", handlePointerMove);
687
- body.addEventListener("pointermove", handlePointerMove);
688
- }
689
- });
690
- }
691
- window.addEventListener("pointerup", handlePointerUp);
692
- window.addEventListener("pointercancel", handlePointerUp);
693
- } else {
683
+ listenersAbortController.abort();
684
+ listenersAbortController = new AbortController();
685
+ const options = {
686
+ capture: true,
687
+ signal: listenersAbortController.signal
688
+ };
689
+ if (!registeredResizeHandlers.size) {
690
+ return;
691
+ }
692
+ if (isPointerDown) {
693
+ if (intersectingHandles.length > 0) {
694
694
  ownerDocumentCounts.forEach((count, ownerDocument) => {
695
695
  const {
696
696
  body
697
697
  } = ownerDocument;
698
698
  if (count > 0) {
699
- body.addEventListener("pointerdown", handlePointerDown, {
700
- capture: true
701
- });
702
- body.addEventListener("pointermove", handlePointerMove);
699
+ body.addEventListener("contextmenu", handlePointerUp, options);
700
+ body.addEventListener("pointerleave", handlePointerMove, options);
701
+ body.addEventListener("pointermove", handlePointerMove, options);
703
702
  }
704
703
  });
705
704
  }
705
+ window.addEventListener("pointerup", handlePointerUp, options);
706
+ window.addEventListener("pointercancel", handlePointerUp, options);
707
+ } else {
708
+ ownerDocumentCounts.forEach((count, ownerDocument) => {
709
+ const {
710
+ body
711
+ } = ownerDocument;
712
+ if (count > 0) {
713
+ body.addEventListener("pointerdown", handlePointerDown, options);
714
+ body.addEventListener("pointermove", handlePointerMove, options);
715
+ }
716
+ });
706
717
  }
707
718
  }
708
719
  function updateResizeHandlerStates(action, event) {
@@ -716,8 +727,8 @@ function updateResizeHandlerStates(action, event) {
716
727
  }
717
728
 
718
729
  function useForceUpdate() {
719
- const [_, setCount] = useState(0);
720
- return useCallback(() => setCount(prevCount => prevCount + 1), []);
730
+ const [_, setCount] = React.useState(0);
731
+ return React.useCallback(() => setCount(prevCount => prevCount + 1), []);
721
732
  }
722
733
 
723
734
  function assert(expectedCondition, message) {
@@ -727,8 +738,6 @@ function assert(expectedCondition, message) {
727
738
  }
728
739
  }
729
740
 
730
- const PRECISION = 10;
731
-
732
741
  function fuzzyCompareNumbers(actual, expected, fractionDigits = PRECISION) {
733
742
  if (actual.toFixed(fractionDigits) === expected.toFixed(fractionDigits)) {
734
743
  return 0;
@@ -1072,12 +1081,12 @@ function calculateAriaValues({
1072
1081
  }
1073
1082
 
1074
1083
  function getResizeHandleElementsForGroup(groupId, scope = document) {
1075
- return Array.from(scope.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${groupId}"]`));
1084
+ return Array.from(scope.querySelectorAll(`[${DATA_ATTRIBUTES.resizeHandleId}][data-panel-group-id="${groupId}"]`));
1076
1085
  }
1077
1086
 
1078
1087
  function getResizeHandleElementIndex(groupId, id, scope = document) {
1079
1088
  const handles = getResizeHandleElementsForGroup(groupId, scope);
1080
- const index = handles.findIndex(handle => handle.getAttribute("data-panel-resize-handle-id") === id);
1089
+ const index = handles.findIndex(handle => handle.getAttribute(DATA_ATTRIBUTES.resizeHandleId) === id);
1081
1090
  return index !== null && index !== void 0 ? index : null;
1082
1091
  }
1083
1092
 
@@ -1102,7 +1111,7 @@ function getPanelGroupElement(id, rootElement = document) {
1102
1111
  }
1103
1112
 
1104
1113
  function getResizeHandleElement(id, scope = document) {
1105
- const element = scope.querySelector(`[data-panel-resize-handle-id="${id}"]`);
1114
+ const element = scope.querySelector(`[${DATA_ATTRIBUTES.resizeHandleId}="${id}"]`);
1106
1115
  if (element) {
1107
1116
  return element;
1108
1117
  }
@@ -1130,7 +1139,7 @@ function useWindowSplitterPanelGroupBehavior({
1130
1139
  panelGroupElement,
1131
1140
  setLayout
1132
1141
  }) {
1133
- useRef({
1142
+ React.useRef({
1134
1143
  didWarnAboutMissingResizeHandle: false
1135
1144
  });
1136
1145
  useIsomorphicLayoutEffect(() => {
@@ -1167,7 +1176,7 @@ function useWindowSplitterPanelGroupBehavior({
1167
1176
  });
1168
1177
  };
1169
1178
  }, [groupId, layout, panelDataArray, panelGroupElement]);
1170
- useEffect(() => {
1179
+ React.useEffect(() => {
1171
1180
  if (!panelGroupElement) {
1172
1181
  return;
1173
1182
  }
@@ -1181,7 +1190,7 @@ function useWindowSplitterPanelGroupBehavior({
1181
1190
  const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
1182
1191
  assert(handles, `No resize handles found for group id "${groupId}"`);
1183
1192
  const cleanupFunctions = handles.map(handle => {
1184
- const handleId = handle.getAttribute("data-panel-resize-handle-id");
1193
+ const handleId = handle.getAttribute(DATA_ATTRIBUTES.resizeHandleId);
1185
1194
  assert(handleId, `Resize handle element has no handle id attribute`);
1186
1195
  const [idBefore, idAfter] = getResizeHandlePanelIds(groupId, handleId, panelDataArray, panelGroupElement);
1187
1196
  if (idBefore == null || idAfter == null) {
@@ -1259,7 +1268,7 @@ function calculateDragOffsetPercentage(event, dragHandleId, direction, initialDr
1259
1268
  const isHorizontal = direction === "horizontal";
1260
1269
  const handleElement = getResizeHandleElement(dragHandleId, panelGroupElement);
1261
1270
  assert(handleElement, `No resize handle element found for id "${dragHandleId}"`);
1262
- const groupId = handleElement.getAttribute("data-panel-group-id");
1271
+ const groupId = handleElement.getAttribute(DATA_ATTRIBUTES.groupId);
1263
1272
  assert(groupId, `Resize handle element has no group id attribute`);
1264
1273
  let {
1265
1274
  initialCursorPosition
@@ -1626,14 +1635,14 @@ function PanelGroupWithForwardedRef({
1626
1635
  ...rest
1627
1636
  }) {
1628
1637
  const groupId = useUniqueId(idFromProps);
1629
- const panelGroupElementRef = useRef(null);
1630
- const [dragState, setDragState] = useState(null);
1631
- const [layout, setLayout] = useState([]);
1638
+ const panelGroupElementRef = React.useRef(null);
1639
+ const [dragState, setDragState] = React.useState(null);
1640
+ const [layout, setLayout] = React.useState([]);
1632
1641
  const forceUpdate = useForceUpdate();
1633
- const panelIdToLastNotifiedSizeMapRef = useRef({});
1634
- const panelSizeBeforeCollapseRef = useRef(new Map());
1635
- const prevDeltaRef = useRef(0);
1636
- const committedValuesRef = useRef({
1642
+ const panelIdToLastNotifiedSizeMapRef = React.useRef({});
1643
+ const panelSizeBeforeCollapseRef = React.useRef(new Map());
1644
+ const prevDeltaRef = React.useRef(0);
1645
+ const committedValuesRef = React.useRef({
1637
1646
  autoSaveId,
1638
1647
  direction,
1639
1648
  dragState,
@@ -1642,17 +1651,17 @@ function PanelGroupWithForwardedRef({
1642
1651
  onLayout,
1643
1652
  storage
1644
1653
  });
1645
- const eagerValuesRef = useRef({
1654
+ const eagerValuesRef = React.useRef({
1646
1655
  layout,
1647
1656
  panelDataArray: [],
1648
1657
  panelDataArrayChanged: false
1649
1658
  });
1650
- useRef({
1659
+ React.useRef({
1651
1660
  didLogIdAndOrderWarning: false,
1652
1661
  didLogPanelConstraintsWarning: false,
1653
1662
  prevPanelIds: []
1654
1663
  });
1655
- useImperativeHandle(forwardedRef, () => ({
1664
+ React.useImperativeHandle(forwardedRef, () => ({
1656
1665
  getId: () => committedValuesRef.current.id,
1657
1666
  getLayout: () => {
1658
1667
  const {
@@ -1699,7 +1708,7 @@ function PanelGroupWithForwardedRef({
1699
1708
  setLayout,
1700
1709
  panelGroupElement: panelGroupElementRef.current
1701
1710
  });
1702
- useEffect(() => {
1711
+ React.useEffect(() => {
1703
1712
  const {
1704
1713
  panelDataArray
1705
1714
  } = eagerValuesRef.current;
@@ -1726,11 +1735,11 @@ function PanelGroupWithForwardedRef({
1726
1735
  }, [autoSaveId, layout, storage]);
1727
1736
 
1728
1737
  // DEV warnings
1729
- useEffect(() => {
1738
+ React.useEffect(() => {
1730
1739
  });
1731
1740
 
1732
1741
  // External APIs are safe to memoize via committed values ref
1733
- const collapsePanel = useCallback(panelData => {
1742
+ const collapsePanel = React.useCallback(panelData => {
1734
1743
  const {
1735
1744
  onLayout
1736
1745
  } = committedValuesRef.current;
@@ -1773,7 +1782,7 @@ function PanelGroupWithForwardedRef({
1773
1782
  }, []);
1774
1783
 
1775
1784
  // External APIs are safe to memoize via committed values ref
1776
- const expandPanel = useCallback((panelData, minSizeOverride) => {
1785
+ const expandPanel = React.useCallback((panelData, minSizeOverride) => {
1777
1786
  const {
1778
1787
  onLayout
1779
1788
  } = committedValuesRef.current;
@@ -1817,7 +1826,7 @@ function PanelGroupWithForwardedRef({
1817
1826
  }, []);
1818
1827
 
1819
1828
  // External APIs are safe to memoize via committed values ref
1820
- const getPanelSize = useCallback(panelData => {
1829
+ const getPanelSize = React.useCallback(panelData => {
1821
1830
  const {
1822
1831
  layout,
1823
1832
  panelDataArray
@@ -1830,7 +1839,7 @@ function PanelGroupWithForwardedRef({
1830
1839
  }, []);
1831
1840
 
1832
1841
  // This API should never read from committedValuesRef
1833
- const getPanelStyle = useCallback((panelData, defaultSize) => {
1842
+ const getPanelStyle = React.useCallback((panelData, defaultSize) => {
1834
1843
  const {
1835
1844
  panelDataArray
1836
1845
  } = eagerValuesRef.current;
@@ -1845,7 +1854,7 @@ function PanelGroupWithForwardedRef({
1845
1854
  }, [dragState, layout]);
1846
1855
 
1847
1856
  // External APIs are safe to memoize via committed values ref
1848
- const isPanelCollapsed = useCallback(panelData => {
1857
+ const isPanelCollapsed = React.useCallback(panelData => {
1849
1858
  const {
1850
1859
  layout,
1851
1860
  panelDataArray
@@ -1860,7 +1869,7 @@ function PanelGroupWithForwardedRef({
1860
1869
  }, []);
1861
1870
 
1862
1871
  // External APIs are safe to memoize via committed values ref
1863
- const isPanelExpanded = useCallback(panelData => {
1872
+ const isPanelExpanded = React.useCallback(panelData => {
1864
1873
  const {
1865
1874
  layout,
1866
1875
  panelDataArray
@@ -1873,7 +1882,7 @@ function PanelGroupWithForwardedRef({
1873
1882
  assert(panelSize != null, `Panel size not found for panel "${panelData.id}"`);
1874
1883
  return !collapsible || fuzzyCompareNumbers(panelSize, collapsedSize) > 0;
1875
1884
  }, []);
1876
- const registerPanel = useCallback(panelData => {
1885
+ const registerPanel = React.useCallback(panelData => {
1877
1886
  const {
1878
1887
  panelDataArray
1879
1888
  } = eagerValuesRef.current;
@@ -1950,7 +1959,7 @@ function PanelGroupWithForwardedRef({
1950
1959
  eagerValues.layout = [];
1951
1960
  };
1952
1961
  }, []);
1953
- const registerResizeHandle = useCallback(dragHandleId => {
1962
+ const registerResizeHandle = React.useCallback(dragHandleId => {
1954
1963
  let isRTL = false;
1955
1964
  const panelGroupElement = panelGroupElementRef.current;
1956
1965
  if (panelGroupElement) {
@@ -2029,7 +2038,7 @@ function PanelGroupWithForwardedRef({
2029
2038
  }, []);
2030
2039
 
2031
2040
  // External APIs are safe to memoize via committed values ref
2032
- const resizePanel = useCallback((panelData, unsafePanelSize) => {
2041
+ const resizePanel = React.useCallback((panelData, unsafePanelSize) => {
2033
2042
  const {
2034
2043
  onLayout
2035
2044
  } = committedValuesRef.current;
@@ -2062,7 +2071,7 @@ function PanelGroupWithForwardedRef({
2062
2071
  callPanelCallbacks(panelDataArray, nextLayout, panelIdToLastNotifiedSizeMapRef.current);
2063
2072
  }
2064
2073
  }, []);
2065
- const reevaluatePanelConstraints = useCallback((panelData, prevConstraints) => {
2074
+ const reevaluatePanelConstraints = React.useCallback((panelData, prevConstraints) => {
2066
2075
  const {
2067
2076
  layout,
2068
2077
  panelDataArray
@@ -2096,7 +2105,7 @@ function PanelGroupWithForwardedRef({
2096
2105
  }, [resizePanel]);
2097
2106
 
2098
2107
  // TODO Multiple drag handles can be active at the same time so this API is a bit awkward now
2099
- const startDragging = useCallback((dragHandleId, event) => {
2108
+ const startDragging = React.useCallback((dragHandleId, event) => {
2100
2109
  const {
2101
2110
  direction
2102
2111
  } = committedValuesRef.current;
@@ -2116,10 +2125,10 @@ function PanelGroupWithForwardedRef({
2116
2125
  initialLayout: layout
2117
2126
  });
2118
2127
  }, []);
2119
- const stopDragging = useCallback(() => {
2128
+ const stopDragging = React.useCallback(() => {
2120
2129
  setDragState(null);
2121
2130
  }, []);
2122
- const unregisterPanel = useCallback(panelData => {
2131
+ const unregisterPanel = React.useCallback(panelData => {
2123
2132
  const {
2124
2133
  panelDataArray
2125
2134
  } = eagerValuesRef.current;
@@ -2136,7 +2145,7 @@ function PanelGroupWithForwardedRef({
2136
2145
  forceUpdate();
2137
2146
  }
2138
2147
  }, [forceUpdate]);
2139
- const context = useMemo(() => ({
2148
+ const context = React.useMemo(() => ({
2140
2149
  collapsePanel,
2141
2150
  direction,
2142
2151
  dragState,
@@ -2162,9 +2171,9 @@ function PanelGroupWithForwardedRef({
2162
2171
  overflow: "hidden",
2163
2172
  width: "100%"
2164
2173
  };
2165
- return createElement(PanelGroupContext.Provider, {
2174
+ return React.createElement(PanelGroupContext.Provider, {
2166
2175
  value: context
2167
- }, createElement(Type, {
2176
+ }, React.createElement(Type, {
2168
2177
  ...rest,
2169
2178
  children,
2170
2179
  className: classNameFromProps,
@@ -2175,12 +2184,12 @@ function PanelGroupWithForwardedRef({
2175
2184
  ...styleFromProps
2176
2185
  },
2177
2186
  // CSS selectors
2178
- "data-panel-group": "",
2179
- "data-panel-group-direction": direction,
2180
- "data-panel-group-id": groupId
2187
+ [DATA_ATTRIBUTES.group]: "",
2188
+ [DATA_ATTRIBUTES.groupDirection]: direction,
2189
+ [DATA_ATTRIBUTES.groupId]: groupId
2181
2190
  }));
2182
2191
  }
2183
- const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwardedRef, {
2192
+ const PanelGroup = React.forwardRef((props, ref) => React.createElement(PanelGroupWithForwardedRef, {
2184
2193
  ...props,
2185
2194
  forwardedRef: ref
2186
2195
  }));
@@ -2209,7 +2218,7 @@ function useWindowSplitterResizeHandlerBehavior({
2209
2218
  resizeHandler,
2210
2219
  panelGroupElement
2211
2220
  }) {
2212
- useEffect(() => {
2221
+ React.useEffect(() => {
2213
2222
  if (disabled || resizeHandler == null || panelGroupElement == null) {
2214
2223
  return;
2215
2224
  }
@@ -2236,7 +2245,7 @@ function useWindowSplitterResizeHandlerBehavior({
2236
2245
  case "F6":
2237
2246
  {
2238
2247
  event.preventDefault();
2239
- const groupId = handleElement.getAttribute("data-panel-group-id");
2248
+ const groupId = handleElement.getAttribute(DATA_ATTRIBUTES.groupId);
2240
2249
  assert(groupId, `No group element found for id "${groupId}"`);
2241
2250
  const handles = getResizeHandleElementsForGroup(groupId, panelGroupElement);
2242
2251
  const index = getResizeHandleElementIndex(groupId, handleId, panelGroupElement);
@@ -2262,24 +2271,33 @@ function PanelResizeHandle({
2262
2271
  hitAreaMargins,
2263
2272
  id: idFromProps,
2264
2273
  onBlur,
2274
+ onClick,
2265
2275
  onDragging,
2266
2276
  onFocus,
2277
+ onPointerDown,
2278
+ onPointerUp,
2267
2279
  style: styleFromProps = {},
2268
2280
  tabIndex = 0,
2269
2281
  tagName: Type = "div",
2270
2282
  ...rest
2271
2283
  }) {
2272
2284
  var _hitAreaMargins$coars, _hitAreaMargins$fine;
2273
- const elementRef = useRef(null);
2285
+ const elementRef = React.useRef(null);
2274
2286
 
2275
2287
  // Use a ref to guard against users passing inline props
2276
- const callbacksRef = useRef({
2277
- onDragging
2288
+ const callbacksRef = React.useRef({
2289
+ onClick,
2290
+ onDragging,
2291
+ onPointerDown,
2292
+ onPointerUp
2278
2293
  });
2279
- useEffect(() => {
2294
+ React.useEffect(() => {
2295
+ callbacksRef.current.onClick = onClick;
2280
2296
  callbacksRef.current.onDragging = onDragging;
2297
+ callbacksRef.current.onPointerDown = onPointerDown;
2298
+ callbacksRef.current.onPointerUp = onPointerUp;
2281
2299
  });
2282
- const panelGroupContext = useContext(PanelGroupContext);
2300
+ const panelGroupContext = React.useContext(PanelGroupContext);
2283
2301
  if (panelGroupContext === null) {
2284
2302
  throw Error(`PanelResizeHandle components must be rendered within a PanelGroup container`);
2285
2303
  }
@@ -2292,16 +2310,16 @@ function PanelResizeHandle({
2292
2310
  panelGroupElement
2293
2311
  } = panelGroupContext;
2294
2312
  const resizeHandleId = useUniqueId(idFromProps);
2295
- const [state, setState] = useState("inactive");
2296
- const [isFocused, setIsFocused] = useState(false);
2297
- const [resizeHandler, setResizeHandler] = useState(null);
2298
- const committedValuesRef = useRef({
2313
+ const [state, setState] = React.useState("inactive");
2314
+ const [isFocused, setIsFocused] = React.useState(false);
2315
+ const [resizeHandler, setResizeHandler] = React.useState(null);
2316
+ const committedValuesRef = React.useRef({
2299
2317
  state
2300
2318
  });
2301
2319
  useIsomorphicLayoutEffect(() => {
2302
2320
  committedValuesRef.current.state = state;
2303
2321
  });
2304
- useEffect(() => {
2322
+ React.useEffect(() => {
2305
2323
  if (disabled) {
2306
2324
  setResizeHandler(null);
2307
2325
  } else {
@@ -2314,55 +2332,62 @@ function PanelResizeHandle({
2314
2332
  // so that inline object values won't trigger re-renders
2315
2333
  const coarseHitAreaMargins = (_hitAreaMargins$coars = hitAreaMargins === null || hitAreaMargins === void 0 ? void 0 : hitAreaMargins.coarse) !== null && _hitAreaMargins$coars !== void 0 ? _hitAreaMargins$coars : 15;
2316
2334
  const fineHitAreaMargins = (_hitAreaMargins$fine = hitAreaMargins === null || hitAreaMargins === void 0 ? void 0 : hitAreaMargins.fine) !== null && _hitAreaMargins$fine !== void 0 ? _hitAreaMargins$fine : 5;
2317
- useEffect(() => {
2335
+ React.useEffect(() => {
2318
2336
  if (disabled || resizeHandler == null) {
2319
2337
  return;
2320
2338
  }
2321
2339
  const element = elementRef.current;
2322
2340
  assert(element, "Element ref not attached");
2341
+ let didMove = false;
2323
2342
  const setResizeHandlerState = (action, isActive, event) => {
2324
- if (isActive) {
2325
- switch (action) {
2326
- case "down":
2327
- {
2328
- setState("drag");
2329
- assert(event, 'Expected event to be defined for "down" action');
2330
- startDragging(resizeHandleId, event);
2331
- const {
2332
- onDragging
2333
- } = callbacksRef.current;
2334
- if (onDragging) {
2335
- onDragging(true);
2336
- }
2337
- break;
2338
- }
2339
- case "move":
2340
- {
2341
- const {
2342
- state
2343
- } = committedValuesRef.current;
2344
- if (state !== "drag") {
2345
- setState("hover");
2346
- }
2347
- assert(event, 'Expected event to be defined for "move" action');
2348
- resizeHandler(event);
2349
- break;
2350
- }
2351
- case "up":
2352
- {
2343
+ if (!isActive) {
2344
+ setState("inactive");
2345
+ return;
2346
+ }
2347
+ switch (action) {
2348
+ case "down":
2349
+ {
2350
+ setState("drag");
2351
+ didMove = false;
2352
+ assert(event, 'Expected event to be defined for "down" action');
2353
+ startDragging(resizeHandleId, event);
2354
+ const {
2355
+ onDragging,
2356
+ onPointerDown
2357
+ } = callbacksRef.current;
2358
+ onDragging === null || onDragging === void 0 ? void 0 : onDragging(true);
2359
+ onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown();
2360
+ break;
2361
+ }
2362
+ case "move":
2363
+ {
2364
+ const {
2365
+ state
2366
+ } = committedValuesRef.current;
2367
+ didMove = true;
2368
+ if (state !== "drag") {
2353
2369
  setState("hover");
2354
- stopDragging();
2355
- const {
2356
- onDragging
2357
- } = callbacksRef.current;
2358
- if (onDragging) {
2359
- onDragging(false);
2360
- }
2361
- break;
2362
2370
  }
2363
- }
2364
- } else {
2365
- setState("inactive");
2371
+ assert(event, 'Expected event to be defined for "move" action');
2372
+ resizeHandler(event);
2373
+ break;
2374
+ }
2375
+ case "up":
2376
+ {
2377
+ setState("hover");
2378
+ stopDragging();
2379
+ const {
2380
+ onClick,
2381
+ onDragging,
2382
+ onPointerUp
2383
+ } = callbacksRef.current;
2384
+ onDragging === null || onDragging === void 0 ? void 0 : onDragging(false);
2385
+ onPointerUp === null || onPointerUp === void 0 ? void 0 : onPointerUp();
2386
+ if (!didMove) {
2387
+ onClick === null || onClick === void 0 ? void 0 : onClick();
2388
+ }
2389
+ break;
2390
+ }
2366
2391
  }
2367
2392
  };
2368
2393
  return registerResizeHandle(resizeHandleId, element, direction, {
@@ -2380,7 +2405,7 @@ function PanelResizeHandle({
2380
2405
  touchAction: "none",
2381
2406
  userSelect: "none"
2382
2407
  };
2383
- return createElement(Type, {
2408
+ return React.createElement(Type, {
2384
2409
  ...rest,
2385
2410
  children,
2386
2411
  className: classNameFromProps,
@@ -2401,13 +2426,13 @@ function PanelResizeHandle({
2401
2426
  },
2402
2427
  tabIndex,
2403
2428
  // CSS selectors
2404
- "data-panel-group-direction": direction,
2405
- "data-panel-group-id": groupId,
2406
- "data-resize-handle": "",
2407
- "data-resize-handle-active": state === "drag" ? "pointer" : isFocused ? "keyboard" : undefined,
2408
- "data-resize-handle-state": state,
2409
- "data-panel-resize-handle-enabled": !disabled,
2410
- "data-panel-resize-handle-id": resizeHandleId
2429
+ [DATA_ATTRIBUTES.groupDirection]: direction,
2430
+ [DATA_ATTRIBUTES.groupId]: groupId,
2431
+ [DATA_ATTRIBUTES.resizeHandle]: "",
2432
+ [DATA_ATTRIBUTES.resizeHandleActive]: state === "drag" ? "pointer" : isFocused ? "keyboard" : undefined,
2433
+ [DATA_ATTRIBUTES.resizeHandleEnabled]: !disabled,
2434
+ [DATA_ATTRIBUTES.resizeHandleId]: resizeHandleId,
2435
+ [DATA_ATTRIBUTES.resizeHandleState]: state
2411
2436
  });
2412
2437
  }
2413
2438
  PanelResizeHandle.displayName = "PanelResizeHandle";
@@ -2441,6 +2466,7 @@ function getIntersectingRectangle(rectOne, rectTwo, strict) {
2441
2466
  };
2442
2467
  }
2443
2468
 
2469
+ exports.DATA_ATTRIBUTES = DATA_ATTRIBUTES;
2444
2470
  exports.Panel = Panel;
2445
2471
  exports.PanelGroup = PanelGroup;
2446
2472
  exports.PanelResizeHandle = PanelResizeHandle;