UNPKG

drip-table

Version:

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

861 lines (726 loc) 31.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; require("./index.less"); var _classnames = _interopRequireDefault(require("classnames")); var _rcResizeObserver = _interopRequireDefault(require("rc-resize-observer")); var _rcTextarea = _interopRequireDefault(require("rc-textarea")); var _react = _interopRequireDefault(require("react")); var _reactClipboard = _interopRequireDefault(require("react-clipboard.js")); var _reactDom = _interopRequireDefault(require("react-dom")); var _reactEventInjector = require("react-event-injector"); var _uuid = require("uuid"); var _operator = require("../../../utils/operator"); var _alert = _interopRequireDefault(require("../../react-components/alert")); var _select = _interopRequireDefault(require("../../react-components/select")); var _tooltip = _interopRequireDefault(require("../../react-components/tooltip")); var _utils = require("../utils"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } 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); } 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-text'; var translate = function translate(i18n, origin) { if (typeof origin === 'string' && i18n && origin in i18n) { return i18n[origin]; } return origin; }; var justifyContentMap = { left: 'flex-start', center: 'center', right: 'flex-end' }; var DTCText = /*#__PURE__*/function (_React$PureComponent) { _inherits(DTCText, _React$PureComponent); var _super = _createSuper(DTCText); function DTCText() { var _globalThis$window; var _this; _classCallCheck(this, DTCText); 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", { windowInnerWidth: ((_globalThis$window = globalThis.window) === null || _globalThis$window === void 0 ? void 0 : _globalThis$window.innerWidth) || 0, cellLeft: 0, cellTop: 0, cellWidth: 0, cellHeight: 0, cellPaddingLeft: 0, cellPaddingRight: 0, cellPaddingTop: 0, cellPaddingBottom: 0, editState: 'none', editWidth: 0, editHeight: 0, editValue: '' }); _defineProperty(_assertThisInitialized(_this), "componentUuid", "dtc-".concat((0, _uuid.v4)())); _defineProperty(_assertThisInitialized(_this), "$main", /*#__PURE__*/_react.default.createRef()); _defineProperty(_assertThisInitialized(_this), "updateCellRect", function ($main) { var innerRect = $main.getBoundingClientRect(); var $cell = $main.parentElement; var cellRect = $cell.getBoundingClientRect(); _this.setState({ cellLeft: cellRect.left, cellTop: cellRect.top, cellWidth: cellRect.width, cellHeight: cellRect.height, cellPaddingLeft: innerRect.left - cellRect.left, cellPaddingRight: cellRect.right - innerRect.right, cellPaddingTop: innerRect.top - cellRect.top, cellPaddingBottom: cellRect.bottom - innerRect.bottom, editWidth: cellRect.width, editHeight: cellRect.height }); }); _defineProperty(_assertThisInitialized(_this), "onDoubleClick", function (e) { if (_this.props.preview) { return; } if (!_this.props.editable) { return; } if (_this.state.editState !== 'none') { return; } _this.updateCellRect(e.currentTarget); _this.setState({ editState: 'entering' }); }); _defineProperty(_assertThisInitialized(_this), "onKeyDown", function (e) { if (_this.props.preview) { return; } if (_this.state.editState === 'none' && e.key.length === 1 && !_this.props.schema.options.i18n) { _this.setState({ editState: 'editing', editValue: '' }); _this.updateCellRect(e.currentTarget); } else if (_this.state.editState === 'editing' && e.key === 'Escape') { _this.setState({ editState: 'none' }); } else if (_this.state.editState === 'none') { e.currentTarget.blur(); } }); _defineProperty(_assertThisInitialized(_this), "onWheel", function (e) { if (e.target instanceof HTMLTextAreaElement) { var scrollable = e.deltaY < 0 ? Math.abs(e.target.scrollTop) > Number.EPSILON : e.target.scrollHeight - e.target.scrollTop - e.target.clientHeight > Number.EPSILON; if (scrollable) { return; } } return (0, _utils.preventEvent)(e); }); _defineProperty(_assertThisInitialized(_this), "onResize", function (sizeInfo, el) { var _globalThis$window$in, _globalThis$window2; if (_this.$main.current) { _this.updateCellRect(_this.$main.current); } _this.setState({ windowInnerWidth: (_globalThis$window$in = (_globalThis$window2 = globalThis.window) === null || _globalThis$window2 === void 0 ? void 0 : _globalThis$window2.innerWidth) !== null && _globalThis$window$in !== void 0 ? _globalThis$window$in : 0 }); }); _defineProperty(_assertThisInitialized(_this), "focusEdit", function () { var $editPopup = document.querySelector("#".concat(_this.componentUuid, "-popup")); if (!$editPopup) { return; } var $editTextarea = $editPopup.querySelector(".".concat(prefixCls, "-edit-textarea")); if (!$editTextarea || !($editTextarea instanceof HTMLTextAreaElement)) { return; } var end = $editTextarea.value.length; $editTextarea.setSelectionRange(end, end); $editTextarea.focus(); }); return _this; } _createClass(DTCText, [{ key: "configured", get: function get() { var schema = this.props.schema; var options = schema.options; if (options.mode === 'custom') { if (options.format) { return true; } return false; } if (options.mode === 'multiple') { if (options.parts) { return options.parts.length > 0; } return false; } if (options.mode === 'single') { if (_typeof(schema.dataIndex) === 'object') { return Object.keys(schema.dataIndex).length > 0; } return !!schema.dataIndex; } if (options.mode === 'static') { return typeof options.static === 'string'; } return false; } }, { key: "fontSize", get: function get() { var fontSize = String(this.props.schema.options.fontSize || '').trim(); if (/^[0-9]+$/ig.test(fontSize)) { fontSize += 'px'; } return fontSize; } }, { key: "lineHeight", get: function get() { return this.props.schema.options.lineHeight || 1.5; } }, { key: "wrapperClassName", get: function get() { var maxRow = this.props.schema.options.maxRow; var wrapperClassName = []; if (this.props.schema.options.ellipsis) { wrapperClassName.push("".concat(prefixCls, "-text-ellipsis")); } if (maxRow) { wrapperClassName.push("".concat(prefixCls, "-max-row")); } return (0, _classnames.default)(wrapperClassName, this.props.schema.options.className); } }, { key: "commonStyles", get: function get() { var lineHeight = this.lineHeight; var textStyles = { fontSize: this.fontSize, fontWeight: this.props.schema.options.fontWeight, lineHeight: lineHeight }; if (this.props.schema.options.height) { textStyles.height = this.props.schema.options.height; } if (this.props.schema.options.width) { textStyles.width = this.props.schema.options.width; } return textStyles; } }, { key: "rawTextStyles", get: function get() { var schema = this.props.schema; var commonStyles = this.commonStyles; var textStyles = Object.assign({}, commonStyles); if (_typeof(schema.options.tooltip) === 'object') { Object.assign(textStyles, schema.options.tooltip.style); } return textStyles; } }, { key: "wrapperStyles", get: function get() { var commonStyles = this.commonStyles; var maxRow = this.props.schema.options.maxRow; var lineHeight = this.lineHeight; var wrapperStyles = Object.assign({}, commonStyles); if (maxRow) { wrapperStyles.WebkitLineClamp = maxRow; wrapperStyles.maxHeight = "".concat(maxRow * lineHeight, "em"); } return wrapperStyles; } }, { key: "rawText", get: function get() { var _schema$defaultValue, _this2 = this; var _this$props = this.props, schema = _this$props.schema, value = _this$props.value, record = _this$props.record, recordIndex = _this$props.recordIndex, indexValue = _this$props.indexValue, ext = _this$props.ext; var dataIndex = schema.dataIndex, options = schema.options; var mode = options.mode, format = options.format, prefix = options.prefix, suffix = options.suffix, params = options.parts; var defaultValue = 'defaultValue' in options ? options.defaultValue : String((_schema$defaultValue = schema.defaultValue) !== null && _schema$defaultValue !== void 0 ? _schema$defaultValue : ''); if (mode === 'custom') { return (format || '').replace(/\{\{((?:[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+?)\}\}/gi, function (s, s1) { return _this2.props.finalizeString('script', "return ".concat(s1), record, recordIndex, ext); }).split('\n'); } if (mode === 'single') { if (options.dataProcess) { var _translate; console.warn('[DripTable] schema.columns[].options.dataProcess is deprecated, use schema.columns[].dataTranslation instead.'); return "".concat(prefix !== null && prefix !== void 0 ? prefix : '').concat((_translate = translate(schema.options.i18n, (0, _utils.dataProcessIndex)(this.props.evaluate, record, dataIndex, defaultValue, options.dataProcess))) !== null && _translate !== void 0 ? _translate : '').concat(suffix !== null && suffix !== void 0 ? suffix : '').split('\n'); } return "".concat(prefix !== null && prefix !== void 0 ? prefix : '').concat(translate(schema.options.i18n, "".concat(value === '' || value === null || value === void 0 ? defaultValue : value))).concat(suffix !== null && suffix !== void 0 ? suffix : '').split('\n'); } if (mode === 'multiple') { if (options.dataProcess) { console.warn('[DripTable] schema.columns[].options.dataProcess is deprecated, use schema.columns[].dataTranslation instead.'); return (params || []).map(function (config, i) { var _translate2; return "".concat(config.prefix || '').concat((_translate2 = translate(config.i18n, (0, _utils.dataProcessIndex)(_this2.props.evaluate, record, config.dataIndex, defaultValue, options.dataProcess))) !== null && _translate2 !== void 0 ? _translate2 : '').concat(config.suffix || ''); }).join('\n').split('\n'); } return (params || []).map(function (config, i) { return "".concat(config.prefix || '').concat(translate(config.i18n, "".concat(indexValue(config.dataIndex, defaultValue)))).concat(config.suffix || ''); }).join('\n').split('\n'); } if (mode === 'static') { return (options.static || '').split('\n'); } return []; } }, { key: "visible", get: function get() { var _this$props2 = this.props, schema = _this$props2.schema, record = _this$props2.record; var dataIndex = schema.dataIndex, options = schema.options; var mode = options.mode, visibleFunc = options.visibleFunc; if (mode === 'single' && visibleFunc) { console.warn('schema.columns[].options.visibleFunc is deprecated, use schema.columns[].hidden instead.'); return !!(0, _utils.dataProcessValue)(this.props.evaluate, record, dataIndex, visibleFunc); } return true; } }, { key: "disabled", get: function get() { var _this$props$disable; var _this$props3 = this.props, schema = _this$props3.schema, record = _this$props3.record; var dataIndex = schema.dataIndex, options = schema.options; var mode = options.mode, disableFunc = options.disableFunc; if (mode === 'single' && disableFunc) { console.warn('schema.columns[].options.disableFunc is deprecated, use schema.columns[].disable instead.'); return !!(0, _utils.dataProcessValue)(this.props.evaluate, record, dataIndex, disableFunc); } return (_this$props$disable = this.props.disable) !== null && _this$props$disable !== void 0 ? _this$props$disable : false; } }, { key: "tooltip", get: function get() { var _this3 = this; var _this$props4 = this.props, schema = _this$props4.schema, record = _this$props4.record, recordIndex = _this$props4.recordIndex, ext = _this$props4.ext; var tooltip = (_typeof(schema.options.tooltip) === 'object' ? schema.options.tooltip.content : schema.options.tooltip) || ''; if (tooltip) { return tooltip.replace(/\{\{((?:[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+?)\}\}/gi, function (s, s1) { return _this3.props.finalizeString('script', "return ".concat(s1), record, recordIndex, ext); }); } return ''; } }, { key: "componentDidUpdate", value: function componentDidUpdate() { var _this4 = this; if (this.state.editState === 'entering') { this.setState({ editState: 'editing', editValue: String(this.props.value) }, function () { return _this4.focusEdit(); }); } } }, { key: "renderEditInput", value: function renderEditInput() { var _this5 = this; if (this.props.schema.options.i18n) { var selectMinWidth = 100; var selectMaxWidth = this.state.windowInnerWidth - this.state.cellLeft - 17; var selectFinalWidth = Math.min(Math.max(this.state.cellWidth, selectMinWidth), selectMaxWidth); var justifyContent = 'center'; if (this.props.schema.verticalAlign === 'top' || this.props.schema.verticalAlign === 'stretch') { justifyContent = 'flex-start'; } else if (this.props.schema.verticalAlign === 'bottom') { justifyContent = 'flex-end'; } return /*#__PURE__*/_react.default.createElement("div", { className: (0, _classnames.default)("".concat(prefixCls, "-edit-editing-outline"), "".concat(prefixCls, "-edit-select")), style: { width: selectFinalWidth, height: this.state.cellHeight, justifyContent: justifyContent } }, /*#__PURE__*/_react.default.createElement(_select.default, { style: { width: selectFinalWidth - 36 }, autoFocus: true, value: this.state.editValue, onChange: function onChange(value) { _this5.setState({ editValue: value }); }, onBlur: function onBlur() { var _this5$props$onChange, _this5$props; (_this5$props$onChange = (_this5$props = _this5.props).onChange) === null || _this5$props$onChange === void 0 ? void 0 : _this5$props$onChange.call(_this5$props, _this5.state.editValue); _this5.setState({ editState: 'none' }); }, dropdownClassName: "".concat(prefixCls, "-edit-select-dropdown") }, Object.entries(this.props.schema.options.i18n).map(function (_ref) { var _ref2 = _slicedToArray(_ref, 2), k = _ref2[0], v = _ref2[1]; return /*#__PURE__*/_react.default.createElement(_select.default.Option, { value: k }, v); }))); } var editMinWidth = this.state.windowInnerWidth < 768 ? 200 : 500; var editMaxWidth = this.state.windowInnerWidth - this.state.cellLeft - 17; var editFinalWidth = Math.min(Math.max(this.state.cellWidth, editMinWidth), editMaxWidth); return /*#__PURE__*/_react.default.createElement(_rcTextarea.default, { className: (0, _classnames.default)("".concat(prefixCls, "-edit-editing-outline"), "".concat(prefixCls, "-edit-textarea")), value: this.state.editValue, autoFocus: true, autoSize: { maxRows: 6 }, style: { width: editFinalWidth, height: this.state.editHeight, minHeight: this.state.cellHeight }, onResize: function onResize(_ref3) { var width = _ref3.width, height = _ref3.height; _this5.setState({ editWidth: width, editHeight: height }); }, onChange: function onChange(e) { _this5.setState({ editValue: e.target.value }); }, onBlur: function onBlur() { var _this5$props$onChange2, _this5$props2; (_this5$props$onChange2 = (_this5$props2 = _this5.props).onChange) === null || _this5$props$onChange2 === void 0 ? void 0 : _this5$props$onChange2.call(_this5$props2, _this5.state.editValue); _this5.setState({ editState: 'none' }); } }); } }, { key: "renderEdit", value: function renderEdit() { if (!this.props.editable) { return null; } return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", { className: "".concat(prefixCls, "-edit-padding-left"), style: { width: this.state.cellPaddingLeft, left: -this.state.cellPaddingLeft } }), /*#__PURE__*/_react.default.createElement("div", { className: "".concat(prefixCls, "-edit-padding-right"), style: { width: this.state.cellPaddingRight, right: -this.state.cellPaddingRight } }), /*#__PURE__*/_react.default.createElement("div", { className: "".concat(prefixCls, "-edit-padding-top"), style: { height: this.state.cellPaddingTop, top: -this.state.cellPaddingTop } }), /*#__PURE__*/_react.default.createElement("div", { className: "".concat(prefixCls, "-edit-padding-bottom"), style: { height: this.state.cellPaddingBottom, bottom: -this.state.cellPaddingBottom } }), this.state.editState === 'none' ? void 0 : /*#__PURE__*/_reactDom.default.createPortal( /*#__PURE__*/_react.default.createElement(_reactEventInjector.EventInjector, { onWheel: this.onWheel, settings: { capture: true, passive: false } }, /*#__PURE__*/_react.default.createElement("div", { className: "".concat(prefixCls, "-edit-popup"), id: "".concat(this.componentUuid, "-popup"), onWheelCapture: function onWheelCapture(e) { return (0, _utils.preventEvent)(e); } }, /*#__PURE__*/_react.default.createElement("div", { className: "".concat(prefixCls, "-edit-popup-body"), style: { left: this.state.cellLeft, right: 0, top: this.state.cellTop, bottom: 0 } }, /*#__PURE__*/_react.default.createElement("div", { className: "".concat(prefixCls, "-edit-popup-bg"), style: { width: this.state.editWidth, height: this.state.editHeight } }), this.renderEditInput()))), document.body)); } }, { key: "renderClipboard", value: function renderClipboard() { var _this6 = this; var showClipboard = this.props.schema.options.clipboard; if (!showClipboard) { return null; } return /*#__PURE__*/_react.default.createElement(_reactClipboard.default, { className: "".concat(prefixCls, "-clipboard"), component: "div", "option-text": function optionText() { return _this6.rawText.join(' '); }, onSuccess: function onSuccess() { _this6.props.fireEvent({ type: 'drip-text-copy', payload: { success: true } }); }, onError: function onError() { _this6.props.fireEvent({ type: 'drip-text-copy', payload: { success: false } }); } }, /*#__PURE__*/_react.default.createElement("span", { role: "img", "aria-label": "copy" }, /*#__PURE__*/_react.default.createElement("svg", { viewBox: "64 64 896 896", focusable: "false", "data-icon": "copy", width: "1em", height: "1em", fill: "currentColor", "aria-hidden": "true" }, /*#__PURE__*/_react.default.createElement("path", { d: "M832 64H296c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h496v688c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8V96c0-17.7-14.3-32-32-32zM704 192H192c-17.7 0-32 14.3-32 32v530.7c0 8.5 3.4 16.6 9.4 22.6l173.3 173.3c2.2 2.2 4.7 4 7.4 5.5v1.9h4.2c3.5 1.3 7.2 2 11 2H704c17.7 0 32-14.3 32-32V224c0-17.7-14.3-32-32-32zM350 856.2L263.9 770H350v86.2zM664 888H414V746c0-22.1-17.9-40-40-40H232V264h432v624z" })))); } }, { key: "render", value: function render() { var _classNames; var wrapperClassName = this.wrapperClassName; var wrapperStyles = this.wrapperStyles; if (!this.visible) { return /*#__PURE__*/_react.default.createElement("div", null); } if (!this.configured) { return /*#__PURE__*/_react.default.createElement(_alert.default, { message: "\u672A\u914D\u7F6E\u5B57\u6BB5", showIcon: true, type: "error" }); } var rawTextEl = this.rawText.map(function (s, i) { return /*#__PURE__*/_react.default.createElement("div", { key: i }, (0, _operator.stringify)(s) || (i === 0 ? '' : /*#__PURE__*/_react.default.createElement("br", null))); }); var wrapperEl = /*#__PURE__*/_react.default.createElement("div", { className: (0, _classnames.default)(wrapperClassName, "".concat(prefixCls, "-word-break")), style: wrapperStyles }, rawTextEl); if ((this.props.schema.options.maxRow && this.props.schema.options.showTooltip === void 0 || this.props.schema.options.showTooltip !== false) && !this.props.preview) { wrapperEl = /*#__PURE__*/_react.default.createElement(_tooltip.default, { title: /*#__PURE__*/_react.default.createElement("div", { className: "".concat(prefixCls, "-word-break"), style: this.rawTextStyles }, this.tooltip || rawTextEl), placement: this.props.schema.options.placement }, wrapperEl); } return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_rcResizeObserver.default, { onResize: this.onResize }, /*#__PURE__*/_react.default.createElement("div", { ref: this.$main, className: (0, _classnames.default)("".concat(prefixCls, "-main"), (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-editable"), this.props.editable && !this.props.preview), _defineProperty(_classNames, "".concat(prefixCls, "-disabled"), this.disabled), _classNames)), style: { justifyContent: this.props.schema.align ? justifyContentMap[this.props.schema.align] : void 0, alignItems: this.props.schema.verticalAlign }, tabIndex: 0, onDoubleClick: this.onDoubleClick, onKeyDown: this.onKeyDown }, wrapperEl, this.renderClipboard(), !this.disabled && this.renderEdit())), /*#__PURE__*/_react.default.createElement("div", { className: "".concat(prefixCls, "-focus-border") })); } }]); return DTCText; }(_react.default.PureComponent); exports.default = DTCText; _defineProperty(DTCText, "componentName", 'text'); _defineProperty(DTCText, "schema", { type: 'object', properties: { fontSize: { type: 'string' }, fontWeight: { type: 'string' }, mode: { enum: ['single', 'multiple', 'custom'] }, format: { type: 'string' }, static: { type: 'string' }, i18n: {}, defaultValue: { type: 'string' }, prefix: { type: 'string' }, suffix: { type: 'string' }, showTooltip: { type: 'boolean' }, placement: { enum: ['top', 'left', 'right', 'bottom', 'topLeft', 'topRight', 'bottomLeft', 'bottomRight', 'leftTop', 'leftBottom', 'rightTop', 'rightBottom'] }, tooltip: { anyOf: [{ type: 'string' }, { type: 'object', properties: { content: { type: 'string' }, style: { type: 'object', patternProperties: { '^.*$': { anyOf: [{ type: 'string' }, { type: 'number' }] } } } } }] }, parts: { type: 'array', items: { type: 'object', properties: { dataIndex: { anyOf: [{ type: 'string' }, { type: 'array', items: { type: 'string' } }] }, i18n: {}, prefix: { type: 'string' }, suffix: { type: 'string' } } } }, maxRow: { type: 'number' }, lineHeight: { type: 'number' }, height: { type: 'number' }, width: { type: 'number' }, ellipsis: { type: 'boolean' }, clipboard: { type: 'boolean' }, dataProcess: { type: 'string' }, disableFunc: { type: 'string' }, visibleFunc: { type: 'string' } } });