antd-mobile 5.36.1 → 5.37.1
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 +1260 -1138
- package/2x/bundle/antd-mobile.cjs.js +7 -7
- package/2x/bundle/antd-mobile.es.development.js +1260 -1138
- package/2x/bundle/antd-mobile.es.js +6853 -6777
- package/2x/bundle/antd-mobile.umd.development.js +1260 -1138
- package/2x/bundle/antd-mobile.umd.js +7 -7
- package/2x/bundle/style.css +50 -53
- package/2x/cjs/components/calendar-picker/calendar-picker.js +12 -6
- package/2x/cjs/components/calendar-picker-view/calendar-picker-view.d.ts +3 -0
- package/2x/cjs/components/calendar-picker-view/calendar-picker-view.js +41 -19
- package/2x/cjs/components/calendar-picker-view/useSyncScroll.d.ts +2 -0
- package/2x/cjs/components/calendar-picker-view/useSyncScroll.js +39 -0
- 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 +20 -15
- 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/calendar-picker/calendar-picker.js +11 -5
- package/2x/es/components/calendar-picker-view/calendar-picker-view.d.ts +3 -0
- package/2x/es/components/calendar-picker-view/calendar-picker-view.js +40 -19
- package/2x/es/components/calendar-picker-view/useSyncScroll.d.ts +2 -0
- package/2x/es/components/calendar-picker-view/useSyncScroll.js +33 -0
- 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 +21 -16
- 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 +1260 -1138
- package/bundle/antd-mobile.cjs.js +7 -7
- package/bundle/antd-mobile.compatible.umd.js +1 -1
- package/bundle/antd-mobile.es.development.js +1260 -1138
- package/bundle/antd-mobile.es.js +6853 -6777
- package/bundle/antd-mobile.umd.development.js +1260 -1138
- package/bundle/antd-mobile.umd.js +7 -7
- package/bundle/style.css +1 -1
- package/cjs/components/calendar-picker/calendar-picker.js +12 -6
- package/cjs/components/calendar-picker-view/calendar-picker-view.d.ts +3 -0
- package/cjs/components/calendar-picker-view/calendar-picker-view.js +41 -19
- package/cjs/components/calendar-picker-view/useSyncScroll.d.ts +2 -0
- package/cjs/components/calendar-picker-view/useSyncScroll.js +39 -0
- 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 +20 -15
- 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/calendar-picker/calendar-picker.js +11 -5
- package/es/components/calendar-picker-view/calendar-picker-view.d.ts +3 -0
- package/es/components/calendar-picker-view/calendar-picker-view.js +40 -19
- package/es/components/calendar-picker-view/useSyncScroll.d.ts +2 -0
- package/es/components/calendar-picker-view/useSyncScroll.js +33 -0
- 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 +21 -16
- 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
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useResultIcon = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _antdMobileIcons = require("antd-mobile-icons");
|
|
9
|
+
var _configProvider = require("../config-provider");
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
const useResultIcon = status => {
|
|
12
|
+
const {
|
|
13
|
+
result: componentConfig = {}
|
|
14
|
+
} = (0, _configProvider.useConfig)();
|
|
15
|
+
const {
|
|
16
|
+
successIcon = _react.default.createElement(_antdMobileIcons.CheckCircleFill, null),
|
|
17
|
+
errorIcon = _react.default.createElement(_antdMobileIcons.CloseCircleFill, null),
|
|
18
|
+
infoIcon = _react.default.createElement(_antdMobileIcons.InformationCircleFill, null),
|
|
19
|
+
waitingIcon = _react.default.createElement(_antdMobileIcons.ClockCircleFill, null),
|
|
20
|
+
warningIcon = _react.default.createElement(_antdMobileIcons.ExclamationCircleFill, null)
|
|
21
|
+
} = componentConfig || {};
|
|
22
|
+
switch (status) {
|
|
23
|
+
case 'success':
|
|
24
|
+
return successIcon;
|
|
25
|
+
case 'error':
|
|
26
|
+
return errorIcon;
|
|
27
|
+
case 'info':
|
|
28
|
+
return infoIcon;
|
|
29
|
+
case 'waiting':
|
|
30
|
+
return waitingIcon;
|
|
31
|
+
case 'warning':
|
|
32
|
+
return warningIcon;
|
|
33
|
+
default:
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
exports.useResultIcon = useResultIcon;
|
|
@@ -5,23 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.ResultPage = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _antdMobileIcons = require("antd-mobile-icons");
|
|
9
8
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
9
|
var _nativeProps = require("../../utils/native-props");
|
|
11
10
|
var _withDefaultProps = require("../../utils/with-default-props");
|
|
12
11
|
var _isNodeWithContent = require("../../utils/is-node-with-content");
|
|
13
12
|
var _button = _interopRequireDefault(require("../button"));
|
|
13
|
+
var _useResultIcon = require("../result/use-result-icon");
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
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); }
|
|
16
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
17
|
const classPrefix = `adm-result-page`;
|
|
18
|
-
const iconRecord = {
|
|
19
|
-
success: _antdMobileIcons.CheckCircleFill,
|
|
20
|
-
error: _antdMobileIcons.CloseCircleFill,
|
|
21
|
-
info: _antdMobileIcons.InformationCircleFill,
|
|
22
|
-
waiting: _antdMobileIcons.ClockCircleFill,
|
|
23
|
-
warning: _antdMobileIcons.ExclamationCircleFill
|
|
24
|
-
};
|
|
25
18
|
const defaultProps = {
|
|
26
19
|
status: 'info',
|
|
27
20
|
details: []
|
|
@@ -39,7 +32,7 @@ const ResultPage = p => {
|
|
|
39
32
|
onPrimaryButtonClick,
|
|
40
33
|
onSecondaryButtonClick
|
|
41
34
|
} = props;
|
|
42
|
-
const
|
|
35
|
+
const fallbackIcon = (0, _useResultIcon.useResultIcon)(status);
|
|
43
36
|
const [collapse, setCollapse] = (0, _react.useState)(true);
|
|
44
37
|
const showSecondaryButton = (0, _isNodeWithContent.isNodeWithContent)(secondaryButtonText);
|
|
45
38
|
const showPrimaryButton = (0, _isNodeWithContent.isNodeWithContent)(primaryButtonText);
|
|
@@ -49,7 +42,7 @@ const ResultPage = p => {
|
|
|
49
42
|
className: `${classPrefix}-header`
|
|
50
43
|
}, _react.default.createElement("div", {
|
|
51
44
|
className: `${classPrefix}-icon`
|
|
52
|
-
},
|
|
45
|
+
}, icon || fallbackIcon), _react.default.createElement("div", {
|
|
53
46
|
className: `${classPrefix}-title`
|
|
54
47
|
}, title), (0, _isNodeWithContent.isNodeWithContent)(description) ? _react.default.createElement("div", {
|
|
55
48
|
className: `${classPrefix}-description`
|
|
@@ -1,7 +1,7 @@
|
|
|
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 { InputProps, InputRef } from '../input';
|
|
5
5
|
export declare type SearchBarRef = InputRef;
|
|
6
6
|
export declare type SearchBarProps = Pick<InputProps, 'onFocus' | 'onBlur' | 'onClear' | 'onCompositionStart' | 'onCompositionEnd'> & {
|
|
7
7
|
value?: string;
|
|
@@ -12,6 +12,10 @@ export declare type SearchBarProps = Pick<InputProps, 'onFocus' | 'onBlur' | 'on
|
|
|
12
12
|
onlyShowClearWhenFocus?: boolean;
|
|
13
13
|
showCancelButton?: boolean | ((focus: boolean, value: string) => boolean);
|
|
14
14
|
cancelText?: string;
|
|
15
|
+
searchIcon?: ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated use `searchIcon` instead
|
|
18
|
+
*/
|
|
15
19
|
icon?: ReactNode;
|
|
16
20
|
clearOnCancel?: boolean;
|
|
17
21
|
onSearch?: (val: string) => void;
|
|
@@ -27,6 +31,10 @@ export declare const SearchBar: React.ForwardRefExoticComponent<Pick<InputProps,
|
|
|
27
31
|
onlyShowClearWhenFocus?: boolean | undefined;
|
|
28
32
|
showCancelButton?: boolean | ((focus: boolean, value: string) => boolean) | undefined;
|
|
29
33
|
cancelText?: string | undefined;
|
|
34
|
+
searchIcon?: ReactNode;
|
|
35
|
+
/**
|
|
36
|
+
* @deprecated use `searchIcon` instead
|
|
37
|
+
*/
|
|
30
38
|
icon?: ReactNode;
|
|
31
39
|
clearOnCancel?: boolean | undefined;
|
|
32
40
|
onSearch?: ((val: string) => void) | undefined;
|
|
@@ -4,35 +4,36 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.SearchBar = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _antdMobileIcons = require("antd-mobile-icons");
|
|
8
8
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
|
-
var
|
|
10
|
-
var _button = _interopRequireDefault(require("../button"));
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
10
|
var _nativeProps = require("../../utils/native-props");
|
|
12
|
-
var _withDefaultProps = require("../../utils/with-default-props");
|
|
13
|
-
var _antdMobileIcons = require("antd-mobile-icons");
|
|
14
11
|
var _usePropsValue = require("../../utils/use-props-value");
|
|
12
|
+
var _withDefaultProps = require("../../utils/with-default-props");
|
|
13
|
+
var _button = _interopRequireDefault(require("../button"));
|
|
15
14
|
var _configProvider = require("../config-provider");
|
|
16
|
-
|
|
15
|
+
var _input = _interopRequireDefault(require("../input"));
|
|
17
16
|
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); }
|
|
18
17
|
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; }
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
19
|
const classPrefix = `adm-search-bar`;
|
|
20
20
|
const defaultProps = {
|
|
21
21
|
clearable: true,
|
|
22
22
|
onlyShowClearWhenFocus: false,
|
|
23
23
|
showCancelButton: false,
|
|
24
24
|
defaultValue: '',
|
|
25
|
-
clearOnCancel: true
|
|
26
|
-
icon: _react.default.createElement(_antdMobileIcons.SearchOutline, null)
|
|
25
|
+
clearOnCancel: true
|
|
27
26
|
};
|
|
28
|
-
const SearchBar = (0, _react.forwardRef)((
|
|
27
|
+
const SearchBar = (0, _react.forwardRef)((props, ref) => {
|
|
29
28
|
const {
|
|
30
|
-
locale
|
|
29
|
+
locale,
|
|
30
|
+
searchBar: componentConfig = {}
|
|
31
31
|
} = (0, _configProvider.useConfig)();
|
|
32
|
-
const
|
|
32
|
+
const mergedProps = (0, _withDefaultProps.mergeProps)(defaultProps, componentConfig, {
|
|
33
33
|
cancelText: locale.common.cancel
|
|
34
|
-
},
|
|
35
|
-
const
|
|
34
|
+
}, props);
|
|
35
|
+
const searchIcon = (0, _withDefaultProps.mergeProp)(_react.default.createElement(_antdMobileIcons.SearchOutline, null), componentConfig.searchIcon, props.icon, props.searchIcon);
|
|
36
|
+
const [value, setValue] = (0, _usePropsValue.usePropsValue)(mergedProps);
|
|
36
37
|
const [hasFocus, setHasFocus] = (0, _react.useState)(false);
|
|
37
38
|
const inputRef = (0, _react.useRef)(null);
|
|
38
39
|
const composingRef = (0, _react.useRef)(false);
|
|
@@ -56,10 +57,10 @@ const SearchBar = (0, _react.forwardRef)((p, ref) => {
|
|
|
56
57
|
}));
|
|
57
58
|
const renderCancelButton = () => {
|
|
58
59
|
let isShowCancel;
|
|
59
|
-
if (typeof
|
|
60
|
-
isShowCancel =
|
|
60
|
+
if (typeof mergedProps.showCancelButton === 'function') {
|
|
61
|
+
isShowCancel = mergedProps.showCancelButton(hasFocus, value);
|
|
61
62
|
} else {
|
|
62
|
-
isShowCancel =
|
|
63
|
+
isShowCancel = mergedProps.showCancelButton && hasFocus;
|
|
63
64
|
}
|
|
64
65
|
return isShowCancel && _react.default.createElement("div", {
|
|
65
66
|
className: `${classPrefix}-suffix`
|
|
@@ -68,66 +69,66 @@ const SearchBar = (0, _react.forwardRef)((p, ref) => {
|
|
|
68
69
|
className: `${classPrefix}-cancel-button`,
|
|
69
70
|
onClick: () => {
|
|
70
71
|
var _a, _b, _c;
|
|
71
|
-
if (
|
|
72
|
+
if (mergedProps.clearOnCancel) {
|
|
72
73
|
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.clear();
|
|
73
74
|
}
|
|
74
75
|
(_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.blur();
|
|
75
|
-
(_c =
|
|
76
|
+
(_c = mergedProps.onCancel) === null || _c === void 0 ? void 0 : _c.call(mergedProps);
|
|
76
77
|
},
|
|
77
78
|
onMouseDown: e => {
|
|
78
79
|
e.preventDefault();
|
|
79
80
|
}
|
|
80
|
-
},
|
|
81
|
+
}, mergedProps.cancelText));
|
|
81
82
|
};
|
|
82
|
-
return (0, _nativeProps.withNativeProps)(
|
|
83
|
+
return (0, _nativeProps.withNativeProps)(mergedProps, _react.default.createElement("div", {
|
|
83
84
|
className: (0, _classnames.default)(classPrefix, {
|
|
84
85
|
[`${classPrefix}-active`]: hasFocus
|
|
85
86
|
})
|
|
86
87
|
}, _react.default.createElement("div", {
|
|
87
88
|
className: `${classPrefix}-input-box`
|
|
88
|
-
},
|
|
89
|
+
}, searchIcon && _react.default.createElement("div", {
|
|
89
90
|
className: `${classPrefix}-input-box-icon`
|
|
90
|
-
},
|
|
91
|
+
}, searchIcon), _react.default.createElement(_input.default, {
|
|
91
92
|
ref: inputRef,
|
|
92
93
|
className: (0, _classnames.default)(`${classPrefix}-input`, {
|
|
93
|
-
[`${classPrefix}-input-without-icon`]: !
|
|
94
|
+
[`${classPrefix}-input-without-icon`]: !searchIcon
|
|
94
95
|
}),
|
|
95
96
|
value: value,
|
|
96
97
|
onChange: setValue,
|
|
97
|
-
maxLength:
|
|
98
|
-
placeholder:
|
|
99
|
-
clearable:
|
|
100
|
-
onlyShowClearWhenFocus:
|
|
98
|
+
maxLength: mergedProps.maxLength,
|
|
99
|
+
placeholder: mergedProps.placeholder,
|
|
100
|
+
clearable: mergedProps.clearable,
|
|
101
|
+
onlyShowClearWhenFocus: mergedProps.onlyShowClearWhenFocus,
|
|
101
102
|
onFocus: e => {
|
|
102
103
|
var _a;
|
|
103
104
|
setHasFocus(true);
|
|
104
|
-
(_a =
|
|
105
|
+
(_a = mergedProps.onFocus) === null || _a === void 0 ? void 0 : _a.call(mergedProps, e);
|
|
105
106
|
},
|
|
106
107
|
onBlur: e => {
|
|
107
108
|
var _a;
|
|
108
109
|
setHasFocus(false);
|
|
109
|
-
(_a =
|
|
110
|
+
(_a = mergedProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(mergedProps, e);
|
|
110
111
|
},
|
|
111
|
-
onClear:
|
|
112
|
+
onClear: mergedProps.onClear,
|
|
112
113
|
type: 'search',
|
|
113
114
|
enterKeyHint: 'search',
|
|
114
115
|
onEnterPress: () => {
|
|
115
116
|
var _a, _b;
|
|
116
117
|
if (!composingRef.current) {
|
|
117
118
|
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.blur();
|
|
118
|
-
(_b =
|
|
119
|
+
(_b = mergedProps.onSearch) === null || _b === void 0 ? void 0 : _b.call(mergedProps, value);
|
|
119
120
|
}
|
|
120
121
|
},
|
|
121
122
|
"aria-label": locale.SearchBar.name,
|
|
122
123
|
onCompositionStart: e => {
|
|
123
124
|
var _a;
|
|
124
125
|
composingRef.current = true;
|
|
125
|
-
(_a =
|
|
126
|
+
(_a = mergedProps.onCompositionStart) === null || _a === void 0 ? void 0 : _a.call(mergedProps, e);
|
|
126
127
|
},
|
|
127
128
|
onCompositionEnd: e => {
|
|
128
129
|
var _a;
|
|
129
130
|
composingRef.current = false;
|
|
130
|
-
(_a =
|
|
131
|
+
(_a = mergedProps.onCompositionEnd) === null || _a === void 0 ? void 0 : _a.call(mergedProps, e);
|
|
131
132
|
}
|
|
132
133
|
})), renderCancelButton()));
|
|
133
134
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { FC, ReactNode } from 'react';
|
|
2
|
-
import type { MaskProps } from '../mask';
|
|
3
|
-
import { PropagationEvent } from '../../utils/with-stop-propagation';
|
|
4
2
|
import { GetContainer } from '../../utils/render-to-container';
|
|
3
|
+
import { PropagationEvent } from '../../utils/with-stop-propagation';
|
|
4
|
+
import type { MaskProps } from '../mask';
|
|
5
5
|
export interface ToastProps {
|
|
6
6
|
afterClose?: () => void;
|
|
7
7
|
maskStyle?: MaskProps['style'];
|
|
@@ -4,16 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.InternalToast = void 0;
|
|
7
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
7
|
var _antdMobileIcons = require("antd-mobile-icons");
|
|
10
|
-
var
|
|
8
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
10
|
var _withDefaultProps = require("../../utils/with-default-props");
|
|
12
11
|
var _autoCenter = _interopRequireDefault(require("../auto-center"));
|
|
12
|
+
var _mask = _interopRequireDefault(require("../mask"));
|
|
13
13
|
var _spinLoading = _interopRequireDefault(require("../spin-loading"));
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
14
|
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); }
|
|
16
15
|
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; }
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
17
|
const classPrefix = `adm-toast`;
|
|
18
18
|
const defaultProps = {
|
|
19
19
|
maskClickable: true,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import type { ReactElement } from 'react';
|
|
3
|
-
import
|
|
2
|
+
import React from 'react';
|
|
4
3
|
import { NativeProps } from '../../utils/native-props';
|
|
4
|
+
import type { InputProps } from '../input';
|
|
5
5
|
import { NumberKeyboardProps } from '../number-keyboard';
|
|
6
6
|
export declare type VirtualInputProps = {
|
|
7
7
|
onFocus?: () => void;
|
|
@@ -10,7 +10,7 @@ export declare type VirtualInputProps = {
|
|
|
10
10
|
keyboard?: ReactElement<NumberKeyboardProps>;
|
|
11
11
|
clearable?: boolean;
|
|
12
12
|
onClear?: () => void;
|
|
13
|
-
} & Pick<InputProps, 'value' | 'onChange' | 'placeholder' | 'disabled'> & NativeProps<'--font-size' | '--color' | '--placeholder-color' | '--disabled-color' | '--text-align' | '--caret-width' | '--caret-color'>;
|
|
13
|
+
} & Pick<InputProps, 'value' | 'onChange' | 'placeholder' | 'disabled' | 'clearIcon'> & NativeProps<'--font-size' | '--color' | '--placeholder-color' | '--disabled-color' | '--text-align' | '--caret-width' | '--caret-color'>;
|
|
14
14
|
export declare type VirtualInputRef = {
|
|
15
15
|
focus: () => void;
|
|
16
16
|
blur: () => void;
|
|
@@ -19,10 +19,10 @@ export declare const VirtualInput: React.ForwardRefExoticComponent<{
|
|
|
19
19
|
onFocus?: (() => void) | undefined;
|
|
20
20
|
onBlur?: (() => void) | undefined;
|
|
21
21
|
onClick?: ((e: React.MouseEvent<HTMLDivElement>) => void) | undefined;
|
|
22
|
-
keyboard?:
|
|
22
|
+
keyboard?: ReactElement<NumberKeyboardProps, string | React.JSXElementConstructor<any>> | undefined;
|
|
23
23
|
clearable?: boolean | undefined;
|
|
24
24
|
onClear?: (() => void) | undefined;
|
|
25
|
-
} & Pick<InputProps, "value" | "onChange" | "disabled" | "placeholder"> & {
|
|
25
|
+
} & Pick<InputProps, "value" | "onChange" | "disabled" | "placeholder" | "clearIcon"> & {
|
|
26
26
|
className?: string | undefined;
|
|
27
27
|
style?: (React.CSSProperties & Partial<Record<"--color" | "--font-size" | "--placeholder-color" | "--text-align" | "--disabled-color" | "--caret-width" | "--caret-color", string>>) | undefined;
|
|
28
28
|
tabIndex?: number | undefined;
|
|
@@ -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,13 +1,14 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
|
+
import classNames from 'classnames';
|
|
2
3
|
import React, { forwardRef, useRef } from 'react';
|
|
3
4
|
import { withNativeProps } from '../../utils/native-props';
|
|
4
|
-
import
|
|
5
|
+
import { mergeProps } from '../../utils/with-default-props';
|
|
5
6
|
import Button from '../button';
|
|
7
|
+
import CalendarPickerView from '../calendar-picker-view';
|
|
8
|
+
import { Context } from '../calendar-picker-view/calendar-picker-view';
|
|
9
|
+
import { useConfig } from '../config-provider';
|
|
6
10
|
import Divider from '../divider';
|
|
7
11
|
import Popup from '../popup';
|
|
8
|
-
import { mergeProps } from '../../utils/with-default-props';
|
|
9
|
-
import { useConfig } from '../config-provider';
|
|
10
|
-
import CalendarPickerView from '../calendar-picker-view';
|
|
11
12
|
const classPrefix = 'adm-calendar-picker';
|
|
12
13
|
const defaultProps = {
|
|
13
14
|
weekStartsOn: 'Sunday',
|
|
@@ -36,6 +37,9 @@ export const CalendarPicker = forwardRef((p, ref) => {
|
|
|
36
37
|
getContainer
|
|
37
38
|
} = props,
|
|
38
39
|
calendarViewProps = __rest(props, ["visible", "confirmText", "popupClassName", "popupStyle", "popupBodyStyle", "forceRender", "closeOnMaskClick", "onClose", "onConfirm", "onMaskClick", "getContainer"]);
|
|
40
|
+
const viewContext = React.useMemo(() => ({
|
|
41
|
+
visible: !!visible
|
|
42
|
+
}), [visible]);
|
|
39
43
|
const footer = React.createElement("div", {
|
|
40
44
|
className: `${classPrefix}-footer`
|
|
41
45
|
}, React.createElement(Divider, null), React.createElement("div", {
|
|
@@ -75,7 +79,9 @@ export const CalendarPicker = forwardRef((p, ref) => {
|
|
|
75
79
|
}
|
|
76
80
|
},
|
|
77
81
|
getContainer: getContainer
|
|
82
|
+
}, React.createElement(Context.Provider, {
|
|
83
|
+
value: viewContext
|
|
78
84
|
}, React.createElement(CalendarPickerView, Object.assign({
|
|
79
85
|
ref: calendarRef
|
|
80
|
-
}, calendarViewProps)), footer)));
|
|
86
|
+
}, calendarViewProps))), footer)));
|
|
81
87
|
});
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { NativeProps } from '../../utils/native-props';
|
|
3
3
|
import { DateRange, Page } from './convert';
|
|
4
|
+
export declare const Context: React.Context<{
|
|
5
|
+
visible: boolean;
|
|
6
|
+
}>;
|
|
4
7
|
export declare type CalendarPickerViewRef = {
|
|
5
8
|
jumpTo: (page: Page | ((page: Page) => Page)) => void;
|
|
6
9
|
jumpToToday: () => void;
|