UNPKG

choerodon-ui

Version:

An enterprise-class UI design language and React-based implementation

183 lines (152 loc) 4.07 kB
import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; import _createClass from "@babel/runtime/helpers/createClass"; import { __decorate } from "tslib"; import { action, computed, observable } from 'mobx'; import { columnWidth } from './Column'; import ColumnGroups from './ColumnGroups'; import { getColumnKey, getColumnLock } from './utils'; var ColumnGroup = /*#__PURE__*/function () { function ColumnGroup(column, parent, store) { _classCallCheck(this, ColumnGroup); this.store = store; this.column = column; this.key = getColumnKey(column); this.parent = parent; var children = column.children; var aggregation = parent.aggregation; if (children && children.length > 0) { if (!column.aggregation || !aggregation) { this.children = new ColumnGroups(children, store, this); } else { this.childrenInAggregation = new ColumnGroups(children, store, this); } } } _createClass(ColumnGroup, [{ key: "lock", get: function get() { return getColumnLock(this.column.lock); } }, { key: "rowSpan", get: function get() { return this.parent.deep - this.deep + 1; } }, { key: "colSpan", get: function get() { var children = this.children; return children ? children.wide : 1; } }, { key: "deep", get: function get() { var children = this.children; return children ? children.deep + 1 : this.hidden ? 0 : 1; } }, { key: "hidden", get: function get() { var children = this.children; return children ? children.hidden : !!this.column.hidden; } }, { key: "lastLeaf", get: function get() { var leafs = this.leafs; var length = leafs.length; return length ? leafs[length - 1] : undefined; } }, { key: "width", get: function get() { var children = this.children; return children ? children.width : columnWidth(this.column, this.store); } }, { key: "left", get: function get() { var prev = this.prev; if (prev) { return prev.left + prev.width; } var parent = this.parent; if (parent) { return parent.left; } return 0; } }, { key: "right", get: function get() { var next = this.next; if (next) { return next.right + next.width; } var parent = this.parent; if (parent) { return parent.right; } return 0; } }, { key: "allLeafs", get: function get() { var children = this.children; if (children) { return children.leafs; } return [this]; } }, { key: "leafs", get: function get() { var hidden = this.hidden; if (!hidden) { return this.allLeafs; } return []; } }, { key: "headerGroup", get: function get() { var __group = this.column.__group; if (__group) { return __group; } return this.parent.headerGroup; } }, { key: "headerGroups", get: function get() { var __groups = this.column.__groups; if (__groups) { return __groups; } return this.parent.headerGroups; } }, { key: "tableGroup", get: function get() { var __tableGroup = this.column.__tableGroup; if (__tableGroup) { return __tableGroup; } return this.parent.tableGroup; } }, { key: "setInView", value: function setInView(inView) { this.inView = inView; } }]); return ColumnGroup; }(); export { ColumnGroup as default }; __decorate([observable], ColumnGroup.prototype, "inView", void 0); __decorate([computed], ColumnGroup.prototype, "left", null); __decorate([computed], ColumnGroup.prototype, "right", null); __decorate([computed], ColumnGroup.prototype, "allLeafs", null); __decorate([computed], ColumnGroup.prototype, "leafs", null); __decorate([action], ColumnGroup.prototype, "setInView", null); //# sourceMappingURL=ColumnGroup.js.map