@zag-js/slider 0.2.7 → 0.2.8

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.
@@ -1,56 +0,0 @@
1
- // ../../utilities/number/src/number.ts
2
- function round(v, t) {
3
- let num = valueOf(v);
4
- const p = 10 ** (t != null ? t : 10);
5
- num = Math.round(num * p) / p;
6
- return t ? num.toFixed(t) : v.toString();
7
- }
8
- var valueToPercent = (v, r) => (valueOf(v) - r.min) * 100 / (r.max - r.min);
9
- var percentToValue = (v, r) => r.min + (r.max - r.min) * valueOf(v);
10
- function clamp(v, o) {
11
- return Math.min(Math.max(valueOf(v), o.min), o.max);
12
- }
13
- function countDecimals(value) {
14
- if (!Number.isFinite(value))
15
- return 0;
16
- let e = 1, p = 0;
17
- while (Math.round(value * e) / e !== value) {
18
- e *= 10;
19
- p += 1;
20
- }
21
- return p;
22
- }
23
- var increment = (v, s) => decimalOperation(valueOf(v), "+", s);
24
- var decrement = (v, s) => decimalOperation(valueOf(v), "-", s);
25
- function snapToStep(value, step) {
26
- const num = valueOf(value);
27
- const p = countDecimals(step);
28
- const v = Math.round(num / step) * step;
29
- return round(v, p);
30
- }
31
- function valueOf(v) {
32
- if (typeof v === "number")
33
- return v;
34
- const num = parseFloat(v.toString().replace(/[^\w.-]+/g, ""));
35
- return !Number.isNaN(num) ? num : 0;
36
- }
37
- function decimalOperation(a, op, b) {
38
- let result = op === "+" ? a + b : a - b;
39
- if (a % 1 !== 0 || b % 1 !== 0) {
40
- const multiplier = 10 ** Math.max(countDecimals(a), countDecimals(b));
41
- a = Math.round(a * multiplier);
42
- b = Math.round(b * multiplier);
43
- result = op === "+" ? a + b : a - b;
44
- result /= multiplier;
45
- }
46
- return result;
47
- }
48
-
49
- export {
50
- valueToPercent,
51
- percentToValue,
52
- clamp,
53
- increment,
54
- decrement,
55
- snapToStep
56
- };