@toolbox-web/grid 3.8.3 → 3.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/all.d.ts +1 -0
  2. package/all.js +1 -1
  3. package/all.js.map +1 -1
  4. package/index.js +1 -1
  5. package/index.js.map +1 -1
  6. package/lib/core/plugin/base-plugin.d.ts +14 -0
  7. package/lib/core/plugin/plugin-manager.d.ts +5 -1
  8. package/lib/core/plugin/types.d.ts +2 -0
  9. package/lib/features/registry.js +1 -1
  10. package/lib/plugins/clipboard/index.js +1 -1
  11. package/lib/plugins/clipboard/index.js.map +1 -1
  12. package/lib/plugins/column-virtualization/index.js +1 -1
  13. package/lib/plugins/column-virtualization/index.js.map +1 -1
  14. package/lib/plugins/context-menu/index.js +1 -1
  15. package/lib/plugins/context-menu/index.js.map +1 -1
  16. package/lib/plugins/editing/index.js +1 -1
  17. package/lib/plugins/editing/index.js.map +1 -1
  18. package/lib/plugins/export/index.js +1 -1
  19. package/lib/plugins/export/index.js.map +1 -1
  20. package/lib/plugins/filtering/index.js +1 -1
  21. package/lib/plugins/filtering/index.js.map +1 -1
  22. package/lib/plugins/grouping-columns/index.js +1 -1
  23. package/lib/plugins/grouping-columns/index.js.map +1 -1
  24. package/lib/plugins/grouping-rows/grouping-rows-plugin.d.ts +20 -24
  25. package/lib/plugins/grouping-rows/grouping-rows.d.ts +9 -4
  26. package/lib/plugins/grouping-rows/index.d.ts +1 -1
  27. package/lib/plugins/grouping-rows/index.js +1 -1
  28. package/lib/plugins/grouping-rows/index.js.map +1 -1
  29. package/lib/plugins/grouping-rows/types.d.ts +32 -4
  30. package/lib/plugins/hierarchy/hierarchy-plugin.d.ts +79 -0
  31. package/lib/plugins/hierarchy/hierarchy.d.ts +28 -0
  32. package/lib/plugins/hierarchy/index.d.ts +9 -0
  33. package/lib/plugins/hierarchy/index.js +2 -0
  34. package/lib/plugins/hierarchy/index.js.map +1 -0
  35. package/lib/plugins/hierarchy/types.d.ts +92 -0
  36. package/lib/plugins/master-detail/index.js +1 -1
  37. package/lib/plugins/master-detail/index.js.map +1 -1
  38. package/lib/plugins/multi-sort/index.js +1 -1
  39. package/lib/plugins/multi-sort/index.js.map +1 -1
  40. package/lib/plugins/pinned-columns/index.js +1 -1
  41. package/lib/plugins/pinned-columns/index.js.map +1 -1
  42. package/lib/plugins/pinned-rows/index.js +1 -1
  43. package/lib/plugins/pinned-rows/index.js.map +1 -1
  44. package/lib/plugins/pivot/index.js +1 -1
  45. package/lib/plugins/pivot/index.js.map +1 -1
  46. package/lib/plugins/print/index.js +1 -1
  47. package/lib/plugins/print/index.js.map +1 -1
  48. package/lib/plugins/reorder-columns/index.js +1 -1
  49. package/lib/plugins/reorder-columns/index.js.map +1 -1
  50. package/lib/plugins/responsive/index.js +1 -1
  51. package/lib/plugins/responsive/index.js.map +1 -1
  52. package/lib/plugins/row-drag-drop/index.js +1 -1
  53. package/lib/plugins/row-drag-drop/index.js.map +1 -1
  54. package/lib/plugins/selection/index.js +1 -1
  55. package/lib/plugins/selection/index.js.map +1 -1
  56. package/lib/plugins/server-side/index.js +1 -1
  57. package/lib/plugins/server-side/index.js.map +1 -1
  58. package/lib/plugins/shell/index.js +1 -1
  59. package/lib/plugins/shell/index.js.map +1 -1
  60. package/lib/plugins/sticky-rows/index.js +1 -1
  61. package/lib/plugins/sticky-rows/index.js.map +1 -1
  62. package/lib/plugins/tooltip/index.js +1 -1
  63. package/lib/plugins/tooltip/index.js.map +1 -1
  64. package/lib/plugins/tree/index.js +1 -1
  65. package/lib/plugins/tree/index.js.map +1 -1
  66. package/lib/plugins/tree/tree-datasource.d.ts +7 -10
  67. package/lib/plugins/tree/tree-plugin.d.ts +23 -3
  68. package/lib/plugins/undo-redo/index.js +1 -1
  69. package/lib/plugins/undo-redo/index.js.map +1 -1
  70. package/lib/plugins/visibility/index.js +1 -1
  71. package/lib/plugins/visibility/index.js.map +1 -1
  72. package/package.json +1 -1
  73. package/umd/grid.all.umd.js +1 -1
  74. package/umd/grid.all.umd.js.map +1 -1
  75. package/umd/grid.umd.js +1 -1
  76. package/umd/grid.umd.js.map +1 -1
  77. package/umd/plugins/grouping-rows.umd.js +1 -1
  78. package/umd/plugins/grouping-rows.umd.js.map +1 -1
  79. package/umd/plugins/hierarchy.umd.js +2 -0
  80. package/umd/plugins/hierarchy.umd.js.map +1 -0
  81. package/umd/plugins/selection.umd.js +1 -1
  82. package/umd/plugins/selection.umd.js.map +1 -1
  83. package/umd/plugins/tree.umd.js +1 -1
  84. package/umd/plugins/tree.umd.js.map +1 -1
@@ -1,2 +1,2 @@
1
- var e=/* @__PURE__ */new WeakMap;function t(e){return"__proto__"===e||"constructor"===e||"prototype"===e}var r=/* @__PURE__ */new Map;function n(e){if(-1===e.indexOf("."))return null;let t=r.get(e);return void 0===t&&(t=Object.freeze(e.split(".")),r.set(e,t)),t}function o(e,r){let n=e;for(let o=0;o<r.length;o++){if(null==n||"object"!=typeof n)return;const e=r[o];if(t(e))return;n=n[e]}return n}function s(r,s,i=-1){if(!s.valueAccessor)return function(e,r){if(null==e)return;const s=n(r),i=e;return null===s?t(r)?void 0:i[r]:Object.prototype.hasOwnProperty.call(i,r)?i[r]:o(i,s)}(r,s.field);if("object"!=typeof r||null===r)return s.valueAccessor({row:r,column:s,rowIndex:i});const l=r,a=s.field;let c=e.get(l);if(c){const e=c.get(a);if(void 0!==e)return e.v}else c=/* @__PURE__ */new Map,e.set(l,c);const u=s.valueAccessor({row:r,column:s,rowIndex:i});return c.set(a,{v:u}),u}var i={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};function l(e,t){return`[tbw-grid${e?`#${e}`:""}${t?`:${t}`:""}]`}function a(e,t,r,n){return`${l(r,n)} ${e}: ${t}\n\n → More info: ${function(e){return`https://toolboxjs.com/grid/errors#${e.toLowerCase()}`}(e)}`}var c="__otorp__|__retteGenifed__|__retteSenifed__|rotcurtsnoc|wodniw|sihTlabolg|labolg|ssecorp|noitcnuF|tropmi|lave|tcelfeR|yxorP|rorrE|stnemugra|tnemucod|noitacol|eikooc|egarotSlacol|egarotSnoisses|BDdexedni|hctef|tseuqeRpttHLMX|tekcoSbeW|rekroW|rekroWderahS|rekroWecivreS|renepo|tnerap|pot|semarf|fles".split("|").map(e=>e.split("").reverse().join("")),u=(new RegExp(`__(proto|defineGetter|defineSetter)|${c.slice(3).join("|")}|this\\b`),new Set("script|iframe|object|embed|form|input|button|textarea|select|link|meta|base|style|template|slot|portal|frame|frameset|applet|noscript|noembed|plaintext|xmp|listing|math".split("|"))),f=/^on\w+$/i,d=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),p=/^\s*(javascript|vbscript|data|blob):/i;function h(e){const t=document.createElement("template");return e&&"string"==typeof e&&(t.innerHTML=e,function(e){const t=[],r=e.querySelectorAll("*");for(const n of r){const e=n.tagName.toLowerCase();if(u.has(e)){t.push(n);continue}if(("svg"===e||"http://www.w3.org/2000/svg"===n.namespaceURI)&&Array.from(n.attributes).some(e=>f.test(e.name)||"href"===e.name||"xlink:href"===e.name)){t.push(n);continue}const r=[];for(const t of n.attributes){const e=t.name.toLowerCase();f.test(e)?r.push(t.name):"is"!==e?(d.has(e)&&p.test(t.value)||"style"===e&&/expression\s*\(|javascript:|behavior\s*:/i.test(t.value))&&r.push(t.name):r.push(t.name)}r.forEach(e=>n.removeAttribute(e))}t.forEach(e=>e.remove())}(t.content)),t.content}var g=class{static dependencies;static manifest;aliases;version="3.8.3";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#e;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}get resolvedConfig(){return this.#e?this.config:{...this.defaultConfig,...this.userConfig}}mergeConfigsFrom(e){if(0===e.length)return;const t={...this.userConfig},r={};for(const n of Object.keys(t))r[n]=this;for(const n of e){const e=n.userConfig;for(const[o,s]of Object.entries(e)){if(void 0===s)continue;if(!(o in t)){t[o]=s,r[o]=n;continue}if(t[o]===s)continue;const e=r[o]?.constructor.name??this.constructor.name,i=n.constructor.name,l=a("TBW025",`Cannot merge plugin configs for "${this.name}": conflicting value for "${o}" supplied by both ${e} and ${i}. Pass the option on a single instance, or remove the duplicate.`,void 0,this.name);throw new Error(l)}}Object.assign(this.userConfig,t)}refreshUserConfigFrom(e){const t=this.userConfig,r={...e.userConfig};for(const n of Object.keys(t))delete t[n];Object.assign(t,r)}attach(e){this.#e?.abort(),this.#e=new AbortController,this.grid=e,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#e?.abort(),this.#e=void 0}getPlugin(e){return this.grid?.getPlugin(e)}emit(e,t){this.grid?.dispatchEvent?.(new CustomEvent(e,{detail:t,bubbles:!0}))}emitCancelable(e,t){const r=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(r),r.defaultPrevented}on(e,t){this.grid?._pluginManager?.subscribe(this,e,t)}off(e){this.grid?._pluginManager?.unsubscribe(this,e)}emitPluginEvent(e,t){this.grid?._pluginManager?.emitPluginEvent(e,t)}broadcast(e,t){this.emitPluginEvent(e,t),this.emit(e,t)}queryBoolean(e,t=null){const r=this.grid?.query?.(e,t);return Array.isArray(r)?r.some(Boolean):!!r}requestRender(){this.grid?.requestRender?.()}requestColumnsRender(){this.grid?.requestColumnsRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}requestVirtualRefresh(){this.grid?.requestVirtualRefresh?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?._visibleColumns??[]}get gridElement(){return this.grid?._hostElement}get disconnectSignal(){return this.#e?.signal??this.grid?.disconnectSignal}get gridIcons(){const e=this.grid?.gridConfig?.icons??{};return{...i,...e}}t(e,t){return this.grid?.effectiveConfig?.locale?.[e]??t}get translate(){return(e,t)=>this.t(e,t)}get isAnimationEnabled(){const e=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(!1===e||"off"===e)return!1;if(!0===e||"on"===e)return!0;const t=this.gridElement;return!t||"0"!==getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim()}get animationDuration(){const e=this.gridElement;if(e){const t=getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(),r=parseInt(t,10);if(!isNaN(r))return r}return 200}setIcon(e,t,r){e.dataset.icon=t.replace(/([A-Z])/g,"-$1").toLowerCase(),"collapse"===t?e.dataset.expanded="":"expand"===t&&delete e.dataset.expanded;const n=this.#t(t,r);var o,s;void 0!==n?"string"==typeof n?(o=e,(s=n)&&"string"==typeof s?-1!==s.indexOf("<")||-1!==s.indexOf("&")?o.replaceChildren(h(s)):o.textContent=s:o.replaceChildren()):n instanceof HTMLElement&&e.replaceChildren(n.cloneNode(!0)):e.innerHTML=""}#t(e,t){return void 0!==t?t:this.grid?.gridConfig?.icons?.[e]}updateSortIndicator(e,t){e.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove();const r=document.createElement("span");r.setAttribute("part","sort-indicator"),r.className="sort-indicator",t?(e.setAttribute("aria-sort","asc"===t?"ascending":"descending"),e.setAttribute("data-sort",t),this.setIcon(r,"asc"===t?"sortAsc":"sortDesc")):(e.setAttribute("aria-sort","none"),e.removeAttribute("data-sort"),this.setIcon(r,"sortNone"));const n=e.querySelector(".tbw-filter-btn")??e.querySelector(".resize-handle");return n?e.insertBefore(r,n):e.appendChild(r),r}warn(e,t){void 0!==t?console.warn(a(e,t,this.gridElement.id,this.name)):console.warn(`${l(this.gridElement.id,this.name)} ${e}`)}throwDiagnostic(e,t){throw new Error(a(e,t,this.gridElement.id,this.name))}};function m(e,t,r=!0){let n=e;if(r&&(n=n.filter(e=>!e.hidden&&!e.field.startsWith("__")&&!0!==e.utility)),t?.length){const e=new Set(t);n=n.filter(t=>e.has(t.field))}return n}function y(e,t){return t?.length?[...t].sort((e,t)=>e-t).map(t=>e[t]).filter(e=>null!=e):e}var b=/^[=+\-@\t\r]/;function v(e,t){if("string"==typeof e){const r=!1!==t.escapeFormulas&&b.test(e)?`'${e}`:e,n=t.quoting??"auto";return"always"===n||"auto"===n&&(r.includes(t.delimiter)||r.includes(t.newline)||r.includes('"')||r.includes("\n")||r.includes("\r"))?`"${r.replace(/"/g,'""')}"`:r}return"number"==typeof e?String(e):"boolean"==typeof e?e?"true":"false":null==e?"":e instanceof Date?e.toISOString():"object"==typeof e?JSON.stringify(e):String(e)}function w(e,t,r,n={}){const o=n.delimiter??",",i=n.newline??"\n",l={delimiter:o,newline:i,quoting:n.quoteStrings??1?"auto":"never",escapeFormulas:n.escapeFormulas},a=[],c=n.bom?"\ufeff":"";if(!1!==r.includeHeaders){const e=t.map(e=>{const t=e.header||e.field;return v(r.processHeader?r.processHeader(t,e.field):t,l)});a.push(e.join(o))}for(const u of e){const e=t.map(e=>{let t=s(u,e);return r.processCell&&(t=r.processCell(t,e.field,u)),v(t,l)});a.push(e.join(o))}return c+a.join(i)}function S(e,t){const r=URL.createObjectURL(e),n=document.createElement("a");n.href=r,n.download=t,n.style.display="none",document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(r)}function x(e){return JSON.stringify(C(e))}function C(e){if(null==e||"object"!=typeof e)return e;if(Array.isArray(e))return e.map(C);const t={};for(const r of Object.keys(e).sort())t[r]=C(e[r]);return t}var E=class{#r=/* @__PURE__ */new Map;#n=0;register(e){const t=x(e),r=this.#r.get(t);if(r)return r.id;this.#n++;const n=`s${this.#n}`;return this.#r.set(t,{id:n,style:e}),n}getStyleId(e){return this.#r.get(x(e))?.id}get size(){return this.#r.size}toXml(){if(0===this.#r.size)return"";let e="\n<Styles>";for(const{id:t,style:r}of this.#r.values())e+=$(t,r);return e+="\n</Styles>",e}};function $(e,t){let r=`\n<Style ss:ID="${e}">`;if(t.font&&(r+="<Font",t.font.name&&(r+=` ss:FontName="${t.font.name}"`),t.font.size&&(r+=` ss:Size="${t.font.size}"`),t.font.bold&&(r+=' ss:Bold="1"'),t.font.italic&&(r+=' ss:Italic="1"'),t.font.color&&(r+=` ss:Color="${t.font.color}"`),r+="/>"),t.fill){const e=t.fill.pattern??"Solid";r+=`<Interior ss:Color="${t.fill.color}" ss:Pattern="${e}"/>`}return t.numberFormat&&(r+=`<NumberFormat ss:Format="${t.numberFormat}"/>`),t.alignment&&(r+="<Alignment",t.alignment.horizontal&&(r+=` ss:Horizontal="${t.alignment.horizontal}"`),t.alignment.vertical&&(r+=` ss:Vertical="${t.alignment.vertical}"`),t.alignment.wrapText&&(r+=' ss:WrapText="1"'),r+="/>"),t.borders&&(r+="<Borders>",t.borders.top&&(r+=R("Top",t.borders.top)),t.borders.bottom&&(r+=R("Bottom",t.borders.bottom)),t.borders.left&&(r+=R("Left",t.borders.left)),t.borders.right&&(r+=R("Right",t.borders.right)),r+="</Borders>"),r+="</Style>",r}function R(e,t){let r=`<Border ss:Position="${e}" ss:LineStyle="Continuous" ss:Weight="${function(e){switch(e){case"Thin":return 1;case"Medium":return 2;case"Thick":return 3}}(t.style)}"`;return t.color&&(r+=` ss:Color="${t.color}"`),r+="/>",r}function A(e,t,r,n,o){if(t.cellStyle){const s=t.cellStyle(r,n,o);if(s)return e.register(s)}const s=t.columnStyles?.[n];return s?e.getStyleId(s):t.defaultStyle?e.getStyleId(t.defaultStyle):void 0}function D(e,r){const s=Math.min(r.length,50);let i=(e.header??e.field).length;const l=function(e){const r=n(e);return null===r?t(e)?()=>{}:t=>null==t?void 0:t[e]:t=>{if(null==t)return;const n=t;return Object.prototype.hasOwnProperty.call(n,e)?n[e]:o(n,r)}}(e.field);for(let t=0;t<s;t++){const e=l(r[t]),n=null==e?0:String(e).length;n>i&&(i=n)}return i+2}function j(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function H(e){return null==e?{type:"String",displayValue:""}:"number"!=typeof e||isNaN(e)?e instanceof Date?{type:"DateTime",displayValue:e.toISOString()}:{type:"String",displayValue:j(String(e))}:{type:"Number",displayValue:String(e)}}function I(e,t,r){const n=r.excelStyles,o=n?function(e){const t=new E;if(e.headerStyle&&t.register(e.headerStyle),e.groupHeaderStyle&&t.register(e.groupHeaderStyle),e.defaultStyle&&t.register(e.defaultStyle),e.columnStyles)for(const r of Object.values(e.columnStyles))t.register(r);return t}(n):void 0;let i='<?xml version="1.0" encoding="UTF-8"?>\n<?mso-application progid="Excel.Sheet"?>\n<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"\n xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">';o&&n&&(i+=function(e,t,r,n){if(t.cellStyle)for(const o of r)for(const r of n){const n=t.cellStyle(s(o,r),r.field,o);n&&e.register(n)}return e.toXml()}(o,n,e,t)),i+='\n<Worksheet ss:Name="Sheet1">\n<Table>',n&&(i+=function(e,t,r){const n=r.columnWidths,o=r.autoFitColumns;if(!n&&!o)return"";let s="";for(const i of e){let e=n?.[i.field];null==e&&o&&(e=D(i,t)),s+=null!=e?`\n<Column ss:Width="${7*e}"/>`:"\n<Column/>"}return s}(t,e,n));const l=n?.headerStyle&&o?o.getStyleId(n.headerStyle):void 0,a=n?.groupHeaderStyle&&o?o.getStyleId(n.groupHeaderStyle):l;return!1!==r.includeHeaders&&(i+=function(e,t){if(!e.headerRows?.length)return"";const r=t?` ss:StyleID="${t}"`:"";let n="";for(const o of e.headerRows){n+="\n<Row>";for(const e of o.cells){const t=Math.max(1,0|e.span);n+=`<Cell${r}${t>1?` ss:MergeAcross="${t-1}"`:""}><Data ss:Type="String">${j(e.label??"")}</Data></Cell>`}n+="</Row>"}return n}(r,a),i+=function(e,t,r){const n=r?` ss:StyleID="${r}"`:"";let o="\n<Row>";for(const s of e){const e=s.header||s.field;o+=`<Cell${n}><Data ss:Type="String">${j(t.processHeader?t.processHeader(e,s.field):e)}</Data></Cell>`}return o+"</Row>"}(t,r,l)),i+=function(e,t,r,n,o){let i="";for(const l of e){i+="\n<Row>";for(const e of t){let t=s(l,e);r.processCell&&(t=r.processCell(t,e.field,l));const{type:a,displayValue:c}=H(t),u=n&&o?A(n,o,t,e.field,l):void 0;i+=`<Cell${u?` ss:StyleID="${u}"`:""}><Data ss:Type="${a}">${c}</Data></Cell>`}i+="</Row>"}return i}(e,t,r,o,n),i+="\n</Table>\n</Worksheet>\n</Workbook>",i}var _=class extends g{static manifest={queries:[{type:"export:csv",description:"Triggers a CSV export"}]};name="export";get defaultConfig(){return{fileName:"export",includeHeaders:!0,onlyVisible:!0,onlySelected:!1}}isExportingFlag=!1;lastExportInfo=null;handleQuery(e){if("export:csv"===e.type)return this.exportCsv(),!0}resolveExportData(e,t){const r=this.config,n={format:e,fileName:t?.fileName??r.fileName??"export",includeHeaders:t?.includeHeaders??r.includeHeaders,processCell:t?.processCell,processHeader:t?.processHeader,processHeaderRow:t?.processHeaderRow,mode:t?.mode??"raw",columns:t?.columns,rowIndices:t?.rowIndices,excelStyles:t?.excelStyles,fileExtension:t?.fileExtension,headerRows:t?.headerRows},o=m(this.columns,t?.columns,r.onlyVisible);let s;if(t?.rowIndices)s=y(this.rows,t.rowIndices);else if(r.onlySelected){const e=this.getSelectionState();s=e?.selected?.size?y(this.rows,[...e.selected]):[...this.rows]}else s=[...this.rows];if(!1===n.includeHeaders)n.headerRows=void 0;else{const e=n.headerRows??this.#o(o);n.headerRows=this.#s(e,o,n.processHeaderRow)}return{columns:o,rows:s,fullParams:n}}#o(e){if(0===e.length)return[];const t=this.grid;if(!t?.query)return[];const r=t.query("collectHeaderRows",{columns:e});if(!r||0===r.length)return[];const n=[];for(const o of r)if(o)if(Array.isArray(o))for(const e of o)e&&Array.isArray(e.cells)&&e.cells.length>0&&n.push(e);else Array.isArray(o.cells)&&o.cells.length>0&&n.push(o);return n}#s(e,t,r){if(!e||0===e.length)return;const n=t.length,o=[];for(let s=0;s<e.length;s++){const t=e[s];if(!t||!Array.isArray(t.cells)||0===t.cells.length)continue;const i=[];let l=!1,a=0,c=!1;for(const e of t.cells){const t=Math.max(1,0|e.span);if(a+t>n){c=!0;break}a+=t;const o=r?r(e,s):e;null===o?i.push({label:"",span:t}):(i.push({...o,span:t}),""!==(o.label??"")&&(l=!0))}c||(a<n&&i.push({label:"",span:n-a}),l&&o.push({cells:i}))}return o.length>0?o:void 0}resolveCellOutput(e,t,r,n,o){let s=e;if("formatted"===n){const n=this.#i(t);if(n)try{const t=n(e,r);s=null==t?"":String(t)}catch{s=null==e?"":String(e)}else s="date"===t.type?function(e){if(null==e||""===e)return"";if(e instanceof Date)return isNaN(e.getTime())?"":e.toLocaleDateString();if("number"==typeof e||"string"==typeof e){const t=new Date(e);return isNaN(t.getTime())?"":t.toLocaleDateString()}return""}(e):"boolean"===t.type?!!e:e}return o&&(s=o(s,t.field,r)),s}performExport(e,t){const{columns:r,rows:n,fullParams:o}=this.resolveExportData(e,t);this.isExportingFlag=!0;let s=o.fileName??"export";const i=this.#l(r);try{switch(e){case"csv":{const e=w(this.#a(n,r,o),i,{...o,processCell:void 0},{bom:!0});s=s.endsWith(".csv")?s:`${s}.csv`,function(e,t){S(new Blob([e],{type:"text/csv;charset=utf-8;"}),t)}(e,s);break}case"excel":{const e=I(this.#a(n,r,o),i,{...o,processCell:void 0}),t=o.fileExtension??".xls",l=t.startsWith(".")?t:`.${t}`;s=s.endsWith(l)?s:`${s}${l}`,function(e,t){S(new Blob([e],{type:"application/vnd.ms-excel;charset=utf-8;"}),t)}(e,s);break}case"json":{const e=this.#a(n,r,o),t=o.headerRows&&o.headerRows.length>0?{headerRows:o.headerRows,rows:e}:e,i=JSON.stringify(t,null,2);s=s.endsWith(".json")?s:`${s}.json`;S(new Blob([i],{type:"application/json"}),s);break}}this.lastExportInfo={format:e,timestamp:/* @__PURE__ */new Date},this.emit("export-complete",{format:e,fileName:s,rowCount:n.length,columnCount:r.length})}finally{this.isExportingFlag=!1}}#a(e,t,r){const n=r.mode??"raw";return e.map(e=>{const o={};for(const i of t){const t=s(e,i);o[i.field]=this.resolveCellOutput(t,i,e,n,r.processCell)}return o})}getSelectionState(){try{return this.grid?.getPluginState?.("selection")??null}catch{return null}}export(e){const{columns:t,rows:r,fullParams:n}=this.resolveExportData("json",e);return this.#a(r,t,n)}getResolvedColumns(e){return m(this.columns,e?.columns,this.config.onlyVisible)}formatCsv(e,t,r){const{columns:n,fullParams:o}=this.resolveExportData("csv",t);return w(e,this.#l(n),o,r)}formatExcel(e,t){const{columns:r,fullParams:n}=this.resolveExportData("excel",t);return I(e,this.#l(r),n)}#l(e){return e.map(e=>e.valueAccessor?{...e,valueAccessor:void 0}:e)}#i(e){if(e.format)return e.format;if(!e.type)return;const t=this.grid,r=t?.__frameworkAdapter;return r?.getTypeDefault?r.getTypeDefault(e.type,t?._hostElement)?.format:void 0}exportCsv(e){this.performExport("csv",e)}exportExcel(e){this.performExport("excel",e)}exportJson(e){this.performExport("json",e)}isExporting(){return this.isExportingFlag}getLastExport(){return this.lastExportInfo}};export{_ as ExportPlugin};
1
+ var e=/* @__PURE__ */new WeakMap;function t(e){return"__proto__"===e||"constructor"===e||"prototype"===e}var r=/* @__PURE__ */new Map;function n(e){if(-1===e.indexOf("."))return null;let t=r.get(e);return void 0===t&&(t=Object.freeze(e.split(".")),r.set(e,t)),t}function o(e,r){let n=e;for(let o=0;o<r.length;o++){if(null==n||"object"!=typeof n)return;const e=r[o];if(t(e))return;n=n[e]}return n}function s(r,s,i=-1){if(!s.valueAccessor)return function(e,r){if(null==e)return;const s=n(r),i=e;return null===s?t(r)?void 0:i[r]:Object.prototype.hasOwnProperty.call(i,r)?i[r]:o(i,s)}(r,s.field);if("object"!=typeof r||null===r)return s.valueAccessor({row:r,column:s,rowIndex:i});const l=r,a=s.field;let c=e.get(l);if(c){const e=c.get(a);if(void 0!==e)return e.v}else c=/* @__PURE__ */new Map,e.set(l,c);const u=s.valueAccessor({row:r,column:s,rowIndex:i});return c.set(a,{v:u}),u}var i={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};function l(e,t){return`[tbw-grid${e?`#${e}`:""}${t?`:${t}`:""}]`}function a(e,t,r,n){return`${l(r,n)} ${e}: ${t}\n\n → More info: ${function(e){return`https://toolboxjs.com/grid/errors#${e.toLowerCase()}`}(e)}`}var c="__otorp__|__retteGenifed__|__retteSenifed__|rotcurtsnoc|wodniw|sihTlabolg|labolg|ssecorp|noitcnuF|tropmi|lave|tcelfeR|yxorP|rorrE|stnemugra|tnemucod|noitacol|eikooc|egarotSlacol|egarotSnoisses|BDdexedni|hctef|tseuqeRpttHLMX|tekcoSbeW|rekroW|rekroWderahS|rekroWecivreS|renepo|tnerap|pot|semarf|fles".split("|").map(e=>e.split("").reverse().join("")),u=(new RegExp(`__(proto|defineGetter|defineSetter)|${c.slice(3).join("|")}|this\\b`),new Set("script|iframe|object|embed|form|input|button|textarea|select|link|meta|base|style|template|slot|portal|frame|frameset|applet|noscript|noembed|plaintext|xmp|listing|math".split("|"))),f=/^on\w+$/i,d=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),p=/^\s*(javascript|vbscript|data|blob):/i;function h(e){const t=document.createElement("template");return e&&"string"==typeof e&&(t.innerHTML=e,function(e){const t=[],r=e.querySelectorAll("*");for(const n of r){const e=n.tagName.toLowerCase();if(u.has(e)){t.push(n);continue}if(("svg"===e||"http://www.w3.org/2000/svg"===n.namespaceURI)&&Array.from(n.attributes).some(e=>f.test(e.name)||"href"===e.name||"xlink:href"===e.name)){t.push(n);continue}const r=[];for(const t of n.attributes){const e=t.name.toLowerCase();f.test(e)?r.push(t.name):"is"!==e?(d.has(e)&&p.test(t.value)||"style"===e&&/expression\s*\(|javascript:|behavior\s*:/i.test(t.value))&&r.push(t.name):r.push(t.name)}r.forEach(e=>n.removeAttribute(e))}t.forEach(e=>e.remove())}(t.content)),t.content}var g=class{static dependencies;static manifest;aliases;version="3.9.0";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#e;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}get resolvedConfig(){return this.#e?this.config:{...this.defaultConfig,...this.userConfig}}mergeConfigsFrom(e){if(0===e.length)return;const t={...this.userConfig},r={};for(const n of Object.keys(t))r[n]=this;for(const n of e){const e=n.userConfig;for(const[o,s]of Object.entries(e)){if(void 0===s)continue;if(!(o in t)){t[o]=s,r[o]=n;continue}if(t[o]===s)continue;const e=r[o]?.constructor.name??this.constructor.name,i=n.constructor.name,l=a("TBW025",`Cannot merge plugin configs for "${this.name}": conflicting value for "${o}" supplied by both ${e} and ${i}. Pass the option on a single instance, or remove the duplicate.`,void 0,this.name);throw new Error(l)}}Object.assign(this.userConfig,t)}refreshUserConfigFrom(e){const t=this.userConfig,r={...e.userConfig};for(const n of Object.keys(t))delete t[n];Object.assign(t,r)}attach(e){this.#e?.abort(),this.#e=new AbortController,this.grid=e,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#e?.abort(),this.#e=void 0}getPlugin(e){return this.grid?.getPlugin(e)}emit(e,t){this.grid?.dispatchEvent?.(new CustomEvent(e,{detail:t,bubbles:!0}))}emitCancelable(e,t){const r=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(r),r.defaultPrevented}on(e,t){this.grid?._pluginManager?.subscribe(this,e,t)}off(e){this.grid?._pluginManager?.unsubscribe(this,e)}emitPluginEvent(e,t){this.grid?._pluginManager?.emitPluginEvent(e,t)}broadcast(e,t){this.emitPluginEvent(e,t),this.emit(e,t)}queryBoolean(e,t=null){const r=this.grid?.query?.(e,t);return Array.isArray(r)?r.some(Boolean):!!r}requestRender(){this.grid?.requestRender?.()}requestColumnsRender(){this.grid?.requestColumnsRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}requestVirtualRefresh(){this.grid?.requestVirtualRefresh?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?._visibleColumns??[]}get gridElement(){return this.grid?._hostElement}get disconnectSignal(){return this.#e?.signal??this.grid?.disconnectSignal}get gridIcons(){const e=this.grid?.gridConfig?.icons??{};return{...i,...e}}t(e,t){return this.grid?.effectiveConfig?.locale?.[e]??t}get translate(){return(e,t)=>this.t(e,t)}get isAnimationEnabled(){const e=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(!1===e||"off"===e)return!1;if(!0===e||"on"===e)return!0;const t=this.gridElement;return!t||"0"!==getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim()}get animationDuration(){const e=this.gridElement;if(e){const t=getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(),r=parseInt(t,10);if(!isNaN(r))return r}return 200}setIcon(e,t,r){e.dataset.icon=t.replace(/([A-Z])/g,"-$1").toLowerCase(),"collapse"===t?e.dataset.expanded="":"expand"===t&&delete e.dataset.expanded;const n=this.#t(t,r);var o,s;void 0!==n?"string"==typeof n?(o=e,(s=n)&&"string"==typeof s?-1!==s.indexOf("<")||-1!==s.indexOf("&")?o.replaceChildren(h(s)):o.textContent=s:o.replaceChildren()):n instanceof HTMLElement&&e.replaceChildren(n.cloneNode(!0)):e.innerHTML=""}#t(e,t){return void 0!==t?t:this.grid?.gridConfig?.icons?.[e]}updateSortIndicator(e,t){e.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove();const r=document.createElement("span");r.setAttribute("part","sort-indicator"),r.className="sort-indicator",t?(e.setAttribute("aria-sort","asc"===t?"ascending":"descending"),e.setAttribute("data-sort",t),this.setIcon(r,"asc"===t?"sortAsc":"sortDesc")):(e.setAttribute("aria-sort","none"),e.removeAttribute("data-sort"),this.setIcon(r,"sortNone"));const n=e.querySelector(".tbw-filter-btn")??e.querySelector(".resize-handle");return n?e.insertBefore(r,n):e.appendChild(r),r}warn(e,t){void 0!==t?console.warn(a(e,t,this.gridElement.id,this.name)):console.warn(`${l(this.gridElement.id,this.name)} ${e}`)}throwDiagnostic(e,t){throw new Error(a(e,t,this.gridElement.id,this.name))}};function m(e,t,r=!0){let n=e;if(r&&(n=n.filter(e=>!e.hidden&&!e.field.startsWith("__")&&!0!==e.utility)),t?.length){const e=new Set(t);n=n.filter(t=>e.has(t.field))}return n}function y(e,t){return t?.length?[...t].sort((e,t)=>e-t).map(t=>e[t]).filter(e=>null!=e):e}var b=/^[=+\-@\t\r]/;function v(e,t){if("string"==typeof e){const r=!1!==t.escapeFormulas&&b.test(e)?`'${e}`:e,n=t.quoting??"auto";return"always"===n||"auto"===n&&(r.includes(t.delimiter)||r.includes(t.newline)||r.includes('"')||r.includes("\n")||r.includes("\r"))?`"${r.replace(/"/g,'""')}"`:r}return"number"==typeof e?String(e):"boolean"==typeof e?e?"true":"false":null==e?"":e instanceof Date?e.toISOString():"object"==typeof e?JSON.stringify(e):String(e)}function w(e,t,r,n={}){const o=n.delimiter??",",i=n.newline??"\n",l={delimiter:o,newline:i,quoting:n.quoteStrings??1?"auto":"never",escapeFormulas:n.escapeFormulas},a=[],c=n.bom?"\ufeff":"";if(!1!==r.includeHeaders){const e=t.map(e=>{const t=e.header||e.field;return v(r.processHeader?r.processHeader(t,e.field):t,l)});a.push(e.join(o))}for(const u of e){const e=t.map(e=>{let t=s(u,e);return r.processCell&&(t=r.processCell(t,e.field,u)),v(t,l)});a.push(e.join(o))}return c+a.join(i)}function S(e,t){const r=URL.createObjectURL(e),n=document.createElement("a");n.href=r,n.download=t,n.style.display="none",document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(r)}function x(e){return JSON.stringify(C(e))}function C(e){if(null==e||"object"!=typeof e)return e;if(Array.isArray(e))return e.map(C);const t={};for(const r of Object.keys(e).sort())t[r]=C(e[r]);return t}var E=class{#r=/* @__PURE__ */new Map;#n=0;register(e){const t=x(e),r=this.#r.get(t);if(r)return r.id;this.#n++;const n=`s${this.#n}`;return this.#r.set(t,{id:n,style:e}),n}getStyleId(e){return this.#r.get(x(e))?.id}get size(){return this.#r.size}toXml(){if(0===this.#r.size)return"";let e="\n<Styles>";for(const{id:t,style:r}of this.#r.values())e+=$(t,r);return e+="\n</Styles>",e}};function $(e,t){let r=`\n<Style ss:ID="${e}">`;if(t.font&&(r+="<Font",t.font.name&&(r+=` ss:FontName="${t.font.name}"`),t.font.size&&(r+=` ss:Size="${t.font.size}"`),t.font.bold&&(r+=' ss:Bold="1"'),t.font.italic&&(r+=' ss:Italic="1"'),t.font.color&&(r+=` ss:Color="${t.font.color}"`),r+="/>"),t.fill){const e=t.fill.pattern??"Solid";r+=`<Interior ss:Color="${t.fill.color}" ss:Pattern="${e}"/>`}return t.numberFormat&&(r+=`<NumberFormat ss:Format="${t.numberFormat}"/>`),t.alignment&&(r+="<Alignment",t.alignment.horizontal&&(r+=` ss:Horizontal="${t.alignment.horizontal}"`),t.alignment.vertical&&(r+=` ss:Vertical="${t.alignment.vertical}"`),t.alignment.wrapText&&(r+=' ss:WrapText="1"'),r+="/>"),t.borders&&(r+="<Borders>",t.borders.top&&(r+=R("Top",t.borders.top)),t.borders.bottom&&(r+=R("Bottom",t.borders.bottom)),t.borders.left&&(r+=R("Left",t.borders.left)),t.borders.right&&(r+=R("Right",t.borders.right)),r+="</Borders>"),r+="</Style>",r}function R(e,t){let r=`<Border ss:Position="${e}" ss:LineStyle="Continuous" ss:Weight="${function(e){switch(e){case"Thin":return 1;case"Medium":return 2;case"Thick":return 3}}(t.style)}"`;return t.color&&(r+=` ss:Color="${t.color}"`),r+="/>",r}function A(e,t,r,n,o){if(t.cellStyle){const s=t.cellStyle(r,n,o);if(s)return e.register(s)}const s=t.columnStyles?.[n];return s?e.getStyleId(s):t.defaultStyle?e.getStyleId(t.defaultStyle):void 0}function D(e,r){const s=Math.min(r.length,50);let i=(e.header??e.field).length;const l=function(e){const r=n(e);return null===r?t(e)?()=>{}:t=>null==t?void 0:t[e]:t=>{if(null==t)return;const n=t;return Object.prototype.hasOwnProperty.call(n,e)?n[e]:o(n,r)}}(e.field);for(let t=0;t<s;t++){const e=l(r[t]),n=null==e?0:String(e).length;n>i&&(i=n)}return i+2}function j(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function H(e){return null==e?{type:"String",displayValue:""}:"number"!=typeof e||isNaN(e)?e instanceof Date?{type:"DateTime",displayValue:e.toISOString()}:{type:"String",displayValue:j(String(e))}:{type:"Number",displayValue:String(e)}}function I(e,t,r){const n=r.excelStyles,o=n?function(e){const t=new E;if(e.headerStyle&&t.register(e.headerStyle),e.groupHeaderStyle&&t.register(e.groupHeaderStyle),e.defaultStyle&&t.register(e.defaultStyle),e.columnStyles)for(const r of Object.values(e.columnStyles))t.register(r);return t}(n):void 0;let i='<?xml version="1.0" encoding="UTF-8"?>\n<?mso-application progid="Excel.Sheet"?>\n<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"\n xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">';o&&n&&(i+=function(e,t,r,n){if(t.cellStyle)for(const o of r)for(const r of n){const n=t.cellStyle(s(o,r),r.field,o);n&&e.register(n)}return e.toXml()}(o,n,e,t)),i+='\n<Worksheet ss:Name="Sheet1">\n<Table>',n&&(i+=function(e,t,r){const n=r.columnWidths,o=r.autoFitColumns;if(!n&&!o)return"";let s="";for(const i of e){let e=n?.[i.field];null==e&&o&&(e=D(i,t)),s+=null!=e?`\n<Column ss:Width="${7*e}"/>`:"\n<Column/>"}return s}(t,e,n));const l=n?.headerStyle&&o?o.getStyleId(n.headerStyle):void 0,a=n?.groupHeaderStyle&&o?o.getStyleId(n.groupHeaderStyle):l;return!1!==r.includeHeaders&&(i+=function(e,t){if(!e.headerRows?.length)return"";const r=t?` ss:StyleID="${t}"`:"";let n="";for(const o of e.headerRows){n+="\n<Row>";for(const e of o.cells){const t=Math.max(1,0|e.span);n+=`<Cell${r}${t>1?` ss:MergeAcross="${t-1}"`:""}><Data ss:Type="String">${j(e.label??"")}</Data></Cell>`}n+="</Row>"}return n}(r,a),i+=function(e,t,r){const n=r?` ss:StyleID="${r}"`:"";let o="\n<Row>";for(const s of e){const e=s.header||s.field;o+=`<Cell${n}><Data ss:Type="String">${j(t.processHeader?t.processHeader(e,s.field):e)}</Data></Cell>`}return o+"</Row>"}(t,r,l)),i+=function(e,t,r,n,o){let i="";for(const l of e){i+="\n<Row>";for(const e of t){let t=s(l,e);r.processCell&&(t=r.processCell(t,e.field,l));const{type:a,displayValue:c}=H(t),u=n&&o?A(n,o,t,e.field,l):void 0;i+=`<Cell${u?` ss:StyleID="${u}"`:""}><Data ss:Type="${a}">${c}</Data></Cell>`}i+="</Row>"}return i}(e,t,r,o,n),i+="\n</Table>\n</Worksheet>\n</Workbook>",i}var _=class extends g{static manifest={queries:[{type:"export:csv",description:"Triggers a CSV export"}]};name="export";get defaultConfig(){return{fileName:"export",includeHeaders:!0,onlyVisible:!0,onlySelected:!1}}isExportingFlag=!1;lastExportInfo=null;handleQuery(e){if("export:csv"===e.type)return this.exportCsv(),!0}resolveExportData(e,t){const r=this.config,n={format:e,fileName:t?.fileName??r.fileName??"export",includeHeaders:t?.includeHeaders??r.includeHeaders,processCell:t?.processCell,processHeader:t?.processHeader,processHeaderRow:t?.processHeaderRow,mode:t?.mode??"raw",columns:t?.columns,rowIndices:t?.rowIndices,excelStyles:t?.excelStyles,fileExtension:t?.fileExtension,headerRows:t?.headerRows},o=m(this.columns,t?.columns,r.onlyVisible);let s;if(t?.rowIndices)s=y(this.rows,t.rowIndices);else if(r.onlySelected){const e=this.getSelectionState();s=e?.selected?.size?y(this.rows,[...e.selected]):[...this.rows]}else s=[...this.rows];if(!1===n.includeHeaders)n.headerRows=void 0;else{const e=n.headerRows??this.#o(o);n.headerRows=this.#s(e,o,n.processHeaderRow)}return{columns:o,rows:s,fullParams:n}}#o(e){if(0===e.length)return[];const t=this.grid;if(!t?.query)return[];const r=t.query("collectHeaderRows",{columns:e});if(!r||0===r.length)return[];const n=[];for(const o of r)if(o)if(Array.isArray(o))for(const e of o)e&&Array.isArray(e.cells)&&e.cells.length>0&&n.push(e);else Array.isArray(o.cells)&&o.cells.length>0&&n.push(o);return n}#s(e,t,r){if(!e||0===e.length)return;const n=t.length,o=[];for(let s=0;s<e.length;s++){const t=e[s];if(!t||!Array.isArray(t.cells)||0===t.cells.length)continue;const i=[];let l=!1,a=0,c=!1;for(const e of t.cells){const t=Math.max(1,0|e.span);if(a+t>n){c=!0;break}a+=t;const o=r?r(e,s):e;null===o?i.push({label:"",span:t}):(i.push({...o,span:t}),""!==(o.label??"")&&(l=!0))}c||(a<n&&i.push({label:"",span:n-a}),l&&o.push({cells:i}))}return o.length>0?o:void 0}resolveCellOutput(e,t,r,n,o){let s=e;if("formatted"===n){const n=this.#i(t);if(n)try{const t=n(e,r);s=null==t?"":String(t)}catch{s=null==e?"":String(e)}else s="date"===t.type?function(e){if(null==e||""===e)return"";if(e instanceof Date)return isNaN(e.getTime())?"":e.toLocaleDateString();if("number"==typeof e||"string"==typeof e){const t=new Date(e);return isNaN(t.getTime())?"":t.toLocaleDateString()}return""}(e):"boolean"===t.type?!!e:e}return o&&(s=o(s,t.field,r)),s}performExport(e,t){const{columns:r,rows:n,fullParams:o}=this.resolveExportData(e,t);this.isExportingFlag=!0;let s=o.fileName??"export";const i=this.#l(r);try{switch(e){case"csv":{const e=w(this.#a(n,r,o),i,{...o,processCell:void 0},{bom:!0});s=s.endsWith(".csv")?s:`${s}.csv`,function(e,t){S(new Blob([e],{type:"text/csv;charset=utf-8;"}),t)}(e,s);break}case"excel":{const e=I(this.#a(n,r,o),i,{...o,processCell:void 0}),t=o.fileExtension??".xls",l=t.startsWith(".")?t:`.${t}`;s=s.endsWith(l)?s:`${s}${l}`,function(e,t){S(new Blob([e],{type:"application/vnd.ms-excel;charset=utf-8;"}),t)}(e,s);break}case"json":{const e=this.#a(n,r,o),t=o.headerRows&&o.headerRows.length>0?{headerRows:o.headerRows,rows:e}:e,i=JSON.stringify(t,null,2);s=s.endsWith(".json")?s:`${s}.json`;S(new Blob([i],{type:"application/json"}),s);break}}this.lastExportInfo={format:e,timestamp:/* @__PURE__ */new Date},this.emit("export-complete",{format:e,fileName:s,rowCount:n.length,columnCount:r.length})}finally{this.isExportingFlag=!1}}#a(e,t,r){const n=r.mode??"raw";return e.map(e=>{const o={};for(const i of t){const t=s(e,i);o[i.field]=this.resolveCellOutput(t,i,e,n,r.processCell)}return o})}getSelectionState(){try{return this.grid?.getPluginState?.("selection")??null}catch{return null}}export(e){const{columns:t,rows:r,fullParams:n}=this.resolveExportData("json",e);return this.#a(r,t,n)}getResolvedColumns(e){return m(this.columns,e?.columns,this.config.onlyVisible)}formatCsv(e,t,r){const{columns:n,fullParams:o}=this.resolveExportData("csv",t);return w(e,this.#l(n),o,r)}formatExcel(e,t){const{columns:r,fullParams:n}=this.resolveExportData("excel",t);return I(e,this.#l(r),n)}#l(e){return e.map(e=>e.valueAccessor?{...e,valueAccessor:void 0}:e)}#i(e){if(e.format)return e.format;if(!e.type)return;const t=this.grid,r=t?.__frameworkAdapter;return r?.getTypeDefault?r.getTypeDefault(e.type,t?._hostElement)?.format:void 0}exportCsv(e){this.performExport("csv",e)}exportExcel(e){this.performExport("excel",e)}exportJson(e){this.performExport("json",e)}isExporting(){return this.isExportingFlag}getLastExport(){return this.lastExportInfo}};export{_ as ExportPlugin};
2
2
  //# sourceMappingURL=index.js.map