@zag-js/number-input
Advanced tools
@@ -184,3 +184,7 @@ "use strict"; | ||
| if ((0, import_dom_query.isComposingEvent)(event)) return; | ||
| const step = (0, import_dom_query.getEventStep)(event) * prop("step"); | ||
| const step = (0, import_dom_query.getEventStepValue)(event, { | ||
| step: prop("step"), | ||
| largeStep: prop("largeStep"), | ||
| smallStep: prop("smallStep") | ||
| }); | ||
| const keyMap = { | ||
@@ -187,0 +191,0 @@ ArrowUp() { |
@@ -6,3 +6,3 @@ // src/number-input.connect.ts | ||
| getEventPoint, | ||
| getEventStep, | ||
| getEventStepValue, | ||
| getWindow, | ||
@@ -162,3 +162,7 @@ isComposingEvent, | ||
| if (isComposingEvent(event)) return; | ||
| const step = getEventStep(event) * prop("step"); | ||
| const step = getEventStepValue(event, { | ||
| step: prop("step"), | ||
| largeStep: prop("largeStep"), | ||
| smallStep: prop("smallStep") | ||
| }); | ||
| const keyMap = { | ||
@@ -165,0 +169,0 @@ ArrowUp() { |
@@ -61,2 +61,4 @@ "use strict"; | ||
| ...props, | ||
| largeStep: props.largeStep ?? 10 * step, | ||
| smallStep: props.smallStep ?? step / 10, | ||
| translations: { | ||
@@ -377,3 +379,3 @@ incrementLabel: "increment value", | ||
| setRawValue({ context, event, prop, computed }) { | ||
| let nextValue = (0, import_number_input.parseValue)(event.value, { computed, prop }); | ||
| let nextValue = typeof event.value === "number" ? event.value : (0, import_number_input.parseValue)(event.value, { computed, prop }); | ||
| if (!prop("allowOverflow")) nextValue = (0, import_utils.clampValue)(nextValue, prop("min"), prop("max")); | ||
@@ -380,0 +382,0 @@ context.set("value", (0, import_number_input.formatValue)(nextValue, { computed, prop })); |
@@ -43,2 +43,4 @@ // src/number-input.machine.ts | ||
| ...props, | ||
| largeStep: props.largeStep ?? 10 * step, | ||
| smallStep: props.smallStep ?? step / 10, | ||
| translations: { | ||
@@ -359,3 +361,3 @@ incrementLabel: "increment value", | ||
| setRawValue({ context, event, prop, computed }) { | ||
| let nextValue = parseValue(event.value, { computed, prop }); | ||
| let nextValue = typeof event.value === "number" ? event.value : parseValue(event.value, { computed, prop }); | ||
| if (!prop("allowOverflow")) nextValue = clampValue(nextValue, prop("min"), prop("max")); | ||
@@ -362,0 +364,0 @@ context.set("value", formatValue(nextValue, { computed, prop })); |
@@ -43,2 +43,3 @@ "use strict"; | ||
| "invalid", | ||
| "largeStep", | ||
| "locale", | ||
@@ -55,2 +56,3 @@ "max", | ||
| "readOnly", | ||
| "smallStep", | ||
| "spinOnPress", | ||
@@ -57,0 +59,0 @@ "step", |
@@ -18,2 +18,3 @@ // src/number-input.props.ts | ||
| "invalid", | ||
| "largeStep", | ||
| "locale", | ||
@@ -30,2 +31,3 @@ "max", | ||
| "readOnly", | ||
| "smallStep", | ||
| "spinOnPress", | ||
@@ -32,0 +34,0 @@ "step", |
@@ -100,2 +100,12 @@ import { NumberParser } from '@internationalized/number'; | ||
| /** | ||
| * The amount to increment or decrement the value by when the `Shift` key is held. | ||
| * @default 10 * step | ||
| */ | ||
| largeStep?: number | undefined; | ||
| /** | ||
| * The amount to increment or decrement the value by when the `Alt` key is held. | ||
| * @default step / 10 | ||
| */ | ||
| smallStep?: number | undefined; | ||
| /** | ||
| * Whether to allow mouse wheel to change the value | ||
@@ -155,3 +165,3 @@ */ | ||
| } | ||
| type PropsWithDefault = "dir" | "locale" | "focusInputOnChange" | "clampValueOnBlur" | "allowOverflow" | "inputMode" | "pattern" | "translations" | "step" | "spinOnPress" | "min" | "max" | "step" | "translations"; | ||
| type PropsWithDefault = "dir" | "locale" | "focusInputOnChange" | "clampValueOnBlur" | "allowOverflow" | "inputMode" | "pattern" | "translations" | "step" | "largeStep" | "smallStep" | "spinOnPress" | "min" | "max"; | ||
| type ComputedContext = Readonly<{ | ||
@@ -158,0 +168,0 @@ /** |
@@ -100,2 +100,12 @@ import { NumberParser } from '@internationalized/number'; | ||
| /** | ||
| * The amount to increment or decrement the value by when the `Shift` key is held. | ||
| * @default 10 * step | ||
| */ | ||
| largeStep?: number | undefined; | ||
| /** | ||
| * The amount to increment or decrement the value by when the `Alt` key is held. | ||
| * @default step / 10 | ||
| */ | ||
| smallStep?: number | undefined; | ||
| /** | ||
| * Whether to allow mouse wheel to change the value | ||
@@ -155,3 +165,3 @@ */ | ||
| } | ||
| type PropsWithDefault = "dir" | "locale" | "focusInputOnChange" | "clampValueOnBlur" | "allowOverflow" | "inputMode" | "pattern" | "translations" | "step" | "spinOnPress" | "min" | "max" | "step" | "translations"; | ||
| type PropsWithDefault = "dir" | "locale" | "focusInputOnChange" | "clampValueOnBlur" | "allowOverflow" | "inputMode" | "pattern" | "translations" | "step" | "largeStep" | "smallStep" | "spinOnPress" | "min" | "max"; | ||
| type ComputedContext = Readonly<{ | ||
@@ -158,0 +168,0 @@ /** |
+11
-8
| { | ||
| "name": "@zag-js/number-input", | ||
| "version": "1.41.2", | ||
| "version": "1.42.0", | ||
| "description": "Core logic for the number-input widget implemented as a state machine", | ||
@@ -17,3 +17,6 @@ "keywords": [ | ||
| "license": "MIT", | ||
| "repository": "https://github.com/chakra-ui/zag/tree/main/packages/number-input", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/chakra-ui/zag/tree/main/packages/number-input" | ||
| }, | ||
| "sideEffects": false, | ||
@@ -30,8 +33,8 @@ "files": [ | ||
| "dependencies": { | ||
| "@internationalized/number": "3.6.6", | ||
| "@zag-js/anatomy": "1.41.2", | ||
| "@zag-js/core": "1.41.2", | ||
| "@zag-js/dom-query": "1.41.2", | ||
| "@zag-js/types": "1.41.2", | ||
| "@zag-js/utils": "1.41.2" | ||
| "@internationalized/number": "3.6.7", | ||
| "@zag-js/anatomy": "1.42.0", | ||
| "@zag-js/core": "1.42.0", | ||
| "@zag-js/dom-query": "1.42.0", | ||
| "@zag-js/types": "1.42.0", | ||
| "@zag-js/utils": "1.42.0" | ||
| }, | ||
@@ -38,0 +41,0 @@ "devDependencies": { |
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
113087
1.15%2682
0.98%0
-100%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated
Updated
Updated
Updated