bways-grid 0.0.5 → 0.0.7

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.
@@ -1,4 +1,4 @@
1
1
  // AUTO-GENERATED FILE. DO NOT EDIT.
2
2
  // Built from src/lib/workers/sorting.worker.ts
3
- export const SORTING_WORKER_CODE = `"use strict";(()=>{var G=[],N=[];addEventListener("message",r=>{let{action:a,rows:n,sortModel:o,filterModel:i,conditionFilters:e,groupModel:t,aggregations:d,groupStateMap:l}=r.data;if(a==="INIT"){G=(n||[]).map(u=>({...u,type:"leaf",level:0})),postMessage({action:"INIT_DONE"});return}if(a==="FLATTEN_ONLY"){let s=m(N,l||{},r.data.groupIncludeFooter);postMessage({flatList:s});return}if(a==="EXECUTE"){let s=G;if(i&&Object.keys(i).length>0){let c={};for(let p of Object.keys(i))c[p]=new Set(i[p]);s=s.filter(p=>{for(let y of Object.keys(c)){let F=c[y],k=p.data?p.data[y]:null;if(!F.has(k))return!1}return!0})}e&&Object.keys(e).length>0&&(s=O(s,e));let u=s,f=d||{};if(t&&t.length>0?u=E(s,t,f):s.forEach(c=>c.level=0),o&&o.length>0&&L(u,o),N=u,t&&t.length>0&&r.data.groupIncludeFooter&&Object.keys(f).length>0){let p={id:"grand-total-footer",type:"group-footer",level:0,groupField:"Grand Total",groupKey:"Grand Total",data:v(s,f)};N.push(p)}let g=m(N,l||{},r.data.groupIncludeFooter),h=U(N);postMessage({flatList:g,resultTree:h})}});function U(r){return r.map(a=>{if(a.type==="leaf")return{id:a.id,type:"leaf",level:a.level};if(a.type==="group"){let n=a;return{...n,children:n.children?U(n.children):void 0}}return a})}function m(r,a,n=!1){let o=[],i=[];for(let e=r.length-1;e>=0;e--)i.push(r[e]);for(;i.length>0;){let e=i.pop();if(e.type==="group"){let t=e;if(o.push({id:t.id,type:"group",level:t.level,groupField:t.groupField,groupKey:t.groupKey,data:t.data,childCount:t.children?t.children.length:0}),!!a[t.id]&&(n&&i.push({id:\`\${t.id}-footer\`,type:"group-footer",level:t.level,groupField:t.groupField,groupKey:t.groupKey,data:{...t.data}}),t.children))for(let l=t.children.length-1;l>=0;l--)i.push(t.children[l])}else e.type==="group-footer"?o.push({id:e.id,type:"group-footer",level:e.level,groupField:e.groupField,groupKey:e.groupKey,data:e.data}):o.push({id:e.id,type:"leaf",level:e.level})}return o}function E(r,a,n){return T(r,a,0,n,"root")}function T(r,a,n,o,i){let e=a[n],t=n===a.length-1,d=new Map;for(let s of r){let u=s.data?s.data[e]:null;d.has(u)||d.set(u,[]),d.get(u).push(s)}let l=[];for(let[s,u]of d.entries()){let f=\`\${i}-\${e}-\${s}\`,g={id:f,type:"group",level:n,groupField:e,groupKey:s,data:{[e]:s},children:[]},h=v(u,o);Object.assign(g.data,h),t?(u.forEach(c=>c.level=n+1),g.children=u):g.children=T(u,a,n+1,o,f),l.push(g)}return l}function v(r,a){let n={};for(let o of Object.keys(a)){let i=a[o],e=0;if(i==="count")e=r.length;else{let t=!0,d=0,l=0;for(let s of r){let u=s.data?s.data[o]:0,f=0;typeof u=="number"?f=u:typeof u=="string"&&(f=Number(u.replace(/[^0-9.-]+/g,""))),isNaN(f)&&(f=0),i==="sum"?e+=f:i==="min"?t?e=f:e=Math.min(e,f):i==="max"?t?e=f:e=Math.max(e,f):i==="avg"&&(d+=f,l++),t=!1}i==="avg"&&(e=l>0?d/l:0)}n[o]=e}return n}function L(r,a){r.sort((n,o)=>{for(let i of a){let{field:e,direction:t}=i,d=n.data?n.data[e]:null,l=o.data?o.data[e]:null;if(d===l)continue;let s=d>l?1:-1;return t==="asc"?s:-s}return 0});for(let n of r)n.type==="group"&&n.children&&L(n.children,a)}function O(r,a){let n=Object.keys(a);return n.length===0?r:r.filter(o=>{for(let i of n){let e=a[i];if(!e||!e.condition1)continue;let t=o.data?o.data[i]:null,d=b(t,e.condition1);if(e.condition2&&e.condition2.type){let l=b(t,e.condition2);if(!(e.operator==="OR"?d||l:d&&l))return!1}else if(!d)return!1}return!0})}function b(r,a){let{type:n,value:o,valueTo:i}=a;if(n==="blank")return r==null||r==="";if(n==="notBlank")return r!=null&&r!=="";if(o==null||o==="")return!0;let e=String(r??"").toLowerCase(),t=String(o).toLowerCase();switch(n){case"contains":return e.includes(t);case"notContains":return!e.includes(t);case"equals":return!isNaN(Number(r))&&!isNaN(Number(o))?Number(r)===Number(o):e===t;case"notEqual":return!isNaN(Number(r))&&!isNaN(Number(o))?Number(r)!==Number(o):e!==t;case"startsWith":return e.startsWith(t);case"endsWith":return e.endsWith(t);case"greaterThan":return Number(r)>Number(o);case"greaterThanOrEqual":return Number(r)>=Number(o);case"lessThan":return Number(r)<Number(o);case"lessThanOrEqual":return Number(r)<=Number(o);case"inRange":if(i==null||i==="")return!0;let d=Number(r);return d>=Number(o)&&d<=Number(i);default:return!0}}})();
3
+ export const SORTING_WORKER_CODE = `"use strict";(()=>{var b=[],h=[];addEventListener("message",e=>{let{action:a,rows:o,sortModel:r,filterModel:i,conditionFilters:t,groupModel:n,aggregations:u,groupStateMap:d}=e.data;if(a==="INIT"){b=(o||[]).map(l=>({...l,type:"leaf",level:0})),postMessage({action:"INIT_DONE"});return}if(a==="FLATTEN_ONLY"){let s=U(h,d||{},e.data.groupIncludeFooter);postMessage({flatList:s});return}if(a==="EXECUTE"){let s=b,{pivotMode:l,pivotColumns:c}=e.data;if(i&&Object.keys(i).length>0){let g={};for(let p of Object.keys(i))g[p]=new Set(i[p]);s=s.filter(p=>{for(let G of Object.keys(g)){let O=g[G],S=p.data?p.data[G]:null;if(!O.has(S))return!1}return!0})}t&&Object.keys(t).length>0&&(s=\$(s,t));let f={...u||{}},y=[];if(l&&c&&c.length>0&&Object.keys(f).length>0){let{virtualAggrs:g,dynamicColumns:p}=K(s,c,f);f=g,y=p}let N=s;if(n&&n.length>0?N=M(s,n,f):s.forEach(g=>g.level=0),r&&r.length>0&&E(N,r),h=N,n&&n.length>0&&e.data.groupIncludeFooter&&Object.keys(f).length>0){let p={id:"grand-total-footer",type:"group-footer",level:0,groupField:"Grand Total",groupKey:"Grand Total",data:k(s,f)};h.push(p)}let m=U(h,d||{},e.data.groupIncludeFooter),F=L(h);postMessage({flatList:m,resultTree:F,pivotColumns:y})}});function L(e){return e.map(a=>{if(a.type==="leaf")return{id:a.id,type:"leaf",level:a.level};if(a.type==="group"){let o=a;return{...o,children:o.children?L(o.children):void 0}}return a})}function U(e,a,o=!1){let r=[],i=[];for(let t=e.length-1;t>=0;t--)i.push(e[t]);for(;i.length>0;){let t=i.pop();if(t.type==="group"){let n=t;if(r.push({id:n.id,type:"group",level:n.level,groupField:n.groupField,groupKey:n.groupKey,data:n.data,childCount:n.children?n.children.length:0}),!!a[n.id]&&(o&&i.push({id:\`\${n.id}-footer\`,type:"group-footer",level:n.level,groupField:n.groupField,groupKey:n.groupKey,data:{...n.data}}),n.children))for(let d=n.children.length-1;d>=0;d--)i.push(n.children[d])}else t.type==="group-footer"?r.push({id:t.id,type:"group-footer",level:t.level,groupField:t.groupField,groupKey:t.groupKey,data:t.data}):r.push({id:t.id,type:"leaf",level:t.level})}return r}function C(e){let a=[],o=[...e];for(;o.length>0;){let r=o.pop();if(I(r))a.push(r);else if(j(r)&&r.children)for(let i=r.children.length-1;i>=0;i--)o.push(r.children[i])}return a}function I(e){return e.type==="leaf"}function j(e){return e.type==="group"}function A(e){if(typeof e=="number")return e;if(typeof e!="string")return e==null?0:Number(e);let a=e.trim();if(!a)return 0;let o=a.startsWith("(")&&a.endsWith(")"),r=a.replace(/[\\u2212\\u2013\\u2014]/g,"-");r.includes("-")&&(o=!0),r=r.replace(/[^0-9.]/g,"");let i=r?Number(r):0;return isNaN(i)?0:o?-i:i}function M(e,a,o){return T(e,a,0,o,"root")}function T(e,a,o,r,i){let t=a[o],n=o===a.length-1,u=new Map;for(let s of e){let l=s.data?s.data[t]:null;u.has(l)||u.set(l,[]),u.get(l).push(s)}let d=[];for(let[s,l]of u.entries()){let c=\`\${i}-\${t}-\${s}\`,f={id:c,type:"group",level:o,groupField:t,groupKey:s,data:{[t]:s},children:[]},y=C(l),N=k(y,r);Object.assign(f.data,N),n?(l.forEach(m=>m.level=o+1),f.children=l):f.children=T(l,a,o+1,r,c),d.push(f)}return d}function k(e,a){let o={};for(let r of Object.keys(a)){let i=a[r],t=0;if(i==="count")t=e.length;else{let n=!0,u=0,d=0;for(let s of e){let l=s.data?s.data[r]:null,c=A(l);i==="sum"?t=Number(t)+c:i==="min"?n?t=c:t=Math.min(t,c):i==="max"?n?t=c:t=Math.max(t,c):i==="avg"&&(u=Number(u)+c,d++),n=!1}i==="avg"&&(t=d>0?u/d:0)}o[r]=t}return o}function E(e,a){e.sort((o,r)=>{for(let i of a){let{field:t,direction:n}=i,u=o.data?o.data[t]:null,d=r.data?r.data[t]:null;if(u===d)continue;let s=u>d?1:-1;return n==="asc"?s:-s}return 0});for(let o of e)o.type==="group"&&o.children&&E(o.children,a)}function \$(e,a){let o=Object.keys(a);return o.length===0?e:e.filter(r=>{for(let i of o){let t=a[i];if(!t||!t.condition1)continue;let n=r.data?r.data[i]:null,u=v(n,t.condition1);if(t.condition2&&t.condition2.type){let d=v(n,t.condition2);if(!(t.operator==="OR"?u||d:u&&d))return!1}else if(!u)return!1}return!0})}function v(e,a){let{type:o,value:r,valueTo:i}=a;if(o==="blank")return e==null||e==="";if(o==="notBlank")return e!=null&&e!=="";if(r==null||r==="")return!0;let t=String(e??"").toLowerCase(),n=String(r).toLowerCase();switch(o){case"contains":return t.includes(n);case"notContains":return!t.includes(n);case"equals":return!isNaN(Number(e))&&!isNaN(Number(r))?Number(e)===Number(r):t===n;case"notEqual":return!isNaN(Number(e))&&!isNaN(Number(r))?Number(e)!==Number(r):t!==n;case"startsWith":return t.startsWith(n);case"endsWith":return t.endsWith(n);case"greaterThan":return Number(e)>Number(r);case"greaterThanOrEqual":return Number(e)>=Number(r);case"lessThan":return Number(e)<Number(r);case"lessThanOrEqual":return Number(e)<=Number(r);case"inRange":if(i==null||i==="")return!0;let u=Number(e);return u>=Number(r)&&u<=Number(i);default:return!0}}function K(e,a,o){let r={};a.forEach(d=>r[d]=new Set),e.forEach(d=>{a.forEach(s=>{let l=d.data[s];l!=null&&r[s].add(l)})});let i={},t=[],n=a[0];return Array.from(r[n]).sort().forEach(d=>{Object.keys(o).forEach(s=>{let l=o[s],c=\`pivot_\${n}_\${d}_\${s}\`;i[c]=l,t.push({field:c,headerName:\`\${d} (\${s})\`,pivotValue:d,originalField:s,isPivotColumn:!0}),e.forEach(f=>{String(f.data[n])===String(d)?f.data[c]=f.data[s]:f.data[c]=null})})}),{virtualAggrs:i,dynamicColumns:t}}})();
4
4
  `;
@@ -25,6 +25,7 @@ addEventListener('message', (event: MessageEvent) => {
25
25
 
26
26
  if (action === 'EXECUTE') {
27
27
  let processed = cachedRows;
28
+ const { pivotMode, pivotColumns } = event.data;
28
29
 
29
30
  // 1. Apply Filtering if present
30
31
  if (filterModel && Object.keys(filterModel).length > 0) {
@@ -50,17 +51,26 @@ addEventListener('message', (event: MessageEvent) => {
50
51
  processed = applyConditionFilters(processed, conditionFilters);
51
52
  }
52
53
 
53
- // 2. Apply Grouping and Aggregation if present
54
+ // 2. Apply Pivot logic if enabled
55
+ let resultAggregations = { ...(aggregations || {}) };
56
+ let pivotResultColumns: any[] = [];
57
+
58
+ if (pivotMode && pivotColumns && pivotColumns.length > 0 && Object.keys(resultAggregations).length > 0) {
59
+ const { virtualAggrs, dynamicColumns } = handlePivoting(processed, pivotColumns, resultAggregations);
60
+ resultAggregations = virtualAggrs;
61
+ pivotResultColumns = dynamicColumns;
62
+ }
63
+
64
+ // 3. Apply Grouping and Aggregation if present
54
65
  let resultTree: UltraGridNode[] = processed;
55
- const aggs = aggregations || {};
56
66
 
57
67
  if (groupModel && groupModel.length > 0) {
58
- resultTree = buildTree(processed, groupModel, aggs);
68
+ resultTree = buildTree(processed, groupModel, resultAggregations);
59
69
  } else {
60
70
  processed.forEach(r => r.level = 0);
61
71
  }
62
72
 
63
- // 3. Apply Recursive Sorting
73
+ // 4. Apply Recursive Sorting
64
74
  if (sortModel && sortModel.length > 0) {
65
75
  sortTree(resultTree, sortModel);
66
76
  }
@@ -68,9 +78,9 @@ addEventListener('message', (event: MessageEvent) => {
68
78
  // Cache the processed tree so toggle operations don't need to rebuild it
69
79
  cachedResultTree = resultTree;
70
80
 
71
- // 4. Compute Grand Total if grouping and footers are enabled
72
- if (groupModel && groupModel.length > 0 && event.data.groupIncludeFooter && Object.keys(aggs).length > 0) {
73
- const grandTotalData = computeAggregations(processed, aggs);
81
+ // 5. Compute Grand Total if grouping and footers are enabled
82
+ if (groupModel && groupModel.length > 0 && event.data.groupIncludeFooter && Object.keys(resultAggregations).length > 0) {
83
+ const grandTotalData = computeAggregations(processed, resultAggregations);
74
84
  const grandTotalNode: UltraGridGroupFooterNode = {
75
85
  id: 'grand-total-footer',
76
86
  type: 'group-footer',
@@ -80,16 +90,16 @@ addEventListener('message', (event: MessageEvent) => {
80
90
  data: grandTotalData
81
91
  };
82
92
  // Append grand total at the end of the root level resultTree
83
- cachedResultTree.push(grandTotalNode as any); // Cast as any to bypass strict type check for now since GroupFooterNode is expected by flattener
93
+ cachedResultTree.push(grandTotalNode as any);
84
94
  }
85
95
 
86
- // 5. Client-side Flattening
96
+ // 6. Client-side Flattening
87
97
  const flatList = flattenTree(cachedResultTree, groupStateMap || {}, event.data.groupIncludeFooter);
88
98
 
89
99
  // Strip massive data payloads from leaf nodes before sending full tree back
90
100
  const strippedTree = stripTreeData(cachedResultTree);
91
101
 
92
- postMessage({ flatList, resultTree: strippedTree });
102
+ postMessage({ flatList, resultTree: strippedTree, pivotColumns: pivotResultColumns });
93
103
  }
94
104
  });
95
105
 
@@ -184,6 +194,57 @@ function flattenTree(nodes: UltraGridNode[], stateMap: { [key: string]: boolean
184
194
  return result;
185
195
  }
186
196
 
197
+ function getAllLeaves(nodes: UltraGridNode[]): UltraGridLeafNode[] {
198
+ const leaves: UltraGridLeafNode[] = [];
199
+ const stack: UltraGridNode[] = [...nodes];
200
+ while (stack.length > 0) {
201
+ const n = stack.pop()!;
202
+ if (nodeIsLeaf(n)) {
203
+ leaves.push(n);
204
+ } else if (nodeIsGroup(n) && n.children) {
205
+ for (let i = n.children.length - 1; i >= 0; i--) {
206
+ stack.push(n.children[i]);
207
+ }
208
+ }
209
+ }
210
+ return leaves;
211
+ }
212
+
213
+ function nodeIsLeaf(node: UltraGridNode): node is UltraGridLeafNode {
214
+ return node.type === 'leaf';
215
+ }
216
+
217
+ function nodeIsGroup(node: UltraGridNode): node is UltraGridGroupNode {
218
+ return node.type === 'group';
219
+ }
220
+
221
+ function parseNumber(val: any): number {
222
+ if (typeof val === 'number') return val;
223
+ if (typeof val !== 'string') return val == null ? 0 : Number(val);
224
+
225
+ const str = val.trim();
226
+ if (!str) return 0;
227
+
228
+ // 1. Handle accounting format: (123.45) or ($123.45)
229
+ let isNegative = str.startsWith('(') && str.endsWith(')');
230
+
231
+ // 2. Normalize different minus signs to standard hyphen-minus
232
+ // Standard hyphen-minus: \u002D
233
+ // Unicode minus sign: \u2212
234
+ // En dash: \u2013, Em dash: \u2014
235
+ let cleanStr = str.replace(/[\u2212\u2013\u2014]/g, '-');
236
+
237
+ if (cleanStr.includes('-')) isNegative = true;
238
+
239
+ // 3. Remove everything except digits and the decimal point
240
+ cleanStr = cleanStr.replace(/[^0-9.]/g, '');
241
+
242
+ const num = cleanStr ? Number(cleanStr) : 0;
243
+ if (isNaN(num)) return 0;
244
+
245
+ return isNegative ? -num : num;
246
+ }
247
+
187
248
  function buildTree(
188
249
  leaves: UltraGridLeafNode[],
189
250
  groupModel: string[],
@@ -232,8 +293,9 @@ function groupLevel(
232
293
  children: []
233
294
  };
234
295
 
235
- // Aggregation Step
236
- const bucketAggData = computeAggregations(bucketNodes, aggregations);
296
+ // Aggregation Step: Always aggregate from the underlying leaf nodes for accuracy (especially for avg/count)
297
+ const allLeavesInBucket = getAllLeaves(bucketNodes);
298
+ const bucketAggData = computeAggregations(allLeavesInBucket, aggregations);
237
299
  Object.assign(groupNode.data, bucketAggData);
238
300
 
239
301
  // Recursive children or direct assignment
@@ -258,7 +320,7 @@ function groupLevel(
258
320
  }
259
321
 
260
322
  function computeAggregations(
261
- nodes: (UltraGridLeafNode | UltraGridGroupNode)[],
323
+ leaves: UltraGridLeafNode[],
262
324
  aggregations: { [field: string]: string }
263
325
  ): any {
264
326
  const resultData: any = {};
@@ -266,29 +328,20 @@ function computeAggregations(
266
328
  for (const aggField of Object.keys(aggregations)) {
267
329
  const aggType = aggregations[aggField];
268
330
 
269
- let aggValue = 0;
331
+ let aggValue: number = 0;
270
332
  if (aggType === 'count') {
271
- aggValue = nodes.length;
333
+ aggValue = leaves.length;
272
334
  } else {
273
335
  let first = true;
274
336
  let sumForAvg = 0;
275
337
  let countForAvg = 0;
276
338
 
277
- for (const child of nodes) {
278
- const val = child.data ? child.data[aggField] : 0;
279
-
280
- // Robust numeric parsing: strip currency symbols, commas, spaces
281
- let numVal = 0;
282
- if (typeof val === 'number') {
283
- numVal = val;
284
- } else if (typeof val === 'string') {
285
- numVal = Number(val.replace(/[^0-9.-]+/g, ""));
286
- }
287
-
288
- if (isNaN(numVal)) numVal = 0;
339
+ for (const leaf of leaves) {
340
+ const val = leaf.data ? leaf.data[aggField] : null;
341
+ const numVal = parseNumber(val);
289
342
 
290
343
  if (aggType === 'sum') {
291
- aggValue += numVal;
344
+ aggValue = Number(aggValue) + numVal;
292
345
  } else if (aggType === 'min') {
293
346
  if (first) aggValue = numVal;
294
347
  else aggValue = Math.min(aggValue, numVal);
@@ -296,7 +349,7 @@ function computeAggregations(
296
349
  if (first) aggValue = numVal;
297
350
  else aggValue = Math.max(aggValue, numVal);
298
351
  } else if (aggType === 'avg') {
299
- sumForAvg += numVal;
352
+ sumForAvg = Number(sumForAvg) + numVal;
300
353
  countForAvg++;
301
354
  }
302
355
  first = false;
@@ -421,3 +474,53 @@ function evaluateCondition(cellValue: any, condition: { type: string; value?: st
421
474
  return true;
422
475
  }
423
476
  }
477
+
478
+ function handlePivoting(rows: UltraGridLeafNode[], pivotCols: string[], originalAggs: any) {
479
+ const uniqueValues: { [field: string]: Set<any> } = {};
480
+ pivotCols.forEach((col) => (uniqueValues[col] = new Set()));
481
+
482
+ // 1. Discover unique values
483
+ rows.forEach((row) => {
484
+ pivotCols.forEach((col) => {
485
+ const val = row.data[col];
486
+ if (val != null) uniqueValues[col].add(val);
487
+ });
488
+ });
489
+
490
+ const virtualAggrs: any = {};
491
+ const dynamicColumns: any[] = [];
492
+
493
+ // For now, we support 1-level pivot for stability
494
+ const primaryPivot = pivotCols[0];
495
+ const sortedUniques = Array.from(uniqueValues[primaryPivot]).sort();
496
+
497
+ sortedUniques.forEach((pivotVal) => {
498
+ // Create virtual fields for each original aggregation
499
+ Object.keys(originalAggs).forEach((aggrField) => {
500
+ const aggrFunc = originalAggs[aggrField];
501
+ const virtualField = `pivot_${primaryPivot}_${pivotVal}_${aggrField}`;
502
+
503
+ virtualAggrs[virtualField] = aggrFunc;
504
+
505
+ // Define the dynamic column for the UI
506
+ dynamicColumns.push({
507
+ field: virtualField,
508
+ headerName: `${pivotVal} (${aggrField})`,
509
+ pivotValue: pivotVal,
510
+ originalField: aggrField,
511
+ isPivotColumn: true
512
+ });
513
+
514
+ // 3. Inject virtual data into leaves
515
+ rows.forEach((row) => {
516
+ if (String(row.data[primaryPivot]) === String(pivotVal)) {
517
+ row.data[virtualField] = row.data[aggrField];
518
+ } else {
519
+ row.data[virtualField] = null;
520
+ }
521
+ });
522
+ });
523
+ });
524
+
525
+ return { virtualAggrs, dynamicColumns };
526
+ }
@@ -1,12 +0,0 @@
1
- export interface CsvExportOptions {
2
- /** Whether to export all rows in the dataset or only the rows currently visible (filtered/sorted). Default: 'all' */
3
- mode?: 'visible' | 'all';
4
- /** The filename to save the downloaded file as. Default: 'export.csv' */
5
- fileName?: string;
6
- /** Whether to include the column headers in the first row. Default: true */
7
- includeHeaders?: boolean;
8
- /** The character used to separate values. Default: ',' */
9
- separator?: string;
10
- /** Optional list of column fields to export. If not provided, all visible columns are exported. */
11
- columnKeys?: string[];
12
- }
@@ -1,11 +0,0 @@
1
- import { CsvExportOptions } from '../models/csv-export.model';
2
- import { UltraGridColumn } from '../models/column.model';
3
- import * as i0 from "@angular/core";
4
- export declare class CsvExportService {
5
- private isBrowser;
6
- constructor(platformId: Object);
7
- exportDataAsCsv(options: CsvExportOptions, columns: UltraGridColumn[], data: any[], config?: any): Promise<void>;
8
- private downloadBlob;
9
- static ɵfac: i0.ɵɵFactoryDeclaration<CsvExportService, never>;
10
- static ɵprov: i0.ɵɵInjectableDeclaration<CsvExportService>;
11
- }
@@ -1 +0,0 @@
1
- export declare const EXPORT_WORKER_CODE = "\"use strict\";(()=>{var E=1e4;addEventListener(\"message\",({data:a})=>{let{action:c,columns:e,data:l,options:u}=a;if(c===\"START_EXPORT\")try{let s=u.separator||\",\",g=u.includeHeaders!==!1,o=[];if(g){let t=e.map(n=>m(n.headerName||n.field,s)).join(s);o.push(t+`\n`)}let r=\"\",d=0,f=(t,n)=>{let C=t.data?t.data:t,y=e.map((p,h)=>{let i=C[p.field];return h===0&&n>0&&(i=\" \".repeat(n)+(i||\"\")),h===0&&t.type===\"group\"&&t.children&&(i=(i||\"\")+` (${t.children.length})`),m(i,s)}).join(s);if(r+=y+`\n`,d++,d>0&&d%E===0&&(o.push(r),r=\"\"),t.type===\"group\"&&t.children&&t.children.length>0)for(let p of t.children)f(p,n+1)};for(let t=0;t<l.length;t++){let n=l[t].level||0;f(l[t],n)}r&&o.push(r),postMessage({action:\"COMPLETE\",payload:{parts:o,type:\"text/csv;charset=utf-8\"}})}catch(s){postMessage({action:\"ERROR\",error:s.message||\"CSV Export Failed\"})}});function m(a,c){if(a==null)return\"\";let e=String(a);return e.includes(c)||e.includes(`\n`)||e.includes('\"')?`\"${e.replace(/\"/g,'\"\"')}\"`:e}})();\n";