@react-aria/numberfield 3.12.5 → 3.13.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 (191) hide show
  1. package/dist/import.mjs +2 -2
  2. package/dist/main.js +2 -2
  3. package/dist/main.js.map +1 -1
  4. package/dist/module.js +2 -2
  5. package/dist/module.js.map +1 -1
  6. package/dist/types/src/index.d.ts +2 -0
  7. package/package.json +15 -22
  8. package/src/index.ts +3 -3
  9. package/dist/ar-AE.main.js +0 -8
  10. package/dist/ar-AE.main.js.map +0 -1
  11. package/dist/ar-AE.mjs +0 -10
  12. package/dist/ar-AE.module.js +0 -10
  13. package/dist/ar-AE.module.js.map +0 -1
  14. package/dist/bg-BG.main.js +0 -8
  15. package/dist/bg-BG.main.js.map +0 -1
  16. package/dist/bg-BG.mjs +0 -10
  17. package/dist/bg-BG.module.js +0 -10
  18. package/dist/bg-BG.module.js.map +0 -1
  19. package/dist/cs-CZ.main.js +0 -8
  20. package/dist/cs-CZ.main.js.map +0 -1
  21. package/dist/cs-CZ.mjs +0 -10
  22. package/dist/cs-CZ.module.js +0 -10
  23. package/dist/cs-CZ.module.js.map +0 -1
  24. package/dist/da-DK.main.js +0 -8
  25. package/dist/da-DK.main.js.map +0 -1
  26. package/dist/da-DK.mjs +0 -10
  27. package/dist/da-DK.module.js +0 -10
  28. package/dist/da-DK.module.js.map +0 -1
  29. package/dist/de-DE.main.js +0 -8
  30. package/dist/de-DE.main.js.map +0 -1
  31. package/dist/de-DE.mjs +0 -10
  32. package/dist/de-DE.module.js +0 -10
  33. package/dist/de-DE.module.js.map +0 -1
  34. package/dist/el-GR.main.js +0 -8
  35. package/dist/el-GR.main.js.map +0 -1
  36. package/dist/el-GR.mjs +0 -10
  37. package/dist/el-GR.module.js +0 -10
  38. package/dist/el-GR.module.js.map +0 -1
  39. package/dist/en-US.main.js +0 -8
  40. package/dist/en-US.main.js.map +0 -1
  41. package/dist/en-US.mjs +0 -10
  42. package/dist/en-US.module.js +0 -10
  43. package/dist/en-US.module.js.map +0 -1
  44. package/dist/es-ES.main.js +0 -8
  45. package/dist/es-ES.main.js.map +0 -1
  46. package/dist/es-ES.mjs +0 -10
  47. package/dist/es-ES.module.js +0 -10
  48. package/dist/es-ES.module.js.map +0 -1
  49. package/dist/et-EE.main.js +0 -8
  50. package/dist/et-EE.main.js.map +0 -1
  51. package/dist/et-EE.mjs +0 -10
  52. package/dist/et-EE.module.js +0 -10
  53. package/dist/et-EE.module.js.map +0 -1
  54. package/dist/fi-FI.main.js +0 -8
  55. package/dist/fi-FI.main.js.map +0 -1
  56. package/dist/fi-FI.mjs +0 -10
  57. package/dist/fi-FI.module.js +0 -10
  58. package/dist/fi-FI.module.js.map +0 -1
  59. package/dist/fr-FR.main.js +0 -8
  60. package/dist/fr-FR.main.js.map +0 -1
  61. package/dist/fr-FR.mjs +0 -10
  62. package/dist/fr-FR.module.js +0 -10
  63. package/dist/fr-FR.module.js.map +0 -1
  64. package/dist/he-IL.main.js +0 -8
  65. package/dist/he-IL.main.js.map +0 -1
  66. package/dist/he-IL.mjs +0 -10
  67. package/dist/he-IL.module.js +0 -10
  68. package/dist/he-IL.module.js.map +0 -1
  69. package/dist/hr-HR.main.js +0 -8
  70. package/dist/hr-HR.main.js.map +0 -1
  71. package/dist/hr-HR.mjs +0 -10
  72. package/dist/hr-HR.module.js +0 -10
  73. package/dist/hr-HR.module.js.map +0 -1
  74. package/dist/hu-HU.main.js +0 -8
  75. package/dist/hu-HU.main.js.map +0 -1
  76. package/dist/hu-HU.mjs +0 -10
  77. package/dist/hu-HU.module.js +0 -10
  78. package/dist/hu-HU.module.js.map +0 -1
  79. package/dist/intlStrings.main.js +0 -108
  80. package/dist/intlStrings.main.js.map +0 -1
  81. package/dist/intlStrings.mjs +0 -110
  82. package/dist/intlStrings.module.js +0 -110
  83. package/dist/intlStrings.module.js.map +0 -1
  84. package/dist/it-IT.main.js +0 -8
  85. package/dist/it-IT.main.js.map +0 -1
  86. package/dist/it-IT.mjs +0 -10
  87. package/dist/it-IT.module.js +0 -10
  88. package/dist/it-IT.module.js.map +0 -1
  89. package/dist/ja-JP.main.js +0 -8
  90. package/dist/ja-JP.main.js.map +0 -1
  91. package/dist/ja-JP.mjs +0 -10
  92. package/dist/ja-JP.module.js +0 -10
  93. package/dist/ja-JP.module.js.map +0 -1
  94. package/dist/ko-KR.main.js +0 -8
  95. package/dist/ko-KR.main.js.map +0 -1
  96. package/dist/ko-KR.mjs +0 -10
  97. package/dist/ko-KR.module.js +0 -10
  98. package/dist/ko-KR.module.js.map +0 -1
  99. package/dist/lt-LT.main.js +0 -8
  100. package/dist/lt-LT.main.js.map +0 -1
  101. package/dist/lt-LT.mjs +0 -10
  102. package/dist/lt-LT.module.js +0 -10
  103. package/dist/lt-LT.module.js.map +0 -1
  104. package/dist/lv-LV.main.js +0 -8
  105. package/dist/lv-LV.main.js.map +0 -1
  106. package/dist/lv-LV.mjs +0 -10
  107. package/dist/lv-LV.module.js +0 -10
  108. package/dist/lv-LV.module.js.map +0 -1
  109. package/dist/nb-NO.main.js +0 -8
  110. package/dist/nb-NO.main.js.map +0 -1
  111. package/dist/nb-NO.mjs +0 -10
  112. package/dist/nb-NO.module.js +0 -10
  113. package/dist/nb-NO.module.js.map +0 -1
  114. package/dist/nl-NL.main.js +0 -8
  115. package/dist/nl-NL.main.js.map +0 -1
  116. package/dist/nl-NL.mjs +0 -10
  117. package/dist/nl-NL.module.js +0 -10
  118. package/dist/nl-NL.module.js.map +0 -1
  119. package/dist/pl-PL.main.js +0 -8
  120. package/dist/pl-PL.main.js.map +0 -1
  121. package/dist/pl-PL.mjs +0 -10
  122. package/dist/pl-PL.module.js +0 -10
  123. package/dist/pl-PL.module.js.map +0 -1
  124. package/dist/pt-BR.main.js +0 -8
  125. package/dist/pt-BR.main.js.map +0 -1
  126. package/dist/pt-BR.mjs +0 -10
  127. package/dist/pt-BR.module.js +0 -10
  128. package/dist/pt-BR.module.js.map +0 -1
  129. package/dist/pt-PT.main.js +0 -8
  130. package/dist/pt-PT.main.js.map +0 -1
  131. package/dist/pt-PT.mjs +0 -10
  132. package/dist/pt-PT.module.js +0 -10
  133. package/dist/pt-PT.module.js.map +0 -1
  134. package/dist/ro-RO.main.js +0 -8
  135. package/dist/ro-RO.main.js.map +0 -1
  136. package/dist/ro-RO.mjs +0 -10
  137. package/dist/ro-RO.module.js +0 -10
  138. package/dist/ro-RO.module.js.map +0 -1
  139. package/dist/ru-RU.main.js +0 -8
  140. package/dist/ru-RU.main.js.map +0 -1
  141. package/dist/ru-RU.mjs +0 -10
  142. package/dist/ru-RU.module.js +0 -10
  143. package/dist/ru-RU.module.js.map +0 -1
  144. package/dist/sk-SK.main.js +0 -8
  145. package/dist/sk-SK.main.js.map +0 -1
  146. package/dist/sk-SK.mjs +0 -10
  147. package/dist/sk-SK.module.js +0 -10
  148. package/dist/sk-SK.module.js.map +0 -1
  149. package/dist/sl-SI.main.js +0 -8
  150. package/dist/sl-SI.main.js.map +0 -1
  151. package/dist/sl-SI.mjs +0 -10
  152. package/dist/sl-SI.module.js +0 -10
  153. package/dist/sl-SI.module.js.map +0 -1
  154. package/dist/sr-SP.main.js +0 -8
  155. package/dist/sr-SP.main.js.map +0 -1
  156. package/dist/sr-SP.mjs +0 -10
  157. package/dist/sr-SP.module.js +0 -10
  158. package/dist/sr-SP.module.js.map +0 -1
  159. package/dist/sv-SE.main.js +0 -8
  160. package/dist/sv-SE.main.js.map +0 -1
  161. package/dist/sv-SE.mjs +0 -10
  162. package/dist/sv-SE.module.js +0 -10
  163. package/dist/sv-SE.module.js.map +0 -1
  164. package/dist/tr-TR.main.js +0 -8
  165. package/dist/tr-TR.main.js.map +0 -1
  166. package/dist/tr-TR.mjs +0 -10
  167. package/dist/tr-TR.module.js +0 -10
  168. package/dist/tr-TR.module.js.map +0 -1
  169. package/dist/types.d.ts +0 -29
  170. package/dist/types.d.ts.map +0 -1
  171. package/dist/uk-UA.main.js +0 -8
  172. package/dist/uk-UA.main.js.map +0 -1
  173. package/dist/uk-UA.mjs +0 -10
  174. package/dist/uk-UA.module.js +0 -10
  175. package/dist/uk-UA.module.js.map +0 -1
  176. package/dist/useNumberField.main.js +0 -289
  177. package/dist/useNumberField.main.js.map +0 -1
  178. package/dist/useNumberField.mjs +0 -284
  179. package/dist/useNumberField.module.js +0 -284
  180. package/dist/useNumberField.module.js.map +0 -1
  181. package/dist/zh-CN.main.js +0 -8
  182. package/dist/zh-CN.main.js.map +0 -1
  183. package/dist/zh-CN.mjs +0 -10
  184. package/dist/zh-CN.module.js +0 -10
  185. package/dist/zh-CN.module.js.map +0 -1
  186. package/dist/zh-TW.main.js +0 -8
  187. package/dist/zh-TW.main.js.map +0 -1
  188. package/dist/zh-TW.mjs +0 -10
  189. package/dist/zh-TW.module.js +0 -10
  190. package/dist/zh-TW.module.js.map +0 -1
  191. package/src/useNumberField.ts +0 -363
@@ -1,363 +0,0 @@
1
- /*
2
- * Copyright 2020 Adobe. All rights reserved.
3
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License. You may obtain a copy
5
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- *
7
- * Unless required by applicable law or agreed to in writing, software distributed under
8
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- * OF ANY KIND, either express or implied. See the License for the specific language
10
- * governing permissions and limitations under the License.
11
- */
12
-
13
- import {announce} from '@react-aria/live-announcer';
14
- import {AriaButtonProps} from '@react-types/button';
15
- import {AriaNumberFieldProps} from '@react-types/numberfield';
16
- import {chain, filterDOMProps, getActiveElement, getEventTarget, isAndroid, isIOS, isIPhone, mergeProps, useFormReset, useId} from '@react-aria/utils';
17
- import {
18
- type ClipboardEvent,
19
- type ClipboardEventHandler,
20
- InputHTMLAttributes,
21
- LabelHTMLAttributes,
22
- RefObject,
23
- useCallback,
24
- useMemo,
25
- useState
26
- } from 'react';
27
- import {DOMAttributes, GroupDOMAttributes, TextInputDOMProps, ValidationResult} from '@react-types/shared';
28
- import {flushSync} from 'react-dom';
29
- // @ts-ignore
30
- import intlMessages from '../intl/*.json';
31
- import {NumberFieldState} from '@react-stately/numberfield';
32
- import {privateValidationStateProp} from '@react-stately/form';
33
- import {useFocus, useFocusWithin, useScrollWheel} from '@react-aria/interactions';
34
- import {useFormattedTextField} from '@react-aria/textfield';
35
- import {
36
- useLocalizedStringFormatter,
37
- useNumberFormatter
38
- } from '@react-aria/i18n';
39
- import {useSpinButton} from '@react-aria/spinbutton';
40
-
41
- export interface NumberFieldAria extends ValidationResult {
42
- /** Props for the label element. */
43
- labelProps: LabelHTMLAttributes<HTMLLabelElement>,
44
- /** Props for the group wrapper around the input and stepper buttons. */
45
- groupProps: GroupDOMAttributes,
46
- /** Props for the input element. */
47
- inputProps: InputHTMLAttributes<HTMLInputElement>,
48
- /** Props for the increment button, to be passed to `useButton`. */
49
- incrementButtonProps: AriaButtonProps,
50
- /** Props for the decrement button, to be passed to `useButton`. */
51
- decrementButtonProps: AriaButtonProps,
52
- /** Props for the number field's description element, if any. */
53
- descriptionProps: DOMAttributes,
54
- /** Props for the number field's error message element, if any. */
55
- errorMessageProps: DOMAttributes
56
- }
57
-
58
- /**
59
- * Provides the behavior and accessibility implementation for a number field component.
60
- * Number fields allow users to enter a number, and increment or decrement the value using stepper buttons.
61
- */
62
- export function useNumberField(props: AriaNumberFieldProps, state: NumberFieldState, inputRef: RefObject<HTMLInputElement | null>): NumberFieldAria {
63
- let {
64
- id,
65
- decrementAriaLabel,
66
- incrementAriaLabel,
67
- isDisabled,
68
- isReadOnly,
69
- isRequired,
70
- minValue,
71
- maxValue,
72
- autoFocus,
73
- label,
74
- formatOptions,
75
- onBlur = () => {},
76
- onFocus,
77
- onFocusChange,
78
- onKeyDown,
79
- onKeyUp,
80
- description,
81
- errorMessage,
82
- isWheelDisabled,
83
- ...otherProps
84
- } = props;
85
-
86
- let {
87
- increment,
88
- incrementToMax,
89
- decrement,
90
- decrementToMin,
91
- numberValue,
92
- inputValue,
93
- commit,
94
- commitValidation
95
- } = state;
96
-
97
- const stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/numberfield');
98
- let commitAndAnnounce = useCallback(() => {
99
- let oldValue = inputRef.current?.value ?? '';
100
- // Set input value to normalized valid value
101
- flushSync(() => {
102
- commit();
103
- });
104
-
105
- if (inputRef.current?.value !== oldValue) {
106
- announce(inputRef.current?.value ?? '', 'assertive');
107
- }
108
- }, [commit, inputRef]);
109
-
110
- let inputId = useId(id);
111
- let {focusProps} = useFocus({
112
- onBlur() {
113
- commitAndAnnounce();
114
- }
115
- });
116
-
117
- let numberFormatter = useNumberFormatter(formatOptions);
118
- let intlOptions = useMemo(() => numberFormatter.resolvedOptions(), [numberFormatter]);
119
-
120
- // Replace negative textValue formatted using currencySign: 'accounting'
121
- // with a textValue that can be announced using a minus sign.
122
- let textValueFormatter = useNumberFormatter({...formatOptions, currencySign: undefined});
123
- let textValue = useMemo(() => isNaN(numberValue) ? '' : textValueFormatter.format(numberValue), [textValueFormatter, numberValue]);
124
-
125
- let {
126
- spinButtonProps,
127
- incrementButtonProps: incButtonProps,
128
- decrementButtonProps: decButtonProps
129
- } = useSpinButton(
130
- {
131
- isDisabled,
132
- isReadOnly,
133
- isRequired,
134
- maxValue,
135
- minValue,
136
- onIncrement: increment,
137
- onIncrementToMax: incrementToMax,
138
- onDecrement: decrement,
139
- onDecrementToMin: decrementToMin,
140
- value: numberValue,
141
- textValue
142
- }
143
- );
144
-
145
- let [focusWithin, setFocusWithin] = useState(false);
146
- let {focusWithinProps} = useFocusWithin({isDisabled, onFocusWithinChange: setFocusWithin});
147
-
148
- let onWheel = useCallback((e) => {
149
- // if on a trackpad, users can scroll in both X and Y at once, check the magnitude of the change
150
- // if it's mostly in the X direction, then just return, the user probably doesn't mean to inc/dec
151
- // this isn't perfect, events come in fast with small deltas and a part of the scroll may give a false indication
152
- // especially if the user is scrolling near 45deg
153
- if (Math.abs(e.deltaY) <= Math.abs(e.deltaX)) {
154
- return;
155
- }
156
- if (e.deltaY > 0) {
157
- increment();
158
- } else if (e.deltaY < 0) {
159
- decrement();
160
- }
161
- }, [decrement, increment]);
162
- // If the input isn't supposed to receive input, disable scrolling.
163
- let scrollingDisabled = isWheelDisabled || isDisabled || isReadOnly || !focusWithin;
164
- useScrollWheel({onScroll: onWheel, isDisabled: scrollingDisabled}, inputRef);
165
-
166
- // The inputMode attribute influences the software keyboard that is shown on touch devices.
167
- // Browsers and operating systems are quite inconsistent about what keys are available, however.
168
- // We choose between numeric and decimal based on whether we allow negative and fractional numbers,
169
- // and based on testing on various devices to determine what keys are available in each inputMode.
170
- let hasDecimals = (intlOptions.maximumFractionDigits ?? 0) > 0;
171
- let hasNegative = (state.minValue === undefined || isNaN(state.minValue)) || state.minValue < 0;
172
- let inputMode: TextInputDOMProps['inputMode'] = 'numeric';
173
- if (isIPhone()) {
174
- // iPhone doesn't have a minus sign in either numeric or decimal.
175
- // Note this is only for iPhone, not iPad, which always has both
176
- // minus and decimal in numeric.
177
- if (hasNegative) {
178
- inputMode = 'text';
179
- } else if (hasDecimals) {
180
- inputMode = 'decimal';
181
- }
182
- } else if (isAndroid()) {
183
- // Android numeric has both a decimal point and minus key.
184
- // decimal does not have a minus key.
185
- if (hasNegative) {
186
- inputMode = 'numeric';
187
- } else if (hasDecimals) {
188
- inputMode = 'decimal';
189
- }
190
- }
191
-
192
- let onChange = value => {
193
- if (state.validate(value)) {
194
- state.setInputValue(value);
195
- }
196
- };
197
-
198
- let onPaste: ClipboardEventHandler<HTMLInputElement> = (e: ClipboardEvent<HTMLInputElement>) => {
199
- props.onPaste?.(e);
200
- let inputElement = getEventTarget(e) as HTMLInputElement;
201
- // we can only handle the case where the paste takes over the entire input, otherwise things get very complicated
202
- // trying to calculate the new string based on what the paste is replacing and where in the source string it is
203
- if (inputElement &&
204
- ((inputElement.selectionEnd ?? -1) - (inputElement.selectionStart ?? 0)) === inputElement.value.length
205
- ) {
206
- e.preventDefault();
207
- // commit so that the user gets to see what it formats to immediately
208
- // paste happens before inputRef's value is updated, so have to prevent the default and do it ourselves
209
- // spin button will then handle announcing the new value, this should work with controlled state as well
210
- // because the announcement is done as a result of the new rendered input value if there is one
211
- commit(e.clipboardData?.getData?.('text/plain')?.trim() ?? '');
212
- }
213
- };
214
-
215
- let domProps = filterDOMProps(props);
216
- let onKeyDownEnter = useCallback((e) => {
217
- if (e.nativeEvent.isComposing) {
218
- return;
219
- }
220
-
221
- if (e.key === 'Enter') {
222
- commit();
223
- commitValidation();
224
- } else {
225
- e.continuePropagation();
226
- }
227
- }, [commit, commitValidation]);
228
-
229
- let {isInvalid, validationErrors, validationDetails} = state.displayValidation;
230
- let {labelProps, inputProps: textFieldProps, descriptionProps, errorMessageProps} = useFormattedTextField({
231
- ...otherProps,
232
- ...domProps,
233
- // These props are added to a hidden input rather than the formatted textfield.
234
- name: undefined,
235
- form: undefined,
236
- label,
237
- autoFocus,
238
- isDisabled,
239
- isReadOnly,
240
- isRequired,
241
- validate: undefined,
242
- [privateValidationStateProp]: state,
243
- value: inputValue,
244
- defaultValue: '!', // an invalid value so that form reset is ignored in onChange above
245
- autoComplete: 'off',
246
- 'aria-label': props['aria-label'] || undefined,
247
- 'aria-labelledby': props['aria-labelledby'] || undefined,
248
- id: inputId,
249
- type: 'text', // Can't use type="number" because then we can't have things like $ in the field.
250
- inputMode,
251
- onChange,
252
- onBlur,
253
- onFocus,
254
- onFocusChange,
255
- onKeyDown: useMemo(() => chain(onKeyDownEnter, onKeyDown), [onKeyDownEnter, onKeyDown]),
256
- onKeyUp,
257
- onPaste,
258
- description,
259
- errorMessage
260
- }, state, inputRef);
261
-
262
- useFormReset(inputRef, state.defaultNumberValue, state.setNumberValue);
263
-
264
- let inputProps: InputHTMLAttributes<HTMLInputElement> = mergeProps(
265
- spinButtonProps,
266
- focusProps,
267
- textFieldProps,
268
- {
269
- // override the spinbutton role, we can't focus a spin button with VO
270
- role: null,
271
- // ignore aria-roledescription on iOS so that required state will announce when it is present
272
- 'aria-roledescription': (!isIOS() ? stringFormatter.format('numberField') : null),
273
- 'aria-valuemax': null,
274
- 'aria-valuemin': null,
275
- 'aria-valuenow': null,
276
- 'aria-valuetext': null,
277
- autoCorrect: 'off',
278
- spellCheck: 'false'
279
- }
280
- );
281
-
282
- if (props.validationBehavior === 'native') {
283
- inputProps['aria-required'] = undefined;
284
- }
285
-
286
- let onButtonPressStart = (e) => {
287
- // If focus is already on the input, keep it there so we don't hide the
288
- // software keyboard when tapping the increment/decrement buttons.
289
- if (getActiveElement() === inputRef.current) {
290
- return;
291
- }
292
-
293
- // Otherwise, when using a mouse, move focus to the input.
294
- // On touch, or with a screen reader, focus the button so that the software
295
- // keyboard does not appear and the screen reader cursor is not moved off the button.
296
- if (e.pointerType === 'mouse') {
297
- inputRef.current?.focus();
298
- } else {
299
- e.target.focus();
300
- }
301
- };
302
-
303
- // Determine the label for the increment and decrement buttons. There are 4 cases:
304
- //
305
- // 1. With a visible label that is a string: aria-label: `Increase ${props.label}`
306
- // 2. With a visible label that is JSX: aria-label: 'Increase', aria-labelledby: '${incrementId} ${labelId}'
307
- // 3. With an aria-label: aria-label: `Increase ${props['aria-label']}`
308
- // 4. With an aria-labelledby: aria-label: 'Increase', aria-labelledby: `${incrementId} ${props['aria-labelledby']}`
309
- //
310
- // (1) and (2) could possibly be combined and both use aria-labelledby. However, placing the label in
311
- // the aria-label string rather than using aria-labelledby gives more flexibility to translators to change
312
- // the order or add additional words around the label if needed.
313
- let fieldLabel = props['aria-label'] || (typeof props.label === 'string' ? props.label : '');
314
- let ariaLabelledby: string | undefined;
315
- if (!fieldLabel) {
316
- ariaLabelledby = props.label != null ? labelProps.id : props['aria-labelledby'];
317
- }
318
-
319
- let incrementId = useId();
320
- let decrementId = useId();
321
-
322
- let incrementButtonProps: AriaButtonProps = mergeProps(incButtonProps, {
323
- 'aria-label': incrementAriaLabel || stringFormatter.format('increase', {fieldLabel}).trim(),
324
- id: ariaLabelledby && !incrementAriaLabel ? incrementId : null,
325
- 'aria-labelledby': ariaLabelledby && !incrementAriaLabel ? `${incrementId} ${ariaLabelledby}` : null,
326
- 'aria-controls': inputId,
327
- excludeFromTabOrder: true,
328
- preventFocusOnPress: true,
329
- allowFocusWhenDisabled: true,
330
- isDisabled: !state.canIncrement,
331
- onPressStart: onButtonPressStart
332
- });
333
-
334
- let decrementButtonProps: AriaButtonProps = mergeProps(decButtonProps, {
335
- 'aria-label': decrementAriaLabel || stringFormatter.format('decrease', {fieldLabel}).trim(),
336
- id: ariaLabelledby && !decrementAriaLabel ? decrementId : null,
337
- 'aria-labelledby': ariaLabelledby && !decrementAriaLabel ? `${decrementId} ${ariaLabelledby}` : null,
338
- 'aria-controls': inputId,
339
- excludeFromTabOrder: true,
340
- preventFocusOnPress: true,
341
- allowFocusWhenDisabled: true,
342
- isDisabled: !state.canDecrement,
343
- onPressStart: onButtonPressStart
344
- });
345
-
346
- return {
347
- groupProps: {
348
- ...focusWithinProps,
349
- role: 'group',
350
- 'aria-disabled': isDisabled,
351
- 'aria-invalid': isInvalid ? 'true' : undefined
352
- },
353
- labelProps,
354
- inputProps,
355
- incrementButtonProps,
356
- decrementButtonProps,
357
- errorMessageProps,
358
- descriptionProps,
359
- isInvalid,
360
- validationErrors,
361
- validationDetails
362
- };
363
- }