@nice2dev/ui-forms 1.0.20 → 1.0.22
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.
- package/dist/NicePinCodeInput-3WugpLHi-CTyDHOeZ.cjs +419 -0
- package/dist/NicePinCodeInput-3WugpLHi-D5Vvnmzl.js +11037 -0
- package/dist/NicePinCodeInput-DDK6qqFW-BLZLxqrK.js +11037 -0
- package/dist/NicePinCodeInput-DDK6qqFW-Cfaplf1K.cjs +419 -0
- package/dist/NicePinCodeInput-DdXTdocN-4kd-wzjS.cjs +419 -0
- package/dist/NicePinCodeInput-DdXTdocN-B0gPW-cM.js +11037 -0
- package/dist/NiceSavedQueryPanel-Dryck7pv-D7TNDKOP.cjs +596 -0
- package/dist/NiceSavedQueryPanel-Dryck7pv-sJJxy7m_.js +6745 -0
- package/dist/NiceSavedQueryPanel-DtgcsEls-CsL2rpj-.cjs +596 -0
- package/dist/NiceSavedQueryPanel-DtgcsEls-rhi_OgS_.js +6745 -0
- package/dist/NiceSavedQueryPanel-z29D7N_A-D8tnSKo-.cjs +596 -0
- package/dist/NiceSavedQueryPanel-z29D7N_A-K3YHc_8w.js +6745 -0
- package/dist/charts-8Bqzj1TE-DQgq7NRB.js +3880 -0
- package/dist/charts-8Bqzj1TE-kxYozvdM.cjs +546 -0
- package/dist/charts-CLbJ4Zjq-CLC7wIJJ.cjs +546 -0
- package/dist/charts-CLbJ4Zjq-DVTOmEgg.js +3880 -0
- package/dist/charts-ClxW-i5q-DoJYE4HW.cjs +546 -0
- package/dist/charts-ClxW-i5q-Dw-2ffUs.js +3880 -0
- package/dist/index-7ZNfGfEK.js +22561 -0
- package/dist/index-B-WxtREy-h2zc1DNu.cjs +4504 -0
- package/dist/index-B-WxtREy-pXs9d_Xc.js +41393 -0
- package/dist/index-BMQ-F0zE-CGrCifaz.cjs +4504 -0
- package/dist/index-BMQ-F0zE-CTvr4Txe.js +41586 -0
- package/dist/index-ByDRtfrm-CmMM9LcZ.js +41407 -0
- package/dist/index-ByDRtfrm-lw-6968-.cjs +4504 -0
- package/dist/index-ChNAl7-x.cjs +404 -0
- package/dist/index-DDNMHIfH.cjs +404 -0
- package/dist/index-DLdxrnF6.cjs +404 -0
- package/dist/index-IT5Wo3RG.js +22559 -0
- package/dist/index-Uxu6da8j.js +22571 -0
- package/dist/index.cjs +7335 -1
- package/dist/index.d.ts +292 -1
- package/dist/index.mjs +93244 -8
- package/package.json +1 -1
|
@@ -0,0 +1,596 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),J=require("./index-ChNAl7-x.cjs"),t=require("react"),Ti=require("react-dom"),Tt=({open:n,onClose:a,title:r,size:l="md",children:d,footer:m,closeOnOverlay:f=!0,closeOnEscape:o=!0,fullscreenable:g,zIndex:N,className:S,style:K,displayStyle:A})=>{const{t:R}=J.ue(),P=t.useContext(J.wt),G=t.useRef(null),[y,s]=t.useState(!1),w=J.Us("modal",A),c=J.Ks("modal",A);if(J.ll(G,n),t.useEffect(()=>{if(!n||!o)return;const F=te=>{te.key==="Escape"&&a()};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[n,o,a]),t.useEffect(()=>(n?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[n]),!n||typeof document>"u")return null;const I=e.jsx("div",{className:"nice-modal-overlay",style:N?{zIndex:N}:void 0,onClick:f?a:void 0,children:e.jsxs("div",{ref:G,className:`nice-modal nice-modal--${y?"full":l} nice-modal--ds-${c} ${S||""}`,style:{...w,...K},role:"dialog","aria-modal":"true","aria-label":r,onClick:F=>F.stopPropagation(),children:[r&&e.jsxs("div",{className:"nice-modal__header",children:[e.jsx("h2",{className:"nice-modal__title",children:r}),e.jsxs("div",{className:"nice-modal__header-actions",children:[g&&e.jsx("button",{type:"button",className:"nice-modal__fullscreen",onClick:()=>s(F=>!F),"aria-label":y?"Exit fullscreen":"Fullscreen",children:y?"⇲":"⇱"}),e.jsx("button",{type:"button",className:"nice-modal__close",onClick:a,"aria-label":R("controls.close","Close"),children:e.jsx("svg",{width:"24",height:"24",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{d:"M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"})})})]})]}),e.jsx("div",{className:"nice-modal__body",children:d}),m&&e.jsx("div",{className:"nice-modal__footer",children:m})]})});return Ti.createPortal(I,(P==null?void 0:P.portalTarget)??document.body)};function Ei(n,a,r){const l=[];if(a<=1)return a===1&&l.push(1),l;const d=Math.max(2,n-r),m=Math.min(a-1,n+r);l.push(1),d>2&&l.push("dots");for(let f=d;f<=m;f++)l.push(f);return m<a-1&&l.push("dots"),l.push(a),l}const ci=({page:n,totalPages:a,onChange:r,showInfo:l,siblingCount:d=1,size:m="md",showFirstLast:f,showJumpInput:o,jumpInputLabel:g,showPageSize:N,pageSizeOptions:S,pageSize:K,onPageSizeChange:A,disabled:R,className:P,style:G})=>{const y=Ei(n,a,d);return e.jsxs("nav",{className:`nice-pagination nice-pagination--${m} ${P||""}`,style:G,"aria-label":"Pagination",children:[f&&e.jsx("button",{className:"nice-pagination__btn",disabled:R||n<=1,onClick:()=>r(1),"aria-label":"First page",title:"First page",children:"⏮"}),e.jsx("button",{className:"nice-pagination__btn",disabled:R||n<=1,onClick:()=>r(n-1),"aria-label":"Previous",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M12.79 5.23a.75.75 0 01-.02 1.06L8.832 10l3.938 3.71a.75.75 0 11-1.04 1.08l-4.5-4.25a.75.75 0 010-1.08l4.5-4.25a.75.75 0 011.06.02z",clipRule:"evenodd"})})}),y.map((s,w)=>s==="dots"?e.jsx("span",{className:"nice-pagination__ellipsis",children:"…"},`dots-${w}`):e.jsx("button",{className:`nice-pagination__btn ${s===n?"nice-pagination__btn--active":""}`,disabled:R,onClick:()=>r(s),"aria-current":s===n?"page":void 0,children:s},s)),e.jsx("button",{className:"nice-pagination__btn",disabled:R||n>=a,onClick:()=>r(n+1),"aria-label":"Next",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z",clipRule:"evenodd"})})}),f&&e.jsx("button",{className:"nice-pagination__btn",disabled:R||n>=a,onClick:()=>r(a),"aria-label":"Last page",title:"Last page",children:"⏭"}),l&&e.jsxs("span",{className:"nice-pagination__info",children:[n," / ",a]}),o&&e.jsxs("span",{className:"nice-pagination__jump",style:{display:"inline-flex",alignItems:"center",gap:6,marginLeft:8},children:[e.jsx("span",{style:{fontSize:"0.85rem",color:"var(--text-secondary)"},children:g??"Go to"}),e.jsx(J.Je,{size:m==="lg"?"md":"sm",min:1,max:a,step:1,value:n,disabled:R,onChange:s=>{const w=typeof s=="number"?s:Number(s);if(!Number.isNaN(w)){const c=Math.max(1,Math.min(a,Math.floor(w)));r(c)}}})]}),N&&S&&S.length>0&&e.jsx("select",{className:"nice-pagination__size",value:K??S[0],disabled:R,onChange:s=>A==null?void 0:A(Number(s.target.value)),style:{marginLeft:8,padding:"4px 8px",border:"1px solid var(--border-color)",borderRadius:6,background:"var(--bg-primary)",color:"var(--text-primary)",font:"inherit",fontSize:"0.85rem"},"aria-label":"Rows per page",children:S.map(s=>e.jsxs("option",{value:s,children:[s," / page"]},s))})]})};function oi({columns:n,data:a,striped:r,compact:l,emptyText:d,className:m,style:f,accessMode:o,id:g,displayStyle:N}){const S=J.Cl(o,g)==="hidden",K=J.Us("table",N),A=J.Ks("table",N),[R,P]=t.useState(null),G=t.useMemo(()=>R?[...a].sort((s,w)=>{const c=s[R.field]??"",I=w[R.field]??"",F=typeof c=="number"?c-I:String(c).localeCompare(String(I));return R.dir==="desc"?-F:F}):a,[a,R]),y=s=>{P(w=>(w==null?void 0:w.field)===s?w.dir==="asc"?{field:s,dir:"desc"}:null:{field:s,dir:"asc"})};return S?null:e.jsx("div",{className:`nice-table-wrapper ${m||""}`,style:{...K,...f},children:e.jsxs("table",{className:`nice-table nice-table--ds-${A} ${r?"nice-table--striped":""} ${l?"nice-table--compact":""}`,"aria-rowcount":G.length,"aria-colcount":n.length,children:[e.jsx("thead",{children:e.jsx("tr",{children:n.map(s=>{const w=s.sortable?(R==null?void 0:R.field)===s.field?R.dir==="asc"?"ascending":"descending":"none":void 0;return e.jsxs("th",{style:{width:s.width,textAlign:s.align},className:s.sortable?"th--sortable":void 0,onClick:()=>s.sortable&&y(s.field),scope:"col","aria-sort":w,children:[s.header,s.sortable&&(R==null?void 0:R.field)===s.field&&e.jsx("span",{className:"nice-table__sort-icon","aria-hidden":"true",children:R.dir==="asc"?"↑":"↓"})]},s.field)})})}),e.jsx("tbody",{children:G.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:n.length,className:"nice-table__empty",children:d||"No data"})}):G.map((s,w)=>e.jsx("tr",{children:n.map(c=>e.jsx("td",{style:{textAlign:c.align},children:c.render?c.render(s[c.field],s):String(s[c.field]??"")},c.field))},w))})]})})}function di(n,a,r){const l=n.map(d=>d[a]).filter(d=>typeof d=="number");if(l.length===0)return r==="count"?"0":"";switch(r){case"sum":return l.reduce((d,m)=>d+m,0).toLocaleString();case"avg":return(l.reduce((d,m)=>d+m,0)/l.length).toLocaleString(void 0,{maximumFractionDigits:2});case"count":return String(n.length);case"min":return Math.min(...l).toLocaleString();case"max":return Math.max(...l).toLocaleString()}}function ot(n){return n.includes(",")||n.includes('"')||n.includes(`
|
|
2
|
+
`)?`"${n.replace(/"/g,'""')}"`:n}const Gn={width:12,height:12,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0},Ri=()=>e.jsx("svg",{...Gn,children:e.jsx("polyline",{points:"6 15 12 9 18 15"})}),ct=()=>e.jsx("svg",{...Gn,children:e.jsx("polyline",{points:"6 9 12 15 18 9"})}),Fi=()=>e.jsxs("svg",{...Gn,style:{opacity:.55},children:[e.jsx("polyline",{points:"6 10 12 5 18 10"}),e.jsx("polyline",{points:"6 14 12 19 18 14"})]}),wt=()=>e.jsx("svg",{...Gn,children:e.jsx("polyline",{points:"9 6 15 12 9 18"})}),Pi=()=>e.jsxs("svg",{...Gn,children:[e.jsx("polyline",{points:"3 17 9 11 13 15 21 7"}),e.jsx("polyline",{points:"14 7 21 7 21 14"})]}),Oi=()=>e.jsxs("svg",{...Gn,children:[e.jsx("polyline",{points:"3 7 9 13 13 9 21 17"}),e.jsx("polyline",{points:"14 17 21 17 21 10"})]}),Bi=()=>e.jsx("svg",{...Gn,children:e.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})});function Ki(n){return typeof n=="boolean"?n?e.jsx("svg",{className:"nice-datagrid__bool-icon nice-datagrid__bool-icon--true",width:"16",height:"16",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-label":"true",role:"img",children:e.jsx("path",{d:"M4 10.5l4 4L16 6"})}):e.jsx("svg",{className:"nice-datagrid__bool-icon nice-datagrid__bool-icon--false",width:"16",height:"16",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-label":"false",role:"img",children:e.jsx("path",{d:"M5 5l10 10M15 5L5 15"})}):String(n??"")}function ut({columns:n,data:a,keyField:r="id",dataSource:l,sortable:d=!0,sortField:m,sortDirection:f,onSort:o,selectable:g,selectedKeys:N,onSelectionChange:S,pagination:K,pageSize:A=10,page:R,onPageChange:P,totalRows:G,searchable:y,searchPlaceholder:s,virtualScroll:w,rowHeight:c=40,groupBy:I,groupRender:F,onCellEdit:te,editMode:ue="inline",formItems:Ae,formColumns:D=2,editFormTitle:me,formProps:be,onRowEdit:xe,onRowAdd:ee,onRowDelete:ae,bulkActions:M,onBulkDelete:E,exportCsv:b,exportFilename:we="export",detailRow:le,expandedRowKeys:O,onExpandedRowChange:U,columnReorder:Q,onColumnReorder:H,columnResize:_e,rowDraggable:ge,onRowReorder:Te,striped:Xe,compact:nn,loading:De,emptyText:tn,toolbar:Ee,onRowClick:Be,pinnedTopKeys:X,pinnedBottomKeys:ye,colSpan:Ie,showStatusBar:L,contextMenuItems:oe,onContextMenuAction:W,printFriendly:T,keyboardNavigation:ne,focusedCell:je,onFocusedCellChange:V,cellRangeSelection:Le,selectedCellRange:Se,onCellRangeChange:he,clipboard:Qe,clipboardFormat:pn="text",onBeforeCopy:ve,onCopy:kn,onPaste:Nn,quickFilters:Ve,activeQuickFilters:In,onQuickFilterChange:$,columnGroups:de,stateStorageKey:pe,initialState:ke,onStateChange:un,flashRowKeys:Ce,flashDuration:Ke=500,autoFitColumns:mn,showColumnStats:We,rowIndicator:an,frozenRows:Cn,className:Qn,style:Zn,accessMode:et,id:Jn,displayStyle:Hn}){var ni,ti;const hn=J.Cl(et,Jn),mt=hn==="hidden",nt=hn==="readOnly"||hn==="disabled",{t:Pe}=J.ue();J.Us("table",Hn),J.Ks("table",Hn);const qe=J.dc(l??null,{autoLoad:!!l,defaultPageSize:A}),Oe=!!l,Kn=Oe?qe.data:a??[],Ln=Oe?qe.loading:De,[Un,Rn]=t.useState({field:"",dir:null}),[Wn,Xn]=t.useState(1),[u,h]=t.useState(new Set),[v,B]=t.useState(""),[q,k]=t.useState(A),[z,Y]=t.useState(null),[Fe,Re]=t.useState(null),[re,Ze]=t.useState(null),[ln,gn]=t.useState(new Set),[sn,fn]=t.useState(0),tt=t.useRef(null),[zn,Sn]=t.useState(new Set),Tn=O??zn,[on,ht]=t.useState({}),[Mn,Fn]=t.useState(null),[Pn,it]=t.useState(null),[Nt,at]=t.useState(null),[En,pt]=t.useState(null),[Ct,St]=t.useState([]),[Ot,gt]=t.useState(null),[Mt,ft]=t.useState(new Set),[Bt,Kt]=t.useState(null),rt=t.useRef(null),Je=je??Nt,cn=Se??En,bn=In??Ct;t.useEffect(()=>{if(!pe)return;const i=localStorage.getItem(`nice-datagrid-${pe}`);if(i&&!ke)try{const p=JSON.parse(i);p.columnWidths&&ht(p.columnWidths),p.expandedGroups&&gn(new Set(p.expandedGroups))}catch{}},[pe,ke]),t.useEffect(()=>{if(!(Ce!=null&&Ce.size))return;ft(new Set(Ce));const i=setTimeout(()=>ft(new Set),Ke);return()=>clearTimeout(i)},[Ce,Ke]),t.useEffect(()=>{if(!Pn)return;const i=()=>it(null);return document.addEventListener("click",i),()=>document.removeEventListener("click",i)},[Pn]);const Dt=t.useCallback((i,p)=>{oe!=null&&oe.length&&(i.preventDefault(),it({x:i.clientX,y:i.clientY,row:p}))},[oe]),lt=t.useCallback(i=>{const p=new Set(Tn);p.has(i)?p.delete(i):p.add(i),U?U(p):Sn(p)},[Tn,U]),_=t.useCallback((i,p)=>{var ce;if(!_e)return;p.preventDefault();const x=p.clientX,j=((ce=p.target.closest("th"))==null?void 0:ce.offsetWidth)??100,C=Z=>{const Ne=Math.max(40,j+Z.clientX-x);ht(Ge=>({...Ge,[i]:Ne}))},ie=()=>{document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",ie)};document.addEventListener("mousemove",C),document.addEventListener("mouseup",ie)},[_e]),se=Oe?((ni=qe.sort[0])==null?void 0:ni.field)??"":m??Un.field,fe=Oe?((ti=qe.sort[0])==null?void 0:ti.direction)??null:f??Un.dir,Me=Oe?qe.page:R??Wn,$e=N??u;t.useCallback(()=>{if(!pe)return;const i={columnWidths:on,sortField:se||void 0,sortDirection:fe,pageSize:q,expandedGroups:Array.from(ln)};localStorage.setItem(`nice-datagrid-${pe}`,JSON.stringify(i)),un==null||un(i)},[pe,on,se,fe,q,ln,un]);const He=t.useMemo(()=>n.filter(i=>!i.hidden),[n]),_n=t.useMemo(()=>He.filter(i=>i.pinned==="left"),[He]),dn=t.useMemo(()=>He.filter(i=>i.pinned==="right"),[He]),xt=t.useMemo(()=>He.filter(i=>!i.pinned),[He]),Ue=t.useMemo(()=>[..._n,...xt,...dn],[_n,xt,dn]),vi=t.useMemo(()=>He.some(i=>i.aggregate),[He]),st=_n.length>0||dn.length>0,Ut=t.useCallback(i=>{const p=se===i?fe==="asc"?"desc":fe==="desc"?null:"asc":"asc";Oe?p?qe.setSortField(i,p):qe.setSort([]):o?o(i,p):Rn({field:i,dir:p})},[se,fe,Oe,qe,o]),yn=t.useMemo(()=>{if(Oe)return Kn;let i=[...Kn];if(v){const p=v.toLowerCase();i=i.filter(x=>He.some(j=>String(x[j.field]??"").toLowerCase().includes(p)))}return!o&&se&&fe&&i.sort((p,x)=>{const j=p[se]??"",C=x[se]??"",ie=typeof j=="number"?j-C:String(j).localeCompare(String(C));return fe==="desc"?-ie:ie}),i},[Kn,v,He,se,fe,o,Oe]),bt=Oe?qe.totalCount:G??yn.length,Vn=Oe?qe.pageSize:q,ji=Math.max(1,Math.ceil(bt/Vn)),Dn=Oe?yn:K&&!G?yn.slice((Me-1)*Vn,Me*Vn):yn,$t=t.useCallback(i=>{Oe?qe.setPage(i):P?P(i):Xn(i)},[Oe,qe,P]),qn=t.useMemo(()=>Dn.map(i=>String(i[r])),[Dn,r]),Yn=qn.length>0&&qn.every(i=>$e.has(i)),Wt=qn.some(i=>$e.has(i)),Gt=t.useCallback(()=>{const i=new Set($e);Yn?qn.forEach(p=>i.delete(p)):qn.forEach(p=>i.add(p)),S?S(i):h(i)},[Yn,qn,$e,S]),Qt=t.useCallback(i=>{const p=new Set($e);p.has(i)?p.delete(i):p.add(i),S?S(p):h(p)},[$e,S]),Zt=({field:i})=>se!==i||!fe?e.jsx("span",{className:"nice-table__sort-icon",children:e.jsx(Fi,{})}):e.jsx("span",{className:"nice-table__sort-icon",children:fe==="asc"?e.jsx(Ri,{}):e.jsx(ct,{})}),vn=t.useMemo(()=>{if(!I)return Dn.map((x,j)=>({type:"data",row:x,key:String(x[r]??j)}));const i=new Map;Dn.forEach(x=>{const j=x[I];i.has(j)||i.set(j,[]),i.get(j).push(x)});const p=[];return i.forEach((x,j)=>{const C=`__group_${String(j)}`,ie=ln.has(C);p.push({type:"group",value:j,rows:x,expanded:ie,key:C}),ie&&x.forEach((ce,Z)=>p.push({type:"data",row:ce,key:String(ce[r]??`${C}_${Z}`)}))}),p},[Dn,I,r,ln]),{pinnedTopRows:wi,pinnedBottomRows:ki,normalRows:Ni}=t.useMemo(()=>{if(!(X!=null&&X.size)&&!(ye!=null&&ye.size))return{pinnedTopRows:[],pinnedBottomRows:[],normalRows:vn};const i=[],p=[],x=[];for(const j of vn){if(j.type==="data"){const C=j.key;if(X!=null&&X.has(C)){i.push(j);continue}if(ye!=null&&ye.has(C)){p.push(j);continue}}x.push(j)}return{pinnedTopRows:i,pinnedBottomRows:p,normalRows:x}},[vn,X,ye]),Jt=t.useCallback(i=>{gn(p=>{const x=new Set(p);return x.has(i)?x.delete(i):x.add(i),x})},[]),Ci=t.useMemo(()=>{var C;if(!w)return vn;const i=((C=tt.current)==null?void 0:C.clientHeight)??400,p=Math.ceil(i/c),x=Math.max(0,Math.floor(sn/c)-3),j=Math.min(vn.length-1,x+p+6);return vn.slice(x,j+1).map((ie,ce)=>({...ie,_vIdx:x+ce}))},[w,vn,sn,c]),_t=t.useCallback((i,p,x)=>{!te||nt||(Y({rowKey:i,field:p}),Re(x))},[te]),Ht=t.useCallback(()=>{z&&te&&te(z.rowKey,z.field,Fe),Y(null),Re(null)},[z,Fe,te]),Si=t.useCallback(()=>{Y(null),Re(null)},[]),Mi=t.useCallback(()=>{const i=He,p=i.map(Z=>ot(Z.header)).join(","),x=yn.map(Z=>i.map(Ne=>ot(String(Z[Ne.field]??""))).join(",")),j=[p,...x].join(`
|
|
3
|
+
`),C=new Blob(["\uFEFF"+j],{type:"text/csv;charset=utf-8;"}),ie=URL.createObjectURL(C),ce=document.createElement("a");ce.href=ie,ce.download=`${we}.csv`,ce.click(),URL.revokeObjectURL(ie)},[He,yn,we]),yt=t.useCallback(i=>{V?V(i):at(i)},[V]),vt=t.useCallback(i=>{he?he(i):pt(i)},[he]),jn=t.useMemo(()=>vn.filter(i=>i.type==="data").map(i=>i.key),[vn]),Di=t.useCallback(i=>{if(!ne||z||!Je)return;const p=jn.indexOf(Je.rowKey),x=Ue.findIndex(ce=>ce.field===Je.field);if(p<0||x<0)return;let j=p,C=x;switch(i.key){case"ArrowUp":j=Math.max(0,p-1);break;case"ArrowDown":j=Math.min(jn.length-1,p+1);break;case"ArrowLeft":C=Math.max(0,x-1);break;case"ArrowRight":C=Math.min(Ue.length-1,x+1);break;case"Tab":i.preventDefault(),i.shiftKey?C=Math.max(0,x-1):C=Math.min(Ue.length-1,x+1);break;case"Enter":{const ce=Ue[x];if(ce.editable&&te){const Z=Dn.find(Ne=>String(Ne[r])===Je.rowKey);Z&&_t(Je.rowKey,ce.field,Z[ce.field])}return}case"Escape":yt(null),vt(null);return;case"Home":i.ctrlKey&&(j=0),C=0;break;case"End":i.ctrlKey&&(j=jn.length-1),C=Ue.length-1;break;case"PageUp":j=Math.max(0,p-q);break;case"PageDown":j=Math.min(jn.length-1,p+q);break;default:return}i.preventDefault();const ie={rowKey:jn[j],field:Ue[C].field};if(yt(ie),i.shiftKey&&Le){const ce=(cn==null?void 0:cn.start)??Je;vt({start:ce,end:ie})}else vt(null)},[ne,z,Je,jn,Ue,Le,cn,yt,vt,te,Dn,r,_t,q]),Xt=t.useCallback(()=>{let i=[],p=[];if(cn){const x=jn.indexOf(cn.start.rowKey),j=jn.indexOf(cn.end.rowKey),C=Math.min(x,j),ie=Math.max(x,j),ce=Ue.findIndex(Ye=>Ye.field===cn.start.field),Z=Ue.findIndex(Ye=>Ye.field===cn.end.field),Ne=Math.min(ce,Z),Ge=Math.max(ce,Z);p=Ue.slice(Ne,Ge+1).map(Ye=>Ye.field),i=Dn.filter(Ye=>{const On=jn.indexOf(String(Ye[r]));return On>=C&&On<=ie})}else $e.size>0&&(i=Dn.filter(x=>$e.has(String(x[r]))),p=Ue.map(x=>x.field));return{rows:i,fields:p}},[cn,jn,Ue,Dn,r,$e]),Vt=t.useCallback((i,p,x)=>{const j=Ue.filter(C=>p.includes(C.field));switch(x){case"json":return JSON.stringify(i.map(C=>Object.fromEntries(p.map(ie=>[ie,C[ie]]))),null,2);case"csv":{const C=j.map(ce=>ot(ce.header)).join(","),ie=i.map(ce=>j.map(Z=>ot(String(ce[Z.field]??""))).join(",")).join(`
|
|
4
|
+
`);return C+`
|
|
5
|
+
`+ie}case"html":{const C=j.map(ce=>`<th>${ce.header}</th>`).join(""),ie=i.map(ce=>`<tr>${j.map(Z=>`<td>${ce[Z.field]??""}</td>`).join("")}</tr>`).join("");return`<table><thead><tr>${C}</tr></thead><tbody>${ie}</tbody></table>`}case"markdown":{const C="| "+j.map(Z=>Z.header).join(" | ")+" |",ie="| "+j.map(()=>"---").join(" | ")+" |",ce=i.map(Z=>"| "+j.map(Ne=>Z[Ne.field]??"").join(" | ")+" |").join(`
|
|
6
|
+
`);return C+`
|
|
7
|
+
`+ie+`
|
|
8
|
+
`+ce}default:return i.map(C=>j.map(ie=>C[ie.field]??"").join(" ")).join(`
|
|
9
|
+
`)}},[Ue]),At=t.useCallback(async()=>{if(!Qe)return;const{rows:i,fields:p}=Xt();if(!i.length||(ve==null?void 0:ve(i,p))===!1)return;const x=Vt(i,p,pn);await navigator.clipboard.writeText(x),kn==null||kn(i,p,pn)},[Qe,Xt,ve,Vt,pn,kn]),qt=t.useCallback(async()=>{if(!Qe||!Je||!Nn)return;const i=(await navigator.clipboard.readText()).split(`
|
|
10
|
+
`).map(p=>p.split(" "));Nn(i,Je)},[Qe,Je,Nn]);t.useEffect(()=>{if(!Qe||!rt.current)return;const i=p=>{var x;(x=rt.current)!=null&&x.contains(document.activeElement)&&(p.type==="copy"&&(p.preventDefault(),At()),p.type==="paste"&&(p.preventDefault(),qt()))};return document.addEventListener("copy",i),document.addEventListener("paste",i),()=>{document.removeEventListener("copy",i),document.removeEventListener("paste",i)}},[Qe,At,qt]);const $i=t.useCallback(i=>{const p=bn.includes(i)?bn.filter(x=>x!==i):[...bn,i];$?$(p):St(p)},[bn,$]),Ai=t.useMemo(()=>{if(!(Ve!=null&&Ve.length)||!bn.length)return yn;const i=Ve.filter(p=>bn.includes(p.key));return yn.filter(p=>i.every(x=>x.filter(p)))},[yn,Ve,bn]),Yt=Ve!=null&&Ve.length?Ai:yn;t.useCallback(i=>{const p=yn.map(Ne=>Ne[i]).filter(Ne=>Ne!=null),x=p.filter(Ne=>typeof Ne=="number");if(x.length===0){const Ne=new Set(p).size;return{count:p.length,unique:Ne,type:"text"}}const j=x.reduce((Ne,Ge)=>Ne+Ge,0),C=j/x.length,ie=Math.min(...x),ce=Math.max(...x),Z=Math.sqrt(x.reduce((Ne,Ge)=>Ne+(Ge-C)**2,0)/x.length);return{count:x.length,sum:j,avg:C,min:ie,max:ce,stdDev:Z,type:"numeric"}},[yn]);const Ii=t.useCallback((i,p,x)=>{if(!i.cellVisualization)return null;const j=Number(p);if(isNaN(j))return null;const C=i.visualMin??0,ie=i.visualMax??100,ce=Math.max(0,Math.min(100,(j-C)/(ie-C)*100));switch(i.cellVisualization){case"progress":return e.jsxs("div",{className:"nice-datagrid__cell-progress",style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("div",{style:{flex:1,height:6,background:"var(--border-color)",borderRadius:3,overflow:"hidden"},children:e.jsx("div",{style:{width:`${ce}%`,height:"100%",background:ce>80?"var(--color-success)":ce>50?"var(--color-primary)":"var(--color-warning)",transition:"width 0.3s ease"}})}),e.jsxs("span",{style:{fontSize:"0.75rem",minWidth:32,textAlign:"right"},children:[Math.round(ce),"%"]})]});case"rating":{const Z=Math.round(j/ie*5);return e.jsx("div",{className:"nice-datagrid__cell-rating",children:[1,2,3,4,5].map(Ne=>e.jsx("span",{style:{color:Ne<=Z?"var(--color-warning)":"var(--text-muted)",fontSize:"0.95rem",lineHeight:1},"aria-hidden":"true",children:"★"},Ne))})}case"trend":{const Z=i.visualMin??j,Ne=j-Z,Ge=Ne>0?Pi:Ne<0?Oi:Bi,Ye=Ne>0?"var(--color-success)":Ne<0?"var(--color-danger)":"var(--text-muted)";return e.jsxs("span",{style:{color:Ye,fontWeight:500,display:"inline-flex",alignItems:"center",gap:4},children:[e.jsx(Ge,{})," ",Math.abs(Ne).toFixed(1),"%"]})}case"heatmap":{const Z=ce/100,Ne=`rgba(${Math.round(255*Z)}, ${Math.round(100*(1-Z))}, ${Math.round(50*(1-Z))}, 0.6)`;return e.jsx("span",{style:{background:Ne,padding:"2px 8px",borderRadius:4},children:j})}default:return null}},[]),Li=t.useCallback((i,p,x)=>{var j;if(!((j=i.conditionalFormats)!=null&&j.length))return{};for(const C of i.conditionalFormats)if(C.when(p,x,i.field))return{className:C.className,style:{...C.style,backgroundColor:C.backgroundColor,color:C.color}};return{}},[]),It=t.useCallback((i,p)=>{if(!st||!i.pinned)return{};const x={position:"sticky",zIndex:2,background:"var(--bg-primary, #fff)"};if(i.pinned==="left"){let j=0;for(let C=0;C<p;C++){const ie=Ue[C];ie.pinned==="left"&&(j+=typeof ie.width=="number"?ie.width:parseInt(String(ie.width)||"100",10))}g&&p===0&&(j=36),x.left=j}else{let j=0;for(let C=Ue.length-1;C>p;C--){const ie=Ue[C];ie.pinned==="right"&&(j+=typeof ie.width=="number"?ie.width:parseInt(String(ie.width)||"100",10))}x.right=j}return x},[st,Ue,g]),ei=(i,p,x,j)=>(z==null?void 0:z.rowKey)===x&&(z==null?void 0:z.field)===i.field?i.editor?i.editor(Fe,p,ie=>Re(ie)):e.jsx("input",{className:"nice-datagrid__edit-input",autoFocus:!0,value:Fe??"",onChange:ie=>Re(ie.target.value),onBlur:Ht,onKeyDown:ie=>{ie.key==="Enter"&&Ht(),ie.key==="Escape"&&Si()}}):Ii(i,p[i.field],p)||(i.render?i.render(p[i.field],p,j):Ki(p[i.field])),zi=(i,p,x,j)=>{const C=(Je==null?void 0:Je.rowKey)===x&&(Je==null?void 0:Je.field)===i.field,ie=cn&&(()=>{const Z=jn.indexOf(cn.start.rowKey),Ne=jn.indexOf(cn.end.rowKey),Ge=jn.indexOf(x),Ye=Ue.findIndex(Bn=>Bn.field===cn.start.field),On=Ue.findIndex(Bn=>Bn.field===cn.end.field);return Ge>=Math.min(Z,Ne)&&Ge<=Math.max(Z,Ne)&&j>=Math.min(Ye,On)&&j<=Math.max(Ye,On)})(),ce=Li(i,p[i.field],p);return{className:[ce.className,C&&"nice-datagrid__cell--focused",ie&&"nice-datagrid__cell--in-range"].filter(Boolean).join(" "),style:{...It(i,j),textAlign:i.align,...ce.style,...C?{outline:"2px solid var(--color-primary)",outlineOffset:-2}:{},...ie?{background:"var(--color-primary-light, rgba(59,130,246,0.15))"}:{}}}},jt=Ue.length+(g?1:0)+(le?1:0)+(ge?1:0)+(an?1:0),Lt=(i,p,x)=>{const{row:j,key:C}=i,ie=$e.has(C),ce=Tn.has(C),Z=Mt.has(C),Ne=[ie&&"nice-datagrid__row--selected",Mn===p&&"nice-datagrid__row--dragging",x&&"nice-datagrid__row--pinned",Z&&"nice-datagrid__row--flash"].filter(Boolean).join(" ");return e.jsxs(t.Fragment,{children:[e.jsxs("tr",{className:Ne,onClick:()=>Be==null?void 0:Be(j),onDoubleClick:ue==="popup"&&(xe||te)?()=>Ze({key:C,data:{...j}}):void 0,onContextMenu:Ge=>Dt(Ge,j),style:Be||ue==="popup"?{cursor:"pointer"}:void 0,draggable:ge,onDragStart:ge?()=>Fn(p):void 0,onDragOver:ge?Ge=>Ge.preventDefault():void 0,onDrop:ge&&Te&&Mn!=null?()=>{Te(Mn,p),Fn(null)}:void 0,onDragEnd:ge?()=>Fn(null):void 0,children:[an&&e.jsx("td",{className:"nice-datagrid__row-indicator",style:{width:32,padding:"0 4px"},children:an(j)}),le&&e.jsx("td",{className:"nice-datagrid__expand-col",onClick:Ge=>{Ge.stopPropagation(),lt(C)},children:e.jsx("span",{className:"nice-datagrid__expand-btn","data-expanded":ce,children:ce?e.jsx(ct,{}):e.jsx(wt,{})})}),ge&&e.jsx("td",{className:"nice-datagrid__drag-handle",style:{cursor:"grab",textAlign:"center",color:"var(--text-muted)"},children:"?"}),g&&e.jsx("td",{className:"nice-datagrid__checkbox",onClick:Ge=>Ge.stopPropagation(),style:st?{position:"sticky",left:0,zIndex:1,background:"var(--bg-primary, #fff)"}:void 0,children:e.jsx("input",{type:"checkbox",checked:ie,onChange:()=>Qt(C),"aria-label":`Select row ${C}`})}),(()=>{let Ge=0;return Ue.map((Ye,On)=>{if(Ge>0)return Ge--,null;const Bn=Ie?Ie(j,Ye,On):void 0;Bn&&Bn>1&&(Ge=Bn-1);const ii=zi(Ye,j,C,On);return e.jsx("td",{colSpan:Bn,className:ii.className,style:ii.style,onClick:ne?()=>yt({rowKey:C,field:Ye.field}):void 0,onDoubleClick:Ye.editable&&te?()=>_t(C,Ye.field,j[Ye.field]):void 0,children:ei(Ye,j,C,p)},Ye.field)})})()]}),le&&ce&&e.jsx("tr",{className:"nice-datagrid__detail-row",children:e.jsx("td",{colSpan:jt,children:le(j)})})]},C)};return mt?null:e.jsxs("div",{ref:rt,className:`nice-datagrid ${T?"nice-datagrid--print":""} ${Qn||""}`,style:Zn,role:"grid","aria-label":Pe("datagrid.title","Data Grid"),"aria-rowcount":vn.length,"aria-colcount":He.length,"aria-busy":Ln||void 0,tabIndex:ne?0:void 0,onKeyDown:ne?Di:void 0,children:[(y||Ee||b||(Ve==null?void 0:Ve.length)||ee)&&e.jsxs("div",{className:"nice-datagrid__toolbar",children:[y&&e.jsx("div",{className:"nice-datagrid__search",children:e.jsx("input",{type:"text",value:Oe?qe.search:v,"aria-label":Pe("controls.search","Search"),onChange:i=>{Oe?qe.setSearch(i.target.value):(B(i.target.value),$t(1))},placeholder:s||Pe("controls.search","Search...")})}),Ve&&Ve.length>0&&e.jsx("div",{className:"nice-datagrid__quick-filters",style:{display:"flex",gap:6,flexWrap:"wrap"},children:Ve.map(i=>e.jsxs("button",{className:`nice-datagrid__quick-filter ${bn.includes(i.key)?"nice-datagrid__quick-filter--active":""}`,onClick:()=>$i(i.key),style:{display:"inline-flex",alignItems:"center",gap:4,padding:"3px 10px",fontSize:"0.75rem",border:"1px solid var(--border-color)",borderRadius:12,background:bn.includes(i.key)?`var(--color-${i.color||"primary"})`:"var(--bg-primary)",color:bn.includes(i.key)?"var(--bg-primary, #fff)":"inherit",cursor:"pointer",transition:"all 0.15s ease"},children:[i.icon&&e.jsx("span",{children:i.icon}),i.label]},i.key))}),Qe&&e.jsx("button",{className:"nice-btn nice-btn--sm nice-btn--ghost",onClick:At,title:Pe("controls.copy","Copy selected"),style:{marginLeft:4},children:"??"}),b&&e.jsx("button",{className:"nice-btn nice-btn--sm",onClick:Mi,title:Pe("controls.exportCsv","Export CSV"),children:"CSV ?"}),ee&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--sm nice-btn--primary",onClick:()=>Ze({key:null,data:{}}),title:Pe("datagrid.addRow","Add row"),children:["+ ",Pe("datagrid.add","Add")]}),Ee]}),g&&$e.size>0&&((M==null?void 0:M.length)||E)&&e.jsxs("div",{className:"nice-datagrid__bulk-toolbar",role:"toolbar","aria-label":Pe("datagrid.bulkActions","Bulk actions"),style:{display:"flex",alignItems:"center",gap:8,padding:"6px 12px",background:"var(--bg-tertiary, #f1f5f9)",borderBottom:"1px solid var(--border-color)",flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:"0.85rem",color:"var(--text-secondary)"},children:Pe("datagrid.selectedCount","{count} selected").replace("{count}",String($e.size))}),(M||[]).map(i=>{var C;const p=Array.from($e),x=Yt.filter(ie=>$e.has(String(ie[r]))),j=((C=i.disabled)==null?void 0:C.call(i,p,x))||!1;return e.jsxs("button",{type:"button",className:`nice-btn nice-btn--sm nice-btn--${i.variant||"secondary"}`,disabled:j,onClick:()=>i.onClick(p,x),children:[i.icon,i.icon&&" ",i.label]},i.key)}),E&&!(M!=null&&M.length)&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--sm nice-btn--danger",onClick:()=>{const i=Array.from($e),p=Yt.filter(x=>$e.has(String(x[r])));E(i,p)},children:["?? ",Pe("datagrid.deleteSelected","Delete selected")]}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--xs nice-btn--ghost",onClick:()=>{const i=new Set;N===void 0&&h(i),S==null||S(i)},style:{marginLeft:"auto"},children:Pe("datagrid.clearSelection","Clear")})]}),e.jsxs("div",{ref:tt,className:`nice-datagrid__table-wrap ${w?"nice-datagrid__table-wrap--virtual":""}`,style:w?{maxHeight:Math.min(vn.length*c,600),overflowY:"auto"}:void 0,onScroll:w?i=>fn(i.currentTarget.scrollTop):void 0,children:[w&&e.jsxs("div",{style:{height:vn.length*c,position:"relative"},children:[e.jsx("table",{className:`${Xe?"nice-table--striped":""} ${nn?"nice-table--compact":""}`,style:{position:"sticky",top:0,zIndex:3},children:e.jsx("thead",{children:e.jsxs("tr",{children:[le&&e.jsx("th",{className:"nice-datagrid__expand-col",style:{width:36}}),ge&&e.jsx("th",{style:{width:28}}),g&&e.jsx("th",{className:"nice-datagrid__checkbox",style:st?{position:"sticky",left:0,zIndex:3,background:"var(--bg-primary, #fff)"}:void 0,children:e.jsx("input",{type:"checkbox",checked:Yn,ref:i=>{i&&(i.indeterminate=Wt&&!Yn)},onChange:Gt,"aria-label":Pe("controls.selectAll","Select all")})}),Ue.map((i,p)=>e.jsxs("th",{style:{width:on[i.field]||i.width,minWidth:i.minWidth,textAlign:i.align,position:"relative",...It(i,p)},className:d&&i.sortable!==!1?"nice-datagrid__th--sortable":void 0,onClick:()=>d&&i.sortable!==!1&&Ut(i.field),children:[i.header,d&&i.sortable!==!1&&e.jsx(Zt,{field:i.field}),_e&&e.jsx("span",{className:"nice-datagrid__resize-handle",onMouseDown:x=>{x.stopPropagation(),_(i.field,x)}})]},i.field))]})})}),Ci.map((i,p)=>{const x=i._vIdx??0;if(i.type==="group"){const Z=i;return e.jsxs("div",{className:"nice-datagrid__group-row",style:{position:"absolute",top:x*c,height:c,left:0,right:0},onClick:()=>Jt(Z.key),children:[e.jsx("span",{className:"nice-datagrid__group-toggle",children:Z.expanded?e.jsx(ct,{}):e.jsx(wt,{})}),F?F(Z.value,Z.rows):e.jsxs(e.Fragment,{children:[String(Z.value)," (",Z.rows.length,")"]})]},Z.key)}const{row:j,key:C}=i,ie=$e.has(C),ce=Tn.has(C);return e.jsxs(t.Fragment,{children:[e.jsxs("div",{className:`nice-datagrid__vrow ${ie?"nice-datagrid__row--selected":""} ${Mn===p?"nice-datagrid__row--dragging":""}`,style:{position:"absolute",top:x*c,height:c,left:0,right:0,display:"flex",alignItems:"center"},onClick:()=>Be==null?void 0:Be(j),onDoubleClick:ue==="popup"&&(xe||te)?()=>Ze({key:C,data:{...j}}):void 0,draggable:ge,onDragStart:ge?()=>Fn(p):void 0,onDragOver:ge?Z=>Z.preventDefault():void 0,onDrop:ge&&Te&&Mn!=null?()=>{Te(Mn,p),Fn(null)}:void 0,onDragEnd:ge?()=>Fn(null):void 0,children:[le&&e.jsx("div",{className:"nice-datagrid__expand-col",style:{width:36,flexShrink:0,textAlign:"center",cursor:"pointer"},onClick:Z=>{Z.stopPropagation(),lt(C)},children:e.jsx("span",{className:"nice-datagrid__expand-btn","data-expanded":ce,children:ce?e.jsx(ct,{}):e.jsx(wt,{})})}),ge&&e.jsx("div",{style:{width:28,flexShrink:0,cursor:"grab",textAlign:"center",color:"var(--text-muted)"},children:"?"}),g&&e.jsx("div",{className:"nice-datagrid__checkbox",style:{width:36,flexShrink:0},onClick:Z=>Z.stopPropagation(),children:e.jsx("input",{type:"checkbox",checked:ie,onChange:()=>Qt(C)})}),Ue.map(Z=>e.jsx("div",{className:"nice-datagrid__vcell",style:{width:on[Z.field]||Z.width||"auto",flex:on[Z.field]||Z.width?`0 0 ${typeof(on[Z.field]||Z.width)=="number"?(on[Z.field]||Z.width)+"px":on[Z.field]||Z.width}`:1,textAlign:Z.align,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",padding:"0 8px"},onDoubleClick:Z.editable&&te?()=>_t(C,Z.field,j[Z.field]):void 0,children:ei(Z,j,C,x)},Z.field))]}),le&&ce&&e.jsx("div",{className:"nice-datagrid__detail-row",style:{position:"absolute",top:(x+1)*c,left:0,right:0,padding:"8px 12px",background:"var(--bg-secondary, #f8f8f8)"},children:le(j)})]},C)})]}),!w&&e.jsxs("table",{className:`${Xe?"nice-table--striped":""} ${nn?"nice-table--compact":""}`,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[le&&e.jsx("th",{className:"nice-datagrid__expand-col",style:{width:36}}),ge&&e.jsx("th",{style:{width:28}}),g&&e.jsx("th",{className:"nice-datagrid__checkbox",style:st?{position:"sticky",left:0,zIndex:3,background:"var(--bg-primary, #fff)"}:void 0,children:e.jsx("input",{type:"checkbox",checked:Yn,ref:i=>{i&&(i.indeterminate=Wt&&!Yn)},onChange:Gt,"aria-label":Pe("controls.selectAll","Select all")})}),Ue.map((i,p)=>{const x=d&&i.sortable!==!1,j=x?se===i.field?fe==="asc"?"ascending":fe==="desc"?"descending":"none":"none":void 0;return e.jsxs("th",{style:{width:on[i.field]||i.width,minWidth:i.minWidth,textAlign:i.align,position:"relative",...It(i,p)},className:x?"nice-datagrid__th--sortable":void 0,onClick:()=>x&&Ut(i.field),"aria-sort":j,scope:"col",children:[i.header,x&&e.jsx(Zt,{field:i.field}),_e&&e.jsx("span",{className:"nice-datagrid__resize-handle",onMouseDown:C=>{C.stopPropagation(),_(i.field,C)}})]},i.field)})]})}),e.jsx("tbody",{children:Ln?e.jsx("tr",{children:e.jsx("td",{colSpan:jt,className:"nice-datagrid__empty",children:e.jsx("div",{className:"nice-spinner nice-spinner--md",style:{margin:"0 auto"}})})}):vn.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:jt,className:"nice-datagrid__empty",children:tn||Pe("controls.noData","No data available")})}):e.jsxs(e.Fragment,{children:[wi.map((i,p)=>i.type==="data"&&Lt(i,p,"top")),Ni.map((i,p)=>{if(i.type==="group"){const x=i;return e.jsx("tr",{className:"nice-datagrid__group-row",onClick:()=>Jt(x.key),children:e.jsxs("td",{colSpan:jt,className:"nice-datagrid__group-cell",children:[e.jsx("span",{className:"nice-datagrid__group-toggle",children:x.expanded?e.jsx(ct,{}):e.jsx(wt,{})}),F?F(x.value,x.rows):e.jsxs(e.Fragment,{children:[String(x.value)," (",x.rows.length,")"]})]})},x.key)}return Lt(i,p)}),ki.map((i,p)=>i.type==="data"&&Lt(i,p,"bottom"))]})}),vi&&!Ln&&Dn.length>0&&e.jsx("tfoot",{children:e.jsxs("tr",{className:"nice-datagrid__aggregate-row",children:[g&&e.jsx("td",{}),Ue.map(i=>e.jsx("td",{style:{textAlign:i.align,fontWeight:600},children:i.aggregate?(i.aggregateLabel||i.aggregate.toUpperCase())+": "+di(yn,i.field,i.aggregate):""},i.field))]})})]})]}),K&&e.jsxs("div",{className:"nice-datagrid__footer",children:[e.jsxs("span",{className:"nice-datagrid__footer-info",children:[Pe("controls.showing","Showing")," ",(Me-1)*Vn+1,"–",Math.min(Me*Vn,bt)," ",Pe("controls.of","of")," ",bt]}),e.jsx(ci,{page:Me,totalPages:ji,onChange:$t,showInfo:!0,pageSize:Vn,showPageSize:!0,pageSizeOptions:[5,10,25,50,100],onPageSizeChange:i=>{Oe?qe.setPageSize(i):(k(i),$t(1))},showFirstLast:!0})]}),L&&!Ln&&e.jsxs("div",{className:"nice-datagrid__status-bar",children:[e.jsxs("span",{children:[Pe("controls.totalRows","Total rows"),": ",bt]}),g&&$e.size>0&&e.jsxs("span",{children:[Pe("controls.selected","Selected"),": ",$e.size]})]}),Pn&&oe&&e.jsx("div",{className:"nice-datagrid__context-menu",style:{position:"fixed",left:Pn.x,top:Pn.y,zIndex:9999},onClick:i=>i.stopPropagation(),children:oe.map(i=>e.jsxs("button",{className:"nice-datagrid__context-item",disabled:i.disabled,onClick:()=>{W==null||W(i.key,Pn.row),it(null)},children:[i.icon&&e.jsx("span",{className:"nice-datagrid__context-icon",children:i.icon}),i.label]},i.key))}),(ue==="popup"||ee)&&re&&(()=>{const i=re.key===null,p=Ae??n.filter(x=>!x.hidden&&x.field!==r).map(x=>{var C;let j="text";return x.dataType==="number"||x.dataType==="currency"||x.dataType==="percent"?j="number":x.dataType==="boolean"?j="checkbox":x.dataType==="date"&&(j="date"),{field:x.field,label:x.header,type:j,required:(C=x.validation)==null?void 0:C.required}});return e.jsx(Tt,{open:!0,onClose:()=>Ze(null),title:me??(i?Pe("datagrid.addRow","Add row"):Pe("datagrid.editRow","Edit row")),size:"lg",children:e.jsx(J.Ga,{items:p,data:re.data,columns:D,showActions:!0,submitLabel:i?Pe("controls.add","Add"):Pe("controls.save","Save"),cancelLabel:Pe("controls.cancel","Cancel"),onCancel:()=>Ze(null),...be,onFieldChange:(x,j)=>Ze(C=>C&&{...C,data:{...C.data,[x]:j}}),onSubmit:x=>{i?ee==null||ee(x):re.key&&(xe?xe(re.key,x):te&&Object.keys(x).forEach(j=>{te(re.key,j,x[j])})),Ze(null)}})})})()]})}ut.displayName="NiceDataGrid";const Ui=Object.freeze(Object.defineProperty({__proto__:null,NiceDataGrid:ut},Symbol.toStringTag,{value:"Module"}));function Wi(n,a){return n.filter(r=>a.every(l=>{const d=r[l.field],m=l.value;switch(l.operator){case"eq":return d===m;case"ne":return d!==m;case"gt":return typeof d=="number"&&typeof m=="number"&&d>m;case"gte":return typeof d=="number"&&typeof m=="number"&&d>=m;case"lt":return typeof d=="number"&&typeof m=="number"&&d<m;case"lte":return typeof d=="number"&&typeof m=="number"&&d<=m;case"contains":return String(d).toLowerCase().includes(String(m).toLowerCase());case"startsWith":return String(d).toLowerCase().startsWith(String(m).toLowerCase());case"endsWith":return String(d).toLowerCase().endsWith(String(m).toLowerCase());default:return!0}}))}function Gi(n){return n.map(a=>({field:a.field,type:a.dataType||"string",label:typeof a.header=="string"?a.header:a.field}))}function Qi(n,a){const{enableAI:r=!0,aiModel:l,enableNLSearch:d=!0,enableInsights:m=!0,nlPlaceholder:f,onAIFilter:o,onInsights:g,showAISearchBar:N=!0,exampleQueries:S=["Show items from last week","Filter by status = active","Orders over $1000",'Names starting with "A"'],columns:K,data:A,...R}=n,[P,G]=t.useState(""),[y,s]=t.useState([]),[w,c]=t.useState([]),[I,F]=t.useState(!1),[te,ue]=t.useState(null),Ae=t.useRef(null),{t:D}=J.ue(),me=J.me(),{parseFilter:be,isLoading:xe}=J.Wd(),ee=r&&me.isConfigured,ae=y.length>0?Wi(A||[],y):A,M=t.useCallback(async U=>{if(!ee||!d||!U.trim())return;ue(U);const Q=Gi(K);try{const H=await be(U,Q);s(H),o==null||o(U,H)}catch{s([])}},[ee,d,K,be,o]),E=t.useCallback(()=>{s([]),ue(null),G("")},[]),b=t.useCallback(()=>y,[y]),we=t.useCallback(async()=>{if(!ee||!m||!(A!=null&&A.length))return[];try{const U=await me.complete([{role:"user",content:`Analyze this data and provide 3-5 key insights. Data sample (${A.length} total rows): ${JSON.stringify(A.slice(0,20))}
|
|
11
|
+
|
|
12
|
+
Columns: ${K.map(Q=>Q.field).join(", ")}
|
|
13
|
+
|
|
14
|
+
Return a JSON array of insight strings. Be specific with numbers and trends.`}],{temperature:.3,maxTokens:500});try{const Q=JSON.parse(U.content),H=Array.isArray(Q)?Q:[];return c(H),g==null||g(H),H}catch{return[]}}catch{return[]}},[ee,m,A,K,me,g]),le=U=>{U.preventDefault(),P.trim()&&M(P)},O=U=>{G(U),M(U)};return t.useImperativeHandle(a,()=>({applyNLFilter:M,clearAIFilters:E,getAIFilters:b,generateInsights:we})),e.jsxs("div",{className:"nice-data-grid-ai","data-testid":n["data-testid"],children:[N&&ee&&d&&e.jsxs("div",{className:"nice-data-grid-ai__search-bar",children:[e.jsx("div",{className:"nice-data-grid-ai__search-left",children:e.jsx("span",{className:"nice-data-grid-ai__badge",children:"AI"})}),e.jsxs("form",{onSubmit:le,className:"nice-data-grid-ai__search-form",children:[e.jsxs("div",{className:"nice-data-grid-ai__input-wrapper",children:[e.jsx("span",{className:"nice-data-grid-ai__search-icon",children:"🔍"}),e.jsx("input",{ref:Ae,type:"text",value:P,onChange:U=>G(U.target.value),placeholder:f||D("dataGridAI.searchPlaceholder","Search with natural language..."),className:"nice-data-grid-ai__input",disabled:xe}),xe&&e.jsx("span",{className:"nice-data-grid-ai__loading-spinner"}),P&&!xe&&e.jsx("button",{type:"button",className:"nice-data-grid-ai__clear-input",onClick:()=>G(""),children:"✕"})]}),e.jsx("button",{type:"submit",className:"nice-data-grid-ai__search-btn",disabled:xe||!P.trim(),children:xe?D("dataGridAI.searching","Searching..."):D("dataGridAI.search","Search")})]}),m&&e.jsxs("button",{type:"button",className:"nice-data-grid-ai__insights-btn",onClick:()=>{we(),F(!0)},disabled:xe||!(A!=null&&A.length),title:D("dataGridAI.generateInsights","Generate AI Insights"),children:["💡 ",D("dataGridAI.insights","Insights")]})]}),N&&ee&&d&&!te&&S.length>0&&e.jsxs("div",{className:"nice-data-grid-ai__examples",children:[e.jsx("span",{className:"nice-data-grid-ai__examples-label",children:D("dataGridAI.tryAsking","Try asking:")}),e.jsx("div",{className:"nice-data-grid-ai__examples-list",children:S.slice(0,4).map((U,Q)=>e.jsxs("button",{type:"button",className:"nice-data-grid-ai__example",onClick:()=>O(U),children:['"',U,'"']},Q))})]}),te&&y.length>0&&e.jsxs("div",{className:"nice-data-grid-ai__active-filter",children:[e.jsxs("div",{className:"nice-data-grid-ai__filter-info",children:[e.jsx("span",{className:"nice-data-grid-ai__filter-icon",children:"🎯"}),e.jsxs("span",{className:"nice-data-grid-ai__filter-query",children:['"',te,'"']}),e.jsxs("span",{className:"nice-data-grid-ai__filter-count",children:["(",(ae==null?void 0:ae.length)||0," ",D("dataGridAI.results","results"),")"]})]}),e.jsx("div",{className:"nice-data-grid-ai__filter-badges",children:y.map((U,Q)=>e.jsxs("span",{className:"nice-data-grid-ai__filter-badge",children:[U.field," ",U.operator," ",String(U.value)]},Q))}),e.jsxs("button",{type:"button",className:"nice-data-grid-ai__clear-filter",onClick:E,children:["✕ ",D("dataGridAI.clearFilter","Clear")]})]}),e.jsx("div",{className:"nice-data-grid-ai__grid-wrapper",children:e.jsx(ut,{columns:K,data:ae,...R})}),I&&e.jsxs("div",{className:"nice-data-grid-ai__insights-panel",children:[e.jsxs("div",{className:"nice-data-grid-ai__insights-header",children:[e.jsxs("h4",{children:["💡 ",D("dataGridAI.aiInsights","AI Insights")]}),e.jsx("button",{type:"button",className:"nice-data-grid-ai__insights-close",onClick:()=>F(!1),children:"✕"})]}),e.jsx("div",{className:"nice-data-grid-ai__insights-body",children:xe?e.jsx("div",{className:"nice-data-grid-ai__insights-loading",children:D("dataGridAI.analyzing","Analyzing data...")}):w.length>0?e.jsx("ul",{className:"nice-data-grid-ai__insights-list",children:w.map((U,Q)=>e.jsxs("li",{className:"nice-data-grid-ai__insight",children:[e.jsx("span",{className:"nice-data-grid-ai__insight-bullet",children:"•"}),U]},Q))}):e.jsx("div",{className:"nice-data-grid-ai__insights-empty",children:D("dataGridAI.noInsights","Click to generate insights from your data")})}),e.jsx("div",{className:"nice-data-grid-ai__insights-footer",children:e.jsxs("button",{type:"button",className:"nice-data-grid-ai__refresh-insights",onClick:()=>we(),disabled:xe,children:["🔄 ",D("dataGridAI.refresh","Refresh")]})})]})]})}t.forwardRef(Qi);const ui=({items:n,selectedKeys:a=[],onSelectionChange:r,selectionMode:l="none",searchable:d,searchPlaceholder:m,grouped:f,groupField:o="group",reorderable:g,onReorder:N,onItemClick:S,renderItem:K,showCheckboxes:A,loading:R,emptyText:P,size:G="md",bordered:y=!0,swipeActions:s,className:w,style:c,accessMode:I,id:F})=>{const te=J.Cl(I,F)==="hidden",{t:ue}=J.ue(),[Ae,D]=t.useState(""),[me,be]=t.useState(null),[xe,ee]=t.useState(null),ae=t.useRef(null),M=t.useMemo(()=>{if(!Ae)return n;const O=Ae.toLowerCase();return n.filter(U=>U.text.toLowerCase().includes(O))},[n,Ae]),E=t.useMemo(()=>{if(!f)return null;const O=new Map;return M.forEach(U=>{const Q=String(U[o]??"");O.has(Q)||O.set(Q,[]),O.get(Q).push(U)}),O},[M,f,o]),b=t.useCallback(O=>{r&&(l==="single"?r(a.includes(O)?[]:[O]):l==="multiple"&&r(a.includes(O)?a.filter(U=>U!==O):[...a,O]))},[a,l,r]),we=t.useCallback(O=>{me!==null&&me!==O&&N&&N(me,O),be(null)},[me,N]),le=(O,U)=>{const Q=a.includes(O.key),H=xe===O.key;return e.jsxs("li",{className:`nice-list__item ${Q?"nice-list__item--selected":""} ${O.disabled?"nice-list__item--disabled":""} ${H?"nice-list__item--swiped":""}`,onClick:()=>{O.disabled||(b(O.key),S==null||S(O))},draggable:g,onDragStart:()=>be(U),onDragOver:_e=>_e.preventDefault(),onDrop:()=>we(U),onTouchStart:s!=null&&s.length?_e=>{ae.current={x:_e.touches[0].clientX,key:O.key}}:void 0,onTouchEnd:s!=null&&s.length?_e=>{if(!ae.current)return;const ge=_e.changedTouches[0].clientX-ae.current.x;ge<-50&&ae.current.key===O.key?ee(O.key):ge>50&&ee(null),ae.current=null}:void 0,role:l!=="none"?"option":void 0,"aria-selected":l!=="none"?Q:void 0,children:[e.jsxs("div",{className:"nice-list__item-content",children:[A&&l!=="none"&&e.jsx("input",{type:"checkbox",checked:Q,readOnly:!0,tabIndex:-1,className:"nice-list__checkbox"}),K?K(O):e.jsxs(e.Fragment,{children:[O.icon&&e.jsx("span",{className:"nice-list__icon",children:O.icon}),e.jsx("span",{className:"nice-list__text",children:O.text}),O.badge&&e.jsx("span",{className:"nice-list__badge",children:O.badge})]})]}),s&&H&&e.jsx("div",{className:"nice-list__swipe-actions",children:s.map(_e=>e.jsx("button",{className:"nice-list__swipe-btn",style:_e.color?{backgroundColor:_e.color}:void 0,onClick:ge=>{ge.stopPropagation(),_e.onClick(O),ee(null)},children:_e.label},_e.key))})]},O.key)};return te?null:e.jsxs("div",{className:`nice-list nice-list--${G} ${y?"nice-list--bordered":""} ${w||""}`,style:c,children:[d&&e.jsx("div",{className:"nice-list__search",children:e.jsx("input",{type:"text",value:Ae,onChange:O=>D(O.target.value),placeholder:m||ue("controls.search","Search...")})}),R?e.jsx("div",{className:"nice-list__loading",children:e.jsx("div",{className:"nice-spinner nice-spinner--sm"})}):M.length===0?e.jsx("div",{className:"nice-list__empty",children:P||ue("controls.noData","No data available")}):E?e.jsx("div",{role:"listbox",children:Array.from(E.entries()).map(([O,U])=>e.jsxs("div",{className:"nice-list__group",children:[e.jsx("div",{className:"nice-list__group-header",children:O}),e.jsx("ul",{className:"nice-list__items",children:U.map((Q,H)=>le(Q,H))})]},O))}):e.jsx("ul",{className:"nice-list__items",role:"listbox",children:M.map((O,U)=>le(O,U))})]})};function mi(n){const a=[];if(n.children)for(const r of n.children)a.push(r.key),a.push(...mi(r));return a}function zt(n,a){if(!n.children||n.children.length===0)return a.has(n.key)?"checked":"unchecked";let r=!0,l=a.has(n.key);for(const d of n.children){const m=zt(d,a);m==="checked"?l=!0:(m==="indeterminate"&&(l=!0),r=!1)}return r&&l?"checked":l?"indeterminate":"unchecked"}const hi=({nodes:n,selectedKeys:a=[],expandedKeys:r,onSelectionChange:l,onExpandedChange:d,selectionMode:m="none",showCheckboxes:f,searchable:o,searchPlaceholder:g,onNodeClick:N,renderNode:S,showLines:K,loading:A,className:R,style:P,accessMode:G,id:y,draggable:s,onNodeDrop:w,onLoadChildren:c,contextMenuItems:I,onContextMenuAction:F,editable:te,onNodeEdit:ue,maxDepth:Ae})=>{const D=J.Cl(G,y)==="hidden",{t:me}=J.ue(),[be,xe]=t.useState([]),[ee,ae]=t.useState(""),[M,E]=t.useState(new Set),[b,we]=t.useState(new Map),[le,O]=t.useState(null),[U,Q]=t.useState(null),[H,_e]=t.useState(null),[ge,Te]=t.useState(""),Xe=t.useRef(null),nn=r??be,De=t.useMemo(()=>new Set(a),[a]),tn=t.useCallback(async(L,oe)=>{var ne;const W=!nn.includes(L),T=W?[...nn,L]:nn.filter(je=>je!==L);if(d?d(T):xe(T),W&&c&&!((ne=oe.children)!=null&&ne.length)&&oe.leaf!==!0&&!b.has(L)){E(V=>new Set(V).add(L));const je=await c(oe);we(V=>new Map(V).set(L,je)),E(V=>{const Le=new Set(V);return Le.delete(L),Le})}},[nn,d,c,b]),Ee=t.useCallback((L,oe)=>{var W;if(l){if(m==="single")l(a.includes(L)?[]:[L]);else if(m==="multiple")if(f&&((W=oe.children)!=null&&W.length)){const T=mi(oe),ne=[L,...T];if(zt(oe,De)==="checked")l(a.filter(je=>!ne.includes(je)));else{const je=new Set([...a,...ne]);l(Array.from(je))}}else l(a.includes(L)?a.filter(T=>T!==L):[...a,L])}},[a,m,l,f,De]),Be=t.useCallback(L=>{var W;if(!ee)return!0;const oe=ee.toLowerCase();return L.text.toLowerCase().includes(oe)?!0:((W=b.get(L.key)??L.children)==null?void 0:W.some(T=>Be(T)))??!1},[ee,b]),X=t.useCallback((L,oe)=>{I!=null&&I.length&&(L.preventDefault(),Q({x:L.clientX,y:L.clientY,node:oe}))},[I]),ye=t.useCallback(()=>{H&&ue&&ue(H,ge),_e(null)},[H,ge,ue]),Ie=(L,oe)=>{if(ee&&!Be(L))return null;const W=typeof Ae=="number"?Math.min(10,Math.max(1,Ae)):1/0,T=oe+1>=W,ne=T?void 0:b.get(L.key)??L.children,je=!T&&(ne&&ne.length>0||L.leaf!==!0&&c&&!(ne!=null&&ne.length)),V=nn.includes(L.key),Le=De.has(L.key),Se=M.has(L.key),he=f&&m==="multiple"&&(ne!=null&&ne.length)?zt(L,De):Le?"checked":"unchecked",Qe=Math.min(oe+1,10),pn={paddingLeft:oe*20+4,"--nice-row-bg":`var(--nice-tree-level-${Qe}-bg, transparent)`,"--nice-row-text":`var(--nice-tree-level-${Qe}-text, inherit)`,"--nice-row-border":`var(--nice-tree-level-${Qe}-border, transparent)`,"--nice-row-hover-bg":`var(--nice-tree-level-${Qe}-hover-bg, var(--hover-bg, color-mix(in srgb, var(--text-primary) 6%, transparent)))`,"--nice-row-active-bg":`var(--nice-tree-level-${Qe}-active-bg, color-mix(in srgb, var(--color-primary) 14%, transparent))`};return e.jsxs("li",{className:"nice-tree__node",role:"treeitem","aria-expanded":je?V:void 0,"data-nice-depth":Qe,draggable:s&&!L.disabled,onDragStart:s?ve=>{ve.stopPropagation(),O(L.key)}:void 0,onDragOver:s?ve=>{ve.preventDefault(),ve.stopPropagation()}:void 0,onDrop:s&&le?ve=>{ve.stopPropagation(),w==null||w(le,L.key,"inside"),O(null)}:void 0,onDragEnd:s?()=>O(null):void 0,children:[e.jsxs("div",{className:`nice-tree__row ${Le?"nice-tree__row--selected":""} ${L.disabled?"nice-tree__row--disabled":""} ${le===L.key?"nice-tree__row--dragging":""}`,style:pn,onClick:()=>{L.disabled||(Ee(L.key,L),N==null||N(L))},onContextMenu:ve=>X(ve,L),onDoubleClick:te&&!L.disabled?()=>{_e(L.key),Te(L.text)}:void 0,children:[e.jsx("span",{className:`nice-tree__toggle ${je?V?"nice-tree__toggle--expanded":"":"nice-tree__toggle--leaf"}`,onClick:ve=>{ve.stopPropagation(),je&&tn(L.key,L)},children:Se?e.jsx("span",{className:"nice-spinner nice-spinner--xs"}):je?V?"▾":"▸":""}),f&&m!=="none"&&e.jsx("input",{type:"checkbox",checked:he==="checked",ref:ve=>{ve&&(ve.indeterminate=he==="indeterminate")},onChange:()=>Ee(L.key,L),onClick:ve=>ve.stopPropagation(),tabIndex:-1,className:"nice-tree__checkbox"}),H===L.key?e.jsx("input",{type:"text",className:"nice-tree__edit-input",value:ge,onChange:ve=>Te(ve.target.value),onBlur:ye,onKeyDown:ve=>{ve.key==="Enter"&&ye(),ve.key==="Escape"&&_e(null)},autoFocus:!0,onClick:ve=>ve.stopPropagation()}):S?S(L):e.jsxs(e.Fragment,{children:[L.icon&&e.jsx("span",{className:"nice-tree__icon",children:L.icon}),e.jsx("span",{className:"nice-tree__text",children:L.text})]})]}),ne&&ne.length>0&&V&&e.jsx("ul",{className:"nice-tree__children",role:"group",children:ne.map(ve=>Ie(ve,oe+1))})]},L.key)};return D?null:e.jsxs("div",{className:`nice-tree ${K?"nice-tree--lines":""} ${R||""}`,style:P,ref:Xe,onClick:()=>Q(null),children:[o&&e.jsx("div",{className:"nice-tree__search",children:e.jsx("input",{type:"text",value:ee,onChange:L=>ae(L.target.value),placeholder:g||me("controls.search","Search..."),"aria-label":g||me("controls.search","Search tree")})}),A?e.jsx("div",{className:"nice-tree__loading",children:e.jsx("div",{className:"nice-spinner nice-spinner--sm"})}):e.jsx("ul",{className:"nice-tree__root",role:"tree",children:n.map(L=>Ie(L,0))}),U&&I&&e.jsx("div",{className:"nice-tree__context-menu",style:{position:"fixed",top:U.y,left:U.x,zIndex:9999},children:I.map(L=>e.jsxs("div",{className:`nice-tree__context-item ${L.disabled?"nice-tree__context-item--disabled":""}`,onClick:()=>{L.disabled||(F==null||F(L.key,U.node),Q(null))},children:[L.icon&&e.jsx("span",{children:L.icon}),L.label]},L.key))})]})};function Zi(n,a,r){const l=new Map,d=[];return n.forEach(m=>{const f={...m,children:[]};l.set(String(f[a]),f)}),n.forEach(m=>{const f=m[r];f!=null&&l.has(String(f))?l.get(String(f)).children.push(l.get(String(m[a]))):d.push(l.get(String(m[a])))}),d}function pi({columns:n,data:a,keyField:r="key",parentKeyField:l="parentKey",expandedKeys:d,onExpandedChange:m,selectedKeys:f=[],onSelectionChange:o,selectable:g,loading:N,emptyText:S,className:K,style:A,accessMode:R,id:P}){const G=J.Cl(R,P)==="hidden",{t:y}=J.ue(),[s,w]=t.useState([]),c=d??s,I=t.useMemo(()=>Zi(a,r,l),[a,r,l]),F=t.useMemo(()=>n.filter(D=>!D.hidden),[n]),te=t.useCallback(D=>{const me=c.includes(D)?c.filter(be=>be!==D):[...c,D];m?m(me):w(me)},[c,m]),ue=t.useCallback(D=>{o&&o(f.includes(D)?f.filter(me=>me!==D):[...f,D])},[f,o]),Ae=(D,me)=>{const be=String(D[r]),xe=D.children&&D.children.length>0,ee=c.includes(be),ae=f.includes(be);return e.jsxs(t.Fragment,{children:[e.jsxs("tr",{className:ae?"nice-treelist__row--selected":"",children:[g&&e.jsx("td",{className:"nice-treelist__checkbox",children:e.jsx("input",{type:"checkbox",checked:ae,onChange:()=>ue(be)})}),F.map((M,E)=>e.jsxs("td",{style:{textAlign:M.align},children:[E===0&&e.jsx("span",{style:{display:"inline-block",width:me*20}}),E===0&&e.jsx("span",{className:"nice-treelist__toggle",onClick:()=>xe&&te(be),style:{cursor:xe?"pointer":"default",width:20,display:"inline-block"},children:xe?ee?"▾":"▸":""}),M.render?M.render(D[M.field],D,0):String(D[M.field]??"")]},M.field))]}),xe&&ee&&D.children.map(M=>Ae(M,me+1))]},be)};return G?null:e.jsx("div",{className:`nice-treelist ${K||""}`,style:A,children:e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[g&&e.jsx("th",{className:"nice-treelist__checkbox"}),F.map(D=>e.jsx("th",{style:{width:D.width,minWidth:D.minWidth,textAlign:D.align},children:D.header},D.field))]})}),e.jsx("tbody",{children:N?e.jsx("tr",{children:e.jsx("td",{colSpan:F.length+(g?1:0),className:"nice-treelist__empty",children:e.jsx("div",{className:"nice-spinner nice-spinner--md",style:{margin:"0 auto"}})})}):I.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:F.length+(g?1:0),className:"nice-treelist__empty",children:S||y("controls.noData","No data available")})}):I.map(D=>Ae(D,0))})]})})}function gi({items:n,renderCard:a,columns:r=3,gap:l=16,searchable:d,searchField:m="text",searchPlaceholder:f,loading:o,emptyText:g,onCardClick:N,className:S,style:K,accessMode:A,id:R}){const P=J.Cl(A,R)==="hidden",{t:G}=J.ue(),[y,s]=t.useState(""),w=t.useMemo(()=>{if(!y)return n;const c=y.toLowerCase();return n.filter(I=>String(I[m]??"").toLowerCase().includes(c))},[n,y,m]);return P?null:e.jsxs("div",{className:`nice-cardview ${S||""}`,style:K,children:[d&&e.jsx("div",{className:"nice-cardview__search",children:e.jsx("input",{type:"text",value:y,onChange:c=>s(c.target.value),placeholder:f||G("controls.search","Search...")})}),o?e.jsx("div",{className:"nice-cardview__loading",children:e.jsx("div",{className:"nice-spinner nice-spinner--md"})}):w.length===0?e.jsx("div",{className:"nice-cardview__empty",children:g||G("controls.noData","No data available")}):e.jsx("div",{className:"nice-cardview__grid",style:{display:"grid",gridTemplateColumns:`repeat(${r}, 1fr)`,gap:l},children:w.map(c=>e.jsx("div",{className:"nice-cardview__card",onClick:()=>N==null?void 0:N(c),style:N?{cursor:"pointer"}:void 0,children:a(c)},c.key))})]})}function fi({items:n,tileWidth:a=180,tileHeight:r=180,direction:l="horizontal",renderTile:d,onTileClick:m,loading:f,emptyText:o,className:g,style:N}){const{t:S}=J.ue();return e.jsx("div",{className:`nice-tileview nice-tileview--${l} ${g||""}`,style:N,children:f?e.jsx("div",{className:"nice-tileview__loading",children:e.jsx("div",{className:"nice-spinner nice-spinner--md"})}):n.length===0?e.jsx("div",{className:"nice-tileview__empty",children:o||S("controls.noData","No data available")}):e.jsx("div",{className:"nice-tileview__container",style:{display:"flex",flexWrap:"wrap",gap:8,flexDirection:l==="vertical"?"column":"row"},children:n.map(K=>e.jsx("div",{className:"nice-tileview__tile",style:{width:a,height:r,cursor:m?"pointer":void 0},onClick:()=>m==null?void 0:m(K),children:d?d(K):e.jsxs(e.Fragment,{children:[K.image&&e.jsx("img",{src:K.image,alt:K.text||"",className:"nice-tileview__image"}),K.text&&e.jsx("div",{className:"nice-tileview__label",children:K.text})]})},K.key))})})}const ai=[{key:"row",label:"Rows"},{key:"column",label:"Columns"},{key:"data",label:"Values"},{key:"filter",label:"Filters"}],Et=({fields:n,onChange:a,className:r,style:l})=>{const d=n.filter(o=>!o.area),m=(o,g)=>{a(n.map(N=>N.field===o?{...N,area:g}:N))},f=o=>{a(n.map(g=>g.field===o?{...g,area:void 0}:g))};return e.jsx("div",{className:`nice-field-chooser ${r||""}`,style:l,children:e.jsxs("div",{className:"nice-field-chooser__panel",children:[e.jsxs("div",{className:"nice-field-chooser__section",children:[e.jsx("h4",{children:"Available Fields"}),e.jsx("ul",{children:d.map(o=>e.jsxs("li",{className:"nice-field-chooser__item",children:[e.jsx("span",{children:o.caption}),e.jsx("div",{className:"nice-field-chooser__actions",children:ai.map(g=>e.jsx("button",{type:"button",className:"nice-btn nice-btn--ghost nice-btn--sm",onClick:()=>m(o.field,g.key),children:g.label},g.key))})]},o.field))})]}),ai.map(o=>{const g=n.filter(N=>N.area===o.key);return e.jsxs("div",{className:"nice-field-chooser__section",children:[e.jsx("h4",{children:o.label}),e.jsx("ul",{children:g.map(N=>e.jsxs("li",{className:"nice-field-chooser__item",children:[e.jsx("span",{children:N.caption}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--ghost nice-btn--sm",onClick:()=>f(N.field),children:"✕"})]},N.field))})]},o.key)})]})})};function Ji(n,a){if(n.length===0)return 0;switch(a){case"sum":return n.reduce((r,l)=>r+l,0);case"count":return n.length;case"avg":return n.reduce((r,l)=>r+l,0)/n.length;case"min":return Math.min(...n);case"max":return Math.max(...n);default:return n.reduce((r,l)=>r+l,0)}}function ri(n,a){return[...new Set(n.map(r=>String(r[a]??"")))].sort()}const Rt=({data:n,fields:a,onFieldsChange:r,showFieldChooser:l,loading:d,emptyText:m,exportCsv:f,exportFilename:o="pivot-export",onDrillThrough:g,className:N,style:S,accessMode:K,id:A})=>{const R=J.Cl(K,A)==="hidden",{t:P}=J.ue(),[G,y]=t.useState(a),[s,w]=t.useState(!1),c=t.useMemo(()=>G.filter(ee=>ee.area==="row"),[G]),I=t.useMemo(()=>G.filter(ee=>ee.area==="column"),[G]),F=t.useMemo(()=>G.filter(ee=>ee.area==="data"),[G]),te=t.useMemo(()=>c.length===0?["Total"]:ri(n,c[0].field),[n,c]),ue=t.useMemo(()=>I.length===0?["Total"]:ri(n,I[0].field),[n,I]),Ae=t.useCallback((ee,ae,M)=>{let E=n;c.length>0&&(E=E.filter(le=>String(le[c[0].field])===ee)),I.length>0&&(E=E.filter(le=>String(le[I[0].field])===ae));const b=E.map(le=>Number(le[M.field])||0),we=Ji(b,M.summaryType||"sum");return M.format?M.format(we):we},[n,c,I]),D=t.useCallback(ee=>{y(ee),r==null||r(ee)},[r]),me=t.useCallback((ee,ae)=>{let M=n;return c.length>0&&(M=M.filter(E=>String(E[c[0].field])===ee)),I.length>0&&(M=M.filter(E=>String(E[I[0].field])===ae)),M},[n,c,I]),be=t.useCallback((ee,ae)=>{g&&g(ee,ae,me(ee,ae))},[g,me]),xe=t.useCallback(()=>{const ee=["",...ue.flatMap(le=>F.length>0?F.map(O=>`${le} - ${O.caption}`):[le])],ae=te.map(le=>{const O=ue.flatMap(U=>F.length>0?F.map(Q=>String(Ae(le,U,Q))):["—"]);return[le,...O]}),M=[ee,...ae].map(le=>le.map(O=>`"${String(O).replace(/"/g,'""')}"`).join(",")).join(`
|
|
15
|
+
`),E=new Blob(["\uFEFF"+M],{type:"text/csv;charset=utf-8;"}),b=URL.createObjectURL(E),we=document.createElement("a");we.href=b,we.download=`${o}.csv`,we.click(),URL.revokeObjectURL(b)},[ue,te,F,Ae,o]);return R?null:e.jsxs("div",{className:`nice-pivotgrid ${N||""}`,style:S,children:[(l||f)&&e.jsxs("div",{className:"nice-pivotgrid__toolbar",children:[l&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",onClick:()=>w(!s),children:P("controls.fieldChooser","Field Chooser")}),f&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--sm",onClick:xe,children:"CSV ↓"})]}),s&&e.jsx(Et,{fields:G,onChange:D}),d?e.jsx("div",{className:"nice-pivotgrid__loading",children:e.jsx("div",{className:"nice-spinner nice-spinner--md"})}):e.jsx("div",{className:"nice-pivotgrid__table-wrap",children:e.jsxs("table",{className:"nice-pivotgrid__table",children:[e.jsxs("thead",{children:[e.jsxs("tr",{children:[e.jsx("th",{children:c.map(ee=>ee.caption).join(" / ")||""}),ue.map(ee=>e.jsx("th",{colSpan:F.length||1,children:ee},ee))]}),F.length>1&&e.jsxs("tr",{children:[e.jsx("th",{}),ue.map(ee=>F.map(ae=>e.jsx("th",{children:ae.caption},`${ee}-${ae.field}`)))]})]}),e.jsx("tbody",{children:te.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:1+ue.length*Math.max(F.length,1),className:"nice-pivotgrid__empty",children:m||P("controls.noData","No data available")})}):te.map(ee=>e.jsxs("tr",{children:[e.jsx("td",{className:"nice-pivotgrid__row-header",children:ee}),ue.map(ae=>F.length>0?F.map(M=>e.jsx("td",{className:`nice-pivotgrid__cell ${g?"nice-pivotgrid__cell--clickable":""}`,onClick:g?()=>be(ee,ae):void 0,children:Ae(ee,ae,M)},`${ae}-${M.field}`)):e.jsx("td",{className:"nice-pivotgrid__cell",children:"—"},ae))]},ee))})]})})]})},Hi=Object.freeze(Object.defineProperty({__proto__:null,NicePivotGrid:Rt},Symbol.toStringTag,{value:"Module"}));function Xi({open:n}){return e.jsx("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{transition:"transform 160ms ease",transform:n?"rotate(0deg)":"rotate(-90deg)"},children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})}function Vi(){return e.jsxs("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),e.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}const Ft=t.forwardRef(({columns:n,cards:a,onCardMove:r,onCardClick:l,renderCard:d,onAddCard:m,disabled:f=!1,size:o="md",collapsible:g=!1,layoutMode:N="scroll",viewMode:S,onViewModeChange:K,collapsedColumns:A,onCollapsedColumnsChange:R,formItems:P,formColumns:G=1,formProps:y,editCardTitle:s,newCardTitle:w,onCardEdit:c,onCardCreate:I,onCardDelete:F,cookies:te=!1,localStorage:ue=!0,sessionStorage:Ae=!1,storageMode:D,storageKey:me,className:be,style:xe,id:ee,...ae},M)=>{const{t:E}=J.ue(),[b,we]=t.useState(null),[le,O]=t.useState(null),[U,Q]=t.useState(null),H=!!P&&(!!c||!!I),_e=t.useCallback(T=>{if(H&&c){Q({key:T.key,data:{...T},column:T.column});return}l==null||l(T)},[H,l,c]),ge=t.useCallback(T=>{if(H&&I){Q({key:null,data:{title:"",description:""},column:T});return}m==null||m(T)},[H,m,I]),Te=J.fr(me??"nice-kanban"),[Xe,nn]=t.useState(()=>Te.get("state")??{collapsedColumns:[],viewMode:"default"}),De=A??Xe.collapsedColumns??[],tn=S??Xe.viewMode??"default",Ee=t.useCallback(T=>{nn(ne=>{const je={...ne,...T};return Te.set("state",je),je})},[Te]),Be=t.useCallback(T=>{const ne=De.includes(T)?De.filter(je=>je!==T):[...De,T];R?R(ne):Ee({collapsedColumns:ne})},[De,R,Ee]);t.useCallback(T=>{K?K(T):Ee({viewMode:T})},[K,Ee]);const X=t.useCallback(T=>a.filter(ne=>ne.column===T).sort((ne,je)=>(ne.order??0)-(je.order??0)),[a]),ye=t.useCallback((T,ne)=>{f||(T.dataTransfer.effectAllowed="move",T.dataTransfer.setData("text/plain",String(ne.key)),we({cardKey:ne.key,fromColumn:ne.column}))},[f]),Ie=t.useCallback((T,ne)=>{T.preventDefault(),T.dataTransfer.dropEffect="move",O({column:ne})},[]),L=t.useCallback(()=>{O(null)},[]),oe=t.useCallback((T,ne)=>{if(T.preventDefault(),O(null),!b||f)return;const je=X(ne);r==null||r(b.cardKey,ne,je.length),we(null)},[b,f,X,r]),W=t.useCallback(()=>{we(null),O(null)},[]);return e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:M,id:ee,className:`nice-kanban nice-kanban--${o} nice-kanban--${tn} nice-kanban--layout-${N} ${f?"nice-kanban--disabled":""} ${be||""}`,style:xe,...ae,children:n.map(T=>{const ne=X(T.key),je=(le==null?void 0:le.column)===T.key,V=T.limit!=null&&ne.length>=T.limit,Le=g&&De.includes(T.key);return e.jsxs("div",{className:`nice-kanban__column ${je?"nice-kanban__column--dragover":""} ${Le?"nice-kanban__column--collapsed":""}`,onDragOver:Se=>!Le&&Ie(Se,T.key),onDragLeave:L,onDrop:Se=>!Le&&oe(Se,T.key),children:[e.jsxs("div",{className:"nice-kanban__column-header",style:T.color?{borderTopColor:T.color}:void 0,onClick:g?()=>Be(T.key):void 0,role:g?"button":void 0,tabIndex:g?0:void 0,onKeyDown:g?Se=>{(Se.key==="Enter"||Se.key===" ")&&Be(T.key)}:void 0,children:[g&&e.jsx("span",{className:"nice-kanban__collapse-icon","aria-hidden":"true",children:e.jsx(Xi,{open:!Le})}),e.jsx("span",{className:"nice-kanban__column-title",children:T.title}),e.jsxs("span",{className:"nice-kanban__column-count",children:[ne.length,T.limit!=null&&` / ${T.limit}`]})]}),!Le&&e.jsxs("div",{className:"nice-kanban__column-body",children:[ne.map(Se=>e.jsx("div",{className:`nice-kanban__card nice-kanban__card--${tn} ${(b==null?void 0:b.cardKey)===Se.key?"nice-kanban__card--dragging":""}`,draggable:!f,onDragStart:he=>ye(he,Se),onDragEnd:W,onClick:()=>_e(Se),role:"article",children:d?d(Se):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"nice-kanban__card-title",children:Se.title}),tn!=="compact"&&Se.description&&e.jsx("div",{className:"nice-kanban__card-desc",children:Se.description})]})},Se.key)),ne.length===0&&e.jsx("div",{className:"nice-kanban__empty",children:E("kanban.empty","No cards")})]}),!Le&&(m||H&&I)&&!V&&e.jsxs("button",{type:"button",className:"nice-kanban__add",onClick:()=>ge(T.key),disabled:f,children:[e.jsx(Vi,{})," ",E("kanban.addCard","Add card")]})]},T.key)})}),H&&U&&e.jsxs(Tt,{open:!0,onClose:()=>Q(null),title:U.key==null?w||E("kanban.newCard","New card"):s||E("kanban.editCard","Edit card"),children:[e.jsx(J.Ga,{items:P,data:U.data,columns:G,...y,onFieldChange:(T,ne)=>Q(je=>je&&{...je,data:{...je.data,[T]:ne}})}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:16,flexWrap:"wrap"},children:[U.key!=null&&F&&e.jsx(J.pn,{type:"button",size:"sm",variant:"error",style:{marginRight:"auto"},onClick:()=>{F(U.key),Q(null)},children:E("controls.delete","Delete")}),e.jsx(J.pn,{type:"button",size:"sm",variant:"secondary",onClick:()=>Q(null),children:E("controls.cancel","Cancel")}),e.jsx(J.pn,{type:"button",size:"sm",variant:"primary",onClick:()=>{if(U.key==null){const T={key:`card-${Date.now()}`,title:"",column:U.column,...U.data};I==null||I(T)}else c==null||c(U.key,{...U.data,key:U.key,column:U.column});Q(null)},children:E("controls.save","Save")})]})]})]})});Ft.displayName="NiceKanbanBoard";function An(...n){return n.filter(Boolean).map(a=>typeof a=="object"?Object.entries(a).filter(([,r])=>r).map(([r])=>r).join(" "):a).join(" ")}const qi=50,Yi=[10,25,50,100,200],ea=40,na=10,ta=768,ia=500,aa=10;function wn(n,a){return a.split(".").reduce((r,l)=>r==null?void 0:r[l],n)}function dt(n,a,r="pl-PL"){var l,d,m;if(n==null)return"—";switch(a.type){case"number":return new Intl.NumberFormat(r,{minimumFractionDigits:(l=a.format)!=null&&l.includes(".")?a.format.split(".")[1].length:0}).format(n);case"currency":return new Intl.NumberFormat(r,{style:"currency",currency:a.currencyCode||"PLN"}).format(n);case"percent":return new Intl.NumberFormat(r,{style:"percent",minimumFractionDigits:0,maximumFractionDigits:2}).format(n/100);case"date":return new Intl.DateTimeFormat(r,{dateStyle:"short"}).format(new Date(n));case"datetime":return new Intl.DateTimeFormat(r,{dateStyle:"short",timeStyle:"short"}).format(new Date(n));case"boolean":return n?"✓":"✗";case"enum":return((m=(d=a.enumOptions)==null?void 0:d.find(f=>f.value===n))==null?void 0:m.label)||String(n);default:return String(n)}}function ra(n,a,r,l){const[d,m]=t.useState(0),{startIndex:f,endIndex:o,totalHeight:g,offsetY:N}=t.useMemo(()=>{const A=n.length*r,R=Math.ceil(a/r),P=Math.max(0,Math.floor(d/r)-l),G=Math.min(n.length,Math.ceil(d/r)+R+l),y=P*r;return{startIndex:P,endIndex:G,totalHeight:A,offsetY:y}},[n.length,a,r,d,l]),S=t.useMemo(()=>n.slice(f,o),[n,f,o]),K=t.useCallback(A=>{m(A.currentTarget.scrollTop)},[]);return{visibleData:S,totalHeight:g,offsetY:N,handleScroll:K,startIndex:f}}function la(n,a){const[r,l]=t.useState(()=>{if(n&&typeof window<"u"){const m=localStorage.getItem(`nice-module-grid-${n}`);if(m)return JSON.parse(m)}return a||{}}),d=t.useCallback(m=>{l(f=>{const o={...f,...m};return n&&typeof window<"u"&&localStorage.setItem(`nice-module-grid-${n}`,JSON.stringify(o)),o})},[n]);return[r,d]}function sa(n){const[a,r]=t.useState(typeof window<"u"&&window.innerWidth<n);return t.useEffect(()=>{if(typeof window>"u")return;const l=()=>r(window.innerWidth<n);return window.addEventListener("resize",l),()=>window.removeEventListener("resize",l)},[n]),a}function ca({column:n,sort:a,onSort:r,onResize:l,resizable:d,t:m}){const f=t.useRef(null),[o,g]=t.useState(!1),N=t.useCallback(A=>{if(!d||!l)return;A.preventDefault(),g(!0);const R=A.clientX,P=n.width||150,G=s=>{const w=s.clientX-R,c=Math.max(n.minWidth||50,P+w);l(n.field,Math.min(c,n.maxWidth||1/0))},y=()=>{g(!1),document.removeEventListener("mousemove",G),document.removeEventListener("mouseup",y)};document.addEventListener("mousemove",G),document.addEventListener("mouseup",y)},[n,d,l]),S=a==null?void 0:a.direction,K=S==="asc"?"↑":S==="desc"?"↓":null;return e.jsxs("div",{className:An("nice-module-grid__header-cell",n.sortable&&"nice-module-grid__header-cell--sortable",o&&"nice-module-grid__header-cell--resizing"),style:{width:n.width==="auto"?"auto":n.width||150,minWidth:n.minWidth,maxWidth:n.maxWidth,textAlign:n.align},onClick:()=>n.sortable&&(r==null?void 0:r(n.field)),role:"columnheader","aria-sort":S==="asc"?"ascending":S==="desc"?"descending":"none",title:n.headerTooltip,children:[e.jsx("span",{className:"nice-module-grid__header-text",children:n.header}),K&&e.jsx("span",{className:"nice-module-grid__sort-indicator",children:K}),d&&e.jsx("div",{ref:f,className:"nice-module-grid__resize-handle",onMouseDown:N})]})}function oa({column:n,row:a,rowIndex:r,value:l,locale:d="pl-PL",onClick:m}){const f=J.Wl({onClick:m}),o=m?f:{};if(n.render)return e.jsx("div",{className:"nice-module-grid__cell",style:{textAlign:n.align},...o,children:n.render(l,a,r)});if(n.type==="enum"&&n.enumOptions){const g=n.enumOptions.find(N=>N.value===l);if(g)return e.jsx("div",{className:"nice-module-grid__cell",style:{textAlign:n.align},...o,children:e.jsxs("span",{className:An("nice-module-grid__badge",`nice-module-grid__badge--${g.color||"default"}`),children:[g.icon&&e.jsx("span",{className:"nice-module-grid__badge-icon",children:g.icon}),g.label]})})}if(n.type==="progress"){const g=Math.min(100,Math.max(0,Number(l)||0));return e.jsx("div",{className:"nice-module-grid__cell",style:{textAlign:n.align},...o,children:e.jsxs("div",{className:"nice-module-grid__progress",children:[e.jsx("div",{className:An("nice-module-grid__progress-bar",`nice-module-grid__progress-bar--${n.progressColor||"primary"}`),style:{width:`${g}%`}}),e.jsxs("span",{className:"nice-module-grid__progress-text",children:[g,"%"]})]})})}if(n.type==="rating"){const g=n.maxRating||5,N=Number(l)||0;return e.jsx("div",{className:"nice-module-grid__cell",style:{textAlign:n.align},...o,children:e.jsx("span",{className:"nice-module-grid__rating","aria-label":`${N} out of ${g} stars`,children:Array.from({length:g},(S,K)=>e.jsx("span",{className:An("nice-module-grid__star",K<N&&"nice-module-grid__star--filled"),children:"★"},K))})})}if(n.type==="link"&&n.linkTemplate){const g=n.linkTemplate.replace(/\{\{(\w+)\}\}/g,(N,S)=>String(wn(a,S)??""));return e.jsx("div",{className:"nice-module-grid__cell",style:{textAlign:n.align},...o,children:e.jsx("a",{href:g,target:n.linkNewTab?"_blank":void 0,rel:n.linkNewTab?"noopener noreferrer":void 0,className:"nice-module-grid__link",children:dt(l,n,d)})})}if(n.type==="image"){const g={xs:24,sm:32,md:48,lg:64}[n.imageSize||"sm"];return e.jsx("div",{className:"nice-module-grid__cell",style:{textAlign:n.align},...o,children:l?e.jsx("img",{src:String(l),alt:"",className:"nice-module-grid__image",style:{width:g,height:g}}):e.jsx("div",{className:"nice-module-grid__image-placeholder",style:{width:g,height:g}})})}return n.type==="avatar"?e.jsx("div",{className:"nice-module-grid__cell",style:{textAlign:n.align},...o,children:l?e.jsx("img",{src:String(l),alt:"",className:"nice-module-grid__avatar"}):e.jsx("div",{className:"nice-module-grid__avatar-placeholder",children:"?"})}):n.type==="color"?e.jsx("div",{className:"nice-module-grid__cell",style:{textAlign:n.align},...o,children:e.jsx("span",{className:"nice-module-grid__color-swatch",style:{backgroundColor:l||"transparent"},title:l})}):n.type==="boolean"?e.jsx("div",{className:"nice-module-grid__cell",style:{textAlign:n.align||"center"},...o,children:e.jsx("span",{className:An("nice-module-grid__boolean",!!l&&"nice-module-grid__boolean--true"),children:l?"✓":"✗"})}):e.jsx("div",{className:"nice-module-grid__cell",style:{textAlign:n.align},...o,children:dt(l,n,d)})}function da({row:n,index:a,columns:r,primaryField:l,secondaryField:d,customRender:m,selected:f,onClick:o,locale:g="pl-PL",t:N}){if(m)return e.jsx("div",{className:An("nice-module-grid__mobile-card",f&&"nice-module-grid__mobile-card--selected"),onClick:o,children:m(n,a)});const S=r.find(A=>A.field===l)||r[0],K=r.find(A=>A.field===d)||r[1];return e.jsxs("div",{className:An("nice-module-grid__mobile-card",f&&"nice-module-grid__mobile-card--selected"),onClick:o,role:"row","aria-selected":f,children:[e.jsxs("div",{className:"nice-module-grid__mobile-card-header",children:[e.jsx("div",{className:"nice-module-grid__mobile-card-title",children:dt(wn(n,(S==null?void 0:S.field)||""),S,g)}),K&&e.jsx("div",{className:"nice-module-grid__mobile-card-subtitle",children:dt(wn(n,K.field),K,g)})]}),e.jsx("div",{className:"nice-module-grid__mobile-card-body",children:r.filter(A=>!A.hidden&&A.field!==l&&A.field!==d).slice(0,4).map(A=>e.jsxs("div",{className:"nice-module-grid__mobile-card-field",children:[e.jsx("span",{className:"nice-module-grid__mobile-card-label",children:A.header}),e.jsx("span",{className:"nice-module-grid__mobile-card-value",children:dt(wn(n,A.field),A,g)})]},A.field))})]})}function ua({page:n,pageSize:a,totalRows:r,pageSizeOptions:l,onPageChange:d,t:m}){const f=Math.ceil(r/a),o=(n-1)*a+1,g=Math.min(n*a,r);return e.jsxs("div",{className:"nice-module-grid__pagination",role:"navigation","aria-label":m("pagination.ariaLabel","Pagination"),children:[e.jsxs("div",{className:"nice-module-grid__pagination-info",children:[m("pagination.showing","Showing")," ",o,"–",g," ",m("pagination.of","of")," ",r]}),e.jsxs("div",{className:"nice-module-grid__pagination-controls",children:[e.jsx("select",{className:"nice-module-grid__page-size-select",value:a,onChange:N=>d(1,Number(N.target.value)),"aria-label":m("pagination.rowsPerPage","Rows per page"),children:l.map(N=>e.jsx("option",{value:N,children:N},N))}),e.jsx("button",{className:"nice-module-grid__pagination-btn",onClick:()=>d(1,a),disabled:n===1,"aria-label":m("pagination.first","First"),children:"««"}),e.jsx("button",{className:"nice-module-grid__pagination-btn",onClick:()=>d(n-1,a),disabled:n===1,"aria-label":m("pagination.previous","Previous"),children:"«"}),e.jsxs("span",{className:"nice-module-grid__pagination-page",children:[n," / ",f]}),e.jsx("button",{className:"nice-module-grid__pagination-btn",onClick:()=>d(n+1,a),disabled:n>=f,"aria-label":m("pagination.next","Next"),children:"»"}),e.jsx("button",{className:"nice-module-grid__pagination-btn",onClick:()=>d(f,a),disabled:n>=f,"aria-label":m("pagination.last","Last"),children:"»»"})]})]})}function ma({columns:n}){return e.jsx("div",{className:"nice-module-grid__row nice-module-grid__row--skeleton",role:"row",children:n.filter(a=>!a.hidden).map(a=>e.jsx("div",{className:"nice-module-grid__cell nice-module-grid__cell--skeleton",style:{width:a.width==="auto"?"auto":a.width||150},children:e.jsx("div",{className:"nice-module-grid__skeleton-bar"})},a.field))})}function ha(n,a){var lt;const{columns:r,data:l,keyField:d="id",dataSource:m,onFetch:f,sortable:o=!0,sort:g,onSortChange:N,multiSort:S=!1,filterable:K=!1,filter:A,onFilterChange:R,searchText:P,onSearchChange:G,searchPlaceholder:y="moduleGrid.searchPlaceholder",pagination:s=!0,page:w,pageSize:c,pageSizeOptions:I=Yi,totalRows:F,onPageChange:te,virtualScroll:ue=!0,rowHeight:Ae=ea,overscan:D=na,selectionMode:me="none",selectedKeys:be,onSelectionChange:xe,columnReorder:ee=!0,onColumnOrderChange:ae,columnResize:M=!0,onColumnWidthChange:E,groupBy:b,onGroupByChange:we,groupRowRender:le,expandAllGroups:O=!1,editable:U=!1,onCellEdit:Q,onRowEdit:H,editMode:_e="cell",contextMenuItems:ge,onContextMenuAction:Te,exportable:Xe=!0,exportFormats:nn=["csv","excel"],onExport:De,preferencesKey:tn,initialPreferences:Ee,onPreferencesChange:Be,density:X="normal",striped:ye=!0,bordered:Ie=!1,hoverable:L=!0,loading:oe=!1,emptyState:W,toolbar:T,onRowClick:ne,onRowDoubleClick:je,rowClassName:V,rowStyle:Le,mobileCardView:Se=!0,mobileBreakpoint:he=ta,mobileCardRender:Qe,mobilePrimaryField:pn,mobileSecondaryField:ve,moduleId:kn,permissions:Nn,size:Ve="medium",skeletonLoading:In=!0,skeletonRows:$=aa,"aria-label":de,"aria-labelledby":pe,"aria-describedby":ke,className:un,style:Ce,id:Ke,testId:mn}=n,{t:We}=J.ue();J.Cl(),J.Us("table");const an=sa(he),[Cn,Qn]=la(tn,Ee),Zn=t.useRef(null),et=t.useRef(null),[Jn,Hn]=t.useState([]),[hn,mt]=t.useState(),[nt,Pe]=t.useState(""),[qe,Oe]=t.useState(1),[Kn,Ln]=t.useState(c||qi),[Un,Rn]=t.useState(new Set),[Wn,Xn]=t.useState([]),[u,h]=t.useState(0),[v,B]=t.useState(!1),[q,k]=t.useState(new Set),[z,Y]=t.useState(null),[Fe,Re]=t.useState({}),re=g??Jn,Ze=A??hn,ln=P??nt,gn=w??qe,sn=c??Kn,fn=be??Un,tt=F??u??(l==null?void 0:l.length)??0,zn=!!(f||m),Sn=t.useMemo(()=>{const _=new Set(Cn.hiddenColumns||[]);return r.filter(se=>!se.hidden&&!_.has(se.field))},[r,Cn.hiddenColumns]),Tn=t.useMemo(()=>{if(zn)return Wn;if(!l)return[];let _=[...l];if(ln){const se=ln.toLowerCase(),fe=r.filter(Me=>Me.searchable!==!1).map(Me=>Me.field);_=_.filter(Me=>fe.some($e=>{const He=wn(Me,$e);return String(He??"").toLowerCase().includes(se)}))}return re.length>0&&_.sort((se,fe)=>{for(const Me of re){const $e=wn(se,Me.field),He=wn(fe,Me.field),_n=$e<He?-1:$e>He?1:0;if(_n!==0)return Me.direction==="asc"?_n:-_n}return 0}),_},[zn,Wn,l,ln,re,r]),on=t.useMemo(()=>{if(zn||!s)return Tn;const _=(gn-1)*sn;return Tn.slice(_,_+sn)},[zn,Tn,s,gn,sn]),ht=((lt=Zn.current)==null?void 0:lt.clientHeight)||400,Mn=ue&&on.length>ia,{visibleData:Fn,totalHeight:Pn,offsetY:it,handleScroll:Nt,startIndex:at}=ra(on,ht,Ae,D),En=Mn?Fn:on,pt=t.useCallback(async()=>{if(f){B(!0);try{const _=await f({page:gn,pageSize:sn,sort:re,filter:Ze,search:ln});Xn(_.data),h(_.total)}catch(_){console.error("NiceModuleGrid fetch error:",_)}finally{B(!1)}}},[f,gn,sn,re,Ze,ln]);t.useEffect(()=>{zn&&pt()},[zn,pt]);const Ct=t.useCallback(_=>{const se=re.find(Me=>Me.field===_);let fe;se?se.direction==="asc"?fe=re.map(Me=>Me.field===_?{...Me,direction:"desc"}:Me):fe=re.filter(Me=>Me.field!==_):fe=S?[...re,{field:_,direction:"asc"}]:[{field:_,direction:"asc"}],N?N(fe):Hn(fe)},[re,S,N]),St=t.useCallback((_,se)=>{te?te(_,se):(Oe(_),Ln(se))},[te]),Ot=t.useCallback(_=>{G?G(_):Pe(_),te||Oe(1)},[G,te]),gt=t.useCallback((_,se)=>{const fe=new Set(fn);if(me==="single"?(fe.clear(),fe.add(_)):(me==="multiple"||me==="checkbox")&&(fe.has(_)?fe.delete(_):fe.add(_)),xe){const Me=on.filter($e=>fe.has(String(wn($e,d))));xe(fe,Me)}else Rn(fe)},[fn,me,xe,on,d]),Mt=t.useCallback((_,se)=>{Re(fe=>({...fe,[_]:se})),E==null||E(_,se),Qn({columnWidths:{...Cn.columnWidths,[_]:se}})},[E,Qn,Cn.columnWidths]),ft=t.useCallback((_,se)=>{ge!=null&&ge.length&&(_.preventDefault(),Y({x:_.clientX,y:_.clientY,row:se}))},[ge]),Bt=t.useCallback(_=>{z&&(Te==null||Te(_,z.row)),Y(null)},[z,Te]),Kt=t.useCallback(async _=>{if(De)await De(_,{selectedOnly:fn.size>0,columns:Sn.map(se=>se.field)});else if(_==="csv"){const se=Sn.map(dn=>dn.header).join(","),fe=on.map(dn=>Sn.map(xt=>JSON.stringify(wn(dn,xt.field)??"")).join(",")),Me=[se,...fe].join(`
|
|
16
|
+
`),$e=new Blob([Me],{type:"text/csv;charset=utf-8;"}),He=URL.createObjectURL($e),_n=document.createElement("a");_n.href=He,_n.download=`export-${new Date().toISOString().slice(0,10)}.csv`,_n.click(),URL.revokeObjectURL(He)}},[De,fn,Sn,on,We]);t.useEffect(()=>{if(!z)return;const _=()=>Y(null);return document.addEventListener("click",_),()=>document.removeEventListener("click",_)},[z]);const rt=t.useCallback(_=>{_.key==="Escape"&&Y(null)},[]),Je=oe||v,cn=!Je&&En.length===0,bn=an&&Se,Dt=An("nice-module-grid",`nice-module-grid--${X}`,`nice-module-grid--${Ve}`,ye&&"nice-module-grid--striped",Ie&&"nice-module-grid--bordered",L&&"nice-module-grid--hoverable",Je&&"nice-module-grid--loading",bn&&"nice-module-grid--mobile",un);return e.jsxs("div",{ref:a,id:Ke,"data-testid":mn,className:Dt,style:Ce,onKeyDown:rt,role:"grid","aria-label":de,"aria-labelledby":pe,"aria-describedby":ke,"aria-rowcount":tt,"aria-colcount":Sn.length,"aria-busy":Je,children:[e.jsxs("div",{className:"nice-module-grid__toolbar",children:[e.jsx("div",{className:"nice-module-grid__toolbar-search",children:e.jsx("input",{type:"search",className:"nice-module-grid__search-input",placeholder:y,value:ln,onChange:_=>Ot(_.target.value),"aria-label":We("moduleGrid.searchAriaLabel","Search")})}),T,Xe&&e.jsx("div",{className:"nice-module-grid__toolbar-export",children:nn.map(_=>e.jsx("button",{className:"nice-module-grid__export-btn",onClick:()=>Kt(_),"aria-label":We(`moduleGrid.export.${_}`,`Export to ${_.toUpperCase()}`),children:_.toUpperCase()},_))})]}),e.jsx("div",{ref:Zn,className:"nice-module-grid__container",onScroll:Mn?Nt:void 0,children:bn?e.jsx("div",{className:"nice-module-grid__mobile-list",children:Je&&In?Array.from({length:$},(_,se)=>e.jsxs("div",{className:"nice-module-grid__mobile-card nice-module-grid__mobile-card--skeleton",children:[e.jsx("div",{className:"nice-module-grid__skeleton-bar",style:{width:"60%",height:20}}),e.jsx("div",{className:"nice-module-grid__skeleton-bar",style:{width:"40%",height:14}}),e.jsx("div",{className:"nice-module-grid__skeleton-bar",style:{width:"80%",height:14}})]},se)):cn?e.jsxs("div",{className:"nice-module-grid__empty",children:[(W==null?void 0:W.icon)&&e.jsx("div",{className:"nice-module-grid__empty-icon",children:W.icon}),e.jsx("div",{className:"nice-module-grid__empty-title",children:(W==null?void 0:W.title)||We("moduleGrid.noData","No data")}),(W==null?void 0:W.description)&&e.jsx("div",{className:"nice-module-grid__empty-description",children:W.description}),(W==null?void 0:W.action)&&e.jsxs("button",{className:"nice-module-grid__empty-action",onClick:W.action.onClick,children:[W.action.icon,W.action.label]})]}):En.map((_,se)=>{const fe=String(wn(_,d));return e.jsx(da,{row:_,index:at+se,columns:Sn,primaryField:pn,secondaryField:ve,customRender:Qe,selected:fn.has(fe),onClick:()=>{me!=="none"&>(fe,_),ne==null||ne(_,at+se)},t:We},fe)})}):e.jsxs("div",{ref:et,className:"nice-module-grid__table",children:[e.jsxs("div",{className:"nice-module-grid__header",role:"row",children:[me==="checkbox"&&e.jsx("div",{className:"nice-module-grid__header-cell nice-module-grid__header-cell--checkbox",children:e.jsx("input",{type:"checkbox",checked:fn.size>0&&fn.size===En.length,onChange:()=>{if(fn.size===En.length)xe==null||xe(new Set,[]),Rn(new Set);else{const _=new Set(En.map(se=>String(wn(se,d))));xe==null||xe(_,En),Rn(_)}},"aria-label":We("moduleGrid.selectAll","Select all")})}),Sn.map(_=>e.jsx(ca,{column:{..._,width:Fe[_.field]||_.width},sort:re.find(se=>se.field===_.field),onSort:o?Ct:void 0,onResize:M?Mt:void 0,resizable:M,t:We},_.field))]}),e.jsx("div",{className:"nice-module-grid__body",style:Mn?{height:Pn,position:"relative"}:void 0,children:Je&&In?Array.from({length:$},(_,se)=>e.jsx(ma,{columns:Sn},se)):cn?e.jsxs("div",{className:"nice-module-grid__empty",children:[(W==null?void 0:W.icon)&&e.jsx("div",{className:"nice-module-grid__empty-icon",children:W.icon}),e.jsx("div",{className:"nice-module-grid__empty-title",children:(W==null?void 0:W.title)||We("moduleGrid.noData","No data")}),(W==null?void 0:W.description)&&e.jsx("div",{className:"nice-module-grid__empty-description",children:W.description}),(W==null?void 0:W.action)&&e.jsxs("button",{className:"nice-module-grid__empty-action",onClick:W.action.onClick,children:[W.action.icon,W.action.label]})]}):e.jsx("div",{style:Mn?{transform:`translateY(${it}px)`}:void 0,children:En.map((_,se)=>{const fe=String(wn(_,d)),Me=at+se,$e=fn.has(fe),He=typeof V=="function"?V(_,Me):V,_n=typeof Le=="function"?Le(_,Me):Le;return e.jsxs("div",{className:An("nice-module-grid__row",$e&&"nice-module-grid__row--selected",He),style:{..._n,height:Ae},role:"row","aria-rowindex":Me+1,"aria-selected":$e,onClick:()=>{me!=="none"&>(fe,_),ne==null||ne(_,Me)},onDoubleClick:()=>je==null?void 0:je(_,Me),onContextMenu:dn=>ft(dn,_),children:[me==="checkbox"&&e.jsx("div",{className:"nice-module-grid__cell nice-module-grid__cell--checkbox",children:e.jsx("input",{type:"checkbox",checked:$e,onChange:()=>gt(fe,_),onClick:dn=>dn.stopPropagation(),"aria-label":We("moduleGrid.selectRow","Select row")})}),Sn.map(dn=>e.jsx(oa,{column:{...dn,width:Fe[dn.field]||dn.width},row:_,rowIndex:Me,value:wn(_,dn.field)},dn.field))]},fe)})})})]})}),s&&tt>0&&e.jsx(ua,{page:gn,pageSize:sn,totalRows:zn?u:Tn.length,pageSizeOptions:I,onPageChange:St,t:We}),z&&ge&&e.jsx("div",{className:"nice-module-grid__context-menu",style:{left:z.x,top:z.y},role:"menu",children:ge.filter(_=>typeof _.hidden=="function"?!_.hidden(z.row):!_.hidden).map(_=>{if(_.divider)return e.jsx("div",{className:"nice-module-grid__context-menu-divider"},_.key);const se=typeof _.disabled=="function"?_.disabled(z.row):_.disabled;return e.jsxs("button",{className:An("nice-module-grid__context-menu-item",_.danger&&"nice-module-grid__context-menu-item--danger",se&&"nice-module-grid__context-menu-item--disabled"),onClick:()=>{var fe;se||((fe=_.onClick)==null||fe.call(_,z.row),Bt(_.key))},disabled:se,role:"menuitem",children:[_.icon&&e.jsx("span",{className:"nice-module-grid__context-menu-icon",children:_.icon}),_.label]},_.key)})}),Je&&!In&&e.jsx("div",{className:"nice-module-grid__loading-overlay",children:e.jsx("div",{className:"nice-module-grid__spinner","aria-label":We("moduleGrid.loading","Loading")})})]})}t.forwardRef(ha);const pa=`
|
|
17
|
+
.nice-reconciliation {
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
height: 100%;
|
|
21
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
22
|
+
border: 1px solid var(--nice-border-color, #e5e7eb);
|
|
23
|
+
border-radius: var(--nice-radius-lg, 0.5rem);
|
|
24
|
+
overflow: hidden;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.nice-reconciliation__toolbar {
|
|
28
|
+
display: flex;
|
|
29
|
+
align-items: center;
|
|
30
|
+
gap: 0.75rem;
|
|
31
|
+
padding: 0.75rem 1rem;
|
|
32
|
+
background: var(--nice-bg-secondary, #f9fafb);
|
|
33
|
+
border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
|
|
34
|
+
flex-wrap: wrap;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.nice-reconciliation__toolbar-group {
|
|
38
|
+
display: flex;
|
|
39
|
+
align-items: center;
|
|
40
|
+
gap: 0.5rem;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.nice-reconciliation__toolbar-group--end {
|
|
44
|
+
margin-inline-start: auto;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.nice-reconciliation__btn {
|
|
48
|
+
display: inline-flex;
|
|
49
|
+
align-items: center;
|
|
50
|
+
gap: 0.375rem;
|
|
51
|
+
padding: 0.375rem 0.75rem;
|
|
52
|
+
font-size: 0.8125rem;
|
|
53
|
+
font-weight: 500;
|
|
54
|
+
border-radius: var(--nice-radius-md, 0.375rem);
|
|
55
|
+
cursor: pointer;
|
|
56
|
+
transition: all 0.15s ease;
|
|
57
|
+
border: 1px solid var(--nice-border-color, #d1d5db);
|
|
58
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
59
|
+
color: var(--nice-text-primary);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.nice-reconciliation__btn:hover {
|
|
63
|
+
background: var(--nice-bg-hover, #f3f4f6);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.nice-reconciliation__btn--primary {
|
|
67
|
+
background: var(--nice-primary, #3b82f6);
|
|
68
|
+
border-color: var(--nice-primary, #3b82f6);
|
|
69
|
+
color: white;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.nice-reconciliation__btn--primary:hover {
|
|
73
|
+
background: var(--nice-primary-dark, #2563eb);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.nice-reconciliation__btn--success {
|
|
77
|
+
background: var(--nice-success, #10b981);
|
|
78
|
+
border-color: var(--nice-success, #10b981);
|
|
79
|
+
color: white;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.nice-reconciliation__btn:disabled {
|
|
83
|
+
opacity: 0.5;
|
|
84
|
+
cursor: not-allowed;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.nice-reconciliation__content {
|
|
88
|
+
display: flex;
|
|
89
|
+
flex: 1;
|
|
90
|
+
overflow: hidden;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.nice-reconciliation--vertical .nice-reconciliation__content {
|
|
94
|
+
flex-direction: column;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.nice-reconciliation__panel {
|
|
98
|
+
flex: 1;
|
|
99
|
+
display: flex;
|
|
100
|
+
flex-direction: column;
|
|
101
|
+
min-width: 0;
|
|
102
|
+
min-height: 0;
|
|
103
|
+
overflow: hidden;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.nice-reconciliation__panel--statements {
|
|
107
|
+
border-inline-end: 1px solid var(--nice-border-color, #e5e7eb);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.nice-reconciliation--vertical .nice-reconciliation__panel--statements {
|
|
111
|
+
border-inline-end: none;
|
|
112
|
+
border-block-end: 1px solid var(--nice-border-color, #e5e7eb);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.nice-reconciliation__panel-header {
|
|
116
|
+
display: flex;
|
|
117
|
+
align-items: center;
|
|
118
|
+
justify-content: space-between;
|
|
119
|
+
padding: 0.75rem 1rem;
|
|
120
|
+
background: var(--nice-bg-secondary, #f9fafb);
|
|
121
|
+
border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.nice-reconciliation__panel-title {
|
|
125
|
+
font-weight: 600;
|
|
126
|
+
font-size: 0.875rem;
|
|
127
|
+
color: var(--nice-text-primary);
|
|
128
|
+
display: flex;
|
|
129
|
+
align-items: center;
|
|
130
|
+
gap: 0.5rem;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.nice-reconciliation__panel-badge {
|
|
134
|
+
font-size: 0.75rem;
|
|
135
|
+
font-weight: 500;
|
|
136
|
+
padding: 0.125rem 0.5rem;
|
|
137
|
+
border-radius: var(--nice-radius-full, 9999px);
|
|
138
|
+
background: var(--nice-bg-tertiary, #e5e7eb);
|
|
139
|
+
color: var(--nice-text-secondary);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.nice-reconciliation__panel-content {
|
|
143
|
+
flex: 1;
|
|
144
|
+
overflow: auto;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.nice-reconciliation__row {
|
|
148
|
+
display: flex;
|
|
149
|
+
align-items: center;
|
|
150
|
+
gap: 0.75rem;
|
|
151
|
+
padding: 0.625rem 1rem;
|
|
152
|
+
border-bottom: 1px solid var(--nice-border-divider, #f3f4f6);
|
|
153
|
+
cursor: pointer;
|
|
154
|
+
user-select: none;
|
|
155
|
+
transition: background 0.1s ease;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.nice-reconciliation__row:hover {
|
|
159
|
+
background: var(--nice-bg-hover, rgba(0, 0, 0, 0.02));
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.nice-reconciliation__row--selected {
|
|
163
|
+
background: var(--nice-primary-light, rgba(59, 130, 246, 0.1));
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.nice-reconciliation__row--dragging {
|
|
167
|
+
opacity: 0.6;
|
|
168
|
+
background: var(--nice-primary-light, rgba(59, 130, 246, 0.15));
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.nice-reconciliation__row--drop-target {
|
|
172
|
+
background: var(--nice-success-light, rgba(16, 185, 129, 0.15));
|
|
173
|
+
box-shadow: inset 0 0 0 2px var(--nice-success, #10b981);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.nice-reconciliation__row--matched {
|
|
177
|
+
background: var(--nice-success-light, rgba(16, 185, 129, 0.08));
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.nice-reconciliation__row--partial {
|
|
181
|
+
background: var(--nice-warning-light, rgba(245, 158, 11, 0.08));
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.nice-reconciliation__row--unmatched {
|
|
185
|
+
background: transparent;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.nice-reconciliation__row--excluded {
|
|
189
|
+
opacity: 0.5;
|
|
190
|
+
background: var(--nice-bg-disabled, #f3f4f6);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.nice-reconciliation__status {
|
|
194
|
+
width: 0.5rem;
|
|
195
|
+
height: 0.5rem;
|
|
196
|
+
border-radius: var(--nice-radius-full, 50%);
|
|
197
|
+
flex-shrink: 0;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.nice-reconciliation__status--matched {
|
|
201
|
+
background: var(--nice-success, #10b981);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.nice-reconciliation__status--partial {
|
|
205
|
+
background: var(--nice-warning, #f59e0b);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.nice-reconciliation__status--unmatched {
|
|
209
|
+
background: var(--nice-danger, #ef4444);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.nice-reconciliation__status--excluded {
|
|
213
|
+
background: var(--nice-text-disabled, #9ca3af);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.nice-reconciliation__row-main {
|
|
217
|
+
flex: 1;
|
|
218
|
+
min-width: 0;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.nice-reconciliation__row-date {
|
|
222
|
+
font-size: 0.75rem;
|
|
223
|
+
color: var(--nice-text-secondary);
|
|
224
|
+
margin-bottom: 0.125rem;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
.nice-reconciliation__row-description {
|
|
228
|
+
font-size: 0.8125rem;
|
|
229
|
+
color: var(--nice-text-primary);
|
|
230
|
+
white-space: nowrap;
|
|
231
|
+
overflow: hidden;
|
|
232
|
+
text-overflow: ellipsis;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.nice-reconciliation__row-counterparty {
|
|
236
|
+
font-size: 0.75rem;
|
|
237
|
+
color: var(--nice-text-tertiary);
|
|
238
|
+
white-space: nowrap;
|
|
239
|
+
overflow: hidden;
|
|
240
|
+
text-overflow: ellipsis;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.nice-reconciliation__row-amount {
|
|
244
|
+
font-size: 0.875rem;
|
|
245
|
+
font-weight: 600;
|
|
246
|
+
font-variant-numeric: tabular-nums;
|
|
247
|
+
white-space: nowrap;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.nice-reconciliation__row-amount--positive {
|
|
251
|
+
color: var(--nice-success, #10b981);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
.nice-reconciliation__row-amount--negative {
|
|
255
|
+
color: var(--nice-danger, #ef4444);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.nice-reconciliation__confidence {
|
|
259
|
+
display: flex;
|
|
260
|
+
align-items: center;
|
|
261
|
+
gap: 0.25rem;
|
|
262
|
+
font-size: 0.6875rem;
|
|
263
|
+
padding: 0.125rem 0.375rem;
|
|
264
|
+
border-radius: var(--nice-radius-sm, 0.25rem);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
.nice-reconciliation__confidence--high {
|
|
268
|
+
background: var(--nice-success-light, rgba(16, 185, 129, 0.15));
|
|
269
|
+
color: var(--nice-success-dark, #059669);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.nice-reconciliation__confidence--medium {
|
|
273
|
+
background: var(--nice-warning-light, rgba(245, 158, 11, 0.15));
|
|
274
|
+
color: var(--nice-warning-dark, #d97706);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.nice-reconciliation__confidence--low {
|
|
278
|
+
background: var(--nice-danger-light, rgba(239, 68, 68, 0.15));
|
|
279
|
+
color: var(--nice-danger-dark, #dc2626);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
.nice-reconciliation__empty {
|
|
283
|
+
display: flex;
|
|
284
|
+
flex-direction: column;
|
|
285
|
+
align-items: center;
|
|
286
|
+
justify-content: center;
|
|
287
|
+
padding: 3rem 1rem;
|
|
288
|
+
color: var(--nice-text-secondary);
|
|
289
|
+
text-align: center;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
.nice-reconciliation__empty-icon {
|
|
293
|
+
font-size: 2.5rem;
|
|
294
|
+
margin-bottom: 0.75rem;
|
|
295
|
+
opacity: 0.5;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.nice-reconciliation__summary {
|
|
299
|
+
display: flex;
|
|
300
|
+
align-items: center;
|
|
301
|
+
gap: 1.5rem;
|
|
302
|
+
padding: 0.75rem 1rem;
|
|
303
|
+
background: var(--nice-bg-secondary, #f9fafb);
|
|
304
|
+
border-top: 1px solid var(--nice-border-color, #e5e7eb);
|
|
305
|
+
font-size: 0.8125rem;
|
|
306
|
+
flex-wrap: wrap;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
.nice-reconciliation__summary-item {
|
|
310
|
+
display: flex;
|
|
311
|
+
align-items: center;
|
|
312
|
+
gap: 0.375rem;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
.nice-reconciliation__summary-label {
|
|
316
|
+
color: var(--nice-text-secondary);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
.nice-reconciliation__summary-value {
|
|
320
|
+
font-weight: 600;
|
|
321
|
+
color: var(--nice-text-primary);
|
|
322
|
+
font-variant-numeric: tabular-nums;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
.nice-reconciliation__summary-value--success {
|
|
326
|
+
color: var(--nice-success, #10b981);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
.nice-reconciliation__summary-value--warning {
|
|
330
|
+
color: var(--nice-warning, #f59e0b);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
.nice-reconciliation__summary-value--danger {
|
|
334
|
+
color: var(--nice-danger, #ef4444);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
.nice-reconciliation__resizer {
|
|
338
|
+
width: 4px;
|
|
339
|
+
background: var(--nice-border-color, #e5e7eb);
|
|
340
|
+
cursor: col-resize;
|
|
341
|
+
transition: background 0.15s ease;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
.nice-reconciliation__resizer:hover {
|
|
345
|
+
background: var(--nice-primary, #3b82f6);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
.nice-reconciliation--vertical .nice-reconciliation__resizer {
|
|
349
|
+
width: 100%;
|
|
350
|
+
height: 4px;
|
|
351
|
+
cursor: row-resize;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
.nice-reconciliation__suggestions {
|
|
355
|
+
padding: 0.75rem 1rem;
|
|
356
|
+
background: var(--nice-info-light, rgba(59, 130, 246, 0.08));
|
|
357
|
+
border-bottom: 1px solid var(--nice-info, #3b82f6);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
.nice-reconciliation__suggestion {
|
|
361
|
+
display: flex;
|
|
362
|
+
align-items: center;
|
|
363
|
+
gap: 0.75rem;
|
|
364
|
+
padding: 0.5rem;
|
|
365
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
366
|
+
border-radius: var(--nice-radius-md, 0.375rem);
|
|
367
|
+
margin-bottom: 0.5rem;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
.nice-reconciliation__suggestion:last-child {
|
|
371
|
+
margin-bottom: 0;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/* Dark mode */
|
|
375
|
+
.dark .nice-reconciliation {
|
|
376
|
+
background: var(--nice-bg-primary-dark, #111827);
|
|
377
|
+
border-color: var(--nice-border-color-dark, #374151);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
.dark .nice-reconciliation__toolbar,
|
|
381
|
+
.dark .nice-reconciliation__panel-header,
|
|
382
|
+
.dark .nice-reconciliation__summary {
|
|
383
|
+
background: var(--nice-bg-secondary-dark, #1f2937);
|
|
384
|
+
border-color: var(--nice-border-color-dark, #374151);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
.dark .nice-reconciliation__row--selected {
|
|
388
|
+
background: var(--nice-primary-tint-20, rgba(59, 130, 246, 0.2));
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/* RTL support */
|
|
392
|
+
[dir="rtl"] .nice-reconciliation__row-amount {
|
|
393
|
+
direction: ltr;
|
|
394
|
+
text-align: left;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/* Detail Panel */
|
|
398
|
+
.nice-reconciliation__detail-panel {
|
|
399
|
+
position: fixed;
|
|
400
|
+
inset-inline-end: 0;
|
|
401
|
+
top: 0;
|
|
402
|
+
bottom: 0;
|
|
403
|
+
width: 420px;
|
|
404
|
+
max-width: 90vw;
|
|
405
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
406
|
+
box-shadow: -4px 0 24px var(--nice-overlay-15, rgba(0, 0, 0, 0.15));
|
|
407
|
+
z-index: 1000;
|
|
408
|
+
display: flex;
|
|
409
|
+
flex-direction: column;
|
|
410
|
+
transform: translateX(100%);
|
|
411
|
+
transition: transform 0.25s ease-out;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
.nice-reconciliation__detail-panel--open {
|
|
415
|
+
transform: translateX(0);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
.nice-reconciliation__detail-header {
|
|
419
|
+
display: flex;
|
|
420
|
+
align-items: center;
|
|
421
|
+
justify-content: space-between;
|
|
422
|
+
padding: 1rem;
|
|
423
|
+
border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
|
|
424
|
+
background: var(--nice-bg-secondary, #f9fafb);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
.nice-reconciliation__detail-title {
|
|
428
|
+
font-weight: 600;
|
|
429
|
+
font-size: 1rem;
|
|
430
|
+
color: var(--nice-text-primary);
|
|
431
|
+
display: flex;
|
|
432
|
+
align-items: center;
|
|
433
|
+
gap: 0.5rem;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
.nice-reconciliation__detail-close {
|
|
437
|
+
width: 2rem;
|
|
438
|
+
height: 2rem;
|
|
439
|
+
display: flex;
|
|
440
|
+
align-items: center;
|
|
441
|
+
justify-content: center;
|
|
442
|
+
background: transparent;
|
|
443
|
+
border: none;
|
|
444
|
+
cursor: pointer;
|
|
445
|
+
font-size: 1.25rem;
|
|
446
|
+
color: var(--nice-text-secondary);
|
|
447
|
+
border-radius: var(--nice-radius-md, 0.375rem);
|
|
448
|
+
transition: all 0.15s ease;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
.nice-reconciliation__detail-close:hover {
|
|
452
|
+
background: var(--nice-bg-hover, #f3f4f6);
|
|
453
|
+
color: var(--nice-text-primary);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
.nice-reconciliation__detail-content {
|
|
457
|
+
flex: 1;
|
|
458
|
+
overflow: auto;
|
|
459
|
+
padding: 1rem;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
.nice-reconciliation__detail-section {
|
|
463
|
+
margin-bottom: 1.5rem;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
.nice-reconciliation__detail-section-title {
|
|
467
|
+
font-weight: 600;
|
|
468
|
+
font-size: 0.875rem;
|
|
469
|
+
color: var(--nice-text-primary);
|
|
470
|
+
margin-bottom: 0.75rem;
|
|
471
|
+
display: flex;
|
|
472
|
+
align-items: center;
|
|
473
|
+
gap: 0.375rem;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
.nice-reconciliation__detail-row {
|
|
477
|
+
display: flex;
|
|
478
|
+
justify-content: space-between;
|
|
479
|
+
align-items: flex-start;
|
|
480
|
+
padding: 0.5rem 0;
|
|
481
|
+
border-bottom: 1px solid var(--nice-border-divider, #f3f4f6);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
.nice-reconciliation__detail-row:last-child {
|
|
485
|
+
border-bottom: none;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
.nice-reconciliation__detail-label {
|
|
489
|
+
font-size: 0.8125rem;
|
|
490
|
+
color: var(--nice-text-secondary);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
.nice-reconciliation__detail-value {
|
|
494
|
+
font-size: 0.8125rem;
|
|
495
|
+
font-weight: 500;
|
|
496
|
+
color: var(--nice-text-primary);
|
|
497
|
+
text-align: end;
|
|
498
|
+
max-width: 60%;
|
|
499
|
+
word-break: break-word;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
.nice-reconciliation__detail-divider {
|
|
503
|
+
height: 1px;
|
|
504
|
+
background: var(--nice-border-color, #e5e7eb);
|
|
505
|
+
margin: 1rem 0;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
.nice-reconciliation__detail-match-info {
|
|
509
|
+
padding: 0.75rem;
|
|
510
|
+
background: var(--nice-success-light, rgba(16, 185, 129, 0.08));
|
|
511
|
+
border-radius: var(--nice-radius-md, 0.375rem);
|
|
512
|
+
margin-bottom: 1rem;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
.nice-reconciliation__detail-match-header {
|
|
516
|
+
display: flex;
|
|
517
|
+
align-items: center;
|
|
518
|
+
gap: 0.5rem;
|
|
519
|
+
font-weight: 600;
|
|
520
|
+
font-size: 0.8125rem;
|
|
521
|
+
color: var(--nice-success-dark, #059669);
|
|
522
|
+
margin-bottom: 0.5rem;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
.nice-reconciliation__detail-match-detail {
|
|
526
|
+
font-size: 0.75rem;
|
|
527
|
+
color: var(--nice-text-secondary);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
.nice-reconciliation__detail-side-by-side {
|
|
531
|
+
display: grid;
|
|
532
|
+
grid-template-columns: 1fr 1fr;
|
|
533
|
+
gap: 1rem;
|
|
534
|
+
padding: 0.75rem;
|
|
535
|
+
background: var(--nice-bg-secondary, #f9fafb);
|
|
536
|
+
border-radius: var(--nice-radius-md, 0.375rem);
|
|
537
|
+
margin-top: 0.75rem;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
.nice-reconciliation__detail-side-item {
|
|
541
|
+
padding: 0.5rem;
|
|
542
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
543
|
+
border-radius: var(--nice-radius-sm, 0.25rem);
|
|
544
|
+
border: 1px solid var(--nice-border-color, #e5e7eb);
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
.nice-reconciliation__detail-side-label {
|
|
548
|
+
font-size: 0.6875rem;
|
|
549
|
+
font-weight: 500;
|
|
550
|
+
text-transform: uppercase;
|
|
551
|
+
color: var(--nice-text-tertiary);
|
|
552
|
+
margin-bottom: 0.375rem;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
.nice-reconciliation__detail-side-amount {
|
|
556
|
+
font-size: 1.125rem;
|
|
557
|
+
font-weight: 600;
|
|
558
|
+
font-variant-numeric: tabular-nums;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
.nice-reconciliation__detail-backdrop {
|
|
562
|
+
position: fixed;
|
|
563
|
+
inset: 0;
|
|
564
|
+
background: var(--nice-overlay-30, rgba(0, 0, 0, 0.3));
|
|
565
|
+
z-index: 999;
|
|
566
|
+
opacity: 0;
|
|
567
|
+
pointer-events: none;
|
|
568
|
+
transition: opacity 0.2s ease;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
.nice-reconciliation__detail-backdrop--visible {
|
|
572
|
+
opacity: 1;
|
|
573
|
+
pointer-events: auto;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
.dark .nice-reconciliation__detail-panel {
|
|
577
|
+
background: var(--nice-bg-primary-dark, #111827);
|
|
578
|
+
box-shadow: -4px 0 24px var(--nice-overlay-40, rgba(0, 0, 0, 0.4));
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
.dark .nice-reconciliation__detail-header {
|
|
582
|
+
background: var(--nice-bg-secondary-dark, #1f2937);
|
|
583
|
+
border-color: var(--nice-border-color-dark, #374151);
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
.dark .nice-reconciliation__detail-side-by-side {
|
|
587
|
+
background: var(--nice-bg-secondary-dark, #1f2937);
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
.dark .nice-reconciliation__detail-side-item {
|
|
591
|
+
background: var(--nice-bg-primary-dark, #111827);
|
|
592
|
+
border-color: var(--nice-border-color-dark, #374151);
|
|
593
|
+
}
|
|
594
|
+
`;function $n(n,a="PLN",r="pl-PL"){return new Intl.NumberFormat(r,{style:"currency",currency:a,minimumFractionDigits:2,maximumFractionDigits:2}).format(n)}function kt(n,a="pl-PL"){return n?(typeof n=="string"?new Date(n):n).toLocaleDateString(a,{year:"numeric",month:"2-digit",day:"2-digit"}):"-"}function ga(n){return n>=80?"high":n>=50?"medium":"low"}function fa(){return`match-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function xa({item:n,isSelected:a,isDragging:r,isDropTarget:l,suggestion:d,currency:m,locale:f,onSelect:o,onDoubleClick:g,onDragStart:N,onDragEnd:S,onDrop:K,disabled:A}){const R=n.status??"unmatched",P=(d==null?void 0:d.confidence)??n.confidence,G=s=>{s.dataTransfer.setData("text/plain",n.id),s.dataTransfer.setData("source","statement"),s.dataTransfer.effectAllowed="move",N()},y=s=>{s.dataTransfer.types.includes("source")&&s.dataTransfer.getData("source")!=="statement"&&s.preventDefault()};return e.jsxs("div",{className:`nice-reconciliation__row nice-reconciliation__row--${R} ${a?"nice-reconciliation__row--selected":""} ${r?"nice-reconciliation__row--dragging":""} ${l?"nice-reconciliation__row--drop-target":""}`,draggable:!A&&R!=="matched",onDragStart:G,onDragEnd:S,onDragOver:y,onDrop:K,onClick:o,onDoubleClick:g,role:"row","aria-selected":a,tabIndex:0,children:[e.jsx("span",{className:`nice-reconciliation__status nice-reconciliation__status--${R}`}),e.jsxs("div",{className:"nice-reconciliation__row-main",children:[e.jsx("div",{className:"nice-reconciliation__row-date",children:kt(n.date,f)}),e.jsx("div",{className:"nice-reconciliation__row-description",title:n.description,children:n.description}),n.counterparty&&e.jsx("div",{className:"nice-reconciliation__row-counterparty",children:n.counterparty})]}),P!=null&&e.jsxs("span",{className:`nice-reconciliation__confidence nice-reconciliation__confidence--${ga(P)}`,children:[P,"%"]}),e.jsx("span",{className:`nice-reconciliation__row-amount ${n.amount>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:$n(n.amount,m,f)})]})}function ba({item:n,isSelected:a,isDragging:r,isDropTarget:l,currency:d,locale:m,onSelect:f,onDoubleClick:o,onDragStart:g,onDragEnd:N,onDrop:S,disabled:K}){const A=n.status??"unmatched",R=G=>{G.dataTransfer.setData("text/plain",n.id),G.dataTransfer.setData("source","entry"),G.dataTransfer.effectAllowed="move",g()},P=G=>{G.dataTransfer.types.includes("source")&&G.dataTransfer.getData("source")!=="entry"&&G.preventDefault()};return e.jsxs("div",{className:`nice-reconciliation__row nice-reconciliation__row--${A} ${a?"nice-reconciliation__row--selected":""} ${r?"nice-reconciliation__row--dragging":""} ${l?"nice-reconciliation__row--drop-target":""}`,draggable:!K&&A!=="matched",onDragStart:R,onDragEnd:N,onDragOver:P,onDrop:S,onClick:f,onDoubleClick:o,role:"row","aria-selected":a,tabIndex:0,children:[e.jsx("span",{className:`nice-reconciliation__status nice-reconciliation__status--${A}`}),e.jsxs("div",{className:"nice-reconciliation__row-main",children:[e.jsxs("div",{className:"nice-reconciliation__row-date",children:[kt(n.date,m),n.documentNumber&&e.jsxs("span",{children:[" · ",n.documentNumber]})]}),e.jsx("div",{className:"nice-reconciliation__row-description",title:n.description,children:n.description}),n.partyName&&e.jsx("div",{className:"nice-reconciliation__row-counterparty",children:n.partyName})]}),e.jsx("span",{className:`nice-reconciliation__row-amount ${n.amount>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:$n(n.amount,d,m)})]})}t.forwardRef(function(n,a){const{statements:r,bankTransactions:l,entries:d,accountingEntries:m,matches:f,defaultMatches:o=[],suggestions:g=[],config:N={},currency:S,showConfidence:K,statementPanelConfig:A,entryPanelConfig:R,onMatch:P,onAutoMatch:G,onUnmatch:y,onBatchAction:s,onFilterChange:w,onRequestSuggestions:c,onSelectionChange:I,onComplete:F,size:te="medium",showToolbar:ue=!0,showFilters:Ae=!0,showSummary:D=!0,showSuggestions:me=!0,layout:be="horizontal",enableDragDrop:xe=!0,enableKeyboard:ee=!0,enableDetailPanel:ae=!0,loading:M=!1,disabled:E=!1,readOnly:b=!1,locale:we="pl-PL",labels:le={},className:O,style:U}=n,Q=r??l??[],H=d??m??[],_e=S??N.currency??"PLN",[ge,Te]=t.useState(o),[Xe,nn]=t.useState(new Set),[De,tn]=t.useState(new Set),[Ee,Be]=t.useState(null),[X,ye]=t.useState(null),[Ie,L]=t.useState({}),[oe,W]=t.useState(null),T=f??ge,ne=t.useRef(null),je=t.useRef(null);t.useEffect(()=>{const $="nice-reconciliation-styles";if(!document.getElementById($)){const de=document.createElement("style");de.id=$,de.textContent=pa,document.head.appendChild(de)}},[]);const V=t.useMemo(()=>{const $=new Set;return T.forEach(de=>de.statementIds.forEach(pe=>$.add(pe))),$},[T]),Le=t.useMemo(()=>{const $=new Set;return T.forEach(de=>de.entryIds.forEach(pe=>$.add(pe))),$},[T]),Se=t.useMemo(()=>{const $=Q.filter(Ce=>!V.has(Ce.id)),de=H.filter(Ce=>!Le.has(Ce.id)),pe=Q.reduce((Ce,Ke)=>Ce+Ke.amount,0),ke=H.reduce((Ce,Ke)=>Ce+Ke.amount,0),un=Q.filter(Ce=>V.has(Ce.id)).reduce((Ce,Ke)=>Ce+Ke.amount,0);return{totalStatements:Q.length,totalEntries:H.length,matchedStatements:Q.length-$.length,matchedEntries:H.length-de.length,unmatchedStatements:$.length,unmatchedEntries:de.length,statementTotal:pe,entryTotal:ke,matchedAmount:un,unmatchedStatementAmount:$.reduce((Ce,Ke)=>Ce+Ke.amount,0),unmatchedEntryAmount:de.reduce((Ce,Ke)=>Ce+Ke.amount,0),difference:pe-ke,matchPercentage:Q.length>0?Math.round((Q.length-$.length)/Q.length*100):0,matchCount:T.length,partialMatchCount:T.filter(Ce=>Ce.status==="partial").length,pendingSuggestions:g.length}},[Q,H,T,g,V,Le]),he=t.useCallback(($,de)=>{const pe=Q.filter(an=>$.includes(an.id)),ke=H.filter(an=>de.includes(an.id));if(pe.length===0||ke.length===0)return null;const un=pe.reduce((an,Cn)=>an+Cn.amount,0),Ce=ke.reduce((an,Cn)=>an+Cn.amount,0),Ke=Math.abs(un-Ce),mn=N.amountTolerance??.01,We={id:fa(),statementIds:$,entryIds:de,status:Ke<=mn?"matched":"partial",statementTotal:un,entryTotal:Ce,difference:Ke,confidence:Ke<=mn?100:Math.max(0,100-Ke/Math.max(Math.abs(un),1)*100),matchedBy:"user",matchedAt:new Date};return f||Te(an=>[...an,We]),P==null||P(We,pe,ke),nn(new Set),tn(new Set),We},[Q,H,N.amountTolerance,f,P]),Qe=t.useCallback($=>{const de=T.find(pe=>pe.id===$);de&&(f||Te(pe=>pe.filter(ke=>ke.id!==$)),y==null||y($,de.statementIds,de.entryIds))},[T,f,y]),pn=t.useCallback(async()=>{const $=[],de=new Set(V),pe=new Set(Le),ke=N.amountTolerance??.01,un=N.dateTolerance??3;for(const Ce of Q){if(de.has(Ce.id))continue;const Ke=H.filter(mn=>{if(pe.has(mn.id)||Math.abs(Ce.amount-mn.amount)>ke)return!1;const We=new Date(Ce.date),an=new Date(mn.date);return!(Math.abs(We.getTime()-an.getTime())/(1e3*60*60*24)>un)});if(Ke.length===1){const mn=Ke[0],We=he([Ce.id],[mn.id]);We&&($.push(We),de.add(Ce.id),pe.add(mn.id))}}return s==null||s("autoMatch",$),$},[Q,H,V,Le,N,he,s]),ve=t.useCallback(($,de,pe,ke)=>{ke!==de&&(ke==="statement"?he([pe],[$]):he([$],[pe]),Be(null),ye(null))},[he]),kn=t.useCallback(()=>{const $=Array.from(Xe),de=Array.from(De);$.length>0&&de.length>0&&he($,de)},[Xe,De,he]);t.useEffect(()=>{I==null||I(Array.from(Xe),Array.from(De))},[Xe,De,I]),t.useImperativeHandle(a,()=>({getMatches:()=>T,getUnmatchedStatements:()=>Q.filter($=>!V.has($.id)),getUnmatchedEntries:()=>H.filter($=>!Le.has($.id)),createMatch:he,removeMatch:Qe,autoMatch:pn,getSuggestions:async $=>c?c($??Q.filter(de=>!V.has(de.id)).map(de=>de.id)):[],applySuggestion:$=>he([$.statementId],$.entryIds),approveAll:()=>{s==null||s("approveAll",T)},clearAll:()=>{f||Te([]),s==null||s("clearAll",[])},exportMatched:$=>{s==null||s("exportMatched",T)},getSummary:()=>Se,reset:()=>{f||Te([]),nn(new Set),tn(new Set),L({})},focusStatements:()=>{var $;return($=ne.current)==null?void 0:$.focus()},focusEntries:()=>{var $;return($=je.current)==null?void 0:$.focus()}}),[T,Q,H,V,Le,he,Qe,pn,c,s,f,Se]);const Nn=t.useMemo(()=>Q.filter($=>{var de,pe;if(Ie.status&&Ie.status.length>0){const ke=V.has($.id)?"matched":"unmatched";if(!Ie.status.includes(ke))return!1}if(Ie.searchText){const ke=Ie.searchText.toLowerCase();if(!((de=$.description)!=null&&de.toLowerCase().includes(ke))&&!((pe=$.counterparty)!=null&&pe.toLowerCase().includes(ke)))return!1}return!0}),[Q,Ie,V]),Ve=t.useMemo(()=>H.filter($=>{var de,pe;if(Ie.status&&Ie.status.length>0){const ke=Le.has($.id)?"matched":"unmatched";if(!Ie.status.includes(ke))return!1}if(Ie.searchText){const ke=Ie.searchText.toLowerCase();if(!((de=$.description)!=null&&de.toLowerCase().includes(ke))&&!((pe=$.partyName)!=null&&pe.toLowerCase().includes(ke)))return!1}return!0}),[H,Ie,Le]),In=Xe.size>0&&De.size>0&&!b&&!E;return e.jsxs("div",{className:`nice-reconciliation nice-reconciliation--${be} ${O??""}`,style:U,children:[ue&&e.jsxs("div",{className:"nice-reconciliation__toolbar",children:[e.jsxs("div",{className:"nice-reconciliation__toolbar-group",children:[e.jsxs("button",{type:"button",className:"nice-reconciliation__btn nice-reconciliation__btn--primary",onClick:pn,disabled:E||b||M,children:["⚡ ",le.autoMatch??"Auto-match"]}),e.jsx("button",{type:"button",className:"nice-reconciliation__btn nice-reconciliation__btn--success",onClick:kn,disabled:!In||M,children:"🔗 Match Selected"})]}),e.jsxs("div",{className:"nice-reconciliation__toolbar-group nice-reconciliation__toolbar-group--end",children:[e.jsxs("button",{type:"button",className:"nice-reconciliation__btn",onClick:()=>s==null?void 0:s("approveAll",T),disabled:T.length===0||E||M,children:["✓ ",le.approveAll??"Approve All"]}),e.jsxs("button",{type:"button",className:"nice-reconciliation__btn",onClick:()=>{f||Te([]),s==null||s("clearAll",[])},disabled:T.length===0||E||b||M,children:["✕ ",le.clearAll??"Clear All"]})]})]}),e.jsxs("div",{className:"nice-reconciliation__content",children:[e.jsxs("div",{className:"nice-reconciliation__panel nice-reconciliation__panel--statements",children:[e.jsx("div",{className:"nice-reconciliation__panel-header",children:e.jsxs("span",{className:"nice-reconciliation__panel-title",children:["📄 ",le.statementPanelTitle??"Bank Statement",e.jsx("span",{className:"nice-reconciliation__panel-badge",children:Nn.length})]})}),e.jsx("div",{ref:ne,className:"nice-reconciliation__panel-content",role:"listbox","aria-multiselectable":"true",children:Nn.length===0?e.jsxs("div",{className:"nice-reconciliation__empty",children:[e.jsx("div",{className:"nice-reconciliation__empty-icon",children:"📋"}),le.noStatements??"No statement items"]}):Nn.map($=>e.jsx(xa,{item:{...$,status:V.has($.id)?"matched":"unmatched"},isSelected:Xe.has($.id),isDragging:Ee===$.id,isDropTarget:X===$.id,suggestion:g.find(de=>de.statementId===$.id),currency:_e,locale:we,onSelect:()=>{E||nn(de=>{const pe=new Set(de);return pe.has($.id)?pe.delete($.id):pe.add($.id),pe})},onDoubleClick:()=>ae&&W({type:"statement",id:$.id}),onDragStart:()=>Be($.id),onDragEnd:()=>{Be(null),ye(null)},onDrop:()=>{Ee&&Ee!==$.id&&ve($.id,"statement",Ee,"entry")},disabled:E||b||!xe},$.id))})]}),e.jsxs("div",{className:"nice-reconciliation__panel nice-reconciliation__panel--entries",children:[e.jsx("div",{className:"nice-reconciliation__panel-header",children:e.jsxs("span",{className:"nice-reconciliation__panel-title",children:["📒 ",le.entryPanelTitle??"Book Entries",e.jsx("span",{className:"nice-reconciliation__panel-badge",children:Ve.length})]})}),e.jsx("div",{ref:je,className:"nice-reconciliation__panel-content",role:"listbox","aria-multiselectable":"true",children:Ve.length===0?e.jsxs("div",{className:"nice-reconciliation__empty",children:[e.jsx("div",{className:"nice-reconciliation__empty-icon",children:"📚"}),le.noEntries??"No book entries"]}):Ve.map($=>e.jsx(ba,{item:{...$,status:Le.has($.id)?"matched":"unmatched"},isSelected:De.has($.id),isDragging:Ee===$.id,isDropTarget:X===$.id,currency:_e,locale:we,onSelect:()=>{E||tn(de=>{const pe=new Set(de);return pe.has($.id)?pe.delete($.id):pe.add($.id),pe})},onDoubleClick:()=>ae&&W({type:"entry",id:$.id}),onDragStart:()=>Be($.id),onDragEnd:()=>{Be(null),ye(null)},onDrop:()=>{Ee&&Ee!==$.id&&ve($.id,"entry",Ee,"statement")},disabled:E||b||!xe},$.id))})]})]}),D&&e.jsxs("div",{className:"nice-reconciliation__summary",children:[e.jsxs("div",{className:"nice-reconciliation__summary-item",children:[e.jsx("span",{className:"nice-reconciliation__summary-label",children:"Matched:"}),e.jsxs("span",{className:"nice-reconciliation__summary-value nice-reconciliation__summary-value--success",children:[Se.matchedStatements,"/",Se.totalStatements," (",Se.matchPercentage,"%)"]})]}),e.jsxs("div",{className:"nice-reconciliation__summary-item",children:[e.jsx("span",{className:"nice-reconciliation__summary-label",children:"Matched Amount:"}),e.jsx("span",{className:"nice-reconciliation__summary-value",children:$n(Se.matchedAmount,_e,we)})]}),e.jsxs("div",{className:"nice-reconciliation__summary-item",children:[e.jsx("span",{className:"nice-reconciliation__summary-label",children:"Unmatched:"}),e.jsx("span",{className:"nice-reconciliation__summary-value nice-reconciliation__summary-value--warning",children:$n(Se.unmatchedStatementAmount,_e,we)})]}),e.jsxs("div",{className:"nice-reconciliation__summary-item",children:[e.jsx("span",{className:"nice-reconciliation__summary-label",children:"Difference:"}),e.jsx("span",{className:`nice-reconciliation__summary-value ${Math.abs(Se.difference)<.01?"nice-reconciliation__summary-value--success":"nice-reconciliation__summary-value--danger"}`,children:$n(Se.difference,_e,we)})]})]}),ae&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`nice-reconciliation__detail-backdrop ${oe?"nice-reconciliation__detail-backdrop--visible":""}`,onClick:()=>W(null)}),e.jsx("div",{className:`nice-reconciliation__detail-panel ${oe?"nice-reconciliation__detail-panel--open":""}`,children:oe&&e.jsx(_a,{type:oe.type,id:oe.id,statements:Q,entries:H,matches:T,currency:_e,locale:we,labels:le,onClose:()=>W(null)})})]})]})});function _a({type:n,id:a,statements:r,entries:l,matches:d,currency:m,locale:f,labels:o,onClose:g}){var G;const N=n==="statement"?r.find(y=>y.id===a):l.find(y=>y.id===a),S=n==="statement"?d.find(y=>y.statementIds.includes(a)):d.find(y=>y.entryIds.includes(a)),K=S?n==="statement"?l.filter(y=>S.entryIds.includes(y.id)):r.filter(y=>S.statementIds.includes(y.id)):[];if(!N)return null;const A=n==="statement",R=A?N:null,P=A?null:N;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-reconciliation__detail-header",children:[e.jsxs("span",{className:"nice-reconciliation__detail-title",children:[A?"📄":"📒"," ",A?o.statementDetails??"Transaction Details":o.entryDetails??"Entry Details"]}),e.jsx("button",{type:"button",className:"nice-reconciliation__detail-close",onClick:g,"aria-label":"Close",children:"✕"})]}),e.jsxs("div",{className:"nice-reconciliation__detail-content",children:[S&&e.jsxs("div",{className:"nice-reconciliation__detail-match-info",children:[e.jsxs("div",{className:"nice-reconciliation__detail-match-header",children:["✓ ",o.matchedWith??"Matched"," (",((G=S.confidence)==null?void 0:G.toFixed(0))??100,"% confidence)"]}),e.jsx("div",{className:"nice-reconciliation__detail-match-detail",children:S.matchedBy==="ai"?o.matchedByAI??"Matched automatically by AI":o.matchedManually??"Matched manually"}),e.jsxs("div",{className:"nice-reconciliation__detail-side-by-side",children:[e.jsxs("div",{className:"nice-reconciliation__detail-side-item",children:[e.jsx("div",{className:"nice-reconciliation__detail-side-label",children:o.statementTotal??"Statement"}),e.jsx("div",{className:`nice-reconciliation__detail-side-amount ${S.statementTotal>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:$n(S.statementTotal,m,f)})]}),e.jsxs("div",{className:"nice-reconciliation__detail-side-item",children:[e.jsx("div",{className:"nice-reconciliation__detail-side-label",children:o.entryTotal??"Book Entry"}),e.jsx("div",{className:`nice-reconciliation__detail-side-amount ${S.entryTotal>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:$n(S.entryTotal,m,f)})]})]}),S.difference>.01&&e.jsxs("div",{className:"nice-reconciliation__detail-row",style:{marginTop:"0.5rem",borderBottom:"none"},children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[o.difference??"Difference",":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",style:{color:"var(--nice-warning, #f59e0b)"},children:$n(S.difference,m,f)})]})]}),e.jsxs("div",{className:"nice-reconciliation__detail-section",children:[e.jsxs("div",{className:"nice-reconciliation__detail-section-title",children:["📋"," ",A?o.transactionInfo??"Transaction Information":o.entryInfo??"Entry Information"]}),e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[o.date??"Date",":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",children:kt(N.date,f)})]}),e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[o.description??"Description",":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",children:N.description})]}),e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[o.amount??"Amount",":"]}),e.jsx("span",{className:`nice-reconciliation__detail-value ${N.amount>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:$n(N.amount,m,f)})]}),A&&(R==null?void 0:R.counterparty)&&e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[o.counterparty??"Counterparty",":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",children:R.counterparty})]}),A&&(R==null?void 0:R.counterpartyAccount)&&e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[o.accountNumber??"Account",":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",style:{fontFamily:"monospace",fontSize:"0.75rem"},children:R.counterpartyAccount})]}),!A&&(P==null?void 0:P.partyName)&&e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[o.party??"Party",":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",children:P.partyName})]}),!A&&(P==null?void 0:P.documentNumber)&&e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[o.documentRef??"Document Ref",":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",children:P.documentNumber})]}),A&&(R==null?void 0:R.referenceNumber)&&e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[o.reference??"Reference",":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",children:R.referenceNumber})]})]}),K.length>0&&e.jsxs("div",{className:"nice-reconciliation__detail-section",children:[e.jsxs("div",{className:"nice-reconciliation__detail-section-title",children:["🔗"," ",A?o.matchedEntries??"Matched Entries":o.matchedStatements??"Matched Statements"]}),K.map(y=>e.jsxs("div",{style:{padding:"0.5rem",background:"var(--nice-bg-secondary, #f9fafb)",borderRadius:"0.25rem",marginBottom:"0.5rem",fontSize:"0.8125rem"},children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"0.25rem"},children:y.description}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",color:"var(--nice-text-secondary)"},children:[e.jsx("span",{children:kt(y.date,f)}),e.jsx("span",{style:{fontWeight:600,color:y.amount>=0?"var(--nice-success)":"var(--nice-danger)"},children:$n(y.amount,m,f)})]})]},y.id))]})]})]})}function ya(n,a,r){const l=new Map,d=[];n.forEach(f=>l.set(String(f[a]),{data:f,children:[],key:String(f[a]),depth:0})),n.forEach(f=>{const o=f[r],g=l.get(String(f[a]));if(o!=null&&o!==""&&l.has(String(o))){const N=l.get(String(o));g.depth=N.depth+1,N.children.push(g)}else d.push(g)});const m=(f,o)=>{f.forEach(g=>{g.depth=o,m(g.children,o+1)})};return m(d,0),d}function xi(n,a,r,l=0){return n.map(d=>({data:d,key:String(d[r]),depth:l,children:Array.isArray(d[a])?xi(d[a],a,r,l+1):[]}))}function va(n){const a=[],r=l=>{l.forEach(d=>{a.push(d.key),r(d.children)})};return r(n),a}function ja(n,a){const r=[],l=d=>{d.forEach(m=>{r.push(m),m.children.length>0&&a.has(m.key)&&l(m.children)})};return l(n),r}function bi(n,a,r){return!a||!r?n:[...n].sort((l,d)=>{const m=l.data[a]??"",f=d.data[a]??"",o=typeof m=="number"&&typeof f=="number"?m-f:String(m).localeCompare(String(f));return r==="desc"?-o:o}).map(l=>({...l,children:bi(l.children,a,r)}))}function _i({columns:n,data:a,keyField:r="id",parentKeyField:l="parentId",nested:d=!1,childrenField:m="children",expandedKeys:f,onExpandedChange:o,defaultExpandAll:g=!1,sortable:N=!0,sortField:S,sortDirection:K,onSort:A,selectable:R,selectedKeys:P,onSelectionChange:G,searchable:y,searchPlaceholder:s,striped:w,compact:c,loading:I,emptyText:F,toolbar:te,onRowClick:ue,className:Ae,style:D}){const{t:me}=J.ue(),be=t.useMemo(()=>d?xi(a,m,r):ya(a,r,l),[a,r,l,d,m]),xe=t.useMemo(()=>va(be),[be]),[ee,ae]=t.useState(()=>g?new Set(xe):new Set),M=f?new Set(f):ee,[E,b]=t.useState({field:"",dir:null}),[we,le]=t.useState(new Set),[O,U]=t.useState(""),Q=S??E.field,H=K??E.dir,_e=P??we,ge=t.useMemo(()=>n.filter(X=>!X.hidden),[n]),Te=t.useCallback(X=>{const ye=Q===X?H==="asc"?"desc":H==="desc"?null:"asc":"asc";A?A(X,ye):b({field:X,dir:ye})},[Q,H,A]),Xe=t.useCallback(X=>{const ye=new Set(M);ye.has(X)?ye.delete(X):ye.add(X),o?o([...ye]):ae(ye)},[M,o]),nn=t.useCallback(X=>{const ye=new Set(_e);ye.has(X)?ye.delete(X):ye.add(X),G?G(ye):le(ye)},[_e,G]),De=t.useMemo(()=>{if(!O)return be;const X=O.toLowerCase(),ye=Ie=>Ie.reduce((L,oe)=>{const W=ye(oe.children);return(ge.some(T=>String(oe.data[T.field]??"").toLowerCase().includes(X))||W.length>0)&&L.push({...oe,children:W}),L},[]);return ye(be)},[be,O,ge]),tn=t.useMemo(()=>bi(De,Q,H),[De,Q,H]),Ee=t.useMemo(()=>ja(tn,M),[tn,M]),Be=({field:X})=>Q!==X||!H?e.jsx("span",{className:"nice-table__sort-icon",style:{opacity:.3},children:"↕"}):e.jsx("span",{className:"nice-table__sort-icon",children:H==="asc"?"↑":"↓"});return e.jsxs("div",{className:`nice-treegrid nice-datagrid ${Ae||""}`,style:D,children:[(y||te)&&e.jsxs("div",{className:"nice-datagrid__toolbar",children:[y&&e.jsx("div",{className:"nice-datagrid__search",children:e.jsx("input",{type:"text",value:O,onChange:X=>U(X.target.value),placeholder:s||me("controls.search","Search...")})}),te]}),e.jsx("div",{className:"nice-datagrid__table-wrap",children:e.jsxs("table",{className:`${w?"nice-table--striped":""} ${c?"nice-table--compact":""}`,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[R&&e.jsx("th",{className:"nice-datagrid__checkbox",style:{width:36}}),ge.map(X=>e.jsxs("th",{style:{width:X.width,minWidth:X.minWidth,textAlign:X.align},className:N&&X.sortable!==!1?"nice-datagrid__th--sortable":void 0,onClick:()=>N&&X.sortable!==!1&&Te(X.field),children:[X.header,N&&X.sortable!==!1&&e.jsx(Be,{field:X.field})]},X.field))]})}),e.jsx("tbody",{children:I?e.jsx("tr",{children:e.jsx("td",{colSpan:ge.length+(R?1:0),className:"nice-datagrid__empty",children:e.jsx("div",{className:"nice-spinner nice-spinner--md",style:{margin:"0 auto"}})})}):Ee.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:ge.length+(R?1:0),className:"nice-datagrid__empty",children:F||me("controls.noData","No data available")})}):Ee.map((X,ye)=>{const Ie=_e.has(X.key),L=X.children.length>0,oe=M.has(X.key);return e.jsxs("tr",{className:Ie?"nice-datagrid__row--selected":void 0,onClick:()=>ue==null?void 0:ue(X.data),style:ue?{cursor:"pointer"}:void 0,children:[R&&e.jsx("td",{className:"nice-datagrid__checkbox",onClick:W=>W.stopPropagation(),children:e.jsx("input",{type:"checkbox",checked:Ie,onChange:()=>nn(X.key),"aria-label":`Select row ${X.key}`})}),ge.map((W,T)=>e.jsxs("td",{style:{textAlign:W.align},children:[T===0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{display:"inline-block",width:X.depth*20}}),e.jsx("button",{className:`nice-treegrid__toggle ${L?"":"nice-treegrid__toggle--leaf"}`,onClick:ne=>{ne.stopPropagation(),L&&Xe(X.key)},tabIndex:L?0:-1,"aria-expanded":L?oe:void 0,"aria-label":L?oe?"Collapse":"Expand":void 0,children:L?oe?"▾":"▸":""})]}),W.render?W.render(X.data[W.field],X.data,ye):String(X.data[W.field]??"")]},W.field))]},X.key)})})]})})]})}const xn={width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0},wa=()=>e.jsxs("svg",{...xn,children:[e.jsx("path",{d:"M3 7v6h6"}),e.jsx("path",{d:"M21 17a9 9 0 0 0-15-6.7L3 13"})]}),ka=()=>e.jsxs("svg",{...xn,children:[e.jsx("path",{d:"M21 7v6h-6"}),e.jsx("path",{d:"M3 17a9 9 0 0 1 15-6.7L21 13"})]}),Na=()=>e.jsxs("svg",{...xn,children:[e.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),e.jsx("line",{x1:"3",y1:"12",x2:"15",y2:"12"}),e.jsx("line",{x1:"3",y1:"18",x2:"18",y2:"18"})]}),Ca=()=>e.jsxs("svg",{...xn,children:[e.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),e.jsx("line",{x1:"6",y1:"12",x2:"18",y2:"12"}),e.jsx("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),Sa=()=>e.jsxs("svg",{...xn,children:[e.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),e.jsx("line",{x1:"9",y1:"12",x2:"21",y2:"12"}),e.jsx("line",{x1:"6",y1:"18",x2:"21",y2:"18"})]}),Ma=()=>e.jsxs("svg",{...xn,children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"6",rx:"1"}),e.jsx("rect",{x:"3",y:"14",width:"18",height:"6",rx:"1"}),e.jsx("line",{x1:"12",y1:"11",x2:"12",y2:"13"})]}),Da=()=>e.jsxs("svg",{...xn,children:[e.jsx("rect",{x:"4",y:"3",width:"6",height:"18",rx:"1"}),e.jsx("rect",{x:"14",y:"3",width:"6",height:"18",rx:"1"}),e.jsx("line",{x1:"11",y1:"12",x2:"13",y2:"12"})]}),$a=()=>e.jsxs("svg",{...xn,children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"6",rx:"1"}),e.jsx("line",{x1:"6",y1:"17",x2:"18",y2:"17"})]}),Aa=()=>e.jsxs("svg",{...xn,children:[e.jsx("rect",{x:"4",y:"3",width:"6",height:"18",rx:"1"}),e.jsx("line",{x1:"14",y1:"12",x2:"20",y2:"12"})]}),Ia=()=>e.jsx("svg",{...xn,children:e.jsx("polyline",{points:"6 9 12 4 18 9"})}),La=()=>e.jsx("svg",{...xn,children:e.jsx("polyline",{points:"6 15 12 20 18 15"})}),za=()=>e.jsxs("svg",{...xn,style:{opacity:.55},children:[e.jsx("polyline",{points:"6 9 12 4 18 9"}),e.jsx("polyline",{points:"6 15 12 20 18 15"})]}),Ta=()=>e.jsxs("svg",{...xn,children:[e.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),e.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),Ea=()=>e.jsxs("svg",{...xn,children:[e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"}),e.jsx("line",{x1:"6",y1:"18",x2:"18",y2:"6"})]});function yi(n){let a="",r=n;for(;r>=0;)a=String.fromCharCode(65+r%26)+a,r=Math.floor(r/26)-1;return a}function ze(n,a){return`${yi(a)}${n+1}`}function rn(n){const a=n.match(/^([A-Z]+)(\d+)$/);if(!a)return null;let r=0;for(let l=0;l<a[1].length;l++)r=r*26+(a[1].charCodeAt(l)-64);return{row:parseInt(a[2],10)-1,col:r-1}}function Ra(n,a,r=new Set){const l=n.startsWith("=")?n.slice(1).trim():n,d=(y,s)=>{if(!y||!s)return[];const w=[];for(let c=y.row;c<=s.row;c++)for(let I=y.col;I<=s.col;I++){const F=en(ze(c,I),a,new Set(r));typeof F=="number"&&w.push(F)}return w},m=(y,s)=>{if(!y||!s)return[];const w=[];for(let c=y.row;c<=s.row;c++)for(let I=y.col;I<=s.col;I++)w.push(en(ze(c,I),a,new Set(r)));return w},f=l.match(/^(\w+)\(([A-Z]+\d+):([A-Z]+\d+)\)$/i);if(f){const y=f[1].toUpperCase(),s=rn(f[2].toUpperCase()),w=rn(f[3].toUpperCase());switch(y){case"SUM":return d(s,w).reduce((c,I)=>c+I,0);case"AVG":case"AVERAGE":{const c=d(s,w);return c.length>0?c.reduce((I,F)=>I+F,0)/c.length:0}case"COUNT":return d(s,w).length;case"COUNTA":return m(s,w).filter(c=>c!==null&&c!=="").length;case"COUNTBLANK":return m(s,w).filter(c=>c===null||c==="").length;case"MIN":{const c=d(s,w);return c.length?Math.min(...c):0}case"MAX":{const c=d(s,w);return c.length?Math.max(...c):0}case"MEDIAN":{const c=d(s,w).sort((F,te)=>F-te);if(!c.length)return 0;const I=Math.floor(c.length/2);return c.length%2?c[I]:(c[I-1]+c[I])/2}case"STDEV":{const c=d(s,w);if(c.length<2)return 0;const I=c.reduce((F,te)=>F+te,0)/c.length;return Math.sqrt(c.reduce((F,te)=>F+(te-I)**2,0)/(c.length-1))}case"PRODUCT":{const c=d(s,w);return c.length?c.reduce((I,F)=>I*F,1):0}}}const o=l.match(/^(SUMIF|COUNTIF)\(([A-Z]+\d+):([A-Z]+\d+)\s*,\s*"?([^"]*)"?\)$/i);if(o){const y=o[1].toUpperCase(),s=rn(o[2].toUpperCase()),w=rn(o[3].toUpperCase()),c=o[4];if(s&&w){let I=0;for(let F=s.row;F<=w.row;F++)for(let te=s.col;te<=w.col;te++){const ue=en(ze(F,te),a,new Set(r));(c.startsWith(">")?Number(ue)>Number(c.slice(1)):c.startsWith("<")?Number(ue)<Number(c.slice(1)):String(ue)===c||typeof ue=="number"&&ue===Number(c))&&(I+=y==="SUMIF"?typeof ue=="number"?ue:0:1)}return I}}const g=l.match(/^IF\(([^,]+),\s*([^,]+),\s*([^)]+)\)$/i);if(g){const y=g[1].trim(),s=g[2].trim(),w=g[3].trim(),c=y.match(/^([A-Z]+\d+)\s*([><=!]+)\s*(\S+)$/i);let I=!1;if(c){const ue=en(c[1].toUpperCase(),a,new Set(r)),Ae=isNaN(Number(c[3]))?c[3].replace(/^"|"$/g,""):Number(c[3]),D=c[2],me=typeof ue=="number"?ue:Number(ue)||0,be=typeof Ae=="number"?Ae:Number(Ae)||0;switch(D){case">":I=me>be;break;case"<":I=me<be;break;case">=":I=me>=be;break;case"<=":I=me<=be;break;case"=":case"==":I=me===be;break;case"<>":case"!=":I=me!==be;break}}const F=I?s:w;if(rn(F.toUpperCase()))return en(F.toUpperCase(),a,new Set(r));const te=Number(F);return isNaN(te)?F.replace(/^"|"$/g,""):te}const N=l.match(/^CONCAT\((.+)\)$/i);if(N)return N[1].split(",").map(y=>y.trim()).map(y=>{if(y.startsWith('"')&&y.endsWith('"'))return y.slice(1,-1);if(rn(y.toUpperCase())){const s=en(y.toUpperCase(),a,new Set(r));return s!==null?String(s):""}return y}).join("");const S=l.match(/^VLOOKUP\(([^,]+),\s*([A-Z]+\d+):([A-Z]+\d+),\s*(\d+)\)$/i);if(S){let y;rn(S[1].trim().toUpperCase())?y=en(S[1].trim().toUpperCase(),a,new Set(r)):y=isNaN(Number(S[1]))?S[1].replace(/^"|"$/g,""):Number(S[1]);const s=rn(S[2].toUpperCase()),w=rn(S[3].toUpperCase()),c=parseInt(S[4])-1;if(s&&w)for(let I=s.row;I<=w.row;I++){const F=en(ze(I,s.col),a,new Set(r));if(String(F)===String(y))return en(ze(I,s.col+c),a,new Set(r))}return null}const K=l.match(/^(ABS|ROUND|FLOOR|CEIL|CEILING|SQRT|LEN|UPPER|LOWER|TRIM|INT)\(([^)]+)\)$/i);if(K){const y=K[1].toUpperCase(),s=K[2].trim();let w;switch(rn(s.toUpperCase())?w=en(s.toUpperCase(),a,new Set(r)):w=isNaN(Number(s))?s.replace(/^"|"$/g,""):Number(s),y){case"ABS":return Math.abs(Number(w)||0);case"ROUND":return Math.round(Number(w)||0);case"FLOOR":return Math.floor(Number(w)||0);case"CEIL":case"CEILING":return Math.ceil(Number(w)||0);case"SQRT":return Math.sqrt(Number(w)||0);case"INT":return Math.trunc(Number(w)||0);case"LEN":return String(w??"").length;case"UPPER":return String(w??"").toUpperCase();case"LOWER":return String(w??"").toLowerCase();case"TRIM":return String(w??"").trim()}}const A=l.match(/^POWER\(([^,]+),\s*([^)]+)\)$/i);if(A){const y=Number(rn(A[1].trim().toUpperCase())?en(A[1].trim().toUpperCase(),a,new Set(r)):A[1].trim())||0,s=Number(rn(A[2].trim().toUpperCase())?en(A[2].trim().toUpperCase(),a,new Set(r)):A[2].trim())||0;return Math.pow(y,s)}if(/^NOW\(\)$/i.test(l))return new Date().toISOString();if(/^TODAY\(\)$/i.test(l))return new Date().toISOString().split("T")[0];if(/^PI\(\)$/i.test(l))return Math.PI;const R=l.match(/^([A-Z]+\d+)$/i);if(R)return en(R[1].toUpperCase(),a,r);const P=l.match(/^([A-Z]+\d+)\s*([+\-*/])\s*([A-Z]+\d+|\d+\.?\d*)$/i);if(P){const y=P[1].toUpperCase(),s=P[2],w=P[3],c=en(y,a,r),I=rn(w.toUpperCase())?en(w.toUpperCase(),a,r):parseFloat(w),F=typeof c=="number"?c:0,te=typeof I=="number"?I:0;switch(s){case"+":return F+te;case"-":return F-te;case"*":return F*te;case"/":return te!==0?F/te:null}}const G=parseFloat(l);return isNaN(G)?l:G}function en(n,a,r){if(r.has(n))return null;r.add(n);const l=a[n];return l?l.formula?Ra(l.formula,a,r):l.value:null}function li(n,a){return n==null?"":a==="percent"&&typeof n=="number"?`${(n*100).toFixed(1)}%`:a==="currency"&&typeof n=="number"?`$${n.toFixed(2)}`:String(n)}function si(n){return{name:n,data:{}}}const Pt=t.forwardRef(({sheets:n,activeSheet:a,rows:r=50,cols:l=26,showToolbar:d=!0,showFormulaBar:m=!0,showSheetTabs:f=!0,readOnly:o=!1,onChange:g,onActiveSheetChange:N,onCellSelect:S,onCopy:K,onPaste:A,onInsert:R,onRemove:P,maxUndo:G=50,sortable:y=!1,filterable:s=!1,rangeSelection:w=!0,className:c,style:I,id:F,...te},ue)=>{var Ln,Un,Rn,Wn,Xn;const Ae=J.nl(F),{t:D}=J.ue(),[me,be]=t.useState(()=>n??[si(D("spreadsheet.sheet","Sheet")+" 1")]),[xe,ee]=t.useState(0),ae=n??me,M=a??xe,E=ae[M]??ae[0],[b,we]=t.useState(null),[le,O]=t.useState(null),[U,Q]=t.useState(!1),[H,_e]=t.useState(null),[ge,Te]=t.useState(""),Xe=t.useRef(null),nn=t.useRef(null),[De,tn]=t.useState([]),[Ee,Be]=t.useState([]),[X,ye]=t.useState(null),Ie=t.useRef({x:0,width:80}),[L,oe]=t.useState(null),[W,T]=t.useState(null),[ne,je]=t.useState("");t.useEffect(()=>{H&&Xe.current&&Xe.current.focus()},[H]);const V=t.useMemo(()=>{if(!b)return null;const u=le??b;return{startRow:Math.min(b.row,u.row),startCol:Math.min(b.col,u.col),endRow:Math.max(b.row,u.row),endCol:Math.max(b.col,u.col)}},[b,le]),Le=t.useCallback((u,h)=>V?u>=V.startRow&&u<=V.endRow&&h>=V.startCol&&h<=V.endCol:!1,[V]),Se=t.useCallback(u=>{tn(h=>{const v=[...h,u.map(B=>({...B,data:{...B.data}}))];return v.length>G?v.slice(-G):v}),Be([])},[G]),he=t.useCallback((u,h=!0)=>{h&&Se(ae);const v=u(ae);n||be(v),g==null||g(v)},[ae,n,g,Se]),Qe=t.useCallback(()=>{if(De.length===0)return;const u=De[De.length-1];Be(h=>[...h,ae.map(v=>({...v,data:{...v.data}}))]),tn(h=>h.slice(0,-1)),n||be(u),g==null||g(u)},[De,ae,n,g]),pn=t.useCallback(()=>{if(Ee.length===0)return;const u=Ee[Ee.length-1];tn(h=>[...h,ae.map(v=>({...v,data:{...v.data}}))]),Be(h=>h.slice(0,-1)),n||be(u),g==null||g(u)},[Ee,ae,n,g]),ve=t.useCallback(u=>{a||ee(u),N==null||N(u),we(null),O(null),_e(null)},[a,N]),kn=t.useCallback((u,h,v)=>{const B=ze(u,h);he(q=>{const k=q.map((Y,Fe)=>Fe===M?{...Y,data:{...Y.data}}:Y),z=v.startsWith("=");return k[M].data[B]={...k[M].data[B]??{value:null},formula:z?v:void 0,value:z?null:isNaN(Number(v))?v:Number(v)},k})},[M,he]),Nn=t.useCallback((u,h,v)=>{v!=null&&v.shiftKey&&w&&b?O({row:u,col:h}):(we({row:u,col:h}),O(null)),_e(null),S==null||S(M,u,h)},[M,S,w,b]),Ve=t.useCallback((u,h,v)=>{v.button===0&&(Nn(u,h,v),w&&!v.shiftKey&&Q(!0))},[Nn,w]),In=t.useCallback((u,h)=>{U&&O({row:u,col:h})},[U]);t.useEffect(()=>{if(!U)return;const u=()=>Q(!1);return document.addEventListener("mouseup",u),()=>document.removeEventListener("mouseup",u)},[U]);const $=t.useCallback((u,h)=>{if(o)return;const v=ze(u,h),B=E.data[v];B!=null&&B.readOnly||(_e({row:u,col:h}),Te((B==null?void 0:B.formula)??((B==null?void 0:B.value)!=null?String(B.value):"")))},[o,E.data]),de=t.useCallback(()=>{H&&(kn(H.row,H.col,ge),_e(null))},[H,ge,kn]),pe=t.useCallback(u=>{if(u.key==="Enter")de();else if(u.key==="Escape")_e(null);else if(u.key==="Tab"&&(u.preventDefault(),de(),b)){const h=u.shiftKey?Math.max(0,b.col-1):Math.min(l-1,b.col+1);we({row:b.row,col:h})}},[de,b,l]),ke=t.useCallback((u,h)=>{if(!b)return;const v=V??{startRow:b.row,startCol:b.col,endRow:b.row,endCol:b.col};he(B=>{const q=B.map((k,z)=>z===M?{...k,data:{...k.data}}:k);for(let k=v.startRow;k<=v.endRow;k++)for(let z=v.startCol;z<=v.endCol;z++){const Y=ze(k,z);q[M].data[Y]={...q[M].data[Y]??{value:null},[u]:h}}return q})},[b,V,M,he]),un=t.useCallback(u=>{if(!V||(K==null?void 0:K(V))===!1)return;const{startRow:h,startCol:v,endRow:B,endCol:q}=V,k=[];for(let z=h;z<=B;z++){const Y=[];for(let Fe=v;Fe<=q;Fe++){const Re=ze(z,Fe),re=E.data[Re],Ze=re?en(Re,E.data,new Set):null;Y.push(li(Ze,re==null?void 0:re.format))}k.push(Y.join(" "))}u.clipboardData.setData("text/plain",k.join(`
|
|
595
|
+
`)),u.preventDefault()},[V,E.data,K]),Ce=t.useCallback(u=>{if(o||!b)return;const h=u.clipboardData.getData("text/plain");if(!h)return;const v=h.split(`
|
|
596
|
+
`).map(B=>B.split(" "));(A==null?void 0:A(v,b.row,b.col))!==!1&&(he(B=>{const q=B.map((k,z)=>z===M?{...k,data:{...k.data}}:k);return v.forEach((k,z)=>{k.forEach((Y,Fe)=>{const Re=ze(b.row+z,b.col+Fe),re=Y.startsWith("=");q[M].data[Re]={...q[M].data[Re]??{value:null},formula:re?Y:void 0,value:re?null:isNaN(Number(Y))?Y:Number(Y)}})}),q}),u.preventDefault())},[o,b,M,he,A]),Ke=t.useCallback(u=>{he(h=>h.map((v,B)=>{if(B!==M)return v;const q={};for(const[k,z]of Object.entries(v.data)){const Y=rn(k);Y&&(Y.row>u?q[ze(Y.row+1,Y.col)]=z:q[k]=z)}return{...v,data:q}})),R==null||R("row",u)},[M,he,R]),mn=t.useCallback(u=>{he(h=>h.map((v,B)=>{if(B!==M)return v;const q={};for(const[k,z]of Object.entries(v.data)){const Y=rn(k);Y&&(Y.col>u?q[ze(Y.row,Y.col+1)]=z:q[k]=z)}return{...v,data:q}})),R==null||R("column",u)},[M,he,R]),We=t.useCallback(u=>{he(h=>h.map((v,B)=>{if(B!==M)return v;const q={};for(const[k,z]of Object.entries(v.data)){const Y=rn(k);Y&&Y.row!==u&&(Y.row>u?q[ze(Y.row-1,Y.col)]=z:q[k]=z)}return{...v,data:q}})),P==null||P("row",u)},[M,he,P]),an=t.useCallback(u=>{he(h=>h.map((v,B)=>{if(B!==M)return v;const q={};for(const[k,z]of Object.entries(v.data)){const Y=rn(k);Y&&Y.col!==u&&(Y.col>u?q[ze(Y.row,Y.col-1)]=z:q[k]=z)}return{...v,data:q}})),P==null||P("column",u)},[M,he,P]),Cn=t.useCallback((u,h)=>{he(v=>v.map((B,q)=>{if(q!==M)return B;const k=new Map;for(const[Fe,Re]of Object.entries(B.data)){const re=rn(Fe);re&&(k.has(re.row)||k.set(re.row,{}),k.get(re.row)[re.col]=Re)}const z=Array.from(k.entries()).sort((Fe,Re)=>{const re=en(ze(Fe[0],u),B.data,new Set),Ze=en(ze(Re[0],u),B.data,new Set),ln=typeof re=="number"?re:Number(re),gn=typeof Ze=="number"?Ze:Number(Ze);if(!isNaN(ln)&&!isNaN(gn))return h==="asc"?ln-gn:gn-ln;const sn=String(re??""),fn=String(Ze??"");return h==="asc"?sn.localeCompare(fn):fn.localeCompare(sn)}),Y={};return z.forEach(([,Fe],Re)=>{for(const[re,Ze]of Object.entries(Fe))Y[ze(Re,Number(re))]=Ze}),{...B,data:Y,sortColumn:u,sortDirection:h}}))},[M,he]),Qn=t.useCallback((u,h)=>{const v=E.conditionalFormats;if(!(v!=null&&v.length))return;const B=ze(u,h),q=en(B,E.data,new Set),k=typeof q=="number"?q:Number(q);for(const z of v){const Y=z.range.match(/^([A-Z]+\d+):([A-Z]+\d+)$/i);if(!Y)continue;const Fe=rn(Y[1].toUpperCase()),Re=rn(Y[2].toUpperCase());if(!Fe||!Re||u<Fe.row||u>Re.row||h<Fe.col||h>Re.col)continue;let re=!1;switch(z.type){case"greaterThan":re=!isNaN(k)&&k>Number(z.value);break;case"lessThan":re=!isNaN(k)&&k<Number(z.value);break;case"equalTo":re=String(q)===String(z.value);break;case"between":re=!isNaN(k)&&k>=Number(z.value)&&k<=Number(z.value2);break;case"textContains":re=String(q).includes(String(z.value));break;case"isEmpty":re=q===null||q==="";break;case"isNotEmpty":re=q!==null&&q!=="";break}if(re)return{backgroundColor:z.style.bgColor,color:z.style.color,fontWeight:z.style.bold?"bold":void 0,fontStyle:z.style.italic?"italic":void 0}}},[E.conditionalFormats,E.data]),Zn=t.useCallback(()=>{const u=`${D("spreadsheet.sheet","Sheet")} ${ae.length+1}`;he(h=>[...h,si(u)]),ve(ae.length)},[ae.length,he,ve,D]),et=t.useCallback(()=>{ae.length<=1||(he(u=>u.filter((h,v)=>v!==M)),ve(Math.max(0,M-1)))},[ae.length,M,he,ve]),Jn=t.useCallback((u,h)=>{h.trim()&&(he(v=>v.map((B,q)=>q===u?{...B,name:h.trim()}:B),!1),T(null))},[he]),Hn=t.useMemo(()=>{if(!b)return"";const u=ze(b.row,b.col),h=E.data[u];return(h==null?void 0:h.formula)??((h==null?void 0:h.value)!=null?String(h.value):"")},[b,E.data]),hn=t.useMemo(()=>{if(!V)return null;const{startRow:u,startCol:h,endRow:v,endCol:B}=V;if(u===v&&h===B)return null;const q=[];let k=0;for(let z=u;z<=v;z++)for(let Y=h;Y<=B;Y++){const Fe=ze(z,Y),Re=en(Fe,E.data,new Set);Re!==null&&Re!==""&&k++,typeof Re=="number"&&q.push(Re)}return q.length===0?{count:k}:{count:k,sum:q.reduce((z,Y)=>z+Y,0),avg:q.reduce((z,Y)=>z+Y,0)/q.length,min:Math.min(...q),max:Math.max(...q)}},[V,E.data]),mt=t.useCallback((u,h)=>{var v;h.preventDefault(),h.stopPropagation(),ye(u),Ie.current={x:h.clientX,width:((v=E.colWidths)==null?void 0:v[u])??80}},[E.colWidths]);t.useEffect(()=>{if(X===null)return;const u=v=>{const B=v.clientX-Ie.current.x,q=Math.max(30,Ie.current.width+B);he(k=>k.map((z,Y)=>Y===M?{...z,colWidths:{...z.colWidths,[X]:q}}:z),!1)},h=()=>ye(null);return document.addEventListener("mousemove",u),document.addEventListener("mouseup",h),()=>{document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",h)}},[X,M,he]);const nt=t.useCallback((u,h,v)=>{u.preventDefault(),we({row:h,col:v}),oe({x:u.clientX,y:u.clientY})},[]);t.useEffect(()=>{if(!L)return;const u=()=>oe(null);return document.addEventListener("click",u),()=>document.removeEventListener("click",u)},[L]);const Pe=t.useCallback(u=>{if((u.ctrlKey||u.metaKey)&&!H){if(u.key==="z"){u.preventDefault(),Qe();return}if(u.key==="y"){u.preventDefault(),pn();return}}if(H||!b)return;let{row:h,col:v}=b;switch(u.key){case"ArrowUp":h=Math.max(0,h-1);break;case"ArrowDown":h=Math.min(r-1,h+1);break;case"ArrowLeft":v=Math.max(0,v-1);break;case"ArrowRight":v=Math.min(l-1,v+1);break;case"Enter":$(h,v);return;case"Delete":case"Backspace":o||(V&&(V.startRow!==V.endRow||V.startCol!==V.endCol)?he(B=>{const q=B.map((k,z)=>z===M?{...k,data:{...k.data}}:k);for(let k=V.startRow;k<=V.endRow;k++)for(let z=V.startCol;z<=V.endCol;z++)delete q[M].data[ze(k,z)];return q}):kn(h,v,""));return;default:if(u.key.length===1&&!u.ctrlKey&&!u.metaKey&&!o){_e({row:h,col:v}),Te(u.key);return}return}u.preventDefault(),u.shiftKey&&w?O({row:h,col:v}):(we({row:h,col:v}),O(null)),S==null||S(M,h,v)},[H,b,r,l,o,$,kn,M,S,Qe,pn,V,he,w]),qe=E.frozenRows??0,Oe=E.frozenCols??0,Kn=[{value:"text",label:D("spreadsheet.formatText","Text")},{value:"number",label:D("spreadsheet.formatNumber","Number")},{value:"percent",label:D("spreadsheet.formatPercent","Percent")},{value:"currency",label:D("spreadsheet.formatCurrency","Currency")},{value:"date",label:D("spreadsheet.formatDate","Date")}];return e.jsxs("div",{ref:ue,id:Ae,className:`nice-spreadsheet ${o?"nice-spreadsheet--readonly":""} ${c??""}`,style:I,onKeyDown:Pe,onCopy:un,onPaste:Ce,tabIndex:0,role:"application","aria-label":D("spreadsheet.label","Spreadsheet"),...te,children:[d&&!o&&e.jsxs("div",{className:"nice-spreadsheet__toolbar",role:"toolbar",children:[e.jsx(J.pn,{variant:"ghost",size:"sm",onClick:Qe,disabled:De.length===0,title:D("spreadsheet.undo","Undo"),children:e.jsx(wa,{})}),e.jsx(J.pn,{variant:"ghost",size:"sm",onClick:pn,disabled:Ee.length===0,title:D("spreadsheet.redo","Redo"),children:e.jsx(ka,{})}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(J.pn,{variant:(Ln=E.data[b?ze(b.row,b.col):""])!=null&&Ln.bold?"primary":"ghost",size:"sm",onClick:()=>{var u;return ke("bold",!((u=E.data[b?ze(b.row,b.col):""])!=null&&u.bold))},title:D("spreadsheet.bold","Bold"),children:e.jsx("strong",{children:"B"})}),e.jsx(J.pn,{variant:(Un=E.data[b?ze(b.row,b.col):""])!=null&&Un.italic?"primary":"ghost",size:"sm",onClick:()=>{var u;return ke("italic",!((u=E.data[b?ze(b.row,b.col):""])!=null&&u.italic))},title:D("spreadsheet.italic","Italic"),children:e.jsx("em",{children:"I"})}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(J.pn,{variant:"ghost",size:"sm",onClick:()=>ke("align","left"),title:D("spreadsheet.alignLeft","Align left"),children:e.jsx(Na,{})}),e.jsx(J.pn,{variant:"ghost",size:"sm",onClick:()=>ke("align","center"),title:D("spreadsheet.alignCenter","Center"),children:e.jsx(Ca,{})}),e.jsx(J.pn,{variant:"ghost",size:"sm",onClick:()=>ke("align","right"),title:D("spreadsheet.alignRight","Align right"),children:e.jsx(Sa,{})}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(J.Xe,{value:((Rn=E.data[b?ze(b.row,b.col):""])==null?void 0:Rn.bgColor)??"var(--bg-primary, #ffffff)",onChange:u=>ke("bgColor",u),title:D("spreadsheet.bgColor","Background color"),showInput:!1,showRandom:!1}),e.jsx(J.Xe,{value:((Wn=E.data[b?ze(b.row,b.col):""])==null?void 0:Wn.color)??"var(--text-primary, #000000)",onChange:u=>ke("color",u),title:D("spreadsheet.textColor","Text color"),showInput:!1,showRandom:!1}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(J.Ze,{size:"sm",value:((Xn=E.data[b?ze(b.row,b.col):""])==null?void 0:Xn.format)??"text",onChange:u=>ke("format",u),options:Kn,"aria-label":D("spreadsheet.format","Cell format")}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(J.pn,{variant:"ghost",size:"sm",onClick:()=>b&&Ke(b.row),title:D("spreadsheet.insertRow","Insert row"),children:e.jsx(Ma,{})}),e.jsx(J.pn,{variant:"ghost",size:"sm",onClick:()=>b&&mn(b.col),title:D("spreadsheet.insertCol","Insert column"),children:e.jsx(Da,{})}),e.jsx(J.pn,{variant:"ghost",size:"sm",onClick:()=>b&&We(b.row),title:D("spreadsheet.deleteRow","Delete row"),children:e.jsx($a,{})}),e.jsx(J.pn,{variant:"ghost",size:"sm",onClick:()=>b&&an(b.col),title:D("spreadsheet.deleteCol","Delete column"),children:e.jsx(Aa,{})})]}),m&&e.jsxs("div",{className:"nice-spreadsheet__formula-bar",children:[e.jsxs("span",{className:"nice-spreadsheet__cell-label",children:[b?ze(b.row,b.col):"",V&&V.startRow!==V.endRow||V&&V.startCol!==V.endCol?`:${ze(V.endRow,V.endCol)}`:""]}),e.jsx(J.Pe,{className:"nice-spreadsheet__formula-input",value:H?ge:Hn,onChange:u=>{H?Te(u):b&&(_e(b),Te(u))},onKeyDown:pe,readOnly:o,"aria-label":D("spreadsheet.formulaBar","Formula bar")})]}),e.jsx("div",{className:"nice-spreadsheet__grid",ref:nn,children:e.jsxs("table",{role:"grid","aria-label":E.name,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"nice-spreadsheet__corner"}),Array.from({length:l},(u,h)=>{var v;return e.jsxs("th",{className:`nice-spreadsheet__col-header ${h<Oe?"nice-spreadsheet__col-header--frozen":""}`,style:{width:((v=E.colWidths)==null?void 0:v[h])??80,position:h<Oe?"sticky":void 0,left:h<Oe?h*80+40:void 0,zIndex:h<Oe?3:void 0},children:[e.jsx("span",{children:yi(h)}),y&&e.jsx("span",{className:"nice-spreadsheet__sort-trigger",onClick:()=>Cn(h,E.sortColumn===h&&E.sortDirection==="asc"?"desc":"asc"),title:D("spreadsheet.sort","Sort"),children:E.sortColumn===h?E.sortDirection==="asc"?e.jsx(Ia,{}):e.jsx(La,{}):e.jsx(za,{})}),!o&&e.jsx("span",{className:"nice-spreadsheet__col-resize",onMouseDown:B=>mt(h,B)})]},h)})]})}),e.jsx("tbody",{children:Array.from({length:r},(u,h)=>e.jsxs("tr",{className:h<qe?"nice-spreadsheet__row--frozen":"",style:h<qe?{position:"sticky",top:h*24,zIndex:2}:void 0,children:[e.jsx("td",{className:"nice-spreadsheet__row-header",children:h+1}),Array.from({length:l},(v,B)=>{var ln,gn;const q=ze(h,B),k=E.data[q];if(k!=null&&k.mergedInto)return null;const z=(b==null?void 0:b.row)===h&&(b==null?void 0:b.col)===B,Y=Le(h,B),Fe=(H==null?void 0:H.row)===h&&(H==null?void 0:H.col)===B,Re=k?en(q,E.data,new Set):null,re=Qn(h,B),Ze=h<qe||B<Oe;return e.jsxs("td",{className:`nice-spreadsheet__cell ${z?"nice-spreadsheet__cell--selected":""} ${Y&&!z?"nice-spreadsheet__cell--in-range":""} ${k!=null&&k.readOnly?"nice-spreadsheet__cell--readonly":""} ${Ze?"nice-spreadsheet__cell--frozen":""}`,style:{textAlign:k==null?void 0:k.align,fontWeight:k!=null&&k.bold?"bold":void 0,fontStyle:k!=null&&k.italic?"italic":void 0,backgroundColor:(re==null?void 0:re.backgroundColor)??(k==null?void 0:k.bgColor),color:(re==null?void 0:re.color)??(k==null?void 0:k.color),width:(ln=E.colWidths)==null?void 0:ln[B],height:(gn=E.rowHeights)==null?void 0:gn[h],position:Ze?"sticky":void 0,left:B<Oe?B*80+40:void 0,zIndex:Ze?1:void 0,...re},colSpan:k==null?void 0:k.colSpan,rowSpan:k==null?void 0:k.rowSpan,onMouseDown:sn=>Ve(h,B,sn),onMouseEnter:()=>In(h,B),onDoubleClick:()=>$(h,B),onContextMenu:sn=>nt(sn,h,B),role:"gridcell","aria-selected":z,title:k==null?void 0:k.comment,children:[(k==null?void 0:k.comment)&&e.jsx("span",{className:"nice-spreadsheet__comment-indicator"}),Fe?e.jsx("input",{ref:Xe,className:"nice-spreadsheet__cell-editor",value:ge,onChange:sn=>Te(sn.target.value),onKeyDown:pe,onBlur:de}):li(Re,k==null?void 0:k.format)]},B)})]},h))})]})}),L&&!o&&b&&e.jsxs("div",{className:"nice-spreadsheet__context-menu",style:{position:"fixed",left:L.x,top:L.y,zIndex:1e3},children:[e.jsx(J.pn,{variant:"ghost",size:"sm",onClick:()=>{Ke(b.row),oe(null)},children:D("spreadsheet.insertRowAbove","Insert row above")}),e.jsx(J.pn,{variant:"ghost",size:"sm",onClick:()=>{Ke(b.row+1),oe(null)},children:D("spreadsheet.insertRowBelow","Insert row below")}),e.jsx(J.pn,{variant:"ghost",size:"sm",onClick:()=>{mn(b.col),oe(null)},children:D("spreadsheet.insertColLeft","Insert column left")}),e.jsx(J.pn,{variant:"ghost",size:"sm",onClick:()=>{mn(b.col+1),oe(null)},children:D("spreadsheet.insertColRight","Insert column right")}),e.jsx("hr",{className:"nice-spreadsheet__context-sep"}),e.jsx(J.pn,{variant:"ghost",size:"sm",onClick:()=>{We(b.row),oe(null)},children:D("spreadsheet.deleteRow","Delete row")}),e.jsx(J.pn,{variant:"ghost",size:"sm",onClick:()=>{an(b.col),oe(null)},children:D("spreadsheet.deleteCol","Delete column")})]}),hn&&e.jsxs("div",{className:"nice-spreadsheet__status-bar",children:[e.jsxs("span",{children:[D("spreadsheet.count","Count"),": ",hn.count]}),hn.sum!==void 0&&e.jsxs("span",{children:[D("spreadsheet.sum","Sum"),": ",hn.sum.toFixed(2)]}),hn.avg!==void 0&&e.jsxs("span",{children:[D("spreadsheet.avg","Avg"),": ",hn.avg.toFixed(2)]}),hn.min!==void 0&&e.jsxs("span",{children:[D("spreadsheet.min","Min"),": ",hn.min]}),hn.max!==void 0&&e.jsxs("span",{children:[D("spreadsheet.max","Max"),": ",hn.max]})]}),f&&e.jsxs("div",{className:"nice-spreadsheet__tabs",role:"tablist",children:[ae.map((u,h)=>e.jsx("span",{className:"nice-spreadsheet__tab-wrapper",children:W===h?e.jsx(J.Pe,{className:"nice-spreadsheet__tab-rename",value:ne,onChange:v=>je(v),onBlur:()=>Jn(h,ne),onKeyDown:v=>{v.key==="Enter"&&Jn(h,ne),v.key==="Escape"&&T(null)},autoFocus:!0}):e.jsx("span",{onDoubleClick:()=>{o||(T(h),je(u.name))},children:e.jsx(J.pn,{variant:h===M?"primary":"ghost",size:"sm",onClick:()=>ve(h),children:u.name})})},h)),!o&&e.jsxs(e.Fragment,{children:[e.jsx(J.pn,{variant:"ghost",size:"sm",onClick:Zn,title:D("spreadsheet.addSheet","Add sheet"),children:e.jsx(Ta,{})}),ae.length>1&&e.jsx(J.pn,{variant:"ghost",size:"sm",onClick:et,title:D("spreadsheet.removeSheet","Remove sheet"),children:e.jsx(Ea,{})})]})]})]})});Pt.displayName="NiceSpreadsheet";const Fa=Object.freeze(Object.defineProperty({__proto__:null,N:gi,a:ut,c:Ft,d:ui,f:Rt,g:Et,j:Pt,k:oi,l:fi,m:_i,n:pi,o:hi,p:di,q:ot,r:Ui,s:Hi},Symbol.toStringTag,{value:"Module"}));exports.Bt=ut;exports.L=ci;exports.NiceSavedQueryPanelDtgcsEls=Fa;exports.Za=Pt;exports.ca=Ft;exports.cr=hi;exports.ia=Rt;exports.lr=gi;exports.mr=_i;exports.na=Et;exports.or=fi;exports.rr=ui;exports.sr=pi;exports.tr=oi;exports.z=Tt;
|