@zag-js/splitter 1.40.0 → 1.41.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/splitter.connect.js +61 -29
- package/dist/splitter.connect.mjs +61 -29
- package/dist/splitter.dom.d.mts +4 -3
- package/dist/splitter.dom.d.ts +4 -3
- package/dist/splitter.dom.js +31 -2
- package/dist/splitter.dom.mjs +31 -3
- package/dist/splitter.machine.js +168 -59
- package/dist/splitter.machine.mjs +169 -61
- package/dist/splitter.types.d.mts +27 -8
- package/dist/splitter.types.d.ts +27 -8
- package/dist/utils/aria.d.mts +9 -3
- package/dist/utils/aria.d.ts +9 -3
- package/dist/utils/aria.js +9 -0
- package/dist/utils/aria.mjs +9 -0
- package/dist/utils/panel.d.mts +13 -12
- package/dist/utils/panel.d.ts +13 -12
- package/dist/utils/panel.js +41 -7
- package/dist/utils/panel.mjs +41 -7
- package/dist/utils/preserve-fixed-panel-sizes.d.mts +18 -0
- package/dist/utils/preserve-fixed-panel-sizes.d.ts +18 -0
- package/dist/utils/preserve-fixed-panel-sizes.js +91 -0
- package/dist/utils/preserve-fixed-panel-sizes.mjs +68 -0
- package/dist/utils/registry.js +1 -1
- package/dist/utils/registry.mjs +2 -2
- package/dist/utils/resize-by-delta.d.mts +2 -2
- package/dist/utils/resize-by-delta.d.ts +2 -2
- package/dist/utils/resize-panel.d.mts +2 -2
- package/dist/utils/resize-panel.d.ts +2 -2
- package/dist/utils/size.d.mts +17 -0
- package/dist/utils/size.d.ts +17 -0
- package/dist/utils/size.js +138 -0
- package/dist/utils/size.mjs +111 -0
- package/dist/utils/validate-sizes.d.mts +2 -2
- package/dist/utils/validate-sizes.d.ts +2 -2
- package/package.json +6 -6
package/dist/splitter.machine.js
CHANGED
|
@@ -40,7 +40,9 @@ var dom = __toESM(require("./splitter.dom.js"));
|
|
|
40
40
|
var import_aria = require("./utils/aria.js");
|
|
41
41
|
var import_fuzzy = require("./utils/fuzzy.js");
|
|
42
42
|
var import_panel = require("./utils/panel.js");
|
|
43
|
+
var import_preserve_fixed_panel_sizes = require("./utils/preserve-fixed-panel-sizes.js");
|
|
43
44
|
var import_resize_by_delta = require("./utils/resize-by-delta.js");
|
|
45
|
+
var import_size = require("./utils/size.js");
|
|
44
46
|
var import_validate_sizes = require("./utils/validate-sizes.js");
|
|
45
47
|
var machine = (0, import_core.createMachine)({
|
|
46
48
|
props({ props }) {
|
|
@@ -58,15 +60,18 @@ var machine = (0, import_core.createMachine)({
|
|
|
58
60
|
},
|
|
59
61
|
context({ prop, bindable, getContext, getRefs }) {
|
|
60
62
|
return {
|
|
63
|
+
panels: bindable(() => ({
|
|
64
|
+
defaultValue: (0, import_size.normalizePanels)(prop("panels"), null, prop("orientation"))
|
|
65
|
+
})),
|
|
61
66
|
size: bindable(() => ({
|
|
62
|
-
|
|
63
|
-
defaultValue: prop("defaultSize"),
|
|
67
|
+
defaultValue: [],
|
|
64
68
|
isEqual(a, b) {
|
|
65
69
|
return b != null && (0, import_fuzzy.fuzzySizeEqual)(a, b);
|
|
66
70
|
},
|
|
67
71
|
onChange(value) {
|
|
68
72
|
const ctx = getContext();
|
|
69
73
|
const refs = getRefs();
|
|
74
|
+
if (refs.get("suppressOnResize")) return;
|
|
70
75
|
const sizesBeforeCollapse = refs.get("panelSizeBeforeCollapse");
|
|
71
76
|
const expandToSizes = Object.fromEntries(sizesBeforeCollapse.entries());
|
|
72
77
|
const resizeTriggerId = ctx.get("dragState")?.resizeTriggerId ?? null;
|
|
@@ -88,15 +93,27 @@ var machine = (0, import_core.createMachine)({
|
|
|
88
93
|
};
|
|
89
94
|
},
|
|
90
95
|
watch({ track, action, prop }) {
|
|
91
|
-
track(
|
|
92
|
-
|
|
93
|
-
|
|
96
|
+
track(
|
|
97
|
+
[
|
|
98
|
+
() => (0, import_panel.serializePanels)(prop("panels")),
|
|
99
|
+
() => JSON.stringify(prop("size") ?? []),
|
|
100
|
+
() => JSON.stringify(prop("defaultSize") ?? [])
|
|
101
|
+
],
|
|
102
|
+
() => {
|
|
103
|
+
action(["syncSize"]);
|
|
104
|
+
}
|
|
105
|
+
);
|
|
94
106
|
},
|
|
95
107
|
refs() {
|
|
96
108
|
return {
|
|
97
109
|
panelSizeBeforeCollapse: /* @__PURE__ */ new Map(),
|
|
98
110
|
prevDelta: 0,
|
|
99
|
-
panelIdToLastNotifiedSizeMap: /* @__PURE__ */ new Map()
|
|
111
|
+
panelIdToLastNotifiedSizeMap: /* @__PURE__ */ new Map(),
|
|
112
|
+
initialSize: null,
|
|
113
|
+
prevInitialLayout: null,
|
|
114
|
+
prevGroupSize: null,
|
|
115
|
+
lastRequestedSize: null,
|
|
116
|
+
suppressOnResize: false
|
|
100
117
|
};
|
|
101
118
|
},
|
|
102
119
|
computed: {
|
|
@@ -108,6 +125,9 @@ var machine = (0, import_core.createMachine)({
|
|
|
108
125
|
"SIZE.SET": {
|
|
109
126
|
actions: ["setSize"]
|
|
110
127
|
},
|
|
128
|
+
"SIZE.RESET": {
|
|
129
|
+
actions: ["resetSize"]
|
|
130
|
+
},
|
|
111
131
|
"PANEL.COLLAPSE": {
|
|
112
132
|
actions: ["collapsePanel"]
|
|
113
133
|
},
|
|
@@ -116,11 +136,14 @@ var machine = (0, import_core.createMachine)({
|
|
|
116
136
|
},
|
|
117
137
|
"PANEL.RESIZE": {
|
|
118
138
|
actions: ["resizePanel"]
|
|
139
|
+
},
|
|
140
|
+
"ROOT.RESIZE": {
|
|
141
|
+
actions: ["syncSize"]
|
|
119
142
|
}
|
|
120
143
|
},
|
|
121
144
|
entry: ["syncSize"],
|
|
122
145
|
exit: ["clearGlobalCursor"],
|
|
123
|
-
effects: ["trackResizeHandles"],
|
|
146
|
+
effects: ["trackResizeHandles", "trackRootResize"],
|
|
124
147
|
states: {
|
|
125
148
|
idle: {
|
|
126
149
|
entry: ["clearDraggingState", "clearKeyboardState"],
|
|
@@ -195,14 +218,27 @@ var machine = (0, import_core.createMachine)({
|
|
|
195
218
|
POINTER_MOVE: {
|
|
196
219
|
actions: ["setPointerValue", "setGlobalCursor"]
|
|
197
220
|
},
|
|
198
|
-
POINTER_UP:
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
221
|
+
POINTER_UP: [
|
|
222
|
+
{
|
|
223
|
+
guard: "isResizeTriggerFocused",
|
|
224
|
+
target: "focused",
|
|
225
|
+
actions: ["invokeOnResizeEnd", "setKeyboardState", "clearDraggingState", "clearGlobalCursor"]
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
target: "idle",
|
|
229
|
+
actions: ["invokeOnResizeEnd", "clearGlobalCursor"]
|
|
230
|
+
}
|
|
231
|
+
]
|
|
202
232
|
}
|
|
203
233
|
}
|
|
204
234
|
},
|
|
205
235
|
implementations: {
|
|
236
|
+
guards: {
|
|
237
|
+
isResizeTriggerFocused({ context, scope }) {
|
|
238
|
+
const dragState = context.get("dragState");
|
|
239
|
+
return scope.isActiveElement(dom.getResizeTriggerEl(scope, dragState?.resizeTriggerId));
|
|
240
|
+
}
|
|
241
|
+
},
|
|
206
242
|
effects: {
|
|
207
243
|
trackResizeHandles: ({ prop, scope, send }) => {
|
|
208
244
|
const registry = prop("registry");
|
|
@@ -235,6 +271,13 @@ var machine = (0, import_core.createMachine)({
|
|
|
235
271
|
observeCleanup?.();
|
|
236
272
|
};
|
|
237
273
|
},
|
|
274
|
+
trackRootResize: ({ scope, send }) => {
|
|
275
|
+
const rootEl = dom.getRootEl(scope);
|
|
276
|
+
if (!rootEl) return;
|
|
277
|
+
return import_dom_query.resizeObserverBorderBox.observe(rootEl, () => {
|
|
278
|
+
send({ type: "ROOT.RESIZE" });
|
|
279
|
+
});
|
|
280
|
+
},
|
|
238
281
|
waitForHoverDelay: ({ send }) => {
|
|
239
282
|
return (0, import_utils.setRafTimeout)(() => {
|
|
240
283
|
send({ type: "HOVER_DELAY" });
|
|
@@ -254,40 +297,85 @@ var machine = (0, import_core.createMachine)({
|
|
|
254
297
|
},
|
|
255
298
|
actions: {
|
|
256
299
|
setSize(params) {
|
|
257
|
-
const { context, event, prop } = params;
|
|
300
|
+
const { context, event, prop, scope } = params;
|
|
258
301
|
const unsafeSize = event.size;
|
|
259
302
|
const prevSize = context.get("size");
|
|
260
|
-
const panels =
|
|
303
|
+
const panels = context.get("panels");
|
|
261
304
|
const safeSize = (0, import_validate_sizes.validateSizes)({
|
|
262
|
-
size:
|
|
305
|
+
size: (0, import_size.resolvePanelSizes)({
|
|
306
|
+
sizes: unsafeSize,
|
|
307
|
+
panels: prop("panels"),
|
|
308
|
+
rootEl: dom.getRootEl(scope),
|
|
309
|
+
orientation: prop("orientation")
|
|
310
|
+
}),
|
|
263
311
|
panels
|
|
264
312
|
});
|
|
265
313
|
if (!(0, import_utils.isEqual)(prevSize, safeSize)) {
|
|
266
314
|
setSize(params, safeSize);
|
|
267
315
|
}
|
|
268
316
|
},
|
|
269
|
-
|
|
270
|
-
const
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
panels,
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
317
|
+
resetSize(params) {
|
|
318
|
+
const { refs, context, prop, scope } = params;
|
|
319
|
+
const initialSize = refs.get("initialSize");
|
|
320
|
+
const nextSize = initialSize ?? (0, import_validate_sizes.validateSizes)({
|
|
321
|
+
size: (0, import_size.resolvePanelSizes)({
|
|
322
|
+
sizes: prop("size") ?? prop("defaultSize"),
|
|
323
|
+
panels: prop("panels"),
|
|
324
|
+
rootEl: dom.getRootEl(scope),
|
|
325
|
+
orientation: prop("orientation")
|
|
326
|
+
}),
|
|
327
|
+
panels: context.get("panels")
|
|
328
|
+
});
|
|
329
|
+
setSize(params, nextSize);
|
|
330
|
+
},
|
|
331
|
+
syncSize(params) {
|
|
332
|
+
const { context, scope, prop, refs } = params;
|
|
333
|
+
const rootEl = dom.getRootEl(scope);
|
|
334
|
+
if (!rootEl) return;
|
|
335
|
+
const orientation = prop("orientation");
|
|
336
|
+
const nextGroupSize = (0, import_size.getGroupSize)(rootEl, orientation);
|
|
337
|
+
if (nextGroupSize <= 0) return;
|
|
338
|
+
const panels = (0, import_size.normalizePanels)(prop("panels"), rootEl, prop("orientation"));
|
|
339
|
+
context.set("panels", panels);
|
|
340
|
+
const sizeSpec = prop("size") ?? prop("defaultSize");
|
|
341
|
+
const initialLayout = `${(0, import_panel.getPanelLayout)(prop("panels"))}:${JSON.stringify(prop("size") ?? [])}:${JSON.stringify(prop("defaultSize") ?? [])}`;
|
|
342
|
+
const prevGroupSize = refs.get("prevGroupSize");
|
|
343
|
+
const currentSize = context.get("size");
|
|
344
|
+
const nextResolvedSize = (0, import_size.resolvePanelSizes)({
|
|
345
|
+
sizes: sizeSpec,
|
|
346
|
+
panels: prop("panels"),
|
|
347
|
+
rootEl,
|
|
348
|
+
orientation
|
|
349
|
+
});
|
|
350
|
+
const canPreserveLayout = prevGroupSize != null && prevGroupSize !== nextGroupSize && currentSize.length === panels.length;
|
|
351
|
+
const nextSize = canPreserveLayout ? (0, import_preserve_fixed_panel_sizes.preserveFixedPanelSizes)({
|
|
352
|
+
panels,
|
|
353
|
+
prevLayout: currentSize,
|
|
354
|
+
prevGroupSize,
|
|
355
|
+
nextGroupSize
|
|
356
|
+
}) : nextResolvedSize;
|
|
357
|
+
const safeSize = (0, import_validate_sizes.validateSizes)({
|
|
358
|
+
size: nextSize,
|
|
281
359
|
panels
|
|
282
360
|
});
|
|
283
|
-
if (
|
|
284
|
-
|
|
361
|
+
if (refs.get("prevInitialLayout") !== initialLayout) {
|
|
362
|
+
refs.set("initialSize", safeSize);
|
|
363
|
+
refs.set("prevInitialLayout", initialLayout);
|
|
364
|
+
}
|
|
365
|
+
const prevSize = context.get("size");
|
|
366
|
+
if (!(0, import_utils.isEqual)(prevSize, safeSize)) {
|
|
367
|
+
refs.set("suppressOnResize", prop("size") != null || prevSize.length === 0);
|
|
368
|
+
context.set("size", safeSize);
|
|
369
|
+
refs.set("suppressOnResize", false);
|
|
285
370
|
}
|
|
371
|
+
refs.set("prevGroupSize", nextGroupSize);
|
|
286
372
|
},
|
|
287
373
|
setDraggingState({ context, event, prop, scope }) {
|
|
288
374
|
const orientation = prop("orientation");
|
|
289
375
|
const size = context.get("size");
|
|
290
376
|
const resizeTriggerId = event.id;
|
|
377
|
+
const resolvedResizeTriggerId = dom.resolveResizeTriggerId(scope, resizeTriggerId);
|
|
378
|
+
if (!resolvedResizeTriggerId) return;
|
|
291
379
|
const panelGroupEl = dom.getRootEl(scope);
|
|
292
380
|
if (!panelGroupEl) return;
|
|
293
381
|
const handleElement = dom.getResizeTriggerEl(scope, resizeTriggerId);
|
|
@@ -295,6 +383,7 @@ var machine = (0, import_core.createMachine)({
|
|
|
295
383
|
const initialCursorPosition = orientation === "horizontal" ? event.point.x : event.point.y;
|
|
296
384
|
context.set("dragState", {
|
|
297
385
|
resizeTriggerId: event.id,
|
|
386
|
+
resolvedResizeTriggerId,
|
|
298
387
|
resizeTriggerRect: handleElement.getBoundingClientRect(),
|
|
299
388
|
initialCursorPosition,
|
|
300
389
|
initialSize: size
|
|
@@ -303,23 +392,26 @@ var machine = (0, import_core.createMachine)({
|
|
|
303
392
|
clearDraggingState({ context }) {
|
|
304
393
|
context.set("dragState", null);
|
|
305
394
|
},
|
|
306
|
-
setKeyboardState({ context, event }) {
|
|
395
|
+
setKeyboardState({ context, event, scope }) {
|
|
396
|
+
const id = event.id ?? context.get("dragState")?.resizeTriggerId;
|
|
397
|
+
if (id == null) return;
|
|
307
398
|
context.set("keyboardState", {
|
|
308
|
-
resizeTriggerId:
|
|
399
|
+
resizeTriggerId: id,
|
|
400
|
+
resolvedResizeTriggerId: dom.resolveResizeTriggerId(scope, id)
|
|
309
401
|
});
|
|
310
402
|
},
|
|
311
403
|
clearKeyboardState({ context }) {
|
|
312
404
|
context.set("keyboardState", null);
|
|
313
405
|
},
|
|
314
406
|
collapsePanel(params) {
|
|
315
|
-
const { context,
|
|
407
|
+
const { context, event, refs } = params;
|
|
316
408
|
const prevSize = context.get("size");
|
|
317
|
-
const panels =
|
|
409
|
+
const panels = context.get("panels");
|
|
318
410
|
const panel = panels.find((panel2) => panel2.id === event.id);
|
|
319
411
|
(0, import_utils.ensure)(panel, () => `Panel data not found for id "${event.id}"`);
|
|
320
412
|
if (panel.collapsible) {
|
|
321
413
|
const { collapsedSize = 0, panelSize, pivotIndices } = (0, import_panel.panelDataHelper)(panels, panel, prevSize);
|
|
322
|
-
(0, import_utils.ensure)(panelSize, () => `Panel size not found for panel "${panel.id}"`);
|
|
414
|
+
(0, import_utils.ensure)(panelSize != null, () => `Panel size not found for panel "${panel.id}"`);
|
|
323
415
|
if (!(0, import_fuzzy.fuzzyNumbersEqual)(panelSize, collapsedSize)) {
|
|
324
416
|
refs.get("panelSizeBeforeCollapse").set(panel.id, panelSize);
|
|
325
417
|
const isLastPanel = (0, import_panel.findPanelDataIndex)(panels, panel) === panels.length - 1;
|
|
@@ -339,8 +431,8 @@ var machine = (0, import_core.createMachine)({
|
|
|
339
431
|
}
|
|
340
432
|
},
|
|
341
433
|
expandPanel(params) {
|
|
342
|
-
const { context,
|
|
343
|
-
const panels =
|
|
434
|
+
const { context, event, refs } = params;
|
|
435
|
+
const panels = context.get("panels");
|
|
344
436
|
const prevSize = context.get("size");
|
|
345
437
|
const panel = panels.find((panel2) => panel2.id === event.id);
|
|
346
438
|
(0, import_utils.ensure)(panel, () => `Panel data not found for id "${event.id}"`);
|
|
@@ -372,13 +464,13 @@ var machine = (0, import_core.createMachine)({
|
|
|
372
464
|
}
|
|
373
465
|
},
|
|
374
466
|
resizePanel(params) {
|
|
375
|
-
const { context,
|
|
467
|
+
const { context, event } = params;
|
|
376
468
|
const prevSize = context.get("size");
|
|
377
|
-
const panels =
|
|
469
|
+
const panels = context.get("panels");
|
|
378
470
|
const panel = (0, import_panel.getPanelById)(panels, event.id);
|
|
379
471
|
const unsafePanelSize = event.size;
|
|
380
472
|
const { panelSize, pivotIndices } = (0, import_panel.panelDataHelper)(panels, panel, prevSize);
|
|
381
|
-
(0, import_utils.ensure)(panelSize, () => `Panel size not found for panel "${panel.id}"`);
|
|
473
|
+
(0, import_utils.ensure)(panelSize != null, () => `Panel size not found for panel "${panel.id}"`);
|
|
382
474
|
const isLastPanel = (0, import_panel.findPanelDataIndex)(panels, panel) === panels.length - 1;
|
|
383
475
|
const delta = isLastPanel ? panelSize - unsafePanelSize : unsafePanelSize - panelSize;
|
|
384
476
|
const nextSize = (0, import_resize_by_delta.resizeByDelta)({
|
|
@@ -397,11 +489,11 @@ var machine = (0, import_core.createMachine)({
|
|
|
397
489
|
const { context, event, prop, scope } = params;
|
|
398
490
|
const dragState = context.get("dragState");
|
|
399
491
|
if (!dragState) return;
|
|
400
|
-
const {
|
|
401
|
-
const panels =
|
|
492
|
+
const { resolvedResizeTriggerId, initialSize, initialCursorPosition } = dragState;
|
|
493
|
+
const panels = context.get("panels");
|
|
402
494
|
const panelGroupElement = dom.getRootEl(scope);
|
|
403
495
|
(0, import_utils.ensure)(panelGroupElement, () => `Panel group element not found`);
|
|
404
|
-
const pivotIndices =
|
|
496
|
+
const pivotIndices = resolvedResizeTriggerId.split(":").map((id) => panels.findIndex((panel) => panel.id === id));
|
|
405
497
|
const horizontal = prop("orientation") === "horizontal";
|
|
406
498
|
const cursorPosition = horizontal ? event.point.x : event.point.y;
|
|
407
499
|
const groupRect = panelGroupElement.getBoundingClientRect();
|
|
@@ -422,9 +514,10 @@ var machine = (0, import_core.createMachine)({
|
|
|
422
514
|
}
|
|
423
515
|
},
|
|
424
516
|
setKeyboardValue(params) {
|
|
425
|
-
const { context, event
|
|
426
|
-
const panelDataArray =
|
|
427
|
-
const resizeTriggerId = event.id;
|
|
517
|
+
const { context, event } = params;
|
|
518
|
+
const panelDataArray = context.get("panels");
|
|
519
|
+
const resizeTriggerId = dom.resolveResizeTriggerId(params.scope, event.id);
|
|
520
|
+
if (!resizeTriggerId) return;
|
|
428
521
|
const delta = event.delta;
|
|
429
522
|
const pivotIndices = resizeTriggerId.split(":").map((id) => panelDataArray.findIndex((panelData) => panelData.id === id));
|
|
430
523
|
const prevSize = context.get("size");
|
|
@@ -440,11 +533,11 @@ var machine = (0, import_core.createMachine)({
|
|
|
440
533
|
setSize(params, nextSize);
|
|
441
534
|
}
|
|
442
535
|
},
|
|
443
|
-
invokeOnResizeEnd({ context, prop }) {
|
|
536
|
+
invokeOnResizeEnd({ context, prop, refs }) {
|
|
444
537
|
queueMicrotask(() => {
|
|
445
538
|
const dragState = context.get("dragState");
|
|
446
539
|
prop("onResizeEnd")?.({
|
|
447
|
-
size: context.get("size"),
|
|
540
|
+
size: refs.get("lastRequestedSize") ?? context.get("size"),
|
|
448
541
|
resizeTriggerId: dragState?.resizeTriggerId ?? null
|
|
449
542
|
});
|
|
450
543
|
});
|
|
@@ -455,10 +548,10 @@ var machine = (0, import_core.createMachine)({
|
|
|
455
548
|
});
|
|
456
549
|
},
|
|
457
550
|
collapseOrExpandPanel(params) {
|
|
458
|
-
const { context,
|
|
459
|
-
const panelDataArray =
|
|
551
|
+
const { context, refs } = params;
|
|
552
|
+
const panelDataArray = context.get("panels");
|
|
460
553
|
const sizes = context.get("size");
|
|
461
|
-
const resizeTriggerId = context.get("keyboardState")?.
|
|
554
|
+
const resizeTriggerId = context.get("keyboardState")?.resolvedResizeTriggerId;
|
|
462
555
|
const [idBefore, idAfter] = resizeTriggerId?.split(":") ?? [];
|
|
463
556
|
const index = panelDataArray.findIndex((panelData2) => panelData2.id === idBefore);
|
|
464
557
|
if (index === -1) return;
|
|
@@ -472,7 +565,7 @@ var machine = (0, import_core.createMachine)({
|
|
|
472
565
|
);
|
|
473
566
|
const nextSize = (0, import_resize_by_delta.resizeByDelta)({
|
|
474
567
|
delta: (0, import_fuzzy.fuzzyNumbersEqual)(size, collapsedSize) ? minSize - collapsedSize : collapsedSize - size,
|
|
475
|
-
initialSize:
|
|
568
|
+
initialSize: refs.get("initialSize") ?? sizes,
|
|
476
569
|
panels: panelDataArray,
|
|
477
570
|
pivotIndices,
|
|
478
571
|
prevSize: sizes,
|
|
@@ -483,18 +576,19 @@ var machine = (0, import_core.createMachine)({
|
|
|
483
576
|
}
|
|
484
577
|
}
|
|
485
578
|
},
|
|
486
|
-
setGlobalCursor(
|
|
579
|
+
setGlobalCursor(params) {
|
|
580
|
+
const { context, scope, prop } = params;
|
|
487
581
|
const registry = prop("registry");
|
|
488
582
|
if (registry) return;
|
|
489
583
|
const dragState = context.get("dragState");
|
|
490
584
|
if (!dragState) return;
|
|
491
|
-
const panels =
|
|
585
|
+
const panels = context.get("panels");
|
|
492
586
|
const horizontal = prop("orientation") === "horizontal";
|
|
493
|
-
const [idBefore] = dragState.
|
|
587
|
+
const [idBefore] = dragState.resolvedResizeTriggerId.split(":");
|
|
494
588
|
const indexBefore = panels.findIndex((panel2) => panel2.id === idBefore);
|
|
495
589
|
const panel = panels[indexBefore];
|
|
496
590
|
const size = context.get("size");
|
|
497
|
-
const aria = (0, import_aria.getAriaValue)(size, panels, dragState.
|
|
591
|
+
const aria = (0, import_aria.getAriaValue)(size, panels, dragState.resolvedResizeTriggerId);
|
|
498
592
|
const isAtMin = (0, import_fuzzy.fuzzyNumbersEqual)(aria.valueNow, aria.valueMin) || (0, import_fuzzy.fuzzyNumbersEqual)(aria.valueNow, panel.collapsedSize);
|
|
499
593
|
const isAtMax = (0, import_fuzzy.fuzzyNumbersEqual)(aria.valueNow, aria.valueMax);
|
|
500
594
|
const cursorState = { isAtMin, isAtMax };
|
|
@@ -514,21 +608,36 @@ var machine = (0, import_core.createMachine)({
|
|
|
514
608
|
});
|
|
515
609
|
function setSize(params, sizes) {
|
|
516
610
|
const { refs, prop, context } = params;
|
|
517
|
-
const panelsArray =
|
|
611
|
+
const panelsArray = context.get("panels");
|
|
518
612
|
const onCollapse = prop("onCollapse");
|
|
519
613
|
const onExpand = prop("onExpand");
|
|
614
|
+
const onResize = prop("onResize");
|
|
520
615
|
const onResizeStart = prop("onResizeStart");
|
|
521
616
|
const onResizeEnd = prop("onResizeEnd");
|
|
522
617
|
const panelIdToLastNotifiedSizeMap = refs.get("panelIdToLastNotifiedSizeMap");
|
|
523
618
|
const dragState = context.get("dragState");
|
|
524
619
|
const keyboardState = context.get("keyboardState");
|
|
525
620
|
const isProgrammatic = dragState === null && keyboardState === null;
|
|
621
|
+
refs.set("lastRequestedSize", sizes);
|
|
526
622
|
if (isProgrammatic && onResizeStart) {
|
|
527
623
|
queueMicrotask(() => {
|
|
528
624
|
onResizeStart();
|
|
529
625
|
});
|
|
530
626
|
}
|
|
531
|
-
|
|
627
|
+
if (prop("size") == null) {
|
|
628
|
+
context.set("size", sizes);
|
|
629
|
+
} else if (onResize) {
|
|
630
|
+
const sizesBeforeCollapse = refs.get("panelSizeBeforeCollapse");
|
|
631
|
+
const expandToSizes = Object.fromEntries(sizesBeforeCollapse.entries());
|
|
632
|
+
const resizeTriggerId = dragState?.resizeTriggerId ?? null;
|
|
633
|
+
const layout = (0, import_panel.getPanelLayout)(prop("panels"));
|
|
634
|
+
onResize({
|
|
635
|
+
size: sizes,
|
|
636
|
+
layout,
|
|
637
|
+
resizeTriggerId,
|
|
638
|
+
expandToSizes
|
|
639
|
+
});
|
|
640
|
+
}
|
|
532
641
|
sizes.forEach((size, index) => {
|
|
533
642
|
const panelData = panelsArray[index];
|
|
534
643
|
(0, import_utils.ensure)(panelData, () => `Panel data not found for index ${index}`);
|
|
@@ -536,11 +645,11 @@ function setSize(params, sizes) {
|
|
|
536
645
|
const lastNotifiedSize = panelIdToLastNotifiedSizeMap.get(panelId);
|
|
537
646
|
if (lastNotifiedSize == null || size !== lastNotifiedSize) {
|
|
538
647
|
panelIdToLastNotifiedSizeMap.set(panelId, size);
|
|
539
|
-
if (collapsible && (onCollapse || onExpand)) {
|
|
540
|
-
if ((
|
|
648
|
+
if (collapsible && lastNotifiedSize != null && (onCollapse || onExpand)) {
|
|
649
|
+
if ((0, import_fuzzy.fuzzyNumbersEqual)(lastNotifiedSize, collapsedSize) && !(0, import_fuzzy.fuzzyNumbersEqual)(size, collapsedSize)) {
|
|
541
650
|
onExpand?.({ panelId, size });
|
|
542
651
|
}
|
|
543
|
-
if (
|
|
652
|
+
if (!(0, import_fuzzy.fuzzyNumbersEqual)(lastNotifiedSize, collapsedSize) && (0, import_fuzzy.fuzzyNumbersEqual)(size, collapsedSize)) {
|
|
544
653
|
onCollapse?.({ panelId, size });
|
|
545
654
|
}
|
|
546
655
|
}
|