@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.mjs
CHANGED
|
@@ -1,28 +1,10 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __spreadValues = (a, b) => {
|
|
7
|
-
for (var prop in b || (b = {}))
|
|
8
|
-
if (__hasOwnProp.call(b, prop))
|
|
9
|
-
__defNormalProp(a, prop, b[prop]);
|
|
10
|
-
if (__getOwnPropSymbols)
|
|
11
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
-
if (__propIsEnum.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
}
|
|
15
|
-
return a;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
1
|
// ../../utilities/dom/dist/index.mjs
|
|
19
|
-
var __pow = Math.pow;
|
|
20
2
|
var dataAttr = (guard) => {
|
|
21
3
|
return guard ? "" : void 0;
|
|
22
4
|
};
|
|
23
5
|
var runIfFn = (v, ...a) => {
|
|
24
6
|
const res = typeof v === "function" ? v(...a) : v;
|
|
25
|
-
return res
|
|
7
|
+
return res ?? void 0;
|
|
26
8
|
};
|
|
27
9
|
var callAll = (...fns) => (...a) => {
|
|
28
10
|
fns.forEach(function(fn) {
|
|
@@ -34,15 +16,43 @@ var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
|
|
|
34
16
|
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
35
17
|
var isDom = () => typeof window !== "undefined";
|
|
36
18
|
function getPlatform() {
|
|
37
|
-
var _a;
|
|
38
19
|
const agent = navigator.userAgentData;
|
|
39
|
-
return (
|
|
20
|
+
return (agent == null ? void 0 : agent.platform) ?? navigator.platform;
|
|
40
21
|
}
|
|
41
22
|
var pt = (v) => isDom() && v.test(getPlatform());
|
|
42
23
|
var isTouchDevice = () => isDom() && !!navigator.maxTouchPoints;
|
|
43
24
|
var isMac = () => pt(/^Mac/) && !isTouchDevice;
|
|
44
25
|
var isApple = () => pt(/mac|iphone|ipad|ipod/i);
|
|
45
26
|
var isIos = () => isApple() && !isMac();
|
|
27
|
+
function isDocument(el) {
|
|
28
|
+
return el.nodeType === Node.DOCUMENT_NODE;
|
|
29
|
+
}
|
|
30
|
+
function isWindow(value) {
|
|
31
|
+
return (value == null ? void 0 : value.toString()) === "[object Window]";
|
|
32
|
+
}
|
|
33
|
+
function getDocument(el) {
|
|
34
|
+
if (isWindow(el))
|
|
35
|
+
return el.document;
|
|
36
|
+
if (isDocument(el))
|
|
37
|
+
return el;
|
|
38
|
+
return (el == null ? void 0 : el.ownerDocument) ?? document;
|
|
39
|
+
}
|
|
40
|
+
function defineDomHelpers(helpers) {
|
|
41
|
+
const dom2 = {
|
|
42
|
+
getRootNode: (ctx) => {
|
|
43
|
+
var _a;
|
|
44
|
+
return ((_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) ?? document;
|
|
45
|
+
},
|
|
46
|
+
getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
|
|
47
|
+
getWin: (ctx) => dom2.getDoc(ctx).defaultView ?? window,
|
|
48
|
+
getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
|
|
49
|
+
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
|
|
50
|
+
};
|
|
51
|
+
return {
|
|
52
|
+
...dom2,
|
|
53
|
+
...helpers
|
|
54
|
+
};
|
|
55
|
+
}
|
|
46
56
|
var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
|
|
47
57
|
var supportsTouchEvent = () => isDom() && window.ontouchstart === null;
|
|
48
58
|
var supportsMouseEvent = () => isDom() && window.onmousedown === null;
|
|
@@ -93,10 +103,9 @@ var sameKeyMap = {
|
|
|
93
103
|
Right: "ArrowRight"
|
|
94
104
|
};
|
|
95
105
|
function getEventKey(event, options = {}) {
|
|
96
|
-
var _a;
|
|
97
106
|
const { dir = "ltr", orientation = "horizontal" } = options;
|
|
98
107
|
let { key } = event;
|
|
99
|
-
key =
|
|
108
|
+
key = sameKeyMap[key] ?? key;
|
|
100
109
|
const isRtl = dir === "rtl" && orientation === "horizontal";
|
|
101
110
|
if (isRtl && key in rtlKeyMap) {
|
|
102
111
|
key = rtlKeyMap[key];
|
|
@@ -133,8 +142,7 @@ function addDomEvent(target, eventName, handler, options) {
|
|
|
133
142
|
};
|
|
134
143
|
}
|
|
135
144
|
function addPointerEvent(target, event, listener, options) {
|
|
136
|
-
|
|
137
|
-
const type = (_a = getEventName(event)) != null ? _a : event;
|
|
145
|
+
const type = getEventName(event) ?? event;
|
|
138
146
|
return addDomEvent(target, type, wrapHandler(listener, event === "pointerdown"), options);
|
|
139
147
|
}
|
|
140
148
|
function wrapHandler(fn, filter = false) {
|
|
@@ -145,8 +153,7 @@ function wrapHandler(fn, filter = false) {
|
|
|
145
153
|
}
|
|
146
154
|
function filterPrimaryPointer(fn) {
|
|
147
155
|
return (event) => {
|
|
148
|
-
|
|
149
|
-
const win = (_a = event.view) != null ? _a : window;
|
|
156
|
+
const win = event.view ?? window;
|
|
150
157
|
const isMouseEvent2 = event instanceof win.MouseEvent;
|
|
151
158
|
const isPrimary = !isMouseEvent2 || isMouseEvent2 && event.button === 0;
|
|
152
159
|
if (isPrimary)
|
|
@@ -201,7 +208,7 @@ var state = "default";
|
|
|
201
208
|
var savedUserSelect = "";
|
|
202
209
|
var modifiedElementMap = /* @__PURE__ */ new WeakMap();
|
|
203
210
|
function disableTextSelection({ target, doc } = {}) {
|
|
204
|
-
const _document = doc
|
|
211
|
+
const _document = doc ?? document;
|
|
205
212
|
if (isIos()) {
|
|
206
213
|
if (state === "default") {
|
|
207
214
|
savedUserSelect = _document.documentElement.style.webkitUserSelect;
|
|
@@ -215,7 +222,7 @@ function disableTextSelection({ target, doc } = {}) {
|
|
|
215
222
|
return () => restoreTextSelection({ target, doc: _document });
|
|
216
223
|
}
|
|
217
224
|
function restoreTextSelection({ target, doc } = {}) {
|
|
218
|
-
const _document = doc
|
|
225
|
+
const _document = doc ?? document;
|
|
219
226
|
if (isIos()) {
|
|
220
227
|
if (state !== "disabled")
|
|
221
228
|
return;
|
|
@@ -235,7 +242,7 @@ function restoreTextSelection({ target, doc } = {}) {
|
|
|
235
242
|
if (target && modifiedElementMap.has(target)) {
|
|
236
243
|
let targetOldUserSelect = modifiedElementMap.get(target);
|
|
237
244
|
if (target.style.userSelect === "none") {
|
|
238
|
-
target.style.userSelect = targetOldUserSelect
|
|
245
|
+
target.style.userSelect = targetOldUserSelect ?? "";
|
|
239
246
|
}
|
|
240
247
|
if (target.getAttribute("style") === "") {
|
|
241
248
|
target.removeAttribute("style");
|
|
@@ -244,13 +251,13 @@ function restoreTextSelection({ target, doc } = {}) {
|
|
|
244
251
|
}
|
|
245
252
|
}
|
|
246
253
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
const {
|
|
254
|
+
var THRESHOLD = 5;
|
|
255
|
+
function trackPointerMove(doc, opts) {
|
|
256
|
+
const { onPointerMove, onPointerUp } = opts;
|
|
250
257
|
const handlePointerMove = (event, info) => {
|
|
251
258
|
const { point: p } = info;
|
|
252
|
-
const distance = Math.sqrt(
|
|
253
|
-
if (distance <
|
|
259
|
+
const distance = Math.sqrt(p.x ** 2 + p.y ** 2);
|
|
260
|
+
if (distance < THRESHOLD)
|
|
254
261
|
return;
|
|
255
262
|
if (isMouseEvent(event) && isLeftClick(event)) {
|
|
256
263
|
onPointerUp();
|
|
@@ -258,45 +265,43 @@ function trackPointerMove(opts) {
|
|
|
258
265
|
}
|
|
259
266
|
onPointerMove(info, event);
|
|
260
267
|
};
|
|
261
|
-
return callAll(
|
|
268
|
+
return callAll(
|
|
269
|
+
addPointerEvent(doc, "pointermove", handlePointerMove, false),
|
|
270
|
+
addPointerEvent(doc, "pointerup", onPointerUp, false),
|
|
271
|
+
addPointerEvent(doc, "pointercancel", onPointerUp, false),
|
|
272
|
+
addPointerEvent(doc, "contextmenu", onPointerUp, false),
|
|
273
|
+
disableTextSelection({ doc })
|
|
274
|
+
);
|
|
262
275
|
}
|
|
263
276
|
|
|
264
277
|
// src/splitter.dom.ts
|
|
265
|
-
var dom = {
|
|
266
|
-
getDoc: (ctx) => {
|
|
267
|
-
var _a;
|
|
268
|
-
return (_a = ctx.doc) != null ? _a : document;
|
|
269
|
-
},
|
|
270
|
-
getRootNode: (ctx) => {
|
|
271
|
-
var _a;
|
|
272
|
-
return (_a = ctx.rootNode) != null ? _a : dom.getDoc(ctx);
|
|
273
|
-
},
|
|
278
|
+
var dom = defineDomHelpers({
|
|
274
279
|
getRootId: (ctx) => {
|
|
275
|
-
var _a
|
|
276
|
-
return (
|
|
280
|
+
var _a;
|
|
281
|
+
return ((_a = ctx.ids) == null ? void 0 : _a.root) ?? `splitter:${ctx.id}`;
|
|
277
282
|
},
|
|
278
283
|
getSplitterId: (ctx) => {
|
|
279
|
-
var _a
|
|
280
|
-
return (
|
|
284
|
+
var _a;
|
|
285
|
+
return ((_a = ctx.ids) == null ? void 0 : _a.splitter) ?? `splitter:${ctx.id}:splitter`;
|
|
281
286
|
},
|
|
282
287
|
getToggleButtonId: (ctx) => {
|
|
283
|
-
var _a
|
|
284
|
-
return (
|
|
288
|
+
var _a;
|
|
289
|
+
return ((_a = ctx.ids) == null ? void 0 : _a.toggleBtn) ?? `splitter:${ctx.id}:toggle-btn`;
|
|
285
290
|
},
|
|
286
291
|
getLabelId: (ctx) => {
|
|
287
|
-
var _a
|
|
288
|
-
return (
|
|
292
|
+
var _a;
|
|
293
|
+
return ((_a = ctx.ids) == null ? void 0 : _a.label) ?? `splitter:${ctx.id}:label`;
|
|
289
294
|
},
|
|
290
295
|
getPrimaryPaneId: (ctx) => {
|
|
291
|
-
var _a
|
|
292
|
-
return (
|
|
296
|
+
var _a;
|
|
297
|
+
return ((_a = ctx.ids) == null ? void 0 : _a.primaryPane) ?? `splitter:${ctx.id}:primary`;
|
|
293
298
|
},
|
|
294
299
|
getSecondaryPaneId: (ctx) => {
|
|
295
|
-
var _a
|
|
296
|
-
return (
|
|
300
|
+
var _a;
|
|
301
|
+
return ((_a = ctx.ids) == null ? void 0 : _a.secondaryPane) ?? `splitter:${ctx.id}:secondary`;
|
|
297
302
|
},
|
|
298
|
-
getSplitterEl: (ctx) => dom.
|
|
299
|
-
getPrimaryPaneEl: (ctx) => dom.
|
|
303
|
+
getSplitterEl: (ctx) => dom.getById(ctx, dom.getSplitterId(ctx)),
|
|
304
|
+
getPrimaryPaneEl: (ctx) => dom.getById(ctx, dom.getPrimaryPaneId(ctx)),
|
|
300
305
|
getCursor(ctx) {
|
|
301
306
|
if (ctx.disabled || ctx.fixed)
|
|
302
307
|
return "default";
|
|
@@ -308,7 +313,7 @@ var dom = {
|
|
|
308
313
|
cursor = x ? "w-resize" : "n-resize";
|
|
309
314
|
return cursor;
|
|
310
315
|
}
|
|
311
|
-
};
|
|
316
|
+
});
|
|
312
317
|
|
|
313
318
|
// src/splitter.connect.ts
|
|
314
319
|
function connect(state2, send, normalize) {
|
|
@@ -366,12 +371,13 @@ function connect(state2, send, normalize) {
|
|
|
366
371
|
id: dom.getPrimaryPaneId(state2.context),
|
|
367
372
|
"data-disabled": dataAttr(isDisabled),
|
|
368
373
|
"data-state": isAtMax ? "at-max" : isAtMin ? "at-min" : "between",
|
|
369
|
-
style:
|
|
374
|
+
style: {
|
|
370
375
|
visibility: "visible",
|
|
371
376
|
flex: `0 0 ${value}px`,
|
|
372
377
|
position: "relative",
|
|
373
|
-
userSelect: isDragging ? "none" : "auto"
|
|
374
|
-
|
|
378
|
+
userSelect: isDragging ? "none" : "auto",
|
|
379
|
+
...isHorizontal ? { minWidth: `${min}px`, maxWidth: `${max}px` } : { minHeight: `${min}px`, maxHeight: `${max}px` }
|
|
380
|
+
}
|
|
375
381
|
}),
|
|
376
382
|
toggleButtonProps: normalize.element({
|
|
377
383
|
"data-part": "toggle-button",
|
|
@@ -475,13 +481,12 @@ function connect(state2, send, normalize) {
|
|
|
475
481
|
}
|
|
476
482
|
|
|
477
483
|
// src/splitter.machine.ts
|
|
478
|
-
import { createMachine, guards
|
|
484
|
+
import { createMachine, guards } from "@zag-js/core";
|
|
479
485
|
|
|
480
486
|
// ../../utilities/number/dist/index.mjs
|
|
481
|
-
var __pow2 = Math.pow;
|
|
482
487
|
function round(v, t) {
|
|
483
488
|
let num = valueOf(v);
|
|
484
|
-
const p =
|
|
489
|
+
const p = 10 ** (t ?? 10);
|
|
485
490
|
num = Math.round(num * p) / p;
|
|
486
491
|
return t ? num.toFixed(t) : v.toString();
|
|
487
492
|
}
|
|
@@ -515,7 +520,7 @@ function valueOf(v) {
|
|
|
515
520
|
function decimalOperation(a, op, b) {
|
|
516
521
|
let result = op === "+" ? a + b : a - b;
|
|
517
522
|
if (a % 1 !== 0 || b % 1 !== 0) {
|
|
518
|
-
const multiplier =
|
|
523
|
+
const multiplier = 10 ** Math.max(countDecimals(a), countDecimals(b));
|
|
519
524
|
a = Math.round(a * multiplier);
|
|
520
525
|
b = Math.round(b * multiplier);
|
|
521
526
|
result = op === "+" ? a + b : a - b;
|
|
@@ -527,225 +532,217 @@ var nf = new Intl.NumberFormat("en-US", { style: "decimal", maximumFractionDigit
|
|
|
527
532
|
|
|
528
533
|
// src/splitter.machine.ts
|
|
529
534
|
var { not } = guards;
|
|
530
|
-
function machine(ctx
|
|
531
|
-
return createMachine(
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
computed: {
|
|
544
|
-
isHorizontal: (ctx2) => ctx2.orientation === "horizontal",
|
|
545
|
-
isAtMin: (ctx2) => ctx2.value === ctx2.min,
|
|
546
|
-
isAtMax: (ctx2) => ctx2.value === ctx2.max
|
|
547
|
-
},
|
|
548
|
-
on: {
|
|
549
|
-
COLLAPSE: {
|
|
550
|
-
actions: "setToMin"
|
|
535
|
+
function machine(ctx) {
|
|
536
|
+
return createMachine(
|
|
537
|
+
{
|
|
538
|
+
id: "splitter",
|
|
539
|
+
initial: "unknown",
|
|
540
|
+
context: {
|
|
541
|
+
orientation: "horizontal",
|
|
542
|
+
min: 224,
|
|
543
|
+
max: 340,
|
|
544
|
+
step: 1,
|
|
545
|
+
value: 256,
|
|
546
|
+
snapOffset: 0,
|
|
547
|
+
...ctx
|
|
551
548
|
},
|
|
552
|
-
|
|
553
|
-
|
|
549
|
+
computed: {
|
|
550
|
+
isHorizontal: (ctx2) => ctx2.orientation === "horizontal",
|
|
551
|
+
isAtMin: (ctx2) => ctx2.value === ctx2.min,
|
|
552
|
+
isAtMax: (ctx2) => ctx2.value === ctx2.max
|
|
554
553
|
},
|
|
555
|
-
|
|
556
|
-
{
|
|
557
|
-
|
|
554
|
+
on: {
|
|
555
|
+
COLLAPSE: {
|
|
556
|
+
actions: "setToMin"
|
|
557
|
+
},
|
|
558
|
+
EXPAND: {
|
|
558
559
|
actions: "setToMax"
|
|
559
560
|
},
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
},
|
|
565
|
-
states: {
|
|
566
|
-
unknown: {
|
|
567
|
-
on: {
|
|
568
|
-
SETUP: {
|
|
569
|
-
target: "idle",
|
|
570
|
-
actions: "setupDocument"
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
},
|
|
574
|
-
idle: {
|
|
575
|
-
on: {
|
|
576
|
-
POINTER_OVER: {
|
|
577
|
-
guard: not("isFixed"),
|
|
578
|
-
target: "hover:temp"
|
|
561
|
+
TOGGLE: [
|
|
562
|
+
{
|
|
563
|
+
guard: "isCollapsed",
|
|
564
|
+
actions: "setToMax"
|
|
579
565
|
},
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
566
|
+
{
|
|
567
|
+
actions: "setToMin"
|
|
568
|
+
}
|
|
569
|
+
]
|
|
583
570
|
},
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
571
|
+
states: {
|
|
572
|
+
unknown: {
|
|
573
|
+
on: {
|
|
574
|
+
SETUP: "idle"
|
|
575
|
+
}
|
|
587
576
|
},
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
actions: ["invokeOnChangeStart"]
|
|
602
|
-
},
|
|
603
|
-
POINTER_LEAVE: "idle"
|
|
604
|
-
}
|
|
605
|
-
},
|
|
606
|
-
focused: {
|
|
607
|
-
tags: ["focus"],
|
|
608
|
-
on: {
|
|
609
|
-
BLUR: "idle",
|
|
610
|
-
POINTER_DOWN: {
|
|
611
|
-
target: "dragging",
|
|
612
|
-
actions: ["invokeOnChangeStart"]
|
|
613
|
-
},
|
|
614
|
-
ARROW_LEFT: {
|
|
615
|
-
guard: "isHorizontal",
|
|
616
|
-
actions: "decrement"
|
|
617
|
-
},
|
|
618
|
-
ARROW_RIGHT: {
|
|
619
|
-
guard: "isHorizontal",
|
|
620
|
-
actions: "increment"
|
|
621
|
-
},
|
|
622
|
-
ARROW_UP: {
|
|
623
|
-
guard: "isVertical",
|
|
624
|
-
actions: "increment"
|
|
625
|
-
},
|
|
626
|
-
ARROW_DOWN: {
|
|
627
|
-
guard: "isVertical",
|
|
628
|
-
actions: "decrement"
|
|
577
|
+
idle: {
|
|
578
|
+
on: {
|
|
579
|
+
POINTER_OVER: {
|
|
580
|
+
guard: not("isFixed"),
|
|
581
|
+
target: "hover:temp"
|
|
582
|
+
},
|
|
583
|
+
POINTER_LEAVE: "idle",
|
|
584
|
+
FOCUS: "focused"
|
|
585
|
+
}
|
|
586
|
+
},
|
|
587
|
+
"hover:temp": {
|
|
588
|
+
after: {
|
|
589
|
+
HOVER_DELAY: "hover"
|
|
629
590
|
},
|
|
630
|
-
|
|
631
|
-
{
|
|
632
|
-
|
|
591
|
+
on: {
|
|
592
|
+
POINTER_DOWN: {
|
|
593
|
+
target: "dragging",
|
|
594
|
+
actions: ["invokeOnChangeStart"]
|
|
595
|
+
},
|
|
596
|
+
POINTER_LEAVE: "idle"
|
|
597
|
+
}
|
|
598
|
+
},
|
|
599
|
+
hover: {
|
|
600
|
+
tags: ["focus"],
|
|
601
|
+
on: {
|
|
602
|
+
POINTER_DOWN: {
|
|
603
|
+
target: "dragging",
|
|
604
|
+
actions: ["invokeOnChangeStart"]
|
|
605
|
+
},
|
|
606
|
+
POINTER_LEAVE: "idle"
|
|
607
|
+
}
|
|
608
|
+
},
|
|
609
|
+
focused: {
|
|
610
|
+
tags: ["focus"],
|
|
611
|
+
on: {
|
|
612
|
+
BLUR: "idle",
|
|
613
|
+
POINTER_DOWN: {
|
|
614
|
+
target: "dragging",
|
|
615
|
+
actions: ["invokeOnChangeStart"]
|
|
616
|
+
},
|
|
617
|
+
ARROW_LEFT: {
|
|
618
|
+
guard: "isHorizontal",
|
|
619
|
+
actions: "decrement"
|
|
620
|
+
},
|
|
621
|
+
ARROW_RIGHT: {
|
|
622
|
+
guard: "isHorizontal",
|
|
623
|
+
actions: "increment"
|
|
624
|
+
},
|
|
625
|
+
ARROW_UP: {
|
|
626
|
+
guard: "isVertical",
|
|
627
|
+
actions: "increment"
|
|
628
|
+
},
|
|
629
|
+
ARROW_DOWN: {
|
|
630
|
+
guard: "isVertical",
|
|
631
|
+
actions: "decrement"
|
|
632
|
+
},
|
|
633
|
+
ENTER: [
|
|
634
|
+
{
|
|
635
|
+
guard: "isCollapsed",
|
|
636
|
+
actions: "setToMin"
|
|
637
|
+
},
|
|
638
|
+
{ actions: "setToMin" }
|
|
639
|
+
],
|
|
640
|
+
HOME: {
|
|
633
641
|
actions: "setToMin"
|
|
634
642
|
},
|
|
635
|
-
|
|
636
|
-
],
|
|
637
|
-
HOME: {
|
|
638
|
-
actions: "setToMin"
|
|
639
|
-
},
|
|
640
|
-
END: {
|
|
641
|
-
actions: "setToMax"
|
|
642
|
-
},
|
|
643
|
-
DOUBLE_CLICK: [
|
|
644
|
-
{
|
|
645
|
-
guard: "isCollapsed",
|
|
643
|
+
END: {
|
|
646
644
|
actions: "setToMax"
|
|
647
645
|
},
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
activities: "trackPointerMove",
|
|
656
|
-
on: {
|
|
657
|
-
POINTER_UP: {
|
|
658
|
-
target: "focused",
|
|
659
|
-
actions: ["invokeOnChangeEnd"]
|
|
660
|
-
},
|
|
661
|
-
POINTER_MOVE: {
|
|
662
|
-
actions: "setPointerValue"
|
|
646
|
+
DOUBLE_CLICK: [
|
|
647
|
+
{
|
|
648
|
+
guard: "isCollapsed",
|
|
649
|
+
actions: "setToMax"
|
|
650
|
+
},
|
|
651
|
+
{ actions: "setToMin" }
|
|
652
|
+
]
|
|
663
653
|
}
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
onPointerUp() {
|
|
678
|
-
send("POINTER_UP");
|
|
679
|
-
el.style.cursor = "";
|
|
654
|
+
},
|
|
655
|
+
dragging: {
|
|
656
|
+
tags: ["focus"],
|
|
657
|
+
entry: "focusSplitter",
|
|
658
|
+
activities: "trackPointerMove",
|
|
659
|
+
on: {
|
|
660
|
+
POINTER_UP: {
|
|
661
|
+
target: "focused",
|
|
662
|
+
actions: ["invokeOnChangeEnd"]
|
|
663
|
+
},
|
|
664
|
+
POINTER_MOVE: {
|
|
665
|
+
actions: "setPointerValue"
|
|
666
|
+
}
|
|
680
667
|
}
|
|
681
|
-
}
|
|
668
|
+
}
|
|
682
669
|
}
|
|
683
670
|
},
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
671
|
+
{
|
|
672
|
+
activities: {
|
|
673
|
+
trackPointerMove: (ctx2, _evt, { send }) => {
|
|
674
|
+
const doc = dom.getDoc(ctx2);
|
|
675
|
+
return trackPointerMove(doc, {
|
|
676
|
+
onPointerMove(info) {
|
|
677
|
+
send({ type: "POINTER_MOVE", point: info.point });
|
|
678
|
+
doc.documentElement.style.cursor = dom.getCursor(ctx2);
|
|
679
|
+
},
|
|
680
|
+
onPointerUp() {
|
|
681
|
+
send("POINTER_UP");
|
|
682
|
+
doc.documentElement.style.cursor = "";
|
|
683
|
+
}
|
|
684
|
+
});
|
|
698
685
|
}
|
|
699
686
|
},
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
var _a;
|
|
706
|
-
(_a = ctx2.onChangeEnd) == null ? void 0 : _a.call(ctx2, { value: ctx2.value });
|
|
707
|
-
},
|
|
708
|
-
setupDocument(ctx2, evt) {
|
|
709
|
-
if (evt.doc)
|
|
710
|
-
ctx2.doc = ref(evt.doc);
|
|
711
|
-
if (evt.root)
|
|
712
|
-
ctx2.rootNode = ref(evt.root);
|
|
713
|
-
ctx2.uid = evt.id;
|
|
687
|
+
guards: {
|
|
688
|
+
isCollapsed: (ctx2) => ctx2.isAtMin,
|
|
689
|
+
isHorizontal: (ctx2) => ctx2.isHorizontal,
|
|
690
|
+
isVertical: (ctx2) => !ctx2.isHorizontal,
|
|
691
|
+
isFixed: (ctx2) => !!ctx2.fixed
|
|
714
692
|
},
|
|
715
|
-
|
|
716
|
-
|
|
693
|
+
delays: {
|
|
694
|
+
HOVER_DELAY: 250
|
|
717
695
|
},
|
|
718
|
-
|
|
719
|
-
ctx2
|
|
720
|
-
},
|
|
721
|
-
increment(ctx2, evt) {
|
|
722
|
-
ctx2.value = clamp(increment(ctx2.value, evt.step), ctx2);
|
|
723
|
-
},
|
|
724
|
-
decrement(ctx2, evt) {
|
|
725
|
-
ctx2.value = clamp(decrement(ctx2.value, evt.step), ctx2);
|
|
726
|
-
},
|
|
727
|
-
focusSplitter(ctx2) {
|
|
728
|
-
raf(() => {
|
|
696
|
+
actions: {
|
|
697
|
+
invokeOnChange(ctx2, evt) {
|
|
729
698
|
var _a;
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
value = ctx2.
|
|
699
|
+
if (evt.type !== "SETUP") {
|
|
700
|
+
(_a = ctx2.onChange) == null ? void 0 : _a.call(ctx2, { value: ctx2.value });
|
|
701
|
+
}
|
|
702
|
+
},
|
|
703
|
+
invokeOnChangeStart(ctx2) {
|
|
704
|
+
var _a;
|
|
705
|
+
(_a = ctx2.onChangeStart) == null ? void 0 : _a.call(ctx2, { value: ctx2.value });
|
|
706
|
+
},
|
|
707
|
+
invokeOnChangeEnd(ctx2) {
|
|
708
|
+
var _a;
|
|
709
|
+
(_a = ctx2.onChangeEnd) == null ? void 0 : _a.call(ctx2, { value: ctx2.value });
|
|
710
|
+
},
|
|
711
|
+
setToMin(ctx2) {
|
|
712
|
+
ctx2.value = ctx2.min;
|
|
713
|
+
},
|
|
714
|
+
setToMax(ctx2) {
|
|
715
|
+
ctx2.value = ctx2.max;
|
|
716
|
+
},
|
|
717
|
+
increment(ctx2, evt) {
|
|
718
|
+
ctx2.value = clamp(increment(ctx2.value, evt.step), ctx2);
|
|
719
|
+
},
|
|
720
|
+
decrement(ctx2, evt) {
|
|
721
|
+
ctx2.value = clamp(decrement(ctx2.value, evt.step), ctx2);
|
|
722
|
+
},
|
|
723
|
+
focusSplitter(ctx2) {
|
|
724
|
+
raf(() => {
|
|
725
|
+
var _a;
|
|
726
|
+
return (_a = dom.getSplitterEl(ctx2)) == null ? void 0 : _a.focus();
|
|
727
|
+
});
|
|
728
|
+
},
|
|
729
|
+
setPointerValue(ctx2, evt) {
|
|
730
|
+
const el = dom.getPrimaryPaneEl(ctx2);
|
|
731
|
+
if (!el)
|
|
732
|
+
return;
|
|
733
|
+
const relativePoint = getPointRelativeToNode(evt.point, el);
|
|
734
|
+
let currentPoint = ctx2.isHorizontal ? relativePoint.x : relativePoint.y;
|
|
735
|
+
let value = parseFloat(snapToStep(clamp(currentPoint, ctx2), ctx2.step));
|
|
736
|
+
if (Math.abs(value - ctx2.min) <= ctx2.snapOffset) {
|
|
737
|
+
value = ctx2.min;
|
|
738
|
+
} else if (Math.abs(value - ctx2.max) <= ctx2.snapOffset) {
|
|
739
|
+
value = ctx2.max;
|
|
740
|
+
}
|
|
741
|
+
ctx2.value = value;
|
|
744
742
|
}
|
|
745
|
-
ctx2.value = value;
|
|
746
743
|
}
|
|
747
744
|
}
|
|
748
|
-
|
|
745
|
+
);
|
|
749
746
|
}
|
|
750
747
|
export {
|
|
751
748
|
connect,
|