joywok-material-components
Version:
<h1 align="center"> Joywok Material Components </h1>
127 lines (103 loc) • 5.25 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
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; }; }();
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _styles = require('@material-ui/core/styles');
var _Button = require('@material-ui/core/Button');
var _Button2 = _interopRequireDefault(_Button);
var _Dialog = require('@material-ui/core/Dialog');
var _Dialog2 = _interopRequireDefault(_Dialog);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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 styles = {
root: {},
button: {
display: 'inline-block',
maxWidth: "120px",
color: "#00C78B"
}
};
require('./style/customHTML.css');
var CustomHTML = function (_React$Component) {
_inherits(CustomHTML, _React$Component);
function CustomHTML(props) {
_classCallCheck(this, CustomHTML);
var _this = _possibleConstructorReturn(this, (CustomHTML.__proto__ || Object.getPrototypeOf(CustomHTML)).call(this, props));
_this.handleClose = function () {
console.log(_this.props, 'dsadasdas');
if (typeof _this.props.maskClosable != 'undefined') {} else {
_this.setState({
open: false
});
_this.props.onClose && _this.props.onClose();
_this.props.events.emit('close');
}
};
_this.state = {
open: props.open || false
};
return _this;
}
_createClass(CustomHTML, [{
key: 'btnClick',
value: function btnClick(e, item) {
var self = this;
var key = item['key'];
this.props[key] && this.props[key](e, item, this);
if (typeof this.props.events != 'undefined') {
this.props.events.emit('click', self, item);
}
}
}, {
key: 'render',
value: function render() {
var self = this;
var classes = this.props.classes;
return _react2.default.createElement(
_Dialog2.default,
{ onClose: this.handleClose, 'aria-labelledby': 'simple-dialog-title', open: this.state.open, className: 'custom-modal-dialog' },
_react2.default.createElement(
'div',
{ className: 'custom-modal-dialog-w' },
_react2.default.createElement(
'div',
{ className: 'custom-modal-dialog-c' },
this.props.title ? _react2.default.createElement(
'div',
{ className: 'custom-modal-dialog-title' },
this.props.title
) : '',
_react2.default.createElement('div', { className: 'custom-modal-dialog-content', dangerouslySetInnerHTML: { __html: this.props.content } }),
this.props.actions && this.props.actions.length != 0 ? _react2.default.createElement(
'div',
{ className: 'custom-modal-dialog-action' },
_.map(this.props.actions, function (i) {
return _react2.default.createElement(
_Button2.default,
_extends({}, i, { className: 'ellipsis ' + classes.button + ' ' + (typeof i['className'] != 'undefined' ? i["className"] : ''), onClick: function onClick(e) {
return self.btnClick(e, i);
} }),
i['value']
);
})
) : ''
)
)
);
}
}, {
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(nextProps) {
this.setState(nextProps);
}
}]);
return CustomHTML;
}(_react2.default.Component);
exports.default = (0, _styles.withStyles)(styles)(CustomHTML);
;