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
@@ -50,10 +50,10 @@
50
50
  .adm-calendar-cell.adm-calendar-cell-today {
51
51
  color: var(--adm-color-primary);
52
52
  }
53
- .adm-calendar-cell.adm-calendar-cell-out {
53
+ .adm-calendar-cell.adm-calendar-cell-disabled {
54
54
  color: var(--adm-color-light);
55
55
  }
56
- .adm-calendar-cell.adm-calendar-cell-out .adm-calendar-cell-bottom {
56
+ .adm-calendar-cell.adm-calendar-cell-disabled .adm-calendar-cell-bottom {
57
57
  color: var(--adm-color-light);
58
58
  }
59
59
  .adm-calendar-cell.adm-calendar-cell-selected.adm-calendar-cell.adm-calendar-cell-selected {
@@ -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;
@@ -122,6 +122,9 @@ const Calendar = (0, _react.forwardRef)((p, ref) => {
122
122
  }
123
123
  }, _react.default.createElement(_arrowLeftDouble.ArrowLeftDouble, null)));
124
124
 
125
+ const maxDay = (0, _react.useMemo)(() => props.max && (0, _dayjs.default)(props.max), [props.max]);
126
+ const minDay = (0, _react.useMemo)(() => props.min && (0, _dayjs.default)(props.min), [props.min]);
127
+
125
128
  function renderCells() {
126
129
  var _a;
127
130
 
@@ -146,9 +149,10 @@ const Calendar = (0, _react.forwardRef)((p, ref) => {
146
149
  }
147
150
 
148
151
  const inThisMonth = d.month() === current.month();
152
+ const disabled = !inThisMonth || maxDay && d.isAfter(maxDay, 'day') || minDay && d.isBefore(minDay, 'day');
149
153
  cells.push(_react.default.createElement("div", {
150
154
  key: d.valueOf(),
151
- className: (0, _classnames.default)(`${classPrefix}-cell`, inThisMonth ? `${classPrefix}-cell-in` : `${classPrefix}-cell-out`, inThisMonth && {
155
+ className: (0, _classnames.default)(`${classPrefix}-cell`, disabled && `${classPrefix}-cell-disabled`, inThisMonth && {
152
156
  [`${classPrefix}-cell-today`]: d.isSame(today, 'day'),
153
157
  [`${classPrefix}-cell-selected`]: isSelect,
154
158
  [`${classPrefix}-cell-selected-begin`]: isBegin,
@@ -156,6 +160,7 @@ const Calendar = (0, _react.forwardRef)((p, ref) => {
156
160
  }),
157
161
  onClick: () => {
158
162
  if (!props.selectionMode) return;
163
+ if (disabled) return;
159
164
  const date = d.toDate();
160
165
 
161
166
  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[];
@@ -3,28 +3,49 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.generateCascadePickerColumns = generateCascadePickerColumns;
6
+ exports.useColumnsFn = useColumnsFn;
7
7
 
8
- function generateCascadePickerColumns(value, options, depth, subOptionsRecord) {
9
- const columns = [];
10
- columns.push(options.map(option => ({
11
- label: option.label,
12
- value: option.value
13
- })));
8
+ var _react = require("react");
14
9
 
15
- for (let i = 0; i < depth - 1; i++) {
16
- const x = value[i];
17
- const subOptions = subOptionsRecord[x];
10
+ function useColumnsFn(options) {
11
+ const depth = (0, _react.useMemo)(() => {
12
+ let depth = 0;
18
13
 
19
- if (!subOptions) {
20
- columns.push([]);
21
- } else {
22
- columns.push(subOptions.map(option => ({
14
+ function traverse(options, currentDepth) {
15
+ if (currentDepth > depth) depth = currentDepth;
16
+ const nextDepth = currentDepth + 1;
17
+ options.forEach(option => {
18
+ if (option.children) {
19
+ traverse(option.children, nextDepth);
20
+ }
21
+ });
22
+ }
23
+
24
+ traverse(options, 1);
25
+ return depth;
26
+ }, [options]);
27
+ return selected => {
28
+ const columns = [];
29
+ let currentOptions = options;
30
+ let i = 0;
31
+
32
+ while (true) {
33
+ columns.push(currentOptions.map(option => ({
23
34
  label: option.label,
24
35
  value: option.value
25
36
  })));
37
+ const x = selected[i];
38
+ const targetOptions = currentOptions.find(option => option.value === x);
39
+ if (!targetOptions || !targetOptions.children) break;
40
+ currentOptions = targetOptions.children;
41
+ i++;
42
+ }
43
+
44
+ while (i < depth - 1) {
45
+ columns.push([]);
46
+ i++;
26
47
  }
27
- }
28
48
 
29
- return columns;
49
+ return columns;
50
+ };
30
51
  }
@@ -11,8 +11,6 @@ var _react = _interopRequireDefault(require("react"));
11
11
 
12
12
  var _picker = _interopRequireDefault(require("../picker"));
13
13
 
14
- var _useCascadePickerOptions = require("./use-cascade-picker-options");
15
-
16
14
  var _cascadePickerUtils = require("./cascade-picker-utils");
17
15
 
18
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -22,12 +20,9 @@ const CascadePicker = props => {
22
20
  options
23
21
  } = props,
24
22
  pickerProps = (0, _tslib.__rest)(props, ["options"]);
25
- const {
26
- depth,
27
- subOptionsRecord
28
- } = (0, _useCascadePickerOptions.useCascadePickerOptions)(options);
23
+ const columnsFn = (0, _cascadePickerUtils.useColumnsFn)(options);
29
24
  return _react.default.createElement(_picker.default, Object.assign({}, pickerProps, {
30
- columns: selected => (0, _cascadePickerUtils.generateCascadePickerColumns)(selected, options, depth, subOptionsRecord)
25
+ columns: columnsFn
31
26
  }));
32
27
  };
33
28
 
@@ -11,8 +11,6 @@ var _react = _interopRequireDefault(require("react"));
11
11
 
12
12
  var _pickerView = _interopRequireDefault(require("../picker-view"));
13
13
 
14
- var _useCascadePickerOptions = require("../cascade-picker/use-cascade-picker-options");
15
-
16
14
  var _cascadePickerUtils = require("../cascade-picker/cascade-picker-utils");
17
15
 
18
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -22,12 +20,9 @@ const CascadePickerView = props => {
22
20
  options
23
21
  } = props,
24
22
  pickerProps = (0, _tslib.__rest)(props, ["options"]);
25
- const {
26
- depth,
27
- subOptionsRecord
28
- } = (0, _useCascadePickerOptions.useCascadePickerOptions)(options);
23
+ const columnsFn = (0, _cascadePickerUtils.useColumnsFn)(options);
29
24
  return _react.default.createElement(_pickerView.default, Object.assign({}, pickerProps, {
30
- columns: selected => (0, _cascadePickerUtils.generateCascadePickerColumns)(selected, options, depth, subOptionsRecord)
25
+ columns: columnsFn
31
26
  }));
32
27
  };
33
28
 
@@ -69,6 +69,7 @@ const DatePicker = p => {
69
69
  value: pickerValue,
70
70
  onCancel: props.onCancel,
71
71
  onClose: props.onClose,
72
+ closeOnMaskClick: props.closeOnMaskClick,
72
73
  visible: props.visible,
73
74
  confirmText: props.confirmText,
74
75
  cancelText: props.cancelText,
@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.DialogActionButton = 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 DialogActionButton = 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-dialog-button', {
49
26
  'adm-dialog-button-bold': action.bold
50
27
  }),
@@ -52,7 +29,7 @@ const DialogActionButton = props => {
52
29
  shape: 'rectangular',
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
  };
@@ -57,7 +57,7 @@ const FloatingPanel = (0, _react.forwardRef)((p, ref) => {
57
57
  tension: 300
58
58
  },
59
59
  onChange: result => {
60
- onHeightChange(result.value.y, y.isAnimating);
60
+ onHeightChange(-result.value.y, y.isAnimating);
61
61
  }
62
62
  }));
63
63
  (0, _react2.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>;
@@ -13,7 +13,8 @@ const defaultFormContext = {
13
13
  name: undefined,
14
14
  hasFeedback: true,
15
15
  layout: 'vertical',
16
- requiredMarkStyle: 'asterisk'
16
+ requiredMarkStyle: 'asterisk',
17
+ disabled: false
17
18
  };
18
19
  exports.defaultFormContext = defaultFormContext;
19
20
 
@@ -53,7 +53,7 @@
53
53
  }
54
54
  .adm-form-item.adm-form-item-horizontal.adm-list-item {
55
55
  --align-items: stretch;
56
- --prefix-width: 6em;
56
+ --prefix-width: 6.8em;
57
57
  }
58
58
  .adm-form-item.adm-form-item-horizontal .adm-list-item-content-prefix {
59
59
  padding-top: 12px;
@@ -45,6 +45,8 @@ const MemoInput = _react.default.memo(({
45
45
  }) => children, (prev, next) => prev.value === next.value && prev.update === next.update);
46
46
 
47
47
  const FormItemLayout = props => {
48
+ var _a;
49
+
48
50
  const {
49
51
  className,
50
52
  style,
@@ -52,7 +54,6 @@ const FormItemLayout = props => {
52
54
  label,
53
55
  help,
54
56
  required,
55
- disabled,
56
57
  children,
57
58
  htmlFor,
58
59
  hidden,
@@ -65,6 +66,7 @@ const FormItemLayout = props => {
65
66
  } = (0, _configProvider.useConfig)();
66
67
  const hasFeedback = props.hasFeedback !== undefined ? props.hasFeedback : context.hasFeedback;
67
68
  const layout = props.layout || context.layout;
69
+ const disabled = (_a = props.disabled) !== null && _a !== void 0 ? _a : context.disabled;
68
70
 
69
71
  const requiredMark = (() => {
70
72
  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>>;
@@ -47,9 +47,10 @@ const Form = (0, _react.forwardRef)((p, ref) => {
47
47
  layout,
48
48
  footer,
49
49
  mode,
50
+ disabled,
50
51
  requiredMarkStyle
51
52
  } = props,
52
- formProps = (0, _tslib.__rest)(props, ["className", "style", "hasFeedback", "children", "layout", "footer", "mode", "requiredMarkStyle"]);
53
+ formProps = (0, _tslib.__rest)(props, ["className", "style", "hasFeedback", "children", "layout", "footer", "mode", "disabled", "requiredMarkStyle"]);
53
54
  const {
54
55
  locale
55
56
  } = (0, _configProvider.useConfig)();
@@ -99,7 +100,8 @@ const Form = (0, _react.forwardRef)((p, ref) => {
99
100
  name: formProps.name,
100
101
  hasFeedback,
101
102
  layout,
102
- requiredMarkStyle
103
+ requiredMarkStyle,
104
+ disabled: disabled
103
105
  }
104
106
  }, lists), footer && _react.default.createElement("div", {
105
107
  className: `${classPrefix}-footer`
@@ -75,7 +75,7 @@
75
75
  }
76
76
  .adm-form-item.adm-form-item-horizontal.adm-list-item {
77
77
  --align-items: stretch;
78
- --prefix-width: 6em;
78
+ --prefix-width: 6.8em;
79
79
  }
80
80
  .adm-form-item.adm-form-item-horizontal .adm-list-item-content-prefix {
81
81
  padding-top: 12px;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import './index.less';
3
- import { useForm } from 'rc-field-form';
3
+ import { useWatch, useForm } from 'rc-field-form';
4
4
  export declare type FormLayout = 'vertical' | 'horizontal';
5
5
  export type { FormProps, FormInstance } from './form';
6
6
  export type { FormItemProps } from './form-item';
@@ -9,7 +9,6 @@ export type { ValidateMessages, FieldData, NamePath, } from 'rc-field-form/es/in
9
9
  export type { FormArrayField, FormArrayOperation, FormArrayProps, } from './form-array';
10
10
  declare const _default: import("react").ForwardRefExoticComponent<Pick<import("rc-field-form").FormProps<any>, "children" | "form" | "name" | "initialValues" | "preserve" | "validateMessages" | "validateTrigger" | "onFieldsChange" | "onFinish" | "onFinishFailed" | "onValuesChange"> & import("../../utils/native-props").NativeProps<"--border-inner" | "--border-top" | "--border-bottom"> & Partial<import("./context").FormContextType> & {
11
11
  footer?: import("react").ReactNode;
12
- layout?: FormLayout | undefined;
13
12
  mode?: "default" | "card" | undefined;
14
13
  } & import("react").RefAttributes<import("./form").FormInstance>> & {
15
14
  Item: import("react").FC<import("./form-item").FormItemProps>;
@@ -19,5 +18,6 @@ declare const _default: import("react").ForwardRefExoticComponent<Pick<import("r
19
18
  }>;
20
19
  Array: import("react").FC<import("./form-array").FormArrayProps>;
21
20
  useForm: typeof useForm;
21
+ useWatch: typeof useWatch;
22
22
  };
23
23
  export default _default;
@@ -26,7 +26,8 @@ var _default = (0, _attachPropertiesToComponent.attachPropertiesToComponent)(_fo
26
26
  Subscribe: _formSubscribe.FormSubscribe,
27
27
  Header: _header.Header,
28
28
  Array: _formArray.FormArray,
29
- useForm: _rcFieldForm.useForm
29
+ useForm: _rcFieldForm.useForm,
30
+ useWatch: _rcFieldForm.useWatch
30
31
  });
31
32
 
32
33
  exports.default = _default;
@@ -25,6 +25,8 @@ var _space = _interopRequireDefault(require("../space"));
25
25
 
26
26
  var _nativeProps = require("../../utils/native-props");
27
27
 
28
+ var _configProvider = require("../config-provider");
29
+
28
30
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
31
 
30
32
  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); }
@@ -46,6 +48,9 @@ const defaultProps = {
46
48
  };
47
49
 
48
50
  const ImageUploader = p => {
51
+ const {
52
+ locale
53
+ } = (0, _configProvider.useConfig)();
49
54
  const props = (0, _withDefaultProps.mergeProps)(defaultProps, p);
50
55
  const [value, setValue] = (0, _usePropsValue.usePropsValue)(props);
51
56
  const updateValue = (0, _ahooks.useMemoizedFn)(updater => {
@@ -218,7 +223,8 @@ const ImageUploader = p => {
218
223
  className: `${classPrefix}-upload-button-wrap`
219
224
  }, props.children ? props.children : _react.default.createElement("span", {
220
225
  className: `${classPrefix}-cell ${classPrefix}-upload-button`,
221
- role: 'button'
226
+ role: 'button',
227
+ "aria-label": locale.ImageUploader.upload
222
228
  }, _react.default.createElement("span", {
223
229
  className: `${classPrefix}-upload-button-icon`
224
230
  }, _react.default.createElement(_antdMobileIcons.AddOutline, null))), !props.disableUpload && _react.default.createElement("input", {
@@ -227,7 +233,8 @@ const ImageUploader = p => {
227
233
  multiple: props.multiple,
228
234
  type: 'file',
229
235
  className: `${classPrefix}-input`,
230
- onChange: onChange
236
+ onChange: onChange,
237
+ "aria-hidden": true
231
238
  })))));
232
239
  };
233
240
 
@@ -4,5 +4,6 @@ export declare type IndexBarPanelProps = {
4
4
  index: string;
5
5
  title?: ReactNode;
6
6
  brief?: ReactNode;
7
+ children?: ReactNode;
7
8
  } & NativeProps;
8
9
  export declare const Panel: FC<IndexBarPanelProps>;
@@ -58,6 +58,9 @@
58
58
  .adm-input-element::-webkit-search-decoration {
59
59
  display: none;
60
60
  }
61
+ .adm-input-element:disabled {
62
+ opacity: 1;
63
+ }
61
64
  .adm-input-element[type='date'],
62
65
  .adm-input-element[type='time'],
63
66
  .adm-input-element[type='datetime-local'] {
@@ -9,6 +9,7 @@ export declare type InputProps = Pick<NativeInputProps, 'maxLength' | 'minLength
9
9
  disabled?: boolean;
10
10
  readOnly?: boolean;
11
11
  clearable?: boolean;
12
+ onlyShowClearWhenFocus?: boolean;
12
13
  onClear?: () => void;
13
14
  id?: string;
14
15
  onEnterPress?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
@@ -30,6 +31,7 @@ export declare const Input: React.ForwardRefExoticComponent<Pick<NativeInputProp
30
31
  disabled?: boolean | undefined;
31
32
  readOnly?: boolean | undefined;
32
33
  clearable?: boolean | undefined;
34
+ onlyShowClearWhenFocus?: boolean | undefined;
33
35
  onClear?: (() => void) | undefined;
34
36
  id?: string | undefined;
35
37
  onEnterPress?: ((e: React.KeyboardEvent<HTMLInputElement>) => void) | undefined;
@@ -29,7 +29,8 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
29
29
 
30
30
  const classPrefix = `adm-input`;
31
31
  const defaultProps = {
32
- defaultValue: ''
32
+ defaultValue: '',
33
+ onlyShowClearWhenFocus: true
33
34
  };
34
35
  const Input = (0, _react.forwardRef)((p, ref) => {
35
36
  const props = (0, _withDefaultProps.mergeProps)(defaultProps, p);
@@ -91,6 +92,16 @@ const Input = (0, _react.forwardRef)((p, ref) => {
91
92
  }
92
93
  }
93
94
 
95
+ const shouldShowClear = (() => {
96
+ if (!props.clearable || !value || props.readOnly) return false;
97
+
98
+ if (props.onlyShowClearWhenFocus) {
99
+ return hasFocus;
100
+ } else {
101
+ return true;
102
+ }
103
+ })();
104
+
94
105
  return (0, _nativeProps.withNativeProps)(props, _react.default.createElement("div", {
95
106
  className: (0, _classnames.default)(`${classPrefix}`, props.disabled && `${classPrefix}-disabled`)
96
107
  }, _react.default.createElement("input", {
@@ -133,7 +144,7 @@ const Input = (0, _react.forwardRef)((p, ref) => {
133
144
  onCompositionStart: props.onCompositionStart,
134
145
  onCompositionEnd: props.onCompositionEnd,
135
146
  onClick: props.onClick
136
- }), props.clearable && !!value && !props.readOnly && hasFocus && _react.default.createElement("div", {
147
+ }), shouldShowClear && _react.default.createElement("div", {
137
148
  className: `${classPrefix}-clear`,
138
149
  onMouseDown: e => {
139
150
  e.preventDefault();
@@ -13,6 +13,8 @@ var _antdMobileIcons = require("antd-mobile-icons");
13
13
 
14
14
  var _classnames = _interopRequireDefault(require("classnames"));
15
15
 
16
+ var _isNodeWithContent = require("../../utils/is-node-with-content");
17
+
16
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
19
 
18
20
  const classPrefix = `adm-list-item`;
@@ -25,17 +27,17 @@ const ListItem = props => {
25
27
 
26
28
  const content = _react.default.createElement("div", {
27
29
  className: `${classPrefix}-content`
28
- }, props.prefix && _react.default.createElement("div", {
30
+ }, (0, _isNodeWithContent.isNodeWithContent)(props.prefix) && _react.default.createElement("div", {
29
31
  className: `${classPrefix}-content-prefix`
30
32
  }, props.prefix), _react.default.createElement("div", {
31
33
  className: `${classPrefix}-content-main`
32
- }, props.title && _react.default.createElement("div", {
34
+ }, (0, _isNodeWithContent.isNodeWithContent)(props.title) && _react.default.createElement("div", {
33
35
  className: `${classPrefix}-title`
34
- }, props.title), props.children, props.description && _react.default.createElement("div", {
36
+ }, props.title), props.children, (0, _isNodeWithContent.isNodeWithContent)(props.description) && _react.default.createElement("div", {
35
37
  className: `${classPrefix}-description`
36
- }, props.description)), props.extra && _react.default.createElement("div", {
38
+ }, props.description)), (0, _isNodeWithContent.isNodeWithContent)(props.extra) && _react.default.createElement("div", {
37
39
  className: `${classPrefix}-content-extra`
38
- }, props.extra), arrow && _react.default.createElement("div", {
40
+ }, props.extra), (0, _isNodeWithContent.isNodeWithContent)(arrow) && _react.default.createElement("div", {
39
41
  className: `${classPrefix}-content-arrow`
40
42
  }, arrow === true ? _react.default.createElement(_antdMobileIcons.RightOutline, null) : arrow));
41
43
 
@@ -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", {