"));
var eGui = maximizeButtonComp.getGui();
eGui.appendChild(this.maximizeIcon = createIconNoSpan('maximize', this.gridOptionsWrapper));
addCssClass(this.maximizeIcon, 'ag-panel-title-bar-button-icon');
eGui.appendChild(this.minimizeIcon = createIconNoSpan('minimize', this.gridOptionsWrapper));
addCssClass(this.minimizeIcon, 'ag-panel-title-bar-button-icon');
addCssClass(this.minimizeIcon, 'ag-hidden');
maximizeButtonComp.addManagedListener(eGui, 'click', this.toggleMaximize.bind(this));
this.addTitleBarButton(maximizeButtonComp, 0);
this.maximizeListeners.push(this.addManagedListener(eTitleBar, 'dblclick', this.toggleMaximize.bind(this)));
this.resizeListenerDestroy = this.addManagedListener(this, 'resize', function () {
_this.isMaximized = false;
_this.refreshMaximizeIcon();
});
};
__decorate$1E([
Autowired('dragService')
], AgDialog.prototype, "dragService", void 0);
return AgDialog;
}(AgPanel));
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v24.0.0
* @link http://www.ag-grid.com/
* @license MIT
*/
var __extends$1F = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var AgInputTextField = /** @class */ (function (_super) {
__extends$1F(AgInputTextField, _super);
function AgInputTextField(config, className, inputType) {
if (className === void 0) { className = 'ag-text-field'; }
if (inputType === void 0) { inputType = 'text'; }
return _super.call(this, config, className, inputType) || this;
}
AgInputTextField.prototype.postConstruct = function () {
_super.prototype.postConstruct.call(this);
if (this.config.allowedCharPattern) {
this.preventDisallowedCharacters();
}
};
AgInputTextField.prototype.setValue = function (value, silent) {
var ret = _super.prototype.setValue.call(this, value, silent);
if (this.eInput.value !== value) {
this.eInput.value = exists(value) ? value : '';
}
return ret;
};
AgInputTextField.prototype.preventDisallowedCharacters = function () {
var pattern = new RegExp("[" + this.config.allowedCharPattern + "]");
var preventDisallowedCharacters = function (event) {
if (event.key && !pattern.test(event.key)) {
event.preventDefault();
}
};
this.addManagedListener(this.eInput, 'keypress', preventDisallowedCharacters);
this.addManagedListener(this.eInput, 'paste', function (e) {
var text = (e.clipboardData || e.clipboardData).getData('text');
if (some(text, function (c) { return !pattern.test(c); })) {
e.preventDefault();
}
});
};
return AgInputTextField;
}(AgAbstractInputField));
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v24.0.0
* @link http://www.ag-grid.com/
* @license MIT
*/
var __extends$1G = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var AgInputTextArea = /** @class */ (function (_super) {
__extends$1G(AgInputTextArea, _super);
function AgInputTextArea(config) {
return _super.call(this, config, 'ag-text-area', 'textarea') || this;
}
AgInputTextArea.prototype.setValue = function (value, silent) {
var ret = _super.prototype.setValue.call(this, value, silent);
this.eInput.value = value;
return ret;
};
AgInputTextArea.prototype.setCols = function (cols) {
this.eInput.cols = cols;
return this;
};
AgInputTextArea.prototype.setRows = function (rows) {
this.eInput.rows = rows;
return this;
};
return AgInputTextArea;
}(AgAbstractInputField));
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v24.0.0
* @link http://www.ag-grid.com/
* @license MIT
*/
var __extends$1H = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate$1F = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var AgSlider = /** @class */ (function (_super) {
__extends$1H(AgSlider, _super);
function AgSlider(config) {
var _this = _super.call(this, config, AgSlider.TEMPLATE) || this;
_this.labelAlignment = 'top';
return _this;
}
AgSlider.prototype.init = function () {
addCssClass(this.eSlider.getGui(), 'ag-slider-field');
};
AgSlider.prototype.onValueChange = function (callbackFn) {
var _this = this;
var eventChanged = AgAbstractField.EVENT_CHANGED;
this.addManagedListener(this.eText, eventChanged, function () {
var textValue = parseFloat(_this.eText.getValue());
_this.eSlider.setValue(textValue.toString(), true);
callbackFn(textValue || 0);
});
this.addManagedListener(this.eSlider, eventChanged, function () {
var sliderValue = _this.eSlider.getValue();
_this.eText.setValue(sliderValue, true);
callbackFn(parseFloat(sliderValue));
});
return this;
};
AgSlider.prototype.setSliderWidth = function (width) {
this.eSlider.setWidth(width);
return this;
};
AgSlider.prototype.setTextFieldWidth = function (width) {
this.eText.setWidth(width);
return this;
};
AgSlider.prototype.setMinValue = function (minValue) {
this.eSlider.setMinValue(minValue);
this.eText.setMin(minValue);
return this;
};
AgSlider.prototype.setMaxValue = function (maxValue) {
this.eSlider.setMaxValue(maxValue);
this.eText.setMax(maxValue);
return this;
};
AgSlider.prototype.getValue = function () {
return this.eText.getValue();
};
AgSlider.prototype.setValue = function (value) {
if (this.getValue() === value) {
return this;
}
this.eText.setValue(value, true);
this.eSlider.setValue(value, true);
this.dispatchEvent({ type: AgAbstractField.EVENT_CHANGED });
return this;
};
AgSlider.prototype.setStep = function (step) {
this.eSlider.setStep(step);
this.eText.setStep(step);
return this;
};
AgSlider.TEMPLATE = "
";
__decorate$1F([
RefSelector('eLabel')
], AgSlider.prototype, "eLabel", void 0);
__decorate$1F([
RefSelector('eSlider')
], AgSlider.prototype, "eSlider", void 0);
__decorate$1F([
RefSelector('eText')
], AgSlider.prototype, "eText", void 0);
__decorate$1F([
PostConstruct
], AgSlider.prototype, "init", null);
return AgSlider;
}(AgAbstractLabel));
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v24.0.0
* @link http://www.ag-grid.com/
* @license MIT
*/
var __extends$1I = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate$1G = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var AgColorPanel = /** @class */ (function (_super) {
__extends$1I(AgColorPanel, _super);
function AgColorPanel(config) {
var _this = _super.call(this, AgColorPanel.TEMPLATE) || this;
_this.H = 1; // in the [0, 1] range
_this.S = 1; // in the [0, 1] range
_this.B = 1; // in the [0, 1] range
_this.A = 1; // in the [0, 1] range
_this.isSpectrumDragging = false;
_this.isSpectrumHueDragging = false;
_this.isSpectrumAlphaDragging = false;
_this.colorChanged = false;
_this.picker = config.picker;
return _this;
}
AgColorPanel.prototype.postConstruct = function () {
var eGui = this.getGui();
this.initRecentColors();
this.addManagedListener(this.spectrumVal, 'mousedown', this.onSpectrumDraggerDown.bind(this));
this.addManagedListener(eGui, 'mousemove', this.onSpectrumDraggerMove.bind(this));
this.addManagedListener(this.spectrumHue, 'mousedown', this.onSpectrumHueDown.bind(this));
this.addManagedListener(eGui, 'mousemove', this.onSpectrumHueMove.bind(this));
this.addManagedListener(this.spectrumAlpha, 'mousedown', this.onSpectrumAlphaDown.bind(this));
this.addManagedListener(eGui, 'mousemove', this.onSpectrumAlphaMove.bind(this));
// Listening to `mouseup` on the document on purpose. The user might release the mouse button
// outside the UI control. When the mouse returns back to the control's area, the dragging
// of the thumb is not expected and seen as a bug.
this.addManagedListener(document, 'mouseup', this.onMouseUp.bind(this));
this.addManagedListener(this.recentColors, 'click', this.onRecentColorClick.bind(this));
};
AgColorPanel.prototype.refreshSpectrumRect = function () {
return this.spectrumValRect = this.spectrumVal.getBoundingClientRect();
};
AgColorPanel.prototype.refreshHueRect = function () {
return this.spectrumHueRect = this.spectrumHue.getBoundingClientRect();
};
AgColorPanel.prototype.refreshAlphaRect = function () {
return this.spectrumAlphaRect = this.spectrumAlpha.getBoundingClientRect();
};
AgColorPanel.prototype.onSpectrumDraggerDown = function (e) {
this.refreshSpectrumRect();
this.isSpectrumDragging = true;
this.moveDragger(e);
};
AgColorPanel.prototype.onSpectrumDraggerMove = function (e) {
if (this.isSpectrumDragging) {
this.moveDragger(e);
}
};
AgColorPanel.prototype.onSpectrumHueDown = function (e) {
this.refreshHueRect();
this.isSpectrumHueDragging = true;
this.moveHueSlider(e);
};
AgColorPanel.prototype.onSpectrumHueMove = function (e) {
if (this.isSpectrumHueDragging) {
this.moveHueSlider(e);
}
};
AgColorPanel.prototype.onSpectrumAlphaDown = function (e) {
this.refreshAlphaRect();
this.isSpectrumAlphaDragging = true;
this.moveAlphaSlider(e);
};
AgColorPanel.prototype.onSpectrumAlphaMove = function (e) {
if (this.isSpectrumAlphaDragging) {
this.moveAlphaSlider(e);
}
};
AgColorPanel.prototype.onMouseUp = function () {
this.isSpectrumDragging = false;
this.isSpectrumHueDragging = false;
this.isSpectrumAlphaDragging = false;
};
AgColorPanel.prototype.moveDragger = function (e) {
var valRect = this.spectrumValRect;
if (valRect) {
var x = e.clientX - valRect.left;
var y = e.clientY - valRect.top;
x = Math.max(x, 0);
x = Math.min(x, valRect.width);
y = Math.max(y, 0);
y = Math.min(y, valRect.height);
this.setSpectrumValue(x / valRect.width, 1 - y / valRect.height);
}
};
AgColorPanel.prototype.moveHueSlider = function (e) {
var hueRect = this.spectrumHueRect;
if (hueRect) {
var slider = this.spectrumHueSlider;
var sliderRect = slider.getBoundingClientRect();
var x = e.clientX - hueRect.left;
x = Math.max(x, 0);
x = Math.min(x, hueRect.width);
this.H = 1 - x / hueRect.width;
slider.style.left = (x + sliderRect.width / 2) + 'px';
this.update();
}
};
AgColorPanel.prototype.moveAlphaSlider = function (e) {
var alphaRect = this.spectrumAlphaRect;
if (alphaRect) {
var slider = this.spectrumAlphaSlider;
var sliderRect = slider.getBoundingClientRect();
var x = e.clientX - alphaRect.left;
x = Math.max(x, 0);
x = Math.min(x, alphaRect.width);
this.A = x / alphaRect.width;
slider.style.left = (x + sliderRect.width / 2) + 'px';
this.update();
}
};
AgColorPanel.prototype.update = function () {
var color = Color.fromHSB(this.H * 360, this.S, this.B, this.A);
var spectrumColor = Color.fromHSB(this.H * 360, 1, 1);
var rgbaColor = color.toRgbaString();
// the recent color list needs to know color has actually changed
var colorPicker = this.picker;
var existingColor = Color.fromString(colorPicker.getValue());
if (existingColor.toRgbaString() !== rgbaColor) {
this.colorChanged = true;
}
colorPicker.setValue(rgbaColor);
this.spectrumColor.style.backgroundColor = spectrumColor.toRgbaString();
this.spectrumDragger.style.backgroundColor = rgbaColor;
};
/**
* @param saturation In the [0, 1] interval.
* @param brightness In the [0, 1] interval.
*/
AgColorPanel.prototype.setSpectrumValue = function (saturation, brightness) {
var valRect = this.spectrumValRect || this.refreshSpectrumRect();
if (valRect) {
var dragger = this.spectrumDragger;
var draggerRect = dragger.getBoundingClientRect();
saturation = Math.max(0, saturation);
saturation = Math.min(1, saturation);
brightness = Math.max(0, brightness);
brightness = Math.min(1, brightness);
this.S = saturation;
this.B = brightness;
dragger.style.left = (saturation * valRect.width - draggerRect.width / 2) + 'px';
dragger.style.top = ((1 - brightness) * valRect.height - draggerRect.height / 2) + 'px';
this.update();
}
};
AgColorPanel.prototype.initRecentColors = function () {
var recentColors = AgColorPanel.recentColors;
var innerHtml = recentColors.map(function (color, index) {
return "
";
});
this.recentColors.innerHTML = innerHtml.join('');
};
AgColorPanel.prototype.setValue = function (val) {
var color = Color.fromString(val);
var _a = color.toHSB(), h = _a[0], s = _a[1], b = _a[2];
this.H = (isNaN(h) ? 0 : h) / 360;
this.A = color.a;
var spectrumHueRect = this.spectrumHueRect || this.refreshHueRect();
var spectrumAlphaRect = this.spectrumAlphaRect || this.refreshAlphaRect();
this.spectrumHueSlider.style.left = ((this.H - 1) * -spectrumHueRect.width) + "px";
this.spectrumAlphaSlider.style.left = (this.A * spectrumAlphaRect.width) + "px";
this.setSpectrumValue(s, b);
};
AgColorPanel.prototype.onRecentColorClick = function (e) {
var target = e.target;
if (!exists(target.id)) {
return;
}
var id = parseInt(target.id, 10);
this.setValue(AgColorPanel.recentColors[id]);
this.destroy();
};
AgColorPanel.prototype.addRecentColor = function () {
var color = Color.fromHSB(this.H * 360, this.S, this.B, this.A);
var rgbaColor = color.toRgbaString();
var recentColors = AgColorPanel.recentColors;
if (!this.colorChanged || recentColors[0] === rgbaColor) {
return;
}
// remove duplicate color
recentColors = recentColors.filter(function (color) { return color != rgbaColor; });
// add color to head
recentColors = [rgbaColor].concat(recentColors);
// ensure we don't exceed max number of recent colors
if (recentColors.length > AgColorPanel.maxRecentColors) {
recentColors = recentColors.slice(0, AgColorPanel.maxRecentColors);
}
AgColorPanel.recentColors = recentColors;
};
AgColorPanel.prototype.destroy = function () {
this.addRecentColor();
_super.prototype.destroy.call(this);
};
AgColorPanel.maxRecentColors = 8;
AgColorPanel.recentColors = [];
AgColorPanel.TEMPLATE = "
";
__decorate$1G([
RefSelector('spectrumColor')
], AgColorPanel.prototype, "spectrumColor", void 0);
__decorate$1G([
RefSelector('spectrumVal')
], AgColorPanel.prototype, "spectrumVal", void 0);
__decorate$1G([
RefSelector('spectrumDragger')
], AgColorPanel.prototype, "spectrumDragger", void 0);
__decorate$1G([
RefSelector('spectrumHue')
], AgColorPanel.prototype, "spectrumHue", void 0);
__decorate$1G([
RefSelector('spectrumHueSlider')
], AgColorPanel.prototype, "spectrumHueSlider", void 0);
__decorate$1G([
RefSelector('spectrumAlpha')
], AgColorPanel.prototype, "spectrumAlpha", void 0);
__decorate$1G([
RefSelector('spectrumAlphaSlider')
], AgColorPanel.prototype, "spectrumAlphaSlider", void 0);
__decorate$1G([
RefSelector('recentColors')
], AgColorPanel.prototype, "recentColors", void 0);
__decorate$1G([
PostConstruct
], AgColorPanel.prototype, "postConstruct", null);
return AgColorPanel;
}(Component));
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v24.0.0
* @link http://www.ag-grid.com/
* @license MIT
*/
var __extends$1J = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate$1H = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var AgPickerField = /** @class */ (function (_super) {
__extends$1J(AgPickerField, _super);
function AgPickerField(config, className, pickerIcon, popupRole) {
var _this = _super.call(this, config, /* html */ "
", className) || this;
_this.pickerIcon = pickerIcon;
_this.isPickerDisplayed = false;
_this.isDestroyingPicker = false;
_this.skipClick = false;
return _this;
}
AgPickerField.prototype.postConstruct = function () {
var _this = this;
_super.prototype.postConstruct.call(this);
var displayId = this.getCompId() + "-display";
this.eDisplayField.setAttribute('id', displayId);
setAriaDescribedBy(this.eWrapper, displayId);
var clickHandler = function () {
if (_this.skipClick) {
_this.skipClick = false;
return;
}
if (_this.isDisabled()) {
return;
}
_this.pickerComponent = _this.showPicker();
};
var eGui = this.getGui();
this.addManagedListener(eGui, 'mousedown', function (e) {
if (!_this.skipClick &&
_this.pickerComponent &&
_this.pickerComponent.isAlive() &&
isVisible(_this.pickerComponent.getGui()) &&
eGui.contains(e.target)) {
_this.skipClick = true;
}
});
this.addManagedListener(eGui, 'keydown', function (e) {
switch (e.keyCode) {
case KeyCode.UP:
case KeyCode.DOWN:
case KeyCode.ENTER:
case KeyCode.SPACE:
clickHandler();
case KeyCode.ESCAPE:
if (_this.isPickerDisplayed) {
e.preventDefault();
}
break;
}
});
this.addManagedListener(this.eWrapper, 'click', clickHandler);
this.addManagedListener(this.eLabel, 'click', clickHandler);
if (this.pickerIcon) {
this.eIcon.appendChild(createIconNoSpan(this.pickerIcon, this.gridOptionsWrapper));
}
};
AgPickerField.prototype.refreshLabel = function () {
if (exists(this.getLabel())) {
setAriaLabelledBy(this.eWrapper, this.getLabelId());
}
else {
this.eWrapper.removeAttribute('aria-labelledby');
}
_super.prototype.refreshLabel.call(this);
};
AgPickerField.prototype.setAriaLabel = function (label) {
setAriaLabel(this.eWrapper, label);
return this;
};
AgPickerField.prototype.setInputWidth = function (width) {
setElementWidth(this.eWrapper, width);
return this;
};
AgPickerField.prototype.getFocusableElement = function () {
return this.eWrapper;
};
__decorate$1H([
Autowired('gridOptionsWrapper')
], AgPickerField.prototype, "gridOptionsWrapper", void 0);
__decorate$1H([
RefSelector('eLabel')
], AgPickerField.prototype, "eLabel", void 0);
__decorate$1H([
RefSelector('eWrapper')
], AgPickerField.prototype, "eWrapper", void 0);
__decorate$1H([
RefSelector('eDisplayField')
], AgPickerField.prototype, "eDisplayField", void 0);
__decorate$1H([
RefSelector('eIcon')
], AgPickerField.prototype, "eIcon", void 0);
return AgPickerField;
}(AgAbstractField));
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v24.0.0
* @link http://www.ag-grid.com/
* @license MIT
*/
var __extends$1K = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var AgColorPicker = /** @class */ (function (_super) {
__extends$1K(AgColorPicker, _super);
function AgColorPicker(config) {
var _this = _super.call(this, config, 'ag-color-picker', 'colorPicker') || this;
if (config && config.color) {
_this.value = config.color;
}
return _this;
}
AgColorPicker.prototype.postConstruct = function () {
_super.prototype.postConstruct.call(this);
if (this.value) {
this.setValue(this.value);
}
};
AgColorPicker.prototype.showPicker = function () {
var _this = this;
var eGuiRect = this.getGui().getBoundingClientRect();
var colorDialog = this.createBean(new AgDialog({
closable: false,
modal: true,
hideTitleBar: true,
minWidth: 190,
width: 190,
height: 250,
x: eGuiRect.right - 190,
y: eGuiRect.top - 250
}));
this.isPickerDisplayed = true;
addCssClass(colorDialog.getGui(), 'ag-color-dialog');
var colorPanel = this.createBean(new AgColorPanel({ picker: this }));
colorPanel.addDestroyFunc(function () {
if (colorDialog.isAlive()) {
_this.destroyBean(colorDialog);
}
});
colorDialog.setParentComponent(this);
colorDialog.setBodyComponent(colorPanel);
colorPanel.setValue(this.getValue());
colorDialog.addDestroyFunc(function () {
// here we check if the picker was already being
// destroyed to avoid a stack overflow
if (!_this.isDestroyingPicker) {
_this.isDestroyingPicker = true;
if (colorPanel.isAlive()) {
_this.destroyBean(colorPanel);
}
}
else {
_this.isDestroyingPicker = false;
}
if (_this.isAlive()) {
_this.getFocusableElement().focus();
}
_this.isPickerDisplayed = false;
});
return colorDialog;
};
AgColorPicker.prototype.setValue = function (color) {
if (this.value === color) {
return this;
}
this.value = color;
this.eDisplayField.style.backgroundColor = color;
this.dispatchEvent({ type: AgAbstractField.EVENT_CHANGED });
return this;
};
AgColorPicker.prototype.getValue = function () {
return this.value;
};
return AgColorPicker;
}(AgPickerField));
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v24.0.0
* @link http://www.ag-grid.com/
* @license MIT
*/
var __extends$1L = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var AgInputNumberField = /** @class */ (function (_super) {
__extends$1L(AgInputNumberField, _super);
function AgInputNumberField(config) {
return _super.call(this, config, 'ag-number-field', 'number') || this;
}
AgInputNumberField.prototype.postConstruct = function () {
var _this = this;
_super.prototype.postConstruct.call(this);
this.addManagedListener(this.eInput, 'blur', function () {
var floatedValue = parseFloat(_this.eInput.value);
var value = isNaN(floatedValue) ? '' : _this.normalizeValue(floatedValue.toString());
if (_this.value !== value) {
_this.setValue(value);
}
});
};
AgInputNumberField.prototype.normalizeValue = function (value) {
if (value === '') {
return '';
}
if (this.precision) {
value = this.adjustPrecision(value);
}
var val = parseFloat(value);
if (this.min != null && val < this.min) {
value = this.min.toString();
}
else if (this.max != null && val > this.max) {
value = this.max.toString();
}
return value;
};
AgInputNumberField.prototype.adjustPrecision = function (value) {
if (this.precision) {
var floatString = parseFloat(value).toFixed(this.precision);
value = parseFloat(floatString).toString();
}
return value;
};
AgInputNumberField.prototype.setMin = function (min) {
if (this.min === min) {
return this;
}
this.min = min;
addOrRemoveAttribute(this.eInput, 'min', min);
return this;
};
AgInputNumberField.prototype.setMax = function (max) {
if (this.max === max) {
return this;
}
this.max = max;
addOrRemoveAttribute(this.eInput, 'max', max);
return this;
};
AgInputNumberField.prototype.setPrecision = function (precision) {
this.precision = precision;
return this;
};
AgInputNumberField.prototype.setStep = function (step) {
if (this.step === step) {
return this;
}
this.step = step;
addOrRemoveAttribute(this.eInput, 'step', step);
return this;
};
AgInputNumberField.prototype.setValue = function (value, silent) {
value = this.adjustPrecision(value);
var normalizedValue = this.normalizeValue(value);
if (value != normalizedValue) {
return this;
}
return _super.prototype.setValue.call(this, value, silent);
};
return AgInputNumberField;
}(AgInputTextField));
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v24.0.0
* @link http://www.ag-grid.com/
* @license MIT
*/
var __extends$1M = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var AgInputRange = /** @class */ (function (_super) {
__extends$1M(AgInputRange, _super);
function AgInputRange(config) {
return _super.call(this, config, 'ag-range-field', 'range') || this;
}
AgInputRange.prototype.postConstruct = function () {
_super.prototype.postConstruct.call(this);
var _a = this.config, min = _a.min, max = _a.max, step = _a.step;
if (min != null) {
this.setMinValue(min);
}
if (max != null) {
this.setMaxValue(max);
}
this.setStep(step || 1);
};
AgInputRange.prototype.addInputListeners = function () {
var _this = this;
var isIE = isBrowserIE();
var eventName = isIE ? 'change' : 'input';
this.addManagedListener(this.eInput, eventName, function (e) {
var value = e.target.value;
_this.setValue(value);
});
};
AgInputRange.prototype.setMinValue = function (value) {
this.min = value;
this.eInput.setAttribute('min', value.toString());
return this;
};
AgInputRange.prototype.setMaxValue = function (value) {
this.max = value;
this.eInput.setAttribute('max', value.toString());
return this;
};
AgInputRange.prototype.setStep = function (value) {
this.eInput.setAttribute('step', value.toString());
return this;
};
AgInputRange.prototype.setValue = function (value, silent) {
if (this.min != null) {
value = Math.max(parseFloat(value), this.min).toString();
}
if (this.max != null) {
value = Math.min(parseFloat(value), this.max).toString();
}
var ret = _super.prototype.setValue.call(this, value, silent);
this.eInput.value = value;
return ret;
};
return AgInputRange;
}(AgAbstractInputField));
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v24.0.0
* @link http://www.ag-grid.com/
* @license MIT
*/
var __extends$1N = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate$1I = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var AgList = /** @class */ (function (_super) {
__extends$1N(AgList, _super);
function AgList(cssIdentifier) {
if (cssIdentifier === void 0) { cssIdentifier = 'default'; }
var _this = _super.call(this, /* html */ "
") || this;
_this.cssIdentifier = cssIdentifier;
_this.options = [];
_this.itemEls = [];
return _this;
}
AgList.prototype.init = function () {
this.addManagedListener(this.getGui(), 'keydown', this.handleKeyDown.bind(this));
};
AgList.prototype.handleKeyDown = function (e) {
var key = e.keyCode;
switch (key) {
case KeyCode.ENTER:
if (!this.highlightedEl) {
this.setValue(this.getValue());
}
else {
var pos = this.itemEls.indexOf(this.highlightedEl);
this.setValueByIndex(pos);
}
break;
case KeyCode.DOWN:
case KeyCode.UP:
var isDown = key === KeyCode.DOWN;
var itemToHighlight = void 0;
e.preventDefault();
if (!this.highlightedEl) {
itemToHighlight = this.itemEls[isDown ? 0 : this.itemEls.length - 1];
}
else {
var currentIdx = this.itemEls.indexOf(this.highlightedEl);
var nextPos = currentIdx + (isDown ? 1 : -1);
nextPos = Math.min(Math.max(nextPos, 0), this.itemEls.length - 1);
itemToHighlight = this.itemEls[nextPos];
}
this.highlightItem(itemToHighlight);
break;
}
};
AgList.prototype.addOptions = function (listOptions) {
var _this = this;
listOptions.forEach(function (listOption) { return _this.addOption(listOption); });
return this;
};
AgList.prototype.addOption = function (listOption) {
var value = listOption.value, text = listOption.text;
var sanitisedText = escapeString(text || value);
this.options.push({ value: value, text: sanitisedText });
this.renderOption(value, sanitisedText);
return this;
};
AgList.prototype.renderOption = function (value, text) {
var _this = this;
var itemEl = document.createElement('div');
itemEl.setAttribute('role', 'option');
addCssClass(itemEl, 'ag-list-item');
addCssClass(itemEl, "ag-" + this.cssIdentifier + "-list-item");
itemEl.innerHTML = text;
itemEl.tabIndex = -1;
this.itemEls.push(itemEl);
this.addManagedListener(itemEl, 'mouseover', function () { return _this.highlightItem(itemEl); });
this.addManagedListener(itemEl, 'mouseleave', function () { return _this.clearHighlighted(); });
this.addManagedListener(itemEl, 'click', function () { return _this.setValue(value); });
this.getGui().appendChild(itemEl);
};
AgList.prototype.setValue = function (value, silent) {
if (this.value === value) {
this.fireItemSelected();
return this;
}
if (value == null) {
this.reset();
return this;
}
var idx = findIndex(this.options, function (option) { return option.value === value; });
if (idx !== -1) {
var option = this.options[idx];
this.value = option.value;
this.displayValue = option.text != null ? option.text : option.value;
this.highlightItem(this.itemEls[idx]);
if (!silent) {
this.fireChangeEvent();
}
}
return this;
};
AgList.prototype.setValueByIndex = function (idx) {
return this.setValue(this.options[idx].value);
};
AgList.prototype.getValue = function () {
return this.value;
};
AgList.prototype.getDisplayValue = function () {
return this.displayValue;
};
AgList.prototype.refreshHighlighted = function () {
var _this = this;
this.clearHighlighted();
var idx = findIndex(this.options, function (option) { return option.value === _this.value; });
if (idx !== -1) {
this.highlightItem(this.itemEls[idx]);
}
};
AgList.prototype.reset = function () {
this.value = null;
this.displayValue = null;
this.clearHighlighted();
this.fireChangeEvent();
};
AgList.prototype.highlightItem = function (el) {
if (!el.offsetParent) {
return;
}
this.clearHighlighted();
this.highlightedEl = el;
addCssClass(this.highlightedEl, AgList.ACTIVE_CLASS);
setAriaSelected(this.highlightedEl, true);
this.highlightedEl.focus();
};
AgList.prototype.clearHighlighted = function () {
if (!this.highlightedEl || !this.highlightedEl.offsetParent) {
return;
}
removeCssClass(this.highlightedEl, AgList.ACTIVE_CLASS);
setAriaSelected(this.highlightedEl, false);
this.highlightedEl = null;
};
AgList.prototype.fireChangeEvent = function () {
this.dispatchEvent({ type: AgAbstractField.EVENT_CHANGED });
this.fireItemSelected();
};
AgList.prototype.fireItemSelected = function () {
this.dispatchEvent({ type: AgList.EVENT_ITEM_SELECTED });
};
AgList.EVENT_ITEM_SELECTED = 'selectedItem';
AgList.ACTIVE_CLASS = 'ag-active-item';
__decorate$1I([
PostConstruct
], AgList.prototype, "init", null);
return AgList;
}(Component));
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v24.0.0
* @link http://www.ag-grid.com/
* @license MIT
*/
var __extends$1O = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate$1J = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var AgSelect = /** @class */ (function (_super) {
__extends$1O(AgSelect, _super);
function AgSelect(config) {
return _super.call(this, config, 'ag-select', 'smallDown', 'listbox') || this;
}
AgSelect.prototype.init = function () {
var _this = this;
this.listComponent = this.createBean(new AgList('select'));
this.listComponent.setParentComponent(this);
this.eWrapper.tabIndex = 0;
this.listComponent.addManagedListener(this.listComponent, AgList.EVENT_ITEM_SELECTED, function () { if (_this.hideList) {
_this.hideList();
} });
this.listComponent.addManagedListener(this.listComponent, AgAbstractField.EVENT_CHANGED, function () {
_this.setValue(_this.listComponent.getValue(), false, true);
if (_this.hideList) {
_this.hideList();
}
});
};
AgSelect.prototype.showPicker = function () {
var _this = this;
var listGui = this.listComponent.getGui();
var destroyMouseWheelFunc = this.addManagedListener(document.body, 'wheel', function (e) {
if (!listGui.contains(e.target) && _this.hideList) {
_this.hideList();
}
});
var destroyFocusOutFunc = this.addManagedListener(listGui, 'focusout', function (e) {
if (!listGui.contains(e.relatedTarget) && _this.hideList) {
_this.hideList();
}
});
this.hideList = this.popupService.addPopup({
modal: true,
eChild: listGui,
closeOnEsc: true,
closedCallback: function () {
_this.hideList = null;
_this.isPickerDisplayed = false;
destroyFocusOutFunc();
destroyMouseWheelFunc();
if (_this.isAlive()) {
_this.getFocusableElement().focus();
}
}
});
this.isPickerDisplayed = true;
setElementWidth(listGui, getAbsoluteWidth(this.eWrapper));
listGui.style.maxHeight = getInnerHeight(this.popupService.getPopupParent()) + 'px';
listGui.style.position = 'absolute';
this.popupService.positionPopupUnderComponent({
type: 'ag-list',
eventSource: this.eWrapper,
ePopup: listGui,
keepWithinBounds: true
});
this.listComponent.refreshHighlighted();
return this.listComponent;
};
AgSelect.prototype.addOptions = function (options) {
var _this = this;
options.forEach(function (option) { return _this.addOption(option); });
return this;
};
AgSelect.prototype.addOption = function (option) {
this.listComponent.addOption(option);
return this;
};
AgSelect.prototype.setValue = function (value, silent, fromPicker) {
if (this.value === value) {
return this;
}
if (!fromPicker) {
this.listComponent.setValue(value, true);
}
var newValue = this.listComponent.getValue();
if (newValue === this.getValue()) {
return this;
}
this.eDisplayField.innerHTML = this.listComponent.getDisplayValue();
return _super.prototype.setValue.call(this, value, silent);
};
AgSelect.prototype.destroy = function () {
if (this.hideList) {
this.hideList();
}
this.destroyBean(this.listComponent);
_super.prototype.destroy.call(this);
};
__decorate$1J([
Autowired('popupService')
], AgSelect.prototype, "popupService", void 0);
__decorate$1J([
PostConstruct
], AgSelect.prototype, "init", null);
return AgSelect;
}(AgPickerField));
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v24.0.0
* @link http://www.ag-grid.com/
* @license MIT
*/
var __extends$1P = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate$1K = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var AgAngleSelect = /** @class */ (function (_super) {
__extends$1P(AgAngleSelect, _super);
function AgAngleSelect(config) {
var _this = _super.call(this, config, AgAngleSelect.TEMPLATE) || this;
_this.radius = 0;
_this.offsetX = 0;
_this.offsetY = 0;
return _this;
}
AgAngleSelect.prototype.postConstruct = function () {
var _this = this;
_super.prototype.postConstruct.call(this);
this.dragListener = {
eElement: this.eParentCircle,
dragStartPixels: 0,
onDragStart: function (e) {
_this.parentCircleRect = _this.eParentCircle.getBoundingClientRect();
},
onDragging: function (e) { return _this.calculateAngleDrag(e); },
onDragStop: function () { }
};
this.dragService.addDragSource(this.dragListener);
this.eAngleValue
.setLabel('')
.setLabelWidth(5)
.setInputWidth(45)
.setMin(0)
.setMax(360)
.setValue("" + this.degrees)
.onValueChange(function (value) {
if (value == null || value === '') {
value = '0';
}
value = _this.eAngleValue.normalizeValue(value);
var floatValue = parseFloat(value);
if (floatValue > 180) {
floatValue = floatValue - 360;
}
_this.setValue(floatValue);
});
this.updateNumberInput();
if (exists(this.getValue())) {
this.eAngleValue.setValue(this.normalizeNegativeValue(this.getValue()).toString());
}
this.addManagedListener(this, AgAbstractField.EVENT_CHANGED, function () {
if (_this.eAngleValue.getInputElement().contains(document.activeElement)) {
return;
}
_this.updateNumberInput();
});
};
AgAngleSelect.prototype.updateNumberInput = function () {
var normalizedValue = this.normalizeNegativeValue(this.getValue());
this.eAngleValue.setValue(normalizedValue.toString());
};
AgAngleSelect.prototype.positionChildCircle = function (radians) {
var rect = this.parentCircleRect || { width: 24, height: 24 };
var eChildCircle = this.eChildCircle;
var centerX = rect.width / 2;
var centerY = rect.height / 2;
eChildCircle.style.left = centerX + Math.cos(radians) * 8 + "px";
eChildCircle.style.top = centerY + Math.sin(radians) * 8 + "px";
};
AgAngleSelect.prototype.calculatePolar = function () {
var x = this.offsetX;
var y = this.offsetY;
var radians = Math.atan2(y, x);
this.degrees = this.toDegrees(radians);
this.radius = Math.sqrt((x * x) + (y * y));
this.positionChildCircle(radians);
};
AgAngleSelect.prototype.calculateCartesian = function () {
var radians = this.toRadians(this.getValue());
var radius = this.getRadius();
this
.setOffsetX(Math.cos(radians) * radius)
.setOffsetY(Math.sin(radians) * radius);
};
AgAngleSelect.prototype.setOffsetX = function (offset) {
if (this.offsetX !== offset) {
this.offsetX = offset;
this.calculatePolar();
}
return this;
};
AgAngleSelect.prototype.setOffsetY = function (offset) {
if (this.offsetY !== offset) {
this.offsetY = offset;
this.calculatePolar();
}
return this;
};
AgAngleSelect.prototype.calculateAngleDrag = function (e) {
var rect = this.parentCircleRect;
var centerX = rect.width / 2;
var centerY = rect.height / 2;
var x = e.clientX - rect.left;
var y = e.clientY - rect.top;
var dx = x - centerX;
var dy = y - centerY;
var radians = Math.atan2(dy, dx);
this.setValue(radians, true);
};
AgAngleSelect.prototype.toDegrees = function (radians) {
return radians / Math.PI * 180;
};
AgAngleSelect.prototype.toRadians = function (degrees) {
return degrees / 180 * Math.PI;
};
AgAngleSelect.prototype.normalizeNegativeValue = function (degrees) {
return degrees < 0 ? 360 + degrees : degrees;
};
AgAngleSelect.prototype.normalizeAngle180 = function (radians) {
radians %= Math.PI * 2;
if (radians < -Math.PI) {
radians += Math.PI * 2;
}
else if (radians >= Math.PI) {
radians -= Math.PI * 2;
}
return radians;
};
AgAngleSelect.prototype.getRadius = function () {
return this.radius;
};
AgAngleSelect.prototype.setRadius = function (r) {
if (this.radius === r) {
return this;
}
this.radius = r;
this.calculateCartesian();
return this;
};
AgAngleSelect.prototype.onValueChange = function (callbackFn) {
var _this = this;
this.addManagedListener(this, AgAbstractField.EVENT_CHANGED, function () {
callbackFn(_this.degrees);
});
return this;
};
AgAngleSelect.prototype.getValue = function (radians) {
return radians ? this.toRadians(this.degrees) : this.degrees;
};
AgAngleSelect.prototype.setValue = function (degrees, radians) {
var radiansValue;
if (!radians) {
radiansValue = this.normalizeAngle180(this.toRadians(degrees));
}
else {
radiansValue = degrees;
}
degrees = this.toDegrees(radiansValue);
if (this.degrees !== degrees) {
this.degrees = Math.floor(degrees);
this.calculateCartesian();
this.positionChildCircle(radiansValue);
this.dispatchEvent({ type: AgAbstractField.EVENT_CHANGED });
}
return this;
};
AgAngleSelect.prototype.setWidth = function (width) {
setFixedWidth(this.getGui(), width);
return this;
};
AgAngleSelect.prototype.destroy = function () {
this.dragService.removeDragSource(this.dragListener);
_super.prototype.destroy.call(this);
};
AgAngleSelect.TEMPLATE = "
";
__decorate$1K([
RefSelector('eLabel')
], AgAngleSelect.prototype, "eLabel", void 0);
__decorate$1K([
RefSelector('eParentCircle')
], AgAngleSelect.prototype, "eParentCircle", void 0);
__decorate$1K([
RefSelector('eChildCircle')
], AgAngleSelect.prototype, "eChildCircle", void 0);
__decorate$1K([
RefSelector('eAngleValue')
], AgAngleSelect.prototype, "eAngleValue", void 0);
__decorate$1K([
Autowired('dragService')
], AgAngleSelect.prototype, "dragService", void 0);
return AgAngleSelect;
}(AgAbstractLabel));
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v24.0.0
* @link http://www.ag-grid.com/
* @license MIT
*/
var __extends$1Q = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var AgToggleButton = /** @class */ (function (_super) {
__extends$1Q(AgToggleButton, _super);
function AgToggleButton(config) {
return _super.call(this, config, 'ag-toggle-button') || this;
}
AgToggleButton.prototype.setValue = function (value, silent) {
_super.prototype.setValue.call(this, value, silent);
addOrRemoveCssClass(this.getGui(), 'ag-selected', this.getValue());
return this;
};
return AgToggleButton;
}(AgCheckbox));
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v24.0.0
* @link http://www.ag-grid.com/
* @license MIT
*/
var __extends$1R = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate$1L = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
/**
* For Master Detail, it is required to keep components between expanding & collapsing parents.
* For example a user expands row A (and shows a detail grid for this row), then when row A
* is closed, we want to keep the detail grid, so next time row A is expanded the detail grid
* is showed with it's context intact, eg if user sorted in the detail grid, that sort should
* still be applied after the detail grid is shown for the second time.
*/
var DetailRowCompCache = /** @class */ (function (_super) {
__extends$1R(DetailRowCompCache, _super);
function DetailRowCompCache() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.cacheItems = [];
return _this;
}
DetailRowCompCache.prototype.postConstruct = function () {
this.active = this.gridOptionsWrapper.isKeepDetailRows();
this.maxCacheSize = this.gridOptionsWrapper.getKeepDetailRowsCount();
};
DetailRowCompCache.prototype.addOrDestroy = function (rowNode, pinned, comp) {
// only accept detail rows
var doNotUseCache = !this.active || !rowNode.detail;
if (doNotUseCache) {
this.destroyFullWidthRow(comp);
return;
}
var item = this.getCacheItem(rowNode, true);
// put the comp in the right location of the item.
// we also destroy any previous comp - this should never happen
// as the logic outside of this class shouldn't be adding same item to the
// cache twice, however we cater for it in case in future releases code
// outside of this class is changed and this could happen.
switch (pinned) {
case Constants.PINNED_LEFT:
this.destroyFullWidthRow(item.left);
item.left = comp;
break;
case Constants.PINNED_RIGHT:
this.destroyFullWidthRow(item.right);
item.right = comp;
break;
default:
this.destroyFullWidthRow(item.center);
item.center = comp;
break;
}
this.cacheItems.sort(function (a, b) {
return b.lastAccessedTime - a.lastAccessedTime;
});
this.purgeCache(this.maxCacheSize);
};
DetailRowCompCache.prototype.getCacheItem = function (rowNode, autoCreate) {
if (autoCreate === void 0) { autoCreate = false; }
var res;
for (var i = 0; i < this.cacheItems.length; i++) {
var item = this.cacheItems[i];
if (item.rowNode === rowNode) {
res = item;
break;
}
}
if (!res && autoCreate) {
res = {
rowNode: rowNode
};
this.cacheItems.push(res);
}
if (res) {
this.stampCacheItem(res);
}
return res;
};
DetailRowCompCache.prototype.stampCacheItem = function (item) {
item.lastAccessedTime = new Date().getTime();
};
DetailRowCompCache.prototype.destroyFullWidthRow = function (comp) {
this.getContext().destroyBean(comp);
};
DetailRowCompCache.prototype.purgeCache = function (startIndex) {
// delete all rows past the index of interest
for (var i = startIndex; i < this.cacheItems.length; i++) {
var item = this.cacheItems[i];
this.destroyFullWidthRow(item.center);
this.destroyFullWidthRow(item.left);
this.destroyFullWidthRow(item.right);
}
// change the length of the array so it no longer contains the deleted items
if (this.cacheItems.length > startIndex) {
this.cacheItems.length = startIndex;
}
};
DetailRowCompCache.prototype.get = function (rowNode, pinned) {
if (!rowNode.detail) {
return undefined;
}
var item = this.getCacheItem(rowNode);
var res;
if (item) {
switch (pinned) {
case Constants.PINNED_LEFT:
if (item.left) {
res = item.left;
item.left = undefined;
}
break;
case Constants.PINNED_RIGHT:
if (item.right) {
res = item.right;
item.right = undefined;
}
break;
default:
if (item.center) {
res = item.center;
item.center = undefined;
}
break;
}
}
return res;
};
DetailRowCompCache.prototype.destroy = function () {
_super.prototype.destroy.call(this);
this.purgeCache(0);
};
__decorate$1L([
Autowired('gridOptionsWrapper')
], DetailRowCompCache.prototype, "gridOptionsWrapper", void 0);
__decorate$1L([
PostConstruct
], DetailRowCompCache.prototype, "postConstruct", null);
__decorate$1L([
PreDestroy
], DetailRowCompCache.prototype, "destroy", null);
DetailRowCompCache = __decorate$1L([
Bean('detailRowCompCache')
], DetailRowCompCache);
return DetailRowCompCache;
}(BeanStub));
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v24.0.0
* @link http://www.ag-grid.com/
* @license MIT
*/
var __extends$1S = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate$1M = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var RowPositionUtils = /** @class */ (function (_super) {
__extends$1S(RowPositionUtils, _super);
function RowPositionUtils() {
return _super !== null && _super.apply(this, arguments) || this;
}
RowPositionUtils.prototype.getFirstRow = function () {
var rowIndex = 0;
var rowPinned;
if (this.pinnedRowModel.getPinnedTopRowCount()) {
rowPinned = Constants.PINNED_TOP;
}
else if (this.rowModel.getRowCount()) {
rowPinned = null;
rowIndex = this.paginationProxy.getPageFirstRow();
}
else if (this.pinnedRowModel.getPinnedBottomRowCount()) {
rowPinned = Constants.PINNED_BOTTOM;
}
return rowPinned === undefined ? null : { rowIndex: rowIndex, rowPinned: rowPinned };
};
RowPositionUtils.prototype.getLastRow = function () {
var rowIndex;
var rowPinned;
var pinnedBottomCount = this.pinnedRowModel.getPinnedBottomRowCount();
var pinnedTopCount = this.pinnedRowModel.getPinnedTopRowCount();
if (pinnedBottomCount) {
rowPinned = Constants.PINNED_BOTTOM;
rowIndex = pinnedBottomCount - 1;
}
else if (this.rowModel.getRowCount()) {
rowPinned = null;
rowIndex = this.paginationProxy.getPageLastRow();
}
else if (pinnedTopCount) {
rowPinned = Constants.PINNED_TOP;
rowIndex = pinnedTopCount - 1;
}
return rowIndex === undefined ? null : { rowIndex: rowIndex, rowPinned: rowPinned };
};
RowPositionUtils.prototype.getRowNode = function (gridRow) {
switch (gridRow.rowPinned) {
case Constants.PINNED_TOP:
return this.pinnedRowModel.getPinnedTopRowData()[gridRow.rowIndex];
case Constants.PINNED_BOTTOM:
return this.pinnedRowModel.getPinnedBottomRowData()[gridRow.rowIndex];
default:
return this.rowModel.getRow(gridRow.rowIndex);
}
};
RowPositionUtils.prototype.sameRow = function (rowA, rowB) {
// if both missing
if (!rowA && !rowB) {
return true;
}
// if only one missing
if ((rowA && !rowB) || (!rowA && rowB)) {
return false;
}
// otherwise compare (use == to compare rowPinned because it can be null or undefined)
return rowA.rowIndex === rowB.rowIndex && rowA.rowPinned == rowB.rowPinned;
};
// tests if this row selection is before the other row selection
RowPositionUtils.prototype.before = function (rowA, rowB) {
switch (rowA.rowPinned) {
case Constants.PINNED_TOP:
// we we are floating top, and other isn't, then we are always before
if (rowB.rowPinned !== Constants.PINNED_TOP) {
return true;
}
break;
case Constants.PINNED_BOTTOM:
// if we are floating bottom, and the other isn't, then we are never before
if (rowB.rowPinned !== Constants.PINNED_BOTTOM) {
return false;
}
break;
default:
// if we are not floating, but the other one is floating...
if (exists(rowB.rowPinned)) {
return rowB.rowPinned !== Constants.PINNED_TOP;
}
break;
}
return rowA.rowIndex < rowB.rowIndex;
};
__decorate$1M([
Autowired('rowModel')
], RowPositionUtils.prototype, "rowModel", void 0);
__decorate$1M([
Autowired('pinnedRowModel')
], RowPositionUtils.prototype, "pinnedRowModel", void 0);
__decorate$1M([
Autowired('paginationProxy')
], RowPositionUtils.prototype, "paginationProxy", void 0);
RowPositionUtils = __decorate$1M([
Bean('rowPositionUtils')
], RowPositionUtils);
return RowPositionUtils;
}(BeanStub));
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v24.0.0
* @link http://www.ag-grid.com/
* @license MIT
*/
var __extends$1T = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate$1N = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var CellPositionUtils = /** @class */ (function (_super) {
__extends$1T(CellPositionUtils, _super);
function CellPositionUtils() {
return _super !== null && _super.apply(this, arguments) || this;
}
CellPositionUtils.prototype.createId = function (cellPosition) {
var rowIndex = cellPosition.rowIndex, rowPinned = cellPosition.rowPinned, column = cellPosition.column;
return this.createIdFromValues(rowIndex, column, rowPinned);
};
CellPositionUtils.prototype.createIdFromValues = function (rowIndex, column, rowPinned) {
return rowIndex + "." + (rowPinned == null ? 'null' : rowPinned) + "." + column.getId();
};
CellPositionUtils.prototype.equals = function (cellA, cellB) {
var colsMatch = cellA.column === cellB.column;
var floatingMatch = cellA.rowPinned === cellB.rowPinned;
var indexMatch = cellA.rowIndex === cellB.rowIndex;
return colsMatch && floatingMatch && indexMatch;
};
CellPositionUtils = __decorate$1N([
Bean('cellPositionUtils')
], CellPositionUtils);
return CellPositionUtils;
}(BeanStub));
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v24.0.0
* @link http://www.ag-grid.com/
* @license MIT
*/
var __extends$1U = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate$1O = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var PinnedRowModel = /** @class */ (function (_super) {
__extends$1U(PinnedRowModel, _super);
function PinnedRowModel() {
return _super !== null && _super.apply(this, arguments) || this;
}
PinnedRowModel.prototype.init = function () {
this.setPinnedTopRowData(this.gridOptionsWrapper.getPinnedTopRowData());
this.setPinnedBottomRowData(this.gridOptionsWrapper.getPinnedBottomRowData());
};
PinnedRowModel.prototype.isEmpty = function (floating) {
var rows = floating === Constants.PINNED_TOP ? this.pinnedTopRows : this.pinnedBottomRows;
return missingOrEmpty(rows);
};
PinnedRowModel.prototype.isRowsToRender = function (floating) {
return !this.isEmpty(floating);
};
PinnedRowModel.prototype.getRowAtPixel = function (pixel, floating) {
var rows = floating === Constants.PINNED_TOP ? this.pinnedTopRows : this.pinnedBottomRows;
if (missingOrEmpty(rows)) {
return 0; // this should never happen, just in case, 0 is graceful failure
}
for (var i = 0; i < rows.length; i++) {
var rowNode = rows[i];
var rowTopPixel = rowNode.rowTop + rowNode.rowHeight - 1;
// only need to range check against the top pixel, as we are going through the list
// in order, first row to hit the pixel wins
if (rowTopPixel >= pixel) {
return i;
}
}
return rows.length - 1;
};
PinnedRowModel.prototype.setPinnedTopRowData = function (rowData) {
this.pinnedTopRows = this.createNodesFromData(rowData, true);
var event = {
type: Events.EVENT_PINNED_ROW_DATA_CHANGED,
api: this.gridApi,
columnApi: this.columnApi
};
this.eventService.dispatchEvent(event);
};
PinnedRowModel.prototype.setPinnedBottomRowData = function (rowData) {
this.pinnedBottomRows = this.createNodesFromData(rowData, false);
var event = {
type: Events.EVENT_PINNED_ROW_DATA_CHANGED,
api: this.gridApi,
columnApi: this.columnApi
};
this.eventService.dispatchEvent(event);
};
PinnedRowModel.prototype.createNodesFromData = function (allData, isTop) {
var _this = this;
var rowNodes = [];
if (allData) {
var nextRowTop_1 = 0;
allData.forEach(function (dataItem, index) {
var rowNode = new RowNode();
_this.context.createBean(rowNode);
rowNode.data = dataItem;
var idPrefix = isTop ? RowNode.ID_PREFIX_TOP_PINNED : RowNode.ID_PREFIX_BOTTOM_PINNED;
rowNode.id = idPrefix + index;
rowNode.rowPinned = isTop ? Constants.PINNED_TOP : Constants.PINNED_BOTTOM;
rowNode.setRowTop(nextRowTop_1);
rowNode.setRowHeight(_this.gridOptionsWrapper.getRowHeightForNode(rowNode).height);
rowNode.setRowIndex(index);
nextRowTop_1 += rowNode.rowHeight;
rowNodes.push(rowNode);
});
}
return rowNodes;
};
PinnedRowModel.prototype.getPinnedTopRowData = function () {
return this.pinnedTopRows;
};
PinnedRowModel.prototype.getPinnedBottomRowData = function () {
return this.pinnedBottomRows;
};
PinnedRowModel.prototype.getPinnedTopTotalHeight = function () {
return this.getTotalHeight(this.pinnedTopRows);
};
PinnedRowModel.prototype.getPinnedTopRowCount = function () {
return this.pinnedTopRows ? this.pinnedTopRows.length : 0;
};
PinnedRowModel.prototype.getPinnedBottomRowCount = function () {
return this.pinnedBottomRows ? this.pinnedBottomRows.length : 0;
};
PinnedRowModel.prototype.getPinnedTopRow = function (index) {
return this.pinnedTopRows[index];
};
PinnedRowModel.prototype.getPinnedBottomRow = function (index) {
return this.pinnedBottomRows[index];
};
PinnedRowModel.prototype.forEachPinnedTopRow = function (callback) {
if (missingOrEmpty(this.pinnedTopRows)) {
return;
}
this.pinnedTopRows.forEach(callback);
};
PinnedRowModel.prototype.forEachPinnedBottomRow = function (callback) {
if (missingOrEmpty(this.pinnedBottomRows)) {
return;
}
this.pinnedBottomRows.forEach(callback);
};
PinnedRowModel.prototype.getPinnedBottomTotalHeight = function () {
return this.getTotalHeight(this.pinnedBottomRows);
};
PinnedRowModel.prototype.getTotalHeight = function (rowNodes) {
if (!rowNodes || rowNodes.length === 0) {
return 0;
}
var lastNode = last(rowNodes);
return lastNode.rowTop + lastNode.rowHeight;
};
__decorate$1O([
Autowired('gridOptionsWrapper')
], PinnedRowModel.prototype, "gridOptionsWrapper", void 0);
__decorate$1O([
Autowired('columnApi')
], PinnedRowModel.prototype, "columnApi", void 0);
__decorate$1O([
Autowired('gridApi')
], PinnedRowModel.prototype, "gridApi", void 0);
__decorate$1O([
PostConstruct
], PinnedRowModel.prototype, "init", null);
PinnedRowModel = __decorate$1O([
Bean('pinnedRowModel')
], PinnedRowModel);
return PinnedRowModel;
}(BeanStub));
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v24.0.0
* @link http://www.ag-grid.com/
* @license MIT
*/
var __extends$1V = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var UndoRedoAction = /** @class */ (function () {
function UndoRedoAction(cellValueChanges) {
this.cellValueChanges = cellValueChanges;
}
return UndoRedoAction;
}());
var FillUndoRedoAction = /** @class */ (function (_super) {
__extends$1V(FillUndoRedoAction, _super);
function FillUndoRedoAction(cellValueChanges, initialRange, finalRange) {
var _this = _super.call(this, cellValueChanges) || this;
_this.initialRange = initialRange;
_this.finalRange = finalRange;
return _this;
}
return FillUndoRedoAction;
}(UndoRedoAction));
var UndoRedoStack = /** @class */ (function () {
function UndoRedoStack(maxStackSize) {
this.actionStack = [];
this.maxStackSize = maxStackSize ? maxStackSize : UndoRedoStack.DEFAULT_STACK_SIZE;
this.actionStack = new Array(this.maxStackSize);
}
UndoRedoStack.prototype.pop = function () {
return this.actionStack.pop();
};
UndoRedoStack.prototype.push = function (item) {
var shouldAddActions = item.cellValueChanges && item.cellValueChanges.length > 0;
if (!shouldAddActions) {
return;
}
if (this.actionStack.length === this.maxStackSize) {
this.actionStack.shift();
}
this.actionStack.push(item);
};
UndoRedoStack.prototype.clear = function () {
this.actionStack = [];
};
UndoRedoStack.prototype.getCurrentStackSize = function () {
return this.actionStack.length;
};
UndoRedoStack.DEFAULT_STACK_SIZE = 10;
return UndoRedoStack;
}());
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v24.0.0
* @link http://www.ag-grid.com/
* @license MIT
*/
var __extends$1W = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate$1P = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var UndoRedoService = /** @class */ (function (_super) {
__extends$1W(UndoRedoService, _super);
function UndoRedoService() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.cellValueChanges = [];
_this.isCellEditing = false;
_this.isRowEditing = false;
_this.isPasting = false;
_this.isFilling = false;
_this.onCellValueChanged = function (event) {
var shouldCaptureAction = _this.isCellEditing || _this.isRowEditing || _this.isPasting || _this.isFilling;
if (!shouldCaptureAction) {
return;
}
var rowPinned = event.rowPinned, rowIndex = event.rowIndex, column = event.column, oldValue = event.oldValue, value = event.value;
var cellValueChange = {
rowPinned: rowPinned,
rowIndex: rowIndex,
columnId: column.getColId(),
oldValue: oldValue,
newValue: value
};
_this.cellValueChanges.push(cellValueChange);
};
_this.clearStacks = function () {
_this.undoStack.clear();
_this.redoStack.clear();
};
return _this;
}
UndoRedoService.prototype.init = function () {
if (!this.gridOptionsWrapper.isUndoRedoCellEditing()) {
return;
}
var undoRedoLimit = this.gridOptionsWrapper.getUndoRedoCellEditingLimit();
if (undoRedoLimit <= 0) {
return;
}
this.undoStack = new UndoRedoStack(undoRedoLimit);
this.redoStack = new UndoRedoStack(undoRedoLimit);
this.addRowEditingListeners();
this.addCellEditingListeners();
this.addPasteListeners();
this.addFillListeners();
this.addManagedListener(this.eventService, Events.EVENT_CELL_VALUE_CHANGED, this.onCellValueChanged);
// undo / redo is restricted to actual editing so we clear the stacks when other operations are
// performed that change the order of the row / cols.
this.addManagedListener(this.eventService, Events.EVENT_MODEL_UPDATED, this.clearStacks);
this.addManagedListener(this.eventService, Events.EVENT_COLUMN_PIVOT_MODE_CHANGED, this.clearStacks);
this.addManagedListener(this.eventService, Events.EVENT_COLUMN_EVERYTHING_CHANGED, this.clearStacks);
this.addManagedListener(this.eventService, Events.EVENT_COLUMN_GROUP_OPENED, this.clearStacks);
this.addManagedListener(this.eventService, Events.EVENT_COLUMN_ROW_GROUP_CHANGED, this.clearStacks);
this.addManagedListener(this.eventService, Events.EVENT_COLUMN_MOVED, this.clearStacks);
this.addManagedListener(this.eventService, Events.EVENT_COLUMN_PINNED, this.clearStacks);
this.addManagedListener(this.eventService, Events.EVENT_COLUMN_VISIBLE, this.clearStacks);
this.addManagedListener(this.eventService, Events.EVENT_ROW_DRAG_END, this.clearStacks);
};
UndoRedoService.prototype.getCurrentUndoStackSize = function () {
return this.undoStack ? this.undoStack.getCurrentStackSize() : 0;
};
UndoRedoService.prototype.getCurrentRedoStackSize = function () {
return this.redoStack ? this.redoStack.getCurrentStackSize() : 0;
};
UndoRedoService.prototype.undo = function () {
if (!this.undoStack) {
return;
}
var undoAction = this.undoStack.pop();
if (!undoAction || !undoAction.cellValueChanges) {
return;
}
this.processAction(undoAction, function (cellValueChange) { return cellValueChange.oldValue; });
if (undoAction instanceof FillUndoRedoAction) {
this.processRangeAndCellFocus(undoAction.cellValueChanges, undoAction.initialRange);
}
else {
this.processRangeAndCellFocus(undoAction.cellValueChanges);
}
this.redoStack.push(undoAction);
};
UndoRedoService.prototype.redo = function () {
if (!this.redoStack) {
return;
}
var redoAction = this.redoStack.pop();
if (!redoAction || !redoAction.cellValueChanges) {
return;
}
this.processAction(redoAction, function (cellValueChange) { return cellValueChange.newValue; });
if (redoAction instanceof FillUndoRedoAction) {
this.processRangeAndCellFocus(redoAction.cellValueChanges, redoAction.finalRange);
}
else {
this.processRangeAndCellFocus(redoAction.cellValueChanges);
}
this.undoStack.push(redoAction);
};
UndoRedoService.prototype.processAction = function (action, valueExtractor) {
var _this = this;
action.cellValueChanges.forEach(function (cellValueChange) {
var rowIndex = cellValueChange.rowIndex, rowPinned = cellValueChange.rowPinned, columnId = cellValueChange.columnId;
var rowPosition = { rowIndex: rowIndex, rowPinned: rowPinned };
var currentRow = _this.getRowNode(rowPosition);
// checks if the row has been filtered out
if (currentRow.rowTop == null) {
return;
}
currentRow.setDataValue(columnId, valueExtractor(cellValueChange));
});
};
UndoRedoService.prototype.processRangeAndCellFocus = function (cellValueChanges, range) {
if (range) {
var startRow = range.startRow;
var endRow = range.endRow;
var lastFocusedCell_1 = {
rowPinned: startRow.rowPinned,
rowIndex: startRow.rowIndex,
columnId: range.startColumn.getColId()
};
this.setLastFocusedCell(lastFocusedCell_1);
var cellRangeParams = {
rowStartIndex: startRow.rowIndex,
rowStartPinned: startRow.rowPinned,
rowEndIndex: endRow.rowIndex,
rowEndPinned: endRow.rowPinned,
columnStart: range.startColumn,
columns: range.columns
};
this.gridApi.addCellRange(cellRangeParams);
return;
}
var cellValueChange = cellValueChanges[0];
var rowIndex = cellValueChange.rowIndex, rowPinned = cellValueChange.rowPinned;
var rowPosition = { rowIndex: rowIndex, rowPinned: rowPinned };
var row = this.getRowNode(rowPosition);
var lastFocusedCell = {
rowPinned: cellValueChange.rowPinned,
rowIndex: row.rowIndex,
columnId: cellValueChange.columnId
};
this.setLastFocusedCell(lastFocusedCell);
};
UndoRedoService.prototype.setLastFocusedCell = function (lastFocusedCell) {
var rowIndex = lastFocusedCell.rowIndex, columnId = lastFocusedCell.columnId, rowPinned = lastFocusedCell.rowPinned;
this.gridApi.ensureIndexVisible(rowIndex);
this.gridApi.ensureColumnVisible(columnId);
if (ModuleRegistry.isRegistered(exports.ModuleNames.RangeSelectionModule)) {
this.gridApi.clearRangeSelection();
}
this.focusController.setFocusedCell(rowIndex, columnId, rowPinned, true);
};
UndoRedoService.prototype.addRowEditingListeners = function () {
var _this = this;
this.addManagedListener(this.eventService, Events.EVENT_ROW_EDITING_STARTED, function () {
_this.isRowEditing = true;
});
this.addManagedListener(this.eventService, Events.EVENT_ROW_EDITING_STOPPED, function () {
var action = new UndoRedoAction(_this.cellValueChanges);
_this.pushActionsToUndoStack(action);
_this.isRowEditing = false;
});
};
UndoRedoService.prototype.addCellEditingListeners = function () {
var _this = this;
this.addManagedListener(this.eventService, Events.EVENT_CELL_EDITING_STARTED, function () {
_this.isCellEditing = true;
});
this.addManagedListener(this.eventService, Events.EVENT_CELL_EDITING_STOPPED, function () {
_this.isCellEditing = false;
var shouldPushAction = !_this.isRowEditing && !_this.isPasting && !_this.isFilling;
if (shouldPushAction) {
var action = new UndoRedoAction(_this.cellValueChanges);
_this.pushActionsToUndoStack(action);
}
});
};
UndoRedoService.prototype.addPasteListeners = function () {
var _this = this;
this.addManagedListener(this.eventService, Events.EVENT_PASTE_START, function () {
_this.isPasting = true;
});
this.addManagedListener(this.eventService, Events.EVENT_PASTE_END, function () {
var action = new UndoRedoAction(_this.cellValueChanges);
_this.pushActionsToUndoStack(action);
_this.isPasting = false;
});
};
UndoRedoService.prototype.addFillListeners = function () {
var _this = this;
this.addManagedListener(this.eventService, Events.EVENT_FILL_START, function () {
_this.isFilling = true;
});
this.addManagedListener(this.eventService, Events.EVENT_FILL_END, function (event) {
var action = new FillUndoRedoAction(_this.cellValueChanges, event.initialRange, event.finalRange);
_this.pushActionsToUndoStack(action);
_this.isFilling = false;
});
};
UndoRedoService.prototype.pushActionsToUndoStack = function (action) {
this.undoStack.push(action);
this.cellValueChanges = [];
this.redoStack.clear();
};
UndoRedoService.prototype.getRowNode = function (gridRow) {
switch (gridRow.rowPinned) {
case Constants.PINNED_TOP:
return this.pinnedRowModel.getPinnedTopRowData()[gridRow.rowIndex];
case Constants.PINNED_BOTTOM:
return this.pinnedRowModel.getPinnedBottomRowData()[gridRow.rowIndex];
default:
return this.rowModel.getRow(gridRow.rowIndex);
}
};
__decorate$1P([
Autowired('gridOptionsWrapper')
], UndoRedoService.prototype, "gridOptionsWrapper", void 0);
__decorate$1P([
Autowired('focusController')
], UndoRedoService.prototype, "focusController", void 0);
__decorate$1P([
Autowired('gridApi')
], UndoRedoService.prototype, "gridApi", void 0);
__decorate$1P([
Autowired('rowModel')
], UndoRedoService.prototype, "rowModel", void 0);
__decorate$1P([
Autowired('pinnedRowModel')
], UndoRedoService.prototype, "pinnedRowModel", void 0);
__decorate$1P([
PostConstruct
], UndoRedoService.prototype, "init", null);
UndoRedoService = __decorate$1P([
Bean('undoRedoService')
], UndoRedoService);
return UndoRedoService;
}(BeanStub));
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v24.0.0
* @link http://www.ag-grid.com/
* @license MIT
*/
var __extends$1X = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate$1Q = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var AgStackComponentsRegistry = /** @class */ (function (_super) {
__extends$1X(AgStackComponentsRegistry, _super);
function AgStackComponentsRegistry() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.componentsMappedByName = {};
return _this;
}
AgStackComponentsRegistry.prototype.setupComponents = function (components) {
var _this = this;
if (components) {
components.forEach(function (componentMeta) { return _this.addComponent(componentMeta); });
}
};
AgStackComponentsRegistry.prototype.addComponent = function (componentMeta) {
// get name of the class as a string
// let className = getNameOfClass(ComponentClass);
// insert a dash after every capital letter
// let classEscaped = className.replace(/([A-Z])/g, "-$1").toLowerCase();
var classEscaped = componentMeta.componentName.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
// put all to upper case
var classUpperCase = classEscaped.toUpperCase();
// finally store
this.componentsMappedByName[classUpperCase] = componentMeta.componentClass;
};
AgStackComponentsRegistry.prototype.getComponentClass = function (htmlTag) {
return this.componentsMappedByName[htmlTag];
};
AgStackComponentsRegistry = __decorate$1Q([
Bean('agStackComponentsRegistry')
], AgStackComponentsRegistry);
return AgStackComponentsRegistry;
}(BeanStub));
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v24.0.0
* @link http://www.ag-grid.com/
* @license MIT
*/
var __extends$1Y = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate$1R = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var HeaderPositionUtils = /** @class */ (function (_super) {
__extends$1Y(HeaderPositionUtils, _super);
function HeaderPositionUtils() {
return _super !== null && _super.apply(this, arguments) || this;
}
HeaderPositionUtils.prototype.findHeader = function (focusedHeader, direction) {
var nextColumn;
var getGroupMethod;
var getColMethod;
if (focusedHeader.column instanceof ColumnGroup) {
getGroupMethod = "getDisplayedGroup" + direction;
nextColumn = this.columnController[getGroupMethod](focusedHeader.column);
}
else {
getColMethod = "getDisplayedCol" + direction;
nextColumn = this.columnController[getColMethod](focusedHeader.column);
}
if (nextColumn) {
return {
column: nextColumn,
headerRowIndex: focusedHeader.headerRowIndex
};
}
};
HeaderPositionUtils.prototype.findColAtEdgeForHeaderRow = function (level, position) {
var displayedColumns = this.columnController.getAllDisplayedColumns();
var column = displayedColumns[position === 'start' ? 0 : displayedColumns.length - 1];
if (!column) {
return;
}
var childContainer = this.headerNavigationService.getHeaderContainer(column.getPinned());
var headerRowComp = childContainer.getRowComps()[level];
var type = headerRowComp && headerRowComp.getType();
if (type == HeaderRowType.COLUMN_GROUP) {
var columnGroup = this.columnController.getColumnGroupAtLevel(column, level);
return {
headerRowIndex: level,
column: columnGroup
};
}
return {
headerRowIndex: !headerRowComp ? -1 : level,
column: column
};
};
__decorate$1R([
Autowired('columnController')
], HeaderPositionUtils.prototype, "columnController", void 0);
__decorate$1R([
Autowired('headerNavigationService')
], HeaderPositionUtils.prototype, "headerNavigationService", void 0);
HeaderPositionUtils = __decorate$1R([
Bean('headerPositionUtils')
], HeaderPositionUtils);
return HeaderPositionUtils;
}(BeanStub));
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v24.0.0
* @link http://www.ag-grid.com/
* @license MIT
*/
var __decorate$1S = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var ColumnDefFactory = /** @class */ (function () {
function ColumnDefFactory() {
}
ColumnDefFactory.prototype.buildColumnDefs = function (cols, rowGroupColumns, pivotColumns) {
var _this = this;
var res = [];
var colGroupDefs = {};
cols.forEach(function (col) {
var colDef = _this.createDefFromColumn(col, rowGroupColumns, pivotColumns);
var addToResult = true;
var childDef = colDef;
var child = col;
while (child.getParent()) {
var parent_1 = child.getParent();
var parentDef = void 0;
// we don't include padding groups, as the column groups provided
// by application didn't have these. the whole point of padding groups
// is to balance the column tree that the user provided.
if (parent_1.isPadding()) {
child = parent_1;
continue;
}
// if colDef for this group already exists, use it
var existingParentDef = colGroupDefs[parent_1.getGroupId()];
if (existingParentDef) {
existingParentDef.children.push(childDef);
// if we added to result, it would be the second time we did it
addToResult = false;
// we don't want to continue up the tree, as it has already been
// done for this group
break;
}
parentDef = _this.createDefFromGroup(parent_1);
parentDef.children = [childDef];
colGroupDefs[parentDef.groupId] = parentDef;
childDef = parentDef;
child = parent_1;
}
if (addToResult) {
res.push(childDef);
}
});
return res;
};
ColumnDefFactory.prototype.createDefFromGroup = function (group) {
var defCloned = deepCloneDefinition(group.getColGroupDef(), ['children']);
defCloned.groupId = group.getGroupId();
return defCloned;
};
ColumnDefFactory.prototype.createDefFromColumn = function (col, rowGroupColumns, pivotColumns) {
var colDefCloned = deepCloneDefinition(col.getColDef());
colDefCloned.colId = col.getColId();
colDefCloned.width = col.getActualWidth();
colDefCloned.rowGroup = col.isRowGroupActive();
colDefCloned.rowGroupIndex = col.isRowGroupActive() ? rowGroupColumns.indexOf(col) : null;
colDefCloned.pivot = col.isPivotActive();
colDefCloned.pivotIndex = col.isPivotActive() ? pivotColumns.indexOf(col) : null;
colDefCloned.aggFunc = col.isValueActive() ? col.getAggFunc() : null;
colDefCloned.hide = col.isVisible() ? undefined : true;
colDefCloned.pinned = col.isPinned() ? col.getPinned() : null;
colDefCloned.sort = col.getSort() ? col.getSort() : null;
colDefCloned.sortIndex = col.getSortIndex() != null ? col.getSortIndex() : null;
return colDefCloned;
};
ColumnDefFactory = __decorate$1S([
Bean('columnDefFactory')
], ColumnDefFactory);
return ColumnDefFactory;
}());
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v24.0.0
* @link http://www.ag-grid.com/
* @license MIT
*/
var __decorate$1T = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
/**
* Common logic for RowComp and AutoHeightCalculator
*/
var RowCssClassCalculator = /** @class */ (function () {
function RowCssClassCalculator() {
}
RowCssClassCalculator.prototype.getInitialRowClasses = function (params) {
var classes = [];
if (exists(params.extraCssClass)) {
classes.push(params.extraCssClass);
}
classes.push('ag-row');
classes.push(params.rowFocused ? 'ag-row-focus' : 'ag-row-no-focus');
if (params.fadeRowIn) {
classes.push('ag-opacity-zero');
}
classes.push(params.rowIsEven ? 'ag-row-even' : 'ag-row-odd');
if (params.rowNode.isRowPinned()) {
classes.push('ag-row-pinned');
}
if (params.rowNode.isSelected()) {
classes.push('ag-row-selected');
}
if (params.rowNode.footer) {
classes.push('ag-row-footer');
}
classes.push('ag-row-level-' + params.rowLevel);
if (params.rowNode.stub) {
classes.push('ag-row-loading');
}
if (params.fullWidthRow) {
classes.push('ag-full-width-row');
}
if (params.expandable) {
classes.push('ag-row-group');
classes.push(params.rowNode.expanded ? 'ag-row-group-expanded' : 'ag-row-group-contracted');
}
if (params.rowNode.dragging) {
classes.push('ag-row-dragging');
}
pushAll(classes, this.processClassesFromGridOptions(params.rowNode));
pushAll(classes, this.preProcessRowClassRules(params.rowNode, params.scope));
// we use absolute position unless we are doing print layout
classes.push(params.printLayout ? 'ag-row-position-relative' : 'ag-row-position-absolute');
if (params.firstRowOnPage) {
classes.push('ag-row-first');
}
if (params.lastRowOnPage) {
classes.push('ag-row-last');
}
return classes;
};
RowCssClassCalculator.prototype.processClassesFromGridOptions = function (rowNode) {
var res = [];
var process = function (rowCls) {
if (typeof rowCls === 'string') {
res.push(rowCls);
}
else if (Array.isArray(rowCls)) {
rowCls.forEach(function (e) { return res.push(e); });
}
};
// part 1 - rowClass
var rowClass = this.gridOptionsWrapper.getRowClass();
if (rowClass) {
if (typeof rowClass === 'function') {
console.warn('ag-Grid: rowClass should not be a function, please use getRowClass instead');
return;
}
process(rowClass);
}
// part 2 - rowClassFunc
var rowClassFunc = this.gridOptionsWrapper.getRowClassFunc();
if (rowClassFunc) {
var params = {
node: rowNode,
data: rowNode.data,
rowIndex: rowNode.rowIndex,
context: this.gridOptionsWrapper.getContext(),
api: this.gridOptionsWrapper.getApi()
};
var rowClassFuncResult = rowClassFunc(params);
process(rowClassFuncResult);
}
return res;
};
RowCssClassCalculator.prototype.preProcessRowClassRules = function (rowNode, scope) {
var res = [];
this.processRowClassRules(rowNode, scope, function (className) {
res.push(className);
}, function (className) {
// not catered for, if creating, no need
// to remove class as it was never there
});
return res;
};
RowCssClassCalculator.prototype.processRowClassRules = function (rowNode, scope, onApplicableClass, onNotApplicableClass) {
this.stylingService.processClassRules(this.gridOptionsWrapper.rowClassRules(), {
value: undefined,
colDef: undefined,
data: rowNode.data,
node: rowNode,
rowIndex: rowNode.rowIndex,
api: this.gridOptionsWrapper.getApi(),
columnApi: this.gridOptionsWrapper.getColumnApi(),
$scope: scope,
context: this.gridOptionsWrapper.getContext()
}, onApplicableClass, onNotApplicableClass);
};
RowCssClassCalculator.prototype.calculateRowLevel = function (rowNode) {
if (rowNode.group) {
return rowNode.level;
}
else {
// if a leaf, and a parent exists, put a level of the parent, else put level of 0 for top level item
return rowNode.parent ? (rowNode.parent.level + 1) : 0;
}
};
RowCssClassCalculator.prototype.isExpandable = function (rowNode) {
var isTreeData = this.gridOptionsWrapper.isTreeData();
var res = isTreeData ?
// if doing tree data, we add the expanded classes if any children, as any node can be a parent
rowNode.childrenAfterGroup != null && rowNode.childrenAfterGroup.length > 0 :
// if normal row grouping, we add expanded classes to groups only
rowNode.group && !rowNode.footer;
return res;
};
__decorate$1T([
Autowired('stylingService')
], RowCssClassCalculator.prototype, "stylingService", void 0);
__decorate$1T([
Autowired('gridOptionsWrapper')
], RowCssClassCalculator.prototype, "gridOptionsWrapper", void 0);
RowCssClassCalculator = __decorate$1T([
Bean('rowCssClassCalculator')
], RowCssClassCalculator);
return RowCssClassCalculator;
}());
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v24.0.0
* @link http://www.ag-grid.com/
* @license MIT
*/
var Grid = /** @class */ (function () {
function Grid(eGridDiv, gridOptions, params) {
if (!eGridDiv) {
console.error('ag-Grid: no div element provided to the grid');
return;
}
if (!gridOptions) {
console.error('ag-Grid: no gridOptions provided to the grid');
return;
}
var debug = !!gridOptions.debug;
this.gridOptions = gridOptions;
var registeredModules = this.getRegisteredModules(params);
var beanClasses = this.createBeansList(registeredModules);
var providedBeanInstances = this.createProvidedBeans(eGridDiv, params);
if (!beanClasses) {
return;
} // happens when no row model found
var contextParams = {
providedBeanInstances: providedBeanInstances,
beanClasses: beanClasses,
debug: debug
};
this.logger = new Logger('ag-Grid', function () { return gridOptions.debug; });
var contextLogger = new Logger('Context', function () { return contextParams.debug; });
this.context = new Context(contextParams, contextLogger);
this.registerModuleUserComponents(registeredModules);
this.registerStackComponents(registeredModules);
var gridCoreClass = (params && params.rootComponent) || GridCore;
var gridCore = new gridCoreClass();
this.context.createBean(gridCore);
this.setColumnsAndData();
this.dispatchGridReadyEvent(gridOptions);
var isEnterprise = ModuleRegistry.isRegistered(exports.ModuleNames.EnterpriseCoreModule);
this.logger.log("initialised successfully, enterprise = " + isEnterprise);
}
Grid.prototype.registerStackComponents = function (registeredModules) {
var agStackComponents = this.createAgStackComponentsList(registeredModules);
var agStackComponentsRegistry = this.context.getBean('agStackComponentsRegistry');
agStackComponentsRegistry.setupComponents(agStackComponents);
};
Grid.prototype.getRegisteredModules = function (params) {
var passedViaConstructor = params ? params.modules : null;
var registered = ModuleRegistry.getRegisteredModules();
var allModules = [];
var mapNames = {};
// adds to list and removes duplicates
function addModule(moduleBased, module) {
function addIndividualModule(module) {
if (!mapNames[module.moduleName]) {
mapNames[module.moduleName] = true;
allModules.push(module);
ModuleRegistry.register(module, moduleBased);
}
}
addIndividualModule(module);
if (module.dependantModules) {
module.dependantModules.forEach(addModule.bind(null, moduleBased));
}
}
if (passedViaConstructor) {
passedViaConstructor.forEach(addModule.bind(null, true));
}
if (registered) {
registered.forEach(addModule.bind(null, !ModuleRegistry.isPackageBased()));
}
return allModules;
};
Grid.prototype.registerModuleUserComponents = function (registeredModules) {
var userComponentRegistry = this.context.getBean('userComponentRegistry');
var moduleUserComps = this.extractModuleEntity(registeredModules, function (module) { return module.userComponents ? module.userComponents : []; });
moduleUserComps.forEach(function (compMeta) {
userComponentRegistry.registerDefaultComponent(compMeta.componentName, compMeta.componentClass);
});
};
Grid.prototype.createProvidedBeans = function (eGridDiv, params) {
var frameworkOverrides = params ? params.frameworkOverrides : null;
if (missing(frameworkOverrides)) {
frameworkOverrides = new VanillaFrameworkOverrides();
}
var seed = {
gridOptions: this.gridOptions,
eGridDiv: eGridDiv,
$scope: params ? params.$scope : null,
$compile: params ? params.$compile : null,
quickFilterOnScope: params ? params.quickFilterOnScope : null,
globalEventListener: params ? params.globalEventListener : null,
frameworkOverrides: frameworkOverrides
};
if (params && params.providedBeanInstances) {
assign(seed, params.providedBeanInstances);
}
return seed;
};
Grid.prototype.createAgStackComponentsList = function (registeredModules) {
var components = [
{ componentName: 'AgCheckbox', componentClass: AgCheckbox },
{ componentName: 'AgRadioButton', componentClass: AgRadioButton },
{ componentName: 'AgToggleButton', componentClass: AgToggleButton },
{ componentName: 'AgInputTextField', componentClass: AgInputTextField },
{ componentName: 'AgInputTextArea', componentClass: AgInputTextArea },
{ componentName: 'AgInputNumberField', componentClass: AgInputNumberField },
{ componentName: 'AgInputRange', componentClass: AgInputRange },
{ componentName: 'AgSelect', componentClass: AgSelect },
{ componentName: 'AgSlider', componentClass: AgSlider },
{ componentName: 'AgAngleSelect', componentClass: AgAngleSelect },
{ componentName: 'AgColorPicker', componentClass: AgColorPicker },
{ componentName: 'AgGridComp', componentClass: GridPanel },
{ componentName: 'AgHeaderRoot', componentClass: HeaderRootComp },
{ componentName: 'AgPagination', componentClass: PaginationComp },
{ componentName: 'AgOverlayWrapper', componentClass: OverlayWrapperComponent },
{ componentName: 'AgGroupComponent', componentClass: AgGroupComponent },
{ componentName: 'AgPanel', componentClass: AgPanel },
{ componentName: 'AgDialog', componentClass: AgDialog }
];
var moduleAgStackComps = this.extractModuleEntity(registeredModules, function (module) { return module.agStackComponents ? module.agStackComponents : []; });
components = components.concat(moduleAgStackComps);
return components;
};
Grid.prototype.createBeansList = function (registeredModules) {
var rowModelClass = this.getRowModelClass(registeredModules);
if (!rowModelClass) {
return;
}
// beans should only contain SERVICES, it should NEVER contain COMPONENTS
var beans = [
rowModelClass, Beans, RowPositionUtils, CellPositionUtils, HeaderPositionUtils,
PaginationAutoPageSizeService, GridApi, UserComponentRegistry, AgComponentUtils,
ComponentMetadataProvider, ResizeObserverService, UserComponentFactory,
MaxDivHeightScaler, AutoHeightCalculator, CellRendererFactory, HorizontalResizeService,
PinnedRowModel, DragService, DisplayedGroupCreator, EventService, GridOptionsWrapper,
PopupService, SelectionController, FilterManager, ColumnController, HeaderNavigationService,
PaginationProxy, RowRenderer, ExpressionService, ColumnFactory, TemplateService,
AlignedGridsService, NavigationService, ValueCache, ValueService, LoggerFactory,
ColumnUtils, AutoWidthCalculator, StandardMenuFactory, DragAndDropService, ColumnApi,
FocusController, MouseEventService, Environment, CellNavigationService, ValueFormatterService,
StylingService, ScrollVisibleService, SortController, ColumnHoverService, ColumnAnimationService,
SelectableService, AutoGroupColService, ChangeDetectionService, AnimationFrameService,
DetailRowCompCache, UndoRedoService, AgStackComponentsRegistry, ColumnDefFactory,
RowCssClassCalculator
];
var moduleBeans = this.extractModuleEntity(registeredModules, function (module) { return module.beans ? module.beans : []; });
beans.push.apply(beans, moduleBeans);
// check for duplicates, as different modules could include the same beans that
// they depend on, eg ClientSideRowModel in enterprise, and ClientSideRowModel in community
var beansNoDuplicates = [];
beans.forEach(function (bean) {
if (beansNoDuplicates.indexOf(bean) < 0) {
beansNoDuplicates.push(bean);
}
});
return beansNoDuplicates;
};
Grid.prototype.extractModuleEntity = function (moduleEntities, extractor) {
return [].concat.apply([], moduleEntities.map(extractor));
};
Grid.prototype.setColumnsAndData = function () {
var gridOptionsWrapper = this.context.getBean('gridOptionsWrapper');
var columnController = this.context.getBean('columnController');
var columnDefs = gridOptionsWrapper.getColumnDefs();
columnController.setColumnDefs(columnDefs || [], "gridInitializing");
var rowModel = this.context.getBean('rowModel');
rowModel.start();
};
Grid.prototype.dispatchGridReadyEvent = function (gridOptions) {
var eventService = this.context.getBean('eventService');
var readyEvent = {
type: Events.EVENT_GRID_READY,
api: gridOptions.api,
columnApi: gridOptions.columnApi
};
eventService.dispatchEvent(readyEvent);
};
Grid.prototype.getRowModelClass = function (registeredModules) {
var rowModelType = this.gridOptions.rowModelType;
// default to client side
if (!rowModelType) {
rowModelType = Constants.ROW_MODEL_TYPE_CLIENT_SIDE;
}
var rowModelClasses = {};
registeredModules.forEach(function (module) {
iterateObject(module.rowModels, function (key, value) {
rowModelClasses[key] = value;
});
});
var rowModelClass = rowModelClasses[rowModelType];
if (exists(rowModelClass)) {
return rowModelClass;
}
if (rowModelType === Constants.ROW_MODEL_TYPE_INFINITE) {
console.error("ag-Grid: Row Model \"Infinite\" not found. Please ensure the " + exports.ModuleNames.InfiniteRowModelModule + " is registered.';");
}
console.error('ag-Grid: could not find matching row model for rowModelType ' + rowModelType);
if (rowModelType === Constants.ROW_MODEL_TYPE_VIEWPORT) {
console.error("ag-Grid: Row Model \"Viewport\" not found. Please ensure the ag-Grid Enterprise Module " + exports.ModuleNames.ViewportRowModelModule + " is registered.';");
}
if (rowModelType === Constants.ROW_MODEL_TYPE_SERVER_SIDE) {
console.error("ag-Grid: Row Model \"Server Side\" not found. Please ensure the ag-Grid Enterprise Module " + exports.ModuleNames.ServerSideRowModelModule + " is registered.';");
}
if (rowModelType === Constants.ROW_MODEL_TYPE_CLIENT_SIDE) {
console.error("ag-Grid: Row Model \"Client Side\" not found. Please ensure the " + exports.ModuleNames.ClientSideRowModelModule + " is registered.';");
}
};
Grid.prototype.destroy = function () {
this.gridOptions.api.destroy();
};
return Grid;
}());
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v24.0.0
* @link http://www.ag-grid.com/
* @license MIT
*/
function initialiseAgGridWithAngular1(angular) {
var angularModule = angular.module("agGrid", []);
angularModule.directive("agGrid", function () {
return {
restrict: "A",
controller: ['$element', '$scope', '$compile', '$attrs', AngularDirectiveController],
scope: true
};
});
}
function AngularDirectiveController($element, $scope, $compile, $attrs) {
var gridOptions;
var quickFilterOnScope;
var keyOfGridInScope = $attrs.agGrid;
quickFilterOnScope = keyOfGridInScope + '.quickFilterText';
gridOptions = $scope.$eval(keyOfGridInScope);
if (!gridOptions) {
console.warn("WARNING - grid options for ag-Grid not found. Please ensure the attribute ag-grid points to a valid object on the scope");
return;
}
var eGridDiv = $element[0];
var gridParams = {
$scope: $scope,
$compile: $compile,
quickFilterOnScope: quickFilterOnScope
};
var grid = new Grid(eGridDiv, gridOptions, gridParams);
$scope.$on("$destroy", function () {
grid.destroy();
grid = null;
});
}
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v24.0.0
* @link http://www.ag-grid.com/
* @license MIT
*/
var registered = false;
function initialiseAgGridWithWebComponents() {
console.warn('ag-grid: initialiseAgGridWithWebComponents is deprecated. Please use the ag-grid-webcomponent dependency instead. ');
// only register to WebComponents once
if (registered) {
return;
}
registered = true;
if (typeof document === 'undefined' || !document.registerElement) {
console.error('ag-Grid: unable to find document.registerElement() function, unable to initialise ag-Grid as a Web Component');
}
// i don't think this type of extension is possible in TypeScript, so back to
// plain Javascript to create this object
var AgileGridProto = Object.create(HTMLElement.prototype);
// wrap each property with a get and set method, so we can track when changes are done
ComponentUtil.ALL_PROPERTIES.forEach(function (key) {
Object.defineProperty(AgileGridProto, key, {
set: function (v) {
this.__agGridSetProperty(key, v);
},
get: function () {
return this.__agGridGetProperty(key);
},
enumerable: true,
configurable: true
});
});
var agGridProtoNoType = AgileGridProto;
agGridProtoNoType.__agGridSetProperty = function (key, value) {
if (!this.__attributes) {
this.__attributes = {};
}
this.__attributes[key] = value;
// keeping this consistent with the ng2 onChange, so I can reuse the handling code
var changeObject = {};
changeObject[key] = { currentValue: value };
this.onChange(changeObject);
};
agGridProtoNoType.onChange = function (changes) {
if (this._initialised) {
ComponentUtil.processOnChange(changes, this._gridOptions, this.api, this.columnApi);
}
};
agGridProtoNoType.__agGridGetProperty = function (key) {
if (!this.__attributes) {
this.__attributes = {};
}
return this.__attributes[key];
};
agGridProtoNoType.setGridOptions = function (options) {
var globalEventListener = this.globalEventListener.bind(this);
this._gridOptions = ComponentUtil.copyAttributesToGridOptions(options, this);
var gridParams = {
globalEventListener: globalEventListener
};
this._agGrid = new Grid(this, this._gridOptions, gridParams);
this.api = options.api;
this.columnApi = options.columnApi;
this._initialised = true;
};
// copies all the attributes into this object
agGridProtoNoType.createdCallback = function () {
for (var i = 0; i < this.attributes.length; i++) {
var attribute = this.attributes[i];
this.setPropertyFromAttribute(attribute);
}
};
agGridProtoNoType.setPropertyFromAttribute = function (attribute) {
var name = toCamelCase(attribute.nodeName);
var value = attribute.nodeValue;
if (ComponentUtil.ALL_PROPERTIES.indexOf(name) >= 0) {
this[name] = value;
}
};
agGridProtoNoType.attachedCallback = function (params) { };
agGridProtoNoType.detachedCallback = function (params) { };
agGridProtoNoType.attributeChangedCallback = function (attributeName) {
var attribute = this.attributes[attributeName];
this.setPropertyFromAttribute(attribute);
};
agGridProtoNoType.globalEventListener = function (eventType, event) {
var eventLowerCase = eventType.toLowerCase();
var browserEvent = new Event(eventLowerCase);
var browserEventNoType = browserEvent;
browserEventNoType.agGridDetails = event;
this.dispatchEvent(browserEvent);
var callbackMethod = 'on' + eventLowerCase;
if (typeof this[callbackMethod] === 'function') {
this[callbackMethod](browserEvent);
}
};
// finally, register
document.registerElement('ag-grid', { prototype: AgileGridProto });
}
function toCamelCase(myString) {
if (typeof myString === 'string') {
var result = myString.replace(/-([a-z])/g, function (g) {
return g[1].toUpperCase();
});
return result;
}
else {
return myString;
}
}
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v24.0.0
* @link http://www.ag-grid.com/
* @license MIT
*/
var __extends$1Z = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate$1U = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var TabbedLayout = /** @class */ (function (_super) {
__extends$1Z(TabbedLayout, _super);
function TabbedLayout(params) {
var _this = _super.call(this, TabbedLayout.getTemplate(params.cssClass)) || this;
_this.items = [];
_this.params = params;
if (params.items) {
params.items.forEach(function (item) { return _this.addItem(item); });
}
return _this;
}
TabbedLayout.getTemplate = function (cssClass) {
return /* html */ "
";
};
TabbedLayout.prototype.handleKeyDown = function (e) {
switch (e.keyCode) {
case KeyCode.RIGHT:
case KeyCode.LEFT:
if (!this.eHeader.contains(document.activeElement)) {
return;
}
var currentPosition = this.items.indexOf(this.activeItem);
var nextPosition = e.keyCode === KeyCode.RIGHT ? Math.min(currentPosition + 1, this.items.length - 1) : Math.max(currentPosition - 1, 0);
if (currentPosition === nextPosition) {
return;
}
e.preventDefault();
var nextItem = this.items[nextPosition];
this.showItemWrapper(nextItem);
nextItem.eHeaderButton.focus();
break;
case KeyCode.UP:
case KeyCode.DOWN:
e.stopPropagation();
break;
}
};
TabbedLayout.prototype.onTabKeyDown = function (e) {
if (e.defaultPrevented) {
return;
}
var _a = this, focusController = _a.focusController, eHeader = _a.eHeader, eBody = _a.eBody, activeItem = _a.activeItem;
var activeElement = document.activeElement;
e.preventDefault();
if (eHeader.contains(activeElement)) {
// focus is in header, move into body of popup
focusController.focusInto(eBody, e.shiftKey);
}
else {
// focus is in body, establish if it should return to header
if (focusController.isFocusUnderManagedComponent(eBody)) {
// focus was in a managed focus component and has now left, so we can return to the header
activeItem.eHeaderButton.focus();
}
else {
var nextEl = focusController.findNextFocusableElement(eBody, false, e.shiftKey);
if (nextEl) {
// if another element exists in the body that can be focussed, go to that
nextEl.focus();
}
else {
// otherwise return to the header
activeItem.eHeaderButton.focus();
}
}
}
};
TabbedLayout.prototype.setAfterAttachedParams = function (params) {
this.afterAttachedParams = params;
};
TabbedLayout.prototype.getMinDimensions = function () {
var eDummyContainer = this.getGui().cloneNode(true);
var eDummyBody = eDummyContainer.querySelector('[ref="eBody"]');
// position fixed, so it isn't restricted to the boundaries of the parent
eDummyContainer.style.position = 'fixed';
// we put the dummy into the body container, so it will inherit all the
// css styles that the real cells are inheriting
this.getGui().appendChild(eDummyContainer);
var minWidth = 0;
var minHeight = 0;
this.items.forEach(function (itemWrapper) {
clearElement(eDummyBody);
var eClone = itemWrapper.tabbedItem.bodyPromise.resolveNow(null, function (body) { return body.cloneNode(true); });
if (eClone == null) {
return;
}
eDummyBody.appendChild(eClone);
if (minWidth < eDummyContainer.offsetWidth) {
minWidth = eDummyContainer.offsetWidth;
}
if (minHeight < eDummyContainer.offsetHeight) {
minHeight = eDummyContainer.offsetHeight;
}
});
this.getGui().removeChild(eDummyContainer);
return { height: minHeight, width: minWidth };
};
TabbedLayout.prototype.showFirstItem = function () {
if (this.items.length > 0) {
this.showItemWrapper(this.items[0]);
}
};
TabbedLayout.prototype.addItem = function (item) {
var eHeaderButton = document.createElement('span');
eHeaderButton.setAttribute('tabIndex', '-1');
eHeaderButton.setAttribute('role', 'menuitem');
eHeaderButton.appendChild(item.title);
addCssClass(eHeaderButton, 'ag-tab');
this.eHeader.appendChild(eHeaderButton);
setAriaLabel(eHeaderButton, item.titleLabel);
var wrapper = {
tabbedItem: item,
eHeaderButton: eHeaderButton
};
this.items.push(wrapper);
eHeaderButton.addEventListener('click', this.showItemWrapper.bind(this, wrapper));
};
TabbedLayout.prototype.showItem = function (tabbedItem) {
var itemWrapper = find(this.items, function (wrapper) {
return wrapper.tabbedItem === tabbedItem;
});
if (itemWrapper) {
this.showItemWrapper(itemWrapper);
}
};
TabbedLayout.prototype.showItemWrapper = function (wrapper) {
var _this = this;
if (this.params.onItemClicked) {
this.params.onItemClicked({ item: wrapper.tabbedItem });
}
if (this.activeItem === wrapper) {
callIfPresent(this.params.onActiveItemClicked);
return;
}
clearElement(this.eBody);
wrapper.tabbedItem.bodyPromise.then(function (body) {
_this.eBody.appendChild(body);
var onlyUnmanaged = !_this.focusController.isKeyboardFocus();
_this.focusController.focusInto(_this.eBody, false, onlyUnmanaged);
});
if (this.activeItem) {
removeCssClass(this.activeItem.eHeaderButton, 'ag-tab-selected');
}
addCssClass(wrapper.eHeaderButton, 'ag-tab-selected');
this.activeItem = wrapper;
if (wrapper.tabbedItem.afterAttachedCallback) {
wrapper.tabbedItem.afterAttachedCallback(this.afterAttachedParams);
}
};
__decorate$1U([
RefSelector('eHeader')
], TabbedLayout.prototype, "eHeader", void 0);
__decorate$1U([
RefSelector('eBody')
], TabbedLayout.prototype, "eBody", void 0);
return TabbedLayout;
}(ManagedFocusComponent));
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v24.0.0
* @link http://www.ag-grid.com/
* @license MIT
*/
function simpleHttpRequest(params) {
return new Promise(function (resolve) {
var httpRequest = new XMLHttpRequest();
httpRequest.open('GET', params.url);
httpRequest.send();
httpRequest.onreadystatechange = function () {
if (httpRequest.readyState === 4 && httpRequest.status === 200) {
resolve(JSON.parse(httpRequest.responseText));
}
};
});
}
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v24.0.0
* @link http://www.ag-grid.com/
* @license MIT
*/
var __extends$1_ = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate$1V = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var RowNodeBlock = /** @class */ (function (_super) {
__extends$1_(RowNodeBlock, _super);
function RowNodeBlock(blockNumber, rowNodeCacheParams) {
var _this = _super.call(this) || this;
_this.version = 0;
_this.state = RowNodeBlock.STATE_DIRTY;
_this.rowNodeCacheParams = rowNodeCacheParams;
_this.blockNumber = blockNumber;
// we don't need to calculate these now, as the inputs don't change,
// however it makes the code easier to read if we work them out up front
_this.startRow = blockNumber * rowNodeCacheParams.blockSize;
_this.endRow = _this.startRow + rowNodeCacheParams.blockSize;
return _this;
}
RowNodeBlock.prototype.isAnyNodeOpen = function (rowCount) {
var result = false;
this.forEachNodeCallback(function (rowNode) {
if (rowNode.expanded) {
result = true;
}
}, rowCount);
return result;
};
RowNodeBlock.prototype.forEachNodeCallback = function (callback, rowCount) {
for (var rowIndex = this.startRow; rowIndex < this.endRow; rowIndex++) {
// we check against rowCount as this page may be the last one, and if it is, then
// the last rows are not part of the set
if (rowIndex < rowCount) {
var rowNode = this.getRowUsingLocalIndex(rowIndex);
callback(rowNode, rowIndex);
}
}
};
RowNodeBlock.prototype.forEachNode = function (callback, sequence, rowCount, deep) {
this.forEachNodeCallback(function (rowNode) {
callback(rowNode, sequence.next());
// this will only every happen for server side row model, as infinite
// row model doesn't have groups
if (deep && rowNode.childrenCache) {
rowNode.childrenCache.forEachNodeDeep(callback, sequence);
}
}, rowCount);
};
RowNodeBlock.prototype.forEachNodeDeep = function (callback, sequence, rowCount) {
this.forEachNode(callback, sequence, rowCount, true);
};
RowNodeBlock.prototype.forEachNodeShallow = function (callback, sequence, rowCount) {
this.forEachNode(callback, sequence, rowCount, false);
};
RowNodeBlock.prototype.getVersion = function () {
return this.version;
};
RowNodeBlock.prototype.getLastAccessed = function () {
return this.lastAccessed;
};
RowNodeBlock.prototype.getRowUsingLocalIndex = function (rowIndex, dontTouchLastAccessed) {
if (dontTouchLastAccessed === void 0) { dontTouchLastAccessed = false; }
if (!dontTouchLastAccessed) {
this.lastAccessed = this.rowNodeCacheParams.lastAccessedSequence.next();
}
var localIndex = rowIndex - this.startRow;
return this.rowNodes[localIndex];
};
RowNodeBlock.prototype.init = function (beans) {
this.beans = beans;
this.createRowNodes();
};
RowNodeBlock.prototype.getStartRow = function () {
return this.startRow;
};
RowNodeBlock.prototype.getEndRow = function () {
return this.endRow;
};
RowNodeBlock.prototype.getBlockNumber = function () {
return this.blockNumber;
};
RowNodeBlock.prototype.setDirty = function () {
// in case any current loads in progress, this will have their results ignored
this.version++;
this.state = RowNodeBlock.STATE_DIRTY;
};
RowNodeBlock.prototype.setDirtyAndPurge = function () {
this.setDirty();
this.rowNodes.forEach(function (rowNode) {
rowNode.setData(null);
});
};
RowNodeBlock.prototype.getState = function () {
return this.state;
};
RowNodeBlock.prototype.setRowNode = function (rowIndex, rowNode) {
var localIndex = rowIndex - this.startRow;
this.rowNodes[localIndex] = rowNode;
};
RowNodeBlock.prototype.setBlankRowNode = function (rowIndex) {
var localIndex = rowIndex - this.startRow;
var newRowNode = this.createBlankRowNode(rowIndex);
this.rowNodes[localIndex] = newRowNode;
return newRowNode;
};
RowNodeBlock.prototype.setNewData = function (rowIndex, dataItem) {
var newRowNode = this.setBlankRowNode(rowIndex);
this.setDataAndId(newRowNode, dataItem, this.startRow + rowIndex);
return newRowNode;
};
RowNodeBlock.prototype.createBlankRowNode = function (rowIndex) {
var rowNode = new RowNode();
this.beans.context.createBean(rowNode);
rowNode.setRowHeight(this.rowNodeCacheParams.rowHeight);
return rowNode;
};
// creates empty row nodes, data is missing as not loaded yet
RowNodeBlock.prototype.createRowNodes = function () {
this.rowNodes = [];
for (var i = 0; i < this.rowNodeCacheParams.blockSize; i++) {
var rowIndex = this.startRow + i;
var rowNode = this.createBlankRowNode(rowIndex);
this.rowNodes.push(rowNode);
}
};
RowNodeBlock.prototype.load = function () {
this.state = RowNodeBlock.STATE_LOADING;
this.loadFromDatasource();
};
RowNodeBlock.prototype.pageLoadFailed = function () {
this.state = RowNodeBlock.STATE_FAILED;
var event = {
type: RowNodeBlock.EVENT_LOAD_COMPLETE,
success: false,
page: this,
lastRow: null
};
this.dispatchEvent(event);
};
RowNodeBlock.prototype.populateWithRowData = function (rows) {
var _this = this;
var rowNodesToRefresh = [];
this.rowNodes.forEach(function (rowNode, index) {
var data = rows[index];
if (rowNode.stub) {
rowNodesToRefresh.push(rowNode);
}
_this.setDataAndId(rowNode, data, _this.startRow + index);
});
if (rowNodesToRefresh.length > 0) {
this.beans.rowRenderer.redrawRows(rowNodesToRefresh);
}
};
RowNodeBlock.prototype.destroyRowNodes = function () {
var _this = this;
this.rowNodes.forEach(function (rowNode) {
if (rowNode.childrenCache) {
_this.destroyBean(rowNode.childrenCache);
rowNode.childrenCache = null;
}
// this is needed, so row render knows to fade out the row, otherwise it
// sees row top is present, and thinks the row should be shown. maybe
// rowNode should have a flag on whether it is visible???
rowNode.clearRowTop();
});
};
RowNodeBlock.prototype.pageLoaded = function (version, rows, lastRow) {
// we need to check the version, in case there was an old request
// from the server that was sent before we refreshed the cache,
// if the load was done as a result of a cache refresh
if (version === this.version) {
this.state = RowNodeBlock.STATE_LOADED;
this.populateWithRowData(rows);
}
lastRow = cleanNumber(lastRow);
// check here if lastRow should be set
var event = {
type: RowNodeBlock.EVENT_LOAD_COMPLETE,
success: true,
page: this,
lastRow: lastRow
};
this.dispatchEvent(event);
};
RowNodeBlock.EVENT_LOAD_COMPLETE = 'loadComplete';
RowNodeBlock.STATE_DIRTY = 'dirty';
RowNodeBlock.STATE_LOADING = 'loading';
RowNodeBlock.STATE_LOADED = 'loaded';
RowNodeBlock.STATE_FAILED = 'failed';
__decorate$1V([
PreDestroy
], RowNodeBlock.prototype, "destroyRowNodes", null);
return RowNodeBlock;
}(BeanStub));
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v24.0.0
* @link http://www.ag-grid.com/
* @license MIT
*/
var __extends$1$ = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate$1W = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __param$9 = (undefined && undefined.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
var RowNodeBlockLoader = /** @class */ (function (_super) {
__extends$1$(RowNodeBlockLoader, _super);
function RowNodeBlockLoader(maxConcurrentRequests, blockLoadDebounceMillis) {
var _this = _super.call(this) || this;
_this.activeBlockLoadsCount = 0;
_this.blocks = [];
_this.active = true;
_this.maxConcurrentRequests = maxConcurrentRequests;
if (blockLoadDebounceMillis && blockLoadDebounceMillis > 0) {
_this.checkBlockToLoadDebounce = debounce(_this.performCheckBlocksToLoad.bind(_this), blockLoadDebounceMillis);
}
return _this;
}
RowNodeBlockLoader.prototype.setBeans = function (loggerFactory) {
this.logger = loggerFactory.create('RowNodeBlockLoader');
};
RowNodeBlockLoader.prototype.addBlock = function (block) {
this.blocks.push(block);
};
RowNodeBlockLoader.prototype.removeBlock = function (block) {
removeFromArray(this.blocks, block);
};
RowNodeBlockLoader.prototype.destroy = function () {
_super.prototype.destroy.call(this);
this.active = false;
};
RowNodeBlockLoader.prototype.loadComplete = function () {
this.activeBlockLoadsCount--;
};
RowNodeBlockLoader.prototype.checkBlockToLoad = function () {
if (this.checkBlockToLoadDebounce) {
this.checkBlockToLoadDebounce();
}
else {
this.performCheckBlocksToLoad();
}
};
RowNodeBlockLoader.prototype.performCheckBlocksToLoad = function () {
if (!this.active) {
return;
}
this.printCacheStatus();
if (this.activeBlockLoadsCount >= this.maxConcurrentRequests) {
this.logger.log("checkBlockToLoad: max loads exceeded");
return;
}
var blockToLoad = null;
this.blocks.forEach(function (block) {
if (block.getState() === RowNodeBlock.STATE_DIRTY) {
blockToLoad = block;
}
});
if (blockToLoad) {
blockToLoad.load();
this.activeBlockLoadsCount++;
this.logger.log("checkBlockToLoad: loading page " + blockToLoad.getBlockNumber());
this.printCacheStatus();
}
else {
this.logger.log("checkBlockToLoad: no pages to load");
}
};
RowNodeBlockLoader.prototype.getBlockState = function () {
var result = {};
this.blocks.forEach(function (block) {
var nodeIdPrefix = block.getNodeIdPrefix();
var stateItem = {
blockNumber: block.getBlockNumber(),
startRow: block.getStartRow(),
endRow: block.getEndRow(),
pageStatus: block.getState()
};
if (exists(nodeIdPrefix)) {
result[nodeIdPrefix + block.getBlockNumber()] = stateItem;
}
else {
result[block.getBlockNumber()] = stateItem;
}
});
return result;
};
RowNodeBlockLoader.prototype.printCacheStatus = function () {
if (this.logger.isLogging()) {
this.logger.log("printCacheStatus: activePageLoadsCount = " + this.activeBlockLoadsCount + ","
+ (" blocks = " + JSON.stringify(this.getBlockState())));
}
};
RowNodeBlockLoader.prototype.isLoading = function () {
return this.activeBlockLoadsCount > 0;
};
__decorate$1W([
__param$9(0, Qualifier('loggerFactory'))
], RowNodeBlockLoader.prototype, "setBeans", null);
return RowNodeBlockLoader;
}(BeanStub));
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v24.0.0
* @link http://www.ag-grid.com/
* @license MIT
*/
var __extends$20 = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate$1X = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var RowNodeCache = /** @class */ (function (_super) {
__extends$20(RowNodeCache, _super);
function RowNodeCache(cacheParams) {
var _this = _super.call(this) || this;
_this.maxRowFound = false;
_this.blocks = {};
_this.blockCount = 0;
_this.virtualRowCount = cacheParams.initialRowCount;
_this.cacheParams = cacheParams;
return _this;
}
RowNodeCache.prototype.destroyAllBlocks = function () {
var _this = this;
this.forEachBlockInOrder(function (block) { return _this.destroyBlock(block); });
};
RowNodeCache.prototype.init = function () {
var _this = this;
this.active = true;
this.addDestroyFunc(function () { return _this.active = false; });
};
RowNodeCache.prototype.isActive = function () {
return this.active;
};
RowNodeCache.prototype.getVirtualRowCount = function () {
return this.virtualRowCount;
};
RowNodeCache.prototype.hack_setVirtualRowCount = function (virtualRowCount) {
this.virtualRowCount = virtualRowCount;
};
RowNodeCache.prototype.isMaxRowFound = function () {
return this.maxRowFound;
};
// listener on EVENT_LOAD_COMPLETE
RowNodeCache.prototype.onPageLoaded = function (event) {
this.cacheParams.rowNodeBlockLoader.loadComplete();
this.checkBlockToLoad();
// if we are not active, then we ignore all events, otherwise we could end up getting the
// grid to refresh even though we are no longer the active cache
if (!this.isActive()) {
return;
}
this.logger.log("onPageLoaded: page = " + event.page.getBlockNumber() + ", lastRow = " + event.lastRow);
if (event.success) {
this.checkVirtualRowCount(event.page, event.lastRow);
this.onCacheUpdated();
}
};
RowNodeCache.prototype.purgeBlocksIfNeeded = function (blockToExclude) {
var _this = this;
// put all candidate blocks into a list for sorting
var blocksForPurging = [];
this.forEachBlockInOrder(function (block) {
// we exclude checking for the page just created, as this has yet to be accessed and hence
// the lastAccessed stamp will not be updated for the first time yet
if (block === blockToExclude) {
return;
}
blocksForPurging.push(block);
});
// note: need to verify that this sorts items in the right order
blocksForPurging.sort(function (a, b) { return b.getLastAccessed() - a.getLastAccessed(); });
// we remove (maxBlocksInCache - 1) as we already excluded the 'just created' page.
// in other words, after the splice operation below, we have taken out the blocks
// we want to keep, which means we are left with blocks that we can potentially purge
var maxBlocksProvided = this.cacheParams.maxBlocksInCache > 0;
var blocksToKeep = maxBlocksProvided ? this.cacheParams.maxBlocksInCache - 1 : null;
var emptyBlocksToKeep = RowNodeCache.MAX_EMPTY_BLOCKS_TO_KEEP - 1;
blocksForPurging.forEach(function (block, index) {
var purgeBecauseBlockEmpty = block.getState() === RowNodeBlock.STATE_DIRTY && index >= emptyBlocksToKeep;
var purgeBecauseCacheFull = maxBlocksProvided ? index >= blocksToKeep : false;
if (purgeBecauseBlockEmpty || purgeBecauseCacheFull) {
// we never purge blocks if they are open, as purging them would mess up with
// our indexes, it would be very messy to restore the purged block to it's
// previous state if it had open children (and what if open children of open
// children, jeeeesus, just thinking about it freaks me out) so best is have a
// rule, if block is open, we never purge.
if (block.isAnyNodeOpen(_this.virtualRowCount)) {
return;
}
// if the block currently has rows been displayed, then don't remove it either.
// this can happen if user has maxBlocks=2, and blockSize=5 (thus 10 max rows in cache)
// but the screen is showing 20 rows, so at least 4 blocks are needed.
if (_this.isBlockCurrentlyDisplayed(block)) {
return;
}
// at this point, block is not needed, and no open nodes, so burn baby burn
_this.removeBlockFromCache(block);
}
});
};
RowNodeCache.prototype.isBlockCurrentlyDisplayed = function (block) {
var firstViewportRow = this.rowRenderer.getFirstVirtualRenderedRow();
var lastViewportRow = this.rowRenderer.getLastVirtualRenderedRow();
var firstRowIndex = block.getDisplayIndexStart();
var lastRowIndex = block.getDisplayIndexEnd() - 1;
// parent closed means the parent node is not expanded, thus these blocks are not visible
var parentClosed = firstRowIndex == null || lastRowIndex == null;
if (parentClosed) {
return false;
}
var blockBeforeViewport = firstRowIndex > lastViewportRow;
var blockAfterViewport = lastRowIndex < firstViewportRow;
var blockInsideViewport = !blockBeforeViewport && !blockAfterViewport;
return blockInsideViewport;
};
RowNodeCache.prototype.postCreateBlock = function (newBlock) {
newBlock.addEventListener(RowNodeBlock.EVENT_LOAD_COMPLETE, this.onPageLoaded.bind(this));
this.setBlock(newBlock.getBlockNumber(), newBlock);
this.purgeBlocksIfNeeded(newBlock);
this.checkBlockToLoad();
};
RowNodeCache.prototype.removeBlockFromCache = function (blockToRemove) {
if (!blockToRemove) {
return;
}
this.destroyBlock(blockToRemove);
// we do not want to remove the 'loaded' event listener, as the
// concurrent loads count needs to be updated when the load is complete
// if the purged page is in loading state
};
// gets called after: 1) block loaded 2) block created 3) cache refresh
RowNodeCache.prototype.checkBlockToLoad = function () {
this.cacheParams.rowNodeBlockLoader.checkBlockToLoad();
};
RowNodeCache.prototype.checkVirtualRowCount = function (block, lastRow) {
// if client provided a last row, we always use it, as it could change between server calls
// if user deleted data and then called refresh on the grid.
if (typeof lastRow === 'number' && lastRow >= 0) {
this.virtualRowCount = lastRow;
this.maxRowFound = true;
}
else if (!this.maxRowFound) {
// otherwise, see if we need to add some virtual rows
var lastRowIndex = (block.getBlockNumber() + 1) * this.cacheParams.blockSize;
var lastRowIndexPlusOverflow = lastRowIndex + this.cacheParams.overflowSize;
if (this.virtualRowCount < lastRowIndexPlusOverflow) {
this.virtualRowCount = lastRowIndexPlusOverflow;
}
}
};
RowNodeCache.prototype.setVirtualRowCount = function (rowCount, maxRowFound) {
this.virtualRowCount = rowCount;
// if undefined is passed, we do not set this value, if one of {true,false}
// is passed, we do set the value.
if (exists(maxRowFound)) {
this.maxRowFound = maxRowFound;
}
// if we are still searching, then the row count must not end at the end
// of a particular page, otherwise the searching will not pop into the
// next page
if (!this.maxRowFound) {
if (this.virtualRowCount % this.cacheParams.blockSize === 0) {
this.virtualRowCount++;
}
}
this.onCacheUpdated();
};
RowNodeCache.prototype.forEachNodeDeep = function (callback, sequence) {
var _this = this;
if (sequence === void 0) { sequence = new NumberSequence(); }
this.forEachBlockInOrder(function (block) {
block.forEachNodeDeep(callback, sequence, _this.virtualRowCount);
});
};
RowNodeCache.prototype.forEachBlockInOrder = function (callback) {
var ids = this.getBlockIdsSorted();
this.forEachBlockId(ids, callback);
};
RowNodeCache.prototype.forEachBlockInReverseOrder = function (callback) {
var ids = this.getBlockIdsSorted().reverse();
this.forEachBlockId(ids, callback);
};
RowNodeCache.prototype.forEachBlockId = function (ids, callback) {
var _this = this;
ids.forEach(function (id) {
var block = _this.blocks[id];
callback(block, id);
});
};
RowNodeCache.prototype.getBlockIdsSorted = function () {
// get all page id's as NUMBERS (not strings, as we need to sort as numbers) and in descending order
var numberComparator = function (a, b) { return a - b; }; // default comparator for array is string comparison
var blockIds = Object.keys(this.blocks).map(function (idStr) { return parseInt(idStr, 10); }).sort(numberComparator);
return blockIds;
};
RowNodeCache.prototype.getBlock = function (blockId) {
return this.blocks[blockId];
};
RowNodeCache.prototype.setBlock = function (id, block) {
this.blocks[id] = block;
this.blockCount++;
this.cacheParams.rowNodeBlockLoader.addBlock(block);
};
RowNodeCache.prototype.destroyBlock = function (block) {
delete this.blocks[block.getBlockNumber()];
this.destroyBean(block);
this.blockCount--;
this.cacheParams.rowNodeBlockLoader.removeBlock(block);
};
// gets called 1) row count changed 2) cache purged 3) items inserted
RowNodeCache.prototype.onCacheUpdated = function () {
if (this.isActive()) {
// if the virtualRowCount is shortened, then it's possible blocks exist that are no longer
// in the valid range. so we must remove these. this can happen if user explicitly sets
// the virtual row count, or the datasource returns a result and sets lastRow to something
// less than virtualRowCount (can happen if user scrolls down, server reduces dataset size).
this.destroyAllBlocksPastVirtualRowCount();
// this results in both row models (infinite and server side) firing ModelUpdated,
// however server side row model also updates the row indexes first
var event_1 = {
type: RowNodeCache.EVENT_CACHE_UPDATED
};
this.dispatchEvent(event_1);
}
};
RowNodeCache.prototype.destroyAllBlocksPastVirtualRowCount = function () {
var _this = this;
var blocksToDestroy = [];
this.forEachBlockInOrder(function (block, id) {
var startRow = id * _this.cacheParams.blockSize;
if (startRow >= _this.virtualRowCount) {
blocksToDestroy.push(block);
}
});
if (blocksToDestroy.length > 0) {
blocksToDestroy.forEach(function (block) { return _this.destroyBlock(block); });
}
};
RowNodeCache.prototype.purgeCache = function () {
var _this = this;
this.forEachBlockInOrder(function (block) { return _this.removeBlockFromCache(block); });
this.maxRowFound = false;
// if zero rows in the cache, we need to get the SSRM to start asking for rows again.
// otherwise if set to zero rows last time, and we don't update the row count, then after
// the purge there will still be zero rows, meaning the SRRM won't request any rows.
// to kick things off, at lest one row needs to be asked for.
if (this.virtualRowCount === 0) {
this.virtualRowCount = this.cacheParams.initialRowCount;
}
this.onCacheUpdated();
};
RowNodeCache.prototype.getRowNodesInRange = function (firstInRange, lastInRange) {
var _this = this;
var result = [];
var lastBlockId = -1;
var inActiveRange = false;
var numberSequence = new NumberSequence();
// if only one node passed, we start the selection at the top
if (missing(firstInRange)) {
inActiveRange = true;
}
var foundGapInSelection = false;
this.forEachBlockInOrder(function (block, id) {
if (foundGapInSelection) {
return;
}
if (inActiveRange && (lastBlockId + 1 !== id)) {
foundGapInSelection = true;
return;
}
lastBlockId = id;
block.forEachNodeShallow(function (rowNode) {
var hitFirstOrLast = rowNode === firstInRange || rowNode === lastInRange;
if (inActiveRange || hitFirstOrLast) {
result.push(rowNode);
}
if (hitFirstOrLast) {
inActiveRange = !inActiveRange;
}
}, numberSequence, _this.virtualRowCount);
});
// inActiveRange will be still true if we never hit the second rowNode
var invalidRange = foundGapInSelection || inActiveRange;
return invalidRange ? [] : result;
};
RowNodeCache.EVENT_CACHE_UPDATED = 'cacheUpdated';
// this property says how many empty blocks should be in a cache, eg if scrolls down fast and creates 10
// blocks all for loading, the grid will only load the last 2 - it will assume the blocks the user quickly
// scrolled over are not needed to be loaded.
RowNodeCache.MAX_EMPTY_BLOCKS_TO_KEEP = 2;
__decorate$1X([
Autowired('rowRenderer')
], RowNodeCache.prototype, "rowRenderer", void 0);
__decorate$1X([
PreDestroy
], RowNodeCache.prototype, "destroyAllBlocks", null);
__decorate$1X([
PostConstruct
], RowNodeCache.prototype, "init", null);
return RowNodeCache;
}(BeanStub));
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v24.0.0
* @link http://www.ag-grid.com/
* @license MIT
*/
var __extends$21 = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate$1Y = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var VirtualList = /** @class */ (function (_super) {
__extends$21(VirtualList, _super);
function VirtualList(cssIdentifier) {
if (cssIdentifier === void 0) { cssIdentifier = 'default'; }
var _this = _super.call(this, VirtualList.getTemplate(cssIdentifier), true) || this;
_this.cssIdentifier = cssIdentifier;
_this.renderedRows = new Map();
_this.rowHeight = 20;
_this.isDestroyed = false;
return _this;
}
VirtualList.prototype.postConstruct = function () {
this.addScrollListener();
this.rowHeight = this.getItemHeight();
_super.prototype.postConstruct.call(this);
};
VirtualList.prototype.focusInnerElement = function (fromBottom) {
this.focusRow(fromBottom ? this.model.getRowCount() - 1 : 0);
};
VirtualList.prototype.onFocusIn = function (e) {
_super.prototype.onFocusIn.call(this, e);
var target = e.target;
if (containsClass(target, 'ag-virtual-list-item')) {
this.lastFocusedRowIndex = getAriaPosInSet(target) - 1;
}
};
VirtualList.prototype.onFocusOut = function (e) {
_super.prototype.onFocusOut.call(this, e);
if (!this.getFocusableElement().contains(e.relatedTarget)) {
this.lastFocusedRowIndex = null;
}
};
VirtualList.prototype.handleKeyDown = function (e) {
switch (e.keyCode) {
case KeyCode.UP:
case KeyCode.DOWN:
if (this.navigate(e.keyCode === KeyCode.UP)) {
e.preventDefault();
}
break;
}
};
VirtualList.prototype.onTabKeyDown = function (e) {
if (this.navigate(e.shiftKey)) {
e.preventDefault();
}
else {
// focus on the first or last focusable element to ensure that any other handlers start from there
this.focusController.focusInto(this.getGui(), !e.shiftKey);
}
};
VirtualList.prototype.navigate = function (up) {
if (this.lastFocusedRowIndex == null) {
return false;
}
var nextRow = this.lastFocusedRowIndex + (up ? -1 : 1);
if (nextRow < 0 || nextRow >= this.model.getRowCount()) {
return false;
}
this.focusRow(nextRow);
return true;
};
VirtualList.prototype.getLastFocusedRow = function () {
return this.lastFocusedRowIndex;
};
VirtualList.prototype.focusRow = function (rowNumber) {
var _this = this;
this.ensureIndexVisible(rowNumber);
window.setTimeout(function () {
var renderedRow = _this.renderedRows.get(rowNumber);
if (renderedRow) {
renderedRow.eDiv.focus();
}
}, 10);
};
VirtualList.prototype.getComponentAt = function (rowIndex) {
var comp = this.renderedRows.get(rowIndex);
return comp && comp.rowComponent;
};
VirtualList.getTemplate = function (cssIdentifier) {
return /* html */ "\n
";
};
VirtualList.prototype.getItemHeight = function () {
return this.gridOptionsWrapper.getListItemHeight();
};
VirtualList.prototype.ensureIndexVisible = function (index) {
var lastRow = this.model.getRowCount();
if (typeof index !== 'number' || index < 0 || index >= lastRow) {
console.warn('invalid row index for ensureIndexVisible: ' + index);
return;
}
var rowTopPixel = index * this.rowHeight;
var rowBottomPixel = rowTopPixel + this.rowHeight;
var eGui = this.getGui();
var viewportTopPixel = eGui.scrollTop;
var viewportHeight = eGui.offsetHeight;
var viewportBottomPixel = viewportTopPixel + viewportHeight;
var viewportScrolledPastRow = viewportTopPixel > rowTopPixel;
var viewportScrolledBeforeRow = viewportBottomPixel < rowBottomPixel;
if (viewportScrolledPastRow) {
// if row is before, scroll up with row at top
eGui.scrollTop = rowTopPixel;
}
else if (viewportScrolledBeforeRow) {
// if row is below, scroll down with row at bottom
var newScrollPosition = rowBottomPixel - viewportHeight;
eGui.scrollTop = newScrollPosition;
}
};
VirtualList.prototype.setComponentCreator = function (componentCreator) {
this.componentCreator = componentCreator;
};
VirtualList.prototype.getRowHeight = function () {
return this.rowHeight;
};
VirtualList.prototype.getScrollTop = function () {
return this.getGui().scrollTop;
};
VirtualList.prototype.setRowHeight = function (rowHeight) {
this.rowHeight = rowHeight;
this.refresh();
};
VirtualList.prototype.refresh = function () {
var _this = this;
if (this.model == null || this.isDestroyed) {
return;
}
var rowCount = this.model.getRowCount();
this.eContainer.style.height = rowCount * this.rowHeight + "px";
// ensure height is applied before attempting to redraw rows
setTimeout(function () {
if (_this.isDestroyed) {
return;
}
_this.clearVirtualRows();
_this.drawVirtualRows();
}, 0);
};
VirtualList.prototype.clearVirtualRows = function () {
var _this = this;
this.renderedRows.forEach(function (_, rowIndex) { return _this.removeRow(rowIndex); });
};
VirtualList.prototype.drawVirtualRows = function () {
var gui = this.getGui();
var topPixel = gui.scrollTop;
var bottomPixel = topPixel + gui.offsetHeight;
var firstRow = Math.floor(topPixel / this.rowHeight);
var lastRow = Math.floor(bottomPixel / this.rowHeight);
this.ensureRowsRendered(firstRow, lastRow);
};
VirtualList.prototype.ensureRowsRendered = function (start, finish) {
var _this = this;
// remove any rows that are no longer required
this.renderedRows.forEach(function (_, rowIndex) {
if ((rowIndex < start || rowIndex > finish) && rowIndex !== _this.lastFocusedRowIndex) {
_this.removeRow(rowIndex);
}
});
// insert any required new rows
for (var rowIndex = start; rowIndex <= finish; rowIndex++) {
if (this.renderedRows.has(rowIndex)) {
continue;
}
// check this row actually exists (in case overflow buffer window exceeds real data)
if (rowIndex < this.model.getRowCount()) {
this.insertRow(rowIndex);
}
}
};
VirtualList.prototype.insertRow = function (rowIndex) {
var _this = this;
var value = this.model.getRow(rowIndex);
var eDiv = document.createElement('div');
addCssClass(eDiv, 'ag-virtual-list-item');
addCssClass(eDiv, "ag-" + this.cssIdentifier + "-virtual-list-item");
eDiv.setAttribute('role', 'option');
setAriaSetSize(eDiv, this.model.getRowCount());
setAriaPosInSet(eDiv, rowIndex + 1);
eDiv.setAttribute('tabindex', '-1');
if (typeof this.model.isRowSelected === 'function') {
var isSelected = this.model.isRowSelected(rowIndex);
setAriaSelected(eDiv, !!isSelected);
setAriaChecked(eDiv, isSelected);
}
eDiv.style.height = this.rowHeight + "px";
eDiv.style.top = this.rowHeight * rowIndex + "px";
var rowComponent = this.componentCreator(value);
rowComponent.addGuiEventListener('focusin', function () { return _this.lastFocusedRowIndex = rowIndex; });
eDiv.appendChild(rowComponent.getGui());
// keep the DOM order consistent with the order of the rows
if (this.renderedRows.has(rowIndex - 1)) {
this.renderedRows.get(rowIndex - 1).eDiv.insertAdjacentElement('afterend', eDiv);
}
else if (this.renderedRows.has(rowIndex + 1)) {
this.renderedRows.get(rowIndex + 1).eDiv.insertAdjacentElement('beforebegin', eDiv);
}
else {
this.eContainer.appendChild(eDiv);
}
this.renderedRows.set(rowIndex, { rowComponent: rowComponent, eDiv: eDiv });
};
VirtualList.prototype.removeRow = function (rowIndex) {
var component = this.renderedRows.get(rowIndex);
this.eContainer.removeChild(component.eDiv);
this.destroyBean(component.rowComponent);
this.renderedRows.delete(rowIndex);
};
VirtualList.prototype.addScrollListener = function () {
var _this = this;
this.addGuiEventListener('scroll', function () { return _this.drawVirtualRows(); });
};
VirtualList.prototype.setModel = function (model) {
this.model = model;
};
VirtualList.prototype.destroy = function () {
if (this.isDestroyed) {
return;
}
this.clearVirtualRows();
this.isDestroyed = true;
_super.prototype.destroy.call(this);
};
__decorate$1Y([
Autowired('gridOptionsWrapper')
], VirtualList.prototype, "gridOptionsWrapper", void 0);
__decorate$1Y([
RefSelector('eContainer')
], VirtualList.prototype, "eContainer", void 0);
return VirtualList;
}(ManagedFocusComponent));
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v24.0.0
* @link http://www.ag-grid.com/
* @license MIT
*/
function defaultGroupComparator(valueA, valueB, nodeA, nodeB, accentedCompare) {
if (accentedCompare === void 0) { accentedCompare = false; }
console.warn('ag-Grid: Since ag-grid 11.0.0 defaultGroupComparator is not necessary. You can remove this from your colDef');
var nodeAIsGroup = exists(nodeA) && nodeA.group;
var nodeBIsGroup = exists(nodeB) && nodeB.group;
var bothAreGroups = nodeAIsGroup && nodeBIsGroup;
var bothAreNormal = !nodeAIsGroup && !nodeBIsGroup;
if (bothAreGroups) {
return defaultComparator(nodeA.key, nodeB.key, accentedCompare);
}
if (bothAreNormal) {
return defaultComparator(valueA, valueB, accentedCompare);
}
if (nodeAIsGroup) {
return 1;
}
return -1;
}
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v24.0.0
* @link http://www.ag-grid.com/
* @license MIT
*/
var BaseComponentWrapper = /** @class */ (function () {
function BaseComponentWrapper() {
}
BaseComponentWrapper.prototype.wrap = function (OriginalConstructor, mandatoryMethodList, optionalMethodList, componentType, componentName) {
var _this = this;
if (optionalMethodList === void 0) { optionalMethodList = []; }
var wrapper = this.createWrapper(OriginalConstructor, componentType, componentName);
mandatoryMethodList.forEach((function (methodName) {
_this.createMethod(wrapper, methodName, true);
}));
optionalMethodList.forEach((function (methodName) {
_this.createMethod(wrapper, methodName, false);
}));
return wrapper;
};
BaseComponentWrapper.prototype.createMethod = function (wrapper, methodName, mandatory) {
wrapper.addMethod(methodName, this.createMethodProxy(wrapper, methodName, mandatory));
};
BaseComponentWrapper.prototype.createMethodProxy = function (wrapper, methodName, mandatory) {
return function () {
if (wrapper.hasMethod(methodName)) {
return wrapper.callMethod(methodName, arguments);
}
if (mandatory) {
console.warn('ag-Grid: Framework component is missing the method ' + methodName + '()');
}
return null;
};
};
return BaseComponentWrapper;
}());
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v24.0.0
* @link http://www.ag-grid.com/
* @license MIT
*/
(function (ChartType) {
ChartType["GroupedColumn"] = "groupedColumn";
ChartType["StackedColumn"] = "stackedColumn";
ChartType["NormalizedColumn"] = "normalizedColumn";
ChartType["GroupedBar"] = "groupedBar";
ChartType["StackedBar"] = "stackedBar";
ChartType["NormalizedBar"] = "normalizedBar";
ChartType["Line"] = "line";
ChartType["Scatter"] = "scatter";
ChartType["Bubble"] = "bubble";
ChartType["Pie"] = "pie";
ChartType["Doughnut"] = "doughnut";
ChartType["Area"] = "area";
ChartType["StackedArea"] = "stackedArea";
ChartType["NormalizedArea"] = "normalizedArea";
ChartType["Histogram"] = "histogram";
})(exports.ChartType || (exports.ChartType = {}));
(function (LegendPosition) {
LegendPosition["Top"] = "top";
LegendPosition["Right"] = "right";
LegendPosition["Bottom"] = "bottom";
LegendPosition["Left"] = "left";
})(exports.LegendPosition || (exports.LegendPosition = {}));
/**
* @ag-grid-community/core - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
* @version v24.0.0
* @link http://www.ag-grid.com/
* @license MIT
*/
var globalObj = typeof global === 'undefined' ? {} : global;
globalObj.HTMLElement = typeof HTMLElement === 'undefined' ? {} : HTMLElement;
globalObj.HTMLButtonElement = typeof HTMLButtonElement === 'undefined' ? {} : HTMLButtonElement;
globalObj.HTMLSelectElement = typeof HTMLSelectElement === 'undefined' ? {} : HTMLSelectElement;
globalObj.HTMLInputElement = typeof HTMLInputElement === 'undefined' ? {} : HTMLInputElement;
globalObj.Node = typeof Node === 'undefined' ? {} : Node;
globalObj.MouseEvent = typeof MouseEvent === 'undefined' ? {} : MouseEvent;
var ClientSideNodeManager = /** @class */ (function () {
function ClientSideNodeManager(rootNode, gridOptionsWrapper, context, eventService, columnController, gridApi, columnApi, selectionController) {
this.nextId = 0;
// when user is provide the id's, we also keep a map of ids to row nodes for convenience
this.allNodesMap = {};
this.rootNode = rootNode;
this.gridOptionsWrapper = gridOptionsWrapper;
this.context = context;
this.eventService = eventService;
this.columnController = columnController;
this.gridApi = gridApi;
this.columnApi = columnApi;
this.selectionController = selectionController;
this.rootNode.group = true;
this.rootNode.level = -1;
this.rootNode.id = ClientSideNodeManager.ROOT_NODE_ID;
this.rootNode.allLeafChildren = [];
this.rootNode.childrenAfterGroup = [];
this.rootNode.childrenAfterSort = [];
this.rootNode.childrenAfterFilter = [];
// if we make this class a bean, then can annotate postConstruct
this.postConstruct();
}
// @PostConstruct - this is not a bean, so postConstruct called by constructor
ClientSideNodeManager.prototype.postConstruct = function () {
// func below doesn't have 'this' pointer, so need to pull out these bits
this.suppressParentsInRowNodes = this.gridOptionsWrapper.isSuppressParentsInRowNodes();
this.isRowMasterFunc = this.gridOptionsWrapper.getIsRowMasterFunc();
this.doingTreeData = this.gridOptionsWrapper.isTreeData();
this.doingMasterDetail = this.gridOptionsWrapper.isMasterDetail();
};
ClientSideNodeManager.prototype.getCopyOfNodesMap = function () {
return _.cloneObject(this.allNodesMap);
};
ClientSideNodeManager.prototype.getRowNode = function (id) {
return this.allNodesMap[id];
};
ClientSideNodeManager.prototype.setRowData = function (rowData) {
this.rootNode.childrenAfterFilter = null;
this.rootNode.childrenAfterGroup = null;
this.rootNode.childrenAfterSort = null;
this.rootNode.childrenMapped = null;
this.rootNode.updateHasChildren();
this.nextId = 0;
this.allNodesMap = {};
if (!rowData) {
this.rootNode.allLeafChildren = [];
this.rootNode.childrenAfterGroup = [];
return;
}
// kick off recursion
// we add rootNode as the parent, however if using ag-grid-enterprise, the grouping stage
// sets the parent node on each row (even if we are not grouping). so setting parent node
// here is for benefit of ag-grid-community users
this.rootNode.allLeafChildren = this.recursiveFunction(rowData, this.rootNode, ClientSideNodeManager.TOP_LEVEL);
};
ClientSideNodeManager.prototype.updateRowData = function (rowDataTran, rowNodeOrder) {
var rowNodeTransaction = {
remove: [],
update: [],
add: []
};
var nodesToUnselect = [];
this.executeAdd(rowDataTran, rowNodeTransaction);
this.executeRemove(rowDataTran, rowNodeTransaction, nodesToUnselect);
this.executeUpdate(rowDataTran, rowNodeTransaction, nodesToUnselect);
this.updateSelection(nodesToUnselect);
if (rowNodeOrder) {
_.sortRowNodesByOrder(this.rootNode.allLeafChildren, rowNodeOrder);
}
return rowNodeTransaction;
};
ClientSideNodeManager.prototype.updateSelection = function (nodesToUnselect) {
var selectionChanged = nodesToUnselect.length > 0;
if (selectionChanged) {
nodesToUnselect.forEach(function (rowNode) {
rowNode.setSelected(false, false, true);
});
}
// we do this regardless of nodes to unselect or not, as it's possible
// a new node was inserted, so a parent that was previously selected (as all
// children were selected) should not be tri-state (as new one unselected against
// all other selected children).
this.selectionController.updateGroupsFromChildrenSelections();
if (selectionChanged) {
var event_1 = {
type: Events.EVENT_SELECTION_CHANGED,
api: this.gridApi,
columnApi: this.columnApi
};
this.eventService.dispatchEvent(event_1);
}
};
ClientSideNodeManager.prototype.executeAdd = function (rowDataTran, rowNodeTransaction) {
var _this = this;
var add = rowDataTran.add, addIndex = rowDataTran.addIndex;
if (_.missingOrEmpty(add)) {
return;
}
var useIndex = typeof addIndex === 'number' && addIndex >= 0;
if (useIndex) {
// items get inserted in reverse order for index insertion
add.reverse().forEach(function (item) {
var newRowNode = _this.addRowNode(item, addIndex);
rowNodeTransaction.add.push(newRowNode);
});
}
else {
add.forEach(function (item) {
var newRowNode = _this.addRowNode(item);
rowNodeTransaction.add.push(newRowNode);
});
}
};
ClientSideNodeManager.prototype.executeRemove = function (rowDataTran, rowNodeTransaction, nodesToUnselect) {
var _this = this;
var remove = rowDataTran.remove;
if (_.missingOrEmpty(remove)) {
return;
}
var rowIdsRemoved = {};
remove.forEach(function (item) {
var rowNode = _this.lookupRowNode(item);
if (!rowNode) {
return;
}
// do delete - setting 'suppressFinishActions = true' to ensure EVENT_SELECTION_CHANGED is not raised for
// each row node updated, instead it is raised once by the calling code if any selected nodes exist.
if (rowNode.isSelected()) {
nodesToUnselect.push(rowNode);
}
// so row renderer knows to fade row out (and not reposition it)
rowNode.clearRowTop();
// NOTE: were we could remove from allLeaveChildren, however _.removeFromArray() is expensive, especially
// if called multiple times (eg deleting lots of rows) and if allLeafChildren is a large list
rowIdsRemoved[rowNode.id] = true;
// _.removeFromArray(this.rootNode.allLeafChildren, rowNode);
delete _this.allNodesMap[rowNode.id];
rowNodeTransaction.remove.push(rowNode);
});
this.rootNode.allLeafChildren = this.rootNode.allLeafChildren.filter(function (rowNode) { return !rowIdsRemoved[rowNode.id]; });
};
ClientSideNodeManager.prototype.executeUpdate = function (rowDataTran, rowNodeTransaction, nodesToUnselect) {
var _this = this;
var update = rowDataTran.update;
if (_.missingOrEmpty(update)) {
return;
}
update.forEach(function (item) {
var rowNode = _this.lookupRowNode(item);
if (!rowNode) {
return;
}
rowNode.updateData(item);
if (!rowNode.selectable && rowNode.isSelected()) {
nodesToUnselect.push(rowNode);
}
_this.setMasterForRow(rowNode, item, ClientSideNodeManager.TOP_LEVEL, false);
rowNodeTransaction.update.push(rowNode);
});
};
ClientSideNodeManager.prototype.addRowNode = function (data, index) {
var newNode = this.createNode(data, this.rootNode, ClientSideNodeManager.TOP_LEVEL);
if (_.exists(index)) {
_.insertIntoArray(this.rootNode.allLeafChildren, newNode, index);
}
else {
this.rootNode.allLeafChildren.push(newNode);
}
return newNode;
};
ClientSideNodeManager.prototype.lookupRowNode = function (data) {
var rowNodeIdFunc = this.gridOptionsWrapper.getRowNodeIdFunc();
var rowNode;
if (_.exists(rowNodeIdFunc)) {
// find rowNode using id
var id = rowNodeIdFunc(data);
rowNode = this.allNodesMap[id];
if (!rowNode) {
console.error("ag-Grid: could not find row id=" + id + ", data item was not found for this id");
return null;
}
}
else {
// find rowNode using object references
rowNode = _.find(this.rootNode.allLeafChildren, function (rowNode) { return rowNode.data === data; });
if (!rowNode) {
console.error("ag-Grid: could not find data item as object was not found", data);
return null;
}
}
return rowNode;
};
ClientSideNodeManager.prototype.recursiveFunction = function (rowData, parent, level) {
var _this = this;
// make sure the rowData is an array and not a string of json - this was a commonly reported problem on the forum
if (typeof rowData === 'string') {
console.warn('ag-Grid: rowData must be an array, however you passed in a string. If you are loading JSON, make sure you convert the JSON string to JavaScript objects first');
return;
}
var rowNodes = [];
rowData.forEach(function (dataItem) {
var node = _this.createNode(dataItem, parent, level);
rowNodes.push(node);
});
return rowNodes;
};
ClientSideNodeManager.prototype.createNode = function (dataItem, parent, level) {
var node = new RowNode();
this.context.createBean(node);
node.group = false;
this.setMasterForRow(node, dataItem, level, true);
if (parent && !this.suppressParentsInRowNodes) {
node.parent = parent;
}
node.level = level;
node.setDataAndId(dataItem, this.nextId.toString());
if (this.allNodesMap[node.id]) {
console.warn("ag-grid: duplicate node id '" + node.id + "' detected from getRowNodeId callback, this could cause issues in your grid.");
}
this.allNodesMap[node.id] = node;
this.nextId++;
return node;
};
ClientSideNodeManager.prototype.setMasterForRow = function (rowNode, data, level, setExpanded) {
if (this.doingTreeData) {
rowNode.setMaster(false);
if (setExpanded) {
rowNode.expanded = false;
}
}
else {
// this is the default, for when doing grid data
if (this.doingMasterDetail) {
// if we are doing master detail, then the
// default is that everything can be a Master Row.
if (this.isRowMasterFunc) {
rowNode.setMaster(this.isRowMasterFunc(data));
}
else {
rowNode.setMaster(true);
}
}
else {
rowNode.setMaster(false);
}
if (setExpanded) {
var rowGroupColumns = this.columnController.getRowGroupColumns();
var numRowGroupColumns = rowGroupColumns ? rowGroupColumns.length : 0;
// need to take row group into account when determining level
var masterRowLevel = level + numRowGroupColumns;
rowNode.expanded = rowNode.master ? this.isExpanded(masterRowLevel) : false;
}
}
};
ClientSideNodeManager.prototype.isExpanded = function (level) {
var expandByDefault = this.gridOptionsWrapper.getGroupDefaultExpanded();
if (expandByDefault === -1) {
return true;
}
else {
return level < expandByDefault;
}
};
// this is only used for doing legacy tree data
ClientSideNodeManager.prototype.setLeafChildren = function (node) {
node.allLeafChildren = [];
if (node.childrenAfterGroup) {
node.childrenAfterGroup.forEach(function (childAfterGroup) {
if (childAfterGroup.group) {
if (childAfterGroup.allLeafChildren) {
childAfterGroup.allLeafChildren.forEach(function (leafChild) { return node.allLeafChildren.push(leafChild); });
}
}
else {
node.allLeafChildren.push(childAfterGroup);
}
});
}
};
ClientSideNodeManager.TOP_LEVEL = 0;
ClientSideNodeManager.ROOT_NODE_ID = 'ROOT_NODE_ID';
return ClientSideNodeManager;
}());
var __extends$22 = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate$1Z = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var RecursionType;
(function (RecursionType) {
RecursionType[RecursionType["Normal"] = 0] = "Normal";
RecursionType[RecursionType["AfterFilter"] = 1] = "AfterFilter";
RecursionType[RecursionType["AfterFilterAndSort"] = 2] = "AfterFilterAndSort";
RecursionType[RecursionType["PivotNodes"] = 3] = "PivotNodes";
})(RecursionType || (RecursionType = {}));
var ClientSideRowModel = /** @class */ (function (_super) {
__extends$22(ClientSideRowModel, _super);
function ClientSideRowModel() {
return _super !== null && _super.apply(this, arguments) || this;
}
ClientSideRowModel.prototype.init = function () {
var refreshEverythingFunc = this.refreshModel.bind(this, { step: Constants.STEP_EVERYTHING });
var refreshEverythingAfterColsChangedFunc = this.refreshModel.bind(this, {
step: Constants.STEP_EVERYTHING,
afterColumnsChanged: true,
keepRenderedRows: true,
animate: true
});
this.addManagedListener(this.eventService, Events.EVENT_COLUMN_EVERYTHING_CHANGED, refreshEverythingAfterColsChangedFunc);
this.addManagedListener(this.eventService, Events.EVENT_COLUMN_ROW_GROUP_CHANGED, refreshEverythingFunc);
this.addManagedListener(this.eventService, Events.EVENT_COLUMN_VALUE_CHANGED, this.onValueChanged.bind(this));
this.addManagedListener(this.eventService, Events.EVENT_COLUMN_PIVOT_CHANGED, this.refreshModel.bind(this, { step: Constants.STEP_PIVOT }));
this.addManagedListener(this.eventService, Events.EVENT_ROW_GROUP_OPENED, this.onRowGroupOpened.bind(this));
this.addManagedListener(this.eventService, Events.EVENT_FILTER_CHANGED, this.onFilterChanged.bind(this));
this.addManagedListener(this.eventService, Events.EVENT_SORT_CHANGED, this.onSortChanged.bind(this));
this.addManagedListener(this.eventService, Events.EVENT_COLUMN_PIVOT_MODE_CHANGED, refreshEverythingFunc);
var refreshMapListener = this.refreshModel.bind(this, {
step: Constants.STEP_MAP,
keepRenderedRows: true,
animate: true
});
this.addManagedListener(this.gridOptionsWrapper, GridOptionsWrapper.PROP_GROUP_REMOVE_SINGLE_CHILDREN, refreshMapListener);
this.addManagedListener(this.gridOptionsWrapper, GridOptionsWrapper.PROP_GROUP_REMOVE_LOWEST_SINGLE_CHILDREN, refreshMapListener);
this.rootNode = new RowNode();
this.nodeManager = new ClientSideNodeManager(this.rootNode, this.gridOptionsWrapper, this.getContext(), this.eventService, this.columnController, this.gridApi, this.columnApi, this.selectionController);
this.createBean(this.rootNode);
};
ClientSideRowModel.prototype.start = function () {
var rowData = this.gridOptionsWrapper.getRowData();
if (rowData) {
this.setRowData(rowData);
}
};
ClientSideRowModel.prototype.ensureRowHeightsValid = function (startPixel, endPixel, startLimitIndex, endLimitIndex) {
var atLeastOneChange;
var res = false;
// we do this multiple times as changing the row heights can also change the first and last rows,
// so the first pass can make lots of rows smaller, which means the second pass we end up changing
// more rows.
do {
atLeastOneChange = false;
var rowAtStartPixel = this.getRowIndexAtPixel(startPixel);
var rowAtEndPixel = this.getRowIndexAtPixel(endPixel);
// keep check to current page if doing pagination
var firstRow = Math.max(rowAtStartPixel, startLimitIndex);
var lastRow = Math.min(rowAtEndPixel, endLimitIndex);
for (var rowIndex = firstRow; rowIndex <= lastRow; rowIndex++) {
var rowNode = this.getRow(rowIndex);
if (rowNode.rowHeightEstimated) {
var rowHeight = this.gridOptionsWrapper.getRowHeightForNode(rowNode);
rowNode.setRowHeight(rowHeight.height);
atLeastOneChange = true;
res = true;
}
}
if (atLeastOneChange) {
this.setRowTops();
}
} while (atLeastOneChange);
return res;
};
ClientSideRowModel.prototype.setRowTops = function () {
var nextRowTop = 0;
for (var i = 0; i < this.rowsToDisplay.length; i++) {
// we don't estimate if doing fullHeight or autoHeight, as all rows get rendered all the time
// with these two layouts.
var allowEstimate = this.gridOptionsWrapper.getDomLayout() === Constants.DOM_LAYOUT_NORMAL;
var rowNode = this.rowsToDisplay[i];
if (_.missing(rowNode.rowHeight)) {
var rowHeight = this.gridOptionsWrapper.getRowHeightForNode(rowNode, allowEstimate);
rowNode.setRowHeight(rowHeight.height, rowHeight.estimated);
}
rowNode.setRowTop(nextRowTop);
rowNode.setRowIndex(i);
nextRowTop += rowNode.rowHeight;
}
};
ClientSideRowModel.prototype.resetRowTops = function (rowNode, changedPath) {
rowNode.clearRowTop();
if (rowNode.hasChildren()) {
if (rowNode.childrenAfterGroup) {
// if a changedPath is active, it means we are here because of a transaction update or
// a change detection. neither of these impacts the open/closed state of groups. so if
// a group is not open this time, it was not open last time. so we know all closed groups
// already have their top positions cleared. so there is no need to traverse all the way
// when changedPath is active and the rowNode is not expanded.
var skipChildren = changedPath.isActive() && !rowNode.expanded;
if (!skipChildren) {
for (var i = 0; i < rowNode.childrenAfterGroup.length; i++) {
this.resetRowTops(rowNode.childrenAfterGroup[i], changedPath);
}
}
}
if (rowNode.sibling) {
rowNode.sibling.clearRowTop();
}
}
if (rowNode.detailNode) {
rowNode.detailNode.clearRowTop();
}
};
// returns false if row was moved, otherwise true
ClientSideRowModel.prototype.ensureRowsAtPixel = function (rowNodes, pixel, increment) {
var _this = this;
if (increment === void 0) { increment = 0; }
var indexAtPixelNow = this.getRowIndexAtPixel(pixel);
var rowNodeAtPixelNow = this.getRow(indexAtPixelNow);
if (rowNodeAtPixelNow === rowNodes[0]) {
return false;
}
rowNodes.forEach(function (rowNode) {
_.removeFromArray(_this.rootNode.allLeafChildren, rowNode);
});
rowNodes.forEach(function (rowNode, idx) {
_.insertIntoArray(_this.rootNode.allLeafChildren, rowNode, indexAtPixelNow + increment + idx);
});
this.refreshModel({
step: Constants.STEP_EVERYTHING,
keepRenderedRows: true,
animate: true,
keepEditingRows: true
});
return true;
};
ClientSideRowModel.prototype.highlightRowAtPixel = function (rowNode, pixel) {
var indexAtPixelNow = pixel != null ? this.getRowIndexAtPixel(pixel) : null;
var rowNodeAtPixelNow = indexAtPixelNow != null ? this.getRow(indexAtPixelNow) : null;
if (!rowNodeAtPixelNow || !rowNode || rowNodeAtPixelNow === rowNode || pixel == null) {
if (this.lastHighlightedRow) {
this.lastHighlightedRow.setHighlighted(null);
this.lastHighlightedRow = null;
}
return;
}
var highlight = this.getHighlightPosition(pixel, rowNodeAtPixelNow);
if (this.lastHighlightedRow && this.lastHighlightedRow !== rowNodeAtPixelNow) {
this.lastHighlightedRow.setHighlighted(null);
this.lastHighlightedRow = null;
}
rowNodeAtPixelNow.setHighlighted(highlight);
this.lastHighlightedRow = rowNodeAtPixelNow;
};
ClientSideRowModel.prototype.getHighlightPosition = function (pixel, rowNode) {
if (!rowNode) {
var index = this.getRowIndexAtPixel(pixel);
rowNode = this.getRow(index || 0);
if (!rowNode) {
return 'below';
}
}
var rowTop = rowNode.rowTop, rowHeight = rowNode.rowHeight;
return pixel - rowTop < rowHeight / 2 ? 'above' : 'below';
};
ClientSideRowModel.prototype.getLastHighlightedRowNode = function () {
return this.lastHighlightedRow;
};
ClientSideRowModel.prototype.isLastRowFound = function () {
return true;
};
ClientSideRowModel.prototype.getRowCount = function () {
if (this.rowsToDisplay) {
return this.rowsToDisplay.length;
}
return 0;
};
ClientSideRowModel.prototype.getTopLevelRowCount = function () {
var showingRootNode = this.rowsToDisplay && this.rowsToDisplay[0] === this.rootNode;
if (showingRootNode) {
return 1;
}
return this.rootNode.childrenAfterFilter ? this.rootNode.childrenAfterFilter.length : 0;
};
ClientSideRowModel.prototype.getTopLevelRowDisplayedIndex = function (topLevelIndex) {
var showingRootNode = this.rowsToDisplay && this.rowsToDisplay[0] === this.rootNode;
if (showingRootNode) {
return topLevelIndex;
}
var rowNode = this.rootNode.childrenAfterSort[topLevelIndex];
if (this.gridOptionsWrapper.isGroupHideOpenParents()) {
// if hideOpenParents, and this row open, then this row is now displayed at this index, first child is
while (rowNode.expanded && rowNode.childrenAfterSort && rowNode.childrenAfterSort.length > 0) {
rowNode = rowNode.childrenAfterSort[0];
}
}
return rowNode.rowIndex;
};
ClientSideRowModel.prototype.getRowBounds = function (index) {
if (_.missing(this.rowsToDisplay)) {
return null;
}
var rowNode = this.rowsToDisplay[index];
if (rowNode) {
return {
rowTop: rowNode.rowTop,
rowHeight: rowNode.rowHeight
};
}
return null;
};
ClientSideRowModel.prototype.onRowGroupOpened = function () {
var animate = this.gridOptionsWrapper.isAnimateRows();
this.refreshModel({ step: Constants.STEP_MAP, keepRenderedRows: true, animate: animate });
};
ClientSideRowModel.prototype.onFilterChanged = function (event) {
if (event.afterDataChange) {
return;
}
var animate = this.gridOptionsWrapper.isAnimateRows();
this.refreshModel({ step: Constants.STEP_FILTER, keepRenderedRows: true, animate: animate });
};
ClientSideRowModel.prototype.onSortChanged = function () {
var animate = this.gridOptionsWrapper.isAnimateRows();
this.refreshModel({ step: Constants.STEP_SORT, keepRenderedRows: true, animate: animate, keepEditingRows: true });
};
ClientSideRowModel.prototype.getType = function () {
return Constants.ROW_MODEL_TYPE_CLIENT_SIDE;
};
ClientSideRowModel.prototype.onValueChanged = function () {
if (this.columnController.isPivotActive()) {
this.refreshModel({ step: Constants.STEP_PIVOT });
}
else {
this.refreshModel({ step: Constants.STEP_AGGREGATE });
}
};
ClientSideRowModel.prototype.createChangePath = function (rowNodeTransactions) {
// for updates, if the row is updated at all, then we re-calc all the values
// in that row. we could compare each value to each old value, however if we
// did this, we would be calling the valueService twice, once on the old value
// and once on the new value. so it's less valueGetter calls if we just assume
// each column is different. that way the changedPath is used so that only
// the impacted parent rows are recalculated, parents who's children have
// not changed are not impacted.
var noTransactions = _.missingOrEmpty(rowNodeTransactions);
var changedPath = new ChangedPath(false, this.rootNode);
if (noTransactions || this.gridOptionsWrapper.isTreeData()) {
changedPath.setInactive();
}
return changedPath;
};
ClientSideRowModel.prototype.refreshModel = function (params) {
// this goes through the pipeline of stages. what's in my head is similar
// to the diagram on this page:
// http://commons.apache.org/sandbox/commons-pipeline/pipeline_basics.html
// however we want to keep the results of each stage, hence we manually call
// each step rather than have them chain each other.
var _this = this;
// fallthrough in below switch is on purpose,
// eg if STEP_FILTER, then all steps below this
// step get done
// let start: number;
// console.log('======= start =======');
var changedPath = this.createChangePath(params.rowNodeTransactions);
switch (params.step) {
case Constants.STEP_EVERYTHING:
// start = new Date().getTime();
this.doRowGrouping(params.groupState, params.rowNodeTransactions, params.rowNodeOrder, changedPath, params.afterColumnsChanged);
// console.log('rowGrouping = ' + (new Date().getTime() - start));
case Constants.STEP_FILTER:
// start = new Date().getTime();
this.doFilter(changedPath);
// console.log('filter = ' + (new Date().getTime() - start));
case Constants.STEP_PIVOT:
this.doPivot(changedPath);
case Constants.STEP_AGGREGATE: // depends on agg fields
// start = new Date().getTime();
this.doAggregate(changedPath);
// console.log('aggregation = ' + (new Date().getTime() - start));
case Constants.STEP_SORT:
// start = new Date().getTime();
this.doSort(params.rowNodeTransactions, changedPath);
// console.log('sort = ' + (new Date().getTime() - start));
case Constants.STEP_MAP:
// start = new Date().getTime();
this.doRowsToDisplay();
// console.log('rowsToDisplay = ' + (new Date().getTime() - start));
}
// set all row tops to null, then set row tops on all visible rows. if we don't
// do this, then the algorithm below only sets row tops, old row tops from old rows
// will still lie around
this.resetRowTops(this.rootNode, changedPath);
this.setRowTops();
var event = {
type: Events.EVENT_MODEL_UPDATED,
api: this.gridApi,
columnApi: this.columnApi,
animate: params.animate,
keepRenderedRows: params.keepRenderedRows,
newData: params.newData,
newPage: false
};
this.eventService.dispatchEvent(event);
if (this.$scope) {
window.setTimeout(function () {
_this.$scope.$apply();
}, 0);
}
};
ClientSideRowModel.prototype.isEmpty = function () {
var rowsMissing = _.missing(this.rootNode.allLeafChildren) || this.rootNode.allLeafChildren.length === 0;
return _.missing(this.rootNode) || rowsMissing || !this.columnController.isReady();
};
ClientSideRowModel.prototype.isRowsToRender = function () {
return _.exists(this.rowsToDisplay) && this.rowsToDisplay.length > 0;
};
ClientSideRowModel.prototype.getNodesInRangeForSelection = function (firstInRange, lastInRange) {
// if lastSelectedNode is missing, we start at the first row
var firstRowHit = !lastInRange;
var lastRowHit = false;
var lastRow;
var result = [];
var groupsSelectChildren = this.gridOptionsWrapper.isGroupSelectsChildren();
this.forEachNodeAfterFilterAndSort(function (rowNode) {
var lookingForLastRow = firstRowHit && !lastRowHit;
// check if we need to flip the select switch
if (!firstRowHit) {
if (rowNode === lastInRange || rowNode === firstInRange) {
firstRowHit = true;
}
}
var skipThisGroupNode = rowNode.group && groupsSelectChildren;
if (!skipThisGroupNode) {
var inRange = firstRowHit && !lastRowHit;
var childOfLastRow = rowNode.isParentOfNode(lastRow);
if (inRange || childOfLastRow) {
result.push(rowNode);
}
}
if (lookingForLastRow) {
if (rowNode === lastInRange || rowNode === firstInRange) {
lastRowHit = true;
if (rowNode === lastInRange) {
lastRow = lastInRange;
}
else {
lastRow = firstInRange;
}
}
}
});
return result;
};
ClientSideRowModel.prototype.setDatasource = function (datasource) {
console.error('ag-Grid: should never call setDatasource on clientSideRowController');
};
ClientSideRowModel.prototype.getTopLevelNodes = function () {
return this.rootNode ? this.rootNode.childrenAfterGroup : null;
};
ClientSideRowModel.prototype.getRootNode = function () {
return this.rootNode;
};
ClientSideRowModel.prototype.getRow = function (index) {
return this.rowsToDisplay[index];
};
ClientSideRowModel.prototype.isRowPresent = function (rowNode) {
return this.rowsToDisplay.indexOf(rowNode) >= 0;
};
ClientSideRowModel.prototype.getRowIndexAtPixel = function (pixelToMatch) {
if (this.isEmpty()) {
return -1;
}
// do binary search of tree
// http://oli.me.uk/2013/06/08/searching-javascript-arrays-with-a-binary-search/
var bottomPointer = 0;
var topPointer = this.rowsToDisplay.length - 1;
// quick check, if the pixel is out of bounds, then return last row
if (pixelToMatch <= 0) {
// if pixel is less than or equal zero, it's always the first row
return 0;
}
var lastNode = _.last(this.rowsToDisplay);
if (lastNode.rowTop <= pixelToMatch) {
return this.rowsToDisplay.length - 1;
}
while (true) {
var midPointer = Math.floor((bottomPointer + topPointer) / 2);
var currentRowNode = this.rowsToDisplay[midPointer];
if (this.isRowInPixel(currentRowNode, pixelToMatch)) {
return midPointer;
}
if (currentRowNode.rowTop < pixelToMatch) {
bottomPointer = midPointer + 1;
}
else if (currentRowNode.rowTop > pixelToMatch) {
topPointer = midPointer - 1;
}
}
};
ClientSideRowModel.prototype.isRowInPixel = function (rowNode, pixelToMatch) {
var topPixel = rowNode.rowTop;
var bottomPixel = rowNode.rowTop + rowNode.rowHeight;
var pixelInRow = topPixel <= pixelToMatch && bottomPixel > pixelToMatch;
return pixelInRow;
};
ClientSideRowModel.prototype.getCurrentPageHeight = function () {
if (this.rowsToDisplay && this.rowsToDisplay.length > 0) {
var lastRow = _.last(this.rowsToDisplay);
var lastPixel = lastRow.rowTop + lastRow.rowHeight;
return lastPixel;
}
return 0;
};
ClientSideRowModel.prototype.forEachLeafNode = function (callback) {
if (this.rootNode.allLeafChildren) {
this.rootNode.allLeafChildren.forEach(function (rowNode, index) { return callback(rowNode, index); });
}
};
ClientSideRowModel.prototype.forEachNode = function (callback) {
this.recursivelyWalkNodesAndCallback(this.rootNode.childrenAfterGroup, callback, RecursionType.Normal, 0);
};
ClientSideRowModel.prototype.forEachNodeAfterFilter = function (callback) {
this.recursivelyWalkNodesAndCallback(this.rootNode.childrenAfterFilter, callback, RecursionType.AfterFilter, 0);
};
ClientSideRowModel.prototype.forEachNodeAfterFilterAndSort = function (callback) {
this.recursivelyWalkNodesAndCallback(this.rootNode.childrenAfterSort, callback, RecursionType.AfterFilterAndSort, 0);
};
ClientSideRowModel.prototype.forEachPivotNode = function (callback) {
this.recursivelyWalkNodesAndCallback([this.rootNode], callback, RecursionType.PivotNodes, 0);
};
// iterates through each item in memory, and calls the callback function
// nodes - the rowNodes to traverse
// callback - the user provided callback
// recursion type - need this to know what child nodes to recurse, eg if looking at all nodes, or filtered notes etc
// index - works similar to the index in forEach in javascript's array function
ClientSideRowModel.prototype.recursivelyWalkNodesAndCallback = function (nodes, callback, recursionType, index) {
if (!nodes) {
return index;
}
for (var i = 0; i < nodes.length; i++) {
var node = nodes[i];
callback(node, index++);
// go to the next level if it is a group
if (node.hasChildren()) {
// depending on the recursion type, we pick a difference set of children
var nodeChildren = null;
switch (recursionType) {
case RecursionType.Normal:
nodeChildren = node.childrenAfterGroup;
break;
case RecursionType.AfterFilter:
nodeChildren = node.childrenAfterFilter;
break;
case RecursionType.AfterFilterAndSort:
nodeChildren = node.childrenAfterSort;
break;
case RecursionType.PivotNodes:
// for pivot, we don't go below leafGroup levels
nodeChildren = !node.leafGroup ? node.childrenAfterSort : null;
break;
}
if (nodeChildren) {
index = this.recursivelyWalkNodesAndCallback(nodeChildren, callback, recursionType, index);
}
}
}
return index;
};
// it's possible to recompute the aggregate without doing the other parts
// + gridApi.recomputeAggregates()
ClientSideRowModel.prototype.doAggregate = function (changedPath) {
if (this.aggregationStage) {
this.aggregationStage.execute({ rowNode: this.rootNode, changedPath: changedPath });
}
};
// + gridApi.expandAll()
// + gridApi.collapseAll()
ClientSideRowModel.prototype.expandOrCollapseAll = function (expand) {
var usingTreeData = this.gridOptionsWrapper.isTreeData();
if (this.rootNode) {
recursiveExpandOrCollapse(this.rootNode.childrenAfterGroup);
}
function recursiveExpandOrCollapse(rowNodes) {
if (!rowNodes) {
return;
}
rowNodes.forEach(function (rowNode) {
var shouldExpandOrCollapse = usingTreeData ? _.exists(rowNode.childrenAfterGroup) : rowNode.group;
if (shouldExpandOrCollapse) {
rowNode.expanded = expand;
recursiveExpandOrCollapse(rowNode.childrenAfterGroup);
}
});
}
this.refreshModel({ step: Constants.STEP_MAP });
var eventSource = expand ? 'expandAll' : 'collapseAll';
var event = {
api: this.gridApi,
columnApi: this.columnApi,
type: Events.EVENT_EXPAND_COLLAPSE_ALL,
source: eventSource
};
this.eventService.dispatchEvent(event);
};
ClientSideRowModel.prototype.doSort = function (rowNodeTransactions, changedPath) {
this.sortStage.execute({
rowNode: this.rootNode,
rowNodeTransactions: rowNodeTransactions,
changedPath: changedPath
});
};
ClientSideRowModel.prototype.doRowGrouping = function (groupState, rowNodeTransactions, rowNodeOrder, changedPath, afterColumnsChanged) {
if (this.groupStage) {
if (rowNodeTransactions) {
this.groupStage.execute({
rowNode: this.rootNode,
rowNodeTransactions: rowNodeTransactions,
rowNodeOrder: rowNodeOrder,
changedPath: changedPath
});
}
else {
// groups are about to get disposed, so need to deselect any that are selected
this.selectionController.removeGroupsFromSelection();
this.groupStage.execute({
rowNode: this.rootNode,
changedPath: changedPath,
afterColumnsChanged: afterColumnsChanged
});
// set open/closed state on groups
this.restoreGroupState(groupState);
}
if (this.gridOptionsWrapper.isGroupSelectsChildren()) {
this.selectionController.updateGroupsFromChildrenSelections(changedPath);
}
}
else {
this.rootNode.childrenAfterGroup = this.rootNode.allLeafChildren;
this.rootNode.updateHasChildren();
}
};
ClientSideRowModel.prototype.restoreGroupState = function (groupState) {
if (!groupState) {
return;
}
_.traverseNodesWithKey(this.rootNode.childrenAfterGroup, function (node, key) {
// if the group was open last time, then open it this time. however
// if was not open last time, then don't touch the group, so the 'groupDefaultExpanded'
// setting will take effect.
if (typeof groupState[key] === 'boolean') {
node.expanded = groupState[key];
}
});
};
ClientSideRowModel.prototype.doFilter = function (changedPath) {
this.filterStage.execute({ rowNode: this.rootNode, changedPath: changedPath });
};
ClientSideRowModel.prototype.doPivot = function (changedPath) {
if (this.pivotStage) {
this.pivotStage.execute({ rowNode: this.rootNode, changedPath: changedPath });
}
};
ClientSideRowModel.prototype.getGroupState = function () {
if (!this.rootNode.childrenAfterGroup || !this.gridOptionsWrapper.isRememberGroupStateWhenNewData()) {
return null;
}
var result = {};
_.traverseNodesWithKey(this.rootNode.childrenAfterGroup, function (node, key) { return result[key] = node.expanded; });
return result;
};
ClientSideRowModel.prototype.getCopyOfNodesMap = function () {
return this.nodeManager.getCopyOfNodesMap();
};
ClientSideRowModel.prototype.getRowNode = function (id) {
return this.nodeManager.getRowNode(id);
};
// rows: the rows to put into the model
ClientSideRowModel.prototype.setRowData = function (rowData) {
// no need to invalidate cache, as the cache is stored on the rowNode,
// so new rowNodes means the cache is wiped anyway.
// remember group state, so we can expand groups that should be expanded
var groupState = this.getGroupState();
this.nodeManager.setRowData(rowData);
// this event kicks off:
// - clears selection
// - updates filters
// - shows 'no rows' overlay if needed
var rowDataChangedEvent = {
type: Events.EVENT_ROW_DATA_CHANGED,
api: this.gridApi,
columnApi: this.columnApi
};
this.eventService.dispatchEvent(rowDataChangedEvent);
this.refreshModel({
step: Constants.STEP_EVERYTHING,
groupState: groupState,
newData: true
});
};
ClientSideRowModel.prototype.batchUpdateRowData = function (rowDataTransaction, callback) {
var _this = this;
if (this.applyAsyncTransactionsTimeout == null) {
this.rowDataTransactionBatch = [];
var waitMillis = this.gridOptionsWrapper.getAsyncTransactionWaitMillis();
this.applyAsyncTransactionsTimeout = window.setTimeout(function () {
_this.executeBatchUpdateRowData();
}, waitMillis);
}
this.rowDataTransactionBatch.push({ rowDataTransaction: rowDataTransaction, callback: callback });
};
ClientSideRowModel.prototype.flushAsyncTransactions = function () {
if (this.applyAsyncTransactionsTimeout != null) {
clearTimeout(this.applyAsyncTransactionsTimeout);
this.executeBatchUpdateRowData();
}
};
ClientSideRowModel.prototype.executeBatchUpdateRowData = function () {
var _this = this;
this.valueCache.onDataChanged();
var callbackFuncsBound = [];
var rowNodeTrans = [];
if (this.rowDataTransactionBatch) {
this.rowDataTransactionBatch.forEach(function (tranItem) {
var rowNodeTran = _this.nodeManager.updateRowData(tranItem.rowDataTransaction, null);
rowNodeTrans.push(rowNodeTran);
if (tranItem.callback) {
callbackFuncsBound.push(tranItem.callback.bind(null, rowNodeTran));
}
});
}
this.commonUpdateRowData(rowNodeTrans);
// do callbacks in next VM turn so it's async
if (callbackFuncsBound.length > 0) {
window.setTimeout(function () {
callbackFuncsBound.forEach(function (func) { return func(); });
}, 0);
}
this.rowDataTransactionBatch = null;
this.applyAsyncTransactionsTimeout = undefined;
};
ClientSideRowModel.prototype.updateRowData = function (rowDataTran, rowNodeOrder) {
this.valueCache.onDataChanged();
var rowNodeTran = this.nodeManager.updateRowData(rowDataTran, rowNodeOrder);
this.commonUpdateRowData([rowNodeTran], rowNodeOrder);
return rowNodeTran;
};
// common to updateRowData and batchUpdateRowData
ClientSideRowModel.prototype.commonUpdateRowData = function (rowNodeTrans, rowNodeOrder) {
this.refreshModel({
step: Constants.STEP_EVERYTHING,
rowNodeTransactions: rowNodeTrans,
rowNodeOrder: rowNodeOrder,
keepRenderedRows: true,
animate: true,
keepEditingRows: true
});
var event = {
type: Events.EVENT_ROW_DATA_UPDATED,
api: this.gridApi,
columnApi: this.columnApi
};
this.eventService.dispatchEvent(event);
};
ClientSideRowModel.prototype.doRowsToDisplay = function () {
this.rowsToDisplay = this.flattenStage.execute({ rowNode: this.rootNode });
};
ClientSideRowModel.prototype.onRowHeightChanged = function () {
this.refreshModel({ step: Constants.STEP_MAP, keepRenderedRows: true, keepEditingRows: true });
};
ClientSideRowModel.prototype.resetRowHeights = function () {
this.forEachNode(function (rowNode) {
rowNode.setRowHeight(rowNode.rowHeight, true);
// we keep the height each row is at, however we set estimated=true rather than clear the height.
// this means the grid will not reset the row heights back to defaults, rather it will re-calc
// the height for each row as the row is displayed. otherwise the scroll will jump when heights are reset.
var detailNode = rowNode.detailNode;
if (detailNode) {
detailNode.setRowHeight(detailNode.rowHeight, true);
}
});
this.onRowHeightChanged();
};
__decorate$1Z([
Autowired('gridOptionsWrapper')
], ClientSideRowModel.prototype, "gridOptionsWrapper", void 0);
__decorate$1Z([
Autowired('columnController')
], ClientSideRowModel.prototype, "columnController", void 0);
__decorate$1Z([
Autowired('filterManager')
], ClientSideRowModel.prototype, "filterManager", void 0);
__decorate$1Z([
Autowired('$scope')
], ClientSideRowModel.prototype, "$scope", void 0);
__decorate$1Z([
Autowired('selectionController')
], ClientSideRowModel.prototype, "selectionController", void 0);
__decorate$1Z([
Autowired('valueService')
], ClientSideRowModel.prototype, "valueService", void 0);
__decorate$1Z([
Autowired('valueCache')
], ClientSideRowModel.prototype, "valueCache", void 0);
__decorate$1Z([
Autowired('columnApi')
], ClientSideRowModel.prototype, "columnApi", void 0);
__decorate$1Z([
Autowired('gridApi')
], ClientSideRowModel.prototype, "gridApi", void 0);
__decorate$1Z([
Autowired('filterStage')
], ClientSideRowModel.prototype, "filterStage", void 0);
__decorate$1Z([
Autowired('sortStage')
], ClientSideRowModel.prototype, "sortStage", void 0);
__decorate$1Z([
Autowired('flattenStage')
], ClientSideRowModel.prototype, "flattenStage", void 0);
__decorate$1Z([
Optional('groupStage')
], ClientSideRowModel.prototype, "groupStage", void 0);
__decorate$1Z([
Optional('aggregationStage')
], ClientSideRowModel.prototype, "aggregationStage", void 0);
__decorate$1Z([
Optional('pivotStage')
], ClientSideRowModel.prototype, "pivotStage", void 0);
__decorate$1Z([
PostConstruct
], ClientSideRowModel.prototype, "init", null);
ClientSideRowModel = __decorate$1Z([
Bean('rowModel')
], ClientSideRowModel);
return ClientSideRowModel;
}(BeanStub));
var __extends$23 = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate$1_ = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var FilterStage = /** @class */ (function (_super) {
__extends$23(FilterStage, _super);
function FilterStage() {
return _super !== null && _super.apply(this, arguments) || this;
}
FilterStage.prototype.execute = function (params) {
var rowNode = params.rowNode, changedPath = params.changedPath;
this.filterService.filter(changedPath);
this.selectableService.updateSelectableAfterFiltering(rowNode);
};
__decorate$1_([
Autowired('gridOptionsWrapper')
], FilterStage.prototype, "gridOptionsWrapper", void 0);
__decorate$1_([
Autowired('selectableService')
], FilterStage.prototype, "selectableService", void 0);
__decorate$1_([
Autowired('filterService')
], FilterStage.prototype, "filterService", void 0);
FilterStage = __decorate$1_([
Bean('filterStage')
], FilterStage);
return FilterStage;
}(BeanStub));
var __extends$24 = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate$1$ = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var SortStage = /** @class */ (function (_super) {
__extends$24(SortStage, _super);
function SortStage() {
return _super !== null && _super.apply(this, arguments) || this;
}
SortStage.prototype.execute = function (params) {
var sortOptions = this.sortController.getSortForRowController();
var sortActive = _.exists(sortOptions) && sortOptions.length > 0;
var deltaSort = sortActive
&& _.exists(params.rowNodeTransactions)
// in time we can remove this check, so that delta sort is always
// on if transactions are present. it's off for now so that we can
// selectively turn it on and test it with some select users before
// rolling out to everyone.
&& this.gridOptionsWrapper.isDeltaSort();
// we only need dirty nodes if doing delta sort
var dirtyLeafNodes = deltaSort ? this.calculateDirtyNodes(params.rowNodeTransactions) : null;
var valueColumns = this.columnController.getValueColumns();
var noAggregations = _.missingOrEmpty(valueColumns);
this.sortService.sort(sortOptions, sortActive, deltaSort, dirtyLeafNodes, params.changedPath, noAggregations);
};
SortStage.prototype.calculateDirtyNodes = function (rowNodeTransactions) {
var dirtyNodes = {};
var addNodesFunc = function (rowNodes) {
if (rowNodes) {
rowNodes.forEach(function (rowNode) { return dirtyNodes[rowNode.id] = true; });
}
};
// all leaf level nodes in the transaction were impacted
rowNodeTransactions.forEach(function (tran) {
addNodesFunc(tran.add);
addNodesFunc(tran.update);
addNodesFunc(tran.remove);
});
return dirtyNodes;
};
__decorate$1$([
Autowired('gridOptionsWrapper')
], SortStage.prototype, "gridOptionsWrapper", void 0);
__decorate$1$([
Autowired('sortService')
], SortStage.prototype, "sortService", void 0);
__decorate$1$([
Autowired('sortController')
], SortStage.prototype, "sortController", void 0);
__decorate$1$([
Autowired('columnController')
], SortStage.prototype, "columnController", void 0);
SortStage = __decorate$1$([
Bean('sortStage')
], SortStage);
return SortStage;
}(BeanStub));
var __extends$25 = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate$20 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var FlattenStage = /** @class */ (function (_super) {
__extends$25(FlattenStage, _super);
function FlattenStage() {
return _super !== null && _super.apply(this, arguments) || this;
}
FlattenStage.prototype.execute = function (params) {
var rootNode = params.rowNode;
// even if not doing grouping, we do the mapping, as the client might
// of passed in data that already has a grouping in it somewhere
var result = [];
// putting value into a wrapper so it's passed by reference
var nextRowTop = { value: 0 };
var skipLeafNodes = this.columnController.isPivotMode();
// if we are reducing, and not grouping, then we want to show the root node, as that
// is where the pivot values are
var showRootNode = skipLeafNodes && rootNode.leafGroup;
var topList = showRootNode ? [rootNode] : rootNode.childrenAfterSort;
this.recursivelyAddToRowsToDisplay(topList, result, nextRowTop, skipLeafNodes, 0);
// we do not want the footer total if the gris is empty
var atLeastOneRowPresent = result.length > 0;
var includeGroupTotalFooter = !showRootNode
// don't show total footer when showRootNode is true (i.e. in pivot mode and no groups)
&& atLeastOneRowPresent
&& this.gridOptionsWrapper.isGroupIncludeTotalFooter();
if (includeGroupTotalFooter) {
this.ensureFooterNodeExists(rootNode);
this.addRowNodeToRowsToDisplay(rootNode.sibling, result, nextRowTop, 0);
}
return result;
};
FlattenStage.prototype.recursivelyAddToRowsToDisplay = function (rowsToFlatten, result, nextRowTop, skipLeafNodes, uiLevel) {
if (_.missingOrEmpty(rowsToFlatten)) {
return;
}
var hideOpenParents = this.gridOptionsWrapper.isGroupHideOpenParents();
// these two are mutually exclusive, so if first set, we don't set the second
var groupRemoveSingleChildren = this.gridOptionsWrapper.isGroupRemoveSingleChildren();
var groupRemoveLowestSingleChildren = !groupRemoveSingleChildren && this.gridOptionsWrapper.isGroupRemoveLowestSingleChildren();
for (var i = 0; i < rowsToFlatten.length; i++) {
var rowNode = rowsToFlatten[i];
// check all these cases, for working out if this row should be included in the final mapped list
var isParent = rowNode.hasChildren();
var isSkippedLeafNode = skipLeafNodes && !isParent;
var isRemovedSingleChildrenGroup = groupRemoveSingleChildren &&
isParent &&
rowNode.childrenAfterGroup.length === 1;
var isRemovedLowestSingleChildrenGroup = groupRemoveLowestSingleChildren &&
isParent &&
rowNode.leafGroup &&
rowNode.childrenAfterGroup.length === 1;
// hide open parents means when group is open, we don't show it. we also need to make sure the
// group is expandable in the first place (as leaf groups are not expandable if pivot mode is on).
// the UI will never allow expanding leaf groups, however the user might via the API (or menu option 'expand all')
var neverAllowToExpand = skipLeafNodes && rowNode.leafGroup;
var isHiddenOpenParent = hideOpenParents && rowNode.expanded && (!neverAllowToExpand);
var thisRowShouldBeRendered = !isSkippedLeafNode && !isHiddenOpenParent &&
!isRemovedSingleChildrenGroup && !isRemovedLowestSingleChildrenGroup;
if (thisRowShouldBeRendered) {
this.addRowNodeToRowsToDisplay(rowNode, result, nextRowTop, uiLevel);
}
// if we are pivoting, we never map below the leaf group
if (skipLeafNodes && rowNode.leafGroup) {
continue;
}
if (isParent) {
var excludedParent = isRemovedSingleChildrenGroup || isRemovedLowestSingleChildrenGroup;
// we traverse the group if it is expended, however we always traverse if the parent node
// was removed (as the group will never be opened if it is not displayed, we show the children instead)
if (rowNode.expanded || excludedParent) {
// if the parent was excluded, then ui level is that of the parent
var uiLevelForChildren = excludedParent ? uiLevel : uiLevel + 1;
this.recursivelyAddToRowsToDisplay(rowNode.childrenAfterSort, result, nextRowTop, skipLeafNodes, uiLevelForChildren);
// put a footer in if user is looking for it
if (this.gridOptionsWrapper.isGroupIncludeFooter()) {
this.ensureFooterNodeExists(rowNode);
this.addRowNodeToRowsToDisplay(rowNode.sibling, result, nextRowTop, uiLevel);
}
}
}
else if (rowNode.master && rowNode.expanded) {
var detailNode = this.createDetailNode(rowNode);
this.addRowNodeToRowsToDisplay(detailNode, result, nextRowTop, uiLevel);
}
}
};
// duplicated method, it's also in floatingRowModel
FlattenStage.prototype.addRowNodeToRowsToDisplay = function (rowNode, result, nextRowTop, uiLevel) {
var isGroupMultiAutoColumn = this.gridOptionsWrapper.isGroupMultiAutoColumn();
result.push(rowNode);
rowNode.setUiLevel(isGroupMultiAutoColumn ? 0 : uiLevel);
};
FlattenStage.prototype.ensureFooterNodeExists = function (groupNode) {
// only create footer node once, otherwise we have daemons and
// the animate screws up with the daemons hanging around
if (_.exists(groupNode.sibling)) {
return;
}
var footerNode = new RowNode();
this.context.createBean(footerNode);
Object.keys(groupNode).forEach(function (key) {
footerNode[key] = groupNode[key];
});
footerNode.footer = true;
footerNode.rowTop = null;
footerNode.oldRowTop = null;
if (_.exists(footerNode.id)) {
footerNode.id = 'rowGroupFooter_' + footerNode.id;
}
// get both header and footer to reference each other as siblings. this is never undone,
// only overwritten. so if a group is expanded, then contracted, it will have a ghost
// sibling - but that's fine, as we can ignore this if the header is contracted.
footerNode.sibling = groupNode;
groupNode.sibling = footerNode;
};
FlattenStage.prototype.createDetailNode = function (masterNode) {
if (_.exists(masterNode.detailNode)) {
return masterNode.detailNode;
}
var detailNode = new RowNode();
this.context.createBean(detailNode);
detailNode.detail = true;
detailNode.selectable = false;
detailNode.parent = masterNode;
if (_.exists(masterNode.id)) {
detailNode.id = 'detail_' + masterNode.id;
}
detailNode.data = masterNode.data;
detailNode.level = masterNode.level + 1;
masterNode.detailNode = detailNode;
return detailNode;
};
__decorate$20([
Autowired('gridOptionsWrapper')
], FlattenStage.prototype, "gridOptionsWrapper", void 0);
__decorate$20([
Autowired('selectionController')
], FlattenStage.prototype, "selectionController", void 0);
__decorate$20([
Autowired('columnController')
], FlattenStage.prototype, "columnController", void 0);
FlattenStage = __decorate$20([
Bean('flattenStage')
], FlattenStage);
return FlattenStage;
}(BeanStub));
var __extends$26 = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate$21 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var SortService = /** @class */ (function (_super) {
__extends$26(SortService, _super);
function SortService() {
return _super !== null && _super.apply(this, arguments) || this;
}
SortService.prototype.init = function () {
this.postSortFunc = this.gridOptionsWrapper.getPostSortFunc();
};
SortService.prototype.sort = function (sortOptions, sortActive, deltaSort, dirtyLeafNodes, changedPath, noAggregations) {
var _this = this;
var callback = function (rowNode) {
// we clear out the 'pull down open parents' first, as the values mix up the sorting
_this.pullDownGroupDataForHideOpenParents(rowNode.childrenAfterFilter, true);
// Javascript sort is non deterministic when all the array items are equals, ie Comparator always returns 0,
// so to ensure the array keeps its order, add an additional sorting condition manually, in this case we
// are going to inspect the original array position. This is what sortedRowNodes is for.
if (sortActive) {
var sortedRowNodes = deltaSort ?
_this.doDeltaSort(rowNode, sortOptions, dirtyLeafNodes, changedPath, noAggregations)
: _this.doFullSort(rowNode, sortOptions);
rowNode.childrenAfterSort = sortedRowNodes.map(function (sorted) { return sorted.rowNode; });
}
else {
rowNode.childrenAfterSort = rowNode.childrenAfterFilter.slice(0);
}
_this.updateChildIndexes(rowNode);
if (_this.postSortFunc) {
_this.postSortFunc(rowNode.childrenAfterSort);
}
};
changedPath.forEachChangedNodeDepthFirst(callback);
this.updateGroupDataForHiddenOpenParents(changedPath);
};
SortService.prototype.doFullSort = function (rowNode, sortOptions) {
var sortedRowNodes = rowNode.childrenAfterFilter
.map(this.mapNodeToSortedNode.bind(this));
sortedRowNodes.sort(this.compareRowNodes.bind(this, sortOptions));
return sortedRowNodes;
};
SortService.prototype.mapNodeToSortedNode = function (rowNode, pos) {
return { currentPos: pos, rowNode: rowNode };
};
SortService.prototype.doDeltaSort = function (rowNode, sortOptions, dirtyLeafNodes, changedPath, noAggregations) {
// clean nodes will be a list of all row nodes that remain in the set
// and ordered. we start with the old sorted set and take out any nodes
// that were removed or changed (but not added, added doesn't make sense,
// if a node was added, there is no way it could be here from last time).
var cleanNodes = rowNode.childrenAfterSort
.filter(function (rowNode) {
// take out all nodes that were changed as part of the current transaction.
// a changed node could a) be in a different sort position or b) may
// no longer be in this set as the changed node may not pass filtering,
// or be in a different group.
var passesDirtyNodesCheck = !dirtyLeafNodes[rowNode.id];
// also remove group nodes in the changed path, as they can have different aggregate
// values which could impact the sort order.
// note: changed path is not active if a) no value columns or b) no transactions. it is never
// (b) in deltaSort as we only do deltaSort for transactions. for (a) if no value columns, then
// there is no value in the group that could of changed (ie no aggregate values)
var passesChangedPathCheck = noAggregations || changedPath.canSkip(rowNode);
return passesDirtyNodesCheck && passesChangedPathCheck;
})
.map(this.mapNodeToSortedNode.bind(this));
// for fast access below, we map them
var cleanNodesMapped = {};
cleanNodes.forEach(function (sortedRowNode) { return cleanNodesMapped[sortedRowNode.rowNode.id] = sortedRowNode.rowNode; });
// these are all nodes that need to be placed
var changedNodes = rowNode.childrenAfterFilter
// ignore nodes in the clean list
.filter(function (rowNode) { return !cleanNodesMapped[rowNode.id]; })
.map(this.mapNodeToSortedNode.bind(this));
// sort changed nodes. note that we don't need to sort cleanNodes as they are
// already sorted from last time.
changedNodes.sort(this.compareRowNodes.bind(this, sortOptions));
if (changedNodes.length === 0) {
return cleanNodes;
}
else if (cleanNodes.length === 0) {
return changedNodes;
}
else {
return this.mergeSortedArrays(sortOptions, cleanNodes, changedNodes);
}
};
// Merge two sorted arrays into each other
SortService.prototype.mergeSortedArrays = function (sortOptions, arr1, arr2) {
var res = [];
var i = 0;
var j = 0;
// Traverse both array, adding them in order
while (i < arr1.length && j < arr2.length) {
// Check if current element of first
// array is smaller than current element
// of second array. If yes, store first
// array element and increment first array
// index. Otherwise do same with second array
var compareResult = this.compareRowNodes(sortOptions, arr1[i], arr2[j]);
if (compareResult < 0) {
res.push(arr1[i++]);
}
else {
res.push(arr2[j++]);
}
}
// add remaining from arr1
while (i < arr1.length) {
res.push(arr1[i++]);
}
// add remaining from arr2
while (j < arr2.length) {
res.push(arr2[j++]);
}
return res;
};
SortService.prototype.compareRowNodes = function (sortOptions, sortedNodeA, sortedNodeB) {
var nodeA = sortedNodeA.rowNode;
var nodeB = sortedNodeB.rowNode;
// Iterate columns, return the first that doesn't match
for (var i = 0, len = sortOptions.length; i < len; i++) {
var sortOption = sortOptions[i];
// let compared = compare(nodeA, nodeB, sortOption.column, sortOption.inverter === -1);
var isInverted = sortOption.inverter === -1;
var valueA = this.getValue(nodeA, sortOption.column);
var valueB = this.getValue(nodeB, sortOption.column);
var comparatorResult = void 0;
if (sortOption.column.getColDef().comparator) {
//if comparator provided, use it
comparatorResult = sortOption.column.getColDef().comparator(valueA, valueB, nodeA, nodeB, isInverted);
}
else {
//otherwise do our own comparison
comparatorResult = _.defaultComparator(valueA, valueB, this.gridOptionsWrapper.isAccentedSort());
}
if (comparatorResult !== 0) {
return comparatorResult * sortOption.inverter;
}
}
// All matched, we make is so that the original sort order is kept:
return sortedNodeA.currentPos - sortedNodeB.currentPos;
};
SortService.prototype.getValue = function (nodeA, column) {
return this.valueService.getValue(column, nodeA);
};
SortService.prototype.updateChildIndexes = function (rowNode) {
if (_.missing(rowNode.childrenAfterSort)) {
return;
}
var listToSort = rowNode.childrenAfterSort;
for (var i = 0; i < listToSort.length; i++) {
var child = listToSort[i];
var firstChild = i === 0;
var lastChild = i === rowNode.childrenAfterSort.length - 1;
child.setFirstChild(firstChild);
child.setLastChild(lastChild);
child.setChildIndex(i);
}
};
SortService.prototype.updateGroupDataForHiddenOpenParents = function (changedPath) {
var _this = this;
if (!this.gridOptionsWrapper.isGroupHideOpenParents()) {
return;
}
// recurse breadth first over group nodes after sort to 'pull down' group data to child groups
var callback = function (rowNode) {
_this.pullDownGroupDataForHideOpenParents(rowNode.childrenAfterSort, false);
rowNode.childrenAfterSort.forEach(function (child) {
if (child.hasChildren()) {
callback(child);
}
});
};
changedPath.executeFromRootNode(function (rowNode) { return callback(rowNode); });
};
SortService.prototype.pullDownGroupDataForHideOpenParents = function (rowNodes, clearOperation) {
var _this = this;
if (_.missing(rowNodes)) {
return;
}
if (!this.gridOptionsWrapper.isGroupHideOpenParents()) {
return;
}
rowNodes.forEach(function (childRowNode) {
var groupDisplayCols = _this.columnController.getGroupDisplayColumns();
groupDisplayCols.forEach(function (groupDisplayCol) {
var showRowGroup = groupDisplayCol.getColDef().showRowGroup;
if (typeof showRowGroup !== 'string') {
console.error('ag-Grid: groupHideOpenParents only works when specifying specific columns for colDef.showRowGroup');
return;
}
var displayingGroupKey = showRowGroup;
var rowGroupColumn = _this.columnController.getPrimaryColumn(displayingGroupKey);
var thisRowNodeMatches = rowGroupColumn === childRowNode.rowGroupColumn;
if (thisRowNodeMatches) {
return;
}
if (clearOperation) {
// if doing a clear operation, we clear down the value for every possible group column
childRowNode.setGroupValue(groupDisplayCol.getId(), null);
}
else {
// if doing a set operation, we set only where the pull down is to occur
var parentToStealFrom = childRowNode.getFirstChildOfFirstChild(rowGroupColumn);
if (parentToStealFrom) {
childRowNode.setGroupValue(groupDisplayCol.getId(), parentToStealFrom.key);
}
}
});
});
};
__decorate$21([
Autowired('sortController')
], SortService.prototype, "sortController", void 0);
__decorate$21([
Autowired('columnController')
], SortService.prototype, "columnController", void 0);
__decorate$21([
Autowired('valueService')
], SortService.prototype, "valueService", void 0);
__decorate$21([
Autowired('gridOptionsWrapper')
], SortService.prototype, "gridOptionsWrapper", void 0);
__decorate$21([
PostConstruct
], SortService.prototype, "init", null);
SortService = __decorate$21([
Bean('sortService')
], SortService);
return SortService;
}(BeanStub));
var __extends$27 = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate$22 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var FilterService = /** @class */ (function (_super) {
__extends$27(FilterService, _super);
function FilterService() {
return _super !== null && _super.apply(this, arguments) || this;
}
FilterService.prototype.postConstruct = function () {
this.doingTreeData = this.gridOptionsWrapper.isTreeData();
};
FilterService.prototype.filter = function (changedPath) {
var filterActive = this.filterManager.isAnyFilterPresent();
this.filterNodes(filterActive, changedPath);
};
FilterService.prototype.filterNodes = function (filterActive, changedPath) {
var _this = this;
var filterCallback = function (rowNode, includeChildNodes) {
// recursively get all children that are groups to also filter
if (rowNode.hasChildren()) {
// result of filter for this node. when filtering tree data, includeChildNodes = true when parent passes
if (filterActive && !includeChildNodes) {
rowNode.childrenAfterFilter = rowNode.childrenAfterGroup.filter(function (childNode) {
// a group is included in the result if it has any children of it's own.
// by this stage, the child groups are already filtered
var passBecauseChildren = childNode.childrenAfterFilter && childNode.childrenAfterFilter.length > 0;
// both leaf level nodes and tree data nodes have data. these get added if
// the data passes the filter
var passBecauseDataPasses = childNode.data && _this.filterManager.doesRowPassFilter(childNode);
// note - tree data nodes pass either if a) they pass themselves or b) any children of that node pass
return passBecauseChildren || passBecauseDataPasses;
});
}
else {
// if not filtering, the result is the original list
rowNode.childrenAfterFilter = rowNode.childrenAfterGroup;
}
_this.setAllChildrenCount(rowNode);
}
else {
rowNode.childrenAfterFilter = rowNode.childrenAfterGroup;
rowNode.setAllChildrenCount(null);
}
};
if (this.doingTreeDataFiltering()) {
var treeDataDepthFirstFilter_1 = function (rowNode, alreadyFoundInParent) {
// tree data filter traverses the hierarchy depth first and includes child nodes if parent passes
// filter, and parent nodes will be include if any children exist.
if (rowNode.childrenAfterGroup) {
for (var i = 0; i < rowNode.childrenAfterGroup.length; i++) {
var childNode = rowNode.childrenAfterGroup[i];
// first check if current node passes filter before invoking child nodes
var foundInParent = alreadyFoundInParent || _this.filterManager.doesRowPassFilter(childNode);
if (childNode.childrenAfterGroup) {
treeDataDepthFirstFilter_1(rowNode.childrenAfterGroup[i], foundInParent);
}
else {
filterCallback(childNode, foundInParent);
}
}
}
filterCallback(rowNode, alreadyFoundInParent);
};
var treeDataFilterCallback = function (rowNode) { return treeDataDepthFirstFilter_1(rowNode, false); };
changedPath.executeFromRootNode(treeDataFilterCallback);
}
else {
var defaultFilterCallback = function (rowNode) { return filterCallback(rowNode, false); };
changedPath.forEachChangedNodeDepthFirst(defaultFilterCallback, true);
}
};
FilterService.prototype.setAllChildrenCountTreeData = function (rowNode) {
// for tree data, we include all children, groups and leafs
var allChildrenCount = 0;
rowNode.childrenAfterFilter.forEach(function (child) {
// include child itself
allChildrenCount++;
// include children of children
allChildrenCount += child.allChildrenCount;
});
rowNode.setAllChildrenCount(allChildrenCount);
};
FilterService.prototype.setAllChildrenCountGridGrouping = function (rowNode) {
// for grid data, we only count the leafs
var allChildrenCount = 0;
rowNode.childrenAfterFilter.forEach(function (child) {
if (child.group) {
allChildrenCount += child.allChildrenCount;
}
else {
allChildrenCount++;
}
});
rowNode.setAllChildrenCount(allChildrenCount);
};
FilterService.prototype.setAllChildrenCount = function (rowNode) {
if (this.doingTreeData) {
this.setAllChildrenCountTreeData(rowNode);
}
else {
this.setAllChildrenCountGridGrouping(rowNode);
}
};
FilterService.prototype.doingTreeDataFiltering = function () {
return this.gridOptionsWrapper.isTreeData() && !this.gridOptionsWrapper.isExcludeChildrenWhenTreeDataFiltering();
};
__decorate$22([
Autowired('filterManager')
], FilterService.prototype, "filterManager", void 0);
__decorate$22([
Autowired('gridOptionsWrapper')
], FilterService.prototype, "gridOptionsWrapper", void 0);
__decorate$22([
PostConstruct
], FilterService.prototype, "postConstruct", null);
FilterService = __decorate$22([
Bean("filterService")
], FilterService);
return FilterService;
}(BeanStub));
var __extends$28 = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate$23 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var ImmutableService = /** @class */ (function (_super) {
__extends$28(ImmutableService, _super);
function ImmutableService() {
return _super !== null && _super.apply(this, arguments) || this;
}
ImmutableService.prototype.postConstruct = function () {
if (this.rowModel.getType() === Constants.ROW_MODEL_TYPE_CLIENT_SIDE) {
this.clientSideRowModel = this.rowModel;
}
};
// converts the setRowData() command to a transaction
ImmutableService.prototype.createTransactionForRowData = function (data) {
if (_.missing(this.clientSideRowModel)) {
console.error('ag-Grid: ImmutableService only works with ClientSideRowModel');
return;
}
var getRowNodeIdFunc = this.gridOptionsWrapper.getRowNodeIdFunc();
if (!getRowNodeIdFunc || _.missing(getRowNodeIdFunc)) {
console.error('ag-Grid: ImmutableService requires getRowNodeId() callback to be implemented, your row data need IDs!');
return;
}
// convert the data into a transaction object by working out adds, removes and updates
var transaction = {
remove: [],
update: [],
add: []
};
var existingNodesMap = this.clientSideRowModel.getCopyOfNodesMap();
var suppressSortOrder = this.gridOptionsWrapper.isSuppressMaintainUnsortedOrder();
var orderMap = suppressSortOrder ? null : {};
if (_.exists(data)) {
// split all the new data in the following:
// if new, push to 'add'
// if update, push to 'update'
// if not changed, do not include in the transaction
data.forEach(function (dataItem, index) {
var id = getRowNodeIdFunc(dataItem);
var existingNode = existingNodesMap[id];
if (orderMap) {
orderMap[id] = index;
}
if (existingNode) {
var dataHasChanged = existingNode.data !== dataItem;
if (dataHasChanged) {
transaction.update.push(dataItem);
}
// otherwise, if data not changed, we just don't include it anywhere, as it's not a delta
// remove from list, so we know the item is not to be removed
existingNodesMap[id] = undefined;
}
else {
transaction.add.push(dataItem);
}
});
}
// at this point, all rows that are left, should be removed
_.iterateObject(existingNodesMap, function (id, rowNode) {
if (rowNode) {
transaction.remove.push(rowNode.data);
}
});
return [transaction, orderMap];
};
__decorate$23([
Autowired('rowModel')
], ImmutableService.prototype, "rowModel", void 0);
__decorate$23([
Autowired('gridOptionsWrapper')
], ImmutableService.prototype, "gridOptionsWrapper", void 0);
__decorate$23([
PostConstruct
], ImmutableService.prototype, "postConstruct", null);
ImmutableService = __decorate$23([
Bean('immutableService')
], ImmutableService);
return ImmutableService;
}(BeanStub));
var ClientSideRowModelModule = {
moduleName: exports.ModuleNames.ClientSideRowModelModule,
beans: [FilterStage, SortStage, FlattenStage, SortService, FilterService, ImmutableService],
rowModels: { clientSide: ClientSideRowModel }
};
var __extends$29 = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate$24 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var InfiniteBlock = /** @class */ (function (_super) {
__extends$29(InfiniteBlock, _super);
function InfiniteBlock(pageNumber, params) {
var _this = _super.call(this, pageNumber, params) || this;
_this.cacheParams = params;
return _this;
}
InfiniteBlock.prototype.getDisplayIndexStart = function () {
return this.getBlockNumber() * this.cacheParams.blockSize;
};
// this is an estimate, as the last block will probably only be partially full. however
// this method is used to know if this block is been rendered, before destroying, so
// and this estimate works in that use case.
InfiniteBlock.prototype.getDisplayIndexEnd = function () {
return this.getDisplayIndexStart() + this.cacheParams.blockSize;
};
InfiniteBlock.prototype.createBlankRowNode = function (rowIndex) {
var rowNode = _super.prototype.createBlankRowNode.call(this, rowIndex);
rowNode.uiLevel = 0;
this.setIndexAndTopOnRowNode(rowNode, rowIndex);
return rowNode;
};
InfiniteBlock.prototype.setDataAndId = function (rowNode, data, index) {
if (_.exists(data)) {
// this means if the user is not providing id's we just use the
// index for the row. this will allow selection to work (that is based
// on index) as long user is not inserting or deleting rows,
// or wanting to keep selection between server side sorting or filtering
rowNode.setDataAndId(data, index.toString());
}
else {
rowNode.setDataAndId(undefined, undefined);
}
};
InfiniteBlock.prototype.setRowNode = function (rowIndex, rowNode) {
_super.prototype.setRowNode.call(this, rowIndex, rowNode);
this.setIndexAndTopOnRowNode(rowNode, rowIndex);
};
InfiniteBlock.prototype.init = function () {
_super.prototype.init.call(this, {
context: this.getContext(),
rowRenderer: this.rowRenderer
});
};
InfiniteBlock.prototype.getNodeIdPrefix = function () {
return null;
};
InfiniteBlock.prototype.getRow = function (displayIndex) {
return this.getRowUsingLocalIndex(displayIndex);
};
InfiniteBlock.prototype.setIndexAndTopOnRowNode = function (rowNode, rowIndex) {
rowNode.setRowIndex(rowIndex);
rowNode.rowTop = this.cacheParams.rowHeight * rowIndex;
};
InfiniteBlock.prototype.loadFromDatasource = function () {
var _this = this;
// PROBLEM . . . . when the user sets sort via colDef.sort, then this code
// is executing before the sort is set up, so server is not getting the sort
// model. need to change with regards order - so the server side request is
// AFTER thus it gets the right sort model.
var params = {
startRow: this.getStartRow(),
endRow: this.getEndRow(),
successCallback: this.pageLoaded.bind(this, this.getVersion()),
failCallback: this.pageLoadFailed.bind(this),
sortModel: this.cacheParams.sortModel,
filterModel: this.cacheParams.filterModel,
context: this.gridOptionsWrapper.getContext()
};
if (_.missing(this.cacheParams.datasource.getRows)) {
console.warn("ag-Grid: datasource is missing getRows method");
return;
}
// put in timeout, to force result to be async
window.setTimeout(function () {
_this.cacheParams.datasource.getRows(params);
}, 0);
};
__decorate$24([
Autowired('gridOptionsWrapper')
], InfiniteBlock.prototype, "gridOptionsWrapper", void 0);
__decorate$24([
Autowired('rowRenderer')
], InfiniteBlock.prototype, "rowRenderer", void 0);
__decorate$24([
PostConstruct
], InfiniteBlock.prototype, "init", null);
return InfiniteBlock;
}(RowNodeBlock));
var __extends$2a = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate$25 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __param$a = (undefined && undefined.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
var InfiniteCache = /** @class */ (function (_super) {
__extends$2a(InfiniteCache, _super);
function InfiniteCache(params) {
return _super.call(this, params) || this;
}
InfiniteCache.prototype.setBeans = function (loggerFactory) {
this.logger = loggerFactory.create('InfiniteCache');
};
InfiniteCache.prototype.moveItemsDown = function (block, moveFromIndex, moveCount) {
var startRow = block.getStartRow();
var endRow = block.getEndRow();
var indexOfLastRowToMove = moveFromIndex + moveCount;
// all rows need to be moved down below the insertion index
for (var currentRowIndex = endRow - 1; currentRowIndex >= startRow; currentRowIndex--) {
// don't move rows at or before the insertion index
if (currentRowIndex < indexOfLastRowToMove) {
continue;
}
var indexOfNodeWeWant = currentRowIndex - moveCount;
var nodeForThisIndex = this.getRow(indexOfNodeWeWant, true);
if (nodeForThisIndex) {
block.setRowNode(currentRowIndex, nodeForThisIndex);
}
else {
block.setBlankRowNode(currentRowIndex);
block.setDirty();
}
}
};
InfiniteCache.prototype.insertItems = function (block, indexToInsert, items) {
var pageStartRow = block.getStartRow();
var pageEndRow = block.getEndRow();
var newRowNodes = [];
// next stage is insert the rows into this page, if applicable
for (var index = 0; index < items.length; index++) {
var rowIndex = indexToInsert + index;
var currentRowInThisPage = rowIndex >= pageStartRow && rowIndex < pageEndRow;
if (currentRowInThisPage) {
var dataItem = items[index];
var newRowNode = block.setNewData(rowIndex, dataItem);
newRowNodes.push(newRowNode);
}
}
return newRowNodes;
};
InfiniteCache.prototype.insertItemsAtIndex = function (indexToInsert, items) {
// get all page id's as NUMBERS (not strings, as we need to sort as numbers) and in descending order
var _this = this;
var newNodes = [];
this.forEachBlockInReverseOrder(function (block) {
var pageEndRow = block.getEndRow();
// if the insertion is after this page, then this page is not impacted
if (pageEndRow <= indexToInsert) {
return;
}
_this.moveItemsDown(block, indexToInsert, items.length);
var newNodesThisPage = _this.insertItems(block, indexToInsert, items);
newNodesThisPage.forEach(function (rowNode) { return newNodes.push(rowNode); });
});
if (this.isMaxRowFound()) {
this.hack_setVirtualRowCount(this.getVirtualRowCount() + items.length);
}
this.onCacheUpdated();
var event = {
type: Events.EVENT_ROW_DATA_UPDATED,
api: this.gridApi,
columnApi: this.columnApi
};
this.eventService.dispatchEvent(event);
};
// the rowRenderer will not pass dontCreatePage, meaning when rendering the grid,
// it will want new pages in the cache as it asks for rows. only when we are inserting /
// removing rows via the api is dontCreatePage set, where we move rows between the pages.
InfiniteCache.prototype.getRow = function (rowIndex, dontCreatePage) {
if (dontCreatePage === void 0) { dontCreatePage = false; }
var blockId = Math.floor(rowIndex / this.cacheParams.blockSize);
var block = this.getBlock(blockId);
if (!block) {
if (dontCreatePage) {
return null;
}
else {
block = this.createBlock(blockId);
}
}
return block.getRow(rowIndex);
};
InfiniteCache.prototype.createBlock = function (blockNumber) {
var newBlock = new InfiniteBlock(blockNumber, this.cacheParams);
this.getContext().createBean(newBlock);
this.postCreateBlock(newBlock);
return newBlock;
};
// we have this on infinite row model only, not server side row model,
// because for server side, it would leave the children in inconsistent
// state - eg if a node had children, but after the refresh it had data
// for a different row, then the children would be with the wrong row node.
InfiniteCache.prototype.refreshCache = function () {
this.forEachBlockInOrder(function (block) { return block.setDirty(); });
this.checkBlockToLoad();
};
__decorate$25([
Autowired('columnApi')
], InfiniteCache.prototype, "columnApi", void 0);
__decorate$25([
Autowired('gridApi')
], InfiniteCache.prototype, "gridApi", void 0);
__decorate$25([
__param$a(0, Qualifier('loggerFactory'))
], InfiniteCache.prototype, "setBeans", null);
return InfiniteCache;
}(RowNodeCache));
var __extends$2b = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate$26 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var InfiniteRowModel = /** @class */ (function (_super) {
__extends$2b(InfiniteRowModel, _super);
function InfiniteRowModel() {
return _super !== null && _super.apply(this, arguments) || this;
}
InfiniteRowModel.prototype.getRowBounds = function (index) {
return {
rowHeight: this.rowHeight,
rowTop: this.rowHeight * index
};
};
// we don't implement as lazy row heights is not supported in this row model
InfiniteRowModel.prototype.ensureRowHeightsValid = function (startPixel, endPixel, startLimitIndex, endLimitIndex) {
return false;
};
InfiniteRowModel.prototype.init = function () {
var _this = this;
if (!this.gridOptionsWrapper.isRowModelInfinite()) {
return;
}
this.rowHeight = this.gridOptionsWrapper.getRowHeightAsNumber();
this.addEventListeners();
this.addDestroyFunc(function () { return _this.destroyCache(); });
};
InfiniteRowModel.prototype.start = function () {
this.setDatasource(this.gridOptionsWrapper.getDatasource());
};
InfiniteRowModel.prototype.destroyDatasource = function () {
if (this.datasource) {
this.getContext().destroyBean(this.datasource);
this.rowRenderer.datasourceChanged();
this.datasource = null;
}
};
InfiniteRowModel.prototype.isLastRowFound = function () {
return this.infiniteCache ? this.infiniteCache.isMaxRowFound() : false;
};
InfiniteRowModel.prototype.addEventListeners = function () {
this.addManagedListener(this.eventService, Events.EVENT_FILTER_CHANGED, this.onFilterChanged.bind(this));
this.addManagedListener(this.eventService, Events.EVENT_SORT_CHANGED, this.onSortChanged.bind(this));
this.addManagedListener(this.eventService, Events.EVENT_COLUMN_EVERYTHING_CHANGED, this.onColumnEverything.bind(this));
};
InfiniteRowModel.prototype.onFilterChanged = function () {
this.reset();
};
InfiniteRowModel.prototype.onSortChanged = function () {
this.reset();
};
InfiniteRowModel.prototype.onColumnEverything = function () {
var resetRequired;
// if cache params, we require reset only if sort model has changed. we don't need to check
// for filter model, as the filter manager will fire an event when columns change that result
// in the filter changing.
if (this.cacheParams) {
resetRequired = this.isSortModelDifferent();
}
else {
// if no cacheParams, means first time creating the cache, so always create one
resetRequired = true;
}
if (resetRequired) {
this.reset();
}
};
InfiniteRowModel.prototype.isSortModelDifferent = function () {
return !_.jsonEquals(this.cacheParams.sortModel, this.sortController.getSortModel());
};
InfiniteRowModel.prototype.getType = function () {
return Constants.ROW_MODEL_TYPE_INFINITE;
};
InfiniteRowModel.prototype.setDatasource = function (datasource) {
this.destroyDatasource();
this.datasource = datasource;
// only reset if we have a valid datasource to working with
if (datasource) {
this.reset();
}
};
InfiniteRowModel.prototype.isEmpty = function () {
return _.missing(this.infiniteCache);
};
InfiniteRowModel.prototype.isRowsToRender = function () {
return _.exists(this.infiniteCache);
};
InfiniteRowModel.prototype.getNodesInRangeForSelection = function (firstInRange, lastInRange) {
return this.infiniteCache ? this.infiniteCache.getRowNodesInRange(firstInRange, lastInRange) : [];
};
InfiniteRowModel.prototype.reset = function () {
// important to return here, as the user could be setting filter or sort before
// data-source is set
if (_.missing(this.datasource)) {
return;
}
// if user is providing id's, then this means we can keep the selection between datasource hits,
// as the rows will keep their unique id's even if, for example, server side sorting or filtering
// is done.
var userGeneratingIds = _.exists(this.gridOptionsWrapper.getRowNodeIdFunc());
if (!userGeneratingIds) {
this.selectionController.reset();
}
this.resetCache();
var event = this.createModelUpdatedEvent();
this.eventService.dispatchEvent(event);
};
InfiniteRowModel.prototype.createModelUpdatedEvent = function () {
return {
type: Events.EVENT_MODEL_UPDATED,
api: this.gridApi,
columnApi: this.columnApi,
// not sure if these should all be false - noticed if after implementing,
// maybe they should be true?
newPage: false,
newData: false,
keepRenderedRows: false,
animate: false
};
};
InfiniteRowModel.prototype.resetCache = function () {
// if not first time creating a cache, need to destroy the old one
this.destroyCache();
var maxConcurrentRequests = this.gridOptionsWrapper.getMaxConcurrentDatasourceRequests();
var blockLoadDebounceMillis = this.gridOptionsWrapper.getBlockLoadDebounceMillis();
// there is a bi-directional dependency between the loader and the cache,
// so we create loader here, and then pass dependencies in setDependencies() method later
this.rowNodeBlockLoader = new RowNodeBlockLoader(maxConcurrentRequests, blockLoadDebounceMillis);
this.getContext().createBean(this.rowNodeBlockLoader);
this.cacheParams = {
// the user provided datasource
datasource: this.datasource,
// sort and filter model
filterModel: this.filterManager.getFilterModel(),
sortModel: this.sortController.getSortModel(),
rowNodeBlockLoader: this.rowNodeBlockLoader,
// properties - this way we take a snapshot of them, so if user changes any, they will be
// used next time we create a new cache, which is generally after a filter or sort change,
// or a new datasource is set
maxConcurrentRequests: maxConcurrentRequests,
overflowSize: this.gridOptionsWrapper.getCacheOverflowSize(),
initialRowCount: this.gridOptionsWrapper.getInfiniteInitialRowCount(),
maxBlocksInCache: this.gridOptionsWrapper.getMaxBlocksInCache(),
blockSize: this.gridOptionsWrapper.getCacheBlockSize(),
rowHeight: this.gridOptionsWrapper.getRowHeightAsNumber(),
// the cache could create this, however it is also used by the pages, so handy to create it
// here as the settings are also passed to the pages
lastAccessedSequence: new NumberSequence()
};
// set defaults
if (!this.cacheParams.maxConcurrentRequests || !(this.cacheParams.maxConcurrentRequests >= 1)) {
this.cacheParams.maxConcurrentRequests = 2;
}
// page size needs to be 1 or greater. having it at 1 would be silly, as you would be hitting the
// server for one page at a time. so the default if not specified is 100.
if (!this.cacheParams.blockSize || !(this.cacheParams.blockSize >= 1)) {
this.cacheParams.blockSize = 100;
}
// if user doesn't give initial rows to display, we assume one
if (!(this.cacheParams.initialRowCount >= 1)) {
this.cacheParams.initialRowCount = 1;
}
// if user doesn't provide overflow, we use default overflow of 1, so user can scroll past
// the current page and request first row of next page
if (!(this.cacheParams.overflowSize >= 1)) {
this.cacheParams.overflowSize = 1;
}
this.infiniteCache = new InfiniteCache(this.cacheParams);
this.getContext().createBean(this.infiniteCache);
this.infiniteCache.addEventListener(RowNodeCache.EVENT_CACHE_UPDATED, this.onCacheUpdated.bind(this));
};
InfiniteRowModel.prototype.destroyCache = function () {
if (this.infiniteCache) {
this.infiniteCache = this.destroyBean(this.infiniteCache);
}
if (this.rowNodeBlockLoader) {
this.rowNodeBlockLoader = this.destroyBean(this.rowNodeBlockLoader);
}
};
InfiniteRowModel.prototype.onCacheUpdated = function () {
var event = this.createModelUpdatedEvent();
this.eventService.dispatchEvent(event);
};
InfiniteRowModel.prototype.getRow = function (rowIndex) {
return this.infiniteCache ? this.infiniteCache.getRow(rowIndex) : null;
};
InfiniteRowModel.prototype.getRowNode = function (id) {
var result = null;
this.forEachNode(function (rowNode) {
if (rowNode.id === id) {
result = rowNode;
}
});
return result;
};
InfiniteRowModel.prototype.forEachNode = function (callback) {
if (this.infiniteCache) {
this.infiniteCache.forEachNodeDeep(callback, new NumberSequence());
}
};
InfiniteRowModel.prototype.getCurrentPageHeight = function () {
return this.getRowCount() * this.rowHeight;
};
InfiniteRowModel.prototype.getTopLevelRowCount = function () {
return this.getRowCount();
};
InfiniteRowModel.prototype.getTopLevelRowDisplayedIndex = function (topLevelIndex) {
return topLevelIndex;
};
InfiniteRowModel.prototype.getRowIndexAtPixel = function (pixel) {
if (this.rowHeight !== 0) { // avoid divide by zero error
var rowIndexForPixel = Math.floor(pixel / this.rowHeight);
var lastRowIndex = this.getRowCount() - 1;
if (rowIndexForPixel > lastRowIndex) {
return lastRowIndex;
}
else {
return rowIndexForPixel;
}
}
else {
return 0;
}
};
InfiniteRowModel.prototype.getRowCount = function () {
return this.infiniteCache ? this.infiniteCache.getVirtualRowCount() : 0;
};
InfiniteRowModel.prototype.updateRowData = function (transaction) {
if (_.exists(transaction.remove) || _.exists(transaction.update)) {
console.warn('ag-Grid: updateRowData for InfiniteRowModel does not support remove or update, only add');
return;
}
if (_.missing(transaction.addIndex)) {
console.warn('ag-Grid: updateRowData for InfiniteRowModel requires add and addIndex to be set');
return;
}
if (this.infiniteCache) {
this.infiniteCache.insertItemsAtIndex(transaction.addIndex, transaction.add);
}
};
InfiniteRowModel.prototype.isRowPresent = function (rowNode) {
return false;
};
InfiniteRowModel.prototype.refreshCache = function () {
if (this.infiniteCache) {
this.infiniteCache.refreshCache();
}
};
InfiniteRowModel.prototype.purgeCache = function () {
if (this.infiniteCache) {
this.infiniteCache.purgeCache();
}
};
InfiniteRowModel.prototype.getVirtualRowCount = function () {
if (this.infiniteCache) {
return this.infiniteCache.getVirtualRowCount();
}
else {
return null;
}
};
InfiniteRowModel.prototype.isMaxRowFound = function () {
if (this.infiniteCache) {
return this.infiniteCache.isMaxRowFound();
}
};
InfiniteRowModel.prototype.setVirtualRowCount = function (rowCount, maxRowFound) {
if (this.infiniteCache) {
this.infiniteCache.setVirtualRowCount(rowCount, maxRowFound);
}
};
InfiniteRowModel.prototype.getBlockState = function () {
if (this.rowNodeBlockLoader) {
return this.rowNodeBlockLoader.getBlockState();
}
else {
return null;
}
};
__decorate$26([
Autowired('gridOptionsWrapper')
], InfiniteRowModel.prototype, "gridOptionsWrapper", void 0);
__decorate$26([
Autowired('filterManager')
], InfiniteRowModel.prototype, "filterManager", void 0);
__decorate$26([
Autowired('sortController')
], InfiniteRowModel.prototype, "sortController", void 0);
__decorate$26([
Autowired('selectionController')
], InfiniteRowModel.prototype, "selectionController", void 0);
__decorate$26([
Autowired('gridApi')
], InfiniteRowModel.prototype, "gridApi", void 0);
__decorate$26([
Autowired('columnApi')
], InfiniteRowModel.prototype, "columnApi", void 0);
__decorate$26([
Autowired('rowRenderer')
], InfiniteRowModel.prototype, "rowRenderer", void 0);
__decorate$26([
PostConstruct
], InfiniteRowModel.prototype, "init", null);
__decorate$26([
PreDestroy
], InfiniteRowModel.prototype, "destroyDatasource", null);
InfiniteRowModel = __decorate$26([
Bean('rowModel')
], InfiniteRowModel);
return InfiniteRowModel;
}(BeanStub));
var InfiniteRowModelModule = {
moduleName: exports.ModuleNames.InfiniteRowModelModule,
rowModels: { 'infinite': InfiniteRowModel }
};
var __extends$2c = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate$27 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var BaseGridSerializingSession = /** @class */ (function () {
function BaseGridSerializingSession(config) {
this.groupColumns = [];
var columnController = config.columnController, valueService = config.valueService, gridOptionsWrapper = config.gridOptionsWrapper, processCellCallback = config.processCellCallback, processHeaderCallback = config.processHeaderCallback, processGroupHeaderCallback = config.processGroupHeaderCallback, processRowGroupCallback = config.processRowGroupCallback;
this.columnController = columnController;
this.valueService = valueService;
this.gridOptionsWrapper = gridOptionsWrapper;
this.processCellCallback = processCellCallback;
this.processHeaderCallback = processHeaderCallback;
this.processGroupHeaderCallback = processGroupHeaderCallback;
this.processRowGroupCallback = processRowGroupCallback;
}
BaseGridSerializingSession.prototype.prepare = function (columnsToExport) {
this.groupColumns = _.filter(columnsToExport, function (col) { return !!col.getColDef().showRowGroup; });
};
BaseGridSerializingSession.prototype.extractHeaderValue = function (column) {
var value = this.getHeaderName(this.processHeaderCallback, column);
return value != null ? value : '';
};
BaseGridSerializingSession.prototype.extractRowCellValue = function (column, index, type, node) {
// we render the group summary text e.g. "-> Parent -> Child"...
var groupIndex = this.gridOptionsWrapper.isGroupMultiAutoColumn() ? node.rowGroupIndex : 0;
var renderGroupSummaryCell =
// on group rows
node && node.group
&& (
// in the group column if groups appear in regular grid cells
index === groupIndex && this.groupColumns.indexOf(column) !== -1
// or the first cell in the row, if we're doing full width rows
|| (index === 0 && this.gridOptionsWrapper.isGroupUseEntireRow(this.columnController.isPivotMode())));
var valueForCell;
if (renderGroupSummaryCell) {
valueForCell = this.createValueForGroupNode(node);
}
else {
valueForCell = this.valueService.getValue(column, node);
}
var value = this.processCell(node, column, valueForCell, this.processCellCallback, type);
return value != null ? value : '';
};
BaseGridSerializingSession.prototype.getHeaderName = function (callback, column) {
if (callback) {
return callback({
column: column,
api: this.gridOptionsWrapper.getApi(),
columnApi: this.gridOptionsWrapper.getColumnApi(),
context: this.gridOptionsWrapper.getContext()
});
}
return this.columnController.getDisplayNameForColumn(column, 'csv', true);
};
BaseGridSerializingSession.prototype.createValueForGroupNode = function (node) {
if (this.processRowGroupCallback) {
return this.processRowGroupCallback({
node: node,
api: this.gridOptionsWrapper.getApi(),
columnApi: this.gridOptionsWrapper.getColumnApi(),
context: this.gridOptionsWrapper.getContext(),
});
}
var keys = [node.key];
if (!this.gridOptionsWrapper.isGroupMultiAutoColumn()) {
while (node.parent) {
node = node.parent;
keys.push(node.key);
}
}
return keys.reverse().join(' -> ');
};
BaseGridSerializingSession.prototype.processCell = function (rowNode, column, value, processCellCallback, type) {
if (processCellCallback) {
return processCellCallback({
column: column,
node: rowNode,
value: value,
api: this.gridOptionsWrapper.getApi(),
columnApi: this.gridOptionsWrapper.getColumnApi(),
context: this.gridOptionsWrapper.getContext(),
type: type
});
}
return value;
};
return BaseGridSerializingSession;
}());
var GridSerializer = /** @class */ (function (_super) {
__extends$2c(GridSerializer, _super);
function GridSerializer() {
return _super !== null && _super.apply(this, arguments) || this;
}
GridSerializer.prototype.serialize = function (gridSerializingSession, params) {
if (params === void 0) { params = {}; }
var rowSkipper = params.shouldRowBeSkipped || (function () { return false; });
var api = this.gridOptionsWrapper.getApi();
var columnApi = this.gridOptionsWrapper.getColumnApi();
var skipSingleChildrenGroup = this.gridOptionsWrapper.isGroupRemoveSingleChildren();
var skipLowestSingleChildrenGroup = this.gridOptionsWrapper.isGroupRemoveLowestSingleChildren();
var context = this.gridOptionsWrapper.getContext();
// when in pivot mode, we always render cols on screen, never 'all columns'
var isPivotMode = this.columnController.isPivotMode();
var rowModelNormal = this.rowModel.getType() === Constants.ROW_MODEL_TYPE_CLIENT_SIDE;
var onlySelectedNonStandardModel = !rowModelNormal && params.onlySelected;
var columnsToExport = [];
if (_.existsAndNotEmpty(params.columnKeys)) {
columnsToExport = this.columnController.getGridColumns(params.columnKeys);
}
else if (params.allColumns && !isPivotMode) {
// add auto group column for tree data
columnsToExport = this.gridOptionsWrapper.isTreeData() ?
this.columnController.getGridColumns([Constants.GROUP_AUTO_COLUMN_ID]) : [];
columnsToExport = columnsToExport.concat(this.columnController.getAllPrimaryColumns() || []);
}
else {
columnsToExport = this.columnController.getAllDisplayedColumns();
}
if (params.customHeader) {
gridSerializingSession.addCustomContent(params.customHeader);
}
gridSerializingSession.prepare(columnsToExport);
// first pass, put in the header names of the cols
if (params.columnGroups) {
var groupInstanceIdCreator = new GroupInstanceIdCreator();
var displayedGroups = this.displayedGroupCreator.createDisplayedGroups(columnsToExport, this.columnController.getGridBalancedTree(), groupInstanceIdCreator, null);
this.recursivelyAddHeaderGroups(displayedGroups, gridSerializingSession, params.processGroupHeaderCallback);
}
if (!params.skipHeader) {
var gridRowIterator_1 = gridSerializingSession.onNewHeaderRow();
columnsToExport.forEach(function (column, index) {
gridRowIterator_1.onColumn(column, index, undefined);
});
}
this.pinnedRowModel.forEachPinnedTopRow(processRow);
if (isPivotMode) {
if (this.rowModel.forEachPivotNode) {
this.rowModel.forEachPivotNode(processRow);
}
else {
//Must be enterprise, so we can just loop through all the nodes
this.rowModel.forEachNode(processRow);
}
}
else {
// onlySelectedAllPages: user doing pagination and wants selected items from
// other pages, so cannot use the standard row model as it won't have rows from
// other pages.
// onlySelectedNonStandardModel: if user wants selected in non standard row model
// (eg viewport) then again rowmodel cannot be used, so need to use selected instead.
if (params.onlySelectedAllPages || onlySelectedNonStandardModel) {
var selectedNodes = this.selectionController.getSelectedNodes();
selectedNodes.forEach(function (node) {
processRow(node);
});
}
else {
// here is everything else - including standard row model and selected. we don't use
// the selection model even when just using selected, so that the result is the order
// of the rows appearing on the screen.
if (rowModelNormal) {
this.rowModel.forEachNodeAfterFilterAndSort(processRow);
}
else {
this.rowModel.forEachNode(processRow);
}
}
}
this.pinnedRowModel.forEachPinnedBottomRow(processRow);
if (params.customFooter) {
gridSerializingSession.addCustomContent(params.customFooter);
}
function processRow(node) {
var shouldSkipLowestGroup = skipLowestSingleChildrenGroup && node.leafGroup;
var shouldSkipCurrentGroup = node.allChildrenCount === 1 && (skipSingleChildrenGroup || shouldSkipLowestGroup);
if (node.group && (params.skipGroups || shouldSkipCurrentGroup)) {
return;
}
if (params.skipFooters && node.footer) {
return;
}
if (params.onlySelected && !node.isSelected()) {
return;
}
if (params.skipPinnedTop && node.rowPinned === 'top') {
return;
}
if (params.skipPinnedBottom && node.rowPinned === 'bottom') {
return;
}
// if we are in pivotMode, then the grid will show the root node only
// if it's not a leaf group
var nodeIsRootNode = node.level === -1;
if (nodeIsRootNode && !node.leafGroup) {
return;
}
var shouldRowBeSkipped = rowSkipper({ node: node, api: api, context: context });
if (shouldRowBeSkipped) {
return;
}
var rowAccumulator = gridSerializingSession.onNewBodyRow();
columnsToExport.forEach(function (column, index) {
rowAccumulator.onColumn(column, index, node);
});
if (params.getCustomContentBelowRow) {
var content = params.getCustomContentBelowRow({ node: node, api: api, columnApi: columnApi, context: context });
if (content) {
gridSerializingSession.addCustomContent(content);
}
}
}
return gridSerializingSession.parse();
};
GridSerializer.prototype.recursivelyAddHeaderGroups = function (displayedGroups, gridSerializingSession, processGroupHeaderCallback) {
var directChildrenHeaderGroups = [];
displayedGroups.forEach(function (columnGroupChild) {
var columnGroup = columnGroupChild;
if (!columnGroup.getChildren) {
return;
}
columnGroup.getChildren().forEach(function (it) { return directChildrenHeaderGroups.push(it); });
});
if (displayedGroups.length > 0 && displayedGroups[0] instanceof ColumnGroup) {
this.doAddHeaderHeader(gridSerializingSession, displayedGroups, processGroupHeaderCallback);
}
if (directChildrenHeaderGroups && directChildrenHeaderGroups.length > 0) {
this.recursivelyAddHeaderGroups(directChildrenHeaderGroups, gridSerializingSession, processGroupHeaderCallback);
}
};
GridSerializer.prototype.doAddHeaderHeader = function (gridSerializingSession, displayedGroups, processGroupHeaderCallback) {
var _this = this;
var gridRowIterator = gridSerializingSession.onNewHeaderGroupingRow();
var columnIndex = 0;
displayedGroups.forEach(function (columnGroupChild) {
var columnGroup = columnGroupChild;
var name;
if (processGroupHeaderCallback) {
name = processGroupHeaderCallback({
columnGroup: columnGroup,
api: _this.gridOptionsWrapper.getApi(),
columnApi: _this.gridOptionsWrapper.getColumnApi(),
context: _this.gridOptionsWrapper.getContext()
});
}
else {
name = _this.columnController.getDisplayNameForColumnGroup(columnGroup, 'header');
}
gridRowIterator.onColumn(name || '', columnIndex++, columnGroup.getLeafColumns().length - 1);
});
};
__decorate$27([
Autowired('displayedGroupCreator')
], GridSerializer.prototype, "displayedGroupCreator", void 0);
__decorate$27([
Autowired('columnController')
], GridSerializer.prototype, "columnController", void 0);
__decorate$27([
Autowired('rowModel')
], GridSerializer.prototype, "rowModel", void 0);
__decorate$27([
Autowired('pinnedRowModel')
], GridSerializer.prototype, "pinnedRowModel", void 0);
__decorate$27([
Autowired('selectionController')
], GridSerializer.prototype, "selectionController", void 0);
__decorate$27([
Autowired('columnFactory')
], GridSerializer.prototype, "columnFactory", void 0);
__decorate$27([
Autowired('gridOptionsWrapper')
], GridSerializer.prototype, "gridOptionsWrapper", void 0);
GridSerializer = __decorate$27([
Bean("gridSerializer")
], GridSerializer);
return GridSerializer;
}(BeanStub));
var RowType;
(function (RowType) {
RowType[RowType["HEADER_GROUPING"] = 0] = "HEADER_GROUPING";
RowType[RowType["HEADER"] = 1] = "HEADER";
RowType[RowType["BODY"] = 2] = "BODY";
})(RowType || (RowType = {}));
var __extends$2d = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate$28 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var LINE_SEPARATOR = '\r\n';
var CsvSerializingSession = /** @class */ (function (_super) {
__extends$2d(CsvSerializingSession, _super);
function CsvSerializingSession(config) {
var _this = _super.call(this, config) || this;
_this.isFirstLine = true;
_this.result = '';
var suppressQuotes = config.suppressQuotes, columnSeparator = config.columnSeparator;
_this.suppressQuotes = suppressQuotes;
_this.columnSeparator = columnSeparator;
return _this;
}
CsvSerializingSession.prototype.addCustomContent = function (content) {
var _this = this;
if (!content) {
return;
}
if (typeof content === 'string') {
// we used to require the customFooter to be prefixed with a newline but no longer do,
// so only add the newline if the user has not supplied one
if (!/^\s*\n/.test(content)) {
this.beginNewLine();
}
// replace whatever newlines are supplied with the style we're using
content = content.replace(/\r?\n/g, LINE_SEPARATOR);
this.result += content;
}
else {
content.forEach(function (row) {
_this.beginNewLine();
row.forEach(function (cell, index) {
if (index !== 0) {
_this.result += _this.columnSeparator;
}
_this.result += _this.putInQuotes(cell.data.value || '');
if (cell.mergeAcross) {
_this.appendEmptyCells(cell.mergeAcross);
}
});
});
}
};
CsvSerializingSession.prototype.onNewHeaderGroupingRow = function () {
this.beginNewLine();
return {
onColumn: this.onNewHeaderGroupingRowColumn.bind(this)
};
};
CsvSerializingSession.prototype.onNewHeaderGroupingRowColumn = function (header, index, span) {
if (index != 0) {
this.result += this.columnSeparator;
}
this.result += this.putInQuotes(header);
this.appendEmptyCells(span);
};
CsvSerializingSession.prototype.appendEmptyCells = function (count) {
for (var i = 1; i <= count; i++) {
this.result += this.columnSeparator + this.putInQuotes("");
}
};
CsvSerializingSession.prototype.onNewHeaderRow = function () {
this.beginNewLine();
return {
onColumn: this.onNewHeaderRowColumn.bind(this)
};
};
CsvSerializingSession.prototype.onNewHeaderRowColumn = function (column, index, node) {
if (index != 0) {
this.result += this.columnSeparator;
}
this.result += this.putInQuotes(this.extractHeaderValue(column));
};
CsvSerializingSession.prototype.onNewBodyRow = function () {
this.beginNewLine();
return {
onColumn: this.onNewBodyRowColumn.bind(this)
};
};
CsvSerializingSession.prototype.onNewBodyRowColumn = function (column, index, node) {
if (index != 0) {
this.result += this.columnSeparator;
}
this.result += this.putInQuotes(this.extractRowCellValue(column, index, Constants.EXPORT_TYPE_CSV, node));
};
CsvSerializingSession.prototype.putInQuotes = function (value) {
if (this.suppressQuotes) {
return value;
}
if (value === null || value === undefined) {
return '""';
}
var stringValue;
if (typeof value === 'string') {
stringValue = value;
}
else if (typeof value.toString === 'function') {
stringValue = value.toString();
}
else {
console.warn('unknown value type during csv conversion');
stringValue = '';
}
// replace each " with "" (ie two sets of double quotes is how to do double quotes in csv)
var valueEscaped = stringValue.replace(/"/g, "\"\"");
return '"' + valueEscaped + '"';
};
CsvSerializingSession.prototype.parse = function () {
return this.result;
};
CsvSerializingSession.prototype.beginNewLine = function () {
if (!this.isFirstLine) {
this.result += LINE_SEPARATOR;
}
this.isFirstLine = false;
};
return CsvSerializingSession;
}(BaseGridSerializingSession));
var BaseCreator = /** @class */ (function () {
function BaseCreator() {
}
BaseCreator.prototype.setBeans = function (beans) {
this.beans = beans;
};
BaseCreator.prototype.export = function (userParams) {
if (this.isExportSuppressed()) {
console.warn("ag-grid: Export cancelled. Export is not allowed as per your configuration.");
return '';
}
var _a = this.getMergedParamsAndData(userParams), mergedParams = _a.mergedParams, data = _a.data;
var fileNamePresent = mergedParams && mergedParams.fileName && mergedParams.fileName.length !== 0;
var fileName = fileNamePresent ? mergedParams.fileName : this.getDefaultFileName();
if (fileName.indexOf(".") === -1) {
fileName = fileName + "." + this.getDefaultFileExtension();
}
this.beans.downloader.download(fileName, this.packageFile(data));
return data;
};
BaseCreator.prototype.getData = function (params) {
return this.getMergedParamsAndData(params).data;
};
BaseCreator.prototype.getMergedParamsAndData = function (userParams) {
var mergedParams = this.mergeDefaultParams(userParams);
var data = this.beans.gridSerializer.serialize(this.createSerializingSession(mergedParams), mergedParams);
return { mergedParams: mergedParams, data: data };
};
BaseCreator.prototype.mergeDefaultParams = function (userParams) {
var baseParams = this.beans.gridOptionsWrapper.getDefaultExportParams();
var params = {};
_.assign(params, baseParams);
_.assign(params, userParams);
return params;
};
BaseCreator.prototype.packageFile = function (data) {
return new Blob(["\ufeff", data], {
type: window.navigator.msSaveOrOpenBlob ? this.getMimeType() : 'octet/stream'
});
};
return BaseCreator;
}());
var CsvCreator = /** @class */ (function (_super) {
__extends$2d(CsvCreator, _super);
function CsvCreator() {
return _super !== null && _super.apply(this, arguments) || this;
}
CsvCreator.prototype.postConstruct = function () {
this.setBeans({
downloader: this.downloader,
gridSerializer: this.gridSerializer,
gridOptionsWrapper: this.gridOptionsWrapper
});
};
CsvCreator.prototype.exportDataAsCsv = function (params) {
return this.export(params);
};
CsvCreator.prototype.getDataAsCsv = function (params) {
return this.getData(params);
};
CsvCreator.prototype.getMimeType = function () {
return 'text/csv;charset=utf-8;';
};
CsvCreator.prototype.getDefaultFileName = function () {
return 'export.csv';
};
CsvCreator.prototype.getDefaultFileExtension = function () {
return 'csv';
};
CsvCreator.prototype.createSerializingSession = function (params) {
var _a = this, columnController = _a.columnController, valueService = _a.valueService, gridOptionsWrapper = _a.gridOptionsWrapper;
var processCellCallback = params.processCellCallback, processHeaderCallback = params.processHeaderCallback, processGroupHeaderCallback = params.processGroupHeaderCallback, processRowGroupCallback = params.processRowGroupCallback, suppressQuotes = params.suppressQuotes, columnSeparator = params.columnSeparator;
return new CsvSerializingSession({
columnController: columnController,
valueService: valueService,
gridOptionsWrapper: gridOptionsWrapper,
processCellCallback: processCellCallback || undefined,
processHeaderCallback: processHeaderCallback || undefined,
processGroupHeaderCallback: processGroupHeaderCallback || undefined,
processRowGroupCallback: processRowGroupCallback || undefined,
suppressQuotes: suppressQuotes || false,
columnSeparator: columnSeparator || ','
});
};
CsvCreator.prototype.isExportSuppressed = function () {
return this.gridOptionsWrapper.isSuppressCsvExport();
};
__decorate$28([
Autowired('columnController')
], CsvCreator.prototype, "columnController", void 0);
__decorate$28([
Autowired('valueService')
], CsvCreator.prototype, "valueService", void 0);
__decorate$28([
Autowired('downloader')
], CsvCreator.prototype, "downloader", void 0);
__decorate$28([
Autowired('gridSerializer')
], CsvCreator.prototype, "gridSerializer", void 0);
__decorate$28([
Autowired('gridOptionsWrapper')
], CsvCreator.prototype, "gridOptionsWrapper", void 0);
__decorate$28([
PostConstruct
], CsvCreator.prototype, "postConstruct", null);
CsvCreator = __decorate$28([
Bean('csvCreator')
], CsvCreator);
return CsvCreator;
}(BaseCreator));
var __decorate$29 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var Downloader = /** @class */ (function () {
function Downloader() {
}
Downloader.prototype.download = function (fileName, content) {
// Internet Explorer
if (window.navigator.msSaveOrOpenBlob) {
window.navigator.msSaveOrOpenBlob(content, fileName);
}
else {
// Other Browsers
var element = document.createElement("a");
var url_1 = window.URL.createObjectURL(content);
element.setAttribute("href", url_1);
element.setAttribute("download", fileName);
element.style.display = "none";
document.body.appendChild(element);
element.dispatchEvent(new MouseEvent('click', {
bubbles: false,
cancelable: true,
view: window
}));
document.body.removeChild(element);
window.setTimeout(function () {
window.URL.revokeObjectURL(url_1);
}, 0);
}
};
Downloader = __decorate$29([
Bean("downloader")
], Downloader);
return Downloader;
}());
var __extends$2e = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate$2a = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var LINE_SEPARATOR$1 = '\r\n';
var XmlFactory = /** @class */ (function (_super) {
__extends$2e(XmlFactory, _super);
function XmlFactory() {
return _super !== null && _super.apply(this, arguments) || this;
}
XmlFactory.prototype.createHeader = function (headerElement) {
if (headerElement === void 0) { headerElement = {}; }
var headerStart = '';
var headerEnd = '?>';
var keys = ['version'];
if (!headerElement.version) {
headerElement.version = "1.0";
}
if (headerElement.encoding) {
keys.push('encoding');
}
if (headerElement.standalone) {
keys.push('standalone');
}
var att = keys.map(function (key) { return key + "=\"" + headerElement[key] + "\""; }).join(' ');
return headerStart + "xml " + att + " " + headerEnd;
};
XmlFactory.prototype.createXml = function (xmlElement, booleanTransformer) {
var _this = this;
var props = '';
if (xmlElement.properties) {
if (xmlElement.properties.prefixedAttributes) {
xmlElement.properties.prefixedAttributes.forEach(function (prefixedSet) {
Object.keys(prefixedSet.map).forEach(function (key) {
props += _this.returnAttributeIfPopulated(prefixedSet.prefix + key, prefixedSet.map[key], booleanTransformer);
});
});
}
if (xmlElement.properties.rawMap) {
Object.keys(xmlElement.properties.rawMap).forEach(function (key) {
props += _this.returnAttributeIfPopulated(key, xmlElement.properties.rawMap[key], booleanTransformer);
});
}
}
var result = '<' + xmlElement.name + props;
if (!xmlElement.children && xmlElement.textNode == null) {
return result + '/>' + LINE_SEPARATOR$1;
}
if (xmlElement.textNode != null) {
return result + '>' + xmlElement.textNode + '' + xmlElement.name + '>' + LINE_SEPARATOR$1;
}
result += '>' + LINE_SEPARATOR$1;
if (xmlElement.children) {
xmlElement.children.forEach(function (it) {
result += _this.createXml(it, booleanTransformer);
});
}
return result + '' + xmlElement.name + '>' + LINE_SEPARATOR$1;
};
XmlFactory.prototype.returnAttributeIfPopulated = function (key, value, booleanTransformer) {
if (!value && value !== '' && value !== 0) {
return '';
}
var xmlValue = value;
if ((typeof (value) === 'boolean')) {
if (booleanTransformer) {
xmlValue = booleanTransformer(value);
}
}
return " " + key + "=\"" + xmlValue + "\"";
};
XmlFactory = __decorate$2a([
Bean('xmlFactory')
], XmlFactory);
return XmlFactory;
}(BeanStub));
var __extends$2f = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate$2b = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
// table for crc calculation
// from: https://referencesource.microsoft.com/#System/sys/System/IO/compression/Crc32Helper.cs,3b31978c7d7f7246,references
var crcTable = [
0, 1996959894, -301047508, -1727442502, 124634137, 1886057615, -379345611, -1637575261, 249268274,
2044508324, -522852066, -1747789432, 162941995, 2125561021, -407360249, -1866523247, 498536548,
1789927666, -205950648, -2067906082, 450548861, 1843258603, -187386543, -2083289657, 325883990,
1684777152, -43845254, -1973040660, 335633487, 1661365465, -99664541, -1928851979, 997073096,
1281953886, -715111964, -1570279054, 1006888145, 1258607687, -770865667, -1526024853, 901097722,
1119000684, -608450090, -1396901568, 853044451, 1172266101, -589951537, -1412350631, 651767980,
1373503546, -925412992, -1076862698, 565507253, 1454621731, -809855591, -1195530993, 671266974,
1594198024, -972236366, -1324619484, 795835527, 1483230225, -1050600021, -1234817731, 1994146192,
31158534, -1731059524, -271249366, 1907459465, 112637215, -1614814043, -390540237, 2013776290,
251722036, -1777751922, -519137256, 2137656763, 141376813, -1855689577, -429695999, 1802195444,
476864866, -2056965928, -228458418, 1812370925, 453092731, -2113342271, -183516073, 1706088902,
314042704, -1950435094, -54949764, 1658658271, 366619977, -1932296973, -69972891, 1303535960,
984961486, -1547960204, -725929758, 1256170817, 1037604311, -1529756563, -740887301, 1131014506,
879679996, -1385723834, -631195440, 1141124467, 855842277, -1442165665, -586318647, 1342533948,
654459306, -1106571248, -921952122, 1466479909, 544179635, -1184443383, -832445281, 1591671054,
702138776, -1328506846, -942167884, 1504918807, 783551873, -1212326853, -1061524307, -306674912,
-1698712650, 62317068, 1957810842, -355121351, -1647151185, 81470997, 1943803523, -480048366,
-1805370492, 225274430, 2053790376, -468791541, -1828061283, 167816743, 2097651377, -267414716,
-2029476910, 503444072, 1762050814, -144550051, -2140837941, 426522225, 1852507879, -19653770,
-1982649376, 282753626, 1742555852, -105259153, -1900089351, 397917763, 1622183637, -690576408,
-1580100738, 953729732, 1340076626, -776247311, -1497606297, 1068828381, 1219638859, -670225446,
-1358292148, 906185462, 1090812512, -547295293, -1469587627, 829329135, 1181335161, -882789492,
-1134132454, 628085408, 1382605366, -871598187, -1156888829, 570562233, 1426400815, -977650754,
-1296233688, 733239954, 1555261956, -1026031705, -1244606671, 752459403, 1541320221, -1687895376,
-328994266, 1969922972, 40735498, -1677130071, -351390145, 1913087877, 83908371, -1782625662,
-491226604, 2075208622, 213261112, -1831694693, -438977011, 2094854071, 198958881, -2032938284,
-237706686, 1759359992, 534414190, -2118248755, -155638181, 1873836001, 414664567, -2012718362,
-15766928, 1711684554, 285281116, -1889165569, -127750551, 1634467795, 376229701, -1609899400,
-686959890, 1308918612, 956543938, -1486412191, -799009033, 1231636301, 1047427035, -1362007478,
-640263460, 1088359270, 936918000, -1447252397, -558129467, 1202900863, 817233897, -1111625188,
-893730166, 1404277552, 615818150, -1160759803, -841546093, 1423857449, 601450431, -1285129682,
-1000256840, 1567103746, 711928724, -1274298825, -1022587231, 1510334235, 755167117
];
var ZipContainer = /** @class */ (function (_super) {
__extends$2f(ZipContainer, _super);
function ZipContainer() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.folders = [];
_this.files = [];
_this.addFolder = function (path) {
_this.folders.push({
path: path,
created: new Date()
});
};
return _this;
}
ZipContainer.prototype.addFolders = function (paths) {
paths.forEach(this.addFolder);
};
ZipContainer.prototype.addFile = function (path, content) {
this.files.push({
path: path,
created: new Date(),
content: content
});
};
ZipContainer.prototype.clearStream = function () {
this.folders = [];
this.files = [];
};
ZipContainer.prototype.getContent = function (mimeType) {
if (mimeType === void 0) { mimeType = 'application/zip'; }
var textOutput = this.buildFileStream();
var uInt8Output = this.buildUint8Array(textOutput);
this.clearStream();
return new Blob([uInt8Output], { type: mimeType });
};
ZipContainer.prototype.buildFileStream = function (fData) {
if (fData === void 0) { fData = ''; }
var totalFiles = this.folders.concat(this.files);
var len = totalFiles.length;
var foData = '';
var lL = 0;
var cL = 0;
for (var _i = 0, totalFiles_1 = totalFiles; _i < totalFiles_1.length; _i++) {
var currentFile = totalFiles_1[_i];
var _a = this.getHeader(currentFile, lL), fileHeader = _a.fileHeader, folderHeader = _a.folderHeader, content = _a.content;
lL += fileHeader.length + content.length;
cL += folderHeader.length;
fData += fileHeader + content;
foData += folderHeader;
}
var foEnd = this.buildFolderEnd(len, cL, lL);
return fData + foData + foEnd;
};
ZipContainer.prototype.getHeader = function (currentFile, offset) {
var content = currentFile.content, path = currentFile.path, created = currentFile.created;
var utf8_encode = _.utf8_encode, decToHex = _.decToHex;
var utfPath = utf8_encode(path);
var isUTF8 = utfPath !== path;
var time = this.convertTime(created);
var dt = this.convertDate(created);
var extraFields = '';
if (isUTF8) {
var uExtraFieldPath = decToHex(1, 1) + decToHex(this.getFromCrc32Table(utfPath), 4) + utfPath;
extraFields = "\x75\x70" + decToHex(uExtraFieldPath.length, 2) + uExtraFieldPath;
}
var header = '\x0A\x00' +
(isUTF8 ? '\x00\x08' : '\x00\x00') +
'\x00\x00' +
decToHex(time, 2) + // last modified time
decToHex(dt, 2) + // last modified date
decToHex(content ? this.getFromCrc32Table(content) : 0, 4) +
decToHex(content ? content.length : 0, 4) + // compressed size
decToHex(content ? content.length : 0, 4) + // uncompressed size
decToHex(utfPath.length, 2) + // file name length
decToHex(extraFields.length, 2); // extra field length
var fileHeader = 'PK\x03\x04' + header + utfPath + extraFields;
var folderHeader = 'PK\x01\x02' + // central header
'\x14\x00' +
header + // file header
'\x00\x00' +
'\x00\x00' +
'\x00\x00' +
(content ? '\x00\x00\x00\x00' : '\x10\x00\x00\x00') + // external file attributes
decToHex(offset, 4) + // relative offset of local header
utfPath + // file name
extraFields; // extra field
return { fileHeader: fileHeader, folderHeader: folderHeader, content: content || '' };
};
ZipContainer.prototype.buildFolderEnd = function (tLen, cLen, lLen) {
var decToHex = _.decToHex;
return 'PK\x05\x06' + // central folder end
'\x00\x00' +
'\x00\x00' +
decToHex(tLen, 2) + // total number of entries in the central folder
decToHex(tLen, 2) + // total number of entries in the central folder
decToHex(cLen, 4) + // size of the central folder
decToHex(lLen, 4) + // central folder start offset
'\x00\x00';
};
ZipContainer.prototype.buildUint8Array = function (content) {
var uint8 = new Uint8Array(content.length);
for (var i = 0; i < uint8.length; i++) {
uint8[i] = content.charCodeAt(i);
}
return uint8;
};
ZipContainer.prototype.getFromCrc32Table = function (content, crc) {
if (crc === void 0) { crc = 0; }
if (!content.length) {
return 0;
}
crc ^= (-1);
var j = 0;
var k = 0;
var l = 0;
for (var i = 0; i < content.length; i++) {
j = content.charCodeAt(i);
k = (crc ^ j) & 0xFF;
l = crcTable[k];
crc = (crc >>> 8) ^ l;
}
return crc ^ (-1);
};
ZipContainer.prototype.convertTime = function (date) {
var time = date.getHours();
time <<= 6;
time = time | date.getMinutes();
time <<= 5;
time = time | date.getSeconds() / 2;
return time;
};
ZipContainer.prototype.convertDate = function (date) {
var dt = date.getFullYear() - 1980;
dt <<= 4;
dt = dt | (date.getMonth() + 1);
dt <<= 5;
dt = dt | date.getDate();
return dt;
};
ZipContainer = __decorate$2b([
Bean('zipContainer')
], ZipContainer);
return ZipContainer;
}(BeanStub));
var CsvExportModule = {
moduleName: exports.ModuleNames.CsvExportModule,
beans: [CsvCreator, Downloader, XmlFactory, GridSerializer, ZipContainer]
};
ModuleRegistry.register(ClientSideRowModelModule, false);
ModuleRegistry.register(InfiniteRowModelModule, false);
ModuleRegistry.register(CsvExportModule, false);
exports.AgAbstractField = AgAbstractField;
exports.AgAngleSelect = AgAngleSelect;
exports.AgCheckbox = AgCheckbox;
exports.AgColorPicker = AgColorPicker;
exports.AgDialog = AgDialog;
exports.AgGroupComponent = AgGroupComponent;
exports.AgInputNumberField = AgInputNumberField;
exports.AgInputRange = AgInputRange;
exports.AgInputTextArea = AgInputTextArea;
exports.AgInputTextField = AgInputTextField;
exports.AgPanel = AgPanel;
exports.AgRadioButton = AgRadioButton;
exports.AgSelect = AgSelect;
exports.AgSlider = AgSlider;
exports.AgToggleButton = AgToggleButton;
exports.AlignedGridsService = AlignedGridsService;
exports.AnimateShowChangeCellRenderer = AnimateShowChangeCellRenderer;
exports.AnimateSlideCellRenderer = AnimateSlideCellRenderer;
exports.AutoWidthCalculator = AutoWidthCalculator;
exports.Autowired = Autowired;
exports.BaseComponentWrapper = BaseComponentWrapper;
exports.Bean = Bean;
exports.BeanStub = BeanStub;
exports.BodyDropPivotTarget = BodyDropPivotTarget;
exports.BodyDropTarget = BodyDropTarget;
exports.CellComp = CellComp;
exports.CellNavigationService = CellNavigationService;
exports.CellPositionUtils = CellPositionUtils;
exports.CellRendererFactory = CellRendererFactory;
exports.ChangedPath = ChangedPath;
exports.CheckboxSelectionComponent = CheckboxSelectionComponent;
exports.ColDefUtil = ColDefUtil;
exports.Color = Color;
exports.Column = Column;
exports.ColumnApi = ColumnApi;
exports.ColumnController = ColumnController;
exports.ColumnFactory = ColumnFactory;
exports.ColumnGroup = ColumnGroup;
exports.ColumnKeyCreator = ColumnKeyCreator;
exports.ColumnUtils = ColumnUtils;
exports.Component = Component;
exports.ComponentUtil = ComponentUtil;
exports.Constants = Constants;
exports.Context = Context;
exports.CssClassApplier = CssClassApplier;
exports.DateFilter = DateFilter;
exports.DisplayedGroupCreator = DisplayedGroupCreator;
exports.DragAndDropService = DragAndDropService;
exports.DragService = DragService;
exports.Environment = Environment;
exports.EventService = EventService;
exports.Events = Events;
exports.ExpressionService = ExpressionService;
exports.FilterManager = FilterManager;
exports.FloatingFilterMapper = FloatingFilterMapper;
exports.FloatingFilterWrapper = FloatingFilterWrapper;
exports.FocusController = FocusController;
exports.Grid = Grid;
exports.GridApi = GridApi;
exports.GridCore = GridCore;
exports.GridListener = GridListener;
exports.GridOptionsWrapper = GridOptionsWrapper;
exports.GridPanel = GridPanel;
exports.GroupCellRenderer = GroupCellRenderer;
exports.GroupInstanceIdCreator = GroupInstanceIdCreator;
exports.GuiListener = GuiListener;
exports.HeaderContainer = HeaderContainer;
exports.HeaderNavigationService = HeaderNavigationService;
exports.HeaderPositionUtils = HeaderPositionUtils;
exports.HeaderRootComp = HeaderRootComp;
exports.HeaderRowComp = HeaderRowComp;
exports.HorizontalResizeService = HorizontalResizeService;
exports.KeyCode = KeyCode;
exports.LargeTextCellEditor = LargeTextCellEditor;
exports.Logger = Logger;
exports.LoggerFactory = LoggerFactory;
exports.ManagedFocusComponent = ManagedFocusComponent;
exports.ModuleRegistry = ModuleRegistry;
exports.MouseEventService = MouseEventService;
exports.MoveColumnController = MoveColumnController;
exports.NumberFilter = NumberFilter;
exports.NumberSequence = NumberSequence;
exports.Optional = Optional;
exports.OriginalColumnGroup = OriginalColumnGroup;
exports.PaginationProxy = PaginationProxy;
exports.PinnedRowModel = PinnedRowModel;
exports.PopupComponent = PopupComponent;
exports.PopupEditorWrapper = PopupEditorWrapper;
exports.PopupSelectCellEditor = PopupSelectCellEditor;
exports.PopupService = PopupService;
exports.PopupTextCellEditor = PopupTextCellEditor;
exports.PostConstruct = PostConstruct;
exports.PreConstruct = PreConstruct;
exports.PreDestroy = PreDestroy;
exports.Promise = Promise;
exports.PropertyKeys = PropertyKeys;
exports.ProvidedFilter = ProvidedFilter;
exports.Qualifier = Qualifier;
exports.QuerySelector = QuerySelector;
exports.RefSelector = RefSelector;
exports.ResizeObserverService = ResizeObserverService;
exports.RowComp = RowComp;
exports.RowNode = RowNode;
exports.RowNodeBlock = RowNodeBlock;
exports.RowNodeBlockLoader = RowNodeBlockLoader;
exports.RowNodeCache = RowNodeCache;
exports.RowPositionUtils = RowPositionUtils;
exports.RowRenderer = RowRenderer;
exports.ScalarFilter = ScalarFilter;
exports.ScrollVisibleService = ScrollVisibleService;
exports.SelectCellEditor = SelectCellEditor;
exports.SelectableService = SelectableService;
exports.SelectionController = SelectionController;
exports.SetLeftFeature = SetLeftFeature;
exports.SimpleFilter = SimpleFilter;
exports.SortController = SortController;
exports.StandardMenuFactory = StandardMenuFactory;
exports.StylingService = StylingService;
exports.TabbedLayout = TabbedLayout;
exports.TemplateService = TemplateService;
exports.TextCellEditor = TextCellEditor;
exports.TextFilter = TextFilter;
exports.TextFloatingFilter = TextFloatingFilter;
exports.Timer = Timer;
exports.TooltipFeature = TooltipFeature;
exports.TouchListener = TouchListener;
exports.UserComponentFactory = UserComponentFactory;
exports.UserComponentRegistry = UserComponentRegistry;
exports.ValueCache = ValueCache;
exports.ValueFormatterService = ValueFormatterService;
exports.ValueService = ValueService;
exports.VanillaFrameworkOverrides = VanillaFrameworkOverrides;
exports.VirtualList = VirtualList;
exports._ = _;
exports.defaultGroupComparator = defaultGroupComparator;
exports.initialiseAgGridWithAngular1 = initialiseAgGridWithAngular1;
exports.initialiseAgGridWithWebComponents = initialiseAgGridWithWebComponents;
exports.simpleHttpRequest = simpleHttpRequest;
exports.stringToArray = stringToArray;