@zag-js/splitter 0.10.1 → 0.10.3
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.ts +4 -7
- package/dist/index.js +8 -684
- package/dist/index.mjs +3 -16
- package/dist/splitter.anatomy.d.ts +3 -6
- package/dist/splitter.anatomy.js +10 -33
- package/dist/splitter.anatomy.mjs +6 -8
- package/dist/splitter.connect.d.ts +3 -7
- package/dist/splitter.connect.js +28 -144
- package/dist/splitter.connect.mjs +181 -9
- package/dist/splitter.dom.d.ts +25 -29
- package/dist/splitter.dom.js +9 -31
- package/dist/splitter.dom.mjs +58 -6
- package/dist/splitter.machine.d.ts +3 -7
- package/dist/splitter.machine.js +34 -250
- package/dist/splitter.machine.mjs +281 -8
- package/dist/splitter.types.d.ts +12 -14
- package/dist/splitter.utils.d.ts +6 -11
- package/dist/splitter.utils.js +10 -37
- package/dist/splitter.utils.mjs +122 -14
- package/package.json +9 -14
- package/src/splitter.connect.ts +3 -3
- package/src/splitter.machine.ts +1 -16
- package/src/splitter.utils.ts +1 -1
- package/dist/chunk-3GDOPT5W.mjs +0 -60
- package/dist/chunk-53T2VZ2R.mjs +0 -190
- package/dist/chunk-HPRMFGOY.mjs +0 -9
- package/dist/chunk-MV44GBQY.mjs +0 -129
- package/dist/chunk-X2E2LAC5.mjs +0 -307
- package/dist/splitter.types.js +0 -18
- package/dist/splitter.types.mjs +0 -0
package/dist/splitter.dom.js
CHANGED
|
@@ -1,30 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
'use strict';
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
module.exports = __toCommonJS(splitter_dom_exports);
|
|
26
|
-
var import_dom_query = require("@zag-js/dom-query");
|
|
27
|
-
var dom = (0, import_dom_query.createScope)({
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const domQuery = require('@zag-js/dom-query');
|
|
6
|
+
|
|
7
|
+
const dom = domQuery.createScope({
|
|
28
8
|
getRootId: (ctx) => ctx.ids?.root ?? `splitter:${ctx.id}`,
|
|
29
9
|
getResizeTriggerId: (ctx, id) => ctx.ids?.resizeTrigger?.(id) ?? `splitter:${ctx.id}:splitter:${id}`,
|
|
30
10
|
getToggleTriggerId: (ctx) => ctx.ids?.toggleTrigger?.(ctx.id) ?? `splitter:${ctx.id}:toggle-btn`,
|
|
@@ -60,7 +40,7 @@ var dom = (0, import_dom_query.createScope)({
|
|
|
60
40
|
},
|
|
61
41
|
getResizeTriggerEls(ctx) {
|
|
62
42
|
const ownerId = CSS.escape(dom.getRootId(ctx));
|
|
63
|
-
return
|
|
43
|
+
return domQuery.queryAll(dom.getRootEl(ctx), `[role=separator][data-ownedby='${ownerId}']`);
|
|
64
44
|
},
|
|
65
45
|
setupGlobalCursor(ctx) {
|
|
66
46
|
const styleEl = dom.getById(ctx, dom.globalCursorId(ctx));
|
|
@@ -78,7 +58,5 @@ var dom = (0, import_dom_query.createScope)({
|
|
|
78
58
|
dom.getById(ctx, dom.globalCursorId(ctx))?.remove();
|
|
79
59
|
}
|
|
80
60
|
});
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
dom
|
|
84
|
-
});
|
|
61
|
+
|
|
62
|
+
exports.dom = dom;
|
package/dist/splitter.dom.mjs
CHANGED
|
@@ -1,6 +1,58 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
1
|
+
import { createScope, queryAll } from '@zag-js/dom-query';
|
|
2
|
+
|
|
3
|
+
const dom = createScope({
|
|
4
|
+
getRootId: (ctx) => ctx.ids?.root ?? `splitter:${ctx.id}`,
|
|
5
|
+
getResizeTriggerId: (ctx, id) => ctx.ids?.resizeTrigger?.(id) ?? `splitter:${ctx.id}:splitter:${id}`,
|
|
6
|
+
getToggleTriggerId: (ctx) => ctx.ids?.toggleTrigger?.(ctx.id) ?? `splitter:${ctx.id}:toggle-btn`,
|
|
7
|
+
getLabelId: (ctx) => ctx.ids?.label ?? `splitter:${ctx.id}:label`,
|
|
8
|
+
getPanelId: (ctx, id) => ctx.ids?.panel?.(id) ?? `splitter:${ctx.id}:panel:${id}`,
|
|
9
|
+
globalCursorId: (ctx) => `splitter:${ctx.id}:global-cursor`,
|
|
10
|
+
getRootEl: (ctx) => dom.queryById(ctx, dom.getRootId(ctx)),
|
|
11
|
+
getResizeTriggerEl: (ctx, id) => dom.getById(ctx, dom.getResizeTriggerId(ctx, id)),
|
|
12
|
+
getPanelEl: (ctx, id) => dom.getById(ctx, dom.getPanelId(ctx, id)),
|
|
13
|
+
getCursor(ctx) {
|
|
14
|
+
const x = ctx.isHorizontal;
|
|
15
|
+
let cursor = x ? "col-resize" : "row-resize";
|
|
16
|
+
if (ctx.activeResizeState.isAtMin)
|
|
17
|
+
cursor = x ? "e-resize" : "s-resize";
|
|
18
|
+
if (ctx.activeResizeState.isAtMax)
|
|
19
|
+
cursor = x ? "w-resize" : "n-resize";
|
|
20
|
+
return cursor;
|
|
21
|
+
},
|
|
22
|
+
getPanelStyle(ctx, id) {
|
|
23
|
+
const flexGrow = ctx.panels.find((panel) => panel.id === id)?.size ?? "0";
|
|
24
|
+
return {
|
|
25
|
+
flexBasis: 0,
|
|
26
|
+
flexGrow,
|
|
27
|
+
flexShrink: 1,
|
|
28
|
+
overflow: "hidden"
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
getActiveHandleEl(ctx) {
|
|
32
|
+
const activeId = ctx.activeResizeId;
|
|
33
|
+
if (activeId == null)
|
|
34
|
+
return;
|
|
35
|
+
return dom.getById(ctx, dom.getResizeTriggerId(ctx, activeId));
|
|
36
|
+
},
|
|
37
|
+
getResizeTriggerEls(ctx) {
|
|
38
|
+
const ownerId = CSS.escape(dom.getRootId(ctx));
|
|
39
|
+
return queryAll(dom.getRootEl(ctx), `[role=separator][data-ownedby='${ownerId}']`);
|
|
40
|
+
},
|
|
41
|
+
setupGlobalCursor(ctx) {
|
|
42
|
+
const styleEl = dom.getById(ctx, dom.globalCursorId(ctx));
|
|
43
|
+
const textContent = `* { cursor: ${dom.getCursor(ctx)} !important; }`;
|
|
44
|
+
if (styleEl) {
|
|
45
|
+
styleEl.textContent = textContent;
|
|
46
|
+
} else {
|
|
47
|
+
const style = dom.getDoc(ctx).createElement("style");
|
|
48
|
+
style.id = dom.globalCursorId(ctx);
|
|
49
|
+
style.textContent = textContent;
|
|
50
|
+
dom.getDoc(ctx).head.appendChild(style);
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
removeGlobalCursor(ctx) {
|
|
54
|
+
dom.getById(ctx, dom.globalCursorId(ctx))?.remove();
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
export { dom };
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
|
|
6
|
-
|
|
7
|
-
export { machine };
|
|
1
|
+
import type { Machine, StateMachine } from '@zag-js/core';
|
|
2
|
+
import type { MachineContext, MachineState, UserDefinedContext } from "./splitter.types";
|
|
3
|
+
export declare function machine(userContext: UserDefinedContext): Machine<MachineContext, MachineState, StateMachine.AnyEventObject>;
|
package/dist/splitter.machine.js
CHANGED
|
@@ -1,216 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
'use strict';
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
var splitter_machine_exports = {};
|
|
22
|
-
__export(splitter_machine_exports, {
|
|
23
|
-
machine: () => machine
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(splitter_machine_exports);
|
|
26
|
-
var import_core = require("@zag-js/core");
|
|
27
|
-
var import_dom_event = require("@zag-js/dom-event");
|
|
28
|
-
var import_dom_query2 = require("@zag-js/dom-query");
|
|
29
|
-
var import_utils = require("@zag-js/utils");
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
30
4
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
getLabelId: (ctx) => ctx.ids?.label ?? `splitter:${ctx.id}:label`,
|
|
38
|
-
getPanelId: (ctx, id) => ctx.ids?.panel?.(id) ?? `splitter:${ctx.id}:panel:${id}`,
|
|
39
|
-
globalCursorId: (ctx) => `splitter:${ctx.id}:global-cursor`,
|
|
40
|
-
getRootEl: (ctx) => dom.queryById(ctx, dom.getRootId(ctx)),
|
|
41
|
-
getResizeTriggerEl: (ctx, id) => dom.getById(ctx, dom.getResizeTriggerId(ctx, id)),
|
|
42
|
-
getPanelEl: (ctx, id) => dom.getById(ctx, dom.getPanelId(ctx, id)),
|
|
43
|
-
getCursor(ctx) {
|
|
44
|
-
const x = ctx.isHorizontal;
|
|
45
|
-
let cursor = x ? "col-resize" : "row-resize";
|
|
46
|
-
if (ctx.activeResizeState.isAtMin)
|
|
47
|
-
cursor = x ? "e-resize" : "s-resize";
|
|
48
|
-
if (ctx.activeResizeState.isAtMax)
|
|
49
|
-
cursor = x ? "w-resize" : "n-resize";
|
|
50
|
-
return cursor;
|
|
51
|
-
},
|
|
52
|
-
getPanelStyle(ctx, id) {
|
|
53
|
-
const flexGrow = ctx.panels.find((panel) => panel.id === id)?.size ?? "0";
|
|
54
|
-
return {
|
|
55
|
-
flexBasis: 0,
|
|
56
|
-
flexGrow,
|
|
57
|
-
flexShrink: 1,
|
|
58
|
-
overflow: "hidden"
|
|
59
|
-
};
|
|
60
|
-
},
|
|
61
|
-
getActiveHandleEl(ctx) {
|
|
62
|
-
const activeId = ctx.activeResizeId;
|
|
63
|
-
if (activeId == null)
|
|
64
|
-
return;
|
|
65
|
-
return dom.getById(ctx, dom.getResizeTriggerId(ctx, activeId));
|
|
66
|
-
},
|
|
67
|
-
getResizeTriggerEls(ctx) {
|
|
68
|
-
const ownerId = CSS.escape(dom.getRootId(ctx));
|
|
69
|
-
return (0, import_dom_query.queryAll)(dom.getRootEl(ctx), `[role=separator][data-ownedby='${ownerId}']`);
|
|
70
|
-
},
|
|
71
|
-
setupGlobalCursor(ctx) {
|
|
72
|
-
const styleEl = dom.getById(ctx, dom.globalCursorId(ctx));
|
|
73
|
-
const textContent = `* { cursor: ${dom.getCursor(ctx)} !important; }`;
|
|
74
|
-
if (styleEl) {
|
|
75
|
-
styleEl.textContent = textContent;
|
|
76
|
-
} else {
|
|
77
|
-
const style = dom.getDoc(ctx).createElement("style");
|
|
78
|
-
style.id = dom.globalCursorId(ctx);
|
|
79
|
-
style.textContent = textContent;
|
|
80
|
-
dom.getDoc(ctx).head.appendChild(style);
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
removeGlobalCursor(ctx) {
|
|
84
|
-
dom.getById(ctx, dom.globalCursorId(ctx))?.remove();
|
|
85
|
-
}
|
|
86
|
-
});
|
|
5
|
+
const core = require('@zag-js/core');
|
|
6
|
+
const domEvent = require('@zag-js/dom-event');
|
|
7
|
+
const domQuery = require('@zag-js/dom-query');
|
|
8
|
+
const utils = require('@zag-js/utils');
|
|
9
|
+
const splitter_dom = require('./splitter.dom.js');
|
|
10
|
+
const splitter_utils = require('./splitter.utils.js');
|
|
87
11
|
|
|
88
|
-
// src/splitter.utils.ts
|
|
89
|
-
function validateSize(key, size) {
|
|
90
|
-
if (Math.floor(size) > 100) {
|
|
91
|
-
throw new Error(`Total ${key} of panels cannot be greater than 100`);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
function getNormalizedPanels(ctx) {
|
|
95
|
-
let numOfPanelsWithoutSize = 0;
|
|
96
|
-
let totalSize = 0;
|
|
97
|
-
let totalMinSize = 0;
|
|
98
|
-
const panels = ctx.size.map((panel) => {
|
|
99
|
-
const minSize = panel.minSize ?? 10;
|
|
100
|
-
const maxSize = panel.maxSize ?? 100;
|
|
101
|
-
totalMinSize += minSize;
|
|
102
|
-
if (panel.size == null) {
|
|
103
|
-
numOfPanelsWithoutSize++;
|
|
104
|
-
} else {
|
|
105
|
-
totalSize += panel.size;
|
|
106
|
-
}
|
|
107
|
-
return {
|
|
108
|
-
...panel,
|
|
109
|
-
minSize,
|
|
110
|
-
maxSize
|
|
111
|
-
};
|
|
112
|
-
});
|
|
113
|
-
validateSize("minSize", totalMinSize);
|
|
114
|
-
validateSize("size", totalSize);
|
|
115
|
-
let end = 0;
|
|
116
|
-
let remainingSize = 0;
|
|
117
|
-
const result = panels.map((panel) => {
|
|
118
|
-
let start = end;
|
|
119
|
-
if (panel.size != null) {
|
|
120
|
-
end += panel.size;
|
|
121
|
-
remainingSize = panel.size - panel.minSize;
|
|
122
|
-
return {
|
|
123
|
-
...panel,
|
|
124
|
-
start,
|
|
125
|
-
end,
|
|
126
|
-
remainingSize
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
const size = (100 - totalSize) / numOfPanelsWithoutSize;
|
|
130
|
-
end += size;
|
|
131
|
-
remainingSize = size - panel.minSize;
|
|
132
|
-
return { ...panel, size, start, end, remainingSize };
|
|
133
|
-
});
|
|
134
|
-
return result;
|
|
135
|
-
}
|
|
136
|
-
function getHandlePanels(ctx, id = ctx.activeResizeId) {
|
|
137
|
-
const [beforeId, afterId] = id?.split(":") ?? [];
|
|
138
|
-
if (!beforeId || !afterId)
|
|
139
|
-
return;
|
|
140
|
-
const beforeIndex = ctx.previousPanels.findIndex((panel) => panel.id === beforeId);
|
|
141
|
-
const afterIndex = ctx.previousPanels.findIndex((panel) => panel.id === afterId);
|
|
142
|
-
if (beforeIndex === -1 || afterIndex === -1)
|
|
143
|
-
return;
|
|
144
|
-
const before = ctx.previousPanels[beforeIndex];
|
|
145
|
-
const after = ctx.previousPanels[afterIndex];
|
|
146
|
-
return {
|
|
147
|
-
before: {
|
|
148
|
-
...before,
|
|
149
|
-
index: beforeIndex
|
|
150
|
-
},
|
|
151
|
-
after: {
|
|
152
|
-
...after,
|
|
153
|
-
index: afterIndex
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
function getHandleBounds(ctx, id = ctx.activeResizeId) {
|
|
158
|
-
const panels = getHandlePanels(ctx, id);
|
|
159
|
-
if (!panels)
|
|
160
|
-
return;
|
|
161
|
-
const { before, after } = panels;
|
|
162
|
-
return {
|
|
163
|
-
min: Math.max(before.start + before.minSize, after.end - after.maxSize),
|
|
164
|
-
max: Math.min(after.end - after.minSize, before.maxSize + before.start)
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
function getPanelBounds(ctx, id) {
|
|
168
|
-
const bounds = getHandleBounds(ctx, id);
|
|
169
|
-
const panels = getHandlePanels(ctx, id);
|
|
170
|
-
if (!bounds || !panels)
|
|
171
|
-
return;
|
|
172
|
-
const { before, after } = panels;
|
|
173
|
-
const beforeMin = Math.abs(before.start - bounds.min);
|
|
174
|
-
const afterMin = after.size + (before.size - beforeMin);
|
|
175
|
-
const beforeMax = Math.abs(before.start - bounds.max);
|
|
176
|
-
const afterMax = after.size - (beforeMax - before.size);
|
|
177
|
-
return {
|
|
178
|
-
before: {
|
|
179
|
-
index: before.index,
|
|
180
|
-
min: beforeMin,
|
|
181
|
-
max: beforeMax,
|
|
182
|
-
isAtMin: beforeMin === before.size,
|
|
183
|
-
isAtMax: beforeMax === before.size,
|
|
184
|
-
up(step) {
|
|
185
|
-
return Math.min(before.size + step, beforeMax);
|
|
186
|
-
},
|
|
187
|
-
down(step) {
|
|
188
|
-
return Math.max(before.size - step, beforeMin);
|
|
189
|
-
}
|
|
190
|
-
},
|
|
191
|
-
after: {
|
|
192
|
-
index: after.index,
|
|
193
|
-
min: afterMin,
|
|
194
|
-
max: afterMax,
|
|
195
|
-
isAtMin: afterMin === after.size,
|
|
196
|
-
isAtMax: afterMax === after.size,
|
|
197
|
-
up(step) {
|
|
198
|
-
return Math.min(after.size + step, afterMin);
|
|
199
|
-
},
|
|
200
|
-
down(step) {
|
|
201
|
-
return Math.max(after.size - step, afterMax);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
function clamp(value, min, max) {
|
|
207
|
-
return Math.min(Math.max(value, min), max);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// src/splitter.machine.ts
|
|
211
12
|
function machine(userContext) {
|
|
212
|
-
const ctx =
|
|
213
|
-
return
|
|
13
|
+
const ctx = utils.compact(userContext);
|
|
14
|
+
return core.createMachine(
|
|
214
15
|
{
|
|
215
16
|
id: "splitter",
|
|
216
17
|
initial: "idle",
|
|
@@ -232,25 +33,10 @@ function machine(userContext) {
|
|
|
232
33
|
},
|
|
233
34
|
computed: {
|
|
234
35
|
isHorizontal: (ctx2) => ctx2.orientation === "horizontal",
|
|
235
|
-
panels: (ctx2) => getNormalizedPanels(ctx2)
|
|
36
|
+
panels: (ctx2) => splitter_utils.getNormalizedPanels(ctx2)
|
|
236
37
|
},
|
|
237
38
|
on: {
|
|
238
|
-
|
|
239
|
-
actions: "setStartPanelToMin"
|
|
240
|
-
},
|
|
241
|
-
EXPAND: {
|
|
242
|
-
actions: "setStartPanelToMax"
|
|
243
|
-
},
|
|
244
|
-
TOGGLE: [
|
|
245
|
-
{
|
|
246
|
-
guard: "isStartPanelAtMin",
|
|
247
|
-
actions: "setStartPanelToMax"
|
|
248
|
-
},
|
|
249
|
-
{
|
|
250
|
-
actions: "setStartPanelToMin"
|
|
251
|
-
}
|
|
252
|
-
],
|
|
253
|
-
SET_SIZE: {
|
|
39
|
+
SET_PANEL_SIZE: {
|
|
254
40
|
actions: "setPanelSize"
|
|
255
41
|
}
|
|
256
42
|
},
|
|
@@ -351,8 +137,8 @@ function machine(userContext) {
|
|
|
351
137
|
{
|
|
352
138
|
activities: {
|
|
353
139
|
trackPointerMove: (ctx2, _evt, { send }) => {
|
|
354
|
-
const doc = dom.getDoc(ctx2);
|
|
355
|
-
return
|
|
140
|
+
const doc = splitter_dom.dom.getDoc(ctx2);
|
|
141
|
+
return domEvent.trackPointerMove(doc, {
|
|
356
142
|
onPointerMove(info) {
|
|
357
143
|
send({ type: "POINTER_MOVE", point: info.point });
|
|
358
144
|
},
|
|
@@ -373,10 +159,10 @@ function machine(userContext) {
|
|
|
373
159
|
},
|
|
374
160
|
actions: {
|
|
375
161
|
setGlobalCursor(ctx2) {
|
|
376
|
-
dom.setupGlobalCursor(ctx2);
|
|
162
|
+
splitter_dom.dom.setupGlobalCursor(ctx2);
|
|
377
163
|
},
|
|
378
164
|
clearGlobalCursor(ctx2) {
|
|
379
|
-
dom.removeGlobalCursor(ctx2);
|
|
165
|
+
splitter_dom.dom.removeGlobalCursor(ctx2);
|
|
380
166
|
},
|
|
381
167
|
invokeOnResize(ctx2) {
|
|
382
168
|
ctx2.onResize?.({ size: ctx2.size, activeHandleId: ctx2.activeResizeId });
|
|
@@ -402,12 +188,12 @@ function machine(userContext) {
|
|
|
402
188
|
setPanelSize(ctx2, evt) {
|
|
403
189
|
const { id, size } = evt;
|
|
404
190
|
ctx2.size = ctx2.size.map((panel) => {
|
|
405
|
-
const panelSize = clamp(size, panel.minSize ?? 0, panel.maxSize ?? 100);
|
|
191
|
+
const panelSize = splitter_utils.clamp(size, panel.minSize ?? 0, panel.maxSize ?? 100);
|
|
406
192
|
return panel.id === id ? { ...panel, size: panelSize } : panel;
|
|
407
193
|
});
|
|
408
194
|
},
|
|
409
195
|
setStartPanelToMin(ctx2) {
|
|
410
|
-
const bounds = getPanelBounds(ctx2);
|
|
196
|
+
const bounds = splitter_utils.getPanelBounds(ctx2);
|
|
411
197
|
if (!bounds)
|
|
412
198
|
return;
|
|
413
199
|
const { before, after } = bounds;
|
|
@@ -415,7 +201,7 @@ function machine(userContext) {
|
|
|
415
201
|
ctx2.size[after.index].size = after.min;
|
|
416
202
|
},
|
|
417
203
|
setStartPanelToMax(ctx2) {
|
|
418
|
-
const bounds = getPanelBounds(ctx2);
|
|
204
|
+
const bounds = splitter_utils.getPanelBounds(ctx2);
|
|
419
205
|
if (!bounds)
|
|
420
206
|
return;
|
|
421
207
|
const { before, after } = bounds;
|
|
@@ -423,7 +209,7 @@ function machine(userContext) {
|
|
|
423
209
|
ctx2.size[after.index].size = after.max;
|
|
424
210
|
},
|
|
425
211
|
expandStartPanel(ctx2, evt) {
|
|
426
|
-
const bounds = getPanelBounds(ctx2);
|
|
212
|
+
const bounds = splitter_utils.getPanelBounds(ctx2);
|
|
427
213
|
if (!bounds)
|
|
428
214
|
return;
|
|
429
215
|
const { before, after } = bounds;
|
|
@@ -431,7 +217,7 @@ function machine(userContext) {
|
|
|
431
217
|
ctx2.size[after.index].size = after.down(evt.step);
|
|
432
218
|
},
|
|
433
219
|
shrinkStartPanel(ctx2, evt) {
|
|
434
|
-
const bounds = getPanelBounds(ctx2);
|
|
220
|
+
const bounds = splitter_utils.getPanelBounds(ctx2);
|
|
435
221
|
if (!bounds)
|
|
436
222
|
return;
|
|
437
223
|
const { before, after } = bounds;
|
|
@@ -439,7 +225,7 @@ function machine(userContext) {
|
|
|
439
225
|
ctx2.size[after.index].size = after.up(evt.step);
|
|
440
226
|
},
|
|
441
227
|
resetStartPanel(ctx2, evt) {
|
|
442
|
-
const bounds = getPanelBounds(ctx2, evt.id);
|
|
228
|
+
const bounds = splitter_utils.getPanelBounds(ctx2, evt.id);
|
|
443
229
|
if (!bounds)
|
|
444
230
|
return;
|
|
445
231
|
const { before, after } = bounds;
|
|
@@ -447,20 +233,20 @@ function machine(userContext) {
|
|
|
447
233
|
ctx2.size[after.index].size = ctx2.initialSize[after.index].size;
|
|
448
234
|
},
|
|
449
235
|
focusResizeHandle(ctx2) {
|
|
450
|
-
|
|
451
|
-
dom.getActiveHandleEl(ctx2)?.focus({ preventScroll: true });
|
|
236
|
+
domQuery.raf(() => {
|
|
237
|
+
splitter_dom.dom.getActiveHandleEl(ctx2)?.focus({ preventScroll: true });
|
|
452
238
|
});
|
|
453
239
|
},
|
|
454
240
|
blurResizeHandle(ctx2) {
|
|
455
|
-
|
|
456
|
-
dom.getActiveHandleEl(ctx2)?.blur();
|
|
241
|
+
domQuery.raf(() => {
|
|
242
|
+
splitter_dom.dom.getActiveHandleEl(ctx2)?.blur();
|
|
457
243
|
});
|
|
458
244
|
},
|
|
459
245
|
setPreviousPanels(ctx2) {
|
|
460
246
|
ctx2.previousPanels = ctx2.panels.slice();
|
|
461
247
|
},
|
|
462
248
|
setActiveResizeState(ctx2) {
|
|
463
|
-
const panels = getPanelBounds(ctx2);
|
|
249
|
+
const panels = splitter_utils.getPanelBounds(ctx2);
|
|
464
250
|
if (!panels)
|
|
465
251
|
return;
|
|
466
252
|
const { before } = panels;
|
|
@@ -470,12 +256,12 @@ function machine(userContext) {
|
|
|
470
256
|
};
|
|
471
257
|
},
|
|
472
258
|
setPointerValue(ctx2, evt) {
|
|
473
|
-
const panels = getHandlePanels(ctx2);
|
|
474
|
-
const bounds = getHandleBounds(ctx2);
|
|
259
|
+
const panels = splitter_utils.getHandlePanels(ctx2);
|
|
260
|
+
const bounds = splitter_utils.getHandleBounds(ctx2);
|
|
475
261
|
if (!panels || !bounds)
|
|
476
262
|
return;
|
|
477
|
-
const rootEl = dom.getRootEl(ctx2);
|
|
478
|
-
const relativePoint =
|
|
263
|
+
const rootEl = splitter_dom.dom.getRootEl(ctx2);
|
|
264
|
+
const relativePoint = domEvent.getRelativePoint(evt.point, rootEl);
|
|
479
265
|
const percentValue = relativePoint.getPercentValue({
|
|
480
266
|
dir: ctx2.dir,
|
|
481
267
|
orientation: ctx2.orientation
|
|
@@ -485,7 +271,7 @@ function machine(userContext) {
|
|
|
485
271
|
isAtMin: pointValue < bounds.min,
|
|
486
272
|
isAtMax: pointValue > bounds.max
|
|
487
273
|
};
|
|
488
|
-
pointValue = clamp(pointValue, bounds.min, bounds.max);
|
|
274
|
+
pointValue = splitter_utils.clamp(pointValue, bounds.min, bounds.max);
|
|
489
275
|
const { before, after } = panels;
|
|
490
276
|
const offset = pointValue - before.end;
|
|
491
277
|
ctx2.size[before.index].size = before.size + offset;
|
|
@@ -495,7 +281,5 @@ function machine(userContext) {
|
|
|
495
281
|
}
|
|
496
282
|
);
|
|
497
283
|
}
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
machine
|
|
501
|
-
});
|
|
284
|
+
|
|
285
|
+
exports.machine = machine;
|