@synertech/ui 0.45.1 → 0.46.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/.claude/skills/use-synertech-ui/SKILL.md +115 -17
  2. package/README.md +47 -5
  3. package/dist/components/area-chart/AreaChart.cjs +1 -1
  4. package/dist/components/area-chart/AreaChart.js +1 -1
  5. package/dist/components/avatar/Avatar.cjs +1 -1
  6. package/dist/components/avatar/Avatar.js +1 -1
  7. package/dist/components/badge/Badge.cjs +1 -1
  8. package/dist/components/badge/Badge.js +1 -1
  9. package/dist/components/banner/Banner.cjs +1 -1
  10. package/dist/components/banner/Banner.js +1 -1
  11. package/dist/components/bar-chart/BarChart.cjs +1 -1
  12. package/dist/components/bar-chart/BarChart.js +1 -1
  13. package/dist/components/box-plot/BoxPlot.cjs +1 -1
  14. package/dist/components/box-plot/BoxPlot.js +1 -1
  15. package/dist/components/breadcrumb/Breadcrumb.cjs +1 -1
  16. package/dist/components/breadcrumb/Breadcrumb.js +1 -1
  17. package/dist/components/bullet-chart/BulletChart.cjs +1 -1
  18. package/dist/components/bullet-chart/BulletChart.js +1 -1
  19. package/dist/components/calendar/Calendar.cjs +1 -1
  20. package/dist/components/calendar/Calendar.js +1 -1
  21. package/dist/components/candlestick-chart/CandlestickChart.cjs +1 -1
  22. package/dist/components/candlestick-chart/CandlestickChart.js +1 -1
  23. package/dist/components/chart/ChartBrush.cjs +1 -1
  24. package/dist/components/chart/ChartBrush.js +1 -1
  25. package/dist/components/chart/ChartExportButton.cjs +1 -1
  26. package/dist/components/chart/ChartExportButton.js +1 -1
  27. package/dist/components/chart/utils/export.cjs +1 -2
  28. package/dist/components/chart/utils/export.js +1 -2
  29. package/dist/components/chart/utils/keyboard.cjs +1 -0
  30. package/dist/components/chart/utils/keyboard.js +1 -0
  31. package/dist/components/chip/Chip.cjs +1 -1
  32. package/dist/components/chip/Chip.js +1 -1
  33. package/dist/components/datagrid/DataGrid.cjs +1 -2
  34. package/dist/components/datagrid/DataGrid.js +1 -2
  35. package/dist/components/device-mockup/DeviceMockup.cjs +1 -1
  36. package/dist/components/device-mockup/DeviceMockup.js +1 -1
  37. package/dist/components/dropdown/Dropdown.cjs +1 -1
  38. package/dist/components/dropdown/Dropdown.js +1 -1
  39. package/dist/components/dropdown/DropdownCheckboxItem.cjs +1 -1
  40. package/dist/components/dropdown/DropdownCheckboxItem.js +1 -1
  41. package/dist/components/dropdown/DropdownContent.cjs +1 -1
  42. package/dist/components/dropdown/DropdownContent.js +1 -1
  43. package/dist/components/dropdown/DropdownItem.cjs +1 -1
  44. package/dist/components/dropdown/DropdownItem.js +1 -1
  45. package/dist/components/dropdown/DropdownRadio.cjs +1 -1
  46. package/dist/components/dropdown/DropdownRadio.js +1 -1
  47. package/dist/components/dropdown/DropdownSubMenu.cjs +1 -1
  48. package/dist/components/dropdown/DropdownSubMenu.js +1 -1
  49. package/dist/components/dropdown/hooks/index.cjs +1 -1
  50. package/dist/components/dropdown/hooks/index.js +1 -1
  51. package/dist/components/dropdown/hooks/useClickOutside.cjs +1 -1
  52. package/dist/components/dropdown/hooks/useClickOutside.js +1 -1
  53. package/dist/components/dropdown/index.cjs +1 -1
  54. package/dist/components/dropdown/index.js +1 -1
  55. package/dist/components/dropdown/menu-navigation.cjs +1 -0
  56. package/dist/components/dropdown/menu-navigation.js +1 -0
  57. package/dist/components/dumbbell-chart/DumbbellChart.cjs +1 -1
  58. package/dist/components/dumbbell-chart/DumbbellChart.js +1 -1
  59. package/dist/components/file-selector/FileSelector.cjs +1 -1
  60. package/dist/components/file-selector/FileSelector.js +1 -1
  61. package/dist/components/form/input/Input.cjs +1 -1
  62. package/dist/components/form/input/Input.js +1 -1
  63. package/dist/components/form/mention-input/MentionInput.cjs +1 -1
  64. package/dist/components/form/mention-input/MentionInput.js +1 -1
  65. package/dist/components/form/number-input/NumberInput.cjs +1 -1
  66. package/dist/components/form/number-input/NumberInput.js +1 -1
  67. package/dist/components/funnel-chart/FunnelChart.cjs +1 -1
  68. package/dist/components/funnel-chart/FunnelChart.js +1 -1
  69. package/dist/components/gantt-chart/GanttChart.cjs +1 -1
  70. package/dist/components/gantt-chart/GanttChart.js +1 -1
  71. package/dist/components/header/Header.cjs +1 -1
  72. package/dist/components/header/Header.js +1 -1
  73. package/dist/components/heat-map/Heatmap.cjs +1 -1
  74. package/dist/components/heat-map/Heatmap.js +1 -1
  75. package/dist/components/help-button/HelpButton.cjs +7 -7
  76. package/dist/components/help-button/HelpButton.js +7 -7
  77. package/dist/components/help-button/MarkdownEditor.cjs +1 -1
  78. package/dist/components/help-button/MarkdownEditor.js +1 -1
  79. package/dist/components/image-uploader/ImageUploader.cjs +1 -1
  80. package/dist/components/image-uploader/ImageUploader.js +1 -1
  81. package/dist/components/indicator/Indicator.cjs +1 -1
  82. package/dist/components/indicator/Indicator.js +1 -1
  83. package/dist/components/label/Label.cjs +1 -1
  84. package/dist/components/label/Label.js +1 -1
  85. package/dist/components/line-chart/LineChart.cjs +1 -1
  86. package/dist/components/line-chart/LineChart.js +1 -1
  87. package/dist/components/modal/Modal.cjs +1 -1
  88. package/dist/components/modal/Modal.js +1 -1
  89. package/dist/components/pagination/Pagination.cjs +1 -1
  90. package/dist/components/pagination/Pagination.js +1 -1
  91. package/dist/components/pie-chart/PieChart.cjs +1 -1
  92. package/dist/components/pie-chart/PieChart.js +1 -1
  93. package/dist/components/radio-button/RadioButton.cjs +1 -1
  94. package/dist/components/radio-button/RadioButton.js +1 -1
  95. package/dist/components/scatter-chart/ScatterChart.cjs +1 -1
  96. package/dist/components/scatter-chart/ScatterChart.js +1 -1
  97. package/dist/components/schema-editor/SchemaEditor.cjs +1 -1
  98. package/dist/components/schema-editor/SchemaEditor.js +1 -1
  99. package/dist/components/schema-editor/legend/SchemaLegend.cjs +1 -1
  100. package/dist/components/schema-editor/legend/SchemaLegend.js +1 -1
  101. package/dist/components/schema-editor/tables/SchemaTableRenderer.cjs +1 -1
  102. package/dist/components/schema-editor/tables/SchemaTableRenderer.js +1 -1
  103. package/dist/components/schema-editor/toolbar/SchemaToolbar.cjs +1 -1
  104. package/dist/components/schema-editor/toolbar/SchemaToolbar.js +1 -1
  105. package/dist/components/select/Select.cjs +1 -1
  106. package/dist/components/select/Select.js +1 -1
  107. package/dist/components/tabs/Tabs.cjs +1 -1
  108. package/dist/components/tabs/Tabs.js +1 -1
  109. package/dist/components/tabs/TabsContent.cjs +1 -1
  110. package/dist/components/tabs/TabsContent.js +1 -1
  111. package/dist/components/tabs/TabsContext.cjs +1 -1
  112. package/dist/components/tabs/TabsContext.js +1 -1
  113. package/dist/components/tabs/TabsList.cjs +1 -1
  114. package/dist/components/tabs/TabsList.js +1 -1
  115. package/dist/components/tabs/TabsTrigger.cjs +1 -1
  116. package/dist/components/tabs/TabsTrigger.js +1 -1
  117. package/dist/components/toast/Toast.cjs +1 -1
  118. package/dist/components/toast/Toast.js +1 -1
  119. package/dist/components/tooltip/Tooltip.cjs +1 -1
  120. package/dist/components/tooltip/Tooltip.js +1 -1
  121. package/dist/components/waterfall-chart/WaterfallChart.cjs +1 -1
  122. package/dist/components/waterfall-chart/WaterfallChart.js +1 -1
  123. package/dist/components/wizard/Wizard.cjs +1 -1
  124. package/dist/components/wizard/Wizard.js +1 -1
  125. package/dist/components/workflow-editor/WorkflowEditor.cjs +1 -1
  126. package/dist/components/workflow-editor/WorkflowEditor.js +1 -1
  127. package/dist/components/workflow-editor/toolbar/WorkflowToolbar.cjs +1 -1
  128. package/dist/components/workflow-editor/toolbar/WorkflowToolbar.js +1 -1
  129. package/dist/index.cjs +1 -1
  130. package/dist/index.d.cts +814 -172
  131. package/dist/index.d.ts +814 -172
  132. package/dist/index.js +1 -1
  133. package/dist/lib/aria-hide.cjs +1 -1
  134. package/dist/lib/aria-hide.js +1 -1
  135. package/dist/lib/csv.cjs +2 -0
  136. package/dist/lib/csv.js +2 -0
  137. package/dist/lib/i18n.cjs +1 -1
  138. package/dist/lib/i18n.js +1 -1
  139. package/dist/lib/server-labels.cjs +1 -0
  140. package/dist/lib/server-labels.js +1 -0
  141. package/dist/lib/ui-labels.cjs +1 -0
  142. package/dist/lib/ui-labels.js +1 -0
  143. package/dist/styles.css +3152 -309
  144. package/package.json +3 -3
@@ -1 +1 @@
1
- "use client";import{useCallback as p,useEffect as Xe,useMemo as K,useRef as ke,useState as Q}from"react";import{cn as c}from"../../lib/cn.js";import{jsx as o,jsxs as N}from"react/jsx-runtime";var Ze=10080*60*1e3;function u(a){return new Date(a.getFullYear(),a.getMonth(),a.getDate())}function W(a){return new Date(a.getFullYear(),a.getMonth(),1)}function P(a,r){return new Date(a.getFullYear(),a.getMonth(),a.getDate()+r)}function v(a,r){return new Date(a.getFullYear(),a.getMonth()+r,1)}function ue(a){return new Date(a.getFullYear(),a.getMonth()+1,0).getDate()}function S(a,r){return!a||!r?!1:a.getFullYear()===r.getFullYear()&&a.getMonth()===r.getMonth()&&a.getDate()===r.getDate()}function de(a,r){return a.getFullYear()===r.getFullYear()&&a.getMonth()===r.getMonth()}function E(a,r){return a.getFullYear()*12+a.getMonth()-(r.getFullYear()*12+r.getMonth())}function X(a){let r=`${a.getMonth()+1}`.padStart(2,"0"),i=`${a.getDate()}`.padStart(2,"0");return`${a.getFullYear()}-${r}-${i}`}function et(a){let r=u(a);r.setDate(r.getDate()-(r.getDay()+6)%7+3);let i=new Date(r.getFullYear(),0,4);return i.setDate(i.getDate()-(i.getDay()+6)%7+3),1+Math.round((r.getTime()-i.getTime())/Ze)}function we(a,r,i){return r&&a<u(r)?u(r):i&&a>u(i)?u(i):a}function tt(a,r,i){let z=W(a),_=(z.getDay()-r+7)%7,j=P(z,-_),O=i?6:Math.ceil((_+ue(a))/7);return Array.from({length:O},(ee,U)=>Array.from({length:7},(ce,T)=>P(j,U*7+T)))}function at({className:a}){return o("svg",{className:a,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:o("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function rt({className:a}){return o("svg",{className:a,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:o("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}var nt={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"}},ot={primary:"bg-blue-600 text-white hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600",success:"bg-green-600 text-white hover:bg-green-700 dark:bg-green-500 dark:hover:bg-green-600",warning:"bg-yellow-500 text-white hover:bg-yellow-600 dark:bg-yellow-400 dark:text-gray-900 dark:hover:bg-yellow-500",error:"bg-red-600 text-white hover:bg-red-700 dark:bg-red-500 dark:hover:bg-red-600",info:"bg-cyan-600 text-white hover:bg-cyan-700 dark:bg-cyan-500 dark:hover:bg-cyan-600",neutral:"bg-gray-700 text-white hover:bg-gray-800 dark:bg-gray-500 dark:hover:bg-gray-400"},lt={primary:"bg-blue-50 dark:bg-blue-900/30",success:"bg-green-50 dark:bg-green-900/30",warning:"bg-yellow-50 dark:bg-yellow-900/30",error:"bg-red-50 dark:bg-red-900/30",info:"bg-cyan-50 dark:bg-cyan-900/30",neutral:"bg-gray-100 dark:bg-gray-700/40"},st={primary:"text-blue-900 dark:text-blue-100",success:"text-green-900 dark:text-green-100",warning:"text-yellow-900 dark:text-yellow-100",error:"text-red-900 dark:text-red-100",info:"text-cyan-900 dark:text-cyan-100",neutral:"text-gray-900 dark:text-gray-100"},it={primary:"font-semibold text-blue-600 dark:text-blue-400",success:"font-semibold text-green-600 dark:text-green-400",warning:"font-semibold text-yellow-600 dark:text-yellow-400",error:"font-semibold text-red-600 dark:text-red-400",info:"font-semibold text-cyan-600 dark:text-cyan-400",neutral:"font-semibold text-gray-900 dark:text-gray-100"},I={primary:"focus-visible:ring-blue-500",success:"focus-visible:ring-green-500",warning:"focus-visible:ring-yellow-500",error:"focus-visible:ring-red-500",info:"focus-visible:ring-cyan-500",neutral:"focus-visible:ring-gray-500"};function Z(a,r){if(a==="multiple")return Array.isArray(r)?r.map(u):[];if(a==="range"){let i=r??null;return{from:i?.from?u(i.from):null,to:i?.to?u(i.to):null}}return r instanceof Date?u(r):null}function Ce(a){return a?a instanceof Date?a:Array.isArray(a)?a[0]??null:a.from??a.to??null:null}function gt(a){let{mode:r="single",value:i,defaultValue:z,onChange:_,max:j,month:O,defaultMonth:ee,onMonthChange:U,numberOfMonths:ce=1,weekStartsOn:T=0,locale:F,size:Me="md",color:D="primary",minDate:x,maxDate:k,disabledDates:$,disabled:b=!1,showOutsideDays:Se=!0,showWeekNumbers:ge=!1,fixedWeeks:Ne=!1,captionLayout:te="label",fromYear:fe,toYear:be,todayButton:ae=!1,clearButton:re=!1,footer:ye,bordered:Fe=!0,renderDay:me,labels:B,className:Re,...Ye}=a,m=nt[Me],w=Math.max(1,ce),R=K(()=>u(new Date),[]),ne=i!==void 0,[Pe,Te]=Q(()=>Z(r,z)),A=ne?Z(r,i):Pe,oe=O!==void 0,[Ae,Ee]=Q(()=>W(ee??Ce(Z(r,z??i))??new Date)),g=oe?W(O):Ae,h=p(e=>{let t=W(e);oe||Ee(t),U?.(t)},[oe,U]),he=ke(null),le=ke(!1),[L,q]=Q(()=>{let e=Ce(Z(r,z??i)),t=W(ee??O??e??new Date),d=e&&de(e,t)?e:de(u(new Date),t)?u(new Date):t;return we(d,x,k)}),Be=v(g,w-1),Le=E(L,g)>=0&&E(L,Be)<=0?L:g;Xe(()=>{if(!le.current)return;le.current=!1,he.current?.querySelector(`[data-day="${X(L)}"]:not([data-outside])`)?.focus()},[L,g]);let Y=p(e=>{let t=we(u(e),x,k);le.current=!0,q(t);let d=v(g,w-1);E(t,g)<0?h(t):E(t,d)>0&&h(v(t,-(w-1)))},[g,w,x,k,h]),V=p(e=>b||x&&e<u(x)||k&&e>u(k)?!0:typeof $=="function"?$(e):Array.isArray($)?$.some(t=>S(t,e)):!1,[b,x,k,$]),[se,pe]=Q(null),C=p(e=>{ne||Te(e),_?.(e)},[ne,_]),J=p(e=>{let t=u(e);if(V(t))return;if(r==="multiple"){let l=A??[];if(l.some(n=>S(n,t))){C(l.filter(n=>!S(n,t)));return}if(j!==void 0&&l.length>=j)return;C([...l,t].sort((n,f)=>n.getTime()-f.getTime()));return}if(r==="range"){let l=A??{from:null,to:null};if(!l.from||l.to){C({from:t,to:null});return}C(t<l.from?{from:t,to:l.from}:{from:l.from,to:t});return}C(S(A,t)?null:t)},[r,A,j,C,V]),Ie=p(e=>{J(e),q(u(e)),E(e,g)<0?h(e):E(e,v(g,w-1))>0&&h(v(e,-(w-1)))},[J,g,w,h]),De=!b&&(!x||E(g,W(x))>0),ve=!b&&(!k||E(v(g,w-1),W(k))<0),We=p(()=>{h(v(g,-1))},[g,h]),ze=p(()=>{h(v(g,1))},[g,h]),Ve=p(e=>{if(b)return;let t=L;switch(e.key){case"ArrowLeft":e.preventDefault(),Y(P(t,-1));break;case"ArrowRight":e.preventDefault(),Y(P(t,1));break;case"ArrowUp":e.preventDefault(),Y(P(t,-7));break;case"ArrowDown":e.preventDefault(),Y(P(t,7));break;case"Home":e.preventDefault(),Y(P(t,-((t.getDay()-T+7)%7)));break;case"End":e.preventDefault(),Y(P(t,6-(t.getDay()-T+7)%7));break;case"PageUp":{e.preventDefault();let d=e.shiftKey?-12:-1,l=v(t,d),y=Math.min(t.getDate(),ue(l));Y(new Date(l.getFullYear(),l.getMonth(),y));break}case"PageDown":{e.preventDefault();let d=e.shiftKey?12:1,l=v(t,d),y=Math.min(t.getDate(),ue(l));Y(new Date(l.getFullYear(),l.getMonth(),y));break}default:break}},[b,L,Y,T]),Ke=K(()=>{let e=new Intl.DateTimeFormat(F,{weekday:"short"}),t=new Intl.DateTimeFormat(F,{weekday:"long"}),d=new Date(2024,0,7);return Array.from({length:7},(l,y)=>{let n=P(d,(T+y)%7);return{short:e.format(n),long:t.format(n)}})},[F,T]),_e=K(()=>{let e=new Intl.DateTimeFormat(F,{month:"long"});return Array.from({length:12},(t,d)=>e.format(new Date(2024,d,1)))},[F]),xe=K(()=>new Intl.DateTimeFormat(F,{month:"long",year:"numeric"}),[F]),je=K(()=>new Intl.DateTimeFormat(F,{dateStyle:"full"}),[F]),Oe=K(()=>{if(te!=="dropdown")return[];let e=R.getFullYear(),t=fe??x?.getFullYear()??e-100,d=be??k?.getFullYear()??e+10;return d<t?[t]:Array.from({length:d-t+1},(l,y)=>t+y)},[te,fe,be,x,k,R]),M=r==="range"?A:null,$e=M&&M.from&&!M.to&&se&&se>M.from?se:null,H=M?.to??$e,He=p((e,t)=>{let d=!de(e,t),l=V(e),y=!1,n=!1,f=!1,s=!1;return r==="multiple"?y=(A??[]).some(G=>S(G,e)):r==="range"?(n=S(M?.from,e),f=S(H,e),y=n||f,s=!!(M?.from&&H&&e>M.from&&e<H)):y=S(A,e),{selected:y,today:S(e,R),outside:d,disabled:l,rangeStart:n,rangeEnd:f,inRange:s}},[r,A,M,H,V,R]),Ge=e=>{let t=v(g,e),d=tt(t,T,Ne),l=e===0,y=e===w-1;return N("div",{className:"flex flex-col",children:[N("div",{className:"mb-2 flex items-center justify-between",children:[o("button",{type:"button",onClick:We,disabled:!De,"aria-label":B?.previousMonth??"Previous month",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",I[D],m.nav,!De&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent",!l&&"invisible"),children:o(at,{className:m.icon})}),te==="dropdown"?N("div",{className:"flex items-center gap-1",children:[o("select",{"aria-label":B?.monthSelect??"Month",value:t.getMonth(),disabled:b,onChange:n=>h(new Date(t.getFullYear(),Number(n.target.value)-e,1)),className:c("rounded-md border border-gray-300 bg-white font-medium text-gray-900","dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100","focus:outline-none focus-visible:ring-2",I[D],m.select,b&&"cursor-not-allowed opacity-50"),children:_e.map((n,f)=>o("option",{value:f,children:n},n))}),o("select",{"aria-label":B?.yearSelect??"Year",value:t.getFullYear(),disabled:b,onChange:n=>h(new Date(Number(n.target.value),t.getMonth()-e,1)),className:c("rounded-md border border-gray-300 bg-white font-medium text-gray-900","dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100","focus:outline-none focus-visible:ring-2",I[D],m.select,b&&"cursor-not-allowed opacity-50"),children:Oe.map(n=>o("option",{value:n,children:n},n))})]}):o("div",{"aria-live":"polite",className:c("font-semibold text-gray-900 dark:text-gray-100",m.caption),children:xe.format(t)}),o("button",{type:"button",onClick:ze,disabled:!ve,"aria-label":B?.nextMonth??"Next month",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",I[D],m.nav,!ve&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent",!y&&"invisible"),children:o(rt,{className:m.icon})})]}),N("table",{role:"grid","aria-label":xe.format(t),className:"border-collapse",children:[o("thead",{children:N("tr",{children:[ge&&N("th",{scope:"col",className:c("font-normal text-gray-400 dark:text-gray-500",m.head),children:[o("span",{className:"sr-only",children:B?.weekNumber??"Week number"}),o("span",{"aria-hidden":"true",children:"#"})]}),Ke.map(n=>o("th",{scope:"col",abbr:n.long,className:c("font-medium uppercase text-gray-500 dark:text-gray-400",m.head),children:n.short},n.long))]})}),o("tbody",{children:d.map(n=>N("tr",{children:[ge&&o("td",{className:c("text-center align-middle text-gray-400 dark:text-gray-500",m.head),children:et(n[0])}),n.map(f=>{let s=He(f,t),G=X(f);if(s.outside&&!Se)return o("td",{className:"p-0"},G);let Qe=S(f,Le)&&!s.outside,ie=s.inRange||s.rangeStart&&!!H||s.rangeEnd&&!!M?.from;return o("td",{role:"presentation",className:c("p-0",ie&&lt[D],ie&&s.rangeStart&&"rounded-l-full",ie&&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:Qe?0:-1,disabled:b,"aria-selected":s.selected,"aria-disabled":s.disabled||void 0,"aria-current":s.today?"date":void 0,"aria-label":je.format(f),onClick:()=>{s.disabled||Ie(f)},onMouseEnter:()=>r==="range"&&pe(u(f)),onMouseLeave:()=>r==="range"&&pe(null),onFocus:()=>q(u(f)),className:c("inline-flex items-center justify-center rounded-full transition-colors","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 dark:focus-visible:ring-offset-gray-900",I[D],m.day,s.selected?ot[D]:s.inRange?c(st[D],"hover:bg-gray-200/60 dark:hover:bg-gray-600/60"):s.today?c(it[D],"hover:bg-gray-100 dark:hover:bg-gray-700"):c("text-gray-900 dark:text-gray-100","hover:bg-gray-100 dark:hover:bg-gray-700"),s.outside&&!s.selected&&"text-gray-400 dark:text-gray-500",s.disabled&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent"),children:me?me(f,s):f.getDate()})},G)})]},X(n[0])))})]})]},X(t))},Ue=p(()=>{h(R),q(R),V(R)||J(R)},[R,h,V,J]),qe=p(()=>{C(r==="multiple"?[]:r==="range"?{from:null,to:null}:null)},[r,C]),Je=!!ye||ae||re;return N("div",{ref:he,onKeyDown:Ve,className:c("inline-block bg-white dark:bg-gray-900",Fe&&"rounded-lg border border-gray-200 shadow-sm dark:border-gray-700",m.padding,b&&"opacity-60",Re),...Ye,children:[o("div",{className:c("flex flex-wrap",m.gap),children:Array.from({length:w},(e,t)=>Ge(t))}),Je&&N("div",{className:c("mt-3 flex items-center justify-between gap-2 border-t border-gray-200 pt-3 dark:border-gray-700",m.footer),children:[o("div",{className:"text-gray-600 dark:text-gray-400",children:ye}),(ae||re)&&N("div",{className:"flex items-center gap-2",children:[ae&&o("button",{type:"button",onClick:Ue,disabled:b,className:c("rounded-md px-2 py-1 font-medium transition-colors","text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2",I[D],b&&"cursor-not-allowed opacity-50"),children:B?.today??"Today"}),re&&o("button",{type:"button",onClick:qe,disabled:b,className:c("rounded-md px-2 py-1 font-medium transition-colors","text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2",I[D],b&&"cursor-not-allowed opacity-50"),children:B?.clear??"Clear"})]})]})]})}export{gt as Calendar};
1
+ "use client";import{useCallback as p,useEffect as Ze,useMemo as _,useRef as we,useState as X}from"react";import{cn as c}from"../../lib/cn.js";import{useUILabels as et}from"../../lib/i18n.js";import{jsx as o,jsxs as N}from"react/jsx-runtime";var tt=10080*60*1e3;function u(a){return new Date(a.getFullYear(),a.getMonth(),a.getDate())}function z(a){return new Date(a.getFullYear(),a.getMonth(),1)}function P(a,r){return new Date(a.getFullYear(),a.getMonth(),a.getDate()+r)}function v(a,r){return new Date(a.getFullYear(),a.getMonth()+r,1)}function ce(a){return new Date(a.getFullYear(),a.getMonth()+1,0).getDate()}function S(a,r){return!a||!r?!1:a.getFullYear()===r.getFullYear()&&a.getMonth()===r.getMonth()&&a.getDate()===r.getDate()}function ue(a,r){return a.getFullYear()===r.getFullYear()&&a.getMonth()===r.getMonth()}function A(a,r){return a.getFullYear()*12+a.getMonth()-(r.getFullYear()*12+r.getMonth())}function Z(a){let r=`${a.getMonth()+1}`.padStart(2,"0"),i=`${a.getDate()}`.padStart(2,"0");return`${a.getFullYear()}-${r}-${i}`}function at(a){let r=u(a);r.setDate(r.getDate()-(r.getDay()+6)%7+3);let i=new Date(r.getFullYear(),0,4);return i.setDate(i.getDate()-(i.getDay()+6)%7+3),1+Math.round((r.getTime()-i.getTime())/tt)}function Ce(a,r,i){return r&&a<u(r)?u(r):i&&a>u(i)?u(i):a}function rt(a,r,i){let V=z(a),j=(V.getDay()-r+7)%7,O=P(V,-j),$=i?6:Math.ceil((j+ce(a))/7);return Array.from({length:$},(te,q)=>Array.from({length:7},(ge,T)=>P(O,q*7+T)))}function nt({className:a}){return o("svg",{className:a,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:o("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function ot({className:a}){return o("svg",{className:a,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:o("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}var lt={sm:{day:"h-7 w-7 text-xs",head:"h-7 w-7 text-[10px]",caption:"text-xs",nav:"h-6 w-6",icon:"h-3 w-3",padding:"p-2",gap:"gap-3",footer:"text-xs",select:"text-xs py-0.5 pl-1 pr-5"},md:{day:"h-9 w-9 text-sm",head:"h-9 w-9 text-xs",caption:"text-sm",nav:"h-7 w-7",icon:"h-4 w-4",padding:"p-3",gap:"gap-4",footer:"text-sm",select:"text-sm py-1 pl-1.5 pr-6"},lg:{day:"h-11 w-11 text-base",head:"h-11 w-11 text-sm",caption:"text-base",nav:"h-9 w-9",icon:"h-5 w-5",padding:"p-4",gap:"gap-5",footer:"text-sm",select:"text-base py-1.5 pl-2 pr-7"}},st={primary:"bg-blue-600 text-white hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600",success:"bg-green-600 text-white hover:bg-green-700 dark:bg-green-500 dark:hover:bg-green-600",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 dark:bg-red-500 dark:hover:bg-red-600",info:"bg-cyan-600 text-white hover:bg-cyan-700 dark:bg-cyan-500 dark:hover:bg-cyan-600",neutral:"bg-gray-700 text-white hover:bg-gray-800 dark:bg-gray-500 dark:hover:bg-gray-400"},it={primary:"bg-blue-50 dark:bg-blue-900/30",success:"bg-green-50 dark:bg-green-900/30",warning:"bg-yellow-50 dark:bg-yellow-900/30",error:"bg-red-50 dark:bg-red-900/30",info:"bg-cyan-50 dark:bg-cyan-900/30",neutral:"bg-gray-100 dark:bg-gray-700/40"},dt={primary:"text-blue-900 dark:text-blue-100",success:"text-green-900 dark:text-green-100",warning:"text-yellow-900 dark:text-yellow-100",error:"text-red-900 dark:text-red-100",info:"text-cyan-900 dark:text-cyan-100",neutral:"text-gray-900 dark:text-gray-100"},ut={primary:"font-semibold text-blue-600 dark:text-blue-400",success:"font-semibold text-green-600 dark:text-green-400",warning:"font-semibold text-yellow-600 dark:text-yellow-400",error:"font-semibold text-red-600 dark:text-red-400",info:"font-semibold text-cyan-600 dark:text-cyan-400",neutral:"font-semibold text-gray-900 dark:text-gray-100"},W={primary:"focus-visible:ring-blue-500",success:"focus-visible:ring-green-500",warning:"focus-visible:ring-yellow-500",error:"focus-visible:ring-red-500",info:"focus-visible:ring-cyan-500",neutral:"focus-visible:ring-gray-500"};function ee(a,r){if(a==="multiple")return Array.isArray(r)?r.map(u):[];if(a==="range"){let i=r??null;return{from:i?.from?u(i.from):null,to:i?.to?u(i.to):null}}return r instanceof Date?u(r):null}function Me(a){return a?a instanceof Date?a:Array.isArray(a)?a[0]??null:a.from??a.to??null:null}function yt(a){let{mode:r="single",value:i,defaultValue:V,onChange:j,max:O,month:$,defaultMonth:te,onMonthChange:q,numberOfMonths:ge=1,weekStartsOn:T=0,locale:F,size:Se="md",color:D="primary",minDate:x,maxDate:k,disabledDates:H,disabled:b=!1,showOutsideDays:Ne=!0,showWeekNumbers:fe=!1,fixedWeeks:Fe=!1,captionLayout:ae="label",fromYear:be,toYear:ye,todayButton:re=!1,clearButton:ne=!1,footer:me,bordered:Re=!0,renderDay:he,labels:E,className:Ye,...Pe}=a,B=et(),m=lt[Se],w=Math.max(1,ge),R=_(()=>u(new Date),[]),oe=i!==void 0,[Te,Le]=X(()=>ee(r,V)),L=oe?ee(r,i):Te,le=$!==void 0,[Ae,Ee]=X(()=>z(te??Me(ee(r,V??i))??new Date)),g=le?z($):Ae,h=p(e=>{let t=z(e);le||Ee(t),q?.(t)},[le,q]),pe=we(null),se=we(!1),[I,J]=X(()=>{let e=Me(ee(r,V??i)),t=z(te??$??e??new Date),d=e&&ue(e,t)?e:ue(u(new Date),t)?u(new Date):t;return Ce(d,x,k)}),Be=v(g,w-1),Ie=A(I,g)>=0&&A(I,Be)<=0?I:g;Ze(()=>{if(!se.current)return;se.current=!1,pe.current?.querySelector(`[data-day="${Z(I)}"]:not([data-outside])`)?.focus()},[I,g]);let Y=p(e=>{let t=Ce(u(e),x,k);se.current=!0,J(t);let d=v(g,w-1);A(t,g)<0?h(t):A(t,d)>0&&h(v(t,-(w-1)))},[g,w,x,k,h]),K=p(e=>b||x&&e<u(x)||k&&e>u(k)?!0:typeof H=="function"?H(e):Array.isArray(H)?H.some(t=>S(t,e)):!1,[b,x,k,H]),[ie,De]=X(null),C=p(e=>{oe||Le(e),j?.(e)},[oe,j]),Q=p(e=>{let t=u(e);if(K(t))return;if(r==="multiple"){let l=L??[];if(l.some(n=>S(n,t))){C(l.filter(n=>!S(n,t)));return}if(O!==void 0&&l.length>=O)return;C([...l,t].sort((n,f)=>n.getTime()-f.getTime()));return}if(r==="range"){let l=L??{from:null,to:null};if(!l.from||l.to){C({from:t,to:null});return}C(t<l.from?{from:t,to:l.from}:{from:l.from,to:t});return}C(S(L,t)?null:t)},[r,L,O,C,K]),We=p(e=>{Q(e),J(u(e)),A(e,g)<0?h(e):A(e,v(g,w-1))>0&&h(v(e,-(w-1)))},[Q,g,w,h]),ve=!b&&(!x||A(g,z(x))>0),xe=!b&&(!k||A(v(g,w-1),z(k))<0),ze=p(()=>{h(v(g,-1))},[g,h]),Ve=p(()=>{h(v(g,1))},[g,h]),Ke=p(e=>{if(b)return;let t=I;switch(e.key){case"ArrowLeft":e.preventDefault(),Y(P(t,-1));break;case"ArrowRight":e.preventDefault(),Y(P(t,1));break;case"ArrowUp":e.preventDefault(),Y(P(t,-7));break;case"ArrowDown":e.preventDefault(),Y(P(t,7));break;case"Home":e.preventDefault(),Y(P(t,-((t.getDay()-T+7)%7)));break;case"End":e.preventDefault(),Y(P(t,6-(t.getDay()-T+7)%7));break;case"PageUp":{e.preventDefault();let d=e.shiftKey?-12:-1,l=v(t,d),y=Math.min(t.getDate(),ce(l));Y(new Date(l.getFullYear(),l.getMonth(),y));break}case"PageDown":{e.preventDefault();let d=e.shiftKey?12:1,l=v(t,d),y=Math.min(t.getDate(),ce(l));Y(new Date(l.getFullYear(),l.getMonth(),y));break}default:break}},[b,I,Y,T]),_e=_(()=>{let e=new Intl.DateTimeFormat(F,{weekday:"short"}),t=new Intl.DateTimeFormat(F,{weekday:"long"}),d=new Date(2024,0,7);return Array.from({length:7},(l,y)=>{let n=P(d,(T+y)%7);return{short:e.format(n),long:t.format(n)}})},[F,T]),je=_(()=>{let e=new Intl.DateTimeFormat(F,{month:"long"});return Array.from({length:12},(t,d)=>e.format(new Date(2024,d,1)))},[F]),ke=_(()=>new Intl.DateTimeFormat(F,{month:"long",year:"numeric"}),[F]),Oe=_(()=>new Intl.DateTimeFormat(F,{dateStyle:"full"}),[F]),$e=_(()=>{if(ae!=="dropdown")return[];let e=R.getFullYear(),t=be??x?.getFullYear()??e-100,d=ye??k?.getFullYear()??e+10;return d<t?[t]:Array.from({length:d-t+1},(l,y)=>t+y)},[ae,be,ye,x,k,R]),M=r==="range"?L:null,He=M&&M.from&&!M.to&&ie&&ie>M.from?ie:null,G=M?.to??He,Ge=p((e,t)=>{let d=!ue(e,t),l=K(e),y=!1,n=!1,f=!1,s=!1;return r==="multiple"?y=(L??[]).some(U=>S(U,e)):r==="range"?(n=S(M?.from,e),f=S(G,e),y=n||f,s=!!(M?.from&&G&&e>M.from&&e<G)):y=S(L,e),{selected:y,today:S(e,R),outside:d,disabled:l,rangeStart:n,rangeEnd:f,inRange:s}},[r,L,M,G,K,R]),Ue=e=>{let t=v(g,e),d=rt(t,T,Fe),l=e===0,y=e===w-1;return N("div",{className:"flex flex-col",children:[N("div",{className:"mb-2 flex items-center justify-between",children:[o("button",{type:"button",onClick:ze,disabled:!ve,"aria-label":E?.previousMonth??B.calendarPreviousMonth,className:c("inline-flex items-center justify-center rounded-md transition-colors","text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 dark:focus-visible:ring-offset-gray-900",W[D],m.nav,!ve&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent",!l&&"invisible"),children:o(nt,{className:m.icon})}),ae==="dropdown"?N("div",{className:"flex items-center gap-1",children:[o("select",{"aria-label":E?.monthSelect??B.calendarMonth,value:t.getMonth(),disabled:b,onChange:n=>h(new Date(t.getFullYear(),Number(n.target.value)-e,1)),className:c("rounded-md border border-gray-300 bg-white font-medium text-gray-900","dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100","focus:outline-none focus-visible:ring-2",W[D],m.select,b&&"cursor-not-allowed opacity-50"),children:je.map((n,f)=>o("option",{value:f,children:n},n))}),o("select",{"aria-label":E?.yearSelect??B.calendarYear,value:t.getFullYear(),disabled:b,onChange:n=>h(new Date(Number(n.target.value),t.getMonth()-e,1)),className:c("rounded-md border border-gray-300 bg-white font-medium text-gray-900","dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100","focus:outline-none focus-visible:ring-2",W[D],m.select,b&&"cursor-not-allowed opacity-50"),children:$e.map(n=>o("option",{value:n,children:n},n))})]}):o("div",{"aria-live":"polite",className:c("font-semibold text-gray-900 dark:text-gray-100",m.caption),children:ke.format(t)}),o("button",{type:"button",onClick:Ve,disabled:!xe,"aria-label":E?.nextMonth??B.calendarNextMonth,className:c("inline-flex items-center justify-center rounded-md transition-colors","text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 dark:focus-visible:ring-offset-gray-900",W[D],m.nav,!xe&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent",!y&&"invisible"),children:o(ot,{className:m.icon})})]}),N("table",{role:"grid","aria-label":ke.format(t),onKeyDown:Ke,className:"border-collapse",children:[o("thead",{children:N("tr",{children:[fe&&N("th",{scope:"col",className:c("font-normal text-gray-400 dark:text-gray-500",m.head),children:[o("span",{className:"sr-only",children:E?.weekNumber??B.calendarWeekNumber}),o("span",{"aria-hidden":"true",children:"#"})]}),_e.map(n=>o("th",{scope:"col",abbr:n.long,className:c("font-medium uppercase text-gray-500 dark:text-gray-400",m.head),children:n.short},n.long))]})}),o("tbody",{children:d.map(n=>N("tr",{children:[fe&&o("td",{className:c("text-center align-middle text-gray-400 dark:text-gray-500",m.head),children:at(n[0])}),n.map(f=>{let s=Ge(f,t),U=Z(f);if(s.outside&&!Ne)return o("td",{className:"p-0"},U);let Xe=S(f,Ie)&&!s.outside,de=s.inRange||s.rangeStart&&!!G||s.rangeEnd&&!!M?.from;return o("td",{role:"presentation",className:c("p-0",de&&it[D],de&&s.rangeStart&&"rounded-l-full",de&&s.rangeEnd&&"rounded-r-full"),children:o("button",{type:"button","data-day":U,"data-selected":s.selected||void 0,"data-today":s.today||void 0,"data-outside":s.outside||void 0,role:"gridcell",tabIndex:Xe?0:-1,disabled:b,"aria-selected":s.selected,"aria-disabled":s.disabled||void 0,"aria-current":s.today?"date":void 0,"aria-label":Oe.format(f),onClick:()=>{s.disabled||We(f)},onMouseEnter:()=>r==="range"&&De(u(f)),onMouseLeave:()=>r==="range"&&De(null),onFocus:()=>J(u(f)),className:c("inline-flex items-center justify-center rounded-full transition-colors","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 dark:focus-visible:ring-offset-gray-900",W[D],m.day,s.selected?st[D]:s.inRange?c(dt[D],"hover:bg-gray-200/60 dark:hover:bg-gray-600/60"):s.today?c(ut[D],"hover:bg-gray-100 dark:hover:bg-gray-700"):c("text-gray-900 dark:text-gray-100","hover:bg-gray-100 dark:hover:bg-gray-700"),s.outside&&!s.selected&&"text-gray-400 dark:text-gray-500",s.disabled&&"cursor-not-allowed opacity-40 hover:bg-transparent dark:hover:bg-transparent"),children:he?he(f,s):f.getDate()})},U)})]},Z(n[0])))})]})]},Z(t))},qe=p(()=>{h(R),J(R),K(R)||Q(R)},[R,h,K,Q]),Je=p(()=>{C(r==="multiple"?[]:r==="range"?{from:null,to:null}:null)},[r,C]),Qe=!!me||re||ne;return N("div",{ref:pe,className:c("inline-block bg-white dark:bg-gray-900",Re&&"rounded-lg border border-gray-200 shadow-sm dark:border-gray-700",m.padding,b&&"opacity-60",Ye),...Pe,children:[o("div",{className:c("flex flex-wrap",m.gap),children:Array.from({length:w},(e,t)=>Ue(t))}),Qe&&N("div",{className:c("mt-3 flex items-center justify-between gap-2 border-t border-gray-200 pt-3 dark:border-gray-700",m.footer),children:[o("div",{className:"text-gray-600 dark:text-gray-400",children:me}),(re||ne)&&N("div",{className:"flex items-center gap-2",children:[re&&o("button",{type:"button",onClick:qe,disabled:b,className:c("rounded-md px-2 py-1 font-medium transition-colors","text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2",W[D],b&&"cursor-not-allowed opacity-50"),children:E?.today??B.calendarToday}),ne&&o("button",{type:"button",onClick:Je,disabled:b,className:c("rounded-md px-2 py-1 font-medium transition-colors","text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700","focus:outline-none focus-visible:ring-2",W[D],b&&"cursor-not-allowed opacity-50"),children:E?.clear??B.calendarClear})]})]})]})}export{yt as Calendar};
@@ -1 +1 @@
1
- "use strict";"use client";var ee=Object.defineProperty;var fe=Object.getOwnPropertyDescriptor;var be=Object.getOwnPropertyNames;var pe=Object.prototype.hasOwnProperty;var ye=(l,a)=>{for(var r in a)ee(l,r,{get:a[r],enumerable:!0})},Ce=(l,a,r,o)=>{if(a&&typeof a=="object"||typeof a=="function")for(let c of be(a))!pe.call(l,c)&&c!==r&&ee(l,c,{get:()=>a[c],enumerable:!(o=fe(a,c))||o.enumerable});return l};var ke=l=>Ce(ee({},"__esModule",{value:!0}),l);var Pe={};ye(Pe,{CandlestickChart:()=>Re});module.exports=ke(Pe);var h=require("react"),ne=require("../../lib/i18n.cjs"),te=require("../chart/ChartAxis.cjs"),oe=require("../chart/ChartContainer.cjs"),le=require("../chart/ChartGrid.cjs"),ie=require("../chart/ChartLegend.cjs"),se=require("../chart/ChartTableView.cjs"),ue=require("../chart/ChartTooltip.cjs"),B=require("../chart/palette.cjs"),he=require("../chart/utils/cartesian.cjs"),L=require("../chart/utils/data.cjs"),Y=require("../chart/utils/format.cjs"),ce=require("../chart/utils/path.cjs"),ge=require("../chart/utils/scales.cjs"),me=require("../chart/utils/touch.cjs"),t=require("react/jsx-runtime"),xe=16,we=1.5,ve=(0,h.memo)(function({candles:a}){return(0,t.jsx)("g",{children:a.map(r=>(0,t.jsxs)("g",{children:[r.wick?(0,t.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,t.jsx)("path",{d:r.body,fill:r.hollow?"none":r.color,stroke:r.color,strokeWidth:r.hollow?1.5:0}):null]},r.key))})});function Le({width:l,height:a,data:r,candles:o,x:c,y,grid:R,size:I,candleSize:E,fillRising:P,palette:M,referenceLines:W,margin:D,tooltip:b,plotLabel:F,formatValue:p,formatX:O,onCandleClick:N}){let[x,S]=(0,h.useState)(null),g=x!==null&&x<o.length?x:null,C=(0,ne.useUILabels)(),n=(0,h.useMemo)(()=>{let e=o.flatMap(i=>i.high===null||i.low===null?[]:[i.low,i.high]),u=(0,he.buildCartesianGeometry)({width:l,height:a,data:r,x:c,y,bounds:e.length===0?null:[Math.min(...e),Math.max(...e)],margin:D,orientation:"vertical",placement:"band",formatValue:p,formatX:O,defaultIncludeZero:!1}),{valueScale:m,bandwidth:k,categoryPositions:z,innerWidth:q,innerHeight:G}=u,w=Math.min(E??xe,Math.max(1,k-2));return{rendered:o.map((i,_)=>{let T=z[_]+(k-w)/2,f=T+w/2,$=i.rising?M.up:M.down,H=i.high===null||i.low===null?null:{x:f,y1:m(i.high),y2:m(i.low)},A=null;if(i.open!==null&&i.close!==null){let v=m(i.open),K=m(i.close);A=(0,ce.buildBarPath)({x:T,y:Math.min(v,K),width:w,height:Math.max(we,Math.abs(K-v)),radius:0,round:"none"})}return{key:`${_}`,color:$,body:A,hollow:i.rising&&!P,wick:H,left:T,width:w}}),categoryPositions:z,categoryCenters:u.categoryCenters,bandwidth:k,categoryTicks:u.categoryTicks,valueTicks:u.valueTicks,valueScale:m,innerWidth:q,innerHeight:G,margin:u.margin}},[o,r,c,y,l,a,D,E,P,M,p,O]),U=(0,h.useCallback)(e=>{if(b===!1||o.length===0)return;let u=e.currentTarget.getBoundingClientRect(),m=e.clientX-u.left-n.margin.left;S((0,ge.nearestIndex)(n.categoryCenters,m))},[b,o.length,n.margin.left,n.categoryCenters]),j=(0,h.useCallback)(e=>{if(o.length===0)return;let u=o.length-1,m=g??0,k=e.key==="ArrowRight"?Math.min(u,m+1):e.key==="ArrowLeft"?Math.max(0,m-1):e.key==="Home"?0:e.key==="End"?u:e.key==="Escape"?null:void 0;k!==void 0&&(e.preventDefault(),S(k))},[o.length,g]),Z=(0,h.useCallback)(()=>{!N||g===null||N(o[g])},[N,g,o]),s=g===null?null:o[g];return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("svg",{width:l,height:a,role:"img","aria-label":F??o.map(e=>e.label).join(", "),tabIndex:0,className:`${me.CHART_TOUCH} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500`,onPointerMove:U,onPointerLeave:()=>S(null),onKeyDown:j,onBlur:()=>S(null),onClick:Z,children:[(0,t.jsxs)("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:[(0,t.jsx)(le.ChartGrid,{width:n.innerWidth,height:n.innerHeight,horizontal:R==="y"||R==="both"?n.valueTicks.map(e=>e.offset):void 0}),g!==null?(0,t.jsx)("rect",{x:n.categoryPositions[g],y:0,width:n.bandwidth,height:n.innerHeight,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,W?.map(e=>(0,t.jsxs)("g",{children:[(0,t.jsx)("line",{x1:0,y1:n.valueScale(e.value),x2:n.innerWidth,y2:n.valueScale(e.value),stroke:e.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:e.dashed===!1?void 0:"4 4"}),e.label?(0,t.jsx)("text",{x:n.innerWidth,y:n.valueScale(e.value)-4,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:e.label}):null]},`${e.value}-${e.label??""}`)),(0,t.jsx)(ve,{candles:n.rendered})]}),(0,t.jsx)("g",{transform:`translate(${n.margin.left}, ${n.margin.top+n.innerHeight})`,children:c.hidden?null:(0,t.jsx)(te.ChartAxis,{orientation:"bottom",ticks:n.categoryTicks,length:n.innerWidth,label:c.label,size:I})}),(0,t.jsx)("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:y?.hidden?null:(0,t.jsx)(te.ChartAxis,{orientation:"left",ticks:n.valueTicks,length:n.innerHeight,showLine:!1,label:y?.label,size:I})})]}),s&&g!==null&&b!==!1?(0,t.jsx)(ue.ChartTooltip,{x:n.margin.left+n.categoryCenters[g],y:n.margin.top+(s.high===null?n.innerHeight/2:n.valueScale(s.high)),containerWidth:l,children:typeof b=="function"?b(s):(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:s.label}),(0,t.jsx)("dl",{className:"grid grid-cols-[auto_auto] gap-x-3 gap-y-0.5",children:[[C.chartOpen,s.open],[C.chartHigh,s.high],[C.chartLow,s.low],[C.chartClose,s.close]].map(([e,u])=>(0,t.jsxs)("div",{className:"contents",children:[(0,t.jsx)("dt",{className:"text-gray-500 dark:text-gray-400",children:e}),(0,t.jsx)("dd",{className:"justify-self-end font-medium text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:u===null?"\u2014":p(u)})]},e))}),s.change===null?null:(0,t.jsxs)("div",{className:"flex items-center gap-2 border-t border-gray-200 pt-1 dark:border-gray-700",children:[(0,t.jsx)("span",{className:"text-gray-500 dark:text-gray-400",children:s.rising?C.chartRise:C.chartFall}),(0,t.jsxs)("span",{className:"[font-variant-numeric:tabular-nums] font-semibold text-gray-900 dark:text-gray-100",children:[s.change>0?"+":"",p(s.change)]})]})]})}):null]})}function Re({data:l,x:a,y:r,open:o,high:c,low:y,close:R,candleSize:I,fillRising:E=!1,colors:P,referenceLines:M,height:W=300,width:D,size:b="md",grid:F="y",legend:p,tooltip:O=!0,tableView:N=!1,title:x,description:S,loading:g=!1,emptyState:C,error:n=!1,errorState:U,onRetry:j,actions:Z,margin:s,locale:e,plotLabel:u,openLabel:m,highLabel:k,lowLabel:z,closeLabel:q,riseLabel:G,fallLabel:w,format:J,onCandleClick:i,className:_,...T}){let f=(0,ne.useUILabels)(),$=(0,h.useMemo)(()=>r?.format??J??(d=>(0,Y.formatAuto)(d,e)),[r?.format,J,e]),H=(0,h.useMemo)(()=>a.format??(d=>(0,Y.formatXValue)(d,e)),[a.format,e]),A=(0,h.useMemo)(()=>l.map((d,Q)=>{let ae=(0,L.readXValue)(d,a.key,Q),V=(0,L.readNumber)(d,o),X=(0,L.readNumber)(d,R);return{index:Q,x:ae,label:H(ae,Q),open:V,high:(0,L.readNumber)(d,c),low:(0,L.readNumber)(d,y),close:X,change:V===null||X===null?null:X-V,rising:V===null||X===null?!0:X>=V,datum:d}}),[l,a.key,o,c,y,R,H]),v=(0,h.useMemo)(()=>({up:P?.up??B.CHART_UP_COLOR,down:P?.down??B.CHART_DOWN_COLOR}),[P]),K=(0,h.useMemo)(()=>[{key:"up",label:G??f.chartRise,color:v.up,marker:"rect"},{key:"down",label:w??f.chartFall,color:v.down,marker:"rect"}],[v,G,w,f.chartRise,f.chartFall]),de=p===void 0?!0:p!==!1,re=typeof p=="string"?p:"bottom";return(0,t.jsx)(oe.ChartContainer,{title:x,description:S,height:W,width:D,size:b,loading:g,empty:A.length===0,emptyState:C,error:n,errorState:U,onRetry:j,actions:Z,tableView:N,legendPosition:re,legend:de?(0,t.jsx)(ie.ChartLegend,{items:K,position:re,marker:"rect",size:b}):void 0,table:N?(0,t.jsx)(se.ChartTableView,{data:l,series:[{key:o,label:m??f.chartOpen},{key:c,label:k??f.chartHigh},{key:y,label:z??f.chartLow},{key:R,label:q??f.chartClose}],xKey:a.key,xLabel:a.label??a.key,formatX:H,formatValue:$,caption:typeof x=="string"?x:void 0}):void 0,className:_,...T,children:({width:d})=>(0,t.jsx)(Le,{width:d,height:W,data:l,candles:A,x:a,y:r,grid:F,size:b,candleSize:I,fillRising:E,palette:v,referenceLines:M,margin:s,tooltip:O,plotLabel:u,formatValue:$,formatX:H,onCandleClick:i})})}0&&(module.exports={CandlestickChart});
1
+ "use strict";"use client";var ee=Object.defineProperty;var be=Object.getOwnPropertyDescriptor;var pe=Object.getOwnPropertyNames;var Ce=Object.prototype.hasOwnProperty;var ye=(l,a)=>{for(var n in a)ee(l,n,{get:a[n],enumerable:!0})},ke=(l,a,n,o)=>{if(a&&typeof a=="object"||typeof a=="function")for(let h of pe(a))!Ce.call(l,h)&&h!==n&&ee(l,h,{get:()=>a[h],enumerable:!(o=be(a,h))||o.enumerable});return l};var xe=l=>ke(ee({},"__esModule",{value:!0}),l);var Ne={};ye(Ne,{CandlestickChart:()=>Pe});module.exports=xe(Ne);var u=require("react"),re=require("../../lib/i18n.cjs"),te=require("../chart/ChartAxis.cjs"),oe=require("../chart/ChartContainer.cjs"),le=require("../chart/ChartGrid.cjs"),ie=require("../chart/ChartLegend.cjs"),se=require("../chart/ChartTableView.cjs"),ue=require("../chart/ChartTooltip.cjs"),Y=require("../chart/palette.cjs"),he=require("../chart/utils/cartesian.cjs"),L=require("../chart/utils/data.cjs"),F=require("../chart/utils/format.cjs"),ge=require("../chart/utils/keyboard.cjs"),ce=require("../chart/utils/path.cjs"),me=require("../chart/utils/scales.cjs"),de=require("../chart/utils/touch.cjs"),e=require("react/jsx-runtime"),ve=16,we=1.5,Le=(0,u.memo)(function({candles:a}){return(0,e.jsx)("g",{children:a.map(n=>(0,e.jsxs)("g",{children:[n.wick?(0,e.jsx)("line",{x1:n.wick.x,y1:n.wick.y1,x2:n.wick.x,y2:n.wick.y2,stroke:n.color,strokeWidth:1.5}):null,n.body?(0,e.jsx)("path",{d:n.body,fill:n.hollow?"none":n.color,stroke:n.color,strokeWidth:n.hollow?1.5:0}):null]},n.key))})});function Re({width:l,height:a,data:n,candles:o,x:h,y:C,grid:R,size:W,candleSize:D,fillRising:P,palette:T,referenceLines:O,margin:z,tooltip:f,plotLabel:U,formatValue:b,formatX:E,onCandleClick:y}){let[x,N]=(0,u.useState)(null),g=x!==null&&x<o.length?x:null,k=(0,re.useUILabels)(),t=(0,u.useMemo)(()=>{let r=o.flatMap(i=>i.high===null||i.low===null?[]:[i.low,i.high]),c=(0,he.buildCartesianGeometry)({width:l,height:a,data:n,x:h,y:C,bounds:r.length===0?null:[Math.min(...r),Math.max(...r)],margin:z,orientation:"vertical",placement:"band",formatValue:b,formatX:E,defaultIncludeZero:!1}),{valueScale:p,bandwidth:M,categoryPositions:G,innerWidth:q,innerHeight:_}=c,v=Math.min(D??ve,Math.max(1,M-2));return{rendered:o.map((i,$)=>{let V=G[$]+(M-v)/2,d=V+v/2,K=i.rising?T.up:T.down,S=i.high===null||i.low===null?null:{x:d,y1:p(i.high),y2:p(i.low)},X=null;if(i.open!==null&&i.close!==null){let w=p(i.open),B=p(i.close);X=(0,ce.buildBarPath)({x:V,y:Math.min(w,B),width:v,height:Math.max(we,Math.abs(B-w)),radius:0,round:"none"})}return{key:`${$}`,color:K,body:X,hollow:i.rising&&!P,wick:S,left:V,width:v}}),categoryPositions:G,categoryCenters:c.categoryCenters,bandwidth:M,categoryTicks:c.categoryTicks,valueTicks:c.valueTicks,valueScale:p,innerWidth:q,innerHeight:_,margin:c.margin}},[o,n,h,C,l,a,z,D,P,T,b,E]),j=(0,u.useCallback)(r=>{if(f===!1||o.length===0)return;let c=r.currentTarget.getBoundingClientRect(),p=r.clientX-c.left-t.margin.left;N((0,me.nearestIndex)(t.categoryCenters,p))},[f,o.length,t.margin.left,t.categoryCenters]),H=(0,u.useCallback)(()=>{!y||g===null||y(o[g])},[y,g,o]),Z=(0,u.useCallback)(r=>(0,ge.handleChartKeyDown)(r,{count:o.length,current:g,axis:"x",onMove:N,pick:y?H:null}),[o.length,g,y,H]),s=g===null?null:o[g];return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("svg",{width:l,height:a,role:"img","aria-label":U??o.map(r=>r.label).join(", "),tabIndex:0,className:`${de.CHART_TOUCH} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500`,onPointerMove:j,onPointerLeave:()=>N(null),onKeyDown:Z,onBlur:()=>N(null),onClick:H,children:[(0,e.jsxs)("g",{transform:`translate(${t.margin.left}, ${t.margin.top})`,children:[(0,e.jsx)(le.ChartGrid,{width:t.innerWidth,height:t.innerHeight,horizontal:R==="y"||R==="both"?t.valueTicks.map(r=>r.offset):void 0}),g!==null?(0,e.jsx)("rect",{x:t.categoryPositions[g],y:0,width:t.bandwidth,height:t.innerHeight,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,O?.map(r=>(0,e.jsxs)("g",{children:[(0,e.jsx)("line",{x1:0,y1:t.valueScale(r.value),x2:t.innerWidth,y2:t.valueScale(r.value),stroke:r.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:r.dashed===!1?void 0:"4 4"}),r.label?(0,e.jsx)("text",{x:t.innerWidth,y:t.valueScale(r.value)-4,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:r.label}):null]},`${r.value}-${r.label??""}`)),(0,e.jsx)(Le,{candles:t.rendered})]}),(0,e.jsx)("g",{transform:`translate(${t.margin.left}, ${t.margin.top+t.innerHeight})`,children:h.hidden?null:(0,e.jsx)(te.ChartAxis,{orientation:"bottom",ticks:t.categoryTicks,length:t.innerWidth,label:h.label,size:W})}),(0,e.jsx)("g",{transform:`translate(${t.margin.left}, ${t.margin.top})`,children:C?.hidden?null:(0,e.jsx)(te.ChartAxis,{orientation:"left",ticks:t.valueTicks,length:t.innerHeight,showLine:!1,label:C?.label,size:W})})]}),s&&g!==null&&f!==!1?(0,e.jsx)(ue.ChartTooltip,{x:t.margin.left+t.categoryCenters[g],y:t.margin.top+(s.high===null?t.innerHeight/2:t.valueScale(s.high)),containerWidth:l,children:typeof f=="function"?f(s):(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:s.label}),(0,e.jsx)("dl",{className:"grid grid-cols-[auto_auto] gap-x-3 gap-y-0.5",children:[[k.chartOpen,s.open],[k.chartHigh,s.high],[k.chartLow,s.low],[k.chartClose,s.close]].map(([r,c])=>(0,e.jsxs)("div",{className:"contents",children:[(0,e.jsx)("dt",{className:"text-gray-500 dark:text-gray-400",children:r}),(0,e.jsx)("dd",{className:"justify-self-end font-medium text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:c===null?"\u2014":b(c)})]},r))}),s.change===null?null:(0,e.jsxs)("div",{className:"flex items-center gap-2 border-t border-gray-200 pt-1 dark:border-gray-700",children:[(0,e.jsx)("span",{className:"text-gray-500 dark:text-gray-400",children:s.rising?k.chartRise:k.chartFall}),(0,e.jsxs)("span",{className:"[font-variant-numeric:tabular-nums] font-semibold text-gray-900 dark:text-gray-100",children:[s.change>0?"+":"",b(s.change)]})]})]})}):null]})}function Pe({data:l,x:a,y:n,open:o,high:h,low:C,close:R,candleSize:W,fillRising:D=!1,colors:P,referenceLines:T,height:O=300,width:z,size:f="md",grid:U="y",legend:b,tooltip:E=!0,tableView:y=!1,title:x,description:N,loading:g=!1,emptyState:k,error:t=!1,errorState:j,onRetry:H,actions:Z,margin:s,locale:r,plotLabel:c,openLabel:p,highLabel:M,lowLabel:G,closeLabel:q,riseLabel:_,fallLabel:v,format:J,onCandleClick:i,className:$,...V}){let d=(0,re.useUILabels)(),K=(0,u.useMemo)(()=>n?.format??J??(m=>(0,F.formatAuto)(m,r)),[n?.format,J,r]),S=(0,u.useMemo)(()=>a.format??(m=>(0,F.formatXValue)(m,r)),[a.format,r]),X=(0,u.useMemo)(()=>l.map((m,Q)=>{let ae=(0,L.readXValue)(m,a.key,Q),A=(0,L.readNumber)(m,o),I=(0,L.readNumber)(m,R);return{index:Q,x:ae,label:S(ae,Q),open:A,high:(0,L.readNumber)(m,h),low:(0,L.readNumber)(m,C),close:I,change:A===null||I===null?null:I-A,rising:A===null||I===null?!0:I>=A,datum:m}}),[l,a.key,o,h,C,R,S]),w=(0,u.useMemo)(()=>({up:P?.up??Y.CHART_UP_COLOR,down:P?.down??Y.CHART_DOWN_COLOR}),[P]),B=(0,u.useMemo)(()=>[{key:"up",label:_??d.chartRise,color:w.up,marker:"rect"},{key:"down",label:v??d.chartFall,color:w.down,marker:"rect"}],[w,_,v,d.chartRise,d.chartFall]),fe=b===void 0?!0:b!==!1,ne=typeof b=="string"?b:"bottom";return(0,e.jsx)(oe.ChartContainer,{title:x,description:N,height:O,width:z,size:f,loading:g,empty:X.length===0,emptyState:k,error:t,errorState:j,onRetry:H,actions:Z,tableView:y,legendPosition:ne,legend:fe?(0,e.jsx)(ie.ChartLegend,{items:B,position:ne,marker:"rect",size:f}):void 0,table:y?(0,e.jsx)(se.ChartTableView,{data:l,series:[{key:o,label:p??d.chartOpen},{key:h,label:M??d.chartHigh},{key:C,label:G??d.chartLow},{key:R,label:q??d.chartClose}],xKey:a.key,xLabel:a.label??a.key,formatX:S,formatValue:K,caption:typeof x=="string"?x:void 0}):void 0,className:$,...V,children:({width:m})=>(0,e.jsx)(Re,{width:m,height:O,data:l,candles:X,x:a,y:n,grid:U,size:f,candleSize:W,fillRising:D,palette:w,referenceLines:T,margin:s,tooltip:E,plotLabel:c,formatValue:K,formatX:S,onCandleClick:i})})}0&&(module.exports={CandlestickChart});
@@ -1 +1 @@
1
- "use client";import{memo as oe,useCallback as Q,useMemo as H,useState as le}from"react";import{useUILabels as re}from"../../lib/i18n.js";import{ChartAxis as ne}from"../chart/ChartAxis.js";import{ChartContainer as ie}from"../chart/ChartContainer.js";import{ChartGrid as se}from"../chart/ChartGrid.js";import{ChartLegend as ue}from"../chart/ChartLegend.js";import{ChartTableView as he}from"../chart/ChartTableView.js";import{ChartTooltip as ce}from"../chart/ChartTooltip.js";import{CHART_DOWN_COLOR as ge,CHART_UP_COLOR as me}from"../chart/palette.js";import{buildCartesianGeometry as de}from"../chart/utils/cartesian.js";import{readNumber as B,readXValue as fe}from"../chart/utils/data.js";import{formatAuto as be,formatXValue as pe}from"../chart/utils/format.js";import{buildBarPath as ye}from"../chart/utils/path.js";import{nearestIndex as Ce}from"../chart/utils/scales.js";import{CHART_TOUCH as ke}from"../chart/utils/touch.js";import{Fragment as Re,jsx as n,jsxs as b}from"react/jsx-runtime";var xe=16,we=1.5,ve=oe(function({candles:s}){return n("g",{children:s.map(r=>b("g",{children:[r.wick?n("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?n("path",{d:r.body,fill:r.hollow?"none":r.color,stroke:r.color,strokeWidth:r.hollow?1.5:0}):null]},r.key))})});function Le({width:g,height:s,data:r,candles:a,x:p,y,grid:L,size:I,candleSize:E,fillRising:R,palette:M,referenceLines:W,margin:D,tooltip:d,plotLabel:Y,formatValue:f,formatX:O,onCandleClick:P}){let[x,N]=le(null),u=x!==null&&x<a.length?x:null,C=re(),t=H(()=>{let e=a.flatMap(o=>o.high===null||o.low===null?[]:[o.low,o.high]),i=de({width:g,height:s,data:r,x:p,y,bounds:e.length===0?null:[Math.min(...e),Math.max(...e)],margin:D,orientation:"vertical",placement:"band",formatValue:f,formatX:O,defaultIncludeZero:!1}),{valueScale:h,bandwidth:k,categoryPositions:z,innerWidth:Z,innerHeight:G}=i,w=Math.min(E??xe,Math.max(1,k-2));return{rendered:a.map((o,_)=>{let T=z[_]+(k-w)/2,m=T+w/2,$=o.rising?M.up:M.down,S=o.high===null||o.low===null?null:{x:m,y1:h(o.high),y2:h(o.low)},A=null;if(o.open!==null&&o.close!==null){let v=h(o.open),K=h(o.close);A=ye({x:T,y:Math.min(v,K),width:w,height:Math.max(we,Math.abs(K-v)),radius:0,round:"none"})}return{key:`${_}`,color:$,body:A,hollow:o.rising&&!R,wick:S,left:T,width:w}}),categoryPositions:z,categoryCenters:i.categoryCenters,bandwidth:k,categoryTicks:i.categoryTicks,valueTicks:i.valueTicks,valueScale:h,innerWidth:Z,innerHeight:G,margin:i.margin}},[a,r,p,y,g,s,D,E,R,M,f,O]),F=Q(e=>{if(d===!1||a.length===0)return;let i=e.currentTarget.getBoundingClientRect(),h=e.clientX-i.left-t.margin.left;N(Ce(t.categoryCenters,h))},[d,a.length,t.margin.left,t.categoryCenters]),U=Q(e=>{if(a.length===0)return;let i=a.length-1,h=u??0,k=e.key==="ArrowRight"?Math.min(i,h+1):e.key==="ArrowLeft"?Math.max(0,h-1):e.key==="Home"?0:e.key==="End"?i:e.key==="Escape"?null:void 0;k!==void 0&&(e.preventDefault(),N(k))},[a.length,u]),j=Q(()=>{!P||u===null||P(a[u])},[P,u,a]),l=u===null?null:a[u];return b(Re,{children:[b("svg",{width:g,height:s,role:"img","aria-label":Y??a.map(e=>e.label).join(", "),tabIndex:0,className:`${ke} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500`,onPointerMove:F,onPointerLeave:()=>N(null),onKeyDown:U,onBlur:()=>N(null),onClick:j,children:[b("g",{transform:`translate(${t.margin.left}, ${t.margin.top})`,children:[n(se,{width:t.innerWidth,height:t.innerHeight,horizontal:L==="y"||L==="both"?t.valueTicks.map(e=>e.offset):void 0}),u!==null?n("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,W?.map(e=>b("g",{children:[n("line",{x1:0,y1:t.valueScale(e.value),x2:t.innerWidth,y2:t.valueScale(e.value),stroke:e.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:e.dashed===!1?void 0:"4 4"}),e.label?n("text",{x:t.innerWidth,y:t.valueScale(e.value)-4,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:e.label}):null]},`${e.value}-${e.label??""}`)),n(ve,{candles:t.rendered})]}),n("g",{transform:`translate(${t.margin.left}, ${t.margin.top+t.innerHeight})`,children:p.hidden?null:n(ne,{orientation:"bottom",ticks:t.categoryTicks,length:t.innerWidth,label:p.label,size:I})}),n("g",{transform:`translate(${t.margin.left}, ${t.margin.top})`,children:y?.hidden?null:n(ne,{orientation:"left",ticks:t.valueTicks,length:t.innerHeight,showLine:!1,label:y?.label,size:I})})]}),l&&u!==null&&d!==!1?n(ce,{x:t.margin.left+t.categoryCenters[u],y:t.margin.top+(l.high===null?t.innerHeight/2:t.valueScale(l.high)),containerWidth:g,children:typeof d=="function"?d(l):b("div",{className:"flex flex-col gap-1",children:[n("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:l.label}),n("dl",{className:"grid grid-cols-[auto_auto] gap-x-3 gap-y-0.5",children:[[C.chartOpen,l.open],[C.chartHigh,l.high],[C.chartLow,l.low],[C.chartClose,l.close]].map(([e,i])=>b("div",{className:"contents",children:[n("dt",{className:"text-gray-500 dark:text-gray-400",children:e}),n("dd",{className:"justify-self-end font-medium text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:i===null?"\u2014":f(i)})]},e))}),l.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:l.rising?C.chartRise:C.chartFall}),b("span",{className:"[font-variant-numeric:tabular-nums] font-semibold text-gray-900 dark:text-gray-100",children:[l.change>0?"+":"",f(l.change)]})]})]})}):null]})}function Ge({data:g,x:s,y:r,open:a,high:p,low:y,close:L,candleSize:I,fillRising:E=!1,colors:R,referenceLines:M,height:W=300,width:D,size:d="md",grid:Y="y",legend:f,tooltip:O=!0,tableView:P=!1,title:x,description:N,loading:u=!1,emptyState:C,error:t=!1,errorState:F,onRetry:U,actions:j,margin:l,locale:e,plotLabel:i,openLabel:h,highLabel:k,lowLabel:z,closeLabel:Z,riseLabel:G,fallLabel:w,format:q,onCandleClick:o,className:_,...T}){let m=re(),$=H(()=>r?.format??q??(c=>be(c,e)),[r?.format,q,e]),S=H(()=>s.format??(c=>pe(c,e)),[s.format,e]),A=H(()=>g.map((c,J)=>{let te=fe(c,s.key,J),V=B(c,a),X=B(c,L);return{index:J,x:te,label:S(te,J),open:V,high:B(c,p),low:B(c,y),close:X,change:V===null||X===null?null:X-V,rising:V===null||X===null?!0:X>=V,datum:c}}),[g,s.key,a,p,y,L,S]),v=H(()=>({up:R?.up??me,down:R?.down??ge}),[R]),K=H(()=>[{key:"up",label:G??m.chartRise,color:v.up,marker:"rect"},{key:"down",label:w??m.chartFall,color:v.down,marker:"rect"}],[v,G,w,m.chartRise,m.chartFall]),ae=f===void 0?!0:f!==!1,ee=typeof f=="string"?f:"bottom";return n(ie,{title:x,description:N,height:W,width:D,size:d,loading:u,empty:A.length===0,emptyState:C,error:t,errorState:F,onRetry:U,actions:j,tableView:P,legendPosition:ee,legend:ae?n(ue,{items:K,position:ee,marker:"rect",size:d}):void 0,table:P?n(he,{data:g,series:[{key:a,label:h??m.chartOpen},{key:p,label:k??m.chartHigh},{key:y,label:z??m.chartLow},{key:L,label:Z??m.chartClose}],xKey:s.key,xLabel:s.label??s.key,formatX:S,formatValue:$,caption:typeof x=="string"?x:void 0}):void 0,className:_,...T,children:({width:c})=>n(Le,{width:c,height:W,data:g,candles:A,x:s,y:r,grid:Y,size:d,candleSize:I,fillRising:E,palette:v,referenceLines:M,margin:l,tooltip:O,plotLabel:i,formatValue:$,formatX:S,onCandleClick:o})})}export{Ge as CandlestickChart};
1
+ "use client";import{memo as oe,useCallback as Q,useMemo as S,useState as le}from"react";import{useUILabels as ne}from"../../lib/i18n.js";import{ChartAxis as re}from"../chart/ChartAxis.js";import{ChartContainer as ie}from"../chart/ChartContainer.js";import{ChartGrid as se}from"../chart/ChartGrid.js";import{ChartLegend as ue}from"../chart/ChartLegend.js";import{ChartTableView as he}from"../chart/ChartTableView.js";import{ChartTooltip as ge}from"../chart/ChartTooltip.js";import{CHART_DOWN_COLOR as ce,CHART_UP_COLOR as me}from"../chart/palette.js";import{buildCartesianGeometry as de}from"../chart/utils/cartesian.js";import{readNumber as Y,readXValue as fe}from"../chart/utils/data.js";import{formatAuto as be,formatXValue as pe}from"../chart/utils/format.js";import{handleChartKeyDown as Ce}from"../chart/utils/keyboard.js";import{buildBarPath as ye}from"../chart/utils/path.js";import{nearestIndex as ke}from"../chart/utils/scales.js";import{CHART_TOUCH as xe}from"../chart/utils/touch.js";import{Fragment as Pe,jsx as r,jsxs as b}from"react/jsx-runtime";var ve=16,we=1.5,Le=oe(function({candles:i}){return r("g",{children:i.map(n=>b("g",{children:[n.wick?r("line",{x1:n.wick.x,y1:n.wick.y1,x2:n.wick.x,y2:n.wick.y2,stroke:n.color,strokeWidth:1.5}):null,n.body?r("path",{d:n.body,fill:n.hollow?"none":n.color,stroke:n.color,strokeWidth:n.hollow?1.5:0}):null]},n.key))})});function Re({width:g,height:i,data:n,candles:o,x:p,y:C,grid:L,size:W,candleSize:D,fillRising:R,palette:T,referenceLines:O,margin:z,tooltip:m,plotLabel:F,formatValue:d,formatX:E,onCandleClick:y}){let[x,P]=le(null),s=x!==null&&x<o.length?x:null,k=ne(),e=S(()=>{let t=o.flatMap(a=>a.high===null||a.low===null?[]:[a.low,a.high]),u=de({width:g,height:i,data:n,x:p,y:C,bounds:t.length===0?null:[Math.min(...t),Math.max(...t)],margin:z,orientation:"vertical",placement:"band",formatValue:d,formatX:E,defaultIncludeZero:!1}),{valueScale:f,bandwidth:M,categoryPositions:G,innerWidth:Z,innerHeight:_}=u,v=Math.min(D??ve,Math.max(1,M-2));return{rendered:o.map((a,$)=>{let V=G[$]+(M-v)/2,c=V+v/2,K=a.rising?T.up:T.down,N=a.high===null||a.low===null?null:{x:c,y1:f(a.high),y2:f(a.low)},X=null;if(a.open!==null&&a.close!==null){let w=f(a.open),B=f(a.close);X=ye({x:V,y:Math.min(w,B),width:v,height:Math.max(we,Math.abs(B-w)),radius:0,round:"none"})}return{key:`${$}`,color:K,body:X,hollow:a.rising&&!R,wick:N,left:V,width:v}}),categoryPositions:G,categoryCenters:u.categoryCenters,bandwidth:M,categoryTicks:u.categoryTicks,valueTicks:u.valueTicks,valueScale:f,innerWidth:Z,innerHeight:_,margin:u.margin}},[o,n,p,C,g,i,z,D,R,T,d,E]),U=Q(t=>{if(m===!1||o.length===0)return;let u=t.currentTarget.getBoundingClientRect(),f=t.clientX-u.left-e.margin.left;P(ke(e.categoryCenters,f))},[m,o.length,e.margin.left,e.categoryCenters]),H=Q(()=>{!y||s===null||y(o[s])},[y,s,o]),j=Q(t=>Ce(t,{count:o.length,current:s,axis:"x",onMove:P,pick:y?H:null}),[o.length,s,y,H]),l=s===null?null:o[s];return b(Pe,{children:[b("svg",{width:g,height:i,role:"img","aria-label":F??o.map(t=>t.label).join(", "),tabIndex:0,className:`${xe} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500`,onPointerMove:U,onPointerLeave:()=>P(null),onKeyDown:j,onBlur:()=>P(null),onClick:H,children:[b("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[r(se,{width:e.innerWidth,height:e.innerHeight,horizontal:L==="y"||L==="both"?e.valueTicks.map(t=>t.offset):void 0}),s!==null?r("rect",{x:e.categoryPositions[s],y:0,width:e.bandwidth,height:e.innerHeight,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,O?.map(t=>b("g",{children:[r("line",{x1:0,y1:e.valueScale(t.value),x2:e.innerWidth,y2:e.valueScale(t.value),stroke:t.color??"var(--color-chart-muted)",strokeWidth:1,strokeDasharray:t.dashed===!1?void 0:"4 4"}),t.label?r("text",{x:e.innerWidth,y:e.valueScale(t.value)-4,textAnchor:"end",className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:t.label}):null]},`${t.value}-${t.label??""}`)),r(Le,{candles:e.rendered})]}),r("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:p.hidden?null:r(re,{orientation:"bottom",ticks:e.categoryTicks,length:e.innerWidth,label:p.label,size:W})}),r("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:C?.hidden?null:r(re,{orientation:"left",ticks:e.valueTicks,length:e.innerHeight,showLine:!1,label:C?.label,size:W})})]}),l&&s!==null&&m!==!1?r(ge,{x:e.margin.left+e.categoryCenters[s],y:e.margin.top+(l.high===null?e.innerHeight/2:e.valueScale(l.high)),containerWidth:g,children:typeof m=="function"?m(l):b("div",{className:"flex flex-col gap-1",children:[r("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:l.label}),r("dl",{className:"grid grid-cols-[auto_auto] gap-x-3 gap-y-0.5",children:[[k.chartOpen,l.open],[k.chartHigh,l.high],[k.chartLow,l.low],[k.chartClose,l.close]].map(([t,u])=>b("div",{className:"contents",children:[r("dt",{className:"text-gray-500 dark:text-gray-400",children:t}),r("dd",{className:"justify-self-end font-medium text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:u===null?"\u2014":d(u)})]},t))}),l.change===null?null:b("div",{className:"flex items-center gap-2 border-t border-gray-200 pt-1 dark:border-gray-700",children:[r("span",{className:"text-gray-500 dark:text-gray-400",children:l.rising?k.chartRise:k.chartFall}),b("span",{className:"[font-variant-numeric:tabular-nums] font-semibold text-gray-900 dark:text-gray-100",children:[l.change>0?"+":"",d(l.change)]})]})]})}):null]})}function $e({data:g,x:i,y:n,open:o,high:p,low:C,close:L,candleSize:W,fillRising:D=!1,colors:R,referenceLines:T,height:O=300,width:z,size:m="md",grid:F="y",legend:d,tooltip:E=!0,tableView:y=!1,title:x,description:P,loading:s=!1,emptyState:k,error:e=!1,errorState:U,onRetry:H,actions:j,margin:l,locale:t,plotLabel:u,openLabel:f,highLabel:M,lowLabel:G,closeLabel:Z,riseLabel:_,fallLabel:v,format:q,onCandleClick:a,className:$,...V}){let c=ne(),K=S(()=>n?.format??q??(h=>be(h,t)),[n?.format,q,t]),N=S(()=>i.format??(h=>pe(h,t)),[i.format,t]),X=S(()=>g.map((h,J)=>{let te=fe(h,i.key,J),A=Y(h,o),I=Y(h,L);return{index:J,x:te,label:N(te,J),open:A,high:Y(h,p),low:Y(h,C),close:I,change:A===null||I===null?null:I-A,rising:A===null||I===null?!0:I>=A,datum:h}}),[g,i.key,o,p,C,L,N]),w=S(()=>({up:R?.up??me,down:R?.down??ce}),[R]),B=S(()=>[{key:"up",label:_??c.chartRise,color:w.up,marker:"rect"},{key:"down",label:v??c.chartFall,color:w.down,marker:"rect"}],[w,_,v,c.chartRise,c.chartFall]),ae=d===void 0?!0:d!==!1,ee=typeof d=="string"?d:"bottom";return r(ie,{title:x,description:P,height:O,width:z,size:m,loading:s,empty:X.length===0,emptyState:k,error:e,errorState:U,onRetry:H,actions:j,tableView:y,legendPosition:ee,legend:ae?r(ue,{items:B,position:ee,marker:"rect",size:m}):void 0,table:y?r(he,{data:g,series:[{key:o,label:f??c.chartOpen},{key:p,label:M??c.chartHigh},{key:C,label:G??c.chartLow},{key:L,label:Z??c.chartClose}],xKey:i.key,xLabel:i.label??i.key,formatX:N,formatValue:K,caption:typeof x=="string"?x:void 0}):void 0,className:$,...V,children:({width:h})=>r(Re,{width:h,height:O,data:g,candles:X,x:i,y:n,grid:F,size:m,candleSize:W,fillRising:D,palette:w,referenceLines:T,margin:l,tooltip:E,plotLabel:u,formatValue:K,formatX:N,onCandleClick:a})})}export{$e as CandlestickChart};
@@ -1 +1 @@
1
- "use strict";"use client";var P=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var K=(r,o)=>{for(var n in o)P(r,n,{get:o[n],enumerable:!0})},O=(r,o,n,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let l of M(o))!I.call(r,l)&&l!==n&&P(r,l,{get:()=>o[l],enumerable:!(i=A(o,l))||i.enumerable});return r};var U=r=>O(P({},"__esModule",{value:!0}),r);var H={};K(H,{ChartBrushLayer:()=>N,useChartBrush:()=>X});module.exports=U(H);var u=require("react"),b=require("./utils/scales.cjs"),E=require("react/jsx-runtime"),T=4,L=.14;function N({from:r,to:o,width:n,height:i,orientation:l="vertical",live:p=!1,label:s}){let g=Math.max(0,Math.min(r,o)),d=Math.min(l==="vertical"?n:i,Math.max(r,o)),h=d-g;if(h<=0)return null;let f=l==="vertical",y=f?{x:g,y:0,width:h,height:i}:{x:0,y:g,width:n,height:h},m=a=>f?{x1:a,y1:0,x2:a,y2:i}:{x1:0,y1:a,x2:n,y2:a};return(0,E.jsxs)("g",{"aria-hidden":s?void 0:"true",role:s?"img":void 0,"aria-label":s,children:[(0,E.jsx)("rect",{...y,className:"fill-blue-500",opacity:L}),[g,d].map(a=>(0,E.jsx)("line",{...m(a),className:"stroke-blue-600 dark:stroke-blue-400",strokeWidth:1.5,strokeDasharray:p?"3 3":void 0},a))]})}function X({enabled:r,active:o,centers:n,xValues:i,offset:l,orientation:p,onCommit:s}){let[g,d]=(0,u.useState)(null),h=(0,u.useRef)(null),f=(0,u.useRef)(!1),y=(0,u.useRef)(!1),m=(0,u.useRef)(null),a=(0,u.useCallback)((e,t)=>{let[c,x]=e<=t?[e,t]:[t,e];return{from:i[c],to:i[x],fromIndex:c,toIndex:x}},[i]),R=(0,u.useCallback)(e=>{let t=e.currentTarget.getBoundingClientRect();return p==="vertical"?e.clientX-t.left-l:e.clientY-t.top-l},[p,l]),S=(0,u.useCallback)(e=>{if(!r||n.length===0||e.button!==0)return;let t=R(e),c=(0,b.nearestIndex)(n,t);c<0||(h.current={index:c,pixel:t},f.current=!1,y.current=!1,e.currentTarget.setPointerCapture?.(e.pointerId))},[r,n,R]),G=(0,u.useCallback)(e=>{let t=h.current;if(!r||!t)return;let c=R(e);!f.current&&Math.abs(c-t.pixel)<T||(f.current=!0,d(a(t.index,(0,b.nearestIndex)(n,c))))},[r,n,R,a]),V=(0,u.useCallback)(e=>{let t=h.current;if(h.current=null,!r||!t)return;if(e.currentTarget.hasPointerCapture?.(e.pointerId)&&e.currentTarget.releasePointerCapture?.(e.pointerId),!f.current){d(null),o&&s(null);return}y.current=!0,f.current=!1;let c=a(t.index,(0,b.nearestIndex)(n,R(e)));d(null),m.current=c.fromIndex,s(c)},[r,o,n,R,a,s]),v=(0,u.useCallback)((e,t)=>{if(!r||n.length===0)return;if(e.key==="Escape"){m.current=null,d(null),o&&s(null);return}if(!e.shiftKey){m.current=null;return}let c=p==="vertical",x=c?"ArrowRight":"ArrowDown",k=c?"ArrowLeft":"ArrowUp";if(e.key!==x&&e.key!==k)return;let w=n.length-1,C=m.current??t??0,D=Math.min(w,Math.max(0,(t??C)+(e.key===x?1:-1)));m.current=C,s(a(C,D))},[r,o,n.length,p,a,s]),B=(0,u.useCallback)(()=>{let e=y.current;return y.current=!1,e},[]);return{dragging:g,onPointerDown:S,onPointerMove:G,onPointerUp:V,onKeyDown:v,consumedClick:B}}0&&(module.exports={ChartBrushLayer,useChartBrush});
1
+ "use strict";"use client";var x=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var M=(n,o)=>{for(var t in o)x(n,t,{get:o[t],enumerable:!0})},O=(n,o,t,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let c of I(o))!K.call(n,c)&&c!==t&&x(n,c,{get:()=>o[c],enumerable:!(i=A(o,c))||i.enumerable});return n};var U=n=>O(x({},"__esModule",{value:!0}),n);var H={};M(H,{ChartBrushLayer:()=>N,useChartBrush:()=>X});module.exports=U(H);var u=require("react"),S=require("./utils/keyboard.cjs"),b=require("./utils/scales.cjs"),E=require("react/jsx-runtime"),T=4,L=.14;function N({from:n,to:o,width:t,height:i,orientation:c="vertical",live:p=!1,label:s}){let g=Math.max(0,Math.min(n,o)),d=Math.min(c==="vertical"?t:i,Math.max(n,o)),h=d-g;if(h<=0)return null;let f=c==="vertical",y=f?{x:g,y:0,width:h,height:i}:{x:0,y:g,width:t,height:h},m=a=>f?{x1:a,y1:0,x2:a,y2:i}:{x1:0,y1:a,x2:t,y2:a};return(0,E.jsxs)("g",{"aria-hidden":s?void 0:"true",role:s?"img":void 0,"aria-label":s,children:[(0,E.jsx)("rect",{...y,className:"fill-blue-500",opacity:L}),[g,d].map(a=>(0,E.jsx)("line",{...m(a),className:"stroke-blue-600 dark:stroke-blue-400",strokeWidth:1.5,strokeDasharray:p?"3 3":void 0},a))]})}function X({enabled:n,active:o,centers:t,xValues:i,offset:c,orientation:p,onCommit:s}){let[g,d]=(0,u.useState)(null),h=(0,u.useRef)(null),f=(0,u.useRef)(!1),y=(0,u.useRef)(!1),m=(0,u.useRef)(null),a=(0,u.useCallback)((r,e)=>{let[l,C]=r<=e?[r,e]:[e,r];return{from:i[l],to:i[C],fromIndex:l,toIndex:C}},[i]),R=(0,u.useCallback)(r=>{let e=r.currentTarget.getBoundingClientRect();return p==="vertical"?r.clientX-e.left-c:r.clientY-e.top-c},[p,c]),G=(0,u.useCallback)(r=>{if(!n||t.length===0||r.button!==0)return;let e=R(r),l=(0,b.nearestIndex)(t,e);l<0||(h.current={index:l,pixel:e},f.current=!1,y.current=!1,r.currentTarget.setPointerCapture?.(r.pointerId))},[n,t,R]),V=(0,u.useCallback)(r=>{let e=h.current;if(!n||!e)return;let l=R(r);!f.current&&Math.abs(l-e.pixel)<T||(f.current=!0,d(a(e.index,(0,b.nearestIndex)(t,l))))},[n,t,R,a]),v=(0,u.useCallback)(r=>{let e=h.current;if(h.current=null,!n||!e)return;if(r.currentTarget.hasPointerCapture?.(r.pointerId)&&r.currentTarget.releasePointerCapture?.(r.pointerId),!f.current){d(null),o&&s(null);return}y.current=!0,f.current=!1;let l=a(e.index,(0,b.nearestIndex)(t,R(r)));d(null),m.current=l.fromIndex,s(l)},[n,o,t,R,a,s]),B=(0,u.useCallback)((r,e)=>{if(!n||t.length===0)return;if(r.key==="Escape"){m.current=null,d(null),o&&s(null);return}if(!r.shiftKey){m.current=null;return}let l=p==="vertical",C=l?"ArrowRight":"ArrowDown",w=l?"ArrowLeft":"ArrowUp";if(r.key!==C&&r.key!==w)return;if(e===null){m.current=null;return}let D=(0,S.stepChartCursor)(e,r.key===C?1:-1,t.length),P=m.current??e;m.current=P,s(a(P,D))},[n,o,t.length,p,a,s]),k=(0,u.useCallback)(()=>{let r=y.current;return y.current=!1,r},[]);return{dragging:g,onPointerDown:G,onPointerMove:V,onPointerUp:v,onKeyDown:B,consumedClick:k}}0&&(module.exports={ChartBrushLayer,useChartBrush});
@@ -1 +1 @@
1
- "use client";import{useCallback as d,useRef as E,useState as A}from"react";import{nearestIndex as C}from"./utils/scales.js";import{jsx as P,jsxs as K}from"react/jsx-runtime";var M=4,I=.14;function T({from:u,to:i,width:n,height:s,orientation:m="vertical",live:p=!1,label:a}){let g=Math.max(0,Math.min(u,i)),h=Math.min(m==="vertical"?n:s,Math.max(u,i)),c=h-g;if(c<=0)return null;let l=m==="vertical",y=l?{x:g,y:0,width:c,height:s}:{x:0,y:g,width:n,height:c},f=t=>l?{x1:t,y1:0,x2:t,y2:s}:{x1:0,y1:t,x2:n,y2:t};return K("g",{"aria-hidden":a?void 0:"true",role:a?"img":void 0,"aria-label":a,children:[P("rect",{...y,className:"fill-blue-500",opacity:I}),[g,h].map(t=>P("line",{...f(t),className:"stroke-blue-600 dark:stroke-blue-400",strokeWidth:1.5,strokeDasharray:p?"3 3":void 0},t))]})}function L({enabled:u,active:i,centers:n,xValues:s,offset:m,orientation:p,onCommit:a}){let[g,h]=A(null),c=E(null),l=E(!1),y=E(!1),f=E(null),t=d((e,r)=>{let[o,x]=e<=r?[e,r]:[r,e];return{from:s[o],to:s[x],fromIndex:o,toIndex:x}},[s]),R=d(e=>{let r=e.currentTarget.getBoundingClientRect();return p==="vertical"?e.clientX-r.left-m:e.clientY-r.top-m},[p,m]),S=d(e=>{if(!u||n.length===0||e.button!==0)return;let r=R(e),o=C(n,r);o<0||(c.current={index:o,pixel:r},l.current=!1,y.current=!1,e.currentTarget.setPointerCapture?.(e.pointerId))},[u,n,R]),G=d(e=>{let r=c.current;if(!u||!r)return;let o=R(e);!l.current&&Math.abs(o-r.pixel)<M||(l.current=!0,h(t(r.index,C(n,o))))},[u,n,R,t]),V=d(e=>{let r=c.current;if(c.current=null,!u||!r)return;if(e.currentTarget.hasPointerCapture?.(e.pointerId)&&e.currentTarget.releasePointerCapture?.(e.pointerId),!l.current){h(null),i&&a(null);return}y.current=!0,l.current=!1;let o=t(r.index,C(n,R(e)));h(null),f.current=o.fromIndex,a(o)},[u,i,n,R,t,a]),v=d((e,r)=>{if(!u||n.length===0)return;if(e.key==="Escape"){f.current=null,h(null),i&&a(null);return}if(!e.shiftKey){f.current=null;return}let o=p==="vertical",x=o?"ArrowRight":"ArrowDown",k=o?"ArrowLeft":"ArrowUp";if(e.key!==x&&e.key!==k)return;let w=n.length-1,b=f.current??r??0,D=Math.min(w,Math.max(0,(r??b)+(e.key===x?1:-1)));f.current=b,a(t(b,D))},[u,i,n.length,p,t,a]),B=d(()=>{let e=y.current;return y.current=!1,e},[]);return{dragging:g,onPointerDown:S,onPointerMove:G,onPointerUp:V,onKeyDown:v,consumedClick:B}}export{T as ChartBrushLayer,L as useChartBrush};
1
+ "use client";import{useCallback as m,useRef as E,useState as D}from"react";import{stepChartCursor as A}from"./utils/keyboard.js";import{nearestIndex as b}from"./utils/scales.js";import{jsx as P,jsxs as M}from"react/jsx-runtime";var I=4,K=.14;function L({from:u,to:s,width:n,height:h,orientation:d="vertical",live:p=!1,label:a}){let g=Math.max(0,Math.min(u,s)),f=Math.min(d==="vertical"?n:h,Math.max(u,s)),l=f-g;if(l<=0)return null;let c=d==="vertical",y=c?{x:g,y:0,width:l,height:h}:{x:0,y:g,width:n,height:l},i=t=>c?{x1:t,y1:0,x2:t,y2:h}:{x1:0,y1:t,x2:n,y2:t};return M("g",{"aria-hidden":a?void 0:"true",role:a?"img":void 0,"aria-label":a,children:[P("rect",{...y,className:"fill-blue-500",opacity:K}),[g,f].map(t=>P("line",{...i(t),className:"stroke-blue-600 dark:stroke-blue-400",strokeWidth:1.5,strokeDasharray:p?"3 3":void 0},t))]})}function N({enabled:u,active:s,centers:n,xValues:h,offset:d,orientation:p,onCommit:a}){let[g,f]=D(null),l=E(null),c=E(!1),y=E(!1),i=E(null),t=m((r,e)=>{let[o,C]=r<=e?[r,e]:[e,r];return{from:h[o],to:h[C],fromIndex:o,toIndex:C}},[h]),R=m(r=>{let e=r.currentTarget.getBoundingClientRect();return p==="vertical"?r.clientX-e.left-d:r.clientY-e.top-d},[p,d]),S=m(r=>{if(!u||n.length===0||r.button!==0)return;let e=R(r),o=b(n,e);o<0||(l.current={index:o,pixel:e},c.current=!1,y.current=!1,r.currentTarget.setPointerCapture?.(r.pointerId))},[u,n,R]),G=m(r=>{let e=l.current;if(!u||!e)return;let o=R(r);!c.current&&Math.abs(o-e.pixel)<I||(c.current=!0,f(t(e.index,b(n,o))))},[u,n,R,t]),V=m(r=>{let e=l.current;if(l.current=null,!u||!e)return;if(r.currentTarget.hasPointerCapture?.(r.pointerId)&&r.currentTarget.releasePointerCapture?.(r.pointerId),!c.current){f(null),s&&a(null);return}y.current=!0,c.current=!1;let o=t(e.index,b(n,R(r)));f(null),i.current=o.fromIndex,a(o)},[u,s,n,R,t,a]),v=m((r,e)=>{if(!u||n.length===0)return;if(r.key==="Escape"){i.current=null,f(null),s&&a(null);return}if(!r.shiftKey){i.current=null;return}let o=p==="vertical",C=o?"ArrowRight":"ArrowDown",k=o?"ArrowLeft":"ArrowUp";if(r.key!==C&&r.key!==k)return;if(e===null){i.current=null;return}let w=A(e,r.key===C?1:-1,n.length),x=i.current??e;i.current=x,a(t(x,w))},[u,s,n.length,p,t,a]),B=m(()=>{let r=y.current;return y.current=!1,r},[]);return{dragging:g,onPointerDown:S,onPointerMove:G,onPointerUp:V,onKeyDown:v,consumedClick:B}}export{L as ChartBrushLayer,N as useChartBrush};
@@ -1 +1 @@
1
- "use strict";"use client";var c=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var L=(t,o)=>{for(var s in o)c(t,s,{get:o[s],enumerable:!0})},M=(t,o,s,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of O(o))!S.call(t,n)&&n!==s&&c(t,n,{get:()=>o[n],enumerable:!(i=N(o,n))||i.enumerable});return t};var P=t=>M(c({},"__esModule",{value:!0}),t);var J={};L(J,{ChartExportButton:()=>j});module.exports=P(J);var b=require("react"),f=require("../../lib/cn.cjs"),y=require("../../lib/i18n.cjs"),v=require("../dropdown/Dropdown.cjs"),w=require("../dropdown/DropdownContent.cjs"),E=require("../dropdown/DropdownItem.cjs"),k=require("../dropdown/DropdownTrigger.cjs"),D=require("./utils/export.cjs"),r=require("react/jsx-runtime"),T={sm:"h-7 px-2.5 text-xs",md:"h-8 px-3 text-sm",lg:"h-10 px-4 text-sm"},C=(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,formats:a=["csv","json"],filename:d="chart",size:F="md",label:z,onExport:p,className:B,disabled:h}){let l=(0,y.useUILabels)(),m=(0,b.useCallback)(e=>{let x={data:t,series:o,xKey:s,xLabel:i,formatX:n};p?p(e,x):(0,D.downloadChartData)(e,x,d)},[t,o,s,i,n,p,d]),g=z??l.chartExport,I=e=>e==="csv"?l.chartExportCsv:l.chartExportJson,u=(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-blue-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",T[F],B);if(a.length<=1){let e=a[0]??"csv";return(0,r.jsxs)("button",{type:"button",onClick:()=>m(e),disabled:h||t.length===0,className:u,children:[C,(0,r.jsx)("span",{children:g})]})}return(0,r.jsxs)(v.Dropdown,{children:[(0,r.jsxs)(k.DropdownTrigger,{disabled:h||t.length===0,className:u,children:[C,(0,r.jsx)("span",{children:g})]}),(0,r.jsx)(w.DropdownContent,{children:a.map(e=>(0,r.jsx)(E.DropdownItem,{onSelect:()=>m(e),children:I(e)},e))})]})}0&&(module.exports={ChartExportButton});
1
+ "use strict";"use client";var c=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var M=(t,o)=>{for(var s in o)c(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&&c(t,n,{get:()=>o[n],enumerable:!(i=S(o,n))||i.enumerable});return t};var T=t=>P(c({},"__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 l=(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??l.chartExport,O=e=>e==="csv"?l.chartExportCsv:l.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-blue-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 +1 @@
1
- "use client";import{useCallback as w}from"react";import{cn as E}from"../../lib/cn.js";import{useUILabels as k}from"../../lib/i18n.js";import{Dropdown as D}from"../dropdown/Dropdown.js";import{DropdownContent as F}from"../dropdown/DropdownContent.js";import{DropdownItem as z}from"../dropdown/DropdownItem.js";import{DropdownTrigger as B}from"../dropdown/DropdownTrigger.js";import{downloadChartData as I}from"./utils/export.js";import{jsx as o,jsxs as i}from"react/jsx-runtime";var N={sm:"h-7 px-2.5 text-xs",md:"h-8 px-3 text-sm",lg:"h-10 px-4 text-sm"},C=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 R({data:r,series:a,xKey:p,xLabel:l,formatX:c,formats:e=["csv","json"],filename:d="chart",size:b="md",label:f,onExport:n,className:y,disabled:h}){let s=k(),m=w(t=>{let x={data:r,series:a,xKey:p,xLabel:l,formatX:c};n?n(t,x):I(t,x,d)},[r,a,p,l,c,n,d]),g=f??s.chartExport,v=t=>t==="csv"?s.chartExportCsv:s.chartExportJson,u=E("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-blue-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",N[b],y);if(e.length<=1){let t=e[0]??"csv";return i("button",{type:"button",onClick:()=>m(t),disabled:h||r.length===0,className:u,children:[C,o("span",{children:g})]})}return i(D,{children:[i(B,{disabled:h||r.length===0,className:u,children:[C,o("span",{children:g})]}),o(F,{children:e.map(t=>o(z,{onSelect:()=>m(t),children:v(t)},t))})]})}export{R as ChartExportButton};
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:l,formatX:c,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:l,formatX:c,neutralizeFormulas:d};n?n(t,C):O(t,C,h)},[r,a,p,l,c,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-blue-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,2 +1 @@
1
- "use strict";var p=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var O=(t,r)=>{for(var n in r)p(t,n,{get:r[n],enumerable:!0})},R=(t,r,n,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let e of y(r))!E.call(t,e)&&e!==n&&p(t,e,{get:()=>r[e],enumerable:!(o=b(r,e))||o.enumerable});return t};var w=t=>R(p({},"__esModule",{value:!0}),t);var L={};O(L,{downloadChartData:()=>v,toChartCsv:()=>m,toChartJson:()=>d,toChartRows:()=>u});module.exports=w(L);var g=require("../palette.cjs"),c=require("./data.cjs");function j(t){return t instanceof Date?t.toISOString():t}function u({data:t,series:r,xKey:n,xLabel:o,formatX:e}){let s=r.filter(a=>!a.hidden),i=o??n;return t.map((a,l)=>{let h=(0,c.readXValue)(a,n,l),f={[i]:e?e(h,l):j(h)};for(let C of s)f[(0,g.getSeriesLabel)(C)]=(0,c.readNumber)(a,C.key);return f})}function x(t,r){if(t===null)return"";let n=String(t);return!n.includes(r)&&!/["\n\r]/.test(n)?n:`"${n.replace(/"/g,'""')}"`}function m(t,r=","){let n=u(t);if(n.length===0)return"";let o=Object.keys(n[0]);return[o.map(e=>x(e,r)).join(r),...n.map(e=>o.map(s=>x(e[s]??null,r)).join(r))].join(`
2
- `)}function d(t){return JSON.stringify(u(t),null,2)}function v(t,r,n="chart"){if(typeof document>"u"||typeof URL.createObjectURL!="function")return;let o=t==="csv",e=o?m(r):d(r),s=new Blob([e],{type:o?"text/csv;charset=utf-8":"application/json"}),i=URL.createObjectURL(s),a=document.createElement("a");a.href=i,a.download=`${n}.${t}`,a.click(),URL.revokeObjectURL(i)}0&&(module.exports={downloadChartData,toChartCsv,toChartJson,toChartRows});
1
+ "use strict";var u=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var O=(t,r)=>{for(var e in r)u(t,e,{get:r[e],enumerable:!0})},R=(t,r,e,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of g(r))!E.call(t,o)&&o!==e&&u(t,o,{get:()=>r[o],enumerable:!(n=y(r,o))||n.enumerable});return t};var w=t=>R(u({},"__esModule",{value:!0}),t);var j={};O(j,{downloadChartData:()=>L,toChartCsv:()=>d,toChartJson:()=>b,toChartRows:()=>p});module.exports=w(j);var C=require("../../../lib/csv.cjs"),x=require("../palette.cjs"),c=require("./data.cjs");function v(t){return t instanceof Date?t.toISOString():t}function p({data:t,series:r,xKey:e,xLabel:n,formatX:o}){let s=r.filter(a=>!a.hidden),i=n??e;return t.map((a,l)=>{let h=(0,c.readXValue)(a,e,l),m={[i]:o?o(h,l):v(h)};for(let f of s)m[(0,x.getSeriesLabel)(f)]=(0,c.readNumber)(a,f.key);return m})}function d(t,r=","){let e=p(t);if(e.length===0)return"";let n=Object.keys(e[0]);return(0,C.csvDocument)([n,...e.map(o=>n.map(s=>o[s]))],{delimiter:r,neutralizeFormulas:t.neutralizeFormulas})}function b(t){return JSON.stringify(p(t),null,2)}function L(t,r,e="chart"){if(typeof document>"u"||typeof URL.createObjectURL!="function")return;let n=t==="csv",o=n?d(r):b(r),s=new Blob([o],{type:n?"text/csv;charset=utf-8":"application/json"}),i=URL.createObjectURL(s),a=document.createElement("a");a.href=i,a.download=`${e}.${t}`,a.click(),URL.revokeObjectURL(i)}0&&(module.exports={downloadChartData,toChartCsv,toChartJson,toChartRows});
@@ -1,2 +1 @@
1
- import{getSeriesLabel as C}from"../palette.js";import{readNumber as x,readXValue as g}from"./data.js";function m(t){return t instanceof Date?t.toISOString():t}function f({data:t,series:n,xKey:r,xLabel:a,formatX:e}){let s=n.filter(o=>!o.hidden),i=a??r;return t.map((o,c)=>{let p=g(o,r,c),u={[i]:e?e(p,c):m(p)};for(let l of s)u[C(l)]=x(o,l.key);return u})}function h(t,n){if(t===null)return"";let r=String(t);return!r.includes(n)&&!/["\n\r]/.test(r)?r:`"${r.replace(/"/g,'""')}"`}function d(t,n=","){let r=f(t);if(r.length===0)return"";let a=Object.keys(r[0]);return[a.map(e=>h(e,n)).join(n),...r.map(e=>a.map(s=>h(e[s]??null,n)).join(n))].join(`
2
- `)}function b(t){return JSON.stringify(f(t),null,2)}function O(t,n,r="chart"){if(typeof document>"u"||typeof URL.createObjectURL!="function")return;let a=t==="csv",e=a?d(n):b(n),s=new Blob([e],{type:a?"text/csv;charset=utf-8":"application/json"}),i=URL.createObjectURL(s),o=document.createElement("a");o.href=i,o.download=`${r}.${t}`,o.click(),URL.revokeObjectURL(i)}export{O as downloadChartData,d as toChartCsv,b as toChartJson,f as toChartRows};
1
+ import{csvDocument as m}from"../../../lib/csv.js";import{getSeriesLabel as f}from"../palette.js";import{readNumber as C,readXValue as x}from"./data.js";function d(t){return t instanceof Date?t.toISOString():t}function h({data:t,series:n,xKey:r,xLabel:o,formatX:a}){let s=n.filter(e=>!e.hidden),i=o??r;return t.map((e,c)=>{let u=x(e,r,c),p={[i]:a?a(u,c):d(u)};for(let l of s)p[f(l)]=C(e,l.key);return p})}function b(t,n=","){let r=h(t);if(r.length===0)return"";let o=Object.keys(r[0]);return m([o,...r.map(a=>o.map(s=>a[s]))],{delimiter:n,neutralizeFormulas:t.neutralizeFormulas})}function y(t){return JSON.stringify(h(t),null,2)}function R(t,n,r="chart"){if(typeof document>"u"||typeof URL.createObjectURL!="function")return;let o=t==="csv",a=o?b(n):y(n),s=new Blob([a],{type:o?"text/csv;charset=utf-8":"application/json"}),i=URL.createObjectURL(s),e=document.createElement("a");e.href=i,e.download=`${r}.${t}`,e.click(),URL.revokeObjectURL(i)}export{R as downloadChartData,b as toChartCsv,y as toChartJson,h as toChartRows};
@@ -0,0 +1 @@
1
+ "use strict";var u=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var h=(r,e)=>{for(var n in e)u(r,n,{get:e[n],enumerable:!0})},p=(r,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of y(e))!b.call(r,o)&&o!==n&&u(r,o,{get:()=>e[o],enumerable:!(t=s(e,o))||t.enumerable});return r};var K=r=>p(u({},"__esModule",{value:!0}),r);var c={};h(c,{chartCursorTarget:()=>l,handleChartKeyDown:()=>m,pressChartMark:()=>f,stepChartCursor:()=>i});module.exports=K(c);var x={x:["ArrowRight"],y:["ArrowDown"],both:["ArrowRight","ArrowDown"]},A={x:["ArrowLeft"],y:["ArrowUp"],both:["ArrowLeft","ArrowUp"]};function i(r,e,n){return r===null?0:Math.max(0,Math.min(n-1,r+e))}function l(r,e,n,t){if(!(n<=0)){if(x[t].includes(r))return i(e,1,n);if(A[t].includes(r))return i(e,-1,n);if(r==="Home")return 0;if(r==="End")return n-1;if(r==="Escape")return null}}function f(r,e){return r.key!=="Enter"&&r.key!==" "||r.altKey||r.ctrlKey||r.metaKey?!1:(e&&(r.preventDefault(),r.repeat||e()),!0)}function m(r,{count:e,current:n,axis:t,onMove:o,pick:d}){if(e<=0||f(r,n===null?null:d))return;let a=l(r.key,n,e,t);a!==void 0&&(r.preventDefault(),o(a))}0&&(module.exports={chartCursorTarget,handleChartKeyDown,pressChartMark,stepChartCursor});
@@ -0,0 +1 @@
1
+ var l={x:["ArrowRight"],y:["ArrowDown"],both:["ArrowRight","ArrowDown"]},f={x:["ArrowLeft"],y:["ArrowUp"],both:["ArrowLeft","ArrowUp"]};function u(r,e,n){return r===null?0:Math.max(0,Math.min(n-1,r+e))}function d(r,e,n,t){if(!(n<=0)){if(l[t].includes(r))return u(e,1,n);if(f[t].includes(r))return u(e,-1,n);if(r==="Home")return 0;if(r==="End")return n-1;if(r==="Escape")return null}}function s(r,e){return r.key!=="Enter"&&r.key!==" "||r.altKey||r.ctrlKey||r.metaKey?!1:(e&&(r.preventDefault(),r.repeat||e()),!0)}function y(r,{count:e,current:n,axis:t,onMove:i,pick:a}){if(e<=0||s(r,n===null?null:a))return;let o=d(r.key,n,e,t);o!==void 0&&(r.preventDefault(),i(o))}export{d as chartCursorTarget,y as handleChartKeyDown,s as pressChartMark,u as stepChartCursor};
@@ -1 +1 @@
1
- "use strict";"use client";var g=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var T=(t,r)=>{for(var a in r)g(t,a,{get:r[a],enumerable:!0})},q=(t,r,a,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of I(r))!O.call(t,s)&&s!==a&&g(t,s,{get:()=>r[s],enumerable:!(n=H(r,s))||n.enumerable});return t};var A=t=>q(g({},"__esModule",{value:!0}),t);var X={};T(X,{Chip:()=>m});module.exports=A(X);var o=require("../../lib/cn.cjs"),e=require("react/jsx-runtime");function D({className:t}){return(0,e.jsx)("svg",{className:t,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:(0,e.jsx)("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}var F={default:{solid:"bg-gray-500 text-white",outlined:"border-gray-300 text-gray-700 dark:border-gray-600 dark:text-gray-300 bg-transparent",soft:"bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300",dot:"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"},primary:{solid:"bg-blue-600 text-white",outlined:"border-blue-600 text-blue-600 dark:border-blue-400 dark:text-blue-400 bg-transparent",soft:"bg-blue-100 text-blue-700 dark:bg-blue-900/50 dark:text-blue-300",dot:"bg-blue-50 text-blue-700 dark:bg-blue-900/30 dark:text-blue-300"},success:{solid:"bg-green-600 text-white",outlined:"border-green-600 text-green-600 dark:border-green-400 dark:text-green-400 bg-transparent",soft:"bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-300",dot:"bg-green-50 text-green-700 dark:bg-green-900/30 dark:text-green-300"},warning:{solid:"bg-yellow-500 text-white",outlined:"border-yellow-500 text-yellow-600 dark:border-yellow-400 dark:text-yellow-400 bg-transparent",soft:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/50 dark:text-yellow-300",dot:"bg-yellow-50 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-300"},error:{solid:"bg-red-600 text-white",outlined:"border-red-600 text-red-600 dark:border-red-400 dark:text-red-400 bg-transparent",soft:"bg-red-100 text-red-700 dark:bg-red-900/50 dark:text-red-300",dot:"bg-red-50 text-red-700 dark:bg-red-900/30 dark:text-red-300"},info:{solid:"bg-cyan-600 text-white",outlined:"border-cyan-600 text-cyan-600 dark:border-cyan-400 dark:text-cyan-400 bg-transparent",soft:"bg-cyan-100 text-cyan-700 dark:bg-cyan-900/50 dark:text-cyan-300",dot:"bg-cyan-50 text-cyan-700 dark:bg-cyan-900/30 dark:text-cyan-300"}},G={default:"bg-gray-500",primary:"bg-blue-600",success:"bg-green-600",warning:"bg-yellow-500",error:"bg-red-600",info:"bg-cyan-600"},J={sm:"h-5 text-xs px-2 gap-1",md:"h-6 text-sm px-2.5 gap-1.5",lg:"h-8 text-sm px-3 gap-2"},c={sm:"w-3 h-3",md:"w-3.5 h-3.5",lg:"w-4 h-4"},K={sm:"w-4 h-4 -ml-1",md:"w-5 h-5 -ml-1.5",lg:"w-6 h-6 -ml-1.5"},Q={sm:"w-1.5 h-1.5",md:"w-2 h-2",lg:"w-2.5 h-2.5"},U={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"rounded-full"};function m({label:t,children:r,variant:a="solid",size:n="md",color:s="default",bgColor:b,textColor:p,borderColor:u,rounded:f="full",icon:x,endIcon:h,avatar:d,onClose:C,closable:y=!1,clickable:w=!1,selected:R=!1,disabled:l=!1,as:v="span",className:N,onClick:S,...z}){let L=v,M=(0,o.cn)("inline-flex items-center justify-center font-medium transition-all",J[n],U[f],a==="outlined"&&"border"),P=(0,o.cn)(b||p||u?(0,o.cn)(b,p,u):F[s][a]),E=R?"ring-2 ring-offset-1 ring-blue-500":"",V=w&&!l?"cursor-pointer hover:opacity-80 active:scale-95":"",W=l?"opacity-50 cursor-not-allowed":"",j=i=>{i.stopPropagation(),C?.()},B=i=>{l||S?.(i)},k=r??t;return(0,e.jsxs)(L,{className:(0,o.cn)(M,P,E,V,W,N),onClick:B,"aria-disabled":l,...z,children:[a==="dot"&&(0,e.jsx)("span",{className:(0,o.cn)("rounded-full shrink-0",Q[n],G[s]),"aria-hidden":"true"}),d&&(0,e.jsx)("span",{className:(0,o.cn)("rounded-full overflow-hidden shrink-0",K[n]),children:d}),x&&!d&&(0,e.jsx)("span",{className:(0,o.cn)("shrink-0",c[n]),children:x}),k&&(0,e.jsx)("span",{className:"truncate",children:k}),h&&!y&&(0,e.jsx)("span",{className:(0,o.cn)("shrink-0",c[n]),children:h}),y&&(0,e.jsx)("button",{type:"button",onClick:j,disabled:l,className:(0,o.cn)("shrink-0 rounded-full hover:bg-black/10 dark:hover:bg-white/10 p-0.5 -mr-1 transition-colors","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-current",l&&"pointer-events-none"),"aria-label":"Remove",children:(0,e.jsx)(D,{className:c[n]})})]})}m.displayName="Chip";0&&(module.exports={Chip});
1
+ "use strict";"use client";var g=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var q=Object.prototype.hasOwnProperty;var A=(t,r)=>{for(var a in r)g(t,a,{get:r[a],enumerable:!0})},D=(t,r,a,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of U(r))!q.call(t,s)&&s!==a&&g(t,s,{get:()=>r[s],enumerable:!(n=T(r,s))||n.enumerable});return t};var F=t=>D(g({},"__esModule",{value:!0}),t);var _={};A(_,{Chip:()=>f});module.exports=F(_);var o=require("../../lib/cn.cjs"),k=require("../../lib/i18n.cjs"),e=require("react/jsx-runtime");function G({className:t}){return(0,e.jsx)("svg",{className:t,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:(0,e.jsx)("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}var J={default:{solid:"bg-gray-500 text-white",outlined:"border-gray-300 text-gray-700 dark:border-gray-600 dark:text-gray-300 bg-transparent",soft:"bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300",dot:"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"},primary:{solid:"bg-blue-600 text-white",outlined:"border-blue-600 text-blue-600 dark:border-blue-400 dark:text-blue-400 bg-transparent",soft:"bg-blue-100 text-blue-700 dark:bg-blue-900/50 dark:text-blue-300",dot:"bg-blue-50 text-blue-700 dark:bg-blue-900/30 dark:text-blue-300"},success:{solid:"bg-green-600 text-white",outlined:"border-green-600 text-green-600 dark:border-green-400 dark:text-green-400 bg-transparent",soft:"bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-300",dot:"bg-green-50 text-green-700 dark:bg-green-900/30 dark:text-green-300"},warning:{solid:"bg-yellow-500 text-gray-900",outlined:"border-yellow-500 text-yellow-600 dark:border-yellow-400 dark:text-yellow-400 bg-transparent",soft:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/50 dark:text-yellow-300",dot:"bg-yellow-50 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-300"},error:{solid:"bg-red-600 text-white",outlined:"border-red-600 text-red-600 dark:border-red-400 dark:text-red-400 bg-transparent",soft:"bg-red-100 text-red-700 dark:bg-red-900/50 dark:text-red-300",dot:"bg-red-50 text-red-700 dark:bg-red-900/30 dark:text-red-300"},info:{solid:"bg-cyan-600 text-white",outlined:"border-cyan-600 text-cyan-600 dark:border-cyan-400 dark:text-cyan-400 bg-transparent",soft:"bg-cyan-100 text-cyan-700 dark:bg-cyan-900/50 dark:text-cyan-300",dot:"bg-cyan-50 text-cyan-700 dark:bg-cyan-900/30 dark:text-cyan-300"}},K={default:"bg-gray-500",primary:"bg-blue-600",success:"bg-green-600",warning:"bg-yellow-500",error:"bg-red-600",info:"bg-cyan-600"},Q={sm:"h-5 text-xs px-2 gap-1",md:"h-6 text-sm px-2.5 gap-1.5",lg:"h-8 text-sm px-3 gap-2"},c={sm:"w-3 h-3",md:"w-3.5 h-3.5",lg:"w-4 h-4"},X={sm:"w-4 h-4 -ml-1",md:"w-5 h-5 -ml-1.5",lg:"w-6 h-6 -ml-1.5"},Y={sm:"w-1.5 h-1.5",md:"w-2 h-2",lg:"w-2.5 h-2.5"},Z={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"rounded-full"};function f({label:t,children:r,variant:a="solid",size:n="md",color:s="default",bgColor:b,textColor:p,borderColor:u,rounded:C="full",icon:x,endIcon:h,avatar:d,onClose:w,closable:m=!1,removeLabel:v,clickable:R=!1,selected:N=!1,disabled:l=!1,as:S="span",className:L,onClick:z,...M}){let P=(0,k.useUILabels)(),E=S,V=(0,o.cn)("inline-flex items-center justify-center font-medium transition-all",Q[n],Z[C],a==="outlined"&&"border"),W=(0,o.cn)(b||p||u?(0,o.cn)(b,p,u):J[s][a]),I=N?"ring-2 ring-offset-1 ring-blue-500":"",j=R&&!l?"cursor-pointer hover:opacity-80 active:scale-95":"",B=l?"opacity-50 cursor-not-allowed":"",H=i=>{i.stopPropagation(),w?.()},O=i=>{l||z?.(i)},y=r??t;return(0,e.jsxs)(E,{className:(0,o.cn)(V,W,I,j,B,L),onClick:O,"aria-disabled":l,...M,children:[a==="dot"&&(0,e.jsx)("span",{className:(0,o.cn)("rounded-full shrink-0",Y[n],K[s]),"aria-hidden":"true"}),d&&(0,e.jsx)("span",{className:(0,o.cn)("rounded-full overflow-hidden shrink-0",X[n]),children:d}),x&&!d&&(0,e.jsx)("span",{className:(0,o.cn)("shrink-0",c[n]),children:x}),y&&(0,e.jsx)("span",{className:"truncate",children:y}),h&&!m&&(0,e.jsx)("span",{className:(0,o.cn)("shrink-0",c[n]),children:h}),m&&(0,e.jsx)("button",{type:"button",onClick:H,disabled:l,className:(0,o.cn)("shrink-0 rounded-full hover:bg-black/10 dark:hover:bg-white/10 p-0.5 -mr-1 transition-colors","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-current",l&&"pointer-events-none"),"aria-label":v??P.chipRemove,children:(0,e.jsx)(G,{className:c[n]})})]})}f.displayName="Chip";0&&(module.exports={Chip});
@@ -1 +1 @@
1
- "use client";import{cn as e}from"../../lib/cn.js";import{jsx as t,jsxs as D}from"react/jsx-runtime";function j({className:n}){return t("svg",{className:n,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}var B={default:{solid:"bg-gray-500 text-white",outlined:"border-gray-300 text-gray-700 dark:border-gray-600 dark:text-gray-300 bg-transparent",soft:"bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300",dot:"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"},primary:{solid:"bg-blue-600 text-white",outlined:"border-blue-600 text-blue-600 dark:border-blue-400 dark:text-blue-400 bg-transparent",soft:"bg-blue-100 text-blue-700 dark:bg-blue-900/50 dark:text-blue-300",dot:"bg-blue-50 text-blue-700 dark:bg-blue-900/30 dark:text-blue-300"},success:{solid:"bg-green-600 text-white",outlined:"border-green-600 text-green-600 dark:border-green-400 dark:text-green-400 bg-transparent",soft:"bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-300",dot:"bg-green-50 text-green-700 dark:bg-green-900/30 dark:text-green-300"},warning:{solid:"bg-yellow-500 text-white",outlined:"border-yellow-500 text-yellow-600 dark:border-yellow-400 dark:text-yellow-400 bg-transparent",soft:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/50 dark:text-yellow-300",dot:"bg-yellow-50 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-300"},error:{solid:"bg-red-600 text-white",outlined:"border-red-600 text-red-600 dark:border-red-400 dark:text-red-400 bg-transparent",soft:"bg-red-100 text-red-700 dark:bg-red-900/50 dark:text-red-300",dot:"bg-red-50 text-red-700 dark:bg-red-900/30 dark:text-red-300"},info:{solid:"bg-cyan-600 text-white",outlined:"border-cyan-600 text-cyan-600 dark:border-cyan-400 dark:text-cyan-400 bg-transparent",soft:"bg-cyan-100 text-cyan-700 dark:bg-cyan-900/50 dark:text-cyan-300",dot:"bg-cyan-50 text-cyan-700 dark:bg-cyan-900/30 dark:text-cyan-300"}},H={default:"bg-gray-500",primary:"bg-blue-600",success:"bg-green-600",warning:"bg-yellow-500",error:"bg-red-600",info:"bg-cyan-600"},I={sm:"h-5 text-xs px-2 gap-1",md:"h-6 text-sm px-2.5 gap-1.5",lg:"h-8 text-sm px-3 gap-2"},d={sm:"w-3 h-3",md:"w-3.5 h-3.5",lg:"w-4 h-4"},O={sm:"w-4 h-4 -ml-1",md:"w-5 h-5 -ml-1.5",lg:"w-6 h-6 -ml-1.5"},T={sm:"w-1.5 h-1.5",md:"w-2 h-2",lg:"w-2.5 h-2.5"},q={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"rounded-full"};function A({label:n,children:y,variant:a="solid",size:r="md",color:i="default",bgColor:g,textColor:c,borderColor:b,rounded:k="full",icon:p,endIcon:u,avatar:s,onClose:m,closable:x=!1,clickable:f=!1,selected:C=!1,disabled:o=!1,as:w="span",className:R,onClick:v,...N}){let S=w,z=e("inline-flex items-center justify-center font-medium transition-all",I[r],q[k],a==="outlined"&&"border"),L=e(g||c||b?e(g,c,b):B[i][a]),M=C?"ring-2 ring-offset-1 ring-blue-500":"",P=f&&!o?"cursor-pointer hover:opacity-80 active:scale-95":"",E=o?"opacity-50 cursor-not-allowed":"",V=l=>{l.stopPropagation(),m?.()},W=l=>{o||v?.(l)},h=y??n;return D(S,{className:e(z,L,M,P,E,R),onClick:W,"aria-disabled":o,...N,children:[a==="dot"&&t("span",{className:e("rounded-full shrink-0",T[r],H[i]),"aria-hidden":"true"}),s&&t("span",{className:e("rounded-full overflow-hidden shrink-0",O[r]),children:s}),p&&!s&&t("span",{className:e("shrink-0",d[r]),children:p}),h&&t("span",{className:"truncate",children:h}),u&&!x&&t("span",{className:e("shrink-0",d[r]),children:u}),x&&t("button",{type:"button",onClick:V,disabled:o,className:e("shrink-0 rounded-full hover:bg-black/10 dark:hover:bg-white/10 p-0.5 -mr-1 transition-colors","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-current",o&&"pointer-events-none"),"aria-label":"Remove",children:t(j,{className:d[r]})})]})}A.displayName="Chip";export{A as Chip};
1
+ "use client";import{cn as e}from"../../lib/cn.js";import{useUILabels as B}from"../../lib/i18n.js";import{jsx as t,jsxs as G}from"react/jsx-runtime";function H({className:n}){return t("svg",{className:n,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}var O={default:{solid:"bg-gray-500 text-white",outlined:"border-gray-300 text-gray-700 dark:border-gray-600 dark:text-gray-300 bg-transparent",soft:"bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300",dot:"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"},primary:{solid:"bg-blue-600 text-white",outlined:"border-blue-600 text-blue-600 dark:border-blue-400 dark:text-blue-400 bg-transparent",soft:"bg-blue-100 text-blue-700 dark:bg-blue-900/50 dark:text-blue-300",dot:"bg-blue-50 text-blue-700 dark:bg-blue-900/30 dark:text-blue-300"},success:{solid:"bg-green-600 text-white",outlined:"border-green-600 text-green-600 dark:border-green-400 dark:text-green-400 bg-transparent",soft:"bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-300",dot:"bg-green-50 text-green-700 dark:bg-green-900/30 dark:text-green-300"},warning:{solid:"bg-yellow-500 text-gray-900",outlined:"border-yellow-500 text-yellow-600 dark:border-yellow-400 dark:text-yellow-400 bg-transparent",soft:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/50 dark:text-yellow-300",dot:"bg-yellow-50 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-300"},error:{solid:"bg-red-600 text-white",outlined:"border-red-600 text-red-600 dark:border-red-400 dark:text-red-400 bg-transparent",soft:"bg-red-100 text-red-700 dark:bg-red-900/50 dark:text-red-300",dot:"bg-red-50 text-red-700 dark:bg-red-900/30 dark:text-red-300"},info:{solid:"bg-cyan-600 text-white",outlined:"border-cyan-600 text-cyan-600 dark:border-cyan-400 dark:text-cyan-400 bg-transparent",soft:"bg-cyan-100 text-cyan-700 dark:bg-cyan-900/50 dark:text-cyan-300",dot:"bg-cyan-50 text-cyan-700 dark:bg-cyan-900/30 dark:text-cyan-300"}},T={default:"bg-gray-500",primary:"bg-blue-600",success:"bg-green-600",warning:"bg-yellow-500",error:"bg-red-600",info:"bg-cyan-600"},U={sm:"h-5 text-xs px-2 gap-1",md:"h-6 text-sm px-2.5 gap-1.5",lg:"h-8 text-sm px-3 gap-2"},d={sm:"w-3 h-3",md:"w-3.5 h-3.5",lg:"w-4 h-4"},q={sm:"w-4 h-4 -ml-1",md:"w-5 h-5 -ml-1.5",lg:"w-6 h-6 -ml-1.5"},A={sm:"w-1.5 h-1.5",md:"w-2 h-2",lg:"w-2.5 h-2.5"},D={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"rounded-full"};function F({label:n,children:m,variant:a="solid",size:r="md",color:i="default",bgColor:g,textColor:c,borderColor:b,rounded:y="full",icon:p,endIcon:u,avatar:s,onClose:k,closable:x=!1,removeLabel:f,clickable:C=!1,selected:w=!1,disabled:o=!1,as:v="span",className:R,onClick:N,...S}){let L=B(),z=v,M=e("inline-flex items-center justify-center font-medium transition-all",U[r],D[y],a==="outlined"&&"border"),P=e(g||c||b?e(g,c,b):O[i][a]),E=w?"ring-2 ring-offset-1 ring-blue-500":"",V=C&&!o?"cursor-pointer hover:opacity-80 active:scale-95":"",W=o?"opacity-50 cursor-not-allowed":"",I=l=>{l.stopPropagation(),k?.()},j=l=>{o||N?.(l)},h=m??n;return G(z,{className:e(M,P,E,V,W,R),onClick:j,"aria-disabled":o,...S,children:[a==="dot"&&t("span",{className:e("rounded-full shrink-0",A[r],T[i]),"aria-hidden":"true"}),s&&t("span",{className:e("rounded-full overflow-hidden shrink-0",q[r]),children:s}),p&&!s&&t("span",{className:e("shrink-0",d[r]),children:p}),h&&t("span",{className:"truncate",children:h}),u&&!x&&t("span",{className:e("shrink-0",d[r]),children:u}),x&&t("button",{type:"button",onClick:I,disabled:o,className:e("shrink-0 rounded-full hover:bg-black/10 dark:hover:bg-white/10 p-0.5 -mr-1 transition-colors","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-current",o&&"pointer-events-none"),"aria-label":f??L.chipRemove,children:t(H,{className:d[r]})})]})}F.displayName="Chip";export{F as Chip};
@@ -1,2 +1 @@
1
- "use strict";"use client";var ar=Object.create;var me=Object.defineProperty;var nr=Object.getOwnPropertyDescriptor;var or=Object.getOwnPropertyNames;var sr=Object.getPrototypeOf,lr=Object.prototype.hasOwnProperty;var ir=(o,l)=>{for(var i in l)me(o,i,{get:l[i],enumerable:!0})},ot=(o,l,i,c)=>{if(l&&typeof l=="object"||typeof l=="function")for(let u of or(l))!lr.call(o,u)&&u!==i&&me(o,u,{get:()=>l[u],enumerable:!(c=nr(l,u))||c.enumerable});return o};var dr=(o,l,i)=>(i=o!=null?ar(sr(o)):{},ot(l||!o||!o.__esModule?me(i,"default",{value:o,enumerable:!0}):i,o)),cr=o=>ot(me({},"__esModule",{value:!0}),o);var Rr={};ir(Rr,{DataGrid:()=>Sr});module.exports=cr(Rr);var n=dr(require("react"),1),m=require("../../lib/cn.cjs"),t=require("react/jsx-runtime"),h={compact:"px-3 py-1.5",default:"px-4 py-3",comfortable:"px-6 py-4"},ye={compact:"text-xs",default:"text-sm",comfortable:"text-base"},gr=()=>(0,t.jsx)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:(0,t.jsx)("path",{d:"M8 3l4 5H4l4-5z"})}),ur=()=>(0,t.jsx)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:(0,t.jsx)("path",{d:"M8 13l4-5H4l4 5z"})}),pr=()=>(0,t.jsx)("svg",{className:"w-3.5 h-3.5 opacity-30",viewBox:"0 0 16 16",fill:"currentColor",children:(0,t.jsx)("path",{d:"M8 3l3 4H5l3-4zM8 13l3-4H5l3 4z"})}),st=({className:o})=>(0,t.jsx)("svg",{className:(0,m.cn)("w-4 h-4",o),viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})}),mr=()=>(0,t.jsx)("svg",{className:"w-4 h-4 text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M9 3.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM2 9a7 7 0 1112.452 4.391l3.328 3.329a.75.75 0 11-1.06 1.06l-3.329-3.328A7 7 0 012 9z",clipRule:"evenodd"})}),br=()=>(0,t.jsx)("svg",{className:"w-4 h-4 text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("path",{d:"M7 4a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3zM7 10.5a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3zM7 17a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3z"})}),yr=()=>(0,t.jsx)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M2.628 1.601C5.028 1.206 7.49 1 10 1s4.973.206 7.372.601a.75.75 0 01.628.74v2.288a2.25 2.25 0 01-.659 1.59l-4.682 4.683a2.25 2.25 0 00-.659 1.59v3.037c0 .684-.31 1.33-.844 1.757l-1.937 1.55A.75.75 0 018 18.25v-5.757a2.25 2.25 0 00-.659-1.591L2.659 6.22A2.25 2.25 0 012 4.629V2.34a.75.75 0 01.628-.74z",clipRule:"evenodd"})}),fr=()=>(0,t.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:[(0,t.jsx)("path",{d:"M10.75 2.75a.75.75 0 00-1.5 0v8.614L6.295 8.235a.75.75 0 10-1.09 1.03l4.25 4.5a.75.75 0 001.09 0l4.25-4.5a.75.75 0 00-1.09-1.03l-2.955 3.129V2.75z"}),(0,t.jsx)("path",{d:"M3.5 12.75a.75.75 0 00-1.5 0v2.5A2.75 2.75 0 004.75 18h10.5A2.75 2.75 0 0018 15.25v-2.5a.75.75 0 00-1.5 0v2.5c0 .69-.56 1.25-1.25 1.25H4.75c-.69 0-1.25-.56-1.25-1.25v-2.5z"})]}),hr=()=>(0,t.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M2.5 3A1.5 1.5 0 001 4.5v11A1.5 1.5 0 002.5 17h15a1.5 1.5 0 001.5-1.5v-11A1.5 1.5 0 0017.5 3h-15zM2.5 4.5h6v11h-6v-11zm7.5 0h7.5v11H10v-11z",clipRule:"evenodd"})});function be(o,l,i){return typeof i=="function"?i(o,l):String(typeof i=="string"?o[i]:l)}function E(o,l){return o[l]}function vr(o,l){return o==null&&l==null?0:o==null?-1:l==null?1:typeof o=="number"&&typeof l=="number"?o-l:String(o).localeCompare(String(l))}function xr(o,l){let i=String(o??"").toLowerCase(),c=l.value.toLowerCase();switch(l.operator){case"contains":return i.includes(c);case"equals":return i===c;case"startsWith":return i.startsWith(c);case"endsWith":return i.endsWith(c);case"gt":return Number(o)>Number(l.value);case"gte":return Number(o)>=Number(l.value);case"lt":return Number(o)<Number(l.value);case"lte":return Number(o)<=Number(l.value);case"isEmpty":return i==="";case"isNotEmpty":return i!=="";default:return!0}}function lt(o,l,i){let c=[];for(let u of o){let p=Number(E(u,l));isNaN(p)||c.push(p)}if(c.length===0)return 0;switch(i){case"sum":return c.reduce((u,p)=>u+p,0);case"avg":return c.reduce((u,p)=>u+p,0)/c.length;case"count":return c.length;case"min":return Math.min(...c);case"max":return Math.max(...c)}}function kr({cols:o,density:l}){return(0,t.jsx)("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:Array.from({length:o}).map((i,c)=>(0,t.jsx)("td",{className:h[l],children:(0,t.jsx)("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"})},c))})}function wr({column:o,value:l,onApply:i,onClear:c}){let[u,p]=(0,n.useState)(!1),[F,z]=(0,n.useState)(l?.operator??"contains"),[C,S]=(0,n.useState)(l?.value??""),I=(0,n.useRef)(null),R=o.filterType??"text",re=R==="number"?[{value:"equals",label:"Equals"},{value:"gt",label:"Greater than"},{value:"gte",label:"Greater or equal"},{value:"lt",label:"Less than"},{value:"lte",label:"Less or equal"}]:[{value:"contains",label:"Contains"},{value:"equals",label:"Equals"},{value:"startsWith",label:"Starts with"},{value:"endsWith",label:"Ends with"},{value:"isEmpty",label:"Is empty"},{value:"isNotEmpty",label:"Is not empty"}];return(0,n.useEffect)(()=>{let b=ie=>{I.current&&!I.current.contains(ie.target)&&p(!1)};return u&&document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[u]),(0,t.jsxs)("div",{className:"relative inline-block",ref:I,children:[(0,t.jsx)("button",{type:"button",onClick:b=>{b.stopPropagation(),p(!u)},className:(0,m.cn)("p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer",l&&"text-blue-600 dark:text-blue-400"),"aria-label":`Filter ${String(o.header)}`,children:(0,t.jsx)(yr,{})}),u&&(0,t.jsx)("div",{className:"absolute z-50 top-full left-0 mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg p-3 min-w-[220px]",children:R==="select"&&o.filterOptions?(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[o.filterOptions.map(b=>(0,t.jsxs)("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[(0,t.jsx)("input",{type:"radio",name:`filter-${o.key}`,value:b,checked:C===b,onChange:()=>S(b),className:"cursor-pointer"}),(0,t.jsx)("span",{className:"text-gray-700 dark:text-gray-300",children:b})]},b)),(0,t.jsxs)("div",{className:"flex gap-2 mt-2",children:[(0,t.jsx)("button",{type:"button",onClick:()=>{i({column:o.key,operator:"equals",value:C}),p(!1)},className:"px-2 py-1 text-xs bg-blue-600 text-white rounded hover:bg-blue-700 cursor-pointer",children:"Apply"}),(0,t.jsx)("button",{type:"button",onClick:()=>{S(""),c(),p(!1)},className:"px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 cursor-pointer",children:"Clear"})]})]}):(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)("select",{value:F,onChange:b=>z(b.target.value),className:"text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200",children:re.map(b=>(0,t.jsx)("option",{value:b.value,children:b.label},b.value))}),F!=="isEmpty"&&F!=="isNotEmpty"&&(0,t.jsx)("input",{type:R==="number"?"number":R==="date"?"date":"text",value:C,onChange:b=>S(b.target.value),placeholder:"Filter value...",className:"text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200",autoFocus:!0,"aria-label":`Filter ${String(o.header)} value`}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("button",{type:"button",onClick:()=>{i({column:o.key,operator:F,value:C}),p(!1)},className:"px-2 py-1 text-xs bg-blue-600 text-white rounded hover:bg-blue-700 cursor-pointer",children:"Apply"}),(0,t.jsx)("button",{type:"button",onClick:()=>{S(""),c(),p(!1)},className:"px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 cursor-pointer",children:"Clear"})]})]})})]})}function Cr({value:o,onSave:l,density:i}){let[c,u]=(0,n.useState)(!1),[p,F]=(0,n.useState)(String(o??"")),z=(0,n.useRef)(null);if((0,n.useEffect)(()=>{c&&z.current&&(z.current.focus(),z.current.select())},[c]),!c)return(0,t.jsx)("div",{onDoubleClick:()=>{F(String(o??"")),u(!0)},className:"cursor-text min-h-[1.5em]",title:"Double-click to edit",children:String(o??"")});let C=()=>{u(!1),p!==String(o??"")&&l(p)};return(0,t.jsx)("input",{ref:z,type:"text",value:p,onChange:S=>F(S.target.value),onBlur:C,"aria-label":"Edit cell value",onKeyDown:S=>{S.key==="Enter"&&C(),S.key==="Escape"&&u(!1)},className:(0,m.cn)("w-full border border-blue-500 rounded px-1 py-0.5 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 outline-none",ye[i])})}function Nr(o,l){let{columns:i,data:c,rowKey:u,mode:p="client",sortable:F=!1,multiSort:z=!1,sort:C,defaultSort:S,onSort:I,pagination:R=!1,page:re,onPageChange:b,onPageSizeChange:ie,totalItems:it,selectable:ae=!1,selectionMode:fe="multiple",selectedRows:G,onSelectionChange:_,searchable:Ve=!1,searchPlaceholder:dt="Search...",searchValue:ne,onSearch:de,filters:B,onFilterChange:J,expandable:oe=!1,expandedContent:Oe,expandedRows:he,onExpandChange:We,editable:ct=!1,onCellEdit:gt,reorderable:x=!1,onReorder:Ge,columnReorderable:L=!1,onColumnReorder:Be,columnToggle:Ke=!1,hiddenColumns:ve,onColumnVisibilityChange:je,groupBy:V,renderGroupHeader:$e,exportable:qe=!1,exportFormats:ut=["csv","json"],exportFilename:Ue="export",virtualized:K=!1,rowHeight:j=40,virtualHeight:xe=400,density:f="default",striped:Xe=!1,bordered:ke=!1,borderless:pt=!1,stickyHeader:_e=!1,maxHeight:ce,loading:mt=!1,loadingRows:bt=5,emptyState:yt,showFooter:ft=!1,onRowClick:we,onRowDoubleClick:Je,onRowContextMenu:Qe,className:ht,rowClassName:Ce,cellClassName:vt,headerClassName:xt}=o,[kt,Ye]=(0,n.useState)(S??[]),[wt,Ct]=(0,n.useState)(1),[Nt,St]=(0,n.useState)(typeof R=="object"?R.pageSize??10:10),[Rt,Ne]=(0,n.useState)([]),[Tt,Ze]=(0,n.useState)(""),[Dt,Se]=(0,n.useState)([]),[Mt,Et]=(0,n.useState)([]),[Ft,zt]=(0,n.useState)(()=>i.flatMap(e=>e.hidden?[e.key]:[])),[Re,Pt]=(0,n.useState)({}),[ge,At]=(0,n.useState)(()=>i.map(e=>e.key)),[$,et]=(0,n.useState)(null),[Q,tt]=(0,n.useState)(null),[ue,rt]=(0,n.useState)(!1),[Ht,It]=(0,n.useState)(new Set),Te=(0,n.useRef)(null),[at,Lt]=(0,n.useState)(0),De=(0,n.useRef)(null),q=C??kt,P=re??wt,T=G??Rt,pe=ne??Tt,O=B??Dt,se=he??Mt,U=ve??Ft,A=R?typeof R=="object"?R:{pageSize:10,pageSizeOptions:[10,25,50,100]}:null,le=A?.pageSize??Nt,H=(0,n.useMemo)(()=>{let e=new Map(i.map(s=>[s.key,s])),r=ge.flatMap(s=>{let d=e.get(s);return d?[d]:[]}),a=new Set(r.map(s=>s.key));for(let s of i)a.has(s.key)||(r.push(s),a.add(s.key));return r.filter(s=>!U.includes(s.key))},[i,ge,U]),N=(0,n.useMemo)(()=>{if(p==="server")return c;let e=[...c];if(pe){let r=pe.toLowerCase();e=e.filter(a=>H.some(s=>{let d=E(a,s.key);return String(d??"").toLowerCase().includes(r)}))}if(O.length>0&&(e=e.filter(r=>O.every(a=>xr(E(r,a.column),a)))),q.length>0){let r=new Map(i.map(a=>[a.key,a]));e.sort((a,s)=>{for(let d of q){if(!d.direction)continue;let y=r.get(d.key),k=y?.sortComparator?y.sortComparator(a,s):vr(E(a,d.key),E(s,d.key));if(k!==0)return d.direction==="asc"?k:-k}return 0})}return e},[c,p,pe,O,q,H,i]),nt=(0,n.useMemo)(()=>{if(!V)return null;let e=Array.isArray(V)?V:[V],r=new Map;for(let a of N){let s=e.map(y=>String(E(a,y)??"")).join(" / "),d=r.get(s)??[];d.push(a),r.set(s,d)}return r},[N,V]),Me=it??N.length,Y=Math.max(1,Math.ceil(Me/le)),Vt=(0,n.useMemo)(()=>{if(!A||p==="server")return N;let e=(P-1)*le;return N.slice(e,e+le)},[N,A,P,le,p]),v=A?Vt:N,Z=(0,n.useMemo)(()=>{if(!K)return{start:0,end:v.length};let e=Math.floor(at/j),r=Math.ceil(xe/j),a=5;return{start:Math.max(0,e-a),end:Math.min(v.length,e+r+a)}},[K,at,j,xe,v.length]),Ee=(0,n.useCallback)(e=>{C||Ye(e),I?.(e)},[C,I]),Ot=(0,n.useCallback)(e=>{let r=q.find(s=>s.key===e),a;if(!r||!r.direction?a="asc":r.direction==="asc"?a="desc":a=null,z){let s=q.filter(d=>d.key!==e);a&&s.push({key:e,direction:a}),Ee(s)}else Ee(a?[{key:e,direction:a}]:[])},[q,z,Ee]),W=(0,n.useCallback)(e=>{let r=Math.max(1,Math.min(e,Y));re||Ct(r),b?.(r)},[re,b,Y]),Wt=(0,n.useCallback)(e=>{St(e),W(1),ie?.(e)},[W,ie]),Gt=(0,n.useCallback)(e=>{let r;fe==="single"?r=T.includes(e)?[]:[e]:r=T.includes(e)?T.filter(a=>a!==e):[...T,e],G||Ne(r),_?.(r)},[fe,T,G,_]),Fe=(0,n.useCallback)(()=>{let e=v.map((r,a)=>be(r,a,u));G||Ne(e),_?.(e)},[v,u,G,_]),ze=(0,n.useCallback)(()=>{G||Ne([]),_?.([])},[G,_]),Pe=v.length>0&&v.every((e,r)=>T.includes(be(e,r,u))),Bt=!Pe&&v.some((e,r)=>T.includes(be(e,r,u))),Kt=(0,n.useCallback)(e=>{let r=se.includes(e)?se.filter(a=>a!==e):[...se,e];he||Et(r),We?.(r)},[se,he,We]),jt=(0,n.useCallback)(e=>{let r=e.target.value;ne||Ze(r),de?.(r),W(1)},[ne,de,W]),$t=(0,n.useCallback)(e=>{let r=[...O.filter(a=>a.column!==e.column),e];B||Se(r),J?.(r)},[O,B,J]),qt=(0,n.useCallback)(e=>{let r=O.filter(a=>a.column!==e);B||Se(r),J?.(r)},[O,B,J]),Ut=(0,n.useCallback)(e=>{let r=U.includes(e)?U.filter(a=>a!==e):[...U,e];ve||zt(r),je?.(r)},[U,ve,je]),Xt=(0,n.useCallback)((e,r)=>{e.preventDefault(),e.stopPropagation();let a=e.clientX,s=Re[r]??e.currentTarget.parentElement?.getBoundingClientRect().width??100,d=i.find(w=>w.key===r),y=d?.minWidth??50,k=d?.maxWidth??1/0,g=w=>{let X=w.clientX-a,M=Math.min(k,Math.max(y,s+X));Pt(te=>({...te,[r]:M}))},D=()=>{document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",D)};document.addEventListener("mousemove",g),document.addEventListener("mouseup",D)},[Re,i]),_t=(0,n.useCallback)(e=>{x&&et(e)},[x]),Jt=(0,n.useCallback)((e,r)=>{!x||$===null||e.preventDefault()},[x,$]),Qt=(0,n.useCallback)(e=>{!x||$===null||$===e||(Ge?.($,e),et(null))},[x,$,Ge]),Yt=(0,n.useCallback)(e=>{L&&tt(e)},[L]),Zt=(0,n.useCallback)(e=>{if(!L||!Q||Q===e)return;let r=[...ge],a=r.indexOf(Q),s=r.indexOf(e);a===-1||s===-1||(r.splice(a,1),r.splice(s,0,Q),At(r),Be?.(Q,e),tt(null))},[L,Q,ge,Be]),Ae=(0,n.useCallback)(e=>{let r=H.filter(w=>w.type!=="actions"&&w.type!=="selection"&&w.type!=="expand"),a=N,s,d,y;if(e==="csv"){let w=r.map(M=>String(M.header)).join(","),X=a.map(M=>r.map(te=>{let Le=String(E(M,te.key)??"");return Le.includes(",")?`"${Le}"`:Le}).join(","));s=[w,...X].join(`
2
- `),d="text/csv",y="csv"}else{let w=a.map(X=>{let M={};for(let te of r)M[te.key]=E(X,te.key);return M});s=JSON.stringify(w,null,2),d="application/json",y="json"}let k=new Blob([s],{type:d}),g=URL.createObjectURL(k),D=document.createElement("a");D.href=g,D.download=`${Ue}.${y}`,D.click(),URL.revokeObjectURL(g)},[H,N,Ue]);(0,n.useEffect)(()=>{if(!ue)return;let e=r=>{De.current&&!De.current.contains(r.target)&&rt(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[ue]),(0,n.useImperativeHandle)(l,()=>({getVisibleData:()=>v,resetFilters:()=>{B||Se([]),ne||Ze(""),J?.([]),de?.("")},resetSort:()=>{C||Ye([]),I?.([])},selectAll:Fe,deselectAll:ze,exportData:Ae,scrollToRow:e=>{Te.current&&K&&(Te.current.scrollTop=e*j)}}),[v,B,ne,C,J,de,I,Fe,ze,Ae,K,j]);let He=e=>{let r={},a=Re[e.key]??e.width;return a&&(r.width=typeof a=="number"?`${a}px`:a,r.minWidth=typeof a=="number"?`${a}px`:a),e.sticky&&(r.position="sticky",r[e.sticky]=0,r.zIndex=10),r},ee=H.length+(ae?1:0)+(oe?1:0)+(x?1:0),er=e=>{let r=F&&e.sortable!==!1&&e.type!=="actions",a=q.find(d=>d.key===e.key),s=e.filterable&&(e.filterType||e.filterOptions);return(0,t.jsxs)("th",{className:(0,m.cn)(h[f],ye[f],"font-semibold text-gray-700 dark:text-gray-300 whitespace-nowrap",e.align==="center"&&"text-center",e.align==="right"&&"text-right",r&&"cursor-pointer select-none hover:bg-gray-100 dark:hover:bg-gray-700",ke&&"border border-gray-200 dark:border-gray-700",e.sticky&&"bg-gray-50 dark:bg-gray-800",e.headerClassName,xt),style:He(e),onClick:r?()=>Ot(e.key):void 0,draggable:L,onDragStart:L?()=>Yt(e.key):void 0,onDragOver:L?d=>d.preventDefault():void 0,onDrop:L?()=>Zt(e.key):void 0,"aria-sort":a?.direction==="asc"?"ascending":a?.direction==="desc"?"descending":void 0,children:[(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[e.renderHeader?e.renderHeader(e):e.header,r&&(0,t.jsx)("span",{className:"inline-flex ml-1",children:a?.direction==="asc"?(0,t.jsx)(gr,{}):a?.direction==="desc"?(0,t.jsx)(ur,{}):(0,t.jsx)(pr,{})}),s&&(0,t.jsx)(wr,{column:e,value:O.find(d=>d.column===e.key),onApply:$t,onClear:()=>qt(e.key)})]}),e.resizable!==!1&&(0,t.jsx)("div",{className:"absolute top-0 right-0 w-1 h-full cursor-col-resize hover:bg-blue-500 opacity-0 hover:opacity-100",onMouseDown:d=>Xt(d,e.key)})]},e.key)},Ie=(e,r,a)=>{let s=be(e,a,u),d=T.includes(s),y=se.includes(s),k=typeof Ce=="function"?Ce(e,a):Ce;return(0,t.jsxs)(n.default.Fragment,{children:[(0,t.jsxs)("tr",{className:(0,m.cn)("border-b border-gray-200 dark:border-gray-700 transition-colors",Xe&&a%2===1&&"bg-gray-50/50 dark:bg-gray-800/50",d&&"bg-blue-50 dark:bg-blue-900/20",we&&"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50",$===r&&"opacity-50",k),onClick:we?()=>we(e,a):void 0,onDoubleClick:Je?()=>Je(e,a):void 0,onContextMenu:Qe?g=>Qe(e,a,g):void 0,draggable:x,onDragStart:x?()=>_t(r):void 0,onDragOver:x?g=>Jt(g,r):void 0,onDrop:x?()=>Qt(r):void 0,"data-row-key":s,"aria-selected":ae?d:void 0,children:[x&&(0,t.jsx)("td",{className:(0,m.cn)(h[f],"cursor-grab active:cursor-grabbing"),children:(0,t.jsx)(br,{})}),ae&&(0,t.jsx)("td",{className:(0,m.cn)(h[f],"w-10"),children:(0,t.jsx)("input",{type:"checkbox",checked:d,onChange:()=>Gt(s),onClick:g=>g.stopPropagation(),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":`Select row ${s}`})}),oe&&(0,t.jsx)("td",{className:(0,m.cn)(h[f],"w-10"),children:(0,t.jsx)("button",{type:"button",onClick:g=>{g.stopPropagation(),Kt(s)},className:"p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer","aria-label":y?"Collapse row":"Expand row","aria-expanded":y,children:(0,t.jsx)(st,{className:(0,m.cn)("transition-transform",y&&"rotate-180")})})}),H.map(g=>{let D=E(e,g.key),w=g.colSpan?.(e,a);if(w===0)return null;let X=ct&&g.editable!==!1&&g.type!=="actions";return(0,t.jsx)("td",{className:(0,m.cn)(h[f],ye[f],"text-gray-700 dark:text-gray-300",g.align==="center"&&"text-center",g.align==="right"&&"text-right",ke&&"border border-gray-200 dark:border-gray-700",g.sticky&&(d?"bg-blue-50 dark:bg-blue-900/20":Xe&&a%2===1?"bg-gray-50/50 dark:bg-gray-800/50":"bg-white dark:bg-gray-900"),g.cellClassName,vt),style:He(g),colSpan:w,children:X?(0,t.jsx)(Cr,{value:D,onSave:M=>gt?.(s,g.key,M),density:f}):g.render?g.render(D,e,a):String(D??"")},g.key)})]}),oe&&y&&Oe&&(0,t.jsx)("tr",{className:"bg-gray-50 dark:bg-gray-800/70",children:(0,t.jsx)("td",{colSpan:ee,className:(0,m.cn)(h[f]),children:Oe(e,a)})})]},s)},tr=()=>{if(mt)return Array.from({length:bt}).map((e,r)=>(0,t.jsx)(kr,{cols:ee,density:f},r));if(v.length===0)return(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:ee,className:(0,m.cn)("text-center text-gray-400 dark:text-gray-500",h[f]),children:yt??"No data available"})});if(nt){let e=[],r=0;for(let[a,s]of nt){let d=Ht.has(a);if(e.push((0,t.jsx)("tr",{className:"bg-gray-100 dark:bg-gray-800 font-medium",children:(0,t.jsx)("td",{colSpan:ee,className:(0,m.cn)(h[f],"cursor-pointer"),onClick:()=>{It(y=>{let k=new Set(y);return k.has(a)?k.delete(a):k.add(a),k})},children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(st,{className:(0,m.cn)("transition-transform",d&&"-rotate-90")}),$e?$e(a,E(s[0],Array.isArray(V)?V[0]:V),s):`${a} (${s.length})`]})})},`group-${a}`)),d)r+=s.length;else for(let y=0;y<s.length;y++)e.push(Ie(s[y],r,r)),r++}return e}if(K){let e=[];for(let r=Z.start;r<Z.end;r++)e.push(Ie(v[r],r,r));return(0,t.jsxs)(t.Fragment,{children:[Z.start>0&&(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:ee,style:{height:Z.start*j,padding:0}})}),e,Z.end<v.length&&(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:ee,style:{height:(v.length-Z.end)*j,padding:0}})})]})}return v.map((e,r)=>Ie(e,r,r))},rr=()=>!ft||!H.some(r=>r.aggregate)?null:(0,t.jsx)("tfoot",{children:(0,t.jsxs)("tr",{className:"bg-gray-50 dark:bg-gray-800 font-semibold border-t-2 border-gray-300 dark:border-gray-600",children:[x&&(0,t.jsx)("td",{className:h[f]}),ae&&(0,t.jsx)("td",{className:h[f]}),oe&&(0,t.jsx)("td",{className:h[f]}),H.map(r=>(0,t.jsx)("td",{className:(0,m.cn)(h[f],ye[f],"text-gray-700 dark:text-gray-300",r.align==="center"&&"text-center",r.align==="right"&&"text-right",ke&&"border border-gray-200 dark:border-gray-700"),style:He(r),children:r.aggregate?r.renderAggregate?r.renderAggregate(lt(N,r.key,r.aggregate),N):`${r.aggregate==="count"?"":r.aggregate==="avg"?"Avg: ":r.aggregate==="sum"?"Total: ":r.aggregate==="min"?"Min: ":"Max: "}${lt(N,r.key,r.aggregate).toLocaleString()}`:""},r.key))]})});return(0,t.jsxs)("div",{className:(0,m.cn)("flex flex-col gap-3",ht),children:[(Ve||qe||Ke)&&(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 flex-1",children:[Ve&&(0,t.jsxs)("div",{className:"relative flex-1 max-w-xs",children:[(0,t.jsx)("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:(0,t.jsx)(mr,{})}),(0,t.jsx)("input",{type:"text",value:pe,onChange:jt,placeholder:dt,className:"w-full pl-9 pr-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500","aria-label":"Search table"})]}),T.length>0&&(0,t.jsxs)("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:[T.length," selected"]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[Ke&&(0,t.jsxs)("div",{className:"relative",ref:De,children:[(0,t.jsx)("button",{type:"button",onClick:()=>rt(!ue),className:"p-1.5 rounded-md border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":"Toggle columns",title:"Toggle columns",children:(0,t.jsx)(hr,{})}),ue&&(0,t.jsx)("div",{className:"absolute z-50 right-0 top-full mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg p-2 min-w-[180px]",children:i.filter(e=>e.type!=="selection"&&e.type!=="expand").map(e=>(0,t.jsxs)("label",{className:"flex items-center gap-2 px-2 py-1.5 text-sm rounded hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:[(0,t.jsx)("input",{type:"checkbox",checked:!U.includes(e.key),onChange:()=>Ut(e.key),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer"}),(0,t.jsx)("span",{className:"text-gray-700 dark:text-gray-300",children:String(e.header)})]},e.key))})]}),qe&&ut.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>Ae(e),className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs font-medium rounded-md border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",title:`Export as ${e.toUpperCase()}`,children:[(0,t.jsx)(fr,{}),e.toUpperCase()]},e))]})]}),(0,t.jsx)("div",{ref:Te,className:(0,m.cn)("overflow-auto rounded-lg",!pt&&"border border-gray-200 dark:border-gray-700",_e&&"relative"),style:ce?{maxHeight:typeof ce=="number"?`${ce}px`:ce}:K?{maxHeight:xe,overflow:"auto"}:void 0,onScroll:K?e=>Lt(e.target.scrollTop):void 0,children:(0,t.jsxs)("table",{className:"w-full text-left",children:[(0,t.jsx)("thead",{className:(0,m.cn)("bg-gray-50 dark:bg-gray-800 text-xs uppercase",_e&&"sticky top-0 z-20"),children:(0,t.jsxs)("tr",{children:[x&&(0,t.jsx)("th",{className:(0,m.cn)(h[f],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),ae&&(0,t.jsx)("th",{className:(0,m.cn)(h[f],"w-10"),children:fe==="multiple"&&(0,t.jsx)("input",{type:"checkbox",checked:Pe,ref:e=>{e&&(e.indeterminate=Bt)},onChange:Pe?ze:Fe,className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":"Select all rows"})}),oe&&(0,t.jsx)("th",{className:(0,m.cn)(h[f],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),H.map(er)]})}),(0,t.jsx)("tbody",{children:tr()}),rr()]})}),A&&(0,t.jsxs)("div",{className:"flex items-center justify-between flex-wrap gap-3 text-sm text-gray-600 dark:text-gray-400",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[A.showTotalItems!==!1&&(0,t.jsxs)("span",{children:[Me," item",Me!==1?"s":""]}),A.showPageSizeSelector!==!1&&A.pageSizeOptions&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{children:"Rows per page:"}),(0,t.jsx)("select",{value:le,onChange:e=>Wt(Number(e.target.value)),className:"border border-gray-300 dark:border-gray-600 rounded px-1.5 py-0.5 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 text-sm",children:A.pageSizeOptions.map(e=>(0,t.jsx)("option",{value:e,children:e},e))})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsxs)("span",{className:"mr-2",children:["Page ",P," of ",Y]}),(0,t.jsx)("button",{type:"button",onClick:()=>W(1),disabled:P<=1,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":"First page",children:"\xAB\xAB"}),(0,t.jsx)("button",{type:"button",onClick:()=>W(P-1),disabled:P<=1,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":"Previous page",children:"\xAB"}),(0,t.jsx)("button",{type:"button",onClick:()=>W(P+1),disabled:P>=Y,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":"Next page",children:"\xBB"}),(0,t.jsx)("button",{type:"button",onClick:()=>W(Y),disabled:P>=Y,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":"Last page",children:"\xBB\xBB"})]})]})]})}var Sr=(0,n.forwardRef)(Nr);0&&(module.exports={DataGrid});
1
+ "use strict";"use client";var xr=Object.create;var Ce=Object.defineProperty;var wr=Object.getOwnPropertyDescriptor;var kr=Object.getOwnPropertyNames;var Cr=Object.getPrototypeOf,Nr=Object.prototype.hasOwnProperty;var Sr=(o,i)=>{for(var d in i)Ce(o,d,{get:i[d],enumerable:!0})},wt=(o,i,d,u)=>{if(i&&typeof i=="object"||typeof i=="function")for(let c of kr(i))!Nr.call(o,c)&&c!==d&&Ce(o,c,{get:()=>i[c],enumerable:!(u=wr(i,c))||u.enumerable});return o};var Rr=(o,i,d)=>(d=o!=null?xr(Cr(o)):{},wt(i||!o||!o.__esModule?Ce(d,"default",{value:o,enumerable:!0}):d,o)),Tr=o=>wt(Ce({},"__esModule",{value:!0}),o);var qr={};Sr(qr,{DataGrid:()=>jr,resetRowKeyWarning:()=>Or});module.exports=Tr(qr);var n=Rr(require("react"),1),f=require("../../lib/cn.cjs"),Nt=require("../../lib/csv.cjs"),D=require("../../lib/i18n.cjs"),t=require("react/jsx-runtime"),k={compact:"px-3 py-1.5",default:"px-4 py-3",comfortable:"px-6 py-4"},Ne={compact:"text-xs",default:"text-sm",comfortable:"text-base"},Dr=()=>(0,t.jsx)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:(0,t.jsx)("path",{d:"M8 3l4 5H4l4-5z"})}),Er=()=>(0,t.jsx)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:(0,t.jsx)("path",{d:"M8 13l4-5H4l4 5z"})}),Gr=()=>(0,t.jsx)("svg",{className:"w-3.5 h-3.5 opacity-30",viewBox:"0 0 16 16",fill:"currentColor",children:(0,t.jsx)("path",{d:"M8 3l3 4H5l3-4zM8 13l3-4H5l3 4z"})}),kt=({className:o})=>(0,t.jsx)("svg",{className:(0,f.cn)("w-4 h-4",o),viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})}),Mr=()=>(0,t.jsx)("svg",{className:"w-4 h-4 text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M9 3.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM2 9a7 7 0 1112.452 4.391l3.328 3.329a.75.75 0 11-1.06 1.06l-3.329-3.328A7 7 0 012 9z",clipRule:"evenodd"})}),Fr=()=>(0,t.jsx)("svg",{className:"w-4 h-4 text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("path",{d:"M7 4a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3zM7 10.5a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3zM7 17a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3z"})}),Pr=()=>(0,t.jsx)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M2.628 1.601C5.028 1.206 7.49 1 10 1s4.973.206 7.372.601a.75.75 0 01.628.74v2.288a2.25 2.25 0 01-.659 1.59l-4.682 4.683a2.25 2.25 0 00-.659 1.59v3.037c0 .684-.31 1.33-.844 1.757l-1.937 1.55A.75.75 0 018 18.25v-5.757a2.25 2.25 0 00-.659-1.591L2.659 6.22A2.25 2.25 0 012 4.629V2.34a.75.75 0 01.628-.74z",clipRule:"evenodd"})}),zr=()=>(0,t.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:[(0,t.jsx)("path",{d:"M10.75 2.75a.75.75 0 00-1.5 0v8.614L6.295 8.235a.75.75 0 10-1.09 1.03l4.25 4.5a.75.75 0 001.09 0l4.25-4.5a.75.75 0 00-1.09-1.03l-2.955 3.129V2.75z"}),(0,t.jsx)("path",{d:"M3.5 12.75a.75.75 0 00-1.5 0v2.5A2.75 2.75 0 004.75 18h10.5A2.75 2.75 0 0018 15.25v-2.5a.75.75 0 00-1.5 0v2.5c0 .69-.56 1.25-1.25 1.25H4.75c-.69 0-1.25-.56-1.25-1.25v-2.5z"})]}),Ir=()=>(0,t.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M2.5 3A1.5 1.5 0 001 4.5v11A1.5 1.5 0 002.5 17h15a1.5 1.5 0 001.5-1.5v-11A1.5 1.5 0 0017.5 3h-15zM2.5 4.5h6v11h-6v-11zm7.5 0h7.5v11H10v-11z",clipRule:"evenodd"})});function qe(o,i,d){return typeof d=="function"?d(o,i):String(typeof d=="string"?o[d]:i)}var $e=!1;function Or(){$e=!1}function Ar(){$e||($e=!0,console.warn("[@synertech/ui] DataGrid has no `rowKey`: each row is known by its position in `data`. Selection, expansion and edits follow that position when `data` is refetched or reordered, and from one page to the next in server mode. Pass `rowKey` to tie them to the row."))}function F(o,i){return o[i]}function Lr(o,i){return o==null&&i==null?0:o==null?-1:i==null?1:typeof o=="number"&&typeof i=="number"?o-i:String(o).localeCompare(String(i))}function Hr(o,i){let d=String(o??"").toLowerCase(),u=i.value.toLowerCase();switch(i.operator){case"contains":return d.includes(u);case"equals":return d===u;case"startsWith":return d.startsWith(u);case"endsWith":return d.endsWith(u);case"gt":return Number(o)>Number(i.value);case"gte":return Number(o)>=Number(i.value);case"lt":return Number(o)<Number(i.value);case"lte":return Number(o)<=Number(i.value);case"isEmpty":return d==="";case"isNotEmpty":return d!=="";default:return!0}}function Ct(o,i,d){let u=[];for(let c of o){let b=Number(F(c,i));isNaN(b)||u.push(b)}if(u.length===0)return 0;switch(d){case"sum":return u.reduce((c,b)=>c+b,0);case"avg":return u.reduce((c,b)=>c+b,0)/u.length;case"count":return u.length;case"min":return Math.min(...u);case"max":return Math.max(...u)}}function Vr(o,i,d){if(o==="count")return i;let u=o==="avg"?d.dataGridAggregateAvg:o==="sum"?d.dataGridAggregateSum:o==="min"?d.dataGridAggregateMin:d.dataGridAggregateMax;return(0,D.formatUILabel)(u,{value:i})}function Kr({cols:o,density:i}){return(0,t.jsx)("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:Array.from({length:o}).map((d,u)=>(0,t.jsx)("td",{className:k[i],children:(0,t.jsx)("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"})},u))})}function Wr({column:o,value:i,onApply:d,onClear:u,labels:c}){let b=o.filterType??"text",L=String(o.header),P=b==="number"?[{value:"equals",label:c.dataGridOperatorEquals},{value:"gt",label:c.dataGridOperatorGreaterThan},{value:"gte",label:c.dataGridOperatorGreaterOrEqual},{value:"lt",label:c.dataGridOperatorLessThan},{value:"lte",label:c.dataGridOperatorLessOrEqual}]:[{value:"contains",label:c.dataGridOperatorContains},{value:"equals",label:c.dataGridOperatorEquals},{value:"startsWith",label:c.dataGridOperatorStartsWith},{value:"endsWith",label:c.dataGridOperatorEndsWith},{value:"isEmpty",label:c.dataGridOperatorIsEmpty},{value:"isNotEmpty",label:c.dataGridOperatorIsNotEmpty}],S=g=>g&&P.some(R=>R.value===g.operator)?g.operator:P[0].value,[E,w]=(0,n.useState)(!1),[G,re]=(0,n.useState)(()=>S(i)),[$,H]=(0,n.useState)(i?.value??""),ae=(0,n.useRef)(null),z=()=>{E||(re(S(i)),H(i?.value??"")),w(!E)};return(0,n.useEffect)(()=>{let g=R=>{ae.current&&!ae.current.contains(R.target)&&w(!1)};return E&&document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[E]),(0,t.jsxs)("div",{className:"relative inline-block",ref:ae,onClick:g=>g.stopPropagation(),children:[(0,t.jsx)("button",{type:"button",onClick:z,className:(0,f.cn)("p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer",i&&"text-blue-600 dark:text-blue-400"),"aria-label":(0,D.formatUILabel)(c.dataGridFilterColumn,{column:L}),children:(0,t.jsx)(Pr,{})}),E&&(0,t.jsx)("div",{className:"absolute z-50 top-full left-0 mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg p-3 min-w-[220px]",children:b==="select"&&o.filterOptions?(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[o.filterOptions.map(g=>(0,t.jsxs)("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[(0,t.jsx)("input",{type:"radio",name:`filter-${o.key}`,value:g,checked:$===g,onChange:()=>H(g),className:"cursor-pointer"}),(0,t.jsx)("span",{className:"text-gray-700 dark:text-gray-300",children:g})]},g)),(0,t.jsxs)("div",{className:"flex gap-2 mt-2",children:[(0,t.jsx)("button",{type:"button",onClick:()=>{d({column:o.key,operator:"equals",value:$}),w(!1)},className:"px-2 py-1 text-xs bg-blue-600 text-white rounded hover:bg-blue-700 cursor-pointer",children:c.dataGridFilterApply}),(0,t.jsx)("button",{type:"button",onClick:()=>{H(""),u(),w(!1)},className:"px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 cursor-pointer",children:c.dataGridFilterClear})]})]}):(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)("select",{value:G,onChange:g=>re(g.target.value),className:"text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200",children:P.map(g=>(0,t.jsx)("option",{value:g.value,children:g.label},g.value))}),G!=="isEmpty"&&G!=="isNotEmpty"&&(0,t.jsx)("input",{type:b==="number"?"number":b==="date"?"date":"text",value:$,onChange:g=>H(g.target.value),placeholder:c.dataGridFilterValuePlaceholder,className:"text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200",autoFocus:!0,"aria-label":(0,D.formatUILabel)(c.dataGridFilterValue,{column:L})}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("button",{type:"button",onClick:()=>{d({column:o.key,operator:G,value:$}),w(!1)},className:"px-2 py-1 text-xs bg-blue-600 text-white rounded hover:bg-blue-700 cursor-pointer",children:c.dataGridFilterApply}),(0,t.jsx)("button",{type:"button",onClick:()=>{H(""),u(),w(!1)},className:"px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 cursor-pointer",children:c.dataGridFilterClear})]})]})})]})}function Br({value:o,onSave:i,density:d,labels:u}){let[c,b]=(0,n.useState)(!1),[L,P]=(0,n.useState)(String(o??"")),S=(0,n.useRef)(null);if((0,n.useEffect)(()=>{c&&S.current&&(S.current.focus(),S.current.select())},[c]),!c)return(0,t.jsx)("div",{onDoubleClick:()=>{P(String(o??"")),b(!0)},className:"cursor-text min-h-[1.5em]",title:u.dataGridEditHint,children:String(o??"")});let E=()=>{b(!1),L!==String(o??"")&&i(L)};return(0,t.jsx)("input",{ref:S,type:"text",value:L,onChange:w=>P(w.target.value),onBlur:E,"aria-label":u.dataGridEditCell,onKeyDown:w=>{w.key==="Enter"&&E(),w.key==="Escape"&&b(!1)},className:(0,f.cn)("w-full border border-blue-500 rounded px-1 py-0.5 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 outline-none",Ne[d])})}function Ur(o,i){let{columns:d,data:u,rowKey:c,mode:b="client",sortable:L=!1,multiSort:P=!1,sort:S,defaultSort:E,onSort:w,pagination:G=!1,page:re,onPageChange:$,onPageSizeChange:H,totalItems:ae,selectable:z=!1,selectionMode:g="multiple",selectedRows:R,onSelectionChange:V,searchable:Xe=!1,searchPlaceholder:St,searchValue:me,onSearch:fe,filters:X,onFilterChange:ne,expandable:oe=!1,expandedContent:_e,expandedRows:Se,onExpandChange:Je,editable:Qe=!1,onCellEdit:Rt,reorderable:se=!1,onReorder:Ye,columnReorderable:K=!1,onColumnReorder:Ze,columnToggle:et=!1,hiddenColumns:Re,onColumnVisibilityChange:tt,groupBy:W,renderGroupHeader:rt,exportable:at=!1,exportFormats:Tt=["csv","json"],exportFilename:nt="export",exportNeutralizeFormulas:ot,virtualized:_=!1,rowHeight:J=40,virtualHeight:Te=400,density:h="default",striped:st=!1,bordered:De=!1,borderless:Dt=!1,stickyHeader:it=!1,maxHeight:he,loading:Et=!1,loadingRows:Gt=5,emptyState:Mt,labels:Ft,showFooter:Pt=!1,onRowClick:Ee,onRowDoubleClick:lt,onRowContextMenu:dt,className:zt,rowClassName:Ge,cellClassName:It,headerClassName:Ot}=o,y=(0,D.useUILabels)(Ft),[At,ct]=(0,n.useState)(E??[]),[Lt,Ht]=(0,n.useState)(1),ie=typeof G=="object"?G.pageSize:void 0,[Vt,ut]=(0,n.useState)(ie??10),[Kt,Wt]=(0,n.useState)(ie);ie!==Kt&&(Wt(ie),ie!==void 0&&ut(ie));let[Bt,ve]=(0,n.useState)([]),[Ut,gt]=(0,n.useState)(""),[jt,Me]=(0,n.useState)([]),[qt,$t]=(0,n.useState)([]),[Xt,_t]=(0,n.useState)(()=>d.flatMap(e=>e.hidden?[e.key]:[])),[Fe,Jt]=(0,n.useState)({}),[xe,Qt]=(0,n.useState)(()=>d.map(e=>e.key)),[Q,Pe]=(0,n.useState)(null),[le,pt]=(0,n.useState)(null),[we,mt]=(0,n.useState)(!1),[Yt,Zt]=(0,n.useState)(new Set),ze=(0,n.useRef)(null),[bt,er]=(0,n.useState)(0),Ie=(0,n.useRef)(null),Oe=(0,n.useRef)(!1),B=S??At,yt=re??Lt,C=R??Bt,ke=me??Ut,U=X??jt,be=Se??qt,Y=Re??Xt,de=G?typeof G=="object"?G:{pageSize:10,pageSizeOptions:[10,25,50,100]}:null,ye=Vt;!c&&(z||oe||Qe||se)&&Ar();let ft=e=>qe(e.row,e.sourceIndex,c),I=(0,n.useMemo)(()=>{let e=new Map(d.map(s=>[s.key,s])),r=xe.flatMap(s=>{let l=e.get(s);return l?[l]:[]}),a=new Set(r.map(s=>s.key));for(let s of d)a.has(s.key)||(r.push(s),a.add(s.key));return r.filter(s=>!Y.includes(s.key))},[d,xe,Y]),Z=(0,n.useMemo)(()=>{let e=u.map((r,a)=>({row:r,sourceIndex:a}));if(b==="server")return e;if(ke){let r=ke.toLowerCase();e=e.filter(({row:a})=>I.some(s=>{let l=F(a,s.key);return String(l??"").toLowerCase().includes(r)}))}if(U.length>0&&(e=e.filter(({row:r})=>U.every(a=>Hr(F(r,a.column),a)))),B.length>0){let r=new Map(d.map(a=>[a.key,a]));e.sort((a,s)=>{for(let l of B){if(!l.direction)continue;let m=r.get(l.key),v=m?.sortComparator?m.sortComparator(a.row,s.row):Lr(F(a.row,l.key),F(s.row,l.key));if(v!==0)return l.direction==="asc"?v:-v}return 0})}return e},[u,b,ke,U,B,I,d]),ce=(0,n.useMemo)(()=>Z.map(e=>e.row),[Z]),ht=(0,n.useMemo)(()=>{if(!W)return null;let e=Array.isArray(W)?W:[W],r=new Map;for(let a of Z){let s=e.map(m=>String(F(a.row,m)??"")).join(" / "),l=r.get(s)??[];l.push(a),r.set(s,l)}return r},[Z,W]),Ae=ae??ce.length,ee=Math.max(1,Math.ceil(Ae/ye)),O=b==="server"&&ae===void 0?yt:Math.min(Math.max(1,yt),ee),vt=de!==null,A=(0,n.useMemo)(()=>{if(!vt||b==="server")return Z;let e=(O-1)*ye;return Z.slice(e,e+ye)},[Z,vt,O,ye,b]),j=(0,n.useMemo)(()=>A.map(e=>e.row),[A]),ue=(0,n.useMemo)(()=>{if(!_)return{start:0,end:j.length};let e=Math.floor(bt/J),r=Math.ceil(Te/J),a=5;return{start:Math.max(0,e-a),end:Math.min(j.length,e+r+a)}},[_,bt,J,Te,j.length]),Le=(0,n.useCallback)(e=>{S||ct(e),w?.(e)},[S,w]),tr=(0,n.useCallback)(e=>{let r=B.find(s=>s.key===e),a;if(!r||!r.direction?a="asc":r.direction==="asc"?a="desc":a=null,P){let s=B.filter(l=>l.key!==e);a&&s.push({key:e,direction:a}),Le(s)}else Le(a?[{key:e,direction:a}]:[])},[B,P,Le]),N=(0,n.useCallback)(e=>{let r=Math.max(1,Math.min(e,ee));re||Ht(r),$?.(r)},[re,$,ee]),rr=(0,n.useCallback)(e=>{ut(e),N(1),H?.(e)},[N,H]),ar=(0,n.useCallback)(e=>{let r;g==="single"?r=C.includes(e)?[]:[e]:r=C.includes(e)?C.filter(a=>a!==e):[...C,e],R||ve(r),V?.(r)},[g,C,R,V]),He=(0,n.useMemo)(()=>new Set(C),[C]),Ve=(0,n.useCallback)(()=>{let e=new Set(C),r=[...C];for(let a of A){let s=qe(a.row,a.sourceIndex,c);e.has(s)||(e.add(s),r.push(s))}R||ve(r),V?.(r)},[A,c,C,R,V]),xt=(0,n.useCallback)(()=>{R||ve([]),V?.([])},[R,V]),nr=(0,n.useCallback)(()=>{let e=new Set(A.map(a=>qe(a.row,a.sourceIndex,c))),r=C.filter(a=>!e.has(a));R||ve(r),V?.(r)},[A,c,C,R,V]),Ke=z?A.map(ft):[],We=Ke.length>0&&Ke.every(e=>He.has(e)),or=!We&&Ke.some(e=>He.has(e)),sr=(0,n.useCallback)(e=>{let r=be.includes(e)?be.filter(a=>a!==e):[...be,e];Se||$t(r),Je?.(r)},[be,Se,Je]),ir=(0,n.useCallback)(e=>{let r=e.target.value;me||gt(r),fe?.(r),N(1)},[me,fe,N]),lr=(0,n.useCallback)(e=>{let r=[...U.filter(a=>a.column!==e.column),e];X||Me(r),ne?.(r),N(1)},[U,X,ne,N]),dr=(0,n.useCallback)(e=>{let r=U.filter(a=>a.column!==e);X||Me(r),ne?.(r),N(1)},[U,X,ne,N]),cr=(0,n.useCallback)(e=>{let r=Y.includes(e)?Y.filter(a=>a!==e):[...Y,e];Re||_t(r),tt?.(r)},[Y,Re,tt]),ur=(0,n.useCallback)((e,r)=>{e.preventDefault(),e.stopPropagation(),Oe.current=!0;let a=e.clientX,s=Fe[r]??e.currentTarget.parentElement?.getBoundingClientRect().width??100,l=d.find(x=>x.key===r),m=l?.minWidth??50,v=l?.maxWidth??1/0,te=x=>{let q=x.clientX-a,M=Math.min(v,Math.max(m,s+q));Jt(pe=>({...pe,[r]:M}))},p=()=>{document.removeEventListener("mousemove",te),document.removeEventListener("mouseup",p),setTimeout(()=>{Oe.current=!1},0)};document.addEventListener("mousemove",te),document.addEventListener("mouseup",p)},[Fe,d]),T=se&&!(b==="client"&&B.some(e=>e.direction)),gr=(0,n.useCallback)((e,r)=>{T&&Pe({key:e,sourceIndex:r})},[T]),pr=(0,n.useCallback)(e=>{!T||Q===null||e.preventDefault()},[T,Q]),mr=(0,n.useCallback)((e,r)=>{!T||Q===null||(Pe(null),Q.key!==e&&Ye?.(Q.sourceIndex,r))},[T,Q,Ye]),br=(0,n.useCallback)(e=>{K&&pt(e)},[K]),yr=(0,n.useCallback)(e=>{if(!K||!le||le===e)return;let r=[...xe],a=r.indexOf(le),s=r.indexOf(e);a===-1||s===-1||(r.splice(a,1),r.splice(s,0,le),Qt(r),Ze?.(le,e),pt(null))},[K,le,xe,Ze]),Be=(0,n.useCallback)(e=>{let r=I.filter(x=>x.type!=="actions"&&x.type!=="selection"&&x.type!=="expand"),a=ce,s,l,m;if(e==="csv")s=(0,Nt.csvDocument)([r.map(x=>String(x.header)),...a.map(x=>r.map(q=>{let M=F(x,q.key);return typeof M=="number"?M:String(M??"")}))],{neutralizeFormulas:ot}),l="text/csv",m="csv";else{let x=a.map(q=>{let M={};for(let pe of r)M[pe.key]=F(q,pe.key);return M});s=JSON.stringify(x,null,2),l="application/json",m="json"}let v=new Blob([s],{type:l}),te=URL.createObjectURL(v),p=document.createElement("a");p.href=te,p.download=`${nt}.${m}`,p.click(),URL.revokeObjectURL(te)},[I,ce,nt,ot]);(0,n.useEffect)(()=>{if(!we)return;let e=r=>{Ie.current&&!Ie.current.contains(r.target)&&mt(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[we]),(0,n.useImperativeHandle)(i,()=>({getVisibleData:()=>j,resetFilters:()=>{X||Me([]),me||gt(""),ne?.([]),fe?.(""),N(1)},resetSort:()=>{S||ct([]),w?.([])},selectAll:Ve,deselectAll:xt,exportData:Be,scrollToRow:e=>{ze.current&&_&&(ze.current.scrollTop=e*J)}}),[j,X,me,S,ne,fe,w,N,Ve,xt,Be,_,J]);let Ue=e=>{let r={},a=Fe[e.key]??e.width;return a&&(r.width=typeof a=="number"?`${a}px`:a,r.minWidth=typeof a=="number"?`${a}px`:a),e.sticky&&(r.position="sticky",r[e.sticky]=0,r.zIndex=10),r},ge=I.length+(z?1:0)+(oe?1:0)+(se?1:0),fr=e=>{let r=L&&e.sortable!==!1&&e.type!=="actions",a=B.find(l=>l.key===e.key),s=e.filterable&&(e.filterType||e.filterOptions);return(0,t.jsxs)("th",{className:(0,f.cn)(k[h],Ne[h],"relative font-semibold text-gray-700 dark:text-gray-300 whitespace-nowrap",e.align==="center"&&"text-center",e.align==="right"&&"text-right",r&&"cursor-pointer select-none hover:bg-gray-100 dark:hover:bg-gray-700",De&&"border border-gray-200 dark:border-gray-700",e.sticky&&"bg-gray-50 dark:bg-gray-800",e.headerClassName,Ot),style:Ue(e),onClick:r?()=>{Oe.current||tr(e.key)}:void 0,draggable:K,onDragStart:K?()=>br(e.key):void 0,onDragOver:K?l=>l.preventDefault():void 0,onDrop:K?()=>yr(e.key):void 0,"aria-sort":a?.direction==="asc"?"ascending":a?.direction==="desc"?"descending":void 0,children:[(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[e.renderHeader?e.renderHeader(e):e.header,r&&(0,t.jsx)("span",{className:"inline-flex ml-1",children:a?.direction==="asc"?(0,t.jsx)(Dr,{}):a?.direction==="desc"?(0,t.jsx)(Er,{}):(0,t.jsx)(Gr,{})}),s&&(0,t.jsx)(Wr,{column:e,value:U.find(l=>l.column===e.key),onApply:lr,onClear:()=>dr(e.key),labels:y})]}),e.resizable!==!1&&(0,t.jsx)("div",{className:"absolute top-0 right-0 w-1 h-full cursor-col-resize hover:bg-blue-500 opacity-0 hover:opacity-100",onMouseDown:l=>ur(l,e.key)})]},e.key)},je=(e,r)=>{let{row:a,sourceIndex:s}=e,l=ft(e),m=He.has(l),v=be.includes(l),te=typeof Ge=="function"?Ge(a,r):Ge;return(0,t.jsxs)(n.default.Fragment,{children:[(0,t.jsxs)("tr",{className:(0,f.cn)("border-b border-gray-200 dark:border-gray-700 transition-colors",st&&r%2===1&&"bg-gray-50/50 dark:bg-gray-800/50",m&&"bg-blue-50 dark:bg-blue-900/20",Ee&&"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50",Q?.key===l&&"opacity-50",te),onClick:Ee?()=>Ee(a,r):void 0,onDoubleClick:lt?()=>lt(a,r):void 0,onContextMenu:dt?p=>dt(a,r,p):void 0,draggable:T,onDragStart:T?()=>gr(l,s):void 0,onDragOver:T?pr:void 0,onDrop:T?()=>mr(l,s):void 0,onDragEnd:T?()=>Pe(null):void 0,"data-row-key":l,"aria-selected":z?m:void 0,children:[se&&(0,t.jsx)("td",{className:(0,f.cn)(k[h],T?"cursor-grab active:cursor-grabbing":"cursor-not-allowed opacity-40"),children:(0,t.jsx)(Fr,{})}),z&&(0,t.jsx)("td",{className:(0,f.cn)(k[h],"w-10"),children:(0,t.jsx)("input",{type:"checkbox",checked:m,onChange:()=>ar(l),onClick:p=>p.stopPropagation(),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":(0,D.formatUILabel)(y.dataGridSelectRow,{row:l})})}),oe&&(0,t.jsx)("td",{className:(0,f.cn)(k[h],"w-10"),children:(0,t.jsx)("button",{type:"button",onClick:p=>{p.stopPropagation(),sr(l)},className:"p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer","aria-label":v?y.dataGridCollapseRow:y.dataGridExpandRow,"aria-expanded":v,children:(0,t.jsx)(kt,{className:(0,f.cn)("transition-transform",v&&"rotate-180")})})}),I.map(p=>{let x=F(a,p.key),q=p.colSpan?.(a,r);if(q===0)return null;let M=Qe&&p.editable!==!1&&p.type!=="actions";return(0,t.jsx)("td",{className:(0,f.cn)(k[h],Ne[h],"text-gray-700 dark:text-gray-300",p.align==="center"&&"text-center",p.align==="right"&&"text-right",De&&"border border-gray-200 dark:border-gray-700",p.sticky&&(m?"bg-blue-50 dark:bg-blue-900/20":st&&r%2===1?"bg-gray-50/50 dark:bg-gray-800/50":"bg-white dark:bg-gray-900"),p.cellClassName,It),style:Ue(p),colSpan:q,children:M?(0,t.jsx)(Br,{value:x,onSave:pe=>Rt?.(l,p.key,pe),density:h,labels:y}):p.render?p.render(x,a,r):String(x??"")},p.key)})]}),oe&&v&&_e&&(0,t.jsx)("tr",{className:"bg-gray-50 dark:bg-gray-800/70",children:(0,t.jsx)("td",{colSpan:ge,className:(0,f.cn)(k[h]),children:_e(a,r)})})]},l)},hr=()=>{if(Et)return Array.from({length:Gt}).map((e,r)=>(0,t.jsx)(Kr,{cols:ge,density:h},r));if(j.length===0)return(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:ge,className:(0,f.cn)("text-center text-gray-400 dark:text-gray-500",k[h]),children:Mt??y.dataGridNoData})});if(ht){let e=[],r=0;for(let[a,s]of ht){let l=Yt.has(a);if(e.push((0,t.jsx)("tr",{className:"bg-gray-100 dark:bg-gray-800 font-medium",children:(0,t.jsx)("td",{colSpan:ge,className:(0,f.cn)(k[h],"cursor-pointer"),onClick:()=>{Zt(m=>{let v=new Set(m);return v.has(a)?v.delete(a):v.add(a),v})},children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(kt,{className:(0,f.cn)("transition-transform",l&&"-rotate-90")}),rt?rt(a,F(s[0].row,Array.isArray(W)?W[0]:W),s.map(m=>m.row)):`${a} (${s.length})`]})})},`group-${a}`)),l)r+=s.length;else for(let m=0;m<s.length;m++)e.push(je(s[m],r)),r++}return e}if(_){let e=[];for(let r=ue.start;r<ue.end;r++)e.push(je(A[r],r));return(0,t.jsxs)(t.Fragment,{children:[ue.start>0&&(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:ge,style:{height:ue.start*J,padding:0}})}),e,ue.end<j.length&&(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:ge,style:{height:(j.length-ue.end)*J,padding:0}})})]})}return A.map((e,r)=>je(e,r))},vr=()=>!Pt||!I.some(r=>r.aggregate)?null:(0,t.jsx)("tfoot",{children:(0,t.jsxs)("tr",{className:"bg-gray-50 dark:bg-gray-800 font-semibold border-t-2 border-gray-300 dark:border-gray-600",children:[se&&(0,t.jsx)("td",{className:k[h]}),z&&(0,t.jsx)("td",{className:k[h]}),oe&&(0,t.jsx)("td",{className:k[h]}),I.map(r=>(0,t.jsx)("td",{className:(0,f.cn)(k[h],Ne[h],"text-gray-700 dark:text-gray-300",r.align==="center"&&"text-center",r.align==="right"&&"text-right",De&&"border border-gray-200 dark:border-gray-700"),style:Ue(r),children:r.aggregate?r.renderAggregate?r.renderAggregate(Ct(ce,r.key,r.aggregate),ce):Vr(r.aggregate,Ct(ce,r.key,r.aggregate).toLocaleString(),y):""},r.key))]})});return(0,t.jsxs)("div",{className:(0,f.cn)("flex flex-col gap-3",zt),children:[(Xe||at||et)&&(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 flex-1",children:[Xe&&(0,t.jsxs)("div",{className:"relative flex-1 max-w-xs",children:[(0,t.jsx)("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:(0,t.jsx)(Mr,{})}),(0,t.jsx)("input",{type:"text",value:ke,onChange:ir,placeholder:St??y.dataGridSearchPlaceholder,className:"w-full pl-9 pr-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500","aria-label":y.dataGridSearch})]}),C.length>0&&(0,t.jsx)("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:(0,D.formatUILabel)(y.dataGridSelectedCount,{count:C.length})})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[et&&(0,t.jsxs)("div",{className:"relative",ref:Ie,children:[(0,t.jsx)("button",{type:"button",onClick:()=>mt(!we),className:"p-1.5 rounded-md border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":y.dataGridToggleColumns,title:y.dataGridToggleColumns,children:(0,t.jsx)(Ir,{})}),we&&(0,t.jsx)("div",{className:"absolute z-50 right-0 top-full mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg p-2 min-w-[180px]",children:d.filter(e=>e.type!=="selection"&&e.type!=="expand").map(e=>(0,t.jsxs)("label",{className:"flex items-center gap-2 px-2 py-1.5 text-sm rounded hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:[(0,t.jsx)("input",{type:"checkbox",checked:!Y.includes(e.key),onChange:()=>cr(e.key),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer"}),(0,t.jsx)("span",{className:"text-gray-700 dark:text-gray-300",children:String(e.header)})]},e.key))})]}),at&&Tt.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>Be(e),className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs font-medium rounded-md border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",title:(0,D.formatUILabel)(y.dataGridExportAs,{format:e.toUpperCase()}),children:[(0,t.jsx)(zr,{}),e.toUpperCase()]},e))]})]}),(0,t.jsx)("div",{ref:ze,className:(0,f.cn)("overflow-auto rounded-lg",!Dt&&"border border-gray-200 dark:border-gray-700",it&&"relative"),style:he?{maxHeight:typeof he=="number"?`${he}px`:he}:_?{maxHeight:Te,overflow:"auto"}:void 0,onScroll:_?e=>er(e.target.scrollTop):void 0,children:(0,t.jsxs)("table",{className:"w-full text-left",children:[(0,t.jsx)("thead",{className:(0,f.cn)("bg-gray-50 dark:bg-gray-800 text-xs uppercase",it&&"sticky top-0 z-20"),children:(0,t.jsxs)("tr",{children:[se&&(0,t.jsx)("th",{className:(0,f.cn)(k[h],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),z&&(0,t.jsx)("th",{className:(0,f.cn)(k[h],"w-10"),children:g==="multiple"&&(0,t.jsx)("input",{type:"checkbox",checked:We,ref:e=>{e&&(e.indeterminate=or)},onChange:We?nr:Ve,className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":y.dataGridSelectAllRows})}),oe&&(0,t.jsx)("th",{className:(0,f.cn)(k[h],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),I.map(fr)]})}),(0,t.jsx)("tbody",{children:hr()}),vr()]})}),de&&(0,t.jsxs)("div",{className:"flex items-center justify-between flex-wrap gap-3 text-sm text-gray-600 dark:text-gray-400",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[de.showTotalItems!==!1&&(0,t.jsx)("span",{children:(0,D.formatUILabel)(Ae===1?y.dataGridItemCount:y.dataGridItemsCount,{count:Ae})}),de.showPageSizeSelector!==!1&&de.pageSizeOptions&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{children:y.dataGridRowsPerPage}),(0,t.jsx)("select",{value:ye,onChange:e=>rr(Number(e.target.value)),className:"border border-gray-300 dark:border-gray-600 rounded px-1.5 py-0.5 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 text-sm",children:de.pageSizeOptions.map(e=>(0,t.jsx)("option",{value:e,children:e},e))})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)("span",{className:"mr-2",children:(0,D.formatUILabel)(y.dataGridPageOf,{page:O,total:ee})}),(0,t.jsx)("button",{type:"button",onClick:()=>N(1),disabled:O<=1,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":y.dataGridFirstPage,children:"\xAB\xAB"}),(0,t.jsx)("button",{type:"button",onClick:()=>N(O-1),disabled:O<=1,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":y.dataGridPreviousPage,children:"\xAB"}),(0,t.jsx)("button",{type:"button",onClick:()=>N(O+1),disabled:O>=ee,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":y.dataGridNextPage,children:"\xBB"}),(0,t.jsx)("button",{type:"button",onClick:()=>N(ee),disabled:O>=ee,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":y.dataGridLastPage,children:"\xBB\xBB"})]})]})]})}var jr=(0,n.forwardRef)(Ur);0&&(module.exports={DataGrid,resetRowKeyWarning});