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