@synertech/ui 0.47.0 → 0.48.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/.claude/skills/use-synertech-ui/SKILL.md +49 -1
  2. package/README.md +23 -0
  3. package/dist/components/area-chart/AreaChart.cjs +1 -1
  4. package/dist/components/area-chart/AreaChart.js +1 -1
  5. package/dist/components/bar-chart/BarChart.cjs +1 -1
  6. package/dist/components/bar-chart/BarChart.js +1 -1
  7. package/dist/components/box-plot/BoxPlot.cjs +1 -1
  8. package/dist/components/box-plot/BoxPlot.js +1 -1
  9. package/dist/components/breadcrumb/Breadcrumb.cjs +1 -1
  10. package/dist/components/breadcrumb/Breadcrumb.js +1 -1
  11. package/dist/components/bullet-chart/BulletChart.cjs +1 -1
  12. package/dist/components/bullet-chart/BulletChart.js +1 -1
  13. package/dist/components/calendar/Calendar.cjs +1 -1
  14. package/dist/components/calendar/Calendar.js +1 -1
  15. package/dist/components/candlestick-chart/CandlestickChart.cjs +1 -1
  16. package/dist/components/candlestick-chart/CandlestickChart.js +1 -1
  17. package/dist/components/chart/ChartPeriodPicker.cjs +1 -1
  18. package/dist/components/chart/ChartPeriodPicker.js +1 -1
  19. package/dist/components/datagrid/DataGrid.cjs +1 -1
  20. package/dist/components/datagrid/DataGrid.js +1 -1
  21. package/dist/components/dumbbell-chart/DumbbellChart.cjs +1 -1
  22. package/dist/components/dumbbell-chart/DumbbellChart.js +1 -1
  23. package/dist/components/footer/FooterLink.cjs +1 -1
  24. package/dist/components/footer/FooterLink.js +1 -1
  25. package/dist/components/footer/FooterSocial.cjs +1 -1
  26. package/dist/components/footer/FooterSocial.js +1 -1
  27. package/dist/components/form/number-input/NumberInput.cjs +1 -1
  28. package/dist/components/form/number-input/NumberInput.js +1 -1
  29. package/dist/components/funnel-chart/FunnelChart.cjs +1 -1
  30. package/dist/components/funnel-chart/FunnelChart.js +1 -1
  31. package/dist/components/gantt-chart/GanttChart.cjs +1 -1
  32. package/dist/components/gantt-chart/GanttChart.js +1 -1
  33. package/dist/components/header/Header.cjs +1 -1
  34. package/dist/components/header/Header.js +1 -1
  35. package/dist/components/heat-map/Heatmap.cjs +1 -1
  36. package/dist/components/heat-map/Heatmap.js +1 -1
  37. package/dist/components/help-button/HelpButton.cjs +5 -5
  38. package/dist/components/help-button/HelpButton.js +6 -6
  39. package/dist/components/help-button/sanitize-html.cjs +1 -0
  40. package/dist/components/help-button/sanitize-html.js +1 -0
  41. package/dist/components/line-chart/LineChart.cjs +1 -1
  42. package/dist/components/line-chart/LineChart.js +1 -1
  43. package/dist/components/pie-chart/PieChart.cjs +1 -1
  44. package/dist/components/pie-chart/PieChart.js +1 -1
  45. package/dist/components/scatter-chart/ScatterChart.cjs +1 -1
  46. package/dist/components/scatter-chart/ScatterChart.js +1 -1
  47. package/dist/components/sidebar/Sidebar.cjs +1 -1
  48. package/dist/components/sidebar/Sidebar.js +1 -1
  49. package/dist/components/stat-card/StatCard.cjs +1 -1
  50. package/dist/components/stat-card/StatCard.js +1 -1
  51. package/dist/components/waterfall-chart/WaterfallChart.cjs +1 -1
  52. package/dist/components/waterfall-chart/WaterfallChart.js +1 -1
  53. package/dist/index.cjs +1 -1
  54. package/dist/index.d.cts +187 -25
  55. package/dist/index.d.ts +187 -25
  56. package/dist/index.js +1 -1
  57. package/dist/lib/i18n.cjs +1 -1
  58. package/dist/lib/i18n.js +1 -1
  59. package/dist/lib/safe-href.cjs +1 -0
  60. package/dist/lib/safe-href.js +1 -0
  61. package/package.json +1 -1
@@ -1 +1 @@
1
- "use strict";"use client";var te=Object.defineProperty;var pe=Object.getOwnPropertyDescriptor;var ye=Object.getOwnPropertyNames;var Ce=Object.prototype.hasOwnProperty;var ke=(o,l)=>{for(var n in l)te(o,n,{get:l[n],enumerable:!0})},xe=(o,l,n,e)=>{if(l&&typeof l=="object"||typeof l=="function")for(let s of ye(l))!Ce.call(o,s)&&s!==n&&te(o,s,{get:()=>l[s],enumerable:!(e=pe(l,s))||e.enumerable});return o};var ve=o=>xe(te({},"__esModule",{value:!0}),o);var Pe={};ke(Pe,{BulletChart:()=>Ee});module.exports=ve(Pe);var m=require("react"),ue=require("../../lib/i18n.cjs"),ne=require("../chart/ChartAxis.cjs"),me=require("../chart/ChartContainer.cjs"),ce=require("../chart/ChartTableView.cjs"),ge=require("../chart/ChartTooltip.cjs"),de=require("../chart/palette.cjs"),I=require("../chart/utils/data.cjs"),z=require("../chart/utils/format.cjs"),he=require("../chart/utils/keyboard.cjs"),ae=require("../chart/utils/path.cjs"),M=require("../chart/utils/scales.cjs"),re=require("../chart/utils/text.cjs"),K=require("../chart/utils/ticks.cjs"),fe=require("../chart/utils/touch.cjs"),t=require("react/jsx-runtime"),Re=22,Te=.42,oe=3,se=8,Ne=12,Se=["fill-gray-300 dark:fill-gray-500","fill-gray-200 dark:fill-gray-600","fill-gray-100 dark:fill-gray-700","fill-gray-50 dark:fill-gray-800"],Ve=(0,m.memo)(function({rows:l,color:n}){return(0,t.jsx)("g",{children:l.map(e=>(0,t.jsxs)("g",{children:[e.bands.map(s=>(0,t.jsx)("path",{d:s.d,className:s.className,fill:s.fill},s.key)),e.measure?(0,t.jsx)("path",{d:e.measure,fill:n}):null,e.target?(0,t.jsx)("line",{x1:e.target.x,y1:e.target.y1,x2:e.target.x,y2:e.target.y2,strokeWidth:2,strokeLinecap:"round",className:"stroke-gray-900 dark:stroke-white"}):null,e.label?(0,t.jsx)("text",{x:e.label.x,y:e.label.y,dominantBaseline:"middle",className:"fill-gray-700 text-[11px] font-medium [font-variant-numeric:tabular-nums] dark:fill-gray-200",children:e.label.text}):null]},e.key))})});function Be({width:o,height:l,rows:n,x:e,size:s,sharedDomain:g,showValues:R,trackSize:W,rangeColors:_,color:U,tooltip:T,plotLabel:J,formatValue:O,locale:D,onRowClick:N}){let[X,x]=(0,m.useState)(null),u=X!==null&&X<n.length?X:null,r=(0,m.useMemo)(()=>{let h=n.map(a=>a.label),y=R?n.map(a=>a.formattedValue):[],C={top:6,right:R?(0,re.widestLabel)(y)+se*2:8,bottom:g?26+(e.label?16:0):6,left:e.hidden?8:e.height??(0,re.widestLabel)(h)+Ne},S=Math.max(0,o-C.left-C.right),G=Math.max(0,l-C.top-C.bottom),d=(0,M.createBandScale)(n.map((a,c)=>c),[0,G],{paddingInner:.34}),V=Math.min(W??Re,d.bandwidth),w=Math.max(3,V*Te),F=_??Se,B=_!==void 0,E=n.map((a,c)=>{let Y=Math.max(0,a.value??0,a.target??0,...a.ranges.length>0?a.ranges:[0]),A=g??(a.ranges.length>0?[0,Y]:(0,K.niceDomain)(0,Y,4)),i=(0,M.createLinearScale)(A,[0,S]),f=d(c)+(d.bandwidth-V)/2,k=f+V/2,L=a.ranges.length>0?[...a.ranges].sort((p,q)=>p-q):[A[1]],b=A[0],j=L.map((p,q)=>{let le=i(b),be=i(Math.max(b,p));b=p;let ie=F[Math.min(q,F.length-1)];return{key:`${c}-${q}`,d:(0,ae.buildBarPath)({x:le,y:f,width:Math.max(0,be-le),height:V,radius:0}),className:B?void 0:ie,fill:B?ie:void 0}}),ee=a.value===null?null:(0,ae.buildBarPath)({x:i(A[0]),y:k-w/2,width:Math.max(0,i(a.value)-i(A[0])),height:w,radius:2,round:"right"});return{key:`${c}`,bands:j,measure:ee,target:a.target===null?null:{x:i(a.target),y1:f-oe,y2:f+V+oe},label:R?{x:S+se,y:k,text:a.formattedValue}:null,top:d(c),height:d.bandwidth}}),H=e.hidden?[]:n.map((a,c)=>({value:a.x,offset:d.center(c),label:a.label})),P=g?(0,K.niceTicks)(g[0],g[1],5).map(a=>({value:a,offset:(0,M.createLinearScale)(g,[0,S])(a),label:O(a)})):[];return{margin:C,innerWidth:S,innerHeight:G,band:d,rendered:E,categoryTicks:H,valueTicks:P,centers:n.map((a,c)=>d.center(c))}},[n,e,o,l,g,R,W,_,O]),Q=(0,m.useCallback)(h=>{if(T===!1||n.length===0)return;let y=h.currentTarget.getBoundingClientRect(),C=h.clientY-y.top-r.margin.top;x((0,M.nearestIndex)(r.centers,C))},[T,n.length,r.margin.top,r.centers]),$=(0,m.useCallback)(()=>{!N||u===null||N(n[u])},[N,u,n]),Z=(0,m.useCallback)(h=>(0,he.handleChartKeyDown)(h,{count:n.length,current:u,axis:"y",onMove:x,pick:N?$:null}),[n.length,u,N,$]),v=u===null?null:n[u];return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("svg",{width:o,height:l,role:"img","aria-label":J??n.map(h=>h.label).join(", "),tabIndex:0,className:`${fe.CHART_TOUCH} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:Q,onPointerLeave:()=>x(null),onKeyDown:Z,onBlur:()=>x(null),onClick:$,children:[(0,t.jsxs)("g",{transform:`translate(${r.margin.left}, ${r.margin.top})`,children:[u!==null&&r.rendered[u]?(0,t.jsx)("rect",{x:-4,y:r.rendered[u].top,width:r.innerWidth+8,height:r.rendered[u].height,rx:4,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,(0,t.jsx)(Ve,{rows:r.rendered,color:U})]}),(0,t.jsx)("g",{transform:`translate(${r.margin.left}, ${r.margin.top})`,children:e.hidden?null:(0,t.jsx)(ne.ChartAxis,{orientation:"left",ticks:r.categoryTicks,length:r.innerHeight,showLine:!1,tickSize:0,size:s})}),g?(0,t.jsx)("g",{transform:`translate(${r.margin.left}, ${r.margin.top+r.innerHeight})`,children:(0,t.jsx)(ne.ChartAxis,{orientation:"bottom",ticks:r.valueTicks,length:r.innerWidth,label:e.label,size:s})}):null]}),v&&u!==null&&T!==!1?(0,t.jsx)(ge.ChartTooltip,{x:r.margin.left+r.innerWidth/2,y:r.margin.top+r.centers[u],containerWidth:o,children:typeof T=="function"?T(v):(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:v.label}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"h-0.5 w-3 shrink-0 rounded-full",style:{backgroundColor:U},"aria-hidden":"true"}),(0,t.jsx)("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:v.formattedValue}),v.attainment!==null?(0,t.jsx)("span",{className:"text-gray-500 [font-variant-numeric:tabular-nums] dark:text-gray-400",children:(0,z.formatPercent)(v.attainment,{locale:D})}):null]})]})}):null]})}function Ee({data:o,x:l,value:n,target:e,ranges:s,domain:g,normalize:R="row",showValues:W=!0,trackSize:_,rangeColors:U,color:T,height:J,width:O,size:D="md",tooltip:N=!0,tableView:X=!1,title:x,description:u,loading:r=!1,emptyState:Q,error:$=!1,errorState:Z,onRetry:v,actions:h,locale:y,plotLabel:C,valueLabel:S,targetLabel:G,format:d,onRowClick:V,className:w,...F}){let B=(0,ue.useUILabels)(),E=(0,m.useMemo)(()=>d??(i=>(0,z.formatAuto)(i,y)),[d,y]),H=(0,m.useMemo)(()=>l.format??(i=>(0,z.formatXValue)(i,y)),[l.format,y]),P=(0,m.useMemo)(()=>o.map((i,f)=>{let k=(0,I.readXValue)(i,l.key,f),L=(0,I.readNumber)(i,n),b=e?(0,I.readNumber)(i,e):null,j=s?i[s]:void 0,ee=Array.isArray(j)?j.map(p=>typeof p=="number"?p:Number(p)).filter(p=>Number.isFinite(p)):[];return{index:f,x:k,label:H(k,f),value:L,target:b,ranges:ee,formattedValue:L===null?"\u2014":E(L),formattedTarget:b===null?"\u2014":E(b),attainment:L===null||b===null||b===0?null:L/b,datum:i}}),[o,l.key,n,e,s,E,H]),a=(0,m.useMemo)(()=>{if(g)return g;if(R!=="shared")return null;let i=P.reduce((f,k)=>Math.max(f,k.value??0,k.target??0,...k.ranges),0);return(0,K.niceDomain)(0,i,5)},[g,R,P]),c=J??Math.max(72,P.length*34+(a?30:12)),Y=(0,m.useMemo)(()=>[{key:n,label:S??B.chartValue},...e?[{key:e,label:G??B.chartTarget}]:[]],[n,e,S,G,B.chartValue,B.chartTarget]),A=T??(0,de.getSeriesColor)(0);return(0,t.jsx)(me.ChartContainer,{title:x,description:u,height:c,width:O,size:D,loading:r,empty:P.length===0,emptyState:Q,error:$,errorState:Z,onRetry:v,actions:h,tableView:X,table:X?(0,t.jsx)(ce.ChartTableView,{data:o,series:Y,xKey:l.key,xLabel:l.label??l.key,formatX:H,formatValue:E,caption:typeof x=="string"?x:void 0}):void 0,className:w,...F,children:({width:i})=>(0,t.jsx)(Be,{width:i,height:c,rows:P,x:l,size:D,sharedDomain:a,showValues:W,trackSize:_,rangeColors:U,color:A,tooltip:N,plotLabel:C,formatValue:E,locale:y,onRowClick:V})})}0&&(module.exports={BulletChart});
1
+ "use strict";"use client";var ne=Object.defineProperty;var pe=Object.getOwnPropertyDescriptor;var ye=Object.getOwnPropertyNames;var Ce=Object.prototype.hasOwnProperty;var ke=(i,l)=>{for(var a in l)ne(i,a,{get:l[a],enumerable:!0})},xe=(i,l,a,e)=>{if(l&&typeof l=="object"||typeof l=="function")for(let s of ye(l))!Ce.call(i,s)&&s!==a&&ne(i,s,{get:()=>l[s],enumerable:!(e=pe(l,s))||e.enumerable});return i};var ve=i=>xe(ne({},"__esModule",{value:!0}),i);var Le={};ke(Le,{BulletChart:()=>Ee});module.exports=ve(Le);var m=require("react"),Q=require("../../lib/i18n.cjs"),ae=require("../chart/ChartAxis.cjs"),me=require("../chart/ChartContainer.cjs"),ce=require("../chart/ChartTableView.cjs"),ge=require("../chart/ChartTooltip.cjs"),de=require("../chart/palette.cjs"),U=require("../chart/utils/data.cjs"),I=require("../chart/utils/format.cjs"),he=require("../chart/utils/keyboard.cjs"),re=require("../chart/utils/path.cjs"),A=require("../chart/utils/scales.cjs"),le=require("../chart/utils/text.cjs"),O=require("../chart/utils/ticks.cjs"),fe=require("../chart/utils/touch.cjs"),n=require("react/jsx-runtime"),Re=22,Te=.42,se=3,ue=8,Ne=12,Se=["fill-gray-300 dark:fill-gray-500","fill-gray-200 dark:fill-gray-600","fill-gray-100 dark:fill-gray-700","fill-gray-50 dark:fill-gray-800"],Ve=(0,m.memo)(function({rows:l,color:a}){return(0,n.jsx)("g",{children:l.map(e=>(0,n.jsxs)("g",{children:[e.bands.map(s=>(0,n.jsx)("path",{d:s.d,className:s.className,fill:s.fill},s.key)),e.measure?(0,n.jsx)("path",{d:e.measure,fill:a}):null,e.target?(0,n.jsx)("line",{x1:e.target.x,y1:e.target.y1,x2:e.target.x,y2:e.target.y2,strokeWidth:2,strokeLinecap:"round",className:"stroke-gray-900 dark:stroke-white"}):null,e.label?(0,n.jsx)("text",{x:e.label.x,y:e.label.y,dominantBaseline:"middle",className:"fill-gray-700 text-[11px] font-medium [font-variant-numeric:tabular-nums] dark:fill-gray-200",children:e.label.text}):null]},e.key))})});function Be({width:i,height:l,rows:a,x:e,size:s,sharedDomain:g,showValues:N,trackSize:D,rangeColors:_,color:w,tooltip:S,plotLabel:Z,formatValue:F,locale:Y,onRowClick:V}){let[M,y]=(0,m.useState)(null),u=M!==null&&M<a.length?M:null,r=(0,m.useMemo)(()=>{let h=a.map(t=>t.label),G=N?a.map(t=>t.formattedValue):[],b={top:6,right:N?(0,le.widestLabel)(G)+ue*2:8,bottom:g?26+(e.label?16:0):6,left:e.hidden?8:e.height??(0,le.widestLabel)(h)+Ne},B=Math.max(0,i-b.left-b.right),H=Math.max(0,l-b.top-b.bottom),d=(0,A.createBandScale)(a.map((t,c)=>c),[0,H],{paddingInner:.34}),E=Math.min(D??Re,d.bandwidth),j=Math.max(3,E*Te),q=_??Se,k=_!==void 0,X=a.map((t,c)=>{let W=Math.max(0,t.value??0,t.target??0,...t.ranges.length>0?t.ranges:[0]),P=g??(t.ranges.length>0?[0,W]:(0,O.niceDomain)(0,W,4)),x=(0,A.createLinearScale)(P,[0,B]),o=d(c)+(d.bandwidth-E)/2,v=o+E/2,R=t.ranges.length>0?[...t.ranges].sort((z,f)=>z-f):[P[1]],p=P[0],T=R.map((z,f)=>{let oe=x(p),be=x(Math.max(p,z));p=z;let ie=q[Math.min(f,q.length-1)];return{key:`${c}-${f}`,d:(0,re.buildBarPath)({x:oe,y:o,width:Math.max(0,be-oe),height:E,radius:0}),className:k?void 0:ie,fill:k?ie:void 0}}),J=t.value===null?null:(0,re.buildBarPath)({x:x(P[0]),y:v-j/2,width:Math.max(0,x(t.value)-x(P[0])),height:j,radius:2,round:"right"});return{key:`${c}`,bands:T,measure:J,target:t.target===null?null:{x:x(t.target),y1:o-se,y2:o+E+se},label:N?{x:B+ue,y:v,text:t.formattedValue}:null,top:d(c),height:d.bandwidth}}),L=e.hidden?[]:a.map((t,c)=>({value:t.x,offset:d.center(c),label:t.label})),K=g?(0,O.niceTicks)(g[0],g[1],5).map(t=>({value:t,offset:(0,A.createLinearScale)(g,[0,B])(t),label:F(t)})):[];return{margin:b,innerWidth:B,innerHeight:H,band:d,rendered:X,categoryTicks:L,valueTicks:K,centers:a.map((t,c)=>d.center(c))}},[a,e,i,l,g,N,D,_,F]),ee=(0,m.useCallback)(h=>{if(S===!1||a.length===0)return;let G=h.currentTarget.getBoundingClientRect(),b=h.clientY-G.top-r.margin.top;y((0,A.nearestIndex)(r.centers,b))},[S,a.length,r.margin.top,r.centers]),$=(0,m.useCallback)(()=>{!V||u===null||V(a[u])},[V,u,a]),te=(0,m.useCallback)(h=>(0,he.handleChartKeyDown)(h,{count:a.length,current:u,axis:"y",onMove:y,pick:V?$:null}),[a.length,u,V,$]),C=u===null?null:a[u];return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("svg",{width:i,height:l,role:"img","aria-label":Z??a.map(h=>h.label).join(", "),tabIndex:0,className:`${fe.CHART_TOUCH} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:ee,onPointerLeave:()=>y(null),onKeyDown:te,onBlur:()=>y(null),onClick:$,children:[(0,n.jsxs)("g",{transform:`translate(${r.margin.left}, ${r.margin.top})`,children:[u!==null&&r.rendered[u]?(0,n.jsx)("rect",{x:-4,y:r.rendered[u].top,width:r.innerWidth+8,height:r.rendered[u].height,rx:4,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,(0,n.jsx)(Ve,{rows:r.rendered,color:w})]}),(0,n.jsx)("g",{transform:`translate(${r.margin.left}, ${r.margin.top})`,children:e.hidden?null:(0,n.jsx)(ae.ChartAxis,{orientation:"left",ticks:r.categoryTicks,length:r.innerHeight,showLine:!1,tickSize:0,size:s})}),g?(0,n.jsx)("g",{transform:`translate(${r.margin.left}, ${r.margin.top+r.innerHeight})`,children:(0,n.jsx)(ae.ChartAxis,{orientation:"bottom",ticks:r.valueTicks,length:r.innerWidth,label:e.label,size:s})}):null]}),C&&u!==null&&S!==!1?(0,n.jsx)(ge.ChartTooltip,{x:r.margin.left+r.innerWidth/2,y:r.margin.top+r.centers[u],containerWidth:i,children:typeof S=="function"?S(C):(0,n.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,n.jsx)("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:C.label}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{className:"h-0.5 w-3 shrink-0 rounded-full",style:{backgroundColor:w},"aria-hidden":"true"}),(0,n.jsx)("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:C.formattedValue}),C.attainment!==null?(0,n.jsx)("span",{className:"text-gray-500 [font-variant-numeric:tabular-nums] dark:text-gray-400",children:(0,I.formatPercent)(C.attainment,{locale:Y})}):null]})]})}):null]})}function Ee({data:i,x:l,value:a,target:e,ranges:s,domain:g,normalize:N="row",showValues:D=!0,trackSize:_,rangeColors:w,color:S,height:Z,width:F,size:Y="md",tooltip:V=!0,tableView:M=!1,title:y,description:u,loading:r=!1,emptyState:ee,error:$=!1,errorState:te,onRetry:C,actions:h,locale:G,plotLabel:b,valueLabel:B,targetLabel:H,format:d,onRowClick:E,className:j,...q}){let k=(0,Q.useUILocale)(G),X=(0,Q.useUILabels)(),L=(0,m.useMemo)(()=>d??(o=>(0,I.formatAuto)(o,k)),[d,k]),K=(0,m.useMemo)(()=>l.format??(o=>(0,I.formatXValue)(o,k)),[l.format,k]),t=(0,m.useMemo)(()=>i.map((o,v)=>{let R=(0,U.readXValue)(o,l.key,v),p=(0,U.readNumber)(o,a),T=e?(0,U.readNumber)(o,e):null,J=s?o[s]:void 0,z=Array.isArray(J)?J.map(f=>typeof f=="number"?f:Number(f)).filter(f=>Number.isFinite(f)):[];return{index:v,x:R,label:K(R,v),value:p,target:T,ranges:z,formattedValue:p===null?"\u2014":L(p),formattedTarget:T===null?"\u2014":L(T),attainment:p===null||T===null||T===0?null:p/T,datum:o}}),[i,l.key,a,e,s,L,K]),c=(0,m.useMemo)(()=>{if(g)return g;if(N!=="shared")return null;let o=t.reduce((v,R)=>Math.max(v,R.value??0,R.target??0,...R.ranges),0);return(0,O.niceDomain)(0,o,5)},[g,N,t]),W=Z??Math.max(72,t.length*34+(c?30:12)),P=(0,m.useMemo)(()=>[{key:a,label:B??X.chartValue},...e?[{key:e,label:H??X.chartTarget}]:[]],[a,e,B,H,X.chartValue,X.chartTarget]),x=S??(0,de.getSeriesColor)(0);return(0,n.jsx)(me.ChartContainer,{title:y,description:u,height:W,width:F,size:Y,loading:r,empty:t.length===0,emptyState:ee,error:$,errorState:te,onRetry:C,actions:h,tableView:M,table:M?(0,n.jsx)(ce.ChartTableView,{data:i,series:P,xKey:l.key,xLabel:l.label??l.key,formatX:K,formatValue:L,caption:typeof y=="string"?y:void 0}):void 0,className:j,...q,children:({width:o})=>(0,n.jsx)(Be,{width:o,height:W,rows:t,x:l,size:Y,sharedDomain:c,showValues:D,trackSize:_,rangeColors:w,color:x,tooltip:V,plotLabel:b,formatValue:L,locale:k,onRowClick:E})})}0&&(module.exports={BulletChart});
@@ -1 +1 @@
1
- "use client";import{memo as me,useCallback as Q,useMemo as M,useState as ce}from"react";import{useUILabels as ge}from"../../lib/i18n.js";import{ChartAxis as te}from"../chart/ChartAxis.js";import{ChartContainer as de}from"../chart/ChartContainer.js";import{ChartTableView as he}from"../chart/ChartTableView.js";import{ChartTooltip as fe}from"../chart/ChartTooltip.js";import{getSeriesColor as be}from"../chart/palette.js";import{readNumber as ne,readXValue as pe}from"../chart/utils/data.js";import{formatAuto as ye,formatPercent as Ce,formatXValue as ke}from"../chart/utils/format.js";import{handleChartKeyDown as xe}from"../chart/utils/keyboard.js";import{buildBarPath as ae}from"../chart/utils/path.js";import{createBandScale as ve,createLinearScale as re,nearestIndex as Re}from"../chart/utils/scales.js";import{widestLabel as le}from"../chart/utils/text.js";import{niceDomain as se,niceTicks as Te}from"../chart/utils/ticks.js";import{CHART_TOUCH as Ne}from"../chart/utils/touch.js";import{Fragment as Le,jsx as l,jsxs as X}from"react/jsx-runtime";var Se=22,Ve=.42,ie=3,oe=8,Be=12,Ee=["fill-gray-300 dark:fill-gray-500","fill-gray-200 dark:fill-gray-600","fill-gray-100 dark:fill-gray-700","fill-gray-50 dark:fill-gray-800"],Pe=me(function({rows:o,color:a}){return l("g",{children:o.map(e=>X("g",{children:[e.bands.map(m=>l("path",{d:m.d,className:m.className,fill:m.fill},m.key)),e.measure?l("path",{d:e.measure,fill:a}):null,e.target?l("line",{x1:e.target.x,y1:e.target.y1,x2:e.target.x,y2:e.target.y2,strokeWidth:2,strokeLinecap:"round",className:"stroke-gray-900 dark:stroke-white"}):null,e.label?l("text",{x:e.label.x,y:e.label.y,dominantBaseline:"middle",className:"fill-gray-700 text-[11px] font-medium [font-variant-numeric:tabular-nums] dark:fill-gray-200",children:e.label.text}):null]},e.key))})});function Ae({width:b,height:o,rows:a,x:e,size:m,sharedDomain:u,showValues:v,trackSize:H,rangeColors:z,color:I,tooltip:R,plotLabel:Y,formatValue:K,locale:W,onRowClick:T}){let[L,k]=ce(null),i=L!==null&&L<a.length?L:null,n=M(()=>{let g=a.map(t=>t.label),p=v?a.map(t=>t.formattedValue):[],y={top:6,right:v?le(p)+oe*2:8,bottom:u?26+(e.label?16:0):6,left:e.hidden?8:e.height??le(g)+Be},N=Math.max(0,b-y.left-y.right),$=Math.max(0,o-y.top-y.bottom),c=ve(a.map((t,s)=>s),[0,$],{paddingInner:.34}),S=Math.min(H??Se,c.bandwidth),U=Math.max(3,S*Ve),O=z??Ee,V=z!==void 0,B=a.map((t,s)=>{let D=Math.max(0,t.value??0,t.target??0,...t.ranges.length>0?t.ranges:[0]),P=u??(t.ranges.length>0?[0,D]:se(0,D,4)),r=re(P,[0,N]),d=c(s)+(c.bandwidth-S)/2,C=d+S/2,A=t.ranges.length>0?[...t.ranges].sort((f,F)=>f-F):[P[1]],h=P[0],w=A.map((f,F)=>{let Z=r(h),ue=r(Math.max(h,f));h=f;let ee=O[Math.min(F,O.length-1)];return{key:`${s}-${F}`,d:ae({x:Z,y:d,width:Math.max(0,ue-Z),height:S,radius:0}),className:V?void 0:ee,fill:V?ee:void 0}}),J=t.value===null?null:ae({x:r(P[0]),y:C-U/2,width:Math.max(0,r(t.value)-r(P[0])),height:U,radius:2,round:"right"});return{key:`${s}`,bands:w,measure:J,target:t.target===null?null:{x:r(t.target),y1:d-ie,y2:d+S+ie},label:v?{x:N+oe,y:C,text:t.formattedValue}:null,top:c(s),height:c.bandwidth}}),G=e.hidden?[]:a.map((t,s)=>({value:t.x,offset:c.center(s),label:t.label})),E=u?Te(u[0],u[1],5).map(t=>({value:t,offset:re(u,[0,N])(t),label:K(t)})):[];return{margin:y,innerWidth:N,innerHeight:$,band:c,rendered:B,categoryTicks:G,valueTicks:E,centers:a.map((t,s)=>c.center(s))}},[a,e,b,o,u,v,H,z,K]),j=Q(g=>{if(R===!1||a.length===0)return;let p=g.currentTarget.getBoundingClientRect(),y=g.clientY-p.top-n.margin.top;k(Re(n.centers,y))},[R,a.length,n.margin.top,n.centers]),_=Q(()=>{!T||i===null||T(a[i])},[T,i,a]),q=Q(g=>xe(g,{count:a.length,current:i,axis:"y",onMove:k,pick:T?_:null}),[a.length,i,T,_]),x=i===null?null:a[i];return X(Le,{children:[X("svg",{width:b,height:o,role:"img","aria-label":Y??a.map(g=>g.label).join(", "),tabIndex:0,className:`${Ne} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:j,onPointerLeave:()=>k(null),onKeyDown:q,onBlur:()=>k(null),onClick:_,children:[X("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:[i!==null&&n.rendered[i]?l("rect",{x:-4,y:n.rendered[i].top,width:n.innerWidth+8,height:n.rendered[i].height,rx:4,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,l(Pe,{rows:n.rendered,color:I})]}),l("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:e.hidden?null:l(te,{orientation:"left",ticks:n.categoryTicks,length:n.innerHeight,showLine:!1,tickSize:0,size:m})}),u?l("g",{transform:`translate(${n.margin.left}, ${n.margin.top+n.innerHeight})`,children:l(te,{orientation:"bottom",ticks:n.valueTicks,length:n.innerWidth,label:e.label,size:m})}):null]}),x&&i!==null&&R!==!1?l(fe,{x:n.margin.left+n.innerWidth/2,y:n.margin.top+n.centers[i],containerWidth:b,children:typeof R=="function"?R(x):X("div",{className:"flex flex-col gap-1",children:[l("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:x.label}),X("div",{className:"flex items-center gap-2",children:[l("span",{className:"h-0.5 w-3 shrink-0 rounded-full",style:{backgroundColor:I},"aria-hidden":"true"}),l("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:x.formattedValue}),x.attainment!==null?l("span",{className:"text-gray-500 [font-variant-numeric:tabular-nums] dark:text-gray-400",children:Ce(x.attainment,{locale:W})}):null]})]})}):null]})}function Ye({data:b,x:o,value:a,target:e,ranges:m,domain:u,normalize:v="row",showValues:H=!0,trackSize:z,rangeColors:I,color:R,height:Y,width:K,size:W="md",tooltip:T=!0,tableView:L=!1,title:k,description:i,loading:n=!1,emptyState:j,error:_=!1,errorState:q,onRetry:x,actions:g,locale:p,plotLabel:y,valueLabel:N,targetLabel:$,format:c,onRowClick:S,className:U,...O}){let V=ge(),B=M(()=>c??(r=>ye(r,p)),[c,p]),G=M(()=>o.format??(r=>ke(r,p)),[o.format,p]),E=M(()=>b.map((r,d)=>{let C=pe(r,o.key,d),A=ne(r,a),h=e?ne(r,e):null,w=m?r[m]:void 0,J=Array.isArray(w)?w.map(f=>typeof f=="number"?f:Number(f)).filter(f=>Number.isFinite(f)):[];return{index:d,x:C,label:G(C,d),value:A,target:h,ranges:J,formattedValue:A===null?"\u2014":B(A),formattedTarget:h===null?"\u2014":B(h),attainment:A===null||h===null||h===0?null:A/h,datum:r}}),[b,o.key,a,e,m,B,G]),t=M(()=>{if(u)return u;if(v!=="shared")return null;let r=E.reduce((d,C)=>Math.max(d,C.value??0,C.target??0,...C.ranges),0);return se(0,r,5)},[u,v,E]),s=Y??Math.max(72,E.length*34+(t?30:12)),D=M(()=>[{key:a,label:N??V.chartValue},...e?[{key:e,label:$??V.chartTarget}]:[]],[a,e,N,$,V.chartValue,V.chartTarget]),P=R??be(0);return l(de,{title:k,description:i,height:s,width:K,size:W,loading:n,empty:E.length===0,emptyState:j,error:_,errorState:q,onRetry:x,actions:g,tableView:L,table:L?l(he,{data:b,series:D,xKey:o.key,xLabel:o.label??o.key,formatX:G,formatValue:B,caption:typeof k=="string"?k:void 0}):void 0,className:U,...O,children:({width:r})=>l(Ae,{width:r,height:s,rows:E,x:o,size:W,sharedDomain:t,showValues:H,trackSize:z,rangeColors:I,color:P,tooltip:T,plotLabel:y,formatValue:B,locale:p,onRowClick:S})})}export{Ye as BulletChart};
1
+ "use client";import{memo as me,useCallback as Q,useMemo as X,useState as ce}from"react";import{useUILabels as ge,useUILocale as de}from"../../lib/i18n.js";import{ChartAxis as te}from"../chart/ChartAxis.js";import{ChartContainer as he}from"../chart/ChartContainer.js";import{ChartTableView as fe}from"../chart/ChartTableView.js";import{ChartTooltip as be}from"../chart/ChartTooltip.js";import{getSeriesColor as pe}from"../chart/palette.js";import{readNumber as ne,readXValue as ye}from"../chart/utils/data.js";import{formatAuto as Ce,formatPercent as ke,formatXValue as xe}from"../chart/utils/format.js";import{handleChartKeyDown as ve}from"../chart/utils/keyboard.js";import{buildBarPath as ae}from"../chart/utils/path.js";import{createBandScale as Re,createLinearScale as re,nearestIndex as Te}from"../chart/utils/scales.js";import{widestLabel as le}from"../chart/utils/text.js";import{niceDomain as se,niceTicks as Ne}from"../chart/utils/ticks.js";import{CHART_TOUCH as Se}from"../chart/utils/touch.js";import{Fragment as Me,jsx as r,jsxs as z}from"react/jsx-runtime";var Ve=22,Be=.42,oe=3,ie=8,Ee=12,Le=["fill-gray-300 dark:fill-gray-500","fill-gray-200 dark:fill-gray-600","fill-gray-100 dark:fill-gray-700","fill-gray-50 dark:fill-gray-800"],Pe=me(function({rows:i,color:a}){return r("g",{children:i.map(t=>z("g",{children:[t.bands.map(m=>r("path",{d:m.d,className:m.className,fill:m.fill},m.key)),t.measure?r("path",{d:t.measure,fill:a}):null,t.target?r("line",{x1:t.target.x,y1:t.target.y1,x2:t.target.x,y2:t.target.y2,strokeWidth:2,strokeLinecap:"round",className:"stroke-gray-900 dark:stroke-white"}):null,t.label?r("text",{x:t.label.x,y:t.label.y,dominantBaseline:"middle",className:"fill-gray-700 text-[11px] font-medium [font-variant-numeric:tabular-nums] dark:fill-gray-200",children:t.label.text}):null]},t.key))})});function Ae({width:h,height:i,rows:a,x:t,size:m,sharedDomain:u,showValues:T,trackSize:W,rangeColors:I,color:U,tooltip:N,plotLabel:j,formatValue:O,locale:D,onRowClick:S}){let[P,p]=ce(null),o=P!==null&&P<a.length?P:null,n=X(()=>{let g=a.map(e=>e.label),$=T?a.map(e=>e.formattedValue):[],f={top:6,right:T?le($)+ie*2:8,bottom:u?26+(t.label?16:0):6,left:t.hidden?8:t.height??le(g)+Ee},V=Math.max(0,h-f.left-f.right),G=Math.max(0,i-f.top-f.bottom),c=Re(a.map((e,s)=>s),[0,G],{paddingInner:.34}),B=Math.min(W??Ve,c.bandwidth),w=Math.max(3,B*Be),F=I??Le,C=I!==void 0,A=a.map((e,s)=>{let K=Math.max(0,e.value??0,e.target??0,...e.ranges.length>0?e.ranges:[0]),L=u??(e.ranges.length>0?[0,K]:se(0,K,4)),k=re(L,[0,V]),l=c(s)+(c.bandwidth-B)/2,x=l+B/2,v=e.ranges.length>0?[...e.ranges].sort((M,d)=>M-d):[L[1]],b=L[0],R=v.map((M,d)=>{let Z=k(b),ue=k(Math.max(b,M));b=M;let ee=F[Math.min(d,F.length-1)];return{key:`${s}-${d}`,d:ae({x:Z,y:l,width:Math.max(0,ue-Z),height:B,radius:0}),className:C?void 0:ee,fill:C?ee:void 0}}),Y=e.value===null?null:ae({x:k(L[0]),y:x-w/2,width:Math.max(0,k(e.value)-k(L[0])),height:w,radius:2,round:"right"});return{key:`${s}`,bands:R,measure:Y,target:e.target===null?null:{x:k(e.target),y1:l-oe,y2:l+B+oe},label:T?{x:V+ie,y:x,text:e.formattedValue}:null,top:c(s),height:c.bandwidth}}),E=t.hidden?[]:a.map((e,s)=>({value:e.x,offset:c.center(s),label:e.label})),H=u?Ne(u[0],u[1],5).map(e=>({value:e,offset:re(u,[0,V])(e),label:O(e)})):[];return{margin:f,innerWidth:V,innerHeight:G,band:c,rendered:A,categoryTicks:E,valueTicks:H,centers:a.map((e,s)=>c.center(s))}},[a,t,h,i,u,T,W,I,O]),q=Q(g=>{if(N===!1||a.length===0)return;let $=g.currentTarget.getBoundingClientRect(),f=g.clientY-$.top-n.margin.top;p(Te(n.centers,f))},[N,a.length,n.margin.top,n.centers]),_=Q(()=>{!S||o===null||S(a[o])},[S,o,a]),J=Q(g=>ve(g,{count:a.length,current:o,axis:"y",onMove:p,pick:S?_:null}),[a.length,o,S,_]),y=o===null?null:a[o];return z(Me,{children:[z("svg",{width:h,height:i,role:"img","aria-label":j??a.map(g=>g.label).join(", "),tabIndex:0,className:`${Se} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:q,onPointerLeave:()=>p(null),onKeyDown:J,onBlur:()=>p(null),onClick:_,children:[z("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:[o!==null&&n.rendered[o]?r("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,r(Pe,{rows:n.rendered,color:U})]}),r("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:t.hidden?null:r(te,{orientation:"left",ticks:n.categoryTicks,length:n.innerHeight,showLine:!1,tickSize:0,size:m})}),u?r("g",{transform:`translate(${n.margin.left}, ${n.margin.top+n.innerHeight})`,children:r(te,{orientation:"bottom",ticks:n.valueTicks,length:n.innerWidth,label:t.label,size:m})}):null]}),y&&o!==null&&N!==!1?r(be,{x:n.margin.left+n.innerWidth/2,y:n.margin.top+n.centers[o],containerWidth:h,children:typeof N=="function"?N(y):z("div",{className:"flex flex-col gap-1",children:[r("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:y.label}),z("div",{className:"flex items-center gap-2",children:[r("span",{className:"h-0.5 w-3 shrink-0 rounded-full",style:{backgroundColor:U},"aria-hidden":"true"}),r("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:y.formattedValue}),y.attainment!==null?r("span",{className:"text-gray-500 [font-variant-numeric:tabular-nums] dark:text-gray-400",children:ke(y.attainment,{locale:D})}):null]})]})}):null]})}function je({data:h,x:i,value:a,target:t,ranges:m,domain:u,normalize:T="row",showValues:W=!0,trackSize:I,rangeColors:U,color:N,height:j,width:O,size:D="md",tooltip:S=!0,tableView:P=!1,title:p,description:o,loading:n=!1,emptyState:q,error:_=!1,errorState:J,onRetry:y,actions:g,locale:$,plotLabel:f,valueLabel:V,targetLabel:G,format:c,onRowClick:B,className:w,...F}){let C=de($),A=ge(),E=X(()=>c??(l=>Ce(l,C)),[c,C]),H=X(()=>i.format??(l=>xe(l,C)),[i.format,C]),e=X(()=>h.map((l,x)=>{let v=ye(l,i.key,x),b=ne(l,a),R=t?ne(l,t):null,Y=m?l[m]:void 0,M=Array.isArray(Y)?Y.map(d=>typeof d=="number"?d:Number(d)).filter(d=>Number.isFinite(d)):[];return{index:x,x:v,label:H(v,x),value:b,target:R,ranges:M,formattedValue:b===null?"\u2014":E(b),formattedTarget:R===null?"\u2014":E(R),attainment:b===null||R===null||R===0?null:b/R,datum:l}}),[h,i.key,a,t,m,E,H]),s=X(()=>{if(u)return u;if(T!=="shared")return null;let l=e.reduce((x,v)=>Math.max(x,v.value??0,v.target??0,...v.ranges),0);return se(0,l,5)},[u,T,e]),K=j??Math.max(72,e.length*34+(s?30:12)),L=X(()=>[{key:a,label:V??A.chartValue},...t?[{key:t,label:G??A.chartTarget}]:[]],[a,t,V,G,A.chartValue,A.chartTarget]),k=N??pe(0);return r(he,{title:p,description:o,height:K,width:O,size:D,loading:n,empty:e.length===0,emptyState:q,error:_,errorState:J,onRetry:y,actions:g,tableView:P,table:P?r(fe,{data:h,series:L,xKey:i.key,xLabel:i.label??i.key,formatX:H,formatValue:E,caption:typeof p=="string"?p:void 0}):void 0,className:w,...F,children:({width:l})=>r(Ae,{width:l,height:K,rows:e,x:i,size:D,sharedDomain:s,showValues:W,trackSize:I,rangeColors:U,color:k,tooltip:S,plotLabel:f,formatValue:E,locale:C,onRowClick:B})})}export{je as BulletChart};
@@ -1 +1 @@
1
- "use strict";"use client";var se=Object.defineProperty;var Qe=Object.getOwnPropertyDescriptor;var Xe=Object.getOwnPropertyNames;var Ze=Object.prototype.hasOwnProperty;var et=(e,a)=>{for(var s in a)se(e,s,{get:a[s],enumerable:!0})},tt=(e,a,s,F)=>{if(a&&typeof a=="object"||typeof a=="function")for(let D of Xe(a))!Ze.call(e,D)&&D!==s&&se(e,D,{get:()=>a[D],enumerable:!(F=Qe(a,D))||F.enumerable});return e};var at=e=>tt(se({},"__esModule",{value:!0}),e);var yt={};et(yt,{Calendar:()=>ft});module.exports=at(yt);var l=require("react"),u=require("../../lib/cn.cjs"),we=require("../../lib/i18n.cjs"),n=require("react/jsx-runtime"),rt=10080*60*1e3;function g(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function V(e){return new Date(e.getFullYear(),e.getMonth(),1)}function T(e,a){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+a)}function v(e,a){return new Date(e.getFullYear(),e.getMonth()+a,1)}function de(e){return new Date(e.getFullYear(),e.getMonth()+1,0).getDate()}function N(e,a){return!e||!a?!1:e.getFullYear()===a.getFullYear()&&e.getMonth()===a.getMonth()&&e.getDate()===a.getDate()}function ie(e,a){return e.getFullYear()===a.getFullYear()&&e.getMonth()===a.getMonth()}function E(e,a){return e.getFullYear()*12+e.getMonth()-(a.getFullYear()*12+a.getMonth())}function J(e){let a=`${e.getMonth()+1}`.padStart(2,"0"),s=`${e.getDate()}`.padStart(2,"0");return`${e.getFullYear()}-${a}-${s}`}function nt(e){let a=g(e);a.setDate(a.getDate()-(a.getDay()+6)%7+3);let s=new Date(a.getFullYear(),0,4);return s.setDate(s.getDate()-(s.getDay()+6)%7+3),1+Math.round((a.getTime()-s.getTime())/rt)}function ve(e,a,s){return a&&e<g(a)?g(a):s&&e>g(s)?g(s):e}function ot(e,a,s){let F=V(e),D=(F.getDay()-a+7)%7,_=T(F,-D),j=s?6:Math.ceil((D+de(e))/7);return Array.from({length:j},(X,G)=>Array.from({length:7},(ce,L)=>T(_,G*7+L)))}function lt({className:e}){return(0,n.jsx)("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function st({className:e}){return(0,n.jsx)("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}var it={sm:{day:"h-7 w-7 text-xs",head:"h-7 w-7 text-[10px]",caption:"text-xs",nav:"h-6 w-6",icon:"h-3 w-3",padding:"p-2",gap:"gap-3",footer:"text-xs",select:"text-xs py-0.5 pl-1 pr-5"},md:{day:"h-9 w-9 text-sm",head:"h-9 w-9 text-xs",caption:"text-sm",nav:"h-7 w-7",icon:"h-4 w-4",padding:"p-3",gap:"gap-4",footer:"text-sm",select:"text-sm py-1 pl-1.5 pr-6"},lg:{day:"h-11 w-11 text-base",head:"h-11 w-11 text-sm",caption:"text-base",nav:"h-9 w-9",icon:"h-5 w-5",padding:"p-4",gap:"gap-5",footer:"text-sm",select:"text-base py-1.5 pl-2 pr-7"}},dt={primary:"bg-synertech-primary-600 text-synertech-on-primary hover:bg-synertech-primary-700",success:"bg-green-700 text-white hover:bg-green-800",warning:"bg-yellow-500 text-gray-900 hover:bg-yellow-600 dark:bg-yellow-400 dark:hover:bg-yellow-500",error:"bg-red-600 text-white hover:bg-red-700",info:"bg-cyan-700 text-white hover:bg-cyan-800",neutral:"bg-gray-700 text-white hover:bg-gray-800 dark:bg-gray-500 dark:hover:bg-gray-400"},ct={primary:"bg-synertech-primary-50 dark:bg-synertech-primary-900/30",success:"bg-green-50 dark:bg-green-900/30",warning:"bg-yellow-50 dark:bg-yellow-900/30",error:"bg-red-50 dark:bg-red-900/30",info:"bg-cyan-50 dark:bg-cyan-900/30",neutral:"bg-gray-100 dark:bg-gray-700/40"},ut={primary:"text-synertech-primary-900 dark:text-synertech-primary-100",success:"text-green-900 dark:text-green-100",warning:"text-yellow-900 dark:text-yellow-100",error:"text-red-900 dark:text-red-100",info:"text-cyan-900 dark:text-cyan-100",neutral:"text-gray-900 dark:text-gray-100"},gt={primary:"font-semibold text-synertech-primary-600 dark:text-synertech-primary-400",success:"font-semibold text-green-700 dark:text-green-400",warning:"font-semibold text-yellow-700 dark:text-yellow-400",error:"font-semibold text-red-600 dark:text-red-400",info:"font-semibold text-cyan-700 dark:text-cyan-400",neutral:"font-semibold text-gray-900 dark:text-gray-100"},z={primary:"focus-visible:ring-synertech-primary-500",success:"focus-visible:ring-green-500",warning:"focus-visible:ring-yellow-500",error:"focus-visible:ring-red-500",info:"focus-visible:ring-cyan-500",neutral:"focus-visible:ring-gray-500"};function Q(e,a){if(e==="multiple")return Array.isArray(a)?a.map(g):[];if(e==="range"){let s=a??null;return{from:s?.from?g(s.from):null,to:s?.to?g(s.to):null}}return a instanceof Date?g(a):null}function ke(e){return e?e instanceof Date?e:Array.isArray(e)?e[0]??null:e.from??e.to??null:null}function ft(e){let{mode:a="single",value:s,defaultValue:F,onChange:D,max:_,month:j,defaultMonth:X,onMonthChange:G,numberOfMonths:ce=1,weekStartsOn:L=0,locale:R,size:Ce="md",color:x="primary",minDate:k,maxDate:w,disabledDates:O,disabled:m=!1,showOutsideDays:Me=!0,showWeekNumbers:ue=!1,fixedWeeks:Se=!1,captionLayout:Z="label",fromYear:ge,toYear:fe,todayButton:ee=!1,clearButton:te=!1,footer:ye,bordered:Ne=!0,renderDay:me,labels:B,className:Fe,...Re}=e,I=(0,we.useUILabels)(),p=it[Ce],C=Math.max(1,ce),Y=(0,l.useMemo)(()=>g(new Date),[]),ae=s!==void 0,[Ye,Pe]=(0,l.useState)(()=>Q(a,F)),A=ae?Q(a,s):Ye,re=j!==void 0,[Te,Le]=(0,l.useState)(()=>V(X??ke(Q(a,F??s))??new Date)),f=re?V(j):Te,h=(0,l.useCallback)(t=>{let r=V(t);re||Le(r),G?.(r)},[re,G]),be=(0,l.useRef)(null),ne=(0,l.useRef)(!1),[W,U]=(0,l.useState)(()=>{let t=ke(Q(a,F??s)),r=V(X??j??t??new Date),c=t&&ie(t,r)?t:ie(g(new Date),r)?g(new Date):r;return ve(c,k,w)}),Ae=v(f,C-1),Ee=E(W,f)>=0&&E(W,Ae)<=0?W:f;(0,l.useEffect)(()=>{if(!ne.current)return;ne.current=!1,be.current?.querySelector(`[data-day="${J(W)}"]:not([data-outside])`)?.focus()},[W,f]);let P=(0,l.useCallback)(t=>{let r=ve(g(t),k,w);ne.current=!0,U(r);let c=v(f,C-1);E(r,f)<0?h(r):E(r,c)>0&&h(v(r,-(C-1)))},[f,C,k,w,h]),K=(0,l.useCallback)(t=>m||k&&t<g(k)||w&&t>g(w)?!0:typeof O=="function"?O(t):Array.isArray(O)?O.some(r=>N(r,t)):!1,[m,k,w,O]),[oe,pe]=(0,l.useState)(null),M=(0,l.useCallback)(t=>{ae||Pe(t),D?.(t)},[ae,D]),q=(0,l.useCallback)(t=>{let r=g(t);if(K(r))return;if(a==="multiple"){let i=A??[];if(i.some(o=>N(o,r))){M(i.filter(o=>!N(o,r)));return}if(_!==void 0&&i.length>=_)return;M([...i,r].sort((o,y)=>o.getTime()-y.getTime()));return}if(a==="range"){let i=A??{from:null,to:null};if(!i.from||i.to){M({from:r,to:null});return}M(r<i.from?{from:r,to:i.from}:{from:i.from,to:r});return}M(N(A,r)?null:r)},[a,A,_,M,K]),Be=(0,l.useCallback)(t=>{q(t),U(g(t)),E(t,f)<0?h(t):E(t,v(f,C-1))>0&&h(v(t,-(C-1)))},[q,f,C,h]),he=!m&&(!k||E(f,V(k))>0),De=!m&&(!w||E(v(f,C-1),V(w))<0),Ie=(0,l.useCallback)(()=>{h(v(f,-1))},[f,h]),We=(0,l.useCallback)(()=>{h(v(f,1))},[f,h]),ze=(0,l.useCallback)(t=>{if(m)return;let r=W;switch(t.key){case"ArrowLeft":t.preventDefault(),P(T(r,-1));break;case"ArrowRight":t.preventDefault(),P(T(r,1));break;case"ArrowUp":t.preventDefault(),P(T(r,-7));break;case"ArrowDown":t.preventDefault(),P(T(r,7));break;case"Home":t.preventDefault(),P(T(r,-((r.getDay()-L+7)%7)));break;case"End":t.preventDefault(),P(T(r,6-(r.getDay()-L+7)%7));break;case"PageUp":{t.preventDefault();let c=t.shiftKey?-12:-1,i=v(r,c),b=Math.min(r.getDate(),de(i));P(new Date(i.getFullYear(),i.getMonth(),b));break}case"PageDown":{t.preventDefault();let c=t.shiftKey?12:1,i=v(r,c),b=Math.min(r.getDate(),de(i));P(new Date(i.getFullYear(),i.getMonth(),b));break}default:break}},[m,W,P,L]),Ve=(0,l.useMemo)(()=>{let t=new Intl.DateTimeFormat(R,{weekday:"short"}),r=new Intl.DateTimeFormat(R,{weekday:"long"}),c=new Date(2024,0,7);return Array.from({length:7},(i,b)=>{let o=T(c,(L+b)%7);return{short:t.format(o),long:r.format(o)}})},[R,L]),Ke=(0,l.useMemo)(()=>{let t=new Intl.DateTimeFormat(R,{month:"long"});return Array.from({length:12},(r,c)=>t.format(new Date(2024,c,1)))},[R]),xe=(0,l.useMemo)(()=>new Intl.DateTimeFormat(R,{month:"long",year:"numeric"}),[R]),_e=(0,l.useMemo)(()=>new Intl.DateTimeFormat(R,{dateStyle:"full"}),[R]),je=(0,l.useMemo)(()=>{if(Z!=="dropdown")return[];let t=Y.getFullYear(),r=ge??k?.getFullYear()??t-100,c=fe??w?.getFullYear()??t+10;return c<r?[r]:Array.from({length:c-r+1},(i,b)=>r+b)},[Z,ge,fe,k,w,Y]),S=a==="range"?A:null,Oe=S&&S.from&&!S.to&&oe&&oe>S.from?oe:null,$=S?.to??Oe,$e=(0,l.useCallback)((t,r)=>{let c=!ie(t,r),i=K(t),b=!1,o=!1,y=!1,d=!1;return a==="multiple"?b=(A??[]).some(H=>N(H,t)):a==="range"?(o=N(S?.from,t),y=N($,t),b=o||y,d=!!(S?.from&&$&&t>S.from&&t<$)):b=N(A,t),{selected:b,today:N(t,Y),outside:c,disabled:i,rangeStart:o,rangeEnd:y,inRange:d}},[a,A,S,$,K,Y]),He=t=>{let r=v(f,t),c=ot(r,L,Se),i=t===0,b=t===C-1;return(0,n.jsxs)("div",{className:"flex flex-col",children:[(0,n.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,n.jsx)("button",{type:"button",onClick:Ie,disabled:!he,"aria-label":B?.previousMonth??I.calendarPreviousMonth,className:(0,u.cn)("inline-flex items-center justify-center rounded-md transition-colors","text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 dark:focus-visible:ring-offset-gray-900",z[x],p.nav,!he&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent",!i&&"invisible"),children:(0,n.jsx)(lt,{className:p.icon})}),Z==="dropdown"?(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("select",{"aria-label":B?.monthSelect??I.calendarMonth,value:r.getMonth(),disabled:m,onChange:o=>h(new Date(r.getFullYear(),Number(o.target.value)-t,1)),className:(0,u.cn)("rounded-md border border-gray-300 bg-white font-medium text-gray-900","dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100","focus:outline-none focus-visible:ring-2",z[x],p.select,m&&"cursor-not-allowed opacity-50"),children:Ke.map((o,y)=>(0,n.jsx)("option",{value:y,children:o},o))}),(0,n.jsx)("select",{"aria-label":B?.yearSelect??I.calendarYear,value:r.getFullYear(),disabled:m,onChange:o=>h(new Date(Number(o.target.value),r.getMonth()-t,1)),className:(0,u.cn)("rounded-md border border-gray-300 bg-white font-medium text-gray-900","dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100","focus:outline-none focus-visible:ring-2",z[x],p.select,m&&"cursor-not-allowed opacity-50"),children:je.map(o=>(0,n.jsx)("option",{value:o,children:o},o))})]}):(0,n.jsx)("div",{"aria-live":"polite",className:(0,u.cn)("font-semibold text-gray-900 dark:text-gray-100",p.caption),children:xe.format(r)}),(0,n.jsx)("button",{type:"button",onClick:We,disabled:!De,"aria-label":B?.nextMonth??I.calendarNextMonth,className:(0,u.cn)("inline-flex items-center justify-center rounded-md transition-colors","text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 dark:focus-visible:ring-offset-gray-900",z[x],p.nav,!De&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent",!b&&"invisible"),children:(0,n.jsx)(st,{className:p.icon})})]}),(0,n.jsxs)("table",{role:"grid","aria-label":xe.format(r),onKeyDown:ze,className:"border-collapse",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[ue&&(0,n.jsxs)("th",{scope:"col",className:(0,u.cn)("font-normal text-gray-500 dark:text-gray-400",p.head),children:[(0,n.jsx)("span",{className:"sr-only",children:B?.weekNumber??I.calendarWeekNumber}),(0,n.jsx)("span",{"aria-hidden":"true",children:"#"})]}),Ve.map(o=>(0,n.jsx)("th",{scope:"col",abbr:o.long,className:(0,u.cn)("font-medium uppercase text-gray-500 dark:text-gray-400",p.head),children:o.short},o.long))]})}),(0,n.jsx)("tbody",{children:c.map(o=>(0,n.jsxs)("tr",{children:[ue&&(0,n.jsx)("td",{className:(0,u.cn)("text-center align-middle text-gray-500 dark:text-gray-400",p.head),children:nt(o[0])}),o.map(y=>{let d=$e(y,r),H=J(y);if(d.outside&&!Me)return(0,n.jsx)("td",{className:"p-0"},H);let Je=N(y,Ee)&&!d.outside,le=d.inRange||d.rangeStart&&!!$||d.rangeEnd&&!!S?.from;return(0,n.jsx)("td",{role:"presentation",className:(0,u.cn)("p-0",le&&ct[x],le&&d.rangeStart&&"rounded-l-full",le&&d.rangeEnd&&"rounded-r-full"),children:(0,n.jsx)("button",{type:"button","data-day":H,"data-selected":d.selected||void 0,"data-today":d.today||void 0,"data-outside":d.outside||void 0,role:"gridcell",tabIndex:Je?0:-1,disabled:m,"aria-selected":d.selected,"aria-disabled":d.disabled||void 0,"aria-current":d.today?"date":void 0,"aria-label":_e.format(y),onClick:()=>{d.disabled||Be(y)},onMouseEnter:()=>a==="range"&&pe(g(y)),onMouseLeave:()=>a==="range"&&pe(null),onFocus:()=>U(g(y)),className:(0,u.cn)("inline-flex items-center justify-center rounded-full transition-colors","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 dark:focus-visible:ring-offset-gray-900",z[x],p.day,d.selected?dt[x]:d.inRange?(0,u.cn)(ut[x],"hover:bg-gray-200/60 dark:hover:bg-gray-600/60"):d.today?(0,u.cn)(gt[x],"hover:bg-gray-100 dark:hover:bg-gray-700"):(0,u.cn)("text-gray-900 dark:text-gray-100","hover:bg-gray-100 dark:hover:bg-gray-700"),d.outside&&!d.selected&&"text-gray-500 dark:text-gray-400",d.disabled&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent"),children:me?me(y,d):y.getDate()})},H)})]},J(o[0])))})]})]},J(r))},Ge=(0,l.useCallback)(()=>{h(Y),U(Y),K(Y)||q(Y)},[Y,h,K,q]),Ue=(0,l.useCallback)(()=>{M(a==="multiple"?[]:a==="range"?{from:null,to:null}:null)},[a,M]),qe=!!ye||ee||te;return(0,n.jsxs)("div",{ref:be,className:(0,u.cn)("inline-block bg-white dark:bg-gray-900",Ne&&"rounded-lg border border-gray-200 shadow-sm dark:border-gray-700",p.padding,m&&"opacity-60",Fe),...Re,children:[(0,n.jsx)("div",{className:(0,u.cn)("flex flex-wrap",p.gap),children:Array.from({length:C},(t,r)=>He(r))}),qe&&(0,n.jsxs)("div",{className:(0,u.cn)("mt-3 flex items-center justify-between gap-2 border-t border-gray-200 pt-3 dark:border-gray-700",p.footer),children:[(0,n.jsx)("div",{className:"text-gray-600 dark:text-gray-400",children:ye}),(ee||te)&&(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[ee&&(0,n.jsx)("button",{type:"button",onClick:Ge,disabled:m,className:(0,u.cn)("rounded-md px-2 py-1 font-medium transition-colors","text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2",z[x],m&&"cursor-not-allowed opacity-50"),children:B?.today??I.calendarToday}),te&&(0,n.jsx)("button",{type:"button",onClick:Ue,disabled:m,className:(0,u.cn)("rounded-md px-2 py-1 font-medium transition-colors","text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2",z[x],m&&"cursor-not-allowed opacity-50"),children:B?.clear??I.calendarClear})]})]})]})}0&&(module.exports={Calendar});
1
+ "use strict";"use client";var ue=Object.defineProperty;var lt=Object.getOwnPropertyDescriptor;var st=Object.getOwnPropertyNames;var it=Object.prototype.hasOwnProperty;var dt=(e,t)=>{for(var s in t)ue(e,s,{get:t[s],enumerable:!0})},ct=(e,t,s,P)=>{if(t&&typeof t=="object"||typeof t=="function")for(let v of st(t))!it.call(e,v)&&v!==s&&ue(e,v,{get:()=>t[v],enumerable:!(P=lt(t,v))||P.enumerable});return e};var ut=e=>ct(ue({},"__esModule",{value:!0}),e);var wt={};dt(wt,{Calendar:()=>Ct});module.exports=ut(wt);var l=require("react"),u=require("../../lib/cn.cjs"),Z=require("../../lib/i18n.cjs"),n=require("react/jsx-runtime"),gt=10080*60*1e3;function U(e){return e instanceof Date&&!Number.isNaN(e.getTime())}function H(e){return U(e)?e:void 0}function y(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function z(e){return new Date(e.getFullYear(),e.getMonth(),1)}function L(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+t)}function w(e,t){return new Date(e.getFullYear(),e.getMonth()+t,1)}function fe(e){return new Date(e.getFullYear(),e.getMonth()+1,0).getDate()}function x(e,t){return!e||!t?!1:e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function ge(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()}function E(e,t){return e.getFullYear()*12+e.getMonth()-(t.getFullYear()*12+t.getMonth())}function Q(e){let t=`${e.getMonth()+1}`.padStart(2,"0"),s=`${e.getDate()}`.padStart(2,"0");return`${e.getFullYear()}-${t}-${s}`}function ft(e){let t=y(e);t.setDate(t.getDate()-(t.getDay()+6)%7+3);let s=new Date(t.getFullYear(),0,4);return s.setDate(s.getDate()-(s.getDay()+6)%7+3),1+Math.round((t.getTime()-s.getTime())/gt)}function yt(e){return ft(e.find(t=>t.getDay()===4)??e[0])}function Ne(e,t,s){return t&&e<y(t)?y(t):s&&e>y(s)?y(s):e}function mt(e,t,s){let P=z(e),v=(P.getDay()-t+7)%7,_=L(P,-v),ee=s?6:Math.ceil((v+fe(e))/7);return Array.from({length:ee},(ye,G)=>Array.from({length:7},(me,A)=>L(_,G*7+A)))}function bt({className:e}){return(0,n.jsx)("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function pt({className:e}){return(0,n.jsx)("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}var ht={sm:{day:"h-7 w-7 text-xs",head:"h-7 w-7 text-[10px]",caption:"text-xs",nav:"h-6 w-6",icon:"h-3 w-3",padding:"p-2",gap:"gap-3",footer:"text-xs",select:"text-xs py-0.5 pl-1 pr-5"},md:{day:"h-9 w-9 text-sm",head:"h-9 w-9 text-xs",caption:"text-sm",nav:"h-7 w-7",icon:"h-4 w-4",padding:"p-3",gap:"gap-4",footer:"text-sm",select:"text-sm py-1 pl-1.5 pr-6"},lg:{day:"h-11 w-11 text-base",head:"h-11 w-11 text-sm",caption:"text-base",nav:"h-9 w-9",icon:"h-5 w-5",padding:"p-4",gap:"gap-5",footer:"text-sm",select:"text-base py-1.5 pl-2 pr-7"}},Dt={primary:"bg-synertech-primary-600 text-synertech-on-primary hover:bg-synertech-primary-700",success:"bg-green-700 text-white hover:bg-green-800",warning:"bg-yellow-500 text-gray-900 hover:bg-yellow-600 dark:bg-yellow-400 dark:hover:bg-yellow-500",error:"bg-red-600 text-white hover:bg-red-700",info:"bg-cyan-700 text-white hover:bg-cyan-800",neutral:"bg-gray-700 text-white hover:bg-gray-800 dark:bg-gray-500 dark:hover:bg-gray-400"},xt={primary:"bg-synertech-primary-50 dark:bg-synertech-primary-900/30",success:"bg-green-50 dark:bg-green-900/30",warning:"bg-yellow-50 dark:bg-yellow-900/30",error:"bg-red-50 dark:bg-red-900/30",info:"bg-cyan-50 dark:bg-cyan-900/30",neutral:"bg-gray-100 dark:bg-gray-700/40"},vt={primary:"text-synertech-primary-900 dark:text-synertech-primary-100",success:"text-green-900 dark:text-green-100",warning:"text-yellow-900 dark:text-yellow-100",error:"text-red-900 dark:text-red-100",info:"text-cyan-900 dark:text-cyan-100",neutral:"text-gray-900 dark:text-gray-100"},kt={primary:"font-semibold text-synertech-primary-600 dark:text-synertech-primary-400",success:"font-semibold text-green-700 dark:text-green-400",warning:"font-semibold text-yellow-700 dark:text-yellow-400",error:"font-semibold text-red-600 dark:text-red-400",info:"font-semibold text-cyan-700 dark:text-cyan-400",neutral:"font-semibold text-gray-900 dark:text-gray-100"},V={primary:"focus-visible:ring-synertech-primary-500",success:"focus-visible:ring-green-500",warning:"focus-visible:ring-yellow-500",error:"focus-visible:ring-red-500",info:"focus-visible:ring-cyan-500",neutral:"focus-visible:ring-gray-500"};function X(e,t){if(e==="multiple")return Array.isArray(t)?t.filter(U).map(y):[];if(e==="range"){let s=t??null;return{from:U(s?.from)?y(s.from):null,to:U(s?.to)?y(s.to):null}}return U(t)?y(t):null}function Fe(e){return e?e instanceof Date?e:Array.isArray(e)?e[0]??null:e.from??e.to??null:null}function Ct(e){let{mode:t="single",value:s,defaultValue:P,onChange:v,max:_,month:ee,defaultMonth:ye,onMonthChange:G,numberOfMonths:me=1,weekStartsOn:A=0,locale:Re,today:Pe,size:Ye="md",color:k="primary",minDate:Te,maxDate:Le,disabledDates:j,disabled:m=!1,showOutsideDays:Ae=!0,showWeekNumbers:be=!1,fixedWeeks:Ee=!1,captionLayout:te="label",fromYear:pe,toYear:he,todayButton:ae=!1,clearButton:re=!1,footer:De,bordered:Be=!0,renderDay:xe,labels:B,className:Ie,...We}=e,I=(0,Z.useUILabels)(),Y=(0,Z.useUILocale)(Re),h=ht[Ye],M=Math.max(1,me),ne=H(ee),ve=H(ye),S=H(Te),N=H(Le),oe=H(Pe)?.getTime(),b=(0,l.useMemo)(()=>y(oe===void 0?new Date:new Date(oe)),[oe]),le=s!==void 0,[Ve,ze]=(0,l.useState)(()=>X(t,P)),C=le?X(t,s):Ve,se=ne!==void 0,[Ke,_e]=(0,l.useState)(()=>z(ve??Fe(X(t,P??s))??b)),g=se?z(ne):Ke,D=(0,l.useCallback)(a=>{let r=z(a);se||_e(r),G?.(r)},[se,G]),ke=(0,l.useRef)(null),ie=(0,l.useRef)(!1),[W,q]=(0,l.useState)(()=>{let a=Fe(X(t,P??s)),r=z(ve??ne??a??b),c=a&&ge(a,r)?a:ge(b,r)?b:r;return Ne(c,S,N)}),je=w(g,M-1),Oe=E(W,g)>=0&&E(W,je)<=0?W:g;(0,l.useEffect)(()=>{if(!ie.current)return;ie.current=!1,ke.current?.querySelector(`[data-day="${Q(W)}"]:not([data-outside])`)?.focus()},[W,g]);let T=(0,l.useCallback)(a=>{let r=Ne(y(a),S,N);ie.current=!0,q(r);let c=w(g,M-1);E(r,g)<0?D(r):E(r,c)>0&&D(w(r,-(M-1)))},[g,M,S,N,D]),K=(0,l.useCallback)(a=>m||S&&a<y(S)||N&&a>y(N)?!0:typeof j=="function"?j(a):Array.isArray(j)?j.some(r=>x(r,a)):!1,[m,S,N,j]),[de,Ce]=(0,l.useState)(null),F=(0,l.useCallback)(a=>{le||ze(a),v?.(a)},[le,v]),J=(0,l.useCallback)(a=>{let r=y(a);if(K(r))return;if(t==="multiple"){let i=C??[];if(i.some(o=>x(o,r))){F(i.filter(o=>!x(o,r)));return}if(_!==void 0&&i.length>=_)return;F([...i,r].sort((o,f)=>o.getTime()-f.getTime()));return}if(t==="range"){let i=C??{from:null,to:null};if(!i.from||i.to){F({from:r,to:null});return}F(r<i.from?{from:r,to:i.from}:{from:i.from,to:r});return}F(x(C,r)?null:r)},[t,C,_,F,K]),$e=(0,l.useCallback)(a=>{J(a),q(y(a)),E(a,g)<0?D(a):E(a,w(g,M-1))>0&&D(w(a,-(M-1)))},[J,g,M,D]),we=!m&&(!S||E(g,z(S))>0),Me=!m&&(!N||E(w(g,M-1),z(N))<0),He=(0,l.useCallback)(()=>{D(w(g,-1))},[g,D]),Ue=(0,l.useCallback)(()=>{D(w(g,1))},[g,D]),Ge=(0,l.useCallback)(a=>{if(m)return;let r=W;switch(a.key){case"ArrowLeft":a.preventDefault(),T(L(r,-1));break;case"ArrowRight":a.preventDefault(),T(L(r,1));break;case"ArrowUp":a.preventDefault(),T(L(r,-7));break;case"ArrowDown":a.preventDefault(),T(L(r,7));break;case"Home":a.preventDefault(),T(L(r,-((r.getDay()-A+7)%7)));break;case"End":a.preventDefault(),T(L(r,6-(r.getDay()-A+7)%7));break;case"PageUp":{a.preventDefault();let c=a.shiftKey?-12:-1,i=w(r,c),p=Math.min(r.getDate(),fe(i));T(new Date(i.getFullYear(),i.getMonth(),p));break}case"PageDown":{a.preventDefault();let c=a.shiftKey?12:1,i=w(r,c),p=Math.min(r.getDate(),fe(i));T(new Date(i.getFullYear(),i.getMonth(),p));break}default:break}},[m,W,T,A]),qe=(0,l.useMemo)(()=>{let a=new Intl.DateTimeFormat(Y,{weekday:"short"}),r=new Intl.DateTimeFormat(Y,{weekday:"long"}),c=new Date(2024,0,7);return Array.from({length:7},(i,p)=>{let o=L(c,(A+p)%7);return{short:a.format(o),long:r.format(o)}})},[Y,A]),Je=(0,l.useMemo)(()=>{let a=new Intl.DateTimeFormat(Y,{month:"long"});return Array.from({length:12},(r,c)=>a.format(new Date(2024,c,1)))},[Y]),Se=(0,l.useMemo)(()=>new Intl.DateTimeFormat(Y,{month:"long",year:"numeric"}),[Y]),Qe=(0,l.useMemo)(()=>new Intl.DateTimeFormat(Y,{dateStyle:"full"}),[Y]),Xe=(0,l.useMemo)(()=>{if(te!=="dropdown")return[];let a=b.getFullYear(),r=pe??S?.getFullYear()??a-100,c=he??N?.getFullYear()??a+10;return c<r?[r]:Array.from({length:c-r+1},(i,p)=>r+p)},[te,pe,he,S,N,b]),R=t==="range"?C:null,Ze=R&&R.from&&!R.to&&de&&de>R.from?de:null,O=R?.to??Ze,et=(0,l.useCallback)((a,r)=>{let c=!ge(a,r),i=K(a),p=!1,o=!1,f=!1,d=!1;return t==="multiple"?p=(C??[]).some($=>x($,a)):t==="range"?(o=x(R?.from,a),f=x(O,a),p=o||f,d=!!(R?.from&&O&&a>R.from&&a<O)):p=x(C,a),{selected:p,today:x(a,b),outside:c,disabled:i,rangeStart:o,rangeEnd:f,inRange:d}},[t,C,R,O,K,b]),tt=a=>{let r=w(g,a),c=mt(r,A,Ee),i=a===0,p=a===M-1;return(0,n.jsxs)("div",{className:"flex flex-col",children:[(0,n.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,n.jsx)("button",{type:"button",onClick:He,disabled:!we,"aria-label":B?.previousMonth??I.calendarPreviousMonth,className:(0,u.cn)("inline-flex items-center justify-center rounded-md transition-colors","text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 dark:focus-visible:ring-offset-gray-900",V[k],h.nav,!we&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent",!i&&"invisible"),children:(0,n.jsx)(bt,{className:h.icon})}),te==="dropdown"?(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("select",{"aria-label":B?.monthSelect??I.calendarMonth,value:r.getMonth(),disabled:m,onChange:o=>D(new Date(r.getFullYear(),Number(o.target.value)-a,1)),className:(0,u.cn)("rounded-md border border-gray-300 bg-white font-medium text-gray-900","dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100","focus:outline-none focus-visible:ring-2",V[k],h.select,m&&"cursor-not-allowed opacity-50"),children:Je.map((o,f)=>(0,n.jsx)("option",{value:f,children:o},o))}),(0,n.jsx)("select",{"aria-label":B?.yearSelect??I.calendarYear,value:r.getFullYear(),disabled:m,onChange:o=>D(new Date(Number(o.target.value),r.getMonth()-a,1)),className:(0,u.cn)("rounded-md border border-gray-300 bg-white font-medium text-gray-900","dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100","focus:outline-none focus-visible:ring-2",V[k],h.select,m&&"cursor-not-allowed opacity-50"),children:Xe.map(o=>(0,n.jsx)("option",{value:o,children:o},o))})]}):(0,n.jsx)("div",{"aria-live":"polite",className:(0,u.cn)("font-semibold text-gray-900 dark:text-gray-100",h.caption),children:Se.format(r)}),(0,n.jsx)("button",{type:"button",onClick:Ue,disabled:!Me,"aria-label":B?.nextMonth??I.calendarNextMonth,className:(0,u.cn)("inline-flex items-center justify-center rounded-md transition-colors","text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 dark:focus-visible:ring-offset-gray-900",V[k],h.nav,!Me&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent",!p&&"invisible"),children:(0,n.jsx)(pt,{className:h.icon})})]}),(0,n.jsxs)("table",{role:"grid","aria-label":Se.format(r),onKeyDown:Ge,className:"border-collapse",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[be&&(0,n.jsxs)("th",{scope:"col",className:(0,u.cn)("font-normal text-gray-500 dark:text-gray-400",h.head),children:[(0,n.jsx)("span",{className:"sr-only",children:B?.weekNumber??I.calendarWeekNumber}),(0,n.jsx)("span",{"aria-hidden":"true",children:"#"})]}),qe.map(o=>(0,n.jsx)("th",{scope:"col",abbr:o.long,className:(0,u.cn)("font-medium uppercase text-gray-500 dark:text-gray-400",h.head),children:o.short},o.long))]})}),(0,n.jsx)("tbody",{children:c.map(o=>(0,n.jsxs)("tr",{children:[be&&(0,n.jsx)("td",{className:(0,u.cn)("text-center align-middle text-gray-500 dark:text-gray-400",h.head),children:yt(o)}),o.map(f=>{let d=et(f,r),$=Q(f);if(d.outside&&!Ae)return(0,n.jsx)("td",{className:"p-0"},$);let ot=x(f,Oe)&&!d.outside,ce=d.inRange||d.rangeStart&&!!O||d.rangeEnd&&!!R?.from;return(0,n.jsx)("td",{role:"presentation",className:(0,u.cn)("p-0",ce&&xt[k],ce&&d.rangeStart&&"rounded-l-full",ce&&d.rangeEnd&&"rounded-r-full"),children:(0,n.jsx)("button",{type:"button","data-day":$,"data-selected":d.selected||void 0,"data-today":d.today||void 0,"data-outside":d.outside||void 0,role:"gridcell",tabIndex:ot?0:-1,disabled:m,"aria-selected":d.selected,"aria-disabled":d.disabled||void 0,"aria-current":d.today?"date":void 0,"aria-label":Qe.format(f),onClick:()=>{d.disabled||$e(f)},onMouseEnter:()=>t==="range"&&Ce(y(f)),onMouseLeave:()=>t==="range"&&Ce(null),onFocus:()=>q(y(f)),className:(0,u.cn)("inline-flex items-center justify-center rounded-full transition-colors","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 dark:focus-visible:ring-offset-gray-900",V[k],h.day,d.selected?Dt[k]:d.inRange?(0,u.cn)(vt[k],"hover:bg-gray-200/60 dark:hover:bg-gray-600/60"):d.today?(0,u.cn)(kt[k],"hover:bg-gray-100 dark:hover:bg-gray-700"):(0,u.cn)("text-gray-900 dark:text-gray-100","hover:bg-gray-100 dark:hover:bg-gray-700"),d.outside&&!d.selected&&"text-gray-500 dark:text-gray-400",d.disabled&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent"),children:xe?xe(f,d):f.getDate()})},$)})]},Q(o[0])))})]})]},Q(r))},at=(0,l.useCallback)(()=>{if(D(b),q(b),K(b))return;(t==="multiple"?(C??[]).some(r=>x(r,b)):t==="single"&&x(C,b))||J(b)},[b,D,K,J,t,C]),rt=(0,l.useCallback)(()=>{F(t==="multiple"?[]:t==="range"?{from:null,to:null}:null)},[t,F]),nt=!!De||ae||re;return(0,n.jsxs)("div",{ref:ke,className:(0,u.cn)("inline-block bg-white dark:bg-gray-900",Be&&"rounded-lg border border-gray-200 shadow-sm dark:border-gray-700",h.padding,m&&"opacity-60",Ie),...We,children:[(0,n.jsx)("div",{className:(0,u.cn)("flex flex-wrap",h.gap),children:Array.from({length:M},(a,r)=>tt(r))}),nt&&(0,n.jsxs)("div",{className:(0,u.cn)("mt-3 flex items-center justify-between gap-2 border-t border-gray-200 pt-3 dark:border-gray-700",h.footer),children:[(0,n.jsx)("div",{className:"text-gray-600 dark:text-gray-400",children:De}),(ae||re)&&(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[ae&&(0,n.jsx)("button",{type:"button",onClick:at,disabled:m,className:(0,u.cn)("rounded-md px-2 py-1 font-medium transition-colors","text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2",V[k],m&&"cursor-not-allowed opacity-50"),children:B?.today??I.calendarToday}),re&&(0,n.jsx)("button",{type:"button",onClick:rt,disabled:m,className:(0,u.cn)("rounded-md px-2 py-1 font-medium transition-colors","text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2",V[k],m&&"cursor-not-allowed opacity-50"),children:B?.clear??I.calendarClear})]})]})]})}0&&(module.exports={Calendar});
@@ -1 +1 @@
1
- "use client";import{useCallback as h,useEffect as Ze,useMemo as _,useRef as we,useState as X}from"react";import{cn as u}from"../../lib/cn.js";import{useUILabels as et}from"../../lib/i18n.js";import{jsx as o,jsxs as N}from"react/jsx-runtime";var tt=10080*60*1e3;function c(a){return new Date(a.getFullYear(),a.getMonth(),a.getDate())}function z(a){return new Date(a.getFullYear(),a.getMonth(),1)}function P(a,r){return new Date(a.getFullYear(),a.getMonth(),a.getDate()+r)}function x(a,r){return new Date(a.getFullYear(),a.getMonth()+r,1)}function ue(a){return new Date(a.getFullYear(),a.getMonth()+1,0).getDate()}function S(a,r){return!a||!r?!1:a.getFullYear()===r.getFullYear()&&a.getMonth()===r.getMonth()&&a.getDate()===r.getDate()}function ce(a,r){return a.getFullYear()===r.getFullYear()&&a.getMonth()===r.getMonth()}function A(a,r){return a.getFullYear()*12+a.getMonth()-(r.getFullYear()*12+r.getMonth())}function Z(a){let r=`${a.getMonth()+1}`.padStart(2,"0"),i=`${a.getDate()}`.padStart(2,"0");return`${a.getFullYear()}-${r}-${i}`}function at(a){let r=c(a);r.setDate(r.getDate()-(r.getDay()+6)%7+3);let i=new Date(r.getFullYear(),0,4);return i.setDate(i.getDate()-(i.getDay()+6)%7+3),1+Math.round((r.getTime()-i.getTime())/tt)}function Ce(a,r,i){return r&&a<c(r)?c(r):i&&a>c(i)?c(i):a}function rt(a,r,i){let V=z(a),j=(V.getDay()-r+7)%7,O=P(V,-j),$=i?6:Math.ceil((j+ue(a))/7);return Array.from({length:$},(te,q)=>Array.from({length:7},(ge,T)=>P(O,q*7+T)))}function nt({className:a}){return o("svg",{className:a,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:o("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function ot({className:a}){return o("svg",{className:a,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:o("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}var lt={sm:{day:"h-7 w-7 text-xs",head:"h-7 w-7 text-[10px]",caption:"text-xs",nav:"h-6 w-6",icon:"h-3 w-3",padding:"p-2",gap:"gap-3",footer:"text-xs",select:"text-xs py-0.5 pl-1 pr-5"},md:{day:"h-9 w-9 text-sm",head:"h-9 w-9 text-xs",caption:"text-sm",nav:"h-7 w-7",icon:"h-4 w-4",padding:"p-3",gap:"gap-4",footer:"text-sm",select:"text-sm py-1 pl-1.5 pr-6"},lg:{day:"h-11 w-11 text-base",head:"h-11 w-11 text-sm",caption:"text-base",nav:"h-9 w-9",icon:"h-5 w-5",padding:"p-4",gap:"gap-5",footer:"text-sm",select:"text-base py-1.5 pl-2 pr-7"}},st={primary:"bg-synertech-primary-600 text-synertech-on-primary hover:bg-synertech-primary-700",success:"bg-green-700 text-white hover:bg-green-800",warning:"bg-yellow-500 text-gray-900 hover:bg-yellow-600 dark:bg-yellow-400 dark:hover:bg-yellow-500",error:"bg-red-600 text-white hover:bg-red-700",info:"bg-cyan-700 text-white hover:bg-cyan-800",neutral:"bg-gray-700 text-white hover:bg-gray-800 dark:bg-gray-500 dark:hover:bg-gray-400"},it={primary:"bg-synertech-primary-50 dark:bg-synertech-primary-900/30",success:"bg-green-50 dark:bg-green-900/30",warning:"bg-yellow-50 dark:bg-yellow-900/30",error:"bg-red-50 dark:bg-red-900/30",info:"bg-cyan-50 dark:bg-cyan-900/30",neutral:"bg-gray-100 dark:bg-gray-700/40"},dt={primary:"text-synertech-primary-900 dark:text-synertech-primary-100",success:"text-green-900 dark:text-green-100",warning:"text-yellow-900 dark:text-yellow-100",error:"text-red-900 dark:text-red-100",info:"text-cyan-900 dark:text-cyan-100",neutral:"text-gray-900 dark:text-gray-100"},ct={primary:"font-semibold text-synertech-primary-600 dark:text-synertech-primary-400",success:"font-semibold text-green-700 dark:text-green-400",warning:"font-semibold text-yellow-700 dark:text-yellow-400",error:"font-semibold text-red-600 dark:text-red-400",info:"font-semibold text-cyan-700 dark:text-cyan-400",neutral:"font-semibold text-gray-900 dark:text-gray-100"},W={primary:"focus-visible:ring-synertech-primary-500",success:"focus-visible:ring-green-500",warning:"focus-visible:ring-yellow-500",error:"focus-visible:ring-red-500",info:"focus-visible:ring-cyan-500",neutral:"focus-visible:ring-gray-500"};function ee(a,r){if(a==="multiple")return Array.isArray(r)?r.map(c):[];if(a==="range"){let i=r??null;return{from:i?.from?c(i.from):null,to:i?.to?c(i.to):null}}return r instanceof Date?c(r):null}function Me(a){return a?a instanceof Date?a:Array.isArray(a)?a[0]??null:a.from??a.to??null:null}function mt(a){let{mode:r="single",value:i,defaultValue:V,onChange:j,max:O,month:$,defaultMonth:te,onMonthChange:q,numberOfMonths:ge=1,weekStartsOn:T=0,locale:F,size:Se="md",color:D="primary",minDate:v,maxDate:k,disabledDates:H,disabled:y=!1,showOutsideDays:Ne=!0,showWeekNumbers:fe=!1,fixedWeeks:Fe=!1,captionLayout:ae="label",fromYear:ye,toYear:me,todayButton:re=!1,clearButton:ne=!1,footer:be,bordered:Re=!0,renderDay:pe,labels:E,className:Ye,...Pe}=a,B=et(),b=lt[Se],w=Math.max(1,ge),R=_(()=>c(new Date),[]),oe=i!==void 0,[Te,Le]=X(()=>ee(r,V)),L=oe?ee(r,i):Te,le=$!==void 0,[Ae,Ee]=X(()=>z(te??Me(ee(r,V??i))??new Date)),g=le?z($):Ae,p=h(e=>{let t=z(e);le||Ee(t),q?.(t)},[le,q]),he=we(null),se=we(!1),[I,J]=X(()=>{let e=Me(ee(r,V??i)),t=z(te??$??e??new Date),d=e&&ce(e,t)?e:ce(c(new Date),t)?c(new Date):t;return Ce(d,v,k)}),Be=x(g,w-1),Ie=A(I,g)>=0&&A(I,Be)<=0?I:g;Ze(()=>{if(!se.current)return;se.current=!1,he.current?.querySelector(`[data-day="${Z(I)}"]:not([data-outside])`)?.focus()},[I,g]);let Y=h(e=>{let t=Ce(c(e),v,k);se.current=!0,J(t);let d=x(g,w-1);A(t,g)<0?p(t):A(t,d)>0&&p(x(t,-(w-1)))},[g,w,v,k,p]),K=h(e=>y||v&&e<c(v)||k&&e>c(k)?!0:typeof H=="function"?H(e):Array.isArray(H)?H.some(t=>S(t,e)):!1,[y,v,k,H]),[ie,De]=X(null),C=h(e=>{oe||Le(e),j?.(e)},[oe,j]),Q=h(e=>{let t=c(e);if(K(t))return;if(r==="multiple"){let l=L??[];if(l.some(n=>S(n,t))){C(l.filter(n=>!S(n,t)));return}if(O!==void 0&&l.length>=O)return;C([...l,t].sort((n,f)=>n.getTime()-f.getTime()));return}if(r==="range"){let l=L??{from:null,to:null};if(!l.from||l.to){C({from:t,to:null});return}C(t<l.from?{from:t,to:l.from}:{from:l.from,to:t});return}C(S(L,t)?null:t)},[r,L,O,C,K]),We=h(e=>{Q(e),J(c(e)),A(e,g)<0?p(e):A(e,x(g,w-1))>0&&p(x(e,-(w-1)))},[Q,g,w,p]),xe=!y&&(!v||A(g,z(v))>0),ve=!y&&(!k||A(x(g,w-1),z(k))<0),ze=h(()=>{p(x(g,-1))},[g,p]),Ve=h(()=>{p(x(g,1))},[g,p]),Ke=h(e=>{if(y)return;let t=I;switch(e.key){case"ArrowLeft":e.preventDefault(),Y(P(t,-1));break;case"ArrowRight":e.preventDefault(),Y(P(t,1));break;case"ArrowUp":e.preventDefault(),Y(P(t,-7));break;case"ArrowDown":e.preventDefault(),Y(P(t,7));break;case"Home":e.preventDefault(),Y(P(t,-((t.getDay()-T+7)%7)));break;case"End":e.preventDefault(),Y(P(t,6-(t.getDay()-T+7)%7));break;case"PageUp":{e.preventDefault();let d=e.shiftKey?-12:-1,l=x(t,d),m=Math.min(t.getDate(),ue(l));Y(new Date(l.getFullYear(),l.getMonth(),m));break}case"PageDown":{e.preventDefault();let d=e.shiftKey?12:1,l=x(t,d),m=Math.min(t.getDate(),ue(l));Y(new Date(l.getFullYear(),l.getMonth(),m));break}default:break}},[y,I,Y,T]),_e=_(()=>{let e=new Intl.DateTimeFormat(F,{weekday:"short"}),t=new Intl.DateTimeFormat(F,{weekday:"long"}),d=new Date(2024,0,7);return Array.from({length:7},(l,m)=>{let n=P(d,(T+m)%7);return{short:e.format(n),long:t.format(n)}})},[F,T]),je=_(()=>{let e=new Intl.DateTimeFormat(F,{month:"long"});return Array.from({length:12},(t,d)=>e.format(new Date(2024,d,1)))},[F]),ke=_(()=>new Intl.DateTimeFormat(F,{month:"long",year:"numeric"}),[F]),Oe=_(()=>new Intl.DateTimeFormat(F,{dateStyle:"full"}),[F]),$e=_(()=>{if(ae!=="dropdown")return[];let e=R.getFullYear(),t=ye??v?.getFullYear()??e-100,d=me??k?.getFullYear()??e+10;return d<t?[t]:Array.from({length:d-t+1},(l,m)=>t+m)},[ae,ye,me,v,k,R]),M=r==="range"?L:null,He=M&&M.from&&!M.to&&ie&&ie>M.from?ie:null,G=M?.to??He,Ge=h((e,t)=>{let d=!ce(e,t),l=K(e),m=!1,n=!1,f=!1,s=!1;return r==="multiple"?m=(L??[]).some(U=>S(U,e)):r==="range"?(n=S(M?.from,e),f=S(G,e),m=n||f,s=!!(M?.from&&G&&e>M.from&&e<G)):m=S(L,e),{selected:m,today:S(e,R),outside:d,disabled:l,rangeStart:n,rangeEnd:f,inRange:s}},[r,L,M,G,K,R]),Ue=e=>{let t=x(g,e),d=rt(t,T,Fe),l=e===0,m=e===w-1;return N("div",{className:"flex flex-col",children:[N("div",{className:"mb-2 flex items-center justify-between",children:[o("button",{type:"button",onClick:ze,disabled:!xe,"aria-label":E?.previousMonth??B.calendarPreviousMonth,className:u("inline-flex items-center justify-center rounded-md transition-colors","text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 dark:focus-visible:ring-offset-gray-900",W[D],b.nav,!xe&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent",!l&&"invisible"),children:o(nt,{className:b.icon})}),ae==="dropdown"?N("div",{className:"flex items-center gap-1",children:[o("select",{"aria-label":E?.monthSelect??B.calendarMonth,value:t.getMonth(),disabled:y,onChange:n=>p(new Date(t.getFullYear(),Number(n.target.value)-e,1)),className:u("rounded-md border border-gray-300 bg-white font-medium text-gray-900","dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100","focus:outline-none focus-visible:ring-2",W[D],b.select,y&&"cursor-not-allowed opacity-50"),children:je.map((n,f)=>o("option",{value:f,children:n},n))}),o("select",{"aria-label":E?.yearSelect??B.calendarYear,value:t.getFullYear(),disabled:y,onChange:n=>p(new Date(Number(n.target.value),t.getMonth()-e,1)),className:u("rounded-md border border-gray-300 bg-white font-medium text-gray-900","dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100","focus:outline-none focus-visible:ring-2",W[D],b.select,y&&"cursor-not-allowed opacity-50"),children:$e.map(n=>o("option",{value:n,children:n},n))})]}):o("div",{"aria-live":"polite",className:u("font-semibold text-gray-900 dark:text-gray-100",b.caption),children:ke.format(t)}),o("button",{type:"button",onClick:Ve,disabled:!ve,"aria-label":E?.nextMonth??B.calendarNextMonth,className:u("inline-flex items-center justify-center rounded-md transition-colors","text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 dark:focus-visible:ring-offset-gray-900",W[D],b.nav,!ve&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent",!m&&"invisible"),children:o(ot,{className:b.icon})})]}),N("table",{role:"grid","aria-label":ke.format(t),onKeyDown:Ke,className:"border-collapse",children:[o("thead",{children:N("tr",{children:[fe&&N("th",{scope:"col",className:u("font-normal text-gray-500 dark:text-gray-400",b.head),children:[o("span",{className:"sr-only",children:E?.weekNumber??B.calendarWeekNumber}),o("span",{"aria-hidden":"true",children:"#"})]}),_e.map(n=>o("th",{scope:"col",abbr:n.long,className:u("font-medium uppercase text-gray-500 dark:text-gray-400",b.head),children:n.short},n.long))]})}),o("tbody",{children:d.map(n=>N("tr",{children:[fe&&o("td",{className:u("text-center align-middle text-gray-500 dark:text-gray-400",b.head),children:at(n[0])}),n.map(f=>{let s=Ge(f,t),U=Z(f);if(s.outside&&!Ne)return o("td",{className:"p-0"},U);let Xe=S(f,Ie)&&!s.outside,de=s.inRange||s.rangeStart&&!!G||s.rangeEnd&&!!M?.from;return o("td",{role:"presentation",className:u("p-0",de&&it[D],de&&s.rangeStart&&"rounded-l-full",de&&s.rangeEnd&&"rounded-r-full"),children:o("button",{type:"button","data-day":U,"data-selected":s.selected||void 0,"data-today":s.today||void 0,"data-outside":s.outside||void 0,role:"gridcell",tabIndex:Xe?0:-1,disabled:y,"aria-selected":s.selected,"aria-disabled":s.disabled||void 0,"aria-current":s.today?"date":void 0,"aria-label":Oe.format(f),onClick:()=>{s.disabled||We(f)},onMouseEnter:()=>r==="range"&&De(c(f)),onMouseLeave:()=>r==="range"&&De(null),onFocus:()=>J(c(f)),className:u("inline-flex items-center justify-center rounded-full transition-colors","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 dark:focus-visible:ring-offset-gray-900",W[D],b.day,s.selected?st[D]:s.inRange?u(dt[D],"hover:bg-gray-200/60 dark:hover:bg-gray-600/60"):s.today?u(ct[D],"hover:bg-gray-100 dark:hover:bg-gray-700"):u("text-gray-900 dark:text-gray-100","hover:bg-gray-100 dark:hover:bg-gray-700"),s.outside&&!s.selected&&"text-gray-500 dark:text-gray-400",s.disabled&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent"),children:pe?pe(f,s):f.getDate()})},U)})]},Z(n[0])))})]})]},Z(t))},qe=h(()=>{p(R),J(R),K(R)||Q(R)},[R,p,K,Q]),Je=h(()=>{C(r==="multiple"?[]:r==="range"?{from:null,to:null}:null)},[r,C]),Qe=!!be||re||ne;return N("div",{ref:he,className:u("inline-block bg-white dark:bg-gray-900",Re&&"rounded-lg border border-gray-200 shadow-sm dark:border-gray-700",b.padding,y&&"opacity-60",Ye),...Pe,children:[o("div",{className:u("flex flex-wrap",b.gap),children:Array.from({length:w},(e,t)=>Ue(t))}),Qe&&N("div",{className:u("mt-3 flex items-center justify-between gap-2 border-t border-gray-200 pt-3 dark:border-gray-700",b.footer),children:[o("div",{className:"text-gray-600 dark:text-gray-400",children:be}),(re||ne)&&N("div",{className:"flex items-center gap-2",children:[re&&o("button",{type:"button",onClick:qe,disabled:y,className:u("rounded-md px-2 py-1 font-medium transition-colors","text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2",W[D],y&&"cursor-not-allowed opacity-50"),children:E?.today??B.calendarToday}),ne&&o("button",{type:"button",onClick:Je,disabled:y,className:u("rounded-md px-2 py-1 font-medium transition-colors","text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2",W[D],y&&"cursor-not-allowed opacity-50"),children:E?.clear??B.calendarClear})]})]})]})}export{mt as Calendar};
1
+ "use client";import{useCallback as D,useEffect as it,useMemo as _,useRef as Fe,useState as Z}from"react";import{cn as c}from"../../lib/cn.js";import{useUILabels as dt,useUILocale as ct}from"../../lib/i18n.js";import{jsx as o,jsxs as R}from"react/jsx-runtime";var ut=10080*60*1e3;function q(e){return e instanceof Date&&!Number.isNaN(e.getTime())}function G(e){return q(e)?e:void 0}function f(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function V(e){return new Date(e.getFullYear(),e.getMonth(),1)}function T(e,r){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+r)}function C(e,r){return new Date(e.getFullYear(),e.getMonth()+r,1)}function ye(e){return new Date(e.getFullYear(),e.getMonth()+1,0).getDate()}function x(e,r){return!e||!r?!1:e.getFullYear()===r.getFullYear()&&e.getMonth()===r.getMonth()&&e.getDate()===r.getDate()}function fe(e,r){return e.getFullYear()===r.getFullYear()&&e.getMonth()===r.getMonth()}function A(e,r){return e.getFullYear()*12+e.getMonth()-(r.getFullYear()*12+r.getMonth())}function ee(e){let r=`${e.getMonth()+1}`.padStart(2,"0"),i=`${e.getDate()}`.padStart(2,"0");return`${e.getFullYear()}-${r}-${i}`}function gt(e){let r=f(e);r.setDate(r.getDate()-(r.getDay()+6)%7+3);let i=new Date(r.getFullYear(),0,4);return i.setDate(i.getDate()-(i.getDay()+6)%7+3),1+Math.round((r.getTime()-i.getTime())/ut)}function ft(e){return gt(e.find(r=>r.getDay()===4)??e[0])}function Re(e,r,i){return r&&e<f(r)?f(r):i&&e>f(i)?f(i):e}function yt(e,r,i){let z=V(e),j=(z.getDay()-r+7)%7,O=T(z,-j),ae=i?6:Math.ceil((j+ye(e))/7);return Array.from({length:ae},(me,J)=>Array.from({length:7},(be,L)=>T(O,J*7+L)))}function mt({className:e}){return o("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:o("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function bt({className:e}){return o("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:o("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}var pt={sm:{day:"h-7 w-7 text-xs",head:"h-7 w-7 text-[10px]",caption:"text-xs",nav:"h-6 w-6",icon:"h-3 w-3",padding:"p-2",gap:"gap-3",footer:"text-xs",select:"text-xs py-0.5 pl-1 pr-5"},md:{day:"h-9 w-9 text-sm",head:"h-9 w-9 text-xs",caption:"text-sm",nav:"h-7 w-7",icon:"h-4 w-4",padding:"p-3",gap:"gap-4",footer:"text-sm",select:"text-sm py-1 pl-1.5 pr-6"},lg:{day:"h-11 w-11 text-base",head:"h-11 w-11 text-sm",caption:"text-base",nav:"h-9 w-9",icon:"h-5 w-5",padding:"p-4",gap:"gap-5",footer:"text-sm",select:"text-base py-1.5 pl-2 pr-7"}},ht={primary:"bg-synertech-primary-600 text-synertech-on-primary hover:bg-synertech-primary-700",success:"bg-green-700 text-white hover:bg-green-800",warning:"bg-yellow-500 text-gray-900 hover:bg-yellow-600 dark:bg-yellow-400 dark:hover:bg-yellow-500",error:"bg-red-600 text-white hover:bg-red-700",info:"bg-cyan-700 text-white hover:bg-cyan-800",neutral:"bg-gray-700 text-white hover:bg-gray-800 dark:bg-gray-500 dark:hover:bg-gray-400"},Dt={primary:"bg-synertech-primary-50 dark:bg-synertech-primary-900/30",success:"bg-green-50 dark:bg-green-900/30",warning:"bg-yellow-50 dark:bg-yellow-900/30",error:"bg-red-50 dark:bg-red-900/30",info:"bg-cyan-50 dark:bg-cyan-900/30",neutral:"bg-gray-100 dark:bg-gray-700/40"},xt={primary:"text-synertech-primary-900 dark:text-synertech-primary-100",success:"text-green-900 dark:text-green-100",warning:"text-yellow-900 dark:text-yellow-100",error:"text-red-900 dark:text-red-100",info:"text-cyan-900 dark:text-cyan-100",neutral:"text-gray-900 dark:text-gray-100"},vt={primary:"font-semibold text-synertech-primary-600 dark:text-synertech-primary-400",success:"font-semibold text-green-700 dark:text-green-400",warning:"font-semibold text-yellow-700 dark:text-yellow-400",error:"font-semibold text-red-600 dark:text-red-400",info:"font-semibold text-cyan-700 dark:text-cyan-400",neutral:"font-semibold text-gray-900 dark:text-gray-100"},W={primary:"focus-visible:ring-synertech-primary-500",success:"focus-visible:ring-green-500",warning:"focus-visible:ring-yellow-500",error:"focus-visible:ring-red-500",info:"focus-visible:ring-cyan-500",neutral:"focus-visible:ring-gray-500"};function te(e,r){if(e==="multiple")return Array.isArray(r)?r.filter(q).map(f):[];if(e==="range"){let i=r??null;return{from:q(i?.from)?f(i.from):null,to:q(i?.to)?f(i.to):null}}return q(r)?f(r):null}function Pe(e){return e?e instanceof Date?e:Array.isArray(e)?e[0]??null:e.from??e.to??null:null}function St(e){let{mode:r="single",value:i,defaultValue:z,onChange:j,max:O,month:ae,defaultMonth:me,onMonthChange:J,numberOfMonths:be=1,weekStartsOn:L=0,locale:Ye,today:Te,size:Le="md",color:v="primary",minDate:Ae,maxDate:Ee,disabledDates:$,disabled:y=!1,showOutsideDays:Be=!0,showWeekNumbers:pe=!1,fixedWeeks:Ie=!1,captionLayout:re="label",fromYear:he,toYear:De,todayButton:ne=!1,clearButton:oe=!1,footer:xe,bordered:We=!0,renderDay:ve,labels:E,className:Ve,...ze}=e,B=dt(),P=ct(Ye),p=pt[Le],w=Math.max(1,be),le=G(ae),ke=G(me),M=G(Ae),S=G(Ee),se=G(Te)?.getTime(),m=_(()=>f(se===void 0?new Date:new Date(se)),[se]),ie=i!==void 0,[Ke,_e]=Z(()=>te(r,z)),k=ie?te(r,i):Ke,de=le!==void 0,[je,Oe]=Z(()=>V(ke??Pe(te(r,z??i))??m)),u=de?V(le):je,h=D(t=>{let a=V(t);de||Oe(a),J?.(a)},[de,J]),Ce=Fe(null),ce=Fe(!1),[I,Q]=Z(()=>{let t=Pe(te(r,z??i)),a=V(ke??le??t??m),d=t&&fe(t,a)?t:fe(m,a)?m:a;return Re(d,M,S)}),$e=C(u,w-1),He=A(I,u)>=0&&A(I,$e)<=0?I:u;it(()=>{if(!ce.current)return;ce.current=!1,Ce.current?.querySelector(`[data-day="${ee(I)}"]:not([data-outside])`)?.focus()},[I,u]);let Y=D(t=>{let a=Re(f(t),M,S);ce.current=!0,Q(a);let d=C(u,w-1);A(a,u)<0?h(a):A(a,d)>0&&h(C(a,-(w-1)))},[u,w,M,S,h]),K=D(t=>y||M&&t<f(M)||S&&t>f(S)?!0:typeof $=="function"?$(t):Array.isArray($)?$.some(a=>x(a,t)):!1,[y,M,S,$]),[ue,we]=Z(null),N=D(t=>{ie||_e(t),j?.(t)},[ie,j]),X=D(t=>{let a=f(t);if(K(a))return;if(r==="multiple"){let l=k??[];if(l.some(n=>x(n,a))){N(l.filter(n=>!x(n,a)));return}if(O!==void 0&&l.length>=O)return;N([...l,a].sort((n,g)=>n.getTime()-g.getTime()));return}if(r==="range"){let l=k??{from:null,to:null};if(!l.from||l.to){N({from:a,to:null});return}N(a<l.from?{from:a,to:l.from}:{from:l.from,to:a});return}N(x(k,a)?null:a)},[r,k,O,N,K]),Ue=D(t=>{X(t),Q(f(t)),A(t,u)<0?h(t):A(t,C(u,w-1))>0&&h(C(t,-(w-1)))},[X,u,w,h]),Me=!y&&(!M||A(u,V(M))>0),Se=!y&&(!S||A(C(u,w-1),V(S))<0),Ge=D(()=>{h(C(u,-1))},[u,h]),qe=D(()=>{h(C(u,1))},[u,h]),Je=D(t=>{if(y)return;let a=I;switch(t.key){case"ArrowLeft":t.preventDefault(),Y(T(a,-1));break;case"ArrowRight":t.preventDefault(),Y(T(a,1));break;case"ArrowUp":t.preventDefault(),Y(T(a,-7));break;case"ArrowDown":t.preventDefault(),Y(T(a,7));break;case"Home":t.preventDefault(),Y(T(a,-((a.getDay()-L+7)%7)));break;case"End":t.preventDefault(),Y(T(a,6-(a.getDay()-L+7)%7));break;case"PageUp":{t.preventDefault();let d=t.shiftKey?-12:-1,l=C(a,d),b=Math.min(a.getDate(),ye(l));Y(new Date(l.getFullYear(),l.getMonth(),b));break}case"PageDown":{t.preventDefault();let d=t.shiftKey?12:1,l=C(a,d),b=Math.min(a.getDate(),ye(l));Y(new Date(l.getFullYear(),l.getMonth(),b));break}default:break}},[y,I,Y,L]),Qe=_(()=>{let t=new Intl.DateTimeFormat(P,{weekday:"short"}),a=new Intl.DateTimeFormat(P,{weekday:"long"}),d=new Date(2024,0,7);return Array.from({length:7},(l,b)=>{let n=T(d,(L+b)%7);return{short:t.format(n),long:a.format(n)}})},[P,L]),Xe=_(()=>{let t=new Intl.DateTimeFormat(P,{month:"long"});return Array.from({length:12},(a,d)=>t.format(new Date(2024,d,1)))},[P]),Ne=_(()=>new Intl.DateTimeFormat(P,{month:"long",year:"numeric"}),[P]),Ze=_(()=>new Intl.DateTimeFormat(P,{dateStyle:"full"}),[P]),et=_(()=>{if(re!=="dropdown")return[];let t=m.getFullYear(),a=he??M?.getFullYear()??t-100,d=De??S?.getFullYear()??t+10;return d<a?[a]:Array.from({length:d-a+1},(l,b)=>a+b)},[re,he,De,M,S,m]),F=r==="range"?k:null,tt=F&&F.from&&!F.to&&ue&&ue>F.from?ue:null,H=F?.to??tt,at=D((t,a)=>{let d=!fe(t,a),l=K(t),b=!1,n=!1,g=!1,s=!1;return r==="multiple"?b=(k??[]).some(U=>x(U,t)):r==="range"?(n=x(F?.from,t),g=x(H,t),b=n||g,s=!!(F?.from&&H&&t>F.from&&t<H)):b=x(k,t),{selected:b,today:x(t,m),outside:d,disabled:l,rangeStart:n,rangeEnd:g,inRange:s}},[r,k,F,H,K,m]),rt=t=>{let a=C(u,t),d=yt(a,L,Ie),l=t===0,b=t===w-1;return R("div",{className:"flex flex-col",children:[R("div",{className:"mb-2 flex items-center justify-between",children:[o("button",{type:"button",onClick:Ge,disabled:!Me,"aria-label":E?.previousMonth??B.calendarPreviousMonth,className:c("inline-flex items-center justify-center rounded-md transition-colors","text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 dark:focus-visible:ring-offset-gray-900",W[v],p.nav,!Me&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent",!l&&"invisible"),children:o(mt,{className:p.icon})}),re==="dropdown"?R("div",{className:"flex items-center gap-1",children:[o("select",{"aria-label":E?.monthSelect??B.calendarMonth,value:a.getMonth(),disabled:y,onChange:n=>h(new Date(a.getFullYear(),Number(n.target.value)-t,1)),className:c("rounded-md border border-gray-300 bg-white font-medium text-gray-900","dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100","focus:outline-none focus-visible:ring-2",W[v],p.select,y&&"cursor-not-allowed opacity-50"),children:Xe.map((n,g)=>o("option",{value:g,children:n},n))}),o("select",{"aria-label":E?.yearSelect??B.calendarYear,value:a.getFullYear(),disabled:y,onChange:n=>h(new Date(Number(n.target.value),a.getMonth()-t,1)),className:c("rounded-md border border-gray-300 bg-white font-medium text-gray-900","dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100","focus:outline-none focus-visible:ring-2",W[v],p.select,y&&"cursor-not-allowed opacity-50"),children:et.map(n=>o("option",{value:n,children:n},n))})]}):o("div",{"aria-live":"polite",className:c("font-semibold text-gray-900 dark:text-gray-100",p.caption),children:Ne.format(a)}),o("button",{type:"button",onClick:qe,disabled:!Se,"aria-label":E?.nextMonth??B.calendarNextMonth,className:c("inline-flex items-center justify-center rounded-md transition-colors","text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 dark:focus-visible:ring-offset-gray-900",W[v],p.nav,!Se&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent",!b&&"invisible"),children:o(bt,{className:p.icon})})]}),R("table",{role:"grid","aria-label":Ne.format(a),onKeyDown:Je,className:"border-collapse",children:[o("thead",{children:R("tr",{children:[pe&&R("th",{scope:"col",className:c("font-normal text-gray-500 dark:text-gray-400",p.head),children:[o("span",{className:"sr-only",children:E?.weekNumber??B.calendarWeekNumber}),o("span",{"aria-hidden":"true",children:"#"})]}),Qe.map(n=>o("th",{scope:"col",abbr:n.long,className:c("font-medium uppercase text-gray-500 dark:text-gray-400",p.head),children:n.short},n.long))]})}),o("tbody",{children:d.map(n=>R("tr",{children:[pe&&o("td",{className:c("text-center align-middle text-gray-500 dark:text-gray-400",p.head),children:ft(n)}),n.map(g=>{let s=at(g,a),U=ee(g);if(s.outside&&!Be)return o("td",{className:"p-0"},U);let st=x(g,He)&&!s.outside,ge=s.inRange||s.rangeStart&&!!H||s.rangeEnd&&!!F?.from;return o("td",{role:"presentation",className:c("p-0",ge&&Dt[v],ge&&s.rangeStart&&"rounded-l-full",ge&&s.rangeEnd&&"rounded-r-full"),children:o("button",{type:"button","data-day":U,"data-selected":s.selected||void 0,"data-today":s.today||void 0,"data-outside":s.outside||void 0,role:"gridcell",tabIndex:st?0:-1,disabled:y,"aria-selected":s.selected,"aria-disabled":s.disabled||void 0,"aria-current":s.today?"date":void 0,"aria-label":Ze.format(g),onClick:()=>{s.disabled||Ue(g)},onMouseEnter:()=>r==="range"&&we(f(g)),onMouseLeave:()=>r==="range"&&we(null),onFocus:()=>Q(f(g)),className:c("inline-flex items-center justify-center rounded-full transition-colors","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 dark:focus-visible:ring-offset-gray-900",W[v],p.day,s.selected?ht[v]:s.inRange?c(xt[v],"hover:bg-gray-200/60 dark:hover:bg-gray-600/60"):s.today?c(vt[v],"hover:bg-gray-100 dark:hover:bg-gray-700"):c("text-gray-900 dark:text-gray-100","hover:bg-gray-100 dark:hover:bg-gray-700"),s.outside&&!s.selected&&"text-gray-500 dark:text-gray-400",s.disabled&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent"),children:ve?ve(g,s):g.getDate()})},U)})]},ee(n[0])))})]})]},ee(a))},nt=D(()=>{if(h(m),Q(m),K(m))return;(r==="multiple"?(k??[]).some(a=>x(a,m)):r==="single"&&x(k,m))||X(m)},[m,h,K,X,r,k]),ot=D(()=>{N(r==="multiple"?[]:r==="range"?{from:null,to:null}:null)},[r,N]),lt=!!xe||ne||oe;return R("div",{ref:Ce,className:c("inline-block bg-white dark:bg-gray-900",We&&"rounded-lg border border-gray-200 shadow-sm dark:border-gray-700",p.padding,y&&"opacity-60",Ve),...ze,children:[o("div",{className:c("flex flex-wrap",p.gap),children:Array.from({length:w},(t,a)=>rt(a))}),lt&&R("div",{className:c("mt-3 flex items-center justify-between gap-2 border-t border-gray-200 pt-3 dark:border-gray-700",p.footer),children:[o("div",{className:"text-gray-600 dark:text-gray-400",children:xe}),(ne||oe)&&R("div",{className:"flex items-center gap-2",children:[ne&&o("button",{type:"button",onClick:nt,disabled:y,className:c("rounded-md px-2 py-1 font-medium transition-colors","text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2",W[v],y&&"cursor-not-allowed opacity-50"),children:E?.today??B.calendarToday}),oe&&o("button",{type:"button",onClick:ot,disabled:y,className:c("rounded-md px-2 py-1 font-medium transition-colors","text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2",W[v],y&&"cursor-not-allowed opacity-50"),children:E?.clear??B.calendarClear})]})]})]})}export{St as Calendar};
@@ -1 +1 @@
1
- "use strict";"use client";var ee=Object.defineProperty;var be=Object.getOwnPropertyDescriptor;var pe=Object.getOwnPropertyNames;var ye=Object.prototype.hasOwnProperty;var Ce=(l,a)=>{for(var n in a)ee(l,n,{get:a[n],enumerable:!0})},ke=(l,a,n,o)=>{if(a&&typeof a=="object"||typeof a=="function")for(let u of pe(a))!ye.call(l,u)&&u!==n&&ee(l,u,{get:()=>a[u],enumerable:!(o=be(a,u))||o.enumerable});return l};var xe=l=>ke(ee({},"__esModule",{value:!0}),l);var Ne={};Ce(Ne,{CandlestickChart:()=>Pe});module.exports=xe(Ne);var h=require("react"),re=require("../../lib/i18n.cjs"),te=require("../chart/ChartAxis.cjs"),oe=require("../chart/ChartContainer.cjs"),le=require("../chart/ChartGrid.cjs"),ie=require("../chart/ChartLegend.cjs"),se=require("../chart/ChartTableView.cjs"),he=require("../chart/ChartTooltip.cjs"),Y=require("../chart/palette.cjs"),ue=require("../chart/utils/cartesian.cjs"),L=require("../chart/utils/data.cjs"),F=require("../chart/utils/format.cjs"),ce=require("../chart/utils/keyboard.cjs"),ge=require("../chart/utils/path.cjs"),me=require("../chart/utils/scales.cjs"),de=require("../chart/utils/touch.cjs"),e=require("react/jsx-runtime"),ve=16,we=1.5,Le=(0,h.memo)(function({candles:a}){return(0,e.jsx)("g",{children:a.map(n=>(0,e.jsxs)("g",{children:[n.wick?(0,e.jsx)("line",{x1:n.wick.x,y1:n.wick.y1,x2:n.wick.x,y2:n.wick.y2,stroke:n.color,strokeWidth:1.5}):null,n.body?(0,e.jsx)("path",{d:n.body,fill:n.hollow?"none":n.color,stroke:n.color,strokeWidth:n.hollow?1.5:0}):null]},n.key))})});function Re({width:l,height:a,data:n,candles:o,x:u,y,grid:R,size:W,candleSize:D,fillRising:P,palette:T,referenceLines:O,margin:z,tooltip:f,plotLabel:U,formatValue:b,formatX:E,onCandleClick:C}){let[x,N]=(0,h.useState)(null),c=x!==null&&x<o.length?x:null,k=(0,re.useUILabels)(),t=(0,h.useMemo)(()=>{let r=o.flatMap(i=>i.high===null||i.low===null?[]:[i.low,i.high]),g=(0,ue.buildCartesianGeometry)({width:l,height:a,data:n,x:u,y,bounds:r.length===0?null:[Math.min(...r),Math.max(...r)],margin:z,orientation:"vertical",placement:"band",formatValue:b,formatX:E,defaultIncludeZero:!1}),{valueScale:p,bandwidth:M,categoryPositions:G,innerWidth:q,innerHeight:_}=g,v=Math.min(D??ve,Math.max(1,M-2));return{rendered:o.map((i,$)=>{let V=G[$]+(M-v)/2,d=V+v/2,K=i.rising?T.up:T.down,S=i.high===null||i.low===null?null:{x:d,y1:p(i.high),y2:p(i.low)},X=null;if(i.open!==null&&i.close!==null){let w=p(i.open),B=p(i.close);X=(0,ge.buildBarPath)({x:V,y:Math.min(w,B),width:v,height:Math.max(we,Math.abs(B-w)),radius:0,round:"none"})}return{key:`${$}`,color:K,body:X,hollow:i.rising&&!P,wick:S,left:V,width:v}}),categoryPositions:G,categoryCenters:g.categoryCenters,bandwidth:M,categoryTicks:g.categoryTicks,valueTicks:g.valueTicks,valueScale:p,innerWidth:q,innerHeight:_,margin:g.margin}},[o,n,u,y,l,a,z,D,P,T,b,E]),j=(0,h.useCallback)(r=>{if(f===!1||o.length===0)return;let g=r.currentTarget.getBoundingClientRect(),p=r.clientX-g.left-t.margin.left;N((0,me.nearestIndex)(t.categoryCenters,p))},[f,o.length,t.margin.left,t.categoryCenters]),H=(0,h.useCallback)(()=>{!C||c===null||C(o[c])},[C,c,o]),Z=(0,h.useCallback)(r=>(0,ce.handleChartKeyDown)(r,{count:o.length,current:c,axis:"x",onMove:N,pick:C?H:null}),[o.length,c,C,H]),s=c===null?null:o[c];return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("svg",{width:l,height:a,role:"img","aria-label":U??o.map(r=>r.label).join(", "),tabIndex:0,className:`${de.CHART_TOUCH} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:j,onPointerLeave:()=>N(null),onKeyDown:Z,onBlur:()=>N(null),onClick:H,children:[(0,e.jsxs)("g",{transform:`translate(${t.margin.left}, ${t.margin.top})`,children:[(0,e.jsx)(le.ChartGrid,{width:t.innerWidth,height:t.innerHeight,horizontal:R==="y"||R==="both"?t.valueTicks.map(r=>r.offset):void 0}),c!==null?(0,e.jsx)("rect",{x:t.categoryPositions[c],y:0,width:t.bandwidth,height:t.innerHeight,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,O?.map(r=>(0,e.jsxs)("g",{children:[(0,e.jsx)("line",{x1:0,y1:t.valueScale(r.value),x2:t.innerWidth,y2:t.valueScale(r.value),stroke:r.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:r.dashed===!1?void 0:"4 4"}),r.label?(0,e.jsx)("text",{x:t.innerWidth,y:t.valueScale(r.value)-4,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:r.label}):null]},`${r.value}-${r.label??""}`)),(0,e.jsx)(Le,{candles:t.rendered})]}),(0,e.jsx)("g",{transform:`translate(${t.margin.left}, ${t.margin.top+t.innerHeight})`,children:u.hidden?null:(0,e.jsx)(te.ChartAxis,{orientation:"bottom",ticks:t.categoryTicks,length:t.innerWidth,label:u.label,size:W})}),(0,e.jsx)("g",{transform:`translate(${t.margin.left}, ${t.margin.top})`,children:y?.hidden?null:(0,e.jsx)(te.ChartAxis,{orientation:"left",ticks:t.valueTicks,length:t.innerHeight,showLine:!1,label:y?.label,size:W})})]}),s&&c!==null&&f!==!1?(0,e.jsx)(he.ChartTooltip,{x:t.margin.left+t.categoryCenters[c],y:t.margin.top+(s.high===null?t.innerHeight/2:t.valueScale(s.high)),containerWidth:l,children:typeof f=="function"?f(s):(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:s.label}),(0,e.jsx)("dl",{className:"grid grid-cols-[auto_auto] gap-x-3 gap-y-0.5",children:[[k.chartOpen,s.open],[k.chartHigh,s.high],[k.chartLow,s.low],[k.chartClose,s.close]].map(([r,g])=>(0,e.jsxs)("div",{className:"contents",children:[(0,e.jsx)("dt",{className:"text-gray-500 dark:text-gray-400",children:r}),(0,e.jsx)("dd",{className:"justify-self-end font-medium text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:g===null?"\u2014":b(g)})]},r))}),s.change===null?null:(0,e.jsxs)("div",{className:"flex items-center gap-2 border-t border-gray-200 pt-1 dark:border-gray-700",children:[(0,e.jsx)("span",{className:"text-gray-500 dark:text-gray-400",children:s.rising?k.chartRise:k.chartFall}),(0,e.jsxs)("span",{className:"[font-variant-numeric:tabular-nums] font-semibold text-gray-900 dark:text-gray-100",children:[s.change>0?"+":"",b(s.change)]})]})]})}):null]})}function Pe({data:l,x:a,y:n,open:o,high:u,low:y,close:R,candleSize:W,fillRising:D=!1,colors:P,referenceLines:T,height:O=300,width:z,size:f="md",grid:U="y",legend:b,tooltip:E=!0,tableView:C=!1,title:x,description:N,loading:c=!1,emptyState:k,error:t=!1,errorState:j,onRetry:H,actions:Z,margin:s,locale:r,plotLabel:g,openLabel:p,highLabel:M,lowLabel:G,closeLabel:q,riseLabel:_,fallLabel:v,format:J,onCandleClick:i,className:$,...V}){let d=(0,re.useUILabels)(),K=(0,h.useMemo)(()=>n?.format??J??(m=>(0,F.formatAuto)(m,r)),[n?.format,J,r]),S=(0,h.useMemo)(()=>a.format??(m=>(0,F.formatXValue)(m,r)),[a.format,r]),X=(0,h.useMemo)(()=>l.map((m,Q)=>{let ae=(0,L.readXValue)(m,a.key,Q),A=(0,L.readNumber)(m,o),I=(0,L.readNumber)(m,R);return{index:Q,x:ae,label:S(ae,Q),open:A,high:(0,L.readNumber)(m,u),low:(0,L.readNumber)(m,y),close:I,change:A===null||I===null?null:I-A,rising:A===null||I===null?!0:I>=A,datum:m}}),[l,a.key,o,u,y,R,S]),w=(0,h.useMemo)(()=>({up:P?.up??Y.CHART_UP_COLOR,down:P?.down??Y.CHART_DOWN_COLOR}),[P]),B=(0,h.useMemo)(()=>[{key:"up",label:_??d.chartRise,color:w.up,marker:"rect"},{key:"down",label:v??d.chartFall,color:w.down,marker:"rect"}],[w,_,v,d.chartRise,d.chartFall]),fe=b===void 0?!0:b!==!1,ne=typeof b=="string"?b:"bottom";return(0,e.jsx)(oe.ChartContainer,{title:x,description:N,height:O,width:z,size:f,loading:c,empty:X.length===0,emptyState:k,error:t,errorState:j,onRetry:H,actions:Z,tableView:C,legendPosition:ne,legend:fe?(0,e.jsx)(ie.ChartLegend,{items:B,position:ne,marker:"rect",size:f}):void 0,table:C?(0,e.jsx)(se.ChartTableView,{data:l,series:[{key:o,label:p??d.chartOpen},{key:u,label:M??d.chartHigh},{key:y,label:G??d.chartLow},{key:R,label:q??d.chartClose}],xKey:a.key,xLabel:a.label??a.key,formatX:S,formatValue:K,caption:typeof x=="string"?x:void 0}):void 0,className:$,...V,children:({width:m})=>(0,e.jsx)(Re,{width:m,height:O,data:l,candles:X,x:a,y:n,grid:U,size:f,candleSize:W,fillRising:D,palette:w,referenceLines:T,margin:s,tooltip:E,plotLabel:g,formatValue:K,formatX:S,onCandleClick:i})})}0&&(module.exports={CandlestickChart});
1
+ "use strict";"use client";var te=Object.defineProperty;var pe=Object.getOwnPropertyDescriptor;var ye=Object.getOwnPropertyNames;var Ce=Object.prototype.hasOwnProperty;var ke=(l,a)=>{for(var n in a)te(l,n,{get:a[n],enumerable:!0})},xe=(l,a,n,o)=>{if(a&&typeof a=="object"||typeof a=="function")for(let h of ye(a))!Ce.call(l,h)&&h!==n&&te(l,h,{get:()=>a[h],enumerable:!(o=pe(a,h))||o.enumerable});return l};var ve=l=>xe(te({},"__esModule",{value:!0}),l);var Se={};ke(Se,{CandlestickChart:()=>Ne});module.exports=ve(Se);var c=require("react"),D=require("../../lib/i18n.cjs"),re=require("../chart/ChartAxis.cjs"),oe=require("../chart/ChartContainer.cjs"),le=require("../chart/ChartGrid.cjs"),ie=require("../chart/ChartLegend.cjs"),se=require("../chart/ChartTableView.cjs"),ce=require("../chart/ChartTooltip.cjs"),U=require("../chart/palette.cjs"),he=require("../chart/utils/cartesian.cjs"),R=require("../chart/utils/data.cjs"),F=require("../chart/utils/format.cjs"),ue=require("../chart/utils/keyboard.cjs"),ge=require("../chart/utils/path.cjs"),me=require("../chart/utils/scales.cjs"),de=require("../chart/utils/touch.cjs"),e=require("react/jsx-runtime"),we=16,Le=1.5,Re=(0,c.memo)(function({candles:a}){return(0,e.jsx)("g",{children:a.map(n=>(0,e.jsxs)("g",{children:[n.wick?(0,e.jsx)("line",{x1:n.wick.x,y1:n.wick.y1,x2:n.wick.x,y2:n.wick.y2,stroke:n.color,strokeWidth:1.5}):null,n.body?(0,e.jsx)("path",{d:n.body,fill:n.hollow?"none":n.color,stroke:n.color,strokeWidth:n.hollow?1.5:0}):null]},n.key))})});function Pe({width:l,height:a,data:n,candles:o,x:h,y,grid:P,size:O,candleSize:z,fillRising:N,palette:H,referenceLines:E,margin:G,tooltip:f,plotLabel:j,formatValue:b,formatX:_,onCandleClick:C}){let[x,S]=(0,c.useState)(null),u=x!==null&&x<o.length?x:null,k=(0,D.useUILabels)(),t=(0,c.useMemo)(()=>{let r=o.flatMap(i=>i.high===null||i.low===null?[]:[i.low,i.high]),g=(0,he.buildCartesianGeometry)({width:l,height:a,data:n,x:h,y,bounds:r.length===0?null:[Math.min(...r),Math.max(...r)],margin:G,orientation:"vertical",placement:"band",formatValue:b,formatX:_,defaultIncludeZero:!1}),{valueScale:p,bandwidth:I,categoryPositions:$,innerWidth:J,innerHeight:K}=g,v=Math.min(z??we,Math.max(1,I-2));return{rendered:o.map((i,B)=>{let V=$[B]+(I-v)/2,T=V+v/2,d=i.rising?H.up:H.down,Y=i.high===null||i.low===null?null:{x:T,y1:p(i.high),y2:p(i.low)},w=null;if(i.open!==null&&i.close!==null){let X=p(i.open),L=p(i.close);w=(0,ge.buildBarPath)({x:V,y:Math.min(X,L),width:v,height:Math.max(Le,Math.abs(L-X)),radius:0,round:"none"})}return{key:`${B}`,color:d,body:w,hollow:i.rising&&!N,wick:Y,left:V,width:v}}),categoryPositions:$,categoryCenters:g.categoryCenters,bandwidth:I,categoryTicks:g.categoryTicks,valueTicks:g.valueTicks,valueScale:p,innerWidth:J,innerHeight:K,margin:g.margin}},[o,n,h,y,l,a,G,z,N,H,b,_]),Z=(0,c.useCallback)(r=>{if(f===!1||o.length===0)return;let g=r.currentTarget.getBoundingClientRect(),p=r.clientX-g.left-t.margin.left;S((0,me.nearestIndex)(t.categoryCenters,p))},[f,o.length,t.margin.left,t.categoryCenters]),M=(0,c.useCallback)(()=>{!C||u===null||C(o[u])},[C,u,o]),q=(0,c.useCallback)(r=>(0,ue.handleChartKeyDown)(r,{count:o.length,current:u,axis:"x",onMove:S,pick:C?M:null}),[o.length,u,C,M]),s=u===null?null:o[u];return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("svg",{width:l,height:a,role:"img","aria-label":j??o.map(r=>r.label).join(", "),tabIndex:0,className:`${de.CHART_TOUCH} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:Z,onPointerLeave:()=>S(null),onKeyDown:q,onBlur:()=>S(null),onClick:M,children:[(0,e.jsxs)("g",{transform:`translate(${t.margin.left}, ${t.margin.top})`,children:[(0,e.jsx)(le.ChartGrid,{width:t.innerWidth,height:t.innerHeight,horizontal:P==="y"||P==="both"?t.valueTicks.map(r=>r.offset):void 0}),u!==null?(0,e.jsx)("rect",{x:t.categoryPositions[u],y:0,width:t.bandwidth,height:t.innerHeight,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,E?.map(r=>(0,e.jsxs)("g",{children:[(0,e.jsx)("line",{x1:0,y1:t.valueScale(r.value),x2:t.innerWidth,y2:t.valueScale(r.value),stroke:r.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:r.dashed===!1?void 0:"4 4"}),r.label?(0,e.jsx)("text",{x:t.innerWidth,y:t.valueScale(r.value)-4,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:r.label}):null]},`${r.value}-${r.label??""}`)),(0,e.jsx)(Re,{candles:t.rendered})]}),(0,e.jsx)("g",{transform:`translate(${t.margin.left}, ${t.margin.top+t.innerHeight})`,children:h.hidden?null:(0,e.jsx)(re.ChartAxis,{orientation:"bottom",ticks:t.categoryTicks,length:t.innerWidth,label:h.label,size:O})}),(0,e.jsx)("g",{transform:`translate(${t.margin.left}, ${t.margin.top})`,children:y?.hidden?null:(0,e.jsx)(re.ChartAxis,{orientation:"left",ticks:t.valueTicks,length:t.innerHeight,showLine:!1,label:y?.label,size:O})})]}),s&&u!==null&&f!==!1?(0,e.jsx)(ce.ChartTooltip,{x:t.margin.left+t.categoryCenters[u],y:t.margin.top+(s.high===null?t.innerHeight/2:t.valueScale(s.high)),containerWidth:l,children:typeof f=="function"?f(s):(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:s.label}),(0,e.jsx)("dl",{className:"grid grid-cols-[auto_auto] gap-x-3 gap-y-0.5",children:[[k.chartOpen,s.open],[k.chartHigh,s.high],[k.chartLow,s.low],[k.chartClose,s.close]].map(([r,g])=>(0,e.jsxs)("div",{className:"contents",children:[(0,e.jsx)("dt",{className:"text-gray-500 dark:text-gray-400",children:r}),(0,e.jsx)("dd",{className:"justify-self-end font-medium text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:g===null?"\u2014":b(g)})]},r))}),s.change===null?null:(0,e.jsxs)("div",{className:"flex items-center gap-2 border-t border-gray-200 pt-1 dark:border-gray-700",children:[(0,e.jsx)("span",{className:"text-gray-500 dark:text-gray-400",children:s.rising?k.chartRise:k.chartFall}),(0,e.jsxs)("span",{className:"[font-variant-numeric:tabular-nums] font-semibold text-gray-900 dark:text-gray-100",children:[s.change>0?"+":"",b(s.change)]})]})]})}):null]})}function Ne({data:l,x:a,y:n,open:o,high:h,low:y,close:P,candleSize:O,fillRising:z=!1,colors:N,referenceLines:H,height:E=300,width:G,size:f="md",grid:j="y",legend:b,tooltip:_=!0,tableView:C=!1,title:x,description:S,loading:u=!1,emptyState:k,error:t=!1,errorState:Z,onRetry:M,actions:q,margin:s,locale:r,plotLabel:g,openLabel:p,highLabel:I,lowLabel:$,closeLabel:J,riseLabel:K,fallLabel:v,format:Q,onCandleClick:i,className:B,...V}){let T=(0,D.useUILocale)(r),d=(0,D.useUILabels)(),Y=(0,c.useMemo)(()=>n?.format??Q??(m=>(0,F.formatAuto)(m,T)),[n?.format,Q,T]),w=(0,c.useMemo)(()=>a.format??(m=>(0,F.formatXValue)(m,T)),[a.format,T]),X=(0,c.useMemo)(()=>l.map((m,ee)=>{let ae=(0,R.readXValue)(m,a.key,ee),A=(0,R.readNumber)(m,o),W=(0,R.readNumber)(m,P);return{index:ee,x:ae,label:w(ae,ee),open:A,high:(0,R.readNumber)(m,h),low:(0,R.readNumber)(m,y),close:W,change:A===null||W===null?null:W-A,rising:A===null||W===null?!0:W>=A,datum:m}}),[l,a.key,o,h,y,P,w]),L=(0,c.useMemo)(()=>({up:N?.up??U.CHART_UP_COLOR,down:N?.down??U.CHART_DOWN_COLOR}),[N]),fe=(0,c.useMemo)(()=>[{key:"up",label:K??d.chartRise,color:L.up,marker:"rect"},{key:"down",label:v??d.chartFall,color:L.down,marker:"rect"}],[L,K,v,d.chartRise,d.chartFall]),be=b===void 0?!0:b!==!1,ne=typeof b=="string"?b:"bottom";return(0,e.jsx)(oe.ChartContainer,{title:x,description:S,height:E,width:G,size:f,loading:u,empty:X.length===0,emptyState:k,error:t,errorState:Z,onRetry:M,actions:q,tableView:C,legendPosition:ne,legend:be?(0,e.jsx)(ie.ChartLegend,{items:fe,position:ne,marker:"rect",size:f}):void 0,table:C?(0,e.jsx)(se.ChartTableView,{data:l,series:[{key:o,label:p??d.chartOpen},{key:h,label:I??d.chartHigh},{key:y,label:$??d.chartLow},{key:P,label:J??d.chartClose}],xKey:a.key,xLabel:a.label??a.key,formatX:w,formatValue:Y,caption:typeof x=="string"?x:void 0}):void 0,className:B,...V,children:({width:m})=>(0,e.jsx)(Pe,{width:m,height:E,data:l,candles:X,x:a,y:n,grid:j,size:f,candleSize:O,fillRising:z,palette:L,referenceLines:H,margin:s,tooltip:_,plotLabel:g,formatValue:Y,formatX:w,onCandleClick:i})})}0&&(module.exports={CandlestickChart});
@@ -1 +1 @@
1
- "use client";import{memo as oe,useCallback as Q,useMemo as S,useState as le}from"react";import{useUILabels as ne}from"../../lib/i18n.js";import{ChartAxis as re}from"../chart/ChartAxis.js";import{ChartContainer as ie}from"../chart/ChartContainer.js";import{ChartGrid as se}from"../chart/ChartGrid.js";import{ChartLegend as he}from"../chart/ChartLegend.js";import{ChartTableView as ue}from"../chart/ChartTableView.js";import{ChartTooltip as ce}from"../chart/ChartTooltip.js";import{CHART_DOWN_COLOR as ge,CHART_UP_COLOR as me}from"../chart/palette.js";import{buildCartesianGeometry as de}from"../chart/utils/cartesian.js";import{readNumber as Y,readXValue as fe}from"../chart/utils/data.js";import{formatAuto as be,formatXValue as pe}from"../chart/utils/format.js";import{handleChartKeyDown as ye}from"../chart/utils/keyboard.js";import{buildBarPath as Ce}from"../chart/utils/path.js";import{nearestIndex as ke}from"../chart/utils/scales.js";import{CHART_TOUCH as xe}from"../chart/utils/touch.js";import{Fragment as Pe,jsx as r,jsxs as b}from"react/jsx-runtime";var ve=16,we=1.5,Le=oe(function({candles:i}){return r("g",{children:i.map(n=>b("g",{children:[n.wick?r("line",{x1:n.wick.x,y1:n.wick.y1,x2:n.wick.x,y2:n.wick.y2,stroke:n.color,strokeWidth:1.5}):null,n.body?r("path",{d:n.body,fill:n.hollow?"none":n.color,stroke:n.color,strokeWidth:n.hollow?1.5:0}):null]},n.key))})});function Re({width:c,height:i,data:n,candles:o,x:p,y,grid:L,size:W,candleSize:D,fillRising:R,palette:T,referenceLines:O,margin:z,tooltip:m,plotLabel:F,formatValue:d,formatX:E,onCandleClick:C}){let[x,P]=le(null),s=x!==null&&x<o.length?x:null,k=ne(),e=S(()=>{let t=o.flatMap(a=>a.high===null||a.low===null?[]:[a.low,a.high]),h=de({width:c,height:i,data:n,x:p,y,bounds:t.length===0?null:[Math.min(...t),Math.max(...t)],margin:z,orientation:"vertical",placement:"band",formatValue:d,formatX:E,defaultIncludeZero:!1}),{valueScale:f,bandwidth:M,categoryPositions:G,innerWidth:Z,innerHeight:_}=h,v=Math.min(D??ve,Math.max(1,M-2));return{rendered:o.map((a,$)=>{let V=G[$]+(M-v)/2,g=V+v/2,K=a.rising?T.up:T.down,N=a.high===null||a.low===null?null:{x:g,y1:f(a.high),y2:f(a.low)},X=null;if(a.open!==null&&a.close!==null){let w=f(a.open),B=f(a.close);X=Ce({x:V,y:Math.min(w,B),width:v,height:Math.max(we,Math.abs(B-w)),radius:0,round:"none"})}return{key:`${$}`,color:K,body:X,hollow:a.rising&&!R,wick:N,left:V,width:v}}),categoryPositions:G,categoryCenters:h.categoryCenters,bandwidth:M,categoryTicks:h.categoryTicks,valueTicks:h.valueTicks,valueScale:f,innerWidth:Z,innerHeight:_,margin:h.margin}},[o,n,p,y,c,i,z,D,R,T,d,E]),U=Q(t=>{if(m===!1||o.length===0)return;let h=t.currentTarget.getBoundingClientRect(),f=t.clientX-h.left-e.margin.left;P(ke(e.categoryCenters,f))},[m,o.length,e.margin.left,e.categoryCenters]),H=Q(()=>{!C||s===null||C(o[s])},[C,s,o]),j=Q(t=>ye(t,{count:o.length,current:s,axis:"x",onMove:P,pick:C?H:null}),[o.length,s,C,H]),l=s===null?null:o[s];return b(Pe,{children:[b("svg",{width:c,height:i,role:"img","aria-label":F??o.map(t=>t.label).join(", "),tabIndex:0,className:`${xe} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:U,onPointerLeave:()=>P(null),onKeyDown:j,onBlur:()=>P(null),onClick:H,children:[b("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[r(se,{width:e.innerWidth,height:e.innerHeight,horizontal:L==="y"||L==="both"?e.valueTicks.map(t=>t.offset):void 0}),s!==null?r("rect",{x:e.categoryPositions[s],y:0,width:e.bandwidth,height:e.innerHeight,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,O?.map(t=>b("g",{children:[r("line",{x1:0,y1:e.valueScale(t.value),x2:e.innerWidth,y2:e.valueScale(t.value),stroke:t.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:t.dashed===!1?void 0:"4 4"}),t.label?r("text",{x:e.innerWidth,y:e.valueScale(t.value)-4,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:t.label}):null]},`${t.value}-${t.label??""}`)),r(Le,{candles:e.rendered})]}),r("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:p.hidden?null:r(re,{orientation:"bottom",ticks:e.categoryTicks,length:e.innerWidth,label:p.label,size:W})}),r("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:y?.hidden?null:r(re,{orientation:"left",ticks:e.valueTicks,length:e.innerHeight,showLine:!1,label:y?.label,size:W})})]}),l&&s!==null&&m!==!1?r(ce,{x:e.margin.left+e.categoryCenters[s],y:e.margin.top+(l.high===null?e.innerHeight/2:e.valueScale(l.high)),containerWidth:c,children:typeof m=="function"?m(l):b("div",{className:"flex flex-col gap-1",children:[r("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:l.label}),r("dl",{className:"grid grid-cols-[auto_auto] gap-x-3 gap-y-0.5",children:[[k.chartOpen,l.open],[k.chartHigh,l.high],[k.chartLow,l.low],[k.chartClose,l.close]].map(([t,h])=>b("div",{className:"contents",children:[r("dt",{className:"text-gray-500 dark:text-gray-400",children:t}),r("dd",{className:"justify-self-end font-medium text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:h===null?"\u2014":d(h)})]},t))}),l.change===null?null:b("div",{className:"flex items-center gap-2 border-t border-gray-200 pt-1 dark:border-gray-700",children:[r("span",{className:"text-gray-500 dark:text-gray-400",children:l.rising?k.chartRise:k.chartFall}),b("span",{className:"[font-variant-numeric:tabular-nums] font-semibold text-gray-900 dark:text-gray-100",children:[l.change>0?"+":"",d(l.change)]})]})]})}):null]})}function $e({data:c,x:i,y:n,open:o,high:p,low:y,close:L,candleSize:W,fillRising:D=!1,colors:R,referenceLines:T,height:O=300,width:z,size:m="md",grid:F="y",legend:d,tooltip:E=!0,tableView:C=!1,title:x,description:P,loading:s=!1,emptyState:k,error:e=!1,errorState:U,onRetry:H,actions:j,margin:l,locale:t,plotLabel:h,openLabel:f,highLabel:M,lowLabel:G,closeLabel:Z,riseLabel:_,fallLabel:v,format:q,onCandleClick:a,className:$,...V}){let g=ne(),K=S(()=>n?.format??q??(u=>be(u,t)),[n?.format,q,t]),N=S(()=>i.format??(u=>pe(u,t)),[i.format,t]),X=S(()=>c.map((u,J)=>{let te=fe(u,i.key,J),A=Y(u,o),I=Y(u,L);return{index:J,x:te,label:N(te,J),open:A,high:Y(u,p),low:Y(u,y),close:I,change:A===null||I===null?null:I-A,rising:A===null||I===null?!0:I>=A,datum:u}}),[c,i.key,o,p,y,L,N]),w=S(()=>({up:R?.up??me,down:R?.down??ge}),[R]),B=S(()=>[{key:"up",label:_??g.chartRise,color:w.up,marker:"rect"},{key:"down",label:v??g.chartFall,color:w.down,marker:"rect"}],[w,_,v,g.chartRise,g.chartFall]),ae=d===void 0?!0:d!==!1,ee=typeof d=="string"?d:"bottom";return r(ie,{title:x,description:P,height:O,width:z,size:m,loading:s,empty:X.length===0,emptyState:k,error:e,errorState:U,onRetry:H,actions:j,tableView:C,legendPosition:ee,legend:ae?r(he,{items:B,position:ee,marker:"rect",size:m}):void 0,table:C?r(ue,{data:c,series:[{key:o,label:f??g.chartOpen},{key:p,label:M??g.chartHigh},{key:y,label:G??g.chartLow},{key:L,label:Z??g.chartClose}],xKey:i.key,xLabel:i.label??i.key,formatX:N,formatValue:K,caption:typeof x=="string"?x:void 0}):void 0,className:$,...V,children:({width:u})=>r(Re,{width:u,height:O,data:c,candles:X,x:i,y:n,grid:F,size:m,candleSize:W,fillRising:D,palette:w,referenceLines:T,margin:l,tooltip:E,plotLabel:h,formatValue:K,formatX:N,onCandleClick:a})})}export{$e as CandlestickChart};
1
+ "use client";import{memo as le,useCallback as Q,useMemo as T,useState as ie}from"react";import{useUILabels as ne,useUILocale as se}from"../../lib/i18n.js";import{ChartAxis as re}from"../chart/ChartAxis.js";import{ChartContainer as ce}from"../chart/ChartContainer.js";import{ChartGrid as he}from"../chart/ChartGrid.js";import{ChartLegend as ue}from"../chart/ChartLegend.js";import{ChartTableView as ge}from"../chart/ChartTableView.js";import{ChartTooltip as me}from"../chart/ChartTooltip.js";import{CHART_DOWN_COLOR as de,CHART_UP_COLOR as fe}from"../chart/palette.js";import{buildCartesianGeometry as be}from"../chart/utils/cartesian.js";import{readNumber as Y,readXValue as pe}from"../chart/utils/data.js";import{formatAuto as ye,formatXValue as Ce}from"../chart/utils/format.js";import{handleChartKeyDown as ke}from"../chart/utils/keyboard.js";import{buildBarPath as xe}from"../chart/utils/path.js";import{nearestIndex as ve}from"../chart/utils/scales.js";import{CHART_TOUCH as we}from"../chart/utils/touch.js";import{Fragment as Se,jsx as r,jsxs as b}from"react/jsx-runtime";var Le=16,Re=1.5,Pe=le(function({candles:i}){return r("g",{children:i.map(n=>b("g",{children:[n.wick?r("line",{x1:n.wick.x,y1:n.wick.y1,x2:n.wick.x,y2:n.wick.y2,stroke:n.color,strokeWidth:1.5}):null,n.body?r("path",{d:n.body,fill:n.hollow?"none":n.color,stroke:n.color,strokeWidth:n.hollow?1.5:0}):null]},n.key))})});function Ne({width:u,height:i,data:n,candles:o,x:p,y,grid:R,size:D,candleSize:O,fillRising:P,palette:H,referenceLines:z,margin:E,tooltip:m,plotLabel:U,formatValue:d,formatX:G,onCandleClick:C}){let[x,N]=ie(null),s=x!==null&&x<o.length?x:null,k=ne(),e=T(()=>{let t=o.flatMap(a=>a.high===null||a.low===null?[]:[a.low,a.high]),c=be({width:u,height:i,data:n,x:p,y,bounds:t.length===0?null:[Math.min(...t),Math.max(...t)],margin:E,orientation:"vertical",placement:"band",formatValue:d,formatX:G,defaultIncludeZero:!1}),{valueScale:f,bandwidth:I,categoryPositions:_,innerWidth:Z,innerHeight:$}=c,v=Math.min(O??Le,Math.max(1,I-2));return{rendered:o.map((a,K)=>{let V=_[K]+(I-v)/2,S=V+v/2,g=a.rising?H.up:H.down,B=a.high===null||a.low===null?null:{x:S,y1:f(a.high),y2:f(a.low)},w=null;if(a.open!==null&&a.close!==null){let X=f(a.open),L=f(a.close);w=xe({x:V,y:Math.min(X,L),width:v,height:Math.max(Re,Math.abs(L-X)),radius:0,round:"none"})}return{key:`${K}`,color:g,body:w,hollow:a.rising&&!P,wick:B,left:V,width:v}}),categoryPositions:_,categoryCenters:c.categoryCenters,bandwidth:I,categoryTicks:c.categoryTicks,valueTicks:c.valueTicks,valueScale:f,innerWidth:Z,innerHeight:$,margin:c.margin}},[o,n,p,y,u,i,E,O,P,H,d,G]),F=Q(t=>{if(m===!1||o.length===0)return;let c=t.currentTarget.getBoundingClientRect(),f=t.clientX-c.left-e.margin.left;N(ve(e.categoryCenters,f))},[m,o.length,e.margin.left,e.categoryCenters]),M=Q(()=>{!C||s===null||C(o[s])},[C,s,o]),j=Q(t=>ke(t,{count:o.length,current:s,axis:"x",onMove:N,pick:C?M:null}),[o.length,s,C,M]),l=s===null?null:o[s];return b(Se,{children:[b("svg",{width:u,height:i,role:"img","aria-label":U??o.map(t=>t.label).join(", "),tabIndex:0,className:`${we} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:F,onPointerLeave:()=>N(null),onKeyDown:j,onBlur:()=>N(null),onClick:M,children:[b("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[r(he,{width:e.innerWidth,height:e.innerHeight,horizontal:R==="y"||R==="both"?e.valueTicks.map(t=>t.offset):void 0}),s!==null?r("rect",{x:e.categoryPositions[s],y:0,width:e.bandwidth,height:e.innerHeight,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,z?.map(t=>b("g",{children:[r("line",{x1:0,y1:e.valueScale(t.value),x2:e.innerWidth,y2:e.valueScale(t.value),stroke:t.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:t.dashed===!1?void 0:"4 4"}),t.label?r("text",{x:e.innerWidth,y:e.valueScale(t.value)-4,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:t.label}):null]},`${t.value}-${t.label??""}`)),r(Pe,{candles:e.rendered})]}),r("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:p.hidden?null:r(re,{orientation:"bottom",ticks:e.categoryTicks,length:e.innerWidth,label:p.label,size:D})}),r("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:y?.hidden?null:r(re,{orientation:"left",ticks:e.valueTicks,length:e.innerHeight,showLine:!1,label:y?.label,size:D})})]}),l&&s!==null&&m!==!1?r(me,{x:e.margin.left+e.categoryCenters[s],y:e.margin.top+(l.high===null?e.innerHeight/2:e.valueScale(l.high)),containerWidth:u,children:typeof m=="function"?m(l):b("div",{className:"flex flex-col gap-1",children:[r("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:l.label}),r("dl",{className:"grid grid-cols-[auto_auto] gap-x-3 gap-y-0.5",children:[[k.chartOpen,l.open],[k.chartHigh,l.high],[k.chartLow,l.low],[k.chartClose,l.close]].map(([t,c])=>b("div",{className:"contents",children:[r("dt",{className:"text-gray-500 dark:text-gray-400",children:t}),r("dd",{className:"justify-self-end font-medium text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:c===null?"\u2014":d(c)})]},t))}),l.change===null?null:b("div",{className:"flex items-center gap-2 border-t border-gray-200 pt-1 dark:border-gray-700",children:[r("span",{className:"text-gray-500 dark:text-gray-400",children:l.rising?k.chartRise:k.chartFall}),b("span",{className:"[font-variant-numeric:tabular-nums] font-semibold text-gray-900 dark:text-gray-100",children:[l.change>0?"+":"",d(l.change)]})]})]})}):null]})}function Be({data:u,x:i,y:n,open:o,high:p,low:y,close:R,candleSize:D,fillRising:O=!1,colors:P,referenceLines:H,height:z=300,width:E,size:m="md",grid:U="y",legend:d,tooltip:G=!0,tableView:C=!1,title:x,description:N,loading:s=!1,emptyState:k,error:e=!1,errorState:F,onRetry:M,actions:j,margin:l,locale:t,plotLabel:c,openLabel:f,highLabel:I,lowLabel:_,closeLabel:Z,riseLabel:$,fallLabel:v,format:q,onCandleClick:a,className:K,...V}){let S=se(t),g=ne(),B=T(()=>n?.format??q??(h=>ye(h,S)),[n?.format,q,S]),w=T(()=>i.format??(h=>Ce(h,S)),[i.format,S]),X=T(()=>u.map((h,J)=>{let te=pe(h,i.key,J),A=Y(h,o),W=Y(h,R);return{index:J,x:te,label:w(te,J),open:A,high:Y(h,p),low:Y(h,y),close:W,change:A===null||W===null?null:W-A,rising:A===null||W===null?!0:W>=A,datum:h}}),[u,i.key,o,p,y,R,w]),L=T(()=>({up:P?.up??fe,down:P?.down??de}),[P]),ae=T(()=>[{key:"up",label:$??g.chartRise,color:L.up,marker:"rect"},{key:"down",label:v??g.chartFall,color:L.down,marker:"rect"}],[L,$,v,g.chartRise,g.chartFall]),oe=d===void 0?!0:d!==!1,ee=typeof d=="string"?d:"bottom";return r(ce,{title:x,description:N,height:z,width:E,size:m,loading:s,empty:X.length===0,emptyState:k,error:e,errorState:F,onRetry:M,actions:j,tableView:C,legendPosition:ee,legend:oe?r(ue,{items:ae,position:ee,marker:"rect",size:m}):void 0,table:C?r(ge,{data:u,series:[{key:o,label:f??g.chartOpen},{key:p,label:I??g.chartHigh},{key:y,label:_??g.chartLow},{key:R,label:Z??g.chartClose}],xKey:i.key,xLabel:i.label??i.key,formatX:w,formatValue:B,caption:typeof x=="string"?x:void 0}):void 0,className:K,...V,children:({width:h})=>r(Ne,{width:h,height:z,data:u,candles:X,x:i,y:n,grid:U,size:m,candleSize:D,fillRising:O,palette:L,referenceLines:H,margin:l,tooltip:G,plotLabel:c,formatValue:B,formatX:w,onCandleClick:a})})}export{Be as CandlestickChart};
@@ -1 +1 @@
1
- "use strict";"use client";var C=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var ee=Object.prototype.hasOwnProperty;var te=(n,o)=>{for(var c in o)C(n,c,{get:o[c],enumerable:!0})},re=(n,o,c,u)=>{if(o&&typeof o=="object"||typeof o=="function")for(let d of Z(o))!ee.call(n,d)&&d!==c&&C(n,d,{get:()=>o[d],enumerable:!(u=X(o,d))||u.enumerable});return n};var oe=n=>re(C({},"__esModule",{value:!0}),n);var de={};te(de,{ChartPeriodPicker:()=>se});module.exports=oe(de);var t=require("react"),T=require("react-dom"),O=require("../../lib/aria-hide.cjs"),b=require("../../lib/cn.cjs"),N=require("../../lib/i18n.cjs"),z=require("../calendar/Calendar.cjs"),I=require("../dropdown/hooks/usePositioning.cjs"),a=require("./utils/period.cjs"),r=require("react/jsx-runtime"),ae={"7d":"chartPeriodLast7Days","30d":"chartPeriodLast30Days","90d":"chartPeriodLast90Days","12m":"chartPeriodLast12Months",mtd:"chartPeriodMonthToDate",qtd:"chartPeriodQuarterToDate",ytd:"chartPeriodYearToDate",custom:"chartPeriodCustom"},ne={sm:"h-7 px-2.5 text-xs",md:"h-8 px-3 text-sm",lg:"h-10 px-4 text-sm"},ie=(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,r.jsx)("path",{d:"M5 1.5v2M11 1.5v2M2.5 6h11M3.5 3h9a1 1 0 011 1v9a1 1 0 01-1 1h-9a1 1 0 01-1-1V4a1 1 0 011-1z",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})});function se({value:n,defaultValue:o,onChange:c,presets:u=a.DEFAULT_CHART_PERIOD_PRESETS,custom:d=!0,presetLabels:A,now:p,minDate:F,maxDate:W,numberOfMonths:H=1,weekStartsOn:U,locale:k,size:_="md",align:B="start",disabled:K=!1,label:x,className:q,...Y}){let g=(0,N.useUILabels)(),m=(0,t.useRef)(null),f=(0,t.useRef)(null),D=(0,t.useRef)(null),[i,L]=(0,t.useState)(!1),[E,R]=(0,t.useState)(!1),[$,w]=(0,t.useState)(null),[Q,j]=(0,t.useState)(()=>typeof o=="string"?(0,a.createPeriod)(o,p):o||(0,a.createPeriod)(u[0]??"30d",p)),s=n??Q,P=(0,I.usePositioning)({triggerRef:m,contentRef:f,isOpen:i,side:"bottom",align:B}),l=(0,t.useCallback)((e=!0)=>{L(!1),R(!1),w(null),e&&m.current?.focus()},[]);(0,t.useEffect)(()=>{if(!i)return;let e=y=>{let S=y.target;f.current?.contains(S)||m.current?.contains(S)||l(!1)};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e,{passive:!0}),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}},[i,l]),(0,t.useEffect)(()=>{if(!i)return;let e=y=>{y.key==="Escape"&&(y.stopPropagation(),l())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[i,l]),(0,t.useEffect)(()=>{let e=f.current;if(e)return(0,O.registerFloatingLayer)(e,()=>m.current)},[i]),(0,t.useEffect)(()=>{if(!i)return;let e=requestAnimationFrame(()=>D.current?.focus());return()=>cancelAnimationFrame(e)},[i]);let h=(0,t.useCallback)(e=>{n===void 0&&j(e),c?.(e),l()},[n,c,l]),G=(0,t.useCallback)(e=>h((0,a.createPeriod)(e,p)),[h,p]),J=(0,t.useCallback)(e=>{w(e),!(!e.from||!e.to)&&h({preset:"custom",from:(0,a.startOfDay)(e.from),to:(0,a.endOfDay)(e.to)})},[h]),v=e=>A?.[e]??g[ae[e]],M=s.preset==="custom"?(0,a.formatPeriodRange)(s.from,s.to,k):v(s.preset),V=(0,r.jsxs)("div",{ref:f,role:"dialog","aria-label":x??g.chartPeriod,style:{position:"fixed",top:P.top,left:P.left,visibility:P.isReady?"visible":"hidden"},className:"z-50 flex overflow-hidden rounded-lg border border-gray-200 bg-white shadow-lg dark:border-gray-700 dark:bg-gray-800",children:[(0,r.jsxs)("div",{ref:D,tabIndex:-1,className:"flex min-w-44 flex-col p-1 outline-none",children:[u.map(e=>(0,r.jsx)("button",{type:"button","aria-pressed":s.preset===e,onClick:()=>G(e),className:(0,b.cn)("cursor-pointer rounded-md px-3 py-1.5 text-left text-sm text-gray-700 hover:bg-gray-100 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-synertech-primary-500 dark:text-gray-200 dark:hover:bg-gray-700",s.preset===e&&"bg-synertech-primary-50 font-medium text-synertech-primary-700 dark:bg-synertech-primary-950 dark:text-synertech-primary-300"),children:v(e)},e)),d?(0,r.jsx)("button",{type:"button","aria-pressed":s.preset==="custom","aria-expanded":E,onClick:()=>R(!0),className:(0,b.cn)("cursor-pointer rounded-md px-3 py-1.5 text-left text-sm text-gray-700 hover:bg-gray-100 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-synertech-primary-500 dark:text-gray-200 dark:hover:bg-gray-700",s.preset==="custom"&&"bg-synertech-primary-50 font-medium text-synertech-primary-700 dark:bg-synertech-primary-950 dark:text-synertech-primary-300"),children:v("custom")}):null]}),d&&E?(0,r.jsx)("div",{className:"border-l border-gray-200 p-2 dark:border-gray-700",children:(0,r.jsx)(z.Calendar,{mode:"range",value:$??{from:s.from,to:s.to},onChange:J,numberOfMonths:H,weekStartsOn:U,locale:k,minDate:F,maxDate:W,size:"sm"})}):null]});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("button",{ref:m,type:"button",disabled:K,"aria-haspopup":"dialog","aria-expanded":i,"aria-label":`${x??g.chartPeriod}: ${M}`,onClick:()=>i?l():L(!0),className:(0,b.cn)("inline-flex cursor-pointer items-center gap-2 rounded-full border border-gray-300 bg-white font-medium text-gray-700 transition-colors hover:bg-gray-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",ne[_],q),...Y,children:[ie,(0,r.jsx)("span",{children:M})]}),i&&typeof document<"u"?(0,T.createPortal)(V,document.body):null]})}0&&(module.exports={ChartPeriodPicker});
1
+ "use strict";"use client";var k=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var te=Object.prototype.hasOwnProperty;var re=(n,o)=>{for(var c in o)k(n,c,{get:o[c],enumerable:!0})},oe=(n,o,c,u)=>{if(o&&typeof o=="object"||typeof o=="function")for(let d of ee(o))!te.call(n,d)&&d!==c&&k(n,d,{get:()=>o[d],enumerable:!(u=Z(o,d))||u.enumerable});return n};var ae=n=>oe(k({},"__esModule",{value:!0}),n);var ce={};re(ce,{ChartPeriodPicker:()=>de});module.exports=ae(ce);var t=require("react"),O=require("react-dom"),I=require("../../lib/aria-hide.cjs"),b=require("../../lib/cn.cjs"),g=require("../../lib/i18n.cjs"),N=require("../calendar/Calendar.cjs"),z=require("../dropdown/hooks/usePositioning.cjs"),a=require("./utils/period.cjs"),r=require("react/jsx-runtime"),ne={"7d":"chartPeriodLast7Days","30d":"chartPeriodLast30Days","90d":"chartPeriodLast90Days","12m":"chartPeriodLast12Months",mtd:"chartPeriodMonthToDate",qtd:"chartPeriodQuarterToDate",ytd:"chartPeriodYearToDate",custom:"chartPeriodCustom"},ie={sm:"h-7 px-2.5 text-xs",md:"h-8 px-3 text-sm",lg:"h-10 px-4 text-sm"},se=(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,r.jsx)("path",{d:"M5 1.5v2M11 1.5v2M2.5 6h11M3.5 3h9a1 1 0 011 1v9a1 1 0 01-1 1h-9a1 1 0 01-1-1V4a1 1 0 011-1z",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})});function de({value:n,defaultValue:o,onChange:c,presets:u=a.DEFAULT_CHART_PERIOD_PRESETS,custom:d=!0,presetLabels:A,now:m,minDate:F,maxDate:U,numberOfMonths:W=1,weekStartsOn:H,locale:_,size:B="md",align:K="start",disabled:q=!1,label:x,className:Y,...$}){let P=(0,g.useUILabels)(),D=(0,g.useUILocale)(_),p=(0,t.useRef)(null),f=(0,t.useRef)(null),L=(0,t.useRef)(null),[i,E]=(0,t.useState)(!1),[R,w]=(0,t.useState)(!1),[Q,M]=(0,t.useState)(null),[j,G]=(0,t.useState)(()=>typeof o=="string"?(0,a.createPeriod)(o,m):o||(0,a.createPeriod)(u[0]??"30d",m)),s=n??j,v=(0,z.usePositioning)({triggerRef:p,contentRef:f,isOpen:i,side:"bottom",align:K}),l=(0,t.useCallback)((e=!0)=>{E(!1),w(!1),M(null),e&&p.current?.focus()},[]);(0,t.useEffect)(()=>{if(!i)return;let e=y=>{let T=y.target;f.current?.contains(T)||p.current?.contains(T)||l(!1)};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e,{passive:!0}),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}},[i,l]),(0,t.useEffect)(()=>{if(!i)return;let e=y=>{y.key==="Escape"&&(y.stopPropagation(),l())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[i,l]),(0,t.useEffect)(()=>{let e=f.current;if(e)return(0,I.registerFloatingLayer)(e,()=>p.current)},[i]),(0,t.useEffect)(()=>{if(!i)return;let e=requestAnimationFrame(()=>L.current?.focus());return()=>cancelAnimationFrame(e)},[i]);let h=(0,t.useCallback)(e=>{n===void 0&&G(e),c?.(e),l()},[n,c,l]),J=(0,t.useCallback)(e=>h((0,a.createPeriod)(e,m)),[h,m]),V=(0,t.useCallback)(e=>{M(e),!(!e.from||!e.to)&&h({preset:"custom",from:(0,a.startOfDay)(e.from),to:(0,a.endOfDay)(e.to)})},[h]),C=e=>A?.[e]??P[ne[e]],S=s.preset==="custom"?(0,a.formatPeriodRange)(s.from,s.to,D):C(s.preset),X=(0,r.jsxs)("div",{ref:f,role:"dialog","aria-label":x??P.chartPeriod,style:{position:"fixed",top:v.top,left:v.left,visibility:v.isReady?"visible":"hidden"},className:"z-50 flex overflow-hidden rounded-lg border border-gray-200 bg-white shadow-lg dark:border-gray-700 dark:bg-gray-800",children:[(0,r.jsxs)("div",{ref:L,tabIndex:-1,className:"flex min-w-44 flex-col p-1 outline-none",children:[u.map(e=>(0,r.jsx)("button",{type:"button","aria-pressed":s.preset===e,onClick:()=>J(e),className:(0,b.cn)("cursor-pointer rounded-md px-3 py-1.5 text-left text-sm text-gray-700 hover:bg-gray-100 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-synertech-primary-500 dark:text-gray-200 dark:hover:bg-gray-700",s.preset===e&&"bg-synertech-primary-50 font-medium text-synertech-primary-700 dark:bg-synertech-primary-950 dark:text-synertech-primary-300"),children:C(e)},e)),d?(0,r.jsx)("button",{type:"button","aria-pressed":s.preset==="custom","aria-expanded":R,onClick:()=>w(!0),className:(0,b.cn)("cursor-pointer rounded-md px-3 py-1.5 text-left text-sm text-gray-700 hover:bg-gray-100 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-synertech-primary-500 dark:text-gray-200 dark:hover:bg-gray-700",s.preset==="custom"&&"bg-synertech-primary-50 font-medium text-synertech-primary-700 dark:bg-synertech-primary-950 dark:text-synertech-primary-300"),children:C("custom")}):null]}),d&&R?(0,r.jsx)("div",{className:"border-l border-gray-200 p-2 dark:border-gray-700",children:(0,r.jsx)(N.Calendar,{mode:"range",value:Q??{from:s.from,to:s.to},onChange:V,numberOfMonths:W,weekStartsOn:H,locale:D,today:m,minDate:F,maxDate:U,size:"sm"})}):null]});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("button",{ref:p,type:"button",disabled:q,"aria-haspopup":"dialog","aria-expanded":i,"aria-label":`${x??P.chartPeriod}: ${S}`,onClick:()=>i?l():E(!0),className:(0,b.cn)("inline-flex cursor-pointer items-center gap-2 rounded-full border border-gray-300 bg-white font-medium text-gray-700 transition-colors hover:bg-gray-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",ie[B],Y),...$,children:[se,(0,r.jsx)("span",{children:S})]}),i&&typeof document<"u"?(0,O.createPortal)(X,document.body):null]})}0&&(module.exports={ChartPeriodPicker});
@@ -1 +1 @@
1
- "use client";import{useCallback as u,useEffect as m,useRef as P,useState as p}from"react";import{createPortal as J}from"react-dom";import{registerFloatingLayer as V}from"../../lib/aria-hide.js";import{cn as v}from"../../lib/cn.js";import{useUILabels as X}from"../../lib/i18n.js";import{Calendar as Z}from"../calendar/Calendar.js";import{usePositioning as ee}from"../dropdown/hooks/usePositioning.js";import{DEFAULT_CHART_PERIOD_PRESETS as te,createPeriod as C,endOfDay as re,formatPeriodRange as oe,startOfDay as ae}from"./utils/period.js";import{Fragment as de,jsx as a,jsxs as f}from"react/jsx-runtime";var ne={"7d":"chartPeriodLast7Days","30d":"chartPeriodLast30Days","90d":"chartPeriodLast90Days","12m":"chartPeriodLast12Months",mtd:"chartPeriodMonthToDate",qtd:"chartPeriodQuarterToDate",ytd:"chartPeriodYearToDate",custom:"chartPeriodCustom"},ie={sm:"h-7 px-2.5 text-xs",md:"h-8 px-3 text-sm",lg:"h-10 px-4 text-sm"},se=a("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:a("path",{d:"M5 1.5v2M11 1.5v2M2.5 6h11M3.5 3h9a1 1 0 011 1v9a1 1 0 01-1 1h-9a1 1 0 01-1-1V4a1 1 0 011-1z",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})});function be({value:h,defaultValue:i,onChange:k,presets:x=te,custom:D=!0,presetLabels:z,now:s,minDate:I,maxDate:A,numberOfMonths:F=1,weekStartsOn:W,locale:L,size:H="md",align:U="start",disabled:_=!1,label:E,className:B,...K}){let y=X(),n=P(null),d=P(null),R=P(null),[t,w]=p(!1),[M,S]=p(!1),[q,T]=p(null),[Y,$]=p(()=>typeof i=="string"?C(i,s):i||C(x[0]??"30d",s)),r=h??Y,b=ee({triggerRef:n,contentRef:d,isOpen:t,side:"bottom",align:U}),o=u((e=!0)=>{w(!1),S(!1),T(null),e&&n.current?.focus()},[]);m(()=>{if(!t)return;let e=l=>{let N=l.target;d.current?.contains(N)||n.current?.contains(N)||o(!1)};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e,{passive:!0}),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}},[t,o]),m(()=>{if(!t)return;let e=l=>{l.key==="Escape"&&(l.stopPropagation(),o())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[t,o]),m(()=>{let e=d.current;if(e)return V(e,()=>n.current)},[t]),m(()=>{if(!t)return;let e=requestAnimationFrame(()=>R.current?.focus());return()=>cancelAnimationFrame(e)},[t]);let c=u(e=>{h===void 0&&$(e),k?.(e),o()},[h,k,o]),Q=u(e=>c(C(e,s)),[c,s]),j=u(e=>{T(e),!(!e.from||!e.to)&&c({preset:"custom",from:ae(e.from),to:re(e.to)})},[c]),g=e=>z?.[e]??y[ne[e]],O=r.preset==="custom"?oe(r.from,r.to,L):g(r.preset),G=f("div",{ref:d,role:"dialog","aria-label":E??y.chartPeriod,style:{position:"fixed",top:b.top,left:b.left,visibility:b.isReady?"visible":"hidden"},className:"z-50 flex overflow-hidden rounded-lg border border-gray-200 bg-white shadow-lg dark:border-gray-700 dark:bg-gray-800",children:[f("div",{ref:R,tabIndex:-1,className:"flex min-w-44 flex-col p-1 outline-none",children:[x.map(e=>a("button",{type:"button","aria-pressed":r.preset===e,onClick:()=>Q(e),className:v("cursor-pointer rounded-md px-3 py-1.5 text-left text-sm text-gray-700 hover:bg-gray-100 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-synertech-primary-500 dark:text-gray-200 dark:hover:bg-gray-700",r.preset===e&&"bg-synertech-primary-50 font-medium text-synertech-primary-700 dark:bg-synertech-primary-950 dark:text-synertech-primary-300"),children:g(e)},e)),D?a("button",{type:"button","aria-pressed":r.preset==="custom","aria-expanded":M,onClick:()=>S(!0),className:v("cursor-pointer rounded-md px-3 py-1.5 text-left text-sm text-gray-700 hover:bg-gray-100 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-synertech-primary-500 dark:text-gray-200 dark:hover:bg-gray-700",r.preset==="custom"&&"bg-synertech-primary-50 font-medium text-synertech-primary-700 dark:bg-synertech-primary-950 dark:text-synertech-primary-300"),children:g("custom")}):null]}),D&&M?a("div",{className:"border-l border-gray-200 p-2 dark:border-gray-700",children:a(Z,{mode:"range",value:q??{from:r.from,to:r.to},onChange:j,numberOfMonths:F,weekStartsOn:W,locale:L,minDate:I,maxDate:A,size:"sm"})}):null]});return f(de,{children:[f("button",{ref:n,type:"button",disabled:_,"aria-haspopup":"dialog","aria-expanded":t,"aria-label":`${E??y.chartPeriod}: ${O}`,onClick:()=>t?o():w(!0),className:v("inline-flex cursor-pointer items-center gap-2 rounded-full border border-gray-300 bg-white font-medium text-gray-700 transition-colors hover:bg-gray-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",ie[H],B),...K,children:[se,a("span",{children:O})]}),t&&typeof document<"u"?J(G,document.body):null]})}export{be as ChartPeriodPicker};
1
+ "use client";import{useCallback as u,useEffect as m,useRef as P,useState as p}from"react";import{createPortal as V}from"react-dom";import{registerFloatingLayer as X}from"../../lib/aria-hide.js";import{cn as v}from"../../lib/cn.js";import{useUILabels as Z,useUILocale as ee}from"../../lib/i18n.js";import{Calendar as te}from"../calendar/Calendar.js";import{usePositioning as re}from"../dropdown/hooks/usePositioning.js";import{DEFAULT_CHART_PERIOD_PRESETS as oe,createPeriod as C,endOfDay as ae,formatPeriodRange as ne,startOfDay as ie}from"./utils/period.js";import{Fragment as le,jsx as a,jsxs as f}from"react/jsx-runtime";var se={"7d":"chartPeriodLast7Days","30d":"chartPeriodLast30Days","90d":"chartPeriodLast90Days","12m":"chartPeriodLast12Months",mtd:"chartPeriodMonthToDate",qtd:"chartPeriodQuarterToDate",ytd:"chartPeriodYearToDate",custom:"chartPeriodCustom"},de={sm:"h-7 px-2.5 text-xs",md:"h-8 px-3 text-sm",lg:"h-10 px-4 text-sm"},ce=a("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:a("path",{d:"M5 1.5v2M11 1.5v2M2.5 6h11M3.5 3h9a1 1 0 011 1v9a1 1 0 01-1 1h-9a1 1 0 01-1-1V4a1 1 0 011-1z",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})});function Pe({value:h,defaultValue:s,onChange:k,presets:x=oe,custom:D=!0,presetLabels:N,now:n,minDate:z,maxDate:A,numberOfMonths:F=1,weekStartsOn:U,locale:W,size:H="md",align:_="start",disabled:B=!1,label:L,className:K,...q}){let y=Z(),E=ee(W),i=P(null),d=P(null),R=P(null),[t,w]=p(!1),[M,S]=p(!1),[Y,T]=p(null),[$,Q]=p(()=>typeof s=="string"?C(s,n):s||C(x[0]??"30d",n)),r=h??$,b=re({triggerRef:i,contentRef:d,isOpen:t,side:"bottom",align:_}),o=u((e=!0)=>{w(!1),S(!1),T(null),e&&i.current?.focus()},[]);m(()=>{if(!t)return;let e=l=>{let I=l.target;d.current?.contains(I)||i.current?.contains(I)||o(!1)};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e,{passive:!0}),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}},[t,o]),m(()=>{if(!t)return;let e=l=>{l.key==="Escape"&&(l.stopPropagation(),o())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[t,o]),m(()=>{let e=d.current;if(e)return X(e,()=>i.current)},[t]),m(()=>{if(!t)return;let e=requestAnimationFrame(()=>R.current?.focus());return()=>cancelAnimationFrame(e)},[t]);let c=u(e=>{h===void 0&&Q(e),k?.(e),o()},[h,k,o]),j=u(e=>c(C(e,n)),[c,n]),G=u(e=>{T(e),!(!e.from||!e.to)&&c({preset:"custom",from:ie(e.from),to:ae(e.to)})},[c]),g=e=>N?.[e]??y[se[e]],O=r.preset==="custom"?ne(r.from,r.to,E):g(r.preset),J=f("div",{ref:d,role:"dialog","aria-label":L??y.chartPeriod,style:{position:"fixed",top:b.top,left:b.left,visibility:b.isReady?"visible":"hidden"},className:"z-50 flex overflow-hidden rounded-lg border border-gray-200 bg-white shadow-lg dark:border-gray-700 dark:bg-gray-800",children:[f("div",{ref:R,tabIndex:-1,className:"flex min-w-44 flex-col p-1 outline-none",children:[x.map(e=>a("button",{type:"button","aria-pressed":r.preset===e,onClick:()=>j(e),className:v("cursor-pointer rounded-md px-3 py-1.5 text-left text-sm text-gray-700 hover:bg-gray-100 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-synertech-primary-500 dark:text-gray-200 dark:hover:bg-gray-700",r.preset===e&&"bg-synertech-primary-50 font-medium text-synertech-primary-700 dark:bg-synertech-primary-950 dark:text-synertech-primary-300"),children:g(e)},e)),D?a("button",{type:"button","aria-pressed":r.preset==="custom","aria-expanded":M,onClick:()=>S(!0),className:v("cursor-pointer rounded-md px-3 py-1.5 text-left text-sm text-gray-700 hover:bg-gray-100 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-synertech-primary-500 dark:text-gray-200 dark:hover:bg-gray-700",r.preset==="custom"&&"bg-synertech-primary-50 font-medium text-synertech-primary-700 dark:bg-synertech-primary-950 dark:text-synertech-primary-300"),children:g("custom")}):null]}),D&&M?a("div",{className:"border-l border-gray-200 p-2 dark:border-gray-700",children:a(te,{mode:"range",value:Y??{from:r.from,to:r.to},onChange:G,numberOfMonths:F,weekStartsOn:U,locale:E,today:n,minDate:z,maxDate:A,size:"sm"})}):null]});return f(le,{children:[f("button",{ref:i,type:"button",disabled:B,"aria-haspopup":"dialog","aria-expanded":t,"aria-label":`${L??y.chartPeriod}: ${O}`,onClick:()=>t?o():w(!0),className:v("inline-flex cursor-pointer items-center gap-2 rounded-full border border-gray-300 bg-white font-medium text-gray-700 transition-colors hover:bg-gray-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",de[H],K),...q,children:[ce,a("span",{children:O})]}),t&&typeof document<"u"?V(J,document.body):null]})}export{Pe as ChartPeriodPicker};