@zag-js/splitter 0.1.3 → 0.1.6
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.js +28 -11
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +28 -11
- package/dist/index.mjs.map +3 -3
- package/dist/splitter.dom.d.ts +1 -0
- package/dist/splitter.dom.d.ts.map +1 -1
- package/dist/splitter.machine.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -336,7 +336,11 @@ findByTypeahead.defaultOptions = {
|
|
|
336
336
|
|
|
337
337
|
// ../../types/dist/index.mjs
|
|
338
338
|
function createNormalizer(fn) {
|
|
339
|
-
return {
|
|
339
|
+
return new Proxy({}, {
|
|
340
|
+
get() {
|
|
341
|
+
return fn;
|
|
342
|
+
}
|
|
343
|
+
});
|
|
340
344
|
}
|
|
341
345
|
var normalizeProp = createNormalizer((v) => v);
|
|
342
346
|
|
|
@@ -346,6 +350,10 @@ var dom = {
|
|
|
346
350
|
var _a;
|
|
347
351
|
return (_a = ctx.doc) != null ? _a : document;
|
|
348
352
|
},
|
|
353
|
+
getRootNode: (ctx) => {
|
|
354
|
+
var _a;
|
|
355
|
+
return (_a = ctx.rootNode) != null ? _a : dom.getDoc(ctx);
|
|
356
|
+
},
|
|
349
357
|
getRootId: (ctx) => {
|
|
350
358
|
var _a, _b;
|
|
351
359
|
return (_b = (_a = ctx.ids) == null ? void 0 : _a.root) != null ? _b : `splitter:${ctx.uid}`;
|
|
@@ -370,8 +378,8 @@ var dom = {
|
|
|
370
378
|
var _a, _b;
|
|
371
379
|
return (_b = (_a = ctx.ids) == null ? void 0 : _a.secondaryPane) != null ? _b : `splitter:${ctx.uid}:secondary`;
|
|
372
380
|
},
|
|
373
|
-
getSplitterEl: (ctx) => dom.
|
|
374
|
-
getPrimaryPaneEl: (ctx) => dom.
|
|
381
|
+
getSplitterEl: (ctx) => dom.getRootNode(ctx).getElementById(dom.getSplitterId(ctx)),
|
|
382
|
+
getPrimaryPaneEl: (ctx) => dom.getRootNode(ctx).getElementById(dom.getPrimaryPaneId(ctx)),
|
|
375
383
|
getCursor(ctx) {
|
|
376
384
|
if (ctx.disabled || ctx.fixed)
|
|
377
385
|
return "default";
|
|
@@ -554,10 +562,6 @@ import { createMachine, guards, ref } from "@zag-js/core";
|
|
|
554
562
|
|
|
555
563
|
// ../../utilities/number/dist/index.mjs
|
|
556
564
|
var __pow2 = Math.pow;
|
|
557
|
-
var nf = new Intl.NumberFormat("en-US", { style: "decimal", maximumFractionDigits: 20 });
|
|
558
|
-
function formatter(n) {
|
|
559
|
-
return parseFloat(nf.format(n));
|
|
560
|
-
}
|
|
561
565
|
function round(v, t2) {
|
|
562
566
|
let num = valueOf(v);
|
|
563
567
|
const p = __pow2(10, t2 != null ? t2 : 10);
|
|
@@ -570,16 +574,15 @@ function clamp(v, o) {
|
|
|
570
574
|
function countDecimals(value) {
|
|
571
575
|
if (!Number.isFinite(value))
|
|
572
576
|
return 0;
|
|
573
|
-
let e = 1;
|
|
574
|
-
let p = 0;
|
|
577
|
+
let e = 1, p = 0;
|
|
575
578
|
while (Math.round(value * e) / e !== value) {
|
|
576
579
|
e *= 10;
|
|
577
580
|
p += 1;
|
|
578
581
|
}
|
|
579
582
|
return p;
|
|
580
583
|
}
|
|
581
|
-
var increment = (v, s) =>
|
|
582
|
-
var decrement = (v, s) =>
|
|
584
|
+
var increment = (v, s) => decimalOperation(valueOf(v), "+", s);
|
|
585
|
+
var decrement = (v, s) => decimalOperation(valueOf(v), "-", s);
|
|
583
586
|
function snapToStep(value, step) {
|
|
584
587
|
const num = valueOf(value);
|
|
585
588
|
const p = countDecimals(step);
|
|
@@ -592,6 +595,18 @@ function valueOf(v) {
|
|
|
592
595
|
const num = parseFloat(v.toString().replace(/[^\w.-]+/g, ""));
|
|
593
596
|
return !Number.isNaN(num) ? num : 0;
|
|
594
597
|
}
|
|
598
|
+
function decimalOperation(a, op, b) {
|
|
599
|
+
let result = op === "+" ? a + b : a - b;
|
|
600
|
+
if (a % 1 !== 0 || b % 1 !== 0) {
|
|
601
|
+
const multiplier = __pow2(10, Math.max(countDecimals(a), countDecimals(b)));
|
|
602
|
+
a = Math.round(a * multiplier);
|
|
603
|
+
b = Math.round(b * multiplier);
|
|
604
|
+
result = op === "+" ? a + b : a - b;
|
|
605
|
+
result /= multiplier;
|
|
606
|
+
}
|
|
607
|
+
return result;
|
|
608
|
+
}
|
|
609
|
+
var nf = new Intl.NumberFormat("en-US", { style: "decimal", maximumFractionDigits: 20 });
|
|
595
610
|
|
|
596
611
|
// ../../utilities/rect/dist/index.mjs
|
|
597
612
|
function relativeToNode(p, el) {
|
|
@@ -786,6 +801,8 @@ function machine(ctx = {}) {
|
|
|
786
801
|
setupDocument(ctx2, evt) {
|
|
787
802
|
if (evt.doc)
|
|
788
803
|
ctx2.doc = ref(evt.doc);
|
|
804
|
+
if (evt.root)
|
|
805
|
+
ctx2.rootNode = ref(evt.root);
|
|
789
806
|
ctx2.uid = evt.id;
|
|
790
807
|
},
|
|
791
808
|
setToMin(ctx2) {
|