@synertech/ui 0.45.1 → 0.46.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/.claude/skills/use-synertech-ui/SKILL.md +115 -17
  2. package/README.md +47 -5
  3. package/dist/components/area-chart/AreaChart.cjs +1 -1
  4. package/dist/components/area-chart/AreaChart.js +1 -1
  5. package/dist/components/avatar/Avatar.cjs +1 -1
  6. package/dist/components/avatar/Avatar.js +1 -1
  7. package/dist/components/badge/Badge.cjs +1 -1
  8. package/dist/components/badge/Badge.js +1 -1
  9. package/dist/components/banner/Banner.cjs +1 -1
  10. package/dist/components/banner/Banner.js +1 -1
  11. package/dist/components/bar-chart/BarChart.cjs +1 -1
  12. package/dist/components/bar-chart/BarChart.js +1 -1
  13. package/dist/components/box-plot/BoxPlot.cjs +1 -1
  14. package/dist/components/box-plot/BoxPlot.js +1 -1
  15. package/dist/components/breadcrumb/Breadcrumb.cjs +1 -1
  16. package/dist/components/breadcrumb/Breadcrumb.js +1 -1
  17. package/dist/components/bullet-chart/BulletChart.cjs +1 -1
  18. package/dist/components/bullet-chart/BulletChart.js +1 -1
  19. package/dist/components/calendar/Calendar.cjs +1 -1
  20. package/dist/components/calendar/Calendar.js +1 -1
  21. package/dist/components/candlestick-chart/CandlestickChart.cjs +1 -1
  22. package/dist/components/candlestick-chart/CandlestickChart.js +1 -1
  23. package/dist/components/chart/ChartBrush.cjs +1 -1
  24. package/dist/components/chart/ChartBrush.js +1 -1
  25. package/dist/components/chart/ChartExportButton.cjs +1 -1
  26. package/dist/components/chart/ChartExportButton.js +1 -1
  27. package/dist/components/chart/utils/export.cjs +1 -2
  28. package/dist/components/chart/utils/export.js +1 -2
  29. package/dist/components/chart/utils/keyboard.cjs +1 -0
  30. package/dist/components/chart/utils/keyboard.js +1 -0
  31. package/dist/components/chip/Chip.cjs +1 -1
  32. package/dist/components/chip/Chip.js +1 -1
  33. package/dist/components/datagrid/DataGrid.cjs +1 -2
  34. package/dist/components/datagrid/DataGrid.js +1 -2
  35. package/dist/components/device-mockup/DeviceMockup.cjs +1 -1
  36. package/dist/components/device-mockup/DeviceMockup.js +1 -1
  37. package/dist/components/dropdown/Dropdown.cjs +1 -1
  38. package/dist/components/dropdown/Dropdown.js +1 -1
  39. package/dist/components/dropdown/DropdownCheckboxItem.cjs +1 -1
  40. package/dist/components/dropdown/DropdownCheckboxItem.js +1 -1
  41. package/dist/components/dropdown/DropdownContent.cjs +1 -1
  42. package/dist/components/dropdown/DropdownContent.js +1 -1
  43. package/dist/components/dropdown/DropdownItem.cjs +1 -1
  44. package/dist/components/dropdown/DropdownItem.js +1 -1
  45. package/dist/components/dropdown/DropdownRadio.cjs +1 -1
  46. package/dist/components/dropdown/DropdownRadio.js +1 -1
  47. package/dist/components/dropdown/DropdownSubMenu.cjs +1 -1
  48. package/dist/components/dropdown/DropdownSubMenu.js +1 -1
  49. package/dist/components/dropdown/hooks/index.cjs +1 -1
  50. package/dist/components/dropdown/hooks/index.js +1 -1
  51. package/dist/components/dropdown/hooks/useClickOutside.cjs +1 -1
  52. package/dist/components/dropdown/hooks/useClickOutside.js +1 -1
  53. package/dist/components/dropdown/index.cjs +1 -1
  54. package/dist/components/dropdown/index.js +1 -1
  55. package/dist/components/dropdown/menu-navigation.cjs +1 -0
  56. package/dist/components/dropdown/menu-navigation.js +1 -0
  57. package/dist/components/dumbbell-chart/DumbbellChart.cjs +1 -1
  58. package/dist/components/dumbbell-chart/DumbbellChart.js +1 -1
  59. package/dist/components/file-selector/FileSelector.cjs +1 -1
  60. package/dist/components/file-selector/FileSelector.js +1 -1
  61. package/dist/components/form/input/Input.cjs +1 -1
  62. package/dist/components/form/input/Input.js +1 -1
  63. package/dist/components/form/mention-input/MentionInput.cjs +1 -1
  64. package/dist/components/form/mention-input/MentionInput.js +1 -1
  65. package/dist/components/form/number-input/NumberInput.cjs +1 -1
  66. package/dist/components/form/number-input/NumberInput.js +1 -1
  67. package/dist/components/funnel-chart/FunnelChart.cjs +1 -1
  68. package/dist/components/funnel-chart/FunnelChart.js +1 -1
  69. package/dist/components/gantt-chart/GanttChart.cjs +1 -1
  70. package/dist/components/gantt-chart/GanttChart.js +1 -1
  71. package/dist/components/header/Header.cjs +1 -1
  72. package/dist/components/header/Header.js +1 -1
  73. package/dist/components/heat-map/Heatmap.cjs +1 -1
  74. package/dist/components/heat-map/Heatmap.js +1 -1
  75. package/dist/components/help-button/HelpButton.cjs +7 -7
  76. package/dist/components/help-button/HelpButton.js +7 -7
  77. package/dist/components/help-button/MarkdownEditor.cjs +1 -1
  78. package/dist/components/help-button/MarkdownEditor.js +1 -1
  79. package/dist/components/image-uploader/ImageUploader.cjs +1 -1
  80. package/dist/components/image-uploader/ImageUploader.js +1 -1
  81. package/dist/components/indicator/Indicator.cjs +1 -1
  82. package/dist/components/indicator/Indicator.js +1 -1
  83. package/dist/components/label/Label.cjs +1 -1
  84. package/dist/components/label/Label.js +1 -1
  85. package/dist/components/line-chart/LineChart.cjs +1 -1
  86. package/dist/components/line-chart/LineChart.js +1 -1
  87. package/dist/components/modal/Modal.cjs +1 -1
  88. package/dist/components/modal/Modal.js +1 -1
  89. package/dist/components/pagination/Pagination.cjs +1 -1
  90. package/dist/components/pagination/Pagination.js +1 -1
  91. package/dist/components/pie-chart/PieChart.cjs +1 -1
  92. package/dist/components/pie-chart/PieChart.js +1 -1
  93. package/dist/components/radio-button/RadioButton.cjs +1 -1
  94. package/dist/components/radio-button/RadioButton.js +1 -1
  95. package/dist/components/scatter-chart/ScatterChart.cjs +1 -1
  96. package/dist/components/scatter-chart/ScatterChart.js +1 -1
  97. package/dist/components/schema-editor/SchemaEditor.cjs +1 -1
  98. package/dist/components/schema-editor/SchemaEditor.js +1 -1
  99. package/dist/components/schema-editor/legend/SchemaLegend.cjs +1 -1
  100. package/dist/components/schema-editor/legend/SchemaLegend.js +1 -1
  101. package/dist/components/schema-editor/tables/SchemaTableRenderer.cjs +1 -1
  102. package/dist/components/schema-editor/tables/SchemaTableRenderer.js +1 -1
  103. package/dist/components/schema-editor/toolbar/SchemaToolbar.cjs +1 -1
  104. package/dist/components/schema-editor/toolbar/SchemaToolbar.js +1 -1
  105. package/dist/components/select/Select.cjs +1 -1
  106. package/dist/components/select/Select.js +1 -1
  107. package/dist/components/tabs/Tabs.cjs +1 -1
  108. package/dist/components/tabs/Tabs.js +1 -1
  109. package/dist/components/tabs/TabsContent.cjs +1 -1
  110. package/dist/components/tabs/TabsContent.js +1 -1
  111. package/dist/components/tabs/TabsContext.cjs +1 -1
  112. package/dist/components/tabs/TabsContext.js +1 -1
  113. package/dist/components/tabs/TabsList.cjs +1 -1
  114. package/dist/components/tabs/TabsList.js +1 -1
  115. package/dist/components/tabs/TabsTrigger.cjs +1 -1
  116. package/dist/components/tabs/TabsTrigger.js +1 -1
  117. package/dist/components/toast/Toast.cjs +1 -1
  118. package/dist/components/toast/Toast.js +1 -1
  119. package/dist/components/tooltip/Tooltip.cjs +1 -1
  120. package/dist/components/tooltip/Tooltip.js +1 -1
  121. package/dist/components/waterfall-chart/WaterfallChart.cjs +1 -1
  122. package/dist/components/waterfall-chart/WaterfallChart.js +1 -1
  123. package/dist/components/wizard/Wizard.cjs +1 -1
  124. package/dist/components/wizard/Wizard.js +1 -1
  125. package/dist/components/workflow-editor/WorkflowEditor.cjs +1 -1
  126. package/dist/components/workflow-editor/WorkflowEditor.js +1 -1
  127. package/dist/components/workflow-editor/toolbar/WorkflowToolbar.cjs +1 -1
  128. package/dist/components/workflow-editor/toolbar/WorkflowToolbar.js +1 -1
  129. package/dist/index.cjs +1 -1
  130. package/dist/index.d.cts +814 -172
  131. package/dist/index.d.ts +814 -172
  132. package/dist/index.js +1 -1
  133. package/dist/lib/aria-hide.cjs +1 -1
  134. package/dist/lib/aria-hide.js +1 -1
  135. package/dist/lib/csv.cjs +2 -0
  136. package/dist/lib/csv.js +2 -0
  137. package/dist/lib/i18n.cjs +1 -1
  138. package/dist/lib/i18n.js +1 -1
  139. package/dist/lib/server-labels.cjs +1 -0
  140. package/dist/lib/server-labels.js +1 -0
  141. package/dist/lib/ui-labels.cjs +1 -0
  142. package/dist/lib/ui-labels.js +1 -0
  143. package/dist/styles.css +3152 -309
  144. package/package.json +3 -3
@@ -1 +1 @@
1
- "use client";import{memo as Z,useCallback as Y,useMemo as M,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 X,formatXValue as ue}from"../chart/utils/format.js";import{buildBarPath as me}from"../chart/utils/path.js";import{createBandScale as ce,createLinearScale as de,nearestIndex as fe}from"../chart/utils/scales.js";import{estimateTextWidth as he,widestLabel as pe}from"../chart/utils/text.js";import{CHART_TOUCH as be}from"../chart/utils/touch.js";import{Table as ge}from"../table/Table.js";import{TableBody as ve}from"../table/TableBody.js";import{TableCell as z}from"../table/TableCell.js";import{TableHeader as ye}from"../table/TableHeader.js";import{TableHeaderCell as B}from"../table/TableHeaderCell.js";import{TableRow as xe}from"../table/TableRow.js";import{Fragment as Re,jsx as t,jsxs as f}from"react/jsx-runtime";var Ce=8,ke=12,Se=44,J="text-right [font-variant-numeric:tabular-nums]",Te=Z(function({stages:s}){return t("g",{children:s.map(e=>f("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 Ne({width:h,height:s,stages:e,x:C,size:O,align:V,showConversion:D,showValues:w,stageSize:_,ramp:P,tooltip:g,plotLabel:W,locale:k,onStageClick:S}){let[A,L]=ee(null),l=A!==null&&A<e.length?A:null,G=Q(),n=M(()=>{let o=e.map(r=>r.label),u={top:6,right:12,bottom:6,left:C.hidden?8:C.height??pe(o)+ke},m=Math.max(0,h-u.left-u.right),y=Math.max(0,s-u.top-u.bottom),c=ce(e.map((r,i)=>i),[0,y],{paddingInner:D?.45:.28}),T=Math.min(_??Se,c.bandwidth),$=Math.max(0,...e.map(r=>r.value??0)),F=de([0,$],[0,m]),E=e.map((r,i)=>{let x=r.value===null?0:Math.max(0,F(r.value)),a=V==="center"?(m-x)/2:0,N=c(i)+(c.bandwidth-T)/2,b=N+T/2,H=null;if(w&&r.value!==null){let q=r.formattedValue;H=he(q,11)+16<=x?{x:a+x/2,y:b,anchor:"middle",text:q,inside:!0,onDark:P.onDark(i)}:{x:a+x+Ce,y:b,anchor:"start",text:q,inside:!1,onDark:!1}}let d=c(i-1)+(c.bandwidth-T)/2+T,R=D&&r.conversion!==null&&i>0?{x:m/2,y:(d+N)/2,text:X(r.conversion,{locale:k,maximumFractionDigits:0})}:null;return{key:`${i}`,d:me({x:a,y:N,width:x,height:T,radius:4,round:V==="center"?"none":"right"}),color:P(i),value:H,conversion:R,top:c(i),height:c.bandwidth}}),I=C.hidden?[]:e.map((r,i)=>({value:r.x,offset:c.center(i),label:r.label}));return{margin:u,innerWidth:m,innerHeight:y,rendered:E,stageTicks:I,centers:e.map((r,i)=>c.center(i))}},[e,C,h,s,V,D,w,_,P,k]),K=Y(o=>{if(g===!1||e.length===0)return;let u=o.currentTarget.getBoundingClientRect(),m=o.clientY-u.top-n.margin.top;L(fe(n.centers,m))},[g,e.length,n.margin.top,n.centers]),U=Y(o=>{if(e.length===0)return;let u=e.length-1,m=l??0,y=o.key==="ArrowDown"?Math.min(u,m+1):o.key==="ArrowUp"?Math.max(0,m-1):o.key==="Home"?0:o.key==="End"?u:o.key==="Escape"?null:void 0;y!==void 0&&(o.preventDefault(),L(y))},[e.length,l]),v=Y(()=>{!S||l===null||S(e[l])},[S,l,e]),p=l===null?null:e[l];return f(Re,{children:[f("svg",{width:h,height:s,role:"img","aria-label":W??e.map(o=>o.label).join(", "),tabIndex:0,className:`${be} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500`,onPointerMove:K,onPointerLeave:()=>L(null),onKeyDown:U,onBlur:()=>L(null),onClick:v,children:[f("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(Te,{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:O})})]}),p&&l!==null&&g!==!1?t(re,{x:n.margin.left+n.innerWidth/2,y:n.margin.top+n.centers[l],containerWidth:h,children:typeof g=="function"?g(p):f("div",{className:"flex flex-col gap-1",children:[t("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:p.label}),f("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:p.formattedValue})]}),p.conversion!==null?f("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:X(p.conversion,{locale:k,maximumFractionDigits:1})})]}):null,p.overall!==null?f("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:X(p.overall,{locale:k,maximumFractionDigits:1})})]}):null]})}):null]})}function $e({data:h,x:s,value:e,align:C="center",showConversion:O=!0,showValues:V=!0,stageSize:D,colors:w,height:_,width:P,size:g="md",tooltip:W=!0,tableView:k=!1,title:S,description:A,loading:L=!1,emptyState:l,error:G=!1,errorState:n,onRetry:K,actions:U,locale:v,plotLabel:p,valueLabel:o,conversionLabel:u,dropOffLabel:m,format:y,onStageClick:c,className:T,...$}){let F=Q(),E=M(()=>y??(a=>se(a,v)),[y,v]),I=M(()=>s.format??(a=>ue(a,v)),[s.format,v]),r=M(()=>{let a=j(h[0]??{},e);return h.map((N,b)=>{let H=ie(N,s.key,b),d=j(N,e),R=b===0?null:j(h[b-1],e);return{index:b,x:H,label:I(H,b),value:d,overall:b===0||a===null||a===0||d===null?null:d/a,conversion:R===null||R===0||d===null?null:d/R,dropOff:R===null||d===null?null:R-d,formattedValue:d===null?"\u2014":E(d),datum:N}})},[h,s.key,e,E,I]),i=M(()=>oe([0,Math.max(1,r.length-1)],{colors:w??ae,...w?{}:{darkStops:le}}),[r.length,w]),x=_??Math.max(96,r.length*(O?56:44)+12);return t(ne,{title:S,description:A,height:x,width:P,size:g,loading:L,empty:r.length===0,emptyState:l,error:G,errorState:n,onRetry:K,actions:U,tableView:k,table:k?t("div",{className:"w-full overflow-x-auto",children:f(ge,{children:[typeof S=="string"?t("caption",{className:"sr-only",children:S}):null,f(ye,{children:[t(B,{children:s.label??s.key}),t(B,{className:"text-right",children:o??F.chartValue}),t(B,{className:"text-right",children:u??F.chartConversion}),t(B,{className:"text-right",children:m??F.chartDropOff})]}),t(ve,{children:r.map(a=>f(xe,{clickable:!1,children:[t(z,{className:"font-medium text-gray-900 dark:text-gray-100",children:a.label}),t(z,{className:J,children:a.formattedValue}),t(z,{className:J,children:a.conversion===null?"\u2014":X(a.conversion,{locale:v,maximumFractionDigits:1})}),t(z,{className:J,children:a.dropOff===null?"\u2014":E(a.dropOff)})]},a.index))})]})}):void 0,className:T,...$,children:({width:a})=>t(Ne,{width:a,height:x,stages:r,x:s,size:g,align:C,showConversion:O,showValues:V,stageSize:D,ramp:i,tooltip:W,plotLabel:p,locale:v,onStageClick:c})})}export{$e as FunnelChart};
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-blue-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 +1 @@
1
- "use strict";"use client";var gt=Object.defineProperty;var Et=Object.getOwnPropertyDescriptor;var It=Object.getOwnPropertyNames;var Ht=Object.prototype.hasOwnProperty;var Wt=(c,o)=>{for(var C in o)gt(c,C,{get:o[C],enumerable:!0})},Xt=(c,o,C,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let h of It(o))!Ht.call(c,h)&&h!==C&&gt(c,h,{get:()=>o[h],enumerable:!(r=Et(o,h))||r.enumerable});return c};var Vt=c=>Xt(gt({},"__esModule",{value:!0}),c);var Yt={};Wt(Yt,{GanttChart:()=>Ut});module.exports=Vt(Yt);var i=require("react"),ft=require("../../lib/i18n.cjs"),ht=require("../chart/ChartAxis.cjs"),vt=require("../chart/ChartContainer.cjs"),wt=require("../chart/ChartGrid.cjs"),Nt=require("../chart/ChartLegend.cjs"),St=require("../chart/ChartTooltip.cjs"),et=require("../chart/palette.cjs"),$t=require("../chart/utils/cartesian.cjs"),rt=require("../chart/utils/data.cjs"),F=require("../chart/utils/format.cjs"),pt=require("../chart/utils/path.cjs"),Lt=require("../chart/utils/scales.cjs"),x=require("../chart/utils/time.cjs"),Pt=require("../chart/utils/touch.cjs"),Rt=require("../table/Table.cjs"),Mt=require("../table/TableBody.cjs"),U=require("../table/TableCell.cjs"),Gt=require("../table/TableHeader.cjs"),Y=require("../table/TableHeaderCell.cjs"),Dt=require("../table/TableRow.cjs"),t=require("react/jsx-runtime"),zt=18,Tt=.5,_t=.3,tt=7,kt=10,xt=.02,dt="text-right [font-variant-numeric:tabular-nums]",Bt=(0,i.memo)(function({tasks:o,arrows:C}){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:C.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 Kt({width:c,height:o,data:C,tasks:r,x:h,domain:w,unit:R,timeTicks:O,today:S,grid:E,size:I,barSize:X,colorOf:Z,margin:j,tooltip:$,plotLabel:nt,todayLabel:at,locale:L,formatDate:q,formatX:M,onTaskClick:V}){let[H,P]=(0,i.useState)(null),y=H!==null&&H<r.length?H:null,z=(0,ft.useUILabels)(),n=(0,i.useMemo)(()=>{let l=(0,$t.buildCartesianGeometry)({width:c,height:o,data:C,x:h,y:{domain:w},bounds:w,margin:j,orientation:"horizontal",placement:"band",formatValue:a=>(0,x.formatTimeTick)(a,R,L),formatX:M}),{valueScale:s,bandwidth:g,categoryPositions:T,innerWidth:st,innerHeight:ct}=l,G=Math.min(X??zt,g),J=new Map(r.map((a,m)=>[a.id,m])),mt=r.map((a,m)=>{let f=T[m]+(g-G)/2,u=f+G/2,N=Z(a);if(a.start===null)return{key:`${m}`,color:N,track:null,trackOpacity:1,progress:null,milestone:null,top:T[m],height:g};let d=s(a.start);if(a.milestone)return{key:`${m}`,color:N,track:null,trackOpacity:1,progress:null,milestone:`M${d},${u-tt} L${d+tt},${u} L${d},${u+tt} L${d-tt},${u} Z`,top:T[m],height:g};let D=s(a.end??a.start),k=Math.max(2,D-d);return{key:`${m}`,color:N,track:(0,pt.buildBarPath)({x:d,y:f,width:k,height:G,radius:3}),trackOpacity:a.progress===null?1:_t,progress:a.progress===null?null:(0,pt.buildBarPath)({x:d,y:u-G*Tt/2,width:Math.max(0,k*Math.min(1,Math.max(0,a.progress))),height:G*Tt,radius:2,round:"right"}),milestone:null,top:T[m],height:g}}),Q=[];r.forEach((a,m)=>{if(a.start!==null)for(let f of a.dependsOn){let u=J.get(f);if(u===void 0||u===m)continue;let N=r[u];if(N.start===null)continue;let d=s(N.end??N.start),D=T[u]+g/2,k=s(a.start),A=T[m]+g/2,_=Math.max(d+kt,k-kt);Q.push({key:`${f}-${a.id}`,d:`M${d},${D} L${_},${D} L${_},${A} L${k-5},${A}`,head:`M${k},${A} L${k-5},${A-3.5} L${k-5},${A+3.5} Z`})}});let ut=O.map(a=>({value:a,offset:s(a),label:(0,x.formatTimeTick)(a,R,L)}));return{rendered:mt,arrows:Q,categoryPositions:T,categoryCenters:l.categoryCenters,bandwidth:g,categoryTicks:l.categoryTicks,valueTicks:ut,valueScale:s,innerWidth:st,innerHeight:ct,margin:l.margin}},[r,C,h,w,R,O,c,o,j,X,Z,L,M]),ot=(0,i.useCallback)(l=>{if($===!1||r.length===0)return;let s=l.currentTarget.getBoundingClientRect(),g=l.clientY-s.top-n.margin.top;P((0,Lt.nearestIndex)(n.categoryCenters,g))},[$,r.length,n.margin.top,n.categoryCenters]),lt=(0,i.useCallback)(l=>{if(r.length===0)return;let s=r.length-1,g=y??0,T=l.key==="ArrowDown"?Math.min(s,g+1):l.key==="ArrowUp"?Math.max(0,g-1):l.key==="Home"?0:l.key==="End"?s:l.key==="Escape"?null:void 0;T!==void 0&&(l.preventDefault(),P(T))},[r.length,y]),it=(0,i.useCallback)(()=>{!V||y===null||V(r[y])},[V,y,r]),p=y===null?null:r[y];return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("svg",{width:c,height:o,role:"img","aria-label":nt??r.map(l=>l.label).join(", "),tabIndex:0,className:`${Pt.CHART_TOUCH} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500`,onPointerMove:ot,onPointerLeave:()=>P(null),onKeyDown:lt,onBlur:()=>P(null),onClick:it,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(l=>l.offset):void 0}),y!==null?(0,t.jsx)("rect",{x:0,y:n.categoryPositions[y],width:n.innerWidth,height:n.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,(0,t.jsx)(Bt,{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:at})]}):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:I})}),(0,t.jsx)("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:h.hidden?null:(0,t.jsx)(ht.ChartAxis,{orientation:"left",ticks:n.categoryTicks,length:n.innerHeight,showLine:!1,tickSize:0,label:h.label,size:I})})]}),p&&y!==null&&$!==!1?(0,t.jsx)(St.ChartTooltip,{x:n.margin.left+(p.start===null?n.innerWidth/2:n.valueScale(p.start)),y:n.margin.top+n.categoryCenters[y],containerWidth:c,children:typeof $=="function"?$(p):(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:p.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:p.start===null?"\u2014":q(p.start)})]}),p.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:p.end===null?"\u2014":q(p.end)})]}),p.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,F.formatPercent)(p.progress,{locale:L,maximumFractionDigits:0})})]})]})}):null]})}function Ut({data:c,x:o,start:C,end:r,id:h,progress:w,milestone:R,dependencies:O,group:S,domain:E,today:I,ticks:X=6,barSize:Z,rowSize:j=30,color:$,height:nt,width:at,size:L="md",grid:q=!0,legend:M,tooltip:V=!0,tableView:H=!1,title:P,description:y,loading:z=!1,emptyState:n,error:ot=!1,errorState:lt,onRetry:it,actions:p,margin:l,locale:s,plotLabel:g,startLabel:T,endLabel:st,progressLabel:ct,todayLabel:G,formatDate:J,onTaskClick:mt,className:Q,...ut}){let a=(0,ft.useUILabels)(),m=(0,i.useMemo)(()=>o.format??(e=>(0,F.formatXValue)(e,s)),[o.format,s]),f=(0,i.useMemo)(()=>c.map((e,b)=>{let B=(0,rt.readXValue)(e,o.key,b),W=(0,x.toTimestamp)(e[C]),v=r?(0,x.toTimestamp)(e[r]):null,K=R?!!e[R]:v===null,Ct=O?e[O]:void 0;return{index:b,id:String(h?e[h]??b:b),x:B,label:m(B,b),start:W,end:K?W:v??W,progress:w?(0,rt.readNumber)(e,w):null,milestone:K,dependsOn:Array.isArray(Ct)?Ct.map(Ot=>String(Ot)):[],group:S?e[S]??null:null,datum:e}}),[c,o.key,C,r,h,w,R,O,S,m]),u=(0,i.useMemo)(()=>{let e=[];for(let b of f)b.group!==null&&!e.includes(b.group)&&e.push(b.group);return e},[f]),N=(0,i.useCallback)(e=>e.group===null?$??(0,et.getSeriesColor)(0):(0,et.getSeriesColor)(u.indexOf(e.group)),[u,$]),d=(0,i.useMemo)(()=>{if(E){let v=(0,x.toTimestamp)(E[0]),K=(0,x.toTimestamp)(E[1]);if(v!==null&&K!==null)return[v,K]}let e=f.flatMap(v=>v.start===null?[]:[v.start,v.end??v.start]);if(e.length===0)return[0,1];let b=Math.min(...e),B=Math.max(...e),W=B-b||864e5;return[b-W*xt,B+W*xt]},[E,f]),D=(0,i.useMemo)(()=>(0,x.niceTimeTicks)(d[0],d[1],X),[d,X]),k=(0,i.useMemo)(()=>J??(e=>new Intl.DateTimeFormat(s,{day:"numeric",month:"short",year:"numeric"}).format(new Date(e))),[J,s]),A=(0,i.useMemo)(()=>I===!1?null:(0,x.toTimestamp)(I??Date.now()),[I]),_=(0,i.useMemo)(()=>u.map((e,b)=>({key:e,label:e,color:(0,et.getSeriesColor)(b),marker:"rect"})),[u]),bt=nt??Math.max(120,f.length*j+48),At=M===void 0?u.length>=2:M!==!1,yt=typeof M=="string"?M:"bottom";return(0,t.jsx)(vt.ChartContainer,{title:P,description:y,height:bt,width:at,size:L,loading:z,empty:f.length===0,emptyState:n,error:ot,errorState:lt,onRetry:it,actions:p,tableView:H,legendPosition:yt,legend:At&&_.length>0?(0,t.jsx)(Nt.ChartLegend,{items:_,position:yt,marker:"rect",size:L}):void 0,table:H?(0,t.jsx)("div",{className:"w-full overflow-x-auto",children:(0,t.jsxs)(Rt.Table,{children:[typeof P=="string"?(0,t.jsx)("caption",{className:"sr-only",children:P}):null,(0,t.jsxs)(Gt.TableHeader,{children:[(0,t.jsx)(Y.TableHeaderCell,{children:o.label??o.key}),(0,t.jsx)(Y.TableHeaderCell,{className:"text-right",children:T??a.chartStart}),(0,t.jsx)(Y.TableHeaderCell,{className:"text-right",children:st??a.chartEnd}),w?(0,t.jsx)(Y.TableHeaderCell,{className:"text-right",children:ct??a.chartProgress}):null]}),(0,t.jsx)(Mt.TableBody,{children:f.map(e=>(0,t.jsxs)(Dt.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:dt,children:e.start===null?"\u2014":k(e.start)}),(0,t.jsx)(U.TableCell,{className:dt,children:e.milestone||e.end===null?"\u2014":k(e.end)}),w?(0,t.jsx)(U.TableCell,{className:dt,children:e.progress===null?"\u2014":(0,F.formatPercent)(e.progress,{locale:s,maximumFractionDigits:0})}):null]},e.index))})]})}):void 0,className:Q,...ut,children:({width:e})=>(0,t.jsx)(Kt,{width:e,height:bt,data:c,tasks:f,x:o,domain:d,unit:D.unit,timeTicks:D.values,today:A,grid:q,size:L,barSize:Z,colorOf:N,margin:l,tooltip:V,plotLabel:g,todayLabel:G??a.chartToday,locale:s,formatDate:k,formatX:m,onTaskClick:mt})})}0&&(module.exports={GanttChart});
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-blue-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 +1 @@
1
- "use client";import{memo as St,useCallback as et,useMemo as v,useState as $t}from"react";import{useUILabels as xt}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 Mt}from"../chart/ChartTooltip.js";import{getSeriesColor as ut}from"../chart/palette.js";import{buildCartesianGeometry as Gt}from"../chart/utils/cartesian.js";import{readNumber as Dt,readXValue as At}from"../chart/utils/data.js";import{formatPercent as vt,formatXValue as Ot}from"../chart/utils/format.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 It,toTimestamp as U}from"../chart/utils/time.js";import{CHART_TOUCH as Ht}from"../chart/utils/touch.js";import{Table as Wt}from"../table/Table.js";import{TableBody as Xt}from"../table/TableBody.js";import{TableCell as J}from"../table/TableCell.js";import{TableHeader as Vt}from"../table/TableHeader.js";import{TableHeaderCell as Q}from"../table/TableHeaderCell.js";import{TableRow as zt}from"../table/TableRow.js";import{Fragment as Yt,jsx as e,jsxs as h}from"react/jsx-runtime";var _t=18,Ct=.5,Bt=.3,tt=7,Tt=10,kt=.02,gt="text-right [font-variant-numeric:tabular-nums]",Kt=St(function({tasks:p,arrows:P}){return h("g",{children:[e("g",{className:"fill-gray-400 stroke-gray-400 dark:fill-gray-500 dark:stroke-gray-500",children:P.map(r=>h("g",{children:[e("path",{d:r.d,fill:"none",strokeWidth:1}),e("path",{d:r.head,strokeWidth:0})]},r.key))}),p.map(r=>h("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 Ut({width:T,height:p,data:P,tasks:r,x:w,domain:k,unit:R,timeTicks:O,today:N,grid:E,size:I,barSize:X,colorOf:Y,margin:F,tooltip:S,plotLabel:rt,todayLabel:nt,locale:$,formatDate:Z,formatX:M,onTaskClick:V}){let[H,L]=$t(null),f=H!==null&&H<r.length?H:null,z=xt(),n=v(()=>{let o=Gt({width:T,height:p,data:P,x:w,y:{domain:k},bounds:k,margin:F,orientation:"horizontal",placement:"band",formatValue:a=>yt(a,R,$),formatX:M}),{valueScale:l,bandwidth:c,categoryPositions:b,innerWidth:it,innerHeight:st}=o,G=Math.min(X??_t,c),j=new Map(r.map((a,i)=>[a.id,i])),ct=r.map((a,i)=>{let g=b[i]+(c-G)/2,s=g+G/2,x=Y(a);if(a.start===null)return{key:`${i}`,color:x,track:null,trackOpacity:1,progress:null,milestone:null,top:b[i],height:c};let m=l(a.start);if(a.milestone)return{key:`${i}`,color:x,track:null,trackOpacity:1,progress:null,milestone:`M${m},${s-tt} L${m+tt},${s} L${m},${s+tt} L${m-tt},${s} Z`,top:b[i],height:c};let D=l(a.end??a.start),y=Math.max(2,D-m);return{key:`${i}`,color:x,track:bt({x:m,y:g,width:y,height:G,radius:3}),trackOpacity:a.progress===null?1:Bt,progress:a.progress===null?null:bt({x:m,y:s-G*Ct/2,width:Math.max(0,y*Math.min(1,Math.max(0,a.progress))),height:G*Ct,radius:2,round:"right"}),milestone:null,top:b[i],height:c}}),q=[];r.forEach((a,i)=>{if(a.start!==null)for(let g of a.dependsOn){let s=j.get(g);if(s===void 0||s===i)continue;let x=r[s];if(x.start===null)continue;let m=l(x.end??x.start),D=b[s]+c/2,y=l(a.start),A=b[i]+c/2,_=Math.max(m+Tt,y-Tt);q.push({key:`${g}-${a.id}`,d:`M${m},${D} L${_},${D} L${_},${A} L${y-5},${A}`,head:`M${y},${A} L${y-5},${A-3.5} L${y-5},${A+3.5} Z`})}});let mt=O.map(a=>({value:a,offset:l(a),label:yt(a,R,$)}));return{rendered:ct,arrows:q,categoryPositions:b,categoryCenters:o.categoryCenters,bandwidth:c,categoryTicks:o.categoryTicks,valueTicks:mt,valueScale:l,innerWidth:it,innerHeight:st,margin:o.margin}},[r,P,w,k,R,O,T,p,F,X,Y,$,M]),at=et(o=>{if(S===!1||r.length===0)return;let l=o.currentTarget.getBoundingClientRect(),c=o.clientY-l.top-n.margin.top;L(Et(n.categoryCenters,c))},[S,r.length,n.margin.top,n.categoryCenters]),ot=et(o=>{if(r.length===0)return;let l=r.length-1,c=f??0,b=o.key==="ArrowDown"?Math.min(l,c+1):o.key==="ArrowUp"?Math.max(0,c-1):o.key==="Home"?0:o.key==="End"?l:o.key==="Escape"?null:void 0;b!==void 0&&(o.preventDefault(),L(b))},[r.length,f]),lt=et(()=>{!V||f===null||V(r[f])},[V,f,r]),u=f===null?null:r[f];return h(Yt,{children:[h("svg",{width:T,height:p,role:"img","aria-label":rt??r.map(o=>o.label).join(", "),tabIndex:0,className:`${Ht} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500`,onPointerMove:at,onPointerLeave:()=>L(null),onKeyDown:ot,onBlur:()=>L(null),onClick:lt,children:[h("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:[e(Pt,{width:n.innerWidth,height:n.innerHeight,vertical:E?n.valueTicks.map(o=>o.offset):void 0}),f!==null?e("rect",{x:0,y:n.categoryPositions[f],width:n.innerWidth,height:n.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,e(Kt,{tasks:n.rendered,arrows:n.arrows}),N!==null?h("g",{children:[e("line",{x1:n.valueScale(N),y1:0,x2:n.valueScale(N),y2:n.innerHeight,className:"stroke-gray-900 dark:stroke-white",strokeWidth:1,strokeDasharray:"4 4"}),e("text",{x:n.valueScale(N)+4,y:8,className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:nt})]}):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:I})}),e("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:w.hidden?null:e(ft,{orientation:"left",ticks:n.categoryTicks,length:n.innerHeight,showLine:!1,tickSize:0,label:w.label,size:I})})]}),u&&f!==null&&S!==!1?e(Mt,{x:n.margin.left+(u.start===null?n.innerWidth/2:n.valueScale(u.start)),y:n.margin.top+n.categoryCenters[f],containerWidth:T,children:typeof S=="function"?S(u):h("div",{className:"flex flex-col gap-1",children:[e("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:u.label}),h("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:u.start===null?"\u2014":Z(u.start)})]}),u.milestone?null:h("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:u.end===null?"\u2014":Z(u.end)})]}),u.progress===null?null:h("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:vt(u.progress,{locale:$,maximumFractionDigits:0})})]})]})}):null]})}function pe({data:T,x:p,start:P,end:r,id:w,progress:k,milestone:R,dependencies:O,group:N,domain:E,today:I,ticks:X=6,barSize:Y,rowSize:F=30,color:S,height:rt,width:nt,size:$="md",grid:Z=!0,legend:M,tooltip:V=!0,tableView:H=!1,title:L,description:f,loading:z=!1,emptyState:n,error:at=!1,errorState:ot,onRetry:lt,actions:u,margin:o,locale:l,plotLabel:c,startLabel:b,endLabel:it,progressLabel:st,todayLabel:G,formatDate:j,onTaskClick:ct,className:q,...mt}){let a=xt(),i=v(()=>p.format??(t=>Ot(t,l)),[p.format,l]),g=v(()=>T.map((t,d)=>{let B=At(t,p.key,d),W=U(t[P]),C=r?U(t[r]):null,K=R?!!t[R]:C===null,pt=O?t[O]:void 0;return{index:d,id:String(w?t[w]??d:d),x:B,label:i(B,d),start:W,end:K?W:C??W,progress:k?Dt(t,k):null,milestone:K,dependsOn:Array.isArray(pt)?pt.map(Nt=>String(Nt)):[],group:N?t[N]??null:null,datum:t}}),[T,p.key,P,r,w,k,R,O,N,i]),s=v(()=>{let t=[];for(let d of g)d.group!==null&&!t.includes(d.group)&&t.push(d.group);return t},[g]),x=et(t=>t.group===null?S??ut(0):ut(s.indexOf(t.group)),[s,S]),m=v(()=>{if(E){let C=U(E[0]),K=U(E[1]);if(C!==null&&K!==null)return[C,K]}let t=g.flatMap(C=>C.start===null?[]:[C.start,C.end??C.start]);if(t.length===0)return[0,1];let d=Math.min(...t),B=Math.max(...t),W=B-d||864e5;return[d-W*kt,B+W*kt]},[E,g]),D=v(()=>It(m[0],m[1],X),[m,X]),y=v(()=>j??(t=>new Intl.DateTimeFormat(l,{day:"numeric",month:"short",year:"numeric"}).format(new Date(t))),[j,l]),A=v(()=>I===!1?null:U(I??Date.now()),[I]),_=v(()=>s.map((t,d)=>({key:t,label:t,color:ut(d),marker:"rect"})),[s]),dt=rt??Math.max(120,g.length*F+48),wt=M===void 0?s.length>=2:M!==!1,ht=typeof M=="string"?M:"bottom";return e(Lt,{title:L,description:f,height:dt,width:nt,size:$,loading:z,empty:g.length===0,emptyState:n,error:at,errorState:ot,onRetry:lt,actions:u,tableView:H,legendPosition:ht,legend:wt&&_.length>0?e(Rt,{items:_,position:ht,marker:"rect",size:$}):void 0,table:H?e("div",{className:"w-full overflow-x-auto",children:h(Wt,{children:[typeof L=="string"?e("caption",{className:"sr-only",children:L}):null,h(Vt,{children:[e(Q,{children:p.label??p.key}),e(Q,{className:"text-right",children:b??a.chartStart}),e(Q,{className:"text-right",children:it??a.chartEnd}),k?e(Q,{className:"text-right",children:st??a.chartProgress}):null]}),e(Xt,{children:g.map(t=>h(zt,{clickable:!1,children:[e(J,{className:"font-medium text-gray-900 dark:text-gray-100",children:t.label}),e(J,{className:gt,children:t.start===null?"\u2014":y(t.start)}),e(J,{className:gt,children:t.milestone||t.end===null?"\u2014":y(t.end)}),k?e(J,{className:gt,children:t.progress===null?"\u2014":vt(t.progress,{locale:l,maximumFractionDigits:0})}):null]},t.index))})]})}):void 0,className:q,...mt,children:({width:t})=>e(Ut,{width:t,height:dt,data:T,tasks:g,x:p,domain:m,unit:D.unit,timeTicks:D.values,today:A,grid:Z,size:$,barSize:Y,colorOf:x,margin:o,tooltip:V,plotLabel:c,todayLabel:G??a.chartToday,locale:l,formatDate:y,formatX:i,onTaskClick:ct})})}export{pe as GanttChart};
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-blue-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 +1 @@
1
- "use strict";"use client";var y=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var $=Object.prototype.hasOwnProperty;var ee=(o,a)=>{for(var i in a)y(o,i,{get:a[i],enumerable:!0})},re=(o,a,i,d)=>{if(a&&typeof a=="object"||typeof a=="function")for(let l of Z(a))!$.call(o,l)&&l!==i&&y(o,l,{get:()=>a[l],enumerable:!(d=Y(a,l))||d.enumerable});return o};var ae=o=>re(y({},"__esModule",{value:!0}),o);var ne={};ee(ne,{Header:()=>te});module.exports=ae(ne);var f=require("react"),s=require("../../lib/cn.cjs"),e=require("react/jsx-runtime");function te({logo:o,logoHref:a="/",onLogoClick:i,navItems:d=[],actions:l,rightContent:p,variant:t="default",size:b="md",backgroundColor:g,textColor:S,hoverColor:B,navItemTextColor:R,navItemHoverColor:j,navItemBgHover:D,navItemActiveColor:O,sticky:T=!1,fixed:W=!1,showSearch:k=!1,onSearch:N,searchPlaceholder:u="Search...",className:z,containerClassName:Q}){let[x,_]=(0,f.useState)(!1),[w,q]=(0,f.useState)(null),[m,C]=(0,f.useState)(""),A=()=>{_(!x)},E=r=>{q(w===r?null:r)},L=r=>{r.preventDefault(),N&&N(m)},F=(0,s.cn)(T&&"sticky top-0 z-50",W&&"fixed top-0 left-0 right-0 z-50"),G=(0,s.cn)(t==="default"&&!g&&"bg-neutral 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"),J=(0,s.cn)(b==="sm"&&"py-2",b==="md"&&"py-4",b==="lg"&&"py-6"),K=g||"",P=S||"",U=B||"",V=(0,s.cn)(F,G,J,K,P,z),M=(r,c,h=!1)=>{let X=r.children&&r.children.length>0,H=w===c,v=(0,s.cn)("px-4 py-2 transition-colors flex items-center gap-2",h?"block w-full text-left":"inline-flex",r.active&&"font-semibold border-b-2",r.active&&(O||"border-current"),R||(t==="default"||t==="transparent"?"text-gray-300":"text-gray-600 dark:text-gray-300"),j||U||(t==="default"||t==="transparent"?"hover:text-white":"hover:text-blue-600 dark:hover:text-blue-400"),D||"");if(X)return(0,e.jsxs)("div",{className:h?"w-full":"relative",children:[(0,e.jsxs)("button",{type:"button",onClick:()=>E(c),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-500 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",h?"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-500 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 I=(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-500 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:I},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:v,children:I},r.href??r.label)};return(0,e.jsxs)("header",{className:V,children:[(0,e.jsxs)("nav",{className:(0,s.cn)("container mx-auto flex items-center justify-between px-4",Q),children:[o&&(0,e.jsx)("div",{className:"flex items-center",children:a?(0,e.jsx)("a",{href:a,onClick:i,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:L,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=>C(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-blue-500 text-gray-900 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-500"})}),(0,e.jsx)("div",{className:"hidden md:flex items-center gap-2",children:d.map((r,c)=>M(r,c,!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:A,"aria-label":"Toggle menu","aria-expanded":x,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"})})})})]}),x&&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:L,className:"mb-4",children:(0,e.jsx)("input",{type:"search","aria-label":u,value:m,onChange:r=>C(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-blue-500 text-gray-900 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-500"})}),d.map((r,c)=>M(r,c,!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 y=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var ae=Object.getOwnPropertyNames;var te=Object.prototype.hasOwnProperty;var ne=(o,a)=>{for(var c in a)y(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&&y(o,l,{get:()=>a[l],enumerable:!(d=re(a,l))||d.enumerable});return o};var se=o=>oe(y({},"__esModule",{value:!0}),o);var de={};ne(de,{Header:()=>le});module.exports=se(de);var b=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,[h,E]=(0,b.useState)(!1),[C,F]=(0,b.useState)(null),[m,L]=(0,b.useState)(""),U=()=>{E(!h)},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,v=(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-blue-600 dark:hover:text-blue-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: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-500 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-500 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-500 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: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:v,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-blue-500 text-gray-900 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-500"})}),(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":h,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"})})})})]}),h&&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-blue-500 text-gray-900 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-500"})}),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 h}from"react";import{cn as n}from"../../lib/cn.js";import{Fragment as Y,jsx as r,jsxs as o}from"react/jsx-runtime";function ee({logo:p,logoHref:v="/",onLogoClick:I,navItems:d=[],actions:i,rightContent:c,variant:a="default",size:u="md",backgroundColor:l,textColor:S,hoverColor:B,navItemTextColor:R,navItemHoverColor:j,navItemBgHover:D,navItemActiveColor:O,sticky:T=!1,fixed:W=!1,showSearch:y=!1,onSearch:k,searchPlaceholder:g="Search...",className:z,containerClassName:Q}){let[f,_]=h(!1),[N,q]=h(null),[b,w]=h(""),A=()=>{_(!f)},E=e=>{q(N===e?null:e)},C=e=>{e.preventDefault(),k&&k(b)},F=n(T&&"sticky top-0 z-50",W&&"fixed top-0 left-0 right-0 z-50"),G=n(a==="default"&&!l&&"bg-neutral 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"),J=n(u==="sm"&&"py-2",u==="md"&&"py-4",u==="lg"&&"py-6"),K=l||"",P=S||"",U=B||"",V=n(F,G,J,K,P,z),L=(e,s,x=!1)=>{let X=e.children&&e.children.length>0,M=N===s,m=n("px-4 py-2 transition-colors flex items-center gap-2",x?"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||U||(a==="default"||a==="transparent"?"hover:text-white":"hover:text-blue-600 dark:hover:text-blue-400"),D||"");if(X)return o("div",{className:x?"w-full":"relative",children:[o("button",{type:"button",onClick:()=>E(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-500 text-white text-xs px-2 py-0.5 rounded-full",children:e.badge}),r("svg",{className:n("w-4 h-4 transition-transform",M&&"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"})})]}),M&&r("div",{className:n("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: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-500 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(Y,{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-500 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:V,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:v?r("a",{href:v,onClick:I,className:"flex items-center hover:opacity-80 transition-opacity",children:p}):r("div",{className:"flex items-center",children:p})}),y&&r("form",{onSubmit:C,className:"hidden md:flex flex-1 max-w-md mx-8",children:r("input",{type:"search","aria-label":g,value:b,onChange:e=>w(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-blue-500 text-gray-900 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-500"})}),r("div",{className:"hidden md:flex items-center gap-2",children:d.map((e,s)=>L(e,s,!1))}),(i||c)&&o("div",{className:"hidden md:flex items-center gap-2 ml-4",children:[i,c]}),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:A,"aria-label":"Toggle menu","aria-expanded":f,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"})})})})]}),f&&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:[y&&r("form",{onSubmit:C,className:"mb-4",children:r("input",{type:"search","aria-label":g,value:b,onChange:e=>w(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-blue-500 text-gray-900 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-500"})}),d.map((e,s)=>L(e,s,!0)),(i||c)&&o("div",{className:"flex flex-col gap-2 mt-4 pt-4 border-t border-gray-700",children:[i,c]})]})})]})}export{ee as Header};
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:v="/",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:y=!1,onSearch:k,searchPlaceholder:z,menuLabel:Q,className:_,containerClassName:q}){let N=ee(),g=z??N.headerSearchPlaceholder,[b,A]=x(!1),[w,E]=x(null),[f,C]=x(""),F=()=>{A(!b)},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,h=!1)=>{let $=e.children&&e.children.length>0,I=w===s,m=n("px-4 py-2 transition-colors flex items-center gap-2",h?"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-blue-600 dark:hover:text-blue-400"),D||"");if($)return o("div",{className:h?"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-500 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",h?"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-500 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-500 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:v?r("a",{href:v,onClick:S,className:"flex items-center hover:opacity-80 transition-opacity",children:p}):r("div",{className:"flex items-center",children:p})}),y&&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-blue-500 text-gray-900 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-500"})}),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":b,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"})})})})]}),b&&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:[y&&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-blue-500 text-gray-900 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-500"})}),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 +1 @@
1
- "use strict";"use client";var te=Object.defineProperty;var pe=Object.getOwnPropertyDescriptor;var Ce=Object.getOwnPropertyNames;var ke=Object.prototype.hasOwnProperty;var ye=(s,l)=>{for(var t in l)te(s,t,{get:l[t],enumerable:!0})},we=(s,l,t,e)=>{if(l&&typeof l=="object"||typeof l=="function")for(let f of Ce(l))!ke.call(s,f)&&f!==t&&te(s,f,{get:()=>l[f],enumerable:!(e=pe(l,f))||e.enumerable});return s};var ve=s=>we(te({},"__esModule",{value:!0}),s);var $e={};ye($e,{Heatmap:()=>Re,resetHeatmapWarnings:()=>Xe});module.exports=ve($e);var m=require("react"),se=require("../../lib/cn.cjs"),ne=require("../chart/ChartAxis.cjs"),ue=require("../chart/ChartContainer.cjs"),me=require("../chart/ChartScaleLegend.cjs"),ce=require("../chart/ChartTableView.cjs"),he=require("../chart/ChartTooltip.cjs"),N=require("../chart/palette.cjs"),I=require("../chart/utils/data.cjs"),F=require("../chart/utils/format.cjs"),k=require("../chart/utils/scales.cjs"),L=require("../chart/utils/text.cjs"),de=require("../chart/utils/ticks.cjs"),ge=require("../chart/utils/touch.cjs"),r=require("react/jsx-runtime"),Se=2,xe=2,Le=12,Ve=16,oe="cell:",ae=!1,He=(0,m.memo)(function({cells:l,radius:t}){return(0,r.jsx)("g",{children:l.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,se.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 Ee({width:s,height:l,columns:t,rows:e,lookup:f,colorScale:S,x:b,y:p,size:V,cellGap:w,cellRadius:K,showValues:O,tooltip:A,plotLabel:Z,formatValue:_,formatX:P,formatY:z,onCellClick:T}){let[H,D]=(0,m.useState)(null),c=H!==null&&H.column<t.length&&H.row<e.length?H:null,n=(0,m.useMemo)(()=>{let C=t.map((g,i)=>P(g,i)),u=e.map((g,i)=>z(g,i)),o={top:8,right:8,bottom:b.hidden?8:b.height??24+(b.label?16:0),left:p.hidden?8:p.height??(0,L.widestLabel)(u)+Le+(p.label?16:0)},h=Math.max(0,s-o.left-o.right),v=Math.max(0,l-o.top-o.bottom),d=(0,k.createBandScale)(t.map((g,i)=>i),[0,h],{paddingInner:0,paddingOuter:0}),x=(0,k.createBandScale)(e.map((g,i)=>i),[0,v],{paddingInner:0,paddingOuter:0}),G=Math.max(0,d.bandwidth-w),R=Math.max(0,x.bandwidth-w),W=[];e.forEach((g,i)=>{t.forEach((ee,q)=>{let a=f.get(`${(0,k.toKey)(ee)}|${(0,k.toKey)(g)}`)?.value??null,y=null;if(O&&a!==null&&R>=Ve){let $=_(a);(0,L.estimateTextWidth)($,10)+6<=G&&(y=$)}W.push({key:`${q}-${i}`,column:q,row:i,x:d(q)+w/2,y:x(i)+w/2,width:G,height:R,color:a===null?"transparent":S(a),label:y,onDark:a!==null&&S.onDark(a),missing:a===null})})});let X=(0,L.labelStride)(C.length,h,(0,L.widestLabel)(C)),B=(0,L.labelStride)(u.length,v,L.AXIS_FONT_SIZE+4),U=b.hidden?[]:C.map((g,i)=>({value:t[i],offset:d.center(i),label:g})).filter((g,i)=>i%X===0),Y=p.hidden?[]:u.map((g,i)=>({value:e[i],offset:x.center(i),label:g})).filter((g,i)=>i%B===0);return{margin:o,innerWidth:h,innerHeight:v,columnScale:d,rowScale:x,cells:W,columnTicks:U,rowTicks:Y}},[t,e,f,S,b,p,s,l,w,O,_,P,z]),M=(0,m.useCallback)((C,u)=>{let o=t[C],h=e[u],v=f.get(`${(0,k.toKey)(o)}|${(0,k.toKey)(h)}`),d=v?.value??null;return{x:o,y:h,xLabel:P(o,C),yLabel:z(h,u),value:d,formattedValue:d===null?"\u2014":_(d),color:d===null?"transparent":S(d),datum:v?.datum}},[t,e,f,S,_,P,z]),J=(0,m.useCallback)(C=>{if(A===!1||t.length===0||e.length===0)return;let u=C.currentTarget.getBoundingClientRect(),o=C.clientX-u.left-n.margin.left,h=C.clientY-u.top-n.margin.top,v=Math.floor(o/(n.columnScale.step||1)),d=Math.floor(h/(n.rowScale.step||1));if(v<0||v>=t.length||d<0||d>=e.length){D(null);return}D(x=>x?.column===v&&x.row===d?x:{column:v,row:d})},[A,t.length,e.length,n.margin,n.columnScale,n.rowScale]),Q=(0,m.useCallback)(C=>{if(t.length===0||e.length===0)return;let u=c??{column:0,row:0},o;switch(C.key){case"ArrowRight":o={...u,column:Math.min(t.length-1,u.column+1)};break;case"ArrowLeft":o={...u,column:Math.max(0,u.column-1)};break;case"ArrowDown":o={...u,row:Math.min(e.length-1,u.row+1)};break;case"ArrowUp":o={...u,row:Math.max(0,u.row-1)};break;case"Home":o={...u,column:0};break;case"End":o={...u,column:t.length-1};break;case"Escape":o=null;break;default:o=void 0}o!==void 0&&(C.preventDefault(),D(o))},[t.length,e.length,c]),j=(0,m.useCallback)(()=>{!T||!c||T(M(c.column,c.row))},[T,c,M]),E=c?M(c.column,c.row):null;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("svg",{width:s,height:l,role:"img","aria-label":Z??`${b.label??b.key} / ${p.label??p.key}`,tabIndex:0,className:`${ge.CHART_TOUCH} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500`,onPointerMove:J,onPointerLeave:()=>D(null),onKeyDown:Q,onBlur:()=>D(null),onClick:j,children:[(0,r.jsxs)("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:[(0,r.jsx)(He,{cells:n.cells,radius:K}),c?(0,r.jsx)("rect",{x:n.columnScale(c.column)+w/2,y:n.rowScale(c.row)+w/2,width:Math.max(0,n.columnScale.bandwidth-w),height:Math.max(0,n.rowScale.bandwidth-w),rx:K,fill:"none",strokeWidth:2,className:"stroke-gray-900 dark:stroke-white","aria-hidden":"true"}):null]}),(0,r.jsx)("g",{transform:`translate(${n.margin.left}, ${n.margin.top+n.innerHeight})`,children:b.hidden?null:(0,r.jsx)(ne.ChartAxis,{orientation:"bottom",ticks:n.columnTicks,length:n.innerWidth,showLine:!1,tickSize:0,label:b.label,size:V})}),(0,r.jsx)("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:p.hidden?null:(0,r.jsx)(ne.ChartAxis,{orientation:"left",ticks:n.rowTicks,length:n.innerHeight,showLine:!1,tickSize:0,label:p.label,size:V})})]}),c&&E&&A!==!1?(0,r.jsx)(he.ChartTooltip,{x:n.margin.left+n.columnScale.center(c.column),y:n.margin.top+n.rowScale.center(c.row),containerWidth:s,children:typeof A=="function"?A(E):(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:[E.yLabel," \xB7 ",E.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:E.color},"aria-hidden":"true"}),(0,r.jsx)("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:E.formattedValue})]})]})}):null]})}function ie(s,l,t){if(t)return t;let e=new Map;return s.forEach((f,S)=>{let b=(0,I.readXValue)(f,l,S),p=(0,k.toKey)(b);e.has(p)||e.set(p,b)}),[...e.values()]}function Re({data:s,x:l,y:t,value:e,format:f,domain:S,scale:b="sequential",center:p=0,steps:V,colors:w,xDomain:K,yDomain:O,cellGap:A=Se,cellRadius:Z=xe,showValues:_=!1,height:P=280,width:z,size:T="md",legend:H=!0,legendLabel:D,tooltip:c=!0,tableView:n=!1,title:M,description:J,loading:Q=!1,emptyState:j,error:E=!1,errorState:C,onRetry:u,actions:o,locale:h,plotLabel:v,onCellClick:d,className:x,...G}){V!==void 0&&V>N.CHART_MAX_COLOR_CLASSES&&!ae&&(ae=!0,console.warn(`[@synertech/ui] A Heatmap was cut into ${V} colour classes. Past ${N.CHART_MAX_COLOR_CLASSES} two neighbouring cells stop being tellable apart: leave \`steps\` unset and let the ramp stay continuous.`));let R=(0,m.useMemo)(()=>ie(s,l.key,K),[s,l.key,K]),W=(0,m.useMemo)(()=>ie(s,t.key,O),[s,t.key,O]),X=(0,m.useMemo)(()=>{let a=new Map;return s.forEach((y,$)=>{let le=(0,I.readNumber)(y,e);if(le===null)return;let fe=(0,I.readXValue)(y,l.key,$),be=(0,I.readXValue)(y,t.key,$);a.set(`${(0,k.toKey)(fe)}|${(0,k.toKey)(be)}`,{value:le,datum:y})}),a},[s,l.key,t.key,e]),B=(0,m.useMemo)(()=>f??(a=>(0,F.formatAuto)(a,h)),[f,h]),U=(0,m.useMemo)(()=>l.format??(a=>(0,F.formatXValue)(a,h)),[l.format,h]),Y=(0,m.useMemo)(()=>t.format??(a=>(0,F.formatXValue)(a,h)),[t.format,h]),g=(0,m.useMemo)(()=>{let a=S??(0,de.extent)([...X.values()].map(y=>y.value))??[0,1];return b==="diverging"?(0,N.createDivergingScale)(a,{center:p,steps:V,colors:w}):(0,N.createSequentialScale)(a,{steps:V,colors:w})},[S,X,b,p,V,w]),i=(0,m.useMemo)(()=>W.map(a=>{let y={[t.key]:a};return R.forEach($=>{y[`${oe}${(0,k.toKey)($)}`]=X.get(`${(0,k.toKey)($)}|${(0,k.toKey)(a)}`)?.value??null}),y}),[W,R,X,t.key]),ee=(0,m.useMemo)(()=>R.map((a,y)=>({key:`${oe}${(0,k.toKey)(a)}`,label:U(a,y)})),[R,U]),q=H!==!1,re=typeof H=="string"?H:"bottom";return(0,r.jsx)(ue.ChartContainer,{title:M,description:J,height:P,width:z,size:T,loading:Q,empty:X.size===0,emptyState:j,error:E,errorState:C,onRetry:u,actions:o,tableView:n,legendPosition:re,legend:q?(0,r.jsx)(me.ChartScaleLegend,{scale:g,label:D,format:B,size:T,locale:h}):void 0,table:n?(0,r.jsx)(ce.ChartTableView,{data:i,series:ee,xKey:t.key,xLabel:t.label??t.key,formatX:Y,formatValue:B,caption:typeof M=="string"?M:void 0}):void 0,className:x,...G,children:({width:a})=>(0,r.jsx)(Ee,{width:a,height:P,columns:R,rows:W,lookup:X,colorScale:g,x:l,y:t,size:T,cellGap:A,cellRadius:Z,showValues:_,tooltip:c,plotLabel:v,formatValue:B,formatX:U,formatY:Y,onCellClick:d})})}function Xe(){ae=!1}0&&(module.exports={Heatmap,resetHeatmapWarnings});
1
+ "use strict";"use client";var ae=Object.defineProperty;var Ce=Object.getOwnPropertyDescriptor;var ke=Object.getOwnPropertyNames;var we=Object.prototype.hasOwnProperty;var ye=(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))!we.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={};ye(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:y,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-y),X=Math.max(0,x.bandwidth-y),I=[];e.forEach((f,i)=>{t.forEach((te,G)=>{let n=b.get(`${(0,k.toKey)(te)}|${(0,k.toKey)(f)}`)?.value??null,w=null;if(B&&n!==null&&X>=He){let A=z(n);(0,L.estimateTextWidth)(A,10)+6<=Z&&(w=A)}I.push({key:`${G}-${i}`,column:G,row:i,x:h(G)+y/2,y:x(i)+y/2,width:Z,height:X,color:n===null?"transparent":S(n),label:w,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,y,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-blue-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)+y/2,y:a.rowScale(c.row)+y/2,width:Math.max(0,a.columnScale.bandwidth-y),height:Math.max(0,a.rowScale.bandwidth-y),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:y,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((w,A)=>{let oe=(0,K.readNumber)(w,e);if(oe===null)return;let be=(0,K.readXValue)(w,o.key,A),pe=(0,K.readXValue)(w,t.key,A);n.set(`${(0,k.toKey)(be)}|${(0,k.toKey)(pe)}`,{value:oe,datum:w})}),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(w=>w.value))??[0,1];return p==="diverging"?(0,M.createDivergingScale)(n,{center:C,steps:V,colors:y}):(0,M.createSequentialScale)(n,{steps:V,colors:y})},[S,$,p,C,V,y]),i=(0,m.useMemo)(()=>I.map(n=>{let w={[t.key]:n};return X.forEach(A=>{w[`${ie}${(0,k.toKey)(A)}`]=$.get(`${(0,k.toKey)(A)}|${(0,k.toKey)(n)}`)?.value??null}),w}),[I,X,$,t.key]),te=(0,m.useMemo)(()=>X.map((n,w)=>({key:`${ie}${(0,k.toKey)(n)}`,label:F(n,w)})),[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 +1 @@
1
- "use client";import{memo as de,useCallback as F,useMemo as S,useState as ge}from"react";import{cn as fe}from"../../lib/cn.js";import{ChartAxis as ae}from"../chart/ChartAxis.js";import{ChartContainer as be}from"../chart/ChartContainer.js";import{ChartScaleLegend as pe}from"../chart/ChartScaleLegend.js";import{ChartTableView as Ce}from"../chart/ChartTableView.js";import{ChartTooltip as ke}from"../chart/ChartTooltip.js";import{CHART_MAX_COLOR_CLASSES as re,createDivergingScale as ye,createSequentialScale as we}from"../chart/palette.js";import{readNumber as ve,readXValue as j}from"../chart/utils/data.js";import{formatAuto as Se,formatXValue as le}from"../chart/utils/format.js";import{createBandScale as oe,toKey as y}from"../chart/utils/scales.js";import{AXIS_FONT_SIZE as xe,estimateTextWidth as Le,labelStride as ie,widestLabel as se}from"../chart/utils/text.js";import{extent as Ve}from"../chart/utils/ticks.js";import{CHART_TOUCH as He}from"../chart/utils/touch.js";import{Fragment as Te,jsx as c,jsxs as M}from"react/jsx-runtime";var Ee=2,Re=2,Xe=12,$e=16,ue="cell:",ee=!1,Ae=de(function({cells:h,radius:t}){return c("g",{children:h.map(e=>M("g",{children:[c("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?c("text",{x:e.x+e.width/2,y:e.y+e.height/2,textAnchor:"middle",dominantBaseline:"central",className:fe("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 Pe({width:b,height:h,columns:t,rows:e,lookup:x,colorScale:w,x:d,y:g,size:L,cellGap:C,cellRadius:W,showValues:I,tooltip:$,plotLabel:G,formatValue:N,formatX:A,formatY:_,onCellClick:P}){let[V,T]=ge(null),i=V!==null&&V.column<t.length&&V.row<e.length?V:null,n=S(()=>{let f=t.map((m,l)=>A(m,l)),o=e.map((m,l)=>_(m,l)),r={top:8,right:8,bottom:d.hidden?8:d.height??24+(d.label?16:0),left:g.hidden?8:g.height??se(o)+Xe+(g.label?16:0)},s=Math.max(0,b-r.left-r.right),k=Math.max(0,h-r.top-r.bottom),u=oe(t.map((m,l)=>l),[0,s],{paddingInner:0,paddingOuter:0}),v=oe(e.map((m,l)=>l),[0,k],{paddingInner:0,paddingOuter:0}),U=Math.max(0,u.bandwidth-C),E=Math.max(0,v.bandwidth-C),z=[];e.forEach((m,l)=>{t.forEach((Q,B)=>{let a=x.get(`${y(Q)}|${y(m)}`)?.value??null,p=null;if(I&&a!==null&&E>=$e){let X=N(a);Le(X,10)+6<=U&&(p=X)}z.push({key:`${B}-${l}`,column:B,row:l,x:u(B)+C/2,y:v(l)+C/2,width:U,height:E,color:a===null?"transparent":w(a),label:p,onDark:a!==null&&w.onDark(a),missing:a===null})})});let R=ie(f.length,s,se(f)),K=ie(o.length,k,xe+4),O=d.hidden?[]:f.map((m,l)=>({value:t[l],offset:u.center(l),label:m})).filter((m,l)=>l%R===0),q=g.hidden?[]:o.map((m,l)=>({value:e[l],offset:v.center(l),label:m})).filter((m,l)=>l%K===0);return{margin:r,innerWidth:s,innerHeight:k,columnScale:u,rowScale:v,cells:z,columnTicks:O,rowTicks:q}},[t,e,x,w,d,g,b,h,C,I,N,A,_]),D=F((f,o)=>{let r=t[f],s=e[o],k=x.get(`${y(r)}|${y(s)}`),u=k?.value??null;return{x:r,y:s,xLabel:A(r,f),yLabel:_(s,o),value:u,formattedValue:u===null?"\u2014":N(u),color:u===null?"transparent":w(u),datum:k?.datum}},[t,e,x,w,N,A,_]),Y=F(f=>{if($===!1||t.length===0||e.length===0)return;let o=f.currentTarget.getBoundingClientRect(),r=f.clientX-o.left-n.margin.left,s=f.clientY-o.top-n.margin.top,k=Math.floor(r/(n.columnScale.step||1)),u=Math.floor(s/(n.rowScale.step||1));if(k<0||k>=t.length||u<0||u>=e.length){T(null);return}T(v=>v?.column===k&&v.row===u?v:{column:k,row:u})},[$,t.length,e.length,n.margin,n.columnScale,n.rowScale]),Z=F(f=>{if(t.length===0||e.length===0)return;let o=i??{column:0,row:0},r;switch(f.key){case"ArrowRight":r={...o,column:Math.min(t.length-1,o.column+1)};break;case"ArrowLeft":r={...o,column:Math.max(0,o.column-1)};break;case"ArrowDown":r={...o,row:Math.min(e.length-1,o.row+1)};break;case"ArrowUp":r={...o,row:Math.max(0,o.row-1)};break;case"Home":r={...o,column:0};break;case"End":r={...o,column:t.length-1};break;case"Escape":r=null;break;default:r=void 0}r!==void 0&&(f.preventDefault(),T(r))},[t.length,e.length,i]),J=F(()=>{!P||!i||P(D(i.column,i.row))},[P,i,D]),H=i?D(i.column,i.row):null;return M(Te,{children:[M("svg",{width:b,height:h,role:"img","aria-label":G??`${d.label??d.key} / ${g.label??g.key}`,tabIndex:0,className:`${He} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500`,onPointerMove:Y,onPointerLeave:()=>T(null),onKeyDown:Z,onBlur:()=>T(null),onClick:J,children:[M("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:[c(Ae,{cells:n.cells,radius:W}),i?c("rect",{x:n.columnScale(i.column)+C/2,y:n.rowScale(i.row)+C/2,width:Math.max(0,n.columnScale.bandwidth-C),height:Math.max(0,n.rowScale.bandwidth-C),rx:W,fill:"none",strokeWidth:2,className:"stroke-gray-900 dark:stroke-white","aria-hidden":"true"}):null]}),c("g",{transform:`translate(${n.margin.left}, ${n.margin.top+n.innerHeight})`,children:d.hidden?null:c(ae,{orientation:"bottom",ticks:n.columnTicks,length:n.innerWidth,showLine:!1,tickSize:0,label:d.label,size:L})}),c("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:g.hidden?null:c(ae,{orientation:"left",ticks:n.rowTicks,length:n.innerHeight,showLine:!1,tickSize:0,label:g.label,size:L})})]}),i&&H&&$!==!1?c(ke,{x:n.margin.left+n.columnScale.center(i.column),y:n.margin.top+n.rowScale.center(i.row),containerWidth:b,children:typeof $=="function"?$(H):M("div",{className:"flex flex-col gap-1",children:[M("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:[H.yLabel," \xB7 ",H.xLabel]}),M("div",{className:"flex items-center gap-2",children:[c("span",{className:"h-2.5 w-2.5 shrink-0 rounded-sm",style:{backgroundColor:H.color},"aria-hidden":"true"}),c("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:H.formattedValue})]})]})}):null]})}function me(b,h,t){if(t)return t;let e=new Map;return b.forEach((x,w)=>{let d=j(x,h,w),g=y(d);e.has(g)||e.set(g,d)}),[...e.values()]}function Ye({data:b,x:h,y:t,value:e,format:x,domain:w,scale:d="sequential",center:g=0,steps:L,colors:C,xDomain:W,yDomain:I,cellGap:$=Ee,cellRadius:G=Re,showValues:N=!1,height:A=280,width:_,size:P="md",legend:V=!0,legendLabel:T,tooltip:i=!0,tableView:n=!1,title:D,description:Y,loading:Z=!1,emptyState:J,error:H=!1,errorState:f,onRetry:o,actions:r,locale:s,plotLabel:k,onCellClick:u,className:v,...U}){L!==void 0&&L>re&&!ee&&(ee=!0,console.warn(`[@synertech/ui] A Heatmap was cut into ${L} colour classes. Past ${re} two neighbouring cells stop being tellable apart: leave \`steps\` unset and let the ramp stay continuous.`));let E=S(()=>me(b,h.key,W),[b,h.key,W]),z=S(()=>me(b,t.key,I),[b,t.key,I]),R=S(()=>{let a=new Map;return b.forEach((p,X)=>{let ne=ve(p,e);if(ne===null)return;let ce=j(p,h.key,X),he=j(p,t.key,X);a.set(`${y(ce)}|${y(he)}`,{value:ne,datum:p})}),a},[b,h.key,t.key,e]),K=S(()=>x??(a=>Se(a,s)),[x,s]),O=S(()=>h.format??(a=>le(a,s)),[h.format,s]),q=S(()=>t.format??(a=>le(a,s)),[t.format,s]),m=S(()=>{let a=w??Ve([...R.values()].map(p=>p.value))??[0,1];return d==="diverging"?ye(a,{center:g,steps:L,colors:C}):we(a,{steps:L,colors:C})},[w,R,d,g,L,C]),l=S(()=>z.map(a=>{let p={[t.key]:a};return E.forEach(X=>{p[`${ue}${y(X)}`]=R.get(`${y(X)}|${y(a)}`)?.value??null}),p}),[z,E,R,t.key]),Q=S(()=>E.map((a,p)=>({key:`${ue}${y(a)}`,label:O(a,p)})),[E,O]),B=V!==!1,te=typeof V=="string"?V:"bottom";return c(be,{title:D,description:Y,height:A,width:_,size:P,loading:Z,empty:R.size===0,emptyState:J,error:H,errorState:f,onRetry:o,actions:r,tableView:n,legendPosition:te,legend:B?c(pe,{scale:m,label:T,format:K,size:P,locale:s}):void 0,table:n?c(Ce,{data:l,series:Q,xKey:t.key,xLabel:t.label??t.key,formatX:q,formatValue:K,caption:typeof D=="string"?D:void 0}):void 0,className:v,...U,children:({width:a})=>c(Pe,{width:a,height:A,columns:E,rows:z,lookup:R,colorScale:m,x:h,y:t,size:P,cellGap:$,cellRadius:G,showValues:N,tooltip:i,plotLabel:k,formatValue:K,formatX:O,formatY:q,onCellClick:u})})}function Ze(){ee=!1}export{Ye as Heatmap,Ze as resetHeatmapWarnings};
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 we}from"../chart/ChartTooltip.js";import{CHART_MAX_COLOR_CLASSES as le,createDivergingScale as ye,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 w}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:y,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(`${w(j)}|${w(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":y(n),label:p,onDark:n!==null&&y.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,y,d,f,b,g,C,I,_,P,M]),D=G((u,m)=>{let o=t[u],r=e[m],k=x.get(`${w(o)}|${w(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":y(s),datum:k?.datum}},[t,e,x,y,_,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-blue-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(we,{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,y)=>{let d=ee(x,g,y),f=w(d);e.has(f)||e.set(f,d)}),[...e.values()]}function Qe({data:b,x:g,y:t,value:e,format:x,domain:y,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(`${w(he)}|${w(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=y??Ee([...X.values()].map(p=>p.value))??[0,1];return d==="diverging"?ye(n,{center:f,steps:L,colors:C}):ve(n,{steps:L,colors:C})},[y,X,d,f,L,C]),l=S(()=>z.map(n=>{let p={[t.key]:n};return R.forEach($=>{p[`${me}${w($)}`]=X.get(`${w($)}|${w(n)}`)?.value??null}),p}),[z,R,X,t.key]),j=S(()=>R.map((n,p)=>({key:`${me}${w(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,5 +1,5 @@
1
- "use strict";"use client";var V=Object.create;var w=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var J=Object.getPrototypeOf,Q=Object.prototype.hasOwnProperty;var X=(t,a)=>{for(var o in a)w(t,o,{get:a[o],enumerable:!0})},P=(t,a,o,i)=>{if(a&&typeof a=="object"||typeof a=="function")for(let n of F(a))!Q.call(t,n)&&n!==o&&w(t,n,{get:()=>a[n],enumerable:!(i=j(a,n))||i.enumerable});return t};var z=(t,a,o)=>(o=t!=null?V(J(t)):{},P(a||!t||!t.__esModule?w(o,"default",{value:t,enumerable:!0}):o,t)),Y=t=>P(w({},"__esModule",{value:!0}),t);var ce={};X(ce,{HelpButton:()=>U,WithHelpButton:()=>de});module.exports=Y(ce);var r=require("react"),A=z(require("dompurify"),1),W=z(require("react-markdown"),1),_=z(require("remark-gfm"),1),D=require("../../lib/i18n.cjs"),e=require("react/jsx-runtime"),Z=(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"})]}),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:"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"})]}),te=(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"})]}),re=(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"})]}),oe={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"},ne={sm:"w-56",md:"w-72",lg:"w-96",xl:"w-[32rem]"},le=[_.default],ie={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:a,...o})=>!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",...o,children:a}):(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",...o,children:a}),pre:({...t})=>(0,e.jsx)("pre",{className:"my-2",...t}),a:({...t})=>(0,e.jsx)("a",{className:"text-blue-600 dark:text-blue-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 U({content:t,markdown:a=!1,position:o="bottom",size:i="sm",className:n="",visible:E=!0,editable:f=!1,onSave:g,onReset:c,width:C="md",title:m,markdownEditor:b,markdownEditorUnavailableLabel:M}){let R=(0,D.useUILabels)(),[y,L]=(0,r.useState)(!1),[d,p]=(0,r.useState)(!1),[v,x]=(0,r.useState)(""),[T,h]=(0,r.useState)(!1),[I,s]=(0,r.useState)(null),B=(0,r.useRef)(null),H=(0,r.useRef)(null),S=(0,r.useRef)(null),l=(0,r.useRef)(null);(0,r.useEffect)(()=>{if(!y)return;let u=N=>{B.current&&!B.current.contains(N.target)&&H.current&&!H.current.contains(N.target)&&(d||L(!1))},O=N=>{N.key==="Escape"&&(d?(p(!1),x("")):L(!1))};return document.addEventListener("mousedown",u),document.addEventListener("keydown",O),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",O)}},[y,d]),(0,r.useEffect)(()=>{d&&S.current&&S.current.focus()},[d]),(0,r.useEffect)(()=>()=>{l.current&&clearTimeout(l.current)},[]);let $=(0,r.useCallback)(()=>{x(typeof t=="string"?t:""),p(!0),s(null)},[t]),G=(0,r.useCallback)(()=>{p(!1),x(""),s(null)},[]),K=(0,r.useCallback)(async()=>{if(!g){s({type:"error",text:"Aucune fonction de sauvegarde fournie"});return}h(!0);try{await g(v)?(s({type:"success",text:"Sauvegard\xE9 avec succ\xE8s !"}),p(!1),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>s(null),2e3)):s({type:"error",text:"Erreur lors de la sauvegarde"})}catch{s({type:"error",text:"Erreur lors de la sauvegarde"})}finally{h(!1)}},[v,g]),q=(0,r.useCallback)(async()=>{if(c&&confirm("\xCAtes-vous s\xFBr de vouloir r\xE9initialiser ce contenu ?")){h(!0);try{await c()?(s({type:"success",text:"R\xE9initialis\xE9 avec succ\xE8s !"}),p(!1),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>s(null),2e3)):s({type:"error",text:"Erreur lors de la r\xE9initialisation"})}catch{s({type:"error",text:"Erreur lors de la r\xE9initialisation"})}finally{h(!1)}}},[c]),k=t;return E?(0,e.jsxs)("div",{className:"relative inline-flex items-center",children:[(0,e.jsx)("button",{type:"button",ref:B,onClick:()=>L(!y),className:`
2
- ${oe[i]}
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,a)=>{for(var s in a)E(t,s,{get:a[s],enumerable:!0})},W=(t,a,s,d)=>{if(a&&typeof a=="object"||typeof a=="function")for(let l of J(a))!X.call(t,l)&&l!==s&&E(t,l,{get:()=>a[l],enumerable:!(d=F(a,l))||d.enumerable});return t};var H=(t,a,s)=>(s=t!=null?j(Q(t)):{},W(a||!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 o=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"})]}),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"})]}),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:a,...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:a}):(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:a}),pre:({...t})=>(0,e.jsx)("pre",{className:"my-2",...t}),a:({...t})=>(0,e.jsx)("a",{className:"text-blue-600 dark:text-blue-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:a=!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,o.useState)(!1),[c,b]=(0,o.useState)(!1),[v,x]=(0,o.useState)(""),[I,k]=(0,o.useState)(!1),[S,n]=(0,o.useState)(null),T=(0,o.useRef)(null),O=(0,o.useRef)(null),P=(0,o.useRef)(null),i=(0,o.useRef)(null);(0,o.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?(b(!1),x("")):L(!1))};return document.addEventListener("mousedown",g),document.addEventListener("keydown",z),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",z)}},[y,c]),(0,o.useEffect)(()=>{c&&P.current&&P.current.focus()},[c]),(0,o.useEffect)(()=>()=>{i.current&&clearTimeout(i.current)},[]);let G=(0,o.useCallback)(()=>{x(typeof t=="string"?t:""),b(!0),n(null)},[t]),K=(0,o.useCallback)(()=>{b(!1),x(""),n(null)},[]),q=(0,o.useCallback)(async()=>{if(!m){n({type:"error",text:r.helpButtonNoSave});return}k(!0);try{await m(v)?(n({type:"success",text:r.helpButtonSaved}),b(!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,o.useCallback)(async()=>{if(u&&confirm(r.helpButtonResetConfirm)){k(!0);try{await u()?(n({type:"success",text:r.helpButtonResetDone}),b(!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]}
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
@@ -10,13 +10,13 @@
10
10
  hover:border-gray-400 dark:hover:border-gray-500
11
11
  transition-all duration-150
12
12
  focus:outline-none focus:ring-2 focus:ring-blue-500/50
13
- ${n}
14
- `,"aria-label":"Afficher l'aide","aria-expanded":y,children:(0,e.jsx)("span",{className:"font-medium",children:"?"})}),y&&(0,e.jsxs)("div",{ref:H,className:`
15
- absolute z-50 ${se[o]}
16
- ${ne[C]} max-h-[80vh] overflow-hidden flex flex-col
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]}
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:[(m||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:m&&(0,e.jsx)("h3",{className:"text-sm font-semibold",children:m})}),f&&(0,e.jsx)("div",{className:"flex items-center gap-1",children:d?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",onClick:K,disabled:T,className:"p-1.5 rounded-md hover:bg-green-100 dark:hover:bg-green-900/30 text-green-600 dark:text-green-400 transition-colors disabled:opacity-50 cursor-pointer",title:"Sauvegarder",children:T?ae:ee}),(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 hover:text-gray-700 dark:hover:text-gray-300 transition-colors cursor-pointer",title:"Annuler",children:te}),c&&(0,e.jsx)("button",{type:"button",onClick:q,disabled:T,className:"p-1.5 rounded-md hover:bg-orange-100 dark:hover:bg-orange-900/30 text-orange-600 dark:text-orange-400 transition-colors disabled:opacity-50 cursor-pointer",title:"R\xE9initialiser",children:re})]}):(0,e.jsx)("button",{type:"button",onClick:$,className:"p-1.5 rounded-md hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 transition-colors cursor-pointer",title:"Modifier",children:Z})})]}),I&&(0,e.jsx)("div",{className:`px-4 py-2 text-xs ${I.type==="success"?"bg-green-50 dark:bg-green-900/20 text-green-600 dark:text-green-400":"bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400"}`,children:I.text}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:d?a?b?(0,e.jsx)(b,{value:v,onChange:x,placeholder:"\xC9crivez en Markdown..."}):(0,e.jsx)("p",{role:"alert",className:"p-3 text-sm text-gray-500 dark:text-gray-400",children:M??R.markdownEditorUnavailable}):(0,e.jsx)("div",{className:"space-y-2",children:(0,e.jsx)("textarea",{ref:S,"aria-label":"Contenu d'aide",value:v,onChange:u=>x(u.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-blue-500/50 text-gray-700 dark:text-gray-300 font-mono",placeholder:"\xC9crivez votre contenu d'aide..."})}):typeof k=="string"?(0,e.jsx)("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:a?(0,e.jsx)(W.default,{remarkPlugins:le,components:ie,children:k}):(0,e.jsx)("div",{dangerouslySetInnerHTML:{__html:A.default.sanitize(k)}})}):k})]})]}):null}function de({children:t,content:a,markdown:o=!1,position:i="bottom",size:n="sm",visible:E=!0,editable:f=!1,onSave:g,onReset:c,width:C="md",title:m,className:b,markdownEditor:M,markdownEditorUnavailableLabel:R}){return(0,e.jsxs)("div",{className:"inline-flex items-center gap-2.5",children:[t,(0,e.jsx)(U,{content:a,markdown:o,position:i,size:n,visible:E,editable:f,onSave:g,onReset:c,width:C,title:m,className:b,markdownEditor:M,markdownEditorUnavailableLabel: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:I,className:"p-1.5 rounded-md hover:bg-green-100 dark:hover:bg-green-900/30 text-green-600 dark:text-green-400 transition-colors disabled:opacity-50 cursor-pointer",title:r.helpButtonSave,children:I?ae: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 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-600 dark:text-orange-400 transition-colors disabled:opacity-50 cursor-pointer",title:r.helpButtonReset,children:oe})]}):(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 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-600 dark:text-green-400":"bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400"}`,children:S.text}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:c?a?h?(0,e.jsx)(h,{value:v,onChange:x,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=>x(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-blue-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:a?(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:a,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:a,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});