@synertech/ui 0.50.1 → 0.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/.claude/skills/use-synertech-ui/SKILL.md +190 -146
  2. package/README.md +27 -19
  3. package/dist/components/accordion/Accordion.cjs +1 -1
  4. package/dist/components/accordion/Accordion.js +1 -1
  5. package/dist/components/advance-detachable/AdvanceDetachable.cjs +1 -1
  6. package/dist/components/advance-detachable/AdvanceDetachable.js +1 -1
  7. package/dist/components/area-chart/AreaChart.cjs +1 -1
  8. package/dist/components/area-chart/AreaChart.js +1 -1
  9. package/dist/components/avatar/Avatar.cjs +1 -1
  10. package/dist/components/avatar/Avatar.js +1 -1
  11. package/dist/components/avatar/AvatarImage.cjs +1 -0
  12. package/dist/components/avatar/AvatarImage.js +1 -0
  13. package/dist/components/banner/Banner.cjs +1 -1
  14. package/dist/components/banner/Banner.js +1 -1
  15. package/dist/components/bar-chart/BarChart.cjs +1 -1
  16. package/dist/components/bar-chart/BarChart.js +1 -1
  17. package/dist/components/box-plot/BoxPlot.cjs +1 -1
  18. package/dist/components/box-plot/BoxPlot.js +1 -1
  19. package/dist/components/breadcrumb/Breadcrumb.cjs +1 -1
  20. package/dist/components/breadcrumb/Breadcrumb.js +1 -1
  21. package/dist/components/bullet-chart/BulletChart.cjs +1 -1
  22. package/dist/components/bullet-chart/BulletChart.js +1 -1
  23. package/dist/components/calendar/Calendar.cjs +1 -1
  24. package/dist/components/calendar/Calendar.js +1 -1
  25. package/dist/components/candlestick-chart/CandlestickChart.cjs +1 -1
  26. package/dist/components/candlestick-chart/CandlestickChart.js +1 -1
  27. package/dist/components/card/Card.cjs +1 -1
  28. package/dist/components/card/Card.js +1 -1
  29. package/dist/components/chart/ChartAnnotations.cjs +1 -1
  30. package/dist/components/chart/ChartAnnotations.js +1 -1
  31. package/dist/components/chart/ChartBrush.cjs +1 -1
  32. package/dist/components/chart/ChartBrush.js +1 -1
  33. package/dist/components/chart/ChartContainer.cjs +1 -1
  34. package/dist/components/chart/ChartContainer.js +1 -1
  35. package/dist/components/chart/ChartExportButton.cjs +1 -1
  36. package/dist/components/chart/ChartExportButton.js +1 -1
  37. package/dist/components/chart/ChartPatterns.cjs +1 -1
  38. package/dist/components/chart/ChartPatterns.js +1 -1
  39. package/dist/components/chart/ChartPeriodPicker.cjs +1 -1
  40. package/dist/components/chart/ChartPeriodPicker.js +1 -1
  41. package/dist/components/chart/ChartPlotClip.cjs +1 -0
  42. package/dist/components/chart/ChartPlotClip.js +1 -0
  43. package/dist/components/chart/ChartSync.cjs +1 -1
  44. package/dist/components/chart/ChartSync.js +1 -1
  45. package/dist/components/chart/ChartTableView.cjs +1 -1
  46. package/dist/components/chart/ChartTableView.js +1 -1
  47. package/dist/components/chart/exportSource.cjs +1 -0
  48. package/dist/components/chart/exportSource.js +1 -0
  49. package/dist/components/chart/palette.cjs +1 -1
  50. package/dist/components/chart/palette.js +1 -1
  51. package/dist/components/chart/useChartSize.cjs +1 -1
  52. package/dist/components/chart/useChartSize.js +1 -1
  53. package/dist/components/chart/utils/bins.cjs +1 -1
  54. package/dist/components/chart/utils/bins.js +1 -1
  55. package/dist/components/chart/utils/cartesian.cjs +1 -1
  56. package/dist/components/chart/utils/cartesian.js +1 -1
  57. package/dist/components/chart/utils/export.cjs +7 -1
  58. package/dist/components/chart/utils/export.js +7 -1
  59. package/dist/components/chart/utils/format.cjs +1 -1
  60. package/dist/components/chart/utils/format.js +1 -1
  61. package/dist/components/chart/utils/keyboard.cjs +1 -1
  62. package/dist/components/chart/utils/keyboard.js +1 -1
  63. package/dist/components/chart/utils/period.cjs +1 -1
  64. package/dist/components/chart/utils/period.js +1 -1
  65. package/dist/components/chart/utils/regression.cjs +1 -0
  66. package/dist/components/chart/utils/regression.js +1 -0
  67. package/dist/components/chart/utils/stack.cjs +1 -1
  68. package/dist/components/chart/utils/stack.js +1 -1
  69. package/dist/components/chart/utils/ticks.cjs +1 -1
  70. package/dist/components/chart/utils/ticks.js +1 -1
  71. package/dist/components/checkbox/Checkbox.cjs +1 -1
  72. package/dist/components/checkbox/Checkbox.js +1 -1
  73. package/dist/components/circular-progress/CircularProgress.cjs +1 -1
  74. package/dist/components/circular-progress/CircularProgress.js +1 -1
  75. package/dist/components/datagrid/DataGrid.cjs +1 -1
  76. package/dist/components/datagrid/DataGrid.js +1 -1
  77. package/dist/components/detachable/Detachable.cjs +1 -1
  78. package/dist/components/detachable/Detachable.js +1 -1
  79. package/dist/components/detachable/popup-window.cjs +1 -0
  80. package/dist/components/detachable/popup-window.js +1 -0
  81. package/dist/components/detachable/useMovableContent.cjs +1 -0
  82. package/dist/components/detachable/useMovableContent.js +1 -0
  83. package/dist/components/device-mockup/DeviceMockup.cjs +1 -1
  84. package/dist/components/device-mockup/DeviceMockup.js +1 -1
  85. package/dist/components/divider/Divider.cjs +1 -1
  86. package/dist/components/divider/Divider.js +1 -1
  87. package/dist/components/drawer/Drawer.cjs +1 -1
  88. package/dist/components/drawer/Drawer.js +1 -1
  89. package/dist/components/dropdown/DropdownContent.cjs +1 -1
  90. package/dist/components/dropdown/DropdownContent.js +1 -1
  91. package/dist/components/dropdown/DropdownSubMenu.cjs +1 -1
  92. package/dist/components/dropdown/DropdownSubMenu.js +1 -1
  93. package/dist/components/dropdown/hooks/useClickOutside.cjs +1 -1
  94. package/dist/components/dropdown/hooks/useClickOutside.js +1 -1
  95. package/dist/components/dropdown/hooks/usePositioning.cjs +1 -1
  96. package/dist/components/dropdown/hooks/usePositioning.js +1 -1
  97. package/dist/components/dumbbell-chart/DumbbellChart.cjs +1 -1
  98. package/dist/components/dumbbell-chart/DumbbellChart.js +1 -1
  99. package/dist/components/file-selector/FileSelector.cjs +1 -1
  100. package/dist/components/file-selector/FileSelector.js +1 -1
  101. package/dist/components/footer/FooterBottom.cjs +1 -1
  102. package/dist/components/footer/FooterBottom.js +1 -1
  103. package/dist/components/form/input/Input.cjs +1 -1
  104. package/dist/components/form/input/Input.js +1 -1
  105. package/dist/components/form/mention-input/MentionInput.cjs +5 -1
  106. package/dist/components/form/mention-input/MentionInput.js +5 -1
  107. package/dist/components/form/number-input/NumberInput.cjs +1 -1
  108. package/dist/components/form/number-input/NumberInput.js +1 -1
  109. package/dist/components/form/shared/InputWrapper.cjs +1 -1
  110. package/dist/components/form/shared/InputWrapper.js +1 -1
  111. package/dist/components/funnel-chart/FunnelChart.cjs +1 -1
  112. package/dist/components/funnel-chart/FunnelChart.js +1 -1
  113. package/dist/components/gantt-chart/GanttChart.cjs +1 -1
  114. package/dist/components/gantt-chart/GanttChart.js +1 -1
  115. package/dist/components/heat-map/Heatmap.cjs +1 -1
  116. package/dist/components/heat-map/Heatmap.js +1 -1
  117. package/dist/components/image-uploader/ImageUploader.cjs +1 -1
  118. package/dist/components/image-uploader/ImageUploader.js +1 -1
  119. package/dist/components/line-chart/LineChart.cjs +1 -1
  120. package/dist/components/line-chart/LineChart.js +1 -1
  121. package/dist/components/modal/Modal.cjs +1 -1
  122. package/dist/components/modal/Modal.js +1 -1
  123. package/dist/components/pagination/Pagination.cjs +1 -1
  124. package/dist/components/pagination/Pagination.js +1 -1
  125. package/dist/components/pie-chart/PieChart.cjs +1 -1
  126. package/dist/components/pie-chart/PieChart.js +1 -1
  127. package/dist/components/progress-bar/ProgressBar.cjs +1 -1
  128. package/dist/components/progress-bar/ProgressBar.js +1 -1
  129. package/dist/components/radio-button/RadioButton.cjs +1 -1
  130. package/dist/components/radio-button/RadioButton.js +1 -1
  131. package/dist/components/scatter-chart/ScatterChart.cjs +1 -1
  132. package/dist/components/scatter-chart/ScatterChart.js +1 -1
  133. package/dist/components/scatter-chart/index.cjs +1 -1
  134. package/dist/components/scatter-chart/index.js +1 -1
  135. package/dist/components/schema-editor/SchemaEditor.cjs +1 -1
  136. package/dist/components/schema-editor/SchemaEditor.js +1 -1
  137. package/dist/components/schema-editor/SchemaEditor.types.cjs +1 -1
  138. package/dist/components/schema-editor/canvas/GridLayer.cjs +1 -1
  139. package/dist/components/schema-editor/canvas/GridLayer.js +1 -1
  140. package/dist/components/schema-editor/minimap/SchemaMinimap.cjs +1 -1
  141. package/dist/components/schema-editor/minimap/SchemaMinimap.js +1 -1
  142. package/dist/components/schema-editor/relations/SchemaRelationRenderer.cjs +1 -1
  143. package/dist/components/schema-editor/relations/SchemaRelationRenderer.js +1 -1
  144. package/dist/components/schema-editor/tables/SchemaTableRenderer.cjs +1 -1
  145. package/dist/components/schema-editor/tables/SchemaTableRenderer.js +1 -1
  146. package/dist/components/schema-editor/toolbar/SchemaToolbar.cjs +1 -1
  147. package/dist/components/schema-editor/toolbar/SchemaToolbar.js +1 -1
  148. package/dist/components/schema-editor/utils/import.cjs +1 -0
  149. package/dist/components/schema-editor/utils/import.js +1 -0
  150. package/dist/components/schema-editor/utils/sql-export.cjs +6 -5
  151. package/dist/components/schema-editor/utils/sql-export.js +7 -6
  152. package/dist/components/select/Select.cjs +1 -1
  153. package/dist/components/select/Select.js +1 -1
  154. package/dist/components/slider/Slider.cjs +1 -1
  155. package/dist/components/slider/Slider.js +1 -1
  156. package/dist/components/sparkline/Sparkline.cjs +1 -1
  157. package/dist/components/sparkline/Sparkline.js +1 -1
  158. package/dist/components/table/TableRow.cjs +1 -1
  159. package/dist/components/table/TableRow.js +1 -1
  160. package/dist/components/waterfall-chart/WaterfallChart.cjs +1 -1
  161. package/dist/components/waterfall-chart/WaterfallChart.js +1 -1
  162. package/dist/components/wizard/Wizard.cjs +1 -1
  163. package/dist/components/wizard/Wizard.js +1 -1
  164. package/dist/components/workflow-editor/WorkflowEditor.cjs +1 -1
  165. package/dist/components/workflow-editor/WorkflowEditor.js +1 -1
  166. package/dist/components/workflow-editor/canvas/GridLayer.cjs +1 -1
  167. package/dist/components/workflow-editor/canvas/GridLayer.js +1 -1
  168. package/dist/components/workflow-editor/nodes/WorkflowNodeRenderer.cjs +1 -1
  169. package/dist/components/workflow-editor/nodes/WorkflowNodeRenderer.js +1 -1
  170. package/dist/components/workflow-editor/toolbar/WorkflowToolbar.cjs +1 -1
  171. package/dist/components/workflow-editor/toolbar/WorkflowToolbar.js +1 -1
  172. package/dist/components/workflow-editor/utils/import.cjs +1 -0
  173. package/dist/components/workflow-editor/utils/import.js +1 -0
  174. package/dist/hooks/useDialogA11y.cjs +1 -1
  175. package/dist/hooks/useDialogA11y.js +1 -1
  176. package/dist/index.d.cts +522 -184
  177. package/dist/index.d.ts +522 -184
  178. package/dist/lib/accept.cjs +1 -0
  179. package/dist/lib/accept.js +1 -0
  180. package/dist/lib/canvas-events.cjs +1 -0
  181. package/dist/lib/canvas-events.js +1 -0
  182. package/dist/lib/css-value.cjs +1 -0
  183. package/dist/lib/css-value.js +1 -0
  184. package/dist/lib/dialog-stack.cjs +1 -1
  185. package/dist/lib/dialog-stack.js +1 -1
  186. package/dist/lib/layer-document.cjs +1 -0
  187. package/dist/lib/layer-document.js +1 -0
  188. package/dist/lib/owner-document.cjs +1 -0
  189. package/dist/lib/owner-document.js +1 -0
  190. package/dist/lib/ui-labels.cjs +1 -1
  191. package/dist/lib/ui-labels.js +1 -1
  192. package/dist/styles-no-preflight.css +10270 -0
  193. package/dist/styles.css +390 -450
  194. package/package.json +9 -4
@@ -1 +1 @@
1
- "use client";import{useState as te,useRef as re,useCallback as y,useEffect as ve,useMemo as oe,useId as ke}from"react";import{cn as p}from"../../lib/cn.js";import{formatUILabel as L,useUILabels as Fe}from"../../lib/i18n.js";import{Fragment as Le,jsx as n,jsxs as x}from"react/jsx-runtime";var we={sm:{dropzone:"py-4 px-3",text:"text-xs",subtext:"text-[10px]",icon:"w-6 h-6",button:"px-2.5 py-1.5 text-xs",fileItem:"py-1 px-2 text-xs",gap:"gap-1"},md:{dropzone:"py-6 px-4",text:"text-sm",subtext:"text-xs",icon:"w-8 h-8",button:"px-3 py-2 text-sm",fileItem:"py-1.5 px-3 text-sm",gap:"gap-1.5"},lg:{dropzone:"py-8 px-6",text:"text-base",subtext:"text-sm",icon:"w-10 h-10",button:"px-4 py-2.5 text-base",fileItem:"py-2 px-4 text-base",gap:"gap-2"}},se=f=>{if(f===0)return"0 B";let l=["B","KB","MB","GB"],g=Math.floor(Math.log(f)/Math.log(1024));return`${(f/Math.pow(1024,g)).toFixed(g===0?0:1)} ${l[g]}`},j=f=>f.webkitRelativePath||f.name,Se=n("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-full h-full",children:n("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"})}),Ne=n("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-full h-full",children:n("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 9.776c.112-.017.227-.026.344-.026h15.812c.117 0 .232.009.344.026m-16.5 0a2.25 2.25 0 00-1.883 2.542l.857 6a2.25 2.25 0 002.227 1.932H19.05a2.25 2.25 0 002.227-1.932l.857-6a2.25 2.25 0 00-1.883-2.542m-16.5 0V6A2.25 2.25 0 016 3.75h3.879a1.5 1.5 0 011.06.44l2.122 2.12a1.5 1.5 0 001.06.44H18A2.25 2.25 0 0120.25 9v.776"})}),De=0;async function Ce(f){let l=[],g=async h=>{if(h.isFile){let v=await new Promise((m,t)=>h.file(m,t));l.push(v)}else if(h.isDirectory){let v=h.createReader(),m=()=>new Promise((E,z)=>v.readEntries(E,z)),t=await m();for(;t.length>0;){for(let E of t)await g(E);t=await m()}}};for(let h of f)await g(h);return l}function Me({value:f,onChange:l,accept:g,multiple:h=!1,maxSize:v=10*1024*1024,maxFiles:m,mode:t="file",variant:E="dropzone",size:z="md",disabled:r=!1,readOnly:o=!1,label:U,helperText:P,error:F,showFileList:V=!0,placeholder:G,browseLabel:M,browseFolderLabel:K,labels:ie,icon:ne,onReject:_,className:le}){let s=Fe(ie),[ae,R]=te([]),[Z,T]=te(!1),k=re(null),A=re(null),S=ke(),w=f!==void 0,N=w?f.map((e,a)=>({file:e,id:`ctrl-${a}`})):ae,u=we[z],D=h||t!=="file";ve(()=>{t==="directory"&&k.current&&k.current.setAttribute("webkitdirectory",""),t==="both"&&A.current&&A.current.setAttribute("webkitdirectory","")},[t]);let W=oe(()=>se(v),[v]),$=oe(()=>g?g.split(",").map(e=>e.trim()).map(e=>e.startsWith(".")?e.toUpperCase():e.endsWith("/*")?e.replace("/*","").toUpperCase():e).join(", "):s.fileSelectorAllFiles,[g,s.fileSelectorAllFiles]),q=t==="directory"?s.fileSelectorDropFolder:t==="both"?s.fileSelectorDropFilesOrFolders:h?s.fileSelectorDropFiles:s.fileSelectorDropFile,ce=t==="directory"?s.fileSelectorBrowseFolder:s.fileSelectorBrowse,fe=s.fileSelectorBrowseFolder,J=L(s.fileSelectorTooLarge,{maxSize:W}),Q=L(s.fileSelectorTypeNotAccepted,{accept:$}),X=y(e=>{if(e.size>v)return J;if(g){let a=g.split(",").map(i=>i.trim()),c=`.${e.name.split(".").pop()?.toLowerCase()}`;if(!a.some(i=>i.startsWith(".")?c===i.toLowerCase():i.endsWith("/*")?e.type.startsWith(i.replace("/*","/")):e.type===i))return Q}return null},[g,v,J,Q]),I=y(e=>{if(r||o)return;let a=Array.from(e),c=[];for(let d of a){let i=X(d);i?_?.(d,i):c.push(d)}if(c.length!==0)if(w)if(D){let i=[...f??[],...c],b=m?i.slice(0,m):i;l?.(b)}else l?.([c[0]]);else R(d=>{let i=c.map(b=>({file:b,id:`file-${++De}`}));if(D){let b=[...d,...i],ee=m?b.slice(0,m):b,xe=ee.map(be=>be.file);return l?.(xe),ee}return l?.([c[0]]),[i[0]]})},[r,o,w,D,m,f,l,_,X]),ue=y(e=>{if(!(r||o)){if(w){let a=(f??[]).filter((c,d)=>d!==e);l?.(a)}else R(a=>{let c=a.filter((d,i)=>i!==e);return l?.(c.map(d=>d.file)),c});k.current&&(k.current.value="")}},[r,o,w,f,l]),pe=y(()=>{r||o||(w?l?.([]):(R([]),l?.([])),k.current&&(k.current.value=""))},[r,o,w,l]),Y=y(e=>{e.target.files&&e.target.files.length>0&&I(e.target.files)},[I]),ge=y(e=>{e.preventDefault(),e.stopPropagation(),!r&&!o&&T(!0)},[r,o]),de=y(e=>{e.preventDefault(),e.stopPropagation(),T(!1)},[]),me=y(e=>{if(e.preventDefault(),e.stopPropagation(),T(!1),r||o)return;let a=e.dataTransfer.items;if(a&&a.length>0&&(t==="directory"||t==="both")){let c=[];for(let i=0;i<a.length;i++){let b=a[i].webkitGetAsEntry?.();b&&c.push(b)}if(c.some(i=>i.isDirectory)){Ce(c).then(i=>{i.length>0&&I(i)});return}}e.dataTransfer.files&&e.dataTransfer.files.length>0&&I(e.dataTransfer.files)},[r,o,t,I]),B=y(()=>{!r&&!o&&k.current?.click()},[r,o]),O=y(()=>{!r&&!o&&A.current?.click()},[r,o]),C=N.length>0,he=ne||(t==="directory"?Ne:Se),ye=V&&C&&x("div",{className:p("flex flex-col",u.gap),children:[N.map((e,a)=>x("div",{className:p("flex items-center justify-between rounded-md border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",u.fileItem),children:[x("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[n("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4 shrink-0 text-gray-500 dark:text-gray-400",children:n("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),n("span",{className:"truncate text-gray-700 dark:text-gray-300",children:j(e.file)}),x("span",{className:"shrink-0 text-gray-500 dark:text-gray-400",children:["(",se(e.file.size),")"]})]}),!r&&!o&&n("button",{type:"button",onClick:()=>ue(a),className:"shrink-0 ml-2 text-gray-500 hover:text-red-600 dark:text-gray-400 dark:hover:text-red-400 transition-colors cursor-pointer","aria-label":L(s.fileSelectorRemove,{name:j(e.file)}),children:n("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4",children:n("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]},e.id)),D&&N.length>1&&!r&&!o&&n("button",{type:"button",onClick:pe,className:p("self-start text-gray-500 hover:text-red-600 dark:text-gray-400 dark:hover:text-red-400 transition-colors cursor-pointer",u.subtext),children:s.fileSelectorRemoveAll})]}),H=p("rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 font-medium transition-colors","hover:bg-gray-50 dark:hover:bg-gray-700","disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer","focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 focus:ring-offset-1",u.button,F&&"border-red-300 dark:border-red-600");return x("div",{className:p("flex flex-col",u.gap,le),children:[U&&n("label",{htmlFor:S,className:p("block font-medium text-gray-700 dark:text-gray-300",u.text),children:U}),n("input",{ref:k,id:S,type:"file",accept:t!=="directory"?g:void 0,multiple:D,onChange:Y,className:"sr-only",disabled:r||o,"aria-describedby":F?`${S}-error`:P?`${S}-helper`:void 0,"aria-invalid":!!F}),t==="both"&&n("input",{ref:A,type:"file",onChange:Y,className:"sr-only",disabled:r||o,tabIndex:-1,"aria-hidden":"true"}),E==="dropzone"?x("div",{role:t==="both"?"group":"button",tabIndex:t==="both"?void 0:r||o?-1:0,onClick:t==="both"?void 0:B,onKeyDown:t==="both"?void 0:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),B())},onDragOver:ge,onDragLeave:de,onDrop:me,className:p("flex flex-col items-center justify-center rounded-lg border-2 border-dashed transition-colors",u.dropzone,Z&&!r&&!o?"border-synertech-primary-500 bg-synertech-primary-50 dark:bg-synertech-primary-900/20":"border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800",!r&&!o&&"hover:border-synertech-primary-400 dark:hover:border-synertech-primary-500 hover:bg-gray-50 dark:hover:bg-gray-800/70",t!=="both"&&!r&&!o&&"cursor-pointer",r&&"opacity-50 cursor-not-allowed",o&&"cursor-default",F&&"border-red-300 dark:border-red-600"),"aria-label":t==="both"?s.fileSelectorDropZone:G||q,children:[n("div",{className:p("text-gray-500 dark:text-gray-400 mb-2",u.icon,Z&&"text-synertech-primary-600 dark:text-synertech-primary-400"),children:he}),x("p",{className:p("text-gray-600 dark:text-gray-400",u.text),children:[G||q," ",!r&&!o&&t!=="both"&&n("span",{className:"text-synertech-primary-600 dark:text-synertech-primary-400 font-medium",children:M||ce})]}),t==="both"&&!r&&!o&&x("div",{className:p("flex items-center gap-3 mt-1",u.text),children:[n("button",{type:"button",onClick:B,className:"text-synertech-primary-600 dark:text-synertech-primary-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 focus:ring-offset-1 rounded",children:M||s.fileSelectorBrowseFiles}),n("span",{className:"text-gray-500 dark:text-gray-400",children:"\xB7"}),n("button",{type:"button",onClick:O,className:"text-synertech-primary-600 dark:text-synertech-primary-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 focus:ring-offset-1 rounded",children:K||fe})]}),n("p",{className:p("text-gray-500 dark:text-gray-400 mt-1",u.subtext),children:D&&m?L(s.fileSelectorConstraintsMaxFiles,{accept:$,maxSize:W,maxFiles:m}):L(s.fileSelectorConstraints,{accept:$,maxSize:W})})]}):x("div",{className:"flex items-center gap-2",children:[t==="both"?x(Le,{children:[n("button",{type:"button",onClick:B,disabled:r||o,className:H,children:M||(C?s.fileSelectorChangeFiles:s.fileSelectorChooseFiles)}),n("button",{type:"button",onClick:O,disabled:r||o,className:H,children:K||s.fileSelectorChooseFolder})]}):n("button",{type:"button",onClick:B,disabled:r||o,className:H,children:M||(t==="directory"?C?s.fileSelectorChangeFolder:s.fileSelectorChooseFolder:C?s.fileSelectorChangeFile:s.fileSelectorChooseFile)}),!C&&n("span",{className:p("text-gray-500 dark:text-gray-400",u.text),children:t==="directory"?s.fileSelectorNoFolder:t==="both"?s.fileSelectorNoFileOrFolder:s.fileSelectorNoFile}),C&&!V&&n("span",{className:p("text-gray-600 dark:text-gray-400 truncate",u.text),children:N.length===1?j(N[0].file):L(s.fileSelectorFilesSelected,{count:N.length})})]}),ye,F&&n("p",{id:`${S}-error`,className:p("text-red-600 dark:text-red-400",u.subtext),role:"alert",children:F}),P&&!F&&n("p",{id:`${S}-helper`,className:p("text-gray-500 dark:text-gray-400",u.subtext),children:P})]})}export{Me as FileSelector};
1
+ "use client";import{useState as ie,useRef as Y,useCallback as y,useEffect as ve,useMemo as se,useId as Fe}from"react";import{cn as u}from"../../lib/cn.js";import{formatUILabel as A,useUILabels as we}from"../../lib/i18n.js";import{matchesAccept as Se}from"../../lib/accept.js";import{Fragment as Me,jsx as i,jsxs as x}from"react/jsx-runtime";var Ne={sm:{dropzone:"py-4 px-3",text:"text-xs",subtext:"text-[10px]",icon:"w-6 h-6",button:"px-2.5 py-1.5 text-xs",fileItem:"py-1 px-2 text-xs",gap:"gap-1"},md:{dropzone:"py-6 px-4",text:"text-sm",subtext:"text-xs",icon:"w-8 h-8",button:"px-3 py-2 text-sm",fileItem:"py-1.5 px-3 text-sm",gap:"gap-1.5"},lg:{dropzone:"py-8 px-6",text:"text-base",subtext:"text-sm",icon:"w-10 h-10",button:"px-4 py-2.5 text-base",fileItem:"py-2 px-4 text-base",gap:"gap-2"}},le=s=>{if(s===0)return"0 B";let p=["B","KB","MB","GB"],g=Math.floor(Math.log(s)/Math.log(1024));return`${(s/Math.pow(1024,g)).toFixed(g===0?0:1)} ${p[g]}`},W=s=>s.webkitRelativePath||s.name,Z=s=>`${W(s)}\0${s.size}\0${s.lastModified}`,Ie=i("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-full h-full",children:i("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"})}),De=i("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-full h-full",children:i("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 9.776c.112-.017.227-.026.344-.026h15.812c.117 0 .232.009.344.026m-16.5 0a2.25 2.25 0 00-1.883 2.542l.857 6a2.25 2.25 0 002.227 1.932H19.05a2.25 2.25 0 002.227-1.932l.857-6a2.25 2.25 0 00-1.883-2.542m-16.5 0V6A2.25 2.25 0 016 3.75h3.879a1.5 1.5 0 011.06.44l2.122 2.12a1.5 1.5 0 001.06.44H18A2.25 2.25 0 0120.25 9v.776"})}),Ce=0,Ee=1e4;async function Le(s,{keep:p=()=>!0,wanted:g=1/0}={}){let D=[],S=0,d=0,n=()=>S>=g||d>=Ee,T=async k=>{if(!n()){if(d++,k.isFile){let t=await new Promise((r,v)=>k.file(r,v));D.push(t),p(t)&&S++}else if(k.isDirectory){let t=k.createReader(),r=()=>new Promise((N,b)=>t.readEntries(N,b)),v=await r();for(;v.length>0&&!n();){for(let N of v)await T(N);n()||(v=await r())}}}};for(let k of s)await T(k);return D}function Re({value:s,onChange:p,accept:g,multiple:D=!1,maxSize:S=10*1024*1024,maxFiles:d,mode:n="file",variant:T="dropzone",size:k="md",disabled:t=!1,readOnly:r=!1,label:v,helperText:N,error:b,showFileList:q=!0,placeholder:J,browseLabel:$,browseFolderLabel:Q,labels:ae,icon:ce,onReject:j,className:fe}){let o=we(ae),[X,ue]=ie([]),B=Y(X),[O,_]=ie(!1),F=Y(null),H=Y(null),C=Fe(),m=s!==void 0,E=m?s.map((e,f)=>({file:e,id:`ctrl-${f}`})):X,c=Ne[k],I=y(e=>{B.current=e,ue(e),p?.(e.map(f=>f.file))},[p]),w=D||n!=="file";ve(()=>{n==="directory"&&F.current&&F.current.setAttribute("webkitdirectory",""),n==="both"&&H.current&&H.current.setAttribute("webkitdirectory","")},[n]);let V=se(()=>le(S),[S]),G=se(()=>g?g.split(",").map(e=>e.trim()).map(e=>e.startsWith(".")?e.toUpperCase():e.endsWith("/*")?e.replace("/*","").toUpperCase():e).join(", "):o.fileSelectorAllFiles,[g,o.fileSelectorAllFiles]),ee=n==="directory"?o.fileSelectorDropFolder:n==="both"?o.fileSelectorDropFilesOrFolders:D?o.fileSelectorDropFiles:o.fileSelectorDropFile,pe=n==="directory"?o.fileSelectorBrowseFolder:o.fileSelectorBrowse,de=o.fileSelectorBrowseFolder,te=A(o.fileSelectorTooLarge,{maxSize:V}),re=A(o.fileSelectorTypeNotAccepted,{accept:G}),U=y(e=>e.size>S?te:Se(e,g)?null:re,[g,S,te,re]),z=y(e=>{if(t||r)return;let f=Array.from(e),h=[],R=new Set(w?(m?s??[]:B.current.map(l=>l.file)).map(Z):[]);for(let l of f){let a=U(l);a?j?.(l,a):R.has(Z(l))?j?.(l,o.fileSelectorAlreadyAdded):(w&&R.add(Z(l)),h.push(l))}if(h.length!==0)if(m)if(w){let a=[...s??[],...h],M=d?a.slice(0,d):a;p?.(M)}else p?.([h[0]]);else{let l=h.map(a=>({file:a,id:`file-${++Ce}`}));if(w){let a=[...B.current,...l];I(d?a.slice(0,d):a)}else I([l[0]])}},[t,r,m,w,d,s,p,j,U,I,o.fileSelectorAlreadyAdded]),ge=y(e=>{if(!(t||r)){if(m){let f=(s??[]).filter((h,R)=>R!==e);p?.(f)}else I(B.current.filter((f,h)=>h!==e));F.current&&(F.current.value="")}},[t,r,m,s,p,I]),he=y(()=>{t||r||(m?p?.([]):I([]),F.current&&(F.current.value=""))},[t,r,m,p,I]),oe=y(e=>{e.target.files&&e.target.files.length>0&&z(e.target.files)},[z]),ye=y(e=>{e.preventDefault(),e.stopPropagation(),!t&&!r&&_(!0)},[t,r]),me=y(e=>{e.preventDefault(),e.stopPropagation(),_(!1)},[]),xe=y(e=>{if(e.preventDefault(),e.stopPropagation(),_(!1),t||r)return;let f=e.dataTransfer.items;if(f&&f.length>0&&(n==="directory"||n==="both")){let h=[];for(let l=0;l<f.length;l++){let a=f[l].webkitGetAsEntry?.();a&&h.push(a)}if(h.some(l=>l.isDirectory)){let l=m?(s??[]).length:B.current.length,a=d?Math.max(0,d-l):1/0;if(a===0)return;Le(h,{keep:M=>U(M)===null,wanted:a}).then(M=>{M.length>0&&z(M)});return}}e.dataTransfer.files&&e.dataTransfer.files.length>0&&z(e.dataTransfer.files)},[t,r,n,z,m,s,d,U]),P=y(()=>{!t&&!r&&F.current?.click()},[t,r]),ne=y(()=>{!t&&!r&&H.current?.click()},[t,r]),L=E.length>0,be=ce||(n==="directory"?De:Ie),ke=q&&L&&x("div",{className:u("flex flex-col",c.gap),children:[E.map((e,f)=>x("div",{className:u("flex items-center justify-between rounded-md border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",c.fileItem),children:[x("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[i("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4 shrink-0 text-gray-500 dark:text-gray-400",children:i("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),i("span",{className:"truncate text-gray-700 dark:text-gray-300",children:W(e.file)}),x("span",{className:"shrink-0 text-gray-500 dark:text-gray-400",children:["(",le(e.file.size),")"]})]}),!t&&!r&&i("button",{type:"button",onClick:()=>ge(f),className:"shrink-0 ml-2 text-gray-500 hover:text-red-600 dark:text-gray-400 dark:hover:text-red-400 transition-colors cursor-pointer","aria-label":A(o.fileSelectorRemove,{name:W(e.file)}),children:i("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4",children:i("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]},e.id)),w&&E.length>1&&!t&&!r&&i("button",{type:"button",onClick:he,className:u("self-start text-gray-500 hover:text-red-600 dark:text-gray-400 dark:hover:text-red-400 transition-colors cursor-pointer",c.subtext),children:o.fileSelectorRemoveAll})]}),K=u("rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 font-medium transition-colors","hover:bg-gray-50 dark:hover:bg-gray-700","disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer","focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 focus:ring-offset-1",c.button,b&&"border-red-300 dark:border-red-600");return x("div",{className:u("flex flex-col",c.gap,fe),children:[v&&i("label",{htmlFor:C,className:u("block font-medium text-gray-700 dark:text-gray-300",c.text),children:v}),i("input",{ref:F,id:C,type:"file",accept:n!=="directory"?g:void 0,multiple:w,onChange:oe,className:"sr-only",tabIndex:-1,disabled:t||r,"aria-describedby":b?`${C}-error`:N?`${C}-helper`:void 0,"aria-invalid":!!b}),n==="both"&&i("input",{ref:H,type:"file",onChange:oe,className:"sr-only",disabled:t||r,tabIndex:-1,"aria-hidden":"true"}),T==="dropzone"?x("div",{role:n==="both"?"group":"button",tabIndex:n==="both"?void 0:t||r?-1:0,onClick:n==="both"?void 0:P,onKeyDown:n==="both"?void 0:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),P())},onDragOver:ye,onDragLeave:me,onDrop:xe,className:u("flex flex-col items-center justify-center rounded-lg border-2 border-dashed transition-colors",c.dropzone,O&&!t&&!r?"border-synertech-primary-500 bg-synertech-primary-50 dark:bg-synertech-primary-900/20":"border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800",!t&&!r&&"hover:border-synertech-primary-400 dark:hover:border-synertech-primary-500 hover:bg-gray-50 dark:hover:bg-gray-800/70",n!=="both"&&!t&&!r&&"cursor-pointer",t&&"opacity-50 cursor-not-allowed",r&&"cursor-default",b&&"border-red-300 dark:border-red-600"),"aria-label":n==="both"?o.fileSelectorDropZone:J||ee,children:[i("div",{className:u("text-gray-500 dark:text-gray-400 mb-2",c.icon,O&&"text-synertech-primary-600 dark:text-synertech-primary-400"),children:be}),x("p",{className:u("text-gray-600 dark:text-gray-400",c.text),children:[J||ee," ",!t&&!r&&n!=="both"&&i("span",{className:"text-synertech-primary-600 dark:text-synertech-primary-400 font-medium",children:$||pe})]}),n==="both"&&!t&&!r&&x("div",{className:u("flex items-center gap-3 mt-1",c.text),children:[i("button",{type:"button",onClick:P,className:"text-synertech-primary-600 dark:text-synertech-primary-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 focus:ring-offset-1 rounded",children:$||o.fileSelectorBrowseFiles}),i("span",{className:"text-gray-500 dark:text-gray-400",children:"\xB7"}),i("button",{type:"button",onClick:ne,className:"text-synertech-primary-600 dark:text-synertech-primary-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 focus:ring-offset-1 rounded",children:Q||de})]}),i("p",{className:u("text-gray-500 dark:text-gray-400 mt-1",c.subtext),children:w&&d?A(o.fileSelectorConstraintsMaxFiles,{accept:G,maxSize:V,maxFiles:d}):A(o.fileSelectorConstraints,{accept:G,maxSize:V})})]}):x("div",{className:"flex items-center gap-2",children:[n==="both"?x(Me,{children:[i("button",{type:"button",onClick:P,disabled:t||r,className:K,children:$||(L?o.fileSelectorChangeFiles:o.fileSelectorChooseFiles)}),i("button",{type:"button",onClick:ne,disabled:t||r,className:K,children:Q||o.fileSelectorChooseFolder})]}):i("button",{type:"button",onClick:P,disabled:t||r,className:K,children:$||(n==="directory"?L?o.fileSelectorChangeFolder:o.fileSelectorChooseFolder:L?o.fileSelectorChangeFile:o.fileSelectorChooseFile)}),!L&&i("span",{className:u("text-gray-500 dark:text-gray-400",c.text),children:n==="directory"?o.fileSelectorNoFolder:n==="both"?o.fileSelectorNoFileOrFolder:o.fileSelectorNoFile}),L&&!q&&i("span",{className:u("text-gray-600 dark:text-gray-400 truncate",c.text),children:E.length===1?W(E[0].file):A(o.fileSelectorFilesSelected,{count:E.length})})]}),ke,b&&i("p",{id:`${C}-error`,className:u("text-red-600 dark:text-red-400",c.subtext),role:"alert",children:b}),N&&!b&&i("p",{id:`${C}-helper`,className:u("text-gray-500 dark:text-gray-400",c.subtext),children:N})]})}export{Ee as DIRECTORY_ENTRY_LIMIT,Re as FileSelector,Le as readDirectoryEntries};
@@ -1 +1 @@
1
- "use strict";var p=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var f=(o,t)=>{for(var e in t)p(o,e,{get:t[e],enumerable:!0})},l=(o,t,e,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of n(t))!c.call(o,r)&&r!==e&&p(o,r,{get:()=>t[r],enumerable:!(a=i(t,r))||a.enumerable});return o};var x=o=>l(p({},"__esModule",{value:!0}),o);var y={};f(y,{FooterBottom:()=>d});module.exports=x(y);var s=require("../../lib/cn.cjs"),m=require("react/jsx-runtime");function d({copyright:o,className:t,children:e,...a}){return(0,m.jsxs)("div",{className:(0,s.cn)("mt-8 border-t border-gray-200 dark:border-gray-700 pt-6 flex flex-col sm:flex-row items-center justify-between gap-4",t),...a,children:[o&&(0,m.jsx)("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:o}),e]})}d.displayName="FooterBottom";0&&(module.exports={FooterBottom});
1
+ "use strict";var m=Object.defineProperty;var n=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var f=(o,t)=>{for(var e in t)m(o,e,{get:t[e],enumerable:!0})},l=(o,t,e,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of s(t))!c.call(o,r)&&r!==e&&m(o,r,{get:()=>t[r],enumerable:!(a=n(t,r))||a.enumerable});return o};var x=o=>l(m({},"__esModule",{value:!0}),o);var y={};f(y,{FooterBottom:()=>p});module.exports=x(y);var i=require("../../lib/cn.cjs"),d=require("react/jsx-runtime");function p({copyright:o,className:t,children:e,...a}){return(0,d.jsxs)("div",{className:(0,i.cn)("mt-8 border-t border-gray-200 dark:border-gray-700 pt-6 flex flex-col sm:flex-row items-center justify-between gap-4",t),...a,children:[o?(0,d.jsx)("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:o}):null,e]})}p.displayName="FooterBottom";0&&(module.exports={FooterBottom});
@@ -1 +1 @@
1
- import{cn as a}from"../../lib/cn.js";import{jsx as p,jsxs as s}from"react/jsx-runtime";function m({copyright:t,className:o,children:e,...r}){return s("div",{className:a("mt-8 border-t border-gray-200 dark:border-gray-700 pt-6 flex flex-col sm:flex-row items-center justify-between gap-4",o),...r,children:[t&&p("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:t}),e]})}m.displayName="FooterBottom";export{m as FooterBottom};
1
+ import{cn as a}from"../../lib/cn.js";import{jsx as m,jsxs as i}from"react/jsx-runtime";function d({copyright:t,className:o,children:e,...r}){return i("div",{className:a("mt-8 border-t border-gray-200 dark:border-gray-700 pt-6 flex flex-col sm:flex-row items-center justify-between gap-4",o),...r,children:[t?m("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:t}):null,e]})}d.displayName="FooterBottom";export{d as FooterBottom};
@@ -1 +1 @@
1
- "use strict";"use client";var T=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var F=(t,e)=>{for(var a in e)T(t,a,{get:e[a],enumerable:!0})},O=(t,e,a,p)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of j(e))!B.call(t,n)&&n!==a&&T(t,n,{get:()=>e[n],enumerable:!(p=z(e,n))||p.enumerable});return t};var k=t=>O(T({},"__esModule",{value:!0}),t);var q={};F(q,{Input:()=>g});module.exports=k(q);var s=require("react"),C=require("../../../lib/cn.cjs"),i=require("../shared/inputStyles.cjs"),P=require("../shared/InputWrapper.cjs"),l=require("react/jsx-runtime"),g=(0,s.forwardRef)(({label:t,inline:e=!1,size:a="md",labelColor:p,borderColor:n,textColor:f,disabled:r=!1,readOnly:o=!1,error:d=!1,helperText:y,hideLabel:W=!1,icon:m,iconPosition:b="left",multiline:R=!1,rows:A=3,focused:L=!1,id:S,className:N,...M},u)=>{let E=(0,s.useRef)(null),H=I=>{E.current=I,typeof u=="function"?u(I):u&&(u.current=I)};(0,s.useEffect)(()=>{L&&E.current?.focus()},[L]);let w=(0,s.useId)(),c=S||w,x=(0,C.cn)((0,i.getBaseInputClasses)({size:a,error:d,disabled:r,readOnly:o,icon:m,iconPosition:b}),R&&"resize-y",N),v={...n&&{borderColor:n},...f&&{color:f}},h=n||f?v:void 0;return(0,l.jsx)(P.InputWrapper,{label:t,hideLabel:W,labelColor:p,error:d,helperText:y,inline:e,htmlFor:c,children:(0,l.jsxs)("div",{className:"relative w-full",children:[m&&(0,l.jsx)("span",{className:(0,i.getIconClasses)(b),children:m}),R?(0,l.jsx)("textarea",{ref:H,id:c,disabled:r,readOnly:o,rows:A,tabIndex:o||r?-1:void 0,className:x,style:h,...M}):(0,l.jsx)("input",{ref:H,id:c,disabled:r,readOnly:o,tabIndex:o||r?-1:void 0,className:x,style:h,...M})]})})});g.displayName="Input";0&&(module.exports={Input});
1
+ "use strict";"use client";var C=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var B=(t,e)=>{for(var r in e)C(t,r,{get:e[r],enumerable:!0})},q=(t,e,r,p)=>{if(e&&typeof e=="object"||typeof e=="function")for(let l of j(e))!k.call(t,l)&&l!==r&&C(t,l,{get:()=>e[l],enumerable:!(p=z(e,l))||p.enumerable});return t};var G=t=>q(C({},"__esModule",{value:!0}),t);var J={};B(J,{Input:()=>P});module.exports=G(J);var n=require("react"),A=require("../../../lib/cn.cjs"),T=require("../../../lib/css-value.cjs"),i=require("../shared/inputStyles.cjs"),y=require("../shared/InputWrapper.cjs"),o=require("react/jsx-runtime"),P=(0,n.forwardRef)(({label:t,inline:e=!1,size:r="md",labelColor:p,borderColor:l,textColor:W,disabled:s=!1,readOnly:a=!1,error:b=!1,helperText:S,hideLabel:v=!1,icon:f,iconPosition:E="left",multiline:M=!1,rows:F=3,focused:x=!1,id:N,className:O,...H},u)=>{let m=(0,T.safeCssColor)(l),c=(0,T.safeCssColor)(W),L=(0,n.useRef)(null),R=I=>{L.current=I,typeof u=="function"?u(I):u&&(u.current=I)};(0,n.useEffect)(()=>{x&&L.current?.focus()},[x]);let w=(0,n.useId)(),d=N||w,h=(0,A.cn)((0,i.getBaseInputClasses)({size:r,error:b,disabled:s,readOnly:a,icon:f,iconPosition:E}),M&&"resize-y",O),D={...m&&{borderColor:m},...c&&{color:c}},g=m||c?D:void 0;return(0,o.jsx)(y.InputWrapper,{label:t,hideLabel:v,labelColor:p,error:b,helperText:S,inline:e,htmlFor:d,children:(0,o.jsxs)("div",{className:"relative w-full",children:[f&&(0,o.jsx)("span",{className:(0,i.getIconClasses)(E),children:f}),M?(0,o.jsx)("textarea",{ref:R,id:d,disabled:s,readOnly:a,rows:F,tabIndex:a||s?-1:void 0,className:h,style:g,...H}):(0,o.jsx)("input",{ref:R,id:d,disabled:s,readOnly:a,tabIndex:a||s?-1:void 0,className:h,style:g,...H})]})})});P.displayName="Input";0&&(module.exports={Input});
@@ -1 +1 @@
1
- "use client";import{forwardRef as W,useEffect as A,useId as S,useRef as N}from"react";import{cn as w}from"../../../lib/cn.js";import{getBaseInputClasses as v,getIconClasses as z}from"../shared/inputStyles.js";import{InputWrapper as j}from"../shared/InputWrapper.js";import{jsx as s,jsxs as F}from"react/jsx-runtime";var B=W(({label:R,inline:L=!1,size:M="md",labelColor:E,borderColor:l,textColor:a,disabled:e=!1,readOnly:t=!1,error:u=!1,helperText:H,hideLabel:x=!1,icon:r,iconPosition:i="left",multiline:f=!1,rows:h=3,focused:m=!1,id:C,className:P,...c},n)=>{let I=N(null),T=p=>{I.current=p,typeof n=="function"?n(p):n&&(n.current=p)};A(()=>{m&&I.current?.focus()},[m]);let g=S(),o=C||g,d=w(v({size:M,error:u,disabled:e,readOnly:t,icon:r,iconPosition:i}),f&&"resize-y",P),y={...l&&{borderColor:l},...a&&{color:a}},b=l||a?y:void 0;return s(j,{label:R,hideLabel:x,labelColor:E,error:u,helperText:H,inline:L,htmlFor:o,children:F("div",{className:"relative w-full",children:[r&&s("span",{className:z(i),children:r}),f?s("textarea",{ref:T,id:o,disabled:e,readOnly:t,rows:h,tabIndex:t||e?-1:void 0,className:d,style:b,...c}):s("input",{ref:T,id:o,disabled:e,readOnly:t,tabIndex:t||e?-1:void 0,className:d,style:b,...c})]})})});B.displayName="Input";export{B as Input};
1
+ "use client";import{forwardRef as v,useEffect as F,useId as N,useRef as O}from"react";import{cn as w}from"../../../lib/cn.js";import{safeCssColor as b}from"../../../lib/css-value.js";import{getBaseInputClasses as D,getIconClasses as z}from"../shared/inputStyles.js";import{InputWrapper as j}from"../shared/InputWrapper.js";import{jsx as l,jsxs as B}from"react/jsx-runtime";var k=v(({label:E,inline:M=!1,size:x="md",labelColor:H,borderColor:L,textColor:R,disabled:e=!1,readOnly:t=!1,error:u=!1,helperText:h,hideLabel:g=!1,icon:o,iconPosition:i="left",multiline:f=!1,rows:A=3,focused:m=!1,id:y,className:P,...c},n)=>{let r=b(L),s=b(R),d=O(null),I=p=>{d.current=p,typeof n=="function"?n(p):n&&(n.current=p)};F(()=>{m&&d.current?.focus()},[m]);let W=N(),a=y||W,C=w(D({size:x,error:u,disabled:e,readOnly:t,icon:o,iconPosition:i}),f&&"resize-y",P),S={...r&&{borderColor:r},...s&&{color:s}},T=r||s?S:void 0;return l(j,{label:E,hideLabel:g,labelColor:H,error:u,helperText:h,inline:M,htmlFor:a,children:B("div",{className:"relative w-full",children:[o&&l("span",{className:z(i),children:o}),f?l("textarea",{ref:I,id:a,disabled:e,readOnly:t,rows:A,tabIndex:t||e?-1:void 0,className:C,style:T,...c}):l("input",{ref:I,id:a,disabled:e,readOnly:t,tabIndex:t||e?-1:void 0,className:C,style:T,...c})]})})});k.displayName="Input";export{k as Input};
@@ -1 +1,5 @@
1
- "use strict";"use client";var X=Object.defineProperty;var xe=Object.getOwnPropertyDescriptor;var ye=Object.getOwnPropertyNames;var Ne=Object.prototype.hasOwnProperty;var Ce=(l,d)=>{for(var m in d)X(l,m,{get:d[m],enumerable:!0})},Ee=(l,d,m,M)=>{if(d&&typeof d=="object"||typeof d=="function")for(let f of ye(d))!Ne.call(l,f)&&f!==m&&X(l,f,{get:()=>d[f],enumerable:!(M=xe(d,f))||M.enumerable});return l};var Se=l=>Ee(X({},"__esModule",{value:!0}),l);var we={};Ce(we,{MentionInput:()=>le});module.exports=Se(we);var a=require("react"),oe=require("react-dom/client"),L=require("../../../lib/cn.cjs"),ae=require("../../../lib/i18n.cjs"),R=require("../shared/inputStyles.cjs"),ie=require("../shared/InputWrapper.cjs"),se=require("../../chip/Chip.cjs"),c=require("react/jsx-runtime"),Me=l=>(0,c.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:[l.avatar&&(0,c.jsx)("img",{src:l.avatar,alt:l.label,className:"w-6 h-6 rounded-full"}),(0,c.jsx)("span",{className:"text-sm text-gray-900 dark:text-white",children:l.label})]}),le=(0,a.forwardRef)(({label:l,inline:d=!1,size:m="md",labelColor:M,borderColor:f,textColor:k,disabled:g=!1,readOnly:C=!1,error:$=!1,helperText:ce,hideLabel:de=!1,icon:B,iconPosition:K="left",mentionTrigger:b="@",suggestions:w=[],onMentionSearch:W,onMentionSelect:F,onMentionRemove:Q,renderSuggestion:U,value:p,onChange:h,placeholder:H,loading:ue=!1,loadingLabel:fe,maxSuggestions:O=10,chipVariant:j="soft",chipColor:G="primary",chipSize:J="sm"},I)=>{let Y=(0,a.useId)(),Z=(0,ae.useUILabels)(),ee=Z.chipRemove,s=(0,a.useRef)(null),[_,T]=(0,a.useState)(!1),[D,P]=(0,a.useState)(0),[Ie,V]=(0,a.useState)(""),pe=(0,L.cn)((0,R.getBaseInputClasses)({size:m,error:$,disabled:g,readOnly:C,icon:B,iconPosition:K}),"min-h-[42px]","whitespace-pre-wrap","break-words"),me={...f&&{borderColor:f},...k&&{color:k}},ge=f||k?me:void 0,v=(0,a.useCallback)(()=>{if(!s.current)return{text:"",mentions:[]};let e="",n=[],t=0,o=r=>{if(r.nodeType===Node.TEXT_NODE)e+=r.textContent||"",t+=(r.textContent||"").length;else if(r.nodeType===Node.ELEMENT_NODE){let i=r;if(i.hasAttribute("data-mention-id")){let u=i.getAttribute("data-mention-id"),x=i.getAttribute("data-mention-label")||"",A=i.getAttribute("data-mention-avatar")||void 0,y=`@${x}`,S=t;n.push({trigger:b,suggestion:{id:u||"",label:x,avatar:A},startIndex:S,endIndex:S+y.length}),e+=y,t+=y.length}else i.childNodes.forEach(o)}};return s.current.childNodes.forEach(o),{text:e,mentions:n}},[b]),te=(0,a.useCallback)((e,n)=>{let t=document.createElement("span");return t.contentEditable="false",t.setAttribute("data-mention-id",e.id),t.setAttribute("data-mention-label",e.label),e.avatar&&t.setAttribute("data-mention-avatar",e.avatar),t.className="inline-block align-middle mx-0.5",t.style.userSelect="none",(0,oe.createRoot)(t).render((0,c.jsx)(se.Chip,{label:e.label,variant:j,color:G,size:J,closable:!g&&!C,removeLabel:ee,onClose:n,disabled:g,avatar:e.avatar?(0,c.jsx)("img",{src:e.avatar,alt:e.label,className:"w-full h-full object-cover"}):void 0})),t},[j,G,J,g,C,ee]),E=(0,a.useCallback)(e=>{if(!s.current)return;let n=s.current.querySelector(`[data-mention-id="${e}"]`);if(n){n.remove();let t=v();h?.(t);let o=p?.mentions.find(r=>r.suggestion.id===e)?.suggestion;o&&Q?.(o)}},[v,h,Q,p?.mentions]),be=(0,a.useCallback)(()=>{if(!s.current)return;let e=window.getSelection();if(!e||e.rangeCount===0)return;let n=e.getRangeAt(0),t="";n.startContainer.nodeType===Node.TEXT_NODE&&(t=n.startContainer.textContent?.substring(0,n.startOffset)||"");let o=t.match(new RegExp(`${b}(\\w*)$`));if(o){let i=o[1];V(i),T(!0),P(0),W?.(i)}else T(!1),V("");let r=v();h?.(r)},[b,W,h,v]),ne=(0,a.useCallback)(e=>{let n=s.current;if(!n)return!1;let t=window.getSelection();if(!t||t.rangeCount===0)return!1;let o=t.getRangeAt(0);if(o.startContainer.nodeType!==Node.TEXT_NODE||!n.contains(o.startContainer))return!1;let r=o.startContainer,i=r.textContent||"",u=o.startOffset,A=i.substring(0,u).lastIndexOf(b);if(A===-1)return!1;let y=i.substring(0,A),S=i.substring(u),N=te(e,()=>{E(e.id)});if(y?(r.textContent=y,r.parentNode?.insertBefore(N,r.nextSibling)):(r.parentNode?.insertBefore(N,r),r.remove()),S){let ve=document.createTextNode(S);N.parentNode?.insertBefore(ve,N.nextSibling)}let re=document.createTextNode(" ");N.parentNode?.insertBefore(re,N.nextSibling);let z=document.createRange();return z.setStartAfter(re),z.collapse(!0),t.removeAllRanges(),t.addRange(z),!0},[b,te,E]),q=(0,a.useCallback)(e=>{let n=ne(e);if(T(!1),V(""),!n)return;let t=v();h?.(t),F?.(e),s.current?.focus()},[ne,v,h,F]),he=(0,a.useCallback)(e=>{let n=w.slice(0,O);if(_&&n.length>0)switch(e.key){case"ArrowDown":e.preventDefault(),P(t=>t<n.length-1?t+1:0);return;case"ArrowUp":e.preventDefault(),P(t=>t>0?t-1:n.length-1);return;case"Enter":case"Tab":e.preventDefault(),n[D]&&q(n[D]);return;case"Escape":e.preventDefault(),T(!1);return}if(e.key==="Backspace"){let t=window.getSelection();if(!t||t.rangeCount===0)return;let o=t.getRangeAt(0);if(o.collapsed&&o.startOffset===0){let r=o.startContainer.previousSibling;if(r&&r.nodeType===Node.ELEMENT_NODE){let i=r;if(i.hasAttribute("data-mention-id")){e.preventDefault();let u=i.getAttribute("data-mention-id");u&&E(u);return}}}if(o.collapsed&&o.startContainer.nodeType===Node.TEXT_NODE){let r=o.startContainer;if(o.startOffset===0){let i=r.previousSibling;if(i&&i.nodeType===Node.ELEMENT_NODE){let u=i;if(u.hasAttribute("data-mention-id")){e.preventDefault();let x=u.getAttribute("data-mention-id");x&&E(x);return}}}}}},[_,w,D,O,q,E]);return(0,a.useEffect)(()=>{s.current&&(!(s.current.textContent||s.current.querySelector("[data-mention-id]"))&&H?s.current.setAttribute("data-placeholder",H):s.current.removeAttribute("data-placeholder"))},[H,p]),(0,a.useEffect)(()=>{s.current&&p?.text===""&&p?.mentions.length===0&&s.current.innerHTML.trim()&&(s.current.innerHTML="")},[p?.text,p?.mentions.length]),(0,c.jsx)(ie.InputWrapper,{label:l,hideLabel:de,labelColor:M,error:$,helperText:ce,inline:d,htmlFor:Y,children:(0,c.jsxs)("div",{className:"relative w-full",children:[B&&(0,c.jsx)("span",{className:(0,R.getIconClasses)(K),children:B}),(0,c.jsx)("div",{ref:e=>{typeof I=="function"?I(e):I&&(I.current=e),s.current=e},id:Y,contentEditable:!g&&!C,suppressContentEditableWarning:!0,onInput:be,onKeyDown:he,className:(0,L.cn)(pe,"empty:before:content-[attr(data-placeholder)] empty:before:text-gray-500 empty:before:dark:text-gray-400"),style:ge,role:"textbox","aria-label":l,"aria-multiline":"true",tabIndex:C||g?-1:0}),_&&w.length>0&&(0,c.jsx)("div",{onMouseDown:e=>e.preventDefault(),className:"absolute z-10 mt-1 w-full max-h-60 overflow-auto rounded-lg border border-gray-300 bg-white dark:bg-gray-700 dark:border-gray-600 shadow-lg",children:ue?(0,c.jsx)("div",{className:"px-3 py-2 text-sm text-gray-500 dark:text-gray-400",children:fe??Z.mentionInputLoading}):w.slice(0,O).map((e,n)=>(0,c.jsx)("div",{onClick:()=>q(e),className:(0,L.cn)(n===D&&"bg-gray-100 dark:bg-gray-600"),children:U?U(e):Me(e)},e.id))})]})})});le.displayName="MentionInput";0&&(module.exports={MentionInput});
1
+ "use strict";"use client";var j=Object.defineProperty;var De=Object.getOwnPropertyDescriptor;var Re=Object.getOwnPropertyNames;var Le=Object.prototype.hasOwnProperty;var ke=(t,n)=>{for(var l in n)j(t,l,{get:n[l],enumerable:!0})},Ae=(t,n,l,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let c of Re(n))!Le.call(t,c)&&c!==l&&j(t,c,{get:()=>n[c],enumerable:!(o=De(n,c))||o.enumerable});return t};var He=t=>Ae(j({},"__esModule",{value:!0}),t);var Fe={};ke(Fe,{MentionInput:()=>ge});module.exports=He(Fe);var i=require("react"),le=require("react-dom"),B=require("../../../lib/cn.cjs"),G=require("../../../lib/css-value.cjs"),ce=require("../../../lib/i18n.cjs"),$=require("../shared/inputStyles.cjs"),ue=require("../shared/InputWrapper.cjs"),de=require("../../chip/Chip.cjs"),g=require("react/jsx-runtime"),fe=0,Pe=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),pe=t=>{let n=document.createElement("span");return n.contentEditable="false",n.setAttribute("data-mention-id",t.id),n.setAttribute("data-mention-label",t.label),t.avatar&&n.setAttribute("data-mention-avatar",t.avatar),n.className="inline-block align-middle mx-0.5",n.style.userSelect="none",n},Ve=(t,n)=>{if(typeof document.execCommand=="function")try{if(document.execCommand("insertText",!1,n))return!1}catch{}let l=t.ownerDocument.getSelection();if(!l||l.rangeCount===0)return!1;let o=l.getRangeAt(0);if(!t.contains(o.commonAncestorContainer))return!1;o.deleteContents();let c=t.ownerDocument.createDocumentFragment();n.split(`
2
+ `).forEach((s,u)=>{u>0&&c.appendChild(t.ownerDocument.createElement("br")),s&&c.appendChild(t.ownerDocument.createTextNode(s))});let x=c.lastChild;return o.insertNode(c),x&&(o.setStartAfter(x),o.collapse(!0),l.removeAllRanges(),l.addRange(o)),!0},Be=t=>t.tagName==="DIV"||t.tagName==="P",$e=(t,n,l)=>{let o="",c=[],x=!1,s=h=>{x&&o&&(o+=`
3
+ `),x=!1,o+=h},u=h=>{if(h.nodeType===Node.TEXT_NODE){h.textContent&&s(h.textContent);return}if(h.nodeType!==Node.ELEMENT_NODE)return;let v=h,T=l.get(v);if(T){let D=`@${T.label}`;s(""),c.push({trigger:n,suggestion:T,startIndex:o.length,endIndex:o.length+D.length}),o+=D;return}if(v.tagName==="BR"){s(v.nextSibling?`
4
+ `:"");return}let S=Be(v);S&&o&&(x=!0),v.childNodes.forEach(u),S&&o&&(x=!0)};return t.childNodes.forEach(u),{text:o,mentions:c}},_e=(t,n)=>{t.replaceChildren();let l=[],o=s=>{s.split(`
5
+ `).forEach((u,h)=>{h>0&&t.appendChild(document.createElement("br")),u&&t.appendChild(document.createTextNode(u))})},c=0,x=[...n.mentions].sort((s,u)=>s.startIndex-u.startIndex);for(let s of x){if(s.startIndex<c||s.endIndex>n.text.length||s.endIndex<s.startIndex)continue;o(n.text.slice(c,s.startIndex));let u=pe(s.suggestion);t.appendChild(u),l.push({key:`mention-${++fe}`,element:u,suggestion:s.suggestion}),c=s.endIndex}return o(n.text.slice(c)),t.lastChild?.nodeName==="BR"&&t.appendChild(document.createElement("br")),l},ze=(t,n)=>t.text===n.text&&t.mentions.length===n.mentions.length&&t.mentions.every((l,o)=>l.suggestion.id===n.mentions[o].suggestion.id&&l.startIndex===n.mentions[o].startIndex&&l.endIndex===n.mentions[o].endIndex),Xe=t=>(0,g.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:[t.avatar&&(0,g.jsx)("img",{src:t.avatar,alt:t.label,className:"w-6 h-6 rounded-full"}),(0,g.jsx)("span",{className:"text-sm text-gray-900 dark:text-white",children:t.label})]}),ge=(0,i.forwardRef)(({label:t,inline:n=!1,size:l="md",labelColor:o,borderColor:c,textColor:x,disabled:s=!1,readOnly:u=!1,error:h=!1,helperText:v,hideLabel:T=!1,icon:S,iconPosition:D="left",mentionTrigger:w="@",suggestions:L=[],onMentionSearch:J,onMentionSelect:Z,onMentionRemove:k,renderSuggestion:ee,value:R,onChange:N,placeholder:_,loading:me=!1,loadingLabel:he,maxSuggestions:z=10,chipVariant:xe="soft",chipColor:Ce="primary",chipSize:be="sm"},A)=>{let X=(0,G.safeCssColor)(c),F=(0,G.safeCssColor)(x),te=(0,i.useId)(),Me=(0,ce.useUILabels)(),p=(0,i.useRef)(null),[ne,Ee]=(0,i.useState)([]),C=(0,i.useRef)(ne),M=(0,i.useCallback)(e=>{e!==C.current&&(C.current=e,Ee(e))},[]),[K,H]=(0,i.useState)(!1),[P,q]=(0,i.useState)(0),[Ke,O]=(0,i.useState)(""),ve=(0,B.cn)((0,$.getBaseInputClasses)({size:l,error:h,disabled:s,readOnly:u,icon:S,iconPosition:D}),"min-h-[42px]","whitespace-pre-wrap","break-words"),ye={...X&&{borderColor:X},...F&&{color:F}},Ie=X||F?ye:void 0,E=(0,i.useCallback)(()=>{let e=p.current;if(!e)return{text:"",mentions:[]};let a=new Map(C.current.map(r=>[r.element,r.suggestion]));return $e(e,w,a)},[w]),W=(0,i.useCallback)(e=>{let a=p.current;if(!a||!a.contains(e))return;let r=C.current.find(d=>d.element===e);r&&(e.remove(),M(C.current.filter(d=>d!==r)),N?.(E()),k?.(r.suggestion))},[E,N,k,M]),Q=(0,i.useCallback)(()=>{if(!p.current)return;let e=window.getSelection();if(!e||e.rangeCount===0)return;let a=e.getRangeAt(0),r="";a.startContainer.nodeType===Node.TEXT_NODE&&(r=a.startContainer.textContent?.substring(0,a.startOffset)||"");let d=r.match(new RegExp(`${Pe(w)}([\\p{L}\\p{M}\\p{N}_]*)$`,"u"));if(d){let b=d[1];O(b),H(!0),q(0),J?.(b)}else H(!1),O("");let f=p.current,m=C.current.filter(b=>!f.contains(b.element));m.length>0&&M(C.current.filter(b=>!m.includes(b)));let y=E();N?.(y),m.forEach(b=>k?.(b.suggestion))},[w,J,N,k,E,M]),re=(0,i.useCallback)(e=>{let a=p.current;if(!a)return!1;let r=window.getSelection();if(!r||r.rangeCount===0)return!1;let d=r.getRangeAt(0);if(d.startContainer.nodeType!==Node.TEXT_NODE||!a.contains(d.startContainer))return!1;let f=d.startContainer,m=f.textContent||"",y=d.startOffset,oe=m.substring(0,y).lastIndexOf(w);if(oe===-1)return!1;let se=m.substring(0,oe),ae=m.substring(y),I=pe(e);if(M([...C.current,{key:`mention-${++fe}`,element:I,suggestion:e}]),se?(f.textContent=se,f.parentNode?.insertBefore(I,f.nextSibling)):(f.parentNode?.insertBefore(I,f),f.remove()),ae){let Te=document.createTextNode(ae);I.parentNode?.insertBefore(Te,I.nextSibling)}let ie=document.createTextNode(" ");I.parentNode?.insertBefore(ie,I.nextSibling);let Y=document.createRange();return Y.setStartAfter(ie),Y.collapse(!0),r.removeAllRanges(),r.addRange(Y),!0},[w,M]),U=(0,i.useCallback)(e=>{let a=re(e);if(H(!1),O(""),!a)return;let r=E();N?.(r),Z?.(e),p.current?.focus()},[re,E,N,Z]),V=(0,i.useCallback)(e=>{let a=p.current;!a||s||u||Ve(a,e)&&Q()},[s,u,Q]),Se=(0,i.useCallback)(e=>{e.preventDefault(),V(e.clipboardData.getData("text/plain"))},[V]),we=(0,i.useCallback)(e=>{e.preventDefault();let a=e.dataTransfer.getData("text/plain");if(!a)return;let r=e.currentTarget.ownerDocument,d=r.caretRangeFromPoint?.(e.clientX,e.clientY)??(()=>{let m=r.caretPositionFromPoint?.(e.clientX,e.clientY);if(!m)return null;let y=r.createRange();return y.setStart(m.offsetNode,m.offset),y})(),f=r.getSelection();d&&f&&e.currentTarget.contains(d.startContainer)&&(f.removeAllRanges(),f.addRange(d)),V(a)},[V]),Ne=(0,i.useCallback)(e=>{let a=L.slice(0,z);if(K&&a.length>0)switch(e.key){case"ArrowDown":e.preventDefault(),q(r=>r<a.length-1?r+1:0);return;case"ArrowUp":e.preventDefault(),q(r=>r>0?r-1:a.length-1);return;case"Enter":case"Tab":e.preventDefault(),a[P]&&U(a[P]);return;case"Escape":e.preventDefault(),H(!1);return}if(e.key==="Backspace"){let r=window.getSelection();if(!r||r.rangeCount===0)return;let d=r.getRangeAt(0);if(!d.collapsed||d.startOffset!==0)return;let f=d.startContainer.previousSibling;f&&C.current.some(m=>m.element===f)&&(e.preventDefault(),W(f))}},[K,L,P,z,U,W]);return(0,i.useLayoutEffect)(()=>{let e=p.current;!e||R===void 0||ze(R,E())||M(_e(e,R))},[R,E,M]),(0,i.useEffect)(()=>{p.current&&(!(p.current.textContent||p.current.querySelector("[data-mention-id]"))&&_?p.current.setAttribute("data-placeholder",_):p.current.removeAttribute("data-placeholder"))},[_,R]),(0,g.jsx)(ue.InputWrapper,{label:t,hideLabel:T,labelColor:o,error:h,helperText:v,inline:n,htmlFor:te,children:(0,g.jsxs)("div",{className:"relative w-full",children:[S&&(0,g.jsx)("span",{className:(0,$.getIconClasses)(D),children:S}),(0,g.jsx)("div",{ref:e=>{typeof A=="function"?A(e):A&&(A.current=e),p.current=e},id:te,contentEditable:!s&&!u,suppressContentEditableWarning:!0,onInput:Q,onKeyDown:Ne,onPaste:Se,onDrop:we,className:(0,B.cn)(ve,"empty:before:content-[attr(data-placeholder)] empty:before:text-gray-500 empty:before:dark:text-gray-400"),style:Ie,role:"textbox","aria-label":t,"aria-multiline":"true",tabIndex:u||s?-1:0}),K&&L.length>0&&(0,g.jsx)("div",{onMouseDown:e=>e.preventDefault(),className:"absolute z-10 mt-1 w-full max-h-60 overflow-auto rounded-lg border border-gray-300 bg-white dark:bg-gray-700 dark:border-gray-600 shadow-lg",children:me?(0,g.jsx)("div",{className:"px-3 py-2 text-sm text-gray-500 dark:text-gray-400",children:he??Me.mentionInputLoading}):L.slice(0,z).map((e,a)=>(0,g.jsx)("div",{onClick:()=>U(e),className:(0,B.cn)(a===P&&"bg-gray-100 dark:bg-gray-600"),children:ee?ee(e):Xe(e)},e.id))}),ne.map(e=>(0,le.createPortal)((0,g.jsx)(de.Chip,{label:e.suggestion.label,variant:xe,color:Ce,size:be,closable:!s&&!u,onClose:()=>W(e.element),disabled:s,avatar:e.suggestion.avatar?(0,g.jsx)("img",{src:e.suggestion.avatar,alt:e.suggestion.label,className:"w-full h-full object-cover"}):void 0}),e.element,e.key))]})})});ge.displayName="MentionInput";0&&(module.exports={MentionInput});
@@ -1 +1,5 @@
1
- "use client";import{forwardRef as ge,useCallback as u,useEffect as ee,useId as be,useRef as he,useState as _}from"react";import{createRoot as ve}from"react-dom/client";import{cn as P}from"../../../lib/cn.js";import{useUILabels as xe}from"../../../lib/i18n.js";import{getBaseInputClasses as ye,getIconClasses as Ne}from"../shared/inputStyles.js";import{InputWrapper as Ce}from"../shared/InputWrapper.js";import{Chip as Ee}from"../../chip/Chip.js";import{jsx as l,jsxs as te}from"react/jsx-runtime";var Se=c=>te("div",{className:"flex items-center gap-2 px-3 py-2 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:[c.avatar&&l("img",{src:c.avatar,alt:c.label,className:"w-6 h-6 rounded-full"}),l("span",{className:"text-sm text-gray-900 dark:text-white",children:c.label})]}),Me=ge(({label:c,inline:ne=!1,size:re="md",labelColor:oe,borderColor:I,textColor:T,disabled:f=!1,readOnly:x=!1,error:V=!1,helperText:ae,hideLabel:ie=!1,icon:D,iconPosition:q="left",mentionTrigger:p="@",suggestions:C=[],onMentionSearch:z,onMentionSelect:X,onMentionRemove:$,renderSuggestion:K,value:d,onChange:m,placeholder:A,loading:se=!1,loadingLabel:le,maxSuggestions:L=10,chipVariant:W="soft",chipColor:F="primary",chipSize:Q="sm"},E)=>{let U=be(),j=xe(),G=j.chipRemove,i=he(null),[R,S]=_(!1),[M,k]=_(0),[we,B]=_(""),ce=P(ye({size:re,error:V,disabled:f,readOnly:x,icon:D,iconPosition:q}),"min-h-[42px]","whitespace-pre-wrap","break-words"),de={...I&&{borderColor:I},...T&&{color:T}},ue=I||T?de:void 0,g=u(()=>{if(!i.current)return{text:"",mentions:[]};let e="",n=[],t=0,o=r=>{if(r.nodeType===Node.TEXT_NODE)e+=r.textContent||"",t+=(r.textContent||"").length;else if(r.nodeType===Node.ELEMENT_NODE){let a=r;if(a.hasAttribute("data-mention-id")){let s=a.getAttribute("data-mention-id"),b=a.getAttribute("data-mention-label")||"",w=a.getAttribute("data-mention-avatar")||void 0,h=`@${b}`,N=t;n.push({trigger:p,suggestion:{id:s||"",label:b,avatar:w},startIndex:N,endIndex:N+h.length}),e+=h,t+=h.length}else a.childNodes.forEach(o)}};return i.current.childNodes.forEach(o),{text:e,mentions:n}},[p]),J=u((e,n)=>{let t=document.createElement("span");return t.contentEditable="false",t.setAttribute("data-mention-id",e.id),t.setAttribute("data-mention-label",e.label),e.avatar&&t.setAttribute("data-mention-avatar",e.avatar),t.className="inline-block align-middle mx-0.5",t.style.userSelect="none",ve(t).render(l(Ee,{label:e.label,variant:W,color:F,size:Q,closable:!f&&!x,removeLabel:G,onClose:n,disabled:f,avatar:e.avatar?l("img",{src:e.avatar,alt:e.label,className:"w-full h-full object-cover"}):void 0})),t},[W,F,Q,f,x,G]),y=u(e=>{if(!i.current)return;let n=i.current.querySelector(`[data-mention-id="${e}"]`);if(n){n.remove();let t=g();m?.(t);let o=d?.mentions.find(r=>r.suggestion.id===e)?.suggestion;o&&$?.(o)}},[g,m,$,d?.mentions]),fe=u(()=>{if(!i.current)return;let e=window.getSelection();if(!e||e.rangeCount===0)return;let n=e.getRangeAt(0),t="";n.startContainer.nodeType===Node.TEXT_NODE&&(t=n.startContainer.textContent?.substring(0,n.startOffset)||"");let o=t.match(new RegExp(`${p}(\\w*)$`));if(o){let a=o[1];B(a),S(!0),k(0),z?.(a)}else S(!1),B("");let r=g();m?.(r)},[p,z,m,g]),Y=u(e=>{let n=i.current;if(!n)return!1;let t=window.getSelection();if(!t||t.rangeCount===0)return!1;let o=t.getRangeAt(0);if(o.startContainer.nodeType!==Node.TEXT_NODE||!n.contains(o.startContainer))return!1;let r=o.startContainer,a=r.textContent||"",s=o.startOffset,w=a.substring(0,s).lastIndexOf(p);if(w===-1)return!1;let h=a.substring(0,w),N=a.substring(s),v=J(e,()=>{y(e.id)});if(h?(r.textContent=h,r.parentNode?.insertBefore(v,r.nextSibling)):(r.parentNode?.insertBefore(v,r),r.remove()),N){let me=document.createTextNode(N);v.parentNode?.insertBefore(me,v.nextSibling)}let Z=document.createTextNode(" ");v.parentNode?.insertBefore(Z,v.nextSibling);let O=document.createRange();return O.setStartAfter(Z),O.collapse(!0),t.removeAllRanges(),t.addRange(O),!0},[p,J,y]),H=u(e=>{let n=Y(e);if(S(!1),B(""),!n)return;let t=g();m?.(t),X?.(e),i.current?.focus()},[Y,g,m,X]),pe=u(e=>{let n=C.slice(0,L);if(R&&n.length>0)switch(e.key){case"ArrowDown":e.preventDefault(),k(t=>t<n.length-1?t+1:0);return;case"ArrowUp":e.preventDefault(),k(t=>t>0?t-1:n.length-1);return;case"Enter":case"Tab":e.preventDefault(),n[M]&&H(n[M]);return;case"Escape":e.preventDefault(),S(!1);return}if(e.key==="Backspace"){let t=window.getSelection();if(!t||t.rangeCount===0)return;let o=t.getRangeAt(0);if(o.collapsed&&o.startOffset===0){let r=o.startContainer.previousSibling;if(r&&r.nodeType===Node.ELEMENT_NODE){let a=r;if(a.hasAttribute("data-mention-id")){e.preventDefault();let s=a.getAttribute("data-mention-id");s&&y(s);return}}}if(o.collapsed&&o.startContainer.nodeType===Node.TEXT_NODE){let r=o.startContainer;if(o.startOffset===0){let a=r.previousSibling;if(a&&a.nodeType===Node.ELEMENT_NODE){let s=a;if(s.hasAttribute("data-mention-id")){e.preventDefault();let b=s.getAttribute("data-mention-id");b&&y(b);return}}}}}},[R,C,M,L,H,y]);return ee(()=>{i.current&&(!(i.current.textContent||i.current.querySelector("[data-mention-id]"))&&A?i.current.setAttribute("data-placeholder",A):i.current.removeAttribute("data-placeholder"))},[A,d]),ee(()=>{i.current&&d?.text===""&&d?.mentions.length===0&&i.current.innerHTML.trim()&&(i.current.innerHTML="")},[d?.text,d?.mentions.length]),l(Ce,{label:c,hideLabel:ie,labelColor:oe,error:V,helperText:ae,inline:ne,htmlFor:U,children:te("div",{className:"relative w-full",children:[D&&l("span",{className:Ne(q),children:D}),l("div",{ref:e=>{typeof E=="function"?E(e):E&&(E.current=e),i.current=e},id:U,contentEditable:!f&&!x,suppressContentEditableWarning:!0,onInput:fe,onKeyDown:pe,className:P(ce,"empty:before:content-[attr(data-placeholder)] empty:before:text-gray-500 empty:before:dark:text-gray-400"),style:ue,role:"textbox","aria-label":c,"aria-multiline":"true",tabIndex:x||f?-1:0}),R&&C.length>0&&l("div",{onMouseDown:e=>e.preventDefault(),className:"absolute z-10 mt-1 w-full max-h-60 overflow-auto rounded-lg border border-gray-300 bg-white dark:bg-gray-700 dark:border-gray-600 shadow-lg",children:se?l("div",{className:"px-3 py-2 text-sm text-gray-500 dark:text-gray-400",children:le??j.mentionInputLoading}):C.slice(0,L).map((e,n)=>l("div",{onClick:()=>H(e),className:P(n===M&&"bg-gray-100 dark:bg-gray-600"),children:K?K(e):Se(e)},e.id))})]})})});Me.displayName="MentionInput";export{Me as MentionInput};
1
+ "use client";import{forwardRef as Se,useCallback as h,useEffect as we,useId as Ne,useLayoutEffect as Te,useRef as ae,useState as B}from"react";import{createPortal as De}from"react-dom";import{cn as Y}from"../../../lib/cn.js";import{safeCssColor as ie}from"../../../lib/css-value.js";import{useUILabels as Re}from"../../../lib/i18n.js";import{getBaseInputClasses as Le,getIconClasses as ke}from"../shared/inputStyles.js";import{InputWrapper as Ae}from"../shared/InputWrapper.js";import{Chip as He}from"../../chip/Chip.js";import{jsx as x,jsxs as ue}from"react/jsx-runtime";var le=0,Pe=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),ce=t=>{let s=document.createElement("span");return s.contentEditable="false",s.setAttribute("data-mention-id",t.id),s.setAttribute("data-mention-label",t.label),t.avatar&&s.setAttribute("data-mention-avatar",t.avatar),s.className="inline-block align-middle mx-0.5",s.style.userSelect="none",s},Ve=(t,s)=>{if(typeof document.execCommand=="function")try{if(document.execCommand("insertText",!1,s))return!1}catch{}let u=t.ownerDocument.getSelection();if(!u||u.rangeCount===0)return!1;let a=u.getRangeAt(0);if(!t.contains(a.commonAncestorContainer))return!1;a.deleteContents();let d=t.ownerDocument.createDocumentFragment();s.split(`
2
+ `).forEach((r,i)=>{i>0&&d.appendChild(t.ownerDocument.createElement("br")),r&&d.appendChild(t.ownerDocument.createTextNode(r))});let m=d.lastChild;return a.insertNode(d),m&&(a.setStartAfter(m),a.collapse(!0),u.removeAllRanges(),u.addRange(a)),!0},Be=t=>t.tagName==="DIV"||t.tagName==="P",$e=(t,s,u)=>{let a="",d=[],m=!1,r=g=>{m&&a&&(a+=`
3
+ `),m=!1,a+=g},i=g=>{if(g.nodeType===Node.TEXT_NODE){g.textContent&&r(g.textContent);return}if(g.nodeType!==Node.ELEMENT_NODE)return;let v=g,T=u.get(v);if(T){let D=`@${T.label}`;r(""),d.push({trigger:s,suggestion:T,startIndex:a.length,endIndex:a.length+D.length}),a+=D;return}if(v.tagName==="BR"){r(v.nextSibling?`
4
+ `:"");return}let S=Be(v);S&&a&&(m=!0),v.childNodes.forEach(i),S&&a&&(m=!0)};return t.childNodes.forEach(i),{text:a,mentions:d}},_e=(t,s)=>{t.replaceChildren();let u=[],a=r=>{r.split(`
5
+ `).forEach((i,g)=>{g>0&&t.appendChild(document.createElement("br")),i&&t.appendChild(document.createTextNode(i))})},d=0,m=[...s.mentions].sort((r,i)=>r.startIndex-i.startIndex);for(let r of m){if(r.startIndex<d||r.endIndex>s.text.length||r.endIndex<r.startIndex)continue;a(s.text.slice(d,r.startIndex));let i=ce(r.suggestion);t.appendChild(i),u.push({key:`mention-${++le}`,element:i,suggestion:r.suggestion}),d=r.endIndex}return a(s.text.slice(d)),t.lastChild?.nodeName==="BR"&&t.appendChild(document.createElement("br")),u},ze=(t,s)=>t.text===s.text&&t.mentions.length===s.mentions.length&&t.mentions.every((u,a)=>u.suggestion.id===s.mentions[a].suggestion.id&&u.startIndex===s.mentions[a].startIndex&&u.endIndex===s.mentions[a].endIndex),Xe=t=>ue("div",{className:"flex items-center gap-2 px-3 py-2 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:[t.avatar&&x("img",{src:t.avatar,alt:t.label,className:"w-6 h-6 rounded-full"}),x("span",{className:"text-sm text-gray-900 dark:text-white",children:t.label})]}),Fe=Se(({label:t,inline:s=!1,size:u="md",labelColor:a,borderColor:d,textColor:m,disabled:r=!1,readOnly:i=!1,error:g=!1,helperText:v,hideLabel:T=!1,icon:S,iconPosition:D="left",mentionTrigger:w="@",suggestions:L=[],onMentionSearch:j,onMentionSelect:G,onMentionRemove:k,renderSuggestion:J,value:R,onChange:N,placeholder:$,loading:de=!1,loadingLabel:fe,maxSuggestions:_=10,chipVariant:pe="soft",chipColor:ge="primary",chipSize:me="sm"},A)=>{let z=ie(d),X=ie(m),Z=Ne(),he=Re(),f=ae(null),[ee,xe]=B([]),C=ae(ee),M=h(e=>{e!==C.current&&(C.current=e,xe(e))},[]),[F,H]=B(!1),[P,K]=B(0),[Ke,q]=B(""),Ce=Y(Le({size:u,error:g,disabled:r,readOnly:i,icon:S,iconPosition:D}),"min-h-[42px]","whitespace-pre-wrap","break-words"),be={...z&&{borderColor:z},...X&&{color:X}},Me=z||X?be:void 0,E=h(()=>{let e=f.current;if(!e)return{text:"",mentions:[]};let o=new Map(C.current.map(n=>[n.element,n.suggestion]));return $e(e,w,o)},[w]),O=h(e=>{let o=f.current;if(!o||!o.contains(e))return;let n=C.current.find(l=>l.element===e);n&&(e.remove(),M(C.current.filter(l=>l!==n)),N?.(E()),k?.(n.suggestion))},[E,N,k,M]),W=h(()=>{if(!f.current)return;let e=window.getSelection();if(!e||e.rangeCount===0)return;let o=e.getRangeAt(0),n="";o.startContainer.nodeType===Node.TEXT_NODE&&(n=o.startContainer.textContent?.substring(0,o.startOffset)||"");let l=n.match(new RegExp(`${Pe(w)}([\\p{L}\\p{M}\\p{N}_]*)$`,"u"));if(l){let b=l[1];q(b),H(!0),K(0),j?.(b)}else H(!1),q("");let c=f.current,p=C.current.filter(b=>!c.contains(b.element));p.length>0&&M(C.current.filter(b=>!p.includes(b)));let y=E();N?.(y),p.forEach(b=>k?.(b.suggestion))},[w,j,N,k,E,M]),te=h(e=>{let o=f.current;if(!o)return!1;let n=window.getSelection();if(!n||n.rangeCount===0)return!1;let l=n.getRangeAt(0);if(l.startContainer.nodeType!==Node.TEXT_NODE||!o.contains(l.startContainer))return!1;let c=l.startContainer,p=c.textContent||"",y=l.startOffset,ne=p.substring(0,y).lastIndexOf(w);if(ne===-1)return!1;let re=p.substring(0,ne),oe=p.substring(y),I=ce(e);if(M([...C.current,{key:`mention-${++le}`,element:I,suggestion:e}]),re?(c.textContent=re,c.parentNode?.insertBefore(I,c.nextSibling)):(c.parentNode?.insertBefore(I,c),c.remove()),oe){let Ie=document.createTextNode(oe);I.parentNode?.insertBefore(Ie,I.nextSibling)}let se=document.createTextNode(" ");I.parentNode?.insertBefore(se,I.nextSibling);let U=document.createRange();return U.setStartAfter(se),U.collapse(!0),n.removeAllRanges(),n.addRange(U),!0},[w,M]),Q=h(e=>{let o=te(e);if(H(!1),q(""),!o)return;let n=E();N?.(n),G?.(e),f.current?.focus()},[te,E,N,G]),V=h(e=>{let o=f.current;!o||r||i||Ve(o,e)&&W()},[r,i,W]),Ee=h(e=>{e.preventDefault(),V(e.clipboardData.getData("text/plain"))},[V]),ve=h(e=>{e.preventDefault();let o=e.dataTransfer.getData("text/plain");if(!o)return;let n=e.currentTarget.ownerDocument,l=n.caretRangeFromPoint?.(e.clientX,e.clientY)??(()=>{let p=n.caretPositionFromPoint?.(e.clientX,e.clientY);if(!p)return null;let y=n.createRange();return y.setStart(p.offsetNode,p.offset),y})(),c=n.getSelection();l&&c&&e.currentTarget.contains(l.startContainer)&&(c.removeAllRanges(),c.addRange(l)),V(o)},[V]),ye=h(e=>{let o=L.slice(0,_);if(F&&o.length>0)switch(e.key){case"ArrowDown":e.preventDefault(),K(n=>n<o.length-1?n+1:0);return;case"ArrowUp":e.preventDefault(),K(n=>n>0?n-1:o.length-1);return;case"Enter":case"Tab":e.preventDefault(),o[P]&&Q(o[P]);return;case"Escape":e.preventDefault(),H(!1);return}if(e.key==="Backspace"){let n=window.getSelection();if(!n||n.rangeCount===0)return;let l=n.getRangeAt(0);if(!l.collapsed||l.startOffset!==0)return;let c=l.startContainer.previousSibling;c&&C.current.some(p=>p.element===c)&&(e.preventDefault(),O(c))}},[F,L,P,_,Q,O]);return Te(()=>{let e=f.current;!e||R===void 0||ze(R,E())||M(_e(e,R))},[R,E,M]),we(()=>{f.current&&(!(f.current.textContent||f.current.querySelector("[data-mention-id]"))&&$?f.current.setAttribute("data-placeholder",$):f.current.removeAttribute("data-placeholder"))},[$,R]),x(Ae,{label:t,hideLabel:T,labelColor:a,error:g,helperText:v,inline:s,htmlFor:Z,children:ue("div",{className:"relative w-full",children:[S&&x("span",{className:ke(D),children:S}),x("div",{ref:e=>{typeof A=="function"?A(e):A&&(A.current=e),f.current=e},id:Z,contentEditable:!r&&!i,suppressContentEditableWarning:!0,onInput:W,onKeyDown:ye,onPaste:Ee,onDrop:ve,className:Y(Ce,"empty:before:content-[attr(data-placeholder)] empty:before:text-gray-500 empty:before:dark:text-gray-400"),style:Me,role:"textbox","aria-label":t,"aria-multiline":"true",tabIndex:i||r?-1:0}),F&&L.length>0&&x("div",{onMouseDown:e=>e.preventDefault(),className:"absolute z-10 mt-1 w-full max-h-60 overflow-auto rounded-lg border border-gray-300 bg-white dark:bg-gray-700 dark:border-gray-600 shadow-lg",children:de?x("div",{className:"px-3 py-2 text-sm text-gray-500 dark:text-gray-400",children:fe??he.mentionInputLoading}):L.slice(0,_).map((e,o)=>x("div",{onClick:()=>Q(e),className:Y(o===P&&"bg-gray-100 dark:bg-gray-600"),children:J?J(e):Xe(e)},e.id))}),ee.map(e=>De(x(He,{label:e.suggestion.label,variant:pe,color:ge,size:me,closable:!r&&!i,onClose:()=>O(e.element),disabled:r,avatar:e.suggestion.avatar?x("img",{src:e.suggestion.avatar,alt:e.suggestion.label,className:"w-full h-full object-cover"}):void 0}),e.element,e.key))]})})});Fe.displayName="MentionInput";export{Fe as MentionInput};
@@ -1 +1 @@
1
- "use strict";"use client";var T=Object.defineProperty;var De=Object.getOwnPropertyDescriptor;var Ne=Object.getOwnPropertyNames;var we=Object.prototype.hasOwnProperty;var Ee=(n,r)=>{for(var l in r)T(n,l,{get:r[l],enumerable:!0})},Se=(n,r,l,F)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of Ne(r))!we.call(n,o)&&o!==l&&T(n,o,{get:()=>r[o],enumerable:!(F=De(r,o))||F.enumerable});return n};var $e=n=>Se(T({},"__esModule",{value:!0}),n);var Le={};Ee(Le,{NumberInput:()=>Y});module.exports=$e(Le);var u=require("react"),J=require("../../../lib/cn.cjs"),Q=require("../../../lib/i18n.cjs"),I=require("../shared/inputStyles.cjs"),X=require("../shared/InputWrapper.cjs"),g=require("react/jsx-runtime");function Ce(n){try{return new Intl.NumberFormat(n,{numberingSystem:"latn"}).formatToParts(1.1).find(l=>l.type==="decimal")?.value??"."}catch{return"."}}function Me(n){try{return new Intl.NumberFormat(n,{numberingSystem:"latn"}).formatToParts(12345.6).find(l=>l.type==="group")?.value??""}catch{return""}}function q(n){let r=w(Math.abs(n),"."),l=r.indexOf(".");return l===-1?0:r.length-l-1}function w(n,r){if(!Number.isFinite(n))return"";if(n===0)return"0";let l=n.toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:20});return r==="."?l:l.replace(".",r)}var Ke=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Y=(0,u.forwardRef)(({label:n,inline:r=!1,size:l="md",labelColor:F,borderColor:o,textColor:E,disabled:S=!1,readOnly:$=!1,error:V=!1,helperText:Z,hideLabel:_=!1,icon:b,iconPosition:y="left",className:ee,value:k,defaultValue:te,onChange:ne,format:h="number",currency:A="USD",locale:re,decimals:s,min:C,max:M,step:U=1,prefix:c,suffix:p,thousandSeparator:H=!0,allowNegative:R=!0,onBlur:x,onFocus:B,id:le,...ae},ue)=>{let oe=(0,u.useId)(),P=le||oe,d=(0,Q.useUILocale)(re)??"en-US",i=(0,u.useMemo)(()=>Ce(d),[d]),K=(0,u.useMemo)(()=>Me(d),[d]),ie=(0,u.useMemo)(()=>new RegExp(`^-?\\d*(?:${Ke(i)}\\d*)?$`),[i]),G=k!==void 0,[se,ce]=(0,u.useState)(te??null),f=G?k:se,L=t=>{G||ce(t),ne?.(t)},[v,D]=(0,u.useState)(null),O=(0,u.useMemo)(()=>{let t=h==="currency"?{style:"currency",currency:A,minimumFractionDigits:s??2,maximumFractionDigits:s??2}:h==="percentage"?{minimumFractionDigits:s??0,maximumFractionDigits:s??2}:{minimumFractionDigits:s??0,maximumFractionDigits:s??(h==="decimal"?2:0),useGrouping:H};try{return new Intl.NumberFormat(d,t)}catch{return null}},[h,A,d,s,H]),W=s,me=t=>{if(t==null)return"";if(!O)return String(t);let e=O.format(t);return h==="percentage"?(e=c?`${c}${e}`:e,e=p||!e.includes("%")?`${e}%`:e,e):(c&&(e=`${c}${e}`),p&&(e=`${e}${p}`),e)},N=t=>{if(!t||t.trim()==="")return null;let e=t;if(c&&(e=e.replace(c,"")),p&&(e=e.replace(p,"")),e=Array.from(e).filter(m=>/[\d-]/.test(m)||m===i).join("").replace(i,"."),!e||e==="-"||e===".")return null;let a=parseFloat(e);return isNaN(a)?null:(!R&&a<0&&(a=Math.abs(a)),W!==void 0&&(a=Number(a.toFixed(W))),C!==void 0&&a<C?C:M!==void 0&&a>M?M:a)},pe=t=>{let e=t;return c&&(e=e.replace(c,"")),p&&(e=e.replace(p,"")),e=e.replace(/[\u2212\u2012\u2013]/g,"-").replace(/[\s%\p{Sc}]/gu,""),K&&K!==i?e.split(K).join(""):e},z=v??me(f??null),j=t=>ie.test(t),ge=t=>{let e=t.target.value;e!==""&&!j(e)&&(e=pe(e),!j(e))||(D(e),L(N(e)))},de=t=>{let e=N(v??"")??f??0,a=Math.min(Math.max(q(U),q(e)),20),m=N(w(Number((e+t*U).toFixed(a)),i));D(m===null?"":w(m,i)),L(m)},fe=t=>{let e=["Backspace","Delete","Tab","Escape","Enter","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"];if((t.key==="ArrowUp"||t.key==="ArrowDown")&&!S&&!$&&!t.altKey&&!t.ctrlKey&&!t.metaKey){t.preventDefault(),de(t.key==="ArrowUp"?1:-1);return}let a=/^[0-9]$/.test(t.key),m=t.key===i,Fe=t.key==="-"&&R&&z.indexOf("-")===-1,ve=t.ctrlKey||t.metaKey;!a&&!m&&!Fe&&!e.includes(t.key)&&!ve&&t.preventDefault()},be=t=>{D(f!=null?w(f,i):""),B&&B(t)},ye=t=>{if(v!==null){let e=N(v);e!==f&&L(e)}D(null),x&&x(t)},he=(0,J.cn)((0,I.getBaseInputClasses)({size:l,error:V,disabled:S,readOnly:$,icon:b,iconPosition:y}),o&&`border-[${o}]`,E&&`text-[${E}]`,ee),Ie=(0,g.jsxs)("div",{className:"relative",children:[b&&y==="left"&&(0,g.jsx)("div",{className:(0,I.getIconClasses)(y),children:b}),(0,g.jsx)("input",{ref:ue,id:P,type:"text",inputMode:"decimal",className:he,style:{borderColor:o,color:E},disabled:S,readOnly:$,value:z,onChange:ge,onKeyDown:fe,onFocus:be,onBlur:ye,...ae}),b&&y==="right"&&(0,g.jsx)("div",{className:(0,I.getIconClasses)(y),children:b})]});return(0,g.jsx)(X.InputWrapper,{label:n,hideLabel:_,labelColor:F,error:V,helperText:Z,inline:r,htmlFor:P,children:Ie})});Y.displayName="NumberInput";0&&(module.exports={NumberInput});
1
+ "use strict";"use client";var V=Object.defineProperty;var we=Object.getOwnPropertyDescriptor;var Ee=Object.getOwnPropertyNames;var Se=Object.prototype.hasOwnProperty;var $e=(n,r)=>{for(var l in r)V(n,l,{get:r[l],enumerable:!0})},Me=(n,r,l,C)=>{if(r&&typeof r=="object"||typeof r=="function")for(let m of Ee(r))!Se.call(n,m)&&m!==l&&V(n,m,{get:()=>r[m],enumerable:!(C=we(r,m))||C.enumerable});return n};var Ke=n=>Me(V({},"__esModule",{value:!0}),n);var ke={};$e(ke,{NumberInput:()=>_});module.exports=Ke(ke);var a=require("react"),X=require("../../../lib/cn.cjs"),k=require("../../../lib/css-value.cjs"),Y=require("../../../lib/i18n.cjs"),I=require("../shared/inputStyles.cjs"),Z=require("../shared/InputWrapper.cjs"),d=require("react/jsx-runtime");function Le(n){try{return new Intl.NumberFormat(n,{numberingSystem:"latn"}).formatToParts(1.1).find(l=>l.type==="decimal")?.value??"."}catch{return"."}}function Te(n){try{return new Intl.NumberFormat(n,{numberingSystem:"latn"}).formatToParts(12345.6).find(l=>l.type==="group")?.value??""}catch{return""}}function Q(n){let r=N(Math.abs(n),"."),l=r.indexOf(".");return l===-1?0:r.length-l-1}function N(n,r){if(!Number.isFinite(n))return"";if(n===0)return"0";let l=n.toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:20});return r==="."?l:l.replace(".",r)}var Ve=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),_=(0,a.forwardRef)(({label:n,inline:r=!1,size:l="md",labelColor:C,borderColor:m,textColor:ee,disabled:w=!1,readOnly:E=!1,error:x=!1,helperText:te,hideLabel:ne=!1,icon:b,iconPosition:y="left",className:re,value:A,defaultValue:le,onChange:oe,format:h="number",currency:U="USD",locale:ae,decimals:s,min:S,max:$,step:H=1,prefix:i,suffix:p,thousandSeparator:R=!0,allowNegative:B=!0,onBlur:P,onFocus:G,id:ue,...se},ie)=>{let M=(0,k.safeCssColor)(m),K=(0,k.safeCssColor)(ee),ce=(0,a.useId)(),O=ue||ce,g=(0,Y.useUILocale)(ae)??"en-US",u=(0,a.useMemo)(()=>Le(g),[g]),L=(0,a.useMemo)(()=>Te(g),[g]),me=(0,a.useMemo)(()=>new RegExp(`^-?\\d*(?:${Ve(u)}\\d*)?$`),[u]),W=A!==void 0,[pe,de]=(0,a.useState)(le??null),f=W?A:pe,T=t=>{W||de(t),oe?.(t)},[F,v]=(0,a.useState)(null),z=(0,a.useMemo)(()=>{let t=h==="currency"?{style:"currency",currency:U,minimumFractionDigits:s??2,maximumFractionDigits:s??2}:h==="percentage"?{minimumFractionDigits:s??0,maximumFractionDigits:s??2}:{minimumFractionDigits:s??0,maximumFractionDigits:s??(h==="decimal"?2:0),useGrouping:R};try{return new Intl.NumberFormat(g,t)}catch{return null}},[h,U,g,s,R]),j=s,ge=t=>{if(t==null)return"";if(!z)return String(t);let e=z.format(t);return h==="percentage"?(e=i?`${i}${e}`:e,e=p||!e.includes("%")?`${e}%`:e,e):(i&&(e=`${i}${e}`),p&&(e=`${e}${p}`),e)},D=t=>{if(!t||t.trim()==="")return null;let e=t;if(i&&(e=e.replace(i,"")),p&&(e=e.replace(p,"")),e=Array.from(e).filter(c=>/[\d-]/.test(c)||c===u).join("").replace(u,"."),!e||e==="-"||e===".")return null;let o=parseFloat(e);return isNaN(o)?null:(!B&&o<0&&(o=Math.abs(o)),j!==void 0&&(o=Number(o.toFixed(j))),S!==void 0&&o<S?S:$!==void 0&&o>$?$:o)},fe=t=>{let e=t;return i&&(e=e.replace(i,"")),p&&(e=e.replace(p,"")),e=e.replace(/[\u2212\u2012\u2013]/g,"-").replace(/[\s%\p{Sc}]/gu,""),L&&L!==u?e.split(L).join(""):e},q=F??ge(f??null),J=t=>me.test(t),be=t=>{let e=t.target.value;e!==""&&!J(e)&&(e=fe(e),!J(e))||(v(e),T(D(e)))},ye=t=>{let e=D(F??"")??f??0,o=Math.min(Math.max(Q(H),Q(e)),20),c=D(N(Number((e+t*H).toFixed(o)),u));v(c===null?"":N(c,u)),T(c)},he=t=>{let e=["Backspace","Delete","Tab","Escape","Enter","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"];if((t.key==="ArrowUp"||t.key==="ArrowDown")&&!w&&!E&&!t.altKey&&!t.ctrlKey&&!t.metaKey){t.preventDefault(),ye(t.key==="ArrowUp"?1:-1);return}let o=/^[0-9]$/.test(t.key),c=t.key===u,De=t.key==="-"&&B&&q.indexOf("-")===-1,Ne=t.ctrlKey||t.metaKey;!o&&!c&&!De&&!e.includes(t.key)&&!Ne&&t.preventDefault()},Ie=t=>{v(f!=null?N(f,u):""),G&&G(t)},Ce=t=>{if(F!==null){let e=D(F);e!==f&&T(e)}v(null),P&&P(t)},Fe=(0,X.cn)((0,I.getBaseInputClasses)({size:l,error:x,disabled:w,readOnly:E,icon:b,iconPosition:y}),M&&`border-[${M}]`,K&&`text-[${K}]`,re),ve=(0,d.jsxs)("div",{className:"relative",children:[b&&y==="left"&&(0,d.jsx)("div",{className:(0,I.getIconClasses)(y),children:b}),(0,d.jsx)("input",{ref:ie,id:O,type:"text",inputMode:"decimal",className:Fe,style:{borderColor:M,color:K},disabled:w,readOnly:E,value:q,onChange:be,onKeyDown:he,onFocus:Ie,onBlur:Ce,...se}),b&&y==="right"&&(0,d.jsx)("div",{className:(0,I.getIconClasses)(y),children:b})]});return(0,d.jsx)(Z.InputWrapper,{label:n,hideLabel:ne,labelColor:C,error:x,helperText:te,inline:r,htmlFor:O,children:ve})});_.displayName="NumberInput";0&&(module.exports={NumberInput});
@@ -1 +1 @@
1
- "use client";import{forwardRef as he,useId as Ie,useState as W,useMemo as I}from"react";import{cn as Fe}from"../../../lib/cn.js";import{useUILocale as ve}from"../../../lib/i18n.js";import{getBaseInputClasses as De,getIconClasses as z}from"../shared/inputStyles.js";import{InputWrapper as Ne}from"../shared/InputWrapper.js";import{jsx as F,jsxs as Ce}from"react/jsx-runtime";function we(n){try{return new Intl.NumberFormat(n,{numberingSystem:"latn"}).formatToParts(1.1).find(l=>l.type==="decimal")?.value??"."}catch{return"."}}function Ee(n){try{return new Intl.NumberFormat(n,{numberingSystem:"latn"}).formatToParts(12345.6).find(l=>l.type==="group")?.value??""}catch{return""}}function j(n){let a=v(Math.abs(n),"."),l=a.indexOf(".");return l===-1?0:a.length-l-1}function v(n,a){if(!Number.isFinite(n))return"";if(n===0)return"0";let l=n.toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:20});return a==="."?l:l.replace(".",a)}var Se=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),$e=he(({label:n,inline:a=!1,size:l="md",labelColor:q,borderColor:D,textColor:N,disabled:w=!1,readOnly:E=!1,error:K=!1,helperText:J,hideLabel:Q=!1,icon:g,iconPosition:d="left",className:X,value:L,defaultValue:Y,onChange:Z,format:f="number",currency:T="USD",locale:_,decimals:o,min:S,max:$,step:V=1,prefix:i,suffix:c,thousandSeparator:k=!0,allowNegative:A=!0,onBlur:U,onFocus:H,id:ee,...te},ne)=>{let re=Ie(),R=ee||re,m=ve(_)??"en-US",u=I(()=>we(m),[m]),C=I(()=>Ee(m),[m]),le=I(()=>new RegExp(`^-?\\d*(?:${Se(u)}\\d*)?$`),[u]),x=L!==void 0,[ae,ue]=W(Y??null),p=x?L:ae,M=t=>{x||ue(t),Z?.(t)},[b,y]=W(null),B=I(()=>{let t=f==="currency"?{style:"currency",currency:T,minimumFractionDigits:o??2,maximumFractionDigits:o??2}:f==="percentage"?{minimumFractionDigits:o??0,maximumFractionDigits:o??2}:{minimumFractionDigits:o??0,maximumFractionDigits:o??(f==="decimal"?2:0),useGrouping:k};try{return new Intl.NumberFormat(m,t)}catch{return null}},[f,T,m,o,k]),P=o,oe=t=>{if(t==null)return"";if(!B)return String(t);let e=B.format(t);return f==="percentage"?(e=i?`${i}${e}`:e,e=c||!e.includes("%")?`${e}%`:e,e):(i&&(e=`${i}${e}`),c&&(e=`${e}${c}`),e)},h=t=>{if(!t||t.trim()==="")return null;let e=t;if(i&&(e=e.replace(i,"")),c&&(e=e.replace(c,"")),e=Array.from(e).filter(s=>/[\d-]/.test(s)||s===u).join("").replace(u,"."),!e||e==="-"||e===".")return null;let r=parseFloat(e);return isNaN(r)?null:(!A&&r<0&&(r=Math.abs(r)),P!==void 0&&(r=Number(r.toFixed(P))),S!==void 0&&r<S?S:$!==void 0&&r>$?$:r)},ie=t=>{let e=t;return i&&(e=e.replace(i,"")),c&&(e=e.replace(c,"")),e=e.replace(/[\u2212\u2012\u2013]/g,"-").replace(/[\s%\p{Sc}]/gu,""),C&&C!==u?e.split(C).join(""):e},G=b??oe(p??null),O=t=>le.test(t),se=t=>{let e=t.target.value;e!==""&&!O(e)&&(e=ie(e),!O(e))||(y(e),M(h(e)))},ce=t=>{let e=h(b??"")??p??0,r=Math.min(Math.max(j(V),j(e)),20),s=h(v(Number((e+t*V).toFixed(r)),u));y(s===null?"":v(s,u)),M(s)},me=t=>{let e=["Backspace","Delete","Tab","Escape","Enter","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"];if((t.key==="ArrowUp"||t.key==="ArrowDown")&&!w&&!E&&!t.altKey&&!t.ctrlKey&&!t.metaKey){t.preventDefault(),ce(t.key==="ArrowUp"?1:-1);return}let r=/^[0-9]$/.test(t.key),s=t.key===u,be=t.key==="-"&&A&&G.indexOf("-")===-1,ye=t.ctrlKey||t.metaKey;!r&&!s&&!be&&!e.includes(t.key)&&!ye&&t.preventDefault()},pe=t=>{y(p!=null?v(p,u):""),H&&H(t)},ge=t=>{if(b!==null){let e=h(b);e!==p&&M(e)}y(null),U&&U(t)},de=Fe(De({size:l,error:K,disabled:w,readOnly:E,icon:g,iconPosition:d}),D&&`border-[${D}]`,N&&`text-[${N}]`,X),fe=Ce("div",{className:"relative",children:[g&&d==="left"&&F("div",{className:z(d),children:g}),F("input",{ref:ne,id:R,type:"text",inputMode:"decimal",className:de,style:{borderColor:D,color:N},disabled:w,readOnly:E,value:G,onChange:se,onKeyDown:me,onFocus:pe,onBlur:ge,...te}),g&&d==="right"&&F("div",{className:z(d),children:g})]});return F(Ne,{label:n,hideLabel:Q,labelColor:q,error:K,helperText:J,inline:a,htmlFor:R,children:fe})});$e.displayName="NumberInput";export{$e as NumberInput};
1
+ "use client";import{forwardRef as Fe,useId as ve,useState as W,useMemo as I}from"react";import{cn as De}from"../../../lib/cn.js";import{safeCssColor as z}from"../../../lib/css-value.js";import{useUILocale as Ne}from"../../../lib/i18n.js";import{getBaseInputClasses as we,getIconClasses as j}from"../shared/inputStyles.js";import{InputWrapper as Ee}from"../shared/InputWrapper.js";import{jsx as C,jsxs as Le}from"react/jsx-runtime";function Se(n){try{return new Intl.NumberFormat(n,{numberingSystem:"latn"}).formatToParts(1.1).find(l=>l.type==="decimal")?.value??"."}catch{return"."}}function $e(n){try{return new Intl.NumberFormat(n,{numberingSystem:"latn"}).formatToParts(12345.6).find(l=>l.type==="group")?.value??""}catch{return""}}function q(n){let o=F(Math.abs(n),"."),l=o.indexOf(".");return l===-1?0:o.length-l-1}function F(n,o){if(!Number.isFinite(n))return"";if(n===0)return"0";let l=n.toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:20});return o==="."?l:l.replace(".",o)}var Me=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Ke=Fe(({label:n,inline:o=!1,size:l="md",labelColor:J,borderColor:Q,textColor:X,disabled:v=!1,readOnly:D=!1,error:K=!1,helperText:Y,hideLabel:Z=!1,icon:d,iconPosition:g="left",className:_,value:L,defaultValue:ee,onChange:te,format:f="number",currency:T="USD",locale:ne,decimals:u,min:N,max:w,step:V=1,prefix:s,suffix:c,thousandSeparator:k=!0,allowNegative:x=!0,onBlur:A,onFocus:U,id:re,...le},oe)=>{let E=z(Q),S=z(X),ae=ve(),H=re||ae,m=Ne(ne)??"en-US",a=I(()=>Se(m),[m]),$=I(()=>$e(m),[m]),ue=I(()=>new RegExp(`^-?\\d*(?:${Me(a)}\\d*)?$`),[a]),R=L!==void 0,[se,ie]=W(ee??null),p=R?L:se,M=t=>{R||ie(t),te?.(t)},[b,y]=W(null),B=I(()=>{let t=f==="currency"?{style:"currency",currency:T,minimumFractionDigits:u??2,maximumFractionDigits:u??2}:f==="percentage"?{minimumFractionDigits:u??0,maximumFractionDigits:u??2}:{minimumFractionDigits:u??0,maximumFractionDigits:u??(f==="decimal"?2:0),useGrouping:k};try{return new Intl.NumberFormat(m,t)}catch{return null}},[f,T,m,u,k]),P=u,ce=t=>{if(t==null)return"";if(!B)return String(t);let e=B.format(t);return f==="percentage"?(e=s?`${s}${e}`:e,e=c||!e.includes("%")?`${e}%`:e,e):(s&&(e=`${s}${e}`),c&&(e=`${e}${c}`),e)},h=t=>{if(!t||t.trim()==="")return null;let e=t;if(s&&(e=e.replace(s,"")),c&&(e=e.replace(c,"")),e=Array.from(e).filter(i=>/[\d-]/.test(i)||i===a).join("").replace(a,"."),!e||e==="-"||e===".")return null;let r=parseFloat(e);return isNaN(r)?null:(!x&&r<0&&(r=Math.abs(r)),P!==void 0&&(r=Number(r.toFixed(P))),N!==void 0&&r<N?N:w!==void 0&&r>w?w:r)},me=t=>{let e=t;return s&&(e=e.replace(s,"")),c&&(e=e.replace(c,"")),e=e.replace(/[\u2212\u2012\u2013]/g,"-").replace(/[\s%\p{Sc}]/gu,""),$&&$!==a?e.split($).join(""):e},G=b??ce(p??null),O=t=>ue.test(t),pe=t=>{let e=t.target.value;e!==""&&!O(e)&&(e=me(e),!O(e))||(y(e),M(h(e)))},de=t=>{let e=h(b??"")??p??0,r=Math.min(Math.max(q(V),q(e)),20),i=h(F(Number((e+t*V).toFixed(r)),a));y(i===null?"":F(i,a)),M(i)},ge=t=>{let e=["Backspace","Delete","Tab","Escape","Enter","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"];if((t.key==="ArrowUp"||t.key==="ArrowDown")&&!v&&!D&&!t.altKey&&!t.ctrlKey&&!t.metaKey){t.preventDefault(),de(t.key==="ArrowUp"?1:-1);return}let r=/^[0-9]$/.test(t.key),i=t.key===a,Ie=t.key==="-"&&x&&G.indexOf("-")===-1,Ce=t.ctrlKey||t.metaKey;!r&&!i&&!Ie&&!e.includes(t.key)&&!Ce&&t.preventDefault()},fe=t=>{y(p!=null?F(p,a):""),U&&U(t)},be=t=>{if(b!==null){let e=h(b);e!==p&&M(e)}y(null),A&&A(t)},ye=De(we({size:l,error:K,disabled:v,readOnly:D,icon:d,iconPosition:g}),E&&`border-[${E}]`,S&&`text-[${S}]`,_),he=Le("div",{className:"relative",children:[d&&g==="left"&&C("div",{className:j(g),children:d}),C("input",{ref:oe,id:H,type:"text",inputMode:"decimal",className:ye,style:{borderColor:E,color:S},disabled:v,readOnly:D,value:G,onChange:pe,onKeyDown:ge,onFocus:fe,onBlur:be,...le}),d&&g==="right"&&C("div",{className:j(g),children:d})]});return C(Ee,{label:n,hideLabel:Z,labelColor:J,error:K,helperText:Y,inline:o,htmlFor:H,children:he})});Ke.displayName="NumberInput";export{Ke as NumberInput};
@@ -1 +1 @@
1
- "use strict";var m=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var b=(r,e)=>{for(var l in e)m(r,l,{get:e[l],enumerable:!0})},x=(r,e,l,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of d(e))!g.call(r,a)&&a!==l&&m(r,a,{get:()=>e[a],enumerable:!(s=i(e,a))||s.enumerable});return r};var N=r=>x(m({},"__esModule",{value:!0}),r);var h={};b(h,{InputWrapper:()=>u});module.exports=N(h);var n=require("../../../lib/cn.cjs"),p=require("./inputStyles.cjs"),o=require("react/jsx-runtime"),u=({label:r,hideLabel:e,labelColor:l,error:s,helperText:a,inline:t,children:c,htmlFor:f})=>(0,o.jsxs)("div",{className:t?"flex items-center gap-4":"flex flex-col",children:[r&&!e&&(0,o.jsx)("label",{htmlFor:f,className:(0,p.getLabelClasses)(t||!1,l),style:l?{color:l}:void 0,children:r}),(0,o.jsx)("div",{className:t?"flex-1":"w-full",children:c}),a&&(0,o.jsx)("p",{className:(0,n.cn)((0,p.getHelperTextClasses)(s),t&&"ml-34"),children:a})]});0&&(module.exports={InputWrapper});
1
+ "use strict";var p=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var v=(e,l)=>{for(var s in l)p(e,s,{get:l[s],enumerable:!0})},C=(e,l,s,n)=>{if(l&&typeof l=="object"||typeof l=="function")for(let a of g(l))!u.call(e,a)&&a!==s&&p(e,a,{get:()=>l[a],enumerable:!(n=N(l,a))||n.enumerable});return e};var w=e=>C(p({},"__esModule",{value:!0}),e);var L={};v(L,{InputWrapper:()=>x});module.exports=w(L);var d=require("../../../lib/cn.cjs"),f=require("../../../lib/css-value.cjs"),t=require("./inputStyles.cjs"),o=require("react/jsx-runtime"),x=({label:e,hideLabel:l,labelColor:s,error:n,helperText:a,inline:b,children:c,htmlFor:m})=>{let r=(0,f.safeCssColor)(s),i=!!e&&!l;return b?(0,o.jsxs)("div",{className:"grid grid-cols-[auto_minmax(0,1fr)] items-center gap-x-4",children:[i&&(0,o.jsx)("label",{htmlFor:m,className:(0,t.getLabelClasses)(!0,r),style:r?{color:r}:void 0,children:e}),(0,o.jsx)("div",{className:i?"min-w-0":"col-span-2 min-w-0",children:c}),a&&(0,o.jsx)("p",{className:(0,d.cn)((0,t.getHelperTextClasses)(n),i?"col-start-2":"col-span-2"),children:a})]}):(0,o.jsxs)("div",{className:"flex flex-col",children:[i&&(0,o.jsx)("label",{htmlFor:m,className:(0,t.getLabelClasses)(!1,r),style:r?{color:r}:void 0,children:e}),(0,o.jsx)("div",{className:"w-full",children:c}),a&&(0,o.jsx)("p",{className:(0,t.getHelperTextClasses)(n),children:a})]})};0&&(module.exports={InputWrapper});
@@ -1 +1 @@
1
- import{cn as n}from"../../../lib/cn.js";import{getLabelClasses as c,getHelperTextClasses as f}from"./inputStyles.js";import{jsx as l,jsxs as i}from"react/jsx-runtime";var b=({label:a,hideLabel:s,labelColor:r,error:t,helperText:o,inline:e,children:p,htmlFor:m})=>i("div",{className:e?"flex items-center gap-4":"flex flex-col",children:[a&&!s&&l("label",{htmlFor:m,className:c(e||!1,r),style:r?{color:r}:void 0,children:a}),l("div",{className:e?"flex-1":"w-full",children:p}),o&&l("p",{className:n(f(t),e&&"ml-34"),children:o})]});export{b as InputWrapper};
1
+ import{cn as b}from"../../../lib/cn.js";import{safeCssColor as N}from"../../../lib/css-value.js";import{getLabelClasses as i,getHelperTextClasses as p}from"./inputStyles.js";import{jsx as l,jsxs as c}from"react/jsx-runtime";var C=({label:s,hideLabel:m,labelColor:d,error:r,helperText:a,inline:f,children:t,htmlFor:n})=>{let e=N(d),o=!!s&&!m;return f?c("div",{className:"grid grid-cols-[auto_minmax(0,1fr)] items-center gap-x-4",children:[o&&l("label",{htmlFor:n,className:i(!0,e),style:e?{color:e}:void 0,children:s}),l("div",{className:o?"min-w-0":"col-span-2 min-w-0",children:t}),a&&l("p",{className:b(p(r),o?"col-start-2":"col-span-2"),children:a})]}):c("div",{className:"flex flex-col",children:[o&&l("label",{htmlFor:n,className:i(!1,e),style:e?{color:e}:void 0,children:s}),l("div",{className:"w-full",children:t}),a&&l("p",{className:p(r),children:a})]})};export{C as InputWrapper};
@@ -1 +1 @@
1
- "use strict";"use client";var Z=Object.defineProperty;var ce=Object.getOwnPropertyDescriptor;var de=Object.getOwnPropertyNames;var fe=Object.prototype.hasOwnProperty;var he=(o,n)=>{for(var t in n)Z(o,t,{get:n[t],enumerable:!0})},pe=(o,n,t,d)=>{if(n&&typeof n=="object"||typeof n=="function")for(let f of de(n))!fe.call(o,f)&&f!==t&&Z(o,f,{get:()=>n[f],enumerable:!(d=ce(n,f))||d.enumerable});return o};var be=o=>pe(Z({},"__esModule",{value:!0}),o);var Te={};he(Te,{FunnelChart:()=>Se});module.exports=be(Te);var u=require("react"),K=require("../../lib/i18n.cjs"),te=require("../chart/ChartAxis.cjs"),ne=require("../chart/ChartContainer.cjs"),ae=require("../chart/ChartTooltip.cjs"),F=require("../chart/palette.cjs"),D=require("../chart/utils/data.cjs"),x=require("../chart/utils/format.cjs"),re=require("../chart/utils/keyboard.cjs"),le=require("../chart/utils/path.cjs"),A=require("../chart/utils/scales.cjs"),$=require("../chart/utils/text.cjs"),oe=require("../chart/utils/touch.cjs"),ie=require("../table/Table.cjs"),se=require("../table/TableBody.cjs"),X=require("../table/TableCell.cjs"),ue=require("../table/TableHeader.cjs"),W=require("../table/TableHeaderCell.cjs"),me=require("../table/TableRow.cjs"),e=require("react/jsx-runtime"),ge=8,ve=12,ye=44,ee="text-right [font-variant-numeric:tabular-nums]",xe=(0,u.memo)(function({stages:n}){return(0,e.jsx)("g",{children:n.map(t=>(0,e.jsxs)("g",{children:[(0,e.jsx)("path",{d:t.d,fill:t.color}),t.value?(0,e.jsx)("text",{x:t.value.x,y:t.value.y,textAnchor:t.value.anchor,dominantBaseline:"middle",className:t.value.inside?t.value.onDark?"fill-gray-50 text-[11px] font-semibold [font-variant-numeric:tabular-nums] dark:fill-gray-900":"fill-gray-900 text-[11px] font-semibold [font-variant-numeric:tabular-nums] dark:fill-gray-50":"fill-gray-700 text-[11px] font-semibold [font-variant-numeric:tabular-nums] dark:fill-gray-200",children:t.value.text}):null,t.conversion?(0,e.jsx)("text",{x:t.conversion.x,y:t.conversion.y,textAnchor:"middle",dominantBaseline:"middle",className:"fill-gray-500 text-[10px] [font-variant-numeric:tabular-nums] dark:fill-gray-400",children:t.conversion.text}):null]},t.key))})});function Ce({width:o,height:n,stages:t,x:d,size:f,align:E,showConversion:H,showValues:w,stageSize:G,ramp:O,tooltip:C,plotLabel:q,locale:k,onStageClick:b}){let[_,L]=(0,u.useState)(null),s=_!==null&&_<t.length?_:null,Y=(0,K.useUILabels)(),a=(0,u.useMemo)(()=>{let p=t.map(i=>i.label),g={top:6,right:12,bottom:6,left:d.hidden?8:d.height??(0,$.widestLabel)(p)+ve},S=Math.max(0,o-g.left-g.right),M=Math.max(0,n-g.top-g.bottom),m=(0,A.createBandScale)(t.map((i,l)=>l),[0,M],{paddingInner:H?.45:.28}),N=Math.min(G??ye,m.bandwidth),Q=Math.max(0,...t.map(i=>i.value??0)),T=(0,A.createLinearScale)([0,Q],[0,S]),z=t.map((i,l)=>{let R=i.value===null?0:Math.max(0,T(i.value)),V=E==="center"?(S-R)/2:0,r=m(l)+(m.bandwidth-N)/2,P=r+N/2,v=null;if(w&&i.value!==null){let y=i.formattedValue;v=(0,$.estimateTextWidth)(y,11)+16<=R?{x:V+R/2,y:P,anchor:"middle",text:y,inside:!0,onDark:O.onDark(l)}:{x:V+R+ge,y:P,anchor:"start",text:y,inside:!1,onDark:!1}}let U=m(l-1)+(m.bandwidth-N)/2+N,c=H&&i.conversion!==null&&l>0?{x:S/2,y:(U+r)/2,text:(0,x.formatPercent)(i.conversion,{locale:k,maximumFractionDigits:0})}:null;return{key:`${l}`,d:(0,le.buildBarPath)({x:V,y:r,width:R,height:N,radius:4,round:E==="center"?"none":"right"}),color:O(l),value:v,conversion:c,top:m(l),height:m.bandwidth}}),B=d.hidden?[]:t.map((i,l)=>({value:i.x,offset:m.center(l),label:i.label}));return{margin:g,innerWidth:S,innerHeight:M,rendered:z,stageTicks:B,centers:t.map((i,l)=>m.center(l))}},[t,d,o,n,E,H,w,G,O,k]),j=(0,u.useCallback)(p=>{if(C===!1||t.length===0)return;let g=p.currentTarget.getBoundingClientRect(),S=p.clientY-g.top-a.margin.top;L((0,A.nearestIndex)(a.centers,S))},[C,t.length,a.margin.top,a.centers]),I=(0,u.useCallback)(()=>{!b||s===null||b(t[s])},[b,s,t]),J=(0,u.useCallback)(p=>(0,re.handleChartKeyDown)(p,{count:t.length,current:s,axis:"y",onMove:L,pick:b?I:null}),[t.length,s,b,I]),h=s===null?null:t[s];return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("svg",{width:o,height:n,role:"img","aria-label":q??t.map(p=>p.label).join(", "),tabIndex:0,className:`${oe.CHART_TOUCH} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:j,onPointerLeave:()=>L(null),onKeyDown:J,onBlur:()=>L(null),onClick:I,children:[(0,e.jsxs)("g",{transform:`translate(${a.margin.left}, ${a.margin.top})`,children:[s!==null&&a.rendered[s]?(0,e.jsx)("rect",{x:-4,y:a.rendered[s].top,width:a.innerWidth+8,height:a.rendered[s].height,rx:4,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,(0,e.jsx)(xe,{stages:a.rendered})]}),(0,e.jsx)("g",{transform:`translate(${a.margin.left}, ${a.margin.top})`,children:d.hidden?null:(0,e.jsx)(te.ChartAxis,{orientation:"left",ticks:a.stageTicks,length:a.innerHeight,showLine:!1,tickSize:0,size:f})})]}),h&&s!==null&&C!==!1?(0,e.jsx)(ae.ChartTooltip,{x:a.margin.left+a.innerWidth/2,y:a.margin.top+a.centers[s],containerWidth:o,children:typeof C=="function"?C(h):(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:h.label}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"h-2.5 w-2.5 shrink-0 rounded-sm",style:{backgroundColor:a.rendered[s]?.color},"aria-hidden":"true"}),(0,e.jsx)("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:h.formattedValue})]}),h.conversion!==null?(0,e.jsxs)("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[(0,e.jsx)("span",{children:Y.chartConversion}),(0,e.jsx)("span",{className:"[font-variant-numeric:tabular-nums]",children:(0,x.formatPercent)(h.conversion,{locale:k,maximumFractionDigits:1})})]}):null,h.overall!==null?(0,e.jsxs)("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[(0,e.jsx)("span",{children:t[0]?.label}),(0,e.jsx)("span",{className:"[font-variant-numeric:tabular-nums]",children:(0,x.formatPercent)(h.overall,{locale:k,maximumFractionDigits:1})})]}):null]})}):null]})}function Se({data:o,x:n,value:t,align:d="center",showConversion:f=!0,showValues:E=!0,stageSize:H,colors:w,height:G,width:O,size:C="md",tooltip:q=!0,tableView:k=!1,title:b,description:_,loading:L=!1,emptyState:s,error:Y=!1,errorState:a,onRetry:j,actions:I,locale:J,plotLabel:h,valueLabel:p,conversionLabel:g,dropOffLabel:S,format:M,onStageClick:m,className:N,...Q}){let T=(0,K.useUILocale)(J),z=(0,K.useUILabels)(),B=(0,u.useMemo)(()=>M??(r=>(0,x.formatAuto)(r,T)),[M,T]),i=(0,u.useMemo)(()=>n.format??(r=>(0,x.formatXValue)(r,T)),[n.format,T]),l=(0,u.useMemo)(()=>{let r=(0,D.readNumber)(o[0]??{},t);return o.map((P,v)=>{let U=(0,D.readXValue)(P,n.key,v),c=(0,D.readNumber)(P,t),y=v===0?null:(0,D.readNumber)(o[v-1],t);return{index:v,x:U,label:i(U,v),value:c,overall:v===0||r===null||r===0||c===null?null:c/r,conversion:y===null||y===0||c===null?null:c/y,dropOff:y===null||c===null?null:y-c,formattedValue:c===null?"\u2014":B(c),datum:P}})},[o,n.key,t,B,i]),R=(0,u.useMemo)(()=>(0,F.createSequentialScale)([0,Math.max(1,l.length-1)],{colors:w??F.CHART_ORDINAL_COLORS,...w?{}:{darkStops:F.CHART_ORDINAL_DARK_STOPS}}),[l.length,w]),V=G??Math.max(96,l.length*(f?56:44)+12);return(0,e.jsx)(ne.ChartContainer,{title:b,description:_,height:V,width:O,size:C,loading:L,empty:l.length===0,emptyState:s,error:Y,errorState:a,onRetry:j,actions:I,tableView:k,table:k?(0,e.jsx)("div",{className:"w-full overflow-x-auto",children:(0,e.jsxs)(ie.Table,{children:[typeof b=="string"?(0,e.jsx)("caption",{className:"sr-only",children:b}):null,(0,e.jsxs)(ue.TableHeader,{children:[(0,e.jsx)(W.TableHeaderCell,{children:n.label??n.key}),(0,e.jsx)(W.TableHeaderCell,{className:"text-right",children:p??z.chartValue}),(0,e.jsx)(W.TableHeaderCell,{className:"text-right",children:g??z.chartConversion}),(0,e.jsx)(W.TableHeaderCell,{className:"text-right",children:S??z.chartDropOff})]}),(0,e.jsx)(se.TableBody,{children:l.map(r=>(0,e.jsxs)(me.TableRow,{clickable:!1,children:[(0,e.jsx)(X.TableCell,{className:"font-medium text-gray-900 dark:text-gray-100",children:r.label}),(0,e.jsx)(X.TableCell,{className:ee,children:r.formattedValue}),(0,e.jsx)(X.TableCell,{className:ee,children:r.conversion===null?"\u2014":(0,x.formatPercent)(r.conversion,{locale:T,maximumFractionDigits:1})}),(0,e.jsx)(X.TableCell,{className:ee,children:r.dropOff===null?"\u2014":B(r.dropOff)})]},r.index))})]})}):void 0,className:N,...Q,children:({width:r})=>(0,e.jsx)(Ce,{width:r,height:V,stages:l,x:n,size:C,align:d,showConversion:f,showValues:E,stageSize:H,ramp:R,tooltip:q,plotLabel:h,locale:T,onStageClick:m})})}0&&(module.exports={FunnelChart});
1
+ "use strict";"use client";var ee=Object.defineProperty;var de=Object.getOwnPropertyDescriptor;var he=Object.getOwnPropertyNames;var fe=Object.prototype.hasOwnProperty;var pe=(o,n)=>{for(var t in n)ee(o,t,{get:n[t],enumerable:!0})},be=(o,n,t,f)=>{if(n&&typeof n=="object"||typeof n=="function")for(let p of he(n))!fe.call(o,p)&&p!==t&&ee(o,p,{get:()=>n[p],enumerable:!(f=de(n,p))||f.enumerable});return o};var ge=o=>be(ee({},"__esModule",{value:!0}),o);var Te={};pe(Te,{FunnelChart:()=>Se});module.exports=ge(Te);var u=require("react"),G=require("../../lib/i18n.cjs"),ne=require("../chart/ChartAxis.cjs"),ae=require("../chart/ChartContainer.cjs"),re=require("../chart/ChartTooltip.cjs"),L=require("../chart/palette.cjs"),F=require("../chart/utils/data.cjs"),x=require("../chart/utils/format.cjs"),le=require("../chart/utils/keyboard.cjs"),oe=require("../chart/utils/path.cjs"),A=require("../chart/utils/scales.cjs"),Y=require("../chart/utils/text.cjs"),ie=require("../chart/utils/touch.cjs"),se=require("../table/Table.cjs"),ue=require("../table/TableBody.cjs"),K=require("../table/TableCell.cjs"),me=require("../table/TableHeader.cjs"),W=require("../table/TableHeaderCell.cjs"),ce=require("../table/TableRow.cjs"),e=require("react/jsx-runtime"),ve=8,ye=12,xe=44,te="text-right [font-variant-numeric:tabular-nums]",Ce=(0,u.memo)(function({stages:n}){return(0,e.jsx)("g",{children:n.map(t=>(0,e.jsxs)("g",{children:[(0,e.jsx)("path",{d:t.d,fill:t.color}),t.value?(0,e.jsx)("text",{x:t.value.x,y:t.value.y,textAnchor:t.value.anchor,dominantBaseline:"middle",className:t.value.inside?t.value.onDark?"fill-gray-50 text-[11px] font-semibold [font-variant-numeric:tabular-nums] dark:fill-gray-900":"fill-gray-900 text-[11px] font-semibold [font-variant-numeric:tabular-nums] dark:fill-gray-50":"fill-gray-700 text-[11px] font-semibold [font-variant-numeric:tabular-nums] dark:fill-gray-200",children:t.value.text}):null,t.conversion?(0,e.jsx)("text",{x:t.conversion.x,y:t.conversion.y,textAnchor:"middle",dominantBaseline:"middle",className:"fill-gray-500 text-[10px] [font-variant-numeric:tabular-nums] dark:fill-gray-400",children:t.conversion.text}):null]},t.key))})});function ke({width:o,height:n,stages:t,x:f,size:p,align:E,showConversion:H,showValues:_,stageSize:U,ramp:O,tooltip:C,plotLabel:j,locale:T,onStageClick:v}){let[I,w]=(0,u.useState)(null),s=I!==null&&I<t.length?I:null,J=(0,G.useUILabels)(),r=(0,u.useMemo)(()=>{let c=t.map(i=>i.label),d={top:6,right:12,bottom:6,left:f.hidden?8:f.height??(0,Y.widestLabel)(c)+ye},g=Math.max(0,o-d.left-d.right),X=Math.max(0,n-d.top-d.bottom),h=(0,A.createBandScale)(t.map((i,l)=>l),[0,X],{paddingInner:H?.45:.28}),N=Math.min(U??xe,h.bandwidth),$=Math.max(0,...t.map(i=>i.value??0)),k=(0,A.createLinearScale)([0,$>0?$:1],[0,g]),y=t.map((i,l)=>{let R=i.value===null?0:Math.max(0,k(i.value)),V=E==="center"?(g-R)/2:0,B=h(l)+(h.bandwidth-N)/2,a=B+N/2,D=null;if(_&&i.value!==null){let m=i.formattedValue;D=(0,Y.estimateTextWidth)(m,11)+16<=R?{x:V+R/2,y:a,anchor:"middle",text:m,inside:!0,onDark:O.onDark(l)}:{x:V+R+ve,y:a,anchor:"start",text:m,inside:!1,onDark:!1}}let S=h(l-1)+(h.bandwidth-N)/2+N,q=H&&i.conversion!==null&&l>0?{x:g/2,y:(S+B)/2,text:(0,x.formatPercent)(i.conversion,{locale:T,maximumFractionDigits:0})}:null;return{key:`${l}`,d:(0,oe.buildBarPath)({x:V,y:B,width:R,height:N,radius:4,round:E==="center"?"none":"right"}),color:O(l),value:D,conversion:q,top:h(l),height:h.bandwidth}}),z=f.hidden?[]:t.map((i,l)=>({value:i.x,offset:h.center(l),label:i.label}));return{margin:d,innerWidth:g,innerHeight:X,rendered:y,stageTicks:z,centers:t.map((i,l)=>h.center(l))}},[t,f,o,n,E,H,_,U,O,T]),Q=(0,u.useCallback)(c=>{if(C===!1||t.length===0)return;let d=c.currentTarget.getBoundingClientRect(),g=c.clientY-d.top-r.margin.top;w((0,A.nearestIndex)(r.centers,g))},[C,t.length,r.margin.top,r.centers]),M=(0,u.useCallback)(()=>{!v||s===null||v(t[s])},[v,s,t]),Z=(0,u.useCallback)(c=>(0,le.handleChartKeyDown)(c,{count:t.length,current:s,axis:"y",onMove:w,pick:v?M:null}),[t.length,s,v,M]),b=s===null?null:t[s];return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("svg",{width:o,height:n,role:"img","aria-label":j??t.map(c=>c.label).join(", "),tabIndex:0,className:`${ie.CHART_TOUCH} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:Q,onPointerLeave:()=>w(null),onKeyDown:Z,onBlur:()=>w(null),onClick:M,children:[(0,e.jsxs)("g",{transform:`translate(${r.margin.left}, ${r.margin.top})`,children:[s!==null&&r.rendered[s]?(0,e.jsx)("rect",{x:-4,y:r.rendered[s].top,width:r.innerWidth+8,height:r.rendered[s].height,rx:4,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,(0,e.jsx)(Ce,{stages:r.rendered})]}),(0,e.jsx)("g",{transform:`translate(${r.margin.left}, ${r.margin.top})`,children:f.hidden?null:(0,e.jsx)(ne.ChartAxis,{orientation:"left",ticks:r.stageTicks,length:r.innerHeight,showLine:!1,tickSize:0,size:p})})]}),b&&s!==null&&C!==!1?(0,e.jsx)(re.ChartTooltip,{x:r.margin.left+r.innerWidth/2,y:r.margin.top+r.centers[s],containerWidth:o,children:typeof C=="function"?C(b):(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:b.label}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"h-2.5 w-2.5 shrink-0 rounded-sm",style:{backgroundColor:r.rendered[s]?.color},"aria-hidden":"true"}),(0,e.jsx)("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:b.formattedValue})]}),b.conversion!==null?(0,e.jsxs)("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[(0,e.jsx)("span",{children:J.chartConversion}),(0,e.jsx)("span",{className:"[font-variant-numeric:tabular-nums]",children:(0,x.formatPercent)(b.conversion,{locale:T,maximumFractionDigits:1})})]}):null,b.overall!==null?(0,e.jsxs)("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[(0,e.jsx)("span",{children:t[0]?.label}),(0,e.jsx)("span",{className:"[font-variant-numeric:tabular-nums]",children:(0,x.formatPercent)(b.overall,{locale:T,maximumFractionDigits:1})})]}):null]})}):null]})}function Se({data:o,x:n,value:t,align:f="center",showConversion:p=!0,showValues:E=!0,stageSize:H,colors:_,height:U,width:O,size:C="md",tooltip:j=!0,tableView:T=!1,title:v,description:I,loading:w=!1,emptyState:s,error:J=!1,errorState:r,onRetry:Q,actions:M,locale:Z,plotLabel:b,valueLabel:c,conversionLabel:d,dropOffLabel:g,format:X,onStageClick:h,className:N,...$}){let k=(0,G.useUILocale)(Z),y=(0,G.useUILabels)(),z=(0,u.useMemo)(()=>X??(a=>(0,x.formatAuto)(a,k)),[X,k]),i=(0,u.useMemo)(()=>n.format??(a=>(0,x.formatXValue)(a,k)),[n.format,k]),l=(0,u.useMemo)(()=>{let a=(0,F.readNumber)(o[0]??{},t);return o.map((D,S)=>{let q=(0,F.readXValue)(D,n.key,S),m=(0,F.readNumber)(D,t),P=S===0?null:(0,F.readNumber)(o[S-1],t);return{index:S,x:q,label:i(q,S),value:m,overall:S===0||a===null||a===0||m===null?null:m/a,conversion:P===null||P===0||m===null?null:m/P,dropOff:P===null||m===null?null:P-m,formattedValue:m===null?"\u2014":z(m),datum:D}})},[o,n.key,t,z,i]),R=(0,u.useMemo)(()=>(0,L.createSequentialScale)([0,Math.max(1,l.length-1)],{colors:_??L.CHART_ORDINAL_COLORS,..._?{}:{darkStops:L.CHART_ORDINAL_DARK_STOPS}}),[l.length,_]),V=U??Math.max(96,l.length*(p?56:44)+12),B=(0,u.useMemo)(()=>({data:l.map(a=>({[n.key]:a.x,__value:a.value,__conversion:a.conversion,__dropOff:a.dropOff})),series:[{key:"__value",label:c??y.chartValue},{key:"__conversion",label:d??y.chartConversion},{key:"__dropOff",label:g??y.chartDropOff}],xKey:n.key,xLabel:n.label??n.key,formatX:n.format}),[l,n.key,n.label,n.format,c,d,g,y]);return(0,e.jsx)(ae.ChartContainer,{title:v,description:I,height:V,width:O,size:C,loading:w,empty:!l.some(a=>a.value!==null&&a.value>0),emptyState:s,error:J,errorState:r,onRetry:Q,actions:M,exportSource:B,tableView:T,table:T?(0,e.jsx)("div",{className:"w-full overflow-x-auto",children:(0,e.jsxs)(se.Table,{children:[typeof v=="string"?(0,e.jsx)("caption",{className:"sr-only",children:v}):null,(0,e.jsxs)(me.TableHeader,{children:[(0,e.jsx)(W.TableHeaderCell,{children:n.label??n.key}),(0,e.jsx)(W.TableHeaderCell,{className:"text-right",children:c??y.chartValue}),(0,e.jsx)(W.TableHeaderCell,{className:"text-right",children:d??y.chartConversion}),(0,e.jsx)(W.TableHeaderCell,{className:"text-right",children:g??y.chartDropOff})]}),(0,e.jsx)(ue.TableBody,{children:l.map(a=>(0,e.jsxs)(ce.TableRow,{clickable:!1,children:[(0,e.jsx)(K.TableCell,{className:"font-medium text-gray-900 dark:text-gray-100",children:a.label}),(0,e.jsx)(K.TableCell,{className:te,children:a.formattedValue}),(0,e.jsx)(K.TableCell,{className:te,children:a.conversion===null?"\u2014":(0,x.formatPercent)(a.conversion,{locale:k,maximumFractionDigits:1})}),(0,e.jsx)(K.TableCell,{className:te,children:a.dropOff===null?"\u2014":z(a.dropOff)})]},a.index))})]})}):void 0,className:N,...$,children:({width:a})=>(0,e.jsx)(ke,{width:a,height:V,stages:l,x:n,size:C,align:f,showConversion:p,showValues:E,stageSize:H,ramp:R,tooltip:j,plotLabel:b,locale:k,onStageClick:h})})}0&&(module.exports={FunnelChart});
@@ -1 +1 @@
1
- "use client";import{memo as Z,useCallback as Y,useMemo as _,useState as ee}from"react";import{useUILabels as Q,useUILocale as te}from"../../lib/i18n.js";import{ChartAxis as ne}from"../chart/ChartAxis.js";import{ChartContainer as ae}from"../chart/ChartContainer.js";import{ChartTooltip as re}from"../chart/ChartTooltip.js";import{CHART_ORDINAL_COLORS as le,CHART_ORDINAL_DARK_STOPS as oe,createSequentialScale as ie}from"../chart/palette.js";import{readNumber as j,readXValue as se}from"../chart/utils/data.js";import{formatAuto as ue,formatPercent as W,formatXValue as me}from"../chart/utils/format.js";import{handleChartKeyDown as ce}from"../chart/utils/keyboard.js";import{buildBarPath as de}from"../chart/utils/path.js";import{createBandScale as fe,createLinearScale as he,nearestIndex as pe}from"../chart/utils/scales.js";import{estimateTextWidth as be,widestLabel as ge}from"../chart/utils/text.js";import{CHART_TOUCH as ve}from"../chart/utils/touch.js";import{Table as ye}from"../table/Table.js";import{TableBody as xe}from"../table/TableBody.js";import{TableCell as B}from"../table/TableCell.js";import{TableHeader as Ce}from"../table/TableHeader.js";import{TableHeaderCell as X}from"../table/TableHeaderCell.js";import{TableRow as Se}from"../table/TableRow.js";import{Fragment as Le,jsx as t,jsxs as m}from"react/jsx-runtime";var Te=8,ke=12,Ne=44,J="text-right [font-variant-numeric:tabular-nums]",Re=Z(function({stages:i}){return t("g",{children:i.map(e=>m("g",{children:[t("path",{d:e.d,fill:e.color}),e.value?t("text",{x:e.value.x,y:e.value.y,textAnchor:e.value.anchor,dominantBaseline:"middle",className:e.value.inside?e.value.onDark?"fill-gray-50 text-[11px] font-semibold [font-variant-numeric:tabular-nums] dark:fill-gray-900":"fill-gray-900 text-[11px] font-semibold [font-variant-numeric:tabular-nums] dark:fill-gray-50":"fill-gray-700 text-[11px] font-semibold [font-variant-numeric:tabular-nums] dark:fill-gray-200",children:e.value.text}):null,e.conversion?t("text",{x:e.conversion.x,y:e.conversion.y,textAnchor:"middle",dominantBaseline:"middle",className:"fill-gray-500 text-[10px] [font-variant-numeric:tabular-nums] dark:fill-gray-400",children:e.conversion.text}):null]},e.key))})});function we({width:c,height:i,stages:e,x:C,size:I,align:V,showConversion:P,showValues:N,stageSize:M,ramp:D,tooltip:v,plotLabel:K,locale:S,onStageClick:h}){let[F,R]=ee(null),o=F!==null&&F<e.length?F:null,G=Q(),n=_(()=>{let f=e.map(l=>l.label),p={top:6,right:12,bottom:6,left:C.hidden?8:C.height??ge(f)+ke},y=Math.max(0,c-p.left-p.right),E=Math.max(0,i-p.top-p.bottom),s=fe(e.map((l,r)=>r),[0,E],{paddingInner:P?.45:.28}),T=Math.min(M??Ne,s.bandwidth),q=Math.max(0,...e.map(l=>l.value??0)),x=he([0,q],[0,y]),H=e.map((l,r)=>{let k=l.value===null?0:Math.max(0,x(l.value)),w=V==="center"?(y-k)/2:0,a=s(r)+(s.bandwidth-T)/2,L=a+T/2,b=null;if(N&&l.value!==null){let g=l.formattedValue;b=be(g,11)+16<=k?{x:w+k/2,y:L,anchor:"middle",text:g,inside:!0,onDark:D.onDark(r)}:{x:w+k+Te,y:L,anchor:"start",text:g,inside:!1,onDark:!1}}let z=s(r-1)+(s.bandwidth-T)/2+T,u=P&&l.conversion!==null&&r>0?{x:y/2,y:(z+a)/2,text:W(l.conversion,{locale:S,maximumFractionDigits:0})}:null;return{key:`${r}`,d:de({x:w,y:a,width:k,height:T,radius:4,round:V==="center"?"none":"right"}),color:D(r),value:b,conversion:u,top:s(r),height:s.bandwidth}}),O=C.hidden?[]:e.map((l,r)=>({value:l.x,offset:s.center(r),label:l.label}));return{margin:p,innerWidth:y,innerHeight:E,rendered:H,stageTicks:O,centers:e.map((l,r)=>s.center(r))}},[e,C,c,i,V,P,N,M,D,S]),U=Y(f=>{if(v===!1||e.length===0)return;let p=f.currentTarget.getBoundingClientRect(),y=f.clientY-p.top-n.margin.top;R(pe(n.centers,y))},[v,e.length,n.margin.top,n.centers]),A=Y(()=>{!h||o===null||h(e[o])},[h,o,e]),$=Y(f=>ce(f,{count:e.length,current:o,axis:"y",onMove:R,pick:h?A:null}),[e.length,o,h,A]),d=o===null?null:e[o];return m(Le,{children:[m("svg",{width:c,height:i,role:"img","aria-label":K??e.map(f=>f.label).join(", "),tabIndex:0,className:`${ve} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:U,onPointerLeave:()=>R(null),onKeyDown:$,onBlur:()=>R(null),onClick:A,children:[m("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:[o!==null&&n.rendered[o]?t("rect",{x:-4,y:n.rendered[o].top,width:n.innerWidth+8,height:n.rendered[o].height,rx:4,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,t(Re,{stages:n.rendered})]}),t("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:C.hidden?null:t(ne,{orientation:"left",ticks:n.stageTicks,length:n.innerHeight,showLine:!1,tickSize:0,size:I})})]}),d&&o!==null&&v!==!1?t(re,{x:n.margin.left+n.innerWidth/2,y:n.margin.top+n.centers[o],containerWidth:c,children:typeof v=="function"?v(d):m("div",{className:"flex flex-col gap-1",children:[t("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:d.label}),m("div",{className:"flex items-center gap-2",children:[t("span",{className:"h-2.5 w-2.5 shrink-0 rounded-sm",style:{backgroundColor:n.rendered[o]?.color},"aria-hidden":"true"}),t("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:d.formattedValue})]}),d.conversion!==null?m("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[t("span",{children:G.chartConversion}),t("span",{className:"[font-variant-numeric:tabular-nums]",children:W(d.conversion,{locale:S,maximumFractionDigits:1})})]}):null,d.overall!==null?m("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[t("span",{children:e[0]?.label}),t("span",{className:"[font-variant-numeric:tabular-nums]",children:W(d.overall,{locale:S,maximumFractionDigits:1})})]}):null]})}):null]})}function je({data:c,x:i,value:e,align:C="center",showConversion:I=!0,showValues:V=!0,stageSize:P,colors:N,height:M,width:D,size:v="md",tooltip:K=!0,tableView:S=!1,title:h,description:F,loading:R=!1,emptyState:o,error:G=!1,errorState:n,onRetry:U,actions:A,locale:$,plotLabel:d,valueLabel:f,conversionLabel:p,dropOffLabel:y,format:E,onStageClick:s,className:T,...q}){let x=te($),H=Q(),O=_(()=>E??(a=>ue(a,x)),[E,x]),l=_(()=>i.format??(a=>me(a,x)),[i.format,x]),r=_(()=>{let a=j(c[0]??{},e);return c.map((L,b)=>{let z=se(L,i.key,b),u=j(L,e),g=b===0?null:j(c[b-1],e);return{index:b,x:z,label:l(z,b),value:u,overall:b===0||a===null||a===0||u===null?null:u/a,conversion:g===null||g===0||u===null?null:u/g,dropOff:g===null||u===null?null:g-u,formattedValue:u===null?"\u2014":O(u),datum:L}})},[c,i.key,e,O,l]),k=_(()=>ie([0,Math.max(1,r.length-1)],{colors:N??le,...N?{}:{darkStops:oe}}),[r.length,N]),w=M??Math.max(96,r.length*(I?56:44)+12);return t(ae,{title:h,description:F,height:w,width:D,size:v,loading:R,empty:r.length===0,emptyState:o,error:G,errorState:n,onRetry:U,actions:A,tableView:S,table:S?t("div",{className:"w-full overflow-x-auto",children:m(ye,{children:[typeof h=="string"?t("caption",{className:"sr-only",children:h}):null,m(Ce,{children:[t(X,{children:i.label??i.key}),t(X,{className:"text-right",children:f??H.chartValue}),t(X,{className:"text-right",children:p??H.chartConversion}),t(X,{className:"text-right",children:y??H.chartDropOff})]}),t(xe,{children:r.map(a=>m(Se,{clickable:!1,children:[t(B,{className:"font-medium text-gray-900 dark:text-gray-100",children:a.label}),t(B,{className:J,children:a.formattedValue}),t(B,{className:J,children:a.conversion===null?"\u2014":W(a.conversion,{locale:x,maximumFractionDigits:1})}),t(B,{className:J,children:a.dropOff===null?"\u2014":O(a.dropOff)})]},a.index))})]})}):void 0,className:T,...q,children:({width:a})=>t(we,{width:a,height:w,stages:r,x:i,size:v,align:C,showConversion:I,showValues:V,stageSize:P,ramp:k,tooltip:K,plotLabel:d,locale:x,onStageClick:s})})}export{je as FunnelChart};
1
+ "use client";import{memo as ee,useCallback as j,useMemo as D,useState as te}from"react";import{useUILabels as Z,useUILocale as ne}from"../../lib/i18n.js";import{ChartAxis as ae}from"../chart/ChartAxis.js";import{ChartContainer as re}from"../chart/ChartContainer.js";import{ChartTooltip as le}from"../chart/ChartTooltip.js";import{CHART_ORDINAL_COLORS as oe,CHART_ORDINAL_DARK_STOPS as ie,createSequentialScale as se}from"../chart/palette.js";import{readNumber as J,readXValue as ue}from"../chart/utils/data.js";import{formatAuto as me,formatPercent as G,formatXValue as ce}from"../chart/utils/format.js";import{handleChartKeyDown as de}from"../chart/utils/keyboard.js";import{buildBarPath as he}from"../chart/utils/path.js";import{createBandScale as fe,createLinearScale as pe,nearestIndex as be}from"../chart/utils/scales.js";import{estimateTextWidth as ge,widestLabel as ve}from"../chart/utils/text.js";import{CHART_TOUCH as ye}from"../chart/utils/touch.js";import{Table as xe}from"../table/Table.js";import{TableBody as Ce}from"../table/TableBody.js";import{TableCell as K}from"../table/TableCell.js";import{TableHeader as ke}from"../table/TableHeader.js";import{TableHeaderCell as W}from"../table/TableHeaderCell.js";import{TableRow as Se}from"../table/TableRow.js";import{Fragment as Ve,jsx as t,jsxs as d}from"react/jsx-runtime";var Te=8,Ne=12,Re=44,Q="text-right [font-variant-numeric:tabular-nums]",_e=ee(function({stages:l}){return t("g",{children:l.map(e=>d("g",{children:[t("path",{d:e.d,fill:e.color}),e.value?t("text",{x:e.value.x,y:e.value.y,textAnchor:e.value.anchor,dominantBaseline:"middle",className:e.value.inside?e.value.onDark?"fill-gray-50 text-[11px] font-semibold [font-variant-numeric:tabular-nums] dark:fill-gray-900":"fill-gray-900 text-[11px] font-semibold [font-variant-numeric:tabular-nums] dark:fill-gray-50":"fill-gray-700 text-[11px] font-semibold [font-variant-numeric:tabular-nums] dark:fill-gray-200",children:e.value.text}):null,e.conversion?t("text",{x:e.conversion.x,y:e.conversion.y,textAnchor:"middle",dominantBaseline:"middle",className:"fill-gray-500 text-[10px] [font-variant-numeric:tabular-nums] dark:fill-gray-400",children:e.conversion.text}):null]},e.key))})});function we({width:h,height:l,stages:e,x:C,size:M,align:P,showConversion:F,showValues:N,stageSize:X,ramp:L,tooltip:v,plotLabel:U,locale:k,onStageClick:b}){let[A,R]=te(null),i=A!==null&&A<e.length?A:null,$=Z(),a=D(()=>{let u=e.map(o=>o.label),m={top:6,right:12,bottom:6,left:C.hidden?8:C.height??ve(u)+Ne},p=Math.max(0,h-m.left-m.right),H=Math.max(0,l-m.top-m.bottom),c=fe(e.map((o,r)=>r),[0,H],{paddingInner:F?.45:.28}),S=Math.min(X??Re,c.bandwidth),z=Math.max(0,...e.map(o=>o.value??0)),y=pe([0,z>0?z:1],[0,p]),g=e.map((o,r)=>{let T=o.value===null?0:Math.max(0,y(o.value)),_=P==="center"?(p-T)/2:0,I=c(r)+(c.bandwidth-S)/2,n=I+S/2,w=null;if(N&&o.value!==null){let s=o.formattedValue;w=ge(s,11)+16<=T?{x:_+T/2,y:n,anchor:"middle",text:s,inside:!0,onDark:L.onDark(r)}:{x:_+T+Te,y:n,anchor:"start",text:s,inside:!1,onDark:!1}}let x=c(r-1)+(c.bandwidth-S)/2+S,B=F&&o.conversion!==null&&r>0?{x:p/2,y:(x+I)/2,text:G(o.conversion,{locale:k,maximumFractionDigits:0})}:null;return{key:`${r}`,d:he({x:_,y:I,width:T,height:S,radius:4,round:P==="center"?"none":"right"}),color:L(r),value:w,conversion:B,top:c(r),height:c.bandwidth}}),O=C.hidden?[]:e.map((o,r)=>({value:o.x,offset:c.center(r),label:o.label}));return{margin:m,innerWidth:p,innerHeight:H,rendered:g,stageTicks:O,centers:e.map((o,r)=>c.center(r))}},[e,C,h,l,P,F,N,X,L,k]),q=j(u=>{if(v===!1||e.length===0)return;let m=u.currentTarget.getBoundingClientRect(),p=u.clientY-m.top-a.margin.top;R(be(a.centers,p))},[v,e.length,a.margin.top,a.centers]),E=j(()=>{!b||i===null||b(e[i])},[b,i,e]),Y=j(u=>de(u,{count:e.length,current:i,axis:"y",onMove:R,pick:b?E:null}),[e.length,i,b,E]),f=i===null?null:e[i];return d(Ve,{children:[d("svg",{width:h,height:l,role:"img","aria-label":U??e.map(u=>u.label).join(", "),tabIndex:0,className:`${ye} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:q,onPointerLeave:()=>R(null),onKeyDown:Y,onBlur:()=>R(null),onClick:E,children:[d("g",{transform:`translate(${a.margin.left}, ${a.margin.top})`,children:[i!==null&&a.rendered[i]?t("rect",{x:-4,y:a.rendered[i].top,width:a.innerWidth+8,height:a.rendered[i].height,rx:4,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,t(_e,{stages:a.rendered})]}),t("g",{transform:`translate(${a.margin.left}, ${a.margin.top})`,children:C.hidden?null:t(ae,{orientation:"left",ticks:a.stageTicks,length:a.innerHeight,showLine:!1,tickSize:0,size:M})})]}),f&&i!==null&&v!==!1?t(le,{x:a.margin.left+a.innerWidth/2,y:a.margin.top+a.centers[i],containerWidth:h,children:typeof v=="function"?v(f):d("div",{className:"flex flex-col gap-1",children:[t("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:f.label}),d("div",{className:"flex items-center gap-2",children:[t("span",{className:"h-2.5 w-2.5 shrink-0 rounded-sm",style:{backgroundColor:a.rendered[i]?.color},"aria-hidden":"true"}),t("span",{className:"font-semibold text-gray-900 [font-variant-numeric:tabular-nums] dark:text-gray-100",children:f.formattedValue})]}),f.conversion!==null?d("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[t("span",{children:$.chartConversion}),t("span",{className:"[font-variant-numeric:tabular-nums]",children:G(f.conversion,{locale:k,maximumFractionDigits:1})})]}):null,f.overall!==null?d("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[t("span",{children:e[0]?.label}),t("span",{className:"[font-variant-numeric:tabular-nums]",children:G(f.overall,{locale:k,maximumFractionDigits:1})})]}):null]})}):null]})}function je({data:h,x:l,value:e,align:C="center",showConversion:M=!0,showValues:P=!0,stageSize:F,colors:N,height:X,width:L,size:v="md",tooltip:U=!0,tableView:k=!1,title:b,description:A,loading:R=!1,emptyState:i,error:$=!1,errorState:a,onRetry:q,actions:E,locale:Y,plotLabel:f,valueLabel:u,conversionLabel:m,dropOffLabel:p,format:H,onStageClick:c,className:S,...z}){let y=ne(Y),g=Z(),O=D(()=>H??(n=>me(n,y)),[H,y]),o=D(()=>l.format??(n=>ce(n,y)),[l.format,y]),r=D(()=>{let n=J(h[0]??{},e);return h.map((w,x)=>{let B=ue(w,l.key,x),s=J(w,e),V=x===0?null:J(h[x-1],e);return{index:x,x:B,label:o(B,x),value:s,overall:x===0||n===null||n===0||s===null?null:s/n,conversion:V===null||V===0||s===null?null:s/V,dropOff:V===null||s===null?null:V-s,formattedValue:s===null?"\u2014":O(s),datum:w}})},[h,l.key,e,O,o]),T=D(()=>se([0,Math.max(1,r.length-1)],{colors:N??oe,...N?{}:{darkStops:ie}}),[r.length,N]),_=X??Math.max(96,r.length*(M?56:44)+12),I=D(()=>({data:r.map(n=>({[l.key]:n.x,__value:n.value,__conversion:n.conversion,__dropOff:n.dropOff})),series:[{key:"__value",label:u??g.chartValue},{key:"__conversion",label:m??g.chartConversion},{key:"__dropOff",label:p??g.chartDropOff}],xKey:l.key,xLabel:l.label??l.key,formatX:l.format}),[r,l.key,l.label,l.format,u,m,p,g]);return t(re,{title:b,description:A,height:_,width:L,size:v,loading:R,empty:!r.some(n=>n.value!==null&&n.value>0),emptyState:i,error:$,errorState:a,onRetry:q,actions:E,exportSource:I,tableView:k,table:k?t("div",{className:"w-full overflow-x-auto",children:d(xe,{children:[typeof b=="string"?t("caption",{className:"sr-only",children:b}):null,d(ke,{children:[t(W,{children:l.label??l.key}),t(W,{className:"text-right",children:u??g.chartValue}),t(W,{className:"text-right",children:m??g.chartConversion}),t(W,{className:"text-right",children:p??g.chartDropOff})]}),t(Ce,{children:r.map(n=>d(Se,{clickable:!1,children:[t(K,{className:"font-medium text-gray-900 dark:text-gray-100",children:n.label}),t(K,{className:Q,children:n.formattedValue}),t(K,{className:Q,children:n.conversion===null?"\u2014":G(n.conversion,{locale:y,maximumFractionDigits:1})}),t(K,{className:Q,children:n.dropOff===null?"\u2014":O(n.dropOff)})]},n.index))})]})}):void 0,className:S,...z,children:({width:n})=>t(we,{width:n,height:_,stages:r,x:l,size:v,align:C,showConversion:M,showValues:P,stageSize:F,ramp:T,tooltip:U,plotLabel:f,locale:y,onStageClick:c})})}export{je as FunnelChart};
@@ -1 +1 @@
1
- "use strict";"use client";var dt=Object.defineProperty;var Ht=Object.getOwnPropertyDescriptor;var Wt=Object.getOwnPropertyNames;var Xt=Object.prototype.hasOwnProperty;var Vt=(s,o)=>{for(var f in o)dt(s,f,{get:o[f],enumerable:!0})},zt=(s,o,f,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let u of Wt(o))!Xt.call(s,u)&&u!==f&&dt(s,u,{get:()=>o[u],enumerable:!(r=Ht(o,u))||r.enumerable});return s};var _t=s=>zt(dt({},"__esModule",{value:!0}),s);var Zt={};Vt(Zt,{GanttChart:()=>Ft});module.exports=_t(Zt);var i=require("react"),F=require("../../lib/i18n.cjs"),pt=require("../chart/ChartAxis.cjs"),Nt=require("../chart/ChartContainer.cjs"),wt=require("../chart/ChartGrid.cjs"),St=require("../chart/ChartLegend.cjs"),$t=require("../chart/ChartTooltip.cjs"),nt=require("../chart/palette.cjs"),Lt=require("../chart/utils/cartesian.cjs"),at=require("../chart/utils/data.cjs"),Z=require("../chart/utils/format.cjs"),Pt=require("../chart/utils/keyboard.cjs"),ft=require("../chart/utils/path.cjs"),Rt=require("../chart/utils/scales.cjs"),T=require("../chart/utils/time.cjs"),Gt=require("../chart/utils/touch.cjs"),Mt=require("../table/Table.cjs"),Dt=require("../table/TableBody.cjs"),U=require("../table/TableCell.cjs"),Ot=require("../table/TableHeader.cjs"),Y=require("../table/TableHeaderCell.cjs"),It=require("../table/TableRow.cjs"),t=require("react/jsx-runtime"),Bt=18,kt=.5,Kt=.3,rt=7,vt=10,xt=.02,ht="text-right [font-variant-numeric:tabular-nums]",Ut=(0,i.memo)(function({tasks:o,arrows:f}){return(0,t.jsxs)("g",{children:[(0,t.jsx)("g",{className:"fill-gray-400 stroke-gray-400 dark:fill-gray-500 dark:stroke-gray-500",children:f.map(r=>(0,t.jsxs)("g",{children:[(0,t.jsx)("path",{d:r.d,fill:"none",strokeWidth:1}),(0,t.jsx)("path",{d:r.head,strokeWidth:0})]},r.key))}),o.map(r=>(0,t.jsxs)("g",{children:[r.track?(0,t.jsx)("path",{d:r.track,fill:r.color,fillOpacity:r.trackOpacity}):null,r.progress?(0,t.jsx)("path",{d:r.progress,fill:r.color}):null,r.milestone?(0,t.jsx)("path",{d:r.milestone,fill:r.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"}):null]},r.key))]})});function Yt({width:s,height:o,data:f,tasks:r,x:u,domain:x,unit:M,timeTicks:A,today:L,grid:E,size:H,barSize:V,colorOf:j,margin:q,tooltip:P,plotLabel:ot,todayLabel:lt,locale:R,formatDate:J,formatX:D,onTaskClick:O}){let[W,G]=(0,i.useState)(null),h=W!==null&&W<r.length?W:null,z=(0,F.useUILabels)(),n=(0,i.useMemo)(()=>{let m=(0,Lt.buildCartesianGeometry)({width:s,height:o,data:f,x:u,y:{domain:x},bounds:x,margin:q,orientation:"horizontal",placement:"band",formatValue:a=>(0,T.formatTimeTick)(a,M,R),formatX:D}),{valueScale:k,bandwidth:b,categoryPositions:N,innerWidth:ct,innerHeight:mt}=m,I=Math.min(V??Bt,b),Q=new Map(r.map((a,c)=>[a.id,c])),ut=r.map((a,c)=>{let w=N[c]+(b-I)/2,l=w+I/2,p=j(a);if(a.start===null)return{key:`${c}`,color:p,track:null,trackOpacity:1,progress:null,milestone:null,top:N[c],height:b};let y=k(a.start);if(a.milestone)return{key:`${c}`,color:p,track:null,trackOpacity:1,progress:null,milestone:`M${y},${l-rt} L${y+rt},${l} L${y},${l+rt} L${y-rt},${l} Z`,top:N[c],height:b};let S=k(a.end??a.start),C=Math.max(2,S-y);return{key:`${c}`,color:p,track:(0,ft.buildBarPath)({x:y,y:w,width:C,height:I,radius:3}),trackOpacity:a.progress===null?1:Kt,progress:a.progress===null?null:(0,ft.buildBarPath)({x:y,y:l-I*kt/2,width:Math.max(0,C*Math.min(1,Math.max(0,a.progress))),height:I*kt,radius:2,round:"right"}),milestone:null,top:N[c],height:b}}),tt=[];r.forEach((a,c)=>{if(a.start!==null)for(let w of a.dependsOn){let l=Q.get(w);if(l===void 0||l===c)continue;let p=r[l];if(p.start===null)continue;let y=k(p.end??p.start),S=N[l]+b/2,C=k(a.start),$=N[c]+b/2,et=Math.max(y+vt,C-vt);tt.push({key:`${w}-${a.id}`,d:`M${y},${S} L${et},${S} L${et},${$} L${C-5},${$}`,head:`M${C},${$} L${C-5},${$-3.5} L${C-5},${$+3.5} Z`})}});let gt=A.map(a=>({value:a,offset:k(a),label:(0,T.formatTimeTick)(a,M,R)}));return{rendered:ut,arrows:tt,categoryPositions:N,categoryCenters:m.categoryCenters,bandwidth:b,categoryTicks:m.categoryTicks,valueTicks:gt,valueScale:k,innerWidth:ct,innerHeight:mt,margin:m.margin}},[r,f,u,x,M,A,s,o,q,V,j,R,D]),it=(0,i.useCallback)(m=>{if(P===!1||r.length===0)return;let k=m.currentTarget.getBoundingClientRect(),b=m.clientY-k.top-n.margin.top;G((0,Rt.nearestIndex)(n.categoryCenters,b))},[P,r.length,n.margin.top,n.categoryCenters]),_=(0,i.useCallback)(()=>{!O||h===null||O(r[h])},[O,h,r]),st=(0,i.useCallback)(m=>(0,Pt.handleChartKeyDown)(m,{count:r.length,current:h,axis:"y",onMove:G,pick:O?_:null}),[r.length,h,O,_]),g=h===null?null:r[h];return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("svg",{width:s,height:o,role:"img","aria-label":ot??r.map(m=>m.label).join(", "),tabIndex:0,className:`${Gt.CHART_TOUCH} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:it,onPointerLeave:()=>G(null),onKeyDown:st,onBlur:()=>G(null),onClick:_,children:[(0,t.jsxs)("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:[(0,t.jsx)(wt.ChartGrid,{width:n.innerWidth,height:n.innerHeight,vertical:E?n.valueTicks.map(m=>m.offset):void 0}),h!==null?(0,t.jsx)("rect",{x:0,y:n.categoryPositions[h],width:n.innerWidth,height:n.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,(0,t.jsx)(Ut,{tasks:n.rendered,arrows:n.arrows}),L!==null?(0,t.jsxs)("g",{children:[(0,t.jsx)("line",{x1:n.valueScale(L),y1:0,x2:n.valueScale(L),y2:n.innerHeight,className:"stroke-gray-900 dark:stroke-white",strokeWidth:1,strokeDasharray:"4 4"}),(0,t.jsx)("text",{x:n.valueScale(L)+4,y:8,className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:lt})]}):null]}),(0,t.jsx)("g",{transform:`translate(${n.margin.left}, ${n.margin.top+n.innerHeight})`,children:(0,t.jsx)(pt.ChartAxis,{orientation:"bottom",ticks:n.valueTicks,length:n.innerWidth,size:H})}),(0,t.jsx)("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:u.hidden?null:(0,t.jsx)(pt.ChartAxis,{orientation:"left",ticks:n.categoryTicks,length:n.innerHeight,showLine:!1,tickSize:0,label:u.label,size:H})})]}),g&&h!==null&&P!==!1?(0,t.jsx)($t.ChartTooltip,{x:n.margin.left+(g.start===null?n.innerWidth/2:n.valueScale(g.start)),y:n.margin.top+n.categoryCenters[h],containerWidth:s,children:typeof P=="function"?P(g):(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:g.label}),(0,t.jsxs)("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[(0,t.jsx)("span",{children:z.chartStart}),(0,t.jsx)("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:g.start===null?"\u2014":J(g.start)})]}),g.milestone?null:(0,t.jsxs)("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[(0,t.jsx)("span",{children:z.chartEnd}),(0,t.jsx)("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:g.end===null?"\u2014":J(g.end)})]}),g.progress===null?null:(0,t.jsxs)("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[(0,t.jsx)("span",{children:z.chartProgress}),(0,t.jsx)("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:(0,Z.formatPercent)(g.progress,{locale:R,maximumFractionDigits:0})})]})]})}):null]})}function Ft({data:s,x:o,start:f,end:r,id:u,progress:x,milestone:M,dependencies:A,group:L,domain:E,today:H,ticks:V=6,barSize:j,rowSize:q=30,color:P,height:ot,width:lt,size:R="md",grid:J=!0,legend:D,tooltip:O=!0,tableView:W=!1,title:G,description:h,loading:z=!1,emptyState:n,error:it=!1,errorState:_,onRetry:st,actions:g,margin:m,locale:k,plotLabel:b,startLabel:N,endLabel:ct,progressLabel:mt,todayLabel:I,formatDate:Q,onTaskClick:ut,className:tt,...gt}){let a=(0,F.useUILocale)(k),c=(0,F.useUILabels)(),w=(0,i.useMemo)(()=>o.format??(e=>(0,Z.formatXValue)(e,a)),[o.format,a]),l=(0,i.useMemo)(()=>s.map((e,d)=>{let B=(0,at.readXValue)(e,o.key,d),X=(0,T.toTimestamp)(e[f]),v=r?(0,T.toTimestamp)(e[r]):null,K=M?!!e[M]:v===null,Tt=A?e[A]:void 0;return{index:d,id:String(u?e[u]??d:d),x:B,label:w(B,d),start:X,end:K?X:v??X,progress:x?(0,at.readNumber)(e,x):null,milestone:K,dependsOn:Array.isArray(Tt)?Tt.map(Et=>String(Et)):[],group:L?e[L]??null:null,datum:e}}),[s,o.key,f,r,u,x,M,A,L,w]),p=(0,i.useMemo)(()=>{let e=[];for(let d of l)d.group!==null&&!e.includes(d.group)&&e.push(d.group);return e},[l]),y=(0,i.useCallback)(e=>e.group===null?P??(0,nt.getSeriesColor)(0):(0,nt.getSeriesColor)(p.indexOf(e.group)),[p,P]),S=(0,i.useMemo)(()=>{if(E){let v=(0,T.toTimestamp)(E[0]),K=(0,T.toTimestamp)(E[1]);if(v!==null&&K!==null)return[v,K]}let e=l.flatMap(v=>v.start===null?[]:[v.start,v.end??v.start]);if(e.length===0)return[0,1];let d=Math.min(...e),B=Math.max(...e),X=B-d||864e5;return[d-X*xt,B+X*xt]},[E,l]),C=(0,i.useMemo)(()=>(0,T.niceTimeTicks)(S[0],S[1],V),[S,V]),$=(0,i.useMemo)(()=>Q??(e=>new Intl.DateTimeFormat(a,{day:"numeric",month:"short",year:"numeric"}).format(new Date(e))),[Q,a]),et=(0,i.useMemo)(()=>H===!1?null:(0,T.toTimestamp)(H??Date.now()),[H]),bt=(0,i.useMemo)(()=>p.map((e,d)=>({key:e,label:e,color:(0,nt.getSeriesColor)(d),marker:"rect"})),[p]),yt=ot??Math.max(120,l.length*q+48),At=D===void 0?p.length>=2:D!==!1,Ct=typeof D=="string"?D:"bottom";return(0,t.jsx)(Nt.ChartContainer,{title:G,description:h,height:yt,width:lt,size:R,loading:z,empty:l.length===0,emptyState:n,error:it,errorState:_,onRetry:st,actions:g,tableView:W,legendPosition:Ct,legend:At&&bt.length>0?(0,t.jsx)(St.ChartLegend,{items:bt,position:Ct,marker:"rect",size:R}):void 0,table:W?(0,t.jsx)("div",{className:"w-full overflow-x-auto",children:(0,t.jsxs)(Mt.Table,{children:[typeof G=="string"?(0,t.jsx)("caption",{className:"sr-only",children:G}):null,(0,t.jsxs)(Ot.TableHeader,{children:[(0,t.jsx)(Y.TableHeaderCell,{children:o.label??o.key}),(0,t.jsx)(Y.TableHeaderCell,{className:"text-right",children:N??c.chartStart}),(0,t.jsx)(Y.TableHeaderCell,{className:"text-right",children:ct??c.chartEnd}),x?(0,t.jsx)(Y.TableHeaderCell,{className:"text-right",children:mt??c.chartProgress}):null]}),(0,t.jsx)(Dt.TableBody,{children:l.map(e=>(0,t.jsxs)(It.TableRow,{clickable:!1,children:[(0,t.jsx)(U.TableCell,{className:"font-medium text-gray-900 dark:text-gray-100",children:e.label}),(0,t.jsx)(U.TableCell,{className:ht,children:e.start===null?"\u2014":$(e.start)}),(0,t.jsx)(U.TableCell,{className:ht,children:e.milestone||e.end===null?"\u2014":$(e.end)}),x?(0,t.jsx)(U.TableCell,{className:ht,children:e.progress===null?"\u2014":(0,Z.formatPercent)(e.progress,{locale:a,maximumFractionDigits:0})}):null]},e.index))})]})}):void 0,className:tt,...gt,children:({width:e})=>(0,t.jsx)(Yt,{width:e,height:yt,data:s,tasks:l,x:o,domain:S,unit:C.unit,timeTicks:C.values,today:et,grid:J,size:R,barSize:j,colorOf:y,margin:m,tooltip:O,plotLabel:b,todayLabel:I??c.chartToday,locale:a,formatDate:$,formatX:w,onTaskClick:ut})})}0&&(module.exports={GanttChart});
1
+ "use strict";"use client";var ft=Object.defineProperty;var Xt=Object.getOwnPropertyDescriptor;var Vt=Object.getOwnPropertyNames;var _t=Object.prototype.hasOwnProperty;var zt=(c,o)=>{for(var p in o)ft(c,p,{get:o[p],enumerable:!0})},Bt=(c,o,p,l)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of Vt(o))!_t.call(c,n)&&n!==p&&ft(c,n,{get:()=>o[n],enumerable:!(l=Xt(o,n))||l.enumerable});return c};var Kt=c=>Bt(ft({},"__esModule",{value:!0}),c);var qt={};zt(qt,{GanttChart:()=>jt});module.exports=Kt(qt);var s=require("react"),tt=require("../../lib/i18n.cjs"),bt=require("../chart/ChartAxis.cjs"),$t=require("../chart/ChartContainer.cjs"),wt=require("../chart/ChartGrid.cjs"),Lt=require("../chart/ChartLegend.cjs"),H=require("../chart/ChartPlotClip.cjs"),Nt=require("../chart/ChartTooltip.cjs"),B=require("../chart/palette.cjs"),St=require("../chart/utils/cartesian.cjs"),st=require("../chart/utils/data.cjs"),et=require("../chart/utils/format.cjs"),Rt=require("../chart/utils/keyboard.cjs"),Ct=require("../chart/utils/path.cjs"),At=require("../chart/utils/scales.cjs"),Gt=require("../chart/utils/ticks.cjs"),k=require("../chart/utils/time.cjs"),It=require("../chart/utils/touch.cjs"),Mt=require("../table/Table.cjs"),Ot=require("../table/TableBody.cjs"),J=require("../table/TableCell.cjs"),Dt=require("../table/TableHeader.cjs"),Q=require("../table/TableHeaderCell.cjs"),Et=require("../table/TableRow.cjs"),t=require("react/jsx-runtime"),Ut=18,xt=.5,Ft=.3,it=7,vt=10,Pt=.02,yt="text-right [font-variant-numeric:tabular-nums]",Yt=(0,s.memo)(function({tasks:o,arrows:p,clipId:l}){return(0,t.jsxs)("g",{children:[(0,t.jsxs)("g",{clipPath:`url(#${l})`,children:[(0,t.jsx)("g",{className:"fill-gray-400 stroke-gray-400 dark:fill-gray-500 dark:stroke-gray-500",children:p.map(n=>(0,t.jsxs)("g",{children:[(0,t.jsx)("path",{d:n.d,fill:"none",strokeWidth:1}),(0,t.jsx)("path",{d:n.head,strokeWidth:0})]},n.key))}),o.map(n=>n.track?(0,t.jsxs)("g",{children:[(0,t.jsx)("path",{d:n.track,fill:n.color,fillOpacity:n.trackOpacity}),n.progress?(0,t.jsx)("path",{d:n.progress,fill:n.color}):null]},n.key):null)]}),o.map(n=>n.milestone?(0,t.jsx)("path",{d:n.milestone,fill:n.color,strokeWidth:2,stroke:B.CHART_SURFACE_COLOR},n.key):null)]})});function Zt({width:c,height:o,data:p,tasks:l,x:n,domain:P,unit:M,timeTicks:W,today:O,grid:X,size:V,barSize:K,colorOf:rt,margin:nt,tooltip:w,plotLabel:ct,todayLabel:mt,locale:L,formatDate:at,formatX:D,onTaskClick:E}){let[_,N]=(0,s.useState)(null),h=_!==null&&_<l.length?_:null,U=(0,tt.useUILabels)(),ot=(0,H.plotClipId)((0,s.useId)()),e=(0,s.useMemo)(()=>{let m=(0,St.buildCartesianGeometry)({width:c,height:o,data:p,x:n,y:{domain:P},bounds:P,margin:nt,orientation:"horizontal",placement:"band",formatValue:a=>(0,k.formatTimeTick)(a,M,L),formatX:D}),{valueScale:C,bandwidth:f,categoryPositions:$,innerWidth:Y,innerHeight:dt}=m,S=Math.min(K??Ut,f),ht=new Map(l.map((a,i)=>[a.id,i])),pt=l.map((a,i)=>{let T=$[i]+(f-S)/2,y=T+S/2,b=rt(a);if(a.start===null)return{key:`${i}`,color:b,track:null,trackOpacity:1,progress:null,milestone:null,top:$[i],height:f};let g=C(a.start);if(a.milestone)return{key:`${i}`,color:b,track:null,trackOpacity:1,progress:null,milestone:(0,H.isOnPlot)(g,Y)?`M${g},${y-it} L${g+it},${y} L${g},${y+it} L${g-it},${y} Z`:null,top:$[i],height:f};let G=C(a.end??a.start),x=Math.max(2,G-g);return{key:`${i}`,color:b,track:(0,Ct.buildBarPath)({x:g,y:T,width:x,height:S,radius:3}),trackOpacity:a.progress===null?1:Ft,progress:a.progress===null?null:(0,Ct.buildBarPath)({x:g,y:y-S*xt/2,width:Math.max(0,x*Math.min(1,Math.max(0,a.progress))),height:S*xt,radius:2,round:"right"}),milestone:null,top:$[i],height:f}}),lt=[];l.forEach((a,i)=>{if(a.start!==null)for(let T of a.dependsOn){let y=ht.get(T);if(y===void 0||y===i)continue;let b=l[y];if(b.start===null)continue;let g=C(b.end??b.start),G=$[y]+f/2,x=C(a.start),I=$[i]+f/2,Z=Math.max(g+vt,x-vt);lt.push({key:`${T}-${a.id}`,d:`M${g},${G} L${Z},${G} L${Z},${I} L${x-5},${I}`,head:`M${x},${I} L${x-5},${I-3.5} L${x-5},${I+3.5} Z`})}});let R=W.map(a=>({value:a,offset:C(a),label:(0,k.formatTimeTick)(a,M,L)})),A=O===null?null:C(O);return{rendered:pt,arrows:lt,categoryPositions:$,categoryCenters:m.categoryCenters,bandwidth:f,categoryTicks:m.categoryTicks,valueTicks:R,valueScale:C,todayAt:A!==null&&(0,H.isOnPlot)(A,Y)?A:null,innerWidth:Y,innerHeight:dt,margin:m.margin}},[l,p,n,P,M,W,O,c,o,nt,K,rt,L,D]),ut=(0,s.useCallback)(m=>{if(w===!1||l.length===0)return;let C=m.currentTarget.getBoundingClientRect(),f=m.clientY-C.top-e.margin.top;N((0,At.nearestIndex)(e.categoryCenters,f))},[w,l.length,e.margin.top,e.categoryCenters]),F=(0,s.useCallback)(()=>{!E||h===null||E(l[h])},[E,h,l]),gt=(0,s.useCallback)(m=>(0,Rt.handleChartKeyDown)(m,{count:l.length,current:h,axis:"y",onMove:N,pick:E?F:null}),[l.length,h,E,F]),u=h===null?null:l[h];return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("svg",{width:c,height:o,role:"img","aria-label":ct??l.map(m=>m.label).join(", "),tabIndex:0,className:`${It.CHART_TOUCH} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:ut,onPointerLeave:()=>N(null),onKeyDown:gt,onBlur:()=>N(null),onClick:F,children:[(0,t.jsxs)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:[(0,t.jsx)(H.ChartPlotClip,{id:ot,width:e.innerWidth,height:e.innerHeight}),(0,t.jsx)(wt.ChartGrid,{width:e.innerWidth,height:e.innerHeight,vertical:X?e.valueTicks.map(m=>m.offset):void 0}),h!==null?(0,t.jsx)("rect",{x:0,y:e.categoryPositions[h],width:e.innerWidth,height:e.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,(0,t.jsx)(Yt,{tasks:e.rendered,arrows:e.arrows,clipId:ot}),e.todayAt!==null?(0,t.jsxs)("g",{children:[(0,t.jsx)("line",{x1:e.todayAt,y1:0,x2:e.todayAt,y2:e.innerHeight,className:"stroke-gray-900 dark:stroke-white",strokeWidth:1,strokeDasharray:"4 4"}),(0,t.jsx)("text",{x:e.todayAt+4,y:8,className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:mt})]}):null]}),(0,t.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top+e.innerHeight})`,children:(0,t.jsx)(bt.ChartAxis,{orientation:"bottom",ticks:e.valueTicks,length:e.innerWidth,size:V})}),(0,t.jsx)("g",{transform:`translate(${e.margin.left}, ${e.margin.top})`,children:n.hidden?null:(0,t.jsx)(bt.ChartAxis,{orientation:"left",ticks:e.categoryTicks,length:e.innerHeight,showLine:!1,tickSize:0,label:n.label,size:V})})]}),u&&h!==null&&w!==!1?(0,t.jsx)(Nt.ChartTooltip,{x:e.margin.left+(u.start===null?e.innerWidth/2:Math.min(e.innerWidth,Math.max(0,e.valueScale(u.start)))),y:e.margin.top+e.categoryCenters[h],containerWidth:c,children:typeof w=="function"?w(u):(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:u.label}),(0,t.jsxs)("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[(0,t.jsx)("span",{children:U.chartStart}),(0,t.jsx)("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:u.start===null?"\u2014":at(u.start)})]}),u.milestone?null:(0,t.jsxs)("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[(0,t.jsx)("span",{children:U.chartEnd}),(0,t.jsx)("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:u.end===null?"\u2014":at(u.end)})]}),u.progress===null?null:(0,t.jsxs)("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[(0,t.jsx)("span",{children:U.chartProgress}),(0,t.jsx)("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:(0,et.formatPercent)(u.progress,{locale:L,maximumFractionDigits:0})})]})]})}):null]})}function jt({data:c,x:o,start:p,end:l,id:n,progress:P,milestone:M,dependencies:W,group:O,domain:X,today:V,ticks:K=6,barSize:rt,rowSize:nt=30,color:w,height:ct,width:mt,size:L="md",grid:at=!0,legend:D,tooltip:E=!0,tableView:_=!1,title:N,description:h,loading:U=!1,emptyState:ot,error:e=!1,errorState:ut,onRetry:F,actions:gt,margin:u,locale:m,plotLabel:C,startLabel:f,endLabel:$,progressLabel:Y,todayLabel:dt,formatDate:S,onTaskClick:ht,className:pt,...lt}){let R=(0,tt.useUILocale)(m),A=(0,tt.useUILabels)(),a=(0,s.useMemo)(()=>o.format??(r=>(0,et.formatXValue)(r,R)),[o.format,R]),i=(0,s.useMemo)(()=>c.map((r,d)=>{let j=(0,st.readXValue)(r,o.key,d),z=(0,k.toTimestamp)(r[p]),v=l?(0,k.toTimestamp)(r[l]):null,q=v===null||(M?!!r[M]:!1),kt=W?r[W]:void 0;return{index:d,id:String(n?r[n]??d:d),x:j,label:a(j,d),start:z,end:q?z:v??z,progress:P?(0,st.readNumber)(r,P):null,milestone:q,dependsOn:Array.isArray(kt)?kt.map(Wt=>String(Wt)):[],group:O?r[O]??null:null,datum:r}}),[c,o.key,p,l,n,P,M,W,O,a]),T=(0,s.useMemo)(()=>{let r=[];for(let d of i)d.group!==null&&!r.includes(d.group)&&r.push(d.group);return r},[i]),y=(0,s.useCallback)(r=>r.group===null?(0,B.getSeriesColor)(0,w):(0,B.getSeriesColor)(T.indexOf(r.group)),[T,w]),b=(0,s.useMemo)(()=>{if(X){let v=(0,k.toTimestamp)(X[0]),q=(0,k.toTimestamp)(X[1]);if(v!==null&&q!==null)return[v,q]}let r=(0,Gt.extent)(i.flatMap(v=>v.start===null?[]:[v.start,v.end??v.start]));if(r===null)return[0,1];let[d,j]=r,z=j-d||864e5;return[d-z*Pt,j+z*Pt]},[X,i]),g=(0,s.useMemo)(()=>(0,k.niceTimeTicks)(b[0],b[1],K),[b,K]),G=(0,s.useMemo)(()=>S??(r=>new Intl.DateTimeFormat(R,{day:"numeric",month:"short",year:"numeric"}).format(new Date(r))),[S,R]),x=(0,s.useMemo)(()=>V===!1?null:(0,k.toTimestamp)(V??Date.now()),[V]),I=(0,s.useMemo)(()=>T.map((r,d)=>({key:r,label:r,color:(0,B.getSeriesColor)(d),marker:"rect"})),[T]),Z=ct??Math.max(120,i.length*nt+48),Ht=D===void 0?T.length>=2:D!==!1,Tt=typeof D=="string"?D:"bottom";return(0,t.jsx)($t.ChartContainer,{title:N,description:h,height:Z,width:mt,size:L,loading:U,empty:i.length===0,emptyState:ot,error:e,errorState:ut,onRetry:F,actions:gt,tableView:_,legendPosition:Tt,legend:Ht&&I.length>0?(0,t.jsx)(Lt.ChartLegend,{items:I,position:Tt,marker:"rect",size:L}):void 0,table:_?(0,t.jsx)("div",{className:"w-full overflow-x-auto",children:(0,t.jsxs)(Mt.Table,{children:[typeof N=="string"?(0,t.jsx)("caption",{className:"sr-only",children:N}):null,(0,t.jsxs)(Dt.TableHeader,{children:[(0,t.jsx)(Q.TableHeaderCell,{children:o.label??o.key}),(0,t.jsx)(Q.TableHeaderCell,{className:"text-right",children:f??A.chartStart}),(0,t.jsx)(Q.TableHeaderCell,{className:"text-right",children:$??A.chartEnd}),P?(0,t.jsx)(Q.TableHeaderCell,{className:"text-right",children:Y??A.chartProgress}):null]}),(0,t.jsx)(Ot.TableBody,{children:i.map(r=>(0,t.jsxs)(Et.TableRow,{clickable:!1,children:[(0,t.jsx)(J.TableCell,{className:"font-medium text-gray-900 dark:text-gray-100",children:r.label}),(0,t.jsx)(J.TableCell,{className:yt,children:r.start===null?"\u2014":G(r.start)}),(0,t.jsx)(J.TableCell,{className:yt,children:r.milestone||r.end===null?"\u2014":G(r.end)}),P?(0,t.jsx)(J.TableCell,{className:yt,children:r.progress===null?"\u2014":(0,et.formatPercent)(r.progress,{locale:R,maximumFractionDigits:0})}):null]},r.index))})]})}):void 0,className:pt,...lt,children:({width:r})=>(0,t.jsx)(Zt,{width:r,height:Z,data:c,tasks:i,x:o,domain:b,unit:g.unit,timeTicks:g.values,today:x,grid:at,size:L,barSize:rt,colorOf:y,margin:u,tooltip:E,plotLabel:C,todayLabel:dt??A.chartToday,locale:R,formatDate:G,formatX:a,onTaskClick:ht})})}0&&(module.exports={GanttChart});
@@ -1 +1 @@
1
- "use client";import{memo as $t,useCallback as rt,useMemo as w,useState as Lt}from"react";import{useUILabels as xt,useUILocale as Pt}from"../../lib/i18n.js";import{ChartAxis as bt}from"../chart/ChartAxis.js";import{ChartContainer as Rt}from"../chart/ChartContainer.js";import{ChartGrid as Gt}from"../chart/ChartGrid.js";import{ChartLegend as Mt}from"../chart/ChartLegend.js";import{ChartTooltip as Dt}from"../chart/ChartTooltip.js";import{getSeriesColor as ut}from"../chart/palette.js";import{buildCartesianGeometry as Ot}from"../chart/utils/cartesian.js";import{readNumber as It,readXValue as At}from"../chart/utils/data.js";import{formatPercent as Nt,formatXValue as Et}from"../chart/utils/format.js";import{handleChartKeyDown as Ht}from"../chart/utils/keyboard.js";import{buildBarPath as yt}from"../chart/utils/path.js";import{nearestIndex as Wt}from"../chart/utils/scales.js";import{formatTimeTick as Ct,niceTimeTicks as Xt,toTimestamp as U}from"../chart/utils/time.js";import{CHART_TOUCH as Vt}from"../chart/utils/touch.js";import{Table as zt}from"../table/Table.js";import{TableBody as _t}from"../table/TableBody.js";import{TableCell as Q}from"../table/TableCell.js";import{TableHeader as Bt}from"../table/TableHeader.js";import{TableHeaderCell as tt}from"../table/TableHeaderCell.js";import{TableRow as Kt}from"../table/TableRow.js";import{Fragment as jt,jsx as e,jsxs as m}from"react/jsx-runtime";var Ut=18,Tt=.5,Yt=.3,et=7,kt=10,vt=.02,gt="text-right [font-variant-numeric:tabular-nums]",Ft=$t(function({tasks:u,arrows:G}){return m("g",{children:[e("g",{className:"fill-gray-400 stroke-gray-400 dark:fill-gray-500 dark:stroke-gray-500",children:G.map(r=>m("g",{children:[e("path",{d:r.d,fill:"none",strokeWidth:1}),e("path",{d:r.head,strokeWidth:0})]},r.key))}),u.map(r=>m("g",{children:[r.track?e("path",{d:r.track,fill:r.color,fillOpacity:r.trackOpacity}):null,r.progress?e("path",{d:r.progress,fill:r.color}):null,r.milestone?e("path",{d:r.milestone,fill:r.color,strokeWidth:2,className:"stroke-white dark:stroke-gray-800"}):null]},r.key))]})});function Zt({width:C,height:u,data:G,tasks:r,x:S,domain:T,unit:M,timeTicks:A,today:$,grid:E,size:H,barSize:V,colorOf:Y,margin:F,tooltip:L,plotLabel:nt,todayLabel:at,locale:P,formatDate:Z,formatX:D,onTaskClick:O}){let[W,R]=Lt(null),g=W!==null&&W<r.length?W:null,z=xt(),n=w(()=>{let i=Ot({width:C,height:u,data:G,x:S,y:{domain:T},bounds:T,margin:F,orientation:"horizontal",placement:"band",formatValue:a=>Ct(a,M,P),formatX:D}),{valueScale:b,bandwidth:h,categoryPositions:k,innerWidth:it,innerHeight:st}=i,I=Math.min(V??Ut,h),j=new Map(r.map((a,l)=>[a.id,l])),ct=r.map((a,l)=>{let v=k[l]+(h-I)/2,o=v+I/2,d=Y(a);if(a.start===null)return{key:`${l}`,color:d,track:null,trackOpacity:1,progress:null,milestone:null,top:k[l],height:h};let p=b(a.start);if(a.milestone)return{key:`${l}`,color:d,track:null,trackOpacity:1,progress:null,milestone:`M${p},${o-et} L${p+et},${o} L${p},${o+et} L${p-et},${o} Z`,top:k[l],height:h};let x=b(a.end??a.start),f=Math.max(2,x-p);return{key:`${l}`,color:d,track:yt({x:p,y:v,width:f,height:I,radius:3}),trackOpacity:a.progress===null?1:Yt,progress:a.progress===null?null:yt({x:p,y:o-I*Tt/2,width:Math.max(0,f*Math.min(1,Math.max(0,a.progress))),height:I*Tt,radius:2,round:"right"}),milestone:null,top:k[l],height:h}}),q=[];r.forEach((a,l)=>{if(a.start!==null)for(let v of a.dependsOn){let o=j.get(v);if(o===void 0||o===l)continue;let d=r[o];if(d.start===null)continue;let p=b(d.end??d.start),x=k[o]+h/2,f=b(a.start),N=k[l]+h/2,J=Math.max(p+kt,f-kt);q.push({key:`${v}-${a.id}`,d:`M${p},${x} L${J},${x} L${J},${N} L${f-5},${N}`,head:`M${f},${N} L${f-5},${N-3.5} L${f-5},${N+3.5} Z`})}});let mt=A.map(a=>({value:a,offset:b(a),label:Ct(a,M,P)}));return{rendered:ct,arrows:q,categoryPositions:k,categoryCenters:i.categoryCenters,bandwidth:h,categoryTicks:i.categoryTicks,valueTicks:mt,valueScale:b,innerWidth:it,innerHeight:st,margin:i.margin}},[r,G,S,T,M,A,C,u,F,V,Y,P,D]),ot=rt(i=>{if(L===!1||r.length===0)return;let b=i.currentTarget.getBoundingClientRect(),h=i.clientY-b.top-n.margin.top;R(Wt(n.categoryCenters,h))},[L,r.length,n.margin.top,n.categoryCenters]),_=rt(()=>{!O||g===null||O(r[g])},[O,g,r]),lt=rt(i=>Ht(i,{count:r.length,current:g,axis:"y",onMove:R,pick:O?_:null}),[r.length,g,O,_]),s=g===null?null:r[g];return m(jt,{children:[m("svg",{width:C,height:u,role:"img","aria-label":nt??r.map(i=>i.label).join(", "),tabIndex:0,className:`${Vt} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:ot,onPointerLeave:()=>R(null),onKeyDown:lt,onBlur:()=>R(null),onClick:_,children:[m("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:[e(Gt,{width:n.innerWidth,height:n.innerHeight,vertical:E?n.valueTicks.map(i=>i.offset):void 0}),g!==null?e("rect",{x:0,y:n.categoryPositions[g],width:n.innerWidth,height:n.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,e(Ft,{tasks:n.rendered,arrows:n.arrows}),$!==null?m("g",{children:[e("line",{x1:n.valueScale($),y1:0,x2:n.valueScale($),y2:n.innerHeight,className:"stroke-gray-900 dark:stroke-white",strokeWidth:1,strokeDasharray:"4 4"}),e("text",{x:n.valueScale($)+4,y:8,className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:at})]}):null]}),e("g",{transform:`translate(${n.margin.left}, ${n.margin.top+n.innerHeight})`,children:e(bt,{orientation:"bottom",ticks:n.valueTicks,length:n.innerWidth,size:H})}),e("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:S.hidden?null:e(bt,{orientation:"left",ticks:n.categoryTicks,length:n.innerHeight,showLine:!1,tickSize:0,label:S.label,size:H})})]}),s&&g!==null&&L!==!1?e(Dt,{x:n.margin.left+(s.start===null?n.innerWidth/2:n.valueScale(s.start)),y:n.margin.top+n.categoryCenters[g],containerWidth:C,children:typeof L=="function"?L(s):m("div",{className:"flex flex-col gap-1",children:[e("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:s.label}),m("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e("span",{children:z.chartStart}),e("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:s.start===null?"\u2014":Z(s.start)})]}),s.milestone?null:m("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e("span",{children:z.chartEnd}),e("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:s.end===null?"\u2014":Z(s.end)})]}),s.progress===null?null:m("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e("span",{children:z.chartProgress}),e("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:Nt(s.progress,{locale:P,maximumFractionDigits:0})})]})]})}):null]})}function Ce({data:C,x:u,start:G,end:r,id:S,progress:T,milestone:M,dependencies:A,group:$,domain:E,today:H,ticks:V=6,barSize:Y,rowSize:F=30,color:L,height:nt,width:at,size:P="md",grid:Z=!0,legend:D,tooltip:O=!0,tableView:W=!1,title:R,description:g,loading:z=!1,emptyState:n,error:ot=!1,errorState:_,onRetry:lt,actions:s,margin:i,locale:b,plotLabel:h,startLabel:k,endLabel:it,progressLabel:st,todayLabel:I,formatDate:j,onTaskClick:ct,className:q,...mt}){let a=Pt(b),l=xt(),v=w(()=>u.format??(t=>Et(t,a)),[u.format,a]),o=w(()=>C.map((t,c)=>{let B=At(t,u.key,c),X=U(t[G]),y=r?U(t[r]):null,K=M?!!t[M]:y===null,ft=A?t[A]:void 0;return{index:c,id:String(S?t[S]??c:c),x:B,label:v(B,c),start:X,end:K?X:y??X,progress:T?It(t,T):null,milestone:K,dependsOn:Array.isArray(ft)?ft.map(St=>String(St)):[],group:$?t[$]??null:null,datum:t}}),[C,u.key,G,r,S,T,M,A,$,v]),d=w(()=>{let t=[];for(let c of o)c.group!==null&&!t.includes(c.group)&&t.push(c.group);return t},[o]),p=rt(t=>t.group===null?L??ut(0):ut(d.indexOf(t.group)),[d,L]),x=w(()=>{if(E){let y=U(E[0]),K=U(E[1]);if(y!==null&&K!==null)return[y,K]}let t=o.flatMap(y=>y.start===null?[]:[y.start,y.end??y.start]);if(t.length===0)return[0,1];let c=Math.min(...t),B=Math.max(...t),X=B-c||864e5;return[c-X*vt,B+X*vt]},[E,o]),f=w(()=>Xt(x[0],x[1],V),[x,V]),N=w(()=>j??(t=>new Intl.DateTimeFormat(a,{day:"numeric",month:"short",year:"numeric"}).format(new Date(t))),[j,a]),J=w(()=>H===!1?null:U(H??Date.now()),[H]),dt=w(()=>d.map((t,c)=>({key:t,label:t,color:ut(c),marker:"rect"})),[d]),ht=nt??Math.max(120,o.length*F+48),wt=D===void 0?d.length>=2:D!==!1,pt=typeof D=="string"?D:"bottom";return e(Rt,{title:R,description:g,height:ht,width:at,size:P,loading:z,empty:o.length===0,emptyState:n,error:ot,errorState:_,onRetry:lt,actions:s,tableView:W,legendPosition:pt,legend:wt&&dt.length>0?e(Mt,{items:dt,position:pt,marker:"rect",size:P}):void 0,table:W?e("div",{className:"w-full overflow-x-auto",children:m(zt,{children:[typeof R=="string"?e("caption",{className:"sr-only",children:R}):null,m(Bt,{children:[e(tt,{children:u.label??u.key}),e(tt,{className:"text-right",children:k??l.chartStart}),e(tt,{className:"text-right",children:it??l.chartEnd}),T?e(tt,{className:"text-right",children:st??l.chartProgress}):null]}),e(_t,{children:o.map(t=>m(Kt,{clickable:!1,children:[e(Q,{className:"font-medium text-gray-900 dark:text-gray-100",children:t.label}),e(Q,{className:gt,children:t.start===null?"\u2014":N(t.start)}),e(Q,{className:gt,children:t.milestone||t.end===null?"\u2014":N(t.end)}),T?e(Q,{className:gt,children:t.progress===null?"\u2014":Nt(t.progress,{locale:a,maximumFractionDigits:0})}):null]},t.index))})]})}):void 0,className:q,...mt,children:({width:t})=>e(Zt,{width:t,height:ht,data:C,tasks:o,x:u,domain:x,unit:f.unit,timeTicks:f.values,today:J,grid:Z,size:P,barSize:Y,colorOf:p,margin:i,tooltip:O,plotLabel:h,todayLabel:I??l.chartToday,locale:a,formatDate:N,formatX:v,onTaskClick:ct})})}export{Ce as GanttChart};
1
+ "use client";import{memo as Nt,useCallback as ot,useId as St,useMemo as P,useState as Rt}from"react";import{useUILabels as Pt,useUILocale as At}from"../../lib/i18n.js";import{ChartAxis as yt}from"../chart/ChartAxis.js";import{ChartContainer as Gt}from"../chart/ChartContainer.js";import{ChartGrid as It}from"../chart/ChartGrid.js";import{ChartLegend as Mt}from"../chart/ChartLegend.js";import{ChartPlotClip as Ot,isOnPlot as bt,plotClipId as Dt}from"../chart/ChartPlotClip.js";import{ChartTooltip as Et}from"../chart/ChartTooltip.js";import{CHART_SURFACE_COLOR as Ht,getSeriesColor as dt}from"../chart/palette.js";import{buildCartesianGeometry as Wt}from"../chart/utils/cartesian.js";import{readNumber as Xt,readXValue as Vt}from"../chart/utils/data.js";import{formatPercent as $t,formatXValue as _t}from"../chart/utils/format.js";import{handleChartKeyDown as zt}from"../chart/utils/keyboard.js";import{buildBarPath as Ct}from"../chart/utils/path.js";import{nearestIndex as Bt}from"../chart/utils/scales.js";import{extent as Kt}from"../chart/utils/ticks.js";import{formatTimeTick as Tt,niceTimeTicks as Ut,toTimestamp as j}from"../chart/utils/time.js";import{CHART_TOUCH as Ft}from"../chart/utils/touch.js";import{Table as Yt}from"../table/Table.js";import{TableBody as Zt}from"../table/TableBody.js";import{TableCell as rt}from"../table/TableCell.js";import{TableHeader as jt}from"../table/TableHeader.js";import{TableHeaderCell as nt}from"../table/TableHeaderCell.js";import{TableRow as qt}from"../table/TableRow.js";import{Fragment as re,jsx as r,jsxs as s}from"react/jsx-runtime";var Jt=18,kt=.5,Qt=.3,at=7,xt=10,vt=.02,ht="text-right [font-variant-numeric:tabular-nums]",te=Nt(function({tasks:c,arrows:I,clipId:l}){return s("g",{children:[s("g",{clipPath:`url(#${l})`,children:[r("g",{className:"fill-gray-400 stroke-gray-400 dark:fill-gray-500 dark:stroke-gray-500",children:I.map(n=>s("g",{children:[r("path",{d:n.d,fill:"none",strokeWidth:1}),r("path",{d:n.head,strokeWidth:0})]},n.key))}),c.map(n=>n.track?s("g",{children:[r("path",{d:n.track,fill:n.color,fillOpacity:n.trackOpacity}),n.progress?r("path",{d:n.progress,fill:n.color}):null]},n.key):null)]}),c.map(n=>n.milestone?r("path",{d:n.milestone,fill:n.color,strokeWidth:2,stroke:Ht},n.key):null)]})});function ee({width:k,height:c,data:I,tasks:l,x:n,domain:x,unit:M,timeTicks:H,today:O,grid:W,size:X,barSize:z,colorOf:q,margin:J,tooltip:$,plotLabel:lt,todayLabel:it,locale:w,formatDate:Q,formatX:D,onTaskClick:E}){let[V,L]=Rt(null),d=V!==null&&V<l.length?V:null,B=Pt(),tt=Dt(St()),t=P(()=>{let i=Wt({width:k,height:c,data:I,x:n,y:{domain:x},bounds:x,margin:J,orientation:"horizontal",placement:"band",formatValue:a=>Tt(a,M,w),formatX:D}),{valueScale:y,bandwidth:h,categoryPositions:v,innerWidth:U,innerHeight:mt}=i,N=Math.min(z??Jt,h),ut=new Map(l.map((a,o)=>[a.id,o])),gt=l.map((a,o)=>{let b=v[o]+(h-N)/2,p=b+N/2,f=q(a);if(a.start===null)return{key:`${o}`,color:f,track:null,trackOpacity:1,progress:null,milestone:null,top:v[o],height:h};let u=y(a.start);if(a.milestone)return{key:`${o}`,color:f,track:null,trackOpacity:1,progress:null,milestone:bt(u,U)?`M${u},${p-at} L${u+at},${p} L${u},${p+at} L${u-at},${p} Z`:null,top:v[o],height:h};let A=y(a.end??a.start),C=Math.max(2,A-u);return{key:`${o}`,color:f,track:Ct({x:u,y:b,width:C,height:N,radius:3}),trackOpacity:a.progress===null?1:Qt,progress:a.progress===null?null:Ct({x:u,y:p-N*kt/2,width:Math.max(0,C*Math.min(1,Math.max(0,a.progress))),height:N*kt,radius:2,round:"right"}),milestone:null,top:v[o],height:h}}),et=[];l.forEach((a,o)=>{if(a.start!==null)for(let b of a.dependsOn){let p=ut.get(b);if(p===void 0||p===o)continue;let f=l[p];if(f.start===null)continue;let u=y(f.end??f.start),A=v[p]+h/2,C=y(a.start),G=v[o]+h/2,F=Math.max(u+xt,C-xt);et.push({key:`${b}-${a.id}`,d:`M${u},${A} L${F},${A} L${F},${G} L${C-5},${G}`,head:`M${C},${G} L${C-5},${G-3.5} L${C-5},${G+3.5} Z`})}});let S=H.map(a=>({value:a,offset:y(a),label:Tt(a,M,w)})),R=O===null?null:y(O);return{rendered:gt,arrows:et,categoryPositions:v,categoryCenters:i.categoryCenters,bandwidth:h,categoryTicks:i.categoryTicks,valueTicks:S,valueScale:y,todayAt:R!==null&&bt(R,U)?R:null,innerWidth:U,innerHeight:mt,margin:i.margin}},[l,I,n,x,M,H,O,k,c,J,z,q,w,D]),st=ot(i=>{if($===!1||l.length===0)return;let y=i.currentTarget.getBoundingClientRect(),h=i.clientY-y.top-t.margin.top;L(Bt(t.categoryCenters,h))},[$,l.length,t.margin.top,t.categoryCenters]),K=ot(()=>{!E||d===null||E(l[d])},[E,d,l]),ct=ot(i=>zt(i,{count:l.length,current:d,axis:"y",onMove:L,pick:E?K:null}),[l.length,d,E,K]),m=d===null?null:l[d];return s(re,{children:[s("svg",{width:k,height:c,role:"img","aria-label":lt??l.map(i=>i.label).join(", "),tabIndex:0,className:`${Ft} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-synertech-primary-500`,onPointerMove:st,onPointerLeave:()=>L(null),onKeyDown:ct,onBlur:()=>L(null),onClick:K,children:[s("g",{transform:`translate(${t.margin.left}, ${t.margin.top})`,children:[r(Ot,{id:tt,width:t.innerWidth,height:t.innerHeight}),r(It,{width:t.innerWidth,height:t.innerHeight,vertical:W?t.valueTicks.map(i=>i.offset):void 0}),d!==null?r("rect",{x:0,y:t.categoryPositions[d],width:t.innerWidth,height:t.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,r(te,{tasks:t.rendered,arrows:t.arrows,clipId:tt}),t.todayAt!==null?s("g",{children:[r("line",{x1:t.todayAt,y1:0,x2:t.todayAt,y2:t.innerHeight,className:"stroke-gray-900 dark:stroke-white",strokeWidth:1,strokeDasharray:"4 4"}),r("text",{x:t.todayAt+4,y:8,className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:it})]}):null]}),r("g",{transform:`translate(${t.margin.left}, ${t.margin.top+t.innerHeight})`,children:r(yt,{orientation:"bottom",ticks:t.valueTicks,length:t.innerWidth,size:X})}),r("g",{transform:`translate(${t.margin.left}, ${t.margin.top})`,children:n.hidden?null:r(yt,{orientation:"left",ticks:t.categoryTicks,length:t.innerHeight,showLine:!1,tickSize:0,label:n.label,size:X})})]}),m&&d!==null&&$!==!1?r(Et,{x:t.margin.left+(m.start===null?t.innerWidth/2:Math.min(t.innerWidth,Math.max(0,t.valueScale(m.start)))),y:t.margin.top+t.categoryCenters[d],containerWidth:k,children:typeof $=="function"?$(m):s("div",{className:"flex flex-col gap-1",children:[r("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:m.label}),s("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[r("span",{children:B.chartStart}),r("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:m.start===null?"\u2014":Q(m.start)})]}),m.milestone?null:s("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[r("span",{children:B.chartEnd}),r("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:m.end===null?"\u2014":Q(m.end)})]}),m.progress===null?null:s("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[r("span",{children:B.chartProgress}),r("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:$t(m.progress,{locale:w,maximumFractionDigits:0})})]})]})}):null]})}function Le({data:k,x:c,start:I,end:l,id:n,progress:x,milestone:M,dependencies:H,group:O,domain:W,today:X,ticks:z=6,barSize:q,rowSize:J=30,color:$,height:lt,width:it,size:w="md",grid:Q=!0,legend:D,tooltip:E=!0,tableView:V=!1,title:L,description:d,loading:B=!1,emptyState:tt,error:t=!1,errorState:st,onRetry:K,actions:ct,margin:m,locale:i,plotLabel:y,startLabel:h,endLabel:v,progressLabel:U,todayLabel:mt,formatDate:N,onTaskClick:ut,className:gt,...et}){let S=At(i),R=Pt(),a=P(()=>c.format??(e=>_t(e,S)),[c.format,S]),o=P(()=>k.map((e,g)=>{let Y=Vt(e,c.key,g),_=j(e[I]),T=l?j(e[l]):null,Z=T===null||(M?!!e[M]:!1),ft=H?e[H]:void 0;return{index:g,id:String(n?e[n]??g:g),x:Y,label:a(Y,g),start:_,end:Z?_:T??_,progress:x?Xt(e,x):null,milestone:Z,dependsOn:Array.isArray(ft)?ft.map(Lt=>String(Lt)):[],group:O?e[O]??null:null,datum:e}}),[k,c.key,I,l,n,x,M,H,O,a]),b=P(()=>{let e=[];for(let g of o)g.group!==null&&!e.includes(g.group)&&e.push(g.group);return e},[o]),p=ot(e=>e.group===null?dt(0,$):dt(b.indexOf(e.group)),[b,$]),f=P(()=>{if(W){let T=j(W[0]),Z=j(W[1]);if(T!==null&&Z!==null)return[T,Z]}let e=Kt(o.flatMap(T=>T.start===null?[]:[T.start,T.end??T.start]));if(e===null)return[0,1];let[g,Y]=e,_=Y-g||864e5;return[g-_*vt,Y+_*vt]},[W,o]),u=P(()=>Ut(f[0],f[1],z),[f,z]),A=P(()=>N??(e=>new Intl.DateTimeFormat(S,{day:"numeric",month:"short",year:"numeric"}).format(new Date(e))),[N,S]),C=P(()=>X===!1?null:j(X??Date.now()),[X]),G=P(()=>b.map((e,g)=>({key:e,label:e,color:dt(g),marker:"rect"})),[b]),F=lt??Math.max(120,o.length*J+48),wt=D===void 0?b.length>=2:D!==!1,pt=typeof D=="string"?D:"bottom";return r(Gt,{title:L,description:d,height:F,width:it,size:w,loading:B,empty:o.length===0,emptyState:tt,error:t,errorState:st,onRetry:K,actions:ct,tableView:V,legendPosition:pt,legend:wt&&G.length>0?r(Mt,{items:G,position:pt,marker:"rect",size:w}):void 0,table:V?r("div",{className:"w-full overflow-x-auto",children:s(Yt,{children:[typeof L=="string"?r("caption",{className:"sr-only",children:L}):null,s(jt,{children:[r(nt,{children:c.label??c.key}),r(nt,{className:"text-right",children:h??R.chartStart}),r(nt,{className:"text-right",children:v??R.chartEnd}),x?r(nt,{className:"text-right",children:U??R.chartProgress}):null]}),r(Zt,{children:o.map(e=>s(qt,{clickable:!1,children:[r(rt,{className:"font-medium text-gray-900 dark:text-gray-100",children:e.label}),r(rt,{className:ht,children:e.start===null?"\u2014":A(e.start)}),r(rt,{className:ht,children:e.milestone||e.end===null?"\u2014":A(e.end)}),x?r(rt,{className:ht,children:e.progress===null?"\u2014":$t(e.progress,{locale:S,maximumFractionDigits:0})}):null]},e.index))})]})}):void 0,className:gt,...et,children:({width:e})=>r(ee,{width:e,height:F,data:k,tasks:o,x:c,domain:f,unit:u.unit,timeTicks:u.values,today:C,grid:Q,size:w,barSize:q,colorOf:p,margin:m,tooltip:E,plotLabel:y,todayLabel:mt??R.chartToday,locale:S,formatDate:A,formatX:a,onTaskClick:ut})})}export{Le as GanttChart};