mrcio-ui
Version:
127 lines (103 loc) • 6.49 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
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; }; }();
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _style = require('./style');
var _utils = require('./utils');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Dialog = function (_Component) {
_inherits(Dialog, _Component);
function Dialog(props) {
_classCallCheck(this, Dialog);
var _this = _possibleConstructorReturn(this, (Dialog.__proto__ || Object.getPrototypeOf(Dialog)).call(this, props));
_initialiseProps.call(_this);
_this.state = {
style: _style.style,
transformStyle: _style.transformStyle
};
return _this;
}
_createClass(Dialog, [{
key: 'componentWillMount',
value: function componentWillMount() {
var props = _objectWithoutProperties(this.props, []);
var sty = eval('(' + JSON.stringify(this.state.style) + ')');
sty.mdBody.padding = props.title ? "0 1rem" : "1.5rem";
sty.mdTitle = props.titleStyle ? (0, _utils.merge)(sty.mdTitle, props.titleStyle) : sty.mdTitle;
sty.mdModal = props.contentStyle ? (0, _utils.merge)(sty.mdModal, props.contentStyle) : sty.mdModal;
sty.mdBody = props.bodyStyle ? (0, _utils.merge)(sty.mdBody, props.bodyStyle) : sty.mdBody;
sty.mdAction = props.actionStyle ? (0, _utils.merge)(sty.mdAction, props.actionStyle) : sty.mdAction;
this.setState({ style: sty });
}
}, {
key: 'render',
value: function render() {
var props = _objectWithoutProperties(this.props, []),
amiType = this.amiType(this.props);
var sty = eval('(' + JSON.stringify(this.state.style) + ')');
sty.mdModal = props.contentStyle ? (0, _utils.merge)(sty.mdModal, props.contentStyle) : sty.mdModal;
return _react2.default.createElement(
'div',
null,
_react2.default.createElement(
'div',
{ style: sty.mdModal },
_react2.default.createElement(
'div',
{ style: amiType.mdContent },
_react2.default.createElement(
'div',
null,
props.title && _react2.default.createElement(
'div',
{ style: sty.titBox },
_react2.default.createElement(
'span',
{ style: sty.titSpan },
' '
),
_react2.default.createElement(
'div',
{ style: sty.mdTitle },
props.title
)
),
_react2.default.createElement(
'div',
{ style: sty.mdBody },
props.children
),
props.actions && _react2.default.createElement(
'div',
{ style: sty.mdAction },
props.actions[0] ? props.actions[0] : null,
_react2.default.createElement('div', { style: sty.spanBtn }),
props.actions[1] ? props.actions[1] : null
)
)
)
),
_react2.default.createElement('div', { style: amiType.mdOverlay, onClick: props.handleClose })
);
}
}]);
return Dialog;
}(_react.Component);
var _initialiseProps = function _initialiseProps() {
var _this2 = this;
this.amiType = function (props) {
var sty = eval('(' + JSON.stringify(_this2.state.style) + ')');
var mdContent = props.open ? (0, _utils.extend)(sty.mdContentTrue, props.type ? _this2.state.transformStyle[props.type].S : _this2.state.transformStyle.SlideInTop.S) : (0, _utils.extend)(sty.mdContentFalse, props.type ? _this2.state.transformStyle[props.type].F : _this2.state.transformStyle.SlideInTop.F),
mdOverlay = props.open ? (0, _utils.extend)(sty.mdOverlay, sty.mdShowOverlay) : sty.mdOverlay;
return { mdContent: mdContent, mdOverlay: mdOverlay };
};
};
exports.default = Dialog;
//# sourceMappingURL=dialog.js.map