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.3.1 to 31.3.2

2

dist/package/main.cjs.js

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

// enterprise-modules/clipboard/src/version.ts
var VERSION = "31.3.1";
var VERSION = "31.3.2";

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

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

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

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

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

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

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

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