@synertech/ui 0.47.0 → 0.48.0

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 (61) hide show
  1. package/.claude/skills/use-synertech-ui/SKILL.md +49 -1
  2. package/README.md +23 -0
  3. package/dist/components/area-chart/AreaChart.cjs +1 -1
  4. package/dist/components/area-chart/AreaChart.js +1 -1
  5. package/dist/components/bar-chart/BarChart.cjs +1 -1
  6. package/dist/components/bar-chart/BarChart.js +1 -1
  7. package/dist/components/box-plot/BoxPlot.cjs +1 -1
  8. package/dist/components/box-plot/BoxPlot.js +1 -1
  9. package/dist/components/breadcrumb/Breadcrumb.cjs +1 -1
  10. package/dist/components/breadcrumb/Breadcrumb.js +1 -1
  11. package/dist/components/bullet-chart/BulletChart.cjs +1 -1
  12. package/dist/components/bullet-chart/BulletChart.js +1 -1
  13. package/dist/components/calendar/Calendar.cjs +1 -1
  14. package/dist/components/calendar/Calendar.js +1 -1
  15. package/dist/components/candlestick-chart/CandlestickChart.cjs +1 -1
  16. package/dist/components/candlestick-chart/CandlestickChart.js +1 -1
  17. package/dist/components/chart/ChartPeriodPicker.cjs +1 -1
  18. package/dist/components/chart/ChartPeriodPicker.js +1 -1
  19. package/dist/components/datagrid/DataGrid.cjs +1 -1
  20. package/dist/components/datagrid/DataGrid.js +1 -1
  21. package/dist/components/dumbbell-chart/DumbbellChart.cjs +1 -1
  22. package/dist/components/dumbbell-chart/DumbbellChart.js +1 -1
  23. package/dist/components/footer/FooterLink.cjs +1 -1
  24. package/dist/components/footer/FooterLink.js +1 -1
  25. package/dist/components/footer/FooterSocial.cjs +1 -1
  26. package/dist/components/footer/FooterSocial.js +1 -1
  27. package/dist/components/form/number-input/NumberInput.cjs +1 -1
  28. package/dist/components/form/number-input/NumberInput.js +1 -1
  29. package/dist/components/funnel-chart/FunnelChart.cjs +1 -1
  30. package/dist/components/funnel-chart/FunnelChart.js +1 -1
  31. package/dist/components/gantt-chart/GanttChart.cjs +1 -1
  32. package/dist/components/gantt-chart/GanttChart.js +1 -1
  33. package/dist/components/header/Header.cjs +1 -1
  34. package/dist/components/header/Header.js +1 -1
  35. package/dist/components/heat-map/Heatmap.cjs +1 -1
  36. package/dist/components/heat-map/Heatmap.js +1 -1
  37. package/dist/components/help-button/HelpButton.cjs +5 -5
  38. package/dist/components/help-button/HelpButton.js +6 -6
  39. package/dist/components/help-button/sanitize-html.cjs +1 -0
  40. package/dist/components/help-button/sanitize-html.js +1 -0
  41. package/dist/components/line-chart/LineChart.cjs +1 -1
  42. package/dist/components/line-chart/LineChart.js +1 -1
  43. package/dist/components/pie-chart/PieChart.cjs +1 -1
  44. package/dist/components/pie-chart/PieChart.js +1 -1
  45. package/dist/components/scatter-chart/ScatterChart.cjs +1 -1
  46. package/dist/components/scatter-chart/ScatterChart.js +1 -1
  47. package/dist/components/sidebar/Sidebar.cjs +1 -1
  48. package/dist/components/sidebar/Sidebar.js +1 -1
  49. package/dist/components/stat-card/StatCard.cjs +1 -1
  50. package/dist/components/stat-card/StatCard.js +1 -1
  51. package/dist/components/waterfall-chart/WaterfallChart.cjs +1 -1
  52. package/dist/components/waterfall-chart/WaterfallChart.js +1 -1
  53. package/dist/index.cjs +1 -1
  54. package/dist/index.d.cts +187 -25
  55. package/dist/index.d.ts +187 -25
  56. package/dist/index.js +1 -1
  57. package/dist/lib/i18n.cjs +1 -1
  58. package/dist/lib/i18n.js +1 -1
  59. package/dist/lib/safe-href.cjs +1 -0
  60. package/dist/lib/safe-href.js +1 -0
  61. package/package.json +1 -1
@@ -1 +1 @@
1
- "use strict";"use client";var Q=Object.defineProperty;var ce=Object.getOwnPropertyDescriptor;var de=Object.getOwnPropertyNames;var fe=Object.prototype.hasOwnProperty;var he=(o,n)=>{for(var t in n)Q(o,t,{get:n[t],enumerable:!0})},pe=(o,n,t,d)=>{if(n&&typeof n=="object"||typeof n=="function")for(let f of de(n))!fe.call(o,f)&&f!==t&&Q(o,f,{get:()=>n[f],enumerable:!(d=ce(n,f))||d.enumerable});return o};var be=o=>pe(Q({},"__esModule",{value:!0}),o);var Te={};he(Te,{FunnelChart:()=>Se});module.exports=be(Te);var u=require("react"),ee=require("../../lib/i18n.cjs"),te=require("../chart/ChartAxis.cjs"),ne=require("../chart/ChartContainer.cjs"),re=require("../chart/ChartTooltip.cjs"),D=require("../chart/palette.cjs"),P=require("../chart/utils/data.cjs"),y=require("../chart/utils/format.cjs"),ae=require("../chart/utils/keyboard.cjs"),le=require("../chart/utils/path.cjs"),F=require("../chart/utils/scales.cjs"),U=require("../chart/utils/text.cjs"),oe=require("../chart/utils/touch.cjs"),ie=require("../table/Table.cjs"),se=require("../table/TableBody.cjs"),X=require("../table/TableCell.cjs"),ue=require("../table/TableHeader.cjs"),W=require("../table/TableHeaderCell.cjs"),me=require("../table/TableRow.cjs"),e=require("react/jsx-runtime"),ge=8,ve=12,ye=44,Z="text-right [font-variant-numeric:tabular-nums]",xe=(0,u.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 Ce({width:o,height:n,stages:t,x:d,size:f,align:A,showConversion:E,showValues:L,stageSize:K,ramp:H,tooltip:x,plotLabel:$,locale:k,onStageClick:b}){let[O,V]=(0,u.useState)(null),i=O!==null&&O<t.length?O:null,q=(0,ee.useUILabels)(),r=(0,u.useMemo)(()=>{let p=t.map(a=>a.label),g={top:6,right:12,bottom:6,left:d.hidden?8:d.height??(0,U.widestLabel)(p)+ve},S=Math.max(0,o-g.left-g.right),M=Math.max(0,n-g.top-g.bottom),m=(0,F.createBandScale)(t.map((a,s)=>s),[0,M],{paddingInner:E?.45:.28}),N=Math.min(K??ye,m.bandwidth),j=Math.max(0,...t.map(a=>a.value??0)),I=(0,F.createLinearScale)([0,j],[0,S]),z=t.map((a,s)=>{let T=a.value===null?0:Math.max(0,I(a.value)),l=A==="center"?(S-T)/2:0,R=m(s)+(m.bandwidth-N)/2,v=R+N/2,B=null;if(L&&a.value!==null){let J=a.formattedValue;B=(0,U.estimateTextWidth)(J,11)+16<=T?{x:l+T/2,y:v,anchor:"middle",text:J,inside:!0,onDark:H.onDark(s)}:{x:l+T+ge,y:v,anchor:"start",text:J,inside:!1,onDark:!1}}let c=m(s-1)+(m.bandwidth-N)/2+N,w=E&&a.conversion!==null&&s>0?{x:S/2,y:(c+R)/2,text:(0,y.formatPercent)(a.conversion,{locale:k,maximumFractionDigits:0})}:null;return{key:`${s}`,d:(0,le.buildBarPath)({x:l,y:R,width:T,height:N,radius:4,round:A==="center"?"none":"right"}),color:H(s),value:B,conversion:w,top:m(s),height:m.bandwidth}}),G=d.hidden?[]:t.map((a,s)=>({value:a.x,offset:m.center(s),label:a.label}));return{margin:g,innerWidth:S,innerHeight:M,rendered:z,stageTicks:G,centers:t.map((a,s)=>m.center(s))}},[t,d,o,n,A,E,L,K,H,k]),Y=(0,u.useCallback)(p=>{if(x===!1||t.length===0)return;let g=p.currentTarget.getBoundingClientRect(),S=p.clientY-g.top-r.margin.top;V((0,F.nearestIndex)(r.centers,S))},[x,t.length,r.margin.top,r.centers]),_=(0,u.useCallback)(()=>{!b||i===null||b(t[i])},[b,i,t]),C=(0,u.useCallback)(p=>(0,ae.handleChartKeyDown)(p,{count:t.length,current:i,axis:"y",onMove:V,pick:b?_:null}),[t.length,i,b,_]),h=i===null?null:t[i];return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("svg",{width:o,height:n,role:"img","aria-label":$??t.map(p=>p.label).join(", "),tabIndex:0,className:`${oe.CHART_TOUCH} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:Y,onPointerLeave:()=>V(null),onKeyDown:C,onBlur:()=>V(null),onClick:_,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)(xe,{stages:r.rendered})]}),(0,e.jsx)("g",{transform:`translate(${r.margin.left}, ${r.margin.top})`,children:d.hidden?null:(0,e.jsx)(te.ChartAxis,{orientation:"left",ticks:r.stageTicks,length:r.innerHeight,showLine:!1,tickSize:0,size:f})})]}),h&&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(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.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:h.formattedValue})]}),h.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:q.chartConversion}),(0,e.jsx)("span",{className:"[font-variant-numeric:tabular-nums]",children:(0,y.formatPercent)(h.conversion,{locale:k,maximumFractionDigits:1})})]}):null,h.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)(h.overall,{locale:k,maximumFractionDigits:1})})]}):null]})}):null]})}function Se({data:o,x:n,value:t,align:d="center",showConversion:f=!0,showValues:A=!0,stageSize:E,colors:L,height:K,width:H,size:x="md",tooltip:$=!0,tableView:k=!1,title:b,description:O,loading:V=!1,emptyState:i,error:q=!1,errorState:r,onRetry:Y,actions:_,locale:C,plotLabel:h,valueLabel:p,conversionLabel:g,dropOffLabel:S,format:M,onStageClick:m,className:N,...j}){let I=(0,ee.useUILabels)(),z=(0,u.useMemo)(()=>M??(l=>(0,y.formatAuto)(l,C)),[M,C]),G=(0,u.useMemo)(()=>n.format??(l=>(0,y.formatXValue)(l,C)),[n.format,C]),a=(0,u.useMemo)(()=>{let l=(0,P.readNumber)(o[0]??{},t);return o.map((R,v)=>{let B=(0,P.readXValue)(R,n.key,v),c=(0,P.readNumber)(R,t),w=v===0?null:(0,P.readNumber)(o[v-1],t);return{index:v,x:B,label:G(B,v),value:c,overall:v===0||l===null||l===0||c===null?null:c/l,conversion:w===null||w===0||c===null?null:c/w,dropOff:w===null||c===null?null:w-c,formattedValue:c===null?"\u2014":z(c),datum:R}})},[o,n.key,t,z,G]),s=(0,u.useMemo)(()=>(0,D.createSequentialScale)([0,Math.max(1,a.length-1)],{colors:L??D.CHART_ORDINAL_COLORS,...L?{}:{darkStops:D.CHART_ORDINAL_DARK_STOPS}}),[a.length,L]),T=K??Math.max(96,a.length*(f?56:44)+12);return(0,e.jsx)(ne.ChartContainer,{title:b,description:O,height:T,width:H,size:x,loading:V,empty:a.length===0,emptyState:i,error:q,errorState:r,onRetry:Y,actions:_,tableView:k,table:k?(0,e.jsx)("div",{className:"w-full overflow-x-auto",children:(0,e.jsxs)(ie.Table,{children:[typeof b=="string"?(0,e.jsx)("caption",{className:"sr-only",children:b}):null,(0,e.jsxs)(ue.TableHeader,{children:[(0,e.jsx)(W.TableHeaderCell,{children:n.label??n.key}),(0,e.jsx)(W.TableHeaderCell,{className:"text-right",children:p??I.chartValue}),(0,e.jsx)(W.TableHeaderCell,{className:"text-right",children:g??I.chartConversion}),(0,e.jsx)(W.TableHeaderCell,{className:"text-right",children:S??I.chartDropOff})]}),(0,e.jsx)(se.TableBody,{children:a.map(l=>(0,e.jsxs)(me.TableRow,{clickable:!1,children:[(0,e.jsx)(X.TableCell,{className:"font-medium text-gray-900 dark:text-gray-100",children:l.label}),(0,e.jsx)(X.TableCell,{className:Z,children:l.formattedValue}),(0,e.jsx)(X.TableCell,{className:Z,children:l.conversion===null?"\u2014":(0,y.formatPercent)(l.conversion,{locale:C,maximumFractionDigits:1})}),(0,e.jsx)(X.TableCell,{className:Z,children:l.dropOff===null?"\u2014":z(l.dropOff)})]},l.index))})]})}):void 0,className:N,...j,children:({width:l})=>(0,e.jsx)(Ce,{width:l,height:T,stages:a,x:n,size:x,align:d,showConversion:f,showValues:A,stageSize:E,ramp:s,tooltip:$,plotLabel:h,locale:C,onStageClick:m})})}0&&(module.exports={FunnelChart});
1
+ "use strict";"use client";var Z=Object.defineProperty;var ce=Object.getOwnPropertyDescriptor;var de=Object.getOwnPropertyNames;var fe=Object.prototype.hasOwnProperty;var he=(o,n)=>{for(var t in n)Z(o,t,{get:n[t],enumerable:!0})},pe=(o,n,t,d)=>{if(n&&typeof n=="object"||typeof n=="function")for(let f of de(n))!fe.call(o,f)&&f!==t&&Z(o,f,{get:()=>n[f],enumerable:!(d=ce(n,f))||d.enumerable});return o};var be=o=>pe(Z({},"__esModule",{value:!0}),o);var Te={};he(Te,{FunnelChart:()=>Se});module.exports=be(Te);var u=require("react"),K=require("../../lib/i18n.cjs"),te=require("../chart/ChartAxis.cjs"),ne=require("../chart/ChartContainer.cjs"),ae=require("../chart/ChartTooltip.cjs"),F=require("../chart/palette.cjs"),D=require("../chart/utils/data.cjs"),x=require("../chart/utils/format.cjs"),re=require("../chart/utils/keyboard.cjs"),le=require("../chart/utils/path.cjs"),A=require("../chart/utils/scales.cjs"),$=require("../chart/utils/text.cjs"),oe=require("../chart/utils/touch.cjs"),ie=require("../table/Table.cjs"),se=require("../table/TableBody.cjs"),X=require("../table/TableCell.cjs"),ue=require("../table/TableHeader.cjs"),W=require("../table/TableHeaderCell.cjs"),me=require("../table/TableRow.cjs"),e=require("react/jsx-runtime"),ge=8,ve=12,ye=44,ee="text-right [font-variant-numeric:tabular-nums]",xe=(0,u.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 Ce({width:o,height:n,stages:t,x:d,size:f,align:E,showConversion:H,showValues:w,stageSize:G,ramp:O,tooltip:C,plotLabel:q,locale:k,onStageClick:b}){let[_,L]=(0,u.useState)(null),s=_!==null&&_<t.length?_:null,Y=(0,K.useUILabels)(),a=(0,u.useMemo)(()=>{let p=t.map(i=>i.label),g={top:6,right:12,bottom:6,left:d.hidden?8:d.height??(0,$.widestLabel)(p)+ve},S=Math.max(0,o-g.left-g.right),M=Math.max(0,n-g.top-g.bottom),m=(0,A.createBandScale)(t.map((i,l)=>l),[0,M],{paddingInner:H?.45:.28}),N=Math.min(G??ye,m.bandwidth),Q=Math.max(0,...t.map(i=>i.value??0)),T=(0,A.createLinearScale)([0,Q],[0,S]),z=t.map((i,l)=>{let R=i.value===null?0:Math.max(0,T(i.value)),V=E==="center"?(S-R)/2:0,r=m(l)+(m.bandwidth-N)/2,P=r+N/2,v=null;if(w&&i.value!==null){let y=i.formattedValue;v=(0,$.estimateTextWidth)(y,11)+16<=R?{x:V+R/2,y:P,anchor:"middle",text:y,inside:!0,onDark:O.onDark(l)}:{x:V+R+ge,y:P,anchor:"start",text:y,inside:!1,onDark:!1}}let U=m(l-1)+(m.bandwidth-N)/2+N,c=H&&i.conversion!==null&&l>0?{x:S/2,y:(U+r)/2,text:(0,x.formatPercent)(i.conversion,{locale:k,maximumFractionDigits:0})}:null;return{key:`${l}`,d:(0,le.buildBarPath)({x:V,y:r,width:R,height:N,radius:4,round:E==="center"?"none":"right"}),color:O(l),value:v,conversion:c,top:m(l),height:m.bandwidth}}),B=d.hidden?[]:t.map((i,l)=>({value:i.x,offset:m.center(l),label:i.label}));return{margin:g,innerWidth:S,innerHeight:M,rendered:z,stageTicks:B,centers:t.map((i,l)=>m.center(l))}},[t,d,o,n,E,H,w,G,O,k]),j=(0,u.useCallback)(p=>{if(C===!1||t.length===0)return;let g=p.currentTarget.getBoundingClientRect(),S=p.clientY-g.top-a.margin.top;L((0,A.nearestIndex)(a.centers,S))},[C,t.length,a.margin.top,a.centers]),I=(0,u.useCallback)(()=>{!b||s===null||b(t[s])},[b,s,t]),J=(0,u.useCallback)(p=>(0,re.handleChartKeyDown)(p,{count:t.length,current:s,axis:"y",onMove:L,pick:b?I:null}),[t.length,s,b,I]),h=s===null?null:t[s];return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("svg",{width:o,height:n,role:"img","aria-label":q??t.map(p=>p.label).join(", "),tabIndex:0,className:`${oe.CHART_TOUCH} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:j,onPointerLeave:()=>L(null),onKeyDown:J,onBlur:()=>L(null),onClick:I,children:[(0,e.jsxs)("g",{transform:`translate(${a.margin.left}, ${a.margin.top})`,children:[s!==null&&a.rendered[s]?(0,e.jsx)("rect",{x:-4,y:a.rendered[s].top,width:a.innerWidth+8,height:a.rendered[s].height,rx:4,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,(0,e.jsx)(xe,{stages:a.rendered})]}),(0,e.jsx)("g",{transform:`translate(${a.margin.left}, ${a.margin.top})`,children:d.hidden?null:(0,e.jsx)(te.ChartAxis,{orientation:"left",ticks:a.stageTicks,length:a.innerHeight,showLine:!1,tickSize:0,size:f})})]}),h&&s!==null&&C!==!1?(0,e.jsx)(ae.ChartTooltip,{x:a.margin.left+a.innerWidth/2,y:a.margin.top+a.centers[s],containerWidth:o,children:typeof C=="function"?C(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.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:a.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:h.formattedValue})]}),h.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:Y.chartConversion}),(0,e.jsx)("span",{className:"[font-variant-numeric:tabular-nums]",children:(0,x.formatPercent)(h.conversion,{locale:k,maximumFractionDigits:1})})]}):null,h.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)(h.overall,{locale:k,maximumFractionDigits:1})})]}):null]})}):null]})}function Se({data:o,x:n,value:t,align:d="center",showConversion:f=!0,showValues:E=!0,stageSize:H,colors:w,height:G,width:O,size:C="md",tooltip:q=!0,tableView:k=!1,title:b,description:_,loading:L=!1,emptyState:s,error:Y=!1,errorState:a,onRetry:j,actions:I,locale:J,plotLabel:h,valueLabel:p,conversionLabel:g,dropOffLabel:S,format:M,onStageClick:m,className:N,...Q}){let T=(0,K.useUILocale)(J),z=(0,K.useUILabels)(),B=(0,u.useMemo)(()=>M??(r=>(0,x.formatAuto)(r,T)),[M,T]),i=(0,u.useMemo)(()=>n.format??(r=>(0,x.formatXValue)(r,T)),[n.format,T]),l=(0,u.useMemo)(()=>{let r=(0,D.readNumber)(o[0]??{},t);return o.map((P,v)=>{let U=(0,D.readXValue)(P,n.key,v),c=(0,D.readNumber)(P,t),y=v===0?null:(0,D.readNumber)(o[v-1],t);return{index:v,x:U,label:i(U,v),value:c,overall:v===0||r===null||r===0||c===null?null:c/r,conversion:y===null||y===0||c===null?null:c/y,dropOff:y===null||c===null?null:y-c,formattedValue:c===null?"\u2014":B(c),datum:P}})},[o,n.key,t,B,i]),R=(0,u.useMemo)(()=>(0,F.createSequentialScale)([0,Math.max(1,l.length-1)],{colors:w??F.CHART_ORDINAL_COLORS,...w?{}:{darkStops:F.CHART_ORDINAL_DARK_STOPS}}),[l.length,w]),V=G??Math.max(96,l.length*(f?56:44)+12);return(0,e.jsx)(ne.ChartContainer,{title:b,description:_,height:V,width:O,size:C,loading:L,empty:l.length===0,emptyState:s,error:Y,errorState:a,onRetry:j,actions:I,tableView:k,table:k?(0,e.jsx)("div",{className:"w-full overflow-x-auto",children:(0,e.jsxs)(ie.Table,{children:[typeof b=="string"?(0,e.jsx)("caption",{className:"sr-only",children:b}):null,(0,e.jsxs)(ue.TableHeader,{children:[(0,e.jsx)(W.TableHeaderCell,{children:n.label??n.key}),(0,e.jsx)(W.TableHeaderCell,{className:"text-right",children:p??z.chartValue}),(0,e.jsx)(W.TableHeaderCell,{className:"text-right",children:g??z.chartConversion}),(0,e.jsx)(W.TableHeaderCell,{className:"text-right",children:S??z.chartDropOff})]}),(0,e.jsx)(se.TableBody,{children:l.map(r=>(0,e.jsxs)(me.TableRow,{clickable:!1,children:[(0,e.jsx)(X.TableCell,{className:"font-medium text-gray-900 dark:text-gray-100",children:r.label}),(0,e.jsx)(X.TableCell,{className:ee,children:r.formattedValue}),(0,e.jsx)(X.TableCell,{className:ee,children:r.conversion===null?"\u2014":(0,x.formatPercent)(r.conversion,{locale:T,maximumFractionDigits:1})}),(0,e.jsx)(X.TableCell,{className:ee,children:r.dropOff===null?"\u2014":B(r.dropOff)})]},r.index))})]})}):void 0,className:N,...Q,children:({width:r})=>(0,e.jsx)(Ce,{width:r,height:V,stages:l,x:n,size:C,align:d,showConversion:f,showValues:E,stageSize:H,ramp:R,tooltip:q,plotLabel:h,locale:T,onStageClick:m})})}0&&(module.exports={FunnelChart});
@@ -1 +1 @@
1
- "use client";import{memo as Z,useCallback as Y,useMemo as _,useState as ee}from"react";import{useUILabels as Q}from"../../lib/i18n.js";import{ChartAxis as te}from"../chart/ChartAxis.js";import{ChartContainer as ne}from"../chart/ChartContainer.js";import{ChartTooltip as re}from"../chart/ChartTooltip.js";import{CHART_ORDINAL_COLORS as ae,CHART_ORDINAL_DARK_STOPS as le,createSequentialScale as oe}from"../chart/palette.js";import{readNumber as j,readXValue as ie}from"../chart/utils/data.js";import{formatAuto as se,formatPercent as W,formatXValue as ue}from"../chart/utils/format.js";import{handleChartKeyDown as me}from"../chart/utils/keyboard.js";import{buildBarPath as ce}from"../chart/utils/path.js";import{createBandScale as de,createLinearScale as fe,nearestIndex as he}from"../chart/utils/scales.js";import{estimateTextWidth as pe,widestLabel as be}from"../chart/utils/text.js";import{CHART_TOUCH as ge}from"../chart/utils/touch.js";import{Table as ve}from"../table/Table.js";import{TableBody as ye}from"../table/TableBody.js";import{TableCell as B}from"../table/TableCell.js";import{TableHeader as xe}from"../table/TableHeader.js";import{TableHeaderCell as X}from"../table/TableHeaderCell.js";import{TableRow as Ce}from"../table/TableRow.js";import{Fragment as we,jsx as t,jsxs as m}from"react/jsx-runtime";var Se=8,Te=12,ke=44,J="text-right [font-variant-numeric:tabular-nums]",Ne=Z(function({stages:i}){return t("g",{children:i.map(e=>m("g",{children:[t("path",{d:e.d,fill:e.color}),e.value?t("text",{x:e.value.x,y:e.value.y,textAnchor:e.value.anchor,dominantBaseline:"middle",className:e.value.inside?e.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:e.value.text}):null,e.conversion?t("text",{x:e.conversion.x,y:e.conversion.y,textAnchor:"middle",dominantBaseline:"middle",className:"fill-gray-500 text-[10px] [font-variant-numeric:tabular-nums] dark:fill-gray-400",children:e.conversion.text}):null]},e.key))})});function Re({width:c,height:i,stages:e,x:C,size:M,align:L,showConversion:V,showValues:R,stageSize:I,ramp:P,tooltip:g,plotLabel:K,locale:S,onStageClick:h}){let[D,w]=ee(null),l=D!==null&&D<e.length?D:null,G=Q(),n=_(()=>{let f=e.map(r=>r.label),p={top:6,right:12,bottom:6,left:C.hidden?8:C.height??be(f)+Te},y=Math.max(0,c-p.left-p.right),A=Math.max(0,i-p.top-p.bottom),s=de(e.map((r,o)=>o),[0,A],{paddingInner:V?.45:.28}),T=Math.min(I??ke,s.bandwidth),$=Math.max(0,...e.map(r=>r.value??0)),E=fe([0,$],[0,y]),H=e.map((r,o)=>{let x=r.value===null?0:Math.max(0,E(r.value)),a=L==="center"?(y-x)/2:0,k=s(o)+(s.bandwidth-T)/2,b=k+T/2,O=null;if(R&&r.value!==null){let q=r.formattedValue;O=pe(q,11)+16<=x?{x:a+x/2,y:b,anchor:"middle",text:q,inside:!0,onDark:P.onDark(o)}:{x:a+x+Se,y:b,anchor:"start",text:q,inside:!1,onDark:!1}}let u=s(o-1)+(s.bandwidth-T)/2+T,N=V&&r.conversion!==null&&o>0?{x:y/2,y:(u+k)/2,text:W(r.conversion,{locale:S,maximumFractionDigits:0})}:null;return{key:`${o}`,d:ce({x:a,y:k,width:x,height:T,radius:4,round:L==="center"?"none":"right"}),color:P(o),value:O,conversion:N,top:s(o),height:s.bandwidth}}),z=C.hidden?[]:e.map((r,o)=>({value:r.x,offset:s.center(o),label:r.label}));return{margin:p,innerWidth:y,innerHeight:A,rendered:H,stageTicks:z,centers:e.map((r,o)=>s.center(o))}},[e,C,c,i,L,V,R,I,P,S]),U=Y(f=>{if(g===!1||e.length===0)return;let p=f.currentTarget.getBoundingClientRect(),y=f.clientY-p.top-n.margin.top;w(he(n.centers,y))},[g,e.length,n.margin.top,n.centers]),F=Y(()=>{!h||l===null||h(e[l])},[h,l,e]),v=Y(f=>me(f,{count:e.length,current:l,axis:"y",onMove:w,pick:h?F:null}),[e.length,l,h,F]),d=l===null?null:e[l];return m(we,{children:[m("svg",{width:c,height:i,role:"img","aria-label":K??e.map(f=>f.label).join(", "),tabIndex:0,className:`${ge} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:U,onPointerLeave:()=>w(null),onKeyDown:v,onBlur:()=>w(null),onClick:F,children:[m("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:[l!==null&&n.rendered[l]?t("rect",{x:-4,y:n.rendered[l].top,width:n.innerWidth+8,height:n.rendered[l].height,rx:4,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,t(Ne,{stages:n.rendered})]}),t("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:C.hidden?null:t(te,{orientation:"left",ticks:n.stageTicks,length:n.innerHeight,showLine:!1,tickSize:0,size:M})})]}),d&&l!==null&&g!==!1?t(re,{x:n.margin.left+n.innerWidth/2,y:n.margin.top+n.centers[l],containerWidth:c,children:typeof g=="function"?g(d):m("div",{className:"flex flex-col gap-1",children:[t("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:d.label}),m("div",{className:"flex items-center gap-2",children:[t("span",{className:"h-2.5 w-2.5 shrink-0 rounded-sm",style:{backgroundColor:n.rendered[l]?.color},"aria-hidden":"true"}),t("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:d.formattedValue})]}),d.conversion!==null?m("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[t("span",{children:G.chartConversion}),t("span",{className:"[font-variant-numeric:tabular-nums]",children:W(d.conversion,{locale:S,maximumFractionDigits:1})})]}):null,d.overall!==null?m("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[t("span",{children:e[0]?.label}),t("span",{className:"[font-variant-numeric:tabular-nums]",children:W(d.overall,{locale:S,maximumFractionDigits:1})})]}):null]})}):null]})}function Ye({data:c,x:i,value:e,align:C="center",showConversion:M=!0,showValues:L=!0,stageSize:V,colors:R,height:I,width:P,size:g="md",tooltip:K=!0,tableView:S=!1,title:h,description:D,loading:w=!1,emptyState:l,error:G=!1,errorState:n,onRetry:U,actions:F,locale:v,plotLabel:d,valueLabel:f,conversionLabel:p,dropOffLabel:y,format:A,onStageClick:s,className:T,...$}){let E=Q(),H=_(()=>A??(a=>se(a,v)),[A,v]),z=_(()=>i.format??(a=>ue(a,v)),[i.format,v]),r=_(()=>{let a=j(c[0]??{},e);return c.map((k,b)=>{let O=ie(k,i.key,b),u=j(k,e),N=b===0?null:j(c[b-1],e);return{index:b,x:O,label:z(O,b),value:u,overall:b===0||a===null||a===0||u===null?null:u/a,conversion:N===null||N===0||u===null?null:u/N,dropOff:N===null||u===null?null:N-u,formattedValue:u===null?"\u2014":H(u),datum:k}})},[c,i.key,e,H,z]),o=_(()=>oe([0,Math.max(1,r.length-1)],{colors:R??ae,...R?{}:{darkStops:le}}),[r.length,R]),x=I??Math.max(96,r.length*(M?56:44)+12);return t(ne,{title:h,description:D,height:x,width:P,size:g,loading:w,empty:r.length===0,emptyState:l,error:G,errorState:n,onRetry:U,actions:F,tableView:S,table:S?t("div",{className:"w-full overflow-x-auto",children:m(ve,{children:[typeof h=="string"?t("caption",{className:"sr-only",children:h}):null,m(xe,{children:[t(X,{children:i.label??i.key}),t(X,{className:"text-right",children:f??E.chartValue}),t(X,{className:"text-right",children:p??E.chartConversion}),t(X,{className:"text-right",children:y??E.chartDropOff})]}),t(ye,{children:r.map(a=>m(Ce,{clickable:!1,children:[t(B,{className:"font-medium text-gray-900 dark:text-gray-100",children:a.label}),t(B,{className:J,children:a.formattedValue}),t(B,{className:J,children:a.conversion===null?"\u2014":W(a.conversion,{locale:v,maximumFractionDigits:1})}),t(B,{className:J,children:a.dropOff===null?"\u2014":H(a.dropOff)})]},a.index))})]})}):void 0,className:T,...$,children:({width:a})=>t(Re,{width:a,height:x,stages:r,x:i,size:g,align:C,showConversion:M,showValues:L,stageSize:V,ramp:o,tooltip:K,plotLabel:d,locale:v,onStageClick:s})})}export{Ye as FunnelChart};
1
+ "use client";import{memo as Z,useCallback as Y,useMemo as _,useState as ee}from"react";import{useUILabels as Q,useUILocale as te}from"../../lib/i18n.js";import{ChartAxis as ne}from"../chart/ChartAxis.js";import{ChartContainer as ae}from"../chart/ChartContainer.js";import{ChartTooltip as re}from"../chart/ChartTooltip.js";import{CHART_ORDINAL_COLORS as le,CHART_ORDINAL_DARK_STOPS as oe,createSequentialScale as ie}from"../chart/palette.js";import{readNumber as j,readXValue as se}from"../chart/utils/data.js";import{formatAuto as ue,formatPercent as W,formatXValue as me}from"../chart/utils/format.js";import{handleChartKeyDown as ce}from"../chart/utils/keyboard.js";import{buildBarPath as de}from"../chart/utils/path.js";import{createBandScale as fe,createLinearScale as he,nearestIndex as pe}from"../chart/utils/scales.js";import{estimateTextWidth as be,widestLabel as ge}from"../chart/utils/text.js";import{CHART_TOUCH as ve}from"../chart/utils/touch.js";import{Table as ye}from"../table/Table.js";import{TableBody as xe}from"../table/TableBody.js";import{TableCell as B}from"../table/TableCell.js";import{TableHeader as Ce}from"../table/TableHeader.js";import{TableHeaderCell as X}from"../table/TableHeaderCell.js";import{TableRow as Se}from"../table/TableRow.js";import{Fragment as Le,jsx as t,jsxs as m}from"react/jsx-runtime";var Te=8,ke=12,Ne=44,J="text-right [font-variant-numeric:tabular-nums]",Re=Z(function({stages:i}){return t("g",{children:i.map(e=>m("g",{children:[t("path",{d:e.d,fill:e.color}),e.value?t("text",{x:e.value.x,y:e.value.y,textAnchor:e.value.anchor,dominantBaseline:"middle",className:e.value.inside?e.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:e.value.text}):null,e.conversion?t("text",{x:e.conversion.x,y:e.conversion.y,textAnchor:"middle",dominantBaseline:"middle",className:"fill-gray-500 text-[10px] [font-variant-numeric:tabular-nums] dark:fill-gray-400",children:e.conversion.text}):null]},e.key))})});function we({width:c,height:i,stages:e,x:C,size:I,align:V,showConversion:P,showValues:N,stageSize:M,ramp:D,tooltip:v,plotLabel:K,locale:S,onStageClick:h}){let[F,R]=ee(null),o=F!==null&&F<e.length?F:null,G=Q(),n=_(()=>{let f=e.map(l=>l.label),p={top:6,right:12,bottom:6,left:C.hidden?8:C.height??ge(f)+ke},y=Math.max(0,c-p.left-p.right),E=Math.max(0,i-p.top-p.bottom),s=fe(e.map((l,r)=>r),[0,E],{paddingInner:P?.45:.28}),T=Math.min(M??Ne,s.bandwidth),q=Math.max(0,...e.map(l=>l.value??0)),x=he([0,q],[0,y]),H=e.map((l,r)=>{let k=l.value===null?0:Math.max(0,x(l.value)),w=V==="center"?(y-k)/2:0,a=s(r)+(s.bandwidth-T)/2,L=a+T/2,b=null;if(N&&l.value!==null){let g=l.formattedValue;b=be(g,11)+16<=k?{x:w+k/2,y:L,anchor:"middle",text:g,inside:!0,onDark:D.onDark(r)}:{x:w+k+Te,y:L,anchor:"start",text:g,inside:!1,onDark:!1}}let z=s(r-1)+(s.bandwidth-T)/2+T,u=P&&l.conversion!==null&&r>0?{x:y/2,y:(z+a)/2,text:W(l.conversion,{locale:S,maximumFractionDigits:0})}:null;return{key:`${r}`,d:de({x:w,y:a,width:k,height:T,radius:4,round:V==="center"?"none":"right"}),color:D(r),value:b,conversion:u,top:s(r),height:s.bandwidth}}),O=C.hidden?[]:e.map((l,r)=>({value:l.x,offset:s.center(r),label:l.label}));return{margin:p,innerWidth:y,innerHeight:E,rendered:H,stageTicks:O,centers:e.map((l,r)=>s.center(r))}},[e,C,c,i,V,P,N,M,D,S]),U=Y(f=>{if(v===!1||e.length===0)return;let p=f.currentTarget.getBoundingClientRect(),y=f.clientY-p.top-n.margin.top;R(pe(n.centers,y))},[v,e.length,n.margin.top,n.centers]),A=Y(()=>{!h||o===null||h(e[o])},[h,o,e]),$=Y(f=>ce(f,{count:e.length,current:o,axis:"y",onMove:R,pick:h?A:null}),[e.length,o,h,A]),d=o===null?null:e[o];return m(Le,{children:[m("svg",{width:c,height:i,role:"img","aria-label":K??e.map(f=>f.label).join(", "),tabIndex:0,className:`${ve} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:U,onPointerLeave:()=>R(null),onKeyDown:$,onBlur:()=>R(null),onClick:A,children:[m("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:[o!==null&&n.rendered[o]?t("rect",{x:-4,y:n.rendered[o].top,width:n.innerWidth+8,height:n.rendered[o].height,rx:4,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,t(Re,{stages:n.rendered})]}),t("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:C.hidden?null:t(ne,{orientation:"left",ticks:n.stageTicks,length:n.innerHeight,showLine:!1,tickSize:0,size:I})})]}),d&&o!==null&&v!==!1?t(re,{x:n.margin.left+n.innerWidth/2,y:n.margin.top+n.centers[o],containerWidth:c,children:typeof v=="function"?v(d):m("div",{className:"flex flex-col gap-1",children:[t("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:d.label}),m("div",{className:"flex items-center gap-2",children:[t("span",{className:"h-2.5 w-2.5 shrink-0 rounded-sm",style:{backgroundColor:n.rendered[o]?.color},"aria-hidden":"true"}),t("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:d.formattedValue})]}),d.conversion!==null?m("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[t("span",{children:G.chartConversion}),t("span",{className:"[font-variant-numeric:tabular-nums]",children:W(d.conversion,{locale:S,maximumFractionDigits:1})})]}):null,d.overall!==null?m("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[t("span",{children:e[0]?.label}),t("span",{className:"[font-variant-numeric:tabular-nums]",children:W(d.overall,{locale:S,maximumFractionDigits:1})})]}):null]})}):null]})}function je({data:c,x:i,value:e,align:C="center",showConversion:I=!0,showValues:V=!0,stageSize:P,colors:N,height:M,width:D,size:v="md",tooltip:K=!0,tableView:S=!1,title:h,description:F,loading:R=!1,emptyState:o,error:G=!1,errorState:n,onRetry:U,actions:A,locale:$,plotLabel:d,valueLabel:f,conversionLabel:p,dropOffLabel:y,format:E,onStageClick:s,className:T,...q}){let x=te($),H=Q(),O=_(()=>E??(a=>ue(a,x)),[E,x]),l=_(()=>i.format??(a=>me(a,x)),[i.format,x]),r=_(()=>{let a=j(c[0]??{},e);return c.map((L,b)=>{let z=se(L,i.key,b),u=j(L,e),g=b===0?null:j(c[b-1],e);return{index:b,x:z,label:l(z,b),value:u,overall:b===0||a===null||a===0||u===null?null:u/a,conversion:g===null||g===0||u===null?null:u/g,dropOff:g===null||u===null?null:g-u,formattedValue:u===null?"\u2014":O(u),datum:L}})},[c,i.key,e,O,l]),k=_(()=>ie([0,Math.max(1,r.length-1)],{colors:N??le,...N?{}:{darkStops:oe}}),[r.length,N]),w=M??Math.max(96,r.length*(I?56:44)+12);return t(ae,{title:h,description:F,height:w,width:D,size:v,loading:R,empty:r.length===0,emptyState:o,error:G,errorState:n,onRetry:U,actions:A,tableView:S,table:S?t("div",{className:"w-full overflow-x-auto",children:m(ye,{children:[typeof h=="string"?t("caption",{className:"sr-only",children:h}):null,m(Ce,{children:[t(X,{children:i.label??i.key}),t(X,{className:"text-right",children:f??H.chartValue}),t(X,{className:"text-right",children:p??H.chartConversion}),t(X,{className:"text-right",children:y??H.chartDropOff})]}),t(xe,{children:r.map(a=>m(Se,{clickable:!1,children:[t(B,{className:"font-medium text-gray-900 dark:text-gray-100",children:a.label}),t(B,{className:J,children:a.formattedValue}),t(B,{className:J,children:a.conversion===null?"\u2014":W(a.conversion,{locale:x,maximumFractionDigits:1})}),t(B,{className:J,children:a.dropOff===null?"\u2014":O(a.dropOff)})]},a.index))})]})}):void 0,className:T,...q,children:({width:a})=>t(we,{width:a,height:w,stages:r,x:i,size:v,align:C,showConversion:I,showValues:V,stageSize:P,ramp:k,tooltip:K,plotLabel:d,locale:x,onStageClick:s})})}export{je as FunnelChart};
@@ -1 +1 @@
1
- "use strict";"use client";var gt=Object.defineProperty;var Et=Object.getOwnPropertyDescriptor;var Ht=Object.getOwnPropertyNames;var Wt=Object.prototype.hasOwnProperty;var Xt=(i,o)=>{for(var y in o)gt(i,y,{get:o[y],enumerable:!0})},Vt=(i,o,y,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let d of Ht(o))!Wt.call(i,d)&&d!==y&&gt(i,d,{get:()=>o[d],enumerable:!(r=Et(o,d))||r.enumerable});return i};var zt=i=>Vt(gt({},"__esModule",{value:!0}),i);var Ft={};Xt(Ft,{GanttChart:()=>Yt});module.exports=zt(Ft);var l=require("react"),ft=require("../../lib/i18n.cjs"),ht=require("../chart/ChartAxis.cjs"),xt=require("../chart/ChartContainer.cjs"),Nt=require("../chart/ChartGrid.cjs"),wt=require("../chart/ChartLegend.cjs"),St=require("../chart/ChartTooltip.cjs"),rt=require("../chart/palette.cjs"),$t=require("../chart/utils/cartesian.cjs"),nt=require("../chart/utils/data.cjs"),Z=require("../chart/utils/format.cjs"),Lt=require("../chart/utils/keyboard.cjs"),pt=require("../chart/utils/path.cjs"),Pt=require("../chart/utils/scales.cjs"),k=require("../chart/utils/time.cjs"),Rt=require("../chart/utils/touch.cjs"),Gt=require("../table/Table.cjs"),Mt=require("../table/TableBody.cjs"),Y=require("../table/TableCell.cjs"),Dt=require("../table/TableHeader.cjs"),F=require("../table/TableHeaderCell.cjs"),Ot=require("../table/TableRow.cjs"),t=require("react/jsx-runtime"),_t=18,Tt=.5,Bt=.3,et=7,kt=10,vt=.02,dt="text-right [font-variant-numeric:tabular-nums]",Kt=(0,l.memo)(function({tasks:o,arrows:y}){return(0,t.jsxs)("g",{children:[(0,t.jsx)("g",{className:"fill-gray-400 stroke-gray-400 dark:fill-gray-500 dark:stroke-gray-500",children:y.map(r=>(0,t.jsxs)("g",{children:[(0,t.jsx)("path",{d:r.d,fill:"none",strokeWidth:1}),(0,t.jsx)("path",{d:r.head,strokeWidth:0})]},r.key))}),o.map(r=>(0,t.jsxs)("g",{children:[r.track?(0,t.jsx)("path",{d:r.track,fill:r.color,fillOpacity:r.trackOpacity}):null,r.progress?(0,t.jsx)("path",{d:r.progress,fill:r.color}):null,r.milestone?(0,t.jsx)("path",{d:r.milestone,fill:r.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"}):null]},r.key))]})});function Ut({width:i,height:o,data:y,tasks:r,x:d,domain:x,unit:R,timeTicks:I,today:S,grid:E,size:H,barSize:V,colorOf:j,margin:q,tooltip:$,plotLabel:at,todayLabel:ot,locale:L,formatDate:J,formatX:G,onTaskClick:M}){let[W,P]=(0,l.useState)(null),b=W!==null&&W<r.length?W:null,z=(0,ft.useUILabels)(),n=(0,l.useMemo)(()=>{let c=(0,$t.buildCartesianGeometry)({width:i,height:o,data:y,x:d,y:{domain:x},bounds:x,margin:q,orientation:"horizontal",placement:"band",formatValue:a=>(0,k.formatTimeTick)(a,R,L),formatX:G}),{valueScale:u,bandwidth:C,categoryPositions:N,innerWidth:st,innerHeight:mt}=c,D=Math.min(V??_t,C),Q=new Map(r.map((a,s)=>[a.id,s])),ct=r.map((a,s)=>{let p=N[s]+(C-D)/2,m=p+D/2,w=j(a);if(a.start===null)return{key:`${s}`,color:w,track:null,trackOpacity:1,progress:null,milestone:null,top:N[s],height:C};let g=u(a.start);if(a.milestone)return{key:`${s}`,color:w,track:null,trackOpacity:1,progress:null,milestone:`M${g},${m-et} L${g+et},${m} L${g},${m+et} L${g-et},${m} Z`,top:N[s],height:C};let O=u(a.end??a.start),T=Math.max(2,O-g);return{key:`${s}`,color:w,track:(0,pt.buildBarPath)({x:g,y:p,width:T,height:D,radius:3}),trackOpacity:a.progress===null?1:Bt,progress:a.progress===null?null:(0,pt.buildBarPath)({x:g,y:m-D*Tt/2,width:Math.max(0,T*Math.min(1,Math.max(0,a.progress))),height:D*Tt,radius:2,round:"right"}),milestone:null,top:N[s],height:C}}),tt=[];r.forEach((a,s)=>{if(a.start!==null)for(let p of a.dependsOn){let m=Q.get(p);if(m===void 0||m===s)continue;let w=r[m];if(w.start===null)continue;let g=u(w.end??w.start),O=N[m]+C/2,T=u(a.start),A=N[s]+C/2,B=Math.max(g+kt,T-kt);tt.push({key:`${p}-${a.id}`,d:`M${g},${O} L${B},${O} L${B},${A} L${T-5},${A}`,head:`M${T},${A} L${T-5},${A-3.5} L${T-5},${A+3.5} Z`})}});let ut=I.map(a=>({value:a,offset:u(a),label:(0,k.formatTimeTick)(a,R,L)}));return{rendered:ct,arrows:tt,categoryPositions:N,categoryCenters:c.categoryCenters,bandwidth:C,categoryTicks:c.categoryTicks,valueTicks:ut,valueScale:u,innerWidth:st,innerHeight:mt,margin:c.margin}},[r,y,d,x,R,I,i,o,q,V,j,L,G]),lt=(0,l.useCallback)(c=>{if($===!1||r.length===0)return;let u=c.currentTarget.getBoundingClientRect(),C=c.clientY-u.top-n.margin.top;P((0,Pt.nearestIndex)(n.categoryCenters,C))},[$,r.length,n.margin.top,n.categoryCenters]),_=(0,l.useCallback)(()=>{!M||b===null||M(r[b])},[M,b,r]),it=(0,l.useCallback)(c=>(0,Lt.handleChartKeyDown)(c,{count:r.length,current:b,axis:"y",onMove:P,pick:M?_:null}),[r.length,b,M,_]),h=b===null?null:r[b];return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("svg",{width:i,height:o,role:"img","aria-label":at??r.map(c=>c.label).join(", "),tabIndex:0,className:`${Rt.CHART_TOUCH} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:lt,onPointerLeave:()=>P(null),onKeyDown:it,onBlur:()=>P(null),onClick:_,children:[(0,t.jsxs)("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:[(0,t.jsx)(Nt.ChartGrid,{width:n.innerWidth,height:n.innerHeight,vertical:E?n.valueTicks.map(c=>c.offset):void 0}),b!==null?(0,t.jsx)("rect",{x:0,y:n.categoryPositions[b],width:n.innerWidth,height:n.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,(0,t.jsx)(Kt,{tasks:n.rendered,arrows:n.arrows}),S!==null?(0,t.jsxs)("g",{children:[(0,t.jsx)("line",{x1:n.valueScale(S),y1:0,x2:n.valueScale(S),y2:n.innerHeight,className:"stroke-gray-900 dark:stroke-white",strokeWidth:1,strokeDasharray:"4 4"}),(0,t.jsx)("text",{x:n.valueScale(S)+4,y:8,className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:ot})]}):null]}),(0,t.jsx)("g",{transform:`translate(${n.margin.left}, ${n.margin.top+n.innerHeight})`,children:(0,t.jsx)(ht.ChartAxis,{orientation:"bottom",ticks:n.valueTicks,length:n.innerWidth,size:H})}),(0,t.jsx)("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:d.hidden?null:(0,t.jsx)(ht.ChartAxis,{orientation:"left",ticks:n.categoryTicks,length:n.innerHeight,showLine:!1,tickSize:0,label:d.label,size:H})})]}),h&&b!==null&&$!==!1?(0,t.jsx)(St.ChartTooltip,{x:n.margin.left+(h.start===null?n.innerWidth/2:n.valueScale(h.start)),y:n.margin.top+n.categoryCenters[b],containerWidth:i,children:typeof $=="function"?$(h):(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:h.label}),(0,t.jsxs)("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[(0,t.jsx)("span",{children:z.chartStart}),(0,t.jsx)("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:h.start===null?"\u2014":J(h.start)})]}),h.milestone?null:(0,t.jsxs)("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[(0,t.jsx)("span",{children:z.chartEnd}),(0,t.jsx)("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:h.end===null?"\u2014":J(h.end)})]}),h.progress===null?null:(0,t.jsxs)("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[(0,t.jsx)("span",{children:z.chartProgress}),(0,t.jsx)("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:(0,Z.formatPercent)(h.progress,{locale:L,maximumFractionDigits:0})})]})]})}):null]})}function Yt({data:i,x:o,start:y,end:r,id:d,progress:x,milestone:R,dependencies:I,group:S,domain:E,today:H,ticks:V=6,barSize:j,rowSize:q=30,color:$,height:at,width:ot,size:L="md",grid:J=!0,legend:G,tooltip:M=!0,tableView:W=!1,title:P,description:b,loading:z=!1,emptyState:n,error:lt=!1,errorState:_,onRetry:it,actions:h,margin:c,locale:u,plotLabel:C,startLabel:N,endLabel:st,progressLabel:mt,todayLabel:D,formatDate:Q,onTaskClick:ct,className:tt,...ut}){let a=(0,ft.useUILabels)(),s=(0,l.useMemo)(()=>o.format??(e=>(0,Z.formatXValue)(e,u)),[o.format,u]),p=(0,l.useMemo)(()=>i.map((e,f)=>{let K=(0,nt.readXValue)(e,o.key,f),X=(0,k.toTimestamp)(e[y]),v=r?(0,k.toTimestamp)(e[r]):null,U=R?!!e[R]:v===null,Ct=I?e[I]:void 0;return{index:f,id:String(d?e[d]??f:f),x:K,label:s(K,f),start:X,end:U?X:v??X,progress:x?(0,nt.readNumber)(e,x):null,milestone:U,dependsOn:Array.isArray(Ct)?Ct.map(It=>String(It)):[],group:S?e[S]??null:null,datum:e}}),[i,o.key,y,r,d,x,R,I,S,s]),m=(0,l.useMemo)(()=>{let e=[];for(let f of p)f.group!==null&&!e.includes(f.group)&&e.push(f.group);return e},[p]),w=(0,l.useCallback)(e=>e.group===null?$??(0,rt.getSeriesColor)(0):(0,rt.getSeriesColor)(m.indexOf(e.group)),[m,$]),g=(0,l.useMemo)(()=>{if(E){let v=(0,k.toTimestamp)(E[0]),U=(0,k.toTimestamp)(E[1]);if(v!==null&&U!==null)return[v,U]}let e=p.flatMap(v=>v.start===null?[]:[v.start,v.end??v.start]);if(e.length===0)return[0,1];let f=Math.min(...e),K=Math.max(...e),X=K-f||864e5;return[f-X*vt,K+X*vt]},[E,p]),O=(0,l.useMemo)(()=>(0,k.niceTimeTicks)(g[0],g[1],V),[g,V]),T=(0,l.useMemo)(()=>Q??(e=>new Intl.DateTimeFormat(u,{day:"numeric",month:"short",year:"numeric"}).format(new Date(e))),[Q,u]),A=(0,l.useMemo)(()=>H===!1?null:(0,k.toTimestamp)(H??Date.now()),[H]),B=(0,l.useMemo)(()=>m.map((e,f)=>({key:e,label:e,color:(0,rt.getSeriesColor)(f),marker:"rect"})),[m]),bt=at??Math.max(120,p.length*q+48),At=G===void 0?m.length>=2:G!==!1,yt=typeof G=="string"?G:"bottom";return(0,t.jsx)(xt.ChartContainer,{title:P,description:b,height:bt,width:ot,size:L,loading:z,empty:p.length===0,emptyState:n,error:lt,errorState:_,onRetry:it,actions:h,tableView:W,legendPosition:yt,legend:At&&B.length>0?(0,t.jsx)(wt.ChartLegend,{items:B,position:yt,marker:"rect",size:L}):void 0,table:W?(0,t.jsx)("div",{className:"w-full overflow-x-auto",children:(0,t.jsxs)(Gt.Table,{children:[typeof P=="string"?(0,t.jsx)("caption",{className:"sr-only",children:P}):null,(0,t.jsxs)(Dt.TableHeader,{children:[(0,t.jsx)(F.TableHeaderCell,{children:o.label??o.key}),(0,t.jsx)(F.TableHeaderCell,{className:"text-right",children:N??a.chartStart}),(0,t.jsx)(F.TableHeaderCell,{className:"text-right",children:st??a.chartEnd}),x?(0,t.jsx)(F.TableHeaderCell,{className:"text-right",children:mt??a.chartProgress}):null]}),(0,t.jsx)(Mt.TableBody,{children:p.map(e=>(0,t.jsxs)(Ot.TableRow,{clickable:!1,children:[(0,t.jsx)(Y.TableCell,{className:"font-medium text-gray-900 dark:text-gray-100",children:e.label}),(0,t.jsx)(Y.TableCell,{className:dt,children:e.start===null?"\u2014":T(e.start)}),(0,t.jsx)(Y.TableCell,{className:dt,children:e.milestone||e.end===null?"\u2014":T(e.end)}),x?(0,t.jsx)(Y.TableCell,{className:dt,children:e.progress===null?"\u2014":(0,Z.formatPercent)(e.progress,{locale:u,maximumFractionDigits:0})}):null]},e.index))})]})}):void 0,className:tt,...ut,children:({width:e})=>(0,t.jsx)(Ut,{width:e,height:bt,data:i,tasks:p,x:o,domain:g,unit:O.unit,timeTicks:O.values,today:A,grid:J,size:L,barSize:j,colorOf:w,margin:c,tooltip:M,plotLabel:C,todayLabel:D??a.chartToday,locale:u,formatDate:T,formatX:s,onTaskClick:ct})})}0&&(module.exports={GanttChart});
1
+ "use strict";"use client";var dt=Object.defineProperty;var Ht=Object.getOwnPropertyDescriptor;var Wt=Object.getOwnPropertyNames;var Xt=Object.prototype.hasOwnProperty;var Vt=(s,o)=>{for(var f in o)dt(s,f,{get:o[f],enumerable:!0})},zt=(s,o,f,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let u of Wt(o))!Xt.call(s,u)&&u!==f&&dt(s,u,{get:()=>o[u],enumerable:!(r=Ht(o,u))||r.enumerable});return s};var _t=s=>zt(dt({},"__esModule",{value:!0}),s);var Zt={};Vt(Zt,{GanttChart:()=>Ft});module.exports=_t(Zt);var i=require("react"),F=require("../../lib/i18n.cjs"),pt=require("../chart/ChartAxis.cjs"),Nt=require("../chart/ChartContainer.cjs"),wt=require("../chart/ChartGrid.cjs"),St=require("../chart/ChartLegend.cjs"),$t=require("../chart/ChartTooltip.cjs"),nt=require("../chart/palette.cjs"),Lt=require("../chart/utils/cartesian.cjs"),at=require("../chart/utils/data.cjs"),Z=require("../chart/utils/format.cjs"),Pt=require("../chart/utils/keyboard.cjs"),ft=require("../chart/utils/path.cjs"),Rt=require("../chart/utils/scales.cjs"),T=require("../chart/utils/time.cjs"),Gt=require("../chart/utils/touch.cjs"),Mt=require("../table/Table.cjs"),Dt=require("../table/TableBody.cjs"),U=require("../table/TableCell.cjs"),Ot=require("../table/TableHeader.cjs"),Y=require("../table/TableHeaderCell.cjs"),It=require("../table/TableRow.cjs"),t=require("react/jsx-runtime"),Bt=18,kt=.5,Kt=.3,rt=7,vt=10,xt=.02,ht="text-right [font-variant-numeric:tabular-nums]",Ut=(0,i.memo)(function({tasks:o,arrows:f}){return(0,t.jsxs)("g",{children:[(0,t.jsx)("g",{className:"fill-gray-400 stroke-gray-400 dark:fill-gray-500 dark:stroke-gray-500",children:f.map(r=>(0,t.jsxs)("g",{children:[(0,t.jsx)("path",{d:r.d,fill:"none",strokeWidth:1}),(0,t.jsx)("path",{d:r.head,strokeWidth:0})]},r.key))}),o.map(r=>(0,t.jsxs)("g",{children:[r.track?(0,t.jsx)("path",{d:r.track,fill:r.color,fillOpacity:r.trackOpacity}):null,r.progress?(0,t.jsx)("path",{d:r.progress,fill:r.color}):null,r.milestone?(0,t.jsx)("path",{d:r.milestone,fill:r.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"}):null]},r.key))]})});function Yt({width:s,height:o,data:f,tasks:r,x:u,domain:x,unit:M,timeTicks:A,today:L,grid:E,size:H,barSize:V,colorOf:j,margin:q,tooltip:P,plotLabel:ot,todayLabel:lt,locale:R,formatDate:J,formatX:D,onTaskClick:O}){let[W,G]=(0,i.useState)(null),h=W!==null&&W<r.length?W:null,z=(0,F.useUILabels)(),n=(0,i.useMemo)(()=>{let m=(0,Lt.buildCartesianGeometry)({width:s,height:o,data:f,x:u,y:{domain:x},bounds:x,margin:q,orientation:"horizontal",placement:"band",formatValue:a=>(0,T.formatTimeTick)(a,M,R),formatX:D}),{valueScale:k,bandwidth:b,categoryPositions:N,innerWidth:ct,innerHeight:mt}=m,I=Math.min(V??Bt,b),Q=new Map(r.map((a,c)=>[a.id,c])),ut=r.map((a,c)=>{let w=N[c]+(b-I)/2,l=w+I/2,p=j(a);if(a.start===null)return{key:`${c}`,color:p,track:null,trackOpacity:1,progress:null,milestone:null,top:N[c],height:b};let y=k(a.start);if(a.milestone)return{key:`${c}`,color:p,track:null,trackOpacity:1,progress:null,milestone:`M${y},${l-rt} L${y+rt},${l} L${y},${l+rt} L${y-rt},${l} Z`,top:N[c],height:b};let S=k(a.end??a.start),C=Math.max(2,S-y);return{key:`${c}`,color:p,track:(0,ft.buildBarPath)({x:y,y:w,width:C,height:I,radius:3}),trackOpacity:a.progress===null?1:Kt,progress:a.progress===null?null:(0,ft.buildBarPath)({x:y,y:l-I*kt/2,width:Math.max(0,C*Math.min(1,Math.max(0,a.progress))),height:I*kt,radius:2,round:"right"}),milestone:null,top:N[c],height:b}}),tt=[];r.forEach((a,c)=>{if(a.start!==null)for(let w of a.dependsOn){let l=Q.get(w);if(l===void 0||l===c)continue;let p=r[l];if(p.start===null)continue;let y=k(p.end??p.start),S=N[l]+b/2,C=k(a.start),$=N[c]+b/2,et=Math.max(y+vt,C-vt);tt.push({key:`${w}-${a.id}`,d:`M${y},${S} L${et},${S} L${et},${$} L${C-5},${$}`,head:`M${C},${$} L${C-5},${$-3.5} L${C-5},${$+3.5} Z`})}});let gt=A.map(a=>({value:a,offset:k(a),label:(0,T.formatTimeTick)(a,M,R)}));return{rendered:ut,arrows:tt,categoryPositions:N,categoryCenters:m.categoryCenters,bandwidth:b,categoryTicks:m.categoryTicks,valueTicks:gt,valueScale:k,innerWidth:ct,innerHeight:mt,margin:m.margin}},[r,f,u,x,M,A,s,o,q,V,j,R,D]),it=(0,i.useCallback)(m=>{if(P===!1||r.length===0)return;let k=m.currentTarget.getBoundingClientRect(),b=m.clientY-k.top-n.margin.top;G((0,Rt.nearestIndex)(n.categoryCenters,b))},[P,r.length,n.margin.top,n.categoryCenters]),_=(0,i.useCallback)(()=>{!O||h===null||O(r[h])},[O,h,r]),st=(0,i.useCallback)(m=>(0,Pt.handleChartKeyDown)(m,{count:r.length,current:h,axis:"y",onMove:G,pick:O?_:null}),[r.length,h,O,_]),g=h===null?null:r[h];return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("svg",{width:s,height:o,role:"img","aria-label":ot??r.map(m=>m.label).join(", "),tabIndex:0,className:`${Gt.CHART_TOUCH} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:it,onPointerLeave:()=>G(null),onKeyDown:st,onBlur:()=>G(null),onClick:_,children:[(0,t.jsxs)("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:[(0,t.jsx)(wt.ChartGrid,{width:n.innerWidth,height:n.innerHeight,vertical:E?n.valueTicks.map(m=>m.offset):void 0}),h!==null?(0,t.jsx)("rect",{x:0,y:n.categoryPositions[h],width:n.innerWidth,height:n.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,(0,t.jsx)(Ut,{tasks:n.rendered,arrows:n.arrows}),L!==null?(0,t.jsxs)("g",{children:[(0,t.jsx)("line",{x1:n.valueScale(L),y1:0,x2:n.valueScale(L),y2:n.innerHeight,className:"stroke-gray-900 dark:stroke-white",strokeWidth:1,strokeDasharray:"4 4"}),(0,t.jsx)("text",{x:n.valueScale(L)+4,y:8,className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:lt})]}):null]}),(0,t.jsx)("g",{transform:`translate(${n.margin.left}, ${n.margin.top+n.innerHeight})`,children:(0,t.jsx)(pt.ChartAxis,{orientation:"bottom",ticks:n.valueTicks,length:n.innerWidth,size:H})}),(0,t.jsx)("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:u.hidden?null:(0,t.jsx)(pt.ChartAxis,{orientation:"left",ticks:n.categoryTicks,length:n.innerHeight,showLine:!1,tickSize:0,label:u.label,size:H})})]}),g&&h!==null&&P!==!1?(0,t.jsx)($t.ChartTooltip,{x:n.margin.left+(g.start===null?n.innerWidth/2:n.valueScale(g.start)),y:n.margin.top+n.categoryCenters[h],containerWidth:s,children:typeof P=="function"?P(g):(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:g.label}),(0,t.jsxs)("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[(0,t.jsx)("span",{children:z.chartStart}),(0,t.jsx)("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:g.start===null?"\u2014":J(g.start)})]}),g.milestone?null:(0,t.jsxs)("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[(0,t.jsx)("span",{children:z.chartEnd}),(0,t.jsx)("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:g.end===null?"\u2014":J(g.end)})]}),g.progress===null?null:(0,t.jsxs)("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[(0,t.jsx)("span",{children:z.chartProgress}),(0,t.jsx)("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:(0,Z.formatPercent)(g.progress,{locale:R,maximumFractionDigits:0})})]})]})}):null]})}function Ft({data:s,x:o,start:f,end:r,id:u,progress:x,milestone:M,dependencies:A,group:L,domain:E,today:H,ticks:V=6,barSize:j,rowSize:q=30,color:P,height:ot,width:lt,size:R="md",grid:J=!0,legend:D,tooltip:O=!0,tableView:W=!1,title:G,description:h,loading:z=!1,emptyState:n,error:it=!1,errorState:_,onRetry:st,actions:g,margin:m,locale:k,plotLabel:b,startLabel:N,endLabel:ct,progressLabel:mt,todayLabel:I,formatDate:Q,onTaskClick:ut,className:tt,...gt}){let a=(0,F.useUILocale)(k),c=(0,F.useUILabels)(),w=(0,i.useMemo)(()=>o.format??(e=>(0,Z.formatXValue)(e,a)),[o.format,a]),l=(0,i.useMemo)(()=>s.map((e,d)=>{let B=(0,at.readXValue)(e,o.key,d),X=(0,T.toTimestamp)(e[f]),v=r?(0,T.toTimestamp)(e[r]):null,K=M?!!e[M]:v===null,Tt=A?e[A]:void 0;return{index:d,id:String(u?e[u]??d:d),x:B,label:w(B,d),start:X,end:K?X:v??X,progress:x?(0,at.readNumber)(e,x):null,milestone:K,dependsOn:Array.isArray(Tt)?Tt.map(Et=>String(Et)):[],group:L?e[L]??null:null,datum:e}}),[s,o.key,f,r,u,x,M,A,L,w]),p=(0,i.useMemo)(()=>{let e=[];for(let d of l)d.group!==null&&!e.includes(d.group)&&e.push(d.group);return e},[l]),y=(0,i.useCallback)(e=>e.group===null?P??(0,nt.getSeriesColor)(0):(0,nt.getSeriesColor)(p.indexOf(e.group)),[p,P]),S=(0,i.useMemo)(()=>{if(E){let v=(0,T.toTimestamp)(E[0]),K=(0,T.toTimestamp)(E[1]);if(v!==null&&K!==null)return[v,K]}let e=l.flatMap(v=>v.start===null?[]:[v.start,v.end??v.start]);if(e.length===0)return[0,1];let d=Math.min(...e),B=Math.max(...e),X=B-d||864e5;return[d-X*xt,B+X*xt]},[E,l]),C=(0,i.useMemo)(()=>(0,T.niceTimeTicks)(S[0],S[1],V),[S,V]),$=(0,i.useMemo)(()=>Q??(e=>new Intl.DateTimeFormat(a,{day:"numeric",month:"short",year:"numeric"}).format(new Date(e))),[Q,a]),et=(0,i.useMemo)(()=>H===!1?null:(0,T.toTimestamp)(H??Date.now()),[H]),bt=(0,i.useMemo)(()=>p.map((e,d)=>({key:e,label:e,color:(0,nt.getSeriesColor)(d),marker:"rect"})),[p]),yt=ot??Math.max(120,l.length*q+48),At=D===void 0?p.length>=2:D!==!1,Ct=typeof D=="string"?D:"bottom";return(0,t.jsx)(Nt.ChartContainer,{title:G,description:h,height:yt,width:lt,size:R,loading:z,empty:l.length===0,emptyState:n,error:it,errorState:_,onRetry:st,actions:g,tableView:W,legendPosition:Ct,legend:At&&bt.length>0?(0,t.jsx)(St.ChartLegend,{items:bt,position:Ct,marker:"rect",size:R}):void 0,table:W?(0,t.jsx)("div",{className:"w-full overflow-x-auto",children:(0,t.jsxs)(Mt.Table,{children:[typeof G=="string"?(0,t.jsx)("caption",{className:"sr-only",children:G}):null,(0,t.jsxs)(Ot.TableHeader,{children:[(0,t.jsx)(Y.TableHeaderCell,{children:o.label??o.key}),(0,t.jsx)(Y.TableHeaderCell,{className:"text-right",children:N??c.chartStart}),(0,t.jsx)(Y.TableHeaderCell,{className:"text-right",children:ct??c.chartEnd}),x?(0,t.jsx)(Y.TableHeaderCell,{className:"text-right",children:mt??c.chartProgress}):null]}),(0,t.jsx)(Dt.TableBody,{children:l.map(e=>(0,t.jsxs)(It.TableRow,{clickable:!1,children:[(0,t.jsx)(U.TableCell,{className:"font-medium text-gray-900 dark:text-gray-100",children:e.label}),(0,t.jsx)(U.TableCell,{className:ht,children:e.start===null?"\u2014":$(e.start)}),(0,t.jsx)(U.TableCell,{className:ht,children:e.milestone||e.end===null?"\u2014":$(e.end)}),x?(0,t.jsx)(U.TableCell,{className:ht,children:e.progress===null?"\u2014":(0,Z.formatPercent)(e.progress,{locale:a,maximumFractionDigits:0})}):null]},e.index))})]})}):void 0,className:tt,...gt,children:({width:e})=>(0,t.jsx)(Yt,{width:e,height:yt,data:s,tasks:l,x:o,domain:S,unit:C.unit,timeTicks:C.values,today:et,grid:J,size:R,barSize:j,colorOf:y,margin:m,tooltip:O,plotLabel:b,todayLabel:I??c.chartToday,locale:a,formatDate:$,formatX:w,onTaskClick:ut})})}0&&(module.exports={GanttChart});
@@ -1 +1 @@
1
- "use client";import{memo as St,useCallback as rt,useMemo as x,useState as $t}from"react";import{useUILabels as vt}from"../../lib/i18n.js";import{ChartAxis as ft}from"../chart/ChartAxis.js";import{ChartContainer as Lt}from"../chart/ChartContainer.js";import{ChartGrid as Pt}from"../chart/ChartGrid.js";import{ChartLegend as Rt}from"../chart/ChartLegend.js";import{ChartTooltip as Gt}from"../chart/ChartTooltip.js";import{getSeriesColor as ut}from"../chart/palette.js";import{buildCartesianGeometry as Mt}from"../chart/utils/cartesian.js";import{readNumber as Dt,readXValue as Ot}from"../chart/utils/data.js";import{formatPercent as xt,formatXValue as At}from"../chart/utils/format.js";import{handleChartKeyDown as It}from"../chart/utils/keyboard.js";import{buildBarPath as bt}from"../chart/utils/path.js";import{nearestIndex as Et}from"../chart/utils/scales.js";import{formatTimeTick as yt,niceTimeTicks as Ht,toTimestamp as Y}from"../chart/utils/time.js";import{CHART_TOUCH as Wt}from"../chart/utils/touch.js";import{Table as Xt}from"../table/Table.js";import{TableBody as Vt}from"../table/TableBody.js";import{TableCell as Q}from"../table/TableCell.js";import{TableHeader as zt}from"../table/TableHeader.js";import{TableHeaderCell as tt}from"../table/TableHeaderCell.js";import{TableRow as _t}from"../table/TableRow.js";import{Fragment as Ft,jsx as e,jsxs as d}from"react/jsx-runtime";var Bt=18,Ct=.5,Kt=.3,et=7,Tt=10,kt=.02,gt="text-right [font-variant-numeric:tabular-nums]",Ut=St(function({tasks:h,arrows:P}){return d("g",{children:[e("g",{className:"fill-gray-400 stroke-gray-400 dark:fill-gray-500 dark:stroke-gray-500",children:P.map(r=>d("g",{children:[e("path",{d:r.d,fill:"none",strokeWidth:1}),e("path",{d:r.head,strokeWidth:0})]},r.key))}),h.map(r=>d("g",{children:[r.track?e("path",{d:r.track,fill:r.color,fillOpacity:r.trackOpacity}):null,r.progress?e("path",{d:r.progress,fill:r.color}):null,r.milestone?e("path",{d:r.milestone,fill:r.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"}):null]},r.key))]})});function Yt({width:C,height:h,data:P,tasks:r,x:N,domain:T,unit:R,timeTicks:I,today:w,grid:E,size:H,barSize:V,colorOf:F,margin:Z,tooltip:S,plotLabel:nt,todayLabel:at,locale:$,formatDate:j,formatX:G,onTaskClick:M}){let[W,L]=$t(null),p=W!==null&&W<r.length?W:null,z=vt(),n=x(()=>{let i=Mt({width:C,height:h,data:P,x:N,y:{domain:T},bounds:T,margin:Z,orientation:"horizontal",placement:"band",formatValue:a=>yt(a,R,$),formatX:G}),{valueScale:s,bandwidth:f,categoryPositions:k,innerWidth:it,innerHeight:st}=i,D=Math.min(V??Bt,f),q=new Map(r.map((a,o)=>[a.id,o])),mt=r.map((a,o)=>{let u=k[o]+(f-D)/2,l=u+D/2,v=F(a);if(a.start===null)return{key:`${o}`,color:v,track:null,trackOpacity:1,progress:null,milestone:null,top:k[o],height:f};let m=s(a.start);if(a.milestone)return{key:`${o}`,color:v,track:null,trackOpacity:1,progress:null,milestone:`M${m},${l-et} L${m+et},${l} L${m},${l+et} L${m-et},${l} Z`,top:k[o],height:f};let O=s(a.end??a.start),b=Math.max(2,O-m);return{key:`${o}`,color:v,track:bt({x:m,y:u,width:b,height:D,radius:3}),trackOpacity:a.progress===null?1:Kt,progress:a.progress===null?null:bt({x:m,y:l-D*Ct/2,width:Math.max(0,b*Math.min(1,Math.max(0,a.progress))),height:D*Ct,radius:2,round:"right"}),milestone:null,top:k[o],height:f}}),J=[];r.forEach((a,o)=>{if(a.start!==null)for(let u of a.dependsOn){let l=q.get(u);if(l===void 0||l===o)continue;let v=r[l];if(v.start===null)continue;let m=s(v.end??v.start),O=k[l]+f/2,b=s(a.start),A=k[o]+f/2,B=Math.max(m+Tt,b-Tt);J.push({key:`${u}-${a.id}`,d:`M${m},${O} L${B},${O} L${B},${A} L${b-5},${A}`,head:`M${b},${A} L${b-5},${A-3.5} L${b-5},${A+3.5} Z`})}});let ct=I.map(a=>({value:a,offset:s(a),label:yt(a,R,$)}));return{rendered:mt,arrows:J,categoryPositions:k,categoryCenters:i.categoryCenters,bandwidth:f,categoryTicks:i.categoryTicks,valueTicks:ct,valueScale:s,innerWidth:it,innerHeight:st,margin:i.margin}},[r,P,N,T,R,I,C,h,Z,V,F,$,G]),ot=rt(i=>{if(S===!1||r.length===0)return;let s=i.currentTarget.getBoundingClientRect(),f=i.clientY-s.top-n.margin.top;L(Et(n.categoryCenters,f))},[S,r.length,n.margin.top,n.categoryCenters]),_=rt(()=>{!M||p===null||M(r[p])},[M,p,r]),lt=rt(i=>It(i,{count:r.length,current:p,axis:"y",onMove:L,pick:M?_:null}),[r.length,p,M,_]),c=p===null?null:r[p];return d(Ft,{children:[d("svg",{width:C,height:h,role:"img","aria-label":nt??r.map(i=>i.label).join(", "),tabIndex:0,className:`${Wt} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:ot,onPointerLeave:()=>L(null),onKeyDown:lt,onBlur:()=>L(null),onClick:_,children:[d("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:[e(Pt,{width:n.innerWidth,height:n.innerHeight,vertical:E?n.valueTicks.map(i=>i.offset):void 0}),p!==null?e("rect",{x:0,y:n.categoryPositions[p],width:n.innerWidth,height:n.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,e(Ut,{tasks:n.rendered,arrows:n.arrows}),w!==null?d("g",{children:[e("line",{x1:n.valueScale(w),y1:0,x2:n.valueScale(w),y2:n.innerHeight,className:"stroke-gray-900 dark:stroke-white",strokeWidth:1,strokeDasharray:"4 4"}),e("text",{x:n.valueScale(w)+4,y:8,className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:at})]}):null]}),e("g",{transform:`translate(${n.margin.left}, ${n.margin.top+n.innerHeight})`,children:e(ft,{orientation:"bottom",ticks:n.valueTicks,length:n.innerWidth,size:H})}),e("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:N.hidden?null:e(ft,{orientation:"left",ticks:n.categoryTicks,length:n.innerHeight,showLine:!1,tickSize:0,label:N.label,size:H})})]}),c&&p!==null&&S!==!1?e(Gt,{x:n.margin.left+(c.start===null?n.innerWidth/2:n.valueScale(c.start)),y:n.margin.top+n.categoryCenters[p],containerWidth:C,children:typeof S=="function"?S(c):d("div",{className:"flex flex-col gap-1",children:[e("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:c.label}),d("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e("span",{children:z.chartStart}),e("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:c.start===null?"\u2014":j(c.start)})]}),c.milestone?null:d("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e("span",{children:z.chartEnd}),e("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:c.end===null?"\u2014":j(c.end)})]}),c.progress===null?null:d("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e("span",{children:z.chartProgress}),e("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:xt(c.progress,{locale:$,maximumFractionDigits:0})})]})]})}):null]})}function be({data:C,x:h,start:P,end:r,id:N,progress:T,milestone:R,dependencies:I,group:w,domain:E,today:H,ticks:V=6,barSize:F,rowSize:Z=30,color:S,height:nt,width:at,size:$="md",grid:j=!0,legend:G,tooltip:M=!0,tableView:W=!1,title:L,description:p,loading:z=!1,emptyState:n,error:ot=!1,errorState:_,onRetry:lt,actions:c,margin:i,locale:s,plotLabel:f,startLabel:k,endLabel:it,progressLabel:st,todayLabel:D,formatDate:q,onTaskClick:mt,className:J,...ct}){let a=vt(),o=x(()=>h.format??(t=>At(t,s)),[h.format,s]),u=x(()=>C.map((t,g)=>{let K=Ot(t,h.key,g),X=Y(t[P]),y=r?Y(t[r]):null,U=R?!!t[R]:y===null,pt=I?t[I]:void 0;return{index:g,id:String(N?t[N]??g:g),x:K,label:o(K,g),start:X,end:U?X:y??X,progress:T?Dt(t,T):null,milestone:U,dependsOn:Array.isArray(pt)?pt.map(wt=>String(wt)):[],group:w?t[w]??null:null,datum:t}}),[C,h.key,P,r,N,T,R,I,w,o]),l=x(()=>{let t=[];for(let g of u)g.group!==null&&!t.includes(g.group)&&t.push(g.group);return t},[u]),v=rt(t=>t.group===null?S??ut(0):ut(l.indexOf(t.group)),[l,S]),m=x(()=>{if(E){let y=Y(E[0]),U=Y(E[1]);if(y!==null&&U!==null)return[y,U]}let t=u.flatMap(y=>y.start===null?[]:[y.start,y.end??y.start]);if(t.length===0)return[0,1];let g=Math.min(...t),K=Math.max(...t),X=K-g||864e5;return[g-X*kt,K+X*kt]},[E,u]),O=x(()=>Ht(m[0],m[1],V),[m,V]),b=x(()=>q??(t=>new Intl.DateTimeFormat(s,{day:"numeric",month:"short",year:"numeric"}).format(new Date(t))),[q,s]),A=x(()=>H===!1?null:Y(H??Date.now()),[H]),B=x(()=>l.map((t,g)=>({key:t,label:t,color:ut(g),marker:"rect"})),[l]),dt=nt??Math.max(120,u.length*Z+48),Nt=G===void 0?l.length>=2:G!==!1,ht=typeof G=="string"?G:"bottom";return e(Lt,{title:L,description:p,height:dt,width:at,size:$,loading:z,empty:u.length===0,emptyState:n,error:ot,errorState:_,onRetry:lt,actions:c,tableView:W,legendPosition:ht,legend:Nt&&B.length>0?e(Rt,{items:B,position:ht,marker:"rect",size:$}):void 0,table:W?e("div",{className:"w-full overflow-x-auto",children:d(Xt,{children:[typeof L=="string"?e("caption",{className:"sr-only",children:L}):null,d(zt,{children:[e(tt,{children:h.label??h.key}),e(tt,{className:"text-right",children:k??a.chartStart}),e(tt,{className:"text-right",children:it??a.chartEnd}),T?e(tt,{className:"text-right",children:st??a.chartProgress}):null]}),e(Vt,{children:u.map(t=>d(_t,{clickable:!1,children:[e(Q,{className:"font-medium text-gray-900 dark:text-gray-100",children:t.label}),e(Q,{className:gt,children:t.start===null?"\u2014":b(t.start)}),e(Q,{className:gt,children:t.milestone||t.end===null?"\u2014":b(t.end)}),T?e(Q,{className:gt,children:t.progress===null?"\u2014":xt(t.progress,{locale:s,maximumFractionDigits:0})}):null]},t.index))})]})}):void 0,className:J,...ct,children:({width:t})=>e(Yt,{width:t,height:dt,data:C,tasks:u,x:h,domain:m,unit:O.unit,timeTicks:O.values,today:A,grid:j,size:$,barSize:F,colorOf:v,margin:i,tooltip:M,plotLabel:f,todayLabel:D??a.chartToday,locale:s,formatDate:b,formatX:o,onTaskClick:mt})})}export{be as GanttChart};
1
+ "use client";import{memo as $t,useCallback as rt,useMemo as w,useState as Lt}from"react";import{useUILabels as xt,useUILocale as Pt}from"../../lib/i18n.js";import{ChartAxis as bt}from"../chart/ChartAxis.js";import{ChartContainer as Rt}from"../chart/ChartContainer.js";import{ChartGrid as Gt}from"../chart/ChartGrid.js";import{ChartLegend as Mt}from"../chart/ChartLegend.js";import{ChartTooltip as Dt}from"../chart/ChartTooltip.js";import{getSeriesColor as ut}from"../chart/palette.js";import{buildCartesianGeometry as Ot}from"../chart/utils/cartesian.js";import{readNumber as It,readXValue as At}from"../chart/utils/data.js";import{formatPercent as Nt,formatXValue as Et}from"../chart/utils/format.js";import{handleChartKeyDown as Ht}from"../chart/utils/keyboard.js";import{buildBarPath as yt}from"../chart/utils/path.js";import{nearestIndex as Wt}from"../chart/utils/scales.js";import{formatTimeTick as Ct,niceTimeTicks as Xt,toTimestamp as U}from"../chart/utils/time.js";import{CHART_TOUCH as Vt}from"../chart/utils/touch.js";import{Table as zt}from"../table/Table.js";import{TableBody as _t}from"../table/TableBody.js";import{TableCell as Q}from"../table/TableCell.js";import{TableHeader as Bt}from"../table/TableHeader.js";import{TableHeaderCell as tt}from"../table/TableHeaderCell.js";import{TableRow as Kt}from"../table/TableRow.js";import{Fragment as jt,jsx as e,jsxs as m}from"react/jsx-runtime";var Ut=18,Tt=.5,Yt=.3,et=7,kt=10,vt=.02,gt="text-right [font-variant-numeric:tabular-nums]",Ft=$t(function({tasks:u,arrows:G}){return m("g",{children:[e("g",{className:"fill-gray-400 stroke-gray-400 dark:fill-gray-500 dark:stroke-gray-500",children:G.map(r=>m("g",{children:[e("path",{d:r.d,fill:"none",strokeWidth:1}),e("path",{d:r.head,strokeWidth:0})]},r.key))}),u.map(r=>m("g",{children:[r.track?e("path",{d:r.track,fill:r.color,fillOpacity:r.trackOpacity}):null,r.progress?e("path",{d:r.progress,fill:r.color}):null,r.milestone?e("path",{d:r.milestone,fill:r.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"}):null]},r.key))]})});function Zt({width:C,height:u,data:G,tasks:r,x:S,domain:T,unit:M,timeTicks:A,today:$,grid:E,size:H,barSize:V,colorOf:Y,margin:F,tooltip:L,plotLabel:nt,todayLabel:at,locale:P,formatDate:Z,formatX:D,onTaskClick:O}){let[W,R]=Lt(null),g=W!==null&&W<r.length?W:null,z=xt(),n=w(()=>{let i=Ot({width:C,height:u,data:G,x:S,y:{domain:T},bounds:T,margin:F,orientation:"horizontal",placement:"band",formatValue:a=>Ct(a,M,P),formatX:D}),{valueScale:b,bandwidth:h,categoryPositions:k,innerWidth:it,innerHeight:st}=i,I=Math.min(V??Ut,h),j=new Map(r.map((a,l)=>[a.id,l])),ct=r.map((a,l)=>{let v=k[l]+(h-I)/2,o=v+I/2,d=Y(a);if(a.start===null)return{key:`${l}`,color:d,track:null,trackOpacity:1,progress:null,milestone:null,top:k[l],height:h};let p=b(a.start);if(a.milestone)return{key:`${l}`,color:d,track:null,trackOpacity:1,progress:null,milestone:`M${p},${o-et} L${p+et},${o} L${p},${o+et} L${p-et},${o} Z`,top:k[l],height:h};let x=b(a.end??a.start),f=Math.max(2,x-p);return{key:`${l}`,color:d,track:yt({x:p,y:v,width:f,height:I,radius:3}),trackOpacity:a.progress===null?1:Yt,progress:a.progress===null?null:yt({x:p,y:o-I*Tt/2,width:Math.max(0,f*Math.min(1,Math.max(0,a.progress))),height:I*Tt,radius:2,round:"right"}),milestone:null,top:k[l],height:h}}),q=[];r.forEach((a,l)=>{if(a.start!==null)for(let v of a.dependsOn){let o=j.get(v);if(o===void 0||o===l)continue;let d=r[o];if(d.start===null)continue;let p=b(d.end??d.start),x=k[o]+h/2,f=b(a.start),N=k[l]+h/2,J=Math.max(p+kt,f-kt);q.push({key:`${v}-${a.id}`,d:`M${p},${x} L${J},${x} L${J},${N} L${f-5},${N}`,head:`M${f},${N} L${f-5},${N-3.5} L${f-5},${N+3.5} Z`})}});let mt=A.map(a=>({value:a,offset:b(a),label:Ct(a,M,P)}));return{rendered:ct,arrows:q,categoryPositions:k,categoryCenters:i.categoryCenters,bandwidth:h,categoryTicks:i.categoryTicks,valueTicks:mt,valueScale:b,innerWidth:it,innerHeight:st,margin:i.margin}},[r,G,S,T,M,A,C,u,F,V,Y,P,D]),ot=rt(i=>{if(L===!1||r.length===0)return;let b=i.currentTarget.getBoundingClientRect(),h=i.clientY-b.top-n.margin.top;R(Wt(n.categoryCenters,h))},[L,r.length,n.margin.top,n.categoryCenters]),_=rt(()=>{!O||g===null||O(r[g])},[O,g,r]),lt=rt(i=>Ht(i,{count:r.length,current:g,axis:"y",onMove:R,pick:O?_:null}),[r.length,g,O,_]),s=g===null?null:r[g];return m(jt,{children:[m("svg",{width:C,height:u,role:"img","aria-label":nt??r.map(i=>i.label).join(", "),tabIndex:0,className:`${Vt} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:ot,onPointerLeave:()=>R(null),onKeyDown:lt,onBlur:()=>R(null),onClick:_,children:[m("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:[e(Gt,{width:n.innerWidth,height:n.innerHeight,vertical:E?n.valueTicks.map(i=>i.offset):void 0}),g!==null?e("rect",{x:0,y:n.categoryPositions[g],width:n.innerWidth,height:n.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,e(Ft,{tasks:n.rendered,arrows:n.arrows}),$!==null?m("g",{children:[e("line",{x1:n.valueScale($),y1:0,x2:n.valueScale($),y2:n.innerHeight,className:"stroke-gray-900 dark:stroke-white",strokeWidth:1,strokeDasharray:"4 4"}),e("text",{x:n.valueScale($)+4,y:8,className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:at})]}):null]}),e("g",{transform:`translate(${n.margin.left}, ${n.margin.top+n.innerHeight})`,children:e(bt,{orientation:"bottom",ticks:n.valueTicks,length:n.innerWidth,size:H})}),e("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:S.hidden?null:e(bt,{orientation:"left",ticks:n.categoryTicks,length:n.innerHeight,showLine:!1,tickSize:0,label:S.label,size:H})})]}),s&&g!==null&&L!==!1?e(Dt,{x:n.margin.left+(s.start===null?n.innerWidth/2:n.valueScale(s.start)),y:n.margin.top+n.categoryCenters[g],containerWidth:C,children:typeof L=="function"?L(s):m("div",{className:"flex flex-col gap-1",children:[e("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:s.label}),m("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e("span",{children:z.chartStart}),e("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:s.start===null?"\u2014":Z(s.start)})]}),s.milestone?null:m("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e("span",{children:z.chartEnd}),e("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:s.end===null?"\u2014":Z(s.end)})]}),s.progress===null?null:m("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e("span",{children:z.chartProgress}),e("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:Nt(s.progress,{locale:P,maximumFractionDigits:0})})]})]})}):null]})}function Ce({data:C,x:u,start:G,end:r,id:S,progress:T,milestone:M,dependencies:A,group:$,domain:E,today:H,ticks:V=6,barSize:Y,rowSize:F=30,color:L,height:nt,width:at,size:P="md",grid:Z=!0,legend:D,tooltip:O=!0,tableView:W=!1,title:R,description:g,loading:z=!1,emptyState:n,error:ot=!1,errorState:_,onRetry:lt,actions:s,margin:i,locale:b,plotLabel:h,startLabel:k,endLabel:it,progressLabel:st,todayLabel:I,formatDate:j,onTaskClick:ct,className:q,...mt}){let a=Pt(b),l=xt(),v=w(()=>u.format??(t=>Et(t,a)),[u.format,a]),o=w(()=>C.map((t,c)=>{let B=At(t,u.key,c),X=U(t[G]),y=r?U(t[r]):null,K=M?!!t[M]:y===null,ft=A?t[A]:void 0;return{index:c,id:String(S?t[S]??c:c),x:B,label:v(B,c),start:X,end:K?X:y??X,progress:T?It(t,T):null,milestone:K,dependsOn:Array.isArray(ft)?ft.map(St=>String(St)):[],group:$?t[$]??null:null,datum:t}}),[C,u.key,G,r,S,T,M,A,$,v]),d=w(()=>{let t=[];for(let c of o)c.group!==null&&!t.includes(c.group)&&t.push(c.group);return t},[o]),p=rt(t=>t.group===null?L??ut(0):ut(d.indexOf(t.group)),[d,L]),x=w(()=>{if(E){let y=U(E[0]),K=U(E[1]);if(y!==null&&K!==null)return[y,K]}let t=o.flatMap(y=>y.start===null?[]:[y.start,y.end??y.start]);if(t.length===0)return[0,1];let c=Math.min(...t),B=Math.max(...t),X=B-c||864e5;return[c-X*vt,B+X*vt]},[E,o]),f=w(()=>Xt(x[0],x[1],V),[x,V]),N=w(()=>j??(t=>new Intl.DateTimeFormat(a,{day:"numeric",month:"short",year:"numeric"}).format(new Date(t))),[j,a]),J=w(()=>H===!1?null:U(H??Date.now()),[H]),dt=w(()=>d.map((t,c)=>({key:t,label:t,color:ut(c),marker:"rect"})),[d]),ht=nt??Math.max(120,o.length*F+48),wt=D===void 0?d.length>=2:D!==!1,pt=typeof D=="string"?D:"bottom";return e(Rt,{title:R,description:g,height:ht,width:at,size:P,loading:z,empty:o.length===0,emptyState:n,error:ot,errorState:_,onRetry:lt,actions:s,tableView:W,legendPosition:pt,legend:wt&&dt.length>0?e(Mt,{items:dt,position:pt,marker:"rect",size:P}):void 0,table:W?e("div",{className:"w-full overflow-x-auto",children:m(zt,{children:[typeof R=="string"?e("caption",{className:"sr-only",children:R}):null,m(Bt,{children:[e(tt,{children:u.label??u.key}),e(tt,{className:"text-right",children:k??l.chartStart}),e(tt,{className:"text-right",children:it??l.chartEnd}),T?e(tt,{className:"text-right",children:st??l.chartProgress}):null]}),e(_t,{children:o.map(t=>m(Kt,{clickable:!1,children:[e(Q,{className:"font-medium text-gray-900 dark:text-gray-100",children:t.label}),e(Q,{className:gt,children:t.start===null?"\u2014":N(t.start)}),e(Q,{className:gt,children:t.milestone||t.end===null?"\u2014":N(t.end)}),T?e(Q,{className:gt,children:t.progress===null?"\u2014":Nt(t.progress,{locale:a,maximumFractionDigits:0})}):null]},t.index))})]})}):void 0,className:q,...mt,children:({width:t})=>e(Zt,{width:t,height:ht,data:C,tasks:o,x:u,domain:x,unit:f.unit,timeTicks:f.values,today:J,grid:Z,size:P,barSize:Y,colorOf:p,margin:i,tooltip:O,plotLabel:h,todayLabel:I??l.chartToday,locale:a,formatDate:N,formatX:v,onTaskClick:ct})})}export{Ce as GanttChart};
@@ -1 +1 @@
1
- "use strict";"use client";var v=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var ae=Object.getOwnPropertyNames;var te=Object.prototype.hasOwnProperty;var ne=(o,a)=>{for(var c in a)v(o,c,{get:a[c],enumerable:!0})},oe=(o,a,c,d)=>{if(a&&typeof a=="object"||typeof a=="function")for(let l of ae(a))!te.call(o,l)&&l!==c&&v(o,l,{get:()=>a[l],enumerable:!(d=re(a,l))||d.enumerable});return o};var se=o=>oe(v({},"__esModule",{value:!0}),o);var de={};ne(de,{Header:()=>le});module.exports=se(de);var h=require("react"),s=require("../../lib/cn.cjs"),B=require("../../lib/i18n.cjs"),e=require("react/jsx-runtime");function le({logo:o,logoHref:a="/",onLogoClick:c,navItems:d=[],actions:l,rightContent:p,variant:t="default",size:f="md",backgroundColor:g,textColor:P,hoverColor:R,navItemTextColor:j,navItemHoverColor:D,navItemBgHover:O,navItemActiveColor:T,sticky:W=!1,fixed:z=!1,showSearch:k=!1,onSearch:N,searchPlaceholder:Q,menuLabel:_,className:q,containerClassName:A}){let w=(0,B.useUILabels)(),u=Q??w.headerSearchPlaceholder,[b,E]=(0,h.useState)(!1),[C,F]=(0,h.useState)(null),[m,L]=(0,h.useState)(""),U=()=>{E(!b)},G=r=>{F(C===r?null:r)},M=r=>{r.preventDefault(),N&&N(m)},J=(0,s.cn)(W&&"sticky top-0 z-50",z&&"fixed top-0 left-0 right-0 z-50"),K=(0,s.cn)(t==="default"&&!g&&"bg-gray-900 text-white",t==="transparent"&&!g&&"bg-transparent",t==="bordered"&&!g&&"bg-white border-b border-gray-200 text-gray-900 dark:bg-gray-900 dark:border-gray-800 dark:text-gray-100",t==="shadow"&&!g&&"bg-white shadow-md text-gray-900 dark:bg-gray-900 dark:text-gray-100"),V=(0,s.cn)(f==="sm"&&"py-2",f==="md"&&"py-4",f==="lg"&&"py-6"),X=g||"",Y=P||"",Z=R||"",$=(0,s.cn)(J,K,V,X,Y,q),I=(r,i,x=!1)=>{let ee=r.children&&r.children.length>0,H=C===i,y=(0,s.cn)("px-4 py-2 transition-colors flex items-center gap-2",x?"block w-full text-left":"inline-flex",r.active&&"font-semibold border-b-2",r.active&&(T||"border-current"),j||(t==="default"||t==="transparent"?"text-gray-300":"text-gray-600 dark:text-gray-300"),D||Z||(t==="default"||t==="transparent"?"hover:text-white":"hover:text-synertech-primary-600 dark:hover:text-synertech-primary-400"),O||"");if(ee)return(0,e.jsxs)("div",{className:x?"w-full":"relative",children:[(0,e.jsxs)("button",{type:"button",onClick:()=>G(i),className:y,children:[r.icon&&(0,e.jsx)("span",{className:"w-5 h-5",children:r.icon}),(0,e.jsx)("span",{children:r.label}),r.badge&&(0,e.jsx)("span",{className:"bg-red-600 text-white text-xs px-2 py-0.5 rounded-full",children:r.badge}),(0,e.jsx)("svg",{className:(0,s.cn)("w-4 h-4 transition-transform",H&&"rotate-180"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),H&&(0,e.jsx)("div",{className:(0,s.cn)("bg-white shadow-lg rounded-lg overflow-hidden dark:bg-gray-800 dark:shadow-black/40",x?"mt-2 mb-2":"absolute top-full left-0 mt-1 min-w-[200px]"),children:r.children?.map(n=>(0,e.jsx)("a",{href:n.href,onClick:n.onClick,target:n.external?"_blank":void 0,rel:n.external?"noopener noreferrer":void 0,className:"block px-4 py-2 text-gray-700 hover:bg-gray-100 transition-colors dark:text-gray-200 dark:hover:bg-gray-700",children:(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[n.icon&&(0,e.jsx)("span",{className:"w-5 h-5",children:n.icon}),(0,e.jsx)("span",{children:n.label}),n.badge&&(0,e.jsx)("span",{className:"bg-red-600 text-white text-xs px-2 py-0.5 rounded-full ml-auto",children:n.badge}),n.external&&(0,e.jsx)("svg",{className:"w-4 h-4 ml-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})},n.href??n.label))})]},r.href??r.label);let S=(0,e.jsxs)(e.Fragment,{children:[r.icon&&(0,e.jsx)("span",{className:"w-5 h-5",children:r.icon}),(0,e.jsx)("span",{children:r.label}),r.badge&&(0,e.jsx)("span",{className:"bg-red-600 text-white text-xs px-2 py-0.5 rounded-full",children:r.badge}),r.external&&(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]});return r.onClick?(0,e.jsx)("button",{type:"button",onClick:r.onClick,className:y,children:S},r.href??r.label):(0,e.jsx)("a",{href:r.href,target:r.external?"_blank":void 0,rel:r.external?"noopener noreferrer":void 0,className:y,children:S},r.href??r.label)};return(0,e.jsxs)("header",{className:$,children:[(0,e.jsxs)("nav",{className:(0,s.cn)("container mx-auto flex items-center justify-between px-4",A),children:[o&&(0,e.jsx)("div",{className:"flex items-center",children:a?(0,e.jsx)("a",{href:a,onClick:c,className:"flex items-center hover:opacity-80 transition-opacity",children:o}):(0,e.jsx)("div",{className:"flex items-center",children:o})}),k&&(0,e.jsx)("form",{onSubmit:M,className:"hidden md:flex flex-1 max-w-md mx-8",children:(0,e.jsx)("input",{type:"search","aria-label":u,value:m,onChange:r=>L(r.target.value),placeholder:u,className:"w-full px-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 text-gray-900 placeholder-gray-500 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-400"})}),(0,e.jsx)("div",{className:"hidden md:flex items-center gap-2",children:d.map((r,i)=>I(r,i,!1))}),(l||p)&&(0,e.jsxs)("div",{className:"hidden md:flex items-center gap-2 ml-4",children:[l,p]}),d.length>0&&(0,e.jsx)("div",{className:"md:hidden",children:(0,e.jsx)("button",{type:"button",className:(0,s.cn)("inline-flex rounded-lg border-2 p-2 w-10 h-10 justify-center transition-colors focus:outline-none",t==="default"||t==="transparent"?"text-gray-300 hover:text-white":"text-gray-600 hover:text-gray-900 dark:text-gray-300 dark:hover:text-gray-100"),onClick:U,"aria-label":_??w.headerToggleMenu,"aria-expanded":b,children:(0,e.jsx)("svg",{className:"w-5 h-5","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 14",children:(0,e.jsx)("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M1 1h15M1 7h15M1 13h15"})})})})]}),b&&d.length>0&&(0,e.jsx)("div",{className:(0,s.cn)("md:hidden border-t animate-in slide-in-from-top duration-300",t==="default"||t==="transparent"?"border-gray-700":"border-gray-200 dark:border-gray-800"),children:(0,e.jsxs)("div",{className:"flex flex-col py-2 px-4",children:[k&&(0,e.jsx)("form",{onSubmit:M,className:"mb-4",children:(0,e.jsx)("input",{type:"search","aria-label":u,value:m,onChange:r=>L(r.target.value),placeholder:u,className:"w-full px-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 text-gray-900 placeholder-gray-500 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-400"})}),d.map((r,i)=>I(r,i,!0)),(l||p)&&(0,e.jsxs)("div",{className:"flex flex-col gap-2 mt-4 pt-4 border-t border-gray-700",children:[l,p]})]})})]})}0&&(module.exports={Header});
1
+ "use strict";"use client";var k=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var oe=Object.getOwnPropertyNames;var ne=Object.prototype.hasOwnProperty;var se=(o,n)=>{for(var c in n)k(o,c,{get:n[c],enumerable:!0})},le=(o,n,c,d)=>{if(n&&typeof n=="object"||typeof n=="function")for(let l of oe(n))!ne.call(o,l)&&l!==c&&k(o,l,{get:()=>n[l],enumerable:!(d=te(n,l))||d.enumerable});return o};var de=o=>le(k({},"__esModule",{value:!0}),o);var ie={};se(ie,{Header:()=>ce});module.exports=de(ie);var h=require("react"),s=require("../../lib/cn.cjs"),f=require("../../lib/safe-href.cjs"),R=require("../../lib/i18n.cjs"),e=require("react/jsx-runtime");function ce({logo:o,logoHref:n="/",onLogoClick:c,navItems:d=[],actions:l,rightContent:p,variant:a="default",size:m="md",backgroundColor:g,textColor:j,hoverColor:D,navItemTextColor:O,navItemHoverColor:T,navItemBgHover:W,navItemActiveColor:z,sticky:Q=!1,fixed:_=!1,showSearch:N=!1,onSearch:w,searchPlaceholder:q,menuLabel:A,className:E,containerClassName:F}){let C=(0,R.useUILabels)(),u=q??C.headerSearchPlaceholder,[b,U]=(0,h.useState)(!1),[L,G]=(0,h.useState)(null),[x,H]=(0,h.useState)(""),J=()=>{U(!b)},K=r=>{G(L===r?null:r)},M=r=>{r.preventDefault(),w&&w(x)},V=(0,s.cn)(Q&&"sticky top-0 z-50",_&&"fixed top-0 left-0 right-0 z-50"),X=(0,s.cn)(a==="default"&&!g&&"bg-gray-900 text-white",a==="transparent"&&!g&&"bg-transparent",a==="bordered"&&!g&&"bg-white border-b border-gray-200 text-gray-900 dark:bg-gray-900 dark:border-gray-800 dark:text-gray-100",a==="shadow"&&!g&&"bg-white shadow-md text-gray-900 dark:bg-gray-900 dark:text-gray-100"),Y=(0,s.cn)(m==="sm"&&"py-2",m==="md"&&"py-4",m==="lg"&&"py-6"),Z=g||"",$=j||"",ee=D||"",re=(0,s.cn)(V,X,Y,Z,$,E),I=(r,i,y=!1)=>{let ae=r.children&&r.children.length>0,B=L===i,v=(0,s.cn)("px-4 py-2 transition-colors flex items-center gap-2",y?"block w-full text-left":"inline-flex",r.active&&"font-semibold border-b-2",r.active&&(z||"border-current"),O||(a==="default"||a==="transparent"?"text-gray-300":"text-gray-600 dark:text-gray-300"),T||ee||(a==="default"||a==="transparent"?"hover:text-white":"hover:text-synertech-primary-600 dark:hover:text-synertech-primary-400"),W||"");if(ae)return(0,e.jsxs)("div",{className:y?"w-full":"relative",children:[(0,e.jsxs)("button",{type:"button",onClick:()=>K(i),className:v,children:[r.icon&&(0,e.jsx)("span",{className:"w-5 h-5",children:r.icon}),(0,e.jsx)("span",{children:r.label}),r.badge&&(0,e.jsx)("span",{className:"bg-red-600 text-white text-xs px-2 py-0.5 rounded-full",children:r.badge}),(0,e.jsx)("svg",{className:(0,s.cn)("w-4 h-4 transition-transform",B&&"rotate-180"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),B&&(0,e.jsx)("div",{className:(0,s.cn)("bg-white shadow-lg rounded-lg overflow-hidden dark:bg-gray-800 dark:shadow-black/40",y?"mt-2 mb-2":"absolute top-full left-0 mt-1 min-w-[200px]"),children:r.children?.map(t=>(0,e.jsx)("a",{href:(0,f.componentHref)("Header",t.href),onClick:t.onClick,target:t.external?"_blank":void 0,rel:t.external?"noopener noreferrer":void 0,className:"block px-4 py-2 text-gray-700 hover:bg-gray-100 transition-colors dark:text-gray-200 dark:hover:bg-gray-700",children:(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[t.icon&&(0,e.jsx)("span",{className:"w-5 h-5",children:t.icon}),(0,e.jsx)("span",{children:t.label}),t.badge&&(0,e.jsx)("span",{className:"bg-red-600 text-white text-xs px-2 py-0.5 rounded-full ml-auto",children:t.badge}),t.external&&(0,e.jsx)("svg",{className:"w-4 h-4 ml-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})},t.href??t.label))})]},r.href??r.label);let P=(0,e.jsxs)(e.Fragment,{children:[r.icon&&(0,e.jsx)("span",{className:"w-5 h-5",children:r.icon}),(0,e.jsx)("span",{children:r.label}),r.badge&&(0,e.jsx)("span",{className:"bg-red-600 text-white text-xs px-2 py-0.5 rounded-full",children:r.badge}),r.external&&(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]});return r.onClick?(0,e.jsx)("button",{type:"button",onClick:r.onClick,className:v,children:P},r.href??r.label):(0,e.jsx)("a",{href:(0,f.componentHref)("Header",r.href),target:r.external?"_blank":void 0,rel:r.external?"noopener noreferrer":void 0,className:v,children:P},r.href??r.label)},S=(0,f.componentHref)("Header",n);return(0,e.jsxs)("header",{className:re,children:[(0,e.jsxs)("nav",{className:(0,s.cn)("container mx-auto flex items-center justify-between px-4",F),children:[o&&(0,e.jsx)("div",{className:"flex items-center",children:S?(0,e.jsx)("a",{href:S,onClick:c,className:"flex items-center hover:opacity-80 transition-opacity",children:o}):(0,e.jsx)("div",{className:"flex items-center",children:o})}),N&&(0,e.jsx)("form",{onSubmit:M,className:"hidden md:flex flex-1 max-w-md mx-8",children:(0,e.jsx)("input",{type:"search","aria-label":u,value:x,onChange:r=>H(r.target.value),placeholder:u,className:"w-full px-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 text-gray-900 placeholder-gray-500 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-400"})}),(0,e.jsx)("div",{className:"hidden md:flex items-center gap-2",children:d.map((r,i)=>I(r,i,!1))}),(l||p)&&(0,e.jsxs)("div",{className:"hidden md:flex items-center gap-2 ml-4",children:[l,p]}),d.length>0&&(0,e.jsx)("div",{className:"md:hidden",children:(0,e.jsx)("button",{type:"button",className:(0,s.cn)("inline-flex rounded-lg border-2 p-2 w-10 h-10 justify-center transition-colors focus:outline-none",a==="default"||a==="transparent"?"text-gray-300 hover:text-white":"text-gray-600 hover:text-gray-900 dark:text-gray-300 dark:hover:text-gray-100"),onClick:J,"aria-label":A??C.headerToggleMenu,"aria-expanded":b,children:(0,e.jsx)("svg",{className:"w-5 h-5","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 14",children:(0,e.jsx)("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M1 1h15M1 7h15M1 13h15"})})})})]}),b&&d.length>0&&(0,e.jsx)("div",{className:(0,s.cn)("md:hidden border-t animate-in slide-in-from-top duration-300",a==="default"||a==="transparent"?"border-gray-700":"border-gray-200 dark:border-gray-800"),children:(0,e.jsxs)("div",{className:"flex flex-col py-2 px-4",children:[N&&(0,e.jsx)("form",{onSubmit:M,className:"mb-4",children:(0,e.jsx)("input",{type:"search","aria-label":u,value:x,onChange:r=>H(r.target.value),placeholder:u,className:"w-full px-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 text-gray-900 placeholder-gray-500 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-400"})}),d.map((r,i)=>I(r,i,!0)),(l||p)&&(0,e.jsxs)("div",{className:"flex flex-col gap-2 mt-4 pt-4 border-t border-gray-700",children:[l,p]})]})})]})}0&&(module.exports={Header});
@@ -1 +1 @@
1
- "use client";import{useState as x}from"react";import{cn as n}from"../../lib/cn.js";import{useUILabels as ee}from"../../lib/i18n.js";import{Fragment as re,jsx as r,jsxs as o}from"react/jsx-runtime";function oe({logo:p,logoHref:y="/",onLogoClick:S,navItems:d=[],actions:c,rightContent:i,variant:a="default",size:u="md",backgroundColor:l,textColor:B,hoverColor:P,navItemTextColor:R,navItemHoverColor:j,navItemBgHover:D,navItemActiveColor:O,sticky:T=!1,fixed:W=!1,showSearch:v=!1,onSearch:k,searchPlaceholder:z,menuLabel:Q,className:_,containerClassName:q}){let N=ee(),g=z??N.headerSearchPlaceholder,[h,A]=x(!1),[w,E]=x(null),[f,C]=x(""),F=()=>{A(!h)},U=e=>{E(w===e?null:e)},L=e=>{e.preventDefault(),k&&k(f)},G=n(T&&"sticky top-0 z-50",W&&"fixed top-0 left-0 right-0 z-50"),J=n(a==="default"&&!l&&"bg-gray-900 text-white",a==="transparent"&&!l&&"bg-transparent",a==="bordered"&&!l&&"bg-white border-b border-gray-200 text-gray-900 dark:bg-gray-900 dark:border-gray-800 dark:text-gray-100",a==="shadow"&&!l&&"bg-white shadow-md text-gray-900 dark:bg-gray-900 dark:text-gray-100"),K=n(u==="sm"&&"py-2",u==="md"&&"py-4",u==="lg"&&"py-6"),V=l||"",X=B||"",Y=P||"",Z=n(G,J,K,V,X,_),M=(e,s,b=!1)=>{let $=e.children&&e.children.length>0,I=w===s,m=n("px-4 py-2 transition-colors flex items-center gap-2",b?"block w-full text-left":"inline-flex",e.active&&"font-semibold border-b-2",e.active&&(O||"border-current"),R||(a==="default"||a==="transparent"?"text-gray-300":"text-gray-600 dark:text-gray-300"),j||Y||(a==="default"||a==="transparent"?"hover:text-white":"hover:text-synertech-primary-600 dark:hover:text-synertech-primary-400"),D||"");if($)return o("div",{className:b?"w-full":"relative",children:[o("button",{type:"button",onClick:()=>U(s),className:m,children:[e.icon&&r("span",{className:"w-5 h-5",children:e.icon}),r("span",{children:e.label}),e.badge&&r("span",{className:"bg-red-600 text-white text-xs px-2 py-0.5 rounded-full",children:e.badge}),r("svg",{className:n("w-4 h-4 transition-transform",I&&"rotate-180"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),I&&r("div",{className:n("bg-white shadow-lg rounded-lg overflow-hidden dark:bg-gray-800 dark:shadow-black/40",b?"mt-2 mb-2":"absolute top-full left-0 mt-1 min-w-[200px]"),children:e.children?.map(t=>r("a",{href:t.href,onClick:t.onClick,target:t.external?"_blank":void 0,rel:t.external?"noopener noreferrer":void 0,className:"block px-4 py-2 text-gray-700 hover:bg-gray-100 transition-colors dark:text-gray-200 dark:hover:bg-gray-700",children:o("div",{className:"flex items-center gap-2",children:[t.icon&&r("span",{className:"w-5 h-5",children:t.icon}),r("span",{children:t.label}),t.badge&&r("span",{className:"bg-red-600 text-white text-xs px-2 py-0.5 rounded-full ml-auto",children:t.badge}),t.external&&r("svg",{className:"w-4 h-4 ml-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})},t.href??t.label))})]},e.href??e.label);let H=o(re,{children:[e.icon&&r("span",{className:"w-5 h-5",children:e.icon}),r("span",{children:e.label}),e.badge&&r("span",{className:"bg-red-600 text-white text-xs px-2 py-0.5 rounded-full",children:e.badge}),e.external&&r("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]});return e.onClick?r("button",{type:"button",onClick:e.onClick,className:m,children:H},e.href??e.label):r("a",{href:e.href,target:e.external?"_blank":void 0,rel:e.external?"noopener noreferrer":void 0,className:m,children:H},e.href??e.label)};return o("header",{className:Z,children:[o("nav",{className:n("container mx-auto flex items-center justify-between px-4",q),children:[p&&r("div",{className:"flex items-center",children:y?r("a",{href:y,onClick:S,className:"flex items-center hover:opacity-80 transition-opacity",children:p}):r("div",{className:"flex items-center",children:p})}),v&&r("form",{onSubmit:L,className:"hidden md:flex flex-1 max-w-md mx-8",children:r("input",{type:"search","aria-label":g,value:f,onChange:e=>C(e.target.value),placeholder:g,className:"w-full px-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 text-gray-900 placeholder-gray-500 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-400"})}),r("div",{className:"hidden md:flex items-center gap-2",children:d.map((e,s)=>M(e,s,!1))}),(c||i)&&o("div",{className:"hidden md:flex items-center gap-2 ml-4",children:[c,i]}),d.length>0&&r("div",{className:"md:hidden",children:r("button",{type:"button",className:n("inline-flex rounded-lg border-2 p-2 w-10 h-10 justify-center transition-colors focus:outline-none",a==="default"||a==="transparent"?"text-gray-300 hover:text-white":"text-gray-600 hover:text-gray-900 dark:text-gray-300 dark:hover:text-gray-100"),onClick:F,"aria-label":Q??N.headerToggleMenu,"aria-expanded":h,children:r("svg",{className:"w-5 h-5","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 14",children:r("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M1 1h15M1 7h15M1 13h15"})})})})]}),h&&d.length>0&&r("div",{className:n("md:hidden border-t animate-in slide-in-from-top duration-300",a==="default"||a==="transparent"?"border-gray-700":"border-gray-200 dark:border-gray-800"),children:o("div",{className:"flex flex-col py-2 px-4",children:[v&&r("form",{onSubmit:L,className:"mb-4",children:r("input",{type:"search","aria-label":g,value:f,onChange:e=>C(e.target.value),placeholder:g,className:"w-full px-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 text-gray-900 placeholder-gray-500 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-400"})}),d.map((e,s)=>M(e,s,!0)),(c||i)&&o("div",{className:"flex flex-col gap-2 mt-4 pt-4 border-t border-gray-700",children:[c,i]})]})})]})}export{oe as Header};
1
+ "use client";import{useState as x}from"react";import{cn as o}from"../../lib/cn.js";import{componentHref as y}from"../../lib/safe-href.js";import{useUILabels as ae}from"../../lib/i18n.js";import{Fragment as te,jsx as r,jsxs as n}from"react/jsx-runtime";function de({logo:p,logoHref:B="/",onLogoClick:P,navItems:d=[],actions:c,rightContent:i,variant:a="default",size:u="md",backgroundColor:l,textColor:R,hoverColor:j,navItemTextColor:D,navItemHoverColor:O,navItemBgHover:T,navItemActiveColor:W,sticky:z=!1,fixed:Q=!1,showSearch:v=!1,onSearch:k,searchPlaceholder:_,menuLabel:q,className:A,containerClassName:E}){let N=ae(),g=_??N.headerSearchPlaceholder,[h,F]=x(!1),[w,U]=x(null),[f,C]=x(""),G=()=>{F(!h)},J=e=>{U(w===e?null:e)},L=e=>{e.preventDefault(),k&&k(f)},K=o(z&&"sticky top-0 z-50",Q&&"fixed top-0 left-0 right-0 z-50"),V=o(a==="default"&&!l&&"bg-gray-900 text-white",a==="transparent"&&!l&&"bg-transparent",a==="bordered"&&!l&&"bg-white border-b border-gray-200 text-gray-900 dark:bg-gray-900 dark:border-gray-800 dark:text-gray-100",a==="shadow"&&!l&&"bg-white shadow-md text-gray-900 dark:bg-gray-900 dark:text-gray-100"),X=o(u==="sm"&&"py-2",u==="md"&&"py-4",u==="lg"&&"py-6"),Y=l||"",Z=R||"",$=j||"",ee=o(K,V,X,Y,Z,A),H=(e,s,m=!1)=>{let re=e.children&&e.children.length>0,I=w===s,b=o("px-4 py-2 transition-colors flex items-center gap-2",m?"block w-full text-left":"inline-flex",e.active&&"font-semibold border-b-2",e.active&&(W||"border-current"),D||(a==="default"||a==="transparent"?"text-gray-300":"text-gray-600 dark:text-gray-300"),O||$||(a==="default"||a==="transparent"?"hover:text-white":"hover:text-synertech-primary-600 dark:hover:text-synertech-primary-400"),T||"");if(re)return n("div",{className:m?"w-full":"relative",children:[n("button",{type:"button",onClick:()=>J(s),className:b,children:[e.icon&&r("span",{className:"w-5 h-5",children:e.icon}),r("span",{children:e.label}),e.badge&&r("span",{className:"bg-red-600 text-white text-xs px-2 py-0.5 rounded-full",children:e.badge}),r("svg",{className:o("w-4 h-4 transition-transform",I&&"rotate-180"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),I&&r("div",{className:o("bg-white shadow-lg rounded-lg overflow-hidden dark:bg-gray-800 dark:shadow-black/40",m?"mt-2 mb-2":"absolute top-full left-0 mt-1 min-w-[200px]"),children:e.children?.map(t=>r("a",{href:y("Header",t.href),onClick:t.onClick,target:t.external?"_blank":void 0,rel:t.external?"noopener noreferrer":void 0,className:"block px-4 py-2 text-gray-700 hover:bg-gray-100 transition-colors dark:text-gray-200 dark:hover:bg-gray-700",children:n("div",{className:"flex items-center gap-2",children:[t.icon&&r("span",{className:"w-5 h-5",children:t.icon}),r("span",{children:t.label}),t.badge&&r("span",{className:"bg-red-600 text-white text-xs px-2 py-0.5 rounded-full ml-auto",children:t.badge}),t.external&&r("svg",{className:"w-4 h-4 ml-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})},t.href??t.label))})]},e.href??e.label);let S=n(te,{children:[e.icon&&r("span",{className:"w-5 h-5",children:e.icon}),r("span",{children:e.label}),e.badge&&r("span",{className:"bg-red-600 text-white text-xs px-2 py-0.5 rounded-full",children:e.badge}),e.external&&r("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]});return e.onClick?r("button",{type:"button",onClick:e.onClick,className:b,children:S},e.href??e.label):r("a",{href:y("Header",e.href),target:e.external?"_blank":void 0,rel:e.external?"noopener noreferrer":void 0,className:b,children:S},e.href??e.label)},M=y("Header",B);return n("header",{className:ee,children:[n("nav",{className:o("container mx-auto flex items-center justify-between px-4",E),children:[p&&r("div",{className:"flex items-center",children:M?r("a",{href:M,onClick:P,className:"flex items-center hover:opacity-80 transition-opacity",children:p}):r("div",{className:"flex items-center",children:p})}),v&&r("form",{onSubmit:L,className:"hidden md:flex flex-1 max-w-md mx-8",children:r("input",{type:"search","aria-label":g,value:f,onChange:e=>C(e.target.value),placeholder:g,className:"w-full px-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 text-gray-900 placeholder-gray-500 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-400"})}),r("div",{className:"hidden md:flex items-center gap-2",children:d.map((e,s)=>H(e,s,!1))}),(c||i)&&n("div",{className:"hidden md:flex items-center gap-2 ml-4",children:[c,i]}),d.length>0&&r("div",{className:"md:hidden",children:r("button",{type:"button",className:o("inline-flex rounded-lg border-2 p-2 w-10 h-10 justify-center transition-colors focus:outline-none",a==="default"||a==="transparent"?"text-gray-300 hover:text-white":"text-gray-600 hover:text-gray-900 dark:text-gray-300 dark:hover:text-gray-100"),onClick:G,"aria-label":q??N.headerToggleMenu,"aria-expanded":h,children:r("svg",{className:"w-5 h-5","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 14",children:r("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M1 1h15M1 7h15M1 13h15"})})})})]}),h&&d.length>0&&r("div",{className:o("md:hidden border-t animate-in slide-in-from-top duration-300",a==="default"||a==="transparent"?"border-gray-700":"border-gray-200 dark:border-gray-800"),children:n("div",{className:"flex flex-col py-2 px-4",children:[v&&r("form",{onSubmit:L,className:"mb-4",children:r("input",{type:"search","aria-label":g,value:f,onChange:e=>C(e.target.value),placeholder:g,className:"w-full px-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 text-gray-900 placeholder-gray-500 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-400"})}),d.map((e,s)=>H(e,s,!0)),(c||i)&&n("div",{className:"flex flex-col gap-2 mt-4 pt-4 border-t border-gray-700",children:[c,i]})]})})]})}export{de as Header};
@@ -1 +1 @@
1
- "use strict";"use client";var ae=Object.defineProperty;var Ce=Object.getOwnPropertyDescriptor;var ke=Object.getOwnPropertyNames;var ye=Object.prototype.hasOwnProperty;var we=(s,o)=>{for(var t in o)ae(s,t,{get:o[t],enumerable:!0})},ve=(s,o,t,e)=>{if(o&&typeof o=="object"||typeof o=="function")for(let b of ke(o))!ye.call(s,b)&&b!==t&&ae(s,b,{get:()=>o[b],enumerable:!(e=Ce(o,b))||e.enumerable});return s};var Se=s=>ve(ae({},"__esModule",{value:!0}),s);var Ae={};we(Ae,{Heatmap:()=>Xe,resetHeatmapWarnings:()=>$e});module.exports=Se(Ae);var m=require("react"),ue=require("../../lib/cn.cjs"),ne=require("../chart/ChartAxis.cjs"),me=require("../chart/ChartContainer.cjs"),ce=require("../chart/ChartScaleLegend.cjs"),he=require("../chart/ChartTableView.cjs"),ge=require("../chart/ChartTooltip.cjs"),M=require("../chart/palette.cjs"),K=require("../chart/utils/data.cjs"),Y=require("../chart/utils/format.cjs"),_=require("../chart/utils/keyboard.cjs"),k=require("../chart/utils/scales.cjs"),L=require("../chart/utils/text.cjs"),de=require("../chart/utils/ticks.cjs"),fe=require("../chart/utils/touch.cjs"),r=require("react/jsx-runtime"),xe=2,Le=2,Ve=12,He=16,ie="cell:",re=!1,Ee=(0,m.memo)(function({cells:o,radius:t}){return(0,r.jsx)("g",{children:o.map(e=>(0,r.jsxs)("g",{children:[(0,r.jsx)("rect",{x:e.x,y:e.y,width:e.width,height:e.height,rx:t,fill:e.missing?void 0:e.color,className:e.missing?"fill-gray-100 dark:fill-gray-800":void 0}),e.label?(0,r.jsx)("text",{x:e.x+e.width/2,y:e.y+e.height/2,textAnchor:"middle",dominantBaseline:"central",className:(0,ue.cn)("text-[10px] [font-variant-numeric:tabular-nums]",e.onDark?"fill-gray-50 dark:fill-gray-900":"fill-gray-900 dark:fill-gray-50"),children:e.label}):null]},e.key))})});function Re({width:s,height:o,columns:t,rows:e,lookup:b,colorScale:S,x:p,y:C,size:V,cellGap:w,cellRadius:O,showValues:B,tooltip:P,plotLabel:Q,formatValue:z,formatX:T,formatY:W,onCellClick:H}){let[E,D]=(0,m.useState)(null),c=E!==null&&E.column<t.length&&E.row<e.length?E:null,a=(0,m.useMemo)(()=>{let g=t.map((f,i)=>T(f,i)),d=e.map((f,i)=>W(f,i)),u={top:8,right:8,bottom:p.hidden?8:p.height??24+(p.label?16:0),left:C.hidden?8:C.height??(0,L.widestLabel)(d)+Ve+(C.label?16:0)},l=Math.max(0,s-u.left-u.right),v=Math.max(0,o-u.top-u.bottom),h=(0,k.createBandScale)(t.map((f,i)=>i),[0,l],{paddingInner:0,paddingOuter:0}),x=(0,k.createBandScale)(e.map((f,i)=>i),[0,v],{paddingInner:0,paddingOuter:0}),Z=Math.max(0,h.bandwidth-w),X=Math.max(0,x.bandwidth-w),I=[];e.forEach((f,i)=>{t.forEach((te,G)=>{let n=b.get(`${(0,k.toKey)(te)}|${(0,k.toKey)(f)}`)?.value??null,y=null;if(B&&n!==null&&X>=He){let A=z(n);(0,L.estimateTextWidth)(A,10)+6<=Z&&(y=A)}I.push({key:`${G}-${i}`,column:G,row:i,x:h(G)+w/2,y:x(i)+w/2,width:Z,height:X,color:n===null?"transparent":S(n),label:y,onDark:n!==null&&S.onDark(n),missing:n===null})})});let $=(0,L.labelStride)(g.length,l,(0,L.widestLabel)(g)),q=(0,L.labelStride)(d.length,v,L.AXIS_FONT_SIZE+4),F=p.hidden?[]:g.map((f,i)=>({value:t[i],offset:h.center(i),label:f})).filter((f,i)=>i%$===0),J=C.hidden?[]:d.map((f,i)=>({value:e[i],offset:x.center(i),label:f})).filter((f,i)=>i%q===0);return{margin:u,innerWidth:l,innerHeight:v,columnScale:h,rowScale:x,cells:I,columnTicks:F,rowTicks:J}},[t,e,b,S,p,C,s,o,w,B,z,T,W]),N=(0,m.useCallback)((g,d)=>{let u=t[g],l=e[d],v=b.get(`${(0,k.toKey)(u)}|${(0,k.toKey)(l)}`),h=v?.value??null;return{x:u,y:l,xLabel:T(u,g),yLabel:W(l,d),value:h,formattedValue:h===null?"\u2014":z(h),color:h===null?"transparent":S(h),datum:v?.datum}},[t,e,b,S,z,T,W]),j=(0,m.useCallback)(g=>{if(P===!1||t.length===0||e.length===0)return;let d=g.currentTarget.getBoundingClientRect(),u=g.clientX-d.left-a.margin.left,l=g.clientY-d.top-a.margin.top,v=Math.floor(u/(a.columnScale.step||1)),h=Math.floor(l/(a.rowScale.step||1));if(v<0||v>=t.length||h<0||h>=e.length){D(null);return}D(x=>x?.column===v&&x.row===h?x:{column:v,row:h})},[P,t.length,e.length,a.margin,a.columnScale,a.rowScale]),U=(0,m.useCallback)(()=>{!H||!c||H(N(c.column,c.row))},[H,c,N]),ee=(0,m.useCallback)(g=>{if(t.length===0||e.length===0||(0,_.pressChartMark)(g,H&&c?U:null))return;let d=c?.column??null,u=c?.row??null,l;switch(g.key){case"ArrowRight":l={row:u??0,column:(0,_.stepChartCursor)(d,1,t.length)};break;case"ArrowLeft":l={row:u??0,column:(0,_.stepChartCursor)(d,-1,t.length)};break;case"ArrowDown":l={column:d??0,row:(0,_.stepChartCursor)(u,1,e.length)};break;case"ArrowUp":l={column:d??0,row:(0,_.stepChartCursor)(u,-1,e.length)};break;case"Home":l={row:u??0,column:0};break;case"End":l={row:u??0,column:t.length-1};break;case"Escape":l=null;break;default:return}g.preventDefault(),D(l)},[t.length,e.length,c,H,U]),R=c?N(c.column,c.row):null;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("svg",{width:s,height:o,role:"img","aria-label":Q??`${p.label??p.key} / ${C.label??C.key}`,tabIndex:0,className:`${fe.CHART_TOUCH} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:j,onPointerLeave:()=>D(null),onKeyDown:ee,onBlur:()=>D(null),onClick:U,children:[(0,r.jsxs)("g",{transform:`translate(${a.margin.left}, ${a.margin.top})`,children:[(0,r.jsx)(Ee,{cells:a.cells,radius:O}),c?(0,r.jsx)("rect",{x:a.columnScale(c.column)+w/2,y:a.rowScale(c.row)+w/2,width:Math.max(0,a.columnScale.bandwidth-w),height:Math.max(0,a.rowScale.bandwidth-w),rx:O,fill:"none",strokeWidth:2,className:"stroke-gray-900 dark:stroke-white","aria-hidden":"true"}):null]}),(0,r.jsx)("g",{transform:`translate(${a.margin.left}, ${a.margin.top+a.innerHeight})`,children:p.hidden?null:(0,r.jsx)(ne.ChartAxis,{orientation:"bottom",ticks:a.columnTicks,length:a.innerWidth,showLine:!1,tickSize:0,label:p.label,size:V})}),(0,r.jsx)("g",{transform:`translate(${a.margin.left}, ${a.margin.top})`,children:C.hidden?null:(0,r.jsx)(ne.ChartAxis,{orientation:"left",ticks:a.rowTicks,length:a.innerHeight,showLine:!1,tickSize:0,label:C.label,size:V})})]}),c&&R&&P!==!1?(0,r.jsx)(ge.ChartTooltip,{x:a.margin.left+a.columnScale.center(c.column),y:a.margin.top+a.rowScale.center(c.row),containerWidth:s,children:typeof P=="function"?P(R):(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,r.jsxs)("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:[R.yLabel," \xB7 ",R.xLabel]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"h-2.5 w-2.5 shrink-0 rounded-sm",style:{backgroundColor:R.color},"aria-hidden":"true"}),(0,r.jsx)("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:R.formattedValue})]})]})}):null]})}function se(s,o,t){if(t)return t;let e=new Map;return s.forEach((b,S)=>{let p=(0,K.readXValue)(b,o,S),C=(0,k.toKey)(p);e.has(C)||e.set(C,p)}),[...e.values()]}function Xe({data:s,x:o,y:t,value:e,format:b,domain:S,scale:p="sequential",center:C=0,steps:V,colors:w,xDomain:O,yDomain:B,cellGap:P=xe,cellRadius:Q=Le,showValues:z=!1,height:T=280,width:W,size:H="md",legend:E=!0,legendLabel:D,tooltip:c=!0,tableView:a=!1,title:N,description:j,loading:U=!1,emptyState:ee,error:R=!1,errorState:g,onRetry:d,actions:u,locale:l,plotLabel:v,onCellClick:h,className:x,...Z}){V!==void 0&&V>M.CHART_MAX_COLOR_CLASSES&&!re&&(re=!0,console.warn(`[@synertech/ui] A Heatmap was cut into ${V} colour classes. Past ${M.CHART_MAX_COLOR_CLASSES} two neighbouring cells stop being tellable apart: leave \`steps\` unset and let the ramp stay continuous.`));let X=(0,m.useMemo)(()=>se(s,o.key,O),[s,o.key,O]),I=(0,m.useMemo)(()=>se(s,t.key,B),[s,t.key,B]),$=(0,m.useMemo)(()=>{let n=new Map;return s.forEach((y,A)=>{let oe=(0,K.readNumber)(y,e);if(oe===null)return;let be=(0,K.readXValue)(y,o.key,A),pe=(0,K.readXValue)(y,t.key,A);n.set(`${(0,k.toKey)(be)}|${(0,k.toKey)(pe)}`,{value:oe,datum:y})}),n},[s,o.key,t.key,e]),q=(0,m.useMemo)(()=>b??(n=>(0,Y.formatAuto)(n,l)),[b,l]),F=(0,m.useMemo)(()=>o.format??(n=>(0,Y.formatXValue)(n,l)),[o.format,l]),J=(0,m.useMemo)(()=>t.format??(n=>(0,Y.formatXValue)(n,l)),[t.format,l]),f=(0,m.useMemo)(()=>{let n=S??(0,de.extent)([...$.values()].map(y=>y.value))??[0,1];return p==="diverging"?(0,M.createDivergingScale)(n,{center:C,steps:V,colors:w}):(0,M.createSequentialScale)(n,{steps:V,colors:w})},[S,$,p,C,V,w]),i=(0,m.useMemo)(()=>I.map(n=>{let y={[t.key]:n};return X.forEach(A=>{y[`${ie}${(0,k.toKey)(A)}`]=$.get(`${(0,k.toKey)(A)}|${(0,k.toKey)(n)}`)?.value??null}),y}),[I,X,$,t.key]),te=(0,m.useMemo)(()=>X.map((n,y)=>({key:`${ie}${(0,k.toKey)(n)}`,label:F(n,y)})),[X,F]),G=E!==!1,le=typeof E=="string"?E:"bottom";return(0,r.jsx)(me.ChartContainer,{title:N,description:j,height:T,width:W,size:H,loading:U,empty:$.size===0,emptyState:ee,error:R,errorState:g,onRetry:d,actions:u,tableView:a,legendPosition:le,legend:G?(0,r.jsx)(ce.ChartScaleLegend,{scale:f,label:D,format:q,size:H,locale:l}):void 0,table:a?(0,r.jsx)(he.ChartTableView,{data:i,series:te,xKey:t.key,xLabel:t.label??t.key,formatX:J,formatValue:q,caption:typeof N=="string"?N:void 0}):void 0,className:x,...Z,children:({width:n})=>(0,r.jsx)(Re,{width:n,height:T,columns:X,rows:I,lookup:$,colorScale:f,x:o,y:t,size:H,cellGap:P,cellRadius:Q,showValues:z,tooltip:c,plotLabel:v,formatValue:q,formatX:F,formatY:J,onCellClick:h})})}function $e(){re=!1}0&&(module.exports={Heatmap,resetHeatmapWarnings});
1
+ "use strict";"use client";var ne=Object.defineProperty;var ye=Object.getOwnPropertyDescriptor;var we=Object.getOwnPropertyNames;var ve=Object.prototype.hasOwnProperty;var Se=(o,r)=>{for(var t in r)ne(o,t,{get:r[t],enumerable:!0})},xe=(o,r,t,e)=>{if(r&&typeof r=="object"||typeof r=="function")for(let b of we(r))!ve.call(o,b)&&b!==t&&ne(o,b,{get:()=>r[b],enumerable:!(e=ye(r,b))||e.enumerable});return o};var Le=o=>xe(ne({},"__esModule",{value:!0}),o);var Te={};Se(Te,{Heatmap:()=>Ae,resetHeatmapWarnings:()=>Pe});module.exports=Le(Te);var c=require("react"),ce=require("../../lib/cn.cjs"),me=require("../../lib/i18n.cjs"),re=require("../chart/ChartAxis.cjs"),he=require("../chart/ChartContainer.cjs"),ge=require("../chart/ChartScaleLegend.cjs"),de=require("../chart/ChartTableView.cjs"),fe=require("../chart/ChartTooltip.cjs"),z=require("../chart/palette.cjs"),K=require("../chart/utils/data.cjs"),J=require("../chart/utils/format.cjs"),M=require("../chart/utils/keyboard.cjs"),k=require("../chart/utils/scales.cjs"),V=require("../chart/utils/text.cjs"),be=require("../chart/utils/ticks.cjs"),pe=require("../chart/utils/touch.cjs"),n=require("react/jsx-runtime"),Ve=2,He=2,Ee=12,Re=16,se="cell:",le=!1,Xe=(0,c.memo)(function({cells:r,radius:t}){return(0,n.jsx)("g",{children:r.map(e=>(0,n.jsxs)("g",{children:[(0,n.jsx)("rect",{x:e.x,y:e.y,width:e.width,height:e.height,rx:t,fill:e.missing?void 0:e.color,className:e.missing?"fill-gray-100 dark:fill-gray-800":void 0}),e.label?(0,n.jsx)("text",{x:e.x+e.width/2,y:e.y+e.height/2,textAnchor:"middle",dominantBaseline:"central",className:(0,ce.cn)("text-[10px] [font-variant-numeric:tabular-nums]",e.onDark?"fill-gray-50 dark:fill-gray-900":"fill-gray-900 dark:fill-gray-50"),children:e.label}):null]},e.key))})});function $e({width:o,height:r,columns:t,rows:e,lookup:b,colorScale:S,x:p,y:C,size:H,cellGap:w,cellRadius:O,showValues:B,tooltip:T,plotLabel:j,formatValue:W,formatX:D,formatY:I,onCellClick:E}){let[X,N]=(0,c.useState)(null),m=X!==null&&X.column<t.length&&X.row<e.length?X:null,a=(0,c.useMemo)(()=>{let g=t.map((f,l)=>D(f,l)),d=e.map((f,l)=>I(f,l)),s={top:8,right:8,bottom:p.hidden?8:p.height??24+(p.label?16:0),left:C.hidden?8:C.height??(0,V.widestLabel)(d)+Ee+(C.label?16:0)},u=Math.max(0,o-s.left-s.right),v=Math.max(0,r-s.top-s.bottom),h=(0,k.createBandScale)(t.map((f,l)=>l),[0,u],{paddingInner:0,paddingOuter:0}),x=(0,k.createBandScale)(e.map((f,l)=>l),[0,v],{paddingInner:0,paddingOuter:0}),Q=Math.max(0,h.bandwidth-w),L=Math.max(0,x.bandwidth-w),A=[];e.forEach((f,l)=>{t.forEach((ae,Y)=>{let R=b.get(`${(0,k.toKey)(ae)}|${(0,k.toKey)(f)}`)?.value??null,i=null;if(B&&R!==null&&L>=Re){let y=W(R);(0,V.estimateTextWidth)(y,10)+6<=Q&&(i=y)}A.push({key:`${Y}-${l}`,column:Y,row:l,x:h(Y)+w/2,y:x(l)+w/2,width:Q,height:L,color:R===null?"transparent":S(R),label:i,onDark:R!==null&&S.onDark(R),missing:R===null})})});let q=(0,V.labelStride)(g.length,u,(0,V.widestLabel)(g)),P=(0,V.labelStride)(d.length,v,V.AXIS_FONT_SIZE+4),F=p.hidden?[]:g.map((f,l)=>({value:t[l],offset:h.center(l),label:f})).filter((f,l)=>l%q===0),G=C.hidden?[]:d.map((f,l)=>({value:e[l],offset:x.center(l),label:f})).filter((f,l)=>l%P===0);return{margin:s,innerWidth:u,innerHeight:v,columnScale:h,rowScale:x,cells:A,columnTicks:F,rowTicks:G}},[t,e,b,S,p,C,o,r,w,B,W,D,I]),_=(0,c.useCallback)((g,d)=>{let s=t[g],u=e[d],v=b.get(`${(0,k.toKey)(s)}|${(0,k.toKey)(u)}`),h=v?.value??null;return{x:s,y:u,xLabel:D(s,g),yLabel:I(u,d),value:h,formattedValue:h===null?"\u2014":W(h),color:h===null?"transparent":S(h),datum:v?.datum}},[t,e,b,S,W,D,I]),ee=(0,c.useCallback)(g=>{if(T===!1||t.length===0||e.length===0)return;let d=g.currentTarget.getBoundingClientRect(),s=g.clientX-d.left-a.margin.left,u=g.clientY-d.top-a.margin.top,v=Math.floor(s/(a.columnScale.step||1)),h=Math.floor(u/(a.rowScale.step||1));if(v<0||v>=t.length||h<0||h>=e.length){N(null);return}N(x=>x?.column===v&&x.row===h?x:{column:v,row:h})},[T,t.length,e.length,a.margin,a.columnScale,a.rowScale]),U=(0,c.useCallback)(()=>{!E||!m||E(_(m.column,m.row))},[E,m,_]),te=(0,c.useCallback)(g=>{if(t.length===0||e.length===0||(0,M.pressChartMark)(g,E&&m?U:null))return;let d=m?.column??null,s=m?.row??null,u;switch(g.key){case"ArrowRight":u={row:s??0,column:(0,M.stepChartCursor)(d,1,t.length)};break;case"ArrowLeft":u={row:s??0,column:(0,M.stepChartCursor)(d,-1,t.length)};break;case"ArrowDown":u={column:d??0,row:(0,M.stepChartCursor)(s,1,e.length)};break;case"ArrowUp":u={column:d??0,row:(0,M.stepChartCursor)(s,-1,e.length)};break;case"Home":u={row:s??0,column:0};break;case"End":u={row:s??0,column:t.length-1};break;case"Escape":u=null;break;default:return}g.preventDefault(),N(u)},[t.length,e.length,m,E,U]),$=m?_(m.column,m.row):null;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("svg",{width:o,height:r,role:"img","aria-label":j??`${p.label??p.key} / ${C.label??C.key}`,tabIndex:0,className:`${pe.CHART_TOUCH} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:ee,onPointerLeave:()=>N(null),onKeyDown:te,onBlur:()=>N(null),onClick:U,children:[(0,n.jsxs)("g",{transform:`translate(${a.margin.left}, ${a.margin.top})`,children:[(0,n.jsx)(Xe,{cells:a.cells,radius:O}),m?(0,n.jsx)("rect",{x:a.columnScale(m.column)+w/2,y:a.rowScale(m.row)+w/2,width:Math.max(0,a.columnScale.bandwidth-w),height:Math.max(0,a.rowScale.bandwidth-w),rx:O,fill:"none",strokeWidth:2,className:"stroke-gray-900 dark:stroke-white","aria-hidden":"true"}):null]}),(0,n.jsx)("g",{transform:`translate(${a.margin.left}, ${a.margin.top+a.innerHeight})`,children:p.hidden?null:(0,n.jsx)(re.ChartAxis,{orientation:"bottom",ticks:a.columnTicks,length:a.innerWidth,showLine:!1,tickSize:0,label:p.label,size:H})}),(0,n.jsx)("g",{transform:`translate(${a.margin.left}, ${a.margin.top})`,children:C.hidden?null:(0,n.jsx)(re.ChartAxis,{orientation:"left",ticks:a.rowTicks,length:a.innerHeight,showLine:!1,tickSize:0,label:C.label,size:H})})]}),m&&$&&T!==!1?(0,n.jsx)(fe.ChartTooltip,{x:a.margin.left+a.columnScale.center(m.column),y:a.margin.top+a.rowScale.center(m.row),containerWidth:o,children:typeof T=="function"?T($):(0,n.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,n.jsxs)("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:[$.yLabel," \xB7 ",$.xLabel]}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{className:"h-2.5 w-2.5 shrink-0 rounded-sm",style:{backgroundColor:$.color},"aria-hidden":"true"}),(0,n.jsx)("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:$.formattedValue})]})]})}):null]})}function ue(o,r,t){if(t)return t;let e=new Map;return o.forEach((b,S)=>{let p=(0,K.readXValue)(b,r,S),C=(0,k.toKey)(p);e.has(C)||e.set(C,p)}),[...e.values()]}function Ae({data:o,x:r,y:t,value:e,format:b,domain:S,scale:p="sequential",center:C=0,steps:H,colors:w,xDomain:O,yDomain:B,cellGap:T=Ve,cellRadius:j=He,showValues:W=!1,height:D=280,width:I,size:E="md",legend:X=!0,legendLabel:N,tooltip:m=!0,tableView:a=!1,title:_,description:ee,loading:U=!1,emptyState:te,error:$=!1,errorState:g,onRetry:d,actions:s,locale:u,plotLabel:v,onCellClick:h,className:x,...Q}){let L=(0,me.useUILocale)(u);H!==void 0&&H>z.CHART_MAX_COLOR_CLASSES&&!le&&(le=!0,console.warn(`[@synertech/ui] A Heatmap was cut into ${H} colour classes. Past ${z.CHART_MAX_COLOR_CLASSES} two neighbouring cells stop being tellable apart: leave \`steps\` unset and let the ramp stay continuous.`));let A=(0,c.useMemo)(()=>ue(o,r.key,O),[o,r.key,O]),q=(0,c.useMemo)(()=>ue(o,t.key,B),[o,t.key,B]),P=(0,c.useMemo)(()=>{let i=new Map;return o.forEach((y,Z)=>{let ie=(0,K.readNumber)(y,e);if(ie===null)return;let Ce=(0,K.readXValue)(y,r.key,Z),ke=(0,K.readXValue)(y,t.key,Z);i.set(`${(0,k.toKey)(Ce)}|${(0,k.toKey)(ke)}`,{value:ie,datum:y})}),i},[o,r.key,t.key,e]),F=(0,c.useMemo)(()=>b??(i=>(0,J.formatAuto)(i,L)),[b,L]),G=(0,c.useMemo)(()=>r.format??(i=>(0,J.formatXValue)(i,L)),[r.format,L]),f=(0,c.useMemo)(()=>t.format??(i=>(0,J.formatXValue)(i,L)),[t.format,L]),l=(0,c.useMemo)(()=>{let i=S??(0,be.extent)([...P.values()].map(y=>y.value))??[0,1];return p==="diverging"?(0,z.createDivergingScale)(i,{center:C,steps:H,colors:w}):(0,z.createSequentialScale)(i,{steps:H,colors:w})},[S,P,p,C,H,w]),ae=(0,c.useMemo)(()=>q.map(i=>{let y={[t.key]:i};return A.forEach(Z=>{y[`${se}${(0,k.toKey)(Z)}`]=P.get(`${(0,k.toKey)(Z)}|${(0,k.toKey)(i)}`)?.value??null}),y}),[q,A,P,t.key]),Y=(0,c.useMemo)(()=>A.map((i,y)=>({key:`${se}${(0,k.toKey)(i)}`,label:G(i,y)})),[A,G]),oe=X!==!1,R=typeof X=="string"?X:"bottom";return(0,n.jsx)(he.ChartContainer,{title:_,description:ee,height:D,width:I,size:E,loading:U,empty:P.size===0,emptyState:te,error:$,errorState:g,onRetry:d,actions:s,tableView:a,legendPosition:R,legend:oe?(0,n.jsx)(ge.ChartScaleLegend,{scale:l,label:N,format:F,size:E,locale:L}):void 0,table:a?(0,n.jsx)(de.ChartTableView,{data:ae,series:Y,xKey:t.key,xLabel:t.label??t.key,formatX:f,formatValue:F,caption:typeof _=="string"?_:void 0}):void 0,className:x,...Q,children:({width:i})=>(0,n.jsx)($e,{width:i,height:D,columns:A,rows:q,lookup:P,colorScale:l,x:r,y:t,size:E,cellGap:T,cellRadius:j,showValues:W,tooltip:m,plotLabel:v,formatValue:F,formatX:G,formatY:f,onCellClick:h})})}function Pe(){le=!1}0&&(module.exports={Heatmap,resetHeatmapWarnings});
@@ -1 +1 @@
1
- "use client";import{memo as de,useCallback as G,useMemo as S,useState as fe}from"react";import{cn as be}from"../../lib/cn.js";import{ChartAxis as re}from"../chart/ChartAxis.js";import{ChartContainer as pe}from"../chart/ChartContainer.js";import{ChartScaleLegend as Ce}from"../chart/ChartScaleLegend.js";import{ChartTableView as ke}from"../chart/ChartTableView.js";import{ChartTooltip as ye}from"../chart/ChartTooltip.js";import{CHART_MAX_COLOR_CLASSES as le,createDivergingScale as we,createSequentialScale as ve}from"../chart/palette.js";import{readNumber as Se,readXValue as ee}from"../chart/utils/data.js";import{formatAuto as xe,formatXValue as oe}from"../chart/utils/format.js";import{pressChartMark as Le,stepChartCursor as Y}from"../chart/utils/keyboard.js";import{createBandScale as ie,toKey as y}from"../chart/utils/scales.js";import{AXIS_FONT_SIZE as Ve,estimateTextWidth as He,labelStride as se,widestLabel as ue}from"../chart/utils/text.js";import{extent as Ee}from"../chart/utils/ticks.js";import{CHART_TOUCH as Re}from"../chart/utils/touch.js";import{Fragment as Ne,jsx as h,jsxs as N}from"react/jsx-runtime";var Xe=2,$e=2,Ae=12,Pe=16,me="cell:",te=!1,Te=de(function({cells:g,radius:t}){return h("g",{children:g.map(e=>N("g",{children:[h("rect",{x:e.x,y:e.y,width:e.width,height:e.height,rx:t,fill:e.missing?void 0:e.color,className:e.missing?"fill-gray-100 dark:fill-gray-800":void 0}),e.label?h("text",{x:e.x+e.width/2,y:e.y+e.height/2,textAnchor:"middle",dominantBaseline:"central",className:be("text-[10px] [font-variant-numeric:tabular-nums]",e.onDark?"fill-gray-50 dark:fill-gray-900":"fill-gray-900 dark:fill-gray-50"),children:e.label}):null]},e.key))})});function De({width:b,height:g,columns:t,rows:e,lookup:x,colorScale:w,x:d,y:f,size:L,cellGap:C,cellRadius:W,showValues:I,tooltip:A,plotLabel:Z,formatValue:_,formatX:P,formatY:M,onCellClick:V}){let[H,T]=fe(null),i=H!==null&&H.column<t.length&&H.row<e.length?H:null,a=S(()=>{let u=t.map((c,l)=>P(c,l)),m=e.map((c,l)=>M(c,l)),o={top:8,right:8,bottom:d.hidden?8:d.height??24+(d.label?16:0),left:f.hidden?8:f.height??ue(m)+Ae+(f.label?16:0)},r=Math.max(0,b-o.left-o.right),k=Math.max(0,g-o.top-o.bottom),s=ie(t.map((c,l)=>l),[0,r],{paddingInner:0,paddingOuter:0}),v=ie(e.map((c,l)=>l),[0,k],{paddingInner:0,paddingOuter:0}),q=Math.max(0,s.bandwidth-C),R=Math.max(0,v.bandwidth-C),z=[];e.forEach((c,l)=>{t.forEach((j,U)=>{let n=x.get(`${y(j)}|${y(c)}`)?.value??null,p=null;if(I&&n!==null&&R>=Pe){let $=_(n);He($,10)+6<=q&&(p=$)}z.push({key:`${U}-${l}`,column:U,row:l,x:s(U)+C/2,y:v(l)+C/2,width:q,height:R,color:n===null?"transparent":w(n),label:p,onDark:n!==null&&w.onDark(n),missing:n===null})})});let X=se(u.length,r,ue(u)),O=se(m.length,k,Ve+4),B=d.hidden?[]:u.map((c,l)=>({value:t[l],offset:s.center(l),label:c})).filter((c,l)=>l%X===0),F=f.hidden?[]:m.map((c,l)=>({value:e[l],offset:v.center(l),label:c})).filter((c,l)=>l%O===0);return{margin:o,innerWidth:r,innerHeight:k,columnScale:s,rowScale:v,cells:z,columnTicks:B,rowTicks:F}},[t,e,x,w,d,f,b,g,C,I,_,P,M]),D=G((u,m)=>{let o=t[u],r=e[m],k=x.get(`${y(o)}|${y(r)}`),s=k?.value??null;return{x:o,y:r,xLabel:P(o,u),yLabel:M(r,m),value:s,formattedValue:s===null?"\u2014":_(s),color:s===null?"transparent":w(s),datum:k?.datum}},[t,e,x,w,_,P,M]),J=G(u=>{if(A===!1||t.length===0||e.length===0)return;let m=u.currentTarget.getBoundingClientRect(),o=u.clientX-m.left-a.margin.left,r=u.clientY-m.top-a.margin.top,k=Math.floor(o/(a.columnScale.step||1)),s=Math.floor(r/(a.rowScale.step||1));if(k<0||k>=t.length||s<0||s>=e.length){T(null);return}T(v=>v?.column===k&&v.row===s?v:{column:k,row:s})},[A,t.length,e.length,a.margin,a.columnScale,a.rowScale]),K=G(()=>{!V||!i||V(D(i.column,i.row))},[V,i,D]),Q=G(u=>{if(t.length===0||e.length===0||Le(u,V&&i?K:null))return;let m=i?.column??null,o=i?.row??null,r;switch(u.key){case"ArrowRight":r={row:o??0,column:Y(m,1,t.length)};break;case"ArrowLeft":r={row:o??0,column:Y(m,-1,t.length)};break;case"ArrowDown":r={column:m??0,row:Y(o,1,e.length)};break;case"ArrowUp":r={column:m??0,row:Y(o,-1,e.length)};break;case"Home":r={row:o??0,column:0};break;case"End":r={row:o??0,column:t.length-1};break;case"Escape":r=null;break;default:return}u.preventDefault(),T(r)},[t.length,e.length,i,V,K]),E=i?D(i.column,i.row):null;return N(Ne,{children:[N("svg",{width:b,height:g,role:"img","aria-label":Z??`${d.label??d.key} / ${f.label??f.key}`,tabIndex:0,className:`${Re} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:J,onPointerLeave:()=>T(null),onKeyDown:Q,onBlur:()=>T(null),onClick:K,children:[N("g",{transform:`translate(${a.margin.left}, ${a.margin.top})`,children:[h(Te,{cells:a.cells,radius:W}),i?h("rect",{x:a.columnScale(i.column)+C/2,y:a.rowScale(i.row)+C/2,width:Math.max(0,a.columnScale.bandwidth-C),height:Math.max(0,a.rowScale.bandwidth-C),rx:W,fill:"none",strokeWidth:2,className:"stroke-gray-900 dark:stroke-white","aria-hidden":"true"}):null]}),h("g",{transform:`translate(${a.margin.left}, ${a.margin.top+a.innerHeight})`,children:d.hidden?null:h(re,{orientation:"bottom",ticks:a.columnTicks,length:a.innerWidth,showLine:!1,tickSize:0,label:d.label,size:L})}),h("g",{transform:`translate(${a.margin.left}, ${a.margin.top})`,children:f.hidden?null:h(re,{orientation:"left",ticks:a.rowTicks,length:a.innerHeight,showLine:!1,tickSize:0,label:f.label,size:L})})]}),i&&E&&A!==!1?h(ye,{x:a.margin.left+a.columnScale.center(i.column),y:a.margin.top+a.rowScale.center(i.row),containerWidth:b,children:typeof A=="function"?A(E):N("div",{className:"flex flex-col gap-1",children:[N("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:[E.yLabel," \xB7 ",E.xLabel]}),N("div",{className:"flex items-center gap-2",children:[h("span",{className:"h-2.5 w-2.5 shrink-0 rounded-sm",style:{backgroundColor:E.color},"aria-hidden":"true"}),h("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:E.formattedValue})]})]})}):null]})}function ce(b,g,t){if(t)return t;let e=new Map;return b.forEach((x,w)=>{let d=ee(x,g,w),f=y(d);e.has(f)||e.set(f,d)}),[...e.values()]}function Qe({data:b,x:g,y:t,value:e,format:x,domain:w,scale:d="sequential",center:f=0,steps:L,colors:C,xDomain:W,yDomain:I,cellGap:A=Xe,cellRadius:Z=$e,showValues:_=!1,height:P=280,width:M,size:V="md",legend:H=!0,legendLabel:T,tooltip:i=!0,tableView:a=!1,title:D,description:J,loading:K=!1,emptyState:Q,error:E=!1,errorState:u,onRetry:m,actions:o,locale:r,plotLabel:k,onCellClick:s,className:v,...q}){L!==void 0&&L>le&&!te&&(te=!0,console.warn(`[@synertech/ui] A Heatmap was cut into ${L} colour classes. Past ${le} two neighbouring cells stop being tellable apart: leave \`steps\` unset and let the ramp stay continuous.`));let R=S(()=>ce(b,g.key,W),[b,g.key,W]),z=S(()=>ce(b,t.key,I),[b,t.key,I]),X=S(()=>{let n=new Map;return b.forEach((p,$)=>{let ne=Se(p,e);if(ne===null)return;let he=ee(p,g.key,$),ge=ee(p,t.key,$);n.set(`${y(he)}|${y(ge)}`,{value:ne,datum:p})}),n},[b,g.key,t.key,e]),O=S(()=>x??(n=>xe(n,r)),[x,r]),B=S(()=>g.format??(n=>oe(n,r)),[g.format,r]),F=S(()=>t.format??(n=>oe(n,r)),[t.format,r]),c=S(()=>{let n=w??Ee([...X.values()].map(p=>p.value))??[0,1];return d==="diverging"?we(n,{center:f,steps:L,colors:C}):ve(n,{steps:L,colors:C})},[w,X,d,f,L,C]),l=S(()=>z.map(n=>{let p={[t.key]:n};return R.forEach($=>{p[`${me}${y($)}`]=X.get(`${y($)}|${y(n)}`)?.value??null}),p}),[z,R,X,t.key]),j=S(()=>R.map((n,p)=>({key:`${me}${y(n)}`,label:B(n,p)})),[R,B]),U=H!==!1,ae=typeof H=="string"?H:"bottom";return h(pe,{title:D,description:J,height:P,width:M,size:V,loading:K,empty:X.size===0,emptyState:Q,error:E,errorState:u,onRetry:m,actions:o,tableView:a,legendPosition:ae,legend:U?h(Ce,{scale:c,label:T,format:O,size:V,locale:r}):void 0,table:a?h(ke,{data:l,series:j,xKey:t.key,xLabel:t.label??t.key,formatX:F,formatValue:O,caption:typeof D=="string"?D:void 0}):void 0,className:v,...q,children:({width:n})=>h(De,{width:n,height:P,columns:R,rows:z,lookup:X,colorScale:c,x:g,y:t,size:V,cellGap:A,cellRadius:Z,showValues:_,tooltip:i,plotLabel:k,formatValue:O,formatX:B,formatY:F,onCellClick:s})})}function je(){te=!1}export{Qe as Heatmap,je as resetHeatmapWarnings};
1
+ "use client";import{memo as fe,useCallback as Y,useMemo as x,useState as be}from"react";import{cn as pe}from"../../lib/cn.js";import{useUILocale as Ce}from"../../lib/i18n.js";import{ChartAxis as le}from"../chart/ChartAxis.js";import{ChartContainer as ke}from"../chart/ChartContainer.js";import{ChartScaleLegend as ye}from"../chart/ChartScaleLegend.js";import{ChartTableView as we}from"../chart/ChartTableView.js";import{ChartTooltip as ve}from"../chart/ChartTooltip.js";import{CHART_MAX_COLOR_CLASSES as oe,createDivergingScale as Se,createSequentialScale as xe}from"../chart/palette.js";import{readNumber as Le,readXValue as te}from"../chart/utils/data.js";import{formatAuto as Ve,formatXValue as ie}from"../chart/utils/format.js";import{pressChartMark as He,stepChartCursor as Z}from"../chart/utils/keyboard.js";import{createBandScale as se,toKey as y}from"../chart/utils/scales.js";import{AXIS_FONT_SIZE as Ee,estimateTextWidth as Re,labelStride as ue,widestLabel as ce}from"../chart/utils/text.js";import{extent as Xe}from"../chart/utils/ticks.js";import{CHART_TOUCH as $e}from"../chart/utils/touch.js";import{Fragment as Me,jsx as h,jsxs as _}from"react/jsx-runtime";var Ae=2,Pe=2,Te=12,De=16,me="cell:",ae=!1,Ne=fe(function({cells:g,radius:t}){return h("g",{children:g.map(e=>_("g",{children:[h("rect",{x:e.x,y:e.y,width:e.width,height:e.height,rx:t,fill:e.missing?void 0:e.color,className:e.missing?"fill-gray-100 dark:fill-gray-800":void 0}),e.label?h("text",{x:e.x+e.width/2,y:e.y+e.height/2,textAnchor:"middle",dominantBaseline:"central",className:pe("text-[10px] [font-variant-numeric:tabular-nums]",e.onDark?"fill-gray-50 dark:fill-gray-900":"fill-gray-900 dark:fill-gray-50"),children:e.label}):null]},e.key))})});function _e({width:b,height:g,columns:t,rows:e,lookup:L,colorScale:w,x:d,y:f,size:V,cellGap:C,cellRadius:W,showValues:I,tooltip:P,plotLabel:J,formatValue:M,formatX:T,formatY:z,onCellClick:H}){let[R,D]=be(null),i=R!==null&&R.column<t.length&&R.row<e.length?R:null,a=x(()=>{let u=t.map((m,n)=>T(m,n)),c=e.map((m,n)=>z(m,n)),l={top:8,right:8,bottom:d.hidden?8:d.height??24+(d.label?16:0),left:f.hidden?8:f.height??ce(c)+Te+(f.label?16:0)},o=Math.max(0,b-l.left-l.right),k=Math.max(0,g-l.top-l.bottom),s=se(t.map((m,n)=>n),[0,o],{paddingInner:0,paddingOuter:0}),v=se(e.map((m,n)=>n),[0,k],{paddingInner:0,paddingOuter:0}),G=Math.max(0,s.bandwidth-C),S=Math.max(0,v.bandwidth-C),$=[];e.forEach((m,n)=>{t.forEach((ee,q)=>{let E=L.get(`${y(ee)}|${y(m)}`)?.value??null,r=null;if(I&&E!==null&&S>=De){let p=M(E);Re(p,10)+6<=G&&(r=p)}$.push({key:`${q}-${n}`,column:q,row:n,x:s(q)+C/2,y:v(n)+C/2,width:G,height:S,color:E===null?"transparent":w(E),label:r,onDark:E!==null&&w.onDark(E),missing:E===null})})});let O=ue(u.length,o,ce(u)),A=ue(c.length,k,Ee+4),B=d.hidden?[]:u.map((m,n)=>({value:t[n],offset:s.center(n),label:m})).filter((m,n)=>n%O===0),U=f.hidden?[]:c.map((m,n)=>({value:e[n],offset:v.center(n),label:m})).filter((m,n)=>n%A===0);return{margin:l,innerWidth:o,innerHeight:k,columnScale:s,rowScale:v,cells:$,columnTicks:B,rowTicks:U}},[t,e,L,w,d,f,b,g,C,I,M,T,z]),N=Y((u,c)=>{let l=t[u],o=e[c],k=L.get(`${y(l)}|${y(o)}`),s=k?.value??null;return{x:l,y:o,xLabel:T(l,u),yLabel:z(o,c),value:s,formattedValue:s===null?"\u2014":M(s),color:s===null?"transparent":w(s),datum:k?.datum}},[t,e,L,w,M,T,z]),Q=Y(u=>{if(P===!1||t.length===0||e.length===0)return;let c=u.currentTarget.getBoundingClientRect(),l=u.clientX-c.left-a.margin.left,o=u.clientY-c.top-a.margin.top,k=Math.floor(l/(a.columnScale.step||1)),s=Math.floor(o/(a.rowScale.step||1));if(k<0||k>=t.length||s<0||s>=e.length){D(null);return}D(v=>v?.column===k&&v.row===s?v:{column:k,row:s})},[P,t.length,e.length,a.margin,a.columnScale,a.rowScale]),K=Y(()=>{!H||!i||H(N(i.column,i.row))},[H,i,N]),j=Y(u=>{if(t.length===0||e.length===0||He(u,H&&i?K:null))return;let c=i?.column??null,l=i?.row??null,o;switch(u.key){case"ArrowRight":o={row:l??0,column:Z(c,1,t.length)};break;case"ArrowLeft":o={row:l??0,column:Z(c,-1,t.length)};break;case"ArrowDown":o={column:c??0,row:Z(l,1,e.length)};break;case"ArrowUp":o={column:c??0,row:Z(l,-1,e.length)};break;case"Home":o={row:l??0,column:0};break;case"End":o={row:l??0,column:t.length-1};break;case"Escape":o=null;break;default:return}u.preventDefault(),D(o)},[t.length,e.length,i,H,K]),X=i?N(i.column,i.row):null;return _(Me,{children:[_("svg",{width:b,height:g,role:"img","aria-label":J??`${d.label??d.key} / ${f.label??f.key}`,tabIndex:0,className:`${$e} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:Q,onPointerLeave:()=>D(null),onKeyDown:j,onBlur:()=>D(null),onClick:K,children:[_("g",{transform:`translate(${a.margin.left}, ${a.margin.top})`,children:[h(Ne,{cells:a.cells,radius:W}),i?h("rect",{x:a.columnScale(i.column)+C/2,y:a.rowScale(i.row)+C/2,width:Math.max(0,a.columnScale.bandwidth-C),height:Math.max(0,a.rowScale.bandwidth-C),rx:W,fill:"none",strokeWidth:2,className:"stroke-gray-900 dark:stroke-white","aria-hidden":"true"}):null]}),h("g",{transform:`translate(${a.margin.left}, ${a.margin.top+a.innerHeight})`,children:d.hidden?null:h(le,{orientation:"bottom",ticks:a.columnTicks,length:a.innerWidth,showLine:!1,tickSize:0,label:d.label,size:V})}),h("g",{transform:`translate(${a.margin.left}, ${a.margin.top})`,children:f.hidden?null:h(le,{orientation:"left",ticks:a.rowTicks,length:a.innerHeight,showLine:!1,tickSize:0,label:f.label,size:V})})]}),i&&X&&P!==!1?h(ve,{x:a.margin.left+a.columnScale.center(i.column),y:a.margin.top+a.rowScale.center(i.row),containerWidth:b,children:typeof P=="function"?P(X):_("div",{className:"flex flex-col gap-1",children:[_("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:[X.yLabel," \xB7 ",X.xLabel]}),_("div",{className:"flex items-center gap-2",children:[h("span",{className:"h-2.5 w-2.5 shrink-0 rounded-sm",style:{backgroundColor:X.color},"aria-hidden":"true"}),h("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:X.formattedValue})]})]})}):null]})}function he(b,g,t){if(t)return t;let e=new Map;return b.forEach((L,w)=>{let d=te(L,g,w),f=y(d);e.has(f)||e.set(f,d)}),[...e.values()]}function tt({data:b,x:g,y:t,value:e,format:L,domain:w,scale:d="sequential",center:f=0,steps:V,colors:C,xDomain:W,yDomain:I,cellGap:P=Ae,cellRadius:J=Pe,showValues:M=!1,height:T=280,width:z,size:H="md",legend:R=!0,legendLabel:D,tooltip:i=!0,tableView:a=!1,title:N,description:Q,loading:K=!1,emptyState:j,error:X=!1,errorState:u,onRetry:c,actions:l,locale:o,plotLabel:k,onCellClick:s,className:v,...G}){let S=Ce(o);V!==void 0&&V>oe&&!ae&&(ae=!0,console.warn(`[@synertech/ui] A Heatmap was cut into ${V} colour classes. Past ${oe} two neighbouring cells stop being tellable apart: leave \`steps\` unset and let the ramp stay continuous.`));let $=x(()=>he(b,g.key,W),[b,g.key,W]),O=x(()=>he(b,t.key,I),[b,t.key,I]),A=x(()=>{let r=new Map;return b.forEach((p,F)=>{let re=Le(p,e);if(re===null)return;let ge=te(p,g.key,F),de=te(p,t.key,F);r.set(`${y(ge)}|${y(de)}`,{value:re,datum:p})}),r},[b,g.key,t.key,e]),B=x(()=>L??(r=>Ve(r,S)),[L,S]),U=x(()=>g.format??(r=>ie(r,S)),[g.format,S]),m=x(()=>t.format??(r=>ie(r,S)),[t.format,S]),n=x(()=>{let r=w??Xe([...A.values()].map(p=>p.value))??[0,1];return d==="diverging"?Se(r,{center:f,steps:V,colors:C}):xe(r,{steps:V,colors:C})},[w,A,d,f,V,C]),ee=x(()=>O.map(r=>{let p={[t.key]:r};return $.forEach(F=>{p[`${me}${y(F)}`]=A.get(`${y(F)}|${y(r)}`)?.value??null}),p}),[O,$,A,t.key]),q=x(()=>$.map((r,p)=>({key:`${me}${y(r)}`,label:U(r,p)})),[$,U]),ne=R!==!1,E=typeof R=="string"?R:"bottom";return h(ke,{title:N,description:Q,height:T,width:z,size:H,loading:K,empty:A.size===0,emptyState:j,error:X,errorState:u,onRetry:c,actions:l,tableView:a,legendPosition:E,legend:ne?h(ye,{scale:n,label:D,format:B,size:H,locale:S}):void 0,table:a?h(we,{data:ee,series:q,xKey:t.key,xLabel:t.label??t.key,formatX:m,formatValue:B,caption:typeof N=="string"?N:void 0}):void 0,className:v,...G,children:({width:r})=>h(_e,{width:r,height:T,columns:$,rows:O,lookup:A,colorScale:n,x:g,y:t,size:H,cellGap:P,cellRadius:J,showValues:M,tooltip:i,plotLabel:k,formatValue:B,formatX:U,formatY:m,onCellClick:s})})}function at(){ae=!1}export{tt as Heatmap,at as resetHeatmapWarnings};
@@ -1,5 +1,5 @@
1
- "use strict";"use client";var j=Object.create;var E=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var Q=Object.getPrototypeOf,X=Object.prototype.hasOwnProperty;var Y=(t,o)=>{for(var s in o)E(t,s,{get:o[s],enumerable:!0})},W=(t,o,s,d)=>{if(o&&typeof o=="object"||typeof o=="function")for(let l of J(o))!X.call(t,l)&&l!==s&&E(t,l,{get:()=>o[l],enumerable:!(d=F(o,l))||d.enumerable});return t};var H=(t,o,s)=>(s=t!=null?j(Q(t)):{},W(o||!t||!t.__esModule?E(s,"default",{value:t,enumerable:!0}):s,t)),Z=t=>W(E({},"__esModule",{value:!0}),t);var ue={};Y(ue,{HelpButton:()=>$,WithHelpButton:()=>ce});module.exports=Z(ue);var a=require("react"),_=H(require("dompurify"),1),U=H(require("react-markdown"),1),A=H(require("remark-gfm"),1),D=require("../../lib/i18n.cjs"),e=require("react/jsx-runtime"),ee=(0,e.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,e.jsx)("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),(0,e.jsx)("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),te=(0,e.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,e.jsx)("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),(0,e.jsx)("polyline",{points:"17 21 17 13 7 13 7 21"}),(0,e.jsx)("polyline",{points:"7 3 7 8 15 8"})]}),re=(0,e.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,e.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,e.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),ae=(0,e.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,e.jsx)("polyline",{points:"1 4 1 10 7 10"}),(0,e.jsx)("path",{d:"M3.51 15a9 9 0 1 0 2.13-9.36L1 10"})]}),oe=(0,e.jsxs)("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,e.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10"}),(0,e.jsx)("path",{className:"opacity-75",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z",fill:"currentColor"})]}),se={xs:"w-4 h-4 text-[10px]",sm:"w-5 h-5 text-xs",md:"w-6 h-6 text-sm",lg:"w-7 h-7 text-base"},ne={top:"bottom-full left-1/2 -translate-x-1/2 mb-2",bottom:"top-full left-1/2 -translate-x-1/2 mt-2",left:"right-full top-1/2 -translate-y-1/2 mr-2",right:"left-full top-1/2 -translate-y-1/2 ml-2"},le={sm:"w-56",md:"w-72",lg:"w-96",xl:"w-[32rem]"},ie=[A.default],de={h1:({...t})=>(0,e.jsx)("h1",{className:"text-xl font-bold mb-2 text-gray-900 dark:text-gray-100",...t}),h2:({...t})=>(0,e.jsx)("h2",{className:"text-lg font-semibold mt-4 mb-2 text-gray-900 dark:text-gray-100",...t}),h3:({...t})=>(0,e.jsx)("h3",{className:"text-base font-semibold mt-3 mb-1 text-gray-900 dark:text-gray-100",...t}),p:({...t})=>(0,e.jsx)("p",{className:"my-1 text-gray-700 dark:text-gray-300",...t}),ul:({...t})=>(0,e.jsx)("ul",{className:"list-disc list-inside space-y-1 my-2 text-gray-700 dark:text-gray-300",...t}),ol:({...t})=>(0,e.jsx)("ol",{className:"list-decimal list-inside space-y-1 my-2 text-gray-700 dark:text-gray-300",...t}),code:({className:t,children:o,...s})=>!t?.includes("language-")?(0,e.jsx)("code",{className:"bg-gray-100 dark:bg-gray-800 px-1.5 py-0.5 rounded text-sm font-mono text-gray-900 dark:text-gray-100",...s,children:o}):(0,e.jsx)("code",{className:"block bg-gray-100 dark:bg-gray-800 rounded-lg p-3 my-2 overflow-x-auto text-sm font-mono text-gray-900 dark:text-gray-100",...s,children:o}),pre:({...t})=>(0,e.jsx)("pre",{className:"my-2",...t}),a:({...t})=>(0,e.jsx)("a",{className:"text-synertech-primary-600 dark:text-synertech-primary-400 hover:underline",...t}),strong:({...t})=>(0,e.jsx)("strong",{className:"font-semibold text-gray-900 dark:text-gray-100",...t}),em:({...t})=>(0,e.jsx)("em",{className:"italic",...t}),blockquote:({...t})=>(0,e.jsx)("blockquote",{className:"border-l-4 border-gray-300 dark:border-gray-600 pl-4 my-2 italic text-gray-600 dark:text-gray-400",...t})};function $({content:t,markdown:o=!1,position:s="bottom",size:d="sm",className:l="",visible:C=!0,editable:f=!1,onSave:m,onReset:u,width:B="md",title:p,markdownEditor:h,markdownEditorUnavailableLabel:R,labels:M}){let r=(0,D.useUILabels)(M),[y,L]=(0,a.useState)(!1),[c,x]=(0,a.useState)(!1),[v,b]=(0,a.useState)(""),[I,k]=(0,a.useState)(!1),[S,n]=(0,a.useState)(null),T=(0,a.useRef)(null),O=(0,a.useRef)(null),P=(0,a.useRef)(null),i=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(!y)return;let g=w=>{T.current&&!T.current.contains(w.target)&&O.current&&!O.current.contains(w.target)&&(c||L(!1))},z=w=>{w.key==="Escape"&&(c?(x(!1),b("")):L(!1))};return document.addEventListener("mousedown",g),document.addEventListener("keydown",z),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",z)}},[y,c]),(0,a.useEffect)(()=>{c&&P.current&&P.current.focus()},[c]),(0,a.useEffect)(()=>()=>{i.current&&clearTimeout(i.current)},[]);let G=(0,a.useCallback)(()=>{b(typeof t=="string"?t:""),x(!0),n(null)},[t]),K=(0,a.useCallback)(()=>{x(!1),b(""),n(null)},[]),q=(0,a.useCallback)(async()=>{if(!m){n({type:"error",text:r.helpButtonNoSave});return}k(!0);try{await m(v)?(n({type:"success",text:r.helpButtonSaved}),x(!1),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>n(null),2e3)):n({type:"error",text:r.helpButtonSaveError})}catch{n({type:"error",text:r.helpButtonSaveError})}finally{k(!1)}},[v,m,r]),V=(0,a.useCallback)(async()=>{if(u&&confirm(r.helpButtonResetConfirm)){k(!0);try{await u()?(n({type:"success",text:r.helpButtonResetDone}),x(!1),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>n(null),2e3)):n({type:"error",text:r.helpButtonResetError})}catch{n({type:"error",text:r.helpButtonResetError})}finally{k(!1)}}},[u,r]),N=t;return C?(0,e.jsxs)("div",{className:"relative inline-flex items-center",children:[(0,e.jsx)("button",{type:"button",ref:T,onClick:()=>L(!y),className:`
2
- ${se[d]}
1
+ "use strict";"use client";var j=Object.create;var E=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var Q=Object.getPrototypeOf,X=Object.prototype.hasOwnProperty;var Y=(r,t)=>{for(var n in t)E(r,n,{get:t[n],enumerable:!0})},P=(r,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of J(t))!X.call(r,l)&&l!==n&&E(r,l,{get:()=>t[l],enumerable:!(i=F(t,l))||i.enumerable});return r};var W=(r,t,n)=>(n=r!=null?j(Q(r)):{},P(t||!r||!r.__esModule?E(n,"default",{value:r,enumerable:!0}):n,r)),Z=r=>P(E({},"__esModule",{value:!0}),r);var ge={};Y(ge,{HelpButton:()=>$,WithHelpButton:()=>ue});module.exports=Z(ge);var a=require("react"),z=W(require("react-markdown"),1),A=W(require("remark-gfm"),1),D=require("../../lib/i18n.cjs"),U=require("./sanitize-html.cjs"),e=require("react/jsx-runtime"),ee=(0,e.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,e.jsx)("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),(0,e.jsx)("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),te=(0,e.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,e.jsx)("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),(0,e.jsx)("polyline",{points:"17 21 17 13 7 13 7 21"}),(0,e.jsx)("polyline",{points:"7 3 7 8 15 8"})]}),re=(0,e.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,e.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,e.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),oe=(0,e.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,e.jsx)("polyline",{points:"1 4 1 10 7 10"}),(0,e.jsx)("path",{d:"M3.51 15a9 9 0 1 0 2.13-9.36L1 10"})]}),ae=(0,e.jsxs)("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,e.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10"}),(0,e.jsx)("path",{className:"opacity-75",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z",fill:"currentColor"})]}),ne={xs:"w-4 h-4 text-[10px]",sm:"w-5 h-5 text-xs",md:"w-6 h-6 text-sm",lg:"w-7 h-7 text-base"},se={top:"bottom-full left-1/2 -translate-x-1/2 mb-2",bottom:"top-full left-1/2 -translate-x-1/2 mt-2",left:"right-full top-1/2 -translate-y-1/2 mr-2",right:"left-full top-1/2 -translate-y-1/2 ml-2"},le={sm:"w-56",md:"w-72",lg:"w-96",xl:"w-[32rem]"},ie=[A.default],de=["img"],ce={h1:({node:r,...t})=>(0,e.jsx)("h1",{className:"text-xl font-bold mb-2 text-gray-900 dark:text-gray-100",...t}),h2:({node:r,...t})=>(0,e.jsx)("h2",{className:"text-lg font-semibold mt-4 mb-2 text-gray-900 dark:text-gray-100",...t}),h3:({node:r,...t})=>(0,e.jsx)("h3",{className:"text-base font-semibold mt-3 mb-1 text-gray-900 dark:text-gray-100",...t}),p:({node:r,...t})=>(0,e.jsx)("p",{className:"my-1 text-gray-700 dark:text-gray-300",...t}),ul:({node:r,...t})=>(0,e.jsx)("ul",{className:"list-disc list-inside space-y-1 my-2 text-gray-700 dark:text-gray-300",...t}),ol:({node:r,...t})=>(0,e.jsx)("ol",{className:"list-decimal list-inside space-y-1 my-2 text-gray-700 dark:text-gray-300",...t}),code:({node:r,className:t,children:n,...i})=>!t?.includes("language-")?(0,e.jsx)("code",{className:"bg-gray-100 dark:bg-gray-800 px-1.5 py-0.5 rounded text-sm font-mono text-gray-900 dark:text-gray-100",...i,children:n}):(0,e.jsx)("code",{className:"block bg-gray-100 dark:bg-gray-800 rounded-lg p-3 my-2 overflow-x-auto text-sm font-mono text-gray-900 dark:text-gray-100",...i,children:n}),pre:({node:r,...t})=>(0,e.jsx)("pre",{className:"my-2",...t}),a:({node:r,...t})=>(0,e.jsx)("a",{className:"text-synertech-primary-600 dark:text-synertech-primary-400 hover:underline",...t}),strong:({node:r,...t})=>(0,e.jsx)("strong",{className:"font-semibold text-gray-900 dark:text-gray-100",...t}),em:({node:r,...t})=>(0,e.jsx)("em",{className:"italic",...t}),blockquote:({node:r,...t})=>(0,e.jsx)("blockquote",{className:"border-l-4 border-gray-300 dark:border-gray-600 pl-4 my-2 italic text-gray-600 dark:text-gray-400",...t})};function $({content:r,markdown:t=!1,position:n="bottom",size:i="sm",className:l="",visible:C=!0,editable:f=!1,onSave:m,onReset:u,width:B="md",title:p,markdownEditor:h,markdownEditorUnavailableLabel:_,labels:R}){let o=(0,D.useUILabels)(R),[y,L]=(0,a.useState)(!1),[c,x]=(0,a.useState)(!1),[v,b]=(0,a.useState)(""),[M,k]=(0,a.useState)(!1),[S,s]=(0,a.useState)(null),I=(0,a.useRef)(null),T=(0,a.useRef)(null),H=(0,a.useRef)(null),d=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(!y)return;let g=w=>{I.current&&!I.current.contains(w.target)&&T.current&&!T.current.contains(w.target)&&(c||L(!1))},O=w=>{w.key==="Escape"&&(c?(x(!1),b("")):L(!1))};return document.addEventListener("mousedown",g),document.addEventListener("keydown",O),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",O)}},[y,c]),(0,a.useEffect)(()=>{c&&H.current&&H.current.focus()},[c]),(0,a.useEffect)(()=>()=>{d.current&&clearTimeout(d.current)},[]);let K=(0,a.useCallback)(()=>{b(typeof r=="string"?r:""),x(!0),s(null)},[r]),G=(0,a.useCallback)(()=>{x(!1),b(""),s(null)},[]),q=(0,a.useCallback)(async()=>{if(!m){s({type:"error",text:o.helpButtonNoSave});return}k(!0);try{await m(v)?(s({type:"success",text:o.helpButtonSaved}),x(!1),d.current&&clearTimeout(d.current),d.current=setTimeout(()=>s(null),2e3)):s({type:"error",text:o.helpButtonSaveError})}catch{s({type:"error",text:o.helpButtonSaveError})}finally{k(!1)}},[v,m,o]),V=(0,a.useCallback)(async()=>{if(u&&confirm(o.helpButtonResetConfirm)){k(!0);try{await u()?(s({type:"success",text:o.helpButtonResetDone}),x(!1),d.current&&clearTimeout(d.current),d.current=setTimeout(()=>s(null),2e3)):s({type:"error",text:o.helpButtonResetError})}catch{s({type:"error",text:o.helpButtonResetError})}finally{k(!1)}}},[u,o]),N=r;return C?(0,e.jsxs)("div",{className:"relative inline-flex items-center",children:[(0,e.jsx)("button",{type:"button",ref:I,onClick:()=>L(!y),className:`
2
+ ${ne[i]}
3
3
  inline-flex items-center justify-center
4
4
  rounded-full border border-gray-300 dark:border-gray-600
5
5
  bg-white dark:bg-gray-800
@@ -11,12 +11,12 @@
11
11
  transition-all duration-150
12
12
  focus:outline-none focus:ring-2 focus:ring-synertech-primary-500/50
13
13
  ${l}
14
- `,"aria-label":r.helpButtonShow,"aria-expanded":y,children:(0,e.jsx)("span",{className:"font-medium",children:"?"})}),y&&(0,e.jsxs)("div",{ref:O,className:`
15
- absolute z-50 ${ne[s]}
14
+ `,"aria-label":o.helpButtonShow,"aria-expanded":y,children:(0,e.jsx)("span",{className:"font-medium",children:"?"})}),y&&(0,e.jsxs)("div",{ref:T,className:`
15
+ absolute z-50 ${se[n]}
16
16
  ${le[B]} max-h-[80vh] overflow-hidden flex flex-col
17
17
  bg-white dark:bg-gray-900
18
18
  border border-gray-200 dark:border-gray-700
19
19
  rounded-xl shadow-xl
20
20
  text-sm text-gray-700 dark:text-gray-300
21
21
  animate-in fade-in-0 zoom-in-95 duration-150
22
- `,role:"tooltip",children:[(p||f)&&(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",children:[(0,e.jsx)("div",{className:"flex items-center gap-2",children:p&&(0,e.jsx)("h3",{className:"text-sm font-semibold",children:p})}),f&&(0,e.jsx)("div",{className:"flex items-center gap-1",children:c?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",onClick:q,disabled:I,className:"p-1.5 rounded-md hover:bg-green-100 dark:hover:bg-green-900/30 text-green-700 dark:text-green-400 transition-colors disabled:opacity-50 cursor-pointer",title:r.helpButtonSave,children:I?oe:te}),(0,e.jsx)("button",{type:"button",onClick:K,className:"p-1.5 rounded-md hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 transition-colors cursor-pointer",title:r.helpButtonCancel,children:re}),u&&(0,e.jsx)("button",{type:"button",onClick:V,disabled:I,className:"p-1.5 rounded-md hover:bg-orange-100 dark:hover:bg-orange-900/30 text-orange-700 dark:text-orange-400 transition-colors disabled:opacity-50 cursor-pointer",title:r.helpButtonReset,children:ae})]}):(0,e.jsx)("button",{type:"button",onClick:G,className:"p-1.5 rounded-md hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 transition-colors cursor-pointer",title:r.helpButtonEdit,children:ee})})]}),S&&(0,e.jsx)("div",{className:`px-4 py-2 text-xs ${S.type==="success"?"bg-green-50 dark:bg-green-900/20 text-green-700 dark:text-green-400":"bg-red-50 dark:bg-red-900/20 text-red-700 dark:text-red-400"}`,children:S.text}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:c?o?h?(0,e.jsx)(h,{value:v,onChange:b,placeholder:r.markdownEditorPlaceholder}):(0,e.jsx)("p",{role:"alert",className:"p-3 text-sm text-gray-500 dark:text-gray-400",children:R??r.markdownEditorUnavailable}):(0,e.jsx)("div",{className:"space-y-2",children:(0,e.jsx)("textarea",{ref:P,"aria-label":r.helpButtonContent,value:v,onChange:g=>b(g.target.value),className:"w-full h-64 p-3 text-sm bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg resize-none focus:outline-none focus:ring-2 focus:ring-synertech-primary-500/50 text-gray-700 dark:text-gray-300 font-mono",placeholder:r.helpButtonContentPlaceholder})}):typeof N=="string"?(0,e.jsx)("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:o?(0,e.jsx)(U.default,{remarkPlugins:ie,components:de,children:N}):(0,e.jsx)("div",{dangerouslySetInnerHTML:{__html:_.default.sanitize(N)}})}):N})]})]}):null}function ce({children:t,content:o,markdown:s=!1,position:d="bottom",size:l="sm",visible:C=!0,editable:f=!1,onSave:m,onReset:u,width:B="md",title:p,className:h,markdownEditor:R,markdownEditorUnavailableLabel:M,labels:r}){return(0,e.jsxs)("div",{className:"inline-flex items-center gap-2.5",children:[t,(0,e.jsx)($,{content:o,markdown:s,position:d,size:l,visible:C,editable:f,onSave:m,onReset:u,width:B,title:p,className:h,markdownEditor:R,markdownEditorUnavailableLabel:M,labels:r})]})}0&&(module.exports={HelpButton,WithHelpButton});
22
+ `,role:"tooltip",children:[(p||f)&&(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",children:[(0,e.jsx)("div",{className:"flex items-center gap-2",children:p&&(0,e.jsx)("h3",{className:"text-sm font-semibold",children:p})}),f&&(0,e.jsx)("div",{className:"flex items-center gap-1",children:c?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",onClick:q,disabled:M,className:"p-1.5 rounded-md hover:bg-green-100 dark:hover:bg-green-900/30 text-green-700 dark:text-green-400 transition-colors disabled:opacity-50 cursor-pointer",title:o.helpButtonSave,children:M?ae:te}),(0,e.jsx)("button",{type:"button",onClick:G,className:"p-1.5 rounded-md hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 transition-colors cursor-pointer",title:o.helpButtonCancel,children:re}),u&&(0,e.jsx)("button",{type:"button",onClick:V,disabled:M,className:"p-1.5 rounded-md hover:bg-orange-100 dark:hover:bg-orange-900/30 text-orange-700 dark:text-orange-400 transition-colors disabled:opacity-50 cursor-pointer",title:o.helpButtonReset,children:oe})]}):(0,e.jsx)("button",{type:"button",onClick:K,className:"p-1.5 rounded-md hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 transition-colors cursor-pointer",title:o.helpButtonEdit,children:ee})})]}),S&&(0,e.jsx)("div",{className:`px-4 py-2 text-xs ${S.type==="success"?"bg-green-50 dark:bg-green-900/20 text-green-700 dark:text-green-400":"bg-red-50 dark:bg-red-900/20 text-red-700 dark:text-red-400"}`,children:S.text}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:c?t?h?(0,e.jsx)(h,{value:v,onChange:b,placeholder:o.markdownEditorPlaceholder}):(0,e.jsx)("p",{role:"alert",className:"p-3 text-sm text-gray-500 dark:text-gray-400",children:_??o.markdownEditorUnavailable}):(0,e.jsx)("div",{className:"space-y-2",children:(0,e.jsx)("textarea",{ref:H,"aria-label":o.helpButtonContent,value:v,onChange:g=>b(g.target.value),className:"w-full h-64 p-3 text-sm bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg resize-none focus:outline-none focus:ring-2 focus:ring-synertech-primary-500/50 text-gray-700 dark:text-gray-300 font-mono",placeholder:o.helpButtonContentPlaceholder})}):typeof N=="string"?(0,e.jsx)("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:t?(0,e.jsx)(z.default,{remarkPlugins:ie,components:ce,disallowedElements:de,children:N}):(0,e.jsx)("div",{dangerouslySetInnerHTML:{__html:(0,U.sanitizeHelpHtml)(N)}})}):N})]})]}):null}function ue({children:r,content:t,markdown:n=!1,position:i="bottom",size:l="sm",visible:C=!0,editable:f=!1,onSave:m,onReset:u,width:B="md",title:p,className:h,markdownEditor:_,markdownEditorUnavailableLabel:R,labels:o}){return(0,e.jsxs)("div",{className:"inline-flex items-center gap-2.5",children:[r,(0,e.jsx)($,{content:t,markdown:n,position:i,size:l,visible:C,editable:f,onSave:m,onReset:u,width:B,title:p,className:h,markdownEditor:_,markdownEditorUnavailableLabel:R,labels:o})]})}0&&(module.exports={HelpButton,WithHelpButton});