@synertech/ui 0.45.0 → 0.46.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 (150) hide show
  1. package/.claude/skills/use-synertech-ui/SKILL.md +116 -18
  2. package/README.md +47 -5
  3. package/dist/components/area-chart/AreaChart.cjs +1 -1
  4. package/dist/components/area-chart/AreaChart.js +1 -1
  5. package/dist/components/avatar/Avatar.cjs +1 -1
  6. package/dist/components/avatar/Avatar.js +1 -1
  7. package/dist/components/banner/Banner.cjs +1 -1
  8. package/dist/components/banner/Banner.js +1 -1
  9. package/dist/components/bar-chart/BarChart.cjs +1 -1
  10. package/dist/components/bar-chart/BarChart.js +1 -1
  11. package/dist/components/box-plot/BoxPlot.cjs +1 -1
  12. package/dist/components/box-plot/BoxPlot.js +1 -1
  13. package/dist/components/breadcrumb/Breadcrumb.cjs +1 -1
  14. package/dist/components/breadcrumb/Breadcrumb.js +1 -1
  15. package/dist/components/bullet-chart/BulletChart.cjs +1 -1
  16. package/dist/components/bullet-chart/BulletChart.js +1 -1
  17. package/dist/components/calendar/Calendar.cjs +1 -1
  18. package/dist/components/calendar/Calendar.js +1 -1
  19. package/dist/components/candlestick-chart/CandlestickChart.cjs +1 -1
  20. package/dist/components/candlestick-chart/CandlestickChart.js +1 -1
  21. package/dist/components/chart/ChartBrush.cjs +1 -1
  22. package/dist/components/chart/ChartBrush.js +1 -1
  23. package/dist/components/chart/ChartExportButton.cjs +1 -1
  24. package/dist/components/chart/ChartExportButton.js +1 -1
  25. package/dist/components/chart/ChartSync.cjs +1 -1
  26. package/dist/components/chart/ChartSync.js +1 -1
  27. package/dist/components/chart/utils/cartesian.cjs +1 -1
  28. package/dist/components/chart/utils/cartesian.js +1 -1
  29. package/dist/components/chart/utils/export.cjs +1 -2
  30. package/dist/components/chart/utils/export.js +1 -2
  31. package/dist/components/chart/utils/keyboard.cjs +1 -0
  32. package/dist/components/chart/utils/keyboard.js +1 -0
  33. package/dist/components/chart/utils/path.cjs +1 -1
  34. package/dist/components/chart/utils/path.js +1 -1
  35. package/dist/components/chart/utils/time.cjs +1 -1
  36. package/dist/components/chart/utils/time.js +1 -1
  37. package/dist/components/chart/utils/timestamp.cjs +1 -0
  38. package/dist/components/chart/utils/timestamp.js +1 -0
  39. package/dist/components/chart/utils/touch.cjs +1 -0
  40. package/dist/components/chart/utils/touch.js +1 -0
  41. package/dist/components/chip/Chip.cjs +1 -1
  42. package/dist/components/chip/Chip.js +1 -1
  43. package/dist/components/datagrid/DataGrid.cjs +1 -2
  44. package/dist/components/datagrid/DataGrid.js +1 -2
  45. package/dist/components/device-mockup/DeviceMockup.cjs +1 -1
  46. package/dist/components/device-mockup/DeviceMockup.js +1 -1
  47. package/dist/components/dropdown/Dropdown.cjs +1 -1
  48. package/dist/components/dropdown/Dropdown.js +1 -1
  49. package/dist/components/dropdown/DropdownCheckboxItem.cjs +1 -1
  50. package/dist/components/dropdown/DropdownCheckboxItem.js +1 -1
  51. package/dist/components/dropdown/DropdownContent.cjs +1 -1
  52. package/dist/components/dropdown/DropdownContent.js +1 -1
  53. package/dist/components/dropdown/DropdownItem.cjs +1 -1
  54. package/dist/components/dropdown/DropdownItem.js +1 -1
  55. package/dist/components/dropdown/DropdownRadio.cjs +1 -1
  56. package/dist/components/dropdown/DropdownRadio.js +1 -1
  57. package/dist/components/dropdown/DropdownSubMenu.cjs +1 -1
  58. package/dist/components/dropdown/DropdownSubMenu.js +1 -1
  59. package/dist/components/dropdown/hooks/index.cjs +1 -1
  60. package/dist/components/dropdown/hooks/index.js +1 -1
  61. package/dist/components/dropdown/hooks/useClickOutside.cjs +1 -1
  62. package/dist/components/dropdown/hooks/useClickOutside.js +1 -1
  63. package/dist/components/dropdown/index.cjs +1 -1
  64. package/dist/components/dropdown/index.js +1 -1
  65. package/dist/components/dropdown/menu-navigation.cjs +1 -0
  66. package/dist/components/dropdown/menu-navigation.js +1 -0
  67. package/dist/components/dumbbell-chart/DumbbellChart.cjs +1 -1
  68. package/dist/components/dumbbell-chart/DumbbellChart.js +1 -1
  69. package/dist/components/file-selector/FileSelector.cjs +1 -1
  70. package/dist/components/file-selector/FileSelector.js +1 -1
  71. package/dist/components/form/input/Input.cjs +1 -1
  72. package/dist/components/form/input/Input.js +1 -1
  73. package/dist/components/form/mention-input/MentionInput.cjs +1 -1
  74. package/dist/components/form/mention-input/MentionInput.js +1 -1
  75. package/dist/components/form/number-input/NumberInput.cjs +1 -1
  76. package/dist/components/form/number-input/NumberInput.js +1 -1
  77. package/dist/components/funnel-chart/FunnelChart.cjs +1 -1
  78. package/dist/components/funnel-chart/FunnelChart.js +1 -1
  79. package/dist/components/gantt-chart/GanttChart.cjs +1 -1
  80. package/dist/components/gantt-chart/GanttChart.js +1 -1
  81. package/dist/components/header/Header.cjs +1 -1
  82. package/dist/components/header/Header.js +1 -1
  83. package/dist/components/heat-map/Heatmap.cjs +1 -1
  84. package/dist/components/heat-map/Heatmap.js +1 -1
  85. package/dist/components/help-button/HelpButton.cjs +7 -7
  86. package/dist/components/help-button/HelpButton.js +7 -7
  87. package/dist/components/help-button/MarkdownEditor.cjs +1 -1
  88. package/dist/components/help-button/MarkdownEditor.js +1 -1
  89. package/dist/components/image-uploader/ImageUploader.cjs +1 -1
  90. package/dist/components/image-uploader/ImageUploader.js +1 -1
  91. package/dist/components/label/Label.cjs +1 -1
  92. package/dist/components/label/Label.js +1 -1
  93. package/dist/components/line-chart/LineChart.cjs +1 -1
  94. package/dist/components/line-chart/LineChart.js +1 -1
  95. package/dist/components/modal/Modal.cjs +1 -1
  96. package/dist/components/modal/Modal.js +1 -1
  97. package/dist/components/pagination/Pagination.cjs +1 -1
  98. package/dist/components/pagination/Pagination.js +1 -1
  99. package/dist/components/pie-chart/PieChart.cjs +1 -1
  100. package/dist/components/pie-chart/PieChart.js +1 -1
  101. package/dist/components/radio-button/RadioButton.cjs +1 -1
  102. package/dist/components/radio-button/RadioButton.js +1 -1
  103. package/dist/components/scatter-chart/ScatterChart.cjs +1 -1
  104. package/dist/components/scatter-chart/ScatterChart.js +1 -1
  105. package/dist/components/schema-editor/SchemaEditor.cjs +1 -1
  106. package/dist/components/schema-editor/SchemaEditor.js +1 -1
  107. package/dist/components/schema-editor/legend/SchemaLegend.cjs +1 -1
  108. package/dist/components/schema-editor/legend/SchemaLegend.js +1 -1
  109. package/dist/components/schema-editor/tables/SchemaTableRenderer.cjs +1 -1
  110. package/dist/components/schema-editor/tables/SchemaTableRenderer.js +1 -1
  111. package/dist/components/schema-editor/toolbar/SchemaToolbar.cjs +1 -1
  112. package/dist/components/schema-editor/toolbar/SchemaToolbar.js +1 -1
  113. package/dist/components/select/Select.cjs +1 -1
  114. package/dist/components/select/Select.js +1 -1
  115. package/dist/components/tabs/Tabs.cjs +1 -1
  116. package/dist/components/tabs/Tabs.js +1 -1
  117. package/dist/components/tabs/TabsContent.cjs +1 -1
  118. package/dist/components/tabs/TabsContent.js +1 -1
  119. package/dist/components/tabs/TabsContext.cjs +1 -1
  120. package/dist/components/tabs/TabsContext.js +1 -1
  121. package/dist/components/tabs/TabsList.cjs +1 -1
  122. package/dist/components/tabs/TabsList.js +1 -1
  123. package/dist/components/tabs/TabsTrigger.cjs +1 -1
  124. package/dist/components/tabs/TabsTrigger.js +1 -1
  125. package/dist/components/toast/Toast.cjs +1 -1
  126. package/dist/components/toast/Toast.js +1 -1
  127. package/dist/components/waterfall-chart/WaterfallChart.cjs +1 -1
  128. package/dist/components/waterfall-chart/WaterfallChart.js +1 -1
  129. package/dist/components/wizard/Wizard.cjs +1 -1
  130. package/dist/components/wizard/Wizard.js +1 -1
  131. package/dist/components/workflow-editor/WorkflowEditor.cjs +1 -1
  132. package/dist/components/workflow-editor/WorkflowEditor.js +1 -1
  133. package/dist/components/workflow-editor/toolbar/WorkflowToolbar.cjs +1 -1
  134. package/dist/components/workflow-editor/toolbar/WorkflowToolbar.js +1 -1
  135. package/dist/index.cjs +1 -1
  136. package/dist/index.d.cts +830 -175
  137. package/dist/index.d.ts +830 -175
  138. package/dist/index.js +1 -1
  139. package/dist/lib/aria-hide.cjs +1 -1
  140. package/dist/lib/aria-hide.js +1 -1
  141. package/dist/lib/csv.cjs +2 -0
  142. package/dist/lib/csv.js +2 -0
  143. package/dist/lib/i18n.cjs +1 -1
  144. package/dist/lib/i18n.js +1 -1
  145. package/dist/lib/server-labels.cjs +1 -0
  146. package/dist/lib/server-labels.js +1 -0
  147. package/dist/lib/ui-labels.cjs +1 -0
  148. package/dist/lib/ui-labels.js +1 -0
  149. package/dist/styles.css +3070 -264
  150. package/package.json +14 -14
@@ -1 +1 @@
1
- "use client";import{forwardRef as g,useEffect as W,useId as y,useRef as A}from"react";import{cn as S}from"../../../lib/cn.js";import{getBaseInputClasses as N,getIconClasses as v}from"../shared/inputStyles.js";import{InputWrapper as w}from"../shared/InputWrapper.js";import{jsx as s,jsxs as j}from"react/jsx-runtime";var z=g(({label:L,inline:M=!1,size:d="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,className:C,...c},n)=>{let I=A(null),T=p=>{I.current=p,typeof n=="function"?n(p):n&&(n.current=p)};W(()=>{m&&I.current?.focus()},[m]);let o=y(),b=S(N({size:d,error:u,disabled:e,readOnly:t,icon:r,iconPosition:i}),f&&"resize-vertical",C),P={...l&&{borderColor:l},...a&&{color:a}},R=l||a?P:void 0;return s(w,{label:L,hideLabel:x,labelColor:E,error:u,helperText:H,inline:M,htmlFor:o,children:j("div",{className:"relative w-full",children:[r&&s("span",{className:v(i),children:r}),f?s("textarea",{ref:T,id:o,disabled:e,readOnly:t,rows:h,tabIndex:t||e?-1:void 0,className:b,style:R,...c}):s("input",{ref:T,id:o,disabled:e,readOnly:t,tabIndex:t||e?-1:void 0,className:b,style:R,...c})]})})});z.displayName="Input";export{z as Input};
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 +1 @@
1
- "use strict";"use client";var X=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var ge=Object.getOwnPropertyNames;var be=Object.prototype.hasOwnProperty;var xe=(l,d)=>{for(var m in d)X(l,m,{get:d[m],enumerable:!0})},he=(l,d,m,M)=>{if(d&&typeof d=="object"||typeof d=="function")for(let f of ge(d))!be.call(l,f)&&f!==m&&X(l,f,{get:()=>d[f],enumerable:!(M=me(d,f))||M.enumerable});return l};var ve=l=>he(X({},"__esModule",{value:!0}),l);var Ne={};xe(Ne,{MentionInput:()=>oe});module.exports=ve(Ne);var o=require("react"),te=require("react-dom/client"),R=require("../../../lib/cn.cjs"),L=require("../shared/inputStyles.cjs"),ne=require("../shared/InputWrapper.cjs"),re=require("../../chip/Chip.cjs"),c=require("react/jsx-runtime"),ye=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})]}),oe=(0,o.forwardRef)(({label:l,inline:d=!1,size:m="md",labelColor:M,borderColor:f,textColor:k,disabled:g=!1,readOnly:C=!1,error:$=!1,helperText:ae,hideLabel:ie=!1,icon:B,iconPosition:K="left",mentionTrigger:b="@",suggestions:T=[],onMentionSearch:W,onMentionSelect:F,onMentionRemove:Q,renderSuggestion:U,value:p,onChange:x,placeholder:H,loading:se=!1,maxSuggestions:O=10,chipVariant:j="soft",chipColor:G="primary",chipSize:J="sm"},I)=>{let Y=(0,o.useId)(),s=(0,o.useRef)(null),[_,w]=(0,o.useState)(!1),[D,V]=(0,o.useState)(0),[Ce,P]=(0,o.useState)(""),le=(0,R.cn)((0,L.getBaseInputClasses)({size:m,error:$,disabled:g,readOnly:C,icon:B,iconPosition:K}),"min-h-[42px]","whitespace-pre-wrap","break-words"),ce={...f&&{borderColor:f},...k&&{color:k}},de=f||k?ce:void 0,h=(0,o.useCallback)(()=>{if(!s.current)return{text:"",mentions:[]};let e="",n=[],t=0,a=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"),v=i.getAttribute("data-mention-label")||"",A=i.getAttribute("data-mention-avatar")||void 0,y=`@${v}`,S=t;n.push({trigger:b,suggestion:{id:u||"",label:v,avatar:A},startIndex:S,endIndex:S+y.length}),e+=y,t+=y.length}else i.childNodes.forEach(a)}};return s.current.childNodes.forEach(a),{text:e,mentions:n}},[b]),Z=(0,o.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,te.createRoot)(t).render((0,c.jsx)(re.Chip,{label:e.label,variant:j,color:G,size:J,closable:!g&&!C,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]),E=(0,o.useCallback)(e=>{if(!s.current)return;let n=s.current.querySelector(`[data-mention-id="${e}"]`);if(n){n.remove();let t=h();x?.(t);let a=p?.mentions.find(r=>r.suggestion.id===e)?.suggestion;a&&Q?.(a)}},[h,x,Q,p?.mentions]),ue=(0,o.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 a=t.match(new RegExp(`${b}(\\w*)$`));if(a){let i=a[1];P(i),w(!0),V(0),W?.(i)}else w(!1),P("");let r=h();x?.(r)},[b,W,x,h]),q=(0,o.useCallback)(e=>{if(!s.current)return;let n=window.getSelection();if(!n||n.rangeCount===0)return;let t=n.getRangeAt(0);if(t.startContainer.nodeType===Node.TEXT_NODE){let r=t.startContainer,i=r.textContent||"",u=t.startOffset,A=i.substring(0,u).lastIndexOf(b);if(A!==-1){let y=i.substring(0,A),S=i.substring(u),N=Z(e,()=>{E(e.id)});if(y?(r.textContent=y,r.parentNode?.insertBefore(N,r.nextSibling)):(r.parentNode?.insertBefore(N,r),r.textContent="",r.textContent||r.remove()),S){let pe=document.createTextNode(S);N.parentNode?.insertBefore(pe,N.nextSibling)}let ee=document.createTextNode(" ");N.parentNode?.insertBefore(ee,N.nextSibling);let z=document.createRange();z.setStartAfter(ee),z.collapse(!0),n.removeAllRanges(),n.addRange(z)}}w(!1),P("");let a=h();x?.(a),F?.(e),s.current.focus()},[b,Z,E,h,x,F]),fe=(0,o.useCallback)(e=>{let n=T.slice(0,O);if(_&&n.length>0)switch(e.key){case"ArrowDown":e.preventDefault(),V(t=>t<n.length-1?t+1:0);return;case"ArrowUp":e.preventDefault(),V(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(),w(!1);return}if(e.key==="Backspace"){let t=window.getSelection();if(!t||t.rangeCount===0)return;let a=t.getRangeAt(0);if(a.collapsed&&a.startOffset===0){let r=a.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(a.collapsed&&a.startContainer.nodeType===Node.TEXT_NODE){let r=a.startContainer;if(a.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 v=u.getAttribute("data-mention-id");v&&E(v);return}}}}}},[_,T,D,O,q,E]);return(0,o.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,o.useEffect)(()=>{s.current&&p?.text===""&&p?.mentions.length===0&&s.current.innerHTML.trim()&&(s.current.innerHTML="")},[p?.text,p?.mentions.length]),(0,c.jsx)(ne.InputWrapper,{label:l,hideLabel:ie,labelColor:M,error:$,helperText:ae,inline:d,htmlFor:Y,children:(0,c.jsxs)("div",{className:"relative w-full",children:[B&&(0,c.jsx)("span",{className:(0,L.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:ue,onKeyDown:fe,className:(0,R.cn)(le,"empty:before:content-[attr(data-placeholder)] empty:before:text-gray-400 empty:before:dark:text-gray-500"),style:de,role:"textbox","aria-label":l,"aria-multiline":"true",tabIndex:C||g?-1:0}),_&&T.length>0&&(0,c.jsx)("div",{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?(0,c.jsx)("div",{className:"px-3 py-2 text-sm text-gray-500 dark:text-gray-400",children:"Loading..."}):T.slice(0,O).map((e,n)=>(0,c.jsx)("div",{onClick:()=>q(e),className:(0,R.cn)(n===D&&"bg-gray-100 dark:bg-gray-600"),children:U?U(e):ye(e)},e.id))})]})})});oe.displayName="MentionInput";0&&(module.exports={MentionInput});
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-400 empty:before:dark:text-gray-500"),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 +1 @@
1
- "use client";import{forwardRef as ue,useCallback as h,useEffect as J,useId as fe,useRef as pe,useState as _}from"react";import{createRoot as me}from"react-dom/client";import{cn as V}from"../../../lib/cn.js";import{getBaseInputClasses as ge,getIconClasses as be}from"../shared/inputStyles.js";import{InputWrapper as xe}from"../shared/InputWrapper.js";import{Chip as he}from"../../chip/Chip.js";import{jsx as l,jsxs as Y}from"react/jsx-runtime";var ve=c=>Y("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})]}),ye=ue(({label:c,inline:Z=!1,size:ee="md",labelColor:te,borderColor:I,textColor:w,disabled:u=!1,readOnly:v=!1,error:P=!1,helperText:ne,hideLabel:re=!1,icon:D,iconPosition:q="left",mentionTrigger:f="@",suggestions:C=[],onMentionSearch:z,onMentionSelect:X,onMentionRemove:$,renderSuggestion:K,value:d,onChange:p,placeholder:A,loading:oe=!1,maxSuggestions:R=10,chipVariant:W="soft",chipColor:F="primary",chipSize:Q="sm"},E)=>{let U=fe(),i=pe(null),[L,S]=_(!1),[M,k]=_(0),[Ne,B]=_(""),ae=V(ge({size:ee,error:P,disabled:u,readOnly:v,icon:D,iconPosition:q}),"min-h-[42px]","whitespace-pre-wrap","break-words"),ie={...I&&{borderColor:I},...w&&{color:w}},se=I||w?ie:void 0,m=h(()=>{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"),g=a.getAttribute("data-mention-label")||"",T=a.getAttribute("data-mention-avatar")||void 0,b=`@${g}`,N=t;n.push({trigger:f,suggestion:{id:s||"",label:g,avatar:T},startIndex:N,endIndex:N+b.length}),e+=b,t+=b.length}else a.childNodes.forEach(o)}};return i.current.childNodes.forEach(o),{text:e,mentions:n}},[f]),j=h((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",me(t).render(l(he,{label:e.label,variant:W,color:F,size:Q,closable:!u&&!v,onClose:n,disabled:u,avatar:e.avatar?l("img",{src:e.avatar,alt:e.label,className:"w-full h-full object-cover"}):void 0})),t},[W,F,Q,u,v]),y=h(e=>{if(!i.current)return;let n=i.current.querySelector(`[data-mention-id="${e}"]`);if(n){n.remove();let t=m();p?.(t);let o=d?.mentions.find(r=>r.suggestion.id===e)?.suggestion;o&&$?.(o)}},[m,p,$,d?.mentions]),le=h(()=>{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(`${f}(\\w*)$`));if(o){let a=o[1];B(a),S(!0),k(0),z?.(a)}else S(!1),B("");let r=m();p?.(r)},[f,z,p,m]),H=h(e=>{if(!i.current)return;let n=window.getSelection();if(!n||n.rangeCount===0)return;let t=n.getRangeAt(0);if(t.startContainer.nodeType===Node.TEXT_NODE){let r=t.startContainer,a=r.textContent||"",s=t.startOffset,T=a.substring(0,s).lastIndexOf(f);if(T!==-1){let b=a.substring(0,T),N=a.substring(s),x=j(e,()=>{y(e.id)});if(b?(r.textContent=b,r.parentNode?.insertBefore(x,r.nextSibling)):(r.parentNode?.insertBefore(x,r),r.textContent="",r.textContent||r.remove()),N){let de=document.createTextNode(N);x.parentNode?.insertBefore(de,x.nextSibling)}let G=document.createTextNode(" ");x.parentNode?.insertBefore(G,x.nextSibling);let O=document.createRange();O.setStartAfter(G),O.collapse(!0),n.removeAllRanges(),n.addRange(O)}}S(!1),B("");let o=m();p?.(o),X?.(e),i.current.focus()},[f,j,y,m,p,X]),ce=h(e=>{let n=C.slice(0,R);if(L&&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 g=s.getAttribute("data-mention-id");g&&y(g);return}}}}}},[L,C,M,R,H,y]);return J(()=>{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]),J(()=>{i.current&&d?.text===""&&d?.mentions.length===0&&i.current.innerHTML.trim()&&(i.current.innerHTML="")},[d?.text,d?.mentions.length]),l(xe,{label:c,hideLabel:re,labelColor:te,error:P,helperText:ne,inline:Z,htmlFor:U,children:Y("div",{className:"relative w-full",children:[D&&l("span",{className:be(q),children:D}),l("div",{ref:e=>{typeof E=="function"?E(e):E&&(E.current=e),i.current=e},id:U,contentEditable:!u&&!v,suppressContentEditableWarning:!0,onInput:le,onKeyDown:ce,className:V(ae,"empty:before:content-[attr(data-placeholder)] empty:before:text-gray-400 empty:before:dark:text-gray-500"),style:se,role:"textbox","aria-label":c,"aria-multiline":"true",tabIndex:v||u?-1:0}),L&&C.length>0&&l("div",{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:oe?l("div",{className:"px-3 py-2 text-sm text-gray-500 dark:text-gray-400",children:"Loading..."}):C.slice(0,R).map((e,n)=>l("div",{onClick:()=>H(e),className:V(n===M&&"bg-gray-100 dark:bg-gray-600"),children:K?K(e):ve(e)},e.id))})]})})});ye.displayName="MentionInput";export{ye as MentionInput};
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-400 empty:before:dark:text-gray-500"),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 +1 @@
1
- "use strict";"use client";var N=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var le=Object.getOwnPropertyNames;var ue=Object.prototype.hasOwnProperty;var ie=(s,t)=>{for(var c in t)N(s,c,{get:t[c],enumerable:!0})},ae=(s,t,c,h)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of le(t))!ue.call(s,l)&&l!==c&&N(s,l,{get:()=>t[l],enumerable:!(h=se(t,l))||h.enumerable});return s};var oe=s=>ae(N({},"__esModule",{value:!0}),s);var ce={};ie(ce,{NumberInput:()=>U});module.exports=oe(ce);var i=require("react"),B=require("../../../lib/cn.cjs"),y=require("../shared/inputStyles.cjs"),O=require("../shared/InputWrapper.cjs"),o=require("react/jsx-runtime"),U=(0,i.forwardRef)(({label:s,inline:t=!1,size:c="md",labelColor:h,borderColor:l,textColor:I,disabled:w=!1,readOnly:$=!1,error:C=!1,helperText:W,hideLabel:x=!1,icon:m,iconPosition:d="left",className:z,value:f,onChange:v,format:g="number",currency:M="USD",locale:u="en-US",decimals:a,min:E,max:F,step:pe=1,prefix:p,suffix:b,thousandSeparator:S=!0,allowNegative:K=!0,onBlur:L,onFocus:T,...G},P)=>{let H=(0,i.useId)(),[V,D]=(0,i.useState)(null),k=(0,i.useMemo)(()=>{let n=g==="currency"?{style:"currency",currency:M,minimumFractionDigits:a??2,maximumFractionDigits:a??2}:g==="percentage"?{minimumFractionDigits:a??0,maximumFractionDigits:a??2}:{minimumFractionDigits:a??0,maximumFractionDigits:a??(g==="decimal"?2:0),useGrouping:S};try{return new Intl.NumberFormat(u,n)}catch{return null}},[g,M,u,a,S]),_=n=>{if(n==null)return"";if(!k)return String(n);let e=k.format(n);return g==="percentage"?(e=p?`${p}${e}`:e,e=b||!e.includes("%")?`${e}%`:e,e):(p&&(e=`${p}${e}`),b&&(e=`${e}${b}`),e)},R=n=>{if(!n||n.trim()==="")return null;let e=n;if(p&&(e=e.replace(p,"")),b&&(e=e.replace(b,"")),e=e.replace(/[^\d.,-]/g,""),u.includes("fr")||u.includes("de")?e=e.replace(/\s/g,"").replace(",","."):e=e.replace(",",""),!e||e==="-"||e===".")return null;let r=parseFloat(e);return isNaN(r)?null:!K&&r<0?Math.abs(r):E!==void 0&&r<E?E:F!==void 0&&r>F?F:r},A=V??_(f??null),q=n=>{let e=u.includes("fr")||u.includes("de")?",":".";return new RegExp(`^-?[0-9${e===","?",":"\\."}]*$`).test(n)},J=n=>{let e=n.target.value;if(e===""||q(e)){D(e);let r=R(e);v&&v(r)}},Q=n=>{let e=u.includes("fr")||u.includes("de")?",":".",r=["Backspace","Delete","Tab","Escape","Enter","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"],ee=/^[0-9]$/.test(n.key),ne=n.key===e,te=n.key==="-"&&K&&A.indexOf("-")===-1,re=n.ctrlKey||n.metaKey;!ee&&!ne&&!te&&!r.includes(n.key)&&!re&&n.preventDefault()},X=n=>{let e=f!=null?String(f):"";D(e),T&&T(n)},Y=n=>{let e=R(V??"");v&&e!==f&&v(e),D(null),L&&L(n)},Z=(0,B.cn)((0,y.getBaseInputClasses)({size:c,error:C,disabled:w,readOnly:$,icon:m,iconPosition:d}),l&&`border-[${l}]`,I&&`text-[${I}]`,z),j=(0,o.jsxs)("div",{className:"relative",children:[m&&d==="left"&&(0,o.jsx)("div",{className:(0,y.getIconClasses)(d),children:m}),(0,o.jsx)("input",{ref:P,id:H,type:"text",inputMode:"decimal",className:Z,style:{borderColor:l,color:I},disabled:w,readOnly:$,value:A,onChange:J,onKeyDown:Q,onFocus:X,onBlur:Y,...G}),m&&d==="right"&&(0,o.jsx)("div",{className:(0,y.getIconClasses)(d),children:m})]});return(0,o.jsx)(O.InputWrapper,{label:s,hideLabel:x,labelColor:h,error:C,helperText:W,inline:t,htmlFor:H,children:j})});U.displayName="NumberInput";0&&(module.exports={NumberInput});
1
+ "use strict";"use client";var w=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var ue=Object.getOwnPropertyNames;var oe=Object.prototype.hasOwnProperty;var ce=(n,r)=>{for(var s in r)w(n,s,{get:r[s],enumerable:!0})},me=(n,r,s,I)=>{if(r&&typeof r=="object"||typeof r=="function")for(let l of ue(r))!oe.call(n,l)&&l!==s&&w(n,l,{get:()=>r[l],enumerable:!(I=le(r,l))||I.enumerable});return n};var pe=n=>me(w({},"__esModule",{value:!0}),n);var be={};ce(be,{NumberInput:()=>P});module.exports=pe(be);var a=require("react"),B=require("../../../lib/cn.cjs"),y=require("../shared/inputStyles.cjs"),O=require("../shared/InputWrapper.cjs"),o=require("react/jsx-runtime");function de(n){try{return new Intl.NumberFormat(n,{numberingSystem:"latn"}).formatToParts(1.1).find(s=>s.type==="decimal")?.value??"."}catch{return"."}}function ge(n,r){if(!Number.isFinite(n))return"";if(n===0)return"0";let s=n.toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:20});return r==="."?s:s.replace(".",r)}var fe=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),P=(0,a.forwardRef)(({label:n,inline:r=!1,size:s="md",labelColor:I,borderColor:l,textColor:E,disabled:S=!1,readOnly:C=!1,error:L=!1,helperText:W,hideLabel:G=!1,icon:p,iconPosition:d="left",className:z,value:g,onChange:F,format:f="number",currency:M="USD",locale:h="en-US",decimals:u,min:v,max:N,step:ye=1,prefix:c,suffix:b,thousandSeparator:T=!0,allowNegative:K=!0,onBlur:H,onFocus:R,id:_,...j},q)=>{let J=(0,a.useId)(),k=_||J,m=(0,a.useMemo)(()=>de(h),[h]),Q=(0,a.useMemo)(()=>new RegExp(`^-?\\d*(?:${fe(m)}\\d*)?$`),[m]),[A,$]=(0,a.useState)(null),V=(0,a.useMemo)(()=>{let t=f==="currency"?{style:"currency",currency:M,minimumFractionDigits:u??2,maximumFractionDigits:u??2}:f==="percentage"?{minimumFractionDigits:u??0,maximumFractionDigits:u??2}:{minimumFractionDigits:u??0,maximumFractionDigits:u??(f==="decimal"?2:0),useGrouping:T};try{return new Intl.NumberFormat(h,t)}catch{return null}},[f,M,h,u,T]),X=t=>{if(t==null)return"";if(!V)return String(t);let e=V.format(t);return f==="percentage"?(e=c?`${c}${e}`:e,e=b||!e.includes("%")?`${e}%`:e,e):(c&&(e=`${c}${e}`),b&&(e=`${e}${b}`),e)},x=t=>{if(!t||t.trim()==="")return null;let e=t;if(c&&(e=e.replace(c,"")),b&&(e=e.replace(b,"")),e=Array.from(e).filter(D=>/[\d-]/.test(D)||D===m).join("").replace(m,"."),!e||e==="-"||e===".")return null;let i=parseFloat(e);return isNaN(i)?null:!K&&i<0?Math.abs(i):v!==void 0&&i<v?v:N!==void 0&&i>N?N:i},U=A??X(g??null),Y=t=>Q.test(t),Z=t=>{let e=t.target.value;if(e===""||Y(e)){$(e);let i=x(e);F&&F(i)}},ee=t=>{let e=["Backspace","Delete","Tab","Escape","Enter","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"],i=/^[0-9]$/.test(t.key),D=t.key===m,ie=t.key==="-"&&K&&U.indexOf("-")===-1,ae=t.ctrlKey||t.metaKey;!i&&!D&&!ie&&!e.includes(t.key)&&!ae&&t.preventDefault()},te=t=>{$(g!=null?ge(g,m):""),R&&R(t)},ne=t=>{let e=x(A??"");F&&e!==g&&F(e),$(null),H&&H(t)},re=(0,B.cn)((0,y.getBaseInputClasses)({size:s,error:L,disabled:S,readOnly:C,icon:p,iconPosition:d}),l&&`border-[${l}]`,E&&`text-[${E}]`,z),se=(0,o.jsxs)("div",{className:"relative",children:[p&&d==="left"&&(0,o.jsx)("div",{className:(0,y.getIconClasses)(d),children:p}),(0,o.jsx)("input",{ref:q,id:k,type:"text",inputMode:"decimal",className:re,style:{borderColor:l,color:E},disabled:S,readOnly:C,value:U,onChange:Z,onKeyDown:ee,onFocus:te,onBlur:ne,...j}),p&&d==="right"&&(0,o.jsx)("div",{className:(0,y.getIconClasses)(d),children:p})]});return(0,o.jsx)(O.InputWrapper,{label:n,hideLabel:G,labelColor:I,error:L,helperText:W,inline:r,htmlFor:k,children:se})});P.displayName="NumberInput";0&&(module.exports={NumberInput});
@@ -1 +1 @@
1
- "use client";import{forwardRef as j,useId as ee,useState as ne,useMemo as te}from"react";import{cn as re}from"../../../lib/cn.js";import{getBaseInputClasses as se,getIconClasses as L}from"../shared/inputStyles.js";import{InputWrapper as le}from"../shared/InputWrapper.js";import{jsx as m,jsxs as ie}from"react/jsx-runtime";var ue=j(({label:T,inline:H=!1,size:V="md",labelColor:k,borderColor:d,textColor:f,disabled:h=!1,readOnly:v=!1,error:I=!1,helperText:R,hideLabel:A=!1,icon:u,iconPosition:i="left",className:B,value:a,onChange:p,format:o="number",currency:E="USD",locale:r="en-US",decimals:s,min:g,max:b,step:ae=1,prefix:l,suffix:c,thousandSeparator:F=!0,allowNegative:D=!0,onBlur:N,onFocus:w,...O},U)=>{let $=ee(),[C,y]=ne(null),M=te(()=>{let n=o==="currency"?{style:"currency",currency:E,minimumFractionDigits:s??2,maximumFractionDigits:s??2}:o==="percentage"?{minimumFractionDigits:s??0,maximumFractionDigits:s??2}:{minimumFractionDigits:s??0,maximumFractionDigits:s??(o==="decimal"?2:0),useGrouping:F};try{return new Intl.NumberFormat(r,n)}catch{return null}},[o,E,r,s,F]),W=n=>{if(n==null)return"";if(!M)return String(n);let e=M.format(n);return o==="percentage"?(e=l?`${l}${e}`:e,e=c||!e.includes("%")?`${e}%`:e,e):(l&&(e=`${l}${e}`),c&&(e=`${e}${c}`),e)},S=n=>{if(!n||n.trim()==="")return null;let e=n;if(l&&(e=e.replace(l,"")),c&&(e=e.replace(c,"")),e=e.replace(/[^\d.,-]/g,""),r.includes("fr")||r.includes("de")?e=e.replace(/\s/g,"").replace(",","."):e=e.replace(",",""),!e||e==="-"||e===".")return null;let t=parseFloat(e);return isNaN(t)?null:!D&&t<0?Math.abs(t):g!==void 0&&t<g?g:b!==void 0&&t>b?b:t},K=C??W(a??null),x=n=>{let e=r.includes("fr")||r.includes("de")?",":".";return new RegExp(`^-?[0-9${e===","?",":"\\."}]*$`).test(n)},z=n=>{let e=n.target.value;if(e===""||x(e)){y(e);let t=S(e);p&&p(t)}},G=n=>{let e=r.includes("fr")||r.includes("de")?",":".",t=["Backspace","Delete","Tab","Escape","Enter","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"],Q=/^[0-9]$/.test(n.key),X=n.key===e,Y=n.key==="-"&&D&&K.indexOf("-")===-1,Z=n.ctrlKey||n.metaKey;!Q&&!X&&!Y&&!t.includes(n.key)&&!Z&&n.preventDefault()},P=n=>{let e=a!=null?String(a):"";y(e),w&&w(n)},_=n=>{let e=S(C??"");p&&e!==a&&p(e),y(null),N&&N(n)},q=re(se({size:V,error:I,disabled:h,readOnly:v,icon:u,iconPosition:i}),d&&`border-[${d}]`,f&&`text-[${f}]`,B),J=ie("div",{className:"relative",children:[u&&i==="left"&&m("div",{className:L(i),children:u}),m("input",{ref:U,id:$,type:"text",inputMode:"decimal",className:q,style:{borderColor:d,color:f},disabled:h,readOnly:v,value:K,onChange:z,onKeyDown:G,onFocus:P,onBlur:_,...O}),u&&i==="right"&&m("div",{className:L(i),children:u})]});return m(le,{label:T,hideLabel:A,labelColor:k,error:I,helperText:R,inline:H,htmlFor:$,children:J})});ue.displayName="NumberInput";export{ue as NumberInput};
1
+ "use client";import{forwardRef as re,useId as se,useState as ie,useMemo as v}from"react";import{cn as ae}from"../../../lib/cn.js";import{getBaseInputClasses as le,getIconClasses as V}from"../shared/inputStyles.js";import{InputWrapper as ue}from"../shared/InputWrapper.js";import{jsx as y,jsxs as de}from"react/jsx-runtime";function oe(r){try{return new Intl.NumberFormat(r,{numberingSystem:"latn"}).formatToParts(1.1).find(i=>i.type==="decimal")?.value??"."}catch{return"."}}function ce(r,u){if(!Number.isFinite(r))return"";if(r===0)return"0";let i=r.toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:20});return u==="."?i:i.replace(".",u)}var me=r=>r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),pe=re(({label:r,inline:u=!1,size:i="md",labelColor:x,borderColor:I,textColor:F,disabled:N=!1,readOnly:$=!1,error:w=!1,helperText:U,hideLabel:B=!1,icon:o,iconPosition:c="left",className:O,value:m,onChange:g,format:p="number",currency:S="USD",locale:f="en-US",decimals:s,min:h,max:D,step:ge=1,prefix:a,suffix:d,thousandSeparator:C=!0,allowNegative:L=!0,onBlur:M,onFocus:T,id:P,...W},G)=>{let z=se(),K=P||z,l=v(()=>oe(f),[f]),_=v(()=>new RegExp(`^-?\\d*(?:${me(l)}\\d*)?$`),[l]),[H,E]=ie(null),R=v(()=>{let t=p==="currency"?{style:"currency",currency:S,minimumFractionDigits:s??2,maximumFractionDigits:s??2}:p==="percentage"?{minimumFractionDigits:s??0,maximumFractionDigits:s??2}:{minimumFractionDigits:s??0,maximumFractionDigits:s??(p==="decimal"?2:0),useGrouping:C};try{return new Intl.NumberFormat(f,t)}catch{return null}},[p,S,f,s,C]),j=t=>{if(t==null)return"";if(!R)return String(t);let e=R.format(t);return p==="percentage"?(e=a?`${a}${e}`:e,e=d||!e.includes("%")?`${e}%`:e,e):(a&&(e=`${a}${e}`),d&&(e=`${e}${d}`),e)},k=t=>{if(!t||t.trim()==="")return null;let e=t;if(a&&(e=e.replace(a,"")),d&&(e=e.replace(d,"")),e=Array.from(e).filter(b=>/[\d-]/.test(b)||b===l).join("").replace(l,"."),!e||e==="-"||e===".")return null;let n=parseFloat(e);return isNaN(n)?null:!L&&n<0?Math.abs(n):h!==void 0&&n<h?h:D!==void 0&&n>D?D:n},A=H??j(m??null),q=t=>_.test(t),J=t=>{let e=t.target.value;if(e===""||q(e)){E(e);let n=k(e);g&&g(n)}},Q=t=>{let e=["Backspace","Delete","Tab","Escape","Enter","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"],n=/^[0-9]$/.test(t.key),b=t.key===l,te=t.key==="-"&&L&&A.indexOf("-")===-1,ne=t.ctrlKey||t.metaKey;!n&&!b&&!te&&!e.includes(t.key)&&!ne&&t.preventDefault()},X=t=>{E(m!=null?ce(m,l):""),T&&T(t)},Y=t=>{let e=k(H??"");g&&e!==m&&g(e),E(null),M&&M(t)},Z=ae(le({size:i,error:w,disabled:N,readOnly:$,icon:o,iconPosition:c}),I&&`border-[${I}]`,F&&`text-[${F}]`,O),ee=de("div",{className:"relative",children:[o&&c==="left"&&y("div",{className:V(c),children:o}),y("input",{ref:G,id:K,type:"text",inputMode:"decimal",className:Z,style:{borderColor:I,color:F},disabled:N,readOnly:$,value:A,onChange:J,onKeyDown:Q,onFocus:X,onBlur:Y,...W}),o&&c==="right"&&y("div",{className:V(c),children:o})]});return y(ue,{label:r,hideLabel:B,labelColor:x,error:w,helperText:U,inline:u,htmlFor:K,children:ee})});pe.displayName="NumberInput";export{pe as NumberInput};
@@ -1 +1 @@
1
- "use strict";"use client";var J=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var ue=Object.getOwnPropertyNames;var me=Object.prototype.hasOwnProperty;var ce=(o,n)=>{for(var t in n)J(o,t,{get:n[t],enumerable:!0})},de=(o,n,t,b)=>{if(n&&typeof n=="object"||typeof n=="function")for(let g of ue(n))!me.call(o,g)&&g!==t&&J(o,g,{get:()=>n[g],enumerable:!(b=se(n,g))||b.enumerable});return o};var fe=o=>de(J({},"__esModule",{value:!0}),o);var xe={};ce(xe,{FunnelChart:()=>ye});module.exports=fe(xe);var c=require("react"),Z=require("../../lib/i18n.cjs"),ee=require("../chart/ChartAxis.cjs"),te=require("../chart/ChartContainer.cjs"),ne=require("../chart/ChartTooltip.cjs"),P=require("../chart/palette.cjs"),F=require("../chart/utils/data.cjs"),x=require("../chart/utils/format.cjs"),re=require("../chart/utils/path.cjs"),A=require("../chart/utils/scales.cjs"),W=require("../chart/utils/text.cjs"),ae=require("../table/Table.cjs"),le=require("../table/TableBody.cjs"),z=require("../table/TableCell.cjs"),oe=require("../table/TableHeader.cjs"),B=require("../table/TableHeaderCell.cjs"),ie=require("../table/TableRow.cjs"),e=require("react/jsx-runtime"),he=8,pe=12,be=44,Q="text-right [font-variant-numeric:tabular-nums]",ge=(0,c.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 ve({width:o,height:n,stages:t,x:b,size:g,align:E,showConversion:H,showValues:w,stageSize:I,ramp:M,tooltip:C,plotLabel:G,locale:k,onStageClick:S}){let[s,L]=(0,c.useState)(null),K=(0,Z.useUILabels)(),r=(0,c.useMemo)(()=>{let m=t.map(i=>i.label),d={top:6,right:12,bottom:6,left:b.hidden?8:b.height??(0,W.widestLabel)(m)+pe},h=Math.max(0,o-d.left-d.right),T=Math.max(0,n-d.top-d.bottom),f=(0,A.createBandScale)(t.map((i,l)=>l),[0,T],{paddingInner:H?.45:.28}),N=Math.min(I??be,f.bandwidth),Y=Math.max(0,...t.map(i=>i.value??0)),j=(0,A.createLinearScale)([0,Y],[0,h]),O=t.map((i,l)=>{let R=i.value===null?0:Math.max(0,j(i.value)),V=E==="center"?(h-R)/2:0,a=f(l)+(f.bandwidth-N)/2,D=a+N/2,v=null;if(w&&i.value!==null){let y=i.formattedValue;v=(0,W.estimateTextWidth)(y,11)+16<=R?{x:V+R/2,y:D,anchor:"middle",text:y,inside:!0,onDark:M.onDark(l)}:{x:V+R+he,y:D,anchor:"start",text:y,inside:!1,onDark:!1}}let X=f(l-1)+(f.bandwidth-N)/2+N,p=H&&i.conversion!==null&&l>0?{x:h/2,y:(X+a)/2,text:(0,x.formatPercent)(i.conversion,{locale:k,maximumFractionDigits:0})}:null;return{key:`${l}`,d:(0,re.buildBarPath)({x:V,y:a,width:R,height:N,radius:4,round:E==="center"?"none":"right"}),color:M(l),value:v,conversion:p,top:f(l),height:f.bandwidth}}),_=b.hidden?[]:t.map((i,l)=>({value:i.x,offset:f.center(l),label:i.label}));return{margin:d,innerWidth:h,innerHeight:T,rendered:O,stageTicks:_,centers:t.map((i,l)=>f.center(l))}},[t,b,o,n,E,H,w,I,M,k]),U=(0,c.useCallback)(m=>{if(C===!1||t.length===0)return;let d=m.currentTarget.getBoundingClientRect(),h=m.clientY-d.top-r.margin.top;L((0,A.nearestIndex)(r.centers,h))},[C,t.length,r.margin.top,r.centers]),$=(0,c.useCallback)(m=>{if(t.length===0)return;let d=t.length-1,h=s??0,T=m.key==="ArrowDown"?Math.min(d,h+1):m.key==="ArrowUp"?Math.max(0,h-1):m.key==="Home"?0:m.key==="End"?d:m.key==="Escape"?null:void 0;T!==void 0&&(m.preventDefault(),L(T))},[t.length,s]),q=(0,c.useCallback)(()=>{!S||s===null||S(t[s])},[S,s,t]),u=s===null?null:t[s];return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("svg",{width:o,height:n,role:"img","aria-label":G??t.map(m=>m.label).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:U,onPointerLeave:()=>L(null),onKeyDown:$,onBlur:()=>L(null),onClick:q,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)(ge,{stages:r.rendered})]}),(0,e.jsx)("g",{transform:`translate(${r.margin.left}, ${r.margin.top})`,children:b.hidden?null:(0,e.jsx)(ee.ChartAxis,{orientation:"left",ticks:r.stageTicks,length:r.innerHeight,showLine:!1,tickSize:0,size:g})})]}),u&&s!==null&&C!==!1?(0,e.jsx)(ne.ChartTooltip,{x:r.margin.left+r.innerWidth/2,y:r.margin.top+r.centers[s],containerWidth:o,children:typeof C=="function"?C(u):(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:u.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:u.formattedValue})]}),u.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:K.chartConversion}),(0,e.jsx)("span",{className:"[font-variant-numeric:tabular-nums]",children:(0,x.formatPercent)(u.conversion,{locale:k,maximumFractionDigits:1})})]}):null,u.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)(u.overall,{locale:k,maximumFractionDigits:1})})]}):null]})}):null]})}function ye({data:o,x:n,value:t,align:b="center",showConversion:g=!0,showValues:E=!0,stageSize:H,colors:w,height:I,width:M,size:C="md",tooltip:G=!0,tableView:k=!1,title:S,description:s,loading:L=!1,emptyState:K,error:r=!1,errorState:U,onRetry:$,actions:q,locale:u,plotLabel:m,valueLabel:d,conversionLabel:h,dropOffLabel:T,format:f,onStageClick:N,className:Y,...j}){let O=(0,Z.useUILabels)(),_=(0,c.useMemo)(()=>f??(a=>(0,x.formatAuto)(a,u)),[f,u]),i=(0,c.useMemo)(()=>n.format??(a=>(0,x.formatXValue)(a,u)),[n.format,u]),l=(0,c.useMemo)(()=>{let a=(0,F.readNumber)(o[0]??{},t);return o.map((D,v)=>{let X=(0,F.readXValue)(D,n.key,v),p=(0,F.readNumber)(D,t),y=v===0?null:(0,F.readNumber)(o[v-1],t);return{index:v,x:X,label:i(X,v),value:p,overall:v===0||a===null||a===0||p===null?null:p/a,conversion:y===null||y===0||p===null?null:p/y,dropOff:y===null||p===null?null:y-p,formattedValue:p===null?"\u2014":_(p),datum:D}})},[o,n.key,t,_,i]),R=(0,c.useMemo)(()=>(0,P.createSequentialScale)([0,Math.max(1,l.length-1)],{colors:w??P.CHART_ORDINAL_COLORS,...w?{}:{darkStops:P.CHART_ORDINAL_DARK_STOPS}}),[l.length,w]),V=I??Math.max(96,l.length*(g?56:44)+12);return(0,e.jsx)(te.ChartContainer,{title:S,description:s,height:V,width:M,size:C,loading:L,empty:l.length===0,emptyState:K,error:r,errorState:U,onRetry:$,actions:q,tableView:k,table:k?(0,e.jsx)("div",{className:"w-full overflow-x-auto",children:(0,e.jsxs)(ae.Table,{children:[typeof S=="string"?(0,e.jsx)("caption",{className:"sr-only",children:S}):null,(0,e.jsxs)(oe.TableHeader,{children:[(0,e.jsx)(B.TableHeaderCell,{children:n.label??n.key}),(0,e.jsx)(B.TableHeaderCell,{className:"text-right",children:d??O.chartValue}),(0,e.jsx)(B.TableHeaderCell,{className:"text-right",children:h??O.chartConversion}),(0,e.jsx)(B.TableHeaderCell,{className:"text-right",children:T??O.chartDropOff})]}),(0,e.jsx)(le.TableBody,{children:l.map(a=>(0,e.jsxs)(ie.TableRow,{clickable:!1,children:[(0,e.jsx)(z.TableCell,{className:"font-medium text-gray-900 dark:text-gray-100",children:a.label}),(0,e.jsx)(z.TableCell,{className:Q,children:a.formattedValue}),(0,e.jsx)(z.TableCell,{className:Q,children:a.conversion===null?"\u2014":(0,x.formatPercent)(a.conversion,{locale:u,maximumFractionDigits:1})}),(0,e.jsx)(z.TableCell,{className:Q,children:a.dropOff===null?"\u2014":_(a.dropOff)})]},a.index))})]})}):void 0,className:Y,...j,children:({width:a})=>(0,e.jsx)(ve,{width:a,height:V,stages:l,x:n,size:C,align:b,showConversion:g,showValues:E,stageSize:H,ramp:R,tooltip:G,plotLabel:m,locale:u,onStageClick:N})})}0&&(module.exports={FunnelChart});
1
+ "use strict";"use client";var Q=Object.defineProperty;var ce=Object.getOwnPropertyDescriptor;var de=Object.getOwnPropertyNames;var fe=Object.prototype.hasOwnProperty;var he=(o,n)=>{for(var t in n)Q(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&&Q(o,f,{get:()=>n[f],enumerable:!(d=ce(n,f))||d.enumerable});return o};var be=o=>pe(Q({},"__esModule",{value:!0}),o);var Te={};he(Te,{FunnelChart:()=>Se});module.exports=be(Te);var u=require("react"),ee=require("../../lib/i18n.cjs"),te=require("../chart/ChartAxis.cjs"),ne=require("../chart/ChartContainer.cjs"),re=require("../chart/ChartTooltip.cjs"),D=require("../chart/palette.cjs"),P=require("../chart/utils/data.cjs"),y=require("../chart/utils/format.cjs"),ae=require("../chart/utils/keyboard.cjs"),le=require("../chart/utils/path.cjs"),F=require("../chart/utils/scales.cjs"),U=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,Z="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:A,showConversion:E,showValues:L,stageSize:K,ramp:H,tooltip:x,plotLabel:$,locale:k,onStageClick:b}){let[O,V]=(0,u.useState)(null),i=O!==null&&O<t.length?O:null,q=(0,ee.useUILabels)(),r=(0,u.useMemo)(()=>{let p=t.map(a=>a.label),g={top:6,right:12,bottom:6,left:d.hidden?8:d.height??(0,U.widestLabel)(p)+ve},S=Math.max(0,o-g.left-g.right),M=Math.max(0,n-g.top-g.bottom),m=(0,F.createBandScale)(t.map((a,s)=>s),[0,M],{paddingInner:E?.45:.28}),N=Math.min(K??ye,m.bandwidth),j=Math.max(0,...t.map(a=>a.value??0)),I=(0,F.createLinearScale)([0,j],[0,S]),z=t.map((a,s)=>{let T=a.value===null?0:Math.max(0,I(a.value)),l=A==="center"?(S-T)/2:0,R=m(s)+(m.bandwidth-N)/2,v=R+N/2,B=null;if(L&&a.value!==null){let J=a.formattedValue;B=(0,U.estimateTextWidth)(J,11)+16<=T?{x:l+T/2,y:v,anchor:"middle",text:J,inside:!0,onDark:H.onDark(s)}:{x:l+T+ge,y:v,anchor:"start",text:J,inside:!1,onDark:!1}}let c=m(s-1)+(m.bandwidth-N)/2+N,w=E&&a.conversion!==null&&s>0?{x:S/2,y:(c+R)/2,text:(0,y.formatPercent)(a.conversion,{locale:k,maximumFractionDigits:0})}:null;return{key:`${s}`,d:(0,le.buildBarPath)({x:l,y:R,width:T,height:N,radius:4,round:A==="center"?"none":"right"}),color:H(s),value:B,conversion:w,top:m(s),height:m.bandwidth}}),G=d.hidden?[]:t.map((a,s)=>({value:a.x,offset:m.center(s),label:a.label}));return{margin:g,innerWidth:S,innerHeight:M,rendered:z,stageTicks:G,centers:t.map((a,s)=>m.center(s))}},[t,d,o,n,A,E,L,K,H,k]),Y=(0,u.useCallback)(p=>{if(x===!1||t.length===0)return;let g=p.currentTarget.getBoundingClientRect(),S=p.clientY-g.top-r.margin.top;V((0,F.nearestIndex)(r.centers,S))},[x,t.length,r.margin.top,r.centers]),_=(0,u.useCallback)(()=>{!b||i===null||b(t[i])},[b,i,t]),C=(0,u.useCallback)(p=>(0,ae.handleChartKeyDown)(p,{count:t.length,current:i,axis:"y",onMove:V,pick:b?_:null}),[t.length,i,b,_]),h=i===null?null:t[i];return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("svg",{width:o,height:n,role:"img","aria-label":$??t.map(p=>p.label).join(", "),tabIndex:0,className:`${oe.CHART_TOUCH} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500`,onPointerMove:Y,onPointerLeave:()=>V(null),onKeyDown:C,onBlur:()=>V(null),onClick:_,children:[(0,e.jsxs)("g",{transform:`translate(${r.margin.left}, ${r.margin.top})`,children:[i!==null&&r.rendered[i]?(0,e.jsx)("rect",{x:-4,y:r.rendered[i].top,width:r.innerWidth+8,height:r.rendered[i].height,rx:4,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,(0,e.jsx)(xe,{stages:r.rendered})]}),(0,e.jsx)("g",{transform:`translate(${r.margin.left}, ${r.margin.top})`,children:d.hidden?null:(0,e.jsx)(te.ChartAxis,{orientation:"left",ticks:r.stageTicks,length:r.innerHeight,showLine:!1,tickSize:0,size:f})})]}),h&&i!==null&&x!==!1?(0,e.jsx)(re.ChartTooltip,{x:r.margin.left+r.innerWidth/2,y:r.margin.top+r.centers[i],containerWidth:o,children:typeof x=="function"?x(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:r.rendered[i]?.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:q.chartConversion}),(0,e.jsx)("span",{className:"[font-variant-numeric:tabular-nums]",children:(0,y.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,y.formatPercent)(h.overall,{locale:k,maximumFractionDigits:1})})]}):null]})}):null]})}function Se({data:o,x:n,value:t,align:d="center",showConversion:f=!0,showValues:A=!0,stageSize:E,colors:L,height:K,width:H,size:x="md",tooltip:$=!0,tableView:k=!1,title:b,description:O,loading:V=!1,emptyState:i,error:q=!1,errorState:r,onRetry:Y,actions:_,locale:C,plotLabel:h,valueLabel:p,conversionLabel:g,dropOffLabel:S,format:M,onStageClick:m,className:N,...j}){let I=(0,ee.useUILabels)(),z=(0,u.useMemo)(()=>M??(l=>(0,y.formatAuto)(l,C)),[M,C]),G=(0,u.useMemo)(()=>n.format??(l=>(0,y.formatXValue)(l,C)),[n.format,C]),a=(0,u.useMemo)(()=>{let l=(0,P.readNumber)(o[0]??{},t);return o.map((R,v)=>{let B=(0,P.readXValue)(R,n.key,v),c=(0,P.readNumber)(R,t),w=v===0?null:(0,P.readNumber)(o[v-1],t);return{index:v,x:B,label:G(B,v),value:c,overall:v===0||l===null||l===0||c===null?null:c/l,conversion:w===null||w===0||c===null?null:c/w,dropOff:w===null||c===null?null:w-c,formattedValue:c===null?"\u2014":z(c),datum:R}})},[o,n.key,t,z,G]),s=(0,u.useMemo)(()=>(0,D.createSequentialScale)([0,Math.max(1,a.length-1)],{colors:L??D.CHART_ORDINAL_COLORS,...L?{}:{darkStops:D.CHART_ORDINAL_DARK_STOPS}}),[a.length,L]),T=K??Math.max(96,a.length*(f?56:44)+12);return(0,e.jsx)(ne.ChartContainer,{title:b,description:O,height:T,width:H,size:x,loading:V,empty:a.length===0,emptyState:i,error:q,errorState:r,onRetry:Y,actions:_,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??I.chartValue}),(0,e.jsx)(W.TableHeaderCell,{className:"text-right",children:g??I.chartConversion}),(0,e.jsx)(W.TableHeaderCell,{className:"text-right",children:S??I.chartDropOff})]}),(0,e.jsx)(se.TableBody,{children:a.map(l=>(0,e.jsxs)(me.TableRow,{clickable:!1,children:[(0,e.jsx)(X.TableCell,{className:"font-medium text-gray-900 dark:text-gray-100",children:l.label}),(0,e.jsx)(X.TableCell,{className:Z,children:l.formattedValue}),(0,e.jsx)(X.TableCell,{className:Z,children:l.conversion===null?"\u2014":(0,y.formatPercent)(l.conversion,{locale:C,maximumFractionDigits:1})}),(0,e.jsx)(X.TableCell,{className:Z,children:l.dropOff===null?"\u2014":z(l.dropOff)})]},l.index))})]})}):void 0,className:N,...j,children:({width:l})=>(0,e.jsx)(Ce,{width:l,height:T,stages:a,x:n,size:x,align:d,showConversion:f,showValues:A,stageSize:E,ramp:s,tooltip:$,plotLabel:h,locale:C,onStageClick:m})})}0&&(module.exports={FunnelChart});
@@ -1 +1 @@
1
- "use client";import{memo as Q,useCallback as q,useMemo as E,useState as Z}from"react";import{useUILabels as J}from"../../lib/i18n.js";import{ChartAxis as ee}from"../chart/ChartAxis.js";import{ChartContainer as te}from"../chart/ChartContainer.js";import{ChartTooltip as ne}from"../chart/ChartTooltip.js";import{CHART_ORDINAL_COLORS as re,CHART_ORDINAL_DARK_STOPS as ae,createSequentialScale as le}from"../chart/palette.js";import{readNumber as Y,readXValue as oe}from"../chart/utils/data.js";import{formatAuto as ie,formatPercent as B,formatXValue as se}from"../chart/utils/format.js";import{buildBarPath as ue}from"../chart/utils/path.js";import{createBandScale as me,createLinearScale as ce,nearestIndex as de}from"../chart/utils/scales.js";import{estimateTextWidth as fe,widestLabel as he}from"../chart/utils/text.js";import{Table as pe}from"../table/Table.js";import{TableBody as be}from"../table/TableBody.js";import{TableCell as _}from"../table/TableCell.js";import{TableHeader as ge}from"../table/TableHeader.js";import{TableHeaderCell as z}from"../table/TableHeaderCell.js";import{TableRow as ve}from"../table/TableRow.js";import{Fragment as Te,jsx as t,jsxs as h}from"react/jsx-runtime";var ye=8,xe=12,Ce=44,j="text-right [font-variant-numeric:tabular-nums]",ke=Q(function({stages:u}){return t("g",{children:u.map(e=>h("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 Se({width:p,height:u,stages:e,x:y,size:H,align:V,showConversion:D,showValues:N,stageSize:M,ramp:F,tooltip:v,plotLabel:I,locale:x,onStageClick:C}){let[o,R]=Z(null),X=J(),n=E(()=>{let s=e.map(l=>l.label),m={top:6,right:12,bottom:6,left:y.hidden?8:y.height??he(s)+xe},d=Math.max(0,p-m.left-m.right),k=Math.max(0,u-m.top-m.bottom),c=me(e.map((l,a)=>a),[0,k],{paddingInner:D?.45:.28}),S=Math.min(M??Ce,c.bandwidth),U=Math.max(0,...e.map(l=>l.value??0)),$=ce([0,U],[0,d]),P=e.map((l,a)=>{let T=l.value===null?0:Math.max(0,$(l.value)),w=V==="center"?(d-T)/2:0,r=c(a)+(c.bandwidth-S)/2,L=r+S/2,b=null;if(N&&l.value!==null){let g=l.formattedValue;b=fe(g,11)+16<=T?{x:w+T/2,y:L,anchor:"middle",text:g,inside:!0,onDark:F.onDark(a)}:{x:w+T+ye,y:L,anchor:"start",text:g,inside:!1,onDark:!1}}let O=c(a-1)+(c.bandwidth-S)/2+S,f=D&&l.conversion!==null&&a>0?{x:d/2,y:(O+r)/2,text:B(l.conversion,{locale:x,maximumFractionDigits:0})}:null;return{key:`${a}`,d:ue({x:w,y:r,width:T,height:S,radius:4,round:V==="center"?"none":"right"}),color:F(a),value:b,conversion:f,top:c(a),height:c.bandwidth}}),A=y.hidden?[]:e.map((l,a)=>({value:l.x,offset:c.center(a),label:l.label}));return{margin:m,innerWidth:d,innerHeight:k,rendered:P,stageTicks:A,centers:e.map((l,a)=>c.center(a))}},[e,y,p,u,V,D,N,M,F,x]),W=q(s=>{if(v===!1||e.length===0)return;let m=s.currentTarget.getBoundingClientRect(),d=s.clientY-m.top-n.margin.top;R(de(n.centers,d))},[v,e.length,n.margin.top,n.centers]),G=q(s=>{if(e.length===0)return;let m=e.length-1,d=o??0,k=s.key==="ArrowDown"?Math.min(m,d+1):s.key==="ArrowUp"?Math.max(0,d-1):s.key==="Home"?0:s.key==="End"?m:s.key==="Escape"?null:void 0;k!==void 0&&(s.preventDefault(),R(k))},[e.length,o]),K=q(()=>{!C||o===null||C(e[o])},[C,o,e]),i=o===null?null:e[o];return h(Te,{children:[h("svg",{width:p,height:u,role:"img","aria-label":I??e.map(s=>s.label).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:W,onPointerLeave:()=>R(null),onKeyDown:G,onBlur:()=>R(null),onClick:K,children:[h("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(ke,{stages:n.rendered})]}),t("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:y.hidden?null:t(ee,{orientation:"left",ticks:n.stageTicks,length:n.innerHeight,showLine:!1,tickSize:0,size:H})})]}),i&&o!==null&&v!==!1?t(ne,{x:n.margin.left+n.innerWidth/2,y:n.margin.top+n.centers[o],containerWidth:p,children:typeof v=="function"?v(i):h("div",{className:"flex flex-col gap-1",children:[t("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:i.label}),h("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:i.formattedValue})]}),i.conversion!==null?h("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[t("span",{children:X.chartConversion}),t("span",{className:"[font-variant-numeric:tabular-nums]",children:B(i.conversion,{locale:x,maximumFractionDigits:1})})]}):null,i.overall!==null?h("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:B(i.overall,{locale:x,maximumFractionDigits:1})})]}):null]})}):null]})}function Ge({data:p,x:u,value:e,align:y="center",showConversion:H=!0,showValues:V=!0,stageSize:D,colors:N,height:M,width:F,size:v="md",tooltip:I=!0,tableView:x=!1,title:C,description:o,loading:R=!1,emptyState:X,error:n=!1,errorState:W,onRetry:G,actions:K,locale:i,plotLabel:s,valueLabel:m,conversionLabel:d,dropOffLabel:k,format:c,onStageClick:S,className:U,...$}){let P=J(),A=E(()=>c??(r=>ie(r,i)),[c,i]),l=E(()=>u.format??(r=>se(r,i)),[u.format,i]),a=E(()=>{let r=Y(p[0]??{},e);return p.map((L,b)=>{let O=oe(L,u.key,b),f=Y(L,e),g=b===0?null:Y(p[b-1],e);return{index:b,x:O,label:l(O,b),value:f,overall:b===0||r===null||r===0||f===null?null:f/r,conversion:g===null||g===0||f===null?null:f/g,dropOff:g===null||f===null?null:g-f,formattedValue:f===null?"\u2014":A(f),datum:L}})},[p,u.key,e,A,l]),T=E(()=>le([0,Math.max(1,a.length-1)],{colors:N??re,...N?{}:{darkStops:ae}}),[a.length,N]),w=M??Math.max(96,a.length*(H?56:44)+12);return t(te,{title:C,description:o,height:w,width:F,size:v,loading:R,empty:a.length===0,emptyState:X,error:n,errorState:W,onRetry:G,actions:K,tableView:x,table:x?t("div",{className:"w-full overflow-x-auto",children:h(pe,{children:[typeof C=="string"?t("caption",{className:"sr-only",children:C}):null,h(ge,{children:[t(z,{children:u.label??u.key}),t(z,{className:"text-right",children:m??P.chartValue}),t(z,{className:"text-right",children:d??P.chartConversion}),t(z,{className:"text-right",children:k??P.chartDropOff})]}),t(be,{children:a.map(r=>h(ve,{clickable:!1,children:[t(_,{className:"font-medium text-gray-900 dark:text-gray-100",children:r.label}),t(_,{className:j,children:r.formattedValue}),t(_,{className:j,children:r.conversion===null?"\u2014":B(r.conversion,{locale:i,maximumFractionDigits:1})}),t(_,{className:j,children:r.dropOff===null?"\u2014":A(r.dropOff)})]},r.index))})]})}):void 0,className:U,...$,children:({width:r})=>t(Se,{width:r,height:w,stages:a,x:u,size:v,align:y,showConversion:H,showValues:V,stageSize:D,ramp:T,tooltip:I,plotLabel:s,locale:i,onStageClick:S})})}export{Ge as FunnelChart};
1
+ "use client";import{memo as Z,useCallback as Y,useMemo as _,useState as ee}from"react";import{useUILabels as Q}from"../../lib/i18n.js";import{ChartAxis as te}from"../chart/ChartAxis.js";import{ChartContainer as ne}from"../chart/ChartContainer.js";import{ChartTooltip as re}from"../chart/ChartTooltip.js";import{CHART_ORDINAL_COLORS as ae,CHART_ORDINAL_DARK_STOPS as le,createSequentialScale as oe}from"../chart/palette.js";import{readNumber as j,readXValue as ie}from"../chart/utils/data.js";import{formatAuto as se,formatPercent as W,formatXValue as ue}from"../chart/utils/format.js";import{handleChartKeyDown as me}from"../chart/utils/keyboard.js";import{buildBarPath as ce}from"../chart/utils/path.js";import{createBandScale as de,createLinearScale as fe,nearestIndex as he}from"../chart/utils/scales.js";import{estimateTextWidth as pe,widestLabel as be}from"../chart/utils/text.js";import{CHART_TOUCH as ge}from"../chart/utils/touch.js";import{Table as ve}from"../table/Table.js";import{TableBody as ye}from"../table/TableBody.js";import{TableCell as B}from"../table/TableCell.js";import{TableHeader as xe}from"../table/TableHeader.js";import{TableHeaderCell as X}from"../table/TableHeaderCell.js";import{TableRow as Ce}from"../table/TableRow.js";import{Fragment as we,jsx as t,jsxs as m}from"react/jsx-runtime";var Se=8,Te=12,ke=44,J="text-right [font-variant-numeric:tabular-nums]",Ne=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 Re({width:c,height:i,stages:e,x:C,size:M,align:L,showConversion:V,showValues:R,stageSize:I,ramp:P,tooltip:g,plotLabel:K,locale:S,onStageClick:h}){let[D,w]=ee(null),l=D!==null&&D<e.length?D:null,G=Q(),n=_(()=>{let f=e.map(r=>r.label),p={top:6,right:12,bottom:6,left:C.hidden?8:C.height??be(f)+Te},y=Math.max(0,c-p.left-p.right),A=Math.max(0,i-p.top-p.bottom),s=de(e.map((r,o)=>o),[0,A],{paddingInner:V?.45:.28}),T=Math.min(I??ke,s.bandwidth),$=Math.max(0,...e.map(r=>r.value??0)),E=fe([0,$],[0,y]),H=e.map((r,o)=>{let x=r.value===null?0:Math.max(0,E(r.value)),a=L==="center"?(y-x)/2:0,k=s(o)+(s.bandwidth-T)/2,b=k+T/2,O=null;if(R&&r.value!==null){let q=r.formattedValue;O=pe(q,11)+16<=x?{x:a+x/2,y:b,anchor:"middle",text:q,inside:!0,onDark:P.onDark(o)}:{x:a+x+Se,y:b,anchor:"start",text:q,inside:!1,onDark:!1}}let u=s(o-1)+(s.bandwidth-T)/2+T,N=V&&r.conversion!==null&&o>0?{x:y/2,y:(u+k)/2,text:W(r.conversion,{locale:S,maximumFractionDigits:0})}:null;return{key:`${o}`,d:ce({x:a,y:k,width:x,height:T,radius:4,round:L==="center"?"none":"right"}),color:P(o),value:O,conversion:N,top:s(o),height:s.bandwidth}}),z=C.hidden?[]:e.map((r,o)=>({value:r.x,offset:s.center(o),label:r.label}));return{margin:p,innerWidth:y,innerHeight:A,rendered:H,stageTicks:z,centers:e.map((r,o)=>s.center(o))}},[e,C,c,i,L,V,R,I,P,S]),U=Y(f=>{if(g===!1||e.length===0)return;let p=f.currentTarget.getBoundingClientRect(),y=f.clientY-p.top-n.margin.top;w(he(n.centers,y))},[g,e.length,n.margin.top,n.centers]),F=Y(()=>{!h||l===null||h(e[l])},[h,l,e]),v=Y(f=>me(f,{count:e.length,current:l,axis:"y",onMove:w,pick:h?F:null}),[e.length,l,h,F]),d=l===null?null:e[l];return m(we,{children:[m("svg",{width:c,height:i,role:"img","aria-label":K??e.map(f=>f.label).join(", "),tabIndex:0,className:`${ge} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500`,onPointerMove:U,onPointerLeave:()=>w(null),onKeyDown:v,onBlur:()=>w(null),onClick:F,children:[m("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:[l!==null&&n.rendered[l]?t("rect",{x:-4,y:n.rendered[l].top,width:n.innerWidth+8,height:n.rendered[l].height,rx:4,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,t(Ne,{stages:n.rendered})]}),t("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:C.hidden?null:t(te,{orientation:"left",ticks:n.stageTicks,length:n.innerHeight,showLine:!1,tickSize:0,size:M})})]}),d&&l!==null&&g!==!1?t(re,{x:n.margin.left+n.innerWidth/2,y:n.margin.top+n.centers[l],containerWidth:c,children:typeof g=="function"?g(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[l]?.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 Ye({data:c,x:i,value:e,align:C="center",showConversion:M=!0,showValues:L=!0,stageSize:V,colors:R,height:I,width:P,size:g="md",tooltip:K=!0,tableView:S=!1,title:h,description:D,loading:w=!1,emptyState:l,error:G=!1,errorState:n,onRetry:U,actions:F,locale:v,plotLabel:d,valueLabel:f,conversionLabel:p,dropOffLabel:y,format:A,onStageClick:s,className:T,...$}){let E=Q(),H=_(()=>A??(a=>se(a,v)),[A,v]),z=_(()=>i.format??(a=>ue(a,v)),[i.format,v]),r=_(()=>{let a=j(c[0]??{},e);return c.map((k,b)=>{let O=ie(k,i.key,b),u=j(k,e),N=b===0?null:j(c[b-1],e);return{index:b,x:O,label:z(O,b),value:u,overall:b===0||a===null||a===0||u===null?null:u/a,conversion:N===null||N===0||u===null?null:u/N,dropOff:N===null||u===null?null:N-u,formattedValue:u===null?"\u2014":H(u),datum:k}})},[c,i.key,e,H,z]),o=_(()=>oe([0,Math.max(1,r.length-1)],{colors:R??ae,...R?{}:{darkStops:le}}),[r.length,R]),x=I??Math.max(96,r.length*(M?56:44)+12);return t(ne,{title:h,description:D,height:x,width:P,size:g,loading:w,empty:r.length===0,emptyState:l,error:G,errorState:n,onRetry:U,actions:F,tableView:S,table:S?t("div",{className:"w-full overflow-x-auto",children:m(ve,{children:[typeof h=="string"?t("caption",{className:"sr-only",children:h}):null,m(xe,{children:[t(X,{children:i.label??i.key}),t(X,{className:"text-right",children:f??E.chartValue}),t(X,{className:"text-right",children:p??E.chartConversion}),t(X,{className:"text-right",children:y??E.chartDropOff})]}),t(ye,{children:r.map(a=>m(Ce,{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:v,maximumFractionDigits:1})}),t(B,{className:J,children:a.dropOff===null?"\u2014":H(a.dropOff)})]},a.index))})]})}):void 0,className:T,...$,children:({width:a})=>t(Re,{width:a,height:x,stages:r,x:i,size:g,align:C,showConversion:M,showValues:L,stageSize:V,ramp:o,tooltip:K,plotLabel:d,locale:v,onStageClick:s})})}export{Ye as FunnelChart};
@@ -1 +1 @@
1
- "use strict";"use client";var ut=Object.defineProperty;var Et=Object.getOwnPropertyDescriptor;var Ot=Object.getOwnPropertyNames;var It=Object.prototype.hasOwnProperty;var Ht=(m,o)=>{for(var y in o)ut(m,y,{get:o[y],enumerable:!0})},Wt=(m,o,y,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let g of Ot(o))!It.call(m,g)&&g!==y&&ut(m,g,{get:()=>o[g],enumerable:!(r=Et(o,g))||r.enumerable});return m};var Xt=m=>Wt(ut({},"__esModule",{value:!0}),m);var Ut={};Ht(Ut,{GanttChart:()=>Kt});module.exports=Xt(Ut);var c=require("react"),pt=require("../../lib/i18n.cjs"),dt=require("../chart/ChartAxis.cjs"),vt=require("../chart/ChartContainer.cjs"),wt=require("../chart/ChartGrid.cjs"),Nt=require("../chart/ChartLegend.cjs"),St=require("../chart/ChartTooltip.cjs"),tt=require("../chart/palette.cjs"),$t=require("../chart/utils/cartesian.cjs"),et=require("../chart/utils/data.cjs"),U=require("../chart/utils/format.cjs"),ht=require("../chart/utils/path.cjs"),Lt=require("../chart/utils/scales.cjs"),x=require("../chart/utils/time.cjs"),Pt=require("../table/Table.cjs"),Rt=require("../table/TableBody.cjs"),B=require("../table/TableCell.cjs"),Mt=require("../table/TableHeader.cjs"),K=require("../table/TableHeaderCell.cjs"),Gt=require("../table/TableRow.cjs"),t=require("react/jsx-runtime"),Vt=18,kt=.5,zt=.3,Q=7,Tt=10,xt=.02,gt="text-right [font-variant-numeric:tabular-nums]",_t=(0,c.memo)(function({tasks:o,arrows:y}){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:y.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 Bt({width:m,height:o,data:y,tasks:r,x:g,domain:w,unit:G,timeTicks:E,today:L,grid:O,size:I,barSize:W,colorOf:Y,margin:F,tooltip:P,plotLabel:rt,todayLabel:nt,locale:R,formatDate:Z,formatX:D,onTaskClick:X}){let[d,M]=(0,c.useState)(null),V=(0,pt.useUILabels)(),n=(0,c.useMemo)(()=>{let l=(0,$t.buildCartesianGeometry)({width:m,height:o,data:y,x:g,y:{domain:w},bounds:w,margin:F,orientation:"horizontal",placement:"band",formatValue:a=>(0,x.formatTimeTick)(a,G,R),formatX:D}),{valueScale:f,bandwidth:i,categoryPositions:C,innerWidth:it,innerHeight:st}=l,A=Math.min(W??Vt,i),ct=new Map(r.map((a,u)=>[a.id,u])),j=r.map((a,u)=>{let N=C[u]+(i-A)/2,s=N+A/2,b=Y(a);if(a.start===null)return{key:`${u}`,color:b,track:null,trackOpacity:1,progress:null,milestone:null,top:C[u],height:i};let k=f(a.start);if(a.milestone)return{key:`${u}`,color:b,track:null,trackOpacity:1,progress:null,milestone:`M${k},${s-Q} L${k+Q},${s} L${k},${s+Q} L${k-Q},${s} Z`,top:C[u],height:i};let S=f(a.end??a.start),T=Math.max(2,S-k);return{key:`${u}`,color:b,track:(0,ht.buildBarPath)({x:k,y:N,width:T,height:A,radius:3}),trackOpacity:a.progress===null?1:zt,progress:a.progress===null?null:(0,ht.buildBarPath)({x:k,y:s-A*kt/2,width:Math.max(0,T*Math.min(1,Math.max(0,a.progress))),height:A*kt,radius:2,round:"right"}),milestone:null,top:C[u],height:i}}),q=[];r.forEach((a,u)=>{if(a.start!==null)for(let N of a.dependsOn){let s=ct.get(N);if(s===void 0||s===u)continue;let b=r[s];if(b.start===null)continue;let k=f(b.end??b.start),S=C[s]+i/2,T=f(a.start),$=C[u]+i/2,J=Math.max(k+Tt,T-Tt);q.push({key:`${N}-${a.id}`,d:`M${k},${S} L${J},${S} L${J},${$} L${T-5},${$}`,head:`M${T},${$} L${T-5},${$-3.5} L${T-5},${$+3.5} Z`})}});let mt=E.map(a=>({value:a,offset:f(a),label:(0,x.formatTimeTick)(a,G,R)}));return{rendered:j,arrows:q,categoryPositions:C,categoryCenters:l.categoryCenters,bandwidth:i,categoryTicks:l.categoryTicks,valueTicks:mt,valueScale:f,innerWidth:it,innerHeight:st,margin:l.margin}},[r,y,g,w,G,E,m,o,F,W,Y,R,D]),at=(0,c.useCallback)(l=>{if(P===!1||r.length===0)return;let f=l.currentTarget.getBoundingClientRect(),i=l.clientY-f.top-n.margin.top;M((0,Lt.nearestIndex)(n.categoryCenters,i))},[P,r.length,n.margin.top,n.categoryCenters]),ot=(0,c.useCallback)(l=>{if(r.length===0)return;let f=r.length-1,i=d??0,C=l.key==="ArrowDown"?Math.min(f,i+1):l.key==="ArrowUp"?Math.max(0,i-1):l.key==="Home"?0:l.key==="End"?f:l.key==="Escape"?null:void 0;C!==void 0&&(l.preventDefault(),M(C))},[r.length,d]),lt=(0,c.useCallback)(()=>{!X||d===null||X(r[d])},[X,d,r]),h=d===null?null:r[d];return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("svg",{width:m,height:o,role:"img","aria-label":rt??r.map(l=>l.label).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:at,onPointerLeave:()=>M(null),onKeyDown:ot,onBlur:()=>M(null),onClick:lt,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:O?n.valueTicks.map(l=>l.offset):void 0}),d!==null?(0,t.jsx)("rect",{x:0,y:n.categoryPositions[d],width:n.innerWidth,height:n.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,(0,t.jsx)(_t,{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:nt})]}):null]}),(0,t.jsx)("g",{transform:`translate(${n.margin.left}, ${n.margin.top+n.innerHeight})`,children:(0,t.jsx)(dt.ChartAxis,{orientation:"bottom",ticks:n.valueTicks,length:n.innerWidth,size:I})}),(0,t.jsx)("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:g.hidden?null:(0,t.jsx)(dt.ChartAxis,{orientation:"left",ticks:n.categoryTicks,length:n.innerHeight,showLine:!1,tickSize:0,label:g.label,size:I})})]}),h&&d!==null&&P!==!1?(0,t.jsx)(St.ChartTooltip,{x:n.margin.left+(h.start===null?n.innerWidth/2:n.valueScale(h.start)),y:n.margin.top+n.categoryCenters[d],containerWidth:m,children:typeof P=="function"?P(h):(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:h.label}),(0,t.jsxs)("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[(0,t.jsx)("span",{children:V.chartStart}),(0,t.jsx)("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:h.start===null?"\u2014":Z(h.start)})]}),h.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:V.chartEnd}),(0,t.jsx)("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:h.end===null?"\u2014":Z(h.end)})]}),h.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:V.chartProgress}),(0,t.jsx)("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:(0,U.formatPercent)(h.progress,{locale:R,maximumFractionDigits:0})})]})]})}):null]})}function Kt({data:m,x:o,start:y,end:r,id:g,progress:w,milestone:G,dependencies:E,group:L,domain:O,today:I,ticks:W=6,barSize:Y,rowSize:F=30,color:P,height:rt,width:nt,size:R="md",grid:Z=!0,legend:D,tooltip:X=!0,tableView:d=!1,title:M,description:V,loading:n=!1,emptyState:at,error:ot=!1,errorState:lt,onRetry:h,actions:l,margin:f,locale:i,plotLabel:C,startLabel:it,endLabel:st,progressLabel:A,todayLabel:ct,formatDate:j,onTaskClick:q,className:mt,...a}){let u=(0,pt.useUILabels)(),N=(0,c.useMemo)(()=>o.format??(e=>(0,U.formatXValue)(e,i)),[o.format,i]),s=(0,c.useMemo)(()=>m.map((e,p)=>{let z=(0,et.readXValue)(e,o.key,p),H=(0,x.toTimestamp)(e[y]),v=r?(0,x.toTimestamp)(e[r]):null,_=G?!!e[G]:v===null,Ct=E?e[E]:void 0;return{index:p,id:String(g?e[g]??p:p),x:z,label:N(z,p),start:H,end:_?H:v??H,progress:w?(0,et.readNumber)(e,w):null,milestone:_,dependsOn:Array.isArray(Ct)?Ct.map(At=>String(At)):[],group:L?e[L]??null:null,datum:e}}),[m,o.key,y,r,g,w,G,E,L,N]),b=(0,c.useMemo)(()=>{let e=[];for(let p of s)p.group!==null&&!e.includes(p.group)&&e.push(p.group);return e},[s]),k=(0,c.useCallback)(e=>e.group===null?P??(0,tt.getSeriesColor)(0):(0,tt.getSeriesColor)(b.indexOf(e.group)),[b,P]),S=(0,c.useMemo)(()=>{if(O){let v=(0,x.toTimestamp)(O[0]),_=(0,x.toTimestamp)(O[1]);if(v!==null&&_!==null)return[v,_]}let e=s.flatMap(v=>v.start===null?[]:[v.start,v.end??v.start]);if(e.length===0)return[0,1];let p=Math.min(...e),z=Math.max(...e),H=z-p||864e5;return[p-H*xt,z+H*xt]},[O,s]),T=(0,c.useMemo)(()=>(0,x.niceTimeTicks)(S[0],S[1],W),[S,W]),$=(0,c.useMemo)(()=>j??(e=>new Intl.DateTimeFormat(i,{day:"numeric",month:"short",year:"numeric"}).format(new Date(e))),[j,i]),J=(0,c.useMemo)(()=>I===!1?null:(0,x.toTimestamp)(I??Date.now()),[I]),ft=(0,c.useMemo)(()=>b.map((e,p)=>({key:e,label:e,color:(0,tt.getSeriesColor)(p),marker:"rect"})),[b]),bt=rt??Math.max(120,s.length*F+48),Dt=D===void 0?b.length>=2:D!==!1,yt=typeof D=="string"?D:"bottom";return(0,t.jsx)(vt.ChartContainer,{title:M,description:V,height:bt,width:nt,size:R,loading:n,empty:s.length===0,emptyState:at,error:ot,errorState:lt,onRetry:h,actions:l,tableView:d,legendPosition:yt,legend:Dt&&ft.length>0?(0,t.jsx)(Nt.ChartLegend,{items:ft,position:yt,marker:"rect",size:R}):void 0,table:d?(0,t.jsx)("div",{className:"w-full overflow-x-auto",children:(0,t.jsxs)(Pt.Table,{children:[typeof M=="string"?(0,t.jsx)("caption",{className:"sr-only",children:M}):null,(0,t.jsxs)(Mt.TableHeader,{children:[(0,t.jsx)(K.TableHeaderCell,{children:o.label??o.key}),(0,t.jsx)(K.TableHeaderCell,{className:"text-right",children:it??u.chartStart}),(0,t.jsx)(K.TableHeaderCell,{className:"text-right",children:st??u.chartEnd}),w?(0,t.jsx)(K.TableHeaderCell,{className:"text-right",children:A??u.chartProgress}):null]}),(0,t.jsx)(Rt.TableBody,{children:s.map(e=>(0,t.jsxs)(Gt.TableRow,{clickable:!1,children:[(0,t.jsx)(B.TableCell,{className:"font-medium text-gray-900 dark:text-gray-100",children:e.label}),(0,t.jsx)(B.TableCell,{className:gt,children:e.start===null?"\u2014":$(e.start)}),(0,t.jsx)(B.TableCell,{className:gt,children:e.milestone||e.end===null?"\u2014":$(e.end)}),w?(0,t.jsx)(B.TableCell,{className:gt,children:e.progress===null?"\u2014":(0,U.formatPercent)(e.progress,{locale:i,maximumFractionDigits:0})}):null]},e.index))})]})}):void 0,className:mt,...a,children:({width:e})=>(0,t.jsx)(Bt,{width:e,height:bt,data:m,tasks:s,x:o,domain:S,unit:T.unit,timeTicks:T.values,today:J,grid:Z,size:R,barSize:Y,colorOf:k,margin:f,tooltip:X,plotLabel:C,todayLabel:ct??u.chartToday,locale:i,formatDate:$,formatX:N,onTaskClick:q})})}0&&(module.exports={GanttChart});
1
+ "use strict";"use client";var gt=Object.defineProperty;var Et=Object.getOwnPropertyDescriptor;var Ht=Object.getOwnPropertyNames;var Wt=Object.prototype.hasOwnProperty;var Xt=(i,o)=>{for(var y in o)gt(i,y,{get:o[y],enumerable:!0})},Vt=(i,o,y,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let d of Ht(o))!Wt.call(i,d)&&d!==y&&gt(i,d,{get:()=>o[d],enumerable:!(r=Et(o,d))||r.enumerable});return i};var zt=i=>Vt(gt({},"__esModule",{value:!0}),i);var Ft={};Xt(Ft,{GanttChart:()=>Yt});module.exports=zt(Ft);var l=require("react"),ft=require("../../lib/i18n.cjs"),ht=require("../chart/ChartAxis.cjs"),xt=require("../chart/ChartContainer.cjs"),Nt=require("../chart/ChartGrid.cjs"),wt=require("../chart/ChartLegend.cjs"),St=require("../chart/ChartTooltip.cjs"),rt=require("../chart/palette.cjs"),$t=require("../chart/utils/cartesian.cjs"),nt=require("../chart/utils/data.cjs"),Z=require("../chart/utils/format.cjs"),Lt=require("../chart/utils/keyboard.cjs"),pt=require("../chart/utils/path.cjs"),Pt=require("../chart/utils/scales.cjs"),k=require("../chart/utils/time.cjs"),Rt=require("../chart/utils/touch.cjs"),Gt=require("../table/Table.cjs"),Mt=require("../table/TableBody.cjs"),Y=require("../table/TableCell.cjs"),Dt=require("../table/TableHeader.cjs"),F=require("../table/TableHeaderCell.cjs"),Ot=require("../table/TableRow.cjs"),t=require("react/jsx-runtime"),_t=18,Tt=.5,Bt=.3,et=7,kt=10,vt=.02,dt="text-right [font-variant-numeric:tabular-nums]",Kt=(0,l.memo)(function({tasks:o,arrows:y}){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:y.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 Ut({width:i,height:o,data:y,tasks:r,x:d,domain:x,unit:R,timeTicks:I,today:S,grid:E,size:H,barSize:V,colorOf:j,margin:q,tooltip:$,plotLabel:at,todayLabel:ot,locale:L,formatDate:J,formatX:G,onTaskClick:M}){let[W,P]=(0,l.useState)(null),b=W!==null&&W<r.length?W:null,z=(0,ft.useUILabels)(),n=(0,l.useMemo)(()=>{let c=(0,$t.buildCartesianGeometry)({width:i,height:o,data:y,x:d,y:{domain:x},bounds:x,margin:q,orientation:"horizontal",placement:"band",formatValue:a=>(0,k.formatTimeTick)(a,R,L),formatX:G}),{valueScale:u,bandwidth:C,categoryPositions:N,innerWidth:st,innerHeight:mt}=c,D=Math.min(V??_t,C),Q=new Map(r.map((a,s)=>[a.id,s])),ct=r.map((a,s)=>{let p=N[s]+(C-D)/2,m=p+D/2,w=j(a);if(a.start===null)return{key:`${s}`,color:w,track:null,trackOpacity:1,progress:null,milestone:null,top:N[s],height:C};let g=u(a.start);if(a.milestone)return{key:`${s}`,color:w,track:null,trackOpacity:1,progress:null,milestone:`M${g},${m-et} L${g+et},${m} L${g},${m+et} L${g-et},${m} Z`,top:N[s],height:C};let O=u(a.end??a.start),T=Math.max(2,O-g);return{key:`${s}`,color:w,track:(0,pt.buildBarPath)({x:g,y:p,width:T,height:D,radius:3}),trackOpacity:a.progress===null?1:Bt,progress:a.progress===null?null:(0,pt.buildBarPath)({x:g,y:m-D*Tt/2,width:Math.max(0,T*Math.min(1,Math.max(0,a.progress))),height:D*Tt,radius:2,round:"right"}),milestone:null,top:N[s],height:C}}),tt=[];r.forEach((a,s)=>{if(a.start!==null)for(let p of a.dependsOn){let m=Q.get(p);if(m===void 0||m===s)continue;let w=r[m];if(w.start===null)continue;let g=u(w.end??w.start),O=N[m]+C/2,T=u(a.start),A=N[s]+C/2,B=Math.max(g+kt,T-kt);tt.push({key:`${p}-${a.id}`,d:`M${g},${O} L${B},${O} L${B},${A} L${T-5},${A}`,head:`M${T},${A} L${T-5},${A-3.5} L${T-5},${A+3.5} Z`})}});let ut=I.map(a=>({value:a,offset:u(a),label:(0,k.formatTimeTick)(a,R,L)}));return{rendered:ct,arrows:tt,categoryPositions:N,categoryCenters:c.categoryCenters,bandwidth:C,categoryTicks:c.categoryTicks,valueTicks:ut,valueScale:u,innerWidth:st,innerHeight:mt,margin:c.margin}},[r,y,d,x,R,I,i,o,q,V,j,L,G]),lt=(0,l.useCallback)(c=>{if($===!1||r.length===0)return;let u=c.currentTarget.getBoundingClientRect(),C=c.clientY-u.top-n.margin.top;P((0,Pt.nearestIndex)(n.categoryCenters,C))},[$,r.length,n.margin.top,n.categoryCenters]),_=(0,l.useCallback)(()=>{!M||b===null||M(r[b])},[M,b,r]),it=(0,l.useCallback)(c=>(0,Lt.handleChartKeyDown)(c,{count:r.length,current:b,axis:"y",onMove:P,pick:M?_:null}),[r.length,b,M,_]),h=b===null?null:r[b];return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("svg",{width:i,height:o,role:"img","aria-label":at??r.map(c=>c.label).join(", "),tabIndex:0,className:`${Rt.CHART_TOUCH} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500`,onPointerMove:lt,onPointerLeave:()=>P(null),onKeyDown:it,onBlur:()=>P(null),onClick:_,children:[(0,t.jsxs)("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:[(0,t.jsx)(Nt.ChartGrid,{width:n.innerWidth,height:n.innerHeight,vertical:E?n.valueTicks.map(c=>c.offset):void 0}),b!==null?(0,t.jsx)("rect",{x:0,y:n.categoryPositions[b],width:n.innerWidth,height:n.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,(0,t.jsx)(Kt,{tasks:n.rendered,arrows:n.arrows}),S!==null?(0,t.jsxs)("g",{children:[(0,t.jsx)("line",{x1:n.valueScale(S),y1:0,x2:n.valueScale(S),y2:n.innerHeight,className:"stroke-gray-900 dark:stroke-white",strokeWidth:1,strokeDasharray:"4 4"}),(0,t.jsx)("text",{x:n.valueScale(S)+4,y:8,className:"fill-gray-500 text-[10px] dark:fill-gray-400",children:ot})]}):null]}),(0,t.jsx)("g",{transform:`translate(${n.margin.left}, ${n.margin.top+n.innerHeight})`,children:(0,t.jsx)(ht.ChartAxis,{orientation:"bottom",ticks:n.valueTicks,length:n.innerWidth,size:H})}),(0,t.jsx)("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:d.hidden?null:(0,t.jsx)(ht.ChartAxis,{orientation:"left",ticks:n.categoryTicks,length:n.innerHeight,showLine:!1,tickSize:0,label:d.label,size:H})})]}),h&&b!==null&&$!==!1?(0,t.jsx)(St.ChartTooltip,{x:n.margin.left+(h.start===null?n.innerWidth/2:n.valueScale(h.start)),y:n.margin.top+n.categoryCenters[b],containerWidth:i,children:typeof $=="function"?$(h):(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:h.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:h.start===null?"\u2014":J(h.start)})]}),h.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:h.end===null?"\u2014":J(h.end)})]}),h.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)(h.progress,{locale:L,maximumFractionDigits:0})})]})]})}):null]})}function Yt({data:i,x:o,start:y,end:r,id:d,progress:x,milestone:R,dependencies:I,group:S,domain:E,today:H,ticks:V=6,barSize:j,rowSize:q=30,color:$,height:at,width:ot,size:L="md",grid:J=!0,legend:G,tooltip:M=!0,tableView:W=!1,title:P,description:b,loading:z=!1,emptyState:n,error:lt=!1,errorState:_,onRetry:it,actions:h,margin:c,locale:u,plotLabel:C,startLabel:N,endLabel:st,progressLabel:mt,todayLabel:D,formatDate:Q,onTaskClick:ct,className:tt,...ut}){let a=(0,ft.useUILabels)(),s=(0,l.useMemo)(()=>o.format??(e=>(0,Z.formatXValue)(e,u)),[o.format,u]),p=(0,l.useMemo)(()=>i.map((e,f)=>{let K=(0,nt.readXValue)(e,o.key,f),X=(0,k.toTimestamp)(e[y]),v=r?(0,k.toTimestamp)(e[r]):null,U=R?!!e[R]:v===null,Ct=I?e[I]:void 0;return{index:f,id:String(d?e[d]??f:f),x:K,label:s(K,f),start:X,end:U?X:v??X,progress:x?(0,nt.readNumber)(e,x):null,milestone:U,dependsOn:Array.isArray(Ct)?Ct.map(It=>String(It)):[],group:S?e[S]??null:null,datum:e}}),[i,o.key,y,r,d,x,R,I,S,s]),m=(0,l.useMemo)(()=>{let e=[];for(let f of p)f.group!==null&&!e.includes(f.group)&&e.push(f.group);return e},[p]),w=(0,l.useCallback)(e=>e.group===null?$??(0,rt.getSeriesColor)(0):(0,rt.getSeriesColor)(m.indexOf(e.group)),[m,$]),g=(0,l.useMemo)(()=>{if(E){let v=(0,k.toTimestamp)(E[0]),U=(0,k.toTimestamp)(E[1]);if(v!==null&&U!==null)return[v,U]}let e=p.flatMap(v=>v.start===null?[]:[v.start,v.end??v.start]);if(e.length===0)return[0,1];let f=Math.min(...e),K=Math.max(...e),X=K-f||864e5;return[f-X*vt,K+X*vt]},[E,p]),O=(0,l.useMemo)(()=>(0,k.niceTimeTicks)(g[0],g[1],V),[g,V]),T=(0,l.useMemo)(()=>Q??(e=>new Intl.DateTimeFormat(u,{day:"numeric",month:"short",year:"numeric"}).format(new Date(e))),[Q,u]),A=(0,l.useMemo)(()=>H===!1?null:(0,k.toTimestamp)(H??Date.now()),[H]),B=(0,l.useMemo)(()=>m.map((e,f)=>({key:e,label:e,color:(0,rt.getSeriesColor)(f),marker:"rect"})),[m]),bt=at??Math.max(120,p.length*q+48),At=G===void 0?m.length>=2:G!==!1,yt=typeof G=="string"?G:"bottom";return(0,t.jsx)(xt.ChartContainer,{title:P,description:b,height:bt,width:ot,size:L,loading:z,empty:p.length===0,emptyState:n,error:lt,errorState:_,onRetry:it,actions:h,tableView:W,legendPosition:yt,legend:At&&B.length>0?(0,t.jsx)(wt.ChartLegend,{items:B,position:yt,marker:"rect",size:L}):void 0,table:W?(0,t.jsx)("div",{className:"w-full overflow-x-auto",children:(0,t.jsxs)(Gt.Table,{children:[typeof P=="string"?(0,t.jsx)("caption",{className:"sr-only",children:P}):null,(0,t.jsxs)(Dt.TableHeader,{children:[(0,t.jsx)(F.TableHeaderCell,{children:o.label??o.key}),(0,t.jsx)(F.TableHeaderCell,{className:"text-right",children:N??a.chartStart}),(0,t.jsx)(F.TableHeaderCell,{className:"text-right",children:st??a.chartEnd}),x?(0,t.jsx)(F.TableHeaderCell,{className:"text-right",children:mt??a.chartProgress}):null]}),(0,t.jsx)(Mt.TableBody,{children:p.map(e=>(0,t.jsxs)(Ot.TableRow,{clickable:!1,children:[(0,t.jsx)(Y.TableCell,{className:"font-medium text-gray-900 dark:text-gray-100",children:e.label}),(0,t.jsx)(Y.TableCell,{className:dt,children:e.start===null?"\u2014":T(e.start)}),(0,t.jsx)(Y.TableCell,{className:dt,children:e.milestone||e.end===null?"\u2014":T(e.end)}),x?(0,t.jsx)(Y.TableCell,{className:dt,children:e.progress===null?"\u2014":(0,Z.formatPercent)(e.progress,{locale:u,maximumFractionDigits:0})}):null]},e.index))})]})}):void 0,className:tt,...ut,children:({width:e})=>(0,t.jsx)(Ut,{width:e,height:bt,data:i,tasks:p,x:o,domain:g,unit:O.unit,timeTicks:O.values,today:A,grid:J,size:L,barSize:j,colorOf:w,margin:c,tooltip:M,plotLabel:C,todayLabel:D??a.chartToday,locale:u,formatDate:T,formatX:s,onTaskClick:ct})})}0&&(module.exports={GanttChart});
@@ -1 +1 @@
1
- "use client";import{memo as St,useCallback as tt,useMemo as N,useState as $t}from"react";import{useUILabels as xt}from"../../lib/i18n.js";import{ChartAxis as ft}from"../chart/ChartAxis.js";import{ChartContainer as Lt}from"../chart/ChartContainer.js";import{ChartGrid as Pt}from"../chart/ChartGrid.js";import{ChartLegend as Rt}from"../chart/ChartLegend.js";import{ChartTooltip as Mt}from"../chart/ChartTooltip.js";import{getSeriesColor as mt}from"../chart/palette.js";import{buildCartesianGeometry as Gt}from"../chart/utils/cartesian.js";import{readNumber as Dt,readXValue as At}from"../chart/utils/data.js";import{formatPercent as vt,formatXValue as Et}from"../chart/utils/format.js";import{buildBarPath as bt}from"../chart/utils/path.js";import{nearestIndex as Ot}from"../chart/utils/scales.js";import{formatTimeTick as yt,niceTimeTicks as It,toTimestamp as B}from"../chart/utils/time.js";import{Table as Ht}from"../table/Table.js";import{TableBody as Wt}from"../table/TableBody.js";import{TableCell as q}from"../table/TableCell.js";import{TableHeader as Xt}from"../table/TableHeader.js";import{TableHeaderCell as J}from"../table/TableHeaderCell.js";import{TableRow as Vt}from"../table/TableRow.js";import{Fragment as Ut,jsx as e,jsxs as g}from"react/jsx-runtime";var zt=18,Ct=.5,_t=.3,Q=7,kt=10,Tt=.02,ut="text-right [font-variant-numeric:tabular-nums]",Bt=St(function({tasks:d,arrows:M}){return g("g",{children:[e("g",{className:"fill-gray-400 stroke-gray-400 dark:fill-gray-500 dark:stroke-gray-500",children:M.map(r=>g("g",{children:[e("path",{d:r.d,fill:"none",strokeWidth:1}),e("path",{d:r.head,strokeWidth:0})]},r.key))}),d.map(r=>g("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 Kt({width:k,height:d,data:M,tasks:r,x:S,domain:T,unit:G,timeTicks:E,today:$,grid:O,size:I,barSize:W,colorOf:K,margin:U,tooltip:L,plotLabel:et,todayLabel:rt,locale:P,formatDate:Y,formatX:D,onTaskClick:X}){let[c,R]=$t(null),V=xt(),n=N(()=>{let o=Gt({width:k,height:d,data:M,x:S,y:{domain:T},bounds:T,margin:U,orientation:"horizontal",placement:"band",formatValue:a=>yt(a,G,P),formatX:D}),{valueScale:h,bandwidth:l,categoryPositions:f,innerWidth:lt,innerHeight:it}=o,A=Math.min(W??zt,l),st=new Map(r.map((a,s)=>[a.id,s])),F=r.map((a,s)=>{let x=f[s]+(l-A)/2,i=x+A/2,p=K(a);if(a.start===null)return{key:`${s}`,color:p,track:null,trackOpacity:1,progress:null,milestone:null,top:f[s],height:l};let b=h(a.start);if(a.milestone)return{key:`${s}`,color:p,track:null,trackOpacity:1,progress:null,milestone:`M${b},${i-Q} L${b+Q},${i} L${b},${i+Q} L${b-Q},${i} Z`,top:f[s],height:l};let v=h(a.end??a.start),y=Math.max(2,v-b);return{key:`${s}`,color:p,track:bt({x:b,y:x,width:y,height:A,radius:3}),trackOpacity:a.progress===null?1:_t,progress:a.progress===null?null:bt({x:b,y:i-A*Ct/2,width:Math.max(0,y*Math.min(1,Math.max(0,a.progress))),height:A*Ct,radius:2,round:"right"}),milestone:null,top:f[s],height:l}}),Z=[];r.forEach((a,s)=>{if(a.start!==null)for(let x of a.dependsOn){let i=st.get(x);if(i===void 0||i===s)continue;let p=r[i];if(p.start===null)continue;let b=h(p.end??p.start),v=f[i]+l/2,y=h(a.start),w=f[s]+l/2,j=Math.max(b+kt,y-kt);Z.push({key:`${x}-${a.id}`,d:`M${b},${v} L${j},${v} L${j},${w} L${y-5},${w}`,head:`M${y},${w} L${y-5},${w-3.5} L${y-5},${w+3.5} Z`})}});let ct=E.map(a=>({value:a,offset:h(a),label:yt(a,G,P)}));return{rendered:F,arrows:Z,categoryPositions:f,categoryCenters:o.categoryCenters,bandwidth:l,categoryTicks:o.categoryTicks,valueTicks:ct,valueScale:h,innerWidth:lt,innerHeight:it,margin:o.margin}},[r,M,S,T,G,E,k,d,U,W,K,P,D]),nt=tt(o=>{if(L===!1||r.length===0)return;let h=o.currentTarget.getBoundingClientRect(),l=o.clientY-h.top-n.margin.top;R(Ot(n.categoryCenters,l))},[L,r.length,n.margin.top,n.categoryCenters]),at=tt(o=>{if(r.length===0)return;let h=r.length-1,l=c??0,f=o.key==="ArrowDown"?Math.min(h,l+1):o.key==="ArrowUp"?Math.max(0,l-1):o.key==="Home"?0:o.key==="End"?h:o.key==="Escape"?null:void 0;f!==void 0&&(o.preventDefault(),R(f))},[r.length,c]),ot=tt(()=>{!X||c===null||X(r[c])},[X,c,r]),m=c===null?null:r[c];return g(Ut,{children:[g("svg",{width:k,height:d,role:"img","aria-label":et??r.map(o=>o.label).join(", "),tabIndex:0,className:"touch-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500",onPointerMove:nt,onPointerLeave:()=>R(null),onKeyDown:at,onBlur:()=>R(null),onClick:ot,children:[g("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:[e(Pt,{width:n.innerWidth,height:n.innerHeight,vertical:O?n.valueTicks.map(o=>o.offset):void 0}),c!==null?e("rect",{x:0,y:n.categoryPositions[c],width:n.innerWidth,height:n.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,e(Bt,{tasks:n.rendered,arrows:n.arrows}),$!==null?g("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:rt})]}):null]}),e("g",{transform:`translate(${n.margin.left}, ${n.margin.top+n.innerHeight})`,children:e(ft,{orientation:"bottom",ticks:n.valueTicks,length:n.innerWidth,size:I})}),e("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:S.hidden?null:e(ft,{orientation:"left",ticks:n.categoryTicks,length:n.innerHeight,showLine:!1,tickSize:0,label:S.label,size:I})})]}),m&&c!==null&&L!==!1?e(Mt,{x:n.margin.left+(m.start===null?n.innerWidth/2:n.valueScale(m.start)),y:n.margin.top+n.categoryCenters[c],containerWidth:k,children:typeof L=="function"?L(m):g("div",{className:"flex flex-col gap-1",children:[e("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:m.label}),g("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e("span",{children:V.chartStart}),e("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:m.start===null?"\u2014":Y(m.start)})]}),m.milestone?null:g("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e("span",{children:V.chartEnd}),e("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:m.end===null?"\u2014":Y(m.end)})]}),m.progress===null?null:g("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e("span",{children:V.chartProgress}),e("span",{className:"[font-variant-numeric:tabular-nums] text-gray-900 dark:text-gray-100",children:vt(m.progress,{locale:P,maximumFractionDigits:0})})]})]})}):null]})}function de({data:k,x:d,start:M,end:r,id:S,progress:T,milestone:G,dependencies:E,group:$,domain:O,today:I,ticks:W=6,barSize:K,rowSize:U=30,color:L,height:et,width:rt,size:P="md",grid:Y=!0,legend:D,tooltip:X=!0,tableView:c=!1,title:R,description:V,loading:n=!1,emptyState:nt,error:at=!1,errorState:ot,onRetry:m,actions:o,margin:h,locale:l,plotLabel:f,startLabel:lt,endLabel:it,progressLabel:A,todayLabel:st,formatDate:F,onTaskClick:Z,className:ct,...a}){let s=xt(),x=N(()=>d.format??(t=>Et(t,l)),[d.format,l]),i=N(()=>k.map((t,u)=>{let z=At(t,d.key,u),H=B(t[M]),C=r?B(t[r]):null,_=G?!!t[G]:C===null,pt=E?t[E]:void 0;return{index:u,id:String(S?t[S]??u:u),x:z,label:x(z,u),start:H,end:_?H:C??H,progress:T?Dt(t,T):null,milestone:_,dependsOn:Array.isArray(pt)?pt.map(Nt=>String(Nt)):[],group:$?t[$]??null:null,datum:t}}),[k,d.key,M,r,S,T,G,E,$,x]),p=N(()=>{let t=[];for(let u of i)u.group!==null&&!t.includes(u.group)&&t.push(u.group);return t},[i]),b=tt(t=>t.group===null?L??mt(0):mt(p.indexOf(t.group)),[p,L]),v=N(()=>{if(O){let C=B(O[0]),_=B(O[1]);if(C!==null&&_!==null)return[C,_]}let t=i.flatMap(C=>C.start===null?[]:[C.start,C.end??C.start]);if(t.length===0)return[0,1];let u=Math.min(...t),z=Math.max(...t),H=z-u||864e5;return[u-H*Tt,z+H*Tt]},[O,i]),y=N(()=>It(v[0],v[1],W),[v,W]),w=N(()=>F??(t=>new Intl.DateTimeFormat(l,{day:"numeric",month:"short",year:"numeric"}).format(new Date(t))),[F,l]),j=N(()=>I===!1?null:B(I??Date.now()),[I]),gt=N(()=>p.map((t,u)=>({key:t,label:t,color:mt(u),marker:"rect"})),[p]),dt=et??Math.max(120,i.length*U+48),wt=D===void 0?p.length>=2:D!==!1,ht=typeof D=="string"?D:"bottom";return e(Lt,{title:R,description:V,height:dt,width:rt,size:P,loading:n,empty:i.length===0,emptyState:nt,error:at,errorState:ot,onRetry:m,actions:o,tableView:c,legendPosition:ht,legend:wt&&gt.length>0?e(Rt,{items:gt,position:ht,marker:"rect",size:P}):void 0,table:c?e("div",{className:"w-full overflow-x-auto",children:g(Ht,{children:[typeof R=="string"?e("caption",{className:"sr-only",children:R}):null,g(Xt,{children:[e(J,{children:d.label??d.key}),e(J,{className:"text-right",children:lt??s.chartStart}),e(J,{className:"text-right",children:it??s.chartEnd}),T?e(J,{className:"text-right",children:A??s.chartProgress}):null]}),e(Wt,{children:i.map(t=>g(Vt,{clickable:!1,children:[e(q,{className:"font-medium text-gray-900 dark:text-gray-100",children:t.label}),e(q,{className:ut,children:t.start===null?"\u2014":w(t.start)}),e(q,{className:ut,children:t.milestone||t.end===null?"\u2014":w(t.end)}),T?e(q,{className:ut,children:t.progress===null?"\u2014":vt(t.progress,{locale:l,maximumFractionDigits:0})}):null]},t.index))})]})}):void 0,className:ct,...a,children:({width:t})=>e(Kt,{width:t,height:dt,data:k,tasks:i,x:d,domain:v,unit:y.unit,timeTicks:y.values,today:j,grid:Y,size:P,barSize:K,colorOf:b,margin:h,tooltip:X,plotLabel:f,todayLabel:st??s.chartToday,locale:l,formatDate:w,formatX:x,onTaskClick:Z})})}export{de as GanttChart};
1
+ "use client";import{memo as St,useCallback as rt,useMemo as x,useState as $t}from"react";import{useUILabels as vt}from"../../lib/i18n.js";import{ChartAxis as ft}from"../chart/ChartAxis.js";import{ChartContainer as Lt}from"../chart/ChartContainer.js";import{ChartGrid as Pt}from"../chart/ChartGrid.js";import{ChartLegend as Rt}from"../chart/ChartLegend.js";import{ChartTooltip as Gt}from"../chart/ChartTooltip.js";import{getSeriesColor as ut}from"../chart/palette.js";import{buildCartesianGeometry as Mt}from"../chart/utils/cartesian.js";import{readNumber as Dt,readXValue as Ot}from"../chart/utils/data.js";import{formatPercent as xt,formatXValue as At}from"../chart/utils/format.js";import{handleChartKeyDown as It}from"../chart/utils/keyboard.js";import{buildBarPath as bt}from"../chart/utils/path.js";import{nearestIndex as Et}from"../chart/utils/scales.js";import{formatTimeTick as yt,niceTimeTicks as Ht,toTimestamp as Y}from"../chart/utils/time.js";import{CHART_TOUCH as Wt}from"../chart/utils/touch.js";import{Table as Xt}from"../table/Table.js";import{TableBody as Vt}from"../table/TableBody.js";import{TableCell as Q}from"../table/TableCell.js";import{TableHeader as zt}from"../table/TableHeader.js";import{TableHeaderCell as tt}from"../table/TableHeaderCell.js";import{TableRow as _t}from"../table/TableRow.js";import{Fragment as Ft,jsx as e,jsxs as d}from"react/jsx-runtime";var Bt=18,Ct=.5,Kt=.3,et=7,Tt=10,kt=.02,gt="text-right [font-variant-numeric:tabular-nums]",Ut=St(function({tasks:h,arrows:P}){return d("g",{children:[e("g",{className:"fill-gray-400 stroke-gray-400 dark:fill-gray-500 dark:stroke-gray-500",children:P.map(r=>d("g",{children:[e("path",{d:r.d,fill:"none",strokeWidth:1}),e("path",{d:r.head,strokeWidth:0})]},r.key))}),h.map(r=>d("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 Yt({width:C,height:h,data:P,tasks:r,x:N,domain:T,unit:R,timeTicks:I,today:w,grid:E,size:H,barSize:V,colorOf:F,margin:Z,tooltip:S,plotLabel:nt,todayLabel:at,locale:$,formatDate:j,formatX:G,onTaskClick:M}){let[W,L]=$t(null),p=W!==null&&W<r.length?W:null,z=vt(),n=x(()=>{let i=Mt({width:C,height:h,data:P,x:N,y:{domain:T},bounds:T,margin:Z,orientation:"horizontal",placement:"band",formatValue:a=>yt(a,R,$),formatX:G}),{valueScale:s,bandwidth:f,categoryPositions:k,innerWidth:it,innerHeight:st}=i,D=Math.min(V??Bt,f),q=new Map(r.map((a,o)=>[a.id,o])),mt=r.map((a,o)=>{let u=k[o]+(f-D)/2,l=u+D/2,v=F(a);if(a.start===null)return{key:`${o}`,color:v,track:null,trackOpacity:1,progress:null,milestone:null,top:k[o],height:f};let m=s(a.start);if(a.milestone)return{key:`${o}`,color:v,track:null,trackOpacity:1,progress:null,milestone:`M${m},${l-et} L${m+et},${l} L${m},${l+et} L${m-et},${l} Z`,top:k[o],height:f};let O=s(a.end??a.start),b=Math.max(2,O-m);return{key:`${o}`,color:v,track:bt({x:m,y:u,width:b,height:D,radius:3}),trackOpacity:a.progress===null?1:Kt,progress:a.progress===null?null:bt({x:m,y:l-D*Ct/2,width:Math.max(0,b*Math.min(1,Math.max(0,a.progress))),height:D*Ct,radius:2,round:"right"}),milestone:null,top:k[o],height:f}}),J=[];r.forEach((a,o)=>{if(a.start!==null)for(let u of a.dependsOn){let l=q.get(u);if(l===void 0||l===o)continue;let v=r[l];if(v.start===null)continue;let m=s(v.end??v.start),O=k[l]+f/2,b=s(a.start),A=k[o]+f/2,B=Math.max(m+Tt,b-Tt);J.push({key:`${u}-${a.id}`,d:`M${m},${O} L${B},${O} L${B},${A} L${b-5},${A}`,head:`M${b},${A} L${b-5},${A-3.5} L${b-5},${A+3.5} Z`})}});let ct=I.map(a=>({value:a,offset:s(a),label:yt(a,R,$)}));return{rendered:mt,arrows:J,categoryPositions:k,categoryCenters:i.categoryCenters,bandwidth:f,categoryTicks:i.categoryTicks,valueTicks:ct,valueScale:s,innerWidth:it,innerHeight:st,margin:i.margin}},[r,P,N,T,R,I,C,h,Z,V,F,$,G]),ot=rt(i=>{if(S===!1||r.length===0)return;let s=i.currentTarget.getBoundingClientRect(),f=i.clientY-s.top-n.margin.top;L(Et(n.categoryCenters,f))},[S,r.length,n.margin.top,n.categoryCenters]),_=rt(()=>{!M||p===null||M(r[p])},[M,p,r]),lt=rt(i=>It(i,{count:r.length,current:p,axis:"y",onMove:L,pick:M?_:null}),[r.length,p,M,_]),c=p===null?null:r[p];return d(Ft,{children:[d("svg",{width:C,height:h,role:"img","aria-label":nt??r.map(i=>i.label).join(", "),tabIndex:0,className:`${Wt} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500`,onPointerMove:ot,onPointerLeave:()=>L(null),onKeyDown:lt,onBlur:()=>L(null),onClick:_,children:[d("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:[e(Pt,{width:n.innerWidth,height:n.innerHeight,vertical:E?n.valueTicks.map(i=>i.offset):void 0}),p!==null?e("rect",{x:0,y:n.categoryPositions[p],width:n.innerWidth,height:n.bandwidth,className:"fill-gray-400 dark:fill-gray-500",opacity:.12,"aria-hidden":"true"}):null,e(Ut,{tasks:n.rendered,arrows:n.arrows}),w!==null?d("g",{children:[e("line",{x1:n.valueScale(w),y1:0,x2:n.valueScale(w),y2:n.innerHeight,className:"stroke-gray-900 dark:stroke-white",strokeWidth:1,strokeDasharray:"4 4"}),e("text",{x:n.valueScale(w)+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(ft,{orientation:"bottom",ticks:n.valueTicks,length:n.innerWidth,size:H})}),e("g",{transform:`translate(${n.margin.left}, ${n.margin.top})`,children:N.hidden?null:e(ft,{orientation:"left",ticks:n.categoryTicks,length:n.innerHeight,showLine:!1,tickSize:0,label:N.label,size:H})})]}),c&&p!==null&&S!==!1?e(Gt,{x:n.margin.left+(c.start===null?n.innerWidth/2:n.valueScale(c.start)),y:n.margin.top+n.categoryCenters[p],containerWidth:C,children:typeof S=="function"?S(c):d("div",{className:"flex flex-col gap-1",children:[e("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:c.label}),d("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:c.start===null?"\u2014":j(c.start)})]}),c.milestone?null:d("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:c.end===null?"\u2014":j(c.end)})]}),c.progress===null?null:d("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:xt(c.progress,{locale:$,maximumFractionDigits:0})})]})]})}):null]})}function be({data:C,x:h,start:P,end:r,id:N,progress:T,milestone:R,dependencies:I,group:w,domain:E,today:H,ticks:V=6,barSize:F,rowSize:Z=30,color:S,height:nt,width:at,size:$="md",grid:j=!0,legend:G,tooltip:M=!0,tableView:W=!1,title:L,description:p,loading:z=!1,emptyState:n,error:ot=!1,errorState:_,onRetry:lt,actions:c,margin:i,locale:s,plotLabel:f,startLabel:k,endLabel:it,progressLabel:st,todayLabel:D,formatDate:q,onTaskClick:mt,className:J,...ct}){let a=vt(),o=x(()=>h.format??(t=>At(t,s)),[h.format,s]),u=x(()=>C.map((t,g)=>{let K=Ot(t,h.key,g),X=Y(t[P]),y=r?Y(t[r]):null,U=R?!!t[R]:y===null,pt=I?t[I]:void 0;return{index:g,id:String(N?t[N]??g:g),x:K,label:o(K,g),start:X,end:U?X:y??X,progress:T?Dt(t,T):null,milestone:U,dependsOn:Array.isArray(pt)?pt.map(wt=>String(wt)):[],group:w?t[w]??null:null,datum:t}}),[C,h.key,P,r,N,T,R,I,w,o]),l=x(()=>{let t=[];for(let g of u)g.group!==null&&!t.includes(g.group)&&t.push(g.group);return t},[u]),v=rt(t=>t.group===null?S??ut(0):ut(l.indexOf(t.group)),[l,S]),m=x(()=>{if(E){let y=Y(E[0]),U=Y(E[1]);if(y!==null&&U!==null)return[y,U]}let t=u.flatMap(y=>y.start===null?[]:[y.start,y.end??y.start]);if(t.length===0)return[0,1];let g=Math.min(...t),K=Math.max(...t),X=K-g||864e5;return[g-X*kt,K+X*kt]},[E,u]),O=x(()=>Ht(m[0],m[1],V),[m,V]),b=x(()=>q??(t=>new Intl.DateTimeFormat(s,{day:"numeric",month:"short",year:"numeric"}).format(new Date(t))),[q,s]),A=x(()=>H===!1?null:Y(H??Date.now()),[H]),B=x(()=>l.map((t,g)=>({key:t,label:t,color:ut(g),marker:"rect"})),[l]),dt=nt??Math.max(120,u.length*Z+48),Nt=G===void 0?l.length>=2:G!==!1,ht=typeof G=="string"?G:"bottom";return e(Lt,{title:L,description:p,height:dt,width:at,size:$,loading:z,empty:u.length===0,emptyState:n,error:ot,errorState:_,onRetry:lt,actions:c,tableView:W,legendPosition:ht,legend:Nt&&B.length>0?e(Rt,{items:B,position:ht,marker:"rect",size:$}):void 0,table:W?e("div",{className:"w-full overflow-x-auto",children:d(Xt,{children:[typeof L=="string"?e("caption",{className:"sr-only",children:L}):null,d(zt,{children:[e(tt,{children:h.label??h.key}),e(tt,{className:"text-right",children:k??a.chartStart}),e(tt,{className:"text-right",children:it??a.chartEnd}),T?e(tt,{className:"text-right",children:st??a.chartProgress}):null]}),e(Vt,{children:u.map(t=>d(_t,{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":b(t.start)}),e(Q,{className:gt,children:t.milestone||t.end===null?"\u2014":b(t.end)}),T?e(Q,{className:gt,children:t.progress===null?"\u2014":xt(t.progress,{locale:s,maximumFractionDigits:0})}):null]},t.index))})]})}):void 0,className:J,...ct,children:({width:t})=>e(Yt,{width:t,height:dt,data:C,tasks:u,x:h,domain:m,unit:O.unit,timeTicks:O.values,today:A,grid:j,size:$,barSize:F,colorOf:v,margin:i,tooltip:M,plotLabel:f,todayLabel:D??a.chartToday,locale:s,formatDate:b,formatX:o,onTaskClick:mt})})}export{be as GanttChart};
@@ -1 +1 @@
1
- "use strict";"use client";var y=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var $=Object.prototype.hasOwnProperty;var ee=(o,a)=>{for(var i in a)y(o,i,{get:a[i],enumerable:!0})},re=(o,a,i,d)=>{if(a&&typeof a=="object"||typeof a=="function")for(let l of Z(a))!$.call(o,l)&&l!==i&&y(o,l,{get:()=>a[l],enumerable:!(d=Y(a,l))||d.enumerable});return o};var ae=o=>re(y({},"__esModule",{value:!0}),o);var ne={};ee(ne,{Header:()=>te});module.exports=ae(ne);var f=require("react"),s=require("../../lib/cn.cjs"),e=require("react/jsx-runtime");function te({logo:o,logoHref:a="/",onLogoClick:i,navItems:d=[],actions:l,rightContent:p,variant:t="default",size:b="md",backgroundColor:g,textColor:S,hoverColor:B,navItemTextColor:R,navItemHoverColor:j,navItemBgHover:D,navItemActiveColor:O,sticky:T=!1,fixed:W=!1,showSearch:k=!1,onSearch:N,searchPlaceholder:u="Search...",className:z,containerClassName:Q}){let[x,_]=(0,f.useState)(!1),[w,q]=(0,f.useState)(null),[m,C]=(0,f.useState)(""),A=()=>{_(!x)},E=r=>{q(w===r?null:r)},L=r=>{r.preventDefault(),N&&N(m)},F=(0,s.cn)(T&&"sticky top-0 z-50",W&&"fixed top-0 left-0 right-0 z-50"),G=(0,s.cn)(t==="default"&&!g&&"bg-neutral text-white",t==="transparent"&&!g&&"bg-transparent",t==="bordered"&&!g&&"bg-white border-b border-gray-200 text-gray-900 dark:bg-gray-900 dark:border-gray-800 dark:text-gray-100",t==="shadow"&&!g&&"bg-white shadow-md text-gray-900 dark:bg-gray-900 dark:text-gray-100"),J=(0,s.cn)(b==="sm"&&"py-2",b==="md"&&"py-4",b==="lg"&&"py-6"),K=g||"",P=S||"",U=B||"",V=(0,s.cn)(F,G,J,K,P,z),M=(r,c,h=!1)=>{let X=r.children&&r.children.length>0,H=w===c,v=(0,s.cn)("px-4 py-2 transition-colors flex items-center gap-2",h?"block w-full text-left":"inline-flex",r.active&&"font-semibold border-b-2",r.active&&(O||"border-current"),R||(t==="default"||t==="transparent"?"text-gray-300":"text-gray-600 dark:text-gray-300"),j||U||(t==="default"||t==="transparent"?"hover:text-white":"hover:text-blue-600 dark:hover:text-blue-400"),D||"");if(X)return(0,e.jsxs)("div",{className:h?"w-full":"relative",children:[(0,e.jsxs)("button",{type:"button",onClick:()=>E(c),className:v,children:[r.icon&&(0,e.jsx)("span",{className:"w-5 h-5",children:r.icon}),(0,e.jsx)("span",{children:r.label}),r.badge&&(0,e.jsx)("span",{className:"bg-red-500 text-white text-xs px-2 py-0.5 rounded-full",children:r.badge}),(0,e.jsx)("svg",{className:(0,s.cn)("w-4 h-4 transition-transform",H&&"rotate-180"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),H&&(0,e.jsx)("div",{className:(0,s.cn)("bg-white shadow-lg rounded-lg overflow-hidden dark:bg-gray-800 dark:shadow-black/40",h?"mt-2 mb-2":"absolute top-full left-0 mt-1 min-w-[200px]"),children:r.children?.map(n=>(0,e.jsx)("a",{href:n.href,onClick:n.onClick,target:n.external?"_blank":void 0,rel:n.external?"noopener noreferrer":void 0,className:"block px-4 py-2 text-gray-700 hover:bg-gray-100 transition-colors dark:text-gray-200 dark:hover:bg-gray-700",children:(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[n.icon&&(0,e.jsx)("span",{className:"w-5 h-5",children:n.icon}),(0,e.jsx)("span",{children:n.label}),n.badge&&(0,e.jsx)("span",{className:"bg-red-500 text-white text-xs px-2 py-0.5 rounded-full ml-auto",children:n.badge}),n.external&&(0,e.jsx)("svg",{className:"w-4 h-4 ml-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})},n.href??n.label))})]},r.href??r.label);let I=(0,e.jsxs)(e.Fragment,{children:[r.icon&&(0,e.jsx)("span",{className:"w-5 h-5",children:r.icon}),(0,e.jsx)("span",{children:r.label}),r.badge&&(0,e.jsx)("span",{className:"bg-red-500 text-white text-xs px-2 py-0.5 rounded-full",children:r.badge}),r.external&&(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]});return r.onClick?(0,e.jsx)("button",{type:"button",onClick:r.onClick,className:v,children:I},r.href??r.label):(0,e.jsx)("a",{href:r.href,target:r.external?"_blank":void 0,rel:r.external?"noopener noreferrer":void 0,className:v,children:I},r.href??r.label)};return(0,e.jsxs)("header",{className:V,children:[(0,e.jsxs)("nav",{className:(0,s.cn)("container mx-auto flex items-center justify-between px-4",Q),children:[o&&(0,e.jsx)("div",{className:"flex items-center",children:a?(0,e.jsx)("a",{href:a,onClick:i,className:"flex items-center hover:opacity-80 transition-opacity",children:o}):(0,e.jsx)("div",{className:"flex items-center",children:o})}),k&&(0,e.jsx)("form",{onSubmit:L,className:"hidden md:flex flex-1 max-w-md mx-8",children:(0,e.jsx)("input",{type:"search","aria-label":u,value:m,onChange:r=>C(r.target.value),placeholder:u,className:"w-full px-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 text-gray-900 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-500"})}),(0,e.jsx)("div",{className:"hidden md:flex items-center gap-2",children:d.map((r,c)=>M(r,c,!1))}),(l||p)&&(0,e.jsxs)("div",{className:"hidden md:flex items-center gap-2 ml-4",children:[l,p]}),d.length>0&&(0,e.jsx)("div",{className:"md:hidden",children:(0,e.jsx)("button",{type:"button",className:(0,s.cn)("inline-flex rounded-lg border-2 p-2 w-10 h-10 justify-center transition-colors focus:outline-none",t==="default"||t==="transparent"?"text-gray-300 hover:text-white":"text-gray-600 hover:text-gray-900 dark:text-gray-300 dark:hover:text-gray-100"),onClick:A,"aria-label":"Toggle menu","aria-expanded":x,children:(0,e.jsx)("svg",{className:"w-5 h-5","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 14",children:(0,e.jsx)("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M1 1h15M1 7h15M1 13h15"})})})})]}),x&&d.length>0&&(0,e.jsx)("div",{className:(0,s.cn)("md:hidden border-t animate-in slide-in-from-top duration-300",t==="default"||t==="transparent"?"border-gray-700":"border-gray-200 dark:border-gray-800"),children:(0,e.jsxs)("div",{className:"flex flex-col py-2 px-4",children:[k&&(0,e.jsx)("form",{onSubmit:L,className:"mb-4",children:(0,e.jsx)("input",{type:"search","aria-label":u,value:m,onChange:r=>C(r.target.value),placeholder:u,className:"w-full px-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 text-gray-900 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-500"})}),d.map((r,c)=>M(r,c,!0)),(l||p)&&(0,e.jsxs)("div",{className:"flex flex-col gap-2 mt-4 pt-4 border-t border-gray-700",children:[l,p]})]})})]})}0&&(module.exports={Header});
1
+ "use strict";"use client";var y=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var ae=Object.getOwnPropertyNames;var te=Object.prototype.hasOwnProperty;var ne=(o,a)=>{for(var c in a)y(o,c,{get:a[c],enumerable:!0})},oe=(o,a,c,d)=>{if(a&&typeof a=="object"||typeof a=="function")for(let l of ae(a))!te.call(o,l)&&l!==c&&y(o,l,{get:()=>a[l],enumerable:!(d=re(a,l))||d.enumerable});return o};var se=o=>oe(y({},"__esModule",{value:!0}),o);var de={};ne(de,{Header:()=>le});module.exports=se(de);var b=require("react"),s=require("../../lib/cn.cjs"),B=require("../../lib/i18n.cjs"),e=require("react/jsx-runtime");function le({logo:o,logoHref:a="/",onLogoClick:c,navItems:d=[],actions:l,rightContent:p,variant:t="default",size:f="md",backgroundColor:g,textColor:P,hoverColor:R,navItemTextColor:j,navItemHoverColor:D,navItemBgHover:O,navItemActiveColor:T,sticky:W=!1,fixed:z=!1,showSearch:k=!1,onSearch:N,searchPlaceholder:Q,menuLabel:_,className:q,containerClassName:A}){let w=(0,B.useUILabels)(),u=Q??w.headerSearchPlaceholder,[h,E]=(0,b.useState)(!1),[C,F]=(0,b.useState)(null),[m,L]=(0,b.useState)(""),U=()=>{E(!h)},G=r=>{F(C===r?null:r)},M=r=>{r.preventDefault(),N&&N(m)},J=(0,s.cn)(W&&"sticky top-0 z-50",z&&"fixed top-0 left-0 right-0 z-50"),K=(0,s.cn)(t==="default"&&!g&&"bg-gray-900 text-white",t==="transparent"&&!g&&"bg-transparent",t==="bordered"&&!g&&"bg-white border-b border-gray-200 text-gray-900 dark:bg-gray-900 dark:border-gray-800 dark:text-gray-100",t==="shadow"&&!g&&"bg-white shadow-md text-gray-900 dark:bg-gray-900 dark:text-gray-100"),V=(0,s.cn)(f==="sm"&&"py-2",f==="md"&&"py-4",f==="lg"&&"py-6"),X=g||"",Y=P||"",Z=R||"",$=(0,s.cn)(J,K,V,X,Y,q),I=(r,i,x=!1)=>{let ee=r.children&&r.children.length>0,H=C===i,v=(0,s.cn)("px-4 py-2 transition-colors flex items-center gap-2",x?"block w-full text-left":"inline-flex",r.active&&"font-semibold border-b-2",r.active&&(T||"border-current"),j||(t==="default"||t==="transparent"?"text-gray-300":"text-gray-600 dark:text-gray-300"),D||Z||(t==="default"||t==="transparent"?"hover:text-white":"hover:text-blue-600 dark:hover:text-blue-400"),O||"");if(ee)return(0,e.jsxs)("div",{className:x?"w-full":"relative",children:[(0,e.jsxs)("button",{type:"button",onClick:()=>G(i),className:v,children:[r.icon&&(0,e.jsx)("span",{className:"w-5 h-5",children:r.icon}),(0,e.jsx)("span",{children:r.label}),r.badge&&(0,e.jsx)("span",{className:"bg-red-500 text-white text-xs px-2 py-0.5 rounded-full",children:r.badge}),(0,e.jsx)("svg",{className:(0,s.cn)("w-4 h-4 transition-transform",H&&"rotate-180"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),H&&(0,e.jsx)("div",{className:(0,s.cn)("bg-white shadow-lg rounded-lg overflow-hidden dark:bg-gray-800 dark:shadow-black/40",x?"mt-2 mb-2":"absolute top-full left-0 mt-1 min-w-[200px]"),children:r.children?.map(n=>(0,e.jsx)("a",{href:n.href,onClick:n.onClick,target:n.external?"_blank":void 0,rel:n.external?"noopener noreferrer":void 0,className:"block px-4 py-2 text-gray-700 hover:bg-gray-100 transition-colors dark:text-gray-200 dark:hover:bg-gray-700",children:(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[n.icon&&(0,e.jsx)("span",{className:"w-5 h-5",children:n.icon}),(0,e.jsx)("span",{children:n.label}),n.badge&&(0,e.jsx)("span",{className:"bg-red-500 text-white text-xs px-2 py-0.5 rounded-full ml-auto",children:n.badge}),n.external&&(0,e.jsx)("svg",{className:"w-4 h-4 ml-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})},n.href??n.label))})]},r.href??r.label);let S=(0,e.jsxs)(e.Fragment,{children:[r.icon&&(0,e.jsx)("span",{className:"w-5 h-5",children:r.icon}),(0,e.jsx)("span",{children:r.label}),r.badge&&(0,e.jsx)("span",{className:"bg-red-500 text-white text-xs px-2 py-0.5 rounded-full",children:r.badge}),r.external&&(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]});return r.onClick?(0,e.jsx)("button",{type:"button",onClick:r.onClick,className:v,children:S},r.href??r.label):(0,e.jsx)("a",{href:r.href,target:r.external?"_blank":void 0,rel:r.external?"noopener noreferrer":void 0,className:v,children:S},r.href??r.label)};return(0,e.jsxs)("header",{className:$,children:[(0,e.jsxs)("nav",{className:(0,s.cn)("container mx-auto flex items-center justify-between px-4",A),children:[o&&(0,e.jsx)("div",{className:"flex items-center",children:a?(0,e.jsx)("a",{href:a,onClick:c,className:"flex items-center hover:opacity-80 transition-opacity",children:o}):(0,e.jsx)("div",{className:"flex items-center",children:o})}),k&&(0,e.jsx)("form",{onSubmit:M,className:"hidden md:flex flex-1 max-w-md mx-8",children:(0,e.jsx)("input",{type:"search","aria-label":u,value:m,onChange:r=>L(r.target.value),placeholder:u,className:"w-full px-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 text-gray-900 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-500"})}),(0,e.jsx)("div",{className:"hidden md:flex items-center gap-2",children:d.map((r,i)=>I(r,i,!1))}),(l||p)&&(0,e.jsxs)("div",{className:"hidden md:flex items-center gap-2 ml-4",children:[l,p]}),d.length>0&&(0,e.jsx)("div",{className:"md:hidden",children:(0,e.jsx)("button",{type:"button",className:(0,s.cn)("inline-flex rounded-lg border-2 p-2 w-10 h-10 justify-center transition-colors focus:outline-none",t==="default"||t==="transparent"?"text-gray-300 hover:text-white":"text-gray-600 hover:text-gray-900 dark:text-gray-300 dark:hover:text-gray-100"),onClick:U,"aria-label":_??w.headerToggleMenu,"aria-expanded":h,children:(0,e.jsx)("svg",{className:"w-5 h-5","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 14",children:(0,e.jsx)("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M1 1h15M1 7h15M1 13h15"})})})})]}),h&&d.length>0&&(0,e.jsx)("div",{className:(0,s.cn)("md:hidden border-t animate-in slide-in-from-top duration-300",t==="default"||t==="transparent"?"border-gray-700":"border-gray-200 dark:border-gray-800"),children:(0,e.jsxs)("div",{className:"flex flex-col py-2 px-4",children:[k&&(0,e.jsx)("form",{onSubmit:M,className:"mb-4",children:(0,e.jsx)("input",{type:"search","aria-label":u,value:m,onChange:r=>L(r.target.value),placeholder:u,className:"w-full px-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 text-gray-900 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-500"})}),d.map((r,i)=>I(r,i,!0)),(l||p)&&(0,e.jsxs)("div",{className:"flex flex-col gap-2 mt-4 pt-4 border-t border-gray-700",children:[l,p]})]})})]})}0&&(module.exports={Header});
@@ -1 +1 @@
1
- "use client";import{useState as h}from"react";import{cn as n}from"../../lib/cn.js";import{Fragment as Y,jsx as r,jsxs as o}from"react/jsx-runtime";function ee({logo:p,logoHref:v="/",onLogoClick:I,navItems:d=[],actions:i,rightContent:c,variant:a="default",size:u="md",backgroundColor:l,textColor:S,hoverColor:B,navItemTextColor:R,navItemHoverColor:j,navItemBgHover:D,navItemActiveColor:O,sticky:T=!1,fixed:W=!1,showSearch:y=!1,onSearch:k,searchPlaceholder:g="Search...",className:z,containerClassName:Q}){let[f,_]=h(!1),[N,q]=h(null),[b,w]=h(""),A=()=>{_(!f)},E=e=>{q(N===e?null:e)},C=e=>{e.preventDefault(),k&&k(b)},F=n(T&&"sticky top-0 z-50",W&&"fixed top-0 left-0 right-0 z-50"),G=n(a==="default"&&!l&&"bg-neutral text-white",a==="transparent"&&!l&&"bg-transparent",a==="bordered"&&!l&&"bg-white border-b border-gray-200 text-gray-900 dark:bg-gray-900 dark:border-gray-800 dark:text-gray-100",a==="shadow"&&!l&&"bg-white shadow-md text-gray-900 dark:bg-gray-900 dark:text-gray-100"),J=n(u==="sm"&&"py-2",u==="md"&&"py-4",u==="lg"&&"py-6"),K=l||"",P=S||"",U=B||"",V=n(F,G,J,K,P,z),L=(e,s,x=!1)=>{let X=e.children&&e.children.length>0,M=N===s,m=n("px-4 py-2 transition-colors flex items-center gap-2",x?"block w-full text-left":"inline-flex",e.active&&"font-semibold border-b-2",e.active&&(O||"border-current"),R||(a==="default"||a==="transparent"?"text-gray-300":"text-gray-600 dark:text-gray-300"),j||U||(a==="default"||a==="transparent"?"hover:text-white":"hover:text-blue-600 dark:hover:text-blue-400"),D||"");if(X)return o("div",{className:x?"w-full":"relative",children:[o("button",{type:"button",onClick:()=>E(s),className:m,children:[e.icon&&r("span",{className:"w-5 h-5",children:e.icon}),r("span",{children:e.label}),e.badge&&r("span",{className:"bg-red-500 text-white text-xs px-2 py-0.5 rounded-full",children:e.badge}),r("svg",{className:n("w-4 h-4 transition-transform",M&&"rotate-180"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),M&&r("div",{className:n("bg-white shadow-lg rounded-lg overflow-hidden dark:bg-gray-800 dark:shadow-black/40",x?"mt-2 mb-2":"absolute top-full left-0 mt-1 min-w-[200px]"),children:e.children?.map(t=>r("a",{href:t.href,onClick:t.onClick,target:t.external?"_blank":void 0,rel:t.external?"noopener noreferrer":void 0,className:"block px-4 py-2 text-gray-700 hover:bg-gray-100 transition-colors dark:text-gray-200 dark:hover:bg-gray-700",children:o("div",{className:"flex items-center gap-2",children:[t.icon&&r("span",{className:"w-5 h-5",children:t.icon}),r("span",{children:t.label}),t.badge&&r("span",{className:"bg-red-500 text-white text-xs px-2 py-0.5 rounded-full ml-auto",children:t.badge}),t.external&&r("svg",{className:"w-4 h-4 ml-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})},t.href??t.label))})]},e.href??e.label);let H=o(Y,{children:[e.icon&&r("span",{className:"w-5 h-5",children:e.icon}),r("span",{children:e.label}),e.badge&&r("span",{className:"bg-red-500 text-white text-xs px-2 py-0.5 rounded-full",children:e.badge}),e.external&&r("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]});return e.onClick?r("button",{type:"button",onClick:e.onClick,className:m,children:H},e.href??e.label):r("a",{href:e.href,target:e.external?"_blank":void 0,rel:e.external?"noopener noreferrer":void 0,className:m,children:H},e.href??e.label)};return o("header",{className:V,children:[o("nav",{className:n("container mx-auto flex items-center justify-between px-4",Q),children:[p&&r("div",{className:"flex items-center",children:v?r("a",{href:v,onClick:I,className:"flex items-center hover:opacity-80 transition-opacity",children:p}):r("div",{className:"flex items-center",children:p})}),y&&r("form",{onSubmit:C,className:"hidden md:flex flex-1 max-w-md mx-8",children:r("input",{type:"search","aria-label":g,value:b,onChange:e=>w(e.target.value),placeholder:g,className:"w-full px-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 text-gray-900 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-500"})}),r("div",{className:"hidden md:flex items-center gap-2",children:d.map((e,s)=>L(e,s,!1))}),(i||c)&&o("div",{className:"hidden md:flex items-center gap-2 ml-4",children:[i,c]}),d.length>0&&r("div",{className:"md:hidden",children:r("button",{type:"button",className:n("inline-flex rounded-lg border-2 p-2 w-10 h-10 justify-center transition-colors focus:outline-none",a==="default"||a==="transparent"?"text-gray-300 hover:text-white":"text-gray-600 hover:text-gray-900 dark:text-gray-300 dark:hover:text-gray-100"),onClick:A,"aria-label":"Toggle menu","aria-expanded":f,children:r("svg",{className:"w-5 h-5","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 14",children:r("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M1 1h15M1 7h15M1 13h15"})})})})]}),f&&d.length>0&&r("div",{className:n("md:hidden border-t animate-in slide-in-from-top duration-300",a==="default"||a==="transparent"?"border-gray-700":"border-gray-200 dark:border-gray-800"),children:o("div",{className:"flex flex-col py-2 px-4",children:[y&&r("form",{onSubmit:C,className:"mb-4",children:r("input",{type:"search","aria-label":g,value:b,onChange:e=>w(e.target.value),placeholder:g,className:"w-full px-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 text-gray-900 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-500"})}),d.map((e,s)=>L(e,s,!0)),(i||c)&&o("div",{className:"flex flex-col gap-2 mt-4 pt-4 border-t border-gray-700",children:[i,c]})]})})]})}export{ee as Header};
1
+ "use client";import{useState as x}from"react";import{cn as n}from"../../lib/cn.js";import{useUILabels as ee}from"../../lib/i18n.js";import{Fragment as re,jsx as r,jsxs as o}from"react/jsx-runtime";function oe({logo:p,logoHref:v="/",onLogoClick:S,navItems:d=[],actions:c,rightContent:i,variant:a="default",size:u="md",backgroundColor:l,textColor:B,hoverColor:P,navItemTextColor:R,navItemHoverColor:j,navItemBgHover:D,navItemActiveColor:O,sticky:T=!1,fixed:W=!1,showSearch:y=!1,onSearch:k,searchPlaceholder:z,menuLabel:Q,className:_,containerClassName:q}){let N=ee(),g=z??N.headerSearchPlaceholder,[b,A]=x(!1),[w,E]=x(null),[f,C]=x(""),F=()=>{A(!b)},U=e=>{E(w===e?null:e)},L=e=>{e.preventDefault(),k&&k(f)},G=n(T&&"sticky top-0 z-50",W&&"fixed top-0 left-0 right-0 z-50"),J=n(a==="default"&&!l&&"bg-gray-900 text-white",a==="transparent"&&!l&&"bg-transparent",a==="bordered"&&!l&&"bg-white border-b border-gray-200 text-gray-900 dark:bg-gray-900 dark:border-gray-800 dark:text-gray-100",a==="shadow"&&!l&&"bg-white shadow-md text-gray-900 dark:bg-gray-900 dark:text-gray-100"),K=n(u==="sm"&&"py-2",u==="md"&&"py-4",u==="lg"&&"py-6"),V=l||"",X=B||"",Y=P||"",Z=n(G,J,K,V,X,_),M=(e,s,h=!1)=>{let $=e.children&&e.children.length>0,I=w===s,m=n("px-4 py-2 transition-colors flex items-center gap-2",h?"block w-full text-left":"inline-flex",e.active&&"font-semibold border-b-2",e.active&&(O||"border-current"),R||(a==="default"||a==="transparent"?"text-gray-300":"text-gray-600 dark:text-gray-300"),j||Y||(a==="default"||a==="transparent"?"hover:text-white":"hover:text-blue-600 dark:hover:text-blue-400"),D||"");if($)return o("div",{className:h?"w-full":"relative",children:[o("button",{type:"button",onClick:()=>U(s),className:m,children:[e.icon&&r("span",{className:"w-5 h-5",children:e.icon}),r("span",{children:e.label}),e.badge&&r("span",{className:"bg-red-500 text-white text-xs px-2 py-0.5 rounded-full",children:e.badge}),r("svg",{className:n("w-4 h-4 transition-transform",I&&"rotate-180"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),I&&r("div",{className:n("bg-white shadow-lg rounded-lg overflow-hidden dark:bg-gray-800 dark:shadow-black/40",h?"mt-2 mb-2":"absolute top-full left-0 mt-1 min-w-[200px]"),children:e.children?.map(t=>r("a",{href:t.href,onClick:t.onClick,target:t.external?"_blank":void 0,rel:t.external?"noopener noreferrer":void 0,className:"block px-4 py-2 text-gray-700 hover:bg-gray-100 transition-colors dark:text-gray-200 dark:hover:bg-gray-700",children:o("div",{className:"flex items-center gap-2",children:[t.icon&&r("span",{className:"w-5 h-5",children:t.icon}),r("span",{children:t.label}),t.badge&&r("span",{className:"bg-red-500 text-white text-xs px-2 py-0.5 rounded-full ml-auto",children:t.badge}),t.external&&r("svg",{className:"w-4 h-4 ml-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})},t.href??t.label))})]},e.href??e.label);let H=o(re,{children:[e.icon&&r("span",{className:"w-5 h-5",children:e.icon}),r("span",{children:e.label}),e.badge&&r("span",{className:"bg-red-500 text-white text-xs px-2 py-0.5 rounded-full",children:e.badge}),e.external&&r("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]});return e.onClick?r("button",{type:"button",onClick:e.onClick,className:m,children:H},e.href??e.label):r("a",{href:e.href,target:e.external?"_blank":void 0,rel:e.external?"noopener noreferrer":void 0,className:m,children:H},e.href??e.label)};return o("header",{className:Z,children:[o("nav",{className:n("container mx-auto flex items-center justify-between px-4",q),children:[p&&r("div",{className:"flex items-center",children:v?r("a",{href:v,onClick:S,className:"flex items-center hover:opacity-80 transition-opacity",children:p}):r("div",{className:"flex items-center",children:p})}),y&&r("form",{onSubmit:L,className:"hidden md:flex flex-1 max-w-md mx-8",children:r("input",{type:"search","aria-label":g,value:f,onChange:e=>C(e.target.value),placeholder:g,className:"w-full px-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 text-gray-900 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-500"})}),r("div",{className:"hidden md:flex items-center gap-2",children:d.map((e,s)=>M(e,s,!1))}),(c||i)&&o("div",{className:"hidden md:flex items-center gap-2 ml-4",children:[c,i]}),d.length>0&&r("div",{className:"md:hidden",children:r("button",{type:"button",className:n("inline-flex rounded-lg border-2 p-2 w-10 h-10 justify-center transition-colors focus:outline-none",a==="default"||a==="transparent"?"text-gray-300 hover:text-white":"text-gray-600 hover:text-gray-900 dark:text-gray-300 dark:hover:text-gray-100"),onClick:F,"aria-label":Q??N.headerToggleMenu,"aria-expanded":b,children:r("svg",{className:"w-5 h-5","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 14",children:r("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M1 1h15M1 7h15M1 13h15"})})})})]}),b&&d.length>0&&r("div",{className:n("md:hidden border-t animate-in slide-in-from-top duration-300",a==="default"||a==="transparent"?"border-gray-700":"border-gray-200 dark:border-gray-800"),children:o("div",{className:"flex flex-col py-2 px-4",children:[y&&r("form",{onSubmit:L,className:"mb-4",children:r("input",{type:"search","aria-label":g,value:f,onChange:e=>C(e.target.value),placeholder:g,className:"w-full px-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 text-gray-900 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-500"})}),d.map((e,s)=>M(e,s,!0)),(c||i)&&o("div",{className:"flex flex-col gap-2 mt-4 pt-4 border-t border-gray-700",children:[c,i]})]})})]})}export{oe as Header};