@window-splitter/state 0.3.2 → 0.4.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/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-lint.log +4 -5
- package/.turbo/turbo-test.log +1192 -4322
- package/CHANGELOG.md +49 -0
- package/coverage/coverage-final.json +1 -1
- package/coverage/coverage-summary.json +2 -2
- package/coverage/index.html +17 -17
- package/coverage/index.ts.html +1161 -399
- package/dist/commonjs/index.d.ts +21 -14
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +219 -45
- package/dist/commonjs/index.js.map +1 -1
- package/dist/esm/index.d.ts +21 -14
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +219 -45
- package/dist/esm/index.js.map +1 -1
- package/package.json +4 -3
- package/src/__snapshots__/machine.test.ts.snap +82 -2
- package/src/index.ts +319 -71
- package/src/machine.test.ts +329 -24
package/src/machine.test.ts
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
import { Actor, createActor } from "xstate";
|
|
21
21
|
import { spring } from "framer-motion";
|
|
22
22
|
import Big from "big.js";
|
|
23
|
+
import Cookies from "universal-cookie";
|
|
23
24
|
|
|
24
25
|
function getTemplate(actor: Actor<typeof groupMachine>) {
|
|
25
26
|
return buildTemplate(actor.getSnapshot().context);
|
|
@@ -177,7 +178,7 @@ describe("constraints", () => {
|
|
|
177
178
|
});
|
|
178
179
|
|
|
179
180
|
expect(getTemplate(actor)).toMatchInlineSnapshot(
|
|
180
|
-
`"minmax(0px,
|
|
181
|
+
`"minmax(0px, 1fr) 10px minmax(0px, min(calc(0.47959183673469387755 * (100% - 10px)), 100%))"`
|
|
181
182
|
);
|
|
182
183
|
|
|
183
184
|
// Drag the resizer to the left
|
|
@@ -188,7 +189,7 @@ describe("constraints", () => {
|
|
|
188
189
|
});
|
|
189
190
|
|
|
190
191
|
expect(getTemplate(actor)).toMatchInlineSnapshot(
|
|
191
|
-
`"minmax(0px,
|
|
192
|
+
`"minmax(0px, 1fr) 10px minmax(0px, min(calc(0.52040816326530612245 * (100% - 10px)), 100%))"`
|
|
192
193
|
);
|
|
193
194
|
});
|
|
194
195
|
|
|
@@ -235,7 +236,7 @@ describe("constraints", () => {
|
|
|
235
236
|
});
|
|
236
237
|
|
|
237
238
|
expect(getTemplate(actor)).toMatchInlineSnapshot(
|
|
238
|
-
`"minmax(0px,
|
|
239
|
+
`"minmax(0px, 1fr) 10px minmax(0px, min(calc(0.53389830508474576271 * (100% - 10px)), 100%))"`
|
|
239
240
|
);
|
|
240
241
|
});
|
|
241
242
|
|
|
@@ -268,7 +269,7 @@ describe("constraints", () => {
|
|
|
268
269
|
});
|
|
269
270
|
|
|
270
271
|
expect(getTemplate(actor)).toMatchInlineSnapshot(
|
|
271
|
-
`"minmax(0px, min(calc(0.40816326530612244898 * (100% - 10px)), 40%)) 10px minmax(0px,
|
|
272
|
+
`"minmax(0px, min(calc(0.40816326530612244898 * (100% - 10px)), 40%)) 10px minmax(0px, 1fr)"`
|
|
272
273
|
);
|
|
273
274
|
});
|
|
274
275
|
|
|
@@ -303,7 +304,7 @@ describe("constraints", () => {
|
|
|
303
304
|
});
|
|
304
305
|
|
|
305
306
|
expect(getTemplate(actor)).toMatchInlineSnapshot(
|
|
306
|
-
`"minmax(0px,
|
|
307
|
+
`"minmax(0px, 1fr) 10px minmax(0px, min(calc(0.47959183673469387755 * (100% - 10px)), 100%))"`
|
|
307
308
|
);
|
|
308
309
|
|
|
309
310
|
// Drag the resizer to the up
|
|
@@ -318,7 +319,7 @@ describe("constraints", () => {
|
|
|
318
319
|
});
|
|
319
320
|
|
|
320
321
|
expect(getTemplate(actor)).toMatchInlineSnapshot(
|
|
321
|
-
`"minmax(0px,
|
|
322
|
+
`"minmax(0px, 1fr) 10px minmax(0px, min(calc(0.52040816326530612245 * (100% - 10px)), 100%))"`
|
|
322
323
|
);
|
|
323
324
|
});
|
|
324
325
|
|
|
@@ -375,8 +376,8 @@ describe("constraints", () => {
|
|
|
375
376
|
|
|
376
377
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
377
378
|
expect(spy).toHaveBeenCalledWith({
|
|
378
|
-
percentage: 0.
|
|
379
|
-
pixel:
|
|
379
|
+
percentage: 0.49,
|
|
380
|
+
pixel: 245,
|
|
380
381
|
});
|
|
381
382
|
|
|
382
383
|
capturePixelValues(actor, () => {
|
|
@@ -581,7 +582,7 @@ describe("constraints", () => {
|
|
|
581
582
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
582
583
|
|
|
583
584
|
expect(getTemplate(actor)).toMatchInlineSnapshot(
|
|
584
|
-
`"minmax(0px,
|
|
585
|
+
`"minmax(0px, 1fr) 10px 300px"`
|
|
585
586
|
);
|
|
586
587
|
|
|
587
588
|
capturePixelValues(actor, () => {
|
|
@@ -747,9 +748,7 @@ describe("collapsible panel", () => {
|
|
|
747
748
|
expect(getTemplate(actor)).toBe("490px 10px 0px");
|
|
748
749
|
});
|
|
749
750
|
|
|
750
|
-
expect(getTemplate(actor)).toBe(
|
|
751
|
-
"minmax(0px, min(calc(1 * (100% - 10px)), 100%)) 10px 0px"
|
|
752
|
-
);
|
|
751
|
+
expect(getTemplate(actor)).toBe("minmax(0px, 1fr) 10px 0px");
|
|
753
752
|
|
|
754
753
|
// Test dragging to expand the panel
|
|
755
754
|
capturePixelValues(actor, () => {
|
|
@@ -1301,6 +1300,176 @@ describe("collapsible panel", () => {
|
|
|
1301
1300
|
expect(getTemplate(actor)).toMatchInlineSnapshot(`"245px 10px 245px"`);
|
|
1302
1301
|
});
|
|
1303
1302
|
});
|
|
1303
|
+
|
|
1304
|
+
describe("constraints", () => {
|
|
1305
|
+
test("on render", async () => {
|
|
1306
|
+
const actor = createActor(groupMachine, {
|
|
1307
|
+
input: { groupId: "group" },
|
|
1308
|
+
}).start();
|
|
1309
|
+
|
|
1310
|
+
sendAll(actor, [
|
|
1311
|
+
{
|
|
1312
|
+
type: "registerPanel",
|
|
1313
|
+
data: initializePanel({ id: "panel-1", min: "200px" }),
|
|
1314
|
+
},
|
|
1315
|
+
{
|
|
1316
|
+
type: "registerPanelHandle",
|
|
1317
|
+
data: { id: "resizer-1", size: "10px" },
|
|
1318
|
+
},
|
|
1319
|
+
{
|
|
1320
|
+
type: "registerPanel",
|
|
1321
|
+
data: initializePanel({
|
|
1322
|
+
id: "panel-2",
|
|
1323
|
+
collapsible: true,
|
|
1324
|
+
min: "300px",
|
|
1325
|
+
collapsedSize: "60px",
|
|
1326
|
+
}),
|
|
1327
|
+
},
|
|
1328
|
+
]);
|
|
1329
|
+
|
|
1330
|
+
expect(getTemplate(actor)).toBe(
|
|
1331
|
+
"minmax(200px, 1fr) 10px minmax(300px, 1fr)"
|
|
1332
|
+
);
|
|
1333
|
+
initializeSizes(actor, { width: 400, height: 200 });
|
|
1334
|
+
// There wasn't enough space to render the panel so the last one is collapsed
|
|
1335
|
+
expect(getTemplate(actor)).toBe("minmax(200px, 1fr) 10px 60px");
|
|
1336
|
+
});
|
|
1337
|
+
|
|
1338
|
+
test("on resize", async () => {
|
|
1339
|
+
const actor = createActor(groupMachine, {
|
|
1340
|
+
input: { groupId: "group" },
|
|
1341
|
+
}).start();
|
|
1342
|
+
|
|
1343
|
+
sendAll(actor, [
|
|
1344
|
+
{
|
|
1345
|
+
type: "registerPanel",
|
|
1346
|
+
data: initializePanel({ id: "panel-1", min: "200px" }),
|
|
1347
|
+
},
|
|
1348
|
+
{
|
|
1349
|
+
type: "registerPanelHandle",
|
|
1350
|
+
data: { id: "resizer-1", size: "10px" },
|
|
1351
|
+
},
|
|
1352
|
+
{
|
|
1353
|
+
type: "registerPanel",
|
|
1354
|
+
data: initializePanel({
|
|
1355
|
+
id: "panel-2",
|
|
1356
|
+
collapsible: true,
|
|
1357
|
+
min: "300px",
|
|
1358
|
+
collapsedSize: "60px",
|
|
1359
|
+
}),
|
|
1360
|
+
},
|
|
1361
|
+
]);
|
|
1362
|
+
|
|
1363
|
+
expect(getTemplate(actor)).toBe(
|
|
1364
|
+
"minmax(200px, 1fr) 10px minmax(300px, 1fr)"
|
|
1365
|
+
);
|
|
1366
|
+
initializeSizes(actor, { width: 510, height: 200 });
|
|
1367
|
+
|
|
1368
|
+
capturePixelValues(actor, () => {
|
|
1369
|
+
dragHandle(actor, { id: "resizer-1", delta: 10 });
|
|
1370
|
+
});
|
|
1371
|
+
|
|
1372
|
+
expect(getTemplate(actor)).toBe(
|
|
1373
|
+
"minmax(200px, 1fr) 10px minmax(300px, min(calc(0.6 * (100% - 10px)), 100%))"
|
|
1374
|
+
);
|
|
1375
|
+
|
|
1376
|
+
initializeSizes(actor, { width: 400, height: 200 });
|
|
1377
|
+
|
|
1378
|
+
// There wasn't enough space to render the panel so the last one is collapsed
|
|
1379
|
+
expect(getTemplate(actor)).toBe("minmax(200px, 1fr) 10px 60px");
|
|
1380
|
+
});
|
|
1381
|
+
|
|
1382
|
+
test("cannot expand panel via event", async () => {
|
|
1383
|
+
const actor = createActor(groupMachine, {
|
|
1384
|
+
input: { groupId: "group" },
|
|
1385
|
+
}).start();
|
|
1386
|
+
|
|
1387
|
+
sendAll(actor, [
|
|
1388
|
+
{
|
|
1389
|
+
type: "registerPanel",
|
|
1390
|
+
data: initializePanel({ id: "panel-1", min: "200px" }),
|
|
1391
|
+
},
|
|
1392
|
+
{
|
|
1393
|
+
type: "registerPanelHandle",
|
|
1394
|
+
data: { id: "resizer-1", size: "10px" },
|
|
1395
|
+
},
|
|
1396
|
+
{
|
|
1397
|
+
type: "registerPanel",
|
|
1398
|
+
data: initializePanel({
|
|
1399
|
+
id: "panel-2",
|
|
1400
|
+
collapsible: true,
|
|
1401
|
+
min: "300px",
|
|
1402
|
+
collapsedSize: "60px",
|
|
1403
|
+
}),
|
|
1404
|
+
},
|
|
1405
|
+
]);
|
|
1406
|
+
|
|
1407
|
+
expect(getTemplate(actor)).toBe(
|
|
1408
|
+
"minmax(200px, 1fr) 10px minmax(300px, 1fr)"
|
|
1409
|
+
);
|
|
1410
|
+
initializeSizes(actor, { width: 400, height: 200 });
|
|
1411
|
+
actor.send({
|
|
1412
|
+
type: "setSize",
|
|
1413
|
+
size: { width: 400, height: 200 },
|
|
1414
|
+
handleOverflow: true,
|
|
1415
|
+
});
|
|
1416
|
+
// There wasn't enough space to render the panel so the last one is collapsed
|
|
1417
|
+
expect(getTemplate(actor)).toBe("minmax(200px, 1fr) 10px 60px");
|
|
1418
|
+
|
|
1419
|
+
actor.send({
|
|
1420
|
+
type: "expandPanel",
|
|
1421
|
+
panelId: "panel-2",
|
|
1422
|
+
});
|
|
1423
|
+
await waitForIdle(actor);
|
|
1424
|
+
|
|
1425
|
+
// There wasn't enough space to render the panel so the last one is collapsed
|
|
1426
|
+
expect(getTemplate(actor)).toBe("minmax(200px, 1fr) 10px 60px");
|
|
1427
|
+
});
|
|
1428
|
+
|
|
1429
|
+
test("cannot expand panel via drag", async () => {
|
|
1430
|
+
const actor = createActor(groupMachine, {
|
|
1431
|
+
input: { groupId: "group" },
|
|
1432
|
+
}).start();
|
|
1433
|
+
|
|
1434
|
+
sendAll(actor, [
|
|
1435
|
+
{
|
|
1436
|
+
type: "registerPanel",
|
|
1437
|
+
data: initializePanel({ id: "panel-1", min: "200px" }),
|
|
1438
|
+
},
|
|
1439
|
+
{
|
|
1440
|
+
type: "registerPanelHandle",
|
|
1441
|
+
data: { id: "resizer-1", size: "10px" },
|
|
1442
|
+
},
|
|
1443
|
+
{
|
|
1444
|
+
type: "registerPanel",
|
|
1445
|
+
data: initializePanel({
|
|
1446
|
+
id: "panel-2",
|
|
1447
|
+
collapsible: true,
|
|
1448
|
+
min: "300px",
|
|
1449
|
+
collapsedSize: "60px",
|
|
1450
|
+
}),
|
|
1451
|
+
},
|
|
1452
|
+
]);
|
|
1453
|
+
|
|
1454
|
+
expect(getTemplate(actor)).toBe(
|
|
1455
|
+
"minmax(200px, 1fr) 10px minmax(300px, 1fr)"
|
|
1456
|
+
);
|
|
1457
|
+
initializeSizes(actor, { width: 400, height: 200 });
|
|
1458
|
+
|
|
1459
|
+
// There wasn't enough space to render the panel so the last one is collapsed
|
|
1460
|
+
expect(getTemplate(actor)).toBe("minmax(200px, 1fr) 10px 60px");
|
|
1461
|
+
|
|
1462
|
+
// update the latest sizes to the new ones
|
|
1463
|
+
initializeSizes(actor, { width: 400, height: 200 });
|
|
1464
|
+
|
|
1465
|
+
// Drag the resizer to the right
|
|
1466
|
+
capturePixelValues(actor, () => {
|
|
1467
|
+
expect(getTemplate(actor)).toBe("330px 10px 60px");
|
|
1468
|
+
dragHandle(actor, { id: "resizer-1", delta: -400 });
|
|
1469
|
+
expect(getTemplate(actor)).toBe("330px 10px 60px");
|
|
1470
|
+
});
|
|
1471
|
+
});
|
|
1472
|
+
});
|
|
1304
1473
|
});
|
|
1305
1474
|
|
|
1306
1475
|
describe("conditional panel", () => {
|
|
@@ -1337,7 +1506,7 @@ describe("conditional panel", () => {
|
|
|
1337
1506
|
|
|
1338
1507
|
capturePixelValues(actor, () => {
|
|
1339
1508
|
expect(getTemplate(actor)).toMatchInlineSnapshot(
|
|
1340
|
-
`"
|
|
1509
|
+
`"245px 10px 135px 10px 100px"`
|
|
1341
1510
|
);
|
|
1342
1511
|
});
|
|
1343
1512
|
|
|
@@ -1347,7 +1516,7 @@ describe("conditional panel", () => {
|
|
|
1347
1516
|
]);
|
|
1348
1517
|
|
|
1349
1518
|
capturePixelValues(actor, () => {
|
|
1350
|
-
expect(getTemplate(actor)).toMatchInlineSnapshot(`"
|
|
1519
|
+
expect(getTemplate(actor)).toMatchInlineSnapshot(`"245px 10px 245px"`);
|
|
1351
1520
|
});
|
|
1352
1521
|
});
|
|
1353
1522
|
|
|
@@ -1392,7 +1561,7 @@ describe("conditional panel", () => {
|
|
|
1392
1561
|
|
|
1393
1562
|
capturePixelValues(actor, () => {
|
|
1394
1563
|
expect(getTemplate(actor)).toMatchInlineSnapshot(
|
|
1395
|
-
`"
|
|
1564
|
+
`"245px 10px 235px 10px 0px"`
|
|
1396
1565
|
);
|
|
1397
1566
|
});
|
|
1398
1567
|
|
|
@@ -1402,7 +1571,7 @@ describe("conditional panel", () => {
|
|
|
1402
1571
|
]);
|
|
1403
1572
|
|
|
1404
1573
|
capturePixelValues(actor, () => {
|
|
1405
|
-
expect(getTemplate(actor)).toMatchInlineSnapshot(`"
|
|
1574
|
+
expect(getTemplate(actor)).toMatchInlineSnapshot(`"245px 10px 245px"`);
|
|
1406
1575
|
});
|
|
1407
1576
|
});
|
|
1408
1577
|
|
|
@@ -1445,7 +1614,7 @@ describe("conditional panel", () => {
|
|
|
1445
1614
|
|
|
1446
1615
|
capturePixelValues(actor, () => {
|
|
1447
1616
|
expect(getTemplate(actor)).toMatchInlineSnapshot(
|
|
1448
|
-
`"
|
|
1617
|
+
`"245px 10px 110px 10px 125px"`
|
|
1449
1618
|
);
|
|
1450
1619
|
});
|
|
1451
1620
|
|
|
@@ -1455,7 +1624,7 @@ describe("conditional panel", () => {
|
|
|
1455
1624
|
]);
|
|
1456
1625
|
|
|
1457
1626
|
capturePixelValues(actor, () => {
|
|
1458
|
-
expect(getTemplate(actor)).toMatchInlineSnapshot(`"
|
|
1627
|
+
expect(getTemplate(actor)).toMatchInlineSnapshot(`"245px 10px 245px"`);
|
|
1459
1628
|
});
|
|
1460
1629
|
});
|
|
1461
1630
|
|
|
@@ -1495,7 +1664,7 @@ describe("conditional panel", () => {
|
|
|
1495
1664
|
|
|
1496
1665
|
capturePixelValues(actor, () => {
|
|
1497
1666
|
expect(getTemplate(actor)).toMatchInlineSnapshot(
|
|
1498
|
-
`"
|
|
1667
|
+
`"245px 10px 100px 10px 135px"`
|
|
1499
1668
|
);
|
|
1500
1669
|
});
|
|
1501
1670
|
|
|
@@ -1505,7 +1674,7 @@ describe("conditional panel", () => {
|
|
|
1505
1674
|
]);
|
|
1506
1675
|
|
|
1507
1676
|
capturePixelValues(actor, () => {
|
|
1508
|
-
expect(getTemplate(actor)).toMatchInlineSnapshot(`"
|
|
1677
|
+
expect(getTemplate(actor)).toMatchInlineSnapshot(`"245px 10px 245px"`);
|
|
1509
1678
|
});
|
|
1510
1679
|
|
|
1511
1680
|
sendAll(actor, [
|
|
@@ -1514,7 +1683,7 @@ describe("conditional panel", () => {
|
|
|
1514
1683
|
]);
|
|
1515
1684
|
|
|
1516
1685
|
capturePixelValues(actor, () => {
|
|
1517
|
-
expect(getTemplate(actor)).toMatchInlineSnapshot(`"
|
|
1686
|
+
expect(getTemplate(actor)).toMatchInlineSnapshot(`"245px 10px 245px"`);
|
|
1518
1687
|
});
|
|
1519
1688
|
});
|
|
1520
1689
|
|
|
@@ -1742,10 +1911,146 @@ describe("utils", async () => {
|
|
|
1742
1911
|
|
|
1743
1912
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
1744
1913
|
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1914
|
+
let oldSnapshot = actor.getSnapshot();
|
|
1915
|
+
let serialized = JSON.stringify(oldSnapshot);
|
|
1916
|
+
let newSnapshot = prepareSnapshot(JSON.parse(serialized));
|
|
1748
1917
|
|
|
1749
1918
|
expect(newSnapshot).toMatchSnapshot();
|
|
1919
|
+
|
|
1920
|
+
capturePixelValues(actor, () => {
|
|
1921
|
+
dragHandle(actor, { id: "resizer-1", delta: 100 });
|
|
1922
|
+
});
|
|
1923
|
+
|
|
1924
|
+
oldSnapshot = actor.getSnapshot();
|
|
1925
|
+
serialized = JSON.stringify(oldSnapshot);
|
|
1926
|
+
newSnapshot = prepareSnapshot(JSON.parse(serialized));
|
|
1927
|
+
|
|
1928
|
+
expect(newSnapshot).toMatchSnapshot();
|
|
1929
|
+
});
|
|
1930
|
+
});
|
|
1931
|
+
|
|
1932
|
+
describe("static at rest", () => {
|
|
1933
|
+
test("a panel can be pixels when resting", async () => {
|
|
1934
|
+
const actor = createActor(groupMachine, {
|
|
1935
|
+
input: {
|
|
1936
|
+
groupId: "group",
|
|
1937
|
+
initialItems: [
|
|
1938
|
+
initializePanel({
|
|
1939
|
+
id: "panel-1",
|
|
1940
|
+
min: "20px",
|
|
1941
|
+
max: "200px",
|
|
1942
|
+
isStaticAtRest: true,
|
|
1943
|
+
}),
|
|
1944
|
+
initializePanelHandleData({ id: "resizer-1", size: "10px" }),
|
|
1945
|
+
initializePanel({ id: "panel-2", min: "50px" }),
|
|
1946
|
+
initializePanelHandleData({ id: "resizer-2", size: "10px" }),
|
|
1947
|
+
initializePanel({ id: "panel-3", min: "50px" }),
|
|
1948
|
+
],
|
|
1949
|
+
},
|
|
1950
|
+
}).start();
|
|
1951
|
+
|
|
1952
|
+
initializeSizes(actor, { width: 500, height: 200 });
|
|
1953
|
+
|
|
1954
|
+
expect(getTemplate(actor)).toMatchInlineSnapshot(
|
|
1955
|
+
`"minmax(20px, 200px) 10px minmax(50px, 1fr) 10px minmax(50px, 1fr)"`
|
|
1956
|
+
);
|
|
1957
|
+
|
|
1958
|
+
capturePixelValues(actor, () => {
|
|
1959
|
+
dragHandle(actor, { id: "resizer-1", delta: -10 });
|
|
1960
|
+
});
|
|
1961
|
+
|
|
1962
|
+
expect(getTemplate(actor)).toMatchInlineSnapshot(
|
|
1963
|
+
`"clamp(20px, 190px, 200px) 10px minmax(50px, 1fr) 10px minmax(50px, min(calc(0.48275862068965517241 * (100% - 210px)), 100%))"`
|
|
1964
|
+
);
|
|
1965
|
+
});
|
|
1966
|
+
});
|
|
1967
|
+
|
|
1968
|
+
describe("autosave", () => {
|
|
1969
|
+
test("localStorage", async () => {
|
|
1970
|
+
localStorage.removeItem("group");
|
|
1971
|
+
|
|
1972
|
+
const actor = createActor(groupMachine, {
|
|
1973
|
+
input: {
|
|
1974
|
+
groupId: "group",
|
|
1975
|
+
autosaveStrategy: "localStorage",
|
|
1976
|
+
initialItems: [
|
|
1977
|
+
initializePanel({
|
|
1978
|
+
id: "panel-1",
|
|
1979
|
+
min: "20px",
|
|
1980
|
+
max: "200px",
|
|
1981
|
+
isStaticAtRest: true,
|
|
1982
|
+
}),
|
|
1983
|
+
initializePanelHandleData({ id: "resizer-1", size: "10px" }),
|
|
1984
|
+
initializePanel({ id: "panel-2", min: "50px" }),
|
|
1985
|
+
initializePanelHandleData({ id: "resizer-2", size: "10px" }),
|
|
1986
|
+
initializePanel({ id: "panel-3", min: "50px" }),
|
|
1987
|
+
],
|
|
1988
|
+
},
|
|
1989
|
+
}).start();
|
|
1990
|
+
|
|
1991
|
+
initializeSizes(actor, { width: 500, height: 200 });
|
|
1992
|
+
|
|
1993
|
+
capturePixelValues(actor, () => {
|
|
1994
|
+
dragHandle(actor, { id: "resizer-1", delta: -10 });
|
|
1995
|
+
});
|
|
1996
|
+
|
|
1997
|
+
await waitForIdle(actor);
|
|
1998
|
+
|
|
1999
|
+
const snapshot = prepareSnapshot(
|
|
2000
|
+
JSON.parse(localStorage.getItem("group")!)
|
|
2001
|
+
);
|
|
2002
|
+
const actor2 = createActor(groupMachine, {
|
|
2003
|
+
// @ts-expect-error For tests
|
|
2004
|
+
input: {},
|
|
2005
|
+
snapshot,
|
|
2006
|
+
}).start();
|
|
2007
|
+
|
|
2008
|
+
expect(buildTemplate(actor2.getSnapshot().context)).toMatchInlineSnapshot(
|
|
2009
|
+
`"clamp(20px, 190px, 200px) 10px minmax(50px, 1fr) 10px minmax(50px, min(calc(0.48275862068965517241 * (100% - 210px)), 100%))"`
|
|
2010
|
+
);
|
|
2011
|
+
});
|
|
2012
|
+
|
|
2013
|
+
test("cookie", async () => {
|
|
2014
|
+
localStorage.removeItem("group");
|
|
2015
|
+
|
|
2016
|
+
const actor = createActor(groupMachine, {
|
|
2017
|
+
input: {
|
|
2018
|
+
groupId: "group-2",
|
|
2019
|
+
autosaveStrategy: "cookie",
|
|
2020
|
+
initialItems: [
|
|
2021
|
+
initializePanel({
|
|
2022
|
+
id: "panel-1",
|
|
2023
|
+
min: "20px",
|
|
2024
|
+
max: "200px",
|
|
2025
|
+
isStaticAtRest: true,
|
|
2026
|
+
}),
|
|
2027
|
+
initializePanelHandleData({ id: "resizer-1", size: "10px" }),
|
|
2028
|
+
initializePanel({ id: "panel-2", min: "50px" }),
|
|
2029
|
+
initializePanelHandleData({ id: "resizer-2", size: "10px" }),
|
|
2030
|
+
initializePanel({ id: "panel-3", min: "50px" }),
|
|
2031
|
+
],
|
|
2032
|
+
},
|
|
2033
|
+
}).start();
|
|
2034
|
+
|
|
2035
|
+
initializeSizes(actor, { width: 500, height: 200 });
|
|
2036
|
+
|
|
2037
|
+
capturePixelValues(actor, () => {
|
|
2038
|
+
dragHandle(actor, { id: "resizer-1", delta: -10 });
|
|
2039
|
+
});
|
|
2040
|
+
|
|
2041
|
+
await waitForIdle(actor);
|
|
2042
|
+
|
|
2043
|
+
const ActualClass = (Cookies as any).default || Cookies;
|
|
2044
|
+
const cookies = new ActualClass(null, { path: "/" });
|
|
2045
|
+
const snapshot = prepareSnapshot(cookies.get("group-2")!);
|
|
2046
|
+
const actor2 = createActor(groupMachine, {
|
|
2047
|
+
// @ts-expect-error For tests
|
|
2048
|
+
input: {},
|
|
2049
|
+
snapshot,
|
|
2050
|
+
}).start();
|
|
2051
|
+
|
|
2052
|
+
expect(buildTemplate(actor2.getSnapshot().context)).toMatchInlineSnapshot(
|
|
2053
|
+
`"clamp(20px, 190px, 200px) 10px minmax(50px, 1fr) 10px minmax(50px, min(calc(0.48275862068965517241 * (100% - 210px)), 100%))"`
|
|
2054
|
+
);
|
|
1750
2055
|
});
|
|
1751
2056
|
});
|