@nice2dev/ui 1.0.19 → 1.0.21
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 +105 -0
- package/dist/NiceErrorBoundary-B9UWIYPz.js +770 -0
- package/dist/NiceErrorBoundary-Bzx-bOeb.cjs +1 -0
- package/dist/NiceErrorBoundary-CFJh1FyM.js +770 -0
- package/dist/NiceErrorBoundary-DvA00DOz.cjs +1 -0
- package/dist/NiceErrorBoundary-XNceAa-3.cjs +1 -0
- package/dist/NiceErrorBoundary-eTwBEuSH.js +770 -0
- package/dist/NiceErrorBoundary-qp4IJ18o.js +770 -0
- package/dist/NiceErrorBoundary-uT48n_F7.cjs +1 -0
- package/dist/NiceForm-B1Okz7SW.cjs +382 -0
- package/dist/NiceForm-BE8vt5k6.js +5383 -0
- package/dist/NiceForm-BXHPoTcH.cjs +382 -0
- package/dist/NiceForm-BzKlOWJa.js +5383 -0
- package/dist/NiceForm-DL7Kxsi2.js +5383 -0
- package/dist/NiceForm-DYPj-XoP.cjs +382 -0
- package/dist/NiceForm-DZ8jwtA8.cjs +382 -0
- package/dist/NiceForm-D_XZxq3a.js +5383 -0
- package/dist/NiceForm.css +1 -1
- package/dist/NiceModal-0Sg2HxIb.cjs +1 -0
- package/dist/NiceModal-BOkmGqPj.cjs +1 -0
- package/dist/NiceModal-BRih_XEH.js +95 -0
- package/dist/NiceModal-C-yKNnig.cjs +1 -0
- package/dist/NiceModal-C4HIsjrn.js +95 -0
- package/dist/NiceModal-DSabJ81z.js +95 -0
- package/dist/NiceModal-DieswZtd.cjs +1 -0
- package/dist/NiceModal-DjN1yXgw.js +95 -0
- package/dist/NiceModuleLifecyclePanel-95lS8pXO.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-C4jlm9tl.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-CEfeJxw_.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-D4xWUswk.js +6777 -0
- package/dist/NiceModuleLifecyclePanel-L5FNYzF9.js +6781 -0
- package/dist/NiceModuleLifecyclePanel-LdYOMLA6.js +6777 -0
- package/dist/NiceModuleLifecyclePanel-jDzEfvDM.js +6553 -0
- package/dist/NiceModuleLifecyclePanel-sBJLlhJp.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel.css +1 -1
- package/dist/NicePagination-B2TC6MTL.cjs +1 -0
- package/dist/NicePagination-BAywVGwT.js +171 -0
- package/dist/NicePagination-BT8UWXYG.js +171 -0
- package/dist/NicePagination-CJqksuAl.cjs +1 -0
- package/dist/NicePagination-CiWxbXT9.cjs +1 -0
- package/dist/NicePagination-DnnypBiE.js +171 -0
- package/dist/NicePagination-F8NyMfgc.cjs +1 -0
- package/dist/NicePagination-d6vm1ce3.js +171 -0
- package/dist/NicePinCodeInput-BY_tgKaU.cjs +419 -0
- package/dist/NicePinCodeInput-Bo8Ahkae.js +12240 -0
- package/dist/NicePinCodeInput-CpPtHZsK.js +12240 -0
- package/dist/NicePinCodeInput-Cpa01Yfg.cjs +419 -0
- package/dist/NicePinCodeInput-DDK6qqFW.js +12240 -0
- package/dist/NicePinCodeInput-DdXTdocN.js +12240 -0
- package/dist/NicePinCodeInput-JvYd_LB_.cjs +419 -0
- package/dist/NicePinCodeInput-qAO9tRhm.cjs +419 -0
- package/dist/NiceSavedQueryPanel-BOBULytX.js +6455 -0
- package/dist/NiceSavedQueryPanel-CTfC-qwV.cjs +596 -0
- package/dist/NiceSavedQueryPanel-CpcjQZDl.cjs +596 -0
- package/dist/NiceSavedQueryPanel-Dryck7pv.js +6584 -0
- package/dist/NiceSavedQueryPanel-DtgcsEls.js +6584 -0
- package/dist/NiceSavedQueryPanel-DuonbEem.js +6584 -0
- package/dist/NiceSavedQueryPanel-MdKdGYNg.cjs +596 -0
- package/dist/NiceSavedQueryPanel-TUoWkvpW.cjs +596 -0
- package/dist/NiceTabs-BjBtazRn.cjs +1 -0
- package/dist/NiceTabs-C-VQXNIa.cjs +1 -0
- package/dist/NiceTabs-CJ8G2t0-.js +1657 -0
- package/dist/NiceTabs-D91-vW_P.js +1657 -0
- package/dist/NiceTabs-DirTIQjD.cjs +1 -0
- package/dist/NiceTabs-dwNCzbJ2.cjs +1 -0
- package/dist/NiceTabs-nQEYYbsV.js +1657 -0
- package/dist/NiceTabs-v7HfeXIw.js +1657 -0
- package/dist/NiceWindow-BMiF-so6.cjs +1 -0
- package/dist/NiceWindow-C677O__r.js +1418 -0
- package/dist/NiceWindow-CmgJGE4d.js +1418 -0
- package/dist/NiceWindow-CysIgnn3.js +1418 -0
- package/dist/NiceWindow-D6SjpDc4.cjs +1 -0
- package/dist/NiceWindow-DUTRQOaP.js +1418 -0
- package/dist/NiceWindow-D_h01zyu.cjs +1 -0
- package/dist/NiceWindow-fcTJOlYf.cjs +1 -0
- package/dist/charts-8Bqzj1TE.js +4657 -0
- package/dist/charts-CFn-7PzC.cjs +761 -0
- package/dist/charts-CJlMAHJG.cjs +761 -0
- package/dist/charts-CLbJ4Zjq.js +4657 -0
- package/dist/charts-CUMpSAQe.cjs +761 -0
- package/dist/charts-CX4jiyVh.cjs +761 -0
- package/dist/charts-CYpqDxHd.js +4657 -0
- package/dist/charts-P6qura0j.js +4657 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.mjs +1 -1
- package/dist/core-BFu5opn6.js +23131 -0
- package/dist/core-BfeyB9A8.cjs +96 -0
- package/dist/core-BgGSTko-.js +22401 -0
- package/dist/core-Bit5kLWQ.cjs +96 -0
- package/dist/core-D0ElqRZA.cjs +96 -0
- package/dist/core-DDJKu5LZ.cjs +96 -0
- package/dist/core-DICON6Z7.js +23129 -0
- package/dist/core-XsWxyBHD.js +22767 -0
- package/dist/data.cjs +1 -1
- package/dist/data.mjs +1 -1
- package/dist/editors.cjs +1 -1
- package/dist/editors.mjs +3 -3
- package/dist/feedback.cjs +1 -1
- package/dist/feedback.mjs +2 -2
- package/dist/index-B-WxtREy.js +65040 -0
- package/dist/index-ByDRtfrm.js +65050 -0
- package/dist/index-CQIDqjZp.cjs +5194 -0
- package/dist/index-CXVXf_HY.cjs +5194 -0
- package/dist/index-CtikFbFa.js +64337 -0
- package/dist/index-DnfPyuXA.cjs +5194 -0
- package/dist/index-DxO61OUF.cjs +5194 -0
- package/dist/index-xVJiF843.js +65040 -0
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +294 -5
- package/dist/index.mjs +875 -861
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.mjs +3 -3
- package/dist/navigation.cjs +1 -1
- package/dist/navigation.d.ts +35 -2
- package/dist/navigation.mjs +22 -22
- package/dist/overlays.cjs +1 -1
- package/dist/overlays.mjs +2 -2
- package/dist/style.css +3 -3
- package/package.json +3 -3
|
@@ -0,0 +1,596 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),Re=require("./core-BfeyB9A8.cjs"),t=require("react"),ni=require("./NiceForm-B1Okz7SW.cjs"),ii=require("./NiceModal-0Sg2HxIb.cjs"),Ci=require("./NicePagination-B2TC6MTL.cjs"),ze=require("./NiceTabs-BjBtazRn.cjs");function Mi({columns:n,data:a,striped:s,compact:r,emptyText:o,className:p,style:_,accessMode:l,id:g,displayStyle:S}){const V=Re.Zs(l,g)==="hidden",R=Re.vs("table",S),ae=Re.Ss("table",S),[q,P]=t.useState(null),L=t.useMemo(()=>q?[...a].sort((f,x)=>{const v=f[q.field]??"",T=x[q.field]??"",$=typeof v=="number"?v-T:String(v).localeCompare(String(T));return q.dir==="desc"?-$:$}):a,[a,q]),N=f=>{P(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:{...R,..._},children:e.jsxs("table",{className:`nice-table nice-table--ds-${ae} ${s?"nice-table--striped":""} ${r?"nice-table--compact":""}`,"aria-rowcount":L.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&&N(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:L.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:n.length,className:"nice-table__empty",children:o||"No data"})}):L.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:S,onSelectionChange:D,pagination:V,pageSize:R=10,page:ae,onPageChange:q,totalRows:P,searchable:L,searchPlaceholder:N,virtualScroll:f,rowHeight:x=40,groupBy:v,groupRender:T,onCellEdit:$,editMode:re="inline",formItems:ve,formColumns:z=2,editFormTitle:X,formProps:le,onRowEdit:de,onRowAdd:ke,onRowDelete:U,bulkActions:M,onBulkDelete:w,exportCsv:c,exportFilename:_e="export",detailRow:je,expandedRowKeys:se,onExpandedRowChange:j,columnReorder:ne,onColumnReorder:O,columnResize:me,rowDraggable:J,onRowReorder:Ae,striped:Xe,compact:at,loading:Ee,emptyText:We,toolbar:Ve,onRowClick:Be,pinnedTopKeys:Z,pinnedBottomKeys:Se,colSpan:He,showStatusBar:Ne,contextMenuItems:k,onContextMenuAction:Q,printFriendly:F,keyboardNavigation:G,focusedCell:be,onFocusedCellChange:H,cellRangeSelection:Ce,selectedCellRange:Me,onCellRangeChange:ue,clipboard:Te,clipboardFormat:st="text",onBeforeCopy:ut,onCopy:we,onPaste:Tt,quickFilters:ht,activeQuickFilters:St,onQuickFilterChange:wt,columnGroups:I,stateStorageKey:Y,initialState:pe,onStateChange:nt,flashRowKeys:ft,flashDuration:De=500,autoFitColumns:Ke,showColumnStats:Ge,rowIndicator:mt,frozenRows:rt,className:kt,style:Vt,accessMode:tn,id:Xt,displayStyle:Ht}){const pt=Re.Zs(tn,Xt),mn=pt==="hidden",nn=pt==="readOnly"||pt==="disabled",{t:Pe}=Re.$o();Re.vs("table",Ht),Re.Ss("table",Ht);const Qe=Re.ad(r??null,{autoLoad:!!r,defaultPageSize:R}),Fe=!!r,Kt=Fe?Qe.data:a??[],d=Fe?Qe.loading:Ee,[h,A]=t.useState({field:"",dir:null}),[K,ee]=t.useState(1),[E,B]=t.useState(new Set),[ie,oe]=t.useState(""),[$e,Oe]=t.useState(R),[xe,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=se??Ft,[ot,pn]=t.useState({}),[At,Wt]=t.useState(null),[Bt,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=be??Sn,gt=Me??Ot,bt=St??Cn;t.useEffect(()=>{if(!Y)return;const i=localStorage.getItem(`nice-datagrid-${Y}`);if(i&&!pe)try{const u=JSON.parse(i);u.columnWidths&&pn(u.columnWidths),u.expandedGroups&&Ut(new Set(u.expandedGroups))}catch{}},[Y,pe]),t.useEffect(()=>{if(!ft?.size)return;xn(new Set(ft));const i=setTimeout(()=>xn(new Set),De);return()=>clearTimeout(i)},[ft,De]),t.useEffect(()=>{if(!Bt)return;const i=()=>sn(null);return document.addEventListener("click",i),()=>document.removeEventListener("click",i)},[Bt]);const In=t.useCallback((i,u)=>{k?.length&&(i.preventDefault(),sn({x:i.clientX,y:i.clientY,row:u}))},[k]),y=t.useCallback(i=>{const u=new Set($t);u.has(i)?u.delete(i):u.add(i),j?j(u):Rt(u)},[$t,j]),he=t.useCallback((i,u)=>{if(!me)return;u.preventDefault();const m=u.clientX,C=u.target.closest("th")?.offsetWidth??100,te=W=>{const ye=Math.max(40,C+W.clientX-m);pn(Ze=>({...Ze,[i]:ye}))},ce=()=>{document.removeEventListener("mousemove",te),document.removeEventListener("mouseup",ce)};document.addEventListener("mousemove",te),document.addEventListener("mouseup",ce)},[me]),ge=Fe?Qe.sort[0]?.field??"":p??h.field,fe=Fe?Qe.sort[0]?.direction??null:_??h.dir,lt=Fe?Qe.page:ae??K,Le=S??E;t.useCallback(()=>{if(!Y)return;const i={columnWidths:ot,sortField:ge||void 0,sortDirection:fe,pageSize:$e,expandedGroups:Array.from(Dt)};localStorage.setItem(`nice-datagrid-${Y}`,JSON.stringify(i)),nt?.(i)},[Y,ot,ge,fe,$e,Dt,nt]);const qe=t.useMemo(()=>n.filter(i=>!i.hidden),[n]),dt=t.useMemo(()=>qe.filter(i=>i.pinned==="left"),[qe]),ln=t.useMemo(()=>qe.filter(i=>i.pinned==="right"),[qe]),Fn=t.useMemo(()=>qe.filter(i=>!i.pinned),[qe]),Ue=t.useMemo(()=>[...dt,...Fn,...ln],[dt,Fn,ln]),mi=t.useMemo(()=>qe.some(i=>i.aggregate),[qe]),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):A({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=>qe.some(b=>String(m[b.field]??"").toLowerCase().includes(u)))}return!l&&ge&&fe&&i.sort((u,m)=>{const b=u[ge]??"",C=m[ge]??"",te=typeof b=="number"?b-C:String(b).localeCompare(String(C));return fe==="desc"?-te:te}),i},[Kt,ie,qe,ge,fe,l,Fe]),_n=Fe?Qe.totalCount:P??yt.length,Qt=Fe?Qe.pageSize:$e,pi=Math.max(1,Math.ceil(_n/Qt)),Et=Fe?yt:V&&!P?yt.slice((lt-1)*Qt,lt*Qt):yt,Rn=t.useCallback(i=>{Fe?Qe.setPage(i):q?q(i):ee(i)},[Fe,Qe,q]),Yt=t.useMemo(()=>Et.map(i=>String(i[s])),[Et,s]),Jt=Yt.length>0&&Yt.every(i=>Le.has(i)),Un=Yt.some(i=>Le.has(i)),Wn=t.useCallback(()=>{const i=new Set(Le);Jt?Yt.forEach(u=>i.delete(u)):Yt.forEach(u=>i.add(u)),D?D(i):B(i)},[Jt,Yt,Le,D]),Bn=t.useCallback(i=>{const u=new Set(Le);u.has(i)?u.delete(i):u.add(i),D?D(u):B(u)},[Le,D]),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 C=`__group_${String(b)}`,te=Dt.has(C);u.push({type:"group",value:b,rows:m,expanded:te,key:C}),te&&m.forEach((ce,W)=>u.push({type:"data",row:ce,key:String(ce[s]??`${C}_${W}`)}))}),u},[Et,v,s,Dt]),{pinnedTopRows:gi,pinnedBottomRows:fi,normalRows:xi}=t.useMemo(()=>{if(!Z?.size&&!Se?.size)return{pinnedTopRows:[],pinnedBottomRows:[],normalRows:vt};const i=[],u=[],m=[];for(const b of vt){if(b.type==="data"){const C=b.key;if(Z?.has(C)){i.push(b);continue}if(Se?.has(C)){u.push(b);continue}}m.push(b)}return{pinnedTopRows:i,pinnedBottomRows:u,normalRows:m}},[vt,Z,Se]),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((C,te)=>({...C,_vIdx:m+te}))},[f,vt,Pt,x]),bn=t.useCallback((i,u,m)=>{!$||nn||(Ye({rowKey:i,field:u}),Mt(m))},[$]),Kn=t.useCallback(()=>{xe&&$&&$(xe.rowKey,xe.field,Ct),Ye(null),Mt(null)},[xe,Ct,$]),bi=t.useCallback(()=>{Ye(null),Mt(null)},[]),yi=t.useCallback(()=>{const i=qe,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
|
+
`),C=new Blob(["\uFEFF"+b],{type:"text/csv;charset=utf-8;"}),te=URL.createObjectURL(C),ce=document.createElement("a");ce.href=te,ce.download=`${_e}.csv`,ce.click(),URL.revokeObjectURL(te)},[qe,yt,_e]),yn=t.useCallback(i=>{H?H(i):rn(i)},[H]),vn=t.useCallback(i=>{ue?ue(i):gn(i)},[ue]),jt=t.useMemo(()=>vt.filter(i=>i.type==="data").map(i=>i.key),[vt]),vi=t.useCallback(i=>{if(!G||xe||!ct)return;const u=jt.indexOf(ct.rowKey),m=Ue.findIndex(ce=>ce.field===ct.field);if(u<0||m<0)return;let b=u,C=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":C=Math.max(0,m-1);break;case"ArrowRight":C=Math.min(Ue.length-1,m+1);break;case"Tab":i.preventDefault(),i.shiftKey?C=Math.max(0,m-1):C=Math.min(Ue.length-1,m+1);break;case"Enter":{const ce=Ue[m];if(ce.editable&&$){const W=Et.find(ye=>String(ye[s])===ct.rowKey);W&&bn(ct.rowKey,ce.field,W[ce.field])}return}case"Escape":yn(null),vn(null);return;case"Home":i.ctrlKey&&(b=0),C=0;break;case"End":i.ctrlKey&&(b=jt.length-1),C=Ue.length-1;break;case"PageUp":b=Math.max(0,u-$e);break;case"PageDown":b=Math.min(jt.length-1,u+$e);break;default:return}i.preventDefault();const te={rowKey:jt[b],field:Ue[C].field};if(yn(te),i.shiftKey&&Ce){const ce=gt?.start??ct;vn({start:ce,end:te})}else vn(null)},[G,xe,ct,jt,Ue,Ce,gt,yn,vn,$,Et,s,bn,$e]),Zn=t.useCallback(()=>{let i=[],u=[];if(gt){const m=jt.indexOf(gt.start.rowKey),b=jt.indexOf(gt.end.rowKey),C=Math.min(m,b),te=Math.max(m,b),ce=Ue.findIndex(et=>et.field===gt.start.field),W=Ue.findIndex(et=>et.field===gt.end.field),ye=Math.min(ce,W),Ze=Math.max(ce,W);u=Ue.slice(ye,Ze+1).map(et=>et.field),i=Et.filter(et=>{const Gt=jt.indexOf(String(et[s]));return Gt>=C&&Gt<=te})}else Le.size>0&&(i=Et.filter(m=>Le.has(String(m[s]))),u=Ue.map(m=>m.field));return{rows:i,fields:u}},[gt,jt,Ue,Et,s,Le]),qn=t.useCallback((i,u,m)=>{const b=Ue.filter(C=>u.includes(C.field));switch(m){case"json":return JSON.stringify(i.map(C=>Object.fromEntries(u.map(te=>[te,C[te]]))),null,2);case"csv":{const C=b.map(ce=>un(ce.header)).join(","),te=i.map(ce=>b.map(W=>un(String(ce[W.field]??""))).join(",")).join(`
|
|
4
|
+
`);return C+`
|
|
5
|
+
`+te}case"html":{const C=b.map(ce=>`<th>${ce.header}</th>`).join(""),te=i.map(ce=>`<tr>${b.map(W=>`<td>${ce[W.field]??""}</td>`).join("")}</tr>`).join("");return`<table><thead><tr>${C}</tr></thead><tbody>${te}</tbody></table>`}case"markdown":{const C="| "+b.map(W=>W.header).join(" | ")+" |",te="| "+b.map(()=>"---").join(" | ")+" |",ce=i.map(W=>"| "+b.map(ye=>W[ye.field]??"").join(" | ")+" |").join(`
|
|
6
|
+
`);return C+`
|
|
7
|
+
`+te+`
|
|
8
|
+
`+ce}default:return i.map(C=>b.map(te=>C[te.field]??"").join(" ")).join(`
|
|
9
|
+
`)}},[Ue]),An=t.useCallback(async()=>{if(!Te)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)},[Te,Zn,ut,qn,st,we]),Xn=t.useCallback(async()=>{if(!Te||!ct||!Tt)return;const u=(await navigator.clipboard.readText()).split(`
|
|
10
|
+
`).map(m=>m.split(" "));Tt(u,ct)},[Te,ct,Tt]);t.useEffect(()=>{if(!Te||!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)}},[Te,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,Ze)=>ye+Ze,0),C=b/m.length,te=Math.min(...m),ce=Math.max(...m),W=Math.sqrt(m.reduce((ye,Ze)=>ye+(Ze-C)**2,0)/m.length);return{count:m.length,sum:b,avg:C,min:te,max:ce,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 C=i.visualMin??0,te=i.visualMax??100,ce=Math.max(0,Math.min(100,(b-C)/(te-C)*100));switch(i.cellVisualization){case"progress":return e.jsxs("div",{className:"nice-datagrid__cell-progress",style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("div",{style:{flex:1,height:6,background:"var(--border-color)",borderRadius:3,overflow:"hidden"},children:e.jsx("div",{style:{width:`${ce}%`,height:"100%",background:ce>80?"var(--color-success)":ce>50?"var(--color-primary)":"var(--color-warning)",transition:"width 0.3s ease"}})}),e.jsxs("span",{style:{fontSize:"0.75rem",minWidth:32,textAlign:"right"},children:[Math.round(ce),"%"]})]});case"rating":{const W=Math.round(b/te*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,Ze=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(Ze,{})," ",Math.abs(ye).toFixed(1),"%"]})}case"heatmap":{const W=ce/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 C=0;C<u;C++){const te=Ue[C];te.pinned==="left"&&(b+=typeof te.width=="number"?te.width:parseInt(String(te.width)||"100",10))}g&&u===0&&(b=36),m.left=b}else{let b=0;for(let C=Ue.length-1;C>u;C--){const te=Ue[C];te.pinned==="right"&&(b+=typeof te.width=="number"?te.width:parseInt(String(te.width)||"100",10))}m.right=b}return m},[on,Ue,g]),Qn=(i,u,m,b)=>{if(xe?.rowKey===m&&xe?.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 te=wi(i,u[i.field],u);return te||(i.render?i.render(u[i.field],u,b):$i(u[i.field]))},Si=(i,u,m,b)=>{const C=ct?.rowKey===m&&ct?.field===i.field,te=gt&&(()=>{const ye=jt.indexOf(gt.start.rowKey),Ze=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,Ze)&&et<=Math.max(ye,Ze)&&b>=Math.min(Gt,Zt)&&b<=Math.max(Gt,Zt)})(),ce=ki(i,u[i.field],u);return{className:[ce.className,C&&"nice-datagrid__cell--focused",te&&"nice-datagrid__cell--in-range"].filter(Boolean).join(" "),style:{...En(i,b),textAlign:i.align,...ce.style,...C?{outline:"2px solid var(--color-primary)",outlineOffset:-2}:{},...te?{background:"var(--color-primary-light, rgba(59,130,246,0.15))"}:{}}}},jn=Ue.length+(g?1:0)+(je?1:0)+(J?1:0)+(mt?1:0),$n=(i,u,m)=>{const{row:b,key:C}=i,te=Le.has(C),ce=$t.has(C),W=Dn.has(C),ye=[te&&"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:()=>Be?.(b),onDoubleClick:re==="popup"&&(de||$)?()=>_t({key:C,data:{...b}}):void 0,onContextMenu:Ze=>In(Ze,b),style:Be||re==="popup"?{cursor:"pointer"}:void 0,draggable:J,onDragStart:J?()=>Wt(u):void 0,onDragOver:J?Ze=>Ze.preventDefault():void 0,onDrop:J&&Ae&&At!=null?()=>{Ae(At,u),Wt(null)}:void 0,onDragEnd:J?()=>Wt(null):void 0,children:[mt&&e.jsx("td",{className:"nice-datagrid__row-indicator",style:{width:32,padding:"0 4px"},children:mt(b)}),je&&e.jsx("td",{className:"nice-datagrid__expand-col",onClick:Ze=>{Ze.stopPropagation(),y(C)},children:e.jsx("span",{className:"nice-datagrid__expand-btn","data-expanded":ce,children:ce?e.jsx(dn,{}):e.jsx(Nn,{})})}),J&&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:Ze=>Ze.stopPropagation(),style:on?{position:"sticky",left:0,zIndex:1,background:"var(--bg-primary, #fff)"}:void 0,children:e.jsx("input",{type:"checkbox",checked:te,onChange:()=>Bn(C),"aria-label":`Select row ${C}`})}),(()=>{let Ze=0;return Ue.map((et,Gt)=>{if(Ze>0)return Ze--,null;const Zt=He?He(b,et,Gt):void 0;Zt&&Zt>1&&(Ze=Zt-1);const en=Si(et,b,C,Gt);return e.jsx("td",{colSpan:Zt,className:en.className,style:en.style,onClick:G?()=>yn({rowKey:C,field:et.field}):void 0,onDoubleClick:et.editable&&$?()=>bn(C,et.field,b[et.field]):void 0,children:Qn(et,b,C,u)},et.field)})})()]}),je&&ce&&e.jsx("tr",{className:"nice-datagrid__detail-row",children:e.jsx("td",{colSpan:jn,children:je(b)})})]},C)};return mn?null:e.jsxs("div",{ref:cn,className:`nice-datagrid ${F?"nice-datagrid--print":""} ${kt||""}`,style:Vt,role:"grid","aria-label":Pe("datagrid.title","Data Grid"),"aria-rowcount":vt.length,"aria-colcount":qe.length,"aria-busy":d||void 0,tabIndex:G?0:void 0,onKeyDown:G?vi:void 0,children:[(L||Ve||c||ht?.length||ke)&&e.jsxs("div",{className:"nice-datagrid__toolbar",children:[L&&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):(oe(i.target.value),Rn(1))},placeholder:N||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))}),Te&&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")]}),Ve]}),g&&Le.size>0&&(M?.length||w)&&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(Le.size))}),(M||[]).map(i=>{const u=Array.from(Le),m=Hn.filter(C=>Le.has(String(C[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)}),w&&!M?.length&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--sm nice-btn--danger",onClick:()=>{const i=Array.from(Le),u=Hn.filter(m=>Le.has(String(m[s])));w(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;S===void 0&&B(i),D?.(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:`${Xe?"nice-table--striped":""} ${at?"nice-table--compact":""}`,style:{position:"sticky",top:0,zIndex:3},children:e.jsx("thead",{children:e.jsxs("tr",{children:[je&&e.jsx("th",{className:"nice-datagrid__expand-col",style:{width:36}}),J&&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:Wn,"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}),me&&e.jsx("span",{className:"nice-datagrid__resize-handle",onMouseDown:m=>{m.stopPropagation(),he(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,{})}),T?T(W.value,W.rows):e.jsxs(e.Fragment,{children:[String(W.value)," (",W.rows.length,")"]})]},W.key)}const{row:b,key:C}=i,te=Le.has(C),ce=$t.has(C);return e.jsxs(t.Fragment,{children:[e.jsxs("div",{className:`nice-datagrid__vrow ${te?"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:()=>Be?.(b),onDoubleClick:re==="popup"&&(de||$)?()=>_t({key:C,data:{...b}}):void 0,draggable:J,onDragStart:J?()=>Wt(u):void 0,onDragOver:J?W=>W.preventDefault():void 0,onDrop:J&&Ae&&At!=null?()=>{Ae(At,u),Wt(null)}:void 0,onDragEnd:J?()=>Wt(null):void 0,children:[je&&e.jsx("div",{className:"nice-datagrid__expand-col",style:{width:36,flexShrink:0,textAlign:"center",cursor:"pointer"},onClick:W=>{W.stopPropagation(),y(C)},children:e.jsx("span",{className:"nice-datagrid__expand-btn","data-expanded":ce,children:ce?e.jsx(dn,{}):e.jsx(Nn,{})})}),J&&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:te,onChange:()=>Bn(C)})}),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(C,W.field,b[W.field]):void 0,children:Qn(W,b,C,m)},W.field))]}),je&&ce&&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:je(b)})]},C)})]}),!f&&e.jsxs("table",{className:`${Xe?"nice-table--striped":""} ${at?"nice-table--compact":""}`,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[je&&e.jsx("th",{className:"nice-datagrid__expand-col",style:{width:36}}),J&&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:Wn,"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}),me&&e.jsx("span",{className:"nice-datagrid__resize-handle",onMouseDown:C=>{C.stopPropagation(),he(i.field,C)}})]},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:We||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,{})}),T?T(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&&Le.size>0&&e.jsxs("span",{children:[Pe("controls.selected","Selected"),": ",Le.size]})]}),Bt&&k&&e.jsx("div",{className:"nice-datagrid__context-menu",style:{position:"fixed",left:Bt.x,top:Bt.y,zIndex:9999},onClick:i=>i.stopPropagation(),children:k.map(i=>e.jsxs("button",{className:"nice-datagrid__context-item",disabled:i.disabled,onClick:()=>{Q?.(i.key,Bt.row),sn(null)},children:[i.icon&&e.jsx("span",{className:"nice-datagrid__context-icon",children:i.icon}),i.label]},i.key))}),(re==="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:z,showActions:!0,submitLabel:i?Pe("controls.add","Add"):Pe("controls.save","Save"),cancelLabel:Pe("controls.cancel","Cancel"),onCancel:()=>_t(null),...le,onFieldChange:(m,b)=>_t(C=>C&&{...C,data:{...C.data,[m]:b}}),onSubmit:m=>{i?ke?.(m):Je.key&&(de?de(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:S=!0,exampleQueries:D=["Show items from last week","Filter by status = active","Orders over $1000",'Names starting with "A"'],columns:V,data:R,...ae}=n,[q,P]=t.useState(""),[L,N]=t.useState([]),[f,x]=t.useState([]),[v,T]=t.useState(!1),[$,re]=t.useState(null),ve=t.useRef(null),{t:z}=Re.$o(),X=Re.ie(),{parseFilter:le,isLoading:de}=Re.Rl(),ke=s&&X.isConfigured,U=L.length>0?zi(R||[],L):R,M=t.useCallback(async j=>{if(!ke||!o||!j.trim())return;re(j);const ne=Ti(V);try{const O=await le(j,ne);N(O),l?.(j,O)}catch{N([])}},[ke,o,V,le,l]),w=t.useCallback(()=>{N([]),re(null),P("")},[]),c=t.useCallback(()=>L,[L]),_e=t.useCallback(async()=>{if(!ke||!p||!R?.length)return[];try{const j=await X.complete([{role:"user",content:`Analyze this data and provide 3-5 key insights. Data sample (${R.length} total rows): ${JSON.stringify(R.slice(0,20))}
|
|
11
|
+
|
|
12
|
+
Columns: ${V.map(ne=>ne.field).join(", ")}
|
|
13
|
+
|
|
14
|
+
Return a JSON array of insight strings. Be specific with numbers and trends.`}],{temperature:.3,maxTokens:500});try{const ne=JSON.parse(j.content),O=Array.isArray(ne)?ne:[];return x(O),g?.(O),O}catch{return[]}}catch{return[]}},[ke,p,R,V,X,g]),je=j=>{j.preventDefault(),q.trim()&&M(q)},se=j=>{P(j),M(j)};return t.useImperativeHandle(a,()=>({applyNLFilter:M,clearAIFilters:w,getAIFilters:c,generateInsights:_e})),e.jsxs("div",{className:"nice-data-grid-ai","data-testid":n["data-testid"],children:[S&&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:je,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:j=>P(j.target.value),placeholder:_||z("dataGridAI.searchPlaceholder","Search with natural language..."),className:"nice-data-grid-ai__input",disabled:de}),de&&e.jsx("span",{className:"nice-data-grid-ai__loading-spinner"}),q&&!de&&e.jsx("button",{type:"button",className:"nice-data-grid-ai__clear-input",onClick:()=>P(""),children:"✕"})]}),e.jsx("button",{type:"submit",className:"nice-data-grid-ai__search-btn",disabled:de||!q.trim(),children:de?z("dataGridAI.searching","Searching..."):z("dataGridAI.search","Search")})]}),p&&e.jsxs("button",{type:"button",className:"nice-data-grid-ai__insights-btn",onClick:()=>{_e(),T(!0)},disabled:de||!R?.length,title:z("dataGridAI.generateInsights","Generate AI Insights"),children:["💡 ",z("dataGridAI.insights","Insights")]})]}),S&&ke&&o&&!$&&D.length>0&&e.jsxs("div",{className:"nice-data-grid-ai__examples",children:[e.jsx("span",{className:"nice-data-grid-ai__examples-label",children:z("dataGridAI.tryAsking","Try asking:")}),e.jsx("div",{className:"nice-data-grid-ai__examples-list",children:D.slice(0,4).map((j,ne)=>e.jsxs("button",{type:"button",className:"nice-data-grid-ai__example",onClick:()=>se(j),children:['"',j,'"']},ne))})]}),$&&L.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:["(",U?.length||0," ",z("dataGridAI.results","results"),")"]})]}),e.jsx("div",{className:"nice-data-grid-ai__filter-badges",children:L.map((j,ne)=>e.jsxs("span",{className:"nice-data-grid-ai__filter-badge",children:[j.field," ",j.operator," ",String(j.value)]},ne))}),e.jsxs("button",{type:"button",className:"nice-data-grid-ai__clear-filter",onClick:w,children:["✕ ",z("dataGridAI.clearFilter","Clear")]})]}),e.jsx("div",{className:"nice-data-grid-ai__grid-wrapper",children:e.jsx(kn,{columns:V,data:U,...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:["💡 ",z("dataGridAI.aiInsights","AI Insights")]}),e.jsx("button",{type:"button",className:"nice-data-grid-ai__insights-close",onClick:()=>T(!1),children:"✕"})]}),e.jsx("div",{className:"nice-data-grid-ai__insights-body",children:de?e.jsx("div",{className:"nice-data-grid-ai__insights-loading",children:z("dataGridAI.analyzing","Analyzing data...")}):f.length>0?e.jsx("ul",{className:"nice-data-grid-ai__insights-list",children:f.map((j,ne)=>e.jsxs("li",{className:"nice-data-grid-ai__insight",children:[e.jsx("span",{className:"nice-data-grid-ai__insight-bullet",children:"•"}),j]},ne))}):e.jsx("div",{className:"nice-data-grid-ai__insights-empty",children:z("dataGridAI.noInsights","Click to generate insights from your data")})}),e.jsx("div",{className:"nice-data-grid-ai__insights-footer",children:e.jsxs("button",{type:"button",className:"nice-data-grid-ai__refresh-insights",onClick:()=>_e(),disabled:de,children:["🔄 ",z("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:S,onItemClick:D,renderItem:V,showCheckboxes:R,loading:ae,emptyText:q,size:P="md",bordered:L=!0,swipeActions:N,className:f,style:x,accessMode:v,id:T})=>{const re=Re.Zs(v,T)==="hidden",{t:ve}=Re.$o(),[z,X]=t.useState(""),[le,de]=t.useState(null),[ke,U]=t.useState(null),M=t.useRef(null),w=t.useMemo(()=>{if(!z)return n;const j=z.toLowerCase();return n.filter(ne=>ne.text.toLowerCase().includes(j))},[n,z]),c=t.useMemo(()=>{if(!_)return null;const j=new Map;return w.forEach(ne=>{const O=String(ne[l]??"");j.has(O)||j.set(O,[]),j.get(O).push(ne)}),j},[w,_,l]),_e=t.useCallback(j=>{s&&(r==="single"?s(a.includes(j)?[]:[j]):r==="multiple"&&s(a.includes(j)?a.filter(ne=>ne!==j):[...a,j]))},[a,r,s]),je=t.useCallback(j=>{le!==null&&le!==j&&S&&S(le,j),de(null)},[le,S]),se=(j,ne)=>{const O=a.includes(j.key),me=ke===j.key;return e.jsxs("li",{className:`nice-list__item ${O?"nice-list__item--selected":""} ${j.disabled?"nice-list__item--disabled":""} ${me?"nice-list__item--swiped":""}`,onClick:()=>{j.disabled||(_e(j.key),D?.(j))},draggable:g,onDragStart:()=>de(ne),onDragOver:J=>J.preventDefault(),onDrop:()=>je(ne),onTouchStart:N?.length?J=>{M.current={x:J.touches[0].clientX,key:j.key}}:void 0,onTouchEnd:N?.length?J=>{if(!M.current)return;const Ae=J.changedTouches[0].clientX-M.current.x;Ae<-50&&M.current.key===j.key?U(j.key):Ae>50&&U(null),M.current=null}:void 0,role:r!=="none"?"option":void 0,"aria-selected":r!=="none"?O:void 0,children:[e.jsxs("div",{className:"nice-list__item-content",children:[R&&r!=="none"&&e.jsx("input",{type:"checkbox",checked:O,readOnly:!0,tabIndex:-1,className:"nice-list__checkbox"}),V?V(j):e.jsxs(e.Fragment,{children:[j.icon&&e.jsx("span",{className:"nice-list__icon",children:j.icon}),e.jsx("span",{className:"nice-list__text",children:j.text}),j.badge&&e.jsx("span",{className:"nice-list__badge",children:j.badge})]})]}),N&&me&&e.jsx("div",{className:"nice-list__swipe-actions",children:N.map(J=>e.jsx("button",{className:"nice-list__swipe-btn",style:J.color?{backgroundColor:J.color}:void 0,onClick:Ae=>{Ae.stopPropagation(),J.onClick(j),U(null)},children:J.label},J.key))})]},j.key)};return re?null:e.jsxs("div",{className:`nice-list nice-list--${P} ${L?"nice-list--bordered":""} ${f||""}`,style:x,children:[o&&e.jsx("div",{className:"nice-list__search",children:e.jsx("input",{type:"text",value:z,onChange:j=>X(j.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"})}):w.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(([j,ne])=>e.jsxs("div",{className:"nice-list__group",children:[e.jsx("div",{className:"nice-list__group-header",children:j}),e.jsx("ul",{className:"nice-list__items",children:ne.map((O,me)=>se(O,me))})]},j))}):e.jsx("ul",{className:"nice-list__items",role:"listbox",children:w.map((j,ne)=>se(j,ne))})]})};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:S,renderNode:D,showLines:V,loading:R,className:ae,style:q,accessMode:P,id:L,draggable:N,onNodeDrop:f,onLoadChildren:x,contextMenuItems:v,onContextMenuAction:T,editable:$,onNodeEdit:re,maxDepth:ve})=>{const X=Re.Zs(P,L)==="hidden",{t:le}=Re.$o(),[de,ke]=t.useState([]),[U,M]=t.useState(""),[w,c]=t.useState(new Set),[_e,je]=t.useState(new Map),[se,j]=t.useState(null),[ne,O]=t.useState(null),[me,J]=t.useState(null),[Ae,Xe]=t.useState(""),at=t.useRef(null),Ee=s??de,We=t.useMemo(()=>new Set(a),[a]),Ve=t.useCallback(async(k,Q)=>{const F=!Ee.includes(k),G=F?[...Ee,k]:Ee.filter(be=>be!==k);if(o?o(G):ke(G),F&&x&&!Q.children?.length&&Q.leaf!==!0&&!_e.has(k)){c(H=>new Set(H).add(k));const be=await x(Q);je(H=>new Map(H).set(k,be)),c(H=>{const Ce=new Set(H);return Ce.delete(k),Ce})}},[Ee,o,x,_e]),Be=t.useCallback((k,Q)=>{if(r){if(p==="single")r(a.includes(k)?[]:[k]);else if(p==="multiple")if(_&&Q.children?.length){const F=si(Q),G=[k,...F];if(Ln(Q,We)==="checked")r(a.filter(H=>!G.includes(H)));else{const H=new Set([...a,...G]);r(Array.from(H))}}else r(a.includes(k)?a.filter(F=>F!==k):[...a,k])}},[a,p,r,_,We]),Z=t.useCallback(k=>{if(!U)return!0;const Q=U.toLowerCase();return k.text.toLowerCase().includes(Q)?!0:(_e.get(k.key)??k.children)?.some(G=>Z(G))??!1},[U,_e]),Se=t.useCallback((k,Q)=>{v?.length&&(k.preventDefault(),O({x:k.clientX,y:k.clientY,node:Q}))},[v]),He=t.useCallback(()=>{me&&re&&re(me,Ae),J(null)},[me,Ae,re]),Ne=(k,Q)=>{if(U&&!Z(k))return null;const F=typeof ve=="number"?Math.min(10,Math.max(1,ve)):1/0,G=Q+1>=F,be=G?void 0:_e.get(k.key)??k.children,H=!G&&(be&&be.length>0||k.leaf!==!0&&x&&!be?.length),Ce=Ee.includes(k.key),Me=We.has(k.key),ue=w.has(k.key),Te=_&&p==="multiple"&&be?.length?Ln(k,We):Me?"checked":"unchecked",st=Math.min(Q+1,10),ut={paddingLeft:Q*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":H?Ce:void 0,"data-nice-depth":st,draggable:N&&!k.disabled,onDragStart:N?we=>{we.stopPropagation(),j(k.key)}:void 0,onDragOver:N?we=>{we.preventDefault(),we.stopPropagation()}:void 0,onDrop:N&&se?we=>{we.stopPropagation(),f?.(se,k.key,"inside"),j(null)}:void 0,onDragEnd:N?()=>j(null):void 0,children:[e.jsxs("div",{className:`nice-tree__row ${Me?"nice-tree__row--selected":""} ${k.disabled?"nice-tree__row--disabled":""} ${se===k.key?"nice-tree__row--dragging":""}`,style:ut,onClick:()=>{k.disabled||(Be(k.key,k),S?.(k))},onContextMenu:we=>Se(we,k),onDoubleClick:$&&!k.disabled?()=>{J(k.key),Xe(k.text)}:void 0,children:[e.jsx("span",{className:`nice-tree__toggle ${H?Ce?"nice-tree__toggle--expanded":"":"nice-tree__toggle--leaf"}`,onClick:we=>{we.stopPropagation(),H&&Ve(k.key,k)},children:ue?e.jsx("span",{className:"nice-spinner nice-spinner--xs"}):H?Ce?"▾":"▸":""}),_&&p!=="none"&&e.jsx("input",{type:"checkbox",checked:Te==="checked",ref:we=>{we&&(we.indeterminate=Te==="indeterminate")},onChange:()=>Be(k.key,k),onClick:we=>we.stopPropagation(),tabIndex:-1,className:"nice-tree__checkbox"}),me===k.key?e.jsx("input",{type:"text",className:"nice-tree__edit-input",value:Ae,onChange:we=>Xe(we.target.value),onBlur:He,onKeyDown:we=>{we.key==="Enter"&&He(),we.key==="Escape"&&J(null)},autoFocus:!0,onClick:we=>we.stopPropagation()}):D?D(k):e.jsxs(e.Fragment,{children:[k.icon&&e.jsx("span",{className:"nice-tree__icon",children:k.icon}),e.jsx("span",{className:"nice-tree__text",children:k.text})]})]}),be&&be.length>0&&Ce&&e.jsx("ul",{className:"nice-tree__children",role:"group",children:be.map(we=>Ne(we,Q+1))})]},k.key)};return X?null:e.jsxs("div",{className:`nice-tree ${V?"nice-tree--lines":""} ${ae||""}`,style:q,ref:at,onClick:()=>O(null),children:[l&&e.jsx("div",{className:"nice-tree__search",children:e.jsx("input",{type:"text",value:U,onChange:k=>M(k.target.value),placeholder:g||le("controls.search","Search..."),"aria-label":g||le("controls.search","Search tree")})}),R?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(k=>Ne(k,0))}),ne&&v&&e.jsx("div",{className:"nice-tree__context-menu",style:{position:"fixed",top:ne.y,left:ne.x,zIndex:9999},children:v.map(k=>e.jsxs("div",{className:`nice-tree__context-item ${k.disabled?"nice-tree__context-item--disabled":""}`,onClick:()=>{k.disabled||(T?.(k.key,ne.node),O(null))},children:[k.icon&&e.jsx("span",{children:k.icon}),k.label]},k.key))})]})};function Wi(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 Bi({columns:n,data:a,keyField:s="key",parentKeyField:r="parentKey",expandedKeys:o,onExpandedChange:p,selectedKeys:_=[],onSelectionChange:l,selectable:g,loading:S,emptyText:D,className:V,style:R,accessMode:ae,id:q}){const L=Re.Zs(ae,q)==="hidden",{t:N}=Re.$o(),[f,x]=t.useState([]),v=o??f,T=t.useMemo(()=>Wi(a,s,r),[a,s,r]),$=t.useMemo(()=>n.filter(X=>!X.hidden),[n]),re=t.useCallback(X=>{const le=v.includes(X)?v.filter(de=>de!==X):[...v,X];p?p(le):x(le)},[v,p]),ve=t.useCallback(X=>{l&&l(_.includes(X)?_.filter(le=>le!==X):[..._,X])},[_,l]),z=(X,le)=>{const de=String(X[s]),ke=X.children&&X.children.length>0,U=v.includes(de),M=_.includes(de);return e.jsxs(t.Fragment,{children:[e.jsxs("tr",{className:M?"nice-treelist__row--selected":"",children:[g&&e.jsx("td",{className:"nice-treelist__checkbox",children:e.jsx("input",{type:"checkbox",checked:M,onChange:()=>ve(de)})}),$.map((w,c)=>e.jsxs("td",{style:{textAlign:w.align},children:[c===0&&e.jsx("span",{style:{display:"inline-block",width:le*20}}),c===0&&e.jsx("span",{className:"nice-treelist__toggle",onClick:()=>ke&&re(de),style:{cursor:ke?"pointer":"default",width:20,display:"inline-block"},children:ke?U?"▾":"▸":""}),w.render?w.render(X[w.field],X,0):String(X[w.field]??"")]},w.field))]}),ke&&U&&X.children.map(w=>z(w,le+1))]},de)};return L?null:e.jsx("div",{className:`nice-treelist ${V||""}`,style:R,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:S?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"}})})}):T.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:$.length+(g?1:0),className:"nice-treelist__empty",children:D||N("controls.noData","No data available")})}):T.map(X=>z(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:S,className:D,style:V,accessMode:R,id:ae}){const P=Re.Zs(R,ae)==="hidden",{t:L}=Re.$o(),[N,f]=t.useState(""),x=t.useMemo(()=>{if(!N)return n;const v=N.toLowerCase();return n.filter(T=>String(T[p]??"").toLowerCase().includes(v))},[n,N,p]);return P?null:e.jsxs("div",{className:`nice-cardview ${D||""}`,style:V,children:[o&&e.jsx("div",{className:"nice-cardview__search",children:e.jsx("input",{type:"text",value:N,onChange:v=>f(v.target.value),placeholder:_||L("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||L("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:()=>S?.(v),style:S?{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:S}){const{t:D}=Re.$o();return e.jsx("div",{className:`nice-tileview nice-tileview--${r} ${g||""}`,style:S,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||D("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(S=>S.field===l?{...S,area:g}:S))},_=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(S=>S.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(S=>e.jsxs("li",{className:"nice-field-chooser__item",children:[e.jsx("span",{children:S.caption}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--ghost nice-btn--sm",onClick:()=>_(S.field),children:"✕"})]},S.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:S,style:D,accessMode:V,id:R})=>{const q=Re.Zs(V,R)==="hidden",{t:P}=Re.$o(),[L,N]=t.useState(a),[f,x]=t.useState(!1),v=t.useMemo(()=>L.filter(U=>U.area==="row"),[L]),T=t.useMemo(()=>L.filter(U=>U.area==="column"),[L]),$=t.useMemo(()=>L.filter(U=>U.area==="data"),[L]),re=t.useMemo(()=>v.length===0?["Total"]:Jn(n,v[0].field),[n,v]),ve=t.useMemo(()=>T.length===0?["Total"]:Jn(n,T[0].field),[n,T]),z=t.useCallback((U,M,w)=>{let c=n;v.length>0&&(c=c.filter(se=>String(se[v[0].field])===U)),T.length>0&&(c=c.filter(se=>String(se[T[0].field])===M));const _e=c.map(se=>Number(se[w.field])||0),je=Ki(_e,w.summaryType||"sum");return w.format?w.format(je):je},[n,v,T]),X=t.useCallback(U=>{N(U),s?.(U)},[s]),le=t.useCallback((U,M)=>{let w=n;return v.length>0&&(w=w.filter(c=>String(c[v[0].field])===U)),T.length>0&&(w=w.filter(c=>String(c[T[0].field])===M)),w},[n,v,T]),de=t.useCallback((U,M)=>{g&&g(U,M,le(U,M))},[g,le]),ke=t.useCallback(()=>{const U=["",...ve.flatMap(se=>$.length>0?$.map(j=>`${se} - ${j.caption}`):[se])],M=re.map(se=>{const j=ve.flatMap(ne=>$.length>0?$.map(O=>String(z(se,ne,O))):["—"]);return[se,...j]}),w=[U,...M].map(se=>se.map(j=>`"${String(j).replace(/"/g,'""')}"`).join(",")).join(`
|
|
15
|
+
`),c=new Blob(["\uFEFF"+w],{type:"text/csv;charset=utf-8;"}),_e=URL.createObjectURL(c),je=document.createElement("a");je.href=_e,je.download=`${l}.csv`,je.click(),URL.revokeObjectURL(_e)},[ve,re,$,z,l]);return q?null:e.jsxs("div",{className:`nice-pivotgrid ${S||""}`,style:D,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:P("controls.fieldChooser","Field Chooser")}),_&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--sm",onClick:ke,children:"CSV ↓"})]}),f&&e.jsx(ri,{fields:L,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(U=>U.caption).join(" / ")||""}),ve.map(U=>e.jsx("th",{colSpan:$.length||1,children:U},U))]}),$.length>1&&e.jsxs("tr",{children:[e.jsx("th",{}),ve.map(U=>$.map(M=>e.jsx("th",{children:M.caption},`${U}-${M.field}`)))]})]}),e.jsx("tbody",{children:re.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:1+ve.length*Math.max($.length,1),className:"nice-pivotgrid__empty",children:p||P("controls.noData","No data available")})}):re.map(U=>e.jsxs("tr",{children:[e.jsx("td",{className:"nice-pivotgrid__row-header",children:U}),ve.map(M=>$.length>0?$.map(w=>e.jsx("td",{className:`nice-pivotgrid__cell ${g?"nice-pivotgrid__cell--clickable":""}`,onClick:g?()=>de(U,M):void 0,children:z(U,M,w)},`${M}-${w.field}`)):e.jsx("td",{className:"nice-pivotgrid__cell",children:"—"},M))]},U))})]})})]})},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 li=t.forwardRef(({columns:n,cards:a,onCardMove:s,onCardClick:r,renderCard:o,onAddCard:p,disabled:_=!1,size:l="md",collapsible:g=!1,layoutMode:S="scroll",viewMode:D,onViewModeChange:V,collapsedColumns:R,onCollapsedColumnsChange:ae,formItems:q,formColumns:P=1,formProps:L,editCardTitle:N,newCardTitle:f,onCardEdit:x,onCardCreate:v,onCardDelete:T,cookies:$=!1,localStorage:re=!0,sessionStorage:ve=!1,storageMode:z,storageKey:X,className:le,style:de,id:ke,...U},M)=>{const{t:w}=Re.$o(),[c,_e]=t.useState(null),[je,se]=t.useState(null),[j,ne]=t.useState(null),O=!!q&&(!!x||!!v),me=t.useCallback(F=>{if(O&&x){ne({key:F.key,data:{...F},column:F.column});return}r?.(F)},[O,r,x]),J=t.useCallback(F=>{if(O&&v){ne({key:null,data:{title:"",description:""},column:F});return}p?.(F)},[O,p,v]),Ae=Re.useStorageAdapter(X??"nice-kanban"),[Xe,at]=t.useState(()=>Ae.get("state")??{collapsedColumns:[],viewMode:"default"}),Ee=R??Xe.collapsedColumns??[],We=D??Xe.viewMode??"default",Ve=t.useCallback(F=>{at(G=>{const be={...G,...F};return Ae.set("state",be),be})},[Ae]),Be=t.useCallback(F=>{const G=Ee.includes(F)?Ee.filter(be=>be!==F):[...Ee,F];ae?ae(G):Ve({collapsedColumns:G})},[Ee,ae,Ve]);t.useCallback(F=>{V?V(F):Ve({viewMode:F})},[V,Ve]);const Z=t.useCallback(F=>a.filter(G=>G.column===F).sort((G,be)=>(G.order??0)-(be.order??0)),[a]),Se=t.useCallback((F,G)=>{_||(F.dataTransfer.effectAllowed="move",F.dataTransfer.setData("text/plain",String(G.key)),_e({cardKey:G.key,fromColumn:G.column}))},[_]),He=t.useCallback((F,G)=>{F.preventDefault(),F.dataTransfer.dropEffect="move",se({column:G})},[]),Ne=t.useCallback(()=>{se(null)},[]),k=t.useCallback((F,G)=>{if(F.preventDefault(),se(null),!c||_)return;const be=Z(G);s?.(c.cardKey,G,be.length),_e(null)},[c,_,Z,s]),Q=t.useCallback(()=>{_e(null),se(null)},[]);return e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:M,id:ke,className:`nice-kanban nice-kanban--${l} nice-kanban--${We} nice-kanban--layout-${S} ${_?"nice-kanban--disabled":""} ${le||""}`,style:de,...U,children:n.map(F=>{const G=Z(F.key),be=je?.column===F.key,H=F.limit!=null&&G.length>=F.limit,Ce=g&&Ee.includes(F.key);return e.jsxs("div",{className:`nice-kanban__column ${be?"nice-kanban__column--dragover":""} ${Ce?"nice-kanban__column--collapsed":""}`,onDragOver:Me=>!Ce&&He(Me,F.key),onDragLeave:Ne,onDrop:Me=>!Ce&&k(Me,F.key),children:[e.jsxs("div",{className:"nice-kanban__column-header",style:F.color?{borderTopColor:F.color}:void 0,onClick:g?()=>Be(F.key):void 0,role:g?"button":void 0,tabIndex:g?0:void 0,onKeyDown:g?Me=>{(Me.key==="Enter"||Me.key===" ")&&Be(F.key)}:void 0,children:[g&&e.jsx("span",{className:"nice-kanban__collapse-icon","aria-hidden":"true",children:e.jsx(qi,{open:!Ce})}),e.jsx("span",{className:"nice-kanban__column-title",children:F.title}),e.jsxs("span",{className:"nice-kanban__column-count",children:[G.length,F.limit!=null&&` / ${F.limit}`]})]}),!Ce&&e.jsxs("div",{className:"nice-kanban__column-body",children:[G.map(Me=>e.jsx("div",{className:`nice-kanban__card nice-kanban__card--${We} ${c?.cardKey===Me.key?"nice-kanban__card--dragging":""}`,draggable:!_,onDragStart:ue=>Se(ue,Me),onDragEnd:Q,onClick:()=>me(Me),role:"article",children:o?o(Me):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"nice-kanban__card-title",children:Me.title}),We!=="compact"&&Me.description&&e.jsx("div",{className:"nice-kanban__card-desc",children:Me.description})]})},Me.key)),G.length===0&&e.jsx("div",{className:"nice-kanban__empty",children:w("kanban.empty","No cards")})]}),!Ce&&(p||O&&v)&&!H&&e.jsxs("button",{type:"button",className:"nice-kanban__add",onClick:()=>J(F.key),disabled:_,children:[e.jsx(Xi,{})," ",w("kanban.addCard","Add card")]})]},F.key)})}),O&&j&&e.jsxs(ii.NiceModal,{open:!0,onClose:()=>ne(null),title:j.key==null?f||w("kanban.newCard","New card"):N||w("kanban.editCard","Edit card"),children:[e.jsx(ni.NiceForm,{items:q,data:j.data,columns:P,...L,onFieldChange:(F,G)=>ne(be=>be&&{...be,data:{...be.data,[F]:G}})}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:16,flexWrap:"wrap"},children:[j.key!=null&&T&&e.jsx(ze.NiceButton,{type:"button",size:"sm",variant:"error",style:{marginRight:"auto"},onClick:()=>{T(j.key),ne(null)},children:w("controls.delete","Delete")}),e.jsx(ze.NiceButton,{type:"button",size:"sm",variant:"secondary",onClick:()=>ne(null),children:w("controls.cancel","Cancel")}),e.jsx(ze.NiceButton,{type:"button",size:"sm",variant:"primary",onClick:()=>{if(j.key==null){const F={key:`card-${Date.now()}`,title:"",column:j.column,...j.data};v?.(F)}else x?.(j.key,{...j.data,key:j.key,column:j.column});ne(null)},children:w("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 Hi=50,Qi=[10,25,50,100,200],Yi=40,Ji=10,ea=768,ta=500,na=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 ia(n,a,s,r){const[o,p]=t.useState(0),{startIndex:_,endIndex:l,totalHeight:g,offsetY:S}=t.useMemo(()=>{const R=n.length*s,ae=Math.ceil(a/s),q=Math.max(0,Math.floor(o/s)-r),P=Math.min(n.length,Math.ceil(o/s)+ae+r),L=q*s;return{startIndex:q,endIndex:P,totalHeight:R,offsetY:L}},[n.length,a,s,o,r]),D=t.useMemo(()=>n.slice(_,l),[n,_,l]),V=t.useCallback(R=>{p(R.currentTarget.scrollTop)},[]);return{visibleData:D,totalHeight:g,offsetY:S,handleScroll:V,startIndex:_}}function aa(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 sa(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 ra({column:n,sort:a,onSort:s,onResize:r,resizable:o,t:p}){const _=t.useRef(null),[l,g]=t.useState(!1),S=t.useCallback(R=>{if(!o||!r)return;R.preventDefault(),g(!0);const ae=R.clientX,q=n.width||150,P=N=>{const f=N.clientX-ae,x=Math.max(n.minWidth||50,q+f);r(n.field,Math.min(x,n.maxWidth||1/0))},L=()=>{g(!1),document.removeEventListener("mousemove",P),document.removeEventListener("mouseup",L)};document.addEventListener("mousemove",P),document.addEventListener("mouseup",L)},[n,o,r]),D=a?.direction,V=D==="asc"?"↑":D==="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":D==="asc"?"ascending":D==="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:S})]})}function ca({column:n,row:a,rowIndex:s,value:r,locale:o="pl-PL",onClick:p}){const _=Re.yc({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(S=>S.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,S=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":`${S} out of ${g} stars`,children:Array.from({length:g},(D,V)=>e.jsx("span",{className:zt("nice-module-grid__star",V<S&&"nice-module-grid__star--filled"),children:"★"},V))})})}if(n.type==="link"&&n.linkTemplate){const g=n.linkTemplate.replace(/\{\{(\w+)\}\}/g,(S,D)=>String(Nt(a,D)??""));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 S={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:S,height:S}}):e.jsx("div",{className:"nice-module-grid__image-placeholder",style:{width:S,height:S}})})}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 la({row:n,index:a,columns:s,primaryField:r,secondaryField:o,customRender:p,selected:_,onClick:l,locale:g="pl-PL",t:S}){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 D=s.find(R=>R.field===r)||s[0],V=s.find(R=>R.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,D?.field||""),D,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(R=>!R.hidden&&R.field!==r&&R.field!==o).slice(0,4).map(R=>e.jsxs("div",{className:"nice-module-grid__mobile-card-field",children:[e.jsx("span",{className:"nice-module-grid__mobile-card-label",children:R.header}),e.jsx("span",{className:"nice-module-grid__mobile-card-value",children:hn(Nt(n,R.field),R,g)})]},R.field))})]})}function oa({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:S=>o(1,Number(S.target.value)),"aria-label":p("pagination.rowsPerPage","Rows per page"),children:r.map(S=>e.jsx("option",{value:S,children:S},S))}),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 da({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 ua(n,a){const{columns:s,data:r,keyField:o="id",dataSource:p,onFetch:_,sortable:l=!0,sort:g,onSortChange:S,multiSort:D=!1,filterable:V=!1,filter:R,onFilterChange:ae,searchText:q,onSearchChange:P,searchPlaceholder:L="moduleGrid.searchPlaceholder",pagination:N=!0,page:f,pageSize:x,pageSizeOptions:v=Qi,totalRows:T,onPageChange:$,virtualScroll:re=!0,rowHeight:ve=Yi,overscan:z=Ji,selectionMode:X="none",selectedKeys:le,onSelectionChange:de,columnReorder:ke=!0,onColumnOrderChange:U,columnResize:M=!0,onColumnWidthChange:w,groupBy:c,onGroupByChange:_e,groupRowRender:je,expandAllGroups:se=!1,editable:j=!1,onCellEdit:ne,onRowEdit:O,editMode:me="cell",contextMenuItems:J,onContextMenuAction:Ae,exportable:Xe=!0,exportFormats:at=["csv","excel"],onExport:Ee,preferencesKey:We,initialPreferences:Ve,onPreferencesChange:Be,density:Z="normal",striped:Se=!0,bordered:He=!1,hoverable:Ne=!0,loading:k=!1,emptyState:Q,toolbar:F,onRowClick:G,onRowDoubleClick:be,rowClassName:H,rowStyle:Ce,mobileCardView:Me=!0,mobileBreakpoint:ue=ea,mobileCardRender:Te,mobilePrimaryField:st,mobileSecondaryField:ut,moduleId:we,permissions:Tt,size:ht="medium",skeletonLoading:St=!0,skeletonRows:wt=na,"aria-label":I,"aria-labelledby":Y,"aria-describedby":pe,className:nt,style:ft,id:De,testId:Ke}=n,{t:Ge}=Re.$o();Re.Zs(),Re.vs("table");const mt=sa(ue),[rt,kt]=aa(We,Ve),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||Hi),[h,A]=t.useState(new Set),[K,ee]=t.useState([]),[E,B]=t.useState(0),[ie,oe]=t.useState(!1),[$e,Oe]=t.useState(new Set),[xe,Ye]=t.useState(null),[Ct,Mt]=t.useState({}),Je=g??Xt,_t=R??pt,Dt=q??nn,Ut=f??Qe,Pt=x??Kt,It=le??h,an=T??E??r?.length??0,Ft=!!(_||p),Rt=t.useMemo(()=>{const y=new Set(rt.hiddenColumns||[]);return s.filter(he=>!he.hidden&&!y.has(he.field))},[s,rt.hiddenColumns]),$t=t.useMemo(()=>{if(Ft)return K;if(!r)return[];let y=[...r];if(Dt){const he=Dt.toLowerCase(),ge=s.filter(fe=>fe.searchable!==!1).map(fe=>fe.field);y=y.filter(fe=>ge.some(lt=>{const Le=Nt(fe,lt);return String(Le??"").toLowerCase().includes(he)}))}return Je.length>0&&y.sort((he,ge)=>{for(const fe of Je){const lt=Nt(he,fe.field),Le=Nt(ge,fe.field),qe=lt<Le?-1:lt>Le?1:0;if(qe!==0)return fe.direction==="asc"?qe:-qe}return 0}),y},[Ft,K,r,Dt,Je,s]),ot=t.useMemo(()=>{if(Ft||!N)return $t;const y=(Ut-1)*Pt;return $t.slice(y,y+Pt)},[Ft,$t,N,Ut,Pt]),pn=Vt.current?.clientHeight||400,At=re&&ot.length>ta,{visibleData:Wt,totalHeight:Bt,offsetY:sn,handleScroll:Sn,startIndex:rn}=ia(ot,pn,ve,z),Ot=At?Wt:ot,gn=t.useCallback(async()=>{if(_){oe(!0);try{const he=await _({page:Ut,pageSize:Pt,sort:Je,filter:_t,search:Dt});ee(he.data),B(he.total)}catch(y){console.error("NiceModuleGrid fetch error:",y)}finally{oe(!1)}}},[_,Ut,Pt,Je,_t,Dt]);t.useEffect(()=>{Ft&&gn()},[Ft,gn]);const Cn=t.useCallback(y=>{const he=Je.find(fe=>fe.field===y);let ge;he?he.direction==="asc"?ge=Je.map(fe=>fe.field===y?{...fe,direction:"desc"}:fe):ge=Je.filter(fe=>fe.field!==y):ge=D?[...Je,{field:y,direction:"asc"}]:[{field:y,direction:"asc"}],S?S(ge):Ht(ge)},[Je,D,S]),Mn=t.useCallback((y,he)=>{$?$(y,he):(Fe(y),d(he))},[$]),zn=t.useCallback(y=>{P?P(y):Pe(y),$||Fe(1)},[P,$]),fn=t.useCallback((y,he)=>{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)),de){const fe=ot.filter(lt=>ge.has(String(Nt(lt,o))));de(ge,fe)}else A(ge)},[It,X,de,ot,o]),Dn=t.useCallback((y,he)=>{Mt(ge=>({...ge,[y]:he})),w?.(y,he),kt({columnWidths:{...rt.columnWidths,[y]:he}})},[w,kt,rt.columnWidths]),xn=t.useCallback((y,he)=>{J?.length&&(y.preventDefault(),Ye({x:y.clientX,y:y.clientY,row:he}))},[J]),Tn=t.useCallback(y=>{xe&&Ae?.(y,xe.row),Ye(null)},[xe,Ae]),Pn=t.useCallback(async y=>{if(Ee)await Ee(y,{selectedOnly:It.size>0,columns:Rt.map(he=>he.field)});else if(y==="csv"){const he=Rt.map(dt=>dt.header).join(","),ge=ot.map(dt=>Rt.map(ln=>JSON.stringify(Nt(dt,ln.field)??"")).join(",")),fe=[he,...ge].join(`
|
|
16
|
+
`),lt=new Blob([fe],{type:"text/csv;charset=utf-8;"}),Le=URL.createObjectURL(lt),qe=document.createElement("a");qe.href=Le,qe.download=`export-${new Date().toISOString().slice(0,10)}.csv`,qe.click(),URL.revokeObjectURL(Le)}},[Ee,It,Rt,ot,Ge]);t.useEffect(()=>{if(!xe)return;const y=()=>Ye(null);return document.addEventListener("click",y),()=>document.removeEventListener("click",y)},[xe]);const cn=t.useCallback(y=>{y.key==="Escape"&&Ye(null)},[]),ct=k||ie,gt=!ct&&Ot.length===0,bt=mt&&Me,In=zt("nice-module-grid",`nice-module-grid--${Z}`,`nice-module-grid--${ht}`,Se&&"nice-module-grid--striped",He&&"nice-module-grid--bordered",Ne&&"nice-module-grid--hoverable",ct&&"nice-module-grid--loading",bt&&"nice-module-grid--mobile",nt);return e.jsxs("div",{ref:a,id:De,"data-testid":Ke,className:In,style:ft,onKeyDown:cn,role:"grid","aria-label":I,"aria-labelledby":Y,"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:L,value:Dt,onChange:y=>zn(y.target.value),"aria-label":Ge("moduleGrid.searchAriaLabel","Search")})}),F,Xe&&e.jsx("div",{className:"nice-module-grid__toolbar-export",children:at.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,he)=>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}})]},he)):gt?e.jsxs("div",{className:"nice-module-grid__empty",children:[Q?.icon&&e.jsx("div",{className:"nice-module-grid__empty-icon",children:Q.icon}),e.jsx("div",{className:"nice-module-grid__empty-title",children:Q?.title||Ge("moduleGrid.noData","No data")}),Q?.description&&e.jsx("div",{className:"nice-module-grid__empty-description",children:Q.description}),Q?.action&&e.jsxs("button",{className:"nice-module-grid__empty-action",onClick:Q.action.onClick,children:[Q.action.icon,Q.action.label]})]}):Ot.map((y,he)=>{const ge=String(Nt(y,o));return e.jsx(la,{row:y,index:rn+he,columns:Rt,primaryField:st,secondaryField:ut,customRender:Te,selected:It.has(ge),onClick:()=>{X!=="none"&&fn(ge,y),G?.(y,rn+he)},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)de?.(new Set,[]),A(new Set);else{const y=new Set(Ot.map(he=>String(Nt(he,o))));de?.(y,Ot),A(y)}},"aria-label":Ge("moduleGrid.selectAll","Select all")})}),Rt.map(y=>e.jsx(ra,{column:{...y,width:Ct[y.field]||y.width},sort:Je.find(he=>he.field===y.field),onSort:l?Cn:void 0,onResize:M?Dn:void 0,resizable:M,t:Ge},y.field))]}),e.jsx("div",{className:"nice-module-grid__body",style:At?{height:Bt,position:"relative"}:void 0,children:ct&&St?Array.from({length:wt},(y,he)=>e.jsx(da,{columns:Rt},he)):gt?e.jsxs("div",{className:"nice-module-grid__empty",children:[Q?.icon&&e.jsx("div",{className:"nice-module-grid__empty-icon",children:Q.icon}),e.jsx("div",{className:"nice-module-grid__empty-title",children:Q?.title||Ge("moduleGrid.noData","No data")}),Q?.description&&e.jsx("div",{className:"nice-module-grid__empty-description",children:Q.description}),Q?.action&&e.jsxs("button",{className:"nice-module-grid__empty-action",onClick:Q.action.onClick,children:[Q.action.icon,Q.action.label]})]}):e.jsx("div",{style:At?{transform:`translateY(${sn}px)`}:void 0,children:Ot.map((y,he)=>{const ge=String(Nt(y,o)),fe=rn+he,lt=It.has(ge),Le=typeof H=="function"?H(y,fe):H,qe=typeof Ce=="function"?Ce(y,fe):Ce;return e.jsxs("div",{className:zt("nice-module-grid__row",lt&&"nice-module-grid__row--selected",Le),style:{...qe,height:ve},role:"row","aria-rowindex":fe+1,"aria-selected":lt,onClick:()=>{X!=="none"&&fn(ge,y),G?.(y,fe)},onDoubleClick:()=>be?.(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(ca,{column:{...dt,width:Ct[dt.field]||dt.width},row:y,rowIndex:fe,value:Nt(y,dt.field)},dt.field))]},ge)})})})]})}),N&&an>0&&e.jsx(oa,{page:Ut,pageSize:Pt,totalRows:Ft?E:$t.length,pageSizeOptions:v,onPageChange:Mn,t:Ge}),xe&&J&&e.jsx("div",{className:"nice-module-grid__context-menu",style:{left:xe.x,top:xe.y},role:"menu",children:J.filter(y=>typeof y.hidden=="function"?!y.hidden(xe.row):!y.hidden).map(y=>{if(y.divider)return e.jsx("div",{className:"nice-module-grid__context-menu-divider"},y.key);const he=typeof y.disabled=="function"?y.disabled(xe.row):y.disabled;return e.jsxs("button",{className:zt("nice-module-grid__context-menu-item",y.danger&&"nice-module-grid__context-menu-item--danger",he&&"nice-module-grid__context-menu-item--disabled"),onClick:()=>{he||(y.onClick?.(xe.row),Tn(y.key))},disabled:he,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 ha=t.forwardRef(ua),ma=`
|
|
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 pa(n){return n>=80?"high":n>=50?"medium":"low"}function ga(){return`match-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function fa({item:n,isSelected:a,isDragging:s,isDropTarget:r,suggestion:o,currency:p,locale:_,onSelect:l,onDoubleClick:g,onDragStart:S,onDragEnd:D,onDrop:V,disabled:R}){const ae=n.status??"unmatched",q=o?.confidence??n.confidence,P=N=>{N.dataTransfer.setData("text/plain",n.id),N.dataTransfer.setData("source","statement"),N.dataTransfer.effectAllowed="move",S()},L=N=>{N.dataTransfer.types.includes("source")&&N.dataTransfer.getData("source")!=="statement"&&N.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:!R&&ae!=="matched",onDragStart:P,onDragEnd:D,onDragOver:L,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--${pa(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 xa({item:n,isSelected:a,isDragging:s,isDropTarget:r,currency:o,locale:p,onSelect:_,onDoubleClick:l,onDragStart:g,onDragEnd:S,onDrop:D,disabled:V}){const R=n.status??"unmatched",ae=P=>{P.dataTransfer.setData("text/plain",n.id),P.dataTransfer.setData("source","entry"),P.dataTransfer.effectAllowed="move",g()},q=P=>{P.dataTransfer.types.includes("source")&&P.dataTransfer.getData("source")!=="entry"&&P.preventDefault()};return e.jsxs("div",{className:`nice-reconciliation__row nice-reconciliation__row--${R} ${a?"nice-reconciliation__row--selected":""} ${s?"nice-reconciliation__row--dragging":""} ${r?"nice-reconciliation__row--drop-target":""}`,draggable:!V&&R!=="matched",onDragStart:ae,onDragEnd:S,onDragOver:q,onDrop:D,onClick:_,onDoubleClick:l,role:"row","aria-selected":a,tabIndex:0,children:[e.jsx("span",{className:`nice-reconciliation__status nice-reconciliation__status--${R}`}),e.jsxs("div",{className:"nice-reconciliation__row-main",children:[e.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 _a=t.forwardRef(function(a,s){const{statements:r,bankTransactions:o,entries:p,accountingEntries:_,matches:l,defaultMatches:g=[],suggestions:S=[],config:D={},currency:V,showConfidence:R,statementPanelConfig:ae,entryPanelConfig:q,onMatch:P,onAutoMatch:L,onUnmatch:N,onBatchAction:f,onFilterChange:x,onRequestSuggestions:v,onSelectionChange:T,onComplete:$,size:re="medium",showToolbar:ve=!0,showFilters:z=!0,showSummary:X=!0,showSuggestions:le=!0,layout:de="horizontal",enableDragDrop:ke=!0,enableKeyboard:U=!0,enableDetailPanel:M=!0,loading:w=!1,disabled:c=!1,readOnly:_e=!1,locale:je="pl-PL",labels:se={},className:j,style:ne}=a,O=r??o??[],me=p??_??[],J=V??D.currency??"PLN",[Ae,Xe]=t.useState(g),[at,Ee]=t.useState(new Set),[We,Ve]=t.useState(new Set),[Be,Z]=t.useState(null),[Se,He]=t.useState(null),[Ne,k]=t.useState({}),[Q,F]=t.useState(null),G=l??Ae,be=t.useRef(null),H=t.useRef(null);t.useEffect(()=>{const I="nice-reconciliation-styles";if(!document.getElementById(I)){const Y=document.createElement("style");Y.id=I,Y.textContent=ma,document.head.appendChild(Y)}},[]);const Ce=t.useMemo(()=>{const I=new Set;return G.forEach(Y=>Y.statementIds.forEach(pe=>I.add(pe))),I},[G]),Me=t.useMemo(()=>{const I=new Set;return G.forEach(Y=>Y.entryIds.forEach(pe=>I.add(pe))),I},[G]),ue=t.useMemo(()=>{const I=O.filter(De=>!Ce.has(De.id)),Y=me.filter(De=>!Me.has(De.id)),pe=O.reduce((De,Ke)=>De+Ke.amount,0),nt=me.reduce((De,Ke)=>De+Ke.amount,0),ft=O.filter(De=>Ce.has(De.id)).reduce((De,Ke)=>De+Ke.amount,0);return{totalStatements:O.length,totalEntries:me.length,matchedStatements:O.length-I.length,matchedEntries:me.length-Y.length,unmatchedStatements:I.length,unmatchedEntries:Y.length,statementTotal:pe,entryTotal:nt,matchedAmount:ft,unmatchedStatementAmount:I.reduce((De,Ke)=>De+Ke.amount,0),unmatchedEntryAmount:Y.reduce((De,Ke)=>De+Ke.amount,0),difference:pe-nt,matchPercentage:O.length>0?Math.round((O.length-I.length)/O.length*100):0,matchCount:G.length,partialMatchCount:G.filter(De=>De.status==="partial").length,pendingSuggestions:S.length}},[O,me,G,S,Ce,Me]),Te=t.useCallback((I,Y)=>{const pe=O.filter(rt=>I.includes(rt.id)),nt=me.filter(rt=>Y.includes(rt.id));if(pe.length===0||nt.length===0)return null;const ft=pe.reduce((rt,kt)=>rt+kt.amount,0),De=nt.reduce((rt,kt)=>rt+kt.amount,0),Ke=Math.abs(ft-De),Ge=D.amountTolerance??.01,mt={id:ga(),statementIds:I,entryIds:Y,status:Ke<=Ge?"matched":"partial",statementTotal:ft,entryTotal:De,difference:Ke,confidence:Ke<=Ge?100:Math.max(0,100-Ke/Math.max(Math.abs(ft),1)*100),matchedBy:"user",matchedAt:new Date};return l||Xe(rt=>[...rt,mt]),P?.(mt,pe,nt),Ee(new Set),Ve(new Set),mt},[O,me,D.amountTolerance,l,P]),st=t.useCallback(I=>{const Y=G.find(pe=>pe.id===I);Y&&(l||Xe(pe=>pe.filter(nt=>nt.id!==I)),N?.(I,Y.statementIds,Y.entryIds))},[G,l,N]),ut=t.useCallback(async()=>{const I=[],Y=new Set(Ce),pe=new Set(Me),nt=D.amountTolerance??.01,ft=D.dateTolerance??3;for(const De of O){if(Y.has(De.id))continue;const Ke=me.filter(Ge=>{if(pe.has(Ge.id)||Math.abs(De.amount-Ge.amount)>nt)return!1;const rt=new Date(De.date),kt=new Date(Ge.date);return!(Math.abs(rt.getTime()-kt.getTime())/(1e3*60*60*24)>ft)});if(Ke.length===1){const Ge=Ke[0],mt=Te([De.id],[Ge.id]);mt&&(I.push(mt),Y.add(De.id),pe.add(Ge.id))}}return f?.("autoMatch",I),I},[O,me,Ce,Me,D,Te,f]),we=t.useCallback((I,Y,pe,nt)=>{nt!==Y&&(nt==="statement"?Te([pe],[I]):Te([I],[pe]),Z(null),He(null))},[Te]),Tt=t.useCallback(()=>{const I=Array.from(at),Y=Array.from(We);I.length>0&&Y.length>0&&Te(I,Y)},[at,We,Te]);t.useEffect(()=>{T?.(Array.from(at),Array.from(We))},[at,We,T]),t.useImperativeHandle(s,()=>({getMatches:()=>G,getUnmatchedStatements:()=>O.filter(I=>!Ce.has(I.id)),getUnmatchedEntries:()=>me.filter(I=>!Me.has(I.id)),createMatch:Te,removeMatch:st,autoMatch:ut,getSuggestions:async I=>v?v(I??O.filter(Y=>!Ce.has(Y.id)).map(Y=>Y.id)):[],applySuggestion:I=>Te([I.statementId],I.entryIds),approveAll:()=>{f?.("approveAll",G)},clearAll:()=>{l||Xe([]),f?.("clearAll",[])},exportMatched:I=>{f?.("exportMatched",G)},getSummary:()=>ue,reset:()=>{l||Xe([]),Ee(new Set),Ve(new Set),k({})},focusStatements:()=>be.current?.focus(),focusEntries:()=>H.current?.focus()}),[G,O,me,Ce,Me,Te,st,ut,v,f,l,ue]);const ht=t.useMemo(()=>O.filter(I=>{if(Ne.status&&Ne.status.length>0){const Y=Ce.has(I.id)?"matched":"unmatched";if(!Ne.status.includes(Y))return!1}if(Ne.searchText){const Y=Ne.searchText.toLowerCase();if(!I.description?.toLowerCase().includes(Y)&&!I.counterparty?.toLowerCase().includes(Y))return!1}return!0}),[O,Ne,Ce]),St=t.useMemo(()=>me.filter(I=>{if(Ne.status&&Ne.status.length>0){const Y=Me.has(I.id)?"matched":"unmatched";if(!Ne.status.includes(Y))return!1}if(Ne.searchText){const Y=Ne.searchText.toLowerCase();if(!I.description?.toLowerCase().includes(Y)&&!I.partyName?.toLowerCase().includes(Y))return!1}return!0}),[me,Ne,Me]),wt=at.size>0&&We.size>0&&!_e&&!c;return e.jsxs("div",{className:`nice-reconciliation nice-reconciliation--${de} ${j??""}`,style:ne,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||_e||w,children:["⚡ ",se.autoMatch??"Auto-match"]}),e.jsx("button",{type:"button",className:"nice-reconciliation__btn nice-reconciliation__btn--success",onClick:Tt,disabled:!wt||w,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",G),disabled:G.length===0||c||w,children:["✓ ",se.approveAll??"Approve All"]}),e.jsxs("button",{type:"button",className:"nice-reconciliation__btn",onClick:()=>{l||Xe([]),f?.("clearAll",[])},disabled:G.length===0||c||_e||w,children:["✕ ",se.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:["📄 ",se.statementPanelTitle??"Bank Statement",e.jsx("span",{className:"nice-reconciliation__panel-badge",children:ht.length})]})}),e.jsx("div",{ref:be,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:"📋"}),se.noStatements??"No statement items"]}):ht.map(I=>e.jsx(fa,{item:{...I,status:Ce.has(I.id)?"matched":"unmatched"},isSelected:at.has(I.id),isDragging:Be===I.id,isDropTarget:Se===I.id,suggestion:S.find(Y=>Y.statementId===I.id),currency:J,locale:je,onSelect:()=>{c||Ee(Y=>{const pe=new Set(Y);return pe.has(I.id)?pe.delete(I.id):pe.add(I.id),pe})},onDoubleClick:()=>M&&F({type:"statement",id:I.id}),onDragStart:()=>Z(I.id),onDragEnd:()=>{Z(null),He(null)},onDrop:()=>{Be&&Be!==I.id&&we(I.id,"statement",Be,"entry")},disabled:c||_e||!ke},I.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:["📒 ",se.entryPanelTitle??"Book Entries",e.jsx("span",{className:"nice-reconciliation__panel-badge",children:St.length})]})}),e.jsx("div",{ref:H,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:"📚"}),se.noEntries??"No book entries"]}):St.map(I=>e.jsx(xa,{item:{...I,status:Me.has(I.id)?"matched":"unmatched"},isSelected:We.has(I.id),isDragging:Be===I.id,isDropTarget:Se===I.id,currency:J,locale:je,onSelect:()=>{c||Ve(Y=>{const pe=new Set(Y);return pe.has(I.id)?pe.delete(I.id):pe.add(I.id),pe})},onDoubleClick:()=>M&&F({type:"entry",id:I.id}),onDragStart:()=>Z(I.id),onDragEnd:()=>{Z(null),He(null)},onDrop:()=>{Be&&Be!==I.id&&we(I.id,"entry",Be,"statement")},disabled:c||_e||!ke},I.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:[ue.matchedStatements,"/",ue.totalStatements," (",ue.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(ue.matchedAmount,J,je)})]}),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(ue.unmatchedStatementAmount,J,je)})]}),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(ue.difference)<.01?"nice-reconciliation__summary-value--success":"nice-reconciliation__summary-value--danger"}`,children:Lt(ue.difference,J,je)})]})]}),M&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`nice-reconciliation__detail-backdrop ${Q?"nice-reconciliation__detail-backdrop--visible":""}`,onClick:()=>F(null)}),e.jsx("div",{className:`nice-reconciliation__detail-panel ${Q?"nice-reconciliation__detail-panel--open":""}`,children:Q&&e.jsx(ba,{type:Q.type,id:Q.id,statements:O,entries:me,matches:G,currency:J,locale:je,labels:se,onClose:()=>F(null)})})]})]})});function ba({type:n,id:a,statements:s,entries:r,matches:o,currency:p,locale:_,labels:l,onClose:g}){const S=n==="statement"?s.find(P=>P.id===a):r.find(P=>P.id===a),D=n==="statement"?o.find(P=>P.statementIds.includes(a)):o.find(P=>P.entryIds.includes(a)),V=D?n==="statement"?r.filter(P=>D.entryIds.includes(P.id)):s.filter(P=>D.statementIds.includes(P.id)):[];if(!S)return null;const R=n==="statement",ae=R?S:null,q=R?null:S;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-reconciliation__detail-header",children:[e.jsxs("span",{className:"nice-reconciliation__detail-title",children:[R?"📄":"📒"," ",R?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:[D&&e.jsxs("div",{className:"nice-reconciliation__detail-match-info",children:[e.jsxs("div",{className:"nice-reconciliation__detail-match-header",children:["✓ ",l.matchedWith??"Matched"," (",D.confidence?.toFixed(0)??100,"% confidence)"]}),e.jsx("div",{className:"nice-reconciliation__detail-match-detail",children:D.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 ${D.statementTotal>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:Lt(D.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 ${D.entryTotal>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:Lt(D.entryTotal,p,_)})]})]}),D.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(D.difference,p,_)})]})]}),e.jsxs("div",{className:"nice-reconciliation__detail-section",children:[e.jsxs("div",{className:"nice-reconciliation__detail-section-title",children:["📋"," ",R?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(S.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:S.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 ${S.amount>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:Lt(S.amount,p,_)})]}),R&&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})]}),R&&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})]}),!R&&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})]}),!R&&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})]}),R&&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:["🔗"," ",R?l.matchedEntries??"Matched Entries":l.matchedStatements??"Matched Statements"]}),V.map(P=>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:P.description}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",color:"var(--nice-text-secondary)"},children:[e.jsx("span",{children:wn(P.date,_)}),e.jsx("span",{style:{fontWeight:600,color:P.amount>=0?"var(--nice-success)":"var(--nice-danger)"},children:Lt(P.amount,p,_)})]})]},P.id))]})]})]})}function ya(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 S=r.get(String(l));g.depth=S.depth+1,S.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 va(n){const a=[],s=r=>{r.forEach(o=>{a.push(o.key),s(o.children)})};return s(n),a}function ja(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 Na({columns:n,data:a,keyField:s="id",parentKeyField:r="parentId",nested:o=!1,childrenField:p="children",expandedKeys:_,onExpandedChange:l,defaultExpandAll:g=!1,sortable:S=!0,sortField:D,sortDirection:V,onSort:R,selectable:ae,selectedKeys:q,onSelectionChange:P,searchable:L,searchPlaceholder:N,striped:f,compact:x,loading:v,emptyText:T,toolbar:$,onRowClick:re,className:ve,style:z}){const{t:X}=Re.$o(),le=t.useMemo(()=>o?oi(a,p,s):ya(a,s,r),[a,s,r,o,p]),de=t.useMemo(()=>va(le),[le]),[ke,U]=t.useState(()=>g?new Set(de):new Set),M=_?new Set(_):ke,[w,c]=t.useState({field:"",dir:null}),[_e,je]=t.useState(new Set),[se,j]=t.useState(""),ne=D??w.field,O=V??w.dir,me=q??_e,J=t.useMemo(()=>n.filter(Z=>!Z.hidden),[n]),Ae=t.useCallback(Z=>{const Se=ne===Z?O==="asc"?"desc":O==="desc"?null:"asc":"asc";R?R(Z,Se):c({field:Z,dir:Se})},[ne,O,R]),Xe=t.useCallback(Z=>{const Se=new Set(M);Se.has(Z)?Se.delete(Z):Se.add(Z),l?l([...Se]):U(Se)},[M,l]),at=t.useCallback(Z=>{const Se=new Set(me);Se.has(Z)?Se.delete(Z):Se.add(Z),P?P(Se):je(Se)},[me,P]),Ee=t.useMemo(()=>{if(!se)return le;const Z=se.toLowerCase(),Se=He=>He.reduce((Ne,k)=>{const Q=Se(k.children);return(J.some(G=>String(k.data[G.field]??"").toLowerCase().includes(Z))||Q.length>0)&&Ne.push({...k,children:Q}),Ne},[]);return Se(le)},[le,se,J]),We=t.useMemo(()=>di(Ee,ne,O),[Ee,ne,O]),Ve=t.useMemo(()=>ja(We,M),[We,M]),Be=({field:Z})=>ne!==Z||!O?e.jsx("span",{className:"nice-table__sort-icon",style:{opacity:.3},children:"↕"}):e.jsx("span",{className:"nice-table__sort-icon",children:O==="asc"?"↑":"↓"});return e.jsxs("div",{className:`nice-treegrid nice-datagrid ${ve||""}`,style:z,children:[(L||$)&&e.jsxs("div",{className:"nice-datagrid__toolbar",children:[L&&e.jsx("div",{className:"nice-datagrid__search",children:e.jsx("input",{type:"text",value:se,onChange:Z=>j(Z.target.value),placeholder:N||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}}),J.map(Z=>e.jsxs("th",{style:{width:Z.width,minWidth:Z.minWidth,textAlign:Z.align},className:S&&Z.sortable!==!1?"nice-datagrid__th--sortable":void 0,onClick:()=>S&&Z.sortable!==!1&&Ae(Z.field),children:[Z.header,S&&Z.sortable!==!1&&e.jsx(Be,{field:Z.field})]},Z.field))]})}),e.jsx("tbody",{children:v?e.jsx("tr",{children:e.jsx("td",{colSpan:J.length+(ae?1:0),className:"nice-datagrid__empty",children:e.jsx("div",{className:"nice-spinner nice-spinner--md",style:{margin:"0 auto"}})})}):Ve.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:J.length+(ae?1:0),className:"nice-datagrid__empty",children:T||X("controls.noData","No data available")})}):Ve.map((Z,Se)=>{const He=me.has(Z.key),Ne=Z.children.length>0,k=M.has(Z.key);return e.jsxs("tr",{className:He?"nice-datagrid__row--selected":void 0,onClick:()=>re?.(Z.data),style:re?{cursor:"pointer"}:void 0,children:[ae&&e.jsx("td",{className:"nice-datagrid__checkbox",onClick:Q=>Q.stopPropagation(),children:e.jsx("input",{type:"checkbox",checked:He,onChange:()=>at(Z.key),"aria-label":`Select row ${Z.key}`})}),J.map((Q,F)=>e.jsxs("td",{style:{textAlign:Q.align},children:[F===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:G=>{G.stopPropagation(),Ne&&Xe(Z.key)},tabIndex:Ne?0:-1,"aria-expanded":Ne?k:void 0,"aria-label":Ne?k?"Collapse":"Expand":void 0,children:Ne?k?"▾":"▸":""})]}),Q.render?Q.render(Z.data[Q.field],Z.data,Se):String(Z.data[Q.field]??"")]},Q.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},wa=()=>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"})]}),ka=()=>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"})]}),Sa=()=>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"})]}),Ca=()=>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"})]}),Ma=()=>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"})]}),Da=()=>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"})]}),Ia=()=>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"})]}),Ra=()=>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"})]}),Aa=()=>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"})]}),Ea=()=>e.jsx("svg",{...xt,children:e.jsx("polyline",{points:"6 9 12 4 18 9"})}),$a=()=>e.jsx("svg",{...xt,children:e.jsx("polyline",{points:"6 15 12 20 18 15"})}),La=()=>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"})]}),za=()=>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"})]}),Ta=()=>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 Ie(n,a){return`${ui(a)}${n+1}`}function it(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 Pa(n,a,s=new Set){const r=n.startsWith("=")?n.slice(1).trim():n,o=(L,N)=>{if(!L||!N)return[];const f=[];for(let x=L.row;x<=N.row;x++)for(let v=L.col;v<=N.col;v++){const T=tt(Ie(x,v),a,new Set(s));typeof T=="number"&&f.push(T)}return f},p=(L,N)=>{if(!L||!N)return[];const f=[];for(let x=L.row;x<=N.row;x++)for(let v=L.col;v<=N.col;v++)f.push(tt(Ie(x,v),a,new Set(s)));return f},_=r.match(/^(\w+)\(([A-Z]+\d+):([A-Z]+\d+)\)$/i);if(_){const L=_[1].toUpperCase(),N=it(_[2].toUpperCase()),f=it(_[3].toUpperCase());switch(L){case"SUM":return o(N,f).reduce((v,T)=>v+T,0);case"AVG":case"AVERAGE":{const x=o(N,f);return x.length>0?x.reduce((v,T)=>v+T,0)/x.length:0}case"COUNT":return o(N,f).length;case"COUNTA":return p(N,f).filter(x=>x!==null&&x!=="").length;case"COUNTBLANK":return p(N,f).filter(x=>x===null||x==="").length;case"MIN":{const x=o(N,f);return x.length?Math.min(...x):0}case"MAX":{const x=o(N,f);return x.length?Math.max(...x):0}case"MEDIAN":{const x=o(N,f).sort((T,$)=>T-$);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(N,f);if(x.length<2)return 0;const v=x.reduce((T,$)=>T+$,0)/x.length;return Math.sqrt(x.reduce((T,$)=>T+($-v)**2,0)/(x.length-1))}case"PRODUCT":{const x=o(N,f);return x.length?x.reduce((v,T)=>v*T,1):0}}}const l=r.match(/^(SUMIF|COUNTIF)\(([A-Z]+\d+):([A-Z]+\d+)\s*,\s*"?([^"]*)"?\)$/i);if(l){const L=l[1].toUpperCase(),N=it(l[2].toUpperCase()),f=it(l[3].toUpperCase()),x=l[4];if(N&&f){let v=0;for(let T=N.row;T<=f.row;T++)for(let $=N.col;$<=f.col;$++){const re=tt(Ie(T,$),a,new Set(s));(x.startsWith(">")?Number(re)>Number(x.slice(1)):x.startsWith("<")?Number(re)<Number(x.slice(1)):String(re)===x||typeof re=="number"&&re===Number(x))&&(v+=L==="SUMIF"?typeof re=="number"?re:0:1)}return v}}const g=r.match(/^IF\(([^,]+),\s*([^,]+),\s*([^)]+)\)$/i);if(g){const L=g[1].trim(),N=g[2].trim(),f=g[3].trim(),x=L.match(/^([A-Z]+\d+)\s*([><=!]+)\s*(\S+)$/i);let v=!1;if(x){const re=tt(x[1].toUpperCase(),a,new Set(s)),ve=isNaN(Number(x[3]))?x[3].replace(/^"|"$/g,""):Number(x[3]),z=x[2],X=typeof re=="number"?re:Number(re)||0,le=typeof ve=="number"?ve:Number(ve)||0;switch(z){case">":v=X>le;break;case"<":v=X<le;break;case">=":v=X>=le;break;case"<=":v=X<=le;break;case"=":case"==":v=X===le;break;case"<>":case"!=":v=X!==le;break}}const T=v?N:f;if(it(T.toUpperCase()))return tt(T.toUpperCase(),a,new Set(s));const $=Number(T);return isNaN($)?T.replace(/^"|"$/g,""):$}const S=r.match(/^CONCAT\((.+)\)$/i);if(S)return S[1].split(",").map(N=>N.trim()).map(N=>{if(N.startsWith('"')&&N.endsWith('"'))return N.slice(1,-1);if(it(N.toUpperCase())){const x=tt(N.toUpperCase(),a,new Set(s));return x!==null?String(x):""}return N}).join("");const D=r.match(/^VLOOKUP\(([^,]+),\s*([A-Z]+\d+):([A-Z]+\d+),\s*(\d+)\)$/i);if(D){let L;it(D[1].trim().toUpperCase())?L=tt(D[1].trim().toUpperCase(),a,new Set(s)):L=isNaN(Number(D[1]))?D[1].replace(/^"|"$/g,""):Number(D[1]);const f=it(D[2].toUpperCase()),x=it(D[3].toUpperCase()),v=parseInt(D[4])-1;if(f&&x)for(let T=f.row;T<=x.row;T++){const $=tt(Ie(T,f.col),a,new Set(s));if(String($)===String(L))return tt(Ie(T,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 L=V[1].toUpperCase(),N=V[2].trim();let f;switch(it(N.toUpperCase())?f=tt(N.toUpperCase(),a,new Set(s)):f=isNaN(Number(N))?N.replace(/^"|"$/g,""):Number(N),L){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 R=r.match(/^POWER\(([^,]+),\s*([^)]+)\)$/i);if(R){const L=Number(it(R[1].trim().toUpperCase())?tt(R[1].trim().toUpperCase(),a,new Set(s)):R[1].trim())||0,N=Number(it(R[2].trim().toUpperCase())?tt(R[2].trim().toUpperCase(),a,new Set(s)):R[2].trim())||0;return Math.pow(L,N)}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 L=q[1].toUpperCase(),N=q[2],f=q[3],x=tt(L,a,s),T=it(f.toUpperCase())?tt(f.toUpperCase(),a,s):parseFloat(f),$=typeof x=="number"?x:0,re=typeof T=="number"?T:0;switch(N){case"+":return $+re;case"-":return $-re;case"*":return $*re;case"/":return re!==0?$/re:null}}const P=parseFloat(r);return isNaN(P)?r:P}function tt(n,a,s){if(s.has(n))return null;s.add(n);const r=a[n];return r?r.formula?Pa(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:S,onCellSelect:D,onCopy:V,onPaste:R,onInsert:ae,onRemove:q,maxUndo:P=50,sortable:L=!1,filterable:N=!1,rangeSelection:f=!0,className:x,style:v,id:T,...$},re)=>{const ve=Re.Hs(T),{t:z}=Re.$o(),[X,le]=t.useState(()=>n??[ti(z("spreadsheet.sheet","Sheet")+" 1")]),[de,ke]=t.useState(0),U=n??X,M=a??de,w=U[M]??U[0],[c,_e]=t.useState(null),[je,se]=t.useState(null),[j,ne]=t.useState(!1),[O,me]=t.useState(null),[J,Ae]=t.useState(""),Xe=t.useRef(null),at=t.useRef(null),[Ee,We]=t.useState([]),[Ve,Be]=t.useState([]),[Z,Se]=t.useState(null),He=t.useRef({x:0,width:80}),[Ne,k]=t.useState(null),[Q,F]=t.useState(null),[G,be]=t.useState("");t.useEffect(()=>{O&&Xe.current&&Xe.current.focus()},[O]);const H=t.useMemo(()=>{if(!c)return null;const d=je??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,je]),Ce=t.useCallback((d,h)=>H?d>=H.startRow&&d<=H.endRow&&h>=H.startCol&&h<=H.endCol:!1,[H]),Me=t.useCallback(d=>{We(h=>{const A=[...h,d.map(K=>({...K,data:{...K.data}}))];return A.length>P?A.slice(-P):A}),Be([])},[P]),ue=t.useCallback((d,h=!0)=>{h&&Me(U);const A=d(U);n||le(A),g?.(A)},[U,n,g,Me]),Te=t.useCallback(()=>{if(Ee.length===0)return;const d=Ee[Ee.length-1];Be(h=>[...h,U.map(A=>({...A,data:{...A.data}}))]),We(h=>h.slice(0,-1)),n||le(d),g?.(d)},[Ee,U,n,g]),st=t.useCallback(()=>{if(Ve.length===0)return;const d=Ve[Ve.length-1];We(h=>[...h,U.map(A=>({...A,data:{...A.data}}))]),Be(h=>h.slice(0,-1)),n||le(d),g?.(d)},[Ve,U,n,g]),ut=t.useCallback(d=>{a||ke(d),S?.(d),_e(null),se(null),me(null)},[a,S]),we=t.useCallback((d,h,A)=>{const K=Ie(d,h);ue(ee=>{const E=ee.map((ie,oe)=>oe===M?{...ie,data:{...ie.data}}:ie),B=A.startsWith("=");return E[M].data[K]={...E[M].data[K]??{value:null},formula:B?A:void 0,value:B?null:isNaN(Number(A))?A:Number(A)},E})},[M,ue]),Tt=t.useCallback((d,h,A)=>{A?.shiftKey&&f&&c?se({row:d,col:h}):(_e({row:d,col:h}),se(null)),me(null),D?.(M,d,h)},[M,D,f,c]),ht=t.useCallback((d,h,A)=>{A.button===0&&(Tt(d,h,A),f&&!A.shiftKey&&ne(!0))},[Tt,f]),St=t.useCallback((d,h)=>{j&&se({row:d,col:h})},[j]);t.useEffect(()=>{if(!j)return;const d=()=>ne(!1);return document.addEventListener("mouseup",d),()=>document.removeEventListener("mouseup",d)},[j]);const wt=t.useCallback((d,h)=>{if(l)return;const A=Ie(d,h),K=w.data[A];K?.readOnly||(me({row:d,col:h}),Ae(K?.formula??(K?.value!=null?String(K.value):"")))},[l,w.data]),I=t.useCallback(()=>{O&&(we(O.row,O.col,J),me(null))},[O,J,we]),Y=t.useCallback(d=>{if(d.key==="Enter")I();else if(d.key==="Escape")me(null);else if(d.key==="Tab"&&(d.preventDefault(),I(),c)){const h=d.shiftKey?Math.max(0,c.col-1):Math.min(r-1,c.col+1);_e({row:c.row,col:h})}},[I,c,r]),pe=t.useCallback((d,h)=>{if(!c)return;const A=H??{startRow:c.row,startCol:c.col,endRow:c.row,endCol:c.col};ue(K=>{const ee=K.map((E,B)=>B===M?{...E,data:{...E.data}}:E);for(let E=A.startRow;E<=A.endRow;E++)for(let B=A.startCol;B<=A.endCol;B++){const ie=Ie(E,B);ee[M].data[ie]={...ee[M].data[ie]??{value:null},[d]:h}}return ee})},[c,H,M,ue]),nt=t.useCallback(d=>{if(!H||V?.(H)===!1)return;const{startRow:h,startCol:A,endRow:K,endCol:ee}=H,E=[];for(let B=h;B<=K;B++){const ie=[];for(let oe=A;oe<=ee;oe++){const $e=Ie(B,oe),Oe=w.data[$e],xe=Oe?tt($e,w.data,new Set):null;ie.push(ei(xe,Oe?.format))}E.push(ie.join(" "))}d.clipboardData.setData("text/plain",E.join(`
|
|
595
|
+
`)),d.preventDefault()},[H,w.data,V]),ft=t.useCallback(d=>{if(l||!c)return;const h=d.clipboardData.getData("text/plain");if(!h)return;const A=h.split(`
|
|
596
|
+
`).map(K=>K.split(" "));R?.(A,c.row,c.col)!==!1&&(ue(K=>{const ee=K.map((E,B)=>B===M?{...E,data:{...E.data}}:E);return A.forEach((E,B)=>{E.forEach((ie,oe)=>{const $e=Ie(c.row+B,c.col+oe),Oe=ie.startsWith("=");ee[M].data[$e]={...ee[M].data[$e]??{value:null},formula:Oe?ie:void 0,value:Oe?null:isNaN(Number(ie))?ie:Number(ie)}})}),ee}),d.preventDefault())},[l,c,M,ue,R]),De=t.useCallback(d=>{ue(h=>h.map((K,ee)=>{if(ee!==M)return K;const E={};for(const[B,ie]of Object.entries(K.data)){const oe=it(B);oe&&(oe.row>d?E[Ie(oe.row+1,oe.col)]=ie:E[B]=ie)}return{...K,data:E}})),ae?.("row",d)},[M,ue,ae]),Ke=t.useCallback(d=>{ue(h=>h.map((K,ee)=>{if(ee!==M)return K;const E={};for(const[B,ie]of Object.entries(K.data)){const oe=it(B);oe&&(oe.col>d?E[Ie(oe.row,oe.col+1)]=ie:E[B]=ie)}return{...K,data:E}})),ae?.("column",d)},[M,ue,ae]),Ge=t.useCallback(d=>{ue(h=>h.map((K,ee)=>{if(ee!==M)return K;const E={};for(const[B,ie]of Object.entries(K.data)){const oe=it(B);oe&&oe.row!==d&&(oe.row>d?E[Ie(oe.row-1,oe.col)]=ie:E[B]=ie)}return{...K,data:E}})),q?.("row",d)},[M,ue,q]),mt=t.useCallback(d=>{ue(h=>h.map((K,ee)=>{if(ee!==M)return K;const E={};for(const[B,ie]of Object.entries(K.data)){const oe=it(B);oe&&oe.col!==d&&(oe.col>d?E[Ie(oe.row,oe.col-1)]=ie:E[B]=ie)}return{...K,data:E}})),q?.("column",d)},[M,ue,q]),rt=t.useCallback((d,h)=>{ue(A=>A.map((ee,E)=>{if(E!==M)return ee;const B=new Map;for(const[$e,Oe]of Object.entries(ee.data)){const xe=it($e);xe&&(B.has(xe.row)||B.set(xe.row,{}),B.get(xe.row)[xe.col]=Oe)}const ie=Array.from(B.entries()).sort(($e,Oe)=>{const xe=tt(Ie($e[0],d),ee.data,new Set),Ye=tt(Ie(Oe[0],d),ee.data,new Set),Ct=typeof xe=="number"?xe:Number(xe),Mt=typeof Ye=="number"?Ye:Number(Ye);if(!isNaN(Ct)&&!isNaN(Mt))return h==="asc"?Ct-Mt:Mt-Ct;const Je=String(xe??""),_t=String(Ye??"");return h==="asc"?Je.localeCompare(_t):_t.localeCompare(Je)}),oe={};return ie.forEach(([,$e],Oe)=>{for(const[xe,Ye]of Object.entries($e))oe[Ie(Oe,Number(xe))]=Ye}),{...ee,data:oe,sortColumn:d,sortDirection:h}}))},[M,ue]),kt=t.useCallback((d,h)=>{const A=w.conditionalFormats;if(!A?.length)return;const K=Ie(d,h),ee=tt(K,w.data,new Set),E=typeof ee=="number"?ee:Number(ee);for(const B of A){const ie=B.range.match(/^([A-Z]+\d+):([A-Z]+\d+)$/i);if(!ie)continue;const oe=it(ie[1].toUpperCase()),$e=it(ie[2].toUpperCase());if(!oe||!$e||d<oe.row||d>$e.row||h<oe.col||h>$e.col)continue;let Oe=!1;switch(B.type){case"greaterThan":Oe=!isNaN(E)&&E>Number(B.value);break;case"lessThan":Oe=!isNaN(E)&&E<Number(B.value);break;case"equalTo":Oe=String(ee)===String(B.value);break;case"between":Oe=!isNaN(E)&&E>=Number(B.value)&&E<=Number(B.value2);break;case"textContains":Oe=String(ee).includes(String(B.value));break;case"isEmpty":Oe=ee===null||ee==="";break;case"isNotEmpty":Oe=ee!==null&&ee!=="";break}if(Oe)return{backgroundColor:B.style.bgColor,color:B.style.color,fontWeight:B.style.bold?"bold":void 0,fontStyle:B.style.italic?"italic":void 0}}},[w.conditionalFormats,w.data]),Vt=t.useCallback(()=>{const d=`${z("spreadsheet.sheet","Sheet")} ${U.length+1}`;ue(h=>[...h,ti(d)]),ut(U.length)},[U.length,ue,ut,z]),tn=t.useCallback(()=>{U.length<=1||(ue(d=>d.filter((h,A)=>A!==M)),ut(Math.max(0,M-1)))},[U.length,M,ue,ut]),Xt=t.useCallback((d,h)=>{h.trim()&&(ue(A=>A.map((K,ee)=>ee===d?{...K,name:h.trim()}:K),!1),F(null))},[ue]),Ht=t.useMemo(()=>{if(!c)return"";const d=Ie(c.row,c.col),h=w.data[d];return h?.formula??(h?.value!=null?String(h.value):"")},[c,w.data]),pt=t.useMemo(()=>{if(!H)return null;const{startRow:d,startCol:h,endRow:A,endCol:K}=H;if(d===A&&h===K)return null;const ee=[];let E=0;for(let B=d;B<=A;B++)for(let ie=h;ie<=K;ie++){const oe=Ie(B,ie),$e=tt(oe,w.data,new Set);$e!==null&&$e!==""&&E++,typeof $e=="number"&&ee.push($e)}return ee.length===0?{count:E}:{count:E,sum:ee.reduce((B,ie)=>B+ie,0),avg:ee.reduce((B,ie)=>B+ie,0)/ee.length,min:Math.min(...ee),max:Math.max(...ee)}},[H,w.data]),mn=t.useCallback((d,h)=>{h.preventDefault(),h.stopPropagation(),Se(d),He.current={x:h.clientX,width:w.colWidths?.[d]??80}},[w.colWidths]);t.useEffect(()=>{if(Z===null)return;const d=A=>{const K=A.clientX-He.current.x,ee=Math.max(30,He.current.width+K);ue(E=>E.map((ie,oe)=>oe===M?{...ie,colWidths:{...ie.colWidths,[Z]:ee}}:ie),!1)},h=()=>Se(null);return document.addEventListener("mousemove",d),document.addEventListener("mouseup",h),()=>{document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",h)}},[Z,M,ue]);const nn=t.useCallback((d,h,A)=>{d.preventDefault(),_e({row:h,col:A}),k({x:d.clientX,y:d.clientY})},[]);t.useEffect(()=>{if(!Ne)return;const d=()=>k(null);return document.addEventListener("click",d),()=>document.removeEventListener("click",d)},[Ne]);const Pe=t.useCallback(d=>{if((d.ctrlKey||d.metaKey)&&!O){if(d.key==="z"){d.preventDefault(),Te();return}if(d.key==="y"){d.preventDefault(),st();return}}if(O||!c)return;let{row:h,col:A}=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":A=Math.max(0,A-1);break;case"ArrowRight":A=Math.min(r-1,A+1);break;case"Enter":wt(h,A);return;case"Delete":case"Backspace":l||(H&&(H.startRow!==H.endRow||H.startCol!==H.endCol)?ue(K=>{const ee=K.map((E,B)=>B===M?{...E,data:{...E.data}}:E);for(let E=H.startRow;E<=H.endRow;E++)for(let B=H.startCol;B<=H.endCol;B++)delete ee[M].data[Ie(E,B)];return ee}):we(h,A,""));return;default:if(d.key.length===1&&!d.ctrlKey&&!d.metaKey&&!l){me({row:h,col:A}),Ae(d.key);return}return}d.preventDefault(),d.shiftKey&&f?se({row:h,col:A}):(_e({row:h,col:A}),se(null)),D?.(M,h,A)},[O,c,s,r,l,wt,we,M,D,Te,st,H,ue,f]),Qe=w.frozenRows??0,Fe=w.frozenCols??0,Kt=[{value:"text",label:z("spreadsheet.formatText","Text")},{value:"number",label:z("spreadsheet.formatNumber","Number")},{value:"percent",label:z("spreadsheet.formatPercent","Percent")},{value:"currency",label:z("spreadsheet.formatCurrency","Currency")},{value:"date",label:z("spreadsheet.formatDate","Date")}];return e.jsxs("div",{ref:re,id:ve,className:`nice-spreadsheet ${l?"nice-spreadsheet--readonly":""} ${x??""}`,style:v,onKeyDown:Pe,onCopy:nt,onPaste:ft,tabIndex:0,role:"application","aria-label":z("spreadsheet.label","Spreadsheet"),...$,children:[o&&!l&&e.jsxs("div",{className:"nice-spreadsheet__toolbar",role:"toolbar",children:[e.jsx(ze.NiceButton,{variant:"ghost",size:"sm",onClick:Te,disabled:Ee.length===0,title:z("spreadsheet.undo","Undo"),children:e.jsx(wa,{})}),e.jsx(ze.NiceButton,{variant:"ghost",size:"sm",onClick:st,disabled:Ve.length===0,title:z("spreadsheet.redo","Redo"),children:e.jsx(ka,{})}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(ze.NiceButton,{variant:w.data[c?Ie(c.row,c.col):""]?.bold?"primary":"ghost",size:"sm",onClick:()=>pe("bold",!w.data[c?Ie(c.row,c.col):""]?.bold),title:z("spreadsheet.bold","Bold"),children:e.jsx("strong",{children:"B"})}),e.jsx(ze.NiceButton,{variant:w.data[c?Ie(c.row,c.col):""]?.italic?"primary":"ghost",size:"sm",onClick:()=>pe("italic",!w.data[c?Ie(c.row,c.col):""]?.italic),title:z("spreadsheet.italic","Italic"),children:e.jsx("em",{children:"I"})}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(ze.NiceButton,{variant:"ghost",size:"sm",onClick:()=>pe("align","left"),title:z("spreadsheet.alignLeft","Align left"),children:e.jsx(Sa,{})}),e.jsx(ze.NiceButton,{variant:"ghost",size:"sm",onClick:()=>pe("align","center"),title:z("spreadsheet.alignCenter","Center"),children:e.jsx(Ca,{})}),e.jsx(ze.NiceButton,{variant:"ghost",size:"sm",onClick:()=>pe("align","right"),title:z("spreadsheet.alignRight","Align right"),children:e.jsx(Ma,{})}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(ze.NiceColorPicker,{value:w.data[c?Ie(c.row,c.col):""]?.bgColor??"var(--bg-primary, #ffffff)",onChange:d=>pe("bgColor",d),title:z("spreadsheet.bgColor","Background color"),showInput:!1,showRandom:!1}),e.jsx(ze.NiceColorPicker,{value:w.data[c?Ie(c.row,c.col):""]?.color??"var(--text-primary, #000000)",onChange:d=>pe("color",d),title:z("spreadsheet.textColor","Text color"),showInput:!1,showRandom:!1}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(ze.NiceSelect,{size:"sm",value:w.data[c?Ie(c.row,c.col):""]?.format??"text",onChange:d=>pe("format",d),options:Kt,"aria-label":z("spreadsheet.format","Cell format")}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(ze.NiceButton,{variant:"ghost",size:"sm",onClick:()=>c&&De(c.row),title:z("spreadsheet.insertRow","Insert row"),children:e.jsx(Da,{})}),e.jsx(ze.NiceButton,{variant:"ghost",size:"sm",onClick:()=>c&&Ke(c.col),title:z("spreadsheet.insertCol","Insert column"),children:e.jsx(Ia,{})}),e.jsx(ze.NiceButton,{variant:"ghost",size:"sm",onClick:()=>c&&Ge(c.row),title:z("spreadsheet.deleteRow","Delete row"),children:e.jsx(Ra,{})}),e.jsx(ze.NiceButton,{variant:"ghost",size:"sm",onClick:()=>c&&mt(c.col),title:z("spreadsheet.deleteCol","Delete column"),children:e.jsx(Aa,{})})]}),p&&e.jsxs("div",{className:"nice-spreadsheet__formula-bar",children:[e.jsxs("span",{className:"nice-spreadsheet__cell-label",children:[c?Ie(c.row,c.col):"",H&&H.startRow!==H.endRow||H&&H.startCol!==H.endCol?`:${Ie(H.endRow,H.endCol)}`:""]}),e.jsx(ze.NiceTextInput,{className:"nice-spreadsheet__formula-input",value:O?J:Ht,onChange:d=>{O?Ae(d):c&&(me(c),Ae(d))},onKeyDown:Y,readOnly:l,"aria-label":z("spreadsheet.formulaBar","Formula bar")})]}),e.jsx("div",{className:"nice-spreadsheet__grid",ref:at,children:e.jsxs("table",{role:"grid","aria-label":w.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:w.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)}),L&&e.jsx("span",{className:"nice-spreadsheet__sort-trigger",onClick:()=>rt(h,w.sortColumn===h&&w.sortDirection==="asc"?"desc":"asc"),title:z("spreadsheet.sort","Sort"),children:w.sortColumn===h?w.sortDirection==="asc"?e.jsx(Ea,{}):e.jsx($a,{}):e.jsx(La,{})}),!l&&e.jsx("span",{className:"nice-spreadsheet__col-resize",onMouseDown:A=>mn(h,A)})]},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},(A,K)=>{const ee=Ie(h,K),E=w.data[ee];if(E?.mergedInto)return null;const B=c?.row===h&&c?.col===K,ie=Ce(h,K),oe=O?.row===h&&O?.col===K,$e=E?tt(ee,w.data,new Set):null,Oe=kt(h,K),xe=h<Qe||K<Fe;return e.jsxs("td",{className:`nice-spreadsheet__cell ${B?"nice-spreadsheet__cell--selected":""} ${ie&&!B?"nice-spreadsheet__cell--in-range":""} ${E?.readOnly?"nice-spreadsheet__cell--readonly":""} ${xe?"nice-spreadsheet__cell--frozen":""}`,style:{textAlign:E?.align,fontWeight:E?.bold?"bold":void 0,fontStyle:E?.italic?"italic":void 0,backgroundColor:Oe?.backgroundColor??E?.bgColor,color:Oe?.color??E?.color,width:w.colWidths?.[K],height:w.rowHeights?.[h],position:xe?"sticky":void 0,left:K<Fe?K*80+40:void 0,zIndex:xe?1:void 0,...Oe},colSpan:E?.colSpan,rowSpan:E?.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":B,title:E?.comment,children:[E?.comment&&e.jsx("span",{className:"nice-spreadsheet__comment-indicator"}),oe?e.jsx("input",{ref:Xe,className:"nice-spreadsheet__cell-editor",value:J,onChange:Ye=>Ae(Ye.target.value),onKeyDown:Y,onBlur:I}):ei($e,E?.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(ze.NiceButton,{variant:"ghost",size:"sm",onClick:()=>{De(c.row),k(null)},children:z("spreadsheet.insertRowAbove","Insert row above")}),e.jsx(ze.NiceButton,{variant:"ghost",size:"sm",onClick:()=>{De(c.row+1),k(null)},children:z("spreadsheet.insertRowBelow","Insert row below")}),e.jsx(ze.NiceButton,{variant:"ghost",size:"sm",onClick:()=>{Ke(c.col),k(null)},children:z("spreadsheet.insertColLeft","Insert column left")}),e.jsx(ze.NiceButton,{variant:"ghost",size:"sm",onClick:()=>{Ke(c.col+1),k(null)},children:z("spreadsheet.insertColRight","Insert column right")}),e.jsx("hr",{className:"nice-spreadsheet__context-sep"}),e.jsx(ze.NiceButton,{variant:"ghost",size:"sm",onClick:()=>{Ge(c.row),k(null)},children:z("spreadsheet.deleteRow","Delete row")}),e.jsx(ze.NiceButton,{variant:"ghost",size:"sm",onClick:()=>{mt(c.col),k(null)},children:z("spreadsheet.deleteCol","Delete column")})]}),pt&&e.jsxs("div",{className:"nice-spreadsheet__status-bar",children:[e.jsxs("span",{children:[z("spreadsheet.count","Count"),": ",pt.count]}),pt.sum!==void 0&&e.jsxs("span",{children:[z("spreadsheet.sum","Sum"),": ",pt.sum.toFixed(2)]}),pt.avg!==void 0&&e.jsxs("span",{children:[z("spreadsheet.avg","Avg"),": ",pt.avg.toFixed(2)]}),pt.min!==void 0&&e.jsxs("span",{children:[z("spreadsheet.min","Min"),": ",pt.min]}),pt.max!==void 0&&e.jsxs("span",{children:[z("spreadsheet.max","Max"),": ",pt.max]})]}),_&&e.jsxs("div",{className:"nice-spreadsheet__tabs",role:"tablist",children:[U.map((d,h)=>e.jsx("span",{className:"nice-spreadsheet__tab-wrapper",children:Q===h?e.jsx(ze.NiceTextInput,{className:"nice-spreadsheet__tab-rename",value:G,onChange:A=>be(A),onBlur:()=>Xt(h,G),onKeyDown:A=>{A.key==="Enter"&&Xt(h,G),A.key==="Escape"&&F(null)},autoFocus:!0}):e.jsx("span",{onDoubleClick:()=>{l||(F(h),be(d.name))},children:e.jsx(ze.NiceButton,{variant:h===M?"primary":"ghost",size:"sm",onClick:()=>ut(h),children:d.name})})},h)),!l&&e.jsxs(e.Fragment,{children:[e.jsx(ze.NiceButton,{variant:"ghost",size:"sm",onClick:Vt,title:z("spreadsheet.addSheet","Add sheet"),children:e.jsx(za,{})}),U.length>1&&e.jsx(ze.NiceButton,{variant:"ghost",size:"sm",onClick:tn,title:z("spreadsheet.removeSheet","Remove sheet"),children:e.jsx(Ta,{})})]})]})]})});hi.displayName="NiceSpreadsheet";const Fa=({queries:n,currentFilter:a,currentColumns:s,currentSort:r,onLoad:o,onSave:p,onUpdate:_,onDelete:l,onShare:g,onSetDefault:S,allowSharing:D=!0,allowPinning:V=!0,position:R="dropdown",className:ae,style:q,"data-testid":P})=>{const[L,N]=t.useState(!1),[f,x]=t.useState(""),[v,T]=t.useState(!1),[$,re]=t.useState(""),[ve,z]=t.useState(""),[X,le]=t.useState(!1),de=n.filter(c=>c.name.toLowerCase().includes(f.toLowerCase())),ke=de.filter(c=>!c.isShared),U=de.filter(c=>c.isShared),M=async()=>{if($.trim()){T(!0);try{await p({name:$,description:ve||void 0,filter:a??{},columns:s,sort:r}),le(!1),re(""),z("")}finally{T(!1)}}},w=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),N(!1)},type:"button",children:"Wczytaj"}),S&&e.jsx("button",{onClick:()=>S(c.id),type:"button",title:"Ustaw domyślne",children:"★"}),D&&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--${R} ${L?"nice-saved-query--open":""} ${ae??""}`,style:q,"data-testid":P,children:[e.jsx("button",{className:"nice-saved-query__trigger",onClick:()=>N(c=>!c),"aria-expanded":L,"aria-haspopup":"listbox",type:"button",children:"Widoki i zapytania"}),L&&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:()=>le(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=>re(c.target.value),"aria-label":"Nazwa zapytania"}),e.jsx("input",{type:"text",placeholder:"Opis (opcjonalnie)",value:ve,onChange:c=>z(c.target.value),"aria-label":"Opis zapytania"}),e.jsx("button",{onClick:M,disabled:v||!$.trim(),type:"button",children:v?"Zapisywanie…":"Zapisz"}),e.jsx("button",{onClick:()=>le(!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(w)]}),U.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"}),U.map(w)]}),de.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=ha;exports.NicePivotGrid=ci;exports.NicePivotGrid$1=Zi;exports.NicePivotGridFieldChooser=ri;exports.NiceReconciliationView=_a;exports.NiceSavedQueryPanel=Fa;exports.NiceSpreadsheet=hi;exports.NiceTable=Mi;exports.NiceTileView=Vi;exports.NiceTreeGrid=Na;exports.NiceTreeList=Bi;exports.NiceTreeView=Ui;exports.computeAggregate=ai;exports.escapeCsvField=un;
|