@zag-js/slider 0.0.0-dev-20220514161650 → 0.0.0-dev-20220519150040
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 +20 -14
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +20 -14
- package/dist/index.mjs.map +3 -3
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -212,10 +212,6 @@ function getOwnerWindow(el) {
|
|
|
212
212
|
var _a;
|
|
213
213
|
return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
|
|
214
214
|
}
|
|
215
|
-
function getNativeEvent(event) {
|
|
216
|
-
var _a;
|
|
217
|
-
return (_a = event.nativeEvent) != null ? _a : event;
|
|
218
|
-
}
|
|
219
215
|
function getDescriptor(el, options) {
|
|
220
216
|
var _a;
|
|
221
217
|
const { type, property } = options;
|
|
@@ -254,6 +250,10 @@ function trackInputPropertyMutation(el, options) {
|
|
|
254
250
|
run = false;
|
|
255
251
|
};
|
|
256
252
|
}
|
|
253
|
+
function getNativeEvent(event) {
|
|
254
|
+
var _a;
|
|
255
|
+
return (_a = event.nativeEvent) != null ? _a : event;
|
|
256
|
+
}
|
|
257
257
|
function getClosestFormElement(el) {
|
|
258
258
|
if (isFormElement(el))
|
|
259
259
|
return el.form;
|
|
@@ -427,10 +427,6 @@ findByTypeahead.defaultOptions = {
|
|
|
427
427
|
|
|
428
428
|
// ../../utilities/number/dist/index.mjs
|
|
429
429
|
var __pow2 = Math.pow;
|
|
430
|
-
var nf = new Intl.NumberFormat("en-US", { style: "decimal", maximumFractionDigits: 20 });
|
|
431
|
-
function formatter(n) {
|
|
432
|
-
return parseFloat(nf.format(n));
|
|
433
|
-
}
|
|
434
430
|
function round(v, t2) {
|
|
435
431
|
let num = valueOf(v);
|
|
436
432
|
const p = __pow2(10, t2 != null ? t2 : 10);
|
|
@@ -445,17 +441,15 @@ function clamp(v, o) {
|
|
|
445
441
|
function countDecimals(value) {
|
|
446
442
|
if (!Number.isFinite(value))
|
|
447
443
|
return 0;
|
|
448
|
-
let e = 1;
|
|
449
|
-
let p = 0;
|
|
444
|
+
let e = 1, p = 0;
|
|
450
445
|
while (Math.round(value * e) / e !== value) {
|
|
451
446
|
e *= 10;
|
|
452
447
|
p += 1;
|
|
453
448
|
}
|
|
454
449
|
return p;
|
|
455
450
|
}
|
|
456
|
-
var increment = (v, s) =>
|
|
457
|
-
var decrement = (v, s) =>
|
|
458
|
-
var multiply = (v, s) => formatter(valueOf(v) * s);
|
|
451
|
+
var increment = (v, s) => decimalOperation(valueOf(v), "+", s);
|
|
452
|
+
var decrement = (v, s) => decimalOperation(valueOf(v), "-", s);
|
|
459
453
|
function snapToStep(value, step) {
|
|
460
454
|
const num = valueOf(value);
|
|
461
455
|
const p = countDecimals(step);
|
|
@@ -468,6 +462,18 @@ function valueOf(v) {
|
|
|
468
462
|
const num = parseFloat(v.toString().replace(/[^\w.-]+/g, ""));
|
|
469
463
|
return !Number.isNaN(num) ? num : 0;
|
|
470
464
|
}
|
|
465
|
+
function decimalOperation(a, op, b) {
|
|
466
|
+
let result = op === "+" ? a + b : a - b;
|
|
467
|
+
if (a % 1 !== 0 || b % 1 !== 0) {
|
|
468
|
+
const multiplier = __pow2(10, Math.max(countDecimals(a), countDecimals(b)));
|
|
469
|
+
a = Math.round(a * multiplier);
|
|
470
|
+
b = Math.round(b * multiplier);
|
|
471
|
+
result = op === "+" ? a + b : a - b;
|
|
472
|
+
result /= multiplier;
|
|
473
|
+
}
|
|
474
|
+
return result;
|
|
475
|
+
}
|
|
476
|
+
var nf = new Intl.NumberFormat("en-US", { style: "decimal", maximumFractionDigits: 20 });
|
|
471
477
|
var transform = (a, b) => {
|
|
472
478
|
const i = { min: a[0], max: a[1] };
|
|
473
479
|
const o = { min: b[0], max: b[1] };
|
|
@@ -760,7 +766,7 @@ function connect(state2, send, normalize = normalizeProp) {
|
|
|
760
766
|
onKeyDown(event) {
|
|
761
767
|
if (!isInteractive)
|
|
762
768
|
return;
|
|
763
|
-
const step =
|
|
769
|
+
const step = getEventStep(event) * state2.context.step;
|
|
764
770
|
let prevent = true;
|
|
765
771
|
const keyMap = {
|
|
766
772
|
ArrowUp() {
|