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,93 +1,30 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import { renderToBody } from '../../utils/render-to-body';
|
|
1
|
+
import React from 'react';
|
|
3
2
|
import { ImageViewer, MultiImageViewer } from './image-viewer';
|
|
4
|
-
import {
|
|
3
|
+
import { renderImperatively } from '../../utils/render-imperatively';
|
|
5
4
|
const handlerSet = new Set();
|
|
6
5
|
export function showImageViewer(props) {
|
|
7
6
|
clearImageViewer();
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
setVisible(true);
|
|
12
|
-
}, []);
|
|
13
|
-
const isUnmountedRef = useUnmountedRef();
|
|
14
|
-
useImperativeHandle(ref, () => ({
|
|
15
|
-
close: () => {
|
|
16
|
-
if (isUnmountedRef.current) return;
|
|
17
|
-
setVisible(false);
|
|
18
|
-
}
|
|
19
|
-
}));
|
|
20
|
-
return React.createElement(ImageViewer, Object.assign({}, props, {
|
|
21
|
-
visible: visible,
|
|
22
|
-
onClose: () => {
|
|
23
|
-
var _a;
|
|
24
|
-
|
|
25
|
-
(_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
26
|
-
setVisible(false);
|
|
27
|
-
},
|
|
28
|
-
afterClose: () => {
|
|
29
|
-
var _a;
|
|
30
|
-
|
|
31
|
-
(_a = props.afterClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
32
|
-
unmount();
|
|
33
|
-
}
|
|
34
|
-
}));
|
|
35
|
-
});
|
|
36
|
-
const ref = createRef();
|
|
37
|
-
const unmount = renderToBody(React.createElement(Wrapper, {
|
|
38
|
-
ref: ref
|
|
39
|
-
}));
|
|
40
|
-
const handler = {
|
|
41
|
-
close: () => {
|
|
7
|
+
const handler = renderImperatively(React.createElement(ImageViewer, Object.assign({}, props, {
|
|
8
|
+
afterClose: () => {
|
|
42
9
|
var _a;
|
|
43
10
|
|
|
44
|
-
|
|
11
|
+
handlerSet.delete(handler);
|
|
12
|
+
(_a = props.afterClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
45
13
|
}
|
|
46
|
-
};
|
|
14
|
+
})));
|
|
47
15
|
handlerSet.add(handler);
|
|
48
16
|
return handler;
|
|
49
17
|
}
|
|
50
18
|
export function showMultiImageViewer(props) {
|
|
51
19
|
clearImageViewer();
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
useEffect(() => {
|
|
55
|
-
setVisible(true);
|
|
56
|
-
}, []);
|
|
57
|
-
const isUnmountedRef = useUnmountedRef();
|
|
58
|
-
useImperativeHandle(ref, () => ({
|
|
59
|
-
close: () => {
|
|
60
|
-
if (isUnmountedRef.current) return;
|
|
61
|
-
setVisible(false);
|
|
62
|
-
}
|
|
63
|
-
}));
|
|
64
|
-
return React.createElement(MultiImageViewer, Object.assign({}, props, {
|
|
65
|
-
visible: visible,
|
|
66
|
-
onClose: () => {
|
|
67
|
-
var _a;
|
|
68
|
-
|
|
69
|
-
(_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
70
|
-
setVisible(false);
|
|
71
|
-
},
|
|
72
|
-
afterClose: () => {
|
|
73
|
-
var _a;
|
|
74
|
-
|
|
75
|
-
(_a = props.afterClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
76
|
-
unmount();
|
|
77
|
-
}
|
|
78
|
-
}));
|
|
79
|
-
});
|
|
80
|
-
const ref = createRef();
|
|
81
|
-
const unmount = renderToBody(React.createElement(Wrapper, {
|
|
82
|
-
ref: ref
|
|
83
|
-
}));
|
|
84
|
-
const handler = {
|
|
85
|
-
close: () => {
|
|
20
|
+
const handler = renderImperatively(React.createElement(MultiImageViewer, Object.assign({}, props, {
|
|
21
|
+
afterClose: () => {
|
|
86
22
|
var _a;
|
|
87
23
|
|
|
88
|
-
|
|
24
|
+
handlerSet.delete(handler);
|
|
25
|
+
(_a = props.afterClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
89
26
|
}
|
|
90
|
-
};
|
|
27
|
+
})));
|
|
91
28
|
handlerSet.add(handler);
|
|
92
29
|
return handler;
|
|
93
30
|
}
|
|
@@ -6,7 +6,7 @@ import { confirm } from './confirm';
|
|
|
6
6
|
import { clear } from './clear';
|
|
7
7
|
export type { ModalProps } from './modal';
|
|
8
8
|
export type { Action } from './modal-action-button';
|
|
9
|
-
export type { ModalShowProps,
|
|
9
|
+
export type { ModalShowProps, ModalShowHandler } from './show';
|
|
10
10
|
export type { ModalAlertProps } from './alert';
|
|
11
11
|
export type { ModalConfirmProps } from './confirm';
|
|
12
12
|
declare const _default: import("react").FC<import("./modal").ModalProps> & {
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { ModalProps } from './modal';
|
|
2
2
|
export declare type ModalShowProps = Omit<ModalProps, 'visible'>;
|
|
3
|
-
export declare type
|
|
3
|
+
export declare type ModalShowHandler = {
|
|
4
4
|
close: () => void;
|
|
5
5
|
};
|
|
6
6
|
export declare const closeFnSet: Set<() => void>;
|
|
7
|
-
export declare function show(props: ModalShowProps):
|
|
8
|
-
close: () => void;
|
|
9
|
-
};
|
|
7
|
+
export declare function show(props: ModalShowProps): ModalShowHandler;
|
|
@@ -1,52 +1,16 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import { renderToBody } from '../../utils/render-to-body';
|
|
1
|
+
import React from 'react';
|
|
3
2
|
import { Modal } from './modal';
|
|
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(Modal, 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
|
}
|
|
@@ -4,9 +4,8 @@ import { mergeProps } from '../../utils/with-default-props';
|
|
|
4
4
|
import { withNativeProps } from '../../utils/native-props';
|
|
5
5
|
import { usePropsValue } from '../../utils/use-props-value';
|
|
6
6
|
import PickerView from '../picker-view';
|
|
7
|
-
import {
|
|
7
|
+
import { generateColumnsExtend, useColumnsExtend } from '../picker-view/columns-extend';
|
|
8
8
|
import { useConfig } from '../config-provider';
|
|
9
|
-
import { usePickerValueExtend } from '../picker-view/use-picker-value-extend';
|
|
10
9
|
import { useMemoizedFn } from 'ahooks';
|
|
11
10
|
import SafeArea from '../safe-area';
|
|
12
11
|
const classPrefix = `adm-picker`;
|
|
@@ -28,12 +27,11 @@ export const Picker = memo(p => {
|
|
|
28
27
|
onChange: val => {
|
|
29
28
|
var _a;
|
|
30
29
|
|
|
31
|
-
|
|
30
|
+
const extend = generateColumnsExtend(props.columns, val);
|
|
31
|
+
(_a = props.onConfirm) === null || _a === void 0 ? void 0 : _a.call(props, val, extend);
|
|
32
32
|
}
|
|
33
|
-
}));
|
|
34
|
-
|
|
35
|
-
const columns = useColumns(props.columns, value);
|
|
36
|
-
const generateValueExtend = usePickerValueExtend(columns);
|
|
33
|
+
}));
|
|
34
|
+
const extend = useColumnsExtend(props.columns, value);
|
|
37
35
|
const [innerValue, setInnerValue] = useState(value);
|
|
38
36
|
useEffect(() => {
|
|
39
37
|
if (innerValue !== value) {
|
|
@@ -104,6 +102,6 @@ export const Picker = memo(p => {
|
|
|
104
102
|
}, pickerElement, React.createElement(SafeArea, {
|
|
105
103
|
position: 'bottom'
|
|
106
104
|
}));
|
|
107
|
-
return React.createElement(React.Fragment, null, popupElement, (_a = props.children) === null || _a === void 0 ? void 0 : _a.call(props,
|
|
105
|
+
return React.createElement(React.Fragment, null, popupElement, (_a = props.children) === null || _a === void 0 ? void 0 : _a.call(props, extend.items));
|
|
108
106
|
});
|
|
109
107
|
Picker.displayName = 'Picker';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { PickerViewProps, PickerValue, PickerValueExtend } from './picker-view';
|
|
2
|
+
export declare function generateColumnsExtend(rawColumns: PickerViewProps['columns'], val: PickerValue[]): PickerValueExtend;
|
|
3
|
+
export declare function useColumnsExtend(rawColumns: PickerViewProps['columns'], value: PickerValue[]): PickerValueExtend;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { withCache } from '../../utils/with-cache';
|
|
3
|
+
export function generateColumnsExtend(rawColumns, val) {
|
|
4
|
+
const columns = withCache(() => {
|
|
5
|
+
const c = typeof rawColumns === 'function' ? rawColumns(val) : rawColumns;
|
|
6
|
+
return c.map(column => column.map(item => typeof item === 'string' ? {
|
|
7
|
+
label: item,
|
|
8
|
+
value: item
|
|
9
|
+
} : item));
|
|
10
|
+
});
|
|
11
|
+
const items = withCache(() => {
|
|
12
|
+
return val.map((v, index) => {
|
|
13
|
+
var _a;
|
|
14
|
+
|
|
15
|
+
const column = columns()[index];
|
|
16
|
+
if (!column) return null;
|
|
17
|
+
return (_a = column.find(item => item.value === v)) !== null && _a !== void 0 ? _a : null;
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
const extend = {
|
|
21
|
+
get columns() {
|
|
22
|
+
return columns();
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
get items() {
|
|
26
|
+
return items();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
};
|
|
30
|
+
return extend;
|
|
31
|
+
}
|
|
32
|
+
export function useColumnsExtend(rawColumns, value) {
|
|
33
|
+
return useMemo(() => generateColumnsExtend(rawColumns, value), [rawColumns, value]);
|
|
34
|
+
}
|
|
@@ -2,6 +2,7 @@ import React, { ReactNode } from 'react';
|
|
|
2
2
|
import { NativeProps } from '../../utils/native-props';
|
|
3
3
|
export declare type PickerValue = string | null;
|
|
4
4
|
export declare type PickerValueExtend = {
|
|
5
|
+
columns: PickerColumnItem[][];
|
|
5
6
|
items: (PickerColumnItem | null)[];
|
|
6
7
|
};
|
|
7
8
|
export declare type PickerColumnItem = {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import React, { memo, useCallback, useEffect, useState } from 'react';
|
|
2
2
|
import { mergeProps } from '../../utils/with-default-props';
|
|
3
3
|
import { Wheel } from './wheel';
|
|
4
|
-
import {
|
|
4
|
+
import { useColumnsExtend } from './columns-extend';
|
|
5
5
|
import { withNativeProps } from '../../utils/native-props';
|
|
6
|
-
import { usePickerValueExtend } from './use-picker-value-extend';
|
|
7
6
|
import { useDebounceEffect } from 'ahooks';
|
|
8
7
|
const classPrefix = `adm-picker-view`;
|
|
9
8
|
const defaultProps = {
|
|
@@ -11,17 +10,7 @@ const defaultProps = {
|
|
|
11
10
|
};
|
|
12
11
|
export const PickerView = memo(p => {
|
|
13
12
|
const props = mergeProps(defaultProps, p);
|
|
14
|
-
const [innerValue, setInnerValue] = useState(props.value === undefined ? props.defaultValue : props.value);
|
|
15
|
-
useDebounceEffect(() => {
|
|
16
|
-
var _a;
|
|
17
|
-
|
|
18
|
-
if (props.value === innerValue) return;
|
|
19
|
-
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, innerValue, generateValueExtend(innerValue));
|
|
20
|
-
}, [innerValue], {
|
|
21
|
-
wait: 0,
|
|
22
|
-
leading: false,
|
|
23
|
-
trailing: true
|
|
24
|
-
}); // Sync `value` to `innerValue`
|
|
13
|
+
const [innerValue, setInnerValue] = useState(props.value === undefined ? props.defaultValue : props.value); // Sync `value` to `innerValue`
|
|
25
14
|
|
|
26
15
|
useEffect(() => {
|
|
27
16
|
if (props.value === undefined) return; // Uncontrolled mode
|
|
@@ -40,8 +29,18 @@ export const PickerView = memo(p => {
|
|
|
40
29
|
window.clearTimeout(timeout);
|
|
41
30
|
};
|
|
42
31
|
}, [props.value, innerValue]);
|
|
43
|
-
const
|
|
44
|
-
const
|
|
32
|
+
const extend = useColumnsExtend(props.columns, innerValue);
|
|
33
|
+
const columns = extend.columns;
|
|
34
|
+
useDebounceEffect(() => {
|
|
35
|
+
var _a;
|
|
36
|
+
|
|
37
|
+
if (props.value === innerValue) return;
|
|
38
|
+
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, innerValue, extend);
|
|
39
|
+
}, [innerValue], {
|
|
40
|
+
wait: 0,
|
|
41
|
+
leading: false,
|
|
42
|
+
trailing: true
|
|
43
|
+
});
|
|
45
44
|
const handleSelect = useCallback((val, index) => {
|
|
46
45
|
setInnerValue(prev => {
|
|
47
46
|
const next = [...prev];
|