@verifiedinc-public/shared-ui-elements 3.9.0 → 3.10.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.
@@ -0,0 +1,37 @@
1
+ import { ReactElement } from 'react';
2
+ import { SxProps } from '@mui/material';
3
+ /**
4
+ * Props for the ErrorCodesChart component
5
+ */
6
+ interface ErrorCodesChartProps {
7
+ /**
8
+ * Data object containing error codes and their occurrence counts.
9
+ * The data should follow the structure: Record<string, number>
10
+ * Example: { OCE000: 150, OCE001: 75 }
11
+ */
12
+ data: Record<string, number> | undefined;
13
+ /**
14
+ * MUI System props object for custom styling of the chart container
15
+ */
16
+ sx?: SxProps;
17
+ }
18
+ /**
19
+ * A bar chart component that visualizes error code occurrences.
20
+ *
21
+ * The chart displays error codes on the x-axis and their counts on the y-axis.
22
+ * It includes a reference line at y=100 to indicate an unhealthy threshold.
23
+ * Each error code is represented by a bar with a light error color from the theme.
24
+ *
25
+ * @example
26
+ * ```tsx
27
+ * <ErrorCodesChart
28
+ * data={{
29
+ * OCE000: 150,
30
+ * OCE001: 75
31
+ * }}
32
+ * sx={{ width: 800, height: 400 }}
33
+ * />
34
+ * ```
35
+ */
36
+ export declare function ErrorCodesChart({ data, sx, }: ErrorCodesChartProps): ReactElement;
37
+ export {};
@@ -3,3 +3,4 @@ export * from './SeriesChartLegend';
3
3
  export * from './SeriesPercentageChart';
4
4
  export * from './BigNumber';
5
5
  export * from './SimpleBarChart';
6
+ export * from './ErrorCodesChart';
@@ -1 +1 @@
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};
1
+ "use strict";import{j as s}from"../../shared/jsx-runtime-jmtevAuS.mjs";import*as D from"react";import{useCallback as X,useMemo as Y,createElement as Ee}from"react";import{Box as z,Stack as P,Typography as R,useTheme as q,Paper as Ae}from"@mui/material";import{ResponsiveContainer as ee,LineChart as Ce,CartesianGrid as oe,XAxis as te,YAxis as re,Label as fe,Tooltip as ne,Legend as De,Line as Le,AreaChart as Fe,Area as Ge,ComposedChart as Re,ReferenceLine as he,Bar as Me}from"recharts";import{b as ye,c as xe}from"../../shared/date-Cq0LS2Mr.mjs";import B,{Decimal as ae}from"decimal.js";import{AnimatePresence as We}from"framer-motion";import{u as Ie}from"../../shared/useCopyToClipboard-BALOSYVW.mjs";import"qrcode";import{u as ie}from"../../shared/usePrevious-DyvR1iCQ.mjs";import{a as Ke,C as be}from"../../shared/motions-CpxgbzKX.mjs";import{i as Ve,_ as U,s as ze,a as f,c as ge,d as Pe,e as qe,f as Be,h as Ue,j as Ze,k as He,l as Je,m as Qe,n as Xe,o as Ye,p as eo,u as oo}from"../../shared/index-CDq4CkLc.mjs";import{u as to}from"../../shared/useCounter-BV32zXDQ.mjs";const ro=["ownerState"],no=["variants"],ao=["name","slot","skipVariantsResolver","skipSx","overridesResolver"];function io(e){return Object.keys(e).length===0}function so(e){return typeof e=="string"&&e.charCodeAt(0)>96}function se(e){return e!=="ownerState"&&e!=="theme"&&e!=="sx"&&e!=="as"}const lo=ge(),co=e=>e&&e.charAt(0).toLowerCase()+e.slice(1);function Z({defaultTheme:e,theme:o,themeId:t}){return io(o)?e:o[t]||o}function uo(e){return e?(o,t)=>t[e]:null}function H(e,o){let{ownerState:t}=o,r=U(o,ro);const a=typeof e=="function"?e(f({ownerState:t},r)):e;if(Array.isArray(a))return a.flatMap(n=>H(n,f({ownerState:t},r)));if(a&&typeof a=="object"&&Array.isArray(a.variants)){const{variants:n=[]}=a;let i=U(a,no);return n.forEach(c=>{let l=!0;typeof c.props=="function"?l=c.props(f({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(f({ownerState:t},r,t)):c.style))}),i}return a}function po(e={}){const{themeId:o,defaultTheme:t=lo,rootShouldForwardProp:r=se,slotShouldForwardProp:a=se}=e,n=i=>Pe(f({},i,{theme:Z(f({},i,{defaultTheme:t,themeId:o}))}));return n.__mui_systemSx=!0,(i,c={})=>{Ve(i,m=>m.filter(w=>!(w!=null&&w.__mui_systemSx)));const{name:l,slot:u,skipVariantsResolver:p,skipSx:d,overridesResolver:h=uo(co(u))}=c,y=U(c,ao),v=p!==void 0?p:u&&u!=="Root"&&u!=="root"||!1,x=d||!1;let j,k=se;u==="Root"||u==="root"?k=r:u?k=a:so(i)&&(k=void 0);const N=ze(i,f({shouldForwardProp:k,label:j},y)),W=m=>typeof m=="function"&&m.__emotion_real!==m||qe(m)?w=>H(m,f({},w,{theme:Z({theme:w.theme,defaultTheme:t,themeId:o})})):m,E=(m,...w)=>{let F=W(m);const _=w?w.map(W):[];l&&h&&_.push(b=>{const g=Z(f({},b,{defaultTheme:t,themeId:o}));if(!g.components||!g.components[l]||!g.components[l].styleOverrides)return null;const S=g.components[l].styleOverrides,A={};return Object.entries(S).forEach(([J,V])=>{A[J]=H(V,f({},b,{theme:g}))}),h(b,A)}),l&&!v&&_.push(b=>{var g;const S=Z(f({},b,{defaultTheme:t,themeId:o})),A=S==null||(g=S.components)==null||(g=g[l])==null?void 0:g.variants;return H({variants:A},f({},b,{theme:S}))}),x||_.push(n);const I=_.length-w.length;if(Array.isArray(m)&&I>0){const b=new Array(I).fill("");F=[...m,...b],F.raw=[...m.raw,...b]}const K=N(F,..._);return i.muiName&&(K.muiName=i.muiName),K};return N.withConfig&&(E.withConfig=N.withConfig),E}}const mo=po(),fo=(e,o)=>e.filter(t=>o.includes(t)),L=(e,o,t)=>{const r=e.keys[0];Array.isArray(o)?o.forEach((a,n)=>{t((i,c)=>{n<=e.keys.length-1&&(n===0?Object.assign(i,c):i[e.up(e.keys[n])]=c)},a)}):o&&typeof o=="object"?(Object.keys(o).length>e.keys.length?e.keys:fo(e.keys,Object.keys(o))).forEach(a=>{if(e.keys.indexOf(a)!==-1){const n=o[a];n!==void 0&&t((i,c)=>{r===a?Object.assign(i,c):i[e.up(a)]=c},n)}}):(typeof o=="number"||typeof o=="string")&&t((a,n)=>{Object.assign(a,n)},o)};function $(e){return e?`Level${e}`:""}function M(e){return e.unstable_level>0&&e.container}function ve(e){return function(o){return`var(--Grid-${o}Spacing${$(e.unstable_level)})`}}function le(e){return function(o){return e.unstable_level===0?`var(--Grid-${o}Spacing)`:`var(--Grid-${o}Spacing${$(e.unstable_level-1)})`}}function ce(e){return e.unstable_level===0?"var(--Grid-columns)":`var(--Grid-columns${$(e.unstable_level-1)})`}const ho=({theme:e,ownerState:o})=>{const t=ve(o),r={};return L(e.breakpoints,o.gridSize,(a,n)=>{let i={};n===!0&&(i={flexBasis:0,flexGrow:1,maxWidth:"100%"}),n==="auto"&&(i={flexBasis:"auto",flexGrow:0,flexShrink:0,maxWidth:"none",width:"auto"}),typeof n=="number"&&(i={flexGrow:0,flexBasis:"auto",width:`calc(100% * ${n} / ${ce(o)}${M(o)?` + ${t("column")}`:""})`}),a(r,i)}),r},yo=({theme:e,ownerState:o})=>{const t={};return L(e.breakpoints,o.gridOffset,(r,a)=>{let n={};a==="auto"&&(n={marginLeft:"auto"}),typeof a=="number"&&(n={marginLeft:a===0?"0px":`calc(100% * ${a} / ${ce(o)})`}),r(t,n)}),t},xo=({theme:e,ownerState:o})=>{if(!o.container)return{};const t=M(o)?{[`--Grid-columns${$(o.unstable_level)}`]:ce(o)}:{"--Grid-columns":12};return L(e.breakpoints,o.columns,(r,a)=>{r(t,{[`--Grid-columns${$(o.unstable_level)}`]:a})}),t},bo=({theme:e,ownerState:o})=>{if(!o.container)return{};const t=le(o),r=M(o)?{[`--Grid-rowSpacing${$(o.unstable_level)}`]:t("row")}:{};return L(e.breakpoints,o.rowSpacing,(a,n)=>{var i;a(r,{[`--Grid-rowSpacing${$(o.unstable_level)}`]:typeof n=="string"?n:(i=e.spacing)==null?void 0:i.call(e,n)})}),r},go=({theme:e,ownerState:o})=>{if(!o.container)return{};const t=le(o),r=M(o)?{[`--Grid-columnSpacing${$(o.unstable_level)}`]:t("column")}:{};return L(e.breakpoints,o.columnSpacing,(a,n)=>{var i;a(r,{[`--Grid-columnSpacing${$(o.unstable_level)}`]:typeof n=="string"?n:(i=e.spacing)==null?void 0:i.call(e,n)})}),r},vo=({theme:e,ownerState:o})=>{if(!o.container)return{};const t={};return L(e.breakpoints,o.direction,(r,a)=>{r(t,{flexDirection:a})}),t},wo=({ownerState:e})=>{const o=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(${o("row")} / -2) calc(${o("column")} / -2)`},e.disableEqualOverflow&&{margin:`calc(${o("row")} * -1) 0px 0px calc(${o("column")} * -1)`}),(!e.container||M(e))&&f({padding:`calc(${t("row")} / 2) calc(${t("column")} / 2)`},(e.disableEqualOverflow||e.parentDisableEqualOverflow)&&{padding:`${t("row")} 0px 0px ${t("column")}`}))},Oo=e=>{const o=[];return Object.entries(e).forEach(([t,r])=>{r!==!1&&r!==void 0&&o.push(`grid-${t}-${String(r)}`)}),o},jo=(e,o="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-${o}-${String(e)}`];if(typeof e=="object"&&!Array.isArray(e)){const r=[];return Object.entries(e).forEach(([a,n])=>{t(n)&&r.push(`spacing-${a}-${String(n)}`)}),r}return[]},ko=e=>e===void 0?[]:typeof e=="object"?Object.entries(e).map(([o,t])=>`direction-${o}-${t}`):[`direction-xs-${String(e)}`],So=["className","children","columns","container","component","direction","wrap","spacing","rowSpacing","columnSpacing","disableEqualOverflow","unstable_level"],$o=ge(),No=mo("div",{name:"MuiGrid",slot:"Root",overridesResolver:(e,o)=>o.root});function _o(e){return Je({props:e,name:"MuiGrid",defaultTheme:$o})}function To(e={}){const{createStyledComponent:o=No,useThemeProps:t=_o,componentName:r="MuiGrid"}=e,a=D.createContext(void 0),n=(l,u)=>{const{container:p,direction:d,spacing:h,wrap:y,gridSize:v}=l,x={root:["root",p&&"container",y!=="wrap"&&`wrap-xs-${String(y)}`,...ko(d),...Oo(v),...p?jo(h,u.breakpoints.keys[0]):[]]};return Qe(x,j=>Xe(r,j),{})},i=o(xo,go,bo,ho,vo,wo,yo),c=D.forwardRef(function(l,u){var p,d,h,y,v,x,j,k;const N=Be(),W=t(l),E=Ue(W),m=D.useContext(a),{className:w,children:F,columns:_=12,container:I=!1,component:K="div",direction:b="row",wrap:g="wrap",spacing:S=0,rowSpacing:A=S,columnSpacing:J=S,disableEqualOverflow:V,unstable_level:T=0}=E,ke=U(E,So);let G=V;T&&V!==void 0&&(G=l.disableEqualOverflow);const ue={},de={},pe={};Object.entries(ke).forEach(([O,C])=>{N.breakpoints.values[O]!==void 0?ue[O]=C:N.breakpoints.values[O.replace("Offset","")]!==void 0?de[O.replace("Offset","")]=C:pe[O]=C});const Se=(p=l.columns)!=null?p:T?void 0:_,$e=(d=l.spacing)!=null?d:T?void 0:S,Ne=(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:J,me=f({},E,{level:T,columns:Se,container:I,direction:b,wrap:g,spacing:$e,rowSpacing:Ne,columnSpacing:_e,gridSize:ue,gridOffset:de,disableEqualOverflow:(j=(k=G)!=null?k:m)!=null?j:!1,parentDisableEqualOverflow:m}),Te=n(me,N);let Q=s.jsx(i,f({ref:u,as:K,ownerState:me,className:Ze(Te.root,w)},pe,{children:D.Children.map(F,O=>{if(D.isValidElement(O)&&He(O,["Grid"])){var C;return D.cloneElement(O,{unstable_level:(C=O.props.unstable_level)!=null?C:T+1})}return O})}));return G!==void 0&&G!==(m??!1)&&(Q=s.jsx(a.Provider,{value:G,children:Q})),Q});return c.muiName="Grid",c}const we=To({createStyledComponent:Ye("div",{name:"MuiGrid2",slot:"Root",overridesResolver:(e,o)=>o.root}),componentName:"MuiGrid2",useThemeProps:e=>eo({props:e,name:"MuiGrid2"})});function Eo({entry:e,payload:o}){const t=X(d=>{var h,y,v;return(v=(y=(h=d.payload)==null?void 0:h.data)==null?void 0:y.reduce)==null?void 0:v.call(y,(x,j)=>x+j.value,0)},[]),r=X(d=>{const h=new ae(t(d)||0),y=o?.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,o]),a=Y(()=>t(e),[e,t]),n=ie(a),i=Y(()=>Number(r(e)),[e,r]),c=ie(i),l=X(d=>Math.floor(d).toLocaleString(),[]),u=Ie({type:"text/plain"}),p=oo();return s.jsxs(Ke,{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(be,{from:n??0,to:a,map:l,children:"0"})}),s.jsxs(P,{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 Oe(e){const{payload:o}=e;return s.jsx(we,{container:!0,direction:"row",component:"ul",gap:2,sx:{mt:2,justifyContent:"flex-start",alignItem:"center",flexWrap:"wrap"},children:s.jsx(We,{children:o?.map(t=>s.jsx(we,{children:s.jsx(Eo,{entry:t,payload:o})},`item-${t.value}`))})})}function Ao(e){const o=q();return s.jsx(z,{sx:{width:"100%",height:"100%",...e.sx},children:s.jsx(ee,{children:s.jsxs(Ce,{width:500,height:300,margin:{top:5,right:60,left:20,bottom:5},children:[s.jsx(oe,{vertical:!1}),s.jsx(te,{dataKey:"date",type:"number",domain:["dataMin","dataMax"],tickFormatter:t=>ye(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(fe,{value:e.label,angle:-90,position:"insideLeft",style:{textAnchor:"middle"}})}),s.jsx(ne,{cursor:{stroke:o.palette.neutral.main,strokeWidth:1},formatter:t=>Number(t).toLocaleString(),labelFormatter:t=>xe(t,{timeZone:e.filter.timezone,hour12:!1})}),s.jsx(De,{content:s.jsx(Oe,{})}),e.data.map(t=>Ee(Le,{uuid:t.uuid,key:t.uuid,name:t.name,dataKey:"value",data:t.chartData,type:"monotone",stroke:t.color,strokeWidth:2}))]})})})}const Co=(e,o)=>{const t=new Map;return e.forEach(r=>{r.chartData.forEach(a=>{const n=new Date(a.date).getTime().toString();if(!t.has(n)){const i={date:n,total:0,diff:0,totalKey:"",originalTotal:0};o.forEach(({key:c})=>{i[c]=0,i[`${c}_absolute`]=0}),t.set(n,i)}o.forEach(({key:i})=>{const c=t.get(n),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(r=>{var a;const n=(a=o.find(l=>l.isTotal))==null?void 0:a.key,i=o.filter(l=>!l.isTotal).map(l=>l.key);if(!n||i.length===0)return r;const c=r[`${n}_absolute`];return r.originalTotal=c,r.total=c,r[n]=100,i.forEach(l=>{const u=r[`${l}_absolute`],p=c>0?new B(u.toString()).div(c).mul(100).toFixed(2,B.ROUND_DOWN):"0.00";r[l]=parseFloat(p)}),{...r,totalKey:n}}).sort((r,a)=>parseInt(r.date)-parseInt(a.date))};function Do(e){const o=q(),t=Y(()=>e.data?Co(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(Fe,{data:t,width:500,height:300,margin:{top:5,right:60,left:20,bottom:5},children:[s.jsx(oe,{strokeDasharray:"3 3"}),s.jsx(te,{dataKey:"date",type:"number",domain:["dataMin","dataMax"],tickFormatter:r=>ye(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(ne,{cursor:{stroke:o.palette.neutral.main,strokeWidth:1},labelFormatter:r=>xe(r,{timeZone:e.filter.timezone,hour12:!1}),formatter:(r,a,n)=>{const i=n.payload.totalKey,c=n.dataKey,l=c===i,u=n.payload[`${c}_absolute`],p=n.payload.originalTotal,d=l?null:p===0?"0.00":new B(u.toString()).div(p).mul(100).toFixed(2,B.ROUND_DOWN);return[d?`${u.toLocaleString()} (${d}%)`:`${u.toLocaleString()} (TOTAL)`,a]}}),e.keyValues.sort((r,a)=>r.isTotal?-1:a.isTotal?1:0).map(r=>s.jsx(Ge,{type:"monotone",dataKey:r.key,name:r.name,stroke:r.color,fill:r.color,strokeWidth:2,fillOpacity:.6},r.key))]})})})}function Lo(e){const o=ie(e.value),{ref:t}=to({from:o??0,to:e.value,duration:1,map:e.map});return s.jsx(Ae,{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 Fo={margin:{top:5,right:30,left:20,bottom:5}},Go={tickLine:!1,fontSize:12,tickMargin:12},Ro={textAnchor:"end",tickLine:!1};function je({data:e,series:o,xAxis:t,yAxis:r,tooltip:a,bar:n,referenceLines:i,sx:c}){const l=q(),u=d=>!d.isFront,p=d=>!!d.isFront;return s.jsx(z,{sx:{width:"100%",height:"100%",...c},children:s.jsx(ee,{children:s.jsxs(Re,{data:e,...Fo,children:[s.jsx(oe,{strokeDasharray:"3 3",vertical:!1}),s.jsx(te,{...Go,...t}),s.jsx(re,{...Ro,...r}),s.jsx(ne,{cursor:{stroke:l.palette.neutral.main,strokeWidth:1},...a}),i?.filter(u).map((d,h)=>s.jsx(he,{...d},h)),o.map(d=>s.jsx(Me,{name:d.key,dataKey:d.dataKey,fill:d.color,stackId:"stack",isAnimationActive:!1,...n},d.key)),i?.filter(p).map((d,h)=>s.jsx(he,{...d},h))]})})})}function Mo({data:e,sx:o}){const t=q(),r=Object.entries(e??{}).map(([n,i])=>({key:n,[n]:i})),a=r.map(({key:n})=>({key:n,dataKey:n,color:t.palette.error.light}));return s.jsx(je,{sx:o,data:r,series:a,xAxis:{tickLine:!1,dataKey:"key"},yAxis:{tickLine:!1,domain:[0,"dataMax + 100"]},tooltip:{labelFormatter:n=>"Total"},referenceLines:[{y:100,stroke:t.palette.error.dark,strokeDasharray:"3 3",label:s.jsx(fe,{value:"Unhealthy threshold",position:"insideBottomRight"}),isFront:!0}]})}export{Lo as BigNumber,Mo as ErrorCodesChart,Ao as SeriesChart,Oe as SeriesChartLegend,Do as SeriesPercentageChart,je as SimpleBarChart};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verifiedinc-public/shared-ui-elements",
3
- "version": "3.9.0",
3
+ "version": "3.10.0",
4
4
  "description": "A set of UI components, utilities that is shareable with the core apps.",
5
5
  "private": false,
6
6
  "keywords": [],