@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
package/es/DialogWrap.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
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);
|
|
@@ -1,87 +1,85 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof3 = require("@babel/runtime/helpers/typeof");
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
11
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
12
9
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
-
var _ref = require("rc-util/lib/ref");
|
|
10
|
+
var _ref = require("@rc-component/util/lib/ref");
|
|
14
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
12
|
var _context = require("../../context");
|
|
16
13
|
var _MemoChildren = _interopRequireDefault(require("./MemoChildren"));
|
|
17
|
-
var _pickAttrs = _interopRequireDefault(require("rc-util/lib/pickAttrs"));
|
|
18
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function
|
|
19
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" !=
|
|
20
|
-
|
|
14
|
+
var _pickAttrs = _interopRequireDefault(require("@rc-component/util/lib/pickAttrs"));
|
|
15
|
+
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); }
|
|
16
|
+
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; }
|
|
17
|
+
const sentinelStyle = {
|
|
21
18
|
width: 0,
|
|
22
19
|
height: 0,
|
|
23
20
|
overflow: 'hidden',
|
|
24
21
|
outline: 'none'
|
|
25
22
|
};
|
|
26
|
-
|
|
23
|
+
const entityStyle = {
|
|
27
24
|
outline: 'none'
|
|
28
25
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
26
|
+
const Panel = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
27
|
+
const {
|
|
28
|
+
prefixCls,
|
|
29
|
+
className,
|
|
30
|
+
style,
|
|
31
|
+
title,
|
|
32
|
+
ariaId,
|
|
33
|
+
footer,
|
|
34
|
+
closable,
|
|
35
|
+
closeIcon,
|
|
36
|
+
onClose,
|
|
37
|
+
children,
|
|
38
|
+
bodyStyle,
|
|
39
|
+
bodyProps,
|
|
40
|
+
modalRender,
|
|
41
|
+
onMouseDown,
|
|
42
|
+
onMouseUp,
|
|
43
|
+
holderRef,
|
|
44
|
+
visible,
|
|
45
|
+
forceRender,
|
|
46
|
+
width,
|
|
47
|
+
height,
|
|
48
|
+
classNames: modalClassNames,
|
|
49
|
+
styles: modalStyles
|
|
50
|
+
} = props;
|
|
52
51
|
|
|
53
52
|
// ================================= Refs =================================
|
|
54
|
-
|
|
55
|
-
panelRef
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
53
|
+
const {
|
|
54
|
+
panel: panelRef
|
|
55
|
+
} = _react.default.useContext(_context.RefContext);
|
|
56
|
+
const mergedRef = (0, _ref.useComposeRef)(holderRef, panelRef);
|
|
57
|
+
const sentinelStartRef = (0, _react.useRef)();
|
|
58
|
+
const sentinelEndRef = (0, _react.useRef)();
|
|
59
|
+
_react.default.useImperativeHandle(ref, () => ({
|
|
60
|
+
focus: () => {
|
|
61
|
+
sentinelStartRef.current?.focus({
|
|
62
|
+
preventScroll: true
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
changeActive: next => {
|
|
66
|
+
const {
|
|
67
|
+
activeElement
|
|
68
|
+
} = document;
|
|
69
|
+
if (next && activeElement === sentinelEndRef.current) {
|
|
70
|
+
sentinelStartRef.current.focus({
|
|
71
|
+
preventScroll: true
|
|
72
|
+
});
|
|
73
|
+
} else if (!next && activeElement === sentinelStartRef.current) {
|
|
74
|
+
sentinelEndRef.current.focus({
|
|
64
75
|
preventScroll: true
|
|
65
76
|
});
|
|
66
|
-
},
|
|
67
|
-
changeActive: function changeActive(next) {
|
|
68
|
-
var _document = document,
|
|
69
|
-
activeElement = _document.activeElement;
|
|
70
|
-
if (next && activeElement === sentinelEndRef.current) {
|
|
71
|
-
sentinelStartRef.current.focus({
|
|
72
|
-
preventScroll: true
|
|
73
|
-
});
|
|
74
|
-
} else if (!next && activeElement === sentinelStartRef.current) {
|
|
75
|
-
sentinelEndRef.current.focus({
|
|
76
|
-
preventScroll: true
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
77
|
}
|
|
80
|
-
}
|
|
81
|
-
});
|
|
78
|
+
}
|
|
79
|
+
}));
|
|
82
80
|
|
|
83
81
|
// ================================ Style =================================
|
|
84
|
-
|
|
82
|
+
const contentStyle = {};
|
|
85
83
|
if (width !== undefined) {
|
|
86
84
|
contentStyle.width = width;
|
|
87
85
|
}
|
|
@@ -89,47 +87,56 @@ var Panel = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
|
89
87
|
contentStyle.height = height;
|
|
90
88
|
}
|
|
91
89
|
// ================================ Render ================================
|
|
92
|
-
|
|
93
|
-
className: (0, _classnames.default)(
|
|
94
|
-
style:
|
|
90
|
+
const footerNode = footer ? /*#__PURE__*/_react.default.createElement("div", {
|
|
91
|
+
className: (0, _classnames.default)(`${prefixCls}-footer`, modalClassNames?.footer),
|
|
92
|
+
style: {
|
|
93
|
+
...modalStyles?.footer
|
|
94
|
+
}
|
|
95
95
|
}, footer) : null;
|
|
96
|
-
|
|
97
|
-
className: (0, _classnames.default)(
|
|
98
|
-
style:
|
|
96
|
+
const headerNode = title ? /*#__PURE__*/_react.default.createElement("div", {
|
|
97
|
+
className: (0, _classnames.default)(`${prefixCls}-header`, modalClassNames?.header),
|
|
98
|
+
style: {
|
|
99
|
+
...modalStyles?.header
|
|
100
|
+
}
|
|
99
101
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
100
|
-
className: (0, _classnames.default)(
|
|
102
|
+
className: (0, _classnames.default)(`${prefixCls}-title`, modalClassNames?.title),
|
|
101
103
|
id: ariaId,
|
|
102
|
-
style:
|
|
104
|
+
style: {
|
|
105
|
+
...modalStyles?.title
|
|
106
|
+
}
|
|
103
107
|
}, title)) : null;
|
|
104
|
-
|
|
105
|
-
if (
|
|
108
|
+
const closableObj = (0, _react.useMemo)(() => {
|
|
109
|
+
if (typeof closable === 'object' && closable !== null) {
|
|
106
110
|
return closable;
|
|
107
111
|
}
|
|
108
112
|
if (closable) {
|
|
109
113
|
return {
|
|
110
|
-
closeIcon: closeIcon
|
|
111
|
-
className:
|
|
114
|
+
closeIcon: closeIcon ?? /*#__PURE__*/_react.default.createElement("span", {
|
|
115
|
+
className: `${prefixCls}-close-x`
|
|
112
116
|
})
|
|
113
117
|
};
|
|
114
118
|
}
|
|
115
119
|
return {};
|
|
116
120
|
}, [closable, closeIcon, prefixCls]);
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
121
|
+
const ariaProps = (0, _pickAttrs.default)(closableObj, true);
|
|
122
|
+
const closeBtnIsDisabled = typeof closable === 'object' && closable.disabled;
|
|
123
|
+
const closerNode = closable ? /*#__PURE__*/_react.default.createElement("button", (0, _extends2.default)({
|
|
120
124
|
type: "button",
|
|
121
125
|
onClick: onClose,
|
|
122
126
|
"aria-label": "Close"
|
|
123
127
|
}, ariaProps, {
|
|
124
|
-
className:
|
|
128
|
+
className: `${prefixCls}-close`,
|
|
125
129
|
disabled: closeBtnIsDisabled
|
|
126
130
|
}), closableObj.closeIcon) : null;
|
|
127
|
-
|
|
128
|
-
className: (0, _classnames.default)(
|
|
129
|
-
style: modalStyles
|
|
131
|
+
const content = /*#__PURE__*/_react.default.createElement("div", {
|
|
132
|
+
className: (0, _classnames.default)(`${prefixCls}-section`, modalClassNames?.section),
|
|
133
|
+
style: modalStyles?.section
|
|
130
134
|
}, closerNode, headerNode, /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
|
|
131
|
-
className: (0, _classnames.default)(
|
|
132
|
-
style:
|
|
135
|
+
className: (0, _classnames.default)(`${prefixCls}-body`, modalClassNames?.body),
|
|
136
|
+
style: {
|
|
137
|
+
...bodyStyle,
|
|
138
|
+
...modalStyles?.body
|
|
139
|
+
}
|
|
133
140
|
}, bodyProps), children), footerNode);
|
|
134
141
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
135
142
|
key: "dialog-element",
|
|
@@ -137,7 +144,10 @@ var Panel = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
|
137
144
|
"aria-labelledby": title ? ariaId : null,
|
|
138
145
|
"aria-modal": "true",
|
|
139
146
|
ref: mergedRef,
|
|
140
|
-
style:
|
|
147
|
+
style: {
|
|
148
|
+
...style,
|
|
149
|
+
...contentStyle
|
|
150
|
+
},
|
|
141
151
|
className: (0, _classnames.default)(prefixCls, className),
|
|
142
152
|
onMouseDown: onMouseDown,
|
|
143
153
|
onMouseUp: onMouseUp
|
|
@@ -1,48 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
10
|
var React = _react;
|
|
14
11
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
12
|
var _rcMotion = _interopRequireDefault(require("rc-motion"));
|
|
16
13
|
var _util = require("../../util");
|
|
17
14
|
var _Panel = _interopRequireDefault(require("./Panel"));
|
|
18
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function
|
|
19
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" !=
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
15
|
+
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); }
|
|
16
|
+
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; }
|
|
17
|
+
const Content = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
18
|
+
const {
|
|
19
|
+
prefixCls,
|
|
20
|
+
title,
|
|
21
|
+
style,
|
|
22
|
+
className,
|
|
23
|
+
visible,
|
|
24
|
+
forceRender,
|
|
25
|
+
destroyOnClose,
|
|
26
|
+
motionName,
|
|
27
|
+
ariaId,
|
|
28
|
+
onVisibleChanged,
|
|
29
|
+
mousePosition
|
|
30
|
+
} = props;
|
|
31
|
+
const dialogRef = (0, _react.useRef)();
|
|
33
32
|
|
|
34
33
|
// ============================= Style ==============================
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
transformOrigin = _React$useState2[0],
|
|
38
|
-
setTransformOrigin = _React$useState2[1];
|
|
39
|
-
var contentStyle = {};
|
|
34
|
+
const [transformOrigin, setTransformOrigin] = React.useState();
|
|
35
|
+
const contentStyle = {};
|
|
40
36
|
if (transformOrigin) {
|
|
41
37
|
contentStyle.transformOrigin = transformOrigin;
|
|
42
38
|
}
|
|
43
39
|
function onPrepare() {
|
|
44
|
-
|
|
45
|
-
setTransformOrigin(mousePosition && (mousePosition.x || mousePosition.y) ?
|
|
40
|
+
const elementOffset = (0, _util.offset)(dialogRef.current);
|
|
41
|
+
setTransformOrigin(mousePosition && (mousePosition.x || mousePosition.y) ? `${mousePosition.x - elementOffset.left}px ${mousePosition.y - elementOffset.top}px` : '');
|
|
46
42
|
}
|
|
47
43
|
|
|
48
44
|
// ============================= Render =============================
|
|
@@ -55,19 +51,22 @@ var Content = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
55
51
|
motionName: motionName,
|
|
56
52
|
removeOnLeave: destroyOnClose,
|
|
57
53
|
ref: dialogRef
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
54
|
+
}, ({
|
|
55
|
+
className: motionClassName,
|
|
56
|
+
style: motionStyle
|
|
57
|
+
}, motionRef) => /*#__PURE__*/React.createElement(_Panel.default, (0, _extends2.default)({}, props, {
|
|
58
|
+
ref: ref,
|
|
59
|
+
title: title,
|
|
60
|
+
ariaId: ariaId,
|
|
61
|
+
prefixCls: prefixCls,
|
|
62
|
+
holderRef: motionRef,
|
|
63
|
+
style: {
|
|
64
|
+
...motionStyle,
|
|
65
|
+
...style,
|
|
66
|
+
...contentStyle
|
|
67
|
+
},
|
|
68
|
+
className: (0, _classnames.default)(className, motionClassName)
|
|
69
|
+
})));
|
|
71
70
|
});
|
|
72
71
|
Content.displayName = 'Content';
|
|
73
72
|
var _default = exports.default = Content;
|
package/lib/Dialog/Mask.js
CHANGED
|
@@ -1,38 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
9
|
var React = _interopRequireWildcard(require("react"));
|
|
12
10
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
11
|
var _rcMotion = _interopRequireDefault(require("rc-motion"));
|
|
14
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function
|
|
15
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" !=
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
12
|
+
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); }
|
|
13
|
+
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; }
|
|
14
|
+
const Mask = props => {
|
|
15
|
+
const {
|
|
16
|
+
prefixCls,
|
|
17
|
+
style,
|
|
18
|
+
visible,
|
|
19
|
+
maskProps,
|
|
20
|
+
motionName,
|
|
21
|
+
className
|
|
22
|
+
} = props;
|
|
23
23
|
return /*#__PURE__*/React.createElement(_rcMotion.default, {
|
|
24
24
|
key: "mask",
|
|
25
25
|
visible: visible,
|
|
26
26
|
motionName: motionName,
|
|
27
|
-
leavedClassName:
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
leavedClassName: `${prefixCls}-mask-hidden`
|
|
28
|
+
}, ({
|
|
29
|
+
className: motionClassName,
|
|
30
|
+
style: motionStyle
|
|
31
|
+
}, ref) => /*#__PURE__*/React.createElement("div", (0, _extends2.default)({
|
|
32
|
+
ref: ref,
|
|
33
|
+
style: {
|
|
34
|
+
...motionStyle,
|
|
35
|
+
...style
|
|
36
|
+
},
|
|
37
|
+
className: (0, _classnames.default)(`${prefixCls}-mask`, motionClassName, className)
|
|
38
|
+
}, maskProps)));
|
|
37
39
|
};
|
|
38
40
|
var _default = exports.default = Mask;
|