@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 te=Object.defineProperty;var he=Object.getOwnPropertyDescriptor;var fe=Object.getOwnPropertyNames;var ge=Object.prototype.hasOwnProperty;var ye=(s,o)=>{for(var r in o)te(s,r,{get:o[r],enumerable:!0})},pe=(s,o,r,v)=>{if(o&&typeof o=="object"||typeof o=="function")for(let d of fe(o))!ge.call(s,d)&&d!==r&&te(s,d,{get:()=>o[d],enumerable:!(v=he(o,d))||v.enumerable});return s};var be=s=>pe(te({},"__esModule",{value:!0}),s);var Ve={};ye(Ve,{ScatterChart:()=>ke,resetScatterWarnings:()=>Pe});module.exports=be(Ve);var g=require("react"),re=require("../chart/ChartAxis.cjs"),se=require("../chart/ChartContainer.cjs"),le=require("../chart/ChartGrid.cjs"),ce=require("../chart/ChartLegend.cjs"),ue=require("../chart/ChartTableView.cjs"),U=require("../chart/ChartTooltip.cjs"),C=require("../chart/palette.cjs"),H=require("../chart/utils/cartesian.cjs"),D=require("../chart/utils/data.cjs"),j=require("../chart/utils/decimate.cjs"),G=require("../chart/utils/format.cjs"),F=require("../chart/utils/scales.cjs"),ne=require("../chart/utils/ticks.cjs"),i=require("react/jsx-runtime"),xe=4.5,Ce=48,ie=!1,ve=(0,g.memo)(function({points:o}){return(0,i.jsx)("g",{children:o.map(r=>(0,i.jsx)("circle",{cx:r.cx,cy:r.cy,r:r.r,fill:r.color,fillOpacity:.85,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},`${r.seriesKey}-${r.index}`))})});function Se({width:s,height:o,data:r,resolvedSeries:v,x:d,y:X,grid:V,size:N,bubble:y,trendLine:O,quadrants:K,pointRadius:M,overlay:E,maxPoints:R,margin:Y,tooltip:T,onPointClick:I,plotLabel:J,formatValue:S,formatX:w}){let[t,z]=(0,g.useState)(null),e=(0,g.useMemo)(()=>{let a=v.filter(c=>!c.hidden),$=a.map(c=>c.key),l=(0,H.buildCartesianGeometry)({width:s,height:o,data:r,x:{...d,scale:d.scale==="time"?"time":"linear"},y:X,bounds:(0,ne.extent)((0,D.collectAllValues)(r,$)),margin:Y,formatValue:S,formatX:w}),k=y?(0,D.collectAllValues)(r,[y.key]):[],A=y?(0,ne.extent)(k):null,[x,L]=y?.range??[4,14],W=c=>{if(!y||!A)return M;let m=(0,D.readNumber)(c,y.key);if(m===null)return x;let[p,b]=A,P=b===p?1:(m-p)/(b-p);return Math.sqrt(x*x+P*(L*L-x*x))},q=[],f=[];a.forEach(c=>{let m=[];r.forEach((p,b)=>{let P=(0,D.readNumber)(p,c.key),n=l.categoryPositions[b];P===null||!Number.isFinite(n)||m.push({seriesKey:c.key,seriesLabel:(0,C.getSeriesLabel)(c),color:c.color,index:b,cx:n,cy:l.valueScale(P),r:W(p),xValue:(0,F.toNumber)(l.xValues[b]),yValue:P})}),R||(0,j.warnPointBudget)("ScatterChart",m.length),f.push(...m),q.push(...R&&R>0?(0,j.sampleEvenly)(m,R):m)});let B=null;if(O&&f.length>1){let c=f.length,m=f.reduce((h,u)=>h+u.xValue,0),p=f.reduce((h,u)=>h+u.yValue,0),b=f.reduce((h,u)=>h+u.xValue*u.yValue,0),P=f.reduce((h,u)=>h+u.xValue*u.xValue,0),n=c*P-m*m;if(n!==0){let h=(c*b-m*p)/n,u=(p-h*m)/c,oe=f.map(ee=>ee.xValue),[de,me]=[Math.min(...oe),Math.max(...oe)],ae=f.map(ee=>ee.cx);B={x1:Math.min(...ae),y1:l.valueScale(h*de+u),x2:Math.max(...ae),y2:l.valueScale(h*me+u)}}}return{visible:a,points:q,plot:(0,H.createPlotContext)({geometry:l,width:s,height:o,data:r,series:a,formatValue:S,formatX:w}),trend:B,xTicks:l.categoryTicks,yTicks:l.valueTicks,valueScale:l.valueScale,positions:l.categoryPositions,innerWidth:l.innerWidth,innerHeight:l.innerHeight,margin:l.margin,xValues:l.xValues}},[r,v,d,X,s,o,Y,y,O,M,R,S,w]),Q=(0,g.useCallback)(a=>{if(T===!1||e.points.length===0)return;let $=a.currentTarget.getBoundingClientRect(),l=a.clientX-$.left-e.margin.left,k=a.clientY-$.top-e.margin.top,A=null,x=Ce;for(let L of e.points){let W=Math.hypot(L.cx-l,L.cy-k);W<x&&(x=W,A=L)}z(A)},[T,e.points,e.margin]),Z=(0,g.useCallback)(()=>{if(!I||!t)return;let a=r[t.index];a&&I({seriesKey:t.seriesKey,seriesLabel:t.seriesLabel,color:t.color,value:t.yValue,formattedValue:S(t.yValue),datum:a,index:t.index,x:e.xValues[t.index]})},[I,t,S,r,e.xValues]),_=(0,H.splitOverlay)(E);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("svg",{width:s,height:o,role:"img","aria-label":J??e.visible.map(a=>(0,C.getSeriesLabel)(a)).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:Q,onPointerLeave:()=>z(null),onBlur:()=>z(null),onClick:Z,children:[(0,i.jsxs)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[(0,i.jsx)(le.ChartGrid,{width:e.innerWidth,height:e.innerHeight,horizontal:V==="y"||V==="both"?e.yTicks.map(a=>a.offset):void 0,vertical:V==="x"||V==="both"?e.xTicks.map(a=>a.offset):void 0}),K?.y!==void 0?(0,i.jsx)("line",{x1:0,y1:e.valueScale(K.y),x2:e.innerWidth,y2:e.valueScale(K.y),stroke:"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:"4 4"}):null,_.under?.(e.plot),e.trend?(0,i.jsx)("line",{x1:e.trend.x1,y1:e.trend.y1,x2:e.trend.x2,y2:e.trend.y2,stroke:"var(--color-chart-muted)",strokeWidth:1.5,strokeDasharray:"4 4"}):null,(0,i.jsx)(ve,{points:e.points}),_.over?.(e.plot),t?(0,i.jsx)("circle",{cx:t.cx,cy:t.cy,r:t.r+3,fill:"none",stroke:t.color,strokeWidth:2,"aria-hidden":"true"}):null]}),(0,i.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:d.hidden?null:(0,i.jsx)(re.ChartAxis,{orientation:"bottom",ticks:e.xTicks,length:e.innerWidth,label:d.label,size:N})}),(0,i.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:X?.hidden?null:(0,i.jsx)(re.ChartAxis,{orientation:"left",ticks:e.yTicks,length:e.innerHeight,showLine:!1,label:X?.label,size:N})})]}),t&&r[t.index]&&T!==!1?(0,i.jsx)(U.ChartTooltip,{x:e.margin.left+t.cx,y:e.margin.top+t.cy,containerWidth:s,children:typeof T=="function"?T({x:e.xValues[t.index],xLabel:w(e.xValues[t.index],t.index),index:t.index,points:[{seriesKey:t.seriesKey,seriesLabel:t.seriesLabel,color:t.color,value:t.yValue,formattedValue:S(t.yValue),datum:r[t.index]}]}):(0,i.jsx)(U.ChartTooltipContent,{title:`${d.label??d.key} ${w(e.xValues[t.index],t.index)}`,points:[{seriesKey:t.seriesKey,seriesLabel:t.seriesLabel,color:t.color,value:t.yValue,formattedValue:S(t.yValue),datum:r[t.index]}]})}):null]})}function ke({data:s,series:o,x:r,y:v,height:d=280,width:X,size:V="md",grid:N="both",legend:y,tooltip:O=!0,tableView:K=!1,emphasis:M,title:E,description:R,loading:Y=!1,emptyState:T,error:I=!1,errorState:J,onRetry:S,actions:w,onPointClick:t,bubble:z,trendLine:e=!1,quadrants:Q,pointRadius:Z=xe,overlay:_,legendToggle:a=!0,maxPoints:$,margin:l,locale:k,plotLabel:A,className:x,...L}){let[W,q]=(0,g.useState)(()=>new Set);o.length>C.CHART_ALL_PAIRS_LIMIT&&!ie&&(ie=!0,console.warn(`[@synertech/ui] A ScatterChart was given ${o.length} series. Any two marks can sit side by side here, and only the first ${C.CHART_ALL_PAIRS_LIMIT} palette slots stay tellable apart under that test: facet the chart instead.`));let f=(0,g.useMemo)(()=>o.map((n,h)=>({...n,hidden:n.hidden||W.has(n.key),color:(0,C.resolveSeriesColor)(n,h,M)})),[o,W,M]),B=(0,g.useMemo)(()=>v?.format??(n=>(0,G.formatAuto)(n,k)),[v?.format,k]),c=(0,g.useMemo)(()=>r.format??(n=>r.scale==="time"?(0,G.formatXValue)(n instanceof Date?n:new Date((0,F.toNumber)(n)),k):(0,G.formatAuto)((0,F.toNumber)(n),k)),[r.format,r.scale,k]),m=(0,g.useCallback)(n=>{q(h=>{let u=new Set(h);return u.has(n)?u.delete(n):u.add(n),u})},[]),p=y===void 0?o.length>=2:y!==!1,b=typeof y=="string"?y:"bottom",P=f.filter(n=>!n.hidden).length;return(0,i.jsx)(se.ChartContainer,{title:E,description:R,height:d,width:X,size:V,loading:Y,empty:s.length===0||P===0,emptyState:T,error:I,errorState:J,onRetry:S,actions:w,tableView:K,legendPosition:b,legend:p?(0,i.jsx)(ce.ChartLegend,{items:(0,C.toLegendItems)(f,M),position:b,marker:"dot",size:V,onToggle:a?m:void 0}):void 0,table:K?(0,i.jsx)(ue.ChartTableView,{data:s,series:f,xKey:r.key,xLabel:r.label??r.key,formatX:c,formatValue:B,caption:typeof E=="string"?E:void 0}):void 0,className:x,...L,children:({width:n})=>(0,i.jsx)(Se,{width:n,height:d,data:s,resolvedSeries:f,x:r,y:v,grid:N,size:V,bubble:z,trendLine:e,quadrants:Q,pointRadius:Z,overlay:_,maxPoints:$,margin:l,tooltip:O,onPointClick:t,plotLabel:A,formatValue:B,formatX:c})})}function Pe(){ie=!1}0&&(module.exports={ScatterChart,resetScatterWarnings});
1
+ "use strict";"use client";var Z=Object.defineProperty;var ge=Object.getOwnPropertyDescriptor;var ye=Object.getOwnPropertyNames;var pe=Object.prototype.hasOwnProperty;var be=(l,o)=>{for(var r in o)Z(l,r,{get:o[r],enumerable:!0})},xe=(l,o,r,v)=>{if(o&&typeof o=="object"||typeof o=="function")for(let m of ye(o))!pe.call(l,m)&&m!==r&&Z(l,m,{get:()=>o[m],enumerable:!(v=ge(o,m))||v.enumerable});return l};var Ce=l=>xe(Z({},"__esModule",{value:!0}),l);var Re={};be(Re,{ScatterChart:()=>Ve,resetScatterWarnings:()=>Le});module.exports=Ce(Re);var g=require("react"),ee=require("../chart/ChartAxis.cjs"),ae=require("../chart/ChartContainer.cjs"),se=require("../chart/ChartGrid.cjs"),le=require("../chart/ChartLegend.cjs"),ce=require("../chart/ChartTableView.cjs"),U=require("../chart/ChartTooltip.cjs"),C=require("../chart/palette.cjs"),E=require("../chart/utils/cartesian.cjs"),M=require("../chart/utils/data.cjs"),q=require("../chart/utils/decimate.cjs"),te=require("../chart/utils/format.cjs"),ue=require("../chart/utils/scales.cjs"),re=require("../chart/utils/ticks.cjs"),me=require("../chart/utils/timestamp.cjs"),de=require("../chart/utils/touch.cjs"),n=require("react/jsx-runtime"),ve=4.5,Se=48,ne=!1,ke=(0,g.memo)(function({points:o}){return(0,n.jsx)("g",{children:o.map(r=>(0,n.jsx)("circle",{cx:r.cx,cy:r.cy,r:r.r,fill:r.color,fillOpacity:.85,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},`${r.seriesKey}-${r.index}`))})});function Pe({width:l,height:o,data:r,resolvedSeries:v,x:m,y:X,grid:V,size:N,bubble:y,trendLine:O,quadrants:$,pointRadius:H,overlay:I,maxPoints:R,margin:G,tooltip:T,onPointClick:z,plotLabel:F,formatValue:S,formatX:w}){let[t,B]=(0,g.useState)(null),e=(0,g.useMemo)(()=>{let a=v.filter(c=>!c.hidden),K=a.map(c=>c.key),s=(0,E.buildCartesianGeometry)({width:l,height:o,data:r,x:{...m,scale:m.scale==="time"?"time":"linear"},y:X,bounds:(0,re.extent)((0,M.collectAllValues)(r,K)),margin:G,formatValue:S,formatX:w}),k=y?(0,M.collectAllValues)(r,[y.key]):[],A=y?(0,re.extent)(k):null,[x,L]=y?.range??[4,14],W=c=>{if(!y||!A)return H;let d=(0,M.readNumber)(c,y.key);if(d===null)return x;let[p,b]=A,P=b===p?1:(d-p)/(b-p);return Math.sqrt(x*x+P*(L*L-x*x))},_=[],f=[];a.forEach(c=>{let d=[];r.forEach((p,b)=>{let P=(0,M.readNumber)(p,c.key),i=s.categoryPositions[b];P===null||!Number.isFinite(i)||d.push({seriesKey:c.key,seriesLabel:(0,C.getSeriesLabel)(c),color:c.color,index:b,cx:i,cy:s.valueScale(P),r:W(p),xValue:s.toCategoryNumber(s.xValues[b]),yValue:P})}),R||(0,q.warnPointBudget)("ScatterChart",d.length),f.push(...d),_.push(...R&&R>0?(0,q.sampleEvenly)(d,R):d)});let D=null;if(O&&f.length>1){let c=f.length,d=f.reduce((h,u)=>h+u.xValue,0),p=f.reduce((h,u)=>h+u.yValue,0),b=f.reduce((h,u)=>h+u.xValue*u.yValue,0),P=f.reduce((h,u)=>h+u.xValue*u.xValue,0),i=c*P-d*d;if(i!==0){let h=(c*b-d*p)/i,u=(p-h*d)/c,ie=f.map(Q=>Q.xValue),[he,fe]=[Math.min(...ie),Math.max(...ie)],oe=f.map(Q=>Q.cx);D={x1:Math.min(...oe),y1:s.valueScale(h*he+u),x2:Math.max(...oe),y2:s.valueScale(h*fe+u)}}}return{visible:a,points:_,plot:(0,E.createPlotContext)({geometry:s,width:l,height:o,data:r,series:a,formatValue:S,formatX:w}),trend:D,xTicks:s.categoryTicks,yTicks:s.valueTicks,valueScale:s.valueScale,positions:s.categoryPositions,innerWidth:s.innerWidth,innerHeight:s.innerHeight,margin:s.margin,xValues:s.xValues}},[r,v,m,X,l,o,G,y,O,H,R,S,w]),j=(0,g.useCallback)(a=>{if(T===!1||e.points.length===0)return;let K=a.currentTarget.getBoundingClientRect(),s=a.clientX-K.left-e.margin.left,k=a.clientY-K.top-e.margin.top,A=null,x=Se;for(let L of e.points){let W=Math.hypot(L.cx-s,L.cy-k);W<x&&(x=W,A=L)}B(A)},[T,e.points,e.margin]),J=(0,g.useCallback)(()=>{if(!z||!t)return;let a=r[t.index];a&&z({seriesKey:t.seriesKey,seriesLabel:t.seriesLabel,color:t.color,value:t.yValue,formattedValue:S(t.yValue),datum:a,index:t.index,x:e.xValues[t.index]})},[z,t,S,r,e.xValues]),Y=(0,E.splitOverlay)(I);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("svg",{width:l,height:o,role:"img","aria-label":F??e.visible.map(a=>(0,C.getSeriesLabel)(a)).join(", "),tabIndex:0,className:`${de.CHART_TOUCH} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500`,onPointerMove:j,onPointerLeave:()=>B(null),onBlur:()=>B(null),onClick:J,children:[(0,n.jsxs)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[(0,n.jsx)(se.ChartGrid,{width:e.innerWidth,height:e.innerHeight,horizontal:V==="y"||V==="both"?e.yTicks.map(a=>a.offset):void 0,vertical:V==="x"||V==="both"?e.xTicks.map(a=>a.offset):void 0}),$?.y!==void 0?(0,n.jsx)("line",{x1:0,y1:e.valueScale($.y),x2:e.innerWidth,y2:e.valueScale($.y),stroke:"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:"4 4"}):null,Y.under?.(e.plot),e.trend?(0,n.jsx)("line",{x1:e.trend.x1,y1:e.trend.y1,x2:e.trend.x2,y2:e.trend.y2,stroke:"var(--color-chart-muted)",strokeWidth:1.5,strokeDasharray:"4 4"}):null,(0,n.jsx)(ke,{points:e.points}),Y.over?.(e.plot),t?(0,n.jsx)("circle",{cx:t.cx,cy:t.cy,r:t.r+3,fill:"none",stroke:t.color,strokeWidth:2,"aria-hidden":"true"}):null]}),(0,n.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:m.hidden?null:(0,n.jsx)(ee.ChartAxis,{orientation:"bottom",ticks:e.xTicks,length:e.innerWidth,label:m.label,size:N})}),(0,n.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:X?.hidden?null:(0,n.jsx)(ee.ChartAxis,{orientation:"left",ticks:e.yTicks,length:e.innerHeight,showLine:!1,label:X?.label,size:N})})]}),t&&r[t.index]&&T!==!1?(0,n.jsx)(U.ChartTooltip,{x:e.margin.left+t.cx,y:e.margin.top+t.cy,containerWidth:l,children:typeof T=="function"?T({x:e.xValues[t.index],xLabel:w(e.xValues[t.index],t.index),index:t.index,points:[{seriesKey:t.seriesKey,seriesLabel:t.seriesLabel,color:t.color,value:t.yValue,formattedValue:S(t.yValue),datum:r[t.index]}]}):(0,n.jsx)(U.ChartTooltipContent,{title:`${m.label??m.key} ${w(e.xValues[t.index],t.index)}`,points:[{seriesKey:t.seriesKey,seriesLabel:t.seriesLabel,color:t.color,value:t.yValue,formattedValue:S(t.yValue),datum:r[t.index]}]})}):null]})}function Ve({data:l,series:o,x:r,y:v,height:m=280,width:X,size:V="md",grid:N="both",legend:y,tooltip:O=!0,tableView:$=!1,emphasis:H,title:I,description:R,loading:G=!1,emptyState:T,error:z=!1,errorState:F,onRetry:S,actions:w,onPointClick:t,bubble:B,trendLine:e=!1,quadrants:j,pointRadius:J=ve,overlay:Y,legendToggle:a=!0,maxPoints:K,margin:s,locale:k,plotLabel:A,className:x,...L}){let[W,_]=(0,g.useState)(()=>new Set);o.length>C.CHART_ALL_PAIRS_LIMIT&&!ne&&(ne=!0,console.warn(`[@synertech/ui] A ScatterChart was given ${o.length} series. Any two marks can sit side by side here, and only the first ${C.CHART_ALL_PAIRS_LIMIT} palette slots stay tellable apart under that test: facet the chart instead.`));let f=(0,g.useMemo)(()=>o.map((i,h)=>({...i,hidden:i.hidden||W.has(i.key),color:(0,C.resolveSeriesColor)(i,h,H)})),[o,W,H]),D=(0,g.useMemo)(()=>v?.format??(i=>(0,te.formatAuto)(i,k)),[v?.format,k]),c=(0,g.useMemo)(()=>r.format??(i=>r.scale==="time"?(0,me.formatTimeValue)(i,k):(0,te.formatAuto)((0,ue.toNumber)(i),k)),[r.format,r.scale,k]),d=(0,g.useCallback)(i=>{_(h=>{let u=new Set(h);return u.has(i)?u.delete(i):u.add(i),u})},[]),p=y===void 0?o.length>=2:y!==!1,b=typeof y=="string"?y:"bottom",P=f.filter(i=>!i.hidden).length;return(0,n.jsx)(ae.ChartContainer,{title:I,description:R,height:m,width:X,size:V,loading:G,empty:l.length===0||P===0,emptyState:T,error:z,errorState:F,onRetry:S,actions:w,tableView:$,legendPosition:b,legend:p?(0,n.jsx)(le.ChartLegend,{items:(0,C.toLegendItems)(f,H),position:b,marker:"dot",size:V,onToggle:a?d:void 0}):void 0,table:$?(0,n.jsx)(ce.ChartTableView,{data:l,series:f,xKey:r.key,xLabel:r.label??r.key,formatX:c,formatValue:D,caption:typeof I=="string"?I:void 0}):void 0,className:x,...L,children:({width:i})=>(0,n.jsx)(Pe,{width:i,height:m,data:l,resolvedSeries:f,x:r,y:v,grid:N,size:V,bubble:B,trendLine:e,quadrants:j,pointRadius:J,overlay:Y,maxPoints:K,margin:s,tooltip:O,onPointClick:t,plotLabel:A,formatValue:D,formatX:c})})}function Le(){ne=!1}0&&(module.exports={ScatterChart,resetScatterWarnings});
@@ -1 +1 @@
1
- "use client";import{memo as ue,useCallback as U,useMemo as N,useState as se}from"react";import{ChartAxis as ee}from"../chart/ChartAxis.js";import{ChartContainer as de}from"../chart/ChartContainer.js";import{ChartGrid as me}from"../chart/ChartGrid.js";import{ChartLegend as he}from"../chart/ChartLegend.js";import{ChartTableView as fe}from"../chart/ChartTableView.js";import{ChartTooltip as ge,ChartTooltipContent as ye}from"../chart/ChartTooltip.js";import{CHART_ALL_PAIRS_LIMIT as te,getSeriesLabel as re,resolveSeriesColor as pe,toLegendItems as be}from"../chart/palette.js";import{buildCartesianGeometry as xe,createPlotContext as Ce,splitOverlay as ve}from"../chart/utils/cartesian.js";import{collectAllValues as ne,readNumber as ie}from"../chart/utils/data.js";import{sampleEvenly as Se,warnPointBudget as ke}from"../chart/utils/decimate.js";import{formatAuto as oe,formatXValue as Pe}from"../chart/utils/format.js";import{toNumber as j}from"../chart/utils/scales.js";import{extent as ae}from"../chart/utils/ticks.js";import{Fragment as we,jsx as l,jsxs as F}from"react/jsx-runtime";var Ve=4.5,Le=48,J=!1,Re=ue(function({points:m}){return l("g",{children:m.map(r=>l("circle",{cx:r.cx,cy:r.cy,r:r.r,fill:r.color,fillOpacity:.85,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},`${r.seriesKey}-${r.index}`))})});function Te({width:y,height:m,data:r,resolvedSeries:w,x:p,y:A,grid:S,size:E,bubble:h,trendLine:I,quadrants:W,pointRadius:X,overlay:M,maxPoints:P,margin:z,tooltip:V,onPointClick:$,plotLabel:O,formatValue:x,formatX:L}){let[t,D]=se(null),e=N(()=>{let i=w.filter(a=>!a.hidden),K=i.map(a=>a.key),o=xe({width:y,height:m,data:r,x:{...p,scale:p.scale==="time"?"time":"linear"},y:A,bounds:ae(ne(r,K)),margin:z,formatValue:x,formatX:L}),C=h?ne(r,[h.key]):[],R=h?ae(C):null,[b,k]=h?.range??[4,14],T=a=>{if(!h||!R)return X;let c=ie(a,h.key);if(c===null)return b;let[f,g]=R,v=g===f?1:(c-f)/(g-f);return Math.sqrt(b*b+v*(k*k-b*b))},G=[],d=[];i.forEach(a=>{let c=[];r.forEach((f,g)=>{let v=ie(f,a.key),n=o.categoryPositions[g];v===null||!Number.isFinite(n)||c.push({seriesKey:a.key,seriesLabel:re(a),color:a.color,index:g,cx:n,cy:o.valueScale(v),r:T(f),xValue:j(o.xValues[g]),yValue:v})}),P||ke("ScatterChart",c.length),d.push(...c),G.push(...P&&P>0?Se(c,P):c)});let H=null;if(I&&d.length>1){let a=d.length,c=d.reduce((u,s)=>u+s.xValue,0),f=d.reduce((u,s)=>u+s.yValue,0),g=d.reduce((u,s)=>u+s.xValue*s.yValue,0),v=d.reduce((u,s)=>u+s.xValue*s.xValue,0),n=a*v-c*c;if(n!==0){let u=(a*g-c*f)/n,s=(f-u*c)/a,Q=d.map(q=>q.xValue),[le,ce]=[Math.min(...Q),Math.max(...Q)],Z=d.map(q=>q.cx);H={x1:Math.min(...Z),y1:o.valueScale(u*le+s),x2:Math.max(...Z),y2:o.valueScale(u*ce+s)}}}return{visible:i,points:G,plot:Ce({geometry:o,width:y,height:m,data:r,series:i,formatValue:x,formatX:L}),trend:H,xTicks:o.categoryTicks,yTicks:o.valueTicks,valueScale:o.valueScale,positions:o.categoryPositions,innerWidth:o.innerWidth,innerHeight:o.innerHeight,margin:o.margin,xValues:o.xValues}},[r,w,p,A,y,m,z,h,I,X,P,x,L]),Y=U(i=>{if(V===!1||e.points.length===0)return;let K=i.currentTarget.getBoundingClientRect(),o=i.clientX-K.left-e.margin.left,C=i.clientY-K.top-e.margin.top,R=null,b=Le;for(let k of e.points){let T=Math.hypot(k.cx-o,k.cy-C);T<b&&(b=T,R=k)}D(R)},[V,e.points,e.margin]),_=U(()=>{if(!$||!t)return;let i=r[t.index];i&&$({seriesKey:t.seriesKey,seriesLabel:t.seriesLabel,color:t.color,value:t.yValue,formattedValue:x(t.yValue),datum:i,index:t.index,x:e.xValues[t.index]})},[$,t,x,r,e.xValues]),B=ve(M);return F(we,{children:[F("svg",{width:y,height:m,role:"img","aria-label":O??e.visible.map(i=>re(i)).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:Y,onPointerLeave:()=>D(null),onBlur:()=>D(null),onClick:_,children:[F("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[l(me,{width:e.innerWidth,height:e.innerHeight,horizontal:S==="y"||S==="both"?e.yTicks.map(i=>i.offset):void 0,vertical:S==="x"||S==="both"?e.xTicks.map(i=>i.offset):void 0}),W?.y!==void 0?l("line",{x1:0,y1:e.valueScale(W.y),x2:e.innerWidth,y2:e.valueScale(W.y),stroke:"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:"4 4"}):null,B.under?.(e.plot),e.trend?l("line",{x1:e.trend.x1,y1:e.trend.y1,x2:e.trend.x2,y2:e.trend.y2,stroke:"var(--color-chart-muted)",strokeWidth:1.5,strokeDasharray:"4 4"}):null,l(Re,{points:e.points}),B.over?.(e.plot),t?l("circle",{cx:t.cx,cy:t.cy,r:t.r+3,fill:"none",stroke:t.color,strokeWidth:2,"aria-hidden":"true"}):null]}),l("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:p.hidden?null:l(ee,{orientation:"bottom",ticks:e.xTicks,length:e.innerWidth,label:p.label,size:E})}),l("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:A?.hidden?null:l(ee,{orientation:"left",ticks:e.yTicks,length:e.innerHeight,showLine:!1,label:A?.label,size:E})})]}),t&&r[t.index]&&V!==!1?l(ge,{x:e.margin.left+t.cx,y:e.margin.top+t.cy,containerWidth:y,children:typeof V=="function"?V({x:e.xValues[t.index],xLabel:L(e.xValues[t.index],t.index),index:t.index,points:[{seriesKey:t.seriesKey,seriesLabel:t.seriesLabel,color:t.color,value:t.yValue,formattedValue:x(t.yValue),datum:r[t.index]}]}):l(ye,{title:`${p.label??p.key} ${L(e.xValues[t.index],t.index)}`,points:[{seriesKey:t.seriesKey,seriesLabel:t.seriesLabel,color:t.color,value:t.yValue,formattedValue:x(t.yValue),datum:r[t.index]}]})}):null]})}function Oe({data:y,series:m,x:r,y:w,height:p=280,width:A,size:S="md",grid:E="both",legend:h,tooltip:I=!0,tableView:W=!1,emphasis:X,title:M,description:P,loading:z=!1,emptyState:V,error:$=!1,errorState:O,onRetry:x,actions:L,onPointClick:t,bubble:D,trendLine:e=!1,quadrants:Y,pointRadius:_=Ve,overlay:B,legendToggle:i=!0,maxPoints:K,margin:o,locale:C,plotLabel:R,className:b,...k}){let[T,G]=se(()=>new Set);m.length>te&&!J&&(J=!0,console.warn(`[@synertech/ui] A ScatterChart was given ${m.length} series. Any two marks can sit side by side here, and only the first ${te} palette slots stay tellable apart under that test: facet the chart instead.`));let d=N(()=>m.map((n,u)=>({...n,hidden:n.hidden||T.has(n.key),color:pe(n,u,X)})),[m,T,X]),H=N(()=>w?.format??(n=>oe(n,C)),[w?.format,C]),a=N(()=>r.format??(n=>r.scale==="time"?Pe(n instanceof Date?n:new Date(j(n)),C):oe(j(n),C)),[r.format,r.scale,C]),c=U(n=>{G(u=>{let s=new Set(u);return s.has(n)?s.delete(n):s.add(n),s})},[]),f=h===void 0?m.length>=2:h!==!1,g=typeof h=="string"?h:"bottom",v=d.filter(n=>!n.hidden).length;return l(de,{title:M,description:P,height:p,width:A,size:S,loading:z,empty:y.length===0||v===0,emptyState:V,error:$,errorState:O,onRetry:x,actions:L,tableView:W,legendPosition:g,legend:f?l(he,{items:be(d,X),position:g,marker:"dot",size:S,onToggle:i?c:void 0}):void 0,table:W?l(fe,{data:y,series:d,xKey:r.key,xLabel:r.label??r.key,formatX:a,formatValue:H,caption:typeof M=="string"?M:void 0}):void 0,className:b,...k,children:({width:n})=>l(Te,{width:n,height:p,data:y,resolvedSeries:d,x:r,y:w,grid:E,size:S,bubble:D,trendLine:e,quadrants:Y,pointRadius:_,overlay:B,maxPoints:K,margin:o,tooltip:I,onPointClick:t,plotLabel:R,formatValue:H,formatX:a})})}function Ye(){J=!1}export{Oe as ScatterChart,Ye as resetScatterWarnings};
1
+ "use client";import{memo as ce,useCallback as F,useMemo as O,useState as ae}from"react";import{ChartAxis as Z}from"../chart/ChartAxis.js";import{ChartContainer as ue}from"../chart/ChartContainer.js";import{ChartGrid as me}from"../chart/ChartGrid.js";import{ChartLegend as de}from"../chart/ChartLegend.js";import{ChartTableView as he}from"../chart/ChartTableView.js";import{ChartTooltip as fe,ChartTooltipContent as ge}from"../chart/ChartTooltip.js";import{CHART_ALL_PAIRS_LIMIT as ee,getSeriesLabel as te,resolveSeriesColor as ye,toLegendItems as pe}from"../chart/palette.js";import{buildCartesianGeometry as be,createPlotContext as xe,splitOverlay as Ce}from"../chart/utils/cartesian.js";import{collectAllValues as re,readNumber as ne}from"../chart/utils/data.js";import{sampleEvenly as ve,warnPointBudget as Se}from"../chart/utils/decimate.js";import{formatAuto as ie}from"../chart/utils/format.js";import{toNumber as ke}from"../chart/utils/scales.js";import{extent as oe}from"../chart/utils/ticks.js";import{formatTimeValue as Pe}from"../chart/utils/timestamp.js";import{CHART_TOUCH as Ve}from"../chart/utils/touch.js";import{Fragment as Ae,jsx as l,jsxs as q}from"react/jsx-runtime";var Le=4.5,Re=48,j=!1,Te=ce(function({points:d}){return l("g",{children:d.map(r=>l("circle",{cx:r.cx,cy:r.cy,r:r.r,fill:r.color,fillOpacity:.85,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"},`${r.seriesKey}-${r.index}`))})});function we({width:y,height:d,data:r,resolvedSeries:w,x:p,y:A,grid:S,size:I,bubble:h,trendLine:z,quadrants:W,pointRadius:X,overlay:H,maxPoints:P,margin:B,tooltip:V,onPointClick:K,plotLabel:G,formatValue:x,formatX:L}){let[t,M]=ae(null),e=O(()=>{let i=w.filter(a=>!a.hidden),$=i.map(a=>a.key),o=be({width:y,height:d,data:r,x:{...p,scale:p.scale==="time"?"time":"linear"},y:A,bounds:oe(re(r,$)),margin:B,formatValue:x,formatX:L}),C=h?re(r,[h.key]):[],R=h?oe(C):null,[b,k]=h?.range??[4,14],T=a=>{if(!h||!R)return X;let c=ne(a,h.key);if(c===null)return b;let[f,g]=R,v=g===f?1:(c-f)/(g-f);return Math.sqrt(b*b+v*(k*k-b*b))},N=[],m=[];i.forEach(a=>{let c=[];r.forEach((f,g)=>{let v=ne(f,a.key),n=o.categoryPositions[g];v===null||!Number.isFinite(n)||c.push({seriesKey:a.key,seriesLabel:te(a),color:a.color,index:g,cx:n,cy:o.valueScale(v),r:T(f),xValue:o.toCategoryNumber(o.xValues[g]),yValue:v})}),P||Se("ScatterChart",c.length),m.push(...c),N.push(...P&&P>0?ve(c,P):c)});let E=null;if(z&&m.length>1){let a=m.length,c=m.reduce((u,s)=>u+s.xValue,0),f=m.reduce((u,s)=>u+s.yValue,0),g=m.reduce((u,s)=>u+s.xValue*s.yValue,0),v=m.reduce((u,s)=>u+s.xValue*s.xValue,0),n=a*v-c*c;if(n!==0){let u=(a*g-c*f)/n,s=(f-u*c)/a,J=m.map(U=>U.xValue),[se,le]=[Math.min(...J),Math.max(...J)],Q=m.map(U=>U.cx);E={x1:Math.min(...Q),y1:o.valueScale(u*se+s),x2:Math.max(...Q),y2:o.valueScale(u*le+s)}}}return{visible:i,points:N,plot:xe({geometry:o,width:y,height:d,data:r,series:i,formatValue:x,formatX:L}),trend:E,xTicks:o.categoryTicks,yTicks:o.valueTicks,valueScale:o.valueScale,positions:o.categoryPositions,innerWidth:o.innerWidth,innerHeight:o.innerHeight,margin:o.margin,xValues:o.xValues}},[r,w,p,A,y,d,B,h,z,X,P,x,L]),Y=F(i=>{if(V===!1||e.points.length===0)return;let $=i.currentTarget.getBoundingClientRect(),o=i.clientX-$.left-e.margin.left,C=i.clientY-$.top-e.margin.top,R=null,b=Re;for(let k of e.points){let T=Math.hypot(k.cx-o,k.cy-C);T<b&&(b=T,R=k)}M(R)},[V,e.points,e.margin]),_=F(()=>{if(!K||!t)return;let i=r[t.index];i&&K({seriesKey:t.seriesKey,seriesLabel:t.seriesLabel,color:t.color,value:t.yValue,formattedValue:x(t.yValue),datum:i,index:t.index,x:e.xValues[t.index]})},[K,t,x,r,e.xValues]),D=Ce(H);return q(Ae,{children:[q("svg",{width:y,height:d,role:"img","aria-label":G??e.visible.map(i=>te(i)).join(", "),tabIndex:0,className:`${Ve} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500`,onPointerMove:Y,onPointerLeave:()=>M(null),onBlur:()=>M(null),onClick:_,children:[q("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[l(me,{width:e.innerWidth,height:e.innerHeight,horizontal:S==="y"||S==="both"?e.yTicks.map(i=>i.offset):void 0,vertical:S==="x"||S==="both"?e.xTicks.map(i=>i.offset):void 0}),W?.y!==void 0?l("line",{x1:0,y1:e.valueScale(W.y),x2:e.innerWidth,y2:e.valueScale(W.y),stroke:"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:"4 4"}):null,D.under?.(e.plot),e.trend?l("line",{x1:e.trend.x1,y1:e.trend.y1,x2:e.trend.x2,y2:e.trend.y2,stroke:"var(--color-chart-muted)",strokeWidth:1.5,strokeDasharray:"4 4"}):null,l(Te,{points:e.points}),D.over?.(e.plot),t?l("circle",{cx:t.cx,cy:t.cy,r:t.r+3,fill:"none",stroke:t.color,strokeWidth:2,"aria-hidden":"true"}):null]}),l("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:p.hidden?null:l(Z,{orientation:"bottom",ticks:e.xTicks,length:e.innerWidth,label:p.label,size:I})}),l("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:A?.hidden?null:l(Z,{orientation:"left",ticks:e.yTicks,length:e.innerHeight,showLine:!1,label:A?.label,size:I})})]}),t&&r[t.index]&&V!==!1?l(fe,{x:e.margin.left+t.cx,y:e.margin.top+t.cy,containerWidth:y,children:typeof V=="function"?V({x:e.xValues[t.index],xLabel:L(e.xValues[t.index],t.index),index:t.index,points:[{seriesKey:t.seriesKey,seriesLabel:t.seriesLabel,color:t.color,value:t.yValue,formattedValue:x(t.yValue),datum:r[t.index]}]}):l(ge,{title:`${p.label??p.key} ${L(e.xValues[t.index],t.index)}`,points:[{seriesKey:t.seriesKey,seriesLabel:t.seriesLabel,color:t.color,value:t.yValue,formattedValue:x(t.yValue),datum:r[t.index]}]})}):null]})}function Ue({data:y,series:d,x:r,y:w,height:p=280,width:A,size:S="md",grid:I="both",legend:h,tooltip:z=!0,tableView:W=!1,emphasis:X,title:H,description:P,loading:B=!1,emptyState:V,error:K=!1,errorState:G,onRetry:x,actions:L,onPointClick:t,bubble:M,trendLine:e=!1,quadrants:Y,pointRadius:_=Le,overlay:D,legendToggle:i=!0,maxPoints:$,margin:o,locale:C,plotLabel:R,className:b,...k}){let[T,N]=ae(()=>new Set);d.length>ee&&!j&&(j=!0,console.warn(`[@synertech/ui] A ScatterChart was given ${d.length} series. Any two marks can sit side by side here, and only the first ${ee} palette slots stay tellable apart under that test: facet the chart instead.`));let m=O(()=>d.map((n,u)=>({...n,hidden:n.hidden||T.has(n.key),color:ye(n,u,X)})),[d,T,X]),E=O(()=>w?.format??(n=>ie(n,C)),[w?.format,C]),a=O(()=>r.format??(n=>r.scale==="time"?Pe(n,C):ie(ke(n),C)),[r.format,r.scale,C]),c=F(n=>{N(u=>{let s=new Set(u);return s.has(n)?s.delete(n):s.add(n),s})},[]),f=h===void 0?d.length>=2:h!==!1,g=typeof h=="string"?h:"bottom",v=m.filter(n=>!n.hidden).length;return l(ue,{title:H,description:P,height:p,width:A,size:S,loading:B,empty:y.length===0||v===0,emptyState:V,error:K,errorState:G,onRetry:x,actions:L,tableView:W,legendPosition:g,legend:f?l(de,{items:pe(m,X),position:g,marker:"dot",size:S,onToggle:i?c:void 0}):void 0,table:W?l(he,{data:y,series:m,xKey:r.key,xLabel:r.label??r.key,formatX:a,formatValue:E,caption:typeof H=="string"?H:void 0}):void 0,className:b,...k,children:({width:n})=>l(we,{width:n,height:p,data:y,resolvedSeries:m,x:r,y:w,grid:I,size:S,bubble:M,trendLine:e,quadrants:Y,pointRadius:_,overlay:D,maxPoints:$,margin:o,tooltip:z,onPointClick:t,plotLabel:R,formatValue:E,formatX:a})})}function qe(){j=!1}export{Ue as ScatterChart,qe as resetScatterWarnings};
@@ -1 +1 @@
1
- "use strict";"use client";var se=Object.defineProperty;var ke=Object.getOwnPropertyDescriptor;var ve=Object.getOwnPropertyNames;var xe=Object.prototype.hasOwnProperty;var Re=(s,r)=>{for(var i in r)se(s,i,{get:r[i],enumerable:!0})},Se=(s,r,i,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let d of ve(r))!xe.call(s,d)&&d!==i&&se(s,d,{get:()=>r[d],enumerable:!(n=ke(r,d))||n.enumerable});return s};var Ee=s=>Se(se({},"__esModule",{value:!0}),s);var Ne={};Re(Ne,{WaterfallChart:()=>Te});module.exports=Ee(Ne);var m=require("react"),de=require("../../lib/i18n.cjs"),ce=require("../chart/ChartAxis.cjs"),me=require("../chart/ChartContainer.cjs"),ue=require("../chart/ChartGrid.cjs"),ge=require("../chart/ChartLegend.cjs"),fe=require("../chart/ChartTableView.cjs"),he=require("../chart/ChartTooltip.cjs"),A=require("../chart/palette.cjs"),ye=require("../chart/utils/cartesian.cjs"),te=require("../chart/utils/data.cjs"),ae=require("../chart/utils/format.cjs"),be=require("../chart/utils/path.cjs"),Ce=require("../chart/utils/scales.cjs"),pe=require("../chart/utils/text.cjs"),t=require("react/jsx-runtime"),Le=24,We=4,K=6,Pe=(0,A.rampColor)(A.CHART_DIVERGING_COLORS,1),we=(0,A.rampColor)(A.CHART_DIVERGING_COLORS,0),Ve=(0,m.memo)(function({bars:r,connectors:i}){return(0,t.jsxs)("g",{children:[(0,t.jsx)("g",{className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,shapeRendering:"crispEdges","aria-hidden":"true",children:i.map(n=>(0,t.jsx)("line",{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2},n.key))}),r.map(n=>(0,t.jsxs)("g",{children:[(0,t.jsx)("path",{d:n.d,fill:n.color}),n.label?(0,t.jsx)("text",{x:n.label.x,y:n.label.y,textAnchor:n.label.anchor,dominantBaseline:"middle",className:"fill-gray-600 text-[10px] [font-variant-numeric:tabular-nums] dark:fill-gray-300",children:n.label.text}):null]},n.key))]})});function Ae({width:s,height:r,steps:i,data:n,x:d,y:S,grid:B,size:Z,orientation:O,connectors:j,showValues:T,barSize:G,palette:$,margin:D,tooltip:N,plotLabel:_,totalLabel:re,formatValue:z,formatX:X,onStepClick:U}){let[u,H]=(0,m.useState)(null),e=(0,m.useMemo)(()=>{let l=O==="vertical",y=i.flatMap(o=>[o.start,o.end]),f=(0,ye.buildCartesianGeometry)({width:s,height:r,data:n,x:d,y:S,bounds:y.length===0?null:[Math.min(...y),Math.max(...y)],margin:D,orientation:O,placement:"band",formatValue:z,formatX:X,defaultIncludeZero:!0}),{valueScale:b,bandwidth:v,categoryPositions:E,innerWidth:q,innerHeight:F}=f,ie=b(0),g=Math.min(G??Le,v),x=[],w=[];return i.forEach((o,h)=>{let C=E[h]+(v-g)/2,J=b(o.start),Q=b(o.end),ee=Math.min(J,Q),Y=Math.abs(Q-J),a=o.end>=o.start,L=l?a?"top":"bottom":a?"right":"left",M=l?{x:C,y:ee,width:g,height:Y}:{x:ee,y:C,width:Y,height:g},V=null;if(T&&o.value!==null){let W=o.kind==="total"?o.formattedEnd:o.formattedValue,I=(0,pe.estimateTextWidth)(W,10),R=b(a?Math.max(o.start,o.end):Math.min(o.start,o.end));if(l){let k=a?R-K:R+K;I<=v&&k>8&&k<F-4&&(V={x:C+g/2,y:k,anchor:"middle",text:W})}else{let k=a?q-R-K:R-K;I<=k&&(V={x:a?R+K:R-K,y:C+g/2,anchor:a?"start":"end",text:W})}}x.push({key:`${h}`,color:$[o.kind],d:(0,be.buildBarPath)({...M,radius:We,round:L}),label:V});let p=i[h+1];if(j&&p){let W=b(o.end),I=E[h+1]+(v-g)/2;w.push(l?{key:`${h}`,x1:C+g,y1:W,x2:I,y2:W}:{key:`${h}`,x1:W,y1:C+g,x2:W,y2:I})}}),{vertical:l,bars:x,rules:w,baseline:ie,bandwidth:v,categoryPositions:E,categoryCenters:f.categoryCenters,categoryTicks:f.categoryTicks,valueTicks:f.valueTicks,valueScale:b,innerWidth:q,innerHeight:F,margin:f.margin}},[i,n,d,S,s,r,D,O,j,T,G,$,z,X]),ne=(0,m.useCallback)(l=>{if(N===!1||i.length===0)return;let y=l.currentTarget.getBoundingClientRect(),f=e.vertical?l.clientX-y.left-e.margin.left:l.clientY-y.top-e.margin.top;H((0,Ce.nearestIndex)(e.categoryCenters,f))},[N,i.length,e.vertical,e.margin,e.categoryCenters]),le=(0,m.useCallback)(l=>{if(i.length===0)return;let y=i.length-1,f=u??0,b=e.vertical?"ArrowRight":"ArrowDown",v=e.vertical?"ArrowLeft":"ArrowUp",E=l.key===b?Math.min(y,f+1):l.key===v?Math.max(0,f-1):l.key==="Home"?0:l.key==="End"?y:l.key==="Escape"?null:void 0;E!==void 0&&(l.preventDefault(),H(E))},[i.length,u,e.vertical]),oe=(0,m.useCallback)(()=>{!U||u===null||U(i[u])},[U,u,i]),c=u===null?null:i[u],P=u===null||c===void 0||c===null?null:e.vertical?{x:e.margin.left+e.categoryCenters[u],y:e.margin.top+Math.min(e.valueScale(c.start),e.valueScale(c.end))}:{x:e.margin.left+Math.max(e.valueScale(c.start),e.valueScale(c.end)),y:e.margin.top+e.categoryCenters[u]};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("svg",{width:s,height:r,role:"img","aria-label":_??i.map(l=>l.label).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:ne,onPointerLeave:()=>H(null),onKeyDown:le,onBlur:()=>H(null),onClick:oe,children:[(0,t.jsxs)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[(0,t.jsx)(ue.ChartGrid,{width:e.innerWidth,height:e.innerHeight,horizontal:e.vertical&&(B==="y"||B==="both")?e.valueTicks.map(l=>l.offset):void 0,vertical:!e.vertical&&(B==="y"||B==="both")?e.valueTicks.map(l=>l.offset):void 0}),u!==null?(0,t.jsx)("rect",{x:e.vertical?e.categoryPositions[u]:0,y:e.vertical?0:e.categoryPositions[u],width:e.vertical?e.bandwidth:e.innerWidth,height:e.vertical?e.innerHeight:e.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,(0,t.jsx)(Ve,{bars:e.bars,connectors:e.rules}),(0,t.jsx)("line",{x1:e.vertical?0:e.baseline,y1:e.vertical?e.baseline:0,x2:e.vertical?e.innerWidth:e.baseline,y2:e.vertical?e.baseline:e.innerHeight,className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,shapeRendering:"crispEdges"})]}),(0,t.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:(e.vertical?d.hidden:S?.hidden)?null:(0,t.jsx)(ce.ChartAxis,{orientation:"bottom",ticks:e.vertical?e.categoryTicks:e.valueTicks,length:e.innerWidth,label:e.vertical?d.label:S?.label,size:Z})}),(0,t.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:(e.vertical?S?.hidden:d.hidden)?null:(0,t.jsx)(ce.ChartAxis,{orientation:"left",ticks:e.vertical?e.valueTicks:e.categoryTicks,length:e.innerHeight,showLine:!1,label:e.vertical?S?.label:d.label,size:Z})})]}),c&&P&&N!==!1?(0,t.jsx)(he.ChartTooltip,{x:P.x,y:P.y,containerWidth:s,children:typeof N=="function"?N(c):(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:c.label}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"h-2.5 w-2.5 shrink-0 rounded-sm",style:{backgroundColor:$[c.kind]},"aria-hidden":"true"}),(0,t.jsx)("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:c.kind==="total"?c.formattedEnd:c.formattedValue})]}),c.kind==="total"?null:(0,t.jsxs)("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[(0,t.jsx)("span",{children:re}),(0,t.jsx)("span",{className:"[font-variant-numeric:tabular-nums]",children:c.formattedEnd})]})]})}):null]})}function Te({data:s,x:r,y:i,value:n,total:d,start:S=0,orientation:B="vertical",connectors:Z=!0,showValues:O=!0,barSize:j,colors:T,height:G=280,width:$,size:D="md",grid:N="y",legend:_,tooltip:re=!0,tableView:z=!1,title:X,description:U,loading:u=!1,emptyState:H,error:e=!1,errorState:ne,onRetry:le,actions:oe,margin:c,locale:P,plotLabel:l,valueLabel:y,totalLabel:f,increaseLabel:b,decreaseLabel:v,format:E,onStepClick:q,className:F,...ie}){let g=(0,de.useUILabels)(),x=(0,m.useMemo)(()=>E??(a=>(0,ae.formatAuto)(a,P)),[E,P]),w=(0,m.useMemo)(()=>r.format??(a=>(0,ae.formatXValue)(a,P)),[r.format,P]),o=(0,m.useMemo)(()=>{let a=S;return s.map((L,M)=>{let V=(0,te.readXValue)(L,r.key,M),p=(0,te.readNumber)(L,n);if(d?!!L[d]:!1){let k=p??a;return a=k,{index:M,x:V,label:w(V,M),value:k,start:0,end:k,kind:"total",formattedValue:x(k),formattedEnd:x(k),datum:L}}let I=a,R=p===null?a:a+p;return a=R,{index:M,x:V,label:w(V,M),value:p,start:I,end:R,kind:p!==null&&p<0?"decrease":"increase",formattedValue:p===null?"\u2014":`${p>0?"+":""}${x(p)}`,formattedEnd:x(R),datum:L}})},[s,r.key,n,d,S,x,w]),h=(0,m.useMemo)(()=>({increase:T?.increase??Pe,decrease:T?.decrease??we,total:T?.total??A.CHART_MUTED_COLOR}),[T]),C=f??g.chartRunningTotal,J=(0,m.useMemo)(()=>{let a=[{key:"increase",label:b??g.chartIncrease,color:h.increase,marker:"rect"},{key:"decrease",label:v??g.chartDecrease,color:h.decrease,marker:"rect"}];return o.some(L=>L.kind==="total")&&a.push({key:"total",label:C,color:h.total,marker:"rect"}),a},[h,o,b,v,C,g.chartIncrease,g.chartDecrease]),Q=(0,m.useMemo)(()=>o.map(a=>({[r.key]:a.x,[n]:a.kind==="total"?null:a.value,__running:a.end})),[o,r.key,n]),ee=_===void 0?!0:_!==!1,Y=typeof _=="string"?_:"bottom";return(0,t.jsx)(me.ChartContainer,{title:X,description:U,height:G,width:$,size:D,loading:u,empty:o.length===0,emptyState:H,error:e,errorState:ne,onRetry:le,actions:oe,tableView:z,legendPosition:Y,legend:ee?(0,t.jsx)(ge.ChartLegend,{items:J,position:Y,marker:"rect",size:D}):void 0,table:z?(0,t.jsx)(fe.ChartTableView,{data:Q,series:[{key:n,label:y??g.chartValue},{key:"__running",label:C}],xKey:r.key,xLabel:r.label??r.key,formatX:w,formatValue:x,caption:typeof X=="string"?X:void 0}):void 0,className:F,...ie,children:({width:a})=>(0,t.jsx)(Ae,{width:a,height:G,steps:o,data:s,x:r,y:i,grid:N,size:D,orientation:B,connectors:Z,showValues:O,barSize:j,palette:h,margin:c,tooltip:re,plotLabel:l,totalLabel:C,formatValue:x,formatX:w,onStepClick:q})})}0&&(module.exports={WaterfallChart});
1
+ "use strict";"use client";var se=Object.defineProperty;var xe=Object.getOwnPropertyDescriptor;var Re=Object.getOwnPropertyNames;var Se=Object.prototype.hasOwnProperty;var Ee=(c,a)=>{for(var l in a)se(c,l,{get:a[l],enumerable:!0})},Le=(c,a,l,r)=>{if(a&&typeof a=="object"||typeof a=="function")for(let d of Re(a))!Se.call(c,d)&&d!==l&&se(c,d,{get:()=>a[d],enumerable:!(r=xe(a,d))||r.enumerable});return c};var We=c=>Le(se({},"__esModule",{value:!0}),c);var Ie={};Ee(Ie,{WaterfallChart:()=>Me});module.exports=We(Ie);var u=require("react"),me=require("../../lib/i18n.cjs"),ce=require("../chart/ChartAxis.cjs"),ue=require("../chart/ChartContainer.cjs"),ge=require("../chart/ChartGrid.cjs"),fe=require("../chart/ChartLegend.cjs"),he=require("../chart/ChartTableView.cjs"),ye=require("../chart/ChartTooltip.cjs"),V=require("../chart/palette.cjs"),be=require("../chart/utils/cartesian.cjs"),ae=require("../chart/utils/data.cjs"),re=require("../chart/utils/format.cjs"),Ce=require("../chart/utils/path.cjs"),pe=require("../chart/utils/scales.cjs"),ke=require("../chart/utils/text.cjs"),ve=require("../chart/utils/touch.cjs"),t=require("react/jsx-runtime"),Pe=24,we=4,H=6,Ve=(0,V.rampColor)(V.CHART_DIVERGING_COLORS,1),Ae=(0,V.rampColor)(V.CHART_DIVERGING_COLORS,0),Te=(0,u.memo)(function({bars:a,connectors:l}){return(0,t.jsxs)("g",{children:[(0,t.jsx)("g",{className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,shapeRendering:"crispEdges","aria-hidden":"true",children:l.map(r=>(0,t.jsx)("line",{x1:r.x1,y1:r.y1,x2:r.x2,y2:r.y2},r.key))}),a.map(r=>(0,t.jsxs)("g",{children:[(0,t.jsx)("path",{d:r.d,fill:r.color}),r.label?(0,t.jsx)("text",{x:r.label.x,y:r.label.y,textAnchor:r.label.anchor,dominantBaseline:"middle",className:"fill-gray-600 text-[10px] [font-variant-numeric:tabular-nums] dark:fill-gray-300",children:r.label.text}):null]},r.key))]})});function Ne({width:c,height:a,steps:l,data:r,x:d,y:R,grid:M,size:q,orientation:O,connectors:F,showValues:A,barSize:K,palette:$,margin:I,tooltip:T,plotLabel:B,totalLabel:ne,formatValue:G,formatX:_,onStepClick:z}){let[U,D]=(0,u.useState)(null),g=U!==null&&U<l.length?U:null,e=(0,u.useMemo)(()=>{let n=O==="vertical",C=l.flatMap(o=>[o.start,o.end]),h=(0,be.buildCartesianGeometry)({width:c,height:a,data:r,x:d,y:R,bounds:C.length===0?null:[Math.min(...C),Math.max(...C)],margin:I,orientation:O,placement:"band",formatValue:G,formatX:_,defaultIncludeZero:!0}),{valueScale:p,bandwidth:v,categoryPositions:L,innerWidth:J,innerHeight:Q}=h,W=p(0),m=Math.min(K??Pe,v),P=[],S=[];return l.forEach((o,k)=>{let w=L[k]+(v-m)/2,ee=p(o.start),te=p(o.end),Z=Math.min(ee,te),i=Math.abs(te-ee),f=o.end>=o.start,N=n?f?"top":"bottom":f?"right":"left",X=n?{x:w,y:Z,width:m,height:i}:{x:Z,y:w,width:i,height:m},y=null;if(A&&o.value!==null){let x=o.kind==="total"?o.formattedEnd:o.formattedValue,E=(0,ke.estimateTextWidth)(x,10),b=p(f?Math.max(o.start,o.end):Math.min(o.start,o.end));if(n){let j=f?b-H:b+H;E<=v&&j>8&&j<Q-4&&(y={x:w+m/2,y:j,anchor:"middle",text:x})}else{let j=f?J-b-H:b-H;E<=j&&(y={x:f?b+H:b-H,y:w+m/2,anchor:f?"start":"end",text:x})}}P.push({key:`${k}`,color:$[o.kind],d:(0,Ce.buildBarPath)({...X,radius:we,round:N}),label:y});let de=l[k+1];if(F&&de){let x=p(o.end),E=L[k+1]+(v-m)/2;S.push(n?{key:`${k}`,x1:w+m,y1:x,x2:E,y2:x}:{key:`${k}`,x1:x,y1:w+m,x2:x,y2:E})}}),{vertical:n,bars:P,rules:S,baseline:W,bandwidth:v,categoryPositions:L,categoryCenters:h.categoryCenters,categoryTicks:h.categoryTicks,valueTicks:h.valueTicks,valueScale:p,innerWidth:J,innerHeight:Q,margin:h.margin}},[l,r,d,R,c,a,I,O,F,A,K,$,G,_]),le=(0,u.useCallback)(n=>{if(T===!1||l.length===0)return;let C=n.currentTarget.getBoundingClientRect(),h=e.vertical?n.clientX-C.left-e.margin.left:n.clientY-C.top-e.margin.top;D((0,pe.nearestIndex)(e.categoryCenters,h))},[T,l.length,e.vertical,e.margin,e.categoryCenters]),oe=(0,u.useCallback)(n=>{if(l.length===0)return;let C=l.length-1,h=g??0,p=e.vertical?"ArrowRight":"ArrowDown",v=e.vertical?"ArrowLeft":"ArrowUp",L=n.key===p?Math.min(C,h+1):n.key===v?Math.max(0,h-1):n.key==="Home"?0:n.key==="End"?C:n.key==="Escape"?null:void 0;L!==void 0&&(n.preventDefault(),D(L))},[l.length,g,e.vertical]),ie=(0,u.useCallback)(()=>{!z||g===null||z(l[g])},[z,g,l]),s=g===null?null:l[g],Y=g===null||s===void 0||s===null?null:e.vertical?{x:e.margin.left+e.categoryCenters[g],y:e.margin.top+Math.min(e.valueScale(s.start),e.valueScale(s.end))}:{x:e.margin.left+Math.max(e.valueScale(s.start),e.valueScale(s.end)),y:e.margin.top+e.categoryCenters[g]};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("svg",{width:c,height:a,role:"img","aria-label":B??l.map(n=>n.label).join(", "),tabIndex:0,className:`${ve.CHART_TOUCH} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500`,onPointerMove:le,onPointerLeave:()=>D(null),onKeyDown:oe,onBlur:()=>D(null),onClick:ie,children:[(0,t.jsxs)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[(0,t.jsx)(ge.ChartGrid,{width:e.innerWidth,height:e.innerHeight,horizontal:e.vertical&&(M==="y"||M==="both")?e.valueTicks.map(n=>n.offset):void 0,vertical:!e.vertical&&(M==="y"||M==="both")?e.valueTicks.map(n=>n.offset):void 0}),g!==null?(0,t.jsx)("rect",{x:e.vertical?e.categoryPositions[g]:0,y:e.vertical?0:e.categoryPositions[g],width:e.vertical?e.bandwidth:e.innerWidth,height:e.vertical?e.innerHeight:e.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,(0,t.jsx)(Te,{bars:e.bars,connectors:e.rules}),(0,t.jsx)("line",{x1:e.vertical?0:e.baseline,y1:e.vertical?e.baseline:0,x2:e.vertical?e.innerWidth:e.baseline,y2:e.vertical?e.baseline:e.innerHeight,className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,shapeRendering:"crispEdges"})]}),(0,t.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:(e.vertical?d.hidden:R?.hidden)?null:(0,t.jsx)(ce.ChartAxis,{orientation:"bottom",ticks:e.vertical?e.categoryTicks:e.valueTicks,length:e.innerWidth,label:e.vertical?d.label:R?.label,size:q})}),(0,t.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:(e.vertical?R?.hidden:d.hidden)?null:(0,t.jsx)(ce.ChartAxis,{orientation:"left",ticks:e.vertical?e.valueTicks:e.categoryTicks,length:e.innerHeight,showLine:!1,label:e.vertical?R?.label:d.label,size:q})})]}),s&&Y&&T!==!1?(0,t.jsx)(ye.ChartTooltip,{x:Y.x,y:Y.y,containerWidth:c,children:typeof T=="function"?T(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.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"h-2.5 w-2.5 shrink-0 rounded-sm",style:{backgroundColor:$[s.kind]},"aria-hidden":"true"}),(0,t.jsx)("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:s.kind==="total"?s.formattedEnd:s.formattedValue})]}),s.kind==="total"?null:(0,t.jsxs)("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[(0,t.jsx)("span",{children:ne}),(0,t.jsx)("span",{className:"[font-variant-numeric:tabular-nums]",children:s.formattedEnd})]})]})}):null]})}function Me({data:c,x:a,y:l,value:r,total:d,start:R=0,orientation:M="vertical",connectors:q=!0,showValues:O=!0,barSize:F,colors:A,height:K=280,width:$,size:I="md",grid:T="y",legend:B,tooltip:ne=!0,tableView:G=!1,title:_,description:z,loading:U=!1,emptyState:D,error:g=!1,errorState:e,onRetry:le,actions:oe,margin:ie,locale:s,plotLabel:Y,valueLabel:n,totalLabel:C,increaseLabel:h,decreaseLabel:p,format:v,onStepClick:L,className:J,...Q}){let W=(0,me.useUILabels)(),m=(0,u.useMemo)(()=>v??(i=>(0,re.formatAuto)(i,s)),[v,s]),P=(0,u.useMemo)(()=>a.format??(i=>(0,re.formatXValue)(i,s)),[a.format,s]),S=(0,u.useMemo)(()=>{let i=R;return c.map((f,N)=>{let X=(0,ae.readXValue)(f,a.key,N),y=(0,ae.readNumber)(f,r);if(d?!!f[d]:!1){let b=y??i;return i=b,{index:N,x:X,label:P(X,N),value:b,start:0,end:b,kind:"total",formattedValue:m(b),formattedEnd:m(b),datum:f}}let x=i,E=y===null?i:i+y;return i=E,{index:N,x:X,label:P(X,N),value:y,start:x,end:E,kind:y!==null&&y<0?"decrease":"increase",formattedValue:y===null?"\u2014":`${y>0?"+":""}${m(y)}`,formattedEnd:m(E),datum:f}})},[c,a.key,r,d,R,m,P]),o=(0,u.useMemo)(()=>({increase:A?.increase??Ve,decrease:A?.decrease??Ae,total:A?.total??V.CHART_MUTED_COLOR}),[A]),k=C??W.chartRunningTotal,w=(0,u.useMemo)(()=>{let i=[{key:"increase",label:h??W.chartIncrease,color:o.increase,marker:"rect"},{key:"decrease",label:p??W.chartDecrease,color:o.decrease,marker:"rect"}];return S.some(f=>f.kind==="total")&&i.push({key:"total",label:k,color:o.total,marker:"rect"}),i},[o,S,h,p,k,W.chartIncrease,W.chartDecrease]),ee=(0,u.useMemo)(()=>S.map(i=>({[a.key]:i.x,[r]:i.kind==="total"?null:i.value,__running:i.end})),[S,a.key,r]),te=B===void 0?!0:B!==!1,Z=typeof B=="string"?B:"bottom";return(0,t.jsx)(ue.ChartContainer,{title:_,description:z,height:K,width:$,size:I,loading:U,empty:S.length===0,emptyState:D,error:g,errorState:e,onRetry:le,actions:oe,tableView:G,legendPosition:Z,legend:te?(0,t.jsx)(fe.ChartLegend,{items:w,position:Z,marker:"rect",size:I}):void 0,table:G?(0,t.jsx)(he.ChartTableView,{data:ee,series:[{key:r,label:n??W.chartValue},{key:"__running",label:k}],xKey:a.key,xLabel:a.label??a.key,formatX:P,formatValue:m,caption:typeof _=="string"?_:void 0}):void 0,className:J,...Q,children:({width:i})=>(0,t.jsx)(Ne,{width:i,height:K,steps:S,data:c,x:a,y:l,grid:T,size:I,orientation:M,connectors:q,showValues:O,barSize:F,palette:o,margin:ie,tooltip:ne,plotLabel:Y,totalLabel:k,formatValue:m,formatX:P,onStepClick:L})})}0&&(module.exports={WaterfallChart});
@@ -1 +1 @@
1
- "use client";import{memo as de,useCallback as oe,useMemo as I,useState as me}from"react";import{useUILabels as ue}from"../../lib/i18n.js";import{ChartAxis as ie}from"../chart/ChartAxis.js";import{ChartContainer as ge}from"../chart/ChartContainer.js";import{ChartGrid as fe}from"../chart/ChartGrid.js";import{ChartLegend as he}from"../chart/ChartLegend.js";import{ChartTableView as ye}from"../chart/ChartTableView.js";import{ChartTooltip as be}from"../chart/ChartTooltip.js";import{CHART_DIVERGING_COLORS as se,CHART_MUTED_COLOR as Ce,rampColor as ce}from"../chart/palette.js";import{buildCartesianGeometry as pe}from"../chart/utils/cartesian.js";import{readNumber as ke,readXValue as ve}from"../chart/utils/data.js";import{formatAuto as xe,formatXValue as Re}from"../chart/utils/format.js";import{buildBarPath as Se}from"../chart/utils/path.js";import{nearestIndex as Ee}from"../chart/utils/scales.js";import{estimateTextWidth as Le}from"../chart/utils/text.js";import{Fragment as Ne,jsx as l,jsxs as V}from"react/jsx-runtime";var We=24,Pe=4,K=6,we=ce(se,1),Ve=ce(se,0),Ae=de(function({bars:s,connectors:o}){return V("g",{children:[l("g",{className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,shapeRendering:"crispEdges","aria-hidden":"true",children:o.map(n=>l("line",{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2},n.key))}),s.map(n=>V("g",{children:[l("path",{d:n.d,fill:n.color}),n.label?l("text",{x:n.label.x,y:n.label.y,textAnchor:n.label.anchor,dominantBaseline:"middle",className:"fill-gray-600 text-[10px] [font-variant-numeric:tabular-nums] dark:fill-gray-300",children:n.label.text}):null]},n.key))]})});function Te({width:x,height:s,steps:o,data:n,x:C,y:R,grid:B,size:Z,orientation:O,connectors:j,showValues:A,barSize:G,palette:$,margin:D,tooltip:T,plotLabel:_,totalLabel:te,formatValue:z,formatX:X,onStepClick:U}){let[c,H]=me(null),e=I(()=>{let a=O==="vertical",g=o.flatMap(r=>[r.start,r.end]),m=pe({width:x,height:s,data:n,x:C,y:R,bounds:g.length===0?null:[Math.min(...g),Math.max(...g)],margin:D,orientation:O,placement:"band",formatValue:z,formatX:X,defaultIncludeZero:!0}),{valueScale:f,bandwidth:p,categoryPositions:S,innerWidth:q,innerHeight:F}=m,le=f(0),d=Math.min(G??We,p),k=[],P=[];return o.forEach((r,u)=>{let h=S[u]+(p-d)/2,J=f(r.start),Q=f(r.end),ee=Math.min(J,Q),Y=Math.abs(Q-J),t=r.end>=r.start,E=a?t?"top":"bottom":t?"right":"left",N=a?{x:h,y:ee,width:d,height:Y}:{x:ee,y:h,width:Y,height:d},w=null;if(A&&r.value!==null){let L=r.kind==="total"?r.formattedEnd:r.formattedValue,M=Le(L,10),v=f(t?Math.max(r.start,r.end):Math.min(r.start,r.end));if(a){let b=t?v-K:v+K;M<=p&&b>8&&b<F-4&&(w={x:h+d/2,y:b,anchor:"middle",text:L})}else{let b=t?q-v-K:v-K;M<=b&&(w={x:t?v+K:v-K,y:h+d/2,anchor:t?"start":"end",text:L})}}k.push({key:`${u}`,color:$[r.kind],d:Se({...N,radius:Pe,round:E}),label:w});let y=o[u+1];if(j&&y){let L=f(r.end),M=S[u+1]+(p-d)/2;P.push(a?{key:`${u}`,x1:h+d,y1:L,x2:M,y2:L}:{key:`${u}`,x1:L,y1:h+d,x2:L,y2:M})}}),{vertical:a,bars:k,rules:P,baseline:le,bandwidth:p,categoryPositions:S,categoryCenters:m.categoryCenters,categoryTicks:m.categoryTicks,valueTicks:m.valueTicks,valueScale:f,innerWidth:q,innerHeight:F,margin:m.margin}},[o,n,C,R,x,s,D,O,j,A,G,$,z,X]),ae=oe(a=>{if(T===!1||o.length===0)return;let g=a.currentTarget.getBoundingClientRect(),m=e.vertical?a.clientX-g.left-e.margin.left:a.clientY-g.top-e.margin.top;H(Ee(e.categoryCenters,m))},[T,o.length,e.vertical,e.margin,e.categoryCenters]),re=oe(a=>{if(o.length===0)return;let g=o.length-1,m=c??0,f=e.vertical?"ArrowRight":"ArrowDown",p=e.vertical?"ArrowLeft":"ArrowUp",S=a.key===f?Math.min(g,m+1):a.key===p?Math.max(0,m-1):a.key==="Home"?0:a.key==="End"?g:a.key==="Escape"?null:void 0;S!==void 0&&(a.preventDefault(),H(S))},[o.length,c,e.vertical]),ne=oe(()=>{!U||c===null||U(o[c])},[U,c,o]),i=c===null?null:o[c],W=c===null||i===void 0||i===null?null:e.vertical?{x:e.margin.left+e.categoryCenters[c],y:e.margin.top+Math.min(e.valueScale(i.start),e.valueScale(i.end))}:{x:e.margin.left+Math.max(e.valueScale(i.start),e.valueScale(i.end)),y:e.margin.top+e.categoryCenters[c]};return V(Ne,{children:[V("svg",{width:x,height:s,role:"img","aria-label":_??o.map(a=>a.label).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:ae,onPointerLeave:()=>H(null),onKeyDown:re,onBlur:()=>H(null),onClick:ne,children:[V("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[l(fe,{width:e.innerWidth,height:e.innerHeight,horizontal:e.vertical&&(B==="y"||B==="both")?e.valueTicks.map(a=>a.offset):void 0,vertical:!e.vertical&&(B==="y"||B==="both")?e.valueTicks.map(a=>a.offset):void 0}),c!==null?l("rect",{x:e.vertical?e.categoryPositions[c]:0,y:e.vertical?0:e.categoryPositions[c],width:e.vertical?e.bandwidth:e.innerWidth,height:e.vertical?e.innerHeight:e.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,l(Ae,{bars:e.bars,connectors:e.rules}),l("line",{x1:e.vertical?0:e.baseline,y1:e.vertical?e.baseline:0,x2:e.vertical?e.innerWidth:e.baseline,y2:e.vertical?e.baseline:e.innerHeight,className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,shapeRendering:"crispEdges"})]}),l("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:(e.vertical?C.hidden:R?.hidden)?null:l(ie,{orientation:"bottom",ticks:e.vertical?e.categoryTicks:e.valueTicks,length:e.innerWidth,label:e.vertical?C.label:R?.label,size:Z})}),l("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:(e.vertical?R?.hidden:C.hidden)?null:l(ie,{orientation:"left",ticks:e.vertical?e.valueTicks:e.categoryTicks,length:e.innerHeight,showLine:!1,label:e.vertical?R?.label:C.label,size:Z})})]}),i&&W&&T!==!1?l(be,{x:W.x,y:W.y,containerWidth:x,children:typeof T=="function"?T(i):V("div",{className:"flex flex-col gap-1",children:[l("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:i.label}),V("div",{className:"flex items-center gap-2",children:[l("span",{className:"h-2.5 w-2.5 shrink-0 rounded-sm",style:{backgroundColor:$[i.kind]},"aria-hidden":"true"}),l("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:i.kind==="total"?i.formattedEnd:i.formattedValue})]}),i.kind==="total"?null:V("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[l("span",{children:te}),l("span",{className:"[font-variant-numeric:tabular-nums]",children:i.formattedEnd})]})]})}):null]})}function je({data:x,x:s,y:o,value:n,total:C,start:R=0,orientation:B="vertical",connectors:Z=!0,showValues:O=!0,barSize:j,colors:A,height:G=280,width:$,size:D="md",grid:T="y",legend:_,tooltip:te=!0,tableView:z=!1,title:X,description:U,loading:c=!1,emptyState:H,error:e=!1,errorState:ae,onRetry:re,actions:ne,margin:i,locale:W,plotLabel:a,valueLabel:g,totalLabel:m,increaseLabel:f,decreaseLabel:p,format:S,onStepClick:q,className:F,...le}){let d=ue(),k=I(()=>S??(t=>xe(t,W)),[S,W]),P=I(()=>s.format??(t=>Re(t,W)),[s.format,W]),r=I(()=>{let t=R;return x.map((E,N)=>{let w=ve(E,s.key,N),y=ke(E,n);if(C?!!E[C]:!1){let b=y??t;return t=b,{index:N,x:w,label:P(w,N),value:b,start:0,end:b,kind:"total",formattedValue:k(b),formattedEnd:k(b),datum:E}}let M=t,v=y===null?t:t+y;return t=v,{index:N,x:w,label:P(w,N),value:y,start:M,end:v,kind:y!==null&&y<0?"decrease":"increase",formattedValue:y===null?"\u2014":`${y>0?"+":""}${k(y)}`,formattedEnd:k(v),datum:E}})},[x,s.key,n,C,R,k,P]),u=I(()=>({increase:A?.increase??we,decrease:A?.decrease??Ve,total:A?.total??Ce}),[A]),h=m??d.chartRunningTotal,J=I(()=>{let t=[{key:"increase",label:f??d.chartIncrease,color:u.increase,marker:"rect"},{key:"decrease",label:p??d.chartDecrease,color:u.decrease,marker:"rect"}];return r.some(E=>E.kind==="total")&&t.push({key:"total",label:h,color:u.total,marker:"rect"}),t},[u,r,f,p,h,d.chartIncrease,d.chartDecrease]),Q=I(()=>r.map(t=>({[s.key]:t.x,[n]:t.kind==="total"?null:t.value,__running:t.end})),[r,s.key,n]),ee=_===void 0?!0:_!==!1,Y=typeof _=="string"?_:"bottom";return l(ge,{title:X,description:U,height:G,width:$,size:D,loading:c,empty:r.length===0,emptyState:H,error:e,errorState:ae,onRetry:re,actions:ne,tableView:z,legendPosition:Y,legend:ee?l(he,{items:J,position:Y,marker:"rect",size:D}):void 0,table:z?l(ye,{data:Q,series:[{key:n,label:g??d.chartValue},{key:"__running",label:h}],xKey:s.key,xLabel:s.label??s.key,formatX:P,formatValue:k,caption:typeof X=="string"?X:void 0}):void 0,className:F,...le,children:({width:t})=>l(Te,{width:t,height:G,steps:r,data:x,x:s,y:o,grid:T,size:D,orientation:B,connectors:Z,showValues:O,barSize:j,palette:u,margin:i,tooltip:te,plotLabel:a,totalLabel:h,formatValue:k,formatX:P,onStepClick:q})})}export{je as WaterfallChart};
1
+ "use client";import{memo as me,useCallback as oe,useMemo as N,useState as ue}from"react";import{useUILabels as ge}from"../../lib/i18n.js";import{ChartAxis as se}from"../chart/ChartAxis.js";import{ChartContainer as fe}from"../chart/ChartContainer.js";import{ChartGrid as he}from"../chart/ChartGrid.js";import{ChartLegend as ye}from"../chart/ChartLegend.js";import{ChartTableView as be}from"../chart/ChartTableView.js";import{ChartTooltip as Ce}from"../chart/ChartTooltip.js";import{CHART_DIVERGING_COLORS as ce,CHART_MUTED_COLOR as pe,rampColor as de}from"../chart/palette.js";import{buildCartesianGeometry as ke}from"../chart/utils/cartesian.js";import{readNumber as ve,readXValue as xe}from"../chart/utils/data.js";import{formatAuto as Re,formatXValue as Se}from"../chart/utils/format.js";import{buildBarPath as Ee}from"../chart/utils/path.js";import{nearestIndex as Le}from"../chart/utils/scales.js";import{estimateTextWidth as We}from"../chart/utils/text.js";import{CHART_TOUCH as Pe}from"../chart/utils/touch.js";import{Fragment as Ie,jsx as l,jsxs as w}from"react/jsx-runtime";var we=24,Ve=4,H=6,Ae=de(ce,1),Te=de(ce,0),Ne=me(function({bars:s,connectors:i}){return w("g",{children:[l("g",{className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,shapeRendering:"crispEdges","aria-hidden":"true",children:i.map(a=>l("line",{x1:a.x1,y1:a.y1,x2:a.x2,y2:a.y2},a.key))}),s.map(a=>w("g",{children:[l("path",{d:a.d,fill:a.color}),a.label?l("text",{x:a.label.x,y:a.label.y,textAnchor:a.label.anchor,dominantBaseline:"middle",className:"fill-gray-600 text-[10px] [font-variant-numeric:tabular-nums] dark:fill-gray-300",children:a.label.text}):null]},a.key))]})});function Me({width:v,height:s,steps:i,data:a,x:C,y:x,grid:M,size:q,orientation:O,connectors:F,showValues:V,barSize:K,palette:$,margin:I,tooltip:A,plotLabel:B,totalLabel:ae,formatValue:G,formatX:_,onStepClick:z}){let[U,D]=ue(null),d=U!==null&&U<i.length?U:null,e=N(()=>{let t=O==="vertical",h=i.flatMap(r=>[r.start,r.end]),u=ke({width:v,height:s,data:a,x:C,y:x,bounds:h.length===0?null:[Math.min(...h),Math.max(...h)],margin:I,orientation:O,placement:"band",formatValue:G,formatX:_,defaultIncludeZero:!0}),{valueScale:y,bandwidth:p,categoryPositions:E,innerWidth:J,innerHeight:Q}=u,L=y(0),c=Math.min(K??we,p),W=[],R=[];return i.forEach((r,b)=>{let P=E[b]+(p-c)/2,ee=y(r.start),te=y(r.end),Z=Math.min(ee,te),n=Math.abs(te-ee),m=r.end>=r.start,T=t?m?"top":"bottom":m?"right":"left",X=t?{x:P,y:Z,width:c,height:n}:{x:Z,y:P,width:n,height:c},g=null;if(V&&r.value!==null){let k=r.kind==="total"?r.formattedEnd:r.formattedValue,S=We(k,10),f=y(m?Math.max(r.start,r.end):Math.min(r.start,r.end));if(t){let j=m?f-H:f+H;S<=p&&j>8&&j<Q-4&&(g={x:P+c/2,y:j,anchor:"middle",text:k})}else{let j=m?J-f-H:f-H;S<=j&&(g={x:m?f+H:f-H,y:P+c/2,anchor:m?"start":"end",text:k})}}W.push({key:`${b}`,color:$[r.kind],d:Ee({...X,radius:Ve,round:T}),label:g});let ie=i[b+1];if(F&&ie){let k=y(r.end),S=E[b+1]+(p-c)/2;R.push(t?{key:`${b}`,x1:P+c,y1:k,x2:S,y2:k}:{key:`${b}`,x1:k,y1:P+c,x2:k,y2:S})}}),{vertical:t,bars:W,rules:R,baseline:L,bandwidth:p,categoryPositions:E,categoryCenters:u.categoryCenters,categoryTicks:u.categoryTicks,valueTicks:u.valueTicks,valueScale:y,innerWidth:J,innerHeight:Q,margin:u.margin}},[i,a,C,x,v,s,I,O,F,V,K,$,G,_]),re=oe(t=>{if(A===!1||i.length===0)return;let h=t.currentTarget.getBoundingClientRect(),u=e.vertical?t.clientX-h.left-e.margin.left:t.clientY-h.top-e.margin.top;D(Le(e.categoryCenters,u))},[A,i.length,e.vertical,e.margin,e.categoryCenters]),ne=oe(t=>{if(i.length===0)return;let h=i.length-1,u=d??0,y=e.vertical?"ArrowRight":"ArrowDown",p=e.vertical?"ArrowLeft":"ArrowUp",E=t.key===y?Math.min(h,u+1):t.key===p?Math.max(0,u-1):t.key==="Home"?0:t.key==="End"?h:t.key==="Escape"?null:void 0;E!==void 0&&(t.preventDefault(),D(E))},[i.length,d,e.vertical]),le=oe(()=>{!z||d===null||z(i[d])},[z,d,i]),o=d===null?null:i[d],Y=d===null||o===void 0||o===null?null:e.vertical?{x:e.margin.left+e.categoryCenters[d],y:e.margin.top+Math.min(e.valueScale(o.start),e.valueScale(o.end))}:{x:e.margin.left+Math.max(e.valueScale(o.start),e.valueScale(o.end)),y:e.margin.top+e.categoryCenters[d]};return w(Ie,{children:[w("svg",{width:v,height:s,role:"img","aria-label":B??i.map(t=>t.label).join(", "),tabIndex:0,className:`${Pe} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500`,onPointerMove:re,onPointerLeave:()=>D(null),onKeyDown:ne,onBlur:()=>D(null),onClick:le,children:[w("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[l(he,{width:e.innerWidth,height:e.innerHeight,horizontal:e.vertical&&(M==="y"||M==="both")?e.valueTicks.map(t=>t.offset):void 0,vertical:!e.vertical&&(M==="y"||M==="both")?e.valueTicks.map(t=>t.offset):void 0}),d!==null?l("rect",{x:e.vertical?e.categoryPositions[d]:0,y:e.vertical?0:e.categoryPositions[d],width:e.vertical?e.bandwidth:e.innerWidth,height:e.vertical?e.innerHeight:e.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,l(Ne,{bars:e.bars,connectors:e.rules}),l("line",{x1:e.vertical?0:e.baseline,y1:e.vertical?e.baseline:0,x2:e.vertical?e.innerWidth:e.baseline,y2:e.vertical?e.baseline:e.innerHeight,className:"stroke-gray-300 dark:stroke-gray-600",strokeWidth:1,shapeRendering:"crispEdges"})]}),l("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:(e.vertical?C.hidden:x?.hidden)?null:l(se,{orientation:"bottom",ticks:e.vertical?e.categoryTicks:e.valueTicks,length:e.innerWidth,label:e.vertical?C.label:x?.label,size:q})}),l("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:(e.vertical?x?.hidden:C.hidden)?null:l(se,{orientation:"left",ticks:e.vertical?e.valueTicks:e.categoryTicks,length:e.innerHeight,showLine:!1,label:e.vertical?x?.label:C.label,size:q})})]}),o&&Y&&A!==!1?l(Ce,{x:Y.x,y:Y.y,containerWidth:v,children:typeof A=="function"?A(o):w("div",{className:"flex flex-col gap-1",children:[l("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:o.label}),w("div",{className:"flex items-center gap-2",children:[l("span",{className:"h-2.5 w-2.5 shrink-0 rounded-sm",style:{backgroundColor:$[o.kind]},"aria-hidden":"true"}),l("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:o.kind==="total"?o.formattedEnd:o.formattedValue})]}),o.kind==="total"?null:w("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[l("span",{children:ae}),l("span",{className:"[font-variant-numeric:tabular-nums]",children:o.formattedEnd})]})]})}):null]})}function Je({data:v,x:s,y:i,value:a,total:C,start:x=0,orientation:M="vertical",connectors:q=!0,showValues:O=!0,barSize:F,colors:V,height:K=280,width:$,size:I="md",grid:A="y",legend:B,tooltip:ae=!0,tableView:G=!1,title:_,description:z,loading:U=!1,emptyState:D,error:d=!1,errorState:e,onRetry:re,actions:ne,margin:le,locale:o,plotLabel:Y,valueLabel:t,totalLabel:h,increaseLabel:u,decreaseLabel:y,format:p,onStepClick:E,className:J,...Q}){let L=ge(),c=N(()=>p??(n=>Re(n,o)),[p,o]),W=N(()=>s.format??(n=>Se(n,o)),[s.format,o]),R=N(()=>{let n=x;return v.map((m,T)=>{let X=xe(m,s.key,T),g=ve(m,a);if(C?!!m[C]:!1){let f=g??n;return n=f,{index:T,x:X,label:W(X,T),value:f,start:0,end:f,kind:"total",formattedValue:c(f),formattedEnd:c(f),datum:m}}let k=n,S=g===null?n:n+g;return n=S,{index:T,x:X,label:W(X,T),value:g,start:k,end:S,kind:g!==null&&g<0?"decrease":"increase",formattedValue:g===null?"\u2014":`${g>0?"+":""}${c(g)}`,formattedEnd:c(S),datum:m}})},[v,s.key,a,C,x,c,W]),r=N(()=>({increase:V?.increase??Ae,decrease:V?.decrease??Te,total:V?.total??pe}),[V]),b=h??L.chartRunningTotal,P=N(()=>{let n=[{key:"increase",label:u??L.chartIncrease,color:r.increase,marker:"rect"},{key:"decrease",label:y??L.chartDecrease,color:r.decrease,marker:"rect"}];return R.some(m=>m.kind==="total")&&n.push({key:"total",label:b,color:r.total,marker:"rect"}),n},[r,R,u,y,b,L.chartIncrease,L.chartDecrease]),ee=N(()=>R.map(n=>({[s.key]:n.x,[a]:n.kind==="total"?null:n.value,__running:n.end})),[R,s.key,a]),te=B===void 0?!0:B!==!1,Z=typeof B=="string"?B:"bottom";return l(fe,{title:_,description:z,height:K,width:$,size:I,loading:U,empty:R.length===0,emptyState:D,error:d,errorState:e,onRetry:re,actions:ne,tableView:G,legendPosition:Z,legend:te?l(ye,{items:P,position:Z,marker:"rect",size:I}):void 0,table:G?l(be,{data:ee,series:[{key:a,label:t??L.chartValue},{key:"__running",label:b}],xKey:s.key,xLabel:s.label??s.key,formatX:W,formatValue:c,caption:typeof _=="string"?_:void 0}):void 0,className:J,...Q,children:({width:n})=>l(Me,{width:n,height:K,steps:R,data:v,x:s,y:i,grid:A,size:I,orientation:M,connectors:q,showValues:O,barSize:F,palette:r,margin:le,tooltip:ae,plotLabel:Y,totalLabel:b,formatValue:c,formatX:W,onStepClick:E})})}export{Je as WaterfallChart};
package/dist/index.d.cts CHANGED
@@ -637,6 +637,12 @@ interface CartesianGeometry {
637
637
  * never carry — an annotation on the 14th of a weekly series.
638
638
  */
639
639
  categoryScale: LinearScale | null;
640
+ /**
641
+ * Reads an x value as the number `categoryScale` places: a timestamp on a
642
+ * time axis, ISO strings included, and the value itself on a linear one.
643
+ * `NaN` when the value cannot be placed.
644
+ */
645
+ toCategoryNumber: (value: ChartXValue) => number;
640
646
  }
641
647
  /**
642
648
  * Everything a cartesian chart needs to place a mark, computed once.
@@ -662,7 +668,7 @@ declare function buildCartesianGeometry({ width, height, data, x, y, bounds, mar
662
668
  * drawn without a clip path, and an out-of-window date would otherwise land in
663
669
  * the axis gutter.
664
670
  */
665
- declare function createCategoryLocator(geometry: Pick<CartesianGeometry, "categoryScale" | "xValues" | "categoryCenters" | "categoryLength">): (value: ChartXValue) => number | null;
671
+ declare function createCategoryLocator(geometry: Pick<CartesianGeometry, "categoryScale" | "xValues" | "categoryCenters" | "categoryLength" | "toCategoryNumber">): (value: ChartXValue) => number | null;
666
672
  /**
667
673
  * The resolved geometry of a plot, in the shape an application can draw with.
668
674
  *
@@ -2468,6 +2474,15 @@ interface UseChartSizeResult<T extends HTMLElement> {
2468
2474
  */
2469
2475
  declare function useChartSize<T extends HTMLElement = HTMLDivElement>(options?: UseChartSizeOptions): UseChartSizeResult<T>;
2470
2476
 
2477
+ /**
2478
+ * Turns a date, a timestamp or a parsable string into a timestamp.
2479
+ *
2480
+ * A string without a time — `2026-03-02`, `2026-03`, `2026` — is read as
2481
+ * midnight local time, like one with a time and no offset: the day the
2482
+ * string names is the day the reader sees, whatever their time zone.
2483
+ */
2484
+ declare function toTimestamp(value: unknown): number | null;
2485
+
2471
2486
  /**
2472
2487
  * Ticks for an axis carrying dates.
2473
2488
  *
@@ -2505,8 +2520,6 @@ declare function niceTimeTicks(min: number, max: number, count?: number): TimeTi
2505
2520
  * reader has to filter out on every label.
2506
2521
  */
2507
2522
  declare function formatTimeTick(value: number, unit: TimeUnit, locale?: string): string;
2508
- /** Turns a date, a timestamp or a parsable string into a timestamp. */
2509
- declare function toTimestamp(value: unknown): number | null;
2510
2523
 
2511
2524
  /** Resets the series warning. Test helper. */
2512
2525
  declare function resetDumbbellWarnings(): void;
package/dist/index.d.ts CHANGED
@@ -637,6 +637,12 @@ interface CartesianGeometry {
637
637
  * never carry — an annotation on the 14th of a weekly series.
638
638
  */
639
639
  categoryScale: LinearScale | null;
640
+ /**
641
+ * Reads an x value as the number `categoryScale` places: a timestamp on a
642
+ * time axis, ISO strings included, and the value itself on a linear one.
643
+ * `NaN` when the value cannot be placed.
644
+ */
645
+ toCategoryNumber: (value: ChartXValue) => number;
640
646
  }
641
647
  /**
642
648
  * Everything a cartesian chart needs to place a mark, computed once.
@@ -662,7 +668,7 @@ declare function buildCartesianGeometry({ width, height, data, x, y, bounds, mar
662
668
  * drawn without a clip path, and an out-of-window date would otherwise land in
663
669
  * the axis gutter.
664
670
  */
665
- declare function createCategoryLocator(geometry: Pick<CartesianGeometry, "categoryScale" | "xValues" | "categoryCenters" | "categoryLength">): (value: ChartXValue) => number | null;
671
+ declare function createCategoryLocator(geometry: Pick<CartesianGeometry, "categoryScale" | "xValues" | "categoryCenters" | "categoryLength" | "toCategoryNumber">): (value: ChartXValue) => number | null;
666
672
  /**
667
673
  * The resolved geometry of a plot, in the shape an application can draw with.
668
674
  *
@@ -2468,6 +2474,15 @@ interface UseChartSizeResult<T extends HTMLElement> {
2468
2474
  */
2469
2475
  declare function useChartSize<T extends HTMLElement = HTMLDivElement>(options?: UseChartSizeOptions): UseChartSizeResult<T>;
2470
2476
 
2477
+ /**
2478
+ * Turns a date, a timestamp or a parsable string into a timestamp.
2479
+ *
2480
+ * A string without a time — `2026-03-02`, `2026-03`, `2026` — is read as
2481
+ * midnight local time, like one with a time and no offset: the day the
2482
+ * string names is the day the reader sees, whatever their time zone.
2483
+ */
2484
+ declare function toTimestamp(value: unknown): number | null;
2485
+
2471
2486
  /**
2472
2487
  * Ticks for an axis carrying dates.
2473
2488
  *
@@ -2505,8 +2520,6 @@ declare function niceTimeTicks(min: number, max: number, count?: number): TimeTi
2505
2520
  * reader has to filter out on every label.
2506
2521
  */
2507
2522
  declare function formatTimeTick(value: number, unit: TimeUnit, locale?: string): string;
2508
- /** Turns a date, a timestamp or a parsable string into a timestamp. */
2509
- declare function toTimestamp(value: unknown): number | null;
2510
2523
 
2511
2524
  /** Resets the series warning. Test helper. */
2512
2525
  declare function resetDumbbellWarnings(): void;
package/dist/styles.css CHANGED
@@ -1352,6 +1352,18 @@
1352
1352
  .cursor-text {
1353
1353
  cursor: text;
1354
1354
  }
1355
+ .touch-pan-x {
1356
+ --tw-pan-x: pan-x;
1357
+ touch-action: var(--tw-pan-x,) var(--tw-pan-y,) var(--tw-pinch-zoom,);
1358
+ }
1359
+ .touch-pan-y {
1360
+ --tw-pan-y: pan-y;
1361
+ touch-action: var(--tw-pan-x,) var(--tw-pan-y,) var(--tw-pinch-zoom,);
1362
+ }
1363
+ .touch-pinch-zoom {
1364
+ --tw-pinch-zoom: pinch-zoom;
1365
+ touch-action: var(--tw-pan-x,) var(--tw-pan-y,) var(--tw-pinch-zoom,);
1366
+ }
1355
1367
  .touch-none {
1356
1368
  touch-action: none;
1357
1369
  }
@@ -6925,6 +6937,18 @@
6925
6937
  syntax: "*";
6926
6938
  inherits: false;
6927
6939
  }
6940
+ @property --tw-pan-x {
6941
+ syntax: "*";
6942
+ inherits: false;
6943
+ }
6944
+ @property --tw-pan-y {
6945
+ syntax: "*";
6946
+ inherits: false;
6947
+ }
6948
+ @property --tw-pinch-zoom {
6949
+ syntax: "*";
6950
+ inherits: false;
6951
+ }
6928
6952
  @property --tw-space-y-reverse {
6929
6953
  syntax: "*";
6930
6954
  inherits: false;
@@ -7220,6 +7244,9 @@
7220
7244
  --tw-rotate-z: initial;
7221
7245
  --tw-skew-x: initial;
7222
7246
  --tw-skew-y: initial;
7247
+ --tw-pan-x: initial;
7248
+ --tw-pan-y: initial;
7249
+ --tw-pinch-zoom: initial;
7223
7250
  --tw-space-y-reverse: 0;
7224
7251
  --tw-space-x-reverse: 0;
7225
7252
  --tw-divide-x-reverse: 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synertech/ui",
3
- "version": "0.45.0",
3
+ "version": "0.45.1",
4
4
  "type": "module",
5
5
  "description": "Synertech UI component library",
6
6
  "main": "./dist/index.cjs",
@@ -84,11 +84,11 @@
84
84
  }
85
85
  },
86
86
  "devDependencies": {
87
- "@changesets/cli": "^2.29.8",
88
- "@eslint/js": "^9.39.2",
87
+ "@changesets/cli": "^2.31.1",
88
+ "@eslint/js": "^9.39.5",
89
89
  "@mdxeditor/editor": "^3.52.3",
90
- "@storybook/addon-docs": "^10.2.3",
91
- "@storybook/react-vite": "^10.2.3",
90
+ "@storybook/addon-docs": "^10.6.7",
91
+ "@storybook/react-vite": "^10.6.7",
92
92
  "@tailwindcss/postcss": "^4.1.18",
93
93
  "@tailwindcss/vite": "^4.1.18",
94
94
  "@testing-library/jest-dom": "^6.9.1",
@@ -97,25 +97,25 @@
97
97
  "@types/react": "^19.2.8",
98
98
  "@types/react-dom": "^19.2.3",
99
99
  "@vitejs/plugin-react": "^5.1.2",
100
- "@vitest/coverage-v8": "^4.1.9",
100
+ "@vitest/coverage-v8": "^4.1.12",
101
101
  "autoprefixer": "^10.4.23",
102
- "eslint": "^9.39.2",
103
- "eslint-plugin-storybook": "^10.2.3",
102
+ "eslint": "^9.39.5",
103
+ "eslint-plugin-storybook": "^10.6.7",
104
104
  "jsdom": "^27.4.0",
105
- "postcss": "^8.5.6",
105
+ "postcss": "^8.5.33",
106
106
  "prettier": "^3.7.4",
107
107
  "react": "^19.2.3",
108
108
  "react-dom": "^19.2.3",
109
- "storybook": "^10.2.3",
109
+ "storybook": "^10.6.7",
110
110
  "tailwindcss": "^4.1.18",
111
111
  "tsup": "^8.5.1",
112
112
  "typescript": "^5.9.3",
113
113
  "typescript-eslint": "^8.52.0",
114
- "vite": "^6.4.1",
115
- "vitest": "^4.1.9"
114
+ "vite": "^6.4.6",
115
+ "vitest": "^4.1.12"
116
116
  },
117
117
  "dependencies": {
118
- "dompurify": "^3.4.11",
118
+ "dompurify": "^3.4.18",
119
119
  "react-markdown": "^10.1.0",
120
120
  "remark-gfm": "^4.0.1"
121
121
  }