@zag-js/number-input 0.2.12 → 0.2.13
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/{chunk-4A67X5BX.mjs → chunk-3O7PA63J.mjs} +13 -138
- package/dist/{chunk-6CS5P7OC.mjs → chunk-AXXDGYUW.mjs} +2 -8
- package/dist/{chunk-4ASBTBA5.mjs → chunk-DYFCS7PF.mjs} +46 -43
- package/dist/{chunk-GQN3V2LU.mjs → chunk-QYY4CWRS.mjs} +4 -13
- package/dist/index.js +105 -326
- package/dist/index.mjs +4 -5
- package/dist/number-input.connect.d.ts +39 -0
- package/dist/number-input.connect.js +81 -175
- package/dist/number-input.connect.mjs +3 -4
- package/dist/number-input.dom.d.ts +9 -6
- package/dist/number-input.dom.js +9 -65
- package/dist/number-input.dom.mjs +1 -2
- package/dist/number-input.machine.js +41 -266
- package/dist/number-input.machine.mjs +3 -4
- package/dist/number-input.utils.js +9 -54
- package/dist/number-input.utils.mjs +1 -2
- package/package.json +10 -8
- package/dist/chunk-EPCXXTFL.mjs +0 -141
package/dist/chunk-EPCXXTFL.mjs
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
// ../../utilities/dom/src/platform.ts
|
|
2
|
-
var isDom = () => typeof window !== "undefined";
|
|
3
|
-
function getPlatform() {
|
|
4
|
-
const agent = navigator.userAgentData;
|
|
5
|
-
return agent?.platform ?? navigator.platform;
|
|
6
|
-
}
|
|
7
|
-
var pt = (v) => isDom() && v.test(getPlatform());
|
|
8
|
-
var vn = (v) => isDom() && v.test(navigator.vendor);
|
|
9
|
-
var isSafari = () => isApple() && vn(/apple/i);
|
|
10
|
-
var isApple = () => pt(/mac|iphone|ipad|ipod/i);
|
|
11
|
-
|
|
12
|
-
// ../../utilities/dom/src/query.ts
|
|
13
|
-
function isDocument(el) {
|
|
14
|
-
return el.nodeType === Node.DOCUMENT_NODE;
|
|
15
|
-
}
|
|
16
|
-
function isWindow(value) {
|
|
17
|
-
return value?.toString() === "[object Window]";
|
|
18
|
-
}
|
|
19
|
-
function getDocument(el) {
|
|
20
|
-
if (isWindow(el))
|
|
21
|
-
return el.document;
|
|
22
|
-
if (isDocument(el))
|
|
23
|
-
return el;
|
|
24
|
-
return el?.ownerDocument ?? document;
|
|
25
|
-
}
|
|
26
|
-
function getWindow(el) {
|
|
27
|
-
return el?.ownerDocument.defaultView ?? window;
|
|
28
|
-
}
|
|
29
|
-
function defineDomHelpers(helpers) {
|
|
30
|
-
const dom = {
|
|
31
|
-
getRootNode: (ctx) => ctx.getRootNode?.() ?? document,
|
|
32
|
-
getDoc: (ctx) => getDocument(dom.getRootNode(ctx)),
|
|
33
|
-
getWin: (ctx) => dom.getDoc(ctx).defaultView ?? window,
|
|
34
|
-
getActiveElement: (ctx) => dom.getDoc(ctx).activeElement,
|
|
35
|
-
getById: (ctx, id) => dom.getRootNode(ctx).getElementById(id)
|
|
36
|
-
};
|
|
37
|
-
return {
|
|
38
|
-
...dom,
|
|
39
|
-
...helpers
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// ../../utilities/core/src/guard.ts
|
|
44
|
-
var isArray = (v) => Array.isArray(v);
|
|
45
|
-
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
|
|
46
|
-
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
47
|
-
|
|
48
|
-
// ../../utilities/dom/src/event.ts
|
|
49
|
-
function getNativeEvent(e) {
|
|
50
|
-
return e.nativeEvent ?? e;
|
|
51
|
-
}
|
|
52
|
-
var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
|
|
53
|
-
var isTouchEvent = (v) => isObject(v) && hasProp(v, "touches");
|
|
54
|
-
var isLeftClick = (v) => v.button === 0;
|
|
55
|
-
var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey;
|
|
56
|
-
|
|
57
|
-
// ../../utilities/number/src/number.ts
|
|
58
|
-
function wrap(num, max) {
|
|
59
|
-
return (num % max + max) % max;
|
|
60
|
-
}
|
|
61
|
-
function roundToDevicePixel(num) {
|
|
62
|
-
if (typeof window === "undefined")
|
|
63
|
-
return Math.round(num);
|
|
64
|
-
const dp = window.devicePixelRatio;
|
|
65
|
-
return Math.floor(num * dp + 0.5) / dp;
|
|
66
|
-
}
|
|
67
|
-
function clamp(v, o) {
|
|
68
|
-
return Math.min(Math.max(valueOf(v), o.min), o.max);
|
|
69
|
-
}
|
|
70
|
-
function countDecimals(value) {
|
|
71
|
-
if (!Number.isFinite(value))
|
|
72
|
-
return 0;
|
|
73
|
-
let e = 1, p = 0;
|
|
74
|
-
while (Math.round(value * e) / e !== value) {
|
|
75
|
-
e *= 10;
|
|
76
|
-
p += 1;
|
|
77
|
-
}
|
|
78
|
-
return p;
|
|
79
|
-
}
|
|
80
|
-
var increment = (v, s) => decimalOperation(valueOf(v), "+", s);
|
|
81
|
-
var decrement = (v, s) => decimalOperation(valueOf(v), "-", s);
|
|
82
|
-
function valueOf(v) {
|
|
83
|
-
if (typeof v === "number")
|
|
84
|
-
return v;
|
|
85
|
-
const num = parseFloat(v.toString().replace(/[^\w.-]+/g, ""));
|
|
86
|
-
return !Number.isNaN(num) ? num : 0;
|
|
87
|
-
}
|
|
88
|
-
function formatDecimal(v, o) {
|
|
89
|
-
return new Intl.NumberFormat("en-US", {
|
|
90
|
-
useGrouping: false,
|
|
91
|
-
style: "decimal",
|
|
92
|
-
minimumFractionDigits: o.minFractionDigits,
|
|
93
|
-
maximumFractionDigits: o.maxFractionDigits
|
|
94
|
-
}).format(valueOf(v));
|
|
95
|
-
}
|
|
96
|
-
function isAtMax(v, o) {
|
|
97
|
-
const val = valueOf(v);
|
|
98
|
-
return val >= o.max;
|
|
99
|
-
}
|
|
100
|
-
function isAtMin(v, o) {
|
|
101
|
-
const val = valueOf(v);
|
|
102
|
-
return val <= o.min;
|
|
103
|
-
}
|
|
104
|
-
function isWithinRange(v, o) {
|
|
105
|
-
const val = valueOf(v);
|
|
106
|
-
return val >= o.min && val <= o.max;
|
|
107
|
-
}
|
|
108
|
-
function decimalOperation(a, op, b) {
|
|
109
|
-
let result = op === "+" ? a + b : a - b;
|
|
110
|
-
if (a % 1 !== 0 || b % 1 !== 0) {
|
|
111
|
-
const multiplier = 10 ** Math.max(countDecimals(a), countDecimals(b));
|
|
112
|
-
a = Math.round(a * multiplier);
|
|
113
|
-
b = Math.round(b * multiplier);
|
|
114
|
-
result = op === "+" ? a + b : a - b;
|
|
115
|
-
result /= multiplier;
|
|
116
|
-
}
|
|
117
|
-
return result;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export {
|
|
121
|
-
isObject,
|
|
122
|
-
hasProp,
|
|
123
|
-
isSafari,
|
|
124
|
-
getWindow,
|
|
125
|
-
defineDomHelpers,
|
|
126
|
-
getNativeEvent,
|
|
127
|
-
supportsPointerEvent,
|
|
128
|
-
isTouchEvent,
|
|
129
|
-
isLeftClick,
|
|
130
|
-
isModifiedEvent,
|
|
131
|
-
wrap,
|
|
132
|
-
roundToDevicePixel,
|
|
133
|
-
clamp,
|
|
134
|
-
increment,
|
|
135
|
-
decrement,
|
|
136
|
-
valueOf,
|
|
137
|
-
formatDecimal,
|
|
138
|
-
isAtMax,
|
|
139
|
-
isAtMin,
|
|
140
|
-
isWithinRange
|
|
141
|
-
};
|