@verifiedinc-public/shared-ui-elements 3.7.0 → 3.8.1

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,15 +1,19 @@
1
1
  import { ComponentProps, ReactElement } from 'react';
2
2
  import { SxProps } from '@mui/material';
3
- import { XAxis, YAxis } from 'recharts';
4
- interface SimpleBarChartProps {
5
- data: Array<{
6
- key: string;
7
- value: number;
8
- }>;
3
+ import { ReferenceLine, XAxis, YAxis } from 'recharts';
4
+ interface Series {
5
+ key: string;
6
+ dataKey: string;
9
7
  color?: string;
8
+ }
9
+ interface SimpleBarChartProps {
10
+ data: Array<Record<string, number | string>>;
11
+ series: Series[];
12
+ xAxisDataKey: string;
10
13
  xAxisProps?: ComponentProps<typeof XAxis>;
11
14
  yAxisProps?: ComponentProps<typeof YAxis>;
15
+ referenceLines?: Array<ComponentProps<typeof ReferenceLine>>;
12
16
  sx?: SxProps;
13
17
  }
14
- export declare function SimpleBarChart({ data, color, xAxisProps, yAxisProps, sx, }: SimpleBarChartProps): ReactElement;
18
+ export declare function SimpleBarChart({ data, series, xAxisDataKey, xAxisProps, yAxisProps, referenceLines, sx, }: SimpleBarChartProps): ReactElement;
15
19
  export {};
@@ -1 +1 @@
1
- "use strict";import{j as s}from"../../shared/jsx-runtime-jmtevAuS.mjs";import*as G from"react";import{useCallback as H,useMemo as J,createElement as _e}from"react";import{Box as P,Stack as q,Typography as R,useTheme as Q,Paper as Ne}from"@mui/material";import{ResponsiveContainer as ee,LineChart as Te,CartesianGrid as ne,XAxis as te,YAxis as re,Label as Ee,Tooltip as oe,Legend as Ae,Line as Ce,AreaChart as Ge,Area as Le,ComposedChart as De,Bar as Me}from"recharts";import{b as fe,c as he}from"../../shared/date-Cq0LS2Mr.mjs";import z,{Decimal as ae}from"decimal.js";import{AnimatePresence as Re}from"framer-motion";import{u as Fe}from"../../shared/useCopyToClipboard-BALOSYVW.mjs";import"qrcode";import{u as ie}from"../../shared/usePrevious-DyvR1iCQ.mjs";import{a as We,C as ye}from"../../shared/motions-CpxgbzKX.mjs";import{i as Ie,_ as B,s as Ve,a as d,c as be,d as Ke,e as Pe,f as qe,h as ze,j as Be,k as Ue,l as Ze,m as Ye,n as Xe,o as He,p as Je,u as Qe}from"../../shared/index-CDq4CkLc.mjs";import{u as en}from"../../shared/useCounter-BV32zXDQ.mjs";const nn=["ownerState"],tn=["variants"],rn=["name","slot","skipVariantsResolver","skipSx","overridesResolver"];function on(e){return Object.keys(e).length===0}function an(e){return typeof e=="string"&&e.charCodeAt(0)>96}function se(e){return e!=="ownerState"&&e!=="theme"&&e!=="sx"&&e!=="as"}const sn=be(),ln=e=>e&&e.charAt(0).toLowerCase()+e.slice(1);function U({defaultTheme:e,theme:n,themeId:t}){return on(n)?e:n[t]||n}function cn(e){return e?(n,t)=>t[e]:null}function Z(e,n){let{ownerState:t}=n,r=B(n,nn);const o=typeof e=="function"?e(d({ownerState:t},r)):e;if(Array.isArray(o))return o.flatMap(a=>Z(a,d({ownerState:t},r)));if(o&&typeof o=="object"&&Array.isArray(o.variants)){const{variants:a=[]}=o;let i=B(o,tn);return a.forEach(c=>{let l=!0;typeof c.props=="function"?l=c.props(d({ownerState:t},r,t)):Object.keys(c.props).forEach(u=>{t?.[u]!==c.props[u]&&r[u]!==c.props[u]&&(l=!1)}),l&&(Array.isArray(i)||(i=[i]),i.push(typeof c.style=="function"?c.style(d({ownerState:t},r,t)):c.style))}),i}return o}function un(e={}){const{themeId:n,defaultTheme:t=sn,rootShouldForwardProp:r=se,slotShouldForwardProp:o=se}=e,a=i=>Ke(d({},i,{theme:U(d({},i,{defaultTheme:t,themeId:n}))}));return a.__mui_systemSx=!0,(i,c={})=>{Ie(i,p=>p.filter(w=>!(w!=null&&w.__mui_systemSx)));const{name:l,slot:u,skipVariantsResolver:m,skipSx:f,overridesResolver:y=cn(ln(u))}=c,h=B(c,rn),x=m!==void 0?m:u&&u!=="Root"&&u!=="root"||!1,b=f||!1;let j,S=se;u==="Root"||u==="root"?S=r:u?S=o:an(i)&&(S=void 0);const _=Ve(i,d({shouldForwardProp:S,label:j},h)),W=p=>typeof p=="function"&&p.__emotion_real!==p||Pe(p)?w=>Z(p,d({},w,{theme:U({theme:w.theme,defaultTheme:t,themeId:n})})):p,E=(p,...w)=>{let D=W(p);const N=w?w.map(W):[];l&&y&&N.push(g=>{const v=U(d({},g,{defaultTheme:t,themeId:n}));if(!v.components||!v.components[l]||!v.components[l].styleOverrides)return null;const k=v.components[l].styleOverrides,A={};return Object.entries(k).forEach(([Y,K])=>{A[Y]=Z(K,d({},g,{theme:v}))}),y(g,A)}),l&&!x&&N.push(g=>{var v;const k=U(d({},g,{defaultTheme:t,themeId:n})),A=k==null||(v=k.components)==null||(v=v[l])==null?void 0:v.variants;return Z({variants:A},d({},g,{theme:k}))}),b||N.push(a);const I=N.length-w.length;if(Array.isArray(p)&&I>0){const g=new Array(I).fill("");D=[...p,...g],D.raw=[...p.raw,...g]}const V=_(D,...N);return i.muiName&&(V.muiName=i.muiName),V};return _.withConfig&&(E.withConfig=_.withConfig),E}}const pn=un(),dn=(e,n)=>e.filter(t=>n.includes(t)),L=(e,n,t)=>{const r=e.keys[0];Array.isArray(n)?n.forEach((o,a)=>{t((i,c)=>{a<=e.keys.length-1&&(a===0?Object.assign(i,c):i[e.up(e.keys[a])]=c)},o)}):n&&typeof n=="object"?(Object.keys(n).length>e.keys.length?e.keys:dn(e.keys,Object.keys(n))).forEach(o=>{if(e.keys.indexOf(o)!==-1){const a=n[o];a!==void 0&&t((i,c)=>{r===o?Object.assign(i,c):i[e.up(o)]=c},a)}}):(typeof n=="number"||typeof n=="string")&&t((o,a)=>{Object.assign(o,a)},n)};function $(e){return e?`Level${e}`:""}function F(e){return e.unstable_level>0&&e.container}function ge(e){return function(n){return`var(--Grid-${n}Spacing${$(e.unstable_level)})`}}function le(e){return function(n){return e.unstable_level===0?`var(--Grid-${n}Spacing)`:`var(--Grid-${n}Spacing${$(e.unstable_level-1)})`}}function ce(e){return e.unstable_level===0?"var(--Grid-columns)":`var(--Grid-columns${$(e.unstable_level-1)})`}const mn=({theme:e,ownerState:n})=>{const t=ge(n),r={};return L(e.breakpoints,n.gridSize,(o,a)=>{let i={};a===!0&&(i={flexBasis:0,flexGrow:1,maxWidth:"100%"}),a==="auto"&&(i={flexBasis:"auto",flexGrow:0,flexShrink:0,maxWidth:"none",width:"auto"}),typeof a=="number"&&(i={flexGrow:0,flexBasis:"auto",width:`calc(100% * ${a} / ${ce(n)}${F(n)?` + ${t("column")}`:""})`}),o(r,i)}),r},fn=({theme:e,ownerState:n})=>{const t={};return L(e.breakpoints,n.gridOffset,(r,o)=>{let a={};o==="auto"&&(a={marginLeft:"auto"}),typeof o=="number"&&(a={marginLeft:o===0?"0px":`calc(100% * ${o} / ${ce(n)})`}),r(t,a)}),t},hn=({theme:e,ownerState:n})=>{if(!n.container)return{};const t=F(n)?{[`--Grid-columns${$(n.unstable_level)}`]:ce(n)}:{"--Grid-columns":12};return L(e.breakpoints,n.columns,(r,o)=>{r(t,{[`--Grid-columns${$(n.unstable_level)}`]:o})}),t},yn=({theme:e,ownerState:n})=>{if(!n.container)return{};const t=le(n),r=F(n)?{[`--Grid-rowSpacing${$(n.unstable_level)}`]:t("row")}:{};return L(e.breakpoints,n.rowSpacing,(o,a)=>{var i;o(r,{[`--Grid-rowSpacing${$(n.unstable_level)}`]:typeof a=="string"?a:(i=e.spacing)==null?void 0:i.call(e,a)})}),r},bn=({theme:e,ownerState:n})=>{if(!n.container)return{};const t=le(n),r=F(n)?{[`--Grid-columnSpacing${$(n.unstable_level)}`]:t("column")}:{};return L(e.breakpoints,n.columnSpacing,(o,a)=>{var i;o(r,{[`--Grid-columnSpacing${$(n.unstable_level)}`]:typeof a=="string"?a:(i=e.spacing)==null?void 0:i.call(e,a)})}),r},gn=({theme:e,ownerState:n})=>{if(!n.container)return{};const t={};return L(e.breakpoints,n.direction,(r,o)=>{r(t,{flexDirection:o})}),t},vn=({ownerState:e})=>{const n=ge(e),t=le(e);return d({minWidth:0,boxSizing:"border-box"},e.container&&d({display:"flex",flexWrap:"wrap"},e.wrap&&e.wrap!=="wrap"&&{flexWrap:e.wrap},{margin:`calc(${n("row")} / -2) calc(${n("column")} / -2)`},e.disableEqualOverflow&&{margin:`calc(${n("row")} * -1) 0px 0px calc(${n("column")} * -1)`}),(!e.container||F(e))&&d({padding:`calc(${t("row")} / 2) calc(${t("column")} / 2)`},(e.disableEqualOverflow||e.parentDisableEqualOverflow)&&{padding:`${t("row")} 0px 0px ${t("column")}`}))},xn=e=>{const n=[];return Object.entries(e).forEach(([t,r])=>{r!==!1&&r!==void 0&&n.push(`grid-${t}-${String(r)}`)}),n},wn=(e,n="xs")=>{function t(r){return r===void 0?!1:typeof r=="string"&&!Number.isNaN(Number(r))||typeof r=="number"&&r>0}if(t(e))return[`spacing-${n}-${String(e)}`];if(typeof e=="object"&&!Array.isArray(e)){const r=[];return Object.entries(e).forEach(([o,a])=>{t(a)&&r.push(`spacing-${o}-${String(a)}`)}),r}return[]},On=e=>e===void 0?[]:typeof e=="object"?Object.entries(e).map(([n,t])=>`direction-${n}-${t}`):[`direction-xs-${String(e)}`],jn=["className","children","columns","container","component","direction","wrap","spacing","rowSpacing","columnSpacing","disableEqualOverflow","unstable_level"],Sn=be(),kn=pn("div",{name:"MuiGrid",slot:"Root",overridesResolver:(e,n)=>n.root});function $n(e){return Ze({props:e,name:"MuiGrid",defaultTheme:Sn})}function _n(e={}){const{createStyledComponent:n=kn,useThemeProps:t=$n,componentName:r="MuiGrid"}=e,o=G.createContext(void 0),a=(l,u)=>{const{container:m,direction:f,spacing:y,wrap:h,gridSize:x}=l,b={root:["root",m&&"container",h!=="wrap"&&`wrap-xs-${String(h)}`,...On(f),...xn(x),...m?wn(y,u.breakpoints.keys[0]):[]]};return Ye(b,j=>Xe(r,j),{})},i=n(hn,bn,yn,mn,gn,vn,fn),c=G.forwardRef(function(l,u){var m,f,y,h,x,b,j,S;const _=qe(),W=t(l),E=ze(W),p=G.useContext(o),{className:w,children:D,columns:N=12,container:I=!1,component:V="div",direction:g="row",wrap:v="wrap",spacing:k=0,rowSpacing:A=k,columnSpacing:Y=k,disableEqualOverflow:K,unstable_level:T=0}=E,we=B(E,jn);let M=K;T&&K!==void 0&&(M=l.disableEqualOverflow);const ue={},pe={},de={};Object.entries(we).forEach(([O,C])=>{_.breakpoints.values[O]!==void 0?ue[O]=C:_.breakpoints.values[O.replace("Offset","")]!==void 0?pe[O.replace("Offset","")]=C:de[O]=C});const Oe=(m=l.columns)!=null?m:T?void 0:N,je=(f=l.spacing)!=null?f:T?void 0:k,Se=(y=(h=l.rowSpacing)!=null?h:l.spacing)!=null?y:T?void 0:A,ke=(x=(b=l.columnSpacing)!=null?b:l.spacing)!=null?x:T?void 0:Y,me=d({},E,{level:T,columns:Oe,container:I,direction:g,wrap:v,spacing:je,rowSpacing:Se,columnSpacing:ke,gridSize:ue,gridOffset:pe,disableEqualOverflow:(j=(S=M)!=null?S:p)!=null?j:!1,parentDisableEqualOverflow:p}),$e=a(me,_);let X=s.jsx(i,d({ref:u,as:V,ownerState:me,className:Be($e.root,w)},de,{children:G.Children.map(D,O=>{if(G.isValidElement(O)&&Ue(O,["Grid"])){var C;return G.cloneElement(O,{unstable_level:(C=O.props.unstable_level)!=null?C:T+1})}return O})}));return M!==void 0&&M!==(p??!1)&&(X=s.jsx(o.Provider,{value:M,children:X})),X});return c.muiName="Grid",c}const ve=_n({createStyledComponent:He("div",{name:"MuiGrid2",slot:"Root",overridesResolver:(e,n)=>n.root}),componentName:"MuiGrid2",useThemeProps:e=>Je({props:e,name:"MuiGrid2"})});function Nn({entry:e,payload:n}){const t=H(f=>{var y,h,x;return(x=(h=(y=f.payload)==null?void 0:y.data)==null?void 0:h.reduce)==null?void 0:x.call(h,(b,j)=>b+j.value,0)},[]),r=H(f=>{const y=new ae(t(f)||0),h=n?.reduce((j,S)=>j+t(S),0)||0,x=new ae(h),b=Number(y.div(x).times(100).toFixed(2,ae.ROUND_DOWN));return isNaN(b)||!isFinite(b)?0:b},[t,n]),o=J(()=>t(e),[e,t]),a=ie(o),i=J(()=>Number(r(e)),[e,r]),c=ie(i),l=H(f=>Math.floor(f).toLocaleString(),[]),u=Fe({type:"text/plain"}),m=Qe();return s.jsxs(We,{component:"li",direction:"row",spacing:1,sx:{color:e.color},layout:"position",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},children:[s.jsx(P,{sx:{width:"3px",height:"100%",backgroundColor:e.color,borderRadius:3}}),s.jsxs(q,{children:[s.jsxs(R,{component:"p",variant:"caption",children:[s.jsx(q,{component:"span",display:"inline-flex",mr:.5,children:s.jsx(ye,{from:a??0,to:o,map:l,children:"0"})}),s.jsxs(q,{component:"span",direction:"row",display:"inline-flex",children:["(",s.jsx(ye,{from:c??0,to:i,map:l,children:"0"}),"%)"]})]}),s.jsx(R,{variant:"body1",children:e.value}),e.payload.uuid&&s.jsxs(R,{variant:"body2",sx:{cursor:"pointer","&:hover":{textDecoration:"underline"}},onClick:()=>{u.copy(e.payload.uuid).catch(()=>{}),m.enqueueSnackbar("UUID copied to clipboard","success")},children:[e.payload.uuid.slice(0,5),"..."]})]})]})}function xe(e){const{payload:n}=e;return s.jsx(ve,{container:!0,direction:"row",component:"ul",gap:2,sx:{mt:2,justifyContent:"flex-start",alignItem:"center",flexWrap:"wrap"},children:s.jsx(Re,{children:n?.map(t=>s.jsx(ve,{children:s.jsx(Nn,{entry:t,payload:n})},`item-${t.value}`))})})}function Tn(e){const n=Q();return s.jsx(P,{sx:{width:"100%",height:"100%",...e.sx},children:s.jsx(ee,{children:s.jsxs(Te,{width:500,height:300,margin:{top:5,right:60,left:20,bottom:5},children:[s.jsx(ne,{vertical:!1}),s.jsx(te,{dataKey:"date",type:"number",domain:["dataMin","dataMax"],tickFormatter:t=>fe(t,{timeZone:e.filter.timezone,hour12:!1,hour:"numeric"}),allowDuplicatedCategory:!1,tickLine:!1,fontSize:12,tickMargin:12}),s.jsx(re,{textAnchor:"end",dataKey:"value",tickLine:!1,tickFormatter:t=>Number(t).toLocaleString(),allowDecimals:!1,domain:[1,"dataMax"],children:e.label&&s.jsx(Ee,{value:e.label,angle:-90,position:"insideLeft",style:{textAnchor:"middle"}})}),s.jsx(oe,{cursor:{stroke:n.palette.neutral.main,strokeWidth:1},formatter:t=>Number(t).toLocaleString(),labelFormatter:t=>he(t,{timeZone:e.filter.timezone,hour12:!1})}),s.jsx(Ae,{content:s.jsx(xe,{})}),e.data.map(t=>_e(Ce,{uuid:t.uuid,key:t.uuid,name:t.name,dataKey:"value",data:t.chartData,type:"monotone",stroke:t.color,strokeWidth:2}))]})})})}const En=(e,n)=>{const t=new Map;return e.forEach(r=>{r.chartData.forEach(o=>{const a=new Date(o.date).getTime().toString();if(!t.has(a)){const i={date:a,total:0,diff:0,totalKey:"",originalTotal:0};n.forEach(({key:c})=>{i[c]=0,i[`${c}_absolute`]=0}),t.set(a,i)}n.forEach(({key:i})=>{const c=t.get(a),l=o[i],u=typeof l=="string"?l.trim()===""?0:parseInt(l,10):typeof l=="number"?l:0;c[`${i}_absolute`]=u,c[i]=0})})}),Array.from(t.values()).map(r=>{var o;const a=(o=n.find(l=>l.isTotal))==null?void 0:o.key,i=n.filter(l=>!l.isTotal).map(l=>l.key);if(!a||i.length===0)return r;const c=r[`${a}_absolute`];return r.originalTotal=c,r.total=c,r[a]=100,i.forEach(l=>{const u=r[`${l}_absolute`],m=c>0?new z(u.toString()).div(c).mul(100).toFixed(2,z.ROUND_DOWN):"0.00";r[l]=parseFloat(m)}),{...r,totalKey:a}}).sort((r,o)=>parseInt(r.date)-parseInt(o.date))};function An(e){const n=Q(),t=J(()=>e.data?En(e.data,e.keyValues):[],[e.data,e.keyValues]);return s.jsx(P,{sx:{width:"100%",height:"100%",...e.sx},children:s.jsx(ee,{width:"100%",height:"100%",children:s.jsxs(Ge,{data:t,width:500,height:300,margin:{top:5,right:60,left:20,bottom:5},children:[s.jsx(ne,{strokeDasharray:"3 3"}),s.jsx(te,{dataKey:"date",type:"number",domain:["dataMin","dataMax"],tickFormatter:r=>fe(r,{timeZone:e.filter.timezone,hour12:!1,hour:"numeric"}),allowDuplicatedCategory:!1,tickLine:!1,fontSize:12,tickMargin:12}),s.jsx(re,{textAnchor:"end",tickLine:!1,tickFormatter:r=>`${r.toFixed(2)}%`}),s.jsx(oe,{cursor:{stroke:n.palette.neutral.main,strokeWidth:1},labelFormatter:r=>he(r,{timeZone:e.filter.timezone,hour12:!1}),formatter:(r,o,a)=>{const i=a.payload.totalKey,c=a.dataKey,l=c===i,u=a.payload[`${c}_absolute`],m=a.payload.originalTotal,f=l?null:m===0?"0.00":new z(u.toString()).div(m).mul(100).toFixed(2,z.ROUND_DOWN);return[f?`${u.toLocaleString()} (${f}%)`:`${u.toLocaleString()} (TOTAL)`,o]}}),e.keyValues.sort((r,o)=>r.isTotal?-1:o.isTotal?1:0).map(r=>s.jsx(Le,{type:"monotone",dataKey:r.key,name:r.name,stroke:r.color,fill:r.color,strokeWidth:2,fillOpacity:.6},r.key))]})})})}function Cn(e){const n=ie(e.value),{ref:t}=en({from:n??0,to:e.value,duration:1,map:e.map});return s.jsx(Ne,{sx:{p:3,flex:1,...e.sx},children:s.jsxs(q,{spacing:1,alignItems:"center",children:[s.jsx(R,{ref:t,variant:"h4",fontWeight:"bold",children:e.initialValue}),s.jsx(R,{color:"text.secondary",children:e.label})]})})}function Gn({data:e,color:n,xAxisProps:t,yAxisProps:r,sx:o}){const a=Q();return s.jsx(P,{sx:{width:"100%",height:"100%",...o},children:s.jsx(ee,{children:s.jsxs(De,{data:e,margin:{top:5,right:30,left:20,bottom:5},children:[s.jsx(ne,{strokeDasharray:"3 3",vertical:!1}),s.jsx(te,{dataKey:"key",tickLine:!1,fontSize:12,tickMargin:12,...t}),s.jsx(re,{textAnchor:"end",tickLine:!1,...r}),s.jsx(oe,{cursor:{stroke:a.palette.neutral.main,strokeWidth:1}}),s.jsx(Me,{dataKey:"value",fill:n,isAnimationActive:!1})]})})})}export{Cn as BigNumber,Tn as SeriesChart,xe as SeriesChartLegend,An as SeriesPercentageChart,Gn as SimpleBarChart};
1
+ "use strict";import{j as s}from"../../shared/jsx-runtime-jmtevAuS.mjs";import*as G from"react";import{useCallback as H,useMemo as J,createElement as _e}from"react";import{Box as P,Stack as z,Typography as R,useTheme as Q,Paper as Te}from"@mui/material";import{ResponsiveContainer as ee,LineChart as Ee,CartesianGrid as ne,XAxis as te,YAxis as oe,Label as Ae,Tooltip as re,Legend as Ce,Line as Ge,AreaChart as Le,Area as De,ComposedChart as Me,ReferenceLine as fe,Bar as Re}from"recharts";import{b as he,c as ye}from"../../shared/date-Cq0LS2Mr.mjs";import q,{Decimal as ae}from"decimal.js";import{AnimatePresence as Fe}from"framer-motion";import{u as We}from"../../shared/useCopyToClipboard-BALOSYVW.mjs";import"qrcode";import{u as ie}from"../../shared/usePrevious-DyvR1iCQ.mjs";import{a as Ie,C as be}from"../../shared/motions-CpxgbzKX.mjs";import{i as Ke,_ as B,s as Ve,a as f,c as ge,d as Pe,e as ze,f as qe,h as Be,j as Ue,k as Ze,l as Xe,m as Ye,n as He,o as Je,p as Qe,u as en}from"../../shared/index-CDq4CkLc.mjs";import{u as nn}from"../../shared/useCounter-BV32zXDQ.mjs";const tn=["ownerState"],on=["variants"],rn=["name","slot","skipVariantsResolver","skipSx","overridesResolver"];function an(e){return Object.keys(e).length===0}function sn(e){return typeof e=="string"&&e.charCodeAt(0)>96}function se(e){return e!=="ownerState"&&e!=="theme"&&e!=="sx"&&e!=="as"}const ln=ge(),cn=e=>e&&e.charAt(0).toLowerCase()+e.slice(1);function U({defaultTheme:e,theme:n,themeId:t}){return an(n)?e:n[t]||n}function un(e){return e?(n,t)=>t[e]:null}function Z(e,n){let{ownerState:t}=n,o=B(n,tn);const a=typeof e=="function"?e(f({ownerState:t},o)):e;if(Array.isArray(a))return a.flatMap(r=>Z(r,f({ownerState:t},o)));if(a&&typeof a=="object"&&Array.isArray(a.variants)){const{variants:r=[]}=a;let i=B(a,on);return r.forEach(c=>{let l=!0;typeof c.props=="function"?l=c.props(f({ownerState:t},o,t)):Object.keys(c.props).forEach(u=>{t?.[u]!==c.props[u]&&o[u]!==c.props[u]&&(l=!1)}),l&&(Array.isArray(i)||(i=[i]),i.push(typeof c.style=="function"?c.style(f({ownerState:t},o,t)):c.style))}),i}return a}function pn(e={}){const{themeId:n,defaultTheme:t=ln,rootShouldForwardProp:o=se,slotShouldForwardProp:a=se}=e,r=i=>Pe(f({},i,{theme:U(f({},i,{defaultTheme:t,themeId:n}))}));return r.__mui_systemSx=!0,(i,c={})=>{Ke(i,m=>m.filter(w=>!(w!=null&&w.__mui_systemSx)));const{name:l,slot:u,skipVariantsResolver:p,skipSx:d,overridesResolver:y=un(cn(u))}=c,h=B(c,rn),x=p!==void 0?p:u&&u!=="Root"&&u!=="root"||!1,b=d||!1;let j,k=se;u==="Root"||u==="root"?k=o:u?k=a:sn(i)&&(k=void 0);const N=Ve(i,f({shouldForwardProp:k,label:j},h)),W=m=>typeof m=="function"&&m.__emotion_real!==m||ze(m)?w=>Z(m,f({},w,{theme:U({theme:w.theme,defaultTheme:t,themeId:n})})):m,E=(m,...w)=>{let D=W(m);const _=w?w.map(W):[];l&&y&&_.push(g=>{const v=U(f({},g,{defaultTheme:t,themeId:n}));if(!v.components||!v.components[l]||!v.components[l].styleOverrides)return null;const S=v.components[l].styleOverrides,A={};return Object.entries(S).forEach(([X,V])=>{A[X]=Z(V,f({},g,{theme:v}))}),y(g,A)}),l&&!x&&_.push(g=>{var v;const S=U(f({},g,{defaultTheme:t,themeId:n})),A=S==null||(v=S.components)==null||(v=v[l])==null?void 0:v.variants;return Z({variants:A},f({},g,{theme:S}))}),b||_.push(r);const I=_.length-w.length;if(Array.isArray(m)&&I>0){const g=new Array(I).fill("");D=[...m,...g],D.raw=[...m.raw,...g]}const K=N(D,..._);return i.muiName&&(K.muiName=i.muiName),K};return N.withConfig&&(E.withConfig=N.withConfig),E}}const dn=pn(),mn=(e,n)=>e.filter(t=>n.includes(t)),L=(e,n,t)=>{const o=e.keys[0];Array.isArray(n)?n.forEach((a,r)=>{t((i,c)=>{r<=e.keys.length-1&&(r===0?Object.assign(i,c):i[e.up(e.keys[r])]=c)},a)}):n&&typeof n=="object"?(Object.keys(n).length>e.keys.length?e.keys:mn(e.keys,Object.keys(n))).forEach(a=>{if(e.keys.indexOf(a)!==-1){const r=n[a];r!==void 0&&t((i,c)=>{o===a?Object.assign(i,c):i[e.up(a)]=c},r)}}):(typeof n=="number"||typeof n=="string")&&t((a,r)=>{Object.assign(a,r)},n)};function $(e){return e?`Level${e}`:""}function F(e){return e.unstable_level>0&&e.container}function ve(e){return function(n){return`var(--Grid-${n}Spacing${$(e.unstable_level)})`}}function le(e){return function(n){return e.unstable_level===0?`var(--Grid-${n}Spacing)`:`var(--Grid-${n}Spacing${$(e.unstable_level-1)})`}}function ce(e){return e.unstable_level===0?"var(--Grid-columns)":`var(--Grid-columns${$(e.unstable_level-1)})`}const fn=({theme:e,ownerState:n})=>{const t=ve(n),o={};return L(e.breakpoints,n.gridSize,(a,r)=>{let i={};r===!0&&(i={flexBasis:0,flexGrow:1,maxWidth:"100%"}),r==="auto"&&(i={flexBasis:"auto",flexGrow:0,flexShrink:0,maxWidth:"none",width:"auto"}),typeof r=="number"&&(i={flexGrow:0,flexBasis:"auto",width:`calc(100% * ${r} / ${ce(n)}${F(n)?` + ${t("column")}`:""})`}),a(o,i)}),o},hn=({theme:e,ownerState:n})=>{const t={};return L(e.breakpoints,n.gridOffset,(o,a)=>{let r={};a==="auto"&&(r={marginLeft:"auto"}),typeof a=="number"&&(r={marginLeft:a===0?"0px":`calc(100% * ${a} / ${ce(n)})`}),o(t,r)}),t},yn=({theme:e,ownerState:n})=>{if(!n.container)return{};const t=F(n)?{[`--Grid-columns${$(n.unstable_level)}`]:ce(n)}:{"--Grid-columns":12};return L(e.breakpoints,n.columns,(o,a)=>{o(t,{[`--Grid-columns${$(n.unstable_level)}`]:a})}),t},bn=({theme:e,ownerState:n})=>{if(!n.container)return{};const t=le(n),o=F(n)?{[`--Grid-rowSpacing${$(n.unstable_level)}`]:t("row")}:{};return L(e.breakpoints,n.rowSpacing,(a,r)=>{var i;a(o,{[`--Grid-rowSpacing${$(n.unstable_level)}`]:typeof r=="string"?r:(i=e.spacing)==null?void 0:i.call(e,r)})}),o},gn=({theme:e,ownerState:n})=>{if(!n.container)return{};const t=le(n),o=F(n)?{[`--Grid-columnSpacing${$(n.unstable_level)}`]:t("column")}:{};return L(e.breakpoints,n.columnSpacing,(a,r)=>{var i;a(o,{[`--Grid-columnSpacing${$(n.unstable_level)}`]:typeof r=="string"?r:(i=e.spacing)==null?void 0:i.call(e,r)})}),o},vn=({theme:e,ownerState:n})=>{if(!n.container)return{};const t={};return L(e.breakpoints,n.direction,(o,a)=>{o(t,{flexDirection:a})}),t},xn=({ownerState:e})=>{const n=ve(e),t=le(e);return f({minWidth:0,boxSizing:"border-box"},e.container&&f({display:"flex",flexWrap:"wrap"},e.wrap&&e.wrap!=="wrap"&&{flexWrap:e.wrap},{margin:`calc(${n("row")} / -2) calc(${n("column")} / -2)`},e.disableEqualOverflow&&{margin:`calc(${n("row")} * -1) 0px 0px calc(${n("column")} * -1)`}),(!e.container||F(e))&&f({padding:`calc(${t("row")} / 2) calc(${t("column")} / 2)`},(e.disableEqualOverflow||e.parentDisableEqualOverflow)&&{padding:`${t("row")} 0px 0px ${t("column")}`}))},wn=e=>{const n=[];return Object.entries(e).forEach(([t,o])=>{o!==!1&&o!==void 0&&n.push(`grid-${t}-${String(o)}`)}),n},On=(e,n="xs")=>{function t(o){return o===void 0?!1:typeof o=="string"&&!Number.isNaN(Number(o))||typeof o=="number"&&o>0}if(t(e))return[`spacing-${n}-${String(e)}`];if(typeof e=="object"&&!Array.isArray(e)){const o=[];return Object.entries(e).forEach(([a,r])=>{t(r)&&o.push(`spacing-${a}-${String(r)}`)}),o}return[]},jn=e=>e===void 0?[]:typeof e=="object"?Object.entries(e).map(([n,t])=>`direction-${n}-${t}`):[`direction-xs-${String(e)}`],kn=["className","children","columns","container","component","direction","wrap","spacing","rowSpacing","columnSpacing","disableEqualOverflow","unstable_level"],Sn=ge(),$n=dn("div",{name:"MuiGrid",slot:"Root",overridesResolver:(e,n)=>n.root});function Nn(e){return Xe({props:e,name:"MuiGrid",defaultTheme:Sn})}function _n(e={}){const{createStyledComponent:n=$n,useThemeProps:t=Nn,componentName:o="MuiGrid"}=e,a=G.createContext(void 0),r=(l,u)=>{const{container:p,direction:d,spacing:y,wrap:h,gridSize:x}=l,b={root:["root",p&&"container",h!=="wrap"&&`wrap-xs-${String(h)}`,...jn(d),...wn(x),...p?On(y,u.breakpoints.keys[0]):[]]};return Ye(b,j=>He(o,j),{})},i=n(yn,gn,bn,fn,vn,xn,hn),c=G.forwardRef(function(l,u){var p,d,y,h,x,b,j,k;const N=qe(),W=t(l),E=Be(W),m=G.useContext(a),{className:w,children:D,columns:_=12,container:I=!1,component:K="div",direction:g="row",wrap:v="wrap",spacing:S=0,rowSpacing:A=S,columnSpacing:X=S,disableEqualOverflow:V,unstable_level:T=0}=E,Oe=B(E,kn);let M=V;T&&V!==void 0&&(M=l.disableEqualOverflow);const ue={},pe={},de={};Object.entries(Oe).forEach(([O,C])=>{N.breakpoints.values[O]!==void 0?ue[O]=C:N.breakpoints.values[O.replace("Offset","")]!==void 0?pe[O.replace("Offset","")]=C:de[O]=C});const je=(p=l.columns)!=null?p:T?void 0:_,ke=(d=l.spacing)!=null?d:T?void 0:S,Se=(y=(h=l.rowSpacing)!=null?h:l.spacing)!=null?y:T?void 0:A,$e=(x=(b=l.columnSpacing)!=null?b:l.spacing)!=null?x:T?void 0:X,me=f({},E,{level:T,columns:je,container:I,direction:g,wrap:v,spacing:ke,rowSpacing:Se,columnSpacing:$e,gridSize:ue,gridOffset:pe,disableEqualOverflow:(j=(k=M)!=null?k:m)!=null?j:!1,parentDisableEqualOverflow:m}),Ne=r(me,N);let Y=s.jsx(i,f({ref:u,as:K,ownerState:me,className:Ue(Ne.root,w)},de,{children:G.Children.map(D,O=>{if(G.isValidElement(O)&&Ze(O,["Grid"])){var C;return G.cloneElement(O,{unstable_level:(C=O.props.unstable_level)!=null?C:T+1})}return O})}));return M!==void 0&&M!==(m??!1)&&(Y=s.jsx(a.Provider,{value:M,children:Y})),Y});return c.muiName="Grid",c}const xe=_n({createStyledComponent:Je("div",{name:"MuiGrid2",slot:"Root",overridesResolver:(e,n)=>n.root}),componentName:"MuiGrid2",useThemeProps:e=>Qe({props:e,name:"MuiGrid2"})});function Tn({entry:e,payload:n}){const t=H(d=>{var y,h,x;return(x=(h=(y=d.payload)==null?void 0:y.data)==null?void 0:h.reduce)==null?void 0:x.call(h,(b,j)=>b+j.value,0)},[]),o=H(d=>{const y=new ae(t(d)||0),h=n?.reduce((j,k)=>j+t(k),0)||0,x=new ae(h),b=Number(y.div(x).times(100).toFixed(2,ae.ROUND_DOWN));return isNaN(b)||!isFinite(b)?0:b},[t,n]),a=J(()=>t(e),[e,t]),r=ie(a),i=J(()=>Number(o(e)),[e,o]),c=ie(i),l=H(d=>Math.floor(d).toLocaleString(),[]),u=We({type:"text/plain"}),p=en();return s.jsxs(Ie,{component:"li",direction:"row",spacing:1,sx:{color:e.color},layout:"position",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},children:[s.jsx(P,{sx:{width:"3px",height:"100%",backgroundColor:e.color,borderRadius:3}}),s.jsxs(z,{children:[s.jsxs(R,{component:"p",variant:"caption",children:[s.jsx(z,{component:"span",display:"inline-flex",mr:.5,children:s.jsx(be,{from:r??0,to:a,map:l,children:"0"})}),s.jsxs(z,{component:"span",direction:"row",display:"inline-flex",children:["(",s.jsx(be,{from:c??0,to:i,map:l,children:"0"}),"%)"]})]}),s.jsx(R,{variant:"body1",children:e.value}),e.payload.uuid&&s.jsxs(R,{variant:"body2",sx:{cursor:"pointer","&:hover":{textDecoration:"underline"}},onClick:()=>{u.copy(e.payload.uuid).catch(()=>{}),p.enqueueSnackbar("UUID copied to clipboard","success")},children:[e.payload.uuid.slice(0,5),"..."]})]})]})}function we(e){const{payload:n}=e;return s.jsx(xe,{container:!0,direction:"row",component:"ul",gap:2,sx:{mt:2,justifyContent:"flex-start",alignItem:"center",flexWrap:"wrap"},children:s.jsx(Fe,{children:n?.map(t=>s.jsx(xe,{children:s.jsx(Tn,{entry:t,payload:n})},`item-${t.value}`))})})}function En(e){const n=Q();return s.jsx(P,{sx:{width:"100%",height:"100%",...e.sx},children:s.jsx(ee,{children:s.jsxs(Ee,{width:500,height:300,margin:{top:5,right:60,left:20,bottom:5},children:[s.jsx(ne,{vertical:!1}),s.jsx(te,{dataKey:"date",type:"number",domain:["dataMin","dataMax"],tickFormatter:t=>he(t,{timeZone:e.filter.timezone,hour12:!1,hour:"numeric"}),allowDuplicatedCategory:!1,tickLine:!1,fontSize:12,tickMargin:12}),s.jsx(oe,{textAnchor:"end",dataKey:"value",tickLine:!1,tickFormatter:t=>Number(t).toLocaleString(),allowDecimals:!1,domain:[1,"dataMax"],children:e.label&&s.jsx(Ae,{value:e.label,angle:-90,position:"insideLeft",style:{textAnchor:"middle"}})}),s.jsx(re,{cursor:{stroke:n.palette.neutral.main,strokeWidth:1},formatter:t=>Number(t).toLocaleString(),labelFormatter:t=>ye(t,{timeZone:e.filter.timezone,hour12:!1})}),s.jsx(Ce,{content:s.jsx(we,{})}),e.data.map(t=>_e(Ge,{uuid:t.uuid,key:t.uuid,name:t.name,dataKey:"value",data:t.chartData,type:"monotone",stroke:t.color,strokeWidth:2}))]})})})}const An=(e,n)=>{const t=new Map;return e.forEach(o=>{o.chartData.forEach(a=>{const r=new Date(a.date).getTime().toString();if(!t.has(r)){const i={date:r,total:0,diff:0,totalKey:"",originalTotal:0};n.forEach(({key:c})=>{i[c]=0,i[`${c}_absolute`]=0}),t.set(r,i)}n.forEach(({key:i})=>{const c=t.get(r),l=a[i],u=typeof l=="string"?l.trim()===""?0:parseInt(l,10):typeof l=="number"?l:0;c[`${i}_absolute`]=u,c[i]=0})})}),Array.from(t.values()).map(o=>{var a;const r=(a=n.find(l=>l.isTotal))==null?void 0:a.key,i=n.filter(l=>!l.isTotal).map(l=>l.key);if(!r||i.length===0)return o;const c=o[`${r}_absolute`];return o.originalTotal=c,o.total=c,o[r]=100,i.forEach(l=>{const u=o[`${l}_absolute`],p=c>0?new q(u.toString()).div(c).mul(100).toFixed(2,q.ROUND_DOWN):"0.00";o[l]=parseFloat(p)}),{...o,totalKey:r}}).sort((o,a)=>parseInt(o.date)-parseInt(a.date))};function Cn(e){const n=Q(),t=J(()=>e.data?An(e.data,e.keyValues):[],[e.data,e.keyValues]);return s.jsx(P,{sx:{width:"100%",height:"100%",...e.sx},children:s.jsx(ee,{width:"100%",height:"100%",children:s.jsxs(Le,{data:t,width:500,height:300,margin:{top:5,right:60,left:20,bottom:5},children:[s.jsx(ne,{strokeDasharray:"3 3"}),s.jsx(te,{dataKey:"date",type:"number",domain:["dataMin","dataMax"],tickFormatter:o=>he(o,{timeZone:e.filter.timezone,hour12:!1,hour:"numeric"}),allowDuplicatedCategory:!1,tickLine:!1,fontSize:12,tickMargin:12}),s.jsx(oe,{textAnchor:"end",tickLine:!1,tickFormatter:o=>`${o.toFixed(2)}%`}),s.jsx(re,{cursor:{stroke:n.palette.neutral.main,strokeWidth:1},labelFormatter:o=>ye(o,{timeZone:e.filter.timezone,hour12:!1}),formatter:(o,a,r)=>{const i=r.payload.totalKey,c=r.dataKey,l=c===i,u=r.payload[`${c}_absolute`],p=r.payload.originalTotal,d=l?null:p===0?"0.00":new q(u.toString()).div(p).mul(100).toFixed(2,q.ROUND_DOWN);return[d?`${u.toLocaleString()} (${d}%)`:`${u.toLocaleString()} (TOTAL)`,a]}}),e.keyValues.sort((o,a)=>o.isTotal?-1:a.isTotal?1:0).map(o=>s.jsx(De,{type:"monotone",dataKey:o.key,name:o.name,stroke:o.color,fill:o.color,strokeWidth:2,fillOpacity:.6},o.key))]})})})}function Gn(e){const n=ie(e.value),{ref:t}=nn({from:n??0,to:e.value,duration:1,map:e.map});return s.jsx(Te,{sx:{p:3,flex:1,...e.sx},children:s.jsxs(z,{spacing:1,alignItems:"center",children:[s.jsx(R,{ref:t,variant:"h4",fontWeight:"bold",children:e.initialValue}),s.jsx(R,{color:"text.secondary",children:e.label})]})})}function Ln({data:e,series:n,xAxisDataKey:t,xAxisProps:o,yAxisProps:a,referenceLines:r,sx:i}){const c=Q(),l=p=>!p.isFront,u=p=>!!p.isFront;return s.jsx(P,{sx:{width:"100%",height:"100%",...i},children:s.jsx(ee,{children:s.jsxs(Me,{data:e,margin:{top:5,right:30,left:20,bottom:5},children:[s.jsx(ne,{strokeDasharray:"3 3",vertical:!1}),s.jsx(te,{dataKey:t,tickLine:!1,fontSize:12,tickMargin:12,...o}),s.jsx(oe,{textAnchor:"end",tickLine:!1,...a}),s.jsx(re,{cursor:{stroke:c.palette.neutral.main,strokeWidth:1}}),r?.filter(l).map((p,d)=>s.jsx(fe,{...p},d)),n.map(p=>s.jsx(Re,{name:p.key,dataKey:p.dataKey,fill:p.color,stackId:"stack",isAnimationActive:!1},p.key)),r?.filter(u).map((p,d)=>s.jsx(fe,{...p},d))]})})})}export{Gn as BigNumber,En as SeriesChart,we as SeriesChartLegend,Cn as SeriesPercentageChart,Ln as SimpleBarChart};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verifiedinc-public/shared-ui-elements",
3
- "version": "3.7.0",
3
+ "version": "3.8.1",
4
4
  "description": "A set of UI components, utilities that is shareable with the core apps.",
5
5
  "private": false,
6
6
  "keywords": [],