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
|
@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.ModalActionButton = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
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:
|
|
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:
|
|
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.
|
|
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", {
|
package/2x/cjs/global/index.js
CHANGED
|
@@ -5,5 +5,7 @@ require("./global.css");
|
|
|
5
5
|
var _canUseDom = require("../utils/can-use-dom");
|
|
6
6
|
|
|
7
7
|
if (_canUseDom.canUseDom) {
|
|
8
|
+
// Make sure the `:active` CSS selector of `button` and `a` take effect
|
|
9
|
+
// See: https://stackoverflow.com/questions/3885018/active-pseudo-class-doesnt-work-in-mobile-safari
|
|
8
10
|
document.addEventListener('touchstart', () => {}, true);
|
|
9
11
|
}
|
package/2x/cjs/locales/base.d.ts
CHANGED
package/2x/cjs/locales/base.js
CHANGED
package/2x/cjs/locales/zh-CN.js
CHANGED
|
@@ -5,10 +5,11 @@ export declare type ButtonProps = {
|
|
|
5
5
|
fill?: 'solid' | 'outline' | 'none';
|
|
6
6
|
size?: 'mini' | 'small' | 'middle' | 'large';
|
|
7
7
|
block?: boolean;
|
|
8
|
-
loading?: boolean;
|
|
8
|
+
loading?: boolean | 'auto';
|
|
9
9
|
loadingText?: string;
|
|
10
|
+
loadingIcon?: React.ReactNode;
|
|
10
11
|
disabled?: boolean;
|
|
11
|
-
onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void
|
|
12
|
+
onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void | Promise<void>;
|
|
12
13
|
type?: 'submit' | 'reset' | 'button';
|
|
13
14
|
shape?: 'default' | 'rounded' | 'rectangular';
|
|
14
15
|
children?: React.ReactNode;
|
|
@@ -21,10 +22,11 @@ export declare const Button: React.ForwardRefExoticComponent<{
|
|
|
21
22
|
fill?: "none" | "solid" | "outline" | undefined;
|
|
22
23
|
size?: "small" | "large" | "middle" | "mini" | undefined;
|
|
23
24
|
block?: boolean | undefined;
|
|
24
|
-
loading?: boolean | undefined;
|
|
25
|
+
loading?: boolean | "auto" | undefined;
|
|
25
26
|
loadingText?: string | undefined;
|
|
27
|
+
loadingIcon?: React.ReactNode;
|
|
26
28
|
disabled?: boolean | undefined;
|
|
27
|
-
onClick?: ((event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void) | undefined;
|
|
29
|
+
onClick?: ((event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void | Promise<void>) | undefined;
|
|
28
30
|
type?: "reset" | "submit" | "button" | undefined;
|
|
29
31
|
shape?: "default" | "rounded" | "rectangular" | undefined;
|
|
30
32
|
children?: React.ReactNode;
|
|
@@ -1,32 +1,56 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import React, { forwardRef, useImperativeHandle, useRef, useState } from 'react';
|
|
2
3
|
import classNames from 'classnames';
|
|
3
4
|
import DotLoading from '../dot-loading';
|
|
4
5
|
import { mergeProps } from '../../utils/with-default-props';
|
|
5
6
|
import { withNativeProps } from '../../utils/native-props';
|
|
7
|
+
import { isPromise } from '../../utils/validate';
|
|
6
8
|
const classPrefix = `adm-button`;
|
|
7
9
|
const defaultProps = {
|
|
8
10
|
color: 'default',
|
|
9
11
|
fill: 'solid',
|
|
10
12
|
block: false,
|
|
11
13
|
loading: false,
|
|
14
|
+
loadingIcon: React.createElement(DotLoading, {
|
|
15
|
+
color: 'currentColor'
|
|
16
|
+
}),
|
|
12
17
|
type: 'button',
|
|
13
18
|
shape: 'default',
|
|
14
19
|
size: 'middle'
|
|
15
20
|
};
|
|
16
21
|
export const Button = forwardRef((p, ref) => {
|
|
17
22
|
const props = mergeProps(defaultProps, p);
|
|
18
|
-
const
|
|
23
|
+
const [innerLoading, setInnerLoading] = useState(false);
|
|
19
24
|
const nativeButtonRef = useRef(null);
|
|
25
|
+
const loading = props.loading === 'auto' ? innerLoading : props.loading;
|
|
26
|
+
const disabled = props.disabled || loading;
|
|
20
27
|
useImperativeHandle(ref, () => ({
|
|
21
28
|
get nativeElement() {
|
|
22
29
|
return nativeButtonRef.current;
|
|
23
30
|
}
|
|
24
31
|
|
|
25
32
|
}));
|
|
33
|
+
|
|
34
|
+
const handleClick = e => __awaiter(void 0, void 0, void 0, function* () {
|
|
35
|
+
if (!props.onClick) return;
|
|
36
|
+
const promise = props.onClick(e);
|
|
37
|
+
|
|
38
|
+
if (isPromise(promise)) {
|
|
39
|
+
try {
|
|
40
|
+
setInnerLoading(true);
|
|
41
|
+
yield promise;
|
|
42
|
+
setInnerLoading(false);
|
|
43
|
+
} catch (e) {
|
|
44
|
+
setInnerLoading(false);
|
|
45
|
+
throw e;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
26
50
|
return withNativeProps(props, React.createElement("button", {
|
|
27
51
|
ref: nativeButtonRef,
|
|
28
52
|
type: props.type,
|
|
29
|
-
onClick:
|
|
53
|
+
onClick: handleClick,
|
|
30
54
|
className: classNames(classPrefix, props.color ? `${classPrefix}-${props.color}` : null, {
|
|
31
55
|
[`${classPrefix}-block`]: props.block,
|
|
32
56
|
[`${classPrefix}-disabled`]: disabled,
|
|
@@ -35,12 +59,10 @@ export const Button = forwardRef((p, ref) => {
|
|
|
35
59
|
[`${classPrefix}-mini`]: props.size === 'mini',
|
|
36
60
|
[`${classPrefix}-small`]: props.size === 'small',
|
|
37
61
|
[`${classPrefix}-large`]: props.size === 'large',
|
|
38
|
-
[`${classPrefix}-loading`]:
|
|
62
|
+
[`${classPrefix}-loading`]: loading
|
|
39
63
|
}, `${classPrefix}-shape-${props.shape}`),
|
|
40
64
|
disabled: disabled
|
|
41
|
-
},
|
|
65
|
+
}, loading ? React.createElement("div", {
|
|
42
66
|
className: `${classPrefix}-loading-wrapper`
|
|
43
|
-
},
|
|
44
|
-
color: 'currentColor'
|
|
45
|
-
}), props.loadingText) : props.children));
|
|
67
|
+
}, props.loadingIcon, props.loadingText) : props.children));
|
|
46
68
|
});
|
|
@@ -59,11 +59,11 @@
|
|
|
59
59
|
color: var(--adm-color-primary);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
.adm-calendar-cell.adm-calendar-cell-
|
|
62
|
+
.adm-calendar-cell.adm-calendar-cell-disabled {
|
|
63
63
|
color: var(--adm-color-light);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
.adm-calendar-cell.adm-calendar-cell-
|
|
66
|
+
.adm-calendar-cell.adm-calendar-cell-disabled .adm-calendar-cell-bottom {
|
|
67
67
|
color: var(--adm-color-light);
|
|
68
68
|
}
|
|
69
69
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { forwardRef, useState, useImperativeHandle } from 'react';
|
|
1
|
+
import React, { forwardRef, useState, useImperativeHandle, useMemo } from 'react';
|
|
2
2
|
import { withNativeProps } from '../../utils/native-props';
|
|
3
3
|
import dayjs from 'dayjs';
|
|
4
4
|
import classNames from 'classnames';
|
|
@@ -94,6 +94,8 @@ export const Calendar = forwardRef((p, ref) => {
|
|
|
94
94
|
setCurrent(current.add(1, 'year'));
|
|
95
95
|
}
|
|
96
96
|
}, React.createElement(ArrowLeftDouble, null)));
|
|
97
|
+
const maxDay = useMemo(() => props.max && dayjs(props.max), [props.max]);
|
|
98
|
+
const minDay = useMemo(() => props.min && dayjs(props.min), [props.min]);
|
|
97
99
|
|
|
98
100
|
function renderCells() {
|
|
99
101
|
var _a;
|
|
@@ -119,9 +121,10 @@ export const Calendar = forwardRef((p, ref) => {
|
|
|
119
121
|
}
|
|
120
122
|
|
|
121
123
|
const inThisMonth = d.month() === current.month();
|
|
124
|
+
const disabled = !inThisMonth || maxDay && d.isAfter(maxDay, 'day') || minDay && d.isBefore(minDay, 'day');
|
|
122
125
|
cells.push(React.createElement("div", {
|
|
123
126
|
key: d.valueOf(),
|
|
124
|
-
className: classNames(`${classPrefix}-cell`,
|
|
127
|
+
className: classNames(`${classPrefix}-cell`, disabled && `${classPrefix}-cell-disabled`, inThisMonth && {
|
|
125
128
|
[`${classPrefix}-cell-today`]: d.isSame(today, 'day'),
|
|
126
129
|
[`${classPrefix}-cell-selected`]: isSelect,
|
|
127
130
|
[`${classPrefix}-cell-selected-begin`]: isBegin,
|
|
@@ -129,6 +132,7 @@ export const Calendar = forwardRef((p, ref) => {
|
|
|
129
132
|
}),
|
|
130
133
|
onClick: () => {
|
|
131
134
|
if (!props.selectionMode) return;
|
|
135
|
+
if (disabled) return;
|
|
132
136
|
const date = d.toDate();
|
|
133
137
|
|
|
134
138
|
if (!inThisMonth) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { PickerColumn } from '../picker-view';
|
|
1
|
+
import { PickerColumn, PickerValue } from '../picker-view';
|
|
2
2
|
import { CascadePickerOption } from './cascade-picker';
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function useColumnsFn(options: CascadePickerOption[]): (selected: PickerValue[]) => PickerColumn[];
|
|
@@ -1,23 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
value: option.value
|
|
6
|
-
})));
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
export function useColumnsFn(options) {
|
|
3
|
+
const depth = useMemo(() => {
|
|
4
|
+
let depth = 0;
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
function traverse(options, currentDepth) {
|
|
7
|
+
if (currentDepth > depth) depth = currentDepth;
|
|
8
|
+
const nextDepth = currentDepth + 1;
|
|
9
|
+
options.forEach(option => {
|
|
10
|
+
if (option.children) {
|
|
11
|
+
traverse(option.children, nextDepth);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
}
|
|
11
15
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
traverse(options, 1);
|
|
17
|
+
return depth;
|
|
18
|
+
}, [options]);
|
|
19
|
+
return selected => {
|
|
20
|
+
const columns = [];
|
|
21
|
+
let currentOptions = options;
|
|
22
|
+
let i = 0;
|
|
23
|
+
|
|
24
|
+
while (true) {
|
|
25
|
+
columns.push(currentOptions.map(option => ({
|
|
16
26
|
label: option.label,
|
|
17
27
|
value: option.value
|
|
18
28
|
})));
|
|
29
|
+
const x = selected[i];
|
|
30
|
+
const targetOptions = currentOptions.find(option => option.value === x);
|
|
31
|
+
if (!targetOptions || !targetOptions.children) break;
|
|
32
|
+
currentOptions = targetOptions.children;
|
|
33
|
+
i++;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
while (i < depth - 1) {
|
|
37
|
+
columns.push([]);
|
|
38
|
+
i++;
|
|
19
39
|
}
|
|
20
|
-
}
|
|
21
40
|
|
|
22
|
-
|
|
41
|
+
return columns;
|
|
42
|
+
};
|
|
23
43
|
}
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import Picker from '../picker';
|
|
4
|
-
import {
|
|
5
|
-
import { generateCascadePickerColumns } from './cascade-picker-utils';
|
|
4
|
+
import { useColumnsFn } from './cascade-picker-utils';
|
|
6
5
|
export const CascadePicker = props => {
|
|
7
6
|
const {
|
|
8
7
|
options
|
|
9
8
|
} = props,
|
|
10
9
|
pickerProps = __rest(props, ["options"]);
|
|
11
10
|
|
|
12
|
-
const
|
|
13
|
-
depth,
|
|
14
|
-
subOptionsRecord
|
|
15
|
-
} = useCascadePickerOptions(options);
|
|
11
|
+
const columnsFn = useColumnsFn(options);
|
|
16
12
|
return React.createElement(Picker, Object.assign({}, pickerProps, {
|
|
17
|
-
columns:
|
|
13
|
+
columns: columnsFn
|
|
18
14
|
}));
|
|
19
15
|
};
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import PickerView from '../picker-view';
|
|
4
|
-
import {
|
|
5
|
-
import { generateCascadePickerColumns } from '../cascade-picker/cascade-picker-utils';
|
|
4
|
+
import { useColumnsFn } from '../cascade-picker/cascade-picker-utils';
|
|
6
5
|
export const CascadePickerView = props => {
|
|
7
6
|
const {
|
|
8
7
|
options
|
|
9
8
|
} = props,
|
|
10
9
|
pickerProps = __rest(props, ["options"]);
|
|
11
10
|
|
|
12
|
-
const
|
|
13
|
-
depth,
|
|
14
|
-
subOptionsRecord
|
|
15
|
-
} = useCascadePickerOptions(options);
|
|
11
|
+
const columnsFn = useColumnsFn(options);
|
|
16
12
|
return React.createElement(PickerView, Object.assign({}, pickerProps, {
|
|
17
|
-
columns:
|
|
13
|
+
columns: columnsFn
|
|
18
14
|
}));
|
|
19
15
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React, { useState } from 'react';
|
|
1
|
+
import React from 'react';
|
|
3
2
|
import classNames from 'classnames';
|
|
4
3
|
import Button from '../button';
|
|
5
4
|
import { withNativeProps } from '../../utils/native-props';
|
|
@@ -7,26 +6,9 @@ export const DialogActionButton = props => {
|
|
|
7
6
|
const {
|
|
8
7
|
action
|
|
9
8
|
} = props;
|
|
10
|
-
const [loading, setLoading] = useState(false);
|
|
11
|
-
|
|
12
|
-
function handleClick() {
|
|
13
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
14
|
-
setLoading(true);
|
|
15
|
-
|
|
16
|
-
try {
|
|
17
|
-
const promise = props.onAction();
|
|
18
|
-
yield promise;
|
|
19
|
-
setLoading(false);
|
|
20
|
-
} catch (e) {
|
|
21
|
-
setLoading(false);
|
|
22
|
-
throw e;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
9
|
return withNativeProps(props.action, React.createElement(Button, {
|
|
28
10
|
key: action.key,
|
|
29
|
-
onClick:
|
|
11
|
+
onClick: props.onAction,
|
|
30
12
|
className: classNames('adm-dialog-button', {
|
|
31
13
|
'adm-dialog-button-bold': action.bold
|
|
32
14
|
}),
|
|
@@ -34,7 +16,7 @@ export const DialogActionButton = props => {
|
|
|
34
16
|
shape: 'rectangular',
|
|
35
17
|
block: true,
|
|
36
18
|
color: action.danger ? 'danger' : 'primary',
|
|
37
|
-
loading:
|
|
19
|
+
loading: 'auto',
|
|
38
20
|
disabled: action.disabled
|
|
39
21
|
}, action.text));
|
|
40
22
|
};
|
|
@@ -6,6 +6,7 @@ export declare type FormContextType = {
|
|
|
6
6
|
hasFeedback: boolean;
|
|
7
7
|
layout: FormLayout;
|
|
8
8
|
requiredMarkStyle: 'asterisk' | 'text-required' | 'text-optional';
|
|
9
|
+
disabled: boolean;
|
|
9
10
|
};
|
|
10
11
|
export declare const defaultFormContext: FormContextType;
|
|
11
12
|
export declare const FormContext: React.Context<FormContextType>;
|
|
@@ -3,7 +3,8 @@ export const defaultFormContext = {
|
|
|
3
3
|
name: undefined,
|
|
4
4
|
hasFeedback: true,
|
|
5
5
|
layout: 'vertical',
|
|
6
|
-
requiredMarkStyle: 'asterisk'
|
|
6
|
+
requiredMarkStyle: 'asterisk',
|
|
7
|
+
disabled: false
|
|
7
8
|
};
|
|
8
9
|
export const FormContext = React.createContext(defaultFormContext);
|
|
9
10
|
export const NoStyleItemContext = React.createContext(null);
|
|
@@ -18,6 +18,8 @@ const MemoInput = React.memo(({
|
|
|
18
18
|
}) => children, (prev, next) => prev.value === next.value && prev.update === next.update);
|
|
19
19
|
|
|
20
20
|
const FormItemLayout = props => {
|
|
21
|
+
var _a;
|
|
22
|
+
|
|
21
23
|
const {
|
|
22
24
|
className,
|
|
23
25
|
style,
|
|
@@ -25,7 +27,6 @@ const FormItemLayout = props => {
|
|
|
25
27
|
label,
|
|
26
28
|
help,
|
|
27
29
|
required,
|
|
28
|
-
disabled,
|
|
29
30
|
children,
|
|
30
31
|
htmlFor,
|
|
31
32
|
hidden,
|
|
@@ -38,6 +39,7 @@ const FormItemLayout = props => {
|
|
|
38
39
|
} = useConfig();
|
|
39
40
|
const hasFeedback = props.hasFeedback !== undefined ? props.hasFeedback : context.hasFeedback;
|
|
40
41
|
const layout = props.layout || context.layout;
|
|
42
|
+
const disabled = (_a = props.disabled) !== null && _a !== void 0 ? _a : context.disabled;
|
|
41
43
|
|
|
42
44
|
const requiredMark = (() => {
|
|
43
45
|
const {
|
|
@@ -3,15 +3,12 @@ import { NativeProps } from '../../utils/native-props';
|
|
|
3
3
|
import { ListProps } from '../list';
|
|
4
4
|
import type { FormProps as RcFormProps, FormInstance as RCFormInstance } from 'rc-field-form';
|
|
5
5
|
import { FormContextType } from './context';
|
|
6
|
-
import type { FormLayout } from '.';
|
|
7
6
|
export declare type FormInstance = Pick<RCFormInstance, 'getFieldValue' | 'getFieldsValue' | 'getFieldError' | 'getFieldsError' | 'isFieldTouched' | 'isFieldsTouched' | 'resetFields' | 'setFields' | 'setFieldsValue' | 'submit' | 'validateFields'>;
|
|
8
7
|
export declare type FormProps = Pick<RcFormProps, 'form' | 'initialValues' | 'name' | 'preserve' | 'validateMessages' | 'validateTrigger' | 'onFieldsChange' | 'onFinish' | 'onFinishFailed' | 'onValuesChange' | 'children'> & NativeProps<'--border-inner' | '--border-top' | '--border-bottom'> & Partial<FormContextType> & {
|
|
9
8
|
footer?: ReactNode;
|
|
10
|
-
layout?: FormLayout;
|
|
11
9
|
mode?: ListProps['mode'];
|
|
12
10
|
};
|
|
13
11
|
export declare const Form: React.ForwardRefExoticComponent<Pick<RcFormProps<any>, "children" | "form" | "name" | "initialValues" | "preserve" | "validateMessages" | "validateTrigger" | "onFieldsChange" | "onFinish" | "onFinishFailed" | "onValuesChange"> & NativeProps<"--border-inner" | "--border-top" | "--border-bottom"> & Partial<FormContextType> & {
|
|
14
12
|
footer?: ReactNode;
|
|
15
|
-
layout?: FormLayout | undefined;
|
|
16
13
|
mode?: ListProps['mode'];
|
|
17
14
|
} & React.RefAttributes<FormInstance>>;
|