@window-splitter/state 0.5.7 → 0.6.0
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/.turbo/turbo-test.log +132 -4941
- package/CHANGELOG.md +34 -0
- package/README.md +1 -4
- package/dist/commonjs/index.d.ts +16 -10
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +402 -411
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/test-utils.d.ts +10 -0
- package/dist/commonjs/test-utils.d.ts.map +1 -0
- package/dist/commonjs/test-utils.js +13 -0
- package/dist/commonjs/test-utils.js.map +1 -0
- package/dist/esm/index.d.ts +16 -10
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +401 -410
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/test-utils.d.ts +10 -0
- package/dist/esm/test-utils.d.ts.map +1 -0
- package/dist/esm/test-utils.js +10 -0
- package/dist/esm/test-utils.js.map +1 -0
- package/package.json +7 -8
- package/src/__snapshots__/machine.test.ts.snap +124 -138
- package/src/index.ts +560 -558
- package/src/machine.test.ts +508 -501
- package/src/test-utils.ts +25 -0
- package/src/utils.test.ts +48 -59
package/src/machine.test.ts
CHANGED
|
@@ -10,24 +10,19 @@ import {
|
|
|
10
10
|
getPanelGroupPixelSizes,
|
|
11
11
|
getPanelPercentageSize,
|
|
12
12
|
getPanelPixelSize,
|
|
13
|
-
groupMachine,
|
|
14
13
|
GroupMachineEvent,
|
|
15
14
|
initializePanel,
|
|
16
15
|
initializePanelHandleData,
|
|
17
16
|
isPanelHandle,
|
|
18
17
|
prepareSnapshot,
|
|
19
18
|
} from "./index.js";
|
|
20
|
-
import { Actor, createActor } from "xstate";
|
|
21
19
|
import { spring } from "framer-motion";
|
|
22
20
|
import Big from "big.js";
|
|
23
21
|
import * as Cookies from "tiny-cookie";
|
|
24
|
-
|
|
25
|
-
function getTemplate(actor: Actor<typeof groupMachine>) {
|
|
26
|
-
return buildTemplate(actor.getSnapshot().context);
|
|
27
|
-
}
|
|
22
|
+
import { Actor, createActor } from "./test-utils.js";
|
|
28
23
|
|
|
29
24
|
function dragHandle(
|
|
30
|
-
actor: Actor
|
|
25
|
+
actor: Actor,
|
|
31
26
|
options: {
|
|
32
27
|
delta: number;
|
|
33
28
|
orientation?: "horizontal" | "vertical";
|
|
@@ -48,19 +43,14 @@ function dragHandle(
|
|
|
48
43
|
}
|
|
49
44
|
}
|
|
50
45
|
|
|
51
|
-
function sendAll(
|
|
52
|
-
actor: Actor<typeof groupMachine>,
|
|
53
|
-
events: GroupMachineEvent[]
|
|
54
|
-
) {
|
|
46
|
+
function sendAll(actor: Actor, events: GroupMachineEvent[]) {
|
|
55
47
|
for (const event of events) {
|
|
56
48
|
actor.send(event);
|
|
57
49
|
}
|
|
58
50
|
}
|
|
59
51
|
|
|
60
|
-
function capturePixelValues(actor: Actor
|
|
61
|
-
const firstHandle = actor
|
|
62
|
-
.getSnapshot()
|
|
63
|
-
.context.items.find((i) => isPanelHandle(i));
|
|
52
|
+
function capturePixelValues(actor: Actor, cb: () => void) {
|
|
53
|
+
const firstHandle = actor.value.items.find((i) => isPanelHandle(i));
|
|
64
54
|
|
|
65
55
|
if (firstHandle) {
|
|
66
56
|
actor.send({ type: "dragHandleStart", handleId: firstHandle.id });
|
|
@@ -73,12 +63,10 @@ function capturePixelValues(actor: Actor<typeof groupMachine>, cb: () => void) {
|
|
|
73
63
|
}
|
|
74
64
|
}
|
|
75
65
|
|
|
76
|
-
function waitForIdle(actor: Actor
|
|
66
|
+
function waitForIdle(actor: Actor) {
|
|
77
67
|
return new Promise<void>((resolve) => {
|
|
78
68
|
setInterval(() => {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (snapshot.value === "idle") {
|
|
69
|
+
if (actor.state.current === "idle") {
|
|
82
70
|
resolve();
|
|
83
71
|
}
|
|
84
72
|
}, 100);
|
|
@@ -86,13 +74,13 @@ function waitForIdle(actor: Actor<typeof groupMachine>) {
|
|
|
86
74
|
}
|
|
87
75
|
|
|
88
76
|
function initializeSizes(
|
|
89
|
-
actor: Actor
|
|
77
|
+
actor: Actor,
|
|
90
78
|
options: {
|
|
91
79
|
width: number;
|
|
92
80
|
height: number;
|
|
93
81
|
}
|
|
94
82
|
) {
|
|
95
|
-
const context = actor.
|
|
83
|
+
const context = actor.value;
|
|
96
84
|
const { orientation, items } = context;
|
|
97
85
|
const template = buildTemplate(context);
|
|
98
86
|
const div = document.createElement("div");
|
|
@@ -139,22 +127,9 @@ function initializeSizes(
|
|
|
139
127
|
});
|
|
140
128
|
}
|
|
141
129
|
|
|
142
|
-
function waitForCondition(condition: () => boolean) {
|
|
143
|
-
return new Promise<void>((resolve) => {
|
|
144
|
-
const interval = setInterval(() => {
|
|
145
|
-
if (condition()) {
|
|
146
|
-
clearInterval(interval);
|
|
147
|
-
resolve();
|
|
148
|
-
}
|
|
149
|
-
}, 100);
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
|
|
153
130
|
describe("constraints", () => {
|
|
154
131
|
test("works with 2 simple panels - horizontal", () => {
|
|
155
|
-
const actor = createActor(
|
|
156
|
-
input: { groupId: "group" },
|
|
157
|
-
}).start();
|
|
132
|
+
const actor = createActor({ groupId: "group" });
|
|
158
133
|
|
|
159
134
|
sendAll(actor, [
|
|
160
135
|
{ type: "registerPanel", data: initializePanel({ id: "panel-1" }) },
|
|
@@ -165,38 +140,44 @@ describe("constraints", () => {
|
|
|
165
140
|
{ type: "registerPanel", data: initializePanel({ id: "panel-2" }) },
|
|
166
141
|
]);
|
|
167
142
|
|
|
168
|
-
expect(
|
|
143
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
169
144
|
`"minmax(0px, 1fr) 10px minmax(0px, 1fr)"`
|
|
170
145
|
);
|
|
171
146
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
172
147
|
|
|
173
148
|
// Drag the resizer to the right
|
|
174
149
|
capturePixelValues(actor, () => {
|
|
175
|
-
expect(
|
|
150
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
151
|
+
`"245px 10px 245px"`
|
|
152
|
+
);
|
|
176
153
|
dragHandle(actor, { id: "resizer-1", delta: 10 });
|
|
177
|
-
expect(
|
|
154
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
155
|
+
`"255px 10px 235px"`
|
|
156
|
+
);
|
|
178
157
|
});
|
|
179
158
|
|
|
180
|
-
expect(
|
|
159
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
181
160
|
`"minmax(0px, 1fr) 10px minmax(0px, min(calc(0.47959183673469387755 * (100% - 10px)), 100%))"`
|
|
182
161
|
);
|
|
183
162
|
|
|
184
163
|
// Drag the resizer to the left
|
|
185
164
|
capturePixelValues(actor, () => {
|
|
186
|
-
expect(
|
|
165
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
166
|
+
`"255px 10px 235px"`
|
|
167
|
+
);
|
|
187
168
|
dragHandle(actor, { id: "resizer-1", delta: -20 });
|
|
188
|
-
expect(
|
|
169
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
170
|
+
`"235px 10px 255px"`
|
|
171
|
+
);
|
|
189
172
|
});
|
|
190
173
|
|
|
191
|
-
expect(
|
|
174
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
192
175
|
`"minmax(0px, 1fr) 10px minmax(0px, min(calc(0.52040816326530612245 * (100% - 10px)), 100%))"`
|
|
193
176
|
);
|
|
194
177
|
});
|
|
195
178
|
|
|
196
179
|
test("works with 2 simple panels - overshot flakiness", () => {
|
|
197
|
-
const actor = createActor(
|
|
198
|
-
input: { groupId: "group" },
|
|
199
|
-
}).start();
|
|
180
|
+
const actor = createActor({ groupId: "group" });
|
|
200
181
|
|
|
201
182
|
sendAll(actor, [
|
|
202
183
|
{
|
|
@@ -211,7 +192,7 @@ describe("constraints", () => {
|
|
|
211
192
|
{ type: "registerPanel", data: initializePanel({ id: "panel-2" }) },
|
|
212
193
|
]);
|
|
213
194
|
|
|
214
|
-
expect(
|
|
195
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
215
196
|
`"minmax(0px, 1fr) 10px minmax(0px, 1fr)"`
|
|
216
197
|
);
|
|
217
198
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
@@ -235,15 +216,13 @@ describe("constraints", () => {
|
|
|
235
216
|
});
|
|
236
217
|
});
|
|
237
218
|
|
|
238
|
-
expect(
|
|
219
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
239
220
|
`"minmax(0px, 1fr) 10px minmax(0px, min(calc(0.53389830508474576271 * (100% - 10px)), 100%))"`
|
|
240
221
|
);
|
|
241
222
|
});
|
|
242
223
|
|
|
243
224
|
test("works with 2 simple panels - max percents", () => {
|
|
244
|
-
const actor = createActor(
|
|
245
|
-
input: { groupId: "group" },
|
|
246
|
-
}).start();
|
|
225
|
+
const actor = createActor({ groupId: "group" });
|
|
247
226
|
|
|
248
227
|
sendAll(actor, [
|
|
249
228
|
{
|
|
@@ -258,7 +237,7 @@ describe("constraints", () => {
|
|
|
258
237
|
{ type: "registerPanel", data: initializePanel({ id: "panel-2" }) },
|
|
259
238
|
]);
|
|
260
239
|
|
|
261
|
-
expect(
|
|
240
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
262
241
|
`"minmax(0px, 40%) 10px minmax(0px, 1fr)"`
|
|
263
242
|
);
|
|
264
243
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
@@ -268,15 +247,13 @@ describe("constraints", () => {
|
|
|
268
247
|
dragHandle(actor, { id: "resizer-1", delta: 10 });
|
|
269
248
|
});
|
|
270
249
|
|
|
271
|
-
expect(
|
|
250
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
272
251
|
`"minmax(0px, min(calc(0.40816326530612244898 * (100% - 10px)), 40%)) 10px minmax(0px, 1fr)"`
|
|
273
252
|
);
|
|
274
253
|
});
|
|
275
254
|
|
|
276
255
|
test("works with 2 simple panels - vertical", () => {
|
|
277
|
-
const actor = createActor(
|
|
278
|
-
input: { orientation: "vertical", groupId: "group" },
|
|
279
|
-
}).start();
|
|
256
|
+
const actor = createActor({ orientation: "vertical", groupId: "group" });
|
|
280
257
|
|
|
281
258
|
sendAll(actor, [
|
|
282
259
|
{ type: "registerPanel", data: initializePanel({ id: "panel-1" }) },
|
|
@@ -287,92 +264,96 @@ describe("constraints", () => {
|
|
|
287
264
|
{ type: "registerPanel", data: initializePanel({ id: "panel-2" }) },
|
|
288
265
|
]);
|
|
289
266
|
|
|
290
|
-
expect(
|
|
267
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
291
268
|
`"minmax(0px, 1fr) 10px minmax(0px, 1fr)"`
|
|
292
269
|
);
|
|
293
270
|
initializeSizes(actor, { width: 200, height: 500 });
|
|
294
271
|
|
|
295
272
|
// Drag the resizer down
|
|
296
273
|
capturePixelValues(actor, () => {
|
|
297
|
-
expect(
|
|
274
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
275
|
+
`"245px 10px 245px"`
|
|
276
|
+
);
|
|
298
277
|
dragHandle(actor, {
|
|
299
278
|
id: "resizer-1",
|
|
300
279
|
delta: 10,
|
|
301
280
|
orientation: "vertical",
|
|
302
281
|
});
|
|
303
|
-
expect(
|
|
282
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
283
|
+
`"255px 10px 235px"`
|
|
284
|
+
);
|
|
304
285
|
});
|
|
305
286
|
|
|
306
|
-
expect(
|
|
287
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
307
288
|
`"minmax(0px, 1fr) 10px minmax(0px, min(calc(0.47959183673469387755 * (100% - 10px)), 100%))"`
|
|
308
289
|
);
|
|
309
290
|
|
|
310
291
|
// Drag the resizer to the up
|
|
311
292
|
capturePixelValues(actor, () => {
|
|
312
|
-
expect(
|
|
293
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
294
|
+
`"255px 10px 235px"`
|
|
295
|
+
);
|
|
313
296
|
dragHandle(actor, {
|
|
314
297
|
id: "resizer-1",
|
|
315
298
|
delta: -20,
|
|
316
299
|
orientation: "vertical",
|
|
317
300
|
});
|
|
318
|
-
expect(
|
|
301
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
302
|
+
`"235px 10px 255px"`
|
|
303
|
+
);
|
|
319
304
|
});
|
|
320
305
|
|
|
321
|
-
expect(
|
|
306
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
322
307
|
`"minmax(0px, 1fr) 10px minmax(0px, min(calc(0.52040816326530612245 * (100% - 10px)), 100%))"`
|
|
323
308
|
);
|
|
324
309
|
});
|
|
325
310
|
|
|
326
311
|
test("doesn't register a panel with the same id twice", () => {
|
|
327
|
-
const actor = createActor(
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
},
|
|
332
|
-
}).start();
|
|
312
|
+
const actor = createActor({
|
|
313
|
+
groupId: "group",
|
|
314
|
+
items: [initializePanel({ id: "panel-1" })],
|
|
315
|
+
});
|
|
333
316
|
|
|
334
317
|
actor.send({
|
|
335
318
|
type: "registerPanel",
|
|
336
319
|
data: initializePanel({ id: "panel-1" }),
|
|
337
320
|
});
|
|
338
321
|
|
|
339
|
-
expect(actor.
|
|
322
|
+
expect(actor.value.items).toHaveLength(1);
|
|
340
323
|
});
|
|
341
324
|
|
|
342
325
|
test("works with 2 simple panels as input", () => {
|
|
343
|
-
const actor = createActor(
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
},
|
|
352
|
-
}).start();
|
|
326
|
+
const actor = createActor({
|
|
327
|
+
groupId: "group",
|
|
328
|
+
items: [
|
|
329
|
+
initializePanel({ id: "panel-1" }),
|
|
330
|
+
initializePanelHandleData({ id: "resizer-1", size: "10px" }),
|
|
331
|
+
initializePanel({ id: "panel-2" }),
|
|
332
|
+
],
|
|
333
|
+
});
|
|
353
334
|
|
|
354
|
-
expect(
|
|
335
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
355
336
|
`"minmax(0px, 1fr) 10px minmax(0px, 1fr)"`
|
|
356
337
|
);
|
|
357
338
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
358
339
|
|
|
359
340
|
capturePixelValues(actor, () => {
|
|
360
|
-
expect(
|
|
341
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
342
|
+
`"245px 10px 245px"`
|
|
343
|
+
);
|
|
361
344
|
});
|
|
362
345
|
});
|
|
363
346
|
|
|
364
347
|
test("can spy on resize", () => {
|
|
365
348
|
const spy = vi.fn();
|
|
366
|
-
const actor = createActor(
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
},
|
|
375
|
-
}).start();
|
|
349
|
+
const actor = createActor({
|
|
350
|
+
groupId: "group",
|
|
351
|
+
items: [
|
|
352
|
+
initializePanel({ id: "panel-1", onResize: { current: spy } }),
|
|
353
|
+
initializePanelHandleData({ id: "resizer-1", size: "10px" }),
|
|
354
|
+
initializePanel({ id: "panel-2" }),
|
|
355
|
+
],
|
|
356
|
+
});
|
|
376
357
|
|
|
377
358
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
378
359
|
expect(spy).toHaveBeenCalledWith({
|
|
@@ -390,123 +371,125 @@ describe("constraints", () => {
|
|
|
390
371
|
});
|
|
391
372
|
|
|
392
373
|
test("no delta does nothing", () => {
|
|
393
|
-
const actor = createActor(
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
},
|
|
402
|
-
}).start();
|
|
374
|
+
const actor = createActor({
|
|
375
|
+
groupId: "group",
|
|
376
|
+
items: [
|
|
377
|
+
initializePanel({ id: "panel-1" }),
|
|
378
|
+
initializePanelHandleData({ id: "resizer-1", size: "10px" }),
|
|
379
|
+
initializePanel({ id: "panel-2" }),
|
|
380
|
+
],
|
|
381
|
+
});
|
|
403
382
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
404
383
|
|
|
405
384
|
capturePixelValues(actor, () => {
|
|
406
|
-
expect(
|
|
385
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
386
|
+
`"245px 10px 245px"`
|
|
387
|
+
);
|
|
407
388
|
actor.send({
|
|
408
389
|
type: "dragHandle",
|
|
409
390
|
handleId: "resizer-1",
|
|
410
391
|
value: dragHandlePayload({ delta: 0 }),
|
|
411
392
|
});
|
|
412
|
-
expect(
|
|
393
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
394
|
+
`"245px 10px 245px"`
|
|
395
|
+
);
|
|
413
396
|
});
|
|
414
397
|
});
|
|
415
398
|
|
|
416
399
|
test("shift key makes it drag more", () => {
|
|
417
|
-
const actor = createActor(
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
},
|
|
426
|
-
}).start();
|
|
400
|
+
const actor = createActor({
|
|
401
|
+
groupId: "group",
|
|
402
|
+
items: [
|
|
403
|
+
initializePanel({ id: "panel-1" }),
|
|
404
|
+
initializePanelHandleData({ id: "resizer-1", size: "10px" }),
|
|
405
|
+
initializePanel({ id: "panel-2" }),
|
|
406
|
+
],
|
|
407
|
+
});
|
|
427
408
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
428
409
|
|
|
429
410
|
capturePixelValues(actor, () => {
|
|
430
|
-
expect(
|
|
411
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
412
|
+
`"245px 10px 245px"`
|
|
413
|
+
);
|
|
431
414
|
dragHandle(actor, { id: "resizer-1", delta: -1, shiftKey: true });
|
|
432
|
-
expect(
|
|
415
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
416
|
+
`"230px 10px 260px"`
|
|
417
|
+
);
|
|
433
418
|
});
|
|
434
419
|
});
|
|
435
420
|
|
|
436
421
|
test("works with percentages", () => {
|
|
437
|
-
const actor = createActor(
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
},
|
|
446
|
-
}).start();
|
|
422
|
+
const actor = createActor({
|
|
423
|
+
groupId: "group",
|
|
424
|
+
items: [
|
|
425
|
+
initializePanel({ id: "panel-1", min: "40%" }),
|
|
426
|
+
initializePanelHandleData({ id: "resizer-1", size: "10px" }),
|
|
427
|
+
initializePanel({ id: "panel-2", min: "10%", default: "30%" }),
|
|
428
|
+
],
|
|
429
|
+
});
|
|
447
430
|
|
|
448
|
-
expect(
|
|
431
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
449
432
|
`"minmax(40%, 1fr) 10px 30%"`
|
|
450
433
|
);
|
|
451
434
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
452
435
|
|
|
453
436
|
capturePixelValues(actor, () => {
|
|
454
|
-
expect(
|
|
437
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
438
|
+
`"340px 10px 150px"`
|
|
439
|
+
);
|
|
455
440
|
dragHandle(actor, { id: "resizer-1", delta: -200 });
|
|
456
|
-
expect(
|
|
441
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
442
|
+
`"200px 10px 290px"`
|
|
443
|
+
);
|
|
457
444
|
});
|
|
458
445
|
});
|
|
459
446
|
|
|
460
447
|
test("supports max", () => {
|
|
461
|
-
const actor = createActor(
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
},
|
|
470
|
-
}).start();
|
|
448
|
+
const actor = createActor({
|
|
449
|
+
groupId: "group",
|
|
450
|
+
items: [
|
|
451
|
+
initializePanel({ id: "panel-1", max: "90%" }),
|
|
452
|
+
initializePanelHandleData({ id: "resizer-1", size: "10px" }),
|
|
453
|
+
initializePanel({ id: "panel-2", default: "30%" }),
|
|
454
|
+
],
|
|
455
|
+
});
|
|
471
456
|
|
|
472
|
-
expect(
|
|
457
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
473
458
|
`"minmax(0px, 90%) 10px minmax(30%, 1fr)"`
|
|
474
459
|
);
|
|
475
460
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
476
461
|
|
|
477
462
|
capturePixelValues(actor, () => {
|
|
478
463
|
dragHandle(actor, { id: "resizer-1", delta: 500 });
|
|
479
|
-
expect(
|
|
464
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
465
|
+
`"450px 10px 40px"`
|
|
466
|
+
);
|
|
480
467
|
});
|
|
481
468
|
});
|
|
482
469
|
|
|
483
470
|
test("supports 1 panel being collapsed with another panel expanding to fill", () => {
|
|
484
|
-
const actor = createActor(
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
},
|
|
499
|
-
}).start();
|
|
471
|
+
const actor = createActor({
|
|
472
|
+
groupId: "group",
|
|
473
|
+
items: [
|
|
474
|
+
initializePanel({ id: "panel-1", default: "200px", min: "200px" }),
|
|
475
|
+
initializePanelHandleData({ id: "resizer-1", size: "10px" }),
|
|
476
|
+
initializePanel({
|
|
477
|
+
id: "panel-2",
|
|
478
|
+
min: "200px",
|
|
479
|
+
collapsible: true,
|
|
480
|
+
collapsedSize: "60px",
|
|
481
|
+
defaultCollapsed: true,
|
|
482
|
+
}),
|
|
483
|
+
],
|
|
484
|
+
});
|
|
500
485
|
|
|
501
|
-
expect(
|
|
486
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
502
487
|
`"minmax(200px, 1fr) 10px 60px"`
|
|
503
488
|
);
|
|
504
489
|
});
|
|
505
490
|
|
|
506
491
|
test("panel can have a min", () => {
|
|
507
|
-
const actor = createActor(
|
|
508
|
-
input: { groupId: "group" },
|
|
509
|
-
}).start();
|
|
492
|
+
const actor = createActor({ groupId: "group" });
|
|
510
493
|
|
|
511
494
|
sendAll(actor, [
|
|
512
495
|
{ type: "registerPanel", data: initializePanel({ id: "panel-1" }) },
|
|
@@ -520,22 +503,24 @@ describe("constraints", () => {
|
|
|
520
503
|
},
|
|
521
504
|
]);
|
|
522
505
|
|
|
523
|
-
expect(
|
|
506
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
524
507
|
`"minmax(0px, 1fr) 10px minmax(100px, 1fr)"`
|
|
525
508
|
);
|
|
526
509
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
527
510
|
|
|
528
511
|
capturePixelValues(actor, () => {
|
|
529
|
-
expect(
|
|
512
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
513
|
+
`"245px 10px 245px"`
|
|
514
|
+
);
|
|
530
515
|
dragHandle(actor, { id: "resizer-1", delta: 200 });
|
|
531
|
-
expect(
|
|
516
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
517
|
+
`"390px 10px 100px"`
|
|
518
|
+
);
|
|
532
519
|
});
|
|
533
520
|
});
|
|
534
521
|
|
|
535
522
|
test("panel can have a max", () => {
|
|
536
|
-
const actor = createActor(
|
|
537
|
-
input: { groupId: "group" },
|
|
538
|
-
}).start();
|
|
523
|
+
const actor = createActor({ groupId: "group" });
|
|
539
524
|
|
|
540
525
|
sendAll(actor, [
|
|
541
526
|
{ type: "registerPanel", data: initializePanel({ id: "panel-1" }) },
|
|
@@ -549,7 +534,7 @@ describe("constraints", () => {
|
|
|
549
534
|
},
|
|
550
535
|
]);
|
|
551
536
|
|
|
552
|
-
expect(
|
|
537
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
553
538
|
`"minmax(0px, 1fr) 10px minmax(0px, 300px)"`
|
|
554
539
|
);
|
|
555
540
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
@@ -557,16 +542,18 @@ describe("constraints", () => {
|
|
|
557
542
|
// Drag the resizer to the right
|
|
558
543
|
|
|
559
544
|
capturePixelValues(actor, () => {
|
|
560
|
-
expect(
|
|
545
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
546
|
+
`"190px 10px 300px"`
|
|
547
|
+
);
|
|
561
548
|
dragHandle(actor, { id: "resizer-1", delta: -200 });
|
|
562
|
-
expect(
|
|
549
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
550
|
+
`"190px 10px 300px"`
|
|
551
|
+
);
|
|
563
552
|
});
|
|
564
553
|
});
|
|
565
554
|
|
|
566
555
|
test("panel can have a default size", () => {
|
|
567
|
-
const actor = createActor(
|
|
568
|
-
input: { groupId: "group" },
|
|
569
|
-
}).start();
|
|
556
|
+
const actor = createActor({ groupId: "group" });
|
|
570
557
|
|
|
571
558
|
sendAll(actor, [
|
|
572
559
|
{ type: "registerPanel", data: initializePanel({ id: "panel-1" }) },
|
|
@@ -581,19 +568,19 @@ describe("constraints", () => {
|
|
|
581
568
|
]);
|
|
582
569
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
583
570
|
|
|
584
|
-
expect(
|
|
571
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
585
572
|
`"minmax(0px, 1fr) 10px 300px"`
|
|
586
573
|
);
|
|
587
574
|
|
|
588
575
|
capturePixelValues(actor, () => {
|
|
589
|
-
expect(
|
|
576
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
577
|
+
`"190px 10px 300px"`
|
|
578
|
+
);
|
|
590
579
|
});
|
|
591
580
|
});
|
|
592
581
|
|
|
593
582
|
test("dragging eats space from multiple panels in front of it", () => {
|
|
594
|
-
const actor = createActor(
|
|
595
|
-
input: { groupId: "group" },
|
|
596
|
-
}).start();
|
|
583
|
+
const actor = createActor({ groupId: "group" });
|
|
597
584
|
|
|
598
585
|
sendAll(actor, [
|
|
599
586
|
{ type: "registerPanel", data: initializePanel({ id: "panel-1" }) },
|
|
@@ -622,27 +609,25 @@ describe("constraints", () => {
|
|
|
622
609
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
623
610
|
|
|
624
611
|
capturePixelValues(actor, () => {
|
|
625
|
-
expect(
|
|
612
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
626
613
|
`"80px 10px 300px 10px 100px"`
|
|
627
614
|
);
|
|
628
615
|
dragHandle(actor, { id: "resizer-1", delta: 160 });
|
|
629
|
-
expect(
|
|
616
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
630
617
|
`"180px 10px 200px 10px 100px"`
|
|
631
618
|
);
|
|
632
619
|
});
|
|
633
620
|
});
|
|
634
621
|
|
|
635
622
|
test("can set a panel's size", () => {
|
|
636
|
-
const actor = createActor(
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
},
|
|
645
|
-
}).start();
|
|
623
|
+
const actor = createActor({
|
|
624
|
+
groupId: "group",
|
|
625
|
+
items: [
|
|
626
|
+
initializePanel({ id: "panel-1" }),
|
|
627
|
+
initializePanelHandleData({ id: "resizer-1", size: "10px" }),
|
|
628
|
+
initializePanel({ id: "panel-2" }),
|
|
629
|
+
],
|
|
630
|
+
});
|
|
646
631
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
647
632
|
|
|
648
633
|
actor.send({
|
|
@@ -652,7 +637,9 @@ describe("constraints", () => {
|
|
|
652
637
|
});
|
|
653
638
|
|
|
654
639
|
capturePixelValues(actor, () => {
|
|
655
|
-
expect(
|
|
640
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
641
|
+
`"100px 10px 390px"`
|
|
642
|
+
);
|
|
656
643
|
});
|
|
657
644
|
|
|
658
645
|
actor.send({
|
|
@@ -662,14 +649,14 @@ describe("constraints", () => {
|
|
|
662
649
|
});
|
|
663
650
|
|
|
664
651
|
capturePixelValues(actor, () => {
|
|
665
|
-
expect(
|
|
652
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
653
|
+
`"125px 10px 365px"`
|
|
654
|
+
);
|
|
666
655
|
});
|
|
667
656
|
});
|
|
668
657
|
|
|
669
658
|
test("can update orientation at runtime", () => {
|
|
670
|
-
const actor = createActor(
|
|
671
|
-
input: { groupId: "group" },
|
|
672
|
-
}).start();
|
|
659
|
+
const actor = createActor({ groupId: "group" });
|
|
673
660
|
|
|
674
661
|
sendAll(actor, [
|
|
675
662
|
{ type: "registerPanel", data: initializePanel({ id: "panel-1" }) },
|
|
@@ -683,13 +670,17 @@ describe("constraints", () => {
|
|
|
683
670
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
684
671
|
|
|
685
672
|
capturePixelValues(actor, () => {
|
|
686
|
-
expect(
|
|
673
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
674
|
+
`"245px 10px 245px"`
|
|
675
|
+
);
|
|
687
676
|
});
|
|
688
677
|
|
|
689
678
|
actor.send({ type: "setOrientation", orientation: "vertical" });
|
|
690
679
|
|
|
691
680
|
capturePixelValues(actor, () => {
|
|
692
|
-
expect(
|
|
681
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
682
|
+
`"95px 10px 95px"`
|
|
683
|
+
);
|
|
693
684
|
});
|
|
694
685
|
});
|
|
695
686
|
});
|
|
@@ -711,9 +702,7 @@ describe("collapsible panel", () => {
|
|
|
711
702
|
{ duration: 500, easing: "linear" as const },
|
|
712
703
|
{ duration: 1000, easing: springEasing },
|
|
713
704
|
])("panel can be collapsible: %s", async (animation) => {
|
|
714
|
-
const actor = createActor(
|
|
715
|
-
input: { groupId: "group" },
|
|
716
|
-
}).start();
|
|
705
|
+
const actor = createActor({ groupId: "group" });
|
|
717
706
|
|
|
718
707
|
sendAll(actor, [
|
|
719
708
|
{ type: "registerPanel", data: initializePanel({ id: "panel-1" }) },
|
|
@@ -732,78 +721,65 @@ describe("collapsible panel", () => {
|
|
|
732
721
|
},
|
|
733
722
|
]);
|
|
734
723
|
|
|
735
|
-
expect(
|
|
724
|
+
expect(buildTemplate(actor.value)).toBe(
|
|
725
|
+
"minmax(0px, 1fr) 10px minmax(100px, 1fr)"
|
|
726
|
+
);
|
|
736
727
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
737
728
|
|
|
738
729
|
// Test dragging to collapse the panel
|
|
739
730
|
capturePixelValues(actor, () => {
|
|
740
|
-
expect(
|
|
731
|
+
expect(buildTemplate(actor.value)).toBe("245px 10px 245px");
|
|
741
732
|
|
|
742
733
|
// Drag into the drag buffer but not past it
|
|
743
734
|
dragHandle(actor, { id: "resizer-1", delta: 160 });
|
|
744
|
-
expect(
|
|
735
|
+
expect(buildTemplate(actor.value)).toBe("390px 10px 100px");
|
|
745
736
|
|
|
746
737
|
// Drag past the drag buffer and collapse the panel
|
|
747
738
|
dragHandle(actor, { id: "resizer-1", delta: 100 });
|
|
748
|
-
expect(
|
|
739
|
+
expect(buildTemplate(actor.value)).toBe("490px 10px 0px");
|
|
749
740
|
});
|
|
750
741
|
|
|
751
|
-
expect(
|
|
742
|
+
expect(buildTemplate(actor.value)).toBe("minmax(0px, 1fr) 10px 0px");
|
|
752
743
|
|
|
753
744
|
// Test dragging to expand the panel
|
|
754
745
|
capturePixelValues(actor, () => {
|
|
755
|
-
expect(
|
|
746
|
+
expect(buildTemplate(actor.value)).toBe("490px 10px 0px");
|
|
756
747
|
|
|
757
748
|
// Stays collapsed in the buffer
|
|
758
749
|
dragHandle(actor, { id: "resizer-1", delta: -30 });
|
|
759
|
-
expect(
|
|
750
|
+
expect(buildTemplate(actor.value)).toBe("490px 10px 0px");
|
|
760
751
|
|
|
761
752
|
// Opens once the buffer is cleared
|
|
762
753
|
dragHandle(actor, { id: "resizer-1", delta: -20 });
|
|
763
|
-
expect(
|
|
754
|
+
expect(buildTemplate(actor.value)).toBe("390px 10px 100px");
|
|
764
755
|
});
|
|
765
756
|
|
|
766
757
|
actor.send({ type: "collapsePanel", panelId: "panel-2" });
|
|
767
758
|
await waitForIdle(actor);
|
|
768
759
|
|
|
769
760
|
capturePixelValues(actor, () => {
|
|
770
|
-
expect(
|
|
761
|
+
expect(buildTemplate(actor.value)).toBe("490px 10px 0px");
|
|
771
762
|
});
|
|
772
763
|
});
|
|
773
764
|
|
|
774
765
|
test("throws when you collapse a panel and there are no handles", async () => {
|
|
775
|
-
const actor = createActor(
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
initialItems: [initializePanel({ id: "panel-1" })],
|
|
779
|
-
},
|
|
780
|
-
}).start();
|
|
781
|
-
|
|
782
|
-
initializeSizes(actor, { width: 500, height: 200 });
|
|
783
|
-
|
|
784
|
-
const spy = vi.fn();
|
|
785
|
-
let didError = false;
|
|
786
|
-
|
|
787
|
-
actor.subscribe({
|
|
788
|
-
error: (e) => {
|
|
789
|
-
spy(e);
|
|
790
|
-
didError = true;
|
|
791
|
-
},
|
|
766
|
+
const actor = createActor({
|
|
767
|
+
groupId: "group",
|
|
768
|
+
items: [initializePanel({ id: "panel-1" })],
|
|
792
769
|
});
|
|
793
770
|
|
|
794
|
-
actor
|
|
795
|
-
|
|
796
|
-
await waitForCondition(() => didError);
|
|
771
|
+
initializeSizes(actor, { width: 500, height: 200 });
|
|
797
772
|
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
)
|
|
773
|
+
try {
|
|
774
|
+
actor.send({ type: "collapsePanel", panelId: "panel-1" });
|
|
775
|
+
} catch (e) {
|
|
776
|
+
expect(e).toBeInstanceOf(Error);
|
|
777
|
+
expect((e as Error).message).toBe("Cant find handle for panel: panel-1");
|
|
778
|
+
}
|
|
801
779
|
});
|
|
802
780
|
|
|
803
781
|
test("collapsible panel can have collapsed size - right", async () => {
|
|
804
|
-
const actor = createActor(
|
|
805
|
-
input: { groupId: "group" },
|
|
806
|
-
}).start();
|
|
782
|
+
const actor = createActor({ groupId: "group" });
|
|
807
783
|
|
|
808
784
|
sendAll(actor, [
|
|
809
785
|
{ type: "registerPanel", data: initializePanel({ id: "panel-1" }) },
|
|
@@ -823,36 +799,44 @@ describe("collapsible panel", () => {
|
|
|
823
799
|
},
|
|
824
800
|
]);
|
|
825
801
|
|
|
826
|
-
expect(
|
|
802
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
827
803
|
`"minmax(0px, 1fr) 10px 60px"`
|
|
828
804
|
);
|
|
829
805
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
830
806
|
|
|
831
807
|
capturePixelValues(actor, () => {
|
|
832
|
-
expect(
|
|
808
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
809
|
+
`"430px 10px 60px"`
|
|
810
|
+
);
|
|
833
811
|
|
|
834
812
|
// Drag into the the panel
|
|
835
813
|
dragHandle(actor, { id: "resizer-1", delta: 50 });
|
|
836
|
-
expect(
|
|
814
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
815
|
+
`"430px 10px 60px"`
|
|
816
|
+
);
|
|
837
817
|
|
|
838
818
|
// Drag into the start
|
|
839
819
|
dragHandle(actor, { id: "resizer-1", delta: -50 });
|
|
840
|
-
expect(
|
|
820
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
821
|
+
`"430px 10px 60px"`
|
|
822
|
+
);
|
|
841
823
|
|
|
842
824
|
// Drag into the drag buffer but not past it
|
|
843
825
|
dragHandle(actor, { id: "resizer-1", delta: -25 });
|
|
844
|
-
expect(
|
|
826
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
827
|
+
`"430px 10px 60px"`
|
|
828
|
+
);
|
|
845
829
|
|
|
846
830
|
// Drag past the buffer
|
|
847
831
|
dragHandle(actor, { id: "resizer-1", delta: -25 });
|
|
848
|
-
expect(
|
|
832
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
833
|
+
`"290px 10px 200px"`
|
|
834
|
+
);
|
|
849
835
|
});
|
|
850
836
|
});
|
|
851
837
|
|
|
852
838
|
test("non collapsible panels should have drag overflow too", async () => {
|
|
853
|
-
const actor = createActor(
|
|
854
|
-
input: { groupId: "group" },
|
|
855
|
-
}).start();
|
|
839
|
+
const actor = createActor({ groupId: "group" });
|
|
856
840
|
|
|
857
841
|
sendAll(actor, [
|
|
858
842
|
{ type: "registerPanel", data: initializePanel({ id: "panel-1" }) },
|
|
@@ -870,32 +854,38 @@ describe("collapsible panel", () => {
|
|
|
870
854
|
},
|
|
871
855
|
]);
|
|
872
856
|
|
|
873
|
-
expect(
|
|
857
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
874
858
|
`"minmax(0px, 1fr) 10px 200px"`
|
|
875
859
|
);
|
|
876
860
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
877
861
|
|
|
878
862
|
capturePixelValues(actor, () => {
|
|
879
|
-
expect(
|
|
863
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
864
|
+
`"290px 10px 200px"`
|
|
865
|
+
);
|
|
880
866
|
|
|
881
867
|
// Drag into the the panel
|
|
882
868
|
dragHandle(actor, { id: "resizer-1", delta: 50 });
|
|
883
|
-
expect(
|
|
869
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
870
|
+
`"290px 10px 200px"`
|
|
871
|
+
);
|
|
884
872
|
|
|
885
873
|
// Drag into the start
|
|
886
874
|
dragHandle(actor, { id: "resizer-1", delta: -50 });
|
|
887
|
-
expect(
|
|
875
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
876
|
+
`"290px 10px 200px"`
|
|
877
|
+
);
|
|
888
878
|
|
|
889
879
|
// Drag into the drag buffer but not past it
|
|
890
880
|
dragHandle(actor, { id: "resizer-1", delta: -25 });
|
|
891
|
-
expect(
|
|
881
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
882
|
+
`"265px 10px 225px"`
|
|
883
|
+
);
|
|
892
884
|
});
|
|
893
885
|
});
|
|
894
886
|
|
|
895
887
|
test("can expand default collapsed panel via event", async () => {
|
|
896
|
-
const actor = createActor(
|
|
897
|
-
input: { groupId: "group" },
|
|
898
|
-
}).start();
|
|
888
|
+
const actor = createActor({ groupId: "group" });
|
|
899
889
|
|
|
900
890
|
sendAll(actor, [
|
|
901
891
|
{ type: "registerPanel", data: initializePanel({ id: "panel-1" }) },
|
|
@@ -920,14 +910,14 @@ describe("collapsible panel", () => {
|
|
|
920
910
|
await waitForIdle(actor);
|
|
921
911
|
|
|
922
912
|
capturePixelValues(actor, () => {
|
|
923
|
-
expect(
|
|
913
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
914
|
+
`"290px 10px 200px"`
|
|
915
|
+
);
|
|
924
916
|
});
|
|
925
917
|
});
|
|
926
918
|
|
|
927
919
|
test("collapsible panel can have collapsed size - left", async () => {
|
|
928
|
-
const actor = createActor(
|
|
929
|
-
input: { groupId: "group" },
|
|
930
|
-
}).start();
|
|
920
|
+
const actor = createActor({ groupId: "group" });
|
|
931
921
|
|
|
932
922
|
sendAll(actor, [
|
|
933
923
|
{
|
|
@@ -947,36 +937,44 @@ describe("collapsible panel", () => {
|
|
|
947
937
|
{ type: "registerPanel", data: initializePanel({ id: "panel-1" }) },
|
|
948
938
|
]);
|
|
949
939
|
|
|
950
|
-
expect(
|
|
940
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
951
941
|
`"60px 10px minmax(0px, 1fr)"`
|
|
952
942
|
);
|
|
953
943
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
954
944
|
|
|
955
945
|
capturePixelValues(actor, () => {
|
|
956
|
-
expect(
|
|
946
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
947
|
+
`"60px 10px 430px"`
|
|
948
|
+
);
|
|
957
949
|
|
|
958
950
|
// Drag into the the panel
|
|
959
951
|
dragHandle(actor, { id: "resizer-1", delta: -50 });
|
|
960
|
-
expect(
|
|
952
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
953
|
+
`"60px 10px 430px"`
|
|
954
|
+
);
|
|
961
955
|
|
|
962
956
|
// Drag to the start
|
|
963
957
|
dragHandle(actor, { id: "resizer-1", delta: 50 });
|
|
964
|
-
expect(
|
|
958
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
959
|
+
`"60px 10px 430px"`
|
|
960
|
+
);
|
|
965
961
|
|
|
966
962
|
// Drag into the drag buffer but not past it
|
|
967
963
|
dragHandle(actor, { id: "resizer-1", delta: 25 });
|
|
968
|
-
expect(
|
|
964
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
965
|
+
`"60px 10px 430px"`
|
|
966
|
+
);
|
|
969
967
|
|
|
970
968
|
// Drag past the buffer
|
|
971
969
|
dragHandle(actor, { id: "resizer-1", delta: 25 });
|
|
972
|
-
expect(
|
|
970
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
971
|
+
`"200px 10px 290px"`
|
|
972
|
+
);
|
|
973
973
|
});
|
|
974
974
|
});
|
|
975
975
|
|
|
976
976
|
test("collapsible remembers last position", async () => {
|
|
977
|
-
const actor = createActor(
|
|
978
|
-
input: { groupId: "group" },
|
|
979
|
-
}).start();
|
|
977
|
+
const actor = createActor({ groupId: "group" });
|
|
980
978
|
|
|
981
979
|
sendAll(actor, [
|
|
982
980
|
{ type: "registerPanel", data: initializePanel({ id: "panel-1" }) },
|
|
@@ -998,30 +996,36 @@ describe("collapsible panel", () => {
|
|
|
998
996
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
999
997
|
|
|
1000
998
|
capturePixelValues(actor, () => {
|
|
1001
|
-
expect(
|
|
999
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1000
|
+
`"245px 10px 245px"`
|
|
1001
|
+
);
|
|
1002
1002
|
dragHandle(actor, { id: "resizer-1", delta: -50 });
|
|
1003
|
-
expect(
|
|
1003
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1004
|
+
`"195px 10px 295px"`
|
|
1005
|
+
);
|
|
1004
1006
|
});
|
|
1005
1007
|
|
|
1006
1008
|
actor.send({ type: "collapsePanel", panelId: "panel-2" });
|
|
1007
1009
|
await waitForIdle(actor);
|
|
1008
1010
|
|
|
1009
1011
|
capturePixelValues(actor, () => {
|
|
1010
|
-
expect(
|
|
1012
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1013
|
+
`"430px 10px 60px"`
|
|
1014
|
+
);
|
|
1011
1015
|
});
|
|
1012
1016
|
|
|
1013
1017
|
actor.send({ type: "expandPanel", panelId: "panel-2" });
|
|
1014
1018
|
await waitForIdle(actor);
|
|
1015
1019
|
|
|
1016
1020
|
capturePixelValues(actor, () => {
|
|
1017
|
-
expect(
|
|
1021
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1022
|
+
`"195px 10px 295px"`
|
|
1023
|
+
);
|
|
1018
1024
|
});
|
|
1019
1025
|
});
|
|
1020
1026
|
|
|
1021
1027
|
test("panel can collapse can subscribe to collapsed state", () => {
|
|
1022
|
-
const actor = createActor(
|
|
1023
|
-
input: { groupId: "group" },
|
|
1024
|
-
}).start();
|
|
1028
|
+
const actor = createActor({ groupId: "group" });
|
|
1025
1029
|
|
|
1026
1030
|
const spy = vi.fn();
|
|
1027
1031
|
|
|
@@ -1044,23 +1048,29 @@ describe("collapsible panel", () => {
|
|
|
1044
1048
|
},
|
|
1045
1049
|
]);
|
|
1046
1050
|
|
|
1047
|
-
expect(
|
|
1051
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1048
1052
|
`"minmax(0px, 1fr) 10px minmax(100px, 1fr)"`
|
|
1049
1053
|
);
|
|
1050
1054
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
1051
1055
|
|
|
1052
1056
|
// collapse the panel
|
|
1053
1057
|
capturePixelValues(actor, () => {
|
|
1054
|
-
expect(
|
|
1058
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1059
|
+
`"245px 10px 245px"`
|
|
1060
|
+
);
|
|
1055
1061
|
|
|
1056
1062
|
// Drag into the drag buffer but not past it
|
|
1057
1063
|
dragHandle(actor, { id: "resizer-1", delta: 160 });
|
|
1058
|
-
expect(
|
|
1064
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1065
|
+
`"390px 10px 100px"`
|
|
1066
|
+
);
|
|
1059
1067
|
|
|
1060
1068
|
// Drag past the drag buffer and collapse the panel
|
|
1061
1069
|
dragHandle(actor, { id: "resizer-1", delta: 100 });
|
|
1062
1070
|
expect(spy).toHaveBeenCalledWith(true);
|
|
1063
|
-
expect(
|
|
1071
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1072
|
+
`"490px 10px 0px"`
|
|
1073
|
+
);
|
|
1064
1074
|
});
|
|
1065
1075
|
|
|
1066
1076
|
spy.mockReset();
|
|
@@ -1069,10 +1079,14 @@ describe("collapsible panel", () => {
|
|
|
1069
1079
|
capturePixelValues(actor, () => {
|
|
1070
1080
|
// The panel doesn't actually expand yet
|
|
1071
1081
|
dragHandle(actor, { id: "resizer-1", delta: -150 });
|
|
1072
|
-
expect(
|
|
1082
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1083
|
+
`"290px 10px 200px"`
|
|
1084
|
+
);
|
|
1073
1085
|
|
|
1074
1086
|
expect(spy).toHaveBeenCalledWith(false);
|
|
1075
|
-
expect(
|
|
1087
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1088
|
+
`"290px 10px 200px"`
|
|
1089
|
+
);
|
|
1076
1090
|
|
|
1077
1091
|
// Actually collapse the panel
|
|
1078
1092
|
actor.send({
|
|
@@ -1080,14 +1094,14 @@ describe("collapsible panel", () => {
|
|
|
1080
1094
|
panelId: "panel-2",
|
|
1081
1095
|
controlled: true,
|
|
1082
1096
|
});
|
|
1083
|
-
expect(
|
|
1097
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1098
|
+
`"290px 10px 200px"`
|
|
1099
|
+
);
|
|
1084
1100
|
});
|
|
1085
1101
|
});
|
|
1086
1102
|
|
|
1087
1103
|
test("should be able to trigger collapse/expand via event", async () => {
|
|
1088
|
-
const actor = createActor(
|
|
1089
|
-
input: { groupId: "group" },
|
|
1090
|
-
}).start();
|
|
1104
|
+
const actor = createActor({ groupId: "group" });
|
|
1091
1105
|
|
|
1092
1106
|
sendAll(actor, [
|
|
1093
1107
|
{ type: "registerPanel", data: initializePanel({ id: "panel-1" }) },
|
|
@@ -1106,34 +1120,38 @@ describe("collapsible panel", () => {
|
|
|
1106
1120
|
},
|
|
1107
1121
|
]);
|
|
1108
1122
|
|
|
1109
|
-
expect(
|
|
1123
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1110
1124
|
`"minmax(0px, 1fr) 10px 100px"`
|
|
1111
1125
|
);
|
|
1112
1126
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
1113
1127
|
|
|
1114
1128
|
capturePixelValues(actor, () => {
|
|
1115
|
-
expect(
|
|
1129
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1130
|
+
`"390px 10px 100px"`
|
|
1131
|
+
);
|
|
1116
1132
|
});
|
|
1117
1133
|
|
|
1118
1134
|
actor.send({ type: "collapsePanel", panelId: "panel-2" });
|
|
1119
1135
|
await waitForIdle(actor);
|
|
1120
1136
|
|
|
1121
1137
|
capturePixelValues(actor, () => {
|
|
1122
|
-
expect(
|
|
1138
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1139
|
+
`"490px 10px 0px"`
|
|
1140
|
+
);
|
|
1123
1141
|
});
|
|
1124
1142
|
|
|
1125
1143
|
actor.send({ type: "expandPanel", panelId: "panel-2" });
|
|
1126
1144
|
await waitForIdle(actor);
|
|
1127
1145
|
|
|
1128
1146
|
capturePixelValues(actor, () => {
|
|
1129
|
-
expect(
|
|
1147
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1148
|
+
`"390px 10px 100px"`
|
|
1149
|
+
);
|
|
1130
1150
|
});
|
|
1131
1151
|
});
|
|
1132
1152
|
|
|
1133
1153
|
test("panel collapse can be controlled ", async () => {
|
|
1134
|
-
const actor = createActor(
|
|
1135
|
-
input: { groupId: "group" },
|
|
1136
|
-
}).start();
|
|
1154
|
+
const actor = createActor({ groupId: "group" });
|
|
1137
1155
|
|
|
1138
1156
|
const spy = vi.fn();
|
|
1139
1157
|
|
|
@@ -1159,22 +1177,28 @@ describe("collapsible panel", () => {
|
|
|
1159
1177
|
},
|
|
1160
1178
|
]);
|
|
1161
1179
|
|
|
1162
|
-
expect(
|
|
1180
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1163
1181
|
`"minmax(0px, 1fr) 10px minmax(100px, 1fr)"`
|
|
1164
1182
|
);
|
|
1165
1183
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
1166
1184
|
|
|
1167
1185
|
// collapse the panel via drag
|
|
1168
1186
|
capturePixelValues(actor, () => {
|
|
1169
|
-
expect(
|
|
1187
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1188
|
+
`"245px 10px 245px"`
|
|
1189
|
+
);
|
|
1170
1190
|
|
|
1171
1191
|
dragHandle(actor, { id: "resizer-1", delta: 160 });
|
|
1172
|
-
expect(
|
|
1192
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1193
|
+
`"390px 10px 100px"`
|
|
1194
|
+
);
|
|
1173
1195
|
|
|
1174
1196
|
// The panel doesn't actually collapse yet
|
|
1175
1197
|
dragHandle(actor, { id: "resizer-1", delta: 100 });
|
|
1176
1198
|
expect(spy).toHaveBeenCalledWith(true);
|
|
1177
|
-
expect(
|
|
1199
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1200
|
+
`"390px 10px 100px"`
|
|
1201
|
+
);
|
|
1178
1202
|
|
|
1179
1203
|
// Actually collapse the panel
|
|
1180
1204
|
actor.send({
|
|
@@ -1182,7 +1206,9 @@ describe("collapsible panel", () => {
|
|
|
1182
1206
|
panelId: "panel-2",
|
|
1183
1207
|
controlled: true,
|
|
1184
1208
|
});
|
|
1185
|
-
expect(
|
|
1209
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1210
|
+
`"470px 10px 20px"`
|
|
1211
|
+
);
|
|
1186
1212
|
});
|
|
1187
1213
|
|
|
1188
1214
|
spy.mockReset();
|
|
@@ -1191,10 +1217,14 @@ describe("collapsible panel", () => {
|
|
|
1191
1217
|
capturePixelValues(actor, () => {
|
|
1192
1218
|
// The panel doesn't actually expand yet
|
|
1193
1219
|
dragHandle(actor, { id: "resizer-1", delta: -150 });
|
|
1194
|
-
expect(
|
|
1220
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1221
|
+
`"470px 10px 20px"`
|
|
1222
|
+
);
|
|
1195
1223
|
|
|
1196
1224
|
expect(spy).toHaveBeenCalledWith(false);
|
|
1197
|
-
expect(
|
|
1225
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1226
|
+
`"470px 10px 20px"`
|
|
1227
|
+
);
|
|
1198
1228
|
|
|
1199
1229
|
// Actually collapse the panel
|
|
1200
1230
|
actor.send({
|
|
@@ -1202,7 +1232,9 @@ describe("collapsible panel", () => {
|
|
|
1202
1232
|
panelId: "panel-2",
|
|
1203
1233
|
controlled: true,
|
|
1204
1234
|
});
|
|
1205
|
-
expect(
|
|
1235
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1236
|
+
`"321px 10px 169px"`
|
|
1237
|
+
);
|
|
1206
1238
|
});
|
|
1207
1239
|
|
|
1208
1240
|
spy.mockReset();
|
|
@@ -1214,7 +1246,9 @@ describe("collapsible panel", () => {
|
|
|
1214
1246
|
|
|
1215
1247
|
// collapse the panel via drag
|
|
1216
1248
|
capturePixelValues(actor, () => {
|
|
1217
|
-
expect(
|
|
1249
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1250
|
+
`"470px 10px 20px"`
|
|
1251
|
+
);
|
|
1218
1252
|
});
|
|
1219
1253
|
|
|
1220
1254
|
actor.send({ type: "expandPanel", panelId: "panel-2", controlled: true });
|
|
@@ -1222,14 +1256,14 @@ describe("collapsible panel", () => {
|
|
|
1222
1256
|
|
|
1223
1257
|
// collapse the panel via drag
|
|
1224
1258
|
capturePixelValues(actor, () => {
|
|
1225
|
-
expect(
|
|
1259
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1260
|
+
`"321px 10px 169px"`
|
|
1261
|
+
);
|
|
1226
1262
|
});
|
|
1227
1263
|
});
|
|
1228
1264
|
|
|
1229
1265
|
test("panel collapse can be controlled - event", async () => {
|
|
1230
|
-
const actor = createActor(
|
|
1231
|
-
input: { groupId: "group" },
|
|
1232
|
-
}).start();
|
|
1266
|
+
const actor = createActor({ groupId: "group" });
|
|
1233
1267
|
|
|
1234
1268
|
const spy = vi.fn();
|
|
1235
1269
|
|
|
@@ -1255,7 +1289,7 @@ describe("collapsible panel", () => {
|
|
|
1255
1289
|
},
|
|
1256
1290
|
]);
|
|
1257
1291
|
|
|
1258
|
-
expect(
|
|
1292
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1259
1293
|
`"minmax(0px, 1fr) 10px minmax(100px, 1fr)"`
|
|
1260
1294
|
);
|
|
1261
1295
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
@@ -1267,7 +1301,9 @@ describe("collapsible panel", () => {
|
|
|
1267
1301
|
expect(spy).toHaveBeenCalledWith(true);
|
|
1268
1302
|
await waitForIdle(actor);
|
|
1269
1303
|
capturePixelValues(actor, () => {
|
|
1270
|
-
expect(
|
|
1304
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1305
|
+
`"245px 10px 245px"`
|
|
1306
|
+
);
|
|
1271
1307
|
});
|
|
1272
1308
|
spy.mockReset();
|
|
1273
1309
|
|
|
@@ -1277,7 +1313,9 @@ describe("collapsible panel", () => {
|
|
|
1277
1313
|
expect(spy).not.toHaveBeenCalled();
|
|
1278
1314
|
await waitForIdle(actor);
|
|
1279
1315
|
capturePixelValues(actor, () => {
|
|
1280
|
-
expect(
|
|
1316
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1317
|
+
`"470px 10px 20px"`
|
|
1318
|
+
);
|
|
1281
1319
|
});
|
|
1282
1320
|
|
|
1283
1321
|
// EXPAND
|
|
@@ -1287,7 +1325,9 @@ describe("collapsible panel", () => {
|
|
|
1287
1325
|
expect(spy).toHaveBeenCalledWith(false);
|
|
1288
1326
|
await waitForIdle(actor);
|
|
1289
1327
|
capturePixelValues(actor, () => {
|
|
1290
|
-
expect(
|
|
1328
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1329
|
+
`"470px 10px 20px"`
|
|
1330
|
+
);
|
|
1291
1331
|
});
|
|
1292
1332
|
spy.mockReset();
|
|
1293
1333
|
|
|
@@ -1297,15 +1337,15 @@ describe("collapsible panel", () => {
|
|
|
1297
1337
|
expect(spy).not.toHaveBeenCalled();
|
|
1298
1338
|
await waitForIdle(actor);
|
|
1299
1339
|
capturePixelValues(actor, () => {
|
|
1300
|
-
expect(
|
|
1340
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1341
|
+
`"245px 10px 245px"`
|
|
1342
|
+
);
|
|
1301
1343
|
});
|
|
1302
1344
|
});
|
|
1303
1345
|
|
|
1304
1346
|
describe("constraints", () => {
|
|
1305
1347
|
test("on render", async () => {
|
|
1306
|
-
const actor = createActor(
|
|
1307
|
-
input: { groupId: "group" },
|
|
1308
|
-
}).start();
|
|
1348
|
+
const actor = createActor({ groupId: "group" });
|
|
1309
1349
|
|
|
1310
1350
|
sendAll(actor, [
|
|
1311
1351
|
{
|
|
@@ -1327,18 +1367,16 @@ describe("collapsible panel", () => {
|
|
|
1327
1367
|
},
|
|
1328
1368
|
]);
|
|
1329
1369
|
|
|
1330
|
-
expect(
|
|
1370
|
+
expect(buildTemplate(actor.value)).toBe(
|
|
1331
1371
|
"minmax(200px, 1fr) 10px minmax(300px, 1fr)"
|
|
1332
1372
|
);
|
|
1333
1373
|
initializeSizes(actor, { width: 400, height: 200 });
|
|
1334
1374
|
// There wasn't enough space to render the panel so the last one is collapsed
|
|
1335
|
-
expect(
|
|
1375
|
+
expect(buildTemplate(actor.value)).toBe("minmax(200px, 1fr) 10px 60px");
|
|
1336
1376
|
});
|
|
1337
1377
|
|
|
1338
1378
|
test("on resize", async () => {
|
|
1339
|
-
const actor = createActor(
|
|
1340
|
-
input: { groupId: "group" },
|
|
1341
|
-
}).start();
|
|
1379
|
+
const actor = createActor({ groupId: "group" });
|
|
1342
1380
|
|
|
1343
1381
|
sendAll(actor, [
|
|
1344
1382
|
{
|
|
@@ -1360,7 +1398,7 @@ describe("collapsible panel", () => {
|
|
|
1360
1398
|
},
|
|
1361
1399
|
]);
|
|
1362
1400
|
|
|
1363
|
-
expect(
|
|
1401
|
+
expect(buildTemplate(actor.value)).toBe(
|
|
1364
1402
|
"minmax(200px, 1fr) 10px minmax(300px, 1fr)"
|
|
1365
1403
|
);
|
|
1366
1404
|
initializeSizes(actor, { width: 510, height: 200 });
|
|
@@ -1369,20 +1407,18 @@ describe("collapsible panel", () => {
|
|
|
1369
1407
|
dragHandle(actor, { id: "resizer-1", delta: 10 });
|
|
1370
1408
|
});
|
|
1371
1409
|
|
|
1372
|
-
expect(
|
|
1410
|
+
expect(buildTemplate(actor.value)).toBe(
|
|
1373
1411
|
"minmax(200px, 1fr) 10px minmax(300px, min(calc(0.6 * (100% - 10px)), 100%))"
|
|
1374
1412
|
);
|
|
1375
1413
|
|
|
1376
1414
|
initializeSizes(actor, { width: 400, height: 200 });
|
|
1377
1415
|
|
|
1378
1416
|
// There wasn't enough space to render the panel so the last one is collapsed
|
|
1379
|
-
expect(
|
|
1417
|
+
expect(buildTemplate(actor.value)).toBe("minmax(200px, 1fr) 10px 60px");
|
|
1380
1418
|
});
|
|
1381
1419
|
|
|
1382
1420
|
test("cannot expand panel via event", async () => {
|
|
1383
|
-
const actor = createActor(
|
|
1384
|
-
input: { groupId: "group" },
|
|
1385
|
-
}).start();
|
|
1421
|
+
const actor = createActor({ groupId: "group" });
|
|
1386
1422
|
|
|
1387
1423
|
sendAll(actor, [
|
|
1388
1424
|
{
|
|
@@ -1404,17 +1440,16 @@ describe("collapsible panel", () => {
|
|
|
1404
1440
|
},
|
|
1405
1441
|
]);
|
|
1406
1442
|
|
|
1407
|
-
expect(
|
|
1443
|
+
expect(buildTemplate(actor.value)).toBe(
|
|
1408
1444
|
"minmax(200px, 1fr) 10px minmax(300px, 1fr)"
|
|
1409
1445
|
);
|
|
1410
1446
|
initializeSizes(actor, { width: 400, height: 200 });
|
|
1411
1447
|
actor.send({
|
|
1412
1448
|
type: "setSize",
|
|
1413
1449
|
size: { width: 400, height: 200 },
|
|
1414
|
-
handleOverflow: true,
|
|
1415
1450
|
});
|
|
1416
1451
|
// There wasn't enough space to render the panel so the last one is collapsed
|
|
1417
|
-
expect(
|
|
1452
|
+
expect(buildTemplate(actor.value)).toBe("minmax(200px, 1fr) 10px 60px");
|
|
1418
1453
|
|
|
1419
1454
|
actor.send({
|
|
1420
1455
|
type: "expandPanel",
|
|
@@ -1423,13 +1458,11 @@ describe("collapsible panel", () => {
|
|
|
1423
1458
|
await waitForIdle(actor);
|
|
1424
1459
|
|
|
1425
1460
|
// There wasn't enough space to render the panel so the last one is collapsed
|
|
1426
|
-
expect(
|
|
1461
|
+
expect(buildTemplate(actor.value)).toBe("minmax(200px, 1fr) 10px 60px");
|
|
1427
1462
|
});
|
|
1428
1463
|
|
|
1429
1464
|
test("cannot expand panel via drag", async () => {
|
|
1430
|
-
const actor = createActor(
|
|
1431
|
-
input: { groupId: "group" },
|
|
1432
|
-
}).start();
|
|
1465
|
+
const actor = createActor({ groupId: "group" });
|
|
1433
1466
|
|
|
1434
1467
|
sendAll(actor, [
|
|
1435
1468
|
{
|
|
@@ -1451,22 +1484,22 @@ describe("collapsible panel", () => {
|
|
|
1451
1484
|
},
|
|
1452
1485
|
]);
|
|
1453
1486
|
|
|
1454
|
-
expect(
|
|
1487
|
+
expect(buildTemplate(actor.value)).toBe(
|
|
1455
1488
|
"minmax(200px, 1fr) 10px minmax(300px, 1fr)"
|
|
1456
1489
|
);
|
|
1457
1490
|
initializeSizes(actor, { width: 400, height: 200 });
|
|
1458
1491
|
|
|
1459
1492
|
// There wasn't enough space to render the panel so the last one is collapsed
|
|
1460
|
-
expect(
|
|
1493
|
+
expect(buildTemplate(actor.value)).toBe("minmax(200px, 1fr) 10px 60px");
|
|
1461
1494
|
|
|
1462
1495
|
// update the latest sizes to the new ones
|
|
1463
1496
|
initializeSizes(actor, { width: 400, height: 200 });
|
|
1464
1497
|
|
|
1465
1498
|
// Drag the resizer to the right
|
|
1466
1499
|
capturePixelValues(actor, () => {
|
|
1467
|
-
expect(
|
|
1500
|
+
expect(buildTemplate(actor.value)).toBe("330px 10px 60px");
|
|
1468
1501
|
dragHandle(actor, { id: "resizer-1", delta: -400 });
|
|
1469
|
-
expect(
|
|
1502
|
+
expect(buildTemplate(actor.value)).toBe("330px 10px 60px");
|
|
1470
1503
|
});
|
|
1471
1504
|
});
|
|
1472
1505
|
});
|
|
@@ -1474,9 +1507,7 @@ describe("collapsible panel", () => {
|
|
|
1474
1507
|
|
|
1475
1508
|
describe("conditional panel", () => {
|
|
1476
1509
|
test("panel can be conditionally rendered", () => {
|
|
1477
|
-
const actor = createActor(
|
|
1478
|
-
input: { groupId: "group" },
|
|
1479
|
-
}).start();
|
|
1510
|
+
const actor = createActor({ groupId: "group" });
|
|
1480
1511
|
|
|
1481
1512
|
sendAll(actor, [
|
|
1482
1513
|
{ type: "registerPanel", data: initializePanel({ id: "panel-1" }) },
|
|
@@ -1490,7 +1521,9 @@ describe("conditional panel", () => {
|
|
|
1490
1521
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
1491
1522
|
|
|
1492
1523
|
capturePixelValues(actor, () => {
|
|
1493
|
-
expect(
|
|
1524
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1525
|
+
`"245px 10px 245px"`
|
|
1526
|
+
);
|
|
1494
1527
|
});
|
|
1495
1528
|
|
|
1496
1529
|
sendAll(actor, [
|
|
@@ -1505,7 +1538,7 @@ describe("conditional panel", () => {
|
|
|
1505
1538
|
]);
|
|
1506
1539
|
|
|
1507
1540
|
capturePixelValues(actor, () => {
|
|
1508
|
-
expect(
|
|
1541
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1509
1542
|
`"245px 10px 135px 10px 100px"`
|
|
1510
1543
|
);
|
|
1511
1544
|
});
|
|
@@ -1516,14 +1549,14 @@ describe("conditional panel", () => {
|
|
|
1516
1549
|
]);
|
|
1517
1550
|
|
|
1518
1551
|
capturePixelValues(actor, () => {
|
|
1519
|
-
expect(
|
|
1552
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1553
|
+
`"245px 10px 245px"`
|
|
1554
|
+
);
|
|
1520
1555
|
});
|
|
1521
1556
|
});
|
|
1522
1557
|
|
|
1523
1558
|
test("collapsed panel can be conditionally rendered", () => {
|
|
1524
|
-
const actor = createActor(
|
|
1525
|
-
input: { groupId: "group" },
|
|
1526
|
-
}).start();
|
|
1559
|
+
const actor = createActor({ groupId: "group" });
|
|
1527
1560
|
|
|
1528
1561
|
sendAll(actor, [
|
|
1529
1562
|
{ type: "registerPanel", data: initializePanel({ id: "panel-1" }) },
|
|
@@ -1540,7 +1573,9 @@ describe("conditional panel", () => {
|
|
|
1540
1573
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
1541
1574
|
|
|
1542
1575
|
capturePixelValues(actor, () => {
|
|
1543
|
-
expect(
|
|
1576
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1577
|
+
`"245px 10px 245px"`
|
|
1578
|
+
);
|
|
1544
1579
|
});
|
|
1545
1580
|
|
|
1546
1581
|
sendAll(actor, [
|
|
@@ -1560,7 +1595,7 @@ describe("conditional panel", () => {
|
|
|
1560
1595
|
]);
|
|
1561
1596
|
|
|
1562
1597
|
capturePixelValues(actor, () => {
|
|
1563
|
-
expect(
|
|
1598
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1564
1599
|
`"245px 10px 235px 10px 0px"`
|
|
1565
1600
|
);
|
|
1566
1601
|
});
|
|
@@ -1571,14 +1606,14 @@ describe("conditional panel", () => {
|
|
|
1571
1606
|
]);
|
|
1572
1607
|
|
|
1573
1608
|
capturePixelValues(actor, () => {
|
|
1574
|
-
expect(
|
|
1609
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1610
|
+
`"245px 10px 245px"`
|
|
1611
|
+
);
|
|
1575
1612
|
});
|
|
1576
1613
|
});
|
|
1577
1614
|
|
|
1578
1615
|
test("panel can be conditionally rendered at default width", () => {
|
|
1579
|
-
const actor = createActor(
|
|
1580
|
-
input: { groupId: "group" },
|
|
1581
|
-
}).start();
|
|
1616
|
+
const actor = createActor({ groupId: "group" });
|
|
1582
1617
|
|
|
1583
1618
|
sendAll(actor, [
|
|
1584
1619
|
{ type: "registerPanel", data: initializePanel({ id: "panel-1" }) },
|
|
@@ -1595,7 +1630,9 @@ describe("conditional panel", () => {
|
|
|
1595
1630
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
1596
1631
|
|
|
1597
1632
|
capturePixelValues(actor, () => {
|
|
1598
|
-
expect(
|
|
1633
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1634
|
+
`"245px 10px 245px"`
|
|
1635
|
+
);
|
|
1599
1636
|
});
|
|
1600
1637
|
|
|
1601
1638
|
sendAll(actor, [
|
|
@@ -1613,7 +1650,7 @@ describe("conditional panel", () => {
|
|
|
1613
1650
|
]);
|
|
1614
1651
|
|
|
1615
1652
|
capturePixelValues(actor, () => {
|
|
1616
|
-
expect(
|
|
1653
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1617
1654
|
`"245px 10px 110px 10px 125px"`
|
|
1618
1655
|
);
|
|
1619
1656
|
});
|
|
@@ -1624,14 +1661,14 @@ describe("conditional panel", () => {
|
|
|
1624
1661
|
]);
|
|
1625
1662
|
|
|
1626
1663
|
capturePixelValues(actor, () => {
|
|
1627
|
-
expect(
|
|
1664
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1665
|
+
`"245px 10px 245px"`
|
|
1666
|
+
);
|
|
1628
1667
|
});
|
|
1629
1668
|
});
|
|
1630
1669
|
|
|
1631
1670
|
test("panel can be conditionally rendered w/order", () => {
|
|
1632
|
-
const actor = createActor(
|
|
1633
|
-
input: { groupId: "group" },
|
|
1634
|
-
}).start();
|
|
1671
|
+
const actor = createActor({ groupId: "group" });
|
|
1635
1672
|
|
|
1636
1673
|
sendAll(actor, [
|
|
1637
1674
|
{ type: "registerPanel", data: initializePanel({ id: "panel-1" }) },
|
|
@@ -1645,7 +1682,9 @@ describe("conditional panel", () => {
|
|
|
1645
1682
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
1646
1683
|
|
|
1647
1684
|
capturePixelValues(actor, () => {
|
|
1648
|
-
expect(
|
|
1685
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1686
|
+
`"245px 10px 245px"`
|
|
1687
|
+
);
|
|
1649
1688
|
});
|
|
1650
1689
|
|
|
1651
1690
|
sendAll(actor, [
|
|
@@ -1663,7 +1702,7 @@ describe("conditional panel", () => {
|
|
|
1663
1702
|
]);
|
|
1664
1703
|
|
|
1665
1704
|
capturePixelValues(actor, () => {
|
|
1666
|
-
expect(
|
|
1705
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1667
1706
|
`"245px 10px 100px 10px 135px"`
|
|
1668
1707
|
);
|
|
1669
1708
|
});
|
|
@@ -1674,7 +1713,9 @@ describe("conditional panel", () => {
|
|
|
1674
1713
|
]);
|
|
1675
1714
|
|
|
1676
1715
|
capturePixelValues(actor, () => {
|
|
1677
|
-
expect(
|
|
1716
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1717
|
+
`"245px 10px 245px"`
|
|
1718
|
+
);
|
|
1678
1719
|
});
|
|
1679
1720
|
|
|
1680
1721
|
sendAll(actor, [
|
|
@@ -1683,32 +1724,32 @@ describe("conditional panel", () => {
|
|
|
1683
1724
|
]);
|
|
1684
1725
|
|
|
1685
1726
|
capturePixelValues(actor, () => {
|
|
1686
|
-
expect(
|
|
1727
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1728
|
+
`"245px 10px 245px"`
|
|
1729
|
+
);
|
|
1687
1730
|
});
|
|
1688
1731
|
});
|
|
1689
1732
|
|
|
1690
1733
|
test("distributes space on both sides of dynamic panel as needed", async () => {
|
|
1691
|
-
const actor = createActor(
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
},
|
|
1706
|
-
}).start();
|
|
1734
|
+
const actor = createActor({
|
|
1735
|
+
groupId: "group",
|
|
1736
|
+
items: [
|
|
1737
|
+
initializePanel({ id: "panel-1", max: "20px" }),
|
|
1738
|
+
initializePanelHandleData({ id: "resizer-1", size: "10px" }),
|
|
1739
|
+
initializePanel({ id: "panel-2", default: "10px", max: "50px" }),
|
|
1740
|
+
initializePanelHandleData({ id: "resizer-2", size: "10px" }),
|
|
1741
|
+
initializePanel({ id: "panel-3", default: "300px" }),
|
|
1742
|
+
initializePanelHandleData({ id: "resizer-3", size: "10px" }),
|
|
1743
|
+
initializePanel({ id: "panel-4", default: "10px", max: "50px" }),
|
|
1744
|
+
initializePanelHandleData({ id: "resizer-4", size: "10px" }),
|
|
1745
|
+
initializePanel({ id: "panel-5", max: "300px" }),
|
|
1746
|
+
],
|
|
1747
|
+
});
|
|
1707
1748
|
|
|
1708
1749
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
1709
1750
|
|
|
1710
1751
|
capturePixelValues(actor, () => {
|
|
1711
|
-
expect(
|
|
1752
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1712
1753
|
`"20px 10px 10px 10px 300px 10px 10px 10px 120px"`
|
|
1713
1754
|
);
|
|
1714
1755
|
});
|
|
@@ -1719,7 +1760,7 @@ describe("conditional panel", () => {
|
|
|
1719
1760
|
]);
|
|
1720
1761
|
|
|
1721
1762
|
capturePixelValues(actor, () => {
|
|
1722
|
-
expect(
|
|
1763
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1723
1764
|
`"20px 10px 50px 10px 50px 10px 300px"`
|
|
1724
1765
|
);
|
|
1725
1766
|
});
|
|
@@ -1728,9 +1769,7 @@ describe("conditional panel", () => {
|
|
|
1728
1769
|
|
|
1729
1770
|
describe("errors", () => {
|
|
1730
1771
|
test("throws for invalid units", () => {
|
|
1731
|
-
const actor = createActor(
|
|
1732
|
-
input: { groupId: "group" },
|
|
1733
|
-
}).start();
|
|
1772
|
+
const actor = createActor({ groupId: "group" });
|
|
1734
1773
|
|
|
1735
1774
|
expect(() =>
|
|
1736
1775
|
actor.send({
|
|
@@ -1743,57 +1782,51 @@ describe("errors", () => {
|
|
|
1743
1782
|
|
|
1744
1783
|
test("throws when using invalid panel IDs", () => {
|
|
1745
1784
|
const spy = vi.fn();
|
|
1746
|
-
const actor = createActor(
|
|
1747
|
-
input: { groupId: "group" },
|
|
1748
|
-
}).start();
|
|
1749
|
-
|
|
1750
|
-
actor.subscribe({ error: spy });
|
|
1785
|
+
const actor = createActor({ groupId: "group" }, spy);
|
|
1751
1786
|
|
|
1752
1787
|
actor.send({
|
|
1753
1788
|
type: "registerPanel",
|
|
1754
1789
|
data: initializePanel({ id: "panel-1" }),
|
|
1755
1790
|
});
|
|
1756
1791
|
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1792
|
+
try {
|
|
1793
|
+
actor.send({
|
|
1794
|
+
type: "setPanelPixelSize",
|
|
1795
|
+
panelId: "panel-2",
|
|
1796
|
+
size: "100px",
|
|
1797
|
+
});
|
|
1798
|
+
} catch (error) {
|
|
1799
|
+
expect(error).toBeInstanceOf(Error);
|
|
1800
|
+
expect((error as Error).message).toBe("Expected panel with id: panel-2");
|
|
1801
|
+
}
|
|
1766
1802
|
});
|
|
1767
1803
|
|
|
1768
1804
|
test("throws when using invalid handle IDs", () => {
|
|
1769
1805
|
const spy = vi.fn();
|
|
1770
|
-
const actor = createActor(
|
|
1771
|
-
input: { groupId: "group" },
|
|
1772
|
-
}).start();
|
|
1773
|
-
|
|
1774
|
-
actor.subscribe({ error: spy });
|
|
1775
|
-
|
|
1776
|
-
sendAll(actor, [
|
|
1777
|
-
{ type: "registerPanel", data: initializePanel({ id: "handle-2" }) },
|
|
1778
|
-
{ type: "dragHandleStart", handleId: "handle-2" },
|
|
1779
|
-
{
|
|
1780
|
-
type: "dragHandle",
|
|
1781
|
-
handleId: "handle-2",
|
|
1782
|
-
value: dragHandlePayload({ delta: 100 }),
|
|
1783
|
-
},
|
|
1784
|
-
]);
|
|
1806
|
+
const actor = createActor({ groupId: "group" }, spy);
|
|
1785
1807
|
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1808
|
+
try {
|
|
1809
|
+
sendAll(actor, [
|
|
1810
|
+
{ type: "registerPanel", data: initializePanel({ id: "handle-2" }) },
|
|
1811
|
+
{ type: "dragHandleStart", handleId: "handle-2" },
|
|
1812
|
+
{
|
|
1813
|
+
type: "dragHandle",
|
|
1814
|
+
handleId: "handle-2",
|
|
1815
|
+
value: dragHandlePayload({ delta: 100 }),
|
|
1816
|
+
},
|
|
1817
|
+
]);
|
|
1818
|
+
} catch (error) {
|
|
1819
|
+
expect(error).toBeInstanceOf(Error);
|
|
1820
|
+
expect((error as Error).message).toBe(
|
|
1821
|
+
"Expected panel handle with id: handle-2"
|
|
1822
|
+
);
|
|
1823
|
+
}
|
|
1789
1824
|
});
|
|
1790
1825
|
});
|
|
1791
1826
|
|
|
1792
1827
|
describe("utils", async () => {
|
|
1793
1828
|
test("getPanelGroupPixelSizes", () => {
|
|
1794
|
-
const actor = createActor(
|
|
1795
|
-
input: { groupId: "group" },
|
|
1796
|
-
}).start();
|
|
1829
|
+
const actor = createActor({ groupId: "group" });
|
|
1797
1830
|
|
|
1798
1831
|
sendAll(actor, [
|
|
1799
1832
|
{ type: "registerPanel", data: initializePanel({ id: "panel-1" }) },
|
|
@@ -1809,15 +1842,11 @@ describe("utils", async () => {
|
|
|
1809
1842
|
|
|
1810
1843
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
1811
1844
|
|
|
1812
|
-
expect(getPanelGroupPixelSizes(actor.
|
|
1813
|
-
190, 10, 300,
|
|
1814
|
-
]);
|
|
1845
|
+
expect(getPanelGroupPixelSizes(actor.value)).toEqual([190, 10, 300]);
|
|
1815
1846
|
});
|
|
1816
1847
|
|
|
1817
1848
|
test("getPanelGroupPercentageSizes", () => {
|
|
1818
|
-
const actor = createActor(
|
|
1819
|
-
input: { groupId: "group" },
|
|
1820
|
-
}).start();
|
|
1849
|
+
const actor = createActor({ groupId: "group" });
|
|
1821
1850
|
|
|
1822
1851
|
sendAll(actor, [
|
|
1823
1852
|
{ type: "registerPanel", data: initializePanel({ id: "panel-1" }) },
|
|
@@ -1833,15 +1862,13 @@ describe("utils", async () => {
|
|
|
1833
1862
|
|
|
1834
1863
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
1835
1864
|
|
|
1836
|
-
expect(getPanelGroupPercentageSizes(actor.
|
|
1865
|
+
expect(getPanelGroupPercentageSizes(actor.value)).toEqual([
|
|
1837
1866
|
0.3877551020408163, 0.02, 0.6122448979591837,
|
|
1838
1867
|
]);
|
|
1839
1868
|
});
|
|
1840
1869
|
|
|
1841
1870
|
test("getPanelPercentageSize", () => {
|
|
1842
|
-
const actor = createActor(
|
|
1843
|
-
input: { groupId: "group" },
|
|
1844
|
-
}).start();
|
|
1871
|
+
const actor = createActor({ groupId: "group" });
|
|
1845
1872
|
|
|
1846
1873
|
sendAll(actor, [
|
|
1847
1874
|
{ type: "registerPanel", data: initializePanel({ id: "panel-1" }) },
|
|
@@ -1857,15 +1884,11 @@ describe("utils", async () => {
|
|
|
1857
1884
|
|
|
1858
1885
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
1859
1886
|
|
|
1860
|
-
expect(getPanelPercentageSize(actor.
|
|
1861
|
-
0.6
|
|
1862
|
-
);
|
|
1887
|
+
expect(getPanelPercentageSize(actor.value, "panel-2")).toBe(0.6);
|
|
1863
1888
|
});
|
|
1864
1889
|
|
|
1865
1890
|
test("getPanelPixelSize", () => {
|
|
1866
|
-
const actor = createActor(
|
|
1867
|
-
input: { groupId: "group" },
|
|
1868
|
-
}).start();
|
|
1891
|
+
const actor = createActor({ groupId: "group" });
|
|
1869
1892
|
|
|
1870
1893
|
sendAll(actor, [
|
|
1871
1894
|
{ type: "registerPanel", data: initializePanel({ id: "panel-1" }) },
|
|
@@ -1881,13 +1904,11 @@ describe("utils", async () => {
|
|
|
1881
1904
|
|
|
1882
1905
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
1883
1906
|
|
|
1884
|
-
expect(getPanelPixelSize(actor.
|
|
1907
|
+
expect(getPanelPixelSize(actor.value, "panel-2")).toBe(300);
|
|
1885
1908
|
});
|
|
1886
1909
|
|
|
1887
1910
|
test("prepareSnapshot", () => {
|
|
1888
|
-
const actor = createActor(
|
|
1889
|
-
input: { groupId: "group" },
|
|
1890
|
-
}).start();
|
|
1911
|
+
const actor = createActor({ groupId: "group" });
|
|
1891
1912
|
|
|
1892
1913
|
sendAll(actor, [
|
|
1893
1914
|
{
|
|
@@ -1911,7 +1932,7 @@ describe("utils", async () => {
|
|
|
1911
1932
|
|
|
1912
1933
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
1913
1934
|
|
|
1914
|
-
let oldSnapshot = actor.
|
|
1935
|
+
let oldSnapshot = { ...actor.value };
|
|
1915
1936
|
let serialized = JSON.stringify(oldSnapshot);
|
|
1916
1937
|
let newSnapshot = prepareSnapshot(JSON.parse(serialized));
|
|
1917
1938
|
|
|
@@ -1921,7 +1942,7 @@ describe("utils", async () => {
|
|
|
1921
1942
|
dragHandle(actor, { id: "resizer-1", delta: 100 });
|
|
1922
1943
|
});
|
|
1923
1944
|
|
|
1924
|
-
oldSnapshot = actor.
|
|
1945
|
+
oldSnapshot = { ...actor.value };
|
|
1925
1946
|
serialized = JSON.stringify(oldSnapshot);
|
|
1926
1947
|
newSnapshot = prepareSnapshot(JSON.parse(serialized));
|
|
1927
1948
|
|
|
@@ -1931,27 +1952,25 @@ describe("utils", async () => {
|
|
|
1931
1952
|
|
|
1932
1953
|
describe("static at rest", () => {
|
|
1933
1954
|
test("a panel can be pixels when resting", async () => {
|
|
1934
|
-
const actor = createActor(
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
},
|
|
1950
|
-
}).start();
|
|
1955
|
+
const actor = createActor({
|
|
1956
|
+
groupId: "group",
|
|
1957
|
+
items: [
|
|
1958
|
+
initializePanel({
|
|
1959
|
+
id: "panel-1",
|
|
1960
|
+
min: "20px",
|
|
1961
|
+
max: "200px",
|
|
1962
|
+
isStaticAtRest: true,
|
|
1963
|
+
}),
|
|
1964
|
+
initializePanelHandleData({ id: "resizer-1", size: "10px" }),
|
|
1965
|
+
initializePanel({ id: "panel-2", min: "50px" }),
|
|
1966
|
+
initializePanelHandleData({ id: "resizer-2", size: "10px" }),
|
|
1967
|
+
initializePanel({ id: "panel-3", min: "50px" }),
|
|
1968
|
+
],
|
|
1969
|
+
});
|
|
1951
1970
|
|
|
1952
1971
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
1953
1972
|
|
|
1954
|
-
expect(
|
|
1973
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1955
1974
|
`"minmax(20px, 200px) 10px minmax(50px, 1fr) 10px minmax(50px, 1fr)"`
|
|
1956
1975
|
);
|
|
1957
1976
|
|
|
@@ -1959,7 +1978,7 @@ describe("static at rest", () => {
|
|
|
1959
1978
|
dragHandle(actor, { id: "resizer-1", delta: -10 });
|
|
1960
1979
|
});
|
|
1961
1980
|
|
|
1962
|
-
expect(
|
|
1981
|
+
expect(buildTemplate(actor.value)).toMatchInlineSnapshot(
|
|
1963
1982
|
`"clamp(20px, 190px, 200px) 10px minmax(50px, 1fr) 10px minmax(50px, min(calc(0.48275862068965517241 * (100% - 210px)), 100%))"`
|
|
1964
1983
|
);
|
|
1965
1984
|
});
|
|
@@ -1969,24 +1988,22 @@ describe("autosave", () => {
|
|
|
1969
1988
|
test("localStorage", async () => {
|
|
1970
1989
|
localStorage.removeItem("group");
|
|
1971
1990
|
|
|
1972
|
-
const actor = createActor(
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
},
|
|
1989
|
-
}).start();
|
|
1991
|
+
const actor = createActor({
|
|
1992
|
+
groupId: "group",
|
|
1993
|
+
autosaveStrategy: "localStorage",
|
|
1994
|
+
items: [
|
|
1995
|
+
initializePanel({
|
|
1996
|
+
id: "panel-1",
|
|
1997
|
+
min: "20px",
|
|
1998
|
+
max: "200px",
|
|
1999
|
+
isStaticAtRest: true,
|
|
2000
|
+
}),
|
|
2001
|
+
initializePanelHandleData({ id: "resizer-1", size: "10px" }),
|
|
2002
|
+
initializePanel({ id: "panel-2", min: "50px" }),
|
|
2003
|
+
initializePanelHandleData({ id: "resizer-2", size: "10px" }),
|
|
2004
|
+
initializePanel({ id: "panel-3", min: "50px" }),
|
|
2005
|
+
],
|
|
2006
|
+
});
|
|
1990
2007
|
|
|
1991
2008
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
1992
2009
|
|
|
@@ -1999,13 +2016,9 @@ describe("autosave", () => {
|
|
|
1999
2016
|
const snapshot = prepareSnapshot(
|
|
2000
2017
|
JSON.parse(localStorage.getItem("group")!)
|
|
2001
2018
|
);
|
|
2002
|
-
const actor2 = createActor(
|
|
2003
|
-
// @ts-expect-error For tests
|
|
2004
|
-
input: {},
|
|
2005
|
-
snapshot,
|
|
2006
|
-
}).start();
|
|
2019
|
+
const actor2 = createActor(snapshot!);
|
|
2007
2020
|
|
|
2008
|
-
expect(buildTemplate(actor2.
|
|
2021
|
+
expect(buildTemplate(actor2.value)).toMatchInlineSnapshot(
|
|
2009
2022
|
`"clamp(20px, 190px, 200px) 10px minmax(50px, 1fr) 10px minmax(50px, min(calc(0.48275862068965517241 * (100% - 210px)), 100%))"`
|
|
2010
2023
|
);
|
|
2011
2024
|
});
|
|
@@ -2013,24 +2026,22 @@ describe("autosave", () => {
|
|
|
2013
2026
|
test("cookie", async () => {
|
|
2014
2027
|
localStorage.removeItem("group");
|
|
2015
2028
|
|
|
2016
|
-
const actor = createActor(
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
},
|
|
2033
|
-
}).start();
|
|
2029
|
+
const actor = createActor({
|
|
2030
|
+
groupId: "group-2",
|
|
2031
|
+
autosaveStrategy: "cookie",
|
|
2032
|
+
items: [
|
|
2033
|
+
initializePanel({
|
|
2034
|
+
id: "panel-1",
|
|
2035
|
+
min: "20px",
|
|
2036
|
+
max: "200px",
|
|
2037
|
+
isStaticAtRest: true,
|
|
2038
|
+
}),
|
|
2039
|
+
initializePanelHandleData({ id: "resizer-1", size: "10px" }),
|
|
2040
|
+
initializePanel({ id: "panel-2", min: "50px" }),
|
|
2041
|
+
initializePanelHandleData({ id: "resizer-2", size: "10px" }),
|
|
2042
|
+
initializePanel({ id: "panel-3", min: "50px" }),
|
|
2043
|
+
],
|
|
2044
|
+
});
|
|
2034
2045
|
|
|
2035
2046
|
initializeSizes(actor, { width: 500, height: 200 });
|
|
2036
2047
|
|
|
@@ -2041,13 +2052,9 @@ describe("autosave", () => {
|
|
|
2041
2052
|
await waitForIdle(actor);
|
|
2042
2053
|
|
|
2043
2054
|
const snapshot = prepareSnapshot(JSON.parse(Cookies.get("group-2")!));
|
|
2044
|
-
const actor2 = createActor(
|
|
2045
|
-
// @ts-expect-error For tests
|
|
2046
|
-
input: {},
|
|
2047
|
-
snapshot,
|
|
2048
|
-
}).start();
|
|
2055
|
+
const actor2 = createActor(snapshot!);
|
|
2049
2056
|
|
|
2050
|
-
expect(buildTemplate(actor2.
|
|
2057
|
+
expect(buildTemplate(actor2.value)).toMatchInlineSnapshot(
|
|
2051
2058
|
`"clamp(20px, 190px, 200px) 10px minmax(50px, 1fr) 10px minmax(50px, min(calc(0.48275862068965517241 * (100% - 210px)), 100%))"`
|
|
2052
2059
|
);
|
|
2053
2060
|
});
|