UNPKG

drip-table

Version:

A tiny and powerful enterprise-class solution for building tables.

203 lines (168 loc) 7.75 kB
"use strict"; function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; require("./index.less"); var _react = _interopRequireDefault(require("react")); var _button = _interopRequireDefault(require("../../react-components/button")); var _modal = _interopRequireDefault(require("../../react-components/modal")); 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 _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); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var prefixCls = 'jfe-drip-table-cc-pop-up-page'; var DTCPopUpPage = /*#__PURE__*/function (_React$PureComponent) { _inherits(DTCPopUpPage, _React$PureComponent); var _super = _createSuper(DTCPopUpPage); function DTCPopUpPage() { var _this; _classCallCheck(this, DTCPopUpPage); for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } _this = _super.call.apply(_super, [this].concat(args)); _defineProperty(_assertThisInitialized(_this), "state", { visible: false }); _defineProperty(_assertThisInitialized(_this), "handlePopUpVisible", function () { if (_this.props.preview) { return; } _this.setState({ visible: true }); }); _defineProperty(_assertThisInitialized(_this), "onClose", function () { _this.setState({ visible: false }); }); return _this; } _createClass(DTCPopUpPage, [{ key: "label", get: function get() { var options = this.props.schema.options; return this.props.finalizeString('pattern', options.label || '', this.props.record, this.props.recordIndex, this.props.ext); } }, { key: "padding", get: function get() { return this.props.schema.options.embeddedSafetyPadding || 0; } }, { key: "auxiliaryDesc", get: function get() { return this.props.schema.options.auxiliaryDesc || ''; } }, { key: "render", value: function render() { var visible = this.state.visible; var options = this.props.schema.options; return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_button.default, { type: options.buttonType, size: options.size, shape: options.shape, onClick: this.handlePopUpVisible }, this.label), /*#__PURE__*/_react.default.createElement(_modal.default, { visible: visible, title: /*#__PURE__*/_react.default.createElement("div", { className: "".concat(prefixCls, "-modal-title") }, /*#__PURE__*/_react.default.createElement("span", null, options.title), /*#__PURE__*/_react.default.createElement("span", { className: "".concat(prefixCls, "-auxiliary-desc") }, this.auxiliaryDesc)), onClose: this.onClose, width: options.width || 520, style: { maxHeight: options.maxHeight || 730, maxWidth: options.maxWidth || 1152, height: options.height || 'unset' } }, /*#__PURE__*/_react.default.createElement("iframe", { src: options.link, width: "100%", height: "100%", frameBorder: "0", style: { width: '100%', padding: this.padding } }))); } }]); return DTCPopUpPage; }(_react.default.PureComponent); exports.default = DTCPopUpPage; _defineProperty(DTCPopUpPage, "componentName", 'pop-up-page'); _defineProperty(DTCPopUpPage, "schema", { type: 'object', properties: { label: { type: 'string' }, buttonType: { type: 'string' }, shape: { type: 'string' }, size: { type: 'string' }, title: { type: 'string' }, auxiliaryDesc: { type: 'string' }, link: { type: 'string' }, width: { anyOf: [{ type: 'string' }, { type: 'number' }] }, embeddedSafetyPadding: { anyOf: [{ type: 'string' }, { type: 'number' }] }, maxHeight: { anyOf: [{ type: 'string' }, { type: 'number' }] }, maxWidth: { anyOf: [{ type: 'string' }, { type: 'number' }] }, height: { anyOf: [{ type: 'string' }, { type: 'number' }] } } });