@react-aria/searchfield 3.7.8 → 3.7.10

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":";;;;;AAuBA,gCAAiC,SAAQ,gBAAgB;IACvD,iEAAiE;IACjE,UAAU,EAAE,oBAAoB,gBAAgB,CAAC,CAAC;IAClD,mCAAmC;IACnC,UAAU,EAAE,oBAAoB,gBAAgB,CAAC,CAAC;IAClD,kCAAkC;IAClC,gBAAgB,EAAE,eAAe,CAAC;IAClC,+DAA+D;IAC/D,gBAAgB,EAAE,aAAa,CAAC;IAChC,iEAAiE;IACjE,iBAAiB,EAAE,aAAa,CAAA;CACjC;AAED;;;;;GAKG;AACH,+BACE,KAAK,EAAE,oBAAoB,EAC3B,KAAK,EAAE,gBAAgB,EACvB,QAAQ,EAAE,UAAU,gBAAgB,GAAG,IAAI,CAAC,GAC3C,eAAe,CAkFjB;ACpHD,YAAY,EAAC,oBAAoB,EAAC,MAAM,0BAA0B,CAAC","sources":["packages/@react-aria/searchfield/src/packages/@react-aria/searchfield/src/useSearchField.ts","packages/@react-aria/searchfield/src/packages/@react-aria/searchfield/src/index.ts","packages/@react-aria/searchfield/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 {useSearchField} from './useSearchField';\nexport type {AriaSearchFieldProps} from '@react-types/searchfield';\nexport type {SearchFieldAria} from './useSearchField';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";;;;;AAuBA,gCAAiC,SAAQ,gBAAgB;IACvD,iEAAiE;IACjE,UAAU,EAAE,oBAAoB,gBAAgB,CAAC,CAAC;IAClD,mCAAmC;IACnC,UAAU,EAAE,oBAAoB,gBAAgB,CAAC,CAAC;IAClD,kCAAkC;IAClC,gBAAgB,EAAE,eAAe,CAAC;IAClC,+DAA+D;IAC/D,gBAAgB,EAAE,aAAa,CAAC;IAChC,iEAAiE;IACjE,iBAAiB,EAAE,aAAa,CAAA;CACjC;AAED;;;;;GAKG;AACH,+BACE,KAAK,EAAE,oBAAoB,EAC3B,KAAK,EAAE,gBAAgB,EACvB,QAAQ,EAAE,UAAU,gBAAgB,GAAG,IAAI,CAAC,GAC3C,eAAe,CAiFjB;ACnHD,YAAY,EAAC,oBAAoB,EAAC,MAAM,0BAA0B,CAAC","sources":["packages/@react-aria/searchfield/src/packages/@react-aria/searchfield/src/useSearchField.ts","packages/@react-aria/searchfield/src/packages/@react-aria/searchfield/src/index.ts","packages/@react-aria/searchfield/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 {useSearchField} from './useSearchField';\nexport type {AriaSearchFieldProps} from '@react-types/searchfield';\nexport type {SearchFieldAria} from './useSearchField';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
@@ -75,7 +75,6 @@ function $ccae92a71d96d51a$export$9bb30bbe003b82e0(props, state, inputRef) {
75
75
  clearButtonProps: {
76
76
  'aria-label': stringFormatter.format('Clear search'),
77
77
  excludeFromTabOrder: true,
78
- // @ts-ignore
79
78
  preventFocusOnPress: true,
80
79
  isDisabled: isDisabled || isRead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Ac;QAChB;QACA,kBAAkB;YAChB,cAAc,gBAAgB,MAAM,CAAC;YACrC,qBAAqB;YACrB,aAAa;YACb,qBAAqB;YACrB,YAAY,cAAc;YAC1B,SAAS;0BACT;QACF;0BACA;2BACA;QACA,GAAG,UAAU;IACf;AACF","sources":["packages/@react-aria/searchfield/src/useSearchField.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '@react-types/button';\nimport {AriaSearchFieldProps} from '@react-types/searchfield';\nimport {chain} from '@react-aria/utils';\nimport {DOMAttributes, RefObject, ValidationResult} from '@react-types/shared';\nimport {InputHTMLAttributes, LabelHTMLAttributes} from 'react';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {SearchFieldState} from '@react-stately/searchfield';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useTextField} from '@react-aria/textfield';\n\nexport interface SearchFieldAria extends ValidationResult {\n /** Props for the text field's visible label element (if any). */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>,\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Props for the clear button. */\n clearButtonProps: AriaButtonProps,\n /** Props for the searchfield's description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the searchfield's error message element, if any. */\n errorMessageProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a search field.\n * @param props - Props for the search field.\n * @param state - State for the search field, as returned by `useSearchFieldState`.\n * @param inputRef - A ref to the input element.\n */\nexport function useSearchField(\n props: AriaSearchFieldProps,\n state: SearchFieldState,\n inputRef: RefObject<HTMLInputElement | null>\n): SearchFieldAria {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/searchfield');\n let {\n isDisabled,\n isReadOnly,\n onSubmit,\n onClear,\n type = 'search'\n } = props;\n\n let onKeyDown = (e) => {\n const key = e.key;\n\n if (key === 'Enter' && (isDisabled || isReadOnly)) {\n e.preventDefault();\n }\n\n if (isDisabled || isReadOnly) {\n return;\n }\n\n // for backward compatibility;\n // otherwise, \"Enter\" on an input would trigger a form submit, the default browser behavior\n if (key === 'Enter' && onSubmit) {\n e.preventDefault();\n onSubmit(state.value);\n }\n\n if (key === 'Escape') {\n if (state.value === '') {\n e.continuePropagation();\n } else {\n state.setValue('');\n if (onClear) {\n onClear();\n }\n }\n }\n };\n\n let onClearButtonClick = () => {\n state.setValue('');\n\n if (onClear) {\n onClear();\n }\n };\n\n let onPressStart = () => {\n // this is in PressStart for mobile so that touching the clear button doesn't remove focus from\n // the input and close the keyboard\n inputRef.current?.focus();\n };\n\n let {labelProps, inputProps, descriptionProps, errorMessageProps, ...validation} = useTextField({\n ...props,\n value: state.value,\n onChange: state.setValue,\n onKeyDown: !isReadOnly ? chain(onKeyDown, props.onKeyDown) : props.onKeyDown,\n type\n }, inputRef);\n\n return {\n labelProps,\n inputProps: {\n ...inputProps,\n // already handled by useSearchFieldState\n defaultValue: undefined\n },\n clearButtonProps: {\n 'aria-label': stringFormatter.format('Clear search'),\n excludeFromTabOrder: true,\n // @ts-ignore\n preventFocusOnPress: true,\n isDisabled: isDisabled || isReadOnly,\n onPress: onClearButtonClick,\n onPressStart\n },\n descriptionProps,\n errorMessageProps,\n ...validation\n };\n}\n"],"names":[],"version":3,"file":"useSearchField.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAgCM,SAAS,0CACd,KAA2B,EAC3B,KAAuB,EACvB,QAA4C;IAE5C,IAAI,kBAAkB,CAAA,GAAA,gDAA0B,EAAE,CAAA,GAAA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/*\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 {AriaSearchFieldProps} from '@react-types/searchfield';\nimport {chain} from '@react-aria/utils';\nimport {DOMAttributes, RefObject, ValidationResult} from '@react-types/shared';\nimport {InputHTMLAttributes, LabelHTMLAttributes} from 'react';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {SearchFieldState} from '@react-stately/searchfield';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useTextField} from '@react-aria/textfield';\n\nexport interface SearchFieldAria extends ValidationResult {\n /** Props for the text field's visible label element (if any). */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>,\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Props for the clear button. */\n clearButtonProps: AriaButtonProps,\n /** Props for the searchfield's description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the searchfield's error message element, if any. */\n errorMessageProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a search field.\n * @param props - Props for the search field.\n * @param state - State for the search field, as returned by `useSearchFieldState`.\n * @param inputRef - A ref to the input element.\n */\nexport function useSearchField(\n props: AriaSearchFieldProps,\n state: SearchFieldState,\n inputRef: RefObject<HTMLInputElement | null>\n): SearchFieldAria {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/searchfield');\n let {\n isDisabled,\n isReadOnly,\n onSubmit,\n onClear,\n type = 'search'\n } = props;\n\n let onKeyDown = (e) => {\n const key = e.key;\n\n if (key === 'Enter' && (isDisabled || isReadOnly)) {\n e.preventDefault();\n }\n\n if (isDisabled || isReadOnly) {\n return;\n }\n\n // for backward compatibility;\n // otherwise, \"Enter\" on an input would trigger a form submit, the default browser behavior\n if (key === 'Enter' && onSubmit) {\n e.preventDefault();\n onSubmit(state.value);\n }\n\n if (key === 'Escape') {\n if (state.value === '') {\n e.continuePropagation();\n } else {\n state.setValue('');\n if (onClear) {\n onClear();\n }\n }\n }\n };\n\n let onClearButtonClick = () => {\n state.setValue('');\n\n if (onClear) {\n onClear();\n }\n };\n\n let onPressStart = () => {\n // this is in PressStart for mobile so that touching the clear button doesn't remove focus from\n // the input and close the keyboard\n inputRef.current?.focus();\n };\n\n let {labelProps, inputProps, descriptionProps, errorMessageProps, ...validation} = useTextField({\n ...props,\n value: state.value,\n onChange: state.setValue,\n onKeyDown: !isReadOnly ? chain(onKeyDown, props.onKeyDown) : props.onKeyDown,\n type\n }, inputRef);\n\n return {\n labelProps,\n inputProps: {\n ...inputProps,\n // already handled by useSearchFieldState\n defaultValue: undefined\n },\n clearButtonProps: {\n 'aria-label': stringFormatter.format('Clear search'),\n excludeFromTabOrder: true,\n preventFocusOnPress: true,\n isDisabled: isDisabled || isReadOnly,\n onPress: onClearButtonClick,\n onPressStart\n },\n descriptionProps,\n errorMessageProps,\n ...validation\n };\n}\n"],"names":[],"version":3,"file":"useSearchField.main.js.map"}
@@ -69,7 +69,6 @@ function $4d52238874b24f86$export$9bb30bbe003b82e0(props, state, inputRef) {
69
69
  clearButtonProps: {
70
70
  'aria-label': stringFormatter.format('Clear search'),
71
71
  excludeFromTabOrder: true,
72
- // @ts-ignore
73
72
  preventFocusOnPress: true,
74
73
  isDisabled: isDisabled || isReadOnly,
75
74
  onPress: onClearButtonClick,
@@ -69,7 +69,6 @@ function $4d52238874b24f86$export$9bb30bbe003b82e0(props, state, inputRef) {
69
69
  clearButtonProps: {
70
70
  'aria-label': stringFormatter.format('Clear search'),
71
71
  excludeFromTabOrder: true,
72
- // @ts-ignore
73
72
  preventFocusOnPress: true,
74
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AyC;YACzC,cAAc;QAChB;QACA,kBAAkB;YAChB,cAAc,gBAAgB,MAAM,CAAC;YACrC,qBAAqB;YACrB,aAAa;YACb,qBAAqB;YACrB,YAAY,cAAc;YAC1B,SAAS;0BACT;QACF;0BACA;2BACA;QACA,GAAG,UAAU;IACf;AACF","sources":["packages/@react-aria/searchfield/src/useSearchField.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '@react-types/button';\nimport {AriaSearchFieldProps} from '@react-types/searchfield';\nimport {chain} from '@react-aria/utils';\nimport {DOMAttributes, RefObject, ValidationResult} from '@react-types/shared';\nimport {InputHTMLAttributes, LabelHTMLAttributes} from 'react';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {SearchFieldState} from '@react-stately/searchfield';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useTextField} from '@react-aria/textfield';\n\nexport interface SearchFieldAria extends ValidationResult {\n /** Props for the text field's visible label element (if any). */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>,\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Props for the clear button. */\n clearButtonProps: AriaButtonProps,\n /** Props for the searchfield's description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the searchfield's error message element, if any. */\n errorMessageProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a search field.\n * @param props - Props for the search field.\n * @param state - State for the search field, as returned by `useSearchFieldState`.\n * @param inputRef - A ref to the input element.\n */\nexport function useSearchField(\n props: AriaSearchFieldProps,\n state: SearchFieldState,\n inputRef: RefObject<HTMLInputElement | null>\n): SearchFieldAria {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/searchfield');\n let {\n isDisabled,\n isReadOnly,\n onSubmit,\n onClear,\n type = 'search'\n } = props;\n\n let onKeyDown = (e) => {\n const key = e.key;\n\n if (key === 'Enter' && (isDisabled || isReadOnly)) {\n e.preventDefault();\n }\n\n if (isDisabled || isReadOnly) {\n return;\n }\n\n // for backward compatibility;\n // otherwise, \"Enter\" on an input would trigger a form submit, the default browser behavior\n if (key === 'Enter' && onSubmit) {\n e.preventDefault();\n onSubmit(state.value);\n }\n\n if (key === 'Escape') {\n if (state.value === '') {\n e.continuePropagation();\n } else {\n state.setValue('');\n if (onClear) {\n onClear();\n }\n }\n }\n };\n\n let onClearButtonClick = () => {\n state.setValue('');\n\n if (onClear) {\n onClear();\n }\n };\n\n let onPressStart = () => {\n // this is in PressStart for mobile so that touching the clear button doesn't remove focus from\n // the input and close the keyboard\n inputRef.current?.focus();\n };\n\n let {labelProps, inputProps, descriptionProps, errorMessageProps, ...validation} = useTextField({\n ...props,\n value: state.value,\n onChange: state.setValue,\n onKeyDown: !isReadOnly ? chain(onKeyDown, props.onKeyDown) : props.onKeyDown,\n type\n }, inputRef);\n\n return {\n labelProps,\n inputProps: {\n ...inputProps,\n // already handled by useSearchFieldState\n defaultValue: undefined\n },\n clearButtonProps: {\n 'aria-label': stringFormatter.format('Clear search'),\n excludeFromTabOrder: true,\n // @ts-ignore\n preventFocusOnPress: true,\n isDisabled: isDisabled || isReadOnly,\n onPress: onClearButtonClick,\n onPressStart\n },\n descriptionProps,\n errorMessageProps,\n ...validation\n };\n}\n"],"names":[],"version":3,"file":"useSearchField.module.js.map"}
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAgCM,SAAS,0CACd,KAA2B,EAC3B,KAAuB,EACvB,QAA4C;IAE5C,IAAI,kBAAkB,CAAA,GAAA,kCAA0B,EAAE,CAAA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Content":["/*\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 {AriaSearchFieldProps} from '@react-types/searchfield';\nimport {chain} from '@react-aria/utils';\nimport {DOMAttributes, RefObject, ValidationResult} from '@react-types/shared';\nimport {InputHTMLAttributes, LabelHTMLAttributes} from 'react';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {SearchFieldState} from '@react-stately/searchfield';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useTextField} from '@react-aria/textfield';\n\nexport interface SearchFieldAria extends ValidationResult {\n /** Props for the text field's visible label element (if any). */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>,\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Props for the clear button. */\n clearButtonProps: AriaButtonProps,\n /** Props for the searchfield's description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the searchfield's error message element, if any. */\n errorMessageProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a search field.\n * @param props - Props for the search field.\n * @param state - State for the search field, as returned by `useSearchFieldState`.\n * @param inputRef - A ref to the input element.\n */\nexport function useSearchField(\n props: AriaSearchFieldProps,\n state: SearchFieldState,\n inputRef: RefObject<HTMLInputElement | null>\n): SearchFieldAria {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/searchfield');\n let {\n isDisabled,\n isReadOnly,\n onSubmit,\n onClear,\n type = 'search'\n } = props;\n\n let onKeyDown = (e) => {\n const key = e.key;\n\n if (key === 'Enter' && (isDisabled || isReadOnly)) {\n e.preventDefault();\n }\n\n if (isDisabled || isReadOnly) {\n return;\n }\n\n // for backward compatibility;\n // otherwise, \"Enter\" on an input would trigger a form submit, the default browser behavior\n if (key === 'Enter' && onSubmit) {\n e.preventDefault();\n onSubmit(state.value);\n }\n\n if (key === 'Escape') {\n if (state.value === '') {\n e.continuePropagation();\n } else {\n state.setValue('');\n if (onClear) {\n onClear();\n }\n }\n }\n };\n\n let onClearButtonClick = () => {\n state.setValue('');\n\n if (onClear) {\n onClear();\n }\n };\n\n let onPressStart = () => {\n // this is in PressStart for mobile so that touching the clear button doesn't remove focus from\n // the input and close the keyboard\n inputRef.current?.focus();\n };\n\n let {labelProps, inputProps, descriptionProps, errorMessageProps, ...validation} = useTextField({\n ...props,\n value: state.value,\n onChange: state.setValue,\n onKeyDown: !isReadOnly ? chain(onKeyDown, props.onKeyDown) : props.onKeyDown,\n type\n }, inputRef);\n\n return {\n labelProps,\n inputProps: {\n ...inputProps,\n // already handled by useSearchFieldState\n defaultValue: undefined\n },\n clearButtonProps: {\n 'aria-label': stringFormatter.format('Clear search'),\n excludeFromTabOrder: true,\n preventFocusOnPress: true,\n isDisabled: isDisabled || isReadOnly,\n onPress: onClearButtonClick,\n onPressStart\n },\n descriptionProps,\n errorMessageProps,\n ...validation\n };\n}\n"],"names":[],"version":3,"file":"useSearchField.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/searchfield",
3
- "version": "3.7.8",
3
+ "version": "3.7.10",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -22,13 +22,13 @@
22
22
  "url": "https://github.com/adobe/react-spectrum"
23
23
  },
24
24
  "dependencies": {
25
- "@react-aria/i18n": "^3.12.2",
26
- "@react-aria/textfield": "^3.14.8",
27
- "@react-aria/utils": "^3.25.2",
28
- "@react-stately/searchfield": "^3.5.6",
29
- "@react-types/button": "^3.9.6",
30
- "@react-types/searchfield": "^3.5.8",
31
- "@react-types/shared": "^3.24.1",
25
+ "@react-aria/i18n": "^3.12.3",
26
+ "@react-aria/textfield": "^3.14.10",
27
+ "@react-aria/utils": "^3.25.3",
28
+ "@react-stately/searchfield": "^3.5.7",
29
+ "@react-types/button": "^3.10.0",
30
+ "@react-types/searchfield": "^3.5.9",
31
+ "@react-types/shared": "^3.25.0",
32
32
  "@swc/helpers": "^0.5.0"
33
33
  },
34
34
  "peerDependencies": {
@@ -37,5 +37,5 @@
37
37
  "publishConfig": {
38
38
  "access": "public"
39
39
  },
40
- "gitHead": "faf0e18467231422cb7a06eb92a74d04e271f1e8"
40
+ "gitHead": "8e0a28d188cdbdbd2b32296fa034b1b02ddde229"
41
41
  }
@@ -116,7 +116,6 @@ export function useSearchField(
116
116
  clearButtonProps: {
117
117
  'aria-label': stringFormatter.format('Clear search'),
118
118
  excludeFromTabOrder: true,
119
- // @ts-ignore
120
119
  preventFocusOnPress: true,
121
120
  isDisabled: isDisabled || isReadOnly,
122
121
  onPress: onClearButtonClick,