antd-mobile 5.36.0 → 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 +393 -295
- package/2x/bundle/antd-mobile.cjs.js +7 -7
- package/2x/bundle/antd-mobile.es.development.js +393 -295
- package/2x/bundle/antd-mobile.es.js +5619 -5550
- package/2x/bundle/antd-mobile.umd.development.js +393 -295
- 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 +10 -2
- package/2x/cjs/components/collapse/collapse.js +54 -39
- 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/locales/ar-SA.js +2 -2
- package/2x/cjs/locales/de-DE.js +3 -3
- package/2x/cjs/locales/es-ES.js +2 -2
- package/2x/cjs/locales/fr-FR.js +1 -1
- package/2x/cjs/locales/in-ID.d.ts +139 -0
- package/2x/cjs/locales/in-ID.js +149 -0
- package/2x/cjs/locales/ja-JP.js +2 -2
- package/2x/cjs/locales/th-TH.js +2 -2
- 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/use-mutation-effect.d.ts +1 -0
- package/2x/cjs/utils/use-mutation-effect.js +20 -9
- 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 +10 -2
- package/2x/es/components/collapse/collapse.js +53 -38
- 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/locales/ar-SA.js +2 -2
- package/2x/es/locales/de-DE.js +3 -3
- package/2x/es/locales/es-ES.js +2 -2
- package/2x/es/locales/fr-FR.js +1 -1
- package/2x/es/locales/in-ID.d.ts +139 -0
- package/2x/es/locales/in-ID.js +142 -0
- package/2x/es/locales/ja-JP.js +2 -2
- package/2x/es/locales/th-TH.js +2 -2
- 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/use-mutation-effect.d.ts +1 -0
- package/2x/es/utils/use-mutation-effect.js +19 -9
- 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 +3 -2
- package/bundle/antd-mobile.cjs.development.js +393 -295
- package/bundle/antd-mobile.cjs.js +7 -7
- package/bundle/antd-mobile.compatible.umd.js +1 -1
- package/bundle/antd-mobile.es.development.js +393 -295
- package/bundle/antd-mobile.es.js +5619 -5550
- package/bundle/antd-mobile.umd.development.js +393 -295
- 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 +10 -2
- package/cjs/components/collapse/collapse.js +54 -39
- 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/locales/ar-SA.js +2 -2
- package/cjs/locales/de-DE.js +3 -3
- package/cjs/locales/es-ES.js +2 -2
- package/cjs/locales/fr-FR.js +1 -1
- package/cjs/locales/in-ID.d.ts +139 -0
- package/cjs/locales/in-ID.js +149 -0
- package/cjs/locales/ja-JP.js +2 -2
- package/cjs/locales/th-TH.js +2 -2
- package/cjs/utils/is-node-with-content.d.ts +3 -0
- package/cjs/utils/is-node-with-content.js +3 -0
- package/cjs/utils/use-mutation-effect.d.ts +1 -0
- package/cjs/utils/use-mutation-effect.js +20 -9
- 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 +10 -2
- package/es/components/collapse/collapse.js +53 -38
- 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/locales/ar-SA.js +2 -2
- package/es/locales/de-DE.js +3 -3
- package/es/locales/es-ES.js +2 -2
- package/es/locales/fr-FR.js +1 -1
- package/es/locales/in-ID.d.ts +139 -0
- package/es/locales/in-ID.js +142 -0
- package/es/locales/ja-JP.js +2 -2
- package/es/locales/th-TH.js +2 -2
- package/es/utils/is-node-with-content.d.ts +3 -0
- package/es/utils/is-node-with-content.js +3 -0
- package/es/utils/use-mutation-effect.d.ts +1 -0
- package/es/utils/use-mutation-effect.js +19 -9
- package/es/utils/with-default-props.d.ts +7 -0
- package/es/utils/with-default-props.js +20 -5
- package/package.json +3 -2
- package/umd/antd-mobile.js +1 -1
|
@@ -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
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import type { FC, ReactNode } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
3
|
import { NativeProps } from '../../utils/native-props';
|
|
4
4
|
export declare type CollapsePanelProps = {
|
|
5
5
|
key: string;
|
|
@@ -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 = (({
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import List from '../list';
|
|
1
|
+
import { animated, useSpring } from '@react-spring/web';
|
|
2
|
+
import { useMount } from 'ahooks';
|
|
4
3
|
import { DownOutline } from 'antd-mobile-icons';
|
|
5
4
|
import classNames from 'classnames';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { useMount } from 'ahooks';
|
|
5
|
+
import React, { isValidElement, useRef } from 'react';
|
|
6
|
+
import { withNativeProps } from '../../utils/native-props';
|
|
9
7
|
import { useShouldRender } from '../../utils/should-render';
|
|
10
|
-
import { useIsomorphicUpdateLayoutEffect } from '../../utils/use-isomorphic-update-layout-effect';
|
|
11
8
|
import { traverseReactNode } from '../../utils/traverse-react-node';
|
|
9
|
+
import { useIsomorphicUpdateLayoutEffect } from '../../utils/use-isomorphic-update-layout-effect';
|
|
10
|
+
import { observe } from '../../utils/use-mutation-effect';
|
|
11
|
+
import { usePropsValue } from '../../utils/use-props-value';
|
|
12
|
+
import { mergeProp, mergeProps } from '../../utils/with-default-props';
|
|
13
|
+
import { useConfig } from '../config-provider';
|
|
14
|
+
import List from '../list';
|
|
12
15
|
const classPrefix = `adm-collapse`;
|
|
13
16
|
export const CollapsePanel = () => {
|
|
14
17
|
return null;
|
|
@@ -46,9 +49,25 @@ const CollapsePanelContent = props => {
|
|
|
46
49
|
const inner = innerRef.current;
|
|
47
50
|
if (!inner) return;
|
|
48
51
|
if (visible) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
let lastMotionId = 0;
|
|
53
|
+
let cancelObserve = () => {};
|
|
54
|
+
const handleMotion = () => {
|
|
55
|
+
lastMotionId += 1;
|
|
56
|
+
const motionId = lastMotionId;
|
|
57
|
+
api.start({
|
|
58
|
+
height: inner.offsetHeight
|
|
59
|
+
})[0].then(() => {
|
|
60
|
+
if (motionId === lastMotionId) {
|
|
61
|
+
cancelObserve();
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
cancelObserve = observe(inner, {
|
|
66
|
+
childList: true,
|
|
67
|
+
subtree: true
|
|
68
|
+
}, handleMotion);
|
|
69
|
+
handleMotion();
|
|
70
|
+
return cancelObserve;
|
|
52
71
|
} else {
|
|
53
72
|
api.start({
|
|
54
73
|
height: inner.offsetHeight,
|
|
@@ -78,8 +97,12 @@ const CollapsePanelContent = props => {
|
|
|
78
97
|
}, React.createElement(List.Item, null, shouldRender && props.children)));
|
|
79
98
|
};
|
|
80
99
|
export const Collapse = props => {
|
|
100
|
+
const {
|
|
101
|
+
collapse: componentConfig = {}
|
|
102
|
+
} = useConfig();
|
|
103
|
+
const mergedProps = mergeProps(componentConfig, props);
|
|
81
104
|
const panels = [];
|
|
82
|
-
traverseReactNode(
|
|
105
|
+
traverseReactNode(mergedProps.children, child => {
|
|
83
106
|
if (!isValidElement(child)) return;
|
|
84
107
|
const key = child.key;
|
|
85
108
|
if (typeof key !== 'string') return;
|
|
@@ -87,11 +110,11 @@ export const Collapse = props => {
|
|
|
87
110
|
});
|
|
88
111
|
const handlePropsValue = () => {
|
|
89
112
|
var _a;
|
|
90
|
-
if (!
|
|
113
|
+
if (!mergedProps.accordion) {
|
|
91
114
|
return {
|
|
92
|
-
value:
|
|
93
|
-
defaultValue: (_a =
|
|
94
|
-
onChange:
|
|
115
|
+
value: mergedProps.activeKey,
|
|
116
|
+
defaultValue: (_a = mergedProps.defaultActiveKey) !== null && _a !== void 0 ? _a : [],
|
|
117
|
+
onChange: mergedProps.onChange
|
|
95
118
|
};
|
|
96
119
|
}
|
|
97
120
|
const initValue = {
|
|
@@ -99,29 +122,29 @@ export const Collapse = props => {
|
|
|
99
122
|
defaultValue: [],
|
|
100
123
|
onChange: v => {
|
|
101
124
|
var _a, _b;
|
|
102
|
-
(_a =
|
|
125
|
+
(_a = mergedProps.onChange) === null || _a === void 0 ? void 0 : _a.call(mergedProps, (_b = v[0]) !== null && _b !== void 0 ? _b : null);
|
|
103
126
|
}
|
|
104
127
|
};
|
|
105
|
-
if (
|
|
128
|
+
if (mergedProps.activeKey === undefined) {
|
|
106
129
|
initValue.value = undefined;
|
|
107
|
-
} else if (
|
|
108
|
-
initValue.value = [
|
|
130
|
+
} else if (mergedProps.activeKey !== null) {
|
|
131
|
+
initValue.value = [mergedProps.activeKey];
|
|
109
132
|
}
|
|
110
|
-
if (![null, undefined].includes(
|
|
111
|
-
initValue.defaultValue = [
|
|
133
|
+
if (![null, undefined].includes(mergedProps.defaultActiveKey)) {
|
|
134
|
+
initValue.defaultValue = [mergedProps.defaultActiveKey];
|
|
112
135
|
}
|
|
113
136
|
return initValue;
|
|
114
137
|
};
|
|
115
138
|
const [activeKey, setActiveKey] = usePropsValue(handlePropsValue());
|
|
116
139
|
const activeKeyList = activeKey === null ? [] : Array.isArray(activeKey) ? activeKey : [activeKey];
|
|
117
|
-
return withNativeProps(
|
|
140
|
+
return withNativeProps(mergedProps, React.createElement("div", {
|
|
118
141
|
className: classPrefix
|
|
119
142
|
}, React.createElement(List, null, panels.map(panel => {
|
|
120
143
|
const key = panel.key;
|
|
121
144
|
const active = activeKeyList.includes(key);
|
|
122
145
|
function handleClick(event) {
|
|
123
146
|
var _a, _b;
|
|
124
|
-
if (
|
|
147
|
+
if (mergedProps.accordion) {
|
|
125
148
|
if (active) {
|
|
126
149
|
setActiveKey([]);
|
|
127
150
|
} else {
|
|
@@ -136,27 +159,19 @@ export const Collapse = props => {
|
|
|
136
159
|
}
|
|
137
160
|
(_b = (_a = panel.props).onClick) === null || _b === void 0 ? void 0 : _b.call(_a, event);
|
|
138
161
|
}
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
arrow
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
arrow = panel.props.arrow;
|
|
146
|
-
}
|
|
147
|
-
return typeof arrow === 'function' ? arrow(active) : React.createElement("div", {
|
|
148
|
-
className: classNames(`${classPrefix}-arrow`, {
|
|
149
|
-
[`${classPrefix}-arrow-active`]: active
|
|
150
|
-
})
|
|
151
|
-
}, arrow);
|
|
152
|
-
};
|
|
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);
|
|
153
168
|
return React.createElement(React.Fragment, {
|
|
154
169
|
key: key
|
|
155
170
|
}, withNativeProps(panel.props, React.createElement(List.Item, {
|
|
156
171
|
className: `${classPrefix}-panel-header`,
|
|
157
172
|
onClick: handleClick,
|
|
158
173
|
disabled: panel.props.disabled,
|
|
159
|
-
|
|
174
|
+
arrowIcon: arrowIcon
|
|
160
175
|
}, panel.props.title)), React.createElement(CollapsePanelContent, {
|
|
161
176
|
visible: active,
|
|
162
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>;
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import type { ReactNode } from 'react';
|
|
3
|
-
import
|
|
2
|
+
import React from 'react';
|
|
4
3
|
import { NativeProps } from '../../utils/native-props';
|
|
4
|
+
import { PopupProps } from '../popup';
|
|
5
5
|
export declare type DropdownProps = {
|
|
6
6
|
activeKey?: string | null;
|
|
7
7
|
defaultActiveKey?: string | null;
|
|
8
8
|
closeOnMaskClick?: boolean;
|
|
9
9
|
closeOnClickAway?: boolean;
|
|
10
10
|
onChange?: (key: string | null) => void;
|
|
11
|
+
arrowIcon?: ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated use `arrowIcon` instead
|
|
14
|
+
*/
|
|
11
15
|
arrow?: ReactNode;
|
|
12
16
|
getContainer?: PopupProps['getContainer'];
|
|
13
17
|
} & NativeProps;
|
|
@@ -20,6 +24,10 @@ declare const Dropdown: React.ForwardRefExoticComponent<{
|
|
|
20
24
|
closeOnMaskClick?: boolean | undefined;
|
|
21
25
|
closeOnClickAway?: boolean | undefined;
|
|
22
26
|
onChange?: ((key: string | null) => void) | undefined;
|
|
27
|
+
arrowIcon?: ReactNode;
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated use `arrowIcon` instead
|
|
30
|
+
*/
|
|
23
31
|
arrow?: ReactNode;
|
|
24
32
|
getContainer?: PopupProps['getContainer'];
|
|
25
33
|
} & {
|
|
@@ -27,6 +35,6 @@ declare const Dropdown: React.ForwardRefExoticComponent<{
|
|
|
27
35
|
style?: (React.CSSProperties & Partial<Record<never, string>>) | undefined;
|
|
28
36
|
tabIndex?: number | undefined;
|
|
29
37
|
} & React.AriaAttributes & {
|
|
30
|
-
children?:
|
|
38
|
+
children?: ReactNode;
|
|
31
39
|
} & React.RefAttributes<DropdownRef>>;
|
|
32
40
|
export default Dropdown;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { useClickAway } from 'ahooks';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
|
-
import React, { cloneElement,
|
|
4
|
-
import Popup from '../popup';
|
|
5
|
-
import { ItemChildrenWrap } from './item';
|
|
3
|
+
import React, { cloneElement, forwardRef, isValidElement, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
6
4
|
import { withNativeProps } from '../../utils/native-props';
|
|
7
|
-
import { mergeProps } from '../../utils/with-default-props';
|
|
8
5
|
import { usePropsValue } from '../../utils/use-props-value';
|
|
6
|
+
import { mergeProp, mergeProps } from '../../utils/with-default-props';
|
|
7
|
+
import { useConfig } from '../config-provider';
|
|
8
|
+
import Popup from '../popup';
|
|
9
9
|
import { defaultPopupBaseProps } from '../popup/popup-base-props';
|
|
10
|
+
import { IconContext } from './context';
|
|
11
|
+
import { ItemChildrenWrap } from './item';
|
|
10
12
|
const classPrefix = `adm-dropdown`;
|
|
11
13
|
const defaultProps = {
|
|
12
14
|
defaultActiveKey: null,
|
|
@@ -14,18 +16,22 @@ const defaultProps = {
|
|
|
14
16
|
closeOnClickAway: false,
|
|
15
17
|
getContainer: defaultPopupBaseProps['getContainer']
|
|
16
18
|
};
|
|
17
|
-
const Dropdown = forwardRef((
|
|
18
|
-
const
|
|
19
|
+
const Dropdown = forwardRef((props, ref) => {
|
|
20
|
+
const {
|
|
21
|
+
dropdown: componentConfig = {}
|
|
22
|
+
} = useConfig();
|
|
23
|
+
const mergedProps = mergeProps(defaultProps, componentConfig, props);
|
|
24
|
+
const arrowIcon = mergeProp(componentConfig.arrowIcon, props.arrow, props.arrowIcon);
|
|
19
25
|
const [value, setValue] = usePropsValue({
|
|
20
|
-
value:
|
|
21
|
-
defaultValue:
|
|
22
|
-
onChange:
|
|
26
|
+
value: mergedProps.activeKey,
|
|
27
|
+
defaultValue: mergedProps.defaultActiveKey,
|
|
28
|
+
onChange: mergedProps.onChange
|
|
23
29
|
});
|
|
24
30
|
const navRef = useRef(null);
|
|
25
31
|
const contentRef = useRef(null);
|
|
26
32
|
// 点击外部区域,关闭
|
|
27
33
|
useClickAway(() => {
|
|
28
|
-
if (!
|
|
34
|
+
if (!mergedProps.closeOnClickAway) return;
|
|
29
35
|
setValue(null);
|
|
30
36
|
}, [navRef, contentRef]);
|
|
31
37
|
// 计算 navs 的 top 值
|
|
@@ -48,7 +54,7 @@ const Dropdown = forwardRef((p, ref) => {
|
|
|
48
54
|
};
|
|
49
55
|
let popupForceRender = false;
|
|
50
56
|
const items = [];
|
|
51
|
-
const navs = React.Children.map(
|
|
57
|
+
const navs = React.Children.map(mergedProps.children, child => {
|
|
52
58
|
if (isValidElement(child)) {
|
|
53
59
|
const childProps = Object.assign(Object.assign({}, child.props), {
|
|
54
60
|
onClick: event => {
|
|
@@ -56,8 +62,7 @@ const Dropdown = forwardRef((p, ref) => {
|
|
|
56
62
|
changeActive(child.key);
|
|
57
63
|
(_b = (_a = child.props).onClick) === null || _b === void 0 ? void 0 : _b.call(_a, event);
|
|
58
64
|
},
|
|
59
|
-
active: child.key === value
|
|
60
|
-
arrow: child.props.arrow === undefined ? props.arrow : child.props.arrow
|
|
65
|
+
active: child.key === value
|
|
61
66
|
});
|
|
62
67
|
items.push(child);
|
|
63
68
|
if (child.props.forceRender) popupForceRender = true;
|
|
@@ -71,18 +76,20 @@ const Dropdown = forwardRef((p, ref) => {
|
|
|
71
76
|
setValue(null);
|
|
72
77
|
}
|
|
73
78
|
}), [setValue]);
|
|
74
|
-
return withNativeProps(
|
|
79
|
+
return withNativeProps(mergedProps, React.createElement("div", {
|
|
75
80
|
className: classNames(classPrefix, {
|
|
76
81
|
[`${classPrefix}-open`]: !!value
|
|
77
82
|
}),
|
|
78
83
|
ref: containerRef
|
|
84
|
+
}, React.createElement(IconContext.Provider, {
|
|
85
|
+
value: arrowIcon
|
|
79
86
|
}, React.createElement("div", {
|
|
80
87
|
className: `${classPrefix}-nav`,
|
|
81
88
|
ref: navRef
|
|
82
|
-
}, navs), React.createElement(Popup, {
|
|
89
|
+
}, navs)), React.createElement(Popup, {
|
|
83
90
|
visible: !!value,
|
|
84
91
|
position: 'top',
|
|
85
|
-
getContainer:
|
|
92
|
+
getContainer: mergedProps.getContainer,
|
|
86
93
|
className: `${classPrefix}-popup`,
|
|
87
94
|
maskClassName: `${classPrefix}-popup-mask`,
|
|
88
95
|
bodyClassName: `${classPrefix}-popup-body`,
|
|
@@ -90,7 +97,7 @@ const Dropdown = forwardRef((p, ref) => {
|
|
|
90
97
|
top
|
|
91
98
|
},
|
|
92
99
|
forceRender: popupForceRender,
|
|
93
|
-
onMaskClick:
|
|
100
|
+
onMaskClick: mergedProps.closeOnMaskClick ? () => {
|
|
94
101
|
changeActive(null);
|
|
95
102
|
} : undefined
|
|
96
103
|
}, React.createElement("div", {
|
|
@@ -7,6 +7,7 @@ declare const _default: import("react").ForwardRefExoticComponent<{
|
|
|
7
7
|
closeOnMaskClick?: boolean | undefined;
|
|
8
8
|
closeOnClickAway?: boolean | undefined;
|
|
9
9
|
onChange?: ((key: string | null) => void) | undefined;
|
|
10
|
+
arrowIcon?: import("react").ReactNode;
|
|
10
11
|
arrow?: import("react").ReactNode;
|
|
11
12
|
getContainer?: import("../../utils/render-to-container").GetContainer | undefined;
|
|
12
13
|
} & {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import type { FC, ReactNode } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
3
|
import { NativeProps } from '../../utils/native-props';
|
|
4
4
|
export declare type DropdownItemProps = {
|
|
5
5
|
key: string;
|
|
@@ -9,6 +9,10 @@ export declare type DropdownItemProps = {
|
|
|
9
9
|
forceRender?: boolean;
|
|
10
10
|
destroyOnClose?: boolean;
|
|
11
11
|
onClick?: (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
|
|
12
|
+
arrowIcon?: ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated use `arrowIcon` instead
|
|
15
|
+
*/
|
|
12
16
|
arrow?: ReactNode;
|
|
13
17
|
children?: ReactNode;
|
|
14
18
|
} & NativeProps;
|
|
@@ -1,27 +1,41 @@
|
|
|
1
|
+
import { DownFill } from 'antd-mobile-icons';
|
|
1
2
|
import classNames from 'classnames';
|
|
2
3
|
import React from 'react';
|
|
3
4
|
import { withNativeProps } from '../../utils/native-props';
|
|
4
5
|
import { useShouldRender } from '../../utils/should-render';
|
|
5
|
-
import {
|
|
6
|
+
import { mergeProp, mergeProps } from '../../utils/with-default-props';
|
|
7
|
+
import { useConfig } from '../config-provider';
|
|
8
|
+
import { IconContext } from './context';
|
|
6
9
|
const classPrefix = `adm-dropdown-item`;
|
|
7
10
|
const Item = props => {
|
|
8
|
-
|
|
11
|
+
const {
|
|
12
|
+
dropdown: componentConfig = {}
|
|
13
|
+
} = useConfig();
|
|
14
|
+
const mergedProps = mergeProps(componentConfig, props);
|
|
15
|
+
const {
|
|
16
|
+
active,
|
|
17
|
+
highlight,
|
|
18
|
+
onClick,
|
|
19
|
+
title
|
|
20
|
+
} = mergedProps;
|
|
9
21
|
const cls = classNames(classPrefix, {
|
|
10
|
-
[`${classPrefix}-active`]:
|
|
11
|
-
[`${classPrefix}-highlight`]:
|
|
22
|
+
[`${classPrefix}-active`]: active,
|
|
23
|
+
[`${classPrefix}-highlight`]: highlight !== null && highlight !== void 0 ? highlight : active
|
|
12
24
|
});
|
|
25
|
+
const contextArrowIcon = React.useContext(IconContext);
|
|
26
|
+
const mergedArrowIcon = mergeProp(React.createElement(DownFill, null), contextArrowIcon, mergedProps.arrow, mergedProps.arrowIcon);
|
|
13
27
|
return withNativeProps(props, React.createElement("div", {
|
|
14
28
|
className: cls,
|
|
15
|
-
onClick:
|
|
29
|
+
onClick: onClick
|
|
16
30
|
}, React.createElement("div", {
|
|
17
31
|
className: `${classPrefix}-title`
|
|
18
32
|
}, React.createElement("span", {
|
|
19
33
|
className: `${classPrefix}-title-text`
|
|
20
|
-
},
|
|
34
|
+
}, title), React.createElement("span", {
|
|
21
35
|
className: classNames(`${classPrefix}-title-arrow`, {
|
|
22
|
-
[`${classPrefix}-title-arrow-active`]:
|
|
36
|
+
[`${classPrefix}-title-arrow-active`]: active
|
|
23
37
|
})
|
|
24
|
-
},
|
|
38
|
+
}, mergedArrowIcon))));
|
|
25
39
|
};
|
|
26
40
|
export default Item;
|
|
27
41
|
export const ItemChildrenWrap = props => {
|