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