@zag-js/number-input 0.10.5 → 0.11.1
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/{number-input.types.d.ts → index.d.mts} +78 -8
- package/dist/index.d.ts +285 -4
- package/dist/index.js +795 -8
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +771 -3
- package/dist/index.mjs.map +1 -0
- package/package.json +11 -11
- package/dist/number-input.anatomy.d.ts +0 -3
- package/dist/number-input.anatomy.js +0 -19
- package/dist/number-input.anatomy.mjs +0 -14
- package/dist/number-input.connect.d.ts +0 -63
- package/dist/number-input.connect.js +0 -238
- package/dist/number-input.connect.mjs +0 -234
- package/dist/number-input.dom.d.ts +0 -45
- package/dist/number-input.dom.js +0 -103
- package/dist/number-input.dom.mjs +0 -99
- package/dist/number-input.machine.d.ts +0 -3
- package/dist/number-input.machine.js +0 -390
- package/dist/number-input.machine.mjs +0 -386
- package/dist/number-input.utils.d.ts +0 -13
- package/dist/number-input.utils.js +0 -45
- package/dist/number-input.utils.mjs +0 -41
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import * as _zag_js_anatomy from '@zag-js/anatomy';
|
|
2
|
+
import { RequiredBy, DirectionProperty, CommonProperties, Context, PropTypes, NormalizeProps } from '@zag-js/types';
|
|
3
|
+
import * as _zag_js_core from '@zag-js/core';
|
|
4
|
+
import { StateMachine } from '@zag-js/core';
|
|
5
|
+
|
|
6
|
+
declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "label" | "input" | "control" | "incrementTrigger" | "decrementTrigger" | "scrubber">;
|
|
7
|
+
|
|
3
8
|
type ValidityState = "rangeUnderflow" | "rangeOverflow";
|
|
4
9
|
type ElementIds = Partial<{
|
|
5
10
|
root: string;
|
|
@@ -151,7 +156,7 @@ type PublicContext = DirectionProperty & CommonProperties & {
|
|
|
151
156
|
*/
|
|
152
157
|
spinOnPress?: boolean;
|
|
153
158
|
};
|
|
154
|
-
|
|
159
|
+
type UserDefinedContext = RequiredBy<PublicContext, "id">;
|
|
155
160
|
type ComputedContext = Readonly<{
|
|
156
161
|
/**
|
|
157
162
|
* @computed
|
|
@@ -205,11 +210,76 @@ type ComputedContext = Readonly<{
|
|
|
205
210
|
isRtl: boolean;
|
|
206
211
|
}>;
|
|
207
212
|
type PrivateContext = Context<{}>;
|
|
208
|
-
|
|
209
|
-
|
|
213
|
+
type MachineContext = PublicContext & PrivateContext & ComputedContext;
|
|
214
|
+
type MachineState = {
|
|
210
215
|
value: "idle" | "focused" | "spinning" | "before:spin" | "scrubbing";
|
|
211
216
|
tags: "focus";
|
|
212
217
|
};
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
218
|
+
type State = StateMachine.State<MachineContext, MachineState>;
|
|
219
|
+
type Send = StateMachine.Send<StateMachine.AnyEventObject>;
|
|
220
|
+
|
|
221
|
+
declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
|
|
222
|
+
/**
|
|
223
|
+
* Whether the input is focused.
|
|
224
|
+
*/
|
|
225
|
+
isFocused: boolean;
|
|
226
|
+
/**
|
|
227
|
+
* Whether the input is invalid.
|
|
228
|
+
*/
|
|
229
|
+
isInvalid: boolean;
|
|
230
|
+
/**
|
|
231
|
+
* Whether the input value is empty.
|
|
232
|
+
*/
|
|
233
|
+
isValueEmpty: boolean;
|
|
234
|
+
/**
|
|
235
|
+
* The formatted value of the input.
|
|
236
|
+
*/
|
|
237
|
+
value: string;
|
|
238
|
+
/**
|
|
239
|
+
* The value of the input as a number.
|
|
240
|
+
*/
|
|
241
|
+
valueAsNumber: number;
|
|
242
|
+
/**
|
|
243
|
+
* Function to set the value of the input.
|
|
244
|
+
*/
|
|
245
|
+
setValue(value: string | number): void;
|
|
246
|
+
/**
|
|
247
|
+
* Function to clear the value of the input.
|
|
248
|
+
*/
|
|
249
|
+
clearValue(): void;
|
|
250
|
+
/**
|
|
251
|
+
* Function to increment the value of the input by the step.
|
|
252
|
+
*/
|
|
253
|
+
increment(): void;
|
|
254
|
+
/**
|
|
255
|
+
* Function to decrement the value of the input by the step.
|
|
256
|
+
*/
|
|
257
|
+
decrement(): void;
|
|
258
|
+
/**
|
|
259
|
+
* Function to set the value of the input to the max.
|
|
260
|
+
*/
|
|
261
|
+
setToMax(): void;
|
|
262
|
+
/**
|
|
263
|
+
* Function to set the value of the input to the min.
|
|
264
|
+
*/
|
|
265
|
+
setToMin(): void;
|
|
266
|
+
/**
|
|
267
|
+
* Function to focus the input.
|
|
268
|
+
*/
|
|
269
|
+
focus(): void;
|
|
270
|
+
/**
|
|
271
|
+
* Function to blur the input.
|
|
272
|
+
*/
|
|
273
|
+
blur(): void;
|
|
274
|
+
rootProps: T["element"];
|
|
275
|
+
labelProps: T["label"];
|
|
276
|
+
controlProps: T["element"];
|
|
277
|
+
inputProps: T["input"];
|
|
278
|
+
decrementTriggerProps: T["button"];
|
|
279
|
+
incrementTriggerProps: T["button"];
|
|
280
|
+
scrubberProps: T["element"];
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
|
|
284
|
+
|
|
285
|
+
export { UserDefinedContext as Context, anatomy, connect, machine };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,285 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import * as _zag_js_anatomy from '@zag-js/anatomy';
|
|
2
|
+
import { RequiredBy, DirectionProperty, CommonProperties, Context, PropTypes, NormalizeProps } from '@zag-js/types';
|
|
3
|
+
import * as _zag_js_core from '@zag-js/core';
|
|
4
|
+
import { StateMachine } from '@zag-js/core';
|
|
5
|
+
|
|
6
|
+
declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "label" | "input" | "control" | "incrementTrigger" | "decrementTrigger" | "scrubber">;
|
|
7
|
+
|
|
8
|
+
type ValidityState = "rangeUnderflow" | "rangeOverflow";
|
|
9
|
+
type ElementIds = Partial<{
|
|
10
|
+
root: string;
|
|
11
|
+
label: string;
|
|
12
|
+
input: string;
|
|
13
|
+
incrementTrigger: string;
|
|
14
|
+
decrementTrigger: string;
|
|
15
|
+
scrubber: string;
|
|
16
|
+
}>;
|
|
17
|
+
type IntlTranslations = {
|
|
18
|
+
/**
|
|
19
|
+
* Function that returns the human-readable value.
|
|
20
|
+
* It is used to set the `aria-valuetext` property of the input
|
|
21
|
+
*/
|
|
22
|
+
valueText?: (value: string) => string;
|
|
23
|
+
/**
|
|
24
|
+
* The label foe the increment button
|
|
25
|
+
*/
|
|
26
|
+
incrementLabel: string;
|
|
27
|
+
/**
|
|
28
|
+
* The label for the decrement button
|
|
29
|
+
*/
|
|
30
|
+
decrementLabel: string;
|
|
31
|
+
};
|
|
32
|
+
type Value = {
|
|
33
|
+
value: string;
|
|
34
|
+
valueAsNumber: number;
|
|
35
|
+
};
|
|
36
|
+
type PublicContext = DirectionProperty & CommonProperties & {
|
|
37
|
+
/**
|
|
38
|
+
* The ids of the elements in the number input. Useful for composition.
|
|
39
|
+
*/
|
|
40
|
+
ids?: ElementIds;
|
|
41
|
+
/**
|
|
42
|
+
* The name attribute of the number input. Useful for form submission.
|
|
43
|
+
*/
|
|
44
|
+
name?: string;
|
|
45
|
+
/**
|
|
46
|
+
* The associate form of the input element.
|
|
47
|
+
*/
|
|
48
|
+
form?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Whether the number input is disabled.
|
|
51
|
+
*/
|
|
52
|
+
disabled?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Whether the number input is readonly
|
|
55
|
+
*/
|
|
56
|
+
readOnly?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Whether the number input value is invalid.
|
|
59
|
+
*/
|
|
60
|
+
invalid?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* The pattern used to check the <input> element's value against
|
|
63
|
+
*
|
|
64
|
+
* @default
|
|
65
|
+
* "[0-9]*(.[0-9]+)?"
|
|
66
|
+
*/
|
|
67
|
+
pattern: string;
|
|
68
|
+
/**
|
|
69
|
+
* The value of the input
|
|
70
|
+
*/
|
|
71
|
+
value: string;
|
|
72
|
+
/**
|
|
73
|
+
* The minimum value of the number input
|
|
74
|
+
*/
|
|
75
|
+
min: number;
|
|
76
|
+
/**
|
|
77
|
+
* The maximum value of the number input
|
|
78
|
+
*/
|
|
79
|
+
max: number;
|
|
80
|
+
/**
|
|
81
|
+
* The amount to increment or decrement the value by
|
|
82
|
+
*/
|
|
83
|
+
step: number;
|
|
84
|
+
/**
|
|
85
|
+
* Whether to allow mouse wheel to change the value
|
|
86
|
+
*/
|
|
87
|
+
allowMouseWheel?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Whether to allow the value overflow the min/max range
|
|
90
|
+
* @default true
|
|
91
|
+
*/
|
|
92
|
+
allowOverflow: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Whether the pressed key should be allowed in the input.
|
|
95
|
+
* The default behavior is to allow DOM floating point characters defined by /^[Ee0-9+\-.]$/
|
|
96
|
+
*/
|
|
97
|
+
validateCharacter?: (char: string) => boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Whether to clamp the value when the input loses focus (blur)
|
|
100
|
+
* @default true
|
|
101
|
+
*/
|
|
102
|
+
clampValueOnBlur: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Whether to focus input when the value changes
|
|
105
|
+
* @default true
|
|
106
|
+
*/
|
|
107
|
+
focusInputOnChange: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Specifies the localized strings that identifies the accessibility elements and their states
|
|
110
|
+
*/
|
|
111
|
+
translations: IntlTranslations;
|
|
112
|
+
/**
|
|
113
|
+
* If using a custom display format, this converts the custom format to a format `parseFloat` understands.
|
|
114
|
+
*/
|
|
115
|
+
parse?: (value: string) => string;
|
|
116
|
+
/**
|
|
117
|
+
* If using a custom display format, this converts the default format to the custom format.
|
|
118
|
+
*/
|
|
119
|
+
format?: (value: string) => string | number;
|
|
120
|
+
/**
|
|
121
|
+
* Hints at the type of data that might be entered by the user. It also determines
|
|
122
|
+
* the type of keyboard shown to the user on mobile devices
|
|
123
|
+
* @default "decimal"
|
|
124
|
+
*/
|
|
125
|
+
inputMode: "text" | "tel" | "numeric" | "decimal";
|
|
126
|
+
/**
|
|
127
|
+
* Function invoked when the value changes
|
|
128
|
+
*/
|
|
129
|
+
onChange?: (details: Value) => void;
|
|
130
|
+
/**
|
|
131
|
+
* Function invoked when the value overflows or underflows the min/max range
|
|
132
|
+
*/
|
|
133
|
+
onInvalid?: (details: Value & {
|
|
134
|
+
reason: ValidityState;
|
|
135
|
+
}) => void;
|
|
136
|
+
/**
|
|
137
|
+
* Function invoked when the number input is focused
|
|
138
|
+
*/
|
|
139
|
+
onFocus?: (details: Value & {
|
|
140
|
+
srcElement: HTMLElement | null;
|
|
141
|
+
}) => void;
|
|
142
|
+
/**
|
|
143
|
+
* The value of the input when it is blurred
|
|
144
|
+
*/
|
|
145
|
+
onBlur?: (details: Value) => void;
|
|
146
|
+
/**
|
|
147
|
+
* The minimum number of fraction digits to use. Possible values are from 0 to 20
|
|
148
|
+
*/
|
|
149
|
+
minFractionDigits?: number;
|
|
150
|
+
/**
|
|
151
|
+
* The maximum number of fraction digits to use. Possible values are from 0 to 20;
|
|
152
|
+
*/
|
|
153
|
+
maxFractionDigits?: number;
|
|
154
|
+
/**
|
|
155
|
+
* Whether to spin the value when the increment/decrement button is pressed
|
|
156
|
+
*/
|
|
157
|
+
spinOnPress?: boolean;
|
|
158
|
+
};
|
|
159
|
+
type UserDefinedContext = RequiredBy<PublicContext, "id">;
|
|
160
|
+
type ComputedContext = Readonly<{
|
|
161
|
+
/**
|
|
162
|
+
* @computed
|
|
163
|
+
* The value of the input as a number
|
|
164
|
+
*/
|
|
165
|
+
valueAsNumber: number;
|
|
166
|
+
/**
|
|
167
|
+
* @computed
|
|
168
|
+
* Whether the value is at the min
|
|
169
|
+
*/
|
|
170
|
+
isAtMin: boolean;
|
|
171
|
+
/**
|
|
172
|
+
* @computed
|
|
173
|
+
* Whether the value is at the max
|
|
174
|
+
*/
|
|
175
|
+
isAtMax: boolean;
|
|
176
|
+
/**
|
|
177
|
+
* @computed
|
|
178
|
+
* Whether the value is out of the min/max range
|
|
179
|
+
*/
|
|
180
|
+
isOutOfRange: boolean;
|
|
181
|
+
/**
|
|
182
|
+
* @computed
|
|
183
|
+
* Whether the value is empty
|
|
184
|
+
*/
|
|
185
|
+
isValueEmpty: boolean;
|
|
186
|
+
/**
|
|
187
|
+
* @computed
|
|
188
|
+
* Whether the increment button is enabled
|
|
189
|
+
*/
|
|
190
|
+
canIncrement: boolean;
|
|
191
|
+
/**
|
|
192
|
+
* @computed
|
|
193
|
+
* Whether the decrement button is enabled
|
|
194
|
+
*/
|
|
195
|
+
canDecrement: boolean;
|
|
196
|
+
/**
|
|
197
|
+
* @computed
|
|
198
|
+
* The `aria-valuetext` attribute of the input
|
|
199
|
+
*/
|
|
200
|
+
valueText: string | undefined;
|
|
201
|
+
/**
|
|
202
|
+
* @computed
|
|
203
|
+
* The formatted value of the input
|
|
204
|
+
*/
|
|
205
|
+
formattedValue: string;
|
|
206
|
+
/**
|
|
207
|
+
* @computed
|
|
208
|
+
* Whether the writing direction is RTL
|
|
209
|
+
*/
|
|
210
|
+
isRtl: boolean;
|
|
211
|
+
}>;
|
|
212
|
+
type PrivateContext = Context<{}>;
|
|
213
|
+
type MachineContext = PublicContext & PrivateContext & ComputedContext;
|
|
214
|
+
type MachineState = {
|
|
215
|
+
value: "idle" | "focused" | "spinning" | "before:spin" | "scrubbing";
|
|
216
|
+
tags: "focus";
|
|
217
|
+
};
|
|
218
|
+
type State = StateMachine.State<MachineContext, MachineState>;
|
|
219
|
+
type Send = StateMachine.Send<StateMachine.AnyEventObject>;
|
|
220
|
+
|
|
221
|
+
declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
|
|
222
|
+
/**
|
|
223
|
+
* Whether the input is focused.
|
|
224
|
+
*/
|
|
225
|
+
isFocused: boolean;
|
|
226
|
+
/**
|
|
227
|
+
* Whether the input is invalid.
|
|
228
|
+
*/
|
|
229
|
+
isInvalid: boolean;
|
|
230
|
+
/**
|
|
231
|
+
* Whether the input value is empty.
|
|
232
|
+
*/
|
|
233
|
+
isValueEmpty: boolean;
|
|
234
|
+
/**
|
|
235
|
+
* The formatted value of the input.
|
|
236
|
+
*/
|
|
237
|
+
value: string;
|
|
238
|
+
/**
|
|
239
|
+
* The value of the input as a number.
|
|
240
|
+
*/
|
|
241
|
+
valueAsNumber: number;
|
|
242
|
+
/**
|
|
243
|
+
* Function to set the value of the input.
|
|
244
|
+
*/
|
|
245
|
+
setValue(value: string | number): void;
|
|
246
|
+
/**
|
|
247
|
+
* Function to clear the value of the input.
|
|
248
|
+
*/
|
|
249
|
+
clearValue(): void;
|
|
250
|
+
/**
|
|
251
|
+
* Function to increment the value of the input by the step.
|
|
252
|
+
*/
|
|
253
|
+
increment(): void;
|
|
254
|
+
/**
|
|
255
|
+
* Function to decrement the value of the input by the step.
|
|
256
|
+
*/
|
|
257
|
+
decrement(): void;
|
|
258
|
+
/**
|
|
259
|
+
* Function to set the value of the input to the max.
|
|
260
|
+
*/
|
|
261
|
+
setToMax(): void;
|
|
262
|
+
/**
|
|
263
|
+
* Function to set the value of the input to the min.
|
|
264
|
+
*/
|
|
265
|
+
setToMin(): void;
|
|
266
|
+
/**
|
|
267
|
+
* Function to focus the input.
|
|
268
|
+
*/
|
|
269
|
+
focus(): void;
|
|
270
|
+
/**
|
|
271
|
+
* Function to blur the input.
|
|
272
|
+
*/
|
|
273
|
+
blur(): void;
|
|
274
|
+
rootProps: T["element"];
|
|
275
|
+
labelProps: T["label"];
|
|
276
|
+
controlProps: T["element"];
|
|
277
|
+
inputProps: T["input"];
|
|
278
|
+
decrementTriggerProps: T["button"];
|
|
279
|
+
incrementTriggerProps: T["button"];
|
|
280
|
+
scrubberProps: T["element"];
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
|
|
284
|
+
|
|
285
|
+
export { UserDefinedContext as Context, anatomy, connect, machine };
|