@react-aria/numberfield 3.11.1 → 3.11.3

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/module.js CHANGED
@@ -1,60 +1,6 @@
1
- import $fb78e0f6ab6349ed$exports from "./ar-AE.module.js";
2
- import $2776acdd9959a647$exports from "./bg-BG.module.js";
3
- import $741954410a365ad3$exports from "./cs-CZ.module.js";
4
- import $8321ed0f8ab642f0$exports from "./da-DK.module.js";
5
- import $92978e0c4ecafa32$exports from "./de-DE.module.js";
6
- import $ac5ff71962864a84$exports from "./el-GR.module.js";
7
- import $efe4685e2440d8be$exports from "./en-US.module.js";
8
- import $e50a9a48739b90e1$exports from "./es-ES.module.js";
9
- import $6e0d5294ecbb8ab6$exports from "./et-EE.module.js";
10
- import $e7129d65f607f77f$exports from "./fi-FI.module.js";
11
- import $d72adf5b20573e34$exports from "./fr-FR.module.js";
12
- import $a25c707e88b844a7$exports from "./he-IL.module.js";
13
- import $69b41140b9a4ca54$exports from "./hr-HR.module.js";
14
- import $81dab28f37f59d1a$exports from "./hu-HU.module.js";
15
- import $866555b31f2d7711$exports from "./it-IT.module.js";
16
- import $dafcd55d52b9d371$exports from "./ja-JP.module.js";
17
- import $f090c1f8c5da0145$exports from "./ko-KR.module.js";
18
- import $6f10f3a13360a75c$exports from "./lt-LT.module.js";
19
- import $47432cefd4b7bd1b$exports from "./lv-LV.module.js";
20
- import $dc578a950a2bf23d$exports from "./nb-NO.module.js";
21
- import $353f1bfca4dc395a$exports from "./nl-NL.module.js";
22
- import $241bc0bbd870e982$exports from "./pl-PL.module.js";
23
- import $da3005c7bd72b0a8$exports from "./pt-BR.module.js";
24
- import $cf48bfc540882310$exports from "./pt-PT.module.js";
25
- import $b63a28c481ab9ee3$exports from "./ro-RO.module.js";
26
- import $19f9df95c2464ab6$exports from "./ru-RU.module.js";
27
- import $b272932a685e8482$exports from "./sk-SK.module.js";
28
- import $cbaf8b5b61f9e544$exports from "./sl-SI.module.js";
29
- import $e0a3af6ac1449b2f$exports from "./sr-SP.module.js";
30
- import $71e167d2458a6019$exports from "./sv-SE.module.js";
31
- import $3719245abc082946$exports from "./tr-TR.module.js";
32
- import $2ccc589e2f51824d$exports from "./uk-UA.module.js";
33
- import $e1103cb9b4c13942$exports from "./zh-CN.module.js";
34
- import $448607634f80dccb$exports from "./zh-TW.module.js";
35
- import {useId as $gfhJl$useId, isIPhone as $gfhJl$isIPhone, isAndroid as $gfhJl$isAndroid, filterDOMProps as $gfhJl$filterDOMProps, chain as $gfhJl$chain, useFormReset as $gfhJl$useFormReset, mergeProps as $gfhJl$mergeProps, isIOS as $gfhJl$isIOS} from "@react-aria/utils";
36
- import {useMemo as $gfhJl$useMemo, useState as $gfhJl$useState, useCallback as $gfhJl$useCallback} from "react";
37
- import {privateValidationStateProp as $gfhJl$privateValidationStateProp} from "@react-stately/form";
38
- import {useFocus as $gfhJl$useFocus, useFocusWithin as $gfhJl$useFocusWithin, useScrollWheel as $gfhJl$useScrollWheel} from "@react-aria/interactions";
39
- import {useFormattedTextField as $gfhJl$useFormattedTextField} from "@react-aria/textfield";
40
- import {useLocalizedStringFormatter as $gfhJl$useLocalizedStringFormatter, useNumberFormatter as $gfhJl$useNumberFormatter} from "@react-aria/i18n";
41
- import {useSpinButton as $gfhJl$useSpinButton} from "@react-aria/spinbutton";
1
+ import {useNumberField as $81397a9303501bda$export$23f548e970bdf099} from "./useNumberField.module.js";
42
2
 
43
-
44
- function $parcel$interopDefault(a) {
45
- return a && a.__esModule ? a.default : a;
46
- }
47
3
  /*
48
- * Copyright 2020 Adobe. All rights reserved.
49
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
50
- * you may not use this file except in compliance with the License. You may obtain a copy
51
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
52
- *
53
- * Unless required by applicable law or agreed to in writing, software distributed under
54
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
55
- * OF ANY KIND, either express or implied. See the License for the specific language
56
- * governing permissions and limitations under the License.
57
- */ /*
58
4
  * Copyright 2020 Adobe. All rights reserved.
59
5
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
60
6
  * you may not use this file except in compliance with the License. You may obtain a copy
@@ -66,296 +12,6 @@ function $parcel$interopDefault(a) {
66
12
  * governing permissions and limitations under the License.
67
13
  */
68
14
 
69
- var $280a227d7cb94b92$exports = {};
70
-
71
-
72
-
73
-
74
-
75
-
76
-
77
-
78
-
79
-
80
-
81
-
82
-
83
-
84
-
85
-
86
-
87
-
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
-
96
-
97
-
98
-
99
-
100
-
101
-
102
-
103
-
104
- $280a227d7cb94b92$exports = {
105
- "ar-AE": $fb78e0f6ab6349ed$exports,
106
- "bg-BG": $2776acdd9959a647$exports,
107
- "cs-CZ": $741954410a365ad3$exports,
108
- "da-DK": $8321ed0f8ab642f0$exports,
109
- "de-DE": $92978e0c4ecafa32$exports,
110
- "el-GR": $ac5ff71962864a84$exports,
111
- "en-US": $efe4685e2440d8be$exports,
112
- "es-ES": $e50a9a48739b90e1$exports,
113
- "et-EE": $6e0d5294ecbb8ab6$exports,
114
- "fi-FI": $e7129d65f607f77f$exports,
115
- "fr-FR": $d72adf5b20573e34$exports,
116
- "he-IL": $a25c707e88b844a7$exports,
117
- "hr-HR": $69b41140b9a4ca54$exports,
118
- "hu-HU": $81dab28f37f59d1a$exports,
119
- "it-IT": $866555b31f2d7711$exports,
120
- "ja-JP": $dafcd55d52b9d371$exports,
121
- "ko-KR": $f090c1f8c5da0145$exports,
122
- "lt-LT": $6f10f3a13360a75c$exports,
123
- "lv-LV": $47432cefd4b7bd1b$exports,
124
- "nb-NO": $dc578a950a2bf23d$exports,
125
- "nl-NL": $353f1bfca4dc395a$exports,
126
- "pl-PL": $241bc0bbd870e982$exports,
127
- "pt-BR": $da3005c7bd72b0a8$exports,
128
- "pt-PT": $cf48bfc540882310$exports,
129
- "ro-RO": $b63a28c481ab9ee3$exports,
130
- "ru-RU": $19f9df95c2464ab6$exports,
131
- "sk-SK": $b272932a685e8482$exports,
132
- "sl-SI": $cbaf8b5b61f9e544$exports,
133
- "sr-SP": $e0a3af6ac1449b2f$exports,
134
- "sv-SE": $71e167d2458a6019$exports,
135
- "tr-TR": $3719245abc082946$exports,
136
- "uk-UA": $2ccc589e2f51824d$exports,
137
- "zh-CN": $e1103cb9b4c13942$exports,
138
- "zh-TW": $448607634f80dccb$exports
139
- };
140
-
141
-
142
-
143
-
144
-
145
-
146
-
147
- function $81397a9303501bda$export$23f548e970bdf099(props, state, inputRef) {
148
- 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;
149
- let { increment: increment, incrementToMax: incrementToMax, decrement: decrement, decrementToMin: decrementToMin, numberValue: numberValue, inputValue: inputValue, commit: commit, commitValidation: commitValidation } = state;
150
- const stringFormatter = (0, $gfhJl$useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($280a227d7cb94b92$exports))), "@react-aria/numberfield");
151
- let inputId = (0, $gfhJl$useId)(id);
152
- let { focusProps: focusProps } = (0, $gfhJl$useFocus)({
153
- onBlur () {
154
- // Set input value to normalized valid value
155
- commit();
156
- }
157
- });
158
- let numberFormatter = (0, $gfhJl$useNumberFormatter)(formatOptions);
159
- let intlOptions = (0, $gfhJl$useMemo)(()=>numberFormatter.resolvedOptions(), [
160
- numberFormatter
161
- ]);
162
- // Replace negative textValue formatted using currencySign: 'accounting'
163
- // with a textValue that can be announced using a minus sign.
164
- let textValueFormatter = (0, $gfhJl$useNumberFormatter)({
165
- ...formatOptions,
166
- currencySign: undefined
167
- });
168
- let textValue = (0, $gfhJl$useMemo)(()=>isNaN(numberValue) ? "" : textValueFormatter.format(numberValue), [
169
- textValueFormatter,
170
- numberValue
171
- ]);
172
- let { spinButtonProps: spinButtonProps, incrementButtonProps: incButtonProps, decrementButtonProps: decButtonProps } = (0, $gfhJl$useSpinButton)({
173
- isDisabled: isDisabled,
174
- isReadOnly: isReadOnly,
175
- isRequired: isRequired,
176
- maxValue: maxValue,
177
- minValue: minValue,
178
- onIncrement: increment,
179
- onIncrementToMax: incrementToMax,
180
- onDecrement: decrement,
181
- onDecrementToMin: decrementToMin,
182
- value: numberValue,
183
- textValue: textValue
184
- });
185
- let [focusWithin, setFocusWithin] = (0, $gfhJl$useState)(false);
186
- let { focusWithinProps: focusWithinProps } = (0, $gfhJl$useFocusWithin)({
187
- isDisabled: isDisabled,
188
- onFocusWithinChange: setFocusWithin
189
- });
190
- let onWheel = (0, $gfhJl$useCallback)((e)=>{
191
- // if on a trackpad, users can scroll in both X and Y at once, check the magnitude of the change
192
- // if it's mostly in the X direction, then just return, the user probably doesn't mean to inc/dec
193
- // this isn't perfect, events come in fast with small deltas and a part of the scroll may give a false indication
194
- // especially if the user is scrolling near 45deg
195
- if (Math.abs(e.deltaY) <= Math.abs(e.deltaX)) return;
196
- if (e.deltaY > 0) increment();
197
- else if (e.deltaY < 0) decrement();
198
- }, [
199
- decrement,
200
- increment
201
- ]);
202
- // If the input isn't supposed to receive input, disable scrolling.
203
- let scrollingDisabled = isWheelDisabled || isDisabled || isReadOnly || !focusWithin;
204
- (0, $gfhJl$useScrollWheel)({
205
- onScroll: onWheel,
206
- isDisabled: scrollingDisabled
207
- }, inputRef);
208
- // The inputMode attribute influences the software keyboard that is shown on touch devices.
209
- // Browsers and operating systems are quite inconsistent about what keys are available, however.
210
- // We choose between numeric and decimal based on whether we allow negative and fractional numbers,
211
- // and based on testing on various devices to determine what keys are available in each inputMode.
212
- let hasDecimals = intlOptions.maximumFractionDigits > 0;
213
- let hasNegative = state.minValue === undefined || isNaN(state.minValue) || state.minValue < 0;
214
- let inputMode = "numeric";
215
- if ((0, $gfhJl$isIPhone)()) {
216
- // iPhone doesn't have a minus sign in either numeric or decimal.
217
- // Note this is only for iPhone, not iPad, which always has both
218
- // minus and decimal in numeric.
219
- if (hasNegative) inputMode = "text";
220
- else if (hasDecimals) inputMode = "decimal";
221
- } else if ((0, $gfhJl$isAndroid)()) {
222
- // Android numeric has both a decimal point and minus key.
223
- // decimal does not have a minus key.
224
- if (hasNegative) inputMode = "numeric";
225
- else if (hasDecimals) inputMode = "decimal";
226
- }
227
- let onChange = (value)=>{
228
- if (state.validate(value)) state.setInputValue(value);
229
- };
230
- let domProps = (0, $gfhJl$filterDOMProps)(props);
231
- let onKeyDownEnter = (0, $gfhJl$useCallback)((e)=>{
232
- if (e.key === "Enter") {
233
- commit();
234
- commitValidation();
235
- } else e.continuePropagation();
236
- }, [
237
- commit,
238
- commitValidation
239
- ]);
240
- let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = state.displayValidation;
241
- let { labelProps: labelProps, inputProps: textFieldProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $gfhJl$useFormattedTextField)({
242
- ...otherProps,
243
- ...domProps,
244
- name: undefined,
245
- label: label,
246
- autoFocus: autoFocus,
247
- isDisabled: isDisabled,
248
- isReadOnly: isReadOnly,
249
- isRequired: isRequired,
250
- validate: undefined,
251
- [(0, $gfhJl$privateValidationStateProp)]: state,
252
- value: inputValue,
253
- defaultValue: undefined,
254
- autoComplete: "off",
255
- "aria-label": props["aria-label"] || undefined,
256
- "aria-labelledby": props["aria-labelledby"] || undefined,
257
- id: inputId,
258
- type: "text",
259
- inputMode: inputMode,
260
- onChange: onChange,
261
- onBlur: onBlur,
262
- onFocus: onFocus,
263
- onFocusChange: onFocusChange,
264
- onKeyDown: (0, $gfhJl$useMemo)(()=>(0, $gfhJl$chain)(onKeyDownEnter, onKeyDown), [
265
- onKeyDownEnter,
266
- onKeyDown
267
- ]),
268
- onKeyUp: onKeyUp,
269
- description: description,
270
- errorMessage: errorMessage
271
- }, state, inputRef);
272
- (0, $gfhJl$useFormReset)(inputRef, state.numberValue, state.setNumberValue);
273
- let inputProps = (0, $gfhJl$mergeProps)(spinButtonProps, focusProps, textFieldProps, {
274
- // override the spinbutton role, we can't focus a spin button with VO
275
- role: null,
276
- // ignore aria-roledescription on iOS so that required state will announce when it is present
277
- "aria-roledescription": !(0, $gfhJl$isIOS)() ? stringFormatter.format("numberField") : null,
278
- "aria-valuemax": null,
279
- "aria-valuemin": null,
280
- "aria-valuenow": null,
281
- "aria-valuetext": null,
282
- autoCorrect: "off",
283
- spellCheck: "false"
284
- });
285
- if (props.validationBehavior === "native") inputProps["aria-required"] = undefined;
286
- let onButtonPressStart = (e)=>{
287
- var _inputRef_current;
288
- // If focus is already on the input, keep it there so we don't hide the
289
- // software keyboard when tapping the increment/decrement buttons.
290
- if (document.activeElement === inputRef.current) return;
291
- // Otherwise, when using a mouse, move focus to the input.
292
- // On touch, or with a screen reader, focus the button so that the software
293
- // keyboard does not appear and the screen reader cursor is not moved off the button.
294
- if (e.pointerType === "mouse") (_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.focus();
295
- else e.target.focus();
296
- };
297
- // Determine the label for the increment and decrement buttons. There are 4 cases:
298
- //
299
- // 1. With a visible label that is a string: aria-label: `Increase ${props.label}`
300
- // 2. With a visible label that is JSX: aria-label: 'Increase', aria-labelledby: '${incrementId} ${labelId}'
301
- // 3. With an aria-label: aria-label: `Increase ${props['aria-label']}`
302
- // 4. With an aria-labelledby: aria-label: 'Increase', aria-labelledby: `${incrementId} ${props['aria-labelledby']}`
303
- //
304
- // (1) and (2) could possibly be combined and both use aria-labelledby. However, placing the label in
305
- // the aria-label string rather than using aria-labelledby gives more flexibility to translators to change
306
- // the order or add additional words around the label if needed.
307
- let fieldLabel = props["aria-label"] || (typeof props.label === "string" ? props.label : "");
308
- let ariaLabelledby;
309
- if (!fieldLabel) ariaLabelledby = props.label != null ? labelProps.id : props["aria-labelledby"];
310
- let incrementId = (0, $gfhJl$useId)();
311
- let decrementId = (0, $gfhJl$useId)();
312
- let incrementButtonProps = (0, $gfhJl$mergeProps)(incButtonProps, {
313
- "aria-label": incrementAriaLabel || stringFormatter.format("increase", {
314
- fieldLabel: fieldLabel
315
- }).trim(),
316
- id: ariaLabelledby && !incrementAriaLabel ? incrementId : null,
317
- "aria-labelledby": ariaLabelledby && !incrementAriaLabel ? `${incrementId} ${ariaLabelledby}` : null,
318
- "aria-controls": inputId,
319
- excludeFromTabOrder: true,
320
- preventFocusOnPress: true,
321
- allowFocusWhenDisabled: true,
322
- isDisabled: !state.canIncrement,
323
- onPressStart: onButtonPressStart
324
- });
325
- let decrementButtonProps = (0, $gfhJl$mergeProps)(decButtonProps, {
326
- "aria-label": decrementAriaLabel || stringFormatter.format("decrease", {
327
- fieldLabel: fieldLabel
328
- }).trim(),
329
- id: ariaLabelledby && !decrementAriaLabel ? decrementId : null,
330
- "aria-labelledby": ariaLabelledby && !decrementAriaLabel ? `${decrementId} ${ariaLabelledby}` : null,
331
- "aria-controls": inputId,
332
- excludeFromTabOrder: true,
333
- preventFocusOnPress: true,
334
- allowFocusWhenDisabled: true,
335
- isDisabled: !state.canDecrement,
336
- onPressStart: onButtonPressStart
337
- });
338
- return {
339
- groupProps: {
340
- ...focusWithinProps,
341
- role: "group",
342
- "aria-disabled": isDisabled,
343
- "aria-invalid": isInvalid ? "true" : undefined
344
- },
345
- labelProps: labelProps,
346
- inputProps: inputProps,
347
- incrementButtonProps: incrementButtonProps,
348
- decrementButtonProps: decrementButtonProps,
349
- errorMessageProps: errorMessageProps,
350
- descriptionProps: descriptionProps,
351
- isInvalid: isInvalid,
352
- validationErrors: validationErrors,
353
- validationDetails: validationDetails
354
- };
355
- }
356
-
357
-
358
-
359
15
 
360
16
  export {$81397a9303501bda$export$23f548e970bdf099 as useNumberField};
361
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MAAM,CAAC,YAAY;wBAAC;QAAU,GAAG,IAAI;QACzF,IAAI,kBAAkB,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,IAAI,uBAAwC,CAAA,GAAA,iBAAS,EAAE,gBAAgB;QACrE,cAAc,sBAAsB,gBAAgB,MAAM,CAAC,YAAY;wBAAC;QAAU,GAAG,IAAI;QACzF,IAAI,kBAAkB,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;;CD1TC","sources":["packages/@react-aria/numberfield/src/index.ts","packages/@react-aria/numberfield/src/useNumberField.ts","packages/@react-aria/numberfield/src/*.js"],"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 */\nexport {useNumberField} from './useNumberField';\nexport type {AriaNumberFieldProps} from '@react-types/numberfield';\nexport type {NumberFieldAria} from './useNumberField';\n","/*\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","const _temp0 = require(\"../intl/ar-AE.json\");\nconst _temp1 = require(\"../intl/bg-BG.json\");\nconst _temp2 = require(\"../intl/cs-CZ.json\");\nconst _temp3 = require(\"../intl/da-DK.json\");\nconst _temp4 = require(\"../intl/de-DE.json\");\nconst _temp5 = require(\"../intl/el-GR.json\");\nconst _temp6 = require(\"../intl/en-US.json\");\nconst _temp7 = require(\"../intl/es-ES.json\");\nconst _temp8 = require(\"../intl/et-EE.json\");\nconst _temp9 = require(\"../intl/fi-FI.json\");\nconst _temp10 = require(\"../intl/fr-FR.json\");\nconst _temp11 = require(\"../intl/he-IL.json\");\nconst _temp12 = require(\"../intl/hr-HR.json\");\nconst _temp13 = require(\"../intl/hu-HU.json\");\nconst _temp14 = require(\"../intl/it-IT.json\");\nconst _temp15 = require(\"../intl/ja-JP.json\");\nconst _temp16 = require(\"../intl/ko-KR.json\");\nconst _temp17 = require(\"../intl/lt-LT.json\");\nconst _temp18 = require(\"../intl/lv-LV.json\");\nconst _temp19 = require(\"../intl/nb-NO.json\");\nconst _temp20 = require(\"../intl/nl-NL.json\");\nconst _temp21 = require(\"../intl/pl-PL.json\");\nconst _temp22 = require(\"../intl/pt-BR.json\");\nconst _temp23 = require(\"../intl/pt-PT.json\");\nconst _temp24 = require(\"../intl/ro-RO.json\");\nconst _temp25 = require(\"../intl/ru-RU.json\");\nconst _temp26 = require(\"../intl/sk-SK.json\");\nconst _temp27 = require(\"../intl/sl-SI.json\");\nconst _temp28 = require(\"../intl/sr-SP.json\");\nconst _temp29 = require(\"../intl/sv-SE.json\");\nconst _temp30 = require(\"../intl/tr-TR.json\");\nconst _temp31 = require(\"../intl/uk-UA.json\");\nconst _temp32 = require(\"../intl/zh-CN.json\");\nconst _temp33 = require(\"../intl/zh-TW.json\");\nmodule.exports = {\n \"ar-AE\": _temp0,\n \"bg-BG\": _temp1,\n \"cs-CZ\": _temp2,\n \"da-DK\": _temp3,\n \"de-DE\": _temp4,\n \"el-GR\": _temp5,\n \"en-US\": _temp6,\n \"es-ES\": _temp7,\n \"et-EE\": _temp8,\n \"fi-FI\": _temp9,\n \"fr-FR\": _temp10,\n \"he-IL\": _temp11,\n \"hr-HR\": _temp12,\n \"hu-HU\": _temp13,\n \"it-IT\": _temp14,\n \"ja-JP\": _temp15,\n \"ko-KR\": _temp16,\n \"lt-LT\": _temp17,\n \"lv-LV\": _temp18,\n \"nb-NO\": _temp19,\n \"nl-NL\": _temp20,\n \"pl-PL\": _temp21,\n \"pt-BR\": _temp22,\n \"pt-PT\": _temp23,\n \"ro-RO\": _temp24,\n \"ru-RU\": _temp25,\n \"sk-SK\": _temp26,\n \"sl-SI\": _temp27,\n \"sr-SP\": _temp28,\n \"sv-SE\": _temp29,\n \"tr-TR\": _temp30,\n \"uk-UA\": _temp31,\n \"zh-CN\": _temp32,\n \"zh-TW\": _temp33\n}"],"names":[],"version":3,"file":"module.js.map"}
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/numberfield/src/index.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 */\nexport {useNumberField} from './useNumberField';\nexport type {AriaNumberFieldProps} from '@react-types/numberfield';\nexport type {NumberFieldAria} from './useNumberField';\n"],"names":[],"version":3,"file":"module.js.map"}
@@ -0,0 +1,249 @@
1
+ var $4932e21065cdc2cd$exports = require("./intlStrings.main.js");
2
+ var $9WaOX$reactariautils = require("@react-aria/utils");
3
+ var $9WaOX$react = require("react");
4
+ var $9WaOX$reactstatelyform = require("@react-stately/form");
5
+ var $9WaOX$reactariainteractions = require("@react-aria/interactions");
6
+ var $9WaOX$reactariatextfield = require("@react-aria/textfield");
7
+ var $9WaOX$reactariai18n = require("@react-aria/i18n");
8
+ var $9WaOX$reactariaspinbutton = require("@react-aria/spinbutton");
9
+
10
+
11
+ function $parcel$interopDefault(a) {
12
+ return a && a.__esModule ? a.default : a;
13
+ }
14
+
15
+ function $parcel$export(e, n, v, s) {
16
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
17
+ }
18
+
19
+ $parcel$export(module.exports, "useNumberField", () => $fa863e9b015ae839$export$23f548e970bdf099);
20
+ /*
21
+ * Copyright 2020 Adobe. All rights reserved.
22
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
23
+ * you may not use this file except in compliance with the License. You may obtain a copy
24
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
25
+ *
26
+ * Unless required by applicable law or agreed to in writing, software distributed under
27
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
28
+ * OF ANY KIND, either express or implied. See the License for the specific language
29
+ * governing permissions and limitations under the License.
30
+ */
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+ function $fa863e9b015ae839$export$23f548e970bdf099(props, state, inputRef) {
39
+ 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;
40
+ let { increment: increment, incrementToMax: incrementToMax, decrement: decrement, decrementToMin: decrementToMin, numberValue: numberValue, inputValue: inputValue, commit: commit, commitValidation: commitValidation } = state;
41
+ const stringFormatter = (0, $9WaOX$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($4932e21065cdc2cd$exports))), '@react-aria/numberfield');
42
+ let inputId = (0, $9WaOX$reactariautils.useId)(id);
43
+ let { focusProps: focusProps } = (0, $9WaOX$reactariainteractions.useFocus)({
44
+ onBlur () {
45
+ // Set input value to normalized valid value
46
+ commit();
47
+ }
48
+ });
49
+ let numberFormatter = (0, $9WaOX$reactariai18n.useNumberFormatter)(formatOptions);
50
+ let intlOptions = (0, $9WaOX$react.useMemo)(()=>numberFormatter.resolvedOptions(), [
51
+ numberFormatter
52
+ ]);
53
+ // Replace negative textValue formatted using currencySign: 'accounting'
54
+ // with a textValue that can be announced using a minus sign.
55
+ let textValueFormatter = (0, $9WaOX$reactariai18n.useNumberFormatter)({
56
+ ...formatOptions,
57
+ currencySign: undefined
58
+ });
59
+ let textValue = (0, $9WaOX$react.useMemo)(()=>isNaN(numberValue) ? '' : textValueFormatter.format(numberValue), [
60
+ textValueFormatter,
61
+ numberValue
62
+ ]);
63
+ let { spinButtonProps: spinButtonProps, incrementButtonProps: incButtonProps, decrementButtonProps: decButtonProps } = (0, $9WaOX$reactariaspinbutton.useSpinButton)({
64
+ isDisabled: isDisabled,
65
+ isReadOnly: isReadOnly,
66
+ isRequired: isRequired,
67
+ maxValue: maxValue,
68
+ minValue: minValue,
69
+ onIncrement: increment,
70
+ onIncrementToMax: incrementToMax,
71
+ onDecrement: decrement,
72
+ onDecrementToMin: decrementToMin,
73
+ value: numberValue,
74
+ textValue: textValue
75
+ });
76
+ let [focusWithin, setFocusWithin] = (0, $9WaOX$react.useState)(false);
77
+ let { focusWithinProps: focusWithinProps } = (0, $9WaOX$reactariainteractions.useFocusWithin)({
78
+ isDisabled: isDisabled,
79
+ onFocusWithinChange: setFocusWithin
80
+ });
81
+ let onWheel = (0, $9WaOX$react.useCallback)((e)=>{
82
+ // if on a trackpad, users can scroll in both X and Y at once, check the magnitude of the change
83
+ // if it's mostly in the X direction, then just return, the user probably doesn't mean to inc/dec
84
+ // this isn't perfect, events come in fast with small deltas and a part of the scroll may give a false indication
85
+ // especially if the user is scrolling near 45deg
86
+ if (Math.abs(e.deltaY) <= Math.abs(e.deltaX)) return;
87
+ if (e.deltaY > 0) increment();
88
+ else if (e.deltaY < 0) decrement();
89
+ }, [
90
+ decrement,
91
+ increment
92
+ ]);
93
+ // If the input isn't supposed to receive input, disable scrolling.
94
+ let scrollingDisabled = isWheelDisabled || isDisabled || isReadOnly || !focusWithin;
95
+ (0, $9WaOX$reactariainteractions.useScrollWheel)({
96
+ onScroll: onWheel,
97
+ isDisabled: scrollingDisabled
98
+ }, inputRef);
99
+ // The inputMode attribute influences the software keyboard that is shown on touch devices.
100
+ // Browsers and operating systems are quite inconsistent about what keys are available, however.
101
+ // We choose between numeric and decimal based on whether we allow negative and fractional numbers,
102
+ // and based on testing on various devices to determine what keys are available in each inputMode.
103
+ let hasDecimals = intlOptions.maximumFractionDigits > 0;
104
+ let hasNegative = state.minValue === undefined || isNaN(state.minValue) || state.minValue < 0;
105
+ let inputMode = 'numeric';
106
+ if ((0, $9WaOX$reactariautils.isIPhone)()) {
107
+ // iPhone doesn't have a minus sign in either numeric or decimal.
108
+ // Note this is only for iPhone, not iPad, which always has both
109
+ // minus and decimal in numeric.
110
+ if (hasNegative) inputMode = 'text';
111
+ else if (hasDecimals) inputMode = 'decimal';
112
+ } else if ((0, $9WaOX$reactariautils.isAndroid)()) {
113
+ // Android numeric has both a decimal point and minus key.
114
+ // decimal does not have a minus key.
115
+ if (hasNegative) inputMode = 'numeric';
116
+ else if (hasDecimals) inputMode = 'decimal';
117
+ }
118
+ let onChange = (value)=>{
119
+ if (state.validate(value)) state.setInputValue(value);
120
+ };
121
+ let domProps = (0, $9WaOX$reactariautils.filterDOMProps)(props);
122
+ let onKeyDownEnter = (0, $9WaOX$react.useCallback)((e)=>{
123
+ if (e.key === 'Enter') {
124
+ commit();
125
+ commitValidation();
126
+ } else e.continuePropagation();
127
+ }, [
128
+ commit,
129
+ commitValidation
130
+ ]);
131
+ let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = state.displayValidation;
132
+ let { labelProps: labelProps, inputProps: textFieldProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $9WaOX$reactariatextfield.useFormattedTextField)({
133
+ ...otherProps,
134
+ ...domProps,
135
+ name: undefined,
136
+ label: label,
137
+ autoFocus: autoFocus,
138
+ isDisabled: isDisabled,
139
+ isReadOnly: isReadOnly,
140
+ isRequired: isRequired,
141
+ validate: undefined,
142
+ [(0, $9WaOX$reactstatelyform.privateValidationStateProp)]: state,
143
+ value: inputValue,
144
+ defaultValue: undefined,
145
+ autoComplete: 'off',
146
+ 'aria-label': props['aria-label'] || undefined,
147
+ 'aria-labelledby': props['aria-labelledby'] || undefined,
148
+ id: inputId,
149
+ type: 'text',
150
+ inputMode: inputMode,
151
+ onChange: onChange,
152
+ onBlur: onBlur,
153
+ onFocus: onFocus,
154
+ onFocusChange: onFocusChange,
155
+ onKeyDown: (0, $9WaOX$react.useMemo)(()=>(0, $9WaOX$reactariautils.chain)(onKeyDownEnter, onKeyDown), [
156
+ onKeyDownEnter,
157
+ onKeyDown
158
+ ]),
159
+ onKeyUp: onKeyUp,
160
+ description: description,
161
+ errorMessage: errorMessage
162
+ }, state, inputRef);
163
+ (0, $9WaOX$reactariautils.useFormReset)(inputRef, state.numberValue, state.setNumberValue);
164
+ let inputProps = (0, $9WaOX$reactariautils.mergeProps)(spinButtonProps, focusProps, textFieldProps, {
165
+ // override the spinbutton role, we can't focus a spin button with VO
166
+ role: null,
167
+ // ignore aria-roledescription on iOS so that required state will announce when it is present
168
+ 'aria-roledescription': !(0, $9WaOX$reactariautils.isIOS)() ? stringFormatter.format('numberField') : null,
169
+ 'aria-valuemax': null,
170
+ 'aria-valuemin': null,
171
+ 'aria-valuenow': null,
172
+ 'aria-valuetext': null,
173
+ autoCorrect: 'off',
174
+ spellCheck: 'false'
175
+ });
176
+ if (props.validationBehavior === 'native') inputProps['aria-required'] = undefined;
177
+ let onButtonPressStart = (e)=>{
178
+ var _inputRef_current;
179
+ // If focus is already on the input, keep it there so we don't hide the
180
+ // software keyboard when tapping the increment/decrement buttons.
181
+ if (document.activeElement === inputRef.current) return;
182
+ // Otherwise, when using a mouse, move focus to the input.
183
+ // On touch, or with a screen reader, focus the button so that the software
184
+ // keyboard does not appear and the screen reader cursor is not moved off the button.
185
+ if (e.pointerType === 'mouse') (_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.focus();
186
+ else e.target.focus();
187
+ };
188
+ // Determine the label for the increment and decrement buttons. There are 4 cases:
189
+ //
190
+ // 1. With a visible label that is a string: aria-label: `Increase ${props.label}`
191
+ // 2. With a visible label that is JSX: aria-label: 'Increase', aria-labelledby: '${incrementId} ${labelId}'
192
+ // 3. With an aria-label: aria-label: `Increase ${props['aria-label']}`
193
+ // 4. With an aria-labelledby: aria-label: 'Increase', aria-labelledby: `${incrementId} ${props['aria-labelledby']}`
194
+ //
195
+ // (1) and (2) could possibly be combined and both use aria-labelledby. However, placing the label in
196
+ // the aria-label string rather than using aria-labelledby gives more flexibility to translators to change
197
+ // the order or add additional words around the label if needed.
198
+ let fieldLabel = props['aria-label'] || (typeof props.label === 'string' ? props.label : '');
199
+ let ariaLabelledby;
200
+ if (!fieldLabel) ariaLabelledby = props.label != null ? labelProps.id : props['aria-labelledby'];
201
+ let incrementId = (0, $9WaOX$reactariautils.useId)();
202
+ let decrementId = (0, $9WaOX$reactariautils.useId)();
203
+ let incrementButtonProps = (0, $9WaOX$reactariautils.mergeProps)(incButtonProps, {
204
+ 'aria-label': incrementAriaLabel || stringFormatter.format('increase', {
205
+ fieldLabel: fieldLabel
206
+ }).trim(),
207
+ id: ariaLabelledby && !incrementAriaLabel ? incrementId : null,
208
+ 'aria-labelledby': ariaLabelledby && !incrementAriaLabel ? `${incrementId} ${ariaLabelledby}` : null,
209
+ 'aria-controls': inputId,
210
+ excludeFromTabOrder: true,
211
+ preventFocusOnPress: true,
212
+ allowFocusWhenDisabled: true,
213
+ isDisabled: !state.canIncrement,
214
+ onPressStart: onButtonPressStart
215
+ });
216
+ let decrementButtonProps = (0, $9WaOX$reactariautils.mergeProps)(decButtonProps, {
217
+ 'aria-label': decrementAriaLabel || stringFormatter.format('decrease', {
218
+ fieldLabel: fieldLabel
219
+ }).trim(),
220
+ id: ariaLabelledby && !decrementAriaLabel ? decrementId : null,
221
+ 'aria-labelledby': ariaLabelledby && !decrementAriaLabel ? `${decrementId} ${ariaLabelledby}` : null,
222
+ 'aria-controls': inputId,
223
+ excludeFromTabOrder: true,
224
+ preventFocusOnPress: true,
225
+ allowFocusWhenDisabled: true,
226
+ isDisabled: !state.canDecrement,
227
+ onPressStart: onButtonPressStart
228
+ });
229
+ return {
230
+ groupProps: {
231
+ ...focusWithinProps,
232
+ role: 'group',
233
+ 'aria-disabled': isDisabled,
234
+ 'aria-invalid': isInvalid ? 'true' : undefined
235
+ },
236
+ labelProps: labelProps,
237
+ inputProps: inputProps,
238
+ incrementButtonProps: incrementButtonProps,
239
+ decrementButtonProps: decrementButtonProps,
240
+ errorMessageProps: errorMessageProps,
241
+ descriptionProps: descriptionProps,
242
+ isInvalid: isInvalid,
243
+ validationErrors: validationErrors,
244
+ validationDetails: validationDetails
245
+ };
246
+ }
247
+
248
+
249
+ //# sourceMappingURL=useNumberField.main.js.map