Socket
Socket
Sign inDemoInstall

@ag-grid-enterprise/clipboard

Package Overview
Dependencies
4
Maintainers
3
Versions
61
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 31.2.1 to 31.3.0

139

dist/package/main.cjs.js

@@ -63,3 +63,3 @@ var __defProp = Object.defineProperty;

this.logger.log("pasteFromClipboard");
const allowNavigator = !this.gridOptionsService.get("suppressClipboardApi");
const allowNavigator = !this.gos.get("suppressClipboardApi");
if (allowNavigator && !this.navigatorApiFailed && navigator.clipboard && navigator.clipboard.readText) {

@@ -116,3 +116,3 @@ navigator.clipboard.readText().then(this.processClipboardData.bind(this)).catch((e) => {

getClipboardDelimiter() {
const delimiter = this.gridOptionsService.get("clipboardDelimiter");
const delimiter = this.gos.get("clipboardDelimiter");
return import_core._.exists(delimiter) ? delimiter : " ";

@@ -125,3 +125,3 @@ }

let parsedData = ClipboardService.stringToArray(data, this.getClipboardDelimiter());
const userFunc = this.gridOptionsService.getCallback("processDataFromClipboard");
const userFunc = this.gos.getCallback("processDataFromClipboard");
if (userFunc) {

@@ -133,10 +133,11 @@ parsedData = userFunc({ data: parsedData });

}
if (this.gridOptionsService.get("suppressLastEmptyLineOnPaste")) {
if (this.gos.get("suppressLastEmptyLineOnPaste")) {
this.removeLastLineIfBlank(parsedData);
}
const pasteOperation = (cellsToFlash, updatedRowNodes, focusedCell, changedPath) => {
const rangeActive = this.rangeService && this.rangeService.isMoreThanOneCell();
var _a;
const rangeActive = (_a = this.rangeService) == null ? void 0 : _a.isMoreThanOneCell();
const pasteIntoRange = rangeActive && !this.hasOnlyOneValueToPaste(parsedData);
if (pasteIntoRange) {
this.pasteIntoActiveRange(parsedData, cellsToFlash, updatedRowNodes, changedPath);
this.pasteIntoActiveRange(this.rangeService, parsedData, cellsToFlash, updatedRowNodes, changedPath);
} else {

@@ -209,3 +210,3 @@ this.pasteStartingFromFocusedCell(parsedData, cellsToFlash, updatedRowNodes, focusedCell, changedPath);

if (this.clientSideRowModel) {
const onlyChangedColumns = this.gridOptionsService.get("aggregateOnlyChangedColumns");
const onlyChangedColumns = this.gos.get("aggregateOnlyChangedColumns");
changedPath = new import_core.ChangedPath(onlyChangedColumns, this.clientSideRowModel.getRootNode());

@@ -234,4 +235,4 @@ }

}
pasteIntoActiveRange(clipboardData, cellsToFlash, updatedRowNodes, changedPath) {
const abortRepeatingPasteIntoRows = this.getRangeSize() % clipboardData.length != 0;
pasteIntoActiveRange(rangeService, clipboardData, cellsToFlash, updatedRowNodes, changedPath) {
const abortRepeatingPasteIntoRows = this.getRangeSize(rangeService) % clipboardData.length != 0;
let indexOffset = 0;

@@ -250,3 +251,3 @@ let dataRowIndex = 0;

updatedRowNodes.push(rowNode);
const processCellFromClipboardFunc = this.gridOptionsService.getCallback("processCellFromClipboard");
const processCellFromClipboardFunc = this.gos.getCallback("processCellFromClipboard");
columns.forEach((column, idx) => {

@@ -279,2 +280,11 @@ if (!column.isCellEditable(rowNode) || column.isSuppressPaste(rowNode)) {

}
getDisplayedColumnsStartingAt(column) {
let currentColumn = column;
const columns = [];
while (currentColumn != null) {
columns.push(currentColumn);
currentColumn = this.columnModel.getDisplayedColAfter(currentColumn);
}
return columns;
}
pasteStartingFromFocusedCell(parsedData, cellsToFlash, updatedRowNodes, focusedCell, changedPath) {

@@ -285,3 +295,3 @@ if (!focusedCell) {

const currentRow = { rowIndex: focusedCell.rowIndex, rowPinned: focusedCell.rowPinned };
const columnsToPasteInto = this.columnModel.getDisplayedColumnsStartingAt(focusedCell.column);
const columnsToPasteInto = this.getDisplayedColumnsStartingAt(focusedCell.column);
if (this.isPasteSingleValueIntoRange(parsedData)) {

@@ -322,4 +332,4 @@ this.pasteSingleValueIntoRange(parsedData, updatedRowNodes, cellsToFlash, changedPath);

const pasteOperation = (cellsToFlash, updatedRowNodes, focusedCell, changedPath) => {
const processCellForClipboardFunc = this.gridOptionsService.getCallback("processCellForClipboard");
const processCellFromClipboardFunc = this.gridOptionsService.getCallback("processCellFromClipboard");
const processCellForClipboardFunc = this.gos.getCallback("processCellForClipboard");
const processCellFromClipboardFunc = this.gos.getCallback("processCellFromClipboard");
const rowCallback = (currentRow, rowNode, columns) => {

@@ -378,3 +388,3 @@ if (!firstRowValues.length) {

fireRowChanged(rowNodes) {
if (this.gridOptionsService.get("editType") !== "fullRow") {
if (this.gos.get("editType") !== "fullRow") {
return;

@@ -395,3 +405,3 @@ }

let rowPointer = currentRow;
const skipGroupRows = this.clientSideRowModel != null && !this.gridOptionsService.get("enableGroupEdit") && !this.gridOptionsService.get("treeData");
const skipGroupRows = this.clientSideRowModel != null && !this.gos.get("enableGroupEdit") && !this.gos.get("treeData");
const getNextGoodRowNode = () => {

@@ -429,3 +439,3 @@ while (true) {

}
const processedValue = this.processCell(rowNode, column, value, type, this.gridOptionsService.getCallback("processCellFromClipboard"), true);
const processedValue = this.processCell(rowNode, column, value, type, this.gos.getCallback("processCellFromClipboard"), true);
rowNode.setDataValue(column, processedValue, SOURCE_PASTE);

@@ -443,3 +453,3 @@ const { rowIndex, rowPinned } = rowNode;

cutToClipboard(params = {}, source = "api") {
if (this.gridOptionsService.get("suppressCutToClipboard")) {
if (this.gos.get("suppressCutToClipboard")) {
return;

@@ -463,11 +473,11 @@ }

if (includeHeaders == null) {
includeHeaders = this.gridOptionsService.get("copyHeadersToClipboard");
includeHeaders = this.gos.get("copyHeadersToClipboard");
}
if (includeGroupHeaders == null) {
includeGroupHeaders = this.gridOptionsService.get("copyGroupHeadersToClipboard");
includeGroupHeaders = this.gos.get("copyGroupHeadersToClipboard");
}
const copyParams = { includeHeaders, includeGroupHeaders };
const shouldCopyRows = !this.gridOptionsService.get("suppressCopyRowsToClipboard");
const shouldCopyRows = !this.gos.get("suppressCopyRowsToClipboard");
let cellClearType = null;
if (this.rangeService && !this.rangeService.isEmpty() && !this.shouldSkipSingleCellRange()) {
if (this.rangeService && !this.rangeService.isEmpty() && !this.shouldSkipSingleCellRange(this.rangeService)) {
this.copySelectedRangeToClipboard(copyParams);

@@ -514,9 +524,11 @@ cellClearType = 0 /* CellRange */;

clearCellValue(rowNode, column) {
var _a;
if (!column.isCellEditable(rowNode)) {
return;
}
rowNode.setDataValue(column, null, "clipboardService");
const emptyValue = (_a = this.valueService.parseValue(column, rowNode, "", rowNode.getValueFromValueService(column))) != null ? _a : null;
rowNode.setDataValue(column, emptyValue, "clipboardService");
}
shouldSkipSingleCellRange() {
return this.gridOptionsService.get("suppressCopySingleCellRanges") && !this.rangeService.isMoreThanOneCell();
shouldSkipSingleCellRange(rangeService) {
return this.gos.get("suppressCopySingleCellRanges") && !rangeService.isMoreThanOneCell();
}

@@ -557,9 +569,9 @@ iterateActiveRanges(onlyFirst, rowCallback, columnCallback) {

const allRangesMerge = this.rangeService.areAllRangesAbleToMerge();
const { data, cellsToFlash } = allRangesMerge ? this.buildDataFromMergedRanges(params) : this.buildDataFromRanges(params);
const { data, cellsToFlash } = allRangesMerge ? this.buildDataFromMergedRanges(this.rangeService, params) : this.buildDataFromRanges(this.rangeService, params);
this.copyDataToClipboard(data);
this.dispatchFlashCells(cellsToFlash);
}
buildDataFromMergedRanges(params) {
buildDataFromMergedRanges(rangeService, params) {
const columnsSet = /* @__PURE__ */ new Set();
const ranges = this.rangeService.getCellRanges();
const ranges = rangeService.getCellRanges();
const rowPositionsMap = /* @__PURE__ */ new Map();

@@ -570,3 +582,3 @@ const allRowPositions = [];

range.columns.forEach((col) => columnsSet.add(col));
const { rowPositions, cellsToFlash } = this.getRangeRowPositionsAndCellsToFlash(range);
const { rowPositions, cellsToFlash } = this.getRangeRowPositionsAndCellsToFlash(rangeService, range);
rowPositions.forEach((rowPosition) => {

@@ -596,8 +608,8 @@ const rowPositionAsString = `${rowPosition.rowIndex}-${rowPosition.rowPinned || "null"}`;

}
buildDataFromRanges(params) {
const ranges = this.rangeService.getCellRanges();
buildDataFromRanges(rangeService, params) {
const ranges = rangeService.getCellRanges();
const data = [];
const allCellsToFlash = {};
ranges.forEach((range) => {
const { rowPositions, cellsToFlash } = this.getRangeRowPositionsAndCellsToFlash(range);
const { rowPositions, cellsToFlash } = this.getRangeRowPositionsAndCellsToFlash(rangeService, range);
Object.assign(allCellsToFlash, cellsToFlash);

@@ -613,7 +625,7 @@ data.push(this.buildExportParams({

}
getRangeRowPositionsAndCellsToFlash(range) {
getRangeRowPositionsAndCellsToFlash(rangeService, range) {
const rowPositions = [];
const cellsToFlash = {};
const startRow = this.rangeService.getRangeStartRow(range);
const lastRow = this.rangeService.getRangeEndRow(range);
const startRow = rangeService.getRangeStartRow(range);
const lastRow = rangeService.getRangeEndRow(range);
let node = startRow;

@@ -688,6 +700,6 @@ while (node) {

onlySelected: !rowPositions,
processCellCallback: this.gridOptionsService.getCallback("processCellForClipboard"),
processCellCallback: this.gos.getCallback("processCellForClipboard"),
processRowGroupCallback: (params2) => this.processRowGroupCallback(params2),
processHeaderCallback: this.gridOptionsService.getCallback("processHeaderForClipboard"),
processGroupHeaderCallback: this.gridOptionsService.getCallback("processGroupHeaderForClipboard")
processHeaderCallback: this.gos.getCallback("processHeaderForClipboard"),
processGroupHeaderCallback: this.gos.getCallback("processGroupHeaderForClipboard")
};

@@ -698,4 +710,4 @@ return this.csvCreator.getDataAsCsv(exportParams, true);

const { node, column } = params;
const isTreeData = this.gridOptionsService.get("treeData");
const isSuppressGroupMaintainValueType = this.gridOptionsService.get("suppressGroupMaintainValueType");
const isTreeData = this.gos.get("treeData");
const isSuppressGroupMaintainValueType = this.gos.get("suppressGroupMaintainValueType");
const getValueFromNode = () => {

@@ -710,3 +722,3 @@ var _a, _b;

}
return (_b = this.valueFormatterService.formatValue(node.rowGroupColumn, node, value2)) != null ? _b : value2;
return (_b = this.valueService.formatValue(node.rowGroupColumn, node, value2)) != null ? _b : value2;
};

@@ -721,3 +733,3 @@ let value = getValueFromNode();

}
const processCellForClipboard = this.gridOptionsService.getCallback("processCellForClipboard");
const processCellForClipboard = this.gos.getCallback("processCellForClipboard");
if (processCellForClipboard) {

@@ -735,5 +747,5 @@ let column2 = node.rowGroupColumn;

var _a;
return (_a = this.valueFormatterService.formatValue(column2, node, valueToFormat)) != null ? _a : valueToFormat;
return (_a = this.valueService.formatValue(column2, node, valueToFormat)) != null ? _a : valueToFormat;
},
parseValue: (valueToParse) => this.valueParserService.parseValue(column2, node, valueToParse, this.valueService.getValue(column2, node))
parseValue: (valueToParse) => this.valueService.parseValue(column2, node, valueToParse, this.valueService.getValue(column2, node))
});

@@ -762,5 +774,5 @@ }

var _a2;
return (_a2 = this.valueFormatterService.formatValue(column, rowNode != null ? rowNode : null, valueToFormat)) != null ? _a2 : valueToFormat;
return (_a2 = this.valueService.formatValue(column, rowNode != null ? rowNode : null, valueToFormat)) != null ? _a2 : valueToFormat;
},
parseValue: (valueToParse) => this.valueParserService.parseValue(column, rowNode != null ? rowNode : null, valueToParse, this.valueService.getValue(column, rowNode))
parseValue: (valueToParse) => this.valueService.parseValue(column, rowNode != null ? rowNode : null, valueToParse, this.valueService.getValue(column, rowNode))
};

@@ -770,10 +782,11 @@ return func(params);

if (canParse && column.getColDef().useValueParserForImport !== false) {
return this.valueParserService.parseValue(column, rowNode != null ? rowNode : null, value, this.valueService.getValue(column, rowNode));
} else if (canFormat && column.getColDef().useValueFormatterForExport !== false) {
return (_a = this.valueFormatterService.formatValue(column, rowNode != null ? rowNode : null, value)) != null ? _a : value;
return this.valueService.parseValue(column, rowNode != null ? rowNode : null, value, this.valueService.getValue(column, rowNode));
}
if (canFormat && column.getColDef().useValueFormatterForExport !== false) {
return (_a = this.valueService.formatValue(column, rowNode != null ? rowNode : null, value)) != null ? _a : value;
}
return value;
}
copyDataToClipboard(data) {
const userProvidedFunc = this.gridOptionsService.getCallback("sendToClipboard");
const userProvidedFunc = this.gos.getCallback("sendToClipboard");
if (userProvidedFunc) {

@@ -783,3 +796,3 @@ userProvidedFunc({ data });

}
const allowNavigator = !this.gridOptionsService.get("suppressClipboardApi");
const allowNavigator = !this.gos.get("suppressClipboardApi");
if (allowNavigator && navigator.clipboard) {

@@ -799,4 +812,4 @@ navigator.clipboard.writeText(data).catch((e) => {

this.executeOnTempElement((element) => {
const eDocument = this.gridOptionsService.getDocument();
const focusedElementBefore = eDocument.activeElement;
const eDocument = this.gos.getDocument();
const focusedElementBefore = this.gos.getActiveDomElement();
element.value = data || " ";

@@ -815,3 +828,3 @@ element.select();

executeOnTempElement(callbackNow, callbackAfter) {
const eDoc = this.gridOptionsService.getDocument();
const eDoc = this.gos.getDocument();
const eTempInput = eDoc.createElement("textarea");

@@ -840,9 +853,9 @@ eTempInput.style.width = "1px";

}
getRangeSize() {
const ranges = this.rangeService.getCellRanges();
getRangeSize(rangeService) {
const ranges = rangeService.getCellRanges();
let startRangeIndex = 0;
let endRangeIndex = 0;
if (ranges.length > 0) {
startRangeIndex = this.rangeService.getRangeStartRow(ranges[0]).rowIndex;
endRangeIndex = this.rangeService.getRangeEndRow(ranges[0]).rowIndex;
startRangeIndex = rangeService.getRangeStartRow(ranges[0]).rowIndex;
endRangeIndex = rangeService.getRangeEndRow(ranges[0]).rowIndex;
}

@@ -862,5 +875,2 @@ return startRangeIndex - endRangeIndex + 1;

__decorateClass([
(0, import_core.Optional)("rangeService")
], ClipboardService.prototype, "rangeService", 2);
__decorateClass([
(0, import_core.Autowired)("rowModel")

@@ -893,8 +903,5 @@ ], ClipboardService.prototype, "rowModel", 2);

__decorateClass([
(0, import_core.Autowired)("valueFormatterService")
], ClipboardService.prototype, "valueFormatterService", 2);
(0, import_core.Optional)("rangeService")
], ClipboardService.prototype, "rangeService", 2);
__decorateClass([
(0, import_core.Autowired)("valueParserService")
], ClipboardService.prototype, "valueParserService", 2);
__decorateClass([
import_core.PostConstruct

@@ -907,3 +914,3 @@ ], ClipboardService.prototype, "init", 1);

// enterprise-modules/clipboard/src/version.ts
var VERSION = "31.2.1";
var VERSION = "31.3.0";

@@ -910,0 +917,0 @@ // enterprise-modules/clipboard/src/clipboardModule.ts

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

var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(e,t)=>{for(var r in t)__defProp(e,r,{get:t[r],enumerable:!0})},__copyProps=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of __getOwnPropNames(t))!__hasOwnProp.call(e,o)&&o!==r&&__defProp(e,o,{get:()=>t[o],enumerable:!(s=__getOwnPropDesc(t,o))||s.enumerable});return e},__toCommonJS=e=>__copyProps(__defProp({},"__esModule",{value:!0}),e),__decorateClass=(e,t,r,s)=>{for(var o=s>1?void 0:s?__getOwnPropDesc(t,r):t,i=e.length-1,l;i>=0;i--)(l=e[i])&&(o=(s?l(t,r,o):l(o))||o);return s&&o&&__defProp(t,r,o),o},main_exports={};__export(main_exports,{ClipboardModule:()=>ClipboardModule}),module.exports=__toCommonJS(main_exports);var import_core2=require("@ag-grid-community/core"),import_core3=require("@ag-grid-enterprise/core"),import_csv_export=require("@ag-grid-community/csv-export"),import_core=require("@ag-grid-community/core"),SOURCE_PASTE="paste",EXPORT_TYPE_DRAG_COPY="dragCopy",EXPORT_TYPE_CLIPBOARD="clipboard",apiError=e=>`AG Grid: Unable to use the Clipboard API (navigator.clipboard.${e}()). 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.`,ClipboardService=class extends import_core.BeanStub{constructor(){super(...arguments),this.lastPasteOperationTime=0,this.navigatorApiFailed=!1}init(){this.logger=this.loggerFactory.create("ClipboardService"),this.rowModel.getType()==="clientSide"&&(this.clientSideRowModel=this.rowModel),this.ctrlsService.whenReady(e=>{this.gridCtrl=e.gridCtrl})}pasteFromClipboard(){this.logger.log("pasteFromClipboard"),!this.gridOptionsService.get("suppressClipboardApi")&&!this.navigatorApiFailed&&navigator.clipboard&&navigator.clipboard.readText?navigator.clipboard.readText().then(this.processClipboardData.bind(this)).catch(t=>{import_core._.doOnce(()=>{console.warn(t),console.warn(apiError("readText"))},"clipboardApiError"),this.navigatorApiFailed=!0,this.pasteFromClipboardLegacy()}):this.pasteFromClipboardLegacy()}pasteFromClipboardLegacy(){let e=!1;const t=r=>{const s=new Date().getTime();s-this.lastPasteOperationTime<50&&(e=!0,r.preventDefault()),this.lastPasteOperationTime=s};this.executeOnTempElement(r=>{r.addEventListener("paste",t),r.focus({preventScroll:!0})},r=>{const s=r.value;e?this.refocusLastFocusedCell():this.processClipboardData(s),r.removeEventListener("paste",t)})}refocusLastFocusedCell(){const e=this.focusService.getFocusedCell();e&&this.focusService.setFocusedCell({rowIndex:e.rowIndex,column:e.column,rowPinned:e.rowPinned,forceBrowserFocus:!0})}getClipboardDelimiter(){const e=this.gridOptionsService.get("clipboardDelimiter");return import_core._.exists(e)?e:" "}processClipboardData(e){if(e==null)return;let t=ClipboardService.stringToArray(e,this.getClipboardDelimiter());const r=this.gridOptionsService.getCallback("processDataFromClipboard");if(r&&(t=r({data:t})),t==null)return;this.gridOptionsService.get("suppressLastEmptyLineOnPaste")&&this.removeLastLineIfBlank(t);const s=(o,i,l,a)=>{this.rangeService&&this.rangeService.isMoreThanOneCell()&&!this.hasOnlyOneValueToPaste(t)?this.pasteIntoActiveRange(t,o,i,a):this.pasteStartingFromFocusedCell(t,o,i,l,a)};this.doPasteOperation(s)}static stringToArray(e,t=","){const r=[],s=i=>i==="\r"||i===`
`;let o=!1;if(e==="")return[[""]];for(let i=0,l=0,a=0;a<e.length;a++){const c=e[a-1],n=e[a],p=e[a+1],d=()=>{r[i]||(r[i]=[]),r[i][l]||(r[i][l]="")};if(d(),n==='"'&&(o?p==='"'?(r[i][l]+='"',a++):o=!1:(c===void 0||c===t||s(c))&&(o=!0)),!o&&n!=='"'){if(n===t){l++,d();continue}else if(s(n)){l=0,i++,d(),n==="\r"&&p===`
`&&a++;continue}}r[i][l]+=n}return r}doPasteOperation(e){const t="clipboard";this.eventService.dispatchEvent({type:import_core.Events.EVENT_PASTE_START,source:t});let r;if(this.clientSideRowModel){const c=this.gridOptionsService.get("aggregateOnlyChangedColumns");r=new import_core.ChangedPath(c,this.clientSideRowModel.getRootNode())}const s={},o=[],i=this.focusService.getFocusedCell();e(s,o,i,r);const l=[...o];r&&(this.clientSideRowModel.doAggregate(r),r.forEachChangedNodeDepthFirst(c=>{l.push(c)})),this.rowRenderer.refreshCells({rowNodes:l}),this.dispatchFlashCells(s),this.fireRowChanged(o),this.refocusLastFocusedCell();const a={type:import_core.Events.EVENT_PASTE_END,source:t};this.eventService.dispatchEvent(a)}pasteIntoActiveRange(e,t,r,s){const o=this.getRangeSize()%e.length!=0;let i=0,l=0;const a=(c,n,p,d)=>{if(d-i>=e.length){if(o)return;i+=l,l=0}const h=e[d-i];r.push(n);const C=this.gridOptionsService.getCallback("processCellFromClipboard");p.forEach((g,v)=>{if(!g.isCellEditable(n)||g.isSuppressPaste(n))return;v>=h.length&&(v=v%h.length);const f=this.processCell(n,g,h[v],EXPORT_TYPE_DRAG_COPY,C,!0);n.setDataValue(g,f,SOURCE_PASTE),s&&s.addParentNode(n.parent,[g]);const{rowIndex:S,rowPinned:w}=c,m=this.cellPositionUtils.createIdFromValues({rowIndex:S,column:g,rowPinned:w});t[m]=!0}),l++};this.iterateActiveRanges(!1,a)}pasteStartingFromFocusedCell(e,t,r,s,o){if(!s)return;const i={rowIndex:s.rowIndex,rowPinned:s.rowPinned},l=this.columnModel.getDisplayedColumnsStartingAt(s.column);this.isPasteSingleValueIntoRange(e)?this.pasteSingleValueIntoRange(e,r,t,o):this.pasteMultipleValues(e,i,r,l,t,EXPORT_TYPE_CLIPBOARD,o)}isPasteSingleValueIntoRange(e){return this.hasOnlyOneValueToPaste(e)&&this.rangeService!=null&&!this.rangeService.isEmpty()}pasteSingleValueIntoRange(e,t,r,s){const o=e[0][0],i=(l,a,c)=>{t.push(a),c.forEach(n=>this.updateCellValue(a,n,o,r,EXPORT_TYPE_CLIPBOARD,s))};this.iterateActiveRanges(!1,i)}hasOnlyOneValueToPaste(e){return e.length===1&&e[0].length===1}copyRangeDown(){if(!this.rangeService||this.rangeService.isEmpty())return;const e=[],t=(r,s,o,i)=>{const l=this.gridOptionsService.getCallback("processCellForClipboard"),a=this.gridOptionsService.getCallback("processCellFromClipboard"),c=(n,p,d)=>{e.length?(s.push(p),d.forEach((u,h)=>{if(!u.isCellEditable(p)||u.isSuppressPaste(p))return;const C=this.processCell(p,u,e[h],EXPORT_TYPE_DRAG_COPY,a,!0);p.setDataValue(u,C,SOURCE_PASTE),i&&i.addParentNode(p.parent,[u]);const{rowIndex:g,rowPinned:v}=n,f=this.cellPositionUtils.createIdFromValues({rowIndex:g,column:u,rowPinned:v});r[f]=!0})):d.forEach(u=>{const h=this.processCell(p,u,this.valueService.getValue(u,p),EXPORT_TYPE_DRAG_COPY,l,!1,!0);e.push(h)})};this.iterateActiveRanges(!0,c)};this.doPasteOperation(t)}removeLastLineIfBlank(e){const t=import_core._.last(e);if(t&&t.length===1&&t[0]===""){if(e.length===1)return;import_core._.removeFromArray(e,t)}}fireRowChanged(e){this.gridOptionsService.get("editType")==="fullRow"&&e.forEach(t=>{const r={type:import_core.Events.EVENT_ROW_VALUE_CHANGED,node:t,data:t.data,rowIndex:t.rowIndex,rowPinned:t.rowPinned};this.eventService.dispatchEvent(r)})}pasteMultipleValues(e,t,r,s,o,i,l){let a=t;const c=this.clientSideRowModel!=null&&!this.gridOptionsService.get("enableGroupEdit")&&!this.gridOptionsService.get("treeData"),n=()=>{for(;;){if(!a)return null;const p=this.rowPositionUtils.getRowNode(a);if(a=this.cellNavigationService.getRowBelow({rowPinned:a.rowPinned,rowIndex:a.rowIndex}),p==null)return null;if(!(p.detail||p.footer||c&&p.group))return p}};e.forEach(p=>{const d=n();d&&(p.forEach((u,h)=>this.updateCellValue(d,s[h],u,o,i,l)),r.push(d))})}updateCellValue(e,t,r,s,o,i){if(!e||!t||!t.isCellEditable(e)||t.isSuppressPaste(e)||e.group&&t.isValueActive())return;const l=this.processCell(e,t,r,o,this.gridOptionsService.getCallback("processCellFromClipboard"),!0);e.setDataValue(t,l,SOURCE_PASTE);const{rowIndex:a,rowPinned:c}=e,n=this.cellPositionUtils.createIdFromValues({rowIndex:a,column:t,rowPinned:c});s[n]=!0,i&&i.addParentNode(e.parent,[t])}copyToClipboard(e={}){this.copyOrCutToClipboard(e)}cutToClipboard(e={},t="api"){if(this.gridOptionsService.get("suppressCutToClipboard"))return;const r={type:import_core.Events.EVENT_CUT_START,source:t};this.eventService.dispatchEvent(r),this.copyOrCutToClipboard(e,!0);const s={type:import_core.Events.EVENT_CUT_END,source:t};this.eventService.dispatchEvent(s)}copyOrCutToClipboard(e,t){let{includeHeaders:r,includeGroupHeaders:s}=e;this.logger.log(`copyToClipboard: includeHeaders = ${r}`),r==null&&(r=this.gridOptionsService.get("copyHeadersToClipboard")),s==null&&(s=this.gridOptionsService.get("copyGroupHeadersToClipboard"));const o={includeHeaders:r,includeGroupHeaders:s},i=!this.gridOptionsService.get("suppressCopyRowsToClipboard");let l=null;this.rangeService&&!this.rangeService.isEmpty()&&!this.shouldSkipSingleCellRange()?(this.copySelectedRangeToClipboard(o),l=0):i&&!this.selectionService.isEmpty()?(this.copySelectedRowsToClipboard(o),l=1):this.focusService.isAnyCellFocused()&&(this.copyFocusedCellToClipboard(o),l=2),t&&l!==null&&this.clearCellsAfterCopy(l)}clearCellsAfterCopy(e){if(this.eventService.dispatchEvent({type:import_core.Events.EVENT_KEY_SHORTCUT_CHANGED_CELL_START}),e===0)this.rangeService.clearCellRangeCellValues({cellEventSource:"clipboardService"});else if(e===1)this.clearSelectedRows();else{const t=this.focusService.getFocusedCell();if(t==null)return;const r=this.rowPositionUtils.getRowNode(t);r&&this.clearCellValue(r,t.column)}this.eventService.dispatchEvent({type:import_core.Events.EVENT_KEY_SHORTCUT_CHANGED_CELL_END})}clearSelectedRows(){const e=this.selectionService.getSelectedNodes(),t=this.columnModel.getAllDisplayedColumns();for(const r of e)for(const s of t)this.clearCellValue(r,s)}clearCellValue(e,t){t.isCellEditable(e)&&e.setDataValue(t,null,"clipboardService")}shouldSkipSingleCellRange(){return this.gridOptionsService.get("suppressCopySingleCellRanges")&&!this.rangeService.isMoreThanOneCell()}iterateActiveRanges(e,t,r){if(!this.rangeService||this.rangeService.isEmpty())return;const s=this.rangeService.getCellRanges();e?this.iterateActiveRange(s[0],t,r,!0):s.forEach((o,i)=>this.iterateActiveRange(o,t,r,i===s.length-1))}iterateActiveRange(e,t,r,s){if(!this.rangeService)return;let o=this.rangeService.getRangeStartRow(e);const i=this.rangeService.getRangeEndRow(e);r&&e.columns&&r(e.columns);let l=0,a=!1;for(;!a&&o!=null;){const c=this.rowPositionUtils.getRowNode(o);a=this.rowPositionUtils.sameRow(o,i),t(o,c,e.columns,l++,a&&s),o=this.cellNavigationService.getRowBelow(o)}}copySelectedRangeToClipboard(e={}){if(!this.rangeService||this.rangeService.isEmpty())return;const t=this.rangeService.areAllRangesAbleToMerge(),{data:r,cellsToFlash:s}=t?this.buildDataFromMergedRanges(e):this.buildDataFromRanges(e);this.copyDataToClipboard(r),this.dispatchFlashCells(s)}buildDataFromMergedRanges(e){const t=new Set,r=this.rangeService.getCellRanges(),s=new Map,o=[],i={};r.forEach(n=>{n.columns.forEach(u=>t.add(u));const{rowPositions:p,cellsToFlash:d}=this.getRangeRowPositionsAndCellsToFlash(n);p.forEach(u=>{const h=`${u.rowIndex}-${u.rowPinned||"null"}`;s.get(h)||(s.set(h,!0),o.push(u))}),Object.assign(i,d)});const l=this.columnModel.getAllDisplayedColumns(),a=Array.from(t);return a.sort((n,p)=>{const d=l.indexOf(n),u=l.indexOf(p);return d-u}),{data:this.buildExportParams({columns:a,rowPositions:o,includeHeaders:e.includeHeaders,includeGroupHeaders:e.includeGroupHeaders}),cellsToFlash:i}}buildDataFromRanges(e){const t=this.rangeService.getCellRanges(),r=[],s={};return t.forEach(o=>{const{rowPositions:i,cellsToFlash:l}=this.getRangeRowPositionsAndCellsToFlash(o);Object.assign(s,l),r.push(this.buildExportParams({columns:o.columns,rowPositions:i,includeHeaders:e.includeHeaders,includeGroupHeaders:e.includeGroupHeaders}))}),{data:r.join(`
`),cellsToFlash:s}}getRangeRowPositionsAndCellsToFlash(e){const t=[],r={},s=this.rangeService.getRangeStartRow(e),o=this.rangeService.getRangeEndRow(e);let i=s;for(;i&&(t.push(i),e.columns.forEach(l=>{const{rowIndex:a,rowPinned:c}=i,n=this.cellPositionUtils.createIdFromValues({rowIndex:a,column:l,rowPinned:c});r[n]=!0}),!this.rowPositionUtils.sameRow(i,o));)i=this.cellNavigationService.getRowBelow(i);return{rowPositions:t,cellsToFlash:r}}getCellsToFlashFromRowNodes(e){const t=this.columnModel.getAllDisplayedColumns(),r={};for(let s=0;s<e.length;s++){const{rowIndex:o,rowPinned:i}=e[s];if(o!=null)for(let l=0;l<t.length;l++){const a=t[l],c=this.cellPositionUtils.createIdFromValues({rowIndex:o,column:a,rowPinned:i});r[c]=!0}}return r}copyFocusedCellToClipboard(e={}){const t=this.focusService.getFocusedCell();if(t==null)return;const r=this.cellPositionUtils.createId(t),s={rowPinned:t.rowPinned,rowIndex:t.rowIndex},o=t.column,i=this.buildExportParams({columns:[o],rowPositions:[s],includeHeaders:e.includeHeaders,includeGroupHeaders:e.includeGroupHeaders});this.copyDataToClipboard(i),this.dispatchFlashCells({[r]:!0})}copySelectedRowsToClipboard(e={}){const{columnKeys:t,includeHeaders:r,includeGroupHeaders:s}=e,o=this.buildExportParams({columns:t,includeHeaders:r,includeGroupHeaders:s});this.copyDataToClipboard(o);const i=this.selectionService.getSelectedNodes()||[];this.dispatchFlashCells(this.getCellsToFlashFromRowNodes(i))}buildExportParams(e){const{columns:t,rowPositions:r,includeHeaders:s=!1,includeGroupHeaders:o=!1}=e,i={columnKeys:t,rowPositions:r,skipColumnHeaders:!s,skipColumnGroupHeaders:!o,suppressQuotes:!0,columnSeparator:this.getClipboardDelimiter(),onlySelected:!r,processCellCallback:this.gridOptionsService.getCallback("processCellForClipboard"),processRowGroupCallback:l=>this.processRowGroupCallback(l),processHeaderCallback:this.gridOptionsService.getCallback("processHeaderForClipboard"),processGroupHeaderCallback:this.gridOptionsService.getCallback("processGroupHeaderForClipboard")};return this.csvCreator.getDataAsCsv(i,!0)}processRowGroupCallback(e){const{node:t,column:r}=e,s=this.gridOptionsService.get("treeData"),o=this.gridOptionsService.get("suppressGroupMaintainValueType");let l=(()=>{var c,n;if(s||o||!r)return t.key;const p=(c=t.groupData)==null?void 0:c[r.getId()];return!p||!t.rowGroupColumn||t.rowGroupColumn.getColDef().useValueFormatterForExport===!1?p:(n=this.valueFormatterService.formatValue(t.rowGroupColumn,t,p))!=null?n:p})();if(e.node.footer){let c="";l&&l.length&&(c=` ${l}`),l=`Total${c}`}const a=this.gridOptionsService.getCallback("processCellForClipboard");if(a){let c=t.rowGroupColumn;return!c&&t.footer&&t.level===-1&&(c=this.columnModel.getRowGroupColumns()[0]),a({value:l,node:t,column:c,type:"clipboard",formatValue:n=>{var p;return(p=this.valueFormatterService.formatValue(c,t,n))!=null?p:n},parseValue:n=>this.valueParserService.parseValue(c,t,n,this.valueService.getValue(c,t))})}return l}dispatchFlashCells(e){window.setTimeout(()=>{const t={type:import_core.Events.EVENT_FLASH_CELLS,cells:e};this.eventService.dispatchEvent(t)},0)}processCell(e,t,r,s,o,i,l){var a;return o?o({column:t,node:e,value:r,type:s,formatValue:n=>{var p;return(p=this.valueFormatterService.formatValue(t,e??null,n))!=null?p:n},parseValue:n=>this.valueParserService.parseValue(t,e??null,n,this.valueService.getValue(t,e))}):i&&t.getColDef().useValueParserForImport!==!1?this.valueParserService.parseValue(t,e??null,r,this.valueService.getValue(t,e)):l&&t.getColDef().useValueFormatterForExport!==!1&&(a=this.valueFormatterService.formatValue(t,e??null,r))!=null?a:r}copyDataToClipboard(e){const t=this.gridOptionsService.getCallback("sendToClipboard");if(t){t({data:e});return}if(!this.gridOptionsService.get("suppressClipboardApi")&&navigator.clipboard){navigator.clipboard.writeText(e).catch(s=>{import_core._.doOnce(()=>{console.warn(s),console.warn(apiError("writeText"))},"clipboardApiError"),this.copyDataToClipboardLegacy(e)});return}this.copyDataToClipboardLegacy(e)}copyDataToClipboardLegacy(e){this.executeOnTempElement(t=>{const r=this.gridOptionsService.getDocument(),s=r.activeElement;t.value=e||" ",t.select(),t.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."),s!=null&&s.focus!=null&&s.focus({preventScroll:!0})})}executeOnTempElement(e,t){const r=this.gridOptionsService.getDocument(),s=r.createElement("textarea");s.style.width="1px",s.style.height="1px",s.style.top=r.documentElement.scrollTop+"px",s.style.left=r.documentElement.scrollLeft+"px",s.style.position="absolute",s.style.opacity="0";const o=this.gridCtrl.getGui();o.appendChild(s);try{e(s)}catch{console.warn("AG Grid: Browser does not support document.execCommand('copy') for clipboard operations")}t?window.setTimeout(()=>{t(s),o.removeChild(s)},100):o.removeChild(s)}getRangeSize(){const e=this.rangeService.getCellRanges();let t=0,r=0;return e.length>0&&(t=this.rangeService.getRangeStartRow(e[0]).rowIndex,r=this.rangeService.getRangeEndRow(e[0]).rowIndex),t-r+1}};__decorateClass([(0,import_core.Autowired)("csvCreator")],ClipboardService.prototype,"csvCreator",2),__decorateClass([(0,import_core.Autowired)("loggerFactory")],ClipboardService.prototype,"loggerFactory",2),__decorateClass([(0,import_core.Autowired)("selectionService")],ClipboardService.prototype,"selectionService",2),__decorateClass([(0,import_core.Optional)("rangeService")],ClipboardService.prototype,"rangeService",2),__decorateClass([(0,import_core.Autowired)("rowModel")],ClipboardService.prototype,"rowModel",2),__decorateClass([(0,import_core.Autowired)("ctrlsService")],ClipboardService.prototype,"ctrlsService",2),__decorateClass([(0,import_core.Autowired)("valueService")],ClipboardService.prototype,"valueService",2),__decorateClass([(0,import_core.Autowired)("focusService")],ClipboardService.prototype,"focusService",2),__decorateClass([(0,import_core.Autowired)("rowRenderer")],ClipboardService.prototype,"rowRenderer",2),__decorateClass([(0,import_core.Autowired)("columnModel")],ClipboardService.prototype,"columnModel",2),__decorateClass([(0,import_core.Autowired)("cellNavigationService")],ClipboardService.prototype,"cellNavigationService",2),__decorateClass([(0,import_core.Autowired)("cellPositionUtils")],ClipboardService.prototype,"cellPositionUtils",2),__decorateClass([(0,import_core.Autowired)("rowPositionUtils")],ClipboardService.prototype,"rowPositionUtils",2),__decorateClass([(0,import_core.Autowired)("valueFormatterService")],ClipboardService.prototype,"valueFormatterService",2),__decorateClass([(0,import_core.Autowired)("valueParserService")],ClipboardService.prototype,"valueParserService",2),__decorateClass([import_core.PostConstruct],ClipboardService.prototype,"init",1),ClipboardService=__decorateClass([(0,import_core.Bean)("clipboardService")],ClipboardService);var VERSION="31.2.1",ClipboardModule={version:VERSION,moduleName:import_core2.ModuleNames.ClipboardModule,beans:[ClipboardService],dependantModules:[import_core3.EnterpriseCoreModule,import_csv_export.CsvExportModule]};
var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(t,e)=>{for(var s in e)__defProp(t,s,{get:e[s],enumerable:!0})},__copyProps=(t,e,s,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of __getOwnPropNames(e))!__hasOwnProp.call(t,r)&&r!==s&&__defProp(t,r,{get:()=>e[r],enumerable:!(o=__getOwnPropDesc(e,r))||o.enumerable});return t},__toCommonJS=t=>__copyProps(__defProp({},"__esModule",{value:!0}),t),__decorateClass=(t,e,s,o)=>{for(var r=o>1?void 0:o?__getOwnPropDesc(e,s):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(r=(o?i(e,s,r):i(r))||r);return o&&r&&__defProp(e,s,r),r},main_exports={};__export(main_exports,{ClipboardModule:()=>ClipboardModule}),module.exports=__toCommonJS(main_exports);var import_core2=require("@ag-grid-community/core"),import_core3=require("@ag-grid-enterprise/core"),import_csv_export=require("@ag-grid-community/csv-export"),import_core=require("@ag-grid-community/core"),SOURCE_PASTE="paste",EXPORT_TYPE_DRAG_COPY="dragCopy",EXPORT_TYPE_CLIPBOARD="clipboard",apiError=t=>`AG Grid: Unable to use the Clipboard API (navigator.clipboard.${t}()). 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.`,ClipboardService=class extends import_core.BeanStub{constructor(){super(...arguments),this.lastPasteOperationTime=0,this.navigatorApiFailed=!1}init(){this.logger=this.loggerFactory.create("ClipboardService"),this.rowModel.getType()==="clientSide"&&(this.clientSideRowModel=this.rowModel),this.ctrlsService.whenReady(t=>{this.gridCtrl=t.gridCtrl})}pasteFromClipboard(){this.logger.log("pasteFromClipboard"),!this.gos.get("suppressClipboardApi")&&!this.navigatorApiFailed&&navigator.clipboard&&navigator.clipboard.readText?navigator.clipboard.readText().then(this.processClipboardData.bind(this)).catch(e=>{import_core._.doOnce(()=>{console.warn(e),console.warn(apiError("readText"))},"clipboardApiError"),this.navigatorApiFailed=!0,this.pasteFromClipboardLegacy()}):this.pasteFromClipboardLegacy()}pasteFromClipboardLegacy(){let t=!1;const e=s=>{const o=new Date().getTime();o-this.lastPasteOperationTime<50&&(t=!0,s.preventDefault()),this.lastPasteOperationTime=o};this.executeOnTempElement(s=>{s.addEventListener("paste",e),s.focus({preventScroll:!0})},s=>{const o=s.value;t?this.refocusLastFocusedCell():this.processClipboardData(o),s.removeEventListener("paste",e)})}refocusLastFocusedCell(){const t=this.focusService.getFocusedCell();t&&this.focusService.setFocusedCell({rowIndex:t.rowIndex,column:t.column,rowPinned:t.rowPinned,forceBrowserFocus:!0})}getClipboardDelimiter(){const t=this.gos.get("clipboardDelimiter");return import_core._.exists(t)?t:" "}processClipboardData(t){if(t==null)return;let e=ClipboardService.stringToArray(t,this.getClipboardDelimiter());const s=this.gos.getCallback("processDataFromClipboard");if(s&&(e=s({data:e})),e==null)return;this.gos.get("suppressLastEmptyLineOnPaste")&&this.removeLastLineIfBlank(e);const o=(r,l,i,a)=>{var c;((c=this.rangeService)==null?void 0:c.isMoreThanOneCell())&&!this.hasOnlyOneValueToPaste(e)?this.pasteIntoActiveRange(this.rangeService,e,r,l,a):this.pasteStartingFromFocusedCell(e,r,l,i,a)};this.doPasteOperation(o)}static stringToArray(t,e=","){const s=[],o=l=>l==="\r"||l===`
`;let r=!1;if(t==="")return[[""]];for(let l=0,i=0,a=0;a<t.length;a++){const c=t[a-1],u=t[a],n=t[a+1],d=()=>{s[l]||(s[l]=[]),s[l][i]||(s[l][i]="")};if(d(),u==='"'&&(r?n==='"'?(s[l][i]+='"',a++):r=!1:(c===void 0||c===e||o(c))&&(r=!0)),!r&&u!=='"'){if(u===e){i++,d();continue}else if(o(u)){i=0,l++,d(),u==="\r"&&n===`
`&&a++;continue}}s[l][i]+=u}return s}doPasteOperation(t){const e="clipboard";this.eventService.dispatchEvent({type:import_core.Events.EVENT_PASTE_START,source:e});let s;if(this.clientSideRowModel){const c=this.gos.get("aggregateOnlyChangedColumns");s=new import_core.ChangedPath(c,this.clientSideRowModel.getRootNode())}const o={},r=[],l=this.focusService.getFocusedCell();t(o,r,l,s);const i=[...r];s&&(this.clientSideRowModel.doAggregate(s),s.forEachChangedNodeDepthFirst(c=>{i.push(c)})),this.rowRenderer.refreshCells({rowNodes:i}),this.dispatchFlashCells(o),this.fireRowChanged(r),this.refocusLastFocusedCell();const a={type:import_core.Events.EVENT_PASTE_END,source:e};this.eventService.dispatchEvent(a)}pasteIntoActiveRange(t,e,s,o,r){const l=this.getRangeSize(t)%e.length!=0;let i=0,a=0;const c=(u,n,d,p)=>{if(p-i>=e.length){if(l)return;i+=a,a=0}const g=e[p-i];o.push(n);const f=this.gos.getCallback("processCellFromClipboard");d.forEach((C,v)=>{if(!C.isCellEditable(n)||C.isSuppressPaste(n))return;v>=g.length&&(v=v%g.length);const w=this.processCell(n,C,g[v],EXPORT_TYPE_DRAG_COPY,f,!0);n.setDataValue(C,w,SOURCE_PASTE),r&&r.addParentNode(n.parent,[C]);const{rowIndex:m,rowPinned:b}=u,S=this.cellPositionUtils.createIdFromValues({rowIndex:m,column:C,rowPinned:b});s[S]=!0}),a++};this.iterateActiveRanges(!1,c)}getDisplayedColumnsStartingAt(t){let e=t;const s=[];for(;e!=null;)s.push(e),e=this.columnModel.getDisplayedColAfter(e);return s}pasteStartingFromFocusedCell(t,e,s,o,r){if(!o)return;const l={rowIndex:o.rowIndex,rowPinned:o.rowPinned},i=this.getDisplayedColumnsStartingAt(o.column);this.isPasteSingleValueIntoRange(t)?this.pasteSingleValueIntoRange(t,s,e,r):this.pasteMultipleValues(t,l,s,i,e,EXPORT_TYPE_CLIPBOARD,r)}isPasteSingleValueIntoRange(t){return this.hasOnlyOneValueToPaste(t)&&this.rangeService!=null&&!this.rangeService.isEmpty()}pasteSingleValueIntoRange(t,e,s,o){const r=t[0][0],l=(i,a,c)=>{e.push(a),c.forEach(u=>this.updateCellValue(a,u,r,s,EXPORT_TYPE_CLIPBOARD,o))};this.iterateActiveRanges(!1,l)}hasOnlyOneValueToPaste(t){return t.length===1&&t[0].length===1}copyRangeDown(){if(!this.rangeService||this.rangeService.isEmpty())return;const t=[],e=(s,o,r,l)=>{const i=this.gos.getCallback("processCellForClipboard"),a=this.gos.getCallback("processCellFromClipboard"),c=(u,n,d)=>{t.length?(o.push(n),d.forEach((p,h)=>{if(!p.isCellEditable(n)||p.isSuppressPaste(n))return;const g=this.processCell(n,p,t[h],EXPORT_TYPE_DRAG_COPY,a,!0);n.setDataValue(p,g,SOURCE_PASTE),l&&l.addParentNode(n.parent,[p]);const{rowIndex:f,rowPinned:C}=u,v=this.cellPositionUtils.createIdFromValues({rowIndex:f,column:p,rowPinned:C});s[v]=!0})):d.forEach(p=>{const h=this.processCell(n,p,this.valueService.getValue(p,n),EXPORT_TYPE_DRAG_COPY,i,!1,!0);t.push(h)})};this.iterateActiveRanges(!0,c)};this.doPasteOperation(e)}removeLastLineIfBlank(t){const e=import_core._.last(t);if(e&&e.length===1&&e[0]===""){if(t.length===1)return;import_core._.removeFromArray(t,e)}}fireRowChanged(t){this.gos.get("editType")==="fullRow"&&t.forEach(e=>{const s={type:import_core.Events.EVENT_ROW_VALUE_CHANGED,node:e,data:e.data,rowIndex:e.rowIndex,rowPinned:e.rowPinned};this.eventService.dispatchEvent(s)})}pasteMultipleValues(t,e,s,o,r,l,i){let a=e;const c=this.clientSideRowModel!=null&&!this.gos.get("enableGroupEdit")&&!this.gos.get("treeData"),u=()=>{for(;;){if(!a)return null;const n=this.rowPositionUtils.getRowNode(a);if(a=this.cellNavigationService.getRowBelow({rowPinned:a.rowPinned,rowIndex:a.rowIndex}),n==null)return null;if(!(n.detail||n.footer||c&&n.group))return n}};t.forEach(n=>{const d=u();d&&(n.forEach((p,h)=>this.updateCellValue(d,o[h],p,r,l,i)),s.push(d))})}updateCellValue(t,e,s,o,r,l){if(!t||!e||!e.isCellEditable(t)||e.isSuppressPaste(t)||t.group&&e.isValueActive())return;const i=this.processCell(t,e,s,r,this.gos.getCallback("processCellFromClipboard"),!0);t.setDataValue(e,i,SOURCE_PASTE);const{rowIndex:a,rowPinned:c}=t,u=this.cellPositionUtils.createIdFromValues({rowIndex:a,column:e,rowPinned:c});o[u]=!0,l&&l.addParentNode(t.parent,[e])}copyToClipboard(t={}){this.copyOrCutToClipboard(t)}cutToClipboard(t={},e="api"){if(this.gos.get("suppressCutToClipboard"))return;const s={type:import_core.Events.EVENT_CUT_START,source:e};this.eventService.dispatchEvent(s),this.copyOrCutToClipboard(t,!0);const o={type:import_core.Events.EVENT_CUT_END,source:e};this.eventService.dispatchEvent(o)}copyOrCutToClipboard(t,e){let{includeHeaders:s,includeGroupHeaders:o}=t;this.logger.log(`copyToClipboard: includeHeaders = ${s}`),s==null&&(s=this.gos.get("copyHeadersToClipboard")),o==null&&(o=this.gos.get("copyGroupHeadersToClipboard"));const r={includeHeaders:s,includeGroupHeaders:o},l=!this.gos.get("suppressCopyRowsToClipboard");let i=null;this.rangeService&&!this.rangeService.isEmpty()&&!this.shouldSkipSingleCellRange(this.rangeService)?(this.copySelectedRangeToClipboard(r),i=0):l&&!this.selectionService.isEmpty()?(this.copySelectedRowsToClipboard(r),i=1):this.focusService.isAnyCellFocused()&&(this.copyFocusedCellToClipboard(r),i=2),e&&i!==null&&this.clearCellsAfterCopy(i)}clearCellsAfterCopy(t){if(this.eventService.dispatchEvent({type:import_core.Events.EVENT_KEY_SHORTCUT_CHANGED_CELL_START}),t===0)this.rangeService.clearCellRangeCellValues({cellEventSource:"clipboardService"});else if(t===1)this.clearSelectedRows();else{const e=this.focusService.getFocusedCell();if(e==null)return;const s=this.rowPositionUtils.getRowNode(e);s&&this.clearCellValue(s,e.column)}this.eventService.dispatchEvent({type:import_core.Events.EVENT_KEY_SHORTCUT_CHANGED_CELL_END})}clearSelectedRows(){const t=this.selectionService.getSelectedNodes(),e=this.columnModel.getAllDisplayedColumns();for(const s of t)for(const o of e)this.clearCellValue(s,o)}clearCellValue(t,e){var s;if(!e.isCellEditable(t))return;const o=(s=this.valueService.parseValue(e,t,"",t.getValueFromValueService(e)))!=null?s:null;t.setDataValue(e,o,"clipboardService")}shouldSkipSingleCellRange(t){return this.gos.get("suppressCopySingleCellRanges")&&!t.isMoreThanOneCell()}iterateActiveRanges(t,e,s){if(!this.rangeService||this.rangeService.isEmpty())return;const o=this.rangeService.getCellRanges();t?this.iterateActiveRange(o[0],e,s,!0):o.forEach((r,l)=>this.iterateActiveRange(r,e,s,l===o.length-1))}iterateActiveRange(t,e,s,o){if(!this.rangeService)return;let r=this.rangeService.getRangeStartRow(t);const l=this.rangeService.getRangeEndRow(t);s&&t.columns&&s(t.columns);let i=0,a=!1;for(;!a&&r!=null;){const c=this.rowPositionUtils.getRowNode(r);a=this.rowPositionUtils.sameRow(r,l),e(r,c,t.columns,i++,a&&o),r=this.cellNavigationService.getRowBelow(r)}}copySelectedRangeToClipboard(t={}){if(!this.rangeService||this.rangeService.isEmpty())return;const e=this.rangeService.areAllRangesAbleToMerge(),{data:s,cellsToFlash:o}=e?this.buildDataFromMergedRanges(this.rangeService,t):this.buildDataFromRanges(this.rangeService,t);this.copyDataToClipboard(s),this.dispatchFlashCells(o)}buildDataFromMergedRanges(t,e){const s=new Set,o=t.getCellRanges(),r=new Map,l=[],i={};o.forEach(n=>{n.columns.forEach(h=>s.add(h));const{rowPositions:d,cellsToFlash:p}=this.getRangeRowPositionsAndCellsToFlash(t,n);d.forEach(h=>{const g=`${h.rowIndex}-${h.rowPinned||"null"}`;r.get(g)||(r.set(g,!0),l.push(h))}),Object.assign(i,p)});const a=this.columnModel.getAllDisplayedColumns(),c=Array.from(s);return c.sort((n,d)=>{const p=a.indexOf(n),h=a.indexOf(d);return p-h}),{data:this.buildExportParams({columns:c,rowPositions:l,includeHeaders:e.includeHeaders,includeGroupHeaders:e.includeGroupHeaders}),cellsToFlash:i}}buildDataFromRanges(t,e){const s=t.getCellRanges(),o=[],r={};return s.forEach(l=>{const{rowPositions:i,cellsToFlash:a}=this.getRangeRowPositionsAndCellsToFlash(t,l);Object.assign(r,a),o.push(this.buildExportParams({columns:l.columns,rowPositions:i,includeHeaders:e.includeHeaders,includeGroupHeaders:e.includeGroupHeaders}))}),{data:o.join(`
`),cellsToFlash:r}}getRangeRowPositionsAndCellsToFlash(t,e){const s=[],o={},r=t.getRangeStartRow(e),l=t.getRangeEndRow(e);let i=r;for(;i&&(s.push(i),e.columns.forEach(a=>{const{rowIndex:c,rowPinned:u}=i,n=this.cellPositionUtils.createIdFromValues({rowIndex:c,column:a,rowPinned:u});o[n]=!0}),!this.rowPositionUtils.sameRow(i,l));)i=this.cellNavigationService.getRowBelow(i);return{rowPositions:s,cellsToFlash:o}}getCellsToFlashFromRowNodes(t){const e=this.columnModel.getAllDisplayedColumns(),s={};for(let o=0;o<t.length;o++){const{rowIndex:r,rowPinned:l}=t[o];if(r!=null)for(let i=0;i<e.length;i++){const a=e[i],c=this.cellPositionUtils.createIdFromValues({rowIndex:r,column:a,rowPinned:l});s[c]=!0}}return s}copyFocusedCellToClipboard(t={}){const e=this.focusService.getFocusedCell();if(e==null)return;const s=this.cellPositionUtils.createId(e),o={rowPinned:e.rowPinned,rowIndex:e.rowIndex},r=e.column,l=this.buildExportParams({columns:[r],rowPositions:[o],includeHeaders:t.includeHeaders,includeGroupHeaders:t.includeGroupHeaders});this.copyDataToClipboard(l),this.dispatchFlashCells({[s]:!0})}copySelectedRowsToClipboard(t={}){const{columnKeys:e,includeHeaders:s,includeGroupHeaders:o}=t,r=this.buildExportParams({columns:e,includeHeaders:s,includeGroupHeaders:o});this.copyDataToClipboard(r);const l=this.selectionService.getSelectedNodes()||[];this.dispatchFlashCells(this.getCellsToFlashFromRowNodes(l))}buildExportParams(t){const{columns:e,rowPositions:s,includeHeaders:o=!1,includeGroupHeaders:r=!1}=t,l={columnKeys:e,rowPositions:s,skipColumnHeaders:!o,skipColumnGroupHeaders:!r,suppressQuotes:!0,columnSeparator:this.getClipboardDelimiter(),onlySelected:!s,processCellCallback:this.gos.getCallback("processCellForClipboard"),processRowGroupCallback:i=>this.processRowGroupCallback(i),processHeaderCallback:this.gos.getCallback("processHeaderForClipboard"),processGroupHeaderCallback:this.gos.getCallback("processGroupHeaderForClipboard")};return this.csvCreator.getDataAsCsv(l,!0)}processRowGroupCallback(t){const{node:e,column:s}=t,o=this.gos.get("treeData"),r=this.gos.get("suppressGroupMaintainValueType");let i=(()=>{var c,u;if(o||r||!s)return e.key;const n=(c=e.groupData)==null?void 0:c[s.getId()];return!n||!e.rowGroupColumn||e.rowGroupColumn.getColDef().useValueFormatterForExport===!1?n:(u=this.valueService.formatValue(e.rowGroupColumn,e,n))!=null?u:n})();if(t.node.footer){let c="";i&&i.length&&(c=` ${i}`),i=`Total${c}`}const a=this.gos.getCallback("processCellForClipboard");if(a){let c=e.rowGroupColumn;return!c&&e.footer&&e.level===-1&&(c=this.columnModel.getRowGroupColumns()[0]),a({value:i,node:e,column:c,type:"clipboard",formatValue:u=>{var n;return(n=this.valueService.formatValue(c,e,u))!=null?n:u},parseValue:u=>this.valueService.parseValue(c,e,u,this.valueService.getValue(c,e))})}return i}dispatchFlashCells(t){window.setTimeout(()=>{const e={type:import_core.Events.EVENT_FLASH_CELLS,cells:t};this.eventService.dispatchEvent(e)},0)}processCell(t,e,s,o,r,l,i){var a;return r?r({column:e,node:t,value:s,type:o,formatValue:u=>{var n;return(n=this.valueService.formatValue(e,t??null,u))!=null?n:u},parseValue:u=>this.valueService.parseValue(e,t??null,u,this.valueService.getValue(e,t))}):l&&e.getColDef().useValueParserForImport!==!1?this.valueService.parseValue(e,t??null,s,this.valueService.getValue(e,t)):i&&e.getColDef().useValueFormatterForExport!==!1&&(a=this.valueService.formatValue(e,t??null,s))!=null?a:s}copyDataToClipboard(t){const e=this.gos.getCallback("sendToClipboard");if(e){e({data:t});return}if(!this.gos.get("suppressClipboardApi")&&navigator.clipboard){navigator.clipboard.writeText(t).catch(o=>{import_core._.doOnce(()=>{console.warn(o),console.warn(apiError("writeText"))},"clipboardApiError"),this.copyDataToClipboardLegacy(t)});return}this.copyDataToClipboardLegacy(t)}copyDataToClipboardLegacy(t){this.executeOnTempElement(e=>{const s=this.gos.getDocument(),o=this.gos.getActiveDomElement();e.value=t||" ",e.select(),e.focus({preventScroll:!0}),s.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."),o!=null&&o.focus!=null&&o.focus({preventScroll:!0})})}executeOnTempElement(t,e){const s=this.gos.getDocument(),o=s.createElement("textarea");o.style.width="1px",o.style.height="1px",o.style.top=s.documentElement.scrollTop+"px",o.style.left=s.documentElement.scrollLeft+"px",o.style.position="absolute",o.style.opacity="0";const r=this.gridCtrl.getGui();r.appendChild(o);try{t(o)}catch{console.warn("AG Grid: Browser does not support document.execCommand('copy') for clipboard operations")}e?window.setTimeout(()=>{e(o),r.removeChild(o)},100):r.removeChild(o)}getRangeSize(t){const e=t.getCellRanges();let s=0,o=0;return e.length>0&&(s=t.getRangeStartRow(e[0]).rowIndex,o=t.getRangeEndRow(e[0]).rowIndex),s-o+1}};__decorateClass([(0,import_core.Autowired)("csvCreator")],ClipboardService.prototype,"csvCreator",2),__decorateClass([(0,import_core.Autowired)("loggerFactory")],ClipboardService.prototype,"loggerFactory",2),__decorateClass([(0,import_core.Autowired)("selectionService")],ClipboardService.prototype,"selectionService",2),__decorateClass([(0,import_core.Autowired)("rowModel")],ClipboardService.prototype,"rowModel",2),__decorateClass([(0,import_core.Autowired)("ctrlsService")],ClipboardService.prototype,"ctrlsService",2),__decorateClass([(0,import_core.Autowired)("valueService")],ClipboardService.prototype,"valueService",2),__decorateClass([(0,import_core.Autowired)("focusService")],ClipboardService.prototype,"focusService",2),__decorateClass([(0,import_core.Autowired)("rowRenderer")],ClipboardService.prototype,"rowRenderer",2),__decorateClass([(0,import_core.Autowired)("columnModel")],ClipboardService.prototype,"columnModel",2),__decorateClass([(0,import_core.Autowired)("cellNavigationService")],ClipboardService.prototype,"cellNavigationService",2),__decorateClass([(0,import_core.Autowired)("cellPositionUtils")],ClipboardService.prototype,"cellPositionUtils",2),__decorateClass([(0,import_core.Autowired)("rowPositionUtils")],ClipboardService.prototype,"rowPositionUtils",2),__decorateClass([(0,import_core.Optional)("rangeService")],ClipboardService.prototype,"rangeService",2),__decorateClass([import_core.PostConstruct],ClipboardService.prototype,"init",1),ClipboardService=__decorateClass([(0,import_core.Bean)("clipboardService")],ClipboardService);var VERSION="31.3.0",ClipboardModule={version:VERSION,moduleName:import_core2.ModuleNames.ClipboardModule,beans:[ClipboardService],dependantModules:[import_core3.EnterpriseCoreModule,import_csv_export.CsvExportModule]};
{
"name": "@ag-grid-enterprise/clipboard",
"version": "31.2.1",
"version": "31.3.0",
"description": "Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue",

@@ -15,5 +15,5 @@ "main": "./dist/package/main.cjs.js",

"dependencies": {
"@ag-grid-community/core": "31.2.1",
"@ag-grid-community/csv-export": "31.2.1",
"@ag-grid-enterprise/core": "31.2.1"
"@ag-grid-community/core": "31.3.0",
"@ag-grid-community/csv-export": "31.3.0",
"@ag-grid-enterprise/core": "31.3.0"
},

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

{
"name": "@ag-grid-enterprise/clipboard",
"version": "31.2.1",
"version": "31.3.0",
"description": "Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue",

@@ -15,5 +15,5 @@ "main": "./src/main.js",

"dependencies": {
"@ag-grid-community/core": "31.2.1",
"@ag-grid-community/csv-export": "31.2.1",
"@ag-grid-enterprise/core": "31.2.1"
"@ag-grid-community/core": "31.3.0",
"@ag-grid-community/csv-export": "31.3.0",
"@ag-grid-enterprise/core": "31.3.0"
},

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

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

private selectionService;
private rangeService;
private rowModel;

@@ -17,4 +16,3 @@ ctrlsService: CtrlsService;

rowPositionUtils: RowPositionUtils;
private valueFormatterService;
private valueParserService;
private rangeService?;
private clientSideRowModel;

@@ -34,2 +32,3 @@ private logger;

private pasteIntoActiveRange;
private getDisplayedColumnsStartingAt;
private pasteStartingFromFocusedCell;

@@ -36,0 +35,0 @@ private isPasteSingleValueIntoRange;

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

export declare const VERSION = "31.2.1";
export declare const VERSION = "31.3.0";
{
"name": "@ag-grid-enterprise/clipboard",
"version": "31.2.1",
"version": "31.3.0",
"description": "Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue",

@@ -15,5 +15,5 @@ "main": "./dist/package/main.cjs.js",

"dependencies": {
"@ag-grid-community/core": "31.2.1",
"@ag-grid-community/csv-export": "31.2.1",
"@ag-grid-enterprise/core": "31.2.1"
"@ag-grid-community/core": "31.3.0",
"@ag-grid-community/csv-export": "31.3.0",
"@ag-grid-enterprise/core": "31.3.0"
},

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

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc