react-resizable-panels 0.0.56 → 0.0.57

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.
@@ -61,7 +61,7 @@ function useUniqueId(idFromParams = null) {
61
61
  if (idRef.current === null) {
62
62
  idRef.current = "" + counter++;
63
63
  }
64
- return idFromParams ?? idRef.current;
64
+ return idFromParams !== null && idFromParams !== void 0 ? idFromParams : idRef.current;
65
65
  }
66
66
 
67
67
  function PanelWithForwardedRef({
@@ -196,9 +196,9 @@ function PanelWithForwardedRef({
196
196
  },
197
197
  // CSS selectors
198
198
  "data-panel": "",
199
+ "data-panel-id": panelId,
199
200
  // e2e test attributes
200
201
  "data-panel-collapsible": collapsible || undefined ,
201
- "data-panel-id": panelId ,
202
202
  "data-panel-size": parseFloat("" + style.flexGrow).toFixed(1)
203
203
  });
204
204
  }
@@ -226,6 +226,16 @@ function convertPixelConstraintsToPercentages(panelConstraints, groupSizePixels)
226
226
  minSizePercentage = 0,
227
227
  minSizePixels
228
228
  } = panelConstraints;
229
+ const hasPixelConstraints = collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null;
230
+ if (hasPixelConstraints && groupSizePixels <= 0) {
231
+ console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
232
+ return {
233
+ collapsedSizePercentage: 0,
234
+ defaultSizePercentage,
235
+ maxSizePercentage: 0,
236
+ minSizePercentage: 0
237
+ };
238
+ }
229
239
  if (collapsedSizePixels != null) {
230
240
  collapsedSizePercentage = convertPixelsToPercentage(collapsedSizePixels, groupSizePixels);
231
241
  }
@@ -300,6 +310,16 @@ function resizePanel({
300
310
  panelIndex,
301
311
  size
302
312
  }) {
313
+ const hasPixelConstraints = panelConstraints.some(({
314
+ collapsedSizePixels,
315
+ defaultSizePixels,
316
+ minSizePixels,
317
+ maxSizePixels
318
+ }) => collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null);
319
+ if (hasPixelConstraints && groupSizePixels <= 0) {
320
+ console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
321
+ return 0;
322
+ }
303
323
  let {
304
324
  collapsible
305
325
  } = panelConstraints[panelIndex];
@@ -356,7 +376,6 @@ function adjustLayoutByDelta({
356
376
  } = panelConstraints[pivotIndex];
357
377
  const {
358
378
  collapsedSizePercentage,
359
- maxSizePercentage,
360
379
  minSizePercentage
361
380
  } = computePercentagePanelConstraints(panelConstraints, pivotIndex, groupSizePixels);
362
381
  const isCollapsed = collapsible && fuzzyNumbersEqual(initialSize, collapsedSizePercentage);
@@ -518,6 +537,7 @@ function calculateAriaValues({
518
537
 
519
538
  // A panel's effective min/max sizes also need to account for other panel's sizes.
520
539
  panelsArray.forEach((panelData, index) => {
540
+ var _getPercentageSizeFro, _getPercentageSizeFro2;
521
541
  const {
522
542
  constraints
523
543
  } = panelData;
@@ -527,14 +547,14 @@ function calculateAriaValues({
527
547
  minSizePercentage,
528
548
  minSizePixels
529
549
  } = constraints;
530
- const minSize = getPercentageSizeFromMixedSizes({
550
+ const minSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
531
551
  sizePercentage: minSizePercentage,
532
552
  sizePixels: minSizePixels
533
- }, groupSizePixels) ?? 0;
534
- const maxSize = getPercentageSizeFromMixedSizes({
553
+ }, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
554
+ const maxSize = (_getPercentageSizeFro2 = getPercentageSizeFromMixedSizes({
535
555
  sizePercentage: maxSizePercentage,
536
556
  sizePixels: maxSizePixels
537
- }, groupSizePixels) ?? 100;
557
+ }, groupSizePixels)) !== null && _getPercentageSizeFro2 !== void 0 ? _getPercentageSizeFro2 : 100;
538
558
  if (index === pivotIndices[0]) {
539
559
  currentMinSize = minSize;
540
560
  currentMaxSize = maxSize;
@@ -560,7 +580,7 @@ function getResizeHandleElementsForGroup(groupId) {
560
580
  function getResizeHandleElementIndex(groupId, id) {
561
581
  const handles = getResizeHandleElementsForGroup(groupId);
562
582
  const index = handles.findIndex(handle => handle.getAttribute("data-panel-resize-handle-id") === id);
563
- return index ?? null;
583
+ return index !== null && index !== void 0 ? index : null;
564
584
  }
565
585
 
566
586
  function determinePivotIndices(groupId, dragHandleId) {
@@ -569,7 +589,7 @@ function determinePivotIndices(groupId, dragHandleId) {
569
589
  }
570
590
 
571
591
  function getPanelGroupElement(id) {
572
- const element = document.querySelector(`[data-panel-group-id="${id}"]`);
592
+ const element = document.querySelector(`[data-panel-group][data-panel-group-id="${id}"]`);
573
593
  if (element) {
574
594
  return element;
575
595
  }
@@ -621,11 +641,12 @@ function getResizeHandleElement(id) {
621
641
  }
622
642
 
623
643
  function getResizeHandlePanelIds(groupId, handleId, panelsArray) {
644
+ var _panelsArray$index$id, _panelsArray$index, _panelsArray$id, _panelsArray;
624
645
  const handle = getResizeHandleElement(handleId);
625
646
  const handles = getResizeHandleElementsForGroup(groupId);
626
647
  const index = handle ? handles.indexOf(handle) : -1;
627
- const idBefore = panelsArray[index]?.id ?? null;
628
- const idAfter = panelsArray[index + 1]?.id ?? null;
648
+ const idBefore = (_panelsArray$index$id = (_panelsArray$index = panelsArray[index]) === null || _panelsArray$index === void 0 ? void 0 : _panelsArray$index.id) !== null && _panelsArray$index$id !== void 0 ? _panelsArray$index$id : null;
649
+ const idAfter = (_panelsArray$id = (_panelsArray = panelsArray[index + 1]) === null || _panelsArray === void 0 ? void 0 : _panelsArray.id) !== null && _panelsArray$id !== void 0 ? _panelsArray$id : null;
629
650
  return [idBefore, idAfter];
630
651
  }
631
652
 
@@ -713,11 +734,12 @@ function useWindowSplitterPanelGroupBehavior({
713
734
  const panelData = panelDataArray[index];
714
735
  const size = layout[index];
715
736
  if (size != null) {
737
+ var _getPercentageSizeFro;
716
738
  const groupSizePixels = getAvailableGroupSizePixels(groupId);
717
- const minSize = getPercentageSizeFromMixedSizes({
739
+ const minSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
718
740
  sizePercentage: panelData.constraints.minSizePercentage,
719
741
  sizePixels: panelData.constraints.minSizePixels
720
- }, groupSizePixels) ?? 0;
742
+ }, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
721
743
  let delta = 0;
722
744
  if (size.toPrecision(PRECISION) <= minSize.toPrecision(PRECISION)) {
723
745
  delta = direction === "horizontal" ? width : height;
@@ -922,10 +944,11 @@ function callPanelCallbacks(groupId, panelsArray, layout, panelIdToLastNotifiedM
922
944
  onResize(mixedSizes, lastNotifiedMixedSizes);
923
945
  }
924
946
  if (collapsible && (onCollapse || onExpand)) {
925
- const collapsedSize = getPercentageSizeFromMixedSizes({
947
+ var _getPercentageSizeFro;
948
+ const collapsedSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
926
949
  sizePercentage: constraints.collapsedSizePercentage,
927
950
  sizePixels: constraints.collapsedSizePixels
928
- }, groupSizePixels) ?? 0;
951
+ }, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
929
952
  const size = getPercentageSizeFromMixedSizes(mixedSizes, groupSizePixels);
930
953
  if (onExpand && (lastNotifiedMixedSizes == null || lastNotifiedMixedSizes.sizePercentage === collapsedSize) && size !== collapsedSize) {
931
954
  onExpand();
@@ -1091,8 +1114,9 @@ function loadSerializedPanelGroupState(autoSaveId, storage) {
1091
1114
  function loadPanelLayout(autoSaveId, panels, storage) {
1092
1115
  const state = loadSerializedPanelGroupState(autoSaveId, storage);
1093
1116
  if (state) {
1117
+ var _state$key;
1094
1118
  const key = getSerializationKey(panels);
1095
- return state[key] ?? null;
1119
+ return (_state$key = state[key]) !== null && _state$key !== void 0 ? _state$key : null;
1096
1120
  }
1097
1121
  return null;
1098
1122
  }
@@ -1385,6 +1409,10 @@ function PanelGroupWithForwardedRef({
1385
1409
  unsafeLayout = loadPanelLayout(autoSaveId, panelDataArray, storage);
1386
1410
  }
1387
1411
  const groupSizePixels = calculateAvailablePanelSizeInPixels(groupId);
1412
+ if (groupSizePixels <= 0) {
1413
+ // Wait until the group has rendered a non-zero size before computing layout.
1414
+ return;
1415
+ }
1388
1416
  if (unsafeLayout == null) {
1389
1417
  unsafeLayout = calculateUnsafeDefaultLayout({
1390
1418
  groupSizePixels,
@@ -1670,7 +1698,7 @@ function PanelGroupWithForwardedRef({
1670
1698
  } = committedValuesRef.current;
1671
1699
  const {
1672
1700
  initialLayout
1673
- } = dragState ?? {};
1701
+ } = dragState !== null && dragState !== void 0 ? dragState : {};
1674
1702
  const pivotIndices = determinePivotIndices(groupId, dragHandleId);
1675
1703
  let delta = calculateDeltaPercentage(event, groupId, dragHandleId, direction, dragState, {
1676
1704
  percentage: keyboardResizeByPercentage,
@@ -1690,7 +1718,7 @@ function PanelGroupWithForwardedRef({
1690
1718
  const nextLayout = adjustLayoutByDelta({
1691
1719
  delta,
1692
1720
  groupSizePixels,
1693
- layout: initialLayout ?? prevLayout,
1721
+ layout: initialLayout !== null && initialLayout !== void 0 ? initialLayout : prevLayout,
1694
1722
  panelConstraints,
1695
1723
  pivotIndices,
1696
1724
  trigger: isKeyDown(event) ? "keyboard" : "mouse-or-touch"
@@ -1833,9 +1861,8 @@ function PanelGroupWithForwardedRef({
1833
1861
  },
1834
1862
  // CSS selectors
1835
1863
  "data-panel-group": "",
1836
- // e2e test attributes
1837
- "data-panel-group-direction": direction ,
1838
- "data-panel-group-id": groupId
1864
+ "data-panel-group-direction": direction,
1865
+ "data-panel-group-id": groupId
1839
1866
  }));
1840
1867
  }
1841
1868
  const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwardedRef, {
@@ -1947,7 +1974,7 @@ function PanelResizeHandle({
1947
1974
  stopDragging
1948
1975
  } = panelGroupContext;
1949
1976
  const resizeHandleId = useUniqueId(idFromProps);
1950
- const isDragging = dragState?.dragHandleId === resizeHandleId;
1977
+ const isDragging = (dragState === null || dragState === void 0 ? void 0 : dragState.dragHandleId) === resizeHandleId;
1951
1978
  const [isFocused, setIsFocused] = useState(false);
1952
1979
  const [resizeHandler, setResizeHandler] = useState(null);
1953
1980
  const stopDraggingAndBlur = useCallback(() => {
@@ -2011,13 +2038,6 @@ function PanelResizeHandle({
2011
2038
  return createElement(Type, {
2012
2039
  children,
2013
2040
  className: classNameFromProps,
2014
- // CSS selectors
2015
- "data-resize-handle": "",
2016
- "data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
2017
- "data-panel-group-direction": direction,
2018
- "data-panel-group-id": groupId,
2019
- "data-panel-resize-handle-enabled": !disabled,
2020
- "data-panel-resize-handle-id": resizeHandleId,
2021
2041
  onBlur: () => setIsFocused(false),
2022
2042
  onFocus: () => setIsFocused(true),
2023
2043
  onMouseDown: event => {
@@ -2047,7 +2067,14 @@ function PanelResizeHandle({
2047
2067
  ...style,
2048
2068
  ...styleFromProps
2049
2069
  },
2050
- tabIndex: 0
2070
+ tabIndex: 0,
2071
+ // CSS selectors
2072
+ "data-panel-group-direction": direction,
2073
+ "data-panel-group-id": groupId,
2074
+ "data-resize-handle": "",
2075
+ "data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
2076
+ "data-panel-resize-handle-enabled": !disabled,
2077
+ "data-panel-resize-handle-id": resizeHandleId
2051
2078
  });
2052
2079
  }
2053
2080
  PanelResizeHandle.displayName = "PanelResizeHandle";
@@ -37,7 +37,7 @@ function useUniqueId(idFromParams = null) {
37
37
  if (idRef.current === null) {
38
38
  idRef.current = "" + counter++;
39
39
  }
40
- return idFromParams ?? idRef.current;
40
+ return idFromParams !== null && idFromParams !== void 0 ? idFromParams : idRef.current;
41
41
  }
42
42
 
43
43
  function PanelWithForwardedRef({
@@ -172,9 +172,9 @@ function PanelWithForwardedRef({
172
172
  },
173
173
  // CSS selectors
174
174
  "data-panel": "",
175
+ "data-panel-id": panelId,
175
176
  // e2e test attributes
176
177
  "data-panel-collapsible": collapsible || undefined ,
177
- "data-panel-id": panelId ,
178
178
  "data-panel-size": parseFloat("" + style.flexGrow).toFixed(1)
179
179
  });
180
180
  }
@@ -202,6 +202,16 @@ function convertPixelConstraintsToPercentages(panelConstraints, groupSizePixels)
202
202
  minSizePercentage = 0,
203
203
  minSizePixels
204
204
  } = panelConstraints;
205
+ const hasPixelConstraints = collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null;
206
+ if (hasPixelConstraints && groupSizePixels <= 0) {
207
+ console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
208
+ return {
209
+ collapsedSizePercentage: 0,
210
+ defaultSizePercentage,
211
+ maxSizePercentage: 0,
212
+ minSizePercentage: 0
213
+ };
214
+ }
205
215
  if (collapsedSizePixels != null) {
206
216
  collapsedSizePercentage = convertPixelsToPercentage(collapsedSizePixels, groupSizePixels);
207
217
  }
@@ -276,6 +286,16 @@ function resizePanel({
276
286
  panelIndex,
277
287
  size
278
288
  }) {
289
+ const hasPixelConstraints = panelConstraints.some(({
290
+ collapsedSizePixels,
291
+ defaultSizePixels,
292
+ minSizePixels,
293
+ maxSizePixels
294
+ }) => collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null);
295
+ if (hasPixelConstraints && groupSizePixels <= 0) {
296
+ console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
297
+ return 0;
298
+ }
279
299
  let {
280
300
  collapsible
281
301
  } = panelConstraints[panelIndex];
@@ -332,7 +352,6 @@ function adjustLayoutByDelta({
332
352
  } = panelConstraints[pivotIndex];
333
353
  const {
334
354
  collapsedSizePercentage,
335
- maxSizePercentage,
336
355
  minSizePercentage
337
356
  } = computePercentagePanelConstraints(panelConstraints, pivotIndex, groupSizePixels);
338
357
  const isCollapsed = collapsible && fuzzyNumbersEqual(initialSize, collapsedSizePercentage);
@@ -494,6 +513,7 @@ function calculateAriaValues({
494
513
 
495
514
  // A panel's effective min/max sizes also need to account for other panel's sizes.
496
515
  panelsArray.forEach((panelData, index) => {
516
+ var _getPercentageSizeFro, _getPercentageSizeFro2;
497
517
  const {
498
518
  constraints
499
519
  } = panelData;
@@ -503,14 +523,14 @@ function calculateAriaValues({
503
523
  minSizePercentage,
504
524
  minSizePixels
505
525
  } = constraints;
506
- const minSize = getPercentageSizeFromMixedSizes({
526
+ const minSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
507
527
  sizePercentage: minSizePercentage,
508
528
  sizePixels: minSizePixels
509
- }, groupSizePixels) ?? 0;
510
- const maxSize = getPercentageSizeFromMixedSizes({
529
+ }, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
530
+ const maxSize = (_getPercentageSizeFro2 = getPercentageSizeFromMixedSizes({
511
531
  sizePercentage: maxSizePercentage,
512
532
  sizePixels: maxSizePixels
513
- }, groupSizePixels) ?? 100;
533
+ }, groupSizePixels)) !== null && _getPercentageSizeFro2 !== void 0 ? _getPercentageSizeFro2 : 100;
514
534
  if (index === pivotIndices[0]) {
515
535
  currentMinSize = minSize;
516
536
  currentMaxSize = maxSize;
@@ -536,7 +556,7 @@ function getResizeHandleElementsForGroup(groupId) {
536
556
  function getResizeHandleElementIndex(groupId, id) {
537
557
  const handles = getResizeHandleElementsForGroup(groupId);
538
558
  const index = handles.findIndex(handle => handle.getAttribute("data-panel-resize-handle-id") === id);
539
- return index ?? null;
559
+ return index !== null && index !== void 0 ? index : null;
540
560
  }
541
561
 
542
562
  function determinePivotIndices(groupId, dragHandleId) {
@@ -545,7 +565,7 @@ function determinePivotIndices(groupId, dragHandleId) {
545
565
  }
546
566
 
547
567
  function getPanelGroupElement(id) {
548
- const element = document.querySelector(`[data-panel-group-id="${id}"]`);
568
+ const element = document.querySelector(`[data-panel-group][data-panel-group-id="${id}"]`);
549
569
  if (element) {
550
570
  return element;
551
571
  }
@@ -597,11 +617,12 @@ function getResizeHandleElement(id) {
597
617
  }
598
618
 
599
619
  function getResizeHandlePanelIds(groupId, handleId, panelsArray) {
620
+ var _panelsArray$index$id, _panelsArray$index, _panelsArray$id, _panelsArray;
600
621
  const handle = getResizeHandleElement(handleId);
601
622
  const handles = getResizeHandleElementsForGroup(groupId);
602
623
  const index = handle ? handles.indexOf(handle) : -1;
603
- const idBefore = panelsArray[index]?.id ?? null;
604
- const idAfter = panelsArray[index + 1]?.id ?? null;
624
+ const idBefore = (_panelsArray$index$id = (_panelsArray$index = panelsArray[index]) === null || _panelsArray$index === void 0 ? void 0 : _panelsArray$index.id) !== null && _panelsArray$index$id !== void 0 ? _panelsArray$index$id : null;
625
+ const idAfter = (_panelsArray$id = (_panelsArray = panelsArray[index + 1]) === null || _panelsArray === void 0 ? void 0 : _panelsArray.id) !== null && _panelsArray$id !== void 0 ? _panelsArray$id : null;
605
626
  return [idBefore, idAfter];
606
627
  }
607
628
 
@@ -689,11 +710,12 @@ function useWindowSplitterPanelGroupBehavior({
689
710
  const panelData = panelDataArray[index];
690
711
  const size = layout[index];
691
712
  if (size != null) {
713
+ var _getPercentageSizeFro;
692
714
  const groupSizePixels = getAvailableGroupSizePixels(groupId);
693
- const minSize = getPercentageSizeFromMixedSizes({
715
+ const minSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
694
716
  sizePercentage: panelData.constraints.minSizePercentage,
695
717
  sizePixels: panelData.constraints.minSizePixels
696
- }, groupSizePixels) ?? 0;
718
+ }, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
697
719
  let delta = 0;
698
720
  if (size.toPrecision(PRECISION) <= minSize.toPrecision(PRECISION)) {
699
721
  delta = direction === "horizontal" ? width : height;
@@ -898,10 +920,11 @@ function callPanelCallbacks(groupId, panelsArray, layout, panelIdToLastNotifiedM
898
920
  onResize(mixedSizes, lastNotifiedMixedSizes);
899
921
  }
900
922
  if (collapsible && (onCollapse || onExpand)) {
901
- const collapsedSize = getPercentageSizeFromMixedSizes({
923
+ var _getPercentageSizeFro;
924
+ const collapsedSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
902
925
  sizePercentage: constraints.collapsedSizePercentage,
903
926
  sizePixels: constraints.collapsedSizePixels
904
- }, groupSizePixels) ?? 0;
927
+ }, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
905
928
  const size = getPercentageSizeFromMixedSizes(mixedSizes, groupSizePixels);
906
929
  if (onExpand && (lastNotifiedMixedSizes == null || lastNotifiedMixedSizes.sizePercentage === collapsedSize) && size !== collapsedSize) {
907
930
  onExpand();
@@ -1067,8 +1090,9 @@ function loadSerializedPanelGroupState(autoSaveId, storage) {
1067
1090
  function loadPanelLayout(autoSaveId, panels, storage) {
1068
1091
  const state = loadSerializedPanelGroupState(autoSaveId, storage);
1069
1092
  if (state) {
1093
+ var _state$key;
1070
1094
  const key = getSerializationKey(panels);
1071
- return state[key] ?? null;
1095
+ return (_state$key = state[key]) !== null && _state$key !== void 0 ? _state$key : null;
1072
1096
  }
1073
1097
  return null;
1074
1098
  }
@@ -1361,6 +1385,10 @@ function PanelGroupWithForwardedRef({
1361
1385
  unsafeLayout = loadPanelLayout(autoSaveId, panelDataArray, storage);
1362
1386
  }
1363
1387
  const groupSizePixels = calculateAvailablePanelSizeInPixels(groupId);
1388
+ if (groupSizePixels <= 0) {
1389
+ // Wait until the group has rendered a non-zero size before computing layout.
1390
+ return;
1391
+ }
1364
1392
  if (unsafeLayout == null) {
1365
1393
  unsafeLayout = calculateUnsafeDefaultLayout({
1366
1394
  groupSizePixels,
@@ -1646,7 +1674,7 @@ function PanelGroupWithForwardedRef({
1646
1674
  } = committedValuesRef.current;
1647
1675
  const {
1648
1676
  initialLayout
1649
- } = dragState ?? {};
1677
+ } = dragState !== null && dragState !== void 0 ? dragState : {};
1650
1678
  const pivotIndices = determinePivotIndices(groupId, dragHandleId);
1651
1679
  let delta = calculateDeltaPercentage(event, groupId, dragHandleId, direction, dragState, {
1652
1680
  percentage: keyboardResizeByPercentage,
@@ -1666,7 +1694,7 @@ function PanelGroupWithForwardedRef({
1666
1694
  const nextLayout = adjustLayoutByDelta({
1667
1695
  delta,
1668
1696
  groupSizePixels,
1669
- layout: initialLayout ?? prevLayout,
1697
+ layout: initialLayout !== null && initialLayout !== void 0 ? initialLayout : prevLayout,
1670
1698
  panelConstraints,
1671
1699
  pivotIndices,
1672
1700
  trigger: isKeyDown(event) ? "keyboard" : "mouse-or-touch"
@@ -1809,9 +1837,8 @@ function PanelGroupWithForwardedRef({
1809
1837
  },
1810
1838
  // CSS selectors
1811
1839
  "data-panel-group": "",
1812
- // e2e test attributes
1813
- "data-panel-group-direction": direction ,
1814
- "data-panel-group-id": groupId
1840
+ "data-panel-group-direction": direction,
1841
+ "data-panel-group-id": groupId
1815
1842
  }));
1816
1843
  }
1817
1844
  const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwardedRef, {
@@ -1923,7 +1950,7 @@ function PanelResizeHandle({
1923
1950
  stopDragging
1924
1951
  } = panelGroupContext;
1925
1952
  const resizeHandleId = useUniqueId(idFromProps);
1926
- const isDragging = dragState?.dragHandleId === resizeHandleId;
1953
+ const isDragging = (dragState === null || dragState === void 0 ? void 0 : dragState.dragHandleId) === resizeHandleId;
1927
1954
  const [isFocused, setIsFocused] = useState(false);
1928
1955
  const [resizeHandler, setResizeHandler] = useState(null);
1929
1956
  const stopDraggingAndBlur = useCallback(() => {
@@ -1987,13 +2014,6 @@ function PanelResizeHandle({
1987
2014
  return createElement(Type, {
1988
2015
  children,
1989
2016
  className: classNameFromProps,
1990
- // CSS selectors
1991
- "data-resize-handle": "",
1992
- "data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
1993
- "data-panel-group-direction": direction,
1994
- "data-panel-group-id": groupId,
1995
- "data-panel-resize-handle-enabled": !disabled,
1996
- "data-panel-resize-handle-id": resizeHandleId,
1997
2017
  onBlur: () => setIsFocused(false),
1998
2018
  onFocus: () => setIsFocused(true),
1999
2019
  onMouseDown: event => {
@@ -2023,7 +2043,14 @@ function PanelResizeHandle({
2023
2043
  ...style,
2024
2044
  ...styleFromProps
2025
2045
  },
2026
- tabIndex: 0
2046
+ tabIndex: 0,
2047
+ // CSS selectors
2048
+ "data-panel-group-direction": direction,
2049
+ "data-panel-group-id": groupId,
2050
+ "data-resize-handle": "",
2051
+ "data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
2052
+ "data-panel-resize-handle-enabled": !disabled,
2053
+ "data-panel-resize-handle-id": resizeHandleId
2027
2054
  });
2028
2055
  }
2029
2056
  PanelResizeHandle.displayName = "PanelResizeHandle";
@@ -57,7 +57,7 @@ function useUniqueId(idFromParams = null) {
57
57
  if (idRef.current === null) {
58
58
  idRef.current = "" + counter++;
59
59
  }
60
- return idFromParams ?? idRef.current;
60
+ return idFromParams !== null && idFromParams !== void 0 ? idFromParams : idRef.current;
61
61
  }
62
62
 
63
63
  function PanelWithForwardedRef({
@@ -164,9 +164,9 @@ function PanelWithForwardedRef({
164
164
  },
165
165
  // CSS selectors
166
166
  "data-panel": "",
167
+ "data-panel-id": panelId,
167
168
  // e2e test attributes
168
169
  "data-panel-collapsible": collapsible || undefined ,
169
- "data-panel-id": panelId ,
170
170
  "data-panel-size": parseFloat("" + style.flexGrow).toFixed(1)
171
171
  });
172
172
  }
@@ -194,6 +194,16 @@ function convertPixelConstraintsToPercentages(panelConstraints, groupSizePixels)
194
194
  minSizePercentage = 0,
195
195
  minSizePixels
196
196
  } = panelConstraints;
197
+ const hasPixelConstraints = collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null;
198
+ if (hasPixelConstraints && groupSizePixels <= 0) {
199
+ console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
200
+ return {
201
+ collapsedSizePercentage: 0,
202
+ defaultSizePercentage,
203
+ maxSizePercentage: 0,
204
+ minSizePercentage: 0
205
+ };
206
+ }
197
207
  if (collapsedSizePixels != null) {
198
208
  collapsedSizePercentage = convertPixelsToPercentage(collapsedSizePixels, groupSizePixels);
199
209
  }
@@ -268,6 +278,16 @@ function resizePanel({
268
278
  panelIndex,
269
279
  size
270
280
  }) {
281
+ const hasPixelConstraints = panelConstraints.some(({
282
+ collapsedSizePixels,
283
+ defaultSizePixels,
284
+ minSizePixels,
285
+ maxSizePixels
286
+ }) => collapsedSizePixels != null || defaultSizePixels != null || minSizePixels != null || maxSizePixels != null);
287
+ if (hasPixelConstraints && groupSizePixels <= 0) {
288
+ console.warn(`WARNING: Invalid group size: ${groupSizePixels}px`);
289
+ return 0;
290
+ }
271
291
  let {
272
292
  collapsible
273
293
  } = panelConstraints[panelIndex];
@@ -324,7 +344,6 @@ function adjustLayoutByDelta({
324
344
  } = panelConstraints[pivotIndex];
325
345
  const {
326
346
  collapsedSizePercentage,
327
- maxSizePercentage,
328
347
  minSizePercentage
329
348
  } = computePercentagePanelConstraints(panelConstraints, pivotIndex, groupSizePixels);
330
349
  const isCollapsed = collapsible && fuzzyNumbersEqual(initialSize, collapsedSizePercentage);
@@ -480,7 +499,7 @@ function getResizeHandleElementsForGroup(groupId) {
480
499
  function getResizeHandleElementIndex(groupId, id) {
481
500
  const handles = getResizeHandleElementsForGroup(groupId);
482
501
  const index = handles.findIndex(handle => handle.getAttribute("data-panel-resize-handle-id") === id);
483
- return index ?? null;
502
+ return index !== null && index !== void 0 ? index : null;
484
503
  }
485
504
 
486
505
  function determinePivotIndices(groupId, dragHandleId) {
@@ -489,7 +508,7 @@ function determinePivotIndices(groupId, dragHandleId) {
489
508
  }
490
509
 
491
510
  function getPanelGroupElement(id) {
492
- const element = document.querySelector(`[data-panel-group-id="${id}"]`);
511
+ const element = document.querySelector(`[data-panel-group][data-panel-group-id="${id}"]`);
493
512
  if (element) {
494
513
  return element;
495
514
  }
@@ -541,11 +560,12 @@ function getResizeHandleElement(id) {
541
560
  }
542
561
 
543
562
  function getResizeHandlePanelIds(groupId, handleId, panelsArray) {
563
+ var _panelsArray$index$id, _panelsArray$index, _panelsArray$id, _panelsArray;
544
564
  const handle = getResizeHandleElement(handleId);
545
565
  const handles = getResizeHandleElementsForGroup(groupId);
546
566
  const index = handle ? handles.indexOf(handle) : -1;
547
- const idBefore = panelsArray[index]?.id ?? null;
548
- const idAfter = panelsArray[index + 1]?.id ?? null;
567
+ const idBefore = (_panelsArray$index$id = (_panelsArray$index = panelsArray[index]) === null || _panelsArray$index === void 0 ? void 0 : _panelsArray$index.id) !== null && _panelsArray$index$id !== void 0 ? _panelsArray$index$id : null;
568
+ const idAfter = (_panelsArray$id = (_panelsArray = panelsArray[index + 1]) === null || _panelsArray === void 0 ? void 0 : _panelsArray.id) !== null && _panelsArray$id !== void 0 ? _panelsArray$id : null;
549
569
  return [idBefore, idAfter];
550
570
  }
551
571
 
@@ -592,11 +612,12 @@ function useWindowSplitterPanelGroupBehavior({
592
612
  const panelData = panelDataArray[index];
593
613
  const size = layout[index];
594
614
  if (size != null) {
615
+ var _getPercentageSizeFro;
595
616
  const groupSizePixels = getAvailableGroupSizePixels(groupId);
596
- const minSize = getPercentageSizeFromMixedSizes({
617
+ const minSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
597
618
  sizePercentage: panelData.constraints.minSizePercentage,
598
619
  sizePixels: panelData.constraints.minSizePixels
599
- }, groupSizePixels) ?? 0;
620
+ }, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
600
621
  let delta = 0;
601
622
  if (size.toPrecision(PRECISION) <= minSize.toPrecision(PRECISION)) {
602
623
  delta = direction === "horizontal" ? width : height;
@@ -763,10 +784,11 @@ function callPanelCallbacks(groupId, panelsArray, layout, panelIdToLastNotifiedM
763
784
  onResize(mixedSizes, lastNotifiedMixedSizes);
764
785
  }
765
786
  if (collapsible && (onCollapse || onExpand)) {
766
- const collapsedSize = getPercentageSizeFromMixedSizes({
787
+ var _getPercentageSizeFro;
788
+ const collapsedSize = (_getPercentageSizeFro = getPercentageSizeFromMixedSizes({
767
789
  sizePercentage: constraints.collapsedSizePercentage,
768
790
  sizePixels: constraints.collapsedSizePixels
769
- }, groupSizePixels) ?? 0;
791
+ }, groupSizePixels)) !== null && _getPercentageSizeFro !== void 0 ? _getPercentageSizeFro : 0;
770
792
  const size = getPercentageSizeFromMixedSizes(mixedSizes, groupSizePixels);
771
793
  if (onExpand && (lastNotifiedMixedSizes == null || lastNotifiedMixedSizes.sizePercentage === collapsedSize) && size !== collapsedSize) {
772
794
  onExpand();
@@ -1403,7 +1425,7 @@ function PanelGroupWithForwardedRef({
1403
1425
  } = committedValuesRef.current;
1404
1426
  const {
1405
1427
  initialLayout
1406
- } = dragState ?? {};
1428
+ } = dragState !== null && dragState !== void 0 ? dragState : {};
1407
1429
  const pivotIndices = determinePivotIndices(groupId, dragHandleId);
1408
1430
  let delta = calculateDeltaPercentage(event, groupId, dragHandleId, direction, dragState, {
1409
1431
  percentage: keyboardResizeByPercentage,
@@ -1423,7 +1445,7 @@ function PanelGroupWithForwardedRef({
1423
1445
  const nextLayout = adjustLayoutByDelta({
1424
1446
  delta,
1425
1447
  groupSizePixels,
1426
- layout: initialLayout ?? prevLayout,
1448
+ layout: initialLayout !== null && initialLayout !== void 0 ? initialLayout : prevLayout,
1427
1449
  panelConstraints,
1428
1450
  pivotIndices,
1429
1451
  trigger: isKeyDown(event) ? "keyboard" : "mouse-or-touch"
@@ -1566,9 +1588,8 @@ function PanelGroupWithForwardedRef({
1566
1588
  },
1567
1589
  // CSS selectors
1568
1590
  "data-panel-group": "",
1569
- // e2e test attributes
1570
- "data-panel-group-direction": direction ,
1571
- "data-panel-group-id": groupId
1591
+ "data-panel-group-direction": direction,
1592
+ "data-panel-group-id": groupId
1572
1593
  }));
1573
1594
  }
1574
1595
  const PanelGroup = forwardRef((props, ref) => createElement(PanelGroupWithForwardedRef, {
@@ -1680,7 +1701,7 @@ function PanelResizeHandle({
1680
1701
  stopDragging
1681
1702
  } = panelGroupContext;
1682
1703
  const resizeHandleId = useUniqueId(idFromProps);
1683
- const isDragging = dragState?.dragHandleId === resizeHandleId;
1704
+ const isDragging = (dragState === null || dragState === void 0 ? void 0 : dragState.dragHandleId) === resizeHandleId;
1684
1705
  const [isFocused, setIsFocused] = useState(false);
1685
1706
  const [resizeHandler, setResizeHandler] = useState(null);
1686
1707
  const stopDraggingAndBlur = useCallback(() => {
@@ -1744,13 +1765,6 @@ function PanelResizeHandle({
1744
1765
  return createElement(Type, {
1745
1766
  children,
1746
1767
  className: classNameFromProps,
1747
- // CSS selectors
1748
- "data-resize-handle": "",
1749
- "data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
1750
- "data-panel-group-direction": direction,
1751
- "data-panel-group-id": groupId,
1752
- "data-panel-resize-handle-enabled": !disabled,
1753
- "data-panel-resize-handle-id": resizeHandleId,
1754
1768
  onBlur: () => setIsFocused(false),
1755
1769
  onFocus: () => setIsFocused(true),
1756
1770
  onMouseDown: event => {
@@ -1780,7 +1794,14 @@ function PanelResizeHandle({
1780
1794
  ...style,
1781
1795
  ...styleFromProps
1782
1796
  },
1783
- tabIndex: 0
1797
+ tabIndex: 0,
1798
+ // CSS selectors
1799
+ "data-panel-group-direction": direction,
1800
+ "data-panel-group-id": groupId,
1801
+ "data-resize-handle": "",
1802
+ "data-resize-handle-active": isDragging ? "pointer" : isFocused ? "keyboard" : undefined,
1803
+ "data-panel-resize-handle-enabled": !disabled,
1804
+ "data-panel-resize-handle-id": resizeHandleId
1784
1805
  });
1785
1806
  }
1786
1807
  PanelResizeHandle.displayName = "PanelResizeHandle";