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