Socket
Socket
Sign inDemoInstall

@ag-grid-enterprise/clipboard

Package Overview
Dependencies
4
Maintainers
3
Versions
60
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 31.2.0 to 31.2.1

2

dist/package/main.cjs.js

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

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

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

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.0",ClipboardModule={version:VERSION,moduleName:import_core2.ModuleNames.ClipboardModule,beans:[ClipboardService],dependantModules:[import_core3.EnterpriseCoreModule,import_csv_export.CsvExportModule]};
`),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]};
{
"name": "@ag-grid-enterprise/clipboard",
"version": "31.2.0",
"version": "31.2.1",
"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.0",
"@ag-grid-community/csv-export": "31.2.0",
"@ag-grid-enterprise/core": "31.2.0"
"@ag-grid-community/core": "31.2.1",
"@ag-grid-community/csv-export": "31.2.1",
"@ag-grid-enterprise/core": "31.2.1"
},

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

{
"name": "@ag-grid-enterprise/clipboard",
"version": "31.2.0",
"version": "31.2.1",
"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.0",
"@ag-grid-community/csv-export": "31.2.0",
"@ag-grid-enterprise/core": "31.2.0"
"@ag-grid-community/core": "31.2.1",
"@ag-grid-community/csv-export": "31.2.1",
"@ag-grid-enterprise/core": "31.2.1"
},

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

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

export declare const VERSION = "31.2.0";
export declare const VERSION = "31.2.1";
{
"name": "@ag-grid-enterprise/clipboard",
"version": "31.2.0",
"version": "31.2.1",
"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.0",
"@ag-grid-community/csv-export": "31.2.0",
"@ag-grid-enterprise/core": "31.2.0"
"@ag-grid-community/core": "31.2.1",
"@ag-grid-community/csv-export": "31.2.1",
"@ag-grid-enterprise/core": "31.2.1"
},

@@ -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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc