UNPKG

choerodon-ui

Version:

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

190 lines (158 loc) 4.5 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"]; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); var _tslib = require("tslib"); var _mobx = require("mobx"); var _Column = require("./Column"); var _ColumnGroups = _interopRequireDefault(require("./ColumnGroups")); var _utils = require("./utils"); var ColumnGroup = /*#__PURE__*/function () { function ColumnGroup(column, parent, store) { (0, _classCallCheck2["default"])(this, ColumnGroup); this.store = store; this.column = column; this.key = (0, _utils.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["default"](children, store, this); } else { this.childrenInAggregation = new _ColumnGroups["default"](children, store, this); } } } (0, _createClass2["default"])(ColumnGroup, [{ key: "lock", get: function get() { return (0, _utils.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 : (0, _Column.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; }(); exports["default"] = ColumnGroup; (0, _tslib.__decorate)([_mobx.observable], ColumnGroup.prototype, "inView", void 0); (0, _tslib.__decorate)([_mobx.computed], ColumnGroup.prototype, "left", null); (0, _tslib.__decorate)([_mobx.computed], ColumnGroup.prototype, "right", null); (0, _tslib.__decorate)([_mobx.computed], ColumnGroup.prototype, "allLeafs", null); (0, _tslib.__decorate)([_mobx.computed], ColumnGroup.prototype, "leafs", null); (0, _tslib.__decorate)([_mobx.action], ColumnGroup.prototype, "setInView", null); //# sourceMappingURL=ColumnGroup.js.map