UNPKG

@useloops/design-system

Version:

The official React based Loops design system

2 lines (1 loc) 1.5 kB
"use strict";var e=require("react/jsx-runtime"),a=require("react"),r=require("./_partials/SliderGraphBar/SliderGraphBar.js"),i=require("./_partials/SliderGraphYAxis/SliderGraphYAxis.js"),s=require("./_partials/StyledComponents.js");module.exports=({rounding:l,tickInterval:t=10,data:n,loading:o,disabled:d,onChangeHandler:p,animateBars:h,slotProps:c,hideYAxis:u=!1,hideValues:g=!1,showGraphLines:x=!1,hideLabels:b=!1,hideCheckboxes:m=!1,disableTooltips:v=!1,maxHeight:k=465,responsive:j=!1})=>{const C=a.useMemo(()=>Math.ceil(n.reduce((e,{percentage:a})=>a>e?a:e,0)),[n]);return e.jsxs(s.SliderGraphWrapper,{...c?.root,maxHeight:k,responsive:j,children:[!u&&e.jsx(i,{graphMaxHeight:k,loading:o,yAxisMax:C,rounding:l,tickInterval:t,disabled:d,showGraphLines:x,hideLabel:b,hideCheckbox:m,responsive:j,slotProps:{root:c?.yAxis}}),e.jsx(s.SliderGraphBarWrapper,{...c?.barsWrapper,maxHeight:k,responsive:j,children:n.map((a,i)=>{const{percentage:s,label:l,value:n,checked:u,id:x,amount:G,relativePercentage:S,onChange:H}=a;return e.jsx(r,{graphMaxHeight:k,loading:o,label:l,value:n,percentage:s,maxDataValue:C,checked:u,tickInterval:t,disabled:d||o,animateBar:h,hideValue:g,responsive:j,onChange:p?(e,a)=>p(e,a):H?(e,a)=>H({amount:G,percentage:s,name:l,relativePercentage:S},a):void 0,hideLabel:b,hideCheckbox:m,toolTipContent:null==s?null:`${s}%`,disableTooltip:v,id:x,className:`slider-graph-bar-${i+1}`,slotProps:{barWrapper:{},checkbox:{},value:{},label:{},tooltip:{},bar:{}},...c?.bar},i)})})]})};