@window-splitter/state 0.8.3 → 0.8.4
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/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-lint.log +1 -1
- package/CHANGELOG.md +17 -0
- package/dist/commonjs/index.d.ts +2 -2
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +18 -4
- package/dist/commonjs/index.js.map +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +18 -4
- package/dist/esm/index.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +32 -5
package/src/index.ts
CHANGED
|
@@ -530,8 +530,12 @@ function eq(a: ParsedUnit, b: ParsedUnit) {
|
|
|
530
530
|
|
|
531
531
|
export function haveConstraintsChangedForPanel(
|
|
532
532
|
a: Omit<PanelData, "id" | "currentValue">,
|
|
533
|
-
b
|
|
533
|
+
b?: Omit<PanelData, "id" | "currentValue">
|
|
534
534
|
) {
|
|
535
|
+
if (!b) {
|
|
536
|
+
return true;
|
|
537
|
+
}
|
|
538
|
+
|
|
535
539
|
if (!eq(a.min, b.min)) {
|
|
536
540
|
return true;
|
|
537
541
|
}
|
|
@@ -583,8 +587,12 @@ export function haveConstraintsChangedForPanel(
|
|
|
583
587
|
|
|
584
588
|
export function haveConstraintsChangedForPanelHandle(
|
|
585
589
|
a: Omit<PanelHandleData, "id">,
|
|
586
|
-
b
|
|
590
|
+
b?: Omit<PanelHandleData, "id">
|
|
587
591
|
) {
|
|
592
|
+
if (!b) {
|
|
593
|
+
return true;
|
|
594
|
+
}
|
|
595
|
+
|
|
588
596
|
if (!eq(a.size, b.size)) {
|
|
589
597
|
return true;
|
|
590
598
|
}
|
|
@@ -1090,6 +1098,7 @@ function updateLayout(
|
|
|
1090
1098
|
| (DragHandleEvent & {
|
|
1091
1099
|
controlled?: boolean;
|
|
1092
1100
|
disregardCollapseBuffer?: never;
|
|
1101
|
+
isVirtual?: boolean;
|
|
1093
1102
|
})
|
|
1094
1103
|
| {
|
|
1095
1104
|
type: "collapsePanel";
|
|
@@ -1097,6 +1106,7 @@ function updateLayout(
|
|
|
1097
1106
|
handleId: string;
|
|
1098
1107
|
controlled?: boolean;
|
|
1099
1108
|
disregardCollapseBuffer?: boolean;
|
|
1109
|
+
isVirtual?: boolean;
|
|
1100
1110
|
}
|
|
1101
1111
|
): Partial<GroupMachineContextValue> {
|
|
1102
1112
|
const handleIndex = getPanelHandleIndex(context, dragEvent.handleId);
|
|
@@ -1281,7 +1291,8 @@ function updateLayout(
|
|
|
1281
1291
|
if (
|
|
1282
1292
|
panelAfter.onCollapseChange?.current &&
|
|
1283
1293
|
!panelAfter.collapseIsControlled &&
|
|
1284
|
-
!dragEvent.controlled
|
|
1294
|
+
!dragEvent.controlled &&
|
|
1295
|
+
!dragEvent.isVirtual
|
|
1285
1296
|
) {
|
|
1286
1297
|
panelAfter.onCollapseChange.current(false);
|
|
1287
1298
|
}
|
|
@@ -1317,7 +1328,8 @@ function updateLayout(
|
|
|
1317
1328
|
if (
|
|
1318
1329
|
panelBefore.onCollapseChange?.current &&
|
|
1319
1330
|
!panelBefore.collapseIsControlled &&
|
|
1320
|
-
!dragEvent.controlled
|
|
1331
|
+
!dragEvent.controlled &&
|
|
1332
|
+
!dragEvent.isVirtual
|
|
1321
1333
|
) {
|
|
1322
1334
|
panelBefore.onCollapseChange.current(true);
|
|
1323
1335
|
}
|
|
@@ -1412,6 +1424,7 @@ function iterativelyUpdateLayout({
|
|
|
1412
1424
|
direction,
|
|
1413
1425
|
controlled,
|
|
1414
1426
|
disregardCollapseBuffer,
|
|
1427
|
+
isVirtual,
|
|
1415
1428
|
}: {
|
|
1416
1429
|
context: GroupMachineContextValue;
|
|
1417
1430
|
handleId: string;
|
|
@@ -1419,6 +1432,11 @@ function iterativelyUpdateLayout({
|
|
|
1419
1432
|
direction: -1 | 1;
|
|
1420
1433
|
controlled?: boolean;
|
|
1421
1434
|
disregardCollapseBuffer?: boolean;
|
|
1435
|
+
/**
|
|
1436
|
+
* Whether this is just a calculation and not intended to be commmited to layout
|
|
1437
|
+
* no on* callbacks will be called
|
|
1438
|
+
*/
|
|
1439
|
+
isVirtual?: boolean;
|
|
1422
1440
|
}) {
|
|
1423
1441
|
let newContext: Partial<GroupMachineContextValue> = context;
|
|
1424
1442
|
|
|
@@ -1433,6 +1451,7 @@ function iterativelyUpdateLayout({
|
|
|
1433
1451
|
type: "collapsePanel",
|
|
1434
1452
|
controlled,
|
|
1435
1453
|
disregardCollapseBuffer,
|
|
1454
|
+
isVirtual,
|
|
1436
1455
|
value: dragHandlePayload({
|
|
1437
1456
|
delta: direction,
|
|
1438
1457
|
orientation: context.orientation,
|
|
@@ -1799,6 +1818,10 @@ export function groupMachine(
|
|
|
1799
1818
|
panel.currentValue = panel.collapsedSize;
|
|
1800
1819
|
}
|
|
1801
1820
|
|
|
1821
|
+
if (!panel.collapseIsControlled) {
|
|
1822
|
+
panel.onCollapseChange?.current?.(panel.collapsed);
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1802
1825
|
actions.commit();
|
|
1803
1826
|
},
|
|
1804
1827
|
};
|
|
@@ -1831,6 +1854,7 @@ export function groupMachine(
|
|
|
1831
1854
|
controlled: event.controlled,
|
|
1832
1855
|
delta: delta,
|
|
1833
1856
|
direction: handle.direction,
|
|
1857
|
+
isVirtual: true,
|
|
1834
1858
|
}),
|
|
1835
1859
|
};
|
|
1836
1860
|
const updatedPanel = interimContext.items.find(
|
|
@@ -2033,7 +2057,10 @@ export function groupMachine(
|
|
|
2033
2057
|
|
|
2034
2058
|
if (useLastKnownSize) {
|
|
2035
2059
|
context.items = withLastKnownSize;
|
|
2036
|
-
} else if (
|
|
2060
|
+
} else if (
|
|
2061
|
+
totalSize > getGroupSize(context) &&
|
|
2062
|
+
state.current !== "dragging"
|
|
2063
|
+
) {
|
|
2037
2064
|
context.items = handleOverflow({
|
|
2038
2065
|
...context,
|
|
2039
2066
|
items: prepareItems({ ...context, items: withLastKnownSize }),
|