choerodon-ui
Version:
An enterprise-class UI design language and React-based implementation
147 lines (122 loc) • 3.31 kB
JavaScript
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) {
_classCallCheck(this, ColumnGroup);
this.column = column;
this.key = getColumnKey(column);
this.parent = parent;
var children = column.children;
var aggregation = parent.aggregation;
if ((!column.aggregation || !aggregation) && children && children.length > 0) {
this.children = new ColumnGroups(children, aggregation, this);
}
}
_createClass(ColumnGroup, [{
key: "setInView",
value: function setInView(inView) {
this.inView = inView;
}
}, {
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);
}
}, {
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 [];
}
}]);
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