@rc-component/dialog 1.0.0 → 1.1.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/dist/10509781610555453368.hot-update-url-map.json +1 -0
- package/dist/10509781610555453368.hot-update.json +1 -0
- package/dist/11977476592833392720.hot-update-url-map.json +1 -0
- package/dist/11977476592833392720.hot-update.json +1 -0
- package/dist/14397576132152343869.hot-update-url-map.json +1 -0
- package/dist/14397576132152343869.hot-update.json +1 -0
- package/dist/14597408625395534096.hot-update-url-map.json +1 -0
- package/dist/14597408625395534096.hot-update.json +1 -0
- package/dist/15104553912779929595.hot-update-url-map.json +1 -0
- package/dist/15104553912779929595.hot-update.json +1 -0
- package/dist/4361192314875393955.hot-update-url-map.json +1 -0
- package/dist/4361192314875393955.hot-update.json +1 -0
- package/dist/4704580574928883170.hot-update-url-map.json +1 -0
- package/dist/4704580574928883170.hot-update.json +1 -0
- package/dist/5496443382647786649.hot-update-url-map.json +1 -0
- package/dist/5496443382647786649.hot-update.json +1 -0
- package/dist/7338948553039754745.hot-update-url-map.json +1 -0
- package/dist/7338948553039754745.hot-update.json +1 -0
- package/dist/7441995189917427860.hot-update-url-map.json +1 -0
- package/dist/7441995189917427860.hot-update.json +1 -0
- package/dist/8425845753817463333.hot-update-url-map.json +1 -0
- package/dist/8425845753817463333.hot-update.json +1 -0
- package/dist/8742625841545363477.hot-update-url-map.json +1 -0
- package/dist/8742625841545363477.hot-update.json +1 -0
- package/dist/960384830459946830.hot-update-url-map.json +1 -0
- package/dist/960384830459946830.hot-update.json +1 -0
- package/dist/9707589364653732454.hot-update-url-map.json +1 -0
- package/dist/9707589364653732454.hot-update.json +1 -0
- package/dist/common-async.10509781610555453368.hot-update.js +268 -0
- package/dist/common-async.10509781610555453368.hot-update.js.map +1 -0
- package/dist/common-async.11977476592833392720.hot-update.js +395 -0
- package/dist/common-async.11977476592833392720.hot-update.js.map +1 -0
- package/dist/common-async.14397576132152343869.hot-update.js +395 -0
- package/dist/common-async.14397576132152343869.hot-update.js.map +1 -0
- package/dist/common-async.14597408625395534096.hot-update.js +268 -0
- package/dist/common-async.14597408625395534096.hot-update.js.map +1 -0
- package/dist/common-async.15104553912779929595.hot-update.js +268 -0
- package/dist/common-async.15104553912779929595.hot-update.js.map +1 -0
- package/dist/common-async.4361192314875393955.hot-update.js +268 -0
- package/dist/common-async.4361192314875393955.hot-update.js.map +1 -0
- package/dist/common-async.4704580574928883170.hot-update.js +268 -0
- package/dist/common-async.4704580574928883170.hot-update.js.map +1 -0
- package/dist/common-async.5496443382647786649.hot-update.js +391 -0
- package/dist/common-async.5496443382647786649.hot-update.js.map +1 -0
- package/dist/common-async.7338948553039754745.hot-update.js +395 -0
- package/dist/common-async.7338948553039754745.hot-update.js.map +1 -0
- package/dist/common-async.7441995189917427860.hot-update.js +394 -0
- package/dist/common-async.7441995189917427860.hot-update.js.map +1 -0
- package/dist/common-async.8425845753817463333.hot-update.js +268 -0
- package/dist/common-async.8425845753817463333.hot-update.js.map +1 -0
- package/dist/common-async.8742625841545363477.hot-update.js +268 -0
- package/dist/common-async.8742625841545363477.hot-update.js.map +1 -0
- package/dist/common-async.960384830459946830.hot-update.js +268 -0
- package/dist/common-async.960384830459946830.hot-update.js.map +1 -0
- package/dist/common-async.9707589364653732454.hot-update.js +268 -0
- package/dist/common-async.9707589364653732454.hot-update.js.map +1 -0
- package/dist/common-async.js +1180 -0
- package/dist/common-async.js.map +1 -0
- package/dist/demos-async.7338948553039754745.hot-update.js +395 -0
- package/dist/demos-async.7338948553039754745.hot-update.js.map +1 -0
- package/dist/demos-async.css +396 -0
- package/dist/demos-async.css.map +1 -0
- package/dist/demos-async.js +1242 -0
- package/dist/demos-async.js.map +1 -0
- package/dist/docs_changelog_md-async.js +2159 -0
- package/dist/docs_changelog_md-async.js.map +1 -0
- package/dist/docs_demo_ant-design_md-async.js +119 -0
- package/dist/docs_demo_ant-design_md-async.js.map +1 -0
- package/dist/docs_demo_bootstrap_md-async.js +119 -0
- package/dist/docs_demo_bootstrap_md-async.js.map +1 -0
- package/dist/docs_demo_draggable_md-async.js +119 -0
- package/dist/docs_demo_draggable_md-async.js.map +1 -0
- package/dist/docs_demo_multiple-Portal_md-async.js +119 -0
- package/dist/docs_demo_multiple-Portal_md-async.js.map +1 -0
- package/dist/docs_demo_pure_md-async.js +119 -0
- package/dist/docs_demo_pure_md-async.js.map +1 -0
- package/dist/docs_index_md-async.js +1717 -0
- package/dist/docs_index_md-async.js.map +1 -0
- package/dist/dumi__tmp__dumi__theme__ContextWrapper-async.js +201 -0
- package/dist/dumi__tmp__dumi__theme__ContextWrapper-async.js.map +1 -0
- package/dist/meta__docs-async.7338948553039754745.hot-update.js +395 -0
- package/dist/meta__docs-async.7338948553039754745.hot-update.js.map +1 -0
- package/dist/meta__docs-async.css +396 -0
- package/dist/meta__docs-async.css.map +1 -0
- package/dist/meta__docs-async.js +2391 -0
- package/dist/meta__docs-async.js.map +1 -0
- package/dist/nm__dumi__dist__client__pages__404-async.js +69 -0
- package/dist/nm__dumi__dist__client__pages__404-async.js.map +1 -0
- package/dist/nm__dumi__dist__client__pages__Demo__index-async.js +63 -0
- package/dist/nm__dumi__dist__client__pages__Demo__index-async.js.map +1 -0
- package/dist/node_modules__dumi_2_4_17_dumi_dist_client_misc_reactDemoCompiler_js-async.js +368 -0
- package/dist/node_modules__dumi_2_4_17_dumi_dist_client_misc_reactDemoCompiler_js-async.js.map +1 -0
- package/dist/node_modules__dumi_2_4_17_dumi_theme-default_layouts_DocLayout_index_js-async.js +1077 -0
- package/dist/node_modules__dumi_2_4_17_dumi_theme-default_layouts_DocLayout_index_js-async.js.map +1 -0
- package/dist/node_modules__react-dom_18_3_1_react-dom_server_browser_js-async.js +18 -0
- package/dist/node_modules__react-dom_18_3_1_react-dom_server_browser_js-async.js.map +1 -0
- package/dist/umi.css +1302 -0
- package/dist/umi.css.map +1 -0
- package/dist/umi.js +80442 -0
- package/dist/umi.js.map +1 -0
- package/dist/vendors-async.css +22545 -0
- package/dist/vendors-async.css.map +1 -0
- package/dist/vendors-async.js +53289 -0
- package/dist/vendors-async.js.map +1 -0
- package/es/Dialog/Content/MemoChildren.js +5 -7
- package/es/Dialog/Content/Panel.d.ts +2 -2
- package/es/Dialog/Content/Panel.js +89 -78
- package/es/Dialog/Content/index.d.ts +4 -1
- package/es/Dialog/Content/index.js +45 -37
- package/es/Dialog/Mask.js +23 -20
- package/es/Dialog/index.js +97 -93
- package/es/DialogWrap.js +17 -22
- 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.d.ts +2 -2
- package/lib/Dialog/Content/Panel.js +93 -83
- package/lib/Dialog/Content/index.d.ts +4 -1
- package/lib/Dialog/Content/index.js +49 -42
- package/lib/Dialog/Mask.js +27 -25
- package/lib/Dialog/index.js +103 -100
- package/lib/DialogWrap.js +21 -27
- package/lib/IDialogPropTypes.d.ts +2 -1
- package/lib/context.js +3 -4
- package/lib/index.js +2 -2
- package/lib/util.js +9 -9
- package/package.json +11 -16
package/es/Dialog/index.js
CHANGED
|
@@ -1,67 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
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,61 +64,66 @@ 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
|
|
|
77
71
|
// ========================= Events =========================
|
|
72
|
+
// Close action will trigger by:
|
|
73
|
+
// 1. When hide motion end
|
|
74
|
+
// 2. Controlled `open` to `false` immediately after set to `true` which will not trigger motion
|
|
75
|
+
function doClose() {
|
|
76
|
+
// Clean up scroll bar & focus back
|
|
77
|
+
setAnimatedVisible(false);
|
|
78
|
+
if (mask && lastOutSideActiveElementRef.current && focusTriggerAfterClose) {
|
|
79
|
+
try {
|
|
80
|
+
lastOutSideActiveElementRef.current.focus({
|
|
81
|
+
preventScroll: true
|
|
82
|
+
});
|
|
83
|
+
} catch (e) {
|
|
84
|
+
// Do nothing
|
|
85
|
+
}
|
|
86
|
+
lastOutSideActiveElementRef.current = null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Trigger afterClose only when change visible from true to false
|
|
90
|
+
if (animatedVisible) {
|
|
91
|
+
afterClose?.();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
78
94
|
function onDialogVisibleChanged(newVisible) {
|
|
79
95
|
// Try to focus
|
|
80
96
|
if (newVisible) {
|
|
81
97
|
focusDialogContent();
|
|
82
98
|
} else {
|
|
83
|
-
|
|
84
|
-
setAnimatedVisible(false);
|
|
85
|
-
if (mask && lastOutSideActiveElementRef.current && focusTriggerAfterClose) {
|
|
86
|
-
try {
|
|
87
|
-
lastOutSideActiveElementRef.current.focus({
|
|
88
|
-
preventScroll: true
|
|
89
|
-
});
|
|
90
|
-
} catch (e) {
|
|
91
|
-
// Do nothing
|
|
92
|
-
}
|
|
93
|
-
lastOutSideActiveElementRef.current = null;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// Trigger afterClose only when change visible from true to false
|
|
97
|
-
if (animatedVisible) {
|
|
98
|
-
afterClose === null || afterClose === void 0 || afterClose();
|
|
99
|
-
}
|
|
99
|
+
doClose();
|
|
100
100
|
}
|
|
101
|
-
afterOpenChange
|
|
101
|
+
afterOpenChange?.(newVisible);
|
|
102
102
|
}
|
|
103
103
|
function onInternalClose(e) {
|
|
104
|
-
onClose
|
|
104
|
+
onClose?.(e);
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
// >>> Content
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
const contentClickRef = useRef(false);
|
|
109
|
+
const contentTimeoutRef = useRef();
|
|
110
110
|
|
|
111
111
|
// We need record content click incase content popup out of dialog
|
|
112
|
-
|
|
112
|
+
const onContentMouseDown = () => {
|
|
113
113
|
clearTimeout(contentTimeoutRef.current);
|
|
114
114
|
contentClickRef.current = true;
|
|
115
115
|
};
|
|
116
|
-
|
|
117
|
-
contentTimeoutRef.current = setTimeout(
|
|
116
|
+
const onContentMouseUp = () => {
|
|
117
|
+
contentTimeoutRef.current = setTimeout(() => {
|
|
118
118
|
contentClickRef.current = false;
|
|
119
119
|
});
|
|
120
120
|
};
|
|
121
121
|
|
|
122
122
|
// >>> Wrapper
|
|
123
123
|
// Close only when element not on dialog
|
|
124
|
-
|
|
124
|
+
let onWrapperClick = null;
|
|
125
125
|
if (maskClosable) {
|
|
126
|
-
onWrapperClick =
|
|
126
|
+
onWrapperClick = e => {
|
|
127
127
|
if (contentClickRef.current) {
|
|
128
128
|
contentClickRef.current = false;
|
|
129
129
|
} else if (wrapperRef.current === e.target) {
|
|
@@ -145,43 +145,47 @@ var Dialog = function Dialog(props) {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
// ========================= Effect =========================
|
|
148
|
-
useEffect(
|
|
148
|
+
useEffect(() => {
|
|
149
149
|
if (visible) {
|
|
150
150
|
setAnimatedVisible(true);
|
|
151
151
|
saveLastOutSideActiveElementRef();
|
|
152
|
+
} else if (animatedVisible && contentRef.current.enableMotion() && !contentRef.current.inMotion()) {
|
|
153
|
+
doClose();
|
|
152
154
|
}
|
|
153
155
|
}, [visible]);
|
|
154
156
|
|
|
155
157
|
// Remove direct should also check the scroll bar update
|
|
156
|
-
useEffect(
|
|
157
|
-
|
|
158
|
-
clearTimeout(contentTimeoutRef.current);
|
|
159
|
-
};
|
|
158
|
+
useEffect(() => () => {
|
|
159
|
+
clearTimeout(contentTimeoutRef.current);
|
|
160
160
|
}, []);
|
|
161
|
-
|
|
162
|
-
zIndex
|
|
163
|
-
|
|
161
|
+
const mergedStyle = {
|
|
162
|
+
zIndex,
|
|
163
|
+
...wrapStyle,
|
|
164
|
+
...modalStyles?.wrapper,
|
|
164
165
|
display: !animatedVisible ? 'none' : null
|
|
165
|
-
}
|
|
166
|
+
};
|
|
166
167
|
|
|
167
168
|
// ========================= Render =========================
|
|
168
169
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
169
|
-
className: classNames(
|
|
170
|
+
className: classNames(`${prefixCls}-root`, rootClassName),
|
|
171
|
+
style: rootStyle
|
|
170
172
|
}, pickAttrs(props, {
|
|
171
173
|
data: true
|
|
172
174
|
})), /*#__PURE__*/React.createElement(Mask, {
|
|
173
175
|
prefixCls: prefixCls,
|
|
174
176
|
visible: mask && visible,
|
|
175
177
|
motionName: getMotionName(prefixCls, maskTransitionName, maskAnimation),
|
|
176
|
-
style:
|
|
177
|
-
zIndex
|
|
178
|
-
|
|
178
|
+
style: {
|
|
179
|
+
zIndex,
|
|
180
|
+
...maskStyle,
|
|
181
|
+
...modalStyles?.mask
|
|
182
|
+
},
|
|
179
183
|
maskProps: maskProps,
|
|
180
|
-
className: modalClassNames
|
|
184
|
+
className: modalClassNames?.mask
|
|
181
185
|
}), /*#__PURE__*/React.createElement("div", _extends({
|
|
182
186
|
tabIndex: -1,
|
|
183
187
|
onKeyDown: onWrapperKeyDown,
|
|
184
|
-
className: classNames(
|
|
188
|
+
className: classNames(`${prefixCls}-wrap`, wrapClassName, modalClassNames?.wrapper),
|
|
185
189
|
ref: wrapperRef,
|
|
186
190
|
onClick: onWrapperClick,
|
|
187
191
|
style: mergedStyle
|
package/es/DialogWrap.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
2
|
import Portal from '@rc-component/portal';
|
|
4
3
|
import * as React from 'react';
|
|
5
4
|
import { RefContext } from "./context";
|
|
@@ -13,24 +12,20 @@ import Dialog from "./Dialog";
|
|
|
13
12
|
* So here should add a child (div element) to custom container.
|
|
14
13
|
* */
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
destroyOnClose =
|
|
22
|
-
|
|
23
|
-
panelRef
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
panel: panelRef
|
|
31
|
-
};
|
|
32
|
-
}, [panelRef]);
|
|
33
|
-
React.useEffect(function () {
|
|
15
|
+
const DialogWrap = props => {
|
|
16
|
+
const {
|
|
17
|
+
visible,
|
|
18
|
+
getContainer,
|
|
19
|
+
forceRender,
|
|
20
|
+
destroyOnClose = false,
|
|
21
|
+
afterClose,
|
|
22
|
+
panelRef
|
|
23
|
+
} = props;
|
|
24
|
+
const [animatedVisible, setAnimatedVisible] = React.useState(visible);
|
|
25
|
+
const refContext = React.useMemo(() => ({
|
|
26
|
+
panel: panelRef
|
|
27
|
+
}), [panelRef]);
|
|
28
|
+
React.useEffect(() => {
|
|
34
29
|
if (visible) {
|
|
35
30
|
setAnimatedVisible(true);
|
|
36
31
|
}
|
|
@@ -49,8 +44,8 @@ var DialogWrap = function DialogWrap(props) {
|
|
|
49
44
|
autoLock: visible || animatedVisible
|
|
50
45
|
}, /*#__PURE__*/React.createElement(Dialog, _extends({}, props, {
|
|
51
46
|
destroyOnClose: destroyOnClose,
|
|
52
|
-
afterClose:
|
|
53
|
-
|
|
47
|
+
afterClose: () => {
|
|
48
|
+
afterClose?.();
|
|
54
49
|
setAnimatedVisible(false);
|
|
55
50
|
}
|
|
56
51
|
}))));
|
package/es/IDialogPropTypes.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GetContainer } from 'rc-util/lib/PortalWrapper';
|
|
1
|
+
import type { GetContainer } from '@rc-component/util/lib/PortalWrapper';
|
|
2
2
|
import type { CSSProperties, ReactNode, SyntheticEvent } from 'react';
|
|
3
3
|
export type SemanticName = 'header' | 'body' | 'footer' | 'section' | 'title' | 'wrapper' | 'mask';
|
|
4
4
|
export type ModalClassNames = Partial<Record<SemanticName, string>>;
|
|
@@ -7,6 +7,7 @@ export type IDialogPropTypes = {
|
|
|
7
7
|
className?: string;
|
|
8
8
|
keyboard?: boolean;
|
|
9
9
|
style?: CSSProperties;
|
|
10
|
+
rootStyle?: CSSProperties;
|
|
10
11
|
mask?: boolean;
|
|
11
12
|
children?: React.ReactNode;
|
|
12
13
|
afterClose?: () => any;
|
package/es/context.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
export
|
|
2
|
+
export const RefContext = /*#__PURE__*/React.createContext({});
|
package/es/util.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
// =============================== Motion ===============================
|
|
2
2
|
export function getMotionName(prefixCls, transitionName, animationName) {
|
|
3
|
-
|
|
3
|
+
let motionName = transitionName;
|
|
4
4
|
if (!motionName && animationName) {
|
|
5
|
-
motionName =
|
|
5
|
+
motionName = `${prefixCls}-${animationName}`;
|
|
6
6
|
}
|
|
7
7
|
return motionName;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
// =============================== Offset ===============================
|
|
11
11
|
function getScroll(w, top) {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
let ret = w[`page${top ? 'Y' : 'X'}Offset`];
|
|
13
|
+
const method = `scroll${top ? 'Top' : 'Left'}`;
|
|
14
14
|
if (typeof ret !== 'number') {
|
|
15
|
-
|
|
15
|
+
const d = w.document;
|
|
16
16
|
ret = d.documentElement[method];
|
|
17
17
|
if (typeof ret !== 'number') {
|
|
18
18
|
ret = d.body[method];
|
|
@@ -21,13 +21,13 @@ function getScroll(w, top) {
|
|
|
21
21
|
return ret;
|
|
22
22
|
}
|
|
23
23
|
export function offset(el) {
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
const rect = el.getBoundingClientRect();
|
|
25
|
+
const pos = {
|
|
26
26
|
left: rect.left,
|
|
27
27
|
top: rect.top
|
|
28
28
|
};
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
const doc = el.ownerDocument;
|
|
30
|
+
const w = doc.defaultView || doc.parentWindow;
|
|
31
31
|
pos.left += getScroll(w);
|
|
32
32
|
pos.top += getScroll(w, true);
|
|
33
33
|
return pos;
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.default = void 0;
|
|
8
7
|
var React = _interopRequireWildcard(require("react"));
|
|
9
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function
|
|
10
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" !=
|
|
11
|
-
var _default = exports.default = /*#__PURE__*/React.memo(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return !shouldUpdate;
|
|
17
|
-
});
|
|
8
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
9
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
10
|
+
var _default = exports.default = /*#__PURE__*/React.memo(({
|
|
11
|
+
children
|
|
12
|
+
}) => children, (_, {
|
|
13
|
+
shouldUpdate
|
|
14
|
+
}) => !shouldUpdate);
|
|
@@ -7,9 +7,9 @@ export interface PanelProps extends Omit<IDialogPropTypes, 'getOpenCount'> {
|
|
|
7
7
|
onMouseUp?: React.MouseEventHandler;
|
|
8
8
|
holderRef?: React.Ref<HTMLDivElement>;
|
|
9
9
|
}
|
|
10
|
-
export type
|
|
10
|
+
export type PanelRef = {
|
|
11
11
|
focus: () => void;
|
|
12
12
|
changeActive: (next: boolean) => void;
|
|
13
13
|
};
|
|
14
|
-
declare const Panel: React.ForwardRefExoticComponent<PanelProps & React.RefAttributes<
|
|
14
|
+
declare const Panel: React.ForwardRefExoticComponent<PanelProps & React.RefAttributes<PanelRef>>;
|
|
15
15
|
export default Panel;
|