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
@@ -27,4 +27,4 @@ export declare const ActionSheet: FC<ActionSheetProps>;
27
27
  export declare type ActionSheetShowHandler = {
28
28
  close: () => void;
29
29
  };
30
- export declare function showActionSheet(props: Omit<ActionSheetProps, 'visible'>): ActionSheetShowHandler;
30
+ export declare function showActionSheet(props: Omit<ActionSheetProps, 'visible' | 'destroyOnClose' | 'forceRender'>): ActionSheetShowHandler;
@@ -88,6 +88,6 @@ const Button = (0, _react.forwardRef)((p, ref) => {
88
88
  onTouchEnd: props.onTouchEnd
89
89
  }, loading ? _react.default.createElement("div", {
90
90
  className: `${classPrefix}-loading-wrapper`
91
- }, props.loadingIcon, props.loadingText) : props.children));
91
+ }, props.loadingIcon, props.loadingText) : _react.default.createElement("span", null, props.children)));
92
92
  });
93
93
  exports.Button = Button;
@@ -4,7 +4,7 @@ declare type Page = {
4
4
  month: number;
5
5
  year: number;
6
6
  };
7
- export declare type CalenderRef = {
7
+ export declare type CalendarRef = {
8
8
  jumpTo: (page: Page | ((page: Page) => Page)) => void;
9
9
  jumpToToday: () => void;
10
10
  };
@@ -15,7 +15,7 @@ export declare type CalendarProps = {
15
15
  nextYearButton?: React.ReactNode;
16
16
  onPageChange?: (year: number, month: number) => void;
17
17
  weekStartsOn?: 'Monday' | 'Sunday';
18
- renderLabel?: (date: Date) => string | null | undefined;
18
+ renderLabel?: (date: Date) => React.ReactNode;
19
19
  allowClear?: boolean;
20
20
  max?: Date;
21
21
  min?: Date;
@@ -36,5 +36,5 @@ export declare type CalendarProps = {
36
36
  defaultValue?: [Date, Date] | null;
37
37
  onChange?: (val: [Date, Date] | null) => void;
38
38
  }) & NativeProps;
39
- export declare const Calendar: React.ForwardRefExoticComponent<CalendarProps & React.RefAttributes<CalenderRef>>;
39
+ export declare const Calendar: React.ForwardRefExoticComponent<CalendarProps & React.RefAttributes<CalendarRef>>;
40
40
  export {};
@@ -1,4 +1,4 @@
1
1
  import './calendar.less';
2
2
  import { Calendar } from './calendar';
3
- export type { CalendarProps, CalenderRef } from './calendar';
3
+ export type { CalendarProps, CalendarRef } from './calendar';
4
4
  export default Calendar;
@@ -23,6 +23,7 @@ export declare type CascaderProps = {
23
23
  cancelText?: ReactNode;
24
24
  children?: (items: (CascaderOption | null)[], actions: CascaderActions) => ReactNode;
25
25
  onTabsChange?: (index: number) => void;
26
+ activeIcon?: ReactNode;
26
27
  } & Pick<PopupProps, 'getContainer' | 'afterShow' | 'afterClose' | 'onClick' | 'stopPropagation' | 'destroyOnClose' | 'forceRender'> & NativeProps;
27
28
  export declare const Cascader: React.ForwardRefExoticComponent<{
28
29
  options: CascaderOption[];
@@ -39,6 +40,7 @@ export declare const Cascader: React.ForwardRefExoticComponent<{
39
40
  cancelText?: ReactNode;
40
41
  children?: ((items: (CascaderOption | null)[], actions: CascaderActions) => ReactNode) | undefined;
41
42
  onTabsChange?: ((index: number) => void) | undefined;
43
+ activeIcon?: ReactNode;
42
44
  } & Pick<PopupProps, "onClick" | "destroyOnClose" | "forceRender" | "getContainer" | "afterShow" | "afterClose" | "stopPropagation"> & {
43
45
  className?: string | undefined;
44
46
  style?: (React.CSSProperties & Partial<Record<never, string>>) | undefined;
@@ -18,6 +18,7 @@ declare const _default: import("react").ForwardRefExoticComponent<{
18
18
  cancelText?: import("react").ReactNode;
19
19
  children?: ((items: (import("../cascader-view").CascaderOption | null)[], actions: import("./cascader").CascaderActions) => import("react").ReactNode) | undefined;
20
20
  onTabsChange?: ((index: number) => void) | undefined;
21
+ activeIcon?: import("react").ReactNode;
21
22
  } & Pick<import("../popup").PopupProps, "onClick" | "destroyOnClose" | "forceRender" | "getContainer" | "afterShow" | "afterClose" | "stopPropagation"> & {
22
23
  className?: string | undefined;
23
24
  style?: (import("react").CSSProperties & Partial<Record<never, string>>) | undefined;
@@ -1,4 +1,4 @@
1
- import { FC } from 'react';
1
+ import { FC, ReactNode } from 'react';
2
2
  import { NativeProps } from '../../utils/native-props';
3
3
  export declare type CascaderValue = string;
4
4
  export declare type CascaderOption = {
@@ -18,5 +18,6 @@ export declare type CascaderViewProps = {
18
18
  onChange?: (value: CascaderValue[], extend: CascaderValueExtend) => void;
19
19
  placeholder?: string;
20
20
  onTabsChange?: (index: number) => void;
21
+ activeIcon?: ReactNode;
21
22
  } & NativeProps<'--height'>;
22
23
  export declare const CascaderView: FC<CascaderViewProps>;
@@ -147,7 +147,8 @@ const CascaderView = p => {
147
147
  animated: true
148
148
  })) : _react.default.createElement(_checkList.default, {
149
149
  value: [value[index]],
150
- onChange: selectValue => onItemSelect(selectValue[0], index)
150
+ onChange: selectValue => onItemSelect(selectValue[0], index),
151
+ activeIcon: props.activeIcon
151
152
  }, level.options.map(option => {
152
153
  const active = value[index] === option.value;
153
154
  return _react.default.createElement(_checkList.default.Item, {
@@ -1,5 +1,5 @@
1
1
  import { DialogProps } from './dialog';
2
- export declare type DialogShowProps = Omit<DialogProps, 'visible'>;
2
+ export declare type DialogShowProps = Omit<DialogProps, 'visible' | 'destroyOnClose' | 'forceRender'>;
3
3
  export declare type DialogShowHandler = {
4
4
  close: () => void;
5
5
  };
@@ -5,7 +5,7 @@ export declare type FormContextType = {
5
5
  name?: string;
6
6
  hasFeedback: boolean;
7
7
  layout: FormLayout;
8
- requiredMarkStyle: 'asterisk' | 'text-required' | 'text-optional';
8
+ requiredMarkStyle: 'asterisk' | 'text-required' | 'text-optional' | 'none';
9
9
  disabled: boolean;
10
10
  };
11
11
  export declare const defaultFormContext: FormContextType;
@@ -11,6 +11,8 @@ var _react = _interopRequireWildcard(require("react"));
11
11
 
12
12
  var _classnames = _interopRequireDefault(require("classnames"));
13
13
 
14
+ var _nativeProps = require("../../utils/native-props");
15
+
14
16
  var _rcFieldForm = require("rc-field-form");
15
17
 
16
18
  var _FieldContext = _interopRequireDefault(require("rc-field-form/lib/FieldContext"));
@@ -89,6 +91,9 @@ const FormItemLayout = props => {
89
91
  className: `${classPrefix}-required-text`
90
92
  }, "(", locale.Form.optional, ")");
91
93
 
94
+ case 'none':
95
+ return null;
96
+
92
97
  default:
93
98
  return null;
94
99
  }
@@ -114,7 +119,7 @@ const FormItemLayout = props => {
114
119
  key: `warning-${index}`,
115
120
  className: `${classPrefix}-feedback-warning`
116
121
  }, warning)))) : null;
117
- return _react.default.createElement(_list.default.Item, {
122
+ return (0, _nativeProps.withNativeProps)(props, _react.default.createElement(_list.default.Item, {
118
123
  style: style,
119
124
  title: layout === 'vertical' && labelElement,
120
125
  prefix: layout === 'horizontal' && labelElement,
@@ -132,7 +137,7 @@ const FormItemLayout = props => {
132
137
  className: (0, _classnames.default)(`${classPrefix}-child`, `${classPrefix}-child-position-${childElementPosition}`)
133
138
  }, _react.default.createElement("div", {
134
139
  className: (0, _classnames.default)(`${classPrefix}-child-inner`)
135
- }, children)));
140
+ }, children))));
136
141
  };
137
142
 
138
143
  const FormItem = props => {
@@ -223,7 +228,7 @@ const FormItem = props => {
223
228
 
224
229
  return subWarnings;
225
230
  }, curWarnings);
226
- return _react.default.createElement(FormItemLayout, {
231
+ return (0, _nativeProps.withNativeProps)(props, _react.default.createElement(FormItemLayout, {
227
232
  className: className,
228
233
  style: style,
229
234
  label: label,
@@ -244,7 +249,7 @@ const FormItem = props => {
244
249
  arrow: arrow
245
250
  }, _react.default.createElement(_context.NoStyleItemContext.Provider, {
246
251
  value: onSubMetaChange
247
- }, baseChildren));
252
+ }, baseChildren)));
248
253
  }
249
254
 
250
255
  const isRenderProps = typeof children === 'function';
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var _tslib = require("tslib");
4
-
5
3
  var _react = _interopRequireDefault(require("react"));
6
4
 
7
5
  var _testing = require("testing");
@@ -10,13 +8,9 @@ var _index = _interopRequireDefault(require("../index"));
10
8
 
11
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
10
 
11
+ const classPrefix = `adm-image`;
13
12
  const demoSrc = 'https://images.unsplash.com/photo-1567945716310-4745a6b7844b?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=300&q=60';
14
- describe('image', () => {
15
- test('a11y', () => (0, _tslib.__awaiter)(void 0, void 0, void 0, function* () {
16
- yield (0, _testing.testA11y)(_react.default.createElement(_index.default, {
17
- src: demoSrc
18
- }));
19
- }));
13
+ describe('Image', () => {
20
14
  test('onContainerClick can work', () => {
21
15
  const onContainerClick = jest.fn();
22
16
  const {
@@ -31,4 +25,59 @@ describe('image', () => {
31
25
 
32
26
  expect(onContainerClick).toBeCalledTimes(1);
33
27
  });
28
+ test('load successfully', () => {
29
+ (0, _testing.render)(_react.default.createElement(_index.default, {
30
+ src: demoSrc
31
+ }));
32
+ const img = document.querySelectorAll(`.${classPrefix}-img`)[0];
33
+
34
+ _testing.fireEvent.load(img);
35
+
36
+ expect(img).toHaveAttribute('src', demoSrc);
37
+ });
38
+ test('load failed', () => {
39
+ (0, _testing.render)(_react.default.createElement(_index.default, {
40
+ src: '404'
41
+ }));
42
+ const img = document.querySelectorAll(`.${classPrefix}-img`)[0];
43
+
44
+ _testing.fireEvent.error(img);
45
+
46
+ expect(img).not.toBeInTheDocument();
47
+ expect(document.querySelectorAll(`.${classPrefix}-tip`)[0]).toBeInTheDocument();
48
+ });
49
+ test('lazy load should be work', () => {
50
+ // mock useInViewport
51
+ // https://github.com/alibaba/hooks/blob/master/packages/hooks/src/useInViewport/__tests__/index.test.ts
52
+ const mockIntersectionObserver = jest.fn().mockReturnValue({
53
+ observe: () => null,
54
+ disconnect: () => null
55
+ });
56
+ window.IntersectionObserver = mockIntersectionObserver;
57
+ (0, _testing.render)(_react.default.createElement(_index.default, {
58
+ src: demoSrc,
59
+ lazy: true
60
+ }));
61
+ const img = document.querySelectorAll(`.${classPrefix}-img`)[0];
62
+ expect(img).not.toHaveAttribute('src');
63
+ const calls = mockIntersectionObserver.mock.calls;
64
+ const [onChange] = calls[calls.length - 1];
65
+ (0, _testing.act)(() => {
66
+ onChange([{
67
+ isIntersecting: true
68
+ }]);
69
+ });
70
+ expect(img).toHaveAttribute('src', demoSrc);
71
+ });
72
+ test('renders with width and height', () => {
73
+ const {
74
+ getByTestId
75
+ } = (0, _testing.render)(_react.default.createElement(_index.default, {
76
+ src: demoSrc,
77
+ width: 100,
78
+ height: 100,
79
+ "data-testid": 'image'
80
+ }));
81
+ expect(getByTestId('image')).toHaveStyle('--width: 100px;--height: 100px');
82
+ });
34
83
  });
@@ -9,12 +9,16 @@ var _react = _interopRequireWildcard(require("react"));
9
9
 
10
10
  var _web = require("@react-spring/web");
11
11
 
12
+ var _ahooks = require("ahooks");
13
+
12
14
  var _rubberband = require("../../utils/rubberband");
13
15
 
14
16
  var _useDragAndPinch = require("../../utils/use-drag-and-pinch");
15
17
 
16
18
  var _bound = require("../../utils/bound");
17
19
 
20
+ var mat = _interopRequireWildcard(require("../../utils/matrix"));
21
+
18
22
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
23
 
20
24
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -28,54 +32,71 @@ const Slide = props => {
28
32
  const controlRef = (0, _react.useRef)(null);
29
33
  const imgRef = (0, _react.useRef)(null);
30
34
  const [{
31
- zoom,
32
- x,
33
- y
35
+ matrix
34
36
  }, api] = (0, _web.useSpring)(() => ({
35
- zoom: 1,
36
- x: 0,
37
- y: 0,
37
+ matrix: mat.create(),
38
38
  config: {
39
39
  tension: 200
40
40
  }
41
41
  }));
42
+ const controlSize = (0, _ahooks.useSize)(controlRef);
43
+ const imgSize = (0, _ahooks.useSize)(imgRef);
42
44
  const pinchLockRef = (0, _react.useRef)(false);
43
45
 
44
- function boundXY([x, y], rubberband) {
45
- const currentZoom = zoom.get();
46
- let xOffset = 0,
47
- yOffset = 0;
46
+ const boundMatrix = (nextMatrix, type, last = false) => {
47
+ if (!controlSize || !imgSize) return nextMatrix;
48
+ const controlLeft = -controlSize.width / 2;
49
+ const controlTop = -controlSize.height / 2;
50
+ const imgLeft = -imgSize.width / 2;
51
+ const imgTop = -imgSize.height / 2;
52
+ const zoom = mat.getScaleX(nextMatrix);
53
+ const scaledImgWidth = zoom * imgSize.width;
54
+ const scaledImgHeight = zoom * imgSize.height;
55
+ const [x, y] = mat.apply(nextMatrix, [imgLeft, imgTop]);
56
+
57
+ if (type === 'translate') {
58
+ let boundedX = x;
59
+ let boundedY = y;
60
+
61
+ if (scaledImgWidth > controlSize.width) {
62
+ const minX = controlLeft - (scaledImgWidth - controlSize.width);
63
+ const maxX = controlLeft;
64
+ boundedX = last ? (0, _bound.bound)(x, minX, maxX) : (0, _rubberband.rubberbandIfOutOfBounds)(x, minX, maxX, zoom * 50);
65
+ } else {
66
+ boundedX = -scaledImgWidth / 2;
67
+ }
68
+
69
+ if (scaledImgHeight > controlSize.height) {
70
+ const minY = controlTop - (scaledImgHeight - controlSize.height);
71
+ const maxY = controlTop;
72
+ boundedY = last ? (0, _bound.bound)(y, minY, maxY) : (0, _rubberband.rubberbandIfOutOfBounds)(y, minY, maxY, zoom * 50);
73
+ } else {
74
+ boundedY = -scaledImgHeight / 2;
75
+ }
48
76
 
49
- if (imgRef.current && controlRef.current) {
50
- xOffset = ((currentZoom * imgRef.current.width || 0) - controlRef.current.clientWidth) / 2;
51
- yOffset = ((currentZoom * imgRef.current.height || 0) - controlRef.current.clientHeight) / 2;
77
+ return mat.translate(nextMatrix, boundedX - x, boundedY - y);
52
78
  }
53
79
 
54
- xOffset = xOffset > 0 ? xOffset : 0;
55
- yOffset = yOffset > 0 ? yOffset : 0;
56
- const bounds = {
57
- left: -xOffset,
58
- right: xOffset,
59
- top: -yOffset,
60
- bottom: yOffset
61
- };
62
-
63
- if (rubberband) {
64
- return [(0, _rubberband.rubberbandIfOutOfBounds)(x, bounds.left, bounds.right, currentZoom * 50), (0, _rubberband.rubberbandIfOutOfBounds)(y, bounds.top, bounds.bottom, currentZoom * 50)];
65
- } else {
66
- return [(0, _bound.bound)(x, bounds.left, bounds.right), (0, _bound.bound)(y, bounds.top, bounds.bottom)];
80
+ if (type === 'scale' && last) {
81
+ const [boundedX, boundedY] = [scaledImgWidth > controlSize.width ? (0, _bound.bound)(x, controlLeft - (scaledImgWidth - controlSize.width), controlLeft) : -scaledImgWidth / 2, scaledImgHeight > controlSize.height ? (0, _bound.bound)(y, controlTop - (scaledImgHeight - controlSize.height), controlTop) : -scaledImgHeight / 2];
82
+ return mat.translate(nextMatrix, boundedX - x, boundedY - y);
67
83
  }
68
- }
84
+
85
+ return nextMatrix;
86
+ };
69
87
 
70
88
  (0, _useDragAndPinch.useDragAndPinch)({
71
89
  onDrag: state => {
90
+ if (state.first) return;
91
+ if (state.pinching) return state.cancel();
92
+
72
93
  if (state.tap && state.elapsedTime > 0 && state.elapsedTime < 1000) {
73
94
  // 判断点击时间>0是为了过滤掉非正常操作,例如用户长按选择图片之后的取消操作(也是一次点击)
74
95
  props.onTap();
75
96
  return;
76
97
  }
77
98
 
78
- const currentZoom = zoom.get();
99
+ const currentZoom = mat.getScaleX(matrix.get());
79
100
 
80
101
  if (dragLockRef) {
81
102
  dragLockRef.current = currentZoom !== 1;
@@ -83,24 +104,16 @@ const Slide = props => {
83
104
 
84
105
  if (!pinchLockRef.current && currentZoom <= 1) {
85
106
  api.start({
86
- x: 0,
87
- y: 0
107
+ matrix: mat.create()
88
108
  });
89
109
  } else {
90
- if (state.last) {
91
- const [x, y] = boundXY([state.offset[0] + state.velocity[0] * state.direction[0] * 200, state.offset[1] + state.velocity[1] * state.direction[1] * 200], false);
92
- api.start({
93
- x,
94
- y
95
- });
96
- } else {
97
- const [x, y] = boundXY(state.offset, true);
98
- api.start({
99
- x,
100
- y,
101
- immediate: true
102
- });
103
- }
110
+ const currentMatrix = matrix.get();
111
+ const offset = [state.offset[0] - mat.getTranslateX(currentMatrix), state.offset[1] - mat.getTranslateY(currentMatrix)];
112
+ const nextMatrix = mat.translate(currentMatrix, ...(state.last ? [offset[0] + state.velocity[0] * state.direction[0] * 200, offset[1] + state.velocity[1] * state.direction[1] * 200] : offset));
113
+ api.start({
114
+ matrix: boundMatrix(nextMatrix, 'translate', state.last),
115
+ immediate: !state.last
116
+ });
104
117
  }
105
118
  },
106
119
  onPinch: state => {
@@ -110,22 +123,30 @@ const Slide = props => {
110
123
  const [d] = state.offset;
111
124
  if (d < 0) return;
112
125
  const nextZoom = state.last ? (0, _bound.bound)(d, 1, props.maxZoom) : d;
113
- api.start({
114
- zoom: nextZoom,
115
- immediate: !state.last
116
- });
117
126
  (_a = props.onZoomChange) === null || _a === void 0 ? void 0 : _a.call(props, nextZoom);
118
127
 
119
128
  if (state.last && nextZoom <= 1) {
120
129
  api.start({
121
- x: 0,
122
- y: 0
130
+ matrix: mat.create()
123
131
  });
124
132
 
125
133
  if (dragLockRef) {
126
134
  dragLockRef.current = false;
127
135
  }
128
136
  } else {
137
+ if (!controlSize) return;
138
+ const currentMatrix = matrix.get();
139
+ const currentZoom = mat.getScaleX(currentMatrix);
140
+ const originOffsetX = state.origin[0] - controlSize.width / 2;
141
+ const originOffsetY = state.origin[1] - controlSize.height / 2;
142
+ let nextMatrix = mat.translate(currentMatrix, -originOffsetX, -originOffsetY);
143
+ nextMatrix = mat.scale(nextMatrix, nextZoom / currentZoom);
144
+ nextMatrix = mat.translate(nextMatrix, originOffsetX, originOffsetY);
145
+ api.start({
146
+ matrix: boundMatrix(nextMatrix, 'scale', state.last),
147
+ immediate: !state.last
148
+ });
149
+
129
150
  if (dragLockRef) {
130
151
  dragLockRef.current = true;
131
152
  }
@@ -135,13 +156,13 @@ const Slide = props => {
135
156
  target: controlRef,
136
157
  drag: {
137
158
  // filterTaps: true,
138
- from: () => [x.get(), y.get()],
159
+ from: () => [mat.getTranslateX(matrix.get()), mat.getTranslateY(matrix.get())],
139
160
  pointer: {
140
161
  touch: true
141
162
  }
142
163
  },
143
164
  pinch: {
144
- from: () => [zoom.get(), 0],
165
+ from: () => [mat.getScaleX(matrix.get()), 0],
145
166
  pointer: {
146
167
  touch: true
147
168
  }
@@ -150,7 +171,7 @@ const Slide = props => {
150
171
  return _react.default.createElement("div", {
151
172
  className: `${classPrefix}-slide`,
152
173
  onPointerMove: e => {
153
- if (zoom.get() !== 1) {
174
+ if (mat.getScaleX(matrix.get()) !== 1) {
154
175
  e.stopPropagation();
155
176
  }
156
177
  }
@@ -160,9 +181,7 @@ const Slide = props => {
160
181
  }, _react.default.createElement(_web.animated.div, {
161
182
  className: `${classPrefix}-image-wrapper`,
162
183
  style: {
163
- translateX: x,
164
- translateY: y,
165
- scale: zoom
184
+ matrix
166
185
  }
167
186
  }, _react.default.createElement("img", {
168
187
  ref: imgRef,
@@ -23,6 +23,8 @@ var _bound = require("../../utils/bound");
23
23
 
24
24
  var _validate = require("../../utils/validate");
25
25
 
26
+ var _configProvider = require("../config-provider");
27
+
26
28
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
29
 
28
30
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -40,6 +42,9 @@ const Input = (0, _react.forwardRef)((p, ref) => {
40
42
  const [hasFocus, setHasFocus] = (0, _react.useState)(false);
41
43
  const compositionStartRef = (0, _react.useRef)(false);
42
44
  const nativeInputRef = (0, _react.useRef)(null);
45
+ const {
46
+ locale
47
+ } = (0, _configProvider.useConfig)();
43
48
  (0, _react.useImperativeHandle)(ref, () => ({
44
49
  clear: () => {
45
50
  setValue('');
@@ -161,7 +166,8 @@ const Input = (0, _react.forwardRef)((p, ref) => {
161
166
  role: props.role,
162
167
  "aria-valuenow": props['aria-valuenow'],
163
168
  "aria-valuemax": props['aria-valuemax'],
164
- "aria-valuemin": props['aria-valuemin']
169
+ "aria-valuemin": props['aria-valuemin'],
170
+ "aria-label": props['aria-label']
165
171
  }), shouldShowClear && _react.default.createElement("div", {
166
172
  className: `${classPrefix}-clear`,
167
173
  onMouseDown: e => {
@@ -177,7 +183,8 @@ const Input = (0, _react.forwardRef)((p, ref) => {
177
183
  compositionStartRef.current = false;
178
184
  (_b = nativeInputRef.current) === null || _b === void 0 ? void 0 : _b.blur();
179
185
  }
180
- }
186
+ },
187
+ "aria-label": locale.Input.clear
181
188
  }, _react.default.createElement(_antdMobileIcons.CloseCircleFill, null))));
182
189
  });
183
190
  exports.Input = Input;
@@ -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
  };
@@ -61,6 +61,14 @@
61
61
  flex-shrink: 0;
62
62
  margin-left: 12px;
63
63
  }
64
+ .adm-notice-bar-close {
65
+ width: 24px;
66
+ height: 24px;
67
+ margin-right: -3px;
68
+ display: flex;
69
+ align-items: center;
70
+ justify-content: center;
71
+ }
64
72
  .adm-notice-bar-close-icon {
65
73
  font-size: var(--adm-font-size-10);
66
74
  }
@@ -103,14 +103,16 @@ const NoticeBar = (0, _react.memo)(p => {
103
103
  className: `${classPrefix}-content-inner`
104
104
  }, props.content)), (props.closeable || props.extra) && _react.default.createElement("span", {
105
105
  className: `${classPrefix}-right`
106
- }, props.extra, props.closeable && _react.default.createElement(_antdMobileIcons.CloseOutline, {
107
- className: `${classPrefix}-close-icon`,
106
+ }, props.extra, props.closeable && _react.default.createElement("div", {
107
+ className: `${classPrefix}-close`,
108
108
  onClick: () => {
109
109
  var _a;
110
110
 
111
111
  setVisible(false);
112
112
  (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
113
113
  }
114
- }))));
114
+ }, _react.default.createElement(_antdMobileIcons.CloseOutline, {
115
+ className: `${classPrefix}-close-icon`
116
+ })))));
115
117
  });
116
118
  exports.NoticeBar = NoticeBar;
@@ -3,7 +3,7 @@
3
3
  flex-wrap: wrap;
4
4
  flex: 1;
5
5
  }
6
- .adm-number-keyboard-main.confirmed-style .sign-key {
6
+ .adm-number-keyboard-main.adm-number-keyboard-main-confirmed-style .adm-number-keyboard-key-sign {
7
7
  background-color: var(--adm-color-white);
8
8
  }
9
9
  .adm-number-keyboard-popup.adm-popup {
@@ -33,10 +33,10 @@
33
33
  padding: 0 12px;
34
34
  font-size: 16px;
35
35
  }
36
- .adm-number-keyboard-header.with-title {
36
+ .adm-number-keyboard-header.adm-number-keyboard-header-with-title {
37
37
  justify-content: space-between;
38
38
  }
39
- .adm-number-keyboard-header.with-title .adm-number-keyboard-header-close-button {
39
+ .adm-number-keyboard-header.adm-number-keyboard-header-with-title .adm-number-keyboard-header-close-button {
40
40
  padding-right: 0;
41
41
  }
42
42
  .adm-number-keyboard-footer {
@@ -82,31 +82,28 @@
82
82
  content: ' ';
83
83
  box-sizing: content-box;
84
84
  }
85
- .adm-number-keyboard-key.mid-key {
85
+ .adm-number-keyboard-key.adm-number-keyboard-key-mid {
86
86
  flex-basis: 66.67%;
87
87
  }
88
- .adm-number-keyboard-key.sign-key:active::before {
88
+ .adm-number-keyboard-key.adm-number-keyboard-key-sign:active::before {
89
89
  opacity: 0.1;
90
90
  }
91
- .adm-number-keyboard-key.extra-key {
91
+ .adm-number-keyboard-key.adm-number-keyboard-key-extra {
92
92
  border-left: solid 1px var(--adm-color-border);
93
93
  border-right: none;
94
94
  }
95
- .adm-number-keyboard-key.extra-key,
96
- .adm-number-keyboard-key.number-key {
95
+ .adm-number-keyboard-key.adm-number-keyboard-key-extra,
96
+ .adm-number-keyboard-key.adm-number-keyboard-key-number {
97
97
  background-color: var(--adm-color-background);
98
98
  }
99
- .adm-number-keyboard-key.extra-key:active::before,
100
- .adm-number-keyboard-key.number-key:active::before {
99
+ .adm-number-keyboard-key.adm-number-keyboard-key-extra:active::before,
100
+ .adm-number-keyboard-key.adm-number-keyboard-key-number:active::before {
101
101
  opacity: 0.1;
102
102
  }
103
- .adm-number-keyboard-key.ok-key {
103
+ .adm-number-keyboard-key.adm-number-keyboard-key-ok {
104
104
  background-color: var(--adm-color-primary);
105
105
  color: var(--adm-color-white);
106
106
  height: 144px;
107
107
  font-size: 16px;
108
108
  border: none;
109
109
  }
110
- .adm-number-keyboard-bs-key {
111
- height: 20px;
112
- }
@@ -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;