@react-aria/searchfield 3.7.10 → 3.8.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.
- package/dist/types.d.ts.map +1 -1
- package/dist/useSearchField.main.js +4 -1
- package/dist/useSearchField.main.js.map +1 -1
- package/dist/useSearchField.mjs +4 -1
- package/dist/useSearchField.module.js +4 -1
- package/dist/useSearchField.module.js.map +1 -1
- package/package.json +11 -10
- package/src/useSearchField.ts +4 -1
package/dist/types.d.ts.map
CHANGED
|
@@ -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,
|
|
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,CAoFjB;ACtHD,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"}
|
|
@@ -41,8 +41,11 @@ function $ccae92a71d96d51a$export$9bb30bbe003b82e0(props, state, inputRef) {
|
|
|
41
41
|
onSubmit(state.value);
|
|
42
42
|
}
|
|
43
43
|
if (key === 'Escape') {
|
|
44
|
-
|
|
44
|
+
// Also check the inputRef value for the case where the value was set directly on the input element instead of going through
|
|
45
|
+
// the hook
|
|
46
|
+
if (state.value === '' && (!inputRef.current || inputRef.current.value === '')) e.continuePropagation();
|
|
45
47
|
else {
|
|
48
|
+
e.preventDefault();
|
|
46
49
|
state.setValue('');
|
|
47
50
|
if (onClear) onClear();
|
|
48
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAgCM,SAAS,0CACd,KAA2B,EAC3B,KAAuB,EACvB,QAA4C;IAE5C,IAAI,kBAAkB,CAAA,GAAA,gDAA0B,EAAE,CAAA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IAAI,SACF;IAEJ;IAEA,IAAI,eAAe;YACjB,+FAA+F;QAC/F,mCAAmC;QACnC;SAAA,oBAAA,SAAS,OAAO,cAAhB,wCAAA,kBAAkB,KAAK;IACzB;IAEA,IAAI,cAAC,UAAU,cAAE,UAAU,oBAAE,gBAAgB,qBAAE,iBAAiB,EAAE,GAAG,YAAW,GAAG,CAAA,GAAA,sCAAW,EAAE;QAC9F,GAAG,KAAK;QACR,OAAO,MAAM,KAAK;QAClB,UAAU,MAAM,QAAQ;QACxB,WAAW,CAAC,aAAa,CAAA,GAAA,2BAAI,EAAE,WAAW,MAAM,SAAS,IAAI,MAAM,SAAS;cAC5E;IACF,GAAG;IAEH,OAAO;oBACL;QACA,YAAY;YACV,GAAG,UAAU;YACb,yCAAyC;YACzC,cAAc;QAChB;QACA,kBAAkB;YAChB,cAAc,gBAAgB,MAAM,CAAC;YACrC,qBAAqB;YACrB,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 // Also check the inputRef value for the case where the value was set directly on the input element instead of going through\n // the hook\n if (state.value === '' && (!inputRef.current || inputRef.current.value === '')) {\n e.continuePropagation();\n } else {\n e.preventDefault();\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"}
|
package/dist/useSearchField.mjs
CHANGED
|
@@ -35,8 +35,11 @@ function $4d52238874b24f86$export$9bb30bbe003b82e0(props, state, inputRef) {
|
|
|
35
35
|
onSubmit(state.value);
|
|
36
36
|
}
|
|
37
37
|
if (key === 'Escape') {
|
|
38
|
-
|
|
38
|
+
// Also check the inputRef value for the case where the value was set directly on the input element instead of going through
|
|
39
|
+
// the hook
|
|
40
|
+
if (state.value === '' && (!inputRef.current || inputRef.current.value === '')) e.continuePropagation();
|
|
39
41
|
else {
|
|
42
|
+
e.preventDefault();
|
|
40
43
|
state.setValue('');
|
|
41
44
|
if (onClear) onClear();
|
|
42
45
|
}
|
|
@@ -35,8 +35,11 @@ function $4d52238874b24f86$export$9bb30bbe003b82e0(props, state, inputRef) {
|
|
|
35
35
|
onSubmit(state.value);
|
|
36
36
|
}
|
|
37
37
|
if (key === 'Escape') {
|
|
38
|
-
|
|
38
|
+
// Also check the inputRef value for the case where the value was set directly on the input element instead of going through
|
|
39
|
+
// the hook
|
|
40
|
+
if (state.value === '' && (!inputRef.current || inputRef.current.value === '')) e.continuePropagation();
|
|
39
41
|
else {
|
|
42
|
+
e.preventDefault();
|
|
40
43
|
state.setValue('');
|
|
41
44
|
if (onClear) onClear();
|
|
42
45
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;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AAM,QAAQ,CAAC;gBACf,IAAI,SACF;YAEJ;;IAEJ;IAEA,IAAI,qBAAqB;QACvB,MAAM,QAAQ,CAAC;QAEf,IAAI,SACF;IAEJ;IAEA,IAAI,eAAe;YACjB,+FAA+F;QAC/F,mCAAmC;QACnC;SAAA,oBAAA,SAAS,OAAO,cAAhB,wCAAA,kBAAkB,KAAK;IACzB;IAEA,IAAI,cAAC,UAAU,cAAE,UAAU,oBAAE,gBAAgB,qBAAE,iBAAiB,EAAE,GAAG,YAAW,GAAG,CAAA,GAAA,mBAAW,EAAE;QAC9F,GAAG,KAAK;QACR,OAAO,MAAM,KAAK;QAClB,UAAU,MAAM,QAAQ;QACxB,WAAW,CAAC,aAAa,CAAA,GAAA,YAAI,EAAE,WAAW,MAAM,SAAS,IAAI,MAAM,SAAS;cAC5E;IACF,GAAG;IAEH,OAAO;oBACL;QACA,YAAY;YACV,GAAG,UAAU;YACb,yCAAyC;YACzC,cAAc;QAChB;QACA,kBAAkB;YAChB,cAAc,gBAAgB,MAAM,CAAC;YACrC,qBAAqB;YACrB,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 // Also check the inputRef value for the case where the value was set directly on the input element instead of going through\n // the hook\n if (state.value === '' && (!inputRef.current || inputRef.current.value === '')) {\n e.continuePropagation();\n } else {\n e.preventDefault();\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.
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -22,20 +22,21 @@
|
|
|
22
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@react-aria/i18n": "^3.12.
|
|
26
|
-
"@react-aria/textfield": "^3.
|
|
27
|
-
"@react-aria/utils": "^3.
|
|
28
|
-
"@react-stately/searchfield": "^3.5.
|
|
29
|
-
"@react-types/button": "^3.10.
|
|
30
|
-
"@react-types/searchfield": "^3.5.
|
|
31
|
-
"@react-types/shared": "^3.
|
|
25
|
+
"@react-aria/i18n": "^3.12.5",
|
|
26
|
+
"@react-aria/textfield": "^3.16.0",
|
|
27
|
+
"@react-aria/utils": "^3.27.0",
|
|
28
|
+
"@react-stately/searchfield": "^3.5.9",
|
|
29
|
+
"@react-types/button": "^3.10.2",
|
|
30
|
+
"@react-types/searchfield": "^3.5.11",
|
|
31
|
+
"@react-types/shared": "^3.27.0",
|
|
32
32
|
"@swc/helpers": "^0.5.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
|
|
35
|
+
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
|
|
36
|
+
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
|
|
36
37
|
},
|
|
37
38
|
"publishConfig": {
|
|
38
39
|
"access": "public"
|
|
39
40
|
},
|
|
40
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "09e7f44bebdc9d89122926b2b439a0a38a2814ea"
|
|
41
42
|
}
|
package/src/useSearchField.ts
CHANGED
|
@@ -73,9 +73,12 @@ export function useSearchField(
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
if (key === 'Escape') {
|
|
76
|
-
|
|
76
|
+
// Also check the inputRef value for the case where the value was set directly on the input element instead of going through
|
|
77
|
+
// the hook
|
|
78
|
+
if (state.value === '' && (!inputRef.current || inputRef.current.value === '')) {
|
|
77
79
|
e.continuePropagation();
|
|
78
80
|
} else {
|
|
81
|
+
e.preventDefault();
|
|
79
82
|
state.setValue('');
|
|
80
83
|
if (onClear) {
|
|
81
84
|
onClear();
|