antd-mobile 5.10.4 → 5.11.2

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 (194) hide show
  1. package/2x/cjs/components/button/button.d.ts +6 -4
  2. package/2x/cjs/components/button/button.js +31 -7
  3. package/2x/cjs/components/calendar/calendar.css +2 -2
  4. package/2x/cjs/components/calendar/calendar.d.ts +2 -0
  5. package/2x/cjs/components/calendar/calendar.js +6 -1
  6. package/2x/cjs/components/cascade-picker/cascade-picker-utils.d.ts +2 -2
  7. package/2x/cjs/components/cascade-picker/cascade-picker-utils.js +37 -16
  8. package/2x/cjs/components/cascade-picker/cascade-picker.js +2 -7
  9. package/2x/cjs/components/cascade-picker-view/cascade-picker-view.js +2 -7
  10. package/2x/cjs/components/date-picker/date-picker.js +1 -0
  11. package/2x/cjs/components/dialog/dialog-action-button.js +3 -26
  12. package/2x/cjs/components/floating-panel/floating-panel.js +1 -1
  13. package/2x/cjs/components/form/context.d.ts +1 -0
  14. package/2x/cjs/components/form/context.js +2 -1
  15. package/2x/cjs/components/form/form-item.css +1 -1
  16. package/2x/cjs/components/form/form-item.js +3 -1
  17. package/2x/cjs/components/form/form.d.ts +0 -3
  18. package/2x/cjs/components/form/form.js +4 -2
  19. package/2x/cjs/components/form/index.css +1 -1
  20. package/2x/cjs/components/form/index.d.ts +2 -2
  21. package/2x/cjs/components/form/index.js +2 -1
  22. package/2x/cjs/components/image-uploader/image-uploader.js +9 -2
  23. package/2x/cjs/components/index-bar/panel.d.ts +1 -0
  24. package/2x/cjs/components/input/input.css +4 -0
  25. package/2x/cjs/components/input/input.d.ts +2 -0
  26. package/2x/cjs/components/input/input.js +13 -2
  27. package/2x/cjs/components/list/list-item.js +7 -5
  28. package/2x/cjs/components/modal/modal-action-button.js +3 -26
  29. package/2x/cjs/components/search-bar/search-bar.d.ts +2 -0
  30. package/2x/cjs/components/search-bar/search-bar.js +2 -0
  31. package/2x/cjs/components/text-area/text-area.js +1 -1
  32. package/2x/cjs/components/virtual-input/virtual-input.js +2 -1
  33. package/2x/cjs/global/index.js +2 -0
  34. package/2x/cjs/locales/base.d.ts +1 -0
  35. package/2x/cjs/locales/base.js +2 -1
  36. package/2x/cjs/locales/en-US.d.ts +1 -0
  37. package/2x/cjs/locales/es-ES.d.ts +1 -0
  38. package/2x/cjs/locales/fa-IR.d.ts +1 -0
  39. package/2x/cjs/locales/ko-KR.d.ts +1 -0
  40. package/2x/cjs/locales/zh-CN.d.ts +1 -0
  41. package/2x/cjs/locales/zh-CN.js +2 -1
  42. package/2x/cjs/locales/zh-HK.d.ts +1 -0
  43. package/2x/cjs/locales/zh-TW.d.ts +1 -0
  44. package/2x/cjs/utils/is-node-with-content.d.ts +4 -0
  45. package/2x/cjs/utils/is-node-with-content.js +10 -0
  46. package/2x/es/components/button/button.d.ts +6 -4
  47. package/2x/es/components/button/button.js +30 -8
  48. package/2x/es/components/calendar/calendar.css +2 -2
  49. package/2x/es/components/calendar/calendar.d.ts +2 -0
  50. package/2x/es/components/calendar/calendar.js +6 -2
  51. package/2x/es/components/cascade-picker/cascade-picker-utils.d.ts +2 -2
  52. package/2x/es/components/cascade-picker/cascade-picker-utils.js +35 -15
  53. package/2x/es/components/cascade-picker/cascade-picker.js +3 -7
  54. package/2x/es/components/cascade-picker-view/cascade-picker-view.js +3 -7
  55. package/2x/es/components/date-picker/date-picker.js +1 -0
  56. package/2x/es/components/dialog/dialog-action-button.js +3 -21
  57. package/2x/es/components/floating-panel/floating-panel.js +1 -1
  58. package/2x/es/components/form/context.d.ts +1 -0
  59. package/2x/es/components/form/context.js +2 -1
  60. package/2x/es/components/form/form-item.css +1 -1
  61. package/2x/es/components/form/form-item.js +3 -1
  62. package/2x/es/components/form/form.d.ts +0 -3
  63. package/2x/es/components/form/form.js +4 -2
  64. package/2x/es/components/form/index.css +1 -1
  65. package/2x/es/components/form/index.d.ts +2 -2
  66. package/2x/es/components/form/index.js +3 -2
  67. package/2x/es/components/image-uploader/image-uploader.js +8 -2
  68. package/2x/es/components/index-bar/panel.d.ts +1 -0
  69. package/2x/es/components/input/input.css +4 -0
  70. package/2x/es/components/input/input.d.ts +2 -0
  71. package/2x/es/components/input/input.js +13 -2
  72. package/2x/es/components/list/list-item.js +6 -5
  73. package/2x/es/components/modal/modal-action-button.js +3 -21
  74. package/2x/es/components/search-bar/search-bar.d.ts +2 -0
  75. package/2x/es/components/search-bar/search-bar.js +2 -0
  76. package/2x/es/components/text-area/text-area.js +2 -2
  77. package/2x/es/components/virtual-input/virtual-input.js +2 -1
  78. package/2x/es/global/index.js +2 -0
  79. package/2x/es/locales/base.d.ts +1 -0
  80. package/2x/es/locales/base.js +2 -1
  81. package/2x/es/locales/en-US.d.ts +1 -0
  82. package/2x/es/locales/es-ES.d.ts +1 -0
  83. package/2x/es/locales/fa-IR.d.ts +1 -0
  84. package/2x/es/locales/ko-KR.d.ts +1 -0
  85. package/2x/es/locales/zh-CN.d.ts +1 -0
  86. package/2x/es/locales/zh-CN.js +2 -1
  87. package/2x/es/locales/zh-HK.d.ts +1 -0
  88. package/2x/es/locales/zh-TW.d.ts +1 -0
  89. package/2x/es/utils/is-node-with-content.d.ts +4 -0
  90. package/2x/es/utils/is-node-with-content.js +3 -0
  91. package/2x/package.json +2 -2
  92. package/bundle/antd-mobile.cjs.js +122 -106
  93. package/bundle/antd-mobile.es.js +124 -108
  94. package/bundle/style.css +6 -3
  95. package/cjs/components/button/button.d.ts +6 -4
  96. package/cjs/components/button/button.js +31 -7
  97. package/cjs/components/calendar/calendar.css +2 -2
  98. package/cjs/components/calendar/calendar.d.ts +2 -0
  99. package/cjs/components/calendar/calendar.js +6 -1
  100. package/cjs/components/cascade-picker/cascade-picker-utils.d.ts +2 -2
  101. package/cjs/components/cascade-picker/cascade-picker-utils.js +37 -16
  102. package/cjs/components/cascade-picker/cascade-picker.js +2 -7
  103. package/cjs/components/cascade-picker-view/cascade-picker-view.js +2 -7
  104. package/cjs/components/date-picker/date-picker.js +1 -0
  105. package/cjs/components/dialog/dialog-action-button.js +3 -26
  106. package/cjs/components/floating-panel/floating-panel.js +1 -1
  107. package/cjs/components/form/context.d.ts +1 -0
  108. package/cjs/components/form/context.js +2 -1
  109. package/cjs/components/form/form-item.css +1 -1
  110. package/cjs/components/form/form-item.js +3 -1
  111. package/cjs/components/form/form.d.ts +0 -3
  112. package/cjs/components/form/form.js +4 -2
  113. package/cjs/components/form/index.css +1 -1
  114. package/cjs/components/form/index.d.ts +2 -2
  115. package/cjs/components/form/index.js +2 -1
  116. package/cjs/components/image-uploader/image-uploader.js +9 -2
  117. package/cjs/components/index-bar/panel.d.ts +1 -0
  118. package/cjs/components/input/input.css +3 -0
  119. package/cjs/components/input/input.d.ts +2 -0
  120. package/cjs/components/input/input.js +13 -2
  121. package/cjs/components/list/list-item.js +7 -5
  122. package/cjs/components/modal/modal-action-button.js +3 -26
  123. package/cjs/components/search-bar/search-bar.d.ts +2 -0
  124. package/cjs/components/search-bar/search-bar.js +2 -0
  125. package/cjs/components/text-area/text-area.js +1 -1
  126. package/cjs/components/virtual-input/virtual-input.js +2 -1
  127. package/cjs/global/index.js +2 -0
  128. package/cjs/locales/base.d.ts +1 -0
  129. package/cjs/locales/base.js +2 -1
  130. package/cjs/locales/en-US.d.ts +1 -0
  131. package/cjs/locales/es-ES.d.ts +1 -0
  132. package/cjs/locales/fa-IR.d.ts +1 -0
  133. package/cjs/locales/ko-KR.d.ts +1 -0
  134. package/cjs/locales/zh-CN.d.ts +1 -0
  135. package/cjs/locales/zh-CN.js +2 -1
  136. package/cjs/locales/zh-HK.d.ts +1 -0
  137. package/cjs/locales/zh-TW.d.ts +1 -0
  138. package/cjs/utils/is-node-with-content.d.ts +4 -0
  139. package/cjs/utils/is-node-with-content.js +10 -0
  140. package/es/components/button/button.d.ts +6 -4
  141. package/es/components/button/button.js +30 -8
  142. package/es/components/calendar/calendar.css +2 -2
  143. package/es/components/calendar/calendar.d.ts +2 -0
  144. package/es/components/calendar/calendar.js +6 -2
  145. package/es/components/cascade-picker/cascade-picker-utils.d.ts +2 -2
  146. package/es/components/cascade-picker/cascade-picker-utils.js +35 -15
  147. package/es/components/cascade-picker/cascade-picker.js +3 -7
  148. package/es/components/cascade-picker-view/cascade-picker-view.js +3 -7
  149. package/es/components/date-picker/date-picker.js +1 -0
  150. package/es/components/dialog/dialog-action-button.js +3 -21
  151. package/es/components/floating-panel/floating-panel.js +1 -1
  152. package/es/components/form/context.d.ts +1 -0
  153. package/es/components/form/context.js +2 -1
  154. package/es/components/form/form-item.css +1 -1
  155. package/es/components/form/form-item.js +3 -1
  156. package/es/components/form/form.d.ts +0 -3
  157. package/es/components/form/form.js +4 -2
  158. package/es/components/form/index.css +1 -1
  159. package/es/components/form/index.d.ts +2 -2
  160. package/es/components/form/index.js +3 -2
  161. package/es/components/image-uploader/image-uploader.js +8 -2
  162. package/es/components/index-bar/panel.d.ts +1 -0
  163. package/es/components/input/input.css +3 -0
  164. package/es/components/input/input.d.ts +2 -0
  165. package/es/components/input/input.js +13 -2
  166. package/es/components/list/list-item.js +6 -5
  167. package/es/components/modal/modal-action-button.js +3 -21
  168. package/es/components/search-bar/search-bar.d.ts +2 -0
  169. package/es/components/search-bar/search-bar.js +2 -0
  170. package/es/components/text-area/text-area.js +2 -2
  171. package/es/components/virtual-input/virtual-input.js +2 -1
  172. package/es/global/index.js +2 -0
  173. package/es/locales/base.d.ts +1 -0
  174. package/es/locales/base.js +2 -1
  175. package/es/locales/en-US.d.ts +1 -0
  176. package/es/locales/es-ES.d.ts +1 -0
  177. package/es/locales/fa-IR.d.ts +1 -0
  178. package/es/locales/ko-KR.d.ts +1 -0
  179. package/es/locales/zh-CN.d.ts +1 -0
  180. package/es/locales/zh-CN.js +2 -1
  181. package/es/locales/zh-HK.d.ts +1 -0
  182. package/es/locales/zh-TW.d.ts +1 -0
  183. package/es/utils/is-node-with-content.d.ts +4 -0
  184. package/es/utils/is-node-with-content.js +3 -0
  185. package/package.json +2 -2
  186. package/umd/antd-mobile.js +1 -1
  187. package/2x/cjs/components/cascade-picker/use-cascade-picker-options.d.ts +0 -5
  188. package/2x/cjs/components/cascade-picker/use-cascade-picker-options.js +0 -40
  189. package/2x/es/components/cascade-picker/use-cascade-picker-options.d.ts +0 -5
  190. package/2x/es/components/cascade-picker/use-cascade-picker-options.js +0 -32
  191. package/cjs/components/cascade-picker/use-cascade-picker-options.d.ts +0 -5
  192. package/cjs/components/cascade-picker/use-cascade-picker-options.js +0 -40
  193. package/es/components/cascade-picker/use-cascade-picker-options.d.ts +0 -5
  194. package/es/components/cascade-picker/use-cascade-picker-options.js +0 -32
@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.ModalActionButton = void 0;
7
7
 
8
- var _tslib = require("tslib");
9
-
10
- var _react = _interopRequireWildcard(require("react"));
8
+ var _react = _interopRequireDefault(require("react"));
11
9
 
12
10
  var _classnames = _interopRequireDefault(require("classnames"));
13
11
 
@@ -17,34 +15,13 @@ var _nativeProps = require("../../utils/native-props");
17
15
 
18
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
17
 
20
- 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); }
21
-
22
- 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; }
23
-
24
18
  const ModalActionButton = props => {
25
19
  const {
26
20
  action
27
21
  } = props;
28
- const [loading, setLoading] = (0, _react.useState)(false);
29
-
30
- function handleClick() {
31
- return (0, _tslib.__awaiter)(this, void 0, void 0, function* () {
32
- setLoading(true);
33
-
34
- try {
35
- const promise = props.onAction();
36
- yield promise;
37
- setLoading(false);
38
- } catch (e) {
39
- setLoading(false);
40
- throw e;
41
- }
42
- });
43
- }
44
-
45
22
  return (0, _nativeProps.withNativeProps)(props.action, _react.default.createElement(_button.default, {
46
23
  key: action.key,
47
- onClick: handleClick,
24
+ onClick: props.onAction,
48
25
  className: (0, _classnames.default)('adm-modal-button', {
49
26
  'adm-modal-button-primary': props.action.primary
50
27
  }),
@@ -52,7 +29,7 @@ const ModalActionButton = props => {
52
29
  size: props.action.primary ? 'large' : 'middle',
53
30
  block: true,
54
31
  color: action.danger ? 'danger' : 'primary',
55
- loading: loading,
32
+ loading: 'auto',
56
33
  disabled: action.disabled
57
34
  }, action.text));
58
35
  };
@@ -8,6 +8,7 @@ export declare type SearchBarProps = Pick<InputProps, 'onFocus' | 'onBlur' | 'on
8
8
  maxLength?: number;
9
9
  placeholder?: string;
10
10
  clearable?: boolean;
11
+ onlyShowClearWhenFocus?: boolean;
11
12
  showCancelButton?: boolean | ((focus: boolean, value: string) => boolean);
12
13
  cancelText?: string;
13
14
  icon?: ReactNode;
@@ -22,6 +23,7 @@ export declare const SearchBar: React.ForwardRefExoticComponent<Pick<InputProps,
22
23
  maxLength?: number | undefined;
23
24
  placeholder?: string | undefined;
24
25
  clearable?: boolean | undefined;
26
+ onlyShowClearWhenFocus?: boolean | undefined;
25
27
  showCancelButton?: boolean | ((focus: boolean, value: string) => boolean) | undefined;
26
28
  cancelText?: string | undefined;
27
29
  icon?: ReactNode;
@@ -32,6 +32,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
32
32
  const classPrefix = `adm-search-bar`;
33
33
  const defaultProps = {
34
34
  clearable: true,
35
+ onlyShowClearWhenFocus: false,
35
36
  showCancelButton: false,
36
37
  defaultValue: '',
37
38
  clearOnCancel: true,
@@ -123,6 +124,7 @@ const SearchBar = (0, _react.forwardRef)((p, ref) => {
123
124
  maxLength: props.maxLength,
124
125
  placeholder: props.placeholder,
125
126
  clearable: props.clearable,
127
+ onlyShowClearWhenFocus: props.onlyShowClearWhenFocus,
126
128
  onFocus: e => {
127
129
  var _a;
128
130
 
@@ -57,7 +57,7 @@ const TextArea = (0, _react.forwardRef)((p, ref) => {
57
57
  (_a = nativeTextAreaRef.current) === null || _a === void 0 ? void 0 : _a.blur();
58
58
  }
59
59
  }));
60
- (0, _react.useEffect)(() => {
60
+ (0, _react.useLayoutEffect)(() => {
61
61
  if (!autoSize) return;
62
62
  const textArea = nativeTextAreaRef.current;
63
63
  if (!textArea) return;
@@ -105,7 +105,8 @@ const VirtualInput = (0, _react.forwardRef)((p, ref) => {
105
105
 
106
106
  (_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.blur();
107
107
  (_c = (_b = keyboard.props).onClose) === null || _c === void 0 ? void 0 : _c.call(_b);
108
- }
108
+ },
109
+ getContainer: null
109
110
  });
110
111
 
111
112
  return (0, _nativeProps.withNativeProps)(props, _react.default.createElement("div", {
@@ -5,5 +5,7 @@ require("./global.css");
5
5
  var _canUseDom = require("../utils/can-use-dom");
6
6
 
7
7
  if (_canUseDom.canUseDom) {
8
+ // Make sure the `:active` CSS selector of `button` and `a` take effect
9
+ // See: https://stackoverflow.com/questions/3885018/active-pseudo-class-doesnt-work-in-mobile-safari
8
10
  document.addEventListener('touchstart', () => {}, true);
9
11
  }
@@ -86,6 +86,7 @@ export declare const base: {
86
86
  };
87
87
  ImageUploader: {
88
88
  uploading: string;
89
+ upload: string;
89
90
  };
90
91
  InfiniteScroll: {
91
92
  noMore: string;
@@ -92,7 +92,8 @@ const base = {
92
92
  }
93
93
  },
94
94
  ImageUploader: {
95
- uploading: 'Uploading...'
95
+ uploading: 'Uploading...',
96
+ upload: 'Upload'
96
97
  },
97
98
  InfiniteScroll: {
98
99
  noMore: 'No more'
@@ -86,6 +86,7 @@ declare const enUS: {
86
86
  };
87
87
  ImageUploader: {
88
88
  uploading: string;
89
+ upload: string;
89
90
  };
90
91
  InfiniteScroll: {
91
92
  noMore: string;
@@ -86,6 +86,7 @@ declare const esES: {
86
86
  };
87
87
  ImageUploader: {
88
88
  uploading: string;
89
+ upload: string;
89
90
  };
90
91
  InfiniteScroll: {
91
92
  noMore: string;
@@ -86,6 +86,7 @@ declare const faIR: {
86
86
  };
87
87
  ImageUploader: {
88
88
  uploading: string;
89
+ upload: string;
89
90
  };
90
91
  InfiniteScroll: {
91
92
  noMore: string;
@@ -86,6 +86,7 @@ declare const koKR: {
86
86
  };
87
87
  ImageUploader: {
88
88
  uploading: string;
89
+ upload: string;
89
90
  };
90
91
  InfiniteScroll: {
91
92
  noMore: string;
@@ -86,6 +86,7 @@ declare const zhCN: {
86
86
  };
87
87
  ImageUploader: {
88
88
  uploading: string;
89
+ upload: string;
89
90
  };
90
91
  InfiniteScroll: {
91
92
  noMore: string;
@@ -97,7 +97,8 @@ const zhCN = (0, _mergeLocale.mergeLocale)(_base.base, {
97
97
  }
98
98
  },
99
99
  ImageUploader: {
100
- uploading: '上传中...'
100
+ uploading: '上传中...',
101
+ upload: '上传'
101
102
  },
102
103
  InfiniteScroll: {
103
104
  noMore: '没有更多了'
@@ -86,6 +86,7 @@ declare const zhHK: {
86
86
  };
87
87
  ImageUploader: {
88
88
  uploading: string;
89
+ upload: string;
89
90
  };
90
91
  InfiniteScroll: {
91
92
  noMore: string;
@@ -86,6 +86,7 @@ declare const zhTW: {
86
86
  };
87
87
  ImageUploader: {
88
88
  uploading: string;
89
+ upload: string;
89
90
  };
90
91
  InfiniteScroll: {
91
92
  noMore: string;
@@ -0,0 +1,4 @@
1
+ import { ReactNode } from 'react';
2
+ declare type Regulated<T> = T extends null | undefined | false ? never : T;
3
+ export declare function isNodeWithContent(node: ReactNode): node is Regulated<ReactNode>;
4
+ export {};
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isNodeWithContent = isNodeWithContent;
7
+
8
+ function isNodeWithContent(node) {
9
+ return node !== undefined && node !== null && node !== false;
10
+ }
@@ -5,10 +5,11 @@ export declare type ButtonProps = {
5
5
  fill?: 'solid' | 'outline' | 'none';
6
6
  size?: 'mini' | 'small' | 'middle' | 'large';
7
7
  block?: boolean;
8
- loading?: boolean;
8
+ loading?: boolean | 'auto';
9
9
  loadingText?: string;
10
+ loadingIcon?: React.ReactNode;
10
11
  disabled?: boolean;
11
- onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
12
+ onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void | Promise<void>;
12
13
  type?: 'submit' | 'reset' | 'button';
13
14
  shape?: 'default' | 'rounded' | 'rectangular';
14
15
  children?: React.ReactNode;
@@ -21,10 +22,11 @@ export declare const Button: React.ForwardRefExoticComponent<{
21
22
  fill?: "none" | "solid" | "outline" | undefined;
22
23
  size?: "small" | "large" | "middle" | "mini" | undefined;
23
24
  block?: boolean | undefined;
24
- loading?: boolean | undefined;
25
+ loading?: boolean | "auto" | undefined;
25
26
  loadingText?: string | undefined;
27
+ loadingIcon?: React.ReactNode;
26
28
  disabled?: boolean | undefined;
27
- onClick?: ((event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void) | undefined;
29
+ onClick?: ((event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void | Promise<void>) | undefined;
28
30
  type?: "reset" | "submit" | "button" | undefined;
29
31
  shape?: "default" | "rounded" | "rectangular" | undefined;
30
32
  children?: React.ReactNode;
@@ -1,32 +1,56 @@
1
- import React, { forwardRef, useImperativeHandle, useRef } from 'react';
1
+ import { __awaiter } from "tslib";
2
+ import React, { forwardRef, useImperativeHandle, useRef, useState } from 'react';
2
3
  import classNames from 'classnames';
3
4
  import DotLoading from '../dot-loading';
4
5
  import { mergeProps } from '../../utils/with-default-props';
5
6
  import { withNativeProps } from '../../utils/native-props';
7
+ import { isPromise } from '../../utils/validate';
6
8
  const classPrefix = `adm-button`;
7
9
  const defaultProps = {
8
10
  color: 'default',
9
11
  fill: 'solid',
10
12
  block: false,
11
13
  loading: false,
14
+ loadingIcon: React.createElement(DotLoading, {
15
+ color: 'currentColor'
16
+ }),
12
17
  type: 'button',
13
18
  shape: 'default',
14
19
  size: 'middle'
15
20
  };
16
21
  export const Button = forwardRef((p, ref) => {
17
22
  const props = mergeProps(defaultProps, p);
18
- const disabled = props.disabled || props.loading;
23
+ const [innerLoading, setInnerLoading] = useState(false);
19
24
  const nativeButtonRef = useRef(null);
25
+ const loading = props.loading === 'auto' ? innerLoading : props.loading;
26
+ const disabled = props.disabled || loading;
20
27
  useImperativeHandle(ref, () => ({
21
28
  get nativeElement() {
22
29
  return nativeButtonRef.current;
23
30
  }
24
31
 
25
32
  }));
33
+
34
+ const handleClick = e => __awaiter(void 0, void 0, void 0, function* () {
35
+ if (!props.onClick) return;
36
+ const promise = props.onClick(e);
37
+
38
+ if (isPromise(promise)) {
39
+ try {
40
+ setInnerLoading(true);
41
+ yield promise;
42
+ setInnerLoading(false);
43
+ } catch (e) {
44
+ setInnerLoading(false);
45
+ throw e;
46
+ }
47
+ }
48
+ });
49
+
26
50
  return withNativeProps(props, React.createElement("button", {
27
51
  ref: nativeButtonRef,
28
52
  type: props.type,
29
- onClick: props.onClick,
53
+ onClick: handleClick,
30
54
  className: classNames(classPrefix, props.color ? `${classPrefix}-${props.color}` : null, {
31
55
  [`${classPrefix}-block`]: props.block,
32
56
  [`${classPrefix}-disabled`]: disabled,
@@ -35,12 +59,10 @@ export const Button = forwardRef((p, ref) => {
35
59
  [`${classPrefix}-mini`]: props.size === 'mini',
36
60
  [`${classPrefix}-small`]: props.size === 'small',
37
61
  [`${classPrefix}-large`]: props.size === 'large',
38
- [`${classPrefix}-loading`]: props.loading
62
+ [`${classPrefix}-loading`]: loading
39
63
  }, `${classPrefix}-shape-${props.shape}`),
40
64
  disabled: disabled
41
- }, props.loading ? React.createElement("div", {
65
+ }, loading ? React.createElement("div", {
42
66
  className: `${classPrefix}-loading-wrapper`
43
- }, React.createElement(DotLoading, {
44
- color: 'currentColor'
45
- }), props.loadingText) : props.children));
67
+ }, props.loadingIcon, props.loadingText) : props.children));
46
68
  });
@@ -59,11 +59,11 @@
59
59
  color: var(--adm-color-primary);
60
60
  }
61
61
 
62
- .adm-calendar-cell.adm-calendar-cell-out {
62
+ .adm-calendar-cell.adm-calendar-cell-disabled {
63
63
  color: var(--adm-color-light);
64
64
  }
65
65
 
66
- .adm-calendar-cell.adm-calendar-cell-out .adm-calendar-cell-bottom {
66
+ .adm-calendar-cell.adm-calendar-cell-disabled .adm-calendar-cell-bottom {
67
67
  color: var(--adm-color-light);
68
68
  }
69
69
 
@@ -13,6 +13,8 @@ export declare type CalendarProps = {
13
13
  weekStartsOn?: 'Monday' | 'Sunday';
14
14
  renderLabel?: (date: Date) => string | null | undefined;
15
15
  allowClear?: boolean;
16
+ max?: Date;
17
+ min?: Date;
16
18
  } & ({
17
19
  selectionMode?: undefined;
18
20
  value?: undefined;
@@ -1,4 +1,4 @@
1
- import React, { forwardRef, useState, useImperativeHandle } from 'react';
1
+ import React, { forwardRef, useState, useImperativeHandle, useMemo } from 'react';
2
2
  import { withNativeProps } from '../../utils/native-props';
3
3
  import dayjs from 'dayjs';
4
4
  import classNames from 'classnames';
@@ -94,6 +94,8 @@ export const Calendar = forwardRef((p, ref) => {
94
94
  setCurrent(current.add(1, 'year'));
95
95
  }
96
96
  }, React.createElement(ArrowLeftDouble, null)));
97
+ const maxDay = useMemo(() => props.max && dayjs(props.max), [props.max]);
98
+ const minDay = useMemo(() => props.min && dayjs(props.min), [props.min]);
97
99
 
98
100
  function renderCells() {
99
101
  var _a;
@@ -119,9 +121,10 @@ export const Calendar = forwardRef((p, ref) => {
119
121
  }
120
122
 
121
123
  const inThisMonth = d.month() === current.month();
124
+ const disabled = !inThisMonth || maxDay && d.isAfter(maxDay, 'day') || minDay && d.isBefore(minDay, 'day');
122
125
  cells.push(React.createElement("div", {
123
126
  key: d.valueOf(),
124
- className: classNames(`${classPrefix}-cell`, inThisMonth ? `${classPrefix}-cell-in` : `${classPrefix}-cell-out`, inThisMonth && {
127
+ className: classNames(`${classPrefix}-cell`, disabled && `${classPrefix}-cell-disabled`, inThisMonth && {
125
128
  [`${classPrefix}-cell-today`]: d.isSame(today, 'day'),
126
129
  [`${classPrefix}-cell-selected`]: isSelect,
127
130
  [`${classPrefix}-cell-selected-begin`]: isBegin,
@@ -129,6 +132,7 @@ export const Calendar = forwardRef((p, ref) => {
129
132
  }),
130
133
  onClick: () => {
131
134
  if (!props.selectionMode) return;
135
+ if (disabled) return;
132
136
  const date = d.toDate();
133
137
 
134
138
  if (!inThisMonth) {
@@ -1,3 +1,3 @@
1
- import { PickerColumn } from '../picker-view';
1
+ import { PickerColumn, PickerValue } from '../picker-view';
2
2
  import { CascadePickerOption } from './cascade-picker';
3
- export declare function generateCascadePickerColumns(value: string[], options: CascadePickerOption[], depth: number, subOptionsRecord: Record<string, CascadePickerOption[]>): PickerColumn[];
3
+ export declare function useColumnsFn(options: CascadePickerOption[]): (selected: PickerValue[]) => PickerColumn[];
@@ -1,23 +1,43 @@
1
- export function generateCascadePickerColumns(value, options, depth, subOptionsRecord) {
2
- const columns = [];
3
- columns.push(options.map(option => ({
4
- label: option.label,
5
- value: option.value
6
- })));
1
+ import { useMemo } from 'react';
2
+ export function useColumnsFn(options) {
3
+ const depth = useMemo(() => {
4
+ let depth = 0;
7
5
 
8
- for (let i = 0; i < depth - 1; i++) {
9
- const x = value[i];
10
- const subOptions = subOptionsRecord[x];
6
+ function traverse(options, currentDepth) {
7
+ if (currentDepth > depth) depth = currentDepth;
8
+ const nextDepth = currentDepth + 1;
9
+ options.forEach(option => {
10
+ if (option.children) {
11
+ traverse(option.children, nextDepth);
12
+ }
13
+ });
14
+ }
11
15
 
12
- if (!subOptions) {
13
- columns.push([]);
14
- } else {
15
- columns.push(subOptions.map(option => ({
16
+ traverse(options, 1);
17
+ return depth;
18
+ }, [options]);
19
+ return selected => {
20
+ const columns = [];
21
+ let currentOptions = options;
22
+ let i = 0;
23
+
24
+ while (true) {
25
+ columns.push(currentOptions.map(option => ({
16
26
  label: option.label,
17
27
  value: option.value
18
28
  })));
29
+ const x = selected[i];
30
+ const targetOptions = currentOptions.find(option => option.value === x);
31
+ if (!targetOptions || !targetOptions.children) break;
32
+ currentOptions = targetOptions.children;
33
+ i++;
34
+ }
35
+
36
+ while (i < depth - 1) {
37
+ columns.push([]);
38
+ i++;
19
39
  }
20
- }
21
40
 
22
- return columns;
41
+ return columns;
42
+ };
23
43
  }
@@ -1,19 +1,15 @@
1
1
  import { __rest } from "tslib";
2
2
  import React from 'react';
3
3
  import Picker from '../picker';
4
- import { useCascadePickerOptions } from './use-cascade-picker-options';
5
- import { generateCascadePickerColumns } from './cascade-picker-utils';
4
+ import { useColumnsFn } from './cascade-picker-utils';
6
5
  export const CascadePicker = props => {
7
6
  const {
8
7
  options
9
8
  } = props,
10
9
  pickerProps = __rest(props, ["options"]);
11
10
 
12
- const {
13
- depth,
14
- subOptionsRecord
15
- } = useCascadePickerOptions(options);
11
+ const columnsFn = useColumnsFn(options);
16
12
  return React.createElement(Picker, Object.assign({}, pickerProps, {
17
- columns: selected => generateCascadePickerColumns(selected, options, depth, subOptionsRecord)
13
+ columns: columnsFn
18
14
  }));
19
15
  };
@@ -1,19 +1,15 @@
1
1
  import { __rest } from "tslib";
2
2
  import React from 'react';
3
3
  import PickerView from '../picker-view';
4
- import { useCascadePickerOptions } from '../cascade-picker/use-cascade-picker-options';
5
- import { generateCascadePickerColumns } from '../cascade-picker/cascade-picker-utils';
4
+ import { useColumnsFn } from '../cascade-picker/cascade-picker-utils';
6
5
  export const CascadePickerView = props => {
7
6
  const {
8
7
  options
9
8
  } = props,
10
9
  pickerProps = __rest(props, ["options"]);
11
10
 
12
- const {
13
- depth,
14
- subOptionsRecord
15
- } = useCascadePickerOptions(options);
11
+ const columnsFn = useColumnsFn(options);
16
12
  return React.createElement(PickerView, Object.assign({}, pickerProps, {
17
- columns: selected => generateCascadePickerColumns(selected, options, depth, subOptionsRecord)
13
+ columns: columnsFn
18
14
  }));
19
15
  };
@@ -47,6 +47,7 @@ export const DatePicker = p => {
47
47
  value: pickerValue,
48
48
  onCancel: props.onCancel,
49
49
  onClose: props.onClose,
50
+ closeOnMaskClick: props.closeOnMaskClick,
50
51
  visible: props.visible,
51
52
  confirmText: props.confirmText,
52
53
  cancelText: props.cancelText,
@@ -1,5 +1,4 @@
1
- import { __awaiter } from "tslib";
2
- import React, { useState } from 'react';
1
+ import React from 'react';
3
2
  import classNames from 'classnames';
4
3
  import Button from '../button';
5
4
  import { withNativeProps } from '../../utils/native-props';
@@ -7,26 +6,9 @@ export const DialogActionButton = props => {
7
6
  const {
8
7
  action
9
8
  } = props;
10
- const [loading, setLoading] = useState(false);
11
-
12
- function handleClick() {
13
- return __awaiter(this, void 0, void 0, function* () {
14
- setLoading(true);
15
-
16
- try {
17
- const promise = props.onAction();
18
- yield promise;
19
- setLoading(false);
20
- } catch (e) {
21
- setLoading(false);
22
- throw e;
23
- }
24
- });
25
- }
26
-
27
9
  return withNativeProps(props.action, React.createElement(Button, {
28
10
  key: action.key,
29
- onClick: handleClick,
11
+ onClick: props.onAction,
30
12
  className: classNames('adm-dialog-button', {
31
13
  'adm-dialog-button-bold': action.bold
32
14
  }),
@@ -34,7 +16,7 @@ export const DialogActionButton = props => {
34
16
  shape: 'rectangular',
35
17
  block: true,
36
18
  color: action.danger ? 'danger' : 'primary',
37
- loading: loading,
19
+ loading: 'auto',
38
20
  disabled: action.disabled
39
21
  }, action.text));
40
22
  };
@@ -37,7 +37,7 @@ export const FloatingPanel = forwardRef((p, ref) => {
37
37
  tension: 300
38
38
  },
39
39
  onChange: result => {
40
- onHeightChange(result.value.y, y.isAnimating);
40
+ onHeightChange(-result.value.y, y.isAnimating);
41
41
  }
42
42
  }));
43
43
  useDrag(state => {
@@ -6,6 +6,7 @@ export declare type FormContextType = {
6
6
  hasFeedback: boolean;
7
7
  layout: FormLayout;
8
8
  requiredMarkStyle: 'asterisk' | 'text-required' | 'text-optional';
9
+ disabled: boolean;
9
10
  };
10
11
  export declare const defaultFormContext: FormContextType;
11
12
  export declare const FormContext: React.Context<FormContextType>;
@@ -3,7 +3,8 @@ export const defaultFormContext = {
3
3
  name: undefined,
4
4
  hasFeedback: true,
5
5
  layout: 'vertical',
6
- requiredMarkStyle: 'asterisk'
6
+ requiredMarkStyle: 'asterisk',
7
+ disabled: false
7
8
  };
8
9
  export const FormContext = React.createContext(defaultFormContext);
9
10
  export const NoStyleItemContext = React.createContext(null);
@@ -66,7 +66,7 @@
66
66
 
67
67
  .adm-form-item.adm-form-item-horizontal.adm-list-item {
68
68
  --align-items: stretch;
69
- --prefix-width: 6em;
69
+ --prefix-width: 6.8em;
70
70
  }
71
71
 
72
72
  .adm-form-item.adm-form-item-horizontal .adm-list-item-content-prefix {
@@ -18,6 +18,8 @@ const MemoInput = React.memo(({
18
18
  }) => children, (prev, next) => prev.value === next.value && prev.update === next.update);
19
19
 
20
20
  const FormItemLayout = props => {
21
+ var _a;
22
+
21
23
  const {
22
24
  className,
23
25
  style,
@@ -25,7 +27,6 @@ const FormItemLayout = props => {
25
27
  label,
26
28
  help,
27
29
  required,
28
- disabled,
29
30
  children,
30
31
  htmlFor,
31
32
  hidden,
@@ -38,6 +39,7 @@ const FormItemLayout = props => {
38
39
  } = useConfig();
39
40
  const hasFeedback = props.hasFeedback !== undefined ? props.hasFeedback : context.hasFeedback;
40
41
  const layout = props.layout || context.layout;
42
+ const disabled = (_a = props.disabled) !== null && _a !== void 0 ? _a : context.disabled;
41
43
 
42
44
  const requiredMark = (() => {
43
45
  const {
@@ -3,15 +3,12 @@ import { NativeProps } from '../../utils/native-props';
3
3
  import { ListProps } from '../list';
4
4
  import type { FormProps as RcFormProps, FormInstance as RCFormInstance } from 'rc-field-form';
5
5
  import { FormContextType } from './context';
6
- import type { FormLayout } from '.';
7
6
  export declare type FormInstance = Pick<RCFormInstance, 'getFieldValue' | 'getFieldsValue' | 'getFieldError' | 'getFieldsError' | 'isFieldTouched' | 'isFieldsTouched' | 'resetFields' | 'setFields' | 'setFieldsValue' | 'submit' | 'validateFields'>;
8
7
  export declare type FormProps = Pick<RcFormProps, 'form' | 'initialValues' | 'name' | 'preserve' | 'validateMessages' | 'validateTrigger' | 'onFieldsChange' | 'onFinish' | 'onFinishFailed' | 'onValuesChange' | 'children'> & NativeProps<'--border-inner' | '--border-top' | '--border-bottom'> & Partial<FormContextType> & {
9
8
  footer?: ReactNode;
10
- layout?: FormLayout;
11
9
  mode?: ListProps['mode'];
12
10
  };
13
11
  export declare const Form: React.ForwardRefExoticComponent<Pick<RcFormProps<any>, "children" | "form" | "name" | "initialValues" | "preserve" | "validateMessages" | "validateTrigger" | "onFieldsChange" | "onFinish" | "onFinishFailed" | "onValuesChange"> & NativeProps<"--border-inner" | "--border-top" | "--border-bottom"> & Partial<FormContextType> & {
14
12
  footer?: ReactNode;
15
- layout?: FormLayout | undefined;
16
13
  mode?: ListProps['mode'];
17
14
  } & React.RefAttributes<FormInstance>>;