antd-mobile 5.17.2 → 5.20.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 -19174
  2. package/2x/bundle/antd-mobile.compatible.umd.js +25815 -0
  3. package/2x/bundle/antd-mobile.es.js +16532 -17127
  4. package/2x/bundle/antd-mobile.umd.js +64 -0
  5. package/2x/bundle/style.css +237 -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 +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/form/context.d.ts +1 -1
  16. package/2x/cjs/components/form/form-item.js +9 -4
  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/notice-bar/notice-bar.css +9 -0
  22. package/2x/cjs/components/notice-bar/notice-bar.js +5 -3
  23. package/2x/cjs/components/number-keyboard/number-keyboard.css +11 -15
  24. package/2x/cjs/components/number-keyboard/number-keyboard.d.ts +1 -1
  25. package/2x/cjs/components/number-keyboard/number-keyboard.js +19 -17
  26. package/2x/cjs/components/passcode-input/index.d.ts +1 -1
  27. package/2x/cjs/components/passcode-input/passcode-input.css +12 -12
  28. package/2x/cjs/components/passcode-input/passcode-input.js +16 -8
  29. package/2x/cjs/components/rate/rate.css +1 -0
  30. package/2x/cjs/components/rate/rate.js +38 -5
  31. package/2x/cjs/components/rate/star.js +0 -10
  32. package/2x/cjs/components/result/result.d.ts +1 -1
  33. package/2x/cjs/components/result/result.js +7 -1
  34. package/2x/cjs/components/search-bar/search-bar.js +12 -2
  35. package/2x/cjs/components/swipe-action/swipe-action.d.ts +2 -0
  36. package/2x/cjs/components/swipe-action/swipe-action.js +34 -6
  37. package/2x/cjs/components/swiper/swiper.js +14 -0
  38. package/2x/cjs/components/switch/switch.d.ts +2 -1
  39. package/2x/cjs/components/switch/switch.js +16 -3
  40. package/2x/cjs/locales/base.d.ts +9 -0
  41. package/2x/cjs/locales/base.js +9 -0
  42. package/2x/cjs/locales/en-US.d.ts +9 -0
  43. package/2x/cjs/locales/es-ES.d.ts +9 -0
  44. package/2x/cjs/locales/fa-IR.d.ts +9 -0
  45. package/2x/cjs/locales/fr-FR.d.ts +9 -0
  46. package/2x/cjs/locales/id-ID.d.ts +9 -0
  47. package/2x/cjs/locales/id-ID.js +13 -0
  48. package/2x/cjs/locales/kk-KZ.d.ts +9 -0
  49. package/2x/cjs/locales/ko-KR.d.ts +9 -0
  50. package/2x/cjs/locales/zh-CN.d.ts +9 -0
  51. package/2x/cjs/locales/zh-CN.js +9 -0
  52. package/2x/cjs/locales/zh-HK.d.ts +9 -0
  53. package/2x/cjs/locales/zh-TW.d.ts +9 -0
  54. package/2x/cjs/utils/matrix.d.ts +10 -0
  55. package/2x/cjs/utils/matrix.js +60 -0
  56. package/2x/cjs/utils/merge-locale.d.ts +1 -1
  57. package/2x/cjs/utils/merge-locale.js +15 -5
  58. package/2x/cjs/utils/use-drag-and-pinch.d.ts +1 -1
  59. package/2x/cjs/utils/use-props-value.js +1 -1
  60. package/2x/cjs/utils/use-resize-effect.js +3 -1
  61. package/2x/cjs/utils/with-default-props.js +2 -6
  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 +3 -3
  65. package/2x/es/components/calendar/index.d.ts +1 -1
  66. package/2x/es/components/cascader/cascader.d.ts +2 -0
  67. package/2x/es/components/cascader/index.d.ts +1 -0
  68. package/2x/es/components/cascader-view/cascader-view.d.ts +2 -1
  69. package/2x/es/components/cascader-view/cascader-view.js +2 -1
  70. package/2x/es/components/dialog/show.d.ts +1 -1
  71. package/2x/es/components/form/context.d.ts +1 -1
  72. package/2x/es/components/form/form-item.js +8 -4
  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/notice-bar/notice-bar.css +9 -0
  78. package/2x/es/components/notice-bar/notice-bar.js +5 -3
  79. package/2x/es/components/number-keyboard/number-keyboard.css +11 -15
  80. package/2x/es/components/number-keyboard/number-keyboard.d.ts +1 -1
  81. package/2x/es/components/number-keyboard/number-keyboard.js +19 -17
  82. package/2x/es/components/passcode-input/index.d.ts +1 -1
  83. package/2x/es/components/passcode-input/passcode-input.css +12 -12
  84. package/2x/es/components/passcode-input/passcode-input.js +15 -8
  85. package/2x/es/components/rate/rate.css +1 -0
  86. package/2x/es/components/rate/rate.js +32 -5
  87. package/2x/es/components/rate/star.js +0 -10
  88. package/2x/es/components/result/result.d.ts +1 -1
  89. package/2x/es/components/result/result.js +6 -1
  90. package/2x/es/components/search-bar/search-bar.js +12 -2
  91. package/2x/es/components/swipe-action/swipe-action.d.ts +2 -0
  92. package/2x/es/components/swipe-action/swipe-action.js +34 -6
  93. package/2x/es/components/swiper/swiper.js +14 -0
  94. package/2x/es/components/switch/switch.d.ts +2 -1
  95. package/2x/es/components/switch/switch.js +15 -3
  96. package/2x/es/locales/base.d.ts +9 -0
  97. package/2x/es/locales/base.js +9 -0
  98. package/2x/es/locales/en-US.d.ts +9 -0
  99. package/2x/es/locales/es-ES.d.ts +9 -0
  100. package/2x/es/locales/fa-IR.d.ts +9 -0
  101. package/2x/es/locales/fr-FR.d.ts +9 -0
  102. package/2x/es/locales/id-ID.d.ts +9 -0
  103. package/2x/es/locales/id-ID.js +13 -0
  104. package/2x/es/locales/kk-KZ.d.ts +9 -0
  105. package/2x/es/locales/ko-KR.d.ts +9 -0
  106. package/2x/es/locales/zh-CN.d.ts +9 -0
  107. package/2x/es/locales/zh-CN.js +9 -0
  108. package/2x/es/locales/zh-HK.d.ts +9 -0
  109. package/2x/es/locales/zh-TW.d.ts +9 -0
  110. package/2x/es/utils/matrix.d.ts +10 -0
  111. package/2x/es/utils/matrix.js +27 -0
  112. package/2x/es/utils/merge-locale.d.ts +1 -1
  113. package/2x/es/utils/merge-locale.js +17 -3
  114. package/2x/es/utils/use-drag-and-pinch.d.ts +1 -1
  115. package/2x/es/utils/use-props-value.js +1 -1
  116. package/2x/es/utils/use-resize-effect.js +3 -1
  117. package/2x/es/utils/with-default-props.js +2 -4
  118. package/2x/package.json +6 -6
  119. package/2x/umd/antd-mobile.js +25815 -2
  120. package/bundle/antd-mobile.cjs.js +47 -19174
  121. package/bundle/antd-mobile.compatible.umd.js +25815 -0
  122. package/bundle/antd-mobile.es.js +16532 -17127
  123. package/bundle/antd-mobile.umd.js +64 -0
  124. package/bundle/style.css +1 -4080
  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 +3 -3
  128. package/cjs/components/calendar/index.d.ts +1 -1
  129. package/cjs/components/cascader/cascader.d.ts +2 -0
  130. package/cjs/components/cascader/index.d.ts +1 -0
  131. package/cjs/components/cascader-view/cascader-view.d.ts +2 -1
  132. package/cjs/components/cascader-view/cascader-view.js +2 -1
  133. package/cjs/components/dialog/show.d.ts +1 -1
  134. package/cjs/components/form/context.d.ts +1 -1
  135. package/cjs/components/form/form-item.js +9 -4
  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/notice-bar/notice-bar.css +8 -0
  141. package/cjs/components/notice-bar/notice-bar.js +5 -3
  142. package/cjs/components/number-keyboard/number-keyboard.css +11 -14
  143. package/cjs/components/number-keyboard/number-keyboard.d.ts +1 -1
  144. package/cjs/components/number-keyboard/number-keyboard.js +19 -17
  145. package/cjs/components/passcode-input/index.d.ts +1 -1
  146. package/cjs/components/passcode-input/passcode-input.css +12 -12
  147. package/cjs/components/passcode-input/passcode-input.js +16 -8
  148. package/cjs/components/rate/rate.css +1 -0
  149. package/cjs/components/rate/rate.js +38 -5
  150. package/cjs/components/rate/star.js +0 -10
  151. package/cjs/components/result/result.d.ts +1 -1
  152. package/cjs/components/result/result.js +7 -1
  153. package/cjs/components/search-bar/search-bar.js +12 -2
  154. package/cjs/components/swipe-action/swipe-action.d.ts +2 -0
  155. package/cjs/components/swipe-action/swipe-action.js +34 -6
  156. package/cjs/components/swiper/swiper.js +14 -0
  157. package/cjs/components/switch/switch.d.ts +2 -1
  158. package/cjs/components/switch/switch.js +16 -3
  159. package/cjs/locales/base.d.ts +9 -0
  160. package/cjs/locales/base.js +9 -0
  161. package/cjs/locales/en-US.d.ts +9 -0
  162. package/cjs/locales/es-ES.d.ts +9 -0
  163. package/cjs/locales/fa-IR.d.ts +9 -0
  164. package/cjs/locales/fr-FR.d.ts +9 -0
  165. package/cjs/locales/id-ID.d.ts +9 -0
  166. package/cjs/locales/id-ID.js +13 -0
  167. package/cjs/locales/kk-KZ.d.ts +9 -0
  168. package/cjs/locales/ko-KR.d.ts +9 -0
  169. package/cjs/locales/zh-CN.d.ts +9 -0
  170. package/cjs/locales/zh-CN.js +9 -0
  171. package/cjs/locales/zh-HK.d.ts +9 -0
  172. package/cjs/locales/zh-TW.d.ts +9 -0
  173. package/cjs/utils/matrix.d.ts +10 -0
  174. package/cjs/utils/matrix.js +60 -0
  175. package/cjs/utils/merge-locale.d.ts +1 -1
  176. package/cjs/utils/merge-locale.js +15 -5
  177. package/cjs/utils/use-drag-and-pinch.d.ts +1 -1
  178. package/cjs/utils/use-props-value.js +1 -1
  179. package/cjs/utils/use-resize-effect.js +3 -1
  180. package/cjs/utils/with-default-props.js +2 -6
  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 +3 -3
  184. package/es/components/calendar/index.d.ts +1 -1
  185. package/es/components/cascader/cascader.d.ts +2 -0
  186. package/es/components/cascader/index.d.ts +1 -0
  187. package/es/components/cascader-view/cascader-view.d.ts +2 -1
  188. package/es/components/cascader-view/cascader-view.js +2 -1
  189. package/es/components/dialog/show.d.ts +1 -1
  190. package/es/components/form/context.d.ts +1 -1
  191. package/es/components/form/form-item.js +8 -4
  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/notice-bar/notice-bar.css +8 -0
  197. package/es/components/notice-bar/notice-bar.js +5 -3
  198. package/es/components/number-keyboard/number-keyboard.css +11 -14
  199. package/es/components/number-keyboard/number-keyboard.d.ts +1 -1
  200. package/es/components/number-keyboard/number-keyboard.js +19 -17
  201. package/es/components/passcode-input/index.d.ts +1 -1
  202. package/es/components/passcode-input/passcode-input.css +12 -12
  203. package/es/components/passcode-input/passcode-input.js +15 -8
  204. package/es/components/rate/rate.css +1 -0
  205. package/es/components/rate/rate.js +32 -5
  206. package/es/components/rate/star.js +0 -10
  207. package/es/components/result/result.d.ts +1 -1
  208. package/es/components/result/result.js +6 -1
  209. package/es/components/search-bar/search-bar.js +12 -2
  210. package/es/components/swipe-action/swipe-action.d.ts +2 -0
  211. package/es/components/swipe-action/swipe-action.js +34 -6
  212. package/es/components/swiper/swiper.js +14 -0
  213. package/es/components/switch/switch.d.ts +2 -1
  214. package/es/components/switch/switch.js +15 -3
  215. package/es/locales/base.d.ts +9 -0
  216. package/es/locales/base.js +9 -0
  217. package/es/locales/en-US.d.ts +9 -0
  218. package/es/locales/es-ES.d.ts +9 -0
  219. package/es/locales/fa-IR.d.ts +9 -0
  220. package/es/locales/fr-FR.d.ts +9 -0
  221. package/es/locales/id-ID.d.ts +9 -0
  222. package/es/locales/id-ID.js +13 -0
  223. package/es/locales/kk-KZ.d.ts +9 -0
  224. package/es/locales/ko-KR.d.ts +9 -0
  225. package/es/locales/zh-CN.d.ts +9 -0
  226. package/es/locales/zh-CN.js +9 -0
  227. package/es/locales/zh-HK.d.ts +9 -0
  228. package/es/locales/zh-TW.d.ts +9 -0
  229. package/es/utils/matrix.d.ts +10 -0
  230. package/es/utils/matrix.js +27 -0
  231. package/es/utils/merge-locale.d.ts +1 -1
  232. package/es/utils/merge-locale.js +17 -3
  233. package/es/utils/use-drag-and-pinch.d.ts +1 -1
  234. package/es/utils/use-props-value.js +1 -1
  235. package/es/utils/use-resize-effect.js +3 -1
  236. package/es/utils/with-default-props.js +2 -4
  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 => {
@@ -3,6 +3,7 @@
3
3
  --active-color: #ffd21e;
4
4
  --inactive-color: var(--adm-color-border);
5
5
  display: inline-flex;
6
+ touch-action: pan-y;
6
7
  }
7
8
 
8
9
  .adm-rate-box {
@@ -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) {
@@ -33,13 +36,37 @@ export const Rate = p => {
33
36
  } else {
34
37
  setValue(v);
35
38
  }
36
- }
39
+ },
40
+ role: 'radio',
41
+ "aria-checked": value >= v,
42
+ "aria-label": '' + v
37
43
  }, props.character);
38
44
  }
39
45
 
40
- return withNativeProps(props, React.createElement("div", {
41
- className: classPrefix
42
- }, starList.map((_, i) => React.createElement("div", {
46
+ const bind = useDrag(state => {
47
+ if (props.readOnly) return;
48
+ const {
49
+ xy: [clientX]
50
+ } = state;
51
+ const container = containerRef.current;
52
+ if (!container) return;
53
+ const rect = container.getBoundingClientRect();
54
+ const rawValue = (clientX - rect.left) / rect.width * props.count;
55
+ const roundedValue = props.allowHalf ? Math.round(rawValue * 2) / 2 : Math.round(rawValue);
56
+ setValue(bound(roundedValue, 0, props.count));
57
+ }, {
58
+ axis: 'x',
59
+ preventScroll: true,
60
+ pointer: {
61
+ touch: true
62
+ }
63
+ });
64
+ return withNativeProps(props, React.createElement("div", Object.assign({
65
+ className: classPrefix,
66
+ role: 'radiogroup',
67
+ "aria-readonly": props.readOnly,
68
+ ref: containerRef
69
+ }, bind()), starList.map((_, i) => React.createElement("div", {
43
70
  key: i,
44
71
  className: classNames(`${classPrefix}-box`)
45
72
  }, props.allowHalf && renderStar(i + 0.5, true), renderStar(i + 1, false)))));
@@ -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
  });
@@ -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();
@@ -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`
@@ -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
  }
@@ -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
  };
@@ -93,17 +93,26 @@ declare const esES: {
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
  };
@@ -93,17 +93,26 @@ declare const faIR: {
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
  };
@@ -93,17 +93,26 @@ declare const frFR: {
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
  };
@@ -93,17 +93,26 @@ declare const idID: {
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
  };
@@ -106,6 +106,19 @@ const idID = mergeLocale(base, {
106
106
  pulling: 'Tarik ke bawah untuk menyegarkan',
107
107
  canRelease: 'Lepaskan untuk menyegarkan segera',
108
108
  complete: 'Segarkan berhasil'
109
+ },
110
+ SearchBar: {
111
+ name: 'Bilah Pencarian'
112
+ },
113
+ Slider: {
114
+ name: 'Penggeser'
115
+ },
116
+ Stepper: {
117
+ decrease: 'mengurangi',
118
+ increase: 'meningkat'
119
+ },
120
+ Switch: {
121
+ name: 'Mengalihkan'
109
122
  }
110
123
  });
111
124
  export default idID;
@@ -93,17 +93,26 @@ declare const kkKZ: {
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
  };
@@ -93,17 +93,26 @@ declare const koKR: {
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
  };