@synertech/ui 0.50.1 → 0.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/.claude/skills/use-synertech-ui/SKILL.md +190 -146
  2. package/README.md +27 -19
  3. package/dist/components/accordion/Accordion.cjs +1 -1
  4. package/dist/components/accordion/Accordion.js +1 -1
  5. package/dist/components/advance-detachable/AdvanceDetachable.cjs +1 -1
  6. package/dist/components/advance-detachable/AdvanceDetachable.js +1 -1
  7. package/dist/components/area-chart/AreaChart.cjs +1 -1
  8. package/dist/components/area-chart/AreaChart.js +1 -1
  9. package/dist/components/avatar/Avatar.cjs +1 -1
  10. package/dist/components/avatar/Avatar.js +1 -1
  11. package/dist/components/avatar/AvatarImage.cjs +1 -0
  12. package/dist/components/avatar/AvatarImage.js +1 -0
  13. package/dist/components/banner/Banner.cjs +1 -1
  14. package/dist/components/banner/Banner.js +1 -1
  15. package/dist/components/bar-chart/BarChart.cjs +1 -1
  16. package/dist/components/bar-chart/BarChart.js +1 -1
  17. package/dist/components/box-plot/BoxPlot.cjs +1 -1
  18. package/dist/components/box-plot/BoxPlot.js +1 -1
  19. package/dist/components/breadcrumb/Breadcrumb.cjs +1 -1
  20. package/dist/components/breadcrumb/Breadcrumb.js +1 -1
  21. package/dist/components/bullet-chart/BulletChart.cjs +1 -1
  22. package/dist/components/bullet-chart/BulletChart.js +1 -1
  23. package/dist/components/calendar/Calendar.cjs +1 -1
  24. package/dist/components/calendar/Calendar.js +1 -1
  25. package/dist/components/candlestick-chart/CandlestickChart.cjs +1 -1
  26. package/dist/components/candlestick-chart/CandlestickChart.js +1 -1
  27. package/dist/components/card/Card.cjs +1 -1
  28. package/dist/components/card/Card.js +1 -1
  29. package/dist/components/chart/ChartAnnotations.cjs +1 -1
  30. package/dist/components/chart/ChartAnnotations.js +1 -1
  31. package/dist/components/chart/ChartBrush.cjs +1 -1
  32. package/dist/components/chart/ChartBrush.js +1 -1
  33. package/dist/components/chart/ChartContainer.cjs +1 -1
  34. package/dist/components/chart/ChartContainer.js +1 -1
  35. package/dist/components/chart/ChartExportButton.cjs +1 -1
  36. package/dist/components/chart/ChartExportButton.js +1 -1
  37. package/dist/components/chart/ChartPatterns.cjs +1 -1
  38. package/dist/components/chart/ChartPatterns.js +1 -1
  39. package/dist/components/chart/ChartPeriodPicker.cjs +1 -1
  40. package/dist/components/chart/ChartPeriodPicker.js +1 -1
  41. package/dist/components/chart/ChartPlotClip.cjs +1 -0
  42. package/dist/components/chart/ChartPlotClip.js +1 -0
  43. package/dist/components/chart/ChartSync.cjs +1 -1
  44. package/dist/components/chart/ChartSync.js +1 -1
  45. package/dist/components/chart/ChartTableView.cjs +1 -1
  46. package/dist/components/chart/ChartTableView.js +1 -1
  47. package/dist/components/chart/exportSource.cjs +1 -0
  48. package/dist/components/chart/exportSource.js +1 -0
  49. package/dist/components/chart/palette.cjs +1 -1
  50. package/dist/components/chart/palette.js +1 -1
  51. package/dist/components/chart/useChartSize.cjs +1 -1
  52. package/dist/components/chart/useChartSize.js +1 -1
  53. package/dist/components/chart/utils/bins.cjs +1 -1
  54. package/dist/components/chart/utils/bins.js +1 -1
  55. package/dist/components/chart/utils/cartesian.cjs +1 -1
  56. package/dist/components/chart/utils/cartesian.js +1 -1
  57. package/dist/components/chart/utils/export.cjs +7 -1
  58. package/dist/components/chart/utils/export.js +7 -1
  59. package/dist/components/chart/utils/format.cjs +1 -1
  60. package/dist/components/chart/utils/format.js +1 -1
  61. package/dist/components/chart/utils/keyboard.cjs +1 -1
  62. package/dist/components/chart/utils/keyboard.js +1 -1
  63. package/dist/components/chart/utils/period.cjs +1 -1
  64. package/dist/components/chart/utils/period.js +1 -1
  65. package/dist/components/chart/utils/regression.cjs +1 -0
  66. package/dist/components/chart/utils/regression.js +1 -0
  67. package/dist/components/chart/utils/stack.cjs +1 -1
  68. package/dist/components/chart/utils/stack.js +1 -1
  69. package/dist/components/chart/utils/ticks.cjs +1 -1
  70. package/dist/components/chart/utils/ticks.js +1 -1
  71. package/dist/components/checkbox/Checkbox.cjs +1 -1
  72. package/dist/components/checkbox/Checkbox.js +1 -1
  73. package/dist/components/circular-progress/CircularProgress.cjs +1 -1
  74. package/dist/components/circular-progress/CircularProgress.js +1 -1
  75. package/dist/components/datagrid/DataGrid.cjs +1 -1
  76. package/dist/components/datagrid/DataGrid.js +1 -1
  77. package/dist/components/detachable/Detachable.cjs +1 -1
  78. package/dist/components/detachable/Detachable.js +1 -1
  79. package/dist/components/detachable/popup-window.cjs +1 -0
  80. package/dist/components/detachable/popup-window.js +1 -0
  81. package/dist/components/detachable/useMovableContent.cjs +1 -0
  82. package/dist/components/detachable/useMovableContent.js +1 -0
  83. package/dist/components/device-mockup/DeviceMockup.cjs +1 -1
  84. package/dist/components/device-mockup/DeviceMockup.js +1 -1
  85. package/dist/components/divider/Divider.cjs +1 -1
  86. package/dist/components/divider/Divider.js +1 -1
  87. package/dist/components/drawer/Drawer.cjs +1 -1
  88. package/dist/components/drawer/Drawer.js +1 -1
  89. package/dist/components/dropdown/DropdownContent.cjs +1 -1
  90. package/dist/components/dropdown/DropdownContent.js +1 -1
  91. package/dist/components/dropdown/DropdownSubMenu.cjs +1 -1
  92. package/dist/components/dropdown/DropdownSubMenu.js +1 -1
  93. package/dist/components/dropdown/hooks/useClickOutside.cjs +1 -1
  94. package/dist/components/dropdown/hooks/useClickOutside.js +1 -1
  95. package/dist/components/dropdown/hooks/usePositioning.cjs +1 -1
  96. package/dist/components/dropdown/hooks/usePositioning.js +1 -1
  97. package/dist/components/dumbbell-chart/DumbbellChart.cjs +1 -1
  98. package/dist/components/dumbbell-chart/DumbbellChart.js +1 -1
  99. package/dist/components/file-selector/FileSelector.cjs +1 -1
  100. package/dist/components/file-selector/FileSelector.js +1 -1
  101. package/dist/components/footer/FooterBottom.cjs +1 -1
  102. package/dist/components/footer/FooterBottom.js +1 -1
  103. package/dist/components/form/input/Input.cjs +1 -1
  104. package/dist/components/form/input/Input.js +1 -1
  105. package/dist/components/form/mention-input/MentionInput.cjs +5 -1
  106. package/dist/components/form/mention-input/MentionInput.js +5 -1
  107. package/dist/components/form/number-input/NumberInput.cjs +1 -1
  108. package/dist/components/form/number-input/NumberInput.js +1 -1
  109. package/dist/components/form/shared/InputWrapper.cjs +1 -1
  110. package/dist/components/form/shared/InputWrapper.js +1 -1
  111. package/dist/components/funnel-chart/FunnelChart.cjs +1 -1
  112. package/dist/components/funnel-chart/FunnelChart.js +1 -1
  113. package/dist/components/gantt-chart/GanttChart.cjs +1 -1
  114. package/dist/components/gantt-chart/GanttChart.js +1 -1
  115. package/dist/components/heat-map/Heatmap.cjs +1 -1
  116. package/dist/components/heat-map/Heatmap.js +1 -1
  117. package/dist/components/image-uploader/ImageUploader.cjs +1 -1
  118. package/dist/components/image-uploader/ImageUploader.js +1 -1
  119. package/dist/components/line-chart/LineChart.cjs +1 -1
  120. package/dist/components/line-chart/LineChart.js +1 -1
  121. package/dist/components/modal/Modal.cjs +1 -1
  122. package/dist/components/modal/Modal.js +1 -1
  123. package/dist/components/pagination/Pagination.cjs +1 -1
  124. package/dist/components/pagination/Pagination.js +1 -1
  125. package/dist/components/pie-chart/PieChart.cjs +1 -1
  126. package/dist/components/pie-chart/PieChart.js +1 -1
  127. package/dist/components/progress-bar/ProgressBar.cjs +1 -1
  128. package/dist/components/progress-bar/ProgressBar.js +1 -1
  129. package/dist/components/radio-button/RadioButton.cjs +1 -1
  130. package/dist/components/radio-button/RadioButton.js +1 -1
  131. package/dist/components/scatter-chart/ScatterChart.cjs +1 -1
  132. package/dist/components/scatter-chart/ScatterChart.js +1 -1
  133. package/dist/components/scatter-chart/index.cjs +1 -1
  134. package/dist/components/scatter-chart/index.js +1 -1
  135. package/dist/components/schema-editor/SchemaEditor.cjs +1 -1
  136. package/dist/components/schema-editor/SchemaEditor.js +1 -1
  137. package/dist/components/schema-editor/SchemaEditor.types.cjs +1 -1
  138. package/dist/components/schema-editor/canvas/GridLayer.cjs +1 -1
  139. package/dist/components/schema-editor/canvas/GridLayer.js +1 -1
  140. package/dist/components/schema-editor/minimap/SchemaMinimap.cjs +1 -1
  141. package/dist/components/schema-editor/minimap/SchemaMinimap.js +1 -1
  142. package/dist/components/schema-editor/relations/SchemaRelationRenderer.cjs +1 -1
  143. package/dist/components/schema-editor/relations/SchemaRelationRenderer.js +1 -1
  144. package/dist/components/schema-editor/tables/SchemaTableRenderer.cjs +1 -1
  145. package/dist/components/schema-editor/tables/SchemaTableRenderer.js +1 -1
  146. package/dist/components/schema-editor/toolbar/SchemaToolbar.cjs +1 -1
  147. package/dist/components/schema-editor/toolbar/SchemaToolbar.js +1 -1
  148. package/dist/components/schema-editor/utils/import.cjs +1 -0
  149. package/dist/components/schema-editor/utils/import.js +1 -0
  150. package/dist/components/schema-editor/utils/sql-export.cjs +6 -5
  151. package/dist/components/schema-editor/utils/sql-export.js +7 -6
  152. package/dist/components/select/Select.cjs +1 -1
  153. package/dist/components/select/Select.js +1 -1
  154. package/dist/components/slider/Slider.cjs +1 -1
  155. package/dist/components/slider/Slider.js +1 -1
  156. package/dist/components/sparkline/Sparkline.cjs +1 -1
  157. package/dist/components/sparkline/Sparkline.js +1 -1
  158. package/dist/components/table/TableRow.cjs +1 -1
  159. package/dist/components/table/TableRow.js +1 -1
  160. package/dist/components/waterfall-chart/WaterfallChart.cjs +1 -1
  161. package/dist/components/waterfall-chart/WaterfallChart.js +1 -1
  162. package/dist/components/wizard/Wizard.cjs +1 -1
  163. package/dist/components/wizard/Wizard.js +1 -1
  164. package/dist/components/workflow-editor/WorkflowEditor.cjs +1 -1
  165. package/dist/components/workflow-editor/WorkflowEditor.js +1 -1
  166. package/dist/components/workflow-editor/canvas/GridLayer.cjs +1 -1
  167. package/dist/components/workflow-editor/canvas/GridLayer.js +1 -1
  168. package/dist/components/workflow-editor/nodes/WorkflowNodeRenderer.cjs +1 -1
  169. package/dist/components/workflow-editor/nodes/WorkflowNodeRenderer.js +1 -1
  170. package/dist/components/workflow-editor/toolbar/WorkflowToolbar.cjs +1 -1
  171. package/dist/components/workflow-editor/toolbar/WorkflowToolbar.js +1 -1
  172. package/dist/components/workflow-editor/utils/import.cjs +1 -0
  173. package/dist/components/workflow-editor/utils/import.js +1 -0
  174. package/dist/hooks/useDialogA11y.cjs +1 -1
  175. package/dist/hooks/useDialogA11y.js +1 -1
  176. package/dist/index.d.cts +522 -184
  177. package/dist/index.d.ts +522 -184
  178. package/dist/lib/accept.cjs +1 -0
  179. package/dist/lib/accept.js +1 -0
  180. package/dist/lib/canvas-events.cjs +1 -0
  181. package/dist/lib/canvas-events.js +1 -0
  182. package/dist/lib/css-value.cjs +1 -0
  183. package/dist/lib/css-value.js +1 -0
  184. package/dist/lib/dialog-stack.cjs +1 -1
  185. package/dist/lib/dialog-stack.js +1 -1
  186. package/dist/lib/layer-document.cjs +1 -0
  187. package/dist/lib/layer-document.js +1 -0
  188. package/dist/lib/owner-document.cjs +1 -0
  189. package/dist/lib/owner-document.js +1 -0
  190. package/dist/lib/ui-labels.cjs +1 -1
  191. package/dist/lib/ui-labels.js +1 -1
  192. package/dist/styles-no-preflight.css +10270 -0
  193. package/dist/styles.css +390 -450
  194. package/package.json +9 -4
@@ -1 +1 @@
1
- "use client";import{useCallback as D,useEffect as it,useMemo as _,useRef as Fe,useState as Z}from"react";import{cn as c}from"../../lib/cn.js";import{useUILabels as dt,useUILocale as ct}from"../../lib/i18n.js";import{jsx as o,jsxs as R}from"react/jsx-runtime";var ut=10080*60*1e3;function q(e){return e instanceof Date&&!Number.isNaN(e.getTime())}function G(e){return q(e)?e:void 0}function f(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function V(e){return new Date(e.getFullYear(),e.getMonth(),1)}function T(e,r){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+r)}function C(e,r){return new Date(e.getFullYear(),e.getMonth()+r,1)}function ye(e){return new Date(e.getFullYear(),e.getMonth()+1,0).getDate()}function x(e,r){return!e||!r?!1:e.getFullYear()===r.getFullYear()&&e.getMonth()===r.getMonth()&&e.getDate()===r.getDate()}function fe(e,r){return e.getFullYear()===r.getFullYear()&&e.getMonth()===r.getMonth()}function A(e,r){return e.getFullYear()*12+e.getMonth()-(r.getFullYear()*12+r.getMonth())}function ee(e){let r=`${e.getMonth()+1}`.padStart(2,"0"),i=`${e.getDate()}`.padStart(2,"0");return`${e.getFullYear()}-${r}-${i}`}function gt(e){let r=f(e);r.setDate(r.getDate()-(r.getDay()+6)%7+3);let i=new Date(r.getFullYear(),0,4);return i.setDate(i.getDate()-(i.getDay()+6)%7+3),1+Math.round((r.getTime()-i.getTime())/ut)}function ft(e){return gt(e.find(r=>r.getDay()===4)??e[0])}function Re(e,r,i){return r&&e<f(r)?f(r):i&&e>f(i)?f(i):e}function yt(e,r,i){let z=V(e),j=(z.getDay()-r+7)%7,O=T(z,-j),ae=i?6:Math.ceil((j+ye(e))/7);return Array.from({length:ae},(me,J)=>Array.from({length:7},(be,L)=>T(O,J*7+L)))}function mt({className:e}){return o("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:o("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function bt({className:e}){return o("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:o("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}var pt={sm:{day:"h-7 w-7 text-xs",head:"h-7 w-7 text-[10px]",caption:"text-xs",nav:"h-6 w-6",icon:"h-3 w-3",padding:"p-2",gap:"gap-3",footer:"text-xs",select:"text-xs py-0.5 pl-1 pr-5"},md:{day:"h-9 w-9 text-sm",head:"h-9 w-9 text-xs",caption:"text-sm",nav:"h-7 w-7",icon:"h-4 w-4",padding:"p-3",gap:"gap-4",footer:"text-sm",select:"text-sm py-1 pl-1.5 pr-6"},lg:{day:"h-11 w-11 text-base",head:"h-11 w-11 text-sm",caption:"text-base",nav:"h-9 w-9",icon:"h-5 w-5",padding:"p-4",gap:"gap-5",footer:"text-sm",select:"text-base py-1.5 pl-2 pr-7"}},ht={primary:"bg-synertech-primary-600 text-synertech-on-primary hover:bg-synertech-primary-700",success:"bg-green-700 text-white hover:bg-green-800",warning:"bg-yellow-500 text-gray-900 hover:bg-yellow-600 dark:bg-yellow-400 dark:hover:bg-yellow-500",error:"bg-red-600 text-white hover:bg-red-700",info:"bg-cyan-700 text-white hover:bg-cyan-800",neutral:"bg-gray-700 text-white hover:bg-gray-800 dark:bg-gray-500 dark:hover:bg-gray-400"},Dt={primary:"bg-synertech-primary-50 dark:bg-synertech-primary-900/30",success:"bg-green-50 dark:bg-green-900/30",warning:"bg-yellow-50 dark:bg-yellow-900/30",error:"bg-red-50 dark:bg-red-900/30",info:"bg-cyan-50 dark:bg-cyan-900/30",neutral:"bg-gray-100 dark:bg-gray-700/40"},xt={primary:"text-synertech-primary-900 dark:text-synertech-primary-100",success:"text-green-900 dark:text-green-100",warning:"text-yellow-900 dark:text-yellow-100",error:"text-red-900 dark:text-red-100",info:"text-cyan-900 dark:text-cyan-100",neutral:"text-gray-900 dark:text-gray-100"},vt={primary:"font-semibold text-synertech-primary-600 dark:text-synertech-primary-400",success:"font-semibold text-green-700 dark:text-green-400",warning:"font-semibold text-yellow-700 dark:text-yellow-400",error:"font-semibold text-red-600 dark:text-red-400",info:"font-semibold text-cyan-700 dark:text-cyan-400",neutral:"font-semibold text-gray-900 dark:text-gray-100"},W={primary:"focus-visible:ring-synertech-primary-500",success:"focus-visible:ring-green-500",warning:"focus-visible:ring-yellow-500",error:"focus-visible:ring-red-500",info:"focus-visible:ring-cyan-500",neutral:"focus-visible:ring-gray-500"};function te(e,r){if(e==="multiple")return Array.isArray(r)?r.filter(q).map(f):[];if(e==="range"){let i=r??null;return{from:q(i?.from)?f(i.from):null,to:q(i?.to)?f(i.to):null}}return q(r)?f(r):null}function Pe(e){return e?e instanceof Date?e:Array.isArray(e)?e[0]??null:e.from??e.to??null:null}function St(e){let{mode:r="single",value:i,defaultValue:z,onChange:j,max:O,month:ae,defaultMonth:me,onMonthChange:J,numberOfMonths:be=1,weekStartsOn:L=0,locale:Ye,today:Te,size:Le="md",color:v="primary",minDate:Ae,maxDate:Ee,disabledDates:$,disabled:y=!1,showOutsideDays:Be=!0,showWeekNumbers:pe=!1,fixedWeeks:Ie=!1,captionLayout:re="label",fromYear:he,toYear:De,todayButton:ne=!1,clearButton:oe=!1,footer:xe,bordered:We=!0,renderDay:ve,labels:E,className:Ve,...ze}=e,B=dt(),P=ct(Ye),p=pt[Le],w=Math.max(1,be),le=G(ae),ke=G(me),M=G(Ae),S=G(Ee),se=G(Te)?.getTime(),m=_(()=>f(se===void 0?new Date:new Date(se)),[se]),ie=i!==void 0,[Ke,_e]=Z(()=>te(r,z)),k=ie?te(r,i):Ke,de=le!==void 0,[je,Oe]=Z(()=>V(ke??Pe(te(r,z??i))??m)),u=de?V(le):je,h=D(t=>{let a=V(t);de||Oe(a),J?.(a)},[de,J]),Ce=Fe(null),ce=Fe(!1),[I,Q]=Z(()=>{let t=Pe(te(r,z??i)),a=V(ke??le??t??m),d=t&&fe(t,a)?t:fe(m,a)?m:a;return Re(d,M,S)}),$e=C(u,w-1),He=A(I,u)>=0&&A(I,$e)<=0?I:u;it(()=>{if(!ce.current)return;ce.current=!1,Ce.current?.querySelector(`[data-day="${ee(I)}"]:not([data-outside])`)?.focus()},[I,u]);let Y=D(t=>{let a=Re(f(t),M,S);ce.current=!0,Q(a);let d=C(u,w-1);A(a,u)<0?h(a):A(a,d)>0&&h(C(a,-(w-1)))},[u,w,M,S,h]),K=D(t=>y||M&&t<f(M)||S&&t>f(S)?!0:typeof $=="function"?$(t):Array.isArray($)?$.some(a=>x(a,t)):!1,[y,M,S,$]),[ue,we]=Z(null),N=D(t=>{ie||_e(t),j?.(t)},[ie,j]),X=D(t=>{let a=f(t);if(K(a))return;if(r==="multiple"){let l=k??[];if(l.some(n=>x(n,a))){N(l.filter(n=>!x(n,a)));return}if(O!==void 0&&l.length>=O)return;N([...l,a].sort((n,g)=>n.getTime()-g.getTime()));return}if(r==="range"){let l=k??{from:null,to:null};if(!l.from||l.to){N({from:a,to:null});return}N(a<l.from?{from:a,to:l.from}:{from:l.from,to:a});return}N(x(k,a)?null:a)},[r,k,O,N,K]),Ue=D(t=>{X(t),Q(f(t)),A(t,u)<0?h(t):A(t,C(u,w-1))>0&&h(C(t,-(w-1)))},[X,u,w,h]),Me=!y&&(!M||A(u,V(M))>0),Se=!y&&(!S||A(C(u,w-1),V(S))<0),Ge=D(()=>{h(C(u,-1))},[u,h]),qe=D(()=>{h(C(u,1))},[u,h]),Je=D(t=>{if(y)return;let a=I;switch(t.key){case"ArrowLeft":t.preventDefault(),Y(T(a,-1));break;case"ArrowRight":t.preventDefault(),Y(T(a,1));break;case"ArrowUp":t.preventDefault(),Y(T(a,-7));break;case"ArrowDown":t.preventDefault(),Y(T(a,7));break;case"Home":t.preventDefault(),Y(T(a,-((a.getDay()-L+7)%7)));break;case"End":t.preventDefault(),Y(T(a,6-(a.getDay()-L+7)%7));break;case"PageUp":{t.preventDefault();let d=t.shiftKey?-12:-1,l=C(a,d),b=Math.min(a.getDate(),ye(l));Y(new Date(l.getFullYear(),l.getMonth(),b));break}case"PageDown":{t.preventDefault();let d=t.shiftKey?12:1,l=C(a,d),b=Math.min(a.getDate(),ye(l));Y(new Date(l.getFullYear(),l.getMonth(),b));break}default:break}},[y,I,Y,L]),Qe=_(()=>{let t=new Intl.DateTimeFormat(P,{weekday:"short"}),a=new Intl.DateTimeFormat(P,{weekday:"long"}),d=new Date(2024,0,7);return Array.from({length:7},(l,b)=>{let n=T(d,(L+b)%7);return{short:t.format(n),long:a.format(n)}})},[P,L]),Xe=_(()=>{let t=new Intl.DateTimeFormat(P,{month:"long"});return Array.from({length:12},(a,d)=>t.format(new Date(2024,d,1)))},[P]),Ne=_(()=>new Intl.DateTimeFormat(P,{month:"long",year:"numeric"}),[P]),Ze=_(()=>new Intl.DateTimeFormat(P,{dateStyle:"full"}),[P]),et=_(()=>{if(re!=="dropdown")return[];let t=m.getFullYear(),a=he??M?.getFullYear()??t-100,d=De??S?.getFullYear()??t+10;return d<a?[a]:Array.from({length:d-a+1},(l,b)=>a+b)},[re,he,De,M,S,m]),F=r==="range"?k:null,tt=F&&F.from&&!F.to&&ue&&ue>F.from?ue:null,H=F?.to??tt,at=D((t,a)=>{let d=!fe(t,a),l=K(t),b=!1,n=!1,g=!1,s=!1;return r==="multiple"?b=(k??[]).some(U=>x(U,t)):r==="range"?(n=x(F?.from,t),g=x(H,t),b=n||g,s=!!(F?.from&&H&&t>F.from&&t<H)):b=x(k,t),{selected:b,today:x(t,m),outside:d,disabled:l,rangeStart:n,rangeEnd:g,inRange:s}},[r,k,F,H,K,m]),rt=t=>{let a=C(u,t),d=yt(a,L,Ie),l=t===0,b=t===w-1;return R("div",{className:"flex flex-col",children:[R("div",{className:"mb-2 flex items-center justify-between",children:[o("button",{type:"button",onClick:Ge,disabled:!Me,"aria-label":E?.previousMonth??B.calendarPreviousMonth,className:c("inline-flex items-center justify-center rounded-md transition-colors","text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 dark:focus-visible:ring-offset-gray-900",W[v],p.nav,!Me&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent",!l&&"invisible"),children:o(mt,{className:p.icon})}),re==="dropdown"?R("div",{className:"flex items-center gap-1",children:[o("select",{"aria-label":E?.monthSelect??B.calendarMonth,value:a.getMonth(),disabled:y,onChange:n=>h(new Date(a.getFullYear(),Number(n.target.value)-t,1)),className:c("rounded-md border border-gray-300 bg-white font-medium text-gray-900","dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100","focus:outline-none focus-visible:ring-2",W[v],p.select,y&&"cursor-not-allowed opacity-50"),children:Xe.map((n,g)=>o("option",{value:g,children:n},n))}),o("select",{"aria-label":E?.yearSelect??B.calendarYear,value:a.getFullYear(),disabled:y,onChange:n=>h(new Date(Number(n.target.value),a.getMonth()-t,1)),className:c("rounded-md border border-gray-300 bg-white font-medium text-gray-900","dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100","focus:outline-none focus-visible:ring-2",W[v],p.select,y&&"cursor-not-allowed opacity-50"),children:et.map(n=>o("option",{value:n,children:n},n))})]}):o("div",{"aria-live":"polite",className:c("font-semibold text-gray-900 dark:text-gray-100",p.caption),children:Ne.format(a)}),o("button",{type:"button",onClick:qe,disabled:!Se,"aria-label":E?.nextMonth??B.calendarNextMonth,className:c("inline-flex items-center justify-center rounded-md transition-colors","text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 dark:focus-visible:ring-offset-gray-900",W[v],p.nav,!Se&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent",!b&&"invisible"),children:o(bt,{className:p.icon})})]}),R("table",{role:"grid","aria-label":Ne.format(a),onKeyDown:Je,className:"border-collapse",children:[o("thead",{children:R("tr",{children:[pe&&R("th",{scope:"col",className:c("font-normal text-gray-500 dark:text-gray-400",p.head),children:[o("span",{className:"sr-only",children:E?.weekNumber??B.calendarWeekNumber}),o("span",{"aria-hidden":"true",children:"#"})]}),Qe.map(n=>o("th",{scope:"col",abbr:n.long,className:c("font-medium uppercase text-gray-500 dark:text-gray-400",p.head),children:n.short},n.long))]})}),o("tbody",{children:d.map(n=>R("tr",{children:[pe&&o("td",{className:c("text-center align-middle text-gray-500 dark:text-gray-400",p.head),children:ft(n)}),n.map(g=>{let s=at(g,a),U=ee(g);if(s.outside&&!Be)return o("td",{className:"p-0"},U);let st=x(g,He)&&!s.outside,ge=s.inRange||s.rangeStart&&!!H||s.rangeEnd&&!!F?.from;return o("td",{role:"presentation",className:c("p-0",ge&&Dt[v],ge&&s.rangeStart&&"rounded-l-full",ge&&s.rangeEnd&&"rounded-r-full"),children:o("button",{type:"button","data-day":U,"data-selected":s.selected||void 0,"data-today":s.today||void 0,"data-outside":s.outside||void 0,role:"gridcell",tabIndex:st?0:-1,disabled:y,"aria-selected":s.selected,"aria-disabled":s.disabled||void 0,"aria-current":s.today?"date":void 0,"aria-label":Ze.format(g),onClick:()=>{s.disabled||Ue(g)},onMouseEnter:()=>r==="range"&&we(f(g)),onMouseLeave:()=>r==="range"&&we(null),onFocus:()=>Q(f(g)),className:c("inline-flex items-center justify-center rounded-full transition-colors","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 dark:focus-visible:ring-offset-gray-900",W[v],p.day,s.selected?ht[v]:s.inRange?c(xt[v],"hover:bg-gray-200/60 dark:hover:bg-gray-600/60"):s.today?c(vt[v],"hover:bg-gray-100 dark:hover:bg-gray-700"):c("text-gray-900 dark:text-gray-100","hover:bg-gray-100 dark:hover:bg-gray-700"),s.outside&&!s.selected&&"text-gray-500 dark:text-gray-400",s.disabled&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent"),children:ve?ve(g,s):g.getDate()})},U)})]},ee(n[0])))})]})]},ee(a))},nt=D(()=>{if(h(m),Q(m),K(m))return;(r==="multiple"?(k??[]).some(a=>x(a,m)):r==="single"&&x(k,m))||X(m)},[m,h,K,X,r,k]),ot=D(()=>{N(r==="multiple"?[]:r==="range"?{from:null,to:null}:null)},[r,N]),lt=!!xe||ne||oe;return R("div",{ref:Ce,className:c("inline-block bg-white dark:bg-gray-900",We&&"rounded-lg border border-gray-200 shadow-sm dark:border-gray-700",p.padding,y&&"opacity-60",Ve),...ze,children:[o("div",{className:c("flex flex-wrap",p.gap),children:Array.from({length:w},(t,a)=>rt(a))}),lt&&R("div",{className:c("mt-3 flex items-center justify-between gap-2 border-t border-gray-200 pt-3 dark:border-gray-700",p.footer),children:[o("div",{className:"text-gray-600 dark:text-gray-400",children:xe}),(ne||oe)&&R("div",{className:"flex items-center gap-2",children:[ne&&o("button",{type:"button",onClick:nt,disabled:y,className:c("rounded-md px-2 py-1 font-medium transition-colors","text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2",W[v],y&&"cursor-not-allowed opacity-50"),children:E?.today??B.calendarToday}),oe&&o("button",{type:"button",onClick:ot,disabled:y,className:c("rounded-md px-2 py-1 font-medium transition-colors","text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2",W[v],y&&"cursor-not-allowed opacity-50"),children:E?.clear??B.calendarClear})]})]})]})}export{St as Calendar};
1
+ "use client";import{useCallback as v,useEffect as ct,useMemo as K,useRef as Pe,useState as ae}from"react";import{cn as g}from"../../lib/cn.js";import{useUILabels as ut,useUILocale as gt}from"../../lib/i18n.js";import{jsx as o,jsxs as P}from"react/jsx-runtime";var ft=10080*60*1e3;function J(e){return e instanceof Date&&!Number.isNaN(e.getTime())}function q(e){return J(e)?e:void 0}function f(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function V(e){return new Date(e.getFullYear(),e.getMonth(),1)}function L(e,r){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+r)}function x(e,r){return new Date(e.getFullYear(),e.getMonth()+r,1)}function be(e){return new Date(e.getFullYear(),e.getMonth()+1,0).getDate()}function k(e,r){return!e||!r?!1:e.getFullYear()===r.getFullYear()&&e.getMonth()===r.getMonth()&&e.getDate()===r.getDate()}function me(e,r){return e.getFullYear()===r.getFullYear()&&e.getMonth()===r.getMonth()}function R(e,r){return e.getFullYear()*12+e.getMonth()-(r.getFullYear()*12+r.getMonth())}function re(e){let r=`${e.getMonth()+1}`.padStart(2,"0"),d=`${e.getDate()}`.padStart(2,"0");return`${e.getFullYear()}-${r}-${d}`}function yt(e){let r=f(e);r.setDate(r.getDate()-(r.getDay()+6)%7+3);let d=new Date(r.getFullYear(),0,4);return d.setDate(d.getDate()-(d.getDay()+6)%7+3),1+Math.round((r.getTime()-d.getTime())/ft)}function mt(e){return yt(e.find(r=>r.getDay()===4)??e[0])}function Ye(e,r,d){return r&&e<f(r)?f(r):d&&e>f(d)?f(d):e}function bt(e,r,d){let z=V(e),j=(z.getDay()-r+7)%7,O=L(z,-j),oe=d?6:Math.ceil((j+be(e))/7);return Array.from({length:oe},(pe,Q)=>Array.from({length:7},(he,A)=>L(O,Q*7+A)))}function pt({className:e}){return o("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:o("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function ht({className:e}){return o("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:o("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}var Dt={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"}},xt={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"},vt={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"},kt={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"},wt={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 ne(e,r){if(e==="multiple")return Array.isArray(r)?r.filter(J).map(f):[];if(e==="range"){let d=r??null;return{from:J(d?.from)?f(d.from):null,to:J(d?.to)?f(d.to):null}}return J(r)?f(r):null}function Te(e){return e?e instanceof Date?e:Array.isArray(e)?e[0]??null:e.from??e.to??null:null}function Ft(e){let{mode:r="single",value:d,defaultValue:z,onChange:j,max:O,month:oe,defaultMonth:pe,onMonthChange:Q,numberOfMonths:he=1,weekStartsOn:A=0,locale:Le,today:Ae,size:Ee="md",color:w="primary",minDate:Be,maxDate:Ie,disabledDates:$,disabled:y=!1,showOutsideDays:We=!0,showWeekNumbers:De=!1,fixedWeeks:Ve=!1,captionLayout:H="label",fromYear:X,toYear:Z,todayButton:le=!1,clearButton:se=!1,footer:xe,bordered:ze=!0,renderDay:ve,labels:E,className:_e,...Ke}=e,B=ut(),Y=gt(Le),p=Dt[Ee],D=Math.max(1,he),ie=q(oe),ke=q(pe),M=q(Be),S=q(Ie),de=q(Ae)?.getTime(),m=K(()=>f(de===void 0?new Date:new Date(de)),[de]),ce=d!==void 0,[je,Oe]=ae(()=>ne(r,z)),C=ce?ne(r,d):je,ue=ie!==void 0,[$e,He]=ae(()=>V(ke??Te(ne(r,z??d))??m)),c=ue?V(ie):$e,h=v(t=>{let a=V(t);ue||He(a),Q?.(a)},[ue,Q]),we=Pe(null),ge=Pe(!1),[I,ee]=ae(()=>{let t=Te(ne(r,z??d)),a=V(ke??ie??t??m),u=t&&me(t,a)?t:me(m,a)?m:a;return Ye(u,M,S)}),Ue=x(c,D-1),Ge=R(I,c)>=0&&R(I,Ue)<=0?I:c;ct(()=>{if(!ge.current)return;ge.current=!1,we.current?.querySelector(`[data-day="${re(I)}"]:not([data-outside])`)?.focus()},[I,c]);let T=v(t=>{let a=Ye(f(t),M,S);ge.current=!0,ee(a);let u=x(c,D-1);R(a,c)<0?h(a):R(a,u)>0&&h(x(a,-(D-1)))},[c,D,M,S,h]),_=v(t=>y||M&&t<f(M)||S&&t>f(S)?!0:typeof $=="function"?$(t):Array.isArray($)?$.some(a=>k(a,t)):!1,[y,M,S,$]),[fe,Ce]=ae(null),N=v(t=>{ce||Oe(t),j?.(t)},[ce,j]),te=v(t=>{let a=f(t);if(_(a))return;if(r==="multiple"){let l=C??[];if(l.some(n=>k(n,a))){N(l.filter(n=>!k(n,a)));return}if(O!==void 0&&l.length>=O)return;N([...l,a].sort((n,i)=>n.getTime()-i.getTime()));return}if(r==="range"){let l=C??{from:null,to:null};if(!l.from||l.to){N({from:a,to:null});return}N(a<l.from?{from:a,to:l.from}:{from:l.from,to:a});return}N(k(C,a)?null:a)},[r,C,O,N,_]),qe=v(t=>{te(t),ee(f(t)),R(t,c)<0?h(t):R(t,x(c,D-1))>0&&h(x(t,-(D-1)))},[te,c,D,h]),Me=H==="dropdown"&&X!==void 0?new Date(X,0,1):null,Se=H==="dropdown"&&Z!==void 0?new Date(Z,11,1):null,Ne=!y&&(!M||R(c,V(M))>0)&&(!Me||R(c,Me)>0),Fe=!y&&(!S||R(x(c,D-1),V(S))<0)&&(!Se||R(x(c,D-1),Se)<0),Je=v(()=>{h(x(c,-1))},[c,h]),Qe=v(()=>{h(x(c,1))},[c,h]),Xe=v(t=>{if(y)return;let a=I;switch(t.key){case"ArrowLeft":t.preventDefault(),T(L(a,-1));break;case"ArrowRight":t.preventDefault(),T(L(a,1));break;case"ArrowUp":t.preventDefault(),T(L(a,-7));break;case"ArrowDown":t.preventDefault(),T(L(a,7));break;case"Home":t.preventDefault(),T(L(a,-((a.getDay()-A+7)%7)));break;case"End":t.preventDefault(),T(L(a,6-(a.getDay()-A+7)%7));break;case"PageUp":{t.preventDefault();let u=t.shiftKey?-12:-1,l=x(a,u),b=Math.min(a.getDate(),be(l));T(new Date(l.getFullYear(),l.getMonth(),b));break}case"PageDown":{t.preventDefault();let u=t.shiftKey?12:1,l=x(a,u),b=Math.min(a.getDate(),be(l));T(new Date(l.getFullYear(),l.getMonth(),b));break}default:break}},[y,I,T,A]),Ze=K(()=>{let t=new Intl.DateTimeFormat(Y,{weekday:"short"}),a=new Intl.DateTimeFormat(Y,{weekday:"long"}),u=new Date(2024,0,7);return Array.from({length:7},(l,b)=>{let n=L(u,(A+b)%7);return{short:t.format(n),long:a.format(n)}})},[Y,A]),et=K(()=>{let t=new Intl.DateTimeFormat(Y,{month:"long"});return Array.from({length:12},(a,u)=>t.format(new Date(2024,u,1)))},[Y]),Re=K(()=>new Intl.DateTimeFormat(Y,{month:"long",year:"numeric"}),[Y]),tt=K(()=>new Intl.DateTimeFormat(Y,{dateStyle:"full"}),[Y]),at=K(()=>{if(H!=="dropdown")return[];let t=m.getFullYear(),a=X??M?.getFullYear()??t-100,u=Z??S?.getFullYear()??t+10,l=u<a?[a]:Array.from({length:u-a+1},(n,i)=>a+i),b=Array.from({length:D},(n,i)=>x(c,i).getFullYear());return[...new Set([...l,...b])].sort((n,i)=>n-i)},[H,X,Z,M,S,m,c,D]),F=r==="range"?C:null,rt=F&&F.from&&!F.to&&fe&&fe>F.from?fe:null,U=F?.to??rt,nt=v((t,a)=>{let u=!me(t,a),l=_(t),b=!1,n=!1,i=!1,s=!1;return r==="multiple"?b=(C??[]).some(G=>k(G,t)):r==="range"?(n=k(F?.from,t),i=k(U,t),b=n||i,s=!!(F?.from&&U&&t>F.from&&t<U)):b=k(C,t),{selected:b,today:k(t,m),outside:u,disabled:l,rangeStart:n,rangeEnd:i,inRange:s}},[r,C,F,U,_,m]),ot=t=>{let a=x(c,t),u=bt(a,A,Ve),l=t===0,b=t===D-1;return P("div",{className:"flex flex-col",children:[P("div",{className:"mb-2 flex items-center justify-between",children:[o("button",{type:"button",onClick:Je,disabled:!Ne,"aria-label":E?.previousMonth??B.calendarPreviousMonth,className:g("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[w],p.nav,!Ne&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent",!l&&"invisible"),children:o(pt,{className:p.icon})}),H==="dropdown"?P("div",{className:"flex items-center gap-1",children:[o("select",{"aria-label":E?.monthSelect??B.calendarMonth,value:a.getMonth(),disabled:y,onChange:n=>h(new Date(a.getFullYear(),Number(n.target.value)-t,1)),className:g("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[w],p.select,y&&"cursor-not-allowed opacity-50"),children:et.map((n,i)=>o("option",{value:i,children:n},n))}),o("select",{"aria-label":E?.yearSelect??B.calendarYear,value:a.getFullYear(),disabled:y,onChange:n=>h(new Date(Number(n.target.value),a.getMonth()-t,1)),className:g("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[w],p.select,y&&"cursor-not-allowed opacity-50"),children:at.map(n=>o("option",{value:n,children:n},n))})]}):o("div",{"aria-live":"polite",className:g("font-semibold text-gray-900 dark:text-gray-100",p.caption),children:Re.format(a)}),o("button",{type:"button",onClick:Qe,disabled:!Fe,"aria-label":E?.nextMonth??B.calendarNextMonth,className:g("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[w],p.nav,!Fe&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent",!b&&"invisible"),children:o(ht,{className:p.icon})})]}),P("table",{role:"grid","aria-label":Re.format(a),onKeyDown:Xe,className:"border-collapse",children:[o("thead",{children:P("tr",{children:[De&&P("th",{scope:"col",className:g("font-normal text-gray-500 dark:text-gray-400",p.head),children:[o("span",{className:"sr-only",children:E?.weekNumber??B.calendarWeekNumber}),o("span",{"aria-hidden":"true",children:"#"})]}),Ze.map(n=>o("th",{scope:"col",abbr:n.long,className:g("font-medium uppercase text-gray-500 dark:text-gray-400",p.head),children:n.short},n.long))]})}),o("tbody",{children:u.map(n=>P("tr",{children:[De&&o("td",{className:g("text-center align-middle text-gray-500 dark:text-gray-400",p.head),children:mt(n)}),n.map(i=>{let s=nt(i,a),G=re(i);if(s.outside&&!We)return o("td",{className:"p-0"},G);let dt=k(i,Ge)&&!s.outside,ye=s.inRange||s.rangeStart&&!!U||s.rangeEnd&&!!F?.from;return o("td",{role:"presentation",className:g("p-0",ye&&vt[w],ye&&s.rangeStart&&"rounded-l-full",ye&&s.rangeEnd&&"rounded-r-full"),children:o("button",{type:"button","data-day":G,"data-selected":s.selected||void 0,"data-today":s.today||void 0,"data-outside":s.outside||void 0,role:"gridcell",tabIndex:dt?0:-1,disabled:y,"aria-selected":s.selected,"aria-disabled":s.disabled||void 0,"aria-current":s.today?"date":void 0,"aria-label":tt.format(i),onClick:()=>{s.disabled||qe(i)},onMouseEnter:()=>r==="range"&&Ce(f(i)),onMouseLeave:()=>r==="range"&&Ce(null),onFocus:()=>ee(f(i)),className:g("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[w],p.day,s.selected?xt[w]:s.inRange?g(kt[w],"hover:bg-gray-200/60 dark:hover:bg-gray-600/60"):s.today?g(wt[w],"hover:bg-gray-100 dark:hover:bg-gray-700"):g("text-gray-900 dark:text-gray-100","hover:bg-gray-100 dark:hover:bg-gray-700"),s.outside&&!s.selected&&"text-gray-500 dark:text-gray-400",s.disabled&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent"),children:ve?ve(i,s):i.getDate()})},G)})]},re(n[0])))})]})]},re(a))},lt=v(()=>{if(h(m),ee(m),_(m))return;(r==="multiple"?(C??[]).some(a=>k(a,m)):r==="single"&&k(C,m))||te(m)},[m,h,_,te,r,C]),st=v(()=>{N(r==="multiple"?[]:r==="range"?{from:null,to:null}:null)},[r,N]),it=!!xe||le||se;return P("div",{ref:we,className:g("inline-block bg-white dark:bg-gray-900",ze&&"rounded-lg border border-gray-200 shadow-sm dark:border-gray-700",p.padding,y&&"opacity-60",_e),...Ke,children:[o("div",{className:g("flex flex-wrap",p.gap),children:Array.from({length:D},(t,a)=>ot(a))}),it&&P("div",{className:g("mt-3 flex items-center justify-between gap-2 border-t border-gray-200 pt-3 dark:border-gray-700",p.footer),children:[o("div",{className:"text-gray-600 dark:text-gray-400",children:xe}),(le||se)&&P("div",{className:"flex items-center gap-2",children:[le&&o("button",{type:"button",onClick:lt,disabled:y,className:g("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[w],y&&"cursor-not-allowed opacity-50"),children:E?.today??B.calendarToday}),se&&o("button",{type:"button",onClick:st,disabled:y,className:g("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[w],y&&"cursor-not-allowed opacity-50"),children:E?.clear??B.calendarClear})]})]})]})}export{Ft as Calendar};
@@ -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=(l,a)=>{for(var n in a)te(l,n,{get:a[n],enumerable:!0})},xe=(l,a,n,o)=>{if(a&&typeof a=="object"||typeof a=="function")for(let h of ye(a))!Ce.call(l,h)&&h!==n&&te(l,h,{get:()=>a[h],enumerable:!(o=pe(a,h))||o.enumerable});return l};var ve=l=>xe(te({},"__esModule",{value:!0}),l);var Se={};ke(Se,{CandlestickChart:()=>Ne});module.exports=ve(Se);var c=require("react"),D=require("../../lib/i18n.cjs"),re=require("../chart/ChartAxis.cjs"),oe=require("../chart/ChartContainer.cjs"),le=require("../chart/ChartGrid.cjs"),ie=require("../chart/ChartLegend.cjs"),se=require("../chart/ChartTableView.cjs"),ce=require("../chart/ChartTooltip.cjs"),U=require("../chart/palette.cjs"),he=require("../chart/utils/cartesian.cjs"),R=require("../chart/utils/data.cjs"),F=require("../chart/utils/format.cjs"),ue=require("../chart/utils/keyboard.cjs"),ge=require("../chart/utils/path.cjs"),me=require("../chart/utils/scales.cjs"),de=require("../chart/utils/touch.cjs"),e=require("react/jsx-runtime"),we=16,Le=1.5,Re=(0,c.memo)(function({candles:a}){return(0,e.jsx)("g",{children:a.map(n=>(0,e.jsxs)("g",{children:[n.wick?(0,e.jsx)("line",{x1:n.wick.x,y1:n.wick.y1,x2:n.wick.x,y2:n.wick.y2,stroke:n.color,strokeWidth:1.5}):null,n.body?(0,e.jsx)("path",{d:n.body,fill:n.hollow?"none":n.color,stroke:n.color,strokeWidth:n.hollow?1.5:0}):null]},n.key))})});function Pe({width:l,height:a,data:n,candles:o,x:h,y,grid:P,size:O,candleSize:z,fillRising:N,palette:H,referenceLines:E,margin:G,tooltip:f,plotLabel:j,formatValue:b,formatX:_,onCandleClick:C}){let[x,S]=(0,c.useState)(null),u=x!==null&&x<o.length?x:null,k=(0,D.useUILabels)(),t=(0,c.useMemo)(()=>{let r=o.flatMap(i=>i.high===null||i.low===null?[]:[i.low,i.high]),g=(0,he.buildCartesianGeometry)({width:l,height:a,data:n,x:h,y,bounds:r.length===0?null:[Math.min(...r),Math.max(...r)],margin:G,orientation:"vertical",placement:"band",formatValue:b,formatX:_,defaultIncludeZero:!1}),{valueScale:p,bandwidth:I,categoryPositions:$,innerWidth:J,innerHeight:K}=g,v=Math.min(z??we,Math.max(1,I-2));return{rendered:o.map((i,B)=>{let V=$[B]+(I-v)/2,T=V+v/2,d=i.rising?H.up:H.down,Y=i.high===null||i.low===null?null:{x:T,y1:p(i.high),y2:p(i.low)},w=null;if(i.open!==null&&i.close!==null){let X=p(i.open),L=p(i.close);w=(0,ge.buildBarPath)({x:V,y:Math.min(X,L),width:v,height:Math.max(Le,Math.abs(L-X)),radius:0,round:"none"})}return{key:`${B}`,color:d,body:w,hollow:i.rising&&!N,wick:Y,left:V,width:v}}),categoryPositions:$,categoryCenters:g.categoryCenters,bandwidth:I,categoryTicks:g.categoryTicks,valueTicks:g.valueTicks,valueScale:p,innerWidth:J,innerHeight:K,margin:g.margin}},[o,n,h,y,l,a,G,z,N,H,b,_]),Z=(0,c.useCallback)(r=>{if(f===!1||o.length===0)return;let g=r.currentTarget.getBoundingClientRect(),p=r.clientX-g.left-t.margin.left;S((0,me.nearestIndex)(t.categoryCenters,p))},[f,o.length,t.margin.left,t.categoryCenters]),M=(0,c.useCallback)(()=>{!C||u===null||C(o[u])},[C,u,o]),q=(0,c.useCallback)(r=>(0,ue.handleChartKeyDown)(r,{count:o.length,current:u,axis:"x",onMove:S,pick:C?M:null}),[o.length,u,C,M]),s=u===null?null:o[u];return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("svg",{width:l,height:a,role:"img","aria-label":j??o.map(r=>r.label).join(", "),tabIndex:0,className:`${de.CHART_TOUCH} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:Z,onPointerLeave:()=>S(null),onKeyDown:q,onBlur:()=>S(null),onClick:M,children:[(0,e.jsxs)("g",{transform:`translate(${t.margin.left}, ${t.margin.top})`,children:[(0,e.jsx)(le.ChartGrid,{width:t.innerWidth,height:t.innerHeight,horizontal:P==="y"||P==="both"?t.valueTicks.map(r=>r.offset):void 0}),u!==null?(0,e.jsx)("rect",{x:t.categoryPositions[u],y:0,width:t.bandwidth,height:t.innerHeight,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,E?.map(r=>(0,e.jsxs)("g",{children:[(0,e.jsx)("line",{x1:0,y1:t.valueScale(r.value),x2:t.innerWidth,y2:t.valueScale(r.value),stroke:r.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:r.dashed===!1?void 0:"4 4"}),r.label?(0,e.jsx)("text",{x:t.innerWidth,y:t.valueScale(r.value)-4,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:r.label}):null]},`${r.value}-${r.label??""}`)),(0,e.jsx)(Re,{candles:t.rendered})]}),(0,e.jsx)("g",{transform:`translate(${t.margin.left}, ${t.margin.top+t.innerHeight})`,children:h.hidden?null:(0,e.jsx)(re.ChartAxis,{orientation:"bottom",ticks:t.categoryTicks,length:t.innerWidth,label:h.label,size:O})}),(0,e.jsx)("g",{transform:`translate(${t.margin.left}, ${t.margin.top})`,children:y?.hidden?null:(0,e.jsx)(re.ChartAxis,{orientation:"left",ticks:t.valueTicks,length:t.innerHeight,showLine:!1,label:y?.label,size:O})})]}),s&&u!==null&&f!==!1?(0,e.jsx)(ce.ChartTooltip,{x:t.margin.left+t.categoryCenters[u],y:t.margin.top+(s.high===null?t.innerHeight/2:t.valueScale(s.high)),containerWidth:l,children:typeof f=="function"?f(s):(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:s.label}),(0,e.jsx)("dl",{className:"grid grid-cols-[auto_auto] gap-x-3 gap-y-0.5",children:[[k.chartOpen,s.open],[k.chartHigh,s.high],[k.chartLow,s.low],[k.chartClose,s.close]].map(([r,g])=>(0,e.jsxs)("div",{className:"contents",children:[(0,e.jsx)("dt",{className:"text-gray-500 dark:text-gray-400",children:r}),(0,e.jsx)("dd",{className:"justify-self-end font-medium text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:g===null?"\u2014":b(g)})]},r))}),s.change===null?null:(0,e.jsxs)("div",{className:"flex items-center gap-2 border-t border-gray-200 pt-1 dark:border-gray-700",children:[(0,e.jsx)("span",{className:"text-gray-500 dark:text-gray-400",children:s.rising?k.chartRise:k.chartFall}),(0,e.jsxs)("span",{className:"[font-variant-numeric:tabular-nums] font-semibold text-gray-900 dark:text-gray-100",children:[s.change>0?"+":"",b(s.change)]})]})]})}):null]})}function Ne({data:l,x:a,y:n,open:o,high:h,low:y,close:P,candleSize:O,fillRising:z=!1,colors:N,referenceLines:H,height:E=300,width:G,size:f="md",grid:j="y",legend:b,tooltip:_=!0,tableView:C=!1,title:x,description:S,loading:u=!1,emptyState:k,error:t=!1,errorState:Z,onRetry:M,actions:q,margin:s,locale:r,plotLabel:g,openLabel:p,highLabel:I,lowLabel:$,closeLabel:J,riseLabel:K,fallLabel:v,format:Q,onCandleClick:i,className:B,...V}){let T=(0,D.useUILocale)(r),d=(0,D.useUILabels)(),Y=(0,c.useMemo)(()=>n?.format??Q??(m=>(0,F.formatAuto)(m,T)),[n?.format,Q,T]),w=(0,c.useMemo)(()=>a.format??(m=>(0,F.formatXValue)(m,T)),[a.format,T]),X=(0,c.useMemo)(()=>l.map((m,ee)=>{let ae=(0,R.readXValue)(m,a.key,ee),A=(0,R.readNumber)(m,o),W=(0,R.readNumber)(m,P);return{index:ee,x:ae,label:w(ae,ee),open:A,high:(0,R.readNumber)(m,h),low:(0,R.readNumber)(m,y),close:W,change:A===null||W===null?null:W-A,rising:A===null||W===null?!0:W>=A,datum:m}}),[l,a.key,o,h,y,P,w]),L=(0,c.useMemo)(()=>({up:N?.up??U.CHART_UP_COLOR,down:N?.down??U.CHART_DOWN_COLOR}),[N]),fe=(0,c.useMemo)(()=>[{key:"up",label:K??d.chartRise,color:L.up,marker:"rect"},{key:"down",label:v??d.chartFall,color:L.down,marker:"rect"}],[L,K,v,d.chartRise,d.chartFall]),be=b===void 0?!0:b!==!1,ne=typeof b=="string"?b:"bottom";return(0,e.jsx)(oe.ChartContainer,{title:x,description:S,height:E,width:G,size:f,loading:u,empty:X.length===0,emptyState:k,error:t,errorState:Z,onRetry:M,actions:q,tableView:C,legendPosition:ne,legend:be?(0,e.jsx)(ie.ChartLegend,{items:fe,position:ne,marker:"rect",size:f}):void 0,table:C?(0,e.jsx)(se.ChartTableView,{data:l,series:[{key:o,label:p??d.chartOpen},{key:h,label:I??d.chartHigh},{key:y,label:$??d.chartLow},{key:P,label:J??d.chartClose}],xKey:a.key,xLabel:a.label??a.key,formatX:w,formatValue:Y,caption:typeof x=="string"?x:void 0}):void 0,className:B,...V,children:({width:m})=>(0,e.jsx)(Pe,{width:m,height:E,data:l,candles:X,x:a,y:n,grid:j,size:f,candleSize:O,fillRising:z,palette:L,referenceLines:H,margin:s,tooltip:_,plotLabel:g,formatValue:Y,formatX:w,onCandleClick:i})})}0&&(module.exports={CandlestickChart});
1
+ "use strict";"use client";var ae=Object.defineProperty;var ke=Object.getOwnPropertyDescriptor;var we=Object.getOwnPropertyNames;var xe=Object.prototype.hasOwnProperty;var ve=(o,n)=>{for(var u in n)ae(o,u,{get:n[u],enumerable:!0})},Le=(o,n,u,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let c of we(n))!xe.call(o,c)&&c!==u&&ae(o,c,{get:()=>n[c],enumerable:!(r=ke(n,c))||r.enumerable});return o};var Pe=o=>Le(ae({},"__esModule",{value:!0}),o);var Te={};ve(Te,{CandlestickChart:()=>He});module.exports=Pe(Te);var s=require("react"),z=require("../../lib/i18n.cjs"),oe=require("../chart/ChartAxis.cjs"),he=require("../chart/ChartContainer.cjs"),ue=require("../chart/ChartGrid.cjs"),ge=require("../chart/ChartLegend.cjs"),T=require("../chart/ChartPlotClip.cjs"),de=require("../chart/ChartTableView.cjs"),me=require("../chart/ChartTooltip.cjs"),J=require("../chart/palette.cjs"),V=require("../chart/utils/cartesian.cjs"),v=require("../chart/utils/data.cjs"),Q=require("../chart/utils/format.cjs"),fe=require("../chart/utils/keyboard.cjs"),pe=require("../chart/utils/path.cjs"),be=require("../chart/utils/scales.cjs"),ye=require("../chart/utils/ticks.cjs"),Ce=require("../chart/utils/touch.cjs"),e=require("react/jsx-runtime"),Re=16,Ne=1.5,Se=(0,s.memo)(function({candles:n,clipId:u}){return(0,e.jsx)("g",{clipPath:`url(#${u})`,children:n.map(r=>(0,e.jsxs)("g",{children:[r.wick?(0,e.jsx)("line",{x1:r.wick.x,y1:r.wick.y1,x2:r.wick.x,y2:r.wick.y2,stroke:r.color,strokeWidth:1.5}):null,r.body?(0,e.jsx)("path",{d:r.body,fill:r.hollow?"none":r.color,stroke:r.color,strokeWidth:r.hollow?1.5:0}):null]},r.key))})});function Ie({width:o,height:n,data:u,candles:r,x:c,y,grid:L,size:E,candleSize:G,fillRising:P,palette:X,referenceLines:R,margin:_,tooltip:f,plotLabel:ee,formatValue:p,formatX:K,onCandleClick:C,locale:N}){let[M,S]=(0,s.useState)(null),g=M!==null&&M<r.length?M:null,k=(0,z.useUILabels)(),B=(0,T.plotClipId)((0,s.useId)()),t=(0,s.useMemo)(()=>{let a=r.flatMap(i=>i.high===null||i.low===null?[]:[i.low,i.high]),l=(0,V.buildCartesianGeometry)({locale:N,width:o,height:n,data:u,x:c,y,bounds:(0,V.widenBounds)((0,ye.extent)(a),(0,V.annotationValues)(u,c.key,R,void 0)),margin:_,orientation:"vertical",placement:"band",formatValue:p,formatX:K,defaultIncludeZero:!1}),{valueScale:b,bandwidth:W,categoryPositions:O,innerWidth:Y,innerHeight:U}=l,I=Math.min(G??Re,Math.max(1,W-2));return{rendered:r.map((i,w)=>{let d=O[w]+(W-I)/2,F=d+I/2,H=i.rising?X.up:X.down,j=i.high===null||i.low===null?null:{x:F,y1:b(i.high),y2:b(i.low)},x=null;if(i.open!==null&&i.close!==null){let Z=b(i.open),q=b(i.close);x=(0,pe.buildBarPath)({x:d,y:Math.min(Z,q),width:I,height:Math.max(Ne,Math.abs(q-Z)),radius:0,round:"none"})}return{key:`${w}`,color:H,body:x,hollow:i.rising&&!P,wick:j,left:d,width:I}}),categoryPositions:O,categoryCenters:l.categoryCenters,bandwidth:W,categoryTicks:l.categoryTicks,valueTicks:l.valueTicks,valueScale:b,innerWidth:Y,innerHeight:U,margin:l.margin}},[N,r,u,c,y,o,n,_,G,P,X,R,p,K]),te=(0,s.useCallback)(a=>{if(f===!1||r.length===0)return;let l=a.currentTarget.getBoundingClientRect(),b=a.clientX-l.left-t.margin.left;S((0,be.nearestIndex)(t.categoryCenters,b))},[f,r.length,t.margin.left,t.categoryCenters]),A=(0,s.useCallback)(()=>{!C||g===null||C(r[g])},[C,g,r]),re=(0,s.useCallback)(a=>(0,fe.handleChartKeyDown)(a,{count:r.length,current:g,axis:"x",onMove:S,pick:C?A:null}),[r.length,g,C,A]),h=g===null?null:r[g];return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("svg",{width:o,height:n,role:"img","aria-label":ee??r.map(a=>a.label).join(", "),tabIndex:0,className:`${Ce.CHART_TOUCH} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:te,onPointerLeave:()=>S(null),onKeyDown:re,onBlur:()=>S(null),onClick:A,children:[(0,e.jsxs)("g",{transform:`translate(${t.margin.left}, ${t.margin.top})`,children:[(0,e.jsx)(T.ChartPlotClip,{id:B,width:t.innerWidth,height:t.innerHeight,bleed:1}),(0,e.jsx)(ue.ChartGrid,{width:t.innerWidth,height:t.innerHeight,horizontal:L==="y"||L==="both"?t.valueTicks.map(a=>a.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,R?.map(a=>{let l=t.valueScale(a.value);return(0,T.isOnPlot)(l,t.innerHeight)?(0,e.jsxs)("g",{children:[(0,e.jsx)("line",{x1:0,y1:l,x2:t.innerWidth,y2:l,stroke:a.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:a.dashed===!1?void 0:"4 4"}),a.label?(0,e.jsx)("text",{x:t.innerWidth,y:l-4,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:a.label}):null]},`${a.value}-${a.label??""}`):null}),(0,e.jsx)(Se,{candles:t.rendered,clipId:B})]}),(0,e.jsx)("g",{transform:`translate(${t.margin.left}, ${t.margin.top+t.innerHeight})`,children:c.hidden?null:(0,e.jsx)(oe.ChartAxis,{orientation:"bottom",ticks:t.categoryTicks,length:t.innerWidth,label:c.label,size:E})}),(0,e.jsx)("g",{transform:`translate(${t.margin.left}, ${t.margin.top})`,children:y?.hidden?null:(0,e.jsx)(oe.ChartAxis,{orientation:"left",ticks:t.valueTicks,length:t.innerHeight,showLine:!1,label:y?.label,size:E})})]}),h&&g!==null&&f!==!1?(0,e.jsx)(me.ChartTooltip,{x:t.margin.left+t.categoryCenters[g],y:t.margin.top+(h.high===null?t.innerHeight/2:t.valueScale(h.high)),containerWidth:o,children:typeof f=="function"?f(h):(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:h.label}),(0,e.jsx)("dl",{className:"grid grid-cols-[auto_auto] gap-x-3 gap-y-0.5",children:[[k.chartOpen,h.open],[k.chartHigh,h.high],[k.chartLow,h.low],[k.chartClose,h.close]].map(([a,l])=>(0,e.jsxs)("div",{className:"contents",children:[(0,e.jsx)("dt",{className:"text-gray-500 dark:text-gray-400",children:a}),(0,e.jsx)("dd",{className:"justify-self-end font-medium text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:l===null?"\u2014":p(l)})]},a))}),h.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:h.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:[h.change>0?"+":"",p(h.change)]})]})]})}):null]})}function He({data:o,x:n,y:u,open:r,high:c,low:y,close:L,candleSize:E,fillRising:G=!1,colors:P,referenceLines:X,height:R=300,width:_,size:f="md",grid:ee="y",legend:p,tooltip:K=!0,tableView:C=!1,title:N,description:M,loading:S=!1,emptyState:g,error:k=!1,errorState:B,onRetry:t,actions:te,margin:A,locale:re,plotLabel:h,openLabel:a,highLabel:l,lowLabel:b,closeLabel:W,riseLabel:O,fallLabel:Y,format:U,onCandleClick:I,className:le,...i}){let w=(0,z.useUILocale)(re),d=(0,z.useUILabels)(),F=(0,s.useMemo)(()=>u?.format??U??(m=>(0,Q.formatAuto)(m,w)),[u?.format,U,w]),H=(0,s.useMemo)(()=>n.format??(m=>(0,Q.formatXValue)(m,w)),[n.format,w]),j=(0,s.useMemo)(()=>o.map((m,ne)=>{let ce=(0,v.readXValue)(m,n.key,ne),D=(0,v.readNumber)(m,r),$=(0,v.readNumber)(m,L);return{index:ne,x:ce,label:H(ce,ne),open:D,high:(0,v.readNumber)(m,c),low:(0,v.readNumber)(m,y),close:$,change:D===null||$===null?null:$-D,rising:D===null||$===null?!0:$>=D,datum:m}}),[o,n.key,r,c,y,L,H]),x=(0,s.useMemo)(()=>({up:P?.up??J.CHART_UP_COLOR,down:P?.down??J.CHART_DOWN_COLOR}),[P]),Z=(0,s.useMemo)(()=>[{key:"up",label:O??d.chartRise,color:x.up,marker:"rect"},{key:"down",label:Y??d.chartFall,color:x.down,marker:"rect"}],[x,O,Y,d.chartRise,d.chartFall]),q=p===void 0?!0:p!==!1,ie=typeof p=="string"?p:"bottom",se=[{key:r,label:a??d.chartOpen},{key:c,label:l??d.chartHigh},{key:y,label:b??d.chartLow},{key:L,label:W??d.chartClose}];return(0,e.jsx)(he.ChartContainer,{title:N,description:M,height:R,width:_,size:f,loading:S,empty:j.length===0,emptyState:g,error:k,errorState:B,onRetry:t,actions:te,exportSource:{data:o,series:se,xKey:n.key,xLabel:n.label??n.key,formatX:n.format},tableView:C,legendPosition:ie,legend:q?(0,e.jsx)(ge.ChartLegend,{items:Z,position:ie,marker:"rect",size:f}):void 0,table:C?(0,e.jsx)(de.ChartTableView,{data:o,series:se,xKey:n.key,xLabel:n.label??n.key,formatX:H,formatValue:F,caption:typeof N=="string"?N:void 0}):void 0,className:le,...i,children:({width:m})=>(0,e.jsx)(Ie,{locale:w,width:m,height:R,data:o,candles:j,x:n,y:u,grid:ee,size:f,candleSize:E,fillRising:G,palette:x,referenceLines:X,margin:A,tooltip:K,plotLabel:h,formatValue:F,formatX:H,onCandleClick:I})})}0&&(module.exports={CandlestickChart});
@@ -1 +1 @@
1
- "use client";import{memo as le,useCallback as Q,useMemo as T,useState as ie}from"react";import{useUILabels as ne,useUILocale as se}from"../../lib/i18n.js";import{ChartAxis as re}from"../chart/ChartAxis.js";import{ChartContainer as ce}from"../chart/ChartContainer.js";import{ChartGrid as he}from"../chart/ChartGrid.js";import{ChartLegend as ue}from"../chart/ChartLegend.js";import{ChartTableView as ge}from"../chart/ChartTableView.js";import{ChartTooltip as me}from"../chart/ChartTooltip.js";import{CHART_DOWN_COLOR as de,CHART_UP_COLOR as fe}from"../chart/palette.js";import{buildCartesianGeometry as be}from"../chart/utils/cartesian.js";import{readNumber as Y,readXValue as pe}from"../chart/utils/data.js";import{formatAuto as ye,formatXValue as Ce}from"../chart/utils/format.js";import{handleChartKeyDown as ke}from"../chart/utils/keyboard.js";import{buildBarPath as xe}from"../chart/utils/path.js";import{nearestIndex as ve}from"../chart/utils/scales.js";import{CHART_TOUCH as we}from"../chart/utils/touch.js";import{Fragment as Se,jsx as r,jsxs as b}from"react/jsx-runtime";var Le=16,Re=1.5,Pe=le(function({candles:i}){return r("g",{children:i.map(n=>b("g",{children:[n.wick?r("line",{x1:n.wick.x,y1:n.wick.y1,x2:n.wick.x,y2:n.wick.y2,stroke:n.color,strokeWidth:1.5}):null,n.body?r("path",{d:n.body,fill:n.hollow?"none":n.color,stroke:n.color,strokeWidth:n.hollow?1.5:0}):null]},n.key))})});function Ne({width:u,height:i,data:n,candles:o,x:p,y,grid:R,size:D,candleSize:O,fillRising:P,palette:H,referenceLines:z,margin:E,tooltip:m,plotLabel:U,formatValue:d,formatX:G,onCandleClick:C}){let[x,N]=ie(null),s=x!==null&&x<o.length?x:null,k=ne(),e=T(()=>{let t=o.flatMap(a=>a.high===null||a.low===null?[]:[a.low,a.high]),c=be({width:u,height:i,data:n,x:p,y,bounds:t.length===0?null:[Math.min(...t),Math.max(...t)],margin:E,orientation:"vertical",placement:"band",formatValue:d,formatX:G,defaultIncludeZero:!1}),{valueScale:f,bandwidth:I,categoryPositions:_,innerWidth:Z,innerHeight:$}=c,v=Math.min(O??Le,Math.max(1,I-2));return{rendered:o.map((a,K)=>{let V=_[K]+(I-v)/2,S=V+v/2,g=a.rising?H.up:H.down,B=a.high===null||a.low===null?null:{x:S,y1:f(a.high),y2:f(a.low)},w=null;if(a.open!==null&&a.close!==null){let X=f(a.open),L=f(a.close);w=xe({x:V,y:Math.min(X,L),width:v,height:Math.max(Re,Math.abs(L-X)),radius:0,round:"none"})}return{key:`${K}`,color:g,body:w,hollow:a.rising&&!P,wick:B,left:V,width:v}}),categoryPositions:_,categoryCenters:c.categoryCenters,bandwidth:I,categoryTicks:c.categoryTicks,valueTicks:c.valueTicks,valueScale:f,innerWidth:Z,innerHeight:$,margin:c.margin}},[o,n,p,y,u,i,E,O,P,H,d,G]),F=Q(t=>{if(m===!1||o.length===0)return;let c=t.currentTarget.getBoundingClientRect(),f=t.clientX-c.left-e.margin.left;N(ve(e.categoryCenters,f))},[m,o.length,e.margin.left,e.categoryCenters]),M=Q(()=>{!C||s===null||C(o[s])},[C,s,o]),j=Q(t=>ke(t,{count:o.length,current:s,axis:"x",onMove:N,pick:C?M:null}),[o.length,s,C,M]),l=s===null?null:o[s];return b(Se,{children:[b("svg",{width:u,height:i,role:"img","aria-label":U??o.map(t=>t.label).join(", "),tabIndex:0,className:`${we} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:F,onPointerLeave:()=>N(null),onKeyDown:j,onBlur:()=>N(null),onClick:M,children:[b("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[r(he,{width:e.innerWidth,height:e.innerHeight,horizontal:R==="y"||R==="both"?e.valueTicks.map(t=>t.offset):void 0}),s!==null?r("rect",{x:e.categoryPositions[s],y:0,width:e.bandwidth,height:e.innerHeight,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,z?.map(t=>b("g",{children:[r("line",{x1:0,y1:e.valueScale(t.value),x2:e.innerWidth,y2:e.valueScale(t.value),stroke:t.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:t.dashed===!1?void 0:"4 4"}),t.label?r("text",{x:e.innerWidth,y:e.valueScale(t.value)-4,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:t.label}):null]},`${t.value}-${t.label??""}`)),r(Pe,{candles:e.rendered})]}),r("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:p.hidden?null:r(re,{orientation:"bottom",ticks:e.categoryTicks,length:e.innerWidth,label:p.label,size:D})}),r("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:y?.hidden?null:r(re,{orientation:"left",ticks:e.valueTicks,length:e.innerHeight,showLine:!1,label:y?.label,size:D})})]}),l&&s!==null&&m!==!1?r(me,{x:e.margin.left+e.categoryCenters[s],y:e.margin.top+(l.high===null?e.innerHeight/2:e.valueScale(l.high)),containerWidth:u,children:typeof m=="function"?m(l):b("div",{className:"flex flex-col gap-1",children:[r("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:l.label}),r("dl",{className:"grid grid-cols-[auto_auto] gap-x-3 gap-y-0.5",children:[[k.chartOpen,l.open],[k.chartHigh,l.high],[k.chartLow,l.low],[k.chartClose,l.close]].map(([t,c])=>b("div",{className:"contents",children:[r("dt",{className:"text-gray-500 dark:text-gray-400",children:t}),r("dd",{className:"justify-self-end font-medium text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:c===null?"\u2014":d(c)})]},t))}),l.change===null?null:b("div",{className:"flex items-center gap-2 border-t border-gray-200 pt-1 dark:border-gray-700",children:[r("span",{className:"text-gray-500 dark:text-gray-400",children:l.rising?k.chartRise:k.chartFall}),b("span",{className:"[font-variant-numeric:tabular-nums] font-semibold text-gray-900 dark:text-gray-100",children:[l.change>0?"+":"",d(l.change)]})]})]})}):null]})}function Be({data:u,x:i,y:n,open:o,high:p,low:y,close:R,candleSize:D,fillRising:O=!1,colors:P,referenceLines:H,height:z=300,width:E,size:m="md",grid:U="y",legend:d,tooltip:G=!0,tableView:C=!1,title:x,description:N,loading:s=!1,emptyState:k,error:e=!1,errorState:F,onRetry:M,actions:j,margin:l,locale:t,plotLabel:c,openLabel:f,highLabel:I,lowLabel:_,closeLabel:Z,riseLabel:$,fallLabel:v,format:q,onCandleClick:a,className:K,...V}){let S=se(t),g=ne(),B=T(()=>n?.format??q??(h=>ye(h,S)),[n?.format,q,S]),w=T(()=>i.format??(h=>Ce(h,S)),[i.format,S]),X=T(()=>u.map((h,J)=>{let te=pe(h,i.key,J),A=Y(h,o),W=Y(h,R);return{index:J,x:te,label:w(te,J),open:A,high:Y(h,p),low:Y(h,y),close:W,change:A===null||W===null?null:W-A,rising:A===null||W===null?!0:W>=A,datum:h}}),[u,i.key,o,p,y,R,w]),L=T(()=>({up:P?.up??fe,down:P?.down??de}),[P]),ae=T(()=>[{key:"up",label:$??g.chartRise,color:L.up,marker:"rect"},{key:"down",label:v??g.chartFall,color:L.down,marker:"rect"}],[L,$,v,g.chartRise,g.chartFall]),oe=d===void 0?!0:d!==!1,ee=typeof d=="string"?d:"bottom";return r(ce,{title:x,description:N,height:z,width:E,size:m,loading:s,empty:X.length===0,emptyState:k,error:e,errorState:F,onRetry:M,actions:j,tableView:C,legendPosition:ee,legend:oe?r(ue,{items:ae,position:ee,marker:"rect",size:m}):void 0,table:C?r(ge,{data:u,series:[{key:o,label:f??g.chartOpen},{key:p,label:I??g.chartHigh},{key:y,label:_??g.chartLow},{key:R,label:Z??g.chartClose}],xKey:i.key,xLabel:i.label??i.key,formatX:w,formatValue:B,caption:typeof x=="string"?x:void 0}):void 0,className:K,...V,children:({width:h})=>r(Ne,{width:h,height:z,data:u,candles:X,x:i,y:n,grid:U,size:m,candleSize:D,fillRising:O,palette:L,referenceLines:H,margin:l,tooltip:G,plotLabel:c,formatValue:B,formatX:w,onCandleClick:a})})}export{Be as CandlestickChart};
1
+ "use client";import{memo as ie,useCallback as ee,useId as se,useMemo as H,useState as ce}from"react";import{useUILabels as le,useUILocale as he}from"../../lib/i18n.js";import{ChartAxis as oe}from"../chart/ChartAxis.js";import{ChartContainer as ue}from"../chart/ChartContainer.js";import{ChartGrid as ge}from"../chart/ChartGrid.js";import{ChartLegend as de}from"../chart/ChartLegend.js";import{ChartPlotClip as me,isOnPlot as fe,plotClipId as pe}from"../chart/ChartPlotClip.js";import{ChartTableView as be}from"../chart/ChartTableView.js";import{ChartTooltip as ye}from"../chart/ChartTooltip.js";import{CHART_DOWN_COLOR as Ce,CHART_UP_COLOR as ke}from"../chart/palette.js";import{annotationValues as we,buildCartesianGeometry as xe,widenBounds as ve}from"../chart/utils/cartesian.js";import{readNumber as j,readXValue as Le}from"../chart/utils/data.js";import{formatAuto as Pe,formatXValue as Re}from"../chart/utils/format.js";import{handleChartKeyDown as Ne}from"../chart/utils/keyboard.js";import{buildBarPath as Se}from"../chart/utils/path.js";import{nearestIndex as Ie}from"../chart/utils/scales.js";import{extent as He}from"../chart/utils/ticks.js";import{CHART_TOUCH as Te}from"../chart/utils/touch.js";import{Fragment as We,jsx as n,jsxs as b}from"react/jsx-runtime";var Ve=16,Xe=1.5,Me=ie(function({candles:a,clipId:g}){return n("g",{clipPath:`url(#${g})`,children:a.map(t=>b("g",{children:[t.wick?n("line",{x1:t.wick.x,y1:t.wick.y1,x2:t.wick.x,y2:t.wick.y2,stroke:t.color,strokeWidth:1.5}):null,t.body?n("path",{d:t.body,fill:t.hollow?"none":t.color,stroke:t.color,strokeWidth:t.hollow?1.5:0}):null]},t.key))})});function Ae({width:u,height:a,data:g,candles:t,x:d,y,grid:v,size:D,candleSize:$,fillRising:L,palette:T,referenceLines:P,margin:z,tooltip:m,plotLabel:Z,formatValue:f,formatX:E,onCandleClick:C,locale:R}){let[V,N]=ce(null),s=V!==null&&V<t.length?V:null,k=le(),G=pe(se()),e=H(()=>{let r=t.flatMap(l=>l.high===null||l.low===null?[]:[l.low,l.high]),o=xe({locale:R,width:u,height:a,data:g,x:d,y,bounds:ve(He(r),we(g,d.key,P,void 0)),margin:z,orientation:"vertical",placement:"band",formatValue:f,formatX:E,defaultIncludeZero:!1}),{valueScale:p,bandwidth:M,categoryPositions:A,innerWidth:_,innerHeight:K}=o,S=Math.min($??Ve,Math.max(1,M-2));return{rendered:t.map((l,w)=>{let c=A[w]+(M-S)/2,B=c+S/2,I=l.rising?T.up:T.down,Y=l.high===null||l.low===null?null:{x:B,y1:p(l.high),y2:p(l.low)},x=null;if(l.open!==null&&l.close!==null){let U=p(l.open),F=p(l.close);x=Se({x:c,y:Math.min(U,F),width:S,height:Math.max(Xe,Math.abs(F-U)),radius:0,round:"none"})}return{key:`${w}`,color:I,body:x,hollow:l.rising&&!L,wick:Y,left:c,width:S}}),categoryPositions:A,categoryCenters:o.categoryCenters,bandwidth:M,categoryTicks:o.categoryTicks,valueTicks:o.valueTicks,valueScale:p,innerWidth:_,innerHeight:K,margin:o.margin}},[R,t,g,d,y,u,a,z,$,L,T,P,f,E]),q=ee(r=>{if(m===!1||t.length===0)return;let o=r.currentTarget.getBoundingClientRect(),p=r.clientX-o.left-e.margin.left;N(Ie(e.categoryCenters,p))},[m,t.length,e.margin.left,e.categoryCenters]),X=ee(()=>{!C||s===null||C(t[s])},[C,s,t]),J=ee(r=>Ne(r,{count:t.length,current:s,axis:"x",onMove:N,pick:C?X:null}),[t.length,s,C,X]),i=s===null?null:t[s];return b(We,{children:[b("svg",{width:u,height:a,role:"img","aria-label":Z??t.map(r=>r.label).join(", "),tabIndex:0,className:`${Te} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:q,onPointerLeave:()=>N(null),onKeyDown:J,onBlur:()=>N(null),onClick:X,children:[b("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[n(me,{id:G,width:e.innerWidth,height:e.innerHeight,bleed:1}),n(ge,{width:e.innerWidth,height:e.innerHeight,horizontal:v==="y"||v==="both"?e.valueTicks.map(r=>r.offset):void 0}),s!==null?n("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,P?.map(r=>{let o=e.valueScale(r.value);return fe(o,e.innerHeight)?b("g",{children:[n("line",{x1:0,y1:o,x2:e.innerWidth,y2:o,stroke:r.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:r.dashed===!1?void 0:"4 4"}),r.label?n("text",{x:e.innerWidth,y:o-4,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:r.label}):null]},`${r.value}-${r.label??""}`):null}),n(Me,{candles:e.rendered,clipId:G})]}),n("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:d.hidden?null:n(oe,{orientation:"bottom",ticks:e.categoryTicks,length:e.innerWidth,label:d.label,size:D})}),n("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:y?.hidden?null:n(oe,{orientation:"left",ticks:e.valueTicks,length:e.innerHeight,showLine:!1,label:y?.label,size:D})})]}),i&&s!==null&&m!==!1?n(ye,{x:e.margin.left+e.categoryCenters[s],y:e.margin.top+(i.high===null?e.innerHeight/2:e.valueScale(i.high)),containerWidth:u,children:typeof m=="function"?m(i):b("div",{className:"flex flex-col gap-1",children:[n("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:i.label}),n("dl",{className:"grid grid-cols-[auto_auto] gap-x-3 gap-y-0.5",children:[[k.chartOpen,i.open],[k.chartHigh,i.high],[k.chartLow,i.low],[k.chartClose,i.close]].map(([r,o])=>b("div",{className:"contents",children:[n("dt",{className:"text-gray-500 dark:text-gray-400",children:r}),n("dd",{className:"justify-self-end font-medium text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:o===null?"\u2014":f(o)})]},r))}),i.change===null?null:b("div",{className:"flex items-center gap-2 border-t border-gray-200 pt-1 dark:border-gray-700",children:[n("span",{className:"text-gray-500 dark:text-gray-400",children:i.rising?k.chartRise:k.chartFall}),b("span",{className:"[font-variant-numeric:tabular-nums] font-semibold text-gray-900 dark:text-gray-100",children:[i.change>0?"+":"",f(i.change)]})]})]})}):null]})}function tt({data:u,x:a,y:g,open:t,high:d,low:y,close:v,candleSize:D,fillRising:$=!1,colors:L,referenceLines:T,height:P=300,width:z,size:m="md",grid:Z="y",legend:f,tooltip:E=!0,tableView:C=!1,title:R,description:V,loading:N=!1,emptyState:s,error:k=!1,errorState:G,onRetry:e,actions:q,margin:X,locale:J,plotLabel:i,openLabel:r,highLabel:o,lowLabel:p,closeLabel:M,riseLabel:A,fallLabel:_,format:K,onCandleClick:S,className:te,...l}){let w=he(J),c=le(),B=H(()=>g?.format??K??(h=>Pe(h,w)),[g?.format,K,w]),I=H(()=>a.format??(h=>Re(h,w)),[a.format,w]),Y=H(()=>u.map((h,Q)=>{let ae=Le(h,a.key,Q),W=j(h,t),O=j(h,v);return{index:Q,x:ae,label:I(ae,Q),open:W,high:j(h,d),low:j(h,y),close:O,change:W===null||O===null?null:O-W,rising:W===null||O===null?!0:O>=W,datum:h}}),[u,a.key,t,d,y,v,I]),x=H(()=>({up:L?.up??ke,down:L?.down??Ce}),[L]),U=H(()=>[{key:"up",label:A??c.chartRise,color:x.up,marker:"rect"},{key:"down",label:_??c.chartFall,color:x.down,marker:"rect"}],[x,A,_,c.chartRise,c.chartFall]),F=f===void 0?!0:f!==!1,re=typeof f=="string"?f:"bottom",ne=[{key:t,label:r??c.chartOpen},{key:d,label:o??c.chartHigh},{key:y,label:p??c.chartLow},{key:v,label:M??c.chartClose}];return n(ue,{title:R,description:V,height:P,width:z,size:m,loading:N,empty:Y.length===0,emptyState:s,error:k,errorState:G,onRetry:e,actions:q,exportSource:{data:u,series:ne,xKey:a.key,xLabel:a.label??a.key,formatX:a.format},tableView:C,legendPosition:re,legend:F?n(de,{items:U,position:re,marker:"rect",size:m}):void 0,table:C?n(be,{data:u,series:ne,xKey:a.key,xLabel:a.label??a.key,formatX:I,formatValue:B,caption:typeof R=="string"?R:void 0}):void 0,className:te,...l,children:({width:h})=>n(Ae,{locale:w,width:h,height:P,data:u,candles:Y,x:a,y:g,grid:Z,size:m,candleSize:D,fillRising:$,palette:x,referenceLines:T,margin:X,tooltip:E,plotLabel:i,formatValue:B,formatX:I,onCandleClick:S})})}export{tt as CandlestickChart};
@@ -1 +1 @@
1
- "use strict";var s=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var k=(e,r)=>{for(var a in r)s(e,a,{get:r[a],enumerable:!0})},N=(e,r,a,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of y(r))!R.call(e,n)&&n!==a&&s(e,n,{get:()=>r[n],enumerable:!(t=P(r,n))||t.enumerable});return e};var z=e=>N(s({},"__esModule",{value:!0}),e);var q={};k(q,{Card:()=>i});module.exports=z(q);var o=require("../../lib/cn.cjs"),u=require("react/jsx-runtime");function B(e,r,a){let t=a||"bg-white dark:bg-gray-800",n=r||"border-gray-200 dark:border-gray-700";switch(e){case"outlined":return(0,o.cn)("border-2 bg-transparent",n);case"elevated":return(0,o.cn)("shadow-lg border-0",t);case"filled":return(0,o.cn)(a||"bg-gray-100 dark:bg-gray-700","border-0");default:return(0,o.cn)("border",n,t)}}function W(e){switch(e){case"sm":return"max-w-sm";case"lg":return"max-w-2xl";default:return"max-w-md"}}function S(e){switch(e){case"none":return"rounded-none";case"sm":return"rounded-sm";case"md":return"rounded-md";case"xl":return"rounded-xl";case"full":return"rounded-3xl";default:return"rounded-lg"}}function V(e){switch(e){case"none":return"";case"sm":return"p-2";case"lg":return"p-6";default:return""}}function i({variant:e="default",size:r="md",rounded:a="lg",padding:t="none",bgColor:n,borderColor:c,shadowColor:g,hoverable:m=!1,clickable:d=!1,as:f="div",className:p,children:C,onClick:l,...h}){let b=f,v=m?"transition-all duration-200 hover:shadow-lg hover:-translate-y-0.5":"",w=d?"cursor-pointer active:scale-[0.98] transition-transform":"",x=g||"";return(0,u.jsx)(b,{className:(0,o.cn)("overflow-hidden",B(e,c,n),W(r),S(a),V(t),v,w,x,p),onClick:d||l?l:void 0,...h,children:C})}i.displayName="Card";0&&(module.exports={Card});
1
+ "use strict";var s=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var k=(e,r)=>{for(var a in r)s(e,a,{get:r[a],enumerable:!0})},N=(e,r,a,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of y(r))!R.call(e,n)&&n!==a&&s(e,n,{get:()=>r[n],enumerable:!(t=P(r,n))||t.enumerable});return e};var z=e=>N(s({},"__esModule",{value:!0}),e);var q={};k(q,{Card:()=>i});module.exports=z(q);var o=require("../../lib/cn.cjs"),u=require("react/jsx-runtime");function B(e,r,a){let t=a||"bg-white dark:bg-gray-800",n=r||"border-gray-200 dark:border-gray-700";switch(e){case"outlined":return(0,o.cn)("border-2 bg-transparent",n);case"elevated":return(0,o.cn)("shadow-lg border-0",t);case"filled":return(0,o.cn)(a||"bg-gray-100 dark:bg-gray-700","border-0");default:return(0,o.cn)("border",n,t)}}function W(e){switch(e){case"sm":return"max-w-sm";case"lg":return"max-w-2xl";default:return"max-w-md"}}function S(e){switch(e){case"none":return"rounded-none";case"sm":return"rounded-sm";case"md":return"rounded-md";case"xl":return"rounded-xl";case"full":return"rounded-3xl";default:return"rounded-lg"}}function V(e){switch(e){case"none":return"";case"sm":return"p-2";case"md":return"p-4";case"lg":return"p-6";default:return""}}function i({variant:e="default",size:r="md",rounded:a="lg",padding:t="none",bgColor:n,borderColor:c,shadowColor:g,hoverable:m=!1,clickable:d=!1,as:f="div",className:p,children:C,onClick:l,...h}){let b=f,v=m?"transition-all duration-200 hover:shadow-lg hover:-translate-y-0.5":"",w=d?"cursor-pointer active:scale-[0.98] transition-transform":"",x=g||"";return(0,u.jsx)(b,{className:(0,o.cn)("overflow-hidden",B(e,c,n),W(r),S(a),V(t),v,w,x,p),onClick:d||l?l:void 0,...h,children:C})}i.displayName="Card";0&&(module.exports={Card});
@@ -1 +1 @@
1
- import{cn as r}from"../../lib/cn.js";import{jsx as R}from"react/jsx-runtime";function v(e,o,n){let a=n||"bg-white dark:bg-gray-800",t=o||"border-gray-200 dark:border-gray-700";switch(e){case"outlined":return r("border-2 bg-transparent",t);case"elevated":return r("shadow-lg border-0",a);case"filled":return r(n||"bg-gray-100 dark:bg-gray-700","border-0");default:return r("border",t,a)}}function w(e){switch(e){case"sm":return"max-w-sm";case"lg":return"max-w-2xl";default:return"max-w-md"}}function x(e){switch(e){case"none":return"rounded-none";case"sm":return"rounded-sm";case"md":return"rounded-md";case"xl":return"rounded-xl";case"full":return"rounded-3xl";default:return"rounded-lg"}}function P(e){switch(e){case"none":return"";case"sm":return"p-2";case"lg":return"p-6";default:return""}}function y({variant:e="default",size:o="md",rounded:n="lg",padding:a="none",bgColor:t,borderColor:l,shadowColor:i,hoverable:u=!1,clickable:s=!1,as:c="div",className:g,children:m,onClick:d,...f}){let p=c,C=u?"transition-all duration-200 hover:shadow-lg hover:-translate-y-0.5":"",h=s?"cursor-pointer active:scale-[0.98] transition-transform":"",b=i||"";return R(p,{className:r("overflow-hidden",v(e,l,t),w(o),x(n),P(a),C,h,b,g),onClick:s||d?d:void 0,...f,children:m})}y.displayName="Card";export{y as Card};
1
+ import{cn as r}from"../../lib/cn.js";import{jsx as R}from"react/jsx-runtime";function v(e,o,n){let a=n||"bg-white dark:bg-gray-800",t=o||"border-gray-200 dark:border-gray-700";switch(e){case"outlined":return r("border-2 bg-transparent",t);case"elevated":return r("shadow-lg border-0",a);case"filled":return r(n||"bg-gray-100 dark:bg-gray-700","border-0");default:return r("border",t,a)}}function w(e){switch(e){case"sm":return"max-w-sm";case"lg":return"max-w-2xl";default:return"max-w-md"}}function x(e){switch(e){case"none":return"rounded-none";case"sm":return"rounded-sm";case"md":return"rounded-md";case"xl":return"rounded-xl";case"full":return"rounded-3xl";default:return"rounded-lg"}}function P(e){switch(e){case"none":return"";case"sm":return"p-2";case"md":return"p-4";case"lg":return"p-6";default:return""}}function y({variant:e="default",size:o="md",rounded:n="lg",padding:a="none",bgColor:t,borderColor:l,shadowColor:i,hoverable:u=!1,clickable:s=!1,as:c="div",className:g,children:m,onClick:d,...f}){let p=c,C=u?"transition-all duration-200 hover:shadow-lg hover:-translate-y-0.5":"",h=s?"cursor-pointer active:scale-[0.98] transition-transform":"",b=i||"";return R(p,{className:r("overflow-hidden",v(e,l,t),w(o),x(n),P(a),C,h,b,g),onClick:s||d?d:void 0,...f,children:m})}y.displayName="Card";export{y as Card};
@@ -1 +1 @@
1
- "use strict";var k=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var D=(t,r)=>{for(var e in r)k(t,e,{get:r[e],enumerable:!0})},$=(t,r,e,l)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of v(r))!M.call(t,a)&&a!==e&&k(t,a,{get:()=>r[a],enumerable:!(l=_(r,a))||l.enumerable});return t};var w=t=>$(k({},"__esModule",{value:!0}),t);var L={};D(L,{ChartAnnotationLayer:()=>E,describeAnnotations:()=>G});module.exports=w(L);var m=require("./utils/text.cjs"),n=require("react/jsx-runtime"),A=10,C=15,x=5,h=6,b=4,B=.1;function P({x:t,y:r,text:e,align:l}){let a=(0,m.estimateTextWidth)(e,A)+x*2,y=l==="start"?t:t-a;return(0,n.jsxs)("g",{children:[(0,n.jsx)("rect",{x:y,y:r,width:a,height:C,rx:3,className:"fill-white stroke-gray-200 dark:fill-gray-800 dark:stroke-gray-700",strokeWidth:1}),(0,n.jsx)("text",{x:y+x,y:r+C/2,dominantBaseline:"central",className:"fill-gray-600 text-[10px] dark:fill-gray-300",children:e})]})}function E({annotations:t,xAt:r,yAt:e,width:l,height:a,bandwidth:y=0,layer:O="over"}){if(t.length===0)return null;if(O==="under"){let o=t.filter(s=>s.type==="band");return o.length===0?null:(0,n.jsx)("g",{"aria-hidden":"true",children:o.map((s,i)=>{let d=r(s.from),c=r(s.to);if(d===null||c===null)return null;let u=Math.max(0,Math.min(d,c)-y/2),g=Math.min(l,Math.max(d,c)+y/2)-u;if(g<=0)return null;let f=s.label??"",p=(0,m.estimateTextWidth)(f,A)+x*2;return(0,n.jsxs)("g",{children:[(0,n.jsx)("rect",{x:u,y:0,width:g,height:a,fill:s.color??"var(--color-chart-muted)",opacity:B}),f&&p<=g?(0,n.jsx)(P,{x:u+2,y:2,text:f,align:"start"}):null]},`band-${i}`)})})}let N=t.filter(o=>o.type!=="band");return N.length===0?null:(0,n.jsx)("g",{"aria-hidden":"true",children:N.map((o,s)=>{let i=r(o.x);if(i===null)return null;let d=o.color??"var(--color-chart-muted)";if(o.type==="line"){let p=o.label??"",W=(0,m.estimateTextWidth)(p,A)+x*2,T=i+h+W<=l?"start":"end";return(0,n.jsxs)("g",{children:[(0,n.jsx)("line",{x1:i,y1:0,x2:i,y2:a,stroke:d,strokeWidth:1,strokeDasharray:o.dashed===!1?void 0:"3 3"}),p?(0,n.jsx)(P,{x:T==="start"?i+h:i-h,y:2,text:p,align:T}):null]},`line-${s}`)}let c=e(o.y);if(!Number.isFinite(c))return null;let u=o.label??"",I=(0,m.estimateTextWidth)(u,A)+x*2,g=i+b+h+I<=l?"start":"end",f=Math.min(Math.max(0,c-C-h),a-C);return(0,n.jsxs)("g",{children:[(0,n.jsx)("circle",{cx:i,cy:c,r:b,fill:"none",stroke:d,strokeWidth:2}),u?(0,n.jsx)(P,{x:g==="start"?i+b+h:i-b-h,y:f,text:u,align:g}):null]},`point-${s}`)})})}function G(t,r){if(!t||t.length===0)return"";let e=t.map(l=>l.label).filter(l=>!!l);return e.length===0?"":`${r}: ${e.join(", ")}`}0&&(module.exports={ChartAnnotationLayer,describeAnnotations});
1
+ "use strict";var N=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var $=(t,r)=>{for(var e in r)N(t,e,{get:r[e],enumerable:!0})},w=(t,r,e,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let l of M(r))!D.call(t,l)&&l!==e&&N(t,l,{get:()=>r[l],enumerable:!(i=_(r,l))||i.enumerable});return t};var B=t=>w(N({},"__esModule",{value:!0}),t);var V={};$(V,{ChartAnnotationLayer:()=>G,describeAnnotations:()=>L});module.exports=B(V);var m=require("./utils/text.cjs"),n=require("react/jsx-runtime"),A=10,C=15,x=5,d=6,b=4,E=.1;function I({x:t,y:r,text:e,align:i}){let l=(0,m.estimateTextWidth)(e,A)+x*2,g=i==="start"?t:t-l;return(0,n.jsxs)("g",{children:[(0,n.jsx)("rect",{x:g,y:r,width:l,height:C,rx:3,className:"fill-white stroke-gray-200 dark:fill-gray-800 dark:stroke-gray-700",strokeWidth:1}),(0,n.jsx)("text",{x:g+x,y:r+C/2,dominantBaseline:"central",className:"fill-gray-600 text-[10px] dark:fill-gray-300",children:e})]})}function G({annotations:t,xAt:r,spanAt:e,yAt:i,width:l,height:g,bandwidth:T=0,layer:W="over"}){if(t.length===0)return null;if(W==="under"){let a=t.filter(s=>s.type==="band");return a.length===0?null:(0,n.jsx)("g",{"aria-hidden":"true",children:a.map((s,o)=>{let p=e??r,c=p(s.from),u=p(s.to);if(c===null||u===null)return null;let y=Math.max(0,Math.min(c,u)-T/2),f=Math.min(l,Math.max(c,u)+T/2)-y;if(f<=0)return null;let h=s.label??"",P=(0,m.estimateTextWidth)(h,A)+x*2;return(0,n.jsxs)("g",{children:[(0,n.jsx)("rect",{x:y,y:0,width:f,height:g,fill:s.color??"var(--color-chart-muted)",opacity:E}),h&&P<=f?(0,n.jsx)(I,{x:y+2,y:2,text:h,align:"start"}):null]},`band-${o}`)})})}let v=t.filter(a=>a.type!=="band");return v.length===0?null:(0,n.jsx)("g",{"aria-hidden":"true",children:v.map((a,s)=>{let o=r(a.x);if(o===null)return null;let p=a.color??"var(--color-chart-muted)";if(a.type==="line"){let h=a.label??"",P=(0,m.estimateTextWidth)(h,A)+x*2,O=o+d+P<=l?"start":"end";return(0,n.jsxs)("g",{children:[(0,n.jsx)("line",{x1:o,y1:0,x2:o,y2:g,stroke:p,strokeWidth:1,strokeDasharray:a.dashed===!1?void 0:"3 3"}),h?(0,n.jsx)(I,{x:O==="start"?o+d:o-d,y:2,text:h,align:O}):null]},`line-${s}`)}let c=i(a.y);if(!Number.isFinite(c))return null;let u=a.label??"",y=(0,m.estimateTextWidth)(u,A)+x*2,k=o+b+d+y<=l?"start":"end",f=Math.min(Math.max(0,c-C-d),g-C);return(0,n.jsxs)("g",{children:[(0,n.jsx)("circle",{cx:o,cy:c,r:b,fill:"none",stroke:p,strokeWidth:2}),u?(0,n.jsx)(I,{x:k==="start"?o+b+d:o-b-d,y:f,text:u,align:k}):null]},`point-${s}`)})})}function L(t,r){if(!t||t.length===0)return"";let e=t.map(i=>i.label).filter(i=>!!i);return e.length===0?"":`${r}: ${e.join(", ")}`}0&&(module.exports={ChartAnnotationLayer,describeAnnotations});
@@ -1 +1 @@
1
- import{estimateTextWidth as b}from"./utils/text.js";import{jsx as e,jsxs as C}from"react/jsx-runtime";var A=10,k=15,m=5,u=6,x=4,_=.1;function P({x:n,y:o,text:i,align:l}){let h=b(i,A)+m*2,y=l==="start"?n:n-h;return C("g",{children:[e("rect",{x:y,y:o,width:h,height:k,rx:3,className:"fill-white stroke-gray-200 dark:fill-gray-800 dark:stroke-gray-700",strokeWidth:1}),e("text",{x:y+m,y:o+k/2,dominantBaseline:"central",className:"fill-gray-600 text-[10px] dark:fill-gray-300",children:i})]})}function M({annotations:n,xAt:o,yAt:i,width:l,height:h,bandwidth:y=0,layer:O="over"}){if(n.length===0)return null;if(O==="under"){let t=n.filter(a=>a.type==="band");return t.length===0?null:e("g",{"aria-hidden":"true",children:t.map((a,r)=>{let d=o(a.from),s=o(a.to);if(d===null||s===null)return null;let c=Math.max(0,Math.min(d,s)-y/2),g=Math.min(l,Math.max(d,s)+y/2)-c;if(g<=0)return null;let f=a.label??"",p=b(f,A)+m*2;return C("g",{children:[e("rect",{x:c,y:0,width:g,height:h,fill:a.color??"var(--color-chart-muted)",opacity:_}),f&&p<=g?e(P,{x:c+2,y:2,text:f,align:"start"}):null]},`band-${r}`)})})}let N=n.filter(t=>t.type!=="band");return N.length===0?null:e("g",{"aria-hidden":"true",children:N.map((t,a)=>{let r=o(t.x);if(r===null)return null;let d=t.color??"var(--color-chart-muted)";if(t.type==="line"){let p=t.label??"",W=b(p,A)+m*2,T=r+u+W<=l?"start":"end";return C("g",{children:[e("line",{x1:r,y1:0,x2:r,y2:h,stroke:d,strokeWidth:1,strokeDasharray:t.dashed===!1?void 0:"3 3"}),p?e(P,{x:T==="start"?r+u:r-u,y:2,text:p,align:T}):null]},`line-${a}`)}let s=i(t.y);if(!Number.isFinite(s))return null;let c=t.label??"",I=b(c,A)+m*2,g=r+x+u+I<=l?"start":"end",f=Math.min(Math.max(0,s-k-u),h-k);return C("g",{children:[e("circle",{cx:r,cy:s,r:x,fill:"none",stroke:d,strokeWidth:2}),c?e(P,{x:g==="start"?r+x+u:r-x-u,y:f,text:c,align:g}):null]},`point-${a}`)})})}function D(n,o){if(!n||n.length===0)return"";let i=n.map(l=>l.label).filter(l=>!!l);return i.length===0?"":`${o}: ${i.join(", ")}`}export{M as ChartAnnotationLayer,D as describeAnnotations};
1
+ import{estimateTextWidth as b}from"./utils/text.js";import{jsx as e,jsxs as C}from"react/jsx-runtime";var A=10,k=15,m=5,h=6,x=4,_=.1;function I({x:n,y:a,text:o,align:i}){let d=b(o,A)+m*2,g=i==="start"?n:n-d;return C("g",{children:[e("rect",{x:g,y:a,width:d,height:k,rx:3,className:"fill-white stroke-gray-200 dark:fill-gray-800 dark:stroke-gray-700",strokeWidth:1}),e("text",{x:g+m,y:a+k/2,dominantBaseline:"central",className:"fill-gray-600 text-[10px] dark:fill-gray-300",children:o})]})}function D({annotations:n,xAt:a,spanAt:o,yAt:i,width:d,height:g,bandwidth:T=0,layer:W="over"}){if(n.length===0)return null;if(W==="under"){let t=n.filter(l=>l.type==="band");return t.length===0?null:e("g",{"aria-hidden":"true",children:t.map((l,r)=>{let p=o??a,s=p(l.from),c=p(l.to);if(s===null||c===null)return null;let y=Math.max(0,Math.min(s,c)-T/2),f=Math.min(d,Math.max(s,c)+T/2)-y;if(f<=0)return null;let u=l.label??"",N=b(u,A)+m*2;return C("g",{children:[e("rect",{x:y,y:0,width:f,height:g,fill:l.color??"var(--color-chart-muted)",opacity:_}),u&&N<=f?e(I,{x:y+2,y:2,text:u,align:"start"}):null]},`band-${r}`)})})}let v=n.filter(t=>t.type!=="band");return v.length===0?null:e("g",{"aria-hidden":"true",children:v.map((t,l)=>{let r=a(t.x);if(r===null)return null;let p=t.color??"var(--color-chart-muted)";if(t.type==="line"){let u=t.label??"",N=b(u,A)+m*2,O=r+h+N<=d?"start":"end";return C("g",{children:[e("line",{x1:r,y1:0,x2:r,y2:g,stroke:p,strokeWidth:1,strokeDasharray:t.dashed===!1?void 0:"3 3"}),u?e(I,{x:O==="start"?r+h:r-h,y:2,text:u,align:O}):null]},`line-${l}`)}let s=i(t.y);if(!Number.isFinite(s))return null;let c=t.label??"",y=b(c,A)+m*2,P=r+x+h+y<=d?"start":"end",f=Math.min(Math.max(0,s-k-h),g-k);return C("g",{children:[e("circle",{cx:r,cy:s,r:x,fill:"none",stroke:p,strokeWidth:2}),c?e(I,{x:P==="start"?r+x+h:r-x-h,y:f,text:c,align:P}):null]},`point-${l}`)})})}function $(n,a){if(!n||n.length===0)return"";let o=n.map(i=>i.label).filter(i=>!!i);return o.length===0?"":`${a}: ${o.join(", ")}`}export{D as ChartAnnotationLayer,$ as describeAnnotations};
@@ -1 +1 @@
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
+ "use strict";"use client";var V=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var O=(e,r)=>{for(var n in r)V(e,n,{get:r[n],enumerable:!0})},X=(e,r,n,l)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of T(r))!K.call(e,o)&&o!==n&&V(e,o,{get:()=>r[o],enumerable:!(l=M(r,o))||l.enumerable});return e};var N=e=>X(V({},"__esModule",{value:!0}),e);var q={};O(q,{ChartBrushLayer:()=>L,locateBrush:()=>_,useChartBrush:()=>W});module.exports=N(q);var c=require("react"),k=require("./utils/keyboard.cjs"),R=require("./utils/scales.cjs"),G=require("./utils/timestamp.cjs"),P=require("react/jsx-runtime"),U=4,Y=.14;function L({from:e,to:r,width:n,height:l,orientation:o="vertical",live:a=!1,label:s,minSpan:f=0}){let C=o==="vertical"?n:l,p=Math.min(e,r),m=Math.max(e,r);if(m-p<f){let h=(p+m)/2;p=h-f/2,m=h+f/2}let y=Math.max(0,p),g=Math.min(C,m),d=g-y;if(d<=0)return null;let b=o==="vertical",S=b?{x:y,y:0,width:d,height:l}:{x:0,y,width:n,height:d},B=h=>b?{x1:h,y1:0,x2:h,y2:l}:{x1:0,y1:h,x2:n,y2:h};return(0,P.jsxs)("g",{"aria-hidden":s?void 0:"true",role:s?"img":void 0,"aria-label":s,children:[(0,P.jsx)("rect",{...S,className:"fill-synertech-primary-500",opacity:Y}),[y,g].map(h=>(0,P.jsx)("line",{...B(h),className:"stroke-synertech-primary-600 dark:stroke-synertech-primary-400",strokeWidth:1.5,strokeDasharray:a?"3 3":void 0},h))]})}function _(e,r,n,l){let o=(f,C)=>f>=0&&f<r.length&&(0,R.toKey)(r[f])===(0,R.toKey)(C)?n[f]:null,a=o(e.fromIndex,e.from)??l(e.from),s=o(e.toIndex,e.to)??l(e.to);return a===null||s===null?null:{from:a,to:s}}function F(e,r){let n=r-e;if(!(n>0))return Number.NaN;let o=n/864e5,a=new Date(r),s=o>=28&&o<=31?1:o>=89&&o<=92?3:0;return s>0?(a.setMonth(a.getMonth()+s),a.getTime()):o>=365&&o<=366?(a.setFullYear(a.getFullYear()+1),a.getTime()):r+n}function H(e,r){let n=(0,G.toTimestamp)(e[r]);if(n===null)return;if(r+1<e.length)return(0,G.toTimestamp)(e[r+1])===null?void 0:e[r+1];if(r<1)return;let l=(0,G.toTimestamp)(e[r-1]);if(l===null)return;let o=F(l,n);return Number.isFinite(o)?new Date(o):void 0}function W({enabled:e,active:r,centers:n,xValues:l,offset:o,orientation:a,onCommit:s}){let[f,C]=(0,c.useState)(null),p=(0,c.useRef)(null),m=(0,c.useRef)(!1),y=(0,c.useRef)(!1),g=(0,c.useRef)(null),d=(0,c.useCallback)((t,u)=>{let[i,E]=t<=u?[t,u]:[u,t],v=H(l,E);return{from:l[i],to:l[E],fromIndex:i,toIndex:E,...v===void 0?{}:{end:v}}},[l]),b=(0,c.useCallback)(t=>{let u=t.currentTarget.getBoundingClientRect();return a==="vertical"?t.clientX-u.left-o:t.clientY-u.top-o},[a,o]),S=(0,c.useCallback)(t=>{if(!e||n.length===0||t.button!==0)return;let u=b(t),i=(0,R.nearestIndex)(n,u);i<0||(p.current={index:i,pixel:u},m.current=!1,y.current=!1,t.currentTarget.setPointerCapture?.(t.pointerId))},[e,n,b]),B=(0,c.useCallback)(t=>{let u=p.current;if(!e||!u)return;let i=b(t);!m.current&&Math.abs(i-u.pixel)<U||(m.current=!0,C(d(u.index,(0,R.nearestIndex)(n,i))))},[e,n,b,d]),h=(0,c.useCallback)(t=>{let u=p.current;if(p.current=null,!e||!u)return;if(t.currentTarget.hasPointerCapture?.(t.pointerId)&&t.currentTarget.releasePointerCapture?.(t.pointerId),!m.current){C(null),r&&s(null);return}y.current=!0,m.current=!1;let i=d(u.index,(0,R.nearestIndex)(n,b(t)));C(null),g.current=i.fromIndex,s(i)},[e,r,n,b,d,s]),D=(0,c.useCallback)((t,u)=>{if(!e||n.length===0)return!1;if(t.key==="Escape"){g.current=null;let I=r||f!==null;return C(null),r&&s(null),I}if(!t.shiftKey)return g.current=null,!1;let i=a==="vertical",E=i?"ArrowRight":"ArrowDown",v=i?"ArrowLeft":"ArrowUp";if(t.key!==E&&t.key!==v)return!1;if(u===null)return g.current=null,!1;let A=(0,k.stepChartCursor)(u,t.key===E?1:-1,n.length),w=g.current??u;return g.current=w,s(d(w,A)),!1},[e,r,f,n.length,a,d,s]),x=(0,c.useCallback)(()=>{let t=y.current;return y.current=!1,t},[]);return{dragging:f,onPointerDown:S,onPointerMove:B,onPointerUp:h,onKeyDown:D,consumedClick:x}}0&&(module.exports={ChartBrushLayer,locateBrush,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 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
+ "use client";import{useCallback as C,useRef as P,useState as M}from"react";import{stepChartCursor as T}from"./utils/keyboard.js";import{nearestIndex as S,toKey as w}from"./utils/scales.js";import{toTimestamp as B}from"./utils/timestamp.js";import{jsx as k,jsxs as U}from"react/jsx-runtime";var K=4,O=.14;function H({from:r,to:t,width:n,height:s,orientation:u="vertical",live:l=!1,label:a,minSpan:i=0}){let b=u==="vertical"?n:s,d=Math.min(r,t),h=Math.max(r,t);if(h-d<i){let f=(d+h)/2;d=f-i/2,h=f+i/2}let p=Math.max(0,d),y=Math.min(b,h),m=y-p;if(m<=0)return null;let g=u==="vertical",v=g?{x:p,y:0,width:m,height:s}:{x:0,y:p,width:n,height:m},G=f=>g?{x1:f,y1:0,x2:f,y2:s}:{x1:0,y1:f,x2:n,y2:f};return U("g",{"aria-hidden":a?void 0:"true",role:a?"img":void 0,"aria-label":a,children:[k("rect",{...v,className:"fill-synertech-primary-500",opacity:O}),[p,y].map(f=>k("line",{...G(f),className:"stroke-synertech-primary-600 dark:stroke-synertech-primary-400",strokeWidth:1.5,strokeDasharray:l?"3 3":void 0},f))]})}function W(r,t,n,s){let u=(i,b)=>i>=0&&i<t.length&&w(t[i])===w(b)?n[i]:null,l=u(r.fromIndex,r.from)??s(r.from),a=u(r.toIndex,r.to)??s(r.to);return l===null||a===null?null:{from:l,to:a}}function X(r,t){let n=t-r;if(!(n>0))return Number.NaN;let u=n/864e5,l=new Date(t),a=u>=28&&u<=31?1:u>=89&&u<=92?3:0;return a>0?(l.setMonth(l.getMonth()+a),l.getTime()):u>=365&&u<=366?(l.setFullYear(l.getFullYear()+1),l.getTime()):t+n}function N(r,t){let n=B(r[t]);if(n===null)return;if(t+1<r.length)return B(r[t+1])===null?void 0:r[t+1];if(t<1)return;let s=B(r[t-1]);if(s===null)return;let u=X(s,n);return Number.isFinite(u)?new Date(u):void 0}function q({enabled:r,active:t,centers:n,xValues:s,offset:u,orientation:l,onCommit:a}){let[i,b]=M(null),d=P(null),h=P(!1),p=P(!1),y=P(null),m=C((e,o)=>{let[c,R]=e<=o?[e,o]:[o,e],E=N(s,R);return{from:s[c],to:s[R],fromIndex:c,toIndex:R,...E===void 0?{}:{end:E}}},[s]),g=C(e=>{let o=e.currentTarget.getBoundingClientRect();return l==="vertical"?e.clientX-o.left-u:e.clientY-o.top-u},[l,u]),v=C(e=>{if(!r||n.length===0||e.button!==0)return;let o=g(e),c=S(n,o);c<0||(d.current={index:c,pixel:o},h.current=!1,p.current=!1,e.currentTarget.setPointerCapture?.(e.pointerId))},[r,n,g]),G=C(e=>{let o=d.current;if(!r||!o)return;let c=g(e);!h.current&&Math.abs(c-o.pixel)<K||(h.current=!0,b(m(o.index,S(n,c))))},[r,n,g,m]),f=C(e=>{let o=d.current;if(d.current=null,!r||!o)return;if(e.currentTarget.hasPointerCapture?.(e.pointerId)&&e.currentTarget.releasePointerCapture?.(e.pointerId),!h.current){b(null),t&&a(null);return}p.current=!0,h.current=!1;let c=m(o.index,S(n,g(e)));b(null),y.current=c.fromIndex,a(c)},[r,t,n,g,m,a]),D=C((e,o)=>{if(!r||n.length===0)return!1;if(e.key==="Escape"){y.current=null;let I=t||i!==null;return b(null),t&&a(null),I}if(!e.shiftKey)return y.current=null,!1;let c=l==="vertical",R=c?"ArrowRight":"ArrowDown",E=c?"ArrowLeft":"ArrowUp";if(e.key!==R&&e.key!==E)return!1;if(o===null)return y.current=null,!1;let A=T(o,e.key===R?1:-1,n.length),V=y.current??o;return y.current=V,a(m(V,A)),!1},[r,t,i,n.length,l,m,a]),x=C(()=>{let e=p.current;return p.current=!1,e},[]);return{dragging:i,onPointerDown:v,onPointerMove:G,onPointerUp:f,onKeyDown:D,consumedClick:x}}export{H as ChartBrushLayer,W as locateBrush,q 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)(),[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
+ "use strict";"use client";var x=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var Y=Object.prototype.hasOwnProperty;var _=(r,t)=>{for(var a in t)x(r,a,{get:t[a],enumerable:!0})},ee=(r,t,a,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of X(t))!Y.call(r,o)&&o!==a&&x(r,o,{get:()=>t[o],enumerable:!(l=Q(t,o))||l.enumerable});return r};var te=r=>ee(x({},"__esModule",{value:!0}),r);var se={};_(se,{ChartContainer:()=>oe});module.exports=te(se);var c=require("react"),d=require("../../lib/cn.cjs"),P=require("../../lib/i18n.cjs"),I=require("../circular-progress/CircularProgress.cjs"),T=require("./exportSource.cjs"),z=require("./useChartSize.cjs"),e=require("react/jsx-runtime"),re=(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"})]}),ae={sm:"text-xs",md:"text-sm",lg:"text-base"};function oe({title:r,description:t,height:a=240,width:l,size:o="md",legend:i,legendPosition:u="bottom",actions:g,exportSource:A,loading:n=!1,empty:y=!1,emptyState:j,error:f=!1,errorState:H,onRetry:v,errorLabel:W,errorHintLabel:B,retryLabel:D,table:m,tableView:C=!1,showTableLabel:M,hideTableLabel:O,noDataLabel:$,loadingLabel:U,ariaLabel:w,children:h,className:V,...Z}){let s=(0,P.useUILabels)(),[p,q]=(0,c.useState)(!1),b=(0,c.useId)(),N=`${b}-table`,k=`${b}-title`,L=`${b}-description`,{ref:F,width:G,measured:J}=(0,z.useChartSize)({width:l}),R=!!m&&C==="toggle",S=!!m&&(C===!0||R&&p),E=(0,e.jsx)("div",{ref:F,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)(I.CircularProgress,{indeterminate:!0,size:"md","aria-label":U??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:H??(0,e.jsxs)(e.Fragment,{children:[re,(0,e.jsx)("span",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:W??s.chartError}),(0,e.jsx)("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:B??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:D??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:j??$??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:G,height:a,measured:J}):h})});return(0,e.jsxs)("figure",{className:(0,d.cn)("flex w-full flex-col gap-3",V),"aria-label":w,"aria-labelledby":!w&&r?k:void 0,"aria-describedby":t?L:void 0,...Z,children:[r||t||g?(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",ae[o]),children:r}):null,t?(0,e.jsx)("span",{id:L,className:"text-xs text-gray-500 dark:text-gray-400",children:t}):null]}),(0,e.jsx)(T.ChartExportContext.Provider,{value:A??null,children:g})]}):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:()=>q(K=>!K),"aria-expanded":p,"aria-controls":S?N: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?O??s.chartHideTable:M??s.chartShowTable})}),S&&(0,e.jsx)("div",{id:N,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: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};
1
+ "use client";import{useId as q,useState as F}from"react";import{cn as m}from"../../lib/cn.js";import{useUILabels as G}from"../../lib/i18n.js";import{CircularProgress as J}from"../circular-progress/CircularProgress.js";import{ChartExportContext as K}from"./exportSource.js";import{useChartSize as Q}from"./useChartSize.js";import{Fragment as _,jsx as e,jsxs as a}from"react/jsx-runtime";var X=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"})]}),Y={sm:"text-xs",md:"text-sm",lg:"text-base"};function de({title:s,description:i,height:h=240,width:R,size:S="md",legend:r,legendPosition:n="bottom",actions:p,exportSource:E,loading:o=!1,empty:b=!1,emptyState:P,error:l=!1,errorState:I,onRetry:x,errorLabel:T,errorHintLabel:z,retryLabel:A,table:d,tableView:g=!1,showTableLabel:j,hideTableLabel:H,noDataLabel:W,loadingLabel:B,ariaLabel:y,children:c,className:D,...M}){let t=G(),[u,O]=F(!1),f=q(),v=`${f}-table`,C=`${f}-title`,w=`${f}-description`,{ref:$,width:U,measured:V}=Q({width:R}),N=!!d&&g==="toggle",k=!!d&&(g===!0||N&&u),L=e("div",{ref:$,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(J,{indeterminate:!0,size:"md","aria-label":B??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(_,{children:[X,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}),x?e("button",{type:"button",onClick:x,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:P??W??t.chartNoData}):e("div",{className:m("h-full w-full transition-opacity duration-200",o&&"opacity-60"),children:typeof c=="function"?c({width:U,height:h,measured:V}):c})});return a("figure",{className:m("flex w-full flex-col gap-3",D),"aria-label":y,"aria-labelledby":!y&&s?C:void 0,"aria-describedby":i?w:void 0,...M,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:C,className:m("font-semibold text-gray-900 dark:text-gray-100",Y[S]),children:s}):null,i?e("span",{id:w,className:"text-xs text-gray-500 dark:text-gray-400",children:i}):null]}),e(K.Provider,{value:E??null,children: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,N&&e("div",{className:"flex",children:e("button",{type:"button",onClick:()=>O(Z=>!Z),"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?H??t.chartHideTable:j??t.chartShowTable})}),k&&e("div",{id:v,children:d})]})}export{de as ChartContainer};
@@ -1 +1 @@
1
- "use strict";"use client";var l=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var M=(t,o)=>{for(var s in o)l(t,s,{get:o[s],enumerable:!0})},P=(t,o,s,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of z(o))!L.call(t,n)&&n!==s&&l(t,n,{get:()=>o[n],enumerable:!(i=S(o,n))||i.enumerable});return t};var T=t=>P(l({},"__esModule",{value:!0}),t);var R={};M(R,{ChartExportButton:()=>J});module.exports=T(R);var f=require("react"),y=require("../../lib/cn.cjs"),v=require("../../lib/i18n.cjs"),w=require("../dropdown/Dropdown.cjs"),E=require("../dropdown/DropdownContent.cjs"),k=require("../dropdown/DropdownItem.cjs"),D=require("../dropdown/DropdownTrigger.cjs"),F=require("./utils/export.cjs"),r=require("react/jsx-runtime"),j={sm:"h-7 px-2.5 text-xs",md:"h-8 px-3 text-sm",lg:"h-10 px-4 text-sm"},b=(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,r.jsx)("path",{d:"M8 2v8m0 0 3-3m-3 3L5 7M2.5 12.5h11",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})});function J({data:t,series:o,xKey:s,xLabel:i,formatX:n,neutralizeFormulas:d,formats:a=["csv","json"],filename:h="chart",size:B="md",label:I,onExport:p,className:N,disabled:m}){let c=(0,v.useUILabels)(),g=(0,f.useCallback)(e=>{let C={data:t,series:o,xKey:s,xLabel:i,formatX:n,neutralizeFormulas:d};p?p(e,C):(0,F.downloadChartData)(e,C,h)},[t,o,s,i,n,d,p,h]),u=I??c.chartExport,O=e=>e==="csv"?c.chartExportCsv:c.chartExportJson,x=(0,y.cn)("inline-flex cursor-pointer items-center gap-2 rounded-full border border-gray-300 bg-white font-medium text-gray-700 transition-colors hover:bg-gray-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",j[B],N);if(a.length<=1){let e=a[0]??"csv";return(0,r.jsxs)("button",{type:"button",onClick:()=>g(e),disabled:m||t.length===0,className:x,children:[b,(0,r.jsx)("span",{children:u})]})}return(0,r.jsxs)(w.Dropdown,{children:[(0,r.jsxs)(D.DropdownTrigger,{disabled:m||t.length===0,className:x,children:[b,(0,r.jsx)("span",{children:u})]}),(0,r.jsx)(E.DropdownContent,{children:a.map(e=>(0,r.jsx)(k.DropdownItem,{onSelect:()=>g(e),children:O(e)},e))})]})}0&&(module.exports={ChartExportButton});
1
+ "use strict";"use client";var m=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var U=(e,t)=>{for(var s in t)m(e,s,{get:t[s],enumerable:!0})},W=(e,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of J(t))!R.call(e,n)&&n!==s&&m(e,n,{get:()=>t[n],enumerable:!(i=j(t,n))||i.enumerable});return e};var q=e=>W(m({},"__esModule",{value:!0}),e);var H={};U(H,{ChartExportButton:()=>G});module.exports=q(H);var L=require("react"),F=require("../../lib/cn.cjs"),S=require("../../lib/i18n.cjs"),B=require("../dropdown/Dropdown.cjs"),I=require("../dropdown/DropdownContent.cjs"),N=require("../dropdown/DropdownItem.cjs"),O=require("../dropdown/DropdownTrigger.cjs"),z=require("./exportSource.cjs"),P=require("./utils/export.cjs"),o=require("react/jsx-runtime"),A={sm:"h-7 px-2.5 text-xs",md:"h-8 px-3 text-sm",lg:"h-10 px-4 text-sm"},D=(0,o.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,o.jsx)("path",{d:"M8 2v8m0 0 3-3m-3 3L5 7M2.5 12.5h11",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})});function G({data:e,series:t,xKey:s,xLabel:i,formatX:n,neutralizeFormulas:g,formats:c=["csv","json"],filename:x="chart",size:K="md",label:M,onExport:d,className:T,disabled:u}){let l=(0,S.useUILabels)(),a=(0,z.useChartExportSource)(),h=e??a?.data??[],f=t??a?.series??[],p=s??a?.xKey,b=i??a?.xLabel,C=n??a?.formatX,y=(0,L.useCallback)(r=>{if(p===void 0)return;let k={data:h,series:f,xKey:p,xLabel:b,formatX:C,neutralizeFormulas:g};d?d(r,k):(0,P.downloadChartData)(r,k,x)},[h,f,p,b,C,g,d,x]),w=h.length===0||p===void 0,E=M??l.chartExport,X=r=>r==="csv"?l.chartExportCsv:l.chartExportJson,v=(0,F.cn)("inline-flex cursor-pointer items-center gap-2 rounded-full border border-gray-300 bg-white font-medium text-gray-700 transition-colors hover:bg-gray-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",A[K],T);if(c.length<=1){let r=c[0]??"csv";return(0,o.jsxs)("button",{type:"button",onClick:()=>y(r),disabled:u||w,className:v,children:[D,(0,o.jsx)("span",{children:E})]})}return(0,o.jsxs)(B.Dropdown,{children:[(0,o.jsxs)(O.DropdownTrigger,{disabled:u||w,className:v,children:[D,(0,o.jsx)("span",{children:E})]}),(0,o.jsx)(I.DropdownContent,{children:c.map(r=>(0,o.jsx)(N.DropdownItem,{onSelect:()=>y(r),children:X(r)},r))})]})}0&&(module.exports={ChartExportButton});
@@ -1 +1 @@
1
- "use client";import{useCallback as E}from"react";import{cn as k}from"../../lib/cn.js";import{useUILabels as D}from"../../lib/i18n.js";import{Dropdown as F}from"../dropdown/Dropdown.js";import{DropdownContent as B}from"../dropdown/DropdownContent.js";import{DropdownItem as I}from"../dropdown/DropdownItem.js";import{DropdownTrigger as N}from"../dropdown/DropdownTrigger.js";import{downloadChartData as O}from"./utils/export.js";import{jsx as o,jsxs as i}from"react/jsx-runtime";var S={sm:"h-7 px-2.5 text-xs",md:"h-8 px-3 text-sm",lg:"h-10 px-4 text-sm"},b=o("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:o("path",{d:"M8 2v8m0 0 3-3m-3 3L5 7M2.5 12.5h11",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})});function U({data:r,series:a,xKey:p,xLabel:c,formatX:l,neutralizeFormulas:d,formats:e=["csv","json"],filename:h="chart",size:f="md",label:y,onExport:n,className:v,disabled:m}){let s=D(),g=E(t=>{let C={data:r,series:a,xKey:p,xLabel:c,formatX:l,neutralizeFormulas:d};n?n(t,C):O(t,C,h)},[r,a,p,c,l,d,n,h]),u=y??s.chartExport,w=t=>t==="csv"?s.chartExportCsv:s.chartExportJson,x=k("inline-flex cursor-pointer items-center gap-2 rounded-full border border-gray-300 bg-white font-medium text-gray-700 transition-colors hover:bg-gray-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",S[f],v);if(e.length<=1){let t=e[0]??"csv";return i("button",{type:"button",onClick:()=>g(t),disabled:m||r.length===0,className:x,children:[b,o("span",{children:u})]})}return i(F,{children:[i(N,{disabled:m||r.length===0,className:x,children:[b,o("span",{children:u})]}),o(B,{children:e.map(t=>o(I,{onSelect:()=>g(t),children:w(t)},t))})]})}export{U as ChartExportButton};
1
+ "use client";import{useCallback as I}from"react";import{cn as N}from"../../lib/cn.js";import{useUILabels as O}from"../../lib/i18n.js";import{Dropdown as z}from"../dropdown/Dropdown.js";import{DropdownContent as P}from"../dropdown/DropdownContent.js";import{DropdownItem as K}from"../dropdown/DropdownItem.js";import{DropdownTrigger as M}from"../dropdown/DropdownTrigger.js";import{useChartExportSource as T}from"./exportSource.js";import{downloadChartData as X}from"./utils/export.js";import{jsx as o,jsxs as p}from"react/jsx-runtime";var j={sm:"h-7 px-2.5 text-xs",md:"h-8 px-3 text-sm",lg:"h-10 px-4 text-sm"},y=o("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:o("path",{d:"M8 2v8m0 0 3-3m-3 3L5 7M2.5 12.5h11",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})});function V({data:w,series:E,xKey:v,xLabel:k,formatX:D,neutralizeFormulas:c,formats:n=["csv","json"],filename:d="chart",size:L="md",label:F,onExport:s,className:S,disabled:l}){let a=O(),r=T(),i=w??r?.data??[],h=E??r?.series??[],e=v??r?.xKey,m=k??r?.xLabel,g=D??r?.formatX,x=I(t=>{if(e===void 0)return;let C={data:i,series:h,xKey:e,xLabel:m,formatX:g,neutralizeFormulas:c};s?s(t,C):X(t,C,d)},[i,h,e,m,g,c,s,d]),u=i.length===0||e===void 0,f=F??a.chartExport,B=t=>t==="csv"?a.chartExportCsv:a.chartExportJson,b=N("inline-flex cursor-pointer items-center gap-2 rounded-full border border-gray-300 bg-white font-medium text-gray-700 transition-colors hover:bg-gray-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",j[L],S);if(n.length<=1){let t=n[0]??"csv";return p("button",{type:"button",onClick:()=>x(t),disabled:l||u,className:b,children:[y,o("span",{children:f})]})}return p(z,{children:[p(M,{disabled:l||u,className:b,children:[y,o("span",{children:f})]}),o(P,{children:n.map(t=>o(K,{onSelect:()=>x(t),children:B(t)},t))})]})}export{V as ChartExportButton};
@@ -1 +1 @@
1
- "use strict";var f=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var m=(t,r)=>{for(var n in r)f(t,n,{get:r[n],enumerable:!0})},P=(t,r,n,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of b(r))!C.call(t,o)&&o!==n&&f(t,o,{get:()=>r[o],enumerable:!(i=x(r,o))||i.enumerable});return t};var $=t=>P(f({},"__esModule",{value:!0}),t);var R={};m(R,{CHART_PATTERNS:()=>k,CHART_SURFACE_COLOR:()=>l,ChartPatternDefs:()=>S,getPattern:()=>g,patternBackground:()=>w,patternFill:()=>y,patternId:()=>p});module.exports=$(R);var a=require("react/jsx-runtime"),l="var(--color-chart-surface)",k=["solid","diagonal","diagonal-reverse","cross","dots","diagonal-wide","diagonal-reverse-wide","dots-wide"],h={solid:null,diagonal:{tile:6,rotate:45,stroke:2},"diagonal-reverse":{tile:6,rotate:-45,stroke:2},cross:{tile:6,rotate:45,stroke:1.25,crossed:!0},dots:{tile:6,rotate:0,stroke:0,dot:1.5},"diagonal-wide":{tile:10,rotate:45,stroke:3},"diagonal-reverse-wide":{tile:10,rotate:-45,stroke:3},"dots-wide":{tile:10,rotate:0,stroke:0,dot:2.6}};function g(t){return!Number.isFinite(t)||t<0?"solid":k[Math.floor(t)%k.length]}function p(t,r){return`${t.replace(/[^a-zA-Z0-9_-]/g,"")}-texture-${Math.max(0,Math.floor(r))}`}function y(t,r,n,i){return!t||g(n)==="solid"?i:`url(#${p(r,n)})`}function S({id:t,entries:r}){return(0,a.jsx)("defs",{children:r.map(({slot:n,color:i})=>{let o=h[g(n)];if(!o)return null;let{tile:e,rotate:u,stroke:s,crossed:d,dot:c}=o;return(0,a.jsxs)("pattern",{id:p(t,n),width:e,height:e,patternUnits:"userSpaceOnUse",patternTransform:u===0?void 0:`rotate(${u})`,children:[(0,a.jsx)("rect",{width:e,height:e,fill:i}),c?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("circle",{cx:e/4,cy:e/4,r:c,fill:l}),(0,a.jsx)("circle",{cx:e*3/4,cy:e*3/4,r:c,fill:l})]}):null,s>0?(0,a.jsx)("line",{x1:e/2,y1:0,x2:e/2,y2:e,stroke:l,strokeWidth:s}):null,d?(0,a.jsx)("line",{x1:0,y1:e/2,x2:e,y2:e/2,stroke:l,strokeWidth:s}):null]},p(t,n))})})}function w(t,r){let n=h[g(t)];if(!n)return{backgroundColor:r};let{tile:i,rotate:o,stroke:e,crossed:u,dot:s}=n;if(s)return{backgroundColor:r,backgroundImage:`radial-gradient(${l} ${s-.4}px, transparent ${s}px)`,backgroundSize:`${i/2}px ${i/2}px`};let d=c=>`repeating-linear-gradient(${c}deg, ${l} 0 ${e}px, transparent ${e}px ${i}px)`;return{backgroundColor:r,backgroundImage:u?`${d(o)}, ${d(o+90)}`:d(o)}}0&&(module.exports={CHART_PATTERNS,CHART_SURFACE_COLOR,ChartPatternDefs,getPattern,patternBackground,patternFill,patternId});
1
+ "use strict";var f=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var C=(t,r)=>{for(var n in r)f(t,n,{get:r[n],enumerable:!0})},P=(t,r,n,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of h(r))!m.call(t,o)&&o!==n&&f(t,o,{get:()=>r[o],enumerable:!(i=b(r,o))||i.enumerable});return t};var $=t=>P(f({},"__esModule",{value:!0}),t);var R={};C(R,{CHART_PATTERNS:()=>k,CHART_SURFACE_COLOR:()=>s.CHART_SURFACE_COLOR,ChartPatternDefs:()=>S,getPattern:()=>g,patternBackground:()=>w,patternFill:()=>y,patternId:()=>p});module.exports=$(R);var s=require("./palette.cjs"),a=require("react/jsx-runtime");var k=["solid","diagonal","diagonal-reverse","cross","dots","diagonal-wide","diagonal-reverse-wide","dots-wide"],x={solid:null,diagonal:{tile:6,rotate:45,stroke:2},"diagonal-reverse":{tile:6,rotate:-45,stroke:2},cross:{tile:6,rotate:45,stroke:1.25,crossed:!0},dots:{tile:6,rotate:0,stroke:0,dot:1.5},"diagonal-wide":{tile:10,rotate:45,stroke:3},"diagonal-reverse-wide":{tile:10,rotate:-45,stroke:3},"dots-wide":{tile:10,rotate:0,stroke:0,dot:2.6}};function g(t){return!Number.isFinite(t)||t<0?"solid":k[Math.floor(t)%k.length]}function p(t,r){return`${t.replace(/[^a-zA-Z0-9_-]/g,"")}-texture-${Math.max(0,Math.floor(r))}`}function y(t,r,n,i){return!t||g(n)==="solid"?i:`url(#${p(r,n)})`}function S({id:t,entries:r}){return(0,a.jsx)("defs",{children:r.map(({slot:n,color:i})=>{let o=x[g(n)];if(!o)return null;let{tile:e,rotate:c,stroke:l,crossed:d,dot:u}=o;return(0,a.jsxs)("pattern",{id:p(t,n),width:e,height:e,patternUnits:"userSpaceOnUse",patternTransform:c===0?void 0:`rotate(${c})`,children:[(0,a.jsx)("rect",{width:e,height:e,fill:i}),u?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("circle",{cx:e/4,cy:e/4,r:u,fill:s.CHART_SURFACE_COLOR}),(0,a.jsx)("circle",{cx:e*3/4,cy:e*3/4,r:u,fill:s.CHART_SURFACE_COLOR})]}):null,l>0?(0,a.jsx)("line",{x1:e/2,y1:0,x2:e/2,y2:e,stroke:s.CHART_SURFACE_COLOR,strokeWidth:l}):null,d?(0,a.jsx)("line",{x1:0,y1:e/2,x2:e,y2:e/2,stroke:s.CHART_SURFACE_COLOR,strokeWidth:l}):null]},p(t,n))})})}function w(t,r){let n=x[g(t)];if(!n)return{backgroundColor:r};let{tile:i,rotate:o,stroke:e,crossed:c,dot:l}=n;if(l)return{backgroundColor:r,backgroundImage:`radial-gradient(${s.CHART_SURFACE_COLOR} ${l-.4}px, transparent ${l}px)`,backgroundSize:`${i/2}px ${i/2}px`};let d=u=>`repeating-linear-gradient(${u}deg, ${s.CHART_SURFACE_COLOR} 0 ${e}px, transparent ${e}px ${i}px)`;return{backgroundColor:r,backgroundImage:c?`${d(o)}, ${d(o+90)}`:d(o)}}0&&(module.exports={CHART_PATTERNS,CHART_SURFACE_COLOR,ChartPatternDefs,getPattern,patternBackground,patternFill,patternId});
@@ -1 +1 @@
1
- import{Fragment as x,jsx as s,jsxs as k}from"react/jsx-runtime";var l="var(--color-chart-surface)",f=["solid","diagonal","diagonal-reverse","cross","dots","diagonal-wide","diagonal-reverse-wide","dots-wide"],h={solid:null,diagonal:{tile:6,rotate:45,stroke:2},"diagonal-reverse":{tile:6,rotate:-45,stroke:2},cross:{tile:6,rotate:45,stroke:1.25,crossed:!0},dots:{tile:6,rotate:0,stroke:0,dot:1.5},"diagonal-wide":{tile:10,rotate:45,stroke:3},"diagonal-reverse-wide":{tile:10,rotate:-45,stroke:3},"dots-wide":{tile:10,rotate:0,stroke:0,dot:2.6}};function g(r){return!Number.isFinite(r)||r<0?"solid":f[Math.floor(r)%f.length]}function p(r,e){return`${r.replace(/[^a-zA-Z0-9_-]/g,"")}-texture-${Math.max(0,Math.floor(e))}`}function b(r,e,n,o){return!r||g(n)==="solid"?o:`url(#${p(e,n)})`}function C({id:r,entries:e}){return s("defs",{children:e.map(({slot:n,color:o})=>{let i=h[g(n)];if(!i)return null;let{tile:t,rotate:u,stroke:a,crossed:d,dot:c}=i;return k("pattern",{id:p(r,n),width:t,height:t,patternUnits:"userSpaceOnUse",patternTransform:u===0?void 0:`rotate(${u})`,children:[s("rect",{width:t,height:t,fill:o}),c?k(x,{children:[s("circle",{cx:t/4,cy:t/4,r:c,fill:l}),s("circle",{cx:t*3/4,cy:t*3/4,r:c,fill:l})]}):null,a>0?s("line",{x1:t/2,y1:0,x2:t/2,y2:t,stroke:l,strokeWidth:a}):null,d?s("line",{x1:0,y1:t/2,x2:t,y2:t/2,stroke:l,strokeWidth:a}):null]},p(r,n))})})}function m(r,e){let n=h[g(r)];if(!n)return{backgroundColor:e};let{tile:o,rotate:i,stroke:t,crossed:u,dot:a}=n;if(a)return{backgroundColor:e,backgroundImage:`radial-gradient(${l} ${a-.4}px, transparent ${a}px)`,backgroundSize:`${o/2}px ${o/2}px`};let d=c=>`repeating-linear-gradient(${c}deg, ${l} 0 ${t}px, transparent ${t}px ${o}px)`;return{backgroundColor:e,backgroundImage:u?`${d(i)}, ${d(i+90)}`:d(i)}}export{f as CHART_PATTERNS,l as CHART_SURFACE_COLOR,C as ChartPatternDefs,g as getPattern,m as patternBackground,b as patternFill,p as patternId};
1
+ import{CHART_SURFACE_COLOR as l}from"./palette.js";import{Fragment as b,jsx as s,jsxs as k}from"react/jsx-runtime";var f=["solid","diagonal","diagonal-reverse","cross","dots","diagonal-wide","diagonal-reverse-wide","dots-wide"],x={solid:null,diagonal:{tile:6,rotate:45,stroke:2},"diagonal-reverse":{tile:6,rotate:-45,stroke:2},cross:{tile:6,rotate:45,stroke:1.25,crossed:!0},dots:{tile:6,rotate:0,stroke:0,dot:1.5},"diagonal-wide":{tile:10,rotate:45,stroke:3},"diagonal-reverse-wide":{tile:10,rotate:-45,stroke:3},"dots-wide":{tile:10,rotate:0,stroke:0,dot:2.6}};function g(r){return!Number.isFinite(r)||r<0?"solid":f[Math.floor(r)%f.length]}function p(r,e){return`${r.replace(/[^a-zA-Z0-9_-]/g,"")}-texture-${Math.max(0,Math.floor(e))}`}function m(r,e,n,o){return!r||g(n)==="solid"?o:`url(#${p(e,n)})`}function C({id:r,entries:e}){return s("defs",{children:e.map(({slot:n,color:o})=>{let i=x[g(n)];if(!i)return null;let{tile:t,rotate:c,stroke:a,crossed:d,dot:u}=i;return k("pattern",{id:p(r,n),width:t,height:t,patternUnits:"userSpaceOnUse",patternTransform:c===0?void 0:`rotate(${c})`,children:[s("rect",{width:t,height:t,fill:o}),u?k(b,{children:[s("circle",{cx:t/4,cy:t/4,r:u,fill:l}),s("circle",{cx:t*3/4,cy:t*3/4,r:u,fill:l})]}):null,a>0?s("line",{x1:t/2,y1:0,x2:t/2,y2:t,stroke:l,strokeWidth:a}):null,d?s("line",{x1:0,y1:t/2,x2:t,y2:t/2,stroke:l,strokeWidth:a}):null]},p(r,n))})})}function P(r,e){let n=x[g(r)];if(!n)return{backgroundColor:e};let{tile:o,rotate:i,stroke:t,crossed:c,dot:a}=n;if(a)return{backgroundColor:e,backgroundImage:`radial-gradient(${l} ${a-.4}px, transparent ${a}px)`,backgroundSize:`${o/2}px ${o/2}px`};let d=u=>`repeating-linear-gradient(${u}deg, ${l} 0 ${t}px, transparent ${t}px ${o}px)`;return{backgroundColor:e,backgroundImage:c?`${d(i)}, ${d(i+90)}`:d(i)}}export{f as CHART_PATTERNS,l as CHART_SURFACE_COLOR,C as ChartPatternDefs,g as getPattern,P as patternBackground,m as patternFill,p as patternId};
@@ -1 +1 @@
1
- "use strict";"use client";var k=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var te=Object.prototype.hasOwnProperty;var re=(n,o)=>{for(var c in o)k(n,c,{get:o[c],enumerable:!0})},oe=(n,o,c,u)=>{if(o&&typeof o=="object"||typeof o=="function")for(let d of ee(o))!te.call(n,d)&&d!==c&&k(n,d,{get:()=>o[d],enumerable:!(u=Z(o,d))||u.enumerable});return n};var ae=n=>oe(k({},"__esModule",{value:!0}),n);var ce={};re(ce,{ChartPeriodPicker:()=>de});module.exports=ae(ce);var t=require("react"),O=require("react-dom"),I=require("../../lib/aria-hide.cjs"),b=require("../../lib/cn.cjs"),g=require("../../lib/i18n.cjs"),N=require("../calendar/Calendar.cjs"),z=require("../dropdown/hooks/usePositioning.cjs"),a=require("./utils/period.cjs"),r=require("react/jsx-runtime"),ne={"7d":"chartPeriodLast7Days","30d":"chartPeriodLast30Days","90d":"chartPeriodLast90Days","12m":"chartPeriodLast12Months",mtd:"chartPeriodMonthToDate",qtd:"chartPeriodQuarterToDate",ytd:"chartPeriodYearToDate",custom:"chartPeriodCustom"},ie={sm:"h-7 px-2.5 text-xs",md:"h-8 px-3 text-sm",lg:"h-10 px-4 text-sm"},se=(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,r.jsx)("path",{d:"M5 1.5v2M11 1.5v2M2.5 6h11M3.5 3h9a1 1 0 011 1v9a1 1 0 01-1 1h-9a1 1 0 01-1-1V4a1 1 0 011-1z",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})});function de({value:n,defaultValue:o,onChange:c,presets:u=a.DEFAULT_CHART_PERIOD_PRESETS,custom:d=!0,presetLabels:A,now:m,minDate:F,maxDate:U,numberOfMonths:W=1,weekStartsOn:H,locale:_,size:B="md",align:K="start",disabled:q=!1,label:x,className:Y,...$}){let P=(0,g.useUILabels)(),D=(0,g.useUILocale)(_),p=(0,t.useRef)(null),f=(0,t.useRef)(null),L=(0,t.useRef)(null),[i,E]=(0,t.useState)(!1),[R,w]=(0,t.useState)(!1),[Q,M]=(0,t.useState)(null),[j,G]=(0,t.useState)(()=>typeof o=="string"?(0,a.createPeriod)(o,m):o||(0,a.createPeriod)(u[0]??"30d",m)),s=n??j,v=(0,z.usePositioning)({triggerRef:p,contentRef:f,isOpen:i,side:"bottom",align:K}),l=(0,t.useCallback)((e=!0)=>{E(!1),w(!1),M(null),e&&p.current?.focus()},[]);(0,t.useEffect)(()=>{if(!i)return;let e=y=>{let T=y.target;f.current?.contains(T)||p.current?.contains(T)||l(!1)};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e,{passive:!0}),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}},[i,l]),(0,t.useEffect)(()=>{if(!i)return;let e=y=>{y.key==="Escape"&&(y.stopPropagation(),l())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[i,l]),(0,t.useEffect)(()=>{let e=f.current;if(e)return(0,I.registerFloatingLayer)(e,()=>p.current)},[i]),(0,t.useEffect)(()=>{if(!i)return;let e=requestAnimationFrame(()=>L.current?.focus());return()=>cancelAnimationFrame(e)},[i]);let h=(0,t.useCallback)(e=>{n===void 0&&G(e),c?.(e),l()},[n,c,l]),J=(0,t.useCallback)(e=>h((0,a.createPeriod)(e,m)),[h,m]),V=(0,t.useCallback)(e=>{M(e),!(!e.from||!e.to)&&h({preset:"custom",from:(0,a.startOfDay)(e.from),to:(0,a.endOfDay)(e.to)})},[h]),C=e=>A?.[e]??P[ne[e]],S=s.preset==="custom"?(0,a.formatPeriodRange)(s.from,s.to,D):C(s.preset),X=(0,r.jsxs)("div",{ref:f,role:"dialog","aria-label":x??P.chartPeriod,style:{position:"fixed",top:v.top,left:v.left,visibility:v.isReady?"visible":"hidden"},className:"z-50 flex overflow-hidden rounded-lg border border-gray-200 bg-white shadow-lg dark:border-gray-700 dark:bg-gray-800",children:[(0,r.jsxs)("div",{ref:L,tabIndex:-1,className:"flex min-w-44 flex-col p-1 outline-none",children:[u.map(e=>(0,r.jsx)("button",{type:"button","aria-pressed":s.preset===e,onClick:()=>J(e),className:(0,b.cn)("cursor-pointer rounded-md px-3 py-1.5 text-left text-sm text-gray-700 hover:bg-gray-100 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-synertech-primary-500 dark:text-gray-200 dark:hover:bg-gray-700",s.preset===e&&"bg-synertech-primary-50 font-medium text-synertech-primary-700 dark:bg-synertech-primary-950 dark:text-synertech-primary-300"),children:C(e)},e)),d?(0,r.jsx)("button",{type:"button","aria-pressed":s.preset==="custom","aria-expanded":R,onClick:()=>w(!0),className:(0,b.cn)("cursor-pointer rounded-md px-3 py-1.5 text-left text-sm text-gray-700 hover:bg-gray-100 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-synertech-primary-500 dark:text-gray-200 dark:hover:bg-gray-700",s.preset==="custom"&&"bg-synertech-primary-50 font-medium text-synertech-primary-700 dark:bg-synertech-primary-950 dark:text-synertech-primary-300"),children:C("custom")}):null]}),d&&R?(0,r.jsx)("div",{className:"border-l border-gray-200 p-2 dark:border-gray-700",children:(0,r.jsx)(N.Calendar,{mode:"range",value:Q??{from:s.from,to:s.to},onChange:V,numberOfMonths:W,weekStartsOn:H,locale:D,today:m,minDate:F,maxDate:U,size:"sm"})}):null]});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("button",{ref:p,type:"button",disabled:q,"aria-haspopup":"dialog","aria-expanded":i,"aria-label":`${x??P.chartPeriod}: ${S}`,onClick:()=>i?l():E(!0),className:(0,b.cn)("inline-flex cursor-pointer items-center gap-2 rounded-full border border-gray-300 bg-white font-medium text-gray-700 transition-colors hover:bg-gray-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",ie[B],Y),...$,children:[se,(0,r.jsx)("span",{children:S})]}),i&&typeof document<"u"?(0,O.createPortal)(X,document.body):null]})}0&&(module.exports={ChartPeriodPicker});
1
+ "use strict";"use client";var D=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var oe=Object.prototype.hasOwnProperty;var ae=(n,o)=>{for(var l in o)D(n,l,{get:o[l],enumerable:!0})},ne=(n,o,l,p)=>{if(o&&typeof o=="object"||typeof o=="function")for(let d of re(o))!oe.call(n,d)&&d!==l&&D(n,d,{get:()=>o[d],enumerable:!(p=te(o,d))||p.enumerable});return n};var ie=n=>ne(D({},"__esModule",{value:!0}),n);var ue={};ae(ue,{ChartPeriodPicker:()=>le});module.exports=ie(ue);var t=require("react"),N=require("react-dom"),z=require("../../lib/aria-hide.cjs"),g=require("../../lib/owner-document.cjs"),P=require("../../lib/cn.cjs"),v=require("../../lib/i18n.cjs"),A=require("../calendar/Calendar.cjs"),F=require("../dropdown/hooks/usePositioning.cjs"),a=require("./utils/period.cjs"),r=require("react/jsx-runtime"),se={"7d":"chartPeriodLast7Days","30d":"chartPeriodLast30Days","90d":"chartPeriodLast90Days","12m":"chartPeriodLast12Months",mtd:"chartPeriodMonthToDate",qtd:"chartPeriodQuarterToDate",ytd:"chartPeriodYearToDate",custom:"chartPeriodCustom"},de={sm:"h-7 px-2.5 text-xs",md:"h-8 px-3 text-sm",lg:"h-10 px-4 text-sm"},ce=(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,r.jsx)("path",{d:"M5 1.5v2M11 1.5v2M2.5 6h11M3.5 3h9a1 1 0 011 1v9a1 1 0 01-1 1h-9a1 1 0 01-1-1V4a1 1 0 011-1z",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})});function le({value:n,defaultValue:o,onChange:l,presets:p=a.DEFAULT_CHART_PERIOD_PRESETS,custom:d=!0,presetLabels:U,now:f,minDate:W,maxDate:H,numberOfMonths:_=1,weekStartsOn:B,locale:K,size:q="md",align:Y="start",disabled:$=!1,label:L,className:Q,...j}){let C=(0,v.useUILabels)(),E=(0,v.useUILocale)(K),c=(0,t.useRef)(null),h=(0,t.useRef)(null),R=(0,t.useRef)(null),[i,w]=(0,t.useState)(!1),[M,S]=(0,t.useState)(!1),[G,O]=(0,t.useState)(null),[J,V]=(0,t.useState)(()=>typeof o=="string"?(0,a.createPeriod)(o,f):o||(0,a.createPeriod)(p[0]??"30d",f)),s=n??J,k=(0,F.usePositioning)({triggerRef:c,contentRef:h,isOpen:i,side:"bottom",align:Y}),u=(0,t.useCallback)((e=!0)=>{w(!1),S(!1),O(null),e&&c.current?.focus()},[]);(0,t.useEffect)(()=>{if(!i)return;let e=b=>{let I=b.target;h.current?.contains(I)||c.current?.contains(I)||u(!1)},m=(0,g.ownerDocumentOf)(c.current);return m.addEventListener("mousedown",e),m.addEventListener("touchstart",e,{passive:!0}),()=>{m.removeEventListener("mousedown",e),m.removeEventListener("touchstart",e)}},[i,u]),(0,t.useEffect)(()=>{if(!i)return;let e=b=>{b.key==="Escape"&&(b.stopPropagation(),u())},m=(0,g.ownerDocumentOf)(c.current);return m.addEventListener("keydown",e),()=>m.removeEventListener("keydown",e)},[i,u]),(0,t.useEffect)(()=>{let e=h.current;if(e)return(0,z.registerFloatingLayer)(e,()=>c.current)},[i]),(0,t.useEffect)(()=>{if(!i)return;let e=requestAnimationFrame(()=>R.current?.focus());return()=>cancelAnimationFrame(e)},[i]);let y=(0,t.useCallback)(e=>{n===void 0&&V(e),l?.(e),u()},[n,l,u]),X=(0,t.useCallback)(e=>y((0,a.createPeriod)(e,f)),[y,f]),Z=(0,t.useCallback)(e=>{O(e),!(!e.from||!e.to)&&y({preset:"custom",from:(0,a.startOfDay)(e.from),to:(0,a.endOfDay)(e.to)})},[y]),x=e=>U?.[e]??C[se[e]],T=s.preset==="custom"?(0,a.formatPeriodRange)(s.from,s.to,E):x(s.preset),ee=(0,r.jsxs)("div",{ref:h,role:"dialog","aria-label":L??C.chartPeriod,style:{position:"fixed",top:k.top,left:k.left,visibility:k.isReady?"visible":"hidden"},className:"z-50 flex overflow-hidden rounded-lg border border-gray-200 bg-white shadow-lg dark:border-gray-700 dark:bg-gray-800",children:[(0,r.jsxs)("div",{ref:R,tabIndex:-1,className:"flex min-w-44 flex-col p-1 outline-none",children:[p.map(e=>(0,r.jsx)("button",{type:"button","aria-pressed":s.preset===e,onClick:()=>X(e),className:(0,P.cn)("cursor-pointer rounded-md px-3 py-1.5 text-left text-sm text-gray-700 hover:bg-gray-100 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-synertech-primary-500 dark:text-gray-200 dark:hover:bg-gray-700",s.preset===e&&"bg-synertech-primary-50 font-medium text-synertech-primary-700 dark:bg-synertech-primary-950 dark:text-synertech-primary-300"),children:x(e)},e)),d?(0,r.jsx)("button",{type:"button","aria-pressed":s.preset==="custom","aria-expanded":M,onClick:()=>S(!0),className:(0,P.cn)("cursor-pointer rounded-md px-3 py-1.5 text-left text-sm text-gray-700 hover:bg-gray-100 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-synertech-primary-500 dark:text-gray-200 dark:hover:bg-gray-700",s.preset==="custom"&&"bg-synertech-primary-50 font-medium text-synertech-primary-700 dark:bg-synertech-primary-950 dark:text-synertech-primary-300"),children:x("custom")}):null]}),d&&M?(0,r.jsx)("div",{className:"border-l border-gray-200 p-2 dark:border-gray-700",children:(0,r.jsx)(A.Calendar,{mode:"range",value:G??{from:s.from,to:s.to},onChange:Z,numberOfMonths:_,weekStartsOn:B,locale:E,today:f,minDate:W,maxDate:H,size:"sm"})}):null]});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("button",{ref:c,type:"button",disabled:$,"aria-haspopup":"dialog","aria-expanded":i,"aria-label":`${L??C.chartPeriod}: ${T}`,onClick:()=>i?u():w(!0),className:(0,P.cn)("inline-flex cursor-pointer items-center gap-2 rounded-full border border-gray-300 bg-white font-medium text-gray-700 transition-colors hover:bg-gray-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",de[q],Q),...j,children:[ce,(0,r.jsx)("span",{children:T})]}),i&&typeof document<"u"?(0,N.createPortal)(ee,(0,g.ownerDocumentOf)(c.current).body):null]})}0&&(module.exports={ChartPeriodPicker});
@@ -1 +1 @@
1
- "use client";import{useCallback as u,useEffect as m,useRef as P,useState as p}from"react";import{createPortal as V}from"react-dom";import{registerFloatingLayer as X}from"../../lib/aria-hide.js";import{cn as v}from"../../lib/cn.js";import{useUILabels as Z,useUILocale as ee}from"../../lib/i18n.js";import{Calendar as te}from"../calendar/Calendar.js";import{usePositioning as re}from"../dropdown/hooks/usePositioning.js";import{DEFAULT_CHART_PERIOD_PRESETS as oe,createPeriod as C,endOfDay as ae,formatPeriodRange as ne,startOfDay as ie}from"./utils/period.js";import{Fragment as le,jsx as a,jsxs as f}from"react/jsx-runtime";var se={"7d":"chartPeriodLast7Days","30d":"chartPeriodLast30Days","90d":"chartPeriodLast90Days","12m":"chartPeriodLast12Months",mtd:"chartPeriodMonthToDate",qtd:"chartPeriodQuarterToDate",ytd:"chartPeriodYearToDate",custom:"chartPeriodCustom"},de={sm:"h-7 px-2.5 text-xs",md:"h-8 px-3 text-sm",lg:"h-10 px-4 text-sm"},ce=a("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:a("path",{d:"M5 1.5v2M11 1.5v2M2.5 6h11M3.5 3h9a1 1 0 011 1v9a1 1 0 01-1 1h-9a1 1 0 01-1-1V4a1 1 0 011-1z",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})});function Pe({value:h,defaultValue:s,onChange:k,presets:x=oe,custom:D=!0,presetLabels:N,now:n,minDate:z,maxDate:A,numberOfMonths:F=1,weekStartsOn:U,locale:W,size:H="md",align:_="start",disabled:B=!1,label:L,className:K,...q}){let y=Z(),E=ee(W),i=P(null),d=P(null),R=P(null),[t,w]=p(!1),[M,S]=p(!1),[Y,T]=p(null),[$,Q]=p(()=>typeof s=="string"?C(s,n):s||C(x[0]??"30d",n)),r=h??$,b=re({triggerRef:i,contentRef:d,isOpen:t,side:"bottom",align:_}),o=u((e=!0)=>{w(!1),S(!1),T(null),e&&i.current?.focus()},[]);m(()=>{if(!t)return;let e=l=>{let I=l.target;d.current?.contains(I)||i.current?.contains(I)||o(!1)};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e,{passive:!0}),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}},[t,o]),m(()=>{if(!t)return;let e=l=>{l.key==="Escape"&&(l.stopPropagation(),o())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[t,o]),m(()=>{let e=d.current;if(e)return X(e,()=>i.current)},[t]),m(()=>{if(!t)return;let e=requestAnimationFrame(()=>R.current?.focus());return()=>cancelAnimationFrame(e)},[t]);let c=u(e=>{h===void 0&&Q(e),k?.(e),o()},[h,k,o]),j=u(e=>c(C(e,n)),[c,n]),G=u(e=>{T(e),!(!e.from||!e.to)&&c({preset:"custom",from:ie(e.from),to:ae(e.to)})},[c]),g=e=>N?.[e]??y[se[e]],O=r.preset==="custom"?ne(r.from,r.to,E):g(r.preset),J=f("div",{ref:d,role:"dialog","aria-label":L??y.chartPeriod,style:{position:"fixed",top:b.top,left:b.left,visibility:b.isReady?"visible":"hidden"},className:"z-50 flex overflow-hidden rounded-lg border border-gray-200 bg-white shadow-lg dark:border-gray-700 dark:bg-gray-800",children:[f("div",{ref:R,tabIndex:-1,className:"flex min-w-44 flex-col p-1 outline-none",children:[x.map(e=>a("button",{type:"button","aria-pressed":r.preset===e,onClick:()=>j(e),className:v("cursor-pointer rounded-md px-3 py-1.5 text-left text-sm text-gray-700 hover:bg-gray-100 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-synertech-primary-500 dark:text-gray-200 dark:hover:bg-gray-700",r.preset===e&&"bg-synertech-primary-50 font-medium text-synertech-primary-700 dark:bg-synertech-primary-950 dark:text-synertech-primary-300"),children:g(e)},e)),D?a("button",{type:"button","aria-pressed":r.preset==="custom","aria-expanded":M,onClick:()=>S(!0),className:v("cursor-pointer rounded-md px-3 py-1.5 text-left text-sm text-gray-700 hover:bg-gray-100 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-synertech-primary-500 dark:text-gray-200 dark:hover:bg-gray-700",r.preset==="custom"&&"bg-synertech-primary-50 font-medium text-synertech-primary-700 dark:bg-synertech-primary-950 dark:text-synertech-primary-300"),children:g("custom")}):null]}),D&&M?a("div",{className:"border-l border-gray-200 p-2 dark:border-gray-700",children:a(te,{mode:"range",value:Y??{from:r.from,to:r.to},onChange:G,numberOfMonths:F,weekStartsOn:U,locale:E,today:n,minDate:z,maxDate:A,size:"sm"})}):null]});return f(le,{children:[f("button",{ref:i,type:"button",disabled:B,"aria-haspopup":"dialog","aria-expanded":t,"aria-label":`${L??y.chartPeriod}: ${O}`,onClick:()=>t?o():w(!0),className:v("inline-flex cursor-pointer items-center gap-2 rounded-full border border-gray-300 bg-white font-medium text-gray-700 transition-colors hover:bg-gray-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",de[H],K),...q,children:[ce,a("span",{children:O})]}),t&&typeof document<"u"?V(J,document.body):null]})}export{Pe as ChartPeriodPicker};
1
+ "use client";import{useCallback as m,useEffect as p,useRef as v,useState as f}from"react";import{createPortal as Z}from"react-dom";import{registerFloatingLayer as ee}from"../../lib/aria-hide.js";import{ownerDocumentOf as C}from"../../lib/owner-document.js";import{cn as k}from"../../lib/cn.js";import{useUILabels as te,useUILocale as re}from"../../lib/i18n.js";import{Calendar as oe}from"../calendar/Calendar.js";import{usePositioning as ae}from"../dropdown/hooks/usePositioning.js";import{DEFAULT_CHART_PERIOD_PRESETS as ne,createPeriod as x,endOfDay as ie,formatPeriodRange as se,startOfDay as de}from"./utils/period.js";import{Fragment as me,jsx as i,jsxs as h}from"react/jsx-runtime";var ce={"7d":"chartPeriodLast7Days","30d":"chartPeriodLast30Days","90d":"chartPeriodLast90Days","12m":"chartPeriodLast12Months",mtd:"chartPeriodMonthToDate",qtd:"chartPeriodQuarterToDate",ytd:"chartPeriodYearToDate",custom:"chartPeriodCustom"},le={sm:"h-7 px-2.5 text-xs",md:"h-8 px-3 text-sm",lg:"h-10 px-4 text-sm"},ue=i("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:i("path",{d:"M5 1.5v2M11 1.5v2M2.5 6h11M3.5 3h9a1 1 0 011 1v9a1 1 0 01-1 1h-9a1 1 0 01-1-1V4a1 1 0 011-1z",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})});function ke({value:y,defaultValue:d,onChange:D,presets:L=ne,custom:E=!0,presetLabels:A,now:s,minDate:F,maxDate:U,numberOfMonths:W=1,weekStartsOn:H,locale:_,size:B="md",align:K="start",disabled:q=!1,label:R,className:Y,...$}){let b=te(),w=re(_),o=v(null),c=v(null),M=v(null),[t,S]=f(!1),[O,T]=f(!1),[Q,I]=f(null),[j,G]=f(()=>typeof d=="string"?x(d,s):d||x(L[0]??"30d",s)),r=y??j,g=ae({triggerRef:o,contentRef:c,isOpen:t,side:"bottom",align:K}),a=m((e=!0)=>{S(!1),T(!1),I(null),e&&o.current?.focus()},[]);p(()=>{if(!t)return;let e=u=>{let z=u.target;c.current?.contains(z)||o.current?.contains(z)||a(!1)},n=C(o.current);return n.addEventListener("mousedown",e),n.addEventListener("touchstart",e,{passive:!0}),()=>{n.removeEventListener("mousedown",e),n.removeEventListener("touchstart",e)}},[t,a]),p(()=>{if(!t)return;let e=u=>{u.key==="Escape"&&(u.stopPropagation(),a())},n=C(o.current);return n.addEventListener("keydown",e),()=>n.removeEventListener("keydown",e)},[t,a]),p(()=>{let e=c.current;if(e)return ee(e,()=>o.current)},[t]),p(()=>{if(!t)return;let e=requestAnimationFrame(()=>M.current?.focus());return()=>cancelAnimationFrame(e)},[t]);let l=m(e=>{y===void 0&&G(e),D?.(e),a()},[y,D,a]),J=m(e=>l(x(e,s)),[l,s]),V=m(e=>{I(e),!(!e.from||!e.to)&&l({preset:"custom",from:de(e.from),to:ie(e.to)})},[l]),P=e=>A?.[e]??b[ce[e]],N=r.preset==="custom"?se(r.from,r.to,w):P(r.preset),X=h("div",{ref:c,role:"dialog","aria-label":R??b.chartPeriod,style:{position:"fixed",top:g.top,left:g.left,visibility:g.isReady?"visible":"hidden"},className:"z-50 flex overflow-hidden rounded-lg border border-gray-200 bg-white shadow-lg dark:border-gray-700 dark:bg-gray-800",children:[h("div",{ref:M,tabIndex:-1,className:"flex min-w-44 flex-col p-1 outline-none",children:[L.map(e=>i("button",{type:"button","aria-pressed":r.preset===e,onClick:()=>J(e),className:k("cursor-pointer rounded-md px-3 py-1.5 text-left text-sm text-gray-700 hover:bg-gray-100 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-synertech-primary-500 dark:text-gray-200 dark:hover:bg-gray-700",r.preset===e&&"bg-synertech-primary-50 font-medium text-synertech-primary-700 dark:bg-synertech-primary-950 dark:text-synertech-primary-300"),children:P(e)},e)),E?i("button",{type:"button","aria-pressed":r.preset==="custom","aria-expanded":O,onClick:()=>T(!0),className:k("cursor-pointer rounded-md px-3 py-1.5 text-left text-sm text-gray-700 hover:bg-gray-100 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-synertech-primary-500 dark:text-gray-200 dark:hover:bg-gray-700",r.preset==="custom"&&"bg-synertech-primary-50 font-medium text-synertech-primary-700 dark:bg-synertech-primary-950 dark:text-synertech-primary-300"),children:P("custom")}):null]}),E&&O?i("div",{className:"border-l border-gray-200 p-2 dark:border-gray-700",children:i(oe,{mode:"range",value:Q??{from:r.from,to:r.to},onChange:V,numberOfMonths:W,weekStartsOn:H,locale:w,today:s,minDate:F,maxDate:U,size:"sm"})}):null]});return h(me,{children:[h("button",{ref:o,type:"button",disabled:q,"aria-haspopup":"dialog","aria-expanded":t,"aria-label":`${R??b.chartPeriod}: ${N}`,onClick:()=>t?a():S(!0),className:k("inline-flex cursor-pointer items-center gap-2 rounded-full border border-gray-300 bg-white font-medium text-gray-700 transition-colors hover:bg-gray-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",le[B],Y),...$,children:[ue,i("span",{children:N})]}),t&&typeof document<"u"?Z(X,C(o.current).body):null]})}export{ke as ChartPeriodPicker};