@rc-component/dialog 1.0.0 → 1.0.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/es/Dialog/Content/MemoChildren.js +5 -7
- package/es/Dialog/Content/Panel.js +88 -77
- package/es/Dialog/Content/index.js +35 -35
- package/es/Dialog/Mask.js +21 -18
- package/es/Dialog/index.js +72 -76
- package/es/DialogWrap.js +16 -21
- package/es/IDialogPropTypes.d.ts +2 -1
- package/es/context.js +1 -1
- package/es/util.js +9 -9
- package/lib/Dialog/Content/MemoChildren.js +7 -10
- package/lib/Dialog/Content/Panel.js +90 -80
- package/lib/Dialog/Content/index.js +37 -38
- package/lib/Dialog/Mask.js +23 -21
- package/lib/Dialog/index.js +74 -79
- package/lib/DialogWrap.js +18 -24
- package/lib/IDialogPropTypes.d.ts +2 -1
- package/lib/context.js +3 -4
- package/lib/index.js +1 -1
- package/lib/util.js +9 -9
- package/package.json +4 -4
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
export default /*#__PURE__*/React.memo(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return !shouldUpdate;
|
|
8
|
-
});
|
|
2
|
+
export default /*#__PURE__*/React.memo(({
|
|
3
|
+
children
|
|
4
|
+
}) => children, (_, {
|
|
5
|
+
shouldUpdate
|
|
6
|
+
}) => !shouldUpdate);
|
|
@@ -1,77 +1,76 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
3
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
2
|
import classNames from 'classnames';
|
|
5
|
-
import { useComposeRef } from "rc-util/es/ref";
|
|
3
|
+
import { useComposeRef } from "@rc-component/util/es/ref";
|
|
6
4
|
import React, { useMemo, useRef } from 'react';
|
|
7
5
|
import { RefContext } from "../../context";
|
|
8
6
|
import MemoChildren from "./MemoChildren";
|
|
9
|
-
import pickAttrs from "rc-util/es/pickAttrs";
|
|
10
|
-
|
|
7
|
+
import pickAttrs from "@rc-component/util/es/pickAttrs";
|
|
8
|
+
const sentinelStyle = {
|
|
11
9
|
width: 0,
|
|
12
10
|
height: 0,
|
|
13
11
|
overflow: 'hidden',
|
|
14
12
|
outline: 'none'
|
|
15
13
|
};
|
|
16
|
-
|
|
14
|
+
const entityStyle = {
|
|
17
15
|
outline: 'none'
|
|
18
16
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
17
|
+
const Panel = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
18
|
+
const {
|
|
19
|
+
prefixCls,
|
|
20
|
+
className,
|
|
21
|
+
style,
|
|
22
|
+
title,
|
|
23
|
+
ariaId,
|
|
24
|
+
footer,
|
|
25
|
+
closable,
|
|
26
|
+
closeIcon,
|
|
27
|
+
onClose,
|
|
28
|
+
children,
|
|
29
|
+
bodyStyle,
|
|
30
|
+
bodyProps,
|
|
31
|
+
modalRender,
|
|
32
|
+
onMouseDown,
|
|
33
|
+
onMouseUp,
|
|
34
|
+
holderRef,
|
|
35
|
+
visible,
|
|
36
|
+
forceRender,
|
|
37
|
+
width,
|
|
38
|
+
height,
|
|
39
|
+
classNames: modalClassNames,
|
|
40
|
+
styles: modalStyles
|
|
41
|
+
} = props;
|
|
42
42
|
|
|
43
43
|
// ================================= Refs =================================
|
|
44
|
-
|
|
45
|
-
panelRef
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
44
|
+
const {
|
|
45
|
+
panel: panelRef
|
|
46
|
+
} = React.useContext(RefContext);
|
|
47
|
+
const mergedRef = useComposeRef(holderRef, panelRef);
|
|
48
|
+
const sentinelStartRef = useRef();
|
|
49
|
+
const sentinelEndRef = useRef();
|
|
50
|
+
React.useImperativeHandle(ref, () => ({
|
|
51
|
+
focus: () => {
|
|
52
|
+
sentinelStartRef.current?.focus({
|
|
53
|
+
preventScroll: true
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
changeActive: next => {
|
|
57
|
+
const {
|
|
58
|
+
activeElement
|
|
59
|
+
} = document;
|
|
60
|
+
if (next && activeElement === sentinelEndRef.current) {
|
|
61
|
+
sentinelStartRef.current.focus({
|
|
62
|
+
preventScroll: true
|
|
63
|
+
});
|
|
64
|
+
} else if (!next && activeElement === sentinelStartRef.current) {
|
|
65
|
+
sentinelEndRef.current.focus({
|
|
54
66
|
preventScroll: true
|
|
55
67
|
});
|
|
56
|
-
},
|
|
57
|
-
changeActive: function changeActive(next) {
|
|
58
|
-
var _document = document,
|
|
59
|
-
activeElement = _document.activeElement;
|
|
60
|
-
if (next && activeElement === sentinelEndRef.current) {
|
|
61
|
-
sentinelStartRef.current.focus({
|
|
62
|
-
preventScroll: true
|
|
63
|
-
});
|
|
64
|
-
} else if (!next && activeElement === sentinelStartRef.current) {
|
|
65
|
-
sentinelEndRef.current.focus({
|
|
66
|
-
preventScroll: true
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
68
|
}
|
|
70
|
-
}
|
|
71
|
-
});
|
|
69
|
+
}
|
|
70
|
+
}));
|
|
72
71
|
|
|
73
72
|
// ================================ Style =================================
|
|
74
|
-
|
|
73
|
+
const contentStyle = {};
|
|
75
74
|
if (width !== undefined) {
|
|
76
75
|
contentStyle.width = width;
|
|
77
76
|
}
|
|
@@ -79,47 +78,56 @@ var Panel = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
79
78
|
contentStyle.height = height;
|
|
80
79
|
}
|
|
81
80
|
// ================================ Render ================================
|
|
82
|
-
|
|
83
|
-
className: classNames(
|
|
84
|
-
style:
|
|
81
|
+
const footerNode = footer ? /*#__PURE__*/React.createElement("div", {
|
|
82
|
+
className: classNames(`${prefixCls}-footer`, modalClassNames?.footer),
|
|
83
|
+
style: {
|
|
84
|
+
...modalStyles?.footer
|
|
85
|
+
}
|
|
85
86
|
}, footer) : null;
|
|
86
|
-
|
|
87
|
-
className: classNames(
|
|
88
|
-
style:
|
|
87
|
+
const headerNode = title ? /*#__PURE__*/React.createElement("div", {
|
|
88
|
+
className: classNames(`${prefixCls}-header`, modalClassNames?.header),
|
|
89
|
+
style: {
|
|
90
|
+
...modalStyles?.header
|
|
91
|
+
}
|
|
89
92
|
}, /*#__PURE__*/React.createElement("div", {
|
|
90
|
-
className: classNames(
|
|
93
|
+
className: classNames(`${prefixCls}-title`, modalClassNames?.title),
|
|
91
94
|
id: ariaId,
|
|
92
|
-
style:
|
|
95
|
+
style: {
|
|
96
|
+
...modalStyles?.title
|
|
97
|
+
}
|
|
93
98
|
}, title)) : null;
|
|
94
|
-
|
|
95
|
-
if (
|
|
99
|
+
const closableObj = useMemo(() => {
|
|
100
|
+
if (typeof closable === 'object' && closable !== null) {
|
|
96
101
|
return closable;
|
|
97
102
|
}
|
|
98
103
|
if (closable) {
|
|
99
104
|
return {
|
|
100
|
-
closeIcon: closeIcon
|
|
101
|
-
className:
|
|
105
|
+
closeIcon: closeIcon ?? /*#__PURE__*/React.createElement("span", {
|
|
106
|
+
className: `${prefixCls}-close-x`
|
|
102
107
|
})
|
|
103
108
|
};
|
|
104
109
|
}
|
|
105
110
|
return {};
|
|
106
111
|
}, [closable, closeIcon, prefixCls]);
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
112
|
+
const ariaProps = pickAttrs(closableObj, true);
|
|
113
|
+
const closeBtnIsDisabled = typeof closable === 'object' && closable.disabled;
|
|
114
|
+
const closerNode = closable ? /*#__PURE__*/React.createElement("button", _extends({
|
|
110
115
|
type: "button",
|
|
111
116
|
onClick: onClose,
|
|
112
117
|
"aria-label": "Close"
|
|
113
118
|
}, ariaProps, {
|
|
114
|
-
className:
|
|
119
|
+
className: `${prefixCls}-close`,
|
|
115
120
|
disabled: closeBtnIsDisabled
|
|
116
121
|
}), closableObj.closeIcon) : null;
|
|
117
|
-
|
|
118
|
-
className: classNames(
|
|
119
|
-
style: modalStyles
|
|
122
|
+
const content = /*#__PURE__*/React.createElement("div", {
|
|
123
|
+
className: classNames(`${prefixCls}-section`, modalClassNames?.section),
|
|
124
|
+
style: modalStyles?.section
|
|
120
125
|
}, closerNode, headerNode, /*#__PURE__*/React.createElement("div", _extends({
|
|
121
|
-
className: classNames(
|
|
122
|
-
style:
|
|
126
|
+
className: classNames(`${prefixCls}-body`, modalClassNames?.body),
|
|
127
|
+
style: {
|
|
128
|
+
...bodyStyle,
|
|
129
|
+
...modalStyles?.body
|
|
130
|
+
}
|
|
123
131
|
}, bodyProps), children), footerNode);
|
|
124
132
|
return /*#__PURE__*/React.createElement("div", {
|
|
125
133
|
key: "dialog-element",
|
|
@@ -127,7 +135,10 @@ var Panel = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
127
135
|
"aria-labelledby": title ? ariaId : null,
|
|
128
136
|
"aria-modal": "true",
|
|
129
137
|
ref: mergedRef,
|
|
130
|
-
style:
|
|
138
|
+
style: {
|
|
139
|
+
...style,
|
|
140
|
+
...contentStyle
|
|
141
|
+
},
|
|
131
142
|
className: classNames(prefixCls, className),
|
|
132
143
|
onMouseDown: onMouseDown,
|
|
133
144
|
onMouseUp: onMouseUp
|
|
@@ -1,38 +1,35 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
2
|
import * as React from 'react';
|
|
5
3
|
import { useRef } from 'react';
|
|
6
4
|
import classNames from 'classnames';
|
|
7
5
|
import CSSMotion from 'rc-motion';
|
|
8
6
|
import { offset } from "../../util";
|
|
9
7
|
import Panel from "./Panel";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
8
|
+
const Content = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
9
|
+
const {
|
|
10
|
+
prefixCls,
|
|
11
|
+
title,
|
|
12
|
+
style,
|
|
13
|
+
className,
|
|
14
|
+
visible,
|
|
15
|
+
forceRender,
|
|
16
|
+
destroyOnClose,
|
|
17
|
+
motionName,
|
|
18
|
+
ariaId,
|
|
19
|
+
onVisibleChanged,
|
|
20
|
+
mousePosition
|
|
21
|
+
} = props;
|
|
22
|
+
const dialogRef = useRef();
|
|
23
23
|
|
|
24
24
|
// ============================= Style ==============================
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
transformOrigin = _React$useState2[0],
|
|
28
|
-
setTransformOrigin = _React$useState2[1];
|
|
29
|
-
var contentStyle = {};
|
|
25
|
+
const [transformOrigin, setTransformOrigin] = React.useState();
|
|
26
|
+
const contentStyle = {};
|
|
30
27
|
if (transformOrigin) {
|
|
31
28
|
contentStyle.transformOrigin = transformOrigin;
|
|
32
29
|
}
|
|
33
30
|
function onPrepare() {
|
|
34
|
-
|
|
35
|
-
setTransformOrigin(mousePosition && (mousePosition.x || mousePosition.y) ?
|
|
31
|
+
const elementOffset = offset(dialogRef.current);
|
|
32
|
+
setTransformOrigin(mousePosition && (mousePosition.x || mousePosition.y) ? `${mousePosition.x - elementOffset.left}px ${mousePosition.y - elementOffset.top}px` : '');
|
|
36
33
|
}
|
|
37
34
|
|
|
38
35
|
// ============================= Render =============================
|
|
@@ -45,19 +42,22 @@ var Content = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
45
42
|
motionName: motionName,
|
|
46
43
|
removeOnLeave: destroyOnClose,
|
|
47
44
|
ref: dialogRef
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
45
|
+
}, ({
|
|
46
|
+
className: motionClassName,
|
|
47
|
+
style: motionStyle
|
|
48
|
+
}, motionRef) => /*#__PURE__*/React.createElement(Panel, _extends({}, props, {
|
|
49
|
+
ref: ref,
|
|
50
|
+
title: title,
|
|
51
|
+
ariaId: ariaId,
|
|
52
|
+
prefixCls: prefixCls,
|
|
53
|
+
holderRef: motionRef,
|
|
54
|
+
style: {
|
|
55
|
+
...motionStyle,
|
|
56
|
+
...style,
|
|
57
|
+
...contentStyle
|
|
58
|
+
},
|
|
59
|
+
className: classNames(className, motionClassName)
|
|
60
|
+
})));
|
|
61
61
|
});
|
|
62
62
|
Content.displayName = 'Content';
|
|
63
63
|
export default Content;
|
package/es/Dialog/Mask.js
CHANGED
|
@@ -1,28 +1,31 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
2
|
import * as React from 'react';
|
|
4
3
|
import classNames from 'classnames';
|
|
5
4
|
import CSSMotion from 'rc-motion';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
const Mask = props => {
|
|
6
|
+
const {
|
|
7
|
+
prefixCls,
|
|
8
|
+
style,
|
|
9
|
+
visible,
|
|
10
|
+
maskProps,
|
|
11
|
+
motionName,
|
|
12
|
+
className
|
|
13
|
+
} = props;
|
|
13
14
|
return /*#__PURE__*/React.createElement(CSSMotion, {
|
|
14
15
|
key: "mask",
|
|
15
16
|
visible: visible,
|
|
16
17
|
motionName: motionName,
|
|
17
|
-
leavedClassName:
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
leavedClassName: `${prefixCls}-mask-hidden`
|
|
19
|
+
}, ({
|
|
20
|
+
className: motionClassName,
|
|
21
|
+
style: motionStyle
|
|
22
|
+
}, ref) => /*#__PURE__*/React.createElement("div", _extends({
|
|
23
|
+
ref: ref,
|
|
24
|
+
style: {
|
|
25
|
+
...motionStyle,
|
|
26
|
+
...style
|
|
27
|
+
},
|
|
28
|
+
className: classNames(`${prefixCls}-mask`, motionClassName, className)
|
|
29
|
+
}, maskProps)));
|
|
27
30
|
};
|
|
28
31
|
export default Mask;
|
package/es/Dialog/index.js
CHANGED
|
@@ -1,67 +1,62 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
2
|
import classNames from 'classnames';
|
|
5
|
-
import contains from "rc-util/es/Dom/contains";
|
|
6
|
-
import useId from "rc-util/es/hooks/useId";
|
|
7
|
-
import KeyCode from "rc-util/es/KeyCode";
|
|
8
|
-
import pickAttrs from "rc-util/es/pickAttrs";
|
|
3
|
+
import contains from "@rc-component/util/es/Dom/contains";
|
|
4
|
+
import useId from "@rc-component/util/es/hooks/useId";
|
|
5
|
+
import KeyCode from "@rc-component/util/es/KeyCode";
|
|
6
|
+
import pickAttrs from "@rc-component/util/es/pickAttrs";
|
|
9
7
|
import * as React from 'react';
|
|
10
8
|
import { useEffect, useRef } from 'react';
|
|
11
9
|
import { getMotionName } from "../util";
|
|
12
10
|
import Content from "./Content";
|
|
13
11
|
import Mask from "./Mask";
|
|
14
|
-
import { warning } from "rc-util/es/warning";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
prefixCls =
|
|
18
|
-
zIndex
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
transitionName
|
|
32
|
-
animation
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
12
|
+
import { warning } from "@rc-component/util/es/warning";
|
|
13
|
+
const Dialog = props => {
|
|
14
|
+
const {
|
|
15
|
+
prefixCls = 'rc-dialog',
|
|
16
|
+
zIndex,
|
|
17
|
+
visible = false,
|
|
18
|
+
keyboard = true,
|
|
19
|
+
focusTriggerAfterClose = true,
|
|
20
|
+
// scrollLocker,
|
|
21
|
+
// Wrapper
|
|
22
|
+
wrapStyle,
|
|
23
|
+
wrapClassName,
|
|
24
|
+
wrapProps,
|
|
25
|
+
onClose,
|
|
26
|
+
afterOpenChange,
|
|
27
|
+
afterClose,
|
|
28
|
+
// Dialog
|
|
29
|
+
transitionName,
|
|
30
|
+
animation,
|
|
31
|
+
closable = true,
|
|
32
|
+
// Mask
|
|
33
|
+
mask = true,
|
|
34
|
+
maskTransitionName,
|
|
35
|
+
maskAnimation,
|
|
36
|
+
maskClosable = true,
|
|
37
|
+
maskStyle,
|
|
38
|
+
maskProps,
|
|
39
|
+
rootClassName,
|
|
40
|
+
rootStyle,
|
|
41
|
+
classNames: modalClassNames,
|
|
42
|
+
styles: modalStyles
|
|
43
|
+
} = props;
|
|
46
44
|
if (process.env.NODE_ENV !== 'production') {
|
|
47
|
-
['wrapStyle', 'bodyStyle', 'maskStyle'].forEach(
|
|
45
|
+
['wrapStyle', 'bodyStyle', 'maskStyle'].forEach(prop => {
|
|
48
46
|
// (prop in props) && console.error(`Warning: ${prop} is deprecated, please use styles instead.`)
|
|
49
|
-
warning(!(prop in props),
|
|
47
|
+
warning(!(prop in props), `${prop} is deprecated, please use styles instead.`);
|
|
50
48
|
});
|
|
51
49
|
if ('wrapClassName' in props) {
|
|
52
|
-
warning(false,
|
|
50
|
+
warning(false, `wrapClassName is deprecated, please use classNames instead.`);
|
|
53
51
|
}
|
|
54
52
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
60
|
-
animatedVisible = _React$useState2[0],
|
|
61
|
-
setAnimatedVisible = _React$useState2[1];
|
|
53
|
+
const lastOutSideActiveElementRef = useRef();
|
|
54
|
+
const wrapperRef = useRef();
|
|
55
|
+
const contentRef = useRef();
|
|
56
|
+
const [animatedVisible, setAnimatedVisible] = React.useState(visible);
|
|
62
57
|
|
|
63
58
|
// ========================== Init ==========================
|
|
64
|
-
|
|
59
|
+
const ariaId = useId();
|
|
65
60
|
function saveLastOutSideActiveElementRef() {
|
|
66
61
|
if (!contains(wrapperRef.current, document.activeElement)) {
|
|
67
62
|
lastOutSideActiveElementRef.current = document.activeElement;
|
|
@@ -69,8 +64,7 @@ var Dialog = function Dialog(props) {
|
|
|
69
64
|
}
|
|
70
65
|
function focusDialogContent() {
|
|
71
66
|
if (!contains(wrapperRef.current, document.activeElement)) {
|
|
72
|
-
|
|
73
|
-
(_contentRef$current = contentRef.current) === null || _contentRef$current === void 0 || _contentRef$current.focus();
|
|
67
|
+
contentRef.current?.focus();
|
|
74
68
|
}
|
|
75
69
|
}
|
|
76
70
|
|
|
@@ -95,35 +89,35 @@ var Dialog = function Dialog(props) {
|
|
|
95
89
|
|
|
96
90
|
// Trigger afterClose only when change visible from true to false
|
|
97
91
|
if (animatedVisible) {
|
|
98
|
-
afterClose
|
|
92
|
+
afterClose?.();
|
|
99
93
|
}
|
|
100
94
|
}
|
|
101
|
-
afterOpenChange
|
|
95
|
+
afterOpenChange?.(newVisible);
|
|
102
96
|
}
|
|
103
97
|
function onInternalClose(e) {
|
|
104
|
-
onClose
|
|
98
|
+
onClose?.(e);
|
|
105
99
|
}
|
|
106
100
|
|
|
107
101
|
// >>> Content
|
|
108
|
-
|
|
109
|
-
|
|
102
|
+
const contentClickRef = useRef(false);
|
|
103
|
+
const contentTimeoutRef = useRef();
|
|
110
104
|
|
|
111
105
|
// We need record content click incase content popup out of dialog
|
|
112
|
-
|
|
106
|
+
const onContentMouseDown = () => {
|
|
113
107
|
clearTimeout(contentTimeoutRef.current);
|
|
114
108
|
contentClickRef.current = true;
|
|
115
109
|
};
|
|
116
|
-
|
|
117
|
-
contentTimeoutRef.current = setTimeout(
|
|
110
|
+
const onContentMouseUp = () => {
|
|
111
|
+
contentTimeoutRef.current = setTimeout(() => {
|
|
118
112
|
contentClickRef.current = false;
|
|
119
113
|
});
|
|
120
114
|
};
|
|
121
115
|
|
|
122
116
|
// >>> Wrapper
|
|
123
117
|
// Close only when element not on dialog
|
|
124
|
-
|
|
118
|
+
let onWrapperClick = null;
|
|
125
119
|
if (maskClosable) {
|
|
126
|
-
onWrapperClick =
|
|
120
|
+
onWrapperClick = e => {
|
|
127
121
|
if (contentClickRef.current) {
|
|
128
122
|
contentClickRef.current = false;
|
|
129
123
|
} else if (wrapperRef.current === e.target) {
|
|
@@ -145,7 +139,7 @@ var Dialog = function Dialog(props) {
|
|
|
145
139
|
}
|
|
146
140
|
|
|
147
141
|
// ========================= Effect =========================
|
|
148
|
-
useEffect(
|
|
142
|
+
useEffect(() => {
|
|
149
143
|
if (visible) {
|
|
150
144
|
setAnimatedVisible(true);
|
|
151
145
|
saveLastOutSideActiveElementRef();
|
|
@@ -153,35 +147,37 @@ var Dialog = function Dialog(props) {
|
|
|
153
147
|
}, [visible]);
|
|
154
148
|
|
|
155
149
|
// Remove direct should also check the scroll bar update
|
|
156
|
-
useEffect(
|
|
157
|
-
|
|
158
|
-
clearTimeout(contentTimeoutRef.current);
|
|
159
|
-
};
|
|
150
|
+
useEffect(() => () => {
|
|
151
|
+
clearTimeout(contentTimeoutRef.current);
|
|
160
152
|
}, []);
|
|
161
|
-
|
|
162
|
-
zIndex
|
|
163
|
-
|
|
153
|
+
const mergedStyle = {
|
|
154
|
+
zIndex,
|
|
155
|
+
...wrapStyle,
|
|
156
|
+
...modalStyles?.wrapper,
|
|
164
157
|
display: !animatedVisible ? 'none' : null
|
|
165
|
-
}
|
|
158
|
+
};
|
|
166
159
|
|
|
167
160
|
// ========================= Render =========================
|
|
168
161
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
169
|
-
className: classNames(
|
|
162
|
+
className: classNames(`${prefixCls}-root`, rootClassName),
|
|
163
|
+
style: rootStyle
|
|
170
164
|
}, pickAttrs(props, {
|
|
171
165
|
data: true
|
|
172
166
|
})), /*#__PURE__*/React.createElement(Mask, {
|
|
173
167
|
prefixCls: prefixCls,
|
|
174
168
|
visible: mask && visible,
|
|
175
169
|
motionName: getMotionName(prefixCls, maskTransitionName, maskAnimation),
|
|
176
|
-
style:
|
|
177
|
-
zIndex
|
|
178
|
-
|
|
170
|
+
style: {
|
|
171
|
+
zIndex,
|
|
172
|
+
...maskStyle,
|
|
173
|
+
...modalStyles?.mask
|
|
174
|
+
},
|
|
179
175
|
maskProps: maskProps,
|
|
180
|
-
className: modalClassNames
|
|
176
|
+
className: modalClassNames?.mask
|
|
181
177
|
}), /*#__PURE__*/React.createElement("div", _extends({
|
|
182
178
|
tabIndex: -1,
|
|
183
179
|
onKeyDown: onWrapperKeyDown,
|
|
184
|
-
className: classNames(
|
|
180
|
+
className: classNames(`${prefixCls}-wrap`, wrapClassName, modalClassNames?.wrapper),
|
|
185
181
|
ref: wrapperRef,
|
|
186
182
|
onClick: onWrapperClick,
|
|
187
183
|
style: mergedStyle
|