@react-aria/numberfield 3.3.4 → 3.4.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 (2) hide show
  1. package/dist/import.mjs +532 -0
  2. package/package.json +18 -13
@@ -0,0 +1,532 @@
1
+ import {useId as $gfhJl$useId, isIPhone as $gfhJl$isIPhone, isAndroid as $gfhJl$isAndroid, filterDOMProps as $gfhJl$filterDOMProps, mergeProps as $gfhJl$mergeProps, isIOS as $gfhJl$isIOS} from "@react-aria/utils";
2
+ import {useState as $gfhJl$useState, useCallback as $gfhJl$useCallback, useMemo as $gfhJl$useMemo} from "react";
3
+ import {useFocus as $gfhJl$useFocus, useFocusWithin as $gfhJl$useFocusWithin, useScrollWheel as $gfhJl$useScrollWheel} from "@react-aria/interactions";
4
+ import {useFormattedTextField as $gfhJl$useFormattedTextField} from "@react-aria/textfield";
5
+ import {useLocalizedStringFormatter as $gfhJl$useLocalizedStringFormatter, useNumberFormatter as $gfhJl$useNumberFormatter} from "@react-aria/i18n";
6
+ import {useSpinButton as $gfhJl$useSpinButton} from "@react-aria/spinbutton";
7
+
8
+ function $parcel$interopDefault(a) {
9
+ return a && a.__esModule ? a.default : a;
10
+ }
11
+ /*
12
+ * Copyright 2020 Adobe. All rights reserved.
13
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
14
+ * you may not use this file except in compliance with the License. You may obtain a copy
15
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
16
+ *
17
+ * Unless required by applicable law or agreed to in writing, software distributed under
18
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
19
+ * OF ANY KIND, either express or implied. See the License for the specific language
20
+ * governing permissions and limitations under the License.
21
+ */ /*
22
+ * Copyright 2020 Adobe. All rights reserved.
23
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
24
+ * you may not use this file except in compliance with the License. You may obtain a copy
25
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
26
+ *
27
+ * Unless required by applicable law or agreed to in writing, software distributed under
28
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
29
+ * OF ANY KIND, either express or implied. See the License for the specific language
30
+ * governing permissions and limitations under the License.
31
+ */
32
+
33
+ var $c3ef0f8b54adbb57$exports = {};
34
+ var $fb78e0f6ab6349ed$exports = {};
35
+ $fb78e0f6ab6349ed$exports = {
36
+ "decrease": (args)=>`خفض ${args.fieldLabel}`,
37
+ "increase": (args)=>`زيادة ${args.fieldLabel}`,
38
+ "numberField": `حقل رقمي`
39
+ };
40
+
41
+
42
+ var $2776acdd9959a647$exports = {};
43
+ $2776acdd9959a647$exports = {
44
+ "decrease": (args)=>`Намаляване ${args.fieldLabel}`,
45
+ "increase": (args)=>`Усилване ${args.fieldLabel}`,
46
+ "numberField": `Номер на полето`
47
+ };
48
+
49
+
50
+ var $741954410a365ad3$exports = {};
51
+ $741954410a365ad3$exports = {
52
+ "decrease": (args)=>`Snížit ${args.fieldLabel}`,
53
+ "increase": (args)=>`Zvýšit ${args.fieldLabel}`,
54
+ "numberField": `Číselné pole`
55
+ };
56
+
57
+
58
+ var $8321ed0f8ab642f0$exports = {};
59
+ $8321ed0f8ab642f0$exports = {
60
+ "decrease": (args)=>`Reducer ${args.fieldLabel}`,
61
+ "increase": (args)=>`Øg ${args.fieldLabel}`,
62
+ "numberField": `Talfelt`
63
+ };
64
+
65
+
66
+ var $92978e0c4ecafa32$exports = {};
67
+ $92978e0c4ecafa32$exports = {
68
+ "decrease": (args)=>`${args.fieldLabel} verringern`,
69
+ "increase": (args)=>`${args.fieldLabel} erhöhen`,
70
+ "numberField": `Nummernfeld`
71
+ };
72
+
73
+
74
+ var $ac5ff71962864a84$exports = {};
75
+ $ac5ff71962864a84$exports = {
76
+ "decrease": (args)=>`Μείωση ${args.fieldLabel}`,
77
+ "increase": (args)=>`Αύξηση ${args.fieldLabel}`,
78
+ "numberField": `Πεδίο αριθμού`
79
+ };
80
+
81
+
82
+ var $efe4685e2440d8be$exports = {};
83
+ $efe4685e2440d8be$exports = {
84
+ "decrease": (args)=>`Decrease ${args.fieldLabel}`,
85
+ "increase": (args)=>`Increase ${args.fieldLabel}`,
86
+ "numberField": `Number field`
87
+ };
88
+
89
+
90
+ var $e50a9a48739b90e1$exports = {};
91
+ $e50a9a48739b90e1$exports = {
92
+ "decrease": (args)=>`Reducir ${args.fieldLabel}`,
93
+ "increase": (args)=>`Aumentar ${args.fieldLabel}`,
94
+ "numberField": `Campo de número`
95
+ };
96
+
97
+
98
+ var $6e0d5294ecbb8ab6$exports = {};
99
+ $6e0d5294ecbb8ab6$exports = {
100
+ "decrease": (args)=>`Vähenda ${args.fieldLabel}`,
101
+ "increase": (args)=>`Suurenda ${args.fieldLabel}`,
102
+ "numberField": `Numbri väli`
103
+ };
104
+
105
+
106
+ var $e7129d65f607f77f$exports = {};
107
+ $e7129d65f607f77f$exports = {
108
+ "decrease": (args)=>`Vähennä ${args.fieldLabel}`,
109
+ "increase": (args)=>`Lisää ${args.fieldLabel}`,
110
+ "numberField": `Numerokenttä`
111
+ };
112
+
113
+
114
+ var $d72adf5b20573e34$exports = {};
115
+ $d72adf5b20573e34$exports = {
116
+ "decrease": (args)=>`Diminuer ${args.fieldLabel}`,
117
+ "increase": (args)=>`Augmenter ${args.fieldLabel}`,
118
+ "numberField": `Champ de nombre`
119
+ };
120
+
121
+
122
+ var $a25c707e88b844a7$exports = {};
123
+ $a25c707e88b844a7$exports = {
124
+ "decrease": (args)=>`הקטן ${args.fieldLabel}`,
125
+ "increase": (args)=>`הגדל ${args.fieldLabel}`,
126
+ "numberField": `שדה מספר`
127
+ };
128
+
129
+
130
+ var $69b41140b9a4ca54$exports = {};
131
+ $69b41140b9a4ca54$exports = {
132
+ "decrease": (args)=>`Smanji ${args.fieldLabel}`,
133
+ "increase": (args)=>`Povećaj ${args.fieldLabel}`,
134
+ "numberField": `Polje broja`
135
+ };
136
+
137
+
138
+ var $81dab28f37f59d1a$exports = {};
139
+ $81dab28f37f59d1a$exports = {
140
+ "decrease": (args)=>`${args.fieldLabel} csökkentése`,
141
+ "increase": (args)=>`${args.fieldLabel} növelése`,
142
+ "numberField": `Számmező`
143
+ };
144
+
145
+
146
+ var $866555b31f2d7711$exports = {};
147
+ $866555b31f2d7711$exports = {
148
+ "decrease": (args)=>`Riduci ${args.fieldLabel}`,
149
+ "increase": (args)=>`Aumenta ${args.fieldLabel}`,
150
+ "numberField": `Campo numero`
151
+ };
152
+
153
+
154
+ var $dafcd55d52b9d371$exports = {};
155
+ $dafcd55d52b9d371$exports = {
156
+ "decrease": (args)=>`${args.fieldLabel}を縮小`,
157
+ "increase": (args)=>`${args.fieldLabel}を拡大`,
158
+ "numberField": `数値フィールド`
159
+ };
160
+
161
+
162
+ var $f090c1f8c5da0145$exports = {};
163
+ $f090c1f8c5da0145$exports = {
164
+ "decrease": (args)=>`${args.fieldLabel} 감소`,
165
+ "increase": (args)=>`${args.fieldLabel} 증가`,
166
+ "numberField": `번호 필드`
167
+ };
168
+
169
+
170
+ var $6f10f3a13360a75c$exports = {};
171
+ $6f10f3a13360a75c$exports = {
172
+ "decrease": (args)=>`Sumažinti ${args.fieldLabel}`,
173
+ "increase": (args)=>`Padidinti ${args.fieldLabel}`,
174
+ "numberField": `Numerio laukas`
175
+ };
176
+
177
+
178
+ var $47432cefd4b7bd1b$exports = {};
179
+ $47432cefd4b7bd1b$exports = {
180
+ "decrease": (args)=>`Samazināšana ${args.fieldLabel}`,
181
+ "increase": (args)=>`Palielināšana ${args.fieldLabel}`,
182
+ "numberField": `Skaitļu lauks`
183
+ };
184
+
185
+
186
+ var $dc578a950a2bf23d$exports = {};
187
+ $dc578a950a2bf23d$exports = {
188
+ "decrease": (args)=>`Reduser ${args.fieldLabel}`,
189
+ "increase": (args)=>`Øk ${args.fieldLabel}`,
190
+ "numberField": `Tallfelt`
191
+ };
192
+
193
+
194
+ var $353f1bfca4dc395a$exports = {};
195
+ $353f1bfca4dc395a$exports = {
196
+ "decrease": (args)=>`${args.fieldLabel} verlagen`,
197
+ "increase": (args)=>`${args.fieldLabel} verhogen`,
198
+ "numberField": `Getalveld`
199
+ };
200
+
201
+
202
+ var $241bc0bbd870e982$exports = {};
203
+ $241bc0bbd870e982$exports = {
204
+ "decrease": (args)=>`Zmniejsz ${args.fieldLabel}`,
205
+ "increase": (args)=>`Zwiększ ${args.fieldLabel}`,
206
+ "numberField": `Pole numeru`
207
+ };
208
+
209
+
210
+ var $da3005c7bd72b0a8$exports = {};
211
+ $da3005c7bd72b0a8$exports = {
212
+ "decrease": (args)=>`Diminuir ${args.fieldLabel}`,
213
+ "increase": (args)=>`Aumentar ${args.fieldLabel}`,
214
+ "numberField": `Campo de número`
215
+ };
216
+
217
+
218
+ var $cf48bfc540882310$exports = {};
219
+ $cf48bfc540882310$exports = {
220
+ "decrease": (args)=>`Diminuir ${args.fieldLabel}`,
221
+ "increase": (args)=>`Aumentar ${args.fieldLabel}`,
222
+ "numberField": `Campo numérico`
223
+ };
224
+
225
+
226
+ var $b63a28c481ab9ee3$exports = {};
227
+ $b63a28c481ab9ee3$exports = {
228
+ "decrease": (args)=>`Scădere ${args.fieldLabel}`,
229
+ "increase": (args)=>`Creștere ${args.fieldLabel}`,
230
+ "numberField": `Câmp numeric`
231
+ };
232
+
233
+
234
+ var $19f9df95c2464ab6$exports = {};
235
+ $19f9df95c2464ab6$exports = {
236
+ "decrease": (args)=>`Уменьшение ${args.fieldLabel}`,
237
+ "increase": (args)=>`Увеличение ${args.fieldLabel}`,
238
+ "numberField": `Числовое поле`
239
+ };
240
+
241
+
242
+ var $b272932a685e8482$exports = {};
243
+ $b272932a685e8482$exports = {
244
+ "decrease": (args)=>`Znížiť ${args.fieldLabel}`,
245
+ "increase": (args)=>`Zvýšiť ${args.fieldLabel}`,
246
+ "numberField": `Číselné pole`
247
+ };
248
+
249
+
250
+ var $cbaf8b5b61f9e544$exports = {};
251
+ $cbaf8b5b61f9e544$exports = {
252
+ "decrease": (args)=>`Upadati ${args.fieldLabel}`,
253
+ "increase": (args)=>`Povečajte ${args.fieldLabel}`,
254
+ "numberField": `Številčno polje`
255
+ };
256
+
257
+
258
+ var $e0a3af6ac1449b2f$exports = {};
259
+ $e0a3af6ac1449b2f$exports = {
260
+ "decrease": (args)=>`Decrease ${args.fieldLabel}`,
261
+ "increase": (args)=>`Increase ${args.fieldLabel}`,
262
+ "numberField": `Number field`
263
+ };
264
+
265
+
266
+ var $71e167d2458a6019$exports = {};
267
+ $71e167d2458a6019$exports = {
268
+ "decrease": (args)=>`Minska ${args.fieldLabel}`,
269
+ "increase": (args)=>`Öka ${args.fieldLabel}`,
270
+ "numberField": `Nummerfält`
271
+ };
272
+
273
+
274
+ var $3719245abc082946$exports = {};
275
+ $3719245abc082946$exports = {
276
+ "decrease": (args)=>`${args.fieldLabel} azalt`,
277
+ "increase": (args)=>`${args.fieldLabel} arttır`,
278
+ "numberField": `Sayı alanı`
279
+ };
280
+
281
+
282
+ var $2ccc589e2f51824d$exports = {};
283
+ $2ccc589e2f51824d$exports = {
284
+ "decrease": (args)=>`Зменшити ${args.fieldLabel}`,
285
+ "increase": (args)=>`Збільшити ${args.fieldLabel}`,
286
+ "numberField": `Поле номера`
287
+ };
288
+
289
+
290
+ var $e1103cb9b4c13942$exports = {};
291
+ $e1103cb9b4c13942$exports = {
292
+ "decrease": (args)=>`降低 ${args.fieldLabel}`,
293
+ "increase": (args)=>`提高 ${args.fieldLabel}`,
294
+ "numberField": `数字字段`
295
+ };
296
+
297
+
298
+ var $448607634f80dccb$exports = {};
299
+ $448607634f80dccb$exports = {
300
+ "decrease": (args)=>`縮小 ${args.fieldLabel}`,
301
+ "increase": (args)=>`放大 ${args.fieldLabel}`,
302
+ "numberField": `數字欄位`
303
+ };
304
+
305
+
306
+ $c3ef0f8b54adbb57$exports = {
307
+ "ar-AE": $fb78e0f6ab6349ed$exports,
308
+ "bg-BG": $2776acdd9959a647$exports,
309
+ "cs-CZ": $741954410a365ad3$exports,
310
+ "da-DK": $8321ed0f8ab642f0$exports,
311
+ "de-DE": $92978e0c4ecafa32$exports,
312
+ "el-GR": $ac5ff71962864a84$exports,
313
+ "en-US": $efe4685e2440d8be$exports,
314
+ "es-ES": $e50a9a48739b90e1$exports,
315
+ "et-EE": $6e0d5294ecbb8ab6$exports,
316
+ "fi-FI": $e7129d65f607f77f$exports,
317
+ "fr-FR": $d72adf5b20573e34$exports,
318
+ "he-IL": $a25c707e88b844a7$exports,
319
+ "hr-HR": $69b41140b9a4ca54$exports,
320
+ "hu-HU": $81dab28f37f59d1a$exports,
321
+ "it-IT": $866555b31f2d7711$exports,
322
+ "ja-JP": $dafcd55d52b9d371$exports,
323
+ "ko-KR": $f090c1f8c5da0145$exports,
324
+ "lt-LT": $6f10f3a13360a75c$exports,
325
+ "lv-LV": $47432cefd4b7bd1b$exports,
326
+ "nb-NO": $dc578a950a2bf23d$exports,
327
+ "nl-NL": $353f1bfca4dc395a$exports,
328
+ "pl-PL": $241bc0bbd870e982$exports,
329
+ "pt-BR": $da3005c7bd72b0a8$exports,
330
+ "pt-PT": $cf48bfc540882310$exports,
331
+ "ro-RO": $b63a28c481ab9ee3$exports,
332
+ "ru-RU": $19f9df95c2464ab6$exports,
333
+ "sk-SK": $b272932a685e8482$exports,
334
+ "sl-SI": $cbaf8b5b61f9e544$exports,
335
+ "sr-SP": $e0a3af6ac1449b2f$exports,
336
+ "sv-SE": $71e167d2458a6019$exports,
337
+ "tr-TR": $3719245abc082946$exports,
338
+ "uk-UA": $2ccc589e2f51824d$exports,
339
+ "zh-CN": $e1103cb9b4c13942$exports,
340
+ "zh-TW": $448607634f80dccb$exports
341
+ };
342
+
343
+
344
+
345
+
346
+
347
+
348
+
349
+ function $81397a9303501bda$export$23f548e970bdf099(props, state, inputRef) {
350
+ let { id: id , decrementAriaLabel: decrementAriaLabel , incrementAriaLabel: incrementAriaLabel , isDisabled: isDisabled , isReadOnly: isReadOnly , isRequired: isRequired , minValue: minValue , maxValue: maxValue , autoFocus: autoFocus , validationState: validationState , label: label , formatOptions: formatOptions , onBlur: onBlur = ()=>{} , onFocus: onFocus , onFocusChange: onFocusChange , onKeyDown: onKeyDown , onKeyUp: onKeyUp , description: description , errorMessage: errorMessage , ...otherProps } = props;
351
+ let { increment: increment , incrementToMax: incrementToMax , decrement: decrement , decrementToMin: decrementToMin , numberValue: numberValue , commit: commit } = state;
352
+ const stringFormatter = (0, $gfhJl$useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($c3ef0f8b54adbb57$exports))));
353
+ let inputId = (0, $gfhJl$useId)(id);
354
+ let { focusProps: focusProps } = (0, $gfhJl$useFocus)({
355
+ onBlur: ()=>{
356
+ // Set input value to normalized valid value
357
+ commit();
358
+ }
359
+ });
360
+ let { spinButtonProps: spinButtonProps , incrementButtonProps: incButtonProps , decrementButtonProps: decButtonProps } = (0, $gfhJl$useSpinButton)({
361
+ isDisabled: isDisabled,
362
+ isReadOnly: isReadOnly,
363
+ isRequired: isRequired,
364
+ maxValue: maxValue,
365
+ minValue: minValue,
366
+ onIncrement: increment,
367
+ onIncrementToMax: incrementToMax,
368
+ onDecrement: decrement,
369
+ onDecrementToMin: decrementToMin,
370
+ value: numberValue,
371
+ textValue: state.inputValue
372
+ });
373
+ let [focusWithin, setFocusWithin] = (0, $gfhJl$useState)(false);
374
+ let { focusWithinProps: focusWithinProps } = (0, $gfhJl$useFocusWithin)({
375
+ isDisabled: isDisabled,
376
+ onFocusWithinChange: setFocusWithin
377
+ });
378
+ let onWheel = (0, $gfhJl$useCallback)((e)=>{
379
+ // if on a trackpad, users can scroll in both X and Y at once, check the magnitude of the change
380
+ // if it's mostly in the X direction, then just return, the user probably doesn't mean to inc/dec
381
+ // this isn't perfect, events come in fast with small deltas and a part of the scroll may give a false indication
382
+ // especially if the user is scrolling near 45deg
383
+ if (Math.abs(e.deltaY) <= Math.abs(e.deltaX)) return;
384
+ if (e.deltaY > 0) increment();
385
+ else if (e.deltaY < 0) decrement();
386
+ }, [
387
+ decrement,
388
+ increment
389
+ ]);
390
+ // If the input isn't supposed to receive input, disable scrolling.
391
+ let scrollingDisabled = isDisabled || isReadOnly || !focusWithin;
392
+ (0, $gfhJl$useScrollWheel)({
393
+ onScroll: onWheel,
394
+ isDisabled: scrollingDisabled
395
+ }, inputRef);
396
+ // The inputMode attribute influences the software keyboard that is shown on touch devices.
397
+ // Browsers and operating systems are quite inconsistent about what keys are available, however.
398
+ // We choose between numeric and decimal based on whether we allow negative and fractional numbers,
399
+ // and based on testing on various devices to determine what keys are available in each inputMode.
400
+ let numberFormatter = (0, $gfhJl$useNumberFormatter)(formatOptions);
401
+ let intlOptions = (0, $gfhJl$useMemo)(()=>numberFormatter.resolvedOptions(), [
402
+ numberFormatter
403
+ ]);
404
+ let hasDecimals = intlOptions.maximumFractionDigits > 0;
405
+ let hasNegative = isNaN(state.minValue) || state.minValue < 0;
406
+ let inputMode = "numeric";
407
+ if ((0, $gfhJl$isIPhone)()) {
408
+ // iPhone doesn't have a minus sign in either numeric or decimal.
409
+ // Note this is only for iPhone, not iPad, which always has both
410
+ // minus and decimal in numeric.
411
+ if (hasNegative) inputMode = "text";
412
+ else if (hasDecimals) inputMode = "decimal";
413
+ } else if ((0, $gfhJl$isAndroid)()) {
414
+ // Android numeric has both a decimal point and minus key.
415
+ // decimal does not have a minus key.
416
+ if (hasNegative) inputMode = "numeric";
417
+ else if (hasDecimals) inputMode = "decimal";
418
+ }
419
+ let onChange = (value)=>{
420
+ state.setInputValue(value);
421
+ };
422
+ let domProps = (0, $gfhJl$filterDOMProps)(props);
423
+ let { labelProps: labelProps , inputProps: textFieldProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = (0, $gfhJl$useFormattedTextField)({
424
+ ...otherProps,
425
+ ...domProps,
426
+ label: label,
427
+ autoFocus: autoFocus,
428
+ isDisabled: isDisabled,
429
+ isReadOnly: isReadOnly,
430
+ isRequired: isRequired,
431
+ validationState: validationState,
432
+ value: state.inputValue,
433
+ defaultValue: undefined,
434
+ autoComplete: "off",
435
+ "aria-label": props["aria-label"] || null,
436
+ "aria-labelledby": props["aria-labelledby"] || null,
437
+ id: inputId,
438
+ type: "text",
439
+ inputMode: inputMode,
440
+ onChange: onChange,
441
+ onBlur: onBlur,
442
+ onFocus: onFocus,
443
+ onFocusChange: onFocusChange,
444
+ onKeyDown: onKeyDown,
445
+ onKeyUp: onKeyUp,
446
+ description: description,
447
+ errorMessage: errorMessage
448
+ }, state, inputRef);
449
+ let inputProps = (0, $gfhJl$mergeProps)(spinButtonProps, focusProps, textFieldProps, {
450
+ // override the spinbutton role, we can't focus a spin button with VO
451
+ role: null,
452
+ // ignore aria-roledescription on iOS so that required state will announce when it is present
453
+ "aria-roledescription": !(0, $gfhJl$isIOS)() ? stringFormatter.format("numberField") : null,
454
+ "aria-valuemax": null,
455
+ "aria-valuemin": null,
456
+ "aria-valuenow": null,
457
+ "aria-valuetext": null,
458
+ autoCorrect: "off",
459
+ spellCheck: "false"
460
+ });
461
+ let onButtonPressStart = (e)=>{
462
+ // If focus is already on the input, keep it there so we don't hide the
463
+ // software keyboard when tapping the increment/decrement buttons.
464
+ if (document.activeElement === inputRef.current) return;
465
+ // Otherwise, when using a mouse, move focus to the input.
466
+ // On touch, or with a screen reader, focus the button so that the software
467
+ // keyboard does not appear and the screen reader cursor is not moved off the button.
468
+ if (e.pointerType === "mouse") inputRef.current.focus();
469
+ else e.target.focus();
470
+ };
471
+ // Determine the label for the increment and decrement buttons. There are 4 cases:
472
+ //
473
+ // 1. With a visible label that is a string: aria-label: `Increase ${props.label}`
474
+ // 2. With a visible label that is JSX: aria-label: 'Increase', aria-labelledby: '${incrementId} ${labelId}'
475
+ // 3. With an aria-label: aria-label: `Increase ${props['aria-label']}`
476
+ // 4. With an aria-labelledby: aria-label: 'Increase', aria-labelledby: `${incrementId} ${props['aria-labelledby']}`
477
+ //
478
+ // (1) and (2) could possibly be combined and both use aria-labelledby. However, placing the label in
479
+ // the aria-label string rather than using aria-labelledby gives more flexibility to translators to change
480
+ // the order or add additional words around the label if needed.
481
+ let fieldLabel = props["aria-label"] || (typeof props.label === "string" ? props.label : "");
482
+ let ariaLabelledby;
483
+ if (!fieldLabel) ariaLabelledby = props.label != null ? labelProps.id : props["aria-labelledby"];
484
+ let incrementId = (0, $gfhJl$useId)();
485
+ let decrementId = (0, $gfhJl$useId)();
486
+ let incrementButtonProps = (0, $gfhJl$mergeProps)(incButtonProps, {
487
+ "aria-label": incrementAriaLabel || stringFormatter.format("increase", {
488
+ fieldLabel: fieldLabel
489
+ }).trim(),
490
+ id: ariaLabelledby && !incrementAriaLabel ? incrementId : null,
491
+ "aria-labelledby": ariaLabelledby && !incrementAriaLabel ? `${incrementId} ${ariaLabelledby}` : null,
492
+ "aria-controls": inputId,
493
+ excludeFromTabOrder: true,
494
+ preventFocusOnPress: true,
495
+ allowFocusWhenDisabled: true,
496
+ isDisabled: !state.canIncrement,
497
+ onPressStart: onButtonPressStart
498
+ });
499
+ let decrementButtonProps = (0, $gfhJl$mergeProps)(decButtonProps, {
500
+ "aria-label": decrementAriaLabel || stringFormatter.format("decrease", {
501
+ fieldLabel: fieldLabel
502
+ }).trim(),
503
+ id: ariaLabelledby && !decrementAriaLabel ? decrementId : null,
504
+ "aria-labelledby": ariaLabelledby && !decrementAriaLabel ? `${decrementId} ${ariaLabelledby}` : null,
505
+ "aria-controls": inputId,
506
+ excludeFromTabOrder: true,
507
+ preventFocusOnPress: true,
508
+ allowFocusWhenDisabled: true,
509
+ isDisabled: !state.canDecrement,
510
+ onPressStart: onButtonPressStart
511
+ });
512
+ return {
513
+ groupProps: {
514
+ role: "group",
515
+ "aria-disabled": isDisabled,
516
+ "aria-invalid": validationState === "invalid" ? "true" : undefined,
517
+ ...focusWithinProps
518
+ },
519
+ labelProps: labelProps,
520
+ inputProps: inputProps,
521
+ incrementButtonProps: incrementButtonProps,
522
+ decrementButtonProps: decrementButtonProps,
523
+ errorMessageProps: errorMessageProps,
524
+ descriptionProps: descriptionProps
525
+ };
526
+ }
527
+
528
+
529
+
530
+
531
+ export {$81397a9303501bda$export$23f548e970bdf099 as useNumberField};
532
+ //# sourceMappingURL=module.js.map
package/package.json CHANGED
@@ -1,10 +1,15 @@
1
1
  {
2
2
  "name": "@react-aria/numberfield",
3
- "version": "3.3.4",
3
+ "version": "3.4.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/module.js",
8
+ "exports": {
9
+ "types": "./dist/types.d.ts",
10
+ "import": "./dist/import.mjs",
11
+ "require": "./dist/main.js"
12
+ },
8
13
  "types": "dist/types.d.ts",
9
14
  "source": "src/index.ts",
10
15
  "files": [
@@ -17,17 +22,17 @@
17
22
  "url": "https://github.com/adobe/react-spectrum"
18
23
  },
19
24
  "dependencies": {
20
- "@react-aria/i18n": "^3.6.3",
21
- "@react-aria/interactions": "^3.13.1",
22
- "@react-aria/live-announcer": "^3.1.2",
23
- "@react-aria/spinbutton": "^3.2.1",
24
- "@react-aria/textfield": "^3.8.1",
25
- "@react-aria/utils": "^3.14.2",
26
- "@react-stately/numberfield": "^3.3.1",
27
- "@react-types/button": "^3.7.0",
28
- "@react-types/numberfield": "^3.3.5",
29
- "@react-types/shared": "^3.16.0",
30
- "@react-types/textfield": "^3.6.2",
25
+ "@react-aria/i18n": "^3.7.0",
26
+ "@react-aria/interactions": "^3.14.0",
27
+ "@react-aria/live-announcer": "^3.2.0",
28
+ "@react-aria/spinbutton": "^3.3.0",
29
+ "@react-aria/textfield": "^3.9.0",
30
+ "@react-aria/utils": "^3.15.0",
31
+ "@react-stately/numberfield": "^3.4.0",
32
+ "@react-types/button": "^3.7.1",
33
+ "@react-types/numberfield": "^3.4.0",
34
+ "@react-types/shared": "^3.17.0",
35
+ "@react-types/textfield": "^3.7.0",
31
36
  "@swc/helpers": "^0.4.14"
32
37
  },
33
38
  "peerDependencies": {
@@ -37,5 +42,5 @@
37
42
  "publishConfig": {
38
43
  "access": "public"
39
44
  },
40
- "gitHead": "5480d76bd815e239366f92852c76b6831ad2a4fd"
45
+ "gitHead": "a0efee84aa178cb1a202951dfd6d8de02b292307"
41
46
  }