@zag-js/number-input 1.4.2 → 1.6.0
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 +9 -1
- package/dist/index.mjs +9 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -408,12 +408,20 @@ var formatValue = (value, params) => {
|
|
|
408
408
|
if (!prop("formatOptions")) return value.toString();
|
|
409
409
|
return computed("formatter").format(value);
|
|
410
410
|
};
|
|
411
|
+
var getDefaultStep = (step, formatOptions) => {
|
|
412
|
+
let defaultStep = step !== void 0 && !Number.isNaN(step) ? step : 1;
|
|
413
|
+
if (formatOptions?.style === "percent" && (step === void 0 || Number.isNaN(step))) {
|
|
414
|
+
defaultStep = 0.01;
|
|
415
|
+
}
|
|
416
|
+
return defaultStep;
|
|
417
|
+
};
|
|
411
418
|
|
|
412
419
|
// src/number-input.machine.ts
|
|
413
420
|
var { choose, guards, createMachine } = core.setup();
|
|
414
421
|
var { not, and } = guards;
|
|
415
422
|
var machine = createMachine({
|
|
416
423
|
props({ props: props2 }) {
|
|
424
|
+
const step = getDefaultStep(props2.step, props2.formatOptions);
|
|
417
425
|
return {
|
|
418
426
|
dir: "ltr",
|
|
419
427
|
locale: "en-US",
|
|
@@ -423,7 +431,7 @@ var machine = createMachine({
|
|
|
423
431
|
inputMode: "decimal",
|
|
424
432
|
pattern: "[0-9]*(.[0-9]+)?",
|
|
425
433
|
defaultValue: "",
|
|
426
|
-
step
|
|
434
|
+
step,
|
|
427
435
|
min: Number.MIN_SAFE_INTEGER,
|
|
428
436
|
max: Number.MAX_SAFE_INTEGER,
|
|
429
437
|
spinOnPress: true,
|
package/dist/index.mjs
CHANGED
|
@@ -406,12 +406,20 @@ var formatValue = (value, params) => {
|
|
|
406
406
|
if (!prop("formatOptions")) return value.toString();
|
|
407
407
|
return computed("formatter").format(value);
|
|
408
408
|
};
|
|
409
|
+
var getDefaultStep = (step, formatOptions) => {
|
|
410
|
+
let defaultStep = step !== void 0 && !Number.isNaN(step) ? step : 1;
|
|
411
|
+
if (formatOptions?.style === "percent" && (step === void 0 || Number.isNaN(step))) {
|
|
412
|
+
defaultStep = 0.01;
|
|
413
|
+
}
|
|
414
|
+
return defaultStep;
|
|
415
|
+
};
|
|
409
416
|
|
|
410
417
|
// src/number-input.machine.ts
|
|
411
418
|
var { choose, guards, createMachine } = setup();
|
|
412
419
|
var { not, and } = guards;
|
|
413
420
|
var machine = createMachine({
|
|
414
421
|
props({ props: props2 }) {
|
|
422
|
+
const step = getDefaultStep(props2.step, props2.formatOptions);
|
|
415
423
|
return {
|
|
416
424
|
dir: "ltr",
|
|
417
425
|
locale: "en-US",
|
|
@@ -421,7 +429,7 @@ var machine = createMachine({
|
|
|
421
429
|
inputMode: "decimal",
|
|
422
430
|
pattern: "[0-9]*(.[0-9]+)?",
|
|
423
431
|
defaultValue: "",
|
|
424
|
-
step
|
|
432
|
+
step,
|
|
425
433
|
min: Number.MIN_SAFE_INTEGER,
|
|
426
434
|
max: Number.MAX_SAFE_INTEGER,
|
|
427
435
|
spinOnPress: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/number-input",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Core logic for the number-input widget implemented as a state machine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@internationalized/number": "3.6.0",
|
|
30
|
-
"@zag-js/anatomy": "1.
|
|
31
|
-
"@zag-js/core": "1.
|
|
32
|
-
"@zag-js/dom-query": "1.
|
|
33
|
-
"@zag-js/types": "1.
|
|
34
|
-
"@zag-js/utils": "1.
|
|
30
|
+
"@zag-js/anatomy": "1.6.0",
|
|
31
|
+
"@zag-js/core": "1.6.0",
|
|
32
|
+
"@zag-js/dom-query": "1.6.0",
|
|
33
|
+
"@zag-js/types": "1.6.0",
|
|
34
|
+
"@zag-js/utils": "1.6.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"clean-package": "2.2.0"
|