@nice2dev/ui-presentations 1.0.5 → 1.0.8
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/NiceSavedQueryPanel-CUAsdOjJ-CluPYvkx.cjs +596 -0
- package/dist/NiceSavedQueryPanel-CUAsdOjJ-DoBn1dP8.js +6078 -0
- package/dist/NiceSavedQueryPanel-DUw8plYP-9P_gnuUz.js +5568 -0
- package/dist/NiceSavedQueryPanel-DUw8plYP-DtmUEWvh.cjs +596 -0
- package/dist/NiceStockChart-Cpmv9_Cc-DBqGppkm.cjs +287 -0
- package/dist/NiceStockChart-Cpmv9_Cc-DbDw3MKe.js +2246 -0
- package/dist/index-BQJzPBop.js +34168 -0
- package/dist/index-BaBBRokT.cjs +863 -0
- package/dist/index-CIl98Vbm-D5_blXJt.js +46639 -0
- package/dist/index-CIl98Vbm-DPDdqp0C.cjs +4993 -0
- package/dist/index-CNwVELPJ-CJET50oR.js +37303 -0
- package/dist/index-CNwVELPJ-CNlww_AU.cjs +5243 -0
- package/dist/index-DJMo5hmg.js +40303 -0
- package/dist/index-DrkeMHRo.cjs +1401 -0
- package/dist/index.cjs +1 -6986
- package/dist/index.mjs +165 -78128
- package/package.json +1 -1
|
@@ -0,0 +1,596 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("react"),ae=require("./index-BaBBRokT.cjs");function ci({columns:t,data:r,striped:a,compact:l,emptyText:s,className:u,style:m,accessMode:o,id:y,displayStyle:A}){if(ae.ei(o,y)==="hidden")return null;const $=ae.ll("table",A),U=ae.cl("table",A),[p,Z]=n.useState(null),L=n.useMemo(()=>p?[...r].sort((x,v)=>{const _=x[p.field]??"",b=v[p.field]??"",F=typeof _=="number"?_-b:String(_).localeCompare(String(b));return p.dir==="desc"?-F:F}):r,[r,p]),q=x=>{Z(v=>(v==null?void 0:v.field)===x?v.dir==="asc"?{field:x,dir:"desc"}:null:{field:x,dir:"asc"})};return e.jsx("div",{className:`nice-table-wrapper ${u||""}`,style:{...$,...m},children:e.jsxs("table",{className:`nice-table nice-table--ds-${U} ${a?"nice-table--striped":""} ${l?"nice-table--compact":""}`,"aria-rowcount":L.length,"aria-colcount":t.length,children:[e.jsx("thead",{children:e.jsx("tr",{children:t.map(x=>{const v=x.sortable?(p==null?void 0:p.field)===x.field?p.dir==="asc"?"ascending":"descending":"none":void 0;return e.jsxs("th",{style:{width:x.width,textAlign:x.align},className:x.sortable?"th--sortable":void 0,onClick:()=>x.sortable&&q(x.field),scope:"col","aria-sort":v,children:[x.header,x.sortable&&(p==null?void 0:p.field)===x.field&&e.jsx("span",{className:"nice-table__sort-icon","aria-hidden":"true",children:p.dir==="asc"?"↑":"↓"})]},x.field)})})}),e.jsx("tbody",{children:L.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:t.length,className:"nice-table__empty",children:s||"No data"})}):L.map((x,v)=>e.jsx("tr",{children:t.map(_=>e.jsx("td",{style:{textAlign:_.align},children:_.render?_.render(x[_.field],x):String(x[_.field]??"")},_.field))},v))})]})})}function Gt(t,r,a){const l=t.map(s=>s[r]).filter(s=>typeof s=="number");if(l.length===0)return a==="count"?"0":"";switch(a){case"sum":return l.reduce((s,u)=>s+u,0).toLocaleString();case"avg":return(l.reduce((s,u)=>s+u,0)/l.length).toLocaleString(void 0,{maximumFractionDigits:2});case"count":return String(t.length);case"min":return Math.min(...l).toLocaleString();case"max":return Math.max(...l).toLocaleString()}}function it(t){return t.includes(",")||t.includes('"')||t.includes(`
|
|
2
|
+
`)?`"${t.replace(/"/g,'""')}"`:t}function xt({columns:t,data:r,keyField:a="id",dataSource:l,sortable:s=!0,sortField:u,sortDirection:m,onSort:o,selectable:y,selectedKeys:A,onSelectionChange:$,pagination:U,pageSize:p=10,page:Z,onPageChange:L,totalRows:q,searchable:x,searchPlaceholder:v,virtualScroll:_,rowHeight:b=40,groupBy:F,groupRender:Y,onCellEdit:V,exportCsv:ue,exportFilename:J="export",detailRow:S,expandedRowKeys:oe,onExpandedRowChange:re,columnReorder:O,onColumnReorder:de,columnResize:z,rowDraggable:N,onRowReorder:B,striped:f,compact:_e,loading:W,emptyText:ge,toolbar:ee,onRowClick:me,pinnedTopKeys:H,pinnedBottomKeys:ve,colSpan:K,showStatusBar:he,contextMenuItems:je,onContextMenuAction:Oe,printFriendly:We,keyboardNavigation:we,focusedCell:qe,onFocusedCellChange:Ne,cellRangeSelection:X,selectedCellRange:C,onCellRangeChange:xe,clipboard:ne,clipboardFormat:pe="text",onBeforeCopy:T,onCopy:Ee,onPaste:Re,quickFilters:De,activeQuickFilters:G,onQuickFilterChange:bn,columnGroups:An,stateStorageKey:ke,initialState:M,onStateChange:se,flashRowKeys:le,flashDuration:He=500,autoFitColumns:kn,showColumnStats:Ce,rowIndicator:Le,frozenRows:an,className:rn,style:en,accessMode:on,id:Qn,displayStyle:Kn}){var Tt,Lt;const Fn=ae.ei(on,Qn);if(Fn==="hidden")return null;const Pn=Fn==="readOnly"||Fn==="disabled",{t:ze}=ae.de();ae.ll("table",Kn),ae.cl("table",Kn);const Ze=ae.ki$1(l??null,{autoLoad:!!l,defaultPageSize:p}),Ge=!!l,zn=Ge?Ze.data:r??[],En=Ge?Ze.loading:W,[Hn,Vn]=n.useState({field:"",dir:null}),[Zn,gn]=n.useState(1),[rt,qn]=n.useState(new Set),[In,Gn]=n.useState(""),[dn,Yn]=n.useState(p),[ln,On]=n.useState(null),[Nn,Cn]=n.useState(null),[Rn,c]=n.useState(new Set),[d,j]=n.useState(0),I=n.useRef(null),[Q,w]=n.useState(new Set),E=oe??Q,[P,Ie]=n.useState({}),[Se,te]=n.useState(null),[Ve,sn]=n.useState(null),[fn,cn]=n.useState(null),[_n,lt]=n.useState(null),[Tn,Sn]=n.useState([]),[Xn,Wn]=n.useState(null),[bt,Un]=n.useState(new Set),[jt,Nt]=n.useState(null),Jn=n.useRef(null),nn=qe??fn,Je=C??_n,tn=G??Tn;n.useEffect(()=>{if(!ke)return;const i=localStorage.getItem(`nice-datagrid-${ke}`);if(i&&!M)try{const h=JSON.parse(i);h.columnWidths&&Ie(h.columnWidths),h.expandedGroups&&c(new Set(h.expandedGroups))}catch{}},[ke,M]),n.useEffect(()=>{if(!(le!=null&&le.size))return;Un(new Set(le));const i=setTimeout(()=>Un(new Set),He);return()=>clearTimeout(i)},[le,He]),n.useEffect(()=>{if(!Ve)return;const i=()=>sn(null);return document.addEventListener("click",i),()=>document.removeEventListener("click",i)},[Ve]);const st=n.useCallback((i,h)=>{je!=null&&je.length&&(i.preventDefault(),sn({x:i.clientX,y:i.clientY,row:h}))},[je]),ct=n.useCallback(i=>{const h=new Set(E);h.has(i)?h.delete(i):h.add(i),re?re(h):w(h)},[E,re]),ot=n.useCallback((i,h)=>{var ye;if(!z)return;h.preventDefault();const k=h.clientX,D=((ye=h.target.closest("th"))==null?void 0:ye.offsetWidth)??100,R=ie=>{const Te=Math.max(40,D+ie.clientX-k);Ie(Ae=>({...Ae,[i]:Te}))},ce=()=>{document.removeEventListener("mousemove",R),document.removeEventListener("mouseup",ce)};document.addEventListener("mousemove",R),document.addEventListener("mouseup",ce)},[z]),jn=Ge?((Tt=Ze.sort[0])==null?void 0:Tt.field)??"":u??Hn.field,un=Ge?((Lt=Ze.sort[0])==null?void 0:Lt.direction)??null:m??Hn.dir,Mn=Ge?Ze.page:Z??Zn,hn=A??rt;n.useCallback(()=>{if(!ke)return;const i={columnWidths:P,sortField:jn||void 0,sortDirection:un,pageSize:dn,expandedGroups:Array.from(Rn)};localStorage.setItem(`nice-datagrid-${ke}`,JSON.stringify(i)),se==null||se(i)},[ke,P,jn,un,dn,Rn,se]);const pn=n.useMemo(()=>t.filter(i=>!i.hidden),[t]),et=n.useMemo(()=>pn.filter(i=>i.pinned==="left"),[pn]),nt=n.useMemo(()=>pn.filter(i=>i.pinned==="right"),[pn]),Ln=n.useMemo(()=>pn.filter(i=>!i.pinned),[pn]),Fe=n.useMemo(()=>[...et,...Ln,...nt],[et,Ln,nt]),dt=n.useMemo(()=>pn.some(i=>i.aggregate),[pn]),Bn=et.length>0||nt.length>0,tt=n.useCallback(i=>{const h=jn===i?un==="asc"?"desc":un==="desc"?null:"asc":"asc";Ge?h?Ze.setSortField(i,h):Ze.setSort([]):o?o(i,h):Vn({field:i,dir:h})},[jn,un,Ge,Ze,o]),g=n.useMemo(()=>{if(Ge)return zn;let i=[...zn];if(In){const h=In.toLowerCase();i=i.filter(k=>pn.some(D=>String(k[D.field]??"").toLowerCase().includes(h)))}return!o&&jn&&un&&i.sort((h,k)=>{const D=h[jn]??"",R=k[jn]??"",ce=typeof D=="number"?D-R:String(D).localeCompare(String(R));return un==="desc"?-ce:ce}),i},[zn,In,pn,jn,un,o,Ge]),fe=Ge?Ze.totalCount:q??g.length,be=Ge?Ze.pageSize:dn,Me=Math.max(1,Math.ceil(fe/be)),Ue=Ge?g:U&&!q?g.slice((Mn-1)*be,Mn*be):g,xn=n.useCallback(i=>{Ge?Ze.setPage(i):L?L(i):gn(i)},[Ge,Ze,L]),mn=n.useMemo(()=>Ue.map(i=>String(i[a])),[Ue,a]),Ye=mn.length>0&&mn.every(i=>hn.has(i)),ut=mn.some(i=>hn.has(i)),Ct=n.useCallback(()=>{const i=new Set(hn);Ye?mn.forEach(h=>i.delete(h)):mn.forEach(h=>i.add(h)),$?$(i):qn(i)},[Ye,mn,hn,$]),St=n.useCallback(i=>{const h=new Set(hn);h.has(i)?h.delete(i):h.add(i),$?$(h):qn(h)},[hn,$]),Mt=({field:i})=>jn!==i||!un?e.jsx("span",{className:"nice-table__sort-icon",style:{opacity:.3},children:"↕"}):e.jsx("span",{className:"nice-table__sort-icon",children:un==="asc"?"↑":"↓"}),yn=n.useMemo(()=>{if(!F)return Ue.map((k,D)=>({type:"data",row:k,key:String(k[a]??D)}));const i=new Map;Ue.forEach(k=>{const D=k[F];i.has(D)||i.set(D,[]),i.get(D).push(k)});const h=[];return i.forEach((k,D)=>{const R=`__group_${String(D)}`,ce=Rn.has(R);h.push({type:"group",value:D,rows:k,expanded:ce,key:R}),ce&&k.forEach((ye,ie)=>h.push({type:"data",row:ye,key:String(ye[a]??`${R}_${ie}`)}))}),h},[Ue,F,a,Rn]),{pinnedTopRows:Yt,pinnedBottomRows:Xt,normalRows:Jt}=n.useMemo(()=>{if(!(H!=null&&H.size)&&!(ve!=null&&ve.size))return{pinnedTopRows:[],pinnedBottomRows:[],normalRows:yn};const i=[],h=[],k=[];for(const D of yn){if(D.type==="data"){const R=D.key;if(H!=null&&H.has(R)){i.push(D);continue}if(ve!=null&&ve.has(R)){h.push(D);continue}}k.push(D)}return{pinnedTopRows:i,pinnedBottomRows:h,normalRows:k}},[yn,H,ve]),$t=n.useCallback(i=>{c(h=>{const k=new Set(h);return k.has(i)?k.delete(i):k.add(i),k})},[]),ei=n.useMemo(()=>{var R;if(!_)return yn;const i=((R=I.current)==null?void 0:R.clientHeight)??400,h=Math.ceil(i/b),k=Math.max(0,Math.floor(d/b)-3),D=Math.min(yn.length-1,k+h+6);return yn.slice(k,D+1).map((ce,ye)=>({...ce,_vIdx:k+ye}))},[_,yn,d,b]),mt=n.useCallback((i,h,k)=>{!V||Pn||(On({rowKey:i,field:h}),Cn(k))},[V]),Dt=n.useCallback(()=>{ln&&V&&V(ln.rowKey,ln.field,Nn),On(null),Cn(null)},[ln,Nn,V]),ni=n.useCallback(()=>{On(null),Cn(null)},[]),ti=n.useCallback(()=>{const i=pn,h=i.map(ie=>it(ie.header)).join(","),k=g.map(ie=>i.map(Te=>it(String(ie[Te.field]??""))).join(",")),D=[h,...k].join(`
|
|
3
|
+
`),R=new Blob(["\uFEFF"+D],{type:"text/csv;charset=utf-8;"}),ce=URL.createObjectURL(R),ye=document.createElement("a");ye.href=ce,ye.download=`${J}.csv`,ye.click(),URL.revokeObjectURL(ce)},[pn,g,J]),ht=n.useCallback(i=>{Ne?Ne(i):cn(i)},[Ne]),pt=n.useCallback(i=>{xe?xe(i):lt(i)},[xe]),vn=n.useMemo(()=>yn.filter(i=>i.type==="data").map(i=>i.key),[yn]),ii=n.useCallback(i=>{if(!we||ln||!nn)return;const h=vn.indexOf(nn.rowKey),k=Fe.findIndex(ye=>ye.field===nn.field);if(h<0||k<0)return;let D=h,R=k;switch(i.key){case"ArrowUp":D=Math.max(0,h-1);break;case"ArrowDown":D=Math.min(vn.length-1,h+1);break;case"ArrowLeft":R=Math.max(0,k-1);break;case"ArrowRight":R=Math.min(Fe.length-1,k+1);break;case"Tab":i.preventDefault(),i.shiftKey?R=Math.max(0,k-1):R=Math.min(Fe.length-1,k+1);break;case"Enter":const ye=Fe[k];if(ye.editable&&V){const ie=Ue.find(Te=>String(Te[a])===nn.rowKey);ie&&mt(nn.rowKey,ye.field,ie[ye.field])}return;case"Escape":ht(null),pt(null);return;case"Home":i.ctrlKey&&(D=0),R=0;break;case"End":i.ctrlKey&&(D=vn.length-1),R=Fe.length-1;break;case"PageUp":D=Math.max(0,h-dn);break;case"PageDown":D=Math.min(vn.length-1,h+dn);break;default:return}i.preventDefault();const ce={rowKey:vn[D],field:Fe[R].field};if(ht(ce),i.shiftKey&&X){const ye=(Je==null?void 0:Je.start)??nn;pt({start:ye,end:ce})}else pt(null)},[we,ln,nn,vn,Fe,X,Je,ht,pt,V,Ue,a,mt,dn]),At=n.useCallback(()=>{let i=[],h=[];if(Je){const k=vn.indexOf(Je.start.rowKey),D=vn.indexOf(Je.end.rowKey),R=Math.min(k,D),ce=Math.max(k,D),ye=Fe.findIndex(Be=>Be.field===Je.start.field),ie=Fe.findIndex(Be=>Be.field===Je.end.field),Te=Math.min(ye,ie),Ae=Math.max(ye,ie);h=Fe.slice(Te,Ae+1).map(Be=>Be.field),i=Ue.filter(Be=>{const Pe=vn.indexOf(String(Be[a]));return Pe>=R&&Pe<=ce})}else hn.size>0&&(i=Ue.filter(k=>hn.has(String(k[a]))),h=Fe.map(k=>k.field));return{rows:i,fields:h}},[Je,vn,Fe,Ue,a,hn]),Ft=n.useCallback((i,h,k)=>{const D=Fe.filter(R=>h.includes(R.field));switch(k){case"json":return JSON.stringify(i.map(Pe=>Object.fromEntries(h.map(Ke=>[Ke,Pe[Ke]]))),null,2);case"csv":const R=D.map(Pe=>it(Pe.header)).join(","),ce=i.map(Pe=>D.map(Ke=>it(String(Pe[Ke.field]??""))).join(",")).join(`
|
|
4
|
+
`);return R+`
|
|
5
|
+
`+ce;case"html":const ye=D.map(Pe=>`<th>${Pe.header}</th>`).join(""),ie=i.map(Pe=>`<tr>${D.map(Ke=>`<td>${Pe[Ke.field]??""}</td>`).join("")}</tr>`).join("");return`<table><thead><tr>${ye}</tr></thead><tbody>${ie}</tbody></table>`;case"markdown":const Te="| "+D.map(Pe=>Pe.header).join(" | ")+" |",Ae="| "+D.map(()=>"---").join(" | ")+" |",Be=i.map(Pe=>"| "+D.map(Ke=>Pe[Ke.field]??"").join(" | ")+" |").join(`
|
|
6
|
+
`);return Te+`
|
|
7
|
+
`+Ae+`
|
|
8
|
+
`+Be;default:return i.map(Pe=>D.map(Ke=>Pe[Ke.field]??"").join(" ")).join(`
|
|
9
|
+
`)}},[Fe]),yt=n.useCallback(async()=>{if(!ne)return;const{rows:i,fields:h}=At();if(!i.length||(T==null?void 0:T(i,h))===!1)return;const k=Ft(i,h,pe);await navigator.clipboard.writeText(k),Ee==null||Ee(i,h,pe)},[ne,At,T,Ft,pe,Ee]),Et=n.useCallback(async()=>{if(!ne||!nn||!Re)return;const i=(await navigator.clipboard.readText()).split(`
|
|
10
|
+
`).map(h=>h.split(" "));Re(i,nn)},[ne,nn,Re]);n.useEffect(()=>{if(!ne||!Jn.current)return;const i=h=>{var k;(k=Jn.current)!=null&&k.contains(document.activeElement)&&(h.type==="copy"&&(h.preventDefault(),yt()),h.type==="paste"&&(h.preventDefault(),Et()))};return document.addEventListener("copy",i),document.addEventListener("paste",i),()=>{document.removeEventListener("copy",i),document.removeEventListener("paste",i)}},[ne,yt,Et]);const ai=n.useCallback(i=>{const h=tn.includes(i)?tn.filter(k=>k!==i):[...tn,i];bn?bn(h):Sn(h)},[tn,bn]);n.useMemo(()=>{if(!(De!=null&&De.length)||!tn.length)return g;const i=De.filter(h=>tn.includes(h.key));return g.filter(h=>i.every(k=>k.filter(h)))},[g,De,tn]),De==null||De.length,n.useCallback(i=>{const h=g.map(Te=>Te[i]).filter(Te=>Te!=null),k=h.filter(Te=>typeof Te=="number");if(k.length===0){const Te=new Set(h).size;return{count:h.length,unique:Te,type:"text"}}const D=k.reduce((Te,Ae)=>Te+Ae,0),R=D/k.length,ce=Math.min(...k),ye=Math.max(...k),ie=Math.sqrt(k.reduce((Te,Ae)=>Te+(Ae-R)**2,0)/k.length);return{count:k.length,sum:D,avg:R,min:ce,max:ye,stdDev:ie,type:"numeric"}},[g]);const ri=n.useCallback((i,h,k)=>{if(!i.cellVisualization)return null;const D=Number(h);if(isNaN(D))return null;const R=i.visualMin??0,ce=i.visualMax??100,ye=Math.max(0,Math.min(100,(D-R)/(ce-R)*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:`${ye}%`,height:"100%",background:ye>80?"var(--color-success)":ye>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(ye),"%"]})]});case"rating":const ie=Math.round(D/ce*5);return e.jsx("div",{className:"nice-datagrid__cell-rating",children:[1,2,3,4,5].map(zt=>e.jsx("span",{style:{color:zt<=ie?"var(--color-warning)":"var(--text-muted)",fontSize:"0.85rem"},children:"★"},zt))});case"trend":const Te=i.visualMin??D,Ae=D-Te,Be=Ae>0?"↑":Ae<0?"↓":"→",Pe=Ae>0?"var(--color-success)":Ae<0?"var(--color-danger)":"var(--text-muted)";return e.jsxs("span",{style:{color:Pe,fontWeight:500},children:[Be," ",Math.abs(Ae).toFixed(1),"%"]});case"heatmap":const Ke=ye/100,ft=`rgba(${Math.round(255*Ke)}, ${Math.round(100*(1-Ke))}, ${Math.round(50*(1-Ke))}, 0.6)`;return e.jsx("span",{style:{background:ft,padding:"2px 8px",borderRadius:4},children:D});default:return null}},[]),li=n.useCallback((i,h,k)=>{var D;if(!((D=i.conditionalFormats)!=null&&D.length))return{};for(const R of i.conditionalFormats)if(R.when(h,k,i.field))return{className:R.className,style:{...R.style,backgroundColor:R.backgroundColor,color:R.color}};return{}},[]),vt=n.useCallback((i,h)=>{if(!Bn||!i.pinned)return{};const k={position:"sticky",zIndex:2,background:"var(--bg-primary, #fff)"};if(i.pinned==="left"){let D=0;for(let R=0;R<h;R++){const ce=Fe[R];ce.pinned==="left"&&(D+=typeof ce.width=="number"?ce.width:parseInt(String(ce.width)||"100",10))}y&&h===0&&(D=36),k.left=D}else{let D=0;for(let R=Fe.length-1;R>h;R--){const ce=Fe[R];ce.pinned==="right"&&(D+=typeof ce.width=="number"?ce.width:parseInt(String(ce.width)||"100",10))}k.right=D}return k},[Bn,Fe,y]),Rt=(i,h,k,D)=>(ln==null?void 0:ln.rowKey)===k&&(ln==null?void 0:ln.field)===i.field?i.editor?i.editor(Nn,h,ce=>Cn(ce)):e.jsx("input",{className:"nice-datagrid__edit-input",autoFocus:!0,value:Nn??"",onChange:ce=>Cn(ce.target.value),onBlur:Dt,onKeyDown:ce=>{ce.key==="Enter"&&Dt(),ce.key==="Escape"&&ni()}}):ri(i,h[i.field],h)||(i.render?i.render(h[i.field],h,D):String(h[i.field]??"")),si=(i,h,k,D)=>{const R=(nn==null?void 0:nn.rowKey)===k&&(nn==null?void 0:nn.field)===i.field,ce=Je&&(()=>{const ie=vn.indexOf(Je.start.rowKey),Te=vn.indexOf(Je.end.rowKey),Ae=vn.indexOf(k),Be=Fe.findIndex(Ke=>Ke.field===Je.start.field),Pe=Fe.findIndex(Ke=>Ke.field===Je.end.field);return Ae>=Math.min(ie,Te)&&Ae<=Math.max(ie,Te)&&D>=Math.min(Be,Pe)&&D<=Math.max(Be,Pe)})(),ye=li(i,h[i.field],h);return{className:[ye.className,R&&"nice-datagrid__cell--focused",ce&&"nice-datagrid__cell--in-range"].filter(Boolean).join(" "),style:{...vt(i,D),textAlign:i.align,...ye.style,...R?{outline:"2px solid var(--color-primary)",outlineOffset:-2}:{},...ce?{background:"var(--color-primary-light, rgba(59,130,246,0.15))"}:{}}}},gt=Fe.length+(y?1:0)+(S?1:0)+(N?1:0)+(Le?1:0),wt=(i,h,k)=>{const{row:D,key:R}=i,ce=hn.has(R),ye=E.has(R),ie=bt.has(R),Te=[ce&&"nice-datagrid__row--selected",Se===h&&"nice-datagrid__row--dragging",k&&"nice-datagrid__row--pinned",ie&&"nice-datagrid__row--flash"].filter(Boolean).join(" ");return e.jsxs(n.Fragment,{children:[e.jsxs("tr",{className:Te,onClick:()=>me==null?void 0:me(D),onContextMenu:Ae=>st(Ae,D),style:me?{cursor:"pointer"}:void 0,draggable:N,onDragStart:N?()=>te(h):void 0,onDragOver:N?Ae=>Ae.preventDefault():void 0,onDrop:N&&B&&Se!=null?()=>{B(Se,h),te(null)}:void 0,onDragEnd:N?()=>te(null):void 0,children:[Le&&e.jsx("td",{className:"nice-datagrid__row-indicator",style:{width:32,padding:"0 4px"},children:Le(D)}),S&&e.jsx("td",{className:"nice-datagrid__expand-col",onClick:Ae=>{Ae.stopPropagation(),ct(R)},children:e.jsx("span",{className:"nice-datagrid__expand-btn",children:ye?"▾":"▸"})}),N&&e.jsx("td",{className:"nice-datagrid__drag-handle",style:{cursor:"grab",textAlign:"center",color:"var(--text-muted)"},children:"⠿"}),y&&e.jsx("td",{className:"nice-datagrid__checkbox",onClick:Ae=>Ae.stopPropagation(),style:Bn?{position:"sticky",left:0,zIndex:1,background:"var(--bg-primary, #fff)"}:void 0,children:e.jsx("input",{type:"checkbox",checked:ce,onChange:()=>St(R),"aria-label":`Select row ${R}`})}),(()=>{let Ae=0;return Fe.map((Be,Pe)=>{if(Ae>0)return Ae--,null;const Ke=K?K(D,Be,Pe):void 0;Ke&&Ke>1&&(Ae=Ke-1);const ft=si(Be,D,R,Pe);return e.jsx("td",{colSpan:Ke,className:ft.className,style:ft.style,onClick:we?()=>ht({rowKey:R,field:Be.field}):void 0,onDoubleClick:Be.editable&&V?()=>mt(R,Be.field,D[Be.field]):void 0,children:Rt(Be,D,R,h)},Be.field)})})()]}),S&&ye&&e.jsx("tr",{className:"nice-datagrid__detail-row",children:e.jsx("td",{colSpan:gt,children:S(D)})})]},R)};return e.jsxs("div",{ref:Jn,className:`nice-datagrid ${We?"nice-datagrid--print":""} ${rn||""}`,style:en,role:"grid","aria-label":ze("datagrid.title","Data Grid"),"aria-rowcount":yn.length,"aria-colcount":pn.length,"aria-busy":En||void 0,tabIndex:we?0:void 0,onKeyDown:we?ii:void 0,children:[(x||ee||ue||(De==null?void 0:De.length))&&e.jsxs("div",{className:"nice-datagrid__toolbar",children:[x&&e.jsx("div",{className:"nice-datagrid__search",children:e.jsx("input",{type:"text",value:Ge?Ze.search:In,"aria-label":ze("controls.search","Search"),onChange:i=>{Ge?Ze.setSearch(i.target.value):(Gn(i.target.value),xn(1))},placeholder:v||ze("controls.search","Search...")})}),De&&De.length>0&&e.jsx("div",{className:"nice-datagrid__quick-filters",style:{display:"flex",gap:6,flexWrap:"wrap"},children:De.map(i=>e.jsxs("button",{className:`nice-datagrid__quick-filter ${tn.includes(i.key)?"nice-datagrid__quick-filter--active":""}`,onClick:()=>ai(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:tn.includes(i.key)?`var(--color-${i.color||"primary"})`:"var(--bg-primary)",color:tn.includes(i.key)?"#fff":"inherit",cursor:"pointer",transition:"all 0.15s ease"},children:[i.icon&&e.jsx("span",{children:i.icon}),i.label]},i.key))}),ne&&e.jsx("button",{className:"nice-btn nice-btn--sm nice-btn--ghost",onClick:yt,title:ze("controls.copy","Copy selected"),style:{marginLeft:4},children:"📋"}),ue&&e.jsx("button",{className:"nice-btn nice-btn--sm",onClick:ti,title:ze("controls.exportCsv","Export CSV"),children:"CSV ↓"}),ee]}),e.jsxs("div",{ref:I,className:`nice-datagrid__table-wrap ${_?"nice-datagrid__table-wrap--virtual":""}`,style:_?{maxHeight:Math.min(yn.length*b,600),overflowY:"auto"}:void 0,onScroll:_?i=>j(i.currentTarget.scrollTop):void 0,children:[_&&e.jsxs("div",{style:{height:yn.length*b,position:"relative"},children:[e.jsx("table",{className:`${f?"nice-table--striped":""} ${_e?"nice-table--compact":""}`,style:{position:"sticky",top:0,zIndex:3},children:e.jsx("thead",{children:e.jsxs("tr",{children:[S&&e.jsx("th",{className:"nice-datagrid__expand-col",style:{width:36}}),N&&e.jsx("th",{style:{width:28}}),y&&e.jsx("th",{className:"nice-datagrid__checkbox",style:Bn?{position:"sticky",left:0,zIndex:3,background:"var(--bg-primary, #fff)"}:void 0,children:e.jsx("input",{type:"checkbox",checked:Ye,ref:i=>{i&&(i.indeterminate=ut&&!Ye)},onChange:Ct,"aria-label":ze("controls.selectAll","Select all")})}),Fe.map((i,h)=>e.jsxs("th",{style:{width:P[i.field]||i.width,minWidth:i.minWidth,textAlign:i.align,position:"relative",...vt(i,h)},className:s&&i.sortable!==!1?"nice-datagrid__th--sortable":void 0,onClick:()=>s&&i.sortable!==!1&&tt(i.field),children:[i.header,s&&i.sortable!==!1&&e.jsx(Mt,{field:i.field}),z&&e.jsx("span",{className:"nice-datagrid__resize-handle",onMouseDown:k=>{k.stopPropagation(),ot(i.field,k)}})]},i.field))]})})}),ei.map((i,h)=>{const k=i._vIdx??0;if(i.type==="group"){const ie=i;return e.jsxs("div",{className:"nice-datagrid__group-row",style:{position:"absolute",top:k*b,height:b,left:0,right:0},onClick:()=>$t(ie.key),children:[e.jsx("span",{className:"nice-datagrid__group-toggle",children:ie.expanded?"▾":"▸"}),Y?Y(ie.value,ie.rows):e.jsxs(e.Fragment,{children:[String(ie.value)," (",ie.rows.length,")"]})]},ie.key)}const{row:D,key:R}=i,ce=hn.has(R),ye=E.has(R);return e.jsxs(n.Fragment,{children:[e.jsxs("div",{className:`nice-datagrid__vrow ${ce?"nice-datagrid__row--selected":""} ${Se===h?"nice-datagrid__row--dragging":""}`,style:{position:"absolute",top:k*b,height:b,left:0,right:0,display:"flex",alignItems:"center"},onClick:()=>me==null?void 0:me(D),draggable:N,onDragStart:N?()=>te(h):void 0,onDragOver:N?ie=>ie.preventDefault():void 0,onDrop:N&&B&&Se!=null?()=>{B(Se,h),te(null)}:void 0,onDragEnd:N?()=>te(null):void 0,children:[S&&e.jsx("div",{className:"nice-datagrid__expand-col",style:{width:36,flexShrink:0,textAlign:"center",cursor:"pointer"},onClick:ie=>{ie.stopPropagation(),ct(R)},children:e.jsx("span",{className:"nice-datagrid__expand-btn",children:ye?"▾":"▸"})}),N&&e.jsx("div",{style:{width:28,flexShrink:0,cursor:"grab",textAlign:"center",color:"var(--text-muted)"},children:"⠿"}),y&&e.jsx("div",{className:"nice-datagrid__checkbox",style:{width:36,flexShrink:0},onClick:ie=>ie.stopPropagation(),children:e.jsx("input",{type:"checkbox",checked:ce,onChange:()=>St(R)})}),Fe.map(ie=>e.jsx("div",{className:"nice-datagrid__vcell",style:{width:P[ie.field]||ie.width||"auto",flex:P[ie.field]||ie.width?`0 0 ${typeof(P[ie.field]||ie.width)=="number"?(P[ie.field]||ie.width)+"px":P[ie.field]||ie.width}`:1,textAlign:ie.align,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",padding:"0 8px"},onDoubleClick:ie.editable&&V?()=>mt(R,ie.field,D[ie.field]):void 0,children:Rt(ie,D,R,k)},ie.field))]}),S&&ye&&e.jsx("div",{className:"nice-datagrid__detail-row",style:{position:"absolute",top:(k+1)*b,left:0,right:0,padding:"8px 12px",background:"var(--bg-secondary, #f8f8f8)"},children:S(D)})]},R)})]}),!_&&e.jsxs("table",{className:`${f?"nice-table--striped":""} ${_e?"nice-table--compact":""}`,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[S&&e.jsx("th",{className:"nice-datagrid__expand-col",style:{width:36}}),N&&e.jsx("th",{style:{width:28}}),y&&e.jsx("th",{className:"nice-datagrid__checkbox",style:Bn?{position:"sticky",left:0,zIndex:3,background:"var(--bg-primary, #fff)"}:void 0,children:e.jsx("input",{type:"checkbox",checked:Ye,ref:i=>{i&&(i.indeterminate=ut&&!Ye)},onChange:Ct,"aria-label":ze("controls.selectAll","Select all")})}),Fe.map((i,h)=>{const k=s&&i.sortable!==!1,D=k?jn===i.field?un==="asc"?"ascending":un==="desc"?"descending":"none":"none":void 0;return e.jsxs("th",{style:{width:P[i.field]||i.width,minWidth:i.minWidth,textAlign:i.align,position:"relative",...vt(i,h)},className:k?"nice-datagrid__th--sortable":void 0,onClick:()=>k&&tt(i.field),"aria-sort":D,scope:"col",children:[i.header,k&&e.jsx(Mt,{field:i.field}),z&&e.jsx("span",{className:"nice-datagrid__resize-handle",onMouseDown:R=>{R.stopPropagation(),ot(i.field,R)}})]},i.field)})]})}),e.jsx("tbody",{children:En?e.jsx("tr",{children:e.jsx("td",{colSpan:gt,className:"nice-datagrid__empty",children:e.jsx("div",{className:"nice-spinner nice-spinner--md",style:{margin:"0 auto"}})})}):yn.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:gt,className:"nice-datagrid__empty",children:ge||ze("controls.noData","No data available")})}):e.jsxs(e.Fragment,{children:[Yt.map((i,h)=>i.type==="data"&&wt(i,h,"top")),Jt.map((i,h)=>{if(i.type==="group"){const k=i;return e.jsx("tr",{className:"nice-datagrid__group-row",onClick:()=>$t(k.key),children:e.jsxs("td",{colSpan:gt,className:"nice-datagrid__group-cell",children:[e.jsx("span",{className:"nice-datagrid__group-toggle",children:k.expanded?"▾":"▸"}),Y?Y(k.value,k.rows):e.jsxs(e.Fragment,{children:[String(k.value)," (",k.rows.length,")"]})]})},k.key)}return wt(i,h)}),Xt.map((i,h)=>i.type==="data"&&wt(i,h,"bottom"))]})}),dt&&!En&&Ue.length>0&&e.jsx("tfoot",{children:e.jsxs("tr",{className:"nice-datagrid__aggregate-row",children:[y&&e.jsx("td",{}),Fe.map(i=>e.jsx("td",{style:{textAlign:i.align,fontWeight:600},children:i.aggregate?(i.aggregateLabel||i.aggregate.toUpperCase())+": "+Gt(g,i.field,i.aggregate):""},i.field))]})})]})]}),U&&e.jsxs("div",{className:"nice-datagrid__footer",children:[e.jsxs("span",{children:[ze("controls.showing","Showing")," ",(Mn-1)*be+1,"–",Math.min(Mn*be,fe)," ",ze("controls.of","of")," ",fe]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("select",{value:be,onChange:i=>{const h=Number(i.target.value);Ge?Ze.setPageSize(h):(Yn(h),xn(1))},style:{padding:"2px 6px",border:"1px solid var(--border-color)",borderRadius:4,background:"var(--bg-primary)",color:"var(--text-primary)",font:"inherit",fontSize:"0.8125rem"},children:[5,10,25,50,100].map(i=>e.jsx("option",{value:i,children:i},i))}),e.jsxs("div",{style:{display:"flex",gap:2},children:[e.jsx("button",{className:"nice-pagination__btn",disabled:Mn<=1,onClick:()=>xn(Mn-1),children:"‹"}),e.jsxs("span",{style:{padding:"0 8px",display:"flex",alignItems:"center"},children:[Mn," / ",Me]}),e.jsx("button",{className:"nice-pagination__btn",disabled:Mn>=Me,onClick:()=>xn(Mn+1),children:"›"})]})]})]}),he&&!En&&e.jsxs("div",{className:"nice-datagrid__status-bar",children:[e.jsxs("span",{children:[ze("controls.totalRows","Total rows"),": ",fe]}),y&&hn.size>0&&e.jsxs("span",{children:[ze("controls.selected","Selected"),": ",hn.size]})]}),Ve&&je&&e.jsx("div",{className:"nice-datagrid__context-menu",style:{position:"fixed",left:Ve.x,top:Ve.y,zIndex:9999},onClick:i=>i.stopPropagation(),children:je.map(i=>e.jsxs("button",{className:"nice-datagrid__context-item",disabled:i.disabled,onClick:()=>{Oe==null||Oe(i.key,Ve.row),sn(null)},children:[i.icon&&e.jsx("span",{className:"nice-datagrid__context-icon",children:i.icon}),i.label]},i.key))})]})}xt.displayName="NiceDataGrid";const oi=Object.freeze(Object.defineProperty({__proto__:null,NiceDataGrid:xt},Symbol.toStringTag,{value:"Module"}));function di(t,r){return t.filter(a=>r.every(l=>{const s=a[l.field],u=l.value;switch(l.operator){case"eq":return s===u;case"ne":return s!==u;case"gt":return typeof s=="number"&&typeof u=="number"&&s>u;case"gte":return typeof s=="number"&&typeof u=="number"&&s>=u;case"lt":return typeof s=="number"&&typeof u=="number"&&s<u;case"lte":return typeof s=="number"&&typeof u=="number"&&s<=u;case"contains":return String(s).toLowerCase().includes(String(u).toLowerCase());case"startsWith":return String(s).toLowerCase().startsWith(String(u).toLowerCase());case"endsWith":return String(s).toLowerCase().endsWith(String(u).toLowerCase());default:return!0}}))}function ui(t){return t.map(r=>({field:r.field,type:r.dataType||"string",label:typeof r.header=="string"?r.header:r.field}))}function mi(t,r){const{enableAI:a=!0,aiModel:l,enableNLSearch:s=!0,enableInsights:u=!0,nlPlaceholder:m,onAIFilter:o,onInsights:y,showAISearchBar:A=!0,exampleQueries:$=["Show items from last week","Filter by status = active","Orders over $1000",'Names starting with "A"'],columns:U,data:p,...Z}=t,[L,q]=n.useState(""),[x,v]=n.useState([]),[_,b]=n.useState([]),[F,Y]=n.useState(!1),[V,ue]=n.useState(null),J=n.useRef(null),{t:S}=ae.a(),oe=ae.ue(),{parseFilter:re,isLoading:O}=ae.pi(),de=a&&oe.isConfigured,z=x.length>0?di(p||[],x):p,N=n.useCallback(async ee=>{if(!de||!s||!ee.trim())return;ue(ee);const me=ui(U);try{const H=await re(ee,me);v(H),o==null||o(ee,H)}catch{v([])}},[de,s,U,re,o]),B=n.useCallback(()=>{v([]),ue(null),q("")},[]),f=n.useCallback(()=>x,[x]),_e=n.useCallback(async()=>{if(!de||!u||!(p!=null&&p.length))return[];try{const ee=await oe.complete([{role:"user",content:`Analyze this data and provide 3-5 key insights. Data sample (${p.length} total rows): ${JSON.stringify(p.slice(0,20))}
|
|
11
|
+
|
|
12
|
+
Columns: ${U.map(me=>me.field).join(", ")}
|
|
13
|
+
|
|
14
|
+
Return a JSON array of insight strings. Be specific with numbers and trends.`}],{temperature:.3,maxTokens:500});try{const me=JSON.parse(ee.content),H=Array.isArray(me)?me:[];return b(H),y==null||y(H),H}catch{return[]}}catch{return[]}},[de,u,p,U,oe,y]),W=ee=>{ee.preventDefault(),L.trim()&&N(L)},ge=ee=>{q(ee),N(ee)};return n.useImperativeHandle(r,()=>({applyNLFilter:N,clearAIFilters:B,getAIFilters:f,generateInsights:_e})),e.jsxs("div",{className:"nice-data-grid-ai","data-testid":t["data-testid"],children:[A&&de&&s&&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:W,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:J,type:"text",value:L,onChange:ee=>q(ee.target.value),placeholder:m||S("dataGridAI.searchPlaceholder","Search with natural language..."),className:"nice-data-grid-ai__input",disabled:O}),O&&e.jsx("span",{className:"nice-data-grid-ai__loading-spinner"}),L&&!O&&e.jsx("button",{type:"button",className:"nice-data-grid-ai__clear-input",onClick:()=>q(""),children:"✕"})]}),e.jsx("button",{type:"submit",className:"nice-data-grid-ai__search-btn",disabled:O||!L.trim(),children:O?S("dataGridAI.searching","Searching..."):S("dataGridAI.search","Search")})]}),u&&e.jsxs("button",{type:"button",className:"nice-data-grid-ai__insights-btn",onClick:()=>{_e(),Y(!0)},disabled:O||!(p!=null&&p.length),title:S("dataGridAI.generateInsights","Generate AI Insights"),children:["💡 ",S("dataGridAI.insights","Insights")]})]}),A&&de&&s&&!V&&$.length>0&&e.jsxs("div",{className:"nice-data-grid-ai__examples",children:[e.jsx("span",{className:"nice-data-grid-ai__examples-label",children:S("dataGridAI.tryAsking","Try asking:")}),e.jsx("div",{className:"nice-data-grid-ai__examples-list",children:$.slice(0,4).map((ee,me)=>e.jsxs("button",{type:"button",className:"nice-data-grid-ai__example",onClick:()=>ge(ee),children:['"',ee,'"']},me))})]}),V&&x.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:['"',V,'"']}),e.jsxs("span",{className:"nice-data-grid-ai__filter-count",children:["(",(z==null?void 0:z.length)||0," ",S("dataGridAI.results","results"),")"]})]}),e.jsx("div",{className:"nice-data-grid-ai__filter-badges",children:x.map((ee,me)=>e.jsxs("span",{className:"nice-data-grid-ai__filter-badge",children:[ee.field," ",ee.operator," ",String(ee.value)]},me))}),e.jsxs("button",{type:"button",className:"nice-data-grid-ai__clear-filter",onClick:B,children:["✕ ",S("dataGridAI.clearFilter","Clear")]})]}),e.jsx("div",{className:"nice-data-grid-ai__grid-wrapper",children:e.jsx(xt,{columns:U,data:z,...Z})}),F&&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:["💡 ",S("dataGridAI.aiInsights","AI Insights")]}),e.jsx("button",{type:"button",className:"nice-data-grid-ai__insights-close",onClick:()=>Y(!1),children:"✕"})]}),e.jsx("div",{className:"nice-data-grid-ai__insights-body",children:O?e.jsx("div",{className:"nice-data-grid-ai__insights-loading",children:S("dataGridAI.analyzing","Analyzing data...")}):_.length>0?e.jsx("ul",{className:"nice-data-grid-ai__insights-list",children:_.map((ee,me)=>e.jsxs("li",{className:"nice-data-grid-ai__insight",children:[e.jsx("span",{className:"nice-data-grid-ai__insight-bullet",children:"•"}),ee]},me))}):e.jsx("div",{className:"nice-data-grid-ai__insights-empty",children:S("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:()=>_e(),disabled:O,children:["🔄 ",S("dataGridAI.refresh","Refresh")]})})]})]})}n.forwardRef(mi);const hi=({items:t,selectedKeys:r=[],onSelectionChange:a,selectionMode:l="none",searchable:s,searchPlaceholder:u,grouped:m,groupField:o="group",reorderable:y,onReorder:A,onItemClick:$,renderItem:U,showCheckboxes:p,loading:Z,emptyText:L,size:q="md",bordered:x=!0,swipeActions:v,className:_,style:b,accessMode:F,id:Y})=>{if(ae.ei(F,Y)==="hidden")return null;const{t:V}=ae.de(),[ue,J]=n.useState(""),[S,oe]=n.useState(null),[re,O]=n.useState(null),de=n.useRef(null),z=n.useMemo(()=>{if(!ue)return t;const W=ue.toLowerCase();return t.filter(ge=>ge.text.toLowerCase().includes(W))},[t,ue]),N=n.useMemo(()=>{if(!m)return null;const W=new Map;return z.forEach(ge=>{const ee=String(ge[o]??"");W.has(ee)||W.set(ee,[]),W.get(ee).push(ge)}),W},[z,m,o]),B=n.useCallback(W=>{a&&(l==="single"?a(r.includes(W)?[]:[W]):l==="multiple"&&a(r.includes(W)?r.filter(ge=>ge!==W):[...r,W]))},[r,l,a]),f=n.useCallback(W=>{S!==null&&S!==W&&A&&A(S,W),oe(null)},[S,A]),_e=(W,ge)=>{const ee=r.includes(W.key),me=re===W.key;return e.jsxs("li",{className:`nice-list__item ${ee?"nice-list__item--selected":""} ${W.disabled?"nice-list__item--disabled":""} ${me?"nice-list__item--swiped":""}`,onClick:()=>{W.disabled||(B(W.key),$==null||$(W))},draggable:y,onDragStart:()=>oe(ge),onDragOver:H=>H.preventDefault(),onDrop:()=>f(ge),onTouchStart:v!=null&&v.length?H=>{de.current={x:H.touches[0].clientX,key:W.key}}:void 0,onTouchEnd:v!=null&&v.length?H=>{if(!de.current)return;const ve=H.changedTouches[0].clientX-de.current.x;ve<-50&&de.current.key===W.key?O(W.key):ve>50&&O(null),de.current=null}:void 0,role:l!=="none"?"option":void 0,"aria-selected":l!=="none"?ee:void 0,children:[e.jsxs("div",{className:"nice-list__item-content",children:[p&&l!=="none"&&e.jsx("input",{type:"checkbox",checked:ee,readOnly:!0,tabIndex:-1,className:"nice-list__checkbox"}),U?U(W):e.jsxs(e.Fragment,{children:[W.icon&&e.jsx("span",{className:"nice-list__icon",children:W.icon}),e.jsx("span",{className:"nice-list__text",children:W.text}),W.badge&&e.jsx("span",{className:"nice-list__badge",children:W.badge})]})]}),v&&me&&e.jsx("div",{className:"nice-list__swipe-actions",children:v.map(H=>e.jsx("button",{className:"nice-list__swipe-btn",style:H.color?{backgroundColor:H.color}:void 0,onClick:ve=>{ve.stopPropagation(),H.onClick(W),O(null)},children:H.label},H.key))})]},W.key)};return e.jsxs("div",{className:`nice-list nice-list--${q} ${x?"nice-list--bordered":""} ${_||""}`,style:b,children:[s&&e.jsx("div",{className:"nice-list__search",children:e.jsx("input",{type:"text",value:ue,onChange:W=>J(W.target.value),placeholder:u||V("controls.search","Search...")})}),Z?e.jsx("div",{className:"nice-list__loading",children:e.jsx("div",{className:"nice-spinner nice-spinner--sm"})}):z.length===0?e.jsx("div",{className:"nice-list__empty",children:L||V("controls.noData","No data available")}):N?e.jsx("div",{role:"listbox",children:Array.from(N.entries()).map(([W,ge])=>e.jsxs("div",{className:"nice-list__group",children:[e.jsx("div",{className:"nice-list__group-header",children:W}),e.jsx("ul",{className:"nice-list__items",children:ge.map((ee,me)=>_e(ee,me))})]},W))}):e.jsx("ul",{className:"nice-list__items",role:"listbox",children:z.map((W,ge)=>_e(W,ge))})]})};function Ut(t){const r=[];if(t.children)for(const a of t.children)r.push(a.key),r.push(...Ut(a));return r}function kt(t,r){if(!t.children||t.children.length===0)return r.has(t.key)?"checked":"unchecked";let a=!0,l=r.has(t.key);for(const s of t.children){const u=kt(s,r);u==="checked"?l=!0:(u==="indeterminate"&&(l=!0),a=!1)}return a&&l?"checked":l?"indeterminate":"unchecked"}const pi=({nodes:t,selectedKeys:r=[],expandedKeys:a,onSelectionChange:l,onExpandedChange:s,selectionMode:u="none",showCheckboxes:m,searchable:o,searchPlaceholder:y,onNodeClick:A,renderNode:$,showLines:U,loading:p,className:Z,style:L,accessMode:q,id:x,draggable:v,onNodeDrop:_,onLoadChildren:b,contextMenuItems:F,onContextMenuAction:Y,editable:V,onNodeEdit:ue})=>{if(ae.ei(q,x)==="hidden")return null;const{t:J}=ae.de(),[S,oe]=n.useState([]),[re,O]=n.useState(""),[de,z]=n.useState(new Set),[N,B]=n.useState(new Map),[f,_e]=n.useState(null),[W,ge]=n.useState(null),[ee,me]=n.useState(null),[H,ve]=n.useState(""),K=n.useRef(null),he=a??S,je=n.useMemo(()=>new Set(r),[r]),Oe=n.useCallback(async(C,xe)=>{var T;const ne=!he.includes(C),pe=ne?[...he,C]:he.filter(Ee=>Ee!==C);if(s?s(pe):oe(pe),ne&&b&&!((T=xe.children)!=null&&T.length)&&xe.leaf!==!0&&!N.has(C)){z(Re=>new Set(Re).add(C));const Ee=await b(xe);B(Re=>new Map(Re).set(C,Ee)),z(Re=>{const De=new Set(Re);return De.delete(C),De})}},[he,s,b,N]),We=n.useCallback((C,xe)=>{var ne;if(l){if(u==="single")l(r.includes(C)?[]:[C]);else if(u==="multiple")if(m&&((ne=xe.children)!=null&&ne.length)){const pe=Ut(xe),T=[C,...pe];if(kt(xe,je)==="checked")l(r.filter(Ee=>!T.includes(Ee)));else{const Ee=new Set([...r,...T]);l(Array.from(Ee))}}else l(r.includes(C)?r.filter(pe=>pe!==C):[...r,C])}},[r,u,l,m,je]),we=n.useCallback(C=>{var ne;if(!re)return!0;const xe=re.toLowerCase();return C.text.toLowerCase().includes(xe)?!0:((ne=N.get(C.key)??C.children)==null?void 0:ne.some(pe=>we(pe)))??!1},[re,N]),qe=n.useCallback((C,xe)=>{F!=null&&F.length&&(C.preventDefault(),ge({x:C.clientX,y:C.clientY,node:xe}))},[F]),Ne=n.useCallback(()=>{ee&&ue&&ue(ee,H),me(null)},[ee,H,ue]),X=(C,xe)=>{if(re&&!we(C))return null;const ne=N.get(C.key)??C.children,pe=ne&&ne.length>0||C.leaf!==!0&&b&&!(ne!=null&&ne.length),T=he.includes(C.key),Ee=je.has(C.key),Re=de.has(C.key),De=m&&u==="multiple"&&(ne!=null&&ne.length)?kt(C,je):Ee?"checked":"unchecked";return e.jsxs("li",{className:"nice-tree__node",role:"treeitem","aria-expanded":pe?T:void 0,draggable:v&&!C.disabled,onDragStart:v?G=>{G.stopPropagation(),_e(C.key)}:void 0,onDragOver:v?G=>{G.preventDefault(),G.stopPropagation()}:void 0,onDrop:v&&f?G=>{G.stopPropagation(),_==null||_(f,C.key,"inside"),_e(null)}:void 0,onDragEnd:v?()=>_e(null):void 0,children:[e.jsxs("div",{className:`nice-tree__row ${Ee?"nice-tree__row--selected":""} ${C.disabled?"nice-tree__row--disabled":""} ${f===C.key?"nice-tree__row--dragging":""}`,style:{paddingLeft:xe*20+4},onClick:()=>{C.disabled||(We(C.key,C),A==null||A(C))},onContextMenu:G=>qe(G,C),onDoubleClick:V&&!C.disabled?()=>{me(C.key),ve(C.text)}:void 0,children:[e.jsx("span",{className:`nice-tree__toggle ${pe?T?"nice-tree__toggle--expanded":"":"nice-tree__toggle--leaf"}`,onClick:G=>{G.stopPropagation(),pe&&Oe(C.key,C)},children:Re?e.jsx("span",{className:"nice-spinner nice-spinner--xs"}):pe?T?"▾":"▸":""}),m&&u!=="none"&&e.jsx("input",{type:"checkbox",checked:De==="checked",ref:G=>{G&&(G.indeterminate=De==="indeterminate")},onChange:()=>We(C.key,C),onClick:G=>G.stopPropagation(),tabIndex:-1,className:"nice-tree__checkbox"}),ee===C.key?e.jsx("input",{type:"text",className:"nice-tree__edit-input",value:H,onChange:G=>ve(G.target.value),onBlur:Ne,onKeyDown:G=>{G.key==="Enter"&&Ne(),G.key==="Escape"&&me(null)},autoFocus:!0,onClick:G=>G.stopPropagation()}):$?$(C):e.jsxs(e.Fragment,{children:[C.icon&&e.jsx("span",{className:"nice-tree__icon",children:C.icon}),e.jsx("span",{className:"nice-tree__text",children:C.text})]})]}),ne&&ne.length>0&&T&&e.jsx("ul",{className:"nice-tree__children",role:"group",children:ne.map(G=>X(G,xe+1))})]},C.key)};return e.jsxs("div",{className:`nice-tree ${U?"nice-tree--lines":""} ${Z||""}`,style:L,ref:K,onClick:()=>ge(null),children:[o&&e.jsx("div",{className:"nice-tree__search",children:e.jsx("input",{type:"text",value:re,onChange:C=>O(C.target.value),placeholder:y||J("controls.search","Search..."),"aria-label":y||J("controls.search","Search tree")})}),p?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:t.map(C=>X(C,0))}),W&&F&&e.jsx("div",{className:"nice-tree__context-menu",style:{position:"fixed",top:W.y,left:W.x,zIndex:9999},children:F.map(C=>e.jsxs("div",{className:`nice-tree__context-item ${C.disabled?"nice-tree__context-item--disabled":""}`,onClick:()=>{C.disabled||(Y==null||Y(C.key,W.node),ge(null))},children:[C.icon&&e.jsx("span",{children:C.icon}),C.label]},C.key))})]})};function gi(t,r,a){const l=new Map,s=[];return t.forEach(u=>{const m={...u,children:[]};l.set(String(m[r]),m)}),t.forEach(u=>{const m=u[a];m!=null&&l.has(String(m))?l.get(String(m)).children.push(l.get(String(u[r]))):s.push(l.get(String(u[r])))}),s}function fi({columns:t,data:r,keyField:a="key",parentKeyField:l="parentKey",expandedKeys:s,onExpandedChange:u,selectedKeys:m=[],onSelectionChange:o,selectable:y,loading:A,emptyText:$,className:U,style:p,accessMode:Z,id:L}){if(ae.ei(Z,L)==="hidden")return null;const{t:q}=ae.de(),[x,v]=n.useState([]),_=s??x,b=n.useMemo(()=>gi(r,a,l),[r,a,l]),F=n.useMemo(()=>t.filter(J=>!J.hidden),[t]),Y=n.useCallback(J=>{const S=_.includes(J)?_.filter(oe=>oe!==J):[..._,J];u?u(S):v(S)},[_,u]),V=n.useCallback(J=>{o&&o(m.includes(J)?m.filter(S=>S!==J):[...m,J])},[m,o]),ue=(J,S)=>{const oe=String(J[a]),re=J.children&&J.children.length>0,O=_.includes(oe),de=m.includes(oe);return e.jsxs(n.Fragment,{children:[e.jsxs("tr",{className:de?"nice-treelist__row--selected":"",children:[y&&e.jsx("td",{className:"nice-treelist__checkbox",children:e.jsx("input",{type:"checkbox",checked:de,onChange:()=>V(oe)})}),F.map((z,N)=>e.jsxs("td",{style:{textAlign:z.align},children:[N===0&&e.jsx("span",{style:{display:"inline-block",width:S*20}}),N===0&&e.jsx("span",{className:"nice-treelist__toggle",onClick:()=>re&&Y(oe),style:{cursor:re?"pointer":"default",width:20,display:"inline-block"},children:re?O?"▾":"▸":""}),z.render?z.render(J[z.field],J,0):String(J[z.field]??"")]},z.field))]}),re&&O&&J.children.map(z=>ue(z,S+1))]},oe)};return e.jsx("div",{className:`nice-treelist ${U||""}`,style:p,children:e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[y&&e.jsx("th",{className:"nice-treelist__checkbox"}),F.map(J=>e.jsx("th",{style:{width:J.width,minWidth:J.minWidth,textAlign:J.align},children:J.header},J.field))]})}),e.jsx("tbody",{children:A?e.jsx("tr",{children:e.jsx("td",{colSpan:F.length+(y?1:0),className:"nice-treelist__empty",children:e.jsx("div",{className:"nice-spinner nice-spinner--md",style:{margin:"0 auto"}})})}):b.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:F.length+(y?1:0),className:"nice-treelist__empty",children:$||q("controls.noData","No data available")})}):b.map(J=>ue(J,0))})]})})}function _i({items:t,renderCard:r,columns:a=3,gap:l=16,searchable:s,searchField:u="text",searchPlaceholder:m,loading:o,emptyText:y,onCardClick:A,className:$,style:U,accessMode:p,id:Z}){if(ae.ei(p,Z)==="hidden")return null;const{t:L}=ae.de(),[q,x]=n.useState(""),v=n.useMemo(()=>{if(!q)return t;const _=q.toLowerCase();return t.filter(b=>String(b[u]??"").toLowerCase().includes(_))},[t,q,u]);return e.jsxs("div",{className:`nice-cardview ${$||""}`,style:U,children:[s&&e.jsx("div",{className:"nice-cardview__search",children:e.jsx("input",{type:"text",value:q,onChange:_=>x(_.target.value),placeholder:m||L("controls.search","Search...")})}),o?e.jsx("div",{className:"nice-cardview__loading",children:e.jsx("div",{className:"nice-spinner nice-spinner--md"})}):v.length===0?e.jsx("div",{className:"nice-cardview__empty",children:y||L("controls.noData","No data available")}):e.jsx("div",{className:"nice-cardview__grid",style:{display:"grid",gridTemplateColumns:`repeat(${a}, 1fr)`,gap:l},children:v.map(_=>e.jsx("div",{className:"nice-cardview__card",onClick:()=>A==null?void 0:A(_),style:A?{cursor:"pointer"}:void 0,children:r(_)},_.key))})]})}function xi({items:t,tileWidth:r=180,tileHeight:a=180,direction:l="horizontal",renderTile:s,onTileClick:u,loading:m,emptyText:o,className:y,style:A}){const{t:$}=ae.de();return e.jsx("div",{className:`nice-tileview nice-tileview--${l} ${y||""}`,style:A,children:m?e.jsx("div",{className:"nice-tileview__loading",children:e.jsx("div",{className:"nice-spinner nice-spinner--md"})}):t.length===0?e.jsx("div",{className:"nice-tileview__empty",children:o||$("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:t.map(U=>e.jsx("div",{className:"nice-tileview__tile",style:{width:r,height:a,cursor:u?"pointer":void 0},onClick:()=>u==null?void 0:u(U),children:s?s(U):e.jsxs(e.Fragment,{children:[U.image&&e.jsx("img",{src:U.image,alt:U.text||"",className:"nice-tileview__image"}),U.text&&e.jsx("div",{className:"nice-tileview__label",children:U.text})]})},U.key))})})}const It=[{key:"row",label:"Rows"},{key:"column",label:"Columns"},{key:"data",label:"Values"},{key:"filter",label:"Filters"}],Bt=({fields:t,onChange:r,className:a,style:l})=>{const s=t.filter(o=>!o.area),u=(o,y)=>{r(t.map(A=>A.field===o?{...A,area:y}:A))},m=o=>{r(t.map(y=>y.field===o?{...y,area:void 0}:y))};return e.jsx("div",{className:`nice-field-chooser ${a||""}`,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:s.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:It.map(y=>e.jsx("button",{type:"button",className:"nice-btn nice-btn--ghost nice-btn--sm",onClick:()=>u(o.field,y.key),children:y.label},y.key))})]},o.field))})]}),It.map(o=>{const y=t.filter(A=>A.area===o.key);return e.jsxs("div",{className:"nice-field-chooser__section",children:[e.jsx("h4",{children:o.label}),e.jsx("ul",{children:y.map(A=>e.jsxs("li",{className:"nice-field-chooser__item",children:[e.jsx("span",{children:A.caption}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--ghost nice-btn--sm",onClick:()=>m(A.field),children:"✕"})]},A.field))})]},o.key)})]})})};function bi(t,r){if(t.length===0)return 0;switch(r){case"sum":return t.reduce((a,l)=>a+l,0);case"count":return t.length;case"avg":return t.reduce((a,l)=>a+l,0)/t.length;case"min":return Math.min(...t);case"max":return Math.max(...t);default:return t.reduce((a,l)=>a+l,0)}}function Ot(t,r){return[...new Set(t.map(a=>String(a[r]??"")))].sort()}const Kt=({data:t,fields:r,onFieldsChange:a,showFieldChooser:l,loading:s,emptyText:u,exportCsv:m,exportFilename:o="pivot-export",onDrillThrough:y,className:A,style:$,accessMode:U,id:p})=>{if(ae.ei(U,p)==="hidden")return null;const{t:Z}=ae.de(),[L,q]=n.useState(r),[x,v]=n.useState(!1),_=n.useMemo(()=>L.filter(O=>O.area==="row"),[L]),b=n.useMemo(()=>L.filter(O=>O.area==="column"),[L]),F=n.useMemo(()=>L.filter(O=>O.area==="data"),[L]),Y=n.useMemo(()=>_.length===0?["Total"]:Ot(t,_[0].field),[t,_]),V=n.useMemo(()=>b.length===0?["Total"]:Ot(t,b[0].field),[t,b]),ue=n.useCallback((O,de,z)=>{let N=t;_.length>0&&(N=N.filter(_e=>String(_e[_[0].field])===O)),b.length>0&&(N=N.filter(_e=>String(_e[b[0].field])===de));const B=N.map(_e=>Number(_e[z.field])||0),f=bi(B,z.summaryType||"sum");return z.format?z.format(f):f},[t,_,b]),J=n.useCallback(O=>{q(O),a==null||a(O)},[a]),S=n.useCallback((O,de)=>{let z=t;return _.length>0&&(z=z.filter(N=>String(N[_[0].field])===O)),b.length>0&&(z=z.filter(N=>String(N[b[0].field])===de)),z},[t,_,b]),oe=n.useCallback((O,de)=>{y&&y(O,de,S(O,de))},[y,S]),re=n.useCallback(()=>{const O=["",...V.flatMap(_e=>F.length>0?F.map(W=>`${_e} - ${W.caption}`):[_e])],de=Y.map(_e=>{const W=V.flatMap(ge=>F.length>0?F.map(ee=>String(ue(_e,ge,ee))):["—"]);return[_e,...W]}),z=[O,...de].map(_e=>_e.map(W=>`"${String(W).replace(/"/g,'""')}"`).join(",")).join(`
|
|
15
|
+
`),N=new Blob(["\uFEFF"+z],{type:"text/csv;charset=utf-8;"}),B=URL.createObjectURL(N),f=document.createElement("a");f.href=B,f.download=`${o}.csv`,f.click(),URL.revokeObjectURL(B)},[V,Y,F,ue,o]);return e.jsxs("div",{className:`nice-pivotgrid ${A||""}`,style:$,children:[(l||m)&&e.jsxs("div",{className:"nice-pivotgrid__toolbar",children:[l&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",onClick:()=>v(!x),children:Z("controls.fieldChooser","Field Chooser")}),m&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--sm",onClick:re,children:"CSV ↓"})]}),x&&e.jsx(Bt,{fields:L,onChange:J}),s?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:_.map(O=>O.caption).join(" / ")||""}),V.map(O=>e.jsx("th",{colSpan:F.length||1,children:O},O))]}),F.length>1&&e.jsxs("tr",{children:[e.jsx("th",{}),V.map(O=>F.map(de=>e.jsx("th",{children:de.caption},`${O}-${de.field}`)))]})]}),e.jsx("tbody",{children:Y.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:1+V.length*Math.max(F.length,1),className:"nice-pivotgrid__empty",children:u||Z("controls.noData","No data available")})}):Y.map(O=>e.jsxs("tr",{children:[e.jsx("td",{className:"nice-pivotgrid__row-header",children:O}),V.map(de=>F.length>0?F.map(z=>e.jsx("td",{className:`nice-pivotgrid__cell ${y?"nice-pivotgrid__cell--clickable":""}`,onClick:y?()=>oe(O,de):void 0,children:ue(O,de,z)},`${de}-${z.field}`)):e.jsx("td",{className:"nice-pivotgrid__cell",children:"—"},de))]},O))})]})})]})},yi=Object.freeze(Object.defineProperty({__proto__:null,NicePivotGrid:Kt},Symbol.toStringTag,{value:"Module"})),Ht=n.forwardRef(({columns:t,cards:r,onCardMove:a,onCardClick:l,renderCard:s,onAddCard:u,disabled:m=!1,size:o="md",collapsible:y=!1,viewMode:A,onViewModeChange:$,collapsedColumns:U,onCollapsedColumnsChange:p,cookies:Z=!1,localStorage:L=!0,sessionStorage:q=!1,storageMode:x,storageKey:v,className:_,style:b,id:F,...Y},V)=>{const{t:ue}=ae.de(),[J,S]=n.useState(null),[oe,re]=n.useState(null),O=ae.Ke(v??"nice-kanban"),[de,z]=n.useState(()=>O.get("state")??{collapsedColumns:[],viewMode:"default"}),N=U??de.collapsedColumns??[],B=A??de.viewMode??"default",f=n.useCallback(K=>{z(he=>{const je={...he,...K};return O.set("state",je),je})},[O]),_e=n.useCallback(K=>{const he=N.includes(K)?N.filter(je=>je!==K):[...N,K];p?p(he):f({collapsedColumns:he})},[N,p,f]);n.useCallback(K=>{$?$(K):f({viewMode:K})},[$,f]);const W=n.useCallback(K=>r.filter(he=>he.column===K).sort((he,je)=>(he.order??0)-(je.order??0)),[r]),ge=n.useCallback((K,he)=>{m||(K.dataTransfer.effectAllowed="move",K.dataTransfer.setData("text/plain",String(he.key)),S({cardKey:he.key,fromColumn:he.column}))},[m]),ee=n.useCallback((K,he)=>{K.preventDefault(),K.dataTransfer.dropEffect="move",re({column:he})},[]),me=n.useCallback(()=>{re(null)},[]),H=n.useCallback((K,he)=>{if(K.preventDefault(),re(null),!J||m)return;const je=W(he);a==null||a(J.cardKey,he,je.length),S(null)},[J,m,W,a]),ve=n.useCallback(()=>{S(null),re(null)},[]);return e.jsx("div",{ref:V,id:F,className:`nice-kanban nice-kanban--${o} nice-kanban--${B} ${m?"nice-kanban--disabled":""} ${_||""}`,style:b,...Y,children:t.map(K=>{const he=W(K.key),je=(oe==null?void 0:oe.column)===K.key,Oe=K.limit!=null&&he.length>=K.limit,We=y&&N.includes(K.key);return e.jsxs("div",{className:`nice-kanban__column ${je?"nice-kanban__column--dragover":""} ${We?"nice-kanban__column--collapsed":""}`,onDragOver:we=>!We&&ee(we,K.key),onDragLeave:me,onDrop:we=>!We&&H(we,K.key),children:[e.jsxs("div",{className:"nice-kanban__column-header",style:K.color?{borderTopColor:K.color}:void 0,onClick:y?()=>_e(K.key):void 0,role:y?"button":void 0,tabIndex:y?0:void 0,onKeyDown:y?we=>{(we.key==="Enter"||we.key===" ")&&_e(K.key)}:void 0,children:[y&&e.jsx("span",{className:"nice-kanban__collapse-icon","aria-hidden":"true",children:We?"▶":"▼"}),e.jsx("span",{className:"nice-kanban__column-title",children:K.title}),e.jsxs("span",{className:"nice-kanban__column-count",children:[he.length,K.limit!=null&&` / ${K.limit}`]})]}),!We&&e.jsxs("div",{className:"nice-kanban__column-body",children:[he.map(we=>e.jsx("div",{className:`nice-kanban__card nice-kanban__card--${B} ${(J==null?void 0:J.cardKey)===we.key?"nice-kanban__card--dragging":""}`,draggable:!m,onDragStart:qe=>ge(qe,we),onDragEnd:ve,onClick:()=>l==null?void 0:l(we),role:"article",children:s?s(we):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"nice-kanban__card-title",children:we.title}),B!=="compact"&&we.description&&e.jsx("div",{className:"nice-kanban__card-desc",children:we.description})]})},we.key)),he.length===0&&e.jsx("div",{className:"nice-kanban__empty",children:ue("kanban.empty","No cards")})]}),!We&&u&&!Oe&&e.jsxs("button",{type:"button",className:"nice-kanban__add",onClick:()=>u(K.key),disabled:m,children:["+ ",ue("kanban.addCard","Add card")]})]},K.key)})})});Ht.displayName="NiceKanbanBoard";function Dn(...t){return t.filter(Boolean).map(r=>typeof r=="object"?Object.entries(r).filter(([,a])=>a).map(([a])=>a).join(" "):r).join(" ")}const vi=50,wi=[10,25,50,100,200],ki=40,ji=10,Ni=768,Ci=500,Si=10;function wn(t,r){return r.split(".").reduce((a,l)=>a==null?void 0:a[l],t)}function at(t,r,a="pl-PL"){var l,s,u;if(t==null)return"—";switch(r.type){case"number":return new Intl.NumberFormat(a,{minimumFractionDigits:(l=r.format)!=null&&l.includes(".")?r.format.split(".")[1].length:0}).format(t);case"currency":return new Intl.NumberFormat(a,{style:"currency",currency:r.currencyCode||"PLN"}).format(t);case"percent":return new Intl.NumberFormat(a,{style:"percent",minimumFractionDigits:0,maximumFractionDigits:2}).format(t/100);case"date":return new Intl.DateTimeFormat(a,{dateStyle:"short"}).format(new Date(t));case"datetime":return new Intl.DateTimeFormat(a,{dateStyle:"short",timeStyle:"short"}).format(new Date(t));case"boolean":return t?"✓":"✗";case"enum":return((u=(s=r.enumOptions)==null?void 0:s.find(m=>m.value===t))==null?void 0:u.label)||String(t);default:return String(t)}}function Mi(t,r,a,l){const[s,u]=n.useState(0),{startIndex:m,endIndex:o,totalHeight:y,offsetY:A}=n.useMemo(()=>{const p=t.length*a,Z=Math.ceil(r/a),L=Math.max(0,Math.floor(s/a)-l),q=Math.min(t.length,Math.ceil(s/a)+Z+l),x=L*a;return{startIndex:L,endIndex:q,totalHeight:p,offsetY:x}},[t.length,r,a,s,l]),$=n.useMemo(()=>t.slice(m,o),[t,m,o]),U=n.useCallback(p=>{u(p.currentTarget.scrollTop)},[]);return{visibleData:$,totalHeight:y,offsetY:A,handleScroll:U,startIndex:m}}function $i(t,r){const[a,l]=n.useState(()=>{if(t&&typeof window<"u"){const u=localStorage.getItem(`nice-module-grid-${t}`);if(u)return JSON.parse(u)}return r||{}}),s=n.useCallback(u=>{l(m=>{const o={...m,...u};return t&&typeof window<"u"&&localStorage.setItem(`nice-module-grid-${t}`,JSON.stringify(o)),o})},[t]);return[a,s]}function Di(t){const[r,a]=n.useState(typeof window<"u"&&window.innerWidth<t);return n.useEffect(()=>{if(typeof window>"u")return;const l=()=>a(window.innerWidth<t);return window.addEventListener("resize",l),()=>window.removeEventListener("resize",l)},[t]),r}function Ai({column:t,sort:r,onSort:a,onResize:l,resizable:s,t:u}){const m=n.useRef(null),[o,y]=n.useState(!1),A=n.useCallback(p=>{if(!s||!l)return;p.preventDefault(),y(!0);const Z=p.clientX,L=t.width||150,q=v=>{const _=v.clientX-Z,b=Math.max(t.minWidth||50,L+_);l(t.field,Math.min(b,t.maxWidth||1/0))},x=()=>{y(!1),document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",x)};document.addEventListener("mousemove",q),document.addEventListener("mouseup",x)},[t,s,l]),$=r==null?void 0:r.direction,U=$==="asc"?"↑":$==="desc"?"↓":null;return e.jsxs("div",{className:Dn("nice-module-grid__header-cell",t.sortable&&"nice-module-grid__header-cell--sortable",o&&"nice-module-grid__header-cell--resizing"),style:{width:t.width==="auto"?"auto":t.width||150,minWidth:t.minWidth,maxWidth:t.maxWidth,textAlign:t.align},onClick:()=>t.sortable&&(a==null?void 0:a(t.field)),role:"columnheader","aria-sort":$==="asc"?"ascending":$==="desc"?"descending":"none",title:t.headerTooltip,children:[e.jsx("span",{className:"nice-module-grid__header-text",children:t.header}),U&&e.jsx("span",{className:"nice-module-grid__sort-indicator",children:U}),s&&e.jsx("div",{ref:m,className:"nice-module-grid__resize-handle",onMouseDown:A})]})}function Fi({column:t,row:r,rowIndex:a,value:l,locale:s="pl-PL",onClick:u}){if(t.render)return e.jsx("div",{className:"nice-module-grid__cell",style:{textAlign:t.align},onClick:u,children:t.render(l,r,a)});if(t.type==="enum"&&t.enumOptions){const m=t.enumOptions.find(o=>o.value===l);if(m)return e.jsx("div",{className:"nice-module-grid__cell",style:{textAlign:t.align},onClick:u,children:e.jsxs("span",{className:Dn("nice-module-grid__badge",`nice-module-grid__badge--${m.color||"default"}`),children:[m.icon&&e.jsx("span",{className:"nice-module-grid__badge-icon",children:m.icon}),m.label]})})}if(t.type==="progress"){const m=Math.min(100,Math.max(0,Number(l)||0));return e.jsx("div",{className:"nice-module-grid__cell",style:{textAlign:t.align},onClick:u,children:e.jsxs("div",{className:"nice-module-grid__progress",children:[e.jsx("div",{className:Dn("nice-module-grid__progress-bar",`nice-module-grid__progress-bar--${t.progressColor||"primary"}`),style:{width:`${m}%`}}),e.jsxs("span",{className:"nice-module-grid__progress-text",children:[m,"%"]})]})})}if(t.type==="rating"){const m=t.maxRating||5,o=Number(l)||0;return e.jsx("div",{className:"nice-module-grid__cell",style:{textAlign:t.align},onClick:u,children:e.jsx("span",{className:"nice-module-grid__rating","aria-label":`${o} out of ${m} stars`,children:Array.from({length:m},(y,A)=>e.jsx("span",{className:Dn("nice-module-grid__star",A<o&&"nice-module-grid__star--filled"),children:"★"},A))})})}if(t.type==="link"&&t.linkTemplate){const m=t.linkTemplate.replace(/\{\{(\w+)\}\}/g,(o,y)=>wn(r,y)||"");return e.jsx("div",{className:"nice-module-grid__cell",style:{textAlign:t.align},onClick:u,children:e.jsx("a",{href:m,target:t.linkNewTab?"_blank":void 0,rel:t.linkNewTab?"noopener noreferrer":void 0,className:"nice-module-grid__link",children:at(l,t,s)})})}if(t.type==="image"){const m={xs:24,sm:32,md:48,lg:64}[t.imageSize||"sm"];return e.jsx("div",{className:"nice-module-grid__cell",style:{textAlign:t.align},onClick:u,children:l?e.jsx("img",{src:l,alt:"",className:"nice-module-grid__image",style:{width:m,height:m}}):e.jsx("div",{className:"nice-module-grid__image-placeholder",style:{width:m,height:m}})})}return t.type==="avatar"?e.jsx("div",{className:"nice-module-grid__cell",style:{textAlign:t.align},onClick:u,children:l?e.jsx("img",{src:l,alt:"",className:"nice-module-grid__avatar"}):e.jsx("div",{className:"nice-module-grid__avatar-placeholder",children:"?"})}):t.type==="color"?e.jsx("div",{className:"nice-module-grid__cell",style:{textAlign:t.align},onClick:u,children:e.jsx("span",{className:"nice-module-grid__color-swatch",style:{backgroundColor:l||"transparent"},title:l})}):t.type==="boolean"?e.jsx("div",{className:"nice-module-grid__cell",style:{textAlign:t.align||"center"},onClick:u,children:e.jsx("span",{className:Dn("nice-module-grid__boolean",l&&"nice-module-grid__boolean--true"),children:l?"✓":"✗"})}):e.jsx("div",{className:"nice-module-grid__cell",style:{textAlign:t.align},onClick:u,children:at(l,t,s)})}function Ei({row:t,index:r,columns:a,primaryField:l,secondaryField:s,customRender:u,selected:m,onClick:o,locale:y="pl-PL",t:A}){if(u)return e.jsx("div",{className:Dn("nice-module-grid__mobile-card",m&&"nice-module-grid__mobile-card--selected"),onClick:o,children:u(t,r)});const $=a.find(p=>p.field===l)||a[0],U=a.find(p=>p.field===s)||a[1];return e.jsxs("div",{className:Dn("nice-module-grid__mobile-card",m&&"nice-module-grid__mobile-card--selected"),onClick:o,role:"row","aria-selected":m,children:[e.jsxs("div",{className:"nice-module-grid__mobile-card-header",children:[e.jsx("div",{className:"nice-module-grid__mobile-card-title",children:at(wn(t,($==null?void 0:$.field)||""),$,y)}),U&&e.jsx("div",{className:"nice-module-grid__mobile-card-subtitle",children:at(wn(t,U.field),U,y)})]}),e.jsx("div",{className:"nice-module-grid__mobile-card-body",children:a.filter(p=>!p.hidden&&p.field!==l&&p.field!==s).slice(0,4).map(p=>e.jsxs("div",{className:"nice-module-grid__mobile-card-field",children:[e.jsx("span",{className:"nice-module-grid__mobile-card-label",children:p.header}),e.jsx("span",{className:"nice-module-grid__mobile-card-value",children:at(wn(t,p.field),p,y)})]},p.field))})]})}function Ri({page:t,pageSize:r,totalRows:a,pageSizeOptions:l,onPageChange:s,t:u}){const m=Math.ceil(a/r),o=(t-1)*r+1,y=Math.min(t*r,a);return e.jsxs("div",{className:"nice-module-grid__pagination",role:"navigation","aria-label":u("pagination.ariaLabel","Pagination"),children:[e.jsxs("div",{className:"nice-module-grid__pagination-info",children:[u("pagination.showing","Showing")," ",o,"–",y," ",u("pagination.of","of")," ",a]}),e.jsxs("div",{className:"nice-module-grid__pagination-controls",children:[e.jsx("select",{className:"nice-module-grid__page-size-select",value:r,onChange:A=>s(1,Number(A.target.value)),"aria-label":u("pagination.rowsPerPage","Rows per page"),children:l.map(A=>e.jsx("option",{value:A,children:A},A))}),e.jsx("button",{className:"nice-module-grid__pagination-btn",onClick:()=>s(1,r),disabled:t===1,"aria-label":u("pagination.first","First"),children:"««"}),e.jsx("button",{className:"nice-module-grid__pagination-btn",onClick:()=>s(t-1,r),disabled:t===1,"aria-label":u("pagination.previous","Previous"),children:"«"}),e.jsxs("span",{className:"nice-module-grid__pagination-page",children:[t," / ",m]}),e.jsx("button",{className:"nice-module-grid__pagination-btn",onClick:()=>s(t+1,r),disabled:t>=m,"aria-label":u("pagination.next","Next"),children:"»"}),e.jsx("button",{className:"nice-module-grid__pagination-btn",onClick:()=>s(m,r),disabled:t>=m,"aria-label":u("pagination.last","Last"),children:"»»"})]})]})}function Ti({columns:t}){return e.jsx("div",{className:"nice-module-grid__row nice-module-grid__row--skeleton",role:"row",children:t.filter(r=>!r.hidden).map(r=>e.jsx("div",{className:"nice-module-grid__cell nice-module-grid__cell--skeleton",style:{width:r.width==="auto"?"auto":r.width||150},children:e.jsx("div",{className:"nice-module-grid__skeleton-bar"})},r.field))})}function Li(t,r){var tt;const{columns:a,data:l,keyField:s="id",dataSource:u,onFetch:m,sortable:o=!0,sort:y,onSortChange:A,multiSort:$=!1,filterable:U=!1,filter:p,onFilterChange:Z,searchText:L,onSearchChange:q,searchPlaceholder:x="moduleGrid.searchPlaceholder",pagination:v=!0,page:_,pageSize:b,pageSizeOptions:F=wi,totalRows:Y,onPageChange:V,virtualScroll:ue=!0,rowHeight:J=ki,overscan:S=ji,selectionMode:oe="none",selectedKeys:re,onSelectionChange:O,columnReorder:de=!0,onColumnOrderChange:z,columnResize:N=!0,onColumnWidthChange:B,groupBy:f,onGroupByChange:_e,groupRowRender:W,expandAllGroups:ge=!1,editable:ee=!1,onCellEdit:me,onRowEdit:H,editMode:ve="cell",contextMenuItems:K,onContextMenuAction:he,exportable:je=!0,exportFormats:Oe=["csv","excel"],onExport:We,preferencesKey:we,initialPreferences:qe,onPreferencesChange:Ne,density:X="normal",striped:C=!0,bordered:xe=!1,hoverable:ne=!0,loading:pe=!1,emptyState:T,toolbar:Ee,onRowClick:Re,onRowDoubleClick:De,rowClassName:G,rowStyle:bn,mobileCardView:An=!0,mobileBreakpoint:ke=Ni,mobileCardRender:M,mobilePrimaryField:se,mobileSecondaryField:le,moduleId:He,permissions:kn,size:Ce="medium",skeletonLoading:Le=!0,skeletonRows:an=Si,"aria-label":rn,"aria-labelledby":en,"aria-describedby":on,className:Qn,style:Kn,id:Fn,testId:Pn}=t,{t:ze}=ae.de();ae.ei(),ae.ll("table");const Ze=Di(ke),[Ge,zn]=$i(we,qe),En=n.useRef(null),Hn=n.useRef(null),[Vn,Zn]=n.useState([]),[gn,rt]=n.useState(),[qn,In]=n.useState(""),[Gn,dn]=n.useState(1),[Yn,ln]=n.useState(b||vi),[On,Nn]=n.useState(new Set),[Cn,Rn]=n.useState([]),[c,d]=n.useState(0),[j,I]=n.useState(!1),[Q,w]=n.useState(new Set),[E,P]=n.useState(null),[Ie,Se]=n.useState({}),te=y??Vn,Ve=p??gn,sn=L??qn,fn=_??Gn,cn=b??Yn,_n=re??On,lt=Y??c??(l==null?void 0:l.length)??0,Tn=!!(m||u),Sn=n.useMemo(()=>{const g=new Set(Ge.hiddenColumns||[]);return a.filter(fe=>!fe.hidden&&!g.has(fe.field))},[a,Ge.hiddenColumns]),Xn=n.useMemo(()=>{if(Tn)return Cn;if(!l)return[];let g=[...l];if(sn){const fe=sn.toLowerCase(),be=a.filter(Me=>Me.searchable!==!1).map(Me=>Me.field);g=g.filter(Me=>be.some(Ue=>{const xn=wn(Me,Ue);return String(xn??"").toLowerCase().includes(fe)}))}return te.length>0&&g.sort((fe,be)=>{for(const Me of te){const Ue=wn(fe,Me.field),xn=wn(be,Me.field),mn=Ue<xn?-1:Ue>xn?1:0;if(mn!==0)return Me.direction==="asc"?mn:-mn}return 0}),g},[Tn,Cn,l,sn,te,a]),Wn=n.useMemo(()=>{if(Tn||!v)return Xn;const g=(fn-1)*cn;return Xn.slice(g,g+cn)},[Tn,Xn,v,fn,cn]),bt=((tt=En.current)==null?void 0:tt.clientHeight)||400,Un=ue&&Wn.length>Ci,{visibleData:jt,totalHeight:Nt,offsetY:Jn,handleScroll:nn,startIndex:Je}=Mi(Wn,bt,J,S),tn=Un?jt:Wn,st=n.useCallback(async()=>{if(m){I(!0);try{const g=await m({page:fn,pageSize:cn,sort:te,filter:Ve,search:sn});Rn(g.data),d(g.total)}catch(g){console.error("NiceModuleGrid fetch error:",g)}finally{I(!1)}}},[m,fn,cn,te,Ve,sn]);n.useEffect(()=>{Tn&&st()},[Tn,st]);const ct=n.useCallback(g=>{const fe=te.find(Me=>Me.field===g);let be;fe?fe.direction==="asc"?be=te.map(Me=>Me.field===g?{...Me,direction:"desc"}:Me):be=te.filter(Me=>Me.field!==g):be=$?[...te,{field:g,direction:"asc"}]:[{field:g,direction:"asc"}],A?A(be):Zn(be)},[te,$,A]),ot=n.useCallback((g,fe)=>{V?V(g,fe):(dn(g),ln(fe))},[V]),jn=n.useCallback(g=>{q?q(g):In(g),V||dn(1)},[q,V]),un=n.useCallback((g,fe)=>{const be=new Set(_n);if(oe==="single"?(be.clear(),be.add(g)):(oe==="multiple"||oe==="checkbox")&&(be.has(g)?be.delete(g):be.add(g)),O){const Me=Wn.filter(Ue=>be.has(String(wn(Ue,s))));O(be,Me)}else Nn(be)},[_n,oe,O,Wn,s]),Mn=n.useCallback((g,fe)=>{Se(be=>({...be,[g]:fe})),B==null||B(g,fe),zn({columnWidths:{...Ge.columnWidths,[g]:fe}})},[B,zn,Ge.columnWidths]),hn=n.useCallback((g,fe)=>{K!=null&&K.length&&(g.preventDefault(),P({x:g.clientX,y:g.clientY,row:fe}))},[K]),pn=n.useCallback(g=>{E&&(he==null||he(g,E.row)),P(null)},[E,he]),et=n.useCallback(async g=>{if(We)await We(g,{selectedOnly:_n.size>0,columns:Sn.map(fe=>fe.field)});else if(g==="csv"){const fe=Sn.map(Ye=>Ye.header).join(","),be=Wn.map(Ye=>Sn.map(ut=>JSON.stringify(wn(Ye,ut.field)??"")).join(",")),Me=[fe,...be].join(`
|
|
16
|
+
`),Ue=new Blob([Me],{type:"text/csv;charset=utf-8;"}),xn=URL.createObjectURL(Ue),mn=document.createElement("a");mn.href=xn,mn.download=`export-${new Date().toISOString().slice(0,10)}.csv`,mn.click(),URL.revokeObjectURL(xn)}},[We,_n,Sn,Wn,ze]);n.useEffect(()=>{if(!E)return;const g=()=>P(null);return document.addEventListener("click",g),()=>document.removeEventListener("click",g)},[E]);const nt=n.useCallback(g=>{g.key==="Escape"&&P(null)},[]),Ln=pe||j,Fe=!Ln&&tn.length===0,dt=Ze&&An,Bn=Dn("nice-module-grid",`nice-module-grid--${X}`,`nice-module-grid--${Ce}`,C&&"nice-module-grid--striped",xe&&"nice-module-grid--bordered",ne&&"nice-module-grid--hoverable",Ln&&"nice-module-grid--loading",dt&&"nice-module-grid--mobile",Qn);return e.jsxs("div",{ref:r,id:Fn,"data-testid":Pn,className:Bn,style:Kn,onKeyDown:nt,role:"grid","aria-label":rn,"aria-labelledby":en,"aria-describedby":on,"aria-rowcount":lt,"aria-colcount":Sn.length,"aria-busy":Ln,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:x,value:sn,onChange:g=>jn(g.target.value),"aria-label":ze("moduleGrid.searchAriaLabel","Search")})}),Ee,je&&e.jsx("div",{className:"nice-module-grid__toolbar-export",children:Oe.map(g=>e.jsx("button",{className:"nice-module-grid__export-btn",onClick:()=>et(g),"aria-label":ze(`moduleGrid.export.${g}`,`Export to ${g.toUpperCase()}`),children:g.toUpperCase()},g))})]}),e.jsx("div",{ref:En,className:"nice-module-grid__container",onScroll:Un?nn:void 0,children:dt?e.jsx("div",{className:"nice-module-grid__mobile-list",children:Ln&&Le?Array.from({length:an},(g,fe)=>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}})]},fe)):Fe?e.jsxs("div",{className:"nice-module-grid__empty",children:[(T==null?void 0:T.icon)&&e.jsx("div",{className:"nice-module-grid__empty-icon",children:T.icon}),e.jsx("div",{className:"nice-module-grid__empty-title",children:(T==null?void 0:T.title)||ze("moduleGrid.noData","No data")}),(T==null?void 0:T.description)&&e.jsx("div",{className:"nice-module-grid__empty-description",children:T.description}),(T==null?void 0:T.action)&&e.jsxs("button",{className:"nice-module-grid__empty-action",onClick:T.action.onClick,children:[T.action.icon,T.action.label]})]}):tn.map((g,fe)=>{const be=String(wn(g,s));return e.jsx(Ei,{row:g,index:Je+fe,columns:Sn,primaryField:se,secondaryField:le,customRender:M,selected:_n.has(be),onClick:()=>{oe!=="none"&&un(be,g),Re==null||Re(g,Je+fe)},t:ze},be)})}):e.jsxs("div",{ref:Hn,className:"nice-module-grid__table",children:[e.jsxs("div",{className:"nice-module-grid__header",role:"row",children:[oe==="checkbox"&&e.jsx("div",{className:"nice-module-grid__header-cell nice-module-grid__header-cell--checkbox",children:e.jsx("input",{type:"checkbox",checked:_n.size>0&&_n.size===tn.length,onChange:()=>{if(_n.size===tn.length)O==null||O(new Set,[]),Nn(new Set);else{const g=new Set(tn.map(fe=>String(wn(fe,s))));O==null||O(g,tn),Nn(g)}},"aria-label":ze("moduleGrid.selectAll","Select all")})}),Sn.map(g=>e.jsx(Ai,{column:{...g,width:Ie[g.field]||g.width},sort:te.find(fe=>fe.field===g.field),onSort:o?ct:void 0,onResize:N?Mn:void 0,resizable:N,t:ze},g.field))]}),e.jsx("div",{className:"nice-module-grid__body",style:Un?{height:Nt,position:"relative"}:void 0,children:Ln&&Le?Array.from({length:an},(g,fe)=>e.jsx(Ti,{columns:Sn},fe)):Fe?e.jsxs("div",{className:"nice-module-grid__empty",children:[(T==null?void 0:T.icon)&&e.jsx("div",{className:"nice-module-grid__empty-icon",children:T.icon}),e.jsx("div",{className:"nice-module-grid__empty-title",children:(T==null?void 0:T.title)||ze("moduleGrid.noData","No data")}),(T==null?void 0:T.description)&&e.jsx("div",{className:"nice-module-grid__empty-description",children:T.description}),(T==null?void 0:T.action)&&e.jsxs("button",{className:"nice-module-grid__empty-action",onClick:T.action.onClick,children:[T.action.icon,T.action.label]})]}):e.jsx("div",{style:Un?{transform:`translateY(${Jn}px)`}:void 0,children:tn.map((g,fe)=>{const be=String(wn(g,s)),Me=Je+fe,Ue=_n.has(be),xn=typeof G=="function"?G(g,Me):G,mn=typeof bn=="function"?bn(g,Me):bn;return e.jsxs("div",{className:Dn("nice-module-grid__row",Ue&&"nice-module-grid__row--selected",xn),style:{...mn,height:J},role:"row","aria-rowindex":Me+1,"aria-selected":Ue,onClick:()=>{oe!=="none"&&un(be,g),Re==null||Re(g,Me)},onDoubleClick:()=>De==null?void 0:De(g,Me),onContextMenu:Ye=>hn(Ye,g),children:[oe==="checkbox"&&e.jsx("div",{className:"nice-module-grid__cell nice-module-grid__cell--checkbox",children:e.jsx("input",{type:"checkbox",checked:Ue,onChange:()=>un(be,g),onClick:Ye=>Ye.stopPropagation(),"aria-label":ze("moduleGrid.selectRow","Select row")})}),Sn.map(Ye=>e.jsx(Fi,{column:{...Ye,width:Ie[Ye.field]||Ye.width},row:g,rowIndex:Me,value:wn(g,Ye.field)},Ye.field))]},be)})})})]})}),v&<>0&&e.jsx(Ri,{page:fn,pageSize:cn,totalRows:Tn?c:Xn.length,pageSizeOptions:F,onPageChange:ot,t:ze}),E&&K&&e.jsx("div",{className:"nice-module-grid__context-menu",style:{left:E.x,top:E.y},role:"menu",children:K.filter(g=>typeof g.hidden=="function"?!g.hidden(E.row):!g.hidden).map(g=>{if(g.divider)return e.jsx("div",{className:"nice-module-grid__context-menu-divider"},g.key);const fe=typeof g.disabled=="function"?g.disabled(E.row):g.disabled;return e.jsxs("button",{className:Dn("nice-module-grid__context-menu-item",g.danger&&"nice-module-grid__context-menu-item--danger",fe&&"nice-module-grid__context-menu-item--disabled"),onClick:()=>{var be;fe||((be=g.onClick)==null||be.call(g,E.row),pn(g.key))},disabled:fe,role:"menuitem",children:[g.icon&&e.jsx("span",{className:"nice-module-grid__context-menu-icon",children:g.icon}),g.label]},g.key)})}),Ln&&!Le&&e.jsx("div",{className:"nice-module-grid__loading-overlay",children:e.jsx("div",{className:"nice-module-grid__spinner","aria-label":ze("moduleGrid.loading","Loading")})})]})}n.forwardRef(Li);const zi=`
|
|
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: 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: 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: 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: 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: 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: 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: 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 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: 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: 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: 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: 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: 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 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(t,r="PLN",a="pl-PL"){return new Intl.NumberFormat(a,{style:"currency",currency:r,minimumFractionDigits:2,maximumFractionDigits:2}).format(t)}function _t(t,r="pl-PL"){return t?(typeof t=="string"?new Date(t):t).toLocaleDateString(r,{year:"numeric",month:"2-digit",day:"2-digit"}):"-"}function Ii(t){return t>=80?"high":t>=50?"medium":"low"}function Oi(){return`match-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function Wi({item:t,isSelected:r,isDragging:a,isDropTarget:l,suggestion:s,currency:u,locale:m,onSelect:o,onDoubleClick:y,onDragStart:A,onDragEnd:$,onDrop:U,disabled:p}){const Z=t.status??"unmatched",L=(s==null?void 0:s.confidence)??t.confidence,q=v=>{v.dataTransfer.setData("text/plain",t.id),v.dataTransfer.setData("source","statement"),v.dataTransfer.effectAllowed="move",A()},x=v=>{v.dataTransfer.types.includes("source")&&v.dataTransfer.getData("source")!=="statement"&&v.preventDefault()};return e.jsxs("div",{className:`nice-reconciliation__row nice-reconciliation__row--${Z} ${r?"nice-reconciliation__row--selected":""} ${a?"nice-reconciliation__row--dragging":""} ${l?"nice-reconciliation__row--drop-target":""}`,draggable:!p&&Z!=="matched",onDragStart:q,onDragEnd:$,onDragOver:x,onDrop:U,onClick:o,onDoubleClick:y,role:"row","aria-selected":r,tabIndex:0,children:[e.jsx("span",{className:`nice-reconciliation__status nice-reconciliation__status--${Z}`}),e.jsxs("div",{className:"nice-reconciliation__row-main",children:[e.jsx("div",{className:"nice-reconciliation__row-date",children:_t(t.date,m)}),e.jsx("div",{className:"nice-reconciliation__row-description",title:t.description,children:t.description}),t.counterparty&&e.jsx("div",{className:"nice-reconciliation__row-counterparty",children:t.counterparty})]}),L!=null&&e.jsxs("span",{className:`nice-reconciliation__confidence nice-reconciliation__confidence--${Ii(L)}`,children:[L,"%"]}),e.jsx("span",{className:`nice-reconciliation__row-amount ${t.amount>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:$n(t.amount,u,m)})]})}function Pi({item:t,isSelected:r,isDragging:a,isDropTarget:l,currency:s,locale:u,onSelect:m,onDoubleClick:o,onDragStart:y,onDragEnd:A,onDrop:$,disabled:U}){const p=t.status??"unmatched",Z=q=>{q.dataTransfer.setData("text/plain",t.id),q.dataTransfer.setData("source","entry"),q.dataTransfer.effectAllowed="move",y()},L=q=>{q.dataTransfer.types.includes("source")&&q.dataTransfer.getData("source")!=="entry"&&q.preventDefault()};return e.jsxs("div",{className:`nice-reconciliation__row nice-reconciliation__row--${p} ${r?"nice-reconciliation__row--selected":""} ${a?"nice-reconciliation__row--dragging":""} ${l?"nice-reconciliation__row--drop-target":""}`,draggable:!U&&p!=="matched",onDragStart:Z,onDragEnd:A,onDragOver:L,onDrop:$,onClick:m,onDoubleClick:o,role:"row","aria-selected":r,tabIndex:0,children:[e.jsx("span",{className:`nice-reconciliation__status nice-reconciliation__status--${p}`}),e.jsxs("div",{className:"nice-reconciliation__row-main",children:[e.jsxs("div",{className:"nice-reconciliation__row-date",children:[_t(t.date,u),t.documentNumber&&e.jsxs("span",{children:[" · ",t.documentNumber]})]}),e.jsx("div",{className:"nice-reconciliation__row-description",title:t.description,children:t.description}),t.partyName&&e.jsx("div",{className:"nice-reconciliation__row-counterparty",children:t.partyName})]}),e.jsx("span",{className:`nice-reconciliation__row-amount ${t.amount>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:$n(t.amount,s,u)})]})}n.forwardRef(function(t,r){const{statements:a,entries:l,matches:s,defaultMatches:u=[],suggestions:m=[],config:o={},statementPanelConfig:y,entryPanelConfig:A,onMatch:$,onUnmatch:U,onBatchAction:p,onFilterChange:Z,onRequestSuggestions:L,onSelectionChange:q,onComplete:x,size:v="medium",showToolbar:_=!0,showFilters:b=!0,showSummary:F=!0,showSuggestions:Y=!0,layout:V="horizontal",enableDragDrop:ue=!0,enableKeyboard:J=!0,enableDetailPanel:S=!0,loading:oe=!1,disabled:re=!1,readOnly:O=!1,locale:de="pl-PL",labels:z={},className:N,style:B}=t,f=o.currency??"PLN",[_e,W]=n.useState(u),[ge,ee]=n.useState(new Set),[me,H]=n.useState(new Set),[ve,K]=n.useState(null),[he,je]=n.useState(null),[Oe,We]=n.useState({}),[we,qe]=n.useState(null),Ne=s??_e,X=n.useRef(null),C=n.useRef(null);n.useEffect(()=>{const M="nice-reconciliation-styles";if(!document.getElementById(M)){const se=document.createElement("style");se.id=M,se.textContent=zi,document.head.appendChild(se)}},[]);const xe=n.useMemo(()=>{const M=new Set;return Ne.forEach(se=>se.statementIds.forEach(le=>M.add(le))),M},[Ne]),ne=n.useMemo(()=>{const M=new Set;return Ne.forEach(se=>se.entryIds.forEach(le=>M.add(le))),M},[Ne]),pe=n.useMemo(()=>{const M=a.filter(Ce=>!xe.has(Ce.id)),se=l.filter(Ce=>!ne.has(Ce.id)),le=a.reduce((Ce,Le)=>Ce+Le.amount,0),He=l.reduce((Ce,Le)=>Ce+Le.amount,0),kn=a.filter(Ce=>xe.has(Ce.id)).reduce((Ce,Le)=>Ce+Le.amount,0);return{totalStatements:a.length,totalEntries:l.length,matchedStatements:a.length-M.length,matchedEntries:l.length-se.length,unmatchedStatements:M.length,unmatchedEntries:se.length,statementTotal:le,entryTotal:He,matchedAmount:kn,unmatchedStatementAmount:M.reduce((Ce,Le)=>Ce+Le.amount,0),unmatchedEntryAmount:se.reduce((Ce,Le)=>Ce+Le.amount,0),difference:le-He,matchPercentage:a.length>0?Math.round((a.length-M.length)/a.length*100):0,matchCount:Ne.length,partialMatchCount:Ne.filter(Ce=>Ce.status==="partial").length,pendingSuggestions:m.length}},[a,l,Ne,m,xe,ne]),T=n.useCallback((M,se)=>{const le=a.filter(en=>M.includes(en.id)),He=l.filter(en=>se.includes(en.id));if(le.length===0||He.length===0)return null;const kn=le.reduce((en,on)=>en+on.amount,0),Ce=He.reduce((en,on)=>en+on.amount,0),Le=Math.abs(kn-Ce),an=o.amountTolerance??.01,rn={id:Oi(),statementIds:M,entryIds:se,status:Le<=an?"matched":"partial",statementTotal:kn,entryTotal:Ce,difference:Le,confidence:Le<=an?100:Math.max(0,100-Le/Math.max(Math.abs(kn),1)*100),matchedBy:"user",matchedAt:new Date};return s||W(en=>[...en,rn]),$==null||$(rn,le,He),ee(new Set),H(new Set),rn},[a,l,o.amountTolerance,s,$]),Ee=n.useCallback(M=>{const se=Ne.find(le=>le.id===M);se&&(s||W(le=>le.filter(He=>He.id!==M)),U==null||U(M,se.statementIds,se.entryIds))},[Ne,s,U]),Re=n.useCallback(async()=>{const M=[],se=new Set(xe),le=new Set(ne),He=o.amountTolerance??.01,kn=o.dateTolerance??3;for(const Ce of a){if(se.has(Ce.id))continue;const Le=l.filter(an=>{if(le.has(an.id)||Math.abs(Ce.amount-an.amount)>He)return!1;const rn=new Date(Ce.date),en=new Date(an.date);return!(Math.abs(rn.getTime()-en.getTime())/(1e3*60*60*24)>kn)});if(Le.length===1){const an=Le[0],rn=T([Ce.id],[an.id]);rn&&(M.push(rn),se.add(Ce.id),le.add(an.id))}}return p==null||p("autoMatch",M),M},[a,l,xe,ne,o,T,p]),De=n.useCallback((M,se,le,He)=>{He!==se&&(He==="statement"?T([le],[M]):T([M],[le]),K(null),je(null))},[T]),G=n.useCallback(()=>{const M=Array.from(ge),se=Array.from(me);M.length>0&&se.length>0&&T(M,se)},[ge,me,T]);n.useEffect(()=>{q==null||q(Array.from(ge),Array.from(me))},[ge,me,q]),n.useImperativeHandle(r,()=>({getMatches:()=>Ne,getUnmatchedStatements:()=>a.filter(M=>!xe.has(M.id)),getUnmatchedEntries:()=>l.filter(M=>!ne.has(M.id)),createMatch:T,removeMatch:Ee,autoMatch:Re,getSuggestions:async M=>L?L(M??a.filter(se=>!xe.has(se.id)).map(se=>se.id)):[],applySuggestion:M=>T([M.statementId],M.entryIds),approveAll:()=>{p==null||p("approveAll",Ne)},clearAll:()=>{s||W([]),p==null||p("clearAll",[])},exportMatched:M=>{p==null||p("exportMatched",Ne)},getSummary:()=>pe,reset:()=>{s||W([]),ee(new Set),H(new Set),We({})},focusStatements:()=>{var M;return(M=X.current)==null?void 0:M.focus()},focusEntries:()=>{var M;return(M=C.current)==null?void 0:M.focus()}}),[Ne,a,l,xe,ne,T,Ee,Re,L,p,s,pe]);const bn=n.useMemo(()=>a.filter(M=>{var se;if(Oe.status&&Oe.status.length>0){const le=xe.has(M.id)?"matched":"unmatched";if(!Oe.status.includes(le))return!1}if(Oe.searchText){const le=Oe.searchText.toLowerCase();if(!M.description.toLowerCase().includes(le)&&!((se=M.counterparty)!=null&&se.toLowerCase().includes(le)))return!1}return!0}),[a,Oe,xe]),An=n.useMemo(()=>l.filter(M=>{var se;if(Oe.status&&Oe.status.length>0){const le=ne.has(M.id)?"matched":"unmatched";if(!Oe.status.includes(le))return!1}if(Oe.searchText){const le=Oe.searchText.toLowerCase();if(!M.description.toLowerCase().includes(le)&&!((se=M.partyName)!=null&&se.toLowerCase().includes(le)))return!1}return!0}),[l,Oe,ne]),ke=ge.size>0&&me.size>0&&!O&&!re;return e.jsxs("div",{className:`nice-reconciliation nice-reconciliation--${V} ${N??""}`,style:B,children:[_&&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:Re,disabled:re||O||oe,children:["⚡ ",z.autoMatch??"Auto-match"]}),e.jsx("button",{type:"button",className:"nice-reconciliation__btn nice-reconciliation__btn--success",onClick:G,disabled:!ke||oe,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:()=>p==null?void 0:p("approveAll",Ne),disabled:Ne.length===0||re||oe,children:["✓ ",z.approveAll??"Approve All"]}),e.jsxs("button",{type:"button",className:"nice-reconciliation__btn",onClick:()=>{s||W([]),p==null||p("clearAll",[])},disabled:Ne.length===0||re||O||oe,children:["✕ ",z.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:["📄 ",z.statementPanelTitle??"Bank Statement",e.jsx("span",{className:"nice-reconciliation__panel-badge",children:bn.length})]})}),e.jsx("div",{ref:X,className:"nice-reconciliation__panel-content",role:"listbox","aria-multiselectable":"true",children:bn.length===0?e.jsxs("div",{className:"nice-reconciliation__empty",children:[e.jsx("div",{className:"nice-reconciliation__empty-icon",children:"📋"}),z.noStatements??"No statement items"]}):bn.map(M=>e.jsx(Wi,{item:{...M,status:xe.has(M.id)?"matched":"unmatched"},isSelected:ge.has(M.id),isDragging:ve===M.id,isDropTarget:he===M.id,suggestion:m.find(se=>se.statementId===M.id),currency:f,locale:de,onSelect:()=>{re||ee(se=>{const le=new Set(se);return le.has(M.id)?le.delete(M.id):le.add(M.id),le})},onDoubleClick:()=>S&&qe({type:"statement",id:M.id}),onDragStart:()=>K(M.id),onDragEnd:()=>{K(null),je(null)},onDrop:()=>{ve&&ve!==M.id&&De(M.id,"statement",ve,"entry")},disabled:re||O||!ue},M.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:["📒 ",z.entryPanelTitle??"Book Entries",e.jsx("span",{className:"nice-reconciliation__panel-badge",children:An.length})]})}),e.jsx("div",{ref:C,className:"nice-reconciliation__panel-content",role:"listbox","aria-multiselectable":"true",children:An.length===0?e.jsxs("div",{className:"nice-reconciliation__empty",children:[e.jsx("div",{className:"nice-reconciliation__empty-icon",children:"📚"}),z.noEntries??"No book entries"]}):An.map(M=>e.jsx(Pi,{item:{...M,status:ne.has(M.id)?"matched":"unmatched"},isSelected:me.has(M.id),isDragging:ve===M.id,isDropTarget:he===M.id,currency:f,locale:de,onSelect:()=>{re||H(se=>{const le=new Set(se);return le.has(M.id)?le.delete(M.id):le.add(M.id),le})},onDoubleClick:()=>S&&qe({type:"entry",id:M.id}),onDragStart:()=>K(M.id),onDragEnd:()=>{K(null),je(null)},onDrop:()=>{ve&&ve!==M.id&&De(M.id,"entry",ve,"statement")},disabled:re||O||!ue},M.id))})]})]}),F&&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:[pe.matchedStatements,"/",pe.totalStatements," (",pe.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(pe.matchedAmount,f,de)})]}),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(pe.unmatchedStatementAmount,f,de)})]}),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(pe.difference)<.01?"nice-reconciliation__summary-value--success":"nice-reconciliation__summary-value--danger"}`,children:$n(pe.difference,f,de)})]})]}),S&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`nice-reconciliation__detail-backdrop ${we?"nice-reconciliation__detail-backdrop--visible":""}`,onClick:()=>qe(null)}),e.jsx("div",{className:`nice-reconciliation__detail-panel ${we?"nice-reconciliation__detail-panel--open":""}`,children:we&&e.jsx(Gi,{type:we.type,id:we.id,statements:a,entries:l,matches:Ne,currency:f,locale:de,labels:z,onClose:()=>qe(null)})})]})]})});function Gi({type:t,id:r,statements:a,entries:l,matches:s,currency:u,locale:m,labels:o,onClose:y}){var q;const A=t==="statement"?a.find(x=>x.id===r):l.find(x=>x.id===r),$=t==="statement"?s.find(x=>x.statementIds.includes(r)):s.find(x=>x.entryIds.includes(r)),U=$?t==="statement"?l.filter(x=>$.entryIds.includes(x.id)):a.filter(x=>$.statementIds.includes(x.id)):[];if(!A)return null;const p=t==="statement",Z=p?A:null,L=p?null:A;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-reconciliation__detail-header",children:[e.jsxs("span",{className:"nice-reconciliation__detail-title",children:[p?"📄":"📒"," ",p?o.statementDetails??"Transaction Details":o.entryDetails??"Entry Details"]}),e.jsx("button",{type:"button",className:"nice-reconciliation__detail-close",onClick:y,"aria-label":"Close",children:"✕"})]}),e.jsxs("div",{className:"nice-reconciliation__detail-content",children:[$&&e.jsxs("div",{className:"nice-reconciliation__detail-match-info",children:[e.jsxs("div",{className:"nice-reconciliation__detail-match-header",children:["✓ ",o.matchedWith??"Matched"," (",((q=$.confidence)==null?void 0:q.toFixed(0))??100,"% confidence)"]}),e.jsx("div",{className:"nice-reconciliation__detail-match-detail",children:$.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 ${$.statementTotal>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:$n($.statementTotal,u,m)})]}),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 ${$.entryTotal>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:$n($.entryTotal,u,m)})]})]}),$.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($.difference,u,m)})]})]}),e.jsxs("div",{className:"nice-reconciliation__detail-section",children:[e.jsxs("div",{className:"nice-reconciliation__detail-section-title",children:["📋"," ",p?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:_t(A.date,m)})]}),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:A.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 ${A.amount>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:$n(A.amount,u,m)})]}),p&&(Z==null?void 0:Z.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:Z.counterparty})]}),p&&(Z==null?void 0:Z.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:Z.counterpartyAccount})]}),!p&&(L==null?void 0:L.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:L.partyName})]}),!p&&(L==null?void 0:L.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:L.documentNumber})]}),p&&(Z==null?void 0:Z.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:Z.referenceNumber})]})]}),U.length>0&&e.jsxs("div",{className:"nice-reconciliation__detail-section",children:[e.jsxs("div",{className:"nice-reconciliation__detail-section-title",children:["🔗"," ",p?o.matchedEntries??"Matched Entries":o.matchedStatements??"Matched Statements"]}),U.map(x=>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:x.description}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",color:"var(--nice-text-secondary)"},children:[e.jsx("span",{children:_t(x.transactionDate??x.postingDate,m)}),e.jsx("span",{style:{fontWeight:600,color:x.amount>=0?"var(--nice-success)":"var(--nice-danger)"},children:$n(x.amount,u,m)})]})]},x.id))]})]})]})}function Ui(t,r,a){const l=new Map,s=[];t.forEach(m=>l.set(String(m[r]),{data:m,children:[],key:String(m[r]),depth:0})),t.forEach(m=>{const o=m[a],y=l.get(String(m[r]));if(o!=null&&o!==""&&l.has(String(o))){const A=l.get(String(o));y.depth=A.depth+1,A.children.push(y)}else s.push(y)});const u=(m,o)=>{m.forEach(y=>{y.depth=o,u(y.children,o+1)})};return u(s,0),s}function Vt(t,r,a,l=0){return t.map(s=>({data:s,key:String(s[a]),depth:l,children:Array.isArray(s[r])?Vt(s[r],r,a,l+1):[]}))}function Bi(t){const r=[],a=l=>{l.forEach(s=>{r.push(s.key),a(s.children)})};return a(t),r}function Ki(t,r){const a=[],l=s=>{s.forEach(u=>{a.push(u),u.children.length>0&&r.has(u.key)&&l(u.children)})};return l(t),a}function qt(t,r,a){return!r||!a?t:[...t].sort((l,s)=>{const u=l.data[r]??"",m=s.data[r]??"",o=typeof u=="number"&&typeof m=="number"?u-m:String(u).localeCompare(String(m));return a==="desc"?-o:o}).map(l=>({...l,children:qt(l.children,r,a)}))}function Hi({columns:t,data:r,keyField:a="id",parentKeyField:l="parentId",nested:s=!1,childrenField:u="children",expandedKeys:m,onExpandedChange:o,defaultExpandAll:y=!1,sortable:A=!0,sortField:$,sortDirection:U,onSort:p,selectable:Z,selectedKeys:L,onSelectionChange:q,searchable:x,searchPlaceholder:v,striped:_,compact:b,loading:F,emptyText:Y,toolbar:V,onRowClick:ue,className:J,style:S}){const{t:oe}=ae.de(),re=n.useMemo(()=>s?Vt(r,u,a):Ui(r,a,l),[r,a,l,s,u]),O=n.useMemo(()=>Bi(re),[re]),[de,z]=n.useState(()=>y?new Set(O):new Set),N=m?new Set(m):de,[B,f]=n.useState({field:"",dir:null}),[_e,W]=n.useState(new Set),[ge,ee]=n.useState(""),me=$??B.field,H=U??B.dir,ve=L??_e,K=n.useMemo(()=>t.filter(X=>!X.hidden),[t]),he=n.useCallback(X=>{const C=me===X?H==="asc"?"desc":H==="desc"?null:"asc":"asc";p?p(X,C):f({field:X,dir:C})},[me,H,p]),je=n.useCallback(X=>{const C=new Set(N);C.has(X)?C.delete(X):C.add(X),o?o([...C]):z(C)},[N,o]),Oe=n.useCallback(X=>{const C=new Set(ve);C.has(X)?C.delete(X):C.add(X),q?q(C):W(C)},[ve,q]),We=n.useMemo(()=>{if(!ge)return re;const X=ge.toLowerCase(),C=xe=>xe.reduce((ne,pe)=>{const T=C(pe.children);return(K.some(Ee=>String(pe.data[Ee.field]??"").toLowerCase().includes(X))||T.length>0)&&ne.push({...pe,children:T}),ne},[]);return C(re)},[re,ge,K]),we=n.useMemo(()=>qt(We,me,H),[We,me,H]),qe=n.useMemo(()=>Ki(we,N),[we,N]),Ne=({field:X})=>me!==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 ${J||""}`,style:S,children:[(x||V)&&e.jsxs("div",{className:"nice-datagrid__toolbar",children:[x&&e.jsx("div",{className:"nice-datagrid__search",children:e.jsx("input",{type:"text",value:ge,onChange:X=>ee(X.target.value),placeholder:v||oe("controls.search","Search...")})}),V]}),e.jsx("div",{className:"nice-datagrid__table-wrap",children:e.jsxs("table",{className:`${_?"nice-table--striped":""} ${b?"nice-table--compact":""}`,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[Z&&e.jsx("th",{className:"nice-datagrid__checkbox",style:{width:36}}),K.map(X=>e.jsxs("th",{style:{width:X.width,minWidth:X.minWidth,textAlign:X.align},className:A&&X.sortable!==!1?"nice-datagrid__th--sortable":void 0,onClick:()=>A&&X.sortable!==!1&&he(X.field),children:[X.header,A&&X.sortable!==!1&&e.jsx(Ne,{field:X.field})]},X.field))]})}),e.jsx("tbody",{children:F?e.jsx("tr",{children:e.jsx("td",{colSpan:K.length+(Z?1:0),className:"nice-datagrid__empty",children:e.jsx("div",{className:"nice-spinner nice-spinner--md",style:{margin:"0 auto"}})})}):qe.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:K.length+(Z?1:0),className:"nice-datagrid__empty",children:Y||oe("controls.noData","No data available")})}):qe.map((X,C)=>{const xe=ve.has(X.key),ne=X.children.length>0,pe=N.has(X.key);return e.jsxs("tr",{className:xe?"nice-datagrid__row--selected":void 0,onClick:()=>ue==null?void 0:ue(X.data),style:ue?{cursor:"pointer"}:void 0,children:[Z&&e.jsx("td",{className:"nice-datagrid__checkbox",onClick:T=>T.stopPropagation(),children:e.jsx("input",{type:"checkbox",checked:xe,onChange:()=>Oe(X.key),"aria-label":`Select row ${X.key}`})}),K.map((T,Ee)=>e.jsxs("td",{style:{textAlign:T.align},children:[Ee===0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{display:"inline-block",width:X.depth*20}}),e.jsx("button",{className:`nice-treegrid__toggle ${ne?"":"nice-treegrid__toggle--leaf"}`,onClick:Re=>{Re.stopPropagation(),ne&&je(X.key)},tabIndex:ne?0:-1,"aria-expanded":ne?pe:void 0,"aria-label":ne?pe?"Collapse":"Expand":void 0,children:ne?pe?"▾":"▸":""})]}),T.render?T.render(X.data[T.field],X.data,C):String(X.data[T.field]??"")]},T.field))]},X.key)})})]})})]})}function Qt(t){let r="",a=t;for(;a>=0;)r=String.fromCharCode(65+a%26)+r,a=Math.floor(a/26)-1;return r}function $e(t,r){return`${Qt(r)}${t+1}`}function Xe(t){const r=t.match(/^([A-Z]+)(\d+)$/);if(!r)return null;let a=0;for(let l=0;l<r[1].length;l++)a=a*26+(r[1].charCodeAt(l)-64);return{row:parseInt(r[2],10)-1,col:a-1}}function Vi(t,r,a=new Set){const l=t.startsWith("=")?t.slice(1).trim():t,s=(x,v)=>{if(!x||!v)return[];const _=[];for(let b=x.row;b<=v.row;b++)for(let F=x.col;F<=v.col;F++){const Y=Qe($e(b,F),r,new Set(a));typeof Y=="number"&&_.push(Y)}return _},u=(x,v)=>{if(!x||!v)return[];const _=[];for(let b=x.row;b<=v.row;b++)for(let F=x.col;F<=v.col;F++)_.push(Qe($e(b,F),r,new Set(a)));return _},m=l.match(/^(\w+)\(([A-Z]+\d+):([A-Z]+\d+)\)$/i);if(m){const x=m[1].toUpperCase(),v=Xe(m[2].toUpperCase()),_=Xe(m[3].toUpperCase());switch(x){case"SUM":return s(v,_).reduce((b,F)=>b+F,0);case"AVG":case"AVERAGE":{const b=s(v,_);return b.length>0?b.reduce((F,Y)=>F+Y,0)/b.length:0}case"COUNT":return s(v,_).length;case"COUNTA":return u(v,_).filter(b=>b!==null&&b!=="").length;case"COUNTBLANK":return u(v,_).filter(b=>b===null||b==="").length;case"MIN":{const b=s(v,_);return b.length?Math.min(...b):0}case"MAX":{const b=s(v,_);return b.length?Math.max(...b):0}case"MEDIAN":{const b=s(v,_).sort((Y,V)=>Y-V);if(!b.length)return 0;const F=Math.floor(b.length/2);return b.length%2?b[F]:(b[F-1]+b[F])/2}case"STDEV":{const b=s(v,_);if(b.length<2)return 0;const F=b.reduce((Y,V)=>Y+V,0)/b.length;return Math.sqrt(b.reduce((Y,V)=>Y+(V-F)**2,0)/(b.length-1))}case"PRODUCT":{const b=s(v,_);return b.length?b.reduce((F,Y)=>F*Y,1):0}}}const o=l.match(/^(SUMIF|COUNTIF)\(([A-Z]+\d+):([A-Z]+\d+)\s*,\s*"?([^"]*)"?\)$/i);if(o){const x=o[1].toUpperCase(),v=Xe(o[2].toUpperCase()),_=Xe(o[3].toUpperCase()),b=o[4];if(v&&_){let F=0;for(let Y=v.row;Y<=_.row;Y++)for(let V=v.col;V<=_.col;V++){const ue=Qe($e(Y,V),r,new Set(a));(b.startsWith(">")?Number(ue)>Number(b.slice(1)):b.startsWith("<")?Number(ue)<Number(b.slice(1)):String(ue)===b||typeof ue=="number"&&ue===Number(b))&&(F+=x==="SUMIF"?typeof ue=="number"?ue:0:1)}return F}}const y=l.match(/^IF\(([^,]+),\s*([^,]+),\s*([^)]+)\)$/i);if(y){const x=y[1].trim(),v=y[2].trim(),_=y[3].trim(),b=x.match(/^([A-Z]+\d+)\s*([><=!]+)\s*(\S+)$/i);let F=!1;if(b){const ue=Qe(b[1].toUpperCase(),r,new Set(a)),J=isNaN(Number(b[3]))?b[3].replace(/^"|"$/g,""):Number(b[3]),S=b[2],oe=typeof ue=="number"?ue:Number(ue)||0,re=typeof J=="number"?J:Number(J)||0;switch(S){case">":F=oe>re;break;case"<":F=oe<re;break;case">=":F=oe>=re;break;case"<=":F=oe<=re;break;case"=":case"==":F=oe===re;break;case"<>":case"!=":F=oe!==re;break}}const Y=F?v:_;if(Xe(Y.toUpperCase()))return Qe(Y.toUpperCase(),r,new Set(a));const V=Number(Y);return isNaN(V)?Y.replace(/^"|"$/g,""):V}const A=l.match(/^CONCAT\((.+)\)$/i);if(A)return A[1].split(",").map(x=>x.trim()).map(x=>{if(x.startsWith('"')&&x.endsWith('"'))return x.slice(1,-1);if(Xe(x.toUpperCase())){const v=Qe(x.toUpperCase(),r,new Set(a));return v!==null?String(v):""}return x}).join("");const $=l.match(/^VLOOKUP\(([^,]+),\s*([A-Z]+\d+):([A-Z]+\d+),\s*(\d+)\)$/i);if($){let x;Xe($[1].trim().toUpperCase())?x=Qe($[1].trim().toUpperCase(),r,new Set(a)):x=isNaN(Number($[1]))?$[1].replace(/^"|"$/g,""):Number($[1]);const v=Xe($[2].toUpperCase()),_=Xe($[3].toUpperCase()),b=parseInt($[4])-1;if(v&&_)for(let F=v.row;F<=_.row;F++){const Y=Qe($e(F,v.col),r,new Set(a));if(String(Y)===String(x))return Qe($e(F,v.col+b),r,new Set(a))}return null}const U=l.match(/^(ABS|ROUND|FLOOR|CEIL|CEILING|SQRT|LEN|UPPER|LOWER|TRIM|INT)\(([^)]+)\)$/i);if(U){const x=U[1].toUpperCase(),v=U[2].trim();let _;switch(Xe(v.toUpperCase())?_=Qe(v.toUpperCase(),r,new Set(a)):_=isNaN(Number(v))?v.replace(/^"|"$/g,""):Number(v),x){case"ABS":return Math.abs(Number(_)||0);case"ROUND":return Math.round(Number(_)||0);case"FLOOR":return Math.floor(Number(_)||0);case"CEIL":case"CEILING":return Math.ceil(Number(_)||0);case"SQRT":return Math.sqrt(Number(_)||0);case"INT":return Math.trunc(Number(_)||0);case"LEN":return String(_??"").length;case"UPPER":return String(_??"").toUpperCase();case"LOWER":return String(_??"").toLowerCase();case"TRIM":return String(_??"").trim()}}const p=l.match(/^POWER\(([^,]+),\s*([^)]+)\)$/i);if(p){const x=Number(Xe(p[1].trim().toUpperCase())?Qe(p[1].trim().toUpperCase(),r,new Set(a)):p[1].trim())||0,v=Number(Xe(p[2].trim().toUpperCase())?Qe(p[2].trim().toUpperCase(),r,new Set(a)):p[2].trim())||0;return Math.pow(x,v)}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 Z=l.match(/^([A-Z]+\d+)$/i);if(Z)return Qe(Z[1].toUpperCase(),r,a);const L=l.match(/^([A-Z]+\d+)\s*([+\-*/])\s*([A-Z]+\d+|\d+\.?\d*)$/i);if(L){const x=L[1].toUpperCase(),v=L[2],_=L[3],b=Qe(x,r,a),F=Xe(_.toUpperCase())?Qe(_.toUpperCase(),r,a):parseFloat(_),Y=typeof b=="number"?b:0,V=typeof F=="number"?F:0;switch(v){case"+":return Y+V;case"-":return Y-V;case"*":return Y*V;case"/":return V!==0?Y/V:null}}const q=parseFloat(l);return isNaN(q)?l:q}function Qe(t,r,a){if(a.has(t))return null;a.add(t);const l=r[t];return l?l.formula?Vi(l.formula,r,a):l.value:null}function Wt(t,r){return t==null?"":r==="percent"&&typeof t=="number"?`${(t*100).toFixed(1)}%`:r==="currency"&&typeof t=="number"?`$${t.toFixed(2)}`:String(t)}function Pt(t){return{name:t,data:{}}}const Zt=n.forwardRef(({sheets:t,activeSheet:r,rows:a=50,cols:l=26,showToolbar:s=!0,showFormulaBar:u=!0,showSheetTabs:m=!0,readOnly:o=!1,onChange:y,onActiveSheetChange:A,onCellSelect:$,onCopy:U,onPaste:p,onInsert:Z,onRemove:L,maxUndo:q=50,sortable:x=!1,filterable:v=!1,rangeSelection:_=!0,className:b,style:F,id:Y,...V},ue)=>{var ln,On,Nn,Cn,Rn;const J=ae.ys(Y),{t:S}=ae.de(),[oe,re]=n.useState(()=>t??[Pt(S("spreadsheet.sheet","Sheet")+" 1")]),[O,de]=n.useState(0),z=t??oe,N=r??O,B=z[N]??z[0],[f,_e]=n.useState(null),[W,ge]=n.useState(null),[ee,me]=n.useState(!1),[H,ve]=n.useState(null),[K,he]=n.useState(""),je=n.useRef(null),Oe=n.useRef(null),[We,we]=n.useState([]),[qe,Ne]=n.useState([]),[X,C]=n.useState(null),xe=n.useRef({x:0,width:80}),[ne,pe]=n.useState(null),[T,Ee]=n.useState(null),[Re,De]=n.useState("");n.useEffect(()=>{H&&je.current&&je.current.focus()},[H]);const G=n.useMemo(()=>{if(!f)return null;const c=W??f;return{startRow:Math.min(f.row,c.row),startCol:Math.min(f.col,c.col),endRow:Math.max(f.row,c.row),endCol:Math.max(f.col,c.col)}},[f,W]),bn=n.useCallback((c,d)=>G?c>=G.startRow&&c<=G.endRow&&d>=G.startCol&&d<=G.endCol:!1,[G]),An=n.useCallback(c=>{we(d=>{const j=[...d,c.map(I=>({...I,data:{...I.data}}))];return j.length>q?j.slice(-q):j}),Ne([])},[q]),ke=n.useCallback((c,d=!0)=>{d&&An(z);const j=c(z);t||re(j),y==null||y(j)},[z,t,y,An]),M=n.useCallback(()=>{if(We.length===0)return;const c=We[We.length-1];Ne(d=>[...d,z.map(j=>({...j,data:{...j.data}}))]),we(d=>d.slice(0,-1)),t||re(c),y==null||y(c)},[We,z,t,y]),se=n.useCallback(()=>{if(qe.length===0)return;const c=qe[qe.length-1];we(d=>[...d,z.map(j=>({...j,data:{...j.data}}))]),Ne(d=>d.slice(0,-1)),t||re(c),y==null||y(c)},[qe,z,t,y]),le=n.useCallback(c=>{r||de(c),A==null||A(c),_e(null),ge(null),ve(null)},[r,A]),He=n.useCallback((c,d,j)=>{const I=$e(c,d);ke(Q=>{const w=Q.map((P,Ie)=>Ie===N?{...P,data:{...P.data}}:P),E=j.startsWith("=");return w[N].data[I]={...w[N].data[I]??{value:null},formula:E?j:void 0,value:E?null:isNaN(Number(j))?j:Number(j)},w})},[N,ke]),kn=n.useCallback((c,d,j)=>{j!=null&&j.shiftKey&&_&&f?ge({row:c,col:d}):(_e({row:c,col:d}),ge(null)),ve(null),$==null||$(N,c,d)},[N,$,_,f]),Ce=n.useCallback((c,d,j)=>{j.button===0&&(kn(c,d,j),_&&!j.shiftKey&&me(!0))},[kn,_]),Le=n.useCallback((c,d)=>{ee&&ge({row:c,col:d})},[ee]);n.useEffect(()=>{if(!ee)return;const c=()=>me(!1);return document.addEventListener("mouseup",c),()=>document.removeEventListener("mouseup",c)},[ee]);const an=n.useCallback((c,d)=>{if(o)return;const j=$e(c,d),I=B.data[j];I!=null&&I.readOnly||(ve({row:c,col:d}),he((I==null?void 0:I.formula)??((I==null?void 0:I.value)!=null?String(I.value):"")))},[o,B.data]),rn=n.useCallback(()=>{H&&(He(H.row,H.col,K),ve(null))},[H,K,He]),en=n.useCallback(c=>{if(c.key==="Enter")rn();else if(c.key==="Escape")ve(null);else if(c.key==="Tab"&&(c.preventDefault(),rn(),f)){const d=c.shiftKey?Math.max(0,f.col-1):Math.min(l-1,f.col+1);_e({row:f.row,col:d})}},[rn,f,l]),on=n.useCallback((c,d)=>{if(!f)return;const j=G??{startRow:f.row,startCol:f.col,endRow:f.row,endCol:f.col};ke(I=>{const Q=I.map((w,E)=>E===N?{...w,data:{...w.data}}:w);for(let w=j.startRow;w<=j.endRow;w++)for(let E=j.startCol;E<=j.endCol;E++){const P=$e(w,E);Q[N].data[P]={...Q[N].data[P]??{value:null},[c]:d}}return Q})},[f,G,N,ke]),Qn=n.useCallback(c=>{if(!G||(U==null?void 0:U(G))===!1)return;const{startRow:d,startCol:j,endRow:I,endCol:Q}=G,w=[];for(let E=d;E<=I;E++){const P=[];for(let Ie=j;Ie<=Q;Ie++){const Se=$e(E,Ie),te=B.data[Se],Ve=te?Qe(Se,B.data,new Set):null;P.push(Wt(Ve,te==null?void 0:te.format))}w.push(P.join(" "))}c.clipboardData.setData("text/plain",w.join(`
|
|
595
|
+
`)),c.preventDefault()},[G,B.data,U]),Kn=n.useCallback(c=>{if(o||!f)return;const d=c.clipboardData.getData("text/plain");if(!d)return;const j=d.split(`
|
|
596
|
+
`).map(I=>I.split(" "));(p==null?void 0:p(j,f.row,f.col))!==!1&&(ke(I=>{const Q=I.map((w,E)=>E===N?{...w,data:{...w.data}}:w);return j.forEach((w,E)=>{w.forEach((P,Ie)=>{const Se=$e(f.row+E,f.col+Ie),te=P.startsWith("=");Q[N].data[Se]={...Q[N].data[Se]??{value:null},formula:te?P:void 0,value:te?null:isNaN(Number(P))?P:Number(P)}})}),Q}),c.preventDefault())},[o,f,N,ke,p]),Fn=n.useCallback(c=>{ke(d=>d.map((j,I)=>{if(I!==N)return j;const Q={};for(const[w,E]of Object.entries(j.data)){const P=Xe(w);P&&(P.row>c?Q[$e(P.row+1,P.col)]=E:Q[w]=E)}return{...j,data:Q}})),Z==null||Z("row",c)},[N,ke,Z]),Pn=n.useCallback(c=>{ke(d=>d.map((j,I)=>{if(I!==N)return j;const Q={};for(const[w,E]of Object.entries(j.data)){const P=Xe(w);P&&(P.col>c?Q[$e(P.row,P.col+1)]=E:Q[w]=E)}return{...j,data:Q}})),Z==null||Z("column",c)},[N,ke,Z]),ze=n.useCallback(c=>{ke(d=>d.map((j,I)=>{if(I!==N)return j;const Q={};for(const[w,E]of Object.entries(j.data)){const P=Xe(w);P&&P.row!==c&&(P.row>c?Q[$e(P.row-1,P.col)]=E:Q[w]=E)}return{...j,data:Q}})),L==null||L("row",c)},[N,ke,L]),Ze=n.useCallback(c=>{ke(d=>d.map((j,I)=>{if(I!==N)return j;const Q={};for(const[w,E]of Object.entries(j.data)){const P=Xe(w);P&&P.col!==c&&(P.col>c?Q[$e(P.row,P.col-1)]=E:Q[w]=E)}return{...j,data:Q}})),L==null||L("column",c)},[N,ke,L]),Ge=n.useCallback((c,d)=>{ke(j=>j.map((I,Q)=>{if(Q!==N)return I;const w=new Map;for(const[Ie,Se]of Object.entries(I.data)){const te=Xe(Ie);te&&(w.has(te.row)||w.set(te.row,{}),w.get(te.row)[te.col]=Se)}const E=Array.from(w.entries()).sort((Ie,Se)=>{const te=Qe($e(Ie[0],c),I.data,new Set),Ve=Qe($e(Se[0],c),I.data,new Set),sn=typeof te=="number"?te:Number(te),fn=typeof Ve=="number"?Ve:Number(Ve);if(!isNaN(sn)&&!isNaN(fn))return d==="asc"?sn-fn:fn-sn;const cn=String(te??""),_n=String(Ve??"");return d==="asc"?cn.localeCompare(_n):_n.localeCompare(cn)}),P={};return E.forEach(([,Ie],Se)=>{for(const[te,Ve]of Object.entries(Ie))P[$e(Se,Number(te))]=Ve}),{...I,data:P,sortColumn:c,sortDirection:d}}))},[N,ke]),zn=n.useCallback((c,d)=>{const j=B.conditionalFormats;if(!(j!=null&&j.length))return;const I=$e(c,d),Q=Qe(I,B.data,new Set),w=typeof Q=="number"?Q:Number(Q);for(const E of j){const P=E.range.match(/^([A-Z]+\d+):([A-Z]+\d+)$/i);if(!P)continue;const Ie=Xe(P[1].toUpperCase()),Se=Xe(P[2].toUpperCase());if(!Ie||!Se||c<Ie.row||c>Se.row||d<Ie.col||d>Se.col)continue;let te=!1;switch(E.type){case"greaterThan":te=!isNaN(w)&&w>Number(E.value);break;case"lessThan":te=!isNaN(w)&&w<Number(E.value);break;case"equalTo":te=String(Q)===String(E.value);break;case"between":te=!isNaN(w)&&w>=Number(E.value)&&w<=Number(E.value2);break;case"textContains":te=String(Q).includes(String(E.value));break;case"isEmpty":te=Q===null||Q==="";break;case"isNotEmpty":te=Q!==null&&Q!=="";break}if(te)return{backgroundColor:E.style.bgColor,color:E.style.color,fontWeight:E.style.bold?"bold":void 0,fontStyle:E.style.italic?"italic":void 0}}},[B.conditionalFormats,B.data]),En=n.useCallback(()=>{const c=`${S("spreadsheet.sheet","Sheet")} ${z.length+1}`;ke(d=>[...d,Pt(c)]),le(z.length)},[z.length,ke,le,S]),Hn=n.useCallback(()=>{z.length<=1||(ke(c=>c.filter((d,j)=>j!==N)),le(Math.max(0,N-1)))},[z.length,N,ke,le]),Vn=n.useCallback((c,d)=>{d.trim()&&(ke(j=>j.map((I,Q)=>Q===c?{...I,name:d.trim()}:I),!1),Ee(null))},[ke]),Zn=n.useMemo(()=>{if(!f)return"";const c=$e(f.row,f.col),d=B.data[c];return(d==null?void 0:d.formula)??((d==null?void 0:d.value)!=null?String(d.value):"")},[f,B.data]),gn=n.useMemo(()=>{if(!G)return null;const{startRow:c,startCol:d,endRow:j,endCol:I}=G;if(c===j&&d===I)return null;const Q=[];let w=0;for(let E=c;E<=j;E++)for(let P=d;P<=I;P++){const Ie=$e(E,P),Se=Qe(Ie,B.data,new Set);Se!==null&&Se!==""&&w++,typeof Se=="number"&&Q.push(Se)}return Q.length===0?{count:w}:{count:w,sum:Q.reduce((E,P)=>E+P,0),avg:Q.reduce((E,P)=>E+P,0)/Q.length,min:Math.min(...Q),max:Math.max(...Q)}},[G,B.data]),rt=n.useCallback((c,d)=>{var j;d.preventDefault(),d.stopPropagation(),C(c),xe.current={x:d.clientX,width:((j=B.colWidths)==null?void 0:j[c])??80}},[B.colWidths]);n.useEffect(()=>{if(X===null)return;const c=j=>{const I=j.clientX-xe.current.x,Q=Math.max(30,xe.current.width+I);ke(w=>w.map((E,P)=>P===N?{...E,colWidths:{...E.colWidths,[X]:Q}}:E),!1)},d=()=>C(null);return document.addEventListener("mousemove",c),document.addEventListener("mouseup",d),()=>{document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",d)}},[X,N,ke]);const qn=n.useCallback((c,d,j)=>{c.preventDefault(),_e({row:d,col:j}),pe({x:c.clientX,y:c.clientY})},[]);n.useEffect(()=>{if(!ne)return;const c=()=>pe(null);return document.addEventListener("click",c),()=>document.removeEventListener("click",c)},[ne]);const In=n.useCallback(c=>{if((c.ctrlKey||c.metaKey)&&!H){if(c.key==="z"){c.preventDefault(),M();return}if(c.key==="y"){c.preventDefault(),se();return}}if(H||!f)return;let{row:d,col:j}=f;switch(c.key){case"ArrowUp":d=Math.max(0,d-1);break;case"ArrowDown":d=Math.min(a-1,d+1);break;case"ArrowLeft":j=Math.max(0,j-1);break;case"ArrowRight":j=Math.min(l-1,j+1);break;case"Enter":an(d,j);return;case"Delete":case"Backspace":o||(G&&(G.startRow!==G.endRow||G.startCol!==G.endCol)?ke(I=>{const Q=I.map((w,E)=>E===N?{...w,data:{...w.data}}:w);for(let w=G.startRow;w<=G.endRow;w++)for(let E=G.startCol;E<=G.endCol;E++)delete Q[N].data[$e(w,E)];return Q}):He(d,j,""));return;default:if(c.key.length===1&&!c.ctrlKey&&!c.metaKey&&!o){ve({row:d,col:j}),he(c.key);return}return}c.preventDefault(),c.shiftKey&&_?ge({row:d,col:j}):(_e({row:d,col:j}),ge(null)),$==null||$(N,d,j)},[H,f,a,l,o,an,He,N,$,M,se,G,ke,_]),Gn=B.frozenRows??0,dn=B.frozenCols??0,Yn=[{value:"text",label:S("spreadsheet.formatText","Text")},{value:"number",label:S("spreadsheet.formatNumber","Number")},{value:"percent",label:S("spreadsheet.formatPercent","Percent")},{value:"currency",label:S("spreadsheet.formatCurrency","Currency")},{value:"date",label:S("spreadsheet.formatDate","Date")}];return e.jsxs("div",{ref:ue,id:J,className:`nice-spreadsheet ${o?"nice-spreadsheet--readonly":""} ${b??""}`,style:F,onKeyDown:In,onCopy:Qn,onPaste:Kn,tabIndex:0,role:"application","aria-label":S("spreadsheet.label","Spreadsheet"),...V,children:[s&&!o&&e.jsxs("div",{className:"nice-spreadsheet__toolbar",role:"toolbar",children:[e.jsx(ae.Fe,{variant:"ghost",size:"sm",onClick:M,disabled:We.length===0,title:S("spreadsheet.undo","Undo"),children:"↩"}),e.jsx(ae.Fe,{variant:"ghost",size:"sm",onClick:se,disabled:qe.length===0,title:S("spreadsheet.redo","Redo"),children:"↪"}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(ae.Fe,{variant:(ln=B.data[f?$e(f.row,f.col):""])!=null&&ln.bold?"primary":"ghost",size:"sm",onClick:()=>{var c;return on("bold",!((c=B.data[f?$e(f.row,f.col):""])!=null&&c.bold))},title:S("spreadsheet.bold","Bold"),children:e.jsx("strong",{children:"B"})}),e.jsx(ae.Fe,{variant:(On=B.data[f?$e(f.row,f.col):""])!=null&&On.italic?"primary":"ghost",size:"sm",onClick:()=>{var c;return on("italic",!((c=B.data[f?$e(f.row,f.col):""])!=null&&c.italic))},title:S("spreadsheet.italic","Italic"),children:e.jsx("em",{children:"I"})}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(ae.Fe,{variant:"ghost",size:"sm",onClick:()=>on("align","left"),title:S("spreadsheet.alignLeft","Align left"),children:"⬅"}),e.jsx(ae.Fe,{variant:"ghost",size:"sm",onClick:()=>on("align","center"),title:S("spreadsheet.alignCenter","Center"),children:"⬌"}),e.jsx(ae.Fe,{variant:"ghost",size:"sm",onClick:()=>on("align","right"),title:S("spreadsheet.alignRight","Align right"),children:"➡"}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(ae.Ae,{value:((Nn=B.data[f?$e(f.row,f.col):""])==null?void 0:Nn.bgColor)??"#ffffff",onChange:c=>on("bgColor",c),title:S("spreadsheet.bgColor","Background color")}),e.jsx(ae.Ae,{value:((Cn=B.data[f?$e(f.row,f.col):""])==null?void 0:Cn.color)??"#000000",onChange:c=>on("color",c),title:S("spreadsheet.textColor","Text color")}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(ae.De,{size:"sm",value:((Rn=B.data[f?$e(f.row,f.col):""])==null?void 0:Rn.format)??"text",onChange:c=>on("format",c),options:Yn,"aria-label":S("spreadsheet.format","Cell format")}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(ae.Fe,{variant:"ghost",size:"sm",onClick:()=>f&&Fn(f.row),title:S("spreadsheet.insertRow","Insert row"),children:"+↕"}),e.jsx(ae.Fe,{variant:"ghost",size:"sm",onClick:()=>f&&Pn(f.col),title:S("spreadsheet.insertCol","Insert column"),children:"+↔"}),e.jsx(ae.Fe,{variant:"ghost",size:"sm",onClick:()=>f&&ze(f.row),title:S("spreadsheet.deleteRow","Delete row"),children:"−↕"}),e.jsx(ae.Fe,{variant:"ghost",size:"sm",onClick:()=>f&&Ze(f.col),title:S("spreadsheet.deleteCol","Delete column"),children:"−↔"})]}),u&&e.jsxs("div",{className:"nice-spreadsheet__formula-bar",children:[e.jsxs("span",{className:"nice-spreadsheet__cell-label",children:[f?$e(f.row,f.col):"",G&&G.startRow!==G.endRow||G&&G.startCol!==G.endCol?`:${$e(G.endRow,G.endCol)}`:""]}),e.jsx(ae.Re,{className:"nice-spreadsheet__formula-input",value:H?K:Zn,onChange:c=>{H?he(c):f&&(ve(f),he(c))},onKeyDown:en,readOnly:o,"aria-label":S("spreadsheet.formulaBar","Formula bar")})]}),e.jsx("div",{className:"nice-spreadsheet__grid",ref:Oe,children:e.jsxs("table",{role:"grid","aria-label":B.name,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"nice-spreadsheet__corner"}),Array.from({length:l},(c,d)=>{var j;return e.jsxs("th",{className:`nice-spreadsheet__col-header ${d<dn?"nice-spreadsheet__col-header--frozen":""}`,style:{width:((j=B.colWidths)==null?void 0:j[d])??80,position:d<dn?"sticky":void 0,left:d<dn?d*80+40:void 0,zIndex:d<dn?3:void 0},children:[e.jsx("span",{children:Qt(d)}),x&&e.jsx("span",{className:"nice-spreadsheet__sort-trigger",onClick:()=>Ge(d,B.sortColumn===d&&B.sortDirection==="asc"?"desc":"asc"),title:S("spreadsheet.sort","Sort"),children:B.sortColumn===d?B.sortDirection==="asc"?"▲":"▼":"⇅"}),!o&&e.jsx("span",{className:"nice-spreadsheet__col-resize",onMouseDown:I=>rt(d,I)})]},d)})]})}),e.jsx("tbody",{children:Array.from({length:a},(c,d)=>e.jsxs("tr",{className:d<Gn?"nice-spreadsheet__row--frozen":"",style:d<Gn?{position:"sticky",top:d*24,zIndex:2}:void 0,children:[e.jsx("td",{className:"nice-spreadsheet__row-header",children:d+1}),Array.from({length:l},(j,I)=>{var sn,fn;const Q=$e(d,I),w=B.data[Q];if(w!=null&&w.mergedInto)return null;const E=(f==null?void 0:f.row)===d&&(f==null?void 0:f.col)===I,P=bn(d,I),Ie=(H==null?void 0:H.row)===d&&(H==null?void 0:H.col)===I,Se=w?Qe(Q,B.data,new Set):null,te=zn(d,I),Ve=d<Gn||I<dn;return e.jsxs("td",{className:`nice-spreadsheet__cell ${E?"nice-spreadsheet__cell--selected":""} ${P&&!E?"nice-spreadsheet__cell--in-range":""} ${w!=null&&w.readOnly?"nice-spreadsheet__cell--readonly":""} ${Ve?"nice-spreadsheet__cell--frozen":""}`,style:{textAlign:w==null?void 0:w.align,fontWeight:w!=null&&w.bold?"bold":void 0,fontStyle:w!=null&&w.italic?"italic":void 0,backgroundColor:(te==null?void 0:te.backgroundColor)??(w==null?void 0:w.bgColor),color:(te==null?void 0:te.color)??(w==null?void 0:w.color),width:(sn=B.colWidths)==null?void 0:sn[I],height:(fn=B.rowHeights)==null?void 0:fn[d],position:Ve?"sticky":void 0,left:I<dn?I*80+40:void 0,zIndex:Ve?1:void 0,...te},colSpan:w==null?void 0:w.colSpan,rowSpan:w==null?void 0:w.rowSpan,onMouseDown:cn=>Ce(d,I,cn),onMouseEnter:()=>Le(d,I),onDoubleClick:()=>an(d,I),onContextMenu:cn=>qn(cn,d,I),role:"gridcell","aria-selected":E,title:w==null?void 0:w.comment,children:[(w==null?void 0:w.comment)&&e.jsx("span",{className:"nice-spreadsheet__comment-indicator"}),Ie?e.jsx("input",{ref:je,className:"nice-spreadsheet__cell-editor",value:K,onChange:cn=>he(cn.target.value),onKeyDown:en,onBlur:rn}):Wt(Se,w==null?void 0:w.format)]},I)})]},d))})]})}),ne&&!o&&f&&e.jsxs("div",{className:"nice-spreadsheet__context-menu",style:{position:"fixed",left:ne.x,top:ne.y,zIndex:1e3},children:[e.jsx(ae.Fe,{variant:"ghost",size:"sm",onClick:()=>{Fn(f.row),pe(null)},children:S("spreadsheet.insertRowAbove","Insert row above")}),e.jsx(ae.Fe,{variant:"ghost",size:"sm",onClick:()=>{Fn(f.row+1),pe(null)},children:S("spreadsheet.insertRowBelow","Insert row below")}),e.jsx(ae.Fe,{variant:"ghost",size:"sm",onClick:()=>{Pn(f.col),pe(null)},children:S("spreadsheet.insertColLeft","Insert column left")}),e.jsx(ae.Fe,{variant:"ghost",size:"sm",onClick:()=>{Pn(f.col+1),pe(null)},children:S("spreadsheet.insertColRight","Insert column right")}),e.jsx("hr",{className:"nice-spreadsheet__context-sep"}),e.jsx(ae.Fe,{variant:"ghost",size:"sm",onClick:()=>{ze(f.row),pe(null)},children:S("spreadsheet.deleteRow","Delete row")}),e.jsx(ae.Fe,{variant:"ghost",size:"sm",onClick:()=>{Ze(f.col),pe(null)},children:S("spreadsheet.deleteCol","Delete column")})]}),gn&&e.jsxs("div",{className:"nice-spreadsheet__status-bar",children:[e.jsxs("span",{children:[S("spreadsheet.count","Count"),": ",gn.count]}),gn.sum!==void 0&&e.jsxs("span",{children:[S("spreadsheet.sum","Sum"),": ",gn.sum.toFixed(2)]}),gn.avg!==void 0&&e.jsxs("span",{children:[S("spreadsheet.avg","Avg"),": ",gn.avg.toFixed(2)]}),gn.min!==void 0&&e.jsxs("span",{children:[S("spreadsheet.min","Min"),": ",gn.min]}),gn.max!==void 0&&e.jsxs("span",{children:[S("spreadsheet.max","Max"),": ",gn.max]})]}),m&&e.jsxs("div",{className:"nice-spreadsheet__tabs",role:"tablist",children:[z.map((c,d)=>e.jsx("span",{className:"nice-spreadsheet__tab-wrapper",children:T===d?e.jsx(ae.Re,{className:"nice-spreadsheet__tab-rename",value:Re,onChange:j=>De(j),onBlur:()=>Vn(d,Re),onKeyDown:j=>{j.key==="Enter"&&Vn(d,Re),j.key==="Escape"&&Ee(null)},autoFocus:!0}):e.jsx("span",{onDoubleClick:()=>{o||(Ee(d),De(c.name))},children:e.jsx(ae.Fe,{variant:d===N?"primary":"ghost",size:"sm",onClick:()=>le(d),children:c.name})})},d)),!o&&e.jsxs(e.Fragment,{children:[e.jsx(ae.Fe,{variant:"ghost",size:"sm",onClick:En,title:S("spreadsheet.addSheet","Add sheet"),children:"+"}),z.length>1&&e.jsx(ae.Fe,{variant:"ghost",size:"sm",onClick:Hn,title:S("spreadsheet.removeSheet","Remove sheet"),children:"×"})]})]})]})});Zt.displayName="NiceSpreadsheet";exports.N=_i;exports.a=xt;exports.c=Ht;exports.d=hi;exports.f=Kt;exports.g=Bt;exports.j=Zt;exports.k=ci;exports.l=xi;exports.m=Hi;exports.n=fi;exports.o=pi;exports.p=Gt;exports.q=it;exports.r=oi;exports.s=yi;
|