@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.
Files changed (41) hide show
  1. package/dist/cursor.d.mts +8 -10
  2. package/dist/cursor.d.ts +8 -10
  3. package/dist/cursor.js +65 -104
  4. package/dist/cursor.mjs +59 -77
  5. package/dist/index.d.mts +6 -9
  6. package/dist/index.d.ts +6 -9
  7. package/dist/index.js +12 -38
  8. package/dist/index.mjs +2 -7
  9. package/dist/number-input.anatomy.d.mts +2 -6
  10. package/dist/number-input.anatomy.d.ts +2 -6
  11. package/dist/number-input.anatomy.js +8 -42
  12. package/dist/number-input.anatomy.mjs +4 -16
  13. package/dist/number-input.connect.d.mts +3 -8
  14. package/dist/number-input.connect.d.ts +3 -8
  15. package/dist/number-input.connect.js +309 -310
  16. package/dist/number-input.connect.mjs +302 -283
  17. package/dist/number-input.dom.d.mts +28 -32
  18. package/dist/number-input.dom.d.ts +28 -32
  19. package/dist/number-input.dom.js +96 -137
  20. package/dist/number-input.dom.mjs +76 -96
  21. package/dist/number-input.machine.d.mts +2 -8
  22. package/dist/number-input.machine.d.ts +2 -8
  23. package/dist/number-input.machine.js +493 -460
  24. package/dist/number-input.machine.mjs +486 -439
  25. package/dist/number-input.props.d.mts +3 -9
  26. package/dist/number-input.props.d.ts +3 -9
  27. package/dist/number-input.props.js +41 -65
  28. package/dist/number-input.props.mjs +35 -38
  29. package/dist/number-input.translations.d.mts +3 -8
  30. package/dist/number-input.translations.d.ts +3 -8
  31. package/dist/number-input.translations.js +8 -31
  32. package/dist/number-input.translations.mjs +4 -6
  33. package/dist/number-input.types.d.mts +302 -300
  34. package/dist/number-input.types.d.ts +302 -300
  35. package/dist/number-input.types.js +4 -18
  36. package/dist/number-input.types.mjs +1 -0
  37. package/dist/number-input.utils.d.mts +9 -12
  38. package/dist/number-input.utils.d.ts +9 -12
  39. package/dist/number-input.utils.js +28 -57
  40. package/dist/number-input.utils.mjs +20 -28
  41. package/package.json +8 -8
@@ -1,313 +1,315 @@
1
- import { NumberParser } from '@internationalized/number';
2
- import { Machine, EventObject, Service } from '@zag-js/core';
3
- import { PropTypes, RequiredBy, LocaleProperties, CommonProperties } from '@zag-js/types';
4
-
5
- interface ValueChangeDetails {
6
- value: string;
7
- valueAsNumber: number;
1
+ import { AnimationFrame } from "@zag-js/dom-query";
2
+ import { NumberParser } from "@internationalized/number";
3
+ import { EventObject, Machine, Service } from "@zag-js/core";
4
+ import { CommonProperties, LocaleProperties, PropTypes, RequiredBy } from "@zag-js/types";
5
+ export interface ValueChangeDetails {
6
+ value: string;
7
+ valueAsNumber: number;
8
8
  }
9
- interface FocusChangeDetails extends ValueChangeDetails {
10
- focused: boolean;
9
+ export interface FocusChangeDetails extends ValueChangeDetails {
10
+ focused: boolean;
11
11
  }
12
- type ValidityState = "rangeUnderflow" | "rangeOverflow";
13
- interface ValueInvalidDetails extends ValueChangeDetails {
14
- reason: ValidityState;
12
+ export type ValidityState = "rangeUnderflow" | "rangeOverflow";
13
+ export interface ValueInvalidDetails extends ValueChangeDetails {
14
+ reason: ValidityState;
15
15
  }
16
- type InputMode = "text" | "tel" | "numeric" | "decimal";
17
- interface ElementIds {
18
- root?: string | undefined;
19
- label?: string | undefined;
20
- input?: string | undefined;
21
- incrementTrigger?: string | undefined;
22
- decrementTrigger?: string | undefined;
23
- scrubber?: string | undefined;
16
+ export type InputMode = "text" | "tel" | "numeric" | "decimal";
17
+ export interface ElementIds {
18
+ root?: string | undefined;
19
+ label?: string | undefined;
20
+ input?: string | undefined;
21
+ incrementTrigger?: string | undefined;
22
+ decrementTrigger?: string | undefined;
23
+ scrubber?: string | undefined;
24
24
  }
25
- interface IntlTranslations {
26
- /**
27
- * Function that returns the human-readable value.
28
- * It is used to set the `aria-valuetext` property of the input
29
- */
30
- valueText?: ((value: string) => string) | undefined;
31
- /**
32
- * The label foe the increment button
33
- */
34
- incrementLabel?: string | undefined;
35
- /**
36
- * The label for the decrement button
37
- */
38
- decrementLabel?: string | undefined;
25
+ export interface IntlTranslations {
26
+ /**
27
+ * Function that returns the human-readable value.
28
+ * It is used to set the `aria-valuetext` property of the input
29
+ */
30
+ valueText?: ((value: string) => string) | undefined;
31
+ /**
32
+ * The label foe the increment button
33
+ */
34
+ incrementLabel?: string | undefined;
35
+ /**
36
+ * The label for the decrement button
37
+ */
38
+ decrementLabel?: string | undefined;
39
39
  }
40
- interface NumberInputProps extends LocaleProperties, CommonProperties {
41
- /**
42
- * The ids of the elements in the number input. Useful for composition.
43
- */
44
- ids?: ElementIds | undefined;
45
- /**
46
- * The name attribute of the number input. Useful for form submission.
47
- */
48
- name?: string | undefined;
49
- /**
50
- * The associate form of the input element.
51
- */
52
- form?: string | undefined;
53
- /**
54
- * Whether the number input is disabled.
55
- */
56
- disabled?: boolean | undefined;
57
- /**
58
- * Whether the number input is readonly
59
- */
60
- readOnly?: boolean | undefined;
61
- /**
62
- * Whether the number input value is invalid.
63
- */
64
- invalid?: boolean | undefined;
65
- /**
66
- * Whether the number input is required
67
- */
68
- required?: boolean | undefined;
69
- /**
70
- * The pattern used to check the <input> element's value against
71
- *
72
- * @default "-?[0-9]*(.[0-9]+)?"
73
- */
74
- pattern?: string | undefined;
75
- /**
76
- * The controlled value of the input
77
- */
78
- value?: string | undefined;
79
- /**
80
- * The initial value of the input when rendered.
81
- * Use when you don't need to control the value of the input.
82
- */
83
- defaultValue?: string | undefined;
84
- /**
85
- * The minimum value of the number input
86
- * @default Number.MIN_SAFE_INTEGER
87
- */
88
- min?: number | undefined;
89
- /**
90
- * The maximum value of the number input
91
- * @default Number.MAX_SAFE_INTEGER
92
- */
93
- max?: number | undefined;
94
- /**
95
- * The amount to increment or decrement the value by
96
- * @default 1
97
- */
98
- step?: number | undefined;
99
- /**
100
- * The amount to increment or decrement the value by when the `Shift` key is held.
101
- * @default 10 * step
102
- */
103
- largeStep?: number | undefined;
104
- /**
105
- * The amount to increment or decrement the value by when the `Alt` key is held.
106
- * @default step / 10
107
- */
108
- smallStep?: number | undefined;
109
- /**
110
- * Whether to allow mouse wheel to change the value
111
- */
112
- allowMouseWheel?: boolean | undefined;
113
- /**
114
- * Whether to allow the value overflow the min/max range
115
- * @default true
116
- */
117
- allowOverflow?: boolean | undefined;
118
- /**
119
- * Whether to clamp the value when the input loses focus (blur)
120
- * @default true
121
- */
122
- clampValueOnBlur?: boolean | undefined;
123
- /**
124
- * Whether to focus input when the value changes
125
- * @default true
126
- */
127
- focusInputOnChange?: boolean | undefined;
128
- /**
129
- * Specifies the localized strings that identifies the accessibility elements and their states
130
- */
131
- translations?: IntlTranslations | undefined;
132
- /**
133
- * The options to pass to the `Intl.NumberFormat` constructor
134
- */
135
- formatOptions?: Intl.NumberFormatOptions | undefined;
136
- /**
137
- * Hints at the type of data that might be entered by the user. It also determines
138
- * the type of keyboard shown to the user on mobile devices
139
- * @default "decimal"
140
- */
141
- inputMode?: InputMode | undefined;
142
- /**
143
- * Function invoked when the value changes
144
- */
145
- onValueChange?: ((details: ValueChangeDetails) => void) | undefined;
146
- /**
147
- * Function invoked when the value overflows or underflows the min/max range
148
- */
149
- onValueInvalid?: ((details: ValueInvalidDetails) => void) | undefined;
150
- /**
151
- * Function invoked when the number input is focused
152
- */
153
- onFocusChange?: ((details: FocusChangeDetails) => void) | undefined;
154
- /**
155
- * Function invoked when the value is committed (when the input is blurred or the Enter key is pressed)
156
- */
157
- onValueCommit?: ((details: ValueChangeDetails) => void) | undefined;
158
- /**
159
- * Whether to spin the value when the increment/decrement button is pressed
160
- * @default true
161
- */
162
- spinOnPress?: boolean | undefined;
40
+ export interface NumberInputProps extends LocaleProperties, CommonProperties {
41
+ /**
42
+ * The ids of the elements in the number input. Useful for composition.
43
+ */
44
+ ids?: ElementIds | undefined;
45
+ /**
46
+ * The name attribute of the number input. Useful for form submission.
47
+ */
48
+ name?: string | undefined;
49
+ /**
50
+ * The associate form of the input element.
51
+ */
52
+ form?: string | undefined;
53
+ /**
54
+ * Whether the number input is disabled.
55
+ */
56
+ disabled?: boolean | undefined;
57
+ /**
58
+ * Whether the number input is readonly
59
+ */
60
+ readOnly?: boolean | undefined;
61
+ /**
62
+ * Whether the number input value is invalid.
63
+ */
64
+ invalid?: boolean | undefined;
65
+ /**
66
+ * Whether the number input is required
67
+ */
68
+ required?: boolean | undefined;
69
+ /**
70
+ * The pattern used to check the <input> element's value against
71
+ *
72
+ * @default "-?[0-9]*(.[0-9]+)?"
73
+ */
74
+ pattern?: string | undefined;
75
+ /**
76
+ * The controlled value of the input
77
+ */
78
+ value?: string | undefined;
79
+ /**
80
+ * The initial value of the input when rendered.
81
+ * Use when you don't need to control the value of the input.
82
+ */
83
+ defaultValue?: string | undefined;
84
+ /**
85
+ * The minimum value of the number input
86
+ * @default Number.MIN_SAFE_INTEGER
87
+ */
88
+ min?: number | undefined;
89
+ /**
90
+ * The maximum value of the number input
91
+ * @default Number.MAX_SAFE_INTEGER
92
+ */
93
+ max?: number | undefined;
94
+ /**
95
+ * The amount to increment or decrement the value by
96
+ * @default 1
97
+ */
98
+ step?: number | undefined;
99
+ /**
100
+ * The amount to increment or decrement the value by when the `Shift` key is held.
101
+ * @default 10 * step
102
+ */
103
+ largeStep?: number | undefined;
104
+ /**
105
+ * The amount to increment or decrement the value by when the `Alt` key is held.
106
+ * @default step / 10
107
+ */
108
+ smallStep?: number | undefined;
109
+ /**
110
+ * Whether to allow mouse wheel to change the value
111
+ */
112
+ allowMouseWheel?: boolean | undefined;
113
+ /**
114
+ * Whether to allow the value overflow the min/max range
115
+ * @default true
116
+ */
117
+ allowOverflow?: boolean | undefined;
118
+ /**
119
+ * Whether to clamp the value when the input loses focus (blur)
120
+ * @default true
121
+ */
122
+ clampValueOnBlur?: boolean | undefined;
123
+ /**
124
+ * Whether to focus input when the value changes
125
+ * @default true
126
+ */
127
+ focusInputOnChange?: boolean | undefined;
128
+ /**
129
+ * Specifies the localized strings that identifies the accessibility elements and their states
130
+ */
131
+ translations?: IntlTranslations | undefined;
132
+ /**
133
+ * The options to pass to the `Intl.NumberFormat` constructor
134
+ */
135
+ formatOptions?: Intl.NumberFormatOptions | undefined;
136
+ /**
137
+ * Hints at the type of data that might be entered by the user. It also determines
138
+ * the type of keyboard shown to the user on mobile devices
139
+ * @default "decimal"
140
+ */
141
+ inputMode?: InputMode | undefined;
142
+ /**
143
+ * Function invoked when the value changes
144
+ */
145
+ onValueChange?: ((details: ValueChangeDetails) => void) | undefined;
146
+ /**
147
+ * Function invoked when the value overflows or underflows the min/max range
148
+ */
149
+ onValueInvalid?: ((details: ValueInvalidDetails) => void) | undefined;
150
+ /**
151
+ * Function invoked when the number input is focused
152
+ */
153
+ onFocusChange?: ((details: FocusChangeDetails) => void) | undefined;
154
+ /**
155
+ * Function invoked when the value is committed (when the input is blurred or the Enter key is pressed)
156
+ */
157
+ onValueCommit?: ((details: ValueChangeDetails) => void) | undefined;
158
+ /**
159
+ * Whether to spin the value when the increment/decrement button is pressed
160
+ * @default true
161
+ */
162
+ spinOnPress?: boolean | undefined;
163
163
  }
164
164
  type PropsWithDefault = "dir" | "locale" | "focusInputOnChange" | "clampValueOnBlur" | "allowOverflow" | "inputMode" | "pattern" | "step" | "largeStep" | "smallStep" | "spinOnPress" | "min" | "max";
165
165
  type ComputedContext = Readonly<{
166
- /**
167
- * The value of the input as a number
168
- */
169
- valueAsNumber: number;
170
- /**
171
- * Whether the value is at the min
172
- */
173
- isAtMin: boolean;
174
- /**
175
- * Whether the value is at the max
176
- */
177
- isAtMax: boolean;
178
- /**
179
- * Whether the value is out of the min/max range
180
- */
181
- isOutOfRange: boolean;
182
- /**
183
- * Whether the value is empty
184
- */
185
- isValueEmpty: boolean;
186
- /**
187
- * Whether the color picker is disabled
188
- */
189
- isDisabled: boolean;
190
- /**
191
- * Whether the increment button is enabled
192
- */
193
- canIncrement: boolean;
194
- /**
195
- * Whether the decrement button is enabled
196
- */
197
- canDecrement: boolean;
198
- /**
199
- * The `aria-valuetext` attribute of the input
200
- */
201
- valueText: string | undefined;
202
- /**
203
- * The formatted value of the input
204
- */
205
- formattedValue: string;
206
- /**
207
- * Whether the writing direction is RTL
208
- */
209
- isRtl: boolean;
210
- /**
211
- * The number i18n formatter
212
- */
213
- formatter: Intl.NumberFormat;
214
- /**
215
- * The number i18n parser
216
- */
217
- parser: NumberParser;
166
+ /**
167
+ * The value of the input as a number
168
+ */
169
+ valueAsNumber: number;
170
+ /**
171
+ * Whether the value is at the min
172
+ */
173
+ isAtMin: boolean;
174
+ /**
175
+ * Whether the value is at the max
176
+ */
177
+ isAtMax: boolean;
178
+ /**
179
+ * Whether the value is out of the min/max range
180
+ */
181
+ isOutOfRange: boolean;
182
+ /**
183
+ * Whether the value is empty
184
+ */
185
+ isValueEmpty: boolean;
186
+ /**
187
+ * Whether the color picker is disabled
188
+ */
189
+ isDisabled: boolean;
190
+ /**
191
+ * Whether the increment button is enabled
192
+ */
193
+ canIncrement: boolean;
194
+ /**
195
+ * Whether the decrement button is enabled
196
+ */
197
+ canDecrement: boolean;
198
+ /**
199
+ * The `aria-valuetext` attribute of the input
200
+ */
201
+ valueText: string | undefined;
202
+ /**
203
+ * The formatted value of the input
204
+ */
205
+ formattedValue: string;
206
+ /**
207
+ * Whether the writing direction is RTL
208
+ */
209
+ isRtl: boolean;
210
+ /**
211
+ * The number i18n formatter
212
+ */
213
+ formatter: Intl.NumberFormat;
214
+ /**
215
+ * The number i18n parser
216
+ */
217
+ parser: NumberParser;
218
218
  }>;
219
- type HintValue = "increment" | "decrement";
219
+ export type HintValue = "increment" | "decrement";
220
220
  interface PrivateContext {
221
- /**
222
- * The hint that determines if we're incrementing or decrementing
223
- */
224
- hint: HintValue | null;
225
- /**
226
- * The scrubber cursor position
227
- */
228
- scrubberCursorPoint: {
229
- x: number;
230
- y: number;
231
- } | null;
232
- /**
233
- * Whether the checkbox's fieldset is disabled
234
- */
235
- fieldsetDisabled: boolean;
236
- /**
237
- * The value of the input
238
- */
239
- value: string;
221
+ /**
222
+ * The hint that determines if we're incrementing or decrementing
223
+ */
224
+ hint: HintValue | null;
225
+ /**
226
+ * The scrubber cursor position
227
+ */
228
+ scrubberCursorPoint: {
229
+ x: number;
230
+ y: number;
231
+ } | null;
232
+ /**
233
+ * Whether the checkbox's fieldset is disabled
234
+ */
235
+ fieldsetDisabled: boolean;
236
+ /**
237
+ * The value of the input
238
+ */
239
+ value: string;
240
240
  }
241
- interface NumberInputSchema {
242
- state: "idle" | "focused" | "spinning" | "before:spin" | "scrubbing";
243
- tag: "focus";
244
- props: RequiredBy<NumberInputProps, PropsWithDefault>;
245
- context: PrivateContext;
246
- computed: ComputedContext;
247
- action: string;
248
- event: EventObject;
249
- guard: string;
250
- effect: string;
241
+ export interface NumberInputSchema {
242
+ state: "idle" | "focused" | "spinning" | "before:spin" | "scrubbing";
243
+ tag: "focus";
244
+ props: RequiredBy<NumberInputProps, PropsWithDefault>;
245
+ context: PrivateContext;
246
+ computed: ComputedContext;
247
+ refs: {
248
+ syncFrame: AnimationFrame;
249
+ };
250
+ action: string;
251
+ event: EventObject;
252
+ guard: string;
253
+ effect: string;
251
254
  }
252
- type NumberInputService = Service<NumberInputSchema>;
253
- type NumberInputMachine = Machine<NumberInputSchema>;
254
- interface NumberInputApi<T extends PropTypes = PropTypes> {
255
- /**
256
- * Whether the input is focused.
257
- */
258
- focused: boolean;
259
- /**
260
- * Whether the input is invalid.
261
- */
262
- invalid: boolean;
263
- /**
264
- * Whether the input value is empty.
265
- */
266
- empty: boolean;
267
- /**
268
- * The formatted value of the input.
269
- */
270
- value: string;
271
- /**
272
- * The value of the input as a number.
273
- */
274
- valueAsNumber: number;
275
- /**
276
- * Function to set the value of the input.
277
- */
278
- setValue: (value: number) => void;
279
- /**
280
- * Function to clear the value of the input.
281
- */
282
- clearValue: VoidFunction;
283
- /**
284
- * Function to increment the value of the input by the step.
285
- */
286
- increment: VoidFunction;
287
- /**
288
- * Function to decrement the value of the input by the step.
289
- */
290
- decrement: VoidFunction;
291
- /**
292
- * Function to set the value of the input to the max.
293
- */
294
- setToMax: VoidFunction;
295
- /**
296
- * Function to set the value of the input to the min.
297
- */
298
- setToMin: VoidFunction;
299
- /**
300
- * Function to focus the input.
301
- */
302
- focus: VoidFunction;
303
- getRootProps: () => T["element"];
304
- getLabelProps: () => T["label"];
305
- getControlProps: () => T["element"];
306
- getValueTextProps: () => T["element"];
307
- getInputProps: () => T["input"];
308
- getDecrementTriggerProps: () => T["button"];
309
- getIncrementTriggerProps: () => T["button"];
310
- getScrubberProps: () => T["element"];
255
+ export type NumberInputService = Service<NumberInputSchema>;
256
+ export type NumberInputMachine = Machine<NumberInputSchema>;
257
+ export interface NumberInputApi<T extends PropTypes = PropTypes> {
258
+ /**
259
+ * Whether the input is focused.
260
+ */
261
+ focused: boolean;
262
+ /**
263
+ * Whether the input is invalid.
264
+ */
265
+ invalid: boolean;
266
+ /**
267
+ * Whether the input value is empty.
268
+ */
269
+ empty: boolean;
270
+ /**
271
+ * The formatted value of the input.
272
+ */
273
+ value: string;
274
+ /**
275
+ * The value of the input as a number.
276
+ */
277
+ valueAsNumber: number;
278
+ /**
279
+ * Function to set the value of the input.
280
+ */
281
+ setValue: (value: number) => void;
282
+ /**
283
+ * Function to clear the value of the input.
284
+ */
285
+ clearValue: VoidFunction;
286
+ /**
287
+ * Function to increment the value of the input by the step.
288
+ */
289
+ increment: VoidFunction;
290
+ /**
291
+ * Function to decrement the value of the input by the step.
292
+ */
293
+ decrement: VoidFunction;
294
+ /**
295
+ * Function to set the value of the input to the max.
296
+ */
297
+ setToMax: VoidFunction;
298
+ /**
299
+ * Function to set the value of the input to the min.
300
+ */
301
+ setToMin: VoidFunction;
302
+ /**
303
+ * Function to focus the input.
304
+ */
305
+ focus: VoidFunction;
306
+ getRootProps: () => T["element"];
307
+ getLabelProps: () => T["label"];
308
+ getControlProps: () => T["element"];
309
+ getValueTextProps: () => T["element"];
310
+ getInputProps: () => T["input"];
311
+ getDecrementTriggerProps: () => T["button"];
312
+ getIncrementTriggerProps: () => T["button"];
313
+ getScrubberProps: () => T["element"];
311
314
  }
312
-
313
- export type { ElementIds, FocusChangeDetails, HintValue, InputMode, IntlTranslations, NumberInputApi, NumberInputMachine, NumberInputProps, NumberInputSchema, NumberInputService, ValidityState, ValueChangeDetails, ValueInvalidDetails };
315
+ export {};
@@ -1,18 +1,4 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
-
16
- // src/number-input.types.ts
17
- var number_input_types_exports = {};
18
- module.exports = __toCommonJS(number_input_types_exports);
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
@@ -0,0 +1 @@
1
+ export {};