choerodon-ui
Version:
An enterprise-class UI design language and React-based implementation
116 lines (94 loc) • 2.71 kB
JavaScript
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import { __decorate } from "tslib";
import { computed } from 'mobx';
import { columnWidth } from './Column';
import ColumnGroups from './ColumnGroups';
import { getColumnKey } from './utils';
var ColumnGroup =
/*#__PURE__*/
function () {
function ColumnGroup(column, parent) {
_classCallCheck(this, ColumnGroup);
this.column = column;
this.parent = parent;
var children = column.children;
if (children && children.length > 0) {
this.children = new ColumnGroups(children, this);
}
}
_createClass(ColumnGroup, [{
key: "key",
get: function get() {
return getColumnKey(this.column);
}
}, {
key: "rowSpan",
get: function get() {
return this.parent.deep - this.deep + 1;
}
}, {
key: "colSpan",
get: function get() {
return this.children ? this.children.wide : 1;
}
}, {
key: "deep",
get: function get() {
return this.children ? this.children.deep + 1 : this.hidden ? 0 : 1;
}
}, {
key: "hidden",
get: function get() {
return this.children ? this.children.hidden : !!this.column.hidden;
}
}, {
key: "lastLeaf",
get: function get() {
return this.children ? this.children.lastLeaf : this.column;
}
}, {
key: "width",
get: function get() {
return this.children ? this.children.width : columnWidth(this.column);
}
}, {
key: "left",
get: function get() {
var prev = this.prev,
parent = this.parent;
if (prev) {
return prev.left + prev.width;
}
if (parent) {
return parent.left;
}
return 0;
}
}, {
key: "right",
get: function get() {
var next = this.next,
parent = this.parent;
if (next) {
return next.right + next.width;
}
if (parent) {
return parent.right;
}
return 0;
}
}]);
return ColumnGroup;
}();
export { ColumnGroup as default };
__decorate([computed], ColumnGroup.prototype, "key", null);
__decorate([computed], ColumnGroup.prototype, "rowSpan", null);
__decorate([computed], ColumnGroup.prototype, "colSpan", null);
__decorate([computed], ColumnGroup.prototype, "deep", null);
__decorate([computed], ColumnGroup.prototype, "hidden", null);
__decorate([computed], ColumnGroup.prototype, "lastLeaf", null);
__decorate([computed], ColumnGroup.prototype, "width", null);
__decorate([computed], ColumnGroup.prototype, "left", null);
__decorate([computed], ColumnGroup.prototype, "right", null);
//# sourceMappingURL=ColumnGroup.js.map