Socket
Socket
Sign inDemoInstall

@ag-grid-community/csv-export

Package Overview
Dependencies
Maintainers
3
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ag-grid-community/csv-export - npm Package Compare versions

Comparing version 25.1.0 to 25.2.0

11

dist/cjs/csvExport/baseCreator.d.ts

@@ -6,7 +6,10 @@ import { ExportParams } from "@ag-grid-community/core";

protected setBeans(beans: BaseCreatorBeans): void;
export(userParams?: P): string;
getData(params?: P): string;
private getMergedParamsAndData;
abstract export(userParams?: P): string;
protected abstract getDefaultExportParams(): P | undefined;
protected getFileName(fileName?: string): string;
protected getMergedParamsAndData(userParams?: P): {
mergedParams: P;
data: string;
};
private mergeDefaultParams;
protected packageFile(data: string): Blob;
abstract createSerializingSession(params?: P): S;

@@ -13,0 +16,0 @@ abstract getMimeType(): string;

@@ -10,19 +10,9 @@ "use strict";

};
BaseCreator.prototype.export = function (userParams) {
if (this.isExportSuppressed()) {
console.warn("ag-grid: Export cancelled. Export is not allowed as per your configuration.");
return '';
BaseCreator.prototype.getFileName = function (fileName) {
var extension = this.getDefaultFileExtension();
if (fileName == null || !fileName.length) {
fileName = this.getDefaultFileName();
}
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;
return fileName.indexOf('.') === -1 ? fileName + "." + extension : fileName;
};
BaseCreator.prototype.getData = function (params) {
return this.getMergedParamsAndData(params).data;
};
BaseCreator.prototype.getMergedParamsAndData = function (userParams) {

@@ -34,3 +24,3 @@ var mergedParams = this.mergeDefaultParams(userParams);

BaseCreator.prototype.mergeDefaultParams = function (userParams) {
var baseParams = this.beans.gridOptionsWrapper.getDefaultExportParams();
var baseParams = this.getDefaultExportParams();
var params = {};

@@ -41,8 +31,2 @@ core_1._.assign(params, baseParams);

};
BaseCreator.prototype.packageFile = function (data) {
return new Blob(["\ufeff", data], {
// @ts-ignore
type: window.navigator.msSaveOrOpenBlob ? this.getMimeType() : 'octet/stream'
});
};
return BaseCreator;

@@ -49,0 +33,0 @@ }());

@@ -7,6 +7,7 @@ import { CsvCustomContent, CsvExportParams, GridOptionsWrapper, ICsvCreator } from "@ag-grid-community/core";

private valueService;
private downloader;
private gridSerializer;
gridOptionsWrapper: GridOptionsWrapper;
postConstruct(): void;
protected getDefaultExportParams(): CsvExportParams | undefined;
export(userParams?: CsvExportParams): string;
exportDataAsCsv(params?: CsvExportParams): string;

@@ -13,0 +14,0 @@ getDataAsCsv(params?: CsvExportParams): string;

@@ -24,2 +24,3 @@ "use strict";

var baseCreator_1 = require("./baseCreator");
var downloader_1 = require("./downloader");
var csvSerializingSession_1 = require("./sessions/csvSerializingSession");

@@ -33,3 +34,2 @@ var CsvCreator = /** @class */ (function (_super) {

this.setBeans({
downloader: this.downloader,
gridSerializer: this.gridSerializer,

@@ -39,2 +39,18 @@ gridOptionsWrapper: this.gridOptionsWrapper

};
CsvCreator.prototype.getDefaultExportParams = function () {
return this.gridOptionsWrapper.getDefaultExportParams('csv');
};
CsvCreator.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 packagedFile = new Blob(["\ufeff", data], {
// @ts-ignore
type: window.navigator.msSaveOrOpenBlob ? this.getMimeType() : 'octet/stream'
});
downloader_1.Downloader.download(this.getFileName(mergedParams.fileName), packagedFile);
return data;
};
CsvCreator.prototype.exportDataAsCsv = function (params) {

@@ -44,3 +60,3 @@ return this.export(params);

CsvCreator.prototype.getDataAsCsv = function (params) {
return this.getData(params);
return this.getMergedParamsAndData(params).data;
};

@@ -81,5 +97,2 @@ CsvCreator.prototype.getMimeType = function () {

__decorate([
core_1.Autowired('downloader')
], CsvCreator.prototype, "downloader", void 0);
__decorate([
core_1.Autowired('gridSerializer')

@@ -86,0 +99,0 @@ ], CsvCreator.prototype, "gridSerializer", void 0);

export declare class Downloader {
download(fileName: string, content: Blob): void;
static download(fileName: string, content: Blob): void;
}
"use strict";
var __decorate = (this && this.__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;
};
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("@ag-grid-community/core");
var Downloader = /** @class */ (function () {
function Downloader() {
}
Downloader.prototype.download = function (fileName, content) {
Downloader.download = function (fileName, content) {
// Internet Explorer

@@ -37,5 +30,2 @@ if (window.navigator.msSaveOrOpenBlob) {

};
Downloader = __decorate([
core_1.Bean("downloader")
], Downloader);
return Downloader;

@@ -42,0 +32,0 @@ }());

@@ -1,3 +0,8 @@

import { BeanStub, ColumnGroupChild, ExportParams, ProcessGroupHeaderForExportParams } from "@ag-grid-community/core";
import { BeanStub, ExportParams } from "@ag-grid-community/core";
import { GridSerializingSession } from "./interfaces";
export declare enum RowType {
HEADER_GROUPING = 0,
HEADER = 1,
BODY = 2
}
export declare class GridSerializer extends BeanStub {

@@ -10,11 +15,14 @@ private displayedGroupCreator;

serialize<T>(gridSerializingSession: GridSerializingSession<T>, params?: ExportParams<T>): string;
recursivelyAddHeaderGroups<T>(displayedGroups: ColumnGroupChild[], gridSerializingSession: GridSerializingSession<T>, processGroupHeaderCallback: ProcessGroupHeaderCallback | undefined): void;
private processRow;
private appendContent;
private prependContent;
private prepareSession;
private exportColumnGroups;
private exportHeaders;
private processPinnedTopRows;
private processRows;
private processPinnedBottomRows;
private getColumnsToExport;
private recursivelyAddHeaderGroups;
private doAddHeaderHeader;
}
declare type ProcessGroupHeaderCallback = (params: ProcessGroupHeaderForExportParams) => string;
export declare enum RowType {
HEADER_GROUPING = 0,
HEADER = 1,
BODY = 2
}
export {};

@@ -23,2 +23,8 @@ "use strict";

var core_1 = require("@ag-grid-community/core");
var RowType;
(function (RowType) {
RowType[RowType["HEADER_GROUPING"] = 0] = "HEADER_GROUPING";
RowType[RowType["HEADER"] = 1] = "HEADER";
RowType[RowType["BODY"] = 2] = "BODY";
})(RowType = exports.RowType || (exports.RowType = {}));
var GridSerializer = /** @class */ (function (_super) {

@@ -31,124 +37,180 @@ __extends(GridSerializer, _super);

if (params === void 0) { params = {}; }
var columnsToExport = this.getColumnsToExport(params.allColumns, params.columnKeys);
var serializeChain = core_1._.compose(
// first pass, put in the header names of the cols
this.prepareSession(columnsToExport), this.prependContent(params), this.exportColumnGroups(params, columnsToExport), this.exportHeaders(params, columnsToExport), this.processPinnedTopRows(params, columnsToExport), this.processRows(params, columnsToExport), this.processPinnedBottomRows(params, columnsToExport), this.appendContent(params));
return serializeChain(gridSerializingSession).parse();
};
GridSerializer.prototype.processRow = function (gridSerializingSession, params, columnsToExport, node) {
var rowSkipper = params.shouldRowBeSkipped || (function () { return false; });
var gridOptionsWrapper = this.gridOptionsWrapper;
var context = gridOptionsWrapper.getContext();
var api = gridOptionsWrapper.getApi();
var columnApi = gridOptionsWrapper.getColumnApi();
var skipSingleChildrenGroup = gridOptionsWrapper.isGroupRemoveSingleChildren();
var hideOpenParents = gridOptionsWrapper.isGroupHideOpenParents();
var skipLowestSingleChildrenGroup = gridOptionsWrapper.isGroupRemoveLowestSingleChildren();
var hideOpenParents = gridOptionsWrapper.isGroupHideOpenParents();
var context = 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() === core_1.Constants.ROW_MODEL_TYPE_CLIENT_SIDE;
var onlySelectedNonStandardModel = !rowModelNormal && params.onlySelected;
var columnsToExport = [];
if (core_1._.existsAndNotEmpty(params.columnKeys)) {
columnsToExport = this.columnController.getGridColumns(params.columnKeys);
var skipRowGroups = params.skipGroups || params.skipRowGroups;
var shouldSkipLowestGroup = skipLowestSingleChildrenGroup && node.leafGroup;
var shouldSkipCurrentGroup = node.allChildrenCount === 1 && (skipSingleChildrenGroup || shouldSkipLowestGroup);
if (skipRowGroups && params.skipGroups) {
console.warn('AG Grid: Since v25.2 `skipGroups` has been renamed to `skipRowGroups`.');
}
else if (params.allColumns && !isPivotMode) {
// add auto group column for tree data
columnsToExport = gridOptionsWrapper.isTreeData() ?
this.columnController.getGridColumns([core_1.Constants.GROUP_AUTO_COLUMN_ID]) : [];
columnsToExport = columnsToExport.concat(this.columnController.getAllPrimaryColumns() || []);
if ((node.group && (params.skipRowGroups || shouldSkipCurrentGroup || hideOpenParents)) ||
(params.onlySelected && !node.isSelected()) ||
(params.skipPinnedTop && node.rowPinned === 'top') ||
(params.skipPinnedBottom && node.rowPinned === 'bottom')) {
return;
}
else {
columnsToExport = this.columnController.getAllDisplayedColumns();
// 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;
}
if (params.customHeader) {
gridSerializingSession.addCustomContent(params.customHeader);
var shouldRowBeSkipped = rowSkipper({ node: node, api: api, context: context });
if (shouldRowBeSkipped) {
return;
}
gridSerializingSession.prepare(columnsToExport);
// first pass, put in the header names of the cols
if (params.columnGroups) {
var groupInstanceIdCreator = new core_1.GroupInstanceIdCreator();
var displayedGroups = this.displayedGroupCreator.createDisplayedGroups(columnsToExport, this.columnController.getGridBalancedTree(), groupInstanceIdCreator, null);
this.recursivelyAddHeaderGroups(displayedGroups, gridSerializingSession, params.processGroupHeaderCallback);
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);
}
}
if (!params.skipHeader) {
var gridRowIterator_1 = gridSerializingSession.onNewHeaderRow();
columnsToExport.forEach(function (column, index) {
gridRowIterator_1.onColumn(column, index, undefined);
});
}
this.pinnedRowModel.forEachPinnedTopRow(processRow);
var rowModel = this.rowModel;
var clientSideRowModel = this.rowModel;
if (isPivotMode) {
// @ts-ignore - ignore tautology below as we are using it to check if it's clientSideRowModel
if (clientSideRowModel.forEachPivotNode) {
clientSideRowModel.forEachPivotNode(processRow);
};
GridSerializer.prototype.appendContent = function (params) {
return function (gridSerializingSession) {
var appendContent = params.customFooter || params.appendContent;
if (appendContent) {
if (params.customFooter) {
console.warn('AG Grid: Since version 25.2.0 the `customFooter` param has been deprecated. Use `appendContent` instead.');
}
gridSerializingSession.addCustomContent(appendContent);
}
else {
// n=must be enterprise, so we can just loop through all the nodes
rowModel.forEachNode(processRow);
return gridSerializingSession;
};
};
GridSerializer.prototype.prependContent = function (params) {
return function (gridSerializingSession) {
var prependContent = params.customHeader || params.prependContent;
if (prependContent) {
if (params.customHeader) {
console.warn('AG Grid: Since version 25.2.0 the `customHeader` param has been deprecated. Use `prependContent` instead.');
}
gridSerializingSession.addCustomContent(prependContent);
}
}
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);
return gridSerializingSession;
};
};
GridSerializer.prototype.prepareSession = function (columnsToExport) {
return function (gridSerializingSession) {
gridSerializingSession.prepare(columnsToExport);
return gridSerializingSession;
};
};
GridSerializer.prototype.exportColumnGroups = function (params, columnsToExport) {
var _this = this;
return function (gridSerializingSession) {
if (!params.skipColumnGroupHeaders) {
var groupInstanceIdCreator = new core_1.GroupInstanceIdCreator();
var displayedGroups = _this.displayedGroupCreator.createDisplayedGroups(columnsToExport, _this.columnController.getGridBalancedTree(), groupInstanceIdCreator, null);
_this.recursivelyAddHeaderGroups(displayedGroups, gridSerializingSession, params.processGroupHeaderCallback);
}
else if (params.columnGroups) {
console.warn('AG Grid: Since v25.2 the `columnGroups` param has deprecated, and groups are exported by default.');
}
return gridSerializingSession;
};
};
GridSerializer.prototype.exportHeaders = function (params, columnsToExport) {
return function (gridSerializingSession) {
if (!params.skipHeader && !params.skipColumnHeaders) {
var gridRowIterator_1 = gridSerializingSession.onNewHeaderRow();
columnsToExport.forEach(function (column, index) {
gridRowIterator_1.onColumn(column, index, undefined);
});
}
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.
else if (params.skipHeader) {
console.warn('AG Grid: Since v25.2 the `skipHeader` param has been renamed to `skipColumnHeaders`.');
}
return gridSerializingSession;
};
};
GridSerializer.prototype.processPinnedTopRows = function (params, columnsToExport) {
var _this = this;
return function (gridSerializingSession) {
var processRow = _this.processRow.bind(_this, gridSerializingSession, params, columnsToExport);
_this.pinnedRowModel.forEachPinnedTopRow(processRow);
return gridSerializingSession;
};
};
GridSerializer.prototype.processRows = function (params, columnsToExport) {
var _this = this;
return function (gridSerializingSession) {
// when in pivot mode, we always render cols on screen, never 'all columns'
var rowModel = _this.rowModel;
var rowModelNormal = rowModel.getType() === core_1.Constants.ROW_MODEL_TYPE_CLIENT_SIDE;
var onlySelectedNonStandardModel = !rowModelNormal && params.onlySelected;
var processRow = _this.processRow.bind(_this, gridSerializingSession, params, columnsToExport);
if (_this.columnController.isPivotMode()) {
if (rowModelNormal) {
clientSideRowModel.forEachNodeAfterFilterAndSort(processRow);
rowModel.forEachPivotNode(processRow);
}
else {
// must be enterprise, so we can just loop through all the nodes
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 || hideOpenParents)) {
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);
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(processRow);
}
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) {
rowModel.forEachNodeAfterFilterAndSort(processRow);
}
else {
rowModel.forEachNode(processRow);
}
}
}
return gridSerializingSession;
};
};
GridSerializer.prototype.processPinnedBottomRows = function (params, columnsToExport) {
var _this = this;
return function (gridSerializingSession) {
var processRow = _this.processRow.bind(_this, gridSerializingSession, params, columnsToExport);
_this.pinnedRowModel.forEachPinnedBottomRow(processRow);
return gridSerializingSession;
};
};
GridSerializer.prototype.getColumnsToExport = function (allColumns, columnKeys) {
if (allColumns === void 0) { allColumns = false; }
var isPivotMode = this.columnController.isPivotMode();
if (columnKeys && columnKeys.length) {
return this.columnController.getGridColumns(columnKeys);
}
return gridSerializingSession.parse();
if (allColumns && !isPivotMode) {
// add auto group column for tree data
var columns = this.gridOptionsWrapper.isTreeData()
? this.columnController.getGridColumns([core_1.Constants.GROUP_AUTO_COLUMN_ID])
: [];
return columns.concat(this.columnController.getAllPrimaryColumns() || []);
}
return this.columnController.getAllDisplayedColumns();
};

@@ -213,8 +275,2 @@ GridSerializer.prototype.recursivelyAddHeaderGroups = function (displayedGroups, gridSerializingSession, processGroupHeaderCallback) {

exports.GridSerializer = GridSerializer;
var RowType;
(function (RowType) {
RowType[RowType["HEADER_GROUPING"] = 0] = "HEADER_GROUPING";
RowType[RowType["HEADER"] = 1] = "HEADER";
RowType[RowType["BODY"] = 2] = "BODY";
})(RowType = exports.RowType || (exports.RowType = {}));
//# sourceMappingURL=gridSerializer.js.map
import { Column, ColumnController, GridOptionsWrapper, ProcessCellForExportParams, ProcessGroupHeaderForExportParams, ProcessHeaderForExportParams, ProcessRowGroupForExportParams, RowNode, ValueService } from "@ag-grid-community/core";
import { Downloader } from "../downloader";
import { GridSerializer } from "../gridSerializer";
export interface BaseCreatorBeans {
downloader: Downloader;
gridSerializer: GridSerializer;

@@ -7,0 +5,0 @@ gridOptionsWrapper: GridOptionsWrapper;

@@ -20,3 +20,3 @@ import { Column, ColumnController, GridOptionsWrapper, ProcessCellForExportParams, ProcessGroupHeaderForExportParams, ProcessHeaderForExportParams, ProcessRowGroupForExportParams, RowNode, ValueService } from "@ag-grid-community/core";

extractHeaderValue(column: Column): string;
extractRowCellValue(column: Column, index: number, type: string, node: RowNode): any;
extractRowCellValue(column: Column, index: number, accumulatedRowIndex: number, type: string, node: RowNode): any;
private getHeaderName;

@@ -23,0 +23,0 @@ private createValueForGroupNode;

@@ -23,3 +23,3 @@ "use strict";

};
BaseGridSerializingSession.prototype.extractRowCellValue = function (column, index, type, node) {
BaseGridSerializingSession.prototype.extractRowCellValue = function (column, index, accumulatedRowIndex, type, node) {
// we render the group summary text e.g. "-> Parent -> Child"...

@@ -42,3 +42,3 @@ var groupIndex = this.gridOptionsWrapper.isGroupMultiAutoColumn() ? node.rowGroupIndex : 0;

}
var value = this.processCell(node, column, valueForCell, this.processCellCallback, type);
var value = this.processCell(accumulatedRowIndex, node, column, valueForCell, this.processCellCallback, type);
return value != null ? value : '';

@@ -75,5 +75,6 @@ };

};
BaseGridSerializingSession.prototype.processCell = function (rowNode, column, value, processCellCallback, type) {
BaseGridSerializingSession.prototype.processCell = function (accumulatedRowIndex, rowNode, column, value, processCellCallback, type) {
if (processCellCallback) {
return processCellCallback({
accumulatedRowIndex: accumulatedRowIndex,
column: column,

@@ -88,3 +89,3 @@ node: rowNode,

}
return value;
return value != null ? value : '';
};

@@ -91,0 +92,0 @@ return BaseGridSerializingSession;

@@ -36,4 +36,2 @@ "use strict";

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)) {

@@ -101,3 +99,3 @@ this.beginNewLine();

}
this.result += this.putInQuotes(this.extractRowCellValue(column, index, core_1.Constants.EXPORT_TYPE_CSV, node));
this.result += this.putInQuotes(this.extractRowCellValue(column, index, index, core_1.Constants.EXPORT_TYPE_CSV, node));
};

@@ -104,0 +102,0 @@ CsvSerializingSession.prototype.putInQuotes = function (value) {

@@ -1,6 +0,6 @@

import { BeanStub, HeaderElement, XmlElement } from "@ag-grid-community/core";
export declare class XmlFactory extends BeanStub {
createHeader(headerElement?: HeaderElement): string;
createXml(xmlElement: XmlElement, booleanTransformer?: (currentValue: boolean) => string): string;
private returnAttributeIfPopulated;
import { HeaderElement, XmlElement } from "@ag-grid-community/core";
export declare class XmlFactory {
static createHeader(headerElement?: HeaderElement): string;
static createXml(xmlElement: XmlElement, booleanTransformer?: (currentValue: boolean) => string): string;
private static returnAttributeIfPopulated;
}
"use strict";
var __extends = (this && this.__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 = (this && this.__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;
};
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("@ag-grid-community/core");
var LINE_SEPARATOR = '\r\n';
var XmlFactory = /** @class */ (function (_super) {
__extends(XmlFactory, _super);
var XmlFactory = /** @class */ (function () {
function XmlFactory() {
return _super !== null && _super.apply(this, arguments) || this;
}
XmlFactory.prototype.createHeader = function (headerElement) {
XmlFactory.createHeader = function (headerElement) {
if (headerElement === void 0) { headerElement = {}; }

@@ -46,3 +24,3 @@ var headerStart = '<?';

};
XmlFactory.prototype.createXml = function (xmlElement, booleanTransformer) {
XmlFactory.createXml = function (xmlElement, booleanTransformer) {
var _this = this;

@@ -79,3 +57,3 @@ var props = '';

};
XmlFactory.prototype.returnAttributeIfPopulated = function (key, value, booleanTransformer) {
XmlFactory.returnAttributeIfPopulated = function (key, value, booleanTransformer) {
if (!value && value !== '' && value !== 0) {

@@ -92,8 +70,5 @@ return '';

};
XmlFactory = __decorate([
core_1.Bean('xmlFactory')
], XmlFactory);
return XmlFactory;
}(core_1.BeanStub));
}());
exports.XmlFactory = XmlFactory;
//# sourceMappingURL=xmlFactory.js.map

@@ -1,5 +0,5 @@

import { BeanStub } from "@ag-grid-community/core";
export interface ZipFolder {
path: string;
created: Date;
isBase64: boolean;
}

@@ -9,17 +9,18 @@ export interface ZipFile extends ZipFolder {

}
export declare class ZipContainer extends BeanStub {
private folders;
private files;
private addFolder;
addFolders(paths: string[]): void;
addFile(path: string, content: string): void;
private clearStream;
getContent(mimeType?: string): Blob;
private buildFileStream;
private getHeader;
private buildFolderEnd;
private buildUint8Array;
private getFromCrc32Table;
private convertTime;
private convertDate;
export declare class ZipContainer {
private static folders;
private static files;
static addFolders(paths: string[]): void;
private static addFolder;
static addFile(path: string, content: string, isBase64?: boolean): void;
static getContent(mimeType?: string): Blob;
private static clearStream;
private static buildFileStream;
private static getHeader;
private static getConvertedContent;
private static buildFolderEnd;
private static buildUint8Array;
private static getFromCrc32Table;
private static convertTime;
private static convertDate;
}
"use strict";
var __extends = (this && this.__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 = (this && this.__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;
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -25,65 +6,70 @@ var core_1 = require("@ag-grid-community/core");

// 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(ZipContainer, _super);
var crcTable = new Uint32Array([
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
]);
var ZipContainer = /** @class */ (function () {
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.addFolders = function (paths) {
paths.forEach(this.addFolder.bind(this));
};
ZipContainer.prototype.addFile = function (path, content) {
ZipContainer.addFolder = function (path) {
this.folders.push({
path: path,
created: new Date(),
isBase64: false
});
};
ZipContainer.addFile = function (path, content, isBase64) {
if (isBase64 === void 0) { isBase64 = false; }
this.files.push({
path: path,
created: new Date(),
content: content
content: content,
isBase64: isBase64
});
};
ZipContainer.prototype.clearStream = function () {
this.folders = [];
this.files = [];
};
ZipContainer.prototype.getContent = function (mimeType) {
ZipContainer.getContent = function (mimeType) {
if (mimeType === void 0) { mimeType = 'application/zip'; }

@@ -95,3 +81,7 @@ var textOutput = this.buildFileStream();

};
ZipContainer.prototype.buildFileStream = function (fData) {
ZipContainer.clearStream = function () {
this.folders = [];
this.files = [];
};
ZipContainer.buildFileStream = function (fData) {
if (fData === void 0) { fData = ''; }

@@ -114,4 +104,4 @@ var totalFiles = this.folders.concat(this.files);

};
ZipContainer.prototype.getHeader = function (currentFile, offset) {
var content = currentFile.content, path = currentFile.path, created = currentFile.created;
ZipContainer.getHeader = function (currentFile, offset) {
var content = currentFile.content, path = currentFile.path, created = currentFile.created, isBase64 = currentFile.isBase64;
var utf8_encode = core_1._.utf8_encode, decToHex = core_1._.decToHex;

@@ -127,2 +117,3 @@ var utfPath = utf8_encode(path);

}
var _a = !content ? { size: 0, content: '' } : this.getConvertedContent(content, isBase64), size = _a.size, convertedContent = _a.content;
var header = '\x0A\x00' +

@@ -133,5 +124,5 @@ (isUTF8 ? '\x00\x08' : '\x00\x00') +

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(size ? this.getFromCrc32Table(convertedContent) : 0, 4) +
decToHex(size, 4) + // compressed size
decToHex(size, 4) + // uncompressed size
decToHex(utfPath.length, 2) + // file name length

@@ -150,5 +141,16 @@ decToHex(extraFields.length, 2); // extra field length

extraFields; // extra field
return { fileHeader: fileHeader, folderHeader: folderHeader, content: content || '' };
return { fileHeader: fileHeader, folderHeader: folderHeader, content: convertedContent || '' };
};
ZipContainer.prototype.buildFolderEnd = function (tLen, cLen, lLen) {
ZipContainer.getConvertedContent = function (content, isBase64) {
if (isBase64 === void 0) { isBase64 = false; }
if (isBase64) {
content = content.split(';base64,')[1];
}
content = isBase64 ? atob(content) : content;
return {
size: content.length,
content: content
};
};
ZipContainer.buildFolderEnd = function (tLen, cLen, lLen) {
var decToHex = core_1._.decToHex;

@@ -164,3 +166,3 @@ return 'PK\x05\x06' + // central folder end

};
ZipContainer.prototype.buildUint8Array = function (content) {
ZipContainer.buildUint8Array = function (content) {
var uint8 = new Uint8Array(content.length);

@@ -172,13 +174,17 @@ for (var i = 0; i < uint8.length; i++) {

};
ZipContainer.prototype.getFromCrc32Table = function (content, crc) {
if (crc === void 0) { crc = 0; }
ZipContainer.getFromCrc32Table = function (content) {
if (!content.length) {
return 0;
}
crc ^= (-1);
var size = content.length;
var iterable = new Uint8Array(size);
for (var i = 0; i < size; i++) {
iterable[i] = content.charCodeAt(i);
}
var crc = 0 ^ (-1);
var j = 0;
var k = 0;
var l = 0;
for (var i = 0; i < content.length; i++) {
j = content.charCodeAt(i);
for (var i = 0; i < size; i++) {
j = iterable[i];
k = (crc ^ j) & 0xFF;

@@ -190,3 +196,3 @@ l = crcTable[k];

};
ZipContainer.prototype.convertTime = function (date) {
ZipContainer.convertTime = function (date) {
var time = date.getHours();

@@ -199,3 +205,3 @@ time <<= 6;

};
ZipContainer.prototype.convertDate = function (date) {
ZipContainer.convertDate = function (date) {
var dt = date.getFullYear() - 1980;

@@ -208,8 +214,7 @@ dt <<= 4;

};
ZipContainer = __decorate([
core_1.Bean('zipContainer')
], ZipContainer);
ZipContainer.folders = [];
ZipContainer.files = [];
return ZipContainer;
}(core_1.BeanStub));
}());
exports.ZipContainer = ZipContainer;
//# sourceMappingURL=zipContainer.js.map

@@ -5,10 +5,7 @@ "use strict";

var csvCreator_1 = require("./csvExport/csvCreator");
var downloader_1 = require("./csvExport/downloader");
var xmlFactory_1 = require("./csvExport/xmlFactory");
var gridSerializer_1 = require("./csvExport/gridSerializer");
var zipContainer_1 = require("./csvExport/zipContainer");
exports.CsvExportModule = {
moduleName: core_1.ModuleNames.CsvExportModule,
beans: [csvCreator_1.CsvCreator, downloader_1.Downloader, xmlFactory_1.XmlFactory, gridSerializer_1.GridSerializer, zipContainer_1.ZipContainer]
beans: [csvCreator_1.CsvCreator, gridSerializer_1.GridSerializer]
};
//# sourceMappingURL=csvExportModule.js.map

@@ -6,7 +6,10 @@ import { ExportParams } from "@ag-grid-community/core";

protected setBeans(beans: BaseCreatorBeans): void;
export(userParams?: P): string;
getData(params?: P): string;
private getMergedParamsAndData;
abstract export(userParams?: P): string;
protected abstract getDefaultExportParams(): P | undefined;
protected getFileName(fileName?: string): string;
protected getMergedParamsAndData(userParams?: P): {
mergedParams: P;
data: string;
};
private mergeDefaultParams;
protected packageFile(data: string): Blob;
abstract createSerializingSession(params?: P): S;

@@ -13,0 +16,0 @@ abstract getMimeType(): string;

@@ -8,19 +8,9 @@ import { _ } from "@ag-grid-community/core";

};
BaseCreator.prototype.export = function (userParams) {
if (this.isExportSuppressed()) {
console.warn("ag-grid: Export cancelled. Export is not allowed as per your configuration.");
return '';
BaseCreator.prototype.getFileName = function (fileName) {
var extension = this.getDefaultFileExtension();
if (fileName == null || !fileName.length) {
fileName = this.getDefaultFileName();
}
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;
return fileName.indexOf('.') === -1 ? fileName + "." + extension : fileName;
};
BaseCreator.prototype.getData = function (params) {
return this.getMergedParamsAndData(params).data;
};
BaseCreator.prototype.getMergedParamsAndData = function (userParams) {

@@ -32,3 +22,3 @@ var mergedParams = this.mergeDefaultParams(userParams);

BaseCreator.prototype.mergeDefaultParams = function (userParams) {
var baseParams = this.beans.gridOptionsWrapper.getDefaultExportParams();
var baseParams = this.getDefaultExportParams();
var params = {};

@@ -39,10 +29,4 @@ _.assign(params, baseParams);

};
BaseCreator.prototype.packageFile = function (data) {
return new Blob(["\ufeff", data], {
// @ts-ignore
type: window.navigator.msSaveOrOpenBlob ? this.getMimeType() : 'octet/stream'
});
};
return BaseCreator;
}());
export { BaseCreator };

@@ -7,6 +7,7 @@ import { CsvCustomContent, CsvExportParams, GridOptionsWrapper, ICsvCreator } from "@ag-grid-community/core";

private valueService;
private downloader;
private gridSerializer;
gridOptionsWrapper: GridOptionsWrapper;
postConstruct(): void;
protected getDefaultExportParams(): CsvExportParams | undefined;
export(userParams?: CsvExportParams): string;
exportDataAsCsv(params?: CsvExportParams): string;

@@ -13,0 +14,0 @@ getDataAsCsv(params?: CsvExportParams): string;

@@ -22,2 +22,3 @@ var __extends = (this && this.__extends) || (function () {

import { BaseCreator } from "./baseCreator";
import { Downloader } from "./downloader";
import { CsvSerializingSession } from "./sessions/csvSerializingSession";

@@ -31,3 +32,2 @@ var CsvCreator = /** @class */ (function (_super) {

this.setBeans({
downloader: this.downloader,
gridSerializer: this.gridSerializer,

@@ -37,2 +37,18 @@ gridOptionsWrapper: this.gridOptionsWrapper

};
CsvCreator.prototype.getDefaultExportParams = function () {
return this.gridOptionsWrapper.getDefaultExportParams('csv');
};
CsvCreator.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 packagedFile = new Blob(["\ufeff", data], {
// @ts-ignore
type: window.navigator.msSaveOrOpenBlob ? this.getMimeType() : 'octet/stream'
});
Downloader.download(this.getFileName(mergedParams.fileName), packagedFile);
return data;
};
CsvCreator.prototype.exportDataAsCsv = function (params) {

@@ -42,3 +58,3 @@ return this.export(params);

CsvCreator.prototype.getDataAsCsv = function (params) {
return this.getData(params);
return this.getMergedParamsAndData(params).data;
};

@@ -79,5 +95,2 @@ CsvCreator.prototype.getMimeType = function () {

__decorate([
Autowired('downloader')
], CsvCreator.prototype, "downloader", void 0);
__decorate([
Autowired('gridSerializer')

@@ -84,0 +97,0 @@ ], CsvCreator.prototype, "gridSerializer", void 0);

export declare class Downloader {
download(fileName: string, content: Blob): void;
static download(fileName: string, content: Blob): void;
}

@@ -1,12 +0,5 @@

var __decorate = (this && this.__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;
};
import { Bean } from "@ag-grid-community/core";
var Downloader = /** @class */ (function () {
function Downloader() {
}
Downloader.prototype.download = function (fileName, content) {
Downloader.download = function (fileName, content) {
// Internet Explorer

@@ -35,7 +28,4 @@ if (window.navigator.msSaveOrOpenBlob) {

};
Downloader = __decorate([
Bean("downloader")
], Downloader);
return Downloader;
}());
export { Downloader };

@@ -1,3 +0,8 @@

import { BeanStub, ColumnGroupChild, ExportParams, ProcessGroupHeaderForExportParams } from "@ag-grid-community/core";
import { BeanStub, ExportParams } from "@ag-grid-community/core";
import { GridSerializingSession } from "./interfaces";
export declare enum RowType {
HEADER_GROUPING = 0,
HEADER = 1,
BODY = 2
}
export declare class GridSerializer extends BeanStub {

@@ -10,11 +15,14 @@ private displayedGroupCreator;

serialize<T>(gridSerializingSession: GridSerializingSession<T>, params?: ExportParams<T>): string;
recursivelyAddHeaderGroups<T>(displayedGroups: ColumnGroupChild[], gridSerializingSession: GridSerializingSession<T>, processGroupHeaderCallback: ProcessGroupHeaderCallback | undefined): void;
private processRow;
private appendContent;
private prependContent;
private prepareSession;
private exportColumnGroups;
private exportHeaders;
private processPinnedTopRows;
private processRows;
private processPinnedBottomRows;
private getColumnsToExport;
private recursivelyAddHeaderGroups;
private doAddHeaderHeader;
}
declare type ProcessGroupHeaderCallback = (params: ProcessGroupHeaderForExportParams) => string;
export declare enum RowType {
HEADER_GROUPING = 0,
HEADER = 1,
BODY = 2
}
export {};

@@ -21,2 +21,8 @@ var __extends = (this && this.__extends) || (function () {

import { Autowired, Bean, BeanStub, ColumnGroup, Constants, GroupInstanceIdCreator, _ } from "@ag-grid-community/core";
export var RowType;
(function (RowType) {
RowType[RowType["HEADER_GROUPING"] = 0] = "HEADER_GROUPING";
RowType[RowType["HEADER"] = 1] = "HEADER";
RowType[RowType["BODY"] = 2] = "BODY";
})(RowType || (RowType = {}));
var GridSerializer = /** @class */ (function (_super) {

@@ -29,124 +35,180 @@ __extends(GridSerializer, _super);

if (params === void 0) { params = {}; }
var columnsToExport = this.getColumnsToExport(params.allColumns, params.columnKeys);
var serializeChain = _.compose(
// first pass, put in the header names of the cols
this.prepareSession(columnsToExport), this.prependContent(params), this.exportColumnGroups(params, columnsToExport), this.exportHeaders(params, columnsToExport), this.processPinnedTopRows(params, columnsToExport), this.processRows(params, columnsToExport), this.processPinnedBottomRows(params, columnsToExport), this.appendContent(params));
return serializeChain(gridSerializingSession).parse();
};
GridSerializer.prototype.processRow = function (gridSerializingSession, params, columnsToExport, node) {
var rowSkipper = params.shouldRowBeSkipped || (function () { return false; });
var gridOptionsWrapper = this.gridOptionsWrapper;
var context = gridOptionsWrapper.getContext();
var api = gridOptionsWrapper.getApi();
var columnApi = gridOptionsWrapper.getColumnApi();
var skipSingleChildrenGroup = gridOptionsWrapper.isGroupRemoveSingleChildren();
var hideOpenParents = gridOptionsWrapper.isGroupHideOpenParents();
var skipLowestSingleChildrenGroup = gridOptionsWrapper.isGroupRemoveLowestSingleChildren();
var hideOpenParents = gridOptionsWrapper.isGroupHideOpenParents();
var context = 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);
var skipRowGroups = params.skipGroups || params.skipRowGroups;
var shouldSkipLowestGroup = skipLowestSingleChildrenGroup && node.leafGroup;
var shouldSkipCurrentGroup = node.allChildrenCount === 1 && (skipSingleChildrenGroup || shouldSkipLowestGroup);
if (skipRowGroups && params.skipGroups) {
console.warn('AG Grid: Since v25.2 `skipGroups` has been renamed to `skipRowGroups`.');
}
else if (params.allColumns && !isPivotMode) {
// add auto group column for tree data
columnsToExport = gridOptionsWrapper.isTreeData() ?
this.columnController.getGridColumns([Constants.GROUP_AUTO_COLUMN_ID]) : [];
columnsToExport = columnsToExport.concat(this.columnController.getAllPrimaryColumns() || []);
if ((node.group && (params.skipRowGroups || shouldSkipCurrentGroup || hideOpenParents)) ||
(params.onlySelected && !node.isSelected()) ||
(params.skipPinnedTop && node.rowPinned === 'top') ||
(params.skipPinnedBottom && node.rowPinned === 'bottom')) {
return;
}
else {
columnsToExport = this.columnController.getAllDisplayedColumns();
// 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;
}
if (params.customHeader) {
gridSerializingSession.addCustomContent(params.customHeader);
var shouldRowBeSkipped = rowSkipper({ node: node, api: api, context: context });
if (shouldRowBeSkipped) {
return;
}
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);
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);
}
}
if (!params.skipHeader) {
var gridRowIterator_1 = gridSerializingSession.onNewHeaderRow();
columnsToExport.forEach(function (column, index) {
gridRowIterator_1.onColumn(column, index, undefined);
});
}
this.pinnedRowModel.forEachPinnedTopRow(processRow);
var rowModel = this.rowModel;
var clientSideRowModel = this.rowModel;
if (isPivotMode) {
// @ts-ignore - ignore tautology below as we are using it to check if it's clientSideRowModel
if (clientSideRowModel.forEachPivotNode) {
clientSideRowModel.forEachPivotNode(processRow);
};
GridSerializer.prototype.appendContent = function (params) {
return function (gridSerializingSession) {
var appendContent = params.customFooter || params.appendContent;
if (appendContent) {
if (params.customFooter) {
console.warn('AG Grid: Since version 25.2.0 the `customFooter` param has been deprecated. Use `appendContent` instead.');
}
gridSerializingSession.addCustomContent(appendContent);
}
else {
// n=must be enterprise, so we can just loop through all the nodes
rowModel.forEachNode(processRow);
return gridSerializingSession;
};
};
GridSerializer.prototype.prependContent = function (params) {
return function (gridSerializingSession) {
var prependContent = params.customHeader || params.prependContent;
if (prependContent) {
if (params.customHeader) {
console.warn('AG Grid: Since version 25.2.0 the `customHeader` param has been deprecated. Use `prependContent` instead.');
}
gridSerializingSession.addCustomContent(prependContent);
}
}
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);
return gridSerializingSession;
};
};
GridSerializer.prototype.prepareSession = function (columnsToExport) {
return function (gridSerializingSession) {
gridSerializingSession.prepare(columnsToExport);
return gridSerializingSession;
};
};
GridSerializer.prototype.exportColumnGroups = function (params, columnsToExport) {
var _this = this;
return function (gridSerializingSession) {
if (!params.skipColumnGroupHeaders) {
var groupInstanceIdCreator = new GroupInstanceIdCreator();
var displayedGroups = _this.displayedGroupCreator.createDisplayedGroups(columnsToExport, _this.columnController.getGridBalancedTree(), groupInstanceIdCreator, null);
_this.recursivelyAddHeaderGroups(displayedGroups, gridSerializingSession, params.processGroupHeaderCallback);
}
else if (params.columnGroups) {
console.warn('AG Grid: Since v25.2 the `columnGroups` param has deprecated, and groups are exported by default.');
}
return gridSerializingSession;
};
};
GridSerializer.prototype.exportHeaders = function (params, columnsToExport) {
return function (gridSerializingSession) {
if (!params.skipHeader && !params.skipColumnHeaders) {
var gridRowIterator_1 = gridSerializingSession.onNewHeaderRow();
columnsToExport.forEach(function (column, index) {
gridRowIterator_1.onColumn(column, index, undefined);
});
}
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.
else if (params.skipHeader) {
console.warn('AG Grid: Since v25.2 the `skipHeader` param has been renamed to `skipColumnHeaders`.');
}
return gridSerializingSession;
};
};
GridSerializer.prototype.processPinnedTopRows = function (params, columnsToExport) {
var _this = this;
return function (gridSerializingSession) {
var processRow = _this.processRow.bind(_this, gridSerializingSession, params, columnsToExport);
_this.pinnedRowModel.forEachPinnedTopRow(processRow);
return gridSerializingSession;
};
};
GridSerializer.prototype.processRows = function (params, columnsToExport) {
var _this = this;
return function (gridSerializingSession) {
// when in pivot mode, we always render cols on screen, never 'all columns'
var rowModel = _this.rowModel;
var rowModelNormal = rowModel.getType() === Constants.ROW_MODEL_TYPE_CLIENT_SIDE;
var onlySelectedNonStandardModel = !rowModelNormal && params.onlySelected;
var processRow = _this.processRow.bind(_this, gridSerializingSession, params, columnsToExport);
if (_this.columnController.isPivotMode()) {
if (rowModelNormal) {
clientSideRowModel.forEachNodeAfterFilterAndSort(processRow);
rowModel.forEachPivotNode(processRow);
}
else {
// must be enterprise, so we can just loop through all the nodes
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 || hideOpenParents)) {
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);
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(processRow);
}
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) {
rowModel.forEachNodeAfterFilterAndSort(processRow);
}
else {
rowModel.forEachNode(processRow);
}
}
}
return gridSerializingSession;
};
};
GridSerializer.prototype.processPinnedBottomRows = function (params, columnsToExport) {
var _this = this;
return function (gridSerializingSession) {
var processRow = _this.processRow.bind(_this, gridSerializingSession, params, columnsToExport);
_this.pinnedRowModel.forEachPinnedBottomRow(processRow);
return gridSerializingSession;
};
};
GridSerializer.prototype.getColumnsToExport = function (allColumns, columnKeys) {
if (allColumns === void 0) { allColumns = false; }
var isPivotMode = this.columnController.isPivotMode();
if (columnKeys && columnKeys.length) {
return this.columnController.getGridColumns(columnKeys);
}
return gridSerializingSession.parse();
if (allColumns && !isPivotMode) {
// add auto group column for tree data
var columns = this.gridOptionsWrapper.isTreeData()
? this.columnController.getGridColumns([Constants.GROUP_AUTO_COLUMN_ID])
: [];
return columns.concat(this.columnController.getAllPrimaryColumns() || []);
}
return this.columnController.getAllDisplayedColumns();
};

@@ -211,7 +273,1 @@ GridSerializer.prototype.recursivelyAddHeaderGroups = function (displayedGroups, gridSerializingSession, processGroupHeaderCallback) {

export { GridSerializer };
export var RowType;
(function (RowType) {
RowType[RowType["HEADER_GROUPING"] = 0] = "HEADER_GROUPING";
RowType[RowType["HEADER"] = 1] = "HEADER";
RowType[RowType["BODY"] = 2] = "BODY";
})(RowType || (RowType = {}));
import { Column, ColumnController, GridOptionsWrapper, ProcessCellForExportParams, ProcessGroupHeaderForExportParams, ProcessHeaderForExportParams, ProcessRowGroupForExportParams, RowNode, ValueService } from "@ag-grid-community/core";
import { Downloader } from "../downloader";
import { GridSerializer } from "../gridSerializer";
export interface BaseCreatorBeans {
downloader: Downloader;
gridSerializer: GridSerializer;

@@ -7,0 +5,0 @@ gridOptionsWrapper: GridOptionsWrapper;

@@ -20,3 +20,3 @@ import { Column, ColumnController, GridOptionsWrapper, ProcessCellForExportParams, ProcessGroupHeaderForExportParams, ProcessHeaderForExportParams, ProcessRowGroupForExportParams, RowNode, ValueService } from "@ag-grid-community/core";

extractHeaderValue(column: Column): string;
extractRowCellValue(column: Column, index: number, type: string, node: RowNode): any;
extractRowCellValue(column: Column, index: number, accumulatedRowIndex: number, type: string, node: RowNode): any;
private getHeaderName;

@@ -23,0 +23,0 @@ private createValueForGroupNode;

@@ -21,3 +21,3 @@ import { _ } from "@ag-grid-community/core";

};
BaseGridSerializingSession.prototype.extractRowCellValue = function (column, index, type, node) {
BaseGridSerializingSession.prototype.extractRowCellValue = function (column, index, accumulatedRowIndex, type, node) {
// we render the group summary text e.g. "-> Parent -> Child"...

@@ -40,3 +40,3 @@ var groupIndex = this.gridOptionsWrapper.isGroupMultiAutoColumn() ? node.rowGroupIndex : 0;

}
var value = this.processCell(node, column, valueForCell, this.processCellCallback, type);
var value = this.processCell(accumulatedRowIndex, node, column, valueForCell, this.processCellCallback, type);
return value != null ? value : '';

@@ -73,5 +73,6 @@ };

};
BaseGridSerializingSession.prototype.processCell = function (rowNode, column, value, processCellCallback, type) {
BaseGridSerializingSession.prototype.processCell = function (accumulatedRowIndex, rowNode, column, value, processCellCallback, type) {
if (processCellCallback) {
return processCellCallback({
accumulatedRowIndex: accumulatedRowIndex,
column: column,

@@ -86,3 +87,3 @@ node: rowNode,

}
return value;
return value != null ? value : '';
};

@@ -89,0 +90,0 @@ return BaseGridSerializingSession;

@@ -34,4 +34,2 @@ var __extends = (this && this.__extends) || (function () {

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)) {

@@ -99,3 +97,3 @@ this.beginNewLine();

}
this.result += this.putInQuotes(this.extractRowCellValue(column, index, Constants.EXPORT_TYPE_CSV, node));
this.result += this.putInQuotes(this.extractRowCellValue(column, index, index, Constants.EXPORT_TYPE_CSV, node));
};

@@ -102,0 +100,0 @@ CsvSerializingSession.prototype.putInQuotes = function (value) {

@@ -1,6 +0,6 @@

import { BeanStub, HeaderElement, XmlElement } from "@ag-grid-community/core";
export declare class XmlFactory extends BeanStub {
createHeader(headerElement?: HeaderElement): string;
createXml(xmlElement: XmlElement, booleanTransformer?: (currentValue: boolean) => string): string;
private returnAttributeIfPopulated;
import { HeaderElement, XmlElement } from "@ag-grid-community/core";
export declare class XmlFactory {
static createHeader(headerElement?: HeaderElement): string;
static createXml(xmlElement: XmlElement, booleanTransformer?: (currentValue: boolean) => string): string;
private static returnAttributeIfPopulated;
}

@@ -1,28 +0,6 @@

var __extends = (this && this.__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 = (this && this.__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;
};
import { Bean, BeanStub } from "@ag-grid-community/core";
var LINE_SEPARATOR = '\r\n';
var XmlFactory = /** @class */ (function (_super) {
__extends(XmlFactory, _super);
var XmlFactory = /** @class */ (function () {
function XmlFactory() {
return _super !== null && _super.apply(this, arguments) || this;
}
XmlFactory.prototype.createHeader = function (headerElement) {
XmlFactory.createHeader = function (headerElement) {
if (headerElement === void 0) { headerElement = {}; }

@@ -44,3 +22,3 @@ var headerStart = '<?';

};
XmlFactory.prototype.createXml = function (xmlElement, booleanTransformer) {
XmlFactory.createXml = function (xmlElement, booleanTransformer) {
var _this = this;

@@ -77,3 +55,3 @@ var props = '';

};
XmlFactory.prototype.returnAttributeIfPopulated = function (key, value, booleanTransformer) {
XmlFactory.returnAttributeIfPopulated = function (key, value, booleanTransformer) {
if (!value && value !== '' && value !== 0) {

@@ -90,7 +68,4 @@ return '';

};
XmlFactory = __decorate([
Bean('xmlFactory')
], XmlFactory);
return XmlFactory;
}(BeanStub));
}());
export { XmlFactory };

@@ -1,5 +0,5 @@

import { BeanStub } from "@ag-grid-community/core";
export interface ZipFolder {
path: string;
created: Date;
isBase64: boolean;
}

@@ -9,17 +9,18 @@ export interface ZipFile extends ZipFolder {

}
export declare class ZipContainer extends BeanStub {
private folders;
private files;
private addFolder;
addFolders(paths: string[]): void;
addFile(path: string, content: string): void;
private clearStream;
getContent(mimeType?: string): Blob;
private buildFileStream;
private getHeader;
private buildFolderEnd;
private buildUint8Array;
private getFromCrc32Table;
private convertTime;
private convertDate;
export declare class ZipContainer {
private static folders;
private static files;
static addFolders(paths: string[]): void;
private static addFolder;
static addFile(path: string, content: string, isBase64?: boolean): void;
static getContent(mimeType?: string): Blob;
private static clearStream;
private static buildFileStream;
private static getHeader;
private static getConvertedContent;
private static buildFolderEnd;
private static buildUint8Array;
private static getFromCrc32Table;
private static convertTime;
private static convertDate;
}

@@ -1,86 +0,72 @@

var __extends = (this && this.__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 = (this && this.__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;
};
import { Bean, BeanStub, _ } from "@ag-grid-community/core";
import { _ } from "@ag-grid-community/core";
// 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(ZipContainer, _super);
var crcTable = new Uint32Array([
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
]);
var ZipContainer = /** @class */ (function () {
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.addFolders = function (paths) {
paths.forEach(this.addFolder.bind(this));
};
ZipContainer.prototype.addFile = function (path, content) {
ZipContainer.addFolder = function (path) {
this.folders.push({
path: path,
created: new Date(),
isBase64: false
});
};
ZipContainer.addFile = function (path, content, isBase64) {
if (isBase64 === void 0) { isBase64 = false; }
this.files.push({
path: path,
created: new Date(),
content: content
content: content,
isBase64: isBase64
});
};
ZipContainer.prototype.clearStream = function () {
this.folders = [];
this.files = [];
};
ZipContainer.prototype.getContent = function (mimeType) {
ZipContainer.getContent = function (mimeType) {
if (mimeType === void 0) { mimeType = 'application/zip'; }

@@ -92,3 +78,7 @@ var textOutput = this.buildFileStream();

};
ZipContainer.prototype.buildFileStream = function (fData) {
ZipContainer.clearStream = function () {
this.folders = [];
this.files = [];
};
ZipContainer.buildFileStream = function (fData) {
if (fData === void 0) { fData = ''; }

@@ -111,4 +101,4 @@ var totalFiles = this.folders.concat(this.files);

};
ZipContainer.prototype.getHeader = function (currentFile, offset) {
var content = currentFile.content, path = currentFile.path, created = currentFile.created;
ZipContainer.getHeader = function (currentFile, offset) {
var content = currentFile.content, path = currentFile.path, created = currentFile.created, isBase64 = currentFile.isBase64;
var utf8_encode = _.utf8_encode, decToHex = _.decToHex;

@@ -124,2 +114,3 @@ var utfPath = utf8_encode(path);

}
var _a = !content ? { size: 0, content: '' } : this.getConvertedContent(content, isBase64), size = _a.size, convertedContent = _a.content;
var header = '\x0A\x00' +

@@ -130,5 +121,5 @@ (isUTF8 ? '\x00\x08' : '\x00\x00') +

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(size ? this.getFromCrc32Table(convertedContent) : 0, 4) +
decToHex(size, 4) + // compressed size
decToHex(size, 4) + // uncompressed size
decToHex(utfPath.length, 2) + // file name length

@@ -147,5 +138,16 @@ decToHex(extraFields.length, 2); // extra field length

extraFields; // extra field
return { fileHeader: fileHeader, folderHeader: folderHeader, content: content || '' };
return { fileHeader: fileHeader, folderHeader: folderHeader, content: convertedContent || '' };
};
ZipContainer.prototype.buildFolderEnd = function (tLen, cLen, lLen) {
ZipContainer.getConvertedContent = function (content, isBase64) {
if (isBase64 === void 0) { isBase64 = false; }
if (isBase64) {
content = content.split(';base64,')[1];
}
content = isBase64 ? atob(content) : content;
return {
size: content.length,
content: content
};
};
ZipContainer.buildFolderEnd = function (tLen, cLen, lLen) {
var decToHex = _.decToHex;

@@ -161,3 +163,3 @@ return 'PK\x05\x06' + // central folder end

};
ZipContainer.prototype.buildUint8Array = function (content) {
ZipContainer.buildUint8Array = function (content) {
var uint8 = new Uint8Array(content.length);

@@ -169,13 +171,17 @@ for (var i = 0; i < uint8.length; i++) {

};
ZipContainer.prototype.getFromCrc32Table = function (content, crc) {
if (crc === void 0) { crc = 0; }
ZipContainer.getFromCrc32Table = function (content) {
if (!content.length) {
return 0;
}
crc ^= (-1);
var size = content.length;
var iterable = new Uint8Array(size);
for (var i = 0; i < size; i++) {
iterable[i] = content.charCodeAt(i);
}
var crc = 0 ^ (-1);
var j = 0;
var k = 0;
var l = 0;
for (var i = 0; i < content.length; i++) {
j = content.charCodeAt(i);
for (var i = 0; i < size; i++) {
j = iterable[i];
k = (crc ^ j) & 0xFF;

@@ -187,3 +193,3 @@ l = crcTable[k];

};
ZipContainer.prototype.convertTime = function (date) {
ZipContainer.convertTime = function (date) {
var time = date.getHours();

@@ -196,3 +202,3 @@ time <<= 6;

};
ZipContainer.prototype.convertDate = function (date) {
ZipContainer.convertDate = function (date) {
var dt = date.getFullYear() - 1980;

@@ -205,7 +211,6 @@ dt <<= 4;

};
ZipContainer = __decorate([
Bean('zipContainer')
], ZipContainer);
ZipContainer.folders = [];
ZipContainer.files = [];
return ZipContainer;
}(BeanStub));
}());
export { ZipContainer };
import { ModuleNames } from "@ag-grid-community/core";
import { CsvCreator } from "./csvExport/csvCreator";
import { Downloader } from "./csvExport/downloader";
import { XmlFactory } from "./csvExport/xmlFactory";
import { GridSerializer } from "./csvExport/gridSerializer";
import { ZipContainer } from "./csvExport/zipContainer";
export var CsvExportModule = {
moduleName: ModuleNames.CsvExportModule,
beans: [CsvCreator, Downloader, XmlFactory, GridSerializer, ZipContainer]
beans: [CsvCreator, GridSerializer]
};
{
"name": "@ag-grid-community/csv-export",
"version": "25.1.0",
"version": "25.2.0",
"description": "Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components",

@@ -45,3 +45,3 @@ "main": "./dist/cjs/main.js",

"dependencies": {
"@ag-grid-community/core": "~25.1.0"
"@ag-grid-community/core": "~25.2.0"
},

@@ -48,0 +48,0 @@ "devDependencies": {

@@ -10,3 +10,3 @@ ![alt text](./github-banner.png "AG Grid")

AG Grid is a fully-featured and highly customizable JavaScript data grid.
It delivers [outstanding performance](https://www.ag-grid.com/example.php?utm_source=@ag-grid-community/csv-export-readme&utm_medium=repository&utm_campaign=github), has no third-party dependencies and [integrates smoothly with all major JavaScript frameworks](https://www.ag-grid.com/documentation/javascript/getting-started/?utm_source=@ag-grid-community/csv-export-readme&utm_medium=repository&utm_campaign=github).
It delivers [outstanding performance](https://www.ag-grid.com/example.php?utm_source=@ag-grid-community/csv-export-readme&utm_medium=repository&utm_campaign=github), has no third-party dependencies and [integrates smoothly with all major JavaScript frameworks](https://www.ag-grid.com/javascript-grid/getting-started/?utm_source=@ag-grid-community/csv-export-readme&utm_medium=repository&utm_campaign=github).

@@ -54,6 +54,6 @@ Here's how our grid looks with multiple filters and grouping enabled:

* [Get Started with Angular](https://www.ag-grid.com/documentation/angular/getting-started/?utm_source=@ag-grid-community/csv-export-readme&utm_medium=repository&utm_campaign=github)
* [Get Started with React](https://www.ag-grid.com/documentation/react/getting-started/?utm_source=@ag-grid-community/csv-export-readme&utm_medium=repository&utm_campaign=github)
* [Get Started with Vue](https://www.ag-grid.com/documentation/vue/getting-started/?utm_source=@ag-grid-community/csv-export-readme&utm_medium=repository&utm_campaign=github)
* [Get Started with AngularJS](https://www.ag-grid.com/documentation/angular/angularjs/?utm_source=@ag-grid-community/csv-export-readme&utm_medium=repository&utm_campaign=github)
* [Get Started with Angular](https://www.ag-grid.com/angular-grid/getting-started/?utm_source=@ag-grid-community/csv-export-readme&utm_medium=repository&utm_campaign=github)
* [Get Started with React](https://www.ag-grid.com/react-grid/getting-started/?utm_source=@ag-grid-community/csv-export-readme&utm_medium=repository&utm_campaign=github)
* [Get Started with Vue](https://www.ag-grid.com/vue-grid/getting-started/?utm_source=@ag-grid-community/csv-export-readme&utm_medium=repository&utm_campaign=github)
* [Get Started with AngularJS](https://www.ag-grid.com/angular-grid/angularjs/?utm_source=@ag-grid-community/csv-export-readme&utm_medium=repository&utm_campaign=github)

@@ -107,3 +107,3 @@ ## Getting started

For more information on how to integrate the grid into your project see [TypeScript - Building with Webpack 2](https://www.ag-grid.com/documentation/javascript/building-typescript/?utm_source=@ag-grid-community/csv-export-readme&utm_medium=repository&utm_campaign=github).
For more information on how to integrate the grid into your project see [TypeScript - Building with Webpack 2](https://www.ag-grid.com/javascript-grid/building-typescript/?utm_source=@ag-grid-community/csv-export-readme&utm_medium=repository&utm_campaign=github).

@@ -110,0 +110,0 @@ ## Issue Reporting

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc