@synertech/ui 0.45.0 → 0.45.1

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.
Files changed (43) hide show
  1. package/.claude/skills/use-synertech-ui/SKILL.md +1 -1
  2. package/dist/components/area-chart/AreaChart.cjs +1 -1
  3. package/dist/components/area-chart/AreaChart.js +1 -1
  4. package/dist/components/bar-chart/BarChart.cjs +1 -1
  5. package/dist/components/bar-chart/BarChart.js +1 -1
  6. package/dist/components/box-plot/BoxPlot.cjs +1 -1
  7. package/dist/components/box-plot/BoxPlot.js +1 -1
  8. package/dist/components/bullet-chart/BulletChart.cjs +1 -1
  9. package/dist/components/bullet-chart/BulletChart.js +1 -1
  10. package/dist/components/candlestick-chart/CandlestickChart.cjs +1 -1
  11. package/dist/components/candlestick-chart/CandlestickChart.js +1 -1
  12. package/dist/components/chart/ChartSync.cjs +1 -1
  13. package/dist/components/chart/ChartSync.js +1 -1
  14. package/dist/components/chart/utils/cartesian.cjs +1 -1
  15. package/dist/components/chart/utils/cartesian.js +1 -1
  16. package/dist/components/chart/utils/path.cjs +1 -1
  17. package/dist/components/chart/utils/path.js +1 -1
  18. package/dist/components/chart/utils/time.cjs +1 -1
  19. package/dist/components/chart/utils/time.js +1 -1
  20. package/dist/components/chart/utils/timestamp.cjs +1 -0
  21. package/dist/components/chart/utils/timestamp.js +1 -0
  22. package/dist/components/chart/utils/touch.cjs +1 -0
  23. package/dist/components/chart/utils/touch.js +1 -0
  24. package/dist/components/dumbbell-chart/DumbbellChart.cjs +1 -1
  25. package/dist/components/dumbbell-chart/DumbbellChart.js +1 -1
  26. package/dist/components/funnel-chart/FunnelChart.cjs +1 -1
  27. package/dist/components/funnel-chart/FunnelChart.js +1 -1
  28. package/dist/components/gantt-chart/GanttChart.cjs +1 -1
  29. package/dist/components/gantt-chart/GanttChart.js +1 -1
  30. package/dist/components/heat-map/Heatmap.cjs +1 -1
  31. package/dist/components/heat-map/Heatmap.js +1 -1
  32. package/dist/components/line-chart/LineChart.cjs +1 -1
  33. package/dist/components/line-chart/LineChart.js +1 -1
  34. package/dist/components/pie-chart/PieChart.cjs +1 -1
  35. package/dist/components/pie-chart/PieChart.js +1 -1
  36. package/dist/components/scatter-chart/ScatterChart.cjs +1 -1
  37. package/dist/components/scatter-chart/ScatterChart.js +1 -1
  38. package/dist/components/waterfall-chart/WaterfallChart.cjs +1 -1
  39. package/dist/components/waterfall-chart/WaterfallChart.js +1 -1
  40. package/dist/index.d.cts +16 -3
  41. package/dist/index.d.ts +16 -3
  42. package/dist/styles.css +27 -0
  43. package/package.json +13 -13
@@ -1 +1 @@
1
- "use strict";"use client";var Q=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var fe=Object.getOwnPropertyNames;var be=Object.prototype.hasOwnProperty;var ye=(l,a)=>{for(var r in a)Q(l,r,{get:a[r],enumerable:!0})},pe=(l,a,r,o)=>{if(a&&typeof a=="object"||typeof a=="function")for(let g of fe(a))!be.call(l,g)&&g!==r&&Q(l,g,{get:()=>a[g],enumerable:!(o=me(a,g))||o.enumerable});return l};var Ce=l=>pe(Q({},"__esModule",{value:!0}),l);var Re={};ye(Re,{CandlestickChart:()=>Le});module.exports=Ce(Re);var c=require("react"),te=require("../../lib/i18n.cjs"),ee=require("../chart/ChartAxis.cjs"),ae=require("../chart/ChartContainer.cjs"),oe=require("../chart/ChartGrid.cjs"),le=require("../chart/ChartLegend.cjs"),ie=require("../chart/ChartTableView.cjs"),se=require("../chart/ChartTooltip.cjs"),_=require("../chart/palette.cjs"),ue=require("../chart/utils/cartesian.cjs"),L=require("../chart/utils/data.cjs"),$=require("../chart/utils/format.cjs"),he=require("../chart/utils/path.cjs"),ce=require("../chart/utils/scales.cjs"),e=require("react/jsx-runtime"),ke=16,xe=1.5,we=(0,c.memo)(function({candles:a}){return(0,e.jsx)("g",{children:a.map(r=>(0,e.jsxs)("g",{children:[r.wick?(0,e.jsx)("line",{x1:r.wick.x,y1:r.wick.y1,x2:r.wick.x,y2:r.wick.y2,stroke:r.color,strokeWidth:1.5}):null,r.body?(0,e.jsx)("path",{d:r.body,fill:r.hollow?"none":r.color,stroke:r.color,strokeWidth:r.hollow?1.5:0}):null]},r.key))})});function ve({width:l,height:a,data:r,candles:o,x:g,y:p,grid:R,size:X,candleSize:E,fillRising:P,palette:M,referenceLines:I,margin:W,tooltip:b,plotLabel:K,formatValue:y,formatX:D,onCandleClick:N}){let[u,S]=(0,c.useState)(null),C=(0,te.useUILabels)(),t=(0,c.useMemo)(()=>{let n=o.flatMap(s=>s.high===null||s.low===null?[]:[s.low,s.high]),i=(0,ue.buildCartesianGeometry)({width:l,height:a,data:r,x:g,y:p,bounds:n.length===0?null:[Math.min(...n),Math.max(...n)],margin:W,orientation:"vertical",placement:"band",formatValue:y,formatX:D,defaultIncludeZero:!1}),{valueScale:d,bandwidth:k,categoryPositions:z,innerWidth:U,innerHeight:j}=i,x=Math.min(E??ke,Math.max(1,k-2));return{rendered:o.map((s,G)=>{let H=z[G]+(k-x)/2,q=H+x/2,f=s.rising?M.up:M.down,O=s.high===null||s.low===null?null:{x:q,y1:d(s.high),y2:d(s.low)},w=null;if(s.open!==null&&s.close!==null){let T=d(s.open),v=d(s.close);w=(0,he.buildBarPath)({x:H,y:Math.min(T,v),width:x,height:Math.max(xe,Math.abs(v-T)),radius:0,round:"none"})}return{key:`${G}`,color:f,body:w,hollow:s.rising&&!P,wick:O,left:H,width:x}}),categoryPositions:z,categoryCenters:i.categoryCenters,bandwidth:k,categoryTicks:i.categoryTicks,valueTicks:i.valueTicks,valueScale:d,innerWidth:U,innerHeight:j,margin:i.margin}},[o,r,g,p,l,a,W,E,P,M,y,D]),B=(0,c.useCallback)(n=>{if(b===!1||o.length===0)return;let i=n.currentTarget.getBoundingClientRect(),d=n.clientX-i.left-t.margin.left;S((0,ce.nearestIndex)(t.categoryCenters,d))},[b,o.length,t.margin.left,t.categoryCenters]),Y=(0,c.useCallback)(n=>{if(o.length===0)return;let i=o.length-1,d=u??0,k=n.key==="ArrowRight"?Math.min(i,d+1):n.key==="ArrowLeft"?Math.max(0,d-1):n.key==="Home"?0:n.key==="End"?i:n.key==="Escape"?null:void 0;k!==void 0&&(n.preventDefault(),S(k))},[o.length,u]),F=(0,c.useCallback)(()=>{!N||u===null||N(o[u])},[N,u,o]),h=u===null?null:o[u];return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("svg",{width:l,height:a,role:"img","aria-label":K??o.map(n=>n.label).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:B,onPointerLeave:()=>S(null),onKeyDown:Y,onBlur:()=>S(null),onClick:F,children:[(0,e.jsxs)("g",{transform:`translate(${t.margin.left}, ${t.margin.top})`,children:[(0,e.jsx)(oe.ChartGrid,{width:t.innerWidth,height:t.innerHeight,horizontal:R==="y"||R==="both"?t.valueTicks.map(n=>n.offset):void 0}),u!==null?(0,e.jsx)("rect",{x:t.categoryPositions[u],y:0,width:t.bandwidth,height:t.innerHeight,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,I?.map(n=>(0,e.jsxs)("g",{children:[(0,e.jsx)("line",{x1:0,y1:t.valueScale(n.value),x2:t.innerWidth,y2:t.valueScale(n.value),stroke:n.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:n.dashed===!1?void 0:"4 4"}),n.label?(0,e.jsx)("text",{x:t.innerWidth,y:t.valueScale(n.value)-4,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:n.label}):null]},`${n.value}-${n.label??""}`)),(0,e.jsx)(we,{candles:t.rendered})]}),(0,e.jsx)("g",{transform:`translate(${t.margin.left}, ${t.margin.top+t.innerHeight})`,children:g.hidden?null:(0,e.jsx)(ee.ChartAxis,{orientation:"bottom",ticks:t.categoryTicks,length:t.innerWidth,label:g.label,size:X})}),(0,e.jsx)("g",{transform:`translate(${t.margin.left}, ${t.margin.top})`,children:p?.hidden?null:(0,e.jsx)(ee.ChartAxis,{orientation:"left",ticks:t.valueTicks,length:t.innerHeight,showLine:!1,label:p?.label,size:X})})]}),h&&u!==null&&b!==!1?(0,e.jsx)(se.ChartTooltip,{x:t.margin.left+t.categoryCenters[u],y:t.margin.top+(h.high===null?t.innerHeight/2:t.valueScale(h.high)),containerWidth:l,children:typeof b=="function"?b(h):(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:h.label}),(0,e.jsx)("dl",{className:"grid grid-cols-[auto_auto] gap-x-3 gap-y-0.5",children:[[C.chartOpen,h.open],[C.chartHigh,h.high],[C.chartLow,h.low],[C.chartClose,h.close]].map(([n,i])=>(0,e.jsxs)("div",{className:"contents",children:[(0,e.jsx)("dt",{className:"text-gray-500 dark:text-gray-400",children:n}),(0,e.jsx)("dd",{className:"justify-self-end font-medium text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:i===null?"\u2014":y(i)})]},n))}),h.change===null?null:(0,e.jsxs)("div",{className:"flex items-center gap-2 border-t border-gray-200 pt-1 dark:border-gray-700",children:[(0,e.jsx)("span",{className:"text-gray-500 dark:text-gray-400",children:h.rising?C.chartRise:C.chartFall}),(0,e.jsxs)("span",{className:"[font-variant-numeric:tabular-nums] font-semibold text-gray-900 dark:text-gray-100",children:[h.change>0?"+":"",y(h.change)]})]})]})}):null]})}function Le({data:l,x:a,y:r,open:o,high:g,low:p,close:R,candleSize:X,fillRising:E=!1,colors:P,referenceLines:M,height:I=300,width:W,size:b="md",grid:K="y",legend:y,tooltip:D=!0,tableView:N=!1,title:u,description:S,loading:C=!1,emptyState:t,error:B=!1,errorState:Y,onRetry:F,actions:h,margin:n,locale:i,plotLabel:d,openLabel:k,highLabel:z,lowLabel:U,closeLabel:j,riseLabel:x,fallLabel:Z,format:s,onCandleClick:G,className:H,...q}){let f=(0,te.useUILabels)(),O=(0,c.useMemo)(()=>r?.format??s??(m=>(0,$.formatAuto)(m,i)),[r?.format,s,i]),w=(0,c.useMemo)(()=>a.format??(m=>(0,$.formatXValue)(m,i)),[a.format,i]),T=(0,c.useMemo)(()=>l.map((m,J)=>{let re=(0,L.readXValue)(m,a.key,J),A=(0,L.readNumber)(m,o),V=(0,L.readNumber)(m,R);return{index:J,x:re,label:w(re,J),open:A,high:(0,L.readNumber)(m,g),low:(0,L.readNumber)(m,p),close:V,change:A===null||V===null?null:V-A,rising:A===null||V===null?!0:V>=A,datum:m}}),[l,a.key,o,g,p,R,w]),v=(0,c.useMemo)(()=>({up:P?.up??_.CHART_UP_COLOR,down:P?.down??_.CHART_DOWN_COLOR}),[P]),ge=(0,c.useMemo)(()=>[{key:"up",label:x??f.chartRise,color:v.up,marker:"rect"},{key:"down",label:Z??f.chartFall,color:v.down,marker:"rect"}],[v,x,Z,f.chartRise,f.chartFall]),de=y===void 0?!0:y!==!1,ne=typeof y=="string"?y:"bottom";return(0,e.jsx)(ae.ChartContainer,{title:u,description:S,height:I,width:W,size:b,loading:C,empty:T.length===0,emptyState:t,error:B,errorState:Y,onRetry:F,actions:h,tableView:N,legendPosition:ne,legend:de?(0,e.jsx)(le.ChartLegend,{items:ge,position:ne,marker:"rect",size:b}):void 0,table:N?(0,e.jsx)(ie.ChartTableView,{data:l,series:[{key:o,label:k??f.chartOpen},{key:g,label:z??f.chartHigh},{key:p,label:U??f.chartLow},{key:R,label:j??f.chartClose}],xKey:a.key,xLabel:a.label??a.key,formatX:w,formatValue:O,caption:typeof u=="string"?u:void 0}):void 0,className:H,...q,children:({width:m})=>(0,e.jsx)(ve,{width:m,height:I,data:l,candles:T,x:a,y:r,grid:K,size:b,candleSize:X,fillRising:E,palette:v,referenceLines:M,margin:n,tooltip:D,plotLabel:d,formatValue:O,formatX:w,onCandleClick:G})})}0&&(module.exports={CandlestickChart});
1
+ "use strict";"use client";var ee=Object.defineProperty;var fe=Object.getOwnPropertyDescriptor;var be=Object.getOwnPropertyNames;var pe=Object.prototype.hasOwnProperty;var ye=(l,a)=>{for(var r in a)ee(l,r,{get:a[r],enumerable:!0})},Ce=(l,a,r,o)=>{if(a&&typeof a=="object"||typeof a=="function")for(let c of be(a))!pe.call(l,c)&&c!==r&&ee(l,c,{get:()=>a[c],enumerable:!(o=fe(a,c))||o.enumerable});return l};var ke=l=>Ce(ee({},"__esModule",{value:!0}),l);var Pe={};ye(Pe,{CandlestickChart:()=>Re});module.exports=ke(Pe);var h=require("react"),ne=require("../../lib/i18n.cjs"),te=require("../chart/ChartAxis.cjs"),oe=require("../chart/ChartContainer.cjs"),le=require("../chart/ChartGrid.cjs"),ie=require("../chart/ChartLegend.cjs"),se=require("../chart/ChartTableView.cjs"),ue=require("../chart/ChartTooltip.cjs"),B=require("../chart/palette.cjs"),he=require("../chart/utils/cartesian.cjs"),L=require("../chart/utils/data.cjs"),Y=require("../chart/utils/format.cjs"),ce=require("../chart/utils/path.cjs"),ge=require("../chart/utils/scales.cjs"),me=require("../chart/utils/touch.cjs"),t=require("react/jsx-runtime"),xe=16,we=1.5,ve=(0,h.memo)(function({candles:a}){return(0,t.jsx)("g",{children:a.map(r=>(0,t.jsxs)("g",{children:[r.wick?(0,t.jsx)("line",{x1:r.wick.x,y1:r.wick.y1,x2:r.wick.x,y2:r.wick.y2,stroke:r.color,strokeWidth:1.5}):null,r.body?(0,t.jsx)("path",{d:r.body,fill:r.hollow?"none":r.color,stroke:r.color,strokeWidth:r.hollow?1.5:0}):null]},r.key))})});function Le({width:l,height:a,data:r,candles:o,x:c,y,grid:R,size:I,candleSize:E,fillRising:P,palette:M,referenceLines:W,margin:D,tooltip:b,plotLabel:F,formatValue:p,formatX:O,onCandleClick:N}){let[x,S]=(0,h.useState)(null),g=x!==null&&x<o.length?x:null,C=(0,ne.useUILabels)(),n=(0,h.useMemo)(()=>{let e=o.flatMap(i=>i.high===null||i.low===null?[]:[i.low,i.high]),u=(0,he.buildCartesianGeometry)({width:l,height:a,data:r,x:c,y,bounds:e.length===0?null:[Math.min(...e),Math.max(...e)],margin:D,orientation:"vertical",placement:"band",formatValue:p,formatX:O,defaultIncludeZero:!1}),{valueScale:m,bandwidth:k,categoryPositions:z,innerWidth:q,innerHeight:G}=u,w=Math.min(E??xe,Math.max(1,k-2));return{rendered:o.map((i,_)=>{let T=z[_]+(k-w)/2,f=T+w/2,$=i.rising?M.up:M.down,H=i.high===null||i.low===null?null:{x:f,y1:m(i.high),y2:m(i.low)},A=null;if(i.open!==null&&i.close!==null){let v=m(i.open),K=m(i.close);A=(0,ce.buildBarPath)({x:T,y:Math.min(v,K),width:w,height:Math.max(we,Math.abs(K-v)),radius:0,round:"none"})}return{key:`${_}`,color:$,body:A,hollow:i.rising&&!P,wick:H,left:T,width:w}}),categoryPositions:z,categoryCenters:u.categoryCenters,bandwidth:k,categoryTicks:u.categoryTicks,valueTicks:u.valueTicks,valueScale:m,innerWidth:q,innerHeight:G,margin:u.margin}},[o,r,c,y,l,a,D,E,P,M,p,O]),U=(0,h.useCallback)(e=>{if(b===!1||o.length===0)return;let u=e.currentTarget.getBoundingClientRect(),m=e.clientX-u.left-n.margin.left;S((0,ge.nearestIndex)(n.categoryCenters,m))},[b,o.length,n.margin.left,n.categoryCenters]),j=(0,h.useCallback)(e=>{if(o.length===0)return;let u=o.length-1,m=g??0,k=e.key==="ArrowRight"?Math.min(u,m+1):e.key==="ArrowLeft"?Math.max(0,m-1):e.key==="Home"?0:e.key==="End"?u:e.key==="Escape"?null:void 0;k!==void 0&&(e.preventDefault(),S(k))},[o.length,g]),Z=(0,h.useCallback)(()=>{!N||g===null||N(o[g])},[N,g,o]),s=g===null?null:o[g];return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("svg",{width:l,height:a,role:"img","aria-label":F??o.map(e=>e.label).join(", "),tabIndex:0,className:`${me.CHART_TOUCH} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500`,onPointerMove:U,onPointerLeave:()=>S(null),onKeyDown:j,onBlur:()=>S(null),onClick:Z,children:[(0,t.jsxs)("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:[(0,t.jsx)(le.ChartGrid,{width:n.innerWidth,height:n.innerHeight,horizontal:R==="y"||R==="both"?n.valueTicks.map(e=>e.offset):void 0}),g!==null?(0,t.jsx)("rect",{x:n.categoryPositions[g],y:0,width:n.bandwidth,height:n.innerHeight,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,W?.map(e=>(0,t.jsxs)("g",{children:[(0,t.jsx)("line",{x1:0,y1:n.valueScale(e.value),x2:n.innerWidth,y2:n.valueScale(e.value),stroke:e.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:e.dashed===!1?void 0:"4 4"}),e.label?(0,t.jsx)("text",{x:n.innerWidth,y:n.valueScale(e.value)-4,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:e.label}):null]},`${e.value}-${e.label??""}`)),(0,t.jsx)(ve,{candles:n.rendered})]}),(0,t.jsx)("g",{transform:`translate(${n.margin.left}, ${n.margin.top+n.innerHeight})`,children:c.hidden?null:(0,t.jsx)(te.ChartAxis,{orientation:"bottom",ticks:n.categoryTicks,length:n.innerWidth,label:c.label,size:I})}),(0,t.jsx)("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:y?.hidden?null:(0,t.jsx)(te.ChartAxis,{orientation:"left",ticks:n.valueTicks,length:n.innerHeight,showLine:!1,label:y?.label,size:I})})]}),s&&g!==null&&b!==!1?(0,t.jsx)(ue.ChartTooltip,{x:n.margin.left+n.categoryCenters[g],y:n.margin.top+(s.high===null?n.innerHeight/2:n.valueScale(s.high)),containerWidth:l,children:typeof b=="function"?b(s):(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:s.label}),(0,t.jsx)("dl",{className:"grid grid-cols-[auto_auto] gap-x-3 gap-y-0.5",children:[[C.chartOpen,s.open],[C.chartHigh,s.high],[C.chartLow,s.low],[C.chartClose,s.close]].map(([e,u])=>(0,t.jsxs)("div",{className:"contents",children:[(0,t.jsx)("dt",{className:"text-gray-500 dark:text-gray-400",children:e}),(0,t.jsx)("dd",{className:"justify-self-end font-medium text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:u===null?"\u2014":p(u)})]},e))}),s.change===null?null:(0,t.jsxs)("div",{className:"flex items-center gap-2 border-t border-gray-200 pt-1 dark:border-gray-700",children:[(0,t.jsx)("span",{className:"text-gray-500 dark:text-gray-400",children:s.rising?C.chartRise:C.chartFall}),(0,t.jsxs)("span",{className:"[font-variant-numeric:tabular-nums] font-semibold text-gray-900 dark:text-gray-100",children:[s.change>0?"+":"",p(s.change)]})]})]})}):null]})}function Re({data:l,x:a,y:r,open:o,high:c,low:y,close:R,candleSize:I,fillRising:E=!1,colors:P,referenceLines:M,height:W=300,width:D,size:b="md",grid:F="y",legend:p,tooltip:O=!0,tableView:N=!1,title:x,description:S,loading:g=!1,emptyState:C,error:n=!1,errorState:U,onRetry:j,actions:Z,margin:s,locale:e,plotLabel:u,openLabel:m,highLabel:k,lowLabel:z,closeLabel:q,riseLabel:G,fallLabel:w,format:J,onCandleClick:i,className:_,...T}){let f=(0,ne.useUILabels)(),$=(0,h.useMemo)(()=>r?.format??J??(d=>(0,Y.formatAuto)(d,e)),[r?.format,J,e]),H=(0,h.useMemo)(()=>a.format??(d=>(0,Y.formatXValue)(d,e)),[a.format,e]),A=(0,h.useMemo)(()=>l.map((d,Q)=>{let ae=(0,L.readXValue)(d,a.key,Q),V=(0,L.readNumber)(d,o),X=(0,L.readNumber)(d,R);return{index:Q,x:ae,label:H(ae,Q),open:V,high:(0,L.readNumber)(d,c),low:(0,L.readNumber)(d,y),close:X,change:V===null||X===null?null:X-V,rising:V===null||X===null?!0:X>=V,datum:d}}),[l,a.key,o,c,y,R,H]),v=(0,h.useMemo)(()=>({up:P?.up??B.CHART_UP_COLOR,down:P?.down??B.CHART_DOWN_COLOR}),[P]),K=(0,h.useMemo)(()=>[{key:"up",label:G??f.chartRise,color:v.up,marker:"rect"},{key:"down",label:w??f.chartFall,color:v.down,marker:"rect"}],[v,G,w,f.chartRise,f.chartFall]),de=p===void 0?!0:p!==!1,re=typeof p=="string"?p:"bottom";return(0,t.jsx)(oe.ChartContainer,{title:x,description:S,height:W,width:D,size:b,loading:g,empty:A.length===0,emptyState:C,error:n,errorState:U,onRetry:j,actions:Z,tableView:N,legendPosition:re,legend:de?(0,t.jsx)(ie.ChartLegend,{items:K,position:re,marker:"rect",size:b}):void 0,table:N?(0,t.jsx)(se.ChartTableView,{data:l,series:[{key:o,label:m??f.chartOpen},{key:c,label:k??f.chartHigh},{key:y,label:z??f.chartLow},{key:R,label:q??f.chartClose}],xKey:a.key,xLabel:a.label??a.key,formatX:H,formatValue:$,caption:typeof x=="string"?x:void 0}):void 0,className:_,...T,children:({width:d})=>(0,t.jsx)(Le,{width:d,height:W,data:l,candles:A,x:a,y:r,grid:F,size:b,candleSize:I,fillRising:E,palette:v,referenceLines:M,margin:s,tooltip:O,plotLabel:u,formatValue:$,formatX:H,onCandleClick:i})})}0&&(module.exports={CandlestickChart});
@@ -1 +1 @@
1
- "use client";import{memo as oe,useCallback as J,useMemo as S,useState as le}from"react";import{useUILabels as ne}from"../../lib/i18n.js";import{ChartAxis as te}from"../chart/ChartAxis.js";import{ChartContainer as ie}from"../chart/ChartContainer.js";import{ChartGrid as se}from"../chart/ChartGrid.js";import{ChartLegend as ue}from"../chart/ChartLegend.js";import{ChartTableView as he}from"../chart/ChartTableView.js";import{ChartTooltip as ce}from"../chart/ChartTooltip.js";import{CHART_DOWN_COLOR as ge,CHART_UP_COLOR as de}from"../chart/palette.js";import{buildCartesianGeometry as me}from"../chart/utils/cartesian.js";import{readNumber as _,readXValue as fe}from"../chart/utils/data.js";import{formatAuto as be,formatXValue as ye}from"../chart/utils/format.js";import{buildBarPath as pe}from"../chart/utils/path.js";import{nearestIndex as Ce}from"../chart/utils/scales.js";import{Fragment as Le,jsx as n,jsxs as b}from"react/jsx-runtime";var ke=16,xe=1.5,we=oe(function({candles:u}){return n("g",{children:u.map(r=>b("g",{children:[r.wick?n("line",{x1:r.wick.x,y1:r.wick.y1,x2:r.wick.x,y2:r.wick.y2,stroke:r.color,strokeWidth:1.5}):null,r.body?n("path",{d:r.body,fill:r.hollow?"none":r.color,stroke:r.color,strokeWidth:r.hollow?1.5:0}):null]},r.key))})});function ve({width:g,height:u,data:r,candles:l,x:y,y:p,grid:L,size:X,candleSize:E,fillRising:R,palette:M,referenceLines:I,margin:W,tooltip:m,plotLabel:$,formatValue:f,formatX:D,onCandleClick:P}){let[i,N]=le(null),C=ne(),e=S(()=>{let t=l.flatMap(o=>o.high===null||o.low===null?[]:[o.low,o.high]),a=me({width:g,height:u,data:r,x:y,y:p,bounds:t.length===0?null:[Math.min(...t),Math.max(...t)],margin:W,orientation:"vertical",placement:"band",formatValue:f,formatX:D,defaultIncludeZero:!1}),{valueScale:h,bandwidth:k,categoryPositions:z,innerWidth:F,innerHeight:U}=a,x=Math.min(E??ke,Math.max(1,k-2));return{rendered:l.map((o,G)=>{let H=z[G]+(k-x)/2,Z=H+x/2,d=o.rising?M.up:M.down,O=o.high===null||o.low===null?null:{x:Z,y1:h(o.high),y2:h(o.low)},w=null;if(o.open!==null&&o.close!==null){let T=h(o.open),v=h(o.close);w=pe({x:H,y:Math.min(T,v),width:x,height:Math.max(xe,Math.abs(v-T)),radius:0,round:"none"})}return{key:`${G}`,color:d,body:w,hollow:o.rising&&!R,wick:O,left:H,width:x}}),categoryPositions:z,categoryCenters:a.categoryCenters,bandwidth:k,categoryTicks:a.categoryTicks,valueTicks:a.valueTicks,valueScale:h,innerWidth:F,innerHeight:U,margin:a.margin}},[l,r,y,p,g,u,W,E,R,M,f,D]),K=J(t=>{if(m===!1||l.length===0)return;let a=t.currentTarget.getBoundingClientRect(),h=t.clientX-a.left-e.margin.left;N(Ce(e.categoryCenters,h))},[m,l.length,e.margin.left,e.categoryCenters]),B=J(t=>{if(l.length===0)return;let a=l.length-1,h=i??0,k=t.key==="ArrowRight"?Math.min(a,h+1):t.key==="ArrowLeft"?Math.max(0,h-1):t.key==="Home"?0:t.key==="End"?a:t.key==="Escape"?null:void 0;k!==void 0&&(t.preventDefault(),N(k))},[l.length,i]),Y=J(()=>{!P||i===null||P(l[i])},[P,i,l]),s=i===null?null:l[i];return b(Le,{children:[b("svg",{width:g,height:u,role:"img","aria-label":$??l.map(t=>t.label).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:K,onPointerLeave:()=>N(null),onKeyDown:B,onBlur:()=>N(null),onClick:Y,children:[b("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[n(se,{width:e.innerWidth,height:e.innerHeight,horizontal:L==="y"||L==="both"?e.valueTicks.map(t=>t.offset):void 0}),i!==null?n("rect",{x:e.categoryPositions[i],y:0,width:e.bandwidth,height:e.innerHeight,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,I?.map(t=>b("g",{children:[n("line",{x1:0,y1:e.valueScale(t.value),x2:e.innerWidth,y2:e.valueScale(t.value),stroke:t.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:t.dashed===!1?void 0:"4 4"}),t.label?n("text",{x:e.innerWidth,y:e.valueScale(t.value)-4,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:t.label}):null]},`${t.value}-${t.label??""}`)),n(we,{candles:e.rendered})]}),n("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:y.hidden?null:n(te,{orientation:"bottom",ticks:e.categoryTicks,length:e.innerWidth,label:y.label,size:X})}),n("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:p?.hidden?null:n(te,{orientation:"left",ticks:e.valueTicks,length:e.innerHeight,showLine:!1,label:p?.label,size:X})})]}),s&&i!==null&&m!==!1?n(ce,{x:e.margin.left+e.categoryCenters[i],y:e.margin.top+(s.high===null?e.innerHeight/2:e.valueScale(s.high)),containerWidth:g,children:typeof m=="function"?m(s):b("div",{className:"flex flex-col gap-1",children:[n("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:s.label}),n("dl",{className:"grid grid-cols-[auto_auto] gap-x-3 gap-y-0.5",children:[[C.chartOpen,s.open],[C.chartHigh,s.high],[C.chartLow,s.low],[C.chartClose,s.close]].map(([t,a])=>b("div",{className:"contents",children:[n("dt",{className:"text-gray-500 dark:text-gray-400",children:t}),n("dd",{className:"justify-self-end font-medium text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:a===null?"\u2014":f(a)})]},t))}),s.change===null?null:b("div",{className:"flex items-center gap-2 border-t border-gray-200 pt-1 dark:border-gray-700",children:[n("span",{className:"text-gray-500 dark:text-gray-400",children:s.rising?C.chartRise:C.chartFall}),b("span",{className:"[font-variant-numeric:tabular-nums] font-semibold text-gray-900 dark:text-gray-100",children:[s.change>0?"+":"",f(s.change)]})]})]})}):null]})}function ze({data:g,x:u,y:r,open:l,high:y,low:p,close:L,candleSize:X,fillRising:E=!1,colors:R,referenceLines:M,height:I=300,width:W,size:m="md",grid:$="y",legend:f,tooltip:D=!0,tableView:P=!1,title:i,description:N,loading:C=!1,emptyState:e,error:K=!1,errorState:B,onRetry:Y,actions:s,margin:t,locale:a,plotLabel:h,openLabel:k,highLabel:z,lowLabel:F,closeLabel:U,riseLabel:x,fallLabel:j,format:o,onCandleClick:G,className:H,...Z}){let d=ne(),O=S(()=>r?.format??o??(c=>be(c,a)),[r?.format,o,a]),w=S(()=>u.format??(c=>ye(c,a)),[u.format,a]),T=S(()=>g.map((c,q)=>{let ee=fe(c,u.key,q),A=_(c,l),V=_(c,L);return{index:q,x:ee,label:w(ee,q),open:A,high:_(c,y),low:_(c,p),close:V,change:A===null||V===null?null:V-A,rising:A===null||V===null?!0:V>=A,datum:c}}),[g,u.key,l,y,p,L,w]),v=S(()=>({up:R?.up??de,down:R?.down??ge}),[R]),re=S(()=>[{key:"up",label:x??d.chartRise,color:v.up,marker:"rect"},{key:"down",label:j??d.chartFall,color:v.down,marker:"rect"}],[v,x,j,d.chartRise,d.chartFall]),ae=f===void 0?!0:f!==!1,Q=typeof f=="string"?f:"bottom";return n(ie,{title:i,description:N,height:I,width:W,size:m,loading:C,empty:T.length===0,emptyState:e,error:K,errorState:B,onRetry:Y,actions:s,tableView:P,legendPosition:Q,legend:ae?n(ue,{items:re,position:Q,marker:"rect",size:m}):void 0,table:P?n(he,{data:g,series:[{key:l,label:k??d.chartOpen},{key:y,label:z??d.chartHigh},{key:p,label:F??d.chartLow},{key:L,label:U??d.chartClose}],xKey:u.key,xLabel:u.label??u.key,formatX:w,formatValue:O,caption:typeof i=="string"?i:void 0}):void 0,className:H,...Z,children:({width:c})=>n(ve,{width:c,height:I,data:g,candles:T,x:u,y:r,grid:$,size:m,candleSize:X,fillRising:E,palette:v,referenceLines:M,margin:t,tooltip:D,plotLabel:h,formatValue:O,formatX:w,onCandleClick:G})})}export{ze as CandlestickChart};
1
+ "use client";import{memo as oe,useCallback as Q,useMemo as H,useState as le}from"react";import{useUILabels as re}from"../../lib/i18n.js";import{ChartAxis as ne}from"../chart/ChartAxis.js";import{ChartContainer as ie}from"../chart/ChartContainer.js";import{ChartGrid as se}from"../chart/ChartGrid.js";import{ChartLegend as ue}from"../chart/ChartLegend.js";import{ChartTableView as he}from"../chart/ChartTableView.js";import{ChartTooltip as ce}from"../chart/ChartTooltip.js";import{CHART_DOWN_COLOR as ge,CHART_UP_COLOR as me}from"../chart/palette.js";import{buildCartesianGeometry as de}from"../chart/utils/cartesian.js";import{readNumber as B,readXValue as fe}from"../chart/utils/data.js";import{formatAuto as be,formatXValue as pe}from"../chart/utils/format.js";import{buildBarPath as ye}from"../chart/utils/path.js";import{nearestIndex as Ce}from"../chart/utils/scales.js";import{CHART_TOUCH as ke}from"../chart/utils/touch.js";import{Fragment as Re,jsx as n,jsxs as b}from"react/jsx-runtime";var xe=16,we=1.5,ve=oe(function({candles:s}){return n("g",{children:s.map(r=>b("g",{children:[r.wick?n("line",{x1:r.wick.x,y1:r.wick.y1,x2:r.wick.x,y2:r.wick.y2,stroke:r.color,strokeWidth:1.5}):null,r.body?n("path",{d:r.body,fill:r.hollow?"none":r.color,stroke:r.color,strokeWidth:r.hollow?1.5:0}):null]},r.key))})});function Le({width:g,height:s,data:r,candles:a,x:p,y,grid:L,size:I,candleSize:E,fillRising:R,palette:M,referenceLines:W,margin:D,tooltip:d,plotLabel:Y,formatValue:f,formatX:O,onCandleClick:P}){let[x,N]=le(null),u=x!==null&&x<a.length?x:null,C=re(),t=H(()=>{let e=a.flatMap(o=>o.high===null||o.low===null?[]:[o.low,o.high]),i=de({width:g,height:s,data:r,x:p,y,bounds:e.length===0?null:[Math.min(...e),Math.max(...e)],margin:D,orientation:"vertical",placement:"band",formatValue:f,formatX:O,defaultIncludeZero:!1}),{valueScale:h,bandwidth:k,categoryPositions:z,innerWidth:Z,innerHeight:G}=i,w=Math.min(E??xe,Math.max(1,k-2));return{rendered:a.map((o,_)=>{let T=z[_]+(k-w)/2,m=T+w/2,$=o.rising?M.up:M.down,S=o.high===null||o.low===null?null:{x:m,y1:h(o.high),y2:h(o.low)},A=null;if(o.open!==null&&o.close!==null){let v=h(o.open),K=h(o.close);A=ye({x:T,y:Math.min(v,K),width:w,height:Math.max(we,Math.abs(K-v)),radius:0,round:"none"})}return{key:`${_}`,color:$,body:A,hollow:o.rising&&!R,wick:S,left:T,width:w}}),categoryPositions:z,categoryCenters:i.categoryCenters,bandwidth:k,categoryTicks:i.categoryTicks,valueTicks:i.valueTicks,valueScale:h,innerWidth:Z,innerHeight:G,margin:i.margin}},[a,r,p,y,g,s,D,E,R,M,f,O]),F=Q(e=>{if(d===!1||a.length===0)return;let i=e.currentTarget.getBoundingClientRect(),h=e.clientX-i.left-t.margin.left;N(Ce(t.categoryCenters,h))},[d,a.length,t.margin.left,t.categoryCenters]),U=Q(e=>{if(a.length===0)return;let i=a.length-1,h=u??0,k=e.key==="ArrowRight"?Math.min(i,h+1):e.key==="ArrowLeft"?Math.max(0,h-1):e.key==="Home"?0:e.key==="End"?i:e.key==="Escape"?null:void 0;k!==void 0&&(e.preventDefault(),N(k))},[a.length,u]),j=Q(()=>{!P||u===null||P(a[u])},[P,u,a]),l=u===null?null:a[u];return b(Re,{children:[b("svg",{width:g,height:s,role:"img","aria-label":Y??a.map(e=>e.label).join(", "),tabIndex:0,className:`${ke} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500`,onPointerMove:F,onPointerLeave:()=>N(null),onKeyDown:U,onBlur:()=>N(null),onClick:j,children:[b("g",{transform:`translate(${t.margin.left}, ${t.margin.top})`,children:[n(se,{width:t.innerWidth,height:t.innerHeight,horizontal:L==="y"||L==="both"?t.valueTicks.map(e=>e.offset):void 0}),u!==null?n("rect",{x:t.categoryPositions[u],y:0,width:t.bandwidth,height:t.innerHeight,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,W?.map(e=>b("g",{children:[n("line",{x1:0,y1:t.valueScale(e.value),x2:t.innerWidth,y2:t.valueScale(e.value),stroke:e.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:e.dashed===!1?void 0:"4 4"}),e.label?n("text",{x:t.innerWidth,y:t.valueScale(e.value)-4,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:e.label}):null]},`${e.value}-${e.label??""}`)),n(ve,{candles:t.rendered})]}),n("g",{transform:`translate(${t.margin.left}, ${t.margin.top+t.innerHeight})`,children:p.hidden?null:n(ne,{orientation:"bottom",ticks:t.categoryTicks,length:t.innerWidth,label:p.label,size:I})}),n("g",{transform:`translate(${t.margin.left}, ${t.margin.top})`,children:y?.hidden?null:n(ne,{orientation:"left",ticks:t.valueTicks,length:t.innerHeight,showLine:!1,label:y?.label,size:I})})]}),l&&u!==null&&d!==!1?n(ce,{x:t.margin.left+t.categoryCenters[u],y:t.margin.top+(l.high===null?t.innerHeight/2:t.valueScale(l.high)),containerWidth:g,children:typeof d=="function"?d(l):b("div",{className:"flex flex-col gap-1",children:[n("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:l.label}),n("dl",{className:"grid grid-cols-[auto_auto] gap-x-3 gap-y-0.5",children:[[C.chartOpen,l.open],[C.chartHigh,l.high],[C.chartLow,l.low],[C.chartClose,l.close]].map(([e,i])=>b("div",{className:"contents",children:[n("dt",{className:"text-gray-500 dark:text-gray-400",children:e}),n("dd",{className:"justify-self-end font-medium text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:i===null?"\u2014":f(i)})]},e))}),l.change===null?null:b("div",{className:"flex items-center gap-2 border-t border-gray-200 pt-1 dark:border-gray-700",children:[n("span",{className:"text-gray-500 dark:text-gray-400",children:l.rising?C.chartRise:C.chartFall}),b("span",{className:"[font-variant-numeric:tabular-nums] font-semibold text-gray-900 dark:text-gray-100",children:[l.change>0?"+":"",f(l.change)]})]})]})}):null]})}function Ge({data:g,x:s,y:r,open:a,high:p,low:y,close:L,candleSize:I,fillRising:E=!1,colors:R,referenceLines:M,height:W=300,width:D,size:d="md",grid:Y="y",legend:f,tooltip:O=!0,tableView:P=!1,title:x,description:N,loading:u=!1,emptyState:C,error:t=!1,errorState:F,onRetry:U,actions:j,margin:l,locale:e,plotLabel:i,openLabel:h,highLabel:k,lowLabel:z,closeLabel:Z,riseLabel:G,fallLabel:w,format:q,onCandleClick:o,className:_,...T}){let m=re(),$=H(()=>r?.format??q??(c=>be(c,e)),[r?.format,q,e]),S=H(()=>s.format??(c=>pe(c,e)),[s.format,e]),A=H(()=>g.map((c,J)=>{let te=fe(c,s.key,J),V=B(c,a),X=B(c,L);return{index:J,x:te,label:S(te,J),open:V,high:B(c,p),low:B(c,y),close:X,change:V===null||X===null?null:X-V,rising:V===null||X===null?!0:X>=V,datum:c}}),[g,s.key,a,p,y,L,S]),v=H(()=>({up:R?.up??me,down:R?.down??ge}),[R]),K=H(()=>[{key:"up",label:G??m.chartRise,color:v.up,marker:"rect"},{key:"down",label:w??m.chartFall,color:v.down,marker:"rect"}],[v,G,w,m.chartRise,m.chartFall]),ae=f===void 0?!0:f!==!1,ee=typeof f=="string"?f:"bottom";return n(ie,{title:x,description:N,height:W,width:D,size:d,loading:u,empty:A.length===0,emptyState:C,error:t,errorState:F,onRetry:U,actions:j,tableView:P,legendPosition:ee,legend:ae?n(ue,{items:K,position:ee,marker:"rect",size:d}):void 0,table:P?n(he,{data:g,series:[{key:a,label:h??m.chartOpen},{key:p,label:k??m.chartHigh},{key:y,label:z??m.chartLow},{key:L,label:Z??m.chartClose}],xKey:s.key,xLabel:s.label??s.key,formatX:S,formatValue:$,caption:typeof x=="string"?x:void 0}):void 0,className:_,...T,children:({width:c})=>n(Le,{width:c,height:W,data:g,candles:A,x:s,y:r,grid:Y,size:d,candleSize:I,fillRising:E,palette:v,referenceLines:M,margin:l,tooltip:O,plotLabel:i,formatValue:$,formatX:S,onCandleClick:o})})}export{Ge as CandlestickChart};
@@ -1 +1 @@
1
- "use strict";"use client";var c=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var N=(e,t)=>{for(var r in t)c(e,r,{get:t[r],enumerable:!0})},X=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of P(t))!b.call(e,a)&&a!==r&&c(e,a,{get:()=>t[a],enumerable:!(o=V(t,a))||o.enumerable});return e};var D=e=>X(c({},"__esModule",{value:!0}),e);var O={};N(O,{ChartSyncProvider:()=>T,brushToPeriod:()=>k,useChartSync:()=>H});module.exports=D(O);var n=require("react"),h=require("./utils/period.cjs"),p=require("./utils/scales.cjs"),S=require("react/jsx-runtime"),B=(0,n.createContext)(null);function H(){return(0,n.useContext)(B)}function T({children:e,hover:t=!0,brush:r,defaultBrush:o=null,onBrushChange:a}){let[C,v]=(0,n.useState)(null),[x,g]=(0,n.useState)(o),s=r!==void 0,i=s?r:x,d=(0,n.useCallback)(u=>{if(!t)return;let y=l=>l===null?"\0":(0,p.toKey)(l);v(l=>y(l)===y(u)?l:u)},[t]),f=(0,n.useCallback)(u=>{s||g(u),a?.(u)},[s,a]),R=(0,n.useMemo)(()=>({hovered:t?C:null,brush:i??null,hoverShared:t,setHovered:d,setBrush:f}),[t,C,i,d,f]);return(0,S.jsx)(B.Provider,{value:R,children:e})}function k(e){let t=m(e.from),r=m(e.to);if(!t||!r)return null;let[o,a]=t<=r?[t,r]:[r,t];return{preset:"custom",from:(0,h.startOfDay)(o),to:(0,h.endOfDay)(a)}}function m(e){if(e instanceof Date)return Number.isNaN(e.getTime())?null:e;let t=new Date(e);return Number.isNaN(t.getTime())?null:t}0&&(module.exports={ChartSyncProvider,brushToPeriod,useChartSync});
1
+ "use strict";"use client";var c=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var D=(e,t)=>{for(var r in t)c(e,r,{get:t[r],enumerable:!0})},H=(e,t,r,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of X(t))!b.call(e,o)&&o!==r&&c(e,o,{get:()=>t[o],enumerable:!(l=g(t,o))||l.enumerable});return e};var k=e=>H(c({},"__esModule",{value:!0}),e);var w={};D(w,{ChartSyncProvider:()=>O,brushToPeriod:()=>T,useChartSync:()=>N});module.exports=k(w);var n=require("react"),h=require("./utils/period.cjs"),p=require("./utils/scales.cjs"),v=require("./utils/timestamp.cjs"),S=require("react/jsx-runtime"),B=(0,n.createContext)(null);function N(){return(0,n.useContext)(B)}function O({children:e,hover:t=!0,brush:r,defaultBrush:l=null,onBrushChange:o}){let[C,x]=(0,n.useState)(null),[R,V]=(0,n.useState)(l),s=r!==void 0,i=s?r:R,d=(0,n.useCallback)(a=>{if(!t)return;let y=u=>u===null?"\0":(0,p.toKey)(u);x(u=>y(u)===y(a)?u:a)},[t]),f=(0,n.useCallback)(a=>{s||V(a),o?.(a)},[s,o]),P=(0,n.useMemo)(()=>({hovered:t?C:null,brush:i??null,hoverShared:t,setHovered:d,setBrush:f}),[t,C,i,d,f]);return(0,S.jsx)(B.Provider,{value:P,children:e})}function T(e){let t=m(e.from),r=m(e.to);if(!t||!r)return null;let[l,o]=t<=r?[t,r]:[r,t];return{preset:"custom",from:(0,h.startOfDay)(l),to:(0,h.endOfDay)(o)}}function m(e){let t=(0,v.toTimestamp)(e);return t===null?null:new Date(t)}0&&(module.exports={ChartSyncProvider,brushToPeriod,useChartSync});
@@ -1 +1 @@
1
- "use client";import{createContext as x,useCallback as d,useContext as g,useMemo as R,useState as f}from"react";import{endOfDay as V,startOfDay as P}from"./utils/period.js";import{toKey as b}from"./utils/scales.js";import{jsx as N}from"react/jsx-runtime";var m=x(null);function T(){return g(m)}function k({children:e,hover:t=!0,brush:r,defaultBrush:u=null,onBrushChange:o}){let[h,p]=f(null),[B,S]=f(u),l=r!==void 0,s=l?r:B,c=d(n=>{if(!t)return;let i=a=>a===null?"\0":b(a);p(a=>i(a)===i(n)?a:n)},[t]),C=d(n=>{l||S(n),o?.(n)},[l,o]),v=R(()=>({hovered:t?h:null,brush:s??null,hoverShared:t,setHovered:c,setBrush:C}),[t,h,s,c,C]);return N(m.Provider,{value:v,children:e})}function O(e){let t=y(e.from),r=y(e.to);if(!t||!r)return null;let[u,o]=t<=r?[t,r]:[r,t];return{preset:"custom",from:P(u),to:V(o)}}function y(e){if(e instanceof Date)return Number.isNaN(e.getTime())?null:e;let t=new Date(e);return Number.isNaN(t.getTime())?null:t}export{k as ChartSyncProvider,O as brushToPeriod,T as useChartSync};
1
+ "use client";import{createContext as x,useCallback as d,useContext as R,useMemo as V,useState as f}from"react";import{endOfDay as P,startOfDay as g}from"./utils/period.js";import{toKey as X}from"./utils/scales.js";import{toTimestamp as b}from"./utils/timestamp.js";import{jsx as D}from"react/jsx-runtime";var m=x(null);function T(){return R(m)}function w({children:r,hover:t=!0,brush:e,defaultBrush:a=null,onBrushChange:l}){let[h,p]=f(null),[v,B]=f(a),u=e!==void 0,s=u?e:v,c=d(n=>{if(!t)return;let i=o=>o===null?"\0":X(o);p(o=>i(o)===i(n)?o:n)},[t]),C=d(n=>{u||B(n),l?.(n)},[u,l]),S=V(()=>({hovered:t?h:null,brush:s??null,hoverShared:t,setHovered:c,setBrush:C}),[t,h,s,c,C]);return D(m.Provider,{value:S,children:r})}function I(r){let t=y(r.from),e=y(r.to);if(!t||!e)return null;let[a,l]=t<=e?[t,e]:[e,t];return{preset:"custom",from:g(a),to:P(l)}}function y(r){let t=b(r);return t===null?null:new Date(t)}export{w as ChartSyncProvider,I as brushToPeriod,T as useChartSync};
@@ -1 +1 @@
1
- "use strict";var X=Object.defineProperty;var ee=Object.getOwnPropertyDescriptor;var te=Object.getOwnPropertyNames;var ne=Object.prototype.hasOwnProperty;var ae=(e,r)=>{for(var i in r)X(e,i,{get:r[i],enumerable:!0})},re=(e,r,i,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of te(r))!ne.call(e,n)&&n!==i&&X(e,n,{get:()=>r[n],enumerable:!(a=ee(r,n))||a.enumerable});return e};var ie=e=>re(X({},"__esModule",{value:!0}),e);var he={};ae(he,{AXIS_CAPTION_SPACE:()=>_,BASE_CHART_MARGIN:()=>L,buildCartesianGeometry:()=>le,createCategoryLocator:()=>Z,createPlotContext:()=>ce,splitOverlay:()=>ue});module.exports=ie(he);var W=require("./data.cjs"),c=require("./scales.cjs"),m=require("./text.cjs"),C=require("./ticks.cjs"),L={top:10,right:16,bottom:28,left:48},_=16,oe=14,se=32;function le({width:e,height:r,data:i,x:a,y:n,bounds:b,margin:d,orientation:g="vertical",placement:h="point",bandPaddingInner:B=.2,formatValue:w,formatX:G,extraTop:F=0,defaultIncludeZero:U=!1}){let o=g==="vertical",k=i.map((t,s)=>(0,W.readXValue)(t,a.key,s)),f=(0,C.resolveDomain)(b??[],{domain:n?.domain,includeZero:n?.includeZero??U,ticks:n?.ticks??5}),A=n?.hidden??!1,x=a.hidden??!1,I=A?[]:(0,C.niceTicks)(f[0],f[1],n?.ticks??5),Y=I.map(w),H=o&&(a.scale==="linear"||a.scale==="time"),y=k.map((t,s)=>G(t,s)),z=o?A:x,K=o?Y:y,j=o?n?.width:a.height,q=o?x:A,J=o?a.height:void 0,Q=o?a.label:n?.label,$=o?n?.label:a.label,O=o&&!x&&h!=="band"?y:[],R=t=>t?(0,m.estimateTextWidth)(t)/2+4:0,S={top:d?.top??L.top+F,right:d?.right??Math.max(L.right,R(O[O.length-1])),bottom:d?.bottom??(q?8:J??L.bottom+(Q?_:0)),left:d?.left??(z?8:j??Math.max(Math.max(se,(0,m.widestLabel)(K)+oe)+($?_:0),R(O[0])))},V=Math.max(0,e-S.left-S.right),M=Math.max(0,r-S.top-S.bottom),D=o?(0,c.createLinearScale)(f,[M,0]):(0,c.createLinearScale)(f,[0,V]),p=o?V:M,v,P=0,T,E=null;if(H){let t=k.map(c.toNumber),s=(0,C.extent)(t)??[0,1],l=(0,c.createLinearScale)(s,[0,p]);E=l,v=t.map(u=>l(u)),T=x?[]:(0,C.niceTicks)(s[0],s[1],a.ticks??5).map(u=>({value:u,offset:l(u),label:G(a.scale==="time"?new Date(u):u,0)}))}else if(h==="band"){let t=(0,c.createBandScale)(i.map((s,l)=>l),[0,p],{paddingInner:B});v=i.map((s,l)=>t(l)),P=t.bandwidth,T=[]}else{let t=i.length>1?p/(i.length-1):0;v=i.map((s,l)=>i.length>1?l*t:p/2),T=[]}let N=v.map(t=>t+P/2);if(!H&&!x){let t=o?(0,m.widestLabel)(y):m.AXIS_FONT_SIZE+4,s=(0,m.labelStride)(y.length,p,t);T=y.map((l,u)=>({value:k[u],offset:N[u],label:l})).filter((l,u)=>u%s===0)}return{margin:S,innerWidth:V,innerHeight:M,orientation:g,valueScale:D,domain:f,valueTicks:I.map(t=>({value:t,offset:D(t),label:w(t)})),xValues:k,categoryPositions:v,bandwidth:P,categoryCenters:N,categoryTicks:T,categoryLength:p,categoryScale:E}}function Z(e){let{categoryScale:r,xValues:i,categoryCenters:a,categoryLength:n}=e;return b=>{if(r){let h=r((0,c.toNumber)(b));return Number.isFinite(h)?h<-.5||h>n+.5?null:h:null}let d=(0,c.toKey)(b),g=i.findIndex(h=>(0,c.toKey)(h)===d);return g<0?null:a[g]}}function ce({geometry:e,width:r,height:i,data:a,series:n,formatValue:b,formatX:d}){return{dimensions:{width:r,height:i,innerWidth:e.innerWidth,innerHeight:e.innerHeight,margin:e.margin},orientation:e.orientation,xAt:Z(e),yAt:e.valueScale,categoryCenters:e.categoryCenters,bandwidth:e.bandwidth,xValues:e.xValues,domain:e.domain,data:a,series:n,formatValue:b,formatX:d}}function ue(e){return e?typeof e=="function"?{over:e}:e:{}}0&&(module.exports={AXIS_CAPTION_SPACE,BASE_CHART_MARGIN,buildCartesianGeometry,createCategoryLocator,createPlotContext,splitOverlay});
1
+ "use strict";var P=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var ae=Object.prototype.hasOwnProperty;var ie=(e,a)=>{for(var i in a)P(e,i,{get:a[i],enumerable:!0})},oe=(e,a,i,n)=>{if(a&&typeof a=="object"||typeof a=="function")for(let r of re(a))!ae.call(e,r)&&r!==i&&P(e,r,{get:()=>a[r],enumerable:!(n=ne(a,r))||n.enumerable});return e};var se=e=>oe(P({},"__esModule",{value:!0}),e);var Ce={};ie(Ce,{AXIS_CAPTION_SPACE:()=>_,BASE_CHART_MARGIN:()=>V,buildCartesianGeometry:()=>ue,createCategoryLocator:()=>U,createPlotContext:()=>he,splitOverlay:()=>de});module.exports=se(Ce);var B=require("./data.cjs"),m=require("./scales.cjs"),h=require("./text.cjs"),C=require("./ticks.cjs"),F=require("./timestamp.cjs");function le(e){return(0,F.toTimestamp)(e)??Number.NaN}var V={top:10,right:16,bottom:28,left:48},_=16,ce=14,me=32;function ue({width:e,height:a,data:i,x:n,y:r,bounds:g,margin:u,orientation:p="vertical",placement:f="point",bandPaddingInner:d=.2,formatValue:w,formatX:G,extraTop:Y=0,defaultIncludeZero:z=!1}){let o=p==="vertical",L=i.map((t,s)=>(0,B.readXValue)(t,n.key,s)),y=(0,C.resolveDomain)(g??[],{domain:r?.domain,includeZero:r?.includeZero??z,ticks:r?.ticks??5}),A=r?.hidden??!1,x=n.hidden??!1,I=A?[]:(0,C.niceTicks)(y[0],y[1],r?.ticks??5),K=I.map(w),H=o&&(n.scale==="linear"||n.scale==="time"),R=n.scale==="time"?le:m.toNumber,S=L.map((t,s)=>G(t,s)),j=o?A:x,q=o?K:S,J=o?r?.width:n.height,Q=o?x:A,$=o?n.height:void 0,ee=o?n.label:r?.label,te=o?r?.label:n.label,O=o&&!x&&f!=="band"?S:[],D=t=>t?(0,h.estimateTextWidth)(t)/2+4:0,v={top:u?.top??V.top+Y,right:u?.right??Math.max(V.right,D(O[O.length-1])),bottom:u?.bottom??(Q?8:$??V.bottom+(ee?_:0)),left:u?.left??(j?8:J??Math.max(Math.max(me,(0,h.widestLabel)(q)+ce)+(te?_:0),D(O[0])))},N=Math.max(0,e-v.left-v.right),X=Math.max(0,a-v.top-v.bottom),E=o?(0,m.createLinearScale)(y,[X,0]):(0,m.createLinearScale)(y,[0,N]),b=o?N:X,T,M=0,k,W=null;if(H){let t=L.map(R),s=(0,C.extent)(t)??[0,1],l=(0,m.createLinearScale)(s,[0,b]);W=l,T=t.map(c=>l(c)),k=x?[]:(0,C.niceTicks)(s[0],s[1],n.ticks??5).map(c=>({value:c,offset:l(c),label:G(n.scale==="time"?new Date(c):c,0)}))}else if(f==="band"){let t=(0,m.createBandScale)(i.map((s,l)=>l),[0,b],{paddingInner:d});T=i.map((s,l)=>t(l)),M=t.bandwidth,k=[]}else{let t=i.length>1?b/(i.length-1):0;T=i.map((s,l)=>i.length>1?l*t:b/2),k=[]}let Z=T.map(t=>t+M/2);if(!H&&!x){let t=o?(0,h.widestLabel)(S):h.AXIS_FONT_SIZE+4,s=(0,h.labelStride)(S.length,b,t);k=S.map((l,c)=>({value:L[c],offset:Z[c],label:l})).filter((l,c)=>c%s===0)}return{margin:v,innerWidth:N,innerHeight:X,orientation:p,valueScale:E,domain:y,valueTicks:I.map(t=>({value:t,offset:E(t),label:w(t)})),xValues:L,categoryPositions:T,bandwidth:M,categoryCenters:Z,categoryTicks:k,categoryLength:b,categoryScale:W,toCategoryNumber:R}}function U(e){let{categoryScale:a,xValues:i,categoryCenters:n,categoryLength:r,toCategoryNumber:g}=e;return u=>{if(a){let d=a(g(u));return Number.isFinite(d)?d<-.5||d>r+.5?null:d:null}let p=(0,m.toKey)(u),f=i.findIndex(d=>(0,m.toKey)(d)===p);return f<0?null:n[f]}}function he({geometry:e,width:a,height:i,data:n,series:r,formatValue:g,formatX:u}){return{dimensions:{width:a,height:i,innerWidth:e.innerWidth,innerHeight:e.innerHeight,margin:e.margin},orientation:e.orientation,xAt:U(e),yAt:e.valueScale,categoryCenters:e.categoryCenters,bandwidth:e.bandwidth,xValues:e.xValues,domain:e.domain,data:n,series:r,formatValue:g,formatX:u}}function de(e){return e?typeof e=="function"?{over:e}:e:{}}0&&(module.exports={AXIS_CAPTION_SPACE,BASE_CHART_MARGIN,buildCartesianGeometry,createCategoryLocator,createPlotContext,splitOverlay});
@@ -1 +1 @@
1
- import{readXValue as $}from"./data.js";import{createBandScale as ee,createLinearScale as O,toKey as R,toNumber as W}from"./scales.js";import{AXIS_FONT_SIZE as te,estimateTextWidth as ne,labelStride as ae,widestLabel as D}from"./text.js";import{extent as re,niceTicks as E,resolveDomain as ie}from"./ticks.js";var V={top:10,right:16,bottom:28,left:48},N=16,oe=14,se=32;function de({width:t,height:h,data:s,x:n,y:a,bounds:m,margin:u,orientation:d="vertical",placement:c="point",bandPaddingInner:Z=.2,formatValue:M,formatX:P,extraTop:B=0,defaultIncludeZero:F=!1}){let r=d==="vertical",S=s.map((e,i)=>$(e,n.key,i)),b=ie(m??[],{domain:a?.domain,includeZero:a?.includeZero??F,ticks:a?.ticks??5}),v=a?.hidden??!1,g=n.hidden??!1,X=v?[]:E(b[0],b[1],a?.ticks??5),U=X.map(M),_=r&&(n.scale==="linear"||n.scale==="time"),p=S.map((e,i)=>P(e,i)),Y=r?v:g,z=r?U:p,K=r?a?.width:n.height,j=r?g:v,q=r?n.height:void 0,J=r?n.label:a?.label,Q=r?a?.label:n.label,T=r&&!g&&c!=="band"?p:[],w=e=>e?ne(e)/2+4:0,f={top:u?.top??V.top+B,right:u?.right??Math.max(V.right,w(T[T.length-1])),bottom:u?.bottom??(j?8:q??V.bottom+(J?N:0)),left:u?.left??(Y?8:K??Math.max(Math.max(se,D(z)+oe)+(Q?N:0),w(T[0])))},k=Math.max(0,t-f.left-f.right),L=Math.max(0,h-f.top-f.bottom),G=r?O(b,[L,0]):O(b,[0,k]),C=r?k:L,x,A=0,y,I=null;if(_){let e=S.map(W),i=re(e)??[0,1],o=O(i,[0,C]);I=o,x=e.map(l=>o(l)),y=g?[]:E(i[0],i[1],n.ticks??5).map(l=>({value:l,offset:o(l),label:P(n.scale==="time"?new Date(l):l,0)}))}else if(c==="band"){let e=ee(s.map((i,o)=>o),[0,C],{paddingInner:Z});x=s.map((i,o)=>e(o)),A=e.bandwidth,y=[]}else{let e=s.length>1?C/(s.length-1):0;x=s.map((i,o)=>s.length>1?o*e:C/2),y=[]}let H=x.map(e=>e+A/2);if(!_&&!g){let e=r?D(p):te+4,i=ae(p.length,C,e);y=p.map((o,l)=>({value:S[l],offset:H[l],label:o})).filter((o,l)=>l%i===0)}return{margin:f,innerWidth:k,innerHeight:L,orientation:d,valueScale:G,domain:b,valueTicks:X.map(e=>({value:e,offset:G(e),label:M(e)})),xValues:S,categoryPositions:x,bandwidth:A,categoryCenters:H,categoryTicks:y,categoryLength:C,categoryScale:I}}function le(t){let{categoryScale:h,xValues:s,categoryCenters:n,categoryLength:a}=t;return m=>{if(h){let c=h(W(m));return Number.isFinite(c)?c<-.5||c>a+.5?null:c:null}let u=R(m),d=s.findIndex(c=>R(c)===u);return d<0?null:n[d]}}function Ce({geometry:t,width:h,height:s,data:n,series:a,formatValue:m,formatX:u}){return{dimensions:{width:h,height:s,innerWidth:t.innerWidth,innerHeight:t.innerHeight,margin:t.margin},orientation:t.orientation,xAt:le(t),yAt:t.valueScale,categoryCenters:t.categoryCenters,bandwidth:t.bandwidth,xValues:t.xValues,domain:t.domain,data:n,series:a,formatValue:m,formatX:u}}function be(t){return t?typeof t=="function"?{over:t}:t:{}}export{N as AXIS_CAPTION_SPACE,V as BASE_CHART_MARGIN,de as buildCartesianGeometry,le as createCategoryLocator,Ce as createPlotContext,be as splitOverlay};
1
+ import{readXValue as $}from"./data.js";import{createBandScale as ee,createLinearScale as O,toKey as D,toNumber as te}from"./scales.js";import{AXIS_FONT_SIZE as ne,estimateTextWidth as re,labelStride as ae,widestLabel as E}from"./text.js";import{extent as ie,niceTicks as W,resolveDomain as oe}from"./ticks.js";import{toTimestamp as se}from"./timestamp.js";function le(t){return se(t)??Number.NaN}var N={top:10,right:16,bottom:28,left:48},Z=16,ce=14,me=32;function pe({width:t,height:u,data:s,x:n,y:r,bounds:d,margin:c,orientation:C="vertical",placement:b="point",bandPaddingInner:m=.2,formatValue:X,formatX:M,extraTop:B=0,defaultIncludeZero:F=!1}){let a=C==="vertical",v=s.map((e,i)=>$(e,n.key,i)),g=oe(d??[],{domain:r?.domain,includeZero:r?.includeZero??F,ticks:r?.ticks??5}),T=r?.hidden??!1,p=n.hidden??!1,P=T?[]:W(g[0],g[1],r?.ticks??5),U=P.map(X),_=a&&(n.scale==="linear"||n.scale==="time"),w=n.scale==="time"?le:te,f=v.map((e,i)=>M(e,i)),Y=a?T:p,z=a?U:f,K=a?r?.width:n.height,j=a?p:T,q=a?n.height:void 0,J=a?n.label:r?.label,Q=a?r?.label:n.label,k=a&&!p&&b!=="band"?f:[],G=e=>e?re(e)/2+4:0,y={top:c?.top??N.top+B,right:c?.right??Math.max(N.right,G(k[k.length-1])),bottom:c?.bottom??(j?8:q??N.bottom+(J?Z:0)),left:c?.left??(Y?8:K??Math.max(Math.max(me,E(z)+ce)+(Q?Z:0),G(k[0])))},L=Math.max(0,t-y.left-y.right),V=Math.max(0,u-y.top-y.bottom),I=a?O(g,[V,0]):O(g,[0,L]),h=a?L:V,x,A=0,S,H=null;if(_){let e=v.map(w),i=ie(e)??[0,1],o=O(i,[0,h]);H=o,x=e.map(l=>o(l)),S=p?[]:W(i[0],i[1],n.ticks??5).map(l=>({value:l,offset:o(l),label:M(n.scale==="time"?new Date(l):l,0)}))}else if(b==="band"){let e=ee(s.map((i,o)=>o),[0,h],{paddingInner:m});x=s.map((i,o)=>e(o)),A=e.bandwidth,S=[]}else{let e=s.length>1?h/(s.length-1):0;x=s.map((i,o)=>s.length>1?o*e:h/2),S=[]}let R=x.map(e=>e+A/2);if(!_&&!p){let e=a?E(f):ne+4,i=ae(f.length,h,e);S=f.map((o,l)=>({value:v[l],offset:R[l],label:o})).filter((o,l)=>l%i===0)}return{margin:y,innerWidth:L,innerHeight:V,orientation:C,valueScale:I,domain:g,valueTicks:P.map(e=>({value:e,offset:I(e),label:X(e)})),xValues:v,categoryPositions:x,bandwidth:A,categoryCenters:R,categoryTicks:S,categoryLength:h,categoryScale:H,toCategoryNumber:w}}function ue(t){let{categoryScale:u,xValues:s,categoryCenters:n,categoryLength:r,toCategoryNumber:d}=t;return c=>{if(u){let m=u(d(c));return Number.isFinite(m)?m<-.5||m>r+.5?null:m:null}let C=D(c),b=s.findIndex(m=>D(m)===C);return b<0?null:n[b]}}function fe({geometry:t,width:u,height:s,data:n,series:r,formatValue:d,formatX:c}){return{dimensions:{width:u,height:s,innerWidth:t.innerWidth,innerHeight:t.innerHeight,margin:t.margin},orientation:t.orientation,xAt:ue(t),yAt:t.valueScale,categoryCenters:t.categoryCenters,bandwidth:t.bandwidth,xValues:t.xValues,domain:t.domain,data:n,series:r,formatValue:d,formatX:c}}function ye(t){return t?typeof t=="function"?{over:t}:t:{}}export{Z as AXIS_CAPTION_SPACE,N as BASE_CHART_MARGIN,pe as buildCartesianGeometry,ue as createCategoryLocator,fe as createPlotContext,ye as splitOverlay};
@@ -1 +1 @@
1
- "use strict";var L=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var N=(n,r)=>{for(var a in r)L(n,a,{get:r[a],enumerable:!0})},S=(n,r,a,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of C(r))!Q.call(n,s)&&s!==a&&L(n,s,{get:()=>r[s],enumerable:!(t=B(r,s))||t.enumerable});return n};var E=n=>S(L({},"__esModule",{value:!0}),n);var T={};N(T,{buildArcPath:()=>O,buildAreaPath:()=>w,buildBarPath:()=>F,buildLinePath:()=>v,splitSegments:()=>y});module.exports=E(T);function f(n){return Math.round(n*100)/100}function A(n){return n.defined!==!1&&Number.isFinite(n.x)&&Number.isFinite(n.y)}function y(n,r=!1){if(r){let s=n.filter(A);return s.length>0?[s]:[]}let a=[],t=[];for(let s of n)A(s)?t.push(s):t.length>0&&(a.push(t),t=[]);return t.length>0&&a.push(t),a}function I(n){let r=n.length,a=[],t=[];for(let $=0;$<r-1;$+=1){let e=n[$+1].x-n[$].x;a.push(e),t.push(e===0?0:(n[$+1].y-n[$].y)/e)}let s=new Array(r);s[0]=t[0],s[r-1]=t[r-2];for(let $=1;$<r-1;$+=1){let e=t[$-1],i=t[$];if(e*i<=0)s[$]=0;else{let o=2*a[$]+a[$-1],c=a[$]+2*a[$-1];s[$]=(o+c)/(o/e+c/i)}}return s}function p(n,r){if(n.length<2)return"";if(r==="monotone"&&n.length>2){let t=I(n),s="";for(let $=0;$<n.length-1;$+=1){let e=n[$],i=n[$+1],o=(i.x-e.x)/3;s+=` C${f(e.x+o)},${f(e.y+t[$]*o)} ${f(i.x-o)},${f(i.y-t[$+1]*o)} ${f(i.x)},${f(i.y)}`}return s}let a="";for(let t=1;t<n.length;t+=1){let s=n[t-1],$=n[t];if(r==="step"){let e=f((s.x+$.x)/2);a+=` L${e},${f(s.y)} L${e},${f($.y)}`}else r==="stepAfter"&&(a+=` L${f($.x)},${f(s.y)}`);a+=` L${f($.x)},${f($.y)}`}return a}function v(n,r="linear",a={}){return y(n,a.connectNulls).map(t=>{let[s]=t;return`M${f(s.x)},${f(s.y)}${p(t,r)}`}).join(" ")}function w(n,r,a="linear",t={}){let s=y(n,t.connectNulls);if(s.length===0)return"";let $=typeof r=="number"?null:new Map(r.map(e=>[f(e.x),e]));return s.map(e=>{let[i]=e,o=e[e.length-1],c=`M${f(i.x)},${f(i.y)}${p(e,a)}`;if($===null){let m=f(r);return`${c} L${f(o.x)},${m} L${f(i.x)},${m} Z`}let l=e.map(m=>$.get(f(m.x))).filter(m=>m!==void 0).reverse();if(l.length===0)return`${c} Z`;let[h]=l;return`${c} L${f(h.x)},${f(h.y)}${p(l,a)} Z`}).join(" ")}function F({x:n,y:r,width:a,height:t,radius:s=4,round:$="none"}){if(!(a>0)||!(t>0))return"";let e=Math.max(0,Math.min(s,a/2,t/2)),[i,o]=[u(n),u(r)],[c,l]=[u(n+a),u(r+t)];if(e===0||$==="none")return`M${i},${o} L${c},${o} L${c},${l} L${i},${l} Z`;switch($){case"top":return`M${i},${l} L${i},${u(r+e)} Q${i},${o} ${u(n+e)},${o} L${u(n+a-e)},${o} Q${c},${o} ${c},${u(r+e)} L${c},${l} Z`;case"bottom":return`M${i},${o} L${c},${o} L${c},${u(r+t-e)} Q${c},${l} ${u(n+a-e)},${l} L${u(n+e)},${l} Q${i},${l} ${i},${u(r+t-e)} Z`;case"right":return`M${i},${o} L${u(n+a-e)},${o} Q${c},${o} ${c},${u(r+e)} L${c},${u(r+t-e)} Q${c},${l} ${u(n+a-e)},${l} L${i},${l} Z`;case"left":return`M${c},${o} L${u(n+e)},${o} Q${i},${o} ${i},${u(r+e)} L${i},${u(r+t-e)} Q${i},${l} ${u(n+e)},${l} L${c},${l} Z`;default:return`M${i},${o} L${c},${o} L${c},${l} L${i},${l} Z`}}function u(n){return Math.round(n*100)/100}function b(n,r,a,t){return{x:u(n+a*Math.sin(t)),y:u(r-a*Math.cos(t))}}function O({cx:n,cy:r,innerRadius:a,outerRadius:t,startAngle:s,endAngle:$}){let e=$-s;if(!(t>0)||!(e>0))return"";let i=e>=Math.PI*2-1e-9,o=Math.max(0,Math.min(a,t));if(i){let P=b(n,r,t,0),d=b(n,r,t,Math.PI),g=`M${P.x},${P.y} A${u(t)},${u(t)} 0 1 1 ${d.x},${d.y} A${u(t)},${u(t)} 0 1 1 ${P.x},${P.y} Z`;if(o===0)return g;let x=b(n,r,o,0),Z=b(n,r,o,Math.PI);return`${g} M${x.x},${x.y} A${u(o)},${u(o)} 0 1 0 ${Z.x},${Z.y} A${u(o)},${u(o)} 0 1 0 ${x.x},${x.y} Z`}let c=e>Math.PI?1:0,l=b(n,r,t,s),h=b(n,r,t,$);if(o===0)return`M${u(n)},${u(r)} L${l.x},${l.y} A${u(t)},${u(t)} 0 ${c} 1 ${h.x},${h.y} Z`;let m=b(n,r,o,$),M=b(n,r,o,s);return`M${l.x},${l.y} A${u(t)},${u(t)} 0 ${c} 1 ${h.x},${h.y} L${m.x},${m.y} A${u(o)},${u(o)} 0 ${c} 0 ${M.x},${M.y} Z`}0&&(module.exports={buildArcPath,buildAreaPath,buildBarPath,buildLinePath,splitSegments});
1
+ "use strict";var y=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var N=(n,t)=>{for(var o in t)y(n,o,{get:t[o],enumerable:!0})},S=(n,t,o,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of C(t))!Q.call(n,a)&&a!==o&&y(n,a,{get:()=>t[a],enumerable:!(e=B(t,a))||e.enumerable});return n};var E=n=>S(y({},"__esModule",{value:!0}),n);var j={};N(j,{buildArcPath:()=>T,buildAreaPath:()=>F,buildBarPath:()=>O,buildLinePath:()=>w,isDrawable:()=>L,isolatedPoints:()=>I,splitSegments:()=>p});module.exports=E(j);function c(n){return Math.round(n*100)/100}function L(n){return n.defined!==!1&&Number.isFinite(n.x)&&Number.isFinite(n.y)}function p(n,t=!1){if(t){let a=n.filter(L);return a.length>0?[a]:[]}let o=[],e=[];for(let a of n)L(a)?e.push(a):e.length>0&&(o.push(e),e=[]);return e.length>0&&o.push(e),o}function I(n,t=!1){return p(n,t).filter(o=>o.length===1).map(([o])=>o)}function v(n){let t=n.length,o=[],e=[];for(let s=0;s<t-1;s+=1){let r=n[s+1].x-n[s].x;o.push(r),e.push(r===0?0:(n[s+1].y-n[s].y)/r)}let a=new Array(t);a[0]=e[0],a[t-1]=e[t-2];for(let s=1;s<t-1;s+=1){let r=e[s-1],i=e[s];if(r*i<=0)a[s]=0;else{let $=2*o[s]+o[s-1],l=o[s]+2*o[s-1];a[s]=($+l)/($/r+l/i)}}return a}function d(n,t,o=!1){if(n.length<2)return"";if(t==="monotone"&&n.length>2){let a=v(n),s="";for(let r=0;r<n.length-1;r+=1){let i=n[r],$=n[r+1],l=($.x-i.x)/3;s+=` C${c(i.x+l)},${c(i.y+a[r]*l)} ${c($.x-l)},${c($.y-a[r+1]*l)} ${c($.x)},${c($.y)}`}return s}let e="";for(let a=1;a<n.length;a+=1){let s=n[a-1],r=n[a];if(t==="step"){let i=c((s.x+r.x)/2);e+=` L${i},${c(s.y)} L${i},${c(r.y)}`}else t==="stepAfter"&&(e+=o?` L${c(s.x)},${c(r.y)}`:` L${c(r.x)},${c(s.y)}`);e+=` L${c(r.x)},${c(r.y)}`}return e}function w(n,t="linear",o={}){return p(n,o.connectNulls).map(e=>{let[a]=e;return`M${c(a.x)},${c(a.y)}${d(e,t)}`}).join(" ")}function F(n,t,o="linear",e={}){let a=p(n,e.connectNulls);if(a.length===0)return"";let s=typeof t=="number"?null:new Map(t.map(r=>[c(r.x),r]));return a.map(r=>{let[i]=r,$=r[r.length-1],l=`M${c(i.x)},${c(i.y)}${d(r,o)}`;if(s===null){let m=c(t);return`${l} L${c($.x)},${m} L${c(i.x)},${m} Z`}let f=r.map(m=>s.get(c(m.x))).filter(m=>m!==void 0).reverse();if(f.length===0)return`${l} Z`;let[b]=f;return`${l} L${c(b.x)},${c(b.y)}${d(f,o,!0)} Z`}).join(" ")}function O({x:n,y:t,width:o,height:e,radius:a=4,round:s="none"}){if(!(o>0)||!(e>0))return"";let r=Math.max(0,Math.min(a,o/2,e/2)),[i,$]=[u(n),u(t)],[l,f]=[u(n+o),u(t+e)];if(r===0||s==="none")return`M${i},${$} L${l},${$} L${l},${f} L${i},${f} Z`;switch(s){case"top":return`M${i},${f} L${i},${u(t+r)} Q${i},${$} ${u(n+r)},${$} L${u(n+o-r)},${$} Q${l},${$} ${l},${u(t+r)} L${l},${f} Z`;case"bottom":return`M${i},${$} L${l},${$} L${l},${u(t+e-r)} Q${l},${f} ${u(n+o-r)},${f} L${u(n+r)},${f} Q${i},${f} ${i},${u(t+e-r)} Z`;case"right":return`M${i},${$} L${u(n+o-r)},${$} Q${l},${$} ${l},${u(t+r)} L${l},${u(t+e-r)} Q${l},${f} ${u(n+o-r)},${f} L${i},${f} Z`;case"left":return`M${l},${$} L${u(n+r)},${$} Q${i},${$} ${i},${u(t+r)} L${i},${u(t+e-r)} Q${i},${f} ${u(n+r)},${f} L${l},${f} Z`;default:return`M${i},${$} L${l},${$} L${l},${f} L${i},${f} Z`}}function u(n){return Math.round(n*100)/100}function h(n,t,o,e){return{x:u(n+o*Math.sin(e)),y:u(t-o*Math.cos(e))}}function T({cx:n,cy:t,innerRadius:o,outerRadius:e,startAngle:a,endAngle:s}){let r=s-a;if(!(e>0)||!(r>0))return"";let i=r>=Math.PI*2-1e-9,$=Math.max(0,Math.min(o,e));if(i){let P=h(n,t,e,0),g=h(n,t,e,Math.PI),Z=`M${P.x},${P.y} A${u(e)},${u(e)} 0 1 1 ${g.x},${g.y} A${u(e)},${u(e)} 0 1 1 ${P.x},${P.y} Z`;if($===0)return Z;let x=h(n,t,$,0),A=h(n,t,$,Math.PI);return`${Z} M${x.x},${x.y} A${u($)},${u($)} 0 1 0 ${A.x},${A.y} A${u($)},${u($)} 0 1 0 ${x.x},${x.y} Z`}let l=r>Math.PI?1:0,f=h(n,t,e,a),b=h(n,t,e,s);if($===0)return`M${u(n)},${u(t)} L${f.x},${f.y} A${u(e)},${u(e)} 0 ${l} 1 ${b.x},${b.y} Z`;let m=h(n,t,$,s),M=h(n,t,$,a);return`M${f.x},${f.y} A${u(e)},${u(e)} 0 ${l} 1 ${b.x},${b.y} L${m.x},${m.y} A${u($)},${u($)} 0 ${l} 0 ${M.x},${M.y} Z`}0&&(module.exports={buildArcPath,buildAreaPath,buildBarPath,buildLinePath,isDrawable,isolatedPoints,splitSegments});
@@ -1 +1 @@
1
- function f(n){return Math.round(n*100)/100}function g(n){return n.defined!==!1&&Number.isFinite(n.x)&&Number.isFinite(n.y)}function Z(n,e=!1){if(e){let i=n.filter(g);return i.length>0?[i]:[]}let a=[],t=[];for(let i of n)g(i)?t.push(i):t.length>0&&(a.push(t),t=[]);return t.length>0&&a.push(t),a}function A(n){let e=n.length,a=[],t=[];for(let $=0;$<e-1;$+=1){let r=n[$+1].x-n[$].x;a.push(r),t.push(r===0?0:(n[$+1].y-n[$].y)/r)}let i=new Array(e);i[0]=t[0],i[e-1]=t[e-2];for(let $=1;$<e-1;$+=1){let r=t[$-1],s=t[$];if(r*s<=0)i[$]=0;else{let o=2*a[$]+a[$-1],c=a[$]+2*a[$-1];i[$]=(o+c)/(o/r+c/s)}}return i}function L(n,e){if(n.length<2)return"";if(e==="monotone"&&n.length>2){let t=A(n),i="";for(let $=0;$<n.length-1;$+=1){let r=n[$],s=n[$+1],o=(s.x-r.x)/3;i+=` C${f(r.x+o)},${f(r.y+t[$]*o)} ${f(s.x-o)},${f(s.y-t[$+1]*o)} ${f(s.x)},${f(s.y)}`}return i}let a="";for(let t=1;t<n.length;t+=1){let i=n[t-1],$=n[t];if(e==="step"){let r=f((i.x+$.x)/2);a+=` L${r},${f(i.y)} L${r},${f($.y)}`}else e==="stepAfter"&&(a+=` L${f($.x)},${f(i.y)}`);a+=` L${f($.x)},${f($.y)}`}return a}function B(n,e="linear",a={}){return Z(n,a.connectNulls).map(t=>{let[i]=t;return`M${f(i.x)},${f(i.y)}${L(t,e)}`}).join(" ")}function C(n,e,a="linear",t={}){let i=Z(n,t.connectNulls);if(i.length===0)return"";let $=typeof e=="number"?null:new Map(e.map(r=>[f(r.x),r]));return i.map(r=>{let[s]=r,o=r[r.length-1],c=`M${f(s.x)},${f(s.y)}${L(r,a)}`;if($===null){let m=f(e);return`${c} L${f(o.x)},${m} L${f(s.x)},${m} Z`}let l=r.map(m=>$.get(f(m.x))).filter(m=>m!==void 0).reverse();if(l.length===0)return`${c} Z`;let[h]=l;return`${c} L${f(h.x)},${f(h.y)}${L(l,a)} Z`}).join(" ")}function Q({x:n,y:e,width:a,height:t,radius:i=4,round:$="none"}){if(!(a>0)||!(t>0))return"";let r=Math.max(0,Math.min(i,a/2,t/2)),[s,o]=[u(n),u(e)],[c,l]=[u(n+a),u(e+t)];if(r===0||$==="none")return`M${s},${o} L${c},${o} L${c},${l} L${s},${l} Z`;switch($){case"top":return`M${s},${l} L${s},${u(e+r)} Q${s},${o} ${u(n+r)},${o} L${u(n+a-r)},${o} Q${c},${o} ${c},${u(e+r)} L${c},${l} Z`;case"bottom":return`M${s},${o} L${c},${o} L${c},${u(e+t-r)} Q${c},${l} ${u(n+a-r)},${l} L${u(n+r)},${l} Q${s},${l} ${s},${u(e+t-r)} Z`;case"right":return`M${s},${o} L${u(n+a-r)},${o} Q${c},${o} ${c},${u(e+r)} L${c},${u(e+t-r)} Q${c},${l} ${u(n+a-r)},${l} L${s},${l} Z`;case"left":return`M${c},${o} L${u(n+r)},${o} Q${s},${o} ${s},${u(e+r)} L${s},${u(e+t-r)} Q${s},${l} ${u(n+r)},${l} L${c},${l} Z`;default:return`M${s},${o} L${c},${o} L${c},${l} L${s},${l} Z`}}function u(n){return Math.round(n*100)/100}function b(n,e,a,t){return{x:u(n+a*Math.sin(t)),y:u(e-a*Math.cos(t))}}function N({cx:n,cy:e,innerRadius:a,outerRadius:t,startAngle:i,endAngle:$}){let r=$-i;if(!(t>0)||!(r>0))return"";let s=r>=Math.PI*2-1e-9,o=Math.max(0,Math.min(a,t));if(s){let P=b(n,e,t,0),y=b(n,e,t,Math.PI),M=`M${P.x},${P.y} A${u(t)},${u(t)} 0 1 1 ${y.x},${y.y} A${u(t)},${u(t)} 0 1 1 ${P.x},${P.y} Z`;if(o===0)return M;let x=b(n,e,o,0),d=b(n,e,o,Math.PI);return`${M} M${x.x},${x.y} A${u(o)},${u(o)} 0 1 0 ${d.x},${d.y} A${u(o)},${u(o)} 0 1 0 ${x.x},${x.y} Z`}let c=r>Math.PI?1:0,l=b(n,e,t,i),h=b(n,e,t,$);if(o===0)return`M${u(n)},${u(e)} L${l.x},${l.y} A${u(t)},${u(t)} 0 ${c} 1 ${h.x},${h.y} Z`;let m=b(n,e,o,$),p=b(n,e,o,i);return`M${l.x},${l.y} A${u(t)},${u(t)} 0 ${c} 1 ${h.x},${h.y} L${m.x},${m.y} A${u(o)},${u(o)} 0 ${c} 0 ${p.x},${p.y} Z`}export{N as buildArcPath,C as buildAreaPath,Q as buildBarPath,B as buildLinePath,Z as splitSegments};
1
+ function c(n){return Math.round(n*100)/100}function Z(n){return n.defined!==!1&&Number.isFinite(n.x)&&Number.isFinite(n.y)}function y(n,r=!1){if(r){let l=n.filter(Z);return l.length>0?[l]:[]}let a=[],e=[];for(let l of n)Z(l)?e.push(l):e.length>0&&(a.push(e),e=[]);return e.length>0&&a.push(e),a}function B(n,r=!1){return y(n,r).filter(a=>a.length===1).map(([a])=>a)}function A(n){let r=n.length,a=[],e=[];for(let u=0;u<r-1;u+=1){let t=n[u+1].x-n[u].x;a.push(t),e.push(t===0?0:(n[u+1].y-n[u].y)/t)}let l=new Array(r);l[0]=e[0],l[r-1]=e[r-2];for(let u=1;u<r-1;u+=1){let t=e[u-1],s=e[u];if(t*s<=0)l[u]=0;else{let $=2*a[u]+a[u-1],i=a[u]+2*a[u-1];l[u]=($+i)/($/t+i/s)}}return l}function p(n,r,a=!1){if(n.length<2)return"";if(r==="monotone"&&n.length>2){let l=A(n),u="";for(let t=0;t<n.length-1;t+=1){let s=n[t],$=n[t+1],i=($.x-s.x)/3;u+=` C${c(s.x+i)},${c(s.y+l[t]*i)} ${c($.x-i)},${c($.y-l[t+1]*i)} ${c($.x)},${c($.y)}`}return u}let e="";for(let l=1;l<n.length;l+=1){let u=n[l-1],t=n[l];if(r==="step"){let s=c((u.x+t.x)/2);e+=` L${s},${c(u.y)} L${s},${c(t.y)}`}else r==="stepAfter"&&(e+=a?` L${c(u.x)},${c(t.y)}`:` L${c(t.x)},${c(u.y)}`);e+=` L${c(t.x)},${c(t.y)}`}return e}function C(n,r="linear",a={}){return y(n,a.connectNulls).map(e=>{let[l]=e;return`M${c(l.x)},${c(l.y)}${p(e,r)}`}).join(" ")}function Q(n,r,a="linear",e={}){let l=y(n,e.connectNulls);if(l.length===0)return"";let u=typeof r=="number"?null:new Map(r.map(t=>[c(t.x),t]));return l.map(t=>{let[s]=t,$=t[t.length-1],i=`M${c(s.x)},${c(s.y)}${p(t,a)}`;if(u===null){let m=c(r);return`${i} L${c($.x)},${m} L${c(s.x)},${m} Z`}let f=t.map(m=>u.get(c(m.x))).filter(m=>m!==void 0).reverse();if(f.length===0)return`${i} Z`;let[b]=f;return`${i} L${c(b.x)},${c(b.y)}${p(f,a,!0)} Z`}).join(" ")}function N({x:n,y:r,width:a,height:e,radius:l=4,round:u="none"}){if(!(a>0)||!(e>0))return"";let t=Math.max(0,Math.min(l,a/2,e/2)),[s,$]=[o(n),o(r)],[i,f]=[o(n+a),o(r+e)];if(t===0||u==="none")return`M${s},${$} L${i},${$} L${i},${f} L${s},${f} Z`;switch(u){case"top":return`M${s},${f} L${s},${o(r+t)} Q${s},${$} ${o(n+t)},${$} L${o(n+a-t)},${$} Q${i},${$} ${i},${o(r+t)} L${i},${f} Z`;case"bottom":return`M${s},${$} L${i},${$} L${i},${o(r+e-t)} Q${i},${f} ${o(n+a-t)},${f} L${o(n+t)},${f} Q${s},${f} ${s},${o(r+e-t)} Z`;case"right":return`M${s},${$} L${o(n+a-t)},${$} Q${i},${$} ${i},${o(r+t)} L${i},${o(r+e-t)} Q${i},${f} ${o(n+a-t)},${f} L${s},${f} Z`;case"left":return`M${i},${$} L${o(n+t)},${$} Q${s},${$} ${s},${o(r+t)} L${s},${o(r+e-t)} Q${s},${f} ${o(n+t)},${f} L${i},${f} Z`;default:return`M${s},${$} L${i},${$} L${i},${f} L${s},${f} Z`}}function o(n){return Math.round(n*100)/100}function h(n,r,a,e){return{x:o(n+a*Math.sin(e)),y:o(r-a*Math.cos(e))}}function S({cx:n,cy:r,innerRadius:a,outerRadius:e,startAngle:l,endAngle:u}){let t=u-l;if(!(e>0)||!(t>0))return"";let s=t>=Math.PI*2-1e-9,$=Math.max(0,Math.min(a,e));if(s){let P=h(n,r,e,0),d=h(n,r,e,Math.PI),M=`M${P.x},${P.y} A${o(e)},${o(e)} 0 1 1 ${d.x},${d.y} A${o(e)},${o(e)} 0 1 1 ${P.x},${P.y} Z`;if($===0)return M;let x=h(n,r,$,0),g=h(n,r,$,Math.PI);return`${M} M${x.x},${x.y} A${o($)},${o($)} 0 1 0 ${g.x},${g.y} A${o($)},${o($)} 0 1 0 ${x.x},${x.y} Z`}let i=t>Math.PI?1:0,f=h(n,r,e,l),b=h(n,r,e,u);if($===0)return`M${o(n)},${o(r)} L${f.x},${f.y} A${o(e)},${o(e)} 0 ${i} 1 ${b.x},${b.y} Z`;let m=h(n,r,$,u),L=h(n,r,$,l);return`M${f.x},${f.y} A${o(e)},${o(e)} 0 ${i} 1 ${b.x},${b.y} L${m.x},${m.y} A${o($)},${o($)} 0 ${i} 0 ${L.x},${L.y} Z`}export{S as buildArcPath,Q as buildAreaPath,N as buildBarPath,C as buildLinePath,Z as isDrawable,B as isolatedPoints,y as splitSegments};
@@ -1 +1 @@
1
- "use strict";var o=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var d=(n,s)=>{for(var e in s)o(n,e,{get:s[e],enumerable:!0})},g=(n,s,e,t)=>{if(s&&typeof s=="object"||typeof s=="function")for(let u of D(s))!T.call(n,u)&&u!==e&&o(n,u,{get:()=>s[u],enumerable:!(t=h(s,u))||t.enumerable});return n};var f=n=>g(o({},"__esModule",{value:!0}),n);var b={};d(b,{formatTimeTick:()=>y,niceTimeTicks:()=>M,toTimestamp:()=>w});module.exports=f(b);var m=[{unit:"second",step:1,span:1e3},{unit:"second",step:5,span:5e3},{unit:"second",step:15,span:15e3},{unit:"second",step:30,span:3e4},{unit:"minute",step:1,span:6e4},{unit:"minute",step:5,span:3e5},{unit:"minute",step:15,span:9e5},{unit:"minute",step:30,span:18e5},{unit:"hour",step:1,span:36e5},{unit:"hour",step:3,span:108e5},{unit:"hour",step:6,span:216e5},{unit:"hour",step:12,span:432e5},{unit:"day",step:1,span:864e5},{unit:"day",step:2,span:1728e5},{unit:"week",step:1,span:6048e5},{unit:"week",step:2,span:12096e5},{unit:"month",step:1,span:2592e6},{unit:"month",step:3,span:78624e5},{unit:"month",step:6,span:157248e5},{unit:"year",step:1,span:31536e6},{unit:"year",step:2,span:63072e6},{unit:"year",step:5,span:1577664e5},{unit:"year",step:10,span:3155328e5}];function l(n,s,e){let t=new Date(n.getTime());switch(s){case"year":return t.setMonth(0,1),t.setHours(0,0,0,0),t.setFullYear(Math.floor(t.getFullYear()/e)*e),t;case"month":return t.setDate(1),t.setHours(0,0,0,0),t.setMonth(Math.floor(t.getMonth()/e)*e),t;case"week":return t.setHours(0,0,0,0),t.setDate(t.getDate()-(t.getDay()+6)%7),t;case"day":return t.setHours(0,0,0,0),t;case"hour":return t.setMinutes(0,0,0),t.setHours(Math.floor(t.getHours()/e)*e),t;case"minute":return t.setSeconds(0,0),t.setMinutes(Math.floor(t.getMinutes()/e)*e),t;default:return t.setMilliseconds(0),t.setSeconds(Math.floor(t.getSeconds()/e)*e),t}}function c(n,s,e){let t=new Date(n.getTime());switch(s){case"year":return t.setFullYear(t.getFullYear()+e),t;case"month":return t.setMonth(t.getMonth()+e),t;case"week":return t.setDate(t.getDate()+e*7),t;case"day":return t.setDate(t.getDate()+e),t;case"hour":return t.setHours(t.getHours()+e),t;case"minute":return t.setMinutes(t.getMinutes()+e),t;default:return t.setSeconds(t.getSeconds()+e),t}}function M(n,s,e=6){if(!Number.isFinite(n)||!Number.isFinite(s))return{values:[],unit:"day",step:1};n>s&&([n,s]=[s,n]);let t=Math.max(1,e),u=(s-n)/t,r=m.find(p=>p.span>=u)??m[m.length-1],a=[],i=l(new Date(n),r.unit,r.step);for(;i.getTime()<n;)i=c(i,r.unit,r.step);for(;i.getTime()<=s&&a.length<=500;)a.push(i.getTime()),i=c(i,r.unit,r.step);return{values:a,unit:r.unit,step:r.step}}function y(n,s,e){let t=new Date(n);switch(s){case"year":return new Intl.DateTimeFormat(e,{year:"numeric"}).format(t);case"month":return new Intl.DateTimeFormat(e,{month:"short",year:"2-digit"}).format(t);case"week":case"day":return new Intl.DateTimeFormat(e,{day:"numeric",month:"short"}).format(t);case"hour":return new Intl.DateTimeFormat(e,{hour:"2-digit",minute:"2-digit"}).format(t);default:return new Intl.DateTimeFormat(e,{minute:"2-digit",second:"2-digit"}).format(t)}}function w(n){if(n instanceof Date){let s=n.getTime();return Number.isFinite(s)?s:null}if(typeof n=="number")return Number.isFinite(n)?n:null;if(typeof n=="string"&&n!==""){let s=Date.parse(n);if(Number.isFinite(s))return s;let e=Number(n);return Number.isFinite(e)?e:null}return null}0&&(module.exports={formatTimeTick,niceTimeTicks,toTimestamp});
1
+ "use strict";var h=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var M=(s,n)=>{for(var t in n)h(s,t,{get:n[t],enumerable:!0})},b=(s,n,t,e)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of w(n))!y.call(s,a)&&a!==t&&h(s,a,{get:()=>n[a],enumerable:!(e=D(n,a))||e.enumerable});return s};var F=s=>b(h({},"__esModule",{value:!0}),s);var U={};M(U,{formatTimeTick:()=>H,niceTimeTicks:()=>S,toTimestamp:()=>T.toTimestamp});module.exports=F(U);var T=require("./timestamp.cjs"),o=1e3,c=60*o,m=60*c,r=24*m,g=7*r,d=[{unit:"second",step:1,span:o},{unit:"second",step:5,span:5*o},{unit:"second",step:15,span:15*o},{unit:"second",step:30,span:30*o},{unit:"minute",step:1,span:c},{unit:"minute",step:5,span:5*c},{unit:"minute",step:15,span:15*c},{unit:"minute",step:30,span:30*c},{unit:"hour",step:1,span:m},{unit:"hour",step:3,span:3*m},{unit:"hour",step:6,span:6*m},{unit:"hour",step:12,span:12*m},{unit:"day",step:1,span:r},{unit:"day",step:2,span:2*r},{unit:"week",step:1,span:g},{unit:"week",step:2,span:2*g},{unit:"month",step:1,span:30*r},{unit:"month",step:3,span:91*r},{unit:"month",step:6,span:182*r},{unit:"year",step:1,span:365*r},{unit:"year",step:2,span:730*r},{unit:"year",step:5,span:1826*r},{unit:"year",step:10,span:3652*r}];function k(s,n,t){let e=new Date(s.getTime());switch(n){case"year":return e.setMonth(0,1),e.setHours(0,0,0,0),e.setFullYear(Math.floor(e.getFullYear()/t)*t),e;case"month":return e.setDate(1),e.setHours(0,0,0,0),e.setMonth(Math.floor(e.getMonth()/t)*t),e;case"week":return e.setHours(0,0,0,0),e.setDate(e.getDate()-(e.getDay()+6)%7),e;case"day":return e.setHours(0,0,0,0),e;case"hour":return e.setMinutes(0,0,0),e.setHours(Math.floor(e.getHours()/t)*t),e;case"minute":return e.setSeconds(0,0),e.setMinutes(Math.floor(e.getMinutes()/t)*t),e;default:return e.setMilliseconds(0),e.setSeconds(Math.floor(e.getSeconds()/t)*t),e}}function l(s,n,t){let e=new Date(s.getTime());switch(n){case"year":return e.setFullYear(e.getFullYear()+t),e;case"month":return e.setMonth(e.getMonth()+t),e;case"week":return e.setDate(e.getDate()+t*7),e;case"day":return e.setDate(e.getDate()+t),e;case"hour":return e.setHours(e.getHours()+t),e;case"minute":return e.setMinutes(e.getMinutes()+t),e;default:return e.setSeconds(e.getSeconds()+t),e}}function S(s,n,t=6){if(!Number.isFinite(s)||!Number.isFinite(n))return{values:[],unit:"day",step:1};s>n&&([s,n]=[n,s]);let e=Math.max(1,t),a=(n-s)/e,u=d.find(f=>f.span>=a)??d[d.length-1],p=[],i=k(new Date(s),u.unit,u.step);for(;i.getTime()<s;)i=l(i,u.unit,u.step);for(;i.getTime()<=n&&p.length<=500;)p.push(i.getTime()),i=l(i,u.unit,u.step);return{values:p,unit:u.unit,step:u.step}}function H(s,n,t){let e=new Date(s);switch(n){case"year":return new Intl.DateTimeFormat(t,{year:"numeric"}).format(e);case"month":return new Intl.DateTimeFormat(t,{month:"short",year:"2-digit"}).format(e);case"week":case"day":return new Intl.DateTimeFormat(t,{day:"numeric",month:"short"}).format(e);case"hour":return new Intl.DateTimeFormat(t,{hour:"2-digit",minute:"2-digit"}).format(e);default:return new Intl.DateTimeFormat(t,{minute:"2-digit",second:"2-digit"}).format(e)}}0&&(module.exports={formatTimeTick,niceTimeTicks,toTimestamp});
@@ -1 +1 @@
1
- var a=[{unit:"second",step:1,span:1e3},{unit:"second",step:5,span:5e3},{unit:"second",step:15,span:15e3},{unit:"second",step:30,span:3e4},{unit:"minute",step:1,span:6e4},{unit:"minute",step:5,span:3e5},{unit:"minute",step:15,span:9e5},{unit:"minute",step:30,span:18e5},{unit:"hour",step:1,span:36e5},{unit:"hour",step:3,span:108e5},{unit:"hour",step:6,span:216e5},{unit:"hour",step:12,span:432e5},{unit:"day",step:1,span:864e5},{unit:"day",step:2,span:1728e5},{unit:"week",step:1,span:6048e5},{unit:"week",step:2,span:12096e5},{unit:"month",step:1,span:2592e6},{unit:"month",step:3,span:78624e5},{unit:"month",step:6,span:157248e5},{unit:"year",step:1,span:31536e6},{unit:"year",step:2,span:63072e6},{unit:"year",step:5,span:1577664e5},{unit:"year",step:10,span:3155328e5}];function p(n,s,e){let t=new Date(n.getTime());switch(s){case"year":return t.setMonth(0,1),t.setHours(0,0,0,0),t.setFullYear(Math.floor(t.getFullYear()/e)*e),t;case"month":return t.setDate(1),t.setHours(0,0,0,0),t.setMonth(Math.floor(t.getMonth()/e)*e),t;case"week":return t.setHours(0,0,0,0),t.setDate(t.getDate()-(t.getDay()+6)%7),t;case"day":return t.setHours(0,0,0,0),t;case"hour":return t.setMinutes(0,0,0),t.setHours(Math.floor(t.getHours()/e)*e),t;case"minute":return t.setSeconds(0,0),t.setMinutes(Math.floor(t.getMinutes()/e)*e),t;default:return t.setMilliseconds(0),t.setSeconds(Math.floor(t.getSeconds()/e)*e),t}}function o(n,s,e){let t=new Date(n.getTime());switch(s){case"year":return t.setFullYear(t.getFullYear()+e),t;case"month":return t.setMonth(t.getMonth()+e),t;case"week":return t.setDate(t.getDate()+e*7),t;case"day":return t.setDate(t.getDate()+e),t;case"hour":return t.setHours(t.getHours()+e),t;case"minute":return t.setMinutes(t.getMinutes()+e),t;default:return t.setSeconds(t.getSeconds()+e),t}}function h(n,s,e=6){if(!Number.isFinite(n)||!Number.isFinite(s))return{values:[],unit:"day",step:1};n>s&&([n,s]=[s,n]);let t=Math.max(1,e),m=(s-n)/t,r=a.find(c=>c.span>=m)??a[a.length-1],i=[],u=p(new Date(n),r.unit,r.step);for(;u.getTime()<n;)u=o(u,r.unit,r.step);for(;u.getTime()<=s&&i.length<=500;)i.push(u.getTime()),u=o(u,r.unit,r.step);return{values:i,unit:r.unit,step:r.step}}function D(n,s,e){let t=new Date(n);switch(s){case"year":return new Intl.DateTimeFormat(e,{year:"numeric"}).format(t);case"month":return new Intl.DateTimeFormat(e,{month:"short",year:"2-digit"}).format(t);case"week":case"day":return new Intl.DateTimeFormat(e,{day:"numeric",month:"short"}).format(t);case"hour":return new Intl.DateTimeFormat(e,{hour:"2-digit",minute:"2-digit"}).format(t);default:return new Intl.DateTimeFormat(e,{minute:"2-digit",second:"2-digit"}).format(t)}}function T(n){if(n instanceof Date){let s=n.getTime();return Number.isFinite(s)?s:null}if(typeof n=="number")return Number.isFinite(n)?n:null;if(typeof n=="string"&&n!==""){let s=Date.parse(n);if(Number.isFinite(s))return s;let e=Number(n);return Number.isFinite(e)?e:null}return null}export{D as formatTimeTick,h as niceTimeTicks,T as toTimestamp};
1
+ import{toTimestamp as M}from"./timestamp.js";var i=1e3,o=60*i,c=60*o,r=24*c,h=7*r,p=[{unit:"second",step:1,span:i},{unit:"second",step:5,span:5*i},{unit:"second",step:15,span:15*i},{unit:"second",step:30,span:30*i},{unit:"minute",step:1,span:o},{unit:"minute",step:5,span:5*o},{unit:"minute",step:15,span:15*o},{unit:"minute",step:30,span:30*o},{unit:"hour",step:1,span:c},{unit:"hour",step:3,span:3*c},{unit:"hour",step:6,span:6*c},{unit:"hour",step:12,span:12*c},{unit:"day",step:1,span:r},{unit:"day",step:2,span:2*r},{unit:"week",step:1,span:h},{unit:"week",step:2,span:2*h},{unit:"month",step:1,span:30*r},{unit:"month",step:3,span:91*r},{unit:"month",step:6,span:182*r},{unit:"year",step:1,span:365*r},{unit:"year",step:2,span:730*r},{unit:"year",step:5,span:1826*r},{unit:"year",step:10,span:3652*r}];function T(n,s,t){let e=new Date(n.getTime());switch(s){case"year":return e.setMonth(0,1),e.setHours(0,0,0,0),e.setFullYear(Math.floor(e.getFullYear()/t)*t),e;case"month":return e.setDate(1),e.setHours(0,0,0,0),e.setMonth(Math.floor(e.getMonth()/t)*t),e;case"week":return e.setHours(0,0,0,0),e.setDate(e.getDate()-(e.getDay()+6)%7),e;case"day":return e.setHours(0,0,0,0),e;case"hour":return e.setMinutes(0,0,0),e.setHours(Math.floor(e.getHours()/t)*t),e;case"minute":return e.setSeconds(0,0),e.setMinutes(Math.floor(e.getMinutes()/t)*t),e;default:return e.setMilliseconds(0),e.setSeconds(Math.floor(e.getSeconds()/t)*t),e}}function d(n,s,t){let e=new Date(n.getTime());switch(s){case"year":return e.setFullYear(e.getFullYear()+t),e;case"month":return e.setMonth(e.getMonth()+t),e;case"week":return e.setDate(e.getDate()+t*7),e;case"day":return e.setDate(e.getDate()+t),e;case"hour":return e.setHours(e.getHours()+t),e;case"minute":return e.setMinutes(e.getMinutes()+t),e;default:return e.setSeconds(e.getSeconds()+t),e}}function f(n,s,t=6){if(!Number.isFinite(n)||!Number.isFinite(s))return{values:[],unit:"day",step:1};n>s&&([n,s]=[s,n]);let e=Math.max(1,t),g=(s-n)/e,u=p.find(l=>l.span>=g)??p[p.length-1],m=[],a=T(new Date(n),u.unit,u.step);for(;a.getTime()<n;)a=d(a,u.unit,u.step);for(;a.getTime()<=s&&m.length<=500;)m.push(a.getTime()),a=d(a,u.unit,u.step);return{values:m,unit:u.unit,step:u.step}}function D(n,s,t){let e=new Date(n);switch(s){case"year":return new Intl.DateTimeFormat(t,{year:"numeric"}).format(e);case"month":return new Intl.DateTimeFormat(t,{month:"short",year:"2-digit"}).format(e);case"week":case"day":return new Intl.DateTimeFormat(t,{day:"numeric",month:"short"}).format(e);case"hour":return new Intl.DateTimeFormat(t,{hour:"2-digit",minute:"2-digit"}).format(e);default:return new Intl.DateTimeFormat(t,{minute:"2-digit",second:"2-digit"}).format(e)}}export{D as formatTimeTick,f as niceTimeTicks,M as toTimestamp};
@@ -0,0 +1 @@
1
+ "use strict";var o=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var b=(t,n)=>{for(var e in n)o(t,e,{get:n[e],enumerable:!0})},p=(t,n,e,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of a(n))!l.call(t,r)&&r!==e&&o(t,r,{get:()=>n[r],enumerable:!(i=c(n,r))||i.enumerable});return t};var d=t=>p(o({},"__esModule",{value:!0}),t);var y={};b(y,{formatTimeValue:()=>g,toTimestamp:()=>f});module.exports=d(y);var m=require("./format.cjs"),s=/^(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?$/;function N(t){let n=s.exec(t);if(!n)return null;let e=Number(n[1]),i=n[2]===void 0?0:Number(n[2])-1,r=n[3]===void 0?1:Number(n[3]),u=new Date(e,i,r);return u.setFullYear(e),u.getMonth()===i&&u.getDate()===r?u.getTime():null}function f(t){if(t instanceof Date){let n=t.getTime();return Number.isFinite(n)?n:null}if(typeof t=="number")return Number.isFinite(t)?t:null;if(typeof t=="string"&&t!==""){if(s.test(t))return N(t);let n=Date.parse(t);if(Number.isFinite(n))return n;let e=Number(t);return Number.isFinite(e)?e:null}return null}function g(t,n){let e=f(t);return e===null?String(t):(0,m.formatXValue)(new Date(e),n)}0&&(module.exports={formatTimeValue,toTimestamp});
@@ -0,0 +1 @@
1
+ import{formatXValue as m}from"./format.js";var o=/^(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?$/;function s(t){let n=o.exec(t);if(!n)return null;let e=Number(n[1]),i=n[2]===void 0?0:Number(n[2])-1,u=n[3]===void 0?1:Number(n[3]),r=new Date(e,i,u);return r.setFullYear(e),r.getMonth()===i&&r.getDate()===u?r.getTime():null}function f(t){if(t instanceof Date){let n=t.getTime();return Number.isFinite(n)?n:null}if(typeof t=="number")return Number.isFinite(t)?t:null;if(typeof t=="string"&&t!==""){if(o.test(t))return s(t);let n=Date.parse(t);if(Number.isFinite(n))return n;let e=Number(t);return Number.isFinite(e)?e:null}return null}function a(t,n){let e=f(t);return e===null?String(t):m(new Date(e),n)}export{a as formatTimeValue,f as toTimestamp};
@@ -0,0 +1 @@
1
+ "use strict";var n=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var A=(c,o)=>{for(var h in o)n(c,h,{get:o[h],enumerable:!0})},H=(c,o,h,p)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of T(o))!u.call(c,t)&&t!==h&&n(c,t,{get:()=>o[t],enumerable:!(p=C(o,t))||p.enumerable});return c};var R=c=>H(n({},"__esModule",{value:!0}),c);var a={};A(a,{CHART_TOUCH:()=>_,CHART_TOUCH_VERTICAL_DRAG:()=>x});module.exports=R(a);var _="touch-pan-y touch-pinch-zoom",x="touch-pan-x touch-pinch-zoom";0&&(module.exports={CHART_TOUCH,CHART_TOUCH_VERTICAL_DRAG});
@@ -0,0 +1 @@
1
+ var o="touch-pan-y touch-pinch-zoom",c="touch-pan-x touch-pinch-zoom";export{o as CHART_TOUCH,c as CHART_TOUCH_VERTICAL_DRAG};
@@ -1 +1 @@
1
- "use strict";"use client";var te=Object.defineProperty;var xe=Object.getOwnPropertyDescriptor;var Re=Object.getOwnPropertyNames;var Se=Object.prototype.hasOwnProperty;var De=(u,o)=>{for(var h in o)te(u,h,{get:o[h],enumerable:!0})},Le=(u,o,h,t)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of Re(o))!Se.call(u,i)&&i!==h&&te(u,i,{get:()=>o[i],enumerable:!(t=xe(o,i))||t.enumerable});return u};var Pe=u=>Le(te({},"__esModule",{value:!0}),u);var Ee={};De(Ee,{DumbbellChart:()=>We,resetDumbbellWarnings:()=>Ve});module.exports=Pe(Ee);var s=require("react"),ce=require("../../lib/i18n.cjs"),ne=require("../chart/ChartAxis.cjs"),me=require("../chart/ChartContainer.cjs"),he=require("../chart/ChartGrid.cjs"),de=require("../chart/ChartLegend.cjs"),ge=require("../chart/ChartTableView.cjs"),Y=require("../chart/ChartTooltip.cjs"),C=require("../chart/palette.cjs"),be=require("../chart/utils/cartesian.cjs"),E=require("../chart/utils/data.cjs"),B=require("../chart/utils/format.cjs"),fe=require("../chart/utils/scales.cjs"),ye=require("../chart/utils/text.cjs"),pe=require("../chart/utils/ticks.cjs"),n=require("react/jsx-runtime"),we=5,Te=3,ue=10,re=!1;function Ve(){re=!1}var Ae=(0,s.memo)(function({rows:o,radius:h}){return(0,n.jsx)("g",{children:o.map(t=>(0,n.jsxs)("g",{children:[t.connector?(0,n.jsx)("line",{x1:t.connector.x1,y1:t.connector.y,x2:t.connector.x2,y2:t.connector.y,strokeWidth:Te,strokeLinecap:"round",className:"stroke-gray-300 dark:stroke-gray-600"}):null,t.dots.map(i=>(0,n.jsx)("circle",{cx:i.cx,cy:i.cy,r:h,fill:i.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},i.key)),t.label?(0,n.jsx)("text",{x:t.label.x,y:t.label.y,dominantBaseline:"middle",className:"fill-gray-600 text-[10px] [font-variant-numeric:tabular-nums] dark:fill-gray-300",children:t.label.text}):null]},t.key))})});function Ne({width:u,height:o,data:h,rows:t,resolvedSeries:i,x:L,y:w,grid:$,size:G,showValues:_,dotSize:Z,referenceLines:z,margin:U,tooltip:b,plotLabel:j,formatValue:H,formatX:I,onRowClick:M}){let[c,T]=(0,s.useState)(null),e=(0,s.useMemo)(()=>{let k=i.filter(d=>!d.hidden).map(d=>d.key),m=(0,be.buildCartesianGeometry)({width:u,height:o,data:h,x:L,y:w,bounds:(0,pe.extent)((0,E.collectAllValues)(h,k)),margin:U,orientation:"horizontal",placement:"band",formatValue:H,formatX:I,defaultIncludeZero:!1}),{valueScale:f,bandwidth:X,categoryPositions:V,innerWidth:O,innerHeight:Q}=m;return{rendered:t.map((d,A)=>{let K=V[A]+X/2,x=d.points.map((l,R)=>({key:l.seriesKey,value:l.value,cx:l.value===null?Number.NaN:f(l.value),cy:K,color:l.color,order:R})).filter(l=>l.value!==null),N=d.from===null||d.to===null||x.length<2?null:{x1:f(d.from),x2:f(d.to),y:K},P=null;if(_&&d.to!==null){let l=H(d.to),R=f(d.to);(0,ye.estimateTextWidth)(l,10)<=O-R-ue&&(P={x:R+ue,y:K,text:l})}return{key:`${A}`,connector:N,dots:x.map(l=>({key:l.key,cx:l.cx,cy:l.cy,color:l.color})),label:P,top:V[A],height:X}}),categoryPositions:V,categoryCenters:m.categoryCenters,bandwidth:X,categoryTicks:m.categoryTicks,valueTicks:m.valueTicks,valueScale:f,innerWidth:O,innerHeight:Q,margin:m.margin}},[h,t,i,L,w,u,o,U,_,H,I]),q=(0,s.useCallback)(r=>{if(b===!1||t.length===0)return;let k=r.currentTarget.getBoundingClientRect(),m=r.clientY-k.top-e.margin.top;T((0,fe.nearestIndex)(e.categoryCenters,m))},[b,t.length,e.margin.top,e.categoryCenters]),F=(0,s.useCallback)(r=>{if(t.length===0)return;let k=t.length-1,m=c??0,f=r.key==="ArrowDown"?Math.min(k,m+1):r.key==="ArrowUp"?Math.max(0,m-1):r.key==="Home"?0:r.key==="End"?k:r.key==="Escape"?null:void 0;f!==void 0&&(r.preventDefault(),T(f))},[t.length,c]),J=(0,s.useCallback)(()=>{!M||c===null||M(t[c])},[M,c,t]),v=c===null?null:t[c];return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("svg",{width:u,height:o,role:"img","aria-label":j??i.map(r=>(0,C.getSeriesLabel)(r)).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:q,onPointerLeave:()=>T(null),onKeyDown:F,onBlur:()=>T(null),onClick:J,children:[(0,n.jsxs)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[(0,n.jsx)(he.ChartGrid,{width:e.innerWidth,height:e.innerHeight,vertical:$==="y"||$==="both"?e.valueTicks.map(r=>r.offset):void 0}),c!==null?(0,n.jsx)("rect",{x:0,y:e.categoryPositions[c],width:e.innerWidth,height:e.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,z?.map(r=>(0,n.jsxs)("g",{children:[(0,n.jsx)("line",{x1:e.valueScale(r.value),y1:0,x2:e.valueScale(r.value),y2:e.innerHeight,stroke:r.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:r.dashed===!1?void 0:"4 4"}),r.label?(0,n.jsx)("text",{x:e.valueScale(r.value)+4,y:8,className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:r.label}):null]},`${r.value}-${r.label??""}`)),(0,n.jsx)(Ae,{rows:e.rendered,radius:Z})]}),(0,n.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:w?.hidden?null:(0,n.jsx)(ne.ChartAxis,{orientation:"bottom",ticks:e.valueTicks,length:e.innerWidth,label:w?.label,size:G})}),(0,n.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:L.hidden?null:(0,n.jsx)(ne.ChartAxis,{orientation:"left",ticks:e.categoryTicks,length:e.innerHeight,showLine:!1,tickSize:0,label:L.label,size:G})})]}),v&&c!==null&&b!==!1?(0,n.jsx)(Y.ChartTooltip,{x:e.margin.left+(v.to===null?e.innerWidth/2:e.valueScale(v.to)),y:e.margin.top+e.categoryCenters[c],containerWidth:u,children:typeof b=="function"?b(v):(0,n.jsx)(Y.ChartTooltipContent,{title:v.label,points:v.points})}):null]})}function We({data:u,x:o,y:h,series:t,sort:i="none",sortBy:L,showValues:w=!1,dotSize:$=we,referenceLines:G,height:_,width:Z,size:z="md",grid:U="y",legend:b,legendToggle:j=!0,tooltip:H=!0,tableView:I=!1,showChange:M=!0,title:c,description:T,loading:e=!1,emptyState:q,error:F=!1,errorState:J,onRetry:v,actions:r,margin:k,locale:m,plotLabel:f,changeLabel:X,format:V,onRowClick:O,className:Q,...ae}){let d=(0,ce.useUILabels)(),[A,K]=(0,s.useState)(()=>new Set);t.length>C.CHART_ALL_PAIRS_LIMIT&&!re&&(re=!0,console.warn(`[@synertech/ui] A DumbbellChart was given ${t.length} series. Any two dots of a row can sit side by side, and only the first ${C.CHART_ALL_PAIRS_LIMIT} palette slots stay tellable apart under that test: facet the chart instead.`));let x=(0,s.useMemo)(()=>t.map((a,g)=>({...a,hidden:a.hidden||A.has(a.key),color:(0,C.resolveSeriesColor)(a,g)})),[t,A]),N=(0,s.useMemo)(()=>h?.format??V??(a=>(0,B.formatAuto)(a,m)),[h?.format,V,m]),P=(0,s.useMemo)(()=>o.format??(a=>(0,B.formatXValue)(a,m)),[o.format,m]),l=(0,s.useMemo)(()=>x.filter(a=>!a.hidden),[x]),R=(0,s.useMemo)(()=>u.map((a,g)=>{let y=(0,E.readXValue)(a,o.key,g),p=l.map(D=>{let ee=(0,E.readNumber)(a,D.key);return{seriesKey:D.key,seriesLabel:(0,C.getSeriesLabel)(D),color:D.color,value:ee,formattedValue:ee===null?"\u2014":N(ee),datum:a}}),S=p.map(D=>D.value).filter(D=>D!==null),ie=p[0]?.value??null,se=p[p.length-1]?.value??null;return{index:g,x:y,label:P(y,g),points:p,from:S.length>0?Math.min(...S):null,to:S.length>0?Math.max(...S):null,change:ie===null||se===null?null:se-ie,datum:a}}),[u,o.key,l,N,P]),W=(0,s.useMemo)(()=>{if(i==="none")return R;let a=L??l[l.length-1]?.key,g=p=>i==="gap"?Math.abs(p.change??0):p.points.find(S=>S.seriesKey===a)?.value??0,y=[...R].sort((p,S)=>g(p)-g(S));return i==="asc"?y:y.reverse()},[R,i,L,l]),Ce=(0,s.useCallback)(a=>{K(g=>{let y=new Set(g);return y.has(a)?y.delete(a):y.add(a),y})},[]),oe=_??Math.max(96,W.length*30+44),ve=(0,s.useMemo)(()=>W.map(a=>({...a.datum,__change:a.change})),[W]),ke=b===void 0?t.length>=2:b!==!1,le=typeof b=="string"?b:"bottom";return(0,n.jsx)(me.ChartContainer,{title:c,description:T,height:oe,width:Z,size:z,loading:e,empty:W.length===0||l.length===0,emptyState:q,error:F,errorState:J,onRetry:v,actions:r,tableView:I,legendPosition:le,legend:ke?(0,n.jsx)(de.ChartLegend,{items:(0,C.toLegendItems)(x),position:le,marker:"dot",size:z,onToggle:j?Ce:void 0}):void 0,table:I?(0,n.jsx)(ge.ChartTableView,{data:ve,series:[...x,...M?[{key:"__change",label:X??d.chartChange}]:[]],xKey:o.key,xLabel:o.label??o.key,formatX:P,formatValue:N,caption:typeof c=="string"?c:void 0}):void 0,className:Q,...ae,children:({width:a})=>(0,n.jsx)(Ne,{width:a,height:oe,data:W.map(g=>g.datum),rows:W,resolvedSeries:x,x:o,y:h,grid:U,size:z,showValues:w,dotSize:$,referenceLines:G,margin:k,tooltip:H,plotLabel:f,formatValue:N,formatX:P,onRowClick:O})})}0&&(module.exports={DumbbellChart,resetDumbbellWarnings});
1
+ "use strict";"use client";var te=Object.defineProperty;var Re=Object.getOwnPropertyDescriptor;var Se=Object.getOwnPropertyNames;var De=Object.prototype.hasOwnProperty;var Le=(u,l)=>{for(var m in l)te(u,m,{get:l[m],enumerable:!0})},Pe=(u,l,m,t)=>{if(l&&typeof l=="object"||typeof l=="function")for(let o of Se(l))!De.call(u,o)&&o!==m&&te(u,o,{get:()=>l[o],enumerable:!(t=Re(l,o))||t.enumerable});return u};var we=u=>Pe(te({},"__esModule",{value:!0}),u);var He={};Le(He,{DumbbellChart:()=>Ee,resetDumbbellWarnings:()=>Ve});module.exports=we(He);var s=require("react"),ce=require("../../lib/i18n.cjs"),ne=require("../chart/ChartAxis.cjs"),me=require("../chart/ChartContainer.cjs"),de=require("../chart/ChartGrid.cjs"),he=require("../chart/ChartLegend.cjs"),ge=require("../chart/ChartTableView.cjs"),Y=require("../chart/ChartTooltip.cjs"),k=require("../chart/palette.cjs"),be=require("../chart/utils/cartesian.cjs"),E=require("../chart/utils/data.cjs"),B=require("../chart/utils/format.cjs"),fe=require("../chart/utils/scales.cjs"),ye=require("../chart/utils/text.cjs"),pe=require("../chart/utils/ticks.cjs"),Ce=require("../chart/utils/touch.cjs"),n=require("react/jsx-runtime"),Te=5,Ae=3,ue=10,re=!1;function Ve(){re=!1}var Ne=(0,s.memo)(function({rows:l,radius:m}){return(0,n.jsx)("g",{children:l.map(t=>(0,n.jsxs)("g",{children:[t.connector?(0,n.jsx)("line",{x1:t.connector.x1,y1:t.connector.y,x2:t.connector.x2,y2:t.connector.y,strokeWidth:Ae,strokeLinecap:"round",className:"stroke-gray-300 dark:stroke-gray-600"}):null,t.dots.map(o=>(0,n.jsx)("circle",{cx:o.cx,cy:o.cy,r:m,fill:o.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},o.key)),t.label?(0,n.jsx)("text",{x:t.label.x,y:t.label.y,dominantBaseline:"middle",className:"fill-gray-600 text-[10px] [font-variant-numeric:tabular-nums] dark:fill-gray-300",children:t.label.text}):null]},t.key))})});function We({width:u,height:l,data:m,rows:t,resolvedSeries:o,x:P,y:A,grid:K,size:_,showValues:G,dotSize:Z,referenceLines:H,margin:U,tooltip:y,plotLabel:j,formatValue:I,formatX:z,onRowClick:M}){let[w,V]=(0,s.useState)(null),d=w!==null&&w<t.length?w:null,e=(0,s.useMemo)(()=>{let b=o.filter(c=>!c.hidden).map(c=>c.key),h=(0,be.buildCartesianGeometry)({width:u,height:l,data:m,x:P,y:A,bounds:(0,pe.extent)((0,E.collectAllValues)(m,b)),margin:U,orientation:"horizontal",placement:"band",formatValue:I,formatX:z,defaultIncludeZero:!1}),{valueScale:p,bandwidth:N,categoryPositions:X,innerWidth:O,innerHeight:Q}=h;return{rendered:t.map((c,$)=>{let x=X[$]+N/2,T=c.points.map((i,f)=>({key:i.seriesKey,value:i.value,cx:i.value===null?Number.NaN:p(i.value),cy:x,color:i.color,order:f})).filter(i=>i.value!==null),W=c.from===null||c.to===null||T.length<2?null:{x1:p(c.from),x2:p(c.to),y:x},R=null;if(G&&c.to!==null){let i=I(c.to),f=p(c.to);(0,ye.estimateTextWidth)(i,10)<=O-f-ue&&(R={x:f+ue,y:x,text:i})}return{key:`${$}`,connector:W,dots:T.map(i=>({key:i.key,cx:i.cx,cy:i.cy,color:i.color})),label:R,top:X[$],height:N}}),categoryPositions:X,categoryCenters:h.categoryCenters,bandwidth:N,categoryTicks:h.categoryTicks,valueTicks:h.valueTicks,valueScale:p,innerWidth:O,innerHeight:Q,margin:h.margin}},[m,t,o,P,A,u,l,U,G,I,z]),q=(0,s.useCallback)(r=>{if(y===!1||t.length===0)return;let b=r.currentTarget.getBoundingClientRect(),h=r.clientY-b.top-e.margin.top;V((0,fe.nearestIndex)(e.categoryCenters,h))},[y,t.length,e.margin.top,e.categoryCenters]),F=(0,s.useCallback)(r=>{if(t.length===0)return;let b=t.length-1,h=d??0,p=r.key==="ArrowDown"?Math.min(b,h+1):r.key==="ArrowUp"?Math.max(0,h-1):r.key==="Home"?0:r.key==="End"?b:r.key==="Escape"?null:void 0;p!==void 0&&(r.preventDefault(),V(p))},[t.length,d]),J=(0,s.useCallback)(()=>{!M||d===null||M(t[d])},[M,d,t]),S=d===null?null:t[d];return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("svg",{width:u,height:l,role:"img","aria-label":j??o.map(r=>(0,k.getSeriesLabel)(r)).join(", "),tabIndex:0,className:`${Ce.CHART_TOUCH} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500`,onPointerMove:q,onPointerLeave:()=>V(null),onKeyDown:F,onBlur:()=>V(null),onClick:J,children:[(0,n.jsxs)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[(0,n.jsx)(de.ChartGrid,{width:e.innerWidth,height:e.innerHeight,vertical:K==="y"||K==="both"?e.valueTicks.map(r=>r.offset):void 0}),d!==null?(0,n.jsx)("rect",{x:0,y:e.categoryPositions[d],width:e.innerWidth,height:e.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,H?.map(r=>(0,n.jsxs)("g",{children:[(0,n.jsx)("line",{x1:e.valueScale(r.value),y1:0,x2:e.valueScale(r.value),y2:e.innerHeight,stroke:r.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:r.dashed===!1?void 0:"4 4"}),r.label?(0,n.jsx)("text",{x:e.valueScale(r.value)+4,y:8,className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:r.label}):null]},`${r.value}-${r.label??""}`)),(0,n.jsx)(Ne,{rows:e.rendered,radius:Z})]}),(0,n.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:A?.hidden?null:(0,n.jsx)(ne.ChartAxis,{orientation:"bottom",ticks:e.valueTicks,length:e.innerWidth,label:A?.label,size:_})}),(0,n.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:P.hidden?null:(0,n.jsx)(ne.ChartAxis,{orientation:"left",ticks:e.categoryTicks,length:e.innerHeight,showLine:!1,tickSize:0,label:P.label,size:_})})]}),S&&d!==null&&y!==!1?(0,n.jsx)(Y.ChartTooltip,{x:e.margin.left+(S.to===null?e.innerWidth/2:e.valueScale(S.to)),y:e.margin.top+e.categoryCenters[d],containerWidth:u,children:typeof y=="function"?y(S):(0,n.jsx)(Y.ChartTooltipContent,{title:S.label,points:S.points})}):null]})}function Ee({data:u,x:l,y:m,series:t,sort:o="none",sortBy:P,showValues:A=!1,dotSize:K=Te,referenceLines:_,height:G,width:Z,size:H="md",grid:U="y",legend:y,legendToggle:j=!0,tooltip:I=!0,tableView:z=!1,showChange:M=!0,title:w,description:V,loading:d=!1,emptyState:e,error:q=!1,errorState:F,onRetry:J,actions:S,margin:r,locale:b,plotLabel:h,changeLabel:p,format:N,onRowClick:X,className:O,...Q}){let ae=(0,ce.useUILabels)(),[c,$]=(0,s.useState)(()=>new Set);t.length>k.CHART_ALL_PAIRS_LIMIT&&!re&&(re=!0,console.warn(`[@synertech/ui] A DumbbellChart was given ${t.length} series. Any two dots of a row can sit side by side, and only the first ${k.CHART_ALL_PAIRS_LIMIT} palette slots stay tellable apart under that test: facet the chart instead.`));let x=(0,s.useMemo)(()=>t.map((a,g)=>({...a,hidden:a.hidden||c.has(a.key),color:(0,k.resolveSeriesColor)(a,g)})),[t,c]),T=(0,s.useMemo)(()=>m?.format??N??(a=>(0,B.formatAuto)(a,b)),[m?.format,N,b]),W=(0,s.useMemo)(()=>l.format??(a=>(0,B.formatXValue)(a,b)),[l.format,b]),R=(0,s.useMemo)(()=>x.filter(a=>!a.hidden),[x]),i=(0,s.useMemo)(()=>u.map((a,g)=>{let C=(0,E.readXValue)(a,l.key,g),v=R.map(L=>{let ee=(0,E.readNumber)(a,L.key);return{seriesKey:L.key,seriesLabel:(0,k.getSeriesLabel)(L),color:L.color,value:ee,formattedValue:ee===null?"\u2014":T(ee),datum:a}}),D=v.map(L=>L.value).filter(L=>L!==null),ie=v[0]?.value??null,se=v[v.length-1]?.value??null;return{index:g,x:C,label:W(C,g),points:v,from:D.length>0?Math.min(...D):null,to:D.length>0?Math.max(...D):null,change:ie===null||se===null?null:se-ie,datum:a}}),[u,l.key,R,T,W]),f=(0,s.useMemo)(()=>{if(o==="none")return i;let a=P??R[R.length-1]?.key,g=v=>o==="gap"?Math.abs(v.change??0):v.points.find(D=>D.seriesKey===a)?.value??0,C=[...i].sort((v,D)=>g(v)-g(D));return o==="asc"?C:C.reverse()},[i,o,P,R]),ve=(0,s.useCallback)(a=>{$(g=>{let C=new Set(g);return C.has(a)?C.delete(a):C.add(a),C})},[]),le=G??Math.max(96,f.length*30+44),ke=(0,s.useMemo)(()=>f.map(a=>({...a.datum,__change:a.change})),[f]),xe=y===void 0?t.length>=2:y!==!1,oe=typeof y=="string"?y:"bottom";return(0,n.jsx)(me.ChartContainer,{title:w,description:V,height:le,width:Z,size:H,loading:d,empty:f.length===0||R.length===0,emptyState:e,error:q,errorState:F,onRetry:J,actions:S,tableView:z,legendPosition:oe,legend:xe?(0,n.jsx)(he.ChartLegend,{items:(0,k.toLegendItems)(x),position:oe,marker:"dot",size:H,onToggle:j?ve:void 0}):void 0,table:z?(0,n.jsx)(ge.ChartTableView,{data:ke,series:[...x,...M?[{key:"__change",label:p??ae.chartChange}]:[]],xKey:l.key,xLabel:l.label??l.key,formatX:W,formatValue:T,caption:typeof w=="string"?w:void 0}):void 0,className:O,...Q,children:({width:a})=>(0,n.jsx)(We,{width:a,height:le,data:f.map(g=>g.datum),rows:f,resolvedSeries:x,x:l,y:m,grid:U,size:H,showValues:A,dotSize:K,referenceLines:_,margin:r,tooltip:I,plotLabel:h,formatValue:T,formatX:W,onRowClick:X})})}0&&(module.exports={DumbbellChart,resetDumbbellWarnings});
@@ -1 +1 @@
1
- "use client";import{memo as de,useCallback as O,useMemo as S,useState as se}from"react";import{useUILabels as ge}from"../../lib/i18n.js";import{ChartAxis as oe}from"../chart/ChartAxis.js";import{ChartContainer as be}from"../chart/ChartContainer.js";import{ChartGrid as fe}from"../chart/ChartGrid.js";import{ChartLegend as ye}from"../chart/ChartLegend.js";import{ChartTableView as pe}from"../chart/ChartTableView.js";import{ChartTooltip as Ce,ChartTooltipContent as ve}from"../chart/ChartTooltip.js";import{CHART_ALL_PAIRS_LIMIT as le,getSeriesLabel as ue,resolveSeriesColor as ke,toLegendItems as xe}from"../chart/palette.js";import{buildCartesianGeometry as Re}from"../chart/utils/cartesian.js";import{collectAllValues as Se,readNumber as De,readXValue as Le}from"../chart/utils/data.js";import{formatAuto as Pe,formatXValue as we}from"../chart/utils/format.js";import{nearestIndex as Te}from"../chart/utils/scales.js";import{estimateTextWidth as Ve}from"../chart/utils/text.js";import{extent as Ae}from"../chart/utils/ticks.js";import{Fragment as He,jsx as o,jsxs as X}from"react/jsx-runtime";var Ne=5,We=3,ie=10,Q=!1;function Je(){Q=!1}var Ee=de(function({rows:s,radius:f}){return o("g",{children:s.map(t=>X("g",{children:[t.connector?o("line",{x1:t.connector.x1,y1:t.connector.y,x2:t.connector.x2,y2:t.connector.y,strokeWidth:We,strokeLinecap:"round",className:"stroke-gray-300 dark:stroke-gray-600"}):null,t.dots.map(c=>o("circle",{cx:c.cx,cy:c.cy,r:f,fill:c.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},c.key)),t.label?o("text",{x:t.label.x,y:t.label.y,dominantBaseline:"middle",className:"fill-gray-600 text-[10px] [font-variant-numeric:tabular-nums] dark:fill-gray-300",children:t.label.text}):null]},t.key))})});function ze({width:y,height:s,data:f,rows:t,resolvedSeries:c,x:D,y:P,grid:K,size:$,showValues:G,dotSize:Y,referenceLines:W,margin:_,tooltip:h,plotLabel:B,formatValue:E,formatX:z,onRowClick:H}){let[l,w]=se(null),e=S(()=>{let C=c.filter(u=>!u.hidden).map(u=>u.key),i=Re({width:y,height:s,data:f,x:D,y:P,bounds:Ae(Se(f,C)),margin:_,orientation:"horizontal",placement:"band",formatValue:E,formatX:z,defaultIncludeZero:!1}),{valueScale:d,bandwidth:I,categoryPositions:T,innerWidth:U,innerHeight:F}=i;return{rendered:t.map((u,V)=>{let M=T[V]+I/2,v=u.points.map((a,k)=>({key:a.seriesKey,value:a.value,cx:a.value===null?Number.NaN:d(a.value),cy:M,color:a.color,order:k})).filter(a=>a.value!==null),A=u.from===null||u.to===null||v.length<2?null:{x1:d(u.from),x2:d(u.to),y:M},L=null;if(G&&u.to!==null){let a=E(u.to),k=d(u.to);Ve(a,10)<=U-k-ie&&(L={x:k+ie,y:M,text:a})}return{key:`${V}`,connector:A,dots:v.map(a=>({key:a.key,cx:a.cx,cy:a.cy,color:a.color})),label:L,top:T[V],height:I}}),categoryPositions:T,categoryCenters:i.categoryCenters,bandwidth:I,categoryTicks:i.categoryTicks,valueTicks:i.valueTicks,valueScale:d,innerWidth:U,innerHeight:F,margin:i.margin}},[f,t,c,D,P,y,s,_,G,E,z]),Z=O(n=>{if(h===!1||t.length===0)return;let C=n.currentTarget.getBoundingClientRect(),i=n.clientY-C.top-e.margin.top;w(Te(e.categoryCenters,i))},[h,t.length,e.margin.top,e.categoryCenters]),j=O(n=>{if(t.length===0)return;let C=t.length-1,i=l??0,d=n.key==="ArrowDown"?Math.min(C,i+1):n.key==="ArrowUp"?Math.max(0,i-1):n.key==="Home"?0:n.key==="End"?C:n.key==="Escape"?null:void 0;d!==void 0&&(n.preventDefault(),w(d))},[t.length,l]),q=O(()=>{!H||l===null||H(t[l])},[H,l,t]),p=l===null?null:t[l];return X(He,{children:[X("svg",{width:y,height:s,role:"img","aria-label":B??c.map(n=>ue(n)).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:Z,onPointerLeave:()=>w(null),onKeyDown:j,onBlur:()=>w(null),onClick:q,children:[X("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[o(fe,{width:e.innerWidth,height:e.innerHeight,vertical:K==="y"||K==="both"?e.valueTicks.map(n=>n.offset):void 0}),l!==null?o("rect",{x:0,y:e.categoryPositions[l],width:e.innerWidth,height:e.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,W?.map(n=>X("g",{children:[o("line",{x1:e.valueScale(n.value),y1:0,x2:e.valueScale(n.value),y2:e.innerHeight,stroke:n.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:n.dashed===!1?void 0:"4 4"}),n.label?o("text",{x:e.valueScale(n.value)+4,y:8,className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:n.label}):null]},`${n.value}-${n.label??""}`)),o(Ee,{rows:e.rendered,radius:Y})]}),o("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:P?.hidden?null:o(oe,{orientation:"bottom",ticks:e.valueTicks,length:e.innerWidth,label:P?.label,size:$})}),o("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:D.hidden?null:o(oe,{orientation:"left",ticks:e.categoryTicks,length:e.innerHeight,showLine:!1,tickSize:0,label:D.label,size:$})})]}),p&&l!==null&&h!==!1?o(Ce,{x:e.margin.left+(p.to===null?e.innerWidth/2:e.valueScale(p.to)),y:e.margin.top+e.categoryCenters[l],containerWidth:y,children:typeof h=="function"?h(p):o(ve,{title:p.label,points:p.points})}):null]})}function Qe({data:y,x:s,y:f,series:t,sort:c="none",sortBy:D,showValues:P=!1,dotSize:K=Ne,referenceLines:$,height:G,width:Y,size:W="md",grid:_="y",legend:h,legendToggle:B=!0,tooltip:E=!0,tableView:z=!1,showChange:H=!0,title:l,description:w,loading:e=!1,emptyState:Z,error:j=!1,errorState:q,onRetry:p,actions:n,margin:C,locale:i,plotLabel:d,changeLabel:I,format:T,onRowClick:U,className:F,...ee}){let u=ge(),[V,M]=se(()=>new Set);t.length>le&&!Q&&(Q=!0,console.warn(`[@synertech/ui] A DumbbellChart was given ${t.length} series. Any two dots of a row can sit side by side, and only the first ${le} palette slots stay tellable apart under that test: facet the chart instead.`));let v=S(()=>t.map((r,m)=>({...r,hidden:r.hidden||V.has(r.key),color:ke(r,m)})),[t,V]),A=S(()=>f?.format??T??(r=>Pe(r,i)),[f?.format,T,i]),L=S(()=>s.format??(r=>we(r,i)),[s.format,i]),a=S(()=>v.filter(r=>!r.hidden),[v]),k=S(()=>y.map((r,m)=>{let g=Le(r,s.key,m),b=a.map(R=>{let J=De(r,R.key);return{seriesKey:R.key,seriesLabel:ue(R),color:R.color,value:J,formattedValue:J===null?"\u2014":A(J),datum:r}}),x=b.map(R=>R.value).filter(R=>R!==null),re=b[0]?.value??null,ae=b[b.length-1]?.value??null;return{index:m,x:g,label:L(g,m),points:b,from:x.length>0?Math.min(...x):null,to:x.length>0?Math.max(...x):null,change:re===null||ae===null?null:ae-re,datum:r}}),[y,s.key,a,A,L]),N=S(()=>{if(c==="none")return k;let r=D??a[a.length-1]?.key,m=b=>c==="gap"?Math.abs(b.change??0):b.points.find(x=>x.seriesKey===r)?.value??0,g=[...k].sort((b,x)=>m(b)-m(x));return c==="asc"?g:g.reverse()},[k,c,D,a]),ce=O(r=>{M(m=>{let g=new Set(m);return g.has(r)?g.delete(r):g.add(r),g})},[]),te=G??Math.max(96,N.length*30+44),me=S(()=>N.map(r=>({...r.datum,__change:r.change})),[N]),he=h===void 0?t.length>=2:h!==!1,ne=typeof h=="string"?h:"bottom";return o(be,{title:l,description:w,height:te,width:Y,size:W,loading:e,empty:N.length===0||a.length===0,emptyState:Z,error:j,errorState:q,onRetry:p,actions:n,tableView:z,legendPosition:ne,legend:he?o(ye,{items:xe(v),position:ne,marker:"dot",size:W,onToggle:B?ce:void 0}):void 0,table:z?o(pe,{data:me,series:[...v,...H?[{key:"__change",label:I??u.chartChange}]:[]],xKey:s.key,xLabel:s.label??s.key,formatX:L,formatValue:A,caption:typeof l=="string"?l:void 0}):void 0,className:F,...ee,children:({width:r})=>o(ze,{width:r,height:te,data:N.map(m=>m.datum),rows:N,resolvedSeries:v,x:s,y:f,grid:_,size:W,showValues:P,dotSize:K,referenceLines:$,margin:C,tooltip:E,plotLabel:d,formatValue:A,formatX:L,onRowClick:U})})}export{Qe as DumbbellChart,Je as resetDumbbellWarnings};
1
+ "use client";import{memo as he,useCallback as O,useMemo as D,useState as se}from"react";import{useUILabels as ge}from"../../lib/i18n.js";import{ChartAxis as le}from"../chart/ChartAxis.js";import{ChartContainer as be}from"../chart/ChartContainer.js";import{ChartGrid as fe}from"../chart/ChartGrid.js";import{ChartLegend as ye}from"../chart/ChartLegend.js";import{ChartTableView as pe}from"../chart/ChartTableView.js";import{ChartTooltip as Ce,ChartTooltipContent as ve}from"../chart/ChartTooltip.js";import{CHART_ALL_PAIRS_LIMIT as oe,getSeriesLabel as ue,resolveSeriesColor as ke,toLegendItems as xe}from"../chart/palette.js";import{buildCartesianGeometry as Re}from"../chart/utils/cartesian.js";import{collectAllValues as Se,readNumber as De,readXValue as Le}from"../chart/utils/data.js";import{formatAuto as Pe,formatXValue as we}from"../chart/utils/format.js";import{nearestIndex as Te}from"../chart/utils/scales.js";import{estimateTextWidth as Ae}from"../chart/utils/text.js";import{extent as Ve}from"../chart/utils/ticks.js";import{CHART_TOUCH as Ne}from"../chart/utils/touch.js";import{Fragment as ze,jsx as l,jsxs as X}from"react/jsx-runtime";var We=5,Ee=3,ie=10,Q=!1;function et(){Q=!1}var He=he(function({rows:i,radius:p}){return l("g",{children:i.map(t=>X("g",{children:[t.connector?l("line",{x1:t.connector.x1,y1:t.connector.y,x2:t.connector.x2,y2:t.connector.y,strokeWidth:Ee,strokeLinecap:"round",className:"stroke-gray-300 dark:stroke-gray-600"}):null,t.dots.map(s=>l("circle",{cx:s.cx,cy:s.cy,r:p,fill:s.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},s.key)),t.label?l("text",{x:t.label.x,y:t.label.y,dominantBaseline:"middle",className:"fill-gray-600 text-[10px] [font-variant-numeric:tabular-nums] dark:fill-gray-300",children:t.label.text}):null]},t.key))})});function Ie({width:k,height:i,data:p,rows:t,resolvedSeries:s,x:L,y:T,grid:$,size:K,showValues:_,dotSize:Y,referenceLines:W,margin:G,tooltip:g,plotLabel:B,formatValue:E,formatX:H,onRowClick:I}){let[P,A]=se(null),u=P!==null&&P<t.length?P:null,e=D(()=>{let d=s.filter(o=>!o.hidden).map(o=>o.key),c=Re({width:k,height:i,data:p,x:L,y:T,bounds:Ve(Se(p,d)),margin:G,orientation:"horizontal",placement:"band",formatValue:E,formatX:H,defaultIncludeZero:!1}),{valueScale:b,bandwidth:V,categoryPositions:z,innerWidth:U,innerHeight:F}=c;return{rendered:t.map((o,M)=>{let C=z[M]+V/2,w=o.points.map((a,h)=>({key:a.seriesKey,value:a.value,cx:a.value===null?Number.NaN:b(a.value),cy:C,color:a.color,order:h})).filter(a=>a.value!==null),N=o.from===null||o.to===null||w.length<2?null:{x1:b(o.from),x2:b(o.to),y:C},v=null;if(_&&o.to!==null){let a=E(o.to),h=b(o.to);Ae(a,10)<=U-h-ie&&(v={x:h+ie,y:C,text:a})}return{key:`${M}`,connector:N,dots:w.map(a=>({key:a.key,cx:a.cx,cy:a.cy,color:a.color})),label:v,top:z[M],height:V}}),categoryPositions:z,categoryCenters:c.categoryCenters,bandwidth:V,categoryTicks:c.categoryTicks,valueTicks:c.valueTicks,valueScale:b,innerWidth:U,innerHeight:F,margin:c.margin}},[p,t,s,L,T,k,i,G,_,E,H]),Z=O(n=>{if(g===!1||t.length===0)return;let d=n.currentTarget.getBoundingClientRect(),c=n.clientY-d.top-e.margin.top;A(Te(e.categoryCenters,c))},[g,t.length,e.margin.top,e.categoryCenters]),j=O(n=>{if(t.length===0)return;let d=t.length-1,c=u??0,b=n.key==="ArrowDown"?Math.min(d,c+1):n.key==="ArrowUp"?Math.max(0,c-1):n.key==="Home"?0:n.key==="End"?d:n.key==="Escape"?null:void 0;b!==void 0&&(n.preventDefault(),A(b))},[t.length,u]),q=O(()=>{!I||u===null||I(t[u])},[I,u,t]),x=u===null?null:t[u];return X(ze,{children:[X("svg",{width:k,height:i,role:"img","aria-label":B??s.map(n=>ue(n)).join(", "),tabIndex:0,className:`${Ne} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500`,onPointerMove:Z,onPointerLeave:()=>A(null),onKeyDown:j,onBlur:()=>A(null),onClick:q,children:[X("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[l(fe,{width:e.innerWidth,height:e.innerHeight,vertical:$==="y"||$==="both"?e.valueTicks.map(n=>n.offset):void 0}),u!==null?l("rect",{x:0,y:e.categoryPositions[u],width:e.innerWidth,height:e.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,W?.map(n=>X("g",{children:[l("line",{x1:e.valueScale(n.value),y1:0,x2:e.valueScale(n.value),y2:e.innerHeight,stroke:n.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:n.dashed===!1?void 0:"4 4"}),n.label?l("text",{x:e.valueScale(n.value)+4,y:8,className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:n.label}):null]},`${n.value}-${n.label??""}`)),l(He,{rows:e.rendered,radius:Y})]}),l("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:T?.hidden?null:l(le,{orientation:"bottom",ticks:e.valueTicks,length:e.innerWidth,label:T?.label,size:K})}),l("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:L.hidden?null:l(le,{orientation:"left",ticks:e.categoryTicks,length:e.innerHeight,showLine:!1,tickSize:0,label:L.label,size:K})})]}),x&&u!==null&&g!==!1?l(Ce,{x:e.margin.left+(x.to===null?e.innerWidth/2:e.valueScale(x.to)),y:e.margin.top+e.categoryCenters[u],containerWidth:k,children:typeof g=="function"?g(x):l(ve,{title:x.label,points:x.points})}):null]})}function tt({data:k,x:i,y:p,series:t,sort:s="none",sortBy:L,showValues:T=!1,dotSize:$=We,referenceLines:K,height:_,width:Y,size:W="md",grid:G="y",legend:g,legendToggle:B=!0,tooltip:E=!0,tableView:H=!1,showChange:I=!0,title:P,description:A,loading:u=!1,emptyState:e,error:Z=!1,errorState:j,onRetry:q,actions:x,margin:n,locale:d,plotLabel:c,changeLabel:b,format:V,onRowClick:z,className:U,...F}){let ee=ge(),[o,M]=se(()=>new Set);t.length>oe&&!Q&&(Q=!0,console.warn(`[@synertech/ui] A DumbbellChart was given ${t.length} series. Any two dots of a row can sit side by side, and only the first ${oe} palette slots stay tellable apart under that test: facet the chart instead.`));let C=D(()=>t.map((r,m)=>({...r,hidden:r.hidden||o.has(r.key),color:ke(r,m)})),[t,o]),w=D(()=>p?.format??V??(r=>Pe(r,d)),[p?.format,V,d]),N=D(()=>i.format??(r=>we(r,d)),[i.format,d]),v=D(()=>C.filter(r=>!r.hidden),[C]),a=D(()=>k.map((r,m)=>{let f=Le(r,i.key,m),y=v.map(S=>{let J=De(r,S.key);return{seriesKey:S.key,seriesLabel:ue(S),color:S.color,value:J,formattedValue:J===null?"\u2014":w(J),datum:r}}),R=y.map(S=>S.value).filter(S=>S!==null),re=y[0]?.value??null,ae=y[y.length-1]?.value??null;return{index:m,x:f,label:N(f,m),points:y,from:R.length>0?Math.min(...R):null,to:R.length>0?Math.max(...R):null,change:re===null||ae===null?null:ae-re,datum:r}}),[k,i.key,v,w,N]),h=D(()=>{if(s==="none")return a;let r=L??v[v.length-1]?.key,m=y=>s==="gap"?Math.abs(y.change??0):y.points.find(R=>R.seriesKey===r)?.value??0,f=[...a].sort((y,R)=>m(y)-m(R));return s==="asc"?f:f.reverse()},[a,s,L,v]),ce=O(r=>{M(m=>{let f=new Set(m);return f.has(r)?f.delete(r):f.add(r),f})},[]),te=_??Math.max(96,h.length*30+44),me=D(()=>h.map(r=>({...r.datum,__change:r.change})),[h]),de=g===void 0?t.length>=2:g!==!1,ne=typeof g=="string"?g:"bottom";return l(be,{title:P,description:A,height:te,width:Y,size:W,loading:u,empty:h.length===0||v.length===0,emptyState:e,error:Z,errorState:j,onRetry:q,actions:x,tableView:H,legendPosition:ne,legend:de?l(ye,{items:xe(C),position:ne,marker:"dot",size:W,onToggle:B?ce:void 0}):void 0,table:H?l(pe,{data:me,series:[...C,...I?[{key:"__change",label:b??ee.chartChange}]:[]],xKey:i.key,xLabel:i.label??i.key,formatX:N,formatValue:w,caption:typeof P=="string"?P:void 0}):void 0,className:U,...F,children:({width:r})=>l(Ie,{width:r,height:te,data:h.map(m=>m.datum),rows:h,resolvedSeries:C,x:i,y:p,grid:G,size:W,showValues:T,dotSize:$,referenceLines:K,margin:n,tooltip:E,plotLabel:c,formatValue:w,formatX:N,onRowClick:z})})}export{tt as DumbbellChart,et as resetDumbbellWarnings};
@@ -1 +1 @@
1
- "use strict";"use client";var J=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var ue=Object.getOwnPropertyNames;var me=Object.prototype.hasOwnProperty;var ce=(o,n)=>{for(var t in n)J(o,t,{get:n[t],enumerable:!0})},de=(o,n,t,b)=>{if(n&&typeof n=="object"||typeof n=="function")for(let g of ue(n))!me.call(o,g)&&g!==t&&J(o,g,{get:()=>n[g],enumerable:!(b=se(n,g))||b.enumerable});return o};var fe=o=>de(J({},"__esModule",{value:!0}),o);var xe={};ce(xe,{FunnelChart:()=>ye});module.exports=fe(xe);var c=require("react"),Z=require("../../lib/i18n.cjs"),ee=require("../chart/ChartAxis.cjs"),te=require("../chart/ChartContainer.cjs"),ne=require("../chart/ChartTooltip.cjs"),P=require("../chart/palette.cjs"),F=require("../chart/utils/data.cjs"),x=require("../chart/utils/format.cjs"),re=require("../chart/utils/path.cjs"),A=require("../chart/utils/scales.cjs"),W=require("../chart/utils/text.cjs"),ae=require("../table/Table.cjs"),le=require("../table/TableBody.cjs"),z=require("../table/TableCell.cjs"),oe=require("../table/TableHeader.cjs"),B=require("../table/TableHeaderCell.cjs"),ie=require("../table/TableRow.cjs"),e=require("react/jsx-runtime"),he=8,pe=12,be=44,Q="text-right [font-variant-numeric:tabular-nums]",ge=(0,c.memo)(function({stages:n}){return(0,e.jsx)("g",{children:n.map(t=>(0,e.jsxs)("g",{children:[(0,e.jsx)("path",{d:t.d,fill:t.color}),t.value?(0,e.jsx)("text",{x:t.value.x,y:t.value.y,textAnchor:t.value.anchor,dominantBaseline:"middle",className:t.value.inside?t.value.onDark?"fill-gray-50 text-[11px] font-semibold [font-variant-numeric:tabular-nums] dark:fill-gray-900":"fill-gray-900 text-[11px] font-semibold [font-variant-numeric:tabular-nums] dark:fill-gray-50":"fill-gray-700 text-[11px] font-semibold [font-variant-numeric:tabular-nums] dark:fill-gray-200",children:t.value.text}):null,t.conversion?(0,e.jsx)("text",{x:t.conversion.x,y:t.conversion.y,textAnchor:"middle",dominantBaseline:"middle",className:"fill-gray-500 text-[10px] [font-variant-numeric:tabular-nums] dark:fill-gray-400",children:t.conversion.text}):null]},t.key))})});function ve({width:o,height:n,stages:t,x:b,size:g,align:E,showConversion:H,showValues:w,stageSize:I,ramp:M,tooltip:C,plotLabel:G,locale:k,onStageClick:S}){let[s,L]=(0,c.useState)(null),K=(0,Z.useUILabels)(),r=(0,c.useMemo)(()=>{let m=t.map(i=>i.label),d={top:6,right:12,bottom:6,left:b.hidden?8:b.height??(0,W.widestLabel)(m)+pe},h=Math.max(0,o-d.left-d.right),T=Math.max(0,n-d.top-d.bottom),f=(0,A.createBandScale)(t.map((i,l)=>l),[0,T],{paddingInner:H?.45:.28}),N=Math.min(I??be,f.bandwidth),Y=Math.max(0,...t.map(i=>i.value??0)),j=(0,A.createLinearScale)([0,Y],[0,h]),O=t.map((i,l)=>{let R=i.value===null?0:Math.max(0,j(i.value)),V=E==="center"?(h-R)/2:0,a=f(l)+(f.bandwidth-N)/2,D=a+N/2,v=null;if(w&&i.value!==null){let y=i.formattedValue;v=(0,W.estimateTextWidth)(y,11)+16<=R?{x:V+R/2,y:D,anchor:"middle",text:y,inside:!0,onDark:M.onDark(l)}:{x:V+R+he,y:D,anchor:"start",text:y,inside:!1,onDark:!1}}let X=f(l-1)+(f.bandwidth-N)/2+N,p=H&&i.conversion!==null&&l>0?{x:h/2,y:(X+a)/2,text:(0,x.formatPercent)(i.conversion,{locale:k,maximumFractionDigits:0})}:null;return{key:`${l}`,d:(0,re.buildBarPath)({x:V,y:a,width:R,height:N,radius:4,round:E==="center"?"none":"right"}),color:M(l),value:v,conversion:p,top:f(l),height:f.bandwidth}}),_=b.hidden?[]:t.map((i,l)=>({value:i.x,offset:f.center(l),label:i.label}));return{margin:d,innerWidth:h,innerHeight:T,rendered:O,stageTicks:_,centers:t.map((i,l)=>f.center(l))}},[t,b,o,n,E,H,w,I,M,k]),U=(0,c.useCallback)(m=>{if(C===!1||t.length===0)return;let d=m.currentTarget.getBoundingClientRect(),h=m.clientY-d.top-r.margin.top;L((0,A.nearestIndex)(r.centers,h))},[C,t.length,r.margin.top,r.centers]),$=(0,c.useCallback)(m=>{if(t.length===0)return;let d=t.length-1,h=s??0,T=m.key==="ArrowDown"?Math.min(d,h+1):m.key==="ArrowUp"?Math.max(0,h-1):m.key==="Home"?0:m.key==="End"?d:m.key==="Escape"?null:void 0;T!==void 0&&(m.preventDefault(),L(T))},[t.length,s]),q=(0,c.useCallback)(()=>{!S||s===null||S(t[s])},[S,s,t]),u=s===null?null:t[s];return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("svg",{width:o,height:n,role:"img","aria-label":G??t.map(m=>m.label).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:U,onPointerLeave:()=>L(null),onKeyDown:$,onBlur:()=>L(null),onClick:q,children:[(0,e.jsxs)("g",{transform:`translate(${r.margin.left}, ${r.margin.top})`,children:[s!==null&&r.rendered[s]?(0,e.jsx)("rect",{x:-4,y:r.rendered[s].top,width:r.innerWidth+8,height:r.rendered[s].height,rx:4,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,(0,e.jsx)(ge,{stages:r.rendered})]}),(0,e.jsx)("g",{transform:`translate(${r.margin.left}, ${r.margin.top})`,children:b.hidden?null:(0,e.jsx)(ee.ChartAxis,{orientation:"left",ticks:r.stageTicks,length:r.innerHeight,showLine:!1,tickSize:0,size:g})})]}),u&&s!==null&&C!==!1?(0,e.jsx)(ne.ChartTooltip,{x:r.margin.left+r.innerWidth/2,y:r.margin.top+r.centers[s],containerWidth:o,children:typeof C=="function"?C(u):(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:u.label}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"h-2.5 w-2.5 shrink-0 rounded-sm",style:{backgroundColor:r.rendered[s]?.color},"aria-hidden":"true"}),(0,e.jsx)("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:u.formattedValue})]}),u.conversion!==null?(0,e.jsxs)("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[(0,e.jsx)("span",{children:K.chartConversion}),(0,e.jsx)("span",{className:"[font-variant-numeric:tabular-nums]",children:(0,x.formatPercent)(u.conversion,{locale:k,maximumFractionDigits:1})})]}):null,u.overall!==null?(0,e.jsxs)("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[(0,e.jsx)("span",{children:t[0]?.label}),(0,e.jsx)("span",{className:"[font-variant-numeric:tabular-nums]",children:(0,x.formatPercent)(u.overall,{locale:k,maximumFractionDigits:1})})]}):null]})}):null]})}function ye({data:o,x:n,value:t,align:b="center",showConversion:g=!0,showValues:E=!0,stageSize:H,colors:w,height:I,width:M,size:C="md",tooltip:G=!0,tableView:k=!1,title:S,description:s,loading:L=!1,emptyState:K,error:r=!1,errorState:U,onRetry:$,actions:q,locale:u,plotLabel:m,valueLabel:d,conversionLabel:h,dropOffLabel:T,format:f,onStageClick:N,className:Y,...j}){let O=(0,Z.useUILabels)(),_=(0,c.useMemo)(()=>f??(a=>(0,x.formatAuto)(a,u)),[f,u]),i=(0,c.useMemo)(()=>n.format??(a=>(0,x.formatXValue)(a,u)),[n.format,u]),l=(0,c.useMemo)(()=>{let a=(0,F.readNumber)(o[0]??{},t);return o.map((D,v)=>{let X=(0,F.readXValue)(D,n.key,v),p=(0,F.readNumber)(D,t),y=v===0?null:(0,F.readNumber)(o[v-1],t);return{index:v,x:X,label:i(X,v),value:p,overall:v===0||a===null||a===0||p===null?null:p/a,conversion:y===null||y===0||p===null?null:p/y,dropOff:y===null||p===null?null:y-p,formattedValue:p===null?"\u2014":_(p),datum:D}})},[o,n.key,t,_,i]),R=(0,c.useMemo)(()=>(0,P.createSequentialScale)([0,Math.max(1,l.length-1)],{colors:w??P.CHART_ORDINAL_COLORS,...w?{}:{darkStops:P.CHART_ORDINAL_DARK_STOPS}}),[l.length,w]),V=I??Math.max(96,l.length*(g?56:44)+12);return(0,e.jsx)(te.ChartContainer,{title:S,description:s,height:V,width:M,size:C,loading:L,empty:l.length===0,emptyState:K,error:r,errorState:U,onRetry:$,actions:q,tableView:k,table:k?(0,e.jsx)("div",{className:"w-full overflow-x-auto",children:(0,e.jsxs)(ae.Table,{children:[typeof S=="string"?(0,e.jsx)("caption",{className:"sr-only",children:S}):null,(0,e.jsxs)(oe.TableHeader,{children:[(0,e.jsx)(B.TableHeaderCell,{children:n.label??n.key}),(0,e.jsx)(B.TableHeaderCell,{className:"text-right",children:d??O.chartValue}),(0,e.jsx)(B.TableHeaderCell,{className:"text-right",children:h??O.chartConversion}),(0,e.jsx)(B.TableHeaderCell,{className:"text-right",children:T??O.chartDropOff})]}),(0,e.jsx)(le.TableBody,{children:l.map(a=>(0,e.jsxs)(ie.TableRow,{clickable:!1,children:[(0,e.jsx)(z.TableCell,{className:"font-medium text-gray-900 dark:text-gray-100",children:a.label}),(0,e.jsx)(z.TableCell,{className:Q,children:a.formattedValue}),(0,e.jsx)(z.TableCell,{className:Q,children:a.conversion===null?"\u2014":(0,x.formatPercent)(a.conversion,{locale:u,maximumFractionDigits:1})}),(0,e.jsx)(z.TableCell,{className:Q,children:a.dropOff===null?"\u2014":_(a.dropOff)})]},a.index))})]})}):void 0,className:Y,...j,children:({width:a})=>(0,e.jsx)(ve,{width:a,height:V,stages:l,x:n,size:C,align:b,showConversion:g,showValues:E,stageSize:H,ramp:R,tooltip:G,plotLabel:m,locale:u,onStageClick:N})})}0&&(module.exports={FunnelChart});
1
+ "use strict";"use client";var Q=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var ce=Object.getOwnPropertyNames;var de=Object.prototype.hasOwnProperty;var fe=(o,n)=>{for(var t in n)Q(o,t,{get:n[t],enumerable:!0})},he=(o,n,t,p)=>{if(n&&typeof n=="object"||typeof n=="function")for(let b of ce(n))!de.call(o,b)&&b!==t&&Q(o,b,{get:()=>n[b],enumerable:!(p=me(n,b))||p.enumerable});return o};var pe=o=>he(Q({},"__esModule",{value:!0}),o);var ke={};fe(ke,{FunnelChart:()=>Ce});module.exports=pe(ke);var m=require("react"),ee=require("../../lib/i18n.cjs"),te=require("../chart/ChartAxis.cjs"),ne=require("../chart/ChartContainer.cjs"),re=require("../chart/ChartTooltip.cjs"),A=require("../chart/palette.cjs"),P=require("../chart/utils/data.cjs"),y=require("../chart/utils/format.cjs"),ae=require("../chart/utils/path.cjs"),F=require("../chart/utils/scales.cjs"),K=require("../chart/utils/text.cjs"),le=require("../chart/utils/touch.cjs"),oe=require("../table/Table.cjs"),ie=require("../table/TableBody.cjs"),B=require("../table/TableCell.cjs"),se=require("../table/TableHeader.cjs"),X=require("../table/TableHeaderCell.cjs"),ue=require("../table/TableRow.cjs"),e=require("react/jsx-runtime"),be=8,ge=12,ve=44,Z="text-right [font-variant-numeric:tabular-nums]",ye=(0,m.memo)(function({stages:n}){return(0,e.jsx)("g",{children:n.map(t=>(0,e.jsxs)("g",{children:[(0,e.jsx)("path",{d:t.d,fill:t.color}),t.value?(0,e.jsx)("text",{x:t.value.x,y:t.value.y,textAnchor:t.value.anchor,dominantBaseline:"middle",className:t.value.inside?t.value.onDark?"fill-gray-50 text-[11px] font-semibold [font-variant-numeric:tabular-nums] dark:fill-gray-900":"fill-gray-900 text-[11px] font-semibold [font-variant-numeric:tabular-nums] dark:fill-gray-50":"fill-gray-700 text-[11px] font-semibold [font-variant-numeric:tabular-nums] dark:fill-gray-200",children:t.value.text}):null,t.conversion?(0,e.jsx)("text",{x:t.conversion.x,y:t.conversion.y,textAnchor:"middle",dominantBaseline:"middle",className:"fill-gray-500 text-[10px] [font-variant-numeric:tabular-nums] dark:fill-gray-400",children:t.conversion.text}):null]},t.key))})});function xe({width:o,height:n,stages:t,x:p,size:b,align:E,showConversion:H,showValues:V,stageSize:W,ramp:M,tooltip:x,plotLabel:U,locale:T,onStageClick:N}){let[O,D]=(0,m.useState)(null),i=O!==null&&O<t.length?O:null,$=(0,ee.useUILabels)(),r=(0,m.useMemo)(()=>{let s=t.map(a=>a.label),c={top:6,right:12,bottom:6,left:p.hidden?8:p.height??(0,K.widestLabel)(s)+ge},d=Math.max(0,o-c.left-c.right),k=Math.max(0,n-c.top-c.bottom),f=(0,F.createBandScale)(t.map((a,u)=>u),[0,k],{paddingInner:H?.45:.28}),R=Math.min(W??ve,f.bandwidth),j=Math.max(0,...t.map(a=>a.value??0)),_=(0,F.createLinearScale)([0,j],[0,d]),I=t.map((a,u)=>{let S=a.value===null?0:Math.max(0,_(a.value)),l=E==="center"?(d-S)/2:0,w=f(u)+(f.bandwidth-R)/2,v=w+R/2,z=null;if(V&&a.value!==null){let J=a.formattedValue;z=(0,K.estimateTextWidth)(J,11)+16<=S?{x:l+S/2,y:v,anchor:"middle",text:J,inside:!0,onDark:M.onDark(u)}:{x:l+S+be,y:v,anchor:"start",text:J,inside:!1,onDark:!1}}let h=f(u-1)+(f.bandwidth-R)/2+R,L=H&&a.conversion!==null&&u>0?{x:d/2,y:(h+w)/2,text:(0,y.formatPercent)(a.conversion,{locale:T,maximumFractionDigits:0})}:null;return{key:`${u}`,d:(0,ae.buildBarPath)({x:l,y:w,width:S,height:R,radius:4,round:E==="center"?"none":"right"}),color:M(u),value:z,conversion:L,top:f(u),height:f.bandwidth}}),G=p.hidden?[]:t.map((a,u)=>({value:a.x,offset:f.center(u),label:a.label}));return{margin:c,innerWidth:d,innerHeight:k,rendered:I,stageTicks:G,centers:t.map((a,u)=>f.center(u))}},[t,p,o,n,E,H,V,W,M,T]),q=(0,m.useCallback)(s=>{if(x===!1||t.length===0)return;let c=s.currentTarget.getBoundingClientRect(),d=s.clientY-c.top-r.margin.top;D((0,F.nearestIndex)(r.centers,d))},[x,t.length,r.margin.top,r.centers]),Y=(0,m.useCallback)(s=>{if(t.length===0)return;let c=t.length-1,d=i??0,k=s.key==="ArrowDown"?Math.min(c,d+1):s.key==="ArrowUp"?Math.max(0,d-1):s.key==="Home"?0:s.key==="End"?c:s.key==="Escape"?null:void 0;k!==void 0&&(s.preventDefault(),D(k))},[t.length,i]),C=(0,m.useCallback)(()=>{!N||i===null||N(t[i])},[N,i,t]),g=i===null?null:t[i];return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("svg",{width:o,height:n,role:"img","aria-label":U??t.map(s=>s.label).join(", "),tabIndex:0,className:`${le.CHART_TOUCH} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500`,onPointerMove:q,onPointerLeave:()=>D(null),onKeyDown:Y,onBlur:()=>D(null),onClick:C,children:[(0,e.jsxs)("g",{transform:`translate(${r.margin.left}, ${r.margin.top})`,children:[i!==null&&r.rendered[i]?(0,e.jsx)("rect",{x:-4,y:r.rendered[i].top,width:r.innerWidth+8,height:r.rendered[i].height,rx:4,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,(0,e.jsx)(ye,{stages:r.rendered})]}),(0,e.jsx)("g",{transform:`translate(${r.margin.left}, ${r.margin.top})`,children:p.hidden?null:(0,e.jsx)(te.ChartAxis,{orientation:"left",ticks:r.stageTicks,length:r.innerHeight,showLine:!1,tickSize:0,size:b})})]}),g&&i!==null&&x!==!1?(0,e.jsx)(re.ChartTooltip,{x:r.margin.left+r.innerWidth/2,y:r.margin.top+r.centers[i],containerWidth:o,children:typeof x=="function"?x(g):(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:g.label}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"h-2.5 w-2.5 shrink-0 rounded-sm",style:{backgroundColor:r.rendered[i]?.color},"aria-hidden":"true"}),(0,e.jsx)("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:g.formattedValue})]}),g.conversion!==null?(0,e.jsxs)("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[(0,e.jsx)("span",{children:$.chartConversion}),(0,e.jsx)("span",{className:"[font-variant-numeric:tabular-nums]",children:(0,y.formatPercent)(g.conversion,{locale:T,maximumFractionDigits:1})})]}):null,g.overall!==null?(0,e.jsxs)("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[(0,e.jsx)("span",{children:t[0]?.label}),(0,e.jsx)("span",{className:"[font-variant-numeric:tabular-nums]",children:(0,y.formatPercent)(g.overall,{locale:T,maximumFractionDigits:1})})]}):null]})}):null]})}function Ce({data:o,x:n,value:t,align:p="center",showConversion:b=!0,showValues:E=!0,stageSize:H,colors:V,height:W,width:M,size:x="md",tooltip:U=!0,tableView:T=!1,title:N,description:O,loading:D=!1,emptyState:i,error:$=!1,errorState:r,onRetry:q,actions:Y,locale:C,plotLabel:g,valueLabel:s,conversionLabel:c,dropOffLabel:d,format:k,onStageClick:f,className:R,...j}){let _=(0,ee.useUILabels)(),I=(0,m.useMemo)(()=>k??(l=>(0,y.formatAuto)(l,C)),[k,C]),G=(0,m.useMemo)(()=>n.format??(l=>(0,y.formatXValue)(l,C)),[n.format,C]),a=(0,m.useMemo)(()=>{let l=(0,P.readNumber)(o[0]??{},t);return o.map((w,v)=>{let z=(0,P.readXValue)(w,n.key,v),h=(0,P.readNumber)(w,t),L=v===0?null:(0,P.readNumber)(o[v-1],t);return{index:v,x:z,label:G(z,v),value:h,overall:v===0||l===null||l===0||h===null?null:h/l,conversion:L===null||L===0||h===null?null:h/L,dropOff:L===null||h===null?null:L-h,formattedValue:h===null?"\u2014":I(h),datum:w}})},[o,n.key,t,I,G]),u=(0,m.useMemo)(()=>(0,A.createSequentialScale)([0,Math.max(1,a.length-1)],{colors:V??A.CHART_ORDINAL_COLORS,...V?{}:{darkStops:A.CHART_ORDINAL_DARK_STOPS}}),[a.length,V]),S=W??Math.max(96,a.length*(b?56:44)+12);return(0,e.jsx)(ne.ChartContainer,{title:N,description:O,height:S,width:M,size:x,loading:D,empty:a.length===0,emptyState:i,error:$,errorState:r,onRetry:q,actions:Y,tableView:T,table:T?(0,e.jsx)("div",{className:"w-full overflow-x-auto",children:(0,e.jsxs)(oe.Table,{children:[typeof N=="string"?(0,e.jsx)("caption",{className:"sr-only",children:N}):null,(0,e.jsxs)(se.TableHeader,{children:[(0,e.jsx)(X.TableHeaderCell,{children:n.label??n.key}),(0,e.jsx)(X.TableHeaderCell,{className:"text-right",children:s??_.chartValue}),(0,e.jsx)(X.TableHeaderCell,{className:"text-right",children:c??_.chartConversion}),(0,e.jsx)(X.TableHeaderCell,{className:"text-right",children:d??_.chartDropOff})]}),(0,e.jsx)(ie.TableBody,{children:a.map(l=>(0,e.jsxs)(ue.TableRow,{clickable:!1,children:[(0,e.jsx)(B.TableCell,{className:"font-medium text-gray-900 dark:text-gray-100",children:l.label}),(0,e.jsx)(B.TableCell,{className:Z,children:l.formattedValue}),(0,e.jsx)(B.TableCell,{className:Z,children:l.conversion===null?"\u2014":(0,y.formatPercent)(l.conversion,{locale:C,maximumFractionDigits:1})}),(0,e.jsx)(B.TableCell,{className:Z,children:l.dropOff===null?"\u2014":I(l.dropOff)})]},l.index))})]})}):void 0,className:R,...j,children:({width:l})=>(0,e.jsx)(xe,{width:l,height:S,stages:a,x:n,size:x,align:p,showConversion:b,showValues:E,stageSize:H,ramp:u,tooltip:U,plotLabel:g,locale:C,onStageClick:f})})}0&&(module.exports={FunnelChart});