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
@@ -1,5 +1,5 @@
1
1
  import { __rest, __awaiter } from "tslib";
2
- import React$1, { useContext, useRef, useEffect, useMemo, useState, memo, forwardRef, useImperativeHandle, useCallback, createContext, cloneElement, createRef } from "react";
2
+ import React$1, { useContext, useRef, useEffect, useMemo, useState, memo, forwardRef, useImperativeHandle, useCallback, createContext, cloneElement, useLayoutEffect, createRef } from "react";
3
3
  import classNames from "classnames";
4
4
  import { useUnmountedRef, useUpdate, useMemoizedFn, useUpdateEffect, useIsomorphicLayoutEffect, createUpdateEffect, useThrottleFn, useDebounceEffect, useMount, useInViewport, useClickAway, useUnmount, useLockFn, useTimeout } from "ahooks";
5
5
  import { useSpring, animated, to } from "@react-spring/web";
@@ -8,7 +8,7 @@ import { isFragment } from "react-is";
8
8
  import { useDrag, useWheel, createUseGesture, dragAction, pinchAction } from "@use-gesture/react";
9
9
  import { RightOutline, CheckOutline, DownOutline, PictureOutline, PictureWrongOutline, DownFill, QuestionCircleOutline, CloseOutline, AddOutline, CloseCircleFill, LeftOutline, SoundOutline, TextDeletionOutline, StarFill, CheckCircleFill, InformationCircleFill, ClockCircleFill, ExclamationCircleFill, SearchOutline, MinusOutline } from "antd-mobile-icons";
10
10
  import { staged } from "staged-components";
11
- import RcForm, { List as List$2, Field, useForm } from "rc-field-form";
11
+ import RcForm, { List as List$2, Field, useForm, useWatch } from "rc-field-form";
12
12
  import { computePosition, offset, shift, limitShift, flip, hide, arrow, autoUpdate } from "@floating-ui/dom";
13
13
  import Big from "big.js";
14
14
  var global$1 = "";
@@ -1313,7 +1313,8 @@ const base = {
1313
1313
  }
1314
1314
  },
1315
1315
  ImageUploader: {
1316
- uploading: "Uploading..."
1316
+ uploading: "Uploading...",
1317
+ upload: "Upload"
1317
1318
  },
1318
1319
  InfiniteScroll: {
1319
1320
  noMore: "No more"
@@ -1418,7 +1419,8 @@ const zhCN = mergeLocale(base, {
1418
1419
  }
1419
1420
  },
1420
1421
  ImageUploader: {
1421
- uploading: "\u4E0A\u4F20\u4E2D..."
1422
+ uploading: "\u4E0A\u4F20\u4E2D...",
1423
+ upload: "\u4E0A\u4F20"
1422
1424
  },
1423
1425
  InfiniteScroll: {
1424
1426
  noMore: "\u6CA1\u6709\u66F4\u591A\u4E86"
@@ -8435,29 +8437,52 @@ const DotLoading = memo((p) => {
8435
8437
  keyTimes: "0; 0.1; 0.3; 0.4; 1"
8436
8438
  }))))))))));
8437
8439
  });
8440
+ function isPromise(obj) {
8441
+ return !!obj && typeof obj === "object" && typeof obj.then === "function";
8442
+ }
8438
8443
  const classPrefix$1d = `adm-button`;
8439
8444
  const defaultProps$W = {
8440
8445
  color: "default",
8441
8446
  fill: "solid",
8442
8447
  block: false,
8443
8448
  loading: false,
8449
+ loadingIcon: React$1.createElement(DotLoading, {
8450
+ color: "currentColor"
8451
+ }),
8444
8452
  type: "button",
8445
8453
  shape: "default",
8446
8454
  size: "middle"
8447
8455
  };
8448
8456
  const Button = forwardRef((p, ref) => {
8449
8457
  const props = mergeProps(defaultProps$W, p);
8450
- const disabled = props.disabled || props.loading;
8458
+ const [innerLoading, setInnerLoading] = useState(false);
8451
8459
  const nativeButtonRef = useRef(null);
8460
+ const loading = props.loading === "auto" ? innerLoading : props.loading;
8461
+ const disabled = props.disabled || loading;
8452
8462
  useImperativeHandle(ref, () => ({
8453
8463
  get nativeElement() {
8454
8464
  return nativeButtonRef.current;
8455
8465
  }
8456
8466
  }));
8467
+ const handleClick = (e) => __awaiter(void 0, void 0, void 0, function* () {
8468
+ if (!props.onClick)
8469
+ return;
8470
+ const promise = props.onClick(e);
8471
+ if (isPromise(promise)) {
8472
+ try {
8473
+ setInnerLoading(true);
8474
+ yield promise;
8475
+ setInnerLoading(false);
8476
+ } catch (e2) {
8477
+ setInnerLoading(false);
8478
+ throw e2;
8479
+ }
8480
+ }
8481
+ });
8457
8482
  return withNativeProps(props, React$1.createElement("button", {
8458
8483
  ref: nativeButtonRef,
8459
8484
  type: props.type,
8460
- onClick: props.onClick,
8485
+ onClick: handleClick,
8461
8486
  className: classNames(classPrefix$1d, props.color ? `${classPrefix$1d}-${props.color}` : null, {
8462
8487
  [`${classPrefix$1d}-block`]: props.block,
8463
8488
  [`${classPrefix$1d}-disabled`]: disabled,
@@ -8466,14 +8491,12 @@ const Button = forwardRef((p, ref) => {
8466
8491
  [`${classPrefix$1d}-mini`]: props.size === "mini",
8467
8492
  [`${classPrefix$1d}-small`]: props.size === "small",
8468
8493
  [`${classPrefix$1d}-large`]: props.size === "large",
8469
- [`${classPrefix$1d}-loading`]: props.loading
8494
+ [`${classPrefix$1d}-loading`]: loading
8470
8495
  }, `${classPrefix$1d}-shape-${props.shape}`),
8471
8496
  disabled
8472
- }, props.loading ? React$1.createElement("div", {
8497
+ }, loading ? React$1.createElement("div", {
8473
8498
  className: `${classPrefix$1d}-loading-wrapper`
8474
- }, React$1.createElement(DotLoading, {
8475
- color: "currentColor"
8476
- }), props.loadingText) : props.children));
8499
+ }, props.loadingIcon, props.loadingText) : props.children));
8477
8500
  });
8478
8501
  var safeArea = "";
8479
8502
  const classPrefix$1c = "adm-safe-area";
@@ -8904,6 +8927,8 @@ const Calendar = forwardRef((p, ref) => {
8904
8927
  setCurrent(current.add(1, "year"));
8905
8928
  }
8906
8929
  }, React$1.createElement(ArrowLeftDouble, null)));
8930
+ const maxDay = useMemo(() => props.max && dayjs(props.max), [props.max]);
8931
+ const minDay = useMemo(() => props.min && dayjs(props.min), [props.min]);
8907
8932
  function renderCells() {
8908
8933
  var _a;
8909
8934
  const cells = [];
@@ -8923,9 +8948,10 @@ const Calendar = forwardRef((p, ref) => {
8923
8948
  isSelect = isBegin || isEnd || d.isAfter(begin, "day") && d.isBefore(end, "day");
8924
8949
  }
8925
8950
  const inThisMonth = d.month() === current.month();
8951
+ const disabled = !inThisMonth || maxDay && d.isAfter(maxDay, "day") || minDay && d.isBefore(minDay, "day");
8926
8952
  cells.push(React$1.createElement("div", {
8927
8953
  key: d.valueOf(),
8928
- className: classNames(`${classPrefix$17}-cell`, inThisMonth ? `${classPrefix$17}-cell-in` : `${classPrefix$17}-cell-out`, inThisMonth && {
8954
+ className: classNames(`${classPrefix$17}-cell`, disabled && `${classPrefix$17}-cell-disabled`, inThisMonth && {
8929
8955
  [`${classPrefix$17}-cell-today`]: d.isSame(today, "day"),
8930
8956
  [`${classPrefix$17}-cell-selected`]: isSelect,
8931
8957
  [`${classPrefix$17}-cell-selected-begin`]: isBegin,
@@ -8934,6 +8960,8 @@ const Calendar = forwardRef((p, ref) => {
8934
8960
  onClick: () => {
8935
8961
  if (!props.selectionMode)
8936
8962
  return;
8963
+ if (disabled)
8964
+ return;
8937
8965
  const date = d.toDate();
8938
8966
  if (!inThisMonth) {
8939
8967
  setCurrent(d.clone().date(1));
@@ -9980,62 +10008,52 @@ function prompt$3(props) {
9980
10008
  var Picker = attachPropertiesToComponent(Picker$1, {
9981
10009
  prompt: prompt$3
9982
10010
  });
9983
- function useCascadePickerOptions(options) {
9984
- return useMemo(() => {
9985
- let depth = 1;
9986
- const subOptionsRecord = {};
9987
- function traverse(option, currentDepth) {
9988
- if (!option.children) {
9989
- return;
9990
- }
9991
- subOptionsRecord[option.value] = option.children;
10011
+ function useColumnsFn(options) {
10012
+ const depth = useMemo(() => {
10013
+ let depth2 = 0;
10014
+ function traverse(options2, currentDepth) {
10015
+ if (currentDepth > depth2)
10016
+ depth2 = currentDepth;
9992
10017
  const nextDepth = currentDepth + 1;
9993
- if (nextDepth > depth) {
9994
- depth = nextDepth;
9995
- }
9996
- option.children.forEach((option2) => {
9997
- traverse(option2, nextDepth);
10018
+ options2.forEach((option) => {
10019
+ if (option.children) {
10020
+ traverse(option.children, nextDepth);
10021
+ }
9998
10022
  });
9999
10023
  }
10000
- options.forEach((option) => {
10001
- traverse(option, 1);
10002
- });
10003
- return {
10004
- depth,
10005
- subOptionsRecord
10006
- };
10024
+ traverse(options, 1);
10025
+ return depth2;
10007
10026
  }, [options]);
10008
- }
10009
- function generateCascadePickerColumns(value, options, depth, subOptionsRecord) {
10010
- const columns = [];
10011
- columns.push(options.map((option) => ({
10012
- label: option.label,
10013
- value: option.value
10014
- })));
10015
- for (let i = 0; i < depth - 1; i++) {
10016
- const x = value[i];
10017
- const subOptions = subOptionsRecord[x];
10018
- if (!subOptions) {
10019
- columns.push([]);
10020
- } else {
10021
- columns.push(subOptions.map((option) => ({
10027
+ return (selected) => {
10028
+ const columns = [];
10029
+ let currentOptions = options;
10030
+ let i = 0;
10031
+ while (true) {
10032
+ columns.push(currentOptions.map((option) => ({
10022
10033
  label: option.label,
10023
10034
  value: option.value
10024
10035
  })));
10036
+ const x = selected[i];
10037
+ const targetOptions = currentOptions.find((option) => option.value === x);
10038
+ if (!targetOptions || !targetOptions.children)
10039
+ break;
10040
+ currentOptions = targetOptions.children;
10041
+ i++;
10025
10042
  }
10026
- }
10027
- return columns;
10043
+ while (i < depth - 1) {
10044
+ columns.push([]);
10045
+ i++;
10046
+ }
10047
+ return columns;
10048
+ };
10028
10049
  }
10029
10050
  const CascadePicker = (props) => {
10030
10051
  const {
10031
10052
  options
10032
10053
  } = props, pickerProps = __rest(props, ["options"]);
10033
- const {
10034
- depth,
10035
- subOptionsRecord
10036
- } = useCascadePickerOptions(options);
10054
+ const columnsFn = useColumnsFn(options);
10037
10055
  return React$1.createElement(Picker, Object.assign({}, pickerProps, {
10038
- columns: (selected) => generateCascadePickerColumns(selected, options, depth, subOptionsRecord)
10056
+ columns: columnsFn
10039
10057
  }));
10040
10058
  };
10041
10059
  function prompt$2(props) {
@@ -10075,12 +10093,9 @@ const CascadePickerView = (props) => {
10075
10093
  const {
10076
10094
  options
10077
10095
  } = props, pickerProps = __rest(props, ["options"]);
10078
- const {
10079
- depth,
10080
- subOptionsRecord
10081
- } = useCascadePickerOptions(options);
10096
+ const columnsFn = useColumnsFn(options);
10082
10097
  return React$1.createElement(PickerView, Object.assign({}, pickerProps, {
10083
- columns: (selected) => generateCascadePickerColumns(selected, options, depth, subOptionsRecord)
10098
+ columns: columnsFn
10084
10099
  }));
10085
10100
  };
10086
10101
  var cascaderView = "";
@@ -10331,6 +10346,9 @@ const List$1 = (p) => {
10331
10346
  className: `${classPrefix$$}-body-inner`
10332
10347
  }, props.children))));
10333
10348
  };
10349
+ function isNodeWithContent(node) {
10350
+ return node !== void 0 && node !== null && node !== false;
10351
+ }
10334
10352
  const classPrefix$_ = `adm-list-item`;
10335
10353
  const ListItem = (props) => {
10336
10354
  var _a;
@@ -10338,17 +10356,17 @@ const ListItem = (props) => {
10338
10356
  const arrow2 = props.arrow === void 0 ? clickable : props.arrow;
10339
10357
  const content = React$1.createElement("div", {
10340
10358
  className: `${classPrefix$_}-content`
10341
- }, props.prefix && React$1.createElement("div", {
10359
+ }, isNodeWithContent(props.prefix) && React$1.createElement("div", {
10342
10360
  className: `${classPrefix$_}-content-prefix`
10343
10361
  }, props.prefix), React$1.createElement("div", {
10344
10362
  className: `${classPrefix$_}-content-main`
10345
- }, props.title && React$1.createElement("div", {
10363
+ }, isNodeWithContent(props.title) && React$1.createElement("div", {
10346
10364
  className: `${classPrefix$_}-title`
10347
- }, props.title), props.children, props.description && React$1.createElement("div", {
10365
+ }, props.title), props.children, isNodeWithContent(props.description) && React$1.createElement("div", {
10348
10366
  className: `${classPrefix$_}-description`
10349
- }, props.description)), props.extra && React$1.createElement("div", {
10367
+ }, props.description)), isNodeWithContent(props.extra) && React$1.createElement("div", {
10350
10368
  className: `${classPrefix$_}-content-extra`
10351
- }, props.extra), arrow2 && React$1.createElement("div", {
10369
+ }, props.extra), isNodeWithContent(arrow2) && React$1.createElement("div", {
10352
10370
  className: `${classPrefix$_}-content-arrow`
10353
10371
  }, arrow2 === true ? React$1.createElement(RightOutline, null) : arrow2));
10354
10372
  return withNativeProps(props, React$1.createElement(clickable ? "a" : "div", {
@@ -11391,6 +11409,7 @@ const DatePicker = (p) => {
11391
11409
  value: pickerValue,
11392
11410
  onCancel: props.onCancel,
11393
11411
  onClose: props.onClose,
11412
+ closeOnMaskClick: props.closeOnMaskClick,
11394
11413
  visible: props.visible,
11395
11414
  confirmText: props.confirmText,
11396
11415
  cancelText: props.cancelText,
@@ -11476,23 +11495,9 @@ const DialogActionButton = (props) => {
11476
11495
  const {
11477
11496
  action
11478
11497
  } = props;
11479
- const [loading, setLoading] = useState(false);
11480
- function handleClick() {
11481
- return __awaiter(this, void 0, void 0, function* () {
11482
- setLoading(true);
11483
- try {
11484
- const promise = props.onAction();
11485
- yield promise;
11486
- setLoading(false);
11487
- } catch (e) {
11488
- setLoading(false);
11489
- throw e;
11490
- }
11491
- });
11492
- }
11493
11498
  return withNativeProps(props.action, React$1.createElement(Button, {
11494
11499
  key: action.key,
11495
- onClick: handleClick,
11500
+ onClick: props.onAction,
11496
11501
  className: classNames("adm-dialog-button", {
11497
11502
  "adm-dialog-button-bold": action.bold
11498
11503
  }),
@@ -11500,7 +11505,7 @@ const DialogActionButton = (props) => {
11500
11505
  shape: "rectangular",
11501
11506
  block: true,
11502
11507
  color: action.danger ? "danger" : "primary",
11503
- loading,
11508
+ loading: "auto",
11504
11509
  disabled: action.disabled
11505
11510
  }, action.text));
11506
11511
  };
@@ -12773,7 +12778,7 @@ const FloatingPanel = forwardRef((p, ref) => {
12773
12778
  tension: 300
12774
12779
  },
12775
12780
  onChange: (result2) => {
12776
- onHeightChange(result2.value.y, y2.isAnimating);
12781
+ onHeightChange(-result2.value.y, y2.isAnimating);
12777
12782
  }
12778
12783
  }));
12779
12784
  useDrag((state) => {
@@ -12867,7 +12872,8 @@ const defaultFormContext = {
12867
12872
  name: void 0,
12868
12873
  hasFeedback: true,
12869
12874
  layout: "vertical",
12870
- requiredMarkStyle: "asterisk"
12875
+ requiredMarkStyle: "asterisk",
12876
+ disabled: false
12871
12877
  };
12872
12878
  const FormContext = React$1.createContext(defaultFormContext);
12873
12879
  const NoStyleItemContext = React$1.createContext(null);
@@ -12916,8 +12922,9 @@ const Form$1 = forwardRef((p, ref) => {
12916
12922
  layout,
12917
12923
  footer,
12918
12924
  mode,
12925
+ disabled,
12919
12926
  requiredMarkStyle
12920
- } = props, formProps = __rest(props, ["className", "style", "hasFeedback", "children", "layout", "footer", "mode", "requiredMarkStyle"]);
12927
+ } = props, formProps = __rest(props, ["className", "style", "hasFeedback", "children", "layout", "footer", "mode", "disabled", "requiredMarkStyle"]);
12921
12928
  const {
12922
12929
  locale
12923
12930
  } = useConfig();
@@ -12964,7 +12971,8 @@ const Form$1 = forwardRef((p, ref) => {
12964
12971
  name: formProps.name,
12965
12972
  hasFeedback,
12966
12973
  layout,
12967
- requiredMarkStyle
12974
+ requiredMarkStyle,
12975
+ disabled
12968
12976
  }
12969
12977
  }, lists), footer && React$1.createElement("div", {
12970
12978
  className: `${classPrefix$K}-footer`
@@ -13116,7 +13124,9 @@ var Context = /* @__PURE__ */ React.createContext({
13116
13124
  registerField: warningFunc,
13117
13125
  useSubscribe: warningFunc,
13118
13126
  setInitialValues: warningFunc,
13127
+ destroyForm: warningFunc,
13119
13128
  setCallbacks: warningFunc,
13129
+ registerWatch: warningFunc,
13120
13130
  getFields: warningFunc,
13121
13131
  setValidateMessages: warningFunc,
13122
13132
  setPreserve: warningFunc,
@@ -13391,6 +13401,7 @@ const MemoInput = React$1.memo(({
13391
13401
  children
13392
13402
  }) => children, (prev, next) => prev.value === next.value && prev.update === next.update);
13393
13403
  const FormItemLayout = (props) => {
13404
+ var _a;
13394
13405
  const {
13395
13406
  className,
13396
13407
  style,
@@ -13398,7 +13409,6 @@ const FormItemLayout = (props) => {
13398
13409
  label,
13399
13410
  help,
13400
13411
  required,
13401
- disabled,
13402
13412
  children,
13403
13413
  htmlFor,
13404
13414
  hidden,
@@ -13411,6 +13421,7 @@ const FormItemLayout = (props) => {
13411
13421
  } = useConfig();
13412
13422
  const hasFeedback = props.hasFeedback !== void 0 ? props.hasFeedback : context.hasFeedback;
13413
13423
  const layout = props.layout || context.layout;
13424
+ const disabled = (_a = props.disabled) !== null && _a !== void 0 ? _a : context.disabled;
13414
13425
  const requiredMark = (() => {
13415
13426
  const {
13416
13427
  requiredMarkStyle
@@ -13647,7 +13658,8 @@ var Form = attachPropertiesToComponent(Form$1, {
13647
13658
  Subscribe: FormSubscribe,
13648
13659
  Header,
13649
13660
  Array: FormArray,
13650
- useForm
13661
+ useForm,
13662
+ useWatch
13651
13663
  });
13652
13664
  var grid = "";
13653
13665
  const classPrefix$G = `adm-grid`;
@@ -14149,6 +14161,9 @@ const defaultProps$t = {
14149
14161
  imageFit: "cover"
14150
14162
  };
14151
14163
  const ImageUploader = (p) => {
14164
+ const {
14165
+ locale
14166
+ } = useConfig();
14152
14167
  const props = mergeProps(defaultProps$t, p);
14153
14168
  const [value, setValue] = usePropsValue(props);
14154
14169
  const updateValue = useMemoizedFn((updater) => {
@@ -14305,7 +14320,8 @@ const ImageUploader = (p) => {
14305
14320
  className: `${classPrefix$z}-upload-button-wrap`
14306
14321
  }, props.children ? props.children : React$1.createElement("span", {
14307
14322
  className: `${classPrefix$z}-cell ${classPrefix$z}-upload-button`,
14308
- role: "button"
14323
+ role: "button",
14324
+ "aria-label": locale.ImageUploader.upload
14309
14325
  }, React$1.createElement("span", {
14310
14326
  className: `${classPrefix$z}-upload-button-icon`
14311
14327
  }, React$1.createElement(AddOutline, null))), !props.disableUpload && React$1.createElement("input", {
@@ -14314,7 +14330,8 @@ const ImageUploader = (p) => {
14314
14330
  multiple: props.multiple,
14315
14331
  type: "file",
14316
14332
  className: `${classPrefix$z}-input`,
14317
- onChange
14333
+ onChange,
14334
+ "aria-hidden": true
14318
14335
  })))));
14319
14336
  };
14320
14337
  var imageUploader = "";
@@ -14553,7 +14570,8 @@ const InfiniteScroll = (p) => {
14553
14570
  var input = "";
14554
14571
  const classPrefix$v = `adm-input`;
14555
14572
  const defaultProps$r = {
14556
- defaultValue: ""
14573
+ defaultValue: "",
14574
+ onlyShowClearWhenFocus: true
14557
14575
  };
14558
14576
  const Input = forwardRef((p, ref) => {
14559
14577
  const props = mergeProps(defaultProps$r, p);
@@ -14602,6 +14620,15 @@ const Input = forwardRef((p, ref) => {
14602
14620
  setValue(nextValue);
14603
14621
  }
14604
14622
  }
14623
+ const shouldShowClear = (() => {
14624
+ if (!props.clearable || !value || props.readOnly)
14625
+ return false;
14626
+ if (props.onlyShowClearWhenFocus) {
14627
+ return hasFocus;
14628
+ } else {
14629
+ return true;
14630
+ }
14631
+ })();
14605
14632
  return withNativeProps(props, React$1.createElement("div", {
14606
14633
  className: classNames(`${classPrefix$v}`, props.disabled && `${classPrefix$v}-disabled`)
14607
14634
  }, React$1.createElement("input", {
@@ -14642,7 +14669,7 @@ const Input = forwardRef((p, ref) => {
14642
14669
  onCompositionStart: props.onCompositionStart,
14643
14670
  onCompositionEnd: props.onCompositionEnd,
14644
14671
  onClick: props.onClick
14645
- }), props.clearable && !!value && !props.readOnly && hasFocus && React$1.createElement("div", {
14672
+ }), shouldShowClear && React$1.createElement("div", {
14646
14673
  className: `${classPrefix$v}-clear`,
14647
14674
  onMouseDown: (e) => {
14648
14675
  e.preventDefault();
@@ -14755,23 +14782,9 @@ const ModalActionButton = (props) => {
14755
14782
  const {
14756
14783
  action
14757
14784
  } = props;
14758
- const [loading, setLoading] = useState(false);
14759
- function handleClick() {
14760
- return __awaiter(this, void 0, void 0, function* () {
14761
- setLoading(true);
14762
- try {
14763
- const promise = props.onAction();
14764
- yield promise;
14765
- setLoading(false);
14766
- } catch (e) {
14767
- setLoading(false);
14768
- throw e;
14769
- }
14770
- });
14771
- }
14772
14785
  return withNativeProps(props.action, React$1.createElement(Button, {
14773
14786
  key: action.key,
14774
- onClick: handleClick,
14787
+ onClick: props.onAction,
14775
14788
  className: classNames("adm-modal-button", {
14776
14789
  "adm-modal-button-primary": props.action.primary
14777
14790
  }),
@@ -14779,7 +14792,7 @@ const ModalActionButton = (props) => {
14779
14792
  size: props.action.primary ? "large" : "middle",
14780
14793
  block: true,
14781
14794
  color: action.danger ? "danger" : "primary",
14782
- loading,
14795
+ loading: "auto",
14783
14796
  disabled: action.disabled
14784
14797
  }, action.text));
14785
14798
  };
@@ -15756,6 +15769,7 @@ var searchBar = "";
15756
15769
  const classPrefix$i = `adm-search-bar`;
15757
15770
  const defaultProps$f = {
15758
15771
  clearable: true,
15772
+ onlyShowClearWhenFocus: false,
15759
15773
  showCancelButton: false,
15760
15774
  defaultValue: "",
15761
15775
  clearOnCancel: true,
@@ -15835,6 +15849,7 @@ const SearchBar = forwardRef((p, ref) => {
15835
15849
  maxLength: props.maxLength,
15836
15850
  placeholder: props.placeholder,
15837
15851
  clearable: props.clearable,
15852
+ onlyShowClearWhenFocus: props.onlyShowClearWhenFocus,
15838
15853
  onFocus: (e) => {
15839
15854
  var _a;
15840
15855
  setHasFocus(true);
@@ -17174,7 +17189,7 @@ const TextArea = forwardRef((p, ref) => {
17174
17189
  (_a = nativeTextAreaRef.current) === null || _a === void 0 ? void 0 : _a.blur();
17175
17190
  }
17176
17191
  }));
17177
- useEffect(() => {
17192
+ useLayoutEffect(() => {
17178
17193
  if (!autoSize)
17179
17194
  return;
17180
17195
  const textArea2 = nativeTextAreaRef.current;
@@ -17810,7 +17825,8 @@ const VirtualInput = forwardRef((p, ref) => {
17810
17825
  var _a, _b, _c;
17811
17826
  (_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.blur();
17812
17827
  (_c = (_b = keyboard.props).onClose) === null || _c === void 0 ? void 0 : _c.call(_b);
17813
- }
17828
+ },
17829
+ getContainer: null
17814
17830
  });
17815
17831
  return withNativeProps(props, React$1.createElement("div", {
17816
17832
  ref: rootRef,
package/bundle/style.css CHANGED
@@ -398,10 +398,10 @@ div.adm-px-tester {
398
398
  .adm-calendar-cell.adm-calendar-cell-today {
399
399
  color: var(--adm-color-primary);
400
400
  }
401
- .adm-calendar-cell.adm-calendar-cell-out {
401
+ .adm-calendar-cell.adm-calendar-cell-disabled {
402
402
  color: var(--adm-color-light);
403
403
  }
404
- .adm-calendar-cell.adm-calendar-cell-out .adm-calendar-cell-bottom {
404
+ .adm-calendar-cell.adm-calendar-cell-disabled .adm-calendar-cell-bottom {
405
405
  color: var(--adm-color-light);
406
406
  }
407
407
  .adm-calendar-cell.adm-calendar-cell-selected.adm-calendar-cell.adm-calendar-cell-selected {
@@ -1553,7 +1553,7 @@ a.adm-list-item:active:not(.adm-list-item-disabled)::after {
1553
1553
  }
1554
1554
  .adm-form-item.adm-form-item-horizontal.adm-list-item {
1555
1555
  --align-items: stretch;
1556
- --prefix-width: 6em;
1556
+ --prefix-width: 6.8em;
1557
1557
  }
1558
1558
  .adm-form-item.adm-form-item-horizontal .adm-list-item-content-prefix {
1559
1559
  padding-top: 12px;
@@ -2085,6 +2085,9 @@ a.adm-list-item:active:not(.adm-list-item-disabled)::after {
2085
2085
  .adm-input-element::-webkit-search-decoration {
2086
2086
  display: none;
2087
2087
  }
2088
+ .adm-input-element:disabled {
2089
+ opacity: 1;
2090
+ }
2088
2091
  .adm-input-element[type='date'],
2089
2092
  .adm-input-element[type='time'],
2090
2093
  .adm-input-element[type='datetime-local'] {
@@ -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;
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.Button = void 0;
7
7
 
8
+ var _tslib = require("tslib");
9
+
8
10
  var _react = _interopRequireWildcard(require("react"));
9
11
 
10
12
  var _classnames = _interopRequireDefault(require("classnames"));
@@ -15,6 +17,8 @@ var _withDefaultProps = require("../../utils/with-default-props");
15
17
 
16
18
  var _nativeProps = require("../../utils/native-props");
17
19
 
20
+ var _validate = require("../../utils/validate");
21
+
18
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
23
 
20
24
  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); }
@@ -27,24 +31,46 @@ const defaultProps = {
27
31
  fill: 'solid',
28
32
  block: false,
29
33
  loading: false,
34
+ loadingIcon: _react.default.createElement(_dotLoading.default, {
35
+ color: 'currentColor'
36
+ }),
30
37
  type: 'button',
31
38
  shape: 'default',
32
39
  size: 'middle'
33
40
  };
34
41
  const Button = (0, _react.forwardRef)((p, ref) => {
35
42
  const props = (0, _withDefaultProps.mergeProps)(defaultProps, p);
36
- const disabled = props.disabled || props.loading;
43
+ const [innerLoading, setInnerLoading] = (0, _react.useState)(false);
37
44
  const nativeButtonRef = (0, _react.useRef)(null);
45
+ const loading = props.loading === 'auto' ? innerLoading : props.loading;
46
+ const disabled = props.disabled || loading;
38
47
  (0, _react.useImperativeHandle)(ref, () => ({
39
48
  get nativeElement() {
40
49
  return nativeButtonRef.current;
41
50
  }
42
51
 
43
52
  }));
53
+
54
+ const handleClick = e => (0, _tslib.__awaiter)(void 0, void 0, void 0, function* () {
55
+ if (!props.onClick) return;
56
+ const promise = props.onClick(e);
57
+
58
+ if ((0, _validate.isPromise)(promise)) {
59
+ try {
60
+ setInnerLoading(true);
61
+ yield promise;
62
+ setInnerLoading(false);
63
+ } catch (e) {
64
+ setInnerLoading(false);
65
+ throw e;
66
+ }
67
+ }
68
+ });
69
+
44
70
  return (0, _nativeProps.withNativeProps)(props, _react.default.createElement("button", {
45
71
  ref: nativeButtonRef,
46
72
  type: props.type,
47
- onClick: props.onClick,
73
+ onClick: handleClick,
48
74
  className: (0, _classnames.default)(classPrefix, props.color ? `${classPrefix}-${props.color}` : null, {
49
75
  [`${classPrefix}-block`]: props.block,
50
76
  [`${classPrefix}-disabled`]: disabled,
@@ -53,13 +79,11 @@ const Button = (0, _react.forwardRef)((p, ref) => {
53
79
  [`${classPrefix}-mini`]: props.size === 'mini',
54
80
  [`${classPrefix}-small`]: props.size === 'small',
55
81
  [`${classPrefix}-large`]: props.size === 'large',
56
- [`${classPrefix}-loading`]: props.loading
82
+ [`${classPrefix}-loading`]: loading
57
83
  }, `${classPrefix}-shape-${props.shape}`),
58
84
  disabled: disabled
59
- }, props.loading ? _react.default.createElement("div", {
85
+ }, loading ? _react.default.createElement("div", {
60
86
  className: `${classPrefix}-loading-wrapper`
61
- }, _react.default.createElement(_dotLoading.default, {
62
- color: 'currentColor'
63
- }), props.loadingText) : props.children));
87
+ }, props.loadingIcon, props.loadingText) : props.children));
64
88
  });
65
89
  exports.Button = Button;