react-resizable-panels 2.1.5 → 2.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ # 2.1.6
4
+
5
+ - Removed `"engines"` block and replaced with `"packageManager"`
6
+ - Don't read `document.direction` for RTL detection; use inherited style instead
7
+
3
8
  ## 2.1.5
4
9
 
5
10
  - Add react v19 to peer deps
@@ -20,6 +20,7 @@ export type PanelGroupProps = Omit<HTMLAttributes<keyof HTMLElementTagNameMap>,
20
20
  storage?: PanelGroupStorage;
21
21
  style?: CSSProperties;
22
22
  tagName?: keyof HTMLElementTagNameMap;
23
+ dir?: "auto" | "ltr" | "rtl" | undefined;
23
24
  }>;
24
25
  export declare const PanelGroup: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<keyof HTMLElementTagNameMap>, "id"> & {
25
26
  autoSaveId?: string | null | undefined;
@@ -31,6 +32,7 @@ export declare const PanelGroup: import("react").ForwardRefExoticComponent<Omit<
31
32
  storage?: PanelGroupStorage | undefined;
32
33
  style?: CSSProperties | undefined;
33
34
  tagName?: keyof HTMLElementTagNameMap | undefined;
35
+ dir?: "auto" | "ltr" | "rtl" | undefined;
34
36
  } & {
35
37
  children?: import("react").ReactNode;
36
38
  } & import("react").RefAttributes<ImperativePanelGroupHandle>>;
@@ -1949,6 +1949,14 @@ function PanelGroupWithForwardedRef({
1949
1949
  };
1950
1950
  }, []);
1951
1951
  const registerResizeHandle = useCallback(dragHandleId => {
1952
+ let isRTL = false;
1953
+ const panelGroupElement = panelGroupElementRef.current;
1954
+ if (panelGroupElement) {
1955
+ const style = window.getComputedStyle(panelGroupElement, null);
1956
+ if (style.getPropertyValue("direction") === "rtl") {
1957
+ isRTL = true;
1958
+ }
1959
+ }
1952
1960
  return function resizeHandler(event) {
1953
1961
  event.preventDefault();
1954
1962
  const panelGroupElement = panelGroupElementRef.current;
@@ -1971,10 +1979,8 @@ function PanelGroupWithForwardedRef({
1971
1979
  } = dragState !== null && dragState !== void 0 ? dragState : {};
1972
1980
  const pivotIndices = determinePivotIndices(groupId, dragHandleId, panelGroupElement);
1973
1981
  let delta = calculateDeltaPercentage(event, dragHandleId, direction, dragState, keyboardResizeBy, panelGroupElement);
1974
-
1975
- // Support RTL layouts
1976
1982
  const isHorizontal = direction === "horizontal";
1977
- if (document.dir === "rtl" && isHorizontal) {
1983
+ if (isHorizontal && isRTL) {
1978
1984
  delta = -delta;
1979
1985
  }
1980
1986
  const panelConstraints = panelDataArray.map(panelData => panelData.constraints);
@@ -2055,6 +2055,14 @@ function PanelGroupWithForwardedRef({
2055
2055
  };
2056
2056
  }, []);
2057
2057
  const registerResizeHandle = useCallback(dragHandleId => {
2058
+ let isRTL = false;
2059
+ const panelGroupElement = panelGroupElementRef.current;
2060
+ if (panelGroupElement) {
2061
+ const style = window.getComputedStyle(panelGroupElement, null);
2062
+ if (style.getPropertyValue("direction") === "rtl") {
2063
+ isRTL = true;
2064
+ }
2065
+ }
2058
2066
  return function resizeHandler(event) {
2059
2067
  event.preventDefault();
2060
2068
  const panelGroupElement = panelGroupElementRef.current;
@@ -2077,10 +2085,8 @@ function PanelGroupWithForwardedRef({
2077
2085
  } = dragState !== null && dragState !== void 0 ? dragState : {};
2078
2086
  const pivotIndices = determinePivotIndices(groupId, dragHandleId, panelGroupElement);
2079
2087
  let delta = calculateDeltaPercentage(event, dragHandleId, direction, dragState, keyboardResizeBy, panelGroupElement);
2080
-
2081
- // Support RTL layouts
2082
2088
  const isHorizontal = direction === "horizontal";
2083
- if (document.dir === "rtl" && isHorizontal) {
2089
+ if (isHorizontal && isRTL) {
2084
2090
  delta = -delta;
2085
2091
  }
2086
2092
  const panelConstraints = panelDataArray.map(panelData => panelData.constraints);
@@ -2031,6 +2031,14 @@ function PanelGroupWithForwardedRef({
2031
2031
  };
2032
2032
  }, []);
2033
2033
  const registerResizeHandle = useCallback(dragHandleId => {
2034
+ let isRTL = false;
2035
+ const panelGroupElement = panelGroupElementRef.current;
2036
+ if (panelGroupElement) {
2037
+ const style = window.getComputedStyle(panelGroupElement, null);
2038
+ if (style.getPropertyValue("direction") === "rtl") {
2039
+ isRTL = true;
2040
+ }
2041
+ }
2034
2042
  return function resizeHandler(event) {
2035
2043
  event.preventDefault();
2036
2044
  const panelGroupElement = panelGroupElementRef.current;
@@ -2053,10 +2061,8 @@ function PanelGroupWithForwardedRef({
2053
2061
  } = dragState !== null && dragState !== void 0 ? dragState : {};
2054
2062
  const pivotIndices = determinePivotIndices(groupId, dragHandleId, panelGroupElement);
2055
2063
  let delta = calculateDeltaPercentage(event, dragHandleId, direction, dragState, keyboardResizeBy, panelGroupElement);
2056
-
2057
- // Support RTL layouts
2058
2064
  const isHorizontal = direction === "horizontal";
2059
- if (document.dir === "rtl" && isHorizontal) {
2065
+ if (isHorizontal && isRTL) {
2060
2066
  delta = -delta;
2061
2067
  }
2062
2068
  const panelConstraints = panelDataArray.map(panelData => panelData.constraints);
@@ -1925,6 +1925,14 @@ function PanelGroupWithForwardedRef({
1925
1925
  };
1926
1926
  }, []);
1927
1927
  const registerResizeHandle = useCallback(dragHandleId => {
1928
+ let isRTL = false;
1929
+ const panelGroupElement = panelGroupElementRef.current;
1930
+ if (panelGroupElement) {
1931
+ const style = window.getComputedStyle(panelGroupElement, null);
1932
+ if (style.getPropertyValue("direction") === "rtl") {
1933
+ isRTL = true;
1934
+ }
1935
+ }
1928
1936
  return function resizeHandler(event) {
1929
1937
  event.preventDefault();
1930
1938
  const panelGroupElement = panelGroupElementRef.current;
@@ -1947,10 +1955,8 @@ function PanelGroupWithForwardedRef({
1947
1955
  } = dragState !== null && dragState !== void 0 ? dragState : {};
1948
1956
  const pivotIndices = determinePivotIndices(groupId, dragHandleId, panelGroupElement);
1949
1957
  let delta = calculateDeltaPercentage(event, dragHandleId, direction, dragState, keyboardResizeBy, panelGroupElement);
1950
-
1951
- // Support RTL layouts
1952
1958
  const isHorizontal = direction === "horizontal";
1953
- if (document.dir === "rtl" && isHorizontal) {
1959
+ if (isHorizontal && isRTL) {
1954
1960
  delta = -delta;
1955
1961
  }
1956
1962
  const panelConstraints = panelDataArray.map(panelData => panelData.constraints);
@@ -1951,6 +1951,14 @@ function PanelGroupWithForwardedRef({
1951
1951
  };
1952
1952
  }, []);
1953
1953
  const registerResizeHandle = useCallback(dragHandleId => {
1954
+ let isRTL = false;
1955
+ const panelGroupElement = panelGroupElementRef.current;
1956
+ if (panelGroupElement) {
1957
+ const style = window.getComputedStyle(panelGroupElement, null);
1958
+ if (style.getPropertyValue("direction") === "rtl") {
1959
+ isRTL = true;
1960
+ }
1961
+ }
1954
1962
  return function resizeHandler(event) {
1955
1963
  event.preventDefault();
1956
1964
  const panelGroupElement = panelGroupElementRef.current;
@@ -1973,10 +1981,8 @@ function PanelGroupWithForwardedRef({
1973
1981
  } = dragState !== null && dragState !== void 0 ? dragState : {};
1974
1982
  const pivotIndices = determinePivotIndices(groupId, dragHandleId, panelGroupElement);
1975
1983
  let delta = calculateDeltaPercentage(event, dragHandleId, direction, dragState, keyboardResizeBy, panelGroupElement);
1976
-
1977
- // Support RTL layouts
1978
1984
  const isHorizontal = direction === "horizontal";
1979
- if (document.dir === "rtl" && isHorizontal) {
1985
+ if (isHorizontal && isRTL) {
1980
1986
  delta = -delta;
1981
1987
  }
1982
1988
  const panelConstraints = panelDataArray.map(panelData => panelData.constraints);
@@ -2062,6 +2062,14 @@ function PanelGroupWithForwardedRef({
2062
2062
  };
2063
2063
  }, []);
2064
2064
  const registerResizeHandle = useCallback(dragHandleId => {
2065
+ let isRTL = false;
2066
+ const panelGroupElement = panelGroupElementRef.current;
2067
+ if (panelGroupElement) {
2068
+ const style = window.getComputedStyle(panelGroupElement, null);
2069
+ if (style.getPropertyValue("direction") === "rtl") {
2070
+ isRTL = true;
2071
+ }
2072
+ }
2065
2073
  return function resizeHandler(event) {
2066
2074
  event.preventDefault();
2067
2075
  const panelGroupElement = panelGroupElementRef.current;
@@ -2084,10 +2092,8 @@ function PanelGroupWithForwardedRef({
2084
2092
  } = dragState !== null && dragState !== void 0 ? dragState : {};
2085
2093
  const pivotIndices = determinePivotIndices(groupId, dragHandleId, panelGroupElement);
2086
2094
  let delta = calculateDeltaPercentage(event, dragHandleId, direction, dragState, keyboardResizeBy, panelGroupElement);
2087
-
2088
- // Support RTL layouts
2089
2095
  const isHorizontal = direction === "horizontal";
2090
- if (document.dir === "rtl" && isHorizontal) {
2096
+ if (isHorizontal && isRTL) {
2091
2097
  delta = -delta;
2092
2098
  }
2093
2099
  const panelConstraints = panelDataArray.map(panelData => panelData.constraints);
@@ -2038,6 +2038,14 @@ function PanelGroupWithForwardedRef({
2038
2038
  };
2039
2039
  }, []);
2040
2040
  const registerResizeHandle = useCallback(dragHandleId => {
2041
+ let isRTL = false;
2042
+ const panelGroupElement = panelGroupElementRef.current;
2043
+ if (panelGroupElement) {
2044
+ const style = window.getComputedStyle(panelGroupElement, null);
2045
+ if (style.getPropertyValue("direction") === "rtl") {
2046
+ isRTL = true;
2047
+ }
2048
+ }
2041
2049
  return function resizeHandler(event) {
2042
2050
  event.preventDefault();
2043
2051
  const panelGroupElement = panelGroupElementRef.current;
@@ -2060,10 +2068,8 @@ function PanelGroupWithForwardedRef({
2060
2068
  } = dragState !== null && dragState !== void 0 ? dragState : {};
2061
2069
  const pivotIndices = determinePivotIndices(groupId, dragHandleId, panelGroupElement);
2062
2070
  let delta = calculateDeltaPercentage(event, dragHandleId, direction, dragState, keyboardResizeBy, panelGroupElement);
2063
-
2064
- // Support RTL layouts
2065
2071
  const isHorizontal = direction === "horizontal";
2066
- if (document.dir === "rtl" && isHorizontal) {
2072
+ if (isHorizontal && isRTL) {
2067
2073
  delta = -delta;
2068
2074
  }
2069
2075
  const panelConstraints = panelDataArray.map(panelData => panelData.constraints);
@@ -1830,6 +1830,14 @@ function PanelGroupWithForwardedRef({
1830
1830
  forceUpdate();
1831
1831
  }, [forceUpdate]);
1832
1832
  const registerResizeHandle = useCallback(dragHandleId => {
1833
+ let isRTL = false;
1834
+ const panelGroupElement = panelGroupElementRef.current;
1835
+ if (panelGroupElement) {
1836
+ const style = window.getComputedStyle(panelGroupElement, null);
1837
+ if (style.getPropertyValue("direction") === "rtl") {
1838
+ isRTL = true;
1839
+ }
1840
+ }
1833
1841
  return function resizeHandler(event) {
1834
1842
  event.preventDefault();
1835
1843
  const panelGroupElement = panelGroupElementRef.current;
@@ -1852,10 +1860,8 @@ function PanelGroupWithForwardedRef({
1852
1860
  } = dragState !== null && dragState !== void 0 ? dragState : {};
1853
1861
  const pivotIndices = determinePivotIndices(groupId, dragHandleId, panelGroupElement);
1854
1862
  let delta = calculateDeltaPercentage(event, dragHandleId, direction, dragState, keyboardResizeBy, panelGroupElement);
1855
-
1856
- // Support RTL layouts
1857
1863
  const isHorizontal = direction === "horizontal";
1858
- if (document.dir === "rtl" && isHorizontal) {
1864
+ if (isHorizontal && isRTL) {
1859
1865
  delta = -delta;
1860
1866
  }
1861
1867
  const panelConstraints = panelDataArray.map(panelData => panelData.constraints);
@@ -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);
@@ -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);
@@ -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);
@@ -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.6",
4
4
  "description": "React components for resizable panel groups/layouts",
5
5
  "author": "Brian Vaughn <brian.david.vaughn@gmail.com>",
6
6
  "license": "MIT",
package/src/PanelGroup.ts CHANGED
@@ -98,6 +98,9 @@ export type PanelGroupProps = Omit<
98
98
  storage?: PanelGroupStorage;
99
99
  style?: CSSProperties;
100
100
  tagName?: keyof HTMLElementTagNameMap;
101
+
102
+ // Better TypeScript hinting
103
+ dir?: "auto" | "ltr" | "rtl" | undefined;
101
104
  }>;
102
105
 
103
106
  const debounceMap: {
@@ -613,8 +616,19 @@ function PanelGroupWithForwardedRef({
613
616
  }, []);
614
617
 
615
618
  const registerResizeHandle = useCallback((dragHandleId: string) => {
619
+ let isRTL = false;
620
+
621
+ const panelGroupElement = panelGroupElementRef.current;
622
+ if (panelGroupElement) {
623
+ const style = window.getComputedStyle(panelGroupElement, null);
624
+ if (style.getPropertyValue("direction") === "rtl") {
625
+ isRTL = true;
626
+ }
627
+ }
628
+
616
629
  return function resizeHandler(event: ResizeEvent) {
617
630
  event.preventDefault();
631
+
618
632
  const panelGroupElement = panelGroupElementRef.current;
619
633
  if (!panelGroupElement) {
620
634
  return () => null;
@@ -646,9 +660,9 @@ function PanelGroupWithForwardedRef({
646
660
  panelGroupElement
647
661
  );
648
662
 
649
- // Support RTL layouts
650
663
  const isHorizontal = direction === "horizontal";
651
- if (document.dir === "rtl" && isHorizontal) {
664
+
665
+ if (isHorizontal && isRTL) {
652
666
  delta = -delta;
653
667
  }
654
668
 
Binary file