@synertech/ui 0.50.1 → 0.51.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 (76) hide show
  1. package/.claude/skills/use-synertech-ui/SKILL.md +9 -1
  2. package/dist/components/accordion/Accordion.cjs +1 -1
  3. package/dist/components/accordion/Accordion.js +1 -1
  4. package/dist/components/advance-detachable/AdvanceDetachable.cjs +1 -1
  5. package/dist/components/advance-detachable/AdvanceDetachable.js +1 -1
  6. package/dist/components/chart/ChartPeriodPicker.cjs +1 -1
  7. package/dist/components/chart/ChartPeriodPicker.js +1 -1
  8. package/dist/components/datagrid/DataGrid.cjs +1 -1
  9. package/dist/components/datagrid/DataGrid.js +1 -1
  10. package/dist/components/detachable/Detachable.cjs +1 -1
  11. package/dist/components/detachable/Detachable.js +1 -1
  12. package/dist/components/detachable/useMovableContent.cjs +1 -0
  13. package/dist/components/detachable/useMovableContent.js +1 -0
  14. package/dist/components/drawer/Drawer.cjs +1 -1
  15. package/dist/components/drawer/Drawer.js +1 -1
  16. package/dist/components/dropdown/DropdownContent.cjs +1 -1
  17. package/dist/components/dropdown/DropdownContent.js +1 -1
  18. package/dist/components/dropdown/DropdownSubMenu.cjs +1 -1
  19. package/dist/components/dropdown/DropdownSubMenu.js +1 -1
  20. package/dist/components/dropdown/hooks/useClickOutside.cjs +1 -1
  21. package/dist/components/dropdown/hooks/useClickOutside.js +1 -1
  22. package/dist/components/dropdown/hooks/usePositioning.cjs +1 -1
  23. package/dist/components/dropdown/hooks/usePositioning.js +1 -1
  24. package/dist/components/file-selector/FileSelector.cjs +1 -1
  25. package/dist/components/file-selector/FileSelector.js +1 -1
  26. package/dist/components/form/input/Input.cjs +1 -1
  27. package/dist/components/form/input/Input.js +1 -1
  28. package/dist/components/form/mention-input/MentionInput.cjs +4 -1
  29. package/dist/components/form/mention-input/MentionInput.js +4 -1
  30. package/dist/components/image-uploader/ImageUploader.cjs +1 -1
  31. package/dist/components/image-uploader/ImageUploader.js +1 -1
  32. package/dist/components/modal/Modal.cjs +1 -1
  33. package/dist/components/modal/Modal.js +1 -1
  34. package/dist/components/schema-editor/SchemaEditor.cjs +1 -1
  35. package/dist/components/schema-editor/SchemaEditor.js +1 -1
  36. package/dist/components/schema-editor/SchemaEditor.types.cjs +1 -1
  37. package/dist/components/schema-editor/minimap/SchemaMinimap.cjs +1 -1
  38. package/dist/components/schema-editor/minimap/SchemaMinimap.js +1 -1
  39. package/dist/components/schema-editor/tables/SchemaTableRenderer.cjs +1 -1
  40. package/dist/components/schema-editor/tables/SchemaTableRenderer.js +1 -1
  41. package/dist/components/schema-editor/toolbar/SchemaToolbar.cjs +1 -1
  42. package/dist/components/schema-editor/toolbar/SchemaToolbar.js +1 -1
  43. package/dist/components/schema-editor/utils/import.cjs +1 -0
  44. package/dist/components/schema-editor/utils/import.js +1 -0
  45. package/dist/components/schema-editor/utils/sql-export.cjs +6 -5
  46. package/dist/components/schema-editor/utils/sql-export.js +7 -6
  47. package/dist/components/select/Select.cjs +1 -1
  48. package/dist/components/select/Select.js +1 -1
  49. package/dist/components/slider/Slider.cjs +1 -1
  50. package/dist/components/slider/Slider.js +1 -1
  51. package/dist/components/wizard/Wizard.cjs +1 -1
  52. package/dist/components/wizard/Wizard.js +1 -1
  53. package/dist/components/workflow-editor/WorkflowEditor.cjs +1 -1
  54. package/dist/components/workflow-editor/WorkflowEditor.js +1 -1
  55. package/dist/components/workflow-editor/nodes/WorkflowNodeRenderer.cjs +1 -1
  56. package/dist/components/workflow-editor/nodes/WorkflowNodeRenderer.js +1 -1
  57. package/dist/components/workflow-editor/toolbar/WorkflowToolbar.cjs +1 -1
  58. package/dist/components/workflow-editor/toolbar/WorkflowToolbar.js +1 -1
  59. package/dist/components/workflow-editor/utils/import.cjs +1 -0
  60. package/dist/components/workflow-editor/utils/import.js +1 -0
  61. package/dist/hooks/useDialogA11y.cjs +1 -1
  62. package/dist/hooks/useDialogA11y.js +1 -1
  63. package/dist/index.d.cts +89 -14
  64. package/dist/index.d.ts +89 -14
  65. package/dist/lib/canvas-events.cjs +1 -0
  66. package/dist/lib/canvas-events.js +1 -0
  67. package/dist/lib/dialog-stack.cjs +1 -1
  68. package/dist/lib/dialog-stack.js +1 -1
  69. package/dist/lib/layer-document.cjs +1 -0
  70. package/dist/lib/layer-document.js +1 -0
  71. package/dist/lib/owner-document.cjs +1 -0
  72. package/dist/lib/owner-document.js +1 -0
  73. package/dist/lib/ui-labels.cjs +1 -1
  74. package/dist/lib/ui-labels.js +1 -1
  75. package/dist/styles.css +129 -462
  76. package/package.json +1 -1
@@ -1 +1 @@
1
- "use client";import Nr,{useState as h,useRef as xe,useCallback as x,useEffect as Qe,useMemo as X,forwardRef as Sr,useImperativeHandle as Rr}from"react";import{cn as f}from"../../lib/cn.js";import{csvDocument as Tr}from"../../lib/csv.js";import{formatUILabel as _,useUILabels as Dr,useUILocale as Er}from"../../lib/i18n.js";import{Fragment as qr,jsx as r,jsxs as c}from"react/jsx-runtime";var N={compact:"px-3 py-1.5",default:"px-4 py-3",comfortable:"px-6 py-4"},Te={compact:"text-xs",default:"text-sm",comfortable:"text-base"},Gr=()=>r("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:r("path",{d:"M8 3l4 5H4l4-5z"})}),Mr=()=>r("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:r("path",{d:"M8 13l4-5H4l4 5z"})}),Fr=()=>r("svg",{className:"w-3.5 h-3.5 opacity-30",viewBox:"0 0 16 16",fill:"currentColor",children:r("path",{d:"M8 3l3 4H5l3-4zM8 13l3-4H5l3 4z"})}),St=({className:s})=>r("svg",{className:f("w-4 h-4",s),viewBox:"0 0 20 20",fill:"currentColor",children:r("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})}),Pr=()=>r("svg",{className:"w-4 h-4 text-gray-500 dark:text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children:r("path",{fillRule:"evenodd",d:"M9 3.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM2 9a7 7 0 1112.452 4.391l3.328 3.329a.75.75 0 11-1.06 1.06l-3.329-3.328A7 7 0 012 9z",clipRule:"evenodd"})}),zr=()=>r("svg",{className:"w-4 h-4 text-gray-500 dark:text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children:r("path",{d:"M7 4a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3zM7 10.5a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3zM7 17a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3z"})}),Ir=()=>r("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:r("path",{fillRule:"evenodd",d:"M2.628 1.601C5.028 1.206 7.49 1 10 1s4.973.206 7.372.601a.75.75 0 01.628.74v2.288a2.25 2.25 0 01-.659 1.59l-4.682 4.683a2.25 2.25 0 00-.659 1.59v3.037c0 .684-.31 1.33-.844 1.757l-1.937 1.55A.75.75 0 018 18.25v-5.757a2.25 2.25 0 00-.659-1.591L2.659 6.22A2.25 2.25 0 012 4.629V2.34a.75.75 0 01.628-.74z",clipRule:"evenodd"})}),Or=()=>c("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:[r("path",{d:"M10.75 2.75a.75.75 0 00-1.5 0v8.614L6.295 8.235a.75.75 0 10-1.09 1.03l4.25 4.5a.75.75 0 001.09 0l4.25-4.5a.75.75 0 00-1.09-1.03l-2.955 3.129V2.75z"}),r("path",{d:"M3.5 12.75a.75.75 0 00-1.5 0v2.5A2.75 2.75 0 004.75 18h10.5A2.75 2.75 0 0018 15.25v-2.5a.75.75 0 00-1.5 0v2.5c0 .69-.56 1.25-1.25 1.25H4.75c-.69 0-1.25-.56-1.25-1.25v-2.5z"})]}),Ar=()=>r("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:r("path",{fillRule:"evenodd",d:"M2.5 3A1.5 1.5 0 001 4.5v11A1.5 1.5 0 002.5 17h15a1.5 1.5 0 001.5-1.5v-11A1.5 1.5 0 0017.5 3h-15zM2.5 4.5h6v11h-6v-11zm7.5 0h7.5v11H10v-11z",clipRule:"evenodd"})});function _e(s,d,i){return typeof i=="function"?i(s,d):String(typeof i=="string"?s[i]:d)}var Je=!1;function Qr(){Je=!1}function Lr(){Je||(Je=!0,console.warn("[@synertech/ui] DataGrid has no `rowKey`: each row is known by its position in `data`. Selection, expansion and edits follow that position when `data` is refetched or reordered, and from one page to the next in server mode. Pass `rowKey` to tie them to the row."))}function P(s,d){return s[d]}function Hr(s,d){return s==null&&d==null?0:s==null?-1:d==null?1:typeof s=="number"&&typeof d=="number"?s-d:String(s).localeCompare(String(d))}function Vr(s,d){let i=String(s??"").toLowerCase(),g=d.value.toLowerCase();switch(d.operator){case"contains":return i.includes(g);case"equals":return i===g;case"startsWith":return i.startsWith(g);case"endsWith":return i.endsWith(g);case"gt":return Number(s)>Number(d.value);case"gte":return Number(s)>=Number(d.value);case"lt":return Number(s)<Number(d.value);case"lte":return Number(s)<=Number(d.value);case"isEmpty":return i==="";case"isNotEmpty":return i!=="";default:return!0}}function Rt(s,d,i){let g=[];for(let l of s){let y=Number(P(l,d));isNaN(y)||g.push(y)}if(g.length===0)return 0;switch(i){case"sum":return g.reduce((l,y)=>l+y,0);case"avg":return g.reduce((l,y)=>l+y,0)/g.length;case"count":return g.length;case"min":return Math.min(...g);case"max":return Math.max(...g)}}function Kr(s,d,i){if(s==="count")return d;let g=s==="avg"?i.dataGridAggregateAvg:s==="sum"?i.dataGridAggregateSum:s==="min"?i.dataGridAggregateMin:i.dataGridAggregateMax;return _(g,{value:d})}function Wr({cols:s,density:d}){return r("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:Array.from({length:s}).map((i,g)=>r("td",{className:N[d],children:r("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"})},g))})}function Br({column:s,value:d,onApply:i,onClear:g,labels:l}){let y=s.filterType??"text",H=String(s.header),z=y==="number"?[{value:"equals",label:l.dataGridOperatorEquals},{value:"gt",label:l.dataGridOperatorGreaterThan},{value:"gte",label:l.dataGridOperatorGreaterOrEqual},{value:"lt",label:l.dataGridOperatorLessThan},{value:"lte",label:l.dataGridOperatorLessOrEqual}]:[{value:"contains",label:l.dataGridOperatorContains},{value:"equals",label:l.dataGridOperatorEquals},{value:"startsWith",label:l.dataGridOperatorStartsWith},{value:"endsWith",label:l.dataGridOperatorEndsWith},{value:"isEmpty",label:l.dataGridOperatorIsEmpty},{value:"isNotEmpty",label:l.dataGridOperatorIsNotEmpty}],T=u=>u&&z.some(D=>D.value===u.operator)?u.operator:z[0].value,[G,C]=h(!1),[M,oe]=h(()=>T(d)),[J,V]=h(d?.value??""),se=xe(null),I=()=>{G||(oe(T(d)),V(d?.value??"")),C(!G)};return Qe(()=>{let u=D=>{se.current&&!se.current.contains(D.target)&&C(!1)};return G&&document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[G]),c("div",{className:"relative inline-block",ref:se,onClick:u=>u.stopPropagation(),children:[r("button",{type:"button",onClick:I,className:f("p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer",d&&"text-synertech-primary-600 dark:text-synertech-primary-400"),"aria-label":_(l.dataGridFilterColumn,{column:H}),children:r(Ir,{})}),G&&r("div",{className:"absolute z-50 top-full left-0 mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg p-3 min-w-[220px]",children:y==="select"&&s.filterOptions?c("div",{className:"flex flex-col gap-1.5",children:[s.filterOptions.map(u=>c("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[r("input",{type:"radio",name:`filter-${s.key}`,value:u,checked:J===u,onChange:()=>V(u),className:"cursor-pointer"}),r("span",{className:"text-gray-700 dark:text-gray-300",children:u})]},u)),c("div",{className:"flex gap-2 mt-2",children:[r("button",{type:"button",onClick:()=>{i({column:s.key,operator:"equals",value:J}),C(!1)},className:"px-2 py-1 text-xs bg-synertech-primary-600 text-synertech-on-primary rounded hover:bg-synertech-primary-700 cursor-pointer",children:l.dataGridFilterApply}),r("button",{type:"button",onClick:()=>{V(""),g(),C(!1)},className:"px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 cursor-pointer",children:l.dataGridFilterClear})]})]}):c("div",{className:"flex flex-col gap-2",children:[r("select",{value:M,onChange:u=>oe(u.target.value),className:"text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200",children:z.map(u=>r("option",{value:u.value,children:u.label},u.value))}),M!=="isEmpty"&&M!=="isNotEmpty"&&r("input",{type:y==="number"?"number":y==="date"?"date":"text",value:J,onChange:u=>V(u.target.value),placeholder:l.dataGridFilterValuePlaceholder,className:"text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200",autoFocus:!0,"aria-label":_(l.dataGridFilterValue,{column:H})}),c("div",{className:"flex gap-2",children:[r("button",{type:"button",onClick:()=>{i({column:s.key,operator:M,value:J}),C(!1)},className:"px-2 py-1 text-xs bg-synertech-primary-600 text-synertech-on-primary rounded hover:bg-synertech-primary-700 cursor-pointer",children:l.dataGridFilterApply}),r("button",{type:"button",onClick:()=>{V(""),g(),C(!1)},className:"px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 cursor-pointer",children:l.dataGridFilterClear})]})]})})]})}function Ur({value:s,onSave:d,density:i,labels:g}){let[l,y]=h(!1),[H,z]=h(String(s??"")),T=xe(null);if(Qe(()=>{l&&T.current&&(T.current.focus(),T.current.select())},[l]),!l)return r("div",{onDoubleClick:()=>{z(String(s??"")),y(!0)},className:"cursor-text min-h-[1.5em]",title:g.dataGridEditHint,children:String(s??"")});let G=()=>{y(!1),H!==String(s??"")&&d(H)};return r("input",{ref:T,type:"text",value:H,onChange:C=>z(C.target.value),onBlur:G,"aria-label":g.dataGridEditCell,onKeyDown:C=>{C.key==="Enter"&&G(),C.key==="Escape"&&y(!1)},className:f("w-full border border-synertech-primary-500 rounded px-1 py-0.5 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 outline-none",Te[i])})}function jr(s,d){let{columns:i,data:g,rowKey:l,mode:y="client",sortable:H=!1,multiSort:z=!1,sort:T,defaultSort:G,onSort:C,pagination:M=!1,page:oe,onPageChange:J,onPageSizeChange:V,totalItems:se,selectable:I=!1,selectionMode:u="multiple",selectedRows:D,onSelectionChange:K,searchable:Ye=!1,searchPlaceholder:Tt,searchValue:fe,onSearch:we,filters:Q,onFilterChange:ie,expandable:le=!1,expandedContent:Ze,expandedRows:De,onExpandChange:et,editable:tt=!1,onCellEdit:Dt,reorderable:de=!1,onReorder:rt,columnReorderable:W=!1,onColumnReorder:at,columnToggle:nt=!1,hiddenColumns:Ee,onColumnVisibilityChange:ot,groupBy:B,renderGroupHeader:st,exportable:it=!1,exportFormats:Et=["csv","json"],exportFilename:lt="export",exportNeutralizeFormulas:dt,virtualized:Y=!1,rowHeight:Z=40,virtualHeight:Ge=400,density:v="default",striped:ct=!1,bordered:Me=!1,borderless:Gt=!1,stickyHeader:gt=!1,maxHeight:ke,loading:Mt=!1,loadingRows:Ft=5,emptyState:Pt,labels:zt,locale:It,showFooter:Ot=!1,onRowClick:Fe,onRowDoubleClick:ut,onRowContextMenu:pt,className:At,rowClassName:Pe,cellClassName:Lt,headerClassName:Ht}=s,b=Dr(zt),Vt=Er(It),[Kt,mt]=h(G??[]),[Wt,Bt]=h(1),ce=typeof M=="object"?M.pageSize:void 0,[Ut,yt]=h(ce??10),[jt,qt]=h(ce);ce!==jt&&(qt(ce),ce!==void 0&&yt(ce));let[$t,Ce]=h([]),[Xt,bt]=h(""),[_t,ze]=h([]),[Jt,Qt]=h([]),[Yt,Zt]=h(()=>i.flatMap(e=>e.hidden?[e.key]:[])),[Ie,er]=h({}),[Ne,tr]=h(()=>i.map(e=>e.key)),[ee,Oe]=h(null),[ge,ft]=h(null),[Se,ht]=h(!1),[rr,ar]=h(new Set),Ae=xe(null),[vt,nr]=h(0),Le=xe(null),He=xe(!1),U=T??Kt,xt=oe??Wt,S=D??$t,Re=fe??Xt,j=Q??_t,he=De??Jt,te=Ee??Yt,ue=M?typeof M=="object"?M:{pageSize:10,pageSizeOptions:[10,25,50,100]}:null,ve=Ut;!l&&(I||le||tt||de)&&Lr();let wt=e=>_e(e.row,e.sourceIndex,l),O=X(()=>{let e=new Map(i.map(n=>[n.key,n])),t=Ne.flatMap(n=>{let o=e.get(n);return o?[o]:[]}),a=new Set(t.map(n=>n.key));for(let n of i)a.has(n.key)||(t.push(n),a.add(n.key));return t.filter(n=>!te.includes(n.key))},[i,Ne,te]),re=X(()=>{let e=g.map((t,a)=>({row:t,sourceIndex:a}));if(y==="server")return e;if(Re){let t=Re.toLowerCase();e=e.filter(({row:a})=>O.some(n=>{let o=P(a,n.key);return String(o??"").toLowerCase().includes(t)}))}if(j.length>0&&(e=e.filter(({row:t})=>j.every(a=>Vr(P(t,a.column),a)))),U.length>0){let t=new Map(i.map(a=>[a.key,a]));e.sort((a,n)=>{for(let o of U){if(!o.direction)continue;let m=t.get(o.key),w=m?.sortComparator?m.sortComparator(a.row,n.row):Hr(P(a.row,o.key),P(n.row,o.key));if(w!==0)return o.direction==="asc"?w:-w}return 0})}return e},[g,y,Re,j,U,O,i]),pe=X(()=>re.map(e=>e.row),[re]),kt=X(()=>{if(!B)return null;let e=Array.isArray(B)?B:[B],t=new Map;for(let a of re){let n=e.map(m=>String(P(a.row,m)??"")).join(" / "),o=t.get(n)??[];o.push(a),t.set(n,o)}return t},[re,B]),Ve=se??pe.length,ae=Math.max(1,Math.ceil(Ve/ve)),A=y==="server"&&se===void 0?xt:Math.min(Math.max(1,xt),ae),Ct=ue!==null,L=X(()=>{if(!Ct||y==="server")return re;let e=(A-1)*ve;return re.slice(e,e+ve)},[re,Ct,A,ve,y]),q=X(()=>L.map(e=>e.row),[L]),me=X(()=>{if(!Y)return{start:0,end:q.length};let e=Math.floor(vt/Z),t=Math.ceil(Ge/Z),a=5;return{start:Math.max(0,e-a),end:Math.min(q.length,e+t+a)}},[Y,vt,Z,Ge,q.length]),Ke=x(e=>{T||mt(e),C?.(e)},[T,C]),or=x(e=>{let t=U.find(n=>n.key===e),a;if(!t||!t.direction?a="asc":t.direction==="asc"?a="desc":a=null,z){let n=U.filter(o=>o.key!==e);a&&n.push({key:e,direction:a}),Ke(n)}else Ke(a?[{key:e,direction:a}]:[])},[U,z,Ke]),R=x(e=>{let t=Math.max(1,Math.min(e,ae));oe||Bt(t),J?.(t)},[oe,J,ae]),sr=x(e=>{yt(e),R(1),V?.(e)},[R,V]),ir=x(e=>{let t;u==="single"?t=S.includes(e)?[]:[e]:t=S.includes(e)?S.filter(a=>a!==e):[...S,e],D||Ce(t),K?.(t)},[u,S,D,K]),We=X(()=>new Set(S),[S]),Be=x(()=>{let e=new Set(S),t=[...S];for(let a of L){let n=_e(a.row,a.sourceIndex,l);e.has(n)||(e.add(n),t.push(n))}D||Ce(t),K?.(t)},[L,l,S,D,K]),Nt=x(()=>{D||Ce([]),K?.([])},[D,K]),lr=x(()=>{let e=new Set(L.map(a=>_e(a.row,a.sourceIndex,l))),t=S.filter(a=>!e.has(a));D||Ce(t),K?.(t)},[L,l,S,D,K]),Ue=I?L.map(wt):[],je=Ue.length>0&&Ue.every(e=>We.has(e)),dr=!je&&Ue.some(e=>We.has(e)),cr=x(e=>{let t=he.includes(e)?he.filter(a=>a!==e):[...he,e];De||Qt(t),et?.(t)},[he,De,et]),gr=x(e=>{let t=e.target.value;fe||bt(t),we?.(t),R(1)},[fe,we,R]),ur=x(e=>{let t=[...j.filter(a=>a.column!==e.column),e];Q||ze(t),ie?.(t),R(1)},[j,Q,ie,R]),pr=x(e=>{let t=j.filter(a=>a.column!==e);Q||ze(t),ie?.(t),R(1)},[j,Q,ie,R]),mr=x(e=>{let t=te.includes(e)?te.filter(a=>a!==e):[...te,e];Ee||Zt(t),ot?.(t)},[te,Ee,ot]),yr=x((e,t)=>{e.preventDefault(),e.stopPropagation(),He.current=!0;let a=e.clientX,n=Ie[t]??e.currentTarget.parentElement?.getBoundingClientRect().width??100,o=i.find(k=>k.key===t),m=o?.minWidth??50,w=o?.maxWidth??1/0,ne=k=>{let $=k.clientX-a,F=Math.min(w,Math.max(m,n+$));er(be=>({...be,[t]:F}))},p=()=>{document.removeEventListener("mousemove",ne),document.removeEventListener("mouseup",p),setTimeout(()=>{He.current=!1},0)};document.addEventListener("mousemove",ne),document.addEventListener("mouseup",p)},[Ie,i]),E=de&&!(y==="client"&&U.some(e=>e.direction)),br=x((e,t)=>{E&&Oe({key:e,sourceIndex:t})},[E]),fr=x(e=>{!E||ee===null||e.preventDefault()},[E,ee]),hr=x((e,t)=>{!E||ee===null||(Oe(null),ee.key!==e&&rt?.(ee.sourceIndex,t))},[E,ee,rt]),vr=x(e=>{W&&ft(e)},[W]),xr=x(e=>{if(!W||!ge||ge===e)return;let t=[...Ne],a=t.indexOf(ge),n=t.indexOf(e);a===-1||n===-1||(t.splice(a,1),t.splice(n,0,ge),tr(t),at?.(ge,e),ft(null))},[W,ge,Ne,at]),qe=x(e=>{let t=O.filter(k=>k.type!=="actions"&&k.type!=="selection"&&k.type!=="expand"),a=pe,n,o,m;if(e==="csv")n=Tr([t.map(k=>String(k.header)),...a.map(k=>t.map($=>{let F=P(k,$.key);return typeof F=="number"?F:String(F??"")}))],{neutralizeFormulas:dt}),o="text/csv",m="csv";else{let k=a.map($=>{let F={};for(let be of t)F[be.key]=P($,be.key);return F});n=JSON.stringify(k,null,2),o="application/json",m="json"}let w=new Blob([n],{type:o}),ne=URL.createObjectURL(w),p=document.createElement("a");p.href=ne,p.download=`${lt}.${m}`,p.click(),URL.revokeObjectURL(ne)},[O,pe,lt,dt]);Qe(()=>{if(!Se)return;let e=t=>{Le.current&&!Le.current.contains(t.target)&&ht(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[Se]),Rr(d,()=>({getVisibleData:()=>q,resetFilters:()=>{Q||ze([]),fe||bt(""),ie?.([]),we?.(""),R(1)},resetSort:()=>{T||mt([]),C?.([])},selectAll:Be,deselectAll:Nt,exportData:qe,scrollToRow:e=>{Ae.current&&Y&&(Ae.current.scrollTop=e*Z)}}),[q,Q,fe,T,ie,we,C,R,Be,Nt,qe,Y,Z]);let $e=e=>{let t={},a=Ie[e.key]??e.width;return a&&(t.width=typeof a=="number"?`${a}px`:a,t.minWidth=typeof a=="number"?`${a}px`:a),e.sticky&&(t.position="sticky",t[e.sticky]=0,t.zIndex=10),t},ye=O.length+(I?1:0)+(le?1:0)+(de?1:0),wr=e=>{let t=H&&e.sortable!==!1&&e.type!=="actions",a=U.find(o=>o.key===e.key),n=e.filterable&&(e.filterType||e.filterOptions);return c("th",{className:f(N[v],Te[v],"relative font-semibold text-gray-700 dark:text-gray-300 whitespace-nowrap",e.align==="center"&&"text-center",e.align==="right"&&"text-right",t&&"cursor-pointer select-none hover:bg-gray-100 dark:hover:bg-gray-700",Me&&"border border-gray-200 dark:border-gray-700",e.sticky&&"bg-gray-50 dark:bg-gray-800",e.headerClassName,Ht),style:$e(e),onClick:t?()=>{He.current||or(e.key)}:void 0,draggable:W,onDragStart:W?()=>vr(e.key):void 0,onDragOver:W?o=>o.preventDefault():void 0,onDrop:W?()=>xr(e.key):void 0,"aria-sort":a?.direction==="asc"?"ascending":a?.direction==="desc"?"descending":void 0,children:[c("div",{className:"flex items-center gap-1",children:[e.renderHeader?e.renderHeader(e):e.header,t&&r("span",{className:"inline-flex ml-1",children:a?.direction==="asc"?r(Gr,{}):a?.direction==="desc"?r(Mr,{}):r(Fr,{})}),n&&r(Br,{column:e,value:j.find(o=>o.column===e.key),onApply:ur,onClear:()=>pr(e.key),labels:b})]}),e.resizable!==!1&&r("div",{className:"absolute top-0 right-0 w-1 h-full cursor-col-resize hover:bg-synertech-primary-500 opacity-0 hover:opacity-100",onMouseDown:o=>yr(o,e.key)})]},e.key)},Xe=(e,t)=>{let{row:a,sourceIndex:n}=e,o=wt(e),m=We.has(o),w=he.includes(o),ne=typeof Pe=="function"?Pe(a,t):Pe;return c(Nr.Fragment,{children:[c("tr",{className:f("border-b border-gray-200 dark:border-gray-700 transition-colors",ct&&t%2===1&&"bg-gray-50/50 dark:bg-gray-800/50",m&&"bg-synertech-primary-50 dark:bg-synertech-primary-900/20",Fe&&"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50",ee?.key===o&&"opacity-50",ne),onClick:Fe?()=>Fe(a,t):void 0,onDoubleClick:ut?()=>ut(a,t):void 0,onContextMenu:pt?p=>pt(a,t,p):void 0,draggable:E,onDragStart:E?()=>br(o,n):void 0,onDragOver:E?fr:void 0,onDrop:E?()=>hr(o,n):void 0,onDragEnd:E?()=>Oe(null):void 0,"data-row-key":o,"aria-selected":I?m:void 0,children:[de&&r("td",{className:f(N[v],E?"cursor-grab active:cursor-grabbing":"cursor-not-allowed opacity-40"),children:r(zr,{})}),I&&r("td",{className:f(N[v],"w-10"),children:r("input",{type:"checkbox",checked:m,onChange:()=>ir(o),onClick:p=>p.stopPropagation(),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":_(b.dataGridSelectRow,{row:o})})}),le&&r("td",{className:f(N[v],"w-10"),children:r("button",{type:"button",onClick:p=>{p.stopPropagation(),cr(o)},className:"p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer","aria-label":w?b.dataGridCollapseRow:b.dataGridExpandRow,"aria-expanded":w,children:r(St,{className:f("transition-transform",w&&"rotate-180")})})}),O.map(p=>{let k=P(a,p.key),$=p.colSpan?.(a,t);if($===0)return null;let F=tt&&p.editable!==!1&&p.type!=="actions";return r("td",{className:f(N[v],Te[v],"text-gray-700 dark:text-gray-300",p.align==="center"&&"text-center",p.align==="right"&&"text-right",Me&&"border border-gray-200 dark:border-gray-700",p.sticky&&(m?"bg-synertech-primary-50 dark:bg-synertech-primary-900/20":ct&&t%2===1?"bg-gray-50/50 dark:bg-gray-800/50":"bg-white dark:bg-gray-900"),p.cellClassName,Lt),style:$e(p),colSpan:$,children:F?r(Ur,{value:k,onSave:be=>Dt?.(o,p.key,be),density:v,labels:b}):p.render?p.render(k,a,t):String(k??"")},p.key)})]}),le&&w&&Ze&&r("tr",{className:"bg-gray-50 dark:bg-gray-800/70",children:r("td",{colSpan:ye,className:f(N[v]),children:Ze(a,t)})})]},o)},kr=()=>{if(Mt)return Array.from({length:Ft}).map((e,t)=>r(Wr,{cols:ye,density:v},t));if(q.length===0)return r("tr",{children:r("td",{colSpan:ye,className:f("text-center text-gray-500 dark:text-gray-400",N[v]),children:Pt??b.dataGridNoData})});if(kt){let e=[],t=0;for(let[a,n]of kt){let o=rr.has(a);if(e.push(r("tr",{className:"bg-gray-100 dark:bg-gray-800 font-medium",children:r("td",{colSpan:ye,className:f(N[v],"cursor-pointer"),onClick:()=>{ar(m=>{let w=new Set(m);return w.has(a)?w.delete(a):w.add(a),w})},children:c("div",{className:"flex items-center gap-2",children:[r(St,{className:f("transition-transform",o&&"-rotate-90")}),st?st(a,P(n[0].row,Array.isArray(B)?B[0]:B),n.map(m=>m.row)):`${a} (${n.length})`]})})},`group-${a}`)),o)t+=n.length;else for(let m=0;m<n.length;m++)e.push(Xe(n[m],t)),t++}return e}if(Y){let e=[];for(let t=me.start;t<me.end;t++)e.push(Xe(L[t],t));return c(qr,{children:[me.start>0&&r("tr",{children:r("td",{colSpan:ye,style:{height:me.start*Z,padding:0}})}),e,me.end<q.length&&r("tr",{children:r("td",{colSpan:ye,style:{height:(q.length-me.end)*Z,padding:0}})})]})}return L.map((e,t)=>Xe(e,t))},Cr=()=>!Ot||!O.some(t=>t.aggregate)?null:r("tfoot",{children:c("tr",{className:"bg-gray-50 dark:bg-gray-800 font-semibold border-t-2 border-gray-300 dark:border-gray-600",children:[de&&r("td",{className:N[v]}),I&&r("td",{className:N[v]}),le&&r("td",{className:N[v]}),O.map(t=>r("td",{className:f(N[v],Te[v],"text-gray-700 dark:text-gray-300",t.align==="center"&&"text-center",t.align==="right"&&"text-right",Me&&"border border-gray-200 dark:border-gray-700"),style:$e(t),children:t.aggregate?t.renderAggregate?t.renderAggregate(Rt(pe,t.key,t.aggregate),pe):Kr(t.aggregate,Rt(pe,t.key,t.aggregate).toLocaleString(Vt),b):""},t.key))]})});return c("div",{className:f("flex flex-col gap-3",At),children:[(Ye||it||nt)&&c("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[c("div",{className:"flex items-center gap-3 flex-1",children:[Ye&&c("div",{className:"relative flex-1 max-w-xs",children:[r("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:r(Pr,{})}),r("input",{type:"text",value:Re,onChange:gr,placeholder:Tt??b.dataGridSearchPlaceholder,className:"w-full pl-9 pr-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500","aria-label":b.dataGridSearch})]}),S.length>0&&r("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:_(b.dataGridSelectedCount,{count:S.length})})]}),c("div",{className:"flex items-center gap-2",children:[nt&&c("div",{className:"relative",ref:Le,children:[r("button",{type:"button",onClick:()=>ht(!Se),className:"p-1.5 rounded-md border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":b.dataGridToggleColumns,title:b.dataGridToggleColumns,children:r(Ar,{})}),Se&&r("div",{className:"absolute z-50 right-0 top-full mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg p-2 min-w-[180px]",children:i.filter(e=>e.type!=="selection"&&e.type!=="expand").map(e=>c("label",{className:"flex items-center gap-2 px-2 py-1.5 text-sm rounded hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:[r("input",{type:"checkbox",checked:!te.includes(e.key),onChange:()=>mr(e.key),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer"}),r("span",{className:"text-gray-700 dark:text-gray-300",children:String(e.header)})]},e.key))})]}),it&&Et.map(e=>c("button",{type:"button",onClick:()=>qe(e),className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs font-medium rounded-md border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",title:_(b.dataGridExportAs,{format:e.toUpperCase()}),children:[r(Or,{}),e.toUpperCase()]},e))]})]}),r("div",{ref:Ae,className:f("overflow-auto rounded-lg",!Gt&&"border border-gray-200 dark:border-gray-700",gt&&"relative"),style:ke?{maxHeight:typeof ke=="number"?`${ke}px`:ke}:Y?{maxHeight:Ge,overflow:"auto"}:void 0,onScroll:Y?e=>nr(e.target.scrollTop):void 0,children:c("table",{className:"w-full text-left",children:[r("thead",{className:f("bg-gray-50 dark:bg-gray-800 text-xs uppercase",gt&&"sticky top-0 z-20"),children:c("tr",{children:[de&&r("th",{className:f(N[v],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),I&&r("th",{className:f(N[v],"w-10"),children:u==="multiple"&&r("input",{type:"checkbox",checked:je,ref:e=>{e&&(e.indeterminate=dr)},onChange:je?lr:Be,className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":b.dataGridSelectAllRows})}),le&&r("th",{className:f(N[v],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),O.map(wr)]})}),r("tbody",{children:kr()}),Cr()]})}),ue&&c("div",{className:"flex items-center justify-between flex-wrap gap-3 text-sm text-gray-600 dark:text-gray-400",children:[c("div",{className:"flex items-center gap-3",children:[ue.showTotalItems!==!1&&r("span",{children:_(Ve===1?b.dataGridItemCount:b.dataGridItemsCount,{count:Ve})}),ue.showPageSizeSelector!==!1&&ue.pageSizeOptions&&c("div",{className:"flex items-center gap-1.5",children:[r("span",{children:b.dataGridRowsPerPage}),r("select",{value:ve,onChange:e=>sr(Number(e.target.value)),className:"border border-gray-300 dark:border-gray-600 rounded px-1.5 py-0.5 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 text-sm",children:ue.pageSizeOptions.map(e=>r("option",{value:e,children:e},e))})]})]}),c("div",{className:"flex items-center gap-1",children:[r("span",{className:"mr-2",children:_(b.dataGridPageOf,{page:A,total:ae})}),r("button",{type:"button",onClick:()=>R(1),disabled:A<=1,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":b.dataGridFirstPage,children:"\xAB\xAB"}),r("button",{type:"button",onClick:()=>R(A-1),disabled:A<=1,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":b.dataGridPreviousPage,children:"\xAB"}),r("button",{type:"button",onClick:()=>R(A+1),disabled:A>=ae,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":b.dataGridNextPage,children:"\xBB"}),r("button",{type:"button",onClick:()=>R(ae),disabled:A>=ae,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":b.dataGridLastPage,children:"\xBB\xBB"})]})]})]})}var Yr=Sr(jr);export{Yr as DataGrid,Qr as resetRowKeyWarning};
1
+ "use client";import Hr,{useState as f,useRef as Ce,useCallback as h,useEffect as Me,useMemo as P,forwardRef as Lr,useImperativeHandle as Vr}from"react";import{cn as b}from"../../lib/cn.js";import{csvDocument as Kr}from"../../lib/csv.js";import{formatUILabel as _,useUILabels as Wr,useUILocale as Br}from"../../lib/i18n.js";import{Fragment as dn,jsx as n,jsxs as c}from"react/jsx-runtime";var F={compact:"px-3 py-1.5",default:"px-4 py-3",comfortable:"px-6 py-4"},Ur={compact:"px-3 py-0",default:"px-4 py-0",comfortable:"px-6 py-0"},Ge={compact:"text-xs",default:"text-sm",comfortable:"text-base"},jr=()=>n("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:n("path",{d:"M8 3l4 5H4l4-5z"})}),qr=()=>n("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:n("path",{d:"M8 13l4-5H4l4 5z"})}),$r=()=>n("svg",{className:"w-3.5 h-3.5 opacity-30",viewBox:"0 0 16 16",fill:"currentColor",children:n("path",{d:"M8 3l3 4H5l3-4zM8 13l3-4H5l3 4z"})}),Ot=({className:s})=>n("svg",{className:b("w-4 h-4",s),viewBox:"0 0 20 20",fill:"currentColor",children:n("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})}),Xr=()=>n("svg",{className:"w-4 h-4 text-gray-500 dark:text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children:n("path",{fillRule:"evenodd",d:"M9 3.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM2 9a7 7 0 1112.452 4.391l3.328 3.329a.75.75 0 11-1.06 1.06l-3.329-3.328A7 7 0 012 9z",clipRule:"evenodd"})}),_r=()=>n("svg",{className:"w-4 h-4 text-gray-500 dark:text-gray-400",viewBox:"0 0 20 20",fill:"currentColor",children:n("path",{d:"M7 4a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3zM7 10.5a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3zM7 17a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm6 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3z"})}),Jr=()=>n("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:n("path",{fillRule:"evenodd",d:"M2.628 1.601C5.028 1.206 7.49 1 10 1s4.973.206 7.372.601a.75.75 0 01.628.74v2.288a2.25 2.25 0 01-.659 1.59l-4.682 4.683a2.25 2.25 0 00-.659 1.59v3.037c0 .684-.31 1.33-.844 1.757l-1.937 1.55A.75.75 0 018 18.25v-5.757a2.25 2.25 0 00-.659-1.591L2.659 6.22A2.25 2.25 0 012 4.629V2.34a.75.75 0 01.628-.74z",clipRule:"evenodd"})}),Qr=()=>c("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:[n("path",{d:"M10.75 2.75a.75.75 0 00-1.5 0v8.614L6.295 8.235a.75.75 0 10-1.09 1.03l4.25 4.5a.75.75 0 001.09 0l4.25-4.5a.75.75 0 00-1.09-1.03l-2.955 3.129V2.75z"}),n("path",{d:"M3.5 12.75a.75.75 0 00-1.5 0v2.5A2.75 2.75 0 004.75 18h10.5A2.75 2.75 0 0018 15.25v-2.5a.75.75 0 00-1.5 0v2.5c0 .69-.56 1.25-1.25 1.25H4.75c-.69 0-1.25-.56-1.25-1.25v-2.5z"})]}),Yr=()=>n("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:n("path",{fillRule:"evenodd",d:"M2.5 3A1.5 1.5 0 001 4.5v11A1.5 1.5 0 002.5 17h15a1.5 1.5 0 001.5-1.5v-11A1.5 1.5 0 0017.5 3h-15zM2.5 4.5h6v11h-6v-11zm7.5 0h7.5v11H10v-11z",clipRule:"evenodd"})});function rt(s,d,i){return typeof i=="function"?i(s,d):String(typeof i=="string"?s[i]:d)}var nt=!1;function yn(){nt=!1}function Zr(){nt||(nt=!0,console.warn("[@synertech/ui] DataGrid has no `rowKey`: each row is known by its position in `data`. Selection, expansion and edits follow that position when `data` is refetched or reordered, and from one page to the next in server mode. Pass `rowKey` to tie them to the row."))}function H(s,d){return s[d]}function At(s,d){return d.map(i=>String(H(s,i)??"")).join(" / ")}function at(s){return s==null||typeof s=="string"&&s.trim()===""||typeof s=="number"&&Number.isNaN(s)||s instanceof Date&&Number.isNaN(s.getTime())}function en(s,d,i){let p=at(s),l=at(d);return p||l?p===l?0:p?-1:1:s instanceof Date&&d instanceof Date?s.getTime()-d.getTime():typeof s=="number"&&typeof d=="number"?s-d:i.compare(String(s),String(d))}function tn(s,d){let i=String(s??"").toLowerCase(),p=d.value.toLowerCase();switch(d.operator){case"contains":return i.includes(p);case"equals":return i===p;case"startsWith":return i.startsWith(p);case"endsWith":return i.endsWith(p);case"gt":return Number(s)>Number(d.value);case"gte":return Number(s)>=Number(d.value);case"lt":return Number(s)<Number(d.value);case"lte":return Number(s)<=Number(d.value);case"isEmpty":return i==="";case"isNotEmpty":return i!=="";default:return!0}}function rn(s,d,i){let p=0,l=0,v=0,G=1/0,R=-1/0;for(let C of s){let T=H(C,d);if(at(T))continue;p++;let m=Number(T);Number.isNaN(m)||(l++,v+=m,m<G&&(G=m),m>R&&(R=m))}switch(i){case"count":return p;case"sum":return v;case"avg":return l===0?null:v/l;case"min":return l===0?null:G;case"max":return l===0?null:R}}function nn(s,d,i){if(s==="count")return d;let p=s==="avg"?i.dataGridAggregateAvg:s==="sum"?i.dataGridAggregateSum:s==="min"?i.dataGridAggregateMin:i.dataGridAggregateMax;return _(p,{value:d})}function an({cols:s,density:d}){return n("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:Array.from({length:s}).map((i,p)=>n("td",{className:F[d],children:n("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"})},p))})}function on({column:s,value:d,onApply:i,onClear:p,labels:l}){let v=s.filterType??"text",G=String(s.header),R=v==="number"?[{value:"equals",label:l.dataGridOperatorEquals},{value:"gt",label:l.dataGridOperatorGreaterThan},{value:"gte",label:l.dataGridOperatorGreaterOrEqual},{value:"lt",label:l.dataGridOperatorLessThan},{value:"lte",label:l.dataGridOperatorLessOrEqual}]:[{value:"contains",label:l.dataGridOperatorContains},{value:"equals",label:l.dataGridOperatorEquals},{value:"startsWith",label:l.dataGridOperatorStartsWith},{value:"endsWith",label:l.dataGridOperatorEndsWith},{value:"isEmpty",label:l.dataGridOperatorIsEmpty},{value:"isNotEmpty",label:l.dataGridOperatorIsNotEmpty}],C=u=>u&&R.some(E=>E.value===u.operator)?u.operator:R[0].value,[T,m]=f(!1),[z,re]=f(()=>C(d)),[J,B]=f(d?.value??""),ne=Ce(null),L=()=>{T||(re(C(d)),B(d?.value??"")),m(!T)};return Me(()=>{let u=E=>{ne.current&&!ne.current.contains(E.target)&&m(!1)};return T&&document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[T]),c("div",{className:"relative inline-block",ref:ne,onClick:u=>u.stopPropagation(),children:[n("button",{type:"button",onClick:L,className:b("p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer",d&&"text-synertech-primary-600 dark:text-synertech-primary-400"),"aria-label":_(l.dataGridFilterColumn,{column:G}),children:n(Jr,{})}),T&&n("div",{className:"absolute z-50 top-full left-0 mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg p-3 min-w-[220px]",children:v==="select"&&s.filterOptions?c("div",{className:"flex flex-col gap-1.5",children:[s.filterOptions.map(u=>c("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[n("input",{type:"radio",name:`filter-${s.key}`,value:u,checked:J===u,onChange:()=>B(u),className:"cursor-pointer"}),n("span",{className:"text-gray-700 dark:text-gray-300",children:u})]},u)),c("div",{className:"flex gap-2 mt-2",children:[n("button",{type:"button",onClick:()=>{i({column:s.key,operator:"equals",value:J}),m(!1)},className:"px-2 py-1 text-xs bg-synertech-primary-600 text-synertech-on-primary rounded hover:bg-synertech-primary-700 cursor-pointer",children:l.dataGridFilterApply}),n("button",{type:"button",onClick:()=>{B(""),p(),m(!1)},className:"px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 cursor-pointer",children:l.dataGridFilterClear})]})]}):c("div",{className:"flex flex-col gap-2",children:[n("select",{value:z,onChange:u=>re(u.target.value),className:"text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200",children:R.map(u=>n("option",{value:u.value,children:u.label},u.value))}),z!=="isEmpty"&&z!=="isNotEmpty"&&n("input",{type:v==="number"?"number":v==="date"?"date":"text",value:J,onChange:u=>B(u.target.value),placeholder:l.dataGridFilterValuePlaceholder,className:"text-xs border border-gray-300 dark:border-gray-600 rounded px-2 py-1 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200",autoFocus:!0,"aria-label":_(l.dataGridFilterValue,{column:G})}),c("div",{className:"flex gap-2",children:[n("button",{type:"button",onClick:()=>{i({column:s.key,operator:z,value:J}),m(!1)},className:"px-2 py-1 text-xs bg-synertech-primary-600 text-synertech-on-primary rounded hover:bg-synertech-primary-700 cursor-pointer",children:l.dataGridFilterApply}),n("button",{type:"button",onClick:()=>{B(""),p(),m(!1)},className:"px-2 py-1 text-xs text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 cursor-pointer",children:l.dataGridFilterClear})]})]})})]})}function sn({value:s,onSave:d,density:i,labels:p}){let[l,v]=f(!1),[G,R]=f(String(s??"")),C=Ce(null);if(Me(()=>{l&&C.current&&(C.current.focus(),C.current.select())},[l]),!l)return n("div",{onDoubleClick:()=>{R(String(s??"")),v(!0)},className:"cursor-text min-h-[1.5em]",title:p.dataGridEditHint,children:String(s??"")});let T=()=>{v(!1),G!==String(s??"")&&d(G)};return n("input",{ref:C,type:"text",value:G,onChange:m=>R(m.target.value),onBlur:T,"aria-label":p.dataGridEditCell,onKeyDown:m=>{m.key==="Enter"&&T(),m.key==="Escape"&&v(!1)},className:b("w-full border border-synertech-primary-500 rounded px-1 py-0.5 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 outline-none",Ge[i])})}function ln(s,d){let{columns:i,data:p,rowKey:l,mode:v="client",sortable:G=!1,multiSort:R=!1,sort:C,defaultSort:T,onSort:m,pagination:z=!1,page:re,onPageChange:J,onPageSizeChange:B,totalItems:ne,selectable:L=!1,selectionMode:u="multiple",selectedRows:E,onSelectionChange:U,searchable:ot=!1,searchPlaceholder:Ht,searchValue:he,onSearch:Se,filters:Q,onFilterChange:ae,expandable:oe=!1,expandedContent:st,expandedRows:Ie,onExpandChange:it,editable:lt=!1,onCellEdit:Lt,reorderable:se=!1,onReorder:dt,columnReorderable:j=!1,onColumnReorder:ct,columnToggle:ut=!1,hiddenColumns:Pe,onColumnVisibilityChange:gt,groupBy:Ne,renderGroupHeader:pt,exportable:mt=!1,exportFormats:Vt=["csv","json"],exportFilename:yt="export",exportNeutralizeFormulas:bt,virtualized:D=!1,rowHeight:q=40,virtualHeight:ft=400,density:w="default",striped:ht=!1,bordered:Fe=!1,borderless:Kt=!1,stickyHeader:vt=!1,maxHeight:ie,loading:Wt=!1,loadingRows:Bt=5,emptyState:Ut,labels:jt,locale:qt,showFooter:$t=!1,onRowClick:ze,onRowDoubleClick:xt,onRowContextMenu:wt,className:Xt,rowClassName:Oe,cellClassName:_t,headerClassName:Jt}=s,y=Wr(jt),Ae=Br(qt),kt=P(()=>new Intl.Collator(Ae,{numeric:!0}),[Ae]),[Qt,Ct]=f(T??[]),[Yt,Zt]=f(1),le=typeof z=="object"?z.pageSize:void 0,[er,St]=f(le??10),[tr,rr]=f(le);le!==tr&&(rr(le),le!==void 0&&St(le));let[nr,Re]=f([]),[ar,Nt]=f(""),[or,He]=f([]),[sr,ir]=f([]),[lr,dr]=f(()=>i.flatMap(e=>e.hidden?[e.key]:[])),[Le,cr]=f({}),[Te,ur]=f(()=>i.map(e=>e.key)),[Y,Ve]=f(null),[de,Rt]=f(null),[Ee,Tt]=f(!1),[Ke,gr]=f(new Set),We=Ce(null),[Et,pr]=f(0),[mr,Dt]=f(null),Be=Ce(null),Ue=Ce(!1),O=C??Qt,Gt=re??Yt,S=E??nr,De=he??ar,$=Q??or,ve=Ie??sr,Z=Pe??lr,ce=z?typeof z=="object"?z:{pageSize:10,pageSizeOptions:[10,25,50,100]}:null,xe=er;!l&&(L||oe||lt||se)&&Zr();let Mt=e=>rt(e.row,e.sourceIndex,l),V=P(()=>{let e=new Map(i.map(a=>[a.key,a])),t=Te.flatMap(a=>{let o=e.get(a);return o?[o]:[]}),r=new Set(t.map(a=>a.key));for(let a of i)r.has(a.key)||(t.push(a),r.add(a.key));return t.filter(a=>!Z.includes(a.key))},[i,Te,Z]),ue=P(()=>{let e=p.map((t,r)=>({row:t,sourceIndex:r}));if(v==="server")return e;if(De){let t=De.toLowerCase();e=e.filter(({row:r})=>V.some(a=>{let o=H(r,a.key);return String(o??"").toLowerCase().includes(t)}))}if($.length>0&&(e=e.filter(({row:t})=>$.every(r=>tn(H(t,r.column),r)))),O.length>0){let t=new Map(i.map(r=>[r.key,r]));e.sort((r,a)=>{for(let o of O){if(!o.direction)continue;let x=t.get(o.key),I=x?.sortComparator?x.sortComparator(r.row,a.row):en(H(r.row,o.key),H(a.row,o.key),kt);if(I!==0)return o.direction==="asc"?I:-I}return 0})}return e},[p,v,De,$,O,V,i,kt]),we=P(()=>ue.map(e=>e.row),[ue]),je=Ne?(Array.isArray(Ne)?Ne:[Ne]).join("\0"):"",ge=P(()=>je?je.split("\0"):[],[je]),pe=P(()=>{if(ge.length===0)return null;let e=new Map;for(let t of ue){let r=At(t.row,ge),a=e.get(r);a?a.push(t):e.set(r,[t])}return e},[ue,ge]),qe=P(()=>pe?Array.from(pe.values()).flat():ue,[pe,ue]),$e=ne??we.length,ee=Math.max(1,Math.ceil($e/xe)),K=v==="server"&&ne===void 0?Gt:Math.min(Math.max(1,Gt),ee),It=ce!==null,W=P(()=>{if(!It||v==="server")return qe;let e=(K-1)*xe;return qe.slice(e,e+xe)},[qe,It,K,xe,v]),Xe=P(()=>W.map(e=>e.row),[W]),me=P(()=>{let e=[],t=null;return W.forEach((r,a)=>{if(pe){let o=At(r.row,ge);if(o!==t&&(t=o,e.push({kind:"group",key:o,rows:pe.get(o)??[r]})),Ke.has(o))return}e.push({kind:"row",entry:r,index:a})}),e},[W,pe,ge,Ke]),Pt=mr??(typeof ie=="number"?ie:ft),ye=me.length,yr=P(()=>{if(!D)return{start:0,end:ye};let e=Math.max(1,Math.ceil(Pt/q)),t=Math.min(Et,Math.max(0,ye-e)),r=5;return{start:Math.max(0,t-r),end:Math.min(ye,t+e+r)}},[D,Et,q,Pt,ye]);Me(()=>{if(!D)return;let e=We.current;if(!e)return;let t=()=>{e.clientHeight>0&&Dt(e.clientHeight)};if(t(),typeof ResizeObserver>"u")return;let r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[D]);let _e=h(e=>{C||Ct(e),m?.(e)},[C,m]),br=h(e=>{let t=O.find(a=>a.key===e),r;if(!t||!t.direction?r="asc":t.direction==="asc"?r="desc":r=null,R){let a;r?t?a=O.map(o=>o.key===e?{key:e,direction:r}:o):a=[...O,{key:e,direction:r}]:a=O.filter(o=>o.key!==e),_e(a)}else _e(r?[{key:e,direction:r}]:[])},[O,R,_e]),N=h(e=>{let t=Math.max(1,Math.min(e,ee));re||Zt(t),J?.(t)},[re,J,ee]),fr=h(e=>{St(e),N(1),B?.(e)},[N,B]),hr=h(e=>{let t;u==="single"?t=S.includes(e)?[]:[e]:t=S.includes(e)?S.filter(r=>r!==e):[...S,e],E||Re(t),U?.(t)},[u,S,E,U]),Je=P(()=>new Set(S),[S]),Qe=h(()=>{let e=new Set(S),t=[...S];for(let r of W){let a=rt(r.row,r.sourceIndex,l);e.has(a)||(e.add(a),t.push(a))}E||Re(t),U?.(t)},[W,l,S,E,U]),Ft=h(()=>{E||Re([]),U?.([])},[E,U]),vr=h(()=>{let e=new Set(W.map(r=>rt(r.row,r.sourceIndex,l))),t=S.filter(r=>!e.has(r));E||Re(t),U?.(t)},[W,l,S,E,U]),Ye=L?W.map(Mt):[],Ze=Ye.length>0&&Ye.every(e=>Je.has(e)),xr=!Ze&&Ye.some(e=>Je.has(e)),wr=h(e=>{let t=ve.includes(e)?ve.filter(r=>r!==e):[...ve,e];Ie||ir(t),it?.(t)},[ve,Ie,it]),kr=h(e=>{let t=e.target.value;he||Nt(t),Se?.(t),N(1)},[he,Se,N]),Cr=h(e=>{let t=[...$.filter(r=>r.column!==e.column),e];Q||He(t),ae?.(t),N(1)},[$,Q,ae,N]),Sr=h(e=>{let t=$.filter(r=>r.column!==e);Q||He(t),ae?.(t),N(1)},[$,Q,ae,N]),Nr=h(e=>{let t=Z.includes(e)?Z.filter(r=>r!==e):[...Z,e];Pe||dr(t),gt?.(t)},[Z,Pe,gt]),Rr=h((e,t)=>{e.preventDefault(),e.stopPropagation(),Ue.current=!0;let r=e.clientX,a=Le[t]??e.currentTarget.parentElement?.getBoundingClientRect().width??100,o=i.find(k=>k.key===t),x=o?.minWidth??50,I=o?.maxWidth??1/0,te=k=>{let X=k.clientX-r,A=Math.min(I,Math.max(x,a+X));cr(fe=>({...fe,[t]:A}))},g=()=>{document.removeEventListener("mousemove",te),document.removeEventListener("mouseup",g),setTimeout(()=>{Ue.current=!1},0)};document.addEventListener("mousemove",te),document.addEventListener("mouseup",g)},[Le,i]),M=se&&!(v==="client"&&O.some(e=>e.direction)),Tr=h((e,t)=>{M&&Ve({key:e,sourceIndex:t})},[M]),Er=h(e=>{!M||Y===null||e.preventDefault()},[M,Y]),Dr=h((e,t)=>{!M||Y===null||(Ve(null),Y.key!==e&&dt?.(Y.sourceIndex,t))},[M,Y,dt]),Gr=h(e=>{j&&Rt(e)},[j]),Mr=h(e=>{if(!j||!de||de===e)return;let t=[...Te],r=t.indexOf(de),a=t.indexOf(e);r===-1||a===-1||(t.splice(r,1),t.splice(a,0,de),ur(t),ct?.(de,e),Rt(null))},[j,de,Te,ct]),et=h(e=>{let t=V.filter(k=>k.type!=="actions"&&k.type!=="selection"&&k.type!=="expand"),r=we,a,o,x;if(e==="csv")a=Kr([t.map(k=>String(k.header)),...r.map(k=>t.map(X=>{let A=H(k,X.key);return typeof A=="number"?A:String(A??"")}))],{neutralizeFormulas:bt}),o="text/csv",x="csv";else{let k=r.map(X=>{let A={};for(let fe of t)A[fe.key]=H(X,fe.key);return A});a=JSON.stringify(k,null,2),o="application/json",x="json"}let I=new Blob([a],{type:o}),te=URL.createObjectURL(I),g=document.createElement("a");g.href=te,g.download=`${yt}.${x}`,g.click(),URL.revokeObjectURL(te)},[V,we,yt,bt]);Me(()=>{if(!Ee)return;let e=t=>{Be.current&&!Be.current.contains(t.target)&&Tt(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[Ee]),Vr(d,()=>({getVisibleData:()=>Xe,resetFilters:()=>{Q||He([]),he||Nt(""),ae?.([]),Se?.(""),N(1)},resetSort:()=>{C||Ct([]),m?.([])},selectAll:Qe,deselectAll:Ft,exportData:et,scrollToRow:e=>{let t=We.current;if(!t||!D)return;let r=-1;for(let a=0;a<me.length;a++){let o=me[a];if(o.kind==="group")r=a;else if(o.index>=e){o.index===e&&(r=a);break}}r>=0&&(t.scrollTop=r*q)}}),[Xe,Q,he,C,ae,Se,m,N,Qe,Ft,et,D,q,me]);let tt=e=>{let t={},r=Le[e.key]??e.width;return r&&(t.width=typeof r=="number"?`${r}px`:r,t.minWidth=typeof r=="number"?`${r}px`:r),e.sticky&&(t.position="sticky",t[e.sticky]=0,t.zIndex=10),t},be=V.length+(L?1:0)+(oe?1:0)+(se?1:0),Ir=e=>{let t=G&&e.sortable!==!1&&e.type!=="actions",r=O.find(o=>o.key===e.key),a=e.filterable&&(e.filterType||e.filterOptions);return c("th",{className:b(F[w],Ge[w],"relative font-semibold text-gray-700 dark:text-gray-300 whitespace-nowrap",e.align==="center"&&"text-center",e.align==="right"&&"text-right",t&&"cursor-pointer select-none hover:bg-gray-100 dark:hover:bg-gray-700",Fe&&"border border-gray-200 dark:border-gray-700",e.sticky&&"bg-gray-50 dark:bg-gray-800",e.headerClassName,Jt),style:tt(e),onClick:t?()=>{Ue.current||br(e.key)}:void 0,draggable:j,onDragStart:j?()=>Gr(e.key):void 0,onDragOver:j?o=>o.preventDefault():void 0,onDrop:j?()=>Mr(e.key):void 0,"aria-sort":r?.direction==="asc"?"ascending":r?.direction==="desc"?"descending":void 0,children:[c("div",{className:"flex items-center gap-1",children:[e.renderHeader?e.renderHeader(e):e.header,t&&n("span",{className:"inline-flex ml-1",children:r?.direction==="asc"?n(jr,{}):r?.direction==="desc"?n(qr,{}):n($r,{})}),a&&n(on,{column:e,value:$.find(o=>o.column===e.key),onApply:Cr,onClear:()=>Sr(e.key),labels:y})]}),e.resizable!==!1&&n("div",{className:"absolute top-0 right-0 w-1 h-full cursor-col-resize hover:bg-synertech-primary-500 opacity-0 hover:opacity-100",onMouseDown:o=>Rr(o,e.key)})]},e.key)},ke=D?Ur[w]:F[w],zt=D?{height:q}:void 0,Pr=(e,t)=>{let{row:r,sourceIndex:a}=e,o=Mt(e),x=Je.has(o),I=ve.includes(o),te=typeof Oe=="function"?Oe(r,t):Oe;return c(Hr.Fragment,{children:[c("tr",{className:b("border-b border-gray-200 dark:border-gray-700 transition-colors",D&&"whitespace-nowrap",ht&&t%2===1&&"bg-gray-50/50 dark:bg-gray-800/50",x&&"bg-synertech-primary-50 dark:bg-synertech-primary-900/20",ze&&"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50",Y?.key===o&&"opacity-50",te),onClick:ze?()=>ze(r,t):void 0,onDoubleClick:xt?()=>xt(r,t):void 0,onContextMenu:wt?g=>wt(r,t,g):void 0,draggable:M,onDragStart:M?()=>Tr(o,a):void 0,onDragOver:M?Er:void 0,onDrop:M?()=>Dr(o,a):void 0,onDragEnd:M?()=>Ve(null):void 0,"data-row-key":o,"aria-selected":L?x:void 0,style:zt,children:[se&&n("td",{className:b(ke,M?"cursor-grab active:cursor-grabbing":"cursor-not-allowed opacity-40"),children:n(_r,{})}),L&&n("td",{className:b(ke,"w-10"),children:n("input",{type:"checkbox",checked:x,onChange:()=>hr(o),onClick:g=>g.stopPropagation(),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":_(y.dataGridSelectRow,{row:o})})}),oe&&n("td",{className:b(ke,"w-10"),children:n("button",{type:"button",onClick:g=>{g.stopPropagation(),wr(o)},className:"p-0.5 rounded hover:bg-gray-200 dark:hover:bg-gray-600 cursor-pointer","aria-label":I?y.dataGridCollapseRow:y.dataGridExpandRow,"aria-expanded":I,children:n(Ot,{className:b("transition-transform",I&&"rotate-180")})})}),V.map(g=>{let k=H(r,g.key),X=g.colSpan?.(r,t);if(X===0)return null;let A=lt&&g.editable!==!1&&g.type!=="actions";return n("td",{className:b(ke,Ge[w],"text-gray-700 dark:text-gray-300",g.align==="center"&&"text-center",g.align==="right"&&"text-right",Fe&&"border border-gray-200 dark:border-gray-700",g.sticky&&(x?"bg-synertech-primary-50 dark:bg-synertech-primary-900/20":ht&&t%2===1?"bg-gray-50/50 dark:bg-gray-800/50":"bg-white dark:bg-gray-900"),g.cellClassName,_t),style:tt(g),colSpan:X,children:A?n(sn,{value:k,onSave:fe=>Lt?.(o,g.key,fe),density:w,labels:y}):g.render?g.render(k,r,t):String(k??"")},g.key)})]}),oe&&I&&st&&n("tr",{className:"bg-gray-50 dark:bg-gray-800/70",children:n("td",{colSpan:be,className:b(F[w]),children:st(r,t)})})]},o)},Fr=e=>{let{key:t,rows:r}=e,a=Ke.has(t);return n("tr",{className:b("bg-gray-100 dark:bg-gray-800 font-medium",D&&"whitespace-nowrap"),style:zt,children:n("td",{colSpan:be,className:b(ke,"cursor-pointer"),onClick:()=>{gr(o=>{let x=new Set(o);return x.has(t)?x.delete(t):x.add(t),x})},children:c("div",{className:"flex items-center gap-2",children:[n(Ot,{className:b("transition-transform",a&&"-rotate-90")}),pt?pt(t,H(r[0].row,ge[0]),r.map(o=>o.row)):`${t} (${r.length})`]})})},`group-${t}`)},zr=()=>{if(Wt)return Array.from({length:Bt}).map((a,o)=>n(an,{cols:be,density:w},o));if(Xe.length===0)return n("tr",{children:n("td",{colSpan:be,className:b("text-center text-gray-500 dark:text-gray-400",F[w]),children:Ut??y.dataGridNoData})});let e=a=>a.kind==="row"?Pr(a.entry,a.index):Fr(a);if(!D)return me.map(e);let{start:t,end:r}=yr;return c(dn,{children:[t>0&&n("tr",{"aria-hidden":"true",children:n("td",{colSpan:be,style:{height:t*q,padding:0}})}),me.slice(t,r).map(e),r<ye&&n("tr",{"aria-hidden":"true",children:n("td",{colSpan:be,style:{height:(ye-r)*q,padding:0}})})]})},Or=(e,t)=>{let r=rn(we,e.key,t);return e.renderAggregate?e.renderAggregate(r??0,we):r===null?"":nn(t,r.toLocaleString(Ae),y)},Ar=()=>!$t||!V.some(t=>t.aggregate)?null:n("tfoot",{children:c("tr",{className:"bg-gray-50 dark:bg-gray-800 font-semibold border-t-2 border-gray-300 dark:border-gray-600",children:[se&&n("td",{className:F[w]}),L&&n("td",{className:F[w]}),oe&&n("td",{className:F[w]}),V.map(t=>n("td",{className:b(F[w],Ge[w],"text-gray-700 dark:text-gray-300",t.align==="center"&&"text-center",t.align==="right"&&"text-right",Fe&&"border border-gray-200 dark:border-gray-700"),style:tt(t),children:t.aggregate?Or(t,t.aggregate):""},t.key))]})});return c("div",{className:b("flex flex-col gap-3",Xt),children:[(ot||mt||ut)&&c("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[c("div",{className:"flex items-center gap-3 flex-1",children:[ot&&c("div",{className:"relative flex-1 max-w-xs",children:[n("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:n(Xr,{})}),n("input",{type:"text",value:De,onChange:kr,placeholder:Ht??y.dataGridSearchPlaceholder,className:"w-full pl-9 pr-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500","aria-label":y.dataGridSearch})]}),S.length>0&&n("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:_(y.dataGridSelectedCount,{count:S.length})})]}),c("div",{className:"flex items-center gap-2",children:[ut&&c("div",{className:"relative",ref:Be,children:[n("button",{type:"button",onClick:()=>Tt(!Ee),className:"p-1.5 rounded-md border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":y.dataGridToggleColumns,title:y.dataGridToggleColumns,children:n(Yr,{})}),Ee&&n("div",{className:"absolute z-50 right-0 top-full mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg p-2 min-w-[180px]",children:i.filter(e=>e.type!=="selection"&&e.type!=="expand").map(e=>c("label",{className:"flex items-center gap-2 px-2 py-1.5 text-sm rounded hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:[n("input",{type:"checkbox",checked:!Z.includes(e.key),onChange:()=>Nr(e.key),className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer"}),n("span",{className:"text-gray-700 dark:text-gray-300",children:String(e.header)})]},e.key))})]}),mt&&Vt.map(e=>c("button",{type:"button",onClick:()=>et(e),className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs font-medium rounded-md border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",title:_(y.dataGridExportAs,{format:e.toUpperCase()}),children:[n(Qr,{}),e.toUpperCase()]},e))]})]}),n("div",{ref:We,className:b("overflow-auto rounded-lg",!Kt&&"border border-gray-200 dark:border-gray-700",vt&&"relative"),style:ie?{maxHeight:typeof ie=="number"?`${ie}px`:ie}:D?{maxHeight:ft,overflow:"auto"}:void 0,onScroll:D?e=>{let t=e.currentTarget;pr(Math.floor(t.scrollTop/q)),t.clientHeight>0&&Dt(t.clientHeight)}:void 0,children:c("table",{className:"w-full text-left",children:[n("thead",{className:b("bg-gray-50 dark:bg-gray-800 text-xs uppercase",vt&&"sticky top-0 z-20"),children:c("tr",{children:[se&&n("th",{className:b(F[w],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),L&&n("th",{className:b(F[w],"w-10"),children:u==="multiple"&&n("input",{type:"checkbox",checked:Ze,ref:e=>{e&&(e.indeterminate=xr)},onChange:Ze?vr:Qe,className:"rounded border-gray-300 dark:border-gray-600 cursor-pointer","aria-label":y.dataGridSelectAllRows})}),oe&&n("th",{className:b(F[w],"w-10 font-semibold text-gray-700 dark:text-gray-300")}),V.map(Ir)]})}),n("tbody",{children:zr()}),Ar()]})}),ce&&c("div",{className:"flex items-center justify-between flex-wrap gap-3 text-sm text-gray-600 dark:text-gray-400",children:[c("div",{className:"flex items-center gap-3",children:[ce.showTotalItems!==!1&&n("span",{children:_($e===1?y.dataGridItemCount:y.dataGridItemsCount,{count:$e})}),ce.showPageSizeSelector!==!1&&ce.pageSizeOptions&&c("div",{className:"flex items-center gap-1.5",children:[n("span",{children:y.dataGridRowsPerPage}),n("select",{value:xe,onChange:e=>fr(Number(e.target.value)),className:"border border-gray-300 dark:border-gray-600 rounded px-1.5 py-0.5 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 text-sm",children:ce.pageSizeOptions.map(e=>n("option",{value:e,children:e},e))})]})]}),c("div",{className:"flex items-center gap-1",children:[n("span",{className:"mr-2",children:_(y.dataGridPageOf,{page:K,total:ee})}),n("button",{type:"button",onClick:()=>N(1),disabled:K<=1,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":y.dataGridFirstPage,children:"\xAB\xAB"}),n("button",{type:"button",onClick:()=>N(K-1),disabled:K<=1,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":y.dataGridPreviousPage,children:"\xAB"}),n("button",{type:"button",onClick:()=>N(K+1),disabled:K>=ee,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":y.dataGridNextPage,children:"\xBB"}),n("button",{type:"button",onClick:()=>N(ee),disabled:K>=ee,className:"px-2 py-1 rounded border border-gray-300 dark:border-gray-600 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","aria-label":y.dataGridLastPage,children:"\xBB\xBB"})]})]})]})}var bn=Lr(ln);export{bn as DataGrid,yn as resetRowKeyWarning};
@@ -1 +1 @@
1
- "use strict";"use client";var C=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var G=(o,e)=>{for(var r in e)C(o,r,{get:e[r],enumerable:!0})},V=(o,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of j(e))!z.call(o,s)&&s!==r&&C(o,s,{get:()=>e[s],enumerable:!(i=q(e,s))||i.enumerable});return o};var X=o=>V(C({},"__esModule",{value:!0}),o);var ee={};G(ee,{Detachable:()=>A});module.exports=X(ee);var n=require("react"),S=require("react-dom"),x=require("../../lib/cn.cjs"),$=require("react/jsx-runtime"),Y=500,B=800,J=600;function K(o,e,r){let i=[`width=${o}`,`height=${e}`,"menubar=no","toolbar=no","location=no","status=no","scrollbars=yes","resizable=yes"];if(r.left!==void 0)i.push(`left=${r.left}`);else if(r.center!==!1&&typeof window<"u"){let s=window.screenLeft??window.screenX,c=window.screenTop??window.screenY,t=window.outerWidth??screen.availWidth,u=window.outerHeight??screen.availHeight;i.push(`left=${s+(t-o)/2}`),i.push(`top=${c+(u-e)/2}`)}if(r.top!==void 0){let s=i.filter(c=>!c.startsWith("top="));return s.push(`top=${r.top}`),s.join(",")}return i.join(",")}function Q(o,e){o.querySelectorAll("style").forEach(t=>{let u=e.createElement("style");u.textContent=t.textContent,e.head.appendChild(u)}),o.querySelectorAll('link[rel="stylesheet"]').forEach(t=>{let u=e.createElement("link");u.rel="stylesheet",u.href=t.href,t.crossOrigin&&(u.crossOrigin=t.crossOrigin),e.head.appendChild(u)});let s=o.documentElement.className;s&&(e.documentElement.className=s);let c=o.body.className;c&&(e.body.className=c)}function Z(o,e){let r=new MutationObserver(i=>{for(let s of i)for(let c of Array.from(s.addedNodes))if(c instanceof HTMLStyleElement){let t=e.createElement("style");t.textContent=c.textContent,e.head.appendChild(t)}else if(c instanceof HTMLLinkElement&&c.rel==="stylesheet"){let t=e.createElement("link");t.rel="stylesheet",t.href=c.href,e.head.appendChild(t)}});return r.observe(o.head,{childList:!0}),r}var A=(0,n.forwardRef)(function({children:e,detached:r,defaultDetached:i=!1,onClose:s,onDetach:c,title:t="",width:u=B,height:R=J,left:T,top:N,center:H=!0,copyStyles:I=!0,closeOnParentUnmount:D=!0,className:F,windowClassName:O,onPopupBlocked:g},U){let f=r!==void 0,[y,v]=(0,n.useState)(i),p=f?r:y,[M,W]=(0,n.useState)(null),l=(0,n.useRef)(null),h=(0,n.useRef)(null),b=(0,n.useRef)(null),w=(0,n.useRef)(!1),E=(0,n.useRef)({width:u,height:R,left:T,top:N,center:H,shouldCopyStyles:I,title:t,windowClassName:O,closeOnParentUnmount:D});E.current={width:u,height:R,left:T,top:N,center:H,shouldCopyStyles:I,title:t,windowClassName:O,closeOnParentUnmount:D};let m=(0,n.useCallback)(()=>{h.current&&(clearInterval(h.current),h.current=null),b.current&&(b.current.disconnect(),b.current=null),W(null)},[]),k=(0,n.useCallback)(()=>{l.current&&!l.current.closed&&l.current.close(),l.current=null,m()},[m]),P=(0,n.useCallback)(()=>{if(typeof window>"u"||w.current||l.current&&!l.current.closed)return;w.current=!0;let a=E.current,_=K(a.width,a.height,{center:a.center,left:a.left,top:a.top}),d=window.open("","",_);if(!d){w.current=!1,g?.();return}l.current=d,d.document.title=a.title||document.title;let L=d.document.createElement("div");a.windowClassName&&(L.className=a.windowClassName),d.document.body.appendChild(L),W(L),a.shouldCopyStyles&&(Q(document,d.document),b.current=Z(document,d.document)),h.current=setInterval(()=>{d.closed&&(m(),l.current=null,f||v(!1),s?.())},Y),w.current=!1,c?.()},[f,s,c,g,m]);return(0,n.useEffect)(()=>{p?P():k()},[p,P,k]),(0,n.useEffect)(()=>{l.current&&!l.current.closed&&t&&(l.current.document.title=t)},[t]),(0,n.useEffect)(()=>()=>{E.current.closeOnParentUnmount&&l.current&&!l.current.closed&&l.current.close(),m(),l.current=null},[m]),(0,n.useImperativeHandle)(U,()=>({detach:()=>{f||v(!0)},attach:()=>{f||v(!1)},get isDetached(){return f?!!r:y},get window(){return l.current}}),[f,r,y]),p&&M?(0,S.createPortal)(e,M):p?null:(0,$.jsx)("div",{className:(0,x.cn)(F),children:e})});A.displayName="Detachable";0&&(module.exports={Detachable});
1
+ "use strict";"use client";var k=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var Q=(o,e)=>{for(var r in e)k(o,r,{get:e[r],enumerable:!0})},Z=(o,e,r,u)=>{if(e&&typeof e=="object"||typeof e=="function")for(let l of J(e))!K.call(o,l)&&l!==r&&k(o,l,{get:()=>e[l],enumerable:!(u=Y(e,l))||u.enumerable});return o};var ee=o=>Z(k({},"__esModule",{value:!0}),o);var ce={};Q(ce,{Detachable:()=>z});module.exports=ee(ce);var n=require("react"),_=require("../../lib/cn.cjs"),q=require("../../lib/layer-document.cjs"),j=require("./useMovableContent.cjs"),p=require("react/jsx-runtime"),ne=500,te=800,re=600;function oe(o,e,r){let u=[`width=${o}`,`height=${e}`,"menubar=no","toolbar=no","location=no","status=no","scrollbars=yes","resizable=yes"];if(r.left!==void 0)u.push(`left=${r.left}`);else if(r.center!==!1&&typeof window<"u"){let l=window.screenLeft??window.screenX,c=window.screenTop??window.screenY,t=window.outerWidth??screen.availWidth,i=window.outerHeight??screen.availHeight;u.push(`left=${l+(t-o)/2}`),u.push(`top=${c+(i-e)/2}`)}if(r.top!==void 0){let l=u.filter(c=>!c.startsWith("top="));return l.push(`top=${r.top}`),l.join(",")}return u.join(",")}function le(o,e){o.querySelectorAll("style").forEach(t=>{let i=e.createElement("style");i.textContent=t.textContent,e.head.appendChild(i)}),o.querySelectorAll('link[rel="stylesheet"]').forEach(t=>{let i=e.createElement("link");i.rel="stylesheet",i.href=t.href,t.crossOrigin&&(i.crossOrigin=t.crossOrigin),e.head.appendChild(i)});let l=o.documentElement.className;l&&(e.documentElement.className=l);let c=o.body.className;c&&(e.body.className=c)}function se(o,e){let r=new MutationObserver(u=>{for(let l of u)for(let c of Array.from(l.addedNodes))if(c instanceof HTMLStyleElement){let t=e.createElement("style");t.textContent=c.textContent,e.head.appendChild(t)}else if(c instanceof HTMLLinkElement&&c.rel==="stylesheet"){let t=e.createElement("link");t.rel="stylesheet",t.href=c.href,e.head.appendChild(t)}});return r.observe(o.head,{childList:!0}),r}var z=(0,n.forwardRef)(function({children:e,detached:r,defaultDetached:u=!1,onClose:l,onDetach:c,title:t="",width:i=te,height:H=re,left:I,top:M,center:O=!0,copyStyles:P=!0,closeOnParentUnmount:W=!0,className:G,windowClassName:S,onPopupBlocked:x},V){let f=r!==void 0,[E,b]=(0,n.useState)(u),A=f?r:E,[C,$]=(0,n.useState)(null),a=(0,n.useRef)(null),w=(0,n.useRef)(null),y=(0,n.useRef)(null),v=(0,n.useRef)(!1),R=(0,n.useRef)(null),g=(0,n.useRef)({width:i,height:H,left:I,top:M,center:O,shouldCopyStyles:P,title:t,windowClassName:S,closeOnParentUnmount:W});g.current={width:i,height:H,left:I,top:M,center:O,shouldCopyStyles:P,title:t,windowClassName:S,closeOnParentUnmount:W};let L=(0,n.useRef)({onClose:l,onDetach:c,onPopupBlocked:x});L.current={onClose:l,onDetach:c,onPopupBlocked:x};let h=(0,j.useMovableContent)(C),T=(0,n.useRef)(h.bringBack);T.current=h.bringBack;let m=(0,n.useCallback)(()=>{R.current?.(),R.current=null,w.current&&(clearInterval(w.current),w.current=null),y.current&&(y.current.disconnect(),y.current=null),$(null)},[]),B=(0,n.useCallback)(()=>{T.current();let s=a.current;a.current=null,m(),s&&!s.closed&&s.close()},[m]),F=(0,n.useCallback)(()=>{if(typeof window>"u"||v.current||a.current&&!a.current.closed)return;v.current=!0;let s=g.current,X=oe(s.width,s.height,{center:s.center,left:s.left,top:s.top}),d=window.open("","",X);if(!d){v.current=!1,f||b(!1),L.current.onPopupBlocked?.();return}a.current=d,d.document.title=s.title||document.title;let D=d.document.createElement("div");s.windowClassName&&(D.className=s.windowClassName),d.document.body.appendChild(D),$(D),s.shouldCopyStyles&&(le(document,d.document),y.current=se(document,d.document));let U=!1,N=()=>{U||(U=!0,T.current(),m(),a.current=null,f||b(!1),L.current.onClose?.())};d.addEventListener("pagehide",N),R.current=()=>d.removeEventListener("pagehide",N),w.current=setInterval(()=>{d.closed&&N()},ne),v.current=!1,L.current.onDetach?.()},[f,m]);return(0,n.useEffect)(()=>{A?F():B()},[A,F,B]),(0,n.useEffect)(()=>{a.current&&!a.current.closed&&t&&(a.current.document.title=t)},[t]),(0,n.useEffect)(()=>()=>{let s=a.current;m(),a.current=null,g.current.closeOnParentUnmount&&s&&!s.closed&&s.close()},[m]),(0,n.useImperativeHandle)(V,()=>({detach:()=>{f||b(!0)},attach:()=>{f||b(!1)},get isDetached(){return f?!!r:E},get window(){return a.current}}),[f,r,E]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("div",{ref:h.hostRef,className:(0,_.cn)(G),hidden:C!==null,children:h.inline(e)}),h.portal((0,p.jsx)(q.LayerDocumentProvider,{document:C?.ownerDocument??null,children:e}))]})});z.displayName="Detachable";0&&(module.exports={Detachable});
@@ -1 +1 @@
1
- "use client";import{useState as x,useRef as m,useEffect as C,useCallback as R,useImperativeHandle as U,forwardRef as _}from"react";import{createPortal as q}from"react-dom";import{cn as j}from"../../lib/cn.js";import{jsx as K}from"react/jsx-runtime";var z=500,G=800,V=600;function X(c,n,o){let i=[`width=${c}`,`height=${n}`,"menubar=no","toolbar=no","location=no","status=no","scrollbars=yes","resizable=yes"];if(o.left!==void 0)i.push(`left=${o.left}`);else if(o.center!==!1&&typeof window<"u"){let s=window.screenLeft??window.screenX,r=window.screenTop??window.screenY,e=window.outerWidth??screen.availWidth,l=window.outerHeight??screen.availHeight;i.push(`left=${s+(e-c)/2}`),i.push(`top=${r+(l-n)/2}`)}if(o.top!==void 0){let s=i.filter(r=>!r.startsWith("top="));return s.push(`top=${o.top}`),s.join(",")}return i.join(",")}function Y(c,n){c.querySelectorAll("style").forEach(e=>{let l=n.createElement("style");l.textContent=e.textContent,n.head.appendChild(l)}),c.querySelectorAll('link[rel="stylesheet"]').forEach(e=>{let l=n.createElement("link");l.rel="stylesheet",l.href=e.href,e.crossOrigin&&(l.crossOrigin=e.crossOrigin),n.head.appendChild(l)});let s=c.documentElement.className;s&&(n.documentElement.className=s);let r=c.body.className;r&&(n.body.className=r)}function B(c,n){let o=new MutationObserver(i=>{for(let s of i)for(let r of Array.from(s.addedNodes))if(r instanceof HTMLStyleElement){let e=n.createElement("style");e.textContent=r.textContent,n.head.appendChild(e)}else if(r instanceof HTMLLinkElement&&r.rel==="stylesheet"){let e=n.createElement("link");e.rel="stylesheet",e.href=r.href,n.head.appendChild(e)}});return o.observe(c.head,{childList:!0}),o}var J=_(function({children:n,detached:o,defaultDetached:i=!1,onClose:s,onDetach:r,title:e="",width:l=G,height:T=V,left:N,top:H,center:I=!0,copyStyles:D=!0,closeOnParentUnmount:O=!0,className:A,windowClassName:g,onPopupBlocked:M},$){let d=o!==void 0,[y,v]=x(i),p=d?o:y,[W,k]=x(null),t=m(null),h=m(null),b=m(null),w=m(!1),E=m({width:l,height:T,left:N,top:H,center:I,shouldCopyStyles:D,title:e,windowClassName:g,closeOnParentUnmount:O});E.current={width:l,height:T,left:N,top:H,center:I,shouldCopyStyles:D,title:e,windowClassName:g,closeOnParentUnmount:O};let f=R(()=>{h.current&&(clearInterval(h.current),h.current=null),b.current&&(b.current.disconnect(),b.current=null),k(null)},[]),P=R(()=>{t.current&&!t.current.closed&&t.current.close(),t.current=null,f()},[f]),S=R(()=>{if(typeof window>"u"||w.current||t.current&&!t.current.closed)return;w.current=!0;let u=E.current,F=X(u.width,u.height,{center:u.center,left:u.left,top:u.top}),a=window.open("","",F);if(!a){w.current=!1,M?.();return}t.current=a,a.document.title=u.title||document.title;let L=a.document.createElement("div");u.windowClassName&&(L.className=u.windowClassName),a.document.body.appendChild(L),k(L),u.shouldCopyStyles&&(Y(document,a.document),b.current=B(document,a.document)),h.current=setInterval(()=>{a.closed&&(f(),t.current=null,d||v(!1),s?.())},z),w.current=!1,r?.()},[d,s,r,M,f]);return C(()=>{p?S():P()},[p,S,P]),C(()=>{t.current&&!t.current.closed&&e&&(t.current.document.title=e)},[e]),C(()=>()=>{E.current.closeOnParentUnmount&&t.current&&!t.current.closed&&t.current.close(),f(),t.current=null},[f]),U($,()=>({detach:()=>{d||v(!0)},attach:()=>{d||v(!1)},get isDetached(){return d?!!o:y},get window(){return t.current}}),[d,o,y]),p&&W?q(n,W):p?null:K("div",{className:j(A),children:n})});J.displayName="Detachable";export{J as Detachable};
1
+ "use client";import{useState as _,useRef as f,useEffect as N,useCallback as k,useImperativeHandle as V,forwardRef as X}from"react";import{cn as Y}from"../../lib/cn.js";import{LayerDocumentProvider as J}from"../../lib/layer-document.js";import{useMovableContent as K}from"./useMovableContent.js";import{Fragment as le,jsx as q,jsxs as se}from"react/jsx-runtime";var Q=500,Z=800,ee=600;function ne(u,n,o){let i=[`width=${u}`,`height=${n}`,"menubar=no","toolbar=no","location=no","status=no","scrollbars=yes","resizable=yes"];if(o.left!==void 0)i.push(`left=${o.left}`);else if(o.center!==!1&&typeof window<"u"){let l=window.screenLeft??window.screenX,r=window.screenTop??window.screenY,e=window.outerWidth??screen.availWidth,s=window.outerHeight??screen.availHeight;i.push(`left=${l+(e-u)/2}`),i.push(`top=${r+(s-n)/2}`)}if(o.top!==void 0){let l=i.filter(r=>!r.startsWith("top="));return l.push(`top=${o.top}`),l.join(",")}return i.join(",")}function te(u,n){u.querySelectorAll("style").forEach(e=>{let s=n.createElement("style");s.textContent=e.textContent,n.head.appendChild(s)}),u.querySelectorAll('link[rel="stylesheet"]').forEach(e=>{let s=n.createElement("link");s.rel="stylesheet",s.href=e.href,e.crossOrigin&&(s.crossOrigin=e.crossOrigin),n.head.appendChild(s)});let l=u.documentElement.className;l&&(n.documentElement.className=l);let r=u.body.className;r&&(n.body.className=r)}function re(u,n){let o=new MutationObserver(i=>{for(let l of i)for(let r of Array.from(l.addedNodes))if(r instanceof HTMLStyleElement){let e=n.createElement("style");e.textContent=r.textContent,n.head.appendChild(e)}else if(r instanceof HTMLLinkElement&&r.rel==="stylesheet"){let e=n.createElement("link");e.rel="stylesheet",e.href=r.href,n.head.appendChild(e)}});return o.observe(u.head,{childList:!0}),o}var oe=X(function({children:n,detached:o,defaultDetached:i=!1,onClose:l,onDetach:r,title:e="",width:s=Z,height:H=ee,left:I,top:M,center:O=!0,copyStyles:P=!0,closeOnParentUnmount:W=!0,className:j,windowClassName:S,onPopupBlocked:x},z){let d=o!==void 0,[L,h]=_(i),A=d?o:L,[E,$]=_(null),c=f(null),b=f(null),w=f(null),y=f(!1),C=f(null),R=f({width:s,height:H,left:I,top:M,center:O,shouldCopyStyles:P,title:e,windowClassName:S,closeOnParentUnmount:W});R.current={width:s,height:H,left:I,top:M,center:O,shouldCopyStyles:P,title:e,windowClassName:S,closeOnParentUnmount:W};let v=f({onClose:l,onDetach:r,onPopupBlocked:x});v.current={onClose:l,onDetach:r,onPopupBlocked:x};let m=K(E),g=f(m.bringBack);g.current=m.bringBack;let p=k(()=>{C.current?.(),C.current=null,b.current&&(clearInterval(b.current),b.current=null),w.current&&(w.current.disconnect(),w.current=null),$(null)},[]),B=k(()=>{g.current();let t=c.current;c.current=null,p(),t&&!t.closed&&t.close()},[p]),F=k(()=>{if(typeof window>"u"||y.current||c.current&&!c.current.closed)return;y.current=!0;let t=R.current,G=ne(t.width,t.height,{center:t.center,left:t.left,top:t.top}),a=window.open("","",G);if(!a){y.current=!1,d||h(!1),v.current.onPopupBlocked?.();return}c.current=a,a.document.title=t.title||document.title;let T=a.document.createElement("div");t.windowClassName&&(T.className=t.windowClassName),a.document.body.appendChild(T),$(T),t.shouldCopyStyles&&(te(document,a.document),w.current=re(document,a.document));let U=!1,D=()=>{U||(U=!0,g.current(),p(),c.current=null,d||h(!1),v.current.onClose?.())};a.addEventListener("pagehide",D),C.current=()=>a.removeEventListener("pagehide",D),b.current=setInterval(()=>{a.closed&&D()},Q),y.current=!1,v.current.onDetach?.()},[d,p]);return N(()=>{A?F():B()},[A,F,B]),N(()=>{c.current&&!c.current.closed&&e&&(c.current.document.title=e)},[e]),N(()=>()=>{let t=c.current;p(),c.current=null,R.current.closeOnParentUnmount&&t&&!t.closed&&t.close()},[p]),V(z,()=>({detach:()=>{d||h(!0)},attach:()=>{d||h(!1)},get isDetached(){return d?!!o:L},get window(){return c.current}}),[d,o,L]),se(le,{children:[q("div",{ref:m.hostRef,className:Y(j),hidden:E!==null,children:m.inline(n)}),m.portal(q(J,{document:E?.ownerDocument??null,children:n}))]})});oe.displayName="Detachable";export{oe as Detachable};
@@ -0,0 +1 @@
1
+ "use strict";"use client";var c=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var d=(n,t)=>{for(var e in t)c(n,e,{get:t[e],enumerable:!0})},m=(n,t,e,u)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of f(t))!p.call(n,r)&&r!==e&&c(n,r,{get:()=>t[r],enumerable:!(u=i(t,r))||u.enumerable});return n};var y=n=>m(c({},"__esModule",{value:!0}),n);var C={};d(C,{useMovableContent:()=>b});module.exports=y(C);var o=require("react"),a=require("react-dom"),E=()=>()=>{};function b(n){let t=(0,o.useSyncExternalStore)(E,()=>!0,()=>!1),[e]=(0,o.useState)(()=>{if(typeof document>"u")return null;let l=document.createElement("div");return l.style.display="contents",l}),u=(0,o.useRef)(null),r=(0,o.useCallback)(()=>{let l=u.current;e&&l&&e.parentNode!==l&&l.appendChild(e)},[e]);(0,o.useLayoutEffect)(()=>{!e||!t||(n?e.parentNode!==n&&n.appendChild(e):r())},[e,n,t,r]);let s=t&&e!==null;return{hostRef:u,bringBack:r,inline:l=>s?null:l,portal:l=>s?(0,a.createPortal)(l,e):null}}0&&(module.exports={useMovableContent});
@@ -0,0 +1 @@
1
+ "use client";import{useCallback as c,useLayoutEffect as s,useRef as a,useState as i,useSyncExternalStore as f}from"react";import{createPortal as p}from"react-dom";var d=()=>()=>{};function E(n){let l=f(d,()=>!0,()=>!1),[e]=i(()=>{if(typeof document>"u")return null;let t=document.createElement("div");return t.style.display="contents",t}),r=a(null),o=c(()=>{let t=r.current;e&&t&&e.parentNode!==t&&t.appendChild(e)},[e]);s(()=>{!e||!l||(n?e.parentNode!==n&&n.appendChild(e):o())},[e,n,l,o]);let u=l&&e!==null;return{hostRef:r,bringBack:o,inline:t=>u?null:t,portal:t=>u?p(t,e):null}}export{E as useMovableContent};
@@ -1 +1 @@
1
- "use strict";"use client";var u=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var B=(t,e)=>{for(var a in e)u(t,a,{get:e[a],enumerable:!0})},H=(t,e,a,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of j(e))!A.call(t,o)&&o!==a&&u(t,o,{get:()=>e[o],enumerable:!(l=T(e,o))||l.enumerable});return t};var U=t=>H(u({},"__esModule",{value:!0}),t);var K={};B(K,{Drawer:()=>v});module.exports=U(K);var i=require("react"),p=require("react-dom"),w=require("../../hooks/useDialogA11y.cjs"),s=require("../../lib/cn.cjs"),y=require("../../lib/i18n.cjs"),r=require("react/jsx-runtime"),$={left:{sm:"w-64",md:"w-80",lg:"w-96",xl:"w-[32rem]",full:"w-full",half:"w-1/2 h-full"},right:{sm:"w-64",md:"w-80",lg:"w-96",xl:"w-[32rem]",full:"w-full",half:"w-1/2 h-full"},top:{sm:"h-64",md:"h-80",lg:"h-96",xl:"h-[32rem]",full:"h-full",half:"w-1/2 h-full"},bottom:{sm:"h-64",md:"h-80",lg:"h-96",xl:"h-[32rem]",full:"h-full",half:"w-1/2 h-full"}},q={left:"left-0 top-0 bottom-0",right:"right-0 top-0 bottom-0",top:"top-0 left-0 right-0",bottom:"bottom-0 left-0 right-0"},G={left:"animate-in slide-in-from-left duration-300",right:"animate-in slide-in-from-right duration-300",top:"animate-in slide-in-from-top duration-300",bottom:"animate-in slide-in-from-bottom duration-300"},J=(0,r.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})});function v({open:t,onClose:e,children:a,position:l="right",size:o="md",customWidth:d,customHeight:f,showOverlay:x=!0,closeOnOverlayClick:c=!0,closeOnEscape:D=!0,title:n,footer:m,className:k,overlayClassName:N,closeLabel:R,"aria-label":C,trapFocus:I=!0,initialFocus:P,returnFocus:z,lockScroll:F=!0}){let L=!!(d||f),g=(0,i.useRef)(null),M=(0,y.useUILabels)(),h=`${(0,i.useId)()}-drawer-title`,{dialogRef:S,dialogProps:E}=(0,w.useDialogA11y)({open:t,onClose:e,closeOnEscape:D,trapFocus:I,initialFocus:P,returnFocus:z,lockScroll:F,keepInteractive:[g]}),O=(0,i.useCallback)(()=>{c&&e()},[c,e]);if(!t)return null;let b=(0,r.jsxs)(r.Fragment,{children:[x&&(0,r.jsx)("div",{ref:g,className:(0,s.cn)("fixed inset-0 bg-black/50 z-40 transition-opacity","animate-in fade-in duration-200",N),onClick:O,"aria-hidden":"true"}),(0,r.jsxs)("div",{ref:S,...E,"aria-labelledby":n?h:void 0,"aria-label":n?void 0:C,className:(0,s.cn)("fixed z-50 bg-white dark:bg-gray-900","shadow-xl overflow-hidden","flex flex-col focus:outline-none",q[l],!L&&$[l][o],G[l],k),style:{...d?{width:d}:{},...f?{height:f}:{}},children:[n&&(0,r.jsxs)("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:[(0,r.jsx)("h2",{id:h,className:"text-lg font-semibold text-gray-900 dark:text-white",children:n}),(0,r.jsx)("button",{type:"button",onClick:e,className:(0,s.cn)("rounded-lg p-1.5 text-gray-500 dark:text-gray-400 hover:bg-gray-100 hover:text-gray-900","dark:hover:bg-gray-800 dark:hover:text-white","focus:outline-none focus:ring-2 focus:ring-gray-300 dark:focus:ring-gray-600"),"aria-label":R??M.closeDrawer,children:J})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:a}),m&&(0,r.jsx)("div",{className:"px-6 py-4 border-t border-gray-200 dark:border-gray-700",children:m})]})]});return typeof document<"u"?(0,p.createPortal)(b,document.body):b}v.displayName="Drawer";0&&(module.exports={Drawer});
1
+ "use strict";"use client";var c=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var B=(t,r)=>{for(var a in r)c(t,a,{get:r[a],enumerable:!0})},H=(t,r,a,l)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of j(r))!A.call(t,o)&&o!==a&&c(t,o,{get:()=>r[o],enumerable:!(l=T(r,o))||l.enumerable});return t};var U=t=>H(c({},"__esModule",{value:!0}),t);var K={};B(K,{Drawer:()=>y});module.exports=U(K);var i=require("react"),b=require("../../hooks/useDialogA11y.cjs"),s=require("../../lib/cn.cjs"),p=require("../../lib/i18n.cjs"),w=require("../../lib/layer-document.cjs"),e=require("react/jsx-runtime"),$={left:{sm:"w-64",md:"w-80",lg:"w-96",xl:"w-[32rem]",full:"w-full",half:"w-1/2 h-full"},right:{sm:"w-64",md:"w-80",lg:"w-96",xl:"w-[32rem]",full:"w-full",half:"w-1/2 h-full"},top:{sm:"h-64",md:"h-80",lg:"h-96",xl:"h-[32rem]",full:"h-full",half:"w-1/2 h-full"},bottom:{sm:"h-64",md:"h-80",lg:"h-96",xl:"h-[32rem]",full:"h-full",half:"w-1/2 h-full"}},q={left:"left-0 top-0 bottom-0",right:"right-0 top-0 bottom-0",top:"top-0 left-0 right-0",bottom:"bottom-0 left-0 right-0"},G={left:"animate-in slide-in-from-left duration-300",right:"animate-in slide-in-from-right duration-300",top:"animate-in slide-in-from-top duration-300",bottom:"animate-in slide-in-from-bottom duration-300"},J=(0,e.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})});function y({open:t,onClose:r,children:a,position:l="right",size:o="md",customWidth:d,customHeight:f,showOverlay:v=!0,closeOnOverlayClick:u=!0,closeOnEscape:x=!0,title:n,footer:g,className:D,overlayClassName:k,closeLabel:N,"aria-label":R,trapFocus:P=!0,initialFocus:C,returnFocus:I,lockScroll:L=!0}){let z=!!(d||f),m=(0,i.useRef)(null),F=(0,p.useUILabels)(),h=`${(0,i.useId)()}-drawer-title`,{dialogRef:M,dialogProps:S}=(0,b.useDialogA11y)({open:t,onClose:r,closeOnEscape:x,trapFocus:P,initialFocus:C,returnFocus:I,lockScroll:L,keepInteractive:[m]}),E=(0,i.useCallback)(()=>{u&&r()},[u,r]);if(!t)return null;let O=(0,e.jsxs)(e.Fragment,{children:[v&&(0,e.jsx)("div",{ref:m,className:(0,s.cn)("fixed inset-0 bg-black/50 z-40 transition-opacity","animate-in fade-in duration-200",k),onClick:E,"aria-hidden":"true"}),(0,e.jsxs)("div",{ref:M,...S,"aria-labelledby":n?h:void 0,"aria-label":n?void 0:R,className:(0,s.cn)("fixed z-50 bg-white dark:bg-gray-900","shadow-xl overflow-hidden","flex flex-col focus:outline-none",q[l],!z&&$[l][o],G[l],D),style:{...d?{width:d}:{},...f?{height:f}:{}},children:[n&&(0,e.jsxs)("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:[(0,e.jsx)("h2",{id:h,className:"text-lg font-semibold text-gray-900 dark:text-white",children:n}),(0,e.jsx)("button",{type:"button",onClick:r,className:(0,s.cn)("rounded-lg p-1.5 text-gray-500 dark:text-gray-400 hover:bg-gray-100 hover:text-gray-900","dark:hover:bg-gray-800 dark:hover:text-white","focus:outline-none focus:ring-2 focus:ring-gray-300 dark:focus:ring-gray-600"),"aria-label":N??F.closeDrawer,children:J})]}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:a}),g&&(0,e.jsx)("div",{className:"px-6 py-4 border-t border-gray-200 dark:border-gray-700",children:g})]})]});return(0,e.jsx)(w.LayerPortal,{children:O})}y.displayName="Drawer";0&&(module.exports={Drawer});
@@ -1 +1 @@
1
- "use client";import{useCallback as L,useId as M,useRef as S}from"react";import{createPortal as E}from"react-dom";import{useDialogA11y as O}from"../../hooks/useDialogA11y.js";import{cn as i}from"../../lib/cn.js";import{useUILabels as T}from"../../lib/i18n.js";import{Fragment as $,jsx as e,jsxs as n}from"react/jsx-runtime";var j={left:{sm:"w-64",md:"w-80",lg:"w-96",xl:"w-[32rem]",full:"w-full",half:"w-1/2 h-full"},right:{sm:"w-64",md:"w-80",lg:"w-96",xl:"w-[32rem]",full:"w-full",half:"w-1/2 h-full"},top:{sm:"h-64",md:"h-80",lg:"h-96",xl:"h-[32rem]",full:"h-full",half:"w-1/2 h-full"},bottom:{sm:"h-64",md:"h-80",lg:"h-96",xl:"h-[32rem]",full:"h-full",half:"w-1/2 h-full"}},A={left:"left-0 top-0 bottom-0",right:"right-0 top-0 bottom-0",top:"top-0 left-0 right-0",bottom:"bottom-0 left-0 right-0"},B={left:"animate-in slide-in-from-left duration-300",right:"animate-in slide-in-from-right duration-300",top:"animate-in slide-in-from-top duration-300",bottom:"animate-in slide-in-from-bottom duration-300"},H=e("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})});function U({open:s,onClose:r,children:g,position:o="right",size:h="md",customWidth:a,customHeight:l,showOverlay:b=!0,closeOnOverlayClick:d=!0,closeOnEscape:p=!0,title:t,footer:f,className:w,overlayClassName:y,closeLabel:v,"aria-label":x,trapFocus:D=!0,initialFocus:k,returnFocus:N,lockScroll:R=!0}){let C=!!(a||l),u=S(null),I=T(),c=`${M()}-drawer-title`,{dialogRef:P,dialogProps:z}=O({open:s,onClose:r,closeOnEscape:p,trapFocus:D,initialFocus:k,returnFocus:N,lockScroll:R,keepInteractive:[u]}),F=L(()=>{d&&r()},[d,r]);if(!s)return null;let m=n($,{children:[b&&e("div",{ref:u,className:i("fixed inset-0 bg-black/50 z-40 transition-opacity","animate-in fade-in duration-200",y),onClick:F,"aria-hidden":"true"}),n("div",{ref:P,...z,"aria-labelledby":t?c:void 0,"aria-label":t?void 0:x,className:i("fixed z-50 bg-white dark:bg-gray-900","shadow-xl overflow-hidden","flex flex-col focus:outline-none",A[o],!C&&j[o][h],B[o],w),style:{...a?{width:a}:{},...l?{height:l}:{}},children:[t&&n("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:[e("h2",{id:c,className:"text-lg font-semibold text-gray-900 dark:text-white",children:t}),e("button",{type:"button",onClick:r,className:i("rounded-lg p-1.5 text-gray-500 dark:text-gray-400 hover:bg-gray-100 hover:text-gray-900","dark:hover:bg-gray-800 dark:hover:text-white","focus:outline-none focus:ring-2 focus:ring-gray-300 dark:focus:ring-gray-600"),"aria-label":v??I.closeDrawer,children:H})]}),e("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:g}),f&&e("div",{className:"px-6 py-4 border-t border-gray-200 dark:border-gray-700",children:f})]})]});return typeof document<"u"?E(m,document.body):m}U.displayName="Drawer";export{U as Drawer};
1
+ "use client";import{useCallback as F,useId as M,useRef as S}from"react";import{useDialogA11y as E}from"../../hooks/useDialogA11y.js";import{cn as i}from"../../lib/cn.js";import{useUILabels as O}from"../../lib/i18n.js";import{LayerPortal as T}from"../../lib/layer-document.js";import{Fragment as $,jsx as e,jsxs as n}from"react/jsx-runtime";var j={left:{sm:"w-64",md:"w-80",lg:"w-96",xl:"w-[32rem]",full:"w-full",half:"w-1/2 h-full"},right:{sm:"w-64",md:"w-80",lg:"w-96",xl:"w-[32rem]",full:"w-full",half:"w-1/2 h-full"},top:{sm:"h-64",md:"h-80",lg:"h-96",xl:"h-[32rem]",full:"h-full",half:"w-1/2 h-full"},bottom:{sm:"h-64",md:"h-80",lg:"h-96",xl:"h-[32rem]",full:"h-full",half:"w-1/2 h-full"}},A={left:"left-0 top-0 bottom-0",right:"right-0 top-0 bottom-0",top:"top-0 left-0 right-0",bottom:"bottom-0 left-0 right-0"},B={left:"animate-in slide-in-from-left duration-300",right:"animate-in slide-in-from-right duration-300",top:"animate-in slide-in-from-top duration-300",bottom:"animate-in slide-in-from-bottom duration-300"},H=e("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})});function U({open:s,onClose:r,children:g,position:o="right",size:m="md",customWidth:a,customHeight:l,showOverlay:h=!0,closeOnOverlayClick:d=!0,closeOnEscape:b=!0,title:t,footer:f,className:p,overlayClassName:w,closeLabel:y,"aria-label":v,trapFocus:x=!0,initialFocus:D,returnFocus:k,lockScroll:N=!0}){let R=!!(a||l),c=S(null),P=O(),u=`${M()}-drawer-title`,{dialogRef:C,dialogProps:I}=E({open:s,onClose:r,closeOnEscape:b,trapFocus:x,initialFocus:D,returnFocus:k,lockScroll:N,keepInteractive:[c]}),L=F(()=>{d&&r()},[d,r]);if(!s)return null;let z=n($,{children:[h&&e("div",{ref:c,className:i("fixed inset-0 bg-black/50 z-40 transition-opacity","animate-in fade-in duration-200",w),onClick:L,"aria-hidden":"true"}),n("div",{ref:C,...I,"aria-labelledby":t?u:void 0,"aria-label":t?void 0:v,className:i("fixed z-50 bg-white dark:bg-gray-900","shadow-xl overflow-hidden","flex flex-col focus:outline-none",A[o],!R&&j[o][m],B[o],p),style:{...a?{width:a}:{},...l?{height:l}:{}},children:[t&&n("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:[e("h2",{id:u,className:"text-lg font-semibold text-gray-900 dark:text-white",children:t}),e("button",{type:"button",onClick:r,className:i("rounded-lg p-1.5 text-gray-500 dark:text-gray-400 hover:bg-gray-100 hover:text-gray-900","dark:hover:bg-gray-800 dark:hover:text-white","focus:outline-none focus:ring-2 focus:ring-gray-300 dark:focus:ring-gray-600"),"aria-label":y??P.closeDrawer,children:H})]}),e("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:g}),f&&e("div",{className:"px-6 py-4 border-t border-gray-200 dark:border-gray-700",children:f})]})]});return e(T,{children:z})}U.displayName="Drawer";export{U as Drawer};
@@ -1 +1 @@
1
- "use strict";"use client";var C=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var Y=Object.prototype.hasOwnProperty;var Z=(u,s)=>{for(var y in s)C(u,y,{get:s[y],enumerable:!0})},j=(u,s,y,h)=>{if(s&&typeof s=="object"||typeof s=="function")for(let l of X(s))!Y.call(u,l)&&l!==y&&C(u,l,{get:()=>s[l],enumerable:!(h=V(s,l))||h.enumerable});return u};var ee=u=>j(C({},"__esModule",{value:!0}),u);var te={};Z(te,{DropdownContent:()=>B});module.exports=ee(te);var a=require("react"),L=require("react-dom"),P=require("./Dropdown.cjs"),S=require("./hooks/useClickOutside.cjs"),D=require("./hooks/useLatest.cjs"),T=require("./hooks/usePositioning.cjs"),t=require("./menu-navigation.cjs"),W=require("../../lib/aria-hide.cjs"),M=require("../../lib/cn.cjs"),f=require("react/jsx-runtime"),ne={fade:"animate-in fade-in-0 duration-200",scale:"animate-in fade-in-0 zoom-in-95 duration-200",slide:"animate-in fade-in-0 slide-in-from-top-2 duration-200",none:""};function B({side:u="bottom",align:s="start",sideOffset:y=4,alignOffset:h=0,avoidCollisions:l=!0,collisionPadding:H=8,minWidth:z,maxWidth:q,maxHeight:w=300,animation:K="scale",portal:U=!0,children:_,className:$}){let{isOpen:n,setIsOpen:k,triggerRef:o,contentRef:i,closeOnClickOutside:G,closeOnEscape:J,modal:Q,contentId:c}=(0,P.useDropdownContext)(),[g,E]=(0,a.useState)(!1),m=(0,T.usePositioning)({triggerRef:o,contentRef:i,isOpen:n,side:u,align:s,sideOffset:y,alignOffset:h,avoidCollisions:l,collisionPadding:H});(0,S.useClickOutside)(i,()=>{G&&k(!1)},n,{isInside:e=>!!o.current?.contains(e)||e instanceof Element&&e.closest((0,t.ownedBy)(c))!==null});let R=(0,D.useLatest)(k),O=(0,D.useLatest)(J);(0,a.useEffect)(()=>{if(!n)return;let e=r=>{if(r.defaultPrevented)return;let p=i.current;if(!p)return;let d=p.ownerDocument,b=d.activeElement,A=(0,t.hasFocusWithin)(c,d)||!!o.current?.contains(b);if(r.key==="Escape"){if(!O.current)return;r.preventDefault(),R.current(!1),o.current?.focus();return}if(r.key==="Tab"){R.current(!1),A&&o.current?.focus();return}if(!A&&b!==null&&b!==d.body)return;let F=(0,t.getActiveMenu)(c,d)??p,x=(0,t.isTyping)(r.target);if(!((r.key==="Home"||r.key==="End")&&x)){if((0,t.moveFocus)(F,r.key)){r.preventDefault();return}if(r.key==="Enter"||r.key===" "){if(x)return;let v=b;if(!v||!(0,t.getMenuItems)(F).includes(v))return;r.preventDefault(),v.click()}}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[n,c,i,o,R,O]),(0,a.useEffect)(()=>{let e=i.current;if(e)return(0,W.registerFloatingLayer)(e,()=>o.current)},[i,o]),(0,a.useEffect)(()=>{if(!n||!g)return;let e=i.current;if(e)return(0,t.focusFirstItem)(e,()=>!(0,t.hasFocusWithin)(c,e.ownerDocument))},[n,g,c,i]);let I=(0,a.useRef)(n);(0,a.useLayoutEffect)(()=>{if(I.current&&!n){let e=i.current?.ownerDocument;e&&(0,t.hasFocusWithin)(c,e)&&o.current?.focus({preventScroll:!0})}I.current=n},[n,c,i,o]),(0,a.useLayoutEffect)(()=>{let e=0;if(!n){E(!1);return}let r=()=>{let p=o.current?.getBoundingClientRect(),d=i.current?.getBoundingClientRect();if(m.isReady&&!!p&&!!d&&p.width>0&&p.height>0&&d.width>0&&d.height>0){E(!0);return}e=requestAnimationFrame(r)};return E(!1),e=requestAnimationFrame(r),()=>{e&&cancelAnimationFrame(e)}},[n,m.isReady,o,i]);let N=(0,f.jsxs)(f.Fragment,{children:[Q&&n&&(0,f.jsx)("div",{className:"fixed inset-0 z-[59] bg-black/20",onClick:()=>k(!1)}),(0,f.jsx)("div",{ref:i,id:c,role:"menu","aria-orientation":"vertical","aria-hidden":!n,tabIndex:-1,[t.MENU_OWNER_ATTRIBUTE]:c,style:{position:"fixed",top:m.top,left:m.left,minWidth:z??o.current?.offsetWidth,maxWidth:q,maxHeight:m.availableHeight===void 0?w:typeof w=="number"?Math.min(w,m.availableHeight):`min(${w}, ${m.availableHeight}px)`,visibility:n&&g?"visible":"hidden",opacity:n&&g?1:0,pointerEvents:n&&g?"auto":"none"},className:(0,M.cn)("z-[60] overflow-auto rounded-lg outline-none","border border-gray-200 bg-white shadow-lg","dark:border-gray-700 dark:bg-gray-800",n&&g&&ne[K],$),children:(0,f.jsx)("div",{className:"py-1",children:_})})]});return U&&typeof document<"u"?(0,L.createPortal)(N,document.body):N}B.displayName="DropdownContent";0&&(module.exports={DropdownContent});
1
+ "use strict";"use client";var D=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var j=Object.prototype.hasOwnProperty;var ee=(u,s)=>{for(var p in s)D(u,p,{get:s[p],enumerable:!0})},ne=(u,s,p,h)=>{if(s&&typeof s=="object"||typeof s=="function")for(let f of Z(s))!j.call(u,f)&&f!==p&&D(u,f,{get:()=>s[f],enumerable:!(h=Y(s,f))||h.enumerable});return u};var te=u=>ne(D({},"__esModule",{value:!0}),u);var oe={};ee(oe,{DropdownContent:()=>z});module.exports=te(oe);var a=require("react"),S=require("react-dom"),T=require("./Dropdown.cjs"),W=require("./hooks/useClickOutside.cjs"),O=require("./hooks/useLatest.cjs"),M=require("./hooks/usePositioning.cjs"),t=require("./menu-navigation.cjs"),B=require("../../lib/aria-hide.cjs"),I=require("../../lib/owner-document.cjs"),H=require("../../lib/cn.cjs"),d=require("react/jsx-runtime"),re={fade:"animate-in fade-in-0 duration-200",scale:"animate-in fade-in-0 zoom-in-95 duration-200",slide:"animate-in fade-in-0 slide-in-from-top-2 duration-200",none:""};function z({side:u="bottom",align:s="start",sideOffset:p=4,alignOffset:h=0,avoidCollisions:f=!0,collisionPadding:q=8,minWidth:K,maxWidth:U,maxHeight:w=300,animation:_="scale",portal:$=!0,children:G,className:J}){let{isOpen:n,setIsOpen:E,triggerRef:o,contentRef:i,closeOnClickOutside:Q,closeOnEscape:V,modal:X,contentId:c}=(0,T.useDropdownContext)(),[y,R]=(0,a.useState)(!1),l=(0,M.usePositioning)({triggerRef:o,contentRef:i,isOpen:n,side:u,align:s,sideOffset:p,alignOffset:h,avoidCollisions:f,collisionPadding:q});(0,W.useClickOutside)(i,()=>{Q&&E(!1)},n,{isInside:e=>!!o.current?.contains(e)||e instanceof Element&&e.closest((0,t.ownedBy)(c))!==null});let v=(0,O.useLatest)(E),N=(0,O.useLatest)(V);(0,a.useEffect)(()=>{if(!n)return;let e=r=>{if(r.defaultPrevented)return;let m=i.current;if(!m)return;let b=m.ownerDocument,k=b.activeElement,x=(0,t.hasFocusWithin)(c,b)||!!o.current?.contains(k);if(r.key==="Escape"){if(!N.current)return;r.preventDefault(),v.current(!1),o.current?.focus();return}if(r.key==="Tab"){v.current(!1),x&&o.current?.focus();return}if(!x&&k!==null&&k!==b.body)return;let L=(0,t.getActiveMenu)(c,b)??m,P=(0,t.isTyping)(r.target);if(!((r.key==="Home"||r.key==="End")&&P)){if((0,t.moveFocus)(L,r.key)){r.preventDefault();return}if(r.key==="Enter"||r.key===" "){if(P)return;let C=k;if(!C||!(0,t.getMenuItems)(L).includes(C))return;r.preventDefault(),C.click()}}},g=(0,I.ownerDocumentOf)(o.current);return g.addEventListener("keydown",e),()=>g.removeEventListener("keydown",e)},[n,c,i,o,v,N]),(0,a.useEffect)(()=>{let e=i.current;if(e)return(0,B.registerFloatingLayer)(e,()=>o.current)},[i,o]),(0,a.useEffect)(()=>{if(!n||!y)return;let e=i.current;if(e)return(0,t.focusFirstItem)(e,()=>!(0,t.hasFocusWithin)(c,e.ownerDocument))},[n,y,c,i]);let A=(0,a.useRef)(n);(0,a.useLayoutEffect)(()=>{if(A.current&&!n){let e=i.current?.ownerDocument;e&&(0,t.hasFocusWithin)(c,e)&&o.current?.focus({preventScroll:!0})}A.current=n},[n,c,i,o]),(0,a.useLayoutEffect)(()=>{let e=0;if(!n){R(!1);return}let g=()=>{let r=o.current?.getBoundingClientRect(),m=i.current?.getBoundingClientRect();if(l.isReady&&!!r&&!!m&&r.width>0&&r.height>0&&m.width>0&&m.height>0){R(!0);return}e=requestAnimationFrame(g)};return R(!1),e=requestAnimationFrame(g),()=>{e&&cancelAnimationFrame(e)}},[n,l.isReady,o,i]);let F=(0,d.jsxs)(d.Fragment,{children:[X&&n&&(0,d.jsx)("div",{className:"fixed inset-0 z-[59] bg-black/20",onClick:()=>E(!1)}),(0,d.jsx)("div",{ref:i,id:c,role:"menu","aria-orientation":"vertical","aria-hidden":!n,tabIndex:-1,[t.MENU_OWNER_ATTRIBUTE]:c,style:{position:"fixed",top:l.top,left:l.left,minWidth:K??o.current?.offsetWidth,maxWidth:U,maxHeight:l.availableHeight===void 0?w:typeof w=="number"?Math.min(w,l.availableHeight):`min(${w}, ${l.availableHeight}px)`,visibility:n&&y?"visible":"hidden",opacity:n&&y?1:0,pointerEvents:n&&y?"auto":"none"},className:(0,H.cn)("z-[60] overflow-auto rounded-lg outline-none","border border-gray-200 bg-white shadow-lg","dark:border-gray-700 dark:bg-gray-800",n&&y&&re[_],J),children:(0,d.jsx)("div",{className:"py-1",children:G})})]});return $&&typeof document<"u"?(0,S.createPortal)(F,(0,I.ownerDocumentOf)(o.current).body):F}z.displayName="DropdownContent";0&&(module.exports={DropdownContent});
@@ -1 +1 @@
1
- "use client";import{useEffect as g,useLayoutEffect as D,useRef as K,useState as U}from"react";import{createPortal as _}from"react-dom";import{useDropdownContext as $}from"./Dropdown.js";import{useClickOutside as G}from"./hooks/useClickOutside.js";import{useLatest as O}from"./hooks/useLatest.js";import{usePositioning as J}from"./hooks/usePositioning.js";import{MENU_OWNER_ATTRIBUTE as Q,focusFirstItem as V,getActiveMenu as X,getMenuItems as Y,hasFocusWithin as b,isTyping as Z,moveFocus as j,ownedBy as ee}from"./menu-navigation.js";import{registerFloatingLayer as ne}from"../../lib/aria-hide.js";import{cn as te}from"../../lib/cn.js";import{Fragment as ie,jsx as h,jsxs as se}from"react/jsx-runtime";var re={fade:"animate-in fade-in-0 duration-200",scale:"animate-in fade-in-0 zoom-in-95 duration-200",slide:"animate-in fade-in-0 slide-in-from-top-2 duration-200",none:""};function oe({side:I="bottom",align:N="start",sideOffset:A=4,alignOffset:F=0,avoidCollisions:x=!0,collisionPadding:L=8,minWidth:P,maxWidth:S,maxHeight:f=300,animation:T="scale",portal:W=!0,children:M,className:B}){let{isOpen:n,setIsOpen:l,triggerRef:r,contentRef:o,closeOnClickOutside:H,closeOnEscape:z,modal:q,contentId:i}=$(),[u,m]=U(!1),a=J({triggerRef:r,contentRef:o,isOpen:n,side:I,align:N,sideOffset:A,alignOffset:F,avoidCollisions:x,collisionPadding:L});G(o,()=>{H&&l(!1)},n,{isInside:e=>!!r.current?.contains(e)||e instanceof Element&&e.closest(ee(i))!==null});let p=O(l),w=O(z);g(()=>{if(!n)return;let e=t=>{if(t.defaultPrevented)return;let c=o.current;if(!c)return;let s=c.ownerDocument,d=s.activeElement,R=b(i,s)||!!r.current?.contains(d);if(t.key==="Escape"){if(!w.current)return;t.preventDefault(),p.current(!1),r.current?.focus();return}if(t.key==="Tab"){p.current(!1),R&&r.current?.focus();return}if(!R&&d!==null&&d!==s.body)return;let v=X(i,s)??c,C=Z(t.target);if(!((t.key==="Home"||t.key==="End")&&C)){if(j(v,t.key)){t.preventDefault();return}if(t.key==="Enter"||t.key===" "){if(C)return;let y=d;if(!y||!Y(v).includes(y))return;t.preventDefault(),y.click()}}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[n,i,o,r,p,w]),g(()=>{let e=o.current;if(e)return ne(e,()=>r.current)},[o,r]),g(()=>{if(!n||!u)return;let e=o.current;if(e)return V(e,()=>!b(i,e.ownerDocument))},[n,u,i,o]);let k=K(n);D(()=>{if(k.current&&!n){let e=o.current?.ownerDocument;e&&b(i,e)&&r.current?.focus({preventScroll:!0})}k.current=n},[n,i,o,r]),D(()=>{let e=0;if(!n){m(!1);return}let t=()=>{let c=r.current?.getBoundingClientRect(),s=o.current?.getBoundingClientRect();if(a.isReady&&!!c&&!!s&&c.width>0&&c.height>0&&s.width>0&&s.height>0){m(!0);return}e=requestAnimationFrame(t)};return m(!1),e=requestAnimationFrame(t),()=>{e&&cancelAnimationFrame(e)}},[n,a.isReady,r,o]);let E=se(ie,{children:[q&&n&&h("div",{className:"fixed inset-0 z-[59] bg-black/20",onClick:()=>l(!1)}),h("div",{ref:o,id:i,role:"menu","aria-orientation":"vertical","aria-hidden":!n,tabIndex:-1,[Q]:i,style:{position:"fixed",top:a.top,left:a.left,minWidth:P??r.current?.offsetWidth,maxWidth:S,maxHeight:a.availableHeight===void 0?f:typeof f=="number"?Math.min(f,a.availableHeight):`min(${f}, ${a.availableHeight}px)`,visibility:n&&u?"visible":"hidden",opacity:n&&u?1:0,pointerEvents:n&&u?"auto":"none"},className:te("z-[60] overflow-auto rounded-lg outline-none","border border-gray-200 bg-white shadow-lg","dark:border-gray-700 dark:bg-gray-800",n&&u&&re[T],B),children:h("div",{className:"py-1",children:M})})]});return W&&typeof document<"u"?_(E,document.body):E}oe.displayName="DropdownContent";export{oe as DropdownContent};
1
+ "use client";import{useEffect as b,useLayoutEffect as O,useRef as _,useState as $}from"react";import{createPortal as G}from"react-dom";import{useDropdownContext as J}from"./Dropdown.js";import{useClickOutside as Q}from"./hooks/useClickOutside.js";import{useLatest as I}from"./hooks/useLatest.js";import{usePositioning as V}from"./hooks/usePositioning.js";import{MENU_OWNER_ATTRIBUTE as X,focusFirstItem as Y,getActiveMenu as Z,getMenuItems as j,hasFocusWithin as h,isTyping as ee,moveFocus as ne,ownedBy as te}from"./menu-navigation.js";import{registerFloatingLayer as re}from"../../lib/aria-hide.js";import{ownerDocumentOf as N}from"../../lib/owner-document.js";import{cn as oe}from"../../lib/cn.js";import{Fragment as ae,jsx as w,jsxs as ce}from"react/jsx-runtime";var ie={fade:"animate-in fade-in-0 duration-200",scale:"animate-in fade-in-0 zoom-in-95 duration-200",slide:"animate-in fade-in-0 slide-in-from-top-2 duration-200",none:""};function se({side:A="bottom",align:F="start",sideOffset:x=4,alignOffset:L=0,avoidCollisions:P=!0,collisionPadding:S=8,minWidth:T,maxWidth:W,maxHeight:f=300,animation:M="scale",portal:B=!0,children:H,className:z}){let{isOpen:n,setIsOpen:m,triggerRef:r,contentRef:o,closeOnClickOutside:q,closeOnEscape:K,modal:U,contentId:i}=J(),[c,p]=$(!1),s=V({triggerRef:r,contentRef:o,isOpen:n,side:A,align:F,sideOffset:x,alignOffset:L,avoidCollisions:P,collisionPadding:S});Q(o,()=>{q&&m(!1)},n,{isInside:e=>!!r.current?.contains(e)||e instanceof Element&&e.closest(te(i))!==null});let y=I(m),k=I(K);b(()=>{if(!n)return;let e=t=>{if(t.defaultPrevented)return;let a=o.current;if(!a)return;let d=a.ownerDocument,l=d.activeElement,v=h(i,d)||!!r.current?.contains(l);if(t.key==="Escape"){if(!k.current)return;t.preventDefault(),y.current(!1),r.current?.focus();return}if(t.key==="Tab"){y.current(!1),v&&r.current?.focus();return}if(!v&&l!==null&&l!==d.body)return;let C=Z(i,d)??a,D=ee(t.target);if(!((t.key==="Home"||t.key==="End")&&D)){if(ne(C,t.key)){t.preventDefault();return}if(t.key==="Enter"||t.key===" "){if(D)return;let g=l;if(!g||!j(C).includes(g))return;t.preventDefault(),g.click()}}},u=N(r.current);return u.addEventListener("keydown",e),()=>u.removeEventListener("keydown",e)},[n,i,o,r,y,k]),b(()=>{let e=o.current;if(e)return re(e,()=>r.current)},[o,r]),b(()=>{if(!n||!c)return;let e=o.current;if(e)return Y(e,()=>!h(i,e.ownerDocument))},[n,c,i,o]);let E=_(n);O(()=>{if(E.current&&!n){let e=o.current?.ownerDocument;e&&h(i,e)&&r.current?.focus({preventScroll:!0})}E.current=n},[n,i,o,r]),O(()=>{let e=0;if(!n){p(!1);return}let u=()=>{let t=r.current?.getBoundingClientRect(),a=o.current?.getBoundingClientRect();if(s.isReady&&!!t&&!!a&&t.width>0&&t.height>0&&a.width>0&&a.height>0){p(!0);return}e=requestAnimationFrame(u)};return p(!1),e=requestAnimationFrame(u),()=>{e&&cancelAnimationFrame(e)}},[n,s.isReady,r,o]);let R=ce(ae,{children:[U&&n&&w("div",{className:"fixed inset-0 z-[59] bg-black/20",onClick:()=>m(!1)}),w("div",{ref:o,id:i,role:"menu","aria-orientation":"vertical","aria-hidden":!n,tabIndex:-1,[X]:i,style:{position:"fixed",top:s.top,left:s.left,minWidth:T??r.current?.offsetWidth,maxWidth:W,maxHeight:s.availableHeight===void 0?f:typeof f=="number"?Math.min(f,s.availableHeight):`min(${f}, ${s.availableHeight}px)`,visibility:n&&c?"visible":"hidden",opacity:n&&c?1:0,pointerEvents:n&&c?"auto":"none"},className:oe("z-[60] overflow-auto rounded-lg outline-none","border border-gray-200 bg-white shadow-lg","dark:border-gray-700 dark:bg-gray-800",n&&c&&ie[M],z),children:w("div",{className:"py-1",children:H})})]});return B&&typeof document<"u"?G(R,N(r.current).body):R}se.displayName="DropdownContent";export{se as DropdownContent};
@@ -1 +1 @@
1
- "use strict";"use client";var M=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var H=(r,n)=>{for(var a in n)M(r,a,{get:n[a],enumerable:!0})},K=(r,n,a,l)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of q(n))!B.call(r,t)&&t!==a&&M(r,t,{get:()=>n[t],enumerable:!(l=A(n,t))||l.enumerable});return r};var W=r=>K(M({},"__esModule",{value:!0}),r);var V={};H(V,{DropdownSubMenu:()=>L,DropdownSubMenuContent:()=>I,DropdownSubMenuTrigger:()=>F});module.exports=W(V);var e=require("react"),S=require("react-dom"),R=require("./Dropdown.cjs"),k=require("./hooks/useClickOutside.cjs"),E=require("./hooks/usePositioning.cjs"),h=require("./menu-navigation.cjs"),N=require("../../lib/aria-hide.cjs"),x=require("../../lib/cn.cjs"),d=require("react/jsx-runtime"),j=100,O=(0,e.createContext)(null);function T(){let r=(0,e.useContext)(O);if(!r)throw new Error("DropdownSubMenu components must be used within a DropdownSubMenu");return r}function L({children:r}){let{isOpen:n}=(0,R.useDropdownContext)(),[a,l]=(0,e.useState)(!1),t=(0,e.useRef)(null),p=(0,e.useRef)(null),i=(0,e.useRef)(null),u=(0,e.useRef)(!1),g=n&&a,o=(0,e.useCallback)(()=>{i.current!==null&&(clearTimeout(i.current),i.current=null)},[]),b=(0,e.useCallback)(()=>{o(),i.current=setTimeout(()=>{i.current=null,l(!1)},j)},[o]),f=(0,e.useCallback)(()=>{o(),u.current=!0,l(!0)},[o]),c=(0,e.useCallback)(()=>{let y=u.current;return u.current=!1,y},[]);(0,e.useEffect)(()=>{n||(o(),u.current=!1,l(!1))},[n,o]),(0,e.useEffect)(()=>o,[o]);let m=(0,e.useMemo)(()=>({isOpen:g,setIsOpen:l,triggerRef:t,contentRef:p,scheduleClose:b,cancelClose:o,openWithFocus:f,takeFocusRequest:c}),[g,b,o,f,c]);return(0,d.jsx)(O.Provider,{value:m,children:(0,d.jsx)("div",{className:"relative",children:r})})}L.displayName="DropdownSubMenu";function F({children:r,icon:n,disabled:a=!1,className:l}){let{isOpen:t,setIsOpen:p,triggerRef:i,scheduleClose:u,cancelClose:g,openWithFocus:o}=T();return(0,d.jsxs)("button",{ref:i,role:"menuitem",type:"button",tabIndex:-1,"aria-haspopup":"menu","aria-expanded":t,disabled:a,"data-disabled":a||void 0,onMouseEnter:c=>{a||(g(),c.currentTarget.focus({preventScroll:!0}),p(!0))},onMouseLeave:u,onClick:a?void 0:o,onKeyDown:c=>{a||(c.key==="ArrowRight"||c.key==="Enter"||c.key===" ")&&(c.preventDefault(),o())},className:(0,x.cn)("relative flex w-full items-center px-3 py-2 text-left text-sm","outline-none transition-colors","text-gray-700 dark:text-gray-200","hover:bg-gray-100 dark:hover:bg-gray-700","focus:bg-gray-100 dark:focus:bg-gray-700",a&&"opacity-50 cursor-not-allowed hover:bg-transparent",t&&"bg-gray-100 dark:bg-gray-700",l),children:[n&&(0,d.jsx)("span",{className:"mr-2 shrink-0 w-5 h-5",children:n}),(0,d.jsx)("span",{className:"flex-1",children:r}),(0,d.jsx)("svg",{className:"ml-auto w-4 h-4 text-gray-500 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]})}F.displayName="DropdownSubMenuTrigger";function I({children:r,sideOffset:n=0,className:a}){let{contentId:l}=(0,R.useDropdownContext)(),{isOpen:t,setIsOpen:p,triggerRef:i,contentRef:u,scheduleClose:g,cancelClose:o,takeFocusRequest:b}=T(),[f,c]=(0,e.useState)(!1),m=(0,E.usePositioning)({triggerRef:i,contentRef:u,isOpen:t,side:"right",align:"start",sideOffset:n,avoidCollisions:!0});(0,k.useClickOutside)(u,()=>p(!1),t,{isInside:s=>!!i.current?.contains(s)}),(0,e.useEffect)(()=>{let s=u.current;if(s)return(0,N.registerFloatingLayer)(s,()=>i.current)},[u,i]);let y=(0,e.useCallback)(()=>{o(),p(!0)},[o,p]),P=s=>{(s.key==="ArrowLeft"||s.key==="Escape")&&(s.preventDefault(),o(),p(!1),i.current?.focus())};(0,e.useEffect)(()=>{if(!t||!f||!b())return;let s=u.current;if(s)return(0,h.focusFirstItem)(s)},[t,f,u,b]),(0,e.useLayoutEffect)(()=>{let s=0;if(!t){c(!1);return}let D=()=>{let v=i.current?.getBoundingClientRect(),w=u.current?.getBoundingClientRect();if(m.isReady&&!!v&&!!w&&v.width>0&&v.height>0&&w.width>0&&w.height>0){c(!0);return}s=requestAnimationFrame(D)};return c(!1),s=requestAnimationFrame(D),()=>{s&&cancelAnimationFrame(s)}},[t,m.isReady,i,u]);let C=(0,d.jsx)("div",{ref:u,role:"menu","aria-orientation":"vertical","aria-hidden":!t,tabIndex:-1,[h.MENU_OWNER_ATTRIBUTE]:l,onMouseEnter:y,onMouseLeave:g,onKeyDown:P,style:{position:"fixed",top:m.top,left:m.left,maxHeight:m.availableHeight,visibility:t&&f?"visible":"hidden",opacity:t&&f?1:0,pointerEvents:t&&f?"auto":"none"},className:(0,x.cn)("z-[61] min-w-40 overflow-x-hidden overflow-y-auto rounded-lg outline-none","border border-gray-200 bg-white shadow-lg","dark:border-gray-700 dark:bg-gray-800",t&&f&&"animate-in fade-in-0 zoom-in-95 duration-150",a),children:(0,d.jsx)("div",{className:"py-1",children:r})});return typeof document<"u"?(0,S.createPortal)(C,document.body):C}I.displayName="DropdownSubMenuContent";0&&(module.exports={DropdownSubMenu,DropdownSubMenuContent,DropdownSubMenuTrigger});
1
+ "use strict";"use client";var M=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var H=Object.prototype.hasOwnProperty;var K=(r,n)=>{for(var i in n)M(r,i,{get:n[i],enumerable:!0})},W=(r,n,i,l)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of B(n))!H.call(r,t)&&t!==i&&M(r,t,{get:()=>n[t],enumerable:!(l=q(n,t))||l.enumerable});return r};var j=r=>W(M({},"__esModule",{value:!0}),r);var _={};K(_,{DropdownSubMenu:()=>F,DropdownSubMenuContent:()=>P,DropdownSubMenuTrigger:()=>I});module.exports=j(_);var e=require("react"),S=require("react-dom"),R=require("./Dropdown.cjs"),k=require("./hooks/useClickOutside.cjs"),E=require("./hooks/usePositioning.cjs"),h=require("./menu-navigation.cjs"),N=require("../../lib/aria-hide.cjs"),O=require("../../lib/owner-document.cjs"),x=require("../../lib/cn.cjs"),d=require("react/jsx-runtime"),V=100,T=(0,e.createContext)(null);function L(){let r=(0,e.useContext)(T);if(!r)throw new Error("DropdownSubMenu components must be used within a DropdownSubMenu");return r}function F({children:r}){let{isOpen:n}=(0,R.useDropdownContext)(),[i,l]=(0,e.useState)(!1),t=(0,e.useRef)(null),p=(0,e.useRef)(null),u=(0,e.useRef)(null),s=(0,e.useRef)(!1),g=n&&i,o=(0,e.useCallback)(()=>{u.current!==null&&(clearTimeout(u.current),u.current=null)},[]),b=(0,e.useCallback)(()=>{o(),u.current=setTimeout(()=>{u.current=null,l(!1)},V)},[o]),f=(0,e.useCallback)(()=>{o(),s.current=!0,l(!0)},[o]),c=(0,e.useCallback)(()=>{let y=s.current;return s.current=!1,y},[]);(0,e.useEffect)(()=>{n||(o(),s.current=!1,l(!1))},[n,o]),(0,e.useEffect)(()=>o,[o]);let m=(0,e.useMemo)(()=>({isOpen:g,setIsOpen:l,triggerRef:t,contentRef:p,scheduleClose:b,cancelClose:o,openWithFocus:f,takeFocusRequest:c}),[g,b,o,f,c]);return(0,d.jsx)(T.Provider,{value:m,children:(0,d.jsx)("div",{className:"relative",children:r})})}F.displayName="DropdownSubMenu";function I({children:r,icon:n,disabled:i=!1,className:l}){let{isOpen:t,setIsOpen:p,triggerRef:u,scheduleClose:s,cancelClose:g,openWithFocus:o}=L();return(0,d.jsxs)("button",{ref:u,role:"menuitem",type:"button",tabIndex:-1,"aria-haspopup":"menu","aria-expanded":t,disabled:i,"data-disabled":i||void 0,onMouseEnter:c=>{i||(g(),c.currentTarget.focus({preventScroll:!0}),p(!0))},onMouseLeave:s,onClick:i?void 0:o,onKeyDown:c=>{i||(c.key==="ArrowRight"||c.key==="Enter"||c.key===" ")&&(c.preventDefault(),o())},className:(0,x.cn)("relative flex w-full items-center px-3 py-2 text-left text-sm","outline-none transition-colors","text-gray-700 dark:text-gray-200","hover:bg-gray-100 dark:hover:bg-gray-700","focus:bg-gray-100 dark:focus:bg-gray-700",i&&"opacity-50 cursor-not-allowed hover:bg-transparent",t&&"bg-gray-100 dark:bg-gray-700",l),children:[n&&(0,d.jsx)("span",{className:"mr-2 shrink-0 w-5 h-5",children:n}),(0,d.jsx)("span",{className:"flex-1",children:r}),(0,d.jsx)("svg",{className:"ml-auto w-4 h-4 text-gray-500 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]})}I.displayName="DropdownSubMenuTrigger";function P({children:r,sideOffset:n=0,className:i}){let{contentId:l}=(0,R.useDropdownContext)(),{isOpen:t,setIsOpen:p,triggerRef:u,contentRef:s,scheduleClose:g,cancelClose:o,takeFocusRequest:b}=L(),[f,c]=(0,e.useState)(!1),m=(0,E.usePositioning)({triggerRef:u,contentRef:s,isOpen:t,side:"right",align:"start",sideOffset:n,avoidCollisions:!0});(0,k.useClickOutside)(s,()=>p(!1),t,{isInside:a=>!!u.current?.contains(a)}),(0,e.useEffect)(()=>{let a=s.current;if(a)return(0,N.registerFloatingLayer)(a,()=>u.current)},[s,u]);let y=(0,e.useCallback)(()=>{o(),p(!0)},[o,p]),A=a=>{(a.key==="ArrowLeft"||a.key==="Escape")&&(a.preventDefault(),o(),p(!1),u.current?.focus())};(0,e.useEffect)(()=>{if(!t||!f||!b())return;let a=s.current;if(a)return(0,h.focusFirstItem)(a)},[t,f,s,b]),(0,e.useLayoutEffect)(()=>{let a=0;if(!t){c(!1);return}let D=()=>{let w=u.current?.getBoundingClientRect(),v=s.current?.getBoundingClientRect();if(m.isReady&&!!w&&!!v&&w.width>0&&w.height>0&&v.width>0&&v.height>0){c(!0);return}a=requestAnimationFrame(D)};return c(!1),a=requestAnimationFrame(D),()=>{a&&cancelAnimationFrame(a)}},[t,m.isReady,u,s]);let C=(0,d.jsx)("div",{ref:s,role:"menu","aria-orientation":"vertical","aria-hidden":!t,tabIndex:-1,[h.MENU_OWNER_ATTRIBUTE]:l,onMouseEnter:y,onMouseLeave:g,onKeyDown:A,style:{position:"fixed",top:m.top,left:m.left,maxHeight:m.availableHeight,visibility:t&&f?"visible":"hidden",opacity:t&&f?1:0,pointerEvents:t&&f?"auto":"none"},className:(0,x.cn)("z-[61] min-w-40 overflow-x-hidden overflow-y-auto rounded-lg outline-none","border border-gray-200 bg-white shadow-lg","dark:border-gray-700 dark:bg-gray-800",t&&f&&"animate-in fade-in-0 zoom-in-95 duration-150",i),children:(0,d.jsx)("div",{className:"py-1",children:r})});return typeof document<"u"?(0,S.createPortal)(C,(0,O.ownerDocumentOf)(u.current).body):C}P.displayName="DropdownSubMenuContent";0&&(module.exports={DropdownSubMenu,DropdownSubMenuContent,DropdownSubMenuTrigger});
@@ -1 +1 @@
1
- "use client";import{createContext as O,useContext as T,useState as C,useRef as h,useEffect as y,useLayoutEffect as L,useCallback as b,useMemo as F}from"react";import{createPortal as I}from"react-dom";import{useDropdownContext as D}from"./Dropdown.js";import{useClickOutside as P}from"./hooks/useClickOutside.js";import{usePositioning as A}from"./hooks/usePositioning.js";import{MENU_OWNER_ATTRIBUTE as q,focusFirstItem as B}from"./menu-navigation.js";import{registerFloatingLayer as H}from"../../lib/aria-hide.js";import{cn as S}from"../../lib/cn.js";import{jsx as f,jsxs as _}from"react/jsx-runtime";var K=100,k=O(null);function E(){let i=T(k);if(!i)throw new Error("DropdownSubMenu components must be used within a DropdownSubMenu");return i}function W({children:i}){let{isOpen:c}=D(),[s,l]=C(!1),t=h(null),d=h(null),r=h(null),n=h(!1),m=c&&s,e=b(()=>{r.current!==null&&(clearTimeout(r.current),r.current=null)},[]),g=b(()=>{e(),r.current=setTimeout(()=>{r.current=null,l(!1)},K)},[e]),a=b(()=>{e(),n.current=!0,l(!0)},[e]),u=b(()=>{let v=n.current;return n.current=!1,v},[]);y(()=>{c||(e(),n.current=!1,l(!1))},[c,e]),y(()=>e,[e]);let p=F(()=>({isOpen:m,setIsOpen:l,triggerRef:t,contentRef:d,scheduleClose:g,cancelClose:e,openWithFocus:a,takeFocusRequest:u}),[m,g,e,a,u]);return f(k.Provider,{value:p,children:f("div",{className:"relative",children:i})})}W.displayName="DropdownSubMenu";function j({children:i,icon:c,disabled:s=!1,className:l}){let{isOpen:t,setIsOpen:d,triggerRef:r,scheduleClose:n,cancelClose:m,openWithFocus:e}=E();return _("button",{ref:r,role:"menuitem",type:"button",tabIndex:-1,"aria-haspopup":"menu","aria-expanded":t,disabled:s,"data-disabled":s||void 0,onMouseEnter:u=>{s||(m(),u.currentTarget.focus({preventScroll:!0}),d(!0))},onMouseLeave:n,onClick:s?void 0:e,onKeyDown:u=>{s||(u.key==="ArrowRight"||u.key==="Enter"||u.key===" ")&&(u.preventDefault(),e())},className:S("relative flex w-full items-center px-3 py-2 text-left text-sm","outline-none transition-colors","text-gray-700 dark:text-gray-200","hover:bg-gray-100 dark:hover:bg-gray-700","focus:bg-gray-100 dark:focus:bg-gray-700",s&&"opacity-50 cursor-not-allowed hover:bg-transparent",t&&"bg-gray-100 dark:bg-gray-700",l),children:[c&&f("span",{className:"mr-2 shrink-0 w-5 h-5",children:c}),f("span",{className:"flex-1",children:i}),f("svg",{className:"ml-auto w-4 h-4 text-gray-500 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:f("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]})}j.displayName="DropdownSubMenuTrigger";function V({children:i,sideOffset:c=0,className:s}){let{contentId:l}=D(),{isOpen:t,setIsOpen:d,triggerRef:r,contentRef:n,scheduleClose:m,cancelClose:e,takeFocusRequest:g}=E(),[a,u]=C(!1),p=A({triggerRef:r,contentRef:n,isOpen:t,side:"right",align:"start",sideOffset:c,avoidCollisions:!0});P(n,()=>d(!1),t,{isInside:o=>!!r.current?.contains(o)}),y(()=>{let o=n.current;if(o)return H(o,()=>r.current)},[n,r]);let v=b(()=>{e(),d(!0)},[e,d]),N=o=>{(o.key==="ArrowLeft"||o.key==="Escape")&&(o.preventDefault(),e(),d(!1),r.current?.focus())};y(()=>{if(!t||!a||!g())return;let o=n.current;if(o)return B(o)},[t,a,n,g]),L(()=>{let o=0;if(!t){u(!1);return}let x=()=>{let w=r.current?.getBoundingClientRect(),M=n.current?.getBoundingClientRect();if(p.isReady&&!!w&&!!M&&w.width>0&&w.height>0&&M.width>0&&M.height>0){u(!0);return}o=requestAnimationFrame(x)};return u(!1),o=requestAnimationFrame(x),()=>{o&&cancelAnimationFrame(o)}},[t,p.isReady,r,n]);let R=f("div",{ref:n,role:"menu","aria-orientation":"vertical","aria-hidden":!t,tabIndex:-1,[q]:l,onMouseEnter:v,onMouseLeave:m,onKeyDown:N,style:{position:"fixed",top:p.top,left:p.left,maxHeight:p.availableHeight,visibility:t&&a?"visible":"hidden",opacity:t&&a?1:0,pointerEvents:t&&a?"auto":"none"},className:S("z-[61] min-w-40 overflow-x-hidden overflow-y-auto rounded-lg outline-none","border border-gray-200 bg-white shadow-lg","dark:border-gray-700 dark:bg-gray-800",t&&a&&"animate-in fade-in-0 zoom-in-95 duration-150",s),children:f("div",{className:"py-1",children:i})});return typeof document<"u"?I(R,document.body):R}V.displayName="DropdownSubMenuContent";export{W as DropdownSubMenu,V as DropdownSubMenuContent,j as DropdownSubMenuTrigger};
1
+ "use client";import{createContext as O,useContext as T,useState as C,useRef as h,useEffect as y,useLayoutEffect as L,useCallback as b,useMemo as F}from"react";import{createPortal as I}from"react-dom";import{useDropdownContext as D}from"./Dropdown.js";import{useClickOutside as P}from"./hooks/useClickOutside.js";import{usePositioning as A}from"./hooks/usePositioning.js";import{MENU_OWNER_ATTRIBUTE as q,focusFirstItem as B}from"./menu-navigation.js";import{registerFloatingLayer as H}from"../../lib/aria-hide.js";import{ownerDocumentOf as K}from"../../lib/owner-document.js";import{cn as S}from"../../lib/cn.js";import{jsx as f,jsxs as z}from"react/jsx-runtime";var W=100,k=O(null);function E(){let i=T(k);if(!i)throw new Error("DropdownSubMenu components must be used within a DropdownSubMenu");return i}function j({children:i}){let{isOpen:c}=D(),[s,l]=C(!1),t=h(null),d=h(null),n=h(null),o=h(!1),m=c&&s,e=b(()=>{n.current!==null&&(clearTimeout(n.current),n.current=null)},[]),g=b(()=>{e(),n.current=setTimeout(()=>{n.current=null,l(!1)},W)},[e]),a=b(()=>{e(),o.current=!0,l(!0)},[e]),u=b(()=>{let w=o.current;return o.current=!1,w},[]);y(()=>{c||(e(),o.current=!1,l(!1))},[c,e]),y(()=>e,[e]);let p=F(()=>({isOpen:m,setIsOpen:l,triggerRef:t,contentRef:d,scheduleClose:g,cancelClose:e,openWithFocus:a,takeFocusRequest:u}),[m,g,e,a,u]);return f(k.Provider,{value:p,children:f("div",{className:"relative",children:i})})}j.displayName="DropdownSubMenu";function V({children:i,icon:c,disabled:s=!1,className:l}){let{isOpen:t,setIsOpen:d,triggerRef:n,scheduleClose:o,cancelClose:m,openWithFocus:e}=E();return z("button",{ref:n,role:"menuitem",type:"button",tabIndex:-1,"aria-haspopup":"menu","aria-expanded":t,disabled:s,"data-disabled":s||void 0,onMouseEnter:u=>{s||(m(),u.currentTarget.focus({preventScroll:!0}),d(!0))},onMouseLeave:o,onClick:s?void 0:e,onKeyDown:u=>{s||(u.key==="ArrowRight"||u.key==="Enter"||u.key===" ")&&(u.preventDefault(),e())},className:S("relative flex w-full items-center px-3 py-2 text-left text-sm","outline-none transition-colors","text-gray-700 dark:text-gray-200","hover:bg-gray-100 dark:hover:bg-gray-700","focus:bg-gray-100 dark:focus:bg-gray-700",s&&"opacity-50 cursor-not-allowed hover:bg-transparent",t&&"bg-gray-100 dark:bg-gray-700",l),children:[c&&f("span",{className:"mr-2 shrink-0 w-5 h-5",children:c}),f("span",{className:"flex-1",children:i}),f("svg",{className:"ml-auto w-4 h-4 text-gray-500 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:f("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]})}V.displayName="DropdownSubMenuTrigger";function _({children:i,sideOffset:c=0,className:s}){let{contentId:l}=D(),{isOpen:t,setIsOpen:d,triggerRef:n,contentRef:o,scheduleClose:m,cancelClose:e,takeFocusRequest:g}=E(),[a,u]=C(!1),p=A({triggerRef:n,contentRef:o,isOpen:t,side:"right",align:"start",sideOffset:c,avoidCollisions:!0});P(o,()=>d(!1),t,{isInside:r=>!!n.current?.contains(r)}),y(()=>{let r=o.current;if(r)return H(r,()=>n.current)},[o,n]);let w=b(()=>{e(),d(!0)},[e,d]),N=r=>{(r.key==="ArrowLeft"||r.key==="Escape")&&(r.preventDefault(),e(),d(!1),n.current?.focus())};y(()=>{if(!t||!a||!g())return;let r=o.current;if(r)return B(r)},[t,a,o,g]),L(()=>{let r=0;if(!t){u(!1);return}let x=()=>{let v=n.current?.getBoundingClientRect(),M=o.current?.getBoundingClientRect();if(p.isReady&&!!v&&!!M&&v.width>0&&v.height>0&&M.width>0&&M.height>0){u(!0);return}r=requestAnimationFrame(x)};return u(!1),r=requestAnimationFrame(x),()=>{r&&cancelAnimationFrame(r)}},[t,p.isReady,n,o]);let R=f("div",{ref:o,role:"menu","aria-orientation":"vertical","aria-hidden":!t,tabIndex:-1,[q]:l,onMouseEnter:w,onMouseLeave:m,onKeyDown:N,style:{position:"fixed",top:p.top,left:p.left,maxHeight:p.availableHeight,visibility:t&&a?"visible":"hidden",opacity:t&&a?1:0,pointerEvents:t&&a?"auto":"none"},className:S("z-[61] min-w-40 overflow-x-hidden overflow-y-auto rounded-lg outline-none","border border-gray-200 bg-white shadow-lg","dark:border-gray-700 dark:bg-gray-800",t&&a&&"animate-in fade-in-0 zoom-in-95 duration-150",s),children:f("div",{className:"py-1",children:i})});return typeof document<"u"?I(R,K(n.current).body):R}_.displayName="DropdownSubMenuContent";export{j as DropdownSubMenu,_ as DropdownSubMenuContent,V as DropdownSubMenuTrigger};
@@ -1 +1 @@
1
- "use strict";"use client";var i=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var p=(e,t)=>{for(var r in t)i(e,r,{get:t[r],enumerable:!0})},E=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of l(t))!v.call(e,n)&&n!==r&&i(e,n,{get:()=>t[n],enumerable:!(s=f(t,n))||s.enumerable});return e};var O=e=>E(i({},"__esModule",{value:!0}),e);var h={};p(h,{useClickOutside:()=>L});module.exports=O(h);var a=require("react"),u=require("./useLatest.cjs");function L(e,t,r=!0,s={}){let n=(0,u.useLatest)(t),c=(0,u.useLatest)(s.isInside);(0,a.useEffect)(()=>{if(!r)return;let o=m=>{let d=m.target;!e.current||e.current.contains(d)||c.current?.(d)||n.current()};return document.addEventListener("mousedown",o),document.addEventListener("touchstart",o,{passive:!0}),()=>{document.removeEventListener("mousedown",o),document.removeEventListener("touchstart",o)}},[r,n,c,e])}0&&(module.exports={useClickOutside});
1
+ "use strict";"use client";var u=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var O=(e,t)=>{for(var r in t)u(e,r,{get:t[r],enumerable:!0})},L=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of p(t))!E.call(e,n)&&n!==r&&u(e,n,{get:()=>t[n],enumerable:!(o=v(t,n))||o.enumerable});return e};var h=e=>L(u({},"__esModule",{value:!0}),e);var b={};O(b,{useClickOutside:()=>R});module.exports=h(b);var f=require("react"),c=require("./useLatest.cjs"),m=require("../../../lib/owner-document.cjs");function R(e,t,r=!0,o={}){let n=(0,c.useLatest)(t),d=(0,c.useLatest)(o.isInside);(0,f.useEffect)(()=>{if(!r)return;let s=l=>{let a=l.target;!e.current||e.current.contains(a)||d.current?.(a)||n.current()},i=(0,m.ownerDocumentOf)(e.current);return i.addEventListener("mousedown",s),i.addEventListener("touchstart",s,{passive:!0}),()=>{i.removeEventListener("mousedown",s),i.removeEventListener("touchstart",s)}},[r,n,d,e])}0&&(module.exports={useClickOutside});
@@ -1 +1 @@
1
- "use client";import{useEffect as a}from"react";import{useLatest as i}from"./useLatest.js";function l(t,u,n=!0,c={}){let r=i(u),s=i(c.isInside);a(()=>{if(!n)return;let e=d=>{let o=d.target;!t.current||t.current.contains(o)||s.current?.(o)||r.current()};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e,{passive:!0}),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}},[n,r,s,t])}export{l as useClickOutside};
1
+ "use client";import{useEffect as f}from"react";import{useLatest as u}from"./useLatest.js";import{ownerDocumentOf as m}from"../../../lib/owner-document.js";function E(e,c,r=!0,d={}){let o=u(c),s=u(d.isInside);f(()=>{if(!r)return;let t=a=>{let i=a.target;!e.current||e.current.contains(i)||s.current?.(i)||o.current()},n=m(e.current);return n.addEventListener("mousedown",t),n.addEventListener("touchstart",t,{passive:!0}),()=>{n.removeEventListener("mousedown",t),n.removeEventListener("touchstart",t)}},[r,o,s,e])}export{E as useClickOutside};
@@ -1 +1 @@
1
- "use strict";"use client";var v=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var k=(i,o)=>{for(var f in o)v(i,f,{get:o[f],enumerable:!0})},q=(i,o,f,c)=>{if(o&&typeof o=="object"||typeof o=="function")for(let a of F(o))!M.call(i,a)&&a!==f&&v(i,a,{get:()=>o[a],enumerable:!(c=C(o,a))||c.enumerable});return i};var z=i=>q(v({},"__esModule",{value:!0}),i);var V={};k(V,{usePositioning:()=>U});module.exports=z(V);var m=require("react"),I={top:"bottom",bottom:"top",left:"right",right:"left"};function U({triggerRef:i,contentRef:o,isOpen:f,side:c="bottom",align:a="start",sideOffset:u=4,alignOffset:b=0,avoidCollisions:x=!0,collisionPadding:n=8}){let[B,E]=(0,m.useState)({top:0,left:0,actualSide:c,actualAlign:a,isReady:!1}),g=(0,m.useRef)(!1),y=(0,m.useCallback)(()=>{if(!i.current||!o.current)return;let t=i.current.getBoundingClientRect(),e=o.current.getBoundingClientRect();if(!(t.width>0&&t.height>0&&e.width>0&&e.height>0)){g.current=!1;return}let l={width:window.innerWidth,height:window.innerHeight},s=c,w=a,L=p=>{switch(p){case"bottom":return{top:t.bottom+u,left:t.left};case"top":return{top:t.top-e.height-u,left:t.left};case"right":return{top:t.top,left:t.right+u};case"left":return{top:t.top,left:t.left-e.width-u}}},H=(p,R,h)=>{if(p==="top"||p==="bottom")switch(R){case"start":return{...h,left:t.left+b};case"center":return{...h,left:t.left+t.width/2-e.width/2+b};case"end":return{...h,left:t.right-e.width+b}}else switch(R){case"start":return{...h,top:t.top+b};case"center":return{...h,top:t.top+t.height/2-e.height/2+b};case"end":return{...h,top:t.bottom-e.height+b}}},r=L(s);r=H(s,w,r);let T;if(x){let p={top:t.top-u-n,bottom:l.height-t.bottom-u-n,left:t.left-u-n,right:l.width-t.right-u-n},R=c==="top"||c==="bottom"?e.height:e.width,h=I[c];R>p[c]&&p[h]>p[c]&&(s=h,r=L(s),r=H(s,w,r));let A=l.width-e.width-n,j=l.height-e.height-n,S=s==="top"||s==="bottom";r.left>A&&(r.left=A,S&&(w="end")),r.left<n&&(r.left=n,S&&(w="start")),r.top>j&&(r.top=j,S||(w="end")),r.top<n&&(r.top=n,S||(w="start")),T=Math.max(0,l.height-2*n)}g.current=!0,E({top:r.top,left:r.left,actualSide:s,actualAlign:w,isReady:!0,availableHeight:T})},[i,o,c,a,u,b,x,n]);return(0,m.useLayoutEffect)(()=>{if(!f)return;let t=0;g.current=!1,E(l=>l.isReady?{...l,isReady:!1}:l);let e=()=>{y(),g.current||(t=requestAnimationFrame(e))};t=requestAnimationFrame(e);let d=()=>y();return window.addEventListener("resize",d),window.addEventListener("scroll",d,{passive:!0,capture:!0}),()=>{t&&cancelAnimationFrame(t),window.removeEventListener("resize",d),window.removeEventListener("scroll",d,{capture:!0})}},[y,f]),B}0&&(module.exports={usePositioning});
1
+ "use strict";"use client";var x=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var q=Object.prototype.hasOwnProperty;var z=(o,n)=>{for(var f in n)x(o,f,{get:n[f],enumerable:!0})},I=(o,n,f,c)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of k(n))!q.call(o,a)&&a!==f&&x(o,a,{get:()=>n[a],enumerable:!(c=M(n,a))||c.enumerable});return o};var U=o=>I(x({},"__esModule",{value:!0}),o);var P={};z(P,{usePositioning:()=>W});module.exports=U(P);var m=require("react"),E=require("../../../lib/owner-document.cjs"),V={top:"bottom",bottom:"top",left:"right",right:"left"};function W({triggerRef:o,contentRef:n,isOpen:f,side:c="bottom",align:a="start",sideOffset:u=4,alignOffset:b=0,avoidCollisions:L=!0,collisionPadding:i=8}){let[F,H]=(0,m.useState)({top:0,left:0,actualSide:c,actualAlign:a,isReady:!1}),R=(0,m.useRef)(!1),v=(0,m.useCallback)(()=>{if(!o.current||!n.current)return;let t=o.current.getBoundingClientRect(),e=n.current.getBoundingClientRect();if(!(t.width>0&&t.height>0&&e.width>0&&e.height>0)){R.current=!1;return}let w=(0,E.ownerWindowOf)(o.current),l={width:w.innerWidth,height:w.innerHeight},s=c,d=a,T=p=>{switch(p){case"bottom":return{top:t.bottom+u,left:t.left};case"top":return{top:t.top-e.height-u,left:t.left};case"right":return{top:t.top,left:t.right+u};case"left":return{top:t.top,left:t.left-e.width-u}}},j=(p,S,h)=>{if(p==="top"||p==="bottom")switch(S){case"start":return{...h,left:t.left+b};case"center":return{...h,left:t.left+t.width/2-e.width/2+b};case"end":return{...h,left:t.right-e.width+b}}else switch(S){case"start":return{...h,top:t.top+b};case"center":return{...h,top:t.top+t.height/2-e.height/2+b};case"end":return{...h,top:t.bottom-e.height+b}}},r=T(s);r=j(s,d,r);let B;if(L){let p={top:t.top-u-i,bottom:l.height-t.bottom-u-i,left:t.left-u-i,right:l.width-t.right-u-i},S=c==="top"||c==="bottom"?e.height:e.width,h=V[c];S>p[c]&&p[h]>p[c]&&(s=h,r=T(s),r=j(s,d,r));let A=l.width-e.width-i,C=l.height-e.height-i,y=s==="top"||s==="bottom";r.left>A&&(r.left=A,y&&(d="end")),r.left<i&&(r.left=i,y&&(d="start")),r.top>C&&(r.top=C,y||(d="end")),r.top<i&&(r.top=i,y||(d="start")),B=Math.max(0,l.height-2*i)}R.current=!0,H({top:r.top,left:r.left,actualSide:s,actualAlign:d,isReady:!0,availableHeight:B})},[o,n,c,a,u,b,L,i]);return(0,m.useLayoutEffect)(()=>{if(!f)return;let t=0;R.current=!1,H(l=>l.isReady?{...l,isReady:!1}:l);let e=()=>{v(),R.current||(t=requestAnimationFrame(e))};t=requestAnimationFrame(e);let g=()=>v(),w=(0,E.ownerWindowOf)(o.current);return w.addEventListener("resize",g),w.addEventListener("scroll",g,{passive:!0,capture:!0}),()=>{t&&cancelAnimationFrame(t),w.removeEventListener("resize",g),w.removeEventListener("scroll",g,{capture:!0})}},[v,f]),F}0&&(module.exports={usePositioning});
@@ -1 +1 @@
1
- "use client";import{useState as j,useLayoutEffect as B,useCallback as C,useRef as F}from"react";var M={top:"bottom",bottom:"top",left:"right",right:"left"};function q({triggerRef:w,contentRef:d,isOpen:y,side:a="bottom",align:g="start",sideOffset:n=4,alignOffset:h=0,avoidCollisions:A=!0,collisionPadding:o=8}){let[T,v]=j({top:0,left:0,actualSide:a,actualAlign:g,isReady:!1}),m=F(!1),R=C(()=>{if(!w.current||!d.current)return;let t=w.current.getBoundingClientRect(),e=d.current.getBoundingClientRect();if(!(t.width>0&&t.height>0&&e.width>0&&e.height>0)){m.current=!1;return}let i={width:window.innerWidth,height:window.innerHeight},u=a,s=g,x=l=>{switch(l){case"bottom":return{top:t.bottom+n,left:t.left};case"top":return{top:t.top-e.height-n,left:t.left};case"right":return{top:t.top,left:t.right+n};case"left":return{top:t.top,left:t.left-e.width-n}}},E=(l,f,c)=>{if(l==="top"||l==="bottom")switch(f){case"start":return{...c,left:t.left+h};case"center":return{...c,left:t.left+t.width/2-e.width/2+h};case"end":return{...c,left:t.right-e.width+h}}else switch(f){case"start":return{...c,top:t.top+h};case"center":return{...c,top:t.top+t.height/2-e.height/2+h};case"end":return{...c,top:t.bottom-e.height+h}}},r=x(u);r=E(u,s,r);let L;if(A){let l={top:t.top-n-o,bottom:i.height-t.bottom-n-o,left:t.left-n-o,right:i.width-t.right-n-o},f=a==="top"||a==="bottom"?e.height:e.width,c=M[a];f>l[a]&&l[c]>l[a]&&(u=c,r=x(u),r=E(u,s,r));let S=i.width-e.width-o,H=i.height-e.height-o,b=u==="top"||u==="bottom";r.left>S&&(r.left=S,b&&(s="end")),r.left<o&&(r.left=o,b&&(s="start")),r.top>H&&(r.top=H,b||(s="end")),r.top<o&&(r.top=o,b||(s="start")),L=Math.max(0,i.height-2*o)}m.current=!0,v({top:r.top,left:r.left,actualSide:u,actualAlign:s,isReady:!0,availableHeight:L})},[w,d,a,g,n,h,A,o]);return B(()=>{if(!y)return;let t=0;m.current=!1,v(i=>i.isReady?{...i,isReady:!1}:i);let e=()=>{R(),m.current||(t=requestAnimationFrame(e))};t=requestAnimationFrame(e);let p=()=>R();return window.addEventListener("resize",p),window.addEventListener("scroll",p,{passive:!0,capture:!0}),()=>{t&&cancelAnimationFrame(t),window.removeEventListener("resize",p),window.removeEventListener("scroll",p,{capture:!0})}},[R,y]),T}export{q as usePositioning};
1
+ "use client";import{useState as C,useLayoutEffect as F,useCallback as M,useRef as k}from"react";import{ownerWindowOf as j}from"../../../lib/owner-document.js";var q={top:"bottom",bottom:"top",left:"right",right:"left"};function U({triggerRef:m,contentRef:g,isOpen:v,side:a="bottom",align:R="start",sideOffset:n=4,alignOffset:h=0,avoidCollisions:A=!0,collisionPadding:o=8}){let[B,x]=C({top:0,left:0,actualSide:a,actualAlign:R,isReady:!1}),b=k(!1),S=M(()=>{if(!m.current||!g.current)return;let t=m.current.getBoundingClientRect(),e=g.current.getBoundingClientRect();if(!(t.width>0&&t.height>0&&e.width>0&&e.height>0)){b.current=!1;return}let s=j(m.current),i={width:s.innerWidth,height:s.innerHeight},u=a,p=R,E=l=>{switch(l){case"bottom":return{top:t.bottom+n,left:t.left};case"top":return{top:t.top-e.height-n,left:t.left};case"right":return{top:t.top,left:t.right+n};case"left":return{top:t.top,left:t.left-e.width-n}}},L=(l,w,c)=>{if(l==="top"||l==="bottom")switch(w){case"start":return{...c,left:t.left+h};case"center":return{...c,left:t.left+t.width/2-e.width/2+h};case"end":return{...c,left:t.right-e.width+h}}else switch(w){case"start":return{...c,top:t.top+h};case"center":return{...c,top:t.top+t.height/2-e.height/2+h};case"end":return{...c,top:t.bottom-e.height+h}}},r=E(u);r=L(u,p,r);let H;if(A){let l={top:t.top-n-o,bottom:i.height-t.bottom-n-o,left:t.left-n-o,right:i.width-t.right-n-o},w=a==="top"||a==="bottom"?e.height:e.width,c=q[a];w>l[a]&&l[c]>l[a]&&(u=c,r=E(u),r=L(u,p,r));let y=i.width-e.width-o,T=i.height-e.height-o,d=u==="top"||u==="bottom";r.left>y&&(r.left=y,d&&(p="end")),r.left<o&&(r.left=o,d&&(p="start")),r.top>T&&(r.top=T,d||(p="end")),r.top<o&&(r.top=o,d||(p="start")),H=Math.max(0,i.height-2*o)}b.current=!0,x({top:r.top,left:r.left,actualSide:u,actualAlign:p,isReady:!0,availableHeight:H})},[m,g,a,R,n,h,A,o]);return F(()=>{if(!v)return;let t=0;b.current=!1,x(i=>i.isReady?{...i,isReady:!1}:i);let e=()=>{S(),b.current||(t=requestAnimationFrame(e))};t=requestAnimationFrame(e);let f=()=>S(),s=j(m.current);return s.addEventListener("resize",f),s.addEventListener("scroll",f,{passive:!0,capture:!0}),()=>{t&&cancelAnimationFrame(t),s.removeEventListener("resize",f),s.removeEventListener("scroll",f,{capture:!0})}},[S,v]),B}export{U as usePositioning};
@@ -1 +1 @@
1
- "use strict";"use client";var H=Object.defineProperty;var ye=Object.getOwnPropertyDescriptor;var xe=Object.getOwnPropertyNames;var be=Object.prototype.hasOwnProperty;var ve=(c,l)=>{for(var f in l)H(c,f,{get:l[f],enumerable:!0})},ke=(c,l,f,h)=>{if(l&&typeof l=="object"||typeof l=="function")for(let m of xe(l))!be.call(c,m)&&m!==f&&H(c,m,{get:()=>l[m],enumerable:!(h=ye(l,m))||h.enumerable});return c};var Fe=c=>ke(H({},"__esModule",{value:!0}),c);var Ee={};ve(Ee,{FileSelector:()=>Le});module.exports=Fe(Ee);var a=require("react"),g=require("../../lib/cn.cjs"),v=require("../../lib/i18n.cjs"),t=require("react/jsx-runtime"),we={sm:{dropzone:"py-4 px-3",text:"text-xs",subtext:"text-[10px]",icon:"w-6 h-6",button:"px-2.5 py-1.5 text-xs",fileItem:"py-1 px-2 text-xs",gap:"gap-1"},md:{dropzone:"py-6 px-4",text:"text-sm",subtext:"text-xs",icon:"w-8 h-8",button:"px-3 py-2 text-sm",fileItem:"py-1.5 px-3 text-sm",gap:"gap-1.5"},lg:{dropzone:"py-8 px-6",text:"text-base",subtext:"text-sm",icon:"w-10 h-10",button:"px-4 py-2.5 text-base",fileItem:"py-2 px-4 text-base",gap:"gap-2"}},te=c=>{if(c===0)return"0 B";let l=["B","KB","MB","GB"],f=Math.floor(Math.log(c)/Math.log(1024));return`${(c/Math.pow(1024,f)).toFixed(f===0?0:1)} ${l[f]}`},j=c=>c.webkitRelativePath||c.name,Se=(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-full h-full",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"})}),Ne=(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-full h-full",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 9.776c.112-.017.227-.026.344-.026h15.812c.117 0 .232.009.344.026m-16.5 0a2.25 2.25 0 00-1.883 2.542l.857 6a2.25 2.25 0 002.227 1.932H19.05a2.25 2.25 0 002.227-1.932l.857-6a2.25 2.25 0 00-1.883-2.542m-16.5 0V6A2.25 2.25 0 016 3.75h3.879a1.5 1.5 0 011.06.44l2.122 2.12a1.5 1.5 0 001.06.44H18A2.25 2.25 0 0120.25 9v.776"})}),De=0;async function Ce(c){let l=[],f=async h=>{if(h.isFile){let m=await new Promise((x,r)=>h.file(x,r));l.push(m)}else if(h.isDirectory){let m=h.createReader(),x=()=>new Promise((L,A)=>m.readEntries(L,A)),r=await x();for(;r.length>0;){for(let L of r)await f(L);r=await x()}}};for(let h of c)await f(h);return l}function Le({value:c,onChange:l,accept:f,multiple:h=!1,maxSize:m=10*1024*1024,maxFiles:x,mode:r="file",variant:L="dropzone",size:A="md",disabled:o=!1,readOnly:s=!1,label:U,helperText:z,error:F,showFileList:V=!0,placeholder:G,browseLabel:B,browseFolderLabel:K,labels:re,icon:oe,onReject:_,className:se}){let i=(0,v.useUILabels)(re),[ie,P]=(0,a.useState)([]),[Z,R]=(0,a.useState)(!1),k=(0,a.useRef)(null),M=(0,a.useRef)(null),S=(0,a.useId)(),w=c!==void 0,N=w?c.map((e,u)=>({file:e,id:`ctrl-${u}`})):ie,d=we[A],D=h||r!=="file";(0,a.useEffect)(()=>{r==="directory"&&k.current&&k.current.setAttribute("webkitdirectory",""),r==="both"&&M.current&&M.current.setAttribute("webkitdirectory","")},[r]);let T=(0,a.useMemo)(()=>te(m),[m]),W=(0,a.useMemo)(()=>f?f.split(",").map(e=>e.trim()).map(e=>e.startsWith(".")?e.toUpperCase():e.endsWith("/*")?e.replace("/*","").toUpperCase():e).join(", "):i.fileSelectorAllFiles,[f,i.fileSelectorAllFiles]),q=r==="directory"?i.fileSelectorDropFolder:r==="both"?i.fileSelectorDropFilesOrFolders:h?i.fileSelectorDropFiles:i.fileSelectorDropFile,ne=r==="directory"?i.fileSelectorBrowseFolder:i.fileSelectorBrowse,le=i.fileSelectorBrowseFolder,J=(0,v.formatUILabel)(i.fileSelectorTooLarge,{maxSize:T}),Q=(0,v.formatUILabel)(i.fileSelectorTypeNotAccepted,{accept:W}),X=(0,a.useCallback)(e=>{if(e.size>m)return J;if(f){let u=f.split(",").map(n=>n.trim()),p=`.${e.name.split(".").pop()?.toLowerCase()}`;if(!u.some(n=>n.startsWith(".")?p===n.toLowerCase():n.endsWith("/*")?e.type.startsWith(n.replace("/*","/")):e.type===n))return Q}return null},[f,m,J,Q]),E=(0,a.useCallback)(e=>{if(o||s)return;let u=Array.from(e),p=[];for(let y of u){let n=X(y);n?_?.(y,n):p.push(y)}if(p.length!==0)if(w)if(D){let n=[...c??[],...p],b=x?n.slice(0,x):n;l?.(b)}else l?.([p[0]]);else P(y=>{let n=p.map(b=>({file:b,id:`file-${++De}`}));if(D){let b=[...y,...n],ee=x?b.slice(0,x):b,me=ee.map(he=>he.file);return l?.(me),ee}return l?.([p[0]]),[n[0]]})},[o,s,w,D,x,c,l,_,X]),ae=(0,a.useCallback)(e=>{if(!(o||s)){if(w){let u=(c??[]).filter((p,y)=>y!==e);l?.(u)}else P(u=>{let p=u.filter((y,n)=>n!==e);return l?.(p.map(y=>y.file)),p});k.current&&(k.current.value="")}},[o,s,w,c,l]),ce=(0,a.useCallback)(()=>{o||s||(w?l?.([]):(P([]),l?.([])),k.current&&(k.current.value=""))},[o,s,w,l]),Y=(0,a.useCallback)(e=>{e.target.files&&e.target.files.length>0&&E(e.target.files)},[E]),fe=(0,a.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),!o&&!s&&R(!0)},[o,s]),ue=(0,a.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),R(!1)},[]),pe=(0,a.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),R(!1),o||s)return;let u=e.dataTransfer.items;if(u&&u.length>0&&(r==="directory"||r==="both")){let p=[];for(let n=0;n<u.length;n++){let b=u[n].webkitGetAsEntry?.();b&&p.push(b)}if(p.some(n=>n.isDirectory)){Ce(p).then(n=>{n.length>0&&E(n)});return}}e.dataTransfer.files&&e.dataTransfer.files.length>0&&E(e.dataTransfer.files)},[o,s,r,E]),I=(0,a.useCallback)(()=>{!o&&!s&&k.current?.click()},[o,s]),O=(0,a.useCallback)(()=>{!o&&!s&&M.current?.click()},[o,s]),C=N.length>0,ge=oe||(r==="directory"?Ne:Se),de=V&&C&&(0,t.jsxs)("div",{className:(0,g.cn)("flex flex-col",d.gap),children:[N.map((e,u)=>(0,t.jsxs)("div",{className:(0,g.cn)("flex items-center justify-between rounded-md border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",d.fileItem),children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4 shrink-0 text-gray-500 dark:text-gray-400",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),(0,t.jsx)("span",{className:"truncate text-gray-700 dark:text-gray-300",children:j(e.file)}),(0,t.jsxs)("span",{className:"shrink-0 text-gray-500 dark:text-gray-400",children:["(",te(e.file.size),")"]})]}),!o&&!s&&(0,t.jsx)("button",{type:"button",onClick:()=>ae(u),className:"shrink-0 ml-2 text-gray-500 hover:text-red-600 dark:text-gray-400 dark:hover:text-red-400 transition-colors cursor-pointer","aria-label":(0,v.formatUILabel)(i.fileSelectorRemove,{name:j(e.file)}),children:(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]},e.id)),D&&N.length>1&&!o&&!s&&(0,t.jsx)("button",{type:"button",onClick:ce,className:(0,g.cn)("self-start text-gray-500 hover:text-red-600 dark:text-gray-400 dark:hover:text-red-400 transition-colors cursor-pointer",d.subtext),children:i.fileSelectorRemoveAll})]}),$=(0,g.cn)("rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 font-medium transition-colors","hover:bg-gray-50 dark:hover:bg-gray-700","disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer","focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 focus:ring-offset-1",d.button,F&&"border-red-300 dark:border-red-600");return(0,t.jsxs)("div",{className:(0,g.cn)("flex flex-col",d.gap,se),children:[U&&(0,t.jsx)("label",{htmlFor:S,className:(0,g.cn)("block font-medium text-gray-700 dark:text-gray-300",d.text),children:U}),(0,t.jsx)("input",{ref:k,id:S,type:"file",accept:r!=="directory"?f:void 0,multiple:D,onChange:Y,className:"sr-only",disabled:o||s,"aria-describedby":F?`${S}-error`:z?`${S}-helper`:void 0,"aria-invalid":!!F}),r==="both"&&(0,t.jsx)("input",{ref:M,type:"file",onChange:Y,className:"sr-only",disabled:o||s,tabIndex:-1,"aria-hidden":"true"}),L==="dropzone"?(0,t.jsxs)("div",{role:r==="both"?"group":"button",tabIndex:r==="both"?void 0:o||s?-1:0,onClick:r==="both"?void 0:I,onKeyDown:r==="both"?void 0:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),I())},onDragOver:fe,onDragLeave:ue,onDrop:pe,className:(0,g.cn)("flex flex-col items-center justify-center rounded-lg border-2 border-dashed transition-colors",d.dropzone,Z&&!o&&!s?"border-synertech-primary-500 bg-synertech-primary-50 dark:bg-synertech-primary-900/20":"border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800",!o&&!s&&"hover:border-synertech-primary-400 dark:hover:border-synertech-primary-500 hover:bg-gray-50 dark:hover:bg-gray-800/70",r!=="both"&&!o&&!s&&"cursor-pointer",o&&"opacity-50 cursor-not-allowed",s&&"cursor-default",F&&"border-red-300 dark:border-red-600"),"aria-label":r==="both"?i.fileSelectorDropZone:G||q,children:[(0,t.jsx)("div",{className:(0,g.cn)("text-gray-500 dark:text-gray-400 mb-2",d.icon,Z&&"text-synertech-primary-600 dark:text-synertech-primary-400"),children:ge}),(0,t.jsxs)("p",{className:(0,g.cn)("text-gray-600 dark:text-gray-400",d.text),children:[G||q," ",!o&&!s&&r!=="both"&&(0,t.jsx)("span",{className:"text-synertech-primary-600 dark:text-synertech-primary-400 font-medium",children:B||ne})]}),r==="both"&&!o&&!s&&(0,t.jsxs)("div",{className:(0,g.cn)("flex items-center gap-3 mt-1",d.text),children:[(0,t.jsx)("button",{type:"button",onClick:I,className:"text-synertech-primary-600 dark:text-synertech-primary-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 focus:ring-offset-1 rounded",children:B||i.fileSelectorBrowseFiles}),(0,t.jsx)("span",{className:"text-gray-500 dark:text-gray-400",children:"\xB7"}),(0,t.jsx)("button",{type:"button",onClick:O,className:"text-synertech-primary-600 dark:text-synertech-primary-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 focus:ring-offset-1 rounded",children:K||le})]}),(0,t.jsx)("p",{className:(0,g.cn)("text-gray-500 dark:text-gray-400 mt-1",d.subtext),children:D&&x?(0,v.formatUILabel)(i.fileSelectorConstraintsMaxFiles,{accept:W,maxSize:T,maxFiles:x}):(0,v.formatUILabel)(i.fileSelectorConstraints,{accept:W,maxSize:T})})]}):(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[r==="both"?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{type:"button",onClick:I,disabled:o||s,className:$,children:B||(C?i.fileSelectorChangeFiles:i.fileSelectorChooseFiles)}),(0,t.jsx)("button",{type:"button",onClick:O,disabled:o||s,className:$,children:K||i.fileSelectorChooseFolder})]}):(0,t.jsx)("button",{type:"button",onClick:I,disabled:o||s,className:$,children:B||(r==="directory"?C?i.fileSelectorChangeFolder:i.fileSelectorChooseFolder:C?i.fileSelectorChangeFile:i.fileSelectorChooseFile)}),!C&&(0,t.jsx)("span",{className:(0,g.cn)("text-gray-500 dark:text-gray-400",d.text),children:r==="directory"?i.fileSelectorNoFolder:r==="both"?i.fileSelectorNoFileOrFolder:i.fileSelectorNoFile}),C&&!V&&(0,t.jsx)("span",{className:(0,g.cn)("text-gray-600 dark:text-gray-400 truncate",d.text),children:N.length===1?j(N[0].file):(0,v.formatUILabel)(i.fileSelectorFilesSelected,{count:N.length})})]}),de,F&&(0,t.jsx)("p",{id:`${S}-error`,className:(0,g.cn)("text-red-600 dark:text-red-400",d.subtext),role:"alert",children:F}),z&&!F&&(0,t.jsx)("p",{id:`${S}-helper`,className:(0,g.cn)("text-gray-500 dark:text-gray-400",d.subtext),children:z})]})}0&&(module.exports={FileSelector});
1
+ "use strict";"use client";var j=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var ye=Object.getOwnPropertyNames;var xe=Object.prototype.hasOwnProperty;var be=(c,a)=>{for(var f in a)j(c,f,{get:a[f],enumerable:!0})},ve=(c,a,f,m)=>{if(a&&typeof a=="object"||typeof a=="function")for(let d of ye(a))!xe.call(c,d)&&d!==f&&j(c,d,{get:()=>a[d],enumerable:!(m=me(a,d))||m.enumerable});return c};var ke=c=>ve(j({},"__esModule",{value:!0}),c);var Le={};be(Le,{FileSelector:()=>De});module.exports=ke(Le);var l=require("react"),p=require("../../lib/cn.cjs"),b=require("../../lib/i18n.cjs"),t=require("react/jsx-runtime"),Fe={sm:{dropzone:"py-4 px-3",text:"text-xs",subtext:"text-[10px]",icon:"w-6 h-6",button:"px-2.5 py-1.5 text-xs",fileItem:"py-1 px-2 text-xs",gap:"gap-1"},md:{dropzone:"py-6 px-4",text:"text-sm",subtext:"text-xs",icon:"w-8 h-8",button:"px-3 py-2 text-sm",fileItem:"py-1.5 px-3 text-sm",gap:"gap-1.5"},lg:{dropzone:"py-8 px-6",text:"text-base",subtext:"text-sm",icon:"w-10 h-10",button:"px-4 py-2.5 text-base",fileItem:"py-2 px-4 text-base",gap:"gap-2"}},re=c=>{if(c===0)return"0 B";let a=["B","KB","MB","GB"],f=Math.floor(Math.log(c)/Math.log(1024));return`${(c/Math.pow(1024,f)).toFixed(f===0?0:1)} ${a[f]}`},U=c=>c.webkitRelativePath||c.name,we=(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-full h-full",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"})}),Se=(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-full h-full",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 9.776c.112-.017.227-.026.344-.026h15.812c.117 0 .232.009.344.026m-16.5 0a2.25 2.25 0 00-1.883 2.542l.857 6a2.25 2.25 0 002.227 1.932H19.05a2.25 2.25 0 002.227-1.932l.857-6a2.25 2.25 0 00-1.883-2.542m-16.5 0V6A2.25 2.25 0 016 3.75h3.879a1.5 1.5 0 011.06.44l2.122 2.12a1.5 1.5 0 001.06.44H18A2.25 2.25 0 0120.25 9v.776"})}),Ne=0;async function Ce(c){let a=[],f=async m=>{if(m.isFile){let d=await new Promise((y,r)=>m.file(y,r));a.push(d)}else if(m.isDirectory){let d=m.createReader(),y=()=>new Promise((L,z)=>d.readEntries(L,z)),r=await y();for(;r.length>0;){for(let L of r)await f(L);r=await y()}}};for(let m of c)await f(m);return a}function De({value:c,onChange:a,accept:f,multiple:m=!1,maxSize:d=10*1024*1024,maxFiles:y,mode:r="file",variant:L="dropzone",size:z="md",disabled:o=!1,readOnly:s=!1,label:V,helperText:P,error:k,showFileList:G=!0,placeholder:K,browseLabel:B,browseFolderLabel:_,labels:oe,icon:se,onReject:Z,className:ne}){let n=(0,b.useUILabels)(oe),[q,ie]=(0,l.useState)([]),R=(0,l.useRef)(q),[J,T]=(0,l.useState)(!1),v=(0,l.useRef)(null),M=(0,l.useRef)(null),S=(0,l.useId)(),F=c!==void 0,N=F?c.map((e,u)=>({file:e,id:`ctrl-${u}`})):q,g=Fe[z],w=(0,l.useCallback)(e=>{R.current=e,ie(e),a?.(e.map(u=>u.file))},[a]),C=m||r!=="file";(0,l.useEffect)(()=>{r==="directory"&&v.current&&v.current.setAttribute("webkitdirectory",""),r==="both"&&M.current&&M.current.setAttribute("webkitdirectory","")},[r]);let W=(0,l.useMemo)(()=>re(d),[d]),$=(0,l.useMemo)(()=>f?f.split(",").map(e=>e.trim()).map(e=>e.startsWith(".")?e.toUpperCase():e.endsWith("/*")?e.replace("/*","").toUpperCase():e).join(", "):n.fileSelectorAllFiles,[f,n.fileSelectorAllFiles]),Q=r==="directory"?n.fileSelectorDropFolder:r==="both"?n.fileSelectorDropFilesOrFolders:m?n.fileSelectorDropFiles:n.fileSelectorDropFile,le=r==="directory"?n.fileSelectorBrowseFolder:n.fileSelectorBrowse,ae=n.fileSelectorBrowseFolder,X=(0,b.formatUILabel)(n.fileSelectorTooLarge,{maxSize:W}),Y=(0,b.formatUILabel)(n.fileSelectorTypeNotAccepted,{accept:$}),O=(0,l.useCallback)(e=>{if(e.size>d)return X;if(f){let u=f.split(",").map(i=>i.trim()),h=`.${e.name.split(".").pop()?.toLowerCase()}`;if(!u.some(i=>i.startsWith(".")?h===i.toLowerCase():i.endsWith("/*")?e.type.startsWith(i.replace("/*","/")):e.type===i))return Y}return null},[f,d,X,Y]),I=(0,l.useCallback)(e=>{if(o||s)return;let u=Array.from(e),h=[];for(let x of u){let i=O(x);i?Z?.(x,i):h.push(x)}if(h.length!==0)if(F)if(C){let i=[...c??[],...h],A=y?i.slice(0,y):i;a?.(A)}else a?.([h[0]]);else{let x=h.map(i=>({file:i,id:`file-${++Ne}`}));if(C){let i=[...R.current,...x];w(y?i.slice(0,y):i)}else w([x[0]])}},[o,s,F,C,y,c,a,Z,O,w]),ce=(0,l.useCallback)(e=>{if(!(o||s)){if(F){let u=(c??[]).filter((h,x)=>x!==e);a?.(u)}else w(R.current.filter((u,h)=>h!==e));v.current&&(v.current.value="")}},[o,s,F,c,a,w]),fe=(0,l.useCallback)(()=>{o||s||(F?a?.([]):w([]),v.current&&(v.current.value=""))},[o,s,F,a,w]),ee=(0,l.useCallback)(e=>{e.target.files&&e.target.files.length>0&&I(e.target.files)},[I]),ue=(0,l.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),!o&&!s&&T(!0)},[o,s]),pe=(0,l.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),T(!1)},[]),ge=(0,l.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),T(!1),o||s)return;let u=e.dataTransfer.items;if(u&&u.length>0&&(r==="directory"||r==="both")){let h=[];for(let i=0;i<u.length;i++){let A=u[i].webkitGetAsEntry?.();A&&h.push(A)}if(h.some(i=>i.isDirectory)){Ce(h).then(i=>{i.length>0&&I(i)});return}}e.dataTransfer.files&&e.dataTransfer.files.length>0&&I(e.dataTransfer.files)},[o,s,r,I]),E=(0,l.useCallback)(()=>{!o&&!s&&v.current?.click()},[o,s]),te=(0,l.useCallback)(()=>{!o&&!s&&M.current?.click()},[o,s]),D=N.length>0,de=se||(r==="directory"?Se:we),he=G&&D&&(0,t.jsxs)("div",{className:(0,p.cn)("flex flex-col",g.gap),children:[N.map((e,u)=>(0,t.jsxs)("div",{className:(0,p.cn)("flex items-center justify-between rounded-md border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",g.fileItem),children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4 shrink-0 text-gray-500 dark:text-gray-400",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),(0,t.jsx)("span",{className:"truncate text-gray-700 dark:text-gray-300",children:U(e.file)}),(0,t.jsxs)("span",{className:"shrink-0 text-gray-500 dark:text-gray-400",children:["(",re(e.file.size),")"]})]}),!o&&!s&&(0,t.jsx)("button",{type:"button",onClick:()=>ce(u),className:"shrink-0 ml-2 text-gray-500 hover:text-red-600 dark:text-gray-400 dark:hover:text-red-400 transition-colors cursor-pointer","aria-label":(0,b.formatUILabel)(n.fileSelectorRemove,{name:U(e.file)}),children:(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]},e.id)),C&&N.length>1&&!o&&!s&&(0,t.jsx)("button",{type:"button",onClick:fe,className:(0,p.cn)("self-start text-gray-500 hover:text-red-600 dark:text-gray-400 dark:hover:text-red-400 transition-colors cursor-pointer",g.subtext),children:n.fileSelectorRemoveAll})]}),H=(0,p.cn)("rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 font-medium transition-colors","hover:bg-gray-50 dark:hover:bg-gray-700","disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer","focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 focus:ring-offset-1",g.button,k&&"border-red-300 dark:border-red-600");return(0,t.jsxs)("div",{className:(0,p.cn)("flex flex-col",g.gap,ne),children:[V&&(0,t.jsx)("label",{htmlFor:S,className:(0,p.cn)("block font-medium text-gray-700 dark:text-gray-300",g.text),children:V}),(0,t.jsx)("input",{ref:v,id:S,type:"file",accept:r!=="directory"?f:void 0,multiple:C,onChange:ee,className:"sr-only",disabled:o||s,"aria-describedby":k?`${S}-error`:P?`${S}-helper`:void 0,"aria-invalid":!!k}),r==="both"&&(0,t.jsx)("input",{ref:M,type:"file",onChange:ee,className:"sr-only",disabled:o||s,tabIndex:-1,"aria-hidden":"true"}),L==="dropzone"?(0,t.jsxs)("div",{role:r==="both"?"group":"button",tabIndex:r==="both"?void 0:o||s?-1:0,onClick:r==="both"?void 0:E,onKeyDown:r==="both"?void 0:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),E())},onDragOver:ue,onDragLeave:pe,onDrop:ge,className:(0,p.cn)("flex flex-col items-center justify-center rounded-lg border-2 border-dashed transition-colors",g.dropzone,J&&!o&&!s?"border-synertech-primary-500 bg-synertech-primary-50 dark:bg-synertech-primary-900/20":"border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800",!o&&!s&&"hover:border-synertech-primary-400 dark:hover:border-synertech-primary-500 hover:bg-gray-50 dark:hover:bg-gray-800/70",r!=="both"&&!o&&!s&&"cursor-pointer",o&&"opacity-50 cursor-not-allowed",s&&"cursor-default",k&&"border-red-300 dark:border-red-600"),"aria-label":r==="both"?n.fileSelectorDropZone:K||Q,children:[(0,t.jsx)("div",{className:(0,p.cn)("text-gray-500 dark:text-gray-400 mb-2",g.icon,J&&"text-synertech-primary-600 dark:text-synertech-primary-400"),children:de}),(0,t.jsxs)("p",{className:(0,p.cn)("text-gray-600 dark:text-gray-400",g.text),children:[K||Q," ",!o&&!s&&r!=="both"&&(0,t.jsx)("span",{className:"text-synertech-primary-600 dark:text-synertech-primary-400 font-medium",children:B||le})]}),r==="both"&&!o&&!s&&(0,t.jsxs)("div",{className:(0,p.cn)("flex items-center gap-3 mt-1",g.text),children:[(0,t.jsx)("button",{type:"button",onClick:E,className:"text-synertech-primary-600 dark:text-synertech-primary-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 focus:ring-offset-1 rounded",children:B||n.fileSelectorBrowseFiles}),(0,t.jsx)("span",{className:"text-gray-500 dark:text-gray-400",children:"\xB7"}),(0,t.jsx)("button",{type:"button",onClick:te,className:"text-synertech-primary-600 dark:text-synertech-primary-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 focus:ring-offset-1 rounded",children:_||ae})]}),(0,t.jsx)("p",{className:(0,p.cn)("text-gray-500 dark:text-gray-400 mt-1",g.subtext),children:C&&y?(0,b.formatUILabel)(n.fileSelectorConstraintsMaxFiles,{accept:$,maxSize:W,maxFiles:y}):(0,b.formatUILabel)(n.fileSelectorConstraints,{accept:$,maxSize:W})})]}):(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[r==="both"?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{type:"button",onClick:E,disabled:o||s,className:H,children:B||(D?n.fileSelectorChangeFiles:n.fileSelectorChooseFiles)}),(0,t.jsx)("button",{type:"button",onClick:te,disabled:o||s,className:H,children:_||n.fileSelectorChooseFolder})]}):(0,t.jsx)("button",{type:"button",onClick:E,disabled:o||s,className:H,children:B||(r==="directory"?D?n.fileSelectorChangeFolder:n.fileSelectorChooseFolder:D?n.fileSelectorChangeFile:n.fileSelectorChooseFile)}),!D&&(0,t.jsx)("span",{className:(0,p.cn)("text-gray-500 dark:text-gray-400",g.text),children:r==="directory"?n.fileSelectorNoFolder:r==="both"?n.fileSelectorNoFileOrFolder:n.fileSelectorNoFile}),D&&!G&&(0,t.jsx)("span",{className:(0,p.cn)("text-gray-600 dark:text-gray-400 truncate",g.text),children:N.length===1?U(N[0].file):(0,b.formatUILabel)(n.fileSelectorFilesSelected,{count:N.length})})]}),he,k&&(0,t.jsx)("p",{id:`${S}-error`,className:(0,p.cn)("text-red-600 dark:text-red-400",g.subtext),role:"alert",children:k}),P&&!k&&(0,t.jsx)("p",{id:`${S}-helper`,className:(0,p.cn)("text-gray-500 dark:text-gray-400",g.subtext),children:P})]})}0&&(module.exports={FileSelector});