@nice2dev/ui 1.0.17 → 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +252 -0
- package/dist/NiceAlertDialog.doc-BST0-aVs.cjs +14 -0
- package/dist/NiceAlertDialog.doc-GRpJU_5Y.js +38 -0
- package/dist/NiceAnimatePresence.doc-BrttRpeS.js +36 -0
- package/dist/NiceAnimatePresence.doc-IdEWrSnT.cjs +12 -0
- package/dist/NiceCalendarScheduler.doc-Cc-DFMhR.js +33 -0
- package/dist/NiceCalendarScheduler.doc-TPe0kRBN.cjs +9 -0
- package/dist/NiceCameraFeed.doc-BJl0gdWv.js +31 -0
- package/dist/NiceCameraFeed.doc-Bt4eZ8MH.cjs +7 -0
- package/dist/NiceChip.doc-Bccf4IQe.cjs +7 -0
- package/dist/NiceChip.doc-DEsqjL7z.js +31 -0
- package/dist/NiceCombobox.doc-8hMzrsdM.js +34 -0
- package/dist/NiceCombobox.doc-C5IPnVuz.cjs +10 -0
- package/dist/NiceConfigProvider.doc-CKIudO44.js +32 -0
- package/dist/NiceConfigProvider.doc-bMLQj3Zx.cjs +8 -0
- package/dist/NiceCronEditor.doc-BThdELxx.js +31 -0
- package/dist/NiceCronEditor.doc-w_TbOWFo.cjs +7 -0
- package/dist/NiceDataList.doc-DHXrpTPT.cjs +9 -0
- package/dist/NiceDataList.doc-R8SchHqZ.js +33 -0
- package/dist/NiceDiagram.doc-CASS0Tnj.cjs +8 -0
- package/dist/NiceDiagram.doc-DGX-Hwhg.js +32 -0
- package/dist/NiceDocPage.doc-BVBe27kj.cjs +1 -0
- package/dist/NiceDocPage.doc-CDcL3Sqt.js +25 -0
- package/dist/NiceDrawingCanvas.doc-DYYFKKMW.js +32 -0
- package/dist/NiceDrawingCanvas.doc-wa684gbC.cjs +8 -0
- package/dist/NiceDropdown.doc-D2NS9hBT.js +35 -0
- package/dist/NiceDropdown.doc-dAgER8da.cjs +11 -0
- package/dist/NiceDropzone.doc-CVVNc9SE.cjs +9 -0
- package/dist/NiceDropzone.doc-aeajYWqU.js +33 -0
- package/dist/NiceEnergyMonitor.doc-BBnVKuwf.js +32 -0
- package/dist/NiceEnergyMonitor.doc-lf6CCIYi.cjs +8 -0
- package/dist/NiceErrorBoundary-COY0cEsF.js +762 -0
- package/dist/NiceErrorBoundary-CR-_ZScD.cjs +1 -0
- package/dist/NiceExpressionBuilder.doc-CTjqEcZR.cjs +8 -0
- package/dist/NiceExpressionBuilder.doc-Cu_ORFhd.js +32 -0
- package/dist/NiceFileExplorer.doc-B0aN041v.js +32 -0
- package/dist/NiceFileExplorer.doc-DNHYQF_t.cjs +8 -0
- package/dist/NiceFloatingActionButton.doc-BOlJwq4S.cjs +7 -0
- package/dist/NiceFloatingActionButton.doc-oYnwvMP9.js +31 -0
- package/dist/NiceFontPicker.doc-B10vOqeF.cjs +8 -0
- package/dist/NiceFontPicker.doc-DuPp0cDP.js +32 -0
- package/dist/NiceForm-COk1rNVa.js +5357 -0
- package/dist/NiceForm-CU8Dldq-.cjs +382 -0
- package/dist/NiceGestureHandler.doc-9GGvVnM5.cjs +8 -0
- package/dist/NiceGestureHandler.doc-BduQU3SA.js +32 -0
- package/dist/NiceHeader.doc-Cxoy_f_k.cjs +6 -0
- package/dist/NiceHeader.doc-DjAVl-T4.js +30 -0
- package/dist/NiceImage.doc-COy4iVy1.js +34 -0
- package/dist/NiceImage.doc-CvnaTRj8.cjs +10 -0
- package/dist/NiceInPlaceEditor.doc-8nC6Kqvn.cjs +1 -0
- package/dist/NiceInPlaceEditor.doc-gF1XPyu5.js +25 -0
- package/dist/NiceInteractiveTimeline.doc-BTeASFR4.js +50 -0
- package/dist/NiceInteractiveTimeline.doc-WMOVQhMe.cjs +11 -0
- package/dist/NiceJsonEditor.doc-BpVa-AlY.js +31 -0
- package/dist/NiceJsonEditor.doc-DeyoVDQw.cjs +7 -0
- package/dist/NiceMegaMenu.doc-CO34gN43.cjs +7 -0
- package/dist/NiceMegaMenu.doc-DpchTBL6.js +31 -0
- package/dist/NiceMentionInput.doc-O0W58Unu.js +32 -0
- package/dist/NiceMentionInput.doc-ZSPjBsZc.cjs +8 -0
- package/dist/NiceModal-CIITx65V.cjs +1 -0
- package/dist/NiceModal-CN23FZsc.js +95 -0
- package/dist/NiceModuleLifecyclePanel-BDnsr5ZW.js +6349 -0
- package/dist/NiceModuleLifecyclePanel-F1uN0gMh.cjs +1 -0
- package/dist/NiceMotion.doc-COF5BldG.cjs +9 -0
- package/dist/NiceMotion.doc-utheTBgM.js +33 -0
- package/dist/NiceMultiColumnComboBox.doc-Ben0Q0J0.cjs +1 -0
- package/dist/NiceMultiColumnComboBox.doc-CK1DppZI.js +25 -0
- package/dist/NiceNotificationList.doc-CBWusjJX.cjs +7 -0
- package/dist/NiceNotificationList.doc-D7lQIxK0.js +31 -0
- package/dist/NiceOfflineSync.doc-BLQFyOf2.cjs +8 -0
- package/dist/NiceOfflineSync.doc-CKWFmR3b.js +32 -0
- package/dist/NicePagination-B4U0LwZy.js +171 -0
- package/dist/NicePagination-CGQf54a9.cjs +1 -0
- package/dist/NicePinCodeInput-DG_-eXXJ.cjs +419 -0
- package/dist/NicePinCodeInput-g-yUiepm.js +11875 -0
- package/dist/NicePreview.doc-Cl7_5MVR.js +30 -0
- package/dist/NicePreview.doc-atKISvmp.cjs +6 -0
- package/dist/NicePropertyGrid.doc-D6xljYe1.cjs +7 -0
- package/dist/NicePropertyGrid.doc-nX2etusg.js +31 -0
- package/dist/NiceRadio.doc-BTURz62X.js +27 -0
- package/dist/NiceRadio.doc-Cc8-1vbn.cjs +3 -0
- package/dist/NiceRecurrencePicker.doc-78HjPJm0.js +31 -0
- package/dist/NiceRecurrencePicker.doc-vC2YmCXF.cjs +7 -0
- package/dist/NiceRichTextEditor.doc-ClPCkzCd.cjs +6 -0
- package/dist/NiceRichTextEditor.doc-CtmV9UvX.js +30 -0
- package/dist/NiceSavedQueryPanel-CE3QR4RY.js +6446 -0
- package/dist/NiceSavedQueryPanel-DSnj-3Es.cjs +596 -0
- package/dist/NiceSceneSelector.doc-CY2OmaWQ.cjs +7 -0
- package/dist/NiceSceneSelector.doc-UsVgDrw1.js +31 -0
- package/dist/NiceScrollArea.doc-C6Y-odUa.js +27 -0
- package/dist/NiceScrollArea.doc-LdxDrGDY.cjs +3 -0
- package/dist/NiceSheet.doc-CsIu3Y1G.cjs +11 -0
- package/dist/NiceSheet.doc-DLfSY-MA.js +35 -0
- package/dist/NiceSpeedDial.doc-CSWvNR9n.cjs +7 -0
- package/dist/NiceSpeedDial.doc-DqnpBcMy.js +31 -0
- package/dist/NiceSplitPane.doc-Ck_FvdL6.cjs +9 -0
- package/dist/NiceSplitPane.doc-Di68JZuy.js +33 -0
- package/dist/NiceSpotlight.doc-CM4PnsHE.js +34 -0
- package/dist/NiceSpotlight.doc-Dm_B-kUJ.cjs +10 -0
- package/dist/NiceStepNavigation.doc-DXraCs7t.js +31 -0
- package/dist/NiceStepNavigation.doc-TSy2dWmf.cjs +7 -0
- package/dist/NiceSteps.doc-C_mkhnez.cjs +10 -0
- package/dist/NiceSteps.doc-PW1zubHM.js +34 -0
- package/dist/NiceSwitch.doc-CLc7OxrE.cjs +6 -0
- package/dist/NiceSwitch.doc-dGMMY4es.js +30 -0
- package/dist/NiceTabs-32xjguOv.cjs +1 -0
- package/dist/NiceTabs-Blk0h4jY.js +1624 -0
- package/dist/NiceTransition.doc-BmImVoB8.js +35 -0
- package/dist/NiceTransition.doc-GA1N91ON.cjs +11 -0
- package/dist/NiceTree.doc-D7SCXljC.js +40 -0
- package/dist/NiceTree.doc-DZx3hUwY.cjs +16 -0
- package/dist/NiceUnitConverter.doc-DmiyYOH_.cjs +10 -0
- package/dist/NiceUnitConverter.doc-YnzD3uKT.js +34 -0
- package/dist/NiceVirtualGrid.doc-DI2c9ckY.js +35 -0
- package/dist/NiceVirtualGrid.doc-rtwudxTG.cjs +11 -0
- package/dist/NiceVirtualList.doc-BpoTiXoV.js +31 -0
- package/dist/NiceVirtualList.doc-C8q-Hfl0.cjs +7 -0
- package/dist/NiceWindow-B4jA_-hi.js +1409 -0
- package/dist/NiceWindow-UpKllge7.cjs +1 -0
- package/dist/charts-0BEMJ0Xt.js +4657 -0
- package/dist/charts-CbxmU6Z2.cjs +761 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.d.ts +19 -19
- package/dist/charts.mjs +1 -1
- package/dist/core-BIA5_uSq.js +22316 -0
- package/dist/core-DQYnL6uf.cjs +96 -0
- package/dist/data.cjs +1 -1
- package/dist/data.mjs +1 -1
- package/dist/editors.cjs +1 -1
- package/dist/editors.mjs +3 -3
- package/dist/feedback.cjs +1 -1
- package/dist/feedback.d.ts +10 -10
- package/dist/feedback.mjs +2 -2
- package/dist/index-BjBsn6ad.cjs +5194 -0
- package/dist/index-C2Uoywo9.js +63852 -0
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1631 -53
- package/dist/index.mjs +943 -895
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.d.ts +4 -3
- package/dist/lazy.mjs +3 -3
- package/dist/navigation.cjs +1 -1
- package/dist/navigation.mjs +4 -4
- package/dist/overlays.cjs +1 -1
- package/dist/overlays.mjs +2 -2
- package/dist/style.css +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,596 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),De=require("./core-DQYnL6uf.cjs"),t=require("react"),Yn=require("./NiceForm-CU8Dldq-.cjs"),Jn=require("./NiceModal-CIITx65V.cjs"),Ni=require("./NicePagination-CGQf54a9.cjs"),ze=require("./NiceTabs-32xjguOv.cjs");function wi({columns:n,data:a,striped:s,compact:r,emptyText:o,className:p,style:x,accessMode:l,id:f,displayStyle:S}){const V=De._s(l,f)==="hidden",R=De.cs("table",S),ae=De.ls("table",S),[X,F]=t.useState(null),T=t.useMemo(()=>X?[...a].sort((g,_)=>{const y=g[X.field]??"",P=_[X.field]??"",$=typeof y=="number"?y-P:String(y).localeCompare(String(P));return X.dir==="desc"?-$:$}):a,[a,X]),w=g=>{F(_=>_?.field===g?_.dir==="asc"?{field:g,dir:"desc"}:null:{field:g,dir:"asc"})};return V?null:e.jsx("div",{className:`nice-table-wrapper ${p||""}`,style:{...R,...x},children:e.jsxs("table",{className:`nice-table nice-table--ds-${ae} ${s?"nice-table--striped":""} ${r?"nice-table--compact":""}`,"aria-rowcount":T.length,"aria-colcount":n.length,children:[e.jsx("thead",{children:e.jsx("tr",{children:n.map(g=>{const _=g.sortable?X?.field===g.field?X.dir==="asc"?"ascending":"descending":"none":void 0;return e.jsxs("th",{style:{width:g.width,textAlign:g.align},className:g.sortable?"th--sortable":void 0,onClick:()=>g.sortable&&w(g.field),scope:"col","aria-sort":_,children:[g.header,g.sortable&&X?.field===g.field&&e.jsx("span",{className:"nice-table__sort-icon","aria-hidden":"true",children:X.dir==="asc"?"↑":"↓"})]},g.field)})})}),e.jsx("tbody",{children:T.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:n.length,className:"nice-table__empty",children:o||"No data"})}):T.map((g,_)=>e.jsx("tr",{children:n.map(y=>e.jsx("td",{style:{textAlign:y.align},children:y.render?y.render(g[y.field],g):String(g[y.field]??"")},y.field))},_))})]})})}function ei(n,a,s){const r=n.map(o=>o[a]).filter(o=>typeof o=="number");if(r.length===0)return s==="count"?"0":"";switch(s){case"sum":return r.reduce((o,p)=>o+p,0).toLocaleString();case"avg":return(r.reduce((o,p)=>o+p,0)/r.length).toLocaleString(void 0,{maximumFractionDigits:2});case"count":return String(n.length);case"min":return Math.min(...r).toLocaleString();case"max":return Math.max(...r).toLocaleString()}}function ln(n){return n.includes(",")||n.includes('"')||n.includes(`
|
|
2
|
+
`)?`"${n.replace(/"/g,'""')}"`:n}function ki(n){return typeof n=="boolean"?n?e.jsx("svg",{className:"nice-datagrid__bool-icon nice-datagrid__bool-icon--true",width:"16",height:"16",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-label":"true",role:"img",children:e.jsx("path",{d:"M4 10.5l4 4L16 6"})}):e.jsx("svg",{className:"nice-datagrid__bool-icon nice-datagrid__bool-icon--false",width:"16",height:"16",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-label":"false",role:"img",children:e.jsx("path",{d:"M5 5l10 10M15 5L5 15"})}):String(n??"")}function yn({columns:n,data:a,keyField:s="id",dataSource:r,sortable:o=!0,sortField:p,sortDirection:x,onSort:l,selectable:f,selectedKeys:S,onSelectionChange:D,pagination:V,pageSize:R=10,page:ae,onPageChange:X,totalRows:F,searchable:T,searchPlaceholder:w,virtualScroll:g,rowHeight:_=40,groupBy:y,groupRender:P,onCellEdit:$,editMode:ce="inline",formItems:ke,formColumns:z=2,editFormTitle:q,formProps:le,onRowEdit:ue,onRowAdd:be,onRowDelete:G,bulkActions:M,onBulkDelete:k,exportCsv:c,exportFilename:Ce="export",detailRow:ve,expandedRowKeys:se,onExpandedRowChange:j,columnReorder:ie,onColumnReorder:O,columnResize:fe,rowDraggable:Y,onRowReorder:Ee,striped:He,compact:Ke,loading:Ae,emptyText:qe,toolbar:Oe,onRowClick:Ue,pinnedTopKeys:Z,pinnedBottomKeys:we,colSpan:Xe,showStatusBar:N,contextMenuItems:ge,onContextMenuAction:H,printFriendly:L,keyboardNavigation:B,focusedCell:je,onFocusedCellChange:re,cellRangeSelection:Ie,selectedCellRange:J,onCellRangeChange:he,clipboard:Be,clipboardFormat:yt="text",onBeforeCopy:pt,onCopy:wt,onPaste:Tt,quickFilters:ot,activeQuickFilters:kt,onQuickFilterChange:jt,columnGroups:I,stateStorageKey:Q,initialState:pe,onStateChange:nt,flashRowKeys:ht,flashDuration:Se=500,autoFitColumns:Ge,showColumnStats:We,rowIndicator:dt,frozenRows:at,className:Nt,style:Gt,accessMode:Jt,id:qt,displayStyle:Zt}){const ut=De._s(Jt,qt),dn=ut==="hidden",en=ut==="readOnly"||ut==="disabled",{t:Te}=De.$o();De.cs("table",Zt),De.ls("table",Zt);const Qe=De.ql(r??null,{autoLoad:!!r,defaultPageSize:R}),Le=!!r,Vt=Le?Qe.data:a??[],d=Le?Qe.loading:Ae,[m,E]=t.useState({field:"",dir:null}),[K,ee]=t.useState(1),[A,W]=t.useState(new Set),[ne,de]=t.useState(""),[Re,Pe]=t.useState(R),[ye,Ye]=t.useState(null),[St,Ct]=t.useState(null),[Je,ft]=t.useState(null),[Mt,Ot]=t.useState(new Set),[Lt,Dt]=t.useState(0),tn=t.useRef(null),[Pt,It]=t.useState(new Set),At=se??Pt,[ct,un]=t.useState({}),[Rt,Ut]=t.useState(null),[Wt,nn]=t.useState(null),[jn,an]=t.useState(null),[Ft,mn]=t.useState(null),[Nn,wn]=t.useState([]),[En,hn]=t.useState(null),[kn,pn]=t.useState(new Set),[An,$n]=t.useState(null),sn=t.useRef(null),st=je??jn,mt=J??Ft,gt=kt??Nn;t.useEffect(()=>{if(!Q)return;const i=localStorage.getItem(`nice-datagrid-${Q}`);if(i&&!pe)try{const u=JSON.parse(i);u.columnWidths&&un(u.columnWidths),u.expandedGroups&&Ot(new Set(u.expandedGroups))}catch{}},[Q,pe]),t.useEffect(()=>{if(!ht?.size)return;pn(new Set(ht));const i=setTimeout(()=>pn(new Set),Se);return()=>clearTimeout(i)},[ht,Se]),t.useEffect(()=>{if(!Wt)return;const i=()=>nn(null);return document.addEventListener("click",i),()=>document.removeEventListener("click",i)},[Wt]);const Sn=t.useCallback((i,u)=>{ge?.length&&(i.preventDefault(),nn({x:i.clientX,y:i.clientY,row:u}))},[ge]),v=t.useCallback(i=>{const u=new Set(At);u.has(i)?u.delete(i):u.add(i),j?j(u):It(u)},[At,j]),me=t.useCallback((i,u)=>{if(!fe)return;u.preventDefault();const h=u.clientX,C=u.target.closest("th")?.offsetWidth??100,te=U=>{const Ne=Math.max(40,C+U.clientX-h);un(Ve=>({...Ve,[i]:Ne}))},oe=()=>{document.removeEventListener("mousemove",te),document.removeEventListener("mouseup",oe)};document.addEventListener("mousemove",te),document.addEventListener("mouseup",oe)},[fe]),_e=Le?Qe.sort[0]?.field??"":p??m.field,xe=Le?Qe.sort[0]?.direction??null:x??m.dir,rt=Le?Qe.page:ae??K,$e=S??A;t.useCallback(()=>{if(!Q)return;const i={columnWidths:ct,sortField:_e||void 0,sortDirection:xe,pageSize:Re,expandedGroups:Array.from(Mt)};localStorage.setItem(`nice-datagrid-${Q}`,JSON.stringify(i)),nt?.(i)},[Q,ct,_e,xe,Re,Mt,nt]);const Ze=t.useMemo(()=>n.filter(i=>!i.hidden),[n]),lt=t.useMemo(()=>Ze.filter(i=>i.pinned==="left"),[Ze]),rn=t.useMemo(()=>Ze.filter(i=>i.pinned==="right"),[Ze]),zn=t.useMemo(()=>Ze.filter(i=>!i.pinned),[Ze]),Fe=t.useMemo(()=>[...lt,...zn,...rn],[lt,zn,rn]),oi=t.useMemo(()=>Ze.some(i=>i.aggregate),[Ze]),cn=lt.length>0||rn.length>0,Tn=t.useCallback(i=>{const u=_e===i?xe==="asc"?"desc":xe==="desc"?null:"asc":"asc";Le?u?Qe.setSortField(i,u):Qe.setSort([]):l?l(i,u):E({field:i,dir:u})},[_e,xe,Le,Qe,l]),_t=t.useMemo(()=>{if(Le)return Vt;let i=[...Vt];if(ne){const u=ne.toLowerCase();i=i.filter(h=>Ze.some(b=>String(h[b.field]??"").toLowerCase().includes(u)))}return!l&&_e&&xe&&i.sort((u,h)=>{const b=u[_e]??"",C=h[_e]??"",te=typeof b=="number"?b-C:String(b).localeCompare(String(C));return xe==="desc"?-te:te}),i},[Vt,ne,Ze,_e,xe,l,Le]),fn=Le?Qe.totalCount:F??_t.length,Xt=Le?Qe.pageSize:Re,di=Math.max(1,Math.ceil(fn/Xt)),Et=Le?_t:V&&!F?_t.slice((rt-1)*Xt,rt*Xt):_t,Cn=t.useCallback(i=>{Le?Qe.setPage(i):X?X(i):ee(i)},[Le,Qe,X]),Ht=t.useMemo(()=>Et.map(i=>String(i[s])),[Et,s]),Qt=Ht.length>0&&Ht.every(i=>$e.has(i)),Ln=Ht.some(i=>$e.has(i)),Pn=t.useCallback(()=>{const i=new Set($e);Qt?Ht.forEach(u=>i.delete(u)):Ht.forEach(u=>i.add(u)),D?D(i):W(i)},[Qt,Ht,$e,D]),Fn=t.useCallback(i=>{const u=new Set($e);u.has(i)?u.delete(i):u.add(i),D?D(u):W(u)},[$e,D]),On=({field:i})=>_e!==i||!xe?e.jsx("span",{className:"nice-table__sort-icon",style:{opacity:.3},children:"?"}):e.jsx("span",{className:"nice-table__sort-icon",children:"?"}),xt=t.useMemo(()=>{if(!y)return Et.map((h,b)=>({type:"data",row:h,key:String(h[s]??b)}));const i=new Map;Et.forEach(h=>{const b=h[y];i.has(b)||i.set(b,[]),i.get(b).push(h)});const u=[];return i.forEach((h,b)=>{const C=`__group_${String(b)}`,te=Mt.has(C);u.push({type:"group",value:b,rows:h,expanded:te,key:C}),te&&h.forEach((oe,U)=>u.push({type:"data",row:oe,key:String(oe[s]??`${C}_${U}`)}))}),u},[Et,y,s,Mt]),{pinnedTopRows:ui,pinnedBottomRows:mi,normalRows:hi}=t.useMemo(()=>{if(!Z?.size&&!we?.size)return{pinnedTopRows:[],pinnedBottomRows:[],normalRows:xt};const i=[],u=[],h=[];for(const b of xt){if(b.type==="data"){const C=b.key;if(Z?.has(C)){i.push(b);continue}if(we?.has(C)){u.push(b);continue}}h.push(b)}return{pinnedTopRows:i,pinnedBottomRows:u,normalRows:h}},[xt,Z,we]),Un=t.useCallback(i=>{Ot(u=>{const h=new Set(u);return h.has(i)?h.delete(i):h.add(i),h})},[]),pi=t.useMemo(()=>{if(!g)return xt;const i=tn.current?.clientHeight??400,u=Math.ceil(i/_),h=Math.max(0,Math.floor(Lt/_)-3),b=Math.min(xt.length-1,h+u+6);return xt.slice(h,b+1).map((C,te)=>({...C,_vIdx:h+te}))},[g,xt,Lt,_]),gn=t.useCallback((i,u,h)=>{!$||en||(Ye({rowKey:i,field:u}),Ct(h))},[$]),Wn=t.useCallback(()=>{ye&&$&&$(ye.rowKey,ye.field,St),Ye(null),Ct(null)},[ye,St,$]),fi=t.useCallback(()=>{Ye(null),Ct(null)},[]),gi=t.useCallback(()=>{const i=Ze,u=i.map(U=>ln(U.header)).join(","),h=_t.map(U=>i.map(Ne=>ln(String(U[Ne.field]??""))).join(",")),b=[u,...h].join(`
|
|
3
|
+
`),C=new Blob(["\uFEFF"+b],{type:"text/csv;charset=utf-8;"}),te=URL.createObjectURL(C),oe=document.createElement("a");oe.href=te,oe.download=`${Ce}.csv`,oe.click(),URL.revokeObjectURL(te)},[Ze,_t,Ce]),_n=t.useCallback(i=>{re?re(i):an(i)},[re]),xn=t.useCallback(i=>{he?he(i):mn(i)},[he]),bt=t.useMemo(()=>xt.filter(i=>i.type==="data").map(i=>i.key),[xt]),_i=t.useCallback(i=>{if(!B||ye||!st)return;const u=bt.indexOf(st.rowKey),h=Fe.findIndex(oe=>oe.field===st.field);if(u<0||h<0)return;let b=u,C=h;switch(i.key){case"ArrowUp":b=Math.max(0,u-1);break;case"ArrowDown":b=Math.min(bt.length-1,u+1);break;case"ArrowLeft":C=Math.max(0,h-1);break;case"ArrowRight":C=Math.min(Fe.length-1,h+1);break;case"Tab":i.preventDefault(),i.shiftKey?C=Math.max(0,h-1):C=Math.min(Fe.length-1,h+1);break;case"Enter":{const oe=Fe[h];if(oe.editable&&$){const U=Et.find(Ne=>String(Ne[s])===st.rowKey);U&&gn(st.rowKey,oe.field,U[oe.field])}return}case"Escape":_n(null),xn(null);return;case"Home":i.ctrlKey&&(b=0),C=0;break;case"End":i.ctrlKey&&(b=bt.length-1),C=Fe.length-1;break;case"PageUp":b=Math.max(0,u-Re);break;case"PageDown":b=Math.min(bt.length-1,u+Re);break;default:return}i.preventDefault();const te={rowKey:bt[b],field:Fe[C].field};if(_n(te),i.shiftKey&&Ie){const oe=mt?.start??st;xn({start:oe,end:te})}else xn(null)},[B,ye,st,bt,Fe,Ie,mt,_n,xn,$,Et,s,gn,Re]),Bn=t.useCallback(()=>{let i=[],u=[];if(mt){const h=bt.indexOf(mt.start.rowKey),b=bt.indexOf(mt.end.rowKey),C=Math.min(h,b),te=Math.max(h,b),oe=Fe.findIndex(et=>et.field===mt.start.field),U=Fe.findIndex(et=>et.field===mt.end.field),Ne=Math.min(oe,U),Ve=Math.max(oe,U);u=Fe.slice(Ne,Ve+1).map(et=>et.field),i=Et.filter(et=>{const Bt=bt.indexOf(String(et[s]));return Bt>=C&&Bt<=te})}else $e.size>0&&(i=Et.filter(h=>$e.has(String(h[s]))),u=Fe.map(h=>h.field));return{rows:i,fields:u}},[mt,bt,Fe,Et,s,$e]),Gn=t.useCallback((i,u,h)=>{const b=Fe.filter(C=>u.includes(C.field));switch(h){case"json":return JSON.stringify(i.map(C=>Object.fromEntries(u.map(te=>[te,C[te]]))),null,2);case"csv":{const C=b.map(oe=>ln(oe.header)).join(","),te=i.map(oe=>b.map(U=>ln(String(oe[U.field]??""))).join(",")).join(`
|
|
4
|
+
`);return C+`
|
|
5
|
+
`+te}case"html":{const C=b.map(oe=>`<th>${oe.header}</th>`).join(""),te=i.map(oe=>`<tr>${b.map(U=>`<td>${oe[U.field]??""}</td>`).join("")}</tr>`).join("");return`<table><thead><tr>${C}</tr></thead><tbody>${te}</tbody></table>`}case"markdown":{const C="| "+b.map(U=>U.header).join(" | ")+" |",te="| "+b.map(()=>"---").join(" | ")+" |",oe=i.map(U=>"| "+b.map(Ne=>U[Ne.field]??"").join(" | ")+" |").join(`
|
|
6
|
+
`);return C+`
|
|
7
|
+
`+te+`
|
|
8
|
+
`+oe}default:return i.map(C=>b.map(te=>C[te.field]??"").join(" ")).join(`
|
|
9
|
+
`)}},[Fe]),Mn=t.useCallback(async()=>{if(!Be)return;const{rows:i,fields:u}=Bn();if(!i.length||pt?.(i,u)===!1)return;const h=Gn(i,u,yt);await navigator.clipboard.writeText(h),wt?.(i,u,yt)},[Be,Bn,pt,Gn,yt,wt]),Vn=t.useCallback(async()=>{if(!Be||!st||!Tt)return;const u=(await navigator.clipboard.readText()).split(`
|
|
10
|
+
`).map(h=>h.split(" "));Tt(u,st)},[Be,st,Tt]);t.useEffect(()=>{if(!Be||!sn.current)return;const i=u=>{sn.current?.contains(document.activeElement)&&(u.type==="copy"&&(u.preventDefault(),Mn()),u.type==="paste"&&(u.preventDefault(),Vn()))};return document.addEventListener("copy",i),document.addEventListener("paste",i),()=>{document.removeEventListener("copy",i),document.removeEventListener("paste",i)}},[Be,Mn,Vn]);const xi=t.useCallback(i=>{const u=gt.includes(i)?gt.filter(h=>h!==i):[...gt,i];jt?jt(u):wn(u)},[gt,jt]),bi=t.useMemo(()=>{if(!ot?.length||!gt.length)return _t;const i=ot.filter(u=>gt.includes(u.key));return _t.filter(u=>i.every(h=>h.filter(u)))},[_t,ot,gt]),Kn=ot?.length?bi:_t;t.useCallback(i=>{const u=_t.map(Ne=>Ne[i]).filter(Ne=>Ne!=null),h=u.filter(Ne=>typeof Ne=="number");if(h.length===0){const Ne=new Set(u).size;return{count:u.length,unique:Ne,type:"text"}}const b=h.reduce((Ne,Ve)=>Ne+Ve,0),C=b/h.length,te=Math.min(...h),oe=Math.max(...h),U=Math.sqrt(h.reduce((Ne,Ve)=>Ne+(Ve-C)**2,0)/h.length);return{count:h.length,sum:b,avg:C,min:te,max:oe,stdDev:U,type:"numeric"}},[_t]);const vi=t.useCallback((i,u,h)=>{if(!i.cellVisualization)return null;const b=Number(u);if(isNaN(b))return null;const C=i.visualMin??0,te=i.visualMax??100,oe=Math.max(0,Math.min(100,(b-C)/(te-C)*100));switch(i.cellVisualization){case"progress":return e.jsxs("div",{className:"nice-datagrid__cell-progress",style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("div",{style:{flex:1,height:6,background:"var(--border-color)",borderRadius:3,overflow:"hidden"},children:e.jsx("div",{style:{width:`${oe}%`,height:"100%",background:oe>80?"var(--color-success)":oe>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(oe),"%"]})]});case"rating":{const U=Math.round(b/te*5);return e.jsx("div",{className:"nice-datagrid__cell-rating",children:[1,2,3,4,5].map(Ne=>e.jsx("span",{style:{color:Ne<=U?"var(--color-warning)":"var(--text-muted)",fontSize:"0.85rem"},children:"?"},Ne))})}case"trend":{const U=i.visualMin??b,Ne=b-U,Ve=(Ne>0||Ne<0,"?"),et=Ne>0?"var(--color-success)":Ne<0?"var(--color-danger)":"var(--text-muted)";return e.jsxs("span",{style:{color:et,fontWeight:500},children:[Ve," ",Math.abs(Ne).toFixed(1),"%"]})}case"heatmap":{const U=oe/100,Ne=`rgba(${Math.round(255*U)}, ${Math.round(100*(1-U))}, ${Math.round(50*(1-U))}, 0.6)`;return e.jsx("span",{style:{background:Ne,padding:"2px 8px",borderRadius:4},children:b})}default:return null}},[]),yi=t.useCallback((i,u,h)=>{if(!i.conditionalFormats?.length)return{};for(const b of i.conditionalFormats)if(b.when(u,h,i.field))return{className:b.className,style:{...b.style,backgroundColor:b.backgroundColor,color:b.color}};return{}},[]),Dn=t.useCallback((i,u)=>{if(!cn||!i.pinned)return{};const h={position:"sticky",zIndex:2,background:"var(--bg-primary, #fff)"};if(i.pinned==="left"){let b=0;for(let C=0;C<u;C++){const te=Fe[C];te.pinned==="left"&&(b+=typeof te.width=="number"?te.width:parseInt(String(te.width)||"100",10))}f&&u===0&&(b=36),h.left=b}else{let b=0;for(let C=Fe.length-1;C>u;C--){const te=Fe[C];te.pinned==="right"&&(b+=typeof te.width=="number"?te.width:parseInt(String(te.width)||"100",10))}h.right=b}return h},[cn,Fe,f]),qn=(i,u,h,b)=>{if(ye?.rowKey===h&&ye?.field===i.field)return i.editor?i.editor(St,u,U=>Ct(U)):e.jsx("input",{className:"nice-datagrid__edit-input",autoFocus:!0,value:St??"",onChange:U=>Ct(U.target.value),onBlur:Wn,onKeyDown:U=>{U.key==="Enter"&&Wn(),U.key==="Escape"&&fi()}});const te=vi(i,u[i.field],u);return te||(i.render?i.render(u[i.field],u,b):ki(u[i.field]))},ji=(i,u,h,b)=>{const C=st?.rowKey===h&&st?.field===i.field,te=mt&&(()=>{const Ne=bt.indexOf(mt.start.rowKey),Ve=bt.indexOf(mt.end.rowKey),et=bt.indexOf(h),Bt=Fe.findIndex(Yt=>Yt.field===mt.start.field),Kt=Fe.findIndex(Yt=>Yt.field===mt.end.field);return et>=Math.min(Ne,Ve)&&et<=Math.max(Ne,Ve)&&b>=Math.min(Bt,Kt)&&b<=Math.max(Bt,Kt)})(),oe=yi(i,u[i.field],u);return{className:[oe.className,C&&"nice-datagrid__cell--focused",te&&"nice-datagrid__cell--in-range"].filter(Boolean).join(" "),style:{...Dn(i,b),textAlign:i.align,...oe.style,...C?{outline:"2px solid var(--color-primary)",outlineOffset:-2}:{},...te?{background:"var(--color-primary-light, rgba(59,130,246,0.15))"}:{}}}},bn=Fe.length+(f?1:0)+(ve?1:0)+(Y?1:0)+(dt?1:0),In=(i,u,h)=>{const{row:b,key:C}=i,te=$e.has(C),oe=At.has(C),U=kn.has(C),Ne=[te&&"nice-datagrid__row--selected",Rt===u&&"nice-datagrid__row--dragging",h&&"nice-datagrid__row--pinned",U&&"nice-datagrid__row--flash"].filter(Boolean).join(" ");return e.jsxs(t.Fragment,{children:[e.jsxs("tr",{className:Ne,onClick:()=>Ue?.(b),onDoubleClick:ce==="popup"&&(ue||$)?()=>ft({key:C,data:{...b}}):void 0,onContextMenu:Ve=>Sn(Ve,b),style:Ue||ce==="popup"?{cursor:"pointer"}:void 0,draggable:Y,onDragStart:Y?()=>Ut(u):void 0,onDragOver:Y?Ve=>Ve.preventDefault():void 0,onDrop:Y&&Ee&&Rt!=null?()=>{Ee(Rt,u),Ut(null)}:void 0,onDragEnd:Y?()=>Ut(null):void 0,children:[dt&&e.jsx("td",{className:"nice-datagrid__row-indicator",style:{width:32,padding:"0 4px"},children:dt(b)}),ve&&e.jsx("td",{className:"nice-datagrid__expand-col",onClick:Ve=>{Ve.stopPropagation(),v(C)},children:e.jsx("span",{className:"nice-datagrid__expand-btn",children:"?"})}),Y&&e.jsx("td",{className:"nice-datagrid__drag-handle",style:{cursor:"grab",textAlign:"center",color:"var(--text-muted)"},children:"?"}),f&&e.jsx("td",{className:"nice-datagrid__checkbox",onClick:Ve=>Ve.stopPropagation(),style:cn?{position:"sticky",left:0,zIndex:1,background:"var(--bg-primary, #fff)"}:void 0,children:e.jsx("input",{type:"checkbox",checked:te,onChange:()=>Fn(C),"aria-label":`Select row ${C}`})}),(()=>{let Ve=0;return Fe.map((et,Bt)=>{if(Ve>0)return Ve--,null;const Kt=Xe?Xe(b,et,Bt):void 0;Kt&&Kt>1&&(Ve=Kt-1);const Yt=ji(et,b,C,Bt);return e.jsx("td",{colSpan:Kt,className:Yt.className,style:Yt.style,onClick:B?()=>_n({rowKey:C,field:et.field}):void 0,onDoubleClick:et.editable&&$?()=>gn(C,et.field,b[et.field]):void 0,children:qn(et,b,C,u)},et.field)})})()]}),ve&&oe&&e.jsx("tr",{className:"nice-datagrid__detail-row",children:e.jsx("td",{colSpan:bn,children:ve(b)})})]},C)};return dn?null:e.jsxs("div",{ref:sn,className:`nice-datagrid ${L?"nice-datagrid--print":""} ${Nt||""}`,style:Gt,role:"grid","aria-label":Te("datagrid.title","Data Grid"),"aria-rowcount":xt.length,"aria-colcount":Ze.length,"aria-busy":d||void 0,tabIndex:B?0:void 0,onKeyDown:B?_i:void 0,children:[(T||Oe||c||ot?.length||be)&&e.jsxs("div",{className:"nice-datagrid__toolbar",children:[T&&e.jsx("div",{className:"nice-datagrid__search",children:e.jsx("input",{type:"text",value:Le?Qe.search:ne,"aria-label":Te("controls.search","Search"),onChange:i=>{Le?Qe.setSearch(i.target.value):(de(i.target.value),Cn(1))},placeholder:w||Te("controls.search","Search...")})}),ot&&ot.length>0&&e.jsx("div",{className:"nice-datagrid__quick-filters",style:{display:"flex",gap:6,flexWrap:"wrap"},children:ot.map(i=>e.jsxs("button",{className:`nice-datagrid__quick-filter ${gt.includes(i.key)?"nice-datagrid__quick-filter--active":""}`,onClick:()=>xi(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:gt.includes(i.key)?`var(--color-${i.color||"primary"})`:"var(--bg-primary)",color:gt.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))}),Be&&e.jsx("button",{className:"nice-btn nice-btn--sm nice-btn--ghost",onClick:Mn,title:Te("controls.copy","Copy selected"),style:{marginLeft:4},children:"??"}),c&&e.jsx("button",{className:"nice-btn nice-btn--sm",onClick:gi,title:Te("controls.exportCsv","Export CSV"),children:"CSV ?"}),be&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--sm nice-btn--primary",onClick:()=>ft({key:null,data:{}}),title:Te("datagrid.addRow","Add row"),children:["+ ",Te("datagrid.add","Add")]}),Oe]}),f&&$e.size>0&&(M?.length||k)&&e.jsxs("div",{className:"nice-datagrid__bulk-toolbar",role:"toolbar","aria-label":Te("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:Te("datagrid.selectedCount","{count} selected").replace("{count}",String($e.size))}),(M||[]).map(i=>{const u=Array.from($e),h=Kn.filter(C=>$e.has(String(C[s]))),b=i.disabled?.(u,h)||!1;return e.jsxs("button",{type:"button",className:`nice-btn nice-btn--sm nice-btn--${i.variant||"secondary"}`,disabled:b,onClick:()=>i.onClick(u,h),children:[i.icon,i.icon&&" ",i.label]},i.key)}),k&&!M?.length&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--sm nice-btn--danger",onClick:()=>{const i=Array.from($e),u=Kn.filter(h=>$e.has(String(h[s])));k(i,u)},children:["?? ",Te("datagrid.deleteSelected","Delete selected")]}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--xs nice-btn--ghost",onClick:()=>{const i=new Set;S===void 0&&W(i),D?.(i)},style:{marginLeft:"auto"},children:Te("datagrid.clearSelection","Clear")})]}),e.jsxs("div",{ref:tn,className:`nice-datagrid__table-wrap ${g?"nice-datagrid__table-wrap--virtual":""}`,style:g?{maxHeight:Math.min(xt.length*_,600),overflowY:"auto"}:void 0,onScroll:g?i=>Dt(i.currentTarget.scrollTop):void 0,children:[g&&e.jsxs("div",{style:{height:xt.length*_,position:"relative"},children:[e.jsx("table",{className:`${He?"nice-table--striped":""} ${Ke?"nice-table--compact":""}`,style:{position:"sticky",top:0,zIndex:3},children:e.jsx("thead",{children:e.jsxs("tr",{children:[ve&&e.jsx("th",{className:"nice-datagrid__expand-col",style:{width:36}}),Y&&e.jsx("th",{style:{width:28}}),f&&e.jsx("th",{className:"nice-datagrid__checkbox",style:cn?{position:"sticky",left:0,zIndex:3,background:"var(--bg-primary, #fff)"}:void 0,children:e.jsx("input",{type:"checkbox",checked:Qt,ref:i=>{i&&(i.indeterminate=Ln&&!Qt)},onChange:Pn,"aria-label":Te("controls.selectAll","Select all")})}),Fe.map((i,u)=>e.jsxs("th",{style:{width:ct[i.field]||i.width,minWidth:i.minWidth,textAlign:i.align,position:"relative",...Dn(i,u)},className:o&&i.sortable!==!1?"nice-datagrid__th--sortable":void 0,onClick:()=>o&&i.sortable!==!1&&Tn(i.field),children:[i.header,o&&i.sortable!==!1&&e.jsx(On,{field:i.field}),fe&&e.jsx("span",{className:"nice-datagrid__resize-handle",onMouseDown:h=>{h.stopPropagation(),me(i.field,h)}})]},i.field))]})})}),pi.map((i,u)=>{const h=i._vIdx??0;if(i.type==="group"){const U=i;return e.jsxs("div",{className:"nice-datagrid__group-row",style:{position:"absolute",top:h*_,height:_,left:0,right:0},onClick:()=>Un(U.key),children:[e.jsx("span",{className:"nice-datagrid__group-toggle",children:(U.expanded,"?")}),P?P(U.value,U.rows):e.jsxs(e.Fragment,{children:[String(U.value)," (",U.rows.length,")"]})]},U.key)}const{row:b,key:C}=i,te=$e.has(C),oe=At.has(C);return e.jsxs(t.Fragment,{children:[e.jsxs("div",{className:`nice-datagrid__vrow ${te?"nice-datagrid__row--selected":""} ${Rt===u?"nice-datagrid__row--dragging":""}`,style:{position:"absolute",top:h*_,height:_,left:0,right:0,display:"flex",alignItems:"center"},onClick:()=>Ue?.(b),onDoubleClick:ce==="popup"&&(ue||$)?()=>ft({key:C,data:{...b}}):void 0,draggable:Y,onDragStart:Y?()=>Ut(u):void 0,onDragOver:Y?U=>U.preventDefault():void 0,onDrop:Y&&Ee&&Rt!=null?()=>{Ee(Rt,u),Ut(null)}:void 0,onDragEnd:Y?()=>Ut(null):void 0,children:[ve&&e.jsx("div",{className:"nice-datagrid__expand-col",style:{width:36,flexShrink:0,textAlign:"center",cursor:"pointer"},onClick:U=>{U.stopPropagation(),v(C)},children:e.jsx("span",{className:"nice-datagrid__expand-btn",children:"?"})}),Y&&e.jsx("div",{style:{width:28,flexShrink:0,cursor:"grab",textAlign:"center",color:"var(--text-muted)"},children:"?"}),f&&e.jsx("div",{className:"nice-datagrid__checkbox",style:{width:36,flexShrink:0},onClick:U=>U.stopPropagation(),children:e.jsx("input",{type:"checkbox",checked:te,onChange:()=>Fn(C)})}),Fe.map(U=>e.jsx("div",{className:"nice-datagrid__vcell",style:{width:ct[U.field]||U.width||"auto",flex:ct[U.field]||U.width?`0 0 ${typeof(ct[U.field]||U.width)=="number"?(ct[U.field]||U.width)+"px":ct[U.field]||U.width}`:1,textAlign:U.align,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",padding:"0 8px"},onDoubleClick:U.editable&&$?()=>gn(C,U.field,b[U.field]):void 0,children:qn(U,b,C,h)},U.field))]}),ve&&oe&&e.jsx("div",{className:"nice-datagrid__detail-row",style:{position:"absolute",top:(h+1)*_,left:0,right:0,padding:"8px 12px",background:"var(--bg-secondary, #f8f8f8)"},children:ve(b)})]},C)})]}),!g&&e.jsxs("table",{className:`${He?"nice-table--striped":""} ${Ke?"nice-table--compact":""}`,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[ve&&e.jsx("th",{className:"nice-datagrid__expand-col",style:{width:36}}),Y&&e.jsx("th",{style:{width:28}}),f&&e.jsx("th",{className:"nice-datagrid__checkbox",style:cn?{position:"sticky",left:0,zIndex:3,background:"var(--bg-primary, #fff)"}:void 0,children:e.jsx("input",{type:"checkbox",checked:Qt,ref:i=>{i&&(i.indeterminate=Ln&&!Qt)},onChange:Pn,"aria-label":Te("controls.selectAll","Select all")})}),Fe.map((i,u)=>{const h=o&&i.sortable!==!1,b=h?_e===i.field?xe==="asc"?"ascending":xe==="desc"?"descending":"none":"none":void 0;return e.jsxs("th",{style:{width:ct[i.field]||i.width,minWidth:i.minWidth,textAlign:i.align,position:"relative",...Dn(i,u)},className:h?"nice-datagrid__th--sortable":void 0,onClick:()=>h&&Tn(i.field),"aria-sort":b,scope:"col",children:[i.header,h&&e.jsx(On,{field:i.field}),fe&&e.jsx("span",{className:"nice-datagrid__resize-handle",onMouseDown:C=>{C.stopPropagation(),me(i.field,C)}})]},i.field)})]})}),e.jsx("tbody",{children:d?e.jsx("tr",{children:e.jsx("td",{colSpan:bn,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:bn,className:"nice-datagrid__empty",children:qe||Te("controls.noData","No data available")})}):e.jsxs(e.Fragment,{children:[ui.map((i,u)=>i.type==="data"&&In(i,u,"top")),hi.map((i,u)=>{if(i.type==="group"){const h=i;return e.jsx("tr",{className:"nice-datagrid__group-row",onClick:()=>Un(h.key),children:e.jsxs("td",{colSpan:bn,className:"nice-datagrid__group-cell",children:[e.jsx("span",{className:"nice-datagrid__group-toggle",children:(h.expanded,"?")}),P?P(h.value,h.rows):e.jsxs(e.Fragment,{children:[String(h.value)," (",h.rows.length,")"]})]})},h.key)}return In(i,u)}),mi.map((i,u)=>i.type==="data"&&In(i,u,"bottom"))]})}),oi&&!d&&Et.length>0&&e.jsx("tfoot",{children:e.jsxs("tr",{className:"nice-datagrid__aggregate-row",children:[f&&e.jsx("td",{}),Fe.map(i=>e.jsx("td",{style:{textAlign:i.align,fontWeight:600},children:i.aggregate?(i.aggregateLabel||i.aggregate.toUpperCase())+": "+ei(_t,i.field,i.aggregate):""},i.field))]})})]})]}),V&&e.jsxs("div",{className:"nice-datagrid__footer",children:[e.jsxs("span",{className:"nice-datagrid__footer-info",children:[Te("controls.showing","Showing")," ",(rt-1)*Xt+1,"�",Math.min(rt*Xt,fn)," ",Te("controls.of","of")," ",fn]}),e.jsx(Ni.NicePagination,{page:rt,totalPages:di,onChange:Cn,showInfo:!0,pageSize:Xt,showPageSize:!0,pageSizeOptions:[5,10,25,50,100],onPageSizeChange:i=>{Le?Qe.setPageSize(i):(Pe(i),Cn(1))},showFirstLast:!0})]}),N&&!d&&e.jsxs("div",{className:"nice-datagrid__status-bar",children:[e.jsxs("span",{children:[Te("controls.totalRows","Total rows"),": ",fn]}),f&&$e.size>0&&e.jsxs("span",{children:[Te("controls.selected","Selected"),": ",$e.size]})]}),Wt&&ge&&e.jsx("div",{className:"nice-datagrid__context-menu",style:{position:"fixed",left:Wt.x,top:Wt.y,zIndex:9999},onClick:i=>i.stopPropagation(),children:ge.map(i=>e.jsxs("button",{className:"nice-datagrid__context-item",disabled:i.disabled,onClick:()=>{H?.(i.key,Wt.row),nn(null)},children:[i.icon&&e.jsx("span",{className:"nice-datagrid__context-icon",children:i.icon}),i.label]},i.key))}),(ce==="popup"||be)&&Je&&(()=>{const i=Je.key===null,u=ke??n.filter(h=>!h.hidden&&h.field!==s).map(h=>{let b="text";return h.dataType==="number"||h.dataType==="currency"||h.dataType==="percent"?b="number":h.dataType==="boolean"?b="checkbox":h.dataType==="date"&&(b="date"),{field:h.field,label:h.header,type:b,required:h.validation?.required}});return e.jsx(Jn.NiceModal,{open:!0,onClose:()=>ft(null),title:q??(i?Te("datagrid.addRow","Add row"):Te("datagrid.editRow","Edit row")),size:"lg",children:e.jsx(Yn.NiceForm,{items:u,data:Je.data,columns:z,showActions:!0,submitLabel:i?Te("controls.add","Add"):Te("controls.save","Save"),cancelLabel:Te("controls.cancel","Cancel"),onCancel:()=>ft(null),...le,onFieldChange:(h,b)=>ft(C=>C&&{...C,data:{...C.data,[h]:b}}),onSubmit:h=>{i?be?.(h):Je.key&&(ue?ue(Je.key,h):$&&Object.keys(h).forEach(b=>{$(Je.key,b,h[b])})),ft(null)}})})})()]})}yn.displayName="NiceDataGrid";const Si=Object.freeze(Object.defineProperty({__proto__:null,NiceDataGrid:yn},Symbol.toStringTag,{value:"Module"}));function Ci(n,a){return n.filter(s=>a.every(r=>{const o=s[r.field],p=r.value;switch(r.operator){case"eq":return o===p;case"ne":return o!==p;case"gt":return typeof o=="number"&&typeof p=="number"&&o>p;case"gte":return typeof o=="number"&&typeof p=="number"&&o>=p;case"lt":return typeof o=="number"&&typeof p=="number"&&o<p;case"lte":return typeof o=="number"&&typeof p=="number"&&o<=p;case"contains":return String(o).toLowerCase().includes(String(p).toLowerCase());case"startsWith":return String(o).toLowerCase().startsWith(String(p).toLowerCase());case"endsWith":return String(o).toLowerCase().endsWith(String(p).toLowerCase());default:return!0}}))}function Mi(n){return n.map(a=>({field:a.field,type:a.dataType||"string",label:typeof a.header=="string"?a.header:a.field}))}function Di(n,a){const{enableAI:s=!0,aiModel:r,enableNLSearch:o=!0,enableInsights:p=!0,nlPlaceholder:x,onAIFilter:l,onInsights:f,showAISearchBar:S=!0,exampleQueries:D=["Show items from last week","Filter by status = active","Orders over $1000",'Names starting with "A"'],columns:V,data:R,...ae}=n,[X,F]=t.useState(""),[T,w]=t.useState([]),[g,_]=t.useState([]),[y,P]=t.useState(!1),[$,ce]=t.useState(null),ke=t.useRef(null),{t:z}=De.$o(),q=De.ie(),{parseFilter:le,isLoading:ue}=De.Ml(),be=s&&q.isConfigured,G=T.length>0?Ci(R||[],T):R,M=t.useCallback(async j=>{if(!be||!o||!j.trim())return;ce(j);const ie=Mi(V);try{const O=await le(j,ie);w(O),l?.(j,O)}catch{w([])}},[be,o,V,le,l]),k=t.useCallback(()=>{w([]),ce(null),F("")},[]),c=t.useCallback(()=>T,[T]),Ce=t.useCallback(async()=>{if(!be||!p||!R?.length)return[];try{const j=await q.complete([{role:"user",content:`Analyze this data and provide 3-5 key insights. Data sample (${R.length} total rows): ${JSON.stringify(R.slice(0,20))}
|
|
11
|
+
|
|
12
|
+
Columns: ${V.map(ie=>ie.field).join(", ")}
|
|
13
|
+
|
|
14
|
+
Return a JSON array of insight strings. Be specific with numbers and trends.`}],{temperature:.3,maxTokens:500});try{const ie=JSON.parse(j.content),O=Array.isArray(ie)?ie:[];return _(O),f?.(O),O}catch{return[]}}catch{return[]}},[be,p,R,V,q,f]),ve=j=>{j.preventDefault(),X.trim()&&M(X)},se=j=>{F(j),M(j)};return t.useImperativeHandle(a,()=>({applyNLFilter:M,clearAIFilters:k,getAIFilters:c,generateInsights:Ce})),e.jsxs("div",{className:"nice-data-grid-ai","data-testid":n["data-testid"],children:[S&&be&&o&&e.jsxs("div",{className:"nice-data-grid-ai__search-bar",children:[e.jsx("div",{className:"nice-data-grid-ai__search-left",children:e.jsx("span",{className:"nice-data-grid-ai__badge",children:"AI"})}),e.jsxs("form",{onSubmit:ve,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:ke,type:"text",value:X,onChange:j=>F(j.target.value),placeholder:x||z("dataGridAI.searchPlaceholder","Search with natural language..."),className:"nice-data-grid-ai__input",disabled:ue}),ue&&e.jsx("span",{className:"nice-data-grid-ai__loading-spinner"}),X&&!ue&&e.jsx("button",{type:"button",className:"nice-data-grid-ai__clear-input",onClick:()=>F(""),children:"✕"})]}),e.jsx("button",{type:"submit",className:"nice-data-grid-ai__search-btn",disabled:ue||!X.trim(),children:ue?z("dataGridAI.searching","Searching..."):z("dataGridAI.search","Search")})]}),p&&e.jsxs("button",{type:"button",className:"nice-data-grid-ai__insights-btn",onClick:()=>{Ce(),P(!0)},disabled:ue||!R?.length,title:z("dataGridAI.generateInsights","Generate AI Insights"),children:["💡 ",z("dataGridAI.insights","Insights")]})]}),S&&be&&o&&!$&&D.length>0&&e.jsxs("div",{className:"nice-data-grid-ai__examples",children:[e.jsx("span",{className:"nice-data-grid-ai__examples-label",children:z("dataGridAI.tryAsking","Try asking:")}),e.jsx("div",{className:"nice-data-grid-ai__examples-list",children:D.slice(0,4).map((j,ie)=>e.jsxs("button",{type:"button",className:"nice-data-grid-ai__example",onClick:()=>se(j),children:['"',j,'"']},ie))})]}),$&&T.length>0&&e.jsxs("div",{className:"nice-data-grid-ai__active-filter",children:[e.jsxs("div",{className:"nice-data-grid-ai__filter-info",children:[e.jsx("span",{className:"nice-data-grid-ai__filter-icon",children:"🎯"}),e.jsxs("span",{className:"nice-data-grid-ai__filter-query",children:['"',$,'"']}),e.jsxs("span",{className:"nice-data-grid-ai__filter-count",children:["(",G?.length||0," ",z("dataGridAI.results","results"),")"]})]}),e.jsx("div",{className:"nice-data-grid-ai__filter-badges",children:T.map((j,ie)=>e.jsxs("span",{className:"nice-data-grid-ai__filter-badge",children:[j.field," ",j.operator," ",String(j.value)]},ie))}),e.jsxs("button",{type:"button",className:"nice-data-grid-ai__clear-filter",onClick:k,children:["✕ ",z("dataGridAI.clearFilter","Clear")]})]}),e.jsx("div",{className:"nice-data-grid-ai__grid-wrapper",children:e.jsx(yn,{columns:V,data:G,...ae})}),y&&e.jsxs("div",{className:"nice-data-grid-ai__insights-panel",children:[e.jsxs("div",{className:"nice-data-grid-ai__insights-header",children:[e.jsxs("h4",{children:["💡 ",z("dataGridAI.aiInsights","AI Insights")]}),e.jsx("button",{type:"button",className:"nice-data-grid-ai__insights-close",onClick:()=>P(!1),children:"✕"})]}),e.jsx("div",{className:"nice-data-grid-ai__insights-body",children:ue?e.jsx("div",{className:"nice-data-grid-ai__insights-loading",children:z("dataGridAI.analyzing","Analyzing data...")}):g.length>0?e.jsx("ul",{className:"nice-data-grid-ai__insights-list",children:g.map((j,ie)=>e.jsxs("li",{className:"nice-data-grid-ai__insight",children:[e.jsx("span",{className:"nice-data-grid-ai__insight-bullet",children:"•"}),j]},ie))}):e.jsx("div",{className:"nice-data-grid-ai__insights-empty",children:z("dataGridAI.noInsights","Click to generate insights from your data")})}),e.jsx("div",{className:"nice-data-grid-ai__insights-footer",children:e.jsxs("button",{type:"button",className:"nice-data-grid-ai__refresh-insights",onClick:()=>Ce(),disabled:ue,children:["🔄 ",z("dataGridAI.refresh","Refresh")]})})]})]})}const Ii=t.forwardRef(Di),Ri=({items:n,selectedKeys:a=[],onSelectionChange:s,selectionMode:r="none",searchable:o,searchPlaceholder:p,grouped:x,groupField:l="group",reorderable:f,onReorder:S,onItemClick:D,renderItem:V,showCheckboxes:R,loading:ae,emptyText:X,size:F="md",bordered:T=!0,swipeActions:w,className:g,style:_,accessMode:y,id:P})=>{const ce=De._s(y,P)==="hidden",{t:ke}=De.$o(),[z,q]=t.useState(""),[le,ue]=t.useState(null),[be,G]=t.useState(null),M=t.useRef(null),k=t.useMemo(()=>{if(!z)return n;const j=z.toLowerCase();return n.filter(ie=>ie.text.toLowerCase().includes(j))},[n,z]),c=t.useMemo(()=>{if(!x)return null;const j=new Map;return k.forEach(ie=>{const O=String(ie[l]??"");j.has(O)||j.set(O,[]),j.get(O).push(ie)}),j},[k,x,l]),Ce=t.useCallback(j=>{s&&(r==="single"?s(a.includes(j)?[]:[j]):r==="multiple"&&s(a.includes(j)?a.filter(ie=>ie!==j):[...a,j]))},[a,r,s]),ve=t.useCallback(j=>{le!==null&&le!==j&&S&&S(le,j),ue(null)},[le,S]),se=(j,ie)=>{const O=a.includes(j.key),fe=be===j.key;return e.jsxs("li",{className:`nice-list__item ${O?"nice-list__item--selected":""} ${j.disabled?"nice-list__item--disabled":""} ${fe?"nice-list__item--swiped":""}`,onClick:()=>{j.disabled||(Ce(j.key),D?.(j))},draggable:f,onDragStart:()=>ue(ie),onDragOver:Y=>Y.preventDefault(),onDrop:()=>ve(ie),onTouchStart:w?.length?Y=>{M.current={x:Y.touches[0].clientX,key:j.key}}:void 0,onTouchEnd:w?.length?Y=>{if(!M.current)return;const Ee=Y.changedTouches[0].clientX-M.current.x;Ee<-50&&M.current.key===j.key?G(j.key):Ee>50&&G(null),M.current=null}:void 0,role:r!=="none"?"option":void 0,"aria-selected":r!=="none"?O:void 0,children:[e.jsxs("div",{className:"nice-list__item-content",children:[R&&r!=="none"&&e.jsx("input",{type:"checkbox",checked:O,readOnly:!0,tabIndex:-1,className:"nice-list__checkbox"}),V?V(j):e.jsxs(e.Fragment,{children:[j.icon&&e.jsx("span",{className:"nice-list__icon",children:j.icon}),e.jsx("span",{className:"nice-list__text",children:j.text}),j.badge&&e.jsx("span",{className:"nice-list__badge",children:j.badge})]})]}),w&&fe&&e.jsx("div",{className:"nice-list__swipe-actions",children:w.map(Y=>e.jsx("button",{className:"nice-list__swipe-btn",style:Y.color?{backgroundColor:Y.color}:void 0,onClick:Ee=>{Ee.stopPropagation(),Y.onClick(j),G(null)},children:Y.label},Y.key))})]},j.key)};return ce?null:e.jsxs("div",{className:`nice-list nice-list--${F} ${T?"nice-list--bordered":""} ${g||""}`,style:_,children:[o&&e.jsx("div",{className:"nice-list__search",children:e.jsx("input",{type:"text",value:z,onChange:j=>q(j.target.value),placeholder:p||ke("controls.search","Search...")})}),ae?e.jsx("div",{className:"nice-list__loading",children:e.jsx("div",{className:"nice-spinner nice-spinner--sm"})}):k.length===0?e.jsx("div",{className:"nice-list__empty",children:X||ke("controls.noData","No data available")}):c?e.jsx("div",{role:"listbox",children:Array.from(c.entries()).map(([j,ie])=>e.jsxs("div",{className:"nice-list__group",children:[e.jsx("div",{className:"nice-list__group-header",children:j}),e.jsx("ul",{className:"nice-list__items",children:ie.map((O,fe)=>se(O,fe))})]},j))}):e.jsx("ul",{className:"nice-list__items",role:"listbox",children:k.map((j,ie)=>se(j,ie))})]})};function ti(n){const a=[];if(n.children)for(const s of n.children)a.push(s.key),a.push(...ti(s));return a}function Rn(n,a){if(!n.children||n.children.length===0)return a.has(n.key)?"checked":"unchecked";let s=!0,r=a.has(n.key);for(const o of n.children){const p=Rn(o,a);p==="checked"?r=!0:(p==="indeterminate"&&(r=!0),s=!1)}return s&&r?"checked":r?"indeterminate":"unchecked"}const Ei=({nodes:n,selectedKeys:a=[],expandedKeys:s,onSelectionChange:r,onExpandedChange:o,selectionMode:p="none",showCheckboxes:x,searchable:l,searchPlaceholder:f,onNodeClick:S,renderNode:D,showLines:V,loading:R,className:ae,style:X,accessMode:F,id:T,draggable:w,onNodeDrop:g,onLoadChildren:_,contextMenuItems:y,onContextMenuAction:P,editable:$,onNodeEdit:ce})=>{const z=De._s(F,T)==="hidden",{t:q}=De.$o(),[le,ue]=t.useState([]),[be,G]=t.useState(""),[M,k]=t.useState(new Set),[c,Ce]=t.useState(new Map),[ve,se]=t.useState(null),[j,ie]=t.useState(null),[O,fe]=t.useState(null),[Y,Ee]=t.useState(""),He=t.useRef(null),Ke=s??le,Ae=t.useMemo(()=>new Set(a),[a]),qe=t.useCallback(async(N,ge)=>{const H=!Ke.includes(N),L=H?[...Ke,N]:Ke.filter(B=>B!==N);if(o?o(L):ue(L),H&&_&&!ge.children?.length&&ge.leaf!==!0&&!c.has(N)){k(je=>new Set(je).add(N));const B=await _(ge);Ce(je=>new Map(je).set(N,B)),k(je=>{const re=new Set(je);return re.delete(N),re})}},[Ke,o,_,c]),Oe=t.useCallback((N,ge)=>{if(r){if(p==="single")r(a.includes(N)?[]:[N]);else if(p==="multiple")if(x&&ge.children?.length){const H=ti(ge),L=[N,...H];if(Rn(ge,Ae)==="checked")r(a.filter(je=>!L.includes(je)));else{const je=new Set([...a,...L]);r(Array.from(je))}}else r(a.includes(N)?a.filter(H=>H!==N):[...a,N])}},[a,p,r,x,Ae]),Ue=t.useCallback(N=>{if(!be)return!0;const ge=be.toLowerCase();return N.text.toLowerCase().includes(ge)?!0:(c.get(N.key)??N.children)?.some(L=>Ue(L))??!1},[be,c]),Z=t.useCallback((N,ge)=>{y?.length&&(N.preventDefault(),ie({x:N.clientX,y:N.clientY,node:ge}))},[y]),we=t.useCallback(()=>{O&&ce&&ce(O,Y),fe(null)},[O,Y,ce]),Xe=(N,ge)=>{if(be&&!Ue(N))return null;const H=c.get(N.key)??N.children,L=H&&H.length>0||N.leaf!==!0&&_&&!H?.length,B=Ke.includes(N.key),je=Ae.has(N.key),re=M.has(N.key),Ie=x&&p==="multiple"&&H?.length?Rn(N,Ae):je?"checked":"unchecked";return e.jsxs("li",{className:"nice-tree__node",role:"treeitem","aria-expanded":L?B:void 0,draggable:w&&!N.disabled,onDragStart:w?J=>{J.stopPropagation(),se(N.key)}:void 0,onDragOver:w?J=>{J.preventDefault(),J.stopPropagation()}:void 0,onDrop:w&&ve?J=>{J.stopPropagation(),g?.(ve,N.key,"inside"),se(null)}:void 0,onDragEnd:w?()=>se(null):void 0,children:[e.jsxs("div",{className:`nice-tree__row ${je?"nice-tree__row--selected":""} ${N.disabled?"nice-tree__row--disabled":""} ${ve===N.key?"nice-tree__row--dragging":""}`,style:{paddingLeft:ge*20+4},onClick:()=>{N.disabled||(Oe(N.key,N),S?.(N))},onContextMenu:J=>Z(J,N),onDoubleClick:$&&!N.disabled?()=>{fe(N.key),Ee(N.text)}:void 0,children:[e.jsx("span",{className:`nice-tree__toggle ${L?B?"nice-tree__toggle--expanded":"":"nice-tree__toggle--leaf"}`,onClick:J=>{J.stopPropagation(),L&&qe(N.key,N)},children:re?e.jsx("span",{className:"nice-spinner nice-spinner--xs"}):L?B?"▾":"▸":""}),x&&p!=="none"&&e.jsx("input",{type:"checkbox",checked:Ie==="checked",ref:J=>{J&&(J.indeterminate=Ie==="indeterminate")},onChange:()=>Oe(N.key,N),onClick:J=>J.stopPropagation(),tabIndex:-1,className:"nice-tree__checkbox"}),O===N.key?e.jsx("input",{type:"text",className:"nice-tree__edit-input",value:Y,onChange:J=>Ee(J.target.value),onBlur:we,onKeyDown:J=>{J.key==="Enter"&&we(),J.key==="Escape"&&fe(null)},autoFocus:!0,onClick:J=>J.stopPropagation()}):D?D(N):e.jsxs(e.Fragment,{children:[N.icon&&e.jsx("span",{className:"nice-tree__icon",children:N.icon}),e.jsx("span",{className:"nice-tree__text",children:N.text})]})]}),H&&H.length>0&&B&&e.jsx("ul",{className:"nice-tree__children",role:"group",children:H.map(J=>Xe(J,ge+1))})]},N.key)};return z?null:e.jsxs("div",{className:`nice-tree ${V?"nice-tree--lines":""} ${ae||""}`,style:X,ref:He,onClick:()=>ie(null),children:[l&&e.jsx("div",{className:"nice-tree__search",children:e.jsx("input",{type:"text",value:be,onChange:N=>G(N.target.value),placeholder:f||q("controls.search","Search..."),"aria-label":f||q("controls.search","Search tree")})}),R?e.jsx("div",{className:"nice-tree__loading",children:e.jsx("div",{className:"nice-spinner nice-spinner--sm"})}):e.jsx("ul",{className:"nice-tree__root",role:"tree",children:n.map(N=>Xe(N,0))}),j&&y&&e.jsx("div",{className:"nice-tree__context-menu",style:{position:"fixed",top:j.y,left:j.x,zIndex:9999},children:y.map(N=>e.jsxs("div",{className:`nice-tree__context-item ${N.disabled?"nice-tree__context-item--disabled":""}`,onClick:()=>{N.disabled||(P?.(N.key,j.node),ie(null))},children:[N.icon&&e.jsx("span",{children:N.icon}),N.label]},N.key))})]})};function Ai(n,a,s){const r=new Map,o=[];return n.forEach(p=>{const x={...p,children:[]};r.set(String(x[a]),x)}),n.forEach(p=>{const x=p[s];x!=null&&r.has(String(x))?r.get(String(x)).children.push(r.get(String(p[a]))):o.push(r.get(String(p[a])))}),o}function $i({columns:n,data:a,keyField:s="key",parentKeyField:r="parentKey",expandedKeys:o,onExpandedChange:p,selectedKeys:x=[],onSelectionChange:l,selectable:f,loading:S,emptyText:D,className:V,style:R,accessMode:ae,id:X}){const T=De._s(ae,X)==="hidden",{t:w}=De.$o(),[g,_]=t.useState([]),y=o??g,P=t.useMemo(()=>Ai(a,s,r),[a,s,r]),$=t.useMemo(()=>n.filter(q=>!q.hidden),[n]),ce=t.useCallback(q=>{const le=y.includes(q)?y.filter(ue=>ue!==q):[...y,q];p?p(le):_(le)},[y,p]),ke=t.useCallback(q=>{l&&l(x.includes(q)?x.filter(le=>le!==q):[...x,q])},[x,l]),z=(q,le)=>{const ue=String(q[s]),be=q.children&&q.children.length>0,G=y.includes(ue),M=x.includes(ue);return e.jsxs(t.Fragment,{children:[e.jsxs("tr",{className:M?"nice-treelist__row--selected":"",children:[f&&e.jsx("td",{className:"nice-treelist__checkbox",children:e.jsx("input",{type:"checkbox",checked:M,onChange:()=>ke(ue)})}),$.map((k,c)=>e.jsxs("td",{style:{textAlign:k.align},children:[c===0&&e.jsx("span",{style:{display:"inline-block",width:le*20}}),c===0&&e.jsx("span",{className:"nice-treelist__toggle",onClick:()=>be&&ce(ue),style:{cursor:be?"pointer":"default",width:20,display:"inline-block"},children:be?G?"▾":"▸":""}),k.render?k.render(q[k.field],q,0):String(q[k.field]??"")]},k.field))]}),be&&G&&q.children.map(k=>z(k,le+1))]},ue)};return T?null:e.jsx("div",{className:`nice-treelist ${V||""}`,style:R,children:e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[f&&e.jsx("th",{className:"nice-treelist__checkbox"}),$.map(q=>e.jsx("th",{style:{width:q.width,minWidth:q.minWidth,textAlign:q.align},children:q.header},q.field))]})}),e.jsx("tbody",{children:S?e.jsx("tr",{children:e.jsx("td",{colSpan:$.length+(f?1:0),className:"nice-treelist__empty",children:e.jsx("div",{className:"nice-spinner nice-spinner--md",style:{margin:"0 auto"}})})}):P.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:$.length+(f?1:0),className:"nice-treelist__empty",children:D||w("controls.noData","No data available")})}):P.map(q=>z(q,0))})]})})}function zi({items:n,renderCard:a,columns:s=3,gap:r=16,searchable:o,searchField:p="text",searchPlaceholder:x,loading:l,emptyText:f,onCardClick:S,className:D,style:V,accessMode:R,id:ae}){const F=De._s(R,ae)==="hidden",{t:T}=De.$o(),[w,g]=t.useState(""),_=t.useMemo(()=>{if(!w)return n;const y=w.toLowerCase();return n.filter(P=>String(P[p]??"").toLowerCase().includes(y))},[n,w,p]);return F?null:e.jsxs("div",{className:`nice-cardview ${D||""}`,style:V,children:[o&&e.jsx("div",{className:"nice-cardview__search",children:e.jsx("input",{type:"text",value:w,onChange:y=>g(y.target.value),placeholder:x||T("controls.search","Search...")})}),l?e.jsx("div",{className:"nice-cardview__loading",children:e.jsx("div",{className:"nice-spinner nice-spinner--md"})}):_.length===0?e.jsx("div",{className:"nice-cardview__empty",children:f||T("controls.noData","No data available")}):e.jsx("div",{className:"nice-cardview__grid",style:{display:"grid",gridTemplateColumns:`repeat(${s}, 1fr)`,gap:r},children:_.map(y=>e.jsx("div",{className:"nice-cardview__card",onClick:()=>S?.(y),style:S?{cursor:"pointer"}:void 0,children:a(y)},y.key))})]})}function Ti({items:n,tileWidth:a=180,tileHeight:s=180,direction:r="horizontal",renderTile:o,onTileClick:p,loading:x,emptyText:l,className:f,style:S}){const{t:D}=De.$o();return e.jsx("div",{className:`nice-tileview nice-tileview--${r} ${f||""}`,style:S,children:x?e.jsx("div",{className:"nice-tileview__loading",children:e.jsx("div",{className:"nice-spinner nice-spinner--md"})}):n.length===0?e.jsx("div",{className:"nice-tileview__empty",children:l||D("controls.noData","No data available")}):e.jsx("div",{className:"nice-tileview__container",style:{display:"flex",flexWrap:"wrap",gap:8,flexDirection:r==="vertical"?"column":"row"},children:n.map(V=>e.jsx("div",{className:"nice-tileview__tile",style:{width:a,height:s,cursor:p?"pointer":void 0},onClick:()=>p?.(V),children:o?o(V):e.jsxs(e.Fragment,{children:[V.image&&e.jsx("img",{src:V.image,alt:V.text||"",className:"nice-tileview__image"}),V.text&&e.jsx("div",{className:"nice-tileview__label",children:V.text})]})},V.key))})})}const Zn=[{key:"row",label:"Rows"},{key:"column",label:"Columns"},{key:"data",label:"Values"},{key:"filter",label:"Filters"}],ni=({fields:n,onChange:a,className:s,style:r})=>{const o=n.filter(l=>!l.area),p=(l,f)=>{a(n.map(S=>S.field===l?{...S,area:f}:S))},x=l=>{a(n.map(f=>f.field===l?{...f,area:void 0}:f))};return e.jsx("div",{className:`nice-field-chooser ${s||""}`,style:r,children:e.jsxs("div",{className:"nice-field-chooser__panel",children:[e.jsxs("div",{className:"nice-field-chooser__section",children:[e.jsx("h4",{children:"Available Fields"}),e.jsx("ul",{children:o.map(l=>e.jsxs("li",{className:"nice-field-chooser__item",children:[e.jsx("span",{children:l.caption}),e.jsx("div",{className:"nice-field-chooser__actions",children:Zn.map(f=>e.jsx("button",{type:"button",className:"nice-btn nice-btn--ghost nice-btn--sm",onClick:()=>p(l.field,f.key),children:f.label},f.key))})]},l.field))})]}),Zn.map(l=>{const f=n.filter(S=>S.area===l.key);return e.jsxs("div",{className:"nice-field-chooser__section",children:[e.jsx("h4",{children:l.label}),e.jsx("ul",{children:f.map(S=>e.jsxs("li",{className:"nice-field-chooser__item",children:[e.jsx("span",{children:S.caption}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--ghost nice-btn--sm",onClick:()=>x(S.field),children:"✕"})]},S.field))})]},l.key)})]})})};function Li(n,a){if(n.length===0)return 0;switch(a){case"sum":return n.reduce((s,r)=>s+r,0);case"count":return n.length;case"avg":return n.reduce((s,r)=>s+r,0)/n.length;case"min":return Math.min(...n);case"max":return Math.max(...n);default:return n.reduce((s,r)=>s+r,0)}}function Xn(n,a){return[...new Set(n.map(s=>String(s[a]??"")))].sort()}const ii=({data:n,fields:a,onFieldsChange:s,showFieldChooser:r,loading:o,emptyText:p,exportCsv:x,exportFilename:l="pivot-export",onDrillThrough:f,className:S,style:D,accessMode:V,id:R})=>{const X=De._s(V,R)==="hidden",{t:F}=De.$o(),[T,w]=t.useState(a),[g,_]=t.useState(!1),y=t.useMemo(()=>T.filter(G=>G.area==="row"),[T]),P=t.useMemo(()=>T.filter(G=>G.area==="column"),[T]),$=t.useMemo(()=>T.filter(G=>G.area==="data"),[T]),ce=t.useMemo(()=>y.length===0?["Total"]:Xn(n,y[0].field),[n,y]),ke=t.useMemo(()=>P.length===0?["Total"]:Xn(n,P[0].field),[n,P]),z=t.useCallback((G,M,k)=>{let c=n;y.length>0&&(c=c.filter(se=>String(se[y[0].field])===G)),P.length>0&&(c=c.filter(se=>String(se[P[0].field])===M));const Ce=c.map(se=>Number(se[k.field])||0),ve=Li(Ce,k.summaryType||"sum");return k.format?k.format(ve):ve},[n,y,P]),q=t.useCallback(G=>{w(G),s?.(G)},[s]),le=t.useCallback((G,M)=>{let k=n;return y.length>0&&(k=k.filter(c=>String(c[y[0].field])===G)),P.length>0&&(k=k.filter(c=>String(c[P[0].field])===M)),k},[n,y,P]),ue=t.useCallback((G,M)=>{f&&f(G,M,le(G,M))},[f,le]),be=t.useCallback(()=>{const G=["",...ke.flatMap(se=>$.length>0?$.map(j=>`${se} - ${j.caption}`):[se])],M=ce.map(se=>{const j=ke.flatMap(ie=>$.length>0?$.map(O=>String(z(se,ie,O))):["—"]);return[se,...j]}),k=[G,...M].map(se=>se.map(j=>`"${String(j).replace(/"/g,'""')}"`).join(",")).join(`
|
|
15
|
+
`),c=new Blob(["\uFEFF"+k],{type:"text/csv;charset=utf-8;"}),Ce=URL.createObjectURL(c),ve=document.createElement("a");ve.href=Ce,ve.download=`${l}.csv`,ve.click(),URL.revokeObjectURL(Ce)},[ke,ce,$,z,l]);return X?null:e.jsxs("div",{className:`nice-pivotgrid ${S||""}`,style:D,children:[(r||x)&&e.jsxs("div",{className:"nice-pivotgrid__toolbar",children:[r&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",onClick:()=>_(!g),children:F("controls.fieldChooser","Field Chooser")}),x&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--sm",onClick:be,children:"CSV ↓"})]}),g&&e.jsx(ni,{fields:T,onChange:q}),o?e.jsx("div",{className:"nice-pivotgrid__loading",children:e.jsx("div",{className:"nice-spinner nice-spinner--md"})}):e.jsx("div",{className:"nice-pivotgrid__table-wrap",children:e.jsxs("table",{className:"nice-pivotgrid__table",children:[e.jsxs("thead",{children:[e.jsxs("tr",{children:[e.jsx("th",{children:y.map(G=>G.caption).join(" / ")||""}),ke.map(G=>e.jsx("th",{colSpan:$.length||1,children:G},G))]}),$.length>1&&e.jsxs("tr",{children:[e.jsx("th",{}),ke.map(G=>$.map(M=>e.jsx("th",{children:M.caption},`${G}-${M.field}`)))]})]}),e.jsx("tbody",{children:ce.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:1+ke.length*Math.max($.length,1),className:"nice-pivotgrid__empty",children:p||F("controls.noData","No data available")})}):ce.map(G=>e.jsxs("tr",{children:[e.jsx("td",{className:"nice-pivotgrid__row-header",children:G}),ke.map(M=>$.length>0?$.map(k=>e.jsx("td",{className:`nice-pivotgrid__cell ${f?"nice-pivotgrid__cell--clickable":""}`,onClick:f?()=>ue(G,M):void 0,children:z(G,M,k)},`${M}-${k.field}`)):e.jsx("td",{className:"nice-pivotgrid__cell",children:"—"},M))]},G))})]})})]})},Pi=Object.freeze(Object.defineProperty({__proto__:null,NicePivotGrid:ii},Symbol.toStringTag,{value:"Module"})),ai=t.forwardRef(({columns:n,cards:a,onCardMove:s,onCardClick:r,renderCard:o,onAddCard:p,disabled:x=!1,size:l="md",collapsible:f=!1,layoutMode:S="scroll",viewMode:D,onViewModeChange:V,collapsedColumns:R,onCollapsedColumnsChange:ae,formItems:X,formColumns:F=1,formProps:T,editCardTitle:w,newCardTitle:g,onCardEdit:_,onCardCreate:y,onCardDelete:P,cookies:$=!1,localStorage:ce=!0,sessionStorage:ke=!1,storageMode:z,storageKey:q,className:le,style:ue,id:be,...G},M)=>{const{t:k}=De.$o(),[c,Ce]=t.useState(null),[ve,se]=t.useState(null),[j,ie]=t.useState(null),O=!!X&&(!!_||!!y),fe=t.useCallback(L=>{if(O&&_){ie({key:L.key,data:{...L},column:L.column});return}r?.(L)},[O,r,_]),Y=t.useCallback(L=>{if(O&&y){ie({key:null,data:{title:"",description:""},column:L});return}p?.(L)},[O,p,y]),Ee=De.useStorageAdapter(q??"nice-kanban"),[He,Ke]=t.useState(()=>Ee.get("state")??{collapsedColumns:[],viewMode:"default"}),Ae=R??He.collapsedColumns??[],qe=D??He.viewMode??"default",Oe=t.useCallback(L=>{Ke(B=>{const je={...B,...L};return Ee.set("state",je),je})},[Ee]),Ue=t.useCallback(L=>{const B=Ae.includes(L)?Ae.filter(je=>je!==L):[...Ae,L];ae?ae(B):Oe({collapsedColumns:B})},[Ae,ae,Oe]);t.useCallback(L=>{V?V(L):Oe({viewMode:L})},[V,Oe]);const Z=t.useCallback(L=>a.filter(B=>B.column===L).sort((B,je)=>(B.order??0)-(je.order??0)),[a]),we=t.useCallback((L,B)=>{x||(L.dataTransfer.effectAllowed="move",L.dataTransfer.setData("text/plain",String(B.key)),Ce({cardKey:B.key,fromColumn:B.column}))},[x]),Xe=t.useCallback((L,B)=>{L.preventDefault(),L.dataTransfer.dropEffect="move",se({column:B})},[]),N=t.useCallback(()=>{se(null)},[]),ge=t.useCallback((L,B)=>{if(L.preventDefault(),se(null),!c||x)return;const je=Z(B);s?.(c.cardKey,B,je.length),Ce(null)},[c,x,Z,s]),H=t.useCallback(()=>{Ce(null),se(null)},[]);return e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:M,id:be,className:`nice-kanban nice-kanban--${l} nice-kanban--${qe} nice-kanban--layout-${S} ${x?"nice-kanban--disabled":""} ${le||""}`,style:ue,...G,children:n.map(L=>{const B=Z(L.key),je=ve?.column===L.key,re=L.limit!=null&&B.length>=L.limit,Ie=f&&Ae.includes(L.key);return e.jsxs("div",{className:`nice-kanban__column ${je?"nice-kanban__column--dragover":""} ${Ie?"nice-kanban__column--collapsed":""}`,onDragOver:J=>!Ie&&Xe(J,L.key),onDragLeave:N,onDrop:J=>!Ie&&ge(J,L.key),children:[e.jsxs("div",{className:"nice-kanban__column-header",style:L.color?{borderTopColor:L.color}:void 0,onClick:f?()=>Ue(L.key):void 0,role:f?"button":void 0,tabIndex:f?0:void 0,onKeyDown:f?J=>{(J.key==="Enter"||J.key===" ")&&Ue(L.key)}:void 0,children:[f&&e.jsx("span",{className:"nice-kanban__collapse-icon","aria-hidden":"true",children:"?"}),e.jsx("span",{className:"nice-kanban__column-title",children:L.title}),e.jsxs("span",{className:"nice-kanban__column-count",children:[B.length,L.limit!=null&&` / ${L.limit}`]})]}),!Ie&&e.jsxs("div",{className:"nice-kanban__column-body",children:[B.map(J=>e.jsx("div",{className:`nice-kanban__card nice-kanban__card--${qe} ${c?.cardKey===J.key?"nice-kanban__card--dragging":""}`,draggable:!x,onDragStart:he=>we(he,J),onDragEnd:H,onClick:()=>fe(J),role:"article",children:o?o(J):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"nice-kanban__card-title",children:J.title}),qe!=="compact"&&J.description&&e.jsx("div",{className:"nice-kanban__card-desc",children:J.description})]})},J.key)),B.length===0&&e.jsx("div",{className:"nice-kanban__empty",children:k("kanban.empty","No cards")})]}),!Ie&&(p||O&&y)&&!re&&e.jsxs("button",{type:"button",className:"nice-kanban__add",onClick:()=>Y(L.key),disabled:x,children:["+ ",k("kanban.addCard","Add card")]})]},L.key)})}),O&&j&&e.jsxs(Jn.NiceModal,{open:!0,onClose:()=>ie(null),title:j.key==null?g||k("kanban.newCard","New card"):w||k("kanban.editCard","Edit card"),children:[e.jsx(Yn.NiceForm,{items:X,data:j.data,columns:F,...T,onFieldChange:(L,B)=>ie(je=>je&&{...je,data:{...je.data,[L]:B}})}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:16,flexWrap:"wrap"},children:[j.key!=null&&P&&e.jsx(ze.NiceButton,{type:"button",size:"sm",variant:"error",style:{marginRight:"auto"},onClick:()=>{P(j.key),ie(null)},children:k("controls.delete","Delete")}),e.jsx(ze.NiceButton,{type:"button",size:"sm",variant:"secondary",onClick:()=>ie(null),children:k("controls.cancel","Cancel")}),e.jsx(ze.NiceButton,{type:"button",size:"sm",variant:"primary",onClick:()=>{if(j.key==null){const L={key:`card-${Date.now()}`,title:"",column:j.column,...j.data};y?.(L)}else _?.(j.key,{...j.data,key:j.key,column:j.column});ie(null)},children:k("controls.save","Save")})]})]})]})});ai.displayName="NiceKanbanBoard";function zt(...n){return n.filter(Boolean).map(a=>typeof a=="object"?Object.entries(a).filter(([,s])=>s).map(([s])=>s).join(" "):a).join(" ")}const Fi=50,Oi=[10,25,50,100,200],Ui=40,Wi=10,Bi=768,Gi=500,Vi=10;function vt(n,a){return a.split(".").reduce((s,r)=>s?.[r],n)}function on(n,a,s="pl-PL"){if(n==null)return"—";switch(a.type){case"number":return new Intl.NumberFormat(s,{minimumFractionDigits:a.format?.includes(".")?a.format.split(".")[1].length:0}).format(n);case"currency":return new Intl.NumberFormat(s,{style:"currency",currency:a.currencyCode||"PLN"}).format(n);case"percent":return new Intl.NumberFormat(s,{style:"percent",minimumFractionDigits:0,maximumFractionDigits:2}).format(n/100);case"date":return new Intl.DateTimeFormat(s,{dateStyle:"short"}).format(new Date(n));case"datetime":return new Intl.DateTimeFormat(s,{dateStyle:"short",timeStyle:"short"}).format(new Date(n));case"boolean":return n?"✓":"✗";case"enum":return a.enumOptions?.find(o=>o.value===n)?.label||String(n);default:return String(n)}}function Ki(n,a,s,r){const[o,p]=t.useState(0),{startIndex:x,endIndex:l,totalHeight:f,offsetY:S}=t.useMemo(()=>{const R=n.length*s,ae=Math.ceil(a/s),X=Math.max(0,Math.floor(o/s)-r),F=Math.min(n.length,Math.ceil(o/s)+ae+r),T=X*s;return{startIndex:X,endIndex:F,totalHeight:R,offsetY:T}},[n.length,a,s,o,r]),D=t.useMemo(()=>n.slice(x,l),[n,x,l]),V=t.useCallback(R=>{p(R.currentTarget.scrollTop)},[]);return{visibleData:D,totalHeight:f,offsetY:S,handleScroll:V,startIndex:x}}function qi(n,a){const[s,r]=t.useState(()=>{if(n&&typeof window<"u"){const p=localStorage.getItem(`nice-module-grid-${n}`);if(p)return JSON.parse(p)}return a||{}}),o=t.useCallback(p=>{r(x=>{const l={...x,...p};return n&&typeof window<"u"&&localStorage.setItem(`nice-module-grid-${n}`,JSON.stringify(l)),l})},[n]);return[s,o]}function Zi(n){const[a,s]=t.useState(typeof window<"u"&&window.innerWidth<n);return t.useEffect(()=>{if(typeof window>"u")return;const r=()=>s(window.innerWidth<n);return window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},[n]),a}function Xi({column:n,sort:a,onSort:s,onResize:r,resizable:o,t:p}){const x=t.useRef(null),[l,f]=t.useState(!1),S=t.useCallback(R=>{if(!o||!r)return;R.preventDefault(),f(!0);const ae=R.clientX,X=n.width||150,F=w=>{const g=w.clientX-ae,_=Math.max(n.minWidth||50,X+g);r(n.field,Math.min(_,n.maxWidth||1/0))},T=()=>{f(!1),document.removeEventListener("mousemove",F),document.removeEventListener("mouseup",T)};document.addEventListener("mousemove",F),document.addEventListener("mouseup",T)},[n,o,r]),D=a?.direction,V=D==="asc"?"↑":D==="desc"?"↓":null;return e.jsxs("div",{className:zt("nice-module-grid__header-cell",n.sortable&&"nice-module-grid__header-cell--sortable",l&&"nice-module-grid__header-cell--resizing"),style:{width:n.width==="auto"?"auto":n.width||150,minWidth:n.minWidth,maxWidth:n.maxWidth,textAlign:n.align},onClick:()=>n.sortable&&s?.(n.field),role:"columnheader","aria-sort":D==="asc"?"ascending":D==="desc"?"descending":"none",title:n.headerTooltip,children:[e.jsx("span",{className:"nice-module-grid__header-text",children:n.header}),V&&e.jsx("span",{className:"nice-module-grid__sort-indicator",children:V}),o&&e.jsx("div",{ref:x,className:"nice-module-grid__resize-handle",onMouseDown:S})]})}function Hi({column:n,row:a,rowIndex:s,value:r,locale:o="pl-PL",onClick:p}){const x=De.oc({onClick:p}),l=p?x:{};if(n.render)return e.jsx("div",{className:"nice-module-grid__cell",style:{textAlign:n.align},...l,children:n.render(r,a,s)});if(n.type==="enum"&&n.enumOptions){const f=n.enumOptions.find(S=>S.value===r);if(f)return e.jsx("div",{className:"nice-module-grid__cell",style:{textAlign:n.align},...l,children:e.jsxs("span",{className:zt("nice-module-grid__badge",`nice-module-grid__badge--${f.color||"default"}`),children:[f.icon&&e.jsx("span",{className:"nice-module-grid__badge-icon",children:f.icon}),f.label]})})}if(n.type==="progress"){const f=Math.min(100,Math.max(0,Number(r)||0));return e.jsx("div",{className:"nice-module-grid__cell",style:{textAlign:n.align},...l,children:e.jsxs("div",{className:"nice-module-grid__progress",children:[e.jsx("div",{className:zt("nice-module-grid__progress-bar",`nice-module-grid__progress-bar--${n.progressColor||"primary"}`),style:{width:`${f}%`}}),e.jsxs("span",{className:"nice-module-grid__progress-text",children:[f,"%"]})]})})}if(n.type==="rating"){const f=n.maxRating||5,S=Number(r)||0;return e.jsx("div",{className:"nice-module-grid__cell",style:{textAlign:n.align},...l,children:e.jsx("span",{className:"nice-module-grid__rating","aria-label":`${S} out of ${f} stars`,children:Array.from({length:f},(D,V)=>e.jsx("span",{className:zt("nice-module-grid__star",V<S&&"nice-module-grid__star--filled"),children:"★"},V))})})}if(n.type==="link"&&n.linkTemplate){const f=n.linkTemplate.replace(/\{\{(\w+)\}\}/g,(S,D)=>String(vt(a,D)??""));return e.jsx("div",{className:"nice-module-grid__cell",style:{textAlign:n.align},...l,children:e.jsx("a",{href:f,target:n.linkNewTab?"_blank":void 0,rel:n.linkNewTab?"noopener noreferrer":void 0,className:"nice-module-grid__link",children:on(r,n,o)})})}if(n.type==="image"){const S={xs:24,sm:32,md:48,lg:64}[n.imageSize||"sm"];return e.jsx("div",{className:"nice-module-grid__cell",style:{textAlign:n.align},...l,children:r?e.jsx("img",{src:String(r),alt:"",className:"nice-module-grid__image",style:{width:S,height:S}}):e.jsx("div",{className:"nice-module-grid__image-placeholder",style:{width:S,height:S}})})}return n.type==="avatar"?e.jsx("div",{className:"nice-module-grid__cell",style:{textAlign:n.align},...l,children:r?e.jsx("img",{src:String(r),alt:"",className:"nice-module-grid__avatar"}):e.jsx("div",{className:"nice-module-grid__avatar-placeholder",children:"?"})}):n.type==="color"?e.jsx("div",{className:"nice-module-grid__cell",style:{textAlign:n.align},...l,children:e.jsx("span",{className:"nice-module-grid__color-swatch",style:{backgroundColor:r||"transparent"},title:r})}):n.type==="boolean"?e.jsx("div",{className:"nice-module-grid__cell",style:{textAlign:n.align||"center"},...l,children:e.jsx("span",{className:zt("nice-module-grid__boolean",!!r&&"nice-module-grid__boolean--true"),children:r?"✓":"✗"})}):e.jsx("div",{className:"nice-module-grid__cell",style:{textAlign:n.align},...l,children:on(r,n,o)})}function Qi({row:n,index:a,columns:s,primaryField:r,secondaryField:o,customRender:p,selected:x,onClick:l,locale:f="pl-PL",t:S}){if(p)return e.jsx("div",{className:zt("nice-module-grid__mobile-card",x&&"nice-module-grid__mobile-card--selected"),onClick:l,children:p(n,a)});const D=s.find(R=>R.field===r)||s[0],V=s.find(R=>R.field===o)||s[1];return e.jsxs("div",{className:zt("nice-module-grid__mobile-card",x&&"nice-module-grid__mobile-card--selected"),onClick:l,role:"row","aria-selected":x,children:[e.jsxs("div",{className:"nice-module-grid__mobile-card-header",children:[e.jsx("div",{className:"nice-module-grid__mobile-card-title",children:on(vt(n,D?.field||""),D,f)}),V&&e.jsx("div",{className:"nice-module-grid__mobile-card-subtitle",children:on(vt(n,V.field),V,f)})]}),e.jsx("div",{className:"nice-module-grid__mobile-card-body",children:s.filter(R=>!R.hidden&&R.field!==r&&R.field!==o).slice(0,4).map(R=>e.jsxs("div",{className:"nice-module-grid__mobile-card-field",children:[e.jsx("span",{className:"nice-module-grid__mobile-card-label",children:R.header}),e.jsx("span",{className:"nice-module-grid__mobile-card-value",children:on(vt(n,R.field),R,f)})]},R.field))})]})}function Yi({page:n,pageSize:a,totalRows:s,pageSizeOptions:r,onPageChange:o,t:p}){const x=Math.ceil(s/a),l=(n-1)*a+1,f=Math.min(n*a,s);return e.jsxs("div",{className:"nice-module-grid__pagination",role:"navigation","aria-label":p("pagination.ariaLabel","Pagination"),children:[e.jsxs("div",{className:"nice-module-grid__pagination-info",children:[p("pagination.showing","Showing")," ",l,"–",f," ",p("pagination.of","of")," ",s]}),e.jsxs("div",{className:"nice-module-grid__pagination-controls",children:[e.jsx("select",{className:"nice-module-grid__page-size-select",value:a,onChange:S=>o(1,Number(S.target.value)),"aria-label":p("pagination.rowsPerPage","Rows per page"),children:r.map(S=>e.jsx("option",{value:S,children:S},S))}),e.jsx("button",{className:"nice-module-grid__pagination-btn",onClick:()=>o(1,a),disabled:n===1,"aria-label":p("pagination.first","First"),children:"««"}),e.jsx("button",{className:"nice-module-grid__pagination-btn",onClick:()=>o(n-1,a),disabled:n===1,"aria-label":p("pagination.previous","Previous"),children:"«"}),e.jsxs("span",{className:"nice-module-grid__pagination-page",children:[n," / ",x]}),e.jsx("button",{className:"nice-module-grid__pagination-btn",onClick:()=>o(n+1,a),disabled:n>=x,"aria-label":p("pagination.next","Next"),children:"»"}),e.jsx("button",{className:"nice-module-grid__pagination-btn",onClick:()=>o(x,a),disabled:n>=x,"aria-label":p("pagination.last","Last"),children:"»»"})]})]})}function Ji({columns:n}){return e.jsx("div",{className:"nice-module-grid__row nice-module-grid__row--skeleton",role:"row",children:n.filter(a=>!a.hidden).map(a=>e.jsx("div",{className:"nice-module-grid__cell nice-module-grid__cell--skeleton",style:{width:a.width==="auto"?"auto":a.width||150},children:e.jsx("div",{className:"nice-module-grid__skeleton-bar"})},a.field))})}function ea(n,a){const{columns:s,data:r,keyField:o="id",dataSource:p,onFetch:x,sortable:l=!0,sort:f,onSortChange:S,multiSort:D=!1,filterable:V=!1,filter:R,onFilterChange:ae,searchText:X,onSearchChange:F,searchPlaceholder:T="moduleGrid.searchPlaceholder",pagination:w=!0,page:g,pageSize:_,pageSizeOptions:y=Oi,totalRows:P,onPageChange:$,virtualScroll:ce=!0,rowHeight:ke=Ui,overscan:z=Wi,selectionMode:q="none",selectedKeys:le,onSelectionChange:ue,columnReorder:be=!0,onColumnOrderChange:G,columnResize:M=!0,onColumnWidthChange:k,groupBy:c,onGroupByChange:Ce,groupRowRender:ve,expandAllGroups:se=!1,editable:j=!1,onCellEdit:ie,onRowEdit:O,editMode:fe="cell",contextMenuItems:Y,onContextMenuAction:Ee,exportable:He=!0,exportFormats:Ke=["csv","excel"],onExport:Ae,preferencesKey:qe,initialPreferences:Oe,onPreferencesChange:Ue,density:Z="normal",striped:we=!0,bordered:Xe=!1,hoverable:N=!0,loading:ge=!1,emptyState:H,toolbar:L,onRowClick:B,onRowDoubleClick:je,rowClassName:re,rowStyle:Ie,mobileCardView:J=!0,mobileBreakpoint:he=Bi,mobileCardRender:Be,mobilePrimaryField:yt,mobileSecondaryField:pt,moduleId:wt,permissions:Tt,size:ot="medium",skeletonLoading:kt=!0,skeletonRows:jt=Vi,"aria-label":I,"aria-labelledby":Q,"aria-describedby":pe,className:nt,style:ht,id:Se,testId:Ge}=n,{t:We}=De.$o();De._s(),De.cs("table");const dt=Zi(he),[at,Nt]=qi(qe,Oe),Gt=t.useRef(null),Jt=t.useRef(null),[qt,Zt]=t.useState([]),[ut,dn]=t.useState(),[en,Te]=t.useState(""),[Qe,Le]=t.useState(1),[Vt,d]=t.useState(_||Fi),[m,E]=t.useState(new Set),[K,ee]=t.useState([]),[A,W]=t.useState(0),[ne,de]=t.useState(!1),[Re,Pe]=t.useState(new Set),[ye,Ye]=t.useState(null),[St,Ct]=t.useState({}),Je=f??qt,ft=R??ut,Mt=X??en,Ot=g??Qe,Lt=_??Vt,Dt=le??m,tn=P??A??r?.length??0,Pt=!!(x||p),It=t.useMemo(()=>{const v=new Set(at.hiddenColumns||[]);return s.filter(me=>!me.hidden&&!v.has(me.field))},[s,at.hiddenColumns]),At=t.useMemo(()=>{if(Pt)return K;if(!r)return[];let v=[...r];if(Mt){const me=Mt.toLowerCase(),_e=s.filter(xe=>xe.searchable!==!1).map(xe=>xe.field);v=v.filter(xe=>_e.some(rt=>{const $e=vt(xe,rt);return String($e??"").toLowerCase().includes(me)}))}return Je.length>0&&v.sort((me,_e)=>{for(const xe of Je){const rt=vt(me,xe.field),$e=vt(_e,xe.field),Ze=rt<$e?-1:rt>$e?1:0;if(Ze!==0)return xe.direction==="asc"?Ze:-Ze}return 0}),v},[Pt,K,r,Mt,Je,s]),ct=t.useMemo(()=>{if(Pt||!w)return At;const v=(Ot-1)*Lt;return At.slice(v,v+Lt)},[Pt,At,w,Ot,Lt]),un=Gt.current?.clientHeight||400,Rt=ce&&ct.length>Gi,{visibleData:Ut,totalHeight:Wt,offsetY:nn,handleScroll:jn,startIndex:an}=Ki(ct,un,ke,z),Ft=Rt?Ut:ct,mn=t.useCallback(async()=>{if(x){de(!0);try{const me=await x({page:Ot,pageSize:Lt,sort:Je,filter:ft,search:Mt});ee(me.data),W(me.total)}catch(v){console.error("NiceModuleGrid fetch error:",v)}finally{de(!1)}}},[x,Ot,Lt,Je,ft,Mt]);t.useEffect(()=>{Pt&&mn()},[Pt,mn]);const Nn=t.useCallback(v=>{const me=Je.find(xe=>xe.field===v);let _e;me?me.direction==="asc"?_e=Je.map(xe=>xe.field===v?{...xe,direction:"desc"}:xe):_e=Je.filter(xe=>xe.field!==v):_e=D?[...Je,{field:v,direction:"asc"}]:[{field:v,direction:"asc"}],S?S(_e):Zt(_e)},[Je,D,S]),wn=t.useCallback((v,me)=>{$?$(v,me):(Le(v),d(me))},[$]),En=t.useCallback(v=>{F?F(v):Te(v),$||Le(1)},[F,$]),hn=t.useCallback((v,me)=>{const _e=new Set(Dt);if(q==="single"?(_e.clear(),_e.add(v)):(q==="multiple"||q==="checkbox")&&(_e.has(v)?_e.delete(v):_e.add(v)),ue){const xe=ct.filter(rt=>_e.has(String(vt(rt,o))));ue(_e,xe)}else E(_e)},[Dt,q,ue,ct,o]),kn=t.useCallback((v,me)=>{Ct(_e=>({..._e,[v]:me})),k?.(v,me),Nt({columnWidths:{...at.columnWidths,[v]:me}})},[k,Nt,at.columnWidths]),pn=t.useCallback((v,me)=>{Y?.length&&(v.preventDefault(),Ye({x:v.clientX,y:v.clientY,row:me}))},[Y]),An=t.useCallback(v=>{ye&&Ee?.(v,ye.row),Ye(null)},[ye,Ee]),$n=t.useCallback(async v=>{if(Ae)await Ae(v,{selectedOnly:Dt.size>0,columns:It.map(me=>me.field)});else if(v==="csv"){const me=It.map(lt=>lt.header).join(","),_e=ct.map(lt=>It.map(rn=>JSON.stringify(vt(lt,rn.field)??"")).join(",")),xe=[me,..._e].join(`
|
|
16
|
+
`),rt=new Blob([xe],{type:"text/csv;charset=utf-8;"}),$e=URL.createObjectURL(rt),Ze=document.createElement("a");Ze.href=$e,Ze.download=`export-${new Date().toISOString().slice(0,10)}.csv`,Ze.click(),URL.revokeObjectURL($e)}},[Ae,Dt,It,ct,We]);t.useEffect(()=>{if(!ye)return;const v=()=>Ye(null);return document.addEventListener("click",v),()=>document.removeEventListener("click",v)},[ye]);const sn=t.useCallback(v=>{v.key==="Escape"&&Ye(null)},[]),st=ge||ne,mt=!st&&Ft.length===0,gt=dt&&J,Sn=zt("nice-module-grid",`nice-module-grid--${Z}`,`nice-module-grid--${ot}`,we&&"nice-module-grid--striped",Xe&&"nice-module-grid--bordered",N&&"nice-module-grid--hoverable",st&&"nice-module-grid--loading",gt&&"nice-module-grid--mobile",nt);return e.jsxs("div",{ref:a,id:Se,"data-testid":Ge,className:Sn,style:ht,onKeyDown:sn,role:"grid","aria-label":I,"aria-labelledby":Q,"aria-describedby":pe,"aria-rowcount":tn,"aria-colcount":It.length,"aria-busy":st,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:T,value:Mt,onChange:v=>En(v.target.value),"aria-label":We("moduleGrid.searchAriaLabel","Search")})}),L,He&&e.jsx("div",{className:"nice-module-grid__toolbar-export",children:Ke.map(v=>e.jsx("button",{className:"nice-module-grid__export-btn",onClick:()=>$n(v),"aria-label":We(`moduleGrid.export.${v}`,`Export to ${v.toUpperCase()}`),children:v.toUpperCase()},v))})]}),e.jsx("div",{ref:Gt,className:"nice-module-grid__container",onScroll:Rt?jn:void 0,children:gt?e.jsx("div",{className:"nice-module-grid__mobile-list",children:st&&kt?Array.from({length:jt},(v,me)=>e.jsxs("div",{className:"nice-module-grid__mobile-card nice-module-grid__mobile-card--skeleton",children:[e.jsx("div",{className:"nice-module-grid__skeleton-bar",style:{width:"60%",height:20}}),e.jsx("div",{className:"nice-module-grid__skeleton-bar",style:{width:"40%",height:14}}),e.jsx("div",{className:"nice-module-grid__skeleton-bar",style:{width:"80%",height:14}})]},me)):mt?e.jsxs("div",{className:"nice-module-grid__empty",children:[H?.icon&&e.jsx("div",{className:"nice-module-grid__empty-icon",children:H.icon}),e.jsx("div",{className:"nice-module-grid__empty-title",children:H?.title||We("moduleGrid.noData","No data")}),H?.description&&e.jsx("div",{className:"nice-module-grid__empty-description",children:H.description}),H?.action&&e.jsxs("button",{className:"nice-module-grid__empty-action",onClick:H.action.onClick,children:[H.action.icon,H.action.label]})]}):Ft.map((v,me)=>{const _e=String(vt(v,o));return e.jsx(Qi,{row:v,index:an+me,columns:It,primaryField:yt,secondaryField:pt,customRender:Be,selected:Dt.has(_e),onClick:()=>{q!=="none"&&hn(_e,v),B?.(v,an+me)},t:We},_e)})}):e.jsxs("div",{ref:Jt,className:"nice-module-grid__table",children:[e.jsxs("div",{className:"nice-module-grid__header",role:"row",children:[q==="checkbox"&&e.jsx("div",{className:"nice-module-grid__header-cell nice-module-grid__header-cell--checkbox",children:e.jsx("input",{type:"checkbox",checked:Dt.size>0&&Dt.size===Ft.length,onChange:()=>{if(Dt.size===Ft.length)ue?.(new Set,[]),E(new Set);else{const v=new Set(Ft.map(me=>String(vt(me,o))));ue?.(v,Ft),E(v)}},"aria-label":We("moduleGrid.selectAll","Select all")})}),It.map(v=>e.jsx(Xi,{column:{...v,width:St[v.field]||v.width},sort:Je.find(me=>me.field===v.field),onSort:l?Nn:void 0,onResize:M?kn:void 0,resizable:M,t:We},v.field))]}),e.jsx("div",{className:"nice-module-grid__body",style:Rt?{height:Wt,position:"relative"}:void 0,children:st&&kt?Array.from({length:jt},(v,me)=>e.jsx(Ji,{columns:It},me)):mt?e.jsxs("div",{className:"nice-module-grid__empty",children:[H?.icon&&e.jsx("div",{className:"nice-module-grid__empty-icon",children:H.icon}),e.jsx("div",{className:"nice-module-grid__empty-title",children:H?.title||We("moduleGrid.noData","No data")}),H?.description&&e.jsx("div",{className:"nice-module-grid__empty-description",children:H.description}),H?.action&&e.jsxs("button",{className:"nice-module-grid__empty-action",onClick:H.action.onClick,children:[H.action.icon,H.action.label]})]}):e.jsx("div",{style:Rt?{transform:`translateY(${nn}px)`}:void 0,children:Ft.map((v,me)=>{const _e=String(vt(v,o)),xe=an+me,rt=Dt.has(_e),$e=typeof re=="function"?re(v,xe):re,Ze=typeof Ie=="function"?Ie(v,xe):Ie;return e.jsxs("div",{className:zt("nice-module-grid__row",rt&&"nice-module-grid__row--selected",$e),style:{...Ze,height:ke},role:"row","aria-rowindex":xe+1,"aria-selected":rt,onClick:()=>{q!=="none"&&hn(_e,v),B?.(v,xe)},onDoubleClick:()=>je?.(v,xe),onContextMenu:lt=>pn(lt,v),children:[q==="checkbox"&&e.jsx("div",{className:"nice-module-grid__cell nice-module-grid__cell--checkbox",children:e.jsx("input",{type:"checkbox",checked:rt,onChange:()=>hn(_e,v),onClick:lt=>lt.stopPropagation(),"aria-label":We("moduleGrid.selectRow","Select row")})}),It.map(lt=>e.jsx(Hi,{column:{...lt,width:St[lt.field]||lt.width},row:v,rowIndex:xe,value:vt(v,lt.field)},lt.field))]},_e)})})})]})}),w&&tn>0&&e.jsx(Yi,{page:Ot,pageSize:Lt,totalRows:Pt?A:At.length,pageSizeOptions:y,onPageChange:wn,t:We}),ye&&Y&&e.jsx("div",{className:"nice-module-grid__context-menu",style:{left:ye.x,top:ye.y},role:"menu",children:Y.filter(v=>typeof v.hidden=="function"?!v.hidden(ye.row):!v.hidden).map(v=>{if(v.divider)return e.jsx("div",{className:"nice-module-grid__context-menu-divider"},v.key);const me=typeof v.disabled=="function"?v.disabled(ye.row):v.disabled;return e.jsxs("button",{className:zt("nice-module-grid__context-menu-item",v.danger&&"nice-module-grid__context-menu-item--danger",me&&"nice-module-grid__context-menu-item--disabled"),onClick:()=>{me||(v.onClick?.(ye.row),An(v.key))},disabled:me,role:"menuitem",children:[v.icon&&e.jsx("span",{className:"nice-module-grid__context-menu-icon",children:v.icon}),v.label]},v.key)})}),st&&!kt&&e.jsx("div",{className:"nice-module-grid__loading-overlay",children:e.jsx("div",{className:"nice-module-grid__spinner","aria-label":We("moduleGrid.loading","Loading")})})]})}const ta=t.forwardRef(ea),na=`
|
|
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 $t(n,a="PLN",s="pl-PL"){return new Intl.NumberFormat(s,{style:"currency",currency:a,minimumFractionDigits:2,maximumFractionDigits:2}).format(n)}function vn(n,a="pl-PL"){return n?(typeof n=="string"?new Date(n):n).toLocaleDateString(a,{year:"numeric",month:"2-digit",day:"2-digit"}):"-"}function ia(n){return n>=80?"high":n>=50?"medium":"low"}function aa(){return`match-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function sa({item:n,isSelected:a,isDragging:s,isDropTarget:r,suggestion:o,currency:p,locale:x,onSelect:l,onDoubleClick:f,onDragStart:S,onDragEnd:D,onDrop:V,disabled:R}){const ae=n.status??"unmatched",X=o?.confidence??n.confidence,F=w=>{w.dataTransfer.setData("text/plain",n.id),w.dataTransfer.setData("source","statement"),w.dataTransfer.effectAllowed="move",S()},T=w=>{w.dataTransfer.types.includes("source")&&w.dataTransfer.getData("source")!=="statement"&&w.preventDefault()};return e.jsxs("div",{className:`nice-reconciliation__row nice-reconciliation__row--${ae} ${a?"nice-reconciliation__row--selected":""} ${s?"nice-reconciliation__row--dragging":""} ${r?"nice-reconciliation__row--drop-target":""}`,draggable:!R&&ae!=="matched",onDragStart:F,onDragEnd:D,onDragOver:T,onDrop:V,onClick:l,onDoubleClick:f,role:"row","aria-selected":a,tabIndex:0,children:[e.jsx("span",{className:`nice-reconciliation__status nice-reconciliation__status--${ae}`}),e.jsxs("div",{className:"nice-reconciliation__row-main",children:[e.jsx("div",{className:"nice-reconciliation__row-date",children:vn(n.date,x)}),e.jsx("div",{className:"nice-reconciliation__row-description",title:n.description,children:n.description}),n.counterparty&&e.jsx("div",{className:"nice-reconciliation__row-counterparty",children:n.counterparty})]}),X!=null&&e.jsxs("span",{className:`nice-reconciliation__confidence nice-reconciliation__confidence--${ia(X)}`,children:[X,"%"]}),e.jsx("span",{className:`nice-reconciliation__row-amount ${n.amount>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:$t(n.amount,p,x)})]})}function ra({item:n,isSelected:a,isDragging:s,isDropTarget:r,currency:o,locale:p,onSelect:x,onDoubleClick:l,onDragStart:f,onDragEnd:S,onDrop:D,disabled:V}){const R=n.status??"unmatched",ae=F=>{F.dataTransfer.setData("text/plain",n.id),F.dataTransfer.setData("source","entry"),F.dataTransfer.effectAllowed="move",f()},X=F=>{F.dataTransfer.types.includes("source")&&F.dataTransfer.getData("source")!=="entry"&&F.preventDefault()};return e.jsxs("div",{className:`nice-reconciliation__row nice-reconciliation__row--${R} ${a?"nice-reconciliation__row--selected":""} ${s?"nice-reconciliation__row--dragging":""} ${r?"nice-reconciliation__row--drop-target":""}`,draggable:!V&&R!=="matched",onDragStart:ae,onDragEnd:S,onDragOver:X,onDrop:D,onClick:x,onDoubleClick:l,role:"row","aria-selected":a,tabIndex:0,children:[e.jsx("span",{className:`nice-reconciliation__status nice-reconciliation__status--${R}`}),e.jsxs("div",{className:"nice-reconciliation__row-main",children:[e.jsxs("div",{className:"nice-reconciliation__row-date",children:[vn(n.date,p),n.documentNumber&&e.jsxs("span",{children:[" · ",n.documentNumber]})]}),e.jsx("div",{className:"nice-reconciliation__row-description",title:n.description,children:n.description}),n.partyName&&e.jsx("div",{className:"nice-reconciliation__row-counterparty",children:n.partyName})]}),e.jsx("span",{className:`nice-reconciliation__row-amount ${n.amount>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:$t(n.amount,o,p)})]})}const ca=t.forwardRef(function(a,s){const{statements:r,bankTransactions:o,entries:p,accountingEntries:x,matches:l,defaultMatches:f=[],suggestions:S=[],config:D={},currency:V,showConfidence:R,statementPanelConfig:ae,entryPanelConfig:X,onMatch:F,onAutoMatch:T,onUnmatch:w,onBatchAction:g,onFilterChange:_,onRequestSuggestions:y,onSelectionChange:P,onComplete:$,size:ce="medium",showToolbar:ke=!0,showFilters:z=!0,showSummary:q=!0,showSuggestions:le=!0,layout:ue="horizontal",enableDragDrop:be=!0,enableKeyboard:G=!0,enableDetailPanel:M=!0,loading:k=!1,disabled:c=!1,readOnly:Ce=!1,locale:ve="pl-PL",labels:se={},className:j,style:ie}=a,O=r??o??[],fe=p??x??[],Y=V??D.currency??"PLN",[Ee,He]=t.useState(f),[Ke,Ae]=t.useState(new Set),[qe,Oe]=t.useState(new Set),[Ue,Z]=t.useState(null),[we,Xe]=t.useState(null),[N,ge]=t.useState({}),[H,L]=t.useState(null),B=l??Ee,je=t.useRef(null),re=t.useRef(null);t.useEffect(()=>{const I="nice-reconciliation-styles";if(!document.getElementById(I)){const Q=document.createElement("style");Q.id=I,Q.textContent=na,document.head.appendChild(Q)}},[]);const Ie=t.useMemo(()=>{const I=new Set;return B.forEach(Q=>Q.statementIds.forEach(pe=>I.add(pe))),I},[B]),J=t.useMemo(()=>{const I=new Set;return B.forEach(Q=>Q.entryIds.forEach(pe=>I.add(pe))),I},[B]),he=t.useMemo(()=>{const I=O.filter(Se=>!Ie.has(Se.id)),Q=fe.filter(Se=>!J.has(Se.id)),pe=O.reduce((Se,Ge)=>Se+Ge.amount,0),nt=fe.reduce((Se,Ge)=>Se+Ge.amount,0),ht=O.filter(Se=>Ie.has(Se.id)).reduce((Se,Ge)=>Se+Ge.amount,0);return{totalStatements:O.length,totalEntries:fe.length,matchedStatements:O.length-I.length,matchedEntries:fe.length-Q.length,unmatchedStatements:I.length,unmatchedEntries:Q.length,statementTotal:pe,entryTotal:nt,matchedAmount:ht,unmatchedStatementAmount:I.reduce((Se,Ge)=>Se+Ge.amount,0),unmatchedEntryAmount:Q.reduce((Se,Ge)=>Se+Ge.amount,0),difference:pe-nt,matchPercentage:O.length>0?Math.round((O.length-I.length)/O.length*100):0,matchCount:B.length,partialMatchCount:B.filter(Se=>Se.status==="partial").length,pendingSuggestions:S.length}},[O,fe,B,S,Ie,J]),Be=t.useCallback((I,Q)=>{const pe=O.filter(at=>I.includes(at.id)),nt=fe.filter(at=>Q.includes(at.id));if(pe.length===0||nt.length===0)return null;const ht=pe.reduce((at,Nt)=>at+Nt.amount,0),Se=nt.reduce((at,Nt)=>at+Nt.amount,0),Ge=Math.abs(ht-Se),We=D.amountTolerance??.01,dt={id:aa(),statementIds:I,entryIds:Q,status:Ge<=We?"matched":"partial",statementTotal:ht,entryTotal:Se,difference:Ge,confidence:Ge<=We?100:Math.max(0,100-Ge/Math.max(Math.abs(ht),1)*100),matchedBy:"user",matchedAt:new Date};return l||He(at=>[...at,dt]),F?.(dt,pe,nt),Ae(new Set),Oe(new Set),dt},[O,fe,D.amountTolerance,l,F]),yt=t.useCallback(I=>{const Q=B.find(pe=>pe.id===I);Q&&(l||He(pe=>pe.filter(nt=>nt.id!==I)),w?.(I,Q.statementIds,Q.entryIds))},[B,l,w]),pt=t.useCallback(async()=>{const I=[],Q=new Set(Ie),pe=new Set(J),nt=D.amountTolerance??.01,ht=D.dateTolerance??3;for(const Se of O){if(Q.has(Se.id))continue;const Ge=fe.filter(We=>{if(pe.has(We.id)||Math.abs(Se.amount-We.amount)>nt)return!1;const at=new Date(Se.date),Nt=new Date(We.date);return!(Math.abs(at.getTime()-Nt.getTime())/(1e3*60*60*24)>ht)});if(Ge.length===1){const We=Ge[0],dt=Be([Se.id],[We.id]);dt&&(I.push(dt),Q.add(Se.id),pe.add(We.id))}}return g?.("autoMatch",I),I},[O,fe,Ie,J,D,Be,g]),wt=t.useCallback((I,Q,pe,nt)=>{nt!==Q&&(nt==="statement"?Be([pe],[I]):Be([I],[pe]),Z(null),Xe(null))},[Be]),Tt=t.useCallback(()=>{const I=Array.from(Ke),Q=Array.from(qe);I.length>0&&Q.length>0&&Be(I,Q)},[Ke,qe,Be]);t.useEffect(()=>{P?.(Array.from(Ke),Array.from(qe))},[Ke,qe,P]),t.useImperativeHandle(s,()=>({getMatches:()=>B,getUnmatchedStatements:()=>O.filter(I=>!Ie.has(I.id)),getUnmatchedEntries:()=>fe.filter(I=>!J.has(I.id)),createMatch:Be,removeMatch:yt,autoMatch:pt,getSuggestions:async I=>y?y(I??O.filter(Q=>!Ie.has(Q.id)).map(Q=>Q.id)):[],applySuggestion:I=>Be([I.statementId],I.entryIds),approveAll:()=>{g?.("approveAll",B)},clearAll:()=>{l||He([]),g?.("clearAll",[])},exportMatched:I=>{g?.("exportMatched",B)},getSummary:()=>he,reset:()=>{l||He([]),Ae(new Set),Oe(new Set),ge({})},focusStatements:()=>je.current?.focus(),focusEntries:()=>re.current?.focus()}),[B,O,fe,Ie,J,Be,yt,pt,y,g,l,he]);const ot=t.useMemo(()=>O.filter(I=>{if(N.status&&N.status.length>0){const Q=Ie.has(I.id)?"matched":"unmatched";if(!N.status.includes(Q))return!1}if(N.searchText){const Q=N.searchText.toLowerCase();if(!I.description?.toLowerCase().includes(Q)&&!I.counterparty?.toLowerCase().includes(Q))return!1}return!0}),[O,N,Ie]),kt=t.useMemo(()=>fe.filter(I=>{if(N.status&&N.status.length>0){const Q=J.has(I.id)?"matched":"unmatched";if(!N.status.includes(Q))return!1}if(N.searchText){const Q=N.searchText.toLowerCase();if(!I.description?.toLowerCase().includes(Q)&&!I.partyName?.toLowerCase().includes(Q))return!1}return!0}),[fe,N,J]),jt=Ke.size>0&&qe.size>0&&!Ce&&!c;return e.jsxs("div",{className:`nice-reconciliation nice-reconciliation--${ue} ${j??""}`,style:ie,children:[ke&&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:pt,disabled:c||Ce||k,children:["⚡ ",se.autoMatch??"Auto-match"]}),e.jsx("button",{type:"button",className:"nice-reconciliation__btn nice-reconciliation__btn--success",onClick:Tt,disabled:!jt||k,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:()=>g?.("approveAll",B),disabled:B.length===0||c||k,children:["✓ ",se.approveAll??"Approve All"]}),e.jsxs("button",{type:"button",className:"nice-reconciliation__btn",onClick:()=>{l||He([]),g?.("clearAll",[])},disabled:B.length===0||c||Ce||k,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:ot.length})]})}),e.jsx("div",{ref:je,className:"nice-reconciliation__panel-content",role:"listbox","aria-multiselectable":"true",children:ot.length===0?e.jsxs("div",{className:"nice-reconciliation__empty",children:[e.jsx("div",{className:"nice-reconciliation__empty-icon",children:"📋"}),se.noStatements??"No statement items"]}):ot.map(I=>e.jsx(sa,{item:{...I,status:Ie.has(I.id)?"matched":"unmatched"},isSelected:Ke.has(I.id),isDragging:Ue===I.id,isDropTarget:we===I.id,suggestion:S.find(Q=>Q.statementId===I.id),currency:Y,locale:ve,onSelect:()=>{c||Ae(Q=>{const pe=new Set(Q);return pe.has(I.id)?pe.delete(I.id):pe.add(I.id),pe})},onDoubleClick:()=>M&&L({type:"statement",id:I.id}),onDragStart:()=>Z(I.id),onDragEnd:()=>{Z(null),Xe(null)},onDrop:()=>{Ue&&Ue!==I.id&&wt(I.id,"statement",Ue,"entry")},disabled:c||Ce||!be},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:kt.length})]})}),e.jsx("div",{ref:re,className:"nice-reconciliation__panel-content",role:"listbox","aria-multiselectable":"true",children:kt.length===0?e.jsxs("div",{className:"nice-reconciliation__empty",children:[e.jsx("div",{className:"nice-reconciliation__empty-icon",children:"📚"}),se.noEntries??"No book entries"]}):kt.map(I=>e.jsx(ra,{item:{...I,status:J.has(I.id)?"matched":"unmatched"},isSelected:qe.has(I.id),isDragging:Ue===I.id,isDropTarget:we===I.id,currency:Y,locale:ve,onSelect:()=>{c||Oe(Q=>{const pe=new Set(Q);return pe.has(I.id)?pe.delete(I.id):pe.add(I.id),pe})},onDoubleClick:()=>M&&L({type:"entry",id:I.id}),onDragStart:()=>Z(I.id),onDragEnd:()=>{Z(null),Xe(null)},onDrop:()=>{Ue&&Ue!==I.id&&wt(I.id,"entry",Ue,"statement")},disabled:c||Ce||!be},I.id))})]})]}),q&&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:[he.matchedStatements,"/",he.totalStatements," (",he.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:$t(he.matchedAmount,Y,ve)})]}),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:$t(he.unmatchedStatementAmount,Y,ve)})]}),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(he.difference)<.01?"nice-reconciliation__summary-value--success":"nice-reconciliation__summary-value--danger"}`,children:$t(he.difference,Y,ve)})]})]}),M&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`nice-reconciliation__detail-backdrop ${H?"nice-reconciliation__detail-backdrop--visible":""}`,onClick:()=>L(null)}),e.jsx("div",{className:`nice-reconciliation__detail-panel ${H?"nice-reconciliation__detail-panel--open":""}`,children:H&&e.jsx(la,{type:H.type,id:H.id,statements:O,entries:fe,matches:B,currency:Y,locale:ve,labels:se,onClose:()=>L(null)})})]})]})});function la({type:n,id:a,statements:s,entries:r,matches:o,currency:p,locale:x,labels:l,onClose:f}){const S=n==="statement"?s.find(F=>F.id===a):r.find(F=>F.id===a),D=n==="statement"?o.find(F=>F.statementIds.includes(a)):o.find(F=>F.entryIds.includes(a)),V=D?n==="statement"?r.filter(F=>D.entryIds.includes(F.id)):s.filter(F=>D.statementIds.includes(F.id)):[];if(!S)return null;const R=n==="statement",ae=R?S:null,X=R?null:S;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-reconciliation__detail-header",children:[e.jsxs("span",{className:"nice-reconciliation__detail-title",children:[R?"📄":"📒"," ",R?l.statementDetails??"Transaction Details":l.entryDetails??"Entry Details"]}),e.jsx("button",{type:"button",className:"nice-reconciliation__detail-close",onClick:f,"aria-label":"Close",children:"✕"})]}),e.jsxs("div",{className:"nice-reconciliation__detail-content",children:[D&&e.jsxs("div",{className:"nice-reconciliation__detail-match-info",children:[e.jsxs("div",{className:"nice-reconciliation__detail-match-header",children:["✓ ",l.matchedWith??"Matched"," (",D.confidence?.toFixed(0)??100,"% confidence)"]}),e.jsx("div",{className:"nice-reconciliation__detail-match-detail",children:D.matchedBy==="ai"?l.matchedByAI??"Matched automatically by AI":l.matchedManually??"Matched manually"}),e.jsxs("div",{className:"nice-reconciliation__detail-side-by-side",children:[e.jsxs("div",{className:"nice-reconciliation__detail-side-item",children:[e.jsx("div",{className:"nice-reconciliation__detail-side-label",children:l.statementTotal??"Statement"}),e.jsx("div",{className:`nice-reconciliation__detail-side-amount ${D.statementTotal>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:$t(D.statementTotal,p,x)})]}),e.jsxs("div",{className:"nice-reconciliation__detail-side-item",children:[e.jsx("div",{className:"nice-reconciliation__detail-side-label",children:l.entryTotal??"Book Entry"}),e.jsx("div",{className:`nice-reconciliation__detail-side-amount ${D.entryTotal>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:$t(D.entryTotal,p,x)})]})]}),D.difference>.01&&e.jsxs("div",{className:"nice-reconciliation__detail-row",style:{marginTop:"0.5rem",borderBottom:"none"},children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[l.difference??"Difference",":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",style:{color:"var(--nice-warning, #f59e0b)"},children:$t(D.difference,p,x)})]})]}),e.jsxs("div",{className:"nice-reconciliation__detail-section",children:[e.jsxs("div",{className:"nice-reconciliation__detail-section-title",children:["📋"," ",R?l.transactionInfo??"Transaction Information":l.entryInfo??"Entry Information"]}),e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[l.date??"Date",":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",children:vn(S.date,x)})]}),e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[l.description??"Description",":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",children:S.description})]}),e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[l.amount??"Amount",":"]}),e.jsx("span",{className:`nice-reconciliation__detail-value ${S.amount>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:$t(S.amount,p,x)})]}),R&&ae?.counterparty&&e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[l.counterparty??"Counterparty",":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",children:ae.counterparty})]}),R&&ae?.counterpartyAccount&&e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[l.accountNumber??"Account",":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",style:{fontFamily:"monospace",fontSize:"0.75rem"},children:ae.counterpartyAccount})]}),!R&&X?.partyName&&e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[l.party??"Party",":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",children:X.partyName})]}),!R&&X?.documentNumber&&e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[l.documentRef??"Document Ref",":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",children:X.documentNumber})]}),R&&ae?.referenceNumber&&e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[l.reference??"Reference",":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",children:ae.referenceNumber})]})]}),V.length>0&&e.jsxs("div",{className:"nice-reconciliation__detail-section",children:[e.jsxs("div",{className:"nice-reconciliation__detail-section-title",children:["🔗"," ",R?l.matchedEntries??"Matched Entries":l.matchedStatements??"Matched Statements"]}),V.map(F=>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:F.description}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",color:"var(--nice-text-secondary)"},children:[e.jsx("span",{children:vn(F.date,x)}),e.jsx("span",{style:{fontWeight:600,color:F.amount>=0?"var(--nice-success)":"var(--nice-danger)"},children:$t(F.amount,p,x)})]})]},F.id))]})]})]})}function oa(n,a,s){const r=new Map,o=[];n.forEach(x=>r.set(String(x[a]),{data:x,children:[],key:String(x[a]),depth:0})),n.forEach(x=>{const l=x[s],f=r.get(String(x[a]));if(l!=null&&l!==""&&r.has(String(l))){const S=r.get(String(l));f.depth=S.depth+1,S.children.push(f)}else o.push(f)});const p=(x,l)=>{x.forEach(f=>{f.depth=l,p(f.children,l+1)})};return p(o,0),o}function si(n,a,s,r=0){return n.map(o=>({data:o,key:String(o[s]),depth:r,children:Array.isArray(o[a])?si(o[a],a,s,r+1):[]}))}function da(n){const a=[],s=r=>{r.forEach(o=>{a.push(o.key),s(o.children)})};return s(n),a}function ua(n,a){const s=[],r=o=>{o.forEach(p=>{s.push(p),p.children.length>0&&a.has(p.key)&&r(p.children)})};return r(n),s}function ri(n,a,s){return!a||!s?n:[...n].sort((o,p)=>{const x=o.data[a]??"",l=p.data[a]??"",f=typeof x=="number"&&typeof l=="number"?x-l:String(x).localeCompare(String(l));return s==="desc"?-f:f}).map(o=>({...o,children:ri(o.children,a,s)}))}function ma({columns:n,data:a,keyField:s="id",parentKeyField:r="parentId",nested:o=!1,childrenField:p="children",expandedKeys:x,onExpandedChange:l,defaultExpandAll:f=!1,sortable:S=!0,sortField:D,sortDirection:V,onSort:R,selectable:ae,selectedKeys:X,onSelectionChange:F,searchable:T,searchPlaceholder:w,striped:g,compact:_,loading:y,emptyText:P,toolbar:$,onRowClick:ce,className:ke,style:z}){const{t:q}=De.$o(),le=t.useMemo(()=>o?si(a,p,s):oa(a,s,r),[a,s,r,o,p]),ue=t.useMemo(()=>da(le),[le]),[be,G]=t.useState(()=>f?new Set(ue):new Set),M=x?new Set(x):be,[k,c]=t.useState({field:"",dir:null}),[Ce,ve]=t.useState(new Set),[se,j]=t.useState(""),ie=D??k.field,O=V??k.dir,fe=X??Ce,Y=t.useMemo(()=>n.filter(Z=>!Z.hidden),[n]),Ee=t.useCallback(Z=>{const we=ie===Z?O==="asc"?"desc":O==="desc"?null:"asc":"asc";R?R(Z,we):c({field:Z,dir:we})},[ie,O,R]),He=t.useCallback(Z=>{const we=new Set(M);we.has(Z)?we.delete(Z):we.add(Z),l?l([...we]):G(we)},[M,l]),Ke=t.useCallback(Z=>{const we=new Set(fe);we.has(Z)?we.delete(Z):we.add(Z),F?F(we):ve(we)},[fe,F]),Ae=t.useMemo(()=>{if(!se)return le;const Z=se.toLowerCase(),we=Xe=>Xe.reduce((N,ge)=>{const H=we(ge.children);return(Y.some(B=>String(ge.data[B.field]??"").toLowerCase().includes(Z))||H.length>0)&&N.push({...ge,children:H}),N},[]);return we(le)},[le,se,Y]),qe=t.useMemo(()=>ri(Ae,ie,O),[Ae,ie,O]),Oe=t.useMemo(()=>ua(qe,M),[qe,M]),Ue=({field:Z})=>ie!==Z||!O?e.jsx("span",{className:"nice-table__sort-icon",style:{opacity:.3},children:"↕"}):e.jsx("span",{className:"nice-table__sort-icon",children:O==="asc"?"↑":"↓"});return e.jsxs("div",{className:`nice-treegrid nice-datagrid ${ke||""}`,style:z,children:[(T||$)&&e.jsxs("div",{className:"nice-datagrid__toolbar",children:[T&&e.jsx("div",{className:"nice-datagrid__search",children:e.jsx("input",{type:"text",value:se,onChange:Z=>j(Z.target.value),placeholder:w||q("controls.search","Search...")})}),$]}),e.jsx("div",{className:"nice-datagrid__table-wrap",children:e.jsxs("table",{className:`${g?"nice-table--striped":""} ${_?"nice-table--compact":""}`,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[ae&&e.jsx("th",{className:"nice-datagrid__checkbox",style:{width:36}}),Y.map(Z=>e.jsxs("th",{style:{width:Z.width,minWidth:Z.minWidth,textAlign:Z.align},className:S&&Z.sortable!==!1?"nice-datagrid__th--sortable":void 0,onClick:()=>S&&Z.sortable!==!1&&Ee(Z.field),children:[Z.header,S&&Z.sortable!==!1&&e.jsx(Ue,{field:Z.field})]},Z.field))]})}),e.jsx("tbody",{children:y?e.jsx("tr",{children:e.jsx("td",{colSpan:Y.length+(ae?1:0),className:"nice-datagrid__empty",children:e.jsx("div",{className:"nice-spinner nice-spinner--md",style:{margin:"0 auto"}})})}):Oe.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:Y.length+(ae?1:0),className:"nice-datagrid__empty",children:P||q("controls.noData","No data available")})}):Oe.map((Z,we)=>{const Xe=fe.has(Z.key),N=Z.children.length>0,ge=M.has(Z.key);return e.jsxs("tr",{className:Xe?"nice-datagrid__row--selected":void 0,onClick:()=>ce?.(Z.data),style:ce?{cursor:"pointer"}:void 0,children:[ae&&e.jsx("td",{className:"nice-datagrid__checkbox",onClick:H=>H.stopPropagation(),children:e.jsx("input",{type:"checkbox",checked:Xe,onChange:()=>Ke(Z.key),"aria-label":`Select row ${Z.key}`})}),Y.map((H,L)=>e.jsxs("td",{style:{textAlign:H.align},children:[L===0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{display:"inline-block",width:Z.depth*20}}),e.jsx("button",{className:`nice-treegrid__toggle ${N?"":"nice-treegrid__toggle--leaf"}`,onClick:B=>{B.stopPropagation(),N&&He(Z.key)},tabIndex:N?0:-1,"aria-expanded":N?ge:void 0,"aria-label":N?ge?"Collapse":"Expand":void 0,children:N?ge?"▾":"▸":""})]}),H.render?H.render(Z.data[H.field],Z.data,we):String(Z.data[H.field]??"")]},H.field))]},Z.key)})})]})})]})}function ci(n){let a="",s=n;for(;s>=0;)a=String.fromCharCode(65+s%26)+a,s=Math.floor(s/26)-1;return a}function Me(n,a){return`${ci(a)}${n+1}`}function it(n){const a=n.match(/^([A-Z]+)(\d+)$/);if(!a)return null;let s=0;for(let r=0;r<a[1].length;r++)s=s*26+(a[1].charCodeAt(r)-64);return{row:parseInt(a[2],10)-1,col:s-1}}function ha(n,a,s=new Set){const r=n.startsWith("=")?n.slice(1).trim():n,o=(T,w)=>{if(!T||!w)return[];const g=[];for(let _=T.row;_<=w.row;_++)for(let y=T.col;y<=w.col;y++){const P=tt(Me(_,y),a,new Set(s));typeof P=="number"&&g.push(P)}return g},p=(T,w)=>{if(!T||!w)return[];const g=[];for(let _=T.row;_<=w.row;_++)for(let y=T.col;y<=w.col;y++)g.push(tt(Me(_,y),a,new Set(s)));return g},x=r.match(/^(\w+)\(([A-Z]+\d+):([A-Z]+\d+)\)$/i);if(x){const T=x[1].toUpperCase(),w=it(x[2].toUpperCase()),g=it(x[3].toUpperCase());switch(T){case"SUM":return o(w,g).reduce((y,P)=>y+P,0);case"AVG":case"AVERAGE":{const _=o(w,g);return _.length>0?_.reduce((y,P)=>y+P,0)/_.length:0}case"COUNT":return o(w,g).length;case"COUNTA":return p(w,g).filter(_=>_!==null&&_!=="").length;case"COUNTBLANK":return p(w,g).filter(_=>_===null||_==="").length;case"MIN":{const _=o(w,g);return _.length?Math.min(..._):0}case"MAX":{const _=o(w,g);return _.length?Math.max(..._):0}case"MEDIAN":{const _=o(w,g).sort((P,$)=>P-$);if(!_.length)return 0;const y=Math.floor(_.length/2);return _.length%2?_[y]:(_[y-1]+_[y])/2}case"STDEV":{const _=o(w,g);if(_.length<2)return 0;const y=_.reduce((P,$)=>P+$,0)/_.length;return Math.sqrt(_.reduce((P,$)=>P+($-y)**2,0)/(_.length-1))}case"PRODUCT":{const _=o(w,g);return _.length?_.reduce((y,P)=>y*P,1):0}}}const l=r.match(/^(SUMIF|COUNTIF)\(([A-Z]+\d+):([A-Z]+\d+)\s*,\s*"?([^"]*)"?\)$/i);if(l){const T=l[1].toUpperCase(),w=it(l[2].toUpperCase()),g=it(l[3].toUpperCase()),_=l[4];if(w&&g){let y=0;for(let P=w.row;P<=g.row;P++)for(let $=w.col;$<=g.col;$++){const ce=tt(Me(P,$),a,new Set(s));(_.startsWith(">")?Number(ce)>Number(_.slice(1)):_.startsWith("<")?Number(ce)<Number(_.slice(1)):String(ce)===_||typeof ce=="number"&&ce===Number(_))&&(y+=T==="SUMIF"?typeof ce=="number"?ce:0:1)}return y}}const f=r.match(/^IF\(([^,]+),\s*([^,]+),\s*([^)]+)\)$/i);if(f){const T=f[1].trim(),w=f[2].trim(),g=f[3].trim(),_=T.match(/^([A-Z]+\d+)\s*([><=!]+)\s*(\S+)$/i);let y=!1;if(_){const ce=tt(_[1].toUpperCase(),a,new Set(s)),ke=isNaN(Number(_[3]))?_[3].replace(/^"|"$/g,""):Number(_[3]),z=_[2],q=typeof ce=="number"?ce:Number(ce)||0,le=typeof ke=="number"?ke:Number(ke)||0;switch(z){case">":y=q>le;break;case"<":y=q<le;break;case">=":y=q>=le;break;case"<=":y=q<=le;break;case"=":case"==":y=q===le;break;case"<>":case"!=":y=q!==le;break}}const P=y?w:g;if(it(P.toUpperCase()))return tt(P.toUpperCase(),a,new Set(s));const $=Number(P);return isNaN($)?P.replace(/^"|"$/g,""):$}const S=r.match(/^CONCAT\((.+)\)$/i);if(S)return S[1].split(",").map(w=>w.trim()).map(w=>{if(w.startsWith('"')&&w.endsWith('"'))return w.slice(1,-1);if(it(w.toUpperCase())){const _=tt(w.toUpperCase(),a,new Set(s));return _!==null?String(_):""}return w}).join("");const D=r.match(/^VLOOKUP\(([^,]+),\s*([A-Z]+\d+):([A-Z]+\d+),\s*(\d+)\)$/i);if(D){let T;it(D[1].trim().toUpperCase())?T=tt(D[1].trim().toUpperCase(),a,new Set(s)):T=isNaN(Number(D[1]))?D[1].replace(/^"|"$/g,""):Number(D[1]);const g=it(D[2].toUpperCase()),_=it(D[3].toUpperCase()),y=parseInt(D[4])-1;if(g&&_)for(let P=g.row;P<=_.row;P++){const $=tt(Me(P,g.col),a,new Set(s));if(String($)===String(T))return tt(Me(P,g.col+y),a,new Set(s))}return null}const V=r.match(/^(ABS|ROUND|FLOOR|CEIL|CEILING|SQRT|LEN|UPPER|LOWER|TRIM|INT)\(([^)]+)\)$/i);if(V){const T=V[1].toUpperCase(),w=V[2].trim();let g;switch(it(w.toUpperCase())?g=tt(w.toUpperCase(),a,new Set(s)):g=isNaN(Number(w))?w.replace(/^"|"$/g,""):Number(w),T){case"ABS":return Math.abs(Number(g)||0);case"ROUND":return Math.round(Number(g)||0);case"FLOOR":return Math.floor(Number(g)||0);case"CEIL":case"CEILING":return Math.ceil(Number(g)||0);case"SQRT":return Math.sqrt(Number(g)||0);case"INT":return Math.trunc(Number(g)||0);case"LEN":return String(g??"").length;case"UPPER":return String(g??"").toUpperCase();case"LOWER":return String(g??"").toLowerCase();case"TRIM":return String(g??"").trim()}}const R=r.match(/^POWER\(([^,]+),\s*([^)]+)\)$/i);if(R){const T=Number(it(R[1].trim().toUpperCase())?tt(R[1].trim().toUpperCase(),a,new Set(s)):R[1].trim())||0,w=Number(it(R[2].trim().toUpperCase())?tt(R[2].trim().toUpperCase(),a,new Set(s)):R[2].trim())||0;return Math.pow(T,w)}if(/^NOW\(\)$/i.test(r))return new Date().toISOString();if(/^TODAY\(\)$/i.test(r))return new Date().toISOString().split("T")[0];if(/^PI\(\)$/i.test(r))return Math.PI;const ae=r.match(/^([A-Z]+\d+)$/i);if(ae)return tt(ae[1].toUpperCase(),a,s);const X=r.match(/^([A-Z]+\d+)\s*([+\-*/])\s*([A-Z]+\d+|\d+\.?\d*)$/i);if(X){const T=X[1].toUpperCase(),w=X[2],g=X[3],_=tt(T,a,s),P=it(g.toUpperCase())?tt(g.toUpperCase(),a,s):parseFloat(g),$=typeof _=="number"?_:0,ce=typeof P=="number"?P:0;switch(w){case"+":return $+ce;case"-":return $-ce;case"*":return $*ce;case"/":return ce!==0?$/ce:null}}const F=parseFloat(r);return isNaN(F)?r:F}function tt(n,a,s){if(s.has(n))return null;s.add(n);const r=a[n];return r?r.formula?ha(r.formula,a,s):r.value:null}function Hn(n,a){return n==null?"":a==="percent"&&typeof n=="number"?`${(n*100).toFixed(1)}%`:a==="currency"&&typeof n=="number"?`$${n.toFixed(2)}`:String(n)}function Qn(n){return{name:n,data:{}}}const li=t.forwardRef(({sheets:n,activeSheet:a,rows:s=50,cols:r=26,showToolbar:o=!0,showFormulaBar:p=!0,showSheetTabs:x=!0,readOnly:l=!1,onChange:f,onActiveSheetChange:S,onCellSelect:D,onCopy:V,onPaste:R,onInsert:ae,onRemove:X,maxUndo:F=50,sortable:T=!1,filterable:w=!1,rangeSelection:g=!0,className:_,style:y,id:P,...$},ce)=>{const ke=De.ks(P),{t:z}=De.$o(),[q,le]=t.useState(()=>n??[Qn(z("spreadsheet.sheet","Sheet")+" 1")]),[ue,be]=t.useState(0),G=n??q,M=a??ue,k=G[M]??G[0],[c,Ce]=t.useState(null),[ve,se]=t.useState(null),[j,ie]=t.useState(!1),[O,fe]=t.useState(null),[Y,Ee]=t.useState(""),He=t.useRef(null),Ke=t.useRef(null),[Ae,qe]=t.useState([]),[Oe,Ue]=t.useState([]),[Z,we]=t.useState(null),Xe=t.useRef({x:0,width:80}),[N,ge]=t.useState(null),[H,L]=t.useState(null),[B,je]=t.useState("");t.useEffect(()=>{O&&He.current&&He.current.focus()},[O]);const re=t.useMemo(()=>{if(!c)return null;const d=ve??c;return{startRow:Math.min(c.row,d.row),startCol:Math.min(c.col,d.col),endRow:Math.max(c.row,d.row),endCol:Math.max(c.col,d.col)}},[c,ve]),Ie=t.useCallback((d,m)=>re?d>=re.startRow&&d<=re.endRow&&m>=re.startCol&&m<=re.endCol:!1,[re]),J=t.useCallback(d=>{qe(m=>{const E=[...m,d.map(K=>({...K,data:{...K.data}}))];return E.length>F?E.slice(-F):E}),Ue([])},[F]),he=t.useCallback((d,m=!0)=>{m&&J(G);const E=d(G);n||le(E),f?.(E)},[G,n,f,J]),Be=t.useCallback(()=>{if(Ae.length===0)return;const d=Ae[Ae.length-1];Ue(m=>[...m,G.map(E=>({...E,data:{...E.data}}))]),qe(m=>m.slice(0,-1)),n||le(d),f?.(d)},[Ae,G,n,f]),yt=t.useCallback(()=>{if(Oe.length===0)return;const d=Oe[Oe.length-1];qe(m=>[...m,G.map(E=>({...E,data:{...E.data}}))]),Ue(m=>m.slice(0,-1)),n||le(d),f?.(d)},[Oe,G,n,f]),pt=t.useCallback(d=>{a||be(d),S?.(d),Ce(null),se(null),fe(null)},[a,S]),wt=t.useCallback((d,m,E)=>{const K=Me(d,m);he(ee=>{const A=ee.map((ne,de)=>de===M?{...ne,data:{...ne.data}}:ne),W=E.startsWith("=");return A[M].data[K]={...A[M].data[K]??{value:null},formula:W?E:void 0,value:W?null:isNaN(Number(E))?E:Number(E)},A})},[M,he]),Tt=t.useCallback((d,m,E)=>{E?.shiftKey&&g&&c?se({row:d,col:m}):(Ce({row:d,col:m}),se(null)),fe(null),D?.(M,d,m)},[M,D,g,c]),ot=t.useCallback((d,m,E)=>{E.button===0&&(Tt(d,m,E),g&&!E.shiftKey&&ie(!0))},[Tt,g]),kt=t.useCallback((d,m)=>{j&&se({row:d,col:m})},[j]);t.useEffect(()=>{if(!j)return;const d=()=>ie(!1);return document.addEventListener("mouseup",d),()=>document.removeEventListener("mouseup",d)},[j]);const jt=t.useCallback((d,m)=>{if(l)return;const E=Me(d,m),K=k.data[E];K?.readOnly||(fe({row:d,col:m}),Ee(K?.formula??(K?.value!=null?String(K.value):"")))},[l,k.data]),I=t.useCallback(()=>{O&&(wt(O.row,O.col,Y),fe(null))},[O,Y,wt]),Q=t.useCallback(d=>{if(d.key==="Enter")I();else if(d.key==="Escape")fe(null);else if(d.key==="Tab"&&(d.preventDefault(),I(),c)){const m=d.shiftKey?Math.max(0,c.col-1):Math.min(r-1,c.col+1);Ce({row:c.row,col:m})}},[I,c,r]),pe=t.useCallback((d,m)=>{if(!c)return;const E=re??{startRow:c.row,startCol:c.col,endRow:c.row,endCol:c.col};he(K=>{const ee=K.map((A,W)=>W===M?{...A,data:{...A.data}}:A);for(let A=E.startRow;A<=E.endRow;A++)for(let W=E.startCol;W<=E.endCol;W++){const ne=Me(A,W);ee[M].data[ne]={...ee[M].data[ne]??{value:null},[d]:m}}return ee})},[c,re,M,he]),nt=t.useCallback(d=>{if(!re||V?.(re)===!1)return;const{startRow:m,startCol:E,endRow:K,endCol:ee}=re,A=[];for(let W=m;W<=K;W++){const ne=[];for(let de=E;de<=ee;de++){const Re=Me(W,de),Pe=k.data[Re],ye=Pe?tt(Re,k.data,new Set):null;ne.push(Hn(ye,Pe?.format))}A.push(ne.join(" "))}d.clipboardData.setData("text/plain",A.join(`
|
|
595
|
+
`)),d.preventDefault()},[re,k.data,V]),ht=t.useCallback(d=>{if(l||!c)return;const m=d.clipboardData.getData("text/plain");if(!m)return;const E=m.split(`
|
|
596
|
+
`).map(K=>K.split(" "));R?.(E,c.row,c.col)!==!1&&(he(K=>{const ee=K.map((A,W)=>W===M?{...A,data:{...A.data}}:A);return E.forEach((A,W)=>{A.forEach((ne,de)=>{const Re=Me(c.row+W,c.col+de),Pe=ne.startsWith("=");ee[M].data[Re]={...ee[M].data[Re]??{value:null},formula:Pe?ne:void 0,value:Pe?null:isNaN(Number(ne))?ne:Number(ne)}})}),ee}),d.preventDefault())},[l,c,M,he,R]),Se=t.useCallback(d=>{he(m=>m.map((K,ee)=>{if(ee!==M)return K;const A={};for(const[W,ne]of Object.entries(K.data)){const de=it(W);de&&(de.row>d?A[Me(de.row+1,de.col)]=ne:A[W]=ne)}return{...K,data:A}})),ae?.("row",d)},[M,he,ae]),Ge=t.useCallback(d=>{he(m=>m.map((K,ee)=>{if(ee!==M)return K;const A={};for(const[W,ne]of Object.entries(K.data)){const de=it(W);de&&(de.col>d?A[Me(de.row,de.col+1)]=ne:A[W]=ne)}return{...K,data:A}})),ae?.("column",d)},[M,he,ae]),We=t.useCallback(d=>{he(m=>m.map((K,ee)=>{if(ee!==M)return K;const A={};for(const[W,ne]of Object.entries(K.data)){const de=it(W);de&&de.row!==d&&(de.row>d?A[Me(de.row-1,de.col)]=ne:A[W]=ne)}return{...K,data:A}})),X?.("row",d)},[M,he,X]),dt=t.useCallback(d=>{he(m=>m.map((K,ee)=>{if(ee!==M)return K;const A={};for(const[W,ne]of Object.entries(K.data)){const de=it(W);de&&de.col!==d&&(de.col>d?A[Me(de.row,de.col-1)]=ne:A[W]=ne)}return{...K,data:A}})),X?.("column",d)},[M,he,X]),at=t.useCallback((d,m)=>{he(E=>E.map((ee,A)=>{if(A!==M)return ee;const W=new Map;for(const[Re,Pe]of Object.entries(ee.data)){const ye=it(Re);ye&&(W.has(ye.row)||W.set(ye.row,{}),W.get(ye.row)[ye.col]=Pe)}const ne=Array.from(W.entries()).sort((Re,Pe)=>{const ye=tt(Me(Re[0],d),ee.data,new Set),Ye=tt(Me(Pe[0],d),ee.data,new Set),St=typeof ye=="number"?ye:Number(ye),Ct=typeof Ye=="number"?Ye:Number(Ye);if(!isNaN(St)&&!isNaN(Ct))return m==="asc"?St-Ct:Ct-St;const Je=String(ye??""),ft=String(Ye??"");return m==="asc"?Je.localeCompare(ft):ft.localeCompare(Je)}),de={};return ne.forEach(([,Re],Pe)=>{for(const[ye,Ye]of Object.entries(Re))de[Me(Pe,Number(ye))]=Ye}),{...ee,data:de,sortColumn:d,sortDirection:m}}))},[M,he]),Nt=t.useCallback((d,m)=>{const E=k.conditionalFormats;if(!E?.length)return;const K=Me(d,m),ee=tt(K,k.data,new Set),A=typeof ee=="number"?ee:Number(ee);for(const W of E){const ne=W.range.match(/^([A-Z]+\d+):([A-Z]+\d+)$/i);if(!ne)continue;const de=it(ne[1].toUpperCase()),Re=it(ne[2].toUpperCase());if(!de||!Re||d<de.row||d>Re.row||m<de.col||m>Re.col)continue;let Pe=!1;switch(W.type){case"greaterThan":Pe=!isNaN(A)&&A>Number(W.value);break;case"lessThan":Pe=!isNaN(A)&&A<Number(W.value);break;case"equalTo":Pe=String(ee)===String(W.value);break;case"between":Pe=!isNaN(A)&&A>=Number(W.value)&&A<=Number(W.value2);break;case"textContains":Pe=String(ee).includes(String(W.value));break;case"isEmpty":Pe=ee===null||ee==="";break;case"isNotEmpty":Pe=ee!==null&&ee!=="";break}if(Pe)return{backgroundColor:W.style.bgColor,color:W.style.color,fontWeight:W.style.bold?"bold":void 0,fontStyle:W.style.italic?"italic":void 0}}},[k.conditionalFormats,k.data]),Gt=t.useCallback(()=>{const d=`${z("spreadsheet.sheet","Sheet")} ${G.length+1}`;he(m=>[...m,Qn(d)]),pt(G.length)},[G.length,he,pt,z]),Jt=t.useCallback(()=>{G.length<=1||(he(d=>d.filter((m,E)=>E!==M)),pt(Math.max(0,M-1)))},[G.length,M,he,pt]),qt=t.useCallback((d,m)=>{m.trim()&&(he(E=>E.map((K,ee)=>ee===d?{...K,name:m.trim()}:K),!1),L(null))},[he]),Zt=t.useMemo(()=>{if(!c)return"";const d=Me(c.row,c.col),m=k.data[d];return m?.formula??(m?.value!=null?String(m.value):"")},[c,k.data]),ut=t.useMemo(()=>{if(!re)return null;const{startRow:d,startCol:m,endRow:E,endCol:K}=re;if(d===E&&m===K)return null;const ee=[];let A=0;for(let W=d;W<=E;W++)for(let ne=m;ne<=K;ne++){const de=Me(W,ne),Re=tt(de,k.data,new Set);Re!==null&&Re!==""&&A++,typeof Re=="number"&&ee.push(Re)}return ee.length===0?{count:A}:{count:A,sum:ee.reduce((W,ne)=>W+ne,0),avg:ee.reduce((W,ne)=>W+ne,0)/ee.length,min:Math.min(...ee),max:Math.max(...ee)}},[re,k.data]),dn=t.useCallback((d,m)=>{m.preventDefault(),m.stopPropagation(),we(d),Xe.current={x:m.clientX,width:k.colWidths?.[d]??80}},[k.colWidths]);t.useEffect(()=>{if(Z===null)return;const d=E=>{const K=E.clientX-Xe.current.x,ee=Math.max(30,Xe.current.width+K);he(A=>A.map((ne,de)=>de===M?{...ne,colWidths:{...ne.colWidths,[Z]:ee}}:ne),!1)},m=()=>we(null);return document.addEventListener("mousemove",d),document.addEventListener("mouseup",m),()=>{document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",m)}},[Z,M,he]);const en=t.useCallback((d,m,E)=>{d.preventDefault(),Ce({row:m,col:E}),ge({x:d.clientX,y:d.clientY})},[]);t.useEffect(()=>{if(!N)return;const d=()=>ge(null);return document.addEventListener("click",d),()=>document.removeEventListener("click",d)},[N]);const Te=t.useCallback(d=>{if((d.ctrlKey||d.metaKey)&&!O){if(d.key==="z"){d.preventDefault(),Be();return}if(d.key==="y"){d.preventDefault(),yt();return}}if(O||!c)return;let{row:m,col:E}=c;switch(d.key){case"ArrowUp":m=Math.max(0,m-1);break;case"ArrowDown":m=Math.min(s-1,m+1);break;case"ArrowLeft":E=Math.max(0,E-1);break;case"ArrowRight":E=Math.min(r-1,E+1);break;case"Enter":jt(m,E);return;case"Delete":case"Backspace":l||(re&&(re.startRow!==re.endRow||re.startCol!==re.endCol)?he(K=>{const ee=K.map((A,W)=>W===M?{...A,data:{...A.data}}:A);for(let A=re.startRow;A<=re.endRow;A++)for(let W=re.startCol;W<=re.endCol;W++)delete ee[M].data[Me(A,W)];return ee}):wt(m,E,""));return;default:if(d.key.length===1&&!d.ctrlKey&&!d.metaKey&&!l){fe({row:m,col:E}),Ee(d.key);return}return}d.preventDefault(),d.shiftKey&&g?se({row:m,col:E}):(Ce({row:m,col:E}),se(null)),D?.(M,m,E)},[O,c,s,r,l,jt,wt,M,D,Be,yt,re,he,g]),Qe=k.frozenRows??0,Le=k.frozenCols??0,Vt=[{value:"text",label:z("spreadsheet.formatText","Text")},{value:"number",label:z("spreadsheet.formatNumber","Number")},{value:"percent",label:z("spreadsheet.formatPercent","Percent")},{value:"currency",label:z("spreadsheet.formatCurrency","Currency")},{value:"date",label:z("spreadsheet.formatDate","Date")}];return e.jsxs("div",{ref:ce,id:ke,className:`nice-spreadsheet ${l?"nice-spreadsheet--readonly":""} ${_??""}`,style:y,onKeyDown:Te,onCopy:nt,onPaste:ht,tabIndex:0,role:"application","aria-label":z("spreadsheet.label","Spreadsheet"),...$,children:[o&&!l&&e.jsxs("div",{className:"nice-spreadsheet__toolbar",role:"toolbar",children:[e.jsx(ze.NiceButton,{variant:"ghost",size:"sm",onClick:Be,disabled:Ae.length===0,title:z("spreadsheet.undo","Undo"),children:"?"}),e.jsx(ze.NiceButton,{variant:"ghost",size:"sm",onClick:yt,disabled:Oe.length===0,title:z("spreadsheet.redo","Redo"),children:"?"}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(ze.NiceButton,{variant:k.data[c?Me(c.row,c.col):""]?.bold?"primary":"ghost",size:"sm",onClick:()=>pe("bold",!k.data[c?Me(c.row,c.col):""]?.bold),title:z("spreadsheet.bold","Bold"),children:e.jsx("strong",{children:"B"})}),e.jsx(ze.NiceButton,{variant:k.data[c?Me(c.row,c.col):""]?.italic?"primary":"ghost",size:"sm",onClick:()=>pe("italic",!k.data[c?Me(c.row,c.col):""]?.italic),title:z("spreadsheet.italic","Italic"),children:e.jsx("em",{children:"I"})}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(ze.NiceButton,{variant:"ghost",size:"sm",onClick:()=>pe("align","left"),title:z("spreadsheet.alignLeft","Align left"),children:"?"}),e.jsx(ze.NiceButton,{variant:"ghost",size:"sm",onClick:()=>pe("align","center"),title:z("spreadsheet.alignCenter","Center"),children:"?"}),e.jsx(ze.NiceButton,{variant:"ghost",size:"sm",onClick:()=>pe("align","right"),title:z("spreadsheet.alignRight","Align right"),children:"?"}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(ze.NiceColorPicker,{value:k.data[c?Me(c.row,c.col):""]?.bgColor??"var(--bg-primary, #ffffff)",onChange:d=>pe("bgColor",d),title:z("spreadsheet.bgColor","Background color"),showInput:!1,showRandom:!1}),e.jsx(ze.NiceColorPicker,{value:k.data[c?Me(c.row,c.col):""]?.color??"var(--text-primary, #000000)",onChange:d=>pe("color",d),title:z("spreadsheet.textColor","Text color"),showInput:!1,showRandom:!1}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(ze.NiceSelect,{size:"sm",value:k.data[c?Me(c.row,c.col):""]?.format??"text",onChange:d=>pe("format",d),options:Vt,"aria-label":z("spreadsheet.format","Cell format")}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(ze.NiceButton,{variant:"ghost",size:"sm",onClick:()=>c&&Se(c.row),title:z("spreadsheet.insertRow","Insert row"),children:"+?"}),e.jsx(ze.NiceButton,{variant:"ghost",size:"sm",onClick:()=>c&&Ge(c.col),title:z("spreadsheet.insertCol","Insert column"),children:"+?"}),e.jsx(ze.NiceButton,{variant:"ghost",size:"sm",onClick:()=>c&&We(c.row),title:z("spreadsheet.deleteRow","Delete row"),children:"-?"}),e.jsx(ze.NiceButton,{variant:"ghost",size:"sm",onClick:()=>c&&dt(c.col),title:z("spreadsheet.deleteCol","Delete column"),children:"-?"})]}),p&&e.jsxs("div",{className:"nice-spreadsheet__formula-bar",children:[e.jsxs("span",{className:"nice-spreadsheet__cell-label",children:[c?Me(c.row,c.col):"",re&&re.startRow!==re.endRow||re&&re.startCol!==re.endCol?`:${Me(re.endRow,re.endCol)}`:""]}),e.jsx(ze.NiceTextInput,{className:"nice-spreadsheet__formula-input",value:O?Y:Zt,onChange:d=>{O?Ee(d):c&&(fe(c),Ee(d))},onKeyDown:Q,readOnly:l,"aria-label":z("spreadsheet.formulaBar","Formula bar")})]}),e.jsx("div",{className:"nice-spreadsheet__grid",ref:Ke,children:e.jsxs("table",{role:"grid","aria-label":k.name,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"nice-spreadsheet__corner"}),Array.from({length:r},(d,m)=>e.jsxs("th",{className:`nice-spreadsheet__col-header ${m<Le?"nice-spreadsheet__col-header--frozen":""}`,style:{width:k.colWidths?.[m]??80,position:m<Le?"sticky":void 0,left:m<Le?m*80+40:void 0,zIndex:m<Le?3:void 0},children:[e.jsx("span",{children:ci(m)}),T&&e.jsx("span",{className:"nice-spreadsheet__sort-trigger",onClick:()=>at(m,k.sortColumn===m&&k.sortDirection==="asc"?"desc":"asc"),title:z("spreadsheet.sort","Sort"),children:(k.sortColumn===m&&k.sortDirection==="asc","?")}),!l&&e.jsx("span",{className:"nice-spreadsheet__col-resize",onMouseDown:E=>dn(m,E)})]},m))]})}),e.jsx("tbody",{children:Array.from({length:s},(d,m)=>e.jsxs("tr",{className:m<Qe?"nice-spreadsheet__row--frozen":"",style:m<Qe?{position:"sticky",top:m*24,zIndex:2}:void 0,children:[e.jsx("td",{className:"nice-spreadsheet__row-header",children:m+1}),Array.from({length:r},(E,K)=>{const ee=Me(m,K),A=k.data[ee];if(A?.mergedInto)return null;const W=c?.row===m&&c?.col===K,ne=Ie(m,K),de=O?.row===m&&O?.col===K,Re=A?tt(ee,k.data,new Set):null,Pe=Nt(m,K),ye=m<Qe||K<Le;return e.jsxs("td",{className:`nice-spreadsheet__cell ${W?"nice-spreadsheet__cell--selected":""} ${ne&&!W?"nice-spreadsheet__cell--in-range":""} ${A?.readOnly?"nice-spreadsheet__cell--readonly":""} ${ye?"nice-spreadsheet__cell--frozen":""}`,style:{textAlign:A?.align,fontWeight:A?.bold?"bold":void 0,fontStyle:A?.italic?"italic":void 0,backgroundColor:Pe?.backgroundColor??A?.bgColor,color:Pe?.color??A?.color,width:k.colWidths?.[K],height:k.rowHeights?.[m],position:ye?"sticky":void 0,left:K<Le?K*80+40:void 0,zIndex:ye?1:void 0,...Pe},colSpan:A?.colSpan,rowSpan:A?.rowSpan,onMouseDown:Ye=>ot(m,K,Ye),onMouseEnter:()=>kt(m,K),onDoubleClick:()=>jt(m,K),onContextMenu:Ye=>en(Ye,m,K),role:"gridcell","aria-selected":W,title:A?.comment,children:[A?.comment&&e.jsx("span",{className:"nice-spreadsheet__comment-indicator"}),de?e.jsx("input",{ref:He,className:"nice-spreadsheet__cell-editor",value:Y,onChange:Ye=>Ee(Ye.target.value),onKeyDown:Q,onBlur:I}):Hn(Re,A?.format)]},K)})]},m))})]})}),N&&!l&&c&&e.jsxs("div",{className:"nice-spreadsheet__context-menu",style:{position:"fixed",left:N.x,top:N.y,zIndex:1e3},children:[e.jsx(ze.NiceButton,{variant:"ghost",size:"sm",onClick:()=>{Se(c.row),ge(null)},children:z("spreadsheet.insertRowAbove","Insert row above")}),e.jsx(ze.NiceButton,{variant:"ghost",size:"sm",onClick:()=>{Se(c.row+1),ge(null)},children:z("spreadsheet.insertRowBelow","Insert row below")}),e.jsx(ze.NiceButton,{variant:"ghost",size:"sm",onClick:()=>{Ge(c.col),ge(null)},children:z("spreadsheet.insertColLeft","Insert column left")}),e.jsx(ze.NiceButton,{variant:"ghost",size:"sm",onClick:()=>{Ge(c.col+1),ge(null)},children:z("spreadsheet.insertColRight","Insert column right")}),e.jsx("hr",{className:"nice-spreadsheet__context-sep"}),e.jsx(ze.NiceButton,{variant:"ghost",size:"sm",onClick:()=>{We(c.row),ge(null)},children:z("spreadsheet.deleteRow","Delete row")}),e.jsx(ze.NiceButton,{variant:"ghost",size:"sm",onClick:()=>{dt(c.col),ge(null)},children:z("spreadsheet.deleteCol","Delete column")})]}),ut&&e.jsxs("div",{className:"nice-spreadsheet__status-bar",children:[e.jsxs("span",{children:[z("spreadsheet.count","Count"),": ",ut.count]}),ut.sum!==void 0&&e.jsxs("span",{children:[z("spreadsheet.sum","Sum"),": ",ut.sum.toFixed(2)]}),ut.avg!==void 0&&e.jsxs("span",{children:[z("spreadsheet.avg","Avg"),": ",ut.avg.toFixed(2)]}),ut.min!==void 0&&e.jsxs("span",{children:[z("spreadsheet.min","Min"),": ",ut.min]}),ut.max!==void 0&&e.jsxs("span",{children:[z("spreadsheet.max","Max"),": ",ut.max]})]}),x&&e.jsxs("div",{className:"nice-spreadsheet__tabs",role:"tablist",children:[G.map((d,m)=>e.jsx("span",{className:"nice-spreadsheet__tab-wrapper",children:H===m?e.jsx(ze.NiceTextInput,{className:"nice-spreadsheet__tab-rename",value:B,onChange:E=>je(E),onBlur:()=>qt(m,B),onKeyDown:E=>{E.key==="Enter"&&qt(m,B),E.key==="Escape"&&L(null)},autoFocus:!0}):e.jsx("span",{onDoubleClick:()=>{l||(L(m),je(d.name))},children:e.jsx(ze.NiceButton,{variant:m===M?"primary":"ghost",size:"sm",onClick:()=>pt(m),children:d.name})})},m)),!l&&e.jsxs(e.Fragment,{children:[e.jsx(ze.NiceButton,{variant:"ghost",size:"sm",onClick:Gt,title:z("spreadsheet.addSheet","Add sheet"),children:"+"}),G.length>1&&e.jsx(ze.NiceButton,{variant:"ghost",size:"sm",onClick:Jt,title:z("spreadsheet.removeSheet","Remove sheet"),children:"�"})]})]})]})});li.displayName="NiceSpreadsheet";const pa=({queries:n,currentFilter:a,currentColumns:s,currentSort:r,onLoad:o,onSave:p,onUpdate:x,onDelete:l,onShare:f,onSetDefault:S,allowSharing:D=!0,allowPinning:V=!0,position:R="dropdown",className:ae,style:X,"data-testid":F})=>{const[T,w]=t.useState(!1),[g,_]=t.useState(""),[y,P]=t.useState(!1),[$,ce]=t.useState(""),[ke,z]=t.useState(""),[q,le]=t.useState(!1),ue=n.filter(c=>c.name.toLowerCase().includes(g.toLowerCase())),be=ue.filter(c=>!c.isShared),G=ue.filter(c=>c.isShared),M=async()=>{if($.trim()){P(!0);try{await p({name:$,description:ke||void 0,filter:a??{},columns:s,sort:r}),le(!1),ce(""),z("")}finally{P(!1)}}},k=c=>e.jsxs("div",{className:"nice-saved-query__item",children:[c.icon&&e.jsx("span",{className:"nice-saved-query__icon","aria-hidden":"true",children:c.icon}),e.jsx("span",{className:"nice-saved-query__name",children:c.name}),c.isDefault&&e.jsx("span",{className:"nice-saved-query__badge nice-saved-query__badge--default",children:"domyślne"}),c.isShared&&e.jsx("span",{className:"nice-saved-query__badge nice-saved-query__badge--shared",children:"udostępnione"}),c.isPinned&&e.jsx("span",{className:"nice-saved-query__badge nice-saved-query__badge--pinned",children:"przypięte"}),e.jsxs("div",{className:"nice-saved-query__actions",children:[e.jsx("button",{onClick:()=>{o(c),w(!1)},type:"button",children:"Wczytaj"}),S&&e.jsx("button",{onClick:()=>S(c.id),type:"button",title:"Ustaw domyślne",children:"★"}),D&&f&&e.jsx("button",{onClick:()=>f(c.id,[]),type:"button",title:"Udostępnij",children:"↗"}),V&&e.jsx("button",{onClick:()=>x(c.id,{...c}),type:"button",title:"Przypnij",children:"📌"}),e.jsx("button",{onClick:()=>l(c.id),type:"button",title:"Usuń","aria-label":`Usuń zapytanie ${c.name}`,children:"✕"})]})]},c.id);return e.jsxs("div",{className:`nice-saved-query nice-saved-query--${R} ${T?"nice-saved-query--open":""} ${ae??""}`,style:X,"data-testid":F,children:[e.jsx("button",{className:"nice-saved-query__trigger",onClick:()=>w(c=>!c),"aria-expanded":T,"aria-haspopup":"listbox",type:"button",children:"Widoki i zapytania"}),T&&e.jsxs("div",{className:"nice-saved-query__panel",role:"dialog","aria-label":"Zarządzanie zapytaniami",children:[e.jsxs("div",{className:"nice-saved-query__search-row",children:[e.jsx("input",{type:"search",placeholder:"Szukaj zapytania…",value:g,onChange:c=>_(c.target.value),"aria-label":"Szukaj zapytania"}),e.jsx("button",{onClick:()=>le(c=>!c),type:"button",children:"+ Zapisz bieżący widok"})]}),q&&e.jsxs("div",{className:"nice-saved-query__save-form",children:[e.jsx("input",{type:"text",placeholder:"Nazwa zapytania",value:$,onChange:c=>ce(c.target.value),"aria-label":"Nazwa zapytania"}),e.jsx("input",{type:"text",placeholder:"Opis (opcjonalnie)",value:ke,onChange:c=>z(c.target.value),"aria-label":"Opis zapytania"}),e.jsx("button",{onClick:M,disabled:y||!$.trim(),type:"button",children:y?"Zapisywanie…":"Zapisz"}),e.jsx("button",{onClick:()=>le(!1),type:"button",children:"Anuluj"})]}),be.length>0&&e.jsxs("section",{className:"nice-saved-query__group","aria-labelledby":"nice-saved-query-mine",children:[e.jsx("h3",{id:"nice-saved-query-mine",className:"nice-saved-query__group-title",children:"Moje"}),be.map(k)]}),G.length>0&&e.jsxs("section",{className:"nice-saved-query__group","aria-labelledby":"nice-saved-query-shared",children:[e.jsx("h3",{id:"nice-saved-query-shared",className:"nice-saved-query__group-title",children:"Udostępnione"}),G.map(k)]}),ue.length===0&&e.jsx("p",{className:"nice-saved-query__empty",children:"Brak zapisanych zapytań"})]})]})};exports.NiceCardView=zi;exports.NiceDataGrid=yn;exports.NiceDataGrid$1=Si;exports.NiceDataGridAI=Ii;exports.NiceKanbanBoard=ai;exports.NiceList=Ri;exports.NiceModuleGrid=ta;exports.NicePivotGrid=ii;exports.NicePivotGrid$1=Pi;exports.NicePivotGridFieldChooser=ni;exports.NiceReconciliationView=ca;exports.NiceSavedQueryPanel=pa;exports.NiceSpreadsheet=li;exports.NiceTable=wi;exports.NiceTileView=Ti;exports.NiceTreeGrid=ma;exports.NiceTreeList=$i;exports.NiceTreeView=Ei;exports.computeAggregate=ei;exports.escapeCsvField=ln;
|