@zag-js/splitter 0.1.9 → 0.1.12
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/LICENSE +21 -0
- package/dist/index.d.ts +117 -3
- package/dist/index.js +263 -258
- package/dist/index.mjs +259 -262
- package/package.json +14 -11
- package/dist/splitter.connect.d.ts +0 -19
- package/dist/splitter.dom.d.ts +0 -14
- package/dist/splitter.machine.d.ts +0 -2
- package/dist/splitter.types.d.ts +0 -94
package/dist/index.js
CHANGED
|
@@ -2,21 +2,7 @@
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
-
var __spreadValues = (a, b) => {
|
|
10
|
-
for (var prop in b || (b = {}))
|
|
11
|
-
if (__hasOwnProp.call(b, prop))
|
|
12
|
-
__defNormalProp(a, prop, b[prop]);
|
|
13
|
-
if (__getOwnPropSymbols)
|
|
14
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
-
if (__propIsEnum.call(b, prop))
|
|
16
|
-
__defNormalProp(a, prop, b[prop]);
|
|
17
|
-
}
|
|
18
|
-
return a;
|
|
19
|
-
};
|
|
20
6
|
var __export = (target, all) => {
|
|
21
7
|
for (var name in all)
|
|
22
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -40,13 +26,12 @@ __export(src_exports, {
|
|
|
40
26
|
module.exports = __toCommonJS(src_exports);
|
|
41
27
|
|
|
42
28
|
// ../../utilities/dom/dist/index.mjs
|
|
43
|
-
var __pow = Math.pow;
|
|
44
29
|
var dataAttr = (guard) => {
|
|
45
30
|
return guard ? "" : void 0;
|
|
46
31
|
};
|
|
47
32
|
var runIfFn = (v, ...a) => {
|
|
48
33
|
const res = typeof v === "function" ? v(...a) : v;
|
|
49
|
-
return res
|
|
34
|
+
return res ?? void 0;
|
|
50
35
|
};
|
|
51
36
|
var callAll = (...fns) => (...a) => {
|
|
52
37
|
fns.forEach(function(fn) {
|
|
@@ -58,15 +43,43 @@ var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
|
|
|
58
43
|
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
59
44
|
var isDom = () => typeof window !== "undefined";
|
|
60
45
|
function getPlatform() {
|
|
61
|
-
var _a;
|
|
62
46
|
const agent = navigator.userAgentData;
|
|
63
|
-
return (
|
|
47
|
+
return (agent == null ? void 0 : agent.platform) ?? navigator.platform;
|
|
64
48
|
}
|
|
65
49
|
var pt = (v) => isDom() && v.test(getPlatform());
|
|
66
50
|
var isTouchDevice = () => isDom() && !!navigator.maxTouchPoints;
|
|
67
51
|
var isMac = () => pt(/^Mac/) && !isTouchDevice;
|
|
68
52
|
var isApple = () => pt(/mac|iphone|ipad|ipod/i);
|
|
69
53
|
var isIos = () => isApple() && !isMac();
|
|
54
|
+
function isDocument(el) {
|
|
55
|
+
return el.nodeType === Node.DOCUMENT_NODE;
|
|
56
|
+
}
|
|
57
|
+
function isWindow(value) {
|
|
58
|
+
return (value == null ? void 0 : value.toString()) === "[object Window]";
|
|
59
|
+
}
|
|
60
|
+
function getDocument(el) {
|
|
61
|
+
if (isWindow(el))
|
|
62
|
+
return el.document;
|
|
63
|
+
if (isDocument(el))
|
|
64
|
+
return el;
|
|
65
|
+
return (el == null ? void 0 : el.ownerDocument) ?? document;
|
|
66
|
+
}
|
|
67
|
+
function defineDomHelpers(helpers) {
|
|
68
|
+
const dom2 = {
|
|
69
|
+
getRootNode: (ctx) => {
|
|
70
|
+
var _a;
|
|
71
|
+
return ((_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) ?? document;
|
|
72
|
+
},
|
|
73
|
+
getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
|
|
74
|
+
getWin: (ctx) => dom2.getDoc(ctx).defaultView ?? window,
|
|
75
|
+
getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
|
|
76
|
+
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
|
|
77
|
+
};
|
|
78
|
+
return {
|
|
79
|
+
...dom2,
|
|
80
|
+
...helpers
|
|
81
|
+
};
|
|
82
|
+
}
|
|
70
83
|
var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
|
|
71
84
|
var supportsTouchEvent = () => isDom() && window.ontouchstart === null;
|
|
72
85
|
var supportsMouseEvent = () => isDom() && window.onmousedown === null;
|
|
@@ -117,10 +130,9 @@ var sameKeyMap = {
|
|
|
117
130
|
Right: "ArrowRight"
|
|
118
131
|
};
|
|
119
132
|
function getEventKey(event, options = {}) {
|
|
120
|
-
var _a;
|
|
121
133
|
const { dir = "ltr", orientation = "horizontal" } = options;
|
|
122
134
|
let { key } = event;
|
|
123
|
-
key =
|
|
135
|
+
key = sameKeyMap[key] ?? key;
|
|
124
136
|
const isRtl = dir === "rtl" && orientation === "horizontal";
|
|
125
137
|
if (isRtl && key in rtlKeyMap) {
|
|
126
138
|
key = rtlKeyMap[key];
|
|
@@ -157,8 +169,7 @@ function addDomEvent(target, eventName, handler, options) {
|
|
|
157
169
|
};
|
|
158
170
|
}
|
|
159
171
|
function addPointerEvent(target, event, listener, options) {
|
|
160
|
-
|
|
161
|
-
const type = (_a = getEventName(event)) != null ? _a : event;
|
|
172
|
+
const type = getEventName(event) ?? event;
|
|
162
173
|
return addDomEvent(target, type, wrapHandler(listener, event === "pointerdown"), options);
|
|
163
174
|
}
|
|
164
175
|
function wrapHandler(fn, filter = false) {
|
|
@@ -169,8 +180,7 @@ function wrapHandler(fn, filter = false) {
|
|
|
169
180
|
}
|
|
170
181
|
function filterPrimaryPointer(fn) {
|
|
171
182
|
return (event) => {
|
|
172
|
-
|
|
173
|
-
const win = (_a = event.view) != null ? _a : window;
|
|
183
|
+
const win = event.view ?? window;
|
|
174
184
|
const isMouseEvent2 = event instanceof win.MouseEvent;
|
|
175
185
|
const isPrimary = !isMouseEvent2 || isMouseEvent2 && event.button === 0;
|
|
176
186
|
if (isPrimary)
|
|
@@ -225,7 +235,7 @@ var state = "default";
|
|
|
225
235
|
var savedUserSelect = "";
|
|
226
236
|
var modifiedElementMap = /* @__PURE__ */ new WeakMap();
|
|
227
237
|
function disableTextSelection({ target, doc } = {}) {
|
|
228
|
-
const _document = doc
|
|
238
|
+
const _document = doc ?? document;
|
|
229
239
|
if (isIos()) {
|
|
230
240
|
if (state === "default") {
|
|
231
241
|
savedUserSelect = _document.documentElement.style.webkitUserSelect;
|
|
@@ -239,7 +249,7 @@ function disableTextSelection({ target, doc } = {}) {
|
|
|
239
249
|
return () => restoreTextSelection({ target, doc: _document });
|
|
240
250
|
}
|
|
241
251
|
function restoreTextSelection({ target, doc } = {}) {
|
|
242
|
-
const _document = doc
|
|
252
|
+
const _document = doc ?? document;
|
|
243
253
|
if (isIos()) {
|
|
244
254
|
if (state !== "disabled")
|
|
245
255
|
return;
|
|
@@ -259,7 +269,7 @@ function restoreTextSelection({ target, doc } = {}) {
|
|
|
259
269
|
if (target && modifiedElementMap.has(target)) {
|
|
260
270
|
let targetOldUserSelect = modifiedElementMap.get(target);
|
|
261
271
|
if (target.style.userSelect === "none") {
|
|
262
|
-
target.style.userSelect = targetOldUserSelect
|
|
272
|
+
target.style.userSelect = targetOldUserSelect ?? "";
|
|
263
273
|
}
|
|
264
274
|
if (target.getAttribute("style") === "") {
|
|
265
275
|
target.removeAttribute("style");
|
|
@@ -268,13 +278,13 @@ function restoreTextSelection({ target, doc } = {}) {
|
|
|
268
278
|
}
|
|
269
279
|
}
|
|
270
280
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
const {
|
|
281
|
+
var THRESHOLD = 5;
|
|
282
|
+
function trackPointerMove(doc, opts) {
|
|
283
|
+
const { onPointerMove, onPointerUp } = opts;
|
|
274
284
|
const handlePointerMove = (event, info) => {
|
|
275
285
|
const { point: p } = info;
|
|
276
|
-
const distance = Math.sqrt(
|
|
277
|
-
if (distance <
|
|
286
|
+
const distance = Math.sqrt(p.x ** 2 + p.y ** 2);
|
|
287
|
+
if (distance < THRESHOLD)
|
|
278
288
|
return;
|
|
279
289
|
if (isMouseEvent(event) && isLeftClick(event)) {
|
|
280
290
|
onPointerUp();
|
|
@@ -282,45 +292,43 @@ function trackPointerMove(opts) {
|
|
|
282
292
|
}
|
|
283
293
|
onPointerMove(info, event);
|
|
284
294
|
};
|
|
285
|
-
return callAll(
|
|
295
|
+
return callAll(
|
|
296
|
+
addPointerEvent(doc, "pointermove", handlePointerMove, false),
|
|
297
|
+
addPointerEvent(doc, "pointerup", onPointerUp, false),
|
|
298
|
+
addPointerEvent(doc, "pointercancel", onPointerUp, false),
|
|
299
|
+
addPointerEvent(doc, "contextmenu", onPointerUp, false),
|
|
300
|
+
disableTextSelection({ doc })
|
|
301
|
+
);
|
|
286
302
|
}
|
|
287
303
|
|
|
288
304
|
// src/splitter.dom.ts
|
|
289
|
-
var dom = {
|
|
290
|
-
getDoc: (ctx) => {
|
|
291
|
-
var _a;
|
|
292
|
-
return (_a = ctx.doc) != null ? _a : document;
|
|
293
|
-
},
|
|
294
|
-
getRootNode: (ctx) => {
|
|
295
|
-
var _a;
|
|
296
|
-
return (_a = ctx.rootNode) != null ? _a : dom.getDoc(ctx);
|
|
297
|
-
},
|
|
305
|
+
var dom = defineDomHelpers({
|
|
298
306
|
getRootId: (ctx) => {
|
|
299
|
-
var _a
|
|
300
|
-
return (
|
|
307
|
+
var _a;
|
|
308
|
+
return ((_a = ctx.ids) == null ? void 0 : _a.root) ?? `splitter:${ctx.id}`;
|
|
301
309
|
},
|
|
302
310
|
getSplitterId: (ctx) => {
|
|
303
|
-
var _a
|
|
304
|
-
return (
|
|
311
|
+
var _a;
|
|
312
|
+
return ((_a = ctx.ids) == null ? void 0 : _a.splitter) ?? `splitter:${ctx.id}:splitter`;
|
|
305
313
|
},
|
|
306
314
|
getToggleButtonId: (ctx) => {
|
|
307
|
-
var _a
|
|
308
|
-
return (
|
|
315
|
+
var _a;
|
|
316
|
+
return ((_a = ctx.ids) == null ? void 0 : _a.toggleBtn) ?? `splitter:${ctx.id}:toggle-btn`;
|
|
309
317
|
},
|
|
310
318
|
getLabelId: (ctx) => {
|
|
311
|
-
var _a
|
|
312
|
-
return (
|
|
319
|
+
var _a;
|
|
320
|
+
return ((_a = ctx.ids) == null ? void 0 : _a.label) ?? `splitter:${ctx.id}:label`;
|
|
313
321
|
},
|
|
314
322
|
getPrimaryPaneId: (ctx) => {
|
|
315
|
-
var _a
|
|
316
|
-
return (
|
|
323
|
+
var _a;
|
|
324
|
+
return ((_a = ctx.ids) == null ? void 0 : _a.primaryPane) ?? `splitter:${ctx.id}:primary`;
|
|
317
325
|
},
|
|
318
326
|
getSecondaryPaneId: (ctx) => {
|
|
319
|
-
var _a
|
|
320
|
-
return (
|
|
327
|
+
var _a;
|
|
328
|
+
return ((_a = ctx.ids) == null ? void 0 : _a.secondaryPane) ?? `splitter:${ctx.id}:secondary`;
|
|
321
329
|
},
|
|
322
|
-
getSplitterEl: (ctx) => dom.
|
|
323
|
-
getPrimaryPaneEl: (ctx) => dom.
|
|
330
|
+
getSplitterEl: (ctx) => dom.getById(ctx, dom.getSplitterId(ctx)),
|
|
331
|
+
getPrimaryPaneEl: (ctx) => dom.getById(ctx, dom.getPrimaryPaneId(ctx)),
|
|
324
332
|
getCursor(ctx) {
|
|
325
333
|
if (ctx.disabled || ctx.fixed)
|
|
326
334
|
return "default";
|
|
@@ -332,7 +340,7 @@ var dom = {
|
|
|
332
340
|
cursor = x ? "w-resize" : "n-resize";
|
|
333
341
|
return cursor;
|
|
334
342
|
}
|
|
335
|
-
};
|
|
343
|
+
});
|
|
336
344
|
|
|
337
345
|
// src/splitter.connect.ts
|
|
338
346
|
function connect(state2, send, normalize) {
|
|
@@ -390,12 +398,13 @@ function connect(state2, send, normalize) {
|
|
|
390
398
|
id: dom.getPrimaryPaneId(state2.context),
|
|
391
399
|
"data-disabled": dataAttr(isDisabled),
|
|
392
400
|
"data-state": isAtMax ? "at-max" : isAtMin ? "at-min" : "between",
|
|
393
|
-
style:
|
|
401
|
+
style: {
|
|
394
402
|
visibility: "visible",
|
|
395
403
|
flex: `0 0 ${value}px`,
|
|
396
404
|
position: "relative",
|
|
397
|
-
userSelect: isDragging ? "none" : "auto"
|
|
398
|
-
|
|
405
|
+
userSelect: isDragging ? "none" : "auto",
|
|
406
|
+
...isHorizontal ? { minWidth: `${min}px`, maxWidth: `${max}px` } : { minHeight: `${min}px`, maxHeight: `${max}px` }
|
|
407
|
+
}
|
|
399
408
|
}),
|
|
400
409
|
toggleButtonProps: normalize.element({
|
|
401
410
|
"data-part": "toggle-button",
|
|
@@ -502,10 +511,9 @@ function connect(state2, send, normalize) {
|
|
|
502
511
|
var import_core = require("@zag-js/core");
|
|
503
512
|
|
|
504
513
|
// ../../utilities/number/dist/index.mjs
|
|
505
|
-
var __pow2 = Math.pow;
|
|
506
514
|
function round(v, t) {
|
|
507
515
|
let num = valueOf(v);
|
|
508
|
-
const p =
|
|
516
|
+
const p = 10 ** (t ?? 10);
|
|
509
517
|
num = Math.round(num * p) / p;
|
|
510
518
|
return t ? num.toFixed(t) : v.toString();
|
|
511
519
|
}
|
|
@@ -539,7 +547,7 @@ function valueOf(v) {
|
|
|
539
547
|
function decimalOperation(a, op, b) {
|
|
540
548
|
let result = op === "+" ? a + b : a - b;
|
|
541
549
|
if (a % 1 !== 0 || b % 1 !== 0) {
|
|
542
|
-
const multiplier =
|
|
550
|
+
const multiplier = 10 ** Math.max(countDecimals(a), countDecimals(b));
|
|
543
551
|
a = Math.round(a * multiplier);
|
|
544
552
|
b = Math.round(b * multiplier);
|
|
545
553
|
result = op === "+" ? a + b : a - b;
|
|
@@ -551,223 +559,220 @@ var nf = new Intl.NumberFormat("en-US", { style: "decimal", maximumFractionDigit
|
|
|
551
559
|
|
|
552
560
|
// src/splitter.machine.ts
|
|
553
561
|
var { not } = import_core.guards;
|
|
554
|
-
function machine(ctx
|
|
555
|
-
return (0, import_core.createMachine)(
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
computed: {
|
|
568
|
-
isHorizontal: (ctx2) => ctx2.orientation === "horizontal",
|
|
569
|
-
isAtMin: (ctx2) => ctx2.value === ctx2.min,
|
|
570
|
-
isAtMax: (ctx2) => ctx2.value === ctx2.max
|
|
571
|
-
},
|
|
572
|
-
on: {
|
|
573
|
-
COLLAPSE: {
|
|
574
|
-
actions: "setToMin"
|
|
562
|
+
function machine(ctx) {
|
|
563
|
+
return (0, import_core.createMachine)(
|
|
564
|
+
{
|
|
565
|
+
id: "splitter",
|
|
566
|
+
initial: "unknown",
|
|
567
|
+
context: {
|
|
568
|
+
orientation: "horizontal",
|
|
569
|
+
min: 224,
|
|
570
|
+
max: 340,
|
|
571
|
+
step: 1,
|
|
572
|
+
value: 256,
|
|
573
|
+
snapOffset: 0,
|
|
574
|
+
...ctx
|
|
575
575
|
},
|
|
576
|
-
|
|
577
|
-
|
|
576
|
+
computed: {
|
|
577
|
+
isHorizontal: (ctx2) => ctx2.orientation === "horizontal",
|
|
578
|
+
isAtMin: (ctx2) => ctx2.value === ctx2.min,
|
|
579
|
+
isAtMax: (ctx2) => ctx2.value === ctx2.max
|
|
578
580
|
},
|
|
579
|
-
|
|
580
|
-
{
|
|
581
|
-
|
|
581
|
+
on: {
|
|
582
|
+
COLLAPSE: {
|
|
583
|
+
actions: "setToMin"
|
|
584
|
+
},
|
|
585
|
+
EXPAND: {
|
|
582
586
|
actions: "setToMax"
|
|
583
587
|
},
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
},
|
|
589
|
-
states: {
|
|
590
|
-
unknown: {
|
|
591
|
-
on: {
|
|
592
|
-
SETUP: {
|
|
593
|
-
target: "idle",
|
|
594
|
-
actions: "setupDocument"
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
},
|
|
598
|
-
idle: {
|
|
599
|
-
on: {
|
|
600
|
-
POINTER_OVER: {
|
|
601
|
-
guard: not("isFixed"),
|
|
602
|
-
target: "hover:temp"
|
|
588
|
+
TOGGLE: [
|
|
589
|
+
{
|
|
590
|
+
guard: "isCollapsed",
|
|
591
|
+
actions: "setToMax"
|
|
603
592
|
},
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
593
|
+
{
|
|
594
|
+
actions: "setToMin"
|
|
595
|
+
}
|
|
596
|
+
]
|
|
607
597
|
},
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
598
|
+
states: {
|
|
599
|
+
unknown: {
|
|
600
|
+
on: {
|
|
601
|
+
SETUP: "idle"
|
|
602
|
+
}
|
|
611
603
|
},
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
actions: ["invokeOnChangeStart"]
|
|
626
|
-
},
|
|
627
|
-
POINTER_LEAVE: "idle"
|
|
628
|
-
}
|
|
629
|
-
},
|
|
630
|
-
focused: {
|
|
631
|
-
tags: ["focus"],
|
|
632
|
-
on: {
|
|
633
|
-
BLUR: "idle",
|
|
634
|
-
POINTER_DOWN: {
|
|
635
|
-
target: "dragging",
|
|
636
|
-
actions: ["invokeOnChangeStart"]
|
|
637
|
-
},
|
|
638
|
-
ARROW_LEFT: {
|
|
639
|
-
guard: "isHorizontal",
|
|
640
|
-
actions: "decrement"
|
|
641
|
-
},
|
|
642
|
-
ARROW_RIGHT: {
|
|
643
|
-
guard: "isHorizontal",
|
|
644
|
-
actions: "increment"
|
|
645
|
-
},
|
|
646
|
-
ARROW_UP: {
|
|
647
|
-
guard: "isVertical",
|
|
648
|
-
actions: "increment"
|
|
649
|
-
},
|
|
650
|
-
ARROW_DOWN: {
|
|
651
|
-
guard: "isVertical",
|
|
652
|
-
actions: "decrement"
|
|
604
|
+
idle: {
|
|
605
|
+
on: {
|
|
606
|
+
POINTER_OVER: {
|
|
607
|
+
guard: not("isFixed"),
|
|
608
|
+
target: "hover:temp"
|
|
609
|
+
},
|
|
610
|
+
POINTER_LEAVE: "idle",
|
|
611
|
+
FOCUS: "focused"
|
|
612
|
+
}
|
|
613
|
+
},
|
|
614
|
+
"hover:temp": {
|
|
615
|
+
after: {
|
|
616
|
+
HOVER_DELAY: "hover"
|
|
653
617
|
},
|
|
654
|
-
|
|
655
|
-
{
|
|
656
|
-
|
|
618
|
+
on: {
|
|
619
|
+
POINTER_DOWN: {
|
|
620
|
+
target: "dragging",
|
|
621
|
+
actions: ["invokeOnChangeStart"]
|
|
622
|
+
},
|
|
623
|
+
POINTER_LEAVE: "idle"
|
|
624
|
+
}
|
|
625
|
+
},
|
|
626
|
+
hover: {
|
|
627
|
+
tags: ["focus"],
|
|
628
|
+
on: {
|
|
629
|
+
POINTER_DOWN: {
|
|
630
|
+
target: "dragging",
|
|
631
|
+
actions: ["invokeOnChangeStart"]
|
|
632
|
+
},
|
|
633
|
+
POINTER_LEAVE: "idle"
|
|
634
|
+
}
|
|
635
|
+
},
|
|
636
|
+
focused: {
|
|
637
|
+
tags: ["focus"],
|
|
638
|
+
on: {
|
|
639
|
+
BLUR: "idle",
|
|
640
|
+
POINTER_DOWN: {
|
|
641
|
+
target: "dragging",
|
|
642
|
+
actions: ["invokeOnChangeStart"]
|
|
643
|
+
},
|
|
644
|
+
ARROW_LEFT: {
|
|
645
|
+
guard: "isHorizontal",
|
|
646
|
+
actions: "decrement"
|
|
647
|
+
},
|
|
648
|
+
ARROW_RIGHT: {
|
|
649
|
+
guard: "isHorizontal",
|
|
650
|
+
actions: "increment"
|
|
651
|
+
},
|
|
652
|
+
ARROW_UP: {
|
|
653
|
+
guard: "isVertical",
|
|
654
|
+
actions: "increment"
|
|
655
|
+
},
|
|
656
|
+
ARROW_DOWN: {
|
|
657
|
+
guard: "isVertical",
|
|
658
|
+
actions: "decrement"
|
|
659
|
+
},
|
|
660
|
+
ENTER: [
|
|
661
|
+
{
|
|
662
|
+
guard: "isCollapsed",
|
|
663
|
+
actions: "setToMin"
|
|
664
|
+
},
|
|
665
|
+
{ actions: "setToMin" }
|
|
666
|
+
],
|
|
667
|
+
HOME: {
|
|
657
668
|
actions: "setToMin"
|
|
658
669
|
},
|
|
659
|
-
|
|
660
|
-
],
|
|
661
|
-
HOME: {
|
|
662
|
-
actions: "setToMin"
|
|
663
|
-
},
|
|
664
|
-
END: {
|
|
665
|
-
actions: "setToMax"
|
|
666
|
-
},
|
|
667
|
-
DOUBLE_CLICK: [
|
|
668
|
-
{
|
|
669
|
-
guard: "isCollapsed",
|
|
670
|
+
END: {
|
|
670
671
|
actions: "setToMax"
|
|
671
672
|
},
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
activities: "trackPointerMove",
|
|
680
|
-
on: {
|
|
681
|
-
POINTER_UP: {
|
|
682
|
-
target: "focused",
|
|
683
|
-
actions: ["invokeOnChangeEnd"]
|
|
684
|
-
},
|
|
685
|
-
POINTER_MOVE: {
|
|
686
|
-
actions: "setPointerValue"
|
|
673
|
+
DOUBLE_CLICK: [
|
|
674
|
+
{
|
|
675
|
+
guard: "isCollapsed",
|
|
676
|
+
actions: "setToMax"
|
|
677
|
+
},
|
|
678
|
+
{ actions: "setToMin" }
|
|
679
|
+
]
|
|
687
680
|
}
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
onPointerUp() {
|
|
702
|
-
send("POINTER_UP");
|
|
703
|
-
el.style.cursor = "";
|
|
681
|
+
},
|
|
682
|
+
dragging: {
|
|
683
|
+
tags: ["focus"],
|
|
684
|
+
entry: "focusSplitter",
|
|
685
|
+
activities: "trackPointerMove",
|
|
686
|
+
on: {
|
|
687
|
+
POINTER_UP: {
|
|
688
|
+
target: "focused",
|
|
689
|
+
actions: ["invokeOnChangeEnd"]
|
|
690
|
+
},
|
|
691
|
+
POINTER_MOVE: {
|
|
692
|
+
actions: "setPointerValue"
|
|
693
|
+
}
|
|
704
694
|
}
|
|
705
|
-
}
|
|
695
|
+
}
|
|
706
696
|
}
|
|
707
697
|
},
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
698
|
+
{
|
|
699
|
+
activities: {
|
|
700
|
+
trackPointerMove: (ctx2, _evt, { send }) => {
|
|
701
|
+
const doc = dom.getDoc(ctx2);
|
|
702
|
+
return trackPointerMove(doc, {
|
|
703
|
+
onPointerMove(info) {
|
|
704
|
+
send({ type: "POINTER_MOVE", point: info.point });
|
|
705
|
+
doc.documentElement.style.cursor = dom.getCursor(ctx2);
|
|
706
|
+
},
|
|
707
|
+
onPointerUp() {
|
|
708
|
+
send("POINTER_UP");
|
|
709
|
+
doc.documentElement.style.cursor = "";
|
|
710
|
+
}
|
|
711
|
+
});
|
|
722
712
|
}
|
|
723
713
|
},
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
var _a;
|
|
730
|
-
(_a = ctx2.onChangeEnd) == null ? void 0 : _a.call(ctx2, { value: ctx2.value });
|
|
731
|
-
},
|
|
732
|
-
setupDocument(ctx2, evt) {
|
|
733
|
-
if (evt.doc)
|
|
734
|
-
ctx2.doc = (0, import_core.ref)(evt.doc);
|
|
735
|
-
if (evt.root)
|
|
736
|
-
ctx2.rootNode = (0, import_core.ref)(evt.root);
|
|
737
|
-
ctx2.uid = evt.id;
|
|
738
|
-
},
|
|
739
|
-
setToMin(ctx2) {
|
|
740
|
-
ctx2.value = ctx2.min;
|
|
714
|
+
guards: {
|
|
715
|
+
isCollapsed: (ctx2) => ctx2.isAtMin,
|
|
716
|
+
isHorizontal: (ctx2) => ctx2.isHorizontal,
|
|
717
|
+
isVertical: (ctx2) => !ctx2.isHorizontal,
|
|
718
|
+
isFixed: (ctx2) => !!ctx2.fixed
|
|
741
719
|
},
|
|
742
|
-
|
|
743
|
-
|
|
720
|
+
delays: {
|
|
721
|
+
HOVER_DELAY: 250
|
|
744
722
|
},
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
},
|
|
748
|
-
decrement(ctx2, evt) {
|
|
749
|
-
ctx2.value = clamp(decrement(ctx2.value, evt.step), ctx2);
|
|
750
|
-
},
|
|
751
|
-
focusSplitter(ctx2) {
|
|
752
|
-
raf(() => {
|
|
723
|
+
actions: {
|
|
724
|
+
invokeOnChange(ctx2, evt) {
|
|
753
725
|
var _a;
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
value = ctx2.
|
|
726
|
+
if (evt.type !== "SETUP") {
|
|
727
|
+
(_a = ctx2.onChange) == null ? void 0 : _a.call(ctx2, { value: ctx2.value });
|
|
728
|
+
}
|
|
729
|
+
},
|
|
730
|
+
invokeOnChangeStart(ctx2) {
|
|
731
|
+
var _a;
|
|
732
|
+
(_a = ctx2.onChangeStart) == null ? void 0 : _a.call(ctx2, { value: ctx2.value });
|
|
733
|
+
},
|
|
734
|
+
invokeOnChangeEnd(ctx2) {
|
|
735
|
+
var _a;
|
|
736
|
+
(_a = ctx2.onChangeEnd) == null ? void 0 : _a.call(ctx2, { value: ctx2.value });
|
|
737
|
+
},
|
|
738
|
+
setToMin(ctx2) {
|
|
739
|
+
ctx2.value = ctx2.min;
|
|
740
|
+
},
|
|
741
|
+
setToMax(ctx2) {
|
|
742
|
+
ctx2.value = ctx2.max;
|
|
743
|
+
},
|
|
744
|
+
increment(ctx2, evt) {
|
|
745
|
+
ctx2.value = clamp(increment(ctx2.value, evt.step), ctx2);
|
|
746
|
+
},
|
|
747
|
+
decrement(ctx2, evt) {
|
|
748
|
+
ctx2.value = clamp(decrement(ctx2.value, evt.step), ctx2);
|
|
749
|
+
},
|
|
750
|
+
focusSplitter(ctx2) {
|
|
751
|
+
raf(() => {
|
|
752
|
+
var _a;
|
|
753
|
+
return (_a = dom.getSplitterEl(ctx2)) == null ? void 0 : _a.focus();
|
|
754
|
+
});
|
|
755
|
+
},
|
|
756
|
+
setPointerValue(ctx2, evt) {
|
|
757
|
+
const el = dom.getPrimaryPaneEl(ctx2);
|
|
758
|
+
if (!el)
|
|
759
|
+
return;
|
|
760
|
+
const relativePoint = getPointRelativeToNode(evt.point, el);
|
|
761
|
+
let currentPoint = ctx2.isHorizontal ? relativePoint.x : relativePoint.y;
|
|
762
|
+
let value = parseFloat(snapToStep(clamp(currentPoint, ctx2), ctx2.step));
|
|
763
|
+
if (Math.abs(value - ctx2.min) <= ctx2.snapOffset) {
|
|
764
|
+
value = ctx2.min;
|
|
765
|
+
} else if (Math.abs(value - ctx2.max) <= ctx2.snapOffset) {
|
|
766
|
+
value = ctx2.max;
|
|
767
|
+
}
|
|
768
|
+
ctx2.value = value;
|
|
768
769
|
}
|
|
769
|
-
ctx2.value = value;
|
|
770
770
|
}
|
|
771
771
|
}
|
|
772
|
-
|
|
772
|
+
);
|
|
773
773
|
}
|
|
774
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
775
|
+
0 && (module.exports = {
|
|
776
|
+
connect,
|
|
777
|
+
machine
|
|
778
|
+
});
|