antd-mobile 5.18.0 → 5.21.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 (239) hide show
  1. package/2x/bundle/antd-mobile.cjs.js +47 -18976
  2. package/2x/bundle/antd-mobile.compatible.umd.js +25911 -0
  3. package/2x/bundle/antd-mobile.es.js +16358 -16685
  4. package/2x/bundle/antd-mobile.umd.js +64 -0
  5. package/2x/bundle/style.css +359 -273
  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 +1 -1
  9. package/2x/cjs/components/cascader/cascader.d.ts +2 -0
  10. package/2x/cjs/components/cascader/index.d.ts +1 -0
  11. package/2x/cjs/components/cascader-view/cascader-view.d.ts +2 -1
  12. package/2x/cjs/components/cascader-view/cascader-view.js +2 -1
  13. package/2x/cjs/components/dialog/show.d.ts +1 -1
  14. package/2x/cjs/components/form/context.d.ts +1 -1
  15. package/2x/cjs/components/form/form-item.d.ts +1 -1
  16. package/2x/cjs/components/form/form-item.js +3 -0
  17. package/2x/cjs/components/image/test/image.test.js +57 -8
  18. package/2x/cjs/components/image-viewer/slide.js +75 -56
  19. package/2x/cjs/components/input/input.js +9 -2
  20. package/2x/cjs/components/modal/show.d.ts +1 -1
  21. package/2x/cjs/components/number-keyboard/number-keyboard.css +11 -15
  22. package/2x/cjs/components/number-keyboard/number-keyboard.d.ts +1 -1
  23. package/2x/cjs/components/number-keyboard/number-keyboard.js +19 -17
  24. package/2x/cjs/components/passcode-input/index.d.ts +1 -1
  25. package/2x/cjs/components/passcode-input/passcode-input.css +12 -12
  26. package/2x/cjs/components/passcode-input/passcode-input.js +16 -8
  27. package/2x/cjs/components/picker-view/wheel.js +2 -0
  28. package/2x/cjs/components/rate/rate.css +4 -0
  29. package/2x/cjs/components/rate/rate.js +42 -13
  30. package/2x/cjs/components/result/result.d.ts +1 -1
  31. package/2x/cjs/components/result/result.js +7 -1
  32. package/2x/cjs/components/result-page/index.d.ts +7 -0
  33. package/2x/cjs/components/result-page/index.js +20 -0
  34. package/2x/cjs/components/result-page/result-page-card.d.ts +6 -0
  35. package/2x/cjs/components/result-page/result-page-card.js +24 -0
  36. package/2x/cjs/components/result-page/result-page.css +130 -0
  37. package/2x/cjs/components/result-page/result-page.d.ts +23 -0
  38. package/2x/cjs/components/result-page/result-page.js +108 -0
  39. package/2x/cjs/components/search-bar/search-bar.js +12 -2
  40. package/2x/cjs/components/swipe-action/swipe-action.d.ts +2 -0
  41. package/2x/cjs/components/swipe-action/swipe-action.js +34 -6
  42. package/2x/cjs/components/swiper/swiper.js +15 -1
  43. package/2x/cjs/index.d.ts +1 -0
  44. package/2x/cjs/index.js +8 -0
  45. package/2x/cjs/locales/base.d.ts +9 -0
  46. package/2x/cjs/locales/base.js +9 -0
  47. package/2x/cjs/locales/en-US.d.ts +9 -0
  48. package/2x/cjs/locales/es-ES.d.ts +9 -0
  49. package/2x/cjs/locales/fa-IR.d.ts +9 -0
  50. package/2x/cjs/locales/fr-FR.d.ts +9 -0
  51. package/2x/cjs/locales/id-ID.d.ts +9 -0
  52. package/2x/cjs/locales/id-ID.js +13 -0
  53. package/2x/cjs/locales/kk-KZ.d.ts +9 -0
  54. package/2x/cjs/locales/ko-KR.d.ts +9 -0
  55. package/2x/cjs/locales/zh-CN.d.ts +9 -0
  56. package/2x/cjs/locales/zh-CN.js +9 -0
  57. package/2x/cjs/locales/zh-HK.d.ts +9 -0
  58. package/2x/cjs/locales/zh-TW.d.ts +9 -0
  59. package/2x/cjs/utils/matrix.d.ts +10 -0
  60. package/2x/cjs/utils/matrix.js +60 -0
  61. package/2x/cjs/utils/use-resize-effect.js +3 -1
  62. package/2x/es/components/action-sheet/action-sheet.d.ts +1 -1
  63. package/2x/es/components/button/button.js +1 -1
  64. package/2x/es/components/calendar/calendar.d.ts +1 -1
  65. package/2x/es/components/cascader/cascader.d.ts +2 -0
  66. package/2x/es/components/cascader/index.d.ts +1 -0
  67. package/2x/es/components/cascader-view/cascader-view.d.ts +2 -1
  68. package/2x/es/components/cascader-view/cascader-view.js +2 -1
  69. package/2x/es/components/dialog/show.d.ts +1 -1
  70. package/2x/es/components/form/context.d.ts +1 -1
  71. package/2x/es/components/form/form-item.d.ts +1 -1
  72. package/2x/es/components/form/form-item.js +3 -0
  73. package/2x/es/components/image/test/image.test.js +54 -8
  74. package/2x/es/components/image-viewer/slide.js +73 -56
  75. package/2x/es/components/input/input.js +8 -2
  76. package/2x/es/components/modal/show.d.ts +1 -1
  77. package/2x/es/components/number-keyboard/number-keyboard.css +11 -15
  78. package/2x/es/components/number-keyboard/number-keyboard.d.ts +1 -1
  79. package/2x/es/components/number-keyboard/number-keyboard.js +19 -17
  80. package/2x/es/components/passcode-input/index.d.ts +1 -1
  81. package/2x/es/components/passcode-input/passcode-input.css +12 -12
  82. package/2x/es/components/passcode-input/passcode-input.js +15 -8
  83. package/2x/es/components/picker-view/wheel.js +2 -0
  84. package/2x/es/components/rate/rate.css +4 -0
  85. package/2x/es/components/rate/rate.js +36 -13
  86. package/2x/es/components/result/result.d.ts +1 -1
  87. package/2x/es/components/result/result.js +6 -1
  88. package/2x/es/components/result-page/index.d.ts +7 -0
  89. package/2x/es/components/result-page/index.js +7 -0
  90. package/2x/es/components/result-page/result-page-card.d.ts +6 -0
  91. package/2x/es/components/result-page/result-page-card.js +9 -0
  92. package/2x/es/components/result-page/result-page.css +130 -0
  93. package/2x/es/components/result-page/result-page.d.ts +23 -0
  94. package/2x/es/components/result-page/result-page.js +83 -0
  95. package/2x/es/components/search-bar/search-bar.js +12 -2
  96. package/2x/es/components/swipe-action/swipe-action.d.ts +2 -0
  97. package/2x/es/components/swipe-action/swipe-action.js +34 -6
  98. package/2x/es/components/swiper/swiper.js +15 -1
  99. package/2x/es/index.d.ts +1 -0
  100. package/2x/es/index.js +1 -0
  101. package/2x/es/locales/base.d.ts +9 -0
  102. package/2x/es/locales/base.js +9 -0
  103. package/2x/es/locales/en-US.d.ts +9 -0
  104. package/2x/es/locales/es-ES.d.ts +9 -0
  105. package/2x/es/locales/fa-IR.d.ts +9 -0
  106. package/2x/es/locales/fr-FR.d.ts +9 -0
  107. package/2x/es/locales/id-ID.d.ts +9 -0
  108. package/2x/es/locales/id-ID.js +13 -0
  109. package/2x/es/locales/kk-KZ.d.ts +9 -0
  110. package/2x/es/locales/ko-KR.d.ts +9 -0
  111. package/2x/es/locales/zh-CN.d.ts +9 -0
  112. package/2x/es/locales/zh-CN.js +9 -0
  113. package/2x/es/locales/zh-HK.d.ts +9 -0
  114. package/2x/es/locales/zh-TW.d.ts +9 -0
  115. package/2x/es/utils/matrix.d.ts +10 -0
  116. package/2x/es/utils/matrix.js +27 -0
  117. package/2x/es/utils/use-resize-effect.js +3 -1
  118. package/2x/package.json +6 -6
  119. package/2x/umd/antd-mobile.js +25911 -2
  120. package/bundle/antd-mobile.cjs.js +47 -18976
  121. package/bundle/antd-mobile.compatible.umd.js +25911 -0
  122. package/bundle/antd-mobile.es.js +16358 -16685
  123. package/bundle/antd-mobile.umd.js +64 -0
  124. package/bundle/style.css +1 -4088
  125. package/cjs/components/action-sheet/action-sheet.d.ts +1 -1
  126. package/cjs/components/button/button.js +1 -1
  127. package/cjs/components/calendar/calendar.d.ts +1 -1
  128. package/cjs/components/cascader/cascader.d.ts +2 -0
  129. package/cjs/components/cascader/index.d.ts +1 -0
  130. package/cjs/components/cascader-view/cascader-view.d.ts +2 -1
  131. package/cjs/components/cascader-view/cascader-view.js +2 -1
  132. package/cjs/components/dialog/show.d.ts +1 -1
  133. package/cjs/components/form/context.d.ts +1 -1
  134. package/cjs/components/form/form-item.d.ts +1 -1
  135. package/cjs/components/form/form-item.js +3 -0
  136. package/cjs/components/image/test/image.test.js +57 -8
  137. package/cjs/components/image-viewer/slide.js +75 -56
  138. package/cjs/components/input/input.js +9 -2
  139. package/cjs/components/modal/show.d.ts +1 -1
  140. package/cjs/components/number-keyboard/number-keyboard.css +11 -14
  141. package/cjs/components/number-keyboard/number-keyboard.d.ts +1 -1
  142. package/cjs/components/number-keyboard/number-keyboard.js +19 -17
  143. package/cjs/components/passcode-input/index.d.ts +1 -1
  144. package/cjs/components/passcode-input/passcode-input.css +12 -12
  145. package/cjs/components/passcode-input/passcode-input.js +16 -8
  146. package/cjs/components/picker-view/wheel.js +2 -0
  147. package/cjs/components/rate/rate.css +4 -0
  148. package/cjs/components/rate/rate.js +42 -13
  149. package/cjs/components/result/result.d.ts +1 -1
  150. package/cjs/components/result/result.js +7 -1
  151. package/cjs/components/result-page/index.d.ts +7 -0
  152. package/cjs/components/result-page/index.js +20 -0
  153. package/cjs/components/result-page/result-page-card.d.ts +6 -0
  154. package/cjs/components/result-page/result-page-card.js +24 -0
  155. package/cjs/components/result-page/result-page.css +113 -0
  156. package/cjs/components/result-page/result-page.d.ts +23 -0
  157. package/cjs/components/result-page/result-page.js +108 -0
  158. package/cjs/components/search-bar/search-bar.js +12 -2
  159. package/cjs/components/swipe-action/swipe-action.d.ts +2 -0
  160. package/cjs/components/swipe-action/swipe-action.js +34 -6
  161. package/cjs/components/swiper/swiper.js +15 -1
  162. package/cjs/index.d.ts +1 -0
  163. package/cjs/index.js +8 -0
  164. package/cjs/locales/base.d.ts +9 -0
  165. package/cjs/locales/base.js +9 -0
  166. package/cjs/locales/en-US.d.ts +9 -0
  167. package/cjs/locales/es-ES.d.ts +9 -0
  168. package/cjs/locales/fa-IR.d.ts +9 -0
  169. package/cjs/locales/fr-FR.d.ts +9 -0
  170. package/cjs/locales/id-ID.d.ts +9 -0
  171. package/cjs/locales/id-ID.js +13 -0
  172. package/cjs/locales/kk-KZ.d.ts +9 -0
  173. package/cjs/locales/ko-KR.d.ts +9 -0
  174. package/cjs/locales/zh-CN.d.ts +9 -0
  175. package/cjs/locales/zh-CN.js +9 -0
  176. package/cjs/locales/zh-HK.d.ts +9 -0
  177. package/cjs/locales/zh-TW.d.ts +9 -0
  178. package/cjs/utils/matrix.d.ts +10 -0
  179. package/cjs/utils/matrix.js +60 -0
  180. package/cjs/utils/use-resize-effect.js +3 -1
  181. package/es/components/action-sheet/action-sheet.d.ts +1 -1
  182. package/es/components/button/button.js +1 -1
  183. package/es/components/calendar/calendar.d.ts +1 -1
  184. package/es/components/cascader/cascader.d.ts +2 -0
  185. package/es/components/cascader/index.d.ts +1 -0
  186. package/es/components/cascader-view/cascader-view.d.ts +2 -1
  187. package/es/components/cascader-view/cascader-view.js +2 -1
  188. package/es/components/dialog/show.d.ts +1 -1
  189. package/es/components/form/context.d.ts +1 -1
  190. package/es/components/form/form-item.d.ts +1 -1
  191. package/es/components/form/form-item.js +3 -0
  192. package/es/components/image/test/image.test.js +54 -8
  193. package/es/components/image-viewer/slide.js +73 -56
  194. package/es/components/input/input.js +8 -2
  195. package/es/components/modal/show.d.ts +1 -1
  196. package/es/components/number-keyboard/number-keyboard.css +11 -14
  197. package/es/components/number-keyboard/number-keyboard.d.ts +1 -1
  198. package/es/components/number-keyboard/number-keyboard.js +19 -17
  199. package/es/components/passcode-input/index.d.ts +1 -1
  200. package/es/components/passcode-input/passcode-input.css +12 -12
  201. package/es/components/passcode-input/passcode-input.js +15 -8
  202. package/es/components/picker-view/wheel.js +2 -0
  203. package/es/components/rate/rate.css +4 -0
  204. package/es/components/rate/rate.js +36 -13
  205. package/es/components/result/result.d.ts +1 -1
  206. package/es/components/result/result.js +6 -1
  207. package/es/components/result-page/index.d.ts +7 -0
  208. package/es/components/result-page/index.js +7 -0
  209. package/es/components/result-page/result-page-card.d.ts +6 -0
  210. package/es/components/result-page/result-page-card.js +9 -0
  211. package/es/components/result-page/result-page.css +113 -0
  212. package/es/components/result-page/result-page.d.ts +23 -0
  213. package/es/components/result-page/result-page.js +83 -0
  214. package/es/components/search-bar/search-bar.js +12 -2
  215. package/es/components/swipe-action/swipe-action.d.ts +2 -0
  216. package/es/components/swipe-action/swipe-action.js +34 -6
  217. package/es/components/swiper/swiper.js +15 -1
  218. package/es/index.d.ts +1 -0
  219. package/es/index.js +1 -0
  220. package/es/locales/base.d.ts +9 -0
  221. package/es/locales/base.js +9 -0
  222. package/es/locales/en-US.d.ts +9 -0
  223. package/es/locales/es-ES.d.ts +9 -0
  224. package/es/locales/fa-IR.d.ts +9 -0
  225. package/es/locales/fr-FR.d.ts +9 -0
  226. package/es/locales/id-ID.d.ts +9 -0
  227. package/es/locales/id-ID.js +13 -0
  228. package/es/locales/kk-KZ.d.ts +9 -0
  229. package/es/locales/ko-KR.d.ts +9 -0
  230. package/es/locales/zh-CN.d.ts +9 -0
  231. package/es/locales/zh-CN.js +9 -0
  232. package/es/locales/zh-HK.d.ts +9 -0
  233. package/es/locales/zh-TW.d.ts +9 -0
  234. package/es/utils/matrix.d.ts +10 -0
  235. package/es/utils/matrix.js +27 -0
  236. package/es/utils/use-resize-effect.js +3 -1
  237. package/package.json +6 -6
  238. package/umd/antd-mobile.js +1 -1
  239. package/2x/umd/antd-mobile.js.LICENSE.txt +0 -35
@@ -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 => {
@@ -186,6 +186,8 @@ export const Wheel = memo(props => {
186
186
  if (prev.index !== next.index) return false;
187
187
  if (prev.value !== next.value) return false;
188
188
  if (prev.onSelect !== next.onSelect) return false;
189
+ if (prev.renderLabel !== next.renderLabel) return false;
190
+ if (prev.mouseWheel !== next.mouseWheel) return false;
189
191
 
190
192
  if (!isEqual(prev.column, next.column)) {
191
193
  return false;
@@ -3,6 +3,9 @@
3
3
  --active-color: #ffd21e;
4
4
  --inactive-color: var(--adm-color-border);
5
5
  display: inline-flex;
6
+ touch-action: pan-y;
7
+ -webkit-user-select: none;
8
+ user-select: none;
6
9
  }
7
10
 
8
11
  .adm-rate-box {
@@ -18,6 +21,7 @@
18
21
  overflow: hidden;
19
22
  cursor: pointer;
20
23
  box-sizing: border-box;
24
+ transition: all 0.3s;
21
25
  }
22
26
 
23
27
  .adm-rate-star-half {
@@ -1,9 +1,11 @@
1
- import React from 'react';
1
+ import React, { useRef } from 'react';
2
2
  import classNames from 'classnames';
3
3
  import { withNativeProps } from '../../utils/native-props';
4
4
  import { mergeProps } from '../../utils/with-default-props';
5
5
  import { usePropsValue } from '../../utils/use-props-value';
6
6
  import { Star } from './star';
7
+ import { useDrag } from '@use-gesture/react';
8
+ import { bound } from '../../utils/bound';
7
9
  const classPrefix = `adm-rate`;
8
10
  const defaultProps = {
9
11
  count: 5,
@@ -16,6 +18,7 @@ const defaultProps = {
16
18
  export const Rate = p => {
17
19
  const props = mergeProps(defaultProps, p);
18
20
  const [value, setValue] = usePropsValue(props);
21
+ const containerRef = useRef(null);
19
22
  const starList = Array(props.count).fill(null);
20
23
 
21
24
  function renderStar(v, half) {
@@ -25,26 +28,46 @@ export const Rate = p => {
25
28
  [`${classPrefix}-star-half`]: half,
26
29
  [`${classPrefix}-star-readonly`]: props.readOnly
27
30
  }),
28
- onClick: () => {
29
- if (props.readOnly) return;
30
-
31
- if (props.allowClear && value === v) {
32
- setValue(0);
33
- } else {
34
- setValue(v);
35
- }
36
- },
37
31
  role: 'radio',
38
32
  "aria-checked": value >= v,
39
33
  "aria-label": '' + v
40
34
  }, props.character);
41
35
  }
42
36
 
43
- return withNativeProps(props, React.createElement("div", {
37
+ const bind = useDrag(state => {
38
+ if (props.readOnly) return;
39
+ const {
40
+ xy: [clientX],
41
+ tap
42
+ } = state;
43
+ const container = containerRef.current;
44
+ if (!container) return;
45
+ const rect = container.getBoundingClientRect();
46
+ const rawValue = (clientX - rect.left) / rect.width * props.count;
47
+ const ceiledValue = props.allowHalf ? Math.ceil(rawValue * 2) / 2 : Math.ceil(rawValue);
48
+ const boundValue = bound(ceiledValue, 0, props.count);
49
+
50
+ if (tap) {
51
+ if (props.allowClear && boundValue === value) {
52
+ setValue(0);
53
+ return;
54
+ }
55
+ }
56
+
57
+ setValue(boundValue);
58
+ }, {
59
+ axis: 'x',
60
+ pointer: {
61
+ touch: true
62
+ },
63
+ filterTaps: true
64
+ });
65
+ return withNativeProps(props, React.createElement("div", Object.assign({
44
66
  className: classPrefix,
45
67
  role: 'radiogroup',
46
- "aria-readonly": props.readOnly
47
- }, starList.map((_, i) => React.createElement("div", {
68
+ "aria-readonly": props.readOnly,
69
+ ref: containerRef
70
+ }, bind()), starList.map((_, i) => React.createElement("div", {
48
71
  key: i,
49
72
  className: classNames(`${classPrefix}-box`)
50
73
  }, props.allowHalf && renderStar(i + 0.5, true), renderStar(i + 1, false)))));
@@ -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,
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import './result-page.less';
3
+ export type { ResultPageProps } from './result-page';
4
+ declare const _default: import("react").FC<import("./result-page").ResultPageProps> & {
5
+ Card: import("react").FC<import("./result-page-card").ResultPageCardProps>;
6
+ };
7
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import "./result-page.css";
2
+ import { ResultPage } from './result-page';
3
+ import { attachPropertiesToComponent } from '../../utils/attach-properties-to-component';
4
+ import { ResultPageCard } from './result-page-card';
5
+ export default attachPropertiesToComponent(ResultPage, {
6
+ Card: ResultPageCard
7
+ });
@@ -0,0 +1,6 @@
1
+ import { FC, ReactNode } from 'react';
2
+ import { NativeProps } from '../../utils/native-props';
3
+ export declare type ResultPageCardProps = {
4
+ children?: ReactNode;
5
+ } & NativeProps;
6
+ export declare const ResultPageCard: FC<ResultPageCardProps>;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { withNativeProps } from '../../utils/native-props';
3
+ import classNames from 'classnames';
4
+ const classPrefix = `adm-result-page-card`;
5
+ export const ResultPageCard = props => {
6
+ return withNativeProps(props, React.createElement('div', {
7
+ className: classNames(`${classPrefix}`)
8
+ }, props.children));
9
+ };
@@ -0,0 +1,130 @@
1
+ .adm-result-page {
2
+ --background-color: var(--adm-color-primary);
3
+ position: relative;
4
+ background-color: var(--adm-color-box);
5
+ min-height: 100vh;
6
+ width: 100%;
7
+ }
8
+
9
+ .adm-result-page-header {
10
+ display: flex;
11
+ align-items: center;
12
+ flex-direction: column;
13
+ background-color: transparent;
14
+ position: relative;
15
+ padding: 40px;
16
+ padding-bottom: 200px;
17
+ z-index: 1;
18
+ overflow: hidden;
19
+ }
20
+
21
+ .adm-result-page-icon {
22
+ color: var(--adm-color-background);
23
+ box-sizing: border-box;
24
+ padding: 4px;
25
+ margin-bottom: 16px;
26
+ }
27
+
28
+ .adm-result-page-icon .antd-mobile-icon {
29
+ font-size: 64px;
30
+ }
31
+
32
+ .adm-result-page-title {
33
+ font-size: var(--adm-font-size-10);
34
+ color: var(--adm-color-background);
35
+ line-height: 1.4;
36
+ text-align: center;
37
+ }
38
+
39
+ .adm-result-page-description {
40
+ margin-top: 16px;
41
+ margin-bottom: 48px;
42
+ font-size: var(--adm-font-size-6);
43
+ color: rgba(255, 255, 255, 0.6);
44
+ line-height: 1.4;
45
+ text-align: center;
46
+ }
47
+
48
+ .adm-result-page-details {
49
+ width: 100%;
50
+ }
51
+
52
+ .adm-result-page-detail {
53
+ width: 100%;
54
+ display: flex;
55
+ flex-direction: row;
56
+ justify-content: space-between;
57
+ margin-bottom: 10px;
58
+ color: var(--adm-color-background);
59
+ font-size: var(--adm-font-size-6);
60
+ }
61
+
62
+ .adm-result-page-detail-bold {
63
+ font-weight: 600;
64
+ }
65
+
66
+ .adm-result-page-collapse {
67
+ opacity: 0.6;
68
+ width: 20px;
69
+ height: 20px;
70
+ margin: auto;
71
+ margin-bottom: 10px;
72
+ border-top: 4px solid var(--adm-color-background);
73
+ border-right: 4px solid var(--adm-color-background);
74
+ transform: rotate(135deg);
75
+ }
76
+
77
+ .adm-result-page-collapse-active {
78
+ transform: rotate(-45deg);
79
+ }
80
+
81
+ .adm-result-page-bgWrapper {
82
+ position: relative;
83
+ align-self: flex-start;
84
+ top: 108px;
85
+ }
86
+
87
+ .adm-result-page-bg {
88
+ --width: 440vw;
89
+ position: absolute;
90
+ height: var(--width);
91
+ width: var(--width);
92
+ left: calc((var(--width) - 100vw) * -1 / 2 - 40px);
93
+ top: calc(var(--width) * -1 + 1vw);
94
+ border-radius: 50%;
95
+ background-color: var(--background-color);
96
+ z-index: -1;
97
+ }
98
+
99
+ .adm-result-page-content {
100
+ position: relative;
101
+ padding: 24px;
102
+ top: -208px;
103
+ z-index: 2;
104
+ }
105
+
106
+ .adm-result-page-footer {
107
+ position: fixed;
108
+ bottom: 0;
109
+ width: 100%;
110
+ padding: 24px;
111
+ padding-bottom: 48px;
112
+ display: flex;
113
+ justify-content: center;
114
+ background-color: var(--adm-color-box);
115
+ z-index: 3;
116
+ }
117
+
118
+ .adm-result-page-footer-btn {
119
+ flex: 1;
120
+ max-width: calc((100vw - 72px) / 2);
121
+ }
122
+
123
+ .adm-result-page-footer-space {
124
+ width: 24px;
125
+ }
126
+
127
+ .adm-result-page-card {
128
+ border-radius: 16px;
129
+ background-color: var(--adm-color-background);
130
+ }
@@ -0,0 +1,23 @@
1
+ import React, { FC, ReactNode } from 'react';
2
+ import { NativeProps } from '../../utils/native-props';
3
+ interface ResultPageDetail {
4
+ label: ReactNode;
5
+ value: ReactNode;
6
+ bold?: boolean;
7
+ }
8
+ declare type ResultPageDetails = ResultPageDetail[];
9
+ declare type OnClick = (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void | Promise<void> | unknown;
10
+ export declare type ResultPageProps = {
11
+ status?: 'success' | 'error' | 'info' | 'waiting' | 'warning';
12
+ title: ReactNode;
13
+ description?: ReactNode;
14
+ icon?: ReactNode;
15
+ details?: ResultPageDetails;
16
+ children?: ReactNode;
17
+ primaryButtonText?: ReactNode;
18
+ secondaryButtonText?: ReactNode;
19
+ onPrimaryButtonClick?: OnClick;
20
+ onSecondaryButtonClick?: OnClick;
21
+ } & NativeProps<'--background-color'>;
22
+ export declare const ResultPage: FC<ResultPageProps>;
23
+ export {};
@@ -0,0 +1,83 @@
1
+ import React, { useState } from 'react';
2
+ import { CheckCircleFill, CloseCircleFill, InformationCircleFill, ClockCircleFill, ExclamationCircleFill } from 'antd-mobile-icons';
3
+ import classNames from 'classnames';
4
+ import { withNativeProps } from '../../utils/native-props';
5
+ import { mergeProps } from '../../utils/with-default-props';
6
+ import { isNodeWithContent } from '../../utils/is-node-with-content';
7
+ import Button from '../button';
8
+ const classPrefix = `adm-result-page`;
9
+ const iconRecord = {
10
+ success: CheckCircleFill,
11
+ error: CloseCircleFill,
12
+ info: InformationCircleFill,
13
+ waiting: ClockCircleFill,
14
+ warning: ExclamationCircleFill
15
+ };
16
+ const defaultProps = {
17
+ status: 'info',
18
+ details: []
19
+ };
20
+ export const ResultPage = p => {
21
+ const props = mergeProps(defaultProps, p);
22
+ const {
23
+ status,
24
+ title,
25
+ description,
26
+ details,
27
+ icon,
28
+ primaryButtonText,
29
+ secondaryButtonText,
30
+ onPrimaryButtonClick,
31
+ onSecondaryButtonClick
32
+ } = props;
33
+ const resultIcon = icon || React.createElement(iconRecord[status]);
34
+ const [collapse, setCollapse] = useState(true);
35
+ const showSecondaryButton = isNodeWithContent(secondaryButtonText);
36
+ const showPrimaryButton = isNodeWithContent(primaryButtonText);
37
+ return withNativeProps(props, React.createElement("div", {
38
+ className: classPrefix
39
+ }, React.createElement("div", {
40
+ className: `${classPrefix}-header`
41
+ }, React.createElement("div", {
42
+ className: `${classPrefix}-icon`
43
+ }, resultIcon), React.createElement("div", {
44
+ className: `${classPrefix}-title`
45
+ }, title), isNodeWithContent(description) ? React.createElement("div", {
46
+ className: `${classPrefix}-description`
47
+ }, description) : null, details.length ? React.createElement("div", {
48
+ className: `${classPrefix}-details`
49
+ }, (collapse ? details.slice(0, 3) : details).map((detail, index) => {
50
+ return React.createElement("div", {
51
+ className: classNames(`${classPrefix}-detail`, detail.bold && `${classPrefix}-detail-bold`),
52
+ key: index
53
+ }, React.createElement("span", null, detail.label), React.createElement("span", null, detail.value));
54
+ }), details.length > 3 && React.createElement("div", {
55
+ onClick: () => setCollapse(prev => !prev)
56
+ }, React.createElement("div", {
57
+ className: classNames(`${classPrefix}-collapse`, !collapse && `${classPrefix}-collapse-active`)
58
+ }))) : null, React.createElement("div", {
59
+ className: `${classPrefix}-bgWrapper`
60
+ }, React.createElement("div", {
61
+ className: `${classPrefix}-bg`
62
+ }))), React.createElement("div", {
63
+ className: `${classPrefix}-content`
64
+ }, props.children), React.createElement("div", {
65
+ className: `${classPrefix}-footer`
66
+ }, showSecondaryButton && React.createElement(Button, {
67
+ block: true,
68
+ color: 'default',
69
+ fill: 'solid',
70
+ size: 'large',
71
+ onClick: onSecondaryButtonClick,
72
+ className: `${classPrefix}-footer-btn`
73
+ }, secondaryButtonText), showPrimaryButton && showSecondaryButton && React.createElement("div", {
74
+ className: `${classPrefix}-footer-space`
75
+ }), showPrimaryButton && React.createElement(Button, {
76
+ block: true,
77
+ color: 'primary',
78
+ fill: 'solid',
79
+ size: 'large',
80
+ onClick: onPrimaryButtonClick,
81
+ className: `${classPrefix}-footer-btn`
82
+ }, primaryButtonText))));
83
+ };
@@ -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
  });
@@ -20,6 +20,7 @@ export declare type SwipeActionProps = {
20
20
  closeOnAction?: boolean;
21
21
  children: ReactNode;
22
22
  stopPropagation?: PropagationEvent[];
23
+ onActionsReveal?: (side: 'left' | 'right') => void;
23
24
  } & NativeProps<'--background'>;
24
25
  export declare const SwipeAction: React.ForwardRefExoticComponent<{
25
26
  rightActions?: Action[] | undefined;
@@ -29,6 +30,7 @@ export declare const SwipeAction: React.ForwardRefExoticComponent<{
29
30
  closeOnAction?: boolean | undefined;
30
31
  children: ReactNode;
31
32
  stopPropagation?: "click"[] | undefined;
33
+ onActionsReveal?: ((side: 'left' | 'right') => void) | undefined;
32
34
  } & {
33
35
  className?: string | undefined;
34
36
  style?: (React.CSSProperties & Partial<Record<"--background", string>>) | undefined;
@@ -44,8 +44,26 @@ export const SwipeAction = forwardRef((p, ref) => {
44
44
  }
45
45
  }), []);
46
46
  const draggingRef = useRef(false);
47
+ const dragCancelRef = useRef(null);
48
+
49
+ function forceCancelDrag() {
50
+ var _a;
51
+
52
+ (_a = dragCancelRef.current) === null || _a === void 0 ? void 0 : _a.call(dragCancelRef);
53
+ draggingRef.current = false;
54
+ }
55
+
47
56
  const bind = useDrag(state => {
48
- draggingRef.current = true;
57
+ var _a;
58
+
59
+ dragCancelRef.current = state.cancel;
60
+ if (!state.intentional) return;
61
+
62
+ if (state.down) {
63
+ draggingRef.current = true;
64
+ }
65
+
66
+ if (!draggingRef.current) return;
49
67
  const [offsetX] = state.offset;
50
68
 
51
69
  if (state.last) {
@@ -61,9 +79,15 @@ export const SwipeAction = forwardRef((p, ref) => {
61
79
  position = 0;
62
80
  }
63
81
 
82
+ const targetX = nearest([-rightWidth, 0, leftWidth], position);
64
83
  api.start({
65
- x: nearest([-rightWidth, 0, leftWidth], position)
84
+ x: targetX
66
85
  });
86
+
87
+ if (targetX !== 0) {
88
+ (_a = p.onActionsReveal) === null || _a === void 0 ? void 0 : _a.call(p, targetX > 0 ? 'left' : 'right');
89
+ }
90
+
67
91
  window.setTimeout(() => {
68
92
  draggingRef.current = false;
69
93
  });
@@ -88,17 +112,21 @@ export const SwipeAction = forwardRef((p, ref) => {
88
112
  preventScroll: true,
89
113
  pointer: {
90
114
  touch: true
91
- }
115
+ },
116
+ triggerAllEvents: true
92
117
  });
93
118
 
94
119
  function close() {
95
120
  api.start({
96
121
  x: 0
97
122
  });
123
+ forceCancelDrag();
98
124
  }
99
125
 
100
126
  useImperativeHandle(ref, () => ({
101
127
  show: (side = 'right') => {
128
+ var _a;
129
+
102
130
  if (side === 'right') {
103
131
  api.start({
104
132
  x: -getRightWidth()
@@ -108,6 +136,8 @@ export const SwipeAction = forwardRef((p, ref) => {
108
136
  x: getLeftWidth()
109
137
  });
110
138
  }
139
+
140
+ (_a = p.onActionsReveal) === null || _a === void 0 ? void 0 : _a.call(p, side);
111
141
  },
112
142
  close
113
143
  }));
@@ -179,9 +209,7 @@ export const SwipeAction = forwardRef((p, ref) => {
179
209
  if (x.goal !== 0) {
180
210
  e.preventDefault();
181
211
  e.stopPropagation();
182
- api.start({
183
- x: 0
184
- });
212
+ close();
185
213
  }
186
214
  }
187
215
  }, React.createElement(animated.div, {
@@ -113,7 +113,18 @@ export const Swiper = forwardRef(staged((p, ref) => {
113
113
  });
114
114
  }
115
115
  }), [count]);
116
+ const dragCancelRef = useRef(null);
117
+
118
+ function forceCancelDrag() {
119
+ var _a;
120
+
121
+ (_a = dragCancelRef.current) === null || _a === void 0 ? void 0 : _a.call(dragCancelRef);
122
+ draggingRef.current = false;
123
+ }
124
+
116
125
  const bind = useDrag(state => {
126
+ dragCancelRef.current = state.cancel;
127
+ if (!state.intentional) return;
117
128
  const slidePixels = getSlidePixels();
118
129
  if (!slidePixels) return;
119
130
  const paramIndex = isVertical ? 1 : 0;
@@ -142,6 +153,7 @@ export const Swiper = forwardRef(staged((p, ref) => {
142
153
  const slidePixels = getSlidePixels();
143
154
  return [position.get() / 100 * slidePixels, position.get() / 100 * slidePixels];
144
155
  },
156
+ triggerAllEvents: true,
145
157
  bounds: () => {
146
158
  if (loop) return {};
147
159
  const slidePixels = getSlidePixels();
@@ -205,7 +217,7 @@ export const Swiper = forwardRef(staged((p, ref) => {
205
217
  return () => {
206
218
  window.clearInterval(interval);
207
219
  };
208
- }, [autoplay, autoplayInterval, dragging]);
220
+ }, [autoplay, autoplayInterval, dragging, count]);
209
221
 
210
222
  function renderTrackInner() {
211
223
  if (loop) {
@@ -256,6 +268,8 @@ export const Swiper = forwardRef(staged((p, ref) => {
256
268
  if (draggingRef.current) {
257
269
  e.stopPropagation();
258
270
  }
271
+
272
+ forceCancelDrag();
259
273
  }
260
274
  }, props.allowTouchMove ? bind() : {}), renderTrackInner()), props.indicator === undefined ? React.createElement("div", {
261
275
  className: `${classPrefix}-indicator`
package/2x/es/index.d.ts CHANGED
@@ -56,6 +56,7 @@ export { default as PullToRefresh } from './components/pull-to-refresh';
56
56
  export { default as Radio } from './components/radio';
57
57
  export { default as Rate } from './components/rate';
58
58
  export { default as Result } from './components/result';
59
+ export { default as ResultPage } from './components/result-page';
59
60
  export { default as SafeArea } from './components/safe-area';
60
61
  export { default as ScrollMask } from './components/scroll-mask';
61
62
  export { default as SearchBar } from './components/search-bar';
package/2x/es/index.js CHANGED
@@ -56,6 +56,7 @@ export { default as PullToRefresh } from './components/pull-to-refresh';
56
56
  export { default as Radio } from './components/radio';
57
57
  export { default as Rate } from './components/rate';
58
58
  export { default as Result } from './components/result';
59
+ export { default as ResultPage } from './components/result-page';
59
60
  export { default as SafeArea } from './components/safe-area';
60
61
  export { default as ScrollMask } from './components/scroll-mask';
61
62
  export { default as SearchBar } from './components/search-bar';