@react-aria/numberfield 3.11.1 → 3.11.2

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 (50) hide show
  1. package/dist/ar-AE.mjs +1 -1
  2. package/dist/bg-BG.mjs +1 -1
  3. package/dist/cs-CZ.mjs +1 -1
  4. package/dist/da-DK.mjs +1 -1
  5. package/dist/de-DE.mjs +1 -1
  6. package/dist/el-GR.mjs +1 -1
  7. package/dist/en-US.mjs +1 -1
  8. package/dist/es-ES.mjs +1 -1
  9. package/dist/et-EE.mjs +1 -1
  10. package/dist/fi-FI.mjs +1 -1
  11. package/dist/fr-FR.mjs +1 -1
  12. package/dist/he-IL.mjs +1 -1
  13. package/dist/hr-HR.mjs +1 -1
  14. package/dist/hu-HU.mjs +1 -1
  15. package/dist/import.mjs +1 -345
  16. package/dist/intlStrings.main.js +108 -0
  17. package/dist/intlStrings.main.js.map +1 -0
  18. package/dist/intlStrings.mjs +110 -0
  19. package/dist/intlStrings.module.js +110 -0
  20. package/dist/intlStrings.module.js.map +1 -0
  21. package/dist/it-IT.mjs +1 -1
  22. package/dist/ja-JP.mjs +1 -1
  23. package/dist/ko-KR.mjs +1 -1
  24. package/dist/lt-LT.mjs +1 -1
  25. package/dist/lv-LV.mjs +1 -1
  26. package/dist/main.js +2 -346
  27. package/dist/main.js.map +1 -1
  28. package/dist/module.js +1 -345
  29. package/dist/module.js.map +1 -1
  30. package/dist/nb-NO.mjs +1 -1
  31. package/dist/nl-NL.mjs +1 -1
  32. package/dist/pl-PL.mjs +1 -1
  33. package/dist/pt-BR.mjs +1 -1
  34. package/dist/pt-PT.mjs +1 -1
  35. package/dist/ro-RO.mjs +1 -1
  36. package/dist/ru-RU.mjs +1 -1
  37. package/dist/sk-SK.mjs +1 -1
  38. package/dist/sl-SI.mjs +1 -1
  39. package/dist/sr-SP.mjs +1 -1
  40. package/dist/sv-SE.mjs +1 -1
  41. package/dist/tr-TR.mjs +1 -1
  42. package/dist/uk-UA.mjs +1 -1
  43. package/dist/useNumberField.main.js +249 -0
  44. package/dist/useNumberField.main.js.map +1 -0
  45. package/dist/useNumberField.mjs +244 -0
  46. package/dist/useNumberField.module.js +244 -0
  47. package/dist/useNumberField.module.js.map +1 -0
  48. package/dist/zh-CN.mjs +1 -1
  49. package/dist/zh-TW.mjs +1 -1
  50. package/package.json +12 -12
@@ -0,0 +1,244 @@
1
+ import $jvaNJ$intlStringsmodulejs from "./intlStrings.module.js";
2
+ import {useId as $jvaNJ$useId, isIPhone as $jvaNJ$isIPhone, isAndroid as $jvaNJ$isAndroid, filterDOMProps as $jvaNJ$filterDOMProps, chain as $jvaNJ$chain, useFormReset as $jvaNJ$useFormReset, mergeProps as $jvaNJ$mergeProps, isIOS as $jvaNJ$isIOS} from "@react-aria/utils";
3
+ import {useMemo as $jvaNJ$useMemo, useState as $jvaNJ$useState, useCallback as $jvaNJ$useCallback} from "react";
4
+ import {privateValidationStateProp as $jvaNJ$privateValidationStateProp} from "@react-stately/form";
5
+ import {useFocus as $jvaNJ$useFocus, useFocusWithin as $jvaNJ$useFocusWithin, useScrollWheel as $jvaNJ$useScrollWheel} from "@react-aria/interactions";
6
+ import {useFormattedTextField as $jvaNJ$useFormattedTextField} from "@react-aria/textfield";
7
+ import {useLocalizedStringFormatter as $jvaNJ$useLocalizedStringFormatter, useNumberFormatter as $jvaNJ$useNumberFormatter} from "@react-aria/i18n";
8
+ import {useSpinButton as $jvaNJ$useSpinButton} from "@react-aria/spinbutton";
9
+
10
+
11
+ function $parcel$interopDefault(a) {
12
+ return a && a.__esModule ? a.default : a;
13
+ }
14
+ /*
15
+ * Copyright 2020 Adobe. All rights reserved.
16
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
17
+ * you may not use this file except in compliance with the License. You may obtain a copy
18
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
19
+ *
20
+ * Unless required by applicable law or agreed to in writing, software distributed under
21
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
22
+ * OF ANY KIND, either express or implied. See the License for the specific language
23
+ * governing permissions and limitations under the License.
24
+ */
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+ function $81397a9303501bda$export$23f548e970bdf099(props, state, inputRef) {
33
+ let { id: id, decrementAriaLabel: decrementAriaLabel, incrementAriaLabel: incrementAriaLabel, isDisabled: isDisabled, isReadOnly: isReadOnly, isRequired: isRequired, minValue: minValue, maxValue: maxValue, autoFocus: autoFocus, label: label, formatOptions: formatOptions, onBlur: onBlur = ()=>{}, onFocus: onFocus, onFocusChange: onFocusChange, onKeyDown: onKeyDown, onKeyUp: onKeyUp, description: description, errorMessage: errorMessage, isWheelDisabled: isWheelDisabled, ...otherProps } = props;
34
+ let { increment: increment, incrementToMax: incrementToMax, decrement: decrement, decrementToMin: decrementToMin, numberValue: numberValue, inputValue: inputValue, commit: commit, commitValidation: commitValidation } = state;
35
+ const stringFormatter = (0, $jvaNJ$useLocalizedStringFormatter)((0, ($parcel$interopDefault($jvaNJ$intlStringsmodulejs))), "@react-aria/numberfield");
36
+ let inputId = (0, $jvaNJ$useId)(id);
37
+ let { focusProps: focusProps } = (0, $jvaNJ$useFocus)({
38
+ onBlur () {
39
+ // Set input value to normalized valid value
40
+ commit();
41
+ }
42
+ });
43
+ let numberFormatter = (0, $jvaNJ$useNumberFormatter)(formatOptions);
44
+ let intlOptions = (0, $jvaNJ$useMemo)(()=>numberFormatter.resolvedOptions(), [
45
+ numberFormatter
46
+ ]);
47
+ // Replace negative textValue formatted using currencySign: 'accounting'
48
+ // with a textValue that can be announced using a minus sign.
49
+ let textValueFormatter = (0, $jvaNJ$useNumberFormatter)({
50
+ ...formatOptions,
51
+ currencySign: undefined
52
+ });
53
+ let textValue = (0, $jvaNJ$useMemo)(()=>isNaN(numberValue) ? "" : textValueFormatter.format(numberValue), [
54
+ textValueFormatter,
55
+ numberValue
56
+ ]);
57
+ let { spinButtonProps: spinButtonProps, incrementButtonProps: incButtonProps, decrementButtonProps: decButtonProps } = (0, $jvaNJ$useSpinButton)({
58
+ isDisabled: isDisabled,
59
+ isReadOnly: isReadOnly,
60
+ isRequired: isRequired,
61
+ maxValue: maxValue,
62
+ minValue: minValue,
63
+ onIncrement: increment,
64
+ onIncrementToMax: incrementToMax,
65
+ onDecrement: decrement,
66
+ onDecrementToMin: decrementToMin,
67
+ value: numberValue,
68
+ textValue: textValue
69
+ });
70
+ let [focusWithin, setFocusWithin] = (0, $jvaNJ$useState)(false);
71
+ let { focusWithinProps: focusWithinProps } = (0, $jvaNJ$useFocusWithin)({
72
+ isDisabled: isDisabled,
73
+ onFocusWithinChange: setFocusWithin
74
+ });
75
+ let onWheel = (0, $jvaNJ$useCallback)((e)=>{
76
+ // if on a trackpad, users can scroll in both X and Y at once, check the magnitude of the change
77
+ // if it's mostly in the X direction, then just return, the user probably doesn't mean to inc/dec
78
+ // this isn't perfect, events come in fast with small deltas and a part of the scroll may give a false indication
79
+ // especially if the user is scrolling near 45deg
80
+ if (Math.abs(e.deltaY) <= Math.abs(e.deltaX)) return;
81
+ if (e.deltaY > 0) increment();
82
+ else if (e.deltaY < 0) decrement();
83
+ }, [
84
+ decrement,
85
+ increment
86
+ ]);
87
+ // If the input isn't supposed to receive input, disable scrolling.
88
+ let scrollingDisabled = isWheelDisabled || isDisabled || isReadOnly || !focusWithin;
89
+ (0, $jvaNJ$useScrollWheel)({
90
+ onScroll: onWheel,
91
+ isDisabled: scrollingDisabled
92
+ }, inputRef);
93
+ // The inputMode attribute influences the software keyboard that is shown on touch devices.
94
+ // Browsers and operating systems are quite inconsistent about what keys are available, however.
95
+ // We choose between numeric and decimal based on whether we allow negative and fractional numbers,
96
+ // and based on testing on various devices to determine what keys are available in each inputMode.
97
+ let hasDecimals = intlOptions.maximumFractionDigits > 0;
98
+ let hasNegative = state.minValue === undefined || isNaN(state.minValue) || state.minValue < 0;
99
+ let inputMode = "numeric";
100
+ if ((0, $jvaNJ$isIPhone)()) {
101
+ // iPhone doesn't have a minus sign in either numeric or decimal.
102
+ // Note this is only for iPhone, not iPad, which always has both
103
+ // minus and decimal in numeric.
104
+ if (hasNegative) inputMode = "text";
105
+ else if (hasDecimals) inputMode = "decimal";
106
+ } else if ((0, $jvaNJ$isAndroid)()) {
107
+ // Android numeric has both a decimal point and minus key.
108
+ // decimal does not have a minus key.
109
+ if (hasNegative) inputMode = "numeric";
110
+ else if (hasDecimals) inputMode = "decimal";
111
+ }
112
+ let onChange = (value)=>{
113
+ if (state.validate(value)) state.setInputValue(value);
114
+ };
115
+ let domProps = (0, $jvaNJ$filterDOMProps)(props);
116
+ let onKeyDownEnter = (0, $jvaNJ$useCallback)((e)=>{
117
+ if (e.key === "Enter") {
118
+ commit();
119
+ commitValidation();
120
+ } else e.continuePropagation();
121
+ }, [
122
+ commit,
123
+ commitValidation
124
+ ]);
125
+ let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = state.displayValidation;
126
+ let { labelProps: labelProps, inputProps: textFieldProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $jvaNJ$useFormattedTextField)({
127
+ ...otherProps,
128
+ ...domProps,
129
+ name: undefined,
130
+ label: label,
131
+ autoFocus: autoFocus,
132
+ isDisabled: isDisabled,
133
+ isReadOnly: isReadOnly,
134
+ isRequired: isRequired,
135
+ validate: undefined,
136
+ [(0, $jvaNJ$privateValidationStateProp)]: state,
137
+ value: inputValue,
138
+ defaultValue: undefined,
139
+ autoComplete: "off",
140
+ "aria-label": props["aria-label"] || undefined,
141
+ "aria-labelledby": props["aria-labelledby"] || undefined,
142
+ id: inputId,
143
+ type: "text",
144
+ inputMode: inputMode,
145
+ onChange: onChange,
146
+ onBlur: onBlur,
147
+ onFocus: onFocus,
148
+ onFocusChange: onFocusChange,
149
+ onKeyDown: (0, $jvaNJ$useMemo)(()=>(0, $jvaNJ$chain)(onKeyDownEnter, onKeyDown), [
150
+ onKeyDownEnter,
151
+ onKeyDown
152
+ ]),
153
+ onKeyUp: onKeyUp,
154
+ description: description,
155
+ errorMessage: errorMessage
156
+ }, state, inputRef);
157
+ (0, $jvaNJ$useFormReset)(inputRef, state.numberValue, state.setNumberValue);
158
+ let inputProps = (0, $jvaNJ$mergeProps)(spinButtonProps, focusProps, textFieldProps, {
159
+ // override the spinbutton role, we can't focus a spin button with VO
160
+ role: null,
161
+ // ignore aria-roledescription on iOS so that required state will announce when it is present
162
+ "aria-roledescription": !(0, $jvaNJ$isIOS)() ? stringFormatter.format("numberField") : null,
163
+ "aria-valuemax": null,
164
+ "aria-valuemin": null,
165
+ "aria-valuenow": null,
166
+ "aria-valuetext": null,
167
+ autoCorrect: "off",
168
+ spellCheck: "false"
169
+ });
170
+ if (props.validationBehavior === "native") inputProps["aria-required"] = undefined;
171
+ let onButtonPressStart = (e)=>{
172
+ var _inputRef_current;
173
+ // If focus is already on the input, keep it there so we don't hide the
174
+ // software keyboard when tapping the increment/decrement buttons.
175
+ if (document.activeElement === inputRef.current) return;
176
+ // Otherwise, when using a mouse, move focus to the input.
177
+ // On touch, or with a screen reader, focus the button so that the software
178
+ // keyboard does not appear and the screen reader cursor is not moved off the button.
179
+ if (e.pointerType === "mouse") (_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.focus();
180
+ else e.target.focus();
181
+ };
182
+ // Determine the label for the increment and decrement buttons. There are 4 cases:
183
+ //
184
+ // 1. With a visible label that is a string: aria-label: `Increase ${props.label}`
185
+ // 2. With a visible label that is JSX: aria-label: 'Increase', aria-labelledby: '${incrementId} ${labelId}'
186
+ // 3. With an aria-label: aria-label: `Increase ${props['aria-label']}`
187
+ // 4. With an aria-labelledby: aria-label: 'Increase', aria-labelledby: `${incrementId} ${props['aria-labelledby']}`
188
+ //
189
+ // (1) and (2) could possibly be combined and both use aria-labelledby. However, placing the label in
190
+ // the aria-label string rather than using aria-labelledby gives more flexibility to translators to change
191
+ // the order or add additional words around the label if needed.
192
+ let fieldLabel = props["aria-label"] || (typeof props.label === "string" ? props.label : "");
193
+ let ariaLabelledby;
194
+ if (!fieldLabel) ariaLabelledby = props.label != null ? labelProps.id : props["aria-labelledby"];
195
+ let incrementId = (0, $jvaNJ$useId)();
196
+ let decrementId = (0, $jvaNJ$useId)();
197
+ let incrementButtonProps = (0, $jvaNJ$mergeProps)(incButtonProps, {
198
+ "aria-label": incrementAriaLabel || stringFormatter.format("increase", {
199
+ fieldLabel: fieldLabel
200
+ }).trim(),
201
+ id: ariaLabelledby && !incrementAriaLabel ? incrementId : null,
202
+ "aria-labelledby": ariaLabelledby && !incrementAriaLabel ? `${incrementId} ${ariaLabelledby}` : null,
203
+ "aria-controls": inputId,
204
+ excludeFromTabOrder: true,
205
+ preventFocusOnPress: true,
206
+ allowFocusWhenDisabled: true,
207
+ isDisabled: !state.canIncrement,
208
+ onPressStart: onButtonPressStart
209
+ });
210
+ let decrementButtonProps = (0, $jvaNJ$mergeProps)(decButtonProps, {
211
+ "aria-label": decrementAriaLabel || stringFormatter.format("decrease", {
212
+ fieldLabel: fieldLabel
213
+ }).trim(),
214
+ id: ariaLabelledby && !decrementAriaLabel ? decrementId : null,
215
+ "aria-labelledby": ariaLabelledby && !decrementAriaLabel ? `${decrementId} ${ariaLabelledby}` : null,
216
+ "aria-controls": inputId,
217
+ excludeFromTabOrder: true,
218
+ preventFocusOnPress: true,
219
+ allowFocusWhenDisabled: true,
220
+ isDisabled: !state.canDecrement,
221
+ onPressStart: onButtonPressStart
222
+ });
223
+ return {
224
+ groupProps: {
225
+ ...focusWithinProps,
226
+ role: "group",
227
+ "aria-disabled": isDisabled,
228
+ "aria-invalid": isInvalid ? "true" : undefined
229
+ },
230
+ labelProps: labelProps,
231
+ inputProps: inputProps,
232
+ incrementButtonProps: incrementButtonProps,
233
+ decrementButtonProps: decrementButtonProps,
234
+ errorMessageProps: errorMessageProps,
235
+ descriptionProps: descriptionProps,
236
+ isInvalid: isInvalid,
237
+ validationErrors: validationErrors,
238
+ validationDetails: validationDetails
239
+ };
240
+ }
241
+
242
+
243
+ export {$81397a9303501bda$export$23f548e970bdf099 as useNumberField};
244
+ //# sourceMappingURL=useNumberField.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;AA+CM,SAAS,0CAAe,KAA2B,EAAE,KAAuB,EAAE,QAAqC;IACxH,IAAI,MACF,EAAE,sBACF,kBAAkB,sBAClB,kBAAkB,cAClB,UAAU,cACV,UAAU,cACV,UAAU,YACV,QAAQ,YACR,QAAQ,aACR,SAAS,SACT,KAAK,iBACL,aAAa,UACb,SAAS,KAAO,YAChB,OAAO,iBACP,aAAa,aACb,SAAS,WACT,OAAO,eACP,WAAW,gBACX,YAAY,mBACZ,eAAe,EACf,GAAG,YACJ,GAAG;IAEJ,IAAI,aACF,SAAS,kBACT,cAAc,aACd,SAAS,kBACT,cAAc,eACd,WAAW,cACX,UAAU,UACV,MAAM,oBACN,gBAAgB,EACjB,GAAG;IAEJ,MAAM,kBAAkB,CAAA,GAAA,kCAA0B,EAAE,CAAA,GAAA,oDAAW,GAAG;IAElE,IAAI,UAAU,CAAA,GAAA,YAAI,EAAE;IACpB,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;QAC1B;YACE,4CAA4C;YAC5C;QACF;IACF;IAEA,IAAI,kBAAkB,CAAA,GAAA,yBAAiB,EAAE;IACzC,IAAI,cAAc,CAAA,GAAA,cAAM,EAAE,IAAM,gBAAgB,eAAe,IAAI;QAAC;KAAgB;IAEpF,wEAAwE;IACxE,6DAA6D;IAC7D,IAAI,qBAAqB,CAAA,GAAA,yBAAiB,EAAE;QAAC,GAAG,aAAa;QAAE,cAAc;IAAS;IACtF,IAAI,YAAY,CAAA,GAAA,cAAM,EAAE,IAAM,MAAM,eAAe,KAAK,mBAAmB,MAAM,CAAC,cAAc;QAAC;QAAoB;KAAY;IAEjI,IAAI,mBACF,eAAe,EACf,sBAAsB,cAAc,EACpC,sBAAsB,cAAc,E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,CAAC,qBAAqB,cAAc;QAC1D,mBAAmB,kBAAkB,CAAC,qBAAqB,CAAC,EAAE,YAAY,CAAC,EAAE,eAAe,CAAC,GAAG;QAChG,iBAAiB;QACjB,qBAAqB;QACrB,qBAAqB;QACrB,wBAAwB;QACxB,YAAY,CAAC,MAAM,YAAY;QAC/B,cAAc;IAChB;IAEA,OAAO;QACL,YAAY;YACV,GAAG,gBAAgB;YACnB,MAAM;YACN,iBAAiB;YACjB,gBAAgB,YAAY,SAAS;QACvC;oBACA;oBACA;8BACA;8BACA;2BACA;0BACA;mBACA;0BACA;2BACA;IACF;AACF","sources":["packages/@react-aria/numberfield/src/useNumberField.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '@react-types/button';\nimport {AriaNumberFieldProps} from '@react-types/numberfield';\nimport {chain, filterDOMProps, isAndroid, isIOS, isIPhone, mergeProps, useFormReset, useId} from '@react-aria/utils';\nimport {DOMAttributes, GroupDOMAttributes, TextInputDOMProps, ValidationResult} from '@react-types/shared';\nimport {\n InputHTMLAttributes,\n LabelHTMLAttributes,\n RefObject,\n useCallback,\n useMemo,\n useState\n} from 'react';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {NumberFieldState} from '@react-stately/numberfield';\nimport {privateValidationStateProp} from '@react-stately/form';\nimport {useFocus, useFocusWithin, useScrollWheel} from '@react-aria/interactions';\nimport {useFormattedTextField} from '@react-aria/textfield';\nimport {\n useLocalizedStringFormatter,\n useNumberFormatter\n} from '@react-aria/i18n';\nimport {useSpinButton} from '@react-aria/spinbutton';\n\nexport interface NumberFieldAria extends ValidationResult {\n /** Props for the label element. */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>,\n /** Props for the group wrapper around the input and stepper buttons. */\n groupProps: GroupDOMAttributes,\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Props for the increment button, to be passed to [useButton](useButton.html). */\n incrementButtonProps: AriaButtonProps,\n /** Props for the decrement button, to be passed to [useButton](useButton.html). */\n decrementButtonProps: AriaButtonProps,\n /** Props for the number field's description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the number field's error message element, if any. */\n errorMessageProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a number field component.\n * Number fields allow users to enter a number, and increment or decrement the value using stepper buttons.\n */\nexport function useNumberField(props: AriaNumberFieldProps, state: NumberFieldState, inputRef: RefObject<HTMLInputElement>): NumberFieldAria {\n let {\n id,\n decrementAriaLabel,\n incrementAriaLabel,\n isDisabled,\n isReadOnly,\n isRequired,\n minValue,\n maxValue,\n autoFocus,\n label,\n formatOptions,\n onBlur = () => {},\n onFocus,\n onFocusChange,\n onKeyDown,\n onKeyUp,\n description,\n errorMessage,\n isWheelDisabled,\n ...otherProps\n } = props;\n\n let {\n increment,\n incrementToMax,\n decrement,\n decrementToMin,\n numberValue,\n inputValue,\n commit,\n commitValidation\n } = state;\n\n const stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/numberfield');\n\n let inputId = useId(id);\n let {focusProps} = useFocus({\n onBlur() {\n // Set input value to normalized valid value\n commit();\n }\n });\n\n let numberFormatter = useNumberFormatter(formatOptions);\n let intlOptions = useMemo(() => numberFormatter.resolvedOptions(), [numberFormatter]);\n\n // Replace negative textValue formatted using currencySign: 'accounting'\n // with a textValue that can be announced using a minus sign.\n let textValueFormatter = useNumberFormatter({...formatOptions, currencySign: undefined});\n let textValue = useMemo(() => isNaN(numberValue) ? '' : textValueFormatter.format(numberValue), [textValueFormatter, numberValue]);\n\n let {\n spinButtonProps,\n incrementButtonProps: incButtonProps,\n decrementButtonProps: decButtonProps\n } = useSpinButton(\n {\n isDisabled,\n isReadOnly,\n isRequired,\n maxValue,\n minValue,\n onIncrement: increment,\n onIncrementToMax: incrementToMax,\n onDecrement: decrement,\n onDecrementToMin: decrementToMin,\n value: numberValue,\n textValue\n }\n );\n\n let [focusWithin, setFocusWithin] = useState(false);\n let {focusWithinProps} = useFocusWithin({isDisabled, onFocusWithinChange: setFocusWithin});\n\n let onWheel = useCallback((e) => {\n // if on a trackpad, users can scroll in both X and Y at once, check the magnitude of the change\n // if it's mostly in the X direction, then just return, the user probably doesn't mean to inc/dec\n // this isn't perfect, events come in fast with small deltas and a part of the scroll may give a false indication\n // especially if the user is scrolling near 45deg\n if (Math.abs(e.deltaY) <= Math.abs(e.deltaX)) {\n return;\n }\n if (e.deltaY > 0) {\n increment();\n } else if (e.deltaY < 0) {\n decrement();\n }\n }, [decrement, increment]);\n // If the input isn't supposed to receive input, disable scrolling.\n let scrollingDisabled = isWheelDisabled || isDisabled || isReadOnly || !focusWithin;\n useScrollWheel({onScroll: onWheel, isDisabled: scrollingDisabled}, inputRef);\n\n // The inputMode attribute influences the software keyboard that is shown on touch devices.\n // Browsers and operating systems are quite inconsistent about what keys are available, however.\n // We choose between numeric and decimal based on whether we allow negative and fractional numbers,\n // and based on testing on various devices to determine what keys are available in each inputMode.\n let hasDecimals = intlOptions.maximumFractionDigits > 0;\n let hasNegative = (state.minValue === undefined || isNaN(state.minValue)) || state.minValue < 0;\n let inputMode: TextInputDOMProps['inputMode'] = 'numeric';\n if (isIPhone()) {\n // iPhone doesn't have a minus sign in either numeric or decimal.\n // Note this is only for iPhone, not iPad, which always has both\n // minus and decimal in numeric.\n if (hasNegative) {\n inputMode = 'text';\n } else if (hasDecimals) {\n inputMode = 'decimal';\n }\n } else if (isAndroid()) {\n // Android numeric has both a decimal point and minus key.\n // decimal does not have a minus key.\n if (hasNegative) {\n inputMode = 'numeric';\n } else if (hasDecimals) {\n inputMode = 'decimal';\n }\n }\n\n let onChange = value => {\n if (state.validate(value)) {\n state.setInputValue(value);\n }\n };\n\n let domProps = filterDOMProps(props);\n let onKeyDownEnter = useCallback((e) => {\n if (e.key === 'Enter') {\n commit();\n commitValidation();\n } else {\n e.continuePropagation();\n }\n }, [commit, commitValidation]);\n\n let {isInvalid, validationErrors, validationDetails} = state.displayValidation;\n let {labelProps, inputProps: textFieldProps, descriptionProps, errorMessageProps} = useFormattedTextField({\n ...otherProps,\n ...domProps,\n name: undefined,\n label,\n autoFocus,\n isDisabled,\n isReadOnly,\n isRequired,\n validate: undefined,\n [privateValidationStateProp]: state,\n value: inputValue,\n defaultValue: undefined, // defaultValue already used to populate state.inputValue, unneeded here\n autoComplete: 'off',\n 'aria-label': props['aria-label'] || undefined,\n 'aria-labelledby': props['aria-labelledby'] || undefined,\n id: inputId,\n type: 'text', // Can't use type=\"number\" because then we can't have things like $ in the field.\n inputMode,\n onChange,\n onBlur,\n onFocus,\n onFocusChange,\n onKeyDown: useMemo(() => chain(onKeyDownEnter, onKeyDown), [onKeyDownEnter, onKeyDown]),\n onKeyUp,\n description,\n errorMessage\n }, state, inputRef);\n\n useFormReset(inputRef, state.numberValue, state.setNumberValue);\n\n let inputProps: InputHTMLAttributes<HTMLInputElement> = mergeProps(\n spinButtonProps,\n focusProps,\n textFieldProps,\n {\n // override the spinbutton role, we can't focus a spin button with VO\n role: null,\n // ignore aria-roledescription on iOS so that required state will announce when it is present\n 'aria-roledescription': (!isIOS() ? stringFormatter.format('numberField') : null),\n 'aria-valuemax': null,\n 'aria-valuemin': null,\n 'aria-valuenow': null,\n 'aria-valuetext': null,\n autoCorrect: 'off',\n spellCheck: 'false'\n }\n );\n\n if (props.validationBehavior === 'native') {\n inputProps['aria-required'] = undefined;\n }\n\n let onButtonPressStart = (e) => {\n // If focus is already on the input, keep it there so we don't hide the\n // software keyboard when tapping the increment/decrement buttons.\n if (document.activeElement === inputRef.current) {\n return;\n }\n\n // Otherwise, when using a mouse, move focus to the input.\n // On touch, or with a screen reader, focus the button so that the software\n // keyboard does not appear and the screen reader cursor is not moved off the button.\n if (e.pointerType === 'mouse') {\n inputRef.current?.focus();\n } else {\n e.target.focus();\n }\n };\n\n // Determine the label for the increment and decrement buttons. There are 4 cases:\n //\n // 1. With a visible label that is a string: aria-label: `Increase ${props.label}`\n // 2. With a visible label that is JSX: aria-label: 'Increase', aria-labelledby: '${incrementId} ${labelId}'\n // 3. With an aria-label: aria-label: `Increase ${props['aria-label']}`\n // 4. With an aria-labelledby: aria-label: 'Increase', aria-labelledby: `${incrementId} ${props['aria-labelledby']}`\n //\n // (1) and (2) could possibly be combined and both use aria-labelledby. However, placing the label in\n // the aria-label string rather than using aria-labelledby gives more flexibility to translators to change\n // the order or add additional words around the label if needed.\n let fieldLabel = props['aria-label'] || (typeof props.label === 'string' ? props.label : '');\n let ariaLabelledby: string | undefined;\n if (!fieldLabel) {\n ariaLabelledby = props.label != null ? labelProps.id : props['aria-labelledby'];\n }\n\n let incrementId = useId();\n let decrementId = useId();\n\n let incrementButtonProps: AriaButtonProps = mergeProps(incButtonProps, {\n 'aria-label': incrementAriaLabel || stringFormatter.format('increase', {fieldLabel}).trim(),\n id: ariaLabelledby && !incrementAriaLabel ? incrementId : null,\n 'aria-labelledby': ariaLabelledby && !incrementAriaLabel ? `${incrementId} ${ariaLabelledby}` : null,\n 'aria-controls': inputId,\n excludeFromTabOrder: true,\n preventFocusOnPress: true,\n allowFocusWhenDisabled: true,\n isDisabled: !state.canIncrement,\n onPressStart: onButtonPressStart\n });\n\n let decrementButtonProps: AriaButtonProps = mergeProps(decButtonProps, {\n 'aria-label': decrementAriaLabel || stringFormatter.format('decrease', {fieldLabel}).trim(),\n id: ariaLabelledby && !decrementAriaLabel ? decrementId : null,\n 'aria-labelledby': ariaLabelledby && !decrementAriaLabel ? `${decrementId} ${ariaLabelledby}` : null,\n 'aria-controls': inputId,\n excludeFromTabOrder: true,\n preventFocusOnPress: true,\n allowFocusWhenDisabled: true,\n isDisabled: !state.canDecrement,\n onPressStart: onButtonPressStart\n });\n\n return {\n groupProps: {\n ...focusWithinProps,\n role: 'group',\n 'aria-disabled': isDisabled,\n 'aria-invalid': isInvalid ? 'true' : undefined\n },\n labelProps,\n inputProps,\n incrementButtonProps,\n decrementButtonProps,\n errorMessageProps,\n descriptionProps,\n isInvalid,\n validationErrors,\n validationDetails\n };\n}\n"],"names":[],"version":3,"file":"useNumberField.module.js.map"}
package/dist/zh-CN.mjs CHANGED
@@ -7,4 +7,4 @@ $e1103cb9b4c13942$exports = {
7
7
 
8
8
 
9
9
  export {$e1103cb9b4c13942$exports as default};
10
- //# sourceMappingURL=zh-CN.module.js.map
10
+ //# sourceMappingURL=zh-CN.mjs.map
package/dist/zh-TW.mjs CHANGED
@@ -7,4 +7,4 @@ $448607634f80dccb$exports = {
7
7
 
8
8
 
9
9
  export {$448607634f80dccb$exports as default};
10
- //# sourceMappingURL=zh-TW.module.js.map
10
+ //# sourceMappingURL=zh-TW.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/numberfield",
3
- "version": "3.11.1",
3
+ "version": "3.11.2",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -22,16 +22,16 @@
22
22
  "url": "https://github.com/adobe/react-spectrum"
23
23
  },
24
24
  "dependencies": {
25
- "@react-aria/i18n": "^3.10.2",
26
- "@react-aria/interactions": "^3.21.1",
27
- "@react-aria/spinbutton": "^3.6.3",
28
- "@react-aria/textfield": "^3.14.3",
29
- "@react-aria/utils": "^3.23.2",
30
- "@react-stately/form": "^3.0.1",
31
- "@react-stately/numberfield": "^3.9.1",
32
- "@react-types/button": "^3.9.2",
33
- "@react-types/numberfield": "^3.8.1",
34
- "@react-types/shared": "^3.22.1",
25
+ "@react-aria/i18n": "^3.11.0",
26
+ "@react-aria/interactions": "^3.21.2",
27
+ "@react-aria/spinbutton": "^3.6.4",
28
+ "@react-aria/textfield": "^3.14.4",
29
+ "@react-aria/utils": "^3.24.0",
30
+ "@react-stately/form": "^3.0.2",
31
+ "@react-stately/numberfield": "^3.9.2",
32
+ "@react-types/button": "^3.9.3",
33
+ "@react-types/numberfield": "^3.8.2",
34
+ "@react-types/shared": "^3.23.0",
35
35
  "@swc/helpers": "^0.5.0"
36
36
  },
37
37
  "peerDependencies": {
@@ -41,5 +41,5 @@
41
41
  "publishConfig": {
42
42
  "access": "public"
43
43
  },
44
- "gitHead": "de9f84a22583fc741c29b341d14cd35ef4cca161"
44
+ "gitHead": "f645f29edc1322153fd60af4640cbcab1d992dbd"
45
45
  }