@react-aria/numberfield 3.2.1 → 3.3.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.
@@ -1 +1 @@
1
- {"mappings":";;;;AAqCA;IACE,mCAAmC;IACnC,UAAU,EAAE,oBAAoB,gBAAgB,CAAC,CAAC;IAClD,wEAAwE;IACxE,UAAU,EAAE,eAAe,WAAW,CAAC,CAAC;IACxC,mCAAmC;IACnC,UAAU,EAAE,oBAAoB,gBAAgB,CAAC,CAAC;IAClD,mFAAmF;IACnF,oBAAoB,EAAE,eAAe,CAAC;IACtC,mFAAmF;IACnF,oBAAoB,EAAE,eAAe,CAAC;IACtC,gEAAgE;IAChE,gBAAgB,EAAE,eAAe,WAAW,CAAC,CAAC;IAC9C,kEAAkE;IAClE,iBAAiB,EAAE,eAAe,WAAW,CAAC,CAAA;CAC/C;AAED;;;GAGG;AACH,+BAA+B,KAAK,EAAE,oBAAoB,EAAE,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,UAAU,gBAAgB,CAAC,GAAG,eAAe,CA8O3I","sources":["packages/@react-aria/numberfield/src/packages/@react-aria/numberfield/src/useNumberField.ts","packages/@react-aria/numberfield/src/packages/@react-aria/numberfield/src/index.ts","packages/@react-aria/numberfield/src/index.ts"],"sourcesContent":[null,null,"/*\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\nexport * from './useNumberField';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";;;;;AAoCA;IACE,mCAAmC;IACnC,UAAU,EAAE,oBAAoB,gBAAgB,CAAC,CAAC;IAClD,wEAAwE;IACxE,UAAU,EAAE,aAAa,CAAC;IAC1B,mCAAmC;IACnC,UAAU,EAAE,oBAAoB,gBAAgB,CAAC,CAAC;IAClD,mFAAmF;IACnF,oBAAoB,EAAE,eAAe,CAAC;IACtC,mFAAmF;IACnF,oBAAoB,EAAE,eAAe,CAAC;IACtC,gEAAgE;IAChE,gBAAgB,EAAE,aAAa,CAAC;IAChC,kEAAkE;IAClE,iBAAiB,EAAE,aAAa,CAAA;CACjC;AAED;;;GAGG;AACH,+BAA+B,KAAK,EAAE,oBAAoB,EAAE,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,UAAU,gBAAgB,CAAC,GAAG,eAAe,CA8O3I;AC3RD,YAAY,EAAC,oBAAoB,EAAC,MAAM,0BAA0B,CAAC","sources":["packages/@react-aria/numberfield/src/packages/@react-aria/numberfield/src/useNumberField.ts","packages/@react-aria/numberfield/src/packages/@react-aria/numberfield/src/index.ts","packages/@react-aria/numberfield/src/index.ts"],"sourcesContent":[null,null,"/*\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":"types.d.ts.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/numberfield",
3
- "version": "3.2.1",
3
+ "version": "3.3.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -18,17 +18,17 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@babel/runtime": "^7.6.2",
21
- "@react-aria/i18n": "^3.4.1",
22
- "@react-aria/interactions": "^3.9.1",
23
- "@react-aria/live-announcer": "^3.1.0",
24
- "@react-aria/spinbutton": "^3.1.1",
25
- "@react-aria/textfield": "^3.6.1",
26
- "@react-aria/utils": "^3.13.1",
27
- "@react-stately/numberfield": "^3.1.1",
28
- "@react-types/button": "^3.5.1",
29
- "@react-types/numberfield": "^3.3.1",
30
- "@react-types/shared": "^3.13.1",
31
- "@react-types/textfield": "^3.5.1"
21
+ "@react-aria/i18n": "^3.5.0",
22
+ "@react-aria/interactions": "^3.10.0",
23
+ "@react-aria/live-announcer": "^3.1.1",
24
+ "@react-aria/spinbutton": "^3.1.2",
25
+ "@react-aria/textfield": "^3.7.0",
26
+ "@react-aria/utils": "^3.13.2",
27
+ "@react-stately/numberfield": "^3.2.0",
28
+ "@react-types/button": "^3.6.0",
29
+ "@react-types/numberfield": "^3.3.2",
30
+ "@react-types/shared": "^3.14.0",
31
+ "@react-types/textfield": "^3.5.2"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0",
@@ -37,5 +37,5 @@
37
37
  "publishConfig": {
38
38
  "access": "public"
39
39
  },
40
- "gitHead": "715c3f563ccf8c2e0102d3e18403d9db21a05a71"
40
+ "gitHead": "cd7c0ec917122c7612f653c22f8ed558f8b66ecd"
41
41
  }
package/src/index.ts CHANGED
@@ -9,5 +9,6 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
-
13
- export * from './useNumberField';
12
+ export {useNumberField} from './useNumberField';
13
+ export type {AriaNumberFieldProps} from '@react-types/numberfield';
14
+ export type {NumberFieldAria} from './useNumberField';
@@ -12,9 +12,9 @@
12
12
 
13
13
  import {AriaButtonProps} from '@react-types/button';
14
14
  import {AriaNumberFieldProps} from '@react-types/numberfield';
15
+ import {DOMAttributes, TextInputDOMProps} from '@react-types/shared';
15
16
  import {filterDOMProps, isAndroid, isIOS, isIPhone, mergeProps, useId} from '@react-aria/utils';
16
17
  import {
17
- HTMLAttributes,
18
18
  InputHTMLAttributes,
19
19
  LabelHTMLAttributes,
20
20
  RefObject,
@@ -25,21 +25,20 @@ import {
25
25
  // @ts-ignore
26
26
  import intlMessages from '../intl/*.json';
27
27
  import {NumberFieldState} from '@react-stately/numberfield';
28
- import {TextInputDOMProps} from '@react-types/shared';
29
28
  import {useFocus, useFocusWithin} from '@react-aria/interactions';
30
29
  import {useFormattedTextField} from '@react-aria/textfield';
31
30
  import {
32
- useMessageFormatter,
31
+ useLocalizedStringFormatter,
33
32
  useNumberFormatter
34
33
  } from '@react-aria/i18n';
35
34
  import {useScrollWheel} from '@react-aria/interactions';
36
35
  import {useSpinButton} from '@react-aria/spinbutton';
37
36
 
38
- interface NumberFieldAria {
37
+ export interface NumberFieldAria {
39
38
  /** Props for the label element. */
40
39
  labelProps: LabelHTMLAttributes<HTMLLabelElement>,
41
40
  /** Props for the group wrapper around the input and stepper buttons. */
42
- groupProps: HTMLAttributes<HTMLElement>,
41
+ groupProps: DOMAttributes,
43
42
  /** Props for the input element. */
44
43
  inputProps: InputHTMLAttributes<HTMLInputElement>,
45
44
  /** Props for the increment button, to be passed to [useButton](useButton.html). */
@@ -47,9 +46,9 @@ interface NumberFieldAria {
47
46
  /** Props for the decrement button, to be passed to [useButton](useButton.html). */
48
47
  decrementButtonProps: AriaButtonProps,
49
48
  /** Props for the number field's description element, if any. */
50
- descriptionProps: HTMLAttributes<HTMLElement>,
49
+ descriptionProps: DOMAttributes,
51
50
  /** Props for the number field's error message element, if any. */
52
- errorMessageProps: HTMLAttributes<HTMLElement>
51
+ errorMessageProps: DOMAttributes
53
52
  }
54
53
 
55
54
  /**
@@ -70,7 +69,7 @@ export function useNumberField(props: AriaNumberFieldProps, state: NumberFieldSt
70
69
  validationState,
71
70
  label,
72
71
  formatOptions,
73
- onBlur,
72
+ onBlur = () => {},
74
73
  onFocus,
75
74
  onFocusChange,
76
75
  onKeyDown,
@@ -89,7 +88,7 @@ export function useNumberField(props: AriaNumberFieldProps, state: NumberFieldSt
89
88
  commit
90
89
  } = state;
91
90
 
92
- const formatMessage = useMessageFormatter(intlMessages);
91
+ const stringFormatter = useLocalizedStringFormatter(intlMessages);
93
92
 
94
93
  let inputId = useId(id);
95
94
 
@@ -204,13 +203,13 @@ export function useNumberField(props: AriaNumberFieldProps, state: NumberFieldSt
204
203
 
205
204
  let inputProps = mergeProps(
206
205
  spinButtonProps,
207
- textFieldProps,
208
206
  focusProps,
207
+ textFieldProps,
209
208
  {
210
209
  // override the spinbutton role, we can't focus a spin button with VO
211
210
  role: null,
212
211
  // ignore aria-roledescription on iOS so that required state will announce when it is present
213
- 'aria-roledescription': (!isIOS() ? formatMessage('numberField') : null),
212
+ 'aria-roledescription': (!isIOS() ? stringFormatter.format('numberField') : null),
214
213
  'aria-valuemax': null,
215
214
  'aria-valuemin': null,
216
215
  'aria-valuenow': null,
@@ -257,7 +256,7 @@ export function useNumberField(props: AriaNumberFieldProps, state: NumberFieldSt
257
256
  let decrementId = useId();
258
257
 
259
258
  let incrementButtonProps: AriaButtonProps = mergeProps(incButtonProps, {
260
- 'aria-label': incrementAriaLabel || formatMessage('increase', {fieldLabel}).trim(),
259
+ 'aria-label': incrementAriaLabel || stringFormatter.format('increase', {fieldLabel}).trim(),
261
260
  id: ariaLabelledby && !incrementAriaLabel ? incrementId : null,
262
261
  'aria-labelledby': ariaLabelledby && !incrementAriaLabel ? `${incrementId} ${ariaLabelledby}` : null,
263
262
  'aria-controls': inputId,
@@ -269,7 +268,7 @@ export function useNumberField(props: AriaNumberFieldProps, state: NumberFieldSt
269
268
  });
270
269
 
271
270
  let decrementButtonProps: AriaButtonProps = mergeProps(decButtonProps, {
272
- 'aria-label': decrementAriaLabel || formatMessage('decrease', {fieldLabel}).trim(),
271
+ 'aria-label': decrementAriaLabel || stringFormatter.format('decrease', {fieldLabel}).trim(),
273
272
  id: ariaLabelledby && !decrementAriaLabel ? decrementId : null,
274
273
  'aria-labelledby': ariaLabelledby && !decrementAriaLabel ? `${decrementId} ${ariaLabelledby}` : null,
275
274
  'aria-controls': inputId,