Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ag-grid-enterprise/clipboard

Package Overview
Dependencies
Maintainers
3
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ag-grid-enterprise/clipboard - npm Package Compare versions

Comparing version 29.0.0 to 29.1.0

6

dist/cjs/es5/clipboard/clipboardService.d.ts

@@ -27,2 +27,3 @@ import { BeanStub, CellPositionUtils, IClipboardCopyParams, IClipboardCopyRowsParams, IClipboardService, RowPositionUtils, CtrlsService } from "@ag-grid-community/core";

private processClipboardData;
static stringToArray(strData: string, delimiter?: string): string[][];
private doPasteOperation;

@@ -40,2 +41,7 @@ private pasteIntoActiveRange;

copyToClipboard(params?: IClipboardCopyParams): void;
cutToClipboard(params?: IClipboardCopyParams): void;
private copyOrCutToClipboard;
private clearCellsAfterCopy;
private clearSelectedRows;
private clearCellValue;
private shouldSkipSingleCellRange;

@@ -42,0 +48,0 @@ private iterateActiveRanges;

189

dist/cjs/es5/clipboard/clipboardService.js

@@ -21,6 +21,16 @@ "use strict";

};
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ClipboardService = void 0;
var core_1 = require("@ag-grid-community/core");
var csv_1 = require("./csv");
// Matches value in changeDetectionService

@@ -30,2 +40,9 @@ var SOURCE_PASTE = 'paste';

var EXPORT_TYPE_CLIPBOARD = 'clipboard';
var CellClearType;
(function (CellClearType) {
CellClearType[CellClearType["CellRange"] = 0] = "CellRange";
CellClearType[CellClearType["SelectedRows"] = 1] = "SelectedRows";
CellClearType[CellClearType["FocusedCell"] = 2] = "FocusedCell";
})(CellClearType || (CellClearType = {}));
;
var ClipboardService = /** @class */ (function (_super) {

@@ -39,2 +56,3 @@ __extends(ClipboardService, _super);

}
ClipboardService_1 = ClipboardService;
ClipboardService.prototype.init = function () {

@@ -124,3 +142,3 @@ var _this = this;

}
var parsedData = csv_1.stringToArray(data, this.getClipboardDelimiter());
var parsedData = ClipboardService_1.stringToArray(data, this.getClipboardDelimiter());
var userFunc = this.gridOptionsService.getCallback('processDataFromClipboard');

@@ -148,6 +166,84 @@ if (userFunc) {

};
// This will parse a delimited string into an array of arrays.
ClipboardService.stringToArray = function (strData, delimiter) {
if (delimiter === void 0) { delimiter = ','; }
var data = [];
var isNewline = function (char) { return char === '\r' || char === '\n'; };
var insideQuotedField = false;
if (strData === '') {
return [['']];
}
var _loop_1 = function (row, column, position) {
var previousChar = strData[position - 1];
var currentChar = strData[position];
var nextChar = strData[position + 1];
var ensureDataExists = function () {
if (!data[row]) {
// create row if it doesn't exist
data[row] = [];
}
if (!data[row][column]) {
// create column if it doesn't exist
data[row][column] = '';
}
};
ensureDataExists();
if (currentChar === '"') {
if (insideQuotedField) {
if (nextChar === '"') {
// unescape double quote
data[row][column] += '"';
position++;
}
else {
// exit quoted field
insideQuotedField = false;
}
return out_row_1 = row, out_column_1 = column, out_position_1 = position, "continue";
}
else if (previousChar === undefined || previousChar === delimiter || isNewline(previousChar)) {
// enter quoted field
insideQuotedField = true;
return out_row_1 = row, out_column_1 = column, out_position_1 = position, "continue";
}
}
if (!insideQuotedField) {
if (currentChar === delimiter) {
// move to next column
column++;
ensureDataExists();
return out_row_1 = row, out_column_1 = column, out_position_1 = position, "continue";
}
else if (isNewline(currentChar)) {
// move to next row
column = 0;
row++;
ensureDataExists();
if (currentChar === '\r' && nextChar === '\n') {
// skip over second newline character if it exists
position++;
}
return out_row_1 = row, out_column_1 = column, out_position_1 = position, "continue";
}
}
// add current character to current column
data[row][column] += currentChar;
out_row_1 = row;
out_column_1 = column;
out_position_1 = position;
};
var out_row_1, out_column_1, out_position_1;
// iterate over each character, keep track of current row and column (of the returned array)
for (var row = 0, column = 0, position = 0; position < strData.length; position++) {
_loop_1(row, column, position);
row = out_row_1;
column = out_column_1;
position = out_position_1;
}
return data;
};
// common code to paste operations, e.g. paste to cell, paste to range, and copy range down
ClipboardService.prototype.doPasteOperation = function (pasteOperationFunc) {
var api = this.gridOptionsService.get('api');
var columnApi = this.gridOptionsService.get('columnApi');
var api = this.gridOptionsService.api;
var columnApi = this.gridOptionsService.columnApi;
var source = 'clipboard';

@@ -218,3 +314,4 @@ this.eventService.dispatchEvent({

}
var cellId = _this.cellPositionUtils.createIdFromValues(currentRow.rowIndex, column, currentRow.rowPinned);
var rowIndex = currentRow.rowIndex, rowPinned = currentRow.rowPinned;
var cellId = _this.cellPositionUtils.createIdFromValues({ rowIndex: rowIndex, column: column, rowPinned: rowPinned });
cellsToFlash[cellId] = true;

@@ -290,3 +387,4 @@ });

}
var cellId = _this.cellPositionUtils.createIdFromValues(currentRow.rowIndex, column, currentRow.rowPinned);
var rowIndex = currentRow.rowIndex, rowPinned = currentRow.rowPinned;
var cellId = _this.cellPositionUtils.createIdFromValues({ rowIndex: rowIndex, column: column, rowPinned: rowPinned });
cellsToFlash[cellId] = true;

@@ -375,3 +473,4 @@ });

rowNode.setDataValue(column, processedValue, SOURCE_PASTE);
var cellId = this.cellPositionUtils.createIdFromValues(rowNode.rowIndex, column, rowNode.rowPinned);
var rowIndex = rowNode.rowIndex, rowPinned = rowNode.rowPinned;
var cellId = this.cellPositionUtils.createIdFromValues({ rowIndex: rowIndex, column: column, rowPinned: rowPinned });
cellsToFlash[cellId] = true;

@@ -384,2 +483,9 @@ if (changedPath) {

if (params === void 0) { params = {}; }
this.copyOrCutToClipboard(params);
};
ClipboardService.prototype.cutToClipboard = function (params) {
if (params === void 0) { params = {}; }
this.copyOrCutToClipboard(params, true);
};
ClipboardService.prototype.copyOrCutToClipboard = function (params, cut) {
var includeHeaders = params.includeHeaders, includeGroupHeaders = params.includeGroupHeaders;

@@ -396,13 +502,76 @@ this.logger.log("copyToClipboard: includeHeaders = " + includeHeaders);

var shouldCopyRows = !this.gridOptionsService.is('suppressCopyRowsToClipboard');
var cellClearType = null;
// Copy priority is Range > Row > Focus
if (this.rangeService && !this.rangeService.isEmpty() && !this.shouldSkipSingleCellRange()) {
this.copySelectedRangeToClipboard(copyParams);
cellClearType = CellClearType.CellRange;
}
else if (shouldCopyRows && !this.selectionService.isEmpty()) {
this.copySelectedRowsToClipboard(copyParams);
cellClearType = CellClearType.SelectedRows;
}
else if (this.focusService.isAnyCellFocused()) {
this.copyFocusedCellToClipboard(copyParams);
cellClearType = CellClearType.FocusedCell;
}
if (cut && cellClearType !== null) {
this.clearCellsAfterCopy(cellClearType);
}
};
ClipboardService.prototype.clearCellsAfterCopy = function (type) {
this.eventService.dispatchEvent({ type: core_1.Events.EVENT_KEY_SHORTCUT_CHANGED_CELL_START });
if (type === CellClearType.CellRange) {
this.rangeService.clearCellRangeCellValues(undefined, 'clipboardService');
}
else if (type === CellClearType.SelectedRows) {
this.clearSelectedRows();
}
else {
var focusedCell = this.focusService.getFocusedCell();
if (focusedCell == null) {
return;
}
var rowNode = this.rowPositionUtils.getRowNode(focusedCell);
if (rowNode) {
this.clearCellValue(rowNode, focusedCell.column);
}
}
this.eventService.dispatchEvent({ type: core_1.Events.EVENT_KEY_SHORTCUT_CHANGED_CELL_END });
};
ClipboardService.prototype.clearSelectedRows = function () {
var e_1, _a, e_2, _b;
var selected = this.selectionService.getSelectedNodes();
var columns = this.columnModel.getAllDisplayedColumns();
try {
for (var selected_1 = __values(selected), selected_1_1 = selected_1.next(); !selected_1_1.done; selected_1_1 = selected_1.next()) {
var row = selected_1_1.value;
try {
for (var columns_1 = (e_2 = void 0, __values(columns)), columns_1_1 = columns_1.next(); !columns_1_1.done; columns_1_1 = columns_1.next()) {
var col = columns_1_1.value;
this.clearCellValue(row, col);
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (columns_1_1 && !columns_1_1.done && (_b = columns_1.return)) _b.call(columns_1);
}
finally { if (e_2) throw e_2.error; }
}
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (selected_1_1 && !selected_1_1.done && (_a = selected_1.return)) _a.call(selected_1);
}
finally { if (e_1) throw e_1.error; }
}
};
ClipboardService.prototype.clearCellValue = function (rowNode, column) {
if (!column.isCellEditable(rowNode)) {
return;
}
rowNode.setDataValue(column, null, 'clipboardService');
};
ClipboardService.prototype.shouldSkipSingleCellRange = function () {

@@ -515,3 +684,4 @@ return this.gridOptionsService.is('suppressCopySingleCellRanges') && !this.rangeService.isMoreThanOneCell();

range.columns.forEach(function (column) {
var cellId = _this.cellPositionUtils.createIdFromValues(node.rowIndex, column, node.rowPinned);
var _a = node, rowIndex = _a.rowIndex, rowPinned = _a.rowPinned;
var cellId = _this.cellPositionUtils.createIdFromValues({ rowIndex: rowIndex, column: column, rowPinned: rowPinned });
cellsToFlash[cellId] = true;

@@ -708,2 +878,3 @@ });

};
var ClipboardService_1;
__decorate([

@@ -751,3 +922,3 @@ core_1.Autowired('csvCreator')

], ClipboardService.prototype, "init", null);
ClipboardService = __decorate([
ClipboardService = ClipboardService_1 = __decorate([
core_1.Bean('clipboardService')

@@ -754,0 +925,0 @@ ], ClipboardService);

2

dist/cjs/es5/version.d.ts

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

export declare const VERSION = "29.0.0";
export declare const VERSION = "29.1.0";

@@ -5,2 +5,2 @@ "use strict";

// DO NOT UPDATE MANUALLY: Generated from script during build time
exports.VERSION = '29.0.0';
exports.VERSION = '29.1.0';

@@ -27,2 +27,3 @@ import { BeanStub, CellPositionUtils, IClipboardCopyParams, IClipboardCopyRowsParams, IClipboardService, RowPositionUtils, CtrlsService } from "@ag-grid-community/core";

private processClipboardData;
static stringToArray(strData: string, delimiter?: string): string[][];
private doPasteOperation;

@@ -40,2 +41,7 @@ private pasteIntoActiveRange;

copyToClipboard(params?: IClipboardCopyParams): void;
cutToClipboard(params?: IClipboardCopyParams): void;
private copyOrCutToClipboard;
private clearCellsAfterCopy;
private clearSelectedRows;
private clearCellValue;
private shouldSkipSingleCellRange;

@@ -42,0 +48,0 @@ private iterateActiveRanges;

@@ -8,6 +8,6 @@ "use strict";

};
var ClipboardService_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ClipboardService = void 0;
const core_1 = require("@ag-grid-community/core");
const csv_1 = require("./csv");
// Matches value in changeDetectionService

@@ -17,3 +17,10 @@ const SOURCE_PASTE = 'paste';

const EXPORT_TYPE_CLIPBOARD = 'clipboard';
let ClipboardService = class ClipboardService extends core_1.BeanStub {
var CellClearType;
(function (CellClearType) {
CellClearType[CellClearType["CellRange"] = 0] = "CellRange";
CellClearType[CellClearType["SelectedRows"] = 1] = "SelectedRows";
CellClearType[CellClearType["FocusedCell"] = 2] = "FocusedCell";
})(CellClearType || (CellClearType = {}));
;
let ClipboardService = ClipboardService_1 = class ClipboardService extends core_1.BeanStub {
constructor() {

@@ -104,3 +111,3 @@ super(...arguments);

}
let parsedData = csv_1.stringToArray(data, this.getClipboardDelimiter());
let parsedData = ClipboardService_1.stringToArray(data, this.getClipboardDelimiter());
const userFunc = this.gridOptionsService.getCallback('processDataFromClipboard');

@@ -128,6 +135,73 @@ if (userFunc) {

}
// This will parse a delimited string into an array of arrays.
static stringToArray(strData, delimiter = ',') {
const data = [];
const isNewline = (char) => char === '\r' || char === '\n';
let insideQuotedField = false;
if (strData === '') {
return [['']];
}
// iterate over each character, keep track of current row and column (of the returned array)
for (let row = 0, column = 0, position = 0; position < strData.length; position++) {
const previousChar = strData[position - 1];
const currentChar = strData[position];
const nextChar = strData[position + 1];
const ensureDataExists = () => {
if (!data[row]) {
// create row if it doesn't exist
data[row] = [];
}
if (!data[row][column]) {
// create column if it doesn't exist
data[row][column] = '';
}
};
ensureDataExists();
if (currentChar === '"') {
if (insideQuotedField) {
if (nextChar === '"') {
// unescape double quote
data[row][column] += '"';
position++;
}
else {
// exit quoted field
insideQuotedField = false;
}
continue;
}
else if (previousChar === undefined || previousChar === delimiter || isNewline(previousChar)) {
// enter quoted field
insideQuotedField = true;
continue;
}
}
if (!insideQuotedField) {
if (currentChar === delimiter) {
// move to next column
column++;
ensureDataExists();
continue;
}
else if (isNewline(currentChar)) {
// move to next row
column = 0;
row++;
ensureDataExists();
if (currentChar === '\r' && nextChar === '\n') {
// skip over second newline character if it exists
position++;
}
continue;
}
}
// add current character to current column
data[row][column] += currentChar;
}
return data;
}
// common code to paste operations, e.g. paste to cell, paste to range, and copy range down
doPasteOperation(pasteOperationFunc) {
const api = this.gridOptionsService.get('api');
const columnApi = this.gridOptionsService.get('columnApi');
const api = this.gridOptionsService.api;
const columnApi = this.gridOptionsService.columnApi;
const source = 'clipboard';

@@ -197,3 +271,4 @@ this.eventService.dispatchEvent({

}
const cellId = this.cellPositionUtils.createIdFromValues(currentRow.rowIndex, column, currentRow.rowPinned);
const { rowIndex, rowPinned } = currentRow;
const cellId = this.cellPositionUtils.createIdFromValues({ rowIndex, column, rowPinned });
cellsToFlash[cellId] = true;

@@ -265,3 +340,4 @@ });

}
const cellId = this.cellPositionUtils.createIdFromValues(currentRow.rowIndex, column, currentRow.rowPinned);
const { rowIndex, rowPinned } = currentRow;
const cellId = this.cellPositionUtils.createIdFromValues({ rowIndex, column, rowPinned });
cellsToFlash[cellId] = true;

@@ -346,3 +422,4 @@ });

rowNode.setDataValue(column, processedValue, SOURCE_PASTE);
const cellId = this.cellPositionUtils.createIdFromValues(rowNode.rowIndex, column, rowNode.rowPinned);
const { rowIndex, rowPinned } = rowNode;
const cellId = this.cellPositionUtils.createIdFromValues({ rowIndex: rowIndex, column, rowPinned });
cellsToFlash[cellId] = true;

@@ -354,2 +431,8 @@ if (changedPath) {

copyToClipboard(params = {}) {
this.copyOrCutToClipboard(params);
}
cutToClipboard(params = {}) {
this.copyOrCutToClipboard(params, true);
}
copyOrCutToClipboard(params, cut) {
let { includeHeaders, includeGroupHeaders } = params;

@@ -366,13 +449,55 @@ this.logger.log(`copyToClipboard: includeHeaders = ${includeHeaders}`);

const shouldCopyRows = !this.gridOptionsService.is('suppressCopyRowsToClipboard');
let cellClearType = null;
// Copy priority is Range > Row > Focus
if (this.rangeService && !this.rangeService.isEmpty() && !this.shouldSkipSingleCellRange()) {
this.copySelectedRangeToClipboard(copyParams);
cellClearType = CellClearType.CellRange;
}
else if (shouldCopyRows && !this.selectionService.isEmpty()) {
this.copySelectedRowsToClipboard(copyParams);
cellClearType = CellClearType.SelectedRows;
}
else if (this.focusService.isAnyCellFocused()) {
this.copyFocusedCellToClipboard(copyParams);
cellClearType = CellClearType.FocusedCell;
}
if (cut && cellClearType !== null) {
this.clearCellsAfterCopy(cellClearType);
}
}
clearCellsAfterCopy(type) {
this.eventService.dispatchEvent({ type: core_1.Events.EVENT_KEY_SHORTCUT_CHANGED_CELL_START });
if (type === CellClearType.CellRange) {
this.rangeService.clearCellRangeCellValues(undefined, 'clipboardService');
}
else if (type === CellClearType.SelectedRows) {
this.clearSelectedRows();
}
else {
const focusedCell = this.focusService.getFocusedCell();
if (focusedCell == null) {
return;
}
const rowNode = this.rowPositionUtils.getRowNode(focusedCell);
if (rowNode) {
this.clearCellValue(rowNode, focusedCell.column);
}
}
this.eventService.dispatchEvent({ type: core_1.Events.EVENT_KEY_SHORTCUT_CHANGED_CELL_END });
}
clearSelectedRows() {
const selected = this.selectionService.getSelectedNodes();
const columns = this.columnModel.getAllDisplayedColumns();
for (const row of selected) {
for (const col of columns) {
this.clearCellValue(row, col);
}
}
}
clearCellValue(rowNode, column) {
if (!column.isCellEditable(rowNode)) {
return;
}
rowNode.setDataValue(column, null, 'clipboardService');
}
shouldSkipSingleCellRange() {

@@ -480,3 +605,4 @@ return this.gridOptionsService.is('suppressCopySingleCellRanges') && !this.rangeService.isMoreThanOneCell();

range.columns.forEach(column => {
const cellId = this.cellPositionUtils.createIdFromValues(node.rowIndex, column, node.rowPinned);
const { rowIndex, rowPinned } = node;
const cellId = this.cellPositionUtils.createIdFromValues({ rowIndex, column, rowPinned });
cellsToFlash[cellId] = true;

@@ -709,5 +835,5 @@ });

], ClipboardService.prototype, "init", null);
ClipboardService = __decorate([
ClipboardService = ClipboardService_1 = __decorate([
core_1.Bean('clipboardService')
], ClipboardService);
exports.ClipboardService = ClipboardService;

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

export declare const VERSION = "29.0.0";
export declare const VERSION = "29.1.0";

@@ -5,2 +5,2 @@ "use strict";

// DO NOT UPDATE MANUALLY: Generated from script during build time
exports.VERSION = '29.0.0';
exports.VERSION = '29.1.0';
/**
* @ag-grid-enterprise/clipboard - Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue * @version v29.0.0
* @ag-grid-enterprise/clipboard - Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue * @version v29.1.0
* @link https://www.ag-grid.com/

@@ -14,82 +14,2 @@ * @license Commercial

// Based on https://stackoverflow.com/a/14991797
// This will parse a delimited string into an array of arrays.
function stringToArray(strData, delimiter) {
if (delimiter === void 0) { delimiter = ','; }
var data = [];
var isNewline = function (char) { return char === '\r' || char === '\n'; };
var insideQuotedField = false;
if (strData === '') {
return [['']];
}
var _loop_1 = function (row, column, position) {
var previousChar = strData[position - 1];
var currentChar = strData[position];
var nextChar = strData[position + 1];
var ensureDataExists = function () {
if (!data[row]) {
// create row if it doesn't exist
data[row] = [];
}
if (!data[row][column]) {
// create column if it doesn't exist
data[row][column] = '';
}
};
ensureDataExists();
if (currentChar === '"') {
if (insideQuotedField) {
if (nextChar === '"') {
// unescape double quote
data[row][column] += '"';
position++;
}
else {
// exit quoted field
insideQuotedField = false;
}
return out_row_1 = row, out_column_1 = column, out_position_1 = position, "continue";
}
else if (previousChar === undefined || previousChar === delimiter || isNewline(previousChar)) {
// enter quoted field
insideQuotedField = true;
return out_row_1 = row, out_column_1 = column, out_position_1 = position, "continue";
}
}
if (!insideQuotedField) {
if (currentChar === delimiter) {
// move to next column
column++;
ensureDataExists();
return out_row_1 = row, out_column_1 = column, out_position_1 = position, "continue";
}
else if (isNewline(currentChar)) {
// move to next row
column = 0;
row++;
ensureDataExists();
if (currentChar === '\r' && nextChar === '\n') {
// skip over second newline character if it exists
position++;
}
return out_row_1 = row, out_column_1 = column, out_position_1 = position, "continue";
}
}
// add current character to current column
data[row][column] += currentChar;
out_row_1 = row;
out_column_1 = column;
out_position_1 = position;
};
var out_row_1, out_column_1, out_position_1;
// iterate over each character, keep track of current row and column (of the returned array)
for (var row = 0, column = 0, position = 0; position < strData.length; position++) {
_loop_1(row, column, position);
row = out_row_1;
column = out_column_1;
position = out_position_1;
}
return data;
}
var __extends = (undefined && undefined.__extends) || (function () {

@@ -114,2 +34,13 @@ var extendStatics = function (d, b) {

};
var __values = (undefined && undefined.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
// Matches value in changeDetectionService

@@ -119,2 +50,8 @@ var SOURCE_PASTE = 'paste';

var EXPORT_TYPE_CLIPBOARD = 'clipboard';
var CellClearType;
(function (CellClearType) {
CellClearType[CellClearType["CellRange"] = 0] = "CellRange";
CellClearType[CellClearType["SelectedRows"] = 1] = "SelectedRows";
CellClearType[CellClearType["FocusedCell"] = 2] = "FocusedCell";
})(CellClearType || (CellClearType = {}));
var ClipboardService = /** @class */ (function (_super) {

@@ -128,2 +65,3 @@ __extends(ClipboardService, _super);

}
ClipboardService_1 = ClipboardService;
ClipboardService.prototype.init = function () {

@@ -213,3 +151,3 @@ var _this = this;

}
var parsedData = stringToArray(data, this.getClipboardDelimiter());
var parsedData = ClipboardService_1.stringToArray(data, this.getClipboardDelimiter());
var userFunc = this.gridOptionsService.getCallback('processDataFromClipboard');

@@ -237,6 +175,84 @@ if (userFunc) {

};
// This will parse a delimited string into an array of arrays.
ClipboardService.stringToArray = function (strData, delimiter) {
if (delimiter === void 0) { delimiter = ','; }
var data = [];
var isNewline = function (char) { return char === '\r' || char === '\n'; };
var insideQuotedField = false;
if (strData === '') {
return [['']];
}
var _loop_1 = function (row, column, position) {
var previousChar = strData[position - 1];
var currentChar = strData[position];
var nextChar = strData[position + 1];
var ensureDataExists = function () {
if (!data[row]) {
// create row if it doesn't exist
data[row] = [];
}
if (!data[row][column]) {
// create column if it doesn't exist
data[row][column] = '';
}
};
ensureDataExists();
if (currentChar === '"') {
if (insideQuotedField) {
if (nextChar === '"') {
// unescape double quote
data[row][column] += '"';
position++;
}
else {
// exit quoted field
insideQuotedField = false;
}
return out_row_1 = row, out_column_1 = column, out_position_1 = position, "continue";
}
else if (previousChar === undefined || previousChar === delimiter || isNewline(previousChar)) {
// enter quoted field
insideQuotedField = true;
return out_row_1 = row, out_column_1 = column, out_position_1 = position, "continue";
}
}
if (!insideQuotedField) {
if (currentChar === delimiter) {
// move to next column
column++;
ensureDataExists();
return out_row_1 = row, out_column_1 = column, out_position_1 = position, "continue";
}
else if (isNewline(currentChar)) {
// move to next row
column = 0;
row++;
ensureDataExists();
if (currentChar === '\r' && nextChar === '\n') {
// skip over second newline character if it exists
position++;
}
return out_row_1 = row, out_column_1 = column, out_position_1 = position, "continue";
}
}
// add current character to current column
data[row][column] += currentChar;
out_row_1 = row;
out_column_1 = column;
out_position_1 = position;
};
var out_row_1, out_column_1, out_position_1;
// iterate over each character, keep track of current row and column (of the returned array)
for (var row = 0, column = 0, position = 0; position < strData.length; position++) {
_loop_1(row, column, position);
row = out_row_1;
column = out_column_1;
position = out_position_1;
}
return data;
};
// common code to paste operations, e.g. paste to cell, paste to range, and copy range down
ClipboardService.prototype.doPasteOperation = function (pasteOperationFunc) {
var api = this.gridOptionsService.get('api');
var columnApi = this.gridOptionsService.get('columnApi');
var api = this.gridOptionsService.api;
var columnApi = this.gridOptionsService.columnApi;
var source = 'clipboard';

@@ -307,3 +323,4 @@ this.eventService.dispatchEvent({

}
var cellId = _this.cellPositionUtils.createIdFromValues(currentRow.rowIndex, column, currentRow.rowPinned);
var rowIndex = currentRow.rowIndex, rowPinned = currentRow.rowPinned;
var cellId = _this.cellPositionUtils.createIdFromValues({ rowIndex: rowIndex, column: column, rowPinned: rowPinned });
cellsToFlash[cellId] = true;

@@ -379,3 +396,4 @@ });

}
var cellId = _this.cellPositionUtils.createIdFromValues(currentRow.rowIndex, column, currentRow.rowPinned);
var rowIndex = currentRow.rowIndex, rowPinned = currentRow.rowPinned;
var cellId = _this.cellPositionUtils.createIdFromValues({ rowIndex: rowIndex, column: column, rowPinned: rowPinned });
cellsToFlash[cellId] = true;

@@ -464,3 +482,4 @@ });

rowNode.setDataValue(column, processedValue, SOURCE_PASTE);
var cellId = this.cellPositionUtils.createIdFromValues(rowNode.rowIndex, column, rowNode.rowPinned);
var rowIndex = rowNode.rowIndex, rowPinned = rowNode.rowPinned;
var cellId = this.cellPositionUtils.createIdFromValues({ rowIndex: rowIndex, column: column, rowPinned: rowPinned });
cellsToFlash[cellId] = true;

@@ -473,2 +492,9 @@ if (changedPath) {

if (params === void 0) { params = {}; }
this.copyOrCutToClipboard(params);
};
ClipboardService.prototype.cutToClipboard = function (params) {
if (params === void 0) { params = {}; }
this.copyOrCutToClipboard(params, true);
};
ClipboardService.prototype.copyOrCutToClipboard = function (params, cut) {
var includeHeaders = params.includeHeaders, includeGroupHeaders = params.includeGroupHeaders;

@@ -485,13 +511,76 @@ this.logger.log("copyToClipboard: includeHeaders = " + includeHeaders);

var shouldCopyRows = !this.gridOptionsService.is('suppressCopyRowsToClipboard');
var cellClearType = null;
// Copy priority is Range > Row > Focus
if (this.rangeService && !this.rangeService.isEmpty() && !this.shouldSkipSingleCellRange()) {
this.copySelectedRangeToClipboard(copyParams);
cellClearType = CellClearType.CellRange;
}
else if (shouldCopyRows && !this.selectionService.isEmpty()) {
this.copySelectedRowsToClipboard(copyParams);
cellClearType = CellClearType.SelectedRows;
}
else if (this.focusService.isAnyCellFocused()) {
this.copyFocusedCellToClipboard(copyParams);
cellClearType = CellClearType.FocusedCell;
}
if (cut && cellClearType !== null) {
this.clearCellsAfterCopy(cellClearType);
}
};
ClipboardService.prototype.clearCellsAfterCopy = function (type) {
this.eventService.dispatchEvent({ type: core.Events.EVENT_KEY_SHORTCUT_CHANGED_CELL_START });
if (type === CellClearType.CellRange) {
this.rangeService.clearCellRangeCellValues(undefined, 'clipboardService');
}
else if (type === CellClearType.SelectedRows) {
this.clearSelectedRows();
}
else {
var focusedCell = this.focusService.getFocusedCell();
if (focusedCell == null) {
return;
}
var rowNode = this.rowPositionUtils.getRowNode(focusedCell);
if (rowNode) {
this.clearCellValue(rowNode, focusedCell.column);
}
}
this.eventService.dispatchEvent({ type: core.Events.EVENT_KEY_SHORTCUT_CHANGED_CELL_END });
};
ClipboardService.prototype.clearSelectedRows = function () {
var e_1, _a, e_2, _b;
var selected = this.selectionService.getSelectedNodes();
var columns = this.columnModel.getAllDisplayedColumns();
try {
for (var selected_1 = __values(selected), selected_1_1 = selected_1.next(); !selected_1_1.done; selected_1_1 = selected_1.next()) {
var row = selected_1_1.value;
try {
for (var columns_1 = (e_2 = void 0, __values(columns)), columns_1_1 = columns_1.next(); !columns_1_1.done; columns_1_1 = columns_1.next()) {
var col = columns_1_1.value;
this.clearCellValue(row, col);
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (columns_1_1 && !columns_1_1.done && (_b = columns_1.return)) _b.call(columns_1);
}
finally { if (e_2) throw e_2.error; }
}
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (selected_1_1 && !selected_1_1.done && (_a = selected_1.return)) _a.call(selected_1);
}
finally { if (e_1) throw e_1.error; }
}
};
ClipboardService.prototype.clearCellValue = function (rowNode, column) {
if (!column.isCellEditable(rowNode)) {
return;
}
rowNode.setDataValue(column, null, 'clipboardService');
};
ClipboardService.prototype.shouldSkipSingleCellRange = function () {

@@ -604,3 +693,4 @@ return this.gridOptionsService.is('suppressCopySingleCellRanges') && !this.rangeService.isMoreThanOneCell();

range.columns.forEach(function (column) {
var cellId = _this.cellPositionUtils.createIdFromValues(node.rowIndex, column, node.rowPinned);
var _a = node, rowIndex = _a.rowIndex, rowPinned = _a.rowPinned;
var cellId = _this.cellPositionUtils.createIdFromValues({ rowIndex: rowIndex, column: column, rowPinned: rowPinned });
cellsToFlash[cellId] = true;

@@ -797,2 +887,3 @@ });

};
var ClipboardService_1;
__decorate([

@@ -840,3 +931,3 @@ core.Autowired('csvCreator')

], ClipboardService.prototype, "init", null);
ClipboardService = __decorate([
ClipboardService = ClipboardService_1 = __decorate([
core.Bean('clipboardService')

@@ -848,3 +939,3 @@ ], ClipboardService);

// DO NOT UPDATE MANUALLY: Generated from script during build time
var VERSION = '29.0.0';
var VERSION = '29.1.0';

@@ -851,0 +942,0 @@ var ClipboardModule = {

/**
* @ag-grid-enterprise/clipboard - Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue * @version v29.0.0
* @ag-grid-enterprise/clipboard - Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue * @version v29.1.0
* @link https://www.ag-grid.com/

@@ -7,6 +7,6 @@ * @license Commercial

/**
* @ag-grid-enterprise/clipboard - Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue * @version v29.0.0
* @ag-grid-enterprise/clipboard - Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue * @version v29.1.0
* @link https://www.ag-grid.com/
* @license Commercial
*/
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@ag-grid-community/core"),t=require("@ag-grid-enterprise/core"),o=require("@ag-grid-community/csv-export");var r,i=(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])})(e,t)},function(e,t){function o(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}),n=function(e,t,o,r){var i,n=arguments.length,a=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,o,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(n<3?i(a):n>3?i(t,o,a):i(t,o))||a);return n>3&&a&&Object.defineProperty(t,o,a),a},a=function(t){function o(){var e=null!==t&&t.apply(this,arguments)||this;return e.lastPasteOperationTime=0,e.navigatorApiFailed=!1,e}return i(o,t),o.prototype.init=function(){var e=this;this.logger=this.loggerFactory.create("ClipboardService"),"clientSide"===this.rowModel.getType()&&(this.clientSideRowModel=this.rowModel),this.ctrlsService.whenReady((function(t){e.gridCtrl=t.gridCtrl}))},o.prototype.pasteFromClipboard=function(){var t=this;this.logger.log("pasteFromClipboard"),!this.gridOptionsService.is("suppressClipboardApi")&&!this.navigatorApiFailed&&navigator.clipboard&&navigator.clipboard.readText?navigator.clipboard.readText().then(this.processClipboardData.bind(this)).catch((function(o){e._.doOnce((function(){console.warn(o),console.warn("AG Grid: Unable to use the Clipboard API (navigator.clipboard.readText()). The reason why it could not be used has been logged in the previous line. For this reason the grid has defaulted to using a workaround which doesn't perform as well. Either fix why Clipboard API is blocked, OR stop this message from appearing by setting grid property suppressClipboardApi=true (which will default the grid to using the workaround rather than the API")}),"clipboardApiError"),t.navigatorApiFailed=!0,t.pasteFromClipboardLegacy()})):this.pasteFromClipboardLegacy()},o.prototype.pasteFromClipboardLegacy=function(){var e=this,t=!1,o=function(o){var r=(new Date).getTime();r-e.lastPasteOperationTime<50&&(t=!0,o.preventDefault()),e.lastPasteOperationTime=r};this.executeOnTempElement((function(e){e.addEventListener("paste",o),e.focus({preventScroll:!0})}),(function(r){var i=r.value;t?e.refocusLastFocusedCell():e.processClipboardData(i),r.removeEventListener("paste",o)}))},o.prototype.refocusLastFocusedCell=function(){var e=this.focusService.getFocusedCell();e&&this.focusService.setFocusedCell({rowIndex:e.rowIndex,column:e.column,rowPinned:e.rowPinned,forceBrowserFocus:!0})},o.prototype.getClipboardDelimiter=function(){var t=this.gridOptionsService.get("clipboardDelimiter");return e._.exists(t)?t:"\t"},o.prototype.processClipboardData=function(e){var t=this;if(null!=e){var o=function(e,t){void 0===t&&(t=",");var o=[],r=function(e){return"\r"===e||"\n"===e},i=!1;if(""===e)return[[""]];for(var n,a,s,l=function(l,c,p){var d=e[p-1],u=e[p],h=e[p+1],g=function(){o[l]||(o[l]=[]),o[l][c]||(o[l][c]="")};if(g(),'"'===u){if(i)return'"'===h?(o[l][c]+='"',p++):i=!1,n=l,a=c,s=p,"continue";if(void 0===d||d===t||r(d))return i=!0,n=l,a=c,s=p,"continue"}if(!i){if(u===t)return c++,g(),n=l,a=c,s=p,"continue";if(r(u))return c=0,l++,g(),"\r"===u&&"\n"===h&&p++,n=l,a=c,s=p,"continue"}o[l][c]+=u,n=l,a=c,s=p},c=0,p=0,d=0;d<e.length;d++)l(c,p,d),c=n,p=a,d=s;return o}(e,this.getClipboardDelimiter()),r=this.gridOptionsService.getCallback("processDataFromClipboard");if(r&&(o=r({data:o})),null!=o){this.gridOptionsService.is("suppressLastEmptyLineOnPaste")&&this.removeLastLineIfBlank(o);this.doPasteOperation((function(e,r,i,n){t.rangeService&&t.rangeService.isMoreThanOneCell()&&!t.hasOnlyOneValueToPaste(o)?t.pasteIntoActiveRange(o,e,r,n):t.pasteStartingFromFocusedCell(o,e,r,i,n)}))}}},o.prototype.doPasteOperation=function(t){var o,r=this.gridOptionsService.get("api"),i=this.gridOptionsService.get("columnApi");if(this.eventService.dispatchEvent({type:e.Events.EVENT_PASTE_START,api:r,columnApi:i,source:"clipboard"}),this.clientSideRowModel){var n=this.gridOptionsService.is("aggregateOnlyChangedColumns");o=new e.ChangedPath(n,this.clientSideRowModel.getRootNode())}var a={},s=[];t(a,s,this.focusService.getFocusedCell(),o),o&&this.clientSideRowModel.doAggregate(o),this.rowRenderer.refreshCells(),this.dispatchFlashCells(a),this.fireRowChanged(s),this.refocusLastFocusedCell();var l={type:e.Events.EVENT_PASTE_END,source:"clipboard"};this.eventService.dispatchEvent(l)},o.prototype.pasteIntoActiveRange=function(e,t,o,r){var i=this,n=this.getRangeSize()%e.length!=0,a=0,s=0;this.iterateActiveRanges(!1,(function(l,c,p,d){if(d-a>=e.length){if(n)return;a+=s,s=0}var u=e[d-a];o.push(c);var h=i.gridOptionsService.getCallback("processCellFromClipboard");p.forEach((function(e,o){if(e.isCellEditable(c)&&!e.isSuppressPaste(c)){o>=u.length&&(o%=u.length);var n=i.processCell(c,e,u[o],"dragCopy",h);c.setDataValue(e,n,"paste"),r&&r.addParentNode(c.parent,[e]);var a=i.cellPositionUtils.createIdFromValues(l.rowIndex,e,l.rowPinned);t[a]=!0}})),s++}))},o.prototype.pasteStartingFromFocusedCell=function(e,t,o,r,i){if(r){var n={rowIndex:r.rowIndex,rowPinned:r.rowPinned},a=this.columnModel.getDisplayedColumnsStartingAt(r.column);this.isPasteSingleValueIntoRange(e)?this.pasteSingleValueIntoRange(e,o,t,i):this.pasteMultipleValues(e,n,o,a,t,"clipboard",i)}},o.prototype.isPasteSingleValueIntoRange=function(e){return this.hasOnlyOneValueToPaste(e)&&null!=this.rangeService&&!this.rangeService.isEmpty()},o.prototype.pasteSingleValueIntoRange=function(e,t,o,r){var i=this,n=e[0][0];this.iterateActiveRanges(!1,(function(e,a,s){t.push(a),s.forEach((function(e){return i.updateCellValue(a,e,n,o,"clipboard",r)}))}))},o.prototype.hasOnlyOneValueToPaste=function(e){return 1===e.length&&1===e[0].length},o.prototype.copyRangeDown=function(){var e=this;if(this.rangeService&&!this.rangeService.isEmpty()){var t=[];this.doPasteOperation((function(o,r,i,n){var a=e.gridOptionsService.getCallback("processCellForClipboard"),s=e.gridOptionsService.getCallback("processCellFromClipboard");e.iterateActiveRanges(!0,(function(i,l,c){t.length?(r.push(l),c.forEach((function(r,a){if(r.isCellEditable(l)&&!r.isSuppressPaste(l)){var c=e.processCell(l,r,t[a],"dragCopy",s);l.setDataValue(r,c,"paste"),n&&n.addParentNode(l.parent,[r]);var p=e.cellPositionUtils.createIdFromValues(i.rowIndex,r,i.rowPinned);o[p]=!0}}))):c.forEach((function(o){var r=e.processCell(l,o,e.valueService.getValue(o,l),"dragCopy",a);t.push(r)}))}))}))}},o.prototype.removeLastLineIfBlank=function(t){var o=e._.last(t);if(o&&1===o.length&&""===o[0]){if(1===t.length)return;e._.removeFromArray(t,o)}},o.prototype.fireRowChanged=function(t){var o=this;"fullRow"===this.gridOptionsService.get("editType")&&t.forEach((function(t){var r={type:e.Events.EVENT_ROW_VALUE_CHANGED,node:t,data:t.data,rowIndex:t.rowIndex,rowPinned:t.rowPinned};o.eventService.dispatchEvent(r)}))},o.prototype.pasteMultipleValues=function(e,t,o,r,i,n,a){var s=this,l=t,c=null!=this.clientSideRowModel&&!this.gridOptionsService.isTreeData();e.forEach((function(e){var t=function(){for(;;){if(!l)return null;var e=s.rowPositionUtils.getRowNode(l);if(l=s.cellNavigationService.getRowBelow({rowPinned:l.rowPinned,rowIndex:l.rowIndex}),null==e)return null;if(!(e.detail||e.footer||c&&e.group))return e}}();t&&(e.forEach((function(e,o){return s.updateCellValue(t,r[o],e,i,n,a)})),o.push(t))}))},o.prototype.updateCellValue=function(e,t,o,r,i,n){if(e&&t&&t.isCellEditable(e)&&!t.isSuppressPaste(e)){var a=this.processCell(e,t,o,i,this.gridOptionsService.getCallback("processCellFromClipboard"));e.setDataValue(t,a,"paste"),r[this.cellPositionUtils.createIdFromValues(e.rowIndex,t,e.rowPinned)]=!0,n&&n.addParentNode(e.parent,[t])}},o.prototype.copyToClipboard=function(e){void 0===e&&(e={});var t=e.includeHeaders,o=e.includeGroupHeaders;this.logger.log("copyToClipboard: includeHeaders = "+t),null==t&&(t=this.gridOptionsService.is("copyHeadersToClipboard")),null==o&&(o=this.gridOptionsService.is("copyGroupHeadersToClipboard"));var r={includeHeaders:t,includeGroupHeaders:o},i=!this.gridOptionsService.is("suppressCopyRowsToClipboard");!this.rangeService||this.rangeService.isEmpty()||this.shouldSkipSingleCellRange()?i&&!this.selectionService.isEmpty()?this.copySelectedRowsToClipboard(r):this.focusService.isAnyCellFocused()&&this.copyFocusedCellToClipboard(r):this.copySelectedRangeToClipboard(r)},o.prototype.shouldSkipSingleCellRange=function(){return this.gridOptionsService.is("suppressCopySingleCellRanges")&&!this.rangeService.isMoreThanOneCell()},o.prototype.iterateActiveRanges=function(e,t,o){var r=this;if(this.rangeService&&!this.rangeService.isEmpty()){var i=this.rangeService.getCellRanges();e?this.iterateActiveRange(i[0],t,o,!0):i.forEach((function(e,n){return r.iterateActiveRange(e,t,o,n===i.length-1)}))}},o.prototype.iterateActiveRange=function(e,t,o,r){if(this.rangeService){var i=this.rangeService.getRangeStartRow(e),n=this.rangeService.getRangeEndRow(e);o&&e.columns&&o(e.columns);for(var a=0,s=!1;!s&&null!=i;){var l=this.rowPositionUtils.getRowNode(i);s=this.rowPositionUtils.sameRow(i,n),t(i,l,e.columns,a++,s&&r),i=this.cellNavigationService.getRowBelow(i)}}},o.prototype.copySelectedRangeToClipboard=function(e){if(void 0===e&&(e={}),this.rangeService&&!this.rangeService.isEmpty()){var t=this.rangeService.areAllRangesAbleToMerge()?this.buildDataFromMergedRanges(e):this.buildDataFromRanges(e),o=t.data,r=t.cellsToFlash;this.copyDataToClipboard(o),this.dispatchFlashCells(r)}},o.prototype.buildDataFromMergedRanges=function(e){var t=this,o=new Set,r=this.rangeService.getCellRanges(),i=new Map,n=[],a={};r.forEach((function(e){e.columns.forEach((function(e){return o.add(e)}));var r=t.getRangeRowPositionsAndCellsToFlash(e),s=r.rowPositions,l=r.cellsToFlash;s.forEach((function(e){var t=e.rowIndex+"-"+(e.rowPinned||"null");i.get(t)||(i.set(t,!0),n.push(e))})),Object.assign(a,l)}));var s=this.columnModel.getAllDisplayedColumns(),l=Array.from(o);return l.sort((function(e,t){return s.indexOf(e)-s.indexOf(t)})),{data:this.buildExportParams({columns:l,rowPositions:n,includeHeaders:e.includeHeaders,includeGroupHeaders:e.includeGroupHeaders}),cellsToFlash:a}},o.prototype.buildDataFromRanges=function(e){var t=this,o=this.rangeService.getCellRanges(),r=[],i={};return o.forEach((function(o){var n=t.getRangeRowPositionsAndCellsToFlash(o),a=n.rowPositions,s=n.cellsToFlash;Object.assign(i,s),r.push(t.buildExportParams({columns:o.columns,rowPositions:a,includeHeaders:e.includeHeaders,includeGroupHeaders:e.includeGroupHeaders}))})),{data:r.join("\n"),cellsToFlash:i}},o.prototype.getRangeRowPositionsAndCellsToFlash=function(e){for(var t=this,o=[],r={},i=this.rangeService.getRangeStartRow(e),n=this.rangeService.getRangeEndRow(e),a=i;a&&(o.push(a),e.columns.forEach((function(e){var o=t.cellPositionUtils.createIdFromValues(a.rowIndex,e,a.rowPinned);r[o]=!0})),!this.rowPositionUtils.sameRow(a,n));)a=this.cellNavigationService.getRowBelow(a);return{rowPositions:o,cellsToFlash:r}},o.prototype.copyFocusedCellToClipboard=function(e){var t;void 0===e&&(e={});var o=this.focusService.getFocusedCell();if(null!=o){var r=this.cellPositionUtils.createId(o),i={rowPinned:o.rowPinned,rowIndex:o.rowIndex},n=o.column,a=this.buildExportParams({columns:[n],rowPositions:[i],includeHeaders:e.includeHeaders,includeGroupHeaders:e.includeGroupHeaders});this.copyDataToClipboard(a),this.dispatchFlashCells(((t={})[r]=!0,t))}},o.prototype.copySelectedRowsToClipboard=function(e){void 0===e&&(e={});var t=e.columnKeys,o=e.includeHeaders,r=e.includeGroupHeaders,i=this.buildExportParams({columns:t,includeHeaders:o,includeGroupHeaders:r});this.copyDataToClipboard(i)},o.prototype.buildExportParams=function(e){var t=this,o=e.columns,r=e.rowPositions,i=e.includeHeaders,n=void 0!==i&&i,a=e.includeGroupHeaders,s={columnKeys:o,rowPositions:r,skipColumnHeaders:!n,skipColumnGroupHeaders:!(void 0!==a&&a),suppressQuotes:!0,columnSeparator:this.getClipboardDelimiter(),onlySelected:!r,processCellCallback:this.gridOptionsService.getCallback("processCellForClipboard"),processRowGroupCallback:function(e){return t.processRowGroupCallback(e)},processHeaderCallback:this.gridOptionsService.getCallback("processHeaderForClipboard"),processGroupHeaderCallback:this.gridOptionsService.getCallback("processGroupHeaderForClipboard")};return this.csvCreator.getDataAsCsv(s,!0)},o.prototype.processRowGroupCallback=function(e){var t=e.node,o=t.key,r=null!=o?o:"";if(e.node.footer){var i="";o&&o.length&&(i=" "+o),r="Total"+i}var n=this.gridOptionsService.getCallback("processCellForClipboard");if(n){var a=t.rowGroupColumn;return!a&&t.footer&&-1===t.level&&(a=this.columnModel.getRowGroupColumns()[0]),n({value:r,node:t,column:a,type:"clipboard"})}return r},o.prototype.dispatchFlashCells=function(t){var o=this;window.setTimeout((function(){var r={type:e.Events.EVENT_FLASH_CELLS,cells:t};o.eventService.dispatchEvent(r)}),0)},o.prototype.processCell=function(e,t,o,r,i){return i?i({column:t,node:e,value:o,type:r}):o},o.prototype.copyDataToClipboard=function(t){var o=this,r=this.gridOptionsService.getCallback("sendToClipboard");r?r({data:t}):!this.gridOptionsService.is("suppressClipboardApi")&&navigator.clipboard?navigator.clipboard.writeText(t).catch((function(r){e._.doOnce((function(){console.warn(r),console.warn("AG Grid: Unable to use the Clipboard API (navigator.clipboard.writeText()). The reason why it could not be used has been logged in the previous line. For this reason the grid has defaulted to using a workaround which doesn't perform as well. Either fix why Clipboard API is blocked, OR stop this message from appearing by setting grid property suppressClipboardApi=true (which will default the grid to using the workaround rather than the API.")}),"clipboardApiError"),o.copyDataToClipboardLegacy(t)})):this.copyDataToClipboardLegacy(t)},o.prototype.copyDataToClipboardLegacy=function(e){var t=this;this.executeOnTempElement((function(o){var r=t.gridOptionsService.getDocument(),i=r.activeElement;o.value=e||" ",o.select(),o.focus({preventScroll:!0}),r.execCommand("copy")||console.warn("AG Grid: Browser did not allow document.execCommand('copy'). Ensure api.copySelectedRowsToClipboard() is invoked via a user event, i.e. button click, otherwise the browser will prevent it for security reasons."),null!=i&&null!=i.focus&&i.focus({preventScroll:!0})}))},o.prototype.executeOnTempElement=function(e,t){var o=this.gridOptionsService.getDocument(),r=o.createElement("textarea");r.style.width="1px",r.style.height="1px",r.style.top=o.documentElement.scrollTop+"px",r.style.left=o.documentElement.scrollLeft+"px",r.style.position="absolute",r.style.opacity="0";var i=this.gridCtrl.getGui();i.appendChild(r);try{e(r)}catch(e){console.warn("AG Grid: Browser does not support document.execCommand('copy') for clipboard operations")}t?window.setTimeout((function(){t(r),i.removeChild(r)}),100):i.removeChild(r)},o.prototype.getRangeSize=function(){var e=this.rangeService.getCellRanges(),t=0,o=0;return e.length>0&&(t=this.rangeService.getRangeStartRow(e[0]).rowIndex,o=this.rangeService.getRangeEndRow(e[0]).rowIndex),t-o+1},n([e.Autowired("csvCreator")],o.prototype,"csvCreator",void 0),n([e.Autowired("loggerFactory")],o.prototype,"loggerFactory",void 0),n([e.Autowired("selectionService")],o.prototype,"selectionService",void 0),n([e.Optional("rangeService")],o.prototype,"rangeService",void 0),n([e.Autowired("rowModel")],o.prototype,"rowModel",void 0),n([e.Autowired("ctrlsService")],o.prototype,"ctrlsService",void 0),n([e.Autowired("valueService")],o.prototype,"valueService",void 0),n([e.Autowired("focusService")],o.prototype,"focusService",void 0),n([e.Autowired("rowRenderer")],o.prototype,"rowRenderer",void 0),n([e.Autowired("columnModel")],o.prototype,"columnModel",void 0),n([e.Autowired("cellNavigationService")],o.prototype,"cellNavigationService",void 0),n([e.Autowired("cellPositionUtils")],o.prototype,"cellPositionUtils",void 0),n([e.Autowired("rowPositionUtils")],o.prototype,"rowPositionUtils",void 0),n([e.PostConstruct],o.prototype,"init",null),o=n([e.Bean("clipboardService")],o)}(e.BeanStub),s={version:"29.0.0",moduleName:e.ModuleNames.ClipboardModule,beans:[a],dependantModules:[t.EnterpriseCoreModule,o.CsvExportModule]};exports.ClipboardModule=s;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t,o=require("@ag-grid-community/core"),r=require("@ag-grid-enterprise/core"),i=require("@ag-grid-community/csv-export"),n=(e=function(t,o){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])})(t,o)},function(t,o){function r(){this.constructor=t}e(t,o),t.prototype=null===o?Object.create(o):(r.prototype=o.prototype,new r)}),a=function(e,t,o,r){var i,n=arguments.length,a=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,o,r);else for(var l=e.length-1;l>=0;l--)(i=e[l])&&(a=(n<3?i(a):n>3?i(t,o,a):i(t,o))||a);return n>3&&a&&Object.defineProperty(t,o,a),a},l=function(e){var t="function"==typeof Symbol&&Symbol.iterator,o=t&&e[t],r=0;if(o)return o.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};!function(e){e[e.CellRange=0]="CellRange",e[e.SelectedRows=1]="SelectedRows",e[e.FocusedCell=2]="FocusedCell"}(t||(t={}));var s=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.lastPasteOperationTime=0,t.navigatorApiFailed=!1,t}var i;return n(r,e),i=r,r.prototype.init=function(){var e=this;this.logger=this.loggerFactory.create("ClipboardService"),"clientSide"===this.rowModel.getType()&&(this.clientSideRowModel=this.rowModel),this.ctrlsService.whenReady((function(t){e.gridCtrl=t.gridCtrl}))},r.prototype.pasteFromClipboard=function(){var e=this;this.logger.log("pasteFromClipboard"),!this.gridOptionsService.is("suppressClipboardApi")&&!this.navigatorApiFailed&&navigator.clipboard&&navigator.clipboard.readText?navigator.clipboard.readText().then(this.processClipboardData.bind(this)).catch((function(t){o._.doOnce((function(){console.warn(t),console.warn("AG Grid: Unable to use the Clipboard API (navigator.clipboard.readText()). The reason why it could not be used has been logged in the previous line. For this reason the grid has defaulted to using a workaround which doesn't perform as well. Either fix why Clipboard API is blocked, OR stop this message from appearing by setting grid property suppressClipboardApi=true (which will default the grid to using the workaround rather than the API")}),"clipboardApiError"),e.navigatorApiFailed=!0,e.pasteFromClipboardLegacy()})):this.pasteFromClipboardLegacy()},r.prototype.pasteFromClipboardLegacy=function(){var e=this,t=!1,o=function(o){var r=(new Date).getTime();r-e.lastPasteOperationTime<50&&(t=!0,o.preventDefault()),e.lastPasteOperationTime=r};this.executeOnTempElement((function(e){e.addEventListener("paste",o),e.focus({preventScroll:!0})}),(function(r){var i=r.value;t?e.refocusLastFocusedCell():e.processClipboardData(i),r.removeEventListener("paste",o)}))},r.prototype.refocusLastFocusedCell=function(){var e=this.focusService.getFocusedCell();e&&this.focusService.setFocusedCell({rowIndex:e.rowIndex,column:e.column,rowPinned:e.rowPinned,forceBrowserFocus:!0})},r.prototype.getClipboardDelimiter=function(){var e=this.gridOptionsService.get("clipboardDelimiter");return o._.exists(e)?e:"\t"},r.prototype.processClipboardData=function(e){var t=this;if(null!=e){var o=i.stringToArray(e,this.getClipboardDelimiter()),r=this.gridOptionsService.getCallback("processDataFromClipboard");if(r&&(o=r({data:o})),null!=o){this.gridOptionsService.is("suppressLastEmptyLineOnPaste")&&this.removeLastLineIfBlank(o);this.doPasteOperation((function(e,r,i,n){t.rangeService&&t.rangeService.isMoreThanOneCell()&&!t.hasOnlyOneValueToPaste(o)?t.pasteIntoActiveRange(o,e,r,n):t.pasteStartingFromFocusedCell(o,e,r,i,n)}))}}},r.stringToArray=function(e,t){void 0===t&&(t=",");var o=[],r=function(e){return"\r"===e||"\n"===e},i=!1;if(""===e)return[[""]];for(var n,a,l,s=function(s,c,p){var d=e[p-1],u=e[p],h=e[p+1],v=function(){o[s]||(o[s]=[]),o[s][c]||(o[s][c]="")};if(v(),'"'===u){if(i)return'"'===h?(o[s][c]+='"',p++):i=!1,n=s,a=c,l=p,"continue";if(void 0===d||d===t||r(d))return i=!0,n=s,a=c,l=p,"continue"}if(!i){if(u===t)return c++,v(),n=s,a=c,l=p,"continue";if(r(u))return c=0,s++,v(),"\r"===u&&"\n"===h&&p++,n=s,a=c,l=p,"continue"}o[s][c]+=u,n=s,a=c,l=p},c=0,p=0,d=0;d<e.length;d++)s(c,p,d),c=n,p=a,d=l;return o},r.prototype.doPasteOperation=function(e){var t,r=this.gridOptionsService.api,i=this.gridOptionsService.columnApi;if(this.eventService.dispatchEvent({type:o.Events.EVENT_PASTE_START,api:r,columnApi:i,source:"clipboard"}),this.clientSideRowModel){var n=this.gridOptionsService.is("aggregateOnlyChangedColumns");t=new o.ChangedPath(n,this.clientSideRowModel.getRootNode())}var a={},l=[];e(a,l,this.focusService.getFocusedCell(),t),t&&this.clientSideRowModel.doAggregate(t),this.rowRenderer.refreshCells(),this.dispatchFlashCells(a),this.fireRowChanged(l),this.refocusLastFocusedCell();var s={type:o.Events.EVENT_PASTE_END,source:"clipboard"};this.eventService.dispatchEvent(s)},r.prototype.pasteIntoActiveRange=function(e,t,o,r){var i=this,n=this.getRangeSize()%e.length!=0,a=0,l=0;this.iterateActiveRanges(!1,(function(s,c,p,d){if(d-a>=e.length){if(n)return;a+=l,l=0}var u=e[d-a];o.push(c);var h=i.gridOptionsService.getCallback("processCellFromClipboard");p.forEach((function(e,o){if(e.isCellEditable(c)&&!e.isSuppressPaste(c)){o>=u.length&&(o%=u.length);var n=i.processCell(c,e,u[o],"dragCopy",h);c.setDataValue(e,n,"paste"),r&&r.addParentNode(c.parent,[e]);var a=s.rowIndex,l=s.rowPinned,p=i.cellPositionUtils.createIdFromValues({rowIndex:a,column:e,rowPinned:l});t[p]=!0}})),l++}))},r.prototype.pasteStartingFromFocusedCell=function(e,t,o,r,i){if(r){var n={rowIndex:r.rowIndex,rowPinned:r.rowPinned},a=this.columnModel.getDisplayedColumnsStartingAt(r.column);this.isPasteSingleValueIntoRange(e)?this.pasteSingleValueIntoRange(e,o,t,i):this.pasteMultipleValues(e,n,o,a,t,"clipboard",i)}},r.prototype.isPasteSingleValueIntoRange=function(e){return this.hasOnlyOneValueToPaste(e)&&null!=this.rangeService&&!this.rangeService.isEmpty()},r.prototype.pasteSingleValueIntoRange=function(e,t,o,r){var i=this,n=e[0][0];this.iterateActiveRanges(!1,(function(e,a,l){t.push(a),l.forEach((function(e){return i.updateCellValue(a,e,n,o,"clipboard",r)}))}))},r.prototype.hasOnlyOneValueToPaste=function(e){return 1===e.length&&1===e[0].length},r.prototype.copyRangeDown=function(){var e=this;if(this.rangeService&&!this.rangeService.isEmpty()){var t=[];this.doPasteOperation((function(o,r,i,n){var a=e.gridOptionsService.getCallback("processCellForClipboard"),l=e.gridOptionsService.getCallback("processCellFromClipboard");e.iterateActiveRanges(!0,(function(i,s,c){t.length?(r.push(s),c.forEach((function(r,a){if(r.isCellEditable(s)&&!r.isSuppressPaste(s)){var c=e.processCell(s,r,t[a],"dragCopy",l);s.setDataValue(r,c,"paste"),n&&n.addParentNode(s.parent,[r]);var p=i.rowIndex,d=i.rowPinned,u=e.cellPositionUtils.createIdFromValues({rowIndex:p,column:r,rowPinned:d});o[u]=!0}}))):c.forEach((function(o){var r=e.processCell(s,o,e.valueService.getValue(o,s),"dragCopy",a);t.push(r)}))}))}))}},r.prototype.removeLastLineIfBlank=function(e){var t=o._.last(e);if(t&&1===t.length&&""===t[0]){if(1===e.length)return;o._.removeFromArray(e,t)}},r.prototype.fireRowChanged=function(e){var t=this;"fullRow"===this.gridOptionsService.get("editType")&&e.forEach((function(e){var r={type:o.Events.EVENT_ROW_VALUE_CHANGED,node:e,data:e.data,rowIndex:e.rowIndex,rowPinned:e.rowPinned};t.eventService.dispatchEvent(r)}))},r.prototype.pasteMultipleValues=function(e,t,o,r,i,n,a){var l=this,s=t,c=null!=this.clientSideRowModel&&!this.gridOptionsService.isTreeData();e.forEach((function(e){var t=function(){for(;;){if(!s)return null;var e=l.rowPositionUtils.getRowNode(s);if(s=l.cellNavigationService.getRowBelow({rowPinned:s.rowPinned,rowIndex:s.rowIndex}),null==e)return null;if(!(e.detail||e.footer||c&&e.group))return e}}();t&&(e.forEach((function(e,o){return l.updateCellValue(t,r[o],e,i,n,a)})),o.push(t))}))},r.prototype.updateCellValue=function(e,t,o,r,i,n){if(e&&t&&t.isCellEditable(e)&&!t.isSuppressPaste(e)){var a=this.processCell(e,t,o,i,this.gridOptionsService.getCallback("processCellFromClipboard"));e.setDataValue(t,a,"paste");var l=e.rowIndex,s=e.rowPinned;r[this.cellPositionUtils.createIdFromValues({rowIndex:l,column:t,rowPinned:s})]=!0,n&&n.addParentNode(e.parent,[t])}},r.prototype.copyToClipboard=function(e){void 0===e&&(e={}),this.copyOrCutToClipboard(e)},r.prototype.cutToClipboard=function(e){void 0===e&&(e={}),this.copyOrCutToClipboard(e,!0)},r.prototype.copyOrCutToClipboard=function(e,o){var r=e.includeHeaders,i=e.includeGroupHeaders;this.logger.log("copyToClipboard: includeHeaders = "+r),null==r&&(r=this.gridOptionsService.is("copyHeadersToClipboard")),null==i&&(i=this.gridOptionsService.is("copyGroupHeadersToClipboard"));var n={includeHeaders:r,includeGroupHeaders:i},a=!this.gridOptionsService.is("suppressCopyRowsToClipboard"),l=null;!this.rangeService||this.rangeService.isEmpty()||this.shouldSkipSingleCellRange()?a&&!this.selectionService.isEmpty()?(this.copySelectedRowsToClipboard(n),l=t.SelectedRows):this.focusService.isAnyCellFocused()&&(this.copyFocusedCellToClipboard(n),l=t.FocusedCell):(this.copySelectedRangeToClipboard(n),l=t.CellRange),o&&null!==l&&this.clearCellsAfterCopy(l)},r.prototype.clearCellsAfterCopy=function(e){if(this.eventService.dispatchEvent({type:o.Events.EVENT_KEY_SHORTCUT_CHANGED_CELL_START}),e===t.CellRange)this.rangeService.clearCellRangeCellValues(void 0,"clipboardService");else if(e===t.SelectedRows)this.clearSelectedRows();else{var r=this.focusService.getFocusedCell();if(null==r)return;var i=this.rowPositionUtils.getRowNode(r);i&&this.clearCellValue(i,r.column)}this.eventService.dispatchEvent({type:o.Events.EVENT_KEY_SHORTCUT_CHANGED_CELL_END})},r.prototype.clearSelectedRows=function(){var e,t,o,r,i=this.selectionService.getSelectedNodes(),n=this.columnModel.getAllDisplayedColumns();try{for(var a=l(i),s=a.next();!s.done;s=a.next()){var c=s.value;try{for(var p=(o=void 0,l(n)),d=p.next();!d.done;d=p.next()){var u=d.value;this.clearCellValue(c,u)}}catch(e){o={error:e}}finally{try{d&&!d.done&&(r=p.return)&&r.call(p)}finally{if(o)throw o.error}}}}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}},r.prototype.clearCellValue=function(e,t){t.isCellEditable(e)&&e.setDataValue(t,null,"clipboardService")},r.prototype.shouldSkipSingleCellRange=function(){return this.gridOptionsService.is("suppressCopySingleCellRanges")&&!this.rangeService.isMoreThanOneCell()},r.prototype.iterateActiveRanges=function(e,t,o){var r=this;if(this.rangeService&&!this.rangeService.isEmpty()){var i=this.rangeService.getCellRanges();e?this.iterateActiveRange(i[0],t,o,!0):i.forEach((function(e,n){return r.iterateActiveRange(e,t,o,n===i.length-1)}))}},r.prototype.iterateActiveRange=function(e,t,o,r){if(this.rangeService){var i=this.rangeService.getRangeStartRow(e),n=this.rangeService.getRangeEndRow(e);o&&e.columns&&o(e.columns);for(var a=0,l=!1;!l&&null!=i;){var s=this.rowPositionUtils.getRowNode(i);l=this.rowPositionUtils.sameRow(i,n),t(i,s,e.columns,a++,l&&r),i=this.cellNavigationService.getRowBelow(i)}}},r.prototype.copySelectedRangeToClipboard=function(e){if(void 0===e&&(e={}),this.rangeService&&!this.rangeService.isEmpty()){var t=this.rangeService.areAllRangesAbleToMerge()?this.buildDataFromMergedRanges(e):this.buildDataFromRanges(e),o=t.data,r=t.cellsToFlash;this.copyDataToClipboard(o),this.dispatchFlashCells(r)}},r.prototype.buildDataFromMergedRanges=function(e){var t=this,o=new Set,r=this.rangeService.getCellRanges(),i=new Map,n=[],a={};r.forEach((function(e){e.columns.forEach((function(e){return o.add(e)}));var r=t.getRangeRowPositionsAndCellsToFlash(e),l=r.rowPositions,s=r.cellsToFlash;l.forEach((function(e){var t=e.rowIndex+"-"+(e.rowPinned||"null");i.get(t)||(i.set(t,!0),n.push(e))})),Object.assign(a,s)}));var l=this.columnModel.getAllDisplayedColumns(),s=Array.from(o);return s.sort((function(e,t){return l.indexOf(e)-l.indexOf(t)})),{data:this.buildExportParams({columns:s,rowPositions:n,includeHeaders:e.includeHeaders,includeGroupHeaders:e.includeGroupHeaders}),cellsToFlash:a}},r.prototype.buildDataFromRanges=function(e){var t=this,o=this.rangeService.getCellRanges(),r=[],i={};return o.forEach((function(o){var n=t.getRangeRowPositionsAndCellsToFlash(o),a=n.rowPositions,l=n.cellsToFlash;Object.assign(i,l),r.push(t.buildExportParams({columns:o.columns,rowPositions:a,includeHeaders:e.includeHeaders,includeGroupHeaders:e.includeGroupHeaders}))})),{data:r.join("\n"),cellsToFlash:i}},r.prototype.getRangeRowPositionsAndCellsToFlash=function(e){for(var t=this,o=[],r={},i=this.rangeService.getRangeStartRow(e),n=this.rangeService.getRangeEndRow(e),a=i;a&&(o.push(a),e.columns.forEach((function(e){var o=a,i=o.rowIndex,n=o.rowPinned,l=t.cellPositionUtils.createIdFromValues({rowIndex:i,column:e,rowPinned:n});r[l]=!0})),!this.rowPositionUtils.sameRow(a,n));)a=this.cellNavigationService.getRowBelow(a);return{rowPositions:o,cellsToFlash:r}},r.prototype.copyFocusedCellToClipboard=function(e){var t;void 0===e&&(e={});var o=this.focusService.getFocusedCell();if(null!=o){var r=this.cellPositionUtils.createId(o),i={rowPinned:o.rowPinned,rowIndex:o.rowIndex},n=o.column,a=this.buildExportParams({columns:[n],rowPositions:[i],includeHeaders:e.includeHeaders,includeGroupHeaders:e.includeGroupHeaders});this.copyDataToClipboard(a),this.dispatchFlashCells(((t={})[r]=!0,t))}},r.prototype.copySelectedRowsToClipboard=function(e){void 0===e&&(e={});var t=e.columnKeys,o=e.includeHeaders,r=e.includeGroupHeaders,i=this.buildExportParams({columns:t,includeHeaders:o,includeGroupHeaders:r});this.copyDataToClipboard(i)},r.prototype.buildExportParams=function(e){var t=this,o=e.columns,r=e.rowPositions,i=e.includeHeaders,n=void 0!==i&&i,a=e.includeGroupHeaders,l={columnKeys:o,rowPositions:r,skipColumnHeaders:!n,skipColumnGroupHeaders:!(void 0!==a&&a),suppressQuotes:!0,columnSeparator:this.getClipboardDelimiter(),onlySelected:!r,processCellCallback:this.gridOptionsService.getCallback("processCellForClipboard"),processRowGroupCallback:function(e){return t.processRowGroupCallback(e)},processHeaderCallback:this.gridOptionsService.getCallback("processHeaderForClipboard"),processGroupHeaderCallback:this.gridOptionsService.getCallback("processGroupHeaderForClipboard")};return this.csvCreator.getDataAsCsv(l,!0)},r.prototype.processRowGroupCallback=function(e){var t=e.node,o=t.key,r=null!=o?o:"";if(e.node.footer){var i="";o&&o.length&&(i=" "+o),r="Total"+i}var n=this.gridOptionsService.getCallback("processCellForClipboard");if(n){var a=t.rowGroupColumn;return!a&&t.footer&&-1===t.level&&(a=this.columnModel.getRowGroupColumns()[0]),n({value:r,node:t,column:a,type:"clipboard"})}return r},r.prototype.dispatchFlashCells=function(e){var t=this;window.setTimeout((function(){var r={type:o.Events.EVENT_FLASH_CELLS,cells:e};t.eventService.dispatchEvent(r)}),0)},r.prototype.processCell=function(e,t,o,r,i){return i?i({column:t,node:e,value:o,type:r}):o},r.prototype.copyDataToClipboard=function(e){var t=this,r=this.gridOptionsService.getCallback("sendToClipboard");r?r({data:e}):!this.gridOptionsService.is("suppressClipboardApi")&&navigator.clipboard?navigator.clipboard.writeText(e).catch((function(r){o._.doOnce((function(){console.warn(r),console.warn("AG Grid: Unable to use the Clipboard API (navigator.clipboard.writeText()). The reason why it could not be used has been logged in the previous line. For this reason the grid has defaulted to using a workaround which doesn't perform as well. Either fix why Clipboard API is blocked, OR stop this message from appearing by setting grid property suppressClipboardApi=true (which will default the grid to using the workaround rather than the API.")}),"clipboardApiError"),t.copyDataToClipboardLegacy(e)})):this.copyDataToClipboardLegacy(e)},r.prototype.copyDataToClipboardLegacy=function(e){var t=this;this.executeOnTempElement((function(o){var r=t.gridOptionsService.getDocument(),i=r.activeElement;o.value=e||" ",o.select(),o.focus({preventScroll:!0}),r.execCommand("copy")||console.warn("AG Grid: Browser did not allow document.execCommand('copy'). Ensure api.copySelectedRowsToClipboard() is invoked via a user event, i.e. button click, otherwise the browser will prevent it for security reasons."),null!=i&&null!=i.focus&&i.focus({preventScroll:!0})}))},r.prototype.executeOnTempElement=function(e,t){var o=this.gridOptionsService.getDocument(),r=o.createElement("textarea");r.style.width="1px",r.style.height="1px",r.style.top=o.documentElement.scrollTop+"px",r.style.left=o.documentElement.scrollLeft+"px",r.style.position="absolute",r.style.opacity="0";var i=this.gridCtrl.getGui();i.appendChild(r);try{e(r)}catch(e){console.warn("AG Grid: Browser does not support document.execCommand('copy') for clipboard operations")}t?window.setTimeout((function(){t(r),i.removeChild(r)}),100):i.removeChild(r)},r.prototype.getRangeSize=function(){var e=this.rangeService.getCellRanges(),t=0,o=0;return e.length>0&&(t=this.rangeService.getRangeStartRow(e[0]).rowIndex,o=this.rangeService.getRangeEndRow(e[0]).rowIndex),t-o+1},a([o.Autowired("csvCreator")],r.prototype,"csvCreator",void 0),a([o.Autowired("loggerFactory")],r.prototype,"loggerFactory",void 0),a([o.Autowired("selectionService")],r.prototype,"selectionService",void 0),a([o.Optional("rangeService")],r.prototype,"rangeService",void 0),a([o.Autowired("rowModel")],r.prototype,"rowModel",void 0),a([o.Autowired("ctrlsService")],r.prototype,"ctrlsService",void 0),a([o.Autowired("valueService")],r.prototype,"valueService",void 0),a([o.Autowired("focusService")],r.prototype,"focusService",void 0),a([o.Autowired("rowRenderer")],r.prototype,"rowRenderer",void 0),a([o.Autowired("columnModel")],r.prototype,"columnModel",void 0),a([o.Autowired("cellNavigationService")],r.prototype,"cellNavigationService",void 0),a([o.Autowired("cellPositionUtils")],r.prototype,"cellPositionUtils",void 0),a([o.Autowired("rowPositionUtils")],r.prototype,"rowPositionUtils",void 0),a([o.PostConstruct],r.prototype,"init",null),r=i=a([o.Bean("clipboardService")],r)}(o.BeanStub),c={version:"29.1.0",moduleName:o.ModuleNames.ClipboardModule,beans:[s],dependantModules:[r.EnterpriseCoreModule,i.CsvExportModule]};exports.ClipboardModule=c;

@@ -27,2 +27,3 @@ import { BeanStub, CellPositionUtils, IClipboardCopyParams, IClipboardCopyRowsParams, IClipboardService, RowPositionUtils, CtrlsService } from "@ag-grid-community/core";

private processClipboardData;
static stringToArray(strData: string, delimiter?: string): string[][];
private doPasteOperation;

@@ -40,2 +41,7 @@ private pasteIntoActiveRange;

copyToClipboard(params?: IClipboardCopyParams): void;
cutToClipboard(params?: IClipboardCopyParams): void;
private copyOrCutToClipboard;
private clearCellsAfterCopy;
private clearSelectedRows;
private clearCellValue;
private shouldSkipSingleCellRange;

@@ -42,0 +48,0 @@ private iterateActiveRanges;

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

};
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
import { _, Autowired, Bean, BeanStub, ChangedPath, Events, PostConstruct, Optional, } from "@ag-grid-community/core";
import { stringToArray } from "./csv";
// Matches value in changeDetectionService

@@ -27,2 +37,9 @@ var SOURCE_PASTE = 'paste';

var EXPORT_TYPE_CLIPBOARD = 'clipboard';
var CellClearType;
(function (CellClearType) {
CellClearType[CellClearType["CellRange"] = 0] = "CellRange";
CellClearType[CellClearType["SelectedRows"] = 1] = "SelectedRows";
CellClearType[CellClearType["FocusedCell"] = 2] = "FocusedCell";
})(CellClearType || (CellClearType = {}));
;
var ClipboardService = /** @class */ (function (_super) {

@@ -36,2 +53,3 @@ __extends(ClipboardService, _super);

}
ClipboardService_1 = ClipboardService;
ClipboardService.prototype.init = function () {

@@ -121,3 +139,3 @@ var _this = this;

}
var parsedData = stringToArray(data, this.getClipboardDelimiter());
var parsedData = ClipboardService_1.stringToArray(data, this.getClipboardDelimiter());
var userFunc = this.gridOptionsService.getCallback('processDataFromClipboard');

@@ -145,6 +163,84 @@ if (userFunc) {

};
// This will parse a delimited string into an array of arrays.
ClipboardService.stringToArray = function (strData, delimiter) {
if (delimiter === void 0) { delimiter = ','; }
var data = [];
var isNewline = function (char) { return char === '\r' || char === '\n'; };
var insideQuotedField = false;
if (strData === '') {
return [['']];
}
var _loop_1 = function (row, column, position) {
var previousChar = strData[position - 1];
var currentChar = strData[position];
var nextChar = strData[position + 1];
var ensureDataExists = function () {
if (!data[row]) {
// create row if it doesn't exist
data[row] = [];
}
if (!data[row][column]) {
// create column if it doesn't exist
data[row][column] = '';
}
};
ensureDataExists();
if (currentChar === '"') {
if (insideQuotedField) {
if (nextChar === '"') {
// unescape double quote
data[row][column] += '"';
position++;
}
else {
// exit quoted field
insideQuotedField = false;
}
return out_row_1 = row, out_column_1 = column, out_position_1 = position, "continue";
}
else if (previousChar === undefined || previousChar === delimiter || isNewline(previousChar)) {
// enter quoted field
insideQuotedField = true;
return out_row_1 = row, out_column_1 = column, out_position_1 = position, "continue";
}
}
if (!insideQuotedField) {
if (currentChar === delimiter) {
// move to next column
column++;
ensureDataExists();
return out_row_1 = row, out_column_1 = column, out_position_1 = position, "continue";
}
else if (isNewline(currentChar)) {
// move to next row
column = 0;
row++;
ensureDataExists();
if (currentChar === '\r' && nextChar === '\n') {
// skip over second newline character if it exists
position++;
}
return out_row_1 = row, out_column_1 = column, out_position_1 = position, "continue";
}
}
// add current character to current column
data[row][column] += currentChar;
out_row_1 = row;
out_column_1 = column;
out_position_1 = position;
};
var out_row_1, out_column_1, out_position_1;
// iterate over each character, keep track of current row and column (of the returned array)
for (var row = 0, column = 0, position = 0; position < strData.length; position++) {
_loop_1(row, column, position);
row = out_row_1;
column = out_column_1;
position = out_position_1;
}
return data;
};
// common code to paste operations, e.g. paste to cell, paste to range, and copy range down
ClipboardService.prototype.doPasteOperation = function (pasteOperationFunc) {
var api = this.gridOptionsService.get('api');
var columnApi = this.gridOptionsService.get('columnApi');
var api = this.gridOptionsService.api;
var columnApi = this.gridOptionsService.columnApi;
var source = 'clipboard';

@@ -215,3 +311,4 @@ this.eventService.dispatchEvent({

}
var cellId = _this.cellPositionUtils.createIdFromValues(currentRow.rowIndex, column, currentRow.rowPinned);
var rowIndex = currentRow.rowIndex, rowPinned = currentRow.rowPinned;
var cellId = _this.cellPositionUtils.createIdFromValues({ rowIndex: rowIndex, column: column, rowPinned: rowPinned });
cellsToFlash[cellId] = true;

@@ -287,3 +384,4 @@ });

}
var cellId = _this.cellPositionUtils.createIdFromValues(currentRow.rowIndex, column, currentRow.rowPinned);
var rowIndex = currentRow.rowIndex, rowPinned = currentRow.rowPinned;
var cellId = _this.cellPositionUtils.createIdFromValues({ rowIndex: rowIndex, column: column, rowPinned: rowPinned });
cellsToFlash[cellId] = true;

@@ -372,3 +470,4 @@ });

rowNode.setDataValue(column, processedValue, SOURCE_PASTE);
var cellId = this.cellPositionUtils.createIdFromValues(rowNode.rowIndex, column, rowNode.rowPinned);
var rowIndex = rowNode.rowIndex, rowPinned = rowNode.rowPinned;
var cellId = this.cellPositionUtils.createIdFromValues({ rowIndex: rowIndex, column: column, rowPinned: rowPinned });
cellsToFlash[cellId] = true;

@@ -381,2 +480,9 @@ if (changedPath) {

if (params === void 0) { params = {}; }
this.copyOrCutToClipboard(params);
};
ClipboardService.prototype.cutToClipboard = function (params) {
if (params === void 0) { params = {}; }
this.copyOrCutToClipboard(params, true);
};
ClipboardService.prototype.copyOrCutToClipboard = function (params, cut) {
var includeHeaders = params.includeHeaders, includeGroupHeaders = params.includeGroupHeaders;

@@ -393,13 +499,76 @@ this.logger.log("copyToClipboard: includeHeaders = " + includeHeaders);

var shouldCopyRows = !this.gridOptionsService.is('suppressCopyRowsToClipboard');
var cellClearType = null;
// Copy priority is Range > Row > Focus
if (this.rangeService && !this.rangeService.isEmpty() && !this.shouldSkipSingleCellRange()) {
this.copySelectedRangeToClipboard(copyParams);
cellClearType = CellClearType.CellRange;
}
else if (shouldCopyRows && !this.selectionService.isEmpty()) {
this.copySelectedRowsToClipboard(copyParams);
cellClearType = CellClearType.SelectedRows;
}
else if (this.focusService.isAnyCellFocused()) {
this.copyFocusedCellToClipboard(copyParams);
cellClearType = CellClearType.FocusedCell;
}
if (cut && cellClearType !== null) {
this.clearCellsAfterCopy(cellClearType);
}
};
ClipboardService.prototype.clearCellsAfterCopy = function (type) {
this.eventService.dispatchEvent({ type: Events.EVENT_KEY_SHORTCUT_CHANGED_CELL_START });
if (type === CellClearType.CellRange) {
this.rangeService.clearCellRangeCellValues(undefined, 'clipboardService');
}
else if (type === CellClearType.SelectedRows) {
this.clearSelectedRows();
}
else {
var focusedCell = this.focusService.getFocusedCell();
if (focusedCell == null) {
return;
}
var rowNode = this.rowPositionUtils.getRowNode(focusedCell);
if (rowNode) {
this.clearCellValue(rowNode, focusedCell.column);
}
}
this.eventService.dispatchEvent({ type: Events.EVENT_KEY_SHORTCUT_CHANGED_CELL_END });
};
ClipboardService.prototype.clearSelectedRows = function () {
var e_1, _a, e_2, _b;
var selected = this.selectionService.getSelectedNodes();
var columns = this.columnModel.getAllDisplayedColumns();
try {
for (var selected_1 = __values(selected), selected_1_1 = selected_1.next(); !selected_1_1.done; selected_1_1 = selected_1.next()) {
var row = selected_1_1.value;
try {
for (var columns_1 = (e_2 = void 0, __values(columns)), columns_1_1 = columns_1.next(); !columns_1_1.done; columns_1_1 = columns_1.next()) {
var col = columns_1_1.value;
this.clearCellValue(row, col);
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (columns_1_1 && !columns_1_1.done && (_b = columns_1.return)) _b.call(columns_1);
}
finally { if (e_2) throw e_2.error; }
}
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (selected_1_1 && !selected_1_1.done && (_a = selected_1.return)) _a.call(selected_1);
}
finally { if (e_1) throw e_1.error; }
}
};
ClipboardService.prototype.clearCellValue = function (rowNode, column) {
if (!column.isCellEditable(rowNode)) {
return;
}
rowNode.setDataValue(column, null, 'clipboardService');
};
ClipboardService.prototype.shouldSkipSingleCellRange = function () {

@@ -512,3 +681,4 @@ return this.gridOptionsService.is('suppressCopySingleCellRanges') && !this.rangeService.isMoreThanOneCell();

range.columns.forEach(function (column) {
var cellId = _this.cellPositionUtils.createIdFromValues(node.rowIndex, column, node.rowPinned);
var _a = node, rowIndex = _a.rowIndex, rowPinned = _a.rowPinned;
var cellId = _this.cellPositionUtils.createIdFromValues({ rowIndex: rowIndex, column: column, rowPinned: rowPinned });
cellsToFlash[cellId] = true;

@@ -705,2 +875,3 @@ });

};
var ClipboardService_1;
__decorate([

@@ -748,3 +919,3 @@ Autowired('csvCreator')

], ClipboardService.prototype, "init", null);
ClipboardService = __decorate([
ClipboardService = ClipboardService_1 = __decorate([
Bean('clipboardService')

@@ -751,0 +922,0 @@ ], ClipboardService);

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

export declare const VERSION = "29.0.0";
export declare const VERSION = "29.1.0";
// DO NOT UPDATE MANUALLY: Generated from script during build time
export var VERSION = '29.0.0';
export var VERSION = '29.1.0';

@@ -27,2 +27,3 @@ import { BeanStub, CellPositionUtils, IClipboardCopyParams, IClipboardCopyRowsParams, IClipboardService, RowPositionUtils, CtrlsService } from "@ag-grid-community/core";

private processClipboardData;
static stringToArray(strData: string, delimiter?: string): string[][];
private doPasteOperation;

@@ -40,2 +41,7 @@ private pasteIntoActiveRange;

copyToClipboard(params?: IClipboardCopyParams): void;
cutToClipboard(params?: IClipboardCopyParams): void;
private copyOrCutToClipboard;
private clearCellsAfterCopy;
private clearSelectedRows;
private clearCellValue;
private shouldSkipSingleCellRange;

@@ -42,0 +48,0 @@ private iterateActiveRanges;

@@ -7,4 +7,4 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

};
var ClipboardService_1;
import { _, Autowired, Bean, BeanStub, ChangedPath, Events, PostConstruct, Optional, } from "@ag-grid-community/core";
import { stringToArray } from "./csv";
// Matches value in changeDetectionService

@@ -14,3 +14,10 @@ const SOURCE_PASTE = 'paste';

const EXPORT_TYPE_CLIPBOARD = 'clipboard';
let ClipboardService = class ClipboardService extends BeanStub {
var CellClearType;
(function (CellClearType) {
CellClearType[CellClearType["CellRange"] = 0] = "CellRange";
CellClearType[CellClearType["SelectedRows"] = 1] = "SelectedRows";
CellClearType[CellClearType["FocusedCell"] = 2] = "FocusedCell";
})(CellClearType || (CellClearType = {}));
;
let ClipboardService = ClipboardService_1 = class ClipboardService extends BeanStub {
constructor() {

@@ -101,3 +108,3 @@ super(...arguments);

}
let parsedData = stringToArray(data, this.getClipboardDelimiter());
let parsedData = ClipboardService_1.stringToArray(data, this.getClipboardDelimiter());
const userFunc = this.gridOptionsService.getCallback('processDataFromClipboard');

@@ -125,6 +132,73 @@ if (userFunc) {

}
// This will parse a delimited string into an array of arrays.
static stringToArray(strData, delimiter = ',') {
const data = [];
const isNewline = (char) => char === '\r' || char === '\n';
let insideQuotedField = false;
if (strData === '') {
return [['']];
}
// iterate over each character, keep track of current row and column (of the returned array)
for (let row = 0, column = 0, position = 0; position < strData.length; position++) {
const previousChar = strData[position - 1];
const currentChar = strData[position];
const nextChar = strData[position + 1];
const ensureDataExists = () => {
if (!data[row]) {
// create row if it doesn't exist
data[row] = [];
}
if (!data[row][column]) {
// create column if it doesn't exist
data[row][column] = '';
}
};
ensureDataExists();
if (currentChar === '"') {
if (insideQuotedField) {
if (nextChar === '"') {
// unescape double quote
data[row][column] += '"';
position++;
}
else {
// exit quoted field
insideQuotedField = false;
}
continue;
}
else if (previousChar === undefined || previousChar === delimiter || isNewline(previousChar)) {
// enter quoted field
insideQuotedField = true;
continue;
}
}
if (!insideQuotedField) {
if (currentChar === delimiter) {
// move to next column
column++;
ensureDataExists();
continue;
}
else if (isNewline(currentChar)) {
// move to next row
column = 0;
row++;
ensureDataExists();
if (currentChar === '\r' && nextChar === '\n') {
// skip over second newline character if it exists
position++;
}
continue;
}
}
// add current character to current column
data[row][column] += currentChar;
}
return data;
}
// common code to paste operations, e.g. paste to cell, paste to range, and copy range down
doPasteOperation(pasteOperationFunc) {
const api = this.gridOptionsService.get('api');
const columnApi = this.gridOptionsService.get('columnApi');
const api = this.gridOptionsService.api;
const columnApi = this.gridOptionsService.columnApi;
const source = 'clipboard';

@@ -194,3 +268,4 @@ this.eventService.dispatchEvent({

}
const cellId = this.cellPositionUtils.createIdFromValues(currentRow.rowIndex, column, currentRow.rowPinned);
const { rowIndex, rowPinned } = currentRow;
const cellId = this.cellPositionUtils.createIdFromValues({ rowIndex, column, rowPinned });
cellsToFlash[cellId] = true;

@@ -262,3 +337,4 @@ });

}
const cellId = this.cellPositionUtils.createIdFromValues(currentRow.rowIndex, column, currentRow.rowPinned);
const { rowIndex, rowPinned } = currentRow;
const cellId = this.cellPositionUtils.createIdFromValues({ rowIndex, column, rowPinned });
cellsToFlash[cellId] = true;

@@ -343,3 +419,4 @@ });

rowNode.setDataValue(column, processedValue, SOURCE_PASTE);
const cellId = this.cellPositionUtils.createIdFromValues(rowNode.rowIndex, column, rowNode.rowPinned);
const { rowIndex, rowPinned } = rowNode;
const cellId = this.cellPositionUtils.createIdFromValues({ rowIndex: rowIndex, column, rowPinned });
cellsToFlash[cellId] = true;

@@ -351,2 +428,8 @@ if (changedPath) {

copyToClipboard(params = {}) {
this.copyOrCutToClipboard(params);
}
cutToClipboard(params = {}) {
this.copyOrCutToClipboard(params, true);
}
copyOrCutToClipboard(params, cut) {
let { includeHeaders, includeGroupHeaders } = params;

@@ -363,13 +446,55 @@ this.logger.log(`copyToClipboard: includeHeaders = ${includeHeaders}`);

const shouldCopyRows = !this.gridOptionsService.is('suppressCopyRowsToClipboard');
let cellClearType = null;
// Copy priority is Range > Row > Focus
if (this.rangeService && !this.rangeService.isEmpty() && !this.shouldSkipSingleCellRange()) {
this.copySelectedRangeToClipboard(copyParams);
cellClearType = CellClearType.CellRange;
}
else if (shouldCopyRows && !this.selectionService.isEmpty()) {
this.copySelectedRowsToClipboard(copyParams);
cellClearType = CellClearType.SelectedRows;
}
else if (this.focusService.isAnyCellFocused()) {
this.copyFocusedCellToClipboard(copyParams);
cellClearType = CellClearType.FocusedCell;
}
if (cut && cellClearType !== null) {
this.clearCellsAfterCopy(cellClearType);
}
}
clearCellsAfterCopy(type) {
this.eventService.dispatchEvent({ type: Events.EVENT_KEY_SHORTCUT_CHANGED_CELL_START });
if (type === CellClearType.CellRange) {
this.rangeService.clearCellRangeCellValues(undefined, 'clipboardService');
}
else if (type === CellClearType.SelectedRows) {
this.clearSelectedRows();
}
else {
const focusedCell = this.focusService.getFocusedCell();
if (focusedCell == null) {
return;
}
const rowNode = this.rowPositionUtils.getRowNode(focusedCell);
if (rowNode) {
this.clearCellValue(rowNode, focusedCell.column);
}
}
this.eventService.dispatchEvent({ type: Events.EVENT_KEY_SHORTCUT_CHANGED_CELL_END });
}
clearSelectedRows() {
const selected = this.selectionService.getSelectedNodes();
const columns = this.columnModel.getAllDisplayedColumns();
for (const row of selected) {
for (const col of columns) {
this.clearCellValue(row, col);
}
}
}
clearCellValue(rowNode, column) {
if (!column.isCellEditable(rowNode)) {
return;
}
rowNode.setDataValue(column, null, 'clipboardService');
}
shouldSkipSingleCellRange() {

@@ -477,3 +602,4 @@ return this.gridOptionsService.is('suppressCopySingleCellRanges') && !this.rangeService.isMoreThanOneCell();

range.columns.forEach(column => {
const cellId = this.cellPositionUtils.createIdFromValues(node.rowIndex, column, node.rowPinned);
const { rowIndex, rowPinned } = node;
const cellId = this.cellPositionUtils.createIdFromValues({ rowIndex, column, rowPinned });
cellsToFlash[cellId] = true;

@@ -706,5 +832,5 @@ });

], ClipboardService.prototype, "init", null);
ClipboardService = __decorate([
ClipboardService = ClipboardService_1 = __decorate([
Bean('clipboardService')
], ClipboardService);
export { ClipboardService };

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

export declare const VERSION = "29.0.0";
export declare const VERSION = "29.1.0";
// DO NOT UPDATE MANUALLY: Generated from script during build time
export const VERSION = '29.0.0';
export const VERSION = '29.1.0';
{
"name": "@ag-grid-enterprise/clipboard",
"version": "29.0.0",
"version": "29.1.0",
"description": "Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue",

@@ -51,5 +51,5 @@ "main": "./dist/cjs/es5/main.js",

"dependencies": {
"@ag-grid-community/core": "~29.0.0",
"@ag-grid-community/csv-export": "~29.0.0",
"@ag-grid-enterprise/core": "~29.0.0"
"@ag-grid-community/core": "~29.1.0",
"@ag-grid-community/csv-export": "~29.1.0",
"@ag-grid-enterprise/core": "~29.1.0"
},

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

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

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