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