@bikdotai/bik-component-library 0.0.533-analytics-beta0.1 → 0.0.533-analytics-beta56

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 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),i=require("../shimmer/ShimmerComponent/ShimmerStyled.js"),n=require("../../utils/DateUtils.js"),r=require("../../constants/Theme.js"),s=require("../../assets/icons/arrow_down.svg.js"),l=require("../../assets/icons/arrow_up.svg.js"),a=require("../../assets/icons/info.svg.js"),o=require("../tag/Tag.js"),c=require("../tooltips/Tooltip.js"),d=require("../TypographyStyle.js"),g=require("./chart/utils/calcPercentage.js"),u=require("./CommonStyles.js");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var y=h(t);const m=i=>{let{percent:a,direction:o,timeline:c,customRange:u,trendRaw:h,prefixSymbol:y,trendIconStyle:m}=i;const p="negative"===o?s.default:l.default,j="negative"===o?r.COLORS.background.negative.vibrant:"positive"===o?r.COLORS.background.positive.vibrant:r.COLORS.content.placeholder,x=t.useRef("today"===c?"vs yesterday":"yesterday"===c?"vs 1 day before":"7 days"===c?"vs last 7 days":"30 days"===c?"vs last 30 days":"custom"===c&&u?n.default.getAnalyticsCustomDateTimelineText(u):""),b=t.useRef((()=>{const e=((null!=h?h:0)>0?"+":"")+(null!=y?y:"");return void 0===h?"--":`${null!=e?e:""}${g.truncateValueTo10K(h)}`})());return e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",flexDirection:"row",flexWrap:"wrap"}},{children:["number"==typeof a&&e.jsx(p,{color:j,height:16,width:16,style:Object.assign({marginRight:2},null!=m?m:{})}),"number"==typeof a&&o&&e.jsxs(d.Caption,Object.assign({style:{color:j}},{children:["neutral"===o?0:a<1e3?a:">999","%"]})),!!h&&e.jsx(d.Caption,Object.assign({style:{marginLeft:4,color:r.COLORS.content.placeholder}},{children:`(${b.current})`})),c&&e.jsx(d.Caption,Object.assign({style:{marginLeft:4,color:r.COLORS.content.placeholder}},{children:x.current}))]}))};exports.AnalyticsTrend=t=>{let{title:n,value:s,trendPercent:l,type:h="horizontal",timeline:p,customRange:j,tooltip:x,card:b=!0,rightSeparator:f=!1,size:O="big",share:v=!1,formatVal:S,prefixSymbol:C,trailingIcon:T,onTrailIconClick:R,iconTooltipBody:w,funnelPercent:L,isLoading:$,trendRaw:q,suffixText:I,trendStyle:D,trendContainerStyle:M,trendIconStyle:k,containerStyle:z,prevTrendDiff:P}=t;const _="big"===O?d.TitleLarge:d.TitleMedium,A=void 0!==l?l<0?"negative":0===l?"neutral":"positive":void 0,F=void 0!==l?v?Math.round(l):Math.abs(Math.round(l)):void 0;return e.jsx(u.AnalyticsTrendContainer,Object.assign({card:b,style:Object.assign({},z)},{children:e.jsxs("div",Object.assign({style:Object.assign({display:"flex",flexDirection:"row",gap:4,borderRightWidth:f?1:0,borderRightColor:r.COLORS.stroke.primary,borderRightStyle:"solid",paddingLeft:b?0:24,paddingRight:b?0:24,height:"100%",justifyContent:"space-between",alignItems:"center"},null!=M?M:{})},{children:[e.jsxs("div",Object.assign({style:Object.assign({display:"flex",flexDirection:"column",gap:4,height:"100%"},null!=D?D:{})},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:4,alignItems:"center"}},{children:[e.jsx(d.BodyCaption,Object.assign({style:{color:r.COLORS.content.secondary}},{children:n})),x&&e.jsx(c.Tooltip,Object.assign({body:x,placement:"right",width:300},{children:e.jsx("div",Object.assign({style:{display:"flex",alignItems:"center",cursor:"pointer"}},{children:e.jsx(a.default,{color:r.COLORS.content.inactive,height:16,width:16})}))}))]})),e.jsxs("div",Object.assign({style:Object.assign({display:"flex",flexDirection:"row",gap:12,alignItems:"center"},v?{justifyContent:"space-between"}:{})},{children:[$&&e.jsx(i.ShimmerComponentStyled,{width:108,height:26}),!$&&e.jsx(_,Object.assign({style:{color:r.COLORS.content.primary}},{children:void 0===s?"--":"number"==typeof s&&S?s>9999?`${null!=C?C:""}${g.truncateValueTo10K(s)} ${null!=I?I:""}`:`${null!=C?C:""}${new Intl.NumberFormat("en-IN",{maximumFractionDigits:2}).format(s)} ${null!=I?I:""}`:`${null!=C?C:""}${s} ${null!=I?I:""}`})),"horizontal"===h&&!$&&!v&&e.jsx(m,{timeline:p,customRange:j,percent:F,direction:A,trendRaw:q,prefixSymbol:C,trendIconStyle:k}),$&&!v&&"horizontal"===h&&e.jsx(i.ShimmerComponentStyled,{height:20,width:141,marginTop:6}),"vertical"===h&&!$&&void 0!==L&&e.jsx(o.Tag,{tagText:`${L} %`,theme:"light",type:"neutral"}),v&&!$&&void 0!==F&&e.jsx(o.Tag,{tagText:`${F} %`,theme:"light",type:"neutral"}),v||$||!P||0==P?e.jsx(e.Fragment,{}):e.jsx(o.Tag,{tagText:`${Math.abs(Math.round(P))} %`,theme:"light",type:"neutral"})]})),"vertical"===h&&!$&&!v&&e.jsx("div",Object.assign({style:{marginTop:10}},{children:e.jsx(m,{timeline:p,customRange:j,percent:F,direction:A,trendRaw:q,prefixSymbol:C,trendIconStyle:k})})),$&&"vertical"===h&&e.jsx(i.ShimmerComponentStyled,{height:20,width:141,marginTop:6})]})),w&&!$&&e.jsx(c.Tooltip,Object.assign({body:w,placement:"right"},{children:T&&e.jsx("div",Object.assign({className:"icon--holder",onClick:R},{children:y.default.createElement(T,{height:20,width:20,color:r.COLORS.content.secondary})}))}))]}))}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),i=require("../shimmer/ShimmerComponent/ShimmerStyled.js"),n=require("../../utils/DateUtils.js"),r=require("../../constants/Theme.js"),s=require("../../assets/icons/arrow_down.svg.js"),l=require("../../assets/icons/arrow_up.svg.js"),a=require("../../assets/icons/info.svg.js"),o=require("../tag/Tag.js"),c=require("../tooltips/Tooltip.js"),d=require("../TypographyStyle.js"),g=require("./chart/utils/calcPercentage.js"),u=require("./CommonStyles.js");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var y=h(t);const m=i=>{let{percent:a,direction:o,timeline:c,customRange:u,trendRaw:h,prefixSymbol:y,trendIconStyle:m}=i;const p="negative"===o?s.default:l.default,j="negative"===o?r.COLORS.background.negative.vibrant:"positive"===o?r.COLORS.background.positive.vibrant:r.COLORS.content.placeholder,x=t.useRef("today"===c?"vs yesterday":"yesterday"===c?"vs 1 day before":"7 days"===c?"vs last 7 days":"30 days"===c?"vs last 30 days":"custom"===c&&u?n.default.getAnalyticsCustomDateTimelineText(u):""),b=t.useRef((()=>{const e=((null!=h?h:0)>0?"+":"")+(null!=y?y:"");return void 0===h?"--":`${null!=e?e:""}${g.truncateValueTo10K(h)}`})());return e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",flexDirection:"row",flexWrap:"wrap"}},{children:["number"==typeof a&&e.jsx(p,{color:j,height:16,width:16,style:Object.assign({marginRight:2},null!=m?m:{})}),"number"==typeof a&&o&&e.jsxs(d.Caption,Object.assign({style:{color:j}},{children:["neutral"===o?0:a<1e3?a:">999","%"]})),!!h&&e.jsx(d.Caption,Object.assign({style:{marginLeft:4,color:r.COLORS.content.placeholder}},{children:`(${b.current})`})),c&&e.jsx(d.Caption,Object.assign({style:{marginLeft:4,color:r.COLORS.content.placeholder}},{children:x.current}))]}))};exports.AnalyticsTrend=t=>{let{title:n,value:s,trendPercent:l,type:h="horizontal",timeline:p,customRange:j,tooltip:x,card:b=!0,rightSeparator:f=!1,size:O="big",share:v=!1,formatVal:S,prefixSymbol:C,trailingIcon:T,onTrailIconClick:R,iconTooltipBody:w,funnelPercent:$,isLoading:L,trendRaw:q,suffixText:I,trendStyle:D,trendContainerStyle:M,trendIconStyle:k,containerStyle:z,prevTrendDiff:F}=t;const P="big"===O?d.TitleLarge:d.TitleMedium,_=void 0!==l?l<0?"negative":0===l?"neutral":"positive":void 0,A=void 0!==l?v?Math.round(l):Math.abs(Math.round(l)):void 0;return e.jsx(u.AnalyticsTrendContainer,Object.assign({card:b,style:Object.assign({},z)},{children:e.jsxs("div",Object.assign({style:Object.assign({display:"flex",flexDirection:"row",gap:4,borderRightWidth:f?1:0,borderRightColor:r.COLORS.stroke.primary,borderRightStyle:"solid",paddingLeft:b?0:24,paddingRight:b?0:24,height:"100%",justifyContent:"space-between",alignItems:"center"},null!=M?M:{})},{children:[e.jsxs("div",Object.assign({style:Object.assign({display:"flex",flexDirection:"column",gap:4,height:"100%"},null!=D?D:{})},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:4,alignItems:"center"}},{children:[e.jsx(d.BodyCaption,Object.assign({style:{color:r.COLORS.content.secondary}},{children:n})),x&&e.jsx(c.Tooltip,Object.assign({body:x,placement:"right",width:300},{children:e.jsx("div",Object.assign({style:{display:"flex",alignItems:"center",cursor:"pointer"}},{children:e.jsx(a.default,{color:r.COLORS.content.inactive,height:16,width:16})}))}))]})),e.jsxs("div",Object.assign({style:Object.assign({display:"flex",flexDirection:"row",gap:12,alignItems:"center"},v?{justifyContent:"space-between"}:{})},{children:[L&&e.jsx(i.ShimmerComponentStyled,{width:108,height:26}),!L&&e.jsx(P,Object.assign({style:{color:r.COLORS.content.primary}},{children:void 0===s?"--":"number"==typeof s&&S?s>9999?`${null!=C?C:""}${g.truncateValueTo10K(s)} ${null!=I?I:""}`:`${null!=C?C:""}${new Intl.NumberFormat("en-IN",{maximumFractionDigits:2}).format(s)} ${null!=I?I:""}`:`${null!=C?C:""}${s} ${null!=I?I:""}`})),"horizontal"===h&&!L&&!v&&e.jsx(m,{timeline:p,customRange:j,percent:A,direction:_,trendRaw:q,prefixSymbol:C,trendIconStyle:k}),L&&!v&&"horizontal"===h&&e.jsx(i.ShimmerComponentStyled,{height:20,width:141,marginTop:6}),"vertical"===h&&!L&&void 0!==$&&e.jsx(o.Tag,{tagText:`${$} %`,theme:"light",type:"neutral"}),v&&!L&&void 0!==A&&e.jsx(o.Tag,{tagText:`${A} %`,theme:"light",type:"neutral"}),v||L||!F||0==F?e.jsx(e.Fragment,{}):e.jsx(o.Tag,{tagText:(e=>{const t=Math.abs(e);return t%1!=0?`${t.toFixed(1)} %`:`${t} %`})(F),theme:"light",type:"neutral"})]})),"vertical"===h&&!L&&!v&&e.jsx("div",Object.assign({style:{marginTop:10}},{children:e.jsx(m,{timeline:p,customRange:j,percent:A,direction:_,trendRaw:q,prefixSymbol:C,trendIconStyle:k})})),L&&"vertical"===h&&e.jsx(i.ShimmerComponentStyled,{height:20,width:141,marginTop:6})]})),w&&!L&&e.jsx(c.Tooltip,Object.assign({body:w,placement:"right"},{children:T&&e.jsx("div",Object.assign({className:"icon--holder",onClick:R},{children:y.default.createElement(T,{height:20,width:20,color:r.COLORS.content.secondary})}))}))]}))}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("chart.js"),l=require("react"),r=require("react-chartjs-2"),n=require("../../../TypographyStyle.js"),i=require("../../../../constants/Theme.js"),o=require("../utils/calcPercentage.js"),a=require("./LineChart.styled.js");t.Chart.register(t.CategoryScale,t.LinearScale,t.PointElement,t.BarElement,t.LineElement,t.ArcElement,t.Filler,t.Title,t.Tooltip,t.Legend);exports.LineChart=t=>{let{scaleText:s,labels:d,canvasHeight:c,datas:u,maintainAspectRatio:g=!1,stepSize:p,min:y,max:b,isZeroState:C,tension:v,isNewStyles:O,prefixCurrencyInYAxis:h,pointRadius:x,useKFormat:j,lineThickness:m,ticksLabelCallback:L,labelCallback:S,afterBodyCallBack:f,titleTooltipCallback:k}=t;var R,q,B;const[w,T]=l.useState(null),E=l.useRef();l.useEffect((()=>{var e,t,l,r;if(null===(r=null===(l=null===(t=null===(e=E.current)||void 0===e?void 0:e.scales)||void 0===t?void 0:t.y)||void 0===l?void 0:l.ticks)||void 0===r?void 0:r.length){const e=38*E.current.scales.y.ticks.length;T(e)}}),[E]);const F=u.map((e=>({text:e.legend,color:e.lineColor?e.lineColor:e.dotted?i.COLORS.content.placeholder:i.COLORS.background.brand,square:e.squareLegends}))),z={labels:d,datasets:u.map(((e,t)=>{var l,r;return Object.assign(Object.assign({tension:null!=v?v:.4,fill:e.gradient?"start":0},((e,t)=>{const l={borderColor:e||(t?i.COLORS.content.placeholder:i.COLORS.background.brand)};return O?Object.assign({pointStyle:"circle",pointRadius:x||(d.length>10?2.5:4),pointBorderColor:"transparent",pointBackgroundColor:e||(t?i.COLORS.content.placeholder:i.COLORS.background.brand)},l):Object.assign({pointRadius:null!=x?x:1},l)})(e.lineColor,e.dotted)),{borderDash:e.dotted?[8,3]:void 0,data:e.data,borderWidth:null!==(l=e.lineWidth)&&void 0!==l?l:2,backgroundColor:e.gradient?e=>{const t=e.chart.ctx.createLinearGradient(0,0,0,w?w-75:150);return t.addColorStop(0,"#F1EEFB"),t.addColorStop(1,"rgba(127, 86, 217, 0)"),t}:null!==(r=e.backgroundColor)&&void 0!==r?r:"transparent",legend:e.legend})}))},$={maintainAspectRatio:g,responsive:!0,plugins:{legend:{display:!1},title:{display:!1},tooltip:{displayColors:null!=O&&O,titleFont:()=>({weight:"600",size:14,family:"inter"}),titleColor:()=>i.COLORS.content.primaryInverse,backgroundColor:i.COLORS.content.primary,callbacks:{labelTextColor:()=>i.COLORS.content.primaryInverse,title:k,label:S,afterBody:f},bodyFont:()=>({weight:"400",size:14,family:"inter"})}},scales:{y:{beginAtZero:!0,min:C?0:y,max:C?10:b,ticks:{color:i.COLORS.content.secondary,callback:e=>{var t,l;return j?`${null!==(t=null==s?void 0:s.yPrefix)&&void 0!==t?t:""}${o.truncateValueToK(e)}${null!=h?h:""}`:`${null!==(l=null==s?void 0:s.yPrefix)&&void 0!==l?l:""}${e}${null!=h?h:""}`},font:{family:"inter",size:12,weight:"400"},stepSize:C?1:p,padding:O?24:0},title:{display:!!(null==s?void 0:s.y),text:null==s?void 0:s.y},grid:{color:i.COLORS.background.base,drawBorder:null===(R=null==s?void 0:s.yDrawBorder)||void 0===R||R}},x:{ticks:{callback:L,color:i.COLORS.content.secondary,font:{family:"inter",size:12,weight:"400"}},title:{display:!!(null==s?void 0:s.x),text:null==s?void 0:s.x},grid:{display:!1,drawBorder:null!==(q=null==s?void 0:s.xDrawBorder)&&void 0!==q&&q}}}};return e.jsxs("div",Object.assign({style:Object.assign(Object.assign({},g?{}:{height:null!==(B=null!=c?c:w)&&void 0!==B?B:204}),{display:"flex",flexDirection:"column",gap:2,width:"100%"})},{children:[e.jsx(a.LegendWrapper,{children:F.map(((t,l)=>{let{text:r,color:i,square:o}=t;return r?e.jsxs(a.LegendContainer,{children:[e.jsx(a.LegendColor,{color:i,square:o,newStyle:O}),e.jsx(n.BodyTiny,Object.assign({color:"#667085"},{children:r}))]},l):e.jsx(e.Fragment,{})}))}),e.jsx("div",Object.assign({style:{flex:1}},{children:e.jsx(r.Line,{ref:E,options:$,data:z})}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("chart.js"),l=require("react"),r=require("react-chartjs-2"),n=require("../../../TypographyStyle.js"),i=require("../../../../constants/Theme.js"),o=require("../utils/calcPercentage.js"),a=require("./LineChart.styled.js");t.Chart.register(t.CategoryScale,t.LinearScale,t.PointElement,t.BarElement,t.LineElement,t.ArcElement,t.Filler,t.Title,t.Tooltip,t.Legend);exports.LineChart=t=>{let{scaleText:s,labels:d,canvasHeight:c,datas:u,maintainAspectRatio:g=!1,stepSize:p,min:y,max:b,isZeroState:C,tension:v,isNewStyles:O,prefixCurrencyInYAxis:h,pointRadius:x,useKFormat:j,lineThickness:m,ticksLabelCallback:L,labelCallback:S,afterBodyCallBack:f,titleTooltipCallback:k}=t;var R,q,B;const[w,T]=l.useState(null),E=l.useRef();l.useEffect((()=>{var e,t,l,r;if(null===(r=null===(l=null===(t=null===(e=E.current)||void 0===e?void 0:e.scales)||void 0===t?void 0:t.y)||void 0===l?void 0:l.ticks)||void 0===r?void 0:r.length){const e=38*E.current.scales.y.ticks.length;T(e)}}),[E]);const F=u.map((e=>({text:e.legend,color:e.lineColor?e.lineColor:e.dotted?i.COLORS.content.placeholder:i.COLORS.background.brand,square:e.squareLegends}))),z={labels:d,datasets:u.map(((e,t)=>{var l,r;return Object.assign(Object.assign({tension:null!=v?v:.4,fill:e.gradient?"start":0},((e,t)=>{const l={borderColor:e||(t?i.COLORS.content.placeholder:i.COLORS.background.brand)};return O?Object.assign({pointStyle:"circle",pointRadius:x||(d&&d.length>10?2.5:4),pointBorderColor:"transparent",pointBackgroundColor:e||(t?i.COLORS.content.placeholder:i.COLORS.background.brand)},l):Object.assign({pointRadius:null!=x?x:1},l)})(e.lineColor,e.dotted)),{borderDash:e.dotted?[8,3]:void 0,data:e.data,borderWidth:null!==(l=e.lineWidth)&&void 0!==l?l:2,backgroundColor:e.gradient?e=>{const t=e.chart.ctx.createLinearGradient(0,0,0,w?w-75:150);return t.addColorStop(0,"#F1EEFB"),t.addColorStop(1,"rgba(127, 86, 217, 0)"),t}:null!==(r=e.backgroundColor)&&void 0!==r?r:"transparent",legend:e.legend})}))},$={maintainAspectRatio:g,responsive:!0,plugins:{legend:{display:!1},title:{display:!1},tooltip:{displayColors:null!=O&&O,titleFont:()=>({weight:"600",size:14,family:"inter"}),titleColor:()=>i.COLORS.content.primaryInverse,backgroundColor:i.COLORS.content.primary,callbacks:{labelTextColor:()=>i.COLORS.content.primaryInverse,title:k,label:S,afterBody:f},bodyFont:()=>({weight:"400",size:14,family:"inter"})}},scales:{y:{beginAtZero:!0,min:C?0:y,max:C?10:b,ticks:{color:i.COLORS.content.secondary,callback:e=>{var t,l;return j?`${null!==(t=null==s?void 0:s.yPrefix)&&void 0!==t?t:""}${o.truncateValueToK(e)}${null!=h?h:""}`:`${null!==(l=null==s?void 0:s.yPrefix)&&void 0!==l?l:""}${e}${null!=h?h:""}`},font:{family:"inter",size:12,weight:"400"},stepSize:C?1:p,padding:O?24:0},title:{display:!!(null==s?void 0:s.y),text:null==s?void 0:s.y},grid:{color:i.COLORS.background.base,drawBorder:null===(R=null==s?void 0:s.yDrawBorder)||void 0===R||R}},x:{ticks:{callback:L,color:i.COLORS.content.secondary,font:{family:"inter",size:12,weight:"400"}},title:{display:!!(null==s?void 0:s.x),text:null==s?void 0:s.x},grid:{display:!1,drawBorder:null!==(q=null==s?void 0:s.xDrawBorder)&&void 0!==q&&q}}}};return e.jsxs("div",Object.assign({style:Object.assign(Object.assign({},g?{}:{height:null!==(B=null!=c?c:w)&&void 0!==B?B:204}),{display:"flex",flexDirection:"column",gap:2,width:"100%"})},{children:[e.jsx(a.LegendWrapper,{children:F.map(((t,l)=>{let{text:r,color:i,square:o}=t;return r?e.jsxs(a.LegendContainer,{children:[e.jsx(a.LegendColor,{color:i,square:o,newStyle:O}),e.jsx(n.BodyTiny,Object.assign({color:"#667085"},{children:r}))]},l):e.jsx(e.Fragment,{})}))}),e.jsx("div",Object.assign({style:{flex:1}},{children:e.jsx(r.Line,{ref:E,options:$,data:z})}))]}))};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as t,Fragment as i}from"react/jsx-runtime";import n,{useRef as r}from"react";import{ShimmerComponentStyled as o}from"../shimmer/ShimmerComponent/ShimmerStyled.js";import l from"../../utils/DateUtils.js";import{COLORS as s}from"../../constants/Theme.js";import a from"../../assets/icons/arrow_down.svg.js";import c from"../../assets/icons/arrow_up.svg.js";import d from"../../assets/icons/info.svg.js";import{Tag as g}from"../tag/Tag.js";import{Tooltip as m}from"../tooltips/Tooltip.js";import{BodyCaption as h,Caption as p,TitleLarge as y,TitleMedium as u}from"../TypographyStyle.js";import{truncateValueTo10K as f}from"./chart/utils/calcPercentage.js";import{AnalyticsTrendContainer as b}from"./CommonStyles.js";const v=r=>{let{title:l,value:a,trendPercent:c,type:p="horizontal",timeline:v,customRange:x,tooltip:w,card:O=!0,rightSeparator:S=!1,size:T="big",share:$=!1,formatVal:I,prefixSymbol:R,trailingIcon:C,onTrailIconClick:D,iconTooltipBody:k,funnelPercent:M,isLoading:z,trendRaw:L,suffixText:N,trendStyle:P,trendContainerStyle:F,trendIconStyle:W,containerStyle:_,prevTrendDiff:A}=r;const B="big"===T?y:u,E=void 0!==c?c<0?"negative":0===c?"neutral":"positive":void 0,U=void 0!==c?$?Math.round(c):Math.abs(Math.round(c)):void 0;return e(b,Object.assign({card:O,style:Object.assign({},_)},{children:t("div",Object.assign({style:Object.assign({display:"flex",flexDirection:"row",gap:4,borderRightWidth:S?1:0,borderRightColor:s.stroke.primary,borderRightStyle:"solid",paddingLeft:O?0:24,paddingRight:O?0:24,height:"100%",justifyContent:"space-between",alignItems:"center"},null!=F?F:{})},{children:[t("div",Object.assign({style:Object.assign({display:"flex",flexDirection:"column",gap:4,height:"100%"},null!=P?P:{})},{children:[t("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:4,alignItems:"center"}},{children:[e(h,Object.assign({style:{color:s.content.secondary}},{children:l})),w&&e(m,Object.assign({body:w,placement:"right",width:300},{children:e("div",Object.assign({style:{display:"flex",alignItems:"center",cursor:"pointer"}},{children:e(d,{color:s.content.inactive,height:16,width:16})}))}))]})),t("div",Object.assign({style:Object.assign({display:"flex",flexDirection:"row",gap:12,alignItems:"center"},$?{justifyContent:"space-between"}:{})},{children:[z&&e(o,{width:108,height:26}),!z&&e(B,Object.assign({style:{color:s.content.primary}},{children:void 0===a?"--":"number"==typeof a&&I?a>9999?`${null!=R?R:""}${f(a)} ${null!=N?N:""}`:`${null!=R?R:""}${new Intl.NumberFormat("en-IN",{maximumFractionDigits:2}).format(a)} ${null!=N?N:""}`:`${null!=R?R:""}${a} ${null!=N?N:""}`})),"horizontal"===p&&!z&&!$&&e(j,{timeline:v,customRange:x,percent:U,direction:E,trendRaw:L,prefixSymbol:R,trendIconStyle:W}),z&&!$&&"horizontal"===p&&e(o,{height:20,width:141,marginTop:6}),"vertical"===p&&!z&&void 0!==M&&e(g,{tagText:`${M} %`,theme:"light",type:"neutral"}),$&&!z&&void 0!==U&&e(g,{tagText:`${U} %`,theme:"light",type:"neutral"}),$||z||!A||0==A?e(i,{}):e(g,{tagText:`${Math.abs(Math.round(A))} %`,theme:"light",type:"neutral"})]})),"vertical"===p&&!z&&!$&&e("div",Object.assign({style:{marginTop:10}},{children:e(j,{timeline:v,customRange:x,percent:U,direction:E,trendRaw:L,prefixSymbol:R,trendIconStyle:W})})),z&&"vertical"===p&&e(o,{height:20,width:141,marginTop:6})]})),k&&!z&&e(m,Object.assign({body:k,placement:"right"},{children:C&&e("div",Object.assign({className:"icon--holder",onClick:D},{children:n.createElement(C,{height:20,width:20,color:s.content.secondary})}))}))]}))}))},j=i=>{let{percent:n,direction:o,timeline:d,customRange:g,trendRaw:m,prefixSymbol:h,trendIconStyle:y}=i;const u="negative"===o?a:c,b="negative"===o?s.background.negative.vibrant:"positive"===o?s.background.positive.vibrant:s.content.placeholder,v=r("today"===d?"vs yesterday":"yesterday"===d?"vs 1 day before":"7 days"===d?"vs last 7 days":"30 days"===d?"vs last 30 days":"custom"===d&&g?l.getAnalyticsCustomDateTimelineText(g):""),j=r((()=>{const e=((null!=m?m:0)>0?"+":"")+(null!=h?h:"");return void 0===m?"--":`${null!=e?e:""}${f(m)}`})());return t("div",Object.assign({style:{display:"flex",alignItems:"center",flexDirection:"row",flexWrap:"wrap"}},{children:["number"==typeof n&&e(u,{color:b,height:16,width:16,style:Object.assign({marginRight:2},null!=y?y:{})}),"number"==typeof n&&o&&t(p,Object.assign({style:{color:b}},{children:["neutral"===o?0:n<1e3?n:">999","%"]})),!!m&&e(p,Object.assign({style:{marginLeft:4,color:s.content.placeholder}},{children:`(${j.current})`})),d&&e(p,Object.assign({style:{marginLeft:4,color:s.content.placeholder}},{children:v.current}))]}))};export{v as AnalyticsTrend};
1
+ import{jsx as e,jsxs as t,Fragment as i}from"react/jsx-runtime";import n,{useRef as r}from"react";import{ShimmerComponentStyled as o}from"../shimmer/ShimmerComponent/ShimmerStyled.js";import l from"../../utils/DateUtils.js";import{COLORS as s}from"../../constants/Theme.js";import a from"../../assets/icons/arrow_down.svg.js";import c from"../../assets/icons/arrow_up.svg.js";import d from"../../assets/icons/info.svg.js";import{Tag as g}from"../tag/Tag.js";import{Tooltip as m}from"../tooltips/Tooltip.js";import{BodyCaption as h,Caption as p,TitleLarge as y,TitleMedium as u}from"../TypographyStyle.js";import{truncateValueTo10K as f}from"./chart/utils/calcPercentage.js";import{AnalyticsTrendContainer as b}from"./CommonStyles.js";const v=r=>{let{title:l,value:a,trendPercent:c,type:p="horizontal",timeline:v,customRange:x,tooltip:w,card:O=!0,rightSeparator:S=!1,size:T="big",share:$=!1,formatVal:I,prefixSymbol:R,trailingIcon:C,onTrailIconClick:D,iconTooltipBody:k,funnelPercent:z,isLoading:L,trendRaw:M,suffixText:F,trendStyle:N,trendContainerStyle:P,trendIconStyle:W,containerStyle:_,prevTrendDiff:A}=r;const B="big"===T?y:u,E=void 0!==c?c<0?"negative":0===c?"neutral":"positive":void 0,U=void 0!==c?$?Math.round(c):Math.abs(Math.round(c)):void 0;return e(b,Object.assign({card:O,style:Object.assign({},_)},{children:t("div",Object.assign({style:Object.assign({display:"flex",flexDirection:"row",gap:4,borderRightWidth:S?1:0,borderRightColor:s.stroke.primary,borderRightStyle:"solid",paddingLeft:O?0:24,paddingRight:O?0:24,height:"100%",justifyContent:"space-between",alignItems:"center"},null!=P?P:{})},{children:[t("div",Object.assign({style:Object.assign({display:"flex",flexDirection:"column",gap:4,height:"100%"},null!=N?N:{})},{children:[t("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:4,alignItems:"center"}},{children:[e(h,Object.assign({style:{color:s.content.secondary}},{children:l})),w&&e(m,Object.assign({body:w,placement:"right",width:300},{children:e("div",Object.assign({style:{display:"flex",alignItems:"center",cursor:"pointer"}},{children:e(d,{color:s.content.inactive,height:16,width:16})}))}))]})),t("div",Object.assign({style:Object.assign({display:"flex",flexDirection:"row",gap:12,alignItems:"center"},$?{justifyContent:"space-between"}:{})},{children:[L&&e(o,{width:108,height:26}),!L&&e(B,Object.assign({style:{color:s.content.primary}},{children:void 0===a?"--":"number"==typeof a&&I?a>9999?`${null!=R?R:""}${f(a)} ${null!=F?F:""}`:`${null!=R?R:""}${new Intl.NumberFormat("en-IN",{maximumFractionDigits:2}).format(a)} ${null!=F?F:""}`:`${null!=R?R:""}${a} ${null!=F?F:""}`})),"horizontal"===p&&!L&&!$&&e(j,{timeline:v,customRange:x,percent:U,direction:E,trendRaw:M,prefixSymbol:R,trendIconStyle:W}),L&&!$&&"horizontal"===p&&e(o,{height:20,width:141,marginTop:6}),"vertical"===p&&!L&&void 0!==z&&e(g,{tagText:`${z} %`,theme:"light",type:"neutral"}),$&&!L&&void 0!==U&&e(g,{tagText:`${U} %`,theme:"light",type:"neutral"}),$||L||!A||0==A?e(i,{}):e(g,{tagText:(e=>{const t=Math.abs(e);return t%1!=0?`${t.toFixed(1)} %`:`${t} %`})(A),theme:"light",type:"neutral"})]})),"vertical"===p&&!L&&!$&&e("div",Object.assign({style:{marginTop:10}},{children:e(j,{timeline:v,customRange:x,percent:U,direction:E,trendRaw:M,prefixSymbol:R,trendIconStyle:W})})),L&&"vertical"===p&&e(o,{height:20,width:141,marginTop:6})]})),k&&!L&&e(m,Object.assign({body:k,placement:"right"},{children:C&&e("div",Object.assign({className:"icon--holder",onClick:D},{children:n.createElement(C,{height:20,width:20,color:s.content.secondary})}))}))]}))}))},j=i=>{let{percent:n,direction:o,timeline:d,customRange:g,trendRaw:m,prefixSymbol:h,trendIconStyle:y}=i;const u="negative"===o?a:c,b="negative"===o?s.background.negative.vibrant:"positive"===o?s.background.positive.vibrant:s.content.placeholder,v=r("today"===d?"vs yesterday":"yesterday"===d?"vs 1 day before":"7 days"===d?"vs last 7 days":"30 days"===d?"vs last 30 days":"custom"===d&&g?l.getAnalyticsCustomDateTimelineText(g):""),j=r((()=>{const e=((null!=m?m:0)>0?"+":"")+(null!=h?h:"");return void 0===m?"--":`${null!=e?e:""}${f(m)}`})());return t("div",Object.assign({style:{display:"flex",alignItems:"center",flexDirection:"row",flexWrap:"wrap"}},{children:["number"==typeof n&&e(u,{color:b,height:16,width:16,style:Object.assign({marginRight:2},null!=y?y:{})}),"number"==typeof n&&o&&t(p,Object.assign({style:{color:b}},{children:["neutral"===o?0:n<1e3?n:">999","%"]})),!!m&&e(p,Object.assign({style:{marginLeft:4,color:s.content.placeholder}},{children:`(${j.current})`})),d&&e(p,Object.assign({style:{marginLeft:4,color:s.content.placeholder}},{children:v.current}))]}))};export{v as AnalyticsTrend};
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t,Fragment as l}from"react/jsx-runtime";import{Chart as o,CategoryScale as r,LinearScale as n,PointElement as i,BarElement as a,LineElement as s,ArcElement as d,Filler as c,Title as u,Tooltip as p,Legend as g}from"chart.js";import{useState as b,useRef as y,useEffect as m}from"react";import{Line as v}from"react-chartjs-2";import{BodyTiny as h}from"../../../TypographyStyle.js";import{COLORS as f}from"../../../../constants/Theme.js";import{truncateValueToK as x}from"../utils/calcPercentage.js";import{LegendWrapper as k,LegendContainer as C,LegendColor as j}from"./LineChart.styled.js";o.register(r,n,i,a,s,d,c,u,p,g);const w=o=>{let{scaleText:r,labels:n,canvasHeight:i,datas:a,maintainAspectRatio:s=!1,stepSize:d,min:c,max:u,isZeroState:p,tension:g,isNewStyles:w,prefixCurrencyInYAxis:B,pointRadius:O,useKFormat:S,lineThickness:z,ticksLabelCallback:T,labelCallback:$,afterBodyCallBack:F,titleTooltipCallback:R}=o;var q,A,D;const[L,I]=b(null),P=y();m((()=>{var e,t,l,o;if(null===(o=null===(l=null===(t=null===(e=P.current)||void 0===e?void 0:e.scales)||void 0===t?void 0:t.y)||void 0===l?void 0:l.ticks)||void 0===o?void 0:o.length){const e=38*P.current.scales.y.ticks.length;I(e)}}),[P]);const E=a.map((e=>({text:e.legend,color:e.lineColor?e.lineColor:e.dotted?f.content.placeholder:f.background.brand,square:e.squareLegends}))),W={labels:n,datasets:a.map(((e,t)=>{var l,o;return Object.assign(Object.assign({tension:null!=g?g:.4,fill:e.gradient?"start":0},((e,t)=>{const l={borderColor:e||(t?f.content.placeholder:f.background.brand)};return w?Object.assign({pointStyle:"circle",pointRadius:O||(n.length>10?2.5:4),pointBorderColor:"transparent",pointBackgroundColor:e||(t?f.content.placeholder:f.background.brand)},l):Object.assign({pointRadius:null!=O?O:1},l)})(e.lineColor,e.dotted)),{borderDash:e.dotted?[8,3]:void 0,data:e.data,borderWidth:null!==(l=e.lineWidth)&&void 0!==l?l:2,backgroundColor:e.gradient?e=>{const t=e.chart.ctx.createLinearGradient(0,0,0,L?L-75:150);return t.addColorStop(0,"#F1EEFB"),t.addColorStop(1,"rgba(127, 86, 217, 0)"),t}:null!==(o=e.backgroundColor)&&void 0!==o?o:"transparent",legend:e.legend})}))},Z={maintainAspectRatio:s,responsive:!0,plugins:{legend:{display:!1},title:{display:!1},tooltip:{displayColors:null!=w&&w,titleFont:()=>({weight:"600",size:14,family:"inter"}),titleColor:()=>f.content.primaryInverse,backgroundColor:f.content.primary,callbacks:{labelTextColor:()=>f.content.primaryInverse,title:R,label:$,afterBody:F},bodyFont:()=>({weight:"400",size:14,family:"inter"})}},scales:{y:{beginAtZero:!0,min:p?0:c,max:p?10:u,ticks:{color:f.content.secondary,callback:e=>{var t,l;return S?`${null!==(t=null==r?void 0:r.yPrefix)&&void 0!==t?t:""}${x(e)}${null!=B?B:""}`:`${null!==(l=null==r?void 0:r.yPrefix)&&void 0!==l?l:""}${e}${null!=B?B:""}`},font:{family:"inter",size:12,weight:"400"},stepSize:p?1:d,padding:w?24:0},title:{display:!!(null==r?void 0:r.y),text:null==r?void 0:r.y},grid:{color:f.background.base,drawBorder:null===(q=null==r?void 0:r.yDrawBorder)||void 0===q||q}},x:{ticks:{callback:T,color:f.content.secondary,font:{family:"inter",size:12,weight:"400"}},title:{display:!!(null==r?void 0:r.x),text:null==r?void 0:r.x},grid:{display:!1,drawBorder:null!==(A=null==r?void 0:r.xDrawBorder)&&void 0!==A&&A}}}};return e("div",Object.assign({style:Object.assign(Object.assign({},s?{}:{height:null!==(D=null!=i?i:L)&&void 0!==D?D:204}),{display:"flex",flexDirection:"column",gap:2,width:"100%"})},{children:[t(k,{children:E.map(((o,r)=>{let{text:n,color:i,square:a}=o;return n?e(C,{children:[t(j,{color:i,square:a,newStyle:w}),t(h,Object.assign({color:"#667085"},{children:n}))]},r):t(l,{})}))}),t("div",Object.assign({style:{flex:1}},{children:t(v,{ref:P,options:Z,data:W})}))]}))};export{w as LineChart};
1
+ import{jsxs as e,jsx as t,Fragment as l}from"react/jsx-runtime";import{Chart as o,CategoryScale as r,LinearScale as n,PointElement as i,BarElement as a,LineElement as s,ArcElement as d,Filler as c,Title as u,Tooltip as p,Legend as g}from"chart.js";import{useState as b,useRef as y,useEffect as m}from"react";import{Line as v}from"react-chartjs-2";import{BodyTiny as h}from"../../../TypographyStyle.js";import{COLORS as f}from"../../../../constants/Theme.js";import{truncateValueToK as x}from"../utils/calcPercentage.js";import{LegendWrapper as k,LegendContainer as C,LegendColor as j}from"./LineChart.styled.js";o.register(r,n,i,a,s,d,c,u,p,g);const w=o=>{let{scaleText:r,labels:n,canvasHeight:i,datas:a,maintainAspectRatio:s=!1,stepSize:d,min:c,max:u,isZeroState:p,tension:g,isNewStyles:w,prefixCurrencyInYAxis:B,pointRadius:O,useKFormat:S,lineThickness:z,ticksLabelCallback:T,labelCallback:$,afterBodyCallBack:F,titleTooltipCallback:R}=o;var q,A,D;const[L,I]=b(null),P=y();m((()=>{var e,t,l,o;if(null===(o=null===(l=null===(t=null===(e=P.current)||void 0===e?void 0:e.scales)||void 0===t?void 0:t.y)||void 0===l?void 0:l.ticks)||void 0===o?void 0:o.length){const e=38*P.current.scales.y.ticks.length;I(e)}}),[P]);const E=a.map((e=>({text:e.legend,color:e.lineColor?e.lineColor:e.dotted?f.content.placeholder:f.background.brand,square:e.squareLegends}))),W={labels:n,datasets:a.map(((e,t)=>{var l,o;return Object.assign(Object.assign({tension:null!=g?g:.4,fill:e.gradient?"start":0},((e,t)=>{const l={borderColor:e||(t?f.content.placeholder:f.background.brand)};return w?Object.assign({pointStyle:"circle",pointRadius:O||(n&&n.length>10?2.5:4),pointBorderColor:"transparent",pointBackgroundColor:e||(t?f.content.placeholder:f.background.brand)},l):Object.assign({pointRadius:null!=O?O:1},l)})(e.lineColor,e.dotted)),{borderDash:e.dotted?[8,3]:void 0,data:e.data,borderWidth:null!==(l=e.lineWidth)&&void 0!==l?l:2,backgroundColor:e.gradient?e=>{const t=e.chart.ctx.createLinearGradient(0,0,0,L?L-75:150);return t.addColorStop(0,"#F1EEFB"),t.addColorStop(1,"rgba(127, 86, 217, 0)"),t}:null!==(o=e.backgroundColor)&&void 0!==o?o:"transparent",legend:e.legend})}))},Z={maintainAspectRatio:s,responsive:!0,plugins:{legend:{display:!1},title:{display:!1},tooltip:{displayColors:null!=w&&w,titleFont:()=>({weight:"600",size:14,family:"inter"}),titleColor:()=>f.content.primaryInverse,backgroundColor:f.content.primary,callbacks:{labelTextColor:()=>f.content.primaryInverse,title:R,label:$,afterBody:F},bodyFont:()=>({weight:"400",size:14,family:"inter"})}},scales:{y:{beginAtZero:!0,min:p?0:c,max:p?10:u,ticks:{color:f.content.secondary,callback:e=>{var t,l;return S?`${null!==(t=null==r?void 0:r.yPrefix)&&void 0!==t?t:""}${x(e)}${null!=B?B:""}`:`${null!==(l=null==r?void 0:r.yPrefix)&&void 0!==l?l:""}${e}${null!=B?B:""}`},font:{family:"inter",size:12,weight:"400"},stepSize:p?1:d,padding:w?24:0},title:{display:!!(null==r?void 0:r.y),text:null==r?void 0:r.y},grid:{color:f.background.base,drawBorder:null===(q=null==r?void 0:r.yDrawBorder)||void 0===q||q}},x:{ticks:{callback:T,color:f.content.secondary,font:{family:"inter",size:12,weight:"400"}},title:{display:!!(null==r?void 0:r.x),text:null==r?void 0:r.x},grid:{display:!1,drawBorder:null!==(A=null==r?void 0:r.xDrawBorder)&&void 0!==A&&A}}}};return e("div",Object.assign({style:Object.assign(Object.assign({},s?{}:{height:null!==(D=null!=i?i:L)&&void 0!==D?D:204}),{display:"flex",flexDirection:"column",gap:2,width:"100%"})},{children:[t(k,{children:E.map(((o,r)=>{let{text:n,color:i,square:a}=o;return n?e(C,{children:[t(j,{color:i,square:a,newStyle:w}),t(h,Object.assign({color:"#667085"},{children:n}))]},r):t(l,{})}))}),t("div",Object.assign({style:{flex:1}},{children:t(v,{ref:P,options:Z,data:W})}))]}))};export{w as LineChart};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.533-analytics-beta0.1",
3
+ "version": "0.0.533-analytics-beta56",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",