antd-mobile 5.5.1 → 5.6.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/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/error-block/error-block.js +4 -2
- 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/image-viewer/index.d.ts +1 -1
- package/2x/cjs/components/image-viewer/methods.d.ts +3 -4
- package/2x/cjs/components/image-viewer/methods.js +41 -56
- 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/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 +58 -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/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/error-block/error-block.js +4 -2
- 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/image-viewer/index.d.ts +1 -1
- package/2x/es/components/image-viewer/methods.d.ts +3 -4
- package/2x/es/components/image-viewer/methods.js +38 -57
- 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/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 +45 -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/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/error-block/error-block.js +4 -2
- package/cjs/components/floating-bubble/floating-bubble.css +2 -1
- package/cjs/components/floating-bubble/floating-bubble.d.ts +1 -1
- package/cjs/components/image-viewer/index.d.ts +1 -1
- package/cjs/components/image-viewer/methods.d.ts +3 -4
- package/cjs/components/image-viewer/methods.js +41 -56
- 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/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 +58 -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/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/error-block/error-block.js +4 -2
- package/es/components/floating-bubble/floating-bubble.css +2 -1
- package/es/components/floating-bubble/floating-bubble.d.ts +1 -1
- package/es/components/image-viewer/index.d.ts +1 -1
- package/es/components/image-viewer/methods.d.ts +3 -4
- package/es/components/image-viewer/methods.js +38 -57
- 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/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 +45 -0
- package/package.json +2 -3
- package/umd/antd-mobile.js +1 -1
|
@@ -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
|
|
@@ -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
|
}
|
|
@@ -18,13 +18,15 @@ export const ErrorBlock = p => {
|
|
|
18
18
|
const des = 'description' in props ? props.description : contentPack.description;
|
|
19
19
|
const title = 'title' in props ? props.title : contentPack.title;
|
|
20
20
|
let imageNode = React.createElement("img", {
|
|
21
|
-
src: icon
|
|
21
|
+
src: icon,
|
|
22
|
+
alt: 'error block image'
|
|
22
23
|
});
|
|
23
24
|
|
|
24
25
|
if (props.image) {
|
|
25
26
|
if (typeof props.image === 'string') {
|
|
26
27
|
imageNode = React.createElement("img", {
|
|
27
|
-
src: props.image
|
|
28
|
+
src: props.image,
|
|
29
|
+
alt: 'error block image'
|
|
28
30
|
});
|
|
29
31
|
} else {
|
|
30
32
|
imageNode = props.image;
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
--edge-distance: 0;
|
|
8
8
|
--size: 48px;
|
|
9
9
|
--border-radius: 50%;
|
|
10
|
+
--background: var(--adm-color-primary);
|
|
10
11
|
}
|
|
11
12
|
.adm-floating-bubble-boundary-outer {
|
|
12
13
|
position: fixed;
|
|
@@ -40,7 +41,7 @@
|
|
|
40
41
|
transition: opacity ease 0.15s;
|
|
41
42
|
user-select: none;
|
|
42
43
|
touch-action: none;
|
|
43
|
-
background: var(--
|
|
44
|
+
background: var(--background);
|
|
44
45
|
color: var(--adm-color-white);
|
|
45
46
|
border-radius: var(--border-radius);
|
|
46
47
|
z-index: var(--z-index);
|
|
@@ -4,5 +4,5 @@ export declare type FloatingBubbleProps = {
|
|
|
4
4
|
onClick?: (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
|
|
5
5
|
axis?: 'x' | 'y' | 'xy' | 'lock';
|
|
6
6
|
magnetic?: 'x' | 'y';
|
|
7
|
-
} & NativeProps<'--initial-position-left' | '--initial-position-right' | '--initial-position-top' | '--initial-position-bottom' | '--z-index' | '--edge-distance' | '--size' | '--border-radius'>;
|
|
7
|
+
} & NativeProps<'--initial-position-left' | '--initial-position-right' | '--initial-position-top' | '--initial-position-bottom' | '--z-index' | '--edge-distance' | '--size' | '--border-radius' | '--background'>;
|
|
8
8
|
export declare const FloatingBubble: FC<FloatingBubbleProps>;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import './image-viewer.less';
|
|
3
3
|
import { showMultiImageViewer, showImageViewer, clearImageViewer } from './methods';
|
|
4
4
|
export type { ImageViewerProps, MultiImageViewerProps, MultiImageViewerRef, } from './image-viewer';
|
|
5
|
-
export type {
|
|
5
|
+
export type { ImageViewerShowHandler } from './methods';
|
|
6
6
|
declare const _default: import("react").FC<import("./image-viewer").ImageViewerProps> & {
|
|
7
7
|
Multi: import("react").ForwardRefExoticComponent<Omit<import("./image-viewer").ImageViewerProps, "image"> & {
|
|
8
8
|
images?: string[] | undefined;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { ImageViewerProps, MultiImageViewerProps } from './image-viewer';
|
|
2
|
-
export declare type
|
|
3
|
-
close: () => void;
|
|
4
|
-
};
|
|
5
|
-
export declare function showImageViewer(props: Omit<ImageViewerProps, 'visible'>): {
|
|
2
|
+
export declare type ImageViewerShowHandler = {
|
|
6
3
|
close: () => void;
|
|
7
4
|
};
|
|
5
|
+
export declare function showImageViewer(props: Omit<ImageViewerProps, 'visible'>): ImageViewerShowHandler;
|
|
8
6
|
export declare function showMultiImageViewer(props: Omit<MultiImageViewerProps, 'visible'>): {
|
|
9
7
|
close: () => void;
|
|
10
8
|
};
|
|
11
9
|
export declare function clearImageViewer(): void;
|
|
10
|
+
export declare const getH: () => void;
|
|
@@ -1,49 +1,18 @@
|
|
|
1
|
-
import React, { createRef, forwardRef, useEffect, useImperativeHandle, useState } from 'react';
|
|
1
|
+
import React, { createRef, forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
2
2
|
import { renderToBody } from '../../utils/render-to-body';
|
|
3
3
|
import { ImageViewer, MultiImageViewer } from './image-viewer';
|
|
4
|
-
import {
|
|
4
|
+
import { renderImperatively } from '../../utils/render-imperatively';
|
|
5
5
|
const handlerSet = new Set();
|
|
6
6
|
export function showImageViewer(props) {
|
|
7
7
|
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: () => {
|
|
8
|
+
const handler = renderImperatively(React.createElement(ImageViewer, Object.assign({}, props, {
|
|
9
|
+
afterClose: () => {
|
|
42
10
|
var _a;
|
|
43
11
|
|
|
44
|
-
|
|
12
|
+
handlerSet.delete(handler);
|
|
13
|
+
(_a = props.afterClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
45
14
|
}
|
|
46
|
-
};
|
|
15
|
+
})));
|
|
47
16
|
handlerSet.add(handler);
|
|
48
17
|
return handler;
|
|
49
18
|
}
|
|
@@ -51,30 +20,39 @@ export function showMultiImageViewer(props) {
|
|
|
51
20
|
clearImageViewer();
|
|
52
21
|
const Wrapper = forwardRef((_, ref) => {
|
|
53
22
|
const [visible, setVisible] = useState(false);
|
|
23
|
+
const closedRef = useRef(false);
|
|
54
24
|
useEffect(() => {
|
|
55
|
-
|
|
25
|
+
if (!closedRef.current) {
|
|
26
|
+
setVisible(true);
|
|
27
|
+
} else {
|
|
28
|
+
handleAfterClose();
|
|
29
|
+
}
|
|
56
30
|
}, []);
|
|
57
|
-
|
|
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
|
+
|
|
58
40
|
useImperativeHandle(ref, () => ({
|
|
59
|
-
close:
|
|
60
|
-
if (isUnmountedRef.current) return;
|
|
61
|
-
setVisible(false);
|
|
62
|
-
}
|
|
41
|
+
close: handleClose
|
|
63
42
|
}));
|
|
64
|
-
return React.createElement(MultiImageViewer, Object.assign({}, props, {
|
|
65
|
-
visible: visible,
|
|
66
|
-
onClose: () => {
|
|
67
|
-
var _a;
|
|
68
43
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
},
|
|
72
|
-
afterClose: () => {
|
|
73
|
-
var _a;
|
|
44
|
+
function handleAfterClose() {
|
|
45
|
+
var _a;
|
|
74
46
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
47
|
+
(_a = props.afterClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
48
|
+
unmount();
|
|
49
|
+
handlerSet.delete(handler);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return React.createElement(MultiImageViewer, Object.assign({}, props, {
|
|
53
|
+
visible: visible,
|
|
54
|
+
onClose: handleClose,
|
|
55
|
+
afterClose: handleAfterClose
|
|
78
56
|
}));
|
|
79
57
|
});
|
|
80
58
|
const ref = createRef();
|
|
@@ -96,4 +74,7 @@ export function clearImageViewer() {
|
|
|
96
74
|
handler.close();
|
|
97
75
|
});
|
|
98
76
|
handlerSet.clear();
|
|
99
|
-
}
|
|
77
|
+
}
|
|
78
|
+
export const getH = () => {
|
|
79
|
+
console.log(handlerSet);
|
|
80
|
+
};
|
|
@@ -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
|
}
|