antd-mobile 5.17.1 → 5.19.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 (219) hide show
  1. package/2x/bundle/antd-mobile.cjs.js +47 -19173
  2. package/2x/bundle/antd-mobile.compatible.umd.js +25752 -0
  3. package/2x/bundle/antd-mobile.es.js +16416 -17055
  4. package/2x/bundle/antd-mobile.umd.js +64 -0
  5. package/2x/bundle/style.css +240 -277
  6. package/2x/cjs/components/action-sheet/action-sheet.d.ts +1 -1
  7. package/2x/cjs/components/button/button.js +1 -1
  8. package/2x/cjs/components/calendar/calendar.d.ts +3 -3
  9. package/2x/cjs/components/calendar/index.d.ts +1 -1
  10. package/2x/cjs/components/cascader/cascader.d.ts +2 -0
  11. package/2x/cjs/components/cascader/index.d.ts +1 -0
  12. package/2x/cjs/components/cascader-view/cascader-view.d.ts +2 -1
  13. package/2x/cjs/components/cascader-view/cascader-view.js +2 -1
  14. package/2x/cjs/components/dialog/show.d.ts +1 -1
  15. package/2x/cjs/components/floating-panel/floating-panel.css +4 -4
  16. package/2x/cjs/components/form/form-item.js +6 -4
  17. package/2x/cjs/components/image-viewer/slide.js +75 -56
  18. package/2x/cjs/components/input/input.js +9 -2
  19. package/2x/cjs/components/modal/show.d.ts +1 -1
  20. package/2x/cjs/components/notice-bar/notice-bar.css +9 -0
  21. package/2x/cjs/components/notice-bar/notice-bar.js +5 -3
  22. package/2x/cjs/components/number-keyboard/number-keyboard.css +11 -15
  23. package/2x/cjs/components/number-keyboard/number-keyboard.d.ts +1 -1
  24. package/2x/cjs/components/number-keyboard/number-keyboard.js +19 -17
  25. package/2x/cjs/components/passcode-input/index.d.ts +1 -1
  26. package/2x/cjs/components/passcode-input/passcode-input.css +12 -12
  27. package/2x/cjs/components/passcode-input/passcode-input.js +16 -8
  28. package/2x/cjs/components/picker-view/wheel.js +1 -1
  29. package/2x/cjs/components/rate/rate.js +7 -2
  30. package/2x/cjs/components/rate/star.js +0 -10
  31. package/2x/cjs/components/result/result.d.ts +1 -1
  32. package/2x/cjs/components/result/result.js +7 -1
  33. package/2x/cjs/components/search-bar/search-bar.js +12 -2
  34. package/2x/cjs/components/switch/switch.d.ts +2 -1
  35. package/2x/cjs/components/switch/switch.js +16 -3
  36. package/2x/cjs/components/text-area/text-area.js +1 -0
  37. package/2x/cjs/locales/base.d.ts +9 -0
  38. package/2x/cjs/locales/base.js +9 -0
  39. package/2x/cjs/locales/en-US.d.ts +9 -0
  40. package/2x/cjs/locales/es-ES.d.ts +9 -0
  41. package/2x/cjs/locales/fa-IR.d.ts +9 -0
  42. package/2x/cjs/locales/fr-FR.d.ts +9 -0
  43. package/2x/cjs/locales/id-ID.d.ts +9 -0
  44. package/2x/cjs/locales/kk-KZ.d.ts +9 -0
  45. package/2x/cjs/locales/ko-KR.d.ts +9 -0
  46. package/2x/cjs/locales/zh-CN.d.ts +9 -0
  47. package/2x/cjs/locales/zh-CN.js +9 -0
  48. package/2x/cjs/locales/zh-HK.d.ts +9 -0
  49. package/2x/cjs/locales/zh-TW.d.ts +9 -0
  50. package/2x/cjs/utils/matrix.d.ts +10 -0
  51. package/2x/cjs/utils/matrix.js +60 -0
  52. package/2x/cjs/utils/merge-locale.d.ts +1 -1
  53. package/2x/cjs/utils/merge-locale.js +15 -5
  54. package/2x/cjs/utils/use-drag-and-pinch.d.ts +1 -1
  55. package/2x/cjs/utils/use-props-value.js +1 -1
  56. package/2x/cjs/utils/with-default-props.js +2 -6
  57. package/2x/es/components/action-sheet/action-sheet.d.ts +1 -1
  58. package/2x/es/components/button/button.js +1 -1
  59. package/2x/es/components/calendar/calendar.d.ts +3 -3
  60. package/2x/es/components/calendar/index.d.ts +1 -1
  61. package/2x/es/components/cascader/cascader.d.ts +2 -0
  62. package/2x/es/components/cascader/index.d.ts +1 -0
  63. package/2x/es/components/cascader-view/cascader-view.d.ts +2 -1
  64. package/2x/es/components/cascader-view/cascader-view.js +2 -1
  65. package/2x/es/components/dialog/show.d.ts +1 -1
  66. package/2x/es/components/floating-panel/floating-panel.css +4 -4
  67. package/2x/es/components/form/form-item.js +5 -4
  68. package/2x/es/components/image-viewer/slide.js +73 -56
  69. package/2x/es/components/input/input.js +8 -2
  70. package/2x/es/components/modal/show.d.ts +1 -1
  71. package/2x/es/components/notice-bar/notice-bar.css +9 -0
  72. package/2x/es/components/notice-bar/notice-bar.js +5 -3
  73. package/2x/es/components/number-keyboard/number-keyboard.css +11 -15
  74. package/2x/es/components/number-keyboard/number-keyboard.d.ts +1 -1
  75. package/2x/es/components/number-keyboard/number-keyboard.js +19 -17
  76. package/2x/es/components/passcode-input/index.d.ts +1 -1
  77. package/2x/es/components/passcode-input/passcode-input.css +12 -12
  78. package/2x/es/components/passcode-input/passcode-input.js +15 -8
  79. package/2x/es/components/picker-view/wheel.js +1 -1
  80. package/2x/es/components/rate/rate.js +7 -2
  81. package/2x/es/components/rate/star.js +0 -10
  82. package/2x/es/components/result/result.d.ts +1 -1
  83. package/2x/es/components/result/result.js +6 -1
  84. package/2x/es/components/search-bar/search-bar.js +12 -2
  85. package/2x/es/components/switch/switch.d.ts +2 -1
  86. package/2x/es/components/switch/switch.js +15 -3
  87. package/2x/es/components/text-area/text-area.js +1 -0
  88. package/2x/es/locales/base.d.ts +9 -0
  89. package/2x/es/locales/base.js +9 -0
  90. package/2x/es/locales/en-US.d.ts +9 -0
  91. package/2x/es/locales/es-ES.d.ts +9 -0
  92. package/2x/es/locales/fa-IR.d.ts +9 -0
  93. package/2x/es/locales/fr-FR.d.ts +9 -0
  94. package/2x/es/locales/id-ID.d.ts +9 -0
  95. package/2x/es/locales/kk-KZ.d.ts +9 -0
  96. package/2x/es/locales/ko-KR.d.ts +9 -0
  97. package/2x/es/locales/zh-CN.d.ts +9 -0
  98. package/2x/es/locales/zh-CN.js +9 -0
  99. package/2x/es/locales/zh-HK.d.ts +9 -0
  100. package/2x/es/locales/zh-TW.d.ts +9 -0
  101. package/2x/es/utils/matrix.d.ts +10 -0
  102. package/2x/es/utils/matrix.js +27 -0
  103. package/2x/es/utils/merge-locale.d.ts +1 -1
  104. package/2x/es/utils/merge-locale.js +17 -3
  105. package/2x/es/utils/use-drag-and-pinch.d.ts +1 -1
  106. package/2x/es/utils/use-props-value.js +1 -1
  107. package/2x/es/utils/with-default-props.js +2 -4
  108. package/2x/package.json +4 -4
  109. package/2x/umd/antd-mobile.js +25752 -2
  110. package/bundle/antd-mobile.cjs.js +47 -19173
  111. package/bundle/antd-mobile.compatible.umd.js +25752 -0
  112. package/bundle/antd-mobile.es.js +16416 -17055
  113. package/bundle/antd-mobile.umd.js +64 -0
  114. package/bundle/style.css +1 -4080
  115. package/cjs/components/action-sheet/action-sheet.d.ts +1 -1
  116. package/cjs/components/button/button.js +1 -1
  117. package/cjs/components/calendar/calendar.d.ts +3 -3
  118. package/cjs/components/calendar/index.d.ts +1 -1
  119. package/cjs/components/cascader/cascader.d.ts +2 -0
  120. package/cjs/components/cascader/index.d.ts +1 -0
  121. package/cjs/components/cascader-view/cascader-view.d.ts +2 -1
  122. package/cjs/components/cascader-view/cascader-view.js +2 -1
  123. package/cjs/components/dialog/show.d.ts +1 -1
  124. package/cjs/components/floating-panel/floating-panel.css +4 -4
  125. package/cjs/components/form/form-item.js +6 -4
  126. package/cjs/components/image-viewer/slide.js +75 -56
  127. package/cjs/components/input/input.js +9 -2
  128. package/cjs/components/modal/show.d.ts +1 -1
  129. package/cjs/components/notice-bar/notice-bar.css +8 -0
  130. package/cjs/components/notice-bar/notice-bar.js +5 -3
  131. package/cjs/components/number-keyboard/number-keyboard.css +11 -14
  132. package/cjs/components/number-keyboard/number-keyboard.d.ts +1 -1
  133. package/cjs/components/number-keyboard/number-keyboard.js +19 -17
  134. package/cjs/components/passcode-input/index.d.ts +1 -1
  135. package/cjs/components/passcode-input/passcode-input.css +12 -12
  136. package/cjs/components/passcode-input/passcode-input.js +16 -8
  137. package/cjs/components/picker-view/wheel.js +1 -1
  138. package/cjs/components/rate/rate.js +7 -2
  139. package/cjs/components/rate/star.js +0 -10
  140. package/cjs/components/result/result.d.ts +1 -1
  141. package/cjs/components/result/result.js +7 -1
  142. package/cjs/components/search-bar/search-bar.js +12 -2
  143. package/cjs/components/switch/switch.d.ts +2 -1
  144. package/cjs/components/switch/switch.js +16 -3
  145. package/cjs/components/text-area/text-area.js +1 -0
  146. package/cjs/locales/base.d.ts +9 -0
  147. package/cjs/locales/base.js +9 -0
  148. package/cjs/locales/en-US.d.ts +9 -0
  149. package/cjs/locales/es-ES.d.ts +9 -0
  150. package/cjs/locales/fa-IR.d.ts +9 -0
  151. package/cjs/locales/fr-FR.d.ts +9 -0
  152. package/cjs/locales/id-ID.d.ts +9 -0
  153. package/cjs/locales/kk-KZ.d.ts +9 -0
  154. package/cjs/locales/ko-KR.d.ts +9 -0
  155. package/cjs/locales/zh-CN.d.ts +9 -0
  156. package/cjs/locales/zh-CN.js +9 -0
  157. package/cjs/locales/zh-HK.d.ts +9 -0
  158. package/cjs/locales/zh-TW.d.ts +9 -0
  159. package/cjs/utils/matrix.d.ts +10 -0
  160. package/cjs/utils/matrix.js +60 -0
  161. package/cjs/utils/merge-locale.d.ts +1 -1
  162. package/cjs/utils/merge-locale.js +15 -5
  163. package/cjs/utils/use-drag-and-pinch.d.ts +1 -1
  164. package/cjs/utils/use-props-value.js +1 -1
  165. package/cjs/utils/with-default-props.js +2 -6
  166. package/es/components/action-sheet/action-sheet.d.ts +1 -1
  167. package/es/components/button/button.js +1 -1
  168. package/es/components/calendar/calendar.d.ts +3 -3
  169. package/es/components/calendar/index.d.ts +1 -1
  170. package/es/components/cascader/cascader.d.ts +2 -0
  171. package/es/components/cascader/index.d.ts +1 -0
  172. package/es/components/cascader-view/cascader-view.d.ts +2 -1
  173. package/es/components/cascader-view/cascader-view.js +2 -1
  174. package/es/components/dialog/show.d.ts +1 -1
  175. package/es/components/floating-panel/floating-panel.css +4 -4
  176. package/es/components/form/form-item.js +5 -4
  177. package/es/components/image-viewer/slide.js +73 -56
  178. package/es/components/input/input.js +8 -2
  179. package/es/components/modal/show.d.ts +1 -1
  180. package/es/components/notice-bar/notice-bar.css +8 -0
  181. package/es/components/notice-bar/notice-bar.js +5 -3
  182. package/es/components/number-keyboard/number-keyboard.css +11 -14
  183. package/es/components/number-keyboard/number-keyboard.d.ts +1 -1
  184. package/es/components/number-keyboard/number-keyboard.js +19 -17
  185. package/es/components/passcode-input/index.d.ts +1 -1
  186. package/es/components/passcode-input/passcode-input.css +12 -12
  187. package/es/components/passcode-input/passcode-input.js +15 -8
  188. package/es/components/picker-view/wheel.js +1 -1
  189. package/es/components/rate/rate.js +7 -2
  190. package/es/components/rate/star.js +0 -10
  191. package/es/components/result/result.d.ts +1 -1
  192. package/es/components/result/result.js +6 -1
  193. package/es/components/search-bar/search-bar.js +12 -2
  194. package/es/components/switch/switch.d.ts +2 -1
  195. package/es/components/switch/switch.js +15 -3
  196. package/es/components/text-area/text-area.js +1 -0
  197. package/es/locales/base.d.ts +9 -0
  198. package/es/locales/base.js +9 -0
  199. package/es/locales/en-US.d.ts +9 -0
  200. package/es/locales/es-ES.d.ts +9 -0
  201. package/es/locales/fa-IR.d.ts +9 -0
  202. package/es/locales/fr-FR.d.ts +9 -0
  203. package/es/locales/id-ID.d.ts +9 -0
  204. package/es/locales/kk-KZ.d.ts +9 -0
  205. package/es/locales/ko-KR.d.ts +9 -0
  206. package/es/locales/zh-CN.d.ts +9 -0
  207. package/es/locales/zh-CN.js +9 -0
  208. package/es/locales/zh-HK.d.ts +9 -0
  209. package/es/locales/zh-TW.d.ts +9 -0
  210. package/es/utils/matrix.d.ts +10 -0
  211. package/es/utils/matrix.js +27 -0
  212. package/es/utils/merge-locale.d.ts +1 -1
  213. package/es/utils/merge-locale.js +17 -3
  214. package/es/utils/use-drag-and-pinch.d.ts +1 -1
  215. package/es/utils/use-props-value.js +1 -1
  216. package/es/utils/with-default-props.js +2 -4
  217. package/package.json +4 -4
  218. package/umd/antd-mobile.js +1 -1
  219. package/2x/umd/antd-mobile.js.LICENSE.txt +0 -35
@@ -7,6 +7,7 @@ import classNames from 'classnames';
7
7
  import { useIsomorphicLayoutEffect } from 'ahooks';
8
8
  import { bound } from '../../utils/bound';
9
9
  import { isIOS } from '../../utils/validate';
10
+ import { useConfig } from '../config-provider';
10
11
  const classPrefix = `adm-input`;
11
12
  const defaultProps = {
12
13
  defaultValue: '',
@@ -18,6 +19,9 @@ export const Input = forwardRef((p, ref) => {
18
19
  const [hasFocus, setHasFocus] = useState(false);
19
20
  const compositionStartRef = useRef(false);
20
21
  const nativeInputRef = useRef(null);
22
+ const {
23
+ locale
24
+ } = useConfig();
21
25
  useImperativeHandle(ref, () => ({
22
26
  clear: () => {
23
27
  setValue('');
@@ -139,7 +143,8 @@ export const Input = forwardRef((p, ref) => {
139
143
  role: props.role,
140
144
  "aria-valuenow": props['aria-valuenow'],
141
145
  "aria-valuemax": props['aria-valuemax'],
142
- "aria-valuemin": props['aria-valuemin']
146
+ "aria-valuemin": props['aria-valuemin'],
147
+ "aria-label": props['aria-label']
143
148
  }), shouldShowClear && React.createElement("div", {
144
149
  className: `${classPrefix}-clear`,
145
150
  onMouseDown: e => {
@@ -155,6 +160,7 @@ export const Input = forwardRef((p, ref) => {
155
160
  compositionStartRef.current = false;
156
161
  (_b = nativeInputRef.current) === null || _b === void 0 ? void 0 : _b.blur();
157
162
  }
158
- }
163
+ },
164
+ "aria-label": locale.Input.clear
159
165
  }, React.createElement(CloseCircleFill, null))));
160
166
  });
@@ -1,5 +1,5 @@
1
1
  import { ModalProps } from './modal';
2
- export declare type ModalShowProps = Omit<ModalProps, 'visible'>;
2
+ export declare type ModalShowProps = Omit<ModalProps, 'visible' | 'destroyOnClose' | 'forceRender'>;
3
3
  export declare type ModalShowHandler = {
4
4
  close: () => void;
5
5
  };
@@ -70,6 +70,15 @@
70
70
  margin-left: 24px;
71
71
  }
72
72
 
73
+ .adm-notice-bar-close {
74
+ width: 48px;
75
+ height: 48px;
76
+ margin-right: -6px;
77
+ display: flex;
78
+ align-items: center;
79
+ justify-content: center;
80
+ }
81
+
73
82
  .adm-notice-bar-close-icon {
74
83
  font-size: var(--adm-font-size-10);
75
84
  }
@@ -82,13 +82,15 @@ export const NoticeBar = memo(p => {
82
82
  className: `${classPrefix}-content-inner`
83
83
  }, props.content)), (props.closeable || props.extra) && React.createElement("span", {
84
84
  className: `${classPrefix}-right`
85
- }, props.extra, props.closeable && React.createElement(CloseOutline, {
86
- className: `${classPrefix}-close-icon`,
85
+ }, props.extra, props.closeable && React.createElement("div", {
86
+ className: `${classPrefix}-close`,
87
87
  onClick: () => {
88
88
  var _a;
89
89
 
90
90
  setVisible(false);
91
91
  (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
92
92
  }
93
- }))));
93
+ }, React.createElement(CloseOutline, {
94
+ className: `${classPrefix}-close-icon`
95
+ })))));
94
96
  });
@@ -4,7 +4,7 @@
4
4
  flex: 1;
5
5
  }
6
6
 
7
- .adm-number-keyboard-main.confirmed-style .sign-key {
7
+ .adm-number-keyboard-main.adm-number-keyboard-main-confirmed-style .adm-number-keyboard-key-sign {
8
8
  background-color: var(--adm-color-white);
9
9
  }
10
10
 
@@ -40,11 +40,11 @@
40
40
  font-size: 32px;
41
41
  }
42
42
 
43
- .adm-number-keyboard-header.with-title {
43
+ .adm-number-keyboard-header.adm-number-keyboard-header-with-title {
44
44
  justify-content: space-between;
45
45
  }
46
46
 
47
- .adm-number-keyboard-header.with-title .adm-number-keyboard-header-close-button {
47
+ .adm-number-keyboard-header.adm-number-keyboard-header-with-title .adm-number-keyboard-header-close-button {
48
48
  padding-right: 0;
49
49
  }
50
50
 
@@ -97,37 +97,33 @@
97
97
  box-sizing: content-box;
98
98
  }
99
99
 
100
- .adm-number-keyboard-key.mid-key {
100
+ .adm-number-keyboard-key.adm-number-keyboard-key-mid {
101
101
  flex-basis: 66.67%;
102
102
  }
103
103
 
104
- .adm-number-keyboard-key.sign-key:active::before {
104
+ .adm-number-keyboard-key.adm-number-keyboard-key-sign:active::before {
105
105
  opacity: 0.1;
106
106
  }
107
107
 
108
- .adm-number-keyboard-key.extra-key {
108
+ .adm-number-keyboard-key.adm-number-keyboard-key-extra {
109
109
  border-left: solid 2px var(--adm-color-border);
110
110
  border-right: none;
111
111
  }
112
112
 
113
- .adm-number-keyboard-key.extra-key,
114
- .adm-number-keyboard-key.number-key {
113
+ .adm-number-keyboard-key.adm-number-keyboard-key-extra,
114
+ .adm-number-keyboard-key.adm-number-keyboard-key-number {
115
115
  background-color: var(--adm-color-background);
116
116
  }
117
117
 
118
- .adm-number-keyboard-key.extra-key:active::before,
119
- .adm-number-keyboard-key.number-key:active::before {
118
+ .adm-number-keyboard-key.adm-number-keyboard-key-extra:active::before,
119
+ .adm-number-keyboard-key.adm-number-keyboard-key-number:active::before {
120
120
  opacity: 0.1;
121
121
  }
122
122
 
123
- .adm-number-keyboard-key.ok-key {
123
+ .adm-number-keyboard-key.adm-number-keyboard-key-ok {
124
124
  background-color: var(--adm-color-primary);
125
125
  color: var(--adm-color-white);
126
126
  height: 288px;
127
127
  font-size: 32px;
128
128
  border: none;
129
- }
130
-
131
- .adm-number-keyboard-bs-key {
132
- height: 40px;
133
129
  }
@@ -5,7 +5,7 @@ export declare type NumberKeyboardProps = {
5
5
  visible?: boolean;
6
6
  title?: string;
7
7
  confirmText?: string | null;
8
- customKey?: '-' | '.' | 'X';
8
+ customKey?: string | [string, string];
9
9
  randomOrder?: boolean;
10
10
  showCloseButton?: boolean;
11
11
  onInput?: (v: string) => void;
@@ -34,13 +34,18 @@ export const NumberKeyboard = p => {
34
34
  const keys = useMemo(() => {
35
35
  const defaultKeys = ['1', '2', '3', '4', '5', '6', '7', '8', '9'];
36
36
  const keyList = randomOrder ? shuffle(defaultKeys) : defaultKeys;
37
+ const customKeys = Array.isArray(customKey) ? customKey : [customKey];
37
38
  keyList.push('0');
38
39
 
39
40
  if (confirmText) {
40
- keyList.push(customKey || '');
41
+ if (customKeys.length === 2) {
42
+ keyList.splice(9, 0, customKeys.pop());
43
+ }
44
+
45
+ keyList.push(customKeys[0] || '');
41
46
  } else {
42
- keyList.splice(9, 0, customKey || '');
43
- keyList.push('BACKSPACE');
47
+ keyList.splice(9, 0, customKeys[0] || '');
48
+ keyList.push(customKeys[1] || 'BACKSPACE');
44
49
  }
45
50
 
46
51
  return keyList;
@@ -63,8 +68,7 @@ export const NumberKeyboard = p => {
63
68
  const onBackspacePressEnd = () => {
64
69
  clearTimeout(timeoutRef.current);
65
70
  clearInterval(intervalRef.current);
66
- }; // 点击键盘按键
67
-
71
+ };
68
72
 
69
73
  const onKeyPress = (e, key) => {
70
74
  var _a, _b;
@@ -86,18 +90,17 @@ export const NumberKeyboard = p => {
86
90
  break;
87
91
 
88
92
  default:
89
- // customKey 不存在时,点击该键不应该触发 onInput
93
+ // onInput should't be called when customKey doesn't exist
90
94
  if (key !== '') onInput === null || onInput === void 0 ? void 0 : onInput(key);
91
95
  break;
92
96
  }
93
- }; // 渲染 title 和 close button
94
-
97
+ };
95
98
 
96
99
  const renderHeader = () => {
97
100
  if (!showCloseButton && !title) return null;
98
101
  return React.createElement("div", {
99
102
  className: classNames(`${classPrefix}-header`, {
100
- 'with-title': !!title
103
+ [`${classPrefix}-header-with-title`]: !!title
101
104
  })
102
105
  }, title && React.createElement("div", {
103
106
  className: `${classPrefix}-title`
@@ -111,15 +114,14 @@ export const NumberKeyboard = p => {
111
114
  role: 'button',
112
115
  title: 'CLOSE'
113
116
  }, React.createElement(DownOutline, null)));
114
- }; // 渲染基础键盘按键
115
-
117
+ };
116
118
 
117
119
  const renderKey = (key, index) => {
118
120
  const isNumberKey = /^\d$/.test(key);
119
121
  const className = classNames(`${classPrefix}-key`, {
120
- 'number-key': isNumberKey,
121
- 'sign-key': !isNumberKey && key,
122
- 'mid-key': index === 9 && !!confirmText
122
+ [`${classPrefix}-key-number`]: isNumberKey,
123
+ [`${classPrefix}-key-sign`]: !isNumberKey && key,
124
+ [`${classPrefix}-key-mid`]: index === 9 && !!confirmText && keys.length < 12
123
125
  });
124
126
  const ariaProps = key ? {
125
127
  role: 'button',
@@ -163,12 +165,12 @@ export const NumberKeyboard = p => {
163
165
  className: `${classPrefix}-wrapper`
164
166
  }, React.createElement("div", {
165
167
  className: classNames(`${classPrefix}-main`, {
166
- 'confirmed-style': !!confirmText
168
+ [`${classPrefix}-main-confirmed-style`]: !!confirmText
167
169
  })
168
170
  }, keys.map(renderKey)), !!confirmText && React.createElement("div", {
169
171
  className: `${classPrefix}-confirm`
170
172
  }, React.createElement("div", {
171
- className: `${classPrefix}-key extra-key bs-key`,
173
+ className: `${classPrefix}-key ${classPrefix}-key-extra ${classPrefix}-key-bs`,
172
174
  onTouchStart: () => {
173
175
  onBackspacePressStart();
174
176
  },
@@ -179,7 +181,7 @@ export const NumberKeyboard = p => {
179
181
  title: 'BACKSPACE',
180
182
  role: 'button'
181
183
  }, React.createElement(TextDeletionOutline, null)), React.createElement("div", {
182
- className: `${classPrefix}-key extra-key ok-key`,
184
+ className: `${classPrefix}-key ${classPrefix}-key-extra ${classPrefix}-key-ok`,
183
185
  onTouchEnd: e => onKeyPress(e, 'OK'),
184
186
  role: 'button'
185
187
  }, confirmText))), props.safeArea && React.createElement("div", {
@@ -1,4 +1,4 @@
1
1
  import './passcode-input.less';
2
2
  import { PasscodeInput } from './passcode-input';
3
- export type { PasscodeInputProps } from './passcode-input';
3
+ export type { PasscodeInputProps, PasscodeInputRef } from './passcode-input';
4
4
  export default PasscodeInput;
@@ -25,56 +25,56 @@
25
25
  background: var(--adm-color-background);
26
26
  }
27
27
 
28
- .adm-passcode-input:not(.seperated) {
28
+ .adm-passcode-input:not(.adm-passcode-input-seperated) {
29
29
  border-radius: var(--border-radius);
30
30
  overflow: hidden;
31
31
  border: 2px solid var(--border-color);
32
32
  }
33
33
 
34
- .adm-passcode-input:not(.seperated) .adm-passcode-input-cell:not(:last-child) {
34
+ .adm-passcode-input:not(.adm-passcode-input-seperated) .adm-passcode-input-cell:not(:last-child) {
35
35
  border-right: 2px solid var(--border-color);
36
36
  }
37
37
 
38
- .adm-passcode-input:not(.seperated).focused {
38
+ .adm-passcode-input:not(.adm-passcode-input-seperated).adm-passcode-input-focused {
39
39
  border-color: var(--adm-color-primary);
40
40
  box-shadow: 0 0 4px 0 var(--adm-color-primary);
41
41
  outline: none;
42
42
  }
43
43
 
44
- .adm-passcode-input:not(.seperated).error {
44
+ .adm-passcode-input:not(.adm-passcode-input-seperated).adm-passcode-input-error {
45
45
  border-color: var(--adm-color-danger);
46
46
  box-shadow: 0 0 4px 0 var(--adm-color-danger);
47
47
  animation: 100ms ease-in-out 0s 3 normal none running adm-shake-horizontal;
48
48
  }
49
49
 
50
- .adm-passcode-input.seperated .adm-passcode-input-cell {
50
+ .adm-passcode-input.adm-passcode-input-seperated .adm-passcode-input-cell {
51
51
  border-radius: var(--border-radius);
52
52
  border: 2px solid var(--border-color);
53
53
  }
54
54
 
55
- .adm-passcode-input.seperated .adm-passcode-input-cell:not(:last-child) {
55
+ .adm-passcode-input.adm-passcode-input-seperated .adm-passcode-input-cell:not(:last-child) {
56
56
  margin-right: var(--cell-gap);
57
57
  }
58
58
 
59
- .adm-passcode-input.seperated .adm-passcode-input-cell.focused {
59
+ .adm-passcode-input.adm-passcode-input-seperated .adm-passcode-input-cell-focused {
60
60
  border-color: var(--adm-color-primary);
61
61
  box-shadow: 0 0 4px 0 var(--adm-color-primary);
62
62
  }
63
63
 
64
- .adm-passcode-input.seperated.focused {
64
+ .adm-passcode-input-seperated.adm-passcode-input-focused {
65
65
  outline: none;
66
66
  }
67
67
 
68
- .adm-passcode-input.seperated.error {
68
+ .adm-passcode-input.adm-passcode-input-seperated.adm-passcode-input-error {
69
69
  animation: 100ms ease-in-out 0s 3 normal none running adm-shake-horizontal;
70
70
  }
71
71
 
72
- .adm-passcode-input.seperated.error .adm-passcode-input-cell {
72
+ .adm-passcode-input.adm-passcode-input-seperated.adm-passcode-input-error .adm-passcode-input-cell {
73
73
  border-color: var(--adm-color-danger);
74
74
  box-shadow: 0 0 4px 0 var(--adm-color-danger);
75
75
  }
76
76
 
77
- .adm-passcode-input-cell.dot::before {
77
+ .adm-passcode-input-cell-dot::before {
78
78
  content: '';
79
79
  width: var(--dot-size);
80
80
  height: var(--dot-size);
@@ -82,7 +82,7 @@
82
82
  background: var(--adm-color-text);
83
83
  }
84
84
 
85
- .adm-passcode-input-cell.caret::after {
85
+ .adm-passcode-input-cell-caret::after {
86
86
  content: '';
87
87
  width: 4px;
88
88
  height: 1.1em;
@@ -4,6 +4,7 @@ import { withNativeProps } from '../../utils/native-props';
4
4
  import classNames from 'classnames';
5
5
  import { bound } from '../../utils/bound';
6
6
  import { usePropsValue } from '../../utils/use-props-value';
7
+ import { useConfig } from '../config-provider';
7
8
  const classPrefix = 'adm-passcode-input';
8
9
  const defaultProps = {
9
10
  defaultValue: '',
@@ -17,6 +18,9 @@ export const PasscodeInput = forwardRef((p, ref) => {
17
18
  const props = mergeProps(defaultProps, p); // 防止 length 值不合法
18
19
 
19
20
  const cellLength = props.length > 0 && props.length < Infinity ? Math.floor(props.length) : defaultProps.length;
21
+ const {
22
+ locale
23
+ } = useConfig();
20
24
  const [focused, setFocused] = useState(false);
21
25
  const [value, setValue] = usePropsValue(props);
22
26
  const rootRef = useRef(null);
@@ -87,9 +91,9 @@ export const PasscodeInput = forwardRef((p, ref) => {
87
91
  for (let i = 0; i < cellLength; i++) {
88
92
  cells.push(React.createElement("div", {
89
93
  className: classNames(`${classPrefix}-cell`, {
90
- caret: props.caret && caretIndex === i && focused,
91
- focused: focusedIndex === i && focused,
92
- dot: !props.plain && chars[i]
94
+ [`${classPrefix}-cell-caret`]: props.caret && caretIndex === i && focused,
95
+ [`${classPrefix}-cell-focused`]: focusedIndex === i && focused,
96
+ [`${classPrefix}-cell-dot`]: !props.plain && chars[i]
93
97
  }),
94
98
  key: i
95
99
  }, chars[i] && props.plain ? chars[i] : ''));
@@ -99,16 +103,18 @@ export const PasscodeInput = forwardRef((p, ref) => {
99
103
  };
100
104
 
101
105
  const cls = classNames(classPrefix, {
102
- focused: focused,
103
- error: props.error,
104
- seperated: props.seperated
106
+ [`${classPrefix}-focused`]: focused,
107
+ [`${classPrefix}-error`]: props.error,
108
+ [`${classPrefix}-seperated`]: props.seperated
105
109
  });
106
110
  return React.createElement(React.Fragment, null, withNativeProps(props, React.createElement("div", {
107
111
  ref: rootRef,
108
112
  tabIndex: 0,
109
113
  className: cls,
110
114
  onFocus: onFocus,
111
- onBlur: onBlur
115
+ onBlur: onBlur,
116
+ role: 'button',
117
+ "aria-label": locale.PasscodeInput.name
112
118
  }, React.createElement("div", {
113
119
  className: `${classPrefix}-cell-container`
114
120
  }, renderCells()), React.createElement("input", {
@@ -120,7 +126,8 @@ export const PasscodeInput = forwardRef((p, ref) => {
120
126
  inputMode: 'numeric',
121
127
  onChange: e => {
122
128
  setValue(e.target.value.slice(0, props.length));
123
- }
129
+ },
130
+ "aria-hidden": true
124
131
  }))), props.keyboard && React.cloneElement(props.keyboard, {
125
132
  visible: focused,
126
133
  onInput: v => {
@@ -40,7 +40,7 @@ export const Wheel = memo(props => {
40
40
  });
41
41
  useIsomorphicLayoutEffect(() => {
42
42
  if (draggingRef.current) return;
43
- if (!value) return;
43
+ if (value === null) return;
44
44
  const targetIndex = column.findIndex(item => item.value === value);
45
45
  if (targetIndex < 0) return;
46
46
  const finalPosition = targetIndex * -itemHeight.current;
@@ -33,12 +33,17 @@ export const Rate = p => {
33
33
  } else {
34
34
  setValue(v);
35
35
  }
36
- }
36
+ },
37
+ role: 'radio',
38
+ "aria-checked": value >= v,
39
+ "aria-label": '' + v
37
40
  }, props.character);
38
41
  }
39
42
 
40
43
  return withNativeProps(props, React.createElement("div", {
41
- className: classPrefix
44
+ className: classPrefix,
45
+ role: 'radiogroup',
46
+ "aria-readonly": props.readOnly
42
47
  }, starList.map((_, i) => React.createElement("div", {
43
48
  key: i,
44
49
  className: classNames(`${classPrefix}-box`)
@@ -1,15 +1,5 @@
1
1
  import React from 'react';
2
2
  export const Star = () => {
3
- // return (
4
- // <svg height='1em' viewBox='0 0 48 48' xmlns='http://www.w3.org/2000/svg'>
5
- // <title>{'star-fill\u5907\u4EFD 71'}</title>
6
- // <path
7
- // d='m24 36-10.52 5.53a2 2 0 0 1-2.902-2.108l2.01-11.714-8.511-8.296a2 2 0 0 1 1.108-3.411l11.762-1.71 5.26-10.657a2 2 0 0 1 3.586 0l5.26 10.658L42.815 16a2 2 0 0 1 1.108 3.411l-8.51 8.296 2.009 11.714a2 2 0 0 1-2.902 2.109L24 36Z'
8
- // fill='#E5E5E5'
9
- // fillRule='evenodd'
10
- // />
11
- // </svg>
12
- // )
13
3
  return React.createElement("svg", {
14
4
  viewBox: '0 0 42 40',
15
5
  height: '1em',
@@ -1,7 +1,7 @@
1
1
  import { FC, ReactNode } from 'react';
2
2
  import { NativeProps } from '../../utils/native-props';
3
3
  export declare type ResultProps = {
4
- status: 'success' | 'error' | 'info' | 'waiting' | 'warning';
4
+ status?: 'success' | 'error' | 'info' | 'waiting' | 'warning';
5
5
  title: ReactNode;
6
6
  description?: ReactNode;
7
7
  icon?: ReactNode;
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import classNames from 'classnames';
3
3
  import { CheckCircleFill, CloseCircleFill, InformationCircleFill, ClockCircleFill, ExclamationCircleFill } from 'antd-mobile-icons';
4
4
  import { withNativeProps } from '../../utils/native-props';
5
+ import { mergeProps } from '../../utils/with-default-props';
5
6
  const classPrefix = `adm-result`;
6
7
  const iconRecord = {
7
8
  success: CheckCircleFill,
@@ -10,7 +11,11 @@ const iconRecord = {
10
11
  waiting: ClockCircleFill,
11
12
  warning: ExclamationCircleFill
12
13
  };
13
- export const Result = props => {
14
+ const defaultProps = {
15
+ status: 'info'
16
+ };
17
+ export const Result = p => {
18
+ const props = mergeProps(defaultProps, p);
14
19
  const {
15
20
  status,
16
21
  title,
@@ -26,6 +26,7 @@ export const SearchBar = forwardRef((p, ref) => {
26
26
  const [value, setValue] = usePropsValue(props);
27
27
  const [hasFocus, setHasFocus] = useState(false);
28
28
  const inputRef = useRef(null);
29
+ const composingRef = useRef(false);
29
30
  useImperativeHandle(ref, () => ({
30
31
  clear: () => {
31
32
  var _a;
@@ -118,8 +119,17 @@ export const SearchBar = forwardRef((p, ref) => {
118
119
  onEnterPress: () => {
119
120
  var _a, _b;
120
121
 
121
- (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.blur();
122
- (_b = props.onSearch) === null || _b === void 0 ? void 0 : _b.call(props, value);
122
+ if (!composingRef.current) {
123
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.blur();
124
+ (_b = props.onSearch) === null || _b === void 0 ? void 0 : _b.call(props, value);
125
+ }
126
+ },
127
+ "aria-label": locale.SearchBar.name,
128
+ onCompositionStart: () => {
129
+ composingRef.current = true;
130
+ },
131
+ onCompositionEnd: () => {
132
+ composingRef.current = false;
123
133
  }
124
134
  })), renderCancelButton()));
125
135
  });
@@ -5,8 +5,9 @@ export declare type SwitchProps = {
5
5
  disabled?: boolean;
6
6
  checked?: boolean;
7
7
  defaultChecked?: boolean;
8
+ /** @deprecated use `onChange` instead */
8
9
  beforeChange?: (val: boolean) => Promise<void>;
9
- onChange?: (checked: boolean) => void;
10
+ onChange?: (checked: boolean) => void | Promise<void>;
10
11
  checkedText?: ReactNode;
11
12
  uncheckedText?: ReactNode;
12
13
  } & NativeProps<'--checked-color' | '--width' | '--height' | '--border-width'>;
@@ -6,6 +6,7 @@ import { usePropsValue } from '../../utils/use-props-value';
6
6
  import { mergeProps } from '../../utils/with-default-props';
7
7
  import { SpinIcon } from './spin-icon';
8
8
  import { useConfig } from '../config-provider';
9
+ import { isPromise } from '../../utils/validate';
9
10
  const classPrefix = `adm-switch`;
10
11
  const defaultProps = {
11
12
  defaultChecked: false
@@ -36,14 +37,25 @@ export const Switch = p => {
36
37
 
37
38
  try {
38
39
  yield props.beforeChange(nextChecked);
39
- setChecked(nextChecked);
40
40
  setChanging(false);
41
41
  } catch (e) {
42
42
  setChanging(false);
43
43
  throw e;
44
44
  }
45
- } else {
46
- setChecked(nextChecked);
45
+ }
46
+
47
+ const result = setChecked(nextChecked);
48
+
49
+ if (isPromise(result)) {
50
+ setChanging(true);
51
+
52
+ try {
53
+ yield result;
54
+ setChanging(false);
55
+ } catch (e) {
56
+ setChanging(false);
57
+ throw e;
58
+ }
47
59
  }
48
60
  });
49
61
  }
@@ -51,6 +51,7 @@ export const TextArea = forwardRef((p, ref) => {
51
51
  if (!autoSize) return;
52
52
  const textArea = nativeTextAreaRef.current;
53
53
  if (!textArea) return;
54
+ textArea.style.height = 'auto';
54
55
  let height = textArea.scrollHeight;
55
56
 
56
57
  if (typeof autoSize === 'object') {
@@ -93,17 +93,26 @@ export declare const base: {
93
93
  failedToLoad: string;
94
94
  retry: string;
95
95
  };
96
+ Input: {
97
+ clear: string;
98
+ };
96
99
  Mask: {
97
100
  name: string;
98
101
  };
99
102
  Modal: {
100
103
  ok: string;
101
104
  };
105
+ PasscodeInput: {
106
+ name: string;
107
+ };
102
108
  PullToRefresh: {
103
109
  pulling: string;
104
110
  canRelease: string;
105
111
  complete: string;
106
112
  };
113
+ SearchBar: {
114
+ name: string;
115
+ };
107
116
  Slider: {
108
117
  name: string;
109
118
  };
@@ -94,17 +94,26 @@ export const base = {
94
94
  failedToLoad: 'Failed to load',
95
95
  retry: 'Retry'
96
96
  },
97
+ Input: {
98
+ clear: 'clear'
99
+ },
97
100
  Mask: {
98
101
  name: 'Mask'
99
102
  },
100
103
  Modal: {
101
104
  ok: 'OK'
102
105
  },
106
+ PasscodeInput: {
107
+ name: 'Passcode Input'
108
+ },
103
109
  PullToRefresh: {
104
110
  pulling: 'Scroll down to refresh',
105
111
  canRelease: 'Release to refresh immediately',
106
112
  complete: 'Refresh successful'
107
113
  },
114
+ SearchBar: {
115
+ name: 'Search Bar'
116
+ },
108
117
  Slider: {
109
118
  name: 'Slider'
110
119
  },
@@ -93,17 +93,26 @@ declare const enUS: {
93
93
  failedToLoad: string;
94
94
  retry: string;
95
95
  };
96
+ Input: {
97
+ clear: string;
98
+ };
96
99
  Mask: {
97
100
  name: string;
98
101
  };
99
102
  Modal: {
100
103
  ok: string;
101
104
  };
105
+ PasscodeInput: {
106
+ name: string;
107
+ };
102
108
  PullToRefresh: {
103
109
  pulling: string;
104
110
  canRelease: string;
105
111
  complete: string;
106
112
  };
113
+ SearchBar: {
114
+ name: string;
115
+ };
107
116
  Slider: {
108
117
  name: string;
109
118
  };