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