@verifiedinc-public/shared-ui-elements 9.2.1 → 9.2.2
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.
|
@@ -3,6 +3,7 @@ interface ExportBillableEventsToCsvOptions {
|
|
|
3
3
|
data: BillableEventsTableRow[];
|
|
4
4
|
visibleProducts?: BillableProduct[];
|
|
5
5
|
filename?: string;
|
|
6
|
+
columnFormatters?: Record<string, (value: number, row: BillableEventsTableRow) => string>;
|
|
6
7
|
}
|
|
7
|
-
export declare function exportBillableEventsToCsv({ data, visibleProducts, filename, }: ExportBillableEventsToCsvOptions): void;
|
|
8
|
+
export declare function exportBillableEventsToCsv({ data, visibleProducts, filename, columnFormatters, }: ExportBillableEventsToCsvOptions): void;
|
|
8
9
|
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";import{BillableProduct as
|
|
2
|
-
`)?`"${t.replace(/"/g,'""')}"`:t}function
|
|
3
|
-
`),
|
|
1
|
+
"use strict";import{BillableProduct as g,BILLABLE_PRODUCTS as B}from"./BillableEventsTable.types.mjs";function n(c){const t=String(c);return t.includes(",")||t.includes('"')||t.includes(`
|
|
2
|
+
`)?`"${t.replace(/"/g,'""')}"`:t}function R({data:c,visibleProducts:t,filename:m="billable-events",columnFormatters:i}){const v=t??Object.values(g),a=B.filter(e=>v.includes(e.product)),u=a.flatMap(e=>e.columns),s=[],l=["",""];for(const e of a){l.push(n(e.label));for(let o=1;o<e.columns.length;o++)l.push("")}s.push(l.join(","));const f=["Brand","Integration Type"];for(const e of u)f.push(n(e.label));s.push(f.join(","));for(const e of c){const o=[n(e.brand),n(e.integrationType)];for(const d of u){const b=e.metrics[d.key]??0,h=i?.[d.key];o.push(h?n(h(b,e)):String(b))}s.push(o.join(","))}const j=s.join(`
|
|
3
|
+
`),L=new Blob([j],{type:"text/csv;charset=utf-8;"}),p=URL.createObjectURL(L),r=document.createElement("a");r.href=p,r.download=`${m}.csv`,r.click(),URL.revokeObjectURL(p)}export{R as exportBillableEventsToCsv};
|