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.
- package/2x/cjs/components/button/button.d.ts +6 -4
- package/2x/cjs/components/button/button.js +31 -7
- package/2x/cjs/components/calendar/calendar.css +2 -2
- package/2x/cjs/components/calendar/calendar.d.ts +2 -0
- package/2x/cjs/components/calendar/calendar.js +6 -1
- package/2x/cjs/components/cascade-picker/cascade-picker-utils.d.ts +2 -2
- package/2x/cjs/components/cascade-picker/cascade-picker-utils.js +37 -16
- package/2x/cjs/components/cascade-picker/cascade-picker.js +2 -7
- package/2x/cjs/components/cascade-picker-view/cascade-picker-view.js +2 -7
- package/2x/cjs/components/date-picker/date-picker.js +1 -0
- package/2x/cjs/components/dialog/dialog-action-button.js +3 -26
- package/2x/cjs/components/floating-panel/floating-panel.js +1 -1
- package/2x/cjs/components/form/context.d.ts +1 -0
- package/2x/cjs/components/form/context.js +2 -1
- package/2x/cjs/components/form/form-item.css +1 -1
- package/2x/cjs/components/form/form-item.js +3 -1
- package/2x/cjs/components/form/form.d.ts +0 -3
- package/2x/cjs/components/form/form.js +4 -2
- package/2x/cjs/components/form/index.css +1 -1
- package/2x/cjs/components/form/index.d.ts +2 -2
- package/2x/cjs/components/form/index.js +2 -1
- package/2x/cjs/components/image-uploader/image-uploader.js +9 -2
- package/2x/cjs/components/index-bar/panel.d.ts +1 -0
- package/2x/cjs/components/input/input.css +4 -0
- package/2x/cjs/components/input/input.d.ts +2 -0
- package/2x/cjs/components/input/input.js +13 -2
- package/2x/cjs/components/list/list-item.js +7 -5
- package/2x/cjs/components/modal/modal-action-button.js +3 -26
- package/2x/cjs/components/search-bar/search-bar.d.ts +2 -0
- package/2x/cjs/components/search-bar/search-bar.js +2 -0
- package/2x/cjs/components/text-area/text-area.js +1 -1
- package/2x/cjs/components/virtual-input/virtual-input.js +2 -1
- package/2x/cjs/global/index.js +2 -0
- package/2x/cjs/locales/base.d.ts +1 -0
- package/2x/cjs/locales/base.js +2 -1
- package/2x/cjs/locales/en-US.d.ts +1 -0
- package/2x/cjs/locales/es-ES.d.ts +1 -0
- package/2x/cjs/locales/fa-IR.d.ts +1 -0
- package/2x/cjs/locales/ko-KR.d.ts +1 -0
- package/2x/cjs/locales/zh-CN.d.ts +1 -0
- package/2x/cjs/locales/zh-CN.js +2 -1
- package/2x/cjs/locales/zh-HK.d.ts +1 -0
- package/2x/cjs/locales/zh-TW.d.ts +1 -0
- package/2x/cjs/utils/is-node-with-content.d.ts +4 -0
- package/2x/cjs/utils/is-node-with-content.js +10 -0
- package/2x/es/components/button/button.d.ts +6 -4
- package/2x/es/components/button/button.js +30 -8
- package/2x/es/components/calendar/calendar.css +2 -2
- package/2x/es/components/calendar/calendar.d.ts +2 -0
- package/2x/es/components/calendar/calendar.js +6 -2
- package/2x/es/components/cascade-picker/cascade-picker-utils.d.ts +2 -2
- package/2x/es/components/cascade-picker/cascade-picker-utils.js +35 -15
- package/2x/es/components/cascade-picker/cascade-picker.js +3 -7
- package/2x/es/components/cascade-picker-view/cascade-picker-view.js +3 -7
- package/2x/es/components/date-picker/date-picker.js +1 -0
- package/2x/es/components/dialog/dialog-action-button.js +3 -21
- package/2x/es/components/floating-panel/floating-panel.js +1 -1
- package/2x/es/components/form/context.d.ts +1 -0
- package/2x/es/components/form/context.js +2 -1
- package/2x/es/components/form/form-item.css +1 -1
- package/2x/es/components/form/form-item.js +3 -1
- package/2x/es/components/form/form.d.ts +0 -3
- package/2x/es/components/form/form.js +4 -2
- package/2x/es/components/form/index.css +1 -1
- package/2x/es/components/form/index.d.ts +2 -2
- package/2x/es/components/form/index.js +3 -2
- package/2x/es/components/image-uploader/image-uploader.js +8 -2
- package/2x/es/components/index-bar/panel.d.ts +1 -0
- package/2x/es/components/input/input.css +4 -0
- package/2x/es/components/input/input.d.ts +2 -0
- package/2x/es/components/input/input.js +13 -2
- package/2x/es/components/list/list-item.js +6 -5
- package/2x/es/components/modal/modal-action-button.js +3 -21
- package/2x/es/components/search-bar/search-bar.d.ts +2 -0
- package/2x/es/components/search-bar/search-bar.js +2 -0
- package/2x/es/components/text-area/text-area.js +2 -2
- package/2x/es/components/virtual-input/virtual-input.js +2 -1
- package/2x/es/global/index.js +2 -0
- package/2x/es/locales/base.d.ts +1 -0
- package/2x/es/locales/base.js +2 -1
- package/2x/es/locales/en-US.d.ts +1 -0
- package/2x/es/locales/es-ES.d.ts +1 -0
- package/2x/es/locales/fa-IR.d.ts +1 -0
- package/2x/es/locales/ko-KR.d.ts +1 -0
- package/2x/es/locales/zh-CN.d.ts +1 -0
- package/2x/es/locales/zh-CN.js +2 -1
- package/2x/es/locales/zh-HK.d.ts +1 -0
- package/2x/es/locales/zh-TW.d.ts +1 -0
- package/2x/es/utils/is-node-with-content.d.ts +4 -0
- package/2x/es/utils/is-node-with-content.js +3 -0
- package/2x/package.json +2 -2
- package/bundle/antd-mobile.cjs.js +122 -106
- package/bundle/antd-mobile.es.js +124 -108
- package/bundle/style.css +6 -3
- package/cjs/components/button/button.d.ts +6 -4
- package/cjs/components/button/button.js +31 -7
- package/cjs/components/calendar/calendar.css +2 -2
- package/cjs/components/calendar/calendar.d.ts +2 -0
- package/cjs/components/calendar/calendar.js +6 -1
- package/cjs/components/cascade-picker/cascade-picker-utils.d.ts +2 -2
- package/cjs/components/cascade-picker/cascade-picker-utils.js +37 -16
- package/cjs/components/cascade-picker/cascade-picker.js +2 -7
- package/cjs/components/cascade-picker-view/cascade-picker-view.js +2 -7
- package/cjs/components/date-picker/date-picker.js +1 -0
- package/cjs/components/dialog/dialog-action-button.js +3 -26
- package/cjs/components/floating-panel/floating-panel.js +1 -1
- package/cjs/components/form/context.d.ts +1 -0
- package/cjs/components/form/context.js +2 -1
- package/cjs/components/form/form-item.css +1 -1
- package/cjs/components/form/form-item.js +3 -1
- package/cjs/components/form/form.d.ts +0 -3
- package/cjs/components/form/form.js +4 -2
- package/cjs/components/form/index.css +1 -1
- package/cjs/components/form/index.d.ts +2 -2
- package/cjs/components/form/index.js +2 -1
- package/cjs/components/image-uploader/image-uploader.js +9 -2
- package/cjs/components/index-bar/panel.d.ts +1 -0
- package/cjs/components/input/input.css +3 -0
- package/cjs/components/input/input.d.ts +2 -0
- package/cjs/components/input/input.js +13 -2
- package/cjs/components/list/list-item.js +7 -5
- package/cjs/components/modal/modal-action-button.js +3 -26
- package/cjs/components/search-bar/search-bar.d.ts +2 -0
- package/cjs/components/search-bar/search-bar.js +2 -0
- package/cjs/components/text-area/text-area.js +1 -1
- package/cjs/components/virtual-input/virtual-input.js +2 -1
- package/cjs/global/index.js +2 -0
- package/cjs/locales/base.d.ts +1 -0
- package/cjs/locales/base.js +2 -1
- package/cjs/locales/en-US.d.ts +1 -0
- package/cjs/locales/es-ES.d.ts +1 -0
- package/cjs/locales/fa-IR.d.ts +1 -0
- package/cjs/locales/ko-KR.d.ts +1 -0
- package/cjs/locales/zh-CN.d.ts +1 -0
- package/cjs/locales/zh-CN.js +2 -1
- package/cjs/locales/zh-HK.d.ts +1 -0
- package/cjs/locales/zh-TW.d.ts +1 -0
- package/cjs/utils/is-node-with-content.d.ts +4 -0
- package/cjs/utils/is-node-with-content.js +10 -0
- package/es/components/button/button.d.ts +6 -4
- package/es/components/button/button.js +30 -8
- package/es/components/calendar/calendar.css +2 -2
- package/es/components/calendar/calendar.d.ts +2 -0
- package/es/components/calendar/calendar.js +6 -2
- package/es/components/cascade-picker/cascade-picker-utils.d.ts +2 -2
- package/es/components/cascade-picker/cascade-picker-utils.js +35 -15
- package/es/components/cascade-picker/cascade-picker.js +3 -7
- package/es/components/cascade-picker-view/cascade-picker-view.js +3 -7
- package/es/components/date-picker/date-picker.js +1 -0
- package/es/components/dialog/dialog-action-button.js +3 -21
- package/es/components/floating-panel/floating-panel.js +1 -1
- package/es/components/form/context.d.ts +1 -0
- package/es/components/form/context.js +2 -1
- package/es/components/form/form-item.css +1 -1
- package/es/components/form/form-item.js +3 -1
- package/es/components/form/form.d.ts +0 -3
- package/es/components/form/form.js +4 -2
- package/es/components/form/index.css +1 -1
- package/es/components/form/index.d.ts +2 -2
- package/es/components/form/index.js +3 -2
- package/es/components/image-uploader/image-uploader.js +8 -2
- package/es/components/index-bar/panel.d.ts +1 -0
- package/es/components/input/input.css +3 -0
- package/es/components/input/input.d.ts +2 -0
- package/es/components/input/input.js +13 -2
- package/es/components/list/list-item.js +6 -5
- package/es/components/modal/modal-action-button.js +3 -21
- package/es/components/search-bar/search-bar.d.ts +2 -0
- package/es/components/search-bar/search-bar.js +2 -0
- package/es/components/text-area/text-area.js +2 -2
- package/es/components/virtual-input/virtual-input.js +2 -1
- package/es/global/index.js +2 -0
- package/es/locales/base.d.ts +1 -0
- package/es/locales/base.js +2 -1
- package/es/locales/en-US.d.ts +1 -0
- package/es/locales/es-ES.d.ts +1 -0
- package/es/locales/fa-IR.d.ts +1 -0
- package/es/locales/ko-KR.d.ts +1 -0
- package/es/locales/zh-CN.d.ts +1 -0
- package/es/locales/zh-CN.js +2 -1
- package/es/locales/zh-HK.d.ts +1 -0
- package/es/locales/zh-TW.d.ts +1 -0
- package/es/utils/is-node-with-content.d.ts +4 -0
- package/es/utils/is-node-with-content.js +3 -0
- package/package.json +2 -2
- package/umd/antd-mobile.js +1 -1
- package/2x/cjs/components/cascade-picker/use-cascade-picker-options.d.ts +0 -5
- package/2x/cjs/components/cascade-picker/use-cascade-picker-options.js +0 -40
- package/2x/es/components/cascade-picker/use-cascade-picker-options.d.ts +0 -5
- package/2x/es/components/cascade-picker/use-cascade-picker-options.js +0 -32
- package/cjs/components/cascade-picker/use-cascade-picker-options.d.ts +0 -5
- package/cjs/components/cascade-picker/use-cascade-picker-options.js +0 -40
- package/es/components/cascade-picker/use-cascade-picker-options.d.ts +0 -5
- package/es/components/cascade-picker/use-cascade-picker-options.js +0 -32
package/bundle/antd-mobile.es.js
CHANGED
|
@@ -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
|
|
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:
|
|
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`]:
|
|
8494
|
+
[`${classPrefix$1d}-loading`]: loading
|
|
8470
8495
|
}, `${classPrefix$1d}-shape-${props.shape}`),
|
|
8471
8496
|
disabled
|
|
8472
|
-
},
|
|
8497
|
+
}, loading ? React$1.createElement("div", {
|
|
8473
8498
|
className: `${classPrefix$1d}-loading-wrapper`
|
|
8474
|
-
},
|
|
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`,
|
|
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
|
|
9984
|
-
|
|
9985
|
-
let
|
|
9986
|
-
|
|
9987
|
-
|
|
9988
|
-
|
|
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
|
-
|
|
9994
|
-
|
|
9995
|
-
|
|
9996
|
-
|
|
9997
|
-
traverse(option2, nextDepth);
|
|
10018
|
+
options2.forEach((option) => {
|
|
10019
|
+
if (option.children) {
|
|
10020
|
+
traverse(option.children, nextDepth);
|
|
10021
|
+
}
|
|
9998
10022
|
});
|
|
9999
10023
|
}
|
|
10000
|
-
options
|
|
10001
|
-
|
|
10002
|
-
});
|
|
10003
|
-
return {
|
|
10004
|
-
depth,
|
|
10005
|
-
subOptionsRecord
|
|
10006
|
-
};
|
|
10024
|
+
traverse(options, 1);
|
|
10025
|
+
return depth2;
|
|
10007
10026
|
}, [options]);
|
|
10008
|
-
|
|
10009
|
-
|
|
10010
|
-
|
|
10011
|
-
|
|
10012
|
-
|
|
10013
|
-
|
|
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
|
-
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
-
}),
|
|
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:
|
|
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
|
-
|
|
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-
|
|
401
|
+
.adm-calendar-cell.adm-calendar-cell-disabled {
|
|
402
402
|
color: var(--adm-color-light);
|
|
403
403
|
}
|
|
404
|
-
.adm-calendar-cell.adm-calendar-cell-
|
|
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:
|
|
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
|
|
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:
|
|
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`]:
|
|
82
|
+
[`${classPrefix}-loading`]: loading
|
|
57
83
|
}, `${classPrefix}-shape-${props.shape}`),
|
|
58
84
|
disabled: disabled
|
|
59
|
-
},
|
|
85
|
+
}, loading ? _react.default.createElement("div", {
|
|
60
86
|
className: `${classPrefix}-loading-wrapper`
|
|
61
|
-
},
|
|
62
|
-
color: 'currentColor'
|
|
63
|
-
}), props.loadingText) : props.children));
|
|
87
|
+
}, props.loadingIcon, props.loadingText) : props.children));
|
|
64
88
|
});
|
|
65
89
|
exports.Button = Button;
|