@zag-js/number-input 1.47.0 → 1.49.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/cursor.d.mts +8 -10
- package/dist/cursor.d.ts +8 -10
- package/dist/cursor.js +65 -104
- package/dist/cursor.mjs +59 -77
- package/dist/index.d.mts +6 -9
- package/dist/index.d.ts +6 -9
- package/dist/index.js +12 -38
- package/dist/index.mjs +2 -7
- package/dist/number-input.anatomy.d.mts +2 -6
- package/dist/number-input.anatomy.d.ts +2 -6
- package/dist/number-input.anatomy.js +8 -42
- package/dist/number-input.anatomy.mjs +4 -16
- package/dist/number-input.connect.d.mts +3 -8
- package/dist/number-input.connect.d.ts +3 -8
- package/dist/number-input.connect.js +309 -310
- package/dist/number-input.connect.mjs +302 -283
- package/dist/number-input.dom.d.mts +28 -32
- package/dist/number-input.dom.d.ts +28 -32
- package/dist/number-input.dom.js +96 -137
- package/dist/number-input.dom.mjs +76 -96
- package/dist/number-input.machine.d.mts +2 -8
- package/dist/number-input.machine.d.ts +2 -8
- package/dist/number-input.machine.js +493 -460
- package/dist/number-input.machine.mjs +486 -439
- package/dist/number-input.props.d.mts +3 -9
- package/dist/number-input.props.d.ts +3 -9
- package/dist/number-input.props.js +41 -65
- package/dist/number-input.props.mjs +35 -38
- package/dist/number-input.translations.d.mts +3 -8
- package/dist/number-input.translations.d.ts +3 -8
- package/dist/number-input.translations.js +8 -31
- package/dist/number-input.translations.mjs +4 -6
- package/dist/number-input.types.d.mts +302 -300
- package/dist/number-input.types.d.ts +302 -300
- package/dist/number-input.types.js +4 -18
- package/dist/number-input.types.mjs +1 -0
- package/dist/number-input.utils.d.mts +9 -12
- package/dist/number-input.utils.d.ts +9 -12
- package/dist/number-input.utils.js +28 -57
- package/dist/number-input.utils.mjs +20 -28
- package/package.json +8 -8
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import { NumberParser } from
|
|
2
|
-
import { Params } from
|
|
3
|
-
import { NumberInputSchema } from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
declare const createFormatter: (locale: string, options?: Intl.NumberFormatOptions) => Intl.NumberFormat;
|
|
7
|
-
declare const createParser: (locale: string, options?: Intl.NumberFormatOptions) => NumberParser;
|
|
1
|
+
import { NumberParser } from "@internationalized/number";
|
|
2
|
+
import { Params } from "@zag-js/core";
|
|
3
|
+
import { NumberInputSchema } from "./number-input.types.mjs";
|
|
4
|
+
export declare const createFormatter: (locale: string, options?: Intl.NumberFormatOptions) => Intl.NumberFormat;
|
|
5
|
+
export declare const createParser: (locale: string, options?: Intl.NumberFormatOptions) => NumberParser;
|
|
8
6
|
type Ctx = Pick<Params<NumberInputSchema>, "prop" | "computed">;
|
|
9
|
-
declare const parseValue: (value: string, params: Ctx) => number;
|
|
10
|
-
declare const formatValue: (value: number, params: Ctx) => string;
|
|
11
|
-
declare const getDefaultStep: (step: number | undefined, formatOptions: Intl.NumberFormatOptions | undefined) => number;
|
|
12
|
-
|
|
13
|
-
export { createFormatter, createParser, formatValue, getDefaultStep, parseValue };
|
|
7
|
+
export declare const parseValue: (value: string, params: Ctx) => number;
|
|
8
|
+
export declare const formatValue: (value: number, params: Ctx) => string;
|
|
9
|
+
export declare const getDefaultStep: (step: number | undefined, formatOptions: Intl.NumberFormatOptions | undefined) => number;
|
|
10
|
+
export {};
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import { NumberParser } from
|
|
2
|
-
import { Params } from
|
|
3
|
-
import { NumberInputSchema } from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
declare const createFormatter: (locale: string, options?: Intl.NumberFormatOptions) => Intl.NumberFormat;
|
|
7
|
-
declare const createParser: (locale: string, options?: Intl.NumberFormatOptions) => NumberParser;
|
|
1
|
+
import { NumberParser } from "@internationalized/number";
|
|
2
|
+
import { Params } from "@zag-js/core";
|
|
3
|
+
import { NumberInputSchema } from "./number-input.types.js";
|
|
4
|
+
export declare const createFormatter: (locale: string, options?: Intl.NumberFormatOptions) => Intl.NumberFormat;
|
|
5
|
+
export declare const createParser: (locale: string, options?: Intl.NumberFormatOptions) => NumberParser;
|
|
8
6
|
type Ctx = Pick<Params<NumberInputSchema>, "prop" | "computed">;
|
|
9
|
-
declare const parseValue: (value: string, params: Ctx) => number;
|
|
10
|
-
declare const formatValue: (value: number, params: Ctx) => string;
|
|
11
|
-
declare const getDefaultStep: (step: number | undefined, formatOptions: Intl.NumberFormatOptions | undefined) => number;
|
|
12
|
-
|
|
13
|
-
export { createFormatter, createParser, formatValue, getDefaultStep, parseValue };
|
|
7
|
+
export declare const parseValue: (value: string, params: Ctx) => number;
|
|
8
|
+
export declare const formatValue: (value: number, params: Ctx) => string;
|
|
9
|
+
export declare const getDefaultStep: (step: number | undefined, formatOptions: Intl.NumberFormatOptions | undefined) => number;
|
|
10
|
+
export {};
|
|
@@ -1,63 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/number-input.utils.ts
|
|
21
|
-
var number_input_utils_exports = {};
|
|
22
|
-
__export(number_input_utils_exports, {
|
|
23
|
-
createFormatter: () => createFormatter,
|
|
24
|
-
createParser: () => createParser,
|
|
25
|
-
formatValue: () => formatValue,
|
|
26
|
-
getDefaultStep: () => getDefaultStep,
|
|
27
|
-
parseValue: () => parseValue
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
28
4
|
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
5
|
+
let _internationalized_number = require("@internationalized/number");
|
|
6
|
+
// src/number-input.utils.ts
|
|
7
|
+
const createFormatter = (locale, options = {}) => {
|
|
8
|
+
return new Intl.NumberFormat(locale, options);
|
|
33
9
|
};
|
|
34
|
-
|
|
35
|
-
|
|
10
|
+
const createParser = (locale, options = {}) => {
|
|
11
|
+
return new _internationalized_number.NumberParser(locale, options);
|
|
36
12
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
13
|
+
const parseValue = (value, params) => {
|
|
14
|
+
const { prop, computed } = params;
|
|
15
|
+
if (!prop("formatOptions")) return parseFloat(value);
|
|
16
|
+
if (value === "") return NaN;
|
|
17
|
+
return computed("parser").parse(value);
|
|
42
18
|
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
19
|
+
const formatValue = (value, params) => {
|
|
20
|
+
const { prop, computed } = params;
|
|
21
|
+
if (Number.isNaN(value)) return "";
|
|
22
|
+
if (!prop("formatOptions")) return value.toString();
|
|
23
|
+
return computed("formatter").format(value);
|
|
48
24
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
return defaultStep;
|
|
25
|
+
const getDefaultStep = (step, formatOptions) => {
|
|
26
|
+
let defaultStep = step !== void 0 && !Number.isNaN(step) ? step : 1;
|
|
27
|
+
if (formatOptions?.style === "percent" && (step === void 0 || Number.isNaN(step))) defaultStep = .01;
|
|
28
|
+
return defaultStep;
|
|
55
29
|
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
getDefaultStep,
|
|
62
|
-
parseValue
|
|
63
|
-
});
|
|
30
|
+
exports.createFormatter = createFormatter;
|
|
31
|
+
exports.createParser = createParser;
|
|
32
|
+
exports.formatValue = formatValue;
|
|
33
|
+
exports.getDefaultStep = getDefaultStep;
|
|
34
|
+
exports.parseValue = parseValue;
|
|
@@ -1,34 +1,26 @@
|
|
|
1
|
-
// src/number-input.utils.ts
|
|
2
1
|
import { NumberParser } from "@internationalized/number";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var createParser = (locale, options = {}) => {
|
|
7
|
-
return new NumberParser(locale, options);
|
|
2
|
+
// src/number-input.utils.ts
|
|
3
|
+
const createFormatter = (locale, options = {}) => {
|
|
4
|
+
return new Intl.NumberFormat(locale, options);
|
|
8
5
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (!prop("formatOptions")) return parseFloat(value);
|
|
12
|
-
if (value === "") return Number.NaN;
|
|
13
|
-
return computed("parser").parse(value);
|
|
6
|
+
const createParser = (locale, options = {}) => {
|
|
7
|
+
return new NumberParser(locale, options);
|
|
14
8
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
const parseValue = (value, params) => {
|
|
10
|
+
const { prop, computed } = params;
|
|
11
|
+
if (!prop("formatOptions")) return parseFloat(value);
|
|
12
|
+
if (value === "") return NaN;
|
|
13
|
+
return computed("parser").parse(value);
|
|
20
14
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return defaultStep;
|
|
15
|
+
const formatValue = (value, params) => {
|
|
16
|
+
const { prop, computed } = params;
|
|
17
|
+
if (Number.isNaN(value)) return "";
|
|
18
|
+
if (!prop("formatOptions")) return value.toString();
|
|
19
|
+
return computed("formatter").format(value);
|
|
27
20
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
getDefaultStep,
|
|
33
|
-
parseValue
|
|
21
|
+
const getDefaultStep = (step, formatOptions) => {
|
|
22
|
+
let defaultStep = step !== void 0 && !Number.isNaN(step) ? step : 1;
|
|
23
|
+
if (formatOptions?.style === "percent" && (step === void 0 || Number.isNaN(step))) defaultStep = .01;
|
|
24
|
+
return defaultStep;
|
|
34
25
|
};
|
|
26
|
+
export { createFormatter, createParser, formatValue, getDefaultStep, parseValue };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/number-input",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.49.0",
|
|
4
4
|
"description": "Core logic for the number-input widget implemented as a state machine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@internationalized/number": "3.6.9",
|
|
33
|
-
"@zag-js/anatomy": "1.
|
|
34
|
-
"@zag-js/core": "1.
|
|
35
|
-
"@zag-js/dom-query": "1.
|
|
36
|
-
"@zag-js/types": "1.
|
|
37
|
-
"@zag-js/utils": "1.
|
|
33
|
+
"@zag-js/anatomy": "1.49.0",
|
|
34
|
+
"@zag-js/core": "1.49.0",
|
|
35
|
+
"@zag-js/dom-query": "1.49.0",
|
|
36
|
+
"@zag-js/types": "1.49.0",
|
|
37
|
+
"@zag-js/utils": "1.49.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"clean-package": "2.2.0"
|
|
@@ -67,8 +67,8 @@
|
|
|
67
67
|
"./package.json": "./package.json"
|
|
68
68
|
},
|
|
69
69
|
"scripts": {
|
|
70
|
-
"build": "
|
|
71
|
-
"lint": "
|
|
70
|
+
"build": "tsdown",
|
|
71
|
+
"lint": "oxlint src",
|
|
72
72
|
"typecheck": "tsc --noEmit"
|
|
73
73
|
}
|
|
74
74
|
}
|