antd-mobile 5.36.0 → 5.37.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 (244) hide show
  1. package/2x/bundle/antd-mobile.cjs.development.js +393 -295
  2. package/2x/bundle/antd-mobile.cjs.js +7 -7
  3. package/2x/bundle/antd-mobile.es.development.js +393 -295
  4. package/2x/bundle/antd-mobile.es.js +5619 -5550
  5. package/2x/bundle/antd-mobile.umd.development.js +393 -295
  6. package/2x/bundle/antd-mobile.umd.js +7 -7
  7. package/2x/bundle/style.css +5 -8
  8. package/2x/cjs/components/card/card.css +5 -5
  9. package/2x/cjs/components/card/card.patch.css +21 -0
  10. package/2x/cjs/components/center-popup/center-popup.js +46 -43
  11. package/2x/cjs/components/check-list/check-list.js +15 -11
  12. package/2x/cjs/components/collapse/collapse.d.ts +10 -2
  13. package/2x/cjs/components/collapse/collapse.js +54 -39
  14. package/2x/cjs/components/config-provider/config-provider.d.ts +40 -2
  15. package/2x/cjs/components/dropdown/context.d.ts +2 -0
  16. package/2x/cjs/components/dropdown/context.js +10 -0
  17. package/2x/cjs/components/dropdown/dropdown.d.ts +11 -3
  18. package/2x/cjs/components/dropdown/dropdown.js +23 -16
  19. package/2x/cjs/components/dropdown/index.d.ts +1 -0
  20. package/2x/cjs/components/dropdown/item.d.ts +5 -1
  21. package/2x/cjs/components/dropdown/item.js +22 -8
  22. package/2x/cjs/components/form/form-item.d.ts +6 -5
  23. package/2x/cjs/components/form/form-item.js +25 -17
  24. package/2x/cjs/components/form/form.d.ts +1 -1
  25. package/2x/cjs/components/form/index.d.ts +1 -1
  26. package/2x/cjs/components/input/input.d.ts +3 -1
  27. package/2x/cjs/components/input/input.js +53 -51
  28. package/2x/cjs/components/list/list-item.d.ts +6 -2
  29. package/2x/cjs/components/list/list-item.js +16 -6
  30. package/2x/cjs/components/nav-bar/nav-bar.d.ts +4 -0
  31. package/2x/cjs/components/nav-bar/nav-bar.js +18 -13
  32. package/2x/cjs/components/notice-bar/notice-bar.css +0 -3
  33. package/2x/cjs/components/notice-bar/notice-bar.d.ts +3 -1
  34. package/2x/cjs/components/notice-bar/notice-bar.js +30 -25
  35. package/2x/cjs/components/number-keyboard/number-keyboard.d.ts +1 -1
  36. package/2x/cjs/components/number-keyboard/number-keyboard.js +14 -13
  37. package/2x/cjs/components/popup/popup-base-props.d.ts +3 -2
  38. package/2x/cjs/components/popup/popup-base-props.js +4 -0
  39. package/2x/cjs/components/popup/popup.js +5 -5
  40. package/2x/cjs/components/result/result.js +3 -10
  41. package/2x/cjs/components/result/use-result-icon.d.ts +3 -0
  42. package/2x/cjs/components/result/use-result-icon.js +37 -0
  43. package/2x/cjs/components/result-page/result-page.js +3 -10
  44. package/2x/cjs/components/search-bar/search-bar.d.ts +10 -2
  45. package/2x/cjs/components/search-bar/search-bar.js +34 -33
  46. package/2x/cjs/components/toast/toast.d.ts +2 -2
  47. package/2x/cjs/components/toast/toast.js +4 -4
  48. package/2x/cjs/components/virtual-input/virtual-input.d.ts +5 -5
  49. package/2x/cjs/components/virtual-input/virtual-input.js +26 -24
  50. package/2x/cjs/locales/ar-SA.js +2 -2
  51. package/2x/cjs/locales/de-DE.js +3 -3
  52. package/2x/cjs/locales/es-ES.js +2 -2
  53. package/2x/cjs/locales/fr-FR.js +1 -1
  54. package/2x/cjs/locales/in-ID.d.ts +139 -0
  55. package/2x/cjs/locales/in-ID.js +149 -0
  56. package/2x/cjs/locales/ja-JP.js +2 -2
  57. package/2x/cjs/locales/th-TH.js +2 -2
  58. package/2x/cjs/utils/is-node-with-content.d.ts +3 -0
  59. package/2x/cjs/utils/is-node-with-content.js +3 -0
  60. package/2x/cjs/utils/use-mutation-effect.d.ts +1 -0
  61. package/2x/cjs/utils/use-mutation-effect.js +20 -9
  62. package/2x/cjs/utils/with-default-props.d.ts +7 -0
  63. package/2x/cjs/utils/with-default-props.js +21 -5
  64. package/2x/es/components/card/card.css +5 -5
  65. package/2x/es/components/card/card.patch.css +21 -0
  66. package/2x/es/components/center-popup/center-popup.js +45 -42
  67. package/2x/es/components/check-list/check-list.js +15 -11
  68. package/2x/es/components/collapse/collapse.d.ts +10 -2
  69. package/2x/es/components/collapse/collapse.js +53 -38
  70. package/2x/es/components/config-provider/config-provider.d.ts +40 -2
  71. package/2x/es/components/dropdown/context.d.ts +2 -0
  72. package/2x/es/components/dropdown/context.js +2 -0
  73. package/2x/es/components/dropdown/dropdown.d.ts +11 -3
  74. package/2x/es/components/dropdown/dropdown.js +24 -17
  75. package/2x/es/components/dropdown/index.d.ts +1 -0
  76. package/2x/es/components/dropdown/item.d.ts +5 -1
  77. package/2x/es/components/dropdown/item.js +22 -8
  78. package/2x/es/components/form/form-item.d.ts +6 -5
  79. package/2x/es/components/form/form-item.js +24 -16
  80. package/2x/es/components/form/form.d.ts +1 -1
  81. package/2x/es/components/form/index.d.ts +1 -1
  82. package/2x/es/components/input/input.d.ts +3 -1
  83. package/2x/es/components/input/input.js +52 -50
  84. package/2x/es/components/list/list-item.d.ts +6 -2
  85. package/2x/es/components/list/list-item.js +16 -6
  86. package/2x/es/components/nav-bar/nav-bar.d.ts +4 -0
  87. package/2x/es/components/nav-bar/nav-bar.js +18 -13
  88. package/2x/es/components/notice-bar/notice-bar.css +0 -3
  89. package/2x/es/components/notice-bar/notice-bar.d.ts +3 -1
  90. package/2x/es/components/notice-bar/notice-bar.js +29 -24
  91. package/2x/es/components/number-keyboard/number-keyboard.d.ts +1 -1
  92. package/2x/es/components/number-keyboard/number-keyboard.js +13 -12
  93. package/2x/es/components/popup/popup-base-props.d.ts +3 -2
  94. package/2x/es/components/popup/popup-base-props.js +3 -0
  95. package/2x/es/components/popup/popup.js +5 -5
  96. package/2x/es/components/result/result.js +3 -10
  97. package/2x/es/components/result/use-result-icon.d.ts +3 -0
  98. package/2x/es/components/result/use-result-icon.js +29 -0
  99. package/2x/es/components/result-page/result-page.js +3 -10
  100. package/2x/es/components/search-bar/search-bar.d.ts +10 -2
  101. package/2x/es/components/search-bar/search-bar.js +33 -32
  102. package/2x/es/components/toast/toast.d.ts +2 -2
  103. package/2x/es/components/toast/toast.js +3 -3
  104. package/2x/es/components/virtual-input/virtual-input.d.ts +5 -5
  105. package/2x/es/components/virtual-input/virtual-input.js +25 -23
  106. package/2x/es/locales/ar-SA.js +2 -2
  107. package/2x/es/locales/de-DE.js +3 -3
  108. package/2x/es/locales/es-ES.js +2 -2
  109. package/2x/es/locales/fr-FR.js +1 -1
  110. package/2x/es/locales/in-ID.d.ts +139 -0
  111. package/2x/es/locales/in-ID.js +142 -0
  112. package/2x/es/locales/ja-JP.js +2 -2
  113. package/2x/es/locales/th-TH.js +2 -2
  114. package/2x/es/utils/is-node-with-content.d.ts +3 -0
  115. package/2x/es/utils/is-node-with-content.js +3 -0
  116. package/2x/es/utils/use-mutation-effect.d.ts +1 -0
  117. package/2x/es/utils/use-mutation-effect.js +19 -9
  118. package/2x/es/utils/with-default-props.d.ts +7 -0
  119. package/2x/es/utils/with-default-props.js +20 -5
  120. package/2x/package.json +3 -2
  121. package/bundle/antd-mobile.cjs.development.js +393 -295
  122. package/bundle/antd-mobile.cjs.js +7 -7
  123. package/bundle/antd-mobile.compatible.umd.js +1 -1
  124. package/bundle/antd-mobile.es.development.js +393 -295
  125. package/bundle/antd-mobile.es.js +5619 -5550
  126. package/bundle/antd-mobile.umd.development.js +393 -295
  127. package/bundle/antd-mobile.umd.js +7 -7
  128. package/bundle/style.css +1 -1
  129. package/cjs/components/card/card.css +5 -5
  130. package/cjs/components/card/card.patch.css +17 -0
  131. package/cjs/components/center-popup/center-popup.js +46 -43
  132. package/cjs/components/check-list/check-list.js +15 -11
  133. package/cjs/components/collapse/collapse.d.ts +10 -2
  134. package/cjs/components/collapse/collapse.js +54 -39
  135. package/cjs/components/config-provider/config-provider.d.ts +40 -2
  136. package/cjs/components/dropdown/context.d.ts +2 -0
  137. package/cjs/components/dropdown/context.js +10 -0
  138. package/cjs/components/dropdown/dropdown.d.ts +11 -3
  139. package/cjs/components/dropdown/dropdown.js +23 -16
  140. package/cjs/components/dropdown/index.d.ts +1 -0
  141. package/cjs/components/dropdown/item.d.ts +5 -1
  142. package/cjs/components/dropdown/item.js +22 -8
  143. package/cjs/components/form/form-item.d.ts +6 -5
  144. package/cjs/components/form/form-item.js +25 -17
  145. package/cjs/components/form/form.d.ts +1 -1
  146. package/cjs/components/form/index.d.ts +1 -1
  147. package/cjs/components/input/input.d.ts +3 -1
  148. package/cjs/components/input/input.js +53 -51
  149. package/cjs/components/list/list-item.d.ts +6 -2
  150. package/cjs/components/list/list-item.js +16 -6
  151. package/cjs/components/nav-bar/nav-bar.d.ts +4 -0
  152. package/cjs/components/nav-bar/nav-bar.js +18 -13
  153. package/cjs/components/notice-bar/notice-bar.css +0 -2
  154. package/cjs/components/notice-bar/notice-bar.d.ts +3 -1
  155. package/cjs/components/notice-bar/notice-bar.js +30 -25
  156. package/cjs/components/number-keyboard/number-keyboard.d.ts +1 -1
  157. package/cjs/components/number-keyboard/number-keyboard.js +14 -13
  158. package/cjs/components/popup/popup-base-props.d.ts +3 -2
  159. package/cjs/components/popup/popup-base-props.js +4 -0
  160. package/cjs/components/popup/popup.js +5 -5
  161. package/cjs/components/result/result.js +3 -10
  162. package/cjs/components/result/use-result-icon.d.ts +3 -0
  163. package/cjs/components/result/use-result-icon.js +37 -0
  164. package/cjs/components/result-page/result-page.js +3 -10
  165. package/cjs/components/search-bar/search-bar.d.ts +10 -2
  166. package/cjs/components/search-bar/search-bar.js +34 -33
  167. package/cjs/components/toast/toast.css +1 -1
  168. package/cjs/components/toast/toast.d.ts +2 -2
  169. package/cjs/components/toast/toast.js +4 -4
  170. package/cjs/components/virtual-input/virtual-input.d.ts +5 -5
  171. package/cjs/components/virtual-input/virtual-input.js +26 -24
  172. package/cjs/locales/ar-SA.js +2 -2
  173. package/cjs/locales/de-DE.js +3 -3
  174. package/cjs/locales/es-ES.js +2 -2
  175. package/cjs/locales/fr-FR.js +1 -1
  176. package/cjs/locales/in-ID.d.ts +139 -0
  177. package/cjs/locales/in-ID.js +149 -0
  178. package/cjs/locales/ja-JP.js +2 -2
  179. package/cjs/locales/th-TH.js +2 -2
  180. package/cjs/utils/is-node-with-content.d.ts +3 -0
  181. package/cjs/utils/is-node-with-content.js +3 -0
  182. package/cjs/utils/use-mutation-effect.d.ts +1 -0
  183. package/cjs/utils/use-mutation-effect.js +20 -9
  184. package/cjs/utils/with-default-props.d.ts +7 -0
  185. package/cjs/utils/with-default-props.js +21 -5
  186. package/es/components/card/card.css +5 -5
  187. package/es/components/card/card.patch.css +17 -0
  188. package/es/components/center-popup/center-popup.js +45 -42
  189. package/es/components/check-list/check-list.js +15 -11
  190. package/es/components/collapse/collapse.d.ts +10 -2
  191. package/es/components/collapse/collapse.js +53 -38
  192. package/es/components/config-provider/config-provider.d.ts +40 -2
  193. package/es/components/dropdown/context.d.ts +2 -0
  194. package/es/components/dropdown/context.js +2 -0
  195. package/es/components/dropdown/dropdown.d.ts +11 -3
  196. package/es/components/dropdown/dropdown.js +24 -17
  197. package/es/components/dropdown/index.d.ts +1 -0
  198. package/es/components/dropdown/item.d.ts +5 -1
  199. package/es/components/dropdown/item.js +22 -8
  200. package/es/components/form/form-item.d.ts +6 -5
  201. package/es/components/form/form-item.js +24 -16
  202. package/es/components/form/form.d.ts +1 -1
  203. package/es/components/form/index.d.ts +1 -1
  204. package/es/components/input/input.d.ts +3 -1
  205. package/es/components/input/input.js +52 -50
  206. package/es/components/list/list-item.d.ts +6 -2
  207. package/es/components/list/list-item.js +16 -6
  208. package/es/components/nav-bar/nav-bar.d.ts +4 -0
  209. package/es/components/nav-bar/nav-bar.js +18 -13
  210. package/es/components/notice-bar/notice-bar.css +0 -2
  211. package/es/components/notice-bar/notice-bar.d.ts +3 -1
  212. package/es/components/notice-bar/notice-bar.js +29 -24
  213. package/es/components/number-keyboard/number-keyboard.d.ts +1 -1
  214. package/es/components/number-keyboard/number-keyboard.js +13 -12
  215. package/es/components/popup/popup-base-props.d.ts +3 -2
  216. package/es/components/popup/popup-base-props.js +3 -0
  217. package/es/components/popup/popup.js +5 -5
  218. package/es/components/result/result.js +3 -10
  219. package/es/components/result/use-result-icon.d.ts +3 -0
  220. package/es/components/result/use-result-icon.js +29 -0
  221. package/es/components/result-page/result-page.js +3 -10
  222. package/es/components/search-bar/search-bar.d.ts +10 -2
  223. package/es/components/search-bar/search-bar.js +33 -32
  224. package/es/components/toast/toast.css +1 -1
  225. package/es/components/toast/toast.d.ts +2 -2
  226. package/es/components/toast/toast.js +3 -3
  227. package/es/components/virtual-input/virtual-input.d.ts +5 -5
  228. package/es/components/virtual-input/virtual-input.js +25 -23
  229. package/es/locales/ar-SA.js +2 -2
  230. package/es/locales/de-DE.js +3 -3
  231. package/es/locales/es-ES.js +2 -2
  232. package/es/locales/fr-FR.js +1 -1
  233. package/es/locales/in-ID.d.ts +139 -0
  234. package/es/locales/in-ID.js +142 -0
  235. package/es/locales/ja-JP.js +2 -2
  236. package/es/locales/th-TH.js +2 -2
  237. package/es/utils/is-node-with-content.d.ts +3 -0
  238. package/es/utils/is-node-with-content.js +3 -0
  239. package/es/utils/use-mutation-effect.d.ts +1 -0
  240. package/es/utils/use-mutation-effect.js +19 -9
  241. package/es/utils/with-default-props.d.ts +7 -0
  242. package/es/utils/with-default-props.js +20 -5
  243. package/package.json +3 -2
  244. package/umd/antd-mobile.js +1 -1
@@ -1,32 +1,34 @@
1
- import React, { useState, forwardRef, useImperativeHandle, useRef } from 'react';
2
- import { usePropsValue } from '../../utils/use-props-value';
3
1
  import { CloseCircleFill } from 'antd-mobile-icons';
4
- import { withNativeProps } from '../../utils/native-props';
5
- import { mergeProps } from '../../utils/with-default-props';
6
2
  import classNames from 'classnames';
3
+ import React, { forwardRef, useImperativeHandle, useRef, useState } from 'react';
7
4
  import { bound } from '../../utils/bound';
5
+ import { withNativeProps } from '../../utils/native-props';
6
+ import { usePropsValue } from '../../utils/use-props-value';
8
7
  import { isIOS } from '../../utils/validate';
8
+ import { mergeProps } from '../../utils/with-default-props';
9
9
  import { useConfig } from '../config-provider';
10
10
  import useInputHandleKeyDown from './useInputHandleKeyDown';
11
11
  const classPrefix = `adm-input`;
12
12
  const defaultProps = {
13
13
  defaultValue: '',
14
+ clearIcon: React.createElement(CloseCircleFill, null),
14
15
  onlyShowClearWhenFocus: true
15
16
  };
16
- export const Input = forwardRef((p, ref) => {
17
- const props = mergeProps(defaultProps, p);
18
- const [value, setValue] = usePropsValue(props);
17
+ export const Input = forwardRef((props, ref) => {
18
+ const {
19
+ locale,
20
+ input: componentConfig = {}
21
+ } = useConfig();
22
+ const mergedProps = mergeProps(defaultProps, componentConfig, props);
23
+ const [value, setValue] = usePropsValue(mergedProps);
19
24
  const [hasFocus, setHasFocus] = useState(false);
20
25
  const compositionStartRef = useRef(false);
21
26
  const nativeInputRef = useRef(null);
22
- const {
23
- locale
24
- } = useConfig();
25
27
  const handleKeydown = useInputHandleKeyDown({
26
- onEnterPress: props.onEnterPress,
27
- onKeyDown: props.onKeyDown,
28
+ onEnterPress: mergedProps.onEnterPress,
29
+ onKeyDown: mergedProps.onKeyDown,
28
30
  nativeInputRef,
29
- enterKeyHint: props.enterKeyHint
31
+ enterKeyHint: mergedProps.enterKeyHint
30
32
  });
31
33
  useImperativeHandle(ref, () => ({
32
34
  clear: () => {
@@ -46,8 +48,8 @@ export const Input = forwardRef((p, ref) => {
46
48
  }));
47
49
  function checkValue() {
48
50
  let nextValue = value;
49
- if (props.type === 'number') {
50
- const boundValue = nextValue && bound(parseFloat(nextValue), props.min, props.max).toString();
51
+ if (mergedProps.type === 'number') {
52
+ const boundValue = nextValue && bound(parseFloat(nextValue), mergedProps.min, mergedProps.max).toString();
51
53
  // fix the display issue of numbers starting with 0
52
54
  if (Number(nextValue) !== Number(boundValue)) {
53
55
  nextValue = boundValue;
@@ -58,15 +60,15 @@ export const Input = forwardRef((p, ref) => {
58
60
  }
59
61
  }
60
62
  const shouldShowClear = (() => {
61
- if (!props.clearable || !value || props.readOnly) return false;
62
- if (props.onlyShowClearWhenFocus) {
63
+ if (!mergedProps.clearable || !value || mergedProps.readOnly) return false;
64
+ if (mergedProps.onlyShowClearWhenFocus) {
63
65
  return hasFocus;
64
66
  } else {
65
67
  return true;
66
68
  }
67
69
  })();
68
- return withNativeProps(props, React.createElement("div", {
69
- className: classNames(`${classPrefix}`, props.disabled && `${classPrefix}-disabled`)
70
+ return withNativeProps(mergedProps, React.createElement("div", {
71
+ className: classNames(`${classPrefix}`, mergedProps.disabled && `${classPrefix}-disabled`)
70
72
  }, React.createElement("input", {
71
73
  ref: nativeInputRef,
72
74
  className: `${classPrefix}-element`,
@@ -77,50 +79,50 @@ export const Input = forwardRef((p, ref) => {
77
79
  onFocus: e => {
78
80
  var _a;
79
81
  setHasFocus(true);
80
- (_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props, e);
82
+ (_a = mergedProps.onFocus) === null || _a === void 0 ? void 0 : _a.call(mergedProps, e);
81
83
  },
82
84
  onBlur: e => {
83
85
  var _a;
84
86
  setHasFocus(false);
85
87
  checkValue();
86
- (_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, e);
88
+ (_a = mergedProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(mergedProps, e);
87
89
  },
88
- id: props.id,
89
- placeholder: props.placeholder,
90
- disabled: props.disabled,
91
- readOnly: props.readOnly,
92
- maxLength: props.maxLength,
93
- minLength: props.minLength,
94
- max: props.max,
95
- min: props.min,
96
- autoComplete: props.autoComplete,
97
- enterKeyHint: props.enterKeyHint,
98
- autoFocus: props.autoFocus,
99
- pattern: props.pattern,
100
- inputMode: props.inputMode,
101
- type: props.type,
102
- name: props.name,
103
- autoCapitalize: props.autoCapitalize,
104
- autoCorrect: props.autoCorrect,
90
+ id: mergedProps.id,
91
+ placeholder: mergedProps.placeholder,
92
+ disabled: mergedProps.disabled,
93
+ readOnly: mergedProps.readOnly,
94
+ maxLength: mergedProps.maxLength,
95
+ minLength: mergedProps.minLength,
96
+ max: mergedProps.max,
97
+ min: mergedProps.min,
98
+ autoComplete: mergedProps.autoComplete,
99
+ enterKeyHint: mergedProps.enterKeyHint,
100
+ autoFocus: mergedProps.autoFocus,
101
+ pattern: mergedProps.pattern,
102
+ inputMode: mergedProps.inputMode,
103
+ type: mergedProps.type,
104
+ name: mergedProps.name,
105
+ autoCapitalize: mergedProps.autoCapitalize,
106
+ autoCorrect: mergedProps.autoCorrect,
105
107
  onKeyDown: handleKeydown,
106
- onKeyUp: props.onKeyUp,
108
+ onKeyUp: mergedProps.onKeyUp,
107
109
  onCompositionStart: e => {
108
110
  var _a;
109
111
  compositionStartRef.current = true;
110
- (_a = props.onCompositionStart) === null || _a === void 0 ? void 0 : _a.call(props, e);
112
+ (_a = mergedProps.onCompositionStart) === null || _a === void 0 ? void 0 : _a.call(mergedProps, e);
111
113
  },
112
114
  onCompositionEnd: e => {
113
115
  var _a;
114
116
  compositionStartRef.current = false;
115
- (_a = props.onCompositionEnd) === null || _a === void 0 ? void 0 : _a.call(props, e);
117
+ (_a = mergedProps.onCompositionEnd) === null || _a === void 0 ? void 0 : _a.call(mergedProps, e);
116
118
  },
117
- onClick: props.onClick,
118
- step: props.step,
119
- role: props.role,
120
- "aria-valuenow": props['aria-valuenow'],
121
- "aria-valuemax": props['aria-valuemax'],
122
- "aria-valuemin": props['aria-valuemin'],
123
- "aria-label": props['aria-label']
119
+ onClick: mergedProps.onClick,
120
+ step: mergedProps.step,
121
+ role: mergedProps.role,
122
+ "aria-valuenow": mergedProps['aria-valuenow'],
123
+ "aria-valuemax": mergedProps['aria-valuemax'],
124
+ "aria-valuemin": mergedProps['aria-valuemin'],
125
+ "aria-label": mergedProps['aria-label']
124
126
  }), shouldShowClear && React.createElement("div", {
125
127
  className: `${classPrefix}-clear`,
126
128
  onMouseDown: e => {
@@ -129,7 +131,7 @@ export const Input = forwardRef((p, ref) => {
129
131
  onClick: () => {
130
132
  var _a, _b;
131
133
  setValue('');
132
- (_a = props.onClear) === null || _a === void 0 ? void 0 : _a.call(props);
134
+ (_a = mergedProps.onClear) === null || _a === void 0 ? void 0 : _a.call(mergedProps);
133
135
  // https://github.com/ant-design/ant-design-mobile/issues/5212
134
136
  if (isIOS() && compositionStartRef.current) {
135
137
  compositionStartRef.current = false;
@@ -137,5 +139,5 @@ export const Input = forwardRef((p, ref) => {
137
139
  }
138
140
  },
139
141
  "aria-label": locale.Input.clear
140
- }, React.createElement(CloseCircleFill, null))));
142
+ }, mergedProps.clearIcon)));
141
143
  });
@@ -1,5 +1,5 @@
1
- import React from 'react';
2
1
  import type { FC, ReactNode } from 'react';
2
+ import React from 'react';
3
3
  import { NativeProps } from '../../utils/native-props';
4
4
  export declare type ListItemProps = {
5
5
  title?: ReactNode;
@@ -8,8 +8,12 @@ export declare type ListItemProps = {
8
8
  prefix?: ReactNode;
9
9
  extra?: ReactNode;
10
10
  clickable?: boolean;
11
- arrow?: boolean | ReactNode;
11
+ arrowIcon?: boolean | ReactNode;
12
12
  disabled?: boolean;
13
13
  onClick?: (e: React.MouseEvent<HTMLElement>) => void;
14
+ /**
15
+ * @deprecated use `arrowIcon` instead
16
+ */
17
+ arrow?: boolean | ReactNode;
14
18
  } & NativeProps<'--prefix-width' | '--align-items' | '--active-background-color'>;
15
19
  export declare const ListItem: FC<ListItemProps>;
@@ -1,13 +1,23 @@
1
- import React from 'react';
2
- import { withNativeProps } from '../../utils/native-props';
3
1
  import { RightOutline } from 'antd-mobile-icons';
4
2
  import classNames from 'classnames';
3
+ import React from 'react';
5
4
  import { isNodeWithContent } from '../../utils/is-node-with-content';
5
+ import { withNativeProps } from '../../utils/native-props';
6
+ import { mergeProp } from '../../utils/with-default-props';
7
+ import { useConfig } from '../config-provider';
6
8
  const classPrefix = `adm-list-item`;
7
9
  export const ListItem = props => {
8
- var _a;
10
+ var _a, _b;
11
+ const {
12
+ arrow,
13
+ arrowIcon
14
+ } = props;
15
+ const {
16
+ list: componentConfig = {}
17
+ } = useConfig();
9
18
  const clickable = (_a = props.clickable) !== null && _a !== void 0 ? _a : !!props.onClick;
10
- const arrow = props.arrow === undefined ? clickable : props.arrow;
19
+ const showArrow = (_b = arrow !== null && arrow !== void 0 ? arrow : arrowIcon) !== null && _b !== void 0 ? _b : clickable;
20
+ const mergedArrowIcon = mergeProp(componentConfig.arrowIcon, arrow !== true ? arrow : null, arrowIcon !== true ? arrowIcon : null);
11
21
  const content = React.createElement("div", {
12
22
  className: `${classPrefix}-content`
13
23
  }, isNodeWithContent(props.prefix) && React.createElement("div", {
@@ -20,9 +30,9 @@ export const ListItem = props => {
20
30
  className: `${classPrefix}-description`
21
31
  }, props.description)), isNodeWithContent(props.extra) && React.createElement("div", {
22
32
  className: `${classPrefix}-content-extra`
23
- }, props.extra), isNodeWithContent(arrow) && React.createElement("div", {
33
+ }, props.extra), showArrow && React.createElement("div", {
24
34
  className: `${classPrefix}-content-arrow`
25
- }, arrow === true ? React.createElement(RightOutline, null) : arrow));
35
+ }, mergedArrowIcon || React.createElement(RightOutline, null)));
26
36
  return withNativeProps(props, React.createElement(clickable ? 'a' : 'div', {
27
37
  className: classNames(`${classPrefix}`, clickable ? ['adm-plain-anchor'] : [], props.disabled && `${classPrefix}-disabled`),
28
38
  onClick: props.disabled ? undefined : props.onClick
@@ -2,6 +2,10 @@ import type { FC, ReactNode } from 'react';
2
2
  import { NativeProps } from '../../utils/native-props';
3
3
  export declare type NavBarProps = {
4
4
  back?: ReactNode;
5
+ backIcon?: boolean | ReactNode;
6
+ /**
7
+ * @deprecated use `backIcon` instead
8
+ */
5
9
  backArrow?: boolean | ReactNode;
6
10
  left?: ReactNode;
7
11
  right?: ReactNode;
@@ -1,33 +1,38 @@
1
- import React from 'react';
2
- import classNames from 'classnames';
3
1
  import { LeftOutline } from 'antd-mobile-icons';
2
+ import classNames from 'classnames';
3
+ import React from 'react';
4
4
  import { withNativeProps } from '../../utils/native-props';
5
5
  import { mergeProps } from '../../utils/with-default-props';
6
+ import { useConfig } from '../config-provider';
6
7
  const classPrefix = `adm-nav-bar`;
7
8
  const defaultProps = {
8
- backArrow: true
9
+ backIcon: true
9
10
  };
10
- export const NavBar = p => {
11
- const props = mergeProps(defaultProps, p);
11
+ export const NavBar = props => {
12
+ const {
13
+ navBar: componentConfig = {}
14
+ } = useConfig();
15
+ const mergedProps = mergeProps(defaultProps, componentConfig, props);
12
16
  const {
13
17
  back,
18
+ backIcon,
14
19
  backArrow
15
- } = props;
16
- return withNativeProps(props, React.createElement("div", {
20
+ } = mergedProps;
21
+ return withNativeProps(mergedProps, React.createElement("div", {
17
22
  className: classNames(classPrefix)
18
23
  }, React.createElement("div", {
19
24
  className: `${classPrefix}-left`,
20
25
  role: 'button'
21
26
  }, back !== null && React.createElement("div", {
22
27
  className: `${classPrefix}-back`,
23
- onClick: props.onBack
24
- }, backArrow && React.createElement("span", {
28
+ onClick: mergedProps.onBack
29
+ }, (backIcon || backArrow) && React.createElement("span", {
25
30
  className: `${classPrefix}-back-arrow`
26
- }, backArrow === true ? React.createElement(LeftOutline, null) : backArrow), React.createElement("span", {
31
+ }, backIcon === true || backArrow === true ? componentConfig.backIcon || React.createElement(LeftOutline, null) : backIcon || backArrow), React.createElement("span", {
27
32
  "aria-hidden": 'true'
28
- }, back)), props.left), React.createElement("div", {
33
+ }, back)), mergedProps.left), React.createElement("div", {
29
34
  className: `${classPrefix}-title`
30
- }, props.children), React.createElement("div", {
35
+ }, mergedProps.children), React.createElement("div", {
31
36
  className: `${classPrefix}-right`
32
- }, props.right)));
37
+ }, mergedProps.right)));
33
38
  };
@@ -80,9 +80,6 @@
80
80
  display: flex;
81
81
  align-items: center;
82
82
  justify-content: center;
83
- }
84
-
85
- .adm-notice-bar-close-icon {
86
83
  font-size: var(--adm-font-size-10);
87
84
  }
88
85
 
@@ -1,5 +1,5 @@
1
- import React from 'react';
2
1
  import type { ReactNode } from 'react';
2
+ import React from 'react';
3
3
  import { NativeProps } from '../../utils/native-props';
4
4
  export declare type NoticeBarProps = {
5
5
  /** The type of the NoticeBar */
@@ -12,6 +12,8 @@ export declare type NoticeBarProps = {
12
12
  content: ReactNode;
13
13
  /** Whether it can be closed */
14
14
  closeable?: boolean;
15
+ /** Custom close icon */
16
+ closeIcon?: ReactNode;
15
17
  /** Callback when closed */
16
18
  onClose?: () => void;
17
19
  /** Event when click */
@@ -1,29 +1,36 @@
1
- import React, { useState, useRef, memo } from 'react';
2
- import classNames from 'classnames';
3
- import { CloseOutline, SoundOutline } from 'antd-mobile-icons';
4
1
  import { useTimeout } from 'ahooks';
5
- import { mergeProps } from '../../utils/with-default-props';
2
+ import { CloseOutline, SoundOutline } from 'antd-mobile-icons';
3
+ import classNames from 'classnames';
4
+ import React, { memo, useRef, useState } from 'react';
6
5
  import { withNativeProps } from '../../utils/native-props';
7
- import { useResizeEffect } from '../../utils/use-resize-effect';
8
6
  import { useMutationEffect } from '../../utils/use-mutation-effect';
7
+ import { useResizeEffect } from '../../utils/use-resize-effect';
8
+ import { mergeProp, mergeProps } from '../../utils/with-default-props';
9
+ import { useConfig } from '../config-provider';
9
10
  const classPrefix = `adm-notice-bar`;
10
11
  const defaultProps = {
11
12
  color: 'default',
12
13
  delay: 2000,
13
14
  speed: 50,
14
- wrap: false,
15
- icon: React.createElement(SoundOutline, null)
15
+ icon: React.createElement(SoundOutline, null),
16
+ wrap: false
16
17
  };
17
- export const NoticeBar = memo(p => {
18
- const props = mergeProps(defaultProps, p);
18
+ export const NoticeBar = memo(props => {
19
+ const {
20
+ noticeBar: componentConfig = {}
21
+ } = useConfig();
22
+ const mergedProps = mergeProps(defaultProps, componentConfig, props);
23
+ const closeIcon = mergeProp(React.createElement(CloseOutline, {
24
+ className: `${classPrefix}-close-icon`
25
+ }), componentConfig.closeIcon, props.closeIcon);
19
26
  const containerRef = useRef(null);
20
27
  const textRef = useRef(null);
21
28
  const [visible, setVisible] = useState(true);
22
- const speed = props.speed;
29
+ const speed = mergedProps.speed;
23
30
  const delayLockRef = useRef(true);
24
31
  const animatingRef = useRef(false);
25
32
  function start() {
26
- if (delayLockRef.current || props.wrap) return;
33
+ if (delayLockRef.current || mergedProps.wrap) return;
27
34
  const container = containerRef.current;
28
35
  const text = textRef.current;
29
36
  if (!container || !text) return;
@@ -49,7 +56,7 @@ export const NoticeBar = memo(p => {
49
56
  useTimeout(() => {
50
57
  delayLockRef.current = false;
51
58
  start();
52
- }, props.delay);
59
+ }, mergedProps.delay);
53
60
  useResizeEffect(() => {
54
61
  start();
55
62
  }, containerRef);
@@ -61,14 +68,14 @@ export const NoticeBar = memo(p => {
61
68
  characterData: true
62
69
  });
63
70
  if (!visible) return null;
64
- return withNativeProps(props, React.createElement("div", {
65
- className: classNames(classPrefix, `${classPrefix}-${props.color}`, {
66
- [`${classPrefix}-wrap`]: props.wrap
71
+ return withNativeProps(mergedProps, React.createElement("div", {
72
+ className: classNames(classPrefix, `${classPrefix}-${mergedProps.color}`, {
73
+ [`${classPrefix}-wrap`]: mergedProps.wrap
67
74
  }),
68
- onClick: props.onClick
69
- }, props.icon && React.createElement("span", {
75
+ onClick: mergedProps.onClick
76
+ }, mergedProps.icon && React.createElement("span", {
70
77
  className: `${classPrefix}-left`
71
- }, props.icon), React.createElement("span", {
78
+ }, mergedProps.icon), React.createElement("span", {
72
79
  ref: containerRef,
73
80
  className: `${classPrefix}-content`
74
81
  }, React.createElement("span", {
@@ -78,16 +85,14 @@ export const NoticeBar = memo(p => {
78
85
  },
79
86
  ref: textRef,
80
87
  className: `${classPrefix}-content-inner`
81
- }, props.content)), (props.closeable || props.extra) && React.createElement("span", {
88
+ }, mergedProps.content)), (mergedProps.closeable || mergedProps.extra) && React.createElement("span", {
82
89
  className: `${classPrefix}-right`
83
- }, props.extra, props.closeable && React.createElement("div", {
90
+ }, mergedProps.extra, mergedProps.closeable && React.createElement("div", {
84
91
  className: `${classPrefix}-close`,
85
92
  onClick: () => {
86
93
  var _a;
87
94
  setVisible(false);
88
- (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
95
+ (_a = mergedProps.onClose) === null || _a === void 0 ? void 0 : _a.call(mergedProps);
89
96
  }
90
- }, React.createElement(CloseOutline, {
91
- className: `${classPrefix}-close-icon`
92
- })))));
97
+ }, closeIcon))));
93
98
  });
@@ -1,6 +1,6 @@
1
1
  import type { FC } from 'react';
2
- import { PopupProps } from '../popup';
3
2
  import { NativeProps } from '../../utils/native-props';
3
+ import { PopupProps } from '../popup';
4
4
  export declare type NumberKeyboardProps = {
5
5
  visible?: boolean;
6
6
  title?: string;
@@ -1,13 +1,13 @@
1
- import React, { useRef, useMemo } from 'react';
2
- import classNames from 'classnames';
1
+ import { useMemoizedFn } from 'ahooks';
3
2
  import { DownOutline, TextDeletionOutline } from 'antd-mobile-icons';
4
- import { mergeProps } from '../../utils/with-default-props';
3
+ import classNames from 'classnames';
4
+ import React, { useMemo, useRef } from 'react';
5
+ import { withNativeProps } from '../../utils/native-props';
5
6
  import { shuffle } from '../../utils/shuffle';
7
+ import { mergeProps } from '../../utils/with-default-props';
8
+ import { useConfig } from '../config-provider';
6
9
  import Popup from '../popup';
7
- import { withNativeProps } from '../../utils/native-props';
8
10
  import SafeArea from '../safe-area';
9
- import { useMemoizedFn } from 'ahooks';
10
- import { useConfig } from '../config-provider';
11
11
  const classPrefix = 'adm-number-keyboard';
12
12
  const defaultProps = {
13
13
  defaultVisible: false,
@@ -57,13 +57,13 @@ export const NumberKeyboard = p => {
57
57
  var _a;
58
58
  (_a = props.onDelete) === null || _a === void 0 ? void 0 : _a.call(props);
59
59
  });
60
- const onBackspacePressStart = () => {
60
+ const startContinueClear = () => {
61
61
  timeoutRef.current = window.setTimeout(() => {
62
62
  onDelete();
63
63
  intervalRef.current = window.setInterval(onDelete, 150);
64
64
  }, 700);
65
65
  };
66
- const onBackspacePressEnd = () => {
66
+ const stopContinueClear = () => {
67
67
  clearTimeout(timeoutRef.current);
68
68
  clearInterval(intervalRef.current);
69
69
  };
@@ -122,14 +122,15 @@ export const NumberKeyboard = p => {
122
122
  key: key,
123
123
  className: className,
124
124
  onTouchStart: () => {
125
+ stopContinueClear();
125
126
  if (key === 'BACKSPACE') {
126
- onBackspacePressStart();
127
+ startContinueClear();
127
128
  }
128
129
  },
129
130
  onTouchEnd: e => {
130
131
  onKeyPress(e, key);
131
132
  if (key === 'BACKSPACE') {
132
- onBackspacePressEnd();
133
+ stopContinueClear();
133
134
  }
134
135
  }
135
136
  }, ariaProps), key === 'BACKSPACE' ? React.createElement(TextDeletionOutline, null) : key);
@@ -161,11 +162,11 @@ export const NumberKeyboard = p => {
161
162
  }, React.createElement("div", {
162
163
  className: `${classPrefix}-key ${classPrefix}-key-extra ${classPrefix}-key-bs`,
163
164
  onTouchStart: () => {
164
- onBackspacePressStart();
165
+ startContinueClear();
165
166
  },
166
167
  onTouchEnd: e => {
167
168
  onKeyPress(e, 'BACKSPACE');
168
- onBackspacePressEnd();
169
+ stopContinueClear();
169
170
  },
170
171
  onContextMenu: e => {
171
172
  // Long press should not trigger native context menu
@@ -1,5 +1,4 @@
1
- import React from 'react';
2
- import type { CSSProperties } from 'react';
1
+ import React, { CSSProperties, ReactNode } from 'react';
3
2
  import { GetContainer } from '../../utils/render-to-container';
4
3
  import { MaskProps } from '../mask';
5
4
  import { PropagationEvent } from '../../utils/with-stop-propagation';
@@ -9,6 +8,7 @@ export declare type PopupBaseProps = {
9
8
  bodyClassName?: string;
10
9
  bodyStyle?: CSSProperties;
11
10
  closeOnMaskClick?: boolean;
11
+ closeIcon?: ReactNode;
12
12
  destroyOnClose?: boolean;
13
13
  disableBodyScroll?: boolean;
14
14
  forceRender?: boolean;
@@ -25,6 +25,7 @@ export declare type PopupBaseProps = {
25
25
  };
26
26
  export declare const defaultPopupBaseProps: {
27
27
  closeOnMaskClick: boolean;
28
+ closeIcon: React.JSX.Element;
28
29
  destroyOnClose: boolean;
29
30
  disableBodyScroll: boolean;
30
31
  forceRender: boolean;
@@ -1,5 +1,8 @@
1
+ import React from 'react';
2
+ import { CloseOutline } from 'antd-mobile-icons';
1
3
  export const defaultPopupBaseProps = {
2
4
  closeOnMaskClick: false,
5
+ closeIcon: React.createElement(CloseOutline, null),
3
6
  destroyOnClose: false,
4
7
  disableBodyScroll: true,
5
8
  forceRender: false,
@@ -9,7 +9,6 @@ import { renderToContainer } from '../../utils/render-to-container';
9
9
  import { useSpring, animated } from '@react-spring/web';
10
10
  import { withStopPropagation } from '../../utils/with-stop-propagation';
11
11
  import { ShouldRender } from '../../utils/should-render';
12
- import { CloseOutline } from 'antd-mobile-icons';
13
12
  import { defaultPopupBaseProps } from './popup-base-props';
14
13
  import { useInnerVisible } from '../../utils/use-inner-visible';
15
14
  import { useConfig } from '../config-provider';
@@ -20,11 +19,12 @@ const defaultProps = Object.assign(Object.assign({}, defaultPopupBaseProps), {
20
19
  position: 'bottom'
21
20
  });
22
21
  export const Popup = p => {
23
- const props = mergeProps(defaultProps, p);
24
- const bodyCls = classNames(`${classPrefix}-body`, props.bodyClassName, `${classPrefix}-body-position-${props.position}`);
25
22
  const {
26
- locale
23
+ locale,
24
+ popup: componentConfig = {}
27
25
  } = useConfig();
26
+ const props = mergeProps(defaultProps, componentConfig, p);
27
+ const bodyCls = classNames(`${classPrefix}-body`, props.bodyClassName, `${classPrefix}-body-position-${props.position}`);
28
28
  const [active, setActive] = useState(props.visible);
29
29
  const ref = useRef(null);
30
30
  useLockScroll(ref, props.disableBodyScroll && active ? 'strict' : false);
@@ -119,7 +119,7 @@ export const Popup = p => {
119
119
  },
120
120
  role: 'button',
121
121
  "aria-label": locale.common.close
122
- }, React.createElement(CloseOutline, null)), props.children))));
122
+ }, props.closeIcon), props.children))));
123
123
  return React.createElement(ShouldRender, {
124
124
  active: active,
125
125
  forceRender: props.forceRender,
@@ -1,16 +1,9 @@
1
1
  import React from 'react';
2
2
  import classNames from 'classnames';
3
- import { CheckCircleFill, CloseCircleFill, InformationCircleFill, ClockCircleFill, ExclamationCircleFill } from 'antd-mobile-icons';
4
3
  import { withNativeProps } from '../../utils/native-props';
5
4
  import { mergeProps } from '../../utils/with-default-props';
5
+ import { useResultIcon } from './use-result-icon';
6
6
  const classPrefix = `adm-result`;
7
- const iconRecord = {
8
- success: CheckCircleFill,
9
- error: CloseCircleFill,
10
- info: InformationCircleFill,
11
- waiting: ClockCircleFill,
12
- warning: ExclamationCircleFill
13
- };
14
7
  const defaultProps = {
15
8
  status: 'info'
16
9
  };
@@ -22,13 +15,13 @@ export const Result = p => {
22
15
  description,
23
16
  icon
24
17
  } = props;
18
+ const fallbackIcon = useResultIcon(status);
25
19
  if (!status) return null;
26
- const resultIcon = icon || React.createElement(iconRecord[status]);
27
20
  return withNativeProps(props, React.createElement("div", {
28
21
  className: classNames(classPrefix, `${classPrefix}-${status}`)
29
22
  }, React.createElement("div", {
30
23
  className: `${classPrefix}-icon`
31
- }, resultIcon), React.createElement("div", {
24
+ }, icon || fallbackIcon), React.createElement("div", {
32
25
  className: `${classPrefix}-title`
33
26
  }, title), !!description && React.createElement("div", {
34
27
  className: `${classPrefix}-description`
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ export declare type ResultIconProps = {};
3
+ export declare const useResultIcon: (status?: "error" | "waiting" | "success" | "warning" | "info" | undefined) => string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null;
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import { CheckCircleFill, CloseCircleFill, InformationCircleFill, ClockCircleFill, ExclamationCircleFill } from 'antd-mobile-icons';
3
+ import { useConfig } from '../config-provider';
4
+ export const useResultIcon = status => {
5
+ const {
6
+ result: componentConfig = {}
7
+ } = useConfig();
8
+ const {
9
+ successIcon = React.createElement(CheckCircleFill, null),
10
+ errorIcon = React.createElement(CloseCircleFill, null),
11
+ infoIcon = React.createElement(InformationCircleFill, null),
12
+ waitingIcon = React.createElement(ClockCircleFill, null),
13
+ warningIcon = React.createElement(ExclamationCircleFill, null)
14
+ } = componentConfig || {};
15
+ switch (status) {
16
+ case 'success':
17
+ return successIcon;
18
+ case 'error':
19
+ return errorIcon;
20
+ case 'info':
21
+ return infoIcon;
22
+ case 'waiting':
23
+ return waitingIcon;
24
+ case 'warning':
25
+ return warningIcon;
26
+ default:
27
+ return null;
28
+ }
29
+ };