@zag-js/splitter 0.2.5 → 0.2.7
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/chunk-HPRMFGOY.mjs +9 -0
- package/dist/chunk-IOEWCDUH.mjs +556 -0
- package/dist/chunk-SQ3UMXCZ.mjs +131 -0
- package/dist/chunk-T56NFB6E.mjs +102 -0
- package/dist/chunk-X2M4RMIJ.mjs +206 -0
- package/dist/index.d.ts +7 -966
- package/dist/index.js +502 -336
- package/dist/index.mjs +11 -794
- package/dist/splitter.anatomy.d.ts +6 -0
- package/dist/splitter.anatomy.js +34 -0
- package/dist/splitter.anatomy.mjs +8 -0
- package/dist/splitter.connect.d.ts +28 -0
- package/dist/splitter.connect.js +360 -0
- package/dist/splitter.connect.mjs +9 -0
- package/dist/splitter.dom.d.ts +39 -0
- package/dist/splitter.dom.js +128 -0
- package/dist/splitter.dom.mjs +6 -0
- package/dist/splitter.machine.d.ts +7 -0
- package/dist/splitter.machine.js +792 -0
- package/dist/splitter.machine.mjs +8 -0
- package/dist/splitter.types.d.ts +68 -0
- package/dist/splitter.types.js +18 -0
- package/dist/splitter.types.mjs +0 -0
- package/dist/splitter.utils.d.ts +54 -0
- package/dist/splitter.utils.js +159 -0
- package/dist/splitter.utils.mjs +14 -0
- package/package.json +22 -12
package/dist/index.mjs
CHANGED
|
@@ -1,797 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// ../../utilities/dom/dist/index.mjs
|
|
14
|
-
var dataAttr = (guard) => {
|
|
15
|
-
return guard ? "" : void 0;
|
|
16
|
-
};
|
|
17
|
-
var runIfFn = (v, ...a) => {
|
|
18
|
-
const res = typeof v === "function" ? v(...a) : v;
|
|
19
|
-
return res != null ? res : void 0;
|
|
20
|
-
};
|
|
21
|
-
var callAll = (...fns) => (...a) => {
|
|
22
|
-
fns.forEach(function(fn) {
|
|
23
|
-
fn == null ? void 0 : fn(...a);
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var isArray = (v) => Array.isArray(v);
|
|
27
|
-
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
|
|
28
|
-
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
29
|
-
var isDom = () => typeof window !== "undefined";
|
|
30
|
-
function getPlatform() {
|
|
31
|
-
var _a;
|
|
32
|
-
const agent = navigator.userAgentData;
|
|
33
|
-
return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform;
|
|
34
|
-
}
|
|
35
|
-
var pt = (v) => isDom() && v.test(getPlatform());
|
|
36
|
-
var isTouchDevice = () => isDom() && !!navigator.maxTouchPoints;
|
|
37
|
-
var isMac = () => pt(/^Mac/) && !isTouchDevice;
|
|
38
|
-
var isApple = () => pt(/mac|iphone|ipad|ipod/i);
|
|
39
|
-
var isIos = () => isApple() && !isMac();
|
|
40
|
-
function isDocument(el) {
|
|
41
|
-
return el.nodeType === Node.DOCUMENT_NODE;
|
|
42
|
-
}
|
|
43
|
-
function isWindow(value) {
|
|
44
|
-
return (value == null ? void 0 : value.toString()) === "[object Window]";
|
|
45
|
-
}
|
|
46
|
-
function getDocument(el) {
|
|
47
|
-
var _a;
|
|
48
|
-
if (isWindow(el))
|
|
49
|
-
return el.document;
|
|
50
|
-
if (isDocument(el))
|
|
51
|
-
return el;
|
|
52
|
-
return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
|
|
53
|
-
}
|
|
54
|
-
function defineDomHelpers(helpers) {
|
|
55
|
-
const dom2 = {
|
|
56
|
-
getRootNode: (ctx) => {
|
|
57
|
-
var _a, _b;
|
|
58
|
-
return (_b = (_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) != null ? _b : document;
|
|
59
|
-
},
|
|
60
|
-
getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
|
|
61
|
-
getWin: (ctx) => {
|
|
62
|
-
var _a;
|
|
63
|
-
return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
|
|
64
|
-
},
|
|
65
|
-
getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
|
|
66
|
-
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id),
|
|
67
|
-
createEmitter: (ctx, target) => {
|
|
68
|
-
const win = dom2.getWin(ctx);
|
|
69
|
-
return function emit(evt, detail, options) {
|
|
70
|
-
const { bubbles = true, cancelable, composed = true } = options != null ? options : {};
|
|
71
|
-
const eventName = `zag:${evt}`;
|
|
72
|
-
const init = { bubbles, cancelable, composed, detail };
|
|
73
|
-
const event = new win.CustomEvent(eventName, init);
|
|
74
|
-
target.dispatchEvent(event);
|
|
75
|
-
};
|
|
76
|
-
},
|
|
77
|
-
createListener: (target) => {
|
|
78
|
-
return function listen(evt, handler) {
|
|
79
|
-
const eventName = `zag:${evt}`;
|
|
80
|
-
const listener = (e) => handler(e);
|
|
81
|
-
target.addEventListener(eventName, listener);
|
|
82
|
-
return () => target.removeEventListener(eventName, listener);
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
return {
|
|
87
|
-
...dom2,
|
|
88
|
-
...helpers
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
|
|
92
|
-
var supportsTouchEvent = () => isDom() && window.ontouchstart === null;
|
|
93
|
-
var supportsMouseEvent = () => isDom() && window.onmousedown === null;
|
|
94
|
-
var isMouseEvent = (v) => isObject(v) && hasProp(v, "button");
|
|
95
|
-
var isTouchEvent = (v) => isObject(v) && hasProp(v, "touches");
|
|
96
|
-
var isLeftClick = (v) => v.button === 0;
|
|
97
|
-
function getElementOffset(element) {
|
|
98
|
-
let left = 0;
|
|
99
|
-
let top = 0;
|
|
100
|
-
let el = element;
|
|
101
|
-
if (el.parentNode) {
|
|
102
|
-
do {
|
|
103
|
-
left += el.offsetLeft;
|
|
104
|
-
top += el.offsetTop;
|
|
105
|
-
} while ((el = el.offsetParent) && el.nodeType < 9);
|
|
106
|
-
el = element;
|
|
107
|
-
do {
|
|
108
|
-
left -= el.scrollLeft;
|
|
109
|
-
top -= el.scrollTop;
|
|
110
|
-
} while ((el = el.parentNode) && !/body/i.test(el.nodeName));
|
|
111
|
-
}
|
|
112
|
-
return {
|
|
113
|
-
top,
|
|
114
|
-
right: innerWidth - left - element.offsetWidth,
|
|
115
|
-
bottom: innerHeight - top - element.offsetHeight,
|
|
116
|
-
left
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
function getPointRelativeToNode(point, element) {
|
|
120
|
-
const offset = getElementOffset(element);
|
|
121
|
-
const x = point.x - offset.left;
|
|
122
|
-
const y = point.y - offset.top;
|
|
123
|
-
return { x, y };
|
|
124
|
-
}
|
|
125
|
-
var rtlKeyMap = {
|
|
126
|
-
ArrowLeft: "ArrowRight",
|
|
127
|
-
ArrowRight: "ArrowLeft"
|
|
128
|
-
};
|
|
129
|
-
var sameKeyMap = {
|
|
130
|
-
Up: "ArrowUp",
|
|
131
|
-
Down: "ArrowDown",
|
|
132
|
-
Esc: "Escape",
|
|
133
|
-
" ": "Space",
|
|
134
|
-
",": "Comma",
|
|
135
|
-
Left: "ArrowLeft",
|
|
136
|
-
Right: "ArrowRight"
|
|
137
|
-
};
|
|
138
|
-
function getEventKey(event, options = {}) {
|
|
139
|
-
var _a;
|
|
140
|
-
const { dir = "ltr", orientation = "horizontal" } = options;
|
|
141
|
-
let { key } = event;
|
|
142
|
-
key = (_a = sameKeyMap[key]) != null ? _a : key;
|
|
143
|
-
const isRtl = dir === "rtl" && orientation === "horizontal";
|
|
144
|
-
if (isRtl && key in rtlKeyMap) {
|
|
145
|
-
key = rtlKeyMap[key];
|
|
146
|
-
}
|
|
147
|
-
return key;
|
|
148
|
-
}
|
|
149
|
-
var PAGE_KEYS = /* @__PURE__ */ new Set(["PageUp", "PageDown"]);
|
|
150
|
-
var ARROW_KEYS = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"]);
|
|
151
|
-
function getEventStep(event) {
|
|
152
|
-
if (event.ctrlKey || event.metaKey) {
|
|
153
|
-
return 0.1;
|
|
154
|
-
} else {
|
|
155
|
-
const isPageKey = PAGE_KEYS.has(event.key);
|
|
156
|
-
const isSkipKey = isPageKey || event.shiftKey && ARROW_KEYS.has(event.key);
|
|
157
|
-
return isSkipKey ? 10 : 1;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
var isRef = (v) => hasProp(v, "current");
|
|
161
|
-
var fallback2 = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
|
|
162
|
-
function extractInfo(event, type = "page") {
|
|
163
|
-
const point = isTouchEvent(event) ? event.touches[0] || event.changedTouches[0] || fallback2 : event;
|
|
164
|
-
return {
|
|
165
|
-
point: {
|
|
166
|
-
x: point[`${type}X`],
|
|
167
|
-
y: point[`${type}Y`]
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
function addDomEvent(target, eventName, handler, options) {
|
|
172
|
-
const node = isRef(target) ? target.current : runIfFn(target);
|
|
173
|
-
node == null ? void 0 : node.addEventListener(eventName, handler, options);
|
|
174
|
-
return () => {
|
|
175
|
-
node == null ? void 0 : node.removeEventListener(eventName, handler, options);
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
function addPointerEvent(target, event, listener, options) {
|
|
179
|
-
var _a;
|
|
180
|
-
const type = (_a = getEventName(event)) != null ? _a : event;
|
|
181
|
-
return addDomEvent(target, type, wrapHandler(listener, event === "pointerdown"), options);
|
|
182
|
-
}
|
|
183
|
-
function wrapHandler(fn, filter = false) {
|
|
184
|
-
const listener = (event) => {
|
|
185
|
-
fn(event, extractInfo(event));
|
|
186
|
-
};
|
|
187
|
-
return filter ? filterPrimaryPointer(listener) : listener;
|
|
188
|
-
}
|
|
189
|
-
function filterPrimaryPointer(fn) {
|
|
190
|
-
return (event) => {
|
|
191
|
-
var _a;
|
|
192
|
-
const win = (_a = event.view) != null ? _a : window;
|
|
193
|
-
const isMouseEvent2 = event instanceof win.MouseEvent;
|
|
194
|
-
const isPrimary = !isMouseEvent2 || isMouseEvent2 && event.button === 0;
|
|
195
|
-
if (isPrimary)
|
|
196
|
-
fn(event);
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
var mouseEventNames = {
|
|
200
|
-
pointerdown: "mousedown",
|
|
201
|
-
pointermove: "mousemove",
|
|
202
|
-
pointerup: "mouseup",
|
|
203
|
-
pointercancel: "mousecancel",
|
|
204
|
-
pointerover: "mouseover",
|
|
205
|
-
pointerout: "mouseout",
|
|
206
|
-
pointerenter: "mouseenter",
|
|
207
|
-
pointerleave: "mouseleave"
|
|
208
|
-
};
|
|
209
|
-
var touchEventNames = {
|
|
210
|
-
pointerdown: "touchstart",
|
|
211
|
-
pointermove: "touchmove",
|
|
212
|
-
pointerup: "touchend",
|
|
213
|
-
pointercancel: "touchcancel"
|
|
214
|
-
};
|
|
215
|
-
function getEventName(evt) {
|
|
216
|
-
if (supportsPointerEvent())
|
|
217
|
-
return evt;
|
|
218
|
-
if (supportsTouchEvent())
|
|
219
|
-
return touchEventNames[evt];
|
|
220
|
-
if (supportsMouseEvent())
|
|
221
|
-
return mouseEventNames[evt];
|
|
222
|
-
return evt;
|
|
223
|
-
}
|
|
224
|
-
function nextTick(fn) {
|
|
225
|
-
const set = /* @__PURE__ */ new Set();
|
|
226
|
-
function raf2(fn2) {
|
|
227
|
-
const id = globalThis.requestAnimationFrame(fn2);
|
|
228
|
-
set.add(() => globalThis.cancelAnimationFrame(id));
|
|
229
|
-
}
|
|
230
|
-
raf2(() => raf2(fn));
|
|
231
|
-
return function cleanup() {
|
|
232
|
-
set.forEach(function(fn2) {
|
|
233
|
-
fn2();
|
|
234
|
-
});
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
function raf(fn) {
|
|
238
|
-
const id = globalThis.requestAnimationFrame(fn);
|
|
239
|
-
return function cleanup() {
|
|
240
|
-
globalThis.cancelAnimationFrame(id);
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
var state = "default";
|
|
244
|
-
var savedUserSelect = "";
|
|
245
|
-
var modifiedElementMap = /* @__PURE__ */ new WeakMap();
|
|
246
|
-
function disableTextSelection({ target, doc } = {}) {
|
|
247
|
-
const _document = doc != null ? doc : document;
|
|
248
|
-
if (isIos()) {
|
|
249
|
-
if (state === "default") {
|
|
250
|
-
savedUserSelect = _document.documentElement.style.webkitUserSelect;
|
|
251
|
-
_document.documentElement.style.webkitUserSelect = "none";
|
|
252
|
-
}
|
|
253
|
-
state = "disabled";
|
|
254
|
-
} else if (target) {
|
|
255
|
-
modifiedElementMap.set(target, target.style.userSelect);
|
|
256
|
-
target.style.userSelect = "none";
|
|
257
|
-
}
|
|
258
|
-
return () => restoreTextSelection({ target, doc: _document });
|
|
259
|
-
}
|
|
260
|
-
function restoreTextSelection({ target, doc } = {}) {
|
|
261
|
-
const _document = doc != null ? doc : document;
|
|
262
|
-
if (isIos()) {
|
|
263
|
-
if (state !== "disabled")
|
|
264
|
-
return;
|
|
265
|
-
state = "restoring";
|
|
266
|
-
setTimeout(() => {
|
|
267
|
-
nextTick(() => {
|
|
268
|
-
if (state === "restoring") {
|
|
269
|
-
if (_document.documentElement.style.webkitUserSelect === "none") {
|
|
270
|
-
_document.documentElement.style.webkitUserSelect = savedUserSelect || "";
|
|
271
|
-
}
|
|
272
|
-
savedUserSelect = "";
|
|
273
|
-
state = "default";
|
|
274
|
-
}
|
|
275
|
-
});
|
|
276
|
-
}, 300);
|
|
277
|
-
} else {
|
|
278
|
-
if (target && modifiedElementMap.has(target)) {
|
|
279
|
-
let targetOldUserSelect = modifiedElementMap.get(target);
|
|
280
|
-
if (target.style.userSelect === "none") {
|
|
281
|
-
target.style.userSelect = targetOldUserSelect != null ? targetOldUserSelect : "";
|
|
282
|
-
}
|
|
283
|
-
if (target.getAttribute("style") === "") {
|
|
284
|
-
target.removeAttribute("style");
|
|
285
|
-
}
|
|
286
|
-
modifiedElementMap.delete(target);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
var THRESHOLD = 5;
|
|
291
|
-
function trackPointerMove(doc, opts) {
|
|
292
|
-
const { onPointerMove, onPointerUp } = opts;
|
|
293
|
-
const handlePointerMove = (event, info) => {
|
|
294
|
-
const { point: p } = info;
|
|
295
|
-
const distance = Math.sqrt(p.x ** 2 + p.y ** 2);
|
|
296
|
-
if (distance < THRESHOLD)
|
|
297
|
-
return;
|
|
298
|
-
if (isMouseEvent(event) && isLeftClick(event)) {
|
|
299
|
-
onPointerUp();
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
onPointerMove(info, event);
|
|
303
|
-
};
|
|
304
|
-
return callAll(
|
|
305
|
-
addPointerEvent(doc, "pointermove", handlePointerMove, false),
|
|
306
|
-
addPointerEvent(doc, "pointerup", onPointerUp, false),
|
|
307
|
-
addPointerEvent(doc, "pointercancel", onPointerUp, false),
|
|
308
|
-
addPointerEvent(doc, "contextmenu", onPointerUp, false),
|
|
309
|
-
disableTextSelection({ doc })
|
|
310
|
-
);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
// src/splitter.dom.ts
|
|
314
|
-
var dom = defineDomHelpers({
|
|
315
|
-
getRootId: (ctx) => {
|
|
316
|
-
var _a, _b;
|
|
317
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.root) != null ? _b : `splitter:${ctx.id}`;
|
|
318
|
-
},
|
|
319
|
-
getSplitterId: (ctx) => {
|
|
320
|
-
var _a, _b;
|
|
321
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.splitter) != null ? _b : `splitter:${ctx.id}:splitter`;
|
|
322
|
-
},
|
|
323
|
-
getToggleButtonId: (ctx) => {
|
|
324
|
-
var _a, _b;
|
|
325
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.toggleBtn) != null ? _b : `splitter:${ctx.id}:toggle-btn`;
|
|
326
|
-
},
|
|
327
|
-
getLabelId: (ctx) => {
|
|
328
|
-
var _a, _b;
|
|
329
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.label) != null ? _b : `splitter:${ctx.id}:label`;
|
|
330
|
-
},
|
|
331
|
-
getPrimaryPaneId: (ctx) => {
|
|
332
|
-
var _a, _b;
|
|
333
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.primaryPane) != null ? _b : `splitter:${ctx.id}:primary`;
|
|
334
|
-
},
|
|
335
|
-
getSecondaryPaneId: (ctx) => {
|
|
336
|
-
var _a, _b;
|
|
337
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.secondaryPane) != null ? _b : `splitter:${ctx.id}:secondary`;
|
|
338
|
-
},
|
|
339
|
-
getSplitterEl: (ctx) => dom.getById(ctx, dom.getSplitterId(ctx)),
|
|
340
|
-
getPrimaryPaneEl: (ctx) => dom.getById(ctx, dom.getPrimaryPaneId(ctx)),
|
|
341
|
-
getCursor(ctx) {
|
|
342
|
-
if (ctx.disabled || ctx.fixed)
|
|
343
|
-
return "default";
|
|
344
|
-
const x = ctx.isHorizontal;
|
|
345
|
-
let cursor = x ? "col-resize" : "row-resize";
|
|
346
|
-
if (ctx.isAtMin)
|
|
347
|
-
cursor = x ? "e-resize" : "s-resize";
|
|
348
|
-
if (ctx.isAtMax)
|
|
349
|
-
cursor = x ? "w-resize" : "n-resize";
|
|
350
|
-
return cursor;
|
|
351
|
-
}
|
|
352
|
-
});
|
|
353
|
-
|
|
354
|
-
// src/splitter.connect.ts
|
|
355
|
-
function connect(state2, send, normalize) {
|
|
356
|
-
const isHorizontal = state2.context.isHorizontal;
|
|
357
|
-
const isDisabled = state2.context.disabled;
|
|
358
|
-
const isFocused = state2.hasTag("focus");
|
|
359
|
-
const isDragging = state2.matches("dragging");
|
|
360
|
-
const isAtMin = state2.context.isAtMin;
|
|
361
|
-
const isAtMax = state2.context.isAtMax;
|
|
362
|
-
const min = state2.context.min;
|
|
363
|
-
const max = state2.context.max;
|
|
364
|
-
const value = state2.context.value;
|
|
365
|
-
return {
|
|
366
|
-
isCollapsed: isAtMin,
|
|
367
|
-
isExpanded: isAtMax,
|
|
368
|
-
isFocused,
|
|
369
|
-
isDragging,
|
|
370
|
-
value,
|
|
371
|
-
collapse() {
|
|
372
|
-
send("COLLAPSE");
|
|
373
|
-
},
|
|
374
|
-
expand() {
|
|
375
|
-
send("EXPAND");
|
|
376
|
-
},
|
|
377
|
-
toggle() {
|
|
378
|
-
send("TOGGLE");
|
|
379
|
-
},
|
|
380
|
-
setSize(size) {
|
|
381
|
-
send({ type: "SET_SIZE", size });
|
|
382
|
-
},
|
|
383
|
-
rootProps: normalize.element({
|
|
384
|
-
...parts.root.attrs,
|
|
385
|
-
"data-orientation": state2.context.orientation,
|
|
386
|
-
"data-disabled": dataAttr(isDisabled),
|
|
387
|
-
id: dom.getRootId(state2.context),
|
|
388
|
-
style: {
|
|
389
|
-
display: "flex",
|
|
390
|
-
flex: "1 1 0%",
|
|
391
|
-
flexDirection: isHorizontal ? "row" : "column"
|
|
392
|
-
}
|
|
393
|
-
}),
|
|
394
|
-
secondaryPaneProps: normalize.element({
|
|
395
|
-
...parts.secondaryPane.attrs,
|
|
396
|
-
"data-disabled": dataAttr(isDisabled),
|
|
397
|
-
id: dom.getSecondaryPaneId(state2.context),
|
|
398
|
-
style: {
|
|
399
|
-
height: isHorizontal ? "100%" : "auto",
|
|
400
|
-
width: isHorizontal ? "auto" : "100%",
|
|
401
|
-
flex: "1 1 auto",
|
|
402
|
-
position: "relative"
|
|
403
|
-
}
|
|
404
|
-
}),
|
|
405
|
-
primaryPaneProps: normalize.element({
|
|
406
|
-
...parts.primaryPane.attrs,
|
|
407
|
-
id: dom.getPrimaryPaneId(state2.context),
|
|
408
|
-
"data-disabled": dataAttr(isDisabled),
|
|
409
|
-
"data-state": isAtMax ? "at-max" : isAtMin ? "at-min" : "between",
|
|
410
|
-
style: {
|
|
411
|
-
visibility: "visible",
|
|
412
|
-
flex: `0 0 ${value}px`,
|
|
413
|
-
position: "relative",
|
|
414
|
-
userSelect: isDragging ? "none" : "auto",
|
|
415
|
-
...isHorizontal ? { minWidth: `${min}px`, maxWidth: `${max}px` } : { minHeight: `${min}px`, maxHeight: `${max}px` }
|
|
416
|
-
}
|
|
417
|
-
}),
|
|
418
|
-
toggleButtonProps: normalize.element({
|
|
419
|
-
...parts.toggleButton.attrs,
|
|
420
|
-
id: dom.getToggleButtonId(state2.context),
|
|
421
|
-
"aria-label": state2.context.isAtMin ? "Expand Primary Pane" : "Collapse Primary Pane",
|
|
422
|
-
onClick() {
|
|
423
|
-
send("TOGGLE");
|
|
424
|
-
}
|
|
425
|
-
}),
|
|
426
|
-
labelProps: normalize.element({
|
|
427
|
-
...parts.label.attrs,
|
|
428
|
-
id: dom.getLabelId(state2.context)
|
|
429
|
-
}),
|
|
430
|
-
splitterProps: normalize.element({
|
|
431
|
-
...parts.splitter.attrs,
|
|
432
|
-
id: dom.getSplitterId(state2.context),
|
|
433
|
-
role: "separator",
|
|
434
|
-
tabIndex: isDisabled ? void 0 : 0,
|
|
435
|
-
"aria-valuenow": value,
|
|
436
|
-
"aria-valuemin": min,
|
|
437
|
-
"aria-valuemax": max,
|
|
438
|
-
"aria-orientation": state2.context.orientation,
|
|
439
|
-
"aria-labelledby": dom.getLabelId(state2.context),
|
|
440
|
-
"aria-controls": dom.getPrimaryPaneId(state2.context),
|
|
441
|
-
"data-orientation": state2.context.orientation,
|
|
442
|
-
"data-focus": dataAttr(isFocused),
|
|
443
|
-
"data-disabled": dataAttr(isDisabled),
|
|
444
|
-
style: {
|
|
445
|
-
touchAction: "none",
|
|
446
|
-
userSelect: "none",
|
|
447
|
-
WebkitUserSelect: "none",
|
|
448
|
-
msUserSelect: "none",
|
|
449
|
-
flex: "0 0 auto",
|
|
450
|
-
cursor: dom.getCursor(state2.context),
|
|
451
|
-
minHeight: isHorizontal ? "0px" : void 0,
|
|
452
|
-
minWidth: isHorizontal ? void 0 : "0px"
|
|
453
|
-
},
|
|
454
|
-
onPointerDown(event) {
|
|
455
|
-
if (isDisabled) {
|
|
456
|
-
event.preventDefault();
|
|
457
|
-
return;
|
|
458
|
-
}
|
|
459
|
-
send("POINTER_DOWN");
|
|
460
|
-
event.preventDefault();
|
|
461
|
-
event.stopPropagation();
|
|
462
|
-
},
|
|
463
|
-
onPointerOver() {
|
|
464
|
-
if (isDisabled)
|
|
465
|
-
return;
|
|
466
|
-
send("POINTER_OVER");
|
|
467
|
-
},
|
|
468
|
-
onPointerLeave() {
|
|
469
|
-
if (isDisabled)
|
|
470
|
-
return;
|
|
471
|
-
send("POINTER_LEAVE");
|
|
472
|
-
},
|
|
473
|
-
onBlur() {
|
|
474
|
-
send("BLUR");
|
|
475
|
-
},
|
|
476
|
-
onFocus() {
|
|
477
|
-
send("FOCUS");
|
|
478
|
-
},
|
|
479
|
-
onDoubleClick() {
|
|
480
|
-
if (isDisabled)
|
|
481
|
-
return;
|
|
482
|
-
send("DOUBLE_CLICK");
|
|
483
|
-
},
|
|
484
|
-
onKeyDown(event) {
|
|
485
|
-
if (isDisabled)
|
|
486
|
-
return;
|
|
487
|
-
const step = getEventStep(event) * state2.context.step;
|
|
488
|
-
const keyMap = {
|
|
489
|
-
ArrowUp() {
|
|
490
|
-
send({ type: "ARROW_UP", step });
|
|
491
|
-
},
|
|
492
|
-
ArrowDown() {
|
|
493
|
-
send({ type: "ARROW_DOWN", step });
|
|
494
|
-
},
|
|
495
|
-
ArrowLeft() {
|
|
496
|
-
send({ type: "ARROW_LEFT", step });
|
|
497
|
-
},
|
|
498
|
-
ArrowRight() {
|
|
499
|
-
send({ type: "ARROW_RIGHT", step });
|
|
500
|
-
},
|
|
501
|
-
Home() {
|
|
502
|
-
send("HOME");
|
|
503
|
-
},
|
|
504
|
-
End() {
|
|
505
|
-
send("END");
|
|
506
|
-
}
|
|
507
|
-
};
|
|
508
|
-
const key = getEventKey(event, state2.context);
|
|
509
|
-
const exec = keyMap[key];
|
|
510
|
-
if (exec) {
|
|
511
|
-
exec(event);
|
|
512
|
-
event.preventDefault();
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
})
|
|
516
|
-
};
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
// src/splitter.machine.ts
|
|
520
|
-
import { createMachine, guards } from "@zag-js/core";
|
|
521
|
-
|
|
522
|
-
// ../../utilities/number/dist/index.mjs
|
|
523
|
-
function round(v, t) {
|
|
524
|
-
let num = valueOf(v);
|
|
525
|
-
const p = 10 ** (t != null ? t : 10);
|
|
526
|
-
num = Math.round(num * p) / p;
|
|
527
|
-
return t ? num.toFixed(t) : v.toString();
|
|
528
|
-
}
|
|
529
|
-
function clamp(v, o) {
|
|
530
|
-
return Math.min(Math.max(valueOf(v), o.min), o.max);
|
|
531
|
-
}
|
|
532
|
-
function countDecimals(value) {
|
|
533
|
-
if (!Number.isFinite(value))
|
|
534
|
-
return 0;
|
|
535
|
-
let e = 1, p = 0;
|
|
536
|
-
while (Math.round(value * e) / e !== value) {
|
|
537
|
-
e *= 10;
|
|
538
|
-
p += 1;
|
|
539
|
-
}
|
|
540
|
-
return p;
|
|
541
|
-
}
|
|
542
|
-
var increment = (v, s) => decimalOperation(valueOf(v), "+", s);
|
|
543
|
-
var decrement = (v, s) => decimalOperation(valueOf(v), "-", s);
|
|
544
|
-
function snapToStep(value, step) {
|
|
545
|
-
const num = valueOf(value);
|
|
546
|
-
const p = countDecimals(step);
|
|
547
|
-
const v = Math.round(num / step) * step;
|
|
548
|
-
return round(v, p);
|
|
549
|
-
}
|
|
550
|
-
function valueOf(v) {
|
|
551
|
-
if (typeof v === "number")
|
|
552
|
-
return v;
|
|
553
|
-
const num = parseFloat(v.toString().replace(/[^\w.-]+/g, ""));
|
|
554
|
-
return !Number.isNaN(num) ? num : 0;
|
|
555
|
-
}
|
|
556
|
-
function decimalOperation(a, op, b) {
|
|
557
|
-
let result = op === "+" ? a + b : a - b;
|
|
558
|
-
if (a % 1 !== 0 || b % 1 !== 0) {
|
|
559
|
-
const multiplier = 10 ** Math.max(countDecimals(a), countDecimals(b));
|
|
560
|
-
a = Math.round(a * multiplier);
|
|
561
|
-
b = Math.round(b * multiplier);
|
|
562
|
-
result = op === "+" ? a + b : a - b;
|
|
563
|
-
result /= multiplier;
|
|
564
|
-
}
|
|
565
|
-
return result;
|
|
566
|
-
}
|
|
567
|
-
var nf = new Intl.NumberFormat("en-US", { style: "decimal", maximumFractionDigits: 20 });
|
|
568
|
-
|
|
569
|
-
// ../../utilities/core/dist/index.mjs
|
|
570
|
-
var isArray2 = (v) => Array.isArray(v);
|
|
571
|
-
var isObject2 = (v) => !(v == null || typeof v !== "object" || isArray2(v));
|
|
572
|
-
function compact(obj) {
|
|
573
|
-
if (obj === void 0)
|
|
574
|
-
return obj;
|
|
575
|
-
return Object.fromEntries(
|
|
576
|
-
Object.entries(obj).filter(([, value]) => value !== void 0).map(([key, value]) => [key, isObject2(value) ? compact(value) : value])
|
|
577
|
-
);
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
// src/splitter.machine.ts
|
|
581
|
-
var { not } = guards;
|
|
582
|
-
function machine(userContext) {
|
|
583
|
-
const ctx = compact(userContext);
|
|
584
|
-
return createMachine(
|
|
585
|
-
{
|
|
586
|
-
id: "splitter",
|
|
587
|
-
initial: "unknown",
|
|
588
|
-
context: {
|
|
589
|
-
orientation: "horizontal",
|
|
590
|
-
min: 224,
|
|
591
|
-
max: 340,
|
|
592
|
-
step: 1,
|
|
593
|
-
value: 256,
|
|
594
|
-
snapOffset: 0,
|
|
595
|
-
...ctx
|
|
596
|
-
},
|
|
597
|
-
computed: {
|
|
598
|
-
isHorizontal: (ctx2) => ctx2.orientation === "horizontal",
|
|
599
|
-
isAtMin: (ctx2) => ctx2.value === ctx2.min,
|
|
600
|
-
isAtMax: (ctx2) => ctx2.value === ctx2.max
|
|
601
|
-
},
|
|
602
|
-
on: {
|
|
603
|
-
COLLAPSE: {
|
|
604
|
-
actions: "setToMin"
|
|
605
|
-
},
|
|
606
|
-
EXPAND: {
|
|
607
|
-
actions: "setToMax"
|
|
608
|
-
},
|
|
609
|
-
TOGGLE: [
|
|
610
|
-
{
|
|
611
|
-
guard: "isCollapsed",
|
|
612
|
-
actions: "setToMax"
|
|
613
|
-
},
|
|
614
|
-
{
|
|
615
|
-
actions: "setToMin"
|
|
616
|
-
}
|
|
617
|
-
]
|
|
618
|
-
},
|
|
619
|
-
states: {
|
|
620
|
-
unknown: {
|
|
621
|
-
on: {
|
|
622
|
-
SETUP: "idle"
|
|
623
|
-
}
|
|
624
|
-
},
|
|
625
|
-
idle: {
|
|
626
|
-
on: {
|
|
627
|
-
POINTER_OVER: {
|
|
628
|
-
guard: not("isFixed"),
|
|
629
|
-
target: "hover:temp"
|
|
630
|
-
},
|
|
631
|
-
POINTER_LEAVE: "idle",
|
|
632
|
-
FOCUS: "focused"
|
|
633
|
-
}
|
|
634
|
-
},
|
|
635
|
-
"hover:temp": {
|
|
636
|
-
after: {
|
|
637
|
-
HOVER_DELAY: "hover"
|
|
638
|
-
},
|
|
639
|
-
on: {
|
|
640
|
-
POINTER_DOWN: {
|
|
641
|
-
target: "dragging",
|
|
642
|
-
actions: ["invokeOnChangeStart"]
|
|
643
|
-
},
|
|
644
|
-
POINTER_LEAVE: "idle"
|
|
645
|
-
}
|
|
646
|
-
},
|
|
647
|
-
hover: {
|
|
648
|
-
tags: ["focus"],
|
|
649
|
-
on: {
|
|
650
|
-
POINTER_DOWN: {
|
|
651
|
-
target: "dragging",
|
|
652
|
-
actions: ["invokeOnChangeStart"]
|
|
653
|
-
},
|
|
654
|
-
POINTER_LEAVE: "idle"
|
|
655
|
-
}
|
|
656
|
-
},
|
|
657
|
-
focused: {
|
|
658
|
-
tags: ["focus"],
|
|
659
|
-
on: {
|
|
660
|
-
BLUR: "idle",
|
|
661
|
-
POINTER_DOWN: {
|
|
662
|
-
target: "dragging",
|
|
663
|
-
actions: ["invokeOnChangeStart"]
|
|
664
|
-
},
|
|
665
|
-
ARROW_LEFT: {
|
|
666
|
-
guard: "isHorizontal",
|
|
667
|
-
actions: "decrement"
|
|
668
|
-
},
|
|
669
|
-
ARROW_RIGHT: {
|
|
670
|
-
guard: "isHorizontal",
|
|
671
|
-
actions: "increment"
|
|
672
|
-
},
|
|
673
|
-
ARROW_UP: {
|
|
674
|
-
guard: "isVertical",
|
|
675
|
-
actions: "increment"
|
|
676
|
-
},
|
|
677
|
-
ARROW_DOWN: {
|
|
678
|
-
guard: "isVertical",
|
|
679
|
-
actions: "decrement"
|
|
680
|
-
},
|
|
681
|
-
ENTER: [
|
|
682
|
-
{
|
|
683
|
-
guard: "isCollapsed",
|
|
684
|
-
actions: "setToMin"
|
|
685
|
-
},
|
|
686
|
-
{ actions: "setToMin" }
|
|
687
|
-
],
|
|
688
|
-
HOME: {
|
|
689
|
-
actions: "setToMin"
|
|
690
|
-
},
|
|
691
|
-
END: {
|
|
692
|
-
actions: "setToMax"
|
|
693
|
-
},
|
|
694
|
-
DOUBLE_CLICK: [
|
|
695
|
-
{
|
|
696
|
-
guard: "isCollapsed",
|
|
697
|
-
actions: "setToMax"
|
|
698
|
-
},
|
|
699
|
-
{ actions: "setToMin" }
|
|
700
|
-
]
|
|
701
|
-
}
|
|
702
|
-
},
|
|
703
|
-
dragging: {
|
|
704
|
-
tags: ["focus"],
|
|
705
|
-
entry: "focusSplitter",
|
|
706
|
-
activities: "trackPointerMove",
|
|
707
|
-
on: {
|
|
708
|
-
POINTER_UP: {
|
|
709
|
-
target: "focused",
|
|
710
|
-
actions: ["invokeOnChangeEnd"]
|
|
711
|
-
},
|
|
712
|
-
POINTER_MOVE: {
|
|
713
|
-
actions: "setPointerValue"
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
},
|
|
719
|
-
{
|
|
720
|
-
activities: {
|
|
721
|
-
trackPointerMove: (ctx2, _evt, { send }) => {
|
|
722
|
-
const doc = dom.getDoc(ctx2);
|
|
723
|
-
return trackPointerMove(doc, {
|
|
724
|
-
onPointerMove(info) {
|
|
725
|
-
send({ type: "POINTER_MOVE", point: info.point });
|
|
726
|
-
doc.documentElement.style.cursor = dom.getCursor(ctx2);
|
|
727
|
-
},
|
|
728
|
-
onPointerUp() {
|
|
729
|
-
send("POINTER_UP");
|
|
730
|
-
doc.documentElement.style.cursor = "";
|
|
731
|
-
}
|
|
732
|
-
});
|
|
733
|
-
}
|
|
734
|
-
},
|
|
735
|
-
guards: {
|
|
736
|
-
isCollapsed: (ctx2) => ctx2.isAtMin,
|
|
737
|
-
isHorizontal: (ctx2) => ctx2.isHorizontal,
|
|
738
|
-
isVertical: (ctx2) => !ctx2.isHorizontal,
|
|
739
|
-
isFixed: (ctx2) => !!ctx2.fixed
|
|
740
|
-
},
|
|
741
|
-
delays: {
|
|
742
|
-
HOVER_DELAY: 250
|
|
743
|
-
},
|
|
744
|
-
actions: {
|
|
745
|
-
invokeOnChange(ctx2, evt) {
|
|
746
|
-
var _a;
|
|
747
|
-
if (evt.type !== "SETUP") {
|
|
748
|
-
(_a = ctx2.onChange) == null ? void 0 : _a.call(ctx2, { value: ctx2.value });
|
|
749
|
-
}
|
|
750
|
-
},
|
|
751
|
-
invokeOnChangeStart(ctx2) {
|
|
752
|
-
var _a;
|
|
753
|
-
(_a = ctx2.onChangeStart) == null ? void 0 : _a.call(ctx2, { value: ctx2.value });
|
|
754
|
-
},
|
|
755
|
-
invokeOnChangeEnd(ctx2) {
|
|
756
|
-
var _a;
|
|
757
|
-
(_a = ctx2.onChangeEnd) == null ? void 0 : _a.call(ctx2, { value: ctx2.value });
|
|
758
|
-
},
|
|
759
|
-
setToMin(ctx2) {
|
|
760
|
-
ctx2.value = ctx2.min;
|
|
761
|
-
},
|
|
762
|
-
setToMax(ctx2) {
|
|
763
|
-
ctx2.value = ctx2.max;
|
|
764
|
-
},
|
|
765
|
-
increment(ctx2, evt) {
|
|
766
|
-
ctx2.value = clamp(increment(ctx2.value, evt.step), ctx2);
|
|
767
|
-
},
|
|
768
|
-
decrement(ctx2, evt) {
|
|
769
|
-
ctx2.value = clamp(decrement(ctx2.value, evt.step), ctx2);
|
|
770
|
-
},
|
|
771
|
-
focusSplitter(ctx2) {
|
|
772
|
-
raf(() => {
|
|
773
|
-
var _a;
|
|
774
|
-
return (_a = dom.getSplitterEl(ctx2)) == null ? void 0 : _a.focus();
|
|
775
|
-
});
|
|
776
|
-
},
|
|
777
|
-
setPointerValue(ctx2, evt) {
|
|
778
|
-
const el = dom.getPrimaryPaneEl(ctx2);
|
|
779
|
-
if (!el)
|
|
780
|
-
return;
|
|
781
|
-
const relativePoint = getPointRelativeToNode(evt.point, el);
|
|
782
|
-
let currentPoint = ctx2.isHorizontal ? relativePoint.x : relativePoint.y;
|
|
783
|
-
let value = parseFloat(snapToStep(clamp(currentPoint, ctx2), ctx2.step));
|
|
784
|
-
if (Math.abs(value - ctx2.min) <= ctx2.snapOffset) {
|
|
785
|
-
value = ctx2.min;
|
|
786
|
-
} else if (Math.abs(value - ctx2.max) <= ctx2.snapOffset) {
|
|
787
|
-
value = ctx2.max;
|
|
788
|
-
}
|
|
789
|
-
ctx2.value = value;
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
}
|
|
793
|
-
);
|
|
794
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
connect
|
|
3
|
+
} from "./chunk-X2M4RMIJ.mjs";
|
|
4
|
+
import {
|
|
5
|
+
anatomy
|
|
6
|
+
} from "./chunk-HPRMFGOY.mjs";
|
|
7
|
+
import {
|
|
8
|
+
machine
|
|
9
|
+
} from "./chunk-IOEWCDUH.mjs";
|
|
10
|
+
import "./chunk-T56NFB6E.mjs";
|
|
11
|
+
import "./chunk-SQ3UMXCZ.mjs";
|
|
795
12
|
export {
|
|
796
13
|
anatomy,
|
|
797
14
|
connect,
|