@verifiedinc-public/shared-ui-elements 9.13.1-beta.0 → 9.14.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.
- package/dist/components/chart/BillableEventsTable/BillableEventsTable.mjs +1 -1
- package/dist/components/chart/BillableEventsTable/BillableEventsTable.types.d.ts +5 -0
- package/dist/components/chart/BillableEventsTable/exportBillableEventsToCsv.d.ts +6 -1
- package/dist/components/chart/BillableEventsTable/exportBillableEventsToCsv.mjs +3 -3
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{TableContainer as
|
|
1
|
+
"use strict";import{TableContainer as U,Paper as L,Table as P,TableHead as D,TableRow as m,TableCell as n,TableBody as N,TableSortLabel as E}from"@mui/material";import{useState as j,useEffect as F,useMemo as y,Fragment as I}from"react";import{EmptyChartSection as M}from"../EmptyChartSection.mjs";import{LoadingChartSection as O}from"../LoadingChartSection.mjs";import{BillableProduct as R,BILLABLE_PRODUCTS as A}from"./BillableEventsTable.types.mjs";import{BrandDetailsPanel as H}from"./BrandDetailsPanel.mjs";import{useBillableSort as K}from"./useBillableSort.hook.mjs";import{white as W}from"../../../styles/colors.mjs";import{jsx as e,jsxs as c}from"react/jsx-runtime";const _=["customerName","brand","integrationType"],q=({data:l,isLoading:S,isFetching:C,visibleProducts:f,onSortedDataChange:h,columnSlots:a,topLevelColumns:i=[],showCustomerColumn:d=!0})=>{const{sortKey:k,sortDir:T,handleSort:v,sortedData:u}=K(l,_,"brand"),[x,B]=j(null);F(()=>{h?.(u)},[u,h]);const p=y(()=>{const r=f??Object.values(R);return A.filter(t=>r.includes(t.product))},[f]),b=y(()=>new Set(i.map(r=>r.key)),[i]),g=y(()=>p.flatMap(r=>r.columns).filter(r=>!b.has(r.key)),[p,b]),w=2+(d?1:0)+i.length+g.length,s=(r,t,o="left")=>e(E,{active:k===r,direction:k===r?T:"asc",onClick:()=>v(r),sx:o==="right"?{flexDirection:"row"}:void 0,children:t});return!(l!=null&&l.length)&&S?e(O,{}):l!=null&&l.length?e(U,{component:L,sx:{opacity:C?.4:1},children:c(P,{sx:{backgroundColor:W},children:[c(D,{children:[c(m,{children:[d&&e(n,{rowSpan:2,children:s("customerName","Customer Name")}),e(n,{rowSpan:2,children:s("brand","Brand Name")}),e(n,{rowSpan:2,children:s("integrationType","Integration Type")}),i.map(r=>e(n,{rowSpan:2,children:s(r.key,r.label)},r.key)),p.map(r=>{const t=r.columns.filter(o=>!b.has(o.key)).length;return t===0?null:e(n,{colSpan:t,align:"center",sx:{fontWeight:"bold",borderBottom:"none"},children:r.label},r.product)})]}),e(m,{children:g.map(r=>e(n,{align:"right",children:s(r.key,r.label,"right")},r.key))})]}),e(N,{children:u.map(r=>{const t=x===r.brandUuid;return c(I,{children:[c(m,{hover:!0,onClick:()=>B(t?null:r.brandUuid),sx:{cursor:"pointer","& > td":{borderBottom:t?"none":void 0}},children:[d&&e(n,{children:r.customerName??"\u2014"}),e(n,{children:r.brand}),e(n,{children:r.integrationType}),i.map(o=>e(n,{children:a!=null&&a[o.key]?a[o.key](r):r.metrics[o.key]??0},o.key)),g.map(o=>e(n,{align:"right",children:a!=null&&a[o.key]?a[o.key](r):r.metrics[o.key]??0},o.key))]}),t&&e(m,{children:e(n,{colSpan:w,sx:{py:0,px:0,borderTop:"none",bgcolor:"grey.50"},children:e(H,{brandUuid:r.brandUuid,customerUuid:d?r.customerUuid:void 0,challengePrompts:r.challengePrompts,providers:r.providers})})})]},r.brandUuid)})})]})}):e(M,{})};export{q as BillableEventsTable};
|
|
@@ -45,6 +45,11 @@ export type BillableEventsTableProps = {
|
|
|
45
45
|
onSortedDataChange?: (sortedData: BillableEventsTableRow[]) => void;
|
|
46
46
|
columnSlots?: Record<string, (row: BillableEventsTableRow) => React.ReactNode>;
|
|
47
47
|
topLevelColumns?: BillableEventColumn[];
|
|
48
|
+
/**
|
|
49
|
+
* Show the leading Customer Name column. Defaults to `true`. Set `false`
|
|
50
|
+
* for views scoped to a single customer where the column would be redundant.
|
|
51
|
+
*/
|
|
52
|
+
showCustomerColumn?: boolean;
|
|
48
53
|
};
|
|
49
54
|
export type BillableEventsProductTableProps = {
|
|
50
55
|
data: BillableEventsTableRow[];
|
|
@@ -5,6 +5,11 @@ interface ExportBillableEventsToCsvOptions {
|
|
|
5
5
|
filename?: string;
|
|
6
6
|
topLevelColumns?: BillableEventColumn[];
|
|
7
7
|
columnFormatters?: Record<string, (value: number, row: BillableEventsTableRow) => string>;
|
|
8
|
+
/**
|
|
9
|
+
* Include the `Customer Name` and `Customer UUID` columns. Defaults to
|
|
10
|
+
* `true`. Set `false` for single-customer-scoped exports.
|
|
11
|
+
*/
|
|
12
|
+
showCustomerColumn?: boolean;
|
|
8
13
|
}
|
|
9
|
-
export declare function exportBillableEventsToCsv({ data, visibleProducts, filename, topLevelColumns, columnFormatters, }: ExportBillableEventsToCsvOptions): void;
|
|
14
|
+
export declare function exportBillableEventsToCsv({ data, visibleProducts, filename, topLevelColumns, columnFormatters, showCustomerColumn, }: ExportBillableEventsToCsvOptions): void;
|
|
10
15
|
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";import{BillableProduct as
|
|
2
|
-
`)?`"${n.replace(/"/g,'""')}"`:n}function
|
|
3
|
-
`),
|
|
1
|
+
"use strict";import{BillableProduct as B,BILLABLE_PRODUCTS as C}from"./BillableEventsTable.types.mjs";function o(u){const n=String(u);return n.includes(",")||n.includes('"')||n.includes(`
|
|
2
|
+
`)?`"${n.replace(/"/g,'""')}"`:n}function w({data:u,visibleProducts:n,filename:U="billable-events",topLevelColumns:c=[],columnFormatters:a,showCustomerColumn:f=!0}){const k=n??Object.values(B),h=C.filter(e=>k.includes(e.product)),b=new Set(c.map(e=>e.key)),v=h.flatMap(e=>e.columns).filter(e=>!b.has(e.key)),i=[],L=(f?2:0)+3,m=[...new Array(L).fill(""),...c.map(()=>"")];for(const e of h){const s=e.columns.filter(t=>!b.has(t.key)).length;if(s!==0){m.push(o(e.label));for(let t=1;t<s;t++)m.push("")}}i.push(m.join(","));const p=[...f?["Customer Name","Customer UUID"]:[],"Brand Name","Brand UUID","Integration Type"];for(const e of c)p.push(o(e.label));for(const e of v)p.push(o(e.label));i.push(p.join(","));for(const e of u){const s=[...f?[o(e.customerName??""),o(e.customerUuid??"")]:[],o(e.brand),o(e.brandUuid),o(e.integrationType)];for(const t of c){const r=e.metrics[t.key]??0,l=a?.[t.key];s.push(l?o(l(r,e)):String(r))}for(const t of v){const r=e.metrics[t.key]??0,l=a?.[t.key];s.push(l?o(l(r,e)):String(r))}i.push(s.join(","))}const g=i.join(`
|
|
3
|
+
`),j=new Blob([g],{type:"text/csv;charset=utf-8;"}),y=URL.createObjectURL(j),d=document.createElement("a");d.href=y,d.download=`${U}.csv`,d.click(),URL.revokeObjectURL(y)}export{w as exportBillableEventsToCsv};
|
package/package.json
CHANGED