antd-mobile 5.5.1 → 5.7.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/cjs/components/action-sheet/action-sheet.d.ts +5 -5
- package/2x/cjs/components/action-sheet/action-sheet.js +6 -46
- package/2x/cjs/components/action-sheet/index.d.ts +1 -1
- package/2x/cjs/components/badge/badge.js +1 -1
- package/2x/cjs/components/calendar/calendar.d.ts +4 -3
- package/2x/cjs/components/calendar/calendar.js +67 -56
- package/2x/cjs/components/calendar/convert.d.ts +2 -0
- package/2x/cjs/components/calendar/convert.js +22 -0
- package/2x/cjs/components/cascader-view/cascader-view.js +7 -0
- package/2x/cjs/components/checkbox/checkbox.js +4 -20
- package/2x/cjs/components/checkbox/native-input.d.ts +10 -0
- package/2x/cjs/components/checkbox/native-input.js +42 -0
- package/2x/cjs/components/dialog/index.d.ts +1 -1
- package/2x/cjs/components/dialog/show.d.ts +2 -4
- package/2x/cjs/components/dialog/show.js +9 -47
- package/2x/cjs/components/dot-loading/dot-loading.js +1 -2
- package/2x/cjs/components/empty/empty-icon.d.ts +3 -0
- package/2x/cjs/components/empty/empty-icon.js +37 -0
- package/2x/cjs/components/empty/empty.js +27 -15
- package/2x/cjs/components/error-block/error-block.css +1 -0
- package/2x/cjs/components/error-block/error-block.js +5 -8
- package/2x/cjs/components/error-block/images/busy.d.ts +1 -0
- package/2x/cjs/components/error-block/images/busy.js +102 -0
- package/2x/cjs/components/error-block/images/default.d.ts +1 -0
- package/2x/cjs/components/error-block/images/default.js +178 -0
- package/2x/cjs/components/error-block/images/disconnected.d.ts +1 -0
- package/2x/cjs/components/error-block/images/disconnected.js +135 -0
- package/2x/cjs/components/error-block/images/empty.d.ts +1 -0
- package/2x/cjs/components/error-block/images/empty.js +131 -0
- package/2x/cjs/components/error-block/images/index.d.ts +2 -0
- package/2x/cjs/components/error-block/images/index.js +22 -0
- package/2x/cjs/components/floating-bubble/floating-bubble.css +2 -1
- package/2x/cjs/components/floating-bubble/floating-bubble.d.ts +1 -1
- package/2x/cjs/components/form/form-item.d.ts +1 -1
- package/2x/cjs/components/form/form-item.js +4 -1
- package/2x/cjs/components/image-viewer/index.d.ts +1 -1
- package/2x/cjs/components/image-viewer/methods.d.ts +3 -7
- package/2x/cjs/components/image-viewer/methods.js +13 -79
- package/2x/cjs/components/modal/index.d.ts +1 -1
- package/2x/cjs/components/modal/show.d.ts +2 -4
- package/2x/cjs/components/modal/show.js +9 -47
- package/2x/cjs/components/picker/picker.js +6 -9
- package/2x/cjs/components/picker-view/columns-extend.d.ts +3 -0
- package/2x/cjs/components/picker-view/columns-extend.js +45 -0
- package/2x/cjs/components/picker-view/picker-view.d.ts +1 -0
- package/2x/cjs/components/picker-view/picker-view.js +14 -16
- package/2x/cjs/components/popover/popover.css +1 -0
- package/2x/cjs/components/popover/popover.js +1 -0
- package/2x/cjs/components/popover/temp-floating-ui.min.js +1 -430
- package/2x/cjs/components/radio/radio.js +4 -20
- package/2x/cjs/components/search-bar/search-bar.d.ts +1 -1
- package/2x/cjs/components/tab-bar/tab-bar.d.ts +1 -1
- package/2x/cjs/components/tab-bar/tab-bar.js +1 -1
- package/2x/cjs/components/tree-select/tree-select.js +2 -2
- package/2x/cjs/utils/render-imperatively.d.ts +10 -0
- package/2x/cjs/utils/render-imperatively.js +68 -0
- package/2x/cjs/utils/with-cache.d.ts +1 -0
- package/2x/cjs/utils/with-cache.js +17 -0
- package/2x/es/components/action-sheet/action-sheet.d.ts +5 -5
- package/2x/es/components/action-sheet/action-sheet.js +5 -41
- package/2x/es/components/action-sheet/index.d.ts +1 -1
- package/2x/es/components/badge/badge.js +1 -1
- package/2x/es/components/calendar/calendar.d.ts +4 -3
- package/2x/es/components/calendar/calendar.js +67 -58
- package/2x/es/components/calendar/convert.d.ts +2 -0
- package/2x/es/components/calendar/convert.js +15 -0
- package/2x/es/components/cascader-view/cascader-view.js +7 -0
- package/2x/es/components/checkbox/checkbox.js +4 -21
- package/2x/es/components/checkbox/native-input.d.ts +10 -0
- package/2x/es/components/checkbox/native-input.js +28 -0
- package/2x/es/components/dialog/index.d.ts +1 -1
- package/2x/es/components/dialog/show.d.ts +2 -4
- package/2x/es/components/dialog/show.js +8 -44
- package/2x/es/components/dot-loading/dot-loading.js +1 -2
- package/2x/es/components/empty/empty-icon.d.ts +3 -0
- package/2x/es/components/empty/empty-icon.js +24 -0
- package/2x/es/components/empty/empty.js +27 -14
- package/2x/es/components/error-block/error-block.css +1 -0
- package/2x/es/components/error-block/error-block.js +4 -6
- package/2x/es/components/error-block/images/busy.d.ts +1 -0
- package/2x/es/components/error-block/images/busy.js +90 -0
- package/2x/es/components/error-block/images/default.d.ts +1 -0
- package/2x/es/components/error-block/images/default.js +166 -0
- package/2x/es/components/error-block/images/disconnected.d.ts +1 -0
- package/2x/es/components/error-block/images/disconnected.js +123 -0
- package/2x/es/components/error-block/images/empty.d.ts +1 -0
- package/2x/es/components/error-block/images/empty.js +119 -0
- package/2x/es/components/error-block/images/index.d.ts +2 -0
- package/2x/es/components/error-block/images/index.js +10 -0
- package/2x/es/components/floating-bubble/floating-bubble.css +2 -1
- package/2x/es/components/floating-bubble/floating-bubble.d.ts +1 -1
- package/2x/es/components/form/form-item.d.ts +1 -1
- package/2x/es/components/form/form-item.js +4 -1
- package/2x/es/components/image-viewer/index.d.ts +1 -1
- package/2x/es/components/image-viewer/methods.d.ts +3 -7
- package/2x/es/components/image-viewer/methods.js +12 -75
- package/2x/es/components/modal/index.d.ts +1 -1
- package/2x/es/components/modal/show.d.ts +2 -4
- package/2x/es/components/modal/show.js +8 -44
- package/2x/es/components/picker/picker.js +6 -8
- package/2x/es/components/picker-view/columns-extend.d.ts +3 -0
- package/2x/es/components/picker-view/columns-extend.js +34 -0
- package/2x/es/components/picker-view/picker-view.d.ts +1 -0
- package/2x/es/components/picker-view/picker-view.js +14 -15
- package/2x/es/components/popover/popover.css +1 -0
- package/2x/es/components/popover/popover.js +1 -0
- package/2x/es/components/popover/temp-floating-ui.min.js +1 -430
- package/2x/es/components/radio/radio.js +4 -21
- package/2x/es/components/search-bar/search-bar.d.ts +1 -1
- package/2x/es/components/tab-bar/tab-bar.d.ts +1 -1
- package/2x/es/components/tab-bar/tab-bar.js +1 -1
- package/2x/es/components/tree-select/tree-select.js +2 -2
- package/2x/es/utils/render-imperatively.d.ts +10 -0
- package/2x/es/utils/render-imperatively.js +53 -0
- package/2x/es/utils/with-cache.d.ts +1 -0
- package/2x/es/utils/with-cache.js +10 -0
- package/2x/package.json +2 -3
- package/cjs/components/action-sheet/action-sheet.d.ts +5 -5
- package/cjs/components/action-sheet/action-sheet.js +6 -46
- package/cjs/components/action-sheet/index.d.ts +1 -1
- package/cjs/components/badge/badge.js +1 -1
- package/cjs/components/calendar/calendar.d.ts +4 -3
- package/cjs/components/calendar/calendar.js +67 -56
- package/cjs/components/calendar/convert.d.ts +2 -0
- package/cjs/components/calendar/convert.js +22 -0
- package/cjs/components/cascader-view/cascader-view.js +7 -0
- package/cjs/components/checkbox/checkbox.js +4 -20
- package/cjs/components/checkbox/native-input.d.ts +10 -0
- package/cjs/components/checkbox/native-input.js +42 -0
- package/cjs/components/dialog/index.d.ts +1 -1
- package/cjs/components/dialog/show.d.ts +2 -4
- package/cjs/components/dialog/show.js +9 -47
- package/cjs/components/dot-loading/dot-loading.js +1 -2
- package/cjs/components/empty/empty-icon.d.ts +3 -0
- package/cjs/components/empty/empty-icon.js +37 -0
- package/cjs/components/empty/empty.js +27 -15
- package/cjs/components/error-block/error-block.css +1 -0
- package/cjs/components/error-block/error-block.js +5 -8
- package/cjs/components/error-block/images/busy.d.ts +1 -0
- package/cjs/components/error-block/images/busy.js +102 -0
- package/cjs/components/error-block/images/default.d.ts +1 -0
- package/cjs/components/error-block/images/default.js +178 -0
- package/cjs/components/error-block/images/disconnected.d.ts +1 -0
- package/cjs/components/error-block/images/disconnected.js +135 -0
- package/cjs/components/error-block/images/empty.d.ts +1 -0
- package/cjs/components/error-block/images/empty.js +131 -0
- package/cjs/components/error-block/images/index.d.ts +2 -0
- package/cjs/components/error-block/images/index.js +22 -0
- package/cjs/components/floating-bubble/floating-bubble.css +2 -1
- package/cjs/components/floating-bubble/floating-bubble.d.ts +1 -1
- package/cjs/components/form/form-item.d.ts +1 -1
- package/cjs/components/form/form-item.js +4 -1
- package/cjs/components/image-viewer/index.d.ts +1 -1
- package/cjs/components/image-viewer/methods.d.ts +3 -7
- package/cjs/components/image-viewer/methods.js +13 -79
- package/cjs/components/modal/index.d.ts +1 -1
- package/cjs/components/modal/show.d.ts +2 -4
- package/cjs/components/modal/show.js +9 -47
- package/cjs/components/picker/picker.js +6 -9
- package/cjs/components/picker-view/columns-extend.d.ts +3 -0
- package/cjs/components/picker-view/columns-extend.js +45 -0
- package/cjs/components/picker-view/picker-view.d.ts +1 -0
- package/cjs/components/picker-view/picker-view.js +14 -16
- package/cjs/components/popover/popover.css +1 -0
- package/cjs/components/popover/popover.js +1 -0
- package/cjs/components/popover/temp-floating-ui.min.js +1 -430
- package/cjs/components/radio/radio.js +4 -20
- package/cjs/components/search-bar/search-bar.d.ts +1 -1
- package/cjs/components/tab-bar/tab-bar.d.ts +1 -1
- package/cjs/components/tab-bar/tab-bar.js +1 -1
- package/cjs/components/tree-select/tree-select.js +2 -2
- package/cjs/utils/render-imperatively.d.ts +10 -0
- package/cjs/utils/render-imperatively.js +68 -0
- package/cjs/utils/with-cache.d.ts +1 -0
- package/cjs/utils/with-cache.js +17 -0
- package/es/components/action-sheet/action-sheet.d.ts +5 -5
- package/es/components/action-sheet/action-sheet.js +5 -41
- package/es/components/action-sheet/index.d.ts +1 -1
- package/es/components/badge/badge.js +1 -1
- package/es/components/calendar/calendar.d.ts +4 -3
- package/es/components/calendar/calendar.js +67 -58
- package/es/components/calendar/convert.d.ts +2 -0
- package/es/components/calendar/convert.js +15 -0
- package/es/components/cascader-view/cascader-view.js +7 -0
- package/es/components/checkbox/checkbox.js +4 -21
- package/es/components/checkbox/native-input.d.ts +10 -0
- package/es/components/checkbox/native-input.js +28 -0
- package/es/components/dialog/index.d.ts +1 -1
- package/es/components/dialog/show.d.ts +2 -4
- package/es/components/dialog/show.js +8 -44
- package/es/components/dot-loading/dot-loading.js +1 -2
- package/es/components/empty/empty-icon.d.ts +3 -0
- package/es/components/empty/empty-icon.js +24 -0
- package/es/components/empty/empty.js +27 -14
- package/es/components/error-block/error-block.css +1 -0
- package/es/components/error-block/error-block.js +4 -6
- package/es/components/error-block/images/busy.d.ts +1 -0
- package/es/components/error-block/images/busy.js +90 -0
- package/es/components/error-block/images/default.d.ts +1 -0
- package/es/components/error-block/images/default.js +166 -0
- package/es/components/error-block/images/disconnected.d.ts +1 -0
- package/es/components/error-block/images/disconnected.js +123 -0
- package/es/components/error-block/images/empty.d.ts +1 -0
- package/es/components/error-block/images/empty.js +119 -0
- package/es/components/error-block/images/index.d.ts +2 -0
- package/es/components/error-block/images/index.js +10 -0
- package/es/components/floating-bubble/floating-bubble.css +2 -1
- package/es/components/floating-bubble/floating-bubble.d.ts +1 -1
- package/es/components/form/form-item.d.ts +1 -1
- package/es/components/form/form-item.js +4 -1
- package/es/components/image-viewer/index.d.ts +1 -1
- package/es/components/image-viewer/methods.d.ts +3 -7
- package/es/components/image-viewer/methods.js +12 -75
- package/es/components/modal/index.d.ts +1 -1
- package/es/components/modal/show.d.ts +2 -4
- package/es/components/modal/show.js +8 -44
- package/es/components/picker/picker.js +6 -8
- package/es/components/picker-view/columns-extend.d.ts +3 -0
- package/es/components/picker-view/columns-extend.js +34 -0
- package/es/components/picker-view/picker-view.d.ts +1 -0
- package/es/components/picker-view/picker-view.js +14 -15
- package/es/components/popover/popover.css +1 -0
- package/es/components/popover/popover.js +1 -0
- package/es/components/popover/temp-floating-ui.min.js +1 -430
- package/es/components/radio/radio.js +4 -21
- package/es/components/search-bar/search-bar.d.ts +1 -1
- package/es/components/tab-bar/tab-bar.d.ts +1 -1
- package/es/components/tab-bar/tab-bar.js +1 -1
- package/es/components/tree-select/tree-select.js +2 -2
- package/es/utils/render-imperatively.d.ts +10 -0
- package/es/utils/render-imperatively.js +53 -0
- package/es/utils/with-cache.d.ts +1 -0
- package/es/utils/with-cache.js +10 -0
- package/package.json +2 -3
- package/umd/antd-mobile.js +1 -1
- package/2x/assets/busy.svg +0 -42
- package/2x/assets/default.svg +0 -53
- package/2x/assets/disconnected.svg +0 -60
- package/2x/assets/empty-icon.svg +0 -18
- package/2x/assets/empty.svg +0 -52
- package/2x/cjs/assets/busy.svg +0 -42
- package/2x/cjs/assets/default.svg +0 -53
- package/2x/cjs/assets/disconnected.svg +0 -60
- package/2x/cjs/assets/empty-icon.svg +0 -18
- package/2x/cjs/assets/empty.svg +0 -52
- package/2x/cjs/components/error-block/error.d.ts +0 -1
- package/2x/cjs/components/error-block/error.js +0 -24
- package/2x/cjs/components/picker-view/use-columns.d.ts +0 -2
- package/2x/cjs/components/picker-view/use-columns.js +0 -18
- package/2x/cjs/components/picker-view/use-picker-value-extend.d.ts +0 -2
- package/2x/cjs/components/picker-view/use-picker-value-extend.js +0 -37
- package/2x/es/assets/busy.svg +0 -42
- package/2x/es/assets/default.svg +0 -53
- package/2x/es/assets/disconnected.svg +0 -60
- package/2x/es/assets/empty-icon.svg +0 -18
- package/2x/es/assets/empty.svg +0 -52
- package/2x/es/components/error-block/error.d.ts +0 -1
- package/2x/es/components/error-block/error.js +0 -10
- package/2x/es/components/picker-view/use-columns.d.ts +0 -2
- package/2x/es/components/picker-view/use-columns.js +0 -10
- package/2x/es/components/picker-view/use-picker-value-extend.d.ts +0 -2
- package/2x/es/components/picker-view/use-picker-value-extend.js +0 -26
- package/assets/busy.svg +0 -42
- package/assets/default.svg +0 -53
- package/assets/disconnected.svg +0 -60
- package/assets/empty-icon.svg +0 -18
- package/assets/empty.svg +0 -52
- package/cjs/assets/busy.svg +0 -42
- package/cjs/assets/default.svg +0 -53
- package/cjs/assets/disconnected.svg +0 -60
- package/cjs/assets/empty-icon.svg +0 -18
- package/cjs/assets/empty.svg +0 -52
- package/cjs/components/error-block/error.d.ts +0 -1
- package/cjs/components/error-block/error.js +0 -24
- package/cjs/components/picker-view/use-columns.d.ts +0 -2
- package/cjs/components/picker-view/use-columns.js +0 -18
- package/cjs/components/picker-view/use-picker-value-extend.d.ts +0 -2
- package/cjs/components/picker-view/use-picker-value-extend.js +0 -37
- package/es/assets/busy.svg +0 -42
- package/es/assets/default.svg +0 -53
- package/es/assets/disconnected.svg +0 -60
- package/es/assets/empty-icon.svg +0 -18
- package/es/assets/empty.svg +0 -52
- package/es/components/error-block/error.d.ts +0 -1
- package/es/components/error-block/error.js +0 -10
- package/es/components/picker-view/use-columns.d.ts +0 -2
- package/es/components/picker-view/use-columns.js +0 -10
- package/es/components/picker-view/use-picker-value-extend.d.ts +0 -2
- package/es/components/picker-view/use-picker-value-extend.js +0 -26
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { withNativeProps } from '../../utils/native-props';
|
|
3
3
|
import { mergeProps } from '../../utils/with-default-props';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
import Popup from '../popup';
|
|
6
6
|
import Button from '../button';
|
|
7
|
-
import { renderToBody } from '../../utils/render-to-body';
|
|
8
7
|
import SafeArea from '../safe-area';
|
|
8
|
+
import { renderImperatively } from '../../utils/render-imperatively';
|
|
9
9
|
const classPrefix = `adm-action-sheet`;
|
|
10
10
|
const defaultProps = {
|
|
11
11
|
visible: false,
|
|
@@ -29,7 +29,8 @@ export const ActionSheet = p => {
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
afterClose: props.afterClose,
|
|
32
|
-
className: `${classPrefix}-popup`,
|
|
32
|
+
className: classNames(`${classPrefix}-popup`, props.popupClassName),
|
|
33
|
+
style: props.popupStyle,
|
|
33
34
|
getContainer: props.getContainer
|
|
34
35
|
}, withNativeProps(props, React.createElement("div", {
|
|
35
36
|
className: classPrefix
|
|
@@ -83,42 +84,5 @@ export const ActionSheet = p => {
|
|
|
83
84
|
}))));
|
|
84
85
|
};
|
|
85
86
|
export function showActionSheet(props) {
|
|
86
|
-
|
|
87
|
-
const [visible, setVisible] = useState(false);
|
|
88
|
-
useEffect(() => {
|
|
89
|
-
setVisible(true);
|
|
90
|
-
}, []);
|
|
91
|
-
|
|
92
|
-
function handleClose() {
|
|
93
|
-
var _a;
|
|
94
|
-
|
|
95
|
-
(_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
96
|
-
setVisible(false);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
useImperativeHandle(ref, () => ({
|
|
100
|
-
close: handleClose
|
|
101
|
-
}));
|
|
102
|
-
return React.createElement(ActionSheet, Object.assign({}, props, {
|
|
103
|
-
visible: visible,
|
|
104
|
-
onClose: handleClose,
|
|
105
|
-
afterClose: () => {
|
|
106
|
-
var _a;
|
|
107
|
-
|
|
108
|
-
(_a = props.afterClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
109
|
-
unmount();
|
|
110
|
-
}
|
|
111
|
-
}));
|
|
112
|
-
});
|
|
113
|
-
const ref = createRef();
|
|
114
|
-
const unmount = renderToBody(React.createElement(Wrapper, {
|
|
115
|
-
ref: ref
|
|
116
|
-
}));
|
|
117
|
-
return {
|
|
118
|
-
close: () => {
|
|
119
|
-
var _a;
|
|
120
|
-
|
|
121
|
-
(_a = ref.current) === null || _a === void 0 ? void 0 : _a.close();
|
|
122
|
-
}
|
|
123
|
-
};
|
|
87
|
+
return renderImperatively(React.createElement(ActionSheet, Object.assign({}, props)));
|
|
124
88
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import './action-sheet.less';
|
|
3
3
|
import { showActionSheet } from './action-sheet';
|
|
4
|
-
export type { Action, ActionSheetProps,
|
|
4
|
+
export type { Action, ActionSheetProps, ActionSheetShowHandler, } from './action-sheet';
|
|
5
5
|
declare const _default: import("react").FC<import("./action-sheet").ActionSheetProps> & {
|
|
6
6
|
show: typeof showActionSheet;
|
|
7
7
|
};
|
|
@@ -11,7 +11,7 @@ export const Badge = props => {
|
|
|
11
11
|
} = props;
|
|
12
12
|
const isDot = content === dot;
|
|
13
13
|
const badgeCls = classNames(classPrefix, !!children && `${classPrefix}-fixed`, isDot && `${classPrefix}-dot`, props.bordered && `${classPrefix}-bordered`);
|
|
14
|
-
const element = content ? withNativeProps(props, React.createElement("div", {
|
|
14
|
+
const element = content || content === 0 ? withNativeProps(props, React.createElement("div", {
|
|
15
15
|
className: badgeCls,
|
|
16
16
|
style: {
|
|
17
17
|
'--color': color
|
|
@@ -9,9 +9,10 @@ export declare type CalenderRef = {
|
|
|
9
9
|
jumpToToday: () => void;
|
|
10
10
|
};
|
|
11
11
|
export declare type CalendarProps = {
|
|
12
|
+
onPageChange?: (year: number, month: number) => void;
|
|
12
13
|
weekStartsOn?: 'Monday' | 'Sunday';
|
|
13
14
|
renderLabel?: (date: Date) => string | null | undefined;
|
|
14
|
-
|
|
15
|
+
allowClear?: boolean;
|
|
15
16
|
} & ({
|
|
16
17
|
selectionMode?: undefined;
|
|
17
18
|
value?: undefined;
|
|
@@ -21,12 +22,12 @@ export declare type CalendarProps = {
|
|
|
21
22
|
selectionMode: 'single';
|
|
22
23
|
value?: Date | null;
|
|
23
24
|
defaultValue?: Date | null;
|
|
24
|
-
onChange?: (val: Date) => void;
|
|
25
|
+
onChange?: (val: Date | null) => void;
|
|
25
26
|
} | {
|
|
26
27
|
selectionMode: 'range';
|
|
27
28
|
value?: [Date, Date] | null;
|
|
28
29
|
defaultValue?: [Date, Date] | null;
|
|
29
|
-
onChange?: (val: [Date, Date]) => void;
|
|
30
|
+
onChange?: (val: [Date, Date] | null) => void;
|
|
30
31
|
}) & NativeProps;
|
|
31
32
|
export declare const Calendar: React.ForwardRefExoticComponent<CalendarProps & React.RefAttributes<CalenderRef>>;
|
|
32
33
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { forwardRef,
|
|
1
|
+
import React, { forwardRef, useState, useImperativeHandle } from 'react';
|
|
2
2
|
import { withNativeProps } from '../../utils/native-props';
|
|
3
3
|
import dayjs from 'dayjs';
|
|
4
4
|
import classNames from 'classnames';
|
|
@@ -7,11 +7,15 @@ import { ArrowLeft } from './arrow-left';
|
|
|
7
7
|
import { ArrowLeftDouble } from './arrow-left-double';
|
|
8
8
|
import { useConfig } from '../config-provider';
|
|
9
9
|
import isoWeek from 'dayjs/plugin/isoWeek';
|
|
10
|
-
import {
|
|
10
|
+
import { useUpdateEffect } from 'ahooks';
|
|
11
|
+
import { usePropsValue } from '../../utils/use-props-value';
|
|
12
|
+
import { convertValueToRange } from './convert';
|
|
11
13
|
dayjs.extend(isoWeek);
|
|
12
14
|
const classPrefix = 'adm-calendar';
|
|
13
15
|
const defaultProps = {
|
|
14
|
-
weekStartsOn: 'Sunday'
|
|
16
|
+
weekStartsOn: 'Sunday',
|
|
17
|
+
defaultValue: null,
|
|
18
|
+
allowClear: true
|
|
15
19
|
};
|
|
16
20
|
export const Calendar = forwardRef((p, ref) => {
|
|
17
21
|
const today = dayjs();
|
|
@@ -26,29 +30,21 @@ export const Calendar = forwardRef((p, ref) => {
|
|
|
26
30
|
if (item) markItems.unshift(item);
|
|
27
31
|
}
|
|
28
32
|
|
|
29
|
-
const dateRange =
|
|
30
|
-
|
|
33
|
+
const [dateRange, setDateRange] = usePropsValue({
|
|
34
|
+
value: props.value === undefined ? undefined : convertValueToRange(props.selectionMode, props.value),
|
|
35
|
+
defaultValue: convertValueToRange(props.selectionMode, props.defaultValue),
|
|
36
|
+
onChange: v => {
|
|
37
|
+
var _a, _b;
|
|
31
38
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
} else {
|
|
38
|
-
return [null, null];
|
|
39
|
+
if (props.selectionMode === 'single') {
|
|
40
|
+
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, v ? v[0] : null);
|
|
41
|
+
} else if (props.selectionMode === 'range') {
|
|
42
|
+
(_b = props.onChange) === null || _b === void 0 ? void 0 : _b.call(props, v);
|
|
43
|
+
}
|
|
39
44
|
}
|
|
40
|
-
}, [props.selectionMode, props.value, props.defaultValue]);
|
|
41
|
-
const [begin, setBegin] = useState(null);
|
|
42
|
-
const [end, setEnd] = useState(null);
|
|
43
|
-
useIsomorphicLayoutEffect(() => {
|
|
44
|
-
setBegin(dateRange[0] ? dayjs(dateRange[0]) : null);
|
|
45
|
-
setEnd(dateRange[1] ? dayjs(dateRange[1]) : null);
|
|
46
|
-
}, [dateRange[0], dateRange[1]]);
|
|
47
|
-
const [current, setCurrent] = useState(() => {
|
|
48
|
-
var _a;
|
|
49
|
-
|
|
50
|
-
return dayjs((_a = dateRange[0]) !== null && _a !== void 0 ? _a : today).date(1);
|
|
51
45
|
});
|
|
46
|
+
const [intermediate, setIntermediate] = useState(false);
|
|
47
|
+
const [current, setCurrent] = useState(() => dayjs(dateRange ? dateRange[0] : today).date(1));
|
|
52
48
|
useUpdateEffect(() => {
|
|
53
49
|
var _a;
|
|
54
50
|
|
|
@@ -111,14 +107,16 @@ export const Calendar = forwardRef((p, ref) => {
|
|
|
111
107
|
|
|
112
108
|
while (cells.length < 6 * 7) {
|
|
113
109
|
const d = iterator;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
110
|
+
let isSelect = false;
|
|
111
|
+
let isBegin = false;
|
|
112
|
+
let isEnd = false;
|
|
113
|
+
|
|
114
|
+
if (dateRange) {
|
|
115
|
+
const [begin, end] = dateRange;
|
|
116
|
+
isBegin = d.isSame(begin, 'day');
|
|
117
|
+
isEnd = d.isSame(end, 'day');
|
|
118
|
+
isSelect = isBegin || isEnd || d.isAfter(begin, 'day') && d.isBefore(end, 'day');
|
|
119
|
+
}
|
|
122
120
|
|
|
123
121
|
const inThisMonth = d.month() === current.month();
|
|
124
122
|
cells.push(React.createElement("div", {
|
|
@@ -126,41 +124,52 @@ export const Calendar = forwardRef((p, ref) => {
|
|
|
126
124
|
className: classNames(`${classPrefix}-cell`, inThisMonth ? `${classPrefix}-cell-in` : `${classPrefix}-cell-out`, inThisMonth && {
|
|
127
125
|
[`${classPrefix}-cell-today`]: d.isSame(today, 'day'),
|
|
128
126
|
[`${classPrefix}-cell-selected`]: isSelect,
|
|
129
|
-
[`${classPrefix}-cell-selected-begin`]:
|
|
130
|
-
[`${classPrefix}-cell-selected-end`]:
|
|
127
|
+
[`${classPrefix}-cell-selected-begin`]: isBegin,
|
|
128
|
+
[`${classPrefix}-cell-selected-end`]: isEnd
|
|
131
129
|
}),
|
|
132
130
|
onClick: () => {
|
|
133
|
-
var _a, _b, _c;
|
|
134
|
-
|
|
135
131
|
if (!props.selectionMode) return;
|
|
132
|
+
const date = d.toDate();
|
|
133
|
+
|
|
134
|
+
if (!inThisMonth) {
|
|
135
|
+
setCurrent(d.clone().date(1));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function shouldClear() {
|
|
139
|
+
if (!props.allowClear) return false;
|
|
140
|
+
if (!dateRange) return false;
|
|
141
|
+
const [begin, end] = dateRange;
|
|
142
|
+
return d.isSame(begin, 'date') && d.isSame(end, 'day');
|
|
143
|
+
}
|
|
136
144
|
|
|
137
145
|
if (props.selectionMode === 'single') {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
146
|
+
if (props.allowClear && shouldClear()) {
|
|
147
|
+
setDateRange(null);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
setDateRange([date, date]);
|
|
141
152
|
} else if (props.selectionMode === 'range') {
|
|
142
|
-
if (
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
} else {
|
|
147
|
-
if (d.isBefore(begin)) {
|
|
148
|
-
setEnd(begin);
|
|
149
|
-
setBegin(d);
|
|
150
|
-
(_b = props.onChange) === null || _b === void 0 ? void 0 : _b.call(props, [d.toDate(), begin.toDate()]);
|
|
151
|
-
} else {
|
|
152
|
-
setEnd(d);
|
|
153
|
-
(_c = props.onChange) === null || _c === void 0 ? void 0 : _c.call(props, [begin.toDate(), d.toDate()]);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
} else {
|
|
157
|
-
setBegin(d);
|
|
158
|
-
setEnd(null);
|
|
153
|
+
if (!dateRange) {
|
|
154
|
+
setDateRange([date, date]);
|
|
155
|
+
setIntermediate(true);
|
|
156
|
+
return;
|
|
159
157
|
}
|
|
160
|
-
}
|
|
161
158
|
|
|
162
|
-
|
|
163
|
-
|
|
159
|
+
if (shouldClear()) {
|
|
160
|
+
setDateRange(null);
|
|
161
|
+
setIntermediate(false);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (intermediate) {
|
|
166
|
+
const another = dateRange[0];
|
|
167
|
+
setDateRange(another > date ? [date, another] : [another, date]);
|
|
168
|
+
setIntermediate(false);
|
|
169
|
+
} else {
|
|
170
|
+
setDateRange([date, date]);
|
|
171
|
+
setIntermediate(true);
|
|
172
|
+
}
|
|
164
173
|
}
|
|
165
174
|
}
|
|
166
175
|
}, React.createElement("div", {
|
|
@@ -61,6 +61,13 @@ export const CascaderView = p => {
|
|
|
61
61
|
useEffect(() => {
|
|
62
62
|
setTabActiveKey(levels.length - 1);
|
|
63
63
|
}, [value]);
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
const max = levels.length - 1;
|
|
66
|
+
|
|
67
|
+
if (tabActiveKey > max) {
|
|
68
|
+
setTabActiveKey(max);
|
|
69
|
+
}
|
|
70
|
+
}, [tabActiveKey, levels]);
|
|
64
71
|
|
|
65
72
|
const onItemSelect = (selectValue, depth) => {
|
|
66
73
|
const next = value.slice(0, depth);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useContext
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
2
|
import { withNativeProps } from '../../utils/native-props';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { CheckboxGroupContext } from './group-context';
|
|
@@ -8,6 +8,7 @@ import { devWarning } from '../../utils/dev-log';
|
|
|
8
8
|
import { CheckIcon } from './check-icon';
|
|
9
9
|
import { IndeterminateIcon } from './indeterminate-icon';
|
|
10
10
|
import { isDev } from '../../utils/is-dev';
|
|
11
|
+
import { NativeInput } from './native-input';
|
|
11
12
|
const classPrefix = `adm-checkbox`;
|
|
12
13
|
const defaultProps = {
|
|
13
14
|
defaultChecked: false,
|
|
@@ -66,35 +67,17 @@ export const Checkbox = p => {
|
|
|
66
67
|
}, props.indeterminate ? React.createElement(IndeterminateIcon, null) : checked && React.createElement(CheckIcon, null));
|
|
67
68
|
};
|
|
68
69
|
|
|
69
|
-
const inputRef = useRef(null);
|
|
70
|
-
const labelRef = useRef(null);
|
|
71
|
-
useEffect(() => {
|
|
72
|
-
var _a;
|
|
73
|
-
|
|
74
|
-
(_a = labelRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('click', e => {
|
|
75
|
-
if (e.target !== inputRef.current) {
|
|
76
|
-
e.stopPropagation();
|
|
77
|
-
e.stopImmediatePropagation();
|
|
78
|
-
}
|
|
79
|
-
}, {
|
|
80
|
-
capture: false
|
|
81
|
-
});
|
|
82
|
-
}, []);
|
|
83
70
|
return withNativeProps(props, React.createElement("label", {
|
|
84
|
-
ref: labelRef,
|
|
85
71
|
className: classNames(classPrefix, {
|
|
86
72
|
[`${classPrefix}-checked`]: checked && !props.indeterminate,
|
|
87
73
|
[`${classPrefix}-indeterminate`]: props.indeterminate,
|
|
88
74
|
[`${classPrefix}-disabled`]: disabled,
|
|
89
75
|
[`${classPrefix}-block`]: props.block
|
|
90
76
|
})
|
|
91
|
-
}, React.createElement(
|
|
92
|
-
ref: inputRef,
|
|
77
|
+
}, React.createElement(NativeInput, {
|
|
93
78
|
type: 'checkbox',
|
|
94
79
|
checked: checked,
|
|
95
|
-
onChange:
|
|
96
|
-
setChecked(e.target.checked);
|
|
97
|
-
},
|
|
80
|
+
onChange: setChecked,
|
|
98
81
|
disabled: disabled,
|
|
99
82
|
id: props.id
|
|
100
83
|
}), renderIcon(), props.children && React.createElement("div", {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
export const NativeInput = props => {
|
|
3
|
+
const inputRef = useRef(null);
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
if (props.disabled) return;
|
|
6
|
+
if (!inputRef.current) return;
|
|
7
|
+
const input = inputRef.current;
|
|
8
|
+
|
|
9
|
+
function handleClick(e) {
|
|
10
|
+
e.stopPropagation();
|
|
11
|
+
e.stopImmediatePropagation();
|
|
12
|
+
props.onChange(input.checked);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
input.addEventListener('click', handleClick);
|
|
16
|
+
return () => {
|
|
17
|
+
input.removeEventListener('click', handleClick);
|
|
18
|
+
};
|
|
19
|
+
}, [props.disabled, props.onChange]);
|
|
20
|
+
return React.createElement("input", {
|
|
21
|
+
ref: inputRef,
|
|
22
|
+
type: 'checkbox',
|
|
23
|
+
checked: props.checked,
|
|
24
|
+
onChange: () => {},
|
|
25
|
+
disabled: props.disabled,
|
|
26
|
+
id: props.id
|
|
27
|
+
});
|
|
28
|
+
};
|
|
@@ -6,7 +6,7 @@ import { confirm } from './confirm';
|
|
|
6
6
|
import { clear } from './clear';
|
|
7
7
|
export type { DialogProps } from './dialog';
|
|
8
8
|
export type { Action } from './dialog-action-button';
|
|
9
|
-
export type { DialogShowProps,
|
|
9
|
+
export type { DialogShowProps, DialogShowHandler } from './show';
|
|
10
10
|
export type { DialogAlertProps } from './alert';
|
|
11
11
|
export type { DialogConfirmProps } from './confirm';
|
|
12
12
|
declare const _default: import("react").FC<import("./dialog").DialogProps> & {
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { DialogProps } from './dialog';
|
|
2
2
|
export declare type DialogShowProps = Omit<DialogProps, 'visible'>;
|
|
3
|
-
export declare type
|
|
3
|
+
export declare type DialogShowHandler = {
|
|
4
4
|
close: () => void;
|
|
5
5
|
};
|
|
6
6
|
export declare const closeFnSet: Set<() => void>;
|
|
7
|
-
export declare function show(props: DialogShowProps):
|
|
8
|
-
close: () => void;
|
|
9
|
-
};
|
|
7
|
+
export declare function show(props: DialogShowProps): DialogShowHandler;
|
|
@@ -1,52 +1,16 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import { renderToBody } from '../../utils/render-to-body';
|
|
1
|
+
import React from 'react';
|
|
3
2
|
import { Dialog } from './dialog';
|
|
3
|
+
import { renderImperatively } from '../../utils/render-imperatively';
|
|
4
4
|
export const closeFnSet = new Set();
|
|
5
5
|
export function show(props) {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
setVisible(true);
|
|
10
|
-
}, []);
|
|
11
|
-
|
|
12
|
-
function handleClose() {
|
|
13
|
-
var _a;
|
|
14
|
-
|
|
15
|
-
(_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
16
|
-
setVisible(false);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
useImperativeHandle(ref, () => ({
|
|
20
|
-
close: handleClose
|
|
21
|
-
}));
|
|
22
|
-
|
|
23
|
-
function handleAfterClose() {
|
|
6
|
+
const handler = renderImperatively(React.createElement(Dialog, Object.assign({}, props, {
|
|
7
|
+
afterClose: () => {
|
|
24
8
|
var _a;
|
|
25
9
|
|
|
10
|
+
closeFnSet.delete(handler.close);
|
|
26
11
|
(_a = props.afterClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
27
|
-
unmount();
|
|
28
|
-
closeFnSet.delete(close);
|
|
29
12
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
onClose: handleClose,
|
|
34
|
-
afterClose: handleAfterClose
|
|
35
|
-
}));
|
|
36
|
-
});
|
|
37
|
-
const ref = createRef();
|
|
38
|
-
const unmount = renderToBody(React.createElement(Wrapper, {
|
|
39
|
-
ref: ref
|
|
40
|
-
}));
|
|
41
|
-
|
|
42
|
-
const close = () => {
|
|
43
|
-
var _a;
|
|
44
|
-
|
|
45
|
-
(_a = ref.current) === null || _a === void 0 ? void 0 : _a.close();
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
closeFnSet.add(close);
|
|
49
|
-
return {
|
|
50
|
-
close
|
|
51
|
-
};
|
|
13
|
+
})));
|
|
14
|
+
closeFnSet.add(handler.close);
|
|
15
|
+
return handler;
|
|
52
16
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { withNativeProps } from '../../utils/native-props';
|
|
3
|
+
export const EmptyIcon = props => {
|
|
4
|
+
return withNativeProps(props, React.createElement("svg", {
|
|
5
|
+
viewBox: '0 0 64 41'
|
|
6
|
+
}, React.createElement("g", {
|
|
7
|
+
transform: 'translate(0 1)',
|
|
8
|
+
fill: 'none',
|
|
9
|
+
fillRule: 'evenodd'
|
|
10
|
+
}, React.createElement("ellipse", {
|
|
11
|
+
fill: '#f5f5f5',
|
|
12
|
+
cx: '32',
|
|
13
|
+
cy: '33',
|
|
14
|
+
rx: '32',
|
|
15
|
+
ry: '7'
|
|
16
|
+
}), React.createElement("g", {
|
|
17
|
+
stroke: '#d9d9d9'
|
|
18
|
+
}, React.createElement("path", {
|
|
19
|
+
d: 'M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z'
|
|
20
|
+
}), React.createElement("path", {
|
|
21
|
+
d: 'M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z',
|
|
22
|
+
fill: '#fafafa'
|
|
23
|
+
})))));
|
|
24
|
+
};
|
|
@@ -1,25 +1,38 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
|
-
import { mergeProps } from '../../utils/with-default-props';
|
|
4
3
|
import { withNativeProps } from '../../utils/native-props';
|
|
5
|
-
import EmptyIcon from '
|
|
4
|
+
import { EmptyIcon } from './empty-icon';
|
|
6
5
|
const classPrefix = `adm-empty`;
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
6
|
+
export const Empty = props => {
|
|
7
|
+
function renderImageNode() {
|
|
8
|
+
const {
|
|
9
|
+
image
|
|
10
|
+
} = props;
|
|
11
|
+
|
|
12
|
+
if (image === undefined) {
|
|
13
|
+
return React.createElement(EmptyIcon, {
|
|
14
|
+
className: `${classPrefix}-image`,
|
|
15
|
+
style: props.imageStyle
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (typeof image === 'string') {
|
|
20
|
+
return React.createElement("img", {
|
|
21
|
+
className: `${classPrefix}-image`,
|
|
22
|
+
style: props.imageStyle,
|
|
23
|
+
src: image,
|
|
24
|
+
alt: 'empty'
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return image;
|
|
29
|
+
}
|
|
30
|
+
|
|
18
31
|
return withNativeProps(props, React.createElement("div", {
|
|
19
32
|
className: classPrefix
|
|
20
33
|
}, React.createElement("div", {
|
|
21
34
|
className: `${classPrefix}-image-container`
|
|
22
|
-
},
|
|
35
|
+
}, renderImageNode()), props.description && React.createElement("div", {
|
|
23
36
|
className: classNames(`${classPrefix}-description`)
|
|
24
37
|
}, props.description)));
|
|
25
38
|
};
|
|
@@ -1,30 +1,28 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
|
-
import { iconRecord } from './error';
|
|
4
3
|
import { mergeProps } from '../../utils/with-default-props';
|
|
5
4
|
import { withNativeProps } from '../../utils/native-props';
|
|
6
5
|
import { useConfig } from '../config-provider';
|
|
6
|
+
import { imageRecord } from './images';
|
|
7
7
|
const classPrefix = `adm-error-block`;
|
|
8
8
|
const defaultProps = {
|
|
9
9
|
status: 'default'
|
|
10
10
|
};
|
|
11
11
|
export const ErrorBlock = p => {
|
|
12
12
|
const props = mergeProps(defaultProps, p);
|
|
13
|
-
const icon = iconRecord[props.status];
|
|
14
13
|
const {
|
|
15
14
|
locale
|
|
16
15
|
} = useConfig();
|
|
17
16
|
const contentPack = locale.ErrorBlock[props.status];
|
|
18
17
|
const des = 'description' in props ? props.description : contentPack.description;
|
|
19
18
|
const title = 'title' in props ? props.title : contentPack.title;
|
|
20
|
-
let imageNode =
|
|
21
|
-
src: icon
|
|
22
|
-
});
|
|
19
|
+
let imageNode = imageRecord[props.status];
|
|
23
20
|
|
|
24
21
|
if (props.image) {
|
|
25
22
|
if (typeof props.image === 'string') {
|
|
26
23
|
imageNode = React.createElement("img", {
|
|
27
|
-
src: props.image
|
|
24
|
+
src: props.image,
|
|
25
|
+
alt: 'error block image'
|
|
28
26
|
});
|
|
29
27
|
} else {
|
|
30
28
|
imageNode = props.image;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const busyImage: JSX.Element;
|