rc-dialog
Advanced tools
Comparing version 4.2.0 to 4.3.0
@@ -69,4 +69,5 @@ 'use strict'; | ||
componentDidUpdate: function componentDidUpdate(prevProps) { | ||
var _this = this; | ||
var props = this.props; | ||
var wrap = props.wrap; | ||
var dialogDomNode = React.findDOMNode(this.refs.dialog); | ||
@@ -82,3 +83,3 @@ var maskNode = React.findDOMNode(this.refs.mask); | ||
this.anim(dialogDomNode, props.transitionName, props.animation, true, function () { | ||
wrap.props.onShow(); | ||
_this.props.onShow(); | ||
}); | ||
@@ -93,3 +94,3 @@ dialogDomNode.focus(); | ||
this.anim(dialogDomNode, props.transitionName, props.animation, false, function () { | ||
wrap.props.onClose(); | ||
_this.props.onClose(); | ||
}); | ||
@@ -129,3 +130,3 @@ } | ||
if (closable) { | ||
maskProps.onClick = this.props.onClose; | ||
maskProps.onClick = this.props.onRequestClose; | ||
} | ||
@@ -143,2 +144,23 @@ if (style.zIndex) { | ||
} | ||
var header; | ||
if (props.title || closable) { | ||
header = React.createElement( | ||
'div', | ||
{ className: prefixClsFn(prefixCls, 'header') }, | ||
closable ? React.createElement( | ||
'a', | ||
{ tabIndex: '0', onClick: this.props.onRequestClose, className: [prefixClsFn(prefixCls, 'close')].join('') }, | ||
React.createElement( | ||
'span', | ||
{ className: prefixClsFn(prefixCls, 'close-x') }, | ||
'×' | ||
) | ||
) : null, | ||
React.createElement( | ||
'div', | ||
{ className: prefixClsFn(prefixCls, 'title') }, | ||
props.title | ||
) | ||
); | ||
} | ||
return React.createElement( | ||
@@ -154,22 +176,5 @@ 'div', | ||
{ className: prefixClsFn(prefixCls, 'content') }, | ||
header, | ||
React.createElement( | ||
'div', | ||
{ className: prefixClsFn(prefixCls, 'header') }, | ||
closable ? React.createElement( | ||
'a', | ||
{ tabIndex: '0', onClick: this.props.onClose, className: [prefixClsFn(prefixCls, 'close')].join('') }, | ||
React.createElement( | ||
'span', | ||
{ className: prefixClsFn(prefixCls, 'close-x') }, | ||
'×' | ||
) | ||
) : null, | ||
React.createElement( | ||
'div', | ||
{ className: prefixClsFn(prefixCls, 'title') }, | ||
props.title | ||
) | ||
), | ||
React.createElement( | ||
'div', | ||
{ className: prefixClsFn(prefixCls, 'body') }, | ||
@@ -176,0 +181,0 @@ props.children |
'use strict'; | ||
var _extends = Object.assign || 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; }; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
@@ -15,2 +13,3 @@ | ||
var Dialog = require('./Dialog'); | ||
var assign = require('object-assign'); | ||
@@ -31,2 +30,4 @@ function noop() {} | ||
function DialogWrap(props) { | ||
var _this = this; | ||
_classCallCheck(this, DialogWrap); | ||
@@ -38,3 +39,5 @@ | ||
}; | ||
this.requestClose = this.requestClose.bind(this); | ||
['cleanDialogContainer', 'requestClose', 'close', 'handleClose', 'handleShow'].forEach(function (m) { | ||
_this[m] = _this[m].bind(_this); | ||
}); | ||
} | ||
@@ -84,3 +87,5 @@ | ||
value: function requestClose() { | ||
if (this.props.onBeforeClose(this) !== false) { | ||
if (this.props.onBeforeClose) { | ||
this.props.onBeforeClose(this.close); | ||
} else { | ||
this.close(); | ||
@@ -100,13 +105,27 @@ } | ||
}, { | ||
key: 'handleClose', | ||
value: function handleClose() { | ||
this.props.onClose(); | ||
} | ||
}, { | ||
key: 'handleShow', | ||
value: function handleShow() { | ||
this.props.onShow(); | ||
} | ||
}, { | ||
key: 'getDialogElement', | ||
value: function getDialogElement() { | ||
value: function getDialogElement(extra) { | ||
var props = this.props; | ||
var dialogProps = copy(props, ['className', 'closable', 'align', 'title', 'footer', 'animation', 'transitionName', 'maskAnimation', 'maskTransitionName', 'prefixCls', 'style', 'width', 'height', 'zIndex']); | ||
assign(dialogProps, { | ||
onClose: this.handleClose, | ||
onShow: this.handleShow, | ||
visible: this.state.visible, | ||
onRequestClose: this.requestClose | ||
}, extra); | ||
return React.createElement( | ||
Dialog, | ||
_extends({ | ||
wrap: this, | ||
visible: this.state.visible | ||
}, dialogProps, { | ||
onClose: this.requestClose }), | ||
dialogProps, | ||
props.children | ||
@@ -136,8 +155,20 @@ ); | ||
}, { | ||
key: 'cleanDialogContainer', | ||
value: function cleanDialogContainer() { | ||
React.unmountComponentAtNode(this.getDialogContainer()); | ||
document.body.removeChild(this.dialogContainer); | ||
this.dialogContainer = null; | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
if (this.dialogContainer) { | ||
React.unmountComponentAtNode(this.getDialogContainer()); | ||
document.body.removeChild(this.dialogContainer); | ||
this.dialogContainer = null; | ||
if (this.state.visible) { | ||
React.render(this.getDialogElement({ | ||
onClose: this.cleanDialogContainer, | ||
visible: false | ||
}), this.dialogContainer); | ||
} else { | ||
this.cleanDialogContainer(); | ||
} | ||
} | ||
@@ -160,3 +191,2 @@ } | ||
visible: false, | ||
onBeforeClose: noop, | ||
onShow: noop, | ||
@@ -163,0 +193,0 @@ onClose: noop |
{ | ||
"name": "rc-dialog", | ||
"version": "4.2.0", | ||
"version": "4.3.0", | ||
"description": "dialog ui component for react", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24674
655