@synertech/ui 0.46.3 → 0.47.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/.claude/skills/use-synertech-ui/SKILL.md +102 -3
  2. package/README.md +50 -0
  3. package/dist/components/area-chart/AreaChart.cjs +1 -1
  4. package/dist/components/area-chart/AreaChart.js +1 -1
  5. package/dist/components/badge/Badge.cjs +1 -1
  6. package/dist/components/badge/Badge.js +1 -1
  7. package/dist/components/bar-chart/BarChart.cjs +1 -1
  8. package/dist/components/bar-chart/BarChart.js +1 -1
  9. package/dist/components/box-plot/BoxPlot.cjs +1 -1
  10. package/dist/components/box-plot/BoxPlot.js +1 -1
  11. package/dist/components/breadcrumb/Breadcrumb.cjs +1 -1
  12. package/dist/components/breadcrumb/Breadcrumb.js +1 -1
  13. package/dist/components/bullet-chart/BulletChart.cjs +1 -1
  14. package/dist/components/bullet-chart/BulletChart.js +1 -1
  15. package/dist/components/button/Button.cjs +1 -1
  16. package/dist/components/button/Button.js +1 -1
  17. package/dist/components/calendar/Calendar.cjs +1 -1
  18. package/dist/components/calendar/Calendar.js +1 -1
  19. package/dist/components/candlestick-chart/CandlestickChart.cjs +1 -1
  20. package/dist/components/candlestick-chart/CandlestickChart.js +1 -1
  21. package/dist/components/chart/ChartBrush.cjs +1 -1
  22. package/dist/components/chart/ChartBrush.js +1 -1
  23. package/dist/components/chart/ChartContainer.cjs +1 -1
  24. package/dist/components/chart/ChartContainer.js +1 -1
  25. package/dist/components/chart/ChartExportButton.cjs +1 -1
  26. package/dist/components/chart/ChartExportButton.js +1 -1
  27. package/dist/components/chart/ChartLegend.cjs +1 -1
  28. package/dist/components/chart/ChartLegend.js +1 -1
  29. package/dist/components/chart/ChartPeriodPicker.cjs +1 -1
  30. package/dist/components/chart/ChartPeriodPicker.js +1 -1
  31. package/dist/components/checkbox/Checkbox.cjs +1 -1
  32. package/dist/components/checkbox/Checkbox.js +1 -1
  33. package/dist/components/checkbox/CheckboxGroup.cjs +1 -1
  34. package/dist/components/checkbox/CheckboxGroup.js +1 -1
  35. package/dist/components/chip/Chip.cjs +1 -1
  36. package/dist/components/chip/Chip.js +1 -1
  37. package/dist/components/circular-progress/CircularProgress.cjs +1 -1
  38. package/dist/components/circular-progress/CircularProgress.js +1 -1
  39. package/dist/components/datagrid/DataGrid.cjs +1 -1
  40. package/dist/components/datagrid/DataGrid.js +1 -1
  41. package/dist/components/dropdown/DropdownCheckboxItem.cjs +1 -1
  42. package/dist/components/dropdown/DropdownCheckboxItem.js +1 -1
  43. package/dist/components/dropdown/DropdownRadio.cjs +1 -1
  44. package/dist/components/dropdown/DropdownRadio.js +1 -1
  45. package/dist/components/dropdown/DropdownTrigger.cjs +1 -1
  46. package/dist/components/dropdown/DropdownTrigger.js +1 -1
  47. package/dist/components/dumbbell-chart/DumbbellChart.cjs +1 -1
  48. package/dist/components/dumbbell-chart/DumbbellChart.js +1 -1
  49. package/dist/components/file-selector/FileSelector.cjs +1 -1
  50. package/dist/components/file-selector/FileSelector.js +1 -1
  51. package/dist/components/footer/FooterLink.cjs +1 -1
  52. package/dist/components/footer/FooterLink.js +1 -1
  53. package/dist/components/footer/FooterSocial.cjs +1 -1
  54. package/dist/components/footer/FooterSocial.js +1 -1
  55. package/dist/components/form/number-input/NumberInput.cjs +1 -1
  56. package/dist/components/form/number-input/NumberInput.js +1 -1
  57. package/dist/components/funnel-chart/FunnelChart.cjs +1 -1
  58. package/dist/components/funnel-chart/FunnelChart.js +1 -1
  59. package/dist/components/gantt-chart/GanttChart.cjs +1 -1
  60. package/dist/components/gantt-chart/GanttChart.js +1 -1
  61. package/dist/components/header/Header.cjs +1 -1
  62. package/dist/components/header/Header.js +1 -1
  63. package/dist/components/heat-map/Heatmap.cjs +1 -1
  64. package/dist/components/heat-map/Heatmap.js +1 -1
  65. package/dist/components/help-button/HelpButton.cjs +6 -6
  66. package/dist/components/help-button/HelpButton.js +7 -7
  67. package/dist/components/help-button/sanitize-html.cjs +1 -0
  68. package/dist/components/help-button/sanitize-html.js +1 -0
  69. package/dist/components/image-uploader/ImageUploader.cjs +1 -1
  70. package/dist/components/image-uploader/ImageUploader.js +1 -1
  71. package/dist/components/indicator/Indicator.cjs +1 -1
  72. package/dist/components/indicator/Indicator.js +1 -1
  73. package/dist/components/label/Label.cjs +1 -1
  74. package/dist/components/label/Label.js +1 -1
  75. package/dist/components/line-chart/LineChart.cjs +1 -1
  76. package/dist/components/line-chart/LineChart.js +1 -1
  77. package/dist/components/modal/Modal.cjs +1 -1
  78. package/dist/components/modal/Modal.js +1 -1
  79. package/dist/components/pagination/Pagination.cjs +1 -1
  80. package/dist/components/pagination/Pagination.js +1 -1
  81. package/dist/components/pie-chart/PieChart.cjs +1 -1
  82. package/dist/components/pie-chart/PieChart.js +1 -1
  83. package/dist/components/progress-bar/ProgressBar.cjs +1 -1
  84. package/dist/components/progress-bar/ProgressBar.js +1 -1
  85. package/dist/components/radio-button/RadioButton.cjs +1 -1
  86. package/dist/components/radio-button/RadioButton.js +1 -1
  87. package/dist/components/scatter-chart/ScatterChart.cjs +1 -1
  88. package/dist/components/scatter-chart/ScatterChart.js +1 -1
  89. package/dist/components/schema-editor/SchemaEditor.cjs +1 -1
  90. package/dist/components/schema-editor/SchemaEditor.js +1 -1
  91. package/dist/components/schema-editor/tables/SchemaTableRenderer.cjs +1 -1
  92. package/dist/components/schema-editor/tables/SchemaTableRenderer.js +1 -1
  93. package/dist/components/select/Select.cjs +1 -1
  94. package/dist/components/select/Select.js +1 -1
  95. package/dist/components/sidebar/Sidebar.cjs +1 -1
  96. package/dist/components/sidebar/Sidebar.js +1 -1
  97. package/dist/components/slider/Slider.cjs +1 -1
  98. package/dist/components/slider/Slider.js +1 -1
  99. package/dist/components/tabs/TabsContent.cjs +1 -1
  100. package/dist/components/tabs/TabsContent.js +1 -1
  101. package/dist/components/tabs/TabsTrigger.cjs +1 -1
  102. package/dist/components/tabs/TabsTrigger.js +1 -1
  103. package/dist/components/waterfall-chart/WaterfallChart.cjs +1 -1
  104. package/dist/components/waterfall-chart/WaterfallChart.js +1 -1
  105. package/dist/components/wizard/Wizard.cjs +1 -1
  106. package/dist/components/wizard/Wizard.js +1 -1
  107. package/dist/components/workflow-editor/edges/WorkflowEdgeRenderer.cjs +1 -1
  108. package/dist/components/workflow-editor/edges/WorkflowEdgeRenderer.js +1 -1
  109. package/dist/components/workflow-editor/nodes/WorkflowNodeRenderer.cjs +1 -1
  110. package/dist/components/workflow-editor/nodes/WorkflowNodeRenderer.js +1 -1
  111. package/dist/index.d.cts +170 -12
  112. package/dist/index.d.ts +170 -12
  113. package/dist/lib/safe-href.cjs +1 -0
  114. package/dist/lib/safe-href.js +1 -0
  115. package/dist/styles.css +618 -249
  116. package/package.json +2 -2
@@ -1 +1 @@
1
- "use client";import{memo as Be,useCallback as se,useMemo as ee,useState as we}from"react";import{useUILabels as be}from"../../lib/i18n.js";import{ChartAxis as xe}from"../chart/ChartAxis.js";import{ChartContainer as Se}from"../chart/ChartContainer.js";import{ChartGrid as Re}from"../chart/ChartGrid.js";import{ChartTooltip as Le}from"../chart/ChartTooltip.js";import{getSeriesColor as Me}from"../chart/palette.js";import{buildCartesianGeometry as $e}from"../chart/utils/cartesian.js";import{readNumber as q,readXValue as He}from"../chart/utils/data.js";import{formatAuto as Ae,formatXValue as Ee}from"../chart/utils/format.js";import{handleChartKeyDown as We}from"../chart/utils/keyboard.js";import{buildBarPath as Xe}from"../chart/utils/path.js";import{boxStats as Ve}from"../chart/utils/quantile.js";import{nearestIndex as Ie}from"../chart/utils/scales.js";import{CHART_TOUCH as ze}from"../chart/utils/touch.js";import{Table as De}from"../table/Table.js";import{TableBody as Ge}from"../table/TableBody.js";import{TableCell as F}from"../table/TableCell.js";import{TableHeader as Ke}from"../table/TableHeader.js";import{TableHeaderCell as T}from"../table/TableHeaderCell.js";import{TableRow as qe}from"../table/TableRow.js";import{Fragment as Ye,jsx as a,jsxs as g}from"react/jsx-runtime";var Oe=40,_e=3,J=4,ce="text-right [font-variant-numeric:tabular-nums]",Qe=Be(function({boxes:h,color:y}){return a("g",{children:h.map(t=>g("g",{children:[a("g",{stroke:y,strokeWidth:1.5,strokeLinecap:"round",children:t.whiskers.map(l=>a("line",{x1:l.x1,y1:l.y1,x2:l.x2,y2:l.y2},l.key))}),t.body?a("path",{d:t.body,fill:y}):null,t.median?a("line",{x1:t.median.x1,y1:t.median.y1,x2:t.median.x2,y2:t.median.y2,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"}):null,t.mean?a("path",{d:`M${t.mean.cx},${t.mean.cy-J} L${t.mean.cx+J},${t.mean.cy} L${t.mean.cx},${t.mean.cy+J} L${t.mean.cx-J},${t.mean.cy} Z`,strokeWidth:1.5,stroke:y,className:"fill-white dark:fill-gray-800"}):null,t.outliers.map(l=>a("circle",{cx:l.cx,cy:l.cy,r:_e,fill:y,strokeWidth:1.5,className:"stroke-white dark:stroke-gray-800"},l.key))]},t.key))})});function Ue({width:p,height:h,data:y,boxes:t,x:l,y:x,grid:M,size:O,orientation:B,boxSize:_,showOutliers:Q,showMean:V,color:U,referenceLines:te,margin:I,tooltip:w,plotLabel:ae,formatValue:$,formatX:H,onBoxClick:S}){let[z,A]=we(null),u=z!==null&&z<t.length?z:null,E=be(),e=ee(()=>{let n=B==="vertical",i=t.flatMap(s=>s.stats===null?[]:[s.stats.min,s.stats.max,...V&&s.mean!==null?[s.mean]:[]]),b=$e({width:p,height:h,data:y,x:l,y:x,bounds:i.length===0?null:[Math.min(...i),Math.max(...i)],margin:I,orientation:B,placement:"band",formatValue:$,formatX:H,defaultIncludeZero:!1}),{valueScale:d,bandwidth:C,categoryPositions:P,innerWidth:G,innerHeight:ne}=b,r=Math.min(_??Oe,C),v=r*.5,k=(s,f)=>n?{x:s,y:f}:{x:f,y:s},R=t.map((s,f)=>{let o=P[f]+(C-r)/2,c=o+r/2;if(s.stats===null)return{key:`${f}`,body:"",median:null,whiskers:[],outliers:[],mean:null,top:P[f],height:C};let{q1:N,q3:K,median:Y,lower:Ce,upper:ve,outliers:ke}=s.stats,me=d(N),ue=d(K),de=Math.min(me,ue),he=Math.abs(ue-me),Pe=Xe({...n?{x:o,y:de,width:r,height:Math.max(1,he)}:{x:de,y:o,width:Math.max(1,he),height:r},radius:2,round:"none"}),j=d(Y),Ne=n?{x1:o,y1:j,x2:o+r,y2:j}:{x1:j,y1:o,x2:j,y2:o+r},le=[];for(let[L,oe,Z]of[["lower",Ce,N],["upper",ve,K]]){let ie=d(oe),Te=d(Z),ge=k(c,ie),ye=k(c,Te);le.push({key:`${L}-stem`,x1:ye.x,y1:ye.y,x2:ge.x,y2:ge.y});let fe=k(c-v/2,ie),pe=k(c+v/2,ie);le.push({key:`${L}-cap`,x1:fe.x,y1:fe.y,x2:pe.x,y2:pe.y})}return{key:`${f}`,body:Pe,median:Ne,whiskers:le,outliers:Q?ke.map((L,oe)=>{let Z=k(c,d(L));return{key:`${oe}`,cx:Z.x,cy:Z.y}}):[],mean:V&&s.mean!==null?(()=>{let L=k(c,d(s.mean));return{cx:L.x,cy:L.y}})():null,top:P[f],height:C}});return{vertical:n,rendered:R,categoryPositions:P,categoryCenters:b.categoryCenters,bandwidth:C,categoryTicks:b.categoryTicks,valueTicks:b.valueTicks,valueScale:d,innerWidth:G,innerHeight:ne,margin:b.margin}},[t,y,l,x,p,h,I,B,_,Q,V,$,H]),re=se(n=>{if(w===!1||t.length===0)return;let i=n.currentTarget.getBoundingClientRect(),b=e.vertical?n.clientX-i.left-e.margin.left:n.clientY-i.top-e.margin.top;A(Ie(e.categoryCenters,b))},[w,t.length,e.vertical,e.margin,e.categoryCenters]),D=se(()=>{!S||u===null||S(t[u])},[S,u,t]),W=se(n=>We(n,{count:t.length,current:u,axis:e.vertical?"x":"y",onMove:A,pick:S?D:null}),[t.length,u,e.vertical,S,D]),m=u===null?null:t[u],X=u===null||m===null||m.stats===null?null:e.vertical?{x:e.margin.left+e.categoryCenters[u],y:e.margin.top+e.valueScale(m.stats.q3)}:{x:e.margin.left+e.valueScale(m.stats.q3),y:e.margin.top+e.categoryCenters[u]};return g(Ye,{children:[g("svg",{width:p,height:h,role:"img","aria-label":ae??t.map(n=>n.label).join(", "),tabIndex:0,className:`${ze} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500`,onPointerMove:re,onPointerLeave:()=>A(null),onKeyDown:W,onBlur:()=>A(null),onClick:D,children:[g("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[a(Re,{width:e.innerWidth,height:e.innerHeight,horizontal:e.vertical&&(M==="y"||M==="both")?e.valueTicks.map(n=>n.offset):void 0,vertical:!e.vertical&&(M==="y"||M==="both")?e.valueTicks.map(n=>n.offset):void 0}),u!==null?a("rect",{x:e.vertical?e.categoryPositions[u]:0,y:e.vertical?0:e.categoryPositions[u],width:e.vertical?e.bandwidth:e.innerWidth,height:e.vertical?e.innerHeight:e.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,te?.map(n=>{let i=e.valueScale(n.value);return g("g",{children:[a("line",{x1:e.vertical?0:i,y1:e.vertical?i:0,x2:e.vertical?e.innerWidth:i,y2:e.vertical?i:e.innerHeight,stroke:n.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:n.dashed===!1?void 0:"4 4"}),n.label?a("text",{x:e.vertical?e.innerWidth:i+4,y:e.vertical?i-4:8,textAnchor:e.vertical?"end":"start",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:n.label}):null]},`${n.value}-${n.label??""}`)}),a(Qe,{boxes:e.rendered,color:U})]}),a("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:(e.vertical?l.hidden:x?.hidden)?null:a(xe,{orientation:"bottom",ticks:e.vertical?e.categoryTicks:e.valueTicks,length:e.innerWidth,label:e.vertical?l.label:x?.label,size:O})}),a("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:(e.vertical?x?.hidden:l.hidden)?null:a(xe,{orientation:"left",ticks:e.vertical?e.valueTicks:e.categoryTicks,length:e.innerHeight,showLine:!1,label:e.vertical?x?.label:l.label,size:O})})]}),m&&m.stats&&X&&w!==!1?a(Le,{x:X.x,y:X.y,containerWidth:p,children:typeof w=="function"?w(m):g("div",{className:"flex flex-col gap-1",children:[a("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:m.label}),g("dl",{className:"grid grid-cols-[auto_auto] gap-x-3 gap-y-0.5",children:[[[E.chartMax,m.stats.max],["Q3",m.stats.q3],[E.chartMedian,m.stats.median],["Q1",m.stats.q1],[E.chartMin,m.stats.min]].map(([n,i])=>g("div",{className:"contents",children:[a("dt",{className:"text-gray-500 dark:text-gray-400",children:n}),a("dd",{className:"justify-self-end font-medium text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:$(i)})]},n)),g("div",{className:"contents",children:[a("dt",{className:"text-gray-500 dark:text-gray-400",children:E.chartCount}),a("dd",{className:"justify-self-end font-medium text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:m.stats.count})]})]})]})}):null]})}function pt({data:p,x:h,y,values:t,quantiles:l,whisker:x=1.5,orientation:M="vertical",boxSize:O,showOutliers:B=!0,showMean:_=!1,color:Q,referenceLines:V,height:U=280,width:te,size:I="md",grid:w="y",tooltip:ae=!0,tableView:$=!1,title:H,description:S,loading:z=!1,emptyState:A,error:u=!1,errorState:E,onRetry:e,actions:re,margin:D,locale:W,plotLabel:m,format:X,onBoxClick:n,className:i,...b}){let d=be(),C=ee(()=>y?.format??X??(r=>Ae(r,W)),[y?.format,X,W]),P=ee(()=>h.format??(r=>Ee(r,W)),[h.format,W]),G=ee(()=>p.map((r,v)=>{let k=He(r,h.key,v),R=t?(()=>{let o=r[t];return Array.isArray(o)?o.map(c=>typeof c=="number"?c:Number(c)).filter(c=>Number.isFinite(c)):null})():null,s=null,f=null;if(R!==null)s=Ve(R,x),f=R.length===0?null:R.reduce((o,c)=>o+c,0)/R.length;else if(l){let o=q(r,l.q1),c=q(r,l.median),N=q(r,l.q3);if(o!==null&&c!==null&&N!==null){let K=l.min?q(r,l.min)??o:o,Y=l.max?q(r,l.max)??N:N;s={count:0,min:K,max:Y,q1:o,median:c,q3:N,iqr:N-o,lower:K,upper:Y,outliers:[]}}}return{index:v,x:k,label:P(k,v),stats:s,mean:f,datum:r}}),[p,h.key,t,l,x,P]),ne=G.filter(r=>r.stats!==null);return a(Se,{title:H,description:S,height:U,width:te,size:I,loading:z,empty:ne.length===0,emptyState:A,error:u,errorState:E,onRetry:e,actions:re,tableView:$,table:$?a("div",{className:"w-full overflow-x-auto",children:g(De,{children:[typeof H=="string"?a("caption",{className:"sr-only",children:H}):null,g(Ke,{children:[a(T,{children:h.label??h.key}),t?a(T,{className:"text-right",children:d.chartCount}):null,a(T,{className:"text-right",children:d.chartMin}),a(T,{className:"text-right",children:"Q1"}),a(T,{className:"text-right",children:d.chartMedian}),a(T,{className:"text-right",children:"Q3"}),a(T,{className:"text-right",children:d.chartMax}),t&&B?a(T,{className:"text-right",children:d.chartOutliers}):null]}),a(Ge,{children:G.map(r=>g(qe,{clickable:!1,children:[a(F,{className:"font-medium text-gray-900 dark:text-gray-100",children:r.label}),t?a(F,{className:ce,children:r.stats?.count??"\u2014"}):null,["min","q1","median","q3","max"].map(v=>a(F,{className:ce,children:r.stats===null?"\u2014":C(r.stats[v])},v)),t&&B?a(F,{className:ce,children:r.stats===null||r.stats.outliers.length===0?"\u2014":r.stats.outliers.map(C).join(", ")}):null]},r.index))})]})}):void 0,className:i,...b,children:({width:r})=>a(Ue,{width:r,height:U,data:p,boxes:G,x:h,y,grid:w,size:I,orientation:M,boxSize:O,showOutliers:B,showMean:_,color:Q??Me(0),referenceLines:V,margin:D,tooltip:ae,plotLabel:m,formatValue:C,formatX:P,onBoxClick:n})})}export{pt as BoxPlot};
1
+ "use client";import{memo as Be,useCallback as se,useMemo as ee,useState as we}from"react";import{useUILabels as be}from"../../lib/i18n.js";import{ChartAxis as xe}from"../chart/ChartAxis.js";import{ChartContainer as Se}from"../chart/ChartContainer.js";import{ChartGrid as Re}from"../chart/ChartGrid.js";import{ChartTooltip as Le}from"../chart/ChartTooltip.js";import{getSeriesColor as Me}from"../chart/palette.js";import{buildCartesianGeometry as $e}from"../chart/utils/cartesian.js";import{readNumber as q,readXValue as He}from"../chart/utils/data.js";import{formatAuto as Ae,formatXValue as Ee}from"../chart/utils/format.js";import{handleChartKeyDown as We}from"../chart/utils/keyboard.js";import{buildBarPath as Xe}from"../chart/utils/path.js";import{boxStats as Ve}from"../chart/utils/quantile.js";import{nearestIndex as Ie}from"../chart/utils/scales.js";import{CHART_TOUCH as ze}from"../chart/utils/touch.js";import{Table as De}from"../table/Table.js";import{TableBody as Ge}from"../table/TableBody.js";import{TableCell as F}from"../table/TableCell.js";import{TableHeader as Ke}from"../table/TableHeader.js";import{TableHeaderCell as T}from"../table/TableHeaderCell.js";import{TableRow as qe}from"../table/TableRow.js";import{Fragment as Ye,jsx as a,jsxs as g}from"react/jsx-runtime";var Oe=40,_e=3,J=4,ce="text-right [font-variant-numeric:tabular-nums]",Qe=Be(function({boxes:h,color:y}){return a("g",{children:h.map(t=>g("g",{children:[a("g",{stroke:y,strokeWidth:1.5,strokeLinecap:"round",children:t.whiskers.map(l=>a("line",{x1:l.x1,y1:l.y1,x2:l.x2,y2:l.y2},l.key))}),t.body?a("path",{d:t.body,fill:y}):null,t.median?a("line",{x1:t.median.x1,y1:t.median.y1,x2:t.median.x2,y2:t.median.y2,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"}):null,t.mean?a("path",{d:`M${t.mean.cx},${t.mean.cy-J} L${t.mean.cx+J},${t.mean.cy} L${t.mean.cx},${t.mean.cy+J} L${t.mean.cx-J},${t.mean.cy} Z`,strokeWidth:1.5,stroke:y,className:"fill-white dark:fill-gray-800"}):null,t.outliers.map(l=>a("circle",{cx:l.cx,cy:l.cy,r:_e,fill:y,strokeWidth:1.5,className:"stroke-white dark:stroke-gray-800"},l.key))]},t.key))})});function Ue({width:p,height:h,data:y,boxes:t,x:l,y:x,grid:M,size:O,orientation:B,boxSize:_,showOutliers:Q,showMean:V,color:U,referenceLines:te,margin:I,tooltip:w,plotLabel:ae,formatValue:$,formatX:H,onBoxClick:S}){let[z,A]=we(null),u=z!==null&&z<t.length?z:null,E=be(),e=ee(()=>{let n=B==="vertical",i=t.flatMap(s=>s.stats===null?[]:[s.stats.min,s.stats.max,...V&&s.mean!==null?[s.mean]:[]]),b=$e({width:p,height:h,data:y,x:l,y:x,bounds:i.length===0?null:[Math.min(...i),Math.max(...i)],margin:I,orientation:B,placement:"band",formatValue:$,formatX:H,defaultIncludeZero:!1}),{valueScale:d,bandwidth:C,categoryPositions:P,innerWidth:G,innerHeight:ne}=b,r=Math.min(_??Oe,C),v=r*.5,k=(s,f)=>n?{x:s,y:f}:{x:f,y:s},R=t.map((s,f)=>{let o=P[f]+(C-r)/2,c=o+r/2;if(s.stats===null)return{key:`${f}`,body:"",median:null,whiskers:[],outliers:[],mean:null,top:P[f],height:C};let{q1:N,q3:K,median:Y,lower:Ce,upper:ve,outliers:ke}=s.stats,me=d(N),ue=d(K),de=Math.min(me,ue),he=Math.abs(ue-me),Pe=Xe({...n?{x:o,y:de,width:r,height:Math.max(1,he)}:{x:de,y:o,width:Math.max(1,he),height:r},radius:2,round:"none"}),j=d(Y),Ne=n?{x1:o,y1:j,x2:o+r,y2:j}:{x1:j,y1:o,x2:j,y2:o+r},le=[];for(let[L,oe,Z]of[["lower",Ce,N],["upper",ve,K]]){let ie=d(oe),Te=d(Z),ge=k(c,ie),ye=k(c,Te);le.push({key:`${L}-stem`,x1:ye.x,y1:ye.y,x2:ge.x,y2:ge.y});let fe=k(c-v/2,ie),pe=k(c+v/2,ie);le.push({key:`${L}-cap`,x1:fe.x,y1:fe.y,x2:pe.x,y2:pe.y})}return{key:`${f}`,body:Pe,median:Ne,whiskers:le,outliers:Q?ke.map((L,oe)=>{let Z=k(c,d(L));return{key:`${oe}`,cx:Z.x,cy:Z.y}}):[],mean:V&&s.mean!==null?(()=>{let L=k(c,d(s.mean));return{cx:L.x,cy:L.y}})():null,top:P[f],height:C}});return{vertical:n,rendered:R,categoryPositions:P,categoryCenters:b.categoryCenters,bandwidth:C,categoryTicks:b.categoryTicks,valueTicks:b.valueTicks,valueScale:d,innerWidth:G,innerHeight:ne,margin:b.margin}},[t,y,l,x,p,h,I,B,_,Q,V,$,H]),re=se(n=>{if(w===!1||t.length===0)return;let i=n.currentTarget.getBoundingClientRect(),b=e.vertical?n.clientX-i.left-e.margin.left:n.clientY-i.top-e.margin.top;A(Ie(e.categoryCenters,b))},[w,t.length,e.vertical,e.margin,e.categoryCenters]),D=se(()=>{!S||u===null||S(t[u])},[S,u,t]),W=se(n=>We(n,{count:t.length,current:u,axis:e.vertical?"x":"y",onMove:A,pick:S?D:null}),[t.length,u,e.vertical,S,D]),m=u===null?null:t[u],X=u===null||m===null||m.stats===null?null:e.vertical?{x:e.margin.left+e.categoryCenters[u],y:e.margin.top+e.valueScale(m.stats.q3)}:{x:e.margin.left+e.valueScale(m.stats.q3),y:e.margin.top+e.categoryCenters[u]};return g(Ye,{children:[g("svg",{width:p,height:h,role:"img","aria-label":ae??t.map(n=>n.label).join(", "),tabIndex:0,className:`${ze} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:re,onPointerLeave:()=>A(null),onKeyDown:W,onBlur:()=>A(null),onClick:D,children:[g("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[a(Re,{width:e.innerWidth,height:e.innerHeight,horizontal:e.vertical&&(M==="y"||M==="both")?e.valueTicks.map(n=>n.offset):void 0,vertical:!e.vertical&&(M==="y"||M==="both")?e.valueTicks.map(n=>n.offset):void 0}),u!==null?a("rect",{x:e.vertical?e.categoryPositions[u]:0,y:e.vertical?0:e.categoryPositions[u],width:e.vertical?e.bandwidth:e.innerWidth,height:e.vertical?e.innerHeight:e.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,te?.map(n=>{let i=e.valueScale(n.value);return g("g",{children:[a("line",{x1:e.vertical?0:i,y1:e.vertical?i:0,x2:e.vertical?e.innerWidth:i,y2:e.vertical?i:e.innerHeight,stroke:n.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:n.dashed===!1?void 0:"4 4"}),n.label?a("text",{x:e.vertical?e.innerWidth:i+4,y:e.vertical?i-4:8,textAnchor:e.vertical?"end":"start",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:n.label}):null]},`${n.value}-${n.label??""}`)}),a(Qe,{boxes:e.rendered,color:U})]}),a("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:(e.vertical?l.hidden:x?.hidden)?null:a(xe,{orientation:"bottom",ticks:e.vertical?e.categoryTicks:e.valueTicks,length:e.innerWidth,label:e.vertical?l.label:x?.label,size:O})}),a("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:(e.vertical?x?.hidden:l.hidden)?null:a(xe,{orientation:"left",ticks:e.vertical?e.valueTicks:e.categoryTicks,length:e.innerHeight,showLine:!1,label:e.vertical?x?.label:l.label,size:O})})]}),m&&m.stats&&X&&w!==!1?a(Le,{x:X.x,y:X.y,containerWidth:p,children:typeof w=="function"?w(m):g("div",{className:"flex flex-col gap-1",children:[a("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:m.label}),g("dl",{className:"grid grid-cols-[auto_auto] gap-x-3 gap-y-0.5",children:[[[E.chartMax,m.stats.max],["Q3",m.stats.q3],[E.chartMedian,m.stats.median],["Q1",m.stats.q1],[E.chartMin,m.stats.min]].map(([n,i])=>g("div",{className:"contents",children:[a("dt",{className:"text-gray-500 dark:text-gray-400",children:n}),a("dd",{className:"justify-self-end font-medium text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:$(i)})]},n)),g("div",{className:"contents",children:[a("dt",{className:"text-gray-500 dark:text-gray-400",children:E.chartCount}),a("dd",{className:"justify-self-end font-medium text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:m.stats.count})]})]})]})}):null]})}function pt({data:p,x:h,y,values:t,quantiles:l,whisker:x=1.5,orientation:M="vertical",boxSize:O,showOutliers:B=!0,showMean:_=!1,color:Q,referenceLines:V,height:U=280,width:te,size:I="md",grid:w="y",tooltip:ae=!0,tableView:$=!1,title:H,description:S,loading:z=!1,emptyState:A,error:u=!1,errorState:E,onRetry:e,actions:re,margin:D,locale:W,plotLabel:m,format:X,onBoxClick:n,className:i,...b}){let d=be(),C=ee(()=>y?.format??X??(r=>Ae(r,W)),[y?.format,X,W]),P=ee(()=>h.format??(r=>Ee(r,W)),[h.format,W]),G=ee(()=>p.map((r,v)=>{let k=He(r,h.key,v),R=t?(()=>{let o=r[t];return Array.isArray(o)?o.map(c=>typeof c=="number"?c:Number(c)).filter(c=>Number.isFinite(c)):null})():null,s=null,f=null;if(R!==null)s=Ve(R,x),f=R.length===0?null:R.reduce((o,c)=>o+c,0)/R.length;else if(l){let o=q(r,l.q1),c=q(r,l.median),N=q(r,l.q3);if(o!==null&&c!==null&&N!==null){let K=l.min?q(r,l.min)??o:o,Y=l.max?q(r,l.max)??N:N;s={count:0,min:K,max:Y,q1:o,median:c,q3:N,iqr:N-o,lower:K,upper:Y,outliers:[]}}}return{index:v,x:k,label:P(k,v),stats:s,mean:f,datum:r}}),[p,h.key,t,l,x,P]),ne=G.filter(r=>r.stats!==null);return a(Se,{title:H,description:S,height:U,width:te,size:I,loading:z,empty:ne.length===0,emptyState:A,error:u,errorState:E,onRetry:e,actions:re,tableView:$,table:$?a("div",{className:"w-full overflow-x-auto",children:g(De,{children:[typeof H=="string"?a("caption",{className:"sr-only",children:H}):null,g(Ke,{children:[a(T,{children:h.label??h.key}),t?a(T,{className:"text-right",children:d.chartCount}):null,a(T,{className:"text-right",children:d.chartMin}),a(T,{className:"text-right",children:"Q1"}),a(T,{className:"text-right",children:d.chartMedian}),a(T,{className:"text-right",children:"Q3"}),a(T,{className:"text-right",children:d.chartMax}),t&&B?a(T,{className:"text-right",children:d.chartOutliers}):null]}),a(Ge,{children:G.map(r=>g(qe,{clickable:!1,children:[a(F,{className:"font-medium text-gray-900 dark:text-gray-100",children:r.label}),t?a(F,{className:ce,children:r.stats?.count??"\u2014"}):null,["min","q1","median","q3","max"].map(v=>a(F,{className:ce,children:r.stats===null?"\u2014":C(r.stats[v])},v)),t&&B?a(F,{className:ce,children:r.stats===null||r.stats.outliers.length===0?"\u2014":r.stats.outliers.map(C).join(", ")}):null]},r.index))})]})}):void 0,className:i,...b,children:({width:r})=>a(Ue,{width:r,height:U,data:p,boxes:G,x:h,y,grid:w,size:I,orientation:M,boxSize:O,showOutliers:B,showMean:_,color:Q??Me(0),referenceLines:V,margin:D,tooltip:ae,plotLabel:m,formatValue:C,formatX:P,onBoxClick:n})})}export{pt as BoxPlot};
@@ -1 +1 @@
1
- "use strict";var m=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var k=(n,s)=>{for(var l in s)m(n,l,{get:s[l],enumerable:!0})},C=(n,s,l,i)=>{if(s&&typeof s=="object"||typeof s=="function")for(let r of N(s))!y.call(n,r)&&r!==l&&m(n,r,{get:()=>s[r],enumerable:!(i=h(s,r))||i.enumerable});return n};var v=n=>C(m({},"__esModule",{value:!0}),n);var R={};k(R,{Breadcrumb:()=>I});module.exports=v(R);var t=require("../../lib/cn.cjs"),g=require("../../lib/server-labels.cjs"),e=require("react/jsx-runtime"),B={sm:"text-xs",md:"text-sm",lg:"text-base"};function I({items:n,separator:s="/",size:l="md",maxItems:i,itemColor:r="text-gray-500 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100",activeColor:f="text-gray-700 font-medium dark:text-gray-200",separatorColor:p="text-gray-500 dark:text-gray-400",className:u,...b}){let d=n,x=!1;if(i&&n.length>i){x=!0;let a=n[0],o=n.slice(-(i-1));d=[a,...o]}return(0,e.jsx)("nav",{"aria-label":g.serverUILabels.breadcrumbLabel,className:(0,t.cn)("inline-flex items-center",B[l],u),...b,children:(0,e.jsx)("ol",{className:"inline-flex items-center space-x-1 md:space-x-2",children:d.map((a,o)=>{let c=o===d.length-1;return(0,e.jsxs)("li",{className:"inline-flex items-center",children:[x&&o===1&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:(0,t.cn)("mx-1 select-none",p),children:"..."}),(0,e.jsx)("span",{className:(0,t.cn)("mx-1 select-none",p),"aria-hidden":"true",children:s})]}),a.href||a.onClick?(0,e.jsxs)("a",{href:a.href,onClick:a.onClick,className:(0,t.cn)("inline-flex items-center gap-1.5 transition-colors",c?f:r),"aria-current":c?"page":void 0,children:[a.icon&&(0,e.jsx)("span",{className:"inline-flex","aria-hidden":"true",children:a.icon}),(0,e.jsx)("span",{children:a.label})]}):(0,e.jsxs)("span",{className:(0,t.cn)("inline-flex items-center gap-1.5",c?f:r),"aria-current":c?"page":void 0,children:[a.icon&&(0,e.jsx)("span",{className:"inline-flex","aria-hidden":"true",children:a.icon}),(0,e.jsx)("span",{children:a.label})]}),!c&&(0,e.jsx)("span",{className:(0,t.cn)("mx-2 select-none",p),"aria-hidden":"true",children:s})]},a.href??a.label)})})})}0&&(module.exports={Breadcrumb});
1
+ "use strict";var d=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var B=(n,r)=>{for(var l in r)d(n,l,{get:r[l],enumerable:!0})},I=(n,r,l,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of C(r))!v.call(n,s)&&s!==l&&d(n,s,{get:()=>r[s],enumerable:!(i=k(r,s))||i.enumerable});return n};var R=n=>I(d({},"__esModule",{value:!0}),n);var z={};B(z,{Breadcrumb:()=>L});module.exports=R(z);var t=require("../../lib/cn.cjs"),u=require("../../lib/server-labels.cjs"),b=require("../../lib/safe-href.cjs"),e=require("react/jsx-runtime"),P={sm:"text-xs",md:"text-sm",lg:"text-base"};function L({items:n,separator:r="/",size:l="md",maxItems:i,itemColor:s="text-gray-500 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100",activeColor:f="text-gray-700 font-medium dark:text-gray-200",separatorColor:p="text-gray-500 dark:text-gray-400",className:h,...N}){let m=n,x=!1;if(i&&n.length>i){x=!0;let a=n[0],o=n.slice(-(i-1));m=[a,...o]}return(0,e.jsx)("nav",{"aria-label":u.serverUILabels.breadcrumbLabel,className:(0,t.cn)("inline-flex items-center",P[l],h),...N,children:(0,e.jsx)("ol",{className:"inline-flex items-center space-x-1 md:space-x-2",children:m.map((a,o)=>{let c=o===m.length-1,y=x&&o===1,g=(0,b.componentHref)("Breadcrumb",a.href);return(0,e.jsxs)("li",{className:"inline-flex items-center",children:[y&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:(0,t.cn)("mx-1 select-none",p),children:"..."}),(0,e.jsx)("span",{className:(0,t.cn)("mx-1 select-none",p),"aria-hidden":"true",children:r})]}),g||a.onClick?(0,e.jsxs)("a",{href:g,onClick:a.onClick,className:(0,t.cn)("inline-flex items-center gap-1.5 transition-colors",c?f:s),"aria-current":c?"page":void 0,children:[a.icon&&(0,e.jsx)("span",{className:"inline-flex","aria-hidden":"true",children:a.icon}),(0,e.jsx)("span",{children:a.label})]}):(0,e.jsxs)("span",{className:(0,t.cn)("inline-flex items-center gap-1.5",c?f:s),"aria-current":c?"page":void 0,children:[a.icon&&(0,e.jsx)("span",{className:"inline-flex","aria-hidden":"true",children:a.icon}),(0,e.jsx)("span",{children:a.label})]}),!c&&(0,e.jsx)("span",{className:(0,t.cn)("mx-2 select-none",p),"aria-hidden":"true",children:r})]},a.href??a.label)})})})}0&&(module.exports={Breadcrumb});
@@ -1 +1 @@
1
- import{cn as n}from"../../lib/cn.js";import{serverUILabels as b}from"../../lib/server-labels.js";import{Fragment as N,jsx as a,jsxs as l}from"react/jsx-runtime";var h={sm:"text-xs",md:"text-sm",lg:"text-base"};function v({items:r,separator:p="/",size:x="md",maxItems:i,itemColor:d="text-gray-500 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100",activeColor:m="text-gray-700 font-medium dark:text-gray-200",separatorColor:c="text-gray-500 dark:text-gray-400",className:g,...u}){let o=r,f=!1;if(i&&r.length>i){f=!0;let e=r[0],t=r.slice(-(i-1));o=[e,...t]}return a("nav",{"aria-label":b.breadcrumbLabel,className:n("inline-flex items-center",h[x],g),...u,children:a("ol",{className:"inline-flex items-center space-x-1 md:space-x-2",children:o.map((e,t)=>{let s=t===o.length-1;return l("li",{className:"inline-flex items-center",children:[f&&t===1&&l(N,{children:[a("span",{className:n("mx-1 select-none",c),children:"..."}),a("span",{className:n("mx-1 select-none",c),"aria-hidden":"true",children:p})]}),e.href||e.onClick?l("a",{href:e.href,onClick:e.onClick,className:n("inline-flex items-center gap-1.5 transition-colors",s?m:d),"aria-current":s?"page":void 0,children:[e.icon&&a("span",{className:"inline-flex","aria-hidden":"true",children:e.icon}),a("span",{children:e.label})]}):l("span",{className:n("inline-flex items-center gap-1.5",s?m:d),"aria-current":s?"page":void 0,children:[e.icon&&a("span",{className:"inline-flex","aria-hidden":"true",children:e.icon}),a("span",{children:e.label})]}),!s&&a("span",{className:n("mx-2 select-none",c),"aria-hidden":"true",children:p})]},e.href??e.label)})})})}export{v as Breadcrumb};
1
+ import{cn as n}from"../../lib/cn.js";import{serverUILabels as N}from"../../lib/server-labels.js";import{componentHref as y}from"../../lib/safe-href.js";import{Fragment as C,jsx as a,jsxs as l}from"react/jsx-runtime";var k={sm:"text-xs",md:"text-sm",lg:"text-base"};function R({items:s,separator:p="/",size:g="md",maxItems:i,itemColor:m="text-gray-500 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100",activeColor:d="text-gray-700 font-medium dark:text-gray-200",separatorColor:c="text-gray-500 dark:text-gray-400",className:u,...b}){let o=s,f=!1;if(i&&s.length>i){f=!0;let e=s[0],t=s.slice(-(i-1));o=[e,...t]}return a("nav",{"aria-label":N.breadcrumbLabel,className:n("inline-flex items-center",k[g],u),...b,children:a("ol",{className:"inline-flex items-center space-x-1 md:space-x-2",children:o.map((e,t)=>{let r=t===o.length-1,h=f&&t===1,x=y("Breadcrumb",e.href);return l("li",{className:"inline-flex items-center",children:[h&&l(C,{children:[a("span",{className:n("mx-1 select-none",c),children:"..."}),a("span",{className:n("mx-1 select-none",c),"aria-hidden":"true",children:p})]}),x||e.onClick?l("a",{href:x,onClick:e.onClick,className:n("inline-flex items-center gap-1.5 transition-colors",r?d:m),"aria-current":r?"page":void 0,children:[e.icon&&a("span",{className:"inline-flex","aria-hidden":"true",children:e.icon}),a("span",{children:e.label})]}):l("span",{className:n("inline-flex items-center gap-1.5",r?d:m),"aria-current":r?"page":void 0,children:[e.icon&&a("span",{className:"inline-flex","aria-hidden":"true",children:e.icon}),a("span",{children:e.label})]}),!r&&a("span",{className:n("mx-2 select-none",c),"aria-hidden":"true",children:p})]},e.href??e.label)})})})}export{R as Breadcrumb};
@@ -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=(i,l)=>{for(var n in l)te(i,n,{get:l[n],enumerable:!0})},xe=(i,l,n,e)=>{if(l&&typeof l=="object"||typeof l=="function")for(let s of ye(l))!Ce.call(i,s)&&s!==n&&te(i,s,{get:()=>l[s],enumerable:!(e=pe(l,s))||e.enumerable});return i};var ve=i=>xe(te({},"__esModule",{value:!0}),i);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,ie=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:i,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,i-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)),o=(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=o(b),be=o(Math.max(b,p));b=p;let oe=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:oe,fill:B?oe:void 0}}),ee=a.value===null?null:(0,ae.buildBarPath)({x:o(A[0]),y:k-w/2,width:Math.max(0,o(a.value)-o(A[0])),height:w,radius:2,round:"right"});return{key:`${c}`,bands:j,measure:ee,target:a.target===null?null:{x:o(a.target),y1:f-ie,y2:f+V+ie},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,i,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:i,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-blue-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:i,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:i,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??(o=>(0,z.formatAuto)(o,y)),[d,y]),H=(0,m.useMemo)(()=>l.format??(o=>(0,z.formatXValue)(o,y)),[l.format,y]),P=(0,m.useMemo)(()=>i.map((o,f)=>{let k=(0,I.readXValue)(o,l.key,f),L=(0,I.readNumber)(o,n),b=e?(0,I.readNumber)(o,e):null,j=s?o[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:o}}),[i,l.key,n,e,s,E,H]),a=(0,m.useMemo)(()=>{if(g)return g;if(R!=="shared")return null;let o=P.reduce((f,k)=>Math.max(f,k.value??0,k.target??0,...k.ranges),0);return(0,K.niceDomain)(0,o,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:i,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:o})=>(0,t.jsx)(Be,{width:o,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 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 +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,oe=3,ie=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:i,color:a}){return l("g",{children:i.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:i,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),o=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)+ie*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,i-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-oe,y2:d+S+oe},label:v?{x:N+ie,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,i,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||o===null||T(a[o])},[T,o,a]),q=Q(g=>xe(g,{count:a.length,current:o,axis:"y",onMove:k,pick:T?_:null}),[a.length,o,T,_]),x=o===null?null:a[o];return X(Le,{children:[X("svg",{width:b,height:i,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-blue-500`,onPointerMove:j,onPointerLeave:()=>k(null),onKeyDown:q,onBlur:()=>k(null),onClick:_,children:[X("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:[o!==null&&n.rendered[o]?l("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,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&&o!==null&&R!==!1?l(fe,{x:n.margin.left+n.innerWidth/2,y:n.margin.top+n.centers[o],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:i,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:o,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(()=>i.format??(r=>ke(r,p)),[i.format,p]),E=M(()=>b.map((r,d)=>{let C=pe(r,i.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,i.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:o,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:i.key,xLabel:i.label??i.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:i,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 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 +1 @@
1
- "use strict";var u=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var $=Object.prototype.hasOwnProperty;var z=(s,t)=>{for(var o in t)u(s,o,{get:t[o],enumerable:!0})},A=(s,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of k(t))!$.call(s,n)&&n!==o&&u(s,n,{get:()=>t[n],enumerable:!(r=S(t,n))||r.enumerable});return s};var D=s=>A(u({},"__esModule",{value:!0}),s);var j={};z(j,{Button:()=>V});module.exports=D(j);var a=require("../../lib/cn.cjs"),e=require("react/jsx-runtime");function H({className:s}){return(0,e.jsxs)("svg",{className:(0,a.cn)("animate-spin",s),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","aria-hidden":"true",children:[(0,e.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,e.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})}var I={sm:"px-3 py-1.5 text-xs gap-1.5",md:"px-4 py-2 text-sm gap-2",lg:"px-5 py-2.5 text-base gap-2",xl:"px-6 py-3 text-lg gap-2.5"},M={sm:"p-1.5",md:"p-2",lg:"p-2.5",xl:"p-3"},c={sm:"h-3.5 w-3.5",md:"h-4 w-4",lg:"h-5 w-5",xl:"h-6 w-6"},O={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"rounded-full"};function V({label:s,children:t,onClick:o,disabled:r=!1,className:n,type:h="button",size:l="md",loading:p=!1,leftIcon:m,rightIcon:g,icon:b,fullWidth:y=!1,rounded:N="lg",bgColor:w="bg-blue-600 hover:bg-blue-700",textColor:C="text-white",focusColor:i="focus:ring-blue-300",selected:f=!1,value:v,showFocusOnClick:d=!1,...R}){let B=r||p,x=b!==void 0&&!t&&!s,P=(0,a.cn)("inline-flex items-center justify-center font-medium transition-colors focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed",d?"focus:ring-4":"focus-visible:ring-4"),W=(0,a.cn)(f?"bg-blue-700 text-white ring-2 ring-blue-500":w,!f&&C,i&&d&&`focus:ring-4 ${i}`,i&&!d&&`focus-visible:ring-4 ${i}`);return(0,e.jsx)("button",{type:h,onClick:o,disabled:B,"data-value":v,className:(0,a.cn)(P,x?M[l]:I[l],O[N],W,y&&"w-full",n),...R,children:p?(0,e.jsx)(H,{className:c[l]}):x?(0,e.jsx)("span",{className:c[l],children:b}):(0,e.jsxs)(e.Fragment,{children:[m&&(0,e.jsx)("span",{className:c[l],children:m}),t??s,g&&(0,e.jsx)("span",{className:c[l],children:g})]})})}0&&(module.exports={Button});
1
+ "use strict";var p=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var A=(t,s)=>{for(var o in s)p(t,o,{get:s[o],enumerable:!0})},D=(t,s,o,l)=>{if(s&&typeof s=="object"||typeof s=="function")for(let n of S(s))!k.call(t,n)&&n!==o&&p(t,n,{get:()=>s[n],enumerable:!(l=O(s,n))||l.enumerable});return t};var L=t=>D(p({},"__esModule",{value:!0}),t);var H={};A(H,{Button:()=>G});module.exports=L(H);var r=require("../../lib/cn.cjs"),e=require("react/jsx-runtime"),v="bg-synertech-primary-600 hover:bg-synertech-primary-700";function _({className:t}){return(0,e.jsxs)("svg",{className:(0,r.cn)("animate-spin",t),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","aria-hidden":"true",children:[(0,e.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,e.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})}var $={sm:"px-3 py-1.5 text-xs gap-1.5",md:"px-4 py-2 text-sm gap-2",lg:"px-5 py-2.5 text-base gap-2",xl:"px-6 py-3 text-lg gap-2.5"},z={sm:"p-1.5",md:"p-2",lg:"p-2.5",xl:"p-3"},c={sm:"h-3.5 w-3.5",md:"h-4 w-4",lg:"h-5 w-5",xl:"h-6 w-6"},E={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"rounded-full"};function G({label:t,children:s,onClick:o,disabled:l=!1,className:n,type:N="button",size:a="md",loading:m=!1,leftIcon:u,rightIcon:g,icon:f,fullWidth:C=!1,rounded:w="lg",bgColor:y=v,textColor:R,focusColor:i="focus:ring-synertech-primary-300",selected:b=!1,value:x,showFocusOnClick:d=!1,...B}){let P=l||m,h=f!==void 0&&!s&&!t,T=(0,r.cn)("inline-flex items-center justify-center font-medium transition-colors focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed",d?"focus:ring-4":"focus-visible:ring-4"),W=(0,r.cn)(b?"bg-synertech-primary-700 text-synertech-on-primary ring-2 ring-synertech-primary-500":y,!b&&(R??(y===v?"text-synertech-on-primary":"text-white")),i&&d&&`focus:ring-4 ${i}`,i&&!d&&`focus-visible:ring-4 ${i}`);return(0,e.jsx)("button",{type:N,onClick:o,disabled:P,value:x,"data-value":x,className:(0,r.cn)(T,h?z[a]:$[a],E[w],W,C&&"w-full",n),...B,children:m?(0,e.jsx)(_,{className:c[a]}):h?(0,e.jsx)("span",{className:c[a],children:f}):(0,e.jsxs)(e.Fragment,{children:[u&&(0,e.jsx)("span",{className:c[a],children:u}),s??t,g&&(0,e.jsx)("span",{className:c[a],children:g})]})})}0&&(module.exports={Button});
@@ -1 +1 @@
1
- import{cn as l}from"../../lib/cn.js";import{Fragment as A,jsx as e,jsxs as g}from"react/jsx-runtime";function S({className:t}){return g("svg",{className:l("animate-spin",t),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","aria-hidden":"true",children:[e("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})}var k={sm:"px-3 py-1.5 text-xs gap-1.5",md:"px-4 py-2 text-sm gap-2",lg:"px-5 py-2.5 text-base gap-2",xl:"px-6 py-3 text-lg gap-2.5"},$={sm:"p-1.5",md:"p-2",lg:"p-2.5",xl:"p-3"},o={sm:"h-3.5 w-3.5",md:"h-4 w-4",lg:"h-5 w-5",xl:"h-6 w-6"},z={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"rounded-full"};function H({label:t,children:r,onClick:b,disabled:f=!1,className:x,type:h="button",size:s="md",loading:i=!1,leftIcon:c,rightIcon:d,icon:u,fullWidth:y=!1,rounded:N="lg",bgColor:w="bg-blue-600 hover:bg-blue-700",textColor:C="text-white",focusColor:n="focus:ring-blue-300",selected:p=!1,value:v,showFocusOnClick:a=!1,...R}){let B=f||i,m=u!==void 0&&!r&&!t,P=l("inline-flex items-center justify-center font-medium transition-colors focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed",a?"focus:ring-4":"focus-visible:ring-4"),W=l(p?"bg-blue-700 text-white ring-2 ring-blue-500":w,!p&&C,n&&a&&`focus:ring-4 ${n}`,n&&!a&&`focus-visible:ring-4 ${n}`);return e("button",{type:h,onClick:b,disabled:B,"data-value":v,className:l(P,m?$[s]:k[s],z[N],W,y&&"w-full",x),...R,children:i?e(S,{className:o[s]}):m?e("span",{className:o[s],children:u}):g(A,{children:[c&&e("span",{className:o[s],children:c}),r??t,d&&e("span",{className:o[s],children:d})]})})}export{H as Button};
1
+ import{cn as a}from"../../lib/cn.js";import{Fragment as D,jsx as e,jsxs as b}from"react/jsx-runtime";var y="bg-synertech-primary-600 hover:bg-synertech-primary-700";function O({className:s}){return b("svg",{className:a("animate-spin",s),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","aria-hidden":"true",children:[e("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})}var S={sm:"px-3 py-1.5 text-xs gap-1.5",md:"px-4 py-2 text-sm gap-2",lg:"px-5 py-2.5 text-base gap-2",xl:"px-6 py-3 text-lg gap-2.5"},k={sm:"p-1.5",md:"p-2",lg:"p-2.5",xl:"p-3"},o={sm:"h-3.5 w-3.5",md:"h-4 w-4",lg:"h-5 w-5",xl:"h-6 w-6"},A={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"rounded-full"};function $({label:s,children:l,onClick:x,disabled:h=!1,className:v,type:N="button",size:t="md",loading:i=!1,leftIcon:c,rightIcon:d,icon:p,fullWidth:C=!1,rounded:w="lg",bgColor:m=y,textColor:R,focusColor:n="focus:ring-synertech-primary-300",selected:u=!1,value:g,showFocusOnClick:r=!1,...B}){let P=h||i,f=p!==void 0&&!l&&!s,T=a("inline-flex items-center justify-center font-medium transition-colors focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed",r?"focus:ring-4":"focus-visible:ring-4"),W=a(u?"bg-synertech-primary-700 text-synertech-on-primary ring-2 ring-synertech-primary-500":m,!u&&(R??(m===y?"text-synertech-on-primary":"text-white")),n&&r&&`focus:ring-4 ${n}`,n&&!r&&`focus-visible:ring-4 ${n}`);return e("button",{type:N,onClick:x,disabled:P,value:g,"data-value":g,className:a(T,f?k[t]:S[t],A[w],W,C&&"w-full",v),...B,children:i?e(O,{className:o[t]}):f?e("span",{className:o[t],children:p}):b(D,{children:[c&&e("span",{className:o[t],children:c}),l??s,d&&e("span",{className:o[t],children:d})]})})}export{$ as Button};
@@ -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 bt={};et(bt,{Calendar:()=>ft});module.exports=at(bt);var l=require("react"),c=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},(ue,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-blue-600 text-white hover:bg-blue-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"},ut={primary:"bg-blue-50 dark:bg-blue-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"},ct={primary:"text-blue-900 dark:text-blue-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-blue-600 dark:text-blue-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-blue-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:ue=1,weekStartsOn:L=0,locale:R,size:Ce="md",color:x="primary",minDate:k,maxDate:w,disabledDates:O,disabled:y=!1,showOutsideDays:Me=!0,showWeekNumbers:ce=!1,fixedWeeks:Se=!1,captionLayout:Z="label",fromYear:ge,toYear:fe,todayButton:ee=!1,clearButton:te=!1,footer:be,bordered:Ne=!0,renderDay:ye,labels:B,className:Fe,...Re}=e,I=(0,we.useUILabels)(),p=it[Ce],C=Math.max(1,ue),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]),me=(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),u=t&&ie(t,r)?t:ie(g(new Date),r)?g(new Date):r;return ve(u,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,me.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 u=v(f,C-1);E(r,f)<0?h(r):E(r,u)>0&&h(v(r,-(C-1)))},[f,C,k,w,h]),K=(0,l.useCallback)(t=>y||k&&t<g(k)||w&&t>g(w)?!0:typeof O=="function"?O(t):Array.isArray(O)?O.some(r=>N(r,t)):!1,[y,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,b)=>o.getTime()-b.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=!y&&(!k||E(f,V(k))>0),De=!y&&(!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(y)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 u=t.shiftKey?-12:-1,i=v(r,u),m=Math.min(r.getDate(),de(i));P(new Date(i.getFullYear(),i.getMonth(),m));break}case"PageDown":{t.preventDefault();let u=t.shiftKey?12:1,i=v(r,u),m=Math.min(r.getDate(),de(i));P(new Date(i.getFullYear(),i.getMonth(),m));break}default:break}},[y,W,P,L]),Ve=(0,l.useMemo)(()=>{let t=new Intl.DateTimeFormat(R,{weekday:"short"}),r=new Intl.DateTimeFormat(R,{weekday:"long"}),u=new Date(2024,0,7);return Array.from({length:7},(i,m)=>{let o=T(u,(L+m)%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,u)=>t.format(new Date(2024,u,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,u=fe??w?.getFullYear()??t+10;return u<r?[r]:Array.from({length:u-r+1},(i,m)=>r+m)},[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 u=!ie(t,r),i=K(t),m=!1,o=!1,b=!1,d=!1;return a==="multiple"?m=(A??[]).some(H=>N(H,t)):a==="range"?(o=N(S?.from,t),b=N($,t),m=o||b,d=!!(S?.from&&$&&t>S.from&&t<$)):m=N(A,t),{selected:m,today:N(t,Y),outside:u,disabled:i,rangeStart:o,rangeEnd:b,inRange:d}},[a,A,S,$,K,Y]),He=t=>{let r=v(f,t),u=ot(r,L,Se),i=t===0,m=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,c.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:y,onChange:o=>h(new Date(r.getFullYear(),Number(o.target.value)-t,1)),className:(0,c.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,y&&"cursor-not-allowed opacity-50"),children:Ke.map((o,b)=>(0,n.jsx)("option",{value:b,children:o},o))}),(0,n.jsx)("select",{"aria-label":B?.yearSelect??I.calendarYear,value:r.getFullYear(),disabled:y,onChange:o=>h(new Date(Number(o.target.value),r.getMonth()-t,1)),className:(0,c.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,y&&"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,c.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,c.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",!m&&"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:[ce&&(0,n.jsxs)("th",{scope:"col",className:(0,c.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,c.cn)("font-medium uppercase text-gray-500 dark:text-gray-400",p.head),children:o.short},o.long))]})}),(0,n.jsx)("tbody",{children:u.map(o=>(0,n.jsxs)("tr",{children:[ce&&(0,n.jsx)("td",{className:(0,c.cn)("text-center align-middle text-gray-500 dark:text-gray-400",p.head),children:nt(o[0])}),o.map(b=>{let d=$e(b,r),H=J(b);if(d.outside&&!Me)return(0,n.jsx)("td",{className:"p-0"},H);let Je=N(b,Ee)&&!d.outside,le=d.inRange||d.rangeStart&&!!$||d.rangeEnd&&!!S?.from;return(0,n.jsx)("td",{role:"presentation",className:(0,c.cn)("p-0",le&&ut[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:y,"aria-selected":d.selected,"aria-disabled":d.disabled||void 0,"aria-current":d.today?"date":void 0,"aria-label":_e.format(b),onClick:()=>{d.disabled||Be(b)},onMouseEnter:()=>a==="range"&&pe(g(b)),onMouseLeave:()=>a==="range"&&pe(null),onFocus:()=>U(g(b)),className:(0,c.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,c.cn)(ct[x],"hover:bg-gray-200/60 dark:hover:bg-gray-600/60"):d.today?(0,c.cn)(gt[x],"hover:bg-gray-100 dark:hover:bg-gray-700"):(0,c.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:ye?ye(b,d):b.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=!!be||ee||te;return(0,n.jsxs)("div",{ref:me,className:(0,c.cn)("inline-block bg-white dark:bg-gray-900",Ne&&"rounded-lg border border-gray-200 shadow-sm dark:border-gray-700",p.padding,y&&"opacity-60",Fe),...Re,children:[(0,n.jsx)("div",{className:(0,c.cn)("flex flex-wrap",p.gap),children:Array.from({length:C},(t,r)=>He(r))}),qe&&(0,n.jsxs)("div",{className:(0,c.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:be}),(ee||te)&&(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[ee&&(0,n.jsx)("button",{type:"button",onClick:Ge,disabled:y,className:(0,c.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],y&&"cursor-not-allowed opacity-50"),children:B?.today??I.calendarToday}),te&&(0,n.jsx)("button",{type:"button",onClick:Ue,disabled:y,className:(0,c.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],y&&"cursor-not-allowed opacity-50"),children:B?.clear??I.calendarClear})]})]})]})}0&&(module.exports={Calendar});
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 +1 @@
1
- "use client";import{useCallback as h,useEffect as Ze,useMemo as _,useRef as we,useState as X}from"react";import{cn as c}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 u(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 ce(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 ue(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=u(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<u(r)?u(r):i&&a>u(i)?u(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+ce(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-blue-600 text-white hover:bg-blue-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-blue-50 dark:bg-blue-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-blue-900 dark:text-blue-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"},ut={primary:"font-semibold text-blue-600 dark:text-blue-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-blue-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(u):[];if(a==="range"){let i=r??null;return{from:i?.from?u(i.from):null,to:i?.to?u(i.to):null}}return r instanceof Date?u(r):null}function Me(a){return a?a instanceof Date?a:Array.isArray(a)?a[0]??null:a.from??a.to??null:null}function yt(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:b=!1,showOutsideDays:Ne=!0,showWeekNumbers:fe=!1,fixedWeeks:Fe=!1,captionLayout:ae="label",fromYear:be,toYear:ye,todayButton:re=!1,clearButton:ne=!1,footer:me,bordered:Re=!0,renderDay:pe,labels:E,className:Ye,...Pe}=a,B=et(),m=lt[Se],w=Math.max(1,ge),R=_(()=>u(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&&ue(e,t)?e:ue(u(new Date),t)?u(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(u(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=>b||v&&e<u(v)||k&&e>u(k)?!0:typeof H=="function"?H(e):Array.isArray(H)?H.some(t=>S(t,e)):!1,[b,v,k,H]),[ie,De]=X(null),C=h(e=>{oe||Le(e),j?.(e)},[oe,j]),Q=h(e=>{let t=u(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(u(e)),A(e,g)<0?p(e):A(e,x(g,w-1))>0&&p(x(e,-(w-1)))},[Q,g,w,p]),xe=!b&&(!v||A(g,z(v))>0),ve=!b&&(!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(b)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),y=Math.min(t.getDate(),ce(l));Y(new Date(l.getFullYear(),l.getMonth(),y));break}case"PageDown":{e.preventDefault();let d=e.shiftKey?12:1,l=x(t,d),y=Math.min(t.getDate(),ce(l));Y(new Date(l.getFullYear(),l.getMonth(),y));break}default:break}},[b,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,y)=>{let n=P(d,(T+y)%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=be??v?.getFullYear()??e-100,d=ye??k?.getFullYear()??e+10;return d<t?[t]:Array.from({length:d-t+1},(l,y)=>t+y)},[ae,be,ye,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=!ue(e,t),l=K(e),y=!1,n=!1,f=!1,s=!1;return r==="multiple"?y=(L??[]).some(U=>S(U,e)):r==="range"?(n=S(M?.from,e),f=S(G,e),y=n||f,s=!!(M?.from&&G&&e>M.from&&e<G)):y=S(L,e),{selected:y,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,y=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: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[D],m.nav,!xe&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent",!l&&"invisible"),children:o(nt,{className:m.icon})}),ae==="dropdown"?N("div",{className:"flex items-center gap-1",children:[o("select",{"aria-label":E?.monthSelect??B.calendarMonth,value:t.getMonth(),disabled:b,onChange:n=>p(new Date(t.getFullYear(),Number(n.target.value)-e,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[D],m.select,b&&"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:b,onChange:n=>p(new Date(Number(n.target.value),t.getMonth()-e,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[D],m.select,b&&"cursor-not-allowed opacity-50"),children:$e.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",m.caption),children:ke.format(t)}),o("button",{type:"button",onClick:Ve,disabled:!ve,"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[D],m.nav,!ve&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent",!y&&"invisible"),children:o(ot,{className:m.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:c("font-normal text-gray-500 dark:text-gray-400",m.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:c("font-medium uppercase text-gray-500 dark:text-gray-400",m.head),children:n.short},n.long))]})}),o("tbody",{children:d.map(n=>N("tr",{children:[fe&&o("td",{className:c("text-center align-middle text-gray-500 dark:text-gray-400",m.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:c("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:b,"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(u(f)),onMouseLeave:()=>r==="range"&&De(null),onFocus:()=>J(u(f)),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[D],m.day,s.selected?st[D]:s.inRange?c(dt[D],"hover:bg-gray-200/60 dark:hover:bg-gray-600/60"):s.today?c(ut[D],"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: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=!!me||re||ne;return N("div",{ref:he,className:c("inline-block bg-white dark:bg-gray-900",Re&&"rounded-lg border border-gray-200 shadow-sm dark:border-gray-700",m.padding,b&&"opacity-60",Ye),...Pe,children:[o("div",{className:c("flex flex-wrap",m.gap),children:Array.from({length:w},(e,t)=>Ue(t))}),Qe&&N("div",{className:c("mt-3 flex items-center justify-between gap-2 border-t border-gray-200 pt-3 dark:border-gray-700",m.footer),children:[o("div",{className:"text-gray-600 dark:text-gray-400",children:me}),(re||ne)&&N("div",{className:"flex items-center gap-2",children:[re&&o("button",{type:"button",onClick:qe,disabled:b,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[D],b&&"cursor-not-allowed opacity-50"),children:E?.today??B.calendarToday}),ne&&o("button",{type:"button",onClick:Je,disabled:b,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[D],b&&"cursor-not-allowed opacity-50"),children:E?.clear??B.calendarClear})]})]})]})}export{yt as Calendar};
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 +1 @@
1
- "use strict";"use client";var ee=Object.defineProperty;var be=Object.getOwnPropertyDescriptor;var pe=Object.getOwnPropertyNames;var Ce=Object.prototype.hasOwnProperty;var ye=(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 h of pe(a))!Ce.call(l,h)&&h!==n&&ee(l,h,{get:()=>a[h],enumerable:!(o=be(a,h))||o.enumerable});return l};var xe=l=>ke(ee({},"__esModule",{value:!0}),l);var Ne={};ye(Ne,{CandlestickChart:()=>Pe});module.exports=xe(Ne);var u=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"),ue=require("../chart/ChartTooltip.cjs"),Y=require("../chart/palette.cjs"),he=require("../chart/utils/cartesian.cjs"),L=require("../chart/utils/data.cjs"),F=require("../chart/utils/format.cjs"),ge=require("../chart/utils/keyboard.cjs"),ce=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,u.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:h,y:C,grid:R,size:W,candleSize:D,fillRising:P,palette:T,referenceLines:O,margin:z,tooltip:f,plotLabel:U,formatValue:b,formatX:E,onCandleClick:y}){let[x,N]=(0,u.useState)(null),g=x!==null&&x<o.length?x:null,k=(0,re.useUILabels)(),t=(0,u.useMemo)(()=>{let r=o.flatMap(i=>i.high===null||i.low===null?[]:[i.low,i.high]),c=(0,he.buildCartesianGeometry)({width:l,height:a,data:n,x:h,y:C,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:_}=c,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,ce.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:c.categoryCenters,bandwidth:M,categoryTicks:c.categoryTicks,valueTicks:c.valueTicks,valueScale:p,innerWidth:q,innerHeight:_,margin:c.margin}},[o,n,h,C,l,a,z,D,P,T,b,E]),j=(0,u.useCallback)(r=>{if(f===!1||o.length===0)return;let c=r.currentTarget.getBoundingClientRect(),p=r.clientX-c.left-t.margin.left;N((0,me.nearestIndex)(t.categoryCenters,p))},[f,o.length,t.margin.left,t.categoryCenters]),H=(0,u.useCallback)(()=>{!y||g===null||y(o[g])},[y,g,o]),Z=(0,u.useCallback)(r=>(0,ge.handleChartKeyDown)(r,{count:o.length,current:g,axis:"x",onMove:N,pick:y?H:null}),[o.length,g,y,H]),s=g===null?null:o[g];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-blue-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}),g!==null?(0,e.jsx)("rect",{x:t.categoryPositions[g],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:h.hidden?null:(0,e.jsx)(te.ChartAxis,{orientation:"bottom",ticks:t.categoryTicks,length:t.innerWidth,label:h.label,size:W})}),(0,e.jsx)("g",{transform:`translate(${t.margin.left}, ${t.margin.top})`,children:C?.hidden?null:(0,e.jsx)(te.ChartAxis,{orientation:"left",ticks:t.valueTicks,length:t.innerHeight,showLine:!1,label:C?.label,size:W})})]}),s&&g!==null&&f!==!1?(0,e.jsx)(ue.ChartTooltip,{x:t.margin.left+t.categoryCenters[g],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,c])=>(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:c===null?"\u2014":b(c)})]},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:h,low:C,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:y=!1,title:x,description:N,loading:g=!1,emptyState:k,error:t=!1,errorState:j,onRetry:H,actions:Z,margin:s,locale:r,plotLabel:c,openLabel:p,highLabel:M,lowLabel:G,closeLabel:q,riseLabel:_,fallLabel:v,format:J,onCandleClick:i,className:$,...V}){let d=(0,re.useUILabels)(),K=(0,u.useMemo)(()=>n?.format??J??(m=>(0,F.formatAuto)(m,r)),[n?.format,J,r]),S=(0,u.useMemo)(()=>a.format??(m=>(0,F.formatXValue)(m,r)),[a.format,r]),X=(0,u.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,h),low:(0,L.readNumber)(m,C),close:I,change:A===null||I===null?null:I-A,rising:A===null||I===null?!0:I>=A,datum:m}}),[l,a.key,o,h,C,R,S]),w=(0,u.useMemo)(()=>({up:P?.up??Y.CHART_UP_COLOR,down:P?.down??Y.CHART_DOWN_COLOR}),[P]),B=(0,u.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:g,empty:X.length===0,emptyState:k,error:t,errorState:j,onRetry:H,actions:Z,tableView:y,legendPosition:ne,legend:fe?(0,e.jsx)(ie.ChartLegend,{items:B,position:ne,marker:"rect",size:f}):void 0,table:y?(0,e.jsx)(se.ChartTableView,{data:l,series:[{key:o,label:p??d.chartOpen},{key:h,label:M??d.chartHigh},{key:C,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:c,formatValue:K,formatX:S,onCandleClick:i})})}0&&(module.exports={CandlestickChart});
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 +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 ue}from"../chart/ChartLegend.js";import{ChartTableView as he}from"../chart/ChartTableView.js";import{ChartTooltip as ge}from"../chart/ChartTooltip.js";import{CHART_DOWN_COLOR as ce,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 Ce}from"../chart/utils/keyboard.js";import{buildBarPath as ye}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:g,height:i,data:n,candles:o,x:p,y:C,grid:L,size:W,candleSize:D,fillRising:R,palette:T,referenceLines:O,margin:z,tooltip:m,plotLabel:F,formatValue:d,formatX:E,onCandleClick:y}){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]),u=de({width:g,height:i,data:n,x:p,y:C,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:_}=u,v=Math.min(D??ve,Math.max(1,M-2));return{rendered:o.map((a,$)=>{let V=G[$]+(M-v)/2,c=V+v/2,K=a.rising?T.up:T.down,N=a.high===null||a.low===null?null:{x:c,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=ye({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:u.categoryCenters,bandwidth:M,categoryTicks:u.categoryTicks,valueTicks:u.valueTicks,valueScale:f,innerWidth:Z,innerHeight:_,margin:u.margin}},[o,n,p,C,g,i,z,D,R,T,d,E]),U=Q(t=>{if(m===!1||o.length===0)return;let u=t.currentTarget.getBoundingClientRect(),f=t.clientX-u.left-e.margin.left;P(ke(e.categoryCenters,f))},[m,o.length,e.margin.left,e.categoryCenters]),H=Q(()=>{!y||s===null||y(o[s])},[y,s,o]),j=Q(t=>Ce(t,{count:o.length,current:s,axis:"x",onMove:P,pick:y?H:null}),[o.length,s,y,H]),l=s===null?null:o[s];return b(Pe,{children:[b("svg",{width:g,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-blue-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:C?.hidden?null:r(re,{orientation:"left",ticks:e.valueTicks,length:e.innerHeight,showLine:!1,label:C?.label,size:W})})]}),l&&s!==null&&m!==!1?r(ge,{x:e.margin.left+e.categoryCenters[s],y:e.margin.top+(l.high===null?e.innerHeight/2:e.valueScale(l.high)),containerWidth:g,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,u])=>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:u===null?"\u2014":d(u)})]},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:g,x:i,y:n,open:o,high:p,low:C,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:y=!1,title:x,description:P,loading:s=!1,emptyState:k,error:e=!1,errorState:U,onRetry:H,actions:j,margin:l,locale:t,plotLabel:u,openLabel:f,highLabel:M,lowLabel:G,closeLabel:Z,riseLabel:_,fallLabel:v,format:q,onCandleClick:a,className:$,...V}){let c=ne(),K=S(()=>n?.format??q??(h=>be(h,t)),[n?.format,q,t]),N=S(()=>i.format??(h=>pe(h,t)),[i.format,t]),X=S(()=>g.map((h,J)=>{let te=fe(h,i.key,J),A=Y(h,o),I=Y(h,L);return{index:J,x:te,label:N(te,J),open:A,high:Y(h,p),low:Y(h,C),close:I,change:A===null||I===null?null:I-A,rising:A===null||I===null?!0:I>=A,datum:h}}),[g,i.key,o,p,C,L,N]),w=S(()=>({up:R?.up??me,down:R?.down??ce}),[R]),B=S(()=>[{key:"up",label:_??c.chartRise,color:w.up,marker:"rect"},{key:"down",label:v??c.chartFall,color:w.down,marker:"rect"}],[w,_,v,c.chartRise,c.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:y,legendPosition:ee,legend:ae?r(ue,{items:B,position:ee,marker:"rect",size:m}):void 0,table:y?r(he,{data:g,series:[{key:o,label:f??c.chartOpen},{key:p,label:M??c.chartHigh},{key:C,label:G??c.chartLow},{key:L,label:Z??c.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:h})=>r(Re,{width:h,height:O,data:g,candles:X,x:i,y:n,grid:F,size:m,candleSize:W,fillRising:D,palette:w,referenceLines:T,margin:l,tooltip:E,plotLabel:u,formatValue:K,formatX:N,onCandleClick:a})})}export{$e as CandlestickChart};
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 +1 @@
1
- "use strict";"use client";var x=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var M=(n,o)=>{for(var t in o)x(n,t,{get:o[t],enumerable:!0})},O=(n,o,t,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let c of I(o))!K.call(n,c)&&c!==t&&x(n,c,{get:()=>o[c],enumerable:!(i=A(o,c))||i.enumerable});return n};var U=n=>O(x({},"__esModule",{value:!0}),n);var H={};M(H,{ChartBrushLayer:()=>N,useChartBrush:()=>X});module.exports=U(H);var u=require("react"),S=require("./utils/keyboard.cjs"),b=require("./utils/scales.cjs"),E=require("react/jsx-runtime"),T=4,L=.14;function N({from:n,to:o,width:t,height:i,orientation:c="vertical",live:p=!1,label:s}){let g=Math.max(0,Math.min(n,o)),d=Math.min(c==="vertical"?t:i,Math.max(n,o)),h=d-g;if(h<=0)return null;let f=c==="vertical",y=f?{x:g,y:0,width:h,height:i}:{x:0,y:g,width:t,height:h},m=a=>f?{x1:a,y1:0,x2:a,y2:i}:{x1:0,y1:a,x2:t,y2:a};return(0,E.jsxs)("g",{"aria-hidden":s?void 0:"true",role:s?"img":void 0,"aria-label":s,children:[(0,E.jsx)("rect",{...y,className:"fill-blue-500",opacity:L}),[g,d].map(a=>(0,E.jsx)("line",{...m(a),className:"stroke-blue-600 dark:stroke-blue-400",strokeWidth:1.5,strokeDasharray:p?"3 3":void 0},a))]})}function X({enabled:n,active:o,centers:t,xValues:i,offset:c,orientation:p,onCommit:s}){let[g,d]=(0,u.useState)(null),h=(0,u.useRef)(null),f=(0,u.useRef)(!1),y=(0,u.useRef)(!1),m=(0,u.useRef)(null),a=(0,u.useCallback)((r,e)=>{let[l,C]=r<=e?[r,e]:[e,r];return{from:i[l],to:i[C],fromIndex:l,toIndex:C}},[i]),R=(0,u.useCallback)(r=>{let e=r.currentTarget.getBoundingClientRect();return p==="vertical"?r.clientX-e.left-c:r.clientY-e.top-c},[p,c]),G=(0,u.useCallback)(r=>{if(!n||t.length===0||r.button!==0)return;let e=R(r),l=(0,b.nearestIndex)(t,e);l<0||(h.current={index:l,pixel:e},f.current=!1,y.current=!1,r.currentTarget.setPointerCapture?.(r.pointerId))},[n,t,R]),V=(0,u.useCallback)(r=>{let e=h.current;if(!n||!e)return;let l=R(r);!f.current&&Math.abs(l-e.pixel)<T||(f.current=!0,d(a(e.index,(0,b.nearestIndex)(t,l))))},[n,t,R,a]),v=(0,u.useCallback)(r=>{let e=h.current;if(h.current=null,!n||!e)return;if(r.currentTarget.hasPointerCapture?.(r.pointerId)&&r.currentTarget.releasePointerCapture?.(r.pointerId),!f.current){d(null),o&&s(null);return}y.current=!0,f.current=!1;let l=a(e.index,(0,b.nearestIndex)(t,R(r)));d(null),m.current=l.fromIndex,s(l)},[n,o,t,R,a,s]),B=(0,u.useCallback)((r,e)=>{if(!n||t.length===0)return;if(r.key==="Escape"){m.current=null,d(null),o&&s(null);return}if(!r.shiftKey){m.current=null;return}let l=p==="vertical",C=l?"ArrowRight":"ArrowDown",w=l?"ArrowLeft":"ArrowUp";if(r.key!==C&&r.key!==w)return;if(e===null){m.current=null;return}let D=(0,S.stepChartCursor)(e,r.key===C?1:-1,t.length),P=m.current??e;m.current=P,s(a(P,D))},[n,o,t.length,p,a,s]),k=(0,u.useCallback)(()=>{let r=y.current;return y.current=!1,r},[]);return{dragging:g,onPointerDown:G,onPointerMove:V,onPointerUp:v,onKeyDown:B,consumedClick:k}}0&&(module.exports={ChartBrushLayer,useChartBrush});
1
+ "use strict";"use client";var P=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var M=(n,o)=>{for(var t in o)P(n,t,{get:o[t],enumerable:!0})},O=(n,o,t,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let l of I(o))!K.call(n,l)&&l!==t&&P(n,l,{get:()=>o[l],enumerable:!(i=A(o,l))||i.enumerable});return n};var U=n=>O(P({},"__esModule",{value:!0}),n);var H={};M(H,{ChartBrushLayer:()=>N,useChartBrush:()=>X});module.exports=U(H);var u=require("react"),b=require("./utils/keyboard.cjs"),x=require("./utils/scales.cjs"),E=require("react/jsx-runtime"),T=4,L=.14;function N({from:n,to:o,width:t,height:i,orientation:l="vertical",live:p=!1,label:s}){let y=Math.max(0,Math.min(n,o)),d=Math.min(l==="vertical"?t:i,Math.max(n,o)),h=d-y;if(h<=0)return null;let f=l==="vertical",g=f?{x:y,y:0,width:h,height:i}:{x:0,y,width:t,height:h},m=a=>f?{x1:a,y1:0,x2:a,y2:i}:{x1:0,y1:a,x2:t,y2:a};return(0,E.jsxs)("g",{"aria-hidden":s?void 0:"true",role:s?"img":void 0,"aria-label":s,children:[(0,E.jsx)("rect",{...g,className:"fill-synertech-primary-500",opacity:L}),[y,d].map(a=>(0,E.jsx)("line",{...m(a),className:"stroke-synertech-primary-600 dark:stroke-synertech-primary-400",strokeWidth:1.5,strokeDasharray:p?"3 3":void 0},a))]})}function X({enabled:n,active:o,centers:t,xValues:i,offset:l,orientation:p,onCommit:s}){let[y,d]=(0,u.useState)(null),h=(0,u.useRef)(null),f=(0,u.useRef)(!1),g=(0,u.useRef)(!1),m=(0,u.useRef)(null),a=(0,u.useCallback)((r,e)=>{let[c,C]=r<=e?[r,e]:[e,r];return{from:i[c],to:i[C],fromIndex:c,toIndex:C}},[i]),R=(0,u.useCallback)(r=>{let e=r.currentTarget.getBoundingClientRect();return p==="vertical"?r.clientX-e.left-l:r.clientY-e.top-l},[p,l]),G=(0,u.useCallback)(r=>{if(!n||t.length===0||r.button!==0)return;let e=R(r),c=(0,x.nearestIndex)(t,e);c<0||(h.current={index:c,pixel:e},f.current=!1,g.current=!1,r.currentTarget.setPointerCapture?.(r.pointerId))},[n,t,R]),V=(0,u.useCallback)(r=>{let e=h.current;if(!n||!e)return;let c=R(r);!f.current&&Math.abs(c-e.pixel)<T||(f.current=!0,d(a(e.index,(0,x.nearestIndex)(t,c))))},[n,t,R,a]),v=(0,u.useCallback)(r=>{let e=h.current;if(h.current=null,!n||!e)return;if(r.currentTarget.hasPointerCapture?.(r.pointerId)&&r.currentTarget.releasePointerCapture?.(r.pointerId),!f.current){d(null),o&&s(null);return}g.current=!0,f.current=!1;let c=a(e.index,(0,x.nearestIndex)(t,R(r)));d(null),m.current=c.fromIndex,s(c)},[n,o,t,R,a,s]),B=(0,u.useCallback)((r,e)=>{if(!n||t.length===0)return;if(r.key==="Escape"){m.current=null,d(null),o&&s(null);return}if(!r.shiftKey){m.current=null;return}let c=p==="vertical",C=c?"ArrowRight":"ArrowDown",w=c?"ArrowLeft":"ArrowUp";if(r.key!==C&&r.key!==w)return;if(e===null){m.current=null;return}let D=(0,b.stepChartCursor)(e,r.key===C?1:-1,t.length),S=m.current??e;m.current=S,s(a(S,D))},[n,o,t.length,p,a,s]),k=(0,u.useCallback)(()=>{let r=g.current;return g.current=!1,r},[]);return{dragging:y,onPointerDown:G,onPointerMove:V,onPointerUp:v,onKeyDown:B,consumedClick:k}}0&&(module.exports={ChartBrushLayer,useChartBrush});
@@ -1 +1 @@
1
- "use client";import{useCallback as m,useRef as E,useState as D}from"react";import{stepChartCursor as A}from"./utils/keyboard.js";import{nearestIndex as b}from"./utils/scales.js";import{jsx as P,jsxs as M}from"react/jsx-runtime";var I=4,K=.14;function L({from:u,to:s,width:n,height:h,orientation:d="vertical",live:p=!1,label:a}){let g=Math.max(0,Math.min(u,s)),f=Math.min(d==="vertical"?n:h,Math.max(u,s)),l=f-g;if(l<=0)return null;let c=d==="vertical",y=c?{x:g,y:0,width:l,height:h}:{x:0,y:g,width:n,height:l},i=t=>c?{x1:t,y1:0,x2:t,y2:h}:{x1:0,y1:t,x2:n,y2:t};return M("g",{"aria-hidden":a?void 0:"true",role:a?"img":void 0,"aria-label":a,children:[P("rect",{...y,className:"fill-blue-500",opacity:K}),[g,f].map(t=>P("line",{...i(t),className:"stroke-blue-600 dark:stroke-blue-400",strokeWidth:1.5,strokeDasharray:p?"3 3":void 0},t))]})}function N({enabled:u,active:s,centers:n,xValues:h,offset:d,orientation:p,onCommit:a}){let[g,f]=D(null),l=E(null),c=E(!1),y=E(!1),i=E(null),t=m((r,e)=>{let[o,C]=r<=e?[r,e]:[e,r];return{from:h[o],to:h[C],fromIndex:o,toIndex:C}},[h]),R=m(r=>{let e=r.currentTarget.getBoundingClientRect();return p==="vertical"?r.clientX-e.left-d:r.clientY-e.top-d},[p,d]),S=m(r=>{if(!u||n.length===0||r.button!==0)return;let e=R(r),o=b(n,e);o<0||(l.current={index:o,pixel:e},c.current=!1,y.current=!1,r.currentTarget.setPointerCapture?.(r.pointerId))},[u,n,R]),G=m(r=>{let e=l.current;if(!u||!e)return;let o=R(r);!c.current&&Math.abs(o-e.pixel)<I||(c.current=!0,f(t(e.index,b(n,o))))},[u,n,R,t]),V=m(r=>{let e=l.current;if(l.current=null,!u||!e)return;if(r.currentTarget.hasPointerCapture?.(r.pointerId)&&r.currentTarget.releasePointerCapture?.(r.pointerId),!c.current){f(null),s&&a(null);return}y.current=!0,c.current=!1;let o=t(e.index,b(n,R(r)));f(null),i.current=o.fromIndex,a(o)},[u,s,n,R,t,a]),v=m((r,e)=>{if(!u||n.length===0)return;if(r.key==="Escape"){i.current=null,f(null),s&&a(null);return}if(!r.shiftKey){i.current=null;return}let o=p==="vertical",C=o?"ArrowRight":"ArrowDown",k=o?"ArrowLeft":"ArrowUp";if(r.key!==C&&r.key!==k)return;if(e===null){i.current=null;return}let w=A(e,r.key===C?1:-1,n.length),x=i.current??e;i.current=x,a(t(x,w))},[u,s,n.length,p,t,a]),B=m(()=>{let r=y.current;return y.current=!1,r},[]);return{dragging:g,onPointerDown:S,onPointerMove:G,onPointerUp:V,onKeyDown:v,consumedClick:B}}export{L as ChartBrushLayer,N as useChartBrush};
1
+ "use client";import{useCallback as m,useRef as E,useState as D}from"react";import{stepChartCursor as A}from"./utils/keyboard.js";import{nearestIndex as x}from"./utils/scales.js";import{jsx as S,jsxs as M}from"react/jsx-runtime";var I=4,K=.14;function L({from:u,to:s,width:n,height:h,orientation:d="vertical",live:p=!1,label:a}){let y=Math.max(0,Math.min(u,s)),f=Math.min(d==="vertical"?n:h,Math.max(u,s)),c=f-y;if(c<=0)return null;let l=d==="vertical",g=l?{x:y,y:0,width:c,height:h}:{x:0,y,width:n,height:c},i=t=>l?{x1:t,y1:0,x2:t,y2:h}:{x1:0,y1:t,x2:n,y2:t};return M("g",{"aria-hidden":a?void 0:"true",role:a?"img":void 0,"aria-label":a,children:[S("rect",{...g,className:"fill-synertech-primary-500",opacity:K}),[y,f].map(t=>S("line",{...i(t),className:"stroke-synertech-primary-600 dark:stroke-synertech-primary-400",strokeWidth:1.5,strokeDasharray:p?"3 3":void 0},t))]})}function N({enabled:u,active:s,centers:n,xValues:h,offset:d,orientation:p,onCommit:a}){let[y,f]=D(null),c=E(null),l=E(!1),g=E(!1),i=E(null),t=m((r,e)=>{let[o,C]=r<=e?[r,e]:[e,r];return{from:h[o],to:h[C],fromIndex:o,toIndex:C}},[h]),R=m(r=>{let e=r.currentTarget.getBoundingClientRect();return p==="vertical"?r.clientX-e.left-d:r.clientY-e.top-d},[p,d]),b=m(r=>{if(!u||n.length===0||r.button!==0)return;let e=R(r),o=x(n,e);o<0||(c.current={index:o,pixel:e},l.current=!1,g.current=!1,r.currentTarget.setPointerCapture?.(r.pointerId))},[u,n,R]),G=m(r=>{let e=c.current;if(!u||!e)return;let o=R(r);!l.current&&Math.abs(o-e.pixel)<I||(l.current=!0,f(t(e.index,x(n,o))))},[u,n,R,t]),V=m(r=>{let e=c.current;if(c.current=null,!u||!e)return;if(r.currentTarget.hasPointerCapture?.(r.pointerId)&&r.currentTarget.releasePointerCapture?.(r.pointerId),!l.current){f(null),s&&a(null);return}g.current=!0,l.current=!1;let o=t(e.index,x(n,R(r)));f(null),i.current=o.fromIndex,a(o)},[u,s,n,R,t,a]),v=m((r,e)=>{if(!u||n.length===0)return;if(r.key==="Escape"){i.current=null,f(null),s&&a(null);return}if(!r.shiftKey){i.current=null;return}let o=p==="vertical",C=o?"ArrowRight":"ArrowDown",k=o?"ArrowLeft":"ArrowUp";if(r.key!==C&&r.key!==k)return;if(e===null){i.current=null;return}let w=A(e,r.key===C?1:-1,n.length),P=i.current??e;i.current=P,a(t(P,w))},[u,s,n.length,p,t,a]),B=m(()=>{let r=g.current;return g.current=!1,r},[]);return{dragging:y,onPointerDown:b,onPointerMove:G,onPointerUp:V,onKeyDown:v,consumedClick:B}}export{L as ChartBrushLayer,N as useChartBrush};
@@ -1 +1 @@
1
- "use strict";"use client";var g=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var K=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var X=(r,t)=>{for(var a in t)g(r,a,{get:t[a],enumerable:!0})},Y=(r,t,a,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of K(t))!Q.call(r,o)&&o!==a&&g(r,o,{get:()=>t[o],enumerable:!(l=J(t,o))||l.enumerable});return r};var _=r=>Y(g({},"__esModule",{value:!0}),r);var ae={};X(ae,{ChartContainer:()=>re});module.exports=_(ae);var c=require("react"),d=require("../../lib/cn.cjs"),I=require("../../lib/i18n.cjs"),T=require("../circular-progress/CircularProgress.cjs"),z=require("./useChartSize.cjs"),e=require("react/jsx-runtime"),ee=(0,e.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",className:"text-red-600 dark:text-red-400",children:[(0,e.jsx)("path",{d:"M10 3.5 2.5 16.5h15L10 3.5Z",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round"}),(0,e.jsx)("path",{d:"M10 8v3.5",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),(0,e.jsx)("circle",{cx:"10",cy:"14",r:"0.9",fill:"currentColor"})]}),te={sm:"text-xs",md:"text-sm",lg:"text-base"};function re({title:r,description:t,height:a=240,width:l,size:o="md",legend:i,legendPosition:u="bottom",actions:x,loading:n=!1,empty:y=!1,emptyState:A,error:f=!1,errorState:P,onRetry:v,errorLabel:j,errorHintLabel:H,retryLabel:W,table:m,tableView:w=!1,showTableLabel:B,hideTableLabel:D,noDataLabel:M,loadingLabel:O,ariaLabel:N,children:h,className:$,...U}){let s=(0,I.useUILabels)(),[b,V]=(0,c.useState)(!1),p=(0,c.useId)(),C=`${p}-table`,k=`${p}-title`,L=`${p}-description`,{ref:Z,width:q,measured:F}=(0,z.useChartSize)({width:l}),R=!!m&&w==="toggle",S=!!m&&(w===!0||R&&b),E=(0,e.jsx)("div",{ref:Z,className:"relative w-full",style:{height:a},"aria-busy":n||void 0,children:n&&(y||f)?(0,e.jsx)("div",{className:"flex h-full w-full items-center justify-center",children:(0,e.jsx)(T.CircularProgress,{indeterminate:!0,size:"md","aria-label":O??s.chartLoading})}):f&&!n?(0,e.jsx)("div",{role:"alert",className:"flex h-full w-full flex-col items-center justify-center gap-2 px-4 text-center",children:P??(0,e.jsxs)(e.Fragment,{children:[ee,(0,e.jsx)("span",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:j??s.chartError}),(0,e.jsx)("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:H??s.chartErrorHint}),v?(0,e.jsx)("button",{type:"button",onClick:v,className:"mt-1 cursor-pointer rounded-md border border-gray-300 bg-white px-3 py-1.5 text-xs font-medium text-gray-700 transition-colors hover:bg-gray-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",children:W??s.chartRetry}):null]})}):y&&!n&&!f?(0,e.jsx)("div",{className:"flex h-full w-full items-center justify-center text-sm text-gray-500 dark:text-gray-400",children:A??M??s.chartNoData}):(0,e.jsx)("div",{className:(0,d.cn)("h-full w-full transition-opacity duration-200",n&&"opacity-60"),children:typeof h=="function"?h({width:q,height:a,measured:F}):h})});return(0,e.jsxs)("figure",{className:(0,d.cn)("flex w-full flex-col gap-3",$),"aria-label":N,"aria-labelledby":!N&&r?k:void 0,"aria-describedby":t?L:void 0,...U,children:[r||t||x?(0,e.jsxs)("figcaption",{className:"flex items-start justify-between gap-3",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-0.5",children:[r?(0,e.jsx)("span",{id:k,className:(0,d.cn)("font-semibold text-gray-900 dark:text-gray-100",te[o]),children:r}):null,t?(0,e.jsx)("span",{id:L,className:"text-xs text-gray-500 dark:text-gray-400",children:t}):null]}),x]}):null,i&&u==="top"?i:null,i&&u==="right"?(0,e.jsxs)("div",{className:"flex items-start gap-4",children:[(0,e.jsx)("div",{className:"min-w-0 grow",children:E}),i]}):E,i&&u==="bottom"?i:null,R&&(0,e.jsx)("div",{className:"flex",children:(0,e.jsx)("button",{type:"button",onClick:()=>V(G=>!G),"aria-expanded":b,"aria-controls":S?C:void 0,className:"cursor-pointer rounded-sm text-xs font-medium text-gray-600 underline underline-offset-2 hover:text-gray-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500 dark:text-gray-400 dark:hover:text-white",children:b?D??s.chartHideTable:B??s.chartShowTable})}),S&&(0,e.jsx)("div",{id:C,children:m})]})}0&&(module.exports={ChartContainer});
1
+ "use strict";"use client";var g=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var K=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var X=(r,t)=>{for(var a in t)g(r,a,{get:t[a],enumerable:!0})},Y=(r,t,a,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of K(t))!Q.call(r,o)&&o!==a&&g(r,o,{get:()=>t[o],enumerable:!(l=J(t,o))||l.enumerable});return r};var _=r=>Y(g({},"__esModule",{value:!0}),r);var ae={};X(ae,{ChartContainer:()=>re});module.exports=_(ae);var c=require("react"),d=require("../../lib/cn.cjs"),I=require("../../lib/i18n.cjs"),T=require("../circular-progress/CircularProgress.cjs"),z=require("./useChartSize.cjs"),e=require("react/jsx-runtime"),ee=(0,e.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",className:"text-red-600 dark:text-red-400",children:[(0,e.jsx)("path",{d:"M10 3.5 2.5 16.5h15L10 3.5Z",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round"}),(0,e.jsx)("path",{d:"M10 8v3.5",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),(0,e.jsx)("circle",{cx:"10",cy:"14",r:"0.9",fill:"currentColor"})]}),te={sm:"text-xs",md:"text-sm",lg:"text-base"};function re({title:r,description:t,height:a=240,width:l,size:o="md",legend:i,legendPosition:u="bottom",actions:x,loading:n=!1,empty:y=!1,emptyState:A,error:f=!1,errorState:P,onRetry:v,errorLabel:j,errorHintLabel:H,retryLabel:W,table:m,tableView:w=!1,showTableLabel:B,hideTableLabel:D,noDataLabel:M,loadingLabel:O,ariaLabel:N,children:h,className:$,...U}){let s=(0,I.useUILabels)(),[p,V]=(0,c.useState)(!1),b=(0,c.useId)(),C=`${b}-table`,k=`${b}-title`,L=`${b}-description`,{ref:Z,width:q,measured:F}=(0,z.useChartSize)({width:l}),R=!!m&&w==="toggle",S=!!m&&(w===!0||R&&p),E=(0,e.jsx)("div",{ref:Z,className:"relative w-full",style:{height:a},"aria-busy":n||void 0,children:n&&(y||f)?(0,e.jsx)("div",{className:"flex h-full w-full items-center justify-center",children:(0,e.jsx)(T.CircularProgress,{indeterminate:!0,size:"md","aria-label":O??s.chartLoading})}):f&&!n?(0,e.jsx)("div",{role:"alert",className:"flex h-full w-full flex-col items-center justify-center gap-2 px-4 text-center",children:P??(0,e.jsxs)(e.Fragment,{children:[ee,(0,e.jsx)("span",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:j??s.chartError}),(0,e.jsx)("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:H??s.chartErrorHint}),v?(0,e.jsx)("button",{type:"button",onClick:v,className:"mt-1 cursor-pointer rounded-md border border-gray-300 bg-white px-3 py-1.5 text-xs 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 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",children:W??s.chartRetry}):null]})}):y&&!n&&!f?(0,e.jsx)("div",{className:"flex h-full w-full items-center justify-center text-sm text-gray-500 dark:text-gray-400",children:A??M??s.chartNoData}):(0,e.jsx)("div",{className:(0,d.cn)("h-full w-full transition-opacity duration-200",n&&"opacity-60"),children:typeof h=="function"?h({width:q,height:a,measured:F}):h})});return(0,e.jsxs)("figure",{className:(0,d.cn)("flex w-full flex-col gap-3",$),"aria-label":N,"aria-labelledby":!N&&r?k:void 0,"aria-describedby":t?L:void 0,...U,children:[r||t||x?(0,e.jsxs)("figcaption",{className:"flex items-start justify-between gap-3",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-0.5",children:[r?(0,e.jsx)("span",{id:k,className:(0,d.cn)("font-semibold text-gray-900 dark:text-gray-100",te[o]),children:r}):null,t?(0,e.jsx)("span",{id:L,className:"text-xs text-gray-500 dark:text-gray-400",children:t}):null]}),x]}):null,i&&u==="top"?i:null,i&&u==="right"?(0,e.jsxs)("div",{className:"flex items-start gap-4",children:[(0,e.jsx)("div",{className:"min-w-0 grow",children:E}),i]}):E,i&&u==="bottom"?i:null,R&&(0,e.jsx)("div",{className:"flex",children:(0,e.jsx)("button",{type:"button",onClick:()=>V(G=>!G),"aria-expanded":p,"aria-controls":S?C:void 0,className:"cursor-pointer rounded-sm text-xs font-medium text-gray-600 underline underline-offset-2 hover:text-gray-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500 dark:text-gray-400 dark:hover:text-white",children:p?D??s.chartHideTable:B??s.chartShowTable})}),S&&(0,e.jsx)("div",{id:C,children:m})]})}0&&(module.exports={ChartContainer});
@@ -1 +1 @@
1
- "use client";import{useId as Z,useState as q}from"react";import{cn as m}from"../../lib/cn.js";import{useUILabels as F}from"../../lib/i18n.js";import{CircularProgress as G}from"../circular-progress/CircularProgress.js";import{useChartSize as J}from"./useChartSize.js";import{Fragment as X,jsx as e,jsxs as a}from"react/jsx-runtime";var K=a("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",className:"text-red-600 dark:text-red-400",children:[e("path",{d:"M10 3.5 2.5 16.5h15L10 3.5Z",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round"}),e("path",{d:"M10 8v3.5",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),e("circle",{cx:"10",cy:"14",r:"0.9",fill:"currentColor"})]}),Q={sm:"text-xs",md:"text-sm",lg:"text-base"};function ie({title:s,description:i,height:h=240,width:R,size:S="md",legend:r,legendPosition:n="bottom",actions:b,loading:o=!1,empty:p=!1,emptyState:E,error:l=!1,errorState:I,onRetry:g,errorLabel:T,errorHintLabel:z,retryLabel:A,table:d,tableView:x=!1,showTableLabel:P,hideTableLabel:j,noDataLabel:H,loadingLabel:W,ariaLabel:y,children:c,className:B,...D}){let t=F(),[u,M]=q(!1),f=Z(),v=`${f}-table`,w=`${f}-title`,N=`${f}-description`,{ref:O,width:$,measured:U}=J({width:R}),C=!!d&&x==="toggle",k=!!d&&(x===!0||C&&u),L=e("div",{ref:O,className:"relative w-full",style:{height:h},"aria-busy":o||void 0,children:o&&(p||l)?e("div",{className:"flex h-full w-full items-center justify-center",children:e(G,{indeterminate:!0,size:"md","aria-label":W??t.chartLoading})}):l&&!o?e("div",{role:"alert",className:"flex h-full w-full flex-col items-center justify-center gap-2 px-4 text-center",children:I??a(X,{children:[K,e("span",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:T??t.chartError}),e("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:z??t.chartErrorHint}),g?e("button",{type:"button",onClick:g,className:"mt-1 cursor-pointer rounded-md border border-gray-300 bg-white px-3 py-1.5 text-xs font-medium text-gray-700 transition-colors hover:bg-gray-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",children:A??t.chartRetry}):null]})}):p&&!o&&!l?e("div",{className:"flex h-full w-full items-center justify-center text-sm text-gray-500 dark:text-gray-400",children:E??H??t.chartNoData}):e("div",{className:m("h-full w-full transition-opacity duration-200",o&&"opacity-60"),children:typeof c=="function"?c({width:$,height:h,measured:U}):c})});return a("figure",{className:m("flex w-full flex-col gap-3",B),"aria-label":y,"aria-labelledby":!y&&s?w:void 0,"aria-describedby":i?N:void 0,...D,children:[s||i||b?a("figcaption",{className:"flex items-start justify-between gap-3",children:[a("div",{className:"flex flex-col gap-0.5",children:[s?e("span",{id:w,className:m("font-semibold text-gray-900 dark:text-gray-100",Q[S]),children:s}):null,i?e("span",{id:N,className:"text-xs text-gray-500 dark:text-gray-400",children:i}):null]}),b]}):null,r&&n==="top"?r:null,r&&n==="right"?a("div",{className:"flex items-start gap-4",children:[e("div",{className:"min-w-0 grow",children:L}),r]}):L,r&&n==="bottom"?r:null,C&&e("div",{className:"flex",children:e("button",{type:"button",onClick:()=>M(V=>!V),"aria-expanded":u,"aria-controls":k?v:void 0,className:"cursor-pointer rounded-sm text-xs font-medium text-gray-600 underline underline-offset-2 hover:text-gray-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500 dark:text-gray-400 dark:hover:text-white",children:u?j??t.chartHideTable:P??t.chartShowTable})}),k&&e("div",{id:v,children:d})]})}export{ie as ChartContainer};
1
+ "use client";import{useId as Z,useState as q}from"react";import{cn as m}from"../../lib/cn.js";import{useUILabels as F}from"../../lib/i18n.js";import{CircularProgress as G}from"../circular-progress/CircularProgress.js";import{useChartSize as J}from"./useChartSize.js";import{Fragment as X,jsx as e,jsxs as a}from"react/jsx-runtime";var K=a("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",className:"text-red-600 dark:text-red-400",children:[e("path",{d:"M10 3.5 2.5 16.5h15L10 3.5Z",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round"}),e("path",{d:"M10 8v3.5",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),e("circle",{cx:"10",cy:"14",r:"0.9",fill:"currentColor"})]}),Q={sm:"text-xs",md:"text-sm",lg:"text-base"};function ie({title:s,description:i,height:h=240,width:R,size:S="md",legend:r,legendPosition:n="bottom",actions:p,loading:o=!1,empty:b=!1,emptyState:E,error:l=!1,errorState:I,onRetry:g,errorLabel:T,errorHintLabel:z,retryLabel:A,table:d,tableView:x=!1,showTableLabel:P,hideTableLabel:j,noDataLabel:H,loadingLabel:W,ariaLabel:y,children:c,className:B,...D}){let t=F(),[u,M]=q(!1),f=Z(),v=`${f}-table`,w=`${f}-title`,N=`${f}-description`,{ref:O,width:$,measured:U}=J({width:R}),C=!!d&&x==="toggle",k=!!d&&(x===!0||C&&u),L=e("div",{ref:O,className:"relative w-full",style:{height:h},"aria-busy":o||void 0,children:o&&(b||l)?e("div",{className:"flex h-full w-full items-center justify-center",children:e(G,{indeterminate:!0,size:"md","aria-label":W??t.chartLoading})}):l&&!o?e("div",{role:"alert",className:"flex h-full w-full flex-col items-center justify-center gap-2 px-4 text-center",children:I??a(X,{children:[K,e("span",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:T??t.chartError}),e("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:z??t.chartErrorHint}),g?e("button",{type:"button",onClick:g,className:"mt-1 cursor-pointer rounded-md border border-gray-300 bg-white px-3 py-1.5 text-xs 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 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",children:A??t.chartRetry}):null]})}):b&&!o&&!l?e("div",{className:"flex h-full w-full items-center justify-center text-sm text-gray-500 dark:text-gray-400",children:E??H??t.chartNoData}):e("div",{className:m("h-full w-full transition-opacity duration-200",o&&"opacity-60"),children:typeof c=="function"?c({width:$,height:h,measured:U}):c})});return a("figure",{className:m("flex w-full flex-col gap-3",B),"aria-label":y,"aria-labelledby":!y&&s?w:void 0,"aria-describedby":i?N:void 0,...D,children:[s||i||p?a("figcaption",{className:"flex items-start justify-between gap-3",children:[a("div",{className:"flex flex-col gap-0.5",children:[s?e("span",{id:w,className:m("font-semibold text-gray-900 dark:text-gray-100",Q[S]),children:s}):null,i?e("span",{id:N,className:"text-xs text-gray-500 dark:text-gray-400",children:i}):null]}),p]}):null,r&&n==="top"?r:null,r&&n==="right"?a("div",{className:"flex items-start gap-4",children:[e("div",{className:"min-w-0 grow",children:L}),r]}):L,r&&n==="bottom"?r:null,C&&e("div",{className:"flex",children:e("button",{type:"button",onClick:()=>M(V=>!V),"aria-expanded":u,"aria-controls":k?v:void 0,className:"cursor-pointer rounded-sm text-xs font-medium text-gray-600 underline underline-offset-2 hover:text-gray-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500 dark:text-gray-400 dark:hover:text-white",children:u?j??t.chartHideTable:P??t.chartShowTable})}),k&&e("div",{id:v,children:d})]})}export{ie as ChartContainer};