react-resizable-panels 0.0.53 → 0.0.55

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 (41) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/dist/declarations/src/Panel.d.ts +6 -5
  3. package/dist/declarations/src/PanelGroup.d.ts +8 -4
  4. package/dist/declarations/src/PanelResizeHandle.d.ts +5 -2
  5. package/dist/declarations/src/index.d.ts +9 -8
  6. package/dist/declarations/src/types.d.ts +4 -2
  7. package/dist/declarations/src/utils/group.d.ts +29 -0
  8. package/dist/react-resizable-panels.browser.cjs.js +1709 -0
  9. package/dist/react-resizable-panels.browser.cjs.mjs +6 -0
  10. package/dist/react-resizable-panels.browser.development.cjs.js +1764 -0
  11. package/dist/react-resizable-panels.browser.development.cjs.mjs +6 -0
  12. package/dist/react-resizable-panels.browser.development.esm.js +1737 -0
  13. package/dist/react-resizable-panels.browser.esm.js +1682 -0
  14. package/dist/react-resizable-panels.cjs.js +395 -126
  15. package/dist/react-resizable-panels.cjs.js.map +1 -0
  16. package/dist/react-resizable-panels.cjs.mjs +2 -1
  17. package/dist/react-resizable-panels.development.cjs.js +452 -135
  18. package/dist/react-resizable-panels.development.cjs.mjs +6 -0
  19. package/dist/react-resizable-panels.development.esm.js +452 -136
  20. package/dist/react-resizable-panels.development.node.cjs.js +1579 -0
  21. package/dist/react-resizable-panels.development.node.cjs.mjs +6 -0
  22. package/dist/react-resizable-panels.development.node.esm.js +1552 -0
  23. package/dist/react-resizable-panels.esm.js +395 -127
  24. package/dist/react-resizable-panels.esm.js.map +1 -0
  25. package/dist/react-resizable-panels.node.cjs.js +1523 -0
  26. package/dist/react-resizable-panels.node.cjs.mjs +6 -0
  27. package/dist/react-resizable-panels.node.esm.js +1496 -0
  28. package/package.json +26 -1
  29. package/src/Panel.ts +37 -37
  30. package/src/PanelContexts.ts +5 -6
  31. package/src/PanelGroup.ts +269 -121
  32. package/src/PanelResizeHandle.ts +1 -4
  33. package/src/env-conditions/browser.ts +1 -0
  34. package/src/env-conditions/node.ts +1 -0
  35. package/src/env-conditions/unknown.ts +1 -0
  36. package/src/hooks/useIsomorphicEffect.ts +2 -9
  37. package/src/hooks/useWindowSplitterBehavior.ts +14 -11
  38. package/src/index.ts +11 -3
  39. package/src/types.ts +3 -1
  40. package/src/utils/group.ts +327 -28
  41. package/src/utils/ssr.ts +0 -7
package/src/PanelGroup.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { isBrowser } from "#is-browser";
1
2
  import { isDevelopment } from "#is-development";
2
3
  import {
3
4
  createElement,
@@ -24,9 +25,9 @@ import {
24
25
  PanelGroupOnLayout,
25
26
  PanelGroupStorage,
26
27
  ResizeEvent,
28
+ Units,
27
29
  } from "./types";
28
30
  import { areEqual } from "./utils/arrays";
29
- import { assert } from "./utils/assert";
30
31
  import {
31
32
  getDragOffset,
32
33
  getMovement,
@@ -37,16 +38,19 @@ import { resetGlobalCursorStyle, setGlobalCursorStyle } from "./utils/cursor";
37
38
  import debounce from "./utils/debounce";
38
39
  import {
39
40
  adjustByDelta,
41
+ calculateDefaultLayout,
40
42
  callPanelCallbacks,
43
+ getAvailableGroupSizePixels,
41
44
  getBeforeAndAfterIds,
42
45
  getFlexGrow,
43
46
  getPanelGroup,
44
47
  getResizeHandle,
45
48
  getResizeHandlePanelIds,
46
49
  panelsMapToSortedArray,
50
+ validatePanelGroupLayout,
51
+ validatePanelProps,
47
52
  } from "./utils/group";
48
53
  import { loadPanelLayout, savePanelGroupLayout } from "./utils/serialization";
49
- import { isServerRendering } from "./utils/ssr";
50
54
 
51
55
  const debounceMap: {
52
56
  [key: string]: (
@@ -95,8 +99,10 @@ const defaultStorage: PanelGroupStorage = {
95
99
 
96
100
  export type CommittedValues = {
97
101
  direction: Direction;
102
+ id: string;
98
103
  panels: Map<string, PanelData>;
99
104
  sizes: number[];
105
+ units: Units;
100
106
  };
101
107
 
102
108
  export type PanelDataMap = Map<string, PanelData>;
@@ -114,10 +120,6 @@ export type InitialDragState = {
114
120
  sizes: number[];
115
121
  };
116
122
 
117
- // TODO
118
- // Within an active drag, remember original positions to refine more easily on expand.
119
- // Look at what the Chrome devtools Sources does.
120
-
121
123
  export type PanelGroupProps = {
122
124
  autoSaveId?: string;
123
125
  children?: ReactNode;
@@ -129,11 +131,13 @@ export type PanelGroupProps = {
129
131
  storage?: PanelGroupStorage;
130
132
  style?: CSSProperties;
131
133
  tagName?: ElementType;
134
+ units?: Units;
132
135
  };
133
136
 
134
137
  export type ImperativePanelGroupHandle = {
135
- getLayout: () => number[];
136
- setLayout: (panelSizes: number[]) => void;
138
+ getId: () => string;
139
+ getLayout: (units?: Units) => number[];
140
+ setLayout: (panelSizes: number[], units?: Units) => void;
137
141
  };
138
142
 
139
143
  function PanelGroupWithForwardedRef({
@@ -148,6 +152,7 @@ function PanelGroupWithForwardedRef({
148
152
  storage = defaultStorage,
149
153
  style: styleFromProps = {},
150
154
  tagName: Type = "div",
155
+ units = "percentages",
151
156
  }: PanelGroupProps & {
152
157
  forwardedRef: ForwardedRef<ImperativePanelGroupHandle>;
153
158
  }) {
@@ -161,6 +166,18 @@ function PanelGroupWithForwardedRef({
161
166
  // This has the benefit of causing force-collapsed panels to spring back open if drag is reversed.
162
167
  const initialDragStateRef = useRef<InitialDragState | null>(null);
163
168
 
169
+ const devWarningsRef = useRef<{
170
+ didLogDefaultSizeWarning: boolean;
171
+ didLogIdAndOrderWarning: boolean;
172
+ didLogInvalidLayoutWarning: boolean;
173
+ prevPanelIds: string[];
174
+ }>({
175
+ didLogDefaultSizeWarning: false,
176
+ didLogIdAndOrderWarning: false,
177
+ didLogInvalidLayoutWarning: false,
178
+ prevPanelIds: [],
179
+ });
180
+
164
181
  // Use a ref to guard against users passing inline props
165
182
  const callbacksRef = useRef<{
166
183
  onLayout: PanelGroupOnLayout | undefined;
@@ -182,42 +199,71 @@ function PanelGroupWithForwardedRef({
182
199
  // Store committed values to avoid unnecessarily re-running memoization/effects functions.
183
200
  const committedValuesRef = useRef<CommittedValues>({
184
201
  direction,
202
+ id: groupId,
185
203
  panels,
186
204
  sizes,
205
+ units,
187
206
  });
188
207
 
189
208
  useImperativeHandle(
190
209
  forwardedRef,
191
210
  () => ({
192
- getLayout: () => {
193
- const { sizes } = committedValuesRef.current;
194
- return sizes;
211
+ getId: () => groupId,
212
+ getLayout: (unitsFromParams?: Units) => {
213
+ const { sizes, units: unitsFromProps } = committedValuesRef.current;
214
+
215
+ const units = unitsFromParams ?? unitsFromProps;
216
+ if (units === "pixels") {
217
+ const groupSizePixels = getAvailableGroupSizePixels(groupId);
218
+ return sizes.map((size) => (size / 100) * groupSizePixels);
219
+ } else {
220
+ return sizes;
221
+ }
195
222
  },
196
- setLayout: (sizes: number[]) => {
197
- const total = sizes.reduce(
198
- (accumulated, current) => accumulated + current,
199
- 0
200
- );
223
+ setLayout: (sizes: number[], unitsFromParams?: Units) => {
224
+ const {
225
+ id: groupId,
226
+ panels,
227
+ sizes: prevSizes,
228
+ units,
229
+ } = committedValuesRef.current;
201
230
 
202
- assert(total === 100, "Panel sizes must add up to 100%");
231
+ if ((unitsFromParams || units) === "pixels") {
232
+ const groupSizePixels = getAvailableGroupSizePixels(groupId);
233
+ sizes = sizes.map((size) => (size / groupSizePixels) * 100);
234
+ }
203
235
 
204
- const { panels } = committedValuesRef.current;
205
236
  const panelIdToLastNotifiedSizeMap =
206
237
  panelIdToLastNotifiedSizeMapRef.current;
207
238
  const panelsArray = panelsMapToSortedArray(panels);
208
239
 
209
- setSizes(sizes);
240
+ const nextSizes = validatePanelGroupLayout({
241
+ groupId,
242
+ panels,
243
+ nextSizes: sizes,
244
+ prevSizes,
245
+ units,
246
+ });
247
+ if (!areEqual(prevSizes, nextSizes)) {
248
+ setSizes(nextSizes);
210
249
 
211
- callPanelCallbacks(panelsArray, sizes, panelIdToLastNotifiedSizeMap);
250
+ callPanelCallbacks(
251
+ panelsArray,
252
+ nextSizes,
253
+ panelIdToLastNotifiedSizeMap
254
+ );
255
+ }
212
256
  },
213
257
  }),
214
- []
258
+ [groupId]
215
259
  );
216
260
 
217
261
  useIsomorphicLayoutEffect(() => {
218
262
  committedValuesRef.current.direction = direction;
263
+ committedValuesRef.current.id = groupId;
219
264
  committedValuesRef.current.panels = panels;
220
265
  committedValuesRef.current.sizes = sizes;
266
+ committedValuesRef.current.units = units;
221
267
  });
222
268
 
223
269
  useWindowSplitterPanelGroupBehavior({
@@ -257,7 +303,7 @@ function PanelGroupWithForwardedRef({
257
303
  // Compute the initial sizes based on default weights.
258
304
  // This assumes that panels register during initial mount (no conditional rendering)!
259
305
  useIsomorphicLayoutEffect(() => {
260
- const sizes = committedValuesRef.current.sizes;
306
+ const { id: groupId, sizes, units } = committedValuesRef.current;
261
307
  if (sizes.length === panels.size) {
262
308
  // Only compute (or restore) default sizes once per panel configuration.
263
309
  return;
@@ -272,50 +318,25 @@ function PanelGroupWithForwardedRef({
272
318
  }
273
319
 
274
320
  if (defaultSizes != null) {
275
- setSizes(defaultSizes);
276
- } else {
277
- const panelsArray = panelsMapToSortedArray(panels);
278
-
279
- let panelsWithNullDefaultSize = 0;
280
- let totalDefaultSize = 0;
281
- let totalMinSize = 0;
282
-
283
- // TODO
284
- // Implicit default size calculations below do not account for inferred min/max size values.
285
- // e.g. if Panel A has a maxSize of 40 then Panels A and B can't both have an implicit default size of 50.
286
- // For now, these logic edge cases are left to the user to handle via props.
287
-
288
- panelsArray.forEach((panel) => {
289
- totalMinSize += panel.current.minSize;
290
-
291
- if (panel.current.defaultSize === null) {
292
- panelsWithNullDefaultSize++;
293
- } else {
294
- totalDefaultSize += panel.current.defaultSize;
295
- }
321
+ // Validate saved sizes in case something has changed since last render
322
+ // e.g. for pixel groups, this could be the size of the window
323
+ const validatedSizes = validatePanelGroupLayout({
324
+ groupId,
325
+ panels,
326
+ nextSizes: defaultSizes,
327
+ prevSizes: defaultSizes,
328
+ units,
296
329
  });
297
330
 
298
- if (totalDefaultSize > 100) {
299
- throw new Error(`Default panel sizes cannot exceed 100%`);
300
- } else if (
301
- panelsArray.length > 1 &&
302
- panelsWithNullDefaultSize === 0 &&
303
- totalDefaultSize !== 100
304
- ) {
305
- throw new Error(`Invalid default sizes specified for panels`);
306
- } else if (totalMinSize > 100) {
307
- throw new Error(`Minimum panel sizes cannot exceed 100%`);
308
- }
309
-
310
- setSizes(
311
- panelsArray.map((panel) => {
312
- if (panel.current.defaultSize === null) {
313
- return (100 - totalDefaultSize) / panelsWithNullDefaultSize;
314
- }
331
+ setSizes(validatedSizes);
332
+ } else {
333
+ const sizes = calculateDefaultLayout({
334
+ groupId,
335
+ panels,
336
+ units,
337
+ });
315
338
 
316
- return panel.current.defaultSize;
317
- })
318
- );
339
+ setSizes(sizes);
319
340
  }
320
341
  }, [autoSaveId, panels, storage]);
321
342
 
@@ -334,8 +355,83 @@ function PanelGroupWithForwardedRef({
334
355
  }
335
356
  debounceMap[autoSaveId](autoSaveId, panelsArray, sizes, storage);
336
357
  }
358
+
359
+ if (isDevelopment) {
360
+ const { didLogIdAndOrderWarning, prevPanelIds } = devWarningsRef.current;
361
+ if (!didLogIdAndOrderWarning) {
362
+ const { panels } = committedValuesRef.current;
363
+
364
+ const panelIds = Array.from(panels.keys());
365
+
366
+ devWarningsRef.current.prevPanelIds = panelIds;
367
+
368
+ const panelsHaveChanged =
369
+ prevPanelIds.length > 0 && !areEqual(prevPanelIds, panelIds);
370
+ if (panelsHaveChanged) {
371
+ if (
372
+ Array.from(panels.values()).find(
373
+ (panel) =>
374
+ panel.current.idWasAutoGenerated || panel.current.order == null
375
+ )
376
+ ) {
377
+ devWarningsRef.current.didLogIdAndOrderWarning = true;
378
+
379
+ console.warn(
380
+ `WARNING: Panel id and order props recommended when panels are dynamically rendered`
381
+ );
382
+ }
383
+ }
384
+ }
385
+ }
337
386
  }, [autoSaveId, panels, sizes, storage]);
338
387
 
388
+ useIsomorphicLayoutEffect(() => {
389
+ // Pixel panel constraints need to be reassessed after a group resize
390
+ // We can avoid the ResizeObserver overhead for relative layouts
391
+ if (units === "pixels") {
392
+ const resizeObserver = new ResizeObserver(() => {
393
+ const { panels, sizes: prevSizes } = committedValuesRef.current;
394
+
395
+ const nextSizes = validatePanelGroupLayout({
396
+ groupId,
397
+ panels,
398
+ nextSizes: prevSizes,
399
+ prevSizes,
400
+ units,
401
+ });
402
+ if (!areEqual(prevSizes, nextSizes)) {
403
+ setSizes(nextSizes);
404
+ }
405
+ });
406
+
407
+ resizeObserver.observe(getPanelGroup(groupId)!);
408
+
409
+ return () => {
410
+ resizeObserver.disconnect();
411
+ };
412
+ }
413
+ }, [groupId, units]);
414
+
415
+ const getPanelSize = useCallback(
416
+ (id: string, unitsFromParams?: Units) => {
417
+ const { panels, units: unitsFromProps } = committedValuesRef.current;
418
+
419
+ const panelsArray = panelsMapToSortedArray(panels);
420
+
421
+ const index = panelsArray.findIndex((panel) => panel.current.id === id);
422
+ const size = sizes[index];
423
+
424
+ const units = unitsFromParams ?? unitsFromProps;
425
+ if (units === "pixels") {
426
+ const groupSizePixels = getAvailableGroupSizePixels(groupId);
427
+ return (size / 100) * groupSizePixels;
428
+ } else {
429
+ return size;
430
+ }
431
+ },
432
+ [groupId, sizes]
433
+ );
434
+
339
435
  const getPanelStyle = useCallback(
340
436
  (id: string, defaultSize: number | null): CSSProperties => {
341
437
  const { panels } = committedValuesRef.current;
@@ -345,10 +441,13 @@ function PanelGroupWithForwardedRef({
345
441
  // At this point the best we can do is render everything with the same size.
346
442
  if (panels.size === 0) {
347
443
  if (isDevelopment) {
348
- if (isServerRendering() && defaultSize == null) {
349
- console.warn(
350
- `WARNING: Panel defaultSize prop recommended to avoid layout shift after server rendering`
351
- );
444
+ if (!devWarningsRef.current.didLogDefaultSizeWarning) {
445
+ if (!isBrowser && defaultSize == null) {
446
+ devWarningsRef.current.didLogDefaultSizeWarning = true;
447
+ console.warn(
448
+ `WARNING: Panel defaultSize prop recommended to avoid layout shift after server rendering`
449
+ );
450
+ }
352
451
  }
353
452
  }
354
453
 
@@ -384,6 +483,10 @@ function PanelGroupWithForwardedRef({
384
483
  );
385
484
 
386
485
  const registerPanel = useCallback((id: string, panelRef: PanelData) => {
486
+ const { units } = committedValuesRef.current;
487
+
488
+ validatePanelProps(units, panelRef);
489
+
387
490
  setPanels((prevPanels) => {
388
491
  if (prevPanels.has(id)) {
389
492
  return prevPanels;
@@ -443,9 +546,11 @@ function PanelGroupWithForwardedRef({
443
546
  const size = isHorizontal ? rect.width : rect.height;
444
547
  const delta = (movement / size) * 100;
445
548
 
549
+ // If a validateLayout method has been provided
550
+ // it's important to use it before updating the mouse cursor
446
551
  const nextSizes = adjustByDelta(
447
552
  event,
448
- panels,
553
+ committedValuesRef.current,
449
554
  idBefore,
450
555
  idAfter,
451
556
  delta,
@@ -487,6 +592,7 @@ function PanelGroupWithForwardedRef({
487
592
  const panelIdToLastNotifiedSizeMap =
488
593
  panelIdToLastNotifiedSizeMapRef.current;
489
594
 
595
+ // It's okay to bypass in this case because we already validated above
490
596
  setSizes(nextSizes);
491
597
 
492
598
  // If resize change handlers have been declared, this is the time to call them.
@@ -557,7 +663,7 @@ function PanelGroupWithForwardedRef({
557
663
 
558
664
  const nextSizes = adjustByDelta(
559
665
  null,
560
- panels,
666
+ committedValuesRef.current,
561
667
  idBefore,
562
668
  idAfter,
563
669
  delta,
@@ -618,7 +724,7 @@ function PanelGroupWithForwardedRef({
618
724
 
619
725
  const nextSizes = adjustByDelta(
620
726
  null,
621
- panels,
727
+ committedValuesRef.current,
622
728
  idBefore,
623
729
  idAfter,
624
730
  delta,
@@ -638,63 +744,103 @@ function PanelGroupWithForwardedRef({
638
744
  }
639
745
  }, []);
640
746
 
641
- const resizePanel = useCallback((id: string, nextSize: number) => {
642
- const { panels, sizes: prevSizes } = committedValuesRef.current;
747
+ const resizePanel = useCallback(
748
+ (id: string, nextSize: number, unitsFromParams?: Units) => {
749
+ const {
750
+ id: groupId,
751
+ panels,
752
+ sizes: prevSizes,
753
+ units,
754
+ } = committedValuesRef.current;
755
+
756
+ if ((unitsFromParams || units) === "pixels") {
757
+ const groupSizePixels = getAvailableGroupSizePixels(groupId);
758
+ nextSize = (nextSize / groupSizePixels) * 100;
759
+ }
643
760
 
644
- const panel = panels.get(id);
645
- if (panel == null) {
646
- return;
647
- }
761
+ const panel = panels.get(id);
762
+ if (panel == null) {
763
+ return;
764
+ }
648
765
 
649
- const { collapsedSize, collapsible, maxSize, minSize } = panel.current;
766
+ let { collapsedSize, collapsible, maxSize, minSize } = panel.current;
650
767
 
651
- const panelsArray = panelsMapToSortedArray(panels);
768
+ if (units === "pixels") {
769
+ const groupSizePixels = getAvailableGroupSizePixels(groupId);
770
+ minSize = (minSize / groupSizePixels) * 100;
771
+ if (maxSize != null) {
772
+ maxSize = (maxSize / groupSizePixels) * 100;
773
+ }
774
+ }
652
775
 
653
- const index = panelsArray.indexOf(panel);
654
- if (index < 0) {
655
- return;
656
- }
776
+ const panelsArray = panelsMapToSortedArray(panels);
657
777
 
658
- const currentSize = prevSizes[index];
659
- if (currentSize === nextSize) {
660
- return;
661
- }
778
+ const index = panelsArray.indexOf(panel);
779
+ if (index < 0) {
780
+ return;
781
+ }
662
782
 
663
- if (collapsible && nextSize === collapsedSize) {
664
- // This is a valid resize state.
665
- } else {
666
- nextSize = Math.min(maxSize, Math.max(minSize, nextSize));
667
- }
783
+ const currentSize = prevSizes[index];
784
+ if (currentSize === nextSize) {
785
+ return;
786
+ }
668
787
 
669
- const [idBefore, idAfter] = getBeforeAndAfterIds(id, panelsArray);
670
- if (idBefore == null || idAfter == null) {
671
- return;
672
- }
788
+ if (collapsible && nextSize === collapsedSize) {
789
+ // This is a valid resize state.
790
+ } else {
791
+ const unsafeNextSize = nextSize;
673
792
 
674
- const isLastPanel = index === panelsArray.length - 1;
675
- const delta = isLastPanel ? currentSize - nextSize : nextSize - currentSize;
793
+ nextSize = Math.min(
794
+ maxSize != null ? maxSize : 100,
795
+ Math.max(minSize, nextSize)
796
+ );
676
797
 
677
- const nextSizes = adjustByDelta(
678
- null,
679
- panels,
680
- idBefore,
681
- idAfter,
682
- delta,
683
- prevSizes,
684
- panelSizeBeforeCollapse.current,
685
- null
686
- );
687
- if (prevSizes !== nextSizes) {
688
- const panelIdToLastNotifiedSizeMap =
689
- panelIdToLastNotifiedSizeMapRef.current;
798
+ if (isDevelopment) {
799
+ if (unsafeNextSize !== nextSize) {
800
+ console.error(
801
+ `Invalid size (${unsafeNextSize}) specified for Panel "${panel.current.id}" given the panel's min/max size constraints`
802
+ );
803
+ }
804
+ }
805
+ }
690
806
 
691
- setSizes(nextSizes);
807
+ const [idBefore, idAfter] = getBeforeAndAfterIds(id, panelsArray);
808
+ if (idBefore == null || idAfter == null) {
809
+ return;
810
+ }
692
811
 
693
- // If resize change handlers have been declared, this is the time to call them.
694
- // Trigger user callbacks after updating state, so that user code can override the sizes.
695
- callPanelCallbacks(panelsArray, nextSizes, panelIdToLastNotifiedSizeMap);
696
- }
697
- }, []);
812
+ const isLastPanel = index === panelsArray.length - 1;
813
+ const delta = isLastPanel
814
+ ? currentSize - nextSize
815
+ : nextSize - currentSize;
816
+
817
+ const nextSizes = adjustByDelta(
818
+ null,
819
+ committedValuesRef.current,
820
+ idBefore,
821
+ idAfter,
822
+ delta,
823
+ prevSizes,
824
+ panelSizeBeforeCollapse.current,
825
+ null
826
+ );
827
+ if (prevSizes !== nextSizes) {
828
+ const panelIdToLastNotifiedSizeMap =
829
+ panelIdToLastNotifiedSizeMapRef.current;
830
+
831
+ setSizes(nextSizes);
832
+
833
+ // If resize change handlers have been declared, this is the time to call them.
834
+ // Trigger user callbacks after updating state, so that user code can override the sizes.
835
+ callPanelCallbacks(
836
+ panelsArray,
837
+ nextSizes,
838
+ panelIdToLastNotifiedSizeMap
839
+ );
840
+ }
841
+ },
842
+ []
843
+ );
698
844
 
699
845
  const context = useMemo(
700
846
  () => ({
@@ -702,6 +848,7 @@ function PanelGroupWithForwardedRef({
702
848
  collapsePanel,
703
849
  direction,
704
850
  expandPanel,
851
+ getPanelSize,
705
852
  getPanelStyle,
706
853
  groupId,
707
854
  registerPanel,
@@ -726,6 +873,7 @@ function PanelGroupWithForwardedRef({
726
873
 
727
874
  initialDragStateRef.current = null;
728
875
  },
876
+ units,
729
877
  unregisterPanel,
730
878
  }),
731
879
  [
@@ -733,11 +881,13 @@ function PanelGroupWithForwardedRef({
733
881
  collapsePanel,
734
882
  direction,
735
883
  expandPanel,
884
+ getPanelSize,
736
885
  getPanelStyle,
737
886
  groupId,
738
887
  registerPanel,
739
888
  registerResizeHandle,
740
889
  resizePanel,
890
+ units,
741
891
  unregisterPanel,
742
892
  ]
743
893
  );
@@ -757,6 +907,7 @@ function PanelGroupWithForwardedRef({
757
907
  "data-panel-group": "",
758
908
  "data-panel-group-direction": direction,
759
909
  "data-panel-group-id": groupId,
910
+ "data-panel-group-units": units,
760
911
  style: { ...style, ...styleFromProps },
761
912
  }),
762
913
  value: context,
@@ -770,8 +921,5 @@ export const PanelGroup = forwardRef<
770
921
  createElement(PanelGroupWithForwardedRef, { ...props, forwardedRef: ref })
771
922
  );
772
923
 
773
- // Workaround for Parcel scope hoisting (which renames objects/functions).
774
- // Casting to :any is required to avoid corrupting the generated TypeScript types.
775
- // See github.com/parcel-bundler/parcel/issues/8724
776
- (PanelGroupWithForwardedRef as any).displayName = "PanelGroup";
777
- (PanelGroup as any).displayName = "forwardRef(PanelGroup)";
924
+ PanelGroupWithForwardedRef.displayName = "PanelGroup";
925
+ PanelGroup.displayName = "forwardRef(PanelGroup)";
@@ -190,7 +190,4 @@ export function PanelResizeHandle({
190
190
  });
191
191
  }
192
192
 
193
- // Workaround for Parcel scope hoisting (which renames objects/functions).
194
- // Casting to :any is required to avoid corrupting the generated TypeScript types.
195
- // See github.com/parcel-bundler/parcel/issues/8724
196
- (PanelResizeHandle as any).displayName = "PanelResizeHandle";
193
+ PanelResizeHandle.displayName = "PanelResizeHandle";
@@ -0,0 +1 @@
1
+ export const isBrowser = true;
@@ -0,0 +1 @@
1
+ export const isBrowser = false;
@@ -0,0 +1 @@
1
+ export const isBrowser = typeof window !== "undefined";
@@ -1,13 +1,6 @@
1
+ import { isBrowser } from "#is-browser";
1
2
  import { useLayoutEffect } from "../vendor/react";
2
3
 
3
- const canUseEffectHooks = !!(
4
- typeof window !== "undefined" &&
5
- typeof window.document !== "undefined" &&
6
- typeof window.document.createElement !== "undefined"
7
- );
8
-
9
- const useIsomorphicLayoutEffect = canUseEffectHooks
10
- ? useLayoutEffect
11
- : () => {};
4
+ const useIsomorphicLayoutEffect = isBrowser ? useLayoutEffect : () => {};
12
5
 
13
6
  export default useIsomorphicLayoutEffect;