![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /var/www/html/libs/absol-full/dist/js/ |
Upload File : |
/*** module: node_modules/absol-acomp/js/EfficientTable.js ***/ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; require("../css/dynamictable.css"); var _ACore = _interopRequireWildcard(require("../ACore")); var _stringGenerate = require("absol/src/String/stringGenerate"); var _DomSignal = _interopRequireDefault(require("absol/src/HTML5/DomSignal")); var _ResizeSystem = _interopRequireDefault(require("absol/src/HTML5/ResizeSystem")); var _Dom = require("absol/src/HTML5/Dom"); var _AElement = _interopRequireDefault(require("absol/src/HTML5/AElement")); var _attribute = require("absol/src/JSX/attribute"); var _Rectangle = _interopRequireDefault(require("absol/src/Math/Rectangle")); var _safeThrow = _interopRequireDefault(require("absol/src/Code/safeThrow")); var _utils = require("./utils"); var _noop = _interopRequireDefault(require("absol/src/Code/noop")); var _Attributes = _interopRequireDefault(require("absol/src/AppPattern/Attributes")); var _OOP = _interopRequireDefault(require("absol/src/HTML5/OOP")); function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread 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 _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } 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; } var execAsync = (commands, whileFunc) => { return commands.reduce((ac, act) => { if (whileFunc && !whileFunc()) return; if (ac && ac.then) { if (typeof act === "function") { return ac.then(act); } else { return ac.then(() => act); } } if (typeof act === 'function') return act(ac);else return act; }, null); }; var getMaxRowCount = () => { var screenSize = (0, _Dom.getScreenSize)(); return Math.ceil(Math.max(2048, screenSize.height) / 40.0) * 3; }; var waitAll = (variables, thenCb) => { var hasPromise = variables.findIndex(v => v && typeof v.then === "function"); if (hasPromise >= 0) return Promise.all(variables).then(thenCb);else return thenCb(variables); }; var waitValue = (value, thenCb) => { if (value && typeof value.then === "function") { return value.then(thenCb); } else return thenCb(value); }; /** * @extends AElement * @constructor */ function EfficientTable() { this.layoutCtrl = new ETLayoutController(this); this.fixHeaderCtrl = new ETFixHeaderController(this); this._adapter = null; this.table = null; this.extendStyle = this.extendStyle || {}; this.$attachhook = (0, _ACore._)('attachhook').addTo(this); this.$attachhook.requestUpdateSize = this.layoutCtrl.requestUpdateSize.bind(this); this.colWidth = new ETColWidthDeclaration(this); /** * @name adapter * @type {ETAdapter} * @memberof EfficientTable# */ } EfficientTable.tag = 'EfficientTable'.toLowerCase(); EfficientTable.render = function (data, domDesc) { var width = domDesc.style && domDesc.style.width; var classList = ['as-efficient-table-wrapper']; if (width === 'match_parent') { classList.push('as-width-match-parent'); } var id = domDesc.id || domDesc.attr && domDesc.attr.id || 'no-id-' + (0, _stringGenerate.randomIdent)(10); return (0, _ACore._)({ id: id, extendEvent: ['colresize'], class: classList, props: { extendStyle: domDesc.style }, child: [{ class: 'as-dynamic-table-fixed-y-ctn' }] }); }; EfficientTable.prototype.addStyle = function (name, value) { if (name === 'width') { this.extendStyle[name] = value; } else { _AElement.default.prototype.addStyle.apply(this, arguments); } return this; }; EfficientTable.prototype.getColWidth = function () { var _this$colWidth; var table = this.table; if (!table) return null; if (arguments.length === 0) return this.colWidth.export();else return (_this$colWidth = this.colWidth).getProperty.apply(_this$colWidth, arguments); }; EfficientTable.prototype.setColWidth = function () { var _this$colWidth2; var table = this.table; if (!table) return null; if (arguments.length === 0) Object.assign(this.colWidth);else (_this$colWidth2 = this.colWidth).setProperty.apply(_this$colWidth2, arguments); }; /** * * @param {string|number|function}arg */ EfficientTable.prototype.findRow = function (arg) { if (this.table) { return this.table.body.findRow(arg); } return null; }; EfficientTable.prototype.requestUpdateSize = function () { this.layoutCtrl.requestUpdateSize(); }; EfficientTable.prototype.notifyDataSheetChange = function () { if (this.adapter) this.adapter.notifyDataSheetChange(); }; EfficientTable.prototype.notifyRowModifiedAt = function (idx) { if (this.adapter) this.adapter.notifyRowModifiedAt(idx); }; EfficientTable.prototype.notifyRowRemoveAt = function (idx) { if (this.adapter) this.adapter.notifyRowRemoveAt(idx); }; EfficientTable.prototype.notifyAddRowAt = function (idx) { if (this.adapter) this.adapter.notifyAddRowAt(idx); }; EfficientTable.prototype.revokeResource = function () { this.fixHeaderCtrl.revokeResource(); //todo: revoke all resource }; EfficientTable.property = {}; EfficientTable.property.adapter = { set: function (value) { this.colWidth.revokeResource(); this.fixHeaderCtrl.reset(); this._adapter = new ETAdapter(this, value); this.table = new ETTable(this, this._adapter.data); this.addChild(this.table.elt); this._adapter.notifyDataSheetChange(); this.colWidth = new ETColWidthDeclaration(this); }, get: function () { return this._adapter; } }; var _default = EfficientTable; exports.default = _default; _ACore.default.install(EfficientTable); // ETAdapter.prototype. /** * * @param {EfficientTable} elt * @constructor */ function ETFixHeaderController(elt) { this.elt = elt; this.$cloneTable = null; this.$cloneHead = null; } ETFixHeaderController.prototype.updateSize = function () {}; ETFixHeaderController.prototype.reset = function () { if (this.isWrapped) {} }; ETFixHeaderController.prototype.revokeResource = function () { this.revokeResource = _noop.default; this.elt = null; }; /** * * @param {EfficientTable} elt * @constructor */ function ETLayoutController(elt) { this.elt = elt; /*** * * @type {SearchTextInput|null} */ this.$searchInput = null; /*** * * @type {AElement} */ this.$table = (0, _ACore.$)('.as-dynamic-table', elt); /*** * * @type {AElement} */ this.$thead = (0, _ACore.$)('.as-dynamic-table>thead', this.$table); /*** * * @type {AElement} */ this.$tbody = (0, _ACore.$)('.as-dynamic-table>tbody', this.$table); this.$filterInputs = []; this.$attachhook = (0, _ACore._)('attachhook').addTo(elt); this.domSignal = new _DomSignal.default((0, _ACore._)('attachhook').addTo(elt)); //controller this.$fixedYCtn = (0, _ACore.$)('.as-dynamic-table-fixed-y-ctn', elt); this.extendStyle = {}; // this.$attachhook.requestUpdateSize = this.fixedContentCtrl.updateSize.bind(this.fixedContentCtrl); this.$attachhook.requestUpdateSize = this.requestUpdateSize.bind(this); this.$attachhook.on('attached', () => { _ResizeSystem.default.add(this.$attachhook); this.onAttached(); this.onAttached(); // manager.add(this); setTimeout(() => { this.requestUpdateSize(); }, 10); }); this.ev_scroll = this.ev_scroll.bind(this); this.$BindedScrollers = []; this.stopScrollTO = -1; } ETLayoutController.prototype.onAttached = function () { this.bindScroller(); }; ETLayoutController.prototype.requestUpdateSize = function () { this.elt.table.body.updateYOffset(true); var beforeRect = this.elt.table.body.size; this.viewSize(); this.viewByScroll(); this.elt.table.body.calcSize(); var newRect = this.elt.table.body.size; if (newRect.width !== beforeRect.width || newRect.height !== beforeRect.height) { _ResizeSystem.default.updateUp(this.elt.parentElement); } }; ETLayoutController.prototype.viewSize = function () { this.elt.table.calcSize(); var size = this.elt.table.size; if (size.trueValue) { this.elt.addClass('as-true-size'); } this.elt.addStyle('height', size.height + 1 + 'px'); }; ETLayoutController.prototype.bindScroller = function () { var p = this.elt.parentElement; while (p) { p.addEventListener('scroll', this.ev_scroll); this.$BindedScrollers.push(p); p = p.parentElement; } document.addEventListener('scroll', this.ev_scroll); this.$BindedScrollers.push(document); }; ETLayoutController.prototype.unBindScroller = function () { while (this.$BindedScrollers.length) { this.$BindedScrollers.pop().removeEventListener('scroll', this.ev_scroll); } }; ETLayoutController.prototype.viewByScroll = function () { if (!this.elt.table) return; if (this.elt.table.size.trueValue) return; var bound = this.elt.getBoundingClientRect(); var outbound = (0, _Dom.traceOutBoundingClientRect)(this.elt); //todo: small than scroller var head = this.elt.table.head; var hs = 0; if (bound.top >= outbound.top) { hs = 0; this.elt.table.elt.addStyle('top', 0); return; } else if (bound.bottom < outbound.bottom) { hs = 1; } else { hs = (outbound.top - (bound.top + head.size.height)) / (bound.height - head.size.height - outbound.height); } var rowLNIdx = this.elt.adapter.length * hs; var y = outbound.top + head.size.height + hs * (outbound.height - head.size.height); var rowIdx = Math.floor(rowLNIdx); if (hs === 1) rowIdx = this.elt.adapter.length - 1; var body = this.elt.table.body; var currentOffset = body.rowOffset; this.elt.table.body.requestVisible(rowIdx); this.elt.table.body.waitLoaded(() => { if (currentOffset !== body.rowOffset) return; this.elt.table.body.updateYOffset(); var row = body.rows[rowIdx - body.rowOffset]; if (!row) return; //out of date, don't update var rowLNY = row.offsetY + row.offsetHeight * hs; var dy = y - bound.top - rowLNY - hs; //hs for border 1px this.elt.table.elt.addStyle('top', dy + 'px'); }); }; ETLayoutController.prototype.ev_scroll = function () { this.viewByScroll(); clearTimeout(this.stopScrollTO); this.stopScrollTO = setTimeout(() => { this.viewByScroll(); }, 100); }; /** * * @param elt * @param adapterData * @constructor */ function ETAdapter(elt, adapterData) { this.elt = elt; this.data = adapterData.data; this.raw = adapterData; this.asyncSession = Math.random(); this.sync = null; } ETAdapter.prototype.notifyDataSheetChange = function () { var asyncSession = Math.random(); this.asyncSession = asyncSession; var cmdArr = [() => this.getLength(), () => { var body = this.elt.table.body; var head = this.elt.table.head; body.clear(); body.drawFrom(0); var makeSize = () => { body.waitLoaded(() => { body.updateYOffset(true); this.elt.layoutCtrl.requestUpdateSize(); }); }; if (this.elt.isDescendantOf(document.body)) { makeSize(); } else { this.elt.$attachhook.once('attached', makeSize); } }]; execAsync(cmdArr, () => this.asyncSession === asyncSession); }; ETAdapter.prototype.notifyRowModifiedAt = function (idx) { this.sync = execAsync([this.sync, () => { this.elt.table.body.modifiedRowAt(idx); if (this.elt.isDescendantOf(document.body)) { this.elt.table.body.waitLoaded(() => { this.elt.layoutCtrl.requestUpdateSize(); }); } }]); }; ETAdapter.prototype.notifyRowRemoveAt = function (idx) { this.sync = execAsync([this.sync, () => this.getLength(), () => { this.elt.table.body.removeRowAt(idx); if (this.elt.isDescendantOf(document.body)) { this.elt.table.body.waitLoaded(() => { this.elt.layoutCtrl.requestUpdateSize(); }); } }]); }; ETAdapter.prototype.notifyAddRowAt = function (idx) { this.sync = execAsync([this.sync, () => this.getLength(), () => { this.elt.table.body.addRowAt(idx); if (this.elt.isDescendantOf(document.body)) { this.elt.table.body.waitLoaded(() => { this.elt.layoutCtrl.viewSize(); }); } }]); }; ETAdapter.prototype.getLength = function () { return execAsync([() => { var body = this.raw.data.body; var length; if (typeof body.length === "number") { length = body.rows.length; } else if (body.length && body.length.then) { length = body.length; } else if (typeof body.getLength === "function") { try { length = this.raw.data.body.getLength(this); } catch (e) { (0, _safeThrow.default)(e); } } else if (body.rows) length = body.rows.length; return length; }, l => { this.length = l; return l; }]); }; ETAdapter.prototype.getRowAt = function (idx) { var data; var body = this.raw.data.body; if (typeof body.getRowAt === "function") { try { data = body.getRowAt(idx, this); } catch (e) { (0, _safeThrow.default)(e); } } else if (body.rows) data = body.rows[idx]; return data; }; ETAdapter.prototype.renderHeadCell = function (elt, data, controller) { if (data.child) { if (data.child.map) { elt.addChild(data.child.map(function (it) { return (0, _ACore._)(it); })); } else { elt.addChild((0, _ACore._)(data.child)); } } if (data.render) { data.render.call(null, elt, data, controller); } }; ETAdapter.prototype.renderBodyCell = function (elt, data, idx, controller) { var body = this.raw.data.body; var template = body.rowTemplate; var cellTpl = template.cells[idx]; if (cellTpl.child) { if (cellTpl.child.map) { elt.addChild(cellTpl.child.map(function (it) { return (0, _ACore._)(it); })); } else { elt.addChild((0, _ACore._)(cellTpl.child)); } } if (cellTpl.render) { cellTpl.render.call(null, elt, data, controller); } if (cellTpl.style) elt.addStyle(cellTpl.style); }; ETAdapter.prototype.getRowLength = function () { var body = this.raw.data.body; var template = body.rowTemplate; return template.cells.length; }; /** * * @param {EfficientTable} wrapper * @param data * @constructor */ function ETTable(wrapper, data) { this.wrapper = wrapper; this.adapter = this.wrapper.adapter; this.data = data; this.head = new ETHead(this, this.data.head); this.body = new ETBody(this, this.data.body); this.elt = (0, _ACore._)({ tag: 'table', class: 'as-dynamic-table', child: [this.head.elt, this.body.elt] }); this.handleStyle(); this.size = new _Rectangle.default(0, 0, 0, 0); this.size.trueValue = false; } ETTable.prototype.handleStyle = function () { var style = this.wrapper.extendStyle; var value; if (style.width) { value = (0, _attribute.parseMeasureValue)(style.width); if (value) { if (value.unit === '%') { this.wrapper.style.setProperty('width', value); this.elt.addStyle('width', '100%'); } } } }; ETTable.prototype.calcSize = function () { this.head.calcSize(); this.body.calcSize(); this.size = this.head.size.clone(); this.size.height += this.body.size.height; this.size.trueValue = this.body.size.trueValue; }; /** * * @param {ETTable} table * @param data * @constructor */ function ETHead(table, data) { this.table = table; this.data = data || {}; if (!this.data.rows) this.data.rows = []; this.rows = this.data.rows.map(rowData => new ETHeadRow(this, rowData)); this.elt = (0, _ACore._)({ tag: 'thead', class: 'as-dt-header', child: this.rows.map(it => it.elt) }); this.size = new _Rectangle.default(0, 0, 0, 0); } ETHead.prototype.calcSize = function () { var bound = this.elt.getBoundingClientRect(); this.size = _Rectangle.default.fromClientRect(bound); }; /** * * @param {ETHead} head * @param data * @constructor */ function ETHeadRow(head, data) { this.head = head; this.data = data || {}; if (!this.data.cells) this.data.cells = []; this.cells = this.data.cells.map(cellData => new ETHeadCell(this, cellData)); this.elt = (0, _ACore._)({ tag: 'tr', class: 'as-dt-header-row', child: this.cells.map(it => it.elt) }); } // (ETHeadRow) function ETHeadCell(row, data) { this.row = row; this.data = data || {}; this.elt = (0, _ACore._)({ tag: 'th', class: 'as-dt-header-cell' }); if (data.attr && (0, _utils.isNaturalNumber)(data.attr.colspan)) { this.elt.attr('colspan', data.attr.colspan); } if (data.attr && (0, _utils.isNaturalNumber)(data.attr.rowspan)) { this.elt.attr('colspan', data.attr.rowspan); } if (data.style) this.elt.addStyle(data.style); this.row.head.table.adapter.renderHeadCell(this.elt, this.data, this); } /** * * @param {ETTable} table * @param data * @constructor */ function ETBody(table, data) { this.data = data; this.table = table; this.elt = (0, _ACore._)({ tag: 'tbody', class: 'as-dt-body' }); this.rowOffset = 0; this.rows = []; /** * * @type {Rectangle|{trueValue:boolean}} */ this.size = new _Rectangle.default(0, 0, 0, 0); this.size.trueValue = false; this.needUpdateYOffset = false; this.sync = null; } ETBody.prototype.clear = function () { this.rowOffset = 0; var row; while (this.rows.length) { row = this.rows.shift(); this.rowOffset++; row.elt.remove(); row.revokeResource(); } this.needUpdateYOffset = true; }; ETBody.prototype.removeRowAt = function (idx) { var localIdx = idx - this.rowOffset; var row = this.rows[localIdx]; if (!row) return false; row.elt.selfRemove(); this.rows.splice(localIdx, 1); row.revokeResource(); for (var i = 0; i < this.rows.length; ++i) { this.rows[i].updateIdx(i + this.rowOffset); } this.drawFrom(this.rowOffset); }; ETBody.prototype.modifiedRowAt = function (idx) { var localIdx = idx - this.rowOffset; var row = this.rows[localIdx]; if (!row) return false; var newRow = new ETBodyRow(this, this.table.wrapper.adapter.getRowAt(idx)); newRow.updateIdx(idx); this.rows[localIdx] = newRow; row.elt.selfReplace(newRow.elt); this.needUpdateYOffset = true; }; ETBody.prototype.addRowAt = function (idx) { var localIdx = idx - this.rowOffset; var row = this.rows[localIdx]; if (!row) return false; var newRow = new ETBodyRow(this, this.table.wrapper.adapter.getRowAt(idx)); this.rows.splice(localIdx, 0, newRow); row.elt.parentElement.addChildBefore(newRow.elt, row.elt); for (var i = 0; i < this.rows.length; ++i) { this.rows[i].updateIdx(i + this.rowOffset); } this.needUpdateYOffset = true; }; ETBody.prototype.requestVisible = function (idx) { var maxRow = getMaxRowCount(); var length = this.table.wrapper.adapter.length; var pageIdx; var pageN = Math.ceil(Math.max(length / (maxRow / 3))); idx = Math.max(0, idx); idx = Math.min(length - 1, idx); pageIdx = Math.floor(idx / (maxRow / 3)); pageIdx = Math.min(pageN - 3, pageIdx - 1); pageIdx = Math.max(0, pageIdx); this.drawFrom(pageIdx * Math.floor(maxRow / 3)); }; ETBody.prototype.drawFrom = function (idx) { var adapter = this.table.wrapper.adapter; var maxRowCount = getMaxRowCount(); idx = Math.max(0, idx); var endIdx = Math.min(idx + maxRowCount, adapter.length); idx = Math.max(0, Math.min(endIdx - 1, idx)); var row; while (this.rowOffset + this.rows.length > idx + maxRowCount && this.rows.length) { row = this.rows.pop(); row.elt.remove(); } while (this.rowOffset < idx && this.rows.length) { row = this.rows.shift(); this.rowOffset++; row.elt.remove(); row.revokeResource(); this.needUpdateYOffset = true; } if (this.rows.length === 0) this.rowOffset = Math.min(adapter.length, idx + 1); var newRows = []; var newRow; while (this.rowOffset > idx && this.rowOffset > 0) { this.rowOffset--; newRow = new ETBodyRow(this, adapter.getRowAt(this.rowOffset)); newRows.push(newRow); newRow.updateIdx(this.rowOffset); this.rows.unshift(newRow); this.elt.addChildBefore(newRow.elt, this.elt.firstChild); this.needUpdateYOffset = true; } while (this.rowOffset + this.rows.length < endIdx) { newRow = new ETBodyRow(this, adapter.getRowAt(this.rowOffset + this.rows.length)); newRow.updateIdx(this.rowOffset + this.rows.length); newRows.push(newRow); this.rows.push(newRow); this.elt.addChild(newRow.elt); this.needUpdateYOffset = true; } }; /** * * @param {boolean} force */ ETBody.prototype.updateYOffset = function (force) { if (!this.needUpdateYOffset && !force) return; this.needUpdateYOffset = false; var tableBound = this.table.elt.getBoundingClientRect(); this.rows.forEach(row => { row.calcSize(); var rowBound = row.size; row.offsetY = rowBound.y - tableBound.top; row.offsetHeight = rowBound.height; }); }; ETBody.prototype.calcSize = function () { var adapter = this.table.wrapper.adapter; var bound = this.elt.getBoundingClientRect(); if (this.rows.length === adapter.length) { this.size = _Rectangle.default.fromClientRect(bound); this.size.trueValue = true; } else { this.size = _Rectangle.default.fromClientRect(bound); this.size.height = bound.height / this.rows.length * adapter.length; this.size.trueValue = false; } }; ETBody.prototype.waitLoaded = function (cb) { waitAll(this.rows.map(row => row.data), cb); }; function ETBodyRow(body, data) { this.elt = (0, _ACore._)({ tag: 'tr', class: 'as-dt-body-row' }); this.offsetY = 0; this.data = data; this.body = body; this.idx = 0; this.$idx = undefined; waitValue(this.data, data => { this.data = data; var adapter = body.table.wrapper.adapter; var length = adapter.getRowLength(); this.cells = Array(length).fill(null).map((u, i) => new ETBodyCell(this, i)); this.elt.addChild(this.cells.map(cell => cell.elt)); this.$idx = (0, _ACore.$)('.as-dt-row-index', this.elt) || null; if (this.$idx) this.$idx.attr('data-idx', this.idx + 1); if (data.on && data.on.click) { this.elt.on('click', event => { data.on.click.call(this.elt, event, this); }); } if (adapter.data.body.rowTemplate.on && typeof adapter.data.body.rowTemplate.on.click === "function") { this.elt.on('click', event => { adapter.data.body.rowTemplate.on.click.call(this.elt, event, this); }); } }); this.size = new _Rectangle.default(0, 0, 0, 0); // this.cells = data.cells.map(cell => new ETBodyCell(this, cell)); /** * @name adapter * @type {ETAdapter} * @memberof ETBodyRow# */ } ETBodyRow.prototype.updateIdx = function (value) { this.idx = value; if (!this.cells) return; if (this.$idx === undefined) this.$idx = (0, _ACore.$)('.as-dt-row-index', this.elt) || null; if (this.$idx) this.$idx.attr('data-idx', this.idx + 1); }; ETBodyRow.prototype.calcSize = function () { this.size = _Rectangle.default.fromClientRect(this.elt.getBoundingClientRect()); }; ETBodyRow.prototype.notifyRemove = function () { if (this.adapter) this.adapter.notifyRowRemoveAt(this.idx); }; ETBodyRow.prototype.notifyModified = function () { if (this.adapter) this.adapter.notifyRowModifiedAt(this.idx); }; ETBodyRow.prototype.revokeResource = function () { // return; this.revokeResource = _noop.default; (0, _utils.revokeResource)(this.elt); delete this.elt; this.body = null; this.notifyRemove = _noop.default; }; Object.defineProperty(ETBodyRow.prototype, 'adapter', { /** * * @returns {ETAdapter} */ get: function () { return this.body && this.body.table.wrapper && this.body.table.wrapper.adapter; } }); function ETBodyCell(row, idx) { this.elt = (0, _ACore._)({ tag: 'td', class: 'as-dt-body-cell' }); this.row = row; var adapter = this.row.body.table.wrapper.adapter; adapter.renderBodyCell(this.elt, row.data, idx, this); } /** * @extends Attributes * @param {EfficientTable} elt * @constructor */ function ETColWidthDeclaration(elt) { _Attributes.default.call(this, this); if (!elt.table) return; var temp = elt.table.head.rows.reduce((ac, row) => { var l = row.cells.reduce((ac1, cell) => { var colspan = cell.data.attr && (cell.data.attrs.colspan || cell.data.attrs.colSpan); colspan = parseInt(colspan + '', 10); if (!(0, _utils.isNaturalNumber)(colspan) || !colspan) colspan = 1; var id = cell.data.id; if (id && typeof id === "string") { ac.id2idx[id] = ac1; } if (colspan === 1) { if (!ac.idx2cells[ac1]) ac.idx2cells[ac1] = []; ac.idx2cells[ac1].push(cell); } return ac1 + colspan; }, 0); ac.length = Math.max(ac.length, l); return ac; }, { length: 0, id2idx: {}, idx2cells: {} }); Array(temp.length).fill(0).forEach((u, i) => { this.defineProperty('' + i, { set: function (value, ...args) { var unit; if (args.length > 1) unit = args[0]; var headWith; var originValue = this.getProperty('' + i); var pOValue = (0, _attribute.parseMeasureValue)(originValue); if (!(0, _utils.isRealNumber)(value) || value < 0) { value = 'auto'; } else if (unit === 'px') { if (pOValue.unit === '%') { headWith = elt.table.head.elt.getBoundingClientRect().width; value = value / headWith * 100 + '%'; } else { value = value + 'px'; } } else if (unit === '%') { headWith = elt.table.head.elt.getBoundingClientRect().width; if (pOValue.unit === 'px') { value = value / 188 * headWith; } else { value = value + '%'; } } if (typeof value === "number") value = value + 'px'; var cells = temp.idx2cells[i] || []; cells.forEach(cell => { if (value === 'auto') { if (cell.data.style) { delete cell.data.style.width; cell.elt.removeStyle('width'); } } else { if (!cell.data.style) cell.data.style = {}; cell.data.style.width = value; cell.elt.addStyle('width', value); } }); }, get: function (...args) { var unit; if (args.length > 1) unit = args[0]; var ref = args[args.length - 1]; var value = ref.get(); var cells = temp.idx2cells[i] || []; if (cells.length === 0) return 0; if (unit === 'px') { value = cells[0].elt.getBoundingClientRect().width; } else if (unit === '%') { value = cells[0].elt.getBoundingClientRect().width / elt.table.head.elt.getBoundingClientRect().width * 100; } else { value = cells.reduce((ac, cell) => { var pValue; if (cell.data.style && cell.data.style.width) { pValue = (0, _attribute.parseMeasureValue)(cell.data.style.width); if (!pValue || pValue.unit !== 'px') return ac; return pValue.value; } return ac; }, 'auto'); } return value; } }); }); Object.keys(temp.id2idx).forEach(id => { var idx = temp.id2idx[id]; this.defineProperty(id, { set: function (...args) { return this.setProperty.apply(this, [idx].concat(_toConsumableArray(args.slice(1)))); }, get: function (...args) { return this.getProperty.apply(this, [idx].concat(_toConsumableArray(args.slice(1)))); } }); }); } _OOP.default.mixClass(ETColWidthDeclaration, _Attributes.default); Object.defineProperty(ETColWidthDeclaration.prototype, 'revokeResource', { value: function () { delete this.$node; delete this.revokeResource; }, writable: true, enumerable: false, configurable: true });