@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.js
CHANGED
|
@@ -359,7 +359,11 @@ findByTypeahead.defaultOptions = {
|
|
|
359
359
|
|
|
360
360
|
// ../../types/dist/index.mjs
|
|
361
361
|
function createNormalizer(fn) {
|
|
362
|
-
return {
|
|
362
|
+
return new Proxy({}, {
|
|
363
|
+
get() {
|
|
364
|
+
return fn;
|
|
365
|
+
}
|
|
366
|
+
});
|
|
363
367
|
}
|
|
364
368
|
var normalizeProp = createNormalizer((v) => v);
|
|
365
369
|
|
|
@@ -369,6 +373,10 @@ var dom = {
|
|
|
369
373
|
var _a;
|
|
370
374
|
return (_a = ctx.doc) != null ? _a : document;
|
|
371
375
|
},
|
|
376
|
+
getRootNode: (ctx) => {
|
|
377
|
+
var _a;
|
|
378
|
+
return (_a = ctx.rootNode) != null ? _a : dom.getDoc(ctx);
|
|
379
|
+
},
|
|
372
380
|
getRootId: (ctx) => {
|
|
373
381
|
var _a, _b;
|
|
374
382
|
return (_b = (_a = ctx.ids) == null ? void 0 : _a.root) != null ? _b : `splitter:${ctx.uid}`;
|
|
@@ -393,8 +401,8 @@ var dom = {
|
|
|
393
401
|
var _a, _b;
|
|
394
402
|
return (_b = (_a = ctx.ids) == null ? void 0 : _a.secondaryPane) != null ? _b : `splitter:${ctx.uid}:secondary`;
|
|
395
403
|
},
|
|
396
|
-
getSplitterEl: (ctx) => dom.
|
|
397
|
-
getPrimaryPaneEl: (ctx) => dom.
|
|
404
|
+
getSplitterEl: (ctx) => dom.getRootNode(ctx).getElementById(dom.getSplitterId(ctx)),
|
|
405
|
+
getPrimaryPaneEl: (ctx) => dom.getRootNode(ctx).getElementById(dom.getPrimaryPaneId(ctx)),
|
|
398
406
|
getCursor(ctx) {
|
|
399
407
|
if (ctx.disabled || ctx.fixed)
|
|
400
408
|
return "default";
|
|
@@ -577,10 +585,6 @@ var import_core = require("@zag-js/core");
|
|
|
577
585
|
|
|
578
586
|
// ../../utilities/number/dist/index.mjs
|
|
579
587
|
var __pow2 = Math.pow;
|
|
580
|
-
var nf = new Intl.NumberFormat("en-US", { style: "decimal", maximumFractionDigits: 20 });
|
|
581
|
-
function formatter(n) {
|
|
582
|
-
return parseFloat(nf.format(n));
|
|
583
|
-
}
|
|
584
588
|
function round(v, t2) {
|
|
585
589
|
let num = valueOf(v);
|
|
586
590
|
const p = __pow2(10, t2 != null ? t2 : 10);
|
|
@@ -593,16 +597,15 @@ function clamp(v, o) {
|
|
|
593
597
|
function countDecimals(value) {
|
|
594
598
|
if (!Number.isFinite(value))
|
|
595
599
|
return 0;
|
|
596
|
-
let e = 1;
|
|
597
|
-
let p = 0;
|
|
600
|
+
let e = 1, p = 0;
|
|
598
601
|
while (Math.round(value * e) / e !== value) {
|
|
599
602
|
e *= 10;
|
|
600
603
|
p += 1;
|
|
601
604
|
}
|
|
602
605
|
return p;
|
|
603
606
|
}
|
|
604
|
-
var increment = (v, s) =>
|
|
605
|
-
var decrement = (v, s) =>
|
|
607
|
+
var increment = (v, s) => decimalOperation(valueOf(v), "+", s);
|
|
608
|
+
var decrement = (v, s) => decimalOperation(valueOf(v), "-", s);
|
|
606
609
|
function snapToStep(value, step) {
|
|
607
610
|
const num = valueOf(value);
|
|
608
611
|
const p = countDecimals(step);
|
|
@@ -615,6 +618,18 @@ function valueOf(v) {
|
|
|
615
618
|
const num = parseFloat(v.toString().replace(/[^\w.-]+/g, ""));
|
|
616
619
|
return !Number.isNaN(num) ? num : 0;
|
|
617
620
|
}
|
|
621
|
+
function decimalOperation(a, op, b) {
|
|
622
|
+
let result = op === "+" ? a + b : a - b;
|
|
623
|
+
if (a % 1 !== 0 || b % 1 !== 0) {
|
|
624
|
+
const multiplier = __pow2(10, Math.max(countDecimals(a), countDecimals(b)));
|
|
625
|
+
a = Math.round(a * multiplier);
|
|
626
|
+
b = Math.round(b * multiplier);
|
|
627
|
+
result = op === "+" ? a + b : a - b;
|
|
628
|
+
result /= multiplier;
|
|
629
|
+
}
|
|
630
|
+
return result;
|
|
631
|
+
}
|
|
632
|
+
var nf = new Intl.NumberFormat("en-US", { style: "decimal", maximumFractionDigits: 20 });
|
|
618
633
|
|
|
619
634
|
// ../../utilities/rect/dist/index.mjs
|
|
620
635
|
function relativeToNode(p, el) {
|
|
@@ -809,6 +824,8 @@ function machine(ctx = {}) {
|
|
|
809
824
|
setupDocument(ctx2, evt) {
|
|
810
825
|
if (evt.doc)
|
|
811
826
|
ctx2.doc = (0, import_core.ref)(evt.doc);
|
|
827
|
+
if (evt.root)
|
|
828
|
+
ctx2.rootNode = (0, import_core.ref)(evt.root);
|
|
812
829
|
ctx2.uid = evt.id;
|
|
813
830
|
},
|
|
814
831
|
setToMin(ctx2) {
|