@rc-component/dialog 1.0.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/LICENSE.md +9 -0
- package/README.md +108 -0
- package/assets/bootstrap.css +177 -0
- package/assets/index.css +174 -0
- package/es/Dialog/Content/MemoChildren.d.ts +7 -0
- package/es/Dialog/Content/MemoChildren.js +8 -0
- package/es/Dialog/Content/Panel.d.ts +15 -0
- package/es/Dialog/Content/Panel.js +149 -0
- package/es/Dialog/Content/index.d.ts +13 -0
- package/es/Dialog/Content/index.js +63 -0
- package/es/Dialog/Mask.d.ts +11 -0
- package/es/Dialog/Mask.js +28 -0
- package/es/Dialog/index.d.ts +4 -0
- package/es/Dialog/index.js +201 -0
- package/es/DialogWrap.d.ts +4 -0
- package/es/DialogWrap.js +59 -0
- package/es/IDialogPropTypes.d.ts +52 -0
- package/es/IDialogPropTypes.js +1 -0
- package/es/context.d.ts +5 -0
- package/es/context.js +2 -0
- package/es/index.d.ts +6 -0
- package/es/index.js +4 -0
- package/es/util.d.ts +5 -0
- package/es/util.js +34 -0
- package/lib/Dialog/Content/MemoChildren.d.ts +7 -0
- package/lib/Dialog/Content/MemoChildren.js +17 -0
- package/lib/Dialog/Content/Panel.d.ts +15 -0
- package/lib/Dialog/Content/Panel.js +159 -0
- package/lib/Dialog/Content/index.d.ts +13 -0
- package/lib/Dialog/Content/index.js +73 -0
- package/lib/Dialog/Mask.d.ts +11 -0
- package/lib/Dialog/Mask.js +38 -0
- package/lib/Dialog/index.d.ts +4 -0
- package/lib/Dialog/index.js +211 -0
- package/lib/DialogWrap.d.ts +4 -0
- package/lib/DialogWrap.js +69 -0
- package/lib/IDialogPropTypes.d.ts +52 -0
- package/lib/IDialogPropTypes.js +5 -0
- package/lib/context.d.ts +5 -0
- package/lib/context.js +11 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +16 -0
- package/lib/util.d.ts +5 -0
- package/lib/util.js +41 -0
- package/package.json +98 -0
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
import * as React from 'react';
|
|
5
|
+
import { useRef } from 'react';
|
|
6
|
+
import classNames from 'classnames';
|
|
7
|
+
import CSSMotion from 'rc-motion';
|
|
8
|
+
import { offset } from "../../util";
|
|
9
|
+
import Panel from "./Panel";
|
|
10
|
+
var Content = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
11
|
+
var prefixCls = props.prefixCls,
|
|
12
|
+
title = props.title,
|
|
13
|
+
style = props.style,
|
|
14
|
+
className = props.className,
|
|
15
|
+
visible = props.visible,
|
|
16
|
+
forceRender = props.forceRender,
|
|
17
|
+
destroyOnClose = props.destroyOnClose,
|
|
18
|
+
motionName = props.motionName,
|
|
19
|
+
ariaId = props.ariaId,
|
|
20
|
+
onVisibleChanged = props.onVisibleChanged,
|
|
21
|
+
mousePosition = props.mousePosition;
|
|
22
|
+
var dialogRef = useRef();
|
|
23
|
+
|
|
24
|
+
// ============================= Style ==============================
|
|
25
|
+
var _React$useState = React.useState(),
|
|
26
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
27
|
+
transformOrigin = _React$useState2[0],
|
|
28
|
+
setTransformOrigin = _React$useState2[1];
|
|
29
|
+
var contentStyle = {};
|
|
30
|
+
if (transformOrigin) {
|
|
31
|
+
contentStyle.transformOrigin = transformOrigin;
|
|
32
|
+
}
|
|
33
|
+
function onPrepare() {
|
|
34
|
+
var elementOffset = offset(dialogRef.current);
|
|
35
|
+
setTransformOrigin(mousePosition && (mousePosition.x || mousePosition.y) ? "".concat(mousePosition.x - elementOffset.left, "px ").concat(mousePosition.y - elementOffset.top, "px") : '');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// ============================= Render =============================
|
|
39
|
+
return /*#__PURE__*/React.createElement(CSSMotion, {
|
|
40
|
+
visible: visible,
|
|
41
|
+
onVisibleChanged: onVisibleChanged,
|
|
42
|
+
onAppearPrepare: onPrepare,
|
|
43
|
+
onEnterPrepare: onPrepare,
|
|
44
|
+
forceRender: forceRender,
|
|
45
|
+
motionName: motionName,
|
|
46
|
+
removeOnLeave: destroyOnClose,
|
|
47
|
+
ref: dialogRef
|
|
48
|
+
}, function (_ref, motionRef) {
|
|
49
|
+
var motionClassName = _ref.className,
|
|
50
|
+
motionStyle = _ref.style;
|
|
51
|
+
return /*#__PURE__*/React.createElement(Panel, _extends({}, props, {
|
|
52
|
+
ref: ref,
|
|
53
|
+
title: title,
|
|
54
|
+
ariaId: ariaId,
|
|
55
|
+
prefixCls: prefixCls,
|
|
56
|
+
holderRef: motionRef,
|
|
57
|
+
style: _objectSpread(_objectSpread(_objectSpread({}, motionStyle), style), contentStyle),
|
|
58
|
+
className: classNames(className, motionClassName)
|
|
59
|
+
}));
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
Content.displayName = 'Content';
|
|
63
|
+
export default Content;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export type MaskProps = {
|
|
3
|
+
prefixCls: string;
|
|
4
|
+
visible: boolean;
|
|
5
|
+
motionName?: string;
|
|
6
|
+
style?: React.CSSProperties;
|
|
7
|
+
maskProps?: React.HTMLAttributes<HTMLDivElement>;
|
|
8
|
+
className?: string;
|
|
9
|
+
};
|
|
10
|
+
declare const Mask: React.FC<MaskProps>;
|
|
11
|
+
export default Mask;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import CSSMotion from 'rc-motion';
|
|
6
|
+
var Mask = function Mask(props) {
|
|
7
|
+
var prefixCls = props.prefixCls,
|
|
8
|
+
style = props.style,
|
|
9
|
+
visible = props.visible,
|
|
10
|
+
maskProps = props.maskProps,
|
|
11
|
+
motionName = props.motionName,
|
|
12
|
+
className = props.className;
|
|
13
|
+
return /*#__PURE__*/React.createElement(CSSMotion, {
|
|
14
|
+
key: "mask",
|
|
15
|
+
visible: visible,
|
|
16
|
+
motionName: motionName,
|
|
17
|
+
leavedClassName: "".concat(prefixCls, "-mask-hidden")
|
|
18
|
+
}, function (_ref, ref) {
|
|
19
|
+
var motionClassName = _ref.className,
|
|
20
|
+
motionStyle = _ref.style;
|
|
21
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
22
|
+
ref: ref,
|
|
23
|
+
style: _objectSpread(_objectSpread({}, motionStyle), style),
|
|
24
|
+
className: classNames("".concat(prefixCls, "-mask"), motionClassName, className)
|
|
25
|
+
}, maskProps));
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
export default Mask;
|
|
@@ -0,0 +1,201 @@
|
|
|
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
|
+
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";
|
|
9
|
+
import * as React from 'react';
|
|
10
|
+
import { useEffect, useRef } from 'react';
|
|
11
|
+
import { getMotionName } from "../util";
|
|
12
|
+
import Content from "./Content";
|
|
13
|
+
import Mask from "./Mask";
|
|
14
|
+
import { warning } from "rc-util/es/warning";
|
|
15
|
+
var Dialog = function Dialog(props) {
|
|
16
|
+
var _props$prefixCls = props.prefixCls,
|
|
17
|
+
prefixCls = _props$prefixCls === void 0 ? 'rc-dialog' : _props$prefixCls,
|
|
18
|
+
zIndex = props.zIndex,
|
|
19
|
+
_props$visible = props.visible,
|
|
20
|
+
visible = _props$visible === void 0 ? false : _props$visible,
|
|
21
|
+
_props$keyboard = props.keyboard,
|
|
22
|
+
keyboard = _props$keyboard === void 0 ? true : _props$keyboard,
|
|
23
|
+
_props$focusTriggerAf = props.focusTriggerAfterClose,
|
|
24
|
+
focusTriggerAfterClose = _props$focusTriggerAf === void 0 ? true : _props$focusTriggerAf,
|
|
25
|
+
wrapStyle = props.wrapStyle,
|
|
26
|
+
wrapClassName = props.wrapClassName,
|
|
27
|
+
wrapProps = props.wrapProps,
|
|
28
|
+
onClose = props.onClose,
|
|
29
|
+
afterOpenChange = props.afterOpenChange,
|
|
30
|
+
afterClose = props.afterClose,
|
|
31
|
+
transitionName = props.transitionName,
|
|
32
|
+
animation = props.animation,
|
|
33
|
+
_props$closable = props.closable,
|
|
34
|
+
closable = _props$closable === void 0 ? true : _props$closable,
|
|
35
|
+
_props$mask = props.mask,
|
|
36
|
+
mask = _props$mask === void 0 ? true : _props$mask,
|
|
37
|
+
maskTransitionName = props.maskTransitionName,
|
|
38
|
+
maskAnimation = props.maskAnimation,
|
|
39
|
+
_props$maskClosable = props.maskClosable,
|
|
40
|
+
maskClosable = _props$maskClosable === void 0 ? true : _props$maskClosable,
|
|
41
|
+
maskStyle = props.maskStyle,
|
|
42
|
+
maskProps = props.maskProps,
|
|
43
|
+
rootClassName = props.rootClassName,
|
|
44
|
+
modalClassNames = props.classNames,
|
|
45
|
+
modalStyles = props.styles;
|
|
46
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
47
|
+
['wrapStyle', 'bodyStyle', 'maskStyle'].forEach(function (prop) {
|
|
48
|
+
// (prop in props) && console.error(`Warning: ${prop} is deprecated, please use styles instead.`)
|
|
49
|
+
warning(!(prop in props), "".concat(prop, " is deprecated, please use styles instead."));
|
|
50
|
+
});
|
|
51
|
+
if ('wrapClassName' in props) {
|
|
52
|
+
warning(false, "wrapClassName is deprecated, please use classNames instead.");
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
var lastOutSideActiveElementRef = useRef();
|
|
56
|
+
var wrapperRef = useRef();
|
|
57
|
+
var contentRef = useRef();
|
|
58
|
+
var _React$useState = React.useState(visible),
|
|
59
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
60
|
+
animatedVisible = _React$useState2[0],
|
|
61
|
+
setAnimatedVisible = _React$useState2[1];
|
|
62
|
+
|
|
63
|
+
// ========================== Init ==========================
|
|
64
|
+
var ariaId = useId();
|
|
65
|
+
function saveLastOutSideActiveElementRef() {
|
|
66
|
+
if (!contains(wrapperRef.current, document.activeElement)) {
|
|
67
|
+
lastOutSideActiveElementRef.current = document.activeElement;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function focusDialogContent() {
|
|
71
|
+
if (!contains(wrapperRef.current, document.activeElement)) {
|
|
72
|
+
var _contentRef$current;
|
|
73
|
+
(_contentRef$current = contentRef.current) === null || _contentRef$current === void 0 || _contentRef$current.focus();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// ========================= Events =========================
|
|
78
|
+
function onDialogVisibleChanged(newVisible) {
|
|
79
|
+
// Try to focus
|
|
80
|
+
if (newVisible) {
|
|
81
|
+
focusDialogContent();
|
|
82
|
+
} else {
|
|
83
|
+
// Clean up scroll bar & focus back
|
|
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
|
+
}
|
|
100
|
+
}
|
|
101
|
+
afterOpenChange === null || afterOpenChange === void 0 || afterOpenChange(newVisible);
|
|
102
|
+
}
|
|
103
|
+
function onInternalClose(e) {
|
|
104
|
+
onClose === null || onClose === void 0 || onClose(e);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// >>> Content
|
|
108
|
+
var contentClickRef = useRef(false);
|
|
109
|
+
var contentTimeoutRef = useRef();
|
|
110
|
+
|
|
111
|
+
// We need record content click incase content popup out of dialog
|
|
112
|
+
var onContentMouseDown = function onContentMouseDown() {
|
|
113
|
+
clearTimeout(contentTimeoutRef.current);
|
|
114
|
+
contentClickRef.current = true;
|
|
115
|
+
};
|
|
116
|
+
var onContentMouseUp = function onContentMouseUp() {
|
|
117
|
+
contentTimeoutRef.current = setTimeout(function () {
|
|
118
|
+
contentClickRef.current = false;
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
// >>> Wrapper
|
|
123
|
+
// Close only when element not on dialog
|
|
124
|
+
var onWrapperClick = null;
|
|
125
|
+
if (maskClosable) {
|
|
126
|
+
onWrapperClick = function onWrapperClick(e) {
|
|
127
|
+
if (contentClickRef.current) {
|
|
128
|
+
contentClickRef.current = false;
|
|
129
|
+
} else if (wrapperRef.current === e.target) {
|
|
130
|
+
onInternalClose(e);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function onWrapperKeyDown(e) {
|
|
135
|
+
if (keyboard && e.keyCode === KeyCode.ESC) {
|
|
136
|
+
e.stopPropagation();
|
|
137
|
+
onInternalClose(e);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// keep focus inside dialog
|
|
142
|
+
if (visible && e.keyCode === KeyCode.TAB) {
|
|
143
|
+
contentRef.current.changeActive(!e.shiftKey);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// ========================= Effect =========================
|
|
148
|
+
useEffect(function () {
|
|
149
|
+
if (visible) {
|
|
150
|
+
setAnimatedVisible(true);
|
|
151
|
+
saveLastOutSideActiveElementRef();
|
|
152
|
+
}
|
|
153
|
+
}, [visible]);
|
|
154
|
+
|
|
155
|
+
// Remove direct should also check the scroll bar update
|
|
156
|
+
useEffect(function () {
|
|
157
|
+
return function () {
|
|
158
|
+
clearTimeout(contentTimeoutRef.current);
|
|
159
|
+
};
|
|
160
|
+
}, []);
|
|
161
|
+
var mergedStyle = _objectSpread(_objectSpread(_objectSpread({
|
|
162
|
+
zIndex: zIndex
|
|
163
|
+
}, wrapStyle), modalStyles === null || modalStyles === void 0 ? void 0 : modalStyles.wrapper), {}, {
|
|
164
|
+
display: !animatedVisible ? 'none' : null
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
// ========================= Render =========================
|
|
168
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
169
|
+
className: classNames("".concat(prefixCls, "-root"), rootClassName)
|
|
170
|
+
}, pickAttrs(props, {
|
|
171
|
+
data: true
|
|
172
|
+
})), /*#__PURE__*/React.createElement(Mask, {
|
|
173
|
+
prefixCls: prefixCls,
|
|
174
|
+
visible: mask && visible,
|
|
175
|
+
motionName: getMotionName(prefixCls, maskTransitionName, maskAnimation),
|
|
176
|
+
style: _objectSpread(_objectSpread({
|
|
177
|
+
zIndex: zIndex
|
|
178
|
+
}, maskStyle), modalStyles === null || modalStyles === void 0 ? void 0 : modalStyles.mask),
|
|
179
|
+
maskProps: maskProps,
|
|
180
|
+
className: modalClassNames === null || modalClassNames === void 0 ? void 0 : modalClassNames.mask
|
|
181
|
+
}), /*#__PURE__*/React.createElement("div", _extends({
|
|
182
|
+
tabIndex: -1,
|
|
183
|
+
onKeyDown: onWrapperKeyDown,
|
|
184
|
+
className: classNames("".concat(prefixCls, "-wrap"), wrapClassName, modalClassNames === null || modalClassNames === void 0 ? void 0 : modalClassNames.wrapper),
|
|
185
|
+
ref: wrapperRef,
|
|
186
|
+
onClick: onWrapperClick,
|
|
187
|
+
style: mergedStyle
|
|
188
|
+
}, wrapProps), /*#__PURE__*/React.createElement(Content, _extends({}, props, {
|
|
189
|
+
onMouseDown: onContentMouseDown,
|
|
190
|
+
onMouseUp: onContentMouseUp,
|
|
191
|
+
ref: contentRef,
|
|
192
|
+
closable: closable,
|
|
193
|
+
ariaId: ariaId,
|
|
194
|
+
prefixCls: prefixCls,
|
|
195
|
+
visible: visible && animatedVisible,
|
|
196
|
+
onClose: onInternalClose,
|
|
197
|
+
onVisibleChanged: onDialogVisibleChanged,
|
|
198
|
+
motionName: getMotionName(prefixCls, transitionName, animation)
|
|
199
|
+
}))));
|
|
200
|
+
};
|
|
201
|
+
export default Dialog;
|
package/es/DialogWrap.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import Portal from '@rc-component/portal';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { RefContext } from "./context";
|
|
6
|
+
import Dialog from "./Dialog";
|
|
7
|
+
// fix issue #10656
|
|
8
|
+
/*
|
|
9
|
+
* getContainer remarks
|
|
10
|
+
* Custom container should not be return, because in the Portal component, it will remove the
|
|
11
|
+
* return container element here, if the custom container is the only child of it's component,
|
|
12
|
+
* like issue #10656, It will has a conflict with removeChild method in react-dom.
|
|
13
|
+
* So here should add a child (div element) to custom container.
|
|
14
|
+
* */
|
|
15
|
+
|
|
16
|
+
var DialogWrap = function DialogWrap(props) {
|
|
17
|
+
var visible = props.visible,
|
|
18
|
+
getContainer = props.getContainer,
|
|
19
|
+
forceRender = props.forceRender,
|
|
20
|
+
_props$destroyOnClose = props.destroyOnClose,
|
|
21
|
+
destroyOnClose = _props$destroyOnClose === void 0 ? false : _props$destroyOnClose,
|
|
22
|
+
_afterClose = props.afterClose,
|
|
23
|
+
panelRef = props.panelRef;
|
|
24
|
+
var _React$useState = React.useState(visible),
|
|
25
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
26
|
+
animatedVisible = _React$useState2[0],
|
|
27
|
+
setAnimatedVisible = _React$useState2[1];
|
|
28
|
+
var refContext = React.useMemo(function () {
|
|
29
|
+
return {
|
|
30
|
+
panel: panelRef
|
|
31
|
+
};
|
|
32
|
+
}, [panelRef]);
|
|
33
|
+
React.useEffect(function () {
|
|
34
|
+
if (visible) {
|
|
35
|
+
setAnimatedVisible(true);
|
|
36
|
+
}
|
|
37
|
+
}, [visible]);
|
|
38
|
+
|
|
39
|
+
// Destroy on close will remove wrapped div
|
|
40
|
+
if (!forceRender && destroyOnClose && !animatedVisible) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
return /*#__PURE__*/React.createElement(RefContext.Provider, {
|
|
44
|
+
value: refContext
|
|
45
|
+
}, /*#__PURE__*/React.createElement(Portal, {
|
|
46
|
+
open: visible || forceRender || animatedVisible,
|
|
47
|
+
autoDestroy: false,
|
|
48
|
+
getContainer: getContainer,
|
|
49
|
+
autoLock: visible || animatedVisible
|
|
50
|
+
}, /*#__PURE__*/React.createElement(Dialog, _extends({}, props, {
|
|
51
|
+
destroyOnClose: destroyOnClose,
|
|
52
|
+
afterClose: function afterClose() {
|
|
53
|
+
_afterClose === null || _afterClose === void 0 || _afterClose();
|
|
54
|
+
setAnimatedVisible(false);
|
|
55
|
+
}
|
|
56
|
+
}))));
|
|
57
|
+
};
|
|
58
|
+
DialogWrap.displayName = 'Dialog';
|
|
59
|
+
export default DialogWrap;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { GetContainer } from 'rc-util/lib/PortalWrapper';
|
|
2
|
+
import type { CSSProperties, ReactNode, SyntheticEvent } from 'react';
|
|
3
|
+
export type SemanticName = 'header' | 'body' | 'footer' | 'section' | 'title' | 'wrapper' | 'mask';
|
|
4
|
+
export type ModalClassNames = Partial<Record<SemanticName, string>>;
|
|
5
|
+
export type ModalStyles = Partial<Record<SemanticName, CSSProperties>>;
|
|
6
|
+
export type IDialogPropTypes = {
|
|
7
|
+
className?: string;
|
|
8
|
+
keyboard?: boolean;
|
|
9
|
+
style?: CSSProperties;
|
|
10
|
+
mask?: boolean;
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
afterClose?: () => any;
|
|
13
|
+
afterOpenChange?: (open: boolean) => void;
|
|
14
|
+
onClose?: (e: SyntheticEvent) => any;
|
|
15
|
+
closable?: boolean | ({
|
|
16
|
+
closeIcon?: React.ReactNode;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
} & React.AriaAttributes);
|
|
19
|
+
maskClosable?: boolean;
|
|
20
|
+
visible?: boolean;
|
|
21
|
+
destroyOnClose?: boolean;
|
|
22
|
+
mousePosition?: {
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
} | null;
|
|
26
|
+
title?: ReactNode;
|
|
27
|
+
footer?: ReactNode;
|
|
28
|
+
transitionName?: string;
|
|
29
|
+
maskTransitionName?: string;
|
|
30
|
+
animation?: any;
|
|
31
|
+
maskAnimation?: any;
|
|
32
|
+
wrapStyle?: Record<string, any>;
|
|
33
|
+
bodyStyle?: Record<string, any>;
|
|
34
|
+
maskStyle?: Record<string, any>;
|
|
35
|
+
prefixCls?: string;
|
|
36
|
+
wrapClassName?: string;
|
|
37
|
+
width?: string | number;
|
|
38
|
+
height?: string | number;
|
|
39
|
+
zIndex?: number;
|
|
40
|
+
bodyProps?: any;
|
|
41
|
+
maskProps?: any;
|
|
42
|
+
rootClassName?: string;
|
|
43
|
+
classNames?: ModalClassNames;
|
|
44
|
+
styles?: ModalStyles;
|
|
45
|
+
wrapProps?: any;
|
|
46
|
+
getContainer?: GetContainer | false;
|
|
47
|
+
closeIcon?: ReactNode;
|
|
48
|
+
modalRender?: (node: ReactNode) => ReactNode;
|
|
49
|
+
forceRender?: boolean;
|
|
50
|
+
focusTriggerAfterClose?: boolean;
|
|
51
|
+
panelRef?: React.Ref<HTMLDivElement>;
|
|
52
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/es/context.d.ts
ADDED
package/es/context.js
ADDED
package/es/index.d.ts
ADDED
package/es/index.js
ADDED
package/es/util.d.ts
ADDED
package/es/util.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// =============================== Motion ===============================
|
|
2
|
+
export function getMotionName(prefixCls, transitionName, animationName) {
|
|
3
|
+
var motionName = transitionName;
|
|
4
|
+
if (!motionName && animationName) {
|
|
5
|
+
motionName = "".concat(prefixCls, "-").concat(animationName);
|
|
6
|
+
}
|
|
7
|
+
return motionName;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// =============================== Offset ===============================
|
|
11
|
+
function getScroll(w, top) {
|
|
12
|
+
var ret = w["page".concat(top ? 'Y' : 'X', "Offset")];
|
|
13
|
+
var method = "scroll".concat(top ? 'Top' : 'Left');
|
|
14
|
+
if (typeof ret !== 'number') {
|
|
15
|
+
var d = w.document;
|
|
16
|
+
ret = d.documentElement[method];
|
|
17
|
+
if (typeof ret !== 'number') {
|
|
18
|
+
ret = d.body[method];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return ret;
|
|
22
|
+
}
|
|
23
|
+
export function offset(el) {
|
|
24
|
+
var rect = el.getBoundingClientRect();
|
|
25
|
+
var pos = {
|
|
26
|
+
left: rect.left,
|
|
27
|
+
top: rect.top
|
|
28
|
+
};
|
|
29
|
+
var doc = el.ownerDocument;
|
|
30
|
+
var w = doc.defaultView || doc.parentWindow;
|
|
31
|
+
pos.left += getScroll(w);
|
|
32
|
+
pos.top += getScroll(w, true);
|
|
33
|
+
return pos;
|
|
34
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export type MemoChildrenProps = {
|
|
3
|
+
shouldUpdate: boolean;
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
};
|
|
6
|
+
declare const _default: React.MemoExoticComponent<({ children }: MemoChildrenProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>>;
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
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 _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
10
|
+
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; }
|
|
11
|
+
var _default = exports.default = /*#__PURE__*/React.memo(function (_ref) {
|
|
12
|
+
var children = _ref.children;
|
|
13
|
+
return children;
|
|
14
|
+
}, function (_, _ref2) {
|
|
15
|
+
var shouldUpdate = _ref2.shouldUpdate;
|
|
16
|
+
return !shouldUpdate;
|
|
17
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { IDialogPropTypes } from '../../IDialogPropTypes';
|
|
3
|
+
export interface PanelProps extends Omit<IDialogPropTypes, 'getOpenCount'> {
|
|
4
|
+
prefixCls: string;
|
|
5
|
+
ariaId?: string;
|
|
6
|
+
onMouseDown?: React.MouseEventHandler;
|
|
7
|
+
onMouseUp?: React.MouseEventHandler;
|
|
8
|
+
holderRef?: React.Ref<HTMLDivElement>;
|
|
9
|
+
}
|
|
10
|
+
export type ContentRef = {
|
|
11
|
+
focus: () => void;
|
|
12
|
+
changeActive: (next: boolean) => void;
|
|
13
|
+
};
|
|
14
|
+
declare const Panel: React.ForwardRefExoticComponent<PanelProps & React.RefAttributes<ContentRef>>;
|
|
15
|
+
export default Panel;
|