Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rc-dialog

Package Overview
Dependencies
Maintainers
10
Versions
164
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rc-dialog - npm Package Compare versions

Comparing version 9.0.0 to 9.0.1

40

es/Dialog/Content/index.js

@@ -12,31 +12,27 @@ import _extends from "@babel/runtime/helpers/esm/extends";

var prefixCls = props.prefixCls,
title = props.title,
style = props.style,
className = props.className,
visible = props.visible,
forceRender = props.forceRender,
destroyOnClose = props.destroyOnClose,
motionName = props.motionName,
ariaId = props.ariaId,
onVisibleChanged = props.onVisibleChanged,
mousePosition = props.mousePosition;
var dialogRef = useRef(); // ============================= Style ==============================
title = props.title,
style = props.style,
className = props.className,
visible = props.visible,
forceRender = props.forceRender,
destroyOnClose = props.destroyOnClose,
motionName = props.motionName,
ariaId = props.ariaId,
onVisibleChanged = props.onVisibleChanged,
mousePosition = props.mousePosition;
var dialogRef = useRef();
// ============================= Style ==============================
var _React$useState = React.useState(),
_React$useState2 = _slicedToArray(_React$useState, 2),
transformOrigin = _React$useState2[0],
setTransformOrigin = _React$useState2[1];
_React$useState2 = _slicedToArray(_React$useState, 2),
transformOrigin = _React$useState2[0],
setTransformOrigin = _React$useState2[1];
var contentStyle = {};
if (transformOrigin) {
contentStyle.transformOrigin = transformOrigin;
}
function onPrepare() {
var elementOffset = offset(dialogRef.current);
setTransformOrigin(mousePosition ? "".concat(mousePosition.x - elementOffset.left, "px ").concat(mousePosition.y - elementOffset.top, "px") : '');
} // ============================= Render =============================
}
// ============================= Render =============================
return /*#__PURE__*/React.createElement(CSSMotion, {

@@ -53,3 +49,3 @@ visible: visible,

var motionClassName = _ref.className,
motionStyle = _ref.style;
motionStyle = _ref.style;
return /*#__PURE__*/React.createElement(Panel, _extends({}, props, {

@@ -56,0 +52,0 @@ ref: ref,

@@ -14,22 +14,22 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";

var prefixCls = props.prefixCls,
className = props.className,
style = props.style,
title = props.title,
ariaId = props.ariaId,
footer = props.footer,
closable = props.closable,
closeIcon = props.closeIcon,
onClose = props.onClose,
children = props.children,
bodyStyle = props.bodyStyle,
bodyProps = props.bodyProps,
modalRender = props.modalRender,
onMouseDown = props.onMouseDown,
onMouseUp = props.onMouseUp,
holderRef = props.holderRef,
visible = props.visible,
forceRender = props.forceRender,
width = props.width,
height = props.height; // ================================= Refs =================================
className = props.className,
style = props.style,
title = props.title,
ariaId = props.ariaId,
footer = props.footer,
closable = props.closable,
closeIcon = props.closeIcon,
onClose = props.onClose,
children = props.children,
bodyStyle = props.bodyStyle,
bodyProps = props.bodyProps,
modalRender = props.modalRender,
onMouseDown = props.onMouseDown,
onMouseUp = props.onMouseUp,
holderRef = props.holderRef,
visible = props.visible,
forceRender = props.forceRender,
width = props.width,
height = props.height;
// ================================= Refs =================================
var sentinelStartRef = useRef();

@@ -41,3 +41,2 @@ var sentinelEndRef = useRef();

var _sentinelStartRef$cur;
(_sentinelStartRef$cur = sentinelStartRef.current) === null || _sentinelStartRef$cur === void 0 ? void 0 : _sentinelStartRef$cur.focus();

@@ -47,4 +46,3 @@ },

var _document = document,
activeElement = _document.activeElement;
activeElement = _document.activeElement;
if (next && activeElement === sentinelEndRef.current) {

@@ -57,17 +55,13 @@ sentinelStartRef.current.focus();

};
}); // ================================ Style =================================
});
// ================================ Style =================================
var contentStyle = {};
if (width !== undefined) {
contentStyle.width = width;
}
if (height !== undefined) {
contentStyle.height = height;
} // ================================ Render ================================
}
// ================================ Render ================================
var footerNode;
if (footer) {

@@ -78,5 +72,3 @@ footerNode = /*#__PURE__*/React.createElement("div", {

}
var headerNode;
if (title) {

@@ -90,5 +82,3 @@ headerNode = /*#__PURE__*/React.createElement("div", {

}
var closer;
if (closable) {

@@ -104,3 +94,2 @@ closer = /*#__PURE__*/React.createElement("button", {

}
var content = /*#__PURE__*/React.createElement("div", {

@@ -136,7 +125,5 @@ className: "".concat(prefixCls, "-content")

});
if (process.env.NODE_ENV !== 'production') {
Panel.displayName = 'Panel';
}
export default Panel;

@@ -1,3 +0,2 @@

/// <reference types="react" />
import type { IDialogPropTypes } from '../IDialogPropTypes';
export default function Dialog(props: IDialogPropTypes): JSX.Element;

@@ -16,40 +16,38 @@ import _extends from "@babel/runtime/helpers/esm/extends";

var _props$prefixCls = props.prefixCls,
prefixCls = _props$prefixCls === void 0 ? 'rc-dialog' : _props$prefixCls,
zIndex = props.zIndex,
_props$visible = props.visible,
visible = _props$visible === void 0 ? false : _props$visible,
_props$keyboard = props.keyboard,
keyboard = _props$keyboard === void 0 ? true : _props$keyboard,
_props$focusTriggerAf = props.focusTriggerAfterClose,
focusTriggerAfterClose = _props$focusTriggerAf === void 0 ? true : _props$focusTriggerAf,
wrapStyle = props.wrapStyle,
wrapClassName = props.wrapClassName,
wrapProps = props.wrapProps,
onClose = props.onClose,
afterClose = props.afterClose,
transitionName = props.transitionName,
animation = props.animation,
_props$closable = props.closable,
closable = _props$closable === void 0 ? true : _props$closable,
_props$mask = props.mask,
mask = _props$mask === void 0 ? true : _props$mask,
maskTransitionName = props.maskTransitionName,
maskAnimation = props.maskAnimation,
_props$maskClosable = props.maskClosable,
maskClosable = _props$maskClosable === void 0 ? true : _props$maskClosable,
maskStyle = props.maskStyle,
maskProps = props.maskProps,
rootClassName = props.rootClassName;
prefixCls = _props$prefixCls === void 0 ? 'rc-dialog' : _props$prefixCls,
zIndex = props.zIndex,
_props$visible = props.visible,
visible = _props$visible === void 0 ? false : _props$visible,
_props$keyboard = props.keyboard,
keyboard = _props$keyboard === void 0 ? true : _props$keyboard,
_props$focusTriggerAf = props.focusTriggerAfterClose,
focusTriggerAfterClose = _props$focusTriggerAf === void 0 ? true : _props$focusTriggerAf,
wrapStyle = props.wrapStyle,
wrapClassName = props.wrapClassName,
wrapProps = props.wrapProps,
onClose = props.onClose,
afterClose = props.afterClose,
transitionName = props.transitionName,
animation = props.animation,
_props$closable = props.closable,
closable = _props$closable === void 0 ? true : _props$closable,
_props$mask = props.mask,
mask = _props$mask === void 0 ? true : _props$mask,
maskTransitionName = props.maskTransitionName,
maskAnimation = props.maskAnimation,
_props$maskClosable = props.maskClosable,
maskClosable = _props$maskClosable === void 0 ? true : _props$maskClosable,
maskStyle = props.maskStyle,
maskProps = props.maskProps,
rootClassName = props.rootClassName;
var lastOutSideActiveElementRef = useRef();
var wrapperRef = useRef();
var contentRef = useRef();
var _React$useState = React.useState(visible),
_React$useState2 = _slicedToArray(_React$useState, 2),
animatedVisible = _React$useState2[0],
setAnimatedVisible = _React$useState2[1]; // ========================== Init ==========================
var ariaId = useId(); // ========================= Events =========================
_React$useState2 = _slicedToArray(_React$useState, 2),
animatedVisible = _React$useState2[0],
setAnimatedVisible = _React$useState2[1];
// ========================== Init ==========================
var ariaId = useId();
// ========================= Events =========================
function onDialogVisibleChanged(newVisible) {

@@ -60,3 +58,2 @@ if (newVisible) {

var _contentRef$current;
lastOutSideActiveElementRef.current = document.activeElement;

@@ -68,3 +65,2 @@ (_contentRef$current = contentRef.current) === null || _contentRef$current === void 0 ? void 0 : _contentRef$current.focus();

setAnimatedVisible(false);
if (mask && lastOutSideActiveElementRef.current && focusTriggerAfterClose) {

@@ -75,9 +71,8 @@ try {

});
} catch (e) {// Do nothing
} catch (e) {
// Do nothing
}
lastOutSideActiveElementRef.current = null;
} // Trigger afterClose only when change visible from true to false
}
// Trigger afterClose only when change visible from true to false
if (animatedVisible) {

@@ -88,11 +83,9 @@ afterClose === null || afterClose === void 0 ? void 0 : afterClose();

}
function onInternalClose(e) {
onClose === null || onClose === void 0 ? void 0 : onClose(e);
} // >>> Content
}
// >>> Content
var contentClickRef = useRef(false);
var contentTimeoutRef = useRef(); // We need record content click incase content popup out of dialog
var contentTimeoutRef = useRef();
// We need record content click incase content popup out of dialog
var onContentMouseDown = function onContentMouseDown() {

@@ -102,3 +95,2 @@ clearTimeout(contentTimeoutRef.current);

};
var onContentMouseUp = function onContentMouseUp() {

@@ -108,8 +100,6 @@ contentTimeoutRef.current = setTimeout(function () {

});
}; // >>> Wrapper
};
// >>> Wrapper
// Close only when element not on dialog
var onWrapperClick = null;
if (maskClosable) {

@@ -124,3 +114,2 @@ onWrapperClick = function onWrapperClick(e) {

}
function onWrapperKeyDown(e) {

@@ -131,5 +120,4 @@ if (keyboard && e.keyCode === KeyCode.ESC) {

return;
} // keep focus inside dialog
}
// keep focus inside dialog
if (visible) {

@@ -140,5 +128,4 @@ if (e.keyCode === KeyCode.TAB) {

}
} // ========================= Effect =========================
}
// ========================= Effect =========================
useEffect(function () {

@@ -148,6 +135,4 @@ if (visible) {

}
return function () {};
}, [visible]); // Remove direct should also check the scroll bar update
}, [visible]);
// Remove direct should also check the scroll bar update
useEffect(function () {

@@ -157,11 +142,4 @@ return function () {

};
}, []); // useEffect(() => {
// if (animatedVisible) {
// scrollLocker?.lock();
// return scrollLocker?.unLock;
// }
// return () => {};
// }, [animatedVisible, scrollLocker]);
}, []);
// ========================= Render =========================
return /*#__PURE__*/React.createElement("div", _extends({

@@ -197,3 +175,3 @@ className: classNames("".concat(prefixCls, "-root"), rootClassName)

prefixCls: prefixCls,
visible: visible,
visible: visible && animatedVisible,
onClose: onInternalClose,

@@ -200,0 +178,0 @@ onVisibleChanged: onDialogVisibleChanged,

@@ -8,6 +8,6 @@ import _extends from "@babel/runtime/helpers/esm/extends";

var prefixCls = props.prefixCls,
style = props.style,
visible = props.visible,
maskProps = props.maskProps,
motionName = props.motionName;
style = props.style,
visible = props.visible,
maskProps = props.maskProps,
motionName = props.motionName;
return /*#__PURE__*/React.createElement(CSSMotion, {

@@ -18,6 +18,7 @@ key: "mask",

leavedClassName: "".concat(prefixCls, "-mask-hidden")
}, function (_ref) {
}, function (_ref, ref) {
var motionClassName = _ref.className,
motionStyle = _ref.style;
motionStyle = _ref.style;
return /*#__PURE__*/React.createElement("div", _extends({
ref: ref,
style: _objectSpread(_objectSpread({}, motionStyle), style),

@@ -24,0 +25,0 @@ className: classNames("".concat(prefixCls, "-mask"), motionClassName)

@@ -5,4 +5,4 @@ import _extends from "@babel/runtime/helpers/esm/extends";

import Portal from '@rc-component/portal';
import Dialog from './Dialog'; // fix issue #10656
import Dialog from './Dialog';
// fix issue #10656
/*

@@ -15,16 +15,13 @@ * getContainer remarks

* */
var DialogWrap = function DialogWrap(props) {
var visible = props.visible,
getContainer = props.getContainer,
forceRender = props.forceRender,
_props$destroyOnClose = props.destroyOnClose,
destroyOnClose = _props$destroyOnClose === void 0 ? false : _props$destroyOnClose,
_afterClose = props.afterClose;
getContainer = props.getContainer,
forceRender = props.forceRender,
_props$destroyOnClose = props.destroyOnClose,
destroyOnClose = _props$destroyOnClose === void 0 ? false : _props$destroyOnClose,
_afterClose = props.afterClose;
var _React$useState = React.useState(visible),
_React$useState2 = _slicedToArray(_React$useState, 2),
animatedVisible = _React$useState2[0],
setAnimatedVisible = _React$useState2[1];
_React$useState2 = _slicedToArray(_React$useState, 2),
animatedVisible = _React$useState2[0],
setAnimatedVisible = _React$useState2[1];
React.useEffect(function () {

@@ -34,3 +31,4 @@ if (visible) {

}
}, [visible]); // // 渲染在当前 dom 里;
}, [visible]);
// // 渲染在当前 dom 里;
// if (getContainer === false) {

@@ -45,7 +43,5 @@ // return (

// Destroy on close will remove wrapped div
if (!forceRender && destroyOnClose && !animatedVisible) {
return null;
}
return /*#__PURE__*/React.createElement(Portal, {

@@ -64,4 +60,3 @@ open: visible || forceRender || animatedVisible,

};
DialogWrap.displayName = 'Dialog';
export default DialogWrap;
// =============================== Motion ===============================
export function getMotionName(prefixCls, transitionName, animationName) {
var motionName = transitionName;
if (!motionName && animationName) {
motionName = "".concat(prefixCls, "-").concat(animationName);
}
return motionName;
} // =============================== Offset ===============================
}
// =============================== Offset ===============================
function getScroll(w, top) {
var ret = w["page".concat(top ? 'Y' : 'X', "Offset")];
var method = "scroll".concat(top ? 'Top' : 'Left');
if (typeof ret !== 'number') {
var d = w.document;
ret = d.documentElement[method];
if (typeof ret !== 'number') {

@@ -24,6 +20,4 @@ ret = d.body[method];

}
return ret;
}
export function offset(el) {

@@ -30,0 +24,0 @@ var rect = el.getBoundingClientRect();

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -11,54 +9,39 @@ value: true

exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var React = _interopRequireWildcard(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _rcMotion = _interopRequireDefault(require("rc-motion"));
var _util = require("../../util");
var _Panel = _interopRequireDefault(require("./Panel"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var Content = /*#__PURE__*/React.forwardRef(function (props, ref) {
var prefixCls = props.prefixCls,
title = props.title,
style = props.style,
className = props.className,
visible = props.visible,
forceRender = props.forceRender,
destroyOnClose = props.destroyOnClose,
motionName = props.motionName,
ariaId = props.ariaId,
onVisibleChanged = props.onVisibleChanged,
mousePosition = props.mousePosition;
var dialogRef = (0, React.useRef)(); // ============================= Style ==============================
title = props.title,
style = props.style,
className = props.className,
visible = props.visible,
forceRender = props.forceRender,
destroyOnClose = props.destroyOnClose,
motionName = props.motionName,
ariaId = props.ariaId,
onVisibleChanged = props.onVisibleChanged,
mousePosition = props.mousePosition;
var dialogRef = (0, React.useRef)();
// ============================= Style ==============================
var _React$useState = React.useState(),
_React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
transformOrigin = _React$useState2[0],
setTransformOrigin = _React$useState2[1];
_React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
transformOrigin = _React$useState2[0],
setTransformOrigin = _React$useState2[1];
var contentStyle = {};
if (transformOrigin) {
contentStyle.transformOrigin = transformOrigin;
}
function onPrepare() {
var elementOffset = (0, _util.offset)(dialogRef.current);
setTransformOrigin(mousePosition ? "".concat(mousePosition.x - elementOffset.left, "px ").concat(mousePosition.y - elementOffset.top, "px") : '');
} // ============================= Render =============================
}
// ============================= Render =============================
return /*#__PURE__*/React.createElement(_rcMotion.default, {

@@ -75,3 +58,3 @@ visible: visible,

var motionClassName = _ref.className,
motionStyle = _ref.style;
motionStyle = _ref.style;
return /*#__PURE__*/React.createElement(_Panel.default, (0, _extends2.default)({}, props, {

@@ -78,0 +61,0 @@ ref: ref,

"use strict";
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -9,9 +8,5 @@ value: true

exports.default = void 0;
var React = _interopRequireWildcard(require("react"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var _default = /*#__PURE__*/React.memo(function (_ref) {

@@ -24,3 +19,2 @@ var children = _ref.children;

});
exports.default = _default;
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -11,17 +9,9 @@ value: true

exports.default = void 0;
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _react = _interopRequireWildcard(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _MemoChildren = _interopRequireDefault(require("./MemoChildren"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var sentinelStyle = {

@@ -33,28 +23,26 @@ width: 0,

};
var Panel = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
var prefixCls = props.prefixCls,
className = props.className,
style = props.style,
title = props.title,
ariaId = props.ariaId,
footer = props.footer,
closable = props.closable,
closeIcon = props.closeIcon,
onClose = props.onClose,
children = props.children,
bodyStyle = props.bodyStyle,
bodyProps = props.bodyProps,
modalRender = props.modalRender,
onMouseDown = props.onMouseDown,
onMouseUp = props.onMouseUp,
holderRef = props.holderRef,
visible = props.visible,
forceRender = props.forceRender,
width = props.width,
height = props.height; // ================================= Refs =================================
className = props.className,
style = props.style,
title = props.title,
ariaId = props.ariaId,
footer = props.footer,
closable = props.closable,
closeIcon = props.closeIcon,
onClose = props.onClose,
children = props.children,
bodyStyle = props.bodyStyle,
bodyProps = props.bodyProps,
modalRender = props.modalRender,
onMouseDown = props.onMouseDown,
onMouseUp = props.onMouseUp,
holderRef = props.holderRef,
visible = props.visible,
forceRender = props.forceRender,
width = props.width,
height = props.height;
// ================================= Refs =================================
var sentinelStartRef = (0, _react.useRef)();
var sentinelEndRef = (0, _react.useRef)();
_react.default.useImperativeHandle(ref, function () {

@@ -64,3 +52,2 @@ return {

var _sentinelStartRef$cur;
(_sentinelStartRef$cur = sentinelStartRef.current) === null || _sentinelStartRef$cur === void 0 ? void 0 : _sentinelStartRef$cur.focus();

@@ -70,4 +57,3 @@ },

var _document = document,
activeElement = _document.activeElement;
activeElement = _document.activeElement;
if (next && activeElement === sentinelEndRef.current) {

@@ -80,18 +66,13 @@ sentinelStartRef.current.focus();

};
}); // ================================ Style =================================
});
// ================================ Style =================================
var contentStyle = {};
if (width !== undefined) {
contentStyle.width = width;
}
if (height !== undefined) {
contentStyle.height = height;
} // ================================ Render ================================
}
// ================================ Render ================================
var footerNode;
if (footer) {

@@ -102,5 +83,3 @@ footerNode = /*#__PURE__*/_react.default.createElement("div", {

}
var headerNode;
if (title) {

@@ -114,5 +93,3 @@ headerNode = /*#__PURE__*/_react.default.createElement("div", {

}
var closer;
if (closable) {

@@ -128,3 +105,2 @@ closer = /*#__PURE__*/_react.default.createElement("button", {

}
var content = /*#__PURE__*/_react.default.createElement("div", {

@@ -136,3 +112,2 @@ className: "".concat(prefixCls, "-content")

}, bodyProps), children), footerNode);
return /*#__PURE__*/_react.default.createElement("div", {

@@ -162,8 +137,6 @@ key: "dialog-element",

});
if (process.env.NODE_ENV !== 'production') {
Panel.displayName = 'Panel';
}
var _default = Panel;
exports.default = _default;

@@ -1,3 +0,2 @@

/// <reference types="react" />
import type { IDialogPropTypes } from '../IDialogPropTypes';
export default function Dialog(props: IDialogPropTypes): JSX.Element;
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -11,71 +9,54 @@ value: true

exports.default = Dialog;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var React = _interopRequireWildcard(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _KeyCode = _interopRequireDefault(require("rc-util/lib/KeyCode"));
var _useId = _interopRequireDefault(require("rc-util/lib/hooks/useId"));
var _contains = _interopRequireDefault(require("rc-util/lib/Dom/contains"));
var _pickAttrs = _interopRequireDefault(require("rc-util/lib/pickAttrs"));
var _Mask = _interopRequireDefault(require("./Mask"));
var _util = require("../util");
var _Content = _interopRequireDefault(require("./Content"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function Dialog(props) {
var _props$prefixCls = props.prefixCls,
prefixCls = _props$prefixCls === void 0 ? 'rc-dialog' : _props$prefixCls,
zIndex = props.zIndex,
_props$visible = props.visible,
visible = _props$visible === void 0 ? false : _props$visible,
_props$keyboard = props.keyboard,
keyboard = _props$keyboard === void 0 ? true : _props$keyboard,
_props$focusTriggerAf = props.focusTriggerAfterClose,
focusTriggerAfterClose = _props$focusTriggerAf === void 0 ? true : _props$focusTriggerAf,
wrapStyle = props.wrapStyle,
wrapClassName = props.wrapClassName,
wrapProps = props.wrapProps,
onClose = props.onClose,
afterClose = props.afterClose,
transitionName = props.transitionName,
animation = props.animation,
_props$closable = props.closable,
closable = _props$closable === void 0 ? true : _props$closable,
_props$mask = props.mask,
mask = _props$mask === void 0 ? true : _props$mask,
maskTransitionName = props.maskTransitionName,
maskAnimation = props.maskAnimation,
_props$maskClosable = props.maskClosable,
maskClosable = _props$maskClosable === void 0 ? true : _props$maskClosable,
maskStyle = props.maskStyle,
maskProps = props.maskProps,
rootClassName = props.rootClassName;
prefixCls = _props$prefixCls === void 0 ? 'rc-dialog' : _props$prefixCls,
zIndex = props.zIndex,
_props$visible = props.visible,
visible = _props$visible === void 0 ? false : _props$visible,
_props$keyboard = props.keyboard,
keyboard = _props$keyboard === void 0 ? true : _props$keyboard,
_props$focusTriggerAf = props.focusTriggerAfterClose,
focusTriggerAfterClose = _props$focusTriggerAf === void 0 ? true : _props$focusTriggerAf,
wrapStyle = props.wrapStyle,
wrapClassName = props.wrapClassName,
wrapProps = props.wrapProps,
onClose = props.onClose,
afterClose = props.afterClose,
transitionName = props.transitionName,
animation = props.animation,
_props$closable = props.closable,
closable = _props$closable === void 0 ? true : _props$closable,
_props$mask = props.mask,
mask = _props$mask === void 0 ? true : _props$mask,
maskTransitionName = props.maskTransitionName,
maskAnimation = props.maskAnimation,
_props$maskClosable = props.maskClosable,
maskClosable = _props$maskClosable === void 0 ? true : _props$maskClosable,
maskStyle = props.maskStyle,
maskProps = props.maskProps,
rootClassName = props.rootClassName;
var lastOutSideActiveElementRef = (0, React.useRef)();
var wrapperRef = (0, React.useRef)();
var contentRef = (0, React.useRef)();
var _React$useState = React.useState(visible),
_React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
animatedVisible = _React$useState2[0],
setAnimatedVisible = _React$useState2[1]; // ========================== Init ==========================
var ariaId = (0, _useId.default)(); // ========================= Events =========================
_React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
animatedVisible = _React$useState2[0],
setAnimatedVisible = _React$useState2[1];
// ========================== Init ==========================
var ariaId = (0, _useId.default)();
// ========================= Events =========================
function onDialogVisibleChanged(newVisible) {

@@ -86,3 +67,2 @@ if (newVisible) {

var _contentRef$current;
lastOutSideActiveElementRef.current = document.activeElement;

@@ -94,3 +74,2 @@ (_contentRef$current = contentRef.current) === null || _contentRef$current === void 0 ? void 0 : _contentRef$current.focus();

setAnimatedVisible(false);
if (mask && lastOutSideActiveElementRef.current && focusTriggerAfterClose) {

@@ -101,9 +80,8 @@ try {

});
} catch (e) {// Do nothing
} catch (e) {
// Do nothing
}
lastOutSideActiveElementRef.current = null;
} // Trigger afterClose only when change visible from true to false
}
// Trigger afterClose only when change visible from true to false
if (animatedVisible) {

@@ -114,11 +92,9 @@ afterClose === null || afterClose === void 0 ? void 0 : afterClose();

}
function onInternalClose(e) {
onClose === null || onClose === void 0 ? void 0 : onClose(e);
} // >>> Content
}
// >>> Content
var contentClickRef = (0, React.useRef)(false);
var contentTimeoutRef = (0, React.useRef)(); // We need record content click incase content popup out of dialog
var contentTimeoutRef = (0, React.useRef)();
// We need record content click incase content popup out of dialog
var onContentMouseDown = function onContentMouseDown() {

@@ -128,3 +104,2 @@ clearTimeout(contentTimeoutRef.current);

};
var onContentMouseUp = function onContentMouseUp() {

@@ -134,8 +109,6 @@ contentTimeoutRef.current = setTimeout(function () {

});
}; // >>> Wrapper
};
// >>> Wrapper
// Close only when element not on dialog
var onWrapperClick = null;
if (maskClosable) {

@@ -150,3 +123,2 @@ onWrapperClick = function onWrapperClick(e) {

}
function onWrapperKeyDown(e) {

@@ -157,5 +129,4 @@ if (keyboard && e.keyCode === _KeyCode.default.ESC) {

return;
} // keep focus inside dialog
}
// keep focus inside dialog
if (visible) {

@@ -166,5 +137,4 @@ if (e.keyCode === _KeyCode.default.TAB) {

}
} // ========================= Effect =========================
}
// ========================= Effect =========================
(0, React.useEffect)(function () {

@@ -174,6 +144,4 @@ if (visible) {

}
return function () {};
}, [visible]); // Remove direct should also check the scroll bar update
}, [visible]);
// Remove direct should also check the scroll bar update
(0, React.useEffect)(function () {

@@ -183,11 +151,4 @@ return function () {

};
}, []); // useEffect(() => {
// if (animatedVisible) {
// scrollLocker?.lock();
// return scrollLocker?.unLock;
// }
// return () => {};
// }, [animatedVisible, scrollLocker]);
}, []);
// ========================= Render =========================
return /*#__PURE__*/React.createElement("div", (0, _extends2.default)({

@@ -223,3 +184,3 @@ className: (0, _classnames.default)("".concat(prefixCls, "-root"), rootClassName)

prefixCls: prefixCls,
visible: visible,
visible: visible && animatedVisible,
onClose: onInternalClose,

@@ -226,0 +187,0 @@ onVisibleChanged: onDialogVisibleChanged,

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -11,23 +9,15 @@ value: true

exports.default = Mask;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
var React = _interopRequireWildcard(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _rcMotion = _interopRequireDefault(require("rc-motion"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function Mask(props) {
var prefixCls = props.prefixCls,
style = props.style,
visible = props.visible,
maskProps = props.maskProps,
motionName = props.motionName;
style = props.style,
visible = props.visible,
maskProps = props.maskProps,
motionName = props.motionName;
return /*#__PURE__*/React.createElement(_rcMotion.default, {

@@ -38,6 +28,7 @@ key: "mask",

leavedClassName: "".concat(prefixCls, "-mask-hidden")
}, function (_ref) {
}, function (_ref, ref) {
var motionClassName = _ref.className,
motionStyle = _ref.style;
motionStyle = _ref.style;
return /*#__PURE__*/React.createElement("div", (0, _extends2.default)({
ref: ref,
style: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, motionStyle), style),

@@ -44,0 +35,0 @@ className: (0, _classnames.default)("".concat(prefixCls, "-mask"), motionClassName)

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {

@@ -11,19 +9,10 @@ value: true

exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var React = _interopRequireWildcard(require("react"));
var _portal = _interopRequireDefault(require("@rc-component/portal"));
var _Dialog = _interopRequireDefault(require("./Dialog"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
// fix issue #10656
/*

@@ -38,13 +27,11 @@ * getContainer remarks

var visible = props.visible,
getContainer = props.getContainer,
forceRender = props.forceRender,
_props$destroyOnClose = props.destroyOnClose,
destroyOnClose = _props$destroyOnClose === void 0 ? false : _props$destroyOnClose,
_afterClose = props.afterClose;
getContainer = props.getContainer,
forceRender = props.forceRender,
_props$destroyOnClose = props.destroyOnClose,
destroyOnClose = _props$destroyOnClose === void 0 ? false : _props$destroyOnClose,
_afterClose = props.afterClose;
var _React$useState = React.useState(visible),
_React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
animatedVisible = _React$useState2[0],
setAnimatedVisible = _React$useState2[1];
_React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
animatedVisible = _React$useState2[0],
setAnimatedVisible = _React$useState2[1];
React.useEffect(function () {

@@ -54,3 +41,4 @@ if (visible) {

}
}, [visible]); // // 渲染在当前 dom 里;
}, [visible]);
// // 渲染在当前 dom 里;
// if (getContainer === false) {

@@ -65,7 +53,5 @@ // return (

// Destroy on close will remove wrapped div
if (!forceRender && destroyOnClose && !animatedVisible) {
return null;
}
return /*#__PURE__*/React.createElement(_portal.default, {

@@ -84,5 +70,4 @@ open: visible || forceRender || animatedVisible,

};
DialogWrap.displayName = 'Dialog';
var _default = DialogWrap;
exports.default = _default;
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {

@@ -15,8 +14,5 @@ value: true

exports.default = void 0;
var _DialogWrap = _interopRequireDefault(require("./DialogWrap"));
var _Panel = _interopRequireDefault(require("./Dialog/Content/Panel"));
var _default = _DialogWrap.default;
exports.default = _default;

@@ -8,23 +8,17 @@ "use strict";

exports.offset = offset;
// =============================== Motion ===============================
function getMotionName(prefixCls, transitionName, animationName) {
var motionName = transitionName;
if (!motionName && animationName) {
motionName = "".concat(prefixCls, "-").concat(animationName);
}
return motionName;
} // =============================== Offset ===============================
}
// =============================== Offset ===============================
function getScroll(w, top) {
var ret = w["page".concat(top ? 'Y' : 'X', "Offset")];
var method = "scroll".concat(top ? 'Top' : 'Left');
if (typeof ret !== 'number') {
var d = w.document;
ret = d.documentElement[method];
if (typeof ret !== 'number') {

@@ -34,6 +28,4 @@ ret = d.body[method];

}
return ret;
}
function offset(el) {

@@ -40,0 +32,0 @@ var rect = el.getBoundingClientRect();

{
"name": "rc-dialog",
"version": "9.0.0",
"version": "9.0.1",
"description": "dialog ui component for react",

@@ -60,4 +60,5 @@ "keywords": [

"@types/jest": "^26.0.14",
"@types/react": "^16.9.2",
"@types/react-dom": "^16.9.0",
"@types/keyv": "3.1.4",
"@types/react": "^18.0.24",
"@types/react-dom": "^17.0.9",
"@umijs/fabric": "^2.0.0",

@@ -72,7 +73,7 @@ "bluebird": "~3.7.2",

"eslint": "^7.1.0",
"eslint-config-airbnb": "^18.2.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-plugin-react": "^7.20.6",
"father": "^2.29.6",
"father-build": "^1.18.6",
"gh-pages": "^3.1.0",
"gh-pages": "^4.0.0",
"glob": "^7.1.6",

@@ -83,4 +84,4 @@ "jquery": "^3.3.1",

"prettier": "^2.1.1",
"rc-drawer": "4.1.0",
"rc-select": "^11.4.1",
"rc-drawer": "^4.4.0",
"rc-select": "^12.1.13",
"react": "^16.9.0",

@@ -87,0 +88,0 @@ "react-dom": "^16.9.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc