antd-mobile 5.5.1 → 5.7.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 (289) hide show
  1. package/2x/cjs/components/action-sheet/action-sheet.d.ts +5 -5
  2. package/2x/cjs/components/action-sheet/action-sheet.js +6 -46
  3. package/2x/cjs/components/action-sheet/index.d.ts +1 -1
  4. package/2x/cjs/components/badge/badge.js +1 -1
  5. package/2x/cjs/components/calendar/calendar.d.ts +4 -3
  6. package/2x/cjs/components/calendar/calendar.js +67 -56
  7. package/2x/cjs/components/calendar/convert.d.ts +2 -0
  8. package/2x/cjs/components/calendar/convert.js +22 -0
  9. package/2x/cjs/components/cascader-view/cascader-view.js +7 -0
  10. package/2x/cjs/components/checkbox/checkbox.js +4 -20
  11. package/2x/cjs/components/checkbox/native-input.d.ts +10 -0
  12. package/2x/cjs/components/checkbox/native-input.js +42 -0
  13. package/2x/cjs/components/dialog/index.d.ts +1 -1
  14. package/2x/cjs/components/dialog/show.d.ts +2 -4
  15. package/2x/cjs/components/dialog/show.js +9 -47
  16. package/2x/cjs/components/dot-loading/dot-loading.js +1 -2
  17. package/2x/cjs/components/empty/empty-icon.d.ts +3 -0
  18. package/2x/cjs/components/empty/empty-icon.js +37 -0
  19. package/2x/cjs/components/empty/empty.js +27 -15
  20. package/2x/cjs/components/error-block/error-block.css +1 -0
  21. package/2x/cjs/components/error-block/error-block.js +5 -8
  22. package/2x/cjs/components/error-block/images/busy.d.ts +1 -0
  23. package/2x/cjs/components/error-block/images/busy.js +102 -0
  24. package/2x/cjs/components/error-block/images/default.d.ts +1 -0
  25. package/2x/cjs/components/error-block/images/default.js +178 -0
  26. package/2x/cjs/components/error-block/images/disconnected.d.ts +1 -0
  27. package/2x/cjs/components/error-block/images/disconnected.js +135 -0
  28. package/2x/cjs/components/error-block/images/empty.d.ts +1 -0
  29. package/2x/cjs/components/error-block/images/empty.js +131 -0
  30. package/2x/cjs/components/error-block/images/index.d.ts +2 -0
  31. package/2x/cjs/components/error-block/images/index.js +22 -0
  32. package/2x/cjs/components/floating-bubble/floating-bubble.css +2 -1
  33. package/2x/cjs/components/floating-bubble/floating-bubble.d.ts +1 -1
  34. package/2x/cjs/components/form/form-item.d.ts +1 -1
  35. package/2x/cjs/components/form/form-item.js +4 -1
  36. package/2x/cjs/components/image-viewer/index.d.ts +1 -1
  37. package/2x/cjs/components/image-viewer/methods.d.ts +3 -7
  38. package/2x/cjs/components/image-viewer/methods.js +13 -79
  39. package/2x/cjs/components/modal/index.d.ts +1 -1
  40. package/2x/cjs/components/modal/show.d.ts +2 -4
  41. package/2x/cjs/components/modal/show.js +9 -47
  42. package/2x/cjs/components/picker/picker.js +6 -9
  43. package/2x/cjs/components/picker-view/columns-extend.d.ts +3 -0
  44. package/2x/cjs/components/picker-view/columns-extend.js +45 -0
  45. package/2x/cjs/components/picker-view/picker-view.d.ts +1 -0
  46. package/2x/cjs/components/picker-view/picker-view.js +14 -16
  47. package/2x/cjs/components/popover/popover.css +1 -0
  48. package/2x/cjs/components/popover/popover.js +1 -0
  49. package/2x/cjs/components/popover/temp-floating-ui.min.js +1 -430
  50. package/2x/cjs/components/radio/radio.js +4 -20
  51. package/2x/cjs/components/search-bar/search-bar.d.ts +1 -1
  52. package/2x/cjs/components/tab-bar/tab-bar.d.ts +1 -1
  53. package/2x/cjs/components/tab-bar/tab-bar.js +1 -1
  54. package/2x/cjs/components/tree-select/tree-select.js +2 -2
  55. package/2x/cjs/utils/render-imperatively.d.ts +10 -0
  56. package/2x/cjs/utils/render-imperatively.js +68 -0
  57. package/2x/cjs/utils/with-cache.d.ts +1 -0
  58. package/2x/cjs/utils/with-cache.js +17 -0
  59. package/2x/es/components/action-sheet/action-sheet.d.ts +5 -5
  60. package/2x/es/components/action-sheet/action-sheet.js +5 -41
  61. package/2x/es/components/action-sheet/index.d.ts +1 -1
  62. package/2x/es/components/badge/badge.js +1 -1
  63. package/2x/es/components/calendar/calendar.d.ts +4 -3
  64. package/2x/es/components/calendar/calendar.js +67 -58
  65. package/2x/es/components/calendar/convert.d.ts +2 -0
  66. package/2x/es/components/calendar/convert.js +15 -0
  67. package/2x/es/components/cascader-view/cascader-view.js +7 -0
  68. package/2x/es/components/checkbox/checkbox.js +4 -21
  69. package/2x/es/components/checkbox/native-input.d.ts +10 -0
  70. package/2x/es/components/checkbox/native-input.js +28 -0
  71. package/2x/es/components/dialog/index.d.ts +1 -1
  72. package/2x/es/components/dialog/show.d.ts +2 -4
  73. package/2x/es/components/dialog/show.js +8 -44
  74. package/2x/es/components/dot-loading/dot-loading.js +1 -2
  75. package/2x/es/components/empty/empty-icon.d.ts +3 -0
  76. package/2x/es/components/empty/empty-icon.js +24 -0
  77. package/2x/es/components/empty/empty.js +27 -14
  78. package/2x/es/components/error-block/error-block.css +1 -0
  79. package/2x/es/components/error-block/error-block.js +4 -6
  80. package/2x/es/components/error-block/images/busy.d.ts +1 -0
  81. package/2x/es/components/error-block/images/busy.js +90 -0
  82. package/2x/es/components/error-block/images/default.d.ts +1 -0
  83. package/2x/es/components/error-block/images/default.js +166 -0
  84. package/2x/es/components/error-block/images/disconnected.d.ts +1 -0
  85. package/2x/es/components/error-block/images/disconnected.js +123 -0
  86. package/2x/es/components/error-block/images/empty.d.ts +1 -0
  87. package/2x/es/components/error-block/images/empty.js +119 -0
  88. package/2x/es/components/error-block/images/index.d.ts +2 -0
  89. package/2x/es/components/error-block/images/index.js +10 -0
  90. package/2x/es/components/floating-bubble/floating-bubble.css +2 -1
  91. package/2x/es/components/floating-bubble/floating-bubble.d.ts +1 -1
  92. package/2x/es/components/form/form-item.d.ts +1 -1
  93. package/2x/es/components/form/form-item.js +4 -1
  94. package/2x/es/components/image-viewer/index.d.ts +1 -1
  95. package/2x/es/components/image-viewer/methods.d.ts +3 -7
  96. package/2x/es/components/image-viewer/methods.js +12 -75
  97. package/2x/es/components/modal/index.d.ts +1 -1
  98. package/2x/es/components/modal/show.d.ts +2 -4
  99. package/2x/es/components/modal/show.js +8 -44
  100. package/2x/es/components/picker/picker.js +6 -8
  101. package/2x/es/components/picker-view/columns-extend.d.ts +3 -0
  102. package/2x/es/components/picker-view/columns-extend.js +34 -0
  103. package/2x/es/components/picker-view/picker-view.d.ts +1 -0
  104. package/2x/es/components/picker-view/picker-view.js +14 -15
  105. package/2x/es/components/popover/popover.css +1 -0
  106. package/2x/es/components/popover/popover.js +1 -0
  107. package/2x/es/components/popover/temp-floating-ui.min.js +1 -430
  108. package/2x/es/components/radio/radio.js +4 -21
  109. package/2x/es/components/search-bar/search-bar.d.ts +1 -1
  110. package/2x/es/components/tab-bar/tab-bar.d.ts +1 -1
  111. package/2x/es/components/tab-bar/tab-bar.js +1 -1
  112. package/2x/es/components/tree-select/tree-select.js +2 -2
  113. package/2x/es/utils/render-imperatively.d.ts +10 -0
  114. package/2x/es/utils/render-imperatively.js +53 -0
  115. package/2x/es/utils/with-cache.d.ts +1 -0
  116. package/2x/es/utils/with-cache.js +10 -0
  117. package/2x/package.json +2 -3
  118. package/cjs/components/action-sheet/action-sheet.d.ts +5 -5
  119. package/cjs/components/action-sheet/action-sheet.js +6 -46
  120. package/cjs/components/action-sheet/index.d.ts +1 -1
  121. package/cjs/components/badge/badge.js +1 -1
  122. package/cjs/components/calendar/calendar.d.ts +4 -3
  123. package/cjs/components/calendar/calendar.js +67 -56
  124. package/cjs/components/calendar/convert.d.ts +2 -0
  125. package/cjs/components/calendar/convert.js +22 -0
  126. package/cjs/components/cascader-view/cascader-view.js +7 -0
  127. package/cjs/components/checkbox/checkbox.js +4 -20
  128. package/cjs/components/checkbox/native-input.d.ts +10 -0
  129. package/cjs/components/checkbox/native-input.js +42 -0
  130. package/cjs/components/dialog/index.d.ts +1 -1
  131. package/cjs/components/dialog/show.d.ts +2 -4
  132. package/cjs/components/dialog/show.js +9 -47
  133. package/cjs/components/dot-loading/dot-loading.js +1 -2
  134. package/cjs/components/empty/empty-icon.d.ts +3 -0
  135. package/cjs/components/empty/empty-icon.js +37 -0
  136. package/cjs/components/empty/empty.js +27 -15
  137. package/cjs/components/error-block/error-block.css +1 -0
  138. package/cjs/components/error-block/error-block.js +5 -8
  139. package/cjs/components/error-block/images/busy.d.ts +1 -0
  140. package/cjs/components/error-block/images/busy.js +102 -0
  141. package/cjs/components/error-block/images/default.d.ts +1 -0
  142. package/cjs/components/error-block/images/default.js +178 -0
  143. package/cjs/components/error-block/images/disconnected.d.ts +1 -0
  144. package/cjs/components/error-block/images/disconnected.js +135 -0
  145. package/cjs/components/error-block/images/empty.d.ts +1 -0
  146. package/cjs/components/error-block/images/empty.js +131 -0
  147. package/cjs/components/error-block/images/index.d.ts +2 -0
  148. package/cjs/components/error-block/images/index.js +22 -0
  149. package/cjs/components/floating-bubble/floating-bubble.css +2 -1
  150. package/cjs/components/floating-bubble/floating-bubble.d.ts +1 -1
  151. package/cjs/components/form/form-item.d.ts +1 -1
  152. package/cjs/components/form/form-item.js +4 -1
  153. package/cjs/components/image-viewer/index.d.ts +1 -1
  154. package/cjs/components/image-viewer/methods.d.ts +3 -7
  155. package/cjs/components/image-viewer/methods.js +13 -79
  156. package/cjs/components/modal/index.d.ts +1 -1
  157. package/cjs/components/modal/show.d.ts +2 -4
  158. package/cjs/components/modal/show.js +9 -47
  159. package/cjs/components/picker/picker.js +6 -9
  160. package/cjs/components/picker-view/columns-extend.d.ts +3 -0
  161. package/cjs/components/picker-view/columns-extend.js +45 -0
  162. package/cjs/components/picker-view/picker-view.d.ts +1 -0
  163. package/cjs/components/picker-view/picker-view.js +14 -16
  164. package/cjs/components/popover/popover.css +1 -0
  165. package/cjs/components/popover/popover.js +1 -0
  166. package/cjs/components/popover/temp-floating-ui.min.js +1 -430
  167. package/cjs/components/radio/radio.js +4 -20
  168. package/cjs/components/search-bar/search-bar.d.ts +1 -1
  169. package/cjs/components/tab-bar/tab-bar.d.ts +1 -1
  170. package/cjs/components/tab-bar/tab-bar.js +1 -1
  171. package/cjs/components/tree-select/tree-select.js +2 -2
  172. package/cjs/utils/render-imperatively.d.ts +10 -0
  173. package/cjs/utils/render-imperatively.js +68 -0
  174. package/cjs/utils/with-cache.d.ts +1 -0
  175. package/cjs/utils/with-cache.js +17 -0
  176. package/es/components/action-sheet/action-sheet.d.ts +5 -5
  177. package/es/components/action-sheet/action-sheet.js +5 -41
  178. package/es/components/action-sheet/index.d.ts +1 -1
  179. package/es/components/badge/badge.js +1 -1
  180. package/es/components/calendar/calendar.d.ts +4 -3
  181. package/es/components/calendar/calendar.js +67 -58
  182. package/es/components/calendar/convert.d.ts +2 -0
  183. package/es/components/calendar/convert.js +15 -0
  184. package/es/components/cascader-view/cascader-view.js +7 -0
  185. package/es/components/checkbox/checkbox.js +4 -21
  186. package/es/components/checkbox/native-input.d.ts +10 -0
  187. package/es/components/checkbox/native-input.js +28 -0
  188. package/es/components/dialog/index.d.ts +1 -1
  189. package/es/components/dialog/show.d.ts +2 -4
  190. package/es/components/dialog/show.js +8 -44
  191. package/es/components/dot-loading/dot-loading.js +1 -2
  192. package/es/components/empty/empty-icon.d.ts +3 -0
  193. package/es/components/empty/empty-icon.js +24 -0
  194. package/es/components/empty/empty.js +27 -14
  195. package/es/components/error-block/error-block.css +1 -0
  196. package/es/components/error-block/error-block.js +4 -6
  197. package/es/components/error-block/images/busy.d.ts +1 -0
  198. package/es/components/error-block/images/busy.js +90 -0
  199. package/es/components/error-block/images/default.d.ts +1 -0
  200. package/es/components/error-block/images/default.js +166 -0
  201. package/es/components/error-block/images/disconnected.d.ts +1 -0
  202. package/es/components/error-block/images/disconnected.js +123 -0
  203. package/es/components/error-block/images/empty.d.ts +1 -0
  204. package/es/components/error-block/images/empty.js +119 -0
  205. package/es/components/error-block/images/index.d.ts +2 -0
  206. package/es/components/error-block/images/index.js +10 -0
  207. package/es/components/floating-bubble/floating-bubble.css +2 -1
  208. package/es/components/floating-bubble/floating-bubble.d.ts +1 -1
  209. package/es/components/form/form-item.d.ts +1 -1
  210. package/es/components/form/form-item.js +4 -1
  211. package/es/components/image-viewer/index.d.ts +1 -1
  212. package/es/components/image-viewer/methods.d.ts +3 -7
  213. package/es/components/image-viewer/methods.js +12 -75
  214. package/es/components/modal/index.d.ts +1 -1
  215. package/es/components/modal/show.d.ts +2 -4
  216. package/es/components/modal/show.js +8 -44
  217. package/es/components/picker/picker.js +6 -8
  218. package/es/components/picker-view/columns-extend.d.ts +3 -0
  219. package/es/components/picker-view/columns-extend.js +34 -0
  220. package/es/components/picker-view/picker-view.d.ts +1 -0
  221. package/es/components/picker-view/picker-view.js +14 -15
  222. package/es/components/popover/popover.css +1 -0
  223. package/es/components/popover/popover.js +1 -0
  224. package/es/components/popover/temp-floating-ui.min.js +1 -430
  225. package/es/components/radio/radio.js +4 -21
  226. package/es/components/search-bar/search-bar.d.ts +1 -1
  227. package/es/components/tab-bar/tab-bar.d.ts +1 -1
  228. package/es/components/tab-bar/tab-bar.js +1 -1
  229. package/es/components/tree-select/tree-select.js +2 -2
  230. package/es/utils/render-imperatively.d.ts +10 -0
  231. package/es/utils/render-imperatively.js +53 -0
  232. package/es/utils/with-cache.d.ts +1 -0
  233. package/es/utils/with-cache.js +10 -0
  234. package/package.json +2 -3
  235. package/umd/antd-mobile.js +1 -1
  236. package/2x/assets/busy.svg +0 -42
  237. package/2x/assets/default.svg +0 -53
  238. package/2x/assets/disconnected.svg +0 -60
  239. package/2x/assets/empty-icon.svg +0 -18
  240. package/2x/assets/empty.svg +0 -52
  241. package/2x/cjs/assets/busy.svg +0 -42
  242. package/2x/cjs/assets/default.svg +0 -53
  243. package/2x/cjs/assets/disconnected.svg +0 -60
  244. package/2x/cjs/assets/empty-icon.svg +0 -18
  245. package/2x/cjs/assets/empty.svg +0 -52
  246. package/2x/cjs/components/error-block/error.d.ts +0 -1
  247. package/2x/cjs/components/error-block/error.js +0 -24
  248. package/2x/cjs/components/picker-view/use-columns.d.ts +0 -2
  249. package/2x/cjs/components/picker-view/use-columns.js +0 -18
  250. package/2x/cjs/components/picker-view/use-picker-value-extend.d.ts +0 -2
  251. package/2x/cjs/components/picker-view/use-picker-value-extend.js +0 -37
  252. package/2x/es/assets/busy.svg +0 -42
  253. package/2x/es/assets/default.svg +0 -53
  254. package/2x/es/assets/disconnected.svg +0 -60
  255. package/2x/es/assets/empty-icon.svg +0 -18
  256. package/2x/es/assets/empty.svg +0 -52
  257. package/2x/es/components/error-block/error.d.ts +0 -1
  258. package/2x/es/components/error-block/error.js +0 -10
  259. package/2x/es/components/picker-view/use-columns.d.ts +0 -2
  260. package/2x/es/components/picker-view/use-columns.js +0 -10
  261. package/2x/es/components/picker-view/use-picker-value-extend.d.ts +0 -2
  262. package/2x/es/components/picker-view/use-picker-value-extend.js +0 -26
  263. package/assets/busy.svg +0 -42
  264. package/assets/default.svg +0 -53
  265. package/assets/disconnected.svg +0 -60
  266. package/assets/empty-icon.svg +0 -18
  267. package/assets/empty.svg +0 -52
  268. package/cjs/assets/busy.svg +0 -42
  269. package/cjs/assets/default.svg +0 -53
  270. package/cjs/assets/disconnected.svg +0 -60
  271. package/cjs/assets/empty-icon.svg +0 -18
  272. package/cjs/assets/empty.svg +0 -52
  273. package/cjs/components/error-block/error.d.ts +0 -1
  274. package/cjs/components/error-block/error.js +0 -24
  275. package/cjs/components/picker-view/use-columns.d.ts +0 -2
  276. package/cjs/components/picker-view/use-columns.js +0 -18
  277. package/cjs/components/picker-view/use-picker-value-extend.d.ts +0 -2
  278. package/cjs/components/picker-view/use-picker-value-extend.js +0 -37
  279. package/es/assets/busy.svg +0 -42
  280. package/es/assets/default.svg +0 -53
  281. package/es/assets/disconnected.svg +0 -60
  282. package/es/assets/empty-icon.svg +0 -18
  283. package/es/assets/empty.svg +0 -52
  284. package/es/components/error-block/error.d.ts +0 -1
  285. package/es/components/error-block/error.js +0 -10
  286. package/es/components/picker-view/use-columns.d.ts +0 -2
  287. package/es/components/picker-view/use-columns.js +0 -10
  288. package/es/components/picker-view/use-picker-value-extend.d.ts +0 -2
  289. package/es/components/picker-view/use-picker-value-extend.js +0 -26
@@ -1,11 +1,11 @@
1
- import React, { createRef, forwardRef, useEffect, useImperativeHandle, useState } from 'react';
1
+ import React from 'react';
2
2
  import { withNativeProps } from '../../utils/native-props';
3
3
  import { mergeProps } from '../../utils/with-default-props';
4
4
  import classNames from 'classnames';
5
5
  import Popup from '../popup';
6
6
  import Button from '../button';
7
- import { renderToBody } from '../../utils/render-to-body';
8
7
  import SafeArea from '../safe-area';
8
+ import { renderImperatively } from '../../utils/render-imperatively';
9
9
  const classPrefix = `adm-action-sheet`;
10
10
  const defaultProps = {
11
11
  visible: false,
@@ -29,7 +29,8 @@ export const ActionSheet = p => {
29
29
  }
30
30
  },
31
31
  afterClose: props.afterClose,
32
- className: `${classPrefix}-popup`,
32
+ className: classNames(`${classPrefix}-popup`, props.popupClassName),
33
+ style: props.popupStyle,
33
34
  getContainer: props.getContainer
34
35
  }, withNativeProps(props, React.createElement("div", {
35
36
  className: classPrefix
@@ -83,42 +84,5 @@ export const ActionSheet = p => {
83
84
  }))));
84
85
  };
85
86
  export function showActionSheet(props) {
86
- const Wrapper = forwardRef((_, ref) => {
87
- const [visible, setVisible] = useState(false);
88
- useEffect(() => {
89
- setVisible(true);
90
- }, []);
91
-
92
- function handleClose() {
93
- var _a;
94
-
95
- (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
96
- setVisible(false);
97
- }
98
-
99
- useImperativeHandle(ref, () => ({
100
- close: handleClose
101
- }));
102
- return React.createElement(ActionSheet, Object.assign({}, props, {
103
- visible: visible,
104
- onClose: handleClose,
105
- afterClose: () => {
106
- var _a;
107
-
108
- (_a = props.afterClose) === null || _a === void 0 ? void 0 : _a.call(props);
109
- unmount();
110
- }
111
- }));
112
- });
113
- const ref = createRef();
114
- const unmount = renderToBody(React.createElement(Wrapper, {
115
- ref: ref
116
- }));
117
- return {
118
- close: () => {
119
- var _a;
120
-
121
- (_a = ref.current) === null || _a === void 0 ? void 0 : _a.close();
122
- }
123
- };
87
+ return renderImperatively(React.createElement(ActionSheet, Object.assign({}, props)));
124
88
  }
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import './action-sheet.less';
3
3
  import { showActionSheet } from './action-sheet';
4
- export type { Action, ActionSheetProps, ActionSheetRef } from './action-sheet';
4
+ export type { Action, ActionSheetProps, ActionSheetShowHandler, } from './action-sheet';
5
5
  declare const _default: import("react").FC<import("./action-sheet").ActionSheetProps> & {
6
6
  show: typeof showActionSheet;
7
7
  };
@@ -11,7 +11,7 @@ export const Badge = props => {
11
11
  } = props;
12
12
  const isDot = content === dot;
13
13
  const badgeCls = classNames(classPrefix, !!children && `${classPrefix}-fixed`, isDot && `${classPrefix}-dot`, props.bordered && `${classPrefix}-bordered`);
14
- const element = content ? withNativeProps(props, React.createElement("div", {
14
+ const element = content || content === 0 ? withNativeProps(props, React.createElement("div", {
15
15
  className: badgeCls,
16
16
  style: {
17
17
  '--color': color
@@ -9,9 +9,10 @@ export declare type CalenderRef = {
9
9
  jumpToToday: () => void;
10
10
  };
11
11
  export declare type CalendarProps = {
12
+ onPageChange?: (year: number, month: number) => void;
12
13
  weekStartsOn?: 'Monday' | 'Sunday';
13
14
  renderLabel?: (date: Date) => string | null | undefined;
14
- onPageChange?: (year: number, month: number) => void;
15
+ allowClear?: boolean;
15
16
  } & ({
16
17
  selectionMode?: undefined;
17
18
  value?: undefined;
@@ -21,12 +22,12 @@ export declare type CalendarProps = {
21
22
  selectionMode: 'single';
22
23
  value?: Date | null;
23
24
  defaultValue?: Date | null;
24
- onChange?: (val: Date) => void;
25
+ onChange?: (val: Date | null) => void;
25
26
  } | {
26
27
  selectionMode: 'range';
27
28
  value?: [Date, Date] | null;
28
29
  defaultValue?: [Date, Date] | null;
29
- onChange?: (val: [Date, Date]) => void;
30
+ onChange?: (val: [Date, Date] | null) => void;
30
31
  }) & NativeProps;
31
32
  export declare const Calendar: React.ForwardRefExoticComponent<CalendarProps & React.RefAttributes<CalenderRef>>;
32
33
  export {};
@@ -1,4 +1,4 @@
1
- import React, { forwardRef, useMemo, useState, useImperativeHandle } from 'react';
1
+ import React, { forwardRef, useState, useImperativeHandle } from 'react';
2
2
  import { withNativeProps } from '../../utils/native-props';
3
3
  import dayjs from 'dayjs';
4
4
  import classNames from 'classnames';
@@ -7,11 +7,15 @@ import { ArrowLeft } from './arrow-left';
7
7
  import { ArrowLeftDouble } from './arrow-left-double';
8
8
  import { useConfig } from '../config-provider';
9
9
  import isoWeek from 'dayjs/plugin/isoWeek';
10
- import { useIsomorphicLayoutEffect, useUpdateEffect } from 'ahooks';
10
+ import { useUpdateEffect } from 'ahooks';
11
+ import { usePropsValue } from '../../utils/use-props-value';
12
+ import { convertValueToRange } from './convert';
11
13
  dayjs.extend(isoWeek);
12
14
  const classPrefix = 'adm-calendar';
13
15
  const defaultProps = {
14
- weekStartsOn: 'Sunday'
16
+ weekStartsOn: 'Sunday',
17
+ defaultValue: null,
18
+ allowClear: true
15
19
  };
16
20
  export const Calendar = forwardRef((p, ref) => {
17
21
  const today = dayjs();
@@ -26,29 +30,21 @@ export const Calendar = forwardRef((p, ref) => {
26
30
  if (item) markItems.unshift(item);
27
31
  }
28
32
 
29
- const dateRange = useMemo(() => {
30
- var _a, _b, _c, _d;
33
+ const [dateRange, setDateRange] = usePropsValue({
34
+ value: props.value === undefined ? undefined : convertValueToRange(props.selectionMode, props.value),
35
+ defaultValue: convertValueToRange(props.selectionMode, props.defaultValue),
36
+ onChange: v => {
37
+ var _a, _b;
31
38
 
32
- if (props.selectionMode === 'single') {
33
- const value = (_b = (_a = props.value) !== null && _a !== void 0 ? _a : props.defaultValue) !== null && _b !== void 0 ? _b : null;
34
- return [value, value];
35
- } else if (props.selectionMode === 'range') {
36
- return (_d = (_c = props.value) !== null && _c !== void 0 ? _c : props.defaultValue) !== null && _d !== void 0 ? _d : [null, null];
37
- } else {
38
- return [null, null];
39
+ if (props.selectionMode === 'single') {
40
+ (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, v ? v[0] : null);
41
+ } else if (props.selectionMode === 'range') {
42
+ (_b = props.onChange) === null || _b === void 0 ? void 0 : _b.call(props, v);
43
+ }
39
44
  }
40
- }, [props.selectionMode, props.value, props.defaultValue]);
41
- const [begin, setBegin] = useState(null);
42
- const [end, setEnd] = useState(null);
43
- useIsomorphicLayoutEffect(() => {
44
- setBegin(dateRange[0] ? dayjs(dateRange[0]) : null);
45
- setEnd(dateRange[1] ? dayjs(dateRange[1]) : null);
46
- }, [dateRange[0], dateRange[1]]);
47
- const [current, setCurrent] = useState(() => {
48
- var _a;
49
-
50
- return dayjs((_a = dateRange[0]) !== null && _a !== void 0 ? _a : today).date(1);
51
45
  });
46
+ const [intermediate, setIntermediate] = useState(false);
47
+ const [current, setCurrent] = useState(() => dayjs(dateRange ? dateRange[0] : today).date(1));
52
48
  useUpdateEffect(() => {
53
49
  var _a;
54
50
 
@@ -111,14 +107,16 @@ export const Calendar = forwardRef((p, ref) => {
111
107
 
112
108
  while (cells.length < 6 * 7) {
113
109
  const d = iterator;
114
-
115
- const isSelect = (() => {
116
- if (!begin) return false;
117
- if (d.isSame(begin, 'day')) return true;
118
- if (!end) return false;
119
- if (d.isSame(end, 'day')) return true;
120
- return d.isAfter(begin, 'day') && d.isBefore(end, 'day');
121
- })();
110
+ let isSelect = false;
111
+ let isBegin = false;
112
+ let isEnd = false;
113
+
114
+ if (dateRange) {
115
+ const [begin, end] = dateRange;
116
+ isBegin = d.isSame(begin, 'day');
117
+ isEnd = d.isSame(end, 'day');
118
+ isSelect = isBegin || isEnd || d.isAfter(begin, 'day') && d.isBefore(end, 'day');
119
+ }
122
120
 
123
121
  const inThisMonth = d.month() === current.month();
124
122
  cells.push(React.createElement("div", {
@@ -126,41 +124,52 @@ export const Calendar = forwardRef((p, ref) => {
126
124
  className: classNames(`${classPrefix}-cell`, inThisMonth ? `${classPrefix}-cell-in` : `${classPrefix}-cell-out`, inThisMonth && {
127
125
  [`${classPrefix}-cell-today`]: d.isSame(today, 'day'),
128
126
  [`${classPrefix}-cell-selected`]: isSelect,
129
- [`${classPrefix}-cell-selected-begin`]: isSelect && d.isSame(begin, 'day'),
130
- [`${classPrefix}-cell-selected-end`]: isSelect && (!end || d.isSame(end, 'day'))
127
+ [`${classPrefix}-cell-selected-begin`]: isBegin,
128
+ [`${classPrefix}-cell-selected-end`]: isEnd
131
129
  }),
132
130
  onClick: () => {
133
- var _a, _b, _c;
134
-
135
131
  if (!props.selectionMode) return;
132
+ const date = d.toDate();
133
+
134
+ if (!inThisMonth) {
135
+ setCurrent(d.clone().date(1));
136
+ }
137
+
138
+ function shouldClear() {
139
+ if (!props.allowClear) return false;
140
+ if (!dateRange) return false;
141
+ const [begin, end] = dateRange;
142
+ return d.isSame(begin, 'date') && d.isSame(end, 'day');
143
+ }
136
144
 
137
145
  if (props.selectionMode === 'single') {
138
- setBegin(d);
139
- setEnd(d);
140
- (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, d.toDate());
146
+ if (props.allowClear && shouldClear()) {
147
+ setDateRange(null);
148
+ return;
149
+ }
150
+
151
+ setDateRange([date, date]);
141
152
  } else if (props.selectionMode === 'range') {
142
- if (begin !== null && end === null) {
143
- if (begin.isSame(d.toDate())) {
144
- setBegin(null);
145
- setEnd(null);
146
- } else {
147
- if (d.isBefore(begin)) {
148
- setEnd(begin);
149
- setBegin(d);
150
- (_b = props.onChange) === null || _b === void 0 ? void 0 : _b.call(props, [d.toDate(), begin.toDate()]);
151
- } else {
152
- setEnd(d);
153
- (_c = props.onChange) === null || _c === void 0 ? void 0 : _c.call(props, [begin.toDate(), d.toDate()]);
154
- }
155
- }
156
- } else {
157
- setBegin(d);
158
- setEnd(null);
153
+ if (!dateRange) {
154
+ setDateRange([date, date]);
155
+ setIntermediate(true);
156
+ return;
159
157
  }
160
- }
161
158
 
162
- if (!inThisMonth) {
163
- setCurrent(d.clone().date(1));
159
+ if (shouldClear()) {
160
+ setDateRange(null);
161
+ setIntermediate(false);
162
+ return;
163
+ }
164
+
165
+ if (intermediate) {
166
+ const another = dateRange[0];
167
+ setDateRange(another > date ? [date, another] : [another, date]);
168
+ setIntermediate(false);
169
+ } else {
170
+ setDateRange([date, date]);
171
+ setIntermediate(true);
172
+ }
164
173
  }
165
174
  }
166
175
  }, React.createElement("div", {
@@ -0,0 +1,2 @@
1
+ export declare type DateRange = [Date, Date] | null;
2
+ export declare function convertValueToRange(selectionMode: 'single' | 'range' | undefined, value: Date | [Date, Date] | null): DateRange;
@@ -0,0 +1,15 @@
1
+ export function convertValueToRange(selectionMode, value) {
2
+ if (selectionMode === undefined) {
3
+ return null;
4
+ }
5
+
6
+ if (value === null) {
7
+ return null;
8
+ }
9
+
10
+ if (Array.isArray(value)) {
11
+ return value;
12
+ }
13
+
14
+ return [value, value];
15
+ }
@@ -61,6 +61,13 @@ export const CascaderView = p => {
61
61
  useEffect(() => {
62
62
  setTabActiveKey(levels.length - 1);
63
63
  }, [value]);
64
+ useEffect(() => {
65
+ const max = levels.length - 1;
66
+
67
+ if (tabActiveKey > max) {
68
+ setTabActiveKey(max);
69
+ }
70
+ }, [tabActiveKey, levels]);
64
71
 
65
72
  const onItemSelect = (selectValue, depth) => {
66
73
  const next = value.slice(0, depth);
@@ -1,4 +1,4 @@
1
- import React, { useContext, useEffect, useRef } from 'react';
1
+ import React, { useContext } from 'react';
2
2
  import { withNativeProps } from '../../utils/native-props';
3
3
  import classNames from 'classnames';
4
4
  import { CheckboxGroupContext } from './group-context';
@@ -8,6 +8,7 @@ import { devWarning } from '../../utils/dev-log';
8
8
  import { CheckIcon } from './check-icon';
9
9
  import { IndeterminateIcon } from './indeterminate-icon';
10
10
  import { isDev } from '../../utils/is-dev';
11
+ import { NativeInput } from './native-input';
11
12
  const classPrefix = `adm-checkbox`;
12
13
  const defaultProps = {
13
14
  defaultChecked: false,
@@ -66,35 +67,17 @@ export const Checkbox = p => {
66
67
  }, props.indeterminate ? React.createElement(IndeterminateIcon, null) : checked && React.createElement(CheckIcon, null));
67
68
  };
68
69
 
69
- const inputRef = useRef(null);
70
- const labelRef = useRef(null);
71
- useEffect(() => {
72
- var _a;
73
-
74
- (_a = labelRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('click', e => {
75
- if (e.target !== inputRef.current) {
76
- e.stopPropagation();
77
- e.stopImmediatePropagation();
78
- }
79
- }, {
80
- capture: false
81
- });
82
- }, []);
83
70
  return withNativeProps(props, React.createElement("label", {
84
- ref: labelRef,
85
71
  className: classNames(classPrefix, {
86
72
  [`${classPrefix}-checked`]: checked && !props.indeterminate,
87
73
  [`${classPrefix}-indeterminate`]: props.indeterminate,
88
74
  [`${classPrefix}-disabled`]: disabled,
89
75
  [`${classPrefix}-block`]: props.block
90
76
  })
91
- }, React.createElement("input", {
92
- ref: inputRef,
77
+ }, React.createElement(NativeInput, {
93
78
  type: 'checkbox',
94
79
  checked: checked,
95
- onChange: e => {
96
- setChecked(e.target.checked);
97
- },
80
+ onChange: setChecked,
98
81
  disabled: disabled,
99
82
  id: props.id
100
83
  }), renderIcon(), props.children && React.createElement("div", {
@@ -0,0 +1,10 @@
1
+ import { FC } from 'react';
2
+ interface Props {
3
+ type: 'checkbox' | 'radio';
4
+ checked: boolean;
5
+ onChange: (checked: boolean) => void;
6
+ disabled?: boolean;
7
+ id?: string;
8
+ }
9
+ export declare const NativeInput: FC<Props>;
10
+ export {};
@@ -0,0 +1,28 @@
1
+ import React, { useEffect, useRef } from 'react';
2
+ export const NativeInput = props => {
3
+ const inputRef = useRef(null);
4
+ useEffect(() => {
5
+ if (props.disabled) return;
6
+ if (!inputRef.current) return;
7
+ const input = inputRef.current;
8
+
9
+ function handleClick(e) {
10
+ e.stopPropagation();
11
+ e.stopImmediatePropagation();
12
+ props.onChange(input.checked);
13
+ }
14
+
15
+ input.addEventListener('click', handleClick);
16
+ return () => {
17
+ input.removeEventListener('click', handleClick);
18
+ };
19
+ }, [props.disabled, props.onChange]);
20
+ return React.createElement("input", {
21
+ ref: inputRef,
22
+ type: 'checkbox',
23
+ checked: props.checked,
24
+ onChange: () => {},
25
+ disabled: props.disabled,
26
+ id: props.id
27
+ });
28
+ };
@@ -6,7 +6,7 @@ import { confirm } from './confirm';
6
6
  import { clear } from './clear';
7
7
  export type { DialogProps } from './dialog';
8
8
  export type { Action } from './dialog-action-button';
9
- export type { DialogShowProps, DialogShowRef } from './show';
9
+ export type { DialogShowProps, DialogShowHandler } from './show';
10
10
  export type { DialogAlertProps } from './alert';
11
11
  export type { DialogConfirmProps } from './confirm';
12
12
  declare const _default: import("react").FC<import("./dialog").DialogProps> & {
@@ -1,9 +1,7 @@
1
1
  import { DialogProps } from './dialog';
2
2
  export declare type DialogShowProps = Omit<DialogProps, 'visible'>;
3
- export declare type DialogShowRef = {
3
+ export declare type DialogShowHandler = {
4
4
  close: () => void;
5
5
  };
6
6
  export declare const closeFnSet: Set<() => void>;
7
- export declare function show(props: DialogShowProps): {
8
- close: () => void;
9
- };
7
+ export declare function show(props: DialogShowProps): DialogShowHandler;
@@ -1,52 +1,16 @@
1
- import React, { createRef, forwardRef, useEffect, useImperativeHandle, useState } from 'react';
2
- import { renderToBody } from '../../utils/render-to-body';
1
+ import React from 'react';
3
2
  import { Dialog } from './dialog';
3
+ import { renderImperatively } from '../../utils/render-imperatively';
4
4
  export const closeFnSet = new Set();
5
5
  export function show(props) {
6
- const Wrapper = forwardRef((_, ref) => {
7
- const [visible, setVisible] = useState(false);
8
- useEffect(() => {
9
- setVisible(true);
10
- }, []);
11
-
12
- function handleClose() {
13
- var _a;
14
-
15
- (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
16
- setVisible(false);
17
- }
18
-
19
- useImperativeHandle(ref, () => ({
20
- close: handleClose
21
- }));
22
-
23
- function handleAfterClose() {
6
+ const handler = renderImperatively(React.createElement(Dialog, Object.assign({}, props, {
7
+ afterClose: () => {
24
8
  var _a;
25
9
 
10
+ closeFnSet.delete(handler.close);
26
11
  (_a = props.afterClose) === null || _a === void 0 ? void 0 : _a.call(props);
27
- unmount();
28
- closeFnSet.delete(close);
29
12
  }
30
-
31
- return React.createElement(Dialog, Object.assign({}, props, {
32
- visible: visible,
33
- onClose: handleClose,
34
- afterClose: handleAfterClose
35
- }));
36
- });
37
- const ref = createRef();
38
- const unmount = renderToBody(React.createElement(Wrapper, {
39
- ref: ref
40
- }));
41
-
42
- const close = () => {
43
- var _a;
44
-
45
- (_a = ref.current) === null || _a === void 0 ? void 0 : _a.close();
46
- };
47
-
48
- closeFnSet.add(close);
49
- return {
50
- close
51
- };
13
+ })));
14
+ closeFnSet.add(handler.close);
15
+ return handler;
52
16
  }
@@ -53,7 +53,6 @@ export const DotLoading = memo(p => {
53
53
  begin: `${i * 0.2}s`,
54
54
  repeatCount: 'indefinite',
55
55
  values: '16; 6; 26; 16; 16',
56
- keyTimes: '0; 0.1; 0.3; 0.4; 1',
57
- id: 'circ-anim'
56
+ keyTimes: '0; 0.1; 0.3; 0.4; 1'
58
57
  }))))))))));
59
58
  });
@@ -0,0 +1,3 @@
1
+ import { FC } from 'react';
2
+ import { NativeProps } from '../../utils/native-props';
3
+ export declare const EmptyIcon: FC<NativeProps>;
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import { withNativeProps } from '../../utils/native-props';
3
+ export const EmptyIcon = props => {
4
+ return withNativeProps(props, React.createElement("svg", {
5
+ viewBox: '0 0 64 41'
6
+ }, React.createElement("g", {
7
+ transform: 'translate(0 1)',
8
+ fill: 'none',
9
+ fillRule: 'evenodd'
10
+ }, React.createElement("ellipse", {
11
+ fill: '#f5f5f5',
12
+ cx: '32',
13
+ cy: '33',
14
+ rx: '32',
15
+ ry: '7'
16
+ }), React.createElement("g", {
17
+ stroke: '#d9d9d9'
18
+ }, React.createElement("path", {
19
+ d: 'M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z'
20
+ }), React.createElement("path", {
21
+ d: 'M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z',
22
+ fill: '#fafafa'
23
+ })))));
24
+ };
@@ -1,25 +1,38 @@
1
1
  import React from 'react';
2
2
  import classNames from 'classnames';
3
- import { mergeProps } from '../../utils/with-default-props';
4
3
  import { withNativeProps } from '../../utils/native-props';
5
- import EmptyIcon from '../../assets/empty-icon.svg';
4
+ import { EmptyIcon } from './empty-icon';
6
5
  const classPrefix = `adm-empty`;
7
- const defaultProps = {
8
- image: EmptyIcon
9
- };
10
- export const Empty = p => {
11
- const props = mergeProps(defaultProps, p);
12
- const imageNode = typeof props.image === 'string' ? React.createElement("img", {
13
- className: `${classPrefix}-image`,
14
- style: props.imageStyle,
15
- src: props.image,
16
- alt: 'empty'
17
- }) : props.image;
6
+ export const Empty = props => {
7
+ function renderImageNode() {
8
+ const {
9
+ image
10
+ } = props;
11
+
12
+ if (image === undefined) {
13
+ return React.createElement(EmptyIcon, {
14
+ className: `${classPrefix}-image`,
15
+ style: props.imageStyle
16
+ });
17
+ }
18
+
19
+ if (typeof image === 'string') {
20
+ return React.createElement("img", {
21
+ className: `${classPrefix}-image`,
22
+ style: props.imageStyle,
23
+ src: image,
24
+ alt: 'empty'
25
+ });
26
+ }
27
+
28
+ return image;
29
+ }
30
+
18
31
  return withNativeProps(props, React.createElement("div", {
19
32
  className: classPrefix
20
33
  }, React.createElement("div", {
21
34
  className: `${classPrefix}-image-container`
22
- }, imageNode), props.description && React.createElement("div", {
35
+ }, renderImageNode()), props.description && React.createElement("div", {
23
36
  className: classNames(`${classPrefix}-description`)
24
37
  }, props.description)));
25
38
  };
@@ -14,6 +14,7 @@
14
14
  max-width: 100%;
15
15
  }
16
16
 
17
+ .adm-error-block-image svg,
17
18
  .adm-error-block-image img {
18
19
  height: 100%;
19
20
  }
@@ -1,30 +1,28 @@
1
1
  import React from 'react';
2
2
  import classNames from 'classnames';
3
- import { iconRecord } from './error';
4
3
  import { mergeProps } from '../../utils/with-default-props';
5
4
  import { withNativeProps } from '../../utils/native-props';
6
5
  import { useConfig } from '../config-provider';
6
+ import { imageRecord } from './images';
7
7
  const classPrefix = `adm-error-block`;
8
8
  const defaultProps = {
9
9
  status: 'default'
10
10
  };
11
11
  export const ErrorBlock = p => {
12
12
  const props = mergeProps(defaultProps, p);
13
- const icon = iconRecord[props.status];
14
13
  const {
15
14
  locale
16
15
  } = useConfig();
17
16
  const contentPack = locale.ErrorBlock[props.status];
18
17
  const des = 'description' in props ? props.description : contentPack.description;
19
18
  const title = 'title' in props ? props.title : contentPack.title;
20
- let imageNode = React.createElement("img", {
21
- src: icon
22
- });
19
+ let imageNode = imageRecord[props.status];
23
20
 
24
21
  if (props.image) {
25
22
  if (typeof props.image === 'string') {
26
23
  imageNode = React.createElement("img", {
27
- src: props.image
24
+ src: props.image,
25
+ alt: 'error block image'
28
26
  });
29
27
  } else {
30
28
  imageNode = props.image;
@@ -0,0 +1 @@
1
+ export declare const busyImage: JSX.Element;