@zag-js/splitter 1.7.0 → 1.8.1

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/dist/index.js CHANGED
@@ -51,7 +51,7 @@ function calculateAriaValues({
51
51
  let totalMinSize = 0;
52
52
  let totalMaxSize = 0;
53
53
  const firstIndex = pivotIndices[0];
54
- utils.ensure(firstIndex, "No pivot index found");
54
+ utils.ensure(firstIndex, () => "No pivot index found");
55
55
  panels.forEach((panel, index) => {
56
56
  const { maxSize = 100, minSize = 0 } = panel;
57
57
  if (index === firstIndex) {
@@ -117,7 +117,7 @@ function fuzzySizeEqual(actual, expected, fractionDigits) {
117
117
  }
118
118
  function getPanelById(panels, id) {
119
119
  const panel = panels.find((panel2) => panel2.id === id);
120
- utils.ensure(panel, `Panel data not found for id "${id}"`);
120
+ utils.ensure(panel, () => `Panel data not found for id "${id}"`);
121
121
  return panel;
122
122
  }
123
123
  function findPanelDataIndex(panels, panel) {
@@ -193,7 +193,7 @@ function getUnsafeDefaultSize({ panels, size: sizes }) {
193
193
  let remainingSize = 100;
194
194
  for (let index = 0; index < panels.length; index++) {
195
195
  const panel = panels[index];
196
- utils.ensure(panel, `Panel data not found for index ${index}`);
196
+ utils.ensure(panel, () => `Panel data not found for index ${index}`);
197
197
  const defaultSize = sizes[index];
198
198
  if (defaultSize != null) {
199
199
  numPanelsWithSizes++;
@@ -203,7 +203,7 @@ function getUnsafeDefaultSize({ panels, size: sizes }) {
203
203
  }
204
204
  for (let index = 0; index < panels.length; index++) {
205
205
  const panel = panels[index];
206
- utils.ensure(panel, `Panel data not found for index ${index}`);
206
+ utils.ensure(panel, () => `Panel data not found for index ${index}`);
207
207
  const defaultSize = sizes[index];
208
208
  if (defaultSize != null) {
209
209
  continue;
@@ -269,7 +269,7 @@ function connect(service, normalize) {
269
269
  const size = context.get("size");
270
270
  const panelData = getPanelById(panels, id);
271
271
  const { panelSize } = panelDataHelper(panels, panelData, size);
272
- utils.ensure(panelSize, `Panel size not found for panel "${panelData.id}"`);
272
+ utils.ensure(panelSize, () => `Panel size not found for panel "${panelData.id}"`);
273
273
  return panelSize;
274
274
  },
275
275
  isPanelCollapsed(id) {
@@ -277,7 +277,7 @@ function connect(service, normalize) {
277
277
  const size = context.get("size");
278
278
  const panelData = getPanelById(panels, id);
279
279
  const { collapsedSize = 0, collapsible, panelSize } = panelDataHelper(panels, panelData, size);
280
- utils.ensure(panelSize, `Panel size not found for panel "${panelData.id}"`);
280
+ utils.ensure(panelSize, () => `Panel size not found for panel "${panelData.id}"`);
281
281
  return collapsible === true && fuzzyNumbersEqual(panelSize, collapsedSize);
282
282
  },
283
283
  isPanelExpanded(id) {
@@ -285,7 +285,7 @@ function connect(service, normalize) {
285
285
  const size = context.get("size");
286
286
  const panelData = getPanelById(panels, id);
287
287
  const { collapsedSize = 0, collapsible, panelSize } = panelDataHelper(panels, panelData, size);
288
- utils.ensure(panelSize, `Panel size not found for panel "${panelData.id}"`);
288
+ utils.ensure(panelSize, () => `Panel size not found for panel "${panelData.id}"`);
289
289
  return !collapsible || fuzzyCompareNumbers(panelSize, collapsedSize) > 0;
290
290
  },
291
291
  getLayout() {
@@ -437,7 +437,7 @@ function connect(service, normalize) {
437
437
  }
438
438
  function resizePanel({ panels, index, size }) {
439
439
  const panel = panels[index];
440
- utils.ensure(panel, `Panel data not found for index ${index}`);
440
+ utils.ensure(panel, () => `Panel data not found for index ${index}`);
441
441
  let { collapsedSize = 0, collapsible, maxSize = 100, minSize = 0 } = panel;
442
442
  if (fuzzyCompareNumbers(size, minSize) < 0) {
443
443
  if (collapsible) {
@@ -464,19 +464,19 @@ function resizeByDelta(props2) {
464
464
  }
465
465
  const nextSize = [...initialSize];
466
466
  const [firstPivotIndex, secondPivotIndex] = pivotIndices;
467
- utils.ensure(firstPivotIndex, "Invalid first pivot index");
468
- utils.ensure(secondPivotIndex, "Invalid second pivot index");
467
+ utils.ensure(firstPivotIndex, () => "Invalid first pivot index");
468
+ utils.ensure(secondPivotIndex, () => "Invalid second pivot index");
469
469
  let deltaApplied = 0;
470
470
  {
471
471
  if (trigger === "keyboard") {
472
472
  {
473
473
  const index = delta < 0 ? secondPivotIndex : firstPivotIndex;
474
474
  const panel = panels[index];
475
- utils.ensure(panel, `Panel data not found for index ${index}`);
475
+ utils.ensure(panel, () => `Panel data not found for index ${index}`);
476
476
  const { collapsedSize = 0, collapsible, minSize = 0 } = panel;
477
477
  if (collapsible) {
478
478
  const prevSize2 = initialSize[index];
479
- utils.ensure(prevSize2, `Previous size not found for panel index ${index}`);
479
+ utils.ensure(prevSize2, () => `Previous size not found for panel index ${index}`);
480
480
  if (fuzzyNumbersEqual(prevSize2, collapsedSize)) {
481
481
  const localDelta = minSize - prevSize2;
482
482
  if (fuzzyCompareNumbers(localDelta, Math.abs(delta)) > 0) {
@@ -488,11 +488,11 @@ function resizeByDelta(props2) {
488
488
  {
489
489
  const index = delta < 0 ? firstPivotIndex : secondPivotIndex;
490
490
  const panel = panels[index];
491
- utils.ensure(panel, `No panel data found for index ${index}`);
491
+ utils.ensure(panel, () => `No panel data found for index ${index}`);
492
492
  const { collapsedSize = 0, collapsible, minSize = 0 } = panel;
493
493
  if (collapsible) {
494
494
  const prevSize2 = initialSize[index];
495
- utils.ensure(prevSize2, `Previous size not found for panel index ${index}`);
495
+ utils.ensure(prevSize2, () => `Previous size not found for panel index ${index}`);
496
496
  if (fuzzyNumbersEqual(prevSize2, minSize)) {
497
497
  const localDelta = prevSize2 - collapsedSize;
498
498
  if (fuzzyCompareNumbers(localDelta, Math.abs(delta)) > 0) {
@@ -509,7 +509,7 @@ function resizeByDelta(props2) {
509
509
  let maxAvailableDelta = 0;
510
510
  while (true) {
511
511
  const prevSize2 = initialSize[index];
512
- utils.ensure(prevSize2, `Previous size not found for panel index ${index}`);
512
+ utils.ensure(prevSize2, () => `Previous size not found for panel index ${index}`);
513
513
  const maxSafeSize = resizePanel({
514
514
  panels,
515
515
  index,
@@ -531,7 +531,7 @@ function resizeByDelta(props2) {
531
531
  while (index >= 0 && index < panels.length) {
532
532
  const deltaRemaining = Math.abs(delta) - Math.abs(deltaApplied);
533
533
  const prevSize2 = initialSize[index];
534
- utils.ensure(prevSize2, `Previous size not found for panel index ${index}`);
534
+ utils.ensure(prevSize2, () => `Previous size not found for panel index ${index}`);
535
535
  const unsafeSize = prevSize2 - deltaRemaining;
536
536
  const safeSize = resizePanel({ panels, index, size: unsafeSize });
537
537
  if (!fuzzyNumbersEqual(prevSize2, safeSize)) {
@@ -556,7 +556,7 @@ function resizeByDelta(props2) {
556
556
  {
557
557
  const pivotIndex = delta < 0 ? secondPivotIndex : firstPivotIndex;
558
558
  const prevSize2 = initialSize[pivotIndex];
559
- utils.ensure(prevSize2, `Previous size not found for panel index ${pivotIndex}`);
559
+ utils.ensure(prevSize2, () => `Previous size not found for panel index ${pivotIndex}`);
560
560
  const unsafeSize = prevSize2 + deltaApplied;
561
561
  const safeSize = resizePanel({ panels, index: pivotIndex, size: unsafeSize });
562
562
  nextSize[pivotIndex] = safeSize;
@@ -566,7 +566,7 @@ function resizeByDelta(props2) {
566
566
  let index = pivotIndex2;
567
567
  while (index >= 0 && index < panels.length) {
568
568
  const prevSize3 = nextSize[index];
569
- utils.ensure(prevSize3, `Previous size not found for panel index ${index}`);
569
+ utils.ensure(prevSize3, () => `Previous size not found for panel index ${index}`);
570
570
  const unsafeSize2 = prevSize3 + deltaRemaining;
571
571
  const safeSize2 = resizePanel({ panels, index, size: unsafeSize2 });
572
572
  if (!fuzzyNumbersEqual(prevSize3, safeSize2)) {
@@ -598,7 +598,7 @@ function validateSizes({ size: prevSize, panels }) {
598
598
  } else if (!fuzzyNumbersEqual(nextSizeTotalSize, 100) && nextSize.length > 0) {
599
599
  for (let index = 0; index < panels.length; index++) {
600
600
  const unsafeSize = nextSize[index];
601
- utils.ensure(unsafeSize, `No size data found for index ${index}`);
601
+ utils.ensure(unsafeSize, () => `No size data found for index ${index}`);
602
602
  const safeSize = 100 / nextSizeTotalSize * unsafeSize;
603
603
  nextSize[index] = safeSize;
604
604
  }
@@ -606,7 +606,7 @@ function validateSizes({ size: prevSize, panels }) {
606
606
  let remainingSize = 0;
607
607
  for (let index = 0; index < panels.length; index++) {
608
608
  const unsafeSize = nextSize[index];
609
- utils.ensure(unsafeSize, `No size data found for index ${index}`);
609
+ utils.ensure(unsafeSize, () => `No size data found for index ${index}`);
610
610
  const safeSize = resizePanel({ panels, index, size: unsafeSize });
611
611
  if (unsafeSize != safeSize) {
612
612
  remainingSize += unsafeSize - safeSize;
@@ -616,7 +616,7 @@ function validateSizes({ size: prevSize, panels }) {
616
616
  if (!fuzzyNumbersEqual(remainingSize, 0)) {
617
617
  for (let index = 0; index < panels.length; index++) {
618
618
  const prevSize2 = nextSize[index];
619
- utils.ensure(prevSize2, `No size data found for index ${index}`);
619
+ utils.ensure(prevSize2, () => `No size data found for index ${index}`);
620
620
  const unsafeSize = prevSize2 + remainingSize;
621
621
  const safeSize = resizePanel({ panels, index, size: unsafeSize });
622
622
  if (prevSize2 !== safeSize) {
@@ -848,7 +848,7 @@ var machine = core.createMachine({
848
848
  const panelGroupEl = getRootEl(scope);
849
849
  if (!panelGroupEl) return;
850
850
  const handleElement = getResizeTriggerEl(scope, resizeTriggerId);
851
- utils.ensure(handleElement, `Drag handle element not found for id "${resizeTriggerId}"`);
851
+ utils.ensure(handleElement, () => `Drag handle element not found for id "${resizeTriggerId}"`);
852
852
  const initialCursorPosition = orientation === "horizontal" ? event.point.x : event.point.y;
853
853
  context.set("dragState", {
854
854
  resizeTriggerId: event.id,
@@ -873,10 +873,10 @@ var machine = core.createMachine({
873
873
  const prevSize = context.get("size");
874
874
  const panels = prop("panels");
875
875
  const panel = panels.find((panel2) => panel2.id === event.id);
876
- utils.ensure(panel, `Panel data not found for id "${event.id}"`);
876
+ utils.ensure(panel, () => `Panel data not found for id "${event.id}"`);
877
877
  if (panel.collapsible) {
878
878
  const { collapsedSize = 0, panelSize, pivotIndices } = panelDataHelper(panels, panel, prevSize);
879
- utils.ensure(panelSize, `Panel size not found for panel "${panel.id}"`);
879
+ utils.ensure(panelSize, () => `Panel size not found for panel "${panel.id}"`);
880
880
  if (!fuzzyNumbersEqual(panelSize, collapsedSize)) {
881
881
  refs.get("panelSizeBeforeCollapse").set(panel.id, panelSize);
882
882
  const isLastPanel = findPanelDataIndex(panels, panel) === panels.length - 1;
@@ -900,7 +900,7 @@ var machine = core.createMachine({
900
900
  const panels = prop("panels");
901
901
  const prevSize = context.get("size");
902
902
  const panel = panels.find((panel2) => panel2.id === event.id);
903
- utils.ensure(panel, `Panel data not found for id "${event.id}"`);
903
+ utils.ensure(panel, () => `Panel data not found for id "${event.id}"`);
904
904
  if (panel.collapsible) {
905
905
  const {
906
906
  collapsedSize = 0,
@@ -935,7 +935,7 @@ var machine = core.createMachine({
935
935
  const panel = getPanelById(panels, event.id);
936
936
  const unsafePanelSize = event.size;
937
937
  const { panelSize, pivotIndices } = panelDataHelper(panels, panel, prevSize);
938
- utils.ensure(panelSize, `Panel size not found for panel "${panel.id}"`);
938
+ utils.ensure(panelSize, () => `Panel size not found for panel "${panel.id}"`);
939
939
  const isLastPanel = findPanelDataIndex(panels, panel) === panels.length - 1;
940
940
  const delta = isLastPanel ? panelSize - unsafePanelSize : unsafePanelSize - panelSize;
941
941
  const nextSize = resizeByDelta({
@@ -957,7 +957,7 @@ var machine = core.createMachine({
957
957
  const { resizeTriggerId, initialSize, initialCursorPosition } = dragState;
958
958
  const panels = prop("panels");
959
959
  const panelGroupElement = getRootEl(scope);
960
- utils.ensure(panelGroupElement, `Panel group element not found`);
960
+ utils.ensure(panelGroupElement, () => `Panel group element not found`);
961
961
  const pivotIndices = resizeTriggerId.split(":").map((id) => panels.findIndex((panel) => panel.id === id));
962
962
  const horizontal = prop("orientation") === "horizontal";
963
963
  const cursorPosition = horizontal ? event.point.x : event.point.y;
@@ -1020,7 +1020,7 @@ var machine = core.createMachine({
1020
1020
  const index = panelDataArray.findIndex((panelData2) => panelData2.id === idBefore);
1021
1021
  if (index === -1) return;
1022
1022
  const panelData = panelDataArray[index];
1023
- utils.ensure(panelData, `No panel data found for index ${index}`);
1023
+ utils.ensure(panelData, () => `No panel data found for index ${index}`);
1024
1024
  const size = sizes[index];
1025
1025
  const { collapsedSize = 0, collapsible, minSize = 0 } = panelData;
1026
1026
  if (size != null && collapsible) {
@@ -1076,7 +1076,7 @@ function setSize(params, sizes) {
1076
1076
  context.set("size", sizes);
1077
1077
  sizes.forEach((size, index) => {
1078
1078
  const panelData = panelsArray[index];
1079
- utils.ensure(panelData, `Panel data not found for index ${index}`);
1079
+ utils.ensure(panelData, () => `Panel data not found for index ${index}`);
1080
1080
  const { collapsedSize = 0, collapsible, id: panelId } = panelData;
1081
1081
  const lastNotifiedSize = panelIdToLastNotifiedSizeMap.get(panelId);
1082
1082
  if (lastNotifiedSize == null || size !== lastNotifiedSize) {
package/dist/index.mjs CHANGED
@@ -49,7 +49,7 @@ function calculateAriaValues({
49
49
  let totalMinSize = 0;
50
50
  let totalMaxSize = 0;
51
51
  const firstIndex = pivotIndices[0];
52
- ensure(firstIndex, "No pivot index found");
52
+ ensure(firstIndex, () => "No pivot index found");
53
53
  panels.forEach((panel, index) => {
54
54
  const { maxSize = 100, minSize = 0 } = panel;
55
55
  if (index === firstIndex) {
@@ -115,7 +115,7 @@ function fuzzySizeEqual(actual, expected, fractionDigits) {
115
115
  }
116
116
  function getPanelById(panels, id) {
117
117
  const panel = panels.find((panel2) => panel2.id === id);
118
- ensure(panel, `Panel data not found for id "${id}"`);
118
+ ensure(panel, () => `Panel data not found for id "${id}"`);
119
119
  return panel;
120
120
  }
121
121
  function findPanelDataIndex(panels, panel) {
@@ -191,7 +191,7 @@ function getUnsafeDefaultSize({ panels, size: sizes }) {
191
191
  let remainingSize = 100;
192
192
  for (let index = 0; index < panels.length; index++) {
193
193
  const panel = panels[index];
194
- ensure(panel, `Panel data not found for index ${index}`);
194
+ ensure(panel, () => `Panel data not found for index ${index}`);
195
195
  const defaultSize = sizes[index];
196
196
  if (defaultSize != null) {
197
197
  numPanelsWithSizes++;
@@ -201,7 +201,7 @@ function getUnsafeDefaultSize({ panels, size: sizes }) {
201
201
  }
202
202
  for (let index = 0; index < panels.length; index++) {
203
203
  const panel = panels[index];
204
- ensure(panel, `Panel data not found for index ${index}`);
204
+ ensure(panel, () => `Panel data not found for index ${index}`);
205
205
  const defaultSize = sizes[index];
206
206
  if (defaultSize != null) {
207
207
  continue;
@@ -267,7 +267,7 @@ function connect(service, normalize) {
267
267
  const size = context.get("size");
268
268
  const panelData = getPanelById(panels, id);
269
269
  const { panelSize } = panelDataHelper(panels, panelData, size);
270
- ensure(panelSize, `Panel size not found for panel "${panelData.id}"`);
270
+ ensure(panelSize, () => `Panel size not found for panel "${panelData.id}"`);
271
271
  return panelSize;
272
272
  },
273
273
  isPanelCollapsed(id) {
@@ -275,7 +275,7 @@ function connect(service, normalize) {
275
275
  const size = context.get("size");
276
276
  const panelData = getPanelById(panels, id);
277
277
  const { collapsedSize = 0, collapsible, panelSize } = panelDataHelper(panels, panelData, size);
278
- ensure(panelSize, `Panel size not found for panel "${panelData.id}"`);
278
+ ensure(panelSize, () => `Panel size not found for panel "${panelData.id}"`);
279
279
  return collapsible === true && fuzzyNumbersEqual(panelSize, collapsedSize);
280
280
  },
281
281
  isPanelExpanded(id) {
@@ -283,7 +283,7 @@ function connect(service, normalize) {
283
283
  const size = context.get("size");
284
284
  const panelData = getPanelById(panels, id);
285
285
  const { collapsedSize = 0, collapsible, panelSize } = panelDataHelper(panels, panelData, size);
286
- ensure(panelSize, `Panel size not found for panel "${panelData.id}"`);
286
+ ensure(panelSize, () => `Panel size not found for panel "${panelData.id}"`);
287
287
  return !collapsible || fuzzyCompareNumbers(panelSize, collapsedSize) > 0;
288
288
  },
289
289
  getLayout() {
@@ -435,7 +435,7 @@ function connect(service, normalize) {
435
435
  }
436
436
  function resizePanel({ panels, index, size }) {
437
437
  const panel = panels[index];
438
- ensure(panel, `Panel data not found for index ${index}`);
438
+ ensure(panel, () => `Panel data not found for index ${index}`);
439
439
  let { collapsedSize = 0, collapsible, maxSize = 100, minSize = 0 } = panel;
440
440
  if (fuzzyCompareNumbers(size, minSize) < 0) {
441
441
  if (collapsible) {
@@ -462,19 +462,19 @@ function resizeByDelta(props2) {
462
462
  }
463
463
  const nextSize = [...initialSize];
464
464
  const [firstPivotIndex, secondPivotIndex] = pivotIndices;
465
- ensure(firstPivotIndex, "Invalid first pivot index");
466
- ensure(secondPivotIndex, "Invalid second pivot index");
465
+ ensure(firstPivotIndex, () => "Invalid first pivot index");
466
+ ensure(secondPivotIndex, () => "Invalid second pivot index");
467
467
  let deltaApplied = 0;
468
468
  {
469
469
  if (trigger === "keyboard") {
470
470
  {
471
471
  const index = delta < 0 ? secondPivotIndex : firstPivotIndex;
472
472
  const panel = panels[index];
473
- ensure(panel, `Panel data not found for index ${index}`);
473
+ ensure(panel, () => `Panel data not found for index ${index}`);
474
474
  const { collapsedSize = 0, collapsible, minSize = 0 } = panel;
475
475
  if (collapsible) {
476
476
  const prevSize2 = initialSize[index];
477
- ensure(prevSize2, `Previous size not found for panel index ${index}`);
477
+ ensure(prevSize2, () => `Previous size not found for panel index ${index}`);
478
478
  if (fuzzyNumbersEqual(prevSize2, collapsedSize)) {
479
479
  const localDelta = minSize - prevSize2;
480
480
  if (fuzzyCompareNumbers(localDelta, Math.abs(delta)) > 0) {
@@ -486,11 +486,11 @@ function resizeByDelta(props2) {
486
486
  {
487
487
  const index = delta < 0 ? firstPivotIndex : secondPivotIndex;
488
488
  const panel = panels[index];
489
- ensure(panel, `No panel data found for index ${index}`);
489
+ ensure(panel, () => `No panel data found for index ${index}`);
490
490
  const { collapsedSize = 0, collapsible, minSize = 0 } = panel;
491
491
  if (collapsible) {
492
492
  const prevSize2 = initialSize[index];
493
- ensure(prevSize2, `Previous size not found for panel index ${index}`);
493
+ ensure(prevSize2, () => `Previous size not found for panel index ${index}`);
494
494
  if (fuzzyNumbersEqual(prevSize2, minSize)) {
495
495
  const localDelta = prevSize2 - collapsedSize;
496
496
  if (fuzzyCompareNumbers(localDelta, Math.abs(delta)) > 0) {
@@ -507,7 +507,7 @@ function resizeByDelta(props2) {
507
507
  let maxAvailableDelta = 0;
508
508
  while (true) {
509
509
  const prevSize2 = initialSize[index];
510
- ensure(prevSize2, `Previous size not found for panel index ${index}`);
510
+ ensure(prevSize2, () => `Previous size not found for panel index ${index}`);
511
511
  const maxSafeSize = resizePanel({
512
512
  panels,
513
513
  index,
@@ -529,7 +529,7 @@ function resizeByDelta(props2) {
529
529
  while (index >= 0 && index < panels.length) {
530
530
  const deltaRemaining = Math.abs(delta) - Math.abs(deltaApplied);
531
531
  const prevSize2 = initialSize[index];
532
- ensure(prevSize2, `Previous size not found for panel index ${index}`);
532
+ ensure(prevSize2, () => `Previous size not found for panel index ${index}`);
533
533
  const unsafeSize = prevSize2 - deltaRemaining;
534
534
  const safeSize = resizePanel({ panels, index, size: unsafeSize });
535
535
  if (!fuzzyNumbersEqual(prevSize2, safeSize)) {
@@ -554,7 +554,7 @@ function resizeByDelta(props2) {
554
554
  {
555
555
  const pivotIndex = delta < 0 ? secondPivotIndex : firstPivotIndex;
556
556
  const prevSize2 = initialSize[pivotIndex];
557
- ensure(prevSize2, `Previous size not found for panel index ${pivotIndex}`);
557
+ ensure(prevSize2, () => `Previous size not found for panel index ${pivotIndex}`);
558
558
  const unsafeSize = prevSize2 + deltaApplied;
559
559
  const safeSize = resizePanel({ panels, index: pivotIndex, size: unsafeSize });
560
560
  nextSize[pivotIndex] = safeSize;
@@ -564,7 +564,7 @@ function resizeByDelta(props2) {
564
564
  let index = pivotIndex2;
565
565
  while (index >= 0 && index < panels.length) {
566
566
  const prevSize3 = nextSize[index];
567
- ensure(prevSize3, `Previous size not found for panel index ${index}`);
567
+ ensure(prevSize3, () => `Previous size not found for panel index ${index}`);
568
568
  const unsafeSize2 = prevSize3 + deltaRemaining;
569
569
  const safeSize2 = resizePanel({ panels, index, size: unsafeSize2 });
570
570
  if (!fuzzyNumbersEqual(prevSize3, safeSize2)) {
@@ -596,7 +596,7 @@ function validateSizes({ size: prevSize, panels }) {
596
596
  } else if (!fuzzyNumbersEqual(nextSizeTotalSize, 100) && nextSize.length > 0) {
597
597
  for (let index = 0; index < panels.length; index++) {
598
598
  const unsafeSize = nextSize[index];
599
- ensure(unsafeSize, `No size data found for index ${index}`);
599
+ ensure(unsafeSize, () => `No size data found for index ${index}`);
600
600
  const safeSize = 100 / nextSizeTotalSize * unsafeSize;
601
601
  nextSize[index] = safeSize;
602
602
  }
@@ -604,7 +604,7 @@ function validateSizes({ size: prevSize, panels }) {
604
604
  let remainingSize = 0;
605
605
  for (let index = 0; index < panels.length; index++) {
606
606
  const unsafeSize = nextSize[index];
607
- ensure(unsafeSize, `No size data found for index ${index}`);
607
+ ensure(unsafeSize, () => `No size data found for index ${index}`);
608
608
  const safeSize = resizePanel({ panels, index, size: unsafeSize });
609
609
  if (unsafeSize != safeSize) {
610
610
  remainingSize += unsafeSize - safeSize;
@@ -614,7 +614,7 @@ function validateSizes({ size: prevSize, panels }) {
614
614
  if (!fuzzyNumbersEqual(remainingSize, 0)) {
615
615
  for (let index = 0; index < panels.length; index++) {
616
616
  const prevSize2 = nextSize[index];
617
- ensure(prevSize2, `No size data found for index ${index}`);
617
+ ensure(prevSize2, () => `No size data found for index ${index}`);
618
618
  const unsafeSize = prevSize2 + remainingSize;
619
619
  const safeSize = resizePanel({ panels, index, size: unsafeSize });
620
620
  if (prevSize2 !== safeSize) {
@@ -846,7 +846,7 @@ var machine = createMachine({
846
846
  const panelGroupEl = getRootEl(scope);
847
847
  if (!panelGroupEl) return;
848
848
  const handleElement = getResizeTriggerEl(scope, resizeTriggerId);
849
- ensure(handleElement, `Drag handle element not found for id "${resizeTriggerId}"`);
849
+ ensure(handleElement, () => `Drag handle element not found for id "${resizeTriggerId}"`);
850
850
  const initialCursorPosition = orientation === "horizontal" ? event.point.x : event.point.y;
851
851
  context.set("dragState", {
852
852
  resizeTriggerId: event.id,
@@ -871,10 +871,10 @@ var machine = createMachine({
871
871
  const prevSize = context.get("size");
872
872
  const panels = prop("panels");
873
873
  const panel = panels.find((panel2) => panel2.id === event.id);
874
- ensure(panel, `Panel data not found for id "${event.id}"`);
874
+ ensure(panel, () => `Panel data not found for id "${event.id}"`);
875
875
  if (panel.collapsible) {
876
876
  const { collapsedSize = 0, panelSize, pivotIndices } = panelDataHelper(panels, panel, prevSize);
877
- ensure(panelSize, `Panel size not found for panel "${panel.id}"`);
877
+ ensure(panelSize, () => `Panel size not found for panel "${panel.id}"`);
878
878
  if (!fuzzyNumbersEqual(panelSize, collapsedSize)) {
879
879
  refs.get("panelSizeBeforeCollapse").set(panel.id, panelSize);
880
880
  const isLastPanel = findPanelDataIndex(panels, panel) === panels.length - 1;
@@ -898,7 +898,7 @@ var machine = createMachine({
898
898
  const panels = prop("panels");
899
899
  const prevSize = context.get("size");
900
900
  const panel = panels.find((panel2) => panel2.id === event.id);
901
- ensure(panel, `Panel data not found for id "${event.id}"`);
901
+ ensure(panel, () => `Panel data not found for id "${event.id}"`);
902
902
  if (panel.collapsible) {
903
903
  const {
904
904
  collapsedSize = 0,
@@ -933,7 +933,7 @@ var machine = createMachine({
933
933
  const panel = getPanelById(panels, event.id);
934
934
  const unsafePanelSize = event.size;
935
935
  const { panelSize, pivotIndices } = panelDataHelper(panels, panel, prevSize);
936
- ensure(panelSize, `Panel size not found for panel "${panel.id}"`);
936
+ ensure(panelSize, () => `Panel size not found for panel "${panel.id}"`);
937
937
  const isLastPanel = findPanelDataIndex(panels, panel) === panels.length - 1;
938
938
  const delta = isLastPanel ? panelSize - unsafePanelSize : unsafePanelSize - panelSize;
939
939
  const nextSize = resizeByDelta({
@@ -955,7 +955,7 @@ var machine = createMachine({
955
955
  const { resizeTriggerId, initialSize, initialCursorPosition } = dragState;
956
956
  const panels = prop("panels");
957
957
  const panelGroupElement = getRootEl(scope);
958
- ensure(panelGroupElement, `Panel group element not found`);
958
+ ensure(panelGroupElement, () => `Panel group element not found`);
959
959
  const pivotIndices = resizeTriggerId.split(":").map((id) => panels.findIndex((panel) => panel.id === id));
960
960
  const horizontal = prop("orientation") === "horizontal";
961
961
  const cursorPosition = horizontal ? event.point.x : event.point.y;
@@ -1018,7 +1018,7 @@ var machine = createMachine({
1018
1018
  const index = panelDataArray.findIndex((panelData2) => panelData2.id === idBefore);
1019
1019
  if (index === -1) return;
1020
1020
  const panelData = panelDataArray[index];
1021
- ensure(panelData, `No panel data found for index ${index}`);
1021
+ ensure(panelData, () => `No panel data found for index ${index}`);
1022
1022
  const size = sizes[index];
1023
1023
  const { collapsedSize = 0, collapsible, minSize = 0 } = panelData;
1024
1024
  if (size != null && collapsible) {
@@ -1074,7 +1074,7 @@ function setSize(params, sizes) {
1074
1074
  context.set("size", sizes);
1075
1075
  sizes.forEach((size, index) => {
1076
1076
  const panelData = panelsArray[index];
1077
- ensure(panelData, `Panel data not found for index ${index}`);
1077
+ ensure(panelData, () => `Panel data not found for index ${index}`);
1078
1078
  const { collapsedSize = 0, collapsible, id: panelId } = panelData;
1079
1079
  const lastNotifiedSize = panelIdToLastNotifiedSizeMap.get(panelId);
1080
1080
  if (lastNotifiedSize == null || size !== lastNotifiedSize) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/splitter",
3
- "version": "1.7.0",
3
+ "version": "1.8.1",
4
4
  "description": "Core logic for the splitter widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -27,11 +27,11 @@
27
27
  "url": "https://github.com/chakra-ui/zag/issues"
28
28
  },
29
29
  "dependencies": {
30
- "@zag-js/anatomy": "1.7.0",
31
- "@zag-js/core": "1.7.0",
32
- "@zag-js/types": "1.7.0",
33
- "@zag-js/dom-query": "1.7.0",
34
- "@zag-js/utils": "1.7.0"
30
+ "@zag-js/anatomy": "1.8.1",
31
+ "@zag-js/core": "1.8.1",
32
+ "@zag-js/types": "1.8.1",
33
+ "@zag-js/dom-query": "1.8.1",
34
+ "@zag-js/utils": "1.8.1"
35
35
  },
36
36
  "devDependencies": {
37
37
  "clean-package": "2.2.0"