@bikdotai/bik-component-library 0.0.515-beta-dropdwon → 0.0.515-beta-dropdwon-0.2
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("chart.js"),l=require("react"),r=require("react-chartjs-2"),n=require("../../../TypographyStyle.js"),i=require("../../../../constants/Theme.js"),o=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:a,labels:s,canvasHeight:d,datas:c,maintainAspectRatio:u=!1,stepSize:g,min:p,max:b,isZeroState:y,tension:C,isNewStyles:v,ticksLabelCallback:O,prefixCurrencyInYAxis:x,pointRadius:h,labelCallback:m,afterBodyCallBack:S,titleTooltipCallback:
|
|
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("./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:a,labels:s,canvasHeight:d,datas:c,maintainAspectRatio:u=!1,stepSize:g,min:p,max:b,isZeroState:y,tension:C,isNewStyles:v,ticksLabelCallback:O,prefixCurrencyInYAxis:x,pointRadius:h,labelCallback:m,afterBodyCallBack:S,titleTooltipCallback:j}=t;var L,f,k;const[R,w]=l.useState(null),B=l.useRef();l.useEffect((()=>{var e,t,l,r;if(null===(r=null===(l=null===(t=null===(e=B.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*B.current.scales.y.ticks.length;w(e)}}),[B]);const q=c.map((e=>({text:e.legend,color:e.lineColor?e.lineColor:e.dotted?i.COLORS.content.placeholder:i.COLORS.background.brand}))),E={labels:s,datasets:c.map(((e,t)=>{var l,r;return Object.assign(Object.assign({tension:null!=C?C:.4,fill:e.gradient?"start":0},((e,t)=>{const l={borderColor:e||(t?i.COLORS.content.placeholder:i.COLORS.background.brand)};return v?Object.assign({pointStyle:"circle",pointRadius:null!=h?h:5,pointBorderColor:"transparent",pointBackgroundColor:e||(t?i.COLORS.content.placeholder:i.COLORS.background.brand)},l):Object.assign({pointRadius:null!=h?h: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,R?R-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})}))},T={maintainAspectRatio:u,responsive:!0,plugins:{legend:{display:!1},title:{display:!1},tooltip:{displayColors:null!=v&&v,titleFont:()=>({weight:"600",size:14,family:"inter"}),titleColor:()=>i.COLORS.content.primaryInverse,backgroundColor:i.COLORS.content.primary,callbacks:{labelTextColor:()=>i.COLORS.content.primaryInverse,title:j,label:m,afterBody:S},bodyFont:()=>({weight:"400",size:14,family:"inter"})}},scales:{y:{beginAtZero:!0,min:y?0:p,max:y?10:b,ticks:{color:i.COLORS.content.secondary,callback:e=>{var t;return`${null!==(t=null==a?void 0:a.yPrefix)&&void 0!==t?t:""}${e}${null!=x?x:""}`},font:{family:"inter",size:12,weight:"400"},stepSize:y?1:g},title:{display:!!(null==a?void 0:a.y),text:null==a?void 0:a.y},grid:{color:i.COLORS.background.base,drawBorder:null===(L=null==a?void 0:a.yDrawBorder)||void 0===L||L}},x:{ticks:{callback:O,color:i.COLORS.content.secondary,font:{family:"inter",size:12,weight:"400"}},title:{display:!!(null==a?void 0:a.x),text:null==a?void 0:a.x},grid:{display:!1,drawBorder:null!==(f=null==a?void 0:a.xDrawBorder)&&void 0!==f&&f}}}};return e.jsxs("div",Object.assign({style:Object.assign(Object.assign({},u?{}:{height:null!==(k=null!=d?d:R)&&void 0!==k?k:204}),{display:"flex",flexDirection:"column",gap:2,width:"100%"})},{children:[e.jsx(o.LegendWrapper,{children:q.map(((t,l)=>{let{text:r,color:i}=t;return r?e.jsxs(o.LegendContainer,{children:[e.jsx(o.LegendColor,{color:i,newStyle:v}),e.jsx(n.SmallRegular,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:B,options:T,data:E})}))]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as t,jsx as e,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 d,ArcElement as s,Filler as c,Title as p,Tooltip as u,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{SmallRegular as h}from"../../../TypographyStyle.js";import{COLORS as f}from"../../../../constants/Theme.js";import{LegendWrapper as
|
|
1
|
+
import{jsxs as t,jsx as e,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 d,ArcElement as s,Filler as c,Title as p,Tooltip as u,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{SmallRegular as h}from"../../../TypographyStyle.js";import{COLORS as f}from"../../../../constants/Theme.js";import{LegendWrapper as x,LegendContainer as k,LegendColor as C}from"./LineChart.styled.js";o.register(r,n,i,a,d,s,c,p,u,g);const j=o=>{let{scaleText:r,labels:n,canvasHeight:i,datas:a,maintainAspectRatio:d=!1,stepSize:s,min:c,max:p,isZeroState:u,tension:g,isNewStyles:j,ticksLabelCallback:w,prefixCurrencyInYAxis:B,pointRadius:O,labelCallback:S,afterBodyCallBack:z,titleTooltipCallback:R}=o;var T,A,D;const[F,I]=b(null),L=y();m((()=>{var t,e,l,o;if(null===(o=null===(l=null===(e=null===(t=L.current)||void 0===t?void 0:t.scales)||void 0===e?void 0:e.y)||void 0===l?void 0:l.ticks)||void 0===o?void 0:o.length){const t=38*L.current.scales.y.ticks.length;I(t)}}),[L]);const $=a.map((t=>({text:t.legend,color:t.lineColor?t.lineColor:t.dotted?f.content.placeholder:f.background.brand}))),E={labels:n,datasets:a.map(((t,e)=>{var l,o;return Object.assign(Object.assign({tension:null!=g?g:.4,fill:t.gradient?"start":0},((t,e)=>{const l={borderColor:t||(e?f.content.placeholder:f.background.brand)};return j?Object.assign({pointStyle:"circle",pointRadius:null!=O?O:5,pointBorderColor:"transparent",pointBackgroundColor:t||(e?f.content.placeholder:f.background.brand)},l):Object.assign({pointRadius:null!=O?O:1},l)})(t.lineColor,t.dotted)),{borderDash:t.dotted?[8,3]:void 0,data:t.data,borderWidth:null!==(l=t.lineWidth)&&void 0!==l?l:2,backgroundColor:t.gradient?t=>{const e=t.chart.ctx.createLinearGradient(0,0,0,F?F-75:150);return e.addColorStop(0,"#F1EEFB"),e.addColorStop(1,"rgba(127, 86, 217, 0)"),e}:null!==(o=t.backgroundColor)&&void 0!==o?o:"transparent",legend:t.legend})}))},W={maintainAspectRatio:d,responsive:!0,plugins:{legend:{display:!1},title:{display:!1},tooltip:{displayColors:null!=j&&j,titleFont:()=>({weight:"600",size:14,family:"inter"}),titleColor:()=>f.content.primaryInverse,backgroundColor:f.content.primary,callbacks:{labelTextColor:()=>f.content.primaryInverse,title:R,label:S,afterBody:z},bodyFont:()=>({weight:"400",size:14,family:"inter"})}},scales:{y:{beginAtZero:!0,min:u?0:c,max:u?10:p,ticks:{color:f.content.secondary,callback:t=>{var e;return`${null!==(e=null==r?void 0:r.yPrefix)&&void 0!==e?e:""}${t}${null!=B?B:""}`},font:{family:"inter",size:12,weight:"400"},stepSize:u?1:s},title:{display:!!(null==r?void 0:r.y),text:null==r?void 0:r.y},grid:{color:f.background.base,drawBorder:null===(T=null==r?void 0:r.yDrawBorder)||void 0===T||T}},x:{ticks:{callback:w,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 t("div",Object.assign({style:Object.assign(Object.assign({},d?{}:{height:null!==(D=null!=i?i:F)&&void 0!==D?D:204}),{display:"flex",flexDirection:"column",gap:2,width:"100%"})},{children:[e(x,{children:$.map(((o,r)=>{let{text:n,color:i}=o;return n?t(k,{children:[e(C,{color:i,newStyle:j}),e(h,Object.assign({color:"#667085"},{children:n}))]},r):e(l,{})}))}),e("div",Object.assign({style:{flex:1}},{children:e(v,{ref:L,options:W,data:E})}))]}))};export{j as LineChart};
|