antd-mobile 5.36.1 → 5.37.0
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/bundle/antd-mobile.cjs.development.js +355 -283
- package/2x/bundle/antd-mobile.cjs.js +7 -7
- package/2x/bundle/antd-mobile.es.development.js +355 -283
- package/2x/bundle/antd-mobile.es.js +5428 -5379
- package/2x/bundle/antd-mobile.umd.development.js +355 -283
- package/2x/bundle/antd-mobile.umd.js +7 -7
- package/2x/bundle/style.css +5 -8
- package/2x/cjs/components/card/card.css +5 -5
- package/2x/cjs/components/card/card.patch.css +21 -0
- package/2x/cjs/components/center-popup/center-popup.js +46 -43
- package/2x/cjs/components/check-list/check-list.js +15 -11
- package/2x/cjs/components/collapse/collapse.d.ts +9 -1
- package/2x/cjs/components/collapse/collapse.js +26 -28
- package/2x/cjs/components/config-provider/config-provider.d.ts +40 -2
- package/2x/cjs/components/dropdown/context.d.ts +2 -0
- package/2x/cjs/components/dropdown/context.js +10 -0
- package/2x/cjs/components/dropdown/dropdown.d.ts +11 -3
- package/2x/cjs/components/dropdown/dropdown.js +23 -16
- package/2x/cjs/components/dropdown/index.d.ts +1 -0
- package/2x/cjs/components/dropdown/item.d.ts +5 -1
- package/2x/cjs/components/dropdown/item.js +22 -8
- package/2x/cjs/components/form/form-item.d.ts +6 -5
- package/2x/cjs/components/form/form-item.js +25 -17
- package/2x/cjs/components/form/form.d.ts +1 -1
- package/2x/cjs/components/form/index.d.ts +1 -1
- package/2x/cjs/components/input/input.d.ts +3 -1
- package/2x/cjs/components/input/input.js +53 -51
- package/2x/cjs/components/list/list-item.d.ts +6 -2
- package/2x/cjs/components/list/list-item.js +16 -6
- package/2x/cjs/components/nav-bar/nav-bar.d.ts +4 -0
- package/2x/cjs/components/nav-bar/nav-bar.js +18 -13
- package/2x/cjs/components/notice-bar/notice-bar.css +0 -3
- package/2x/cjs/components/notice-bar/notice-bar.d.ts +3 -1
- package/2x/cjs/components/notice-bar/notice-bar.js +30 -25
- package/2x/cjs/components/number-keyboard/number-keyboard.d.ts +1 -1
- package/2x/cjs/components/number-keyboard/number-keyboard.js +14 -13
- package/2x/cjs/components/popup/popup-base-props.d.ts +3 -2
- package/2x/cjs/components/popup/popup-base-props.js +4 -0
- package/2x/cjs/components/popup/popup.js +5 -5
- package/2x/cjs/components/result/result.js +3 -10
- package/2x/cjs/components/result/use-result-icon.d.ts +3 -0
- package/2x/cjs/components/result/use-result-icon.js +37 -0
- package/2x/cjs/components/result-page/result-page.js +3 -10
- package/2x/cjs/components/search-bar/search-bar.d.ts +10 -2
- package/2x/cjs/components/search-bar/search-bar.js +34 -33
- package/2x/cjs/components/toast/toast.d.ts +2 -2
- package/2x/cjs/components/toast/toast.js +4 -4
- package/2x/cjs/components/virtual-input/virtual-input.d.ts +5 -5
- package/2x/cjs/components/virtual-input/virtual-input.js +26 -24
- package/2x/cjs/utils/is-node-with-content.d.ts +3 -0
- package/2x/cjs/utils/is-node-with-content.js +3 -0
- package/2x/cjs/utils/with-default-props.d.ts +7 -0
- package/2x/cjs/utils/with-default-props.js +21 -5
- package/2x/es/components/card/card.css +5 -5
- package/2x/es/components/card/card.patch.css +21 -0
- package/2x/es/components/center-popup/center-popup.js +45 -42
- package/2x/es/components/check-list/check-list.js +15 -11
- package/2x/es/components/collapse/collapse.d.ts +9 -1
- package/2x/es/components/collapse/collapse.js +26 -28
- package/2x/es/components/config-provider/config-provider.d.ts +40 -2
- package/2x/es/components/dropdown/context.d.ts +2 -0
- package/2x/es/components/dropdown/context.js +2 -0
- package/2x/es/components/dropdown/dropdown.d.ts +11 -3
- package/2x/es/components/dropdown/dropdown.js +24 -17
- package/2x/es/components/dropdown/index.d.ts +1 -0
- package/2x/es/components/dropdown/item.d.ts +5 -1
- package/2x/es/components/dropdown/item.js +22 -8
- package/2x/es/components/form/form-item.d.ts +6 -5
- package/2x/es/components/form/form-item.js +24 -16
- package/2x/es/components/form/form.d.ts +1 -1
- package/2x/es/components/form/index.d.ts +1 -1
- package/2x/es/components/input/input.d.ts +3 -1
- package/2x/es/components/input/input.js +52 -50
- package/2x/es/components/list/list-item.d.ts +6 -2
- package/2x/es/components/list/list-item.js +16 -6
- package/2x/es/components/nav-bar/nav-bar.d.ts +4 -0
- package/2x/es/components/nav-bar/nav-bar.js +18 -13
- package/2x/es/components/notice-bar/notice-bar.css +0 -3
- package/2x/es/components/notice-bar/notice-bar.d.ts +3 -1
- package/2x/es/components/notice-bar/notice-bar.js +29 -24
- package/2x/es/components/number-keyboard/number-keyboard.d.ts +1 -1
- package/2x/es/components/number-keyboard/number-keyboard.js +13 -12
- package/2x/es/components/popup/popup-base-props.d.ts +3 -2
- package/2x/es/components/popup/popup-base-props.js +3 -0
- package/2x/es/components/popup/popup.js +5 -5
- package/2x/es/components/result/result.js +3 -10
- package/2x/es/components/result/use-result-icon.d.ts +3 -0
- package/2x/es/components/result/use-result-icon.js +29 -0
- package/2x/es/components/result-page/result-page.js +3 -10
- package/2x/es/components/search-bar/search-bar.d.ts +10 -2
- package/2x/es/components/search-bar/search-bar.js +33 -32
- package/2x/es/components/toast/toast.d.ts +2 -2
- package/2x/es/components/toast/toast.js +3 -3
- package/2x/es/components/virtual-input/virtual-input.d.ts +5 -5
- package/2x/es/components/virtual-input/virtual-input.js +25 -23
- package/2x/es/utils/is-node-with-content.d.ts +3 -0
- package/2x/es/utils/is-node-with-content.js +3 -0
- package/2x/es/utils/with-default-props.d.ts +7 -0
- package/2x/es/utils/with-default-props.js +20 -5
- package/2x/package.json +1 -1
- package/bundle/antd-mobile.cjs.development.js +355 -283
- package/bundle/antd-mobile.cjs.js +7 -7
- package/bundle/antd-mobile.compatible.umd.js +1 -1
- package/bundle/antd-mobile.es.development.js +355 -283
- package/bundle/antd-mobile.es.js +5428 -5379
- package/bundle/antd-mobile.umd.development.js +355 -283
- package/bundle/antd-mobile.umd.js +7 -7
- package/bundle/style.css +1 -1
- package/cjs/components/card/card.css +5 -5
- package/cjs/components/card/card.patch.css +17 -0
- package/cjs/components/center-popup/center-popup.js +46 -43
- package/cjs/components/check-list/check-list.js +15 -11
- package/cjs/components/collapse/collapse.d.ts +9 -1
- package/cjs/components/collapse/collapse.js +26 -28
- package/cjs/components/config-provider/config-provider.d.ts +40 -2
- package/cjs/components/dropdown/context.d.ts +2 -0
- package/cjs/components/dropdown/context.js +10 -0
- package/cjs/components/dropdown/dropdown.d.ts +11 -3
- package/cjs/components/dropdown/dropdown.js +23 -16
- package/cjs/components/dropdown/index.d.ts +1 -0
- package/cjs/components/dropdown/item.d.ts +5 -1
- package/cjs/components/dropdown/item.js +22 -8
- package/cjs/components/form/form-item.d.ts +6 -5
- package/cjs/components/form/form-item.js +25 -17
- package/cjs/components/form/form.d.ts +1 -1
- package/cjs/components/form/index.d.ts +1 -1
- package/cjs/components/input/input.d.ts +3 -1
- package/cjs/components/input/input.js +53 -51
- package/cjs/components/list/list-item.d.ts +6 -2
- package/cjs/components/list/list-item.js +16 -6
- package/cjs/components/nav-bar/nav-bar.d.ts +4 -0
- package/cjs/components/nav-bar/nav-bar.js +18 -13
- package/cjs/components/notice-bar/notice-bar.css +0 -2
- package/cjs/components/notice-bar/notice-bar.d.ts +3 -1
- package/cjs/components/notice-bar/notice-bar.js +30 -25
- package/cjs/components/number-keyboard/number-keyboard.d.ts +1 -1
- package/cjs/components/number-keyboard/number-keyboard.js +14 -13
- package/cjs/components/popup/popup-base-props.d.ts +3 -2
- package/cjs/components/popup/popup-base-props.js +4 -0
- package/cjs/components/popup/popup.js +5 -5
- package/cjs/components/result/result.js +3 -10
- package/cjs/components/result/use-result-icon.d.ts +3 -0
- package/cjs/components/result/use-result-icon.js +37 -0
- package/cjs/components/result-page/result-page.js +3 -10
- package/cjs/components/search-bar/search-bar.d.ts +10 -2
- package/cjs/components/search-bar/search-bar.js +34 -33
- package/cjs/components/toast/toast.css +1 -1
- package/cjs/components/toast/toast.d.ts +2 -2
- package/cjs/components/toast/toast.js +4 -4
- package/cjs/components/virtual-input/virtual-input.d.ts +5 -5
- package/cjs/components/virtual-input/virtual-input.js +26 -24
- package/cjs/utils/is-node-with-content.d.ts +3 -0
- package/cjs/utils/is-node-with-content.js +3 -0
- package/cjs/utils/with-default-props.d.ts +7 -0
- package/cjs/utils/with-default-props.js +21 -5
- package/es/components/card/card.css +5 -5
- package/es/components/card/card.patch.css +17 -0
- package/es/components/center-popup/center-popup.js +45 -42
- package/es/components/check-list/check-list.js +15 -11
- package/es/components/collapse/collapse.d.ts +9 -1
- package/es/components/collapse/collapse.js +26 -28
- package/es/components/config-provider/config-provider.d.ts +40 -2
- package/es/components/dropdown/context.d.ts +2 -0
- package/es/components/dropdown/context.js +2 -0
- package/es/components/dropdown/dropdown.d.ts +11 -3
- package/es/components/dropdown/dropdown.js +24 -17
- package/es/components/dropdown/index.d.ts +1 -0
- package/es/components/dropdown/item.d.ts +5 -1
- package/es/components/dropdown/item.js +22 -8
- package/es/components/form/form-item.d.ts +6 -5
- package/es/components/form/form-item.js +24 -16
- package/es/components/form/form.d.ts +1 -1
- package/es/components/form/index.d.ts +1 -1
- package/es/components/input/input.d.ts +3 -1
- package/es/components/input/input.js +52 -50
- package/es/components/list/list-item.d.ts +6 -2
- package/es/components/list/list-item.js +16 -6
- package/es/components/nav-bar/nav-bar.d.ts +4 -0
- package/es/components/nav-bar/nav-bar.js +18 -13
- package/es/components/notice-bar/notice-bar.css +0 -2
- package/es/components/notice-bar/notice-bar.d.ts +3 -1
- package/es/components/notice-bar/notice-bar.js +29 -24
- package/es/components/number-keyboard/number-keyboard.d.ts +1 -1
- package/es/components/number-keyboard/number-keyboard.js +13 -12
- package/es/components/popup/popup-base-props.d.ts +3 -2
- package/es/components/popup/popup-base-props.js +3 -0
- package/es/components/popup/popup.js +5 -5
- package/es/components/result/result.js +3 -10
- package/es/components/result/use-result-icon.d.ts +3 -0
- package/es/components/result/use-result-icon.js +29 -0
- package/es/components/result-page/result-page.js +3 -10
- package/es/components/search-bar/search-bar.d.ts +10 -2
- package/es/components/search-bar/search-bar.js +33 -32
- package/es/components/toast/toast.css +1 -1
- package/es/components/toast/toast.d.ts +2 -2
- package/es/components/toast/toast.js +3 -3
- package/es/components/virtual-input/virtual-input.d.ts +5 -5
- package/es/components/virtual-input/virtual-input.js +25 -23
- package/es/utils/is-node-with-content.d.ts +3 -0
- package/es/utils/is-node-with-content.js +3 -0
- package/es/utils/with-default-props.d.ts +7 -0
- package/es/utils/with-default-props.js +20 -5
- package/package.json +1 -1
- package/umd/antd-mobile.js +1 -1
|
@@ -4,30 +4,32 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.VirtualInput = void 0;
|
|
7
|
+
var _ahooks = require("ahooks");
|
|
8
|
+
var _antdMobileIcons = require("antd-mobile-icons");
|
|
9
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
7
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
11
|
var _nativeProps = require("../../utils/native-props");
|
|
9
|
-
var _withDefaultProps = require("../../utils/with-default-props");
|
|
10
12
|
var _usePropsValue = require("../../utils/use-props-value");
|
|
11
|
-
var
|
|
12
|
-
var _antdMobileIcons = require("antd-mobile-icons");
|
|
13
|
-
var _ahooks = require("ahooks");
|
|
13
|
+
var _withDefaultProps = require("../../utils/with-default-props");
|
|
14
14
|
var _configProvider = require("../config-provider");
|
|
15
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
15
|
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); }
|
|
17
16
|
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; }
|
|
17
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
18
|
const classPrefix = 'adm-virtual-input';
|
|
19
19
|
const defaultProps = {
|
|
20
20
|
defaultValue: ''
|
|
21
21
|
};
|
|
22
|
-
const VirtualInput = (0, _react.forwardRef)((
|
|
23
|
-
const
|
|
24
|
-
|
|
22
|
+
const VirtualInput = (0, _react.forwardRef)((props, ref) => {
|
|
23
|
+
const {
|
|
24
|
+
locale,
|
|
25
|
+
input: componentConfig = {}
|
|
26
|
+
} = (0, _configProvider.useConfig)();
|
|
27
|
+
const mergedProps = (0, _withDefaultProps.mergeProps)(defaultProps, componentConfig, props);
|
|
28
|
+
const [value, setValue] = (0, _usePropsValue.usePropsValue)(mergedProps);
|
|
25
29
|
const rootRef = (0, _react.useRef)(null);
|
|
26
30
|
const contentRef = (0, _react.useRef)(null);
|
|
27
31
|
const [hasFocus, setHasFocus] = (0, _react.useState)(false);
|
|
28
|
-
const
|
|
29
|
-
locale
|
|
30
|
-
} = (0, _configProvider.useConfig)();
|
|
32
|
+
const clearIcon = (0, _withDefaultProps.mergeProp)(_react.default.createElement(_antdMobileIcons.CloseCircleFill, null), componentConfig.clearIcon, props.clearIcon);
|
|
31
33
|
function scrollToEnd() {
|
|
32
34
|
const root = rootRef.current;
|
|
33
35
|
if (!root) return;
|
|
@@ -59,14 +61,14 @@ const VirtualInput = (0, _react.forwardRef)((p, ref) => {
|
|
|
59
61
|
function onFocus() {
|
|
60
62
|
var _a;
|
|
61
63
|
setHasFocus(true);
|
|
62
|
-
(_a =
|
|
64
|
+
(_a = mergedProps.onFocus) === null || _a === void 0 ? void 0 : _a.call(mergedProps);
|
|
63
65
|
}
|
|
64
66
|
function onBlur() {
|
|
65
67
|
var _a;
|
|
66
68
|
setHasFocus(false);
|
|
67
|
-
(_a =
|
|
69
|
+
(_a = mergedProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(mergedProps);
|
|
68
70
|
}
|
|
69
|
-
const keyboard =
|
|
71
|
+
const keyboard = mergedProps.keyboard;
|
|
70
72
|
const keyboardElement = keyboard && _react.default.cloneElement(keyboard, {
|
|
71
73
|
onInput: v => {
|
|
72
74
|
var _a, _b;
|
|
@@ -93,37 +95,37 @@ const VirtualInput = (0, _react.forwardRef)((p, ref) => {
|
|
|
93
95
|
},
|
|
94
96
|
getContainer: null
|
|
95
97
|
});
|
|
96
|
-
return (0, _nativeProps.withNativeProps)(
|
|
98
|
+
return (0, _nativeProps.withNativeProps)(mergedProps, _react.default.createElement("div", {
|
|
97
99
|
ref: rootRef,
|
|
98
100
|
className: (0, _classnames.default)(classPrefix, {
|
|
99
|
-
[`${classPrefix}-disabled`]:
|
|
101
|
+
[`${classPrefix}-disabled`]: mergedProps.disabled
|
|
100
102
|
}),
|
|
101
|
-
tabIndex:
|
|
103
|
+
tabIndex: mergedProps.disabled ? undefined : 0,
|
|
102
104
|
role: 'textbox',
|
|
103
105
|
onFocus: onFocus,
|
|
104
106
|
onBlur: onBlur,
|
|
105
|
-
onClick:
|
|
107
|
+
onClick: mergedProps.onClick
|
|
106
108
|
}, _react.default.createElement("div", {
|
|
107
109
|
className: `${classPrefix}-content`,
|
|
108
110
|
ref: contentRef,
|
|
109
|
-
"aria-disabled":
|
|
110
|
-
"aria-label":
|
|
111
|
+
"aria-disabled": mergedProps.disabled,
|
|
112
|
+
"aria-label": mergedProps.placeholder
|
|
111
113
|
}, value, _react.default.createElement("div", {
|
|
112
114
|
className: `${classPrefix}-caret-container`
|
|
113
115
|
}, hasFocus && _react.default.createElement("div", {
|
|
114
116
|
className: `${classPrefix}-caret`
|
|
115
|
-
}))),
|
|
117
|
+
}))), mergedProps.clearable && !!value && hasFocus && _react.default.createElement("div", {
|
|
116
118
|
className: `${classPrefix}-clear`,
|
|
117
119
|
onClick: e => {
|
|
118
120
|
var _a;
|
|
119
121
|
e.stopPropagation();
|
|
120
122
|
setValue('');
|
|
121
|
-
(_a =
|
|
123
|
+
(_a = mergedProps.onClear) === null || _a === void 0 ? void 0 : _a.call(mergedProps);
|
|
122
124
|
},
|
|
123
125
|
role: 'button',
|
|
124
126
|
"aria-label": locale.Input.clear
|
|
125
|
-
},
|
|
127
|
+
}, clearIcon), [undefined, null, ''].includes(value) && _react.default.createElement("div", {
|
|
126
128
|
className: `${classPrefix}-placeholder`
|
|
127
|
-
},
|
|
129
|
+
}, mergedProps.placeholder), keyboardElement));
|
|
128
130
|
});
|
|
129
131
|
exports.VirtualInput = VirtualInput;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
declare type Regulated<T> = T extends null | undefined | false ? never : T;
|
|
3
|
+
/**
|
|
4
|
+
* Check if the `node` is visible Node (not null, undefined, or false)
|
|
5
|
+
*/
|
|
3
6
|
export declare function isNodeWithContent(node: ReactNode): node is Regulated<ReactNode>;
|
|
4
7
|
export {};
|
|
@@ -4,6 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.isNodeWithContent = isNodeWithContent;
|
|
7
|
+
/**
|
|
8
|
+
* Check if the `node` is visible Node (not null, undefined, or false)
|
|
9
|
+
*/
|
|
7
10
|
function isNodeWithContent(node) {
|
|
8
11
|
return node !== undefined && node !== null && node !== false;
|
|
9
12
|
}
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
export declare function mergeProps<A, B>(a: A, b: B): B & A;
|
|
2
2
|
export declare function mergeProps<A, B, C>(a: A, b: B, c: C): C & B & A;
|
|
3
|
+
export declare function mergeProps<A, B, C, D>(a: A, b: B, c: C, d: D): D & C & B & A;
|
|
4
|
+
/**
|
|
5
|
+
* Merge props and return the first non-undefined value.
|
|
6
|
+
* The later has higher priority. e.g. (10, 1, 5) => 5 wins.
|
|
7
|
+
* This is useful with legacy props that have been deprecated.
|
|
8
|
+
*/
|
|
9
|
+
export declare function mergeProp<T, DefaultT extends T = T>(defaultProp: DefaultT, ...propList: T[]): T | undefined;
|
|
@@ -3,15 +3,31 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.mergeProp = mergeProp;
|
|
6
7
|
exports.mergeProps = mergeProps;
|
|
7
8
|
function mergeProps(...items) {
|
|
8
9
|
const ret = {};
|
|
9
10
|
items.forEach(item => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
if (item) {
|
|
12
|
+
Object.keys(item).forEach(key => {
|
|
13
|
+
if (item[key] !== undefined) {
|
|
14
|
+
ret[key] = item[key];
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
15
18
|
});
|
|
16
19
|
return ret;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Merge props and return the first non-undefined value.
|
|
23
|
+
* The later has higher priority. e.g. (10, 1, 5) => 5 wins.
|
|
24
|
+
* This is useful with legacy props that have been deprecated.
|
|
25
|
+
*/
|
|
26
|
+
function mergeProp(defaultProp, ...propList) {
|
|
27
|
+
for (let i = propList.length - 1; i >= 0; i -= 1) {
|
|
28
|
+
if (propList[i] !== undefined) {
|
|
29
|
+
return propList[i];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return defaultProp;
|
|
17
33
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
.adm-card {
|
|
2
2
|
background: var(--adm-color-background);
|
|
3
|
-
border-radius: 16px;
|
|
4
|
-
padding: 0 24px;
|
|
3
|
+
border-radius: var(--adm-card-border-radius, 16px);
|
|
4
|
+
padding: 0 var(--adm-card-padding-inline, 24px);
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
.adm-card-header {
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
justify-content: space-between;
|
|
11
11
|
align-items: center;
|
|
12
12
|
box-sizing: border-box;
|
|
13
|
-
padding: 24px 0;
|
|
13
|
+
padding: var(--adm-card-header-padding-block, 24px) 0;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
.adm-card-header:not(:last-child) {
|
|
17
|
-
border-bottom: solid 1px var(--adm-color-border);
|
|
17
|
+
border-bottom: solid var(--adm-card-header-border-width, 1px) var(--adm-card-header-border-color, var(--adm-color-border));
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
.adm-card-header-title {
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
.adm-card-body {
|
|
27
|
-
padding: 24px 0;
|
|
27
|
+
padding: var(--adm-card-body-padding-block, 24px) 0;
|
|
28
28
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
.adm-card {
|
|
2
|
+
background: #fff;
|
|
3
|
+
border-radius: 16px;
|
|
4
|
+
padding: 0 24px;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.adm-card-header {
|
|
8
|
+
padding: 24px 0;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.adm-card-header:not(:last-child) {
|
|
12
|
+
border-bottom: solid 1px #eee;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.adm-card-header-title {
|
|
16
|
+
font-size: 30px;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.adm-card-body {
|
|
20
|
+
padding: 24px 0;
|
|
21
|
+
}
|
|
@@ -1,27 +1,30 @@
|
|
|
1
|
-
import React, { useRef, useState } from 'react';
|
|
2
|
-
import { renderToContainer } from '../../utils/render-to-container';
|
|
3
|
-
import Mask from '../mask';
|
|
4
|
-
import { withStopPropagation } from '../../utils/with-stop-propagation';
|
|
5
|
-
import { mergeProps } from '../../utils/with-default-props';
|
|
6
|
-
import { useIsomorphicLayoutEffect, useUnmountedRef } from 'ahooks';
|
|
7
1
|
import { animated, useSpring } from '@react-spring/web';
|
|
8
|
-
import {
|
|
2
|
+
import { useIsomorphicLayoutEffect, useUnmountedRef } from 'ahooks';
|
|
9
3
|
import classNames from 'classnames';
|
|
4
|
+
import React, { useRef, useState } from 'react';
|
|
10
5
|
import { withNativeProps } from '../../utils/native-props';
|
|
6
|
+
import { renderToContainer } from '../../utils/render-to-container';
|
|
11
7
|
import { ShouldRender } from '../../utils/should-render';
|
|
8
|
+
import { useInnerVisible } from '../../utils/use-inner-visible';
|
|
12
9
|
import { useLockScroll } from '../../utils/use-lock-scroll';
|
|
13
|
-
import {
|
|
10
|
+
import { mergeProps } from '../../utils/with-default-props';
|
|
11
|
+
import { withStopPropagation } from '../../utils/with-stop-propagation';
|
|
12
|
+
import { useConfig } from '../config-provider';
|
|
13
|
+
import Mask from '../mask';
|
|
14
14
|
import { defaultPopupBaseProps } from '../popup/popup-base-props';
|
|
15
15
|
const classPrefix = 'adm-center-popup';
|
|
16
16
|
const defaultProps = Object.assign(Object.assign({}, defaultPopupBaseProps), {
|
|
17
17
|
getContainer: null
|
|
18
18
|
});
|
|
19
|
-
export const CenterPopup =
|
|
20
|
-
const
|
|
19
|
+
export const CenterPopup = props => {
|
|
20
|
+
const {
|
|
21
|
+
popup: componentConfig = {}
|
|
22
|
+
} = useConfig();
|
|
23
|
+
const mergedProps = mergeProps(defaultProps, componentConfig, props);
|
|
21
24
|
const unmountedRef = useUnmountedRef();
|
|
22
25
|
const style = useSpring({
|
|
23
|
-
scale:
|
|
24
|
-
opacity:
|
|
26
|
+
scale: mergedProps.visible ? 1 : 0.8,
|
|
27
|
+
opacity: mergedProps.visible ? 1 : 0,
|
|
25
28
|
config: {
|
|
26
29
|
mass: 1.2,
|
|
27
30
|
tension: 200,
|
|
@@ -31,67 +34,67 @@ export const CenterPopup = p => {
|
|
|
31
34
|
onRest: () => {
|
|
32
35
|
var _a, _b;
|
|
33
36
|
if (unmountedRef.current) return;
|
|
34
|
-
setActive(
|
|
35
|
-
if (
|
|
36
|
-
(_a =
|
|
37
|
+
setActive(mergedProps.visible);
|
|
38
|
+
if (mergedProps.visible) {
|
|
39
|
+
(_a = mergedProps.afterShow) === null || _a === void 0 ? void 0 : _a.call(mergedProps);
|
|
37
40
|
} else {
|
|
38
|
-
(_b =
|
|
41
|
+
(_b = mergedProps.afterClose) === null || _b === void 0 ? void 0 : _b.call(mergedProps);
|
|
39
42
|
}
|
|
40
43
|
}
|
|
41
44
|
});
|
|
42
|
-
const [active, setActive] = useState(
|
|
45
|
+
const [active, setActive] = useState(mergedProps.visible);
|
|
43
46
|
useIsomorphicLayoutEffect(() => {
|
|
44
|
-
if (
|
|
47
|
+
if (mergedProps.visible) {
|
|
45
48
|
setActive(true);
|
|
46
49
|
}
|
|
47
|
-
}, [
|
|
50
|
+
}, [mergedProps.visible]);
|
|
48
51
|
const ref = useRef(null);
|
|
49
|
-
useLockScroll(ref,
|
|
50
|
-
const maskVisible = useInnerVisible(active &&
|
|
52
|
+
useLockScroll(ref, mergedProps.disableBodyScroll && active);
|
|
53
|
+
const maskVisible = useInnerVisible(active && mergedProps.visible);
|
|
51
54
|
const body = React.createElement("div", {
|
|
52
|
-
className: classNames(`${classPrefix}-body`,
|
|
53
|
-
style:
|
|
54
|
-
},
|
|
55
|
-
const node = withStopPropagation(
|
|
55
|
+
className: classNames(`${classPrefix}-body`, mergedProps.bodyClassName),
|
|
56
|
+
style: mergedProps.bodyStyle
|
|
57
|
+
}, mergedProps.children);
|
|
58
|
+
const node = withStopPropagation(mergedProps.stopPropagation, withNativeProps(mergedProps, React.createElement("div", {
|
|
56
59
|
className: classPrefix,
|
|
57
60
|
style: {
|
|
58
61
|
display: active ? undefined : 'none',
|
|
59
62
|
pointerEvents: active ? undefined : 'none'
|
|
60
63
|
}
|
|
61
|
-
},
|
|
64
|
+
}, mergedProps.mask && React.createElement(Mask, {
|
|
62
65
|
visible: maskVisible,
|
|
63
|
-
forceRender:
|
|
64
|
-
destroyOnClose:
|
|
66
|
+
forceRender: mergedProps.forceRender,
|
|
67
|
+
destroyOnClose: mergedProps.destroyOnClose,
|
|
65
68
|
onMaskClick: e => {
|
|
66
69
|
var _a, _b;
|
|
67
|
-
(_a =
|
|
68
|
-
if (
|
|
69
|
-
(_b =
|
|
70
|
+
(_a = mergedProps.onMaskClick) === null || _a === void 0 ? void 0 : _a.call(mergedProps, e);
|
|
71
|
+
if (mergedProps.closeOnMaskClick) {
|
|
72
|
+
(_b = mergedProps.onClose) === null || _b === void 0 ? void 0 : _b.call(mergedProps);
|
|
70
73
|
}
|
|
71
74
|
},
|
|
72
|
-
style:
|
|
73
|
-
className: classNames(`${classPrefix}-mask`,
|
|
75
|
+
style: mergedProps.maskStyle,
|
|
76
|
+
className: classNames(`${classPrefix}-mask`, mergedProps.maskClassName),
|
|
74
77
|
disableBodyScroll: false,
|
|
75
|
-
stopPropagation:
|
|
78
|
+
stopPropagation: mergedProps.stopPropagation
|
|
76
79
|
}), React.createElement("div", {
|
|
77
80
|
className: `${classPrefix}-wrap`,
|
|
78
|
-
role:
|
|
79
|
-
"aria-label":
|
|
81
|
+
role: mergedProps.role,
|
|
82
|
+
"aria-label": mergedProps['aria-label']
|
|
80
83
|
}, React.createElement(animated.div, {
|
|
81
84
|
style: Object.assign(Object.assign({}, style), {
|
|
82
85
|
pointerEvents: style.opacity.to(v => v === 1 ? 'unset' : 'none')
|
|
83
86
|
}),
|
|
84
87
|
ref: ref
|
|
85
|
-
},
|
|
88
|
+
}, mergedProps.showCloseButton && React.createElement("a", {
|
|
86
89
|
className: classNames(`${classPrefix}-close`, 'adm-plain-anchor'),
|
|
87
90
|
onClick: () => {
|
|
88
91
|
var _a;
|
|
89
|
-
(_a =
|
|
92
|
+
(_a = mergedProps.onClose) === null || _a === void 0 ? void 0 : _a.call(mergedProps);
|
|
90
93
|
}
|
|
91
|
-
},
|
|
94
|
+
}, mergedProps.closeIcon), body)))));
|
|
92
95
|
return React.createElement(ShouldRender, {
|
|
93
96
|
active: active,
|
|
94
|
-
forceRender:
|
|
95
|
-
destroyOnClose:
|
|
96
|
-
}, renderToContainer(
|
|
97
|
+
forceRender: mergedProps.forceRender,
|
|
98
|
+
destroyOnClose: mergedProps.destroyOnClose
|
|
99
|
+
}, renderToContainer(mergedProps.getContainer, node));
|
|
97
100
|
};
|
|
@@ -1,21 +1,25 @@
|
|
|
1
|
+
import { CheckOutline } from 'antd-mobile-icons';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { withNativeProps } from '../../utils/native-props';
|
|
3
|
-
import
|
|
4
|
+
import { usePropsValue } from '../../utils/use-props-value';
|
|
4
5
|
import { mergeProps } from '../../utils/with-default-props';
|
|
6
|
+
import { useConfig } from '../config-provider';
|
|
7
|
+
import List from '../list';
|
|
5
8
|
import { CheckListContext } from './context';
|
|
6
|
-
import { usePropsValue } from '../../utils/use-props-value';
|
|
7
|
-
import { CheckOutline } from 'antd-mobile-icons';
|
|
8
9
|
const classPrefix = 'adm-check-list';
|
|
9
10
|
const defaultProps = {
|
|
10
11
|
multiple: false,
|
|
11
12
|
defaultValue: [],
|
|
12
13
|
activeIcon: React.createElement(CheckOutline, null)
|
|
13
14
|
};
|
|
14
|
-
export const CheckList =
|
|
15
|
-
const
|
|
16
|
-
|
|
15
|
+
export const CheckList = props => {
|
|
16
|
+
const {
|
|
17
|
+
checkList: componentConfig = {}
|
|
18
|
+
} = useConfig();
|
|
19
|
+
const mergedProps = mergeProps(defaultProps, componentConfig, props);
|
|
20
|
+
const [value, setValue] = usePropsValue(mergedProps);
|
|
17
21
|
function check(val) {
|
|
18
|
-
if (
|
|
22
|
+
if (mergedProps.multiple) {
|
|
19
23
|
setValue([...value, val]);
|
|
20
24
|
} else {
|
|
21
25
|
setValue([val]);
|
|
@@ -29,7 +33,7 @@ export const CheckList = p => {
|
|
|
29
33
|
extra,
|
|
30
34
|
disabled,
|
|
31
35
|
readOnly
|
|
32
|
-
} =
|
|
36
|
+
} = mergedProps;
|
|
33
37
|
return React.createElement(CheckListContext.Provider, {
|
|
34
38
|
value: {
|
|
35
39
|
value,
|
|
@@ -40,8 +44,8 @@ export const CheckList = p => {
|
|
|
40
44
|
disabled,
|
|
41
45
|
readOnly
|
|
42
46
|
}
|
|
43
|
-
}, withNativeProps(
|
|
44
|
-
mode:
|
|
47
|
+
}, withNativeProps(mergedProps, React.createElement(List, {
|
|
48
|
+
mode: mergedProps.mode,
|
|
45
49
|
className: classPrefix
|
|
46
|
-
},
|
|
50
|
+
}, mergedProps.children)));
|
|
47
51
|
};
|
|
@@ -8,14 +8,22 @@ export declare type CollapsePanelProps = {
|
|
|
8
8
|
forceRender?: boolean;
|
|
9
9
|
destroyOnClose?: boolean;
|
|
10
10
|
onClick?: (event: React.MouseEvent<Element, MouseEvent>) => void;
|
|
11
|
-
|
|
11
|
+
arrowIcon?: ReactNode | ((active: boolean) => ReactNode);
|
|
12
12
|
children?: ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated use `arrowIcon` instead
|
|
15
|
+
*/
|
|
16
|
+
arrow?: ReactNode | ((active: boolean) => ReactNode);
|
|
13
17
|
} & NativeProps;
|
|
14
18
|
export declare const CollapsePanel: FC<CollapsePanelProps>;
|
|
15
19
|
declare type ValueProps<T> = {
|
|
16
20
|
activeKey?: T;
|
|
17
21
|
defaultActiveKey?: T;
|
|
18
22
|
onChange?: (activeKey: T) => void;
|
|
23
|
+
arrowIcon?: ReactNode | ((active: boolean) => ReactNode);
|
|
24
|
+
/**
|
|
25
|
+
* @deprecated use `arrowIcon` instead
|
|
26
|
+
*/
|
|
19
27
|
arrow?: ReactNode | ((active: boolean) => ReactNode);
|
|
20
28
|
};
|
|
21
29
|
export declare type CollapseProps = (({
|
|
@@ -9,6 +9,8 @@ import { traverseReactNode } from '../../utils/traverse-react-node';
|
|
|
9
9
|
import { useIsomorphicUpdateLayoutEffect } from '../../utils/use-isomorphic-update-layout-effect';
|
|
10
10
|
import { observe } from '../../utils/use-mutation-effect';
|
|
11
11
|
import { usePropsValue } from '../../utils/use-props-value';
|
|
12
|
+
import { mergeProp, mergeProps } from '../../utils/with-default-props';
|
|
13
|
+
import { useConfig } from '../config-provider';
|
|
12
14
|
import List from '../list';
|
|
13
15
|
const classPrefix = `adm-collapse`;
|
|
14
16
|
export const CollapsePanel = () => {
|
|
@@ -95,8 +97,12 @@ const CollapsePanelContent = props => {
|
|
|
95
97
|
}, React.createElement(List.Item, null, shouldRender && props.children)));
|
|
96
98
|
};
|
|
97
99
|
export const Collapse = props => {
|
|
100
|
+
const {
|
|
101
|
+
collapse: componentConfig = {}
|
|
102
|
+
} = useConfig();
|
|
103
|
+
const mergedProps = mergeProps(componentConfig, props);
|
|
98
104
|
const panels = [];
|
|
99
|
-
traverseReactNode(
|
|
105
|
+
traverseReactNode(mergedProps.children, child => {
|
|
100
106
|
if (!isValidElement(child)) return;
|
|
101
107
|
const key = child.key;
|
|
102
108
|
if (typeof key !== 'string') return;
|
|
@@ -104,11 +110,11 @@ export const Collapse = props => {
|
|
|
104
110
|
});
|
|
105
111
|
const handlePropsValue = () => {
|
|
106
112
|
var _a;
|
|
107
|
-
if (!
|
|
113
|
+
if (!mergedProps.accordion) {
|
|
108
114
|
return {
|
|
109
|
-
value:
|
|
110
|
-
defaultValue: (_a =
|
|
111
|
-
onChange:
|
|
115
|
+
value: mergedProps.activeKey,
|
|
116
|
+
defaultValue: (_a = mergedProps.defaultActiveKey) !== null && _a !== void 0 ? _a : [],
|
|
117
|
+
onChange: mergedProps.onChange
|
|
112
118
|
};
|
|
113
119
|
}
|
|
114
120
|
const initValue = {
|
|
@@ -116,29 +122,29 @@ export const Collapse = props => {
|
|
|
116
122
|
defaultValue: [],
|
|
117
123
|
onChange: v => {
|
|
118
124
|
var _a, _b;
|
|
119
|
-
(_a =
|
|
125
|
+
(_a = mergedProps.onChange) === null || _a === void 0 ? void 0 : _a.call(mergedProps, (_b = v[0]) !== null && _b !== void 0 ? _b : null);
|
|
120
126
|
}
|
|
121
127
|
};
|
|
122
|
-
if (
|
|
128
|
+
if (mergedProps.activeKey === undefined) {
|
|
123
129
|
initValue.value = undefined;
|
|
124
|
-
} else if (
|
|
125
|
-
initValue.value = [
|
|
130
|
+
} else if (mergedProps.activeKey !== null) {
|
|
131
|
+
initValue.value = [mergedProps.activeKey];
|
|
126
132
|
}
|
|
127
|
-
if (![null, undefined].includes(
|
|
128
|
-
initValue.defaultValue = [
|
|
133
|
+
if (![null, undefined].includes(mergedProps.defaultActiveKey)) {
|
|
134
|
+
initValue.defaultValue = [mergedProps.defaultActiveKey];
|
|
129
135
|
}
|
|
130
136
|
return initValue;
|
|
131
137
|
};
|
|
132
138
|
const [activeKey, setActiveKey] = usePropsValue(handlePropsValue());
|
|
133
139
|
const activeKeyList = activeKey === null ? [] : Array.isArray(activeKey) ? activeKey : [activeKey];
|
|
134
|
-
return withNativeProps(
|
|
140
|
+
return withNativeProps(mergedProps, React.createElement("div", {
|
|
135
141
|
className: classPrefix
|
|
136
142
|
}, React.createElement(List, null, panels.map(panel => {
|
|
137
143
|
const key = panel.key;
|
|
138
144
|
const active = activeKeyList.includes(key);
|
|
139
145
|
function handleClick(event) {
|
|
140
146
|
var _a, _b;
|
|
141
|
-
if (
|
|
147
|
+
if (mergedProps.accordion) {
|
|
142
148
|
if (active) {
|
|
143
149
|
setActiveKey([]);
|
|
144
150
|
} else {
|
|
@@ -153,27 +159,19 @@ export const Collapse = props => {
|
|
|
153
159
|
}
|
|
154
160
|
(_b = (_a = panel.props).onClick) === null || _b === void 0 ? void 0 : _b.call(_a, event);
|
|
155
161
|
}
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
arrow
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
arrow = panel.props.arrow;
|
|
163
|
-
}
|
|
164
|
-
return typeof arrow === 'function' ? arrow(active) : React.createElement("div", {
|
|
165
|
-
className: classNames(`${classPrefix}-arrow`, {
|
|
166
|
-
[`${classPrefix}-arrow-active`]: active
|
|
167
|
-
})
|
|
168
|
-
}, arrow);
|
|
169
|
-
};
|
|
162
|
+
const arrow = mergeProp(React.createElement(DownOutline, null), mergedProps.arrow, mergedProps.arrowIcon, panel.props.arrow, panel.props.arrowIcon);
|
|
163
|
+
const arrowIcon = typeof arrow === 'function' ? arrow(active) : React.createElement("div", {
|
|
164
|
+
className: classNames(`${classPrefix}-arrow`, {
|
|
165
|
+
[`${classPrefix}-arrow-active`]: active
|
|
166
|
+
})
|
|
167
|
+
}, arrow);
|
|
170
168
|
return React.createElement(React.Fragment, {
|
|
171
169
|
key: key
|
|
172
170
|
}, withNativeProps(panel.props, React.createElement(List.Item, {
|
|
173
171
|
className: `${classPrefix}-panel-header`,
|
|
174
172
|
onClick: handleClick,
|
|
175
173
|
disabled: panel.props.disabled,
|
|
176
|
-
|
|
174
|
+
arrowIcon: arrowIcon
|
|
177
175
|
}, panel.props.title)), React.createElement(CollapsePanelContent, {
|
|
178
176
|
visible: active,
|
|
179
177
|
forceRender: !!panel.props.forceRender,
|
|
@@ -1,14 +1,52 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
2
|
import { Locale } from '../../locales/base';
|
|
3
3
|
declare type Config = {
|
|
4
4
|
locale: Locale;
|
|
5
|
+
checkList?: {
|
|
6
|
+
activeIcon?: ReactNode;
|
|
7
|
+
};
|
|
8
|
+
collapse?: {
|
|
9
|
+
arrowIcon?: ReactNode | ((active: boolean) => ReactNode);
|
|
10
|
+
};
|
|
11
|
+
dropdown?: {
|
|
12
|
+
arrowIcon?: ReactNode;
|
|
13
|
+
};
|
|
14
|
+
form?: {
|
|
15
|
+
helpIcon?: ReactNode;
|
|
16
|
+
};
|
|
17
|
+
input?: {
|
|
18
|
+
clearIcon?: ReactNode;
|
|
19
|
+
};
|
|
20
|
+
list?: {
|
|
21
|
+
arrowIcon?: ReactNode;
|
|
22
|
+
};
|
|
23
|
+
navBar?: {
|
|
24
|
+
backIcon?: ReactNode;
|
|
25
|
+
};
|
|
26
|
+
noticeBar?: {
|
|
27
|
+
icon?: ReactNode;
|
|
28
|
+
closeIcon?: ReactNode;
|
|
29
|
+
};
|
|
30
|
+
popup?: {
|
|
31
|
+
closeIcon?: ReactNode;
|
|
32
|
+
};
|
|
33
|
+
result?: {
|
|
34
|
+
successIcon?: ReactNode;
|
|
35
|
+
errorIcon?: ReactNode;
|
|
36
|
+
infoIcon?: ReactNode;
|
|
37
|
+
waitingIcon?: ReactNode;
|
|
38
|
+
warningIcon?: ReactNode;
|
|
39
|
+
};
|
|
40
|
+
searchBar?: {
|
|
41
|
+
searchIcon?: ReactNode;
|
|
42
|
+
};
|
|
5
43
|
};
|
|
6
44
|
export declare const defaultConfigRef: {
|
|
7
45
|
current: Config;
|
|
8
46
|
};
|
|
9
47
|
export declare function setDefaultConfig(config: Config): void;
|
|
10
48
|
export declare function getDefaultConfig(): Config;
|
|
11
|
-
export declare type ConfigProviderProps = Config & {
|
|
49
|
+
export declare type ConfigProviderProps = Partial<Config> & {
|
|
12
50
|
children?: ReactNode;
|
|
13
51
|
};
|
|
14
52
|
export declare const ConfigProvider: FC<ConfigProviderProps>;
|