@window-splitter/state 0.4.0 → 0.4.2
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 +5 -4
- package/CHANGELOG.md +35 -0
- package/dist/commonjs/index.d.ts +18 -4
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +119 -29
- package/dist/commonjs/index.js.map +1 -1
- package/dist/esm/index.d.ts +18 -4
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +119 -29
- package/dist/esm/index.js.map +1 -1
- package/package.json +4 -3
- package/src/__snapshots__/machine.test.ts.snap +82 -2
- package/src/index.ts +159 -39
- package/src/machine.test.ts +144 -58
- package/.turbo/turbo-lint.log +0 -5
- package/.turbo/turbo-test.log +0 -4729
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -87
- package/coverage/coverage-final.json +0 -2
- package/coverage/coverage-summary.json +0 -3
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +0 -116
- package/coverage/index.ts.html +0 -5818
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -2
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -196
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
>
|
|
4
|
-
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
> @window-splitter/state@0.4.1 build /Users/andrew/Documents/react-window-splitter/packages/state
|
|
4
|
+
> tshy
|
|
5
|
+
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,38 @@
|
|
|
1
|
+
# v0.4.2 (Tue Apr 15 2025)
|
|
2
|
+
|
|
3
|
+
#### 🐛 Bug Fix
|
|
4
|
+
|
|
5
|
+
- rebind onResize and onCollapseChange to fix restoring from snapshot [#44](https://github.com/hipstersmoothie/react-window-splitter/pull/44) ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
|
6
|
+
- rebind onResize and onCollapseChange to fix restoring from snapshot (closes #41) ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
|
7
|
+
|
|
8
|
+
#### Authors: 1
|
|
9
|
+
|
|
10
|
+
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# v0.4.1 (Sun Aug 25 2024)
|
|
15
|
+
|
|
16
|
+
#### 🐛 Bug Fix
|
|
17
|
+
|
|
18
|
+
- Responsive Bugs [#38](https://github.com/hipstersmoothie/react-window-splitter/pull/38) ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
|
19
|
+
- fix tests ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
|
20
|
+
- move handle overflow logic to recordActualItemSize ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
|
21
|
+
- more ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
|
22
|
+
- update test ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
|
23
|
+
- updating tests ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
|
24
|
+
- measure more ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
|
25
|
+
- add fill panel. improves resizing a lot ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
|
26
|
+
- move autosave to state package [#36](https://github.com/hipstersmoothie/react-window-splitter/pull/36) ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
|
27
|
+
- improve lint ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
|
28
|
+
- move autosave to state ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
|
29
|
+
|
|
30
|
+
#### Authors: 1
|
|
31
|
+
|
|
32
|
+
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
1
36
|
# v0.4.0 (Fri Aug 23 2024)
|
|
2
37
|
|
|
3
38
|
#### 🚀 Enhancement
|
package/dist/commonjs/index.d.ts
CHANGED
|
@@ -82,6 +82,7 @@ export interface PanelData extends Omit<Constraints, "min" | "max" | "collapsedS
|
|
|
82
82
|
duration: number;
|
|
83
83
|
easing: CollapseAnimation | ((t: number) => number);
|
|
84
84
|
};
|
|
85
|
+
lastKnownSize?: Rect;
|
|
85
86
|
}
|
|
86
87
|
/** Copied from https://github.com/d3/d3-ease */
|
|
87
88
|
declare const collapseAnimations: {
|
|
@@ -105,6 +106,11 @@ interface RegisterPanelEvent {
|
|
|
105
106
|
type: "registerPanel";
|
|
106
107
|
data: Omit<PanelData, "type" | "currentValue" | "defaultCollapsed">;
|
|
107
108
|
}
|
|
109
|
+
interface RebindPanelCallbacksEvent {
|
|
110
|
+
/** Rebind the panel callbacks */
|
|
111
|
+
type: "rebindPanelCallbacks";
|
|
112
|
+
data: Pick<PanelData, "id" | "onCollapseChange" | "onResize">;
|
|
113
|
+
}
|
|
108
114
|
interface RegisterDynamicPanelEvent extends Omit<RegisterPanelEvent, "type"> {
|
|
109
115
|
/** Register a new panel with the state machine */
|
|
110
116
|
type: "registerDynamicPanel";
|
|
@@ -154,7 +160,6 @@ interface SetSizeEvent {
|
|
|
154
160
|
/** Set the size of the whole group */
|
|
155
161
|
type: "setSize";
|
|
156
162
|
size: Rect;
|
|
157
|
-
handleOverflow?: boolean;
|
|
158
163
|
}
|
|
159
164
|
interface SetActualItemsSizeEvent {
|
|
160
165
|
/** Set the size of the whole group */
|
|
@@ -213,10 +218,18 @@ export interface GroupMachineContextValue {
|
|
|
213
218
|
/** How much the drag has overshot the handle */
|
|
214
219
|
dragOvershoot: Big.Big;
|
|
215
220
|
groupId: string;
|
|
221
|
+
/**
|
|
222
|
+
* How to save the persisted state
|
|
223
|
+
*/
|
|
224
|
+
autosaveStrategy?: "localStorage" | "cookie";
|
|
216
225
|
}
|
|
217
|
-
export type
|
|
226
|
+
export type GroupMachineSnapshot = Snapshot<unknown> & {
|
|
227
|
+
context: GroupMachineContextValue;
|
|
228
|
+
value: string;
|
|
229
|
+
};
|
|
230
|
+
export type GroupMachineEvent = RegisterPanelEvent | RegisterDynamicPanelEvent | UnregisterPanelEvent | RegisterPanelHandleEvent | UnregisterPanelHandleEvent | DragHandleEvent | SetSizeEvent | SetOrientationEvent | DragHandleStartEvent | DragHandleEndEvent | CollapsePanelEvent | ExpandPanelEvent | SetPanelPixelSizeEvent | ApplyDeltaEvent | SetActualItemsSizeEvent | RebindPanelCallbacksEvent;
|
|
218
231
|
export declare function getCursor(context: Pick<GroupMachineContextValue, "dragOvershoot" | "orientation">): "w-resize" | "e-resize" | "ew-resize" | "n-resize" | "s-resize" | "ns-resize";
|
|
219
|
-
export declare function prepareSnapshot(snapshot:
|
|
232
|
+
export declare function prepareSnapshot(snapshot: GroupMachineSnapshot): GroupMachineSnapshot;
|
|
220
233
|
/** Determine if an item is a panel */
|
|
221
234
|
export declare function isPanelData(value: unknown): value is PanelData;
|
|
222
235
|
/** Determine if an item is a panel handle */
|
|
@@ -326,10 +339,11 @@ export declare function dragHandlePayload({ delta, orientation, shiftKey, }: {
|
|
|
326
339
|
readonly deltaX: number;
|
|
327
340
|
readonly deltaY: number;
|
|
328
341
|
};
|
|
329
|
-
export declare const groupMachine: import("xstate").StateMachine<GroupMachineContextValue, RegisterPanelEvent | RegisterDynamicPanelEvent | UnregisterPanelEvent | RegisterPanelHandleEvent | UnregisterPanelHandleEvent | DragHandleStartEvent | DragHandleEvent | DragHandleEndEvent | SetSizeEvent | SetActualItemsSizeEvent | ApplyDeltaEvent | SetOrientationEvent | CollapsePanelEvent | ExpandPanelEvent | SetPanelPixelSizeEvent, Record<string, import("xstate").AnyActorRef>, import("xstate").ProvidedActor, import("xstate").ParameterizedObject, import("xstate").ParameterizedObject, string, import("xstate").StateValue, string, {
|
|
342
|
+
export declare const groupMachine: import("xstate").StateMachine<GroupMachineContextValue, RegisterPanelEvent | RebindPanelCallbacksEvent | RegisterDynamicPanelEvent | UnregisterPanelEvent | RegisterPanelHandleEvent | UnregisterPanelHandleEvent | DragHandleStartEvent | DragHandleEvent | DragHandleEndEvent | SetSizeEvent | SetActualItemsSizeEvent | ApplyDeltaEvent | SetOrientationEvent | CollapsePanelEvent | ExpandPanelEvent | SetPanelPixelSizeEvent, Record<string, import("xstate").AnyActorRef>, import("xstate").ProvidedActor, import("xstate").ParameterizedObject, import("xstate").ParameterizedObject, string, import("xstate").StateValue, string, {
|
|
330
343
|
orientation?: Orientation;
|
|
331
344
|
groupId: string;
|
|
332
345
|
initialItems?: Item[];
|
|
346
|
+
autosaveStrategy?: "localStorage" | "cookie";
|
|
333
347
|
}, import("xstate").NonReducibleUnknown, import("xstate").EventObject, import("xstate").MetaObject, any>;
|
|
334
348
|
export {};
|
|
335
349
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAKL,QAAQ,EACT,MAAM,QAAQ,CAAC;AAEhB,OAAO,GAAG,MAAM,QAAQ,CAAC;AAWzB,MAAM,MAAM,SAAS,GAAG,GAAG,MAAM,IAAI,CAAC;AACtC,MAAM,MAAM,WAAW,GAAG,GAAG,MAAM,GAAG,CAAC;AACvC,MAAM,MAAM,IAAI,GAAG,SAAS,GAAG,WAAW,CAAC;AAC3C,KAAK,WAAW,GAAG,YAAY,GAAG,UAAU,CAAC;AAE7C,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,GAAG,CAAC,GAAG,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,GAAG,CAAC,GAAG,CAAC;CAChB;AAED,KAAK,UAAU,GAAG,iBAAiB,GAAG,eAAe,CAAC;AAEtD,wBAAgB,eAAe,CAAC,KAAK,EAAE,M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C,EAAE,WAAW,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;;;;;;;;;EAWA;AA4PD,eAAO,MAAM,YAAY;kBAOH,WAAW;aAChB,MAAM;mBACA,IAAI,EAAE;uBACF,cAAc,GAAG,QAAQ;wGAsdnD,CAAC"}
|
package/dist/commonjs/index.js
CHANGED
|
@@ -24,6 +24,7 @@ exports.getPanelPercentageSize = getPanelPercentageSize;
|
|
|
24
24
|
exports.buildTemplate = buildTemplate;
|
|
25
25
|
exports.prepareItems = prepareItems;
|
|
26
26
|
exports.dragHandlePayload = dragHandlePayload;
|
|
27
|
+
const universal_cookie_1 = __importDefault(require("universal-cookie"));
|
|
27
28
|
const rafz_1 = require("@react-spring/rafz");
|
|
28
29
|
const xstate_1 = require("xstate");
|
|
29
30
|
const invariant_1 = __importDefault(require("invariant"));
|
|
@@ -96,9 +97,7 @@ function getCursor(context) {
|
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
99
|
function prepareSnapshot(snapshot) {
|
|
99
|
-
|
|
100
|
-
const snapshotContext = snapshot
|
|
101
|
-
.context;
|
|
100
|
+
const snapshotContext = snapshot.context;
|
|
102
101
|
snapshotContext.dragOvershoot = new big_js_1.default(snapshotContext.dragOvershoot);
|
|
103
102
|
for (const item of snapshotContext.items) {
|
|
104
103
|
if (isPanelData(item)) {
|
|
@@ -375,6 +374,7 @@ function getPanelPercentageSize(context, panelId) {
|
|
|
375
374
|
/** Build the grid template from the item values. */
|
|
376
375
|
function buildTemplate(context) {
|
|
377
376
|
const staticWidth = getStaticWidth(context);
|
|
377
|
+
let hasSeenFillPanel = false;
|
|
378
378
|
return context.items
|
|
379
379
|
.map((item) => {
|
|
380
380
|
if (item.type === "panel") {
|
|
@@ -388,6 +388,12 @@ function buildTemplate(context) {
|
|
|
388
388
|
return formatUnit(item.currentValue);
|
|
389
389
|
}
|
|
390
390
|
else if (item.currentValue.type === "percent") {
|
|
391
|
+
if (!hasSeenFillPanel &&
|
|
392
|
+
(item.max === "1fr" ||
|
|
393
|
+
(item.max.type === "percent" && item.max.value.eq(100)))) {
|
|
394
|
+
hasSeenFillPanel = true;
|
|
395
|
+
return `minmax(${min}, 1fr)`;
|
|
396
|
+
}
|
|
391
397
|
const max = item.max === "1fr" ? "100%" : formatUnit(item.max);
|
|
392
398
|
return `minmax(${min}, min(calc(${item.currentValue.value} * (100% - ${staticWidth}px)), ${max}))`;
|
|
393
399
|
}
|
|
@@ -493,6 +499,13 @@ function prepareItems(context) {
|
|
|
493
499
|
newItems.push({ ...item });
|
|
494
500
|
continue;
|
|
495
501
|
}
|
|
502
|
+
if (item.lastKnownSize) {
|
|
503
|
+
const lastSize = makePixelUnit(context.orientation === "horizontal"
|
|
504
|
+
? item.lastKnownSize.width
|
|
505
|
+
: item.lastKnownSize.height);
|
|
506
|
+
newItems.push({ ...item, currentValue: lastSize });
|
|
507
|
+
continue;
|
|
508
|
+
}
|
|
496
509
|
if (item.currentValue.type === "pixel") {
|
|
497
510
|
newItems.push({ ...item });
|
|
498
511
|
continue;
|
|
@@ -802,6 +815,9 @@ function handleOverflow(context) {
|
|
|
802
815
|
}
|
|
803
816
|
return { ...newContext, items: commitLayout(newContext) };
|
|
804
817
|
}
|
|
818
|
+
function clearLastKnownSize(items) {
|
|
819
|
+
return items.map((i) => ({ ...i, lastKnownSize: undefined }));
|
|
820
|
+
}
|
|
805
821
|
function getDeltaForEvent(context, event) {
|
|
806
822
|
const panel = getPanelWithId(context, event.panelId);
|
|
807
823
|
if (event.type === "expandPanel") {
|
|
@@ -861,15 +877,17 @@ exports.groupMachine = (0, xstate_1.createMachine)({
|
|
|
861
877
|
orientation: input.orientation || "horizontal",
|
|
862
878
|
dragOvershoot: new big_js_1.default(0),
|
|
863
879
|
groupId: input.groupId,
|
|
880
|
+
autosaveStrategy: input.autosaveStrategy,
|
|
864
881
|
}),
|
|
865
882
|
states: {
|
|
866
883
|
idle: {
|
|
884
|
+
entry: ["onAutosave"],
|
|
867
885
|
on: {
|
|
868
|
-
setActualItemsSize: { actions: ["recordActualItemSize", "onResize"] },
|
|
869
886
|
dragHandleStart: { target: "dragging" },
|
|
870
887
|
setPanelPixelSize: {
|
|
871
888
|
actions: [
|
|
872
889
|
"prepare",
|
|
890
|
+
"onClearLastKnownSize",
|
|
873
891
|
"onSetPanelSize",
|
|
874
892
|
"commit",
|
|
875
893
|
"onResize",
|
|
@@ -897,7 +915,9 @@ exports.groupMachine = (0, xstate_1.createMachine)({
|
|
|
897
915
|
dragging: {
|
|
898
916
|
entry: ["prepare"],
|
|
899
917
|
on: {
|
|
900
|
-
dragHandle: {
|
|
918
|
+
dragHandle: {
|
|
919
|
+
actions: ["onClearLastKnownSize", "onDragHandle", "onResize"],
|
|
920
|
+
},
|
|
901
921
|
dragHandleEnd: { target: "idle" },
|
|
902
922
|
collapsePanel: {
|
|
903
923
|
guard: "shouldCollapseToggle",
|
|
@@ -908,16 +928,16 @@ exports.groupMachine = (0, xstate_1.createMachine)({
|
|
|
908
928
|
actions: "runCollapseToggle",
|
|
909
929
|
},
|
|
910
930
|
},
|
|
911
|
-
exit: ["commit"
|
|
931
|
+
exit: ["commit"],
|
|
912
932
|
},
|
|
913
933
|
togglingCollapse: {
|
|
914
|
-
entry: ["prepare"],
|
|
934
|
+
entry: ["prepare", "onClearLastKnownSize"],
|
|
915
935
|
invoke: {
|
|
916
936
|
src: "animation",
|
|
917
937
|
input: (i) => ({ ...i, send: i.self.send }),
|
|
918
938
|
onDone: {
|
|
919
939
|
target: "idle",
|
|
920
|
-
actions: ["onToggleCollapseComplete", "commit"
|
|
940
|
+
actions: ["onToggleCollapseComplete", "commit"],
|
|
921
941
|
},
|
|
922
942
|
},
|
|
923
943
|
on: {
|
|
@@ -926,25 +946,44 @@ exports.groupMachine = (0, xstate_1.createMachine)({
|
|
|
926
946
|
},
|
|
927
947
|
},
|
|
928
948
|
on: {
|
|
949
|
+
setActualItemsSize: { actions: ["recordActualItemSize", "onResize"] },
|
|
929
950
|
registerPanel: { actions: ["assignPanelData"] },
|
|
951
|
+
rebindPanelCallbacks: { actions: ["rebindPanelCallbacks"] },
|
|
930
952
|
registerDynamicPanel: {
|
|
931
953
|
actions: [
|
|
932
954
|
"prepare",
|
|
933
955
|
"onRegisterDynamicPanel",
|
|
956
|
+
"onClearLastKnownSize",
|
|
934
957
|
"commit",
|
|
935
958
|
"onResize",
|
|
936
959
|
"onAutosave",
|
|
937
960
|
],
|
|
938
961
|
},
|
|
939
962
|
unregisterPanel: {
|
|
940
|
-
actions: [
|
|
963
|
+
actions: [
|
|
964
|
+
"prepare",
|
|
965
|
+
"removeItem",
|
|
966
|
+
"onClearLastKnownSize",
|
|
967
|
+
"commit",
|
|
968
|
+
"onResize",
|
|
969
|
+
"onAutosave",
|
|
970
|
+
],
|
|
941
971
|
},
|
|
942
972
|
registerPanelHandle: { actions: ["assignPanelHandleData"] },
|
|
943
973
|
unregisterPanelHandle: {
|
|
944
|
-
actions: [
|
|
974
|
+
actions: [
|
|
975
|
+
"prepare",
|
|
976
|
+
"removeItem",
|
|
977
|
+
"onClearLastKnownSize",
|
|
978
|
+
"commit",
|
|
979
|
+
"onResize",
|
|
980
|
+
"onAutosave",
|
|
981
|
+
],
|
|
945
982
|
},
|
|
946
983
|
setSize: { actions: ["updateSize", "onResize"] },
|
|
947
|
-
setOrientation: {
|
|
984
|
+
setOrientation: {
|
|
985
|
+
actions: ["updateOrientation", "onClearLastKnownSize", "onResize"],
|
|
986
|
+
},
|
|
948
987
|
},
|
|
949
988
|
}, {
|
|
950
989
|
guards: {
|
|
@@ -986,6 +1025,24 @@ exports.groupMachine = (0, xstate_1.createMachine)({
|
|
|
986
1025
|
animation: animationActor,
|
|
987
1026
|
},
|
|
988
1027
|
actions: {
|
|
1028
|
+
onAutosave: ({ context, self }) => {
|
|
1029
|
+
if (!context.autosaveStrategy || typeof window === "undefined") {
|
|
1030
|
+
return;
|
|
1031
|
+
}
|
|
1032
|
+
const snapshot = self.getPersistedSnapshot();
|
|
1033
|
+
snapshot.context.items = clearLastKnownSize(context.items);
|
|
1034
|
+
snapshot.value = "idle";
|
|
1035
|
+
const data = JSON.stringify(snapshot);
|
|
1036
|
+
if (context.autosaveStrategy === "localStorage") {
|
|
1037
|
+
localStorage.setItem(context.groupId, data);
|
|
1038
|
+
}
|
|
1039
|
+
else {
|
|
1040
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1041
|
+
const ActualClass = universal_cookie_1.default.default || universal_cookie_1.default;
|
|
1042
|
+
const cookies = new ActualClass(null, { path: "/" });
|
|
1043
|
+
cookies.set(context.groupId, data, { path: "/", maxAge: 31536000 });
|
|
1044
|
+
}
|
|
1045
|
+
},
|
|
989
1046
|
notifyCollapseToggle: ({ context, event }) => {
|
|
990
1047
|
isEvent(event, ["collapsePanel", "expandPanel"]);
|
|
991
1048
|
const panel = getPanelWithId(context, event.panelId);
|
|
@@ -1009,8 +1066,7 @@ exports.groupMachine = (0, xstate_1.createMachine)({
|
|
|
1009
1066
|
}),
|
|
1010
1067
|
onToggleCollapseComplete: (0, xstate_1.assign)({
|
|
1011
1068
|
items: ({ context, event: e }) => {
|
|
1012
|
-
|
|
1013
|
-
const output = e.output;
|
|
1069
|
+
const { output } = e;
|
|
1014
1070
|
(0, invariant_1.default)(output, "Expected output from animation actor");
|
|
1015
1071
|
const panel = getPanelWithId(context, output.panelId);
|
|
1016
1072
|
panel.collapsed = output.action === "collapse";
|
|
@@ -1020,27 +1076,42 @@ exports.groupMachine = (0, xstate_1.createMachine)({
|
|
|
1020
1076
|
return context.items;
|
|
1021
1077
|
},
|
|
1022
1078
|
}),
|
|
1023
|
-
updateSize: (0, xstate_1.
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
}
|
|
1028
|
-
else {
|
|
1029
|
-
enqueue.assign({ size: event.size });
|
|
1030
|
-
}
|
|
1079
|
+
updateSize: (0, xstate_1.assign)({
|
|
1080
|
+
size: ({ event }) => {
|
|
1081
|
+
isEvent(event, ["setSize"]);
|
|
1082
|
+
return event.size;
|
|
1083
|
+
},
|
|
1031
1084
|
}),
|
|
1032
1085
|
recordActualItemSize: (0, xstate_1.assign)({
|
|
1033
1086
|
items: ({ context, event }) => {
|
|
1034
1087
|
isEvent(event, ["setActualItemsSize"]);
|
|
1035
|
-
const
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1088
|
+
const withLastKnownSize = context.items.map((i) => {
|
|
1089
|
+
if (!isPanelData(i))
|
|
1090
|
+
return i;
|
|
1091
|
+
const lastKnownSize = event.childrenSizes[i.id] || i.lastKnownSize;
|
|
1092
|
+
return { ...i, lastKnownSize };
|
|
1093
|
+
});
|
|
1094
|
+
let totalSize = 0;
|
|
1095
|
+
for (const item of withLastKnownSize) {
|
|
1096
|
+
if (isPanelData(item)) {
|
|
1097
|
+
const size = item.lastKnownSize?.[context.orientation === "horizontal" ? "width" : "height"];
|
|
1098
|
+
// If any size is 0 don't handle overflow
|
|
1099
|
+
if (!size) {
|
|
1100
|
+
return withLastKnownSize;
|
|
1101
|
+
}
|
|
1102
|
+
totalSize += size;
|
|
1103
|
+
}
|
|
1104
|
+
else {
|
|
1105
|
+
totalSize += item.size.value.toNumber();
|
|
1040
1106
|
}
|
|
1041
|
-
item.currentValue = makePixelUnit(orientation === "horizontal" ? size.width : size.height);
|
|
1042
1107
|
}
|
|
1043
|
-
|
|
1108
|
+
if (totalSize > getGroupSize(context)) {
|
|
1109
|
+
return handleOverflow({
|
|
1110
|
+
...context,
|
|
1111
|
+
items: prepareItems({ ...context, items: withLastKnownSize }),
|
|
1112
|
+
}).items;
|
|
1113
|
+
}
|
|
1114
|
+
return withLastKnownSize;
|
|
1044
1115
|
},
|
|
1045
1116
|
}),
|
|
1046
1117
|
updateOrientation: (0, xstate_1.assign)({
|
|
@@ -1049,6 +1120,9 @@ exports.groupMachine = (0, xstate_1.createMachine)({
|
|
|
1049
1120
|
return event.orientation;
|
|
1050
1121
|
},
|
|
1051
1122
|
}),
|
|
1123
|
+
onClearLastKnownSize: (0, xstate_1.assign)({
|
|
1124
|
+
items: ({ context }) => clearLastKnownSize(context.items),
|
|
1125
|
+
}),
|
|
1052
1126
|
assignPanelData: (0, xstate_1.assign)({
|
|
1053
1127
|
items: ({ context, event }) => {
|
|
1054
1128
|
isEvent(event, ["registerPanel"]);
|
|
@@ -1059,6 +1133,18 @@ exports.groupMachine = (0, xstate_1.createMachine)({
|
|
|
1059
1133
|
});
|
|
1060
1134
|
},
|
|
1061
1135
|
}),
|
|
1136
|
+
rebindPanelCallbacks: (0, xstate_1.assign)({
|
|
1137
|
+
items: ({ context, event }) => {
|
|
1138
|
+
isEvent(event, ["rebindPanelCallbacks"]);
|
|
1139
|
+
for (const item of context.items) {
|
|
1140
|
+
if (isPanelData(item) && item.id === event.data.id) {
|
|
1141
|
+
item.onCollapseChange = event.data.onCollapseChange;
|
|
1142
|
+
item.onResize = event.data.onResize;
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
return context.items;
|
|
1146
|
+
},
|
|
1147
|
+
}),
|
|
1062
1148
|
onRegisterDynamicPanel: (0, xstate_1.assign)({
|
|
1063
1149
|
items: ({ context, event }) => {
|
|
1064
1150
|
isEvent(event, ["registerDynamicPanel"]);
|
|
@@ -1168,7 +1254,11 @@ exports.groupMachine = (0, xstate_1.createMachine)({
|
|
|
1168
1254
|
onResize: ({ context }) => {
|
|
1169
1255
|
for (const item of context.items) {
|
|
1170
1256
|
if (isPanelData(item)) {
|
|
1171
|
-
const pixel =
|
|
1257
|
+
const pixel = item.lastKnownSize
|
|
1258
|
+
? new big_js_1.default(context.orientation === "horizontal"
|
|
1259
|
+
? item.lastKnownSize.width
|
|
1260
|
+
: item.lastKnownSize.height)
|
|
1261
|
+
: clampUnit(context, item, getUnitPixelValue(context, item.currentValue));
|
|
1172
1262
|
const groupSize = getGroupSize(context);
|
|
1173
1263
|
item.onResize?.current?.({
|
|
1174
1264
|
pixel: pixel.toNumber(),
|