react-resizable-panels 2.1.5 → 2.1.7

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 (89) hide show
  1. package/dist/declarations/src/PanelGroup.d.ts +2 -0
  2. package/dist/react-resizable-panels.browser.cjs.js +16 -10
  3. package/dist/react-resizable-panels.browser.development.cjs.js +16 -10
  4. package/dist/react-resizable-panels.browser.development.esm.js +16 -10
  5. package/dist/react-resizable-panels.browser.esm.js +16 -10
  6. package/dist/react-resizable-panels.cjs.js +16 -10
  7. package/dist/react-resizable-panels.development.cjs.js +16 -10
  8. package/dist/react-resizable-panels.development.esm.js +16 -10
  9. package/dist/react-resizable-panels.development.node.cjs.js +16 -10
  10. package/dist/react-resizable-panels.development.node.esm.js +16 -10
  11. package/dist/react-resizable-panels.esm.js +16 -10
  12. package/dist/react-resizable-panels.node.cjs.js +16 -10
  13. package/dist/react-resizable-panels.node.esm.js +16 -10
  14. package/package.json +7 -1
  15. package/.eslintrc.cjs +0 -27
  16. package/CHANGELOG.md +0 -569
  17. package/jest.config.js +0 -10
  18. package/react-resizable-panels-2.1.5.tgz +0 -0
  19. package/src/Panel.test.tsx +0 -1084
  20. package/src/Panel.ts +0 -259
  21. package/src/PanelGroup.test.tsx +0 -443
  22. package/src/PanelGroup.ts +0 -985
  23. package/src/PanelGroupContext.ts +0 -42
  24. package/src/PanelResizeHandle.test.tsx +0 -367
  25. package/src/PanelResizeHandle.ts +0 -246
  26. package/src/PanelResizeHandleRegistry.ts +0 -336
  27. package/src/constants.ts +0 -1
  28. package/src/env-conditions/browser.ts +0 -1
  29. package/src/env-conditions/development.ts +0 -1
  30. package/src/env-conditions/node.ts +0 -1
  31. package/src/env-conditions/production.ts +0 -1
  32. package/src/env-conditions/unknown.ts +0 -1
  33. package/src/hooks/useForceUpdate.ts +0 -7
  34. package/src/hooks/useIsomorphicEffect.ts +0 -8
  35. package/src/hooks/useUniqueId.ts +0 -19
  36. package/src/hooks/useWindowSplitterBehavior.ts +0 -90
  37. package/src/hooks/useWindowSplitterPanelGroupBehavior.ts +0 -201
  38. package/src/index.ts +0 -77
  39. package/src/types.ts +0 -5
  40. package/src/utils/adjustLayoutByDelta.test.ts +0 -2061
  41. package/src/utils/adjustLayoutByDelta.ts +0 -308
  42. package/src/utils/arrays.ts +0 -13
  43. package/src/utils/assert.ts +0 -10
  44. package/src/utils/calculateAriaValues.test.ts +0 -106
  45. package/src/utils/calculateAriaValues.ts +0 -45
  46. package/src/utils/calculateDeltaPercentage.ts +0 -63
  47. package/src/utils/calculateDragOffsetPercentage.ts +0 -40
  48. package/src/utils/calculateUnsafeDefaultLayout.test.ts +0 -87
  49. package/src/utils/calculateUnsafeDefaultLayout.ts +0 -50
  50. package/src/utils/callPanelCallbacks.ts +0 -49
  51. package/src/utils/compareLayouts.test.ts +0 -9
  52. package/src/utils/compareLayouts.ts +0 -12
  53. package/src/utils/computePanelFlexBoxStyle.test.ts +0 -123
  54. package/src/utils/computePanelFlexBoxStyle.ts +0 -50
  55. package/src/utils/csp.ts +0 -9
  56. package/src/utils/cursor.ts +0 -103
  57. package/src/utils/debounce.ts +0 -18
  58. package/src/utils/determinePivotIndices.ts +0 -15
  59. package/src/utils/dom/getPanelElement.ts +0 -10
  60. package/src/utils/dom/getPanelElementsForGroup.ts +0 -8
  61. package/src/utils/dom/getPanelGroupElement.ts +0 -21
  62. package/src/utils/dom/getResizeHandleElement.ts +0 -10
  63. package/src/utils/dom/getResizeHandleElementIndex.ts +0 -13
  64. package/src/utils/dom/getResizeHandleElementsForGroup.ts +0 -10
  65. package/src/utils/dom/getResizeHandlePanelIds.ts +0 -19
  66. package/src/utils/events/getResizeEventCoordinates.ts +0 -23
  67. package/src/utils/events/getResizeEventCursorPosition.ts +0 -14
  68. package/src/utils/events/index.ts +0 -13
  69. package/src/utils/getInputType.ts +0 -5
  70. package/src/utils/initializeDefaultStorage.ts +0 -26
  71. package/src/utils/numbers/fuzzyCompareNumbers.test.ts +0 -16
  72. package/src/utils/numbers/fuzzyCompareNumbers.ts +0 -21
  73. package/src/utils/numbers/fuzzyLayoutsEqual.ts +0 -22
  74. package/src/utils/numbers/fuzzyNumbersEqual.ts +0 -9
  75. package/src/utils/rects/getIntersectingRectangle.test.ts +0 -198
  76. package/src/utils/rects/getIntersectingRectangle.ts +0 -28
  77. package/src/utils/rects/intersects.test.ts +0 -197
  78. package/src/utils/rects/intersects.ts +0 -23
  79. package/src/utils/rects/types.ts +0 -6
  80. package/src/utils/resizePanel.test.ts +0 -59
  81. package/src/utils/resizePanel.ts +0 -47
  82. package/src/utils/serialization.ts +0 -87
  83. package/src/utils/test-utils.ts +0 -205
  84. package/src/utils/validatePanelConstraints.test.ts +0 -143
  85. package/src/utils/validatePanelConstraints.ts +0 -69
  86. package/src/utils/validatePanelGroupLayout.test.ts +0 -148
  87. package/src/utils/validatePanelGroupLayout.ts +0 -95
  88. package/src/vendor/react.ts +0 -73
  89. package/src/vendor/stacking-order.ts +0 -139
@@ -282,8 +282,8 @@ function intersects(rectOne, rectTwo, strict) {
282
282
  /**
283
283
  * Determine which of two nodes appears in front of the other —
284
284
  * if `a` is in front, returns 1, otherwise returns -1
285
- * @param {HTMLElement} a
286
- * @param {HTMLElement} b
285
+ * @param {HTMLElement | SVGElement} a
286
+ * @param {HTMLElement | SVGElement} b
287
287
  */
288
288
  function compare(a, b) {
289
289
  if (a === b) throw new Error("Cannot compare node with itself");
@@ -321,7 +321,7 @@ function compare(a, b) {
321
321
  }
322
322
  const props = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;
323
323
 
324
- /** @param {HTMLElement} node */
324
+ /** @param {HTMLElement | SVGElement} node */
325
325
  function is_flex_item(node) {
326
326
  var _get_parent;
327
327
  // @ts-ignore
@@ -329,7 +329,7 @@ function is_flex_item(node) {
329
329
  return display === "flex" || display === "inline-flex";
330
330
  }
331
331
 
332
- /** @param {HTMLElement} node */
332
+ /** @param {HTMLElement | SVGElement} node */
333
333
  function creates_stacking_context(node) {
334
334
  const style = getComputedStyle(node);
335
335
 
@@ -354,7 +354,7 @@ function creates_stacking_context(node) {
354
354
  return false;
355
355
  }
356
356
 
357
- /** @param {HTMLElement[]} nodes */
357
+ /** @param {(HTMLElement| SVGElement)[]} nodes */
358
358
  function find_stacking_context(nodes) {
359
359
  let i = nodes.length;
360
360
  while (i--) {
@@ -365,7 +365,7 @@ function find_stacking_context(nodes) {
365
365
  return null;
366
366
  }
367
367
 
368
- /** @param {HTMLElement} node */
368
+ /** @param {HTMLElement | SVGElement} node */
369
369
  function get_z_index(node) {
370
370
  return node && Number(getComputedStyle(node).zIndex) || 0;
371
371
  }
@@ -527,7 +527,7 @@ function recalculateIntersectingHandles({
527
527
  }) {
528
528
  intersectingHandles.splice(0);
529
529
  let targetElement = null;
530
- if (target instanceof HTMLElement) {
530
+ if (target instanceof HTMLElement || target instanceof SVGElement) {
531
531
  targetElement = target;
532
532
  }
533
533
  registeredResizeHandlers.forEach(data => {
@@ -1806,6 +1806,14 @@ function PanelGroupWithForwardedRef({
1806
1806
  forceUpdate();
1807
1807
  }, [forceUpdate]);
1808
1808
  const registerResizeHandle = useCallback(dragHandleId => {
1809
+ let isRTL = false;
1810
+ const panelGroupElement = panelGroupElementRef.current;
1811
+ if (panelGroupElement) {
1812
+ const style = window.getComputedStyle(panelGroupElement, null);
1813
+ if (style.getPropertyValue("direction") === "rtl") {
1814
+ isRTL = true;
1815
+ }
1816
+ }
1809
1817
  return function resizeHandler(event) {
1810
1818
  event.preventDefault();
1811
1819
  const panelGroupElement = panelGroupElementRef.current;
@@ -1828,10 +1836,8 @@ function PanelGroupWithForwardedRef({
1828
1836
  } = dragState !== null && dragState !== void 0 ? dragState : {};
1829
1837
  const pivotIndices = determinePivotIndices(groupId, dragHandleId, panelGroupElement);
1830
1838
  let delta = calculateDeltaPercentage(event, dragHandleId, direction, dragState, keyboardResizeBy, panelGroupElement);
1831
-
1832
- // Support RTL layouts
1833
1839
  const isHorizontal = direction === "horizontal";
1834
- if (document.dir === "rtl" && isHorizontal) {
1840
+ if (isHorizontal && isRTL) {
1835
1841
  delta = -delta;
1836
1842
  }
1837
1843
  const panelConstraints = panelDataArray.map(panelData => panelData.constraints);
@@ -309,8 +309,8 @@ function intersects(rectOne, rectTwo, strict) {
309
309
  /**
310
310
  * Determine which of two nodes appears in front of the other —
311
311
  * if `a` is in front, returns 1, otherwise returns -1
312
- * @param {HTMLElement} a
313
- * @param {HTMLElement} b
312
+ * @param {HTMLElement | SVGElement} a
313
+ * @param {HTMLElement | SVGElement} b
314
314
  */
315
315
  function compare(a, b) {
316
316
  if (a === b) throw new Error("Cannot compare node with itself");
@@ -348,7 +348,7 @@ function compare(a, b) {
348
348
  }
349
349
  const props = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;
350
350
 
351
- /** @param {HTMLElement} node */
351
+ /** @param {HTMLElement | SVGElement} node */
352
352
  function is_flex_item(node) {
353
353
  var _get_parent;
354
354
  // @ts-ignore
@@ -356,7 +356,7 @@ function is_flex_item(node) {
356
356
  return display === "flex" || display === "inline-flex";
357
357
  }
358
358
 
359
- /** @param {HTMLElement} node */
359
+ /** @param {HTMLElement | SVGElement} node */
360
360
  function creates_stacking_context(node) {
361
361
  const style = getComputedStyle(node);
362
362
 
@@ -381,7 +381,7 @@ function creates_stacking_context(node) {
381
381
  return false;
382
382
  }
383
383
 
384
- /** @param {HTMLElement[]} nodes */
384
+ /** @param {(HTMLElement| SVGElement)[]} nodes */
385
385
  function find_stacking_context(nodes) {
386
386
  let i = nodes.length;
387
387
  while (i--) {
@@ -392,7 +392,7 @@ function find_stacking_context(nodes) {
392
392
  return null;
393
393
  }
394
394
 
395
- /** @param {HTMLElement} node */
395
+ /** @param {HTMLElement | SVGElement} node */
396
396
  function get_z_index(node) {
397
397
  return node && Number(getComputedStyle(node).zIndex) || 0;
398
398
  }
@@ -554,7 +554,7 @@ function recalculateIntersectingHandles({
554
554
  }) {
555
555
  intersectingHandles.splice(0);
556
556
  let targetElement = null;
557
- if (target instanceof HTMLElement) {
557
+ if (target instanceof HTMLElement || target instanceof SVGElement) {
558
558
  targetElement = target;
559
559
  }
560
560
  registeredResizeHandlers.forEach(data => {
@@ -1927,6 +1927,14 @@ function PanelGroupWithForwardedRef({
1927
1927
  };
1928
1928
  }, []);
1929
1929
  const registerResizeHandle = useCallback(dragHandleId => {
1930
+ let isRTL = false;
1931
+ const panelGroupElement = panelGroupElementRef.current;
1932
+ if (panelGroupElement) {
1933
+ const style = window.getComputedStyle(panelGroupElement, null);
1934
+ if (style.getPropertyValue("direction") === "rtl") {
1935
+ isRTL = true;
1936
+ }
1937
+ }
1930
1938
  return function resizeHandler(event) {
1931
1939
  event.preventDefault();
1932
1940
  const panelGroupElement = panelGroupElementRef.current;
@@ -1949,10 +1957,8 @@ function PanelGroupWithForwardedRef({
1949
1957
  } = dragState !== null && dragState !== void 0 ? dragState : {};
1950
1958
  const pivotIndices = determinePivotIndices(groupId, dragHandleId, panelGroupElement);
1951
1959
  let delta = calculateDeltaPercentage(event, dragHandleId, direction, dragState, keyboardResizeBy, panelGroupElement);
1952
-
1953
- // Support RTL layouts
1954
1960
  const isHorizontal = direction === "horizontal";
1955
- if (document.dir === "rtl" && isHorizontal) {
1961
+ if (isHorizontal && isRTL) {
1956
1962
  delta = -delta;
1957
1963
  }
1958
1964
  const panelConstraints = panelDataArray.map(panelData => panelData.constraints);
@@ -295,8 +295,8 @@ function intersects(rectOne, rectTwo, strict) {
295
295
  /**
296
296
  * Determine which of two nodes appears in front of the other —
297
297
  * if `a` is in front, returns 1, otherwise returns -1
298
- * @param {HTMLElement} a
299
- * @param {HTMLElement} b
298
+ * @param {HTMLElement | SVGElement} a
299
+ * @param {HTMLElement | SVGElement} b
300
300
  */
301
301
  function compare(a, b) {
302
302
  if (a === b) throw new Error("Cannot compare node with itself");
@@ -334,7 +334,7 @@ function compare(a, b) {
334
334
  }
335
335
  const props = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;
336
336
 
337
- /** @param {HTMLElement} node */
337
+ /** @param {HTMLElement | SVGElement} node */
338
338
  function is_flex_item(node) {
339
339
  var _get_parent;
340
340
  // @ts-ignore
@@ -342,7 +342,7 @@ function is_flex_item(node) {
342
342
  return display === "flex" || display === "inline-flex";
343
343
  }
344
344
 
345
- /** @param {HTMLElement} node */
345
+ /** @param {HTMLElement | SVGElement} node */
346
346
  function creates_stacking_context(node) {
347
347
  const style = getComputedStyle(node);
348
348
 
@@ -367,7 +367,7 @@ function creates_stacking_context(node) {
367
367
  return false;
368
368
  }
369
369
 
370
- /** @param {HTMLElement[]} nodes */
370
+ /** @param {(HTMLElement| SVGElement)[]} nodes */
371
371
  function find_stacking_context(nodes) {
372
372
  let i = nodes.length;
373
373
  while (i--) {
@@ -378,7 +378,7 @@ function find_stacking_context(nodes) {
378
378
  return null;
379
379
  }
380
380
 
381
- /** @param {HTMLElement} node */
381
+ /** @param {HTMLElement | SVGElement} node */
382
382
  function get_z_index(node) {
383
383
  return node && Number(getComputedStyle(node).zIndex) || 0;
384
384
  }
@@ -540,7 +540,7 @@ function recalculateIntersectingHandles({
540
540
  }) {
541
541
  intersectingHandles.splice(0);
542
542
  let targetElement = null;
543
- if (target instanceof HTMLElement) {
543
+ if (target instanceof HTMLElement || target instanceof SVGElement) {
544
544
  targetElement = target;
545
545
  }
546
546
  registeredResizeHandlers.forEach(data => {
@@ -1729,6 +1729,14 @@ function PanelGroupWithForwardedRef({
1729
1729
  forceUpdate();
1730
1730
  }, [forceUpdate]);
1731
1731
  const registerResizeHandle = useCallback(dragHandleId => {
1732
+ let isRTL = false;
1733
+ const panelGroupElement = panelGroupElementRef.current;
1734
+ if (panelGroupElement) {
1735
+ const style = window.getComputedStyle(panelGroupElement, null);
1736
+ if (style.getPropertyValue("direction") === "rtl") {
1737
+ isRTL = true;
1738
+ }
1739
+ }
1732
1740
  return function resizeHandler(event) {
1733
1741
  event.preventDefault();
1734
1742
  const panelGroupElement = panelGroupElementRef.current;
@@ -1751,10 +1759,8 @@ function PanelGroupWithForwardedRef({
1751
1759
  } = dragState !== null && dragState !== void 0 ? dragState : {};
1752
1760
  const pivotIndices = determinePivotIndices(groupId, dragHandleId, panelGroupElement);
1753
1761
  let delta = calculateDeltaPercentage(event, dragHandleId, direction, dragState, keyboardResizeBy, panelGroupElement);
1754
-
1755
- // Support RTL layouts
1756
1762
  const isHorizontal = direction === "horizontal";
1757
- if (document.dir === "rtl" && isHorizontal) {
1763
+ if (isHorizontal && isRTL) {
1758
1764
  delta = -delta;
1759
1765
  }
1760
1766
  const panelConstraints = panelDataArray.map(panelData => panelData.constraints);
@@ -271,8 +271,8 @@ function intersects(rectOne, rectTwo, strict) {
271
271
  /**
272
272
  * Determine which of two nodes appears in front of the other —
273
273
  * if `a` is in front, returns 1, otherwise returns -1
274
- * @param {HTMLElement} a
275
- * @param {HTMLElement} b
274
+ * @param {HTMLElement | SVGElement} a
275
+ * @param {HTMLElement | SVGElement} b
276
276
  */
277
277
  function compare(a, b) {
278
278
  if (a === b) throw new Error("Cannot compare node with itself");
@@ -310,7 +310,7 @@ function compare(a, b) {
310
310
  }
311
311
  const props = /\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;
312
312
 
313
- /** @param {HTMLElement} node */
313
+ /** @param {HTMLElement | SVGElement} node */
314
314
  function is_flex_item(node) {
315
315
  var _get_parent;
316
316
  // @ts-ignore
@@ -318,7 +318,7 @@ function is_flex_item(node) {
318
318
  return display === "flex" || display === "inline-flex";
319
319
  }
320
320
 
321
- /** @param {HTMLElement} node */
321
+ /** @param {HTMLElement | SVGElement} node */
322
322
  function creates_stacking_context(node) {
323
323
  const style = getComputedStyle(node);
324
324
 
@@ -343,7 +343,7 @@ function creates_stacking_context(node) {
343
343
  return false;
344
344
  }
345
345
 
346
- /** @param {HTMLElement[]} nodes */
346
+ /** @param {(HTMLElement| SVGElement)[]} nodes */
347
347
  function find_stacking_context(nodes) {
348
348
  let i = nodes.length;
349
349
  while (i--) {
@@ -354,7 +354,7 @@ function find_stacking_context(nodes) {
354
354
  return null;
355
355
  }
356
356
 
357
- /** @param {HTMLElement} node */
357
+ /** @param {HTMLElement | SVGElement} node */
358
358
  function get_z_index(node) {
359
359
  return node && Number(getComputedStyle(node).zIndex) || 0;
360
360
  }
@@ -516,7 +516,7 @@ function recalculateIntersectingHandles({
516
516
  }) {
517
517
  intersectingHandles.splice(0);
518
518
  let targetElement = null;
519
- if (target instanceof HTMLElement) {
519
+ if (target instanceof HTMLElement || target instanceof SVGElement) {
520
520
  targetElement = target;
521
521
  }
522
522
  registeredResizeHandlers.forEach(data => {
@@ -1705,6 +1705,14 @@ function PanelGroupWithForwardedRef({
1705
1705
  forceUpdate();
1706
1706
  }, [forceUpdate]);
1707
1707
  const registerResizeHandle = useCallback(dragHandleId => {
1708
+ let isRTL = false;
1709
+ const panelGroupElement = panelGroupElementRef.current;
1710
+ if (panelGroupElement) {
1711
+ const style = window.getComputedStyle(panelGroupElement, null);
1712
+ if (style.getPropertyValue("direction") === "rtl") {
1713
+ isRTL = true;
1714
+ }
1715
+ }
1708
1716
  return function resizeHandler(event) {
1709
1717
  event.preventDefault();
1710
1718
  const panelGroupElement = panelGroupElementRef.current;
@@ -1727,10 +1735,8 @@ function PanelGroupWithForwardedRef({
1727
1735
  } = dragState !== null && dragState !== void 0 ? dragState : {};
1728
1736
  const pivotIndices = determinePivotIndices(groupId, dragHandleId, panelGroupElement);
1729
1737
  let delta = calculateDeltaPercentage(event, dragHandleId, direction, dragState, keyboardResizeBy, panelGroupElement);
1730
-
1731
- // Support RTL layouts
1732
1738
  const isHorizontal = direction === "horizontal";
1733
- if (document.dir === "rtl" && isHorizontal) {
1739
+ if (isHorizontal && isRTL) {
1734
1740
  delta = -delta;
1735
1741
  }
1736
1742
  const panelConstraints = panelDataArray.map(panelData => panelData.constraints);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-resizable-panels",
3
- "version": "2.1.5",
3
+ "version": "2.1.7",
4
4
  "description": "React components for resizable panel groups/layouts",
5
5
  "author": "Brian Vaughn <brian.david.vaughn@gmail.com>",
6
6
  "license": "MIT",
@@ -11,6 +11,12 @@
11
11
  "source": "src/index.ts",
12
12
  "main": "dist/react-resizable-panels.cjs.js",
13
13
  "module": "dist/react-resizable-panels.esm.js",
14
+ "files": [
15
+ "dist",
16
+ "package.json",
17
+ "README.md",
18
+ "LICENSE"
19
+ ],
14
20
  "exports": {
15
21
  ".": {
16
22
  "types": {
package/.eslintrc.cjs DELETED
@@ -1,27 +0,0 @@
1
- /* eslint-env node */
2
- module.exports = {
3
- ignorePatterns: [".parcel-cache", "dist", "node_modules"],
4
- parser: "@typescript-eslint/parser",
5
- parserOptions: {
6
- project: "../../tsconfig.json",
7
- tsconfigRootDir: __dirname,
8
- },
9
- plugins: ["@typescript-eslint", "no-restricted-imports", "react-hooks"],
10
- root: true,
11
- rules: {
12
- "@typescript-eslint/no-non-null-assertion": "error",
13
- "no-restricted-imports": [
14
- "error",
15
- {
16
- paths: ["react"],
17
- },
18
- ],
19
- "react-hooks/rules-of-hooks": "error",
20
- "react-hooks/exhaustive-deps": [
21
- "warn",
22
- {
23
- additionalHooks: "(useIsomorphicLayoutEffect)",
24
- },
25
- ],
26
- },
27
- };