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