@react-aria/searchfield 3.8.12 → 3.9.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 (191) hide show
  1. package/dist/import.mjs +2 -2
  2. package/dist/main.js +2 -2
  3. package/dist/main.js.map +1 -1
  4. package/dist/module.js +2 -2
  5. package/dist/module.js.map +1 -1
  6. package/dist/types/src/index.d.ts +2 -0
  7. package/package.json +15 -18
  8. package/src/index.ts +3 -3
  9. package/dist/ar-AE.main.js +0 -6
  10. package/dist/ar-AE.main.js.map +0 -1
  11. package/dist/ar-AE.mjs +0 -8
  12. package/dist/ar-AE.module.js +0 -8
  13. package/dist/ar-AE.module.js.map +0 -1
  14. package/dist/bg-BG.main.js +0 -6
  15. package/dist/bg-BG.main.js.map +0 -1
  16. package/dist/bg-BG.mjs +0 -8
  17. package/dist/bg-BG.module.js +0 -8
  18. package/dist/bg-BG.module.js.map +0 -1
  19. package/dist/cs-CZ.main.js +0 -6
  20. package/dist/cs-CZ.main.js.map +0 -1
  21. package/dist/cs-CZ.mjs +0 -8
  22. package/dist/cs-CZ.module.js +0 -8
  23. package/dist/cs-CZ.module.js.map +0 -1
  24. package/dist/da-DK.main.js +0 -6
  25. package/dist/da-DK.main.js.map +0 -1
  26. package/dist/da-DK.mjs +0 -8
  27. package/dist/da-DK.module.js +0 -8
  28. package/dist/da-DK.module.js.map +0 -1
  29. package/dist/de-DE.main.js +0 -6
  30. package/dist/de-DE.main.js.map +0 -1
  31. package/dist/de-DE.mjs +0 -8
  32. package/dist/de-DE.module.js +0 -8
  33. package/dist/de-DE.module.js.map +0 -1
  34. package/dist/el-GR.main.js +0 -6
  35. package/dist/el-GR.main.js.map +0 -1
  36. package/dist/el-GR.mjs +0 -8
  37. package/dist/el-GR.module.js +0 -8
  38. package/dist/el-GR.module.js.map +0 -1
  39. package/dist/en-US.main.js +0 -6
  40. package/dist/en-US.main.js.map +0 -1
  41. package/dist/en-US.mjs +0 -8
  42. package/dist/en-US.module.js +0 -8
  43. package/dist/en-US.module.js.map +0 -1
  44. package/dist/es-ES.main.js +0 -6
  45. package/dist/es-ES.main.js.map +0 -1
  46. package/dist/es-ES.mjs +0 -8
  47. package/dist/es-ES.module.js +0 -8
  48. package/dist/es-ES.module.js.map +0 -1
  49. package/dist/et-EE.main.js +0 -6
  50. package/dist/et-EE.main.js.map +0 -1
  51. package/dist/et-EE.mjs +0 -8
  52. package/dist/et-EE.module.js +0 -8
  53. package/dist/et-EE.module.js.map +0 -1
  54. package/dist/fi-FI.main.js +0 -6
  55. package/dist/fi-FI.main.js.map +0 -1
  56. package/dist/fi-FI.mjs +0 -8
  57. package/dist/fi-FI.module.js +0 -8
  58. package/dist/fi-FI.module.js.map +0 -1
  59. package/dist/fr-FR.main.js +0 -6
  60. package/dist/fr-FR.main.js.map +0 -1
  61. package/dist/fr-FR.mjs +0 -8
  62. package/dist/fr-FR.module.js +0 -8
  63. package/dist/fr-FR.module.js.map +0 -1
  64. package/dist/he-IL.main.js +0 -6
  65. package/dist/he-IL.main.js.map +0 -1
  66. package/dist/he-IL.mjs +0 -8
  67. package/dist/he-IL.module.js +0 -8
  68. package/dist/he-IL.module.js.map +0 -1
  69. package/dist/hr-HR.main.js +0 -6
  70. package/dist/hr-HR.main.js.map +0 -1
  71. package/dist/hr-HR.mjs +0 -8
  72. package/dist/hr-HR.module.js +0 -8
  73. package/dist/hr-HR.module.js.map +0 -1
  74. package/dist/hu-HU.main.js +0 -6
  75. package/dist/hu-HU.main.js.map +0 -1
  76. package/dist/hu-HU.mjs +0 -8
  77. package/dist/hu-HU.module.js +0 -8
  78. package/dist/hu-HU.module.js.map +0 -1
  79. package/dist/intlStrings.main.js +0 -108
  80. package/dist/intlStrings.main.js.map +0 -1
  81. package/dist/intlStrings.mjs +0 -110
  82. package/dist/intlStrings.module.js +0 -110
  83. package/dist/intlStrings.module.js.map +0 -1
  84. package/dist/it-IT.main.js +0 -6
  85. package/dist/it-IT.main.js.map +0 -1
  86. package/dist/it-IT.mjs +0 -8
  87. package/dist/it-IT.module.js +0 -8
  88. package/dist/it-IT.module.js.map +0 -1
  89. package/dist/ja-JP.main.js +0 -6
  90. package/dist/ja-JP.main.js.map +0 -1
  91. package/dist/ja-JP.mjs +0 -8
  92. package/dist/ja-JP.module.js +0 -8
  93. package/dist/ja-JP.module.js.map +0 -1
  94. package/dist/ko-KR.main.js +0 -6
  95. package/dist/ko-KR.main.js.map +0 -1
  96. package/dist/ko-KR.mjs +0 -8
  97. package/dist/ko-KR.module.js +0 -8
  98. package/dist/ko-KR.module.js.map +0 -1
  99. package/dist/lt-LT.main.js +0 -6
  100. package/dist/lt-LT.main.js.map +0 -1
  101. package/dist/lt-LT.mjs +0 -8
  102. package/dist/lt-LT.module.js +0 -8
  103. package/dist/lt-LT.module.js.map +0 -1
  104. package/dist/lv-LV.main.js +0 -6
  105. package/dist/lv-LV.main.js.map +0 -1
  106. package/dist/lv-LV.mjs +0 -8
  107. package/dist/lv-LV.module.js +0 -8
  108. package/dist/lv-LV.module.js.map +0 -1
  109. package/dist/nb-NO.main.js +0 -6
  110. package/dist/nb-NO.main.js.map +0 -1
  111. package/dist/nb-NO.mjs +0 -8
  112. package/dist/nb-NO.module.js +0 -8
  113. package/dist/nb-NO.module.js.map +0 -1
  114. package/dist/nl-NL.main.js +0 -6
  115. package/dist/nl-NL.main.js.map +0 -1
  116. package/dist/nl-NL.mjs +0 -8
  117. package/dist/nl-NL.module.js +0 -8
  118. package/dist/nl-NL.module.js.map +0 -1
  119. package/dist/pl-PL.main.js +0 -6
  120. package/dist/pl-PL.main.js.map +0 -1
  121. package/dist/pl-PL.mjs +0 -8
  122. package/dist/pl-PL.module.js +0 -8
  123. package/dist/pl-PL.module.js.map +0 -1
  124. package/dist/pt-BR.main.js +0 -6
  125. package/dist/pt-BR.main.js.map +0 -1
  126. package/dist/pt-BR.mjs +0 -8
  127. package/dist/pt-BR.module.js +0 -8
  128. package/dist/pt-BR.module.js.map +0 -1
  129. package/dist/pt-PT.main.js +0 -6
  130. package/dist/pt-PT.main.js.map +0 -1
  131. package/dist/pt-PT.mjs +0 -8
  132. package/dist/pt-PT.module.js +0 -8
  133. package/dist/pt-PT.module.js.map +0 -1
  134. package/dist/ro-RO.main.js +0 -6
  135. package/dist/ro-RO.main.js.map +0 -1
  136. package/dist/ro-RO.mjs +0 -8
  137. package/dist/ro-RO.module.js +0 -8
  138. package/dist/ro-RO.module.js.map +0 -1
  139. package/dist/ru-RU.main.js +0 -6
  140. package/dist/ru-RU.main.js.map +0 -1
  141. package/dist/ru-RU.mjs +0 -8
  142. package/dist/ru-RU.module.js +0 -8
  143. package/dist/ru-RU.module.js.map +0 -1
  144. package/dist/sk-SK.main.js +0 -6
  145. package/dist/sk-SK.main.js.map +0 -1
  146. package/dist/sk-SK.mjs +0 -8
  147. package/dist/sk-SK.module.js +0 -8
  148. package/dist/sk-SK.module.js.map +0 -1
  149. package/dist/sl-SI.main.js +0 -6
  150. package/dist/sl-SI.main.js.map +0 -1
  151. package/dist/sl-SI.mjs +0 -8
  152. package/dist/sl-SI.module.js +0 -8
  153. package/dist/sl-SI.module.js.map +0 -1
  154. package/dist/sr-SP.main.js +0 -6
  155. package/dist/sr-SP.main.js.map +0 -1
  156. package/dist/sr-SP.mjs +0 -8
  157. package/dist/sr-SP.module.js +0 -8
  158. package/dist/sr-SP.module.js.map +0 -1
  159. package/dist/sv-SE.main.js +0 -6
  160. package/dist/sv-SE.main.js.map +0 -1
  161. package/dist/sv-SE.mjs +0 -8
  162. package/dist/sv-SE.module.js +0 -8
  163. package/dist/sv-SE.module.js.map +0 -1
  164. package/dist/tr-TR.main.js +0 -6
  165. package/dist/tr-TR.main.js.map +0 -1
  166. package/dist/tr-TR.mjs +0 -8
  167. package/dist/tr-TR.module.js +0 -8
  168. package/dist/tr-TR.module.js.map +0 -1
  169. package/dist/types.d.ts +0 -27
  170. package/dist/types.d.ts.map +0 -1
  171. package/dist/uk-UA.main.js +0 -6
  172. package/dist/uk-UA.main.js.map +0 -1
  173. package/dist/uk-UA.mjs +0 -8
  174. package/dist/uk-UA.module.js +0 -8
  175. package/dist/uk-UA.module.js.map +0 -1
  176. package/dist/useSearchField.main.js +0 -93
  177. package/dist/useSearchField.main.js.map +0 -1
  178. package/dist/useSearchField.mjs +0 -88
  179. package/dist/useSearchField.module.js +0 -88
  180. package/dist/useSearchField.module.js.map +0 -1
  181. package/dist/zh-CN.main.js +0 -6
  182. package/dist/zh-CN.main.js.map +0 -1
  183. package/dist/zh-CN.mjs +0 -8
  184. package/dist/zh-CN.module.js +0 -8
  185. package/dist/zh-CN.module.js.map +0 -1
  186. package/dist/zh-TW.main.js +0 -6
  187. package/dist/zh-TW.main.js.map +0 -1
  188. package/dist/zh-TW.mjs +0 -8
  189. package/dist/zh-TW.module.js +0 -8
  190. package/dist/zh-TW.module.js.map +0 -1
  191. package/src/useSearchField.ts +0 -131
@@ -1,88 +0,0 @@
1
- import $kTEqN$intlStringsmodulejs from "./intlStrings.module.js";
2
- import {chain as $kTEqN$chain} from "@react-aria/utils";
3
- import {useLocalizedStringFormatter as $kTEqN$useLocalizedStringFormatter} from "@react-aria/i18n";
4
- import {useTextField as $kTEqN$useTextField} from "@react-aria/textfield";
5
-
6
-
7
- function $parcel$interopDefault(a) {
8
- return a && a.__esModule ? a.default : a;
9
- }
10
- /*
11
- * Copyright 2020 Adobe. All rights reserved.
12
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
13
- * you may not use this file except in compliance with the License. You may obtain a copy
14
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
15
- *
16
- * Unless required by applicable law or agreed to in writing, software distributed under
17
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
18
- * OF ANY KIND, either express or implied. See the License for the specific language
19
- * governing permissions and limitations under the License.
20
- */
21
-
22
-
23
-
24
- function $4d52238874b24f86$export$9bb30bbe003b82e0(props, state, inputRef) {
25
- let stringFormatter = (0, $kTEqN$useLocalizedStringFormatter)((0, ($parcel$interopDefault($kTEqN$intlStringsmodulejs))), '@react-aria/searchfield');
26
- let { isDisabled: isDisabled, isReadOnly: isReadOnly, onSubmit: onSubmit, onClear: onClear, type: type = 'search' } = props;
27
- let onKeyDown = (e)=>{
28
- const key = e.key;
29
- if (key === 'Enter' && (isDisabled || isReadOnly)) e.preventDefault();
30
- if (isDisabled || isReadOnly) return;
31
- // for backward compatibility;
32
- // otherwise, "Enter" on an input would trigger a form submit, the default browser behavior
33
- if (key === 'Enter' && onSubmit) {
34
- e.preventDefault();
35
- onSubmit(state.value);
36
- }
37
- if (key === 'Escape') {
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();
41
- else {
42
- e.preventDefault();
43
- state.setValue('');
44
- if (onClear) onClear();
45
- }
46
- }
47
- };
48
- let onClearButtonClick = ()=>{
49
- state.setValue('');
50
- if (onClear) onClear();
51
- };
52
- let onPressStart = ()=>{
53
- var // this is in PressStart for mobile so that touching the clear button doesn't remove focus from
54
- // the input and close the keyboard
55
- _inputRef_current;
56
- (_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.focus();
57
- };
58
- let { labelProps: labelProps, inputProps: inputProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps, ...validation } = (0, $kTEqN$useTextField)({
59
- ...props,
60
- value: state.value,
61
- onChange: state.setValue,
62
- onKeyDown: !isReadOnly ? (0, $kTEqN$chain)(onKeyDown, props.onKeyDown) : props.onKeyDown,
63
- type: type
64
- }, inputRef);
65
- return {
66
- labelProps: labelProps,
67
- inputProps: {
68
- ...inputProps,
69
- // already handled by useSearchFieldState
70
- defaultValue: undefined
71
- },
72
- clearButtonProps: {
73
- 'aria-label': stringFormatter.format('Clear search'),
74
- excludeFromTabOrder: true,
75
- preventFocusOnPress: true,
76
- isDisabled: isDisabled || isReadOnly,
77
- onPress: onClearButtonClick,
78
- onPressStart: onPressStart
79
- },
80
- descriptionProps: descriptionProps,
81
- errorMessageProps: errorMessageProps,
82
- ...validation
83
- };
84
- }
85
-
86
-
87
- export {$4d52238874b24f86$export$9bb30bbe003b82e0 as useSearchField};
88
- //# sourceMappingURL=useSearchField.module.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAgCM,SAAS,0CACd,KAA2B,EAC3B,KAAuB,EACvB,QAA4C;IAE5C,IAAI,kBAAkB,CAAA,GAAA,kCAA0B,EAAE,CAAA,GAAA,oDAAW,GAAG;IAChE,IAAI,cACF,UAAU,cACV,UAAU,YACV,QAAQ,WACR,OAAO,QACP,OAAO,UACR,GAAG;IAEJ,IAAI,YAAY,CAAC;QACf,MAAM,MAAM,EAAE,GAAG;QAEjB,IAAI,QAAQ,WAAY,CAAA,cAAc,UAAS,GAC7C,EAAE,cAAc;QAGlB,IAAI,cAAc,YAChB;QAGF,8BAA8B;QAC9B,2FAA2F;QAC3F,IAAI,QAAQ,WAAW,UAAU;YAC/B,EAAE,cAAc;YAChB,SAAS,MAAM,KAAK;QACtB;QAEA,IAAI,QAAQ;YACV,4HAA4H;YAC5H,WAAW;YACX,IAAI,MAAM,KAAK,KAAK,MAAO,CAAA,CAAC,SAAS,OAAO,IAAI,SAAS,OAAO,CAAC,KAAK,KAAK,EAAC,GAC1E,EAAE,mBAAmB;iBAChB;gBACL,EAAE,cAAc;gBAChB,MAAM,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"}
@@ -1,6 +0,0 @@
1
- module.exports = {
2
- "Clear search": `\u{6E05}\u{9664}\u{641C}\u{7D22}`
3
- };
4
-
5
-
6
- //# sourceMappingURL=zh-CN.main.js.map
@@ -1 +0,0 @@
1
- {"mappings":"AAAA,iBAAiB;IAAG,gBAAgB,CAAC,gCAAI,CAAC;AAC1C","sources":["packages/@react-aria/searchfield/intl/zh-CN.json"],"sourcesContent":["{\n \"Clear search\": \"清除搜索\"\n}\n"],"names":[],"version":3,"file":"zh-CN.main.js.map"}
package/dist/zh-CN.mjs DELETED
@@ -1,8 +0,0 @@
1
- var $117b536bfb1ae554$exports = {};
2
- $117b536bfb1ae554$exports = {
3
- "Clear search": `\u{6E05}\u{9664}\u{641C}\u{7D22}`
4
- };
5
-
6
-
7
- export {$117b536bfb1ae554$exports as default};
8
- //# sourceMappingURL=zh-CN.module.js.map
@@ -1,8 +0,0 @@
1
- var $117b536bfb1ae554$exports = {};
2
- $117b536bfb1ae554$exports = {
3
- "Clear search": `\u{6E05}\u{9664}\u{641C}\u{7D22}`
4
- };
5
-
6
-
7
- export {$117b536bfb1ae554$exports as default};
8
- //# sourceMappingURL=zh-CN.module.js.map
@@ -1 +0,0 @@
1
- {"mappings":";AAAA,4BAAiB;IAAG,gBAAgB,CAAC,gCAAI,CAAC;AAC1C","sources":["packages/@react-aria/searchfield/intl/zh-CN.json"],"sourcesContent":["{\n \"Clear search\": \"清除搜索\"\n}\n"],"names":[],"version":3,"file":"zh-CN.module.js.map"}
@@ -1,6 +0,0 @@
1
- module.exports = {
2
- "Clear search": `\u{6E05}\u{9664}\u{641C}\u{5C0B}\u{689D}\u{4EF6}`
3
- };
4
-
5
-
6
- //# sourceMappingURL=zh-TW.main.js.map
@@ -1 +0,0 @@
1
- {"mappings":"AAAA,iBAAiB;IAAG,gBAAgB,CAAC,gDAAM,CAAC;AAC5C","sources":["packages/@react-aria/searchfield/intl/zh-TW.json"],"sourcesContent":["{\n \"Clear search\": \"清除搜尋條件\"\n}\n"],"names":[],"version":3,"file":"zh-TW.main.js.map"}
package/dist/zh-TW.mjs DELETED
@@ -1,8 +0,0 @@
1
- var $525f6fa4ac26e278$exports = {};
2
- $525f6fa4ac26e278$exports = {
3
- "Clear search": `\u{6E05}\u{9664}\u{641C}\u{5C0B}\u{689D}\u{4EF6}`
4
- };
5
-
6
-
7
- export {$525f6fa4ac26e278$exports as default};
8
- //# sourceMappingURL=zh-TW.module.js.map
@@ -1,8 +0,0 @@
1
- var $525f6fa4ac26e278$exports = {};
2
- $525f6fa4ac26e278$exports = {
3
- "Clear search": `\u{6E05}\u{9664}\u{641C}\u{5C0B}\u{689D}\u{4EF6}`
4
- };
5
-
6
-
7
- export {$525f6fa4ac26e278$exports as default};
8
- //# sourceMappingURL=zh-TW.module.js.map
@@ -1 +0,0 @@
1
- {"mappings":";AAAA,4BAAiB;IAAG,gBAAgB,CAAC,gDAAM,CAAC;AAC5C","sources":["packages/@react-aria/searchfield/intl/zh-TW.json"],"sourcesContent":["{\n \"Clear search\": \"清除搜尋條件\"\n}\n"],"names":[],"version":3,"file":"zh-TW.module.js.map"}
@@ -1,131 +0,0 @@
1
- /*
2
- * Copyright 2020 Adobe. All rights reserved.
3
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License. You may obtain a copy
5
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- *
7
- * Unless required by applicable law or agreed to in writing, software distributed under
8
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- * OF ANY KIND, either express or implied. See the License for the specific language
10
- * governing permissions and limitations under the License.
11
- */
12
-
13
- import {AriaButtonProps} from '@react-types/button';
14
- import {AriaSearchFieldProps} from '@react-types/searchfield';
15
- import {chain} from '@react-aria/utils';
16
- import {DOMAttributes, RefObject, ValidationResult} from '@react-types/shared';
17
- import {InputHTMLAttributes, LabelHTMLAttributes} from 'react';
18
- // @ts-ignore
19
- import intlMessages from '../intl/*.json';
20
- import {SearchFieldState} from '@react-stately/searchfield';
21
- import {useLocalizedStringFormatter} from '@react-aria/i18n';
22
- import {useTextField} from '@react-aria/textfield';
23
-
24
- export interface SearchFieldAria extends ValidationResult {
25
- /** Props for the text field's visible label element (if any). */
26
- labelProps: LabelHTMLAttributes<HTMLLabelElement>,
27
- /** Props for the input element. */
28
- inputProps: InputHTMLAttributes<HTMLInputElement>,
29
- /** Props for the clear button. */
30
- clearButtonProps: AriaButtonProps,
31
- /** Props for the searchfield's description element, if any. */
32
- descriptionProps: DOMAttributes,
33
- /** Props for the searchfield's error message element, if any. */
34
- errorMessageProps: DOMAttributes
35
- }
36
-
37
- /**
38
- * Provides the behavior and accessibility implementation for a search field.
39
- * @param props - Props for the search field.
40
- * @param state - State for the search field, as returned by `useSearchFieldState`.
41
- * @param inputRef - A ref to the input element.
42
- */
43
- export function useSearchField(
44
- props: AriaSearchFieldProps,
45
- state: SearchFieldState,
46
- inputRef: RefObject<HTMLInputElement | null>
47
- ): SearchFieldAria {
48
- let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/searchfield');
49
- let {
50
- isDisabled,
51
- isReadOnly,
52
- onSubmit,
53
- onClear,
54
- type = 'search'
55
- } = props;
56
-
57
- let onKeyDown = (e) => {
58
- const key = e.key;
59
-
60
- if (key === 'Enter' && (isDisabled || isReadOnly)) {
61
- e.preventDefault();
62
- }
63
-
64
- if (isDisabled || isReadOnly) {
65
- return;
66
- }
67
-
68
- // for backward compatibility;
69
- // otherwise, "Enter" on an input would trigger a form submit, the default browser behavior
70
- if (key === 'Enter' && onSubmit) {
71
- e.preventDefault();
72
- onSubmit(state.value);
73
- }
74
-
75
- if (key === 'Escape') {
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 === '')) {
79
- e.continuePropagation();
80
- } else {
81
- e.preventDefault();
82
- state.setValue('');
83
- if (onClear) {
84
- onClear();
85
- }
86
- }
87
- }
88
- };
89
-
90
- let onClearButtonClick = () => {
91
- state.setValue('');
92
-
93
- if (onClear) {
94
- onClear();
95
- }
96
- };
97
-
98
- let onPressStart = () => {
99
- // this is in PressStart for mobile so that touching the clear button doesn't remove focus from
100
- // the input and close the keyboard
101
- inputRef.current?.focus();
102
- };
103
-
104
- let {labelProps, inputProps, descriptionProps, errorMessageProps, ...validation} = useTextField({
105
- ...props,
106
- value: state.value,
107
- onChange: state.setValue,
108
- onKeyDown: !isReadOnly ? chain(onKeyDown, props.onKeyDown) : props.onKeyDown,
109
- type
110
- }, inputRef);
111
-
112
- return {
113
- labelProps,
114
- inputProps: {
115
- ...inputProps,
116
- // already handled by useSearchFieldState
117
- defaultValue: undefined
118
- },
119
- clearButtonProps: {
120
- 'aria-label': stringFormatter.format('Clear search'),
121
- excludeFromTabOrder: true,
122
- preventFocusOnPress: true,
123
- isDisabled: isDisabled || isReadOnly,
124
- onPress: onClearButtonClick,
125
- onPressStart
126
- },
127
- descriptionProps,
128
- errorMessageProps,
129
- ...validation
130
- };
131
- }