react-resizable-panels 2.0.8-rc.1 → 2.0.8

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.0.8
4
+
5
+ - `Panel`/`PanelGroup`/`PanelResizeHandle`` pass "id" prop through to DOM (#299)
6
+ - `Panel` attributes `data-panel-collapsible` and `data-panel-size` are no longer DEV-only (#297)
7
+
3
8
  ## 2.0.7
4
9
 
5
10
  - Group default layouts use `toPrecision` to avoid small layout shifts due to floating point precision differences between initial server rendering and client hydration (#295)
@@ -180,6 +180,7 @@ function PanelWithForwardedRef({
180
180
  ...rest,
181
181
  children,
182
182
  className: classNameFromProps,
183
+ id: idFromProps,
183
184
  style: {
184
185
  ...style,
185
186
  ...styleFromProps
@@ -1972,11 +1973,12 @@ function PanelGroupWithForwardedRef({
1972
1973
  ...rest,
1973
1974
  children,
1974
1975
  className: classNameFromProps,
1976
+ id: idFromProps,
1977
+ ref: panelGroupElementRef,
1975
1978
  style: {
1976
1979
  ...style,
1977
1980
  ...styleFromProps
1978
1981
  },
1979
- ref: panelGroupElementRef,
1980
1982
  // CSS selectors
1981
1983
  "data-panel-group": "",
1982
1984
  "data-panel-group-direction": direction,
@@ -2180,6 +2182,7 @@ function PanelResizeHandle({
2180
2182
  ...rest,
2181
2183
  children,
2182
2184
  className: classNameFromProps,
2185
+ id: idFromProps,
2183
2186
  onBlur: () => setIsFocused(false),
2184
2187
  onFocus: () => setIsFocused(true),
2185
2188
  ref: elementRef,
@@ -186,6 +186,7 @@ function PanelWithForwardedRef({
186
186
  ...rest,
187
187
  children,
188
188
  className: classNameFromProps,
189
+ id: idFromProps,
189
190
  style: {
190
191
  ...style,
191
192
  ...styleFromProps
@@ -2078,11 +2079,12 @@ function PanelGroupWithForwardedRef({
2078
2079
  ...rest,
2079
2080
  children,
2080
2081
  className: classNameFromProps,
2082
+ id: idFromProps,
2083
+ ref: panelGroupElementRef,
2081
2084
  style: {
2082
2085
  ...style,
2083
2086
  ...styleFromProps
2084
2087
  },
2085
- ref: panelGroupElementRef,
2086
2088
  // CSS selectors
2087
2089
  "data-panel-group": "",
2088
2090
  "data-panel-group-direction": direction,
@@ -2286,6 +2288,7 @@ function PanelResizeHandle({
2286
2288
  ...rest,
2287
2289
  children,
2288
2290
  className: classNameFromProps,
2291
+ id: idFromProps,
2289
2292
  onBlur: () => setIsFocused(false),
2290
2293
  onFocus: () => setIsFocused(true),
2291
2294
  ref: elementRef,
@@ -162,6 +162,7 @@ function PanelWithForwardedRef({
162
162
  ...rest,
163
163
  children,
164
164
  className: classNameFromProps,
165
+ id: idFromProps,
165
166
  style: {
166
167
  ...style,
167
168
  ...styleFromProps
@@ -2054,11 +2055,12 @@ function PanelGroupWithForwardedRef({
2054
2055
  ...rest,
2055
2056
  children,
2056
2057
  className: classNameFromProps,
2058
+ id: idFromProps,
2059
+ ref: panelGroupElementRef,
2057
2060
  style: {
2058
2061
  ...style,
2059
2062
  ...styleFromProps
2060
2063
  },
2061
- ref: panelGroupElementRef,
2062
2064
  // CSS selectors
2063
2065
  "data-panel-group": "",
2064
2066
  "data-panel-group-direction": direction,
@@ -2262,6 +2264,7 @@ function PanelResizeHandle({
2262
2264
  ...rest,
2263
2265
  children,
2264
2266
  className: classNameFromProps,
2267
+ id: idFromProps,
2265
2268
  onBlur: () => setIsFocused(false),
2266
2269
  onFocus: () => setIsFocused(true),
2267
2270
  ref: elementRef,
@@ -156,6 +156,7 @@ function PanelWithForwardedRef({
156
156
  ...rest,
157
157
  children,
158
158
  className: classNameFromProps,
159
+ id: idFromProps,
159
160
  style: {
160
161
  ...style,
161
162
  ...styleFromProps
@@ -1948,11 +1949,12 @@ function PanelGroupWithForwardedRef({
1948
1949
  ...rest,
1949
1950
  children,
1950
1951
  className: classNameFromProps,
1952
+ id: idFromProps,
1953
+ ref: panelGroupElementRef,
1951
1954
  style: {
1952
1955
  ...style,
1953
1956
  ...styleFromProps
1954
1957
  },
1955
- ref: panelGroupElementRef,
1956
1958
  // CSS selectors
1957
1959
  "data-panel-group": "",
1958
1960
  "data-panel-group-direction": direction,
@@ -2156,6 +2158,7 @@ function PanelResizeHandle({
2156
2158
  ...rest,
2157
2159
  children,
2158
2160
  className: classNameFromProps,
2161
+ id: idFromProps,
2159
2162
  onBlur: () => setIsFocused(false),
2160
2163
  onFocus: () => setIsFocused(true),
2161
2164
  ref: elementRef,
@@ -182,6 +182,7 @@ function PanelWithForwardedRef({
182
182
  ...rest,
183
183
  children,
184
184
  className: classNameFromProps,
185
+ id: idFromProps,
185
186
  style: {
186
187
  ...style,
187
188
  ...styleFromProps
@@ -1974,11 +1975,12 @@ function PanelGroupWithForwardedRef({
1974
1975
  ...rest,
1975
1976
  children,
1976
1977
  className: classNameFromProps,
1978
+ id: idFromProps,
1979
+ ref: panelGroupElementRef,
1977
1980
  style: {
1978
1981
  ...style,
1979
1982
  ...styleFromProps
1980
1983
  },
1981
- ref: panelGroupElementRef,
1982
1984
  // CSS selectors
1983
1985
  "data-panel-group": "",
1984
1986
  "data-panel-group-direction": direction,
@@ -2182,6 +2184,7 @@ function PanelResizeHandle({
2182
2184
  ...rest,
2183
2185
  children,
2184
2186
  className: classNameFromProps,
2187
+ id: idFromProps,
2185
2188
  onBlur: () => setIsFocused(false),
2186
2189
  onFocus: () => setIsFocused(true),
2187
2190
  ref: elementRef,
@@ -193,6 +193,7 @@ function PanelWithForwardedRef({
193
193
  ...rest,
194
194
  children,
195
195
  className: classNameFromProps,
196
+ id: idFromProps,
196
197
  style: {
197
198
  ...style,
198
199
  ...styleFromProps
@@ -2085,11 +2086,12 @@ function PanelGroupWithForwardedRef({
2085
2086
  ...rest,
2086
2087
  children,
2087
2088
  className: classNameFromProps,
2089
+ id: idFromProps,
2090
+ ref: panelGroupElementRef,
2088
2091
  style: {
2089
2092
  ...style,
2090
2093
  ...styleFromProps
2091
2094
  },
2092
- ref: panelGroupElementRef,
2093
2095
  // CSS selectors
2094
2096
  "data-panel-group": "",
2095
2097
  "data-panel-group-direction": direction,
@@ -2293,6 +2295,7 @@ function PanelResizeHandle({
2293
2295
  ...rest,
2294
2296
  children,
2295
2297
  className: classNameFromProps,
2298
+ id: idFromProps,
2296
2299
  onBlur: () => setIsFocused(false),
2297
2300
  onFocus: () => setIsFocused(true),
2298
2301
  ref: elementRef,
@@ -169,6 +169,7 @@ function PanelWithForwardedRef({
169
169
  ...rest,
170
170
  children,
171
171
  className: classNameFromProps,
172
+ id: idFromProps,
172
173
  style: {
173
174
  ...style,
174
175
  ...styleFromProps
@@ -2061,11 +2062,12 @@ function PanelGroupWithForwardedRef({
2061
2062
  ...rest,
2062
2063
  children,
2063
2064
  className: classNameFromProps,
2065
+ id: idFromProps,
2066
+ ref: panelGroupElementRef,
2064
2067
  style: {
2065
2068
  ...style,
2066
2069
  ...styleFromProps
2067
2070
  },
2068
- ref: panelGroupElementRef,
2069
2071
  // CSS selectors
2070
2072
  "data-panel-group": "",
2071
2073
  "data-panel-group-direction": direction,
@@ -2269,6 +2271,7 @@ function PanelResizeHandle({
2269
2271
  ...rest,
2270
2272
  children,
2271
2273
  className: classNameFromProps,
2274
+ id: idFromProps,
2272
2275
  onBlur: () => setIsFocused(false),
2273
2276
  onFocus: () => setIsFocused(true),
2274
2277
  ref: elementRef,
@@ -155,6 +155,7 @@ function PanelWithForwardedRef({
155
155
  ...rest,
156
156
  children,
157
157
  className: classNameFromProps,
158
+ id: idFromProps,
158
159
  style: {
159
160
  ...style,
160
161
  ...styleFromProps
@@ -1853,11 +1854,12 @@ function PanelGroupWithForwardedRef({
1853
1854
  ...rest,
1854
1855
  children,
1855
1856
  className: classNameFromProps,
1857
+ id: idFromProps,
1858
+ ref: panelGroupElementRef,
1856
1859
  style: {
1857
1860
  ...style,
1858
1861
  ...styleFromProps
1859
1862
  },
1860
- ref: panelGroupElementRef,
1861
1863
  // CSS selectors
1862
1864
  "data-panel-group": "",
1863
1865
  "data-panel-group-direction": direction,
@@ -2058,6 +2060,7 @@ function PanelResizeHandle({
2058
2060
  ...rest,
2059
2061
  children,
2060
2062
  className: classNameFromProps,
2063
+ id: idFromProps,
2061
2064
  onBlur: () => setIsFocused(false),
2062
2065
  onFocus: () => setIsFocused(true),
2063
2066
  ref: elementRef,
@@ -131,6 +131,7 @@ function PanelWithForwardedRef({
131
131
  ...rest,
132
132
  children,
133
133
  className: classNameFromProps,
134
+ id: idFromProps,
134
135
  style: {
135
136
  ...style,
136
137
  ...styleFromProps
@@ -1829,11 +1830,12 @@ function PanelGroupWithForwardedRef({
1829
1830
  ...rest,
1830
1831
  children,
1831
1832
  className: classNameFromProps,
1833
+ id: idFromProps,
1834
+ ref: panelGroupElementRef,
1832
1835
  style: {
1833
1836
  ...style,
1834
1837
  ...styleFromProps
1835
1838
  },
1836
- ref: panelGroupElementRef,
1837
1839
  // CSS selectors
1838
1840
  "data-panel-group": "",
1839
1841
  "data-panel-group-direction": direction,
@@ -2034,6 +2036,7 @@ function PanelResizeHandle({
2034
2036
  ...rest,
2035
2037
  children,
2036
2038
  className: classNameFromProps,
2039
+ id: idFromProps,
2037
2040
  onBlur: () => setIsFocused(false),
2038
2041
  onFocus: () => setIsFocused(true),
2039
2042
  ref: elementRef,
@@ -158,6 +158,7 @@ function PanelWithForwardedRef({
158
158
  ...rest,
159
159
  children,
160
160
  className: classNameFromProps,
161
+ id: idFromProps,
161
162
  style: {
162
163
  ...style,
163
164
  ...styleFromProps
@@ -1950,11 +1951,12 @@ function PanelGroupWithForwardedRef({
1950
1951
  ...rest,
1951
1952
  children,
1952
1953
  className: classNameFromProps,
1954
+ id: idFromProps,
1955
+ ref: panelGroupElementRef,
1953
1956
  style: {
1954
1957
  ...style,
1955
1958
  ...styleFromProps
1956
1959
  },
1957
- ref: panelGroupElementRef,
1958
1960
  // CSS selectors
1959
1961
  "data-panel-group": "",
1960
1962
  "data-panel-group-direction": direction,
@@ -2158,6 +2160,7 @@ function PanelResizeHandle({
2158
2160
  ...rest,
2159
2161
  children,
2160
2162
  className: classNameFromProps,
2163
+ id: idFromProps,
2161
2164
  onBlur: () => setIsFocused(false),
2162
2165
  onFocus: () => setIsFocused(true),
2163
2166
  ref: elementRef,
@@ -144,6 +144,7 @@ function PanelWithForwardedRef({
144
144
  ...rest,
145
145
  children,
146
146
  className: classNameFromProps,
147
+ id: idFromProps,
147
148
  style: {
148
149
  ...style,
149
150
  ...styleFromProps
@@ -1752,11 +1753,12 @@ function PanelGroupWithForwardedRef({
1752
1753
  ...rest,
1753
1754
  children,
1754
1755
  className: classNameFromProps,
1756
+ id: idFromProps,
1757
+ ref: panelGroupElementRef,
1755
1758
  style: {
1756
1759
  ...style,
1757
1760
  ...styleFromProps
1758
1761
  },
1759
- ref: panelGroupElementRef,
1760
1762
  // CSS selectors
1761
1763
  "data-panel-group": "",
1762
1764
  "data-panel-group-direction": direction,
@@ -1957,6 +1959,7 @@ function PanelResizeHandle({
1957
1959
  ...rest,
1958
1960
  children,
1959
1961
  className: classNameFromProps,
1962
+ id: idFromProps,
1960
1963
  onBlur: () => setIsFocused(false),
1961
1964
  onFocus: () => setIsFocused(true),
1962
1965
  ref: elementRef,
@@ -120,6 +120,7 @@ function PanelWithForwardedRef({
120
120
  ...rest,
121
121
  children,
122
122
  className: classNameFromProps,
123
+ id: idFromProps,
123
124
  style: {
124
125
  ...style,
125
126
  ...styleFromProps
@@ -1728,11 +1729,12 @@ function PanelGroupWithForwardedRef({
1728
1729
  ...rest,
1729
1730
  children,
1730
1731
  className: classNameFromProps,
1732
+ id: idFromProps,
1733
+ ref: panelGroupElementRef,
1731
1734
  style: {
1732
1735
  ...style,
1733
1736
  ...styleFromProps
1734
1737
  },
1735
- ref: panelGroupElementRef,
1736
1738
  // CSS selectors
1737
1739
  "data-panel-group": "",
1738
1740
  "data-panel-group-direction": direction,
@@ -1933,6 +1935,7 @@ function PanelResizeHandle({
1933
1935
  ...rest,
1934
1936
  children,
1935
1937
  className: classNameFromProps,
1938
+ id: idFromProps,
1936
1939
  onBlur: () => setIsFocused(false),
1937
1940
  onFocus: () => setIsFocused(true),
1938
1941
  ref: elementRef,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-resizable-panels",
3
- "version": "2.0.8-rc.1",
3
+ "version": "2.0.8",
4
4
  "description": "React components for resizable panel groups/layouts",
5
5
  "author": "Brian Vaughn <brian.david.vaughn@gmail.com>",
6
6
  "license": "MIT",
@@ -738,6 +738,38 @@ describe("PanelGroup", () => {
738
738
  });
739
739
  });
740
740
 
741
+ describe("a11y", () => {
742
+ it("should pass explicit id prop to DOM", () => {
743
+ act(() => {
744
+ root.render(
745
+ <PanelGroup direction="horizontal">
746
+ <Panel id="explicit-id" />
747
+ </PanelGroup>
748
+ );
749
+ });
750
+
751
+ const element = container.querySelector("[data-panel]");
752
+
753
+ expect(element).not.toBeNull();
754
+ expect(element?.getAttribute("id")).toBe("explicit-id");
755
+ });
756
+
757
+ it("should not pass auto-generated id prop to DOM", () => {
758
+ act(() => {
759
+ root.render(
760
+ <PanelGroup direction="horizontal">
761
+ <Panel />
762
+ </PanelGroup>
763
+ );
764
+ });
765
+
766
+ const element = container.querySelector("[data-panel]");
767
+
768
+ expect(element).not.toBeNull();
769
+ expect(element?.getAttribute("id")).toBeNull();
770
+ });
771
+ });
772
+
741
773
  describe("DEV warnings", () => {
742
774
  it("should warn about server rendered panels with no default size", () => {
743
775
  jest.resetModules();
package/src/Panel.ts CHANGED
@@ -236,6 +236,7 @@ export function PanelWithForwardedRef({
236
236
 
237
237
  children,
238
238
  className: classNameFromProps,
239
+ id: idFromProps,
239
240
  style: {
240
241
  ...style,
241
242
  ...styleFromProps,
@@ -276,6 +276,42 @@ describe("PanelGroup", () => {
276
276
  });
277
277
  });
278
278
 
279
+ describe("a11y", () => {
280
+ it("should pass explicit id prop to DOM", () => {
281
+ act(() => {
282
+ root.render(
283
+ <PanelGroup direction="horizontal" id="explicit-id">
284
+ <Panel />
285
+ <PanelResizeHandle />
286
+ <Panel />
287
+ </PanelGroup>
288
+ );
289
+ });
290
+
291
+ const element = container.querySelector("[data-panel-group]");
292
+
293
+ expect(element).not.toBeNull();
294
+ expect(element?.getAttribute("id")).toBe("explicit-id");
295
+ });
296
+
297
+ it("should not pass auto-generated id prop to DOM", () => {
298
+ act(() => {
299
+ root.render(
300
+ <PanelGroup direction="horizontal">
301
+ <Panel />
302
+ <PanelResizeHandle />
303
+ <Panel />
304
+ </PanelGroup>
305
+ );
306
+ });
307
+
308
+ const element = container.querySelector("[data-panel-group]");
309
+
310
+ expect(element).not.toBeNull();
311
+ expect(element?.getAttribute("id")).toBeNull();
312
+ });
313
+ });
314
+
279
315
  describe("DEV warnings", () => {
280
316
  it("should warn about unstable layouts without id and order props", () => {
281
317
  act(() => {
package/src/PanelGroup.ts CHANGED
@@ -880,13 +880,16 @@ function PanelGroupWithForwardedRef({
880
880
  { value: context },
881
881
  createElement(Type, {
882
882
  ...rest,
883
+
883
884
  children,
884
885
  className: classNameFromProps,
886
+ id: idFromProps,
887
+ ref: panelGroupElementRef,
885
888
  style: {
886
889
  ...style,
887
890
  ...styleFromProps,
888
891
  },
889
- ref: panelGroupElementRef,
892
+
890
893
  // CSS selectors
891
894
  "data-panel-group": "",
892
895
  "data-panel-group-direction": direction,
@@ -269,4 +269,40 @@ describe("PanelResizeHandle", () => {
269
269
  verifyAttribute(rightElement, "data-resize-handle-active", null);
270
270
  });
271
271
  });
272
+
273
+ describe("a11y", () => {
274
+ it("should pass explicit id prop to DOM", () => {
275
+ act(() => {
276
+ root.render(
277
+ <PanelGroup direction="horizontal">
278
+ <Panel />
279
+ <PanelResizeHandle id="explicit-id" />
280
+ <Panel />
281
+ </PanelGroup>
282
+ );
283
+ });
284
+
285
+ const element = container.querySelector("[data-resize-handle]");
286
+
287
+ expect(element).not.toBeNull();
288
+ expect(element?.getAttribute("id")).toBe("explicit-id");
289
+ });
290
+
291
+ it("should not pass auto-generated id prop to DOM", () => {
292
+ act(() => {
293
+ root.render(
294
+ <PanelGroup direction="horizontal">
295
+ <Panel />
296
+ <PanelResizeHandle />
297
+ <Panel />
298
+ </PanelGroup>
299
+ );
300
+ });
301
+
302
+ const element = container.querySelector("[data-resize-handle]");
303
+
304
+ expect(element).not.toBeNull();
305
+ expect(element?.getAttribute("id")).toBeNull();
306
+ });
307
+ });
272
308
  });
@@ -203,6 +203,7 @@ export function PanelResizeHandle({
203
203
 
204
204
  children,
205
205
  className: classNameFromProps,
206
+ id: idFromProps,
206
207
  onBlur: () => setIsFocused(false),
207
208
  onFocus: () => setIsFocused(true),
208
209
  ref: elementRef,