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