UNPKG

6.1 kBJavaScriptView Raw
1/**
2 * ag-grid - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
3 * @version v18.1.2
4 * @link http://www.ag-grid.com/
5 * @license MIT
6 */
7"use strict";
8var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
9 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
11 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
12 return c > 3 && r && Object.defineProperty(target, key, r), r;
13};
14var __metadata = (this && this.__metadata) || function (k, v) {
15 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
16};
17Object.defineProperty(exports, "__esModule", { value: true });
18var utils_1 = require("../utils");
19var context_1 = require("../context/context");
20var gridOptionsWrapper_1 = require("../gridOptionsWrapper");
21/**
22 * There are many instances of this component covering each of the areas a row can be entered
23 * eg body, pinned left, fullWidth. The component differs from others in that it's given the
24 * elements, there is no template. All of the elements are part of the GridPanel.
25 */
26var RowContainerComponent = (function () {
27 function RowContainerComponent(params) {
28 this.childCount = 0;
29 this.rowTemplatesToAdd = [];
30 this.afterGuiAttachedCallbacks = [];
31 this.eContainer = params.eContainer;
32 this.eViewport = params.eViewport;
33 this.hideWhenNoChildren = params.hideWhenNoChildren;
34 }
35 RowContainerComponent.prototype.setVerticalScrollPosition = function (verticalScrollPosition) {
36 this.scrollTop = verticalScrollPosition;
37 };
38 RowContainerComponent.prototype.postConstruct = function () {
39 this.domOrder = this.gridOptionsWrapper.isEnsureDomOrder();
40 this.checkVisibility();
41 };
42 RowContainerComponent.prototype.getRowElement = function (compId) {
43 return this.eContainer.querySelector("[comp-id=\"" + compId + "\"]");
44 };
45 RowContainerComponent.prototype.setHeight = function (height) {
46 this.eContainer.style.height = height + "px";
47 };
48 RowContainerComponent.prototype.flushRowTemplates = function () {
49 // if doing dom order, then rowTemplates will be empty,
50 // or if no rows added since last time also empty.
51 if (this.rowTemplatesToAdd.length !== 0) {
52 var htmlToAdd = this.rowTemplatesToAdd.join('');
53 utils_1.Utils.appendHtml(this.eContainer, htmlToAdd);
54 this.rowTemplatesToAdd.length = 0;
55 }
56 // this only empty if no rows since last time, as when
57 // doing dom order, we still have callbacks to process
58 this.afterGuiAttachedCallbacks.forEach(function (func) { return func(); });
59 this.afterGuiAttachedCallbacks.length = 0;
60 this.lastPlacedElement = null;
61 };
62 RowContainerComponent.prototype.appendRowTemplate = function (rowTemplate, callback) {
63 if (this.domOrder) {
64 this.lastPlacedElement = utils_1.Utils.insertTemplateWithDomOrder(this.eContainer, rowTemplate, this.lastPlacedElement);
65 }
66 else {
67 this.rowTemplatesToAdd.push(rowTemplate);
68 }
69 this.afterGuiAttachedCallbacks.push(callback);
70 // it is important we put items in in order, so that when we open a row group,
71 // the new rows are inserted after the opened group, but before the rows below.
72 // that way, the rows below are over the new rows (as dom renders last in dom over
73 // items previous in dom), otherwise the child rows would cover the row below and
74 // that meant the user doesn't see the rows below slide away.
75 this.childCount++;
76 this.checkVisibility();
77 };
78 RowContainerComponent.prototype.ensureDomOrder = function (eRow) {
79 if (this.domOrder) {
80 utils_1.Utils.ensureDomOrder(this.eContainer, eRow, this.lastPlacedElement);
81 this.lastPlacedElement = eRow;
82 }
83 };
84 RowContainerComponent.prototype.removeRowElement = function (eRow) {
85 this.eContainer.removeChild(eRow);
86 this.childCount--;
87 this.checkVisibility();
88 };
89 RowContainerComponent.prototype.checkVisibility = function () {
90 if (!this.hideWhenNoChildren) {
91 return;
92 }
93 var eGui = this.eViewport ? this.eViewport : this.eContainer;
94 var visible = this.childCount > 0;
95 if (this.visible !== visible) {
96 this.visible = visible;
97 utils_1.Utils.setVisible(eGui, visible);
98 // if we are showing the viewport, then the scroll is always zero,
99 // so we need to align with the other sections (ie if this is full
100 // width container, and first time showing a full width row, we need to
101 // scroll it so full width rows are show in right place alongside the
102 // body rows). without this, there was an issue with 'loading rows' for
103 // server side row model, as loading rows are full width, and they were
104 // not getting displayed in the right location when rows were expanded.
105 if (visible && this.eViewport) {
106 this.eViewport.scrollTop = this.scrollTop;
107 }
108 }
109 };
110 __decorate([
111 context_1.Autowired('gridOptionsWrapper'),
112 __metadata("design:type", gridOptionsWrapper_1.GridOptionsWrapper)
113 ], RowContainerComponent.prototype, "gridOptionsWrapper", void 0);
114 __decorate([
115 context_1.PostConstruct,
116 __metadata("design:type", Function),
117 __metadata("design:paramtypes", []),
118 __metadata("design:returntype", void 0)
119 ], RowContainerComponent.prototype, "postConstruct", null);
120 return RowContainerComponent;
121}());
122exports.RowContainerComponent = RowContainerComponent;