antd-mobile 5.6.0 → 5.7.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/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/collapse/collapse.js +7 -0
- 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 +3 -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/form/form-item.d.ts +1 -1
- package/2x/cjs/components/form/form-item.js +4 -1
- package/2x/cjs/components/image-viewer/methods.d.ts +1 -4
- package/2x/cjs/components/image-viewer/methods.js +7 -58
- 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/result/result.d.ts +2 -2
- package/2x/cjs/components/virtual-input/virtual-input.js +25 -14
- package/2x/cjs/utils/render-imperatively.js +17 -7
- package/2x/cjs/utils/with-cache.d.ts +1 -0
- package/2x/cjs/utils/with-cache.js +17 -0
- 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/collapse/collapse.js +7 -0
- 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 +2 -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/form/form-item.d.ts +1 -1
- package/2x/es/components/form/form-item.js +4 -1
- package/2x/es/components/image-viewer/methods.d.ts +1 -4
- package/2x/es/components/image-viewer/methods.js +6 -50
- 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/result/result.d.ts +2 -2
- package/2x/es/components/virtual-input/virtual-input.js +23 -14
- package/2x/es/utils/render-imperatively.js +16 -8
- package/2x/es/utils/with-cache.d.ts +1 -0
- package/2x/es/utils/with-cache.js +10 -0
- package/2x/package.json +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/collapse/collapse.js +7 -0
- 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 +3 -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/form/form-item.d.ts +1 -1
- package/cjs/components/form/form-item.js +4 -1
- package/cjs/components/image-viewer/methods.d.ts +1 -4
- package/cjs/components/image-viewer/methods.js +7 -58
- 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/result/result.d.ts +2 -2
- package/cjs/components/virtual-input/virtual-input.js +25 -14
- package/cjs/utils/render-imperatively.js +17 -7
- package/cjs/utils/with-cache.d.ts +1 -0
- package/cjs/utils/with-cache.js +17 -0
- 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/collapse/collapse.js +7 -0
- 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 +2 -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/form/form-item.d.ts +1 -1
- package/es/components/form/form-item.js +4 -1
- package/es/components/image-viewer/methods.d.ts +1 -4
- package/es/components/image-viewer/methods.js +6 -50
- 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/result/result.d.ts +2 -2
- package/es/components/virtual-input/virtual-input.js +23 -14
- package/es/utils/render-imperatively.js +16 -8
- package/es/utils/with-cache.d.ts +1 -0
- package/es/utils/with-cache.js +10 -0
- package/package.json +1 -1
- 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,5 +1,4 @@
|
|
|
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
3
|
import { renderImperatively } from '../../utils/render-imperatively';
|
|
5
4
|
const handlerSet = new Set();
|
|
@@ -18,54 +17,14 @@ export function showImageViewer(props) {
|
|
|
18
17
|
}
|
|
19
18
|
export function showMultiImageViewer(props) {
|
|
20
19
|
clearImageViewer();
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
const closedRef = useRef(false);
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
if (!closedRef.current) {
|
|
26
|
-
setVisible(true);
|
|
27
|
-
} else {
|
|
28
|
-
handleAfterClose();
|
|
29
|
-
}
|
|
30
|
-
}, []);
|
|
31
|
-
|
|
32
|
-
function handleClose() {
|
|
33
|
-
var _a;
|
|
34
|
-
|
|
35
|
-
closedRef.current = true;
|
|
36
|
-
(_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
37
|
-
setVisible(false);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
useImperativeHandle(ref, () => ({
|
|
41
|
-
close: handleClose
|
|
42
|
-
}));
|
|
43
|
-
|
|
44
|
-
function handleAfterClose() {
|
|
20
|
+
const handler = renderImperatively(React.createElement(MultiImageViewer, Object.assign({}, props, {
|
|
21
|
+
afterClose: () => {
|
|
45
22
|
var _a;
|
|
46
23
|
|
|
47
|
-
(_a = props.afterClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
48
|
-
unmount();
|
|
49
24
|
handlerSet.delete(handler);
|
|
25
|
+
(_a = props.afterClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
50
26
|
}
|
|
51
|
-
|
|
52
|
-
return React.createElement(MultiImageViewer, Object.assign({}, props, {
|
|
53
|
-
visible: visible,
|
|
54
|
-
onClose: handleClose,
|
|
55
|
-
afterClose: handleAfterClose
|
|
56
|
-
}));
|
|
57
|
-
});
|
|
58
|
-
const ref = createRef();
|
|
59
|
-
const unmount = renderToBody(React.createElement(Wrapper, {
|
|
60
|
-
ref: ref
|
|
61
|
-
}));
|
|
62
|
-
const handler = {
|
|
63
|
-
close: () => {
|
|
64
|
-
var _a;
|
|
65
|
-
|
|
66
|
-
(_a = ref.current) === null || _a === void 0 ? void 0 : _a.close();
|
|
67
|
-
}
|
|
68
|
-
};
|
|
27
|
+
})));
|
|
69
28
|
handlerSet.add(handler);
|
|
70
29
|
return handler;
|
|
71
30
|
}
|
|
@@ -74,7 +33,4 @@ export function clearImageViewer() {
|
|
|
74
33
|
handler.close();
|
|
75
34
|
});
|
|
76
35
|
handlerSet.clear();
|
|
77
|
-
}
|
|
78
|
-
export const getH = () => {
|
|
79
|
-
console.log(handlerSet);
|
|
80
|
-
};
|
|
36
|
+
}
|
|
@@ -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];
|
|
@@ -2,8 +2,8 @@ import { FC, ReactNode } from 'react';
|
|
|
2
2
|
import { NativeProps } from '../../utils/native-props';
|
|
3
3
|
export declare type ResultProps = {
|
|
4
4
|
status: 'success' | 'error' | 'info' | 'waiting' | 'warning';
|
|
5
|
-
title:
|
|
6
|
-
description?:
|
|
5
|
+
title: ReactNode;
|
|
6
|
+
description?: ReactNode;
|
|
7
7
|
icon?: ReactNode;
|
|
8
8
|
} & NativeProps;
|
|
9
9
|
export declare const Result: FC<ResultProps>;
|
|
@@ -64,6 +64,28 @@ export const VirtualInput = forwardRef((p, ref) => {
|
|
|
64
64
|
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
const keyboard = props.keyboard;
|
|
68
|
+
const keyboardElement = keyboard && React.cloneElement(keyboard, {
|
|
69
|
+
onInput: v => {
|
|
70
|
+
var _a, _b;
|
|
71
|
+
|
|
72
|
+
setValue(value + v);
|
|
73
|
+
(_b = (_a = keyboard.props).onInput) === null || _b === void 0 ? void 0 : _b.call(_a, v);
|
|
74
|
+
},
|
|
75
|
+
onDelete: () => {
|
|
76
|
+
var _a, _b;
|
|
77
|
+
|
|
78
|
+
setValue(value.slice(0, -1));
|
|
79
|
+
(_b = (_a = keyboard.props).onDelete) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
80
|
+
},
|
|
81
|
+
visible: hasFocus,
|
|
82
|
+
onClose: () => {
|
|
83
|
+
var _a, _b, _c;
|
|
84
|
+
|
|
85
|
+
(_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.blur();
|
|
86
|
+
(_c = (_b = keyboard.props).onClose) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
67
89
|
return withNativeProps(props, React.createElement("div", {
|
|
68
90
|
ref: rootRef,
|
|
69
91
|
className: classNames(classPrefix, {
|
|
@@ -91,18 +113,5 @@ export const VirtualInput = forwardRef((p, ref) => {
|
|
|
91
113
|
}
|
|
92
114
|
}, React.createElement(CloseCircleFill, null)), !value && React.createElement("div", {
|
|
93
115
|
className: `${classPrefix}-placeholder`
|
|
94
|
-
}, props.placeholder),
|
|
95
|
-
onInput: v => {
|
|
96
|
-
setValue(value + v);
|
|
97
|
-
},
|
|
98
|
-
onDelete: () => {
|
|
99
|
-
setValue(value.slice(0, -1));
|
|
100
|
-
},
|
|
101
|
-
visible: hasFocus,
|
|
102
|
-
onClose: () => {
|
|
103
|
-
var _a;
|
|
104
|
-
|
|
105
|
-
(_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.blur();
|
|
106
|
-
}
|
|
107
|
-
})));
|
|
116
|
+
}, props.placeholder), keyboardElement));
|
|
108
117
|
});
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
1
|
+
import React, { useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
2
2
|
import { renderToBody } from './render-to-body';
|
|
3
3
|
export function renderImperatively(element) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const Wrapper = () => {
|
|
4
|
+
const Wrapper = React.forwardRef((_, ref) => {
|
|
7
5
|
const [visible, setVisible] = useState(false);
|
|
8
6
|
const closedRef = useRef(false);
|
|
9
7
|
useEffect(() => {
|
|
@@ -22,8 +20,6 @@ export function renderImperatively(element) {
|
|
|
22
20
|
(_b = (_a = element.props).onClose) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
23
21
|
}
|
|
24
22
|
|
|
25
|
-
close = onClose;
|
|
26
|
-
|
|
27
23
|
function afterClose() {
|
|
28
24
|
var _a, _b;
|
|
29
25
|
|
|
@@ -31,14 +27,26 @@ export function renderImperatively(element) {
|
|
|
31
27
|
(_b = (_a = element.props).afterClose) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
32
28
|
}
|
|
33
29
|
|
|
30
|
+
useImperativeHandle(ref, () => ({
|
|
31
|
+
close: onClose
|
|
32
|
+
}));
|
|
34
33
|
return React.cloneElement(element, Object.assign(Object.assign({}, element.props), {
|
|
35
34
|
visible,
|
|
36
35
|
onClose,
|
|
37
36
|
afterClose
|
|
38
37
|
}));
|
|
39
|
-
};
|
|
38
|
+
});
|
|
39
|
+
const wrapperRef = React.createRef();
|
|
40
|
+
const unmount = renderToBody(React.createElement(Wrapper, {
|
|
41
|
+
ref: wrapperRef
|
|
42
|
+
}));
|
|
43
|
+
|
|
44
|
+
function close() {
|
|
45
|
+
var _a;
|
|
46
|
+
|
|
47
|
+
(_a = wrapperRef.current) === null || _a === void 0 ? void 0 : _a.close();
|
|
48
|
+
}
|
|
40
49
|
|
|
41
|
-
const unmount = renderToBody(React.createElement(Wrapper, null));
|
|
42
50
|
return {
|
|
43
51
|
close
|
|
44
52
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function withCache<T>(generate: () => T): () => T;
|
package/2x/package.json
CHANGED
|
@@ -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 {};
|
|
@@ -25,6 +25,10 @@ var _isoWeek = _interopRequireDefault(require("dayjs/plugin/isoWeek"));
|
|
|
25
25
|
|
|
26
26
|
var _ahooks = require("ahooks");
|
|
27
27
|
|
|
28
|
+
var _usePropsValue = require("../../utils/use-props-value");
|
|
29
|
+
|
|
30
|
+
var _convert = require("./convert");
|
|
31
|
+
|
|
28
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
33
|
|
|
30
34
|
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); }
|
|
@@ -35,7 +39,9 @@ _dayjs.default.extend(_isoWeek.default);
|
|
|
35
39
|
|
|
36
40
|
const classPrefix = 'adm-calendar';
|
|
37
41
|
const defaultProps = {
|
|
38
|
-
weekStartsOn: 'Sunday'
|
|
42
|
+
weekStartsOn: 'Sunday',
|
|
43
|
+
defaultValue: null,
|
|
44
|
+
allowClear: true
|
|
39
45
|
};
|
|
40
46
|
const Calendar = (0, _react.forwardRef)((p, ref) => {
|
|
41
47
|
const today = (0, _dayjs.default)();
|
|
@@ -50,29 +56,21 @@ const Calendar = (0, _react.forwardRef)((p, ref) => {
|
|
|
50
56
|
if (item) markItems.unshift(item);
|
|
51
57
|
}
|
|
52
58
|
|
|
53
|
-
const dateRange = (0,
|
|
54
|
-
|
|
59
|
+
const [dateRange, setDateRange] = (0, _usePropsValue.usePropsValue)({
|
|
60
|
+
value: props.value === undefined ? undefined : (0, _convert.convertValueToRange)(props.selectionMode, props.value),
|
|
61
|
+
defaultValue: (0, _convert.convertValueToRange)(props.selectionMode, props.defaultValue),
|
|
62
|
+
onChange: v => {
|
|
63
|
+
var _a, _b;
|
|
55
64
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
} else {
|
|
62
|
-
return [null, null];
|
|
65
|
+
if (props.selectionMode === 'single') {
|
|
66
|
+
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, v ? v[0] : null);
|
|
67
|
+
} else if (props.selectionMode === 'range') {
|
|
68
|
+
(_b = props.onChange) === null || _b === void 0 ? void 0 : _b.call(props, v);
|
|
69
|
+
}
|
|
63
70
|
}
|
|
64
|
-
}, [props.selectionMode, props.value, props.defaultValue]);
|
|
65
|
-
const [begin, setBegin] = (0, _react.useState)(null);
|
|
66
|
-
const [end, setEnd] = (0, _react.useState)(null);
|
|
67
|
-
(0, _ahooks.useIsomorphicLayoutEffect)(() => {
|
|
68
|
-
setBegin(dateRange[0] ? (0, _dayjs.default)(dateRange[0]) : null);
|
|
69
|
-
setEnd(dateRange[1] ? (0, _dayjs.default)(dateRange[1]) : null);
|
|
70
|
-
}, [dateRange[0], dateRange[1]]);
|
|
71
|
-
const [current, setCurrent] = (0, _react.useState)(() => {
|
|
72
|
-
var _a;
|
|
73
|
-
|
|
74
|
-
return (0, _dayjs.default)((_a = dateRange[0]) !== null && _a !== void 0 ? _a : today).date(1);
|
|
75
71
|
});
|
|
72
|
+
const [intermediate, setIntermediate] = (0, _react.useState)(false);
|
|
73
|
+
const [current, setCurrent] = (0, _react.useState)(() => (0, _dayjs.default)(dateRange ? dateRange[0] : today).date(1));
|
|
76
74
|
(0, _ahooks.useUpdateEffect)(() => {
|
|
77
75
|
var _a;
|
|
78
76
|
|
|
@@ -136,14 +134,16 @@ const Calendar = (0, _react.forwardRef)((p, ref) => {
|
|
|
136
134
|
|
|
137
135
|
while (cells.length < 6 * 7) {
|
|
138
136
|
const d = iterator;
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
137
|
+
let isSelect = false;
|
|
138
|
+
let isBegin = false;
|
|
139
|
+
let isEnd = false;
|
|
140
|
+
|
|
141
|
+
if (dateRange) {
|
|
142
|
+
const [begin, end] = dateRange;
|
|
143
|
+
isBegin = d.isSame(begin, 'day');
|
|
144
|
+
isEnd = d.isSame(end, 'day');
|
|
145
|
+
isSelect = isBegin || isEnd || d.isAfter(begin, 'day') && d.isBefore(end, 'day');
|
|
146
|
+
}
|
|
147
147
|
|
|
148
148
|
const inThisMonth = d.month() === current.month();
|
|
149
149
|
cells.push(_react.default.createElement("div", {
|
|
@@ -151,41 +151,52 @@ const Calendar = (0, _react.forwardRef)((p, ref) => {
|
|
|
151
151
|
className: (0, _classnames.default)(`${classPrefix}-cell`, inThisMonth ? `${classPrefix}-cell-in` : `${classPrefix}-cell-out`, inThisMonth && {
|
|
152
152
|
[`${classPrefix}-cell-today`]: d.isSame(today, 'day'),
|
|
153
153
|
[`${classPrefix}-cell-selected`]: isSelect,
|
|
154
|
-
[`${classPrefix}-cell-selected-begin`]:
|
|
155
|
-
[`${classPrefix}-cell-selected-end`]:
|
|
154
|
+
[`${classPrefix}-cell-selected-begin`]: isBegin,
|
|
155
|
+
[`${classPrefix}-cell-selected-end`]: isEnd
|
|
156
156
|
}),
|
|
157
157
|
onClick: () => {
|
|
158
|
-
var _a, _b, _c;
|
|
159
|
-
|
|
160
158
|
if (!props.selectionMode) return;
|
|
159
|
+
const date = d.toDate();
|
|
160
|
+
|
|
161
|
+
if (!inThisMonth) {
|
|
162
|
+
setCurrent(d.clone().date(1));
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function shouldClear() {
|
|
166
|
+
if (!props.allowClear) return false;
|
|
167
|
+
if (!dateRange) return false;
|
|
168
|
+
const [begin, end] = dateRange;
|
|
169
|
+
return d.isSame(begin, 'date') && d.isSame(end, 'day');
|
|
170
|
+
}
|
|
161
171
|
|
|
162
172
|
if (props.selectionMode === 'single') {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
173
|
+
if (props.allowClear && shouldClear()) {
|
|
174
|
+
setDateRange(null);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
setDateRange([date, date]);
|
|
166
179
|
} else if (props.selectionMode === 'range') {
|
|
167
|
-
if (
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
} else {
|
|
172
|
-
if (d.isBefore(begin)) {
|
|
173
|
-
setEnd(begin);
|
|
174
|
-
setBegin(d);
|
|
175
|
-
(_b = props.onChange) === null || _b === void 0 ? void 0 : _b.call(props, [d.toDate(), begin.toDate()]);
|
|
176
|
-
} else {
|
|
177
|
-
setEnd(d);
|
|
178
|
-
(_c = props.onChange) === null || _c === void 0 ? void 0 : _c.call(props, [begin.toDate(), d.toDate()]);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
} else {
|
|
182
|
-
setBegin(d);
|
|
183
|
-
setEnd(null);
|
|
180
|
+
if (!dateRange) {
|
|
181
|
+
setDateRange([date, date]);
|
|
182
|
+
setIntermediate(true);
|
|
183
|
+
return;
|
|
184
184
|
}
|
|
185
|
-
}
|
|
186
185
|
|
|
187
|
-
|
|
188
|
-
|
|
186
|
+
if (shouldClear()) {
|
|
187
|
+
setDateRange(null);
|
|
188
|
+
setIntermediate(false);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (intermediate) {
|
|
193
|
+
const another = dateRange[0];
|
|
194
|
+
setDateRange(another > date ? [date, another] : [another, date]);
|
|
195
|
+
setIntermediate(false);
|
|
196
|
+
} else {
|
|
197
|
+
setDateRange([date, date]);
|
|
198
|
+
setIntermediate(true);
|
|
199
|
+
}
|
|
189
200
|
}
|
|
190
201
|
}
|
|
191
202
|
}, _react.default.createElement("div", {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.convertValueToRange = convertValueToRange;
|
|
7
|
+
|
|
8
|
+
function convertValueToRange(selectionMode, value) {
|
|
9
|
+
if (selectionMode === undefined) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (value === null) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (Array.isArray(value)) {
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return [value, value];
|
|
22
|
+
}
|
|
@@ -50,6 +50,13 @@ const CollapsePanelContent = props => {
|
|
|
50
50
|
}, api] = (0, _web.useSpring)(() => ({
|
|
51
51
|
from: {
|
|
52
52
|
height: 0
|
|
53
|
+
},
|
|
54
|
+
config: {
|
|
55
|
+
precision: 0.01,
|
|
56
|
+
mass: 1,
|
|
57
|
+
tension: 200,
|
|
58
|
+
friction: 25,
|
|
59
|
+
clamp: true
|
|
53
60
|
}
|
|
54
61
|
}));
|
|
55
62
|
(0, _ahooks.useMount)(() => {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.EmptyIcon = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _nativeProps = require("../../utils/native-props");
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
const EmptyIcon = props => {
|
|
15
|
+
return (0, _nativeProps.withNativeProps)(props, _react.default.createElement("svg", {
|
|
16
|
+
viewBox: '0 0 64 41'
|
|
17
|
+
}, _react.default.createElement("g", {
|
|
18
|
+
transform: 'translate(0 1)',
|
|
19
|
+
fill: 'none',
|
|
20
|
+
fillRule: 'evenodd'
|
|
21
|
+
}, _react.default.createElement("ellipse", {
|
|
22
|
+
fill: '#f5f5f5',
|
|
23
|
+
cx: '32',
|
|
24
|
+
cy: '33',
|
|
25
|
+
rx: '32',
|
|
26
|
+
ry: '7'
|
|
27
|
+
}), _react.default.createElement("g", {
|
|
28
|
+
stroke: '#d9d9d9'
|
|
29
|
+
}, _react.default.createElement("path", {
|
|
30
|
+
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'
|
|
31
|
+
}), _react.default.createElement("path", {
|
|
32
|
+
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',
|
|
33
|
+
fill: '#fafafa'
|
|
34
|
+
})))));
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
exports.EmptyIcon = EmptyIcon;
|