@verifiedinc-public/shared-ui-elements 3.8.1 → 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.
@@ -1,6 +1,6 @@
1
1
  import { ComponentProps, ReactElement } from 'react';
2
2
  import { SxProps } from '@mui/material';
3
- import { ReferenceLine, XAxis, YAxis } from 'recharts';
3
+ import { Bar, ReferenceLine, Tooltip, XAxis, YAxis } from 'recharts';
4
4
  interface Series {
5
5
  key: string;
6
6
  dataKey: string;
@@ -9,11 +9,12 @@ interface Series {
9
9
  interface SimpleBarChartProps {
10
10
  data: Array<Record<string, number | string>>;
11
11
  series: Series[];
12
- xAxisDataKey: string;
13
- xAxisProps?: ComponentProps<typeof XAxis>;
14
- yAxisProps?: ComponentProps<typeof YAxis>;
12
+ xAxis?: ComponentProps<typeof XAxis>;
13
+ yAxis?: ComponentProps<typeof YAxis>;
14
+ tooltip?: ComponentProps<typeof Tooltip>;
15
+ bar?: ComponentProps<typeof Bar>;
15
16
  referenceLines?: Array<ComponentProps<typeof ReferenceLine>>;
16
17
  sx?: SxProps;
17
18
  }
18
- export declare function SimpleBarChart({ data, series, xAxisDataKey, xAxisProps, yAxisProps, referenceLines, sx, }: SimpleBarChartProps): ReactElement;
19
+ export declare function SimpleBarChart({ data, series, xAxis, yAxis, tooltip, bar, referenceLines, sx, }: SimpleBarChartProps): ReactElement;
19
20
  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 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};
1
+ "use strict";import{j as s}from"../../shared/jsx-runtime-jmtevAuS.mjs";import*as D from"react";import{useCallback as J,useMemo as Q,createElement as _e}from"react";import{Box as z,Stack as P,Typography as R,useTheme as Y,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 De,AreaChart as Le,Area as Ge,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 xe}from"../../shared/motions-CpxgbzKX.mjs";import{i as Ve,_ as B,s as Ke,a as f,c as be,d as ze,e as Pe,f as qe,h as Be,j as Ue,k as Ze,l as Xe,m as He,n as Je,o as Qe,p as Ye,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=be(),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 r=typeof e=="function"?e(f({ownerState:t},o)):e;if(Array.isArray(r))return r.flatMap(a=>Z(a,f({ownerState:t},o)));if(r&&typeof r=="object"&&Array.isArray(r.variants)){const{variants:a=[]}=r;let i=B(r,on);return a.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 r}function pn(e={}){const{themeId:n,defaultTheme:t=ln,rootShouldForwardProp:o=se,slotShouldForwardProp:r=se}=e,a=i=>ze(f({},i,{theme:U(f({},i,{defaultTheme:t,themeId:n}))}));return a.__mui_systemSx=!0,(i,c={})=>{Ve(i,m=>m.filter(w=>!(w!=null&&w.__mui_systemSx)));const{name:l,slot:u,skipVariantsResolver:d,skipSx:p,overridesResolver:h=un(cn(u))}=c,y=B(c,rn),v=d!==void 0?d:u&&u!=="Root"&&u!=="root"||!1,x=p||!1;let j,k=se;u==="Root"||u==="root"?k=o:u?k=r:sn(i)&&(k=void 0);const N=Ke(i,f({shouldForwardProp:k,label:j},y)),W=m=>typeof m=="function"&&m.__emotion_real!==m||Pe(m)?w=>Z(m,f({},w,{theme:U({theme:w.theme,defaultTheme:t,themeId:n})})):m,E=(m,...w)=>{let G=W(m);const _=w?w.map(W):[];l&&h&&_.push(b=>{const g=U(f({},b,{defaultTheme:t,themeId:n}));if(!g.components||!g.components[l]||!g.components[l].styleOverrides)return null;const S=g.components[l].styleOverrides,A={};return Object.entries(S).forEach(([X,K])=>{A[X]=Z(K,f({},b,{theme:g}))}),h(b,A)}),l&&!v&&_.push(b=>{var g;const S=U(f({},b,{defaultTheme:t,themeId:n})),A=S==null||(g=S.components)==null||(g=g[l])==null?void 0:g.variants;return Z({variants:A},f({},b,{theme:S}))}),x||_.push(a);const I=_.length-w.length;if(Array.isArray(m)&&I>0){const b=new Array(I).fill("");G=[...m,...b],G.raw=[...m.raw,...b]}const V=N(G,..._);return i.muiName&&(V.muiName=i.muiName),V};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((r,a)=>{t((i,c)=>{a<=e.keys.length-1&&(a===0?Object.assign(i,c):i[e.up(e.keys[a])]=c)},r)}):n&&typeof n=="object"?(Object.keys(n).length>e.keys.length?e.keys:mn(e.keys,Object.keys(n))).forEach(r=>{if(e.keys.indexOf(r)!==-1){const a=n[r];a!==void 0&&t((i,c)=>{o===r?Object.assign(i,c):i[e.up(r)]=c},a)}}):(typeof n=="number"||typeof n=="string")&&t((r,a)=>{Object.assign(r,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 fn=({theme:e,ownerState:n})=>{const t=ge(n),o={};return L(e.breakpoints,n.gridSize,(r,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")}`:""})`}),r(o,i)}),o},hn=({theme:e,ownerState:n})=>{const t={};return L(e.breakpoints,n.gridOffset,(o,r)=>{let a={};r==="auto"&&(a={marginLeft:"auto"}),typeof r=="number"&&(a={marginLeft:r===0?"0px":`calc(100% * ${r} / ${ce(n)})`}),o(t,a)}),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,r)=>{o(t,{[`--Grid-columns${$(n.unstable_level)}`]:r})}),t},xn=({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,(r,a)=>{var i;r(o,{[`--Grid-rowSpacing${$(n.unstable_level)}`]:typeof a=="string"?a:(i=e.spacing)==null?void 0:i.call(e,a)})}),o},bn=({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,(r,a)=>{var i;r(o,{[`--Grid-columnSpacing${$(n.unstable_level)}`]:typeof a=="string"?a:(i=e.spacing)==null?void 0:i.call(e,a)})}),o},gn=({theme:e,ownerState:n})=>{if(!n.container)return{};const t={};return L(e.breakpoints,n.direction,(o,r)=>{o(t,{flexDirection:r})}),t},vn=({ownerState:e})=>{const n=ge(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(([r,a])=>{t(a)&&o.push(`spacing-${r}-${String(a)}`)}),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=be(),$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,r=D.createContext(void 0),a=(l,u)=>{const{container:d,direction:p,spacing:h,wrap:y,gridSize:v}=l,x={root:["root",d&&"container",y!=="wrap"&&`wrap-xs-${String(y)}`,...jn(p),...wn(v),...d?On(h,u.breakpoints.keys[0]):[]]};return He(x,j=>Je(o,j),{})},i=n(yn,bn,xn,fn,gn,vn,hn),c=D.forwardRef(function(l,u){var d,p,h,y,v,x,j,k;const N=qe(),W=t(l),E=Be(W),m=D.useContext(r),{className:w,children:G,columns:_=12,container:I=!1,component:V="div",direction:b="row",wrap:g="wrap",spacing:S=0,rowSpacing:A=S,columnSpacing:X=S,disableEqualOverflow:K,unstable_level:T=0}=E,Oe=B(E,kn);let M=K;T&&K!==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=(d=l.columns)!=null?d:T?void 0:_,ke=(p=l.spacing)!=null?p:T?void 0:S,Se=(h=(y=l.rowSpacing)!=null?y:l.spacing)!=null?h:T?void 0:A,$e=(v=(x=l.columnSpacing)!=null?x:l.spacing)!=null?v:T?void 0:X,me=f({},E,{level:T,columns:je,container:I,direction:b,wrap:g,spacing:ke,rowSpacing:Se,columnSpacing:$e,gridSize:ue,gridOffset:pe,disableEqualOverflow:(j=(k=M)!=null?k:m)!=null?j:!1,parentDisableEqualOverflow:m}),Ne=a(me,N);let H=s.jsx(i,f({ref:u,as:V,ownerState:me,className:Ue(Ne.root,w)},de,{children:D.Children.map(G,O=>{if(D.isValidElement(O)&&Ze(O,["Grid"])){var C;return D.cloneElement(O,{unstable_level:(C=O.props.unstable_level)!=null?C:T+1})}return O})}));return M!==void 0&&M!==(m??!1)&&(H=s.jsx(r.Provider,{value:M,children:H})),H});return c.muiName="Grid",c}const ve=_n({createStyledComponent:Qe("div",{name:"MuiGrid2",slot:"Root",overridesResolver:(e,n)=>n.root}),componentName:"MuiGrid2",useThemeProps:e=>Ye({props:e,name:"MuiGrid2"})});function Tn({entry:e,payload:n}){const t=J(p=>{var h,y,v;return(v=(y=(h=p.payload)==null?void 0:h.data)==null?void 0:y.reduce)==null?void 0:v.call(y,(x,j)=>x+j.value,0)},[]),o=J(p=>{const h=new ae(t(p)||0),y=n?.reduce((j,k)=>j+t(k),0)||0,v=new ae(y),x=Number(h.div(v).times(100).toFixed(2,ae.ROUND_DOWN));return isNaN(x)||!isFinite(x)?0:x},[t,n]),r=Q(()=>t(e),[e,t]),a=ie(r),i=Q(()=>Number(o(e)),[e,o]),c=ie(i),l=J(p=>Math.floor(p).toLocaleString(),[]),u=We({type:"text/plain"}),d=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(z,{sx:{width:"3px",height:"100%",backgroundColor:e.color,borderRadius:3}}),s.jsxs(P,{children:[s.jsxs(R,{component:"p",variant:"caption",children:[s.jsx(P,{component:"span",display:"inline-flex",mr:.5,children:s.jsx(xe,{from:a??0,to:r,map:l,children:"0"})}),s.jsxs(P,{component:"span",direction:"row",display:"inline-flex",children:["(",s.jsx(xe,{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(()=>{}),d.enqueueSnackbar("UUID copied to clipboard","success")},children:[e.payload.uuid.slice(0,5),"..."]})]})]})}function we(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(Fe,{children:n?.map(t=>s.jsx(ve,{children:s.jsx(Tn,{entry:t,payload:n})},`item-${t.value}`))})})}function En(e){const n=Y();return s.jsx(z,{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(De,{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(r=>{const a=new Date(r.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=r[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 r;const a=(r=n.find(l=>l.isTotal))==null?void 0:r.key,i=n.filter(l=>!l.isTotal).map(l=>l.key);if(!a||i.length===0)return o;const c=o[`${a}_absolute`];return o.originalTotal=c,o.total=c,o[a]=100,i.forEach(l=>{const u=o[`${l}_absolute`],d=c>0?new q(u.toString()).div(c).mul(100).toFixed(2,q.ROUND_DOWN):"0.00";o[l]=parseFloat(d)}),{...o,totalKey:a}}).sort((o,r)=>parseInt(o.date)-parseInt(r.date))};function Cn(e){const n=Y(),t=Q(()=>e.data?An(e.data,e.keyValues):[],[e.data,e.keyValues]);return s.jsx(z,{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,r,a)=>{const i=a.payload.totalKey,c=a.dataKey,l=c===i,u=a.payload[`${c}_absolute`],d=a.payload.originalTotal,p=l?null:d===0?"0.00":new q(u.toString()).div(d).mul(100).toFixed(2,q.ROUND_DOWN);return[p?`${u.toLocaleString()} (${p}%)`:`${u.toLocaleString()} (TOTAL)`,r]}}),e.keyValues.sort((o,r)=>o.isTotal?-1:r.isTotal?1:0).map(o=>s.jsx(Ge,{type:"monotone",dataKey:o.key,name:o.name,stroke:o.color,fill:o.color,strokeWidth:2,fillOpacity:.6},o.key))]})})})}function Dn(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(P,{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})]})})}const Ln={margin:{top:5,right:30,left:20,bottom:5}},Gn={tickLine:!1,fontSize:12,tickMargin:12},Mn={textAnchor:"end",tickLine:!1};function Rn({data:e,series:n,xAxis:t,yAxis:o,tooltip:r,bar:a,referenceLines:i,sx:c}){const l=Y(),u=p=>!p.isFront,d=p=>!!p.isFront;return s.jsx(z,{sx:{width:"100%",height:"100%",...c},children:s.jsx(ee,{children:s.jsxs(Me,{data:e,...Ln,children:[s.jsx(ne,{strokeDasharray:"3 3",vertical:!1}),s.jsx(te,{...Gn,...t}),s.jsx(oe,{...Mn,...o}),s.jsx(re,{cursor:{stroke:l.palette.neutral.main,strokeWidth:1},...r}),i?.filter(u).map((p,h)=>s.jsx(fe,{...p},h)),n.map(p=>s.jsx(Re,{name:p.key,dataKey:p.dataKey,fill:p.color,stackId:"stack",isAnimationActive:!1,...a},p.key)),i?.filter(d).map((p,h)=>s.jsx(fe,{...p},h))]})})})}export{Dn as BigNumber,En as SeriesChart,we as SeriesChartLegend,Cn as SeriesPercentageChart,Rn as SimpleBarChart};
@@ -0,0 +1,17 @@
1
+ export declare const chartDefaultProps: {
2
+ margin: {
3
+ top: number;
4
+ right: number;
5
+ left: number;
6
+ bottom: number;
7
+ };
8
+ };
9
+ export declare const xAxisDefaultProps: {
10
+ tickLine: boolean;
11
+ fontSize: number;
12
+ tickMargin: number;
13
+ };
14
+ export declare const yAxisDefaultProps: {
15
+ textAnchor: string;
16
+ tickLine: boolean;
17
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verifiedinc-public/shared-ui-elements",
3
- "version": "3.8.1",
3
+ "version": "3.9.0",
4
4
  "description": "A set of UI components, utilities that is shareable with the core apps.",
5
5
  "private": false,
6
6
  "keywords": [],