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