@nice2dev/ui 1.3.8 → 1.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +107 -0
- package/dist/NiceColorPicker-BLwYNSXJ.cjs +1 -0
- package/dist/NiceColorPicker-DS59tNkP.js +552 -0
- package/dist/NiceDataGrid-CL2_7fS7.cjs +10 -0
- package/dist/NiceDataGrid-CpJrRN_H.js +2269 -0
- package/dist/NiceForm-BQj-K7p7.cjs +1 -0
- package/dist/NiceForm-HQ4h7hX_.js +5023 -0
- package/dist/NiceGantt-BygumlaY.cjs +1 -0
- package/dist/NiceGantt-DTC7OH-v.js +334 -0
- package/dist/NiceHtmlEditor-BtpuaLln.js +901 -0
- package/dist/NiceHtmlEditor-C1OVtLQ6.cjs +10 -0
- package/dist/NiceMention-CVxxCVtQ.js +11668 -0
- package/dist/NiceMention-Te66Oid1.cjs +430 -0
- package/dist/NiceModuleLifecyclePanel-DCrFyUH8.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-Mt80MdET.js +7441 -0
- package/dist/NicePagination-CKsAP38Q.cjs +1 -0
- package/dist/NicePagination-zOed5QxG.js +202 -0
- package/dist/NicePivotGrid-Clue9FM5.js +1184 -0
- package/dist/NicePivotGrid-Cnkr9WkC.cjs +152 -0
- package/dist/NiceSavedQueryPanel-B8hVgWR2.cjs +587 -0
- package/dist/NiceSavedQueryPanel-BFtY9GOP.js +6002 -0
- package/dist/NiceSavedQueryPanel-NgG58w6i.js +6226 -0
- package/dist/NiceSavedQueryPanel-lTWY2plm.cjs +587 -0
- package/dist/NiceScheduler-BWwqFKEc.js +1712 -0
- package/dist/NiceScheduler-DqWEJU7g.cjs +5 -0
- package/dist/NiceSelect-BNPXs6FQ.cjs +1 -0
- package/dist/NiceSelect-DEruWHan.js +495 -0
- package/dist/NiceTree.doc-AIR9cRQp.js +40 -0
- package/dist/NiceTree.doc-DGrIAx3G.cjs +16 -0
- package/dist/NiceWindow-D3V7A69Q.js +2247 -0
- package/dist/NiceWindow-pgR4c-kQ.cjs +1 -0
- package/dist/core-lazy-Bjdu111n.js +351 -0
- package/dist/core-lazy-Bx_8BOlG.cjs +1 -0
- package/dist/data.cjs +1 -1
- package/dist/data.d.ts +189 -14
- package/dist/data.mjs +3 -3
- package/dist/devops-CqhA0rjL.js +9130 -0
- package/dist/devops-cgRBnZVX.cjs +18 -0
- package/dist/devops.cjs +1 -1
- package/dist/devops.mjs +1 -1
- package/dist/editors.cjs +1 -1
- package/dist/editors.mjs +7 -7
- package/dist/feedback.cjs +1 -1
- package/dist/feedback.mjs +1 -1
- package/dist/index.cjs +130 -130
- package/dist/index.css +1 -1
- package/dist/index.d.ts +193 -17
- package/dist/index.mjs +14780 -14657
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.mjs +15 -15
- package/dist/navigation.cjs +1 -1
- package/dist/navigation.d.ts +2 -0
- package/dist/navigation.mjs +3 -3
- package/dist/no-code-BQqK8mvU.cjs +331 -0
- package/dist/no-code-Cppb-xz3.js +8320 -0
- package/dist/no-code.cjs +1 -1
- package/dist/no-code.mjs +1 -1
- package/dist/overlays.cjs +1 -1
- package/dist/overlays.mjs +1 -1
- package/dist/pickerCommons-BA3-D5RC.js +663 -0
- package/dist/pickerCommons-KrBqCBDn.cjs +1 -0
- package/dist/style.css +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,587 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),hi=require("@nice2dev/i18n"),N=require("@nice2dev/ui-core"),n=require("react"),mi=require("./NiceDataGrid-CL2_7fS7.cjs"),He=require("./NiceButton-DzCqkG5a.cjs"),fi=require("./NiceForm-BQj-K7p7.cjs"),pi=require("./NiceModal-BRVzjuUN.cjs"),gi=require("./core-lBFqvT0V.cjs"),_i=require("./NiceSelect-BNPXs6FQ.cjs"),Ln=require("./no-code-BQqK8mvU.cjs"),Pn=require("./NiceColorPicker-BLwYNSXJ.cjs"),bi=[];function xi(t,a){return t.filter(s=>a.every(r=>{const l=s[r.field],o=r.value;switch(r.operator){case"eq":return l===o;case"ne":return l!==o;case"gt":return typeof l=="number"&&typeof o=="number"&&l>o;case"gte":return typeof l=="number"&&typeof o=="number"&&l>=o;case"lt":return typeof l=="number"&&typeof o=="number"&&l<o;case"lte":return typeof l=="number"&&typeof o=="number"&&l<=o;case"contains":return String(l).toLowerCase().includes(String(o).toLowerCase());case"startsWith":return String(l).toLowerCase().startsWith(String(o).toLowerCase());case"endsWith":return String(l).toLowerCase().endsWith(String(o).toLowerCase());default:return!0}}))}function yi(t){return t.map(a=>({field:a.field,type:a.dataType||"string",label:typeof a.header=="string"?a.header:a.field}))}function vi(t,a){const{enableAI:s=!0,aiModel:r,enableNLSearch:l=!0,enableInsights:o=!0,nlPlaceholder:d,onAIFilter:c,onInsights:f,showAISearchBar:m=!0,exampleQueries:w=["Show items from last week","Filter by status = active","Orders over $1000",'Names starting with "A"'],columns:E=bi,data:P,...R}=t,[T,K]=n.useState(""),[p,b]=n.useState([]),[I,_]=n.useState([]),[z,C]=n.useState(!1),[G,H]=n.useState(null),he=n.useRef(null),{t:se}=hi.useNiceTranslation(),fe=N.useNiceAI(),{parseFilter:Ie,isLoading:ee}=N.useNaturalLanguageFilter(),we=s&&fe.isConfigured,B=p.length>0?xi(P||[],p):P,$e=n.useCallback(async A=>{if(!we||!l||!A.trim())return;H(A);const g=yi(E);try{const pe=await Ie(A,g);b(pe),c?.(A,pe)}catch{b([])}},[we,l,E,Ie,c]),ke=n.useCallback(()=>{b([]),H(null),K("")},[]),Pe=n.useCallback(()=>p,[p]),Z=n.useCallback(async()=>{if(!we||!o||!P?.length)return[];try{const A=await fe.complete([{role:"user",content:`Analyze this data and provide 3-5 key insights. Data sample (${P.length} total rows): ${JSON.stringify(P.slice(0,20))}
|
|
2
|
+
|
|
3
|
+
Columns: ${E.map(g=>g.field).join(", ")}
|
|
4
|
+
|
|
5
|
+
Return a JSON array of insight strings. Be specific with numbers and trends.`}],{temperature:.3,maxTokens:500});try{const g=JSON.parse(A.content),pe=Array.isArray(g)?g:[];return _(pe),f?.(pe),pe}catch{return[]}}catch{return[]}},[we,o,P,E,fe,f]),$=A=>{A.preventDefault(),T.trim()&&$e(T)},O=A=>{K(A),$e(A)};return n.useImperativeHandle(a,()=>({applyNLFilter:$e,clearAIFilters:ke,getAIFilters:Pe,generateInsights:Z})),e.jsxs("div",{className:"nice-data-grid-ai","data-testid":t["data-testid"],children:[m&&we&&l&&e.jsxs("div",{className:"nice-data-grid-ai__search-bar",children:[e.jsx("div",{className:"nice-data-grid-ai__search-left",children:e.jsx("span",{className:"nice-data-grid-ai__badge",children:se("dataGridAI.ai","AI")})}),e.jsxs("form",{onSubmit:$,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(N.NiceIcon,{name:"search",size:14})}),e.jsx("input",{ref:he,type:"text",value:T,onChange:A=>K(A.target.value),placeholder:d||se("dataGridAI.searchPlaceholder","Search with natural language..."),className:"nice-data-grid-ai__input",disabled:ee}),ee&&e.jsx("span",{className:"nice-data-grid-ai__loading-spinner"}),T&&!ee&&e.jsx("button",{type:"button",className:"nice-data-grid-ai__clear-input",onClick:()=>K(""),"aria-label":se("dataGridAI.clearInput","Clear"),children:e.jsx(N.NiceIcon,{name:"close",size:14})})]}),e.jsx("button",{type:"submit",className:"nice-data-grid-ai__search-btn",disabled:ee||!T.trim(),children:ee?se("dataGridAI.searching","Searching..."):se("dataGridAI.search","Search")})]}),o&&e.jsxs("button",{type:"button",className:"nice-data-grid-ai__insights-btn",onClick:()=>{Z(),C(!0)},disabled:ee||!P?.length,title:se("dataGridAI.generateInsights","Generate AI Insights"),children:[e.jsx(N.NiceIcon,{name:"lightbulb",size:14})," ",se("dataGridAI.insights","Insights")]})]}),m&&we&&l&&!G&&w.length>0&&e.jsxs("div",{className:"nice-data-grid-ai__examples",children:[e.jsx("span",{className:"nice-data-grid-ai__examples-label",children:se("dataGridAI.tryAsking","Try asking:")}),e.jsx("div",{className:"nice-data-grid-ai__examples-list",children:w.slice(0,4).map((A,g)=>e.jsxs("button",{type:"button",className:"nice-data-grid-ai__example",onClick:()=>O(A),children:['"',A,'"']},g))})]}),G&&p.length>0&&e.jsxs("div",{className:"nice-data-grid-ai__active-filter",children:[e.jsxs("div",{className:"nice-data-grid-ai__filter-info",children:[e.jsx("span",{className:"nice-data-grid-ai__filter-icon",children:e.jsx(N.NiceIcon,{name:"target",size:14})}),e.jsxs("span",{className:"nice-data-grid-ai__filter-query",children:['"',G,'"']}),e.jsxs("span",{className:"nice-data-grid-ai__filter-count",children:["(",B?.length||0," ",se("dataGridAI.results","results"),")"]})]}),e.jsx("div",{className:"nice-data-grid-ai__filter-badges",children:p.map((A,g)=>e.jsxs("span",{className:"nice-data-grid-ai__filter-badge",children:[A.field," ",A.operator," ",String(A.value)]},g))}),e.jsxs("button",{type:"button",className:"nice-data-grid-ai__clear-filter",onClick:ke,children:[e.jsx(N.NiceIcon,{name:"close",size:14})," ",se("dataGridAI.clearFilter","Clear")]})]}),e.jsx("div",{className:"nice-data-grid-ai__grid-wrapper",children:e.jsx(mi.NiceDataGrid,{columns:E,data:B,...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:[e.jsx(N.NiceIcon,{name:"lightbulb",size:14})," ",se("dataGridAI.aiInsights","AI Insights")]}),e.jsx("button",{type:"button",className:"nice-data-grid-ai__insights-close",onClick:()=>C(!1),"aria-label":se("dataGridAI.closeInsights","Close"),children:e.jsx(N.NiceIcon,{name:"close",size:14})})]}),e.jsx("div",{className:"nice-data-grid-ai__insights-body",children:ee?e.jsx("div",{className:"nice-data-grid-ai__insights-loading",children:se("dataGridAI.analyzing","Analyzing data...")}):I.length>0?e.jsx("ul",{className:"nice-data-grid-ai__insights-list",children:I.map((A,g)=>e.jsxs("li",{className:"nice-data-grid-ai__insight",children:[e.jsx("span",{className:"nice-data-grid-ai__insight-bullet",children:"•"}),A]},g))}):e.jsx("div",{className:"nice-data-grid-ai__insights-empty",children:se("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:()=>Z(),disabled:ee,children:[e.jsx(N.NiceIcon,{name:"refresh",size:14})," ",se("dataGridAI.refresh","Refresh")]})})]})]})}const ki=n.forwardRef(vi);function Ni(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}const yn=({text:t,query:a,highlightTag:s="mark",highlightClassName:r="",caseSensitive:l=!1,className:o="",style:d,testId:c,"data-testid":f})=>{const m=(Array.isArray(a)?a:[a]).map(R=>(R??"").trim()).filter(Boolean).map(Ni);if(m.length===0||!t)return e.jsx("span",{className:`nice-highlight ${o}`,style:d,"data-testid":f??c,children:t});const w=l?"g":"gi",E=new RegExp(`(${m.join("|")})`,w),P=t.split(E);return e.jsx("span",{className:`nice-highlight ${o}`,style:d,"data-testid":f??c,children:P.map((R,T)=>T%2===1?e.jsx(s,{className:`nice-highlight__mark ${r}`.trim(),children:R},T):e.jsx(n.Fragment,{children:R},T))})};process.env.NODE_ENV!=="production"&&(yn.displayName="NiceHighlight");function wi(t,a,s,r=0){const l=new Map,o=[];t.forEach(c=>l.set(String(c[a]),{data:c,children:[],key:String(c[a]),depth:0})),t.forEach(c=>{const f=c[s],m=l.get(String(c[a]));if(f!=null&&f!==""&&l.has(String(f))){const w=l.get(String(f));m.depth=w.depth+1,w.children.push(m)}else o.push(m)});const d=(c,f)=>{c.forEach(m=>{m.depth=f,d(m.children,f+1)})};return d(o,r),o}function ji(t,a,s){const r=l=>l.map(o=>{const d=o.children.length===0?a.get(o.key):void 0,c=d?s(d,o.depth+1):o.children;return c.length>0?{...o,children:r(c)}:o});return r(t)}function Si(t,a){const s=[],r=l=>{a(l)&&s.push(l.key),l.children.forEach(r)};return r(t),s}function Wn(t,a,s,r=0){return t.map(l=>({data:l,key:String(l[s]),depth:r,children:Array.isArray(l[a])?Wn(l[a],a,s,r+1):[]}))}function bn(t){const a=[],s=r=>{r.forEach(l=>{l.children.length>0&&(a.push(l.key),s(l.children))})};return s(t),a}function Ci(t){const a=[],s=r=>{r.forEach(l=>{a.push(l.key),s(l.children)})};return s(t),a}function Qn(t,a,s){return!a||!s?t:[...t].sort((l,o)=>{const d=l.data[a]??"",c=o.data[a]??"",f=typeof d=="number"&&typeof c=="number"?d-c:String(d).localeCompare(String(c));return s==="desc"?-f:f}).map(l=>({...l,children:Qn(l.children,a,s)}))}function Ii(t,a,s){const r=new Set,l=new Set,o=d=>d.reduce((c,f)=>{const m=o(f.children),w=a(f);return w&&l.add(f.key),m.length>0&&r.add(f.key),w&&s?c.push(f):(w||m.length>0)&&c.push({...f,children:m}),c},[]);return{tree:o(t),expand:r,matched:l}}function Mi(t,a){const s=(r,l)=>r.reduce((o,d)=>{if(l)return o.push({...d,children:s(d.children,!0)}),o;if(a.isCheckable(d.key)){const f=a.state(d.key);if(f!=="unchecked"){const m=a.isLeaf(d.key)&&f==="checked";o.push({...d,children:s(d.children,m)})}return o}const c=s(d.children,!1);return c.length>0&&o.push({...d,children:c}),o},[]);return s(t,!1)}function Di(t,a,s){const r=[],l=(o,d)=>{o.forEach((c,f)=>{if(r.push({node:c,level:d,posInSet:f+1,setSize:o.length}),c.children.length>0)a(c.key)&&l(c.children,d+1);else if(s&&a(c.key)){const m=s(c);m&&r.push({node:c,level:d+1,posInSet:1,setSize:1,placeholder:m})}})};return l(t,1),r}function vn(t,a,s={}){const{getKey:r,getChildren:l,isCheckable:o,isDisabled:d}=a,c=s.inheritDisabled!==!1,f=[],m=[],w=[],E=new Map,P=(T,K,p,b)=>{const I=r(T);if(E.has(I))return;const _=o?o(T):!0,z=(d?d(T):!1)||c&&b,C={pos:f.length,subtreeEnd:0,leafStart:m.length,leafEnd:0,checkable:_,leaf:!1,disabled:z,parent:p};E.set(I,C),f.push(I);const G=l(T,K);if(G)for(const H of G)P(H,K+1,I,z);_&&m.length===C.leafStart&&(C.leaf=!0,m.push(I),w.push(z)),C.leafEnd=m.length,C.subtreeEnd=f.length};for(const T of t)P(T,0,void 0,!1);const R=new Int32Array(m.length+1);for(let T=0;T<m.length;T++)R[T+1]=R[T]+(w[T]?1:0);return{keys:f,leaves:m,records:E,lockedBefore:R,has:T=>E.has(T),isCheckable:T=>E.get(T)?.checkable??!1,isLeaf:T=>E.get(T)?.leaf??!1,isLocked:T=>{const K=E.get(T);if(!K)return!1;const p=K.leafEnd-K.leafStart;return K.disabled||p===0?K.disabled:R[K.leafEnd]-R[K.leafStart]===p},leavesOf:T=>{const K=E.get(T);return K?m.slice(K.leafStart,K.leafEnd):[]},parentOf:T=>E.get(T)?.parent}}function kn(t,a){const s=new Set,r=[];if(!a)return{leaves:s,unknown:r};const l=new Set;for(const o of a){const d=t.records.get(o);if(!d){l.has(o)||(l.add(o),r.push(o));continue}if(d.checkable)for(let c=d.leafStart;c<d.leafEnd;c++)s.add(t.leaves[c])}return{leaves:s,unknown:r}}function sn(t,a){const s=new Int32Array(t.leaves.length+1);for(let d=0;d<t.leaves.length;d++)s[d+1]=s[d]+(a.has(t.leaves[d])?1:0);const r=d=>{const c=t.records.get(d);return c?{checked:s[c.leafEnd]-s[c.leafStart],total:c.leafEnd-c.leafStart}:{checked:0,total:0}},l=d=>{const{checked:c,total:f}=r(d);return c===0||f===0?"unchecked":c===f?"checked":"indeterminate"},o=[];for(const d of t.keys){const c=t.records.get(d);c.checkable&&!c.leaf&&l(d)==="indeterminate"&&o.push(d)}return{state:l,count:r,total:{checked:s[t.leaves.length],total:t.leaves.length},halfChecked:o}}function Nn(t,a,s,r){const l=t.records.get(s);if(!l||!l.checkable)return a;const o=[];for(let c=l.leafStart;c<l.leafEnd;c++)t.lockedBefore[c+1]===t.lockedBefore[c]&&o.push(t.leaves[c]);if(o.length===0)return a;const d=!o.every(c=>a.has(c));return qn(a,o,d)}function On(t,a,s,r){const l=[];for(const o of s){const d=t.records.get(o);d?.leaf&&!d.disabled&&l.push(o)}return l.length===0?a:qn(a,l,r)}function qn(t,a,s){const r=new Set(t);for(const l of a)s?r.add(l):r.delete(l);return r}function Ht(t,a,s,r=[]){const l=[];if(s==="leaves")for(const o of t.leaves)a.has(o)&&l.push(o);else{const o=new Int32Array(t.leaves.length+1);for(let c=0;c<t.leaves.length;c++)o[c+1]=o[c]+(a.has(t.leaves[c])?1:0);const d=c=>c.leafEnd>c.leafStart&&o[c.leafEnd]-o[c.leafStart]===c.leafEnd-c.leafStart;for(let c=0;c<t.keys.length;){const f=t.keys[c],m=t.records.get(f);if(m.checkable&&d(m)&&(l.push(f),s==="parents")){c=m.subtreeEnd;continue}c++}}for(const o of r)l.push(o);return l}const Ei=[],Ai=[],xn=[],Ri=new Set,Ti=new Map,zi=[],$i=new Map,Li=new Map,Fn=["expandAll","collapseAll","onlyChecked","clearChecked"],Vn=10;function Pi({node:t,level:a,posInSet:s,setSize:r,rowIndex:l,ariaRowIndex:o,columns:d,highlight:c,query:f,expandable:m,expanded:w,busy:E,expandLabel:P,collapseLabel:R,subtreeAction:T,subtreeLabel:K,checkMode:p,hasCheckbox:b,checkState:I,checkLabel:_,locked:z,countChecked:C,countTotal:G,countTitle:H,selectColumn:he,selected:se,selectLabel:fe,readOnly:Ie,className:ee,clickable:we,height:B,handlers:$e}){const ke=b?e.jsx("input",{type:"checkbox",className:"nice-treegrid__check-input",checked:I==="checked",ref:Z=>{Z&&(Z.indeterminate=I==="indeterminate")},disabled:z||Ie,tabIndex:-1,"aria-label":_,onClick:Z=>Z.stopPropagation(),onChange:Z=>{$e.toggleCheck(t.key),Z.currentTarget.closest("tr")?.focus({preventScroll:!0})}}):null,Pe=["nice-treegrid__row",p!=="none"&&!b?"nice-treegrid__row--info":"",z?"nice-treegrid__row--disabled":"",b&&I==="checked"?"nice-treegrid__row--checked":"",se?"nice-datagrid__row--selected":"",ee??""].filter(Boolean).join(" ");return e.jsxs("tr",{className:Pe,"data-key":t.key,tabIndex:-1,"aria-level":a,"aria-posinset":s,"aria-setsize":r,"aria-rowindex":o,"aria-expanded":m?w:void 0,"aria-selected":se,"aria-disabled":z||void 0,"aria-busy":E||void 0,onClick:()=>$e.rowClick(t),style:we||B!==void 0?{cursor:we?"pointer":void 0,height:B}:void 0,children:[p==="column"&&e.jsx("td",{className:"nice-datagrid__checkbox nice-treegrid__check-cell",children:ke}),he&&e.jsx("td",{className:"nice-datagrid__checkbox",children:e.jsx("input",{type:"checkbox",checked:!!se,onChange:()=>$e.toggleSelected(t.key),onClick:Z=>Z.stopPropagation(),disabled:Ie,tabIndex:-1,"aria-label":fe})}),d.map((Z,$)=>{const O=t.data[Z.field];return e.jsxs("td",{style:{textAlign:Z.align},children:[$===0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"nice-treegrid__indent",style:{width:(a-1)*20}}),e.jsx("button",{type:"button",className:`nice-treegrid__toggle ${m?"":"nice-treegrid__toggle--leaf"}`,onClick:A=>{A.stopPropagation(),m&&$e.toggleExpand(t.key,A.altKey||A.shiftKey)},tabIndex:-1,"aria-hidden":m?void 0:!0,"aria-label":m?w?R:P:void 0,children:m?e.jsx(N.NiceIcon,{name:w?"chevron-down":"chevron-right",size:12}):""}),p==="tree"&&e.jsx("span",{className:`nice-treegrid__check${b?"":" nice-treegrid__check--none"}`,children:ke})]}),Z.render?Z.render(O,t.data,l):c[$]&&f?e.jsx(yn,{text:String(O??""),query:f,highlightClassName:"nice-treegrid__match"}):String(O??""),$===0&&G>0&&e.jsxs("span",{className:`nice-treegrid__count${C===G?" nice-treegrid__count--full":""}`,title:H,children:[C,"/",G]}),$===0&&T&&e.jsx("button",{type:"button",className:"nice-treegrid__row-action",tabIndex:-1,"aria-label":K,title:K,onClick:A=>{A.stopPropagation(),$e.setSubtreeExpanded(t.key,T==="expand")},children:e.jsx(N.NiceIcon,{name:T==="expand"?"expand":"collapse",size:12})})]},Z.field)})]})}const Oi=n.memo(Pi);function Fi({columns:t=Ei,data:a=Ai,keyField:s="id",parentKeyField:r="parentId",nested:l=!1,childrenField:o="children",expandedKeys:d,defaultExpandedKeys:c,onExpandedChange:f,hasChildren:m,loadChildren:w,rowActions:E,defaultExpandAll:P=!1,sortable:R=!0,sortField:T,sortDirection:K,onSort:p,selectable:b,selectedKeys:I,onSelectionChange:_,checkable:z,checkedKeys:C,defaultCheckedKeys:G,onCheckedChange:H,checkStrategy:he="all",isRowCheckable:se,isRowDisabled:fe,checkboxPlacement:Ie="tree",checkOnRowClick:ee,showCheckedCount:we,checkedSummary:B,showSelectAll:$e=!0,showOnlyChecked:ke,defaultShowOnlyChecked:Pe,onShowOnlyCheckedChange:Z,toolbarActions:$,searchable:O,searchPlaceholder:A,searchText:g,defaultSearchText:pe,onSearchChange:re,searchFields:k,searchFilter:ae,searchKeepDescendants:de=!1,searchAutoExpand:ge=!0,highlightMatches:D=!0,rowClassName:le,getRowLabel:_e,virtualScroll:ze,rowHeight:oe=36,height:je,striped:Le,compact:Me,size:Se="md",loading:ct,disabled:it,readOnly:at,error:ve,emptyText:W,toolbar:be,onRowClick:De,className:qe,style:Re,id:ie,testId:J,"data-testid":v,accessMode:xe,"aria-label":te,"aria-labelledby":Ve}){const{t:ue}=N.useNiceTranslation(),Ue=N.useNiceAccessMode(xe,ie),Ke=!!it||Ue==="disabled",S=!!at||Ue==="readOnly",X=n.useCallback((i,j)=>l?Wn(i,o,s,j):wi(i,s,r,j),[s,r,l,o]),me=n.useMemo(()=>X(a,0),[X,a]),[Ee,st]=n.useState($i),[Q,Ae]=n.useState(Li),Fe=n.useMemo(()=>Ee.size>0?ji(me,Ee,X):me,[me,Ee,X]),Ge=n.useMemo(()=>{const i=new Map,j=Y=>Y.forEach(ce=>{i.set(ce.key,ce),j(ce.children)});return j(Fe),i},[Fe]),We=!!m||!!w,Qe=n.useCallback(i=>{if(!We)return!1;const j=Ge.get(i);return!!j&&j.children.length===0&&!Ee.has(i)&&(m?m(j.data):!0)},[We,Ge,Ee,m]),Mt=n.useRef(new Set),Dt=n.useRef(!0);n.useEffect(()=>(Dt.current=!0,()=>{Dt.current=!1}),[]);const Ft=n.useCallback(i=>{const j=Ge.get(i);if(!w||!j||Mt.current.has(i))return;Mt.current.add(i);const Y=ce=>{Mt.current.delete(i),Dt.current&&(ce&&st(Xe=>new Map(Xe).set(i,ce)),Ae(Xe=>{const rt=new Map(Xe);return ce?rt.delete(i):rt.set(i,"error"),rt}))};Ae(ce=>new Map(ce).set(i,"loading")),w(j.data).then(ce=>Y(Array.isArray(ce)?ce:[]),()=>Y(null))},[w,Ge]),Ut=n.useCallback(i=>{Ae(j=>{const Y=new Map(j);return Y.delete(i),Y})},[]),gt=n.useMemo(()=>t.filter(i=>!i.hidden),[t]),Lt=n.useMemo(()=>bn(Fe),[Fe]),[Pt,lt]=n.useState(null),Ze=n.useMemo(()=>{if(d)return new Set(d);if(Pt)return Pt;const i=new Set(c??xn);return P&&Lt.forEach(j=>i.add(j)),i},[d,Pt,c,P,Lt]),At=n.useRef(Ze);At.current=Ze;const Rt=n.useCallback(i=>{At.current=i,d||lt(i),f?.([...i])},[d,f]),[ot,Tt]=n.useState({field:"",dir:null}),et=T??ot.field,dt=K??ot.dir,h=n.useCallback(i=>{const j=et===i?dt==="asc"?"desc":dt==="desc"?null:"asc":"asc";p?p(i,j):Tt({field:i,dir:j})},[et,dt,p]),[u,M]=N.useControllableState({value:I,fallbackValue:Ri,onChange:_,componentName:"NiceTreeGrid"}),U=n.useCallback(i=>{M(j=>{const Y=new Set(j);return Y.has(i)?Y.delete(i):Y.add(i),Y})},[M]),x=n.useMemo(()=>z?vn(Fe,{getKey:i=>i.key,getChildren:i=>i.children,isCheckable:se?i=>se(i.data):void 0,isDisabled:fe?i=>fe(i.data):void 0}):null,[z,Fe,se,fe]),[L,F]=N.useControllableState({value:C,defaultValue:G,fallbackValue:xn,componentName:"NiceTreeGrid"}),V=n.useMemo(()=>x?kn(x,L):null,[x,L]),q=n.useMemo(()=>x&&V?sn(x,V.leaves):null,[x,V]),Oe=n.useMemo(()=>{if(typeof B!="function"||!x||!V||!q)return null;const i=Ht(x,V.leaves,"leaves"),j=[];return i.forEach(Y=>{const ce=Ge.get(Y);ce&&j.push(ce.data)}),{checked:q.total.checked,total:q.total.total,leafKeys:i,rows:j}},[B,x,V,q,Ge]),Ce=n.useCallback((i,j)=>{if(!x||!V||i===V.leaves)return;const Y=Ht(x,i,he,V.unknown);F(Y),H?.(Y,{...j,leafKeys:Ht(x,i,"leaves"),halfCheckedKeys:[...sn(x,i).halfChecked]})},[x,V,he,F,H]),Be=n.useCallback(i=>{if(!x||!V)return;const j=Nn(x,V.leaves,i);Ce(j,{source:"row",checked:j.size>V.leaves.size,key:i,row:Ge.get(i)?.data})},[x,V,Ce,Ge]),[nt,vt]=N.useControllableState({value:g,defaultValue:pe,fallbackValue:"",onChange:re,componentName:"NiceTreeGrid"}),Ye=nt.trim(),wt=n.useMemo(()=>k??gt.map(i=>i.field),[k,gt]),kt=n.useMemo(()=>{if(!Ye)return null;const i=Ye.toLowerCase();return Ii(Fe,ae?Y=>ae(Y.data,Ye):Y=>wt.some(ce=>String(Y.data[ce]??"").toLowerCase().includes(i)),de)},[Fe,Ye,ae,wt,de]),Ot=kt?.tree??Fe,[Xt,Gt]=N.useControllableState({value:ke,defaultValue:Pe,fallbackValue:!1,onChange:Z,componentName:"NiceTreeGrid"}),jt=!!z&&Xt&&q!==null,zt=n.useMemo(()=>jt&&q&&x?Mi(Ot,{state:q.state,isCheckable:x.isCheckable,isLeaf:x.isLeaf}):Ot,[jt,q,x,Ot]),St=Ye!==""||jt,$t=`${Ye}
|
|
6
|
+
${jt?1:0}`,[Jt,Wt]=n.useState(()=>({key:"",map:new Map})),Et=Jt.key===$t?Jt.map:Ti,Qt=n.useMemo(()=>{const i=new Set;return kt&&ge&&kt.expand.forEach(j=>i.add(j)),jt&&x&&bn(zt).forEach(j=>{x.isLeaf(j)||i.add(j)}),i},[kt,ge,jt,x,zt]),xt=n.useCallback(i=>St?Et.get(i)??(Ze.has(i)||Qt.has(i)):Ze.has(i),[St,Et,Ze,Qt]),Vt=n.useCallback((i,j)=>{const Y=At.current;if(i.some(ce=>Y.has(ce)!==j)){const ce=new Set(Y);i.forEach(Xe=>j?ce.add(Xe):ce.delete(Xe)),Rt(ce)}St&&Wt(ce=>{const Xe=new Map(ce.key===$t?ce.map:void 0);return i.forEach(rt=>Xe.set(rt,j)),{key:$t,map:Xe}})},[Rt,St,$t]),y=n.useCallback(i=>i.children.length>0||Qe(i.key),[Qe]),ne=n.useRef(new Set),ye=n.useCallback((i,j)=>{const Y=i.flatMap(ce=>Si(ce,y));Y.forEach(ce=>{j?Qe(ce)&&ne.current.add(ce):ne.current.delete(ce)}),Vt(Y,j)},[y,Qe,Vt]),Ne=n.useCallback((i,j)=>{const Y=Ge.get(i);Y&&ye([Y],j)},[Ge,ye]),ht=n.useCallback((i,j)=>{const Y=!xt(i);j?Ne(i,Y):Vt([i],Y)},[xt,Ne,Vt]),yt=n.useRef({nodeByKey:Ge,isPending:Qe,setSubtreesExpanded:ye});yt.current={nodeByKey:Ge,isPending:Qe,setSubtreesExpanded:ye},n.useEffect(()=>{const{nodeByKey:i,isPending:j,setSubtreesExpanded:Y}=yt.current,ce=[];for(const Xe of[...ne.current]){const rt=i.get(Xe);(!rt||rt.children.length>0||!j(Xe))&&(ne.current.delete(Xe),ce.push(...rt?.children??[]))}ce.length>0&&Y(ce,!0)},[Fe]);const Nt=n.useCallback(i=>{i||ne.current.clear(),Rt(i?new Set(Lt):new Set),St&&Wt({key:$t,map:new Map(bn(zt).map(j=>[j,i]))})},[Rt,Lt,St,$t,zt]),ut=n.useMemo(()=>Qn(zt,et,dt),[zt,et,dt]),en=n.useCallback(i=>Qe(i.key)?Q.get(i.key)==="error"?"error":"loading":null,[Qe,Q]),_t=n.useMemo(()=>Di(ut,xt,We?en:void 0),[ut,xt,We,en]),cn=E===!0||Array.isArray(E)&&E.includes("expandSubtree"),Jn=n.useMemo(()=>{const i=new Set;if(!cn)return i;const j=Y=>{if(Y.children.length===0)return!Qe(Y.key);let ce=xt(Y.key);return Y.children.forEach(Xe=>{j(Xe)||(ce=!1)}),ce&&i.add(Y.key),ce};return Fe.forEach(j),i},[cn,Fe,Qe,xt]);n.useEffect(()=>{w&&_t.forEach(i=>{i.placeholder==="loading"&&Ft(i.node.key)})},[_t,w,Ft]);const Kt=n.useMemo(()=>x?Ye?Ci(Ot).filter(i=>x.isLeaf(i)):x.leaves:xn,[x,Ye,Ot]),wn=n.useMemo(()=>{if(!V||Kt.length===0)return"unchecked";let i=0;for(const j of Kt)V.leaves.has(j)&&i++;return i===0?"unchecked":i===Kt.length?"checked":"indeterminate"},[V,Kt]),ei=n.useCallback(()=>{if(!x||!V)return;const i=Kt.filter(Y=>!x.isLocked(Y)),j=!i.every(Y=>V.leaves.has(Y));Ce(On(x,V.leaves,i,j),{source:"selectAll",checked:j})},[x,V,Kt,Ce]),ti=n.useCallback(()=>{x&&V&&Ce(On(x,V.leaves,x.leaves,!1),{source:"clear",checked:!1})},[x,V,Ce]),jn=i=>{S||Ke||(z&&ee&&x?.isCheckable(i.key)?Be(i.key):z&&b&&U(i.key),De?.(i.data))},Bt=n.useRef({toggleExpand:ht,setSubtreeExpanded:Ne,toggleCheck:Be,toggleSelected:U,rowClick:jn});Bt.current={toggleExpand:ht,setSubtreeExpanded:Ne,toggleCheck:Be,toggleSelected:U,rowClick:jn};const Sn=n.useMemo(()=>({toggleExpand:(i,j)=>Bt.current.toggleExpand(i,j),setSubtreeExpanded:(i,j)=>Bt.current.setSubtreeExpanded(i,j),toggleCheck:i=>Bt.current.toggleCheck(i),toggleSelected:i=>Bt.current.toggleSelected(i),rowClick:i=>Bt.current.rowClick(i)}),[]),mt=!!ze,tn=n.useRef(null),[Cn,ni]=n.useState(typeof je=="number"?je:480);n.useEffect(()=>{const i=tn.current;if(!mt||!i||typeof ResizeObserver>"u")return;const j=new ResizeObserver(()=>{i.clientHeight>0&&ni(i.clientHeight)});return j.observe(i),()=>j.disconnect()},[mt]);const ln=N.useVirtualScroll({itemCount:mt?_t.length:0,itemHeight:oe,containerHeight:Cn,overscan:8}),on=mt?ln.startIndex:0,dn=mt?ln.endIndex:_t.length,un=n.useRef(null),In=n.useRef(xt);In.current=xt,N.useTreeFocus(un,{itemSelector:"tr.nice-treegrid__row",enabled:!Ke,onToggle:(i,j)=>{const Y=i.dataset.key;Y!==void 0&&i.hasAttribute("aria-expanded")&&In.current(Y)!==j&&Sn.toggleExpand(Y)}});const hn=n.useCallback(i=>[...un.current?.querySelectorAll("tr.nice-treegrid__row")??[]].find(j=>j.dataset.key===i),[]),[mn,Mn]=n.useState(null);n.useEffect(()=>{if(mn===null)return;const i=hn(mn);i&&(i.focus(),Mn(null))},[mn,on,dn,hn]);const ii=i=>{const j=_t[i]?.placeholder?i-1:i,Y=_t[j]?.node.key;if(Y===void 0)return;const ce=hn(Y);ce?ce.focus():mt&&tn.current&&(tn.current.scrollTop=Math.max(0,j*oe-Cn/2),Mn(Y))},ai=i=>{const j=i.target;if(i.altKey||i.ctrlKey||i.metaKey||!j.matches?.("tr.nice-treegrid__row"))return;const Y=j.dataset.key??"";if(i.shiftKey&&(i.key==="ArrowRight"||i.key==="ArrowLeft")){if(j.hasAttribute("aria-expanded")){i.preventDefault();const rt=getComputedStyle(j).direction==="rtl";Ne(Y,i.key==="ArrowRight"!==rt)}return}if(i.key===" "){if(S)return;z&&x?.isCheckable(Y)?(i.preventDefault(),Be(Y)):b&&(i.preventDefault(),U(Y));return}if(!(i.key==="PageDown"||i.key==="PageUp")&&!(mt&&(i.key==="Home"||i.key==="End")))return;const Xe=_t.findIndex(rt=>rt.node.key===Y);Xe<0||(i.preventDefault(),ii(i.key==="PageDown"?Math.min(_t.length-1,Xe+Vn):i.key==="PageUp"?Math.max(0,Xe-Vn):i.key==="Home"?0:_t.length-1))},si=ue("controls.expand","Expand"),ri=ue("controls.collapse","Collapse"),Dn=gt[0]?.field,ci=i=>_e?_e(i.data):String((Dn!=null?i.data[Dn]:void 0)??i.key),En=(i,j)=>ue("treeGrid.checkedSummary","{checked} of {total} selected").replace("{checked}",String(i)).replace("{total}",String(j)),li=n.useMemo(()=>{const i=new Set(wt);return gt.map(j=>D&&!ae&&i.has(j.field))},[gt,wt,D,ae]),fn=$===!0?z?Fn:Fn.slice(0,2):Array.isArray($)?$.filter(i=>z||i==="expandAll"||i==="collapseAll"):zi,nn=z?Ie==="column"?"column":"tree":"none",an=!!b&&!z,qt=gt.length+(nn==="column"||an?1:0),An=[["checked",!q||B===!1?null:Oe&&typeof B=="function"?B(Oe):En(q.total.checked,q.total.total)],["matches",kt?ue("treeGrid.matchCount","{count} matching rows").replace("{count}",String(kt.matched.size)):null]].filter(([,i])=>i!=null&&i!==!1&&i!=="");if(Ue==="hidden")return null;const pn=z&&$e&&x&&x.leaves.length>0?e.jsx("input",{type:"checkbox",className:"nice-treegrid__check-input nice-treegrid__select-all",checked:wn==="checked",ref:i=>{i&&(i.indeterminate=wn==="indeterminate")},disabled:S||Ke,"aria-label":Ye?ue("treeGrid.selectAllResults","Select all results"):ue("controls.selectAll","Select all"),onClick:i=>i.stopPropagation(),onChange:ei}):null,oi=i=>{const j={expandAll:{icon:"expand",label:ue("treeGrid.expandAll","Expand all")},collapseAll:{icon:"collapse",label:ue("treeGrid.collapseAll","Collapse all")},onlyChecked:{icon:"filter",label:ue("treeGrid.showOnlyChecked","Show selected only")},clearChecked:{icon:"eraser",label:ue("treeGrid.clearChecked","Clear selection")}}[i];return e.jsxs("button",{type:"button",className:`nice-btn nice-btn--sm nice-btn--ghost nice-treegrid__action${i==="onlyChecked"&&jt?" nice-treegrid__action--active":""}`,"aria-pressed":i==="onlyChecked"?jt:void 0,disabled:Ke||i==="clearChecked"&&(S||!q||q.total.checked===0),onClick:()=>{i==="expandAll"||i==="collapseAll"?Nt(i==="expandAll"):i==="onlyChecked"?Gt(!Xt):ti()},children:[e.jsx(N.NiceIcon,{name:j.icon,size:14}),e.jsx("span",{children:j.label})]},i)},di=i=>{const{node:j,level:Y,posInSet:ce,setSize:Xe,placeholder:rt}=_t[i],ft=j.key;if(rt)return e.jsx("tr",{className:`nice-treegrid__placeholder nice-treegrid__placeholder--${rt}`,"aria-level":Y,style:mt?{height:oe}:void 0,children:e.jsxs("td",{colSpan:qt,children:[e.jsx("span",{className:"nice-treegrid__indent",style:{width:(Y-1)*20}}),e.jsx("span",{className:"nice-treegrid__toggle nice-treegrid__toggle--leaf","aria-hidden":"true"}),rt==="loading"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"nice-spinner nice-spinner--sm","aria-hidden":"true"}),e.jsx("span",{role:"status",children:ue("treeGrid.loading","Loading…")})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{role:"alert",children:ue("treeGrid.loadError","Could not load the rows.")}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--sm nice-btn--ghost",onClick:()=>Ut(ft),children:ue("treeGrid.retry","Retry")})]})]})},`${ft}\0${rt}`);const gn=j.children.length>0||Qe(ft),zn=gn&&xt(ft),_n=cn&&gn?Jn.has(ft)?"collapse":"expand":null,$n=!!x?.isCheckable(ft),Yt=we&&q&&x&&!x.isLeaf(ft)?q.count(ft):null,ui=ci(j);return e.jsx(Oi,{node:j,level:Y,posInSet:ce,setSize:Xe,rowIndex:i,ariaRowIndex:mt?i+2:void 0,columns:gt,highlight:li,query:Ye,expandable:gn,expanded:zn,busy:zn&&Q.get(ft)==="loading",expandLabel:si,collapseLabel:ri,subtreeAction:_n,subtreeLabel:_n==="expand"?ue("treeGrid.expandSubtree","Expand all below"):_n==="collapse"?ue("treeGrid.collapseSubtree","Collapse all below"):"",checkMode:nn,hasCheckbox:$n,checkState:q?q.state(ft):"unchecked",checkLabel:$n?ue("treeGrid.checkRow","Select {label}").replace("{label}",ui):"",locked:!!x?.isLocked(ft),countChecked:Yt?.checked??0,countTotal:Yt?.total??0,countTitle:Yt?En(Yt.checked,Yt.total):"",selectColumn:an,selected:b?u.has(ft):void 0,selectLabel:an?ue("controls.selectRow","Select row {key}").replace("{key}",ft):"",readOnly:S,className:typeof le=="function"?le(j.data,i):le,clickable:!S&&(!!De||!!ee||!!z&&!!b),height:mt?oe:void 0,handlers:Sn},ft)},Rn=[];for(let i=on;i<dn;i++)Rn.push(di(i));const Tn=(i,j)=>i>0?e.jsx("tr",{className:"nice-treegrid__spacer","aria-hidden":"true",children:e.jsx("td",{colSpan:qt,style:{height:i*oe}})},j):null;return e.jsxs("div",{id:ie,"data-testid":v??J,className:`nice-treegrid nice-datagrid ${Ke?"nice-treegrid--disabled":""} ${S?"nice-treegrid--readonly":""} ${ve?"nice-treegrid--error":""} ${mt?"nice-treegrid--virtual":""} ${qe||""}`,style:Re,"aria-disabled":Ke||void 0,"aria-busy":ct||void 0,"aria-invalid":!!ve||void 0,children:[(O||be||fn.length>0)&&e.jsxs("div",{className:"nice-datagrid__toolbar nice-treegrid__toolbar",children:[O&&e.jsxs("div",{className:"nice-datagrid__search nice-treegrid__search",children:[e.jsx("input",{type:"search",value:nt,onChange:i=>vt(i.target.value),onKeyDown:i=>{i.key==="Escape"&&nt&&(i.preventDefault(),vt(""))},placeholder:A||ue("controls.search","Search..."),"aria-label":A||ue("controls.search","Search...")}),nt&&e.jsx("button",{type:"button",className:"nice-treegrid__search-clear",onClick:()=>vt(""),"aria-label":ue("treeGrid.clearSearch","Clear search"),children:e.jsx(N.NiceIcon,{name:"close",size:12})})]}),fn.length>0&&e.jsx("div",{className:"nice-treegrid__actions",children:fn.map(oi)}),be,An.length>0&&e.jsx("span",{className:"nice-treegrid__summary",role:"status",children:An.map(([i,j],Y)=>e.jsxs(n.Fragment,{children:[Y>0&&" · ",j]},i))})]}),e.jsx("div",{ref:tn,className:"nice-datagrid__table-wrap",style:mt?{height:je??480,overflow:"auto"}:void 0,onScroll:mt?ln.onScroll:void 0,children:e.jsxs("table",{ref:un,role:"treegrid","aria-label":te,"aria-labelledby":Ve,"aria-multiselectable":b||z||void 0,"aria-rowcount":mt?_t.length+1:void 0,className:`nice-table nice-table--${Se} ${Le?"nice-table--striped":""} ${Me?"nice-table--compact":""}`,onKeyDownCapture:ai,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[nn==="column"&&e.jsx("th",{className:"nice-datagrid__checkbox nice-treegrid__th-check",children:pn}),an&&e.jsx("th",{className:"nice-datagrid__checkbox",style:{width:36}}),gt.map((i,j)=>e.jsxs("th",{style:{width:i.width,minWidth:i.minWidth,textAlign:i.align},className:R&&i.sortable!==!1?"nice-datagrid__th--sortable":void 0,onClick:()=>R&&i.sortable!==!1&&h(i.field),children:[j===0&&nn==="tree"&&pn&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"nice-treegrid__toggle nice-treegrid__toggle--leaf","aria-hidden":"true"}),e.jsx("span",{className:"nice-treegrid__check",children:pn})]}),i.header,R&&i.sortable!==!1&&e.jsx("span",{className:"nice-table__sort-icon",style:{opacity:et===i.field&&dt?void 0:.3},children:e.jsx(N.NiceIcon,{name:et===i.field&&dt?dt==="asc"?"sort-asc":"sort-desc":"sort",size:12})})]},i.field))]})}),e.jsx("tbody",{children:ct?e.jsx("tr",{children:e.jsx("td",{colSpan:qt,className:"nice-datagrid__empty",children:e.jsx("div",{className:"nice-spinner nice-spinner--md",style:{margin:"0 auto"}})})}):ve?e.jsx("tr",{children:e.jsx("td",{colSpan:qt,className:"nice-datagrid__empty nice-treegrid__error",role:"alert",children:ve})}):_t.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:qt,className:"nice-datagrid__empty",children:Ye?ue("controls.noResults","No results"):W||ue("controls.noData","No data available")})}):e.jsxs(e.Fragment,{children:[Tn(on,"top"),Rn,Tn(_t.length-dn,"bottom")]})})]})})]})}const Vi=[],Ki=[],Bi=[];function Ui(t,a,s){const r=[],l=(c,f)=>{c.forEach(m=>{r.push({item:m,parent:m[s]??f}),Array.isArray(m.children)&&m.children.length>0&&l(m.children,m[a])})};l(t,null);const o=new Map,d=[];return r.forEach(({item:c})=>{const f={...c,children:[]};o.set(String(f[a]),f)}),r.forEach(({item:c,parent:f})=>{f!=null&&o.has(String(f))?o.get(String(f)).children.push(o.get(String(c[a]))):d.push(o.get(String(c[a])))}),d}function Gi({columns:t=Vi,data:a=Ki,keyField:s="key",parentKeyField:r="parentKey",expandedKeys:l,onExpandedChange:o,selectedKeys:d=Bi,onSelectionChange:c,selectable:f,sortable:m,loading:w,emptyText:E,className:P,style:R,accessMode:T,id:K,"data-testid":p}){const I=N.useNiceAccessMode(T,K)==="hidden",{t:_}=N.useNiceTranslation(),[z,C]=n.useState([]),G=l??z,[H,he]=n.useState(d),se=c?d:H,fe=n.useMemo(()=>Ui(a,s,r),[a,s,r]),Ie=n.useMemo(()=>t.filter(k=>!k.hidden),[t]),[ee,we]=n.useState(null),B=n.useCallback(k=>{we(ae=>ae?.field===k?ae.dir==="asc"?{field:k,dir:"desc"}:null:{field:k,dir:"asc"})},[]),$e=n.useCallback(k=>ee?[...k].sort((de,ge)=>{const D=de[ee.field]??"",le=ge[ee.field]??"",_e=typeof D=="number"?D-le:String(D).localeCompare(String(le));return ee.dir==="desc"?-_e:_e}).map(de=>de.children&&de.children.length?{...de,children:$e(de.children)}:de):k,[ee]),ke=n.useMemo(()=>$e(fe),[fe,$e]),Pe=n.useCallback(k=>{const ae=G.includes(k)?G.filter(de=>de!==k):[...G,k];o?o(ae):C(ae)},[G,o]),Z=n.useMemo(()=>vn(fe,{getKey:k=>String(k[s]),getChildren:k=>k.children}),[fe,s]),$=n.useMemo(()=>kn(Z,se),[Z,se]),O=n.useMemo(()=>sn(Z,$.leaves),[Z,$]),A=n.useCallback(k=>{const ae=Nn(Z,$.leaves,k),de=Ht(Z,ae,"all",$.unknown);c?c(de):he(de)},[Z,$,c]),g=Ie[0]?.field;let pe=0;const re=(k,ae)=>{const de=String(k[s]),ge=pe++,D=!!(k.children&&k.children.length>0),le=G.includes(de),_e=O.state(de),ze=_e==="checked",oe=_e==="indeterminate",je=g!=null?String(k[g]??de):de;return e.jsxs(n.Fragment,{children:[e.jsxs("tr",{className:ze?"nice-treelist__row--selected":"",children:[f&&e.jsx("td",{className:"nice-treelist__checkbox",children:e.jsx("input",{type:"checkbox",checked:ze,ref:Le=>{Le&&(Le.indeterminate=oe)},onChange:()=>A(de),"aria-label":_("controls.selectRow","Select row {key}").replace("{key}",je)})}),Ie.map((Le,Me)=>e.jsxs("td",{style:{textAlign:Le.align},children:[Me===0&&e.jsx("span",{style:{display:"inline-block",width:ae*20}}),Me===0&&e.jsx("span",{role:D?"button":void 0,tabIndex:D?0:void 0,"aria-expanded":D?le:void 0,"aria-label":D?_(le?"controls.collapse":"controls.expand",le?"Collapse":"Expand"):void 0,onKeyDown:D?N.clickOnActivationKey:void 0,className:"nice-treelist__toggle",onClick:()=>D&&Pe(de),style:{cursor:D?"pointer":"default",width:20,display:"inline-block"},children:D?e.jsx(N.NiceIcon,{name:le?"chevron-down":"chevron-right",size:12}):""}),Le.render?Le.render(k[Le.field],k,ge):String(k[Le.field]??"")]},Le.field))]}),D&&le&&k.children.map(Le=>re(Le,ae+1))]},de)};return I?null:e.jsx("div",{className:`nice-treelist ${P||""}`,style:R,"data-testid":p,children:e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[f&&e.jsx("th",{className:"nice-treelist__checkbox"}),Ie.map(k=>{const ae=!!m&&!!k.sortable;return e.jsxs("th",{style:{width:k.width,minWidth:k.minWidth,textAlign:k.align},className:ae?"nice-treelist__th--sortable":void 0,onClick:()=>ae&&B(k.field),scope:"col","aria-sort":ae?ee?.field===k.field?ee.dir==="asc"?"ascending":"descending":"none":void 0,children:[k.header,ae&&e.jsx("span",{className:"nice-table__sort-icon","aria-hidden":"true",children:e.jsx(N.NiceIcon,{name:ee?.field===k.field?ee.dir==="desc"?"chevron-down":"chevron-up":"sort",size:12})})]},k.field)})]})}),e.jsx("tbody",{children:w?e.jsx("tr",{children:e.jsx("td",{colSpan:Ie.length+(f?1:0),className:"nice-treelist__empty",children:e.jsx("div",{className:"nice-spinner nice-spinner--md",style:{margin:"0 auto"}})})}):fe.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:Ie.length+(f?1:0),className:"nice-treelist__empty",children:E||_("controls.noData","No data available")})}):ke.map(k=>re(k,0))})]})})}function Yn(t,a=[]){for(const s of t)s.expanded&&a.push(s.key),s.children&&Yn(s.children,a);return a}const Kn=[],Wi=[],Qi=({nodes:t=Kn,header:a,selectedKeys:s=Wi,expandedKeys:r,onSelectionChange:l,onExpandedChange:o,selectionMode:d="none",showCheckboxes:c,searchable:f,searchPlaceholder:m,onNodeClick:w,renderNode:E,showLines:P,loading:R,className:T,style:K,accessMode:p,id:b,draggable:I,onNodeDrop:_,onLoadChildren:z,contextMenuItems:C,onContextMenuAction:G,editable:H,onNodeEdit:he,maxDepth:se,"data-testid":fe})=>{const ee=N.useNiceAccessMode(p,b)==="hidden",{t:we}=N.useNiceTranslation(),[B,$e]=n.useState(()=>Yn(t)),[ke,Pe]=n.useState(""),[Z,$]=n.useState(new Set),[O,A]=n.useState(new Map),[g,pe]=n.useState(null),[re,k]=n.useState(null),[ae,de]=n.useState(null),[ge,D]=n.useState(""),le=n.useRef(null),_e=r??B,ze=n.useRef(_e);ze.current=_e;const oe=n.useMemo(()=>new Set(s),[s]),je=typeof se=="number"?Math.min(10,Math.max(1,se)):1/0,Le=!!c&&d==="multiple",Me=n.useMemo(()=>Le?vn(t,{getKey:v=>v.key,getChildren:(v,xe)=>xe+1>=je?null:O.get(v.key)??v.children,isDisabled:v=>!!v.disabled},{inheritDisabled:!1}):null,[Le,t,O,je]),Se=n.useMemo(()=>Me?kn(Me,s):null,[Me,s]),ct=n.useMemo(()=>Me&&Se?sn(Me,Se.leaves):null,[Me,Se]),it=n.useCallback(async(v,xe)=>{const te=ze.current,Ve=!te.includes(v),ue=Ve?[...te,v]:te.filter(Ue=>Ue!==v);if(ze.current=ue,o?o(ue):$e(ue),Ve&&z&&!xe.children?.length&&xe.leaf!==!0&&!O.has(v)){$(Ke=>new Set(Ke).add(v));const Ue=await z(xe);A(Ke=>new Map(Ke).set(v,Ue)),$(Ke=>{const S=new Set(Ke);return S.delete(v),S})}},[o,z,O]),at=n.useCallback(v=>{if(l){if(d==="single")l(s.includes(v)?[]:[v]);else if(d==="multiple")if(Me&&Se){const xe=Nn(Me,Se.leaves,v);xe!==Se.leaves&&l(Ht(Me,xe,"all",Se.unknown))}else l(s.includes(v)?s.filter(xe=>xe!==v):[...s,v])}},[s,d,l,Me,Se]),ve=n.useCallback(v=>{if(!ke)return!0;const xe=ke.toLowerCase();return v.text.toLowerCase().includes(xe)?!0:(O.get(v.key)??v.children)?.some(Ve=>ve(Ve))??!1},[ke,O]),W=n.useCallback((v,xe)=>{C?.length&&(v.preventDefault(),k({x:v.clientX,y:v.clientY,node:xe}))},[C]),be=n.useCallback(()=>{ae&&he&&he(ae,ge),de(null)},[ae,ge,he]),De=n.useRef(null),qe=(v,xe=t)=>{for(const te of xe){const Ve=te.key===v?te:qe(v,O.get(te.key)??te.children??Kn);if(Ve)return Ve}};N.useTreeFocus(De,{rowSelector:".nice-tree__row",onToggle:(v,xe)=>{const te=v.dataset.key===void 0?void 0:qe(v.dataset.key);te&&ze.current.includes(te.key)!==xe&&it(te.key,te)}});const Re=n.useRef(null);n.useEffect(()=>{if(ae!==null||Re.current===null)return;const v=Re.current;Re.current=null,[...De.current?.querySelectorAll('[role="treeitem"]')??[]].find(xe=>xe.dataset.key===v)?.focus()},[ae]);const ie=n.useRef(null);N.useRovingFocus(ie,{orientation:"vertical",wrap:!0,typeahead:!0}),N.useOverlayFocus(ie,{open:!!re,modal:!1,onClose:()=>k(null)});const J=(v,xe)=>{if(ke&&!ve(v))return null;const te=xe+1>=je,Ve=te?void 0:O.get(v.key)??v.children,ue=!te&&(Ve&&Ve.length>0||v.leaf!==!0&&z&&!Ve?.length),Ue=_e.includes(v.key),Ke=ct?ct.state(v.key):oe.has(v.key)?"checked":"unchecked",S=ct?Ke==="checked":oe.has(v.key),X=!!v.disabled||!!Me?.isLocked(v.key),me=Z.has(v.key),Ee=Math.min(xe+1,10),st={paddingLeft:xe*20+4,"--nice-row-bg":`var(--nice-tree-level-${Ee}-bg, transparent)`,"--nice-row-text":`var(--nice-tree-level-${Ee}-text, inherit)`,"--nice-row-border":`var(--nice-tree-level-${Ee}-border, transparent)`,"--nice-row-hover-bg":`var(--nice-tree-level-${Ee}-hover-bg, var(--nice-hover-bg, color-mix(in srgb, var(--nice-text-primary) 6%, transparent)))`,"--nice-row-active-bg":`var(--nice-tree-level-${Ee}-active-bg, color-mix(in srgb, var(--nice-color-primary) 14%, transparent))`};return e.jsxs("li",{className:"nice-tree__node",role:"treeitem","aria-label":v.text,"aria-expanded":ue?Ue:void 0,"aria-selected":d!=="none"?S:void 0,"aria-disabled":v.disabled||void 0,"data-key":v.key,"data-nice-depth":Ee,onKeyDown:H&&!v.disabled?Q=>{Q.key==="F2"&&Q.target===Q.currentTarget&&(Q.preventDefault(),de(v.key),D(v.text))}:void 0,draggable:I&&!v.disabled,onDragStart:I?Q=>{Q.stopPropagation(),pe(v.key)}:void 0,onDragOver:I?Q=>{Q.preventDefault(),Q.stopPropagation()}:void 0,onDrop:I&&g?Q=>{Q.stopPropagation(),_?.(g,v.key,"inside"),pe(null)}:void 0,onDragEnd:I?()=>pe(null):void 0,children:[e.jsxs("div",{role:"presentation",className:`nice-tree__row ${S?"nice-tree__row--selected":""} ${v.disabled?"nice-tree__row--disabled":""} ${g===v.key?"nice-tree__row--dragging":""}`,style:st,onClick:()=>{v.disabled||(at(v.key),w?.(v))},onContextMenu:Q=>W(Q,v),onDoubleClick:H&&!v.disabled?()=>{de(v.key),D(v.text)}:void 0,children:[e.jsx("span",{role:"presentation",className:`nice-tree__toggle ${ue?Ue?"nice-tree__toggle--expanded":"":"nice-tree__toggle--leaf"}`,onClick:Q=>{Q.stopPropagation(),ue&&it(v.key,v)},children:me?e.jsx("span",{className:"nice-spinner nice-spinner--xs"}):ue?Ue?e.jsx(N.NiceIcon,{name:"chevron-down",size:12}):e.jsx(N.NiceIcon,{name:"chevron-right",size:12}):""}),c&&d!=="none"&&e.jsx("input",{type:"checkbox",checked:Ke==="checked",ref:Q=>{Q&&(Q.indeterminate=Ke==="indeterminate")},onChange:()=>at(v.key),onClick:Q=>Q.stopPropagation(),disabled:X,tabIndex:-1,"aria-label":v.text,className:"nice-tree__checkbox"}),ae===v.key?e.jsx("input",{type:"text",className:"nice-tree__edit-input",value:ge,onChange:Q=>D(Q.target.value),onBlur:be,onKeyDown:Q=>{Q.key==="Enter"&&(Re.current=v.key,be()),Q.key==="Escape"&&(Q.preventDefault(),Re.current=v.key,de(null))},autoFocus:!0,onClick:Q=>Q.stopPropagation()}):E?E(v):e.jsxs(e.Fragment,{children:[v.icon&&e.jsx("span",{className:"nice-tree__icon",children:v.icon}),e.jsx("span",{className:"nice-tree__text",children:v.text})]})]}),Ve&&Ve.length>0&&Ue&&e.jsx("ul",{className:"nice-tree__children",role:"group",children:Ve.map(Q=>J(Q,xe+1))})]},v.key)};return ee?null:e.jsxs("div",{role:"presentation",className:`nice-tree ${P?"nice-tree--lines":""} ${T||""}`,style:K,ref:le,"data-testid":fe,onClick:()=>k(null),children:[a!=null&&a!==!1&&e.jsx("div",{className:"nice-tree__header",children:a}),f&&e.jsx("div",{className:"nice-tree__search",children:e.jsx("input",{type:"text",value:ke,onChange:v=>Pe(v.target.value),placeholder:m||we("controls.search","Search..."),"aria-label":m||we("controls.search","Search tree")})}),R?e.jsx("div",{className:"nice-tree__loading",children:e.jsx("div",{className:"nice-spinner nice-spinner--sm"})}):e.jsx("ul",{ref:De,className:"nice-tree__root",role:"tree","aria-multiselectable":d==="multiple"||void 0,children:t.map(v=>J(v,0))}),re&&C&&e.jsx("div",{ref:ie,className:"nice-tree__context-menu",role:"menu","aria-label":re.node.text,style:{position:"fixed",top:re.y,left:re.x,zIndex:9999},children:C.map(v=>e.jsxs("button",{type:"button",role:"menuitem",disabled:v.disabled,className:`nice-tree__context-item ${v.disabled?"nice-tree__context-item--disabled":""}`,onClick:()=>{v.disabled||(G?.(v.key,re.node),k(null))},children:[v.icon&&e.jsx("span",{children:v.icon}),v.label]},v.key))})]})},qi=[],Yi=({items:t=qi,selectedKeys:a=[],onSelectionChange:s,selectionMode:r="none",searchable:l,searchPlaceholder:o,grouped:d,groupField:c="group",reorderable:f,onReorder:m,onItemClick:w,renderItem:E,showCheckboxes:P,loading:R,emptyText:T,size:K="md",header:p,disabled:b,readOnly:I,error:_,bordered:z=!0,swipeActions:C,className:G,style:H,accessMode:he,id:se,"data-testid":fe})=>{const ee=N.useNiceAccessMode(he,se)==="hidden",{t:we}=N.useNiceTranslation(),[B,$e]=n.useState(""),[ke,Pe]=n.useState(null),[Z,$]=n.useState(null),O=n.useRef(null),A=n.useMemo(()=>{if(!B)return t;const D=B.toLowerCase();return t.filter(le=>le.text.toLowerCase().includes(D))},[t,B]),g=n.useMemo(()=>{if(!d)return null;const D=new Map;return A.forEach(le=>{const _e=String(le[c]??"");D.has(_e)||D.set(_e,[]),D.get(_e).push(le)}),D},[A,d,c]),pe=n.useCallback(D=>{s&&(r==="single"?s(a.includes(D)?[]:[D]):r==="multiple"&&s(a.includes(D)?a.filter(le=>le!==D):[...a,D]))},[a,r,s]),re=n.useCallback(D=>{ke!==null&&ke!==D&&m&&m(ke,D),Pe(null)},[ke,m]),k=n.useRef(null),ae=n.useCallback(D=>{k.current=D},[]);N.useRovingFocus(k,{orientation:"vertical",itemSelector:".nice-list__item",typeahead:!0,pageSize:10});const de=D=>{!D.disabled&&!b&&!I&&(pe(D.key),w?.(D))},ge=(D,le)=>{const _e=a.includes(D.key),ze=Z===D.key;return e.jsxs("li",{className:`nice-list__item ${_e?"nice-list__item--selected":""} ${D.disabled?"nice-list__item--disabled":""} ${ze?"nice-list__item--swiped":""}`,onClick:()=>de(D),onKeyDown:oe=>{oe.target===oe.currentTarget&&(oe.key==="Enter"||oe.key===" ")&&(oe.preventDefault(),de(D))},draggable:f&&!b&&!I,onDragStart:()=>Pe(le),onDragOver:oe=>oe.preventDefault(),onDrop:()=>re(le),onTouchStart:C?.length?oe=>{O.current={x:oe.touches[0].clientX,key:D.key}}:void 0,onTouchEnd:C?.length?oe=>{if(!O.current)return;const je=oe.changedTouches[0].clientX-O.current.x;je<-50&&O.current.key===D.key?$(D.key):je>50&&$(null),O.current=null}:void 0,role:"option","aria-selected":r!=="none"?_e:void 0,"aria-disabled":D.disabled||void 0,children:[e.jsxs("div",{className:"nice-list__item-content",children:[P&&r!=="none"&&e.jsx("input",{type:"checkbox",checked:_e,readOnly:!0,tabIndex:-1,className:"nice-list__checkbox"}),E?E(D):e.jsxs(e.Fragment,{children:[D.icon&&e.jsx("span",{className:"nice-list__icon",children:D.icon}),e.jsx("span",{className:"nice-list__text",children:D.text}),D.badge&&e.jsx("span",{className:"nice-list__badge",children:D.badge})]})]}),C&&ze&&e.jsx("div",{className:"nice-list__swipe-actions",children:C.map(oe=>e.jsx("button",{className:"nice-list__swipe-btn",style:oe.color?{backgroundColor:oe.color}:void 0,onClick:je=>{je.stopPropagation(),oe.onClick(D),$(null)},children:oe.label},oe.key))})]},D.key)};return ee?null:e.jsxs("div",{className:`nice-list nice-list--${K} ${z?"nice-list--bordered":""} ${b?"nice-list--disabled":""} ${I?"nice-list--readonly":""} ${_?"nice-list--error":""} ${G||""}`,style:H,"data-testid":fe,"aria-disabled":b||void 0,"aria-busy":R||void 0,children:[p&&e.jsx("div",{className:"nice-list__header",children:p}),l&&!R&&e.jsx("div",{className:"nice-list__search",children:e.jsx("input",{type:"text",value:B,onChange:D=>$e(D.target.value),placeholder:o||we("controls.search","Search...")})}),R?e.jsx("div",{className:"nice-list__loading",role:"status","aria-live":"polite",children:e.jsx("div",{className:`nice-spinner nice-spinner--${K}`})}):_?e.jsx("div",{className:"nice-list__error",role:"alert",children:_}):A.length===0?e.jsx("div",{className:"nice-list__empty",children:T||we("controls.noData","No data available")}):e.jsx("div",{role:"listbox",ref:ae,"aria-multiselectable":r==="multiple"||void 0,children:g?Array.from(g.entries()).map(([D,le])=>e.jsxs("div",{className:"nice-list__group",role:"group","aria-label":D,children:[e.jsx("div",{className:"nice-list__group-header","aria-hidden":"true",children:D}),e.jsx("ul",{className:"nice-list__items",role:"presentation",children:le.map((_e,ze)=>ge(_e,ze))})]},D)):e.jsx("ul",{className:"nice-list__items",role:"presentation",children:A.map((D,le)=>ge(D,le))})})]})},Hi=[],Zi=[];function Xi({columns:t=Hi,data:a=Zi,striped:s,compact:r,size:l="md",emptyText:o,className:d,style:c,accessMode:f,id:m,displayStyle:w}){const{t:E}=N.useNiceTranslation(),P=N.normalizeSize(l),T=N.useNiceAccessMode(f,m)==="hidden",K=N.useComponentDisplayStyle("table",w),p=N.useComponentDisplayClass("table",w),[b,I]=n.useState(null),_=n.useMemo(()=>b?[...a].sort((C,G)=>{const H=C[b.field]??"",he=G[b.field]??"",se=typeof H=="number"?H-he:String(H).localeCompare(String(he));return b.dir==="desc"?-se:se}):a,[a,b]),z=C=>{I(G=>G?.field===C?G.dir==="asc"?{field:C,dir:"desc"}:null:{field:C,dir:"asc"})};return T?null:e.jsx("div",{className:`nice-table-wrapper ${d||""}`,style:{...K,...c},children:e.jsxs("table",{className:`nice-table nice-table--ds-${p} nice-table--${P} ${s?"nice-table--striped":""} ${r?"nice-table--compact":""}`,"aria-rowcount":_.length,"aria-colcount":t.length,children:[e.jsx("thead",{children:e.jsx("tr",{children:t.map(C=>{const G=C.sortable?b?.field===C.field?b.dir==="asc"?"ascending":"descending":"none":void 0;return e.jsxs("th",{style:{width:C.width,textAlign:C.align},className:C.sortable?"th--sortable":void 0,onClick:()=>C.sortable&&z(C.field),scope:"col","aria-sort":G,children:[C.header,C.sortable&&e.jsx("span",{className:"nice-table__sort-icon","aria-hidden":"true",children:e.jsx(N.NiceIcon,{name:b?.field===C.field?b.dir==="desc"?"chevron-down":"chevron-up":"sort",size:12})})]},C.field)})})}),e.jsx("tbody",{children:_.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:t.length,className:"nice-table__empty",children:o||E("table.noData","No data")})}):_.map((C,G)=>e.jsx("tr",{children:t.map(H=>e.jsx("td",{style:{textAlign:H.align},children:H.render?H.render(C[H.field],C):String(C[H.field]??"")},H.field))},G))})]})})}const Ji=[];function ea({items:t=Ji,tileWidth:a=180,tileHeight:s=180,direction:r="horizontal",renderTile:l,onTileClick:o,loading:d,emptyText:c,className:f,style:m,"data-testid":w}){const{t:E}=N.useNiceTranslation();return e.jsx("div",{className:`nice-tileview nice-tileview--${r} ${f||""}`,style:m,"data-testid":w,children:d?e.jsx("div",{className:"nice-tileview__loading",children:e.jsx("div",{className:"nice-spinner nice-spinner--md"})}):t.length===0?e.jsx("div",{className:"nice-tileview__empty",children:c||E("controls.noData","No data available")}):e.jsx("div",{className:"nice-tileview__container",style:{display:"flex",flexWrap:"wrap",gap:8,flexDirection:r==="vertical"?"column":"row"},children:t.map(P=>e.jsx("div",{role:o?"button":void 0,tabIndex:o?0:void 0,onKeyDown:o?N.clickOnActivationKey:void 0,className:"nice-tileview__tile",style:{width:a,height:s,cursor:o?"pointer":void 0},onClick:()=>o?.(P),children:l?l(P):e.jsxs(e.Fragment,{children:[P.image&&e.jsx("img",{src:P.image,alt:P.text||"",className:"nice-tileview__image"}),P.text&&e.jsx("div",{className:"nice-tileview__label",children:P.text})]})},P.key))})})}const ta=[],na=[];function ia({open:t}){return e.jsx(N.NiceIcon,{name:"chevron-down",size:14,style:{transition:"transform 160ms ease",transform:t?"rotate(0deg)":"rotate(-90deg)"}})}function aa(){return e.jsx(N.NiceIcon,{name:"plus",size:14})}const sa=[{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"}],ra=Object.assign(n.forwardRef(({columns:t=ta,cards:a=na,onCardMove:s,onCardClick:r,renderCard:l,onAddCard:o,disabled:d=!1,size:c="md",collapsible:f=!1,collapseDirection:m="vertical",layoutMode:w="scroll",viewMode:E,onViewModeChange:P,collapsedColumns:R,onCollapsedColumnsChange:T,formItems:K,formColumns:p=1,formProps:b,editCardTitle:I,newCardTitle:_,onCardEdit:z,onCardCreate:C,onCardDelete:G,tutorial:H,cookies:he=!1,localStorage:se=!0,sessionStorage:fe=!1,storageMode:Ie,storageKey:ee,className:we,style:B,id:$e,...ke},Pe)=>{const{t:Z}=N.useNiceTranslation(),[$,O]=n.useState(null),[A,g]=n.useState(null),[pe,re]=n.useState(null),k=!!K&&(!!z||!!C),ae=n.useCallback(W=>{if(k&&z){re({key:W.key,data:{...W},column:W.column});return}r?.(W)},[k,r,z]),de=k&&!!z||!!r,ge=n.useCallback(W=>{if(k&&C){re({key:null,data:{title:"",description:""},column:W});return}o?.(W)},[k,o,C]),D=gi.useStorageAdapter(ee??"nice-kanban"),[le,_e]=n.useState(()=>D.get("state")??{collapsedColumns:[],viewMode:"default"}),ze=n.useMemo(()=>R??le.collapsedColumns??[],[R,le.collapsedColumns]),oe=E??le.viewMode??"default",je=n.useCallback(W=>{_e(be=>{const De={...be,...W};return D.set("state",De),De})},[D]),Le=n.useCallback(W=>{const be=ze.includes(W)?ze.filter(De=>De!==W):[...ze,W];T?T(be):je({collapsedColumns:be})},[ze,T,je]);n.useCallback(W=>{P?P(W):je({viewMode:W})},[P,je]);const Me=n.useCallback(W=>a.filter(be=>be.column===W).sort((be,De)=>(be.order??0)-(De.order??0)),[a]),Se=n.useCallback((W,be)=>{d||(W.dataTransfer.effectAllowed="move",W.dataTransfer.setData("text/plain",String(be.key)),O({cardKey:be.key,fromColumn:be.column}))},[d]),ct=n.useCallback((W,be)=>{W.preventDefault(),W.dataTransfer.dropEffect="move",g({column:be})},[]),it=n.useCallback(()=>{g(null)},[]),at=n.useCallback((W,be)=>{if(W.preventDefault(),g(null),!$||d)return;const De=Me(be);s?.($.cardKey,be,De.length),O(null)},[$,d,Me,s]),ve=n.useCallback(()=>{O(null),g(null)},[]);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{ref:Pe,id:$e,className:`nice-kanban nice-kanban--${c} nice-kanban--${oe} nice-kanban--layout-${w} ${d?"nice-kanban--disabled":""} ${we||""}`,style:{position:"relative",...B},...ke,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(N.NiceTutorialButton,{steps:N.resolveTutorial(H,sa)})}),t.map(W=>{const be=Me(W.key),De=A?.column===W.key,qe=W.limit!=null&&be.length>=W.limit,Re=f&&ze.includes(W.key);return e.jsxs("div",{className:`nice-kanban__column ${De?"nice-kanban__column--dragover":""} ${Re?`nice-kanban__column--collapsed nice-kanban__column--collapse-${m}`:""}`,onDragOver:ie=>!Re&&ct(ie,W.key),onDragLeave:it,onDrop:ie=>!Re&&at(ie,W.key),children:[e.jsxs("div",{className:"nice-kanban__column-header",style:W.color?{borderTopColor:W.color}:void 0,onClick:f?()=>Le(W.key):void 0,role:f?"button":void 0,tabIndex:f?0:void 0,onKeyDown:f?ie=>{(ie.key==="Enter"||ie.key===" ")&&Le(W.key)}:void 0,children:[f&&e.jsx("span",{className:"nice-kanban__collapse-icon","aria-hidden":"true",children:e.jsx(ia,{open:!Re})}),e.jsx("span",{className:"nice-kanban__column-title",children:W.title}),e.jsx("span",{className:"nice-kanban__column-count",children:W.limit!=null?e.jsxs("span",{className:"nice-kanban__count-frac",children:[e.jsx("span",{className:"nice-kanban__count-num",children:be.length}),e.jsx("span",{className:"nice-kanban__count-slash",children:"/"}),e.jsx("span",{className:"nice-kanban__count-den",children:W.limit})]}):be.length})]}),!Re&&e.jsxs("div",{className:"nice-kanban__column-body",children:[be.map(ie=>e.jsx("div",{className:`nice-kanban__card nice-kanban__card--${oe} ${$?.cardKey===ie.key?"nice-kanban__card--dragging":""}`,draggable:!d,onDragStart:J=>Se(J,ie),onDragEnd:ve,onClick:()=>ae(ie),role:de?"button":"article",tabIndex:de?0:void 0,onKeyDown:de?N.clickOnActivationKey:void 0,children:l?l(ie):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"nice-kanban__card-title",children:ie.title}),oe!=="compact"&&ie.description&&e.jsx("div",{className:"nice-kanban__card-desc",children:ie.description})]})},ie.key)),be.length===0&&e.jsx("div",{className:"nice-kanban__empty",children:Z("kanban.empty","No cards")})]}),!Re&&(o||k&&C)&&!qe&&e.jsxs("button",{type:"button",className:"nice-kanban__add",onClick:()=>ge(W.key),disabled:d,children:[e.jsx(aa,{})," ",Z("kanban.addCard","Add card")]})]},W.key)})]}),k&&pe&&e.jsxs(pi.NiceModal,{open:!0,onClose:()=>re(null),title:pe.key==null?_||Z("kanban.newCard","New card"):I||Z("kanban.editCard","Edit card"),children:[e.jsx(fi.NiceForm,{items:K,data:pe.data,columns:p,...b,onFieldChange:(W,be)=>re(De=>De&&{...De,data:{...De.data,[W]:be}})}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:16,flexWrap:"wrap"},children:[pe.key!=null&&G&&e.jsx(He.NiceButton,{type:"button",size:"sm",variant:"error",style:{marginRight:"auto"},onClick:()=>{G(pe.key),re(null)},children:Z("controls.delete","Delete")}),e.jsx(He.NiceButton,{type:"button",size:"sm",variant:"secondary",onClick:()=>re(null),children:Z("controls.cancel","Cancel")}),e.jsx(He.NiceButton,{type:"button",size:"sm",variant:"primary",onClick:()=>{if(pe.key==null){const W={key:`card-${Date.now()}`,title:"",column:pe.column,...pe.data};C?.(W)}else z?.(pe.key,{...pe.data,key:pe.key,column:pe.column});re(null)},children:Z("controls.save","Save")})]})]})]})}),{displayName:"NiceKanbanBoard"}),ca=[];function It(...t){return t.filter(Boolean).map(a=>typeof a=="object"?Object.entries(a).filter(([,s])=>s).map(([s])=>s).join(" "):a).join(" ")}const la=50,oa=[10,25,50,100,200],da=40,ua={compact:32,normal:da,comfortable:48},ha=10,ma=768,fa=500,pa=10;function bt(t,a){return a.split(".").reduce((s,r)=>s?.[r],t)}function Hn(t){return t.width==="auto"?{flex:"1 1 0",minWidth:t.minWidth??80,maxWidth:t.maxWidth}:{width:t.width||150,minWidth:t.minWidth,maxWidth:t.maxWidth}}function Zt(t,a,s="pl-PL"){if(t==null)return"—";switch(a.type){case"number":return new Intl.NumberFormat(s,{minimumFractionDigits:a.format?.includes(".")?a.format.split(".")[1].length:0}).format(t);case"currency":return new Intl.NumberFormat(s,{style:"currency",currency:a.currencyCode||"PLN"}).format(t);case"percent":return new Intl.NumberFormat(s,{style:"percent",minimumFractionDigits:0,maximumFractionDigits:2}).format(t/100);case"date":return new Intl.DateTimeFormat(s,{dateStyle:"short"}).format(new Date(t));case"datetime":return new Intl.DateTimeFormat(s,{dateStyle:"short",timeStyle:"short"}).format(new Date(t));case"boolean":return t?e.jsx(N.NiceIcon,{name:"check",size:14}):e.jsx(N.NiceIcon,{name:"close",size:14});case"enum":return a.enumOptions?.find(l=>l.value===t)?.label||String(t);default:return String(t)}}function ga(t,a,s,r){const[l,o]=n.useState(0),{startIndex:d,endIndex:c,totalHeight:f,offsetY:m}=n.useMemo(()=>{const P=t.length*s,R=Math.ceil(a/s),T=Math.max(0,Math.floor(l/s)-r),K=Math.min(t.length,Math.ceil(l/s)+R+r),p=T*s;return{startIndex:T,endIndex:K,totalHeight:P,offsetY:p}},[t.length,a,s,l,r]),w=n.useMemo(()=>t.slice(d,c),[t,d,c]),E=n.useCallback(P=>{o(P.currentTarget.scrollTop)},[]);return{visibleData:w,totalHeight:f,offsetY:m,handleScroll:E,startIndex:d}}function _a(t,a){const[s,r]=n.useState(()=>{if(t&&typeof window<"u"){const o=localStorage.getItem(`nice-module-grid-${t}`);if(o)return JSON.parse(o)}return a||{}}),l=n.useCallback(o=>{r(d=>{const c={...d,...o};return t&&typeof window<"u"&&localStorage.setItem(`nice-module-grid-${t}`,JSON.stringify(c)),c})},[t]);return[s,l]}function ba(t){const[a,s]=n.useState(typeof window<"u"&&window.innerWidth<t);return n.useEffect(()=>{if(typeof window>"u")return;const r=()=>s(window.innerWidth<t);return window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},[t]),a}function xa({column:t,sort:a,onSort:s,onResize:r,resizable:l,t:o}){const d=n.useRef(null),[c,f]=n.useState(!1),m=n.useCallback(P=>{if(!l||!r)return;P.preventDefault(),f(!0);const R=P.clientX,T=t.width||150,K=b=>{const I=b.clientX-R,_=Math.max(t.minWidth||50,T+I);r(t.field,Math.min(_,t.maxWidth||1/0))},p=()=>{f(!1),document.removeEventListener("mousemove",K),document.removeEventListener("mouseup",p)};document.addEventListener("mousemove",K),document.addEventListener("mouseup",p)},[t,l,r]),w=a?.direction,E=w==="asc"?e.jsx(N.NiceIcon,{name:"sort-asc",size:12}):w==="desc"?e.jsx(N.NiceIcon,{name:"sort-desc",size:12}):null;return e.jsxs("div",{className:It("nice-module-grid__header-cell",t.sortable&&"nice-module-grid__header-cell--sortable",c&&"nice-module-grid__header-cell--resizing"),style:{...Hn(t),textAlign:t.align},onClick:()=>t.sortable&&s?.(t.field),role:"columnheader","aria-sort":w==="asc"?"ascending":w==="desc"?"descending":"none",title:t.headerTooltip,children:[e.jsx("span",{className:"nice-module-grid__header-text",children:t.header}),E&&e.jsx("span",{className:"nice-module-grid__sort-indicator",children:E}),l&&e.jsx("div",{ref:d,className:"nice-module-grid__resize-handle",onMouseDown:m})]})}function ya({column:t,row:a,rowIndex:s,value:r,locale:l="pl-PL",onClick:o}){const{t:d}=N.useNiceTranslation(),c=N.useAccessibleClick({onClick:o}),f=o?c:{},m={...Hn(t),textAlign:t.align};if(t.render)return e.jsx("div",{className:"nice-module-grid__cell",style:m,role:"gridcell",...f,children:t.render(r,a,s)});if((t.type==="enum"||t.type==="badge")&&t.enumOptions){const w=t.enumOptions.find(E=>E.value===r);if(w)return e.jsx("div",{className:"nice-module-grid__cell",style:m,role:"gridcell",...f,children:e.jsxs("span",{className:It("nice-module-grid__badge",`nice-module-grid__badge--${w.color||"default"}`),children:[w.icon&&e.jsx("span",{className:"nice-module-grid__badge-icon",children:w.icon}),w.label]})})}if(t.type==="progress"){const w=Math.min(100,Math.max(0,Number(r)||0));return e.jsx("div",{className:"nice-module-grid__cell",style:m,role:"gridcell",...f,children:e.jsxs("div",{className:"nice-module-grid__progress",children:[e.jsx("div",{className:"nice-module-grid__progress-bar",children:e.jsx("div",{className:It("nice-module-grid__progress-fill",`nice-module-grid__progress-fill--${t.progressColor||"primary"}`),style:{width:`${w}%`}})}),e.jsxs("span",{className:"nice-module-grid__progress-text",children:[w,"%"]})]})})}if(t.type==="rating"){const w=t.maxRating||5,E=Number(r)||0;return e.jsx("div",{className:"nice-module-grid__cell",style:m,role:"gridcell",...f,children:e.jsx("span",{className:"nice-module-grid__rating","aria-label":d("pagination.outOfStars","{rating} out of {max} stars").replace("{rating}",String(E)).replace("{max}",String(w)),children:Array.from({length:w},(P,R)=>e.jsx("span",{className:It("nice-module-grid__rating-star",R<E&&"nice-module-grid__rating-star--filled"),children:e.jsx(N.NiceIcon,{name:"star",size:14})},R))})})}if(t.type==="link"&&t.linkTemplate){const w=t.linkTemplate.replace(/\{\{(\w+)\}\}/g,(E,P)=>String(bt(a,P)??""));return e.jsx("div",{className:"nice-module-grid__cell",style:m,role:"gridcell",...f,children:e.jsx("a",{href:w,target:t.linkNewTab?"_blank":void 0,rel:t.linkNewTab?"noopener noreferrer":void 0,className:"nice-module-grid__link",children:Zt(r,t,l)})})}if(t.type==="image"){const E={xs:24,sm:32,md:48,lg:64}[t.imageSize||"sm"];return e.jsx("div",{className:"nice-module-grid__cell",style:m,role:"gridcell",...f,children:r?e.jsx("img",{src:String(r),alt:"",className:"nice-module-grid__image",style:{width:E,height:E}}):e.jsx("div",{className:"nice-module-grid__image-placeholder",style:{width:E,height:E}})})}return t.type==="avatar"?e.jsx("div",{className:"nice-module-grid__cell",style:m,role:"gridcell",...f,children:r?e.jsx("img",{src:String(r),alt:"",className:"nice-module-grid__avatar"}):e.jsx("div",{className:"nice-module-grid__avatar-placeholder",children:"?"})}):t.type==="color"?e.jsx("div",{className:"nice-module-grid__cell",style:m,role:"gridcell",...f,children:e.jsx("span",{className:"nice-module-grid__color-swatch",style:{backgroundColor:r||"transparent"},title:r})}):t.type==="boolean"?e.jsx("div",{className:"nice-module-grid__cell",style:{...m,textAlign:t.align||"center"},role:"gridcell",...f,children:e.jsx("span",{className:It("nice-module-grid__boolean",!!r&&"nice-module-grid__boolean--true"),children:e.jsx(N.NiceIcon,{name:r?"check":"close",size:14})})}):e.jsx("div",{className:"nice-module-grid__cell",style:m,role:"gridcell",...f,children:Zt(r,t,l)})}function va({row:t,index:a,columns:s,primaryField:r,secondaryField:l,customRender:o,selected:d,onClick:c,locale:f="pl-PL",t:m}){const w={role:"option","aria-selected":!!d,onClick:c,onKeyDown:R=>{R.target===R.currentTarget&&(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),c?.())}};if(o)return e.jsx("div",{className:It("nice-module-grid__mobile-card",d&&"nice-module-grid__mobile-card--selected"),...w,children:o(t,a)});const E=s.find(R=>R.field===r)||s[0],P=s.find(R=>R.field===l)||s[1];return e.jsxs("div",{className:It("nice-module-grid__mobile-card",d&&"nice-module-grid__mobile-card--selected"),...w,children:[e.jsxs("div",{className:"nice-module-grid__mobile-card-header",children:[e.jsx("div",{className:"nice-module-grid__mobile-card-title",children:Zt(bt(t,E?.field||""),E,f)}),P&&e.jsx("div",{className:"nice-module-grid__mobile-card-subtitle",children:Zt(bt(t,P.field),P,f)})]}),e.jsx("div",{className:"nice-module-grid__mobile-card-body",children:s.filter(R=>!R.hidden&&R.field!==r&&R.field!==l).slice(0,4).map(R=>e.jsxs("div",{className:"nice-module-grid__mobile-card-field",children:[e.jsx("span",{className:"nice-module-grid__mobile-card-label",children:R.header}),e.jsx("span",{className:"nice-module-grid__mobile-card-value",children:Zt(bt(t,R.field),R,f)})]},R.field))})]})}function ka({page:t,pageSize:a,totalRows:s,pageSizeOptions:r,onPageChange:l,t:o}){const d=Math.ceil(s/a),c=(t-1)*a+1,f=Math.min(t*a,s);return e.jsxs("div",{className:"nice-module-grid__pagination",role:"navigation","aria-label":o("pagination.ariaLabel","Pagination"),children:[e.jsxs("div",{className:"nice-module-grid__pagination-info",children:[o("pagination.showing","Showing")," ",c,"–",f," ",o("pagination.of","of")," ",s]}),e.jsxs("div",{className:"nice-module-grid__pagination-controls",children:[e.jsx("select",{className:"nice-module-grid__page-size-select",value:a,onChange:m=>l(1,Number(m.target.value)),"aria-label":o("pagination.rowsPerPage","Rows per page"),children:r.map(m=>e.jsx("option",{value:m,children:m},m))}),e.jsx("button",{className:"nice-module-grid__pagination-btn",onClick:()=>l(1,a),disabled:t===1,"aria-label":o("pagination.first","First"),children:e.jsx(N.NiceIcon,{name:"skip-back",size:14})}),e.jsx("button",{className:"nice-module-grid__pagination-btn",onClick:()=>l(t-1,a),disabled:t===1,"aria-label":o("pagination.previous","Previous"),children:e.jsx(N.NiceIcon,{name:"chevron-left",size:14})}),e.jsxs("span",{className:"nice-module-grid__pagination-page",children:[t," / ",d]}),e.jsx("button",{className:"nice-module-grid__pagination-btn",onClick:()=>l(t+1,a),disabled:t>=d,"aria-label":o("pagination.next","Next"),children:e.jsx(N.NiceIcon,{name:"chevron-right",size:14})}),e.jsx("button",{className:"nice-module-grid__pagination-btn",onClick:()=>l(d,a),disabled:t>=d,"aria-label":o("pagination.last","Last"),children:e.jsx(N.NiceIcon,{name:"skip-forward",size:14})})]})]})}function Na({columns:t}){return e.jsx("div",{className:"nice-module-grid__row nice-module-grid__row--skeleton",role:"row",children:t.filter(a=>!a.hidden).map(a=>e.jsx("div",{className:"nice-module-grid__cell nice-module-grid__cell--skeleton",style:{width:a.width==="auto"?"auto":a.width||150},children:e.jsx("div",{className:"nice-module-grid__skeleton-bar"})},a.field))})}function wa(t,a){const{columns:s=ca,data:r,keyField:l="id",dataSource:o,onFetch:d,sortable:c=!0,sort:f,onSortChange:m,multiSort:w=!1,filter:E,searchText:P,onSearchChange:R,searchPlaceholder:T,pagination:K=!0,page:p,pageSize:b,pageSizeOptions:I=oa,totalRows:_,onPageChange:z,virtualScroll:C=!0,rowHeight:G,overscan:H=ha,selectionMode:he="none",selectedKeys:se,onSelectionChange:fe,columnResize:Ie=!0,onColumnWidthChange:ee,contextMenuItems:we,onContextMenuAction:B,exportable:$e=!0,exportFormats:ke=["csv","excel"],onExport:Pe,preferencesKey:Z,initialPreferences:$,density:O="normal",striped:A=!0,bordered:g=!1,hoverable:pe=!0,loading:re=!1,emptyState:k,toolbar:ae,onRowClick:de,onRowDoubleClick:ge,rowClassName:D,rowStyle:le,mobileCardView:_e=!0,mobileBreakpoint:ze=ma,mobileCardRender:oe,mobilePrimaryField:je,mobileSecondaryField:Le,size:Me="medium",skeletonLoading:Se=!0,skeletonRows:ct=pa,"aria-label":it,"aria-labelledby":at,"aria-describedby":ve,className:W,style:be,id:De,testId:qe}=t,Re=G??ua[O],{t:ie,lang:J}=N.useNiceTranslation();N.useNiceAccessMode(),N.useComponentDisplayStyle("table");const v=ba(ze),[xe,te]=_a(Z,$),Ve=n.useRef(null),ue=n.useRef(null),[Ue,Ke]=n.useState([]),[S,X]=n.useState(),[me,Ee]=n.useState(""),[st,Q]=n.useState(1),[Ae,Fe]=n.useState(b||la),[Ge,We]=n.useState(new Set),[Qe,Mt]=n.useState([]),[Dt,Ft]=n.useState(0),[Ut,gt]=n.useState(!1),[Lt,Pt]=n.useState(new Set),[lt,Ze]=n.useState(null),[At,Rt]=n.useState({}),ot=f??Ue,Tt=E??S,et=P??me,dt=p??st,h=b??Ae,u=se??Ge,M=!!(d||o),U=_??(M?Dt:r?.length??0),x=n.useMemo(()=>{const y=new Set(xe.hiddenColumns||[]);return s.filter(ne=>!ne.hidden&&!y.has(ne.field))},[s,xe.hiddenColumns]),L=n.useMemo(()=>{if(M)return Qe;if(!r)return[];let y=[...r];if(et){const ne=et.toLowerCase(),ye=s.filter(Ne=>Ne.searchable!==!1).map(Ne=>Ne.field);y=y.filter(Ne=>ye.some(ht=>{const yt=bt(Ne,ht);return String(yt??"").toLowerCase().includes(ne)}))}return ot.length>0&&y.sort((ne,ye)=>{for(const Ne of ot){const ht=bt(ne,Ne.field),yt=bt(ye,Ne.field),Nt=ht<yt?-1:ht>yt?1:0;if(Nt!==0)return Ne.direction==="asc"?Nt:-Nt}return 0}),y},[M,Qe,r,et,ot,s]),F=n.useMemo(()=>{if(M||!K)return L;const y=(dt-1)*h;return L.slice(y,y+h)},[M,L,K,dt,h]),V=Ve.current?.clientHeight||400,q=C&&F.length>fa,{visibleData:Oe,totalHeight:Ce,offsetY:Be,handleScroll:nt,startIndex:vt}=ga(F,V,Re,H),Ye=q?Oe:F,wt=n.useCallback(async()=>{if(d){gt(!0);try{const ne=await d({page:dt,pageSize:h,sort:ot,filter:Tt,search:et});Mt(ne.data),Ft(ne.total)}catch(y){console.error("NiceModuleGrid fetch error:",y)}finally{gt(!1)}}},[d,dt,h,ot,Tt,et]);n.useEffect(()=>{M&&wt()},[M,wt]);const kt=n.useCallback(y=>{const ne=ot.find(Ne=>Ne.field===y);let ye;ne?ne.direction==="asc"?ye=ot.map(Ne=>Ne.field===y?{...Ne,direction:"desc"}:Ne):ye=ot.filter(Ne=>Ne.field!==y):ye=w?[...ot,{field:y,direction:"asc"}]:[{field:y,direction:"asc"}],m?m(ye):Ke(ye)},[ot,w,m]),Ot=n.useCallback((y,ne)=>{z?z(y,ne):(Q(y),Fe(ne))},[z]),Xt=n.useCallback(y=>{R?R(y):Ee(y),z||Q(1)},[R,z]),Gt=n.useCallback((y,ne)=>{const ye=new Set(u);if(he==="single"?(ye.clear(),ye.add(y)):(he==="multiple"||he==="checkbox")&&(ye.has(y)?ye.delete(y):ye.add(y)),fe){const Ne=F.filter(ht=>ye.has(String(bt(ht,l))));fe(ye,Ne)}else We(ye)},[u,he,fe,F,l]),jt=n.useCallback((y,ne)=>{Rt(ye=>({...ye,[y]:ne})),ee?.(y,ne),te({columnWidths:{...xe.columnWidths,[y]:ne}})},[ee,te,xe.columnWidths]),zt=n.useCallback((y,ne)=>{if(we?.length)if(y.preventDefault(),y.clientX===0&&y.clientY===0){const ye=y.currentTarget.getBoundingClientRect();Ze({x:ye.left,y:ye.bottom,row:ne})}else Ze({x:y.clientX,y:y.clientY,row:ne})},[we]),St=n.useRef(null);N.useOverlayFocus(St,{open:lt!=null,modal:!1,onClose:()=>Ze(null)}),N.useRovingFocus(St,{orientation:"vertical",wrap:!0,typeahead:!0});const $t=n.useCallback(y=>{lt&&B?.(y,lt.row),Ze(null)},[lt,B]),Jt=n.useCallback(async y=>{if(Pe)await Pe(y,{selectedOnly:u.size>0,columns:x.map(ne=>ne.field)});else if(y==="csv"){const ne=x.map(ut=>ut.header).join(","),ye=F.map(ut=>x.map(en=>JSON.stringify(bt(ut,en.field)??"")).join(",")),Ne=[ne,...ye].join(`
|
|
7
|
+
`),ht=new Blob([Ne],{type:"text/csv;charset=utf-8;"}),yt=URL.createObjectURL(ht),Nt=document.createElement("a");Nt.href=yt,Nt.download=`export-${new Date().toISOString().slice(0,10)}.csv`,Nt.click(),URL.revokeObjectURL(yt)}},[Pe,u,x,F]);n.useEffect(()=>{if(!lt)return;const y=()=>Ze(null);return document.addEventListener("click",y),()=>document.removeEventListener("click",y)},[lt]),N.useGridFocus(ue,{pageSize:10});const Wt=n.useRef(null);N.useRovingFocus(Wt,{orientation:"vertical",pageSize:10});const Et=re||Ut,Qt=!Et&&Ye.length===0,xt=v&&_e,Vt=It("nice-module-grid",`nice-module-grid--${O}`,`nice-module-grid--${Me}`,A&&"nice-module-grid--striped",g&&"nice-module-grid--bordered",pe&&"nice-module-grid--hoverable",Et&&"nice-module-grid--loading",xt&&"nice-module-grid--mobile",W);return e.jsxs("div",{ref:a,id:De,"data-testid":qe,className:Vt,style:be,"aria-busy":Et,children:[e.jsxs("div",{className:"nice-module-grid__toolbar",children:[e.jsx("div",{className:"nice-module-grid__toolbar-search",children:e.jsx("input",{type:"search",className:"nice-module-grid__search-input",placeholder:T??ie("moduleGrid.searchPlaceholder","Search…"),value:et,onChange:y=>Xt(y.target.value),"aria-label":ie("moduleGrid.searchAriaLabel","Search")})}),ae,$e&&e.jsx("div",{className:"nice-module-grid__toolbar-export",children:ke.map(y=>e.jsx("button",{className:"nice-module-grid__export-btn",onClick:()=>Jt(y),"aria-label":ie(`moduleGrid.export.${y}`,`Export to ${y.toUpperCase()}`),children:y.toUpperCase()},y))})]}),e.jsx("div",{ref:Ve,className:"nice-module-grid__container",onScroll:q?nt:void 0,children:xt?e.jsx("div",{ref:Wt,className:"nice-module-grid__mobile-list",role:"listbox","aria-label":it,"aria-labelledby":at,"aria-describedby":ve,"aria-multiselectable":he==="checkbox"||void 0,children:Et&&Se?Array.from({length:ct},(y,ne)=>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}})]},ne)):Qt?e.jsxs("div",{className:"nice-module-grid__empty",children:[k?.icon&&e.jsx("div",{className:"nice-module-grid__empty-icon",children:k.icon}),e.jsx("div",{className:"nice-module-grid__empty-title",children:k?.title||ie("moduleGrid.noData","No data")}),k?.description&&e.jsx("div",{className:"nice-module-grid__empty-description",children:k.description}),k?.action&&e.jsxs("button",{className:"nice-module-grid__empty-action",onClick:k.action.onClick,children:[k.action.icon,k.action.label]})]}):Ye.map((y,ne)=>{const ye=String(bt(y,l));return e.jsx(va,{row:y,index:vt+ne,columns:x,primaryField:je,secondaryField:Le,customRender:oe,selected:u.has(ye),locale:J,onClick:()=>{he!=="none"&&Gt(ye,y),de?.(y,vt+ne)},t:ie},ye)})}):e.jsxs("div",{ref:ue,className:"nice-module-grid__table",role:"grid","aria-label":it,"aria-labelledby":at,"aria-describedby":ve,"aria-rowcount":U,"aria-colcount":x.length,children:[e.jsxs("div",{className:"nice-module-grid__header",role:"row",children:[he==="checkbox"&&e.jsx("div",{className:"nice-module-grid__header-cell nice-module-grid__header-cell--checkbox",role:"columnheader",children:e.jsx("input",{type:"checkbox",checked:u.size>0&&u.size===Ye.length,onChange:()=>{if(u.size===Ye.length)fe?.(new Set,[]),We(new Set);else{const y=new Set(Ye.map(ne=>String(bt(ne,l))));fe?.(y,Ye),We(y)}},"aria-label":ie("moduleGrid.selectAll","Select all")})}),x.map(y=>e.jsx(xa,{column:{...y,width:At[y.field]||y.width},sort:ot.find(ne=>ne.field===y.field),onSort:c?kt:void 0,onResize:Ie?jt:void 0,resizable:Ie,t:ie},y.field))]}),e.jsx("div",{className:"nice-module-grid__body",style:q?{height:Ce,position:"relative"}:void 0,children:Et&&Se?Array.from({length:ct},(y,ne)=>e.jsx(Na,{columns:x},ne)):Qt?e.jsxs("div",{className:"nice-module-grid__empty",children:[k?.icon&&e.jsx("div",{className:"nice-module-grid__empty-icon",children:k.icon}),e.jsx("div",{className:"nice-module-grid__empty-title",children:k?.title||ie("moduleGrid.noData","No data")}),k?.description&&e.jsx("div",{className:"nice-module-grid__empty-description",children:k.description}),k?.action&&e.jsxs("button",{className:"nice-module-grid__empty-action",onClick:k.action.onClick,children:[k.action.icon,k.action.label]})]}):e.jsx("div",{style:q?{transform:`translateY(${Be}px)`}:void 0,children:Ye.map((y,ne)=>{const ye=String(bt(y,l)),Ne=vt+ne,ht=u.has(ye),yt=typeof D=="function"?D(y,Ne):D,Nt=typeof le=="function"?le(y,Ne):le;return e.jsxs("div",{className:It("nice-module-grid__row",ht&&"nice-module-grid__row--selected",yt),style:{...Nt,height:Re},role:"row","aria-rowindex":Ne+1,"aria-selected":ht,onClick:()=>{he!=="none"&&Gt(ye,y),de?.(y,Ne)},onDoubleClick:()=>ge?.(y,Ne),onContextMenu:ut=>zt(ut,y),children:[he==="checkbox"&&e.jsx("div",{className:"nice-module-grid__cell nice-module-grid__cell--checkbox",role:"gridcell",children:e.jsx("input",{type:"checkbox",checked:ht,onChange:()=>Gt(ye,y),onClick:ut=>ut.stopPropagation(),"aria-label":ie("moduleGrid.selectRow","Select row")})}),x.map(ut=>e.jsx(ya,{column:{...ut,width:At[ut.field]||ut.width},row:y,rowIndex:Ne,value:bt(y,ut.field),locale:J},ut.field))]},ye)})})})]})}),K&&U>0&&e.jsx(ka,{page:dt,pageSize:h,totalRows:M?Dt:L.length,pageSizeOptions:I,onPageChange:Ot,t:ie}),lt&&we&&e.jsx("div",{ref:St,className:"nice-module-grid__context-menu",style:{left:lt.x,top:lt.y},role:"menu",children:we.filter(y=>typeof y.hidden=="function"?!y.hidden(lt.row):!y.hidden).map(y=>{if(y.divider)return e.jsx("div",{className:"nice-module-grid__context-menu-divider"},y.key);const ne=typeof y.disabled=="function"?y.disabled(lt.row):y.disabled;return e.jsxs("button",{className:It("nice-module-grid__context-menu-item",y.danger&&"nice-module-grid__context-menu-item--danger",ne&&"nice-module-grid__context-menu-item--disabled"),onClick:()=>{ne||(y.onClick?.(lt.row),$t(y.key))},disabled:ne,role:"menuitem",children:[y.icon&&e.jsx("span",{className:"nice-module-grid__context-menu-icon",children:y.icon}),y.label]},y.key)})}),Et&&!Se&&e.jsx("div",{className:"nice-module-grid__loading-overlay",children:e.jsx("div",{className:"nice-module-grid__spinner","aria-label":ie("moduleGrid.loading","Loading")})})]})}const ja=n.forwardRef(wa),pt={width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0},Sa=()=>e.jsxs("svg",{...pt,children:[e.jsx("path",{d:"M3 7v6h6"}),e.jsx("path",{d:"M21 17a9 9 0 0 0-15-6.7L3 13"})]}),Ca=()=>e.jsxs("svg",{...pt,children:[e.jsx("path",{d:"M21 7v6h-6"}),e.jsx("path",{d:"M3 17a9 9 0 0 1 15-6.7L21 13"})]}),Ia=()=>e.jsxs("svg",{...pt,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"})]}),Ma=()=>e.jsxs("svg",{...pt,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"})]}),Da=()=>e.jsxs("svg",{...pt,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"})]}),Ea=()=>e.jsxs("svg",{...pt,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"})]}),Aa=()=>e.jsxs("svg",{...pt,children:[e.jsx("rect",{x:"4",y:"3",width:"6",height:"18",rx:"1"}),e.jsx("rect",{x:"14",y:"3",width:"6",height:"18",rx:"1"}),e.jsx("line",{x1:"11",y1:"12",x2:"13",y2:"12"})]}),Ra=()=>e.jsxs("svg",{...pt,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"})]}),Ta=()=>e.jsxs("svg",{...pt,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"})]}),za=()=>e.jsx("svg",{...pt,children:e.jsx("polyline",{points:"6 9 12 4 18 9"})}),$a=()=>e.jsx("svg",{...pt,children:e.jsx("polyline",{points:"6 15 12 20 18 15"})}),La=()=>e.jsxs("svg",{...pt,style:{opacity:.55},children:[e.jsx("polyline",{points:"6 9 12 4 18 9"}),e.jsx("polyline",{points:"6 15 12 20 18 15"})]}),Pa=()=>e.jsxs("svg",{...pt,children:[e.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),e.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),Oa=()=>e.jsxs("svg",{...pt,children:[e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"}),e.jsx("line",{x1:"6",y1:"18",x2:"18",y2:"6"})]});function Zn(t){let a="",s=t;for(;s>=0;)a=String.fromCharCode(65+s%26)+a,s=Math.floor(s/26)-1;return a}function Te(t,a){return`${Zn(a)}${t+1}`}function tt(t){const a=t.match(/^([A-Z]+)(\d+)$/);if(!a)return null;let s=0;for(let r=0;r<a[1].length;r++)s=s*26+(a[1].charCodeAt(r)-64);return{row:parseInt(a[2],10)-1,col:s-1}}function Fa(t,a,s=new Set){const r=t.startsWith("=")?t.slice(1).trim():t,l=(p,b)=>{if(!p||!b)return[];const I=[];for(let _=p.row;_<=b.row;_++)for(let z=p.col;z<=b.col;z++){const C=Je(Te(_,z),a,new Set(s));typeof C=="number"&&I.push(C)}return I},o=(p,b)=>{if(!p||!b)return[];const I=[];for(let _=p.row;_<=b.row;_++)for(let z=p.col;z<=b.col;z++)I.push(Je(Te(_,z),a,new Set(s)));return I},d=r.match(/^(\w+)\(([A-Z]+\d+):([A-Z]+\d+)\)$/i);if(d){const p=d[1].toUpperCase(),b=tt(d[2].toUpperCase()),I=tt(d[3].toUpperCase());switch(p){case"SUM":return l(b,I).reduce((z,C)=>z+C,0);case"AVG":case"AVERAGE":{const _=l(b,I);return _.length>0?_.reduce((z,C)=>z+C,0)/_.length:0}case"COUNT":return l(b,I).length;case"COUNTA":return o(b,I).filter(_=>_!==null&&_!=="").length;case"COUNTBLANK":return o(b,I).filter(_=>_===null||_==="").length;case"MIN":{const _=l(b,I);return _.length?Math.min(..._):0}case"MAX":{const _=l(b,I);return _.length?Math.max(..._):0}case"MEDIAN":{const _=l(b,I).sort((C,G)=>C-G);if(!_.length)return 0;const z=Math.floor(_.length/2);return _.length%2?_[z]:(_[z-1]+_[z])/2}case"STDEV":{const _=l(b,I);if(_.length<2)return 0;const z=_.reduce((C,G)=>C+G,0)/_.length;return Math.sqrt(_.reduce((C,G)=>C+(G-z)**2,0)/(_.length-1))}case"PRODUCT":{const _=l(b,I);return _.length?_.reduce((z,C)=>z*C,1):0}}}const c=r.match(/^(SUMIF|COUNTIF)\(([A-Z]+\d+):([A-Z]+\d+)\s*,\s*"?([^"]*)"?\)$/i);if(c){const p=c[1].toUpperCase(),b=tt(c[2].toUpperCase()),I=tt(c[3].toUpperCase()),_=c[4];if(b&&I){let z=0;for(let C=b.row;C<=I.row;C++)for(let G=b.col;G<=I.col;G++){const H=Je(Te(C,G),a,new Set(s));(_.startsWith(">")?Number(H)>Number(_.slice(1)):_.startsWith("<")?Number(H)<Number(_.slice(1)):String(H)===_||typeof H=="number"&&H===Number(_))&&(z+=p==="SUMIF"?typeof H=="number"?H:0:1)}return z}}const f=r.match(/^IF\(([^,]+),\s*([^,]+),\s*([^)]+)\)$/i);if(f){const p=f[1].trim(),b=f[2].trim(),I=f[3].trim(),_=p.match(/^([A-Z]+\d+)\s*([><=!]+)\s*(\S+)$/i);let z=!1;if(_){const H=Je(_[1].toUpperCase(),a,new Set(s)),he=isNaN(Number(_[3]))?_[3].replace(/^"|"$/g,""):Number(_[3]),se=_[2],fe=typeof H=="number"?H:Number(H)||0,Ie=typeof he=="number"?he:Number(he)||0;switch(se){case">":z=fe>Ie;break;case"<":z=fe<Ie;break;case">=":z=fe>=Ie;break;case"<=":z=fe<=Ie;break;case"=":case"==":z=fe===Ie;break;case"<>":case"!=":z=fe!==Ie;break}}const C=z?b:I;if(tt(C.toUpperCase()))return Je(C.toUpperCase(),a,new Set(s));const G=Number(C);return isNaN(G)?C.replace(/^"|"$/g,""):G}const m=r.match(/^CONCAT\((.+)\)$/i);if(m)return m[1].split(",").map(b=>b.trim()).map(b=>{if(b.startsWith('"')&&b.endsWith('"'))return b.slice(1,-1);if(tt(b.toUpperCase())){const _=Je(b.toUpperCase(),a,new Set(s));return _!==null?String(_):""}return b}).join("");const w=r.match(/^VLOOKUP\(([^,]+),\s*([A-Z]+\d+):([A-Z]+\d+),\s*(\d+)\)$/i);if(w){let p;tt(w[1].trim().toUpperCase())?p=Je(w[1].trim().toUpperCase(),a,new Set(s)):p=isNaN(Number(w[1]))?w[1].replace(/^"|"$/g,""):Number(w[1]);const I=tt(w[2].toUpperCase()),_=tt(w[3].toUpperCase()),z=parseInt(w[4])-1;if(I&&_)for(let C=I.row;C<=_.row;C++){const G=Je(Te(C,I.col),a,new Set(s));if(String(G)===String(p))return Je(Te(C,I.col+z),a,new Set(s))}return null}const E=r.match(/^(ABS|ROUND|FLOOR|CEIL|CEILING|SQRT|LEN|UPPER|LOWER|TRIM|INT)\(([^)]+)\)$/i);if(E){const p=E[1].toUpperCase(),b=E[2].trim();let I;switch(tt(b.toUpperCase())?I=Je(b.toUpperCase(),a,new Set(s)):I=isNaN(Number(b))?b.replace(/^"|"$/g,""):Number(b),p){case"ABS":return Math.abs(Number(I)||0);case"ROUND":return Math.round(Number(I)||0);case"FLOOR":return Math.floor(Number(I)||0);case"CEIL":case"CEILING":return Math.ceil(Number(I)||0);case"SQRT":return Math.sqrt(Number(I)||0);case"INT":return Math.trunc(Number(I)||0);case"LEN":return String(I??"").length;case"UPPER":return String(I??"").toUpperCase();case"LOWER":return String(I??"").toLowerCase();case"TRIM":return String(I??"").trim()}}const P=r.match(/^POWER\(([^,]+),\s*([^)]+)\)$/i);if(P){const p=Number(tt(P[1].trim().toUpperCase())?Je(P[1].trim().toUpperCase(),a,new Set(s)):P[1].trim())||0,b=Number(tt(P[2].trim().toUpperCase())?Je(P[2].trim().toUpperCase(),a,new Set(s)):P[2].trim())||0;return Math.pow(p,b)}if(/^NOW\(\)$/i.test(r))return new Date().toISOString();if(/^TODAY\(\)$/i.test(r))return new Date().toISOString().split("T")[0];if(/^PI\(\)$/i.test(r))return Math.PI;const R=r.match(/^([A-Z]+\d+)$/i);if(R)return Je(R[1].toUpperCase(),a,s);const T=r.match(/^([A-Z]+\d+)\s*([+\-*/])\s*([A-Z]+\d+|\d+\.?\d*)$/i);if(T){const p=T[1].toUpperCase(),b=T[2],I=T[3],_=Je(p,a,s),C=tt(I.toUpperCase())?Je(I.toUpperCase(),a,s):parseFloat(I),G=typeof _=="number"?_:0,H=typeof C=="number"?C:0;switch(b){case"+":return G+H;case"-":return G-H;case"*":return G*H;case"/":return H!==0?G/H:null}}const K=parseFloat(r);return isNaN(K)?r:K}function Je(t,a,s){if(s.has(t))return null;s.add(t);const r=a[t];return r?r.formula?Fa(r.formula,a,s):r.value:null}function Bn(t,a){return t==null?"":a==="percent"&&typeof t=="number"?`${(t*100).toFixed(1)}%`:a==="currency"&&typeof t=="number"?`$${t.toFixed(2)}`:String(t)}function Un(t){return{name:t,data:{}}}const Va=Object.assign(n.forwardRef(({sheets:t,activeSheet:a,rows:s=50,cols:r=26,showToolbar:l=!0,showFormulaBar:o=!0,showSheetTabs:d=!0,readOnly:c=!1,disabled:f=!1,loading:m=!1,error:w,size:E="md",onChange:P,onActiveSheetChange:R,onCellSelect:T,onCopy:K,onPaste:p,onInsert:b,onRemove:I,maxUndo:_=50,sortable:z=!1,filterable:C=!1,rangeSelection:G=!0,className:H,style:he,id:se,...fe},Ie)=>{const ee=c||f,we=N.useControlId(se),{t:B}=N.useNiceTranslation(),[$e,ke]=n.useState(()=>t??[Un(B("spreadsheet.sheet","Sheet")+" 1")]),[Pe,Z]=n.useState(0),$=t??$e,O=a??Pe,A=$[O]??$[0],[g,pe]=n.useState(null),[re,k]=n.useState(null),[ae,de]=n.useState(!1),[ge,D]=n.useState(null),[le,_e]=n.useState(""),ze=n.useRef(null),oe=n.useRef(null),[je,Le]=n.useState([]),[Me,Se]=n.useState([]),[ct,it]=n.useState(null),at=n.useRef({x:0,width:80}),[ve,W]=n.useState(null),[be,De]=n.useState(null),qe=n.useRef(null);N.useRovingFocus(qe,{orientation:"horizontal",wrap:!0,activateOnMove:!0});const[Re,ie]=n.useState("");n.useEffect(()=>{ge&&ze.current&&ze.current.focus()},[ge]);const J=n.useMemo(()=>{if(!g)return null;const h=re??g;return{startRow:Math.min(g.row,h.row),startCol:Math.min(g.col,h.col),endRow:Math.max(g.row,h.row),endCol:Math.max(g.col,h.col)}},[g,re]),v=n.useCallback((h,u)=>J?h>=J.startRow&&h<=J.endRow&&u>=J.startCol&&u<=J.endCol:!1,[J]),xe=n.useCallback(h=>{Le(u=>{const M=[...u,h.map(U=>({...U,data:{...U.data}}))];return M.length>_?M.slice(-_):M}),Se([])},[_]),te=n.useCallback((h,u=!0)=>{u&&xe($);const M=h($);t||ke(M),P?.(M)},[$,t,P,xe]),Ve=n.useCallback(()=>{if(je.length===0)return;const h=je[je.length-1];Se(u=>[...u,$.map(M=>({...M,data:{...M.data}}))]),Le(u=>u.slice(0,-1)),t||ke(h),P?.(h)},[je,$,t,P]),ue=n.useCallback(()=>{if(Me.length===0)return;const h=Me[Me.length-1];Le(u=>[...u,$.map(M=>({...M,data:{...M.data}}))]),Se(u=>u.slice(0,-1)),t||ke(h),P?.(h)},[Me,$,t,P]),Ue=n.useCallback(h=>{a||Z(h),R?.(h),pe(null),k(null),D(null)},[a,R]),Ke=n.useCallback((h,u,M)=>{const U=Te(h,u);te(x=>{const L=x.map((V,q)=>q===O?{...V,data:{...V.data}}:V),F=M.startsWith("=");return L[O].data[U]={...L[O].data[U]??{value:null},formula:F?M:void 0,value:F?null:isNaN(Number(M))?M:Number(M)},L})},[O,te]),S=n.useCallback((h,u,M)=>{M?.shiftKey&&G&&g?k({row:h,col:u}):(pe({row:h,col:u}),k(null)),D(null),T?.(O,h,u)},[O,T,G,g]),X=n.useCallback((h,u,M)=>{M.button===0&&(S(h,u,M),G&&!M.shiftKey&&de(!0))},[S,G]),me=n.useCallback((h,u)=>{ae&&k({row:h,col:u})},[ae]);n.useEffect(()=>{if(!ae)return;const h=()=>de(!1);return document.addEventListener("mouseup",h),()=>document.removeEventListener("mouseup",h)},[ae]);const Ee=n.useCallback((h,u)=>{if(ee)return;const M=Te(h,u),U=A.data[M];U?.readOnly||(D({row:h,col:u}),_e(U?.formula??(U?.value!=null?String(U.value):"")))},[ee,A.data]),st=n.useCallback(()=>{ge&&(Ke(ge.row,ge.col,le),D(null))},[ge,le,Ke]),Q=n.useCallback(h=>{if(h.key==="Enter")st();else if(h.key==="Escape")D(null);else if(h.key==="Tab"&&ge&&(h.preventDefault(),st(),g)){const u=h.shiftKey?Math.max(0,g.col-1):Math.min(r-1,g.col+1);pe({row:g.row,col:u})}},[st,g,r,ge]),Ae=n.useCallback((h,u)=>{if(!g)return;const M=J??{startRow:g.row,startCol:g.col,endRow:g.row,endCol:g.col};te(U=>{const x=U.map((L,F)=>F===O?{...L,data:{...L.data}}:L);for(let L=M.startRow;L<=M.endRow;L++)for(let F=M.startCol;F<=M.endCol;F++){const V=Te(L,F);x[O].data[V]={...x[O].data[V]??{value:null},[h]:u}}return x})},[g,J,O,te]),Fe=n.useCallback(h=>{if(!J||K?.(J)===!1)return;const{startRow:u,startCol:M,endRow:U,endCol:x}=J,L=[];for(let F=u;F<=U;F++){const V=[];for(let q=M;q<=x;q++){const Oe=Te(F,q),Ce=A.data[Oe],Be=Ce?Je(Oe,A.data,new Set):null;V.push(Bn(Be,Ce?.format))}L.push(V.join(" "))}h.clipboardData.setData("text/plain",L.join(`
|
|
8
|
+
`)),h.preventDefault()},[J,A.data,K]),Ge=n.useCallback(h=>{if(ee||!g)return;const u=h.clipboardData.getData("text/plain");if(!u)return;const M=u.split(`
|
|
9
|
+
`).map(U=>U.split(" "));p?.(M,g.row,g.col)!==!1&&(te(U=>{const x=U.map((L,F)=>F===O?{...L,data:{...L.data}}:L);return M.forEach((L,F)=>{L.forEach((V,q)=>{const Oe=Te(g.row+F,g.col+q),Ce=V.startsWith("=");x[O].data[Oe]={...x[O].data[Oe]??{value:null},formula:Ce?V:void 0,value:Ce?null:isNaN(Number(V))?V:Number(V)}})}),x}),h.preventDefault())},[ee,g,O,te,p]),We=n.useCallback(h=>{te(u=>u.map((U,x)=>{if(x!==O)return U;const L={};for(const[F,V]of Object.entries(U.data)){const q=tt(F);q&&(q.row>h?L[Te(q.row+1,q.col)]=V:L[F]=V)}return{...U,data:L}})),b?.("row",h)},[O,te,b]),Qe=n.useCallback(h=>{te(u=>u.map((U,x)=>{if(x!==O)return U;const L={};for(const[F,V]of Object.entries(U.data)){const q=tt(F);q&&(q.col>h?L[Te(q.row,q.col+1)]=V:L[F]=V)}return{...U,data:L}})),b?.("column",h)},[O,te,b]),Mt=n.useCallback(h=>{te(u=>u.map((U,x)=>{if(x!==O)return U;const L={};for(const[F,V]of Object.entries(U.data)){const q=tt(F);q&&q.row!==h&&(q.row>h?L[Te(q.row-1,q.col)]=V:L[F]=V)}return{...U,data:L}})),I?.("row",h)},[O,te,I]),Dt=n.useCallback(h=>{te(u=>u.map((U,x)=>{if(x!==O)return U;const L={};for(const[F,V]of Object.entries(U.data)){const q=tt(F);q&&q.col!==h&&(q.col>h?L[Te(q.row,q.col-1)]=V:L[F]=V)}return{...U,data:L}})),I?.("column",h)},[O,te,I]),Ft=n.useCallback((h,u)=>{te(M=>M.map((x,L)=>{if(L!==O)return x;const F=new Map;for(const[Oe,Ce]of Object.entries(x.data)){const Be=tt(Oe);Be&&(F.has(Be.row)||F.set(Be.row,{}),F.get(Be.row)[Be.col]=Ce)}const V=Array.from(F.entries()).sort((Oe,Ce)=>{const Be=Je(Te(Oe[0],h),x.data,new Set),nt=Je(Te(Ce[0],h),x.data,new Set),vt=typeof Be=="number"?Be:Number(Be),Ye=typeof nt=="number"?nt:Number(nt);if(!isNaN(vt)&&!isNaN(Ye))return u==="asc"?vt-Ye:Ye-vt;const wt=String(Be??""),kt=String(nt??"");return u==="asc"?wt.localeCompare(kt):kt.localeCompare(wt)}),q={};return V.forEach(([,Oe],Ce)=>{for(const[Be,nt]of Object.entries(Oe))q[Te(Ce,Number(Be))]=nt}),{...x,data:q,sortColumn:h,sortDirection:u}}))},[O,te]),Ut=n.useCallback((h,u)=>{const M=A.conditionalFormats;if(!M?.length)return;const U=Te(h,u),x=Je(U,A.data,new Set),L=typeof x=="number"?x:Number(x);for(const F of M){const V=F.range.match(/^([A-Z]+\d+):([A-Z]+\d+)$/i);if(!V)continue;const q=tt(V[1].toUpperCase()),Oe=tt(V[2].toUpperCase());if(!q||!Oe||h<q.row||h>Oe.row||u<q.col||u>Oe.col)continue;let Ce=!1;switch(F.type){case"greaterThan":Ce=!isNaN(L)&&L>Number(F.value);break;case"lessThan":Ce=!isNaN(L)&&L<Number(F.value);break;case"equalTo":Ce=String(x)===String(F.value);break;case"between":Ce=!isNaN(L)&&L>=Number(F.value)&&L<=Number(F.value2);break;case"textContains":Ce=String(x).includes(String(F.value));break;case"isEmpty":Ce=x===null||x==="";break;case"isNotEmpty":Ce=x!==null&&x!=="";break}if(Ce)return{backgroundColor:F.style.bgColor,color:F.style.color,fontWeight:F.style.bold?"bold":void 0,fontStyle:F.style.italic?"italic":void 0}}},[A.conditionalFormats,A.data]),gt=n.useCallback(()=>{const h=`${B("spreadsheet.sheet","Sheet")} ${$.length+1}`;te(u=>[...u,Un(h)]),Ue($.length)},[$.length,te,Ue,B]),Lt=n.useCallback(()=>{$.length<=1||(te(h=>h.filter((u,M)=>M!==O)),Ue(Math.max(0,O-1)))},[$.length,O,te,Ue]),Pt=n.useCallback((h,u)=>{u.trim()&&(te(M=>M.map((U,x)=>x===h?{...U,name:u.trim()}:U),!1),De(null))},[te]),lt=n.useMemo(()=>{if(!g)return"";const h=Te(g.row,g.col),u=A.data[h];return u?.formula??(u?.value!=null?String(u.value):"")},[g,A.data]),Ze=n.useMemo(()=>{if(!J)return null;const{startRow:h,startCol:u,endRow:M,endCol:U}=J;if(h===M&&u===U)return null;const x=[];let L=0;for(let F=h;F<=M;F++)for(let V=u;V<=U;V++){const q=Te(F,V),Oe=Je(q,A.data,new Set);Oe!==null&&Oe!==""&&L++,typeof Oe=="number"&&x.push(Oe)}return x.length===0?{count:L}:{count:L,sum:x.reduce((F,V)=>F+V,0),avg:x.reduce((F,V)=>F+V,0)/x.length,min:Math.min(...x),max:Math.max(...x)}},[J,A.data]),At=n.useCallback((h,u)=>{u.preventDefault(),u.stopPropagation(),it(h),at.current={x:u.clientX,width:A.colWidths?.[h]??80}},[A.colWidths]);n.useEffect(()=>{if(ct===null)return;const h=M=>{const U=M.clientX-at.current.x,x=Math.max(30,at.current.width+U);te(L=>L.map((V,q)=>q===O?{...V,colWidths:{...V.colWidths,[ct]:x}}:V),!1)},u=()=>it(null);return document.addEventListener("mousemove",h),document.addEventListener("mouseup",u),()=>{document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",u)}},[ct,O,te]);const Rt=n.useCallback((h,u,M)=>{h.preventDefault(),pe({row:u,col:M}),W({x:h.clientX,y:h.clientY})},[]);n.useEffect(()=>{if(!ve)return;const h=()=>W(null);return document.addEventListener("click",h),()=>document.removeEventListener("click",h)},[ve]);const ot=n.useCallback(h=>{if((h.ctrlKey||h.metaKey)&&!ge){if(h.key==="z"){h.preventDefault(),Ve();return}if(h.key==="y"){h.preventDefault(),ue();return}}if(ge||!g)return;let{row:u,col:M}=g;switch(h.key){case"ArrowUp":u=Math.max(0,u-1);break;case"ArrowDown":u=Math.min(s-1,u+1);break;case"ArrowLeft":M=Math.max(0,M-1);break;case"ArrowRight":M=Math.min(r-1,M+1);break;case"Home":M=0,u=h.ctrlKey||h.metaKey?0:u;break;case"End":M=r-1,u=h.ctrlKey||h.metaKey?s-1:u;break;case"PageUp":u=Math.max(0,u-10);break;case"PageDown":u=Math.min(s-1,u+10);break;case"Enter":Ee(u,M);return;case"Delete":case"Backspace":ee||(J&&(J.startRow!==J.endRow||J.startCol!==J.endCol)?te(U=>{const x=U.map((L,F)=>F===O?{...L,data:{...L.data}}:L);for(let L=J.startRow;L<=J.endRow;L++)for(let F=J.startCol;F<=J.endCol;F++)delete x[O].data[Te(L,F)];return x}):Ke(u,M,""));return;default:if(h.key.length===1&&!h.ctrlKey&&!h.metaKey&&!ee){D({row:u,col:M}),_e(h.key);return}return}h.preventDefault(),h.shiftKey&&G?k({row:u,col:M}):(pe({row:u,col:M}),k(null)),T?.(O,u,M)},[ge,g,s,r,ee,Ee,Ke,O,T,Ve,ue,J,te,G]),Tt=A.frozenRows??0,et=A.frozenCols??0,dt=[{value:"text",label:B("spreadsheet.formatText","Text")},{value:"number",label:B("spreadsheet.formatNumber","Number")},{value:"percent",label:B("spreadsheet.formatPercent","Percent")},{value:"currency",label:B("spreadsheet.formatCurrency","Currency")},{value:"date",label:B("spreadsheet.formatDate","Date")}];return e.jsxs("div",{ref:Ie,id:we,className:`nice-spreadsheet nice-spreadsheet--${E} ${c&&!f?"nice-spreadsheet--readonly":""} ${f?"nice-spreadsheet--disabled":""} ${m?"nice-spreadsheet--loading":""} ${w?"nice-spreadsheet--error":""} ${H??""}`,style:{...he,position:m?"relative":he?.position},onKeyDown:ot,onCopy:Fe,onPaste:Ge,tabIndex:f?-1:0,role:"application","aria-label":B("spreadsheet.label","Spreadsheet"),"aria-disabled":f||void 0,"aria-busy":m||void 0,...fe,children:[w&&e.jsx("div",{className:"nice-spreadsheet__error",role:"alert",children:w}),m&&e.jsx("span",{className:"nice-spreadsheet__spinner","aria-hidden":"true",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),l&&!ee&&e.jsxs("div",{className:"nice-spreadsheet__toolbar",role:"toolbar",children:[e.jsx(He.NiceButton,{variant:"ghost",size:"sm",onClick:Ve,disabled:je.length===0,title:B("spreadsheet.undo","Undo"),children:e.jsx(Sa,{})}),e.jsx(He.NiceButton,{variant:"ghost",size:"sm",onClick:ue,disabled:Me.length===0,title:B("spreadsheet.redo","Redo"),children:e.jsx(Ca,{})}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(He.NiceButton,{variant:A.data[g?Te(g.row,g.col):""]?.bold?"primary":"ghost",size:"sm",onClick:()=>Ae("bold",!A.data[g?Te(g.row,g.col):""]?.bold),title:B("spreadsheet.bold","Bold"),children:e.jsx("strong",{children:"B"})}),e.jsx(He.NiceButton,{variant:A.data[g?Te(g.row,g.col):""]?.italic?"primary":"ghost",size:"sm",onClick:()=>Ae("italic",!A.data[g?Te(g.row,g.col):""]?.italic),title:B("spreadsheet.italic","Italic"),children:e.jsx("em",{children:"I"})}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(He.NiceButton,{variant:"ghost",size:"sm",onClick:()=>Ae("align","left"),title:B("spreadsheet.alignLeft","Align left"),children:e.jsx(Ia,{})}),e.jsx(He.NiceButton,{variant:"ghost",size:"sm",onClick:()=>Ae("align","center"),title:B("spreadsheet.alignCenter","Center"),children:e.jsx(Ma,{})}),e.jsx(He.NiceButton,{variant:"ghost",size:"sm",onClick:()=>Ae("align","right"),title:B("spreadsheet.alignRight","Align right"),children:e.jsx(Da,{})}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(Pn.NiceColorPicker,{value:A.data[g?Te(g.row,g.col):""]?.bgColor??"var(--nice-bg-primary, #ffffff)",onChange:h=>Ae("bgColor",h),title:B("spreadsheet.bgColor","Background color"),showInput:!1,showRandom:!1}),e.jsx(Pn.NiceColorPicker,{value:A.data[g?Te(g.row,g.col):""]?.color??"var(--nice-text-primary, #000000)",onChange:h=>Ae("color",h),title:B("spreadsheet.textColor","Text color"),showInput:!1,showRandom:!1}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(_i.NiceSelect,{size:"sm",value:A.data[g?Te(g.row,g.col):""]?.format??"text",onChange:h=>Ae("format",h),options:dt,"aria-label":B("spreadsheet.format","Cell format")}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(He.NiceButton,{variant:"ghost",size:"sm",onClick:()=>g&&We(g.row),title:B("spreadsheet.insertRow","Insert row"),children:e.jsx(Ea,{})}),e.jsx(He.NiceButton,{variant:"ghost",size:"sm",onClick:()=>g&&Qe(g.col),title:B("spreadsheet.insertCol","Insert column"),children:e.jsx(Aa,{})}),e.jsx(He.NiceButton,{variant:"ghost",size:"sm",onClick:()=>g&&Mt(g.row),title:B("spreadsheet.deleteRow","Delete row"),children:e.jsx(Ra,{})}),e.jsx(He.NiceButton,{variant:"ghost",size:"sm",onClick:()=>g&&Dt(g.col),title:B("spreadsheet.deleteCol","Delete column"),children:e.jsx(Ta,{})})]}),o&&e.jsxs("div",{className:"nice-spreadsheet__formula-bar",children:[e.jsxs("span",{className:"nice-spreadsheet__cell-label",children:[g?Te(g.row,g.col):"",J&&J.startRow!==J.endRow||J&&J.startCol!==J.endCol?`:${Te(J.endRow,J.endCol)}`:""]}),e.jsx(Ln.NiceTextInput,{className:"nice-spreadsheet__formula-input",value:ge?le:lt,onChange:h=>{ge?_e(h):g&&(D(g),_e(h))},onKeyDown:Q,readOnly:ee,"aria-label":B("spreadsheet.formulaBar","Formula bar")})]}),e.jsx("div",{className:"nice-spreadsheet__grid",ref:oe,children:e.jsxs("table",{role:"grid","aria-label":A.name,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"nice-spreadsheet__corner"}),Array.from({length:r},(h,u)=>e.jsxs("th",{className:`nice-spreadsheet__col-header ${u<et?"nice-spreadsheet__col-header--frozen":""}`,style:{width:A.colWidths?.[u]??80,position:u<et?"sticky":void 0,left:u<et?u*80+40:void 0,zIndex:u<et?3:void 0},children:[e.jsx("span",{children:Zn(u)}),z&&e.jsx("span",{role:"button",tabIndex:0,onKeyDown:N.clickOnActivationKey,className:"nice-spreadsheet__sort-trigger",onClick:()=>Ft(u,A.sortColumn===u&&A.sortDirection==="asc"?"desc":"asc"),title:B("spreadsheet.sort","Sort"),children:A.sortColumn===u?A.sortDirection==="asc"?e.jsx(za,{}):e.jsx($a,{}):e.jsx(La,{})}),!ee&&e.jsx("span",{className:"nice-spreadsheet__col-resize",onMouseDown:M=>At(u,M)})]},u))]})}),e.jsx("tbody",{children:Array.from({length:s},(h,u)=>e.jsxs("tr",{className:u<Tt?"nice-spreadsheet__row--frozen":"",style:u<Tt?{position:"sticky",top:u*24,zIndex:2}:void 0,children:[e.jsx("td",{className:"nice-spreadsheet__row-header",children:u+1}),Array.from({length:r},(M,U)=>{const x=Te(u,U),L=A.data[x];if(L?.mergedInto)return null;const F=g?.row===u&&g?.col===U,V=v(u,U),q=ge?.row===u&&ge?.col===U,Oe=L?Je(x,A.data,new Set):null,Ce=Ut(u,U),Be=u<Tt||U<et;return e.jsxs("td",{className:`nice-spreadsheet__cell ${F?"nice-spreadsheet__cell--selected":""} ${V&&!F?"nice-spreadsheet__cell--in-range":""} ${L?.readOnly?"nice-spreadsheet__cell--readonly":""} ${Be?"nice-spreadsheet__cell--frozen":""}`,style:{textAlign:L?.align,fontWeight:L?.bold?"bold":void 0,fontStyle:L?.italic?"italic":void 0,backgroundColor:Ce?.backgroundColor??L?.bgColor,color:Ce?.color??L?.color,width:A.colWidths?.[U],height:A.rowHeights?.[u],position:Be?"sticky":void 0,left:U<et?U*80+40:void 0,zIndex:Be?1:void 0,...Ce},colSpan:L?.colSpan,rowSpan:L?.rowSpan,onMouseDown:nt=>X(u,U,nt),onMouseEnter:()=>me(u,U),onDoubleClick:()=>Ee(u,U),onContextMenu:nt=>Rt(nt,u,U),role:"gridcell","aria-selected":F,title:L?.comment,children:[L?.comment&&e.jsx("span",{className:"nice-spreadsheet__comment-indicator"}),q?e.jsx("input",{ref:ze,className:"nice-spreadsheet__cell-editor",value:le,onChange:nt=>_e(nt.target.value),onKeyDown:Q,onBlur:st}):Bn(Oe,L?.format)]},U)})]},u))})]})}),ve&&!ee&&g&&e.jsxs("div",{className:"nice-spreadsheet__context-menu",style:{position:"fixed",left:ve.x,top:ve.y,zIndex:1e3},children:[e.jsx(He.NiceButton,{variant:"ghost",size:"sm",onClick:()=>{We(g.row),W(null)},children:B("spreadsheet.insertRowAbove","Insert row above")}),e.jsx(He.NiceButton,{variant:"ghost",size:"sm",onClick:()=>{We(g.row+1),W(null)},children:B("spreadsheet.insertRowBelow","Insert row below")}),e.jsx(He.NiceButton,{variant:"ghost",size:"sm",onClick:()=>{Qe(g.col),W(null)},children:B("spreadsheet.insertColLeft","Insert column left")}),e.jsx(He.NiceButton,{variant:"ghost",size:"sm",onClick:()=>{Qe(g.col+1),W(null)},children:B("spreadsheet.insertColRight","Insert column right")}),e.jsx("hr",{className:"nice-spreadsheet__context-sep"}),e.jsx(He.NiceButton,{variant:"ghost",size:"sm",onClick:()=>{Mt(g.row),W(null)},children:B("spreadsheet.deleteRow","Delete row")}),e.jsx(He.NiceButton,{variant:"ghost",size:"sm",onClick:()=>{Dt(g.col),W(null)},children:B("spreadsheet.deleteCol","Delete column")})]}),Ze&&e.jsxs("div",{className:"nice-spreadsheet__status-bar",children:[e.jsxs("span",{children:[B("spreadsheet.count","Count"),": ",Ze.count]}),Ze.sum!==void 0&&e.jsxs("span",{children:[B("spreadsheet.sum","Sum"),": ",Ze.sum.toFixed(2)]}),Ze.avg!==void 0&&e.jsxs("span",{children:[B("spreadsheet.avg","Avg"),": ",Ze.avg.toFixed(2)]}),Ze.min!==void 0&&e.jsxs("span",{children:[B("spreadsheet.min","Min"),": ",Ze.min]}),Ze.max!==void 0&&e.jsxs("span",{children:[B("spreadsheet.max","Max"),": ",Ze.max]})]}),d&&e.jsxs("div",{className:"nice-spreadsheet__tabs",role:"tablist",ref:qe,children:[$.map((h,u)=>e.jsx("span",{className:"nice-spreadsheet__tab-wrapper",children:be===u?e.jsx(Ln.NiceTextInput,{className:"nice-spreadsheet__tab-rename",value:Re,onChange:M=>ie(M),onBlur:()=>Pt(u,Re),onKeyDown:M=>{M.key==="Enter"&&Pt(u,Re),M.key==="Escape"&&De(null)},autoFocus:!0}):e.jsx("span",{onDoubleClick:()=>{ee||(De(u),ie(h.name))},children:e.jsx(He.NiceButton,{variant:u===O?"primary":"ghost",size:"sm",role:"tab","aria-selected":u===O,onClick:()=>Ue(u),onKeyDown:M=>{M.key==="F2"&&!ee&&(M.preventDefault(),De(u),ie(h.name))},children:h.name})})},u)),!ee&&e.jsxs(e.Fragment,{children:[e.jsx(He.NiceButton,{variant:"ghost",size:"sm",onClick:gt,title:B("spreadsheet.addSheet","Add sheet"),children:e.jsx(Pa,{})}),$.length>1&&e.jsx(He.NiceButton,{variant:"ghost",size:"sm",onClick:Lt,title:B("spreadsheet.removeSheet","Remove sheet"),children:e.jsx(Oa,{})})]})]})]})}),{displayName:"NiceSpreadsheet"}),Ka=`
|
|
10
|
+
.nice-reconciliation {
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
height: 100%;
|
|
14
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
15
|
+
border: 1px solid var(--nice-border-color, #e5e7eb);
|
|
16
|
+
border-radius: var(--nice-radius-lg, 0.5rem);
|
|
17
|
+
overflow: hidden;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.nice-reconciliation__toolbar {
|
|
21
|
+
display: flex;
|
|
22
|
+
align-items: center;
|
|
23
|
+
gap: 0.75rem;
|
|
24
|
+
padding: 0.75rem 1rem;
|
|
25
|
+
background: var(--nice-bg-secondary, #f9fafb);
|
|
26
|
+
border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
|
|
27
|
+
flex-wrap: wrap;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.nice-reconciliation__toolbar-group {
|
|
31
|
+
display: flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
gap: 0.5rem;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.nice-reconciliation__toolbar-group--end {
|
|
37
|
+
margin-inline-start: auto;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.nice-reconciliation__btn {
|
|
41
|
+
display: inline-flex;
|
|
42
|
+
align-items: center;
|
|
43
|
+
gap: 0.375rem;
|
|
44
|
+
padding: 0.375rem 0.75rem;
|
|
45
|
+
font-size: 0.8125rem;
|
|
46
|
+
font-weight: 500;
|
|
47
|
+
border-radius: var(--nice-radius-md, 0.375rem);
|
|
48
|
+
cursor: pointer;
|
|
49
|
+
transition: all 0.15s ease;
|
|
50
|
+
border: 1px solid var(--nice-border-color, #d1d5db);
|
|
51
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
52
|
+
color: var(--nice-text-primary);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.nice-reconciliation__btn:hover {
|
|
56
|
+
background: var(--nice-bg-hover, #f3f4f6);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.nice-reconciliation__btn--primary {
|
|
60
|
+
background: var(--nice-primary, #3b82f6);
|
|
61
|
+
border-color: var(--nice-primary, #3b82f6);
|
|
62
|
+
color: white;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.nice-reconciliation__btn--primary:hover {
|
|
66
|
+
background: var(--nice-primary-dark, #2563eb);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.nice-reconciliation__btn--success {
|
|
70
|
+
background: var(--nice-success, #10b981);
|
|
71
|
+
border-color: var(--nice-success, #10b981);
|
|
72
|
+
color: white;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.nice-reconciliation__btn:disabled {
|
|
76
|
+
opacity: 0.5;
|
|
77
|
+
cursor: not-allowed;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.nice-reconciliation__content {
|
|
81
|
+
display: flex;
|
|
82
|
+
flex: 1;
|
|
83
|
+
overflow: hidden;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.nice-reconciliation--vertical .nice-reconciliation__content {
|
|
87
|
+
flex-direction: column;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.nice-reconciliation__panel {
|
|
91
|
+
flex: 1;
|
|
92
|
+
display: flex;
|
|
93
|
+
flex-direction: column;
|
|
94
|
+
min-width: 0;
|
|
95
|
+
min-height: 0;
|
|
96
|
+
overflow: hidden;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.nice-reconciliation__panel--statements {
|
|
100
|
+
border-inline-end: 1px solid var(--nice-border-color, #e5e7eb);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.nice-reconciliation--vertical .nice-reconciliation__panel--statements {
|
|
104
|
+
border-inline-end: none;
|
|
105
|
+
border-block-end: 1px solid var(--nice-border-color, #e5e7eb);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.nice-reconciliation__panel-header {
|
|
109
|
+
display: flex;
|
|
110
|
+
align-items: center;
|
|
111
|
+
justify-content: space-between;
|
|
112
|
+
padding: 0.75rem 1rem;
|
|
113
|
+
background: var(--nice-bg-secondary, #f9fafb);
|
|
114
|
+
border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.nice-reconciliation__panel-title {
|
|
118
|
+
font-weight: 600;
|
|
119
|
+
font-size: 0.875rem;
|
|
120
|
+
color: var(--nice-text-primary);
|
|
121
|
+
display: flex;
|
|
122
|
+
align-items: center;
|
|
123
|
+
gap: 0.5rem;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.nice-reconciliation__panel-badge {
|
|
127
|
+
font-size: 0.75rem;
|
|
128
|
+
font-weight: 500;
|
|
129
|
+
padding: 0.125rem 0.5rem;
|
|
130
|
+
border-radius: var(--nice-radius-full, 9999px);
|
|
131
|
+
background: var(--nice-bg-tertiary, #e5e7eb);
|
|
132
|
+
color: var(--nice-text-secondary);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.nice-reconciliation__panel-content {
|
|
136
|
+
flex: 1;
|
|
137
|
+
overflow: auto;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.nice-reconciliation__row {
|
|
141
|
+
display: flex;
|
|
142
|
+
align-items: center;
|
|
143
|
+
gap: 0.75rem;
|
|
144
|
+
padding: 0.625rem 1rem;
|
|
145
|
+
border-bottom: 1px solid var(--nice-border-divider, #f3f4f6);
|
|
146
|
+
cursor: pointer;
|
|
147
|
+
user-select: none;
|
|
148
|
+
transition: background 0.1s ease;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.nice-reconciliation__row:hover {
|
|
152
|
+
background: var(--nice-bg-hover, rgba(0, 0, 0, 0.02));
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.nice-reconciliation__row--selected {
|
|
156
|
+
background: var(--nice-primary-light, rgba(59, 130, 246, 0.1));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.nice-reconciliation__row--dragging {
|
|
160
|
+
opacity: 0.6;
|
|
161
|
+
background: var(--nice-primary-light, rgba(59, 130, 246, 0.15));
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.nice-reconciliation__row--drop-target {
|
|
165
|
+
background: var(--nice-success-bg, rgba(16, 185, 129, 0.15));
|
|
166
|
+
box-shadow: inset 0 0 0 2px var(--nice-success, #10b981);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.nice-reconciliation__row--matched {
|
|
170
|
+
background: var(--nice-success-bg, rgba(16, 185, 129, 0.08));
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.nice-reconciliation__row--partial {
|
|
174
|
+
background: var(--nice-warning-bg, rgba(245, 158, 11, 0.08));
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.nice-reconciliation__row--unmatched {
|
|
178
|
+
background: transparent;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.nice-reconciliation__row--excluded {
|
|
182
|
+
opacity: 0.5;
|
|
183
|
+
background: var(--nice-bg-tertiary, #f3f4f6);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.nice-reconciliation__status {
|
|
187
|
+
width: 0.5rem;
|
|
188
|
+
height: 0.5rem;
|
|
189
|
+
border-radius: var(--nice-radius-full, 50%);
|
|
190
|
+
flex-shrink: 0;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.nice-reconciliation__status--matched {
|
|
194
|
+
background: var(--nice-success, #10b981);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.nice-reconciliation__status--partial {
|
|
198
|
+
background: var(--nice-warning, #f59e0b);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.nice-reconciliation__status--unmatched {
|
|
202
|
+
background: var(--nice-danger, #ef4444);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.nice-reconciliation__status--excluded {
|
|
206
|
+
background: var(--nice-text-disabled, #9ca3af);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.nice-reconciliation__row-main {
|
|
210
|
+
flex: 1;
|
|
211
|
+
min-width: 0;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.nice-reconciliation__row-date {
|
|
215
|
+
font-size: 0.75rem;
|
|
216
|
+
color: var(--nice-text-secondary);
|
|
217
|
+
margin-bottom: 0.125rem;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.nice-reconciliation__row-description {
|
|
221
|
+
font-size: 0.8125rem;
|
|
222
|
+
color: var(--nice-text-primary);
|
|
223
|
+
white-space: nowrap;
|
|
224
|
+
overflow: hidden;
|
|
225
|
+
text-overflow: ellipsis;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.nice-reconciliation__row-counterparty {
|
|
229
|
+
font-size: 0.75rem;
|
|
230
|
+
color: var(--nice-text-tertiary);
|
|
231
|
+
white-space: nowrap;
|
|
232
|
+
overflow: hidden;
|
|
233
|
+
text-overflow: ellipsis;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.nice-reconciliation__row-amount {
|
|
237
|
+
font-size: 0.875rem;
|
|
238
|
+
font-weight: 600;
|
|
239
|
+
font-variant-numeric: tabular-nums;
|
|
240
|
+
white-space: nowrap;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.nice-reconciliation__row-amount--positive {
|
|
244
|
+
color: var(--nice-success, #10b981);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
.nice-reconciliation__row-amount--negative {
|
|
248
|
+
color: var(--nice-danger, #ef4444);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.nice-reconciliation__confidence {
|
|
252
|
+
display: flex;
|
|
253
|
+
align-items: center;
|
|
254
|
+
gap: 0.25rem;
|
|
255
|
+
font-size: 0.6875rem;
|
|
256
|
+
padding: 0.125rem 0.375rem;
|
|
257
|
+
border-radius: var(--nice-radius-sm, 0.25rem);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.nice-reconciliation__confidence--high {
|
|
261
|
+
background: var(--nice-success-bg, rgba(16, 185, 129, 0.15));
|
|
262
|
+
color: var(--nice-success-dark, #059669);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.nice-reconciliation__confidence--medium {
|
|
266
|
+
background: var(--nice-warning-bg, rgba(245, 158, 11, 0.15));
|
|
267
|
+
color: var(--nice-warning-dark, #d97706);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.nice-reconciliation__confidence--low {
|
|
271
|
+
background: var(--nice-danger-bg, rgba(239, 68, 68, 0.15));
|
|
272
|
+
color: var(--nice-danger-dark, #dc2626);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.nice-reconciliation__empty {
|
|
276
|
+
display: flex;
|
|
277
|
+
flex-direction: column;
|
|
278
|
+
align-items: center;
|
|
279
|
+
justify-content: center;
|
|
280
|
+
padding: 3rem 1rem;
|
|
281
|
+
color: var(--nice-text-secondary);
|
|
282
|
+
text-align: center;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
.nice-reconciliation__empty-icon {
|
|
286
|
+
font-size: 2.5rem;
|
|
287
|
+
margin-bottom: 0.75rem;
|
|
288
|
+
opacity: 0.5;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
.nice-reconciliation__summary {
|
|
292
|
+
display: flex;
|
|
293
|
+
align-items: center;
|
|
294
|
+
gap: 1.5rem;
|
|
295
|
+
padding: 0.75rem 1rem;
|
|
296
|
+
background: var(--nice-bg-secondary, #f9fafb);
|
|
297
|
+
border-top: 1px solid var(--nice-border-color, #e5e7eb);
|
|
298
|
+
font-size: 0.8125rem;
|
|
299
|
+
flex-wrap: wrap;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
.nice-reconciliation__summary-item {
|
|
303
|
+
display: flex;
|
|
304
|
+
align-items: center;
|
|
305
|
+
gap: 0.375rem;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
.nice-reconciliation__summary-label {
|
|
309
|
+
color: var(--nice-text-secondary);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
.nice-reconciliation__summary-value {
|
|
313
|
+
font-weight: 600;
|
|
314
|
+
color: var(--nice-text-primary);
|
|
315
|
+
font-variant-numeric: tabular-nums;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
.nice-reconciliation__summary-value--success {
|
|
319
|
+
color: var(--nice-success, #10b981);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.nice-reconciliation__summary-value--warning {
|
|
323
|
+
color: var(--nice-warning, #f59e0b);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
.nice-reconciliation__summary-value--danger {
|
|
327
|
+
color: var(--nice-danger, #ef4444);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
.nice-reconciliation__resizer {
|
|
331
|
+
width: 4px;
|
|
332
|
+
background: var(--nice-border-color, #e5e7eb);
|
|
333
|
+
cursor: col-resize;
|
|
334
|
+
transition: background 0.15s ease;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
.nice-reconciliation__resizer:hover {
|
|
338
|
+
background: var(--nice-primary, #3b82f6);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
.nice-reconciliation--vertical .nice-reconciliation__resizer {
|
|
342
|
+
width: 100%;
|
|
343
|
+
height: 4px;
|
|
344
|
+
cursor: row-resize;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
.nice-reconciliation__suggestions {
|
|
348
|
+
padding: 0.75rem 1rem;
|
|
349
|
+
background: var(--nice-info-bg, rgba(59, 130, 246, 0.08));
|
|
350
|
+
border-bottom: 1px solid var(--nice-info, #3b82f6);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
.nice-reconciliation__suggestion {
|
|
354
|
+
display: flex;
|
|
355
|
+
align-items: center;
|
|
356
|
+
gap: 0.75rem;
|
|
357
|
+
padding: 0.5rem;
|
|
358
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
359
|
+
border-radius: var(--nice-radius-md, 0.375rem);
|
|
360
|
+
margin-bottom: 0.5rem;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
.nice-reconciliation__suggestion:last-child {
|
|
364
|
+
margin-bottom: 0;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/* Dark mode */
|
|
368
|
+
.dark .nice-reconciliation {
|
|
369
|
+
background: var(--nice-bg-primary-dark, #111827);
|
|
370
|
+
border-color: var(--nice-border-color-dark, #374151);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
.dark .nice-reconciliation__toolbar,
|
|
374
|
+
.dark .nice-reconciliation__panel-header,
|
|
375
|
+
.dark .nice-reconciliation__summary {
|
|
376
|
+
background: var(--nice-bg-secondary-dark, #1f2937);
|
|
377
|
+
border-color: var(--nice-border-color-dark, #374151);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
.dark .nice-reconciliation__row--selected {
|
|
381
|
+
background: var(--nice-primary-tint-20, rgba(59, 130, 246, 0.2));
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/* RTL support */
|
|
385
|
+
[dir="rtl"] .nice-reconciliation__row-amount {
|
|
386
|
+
direction: ltr;
|
|
387
|
+
text-align: left;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/* Detail Panel */
|
|
391
|
+
.nice-reconciliation__detail-panel {
|
|
392
|
+
position: fixed;
|
|
393
|
+
inset-inline-end: 0;
|
|
394
|
+
top: 0;
|
|
395
|
+
bottom: 0;
|
|
396
|
+
width: 420px;
|
|
397
|
+
max-width: 90vw;
|
|
398
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
399
|
+
box-shadow: -4px 0 24px var(--nice-overlay-15, rgba(0, 0, 0, 0.15));
|
|
400
|
+
z-index: 1000;
|
|
401
|
+
display: flex;
|
|
402
|
+
flex-direction: column;
|
|
403
|
+
transform: translateX(100%);
|
|
404
|
+
transition: transform 0.25s ease-out;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
.nice-reconciliation__detail-panel--open {
|
|
408
|
+
transform: translateX(0);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
.nice-reconciliation__detail-header {
|
|
412
|
+
display: flex;
|
|
413
|
+
align-items: center;
|
|
414
|
+
justify-content: space-between;
|
|
415
|
+
padding: 1rem;
|
|
416
|
+
border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
|
|
417
|
+
background: var(--nice-bg-secondary, #f9fafb);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
.nice-reconciliation__detail-title {
|
|
421
|
+
font-weight: 600;
|
|
422
|
+
font-size: 1rem;
|
|
423
|
+
color: var(--nice-text-primary);
|
|
424
|
+
display: flex;
|
|
425
|
+
align-items: center;
|
|
426
|
+
gap: 0.5rem;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
.nice-reconciliation__detail-close {
|
|
430
|
+
width: 2rem;
|
|
431
|
+
height: 2rem;
|
|
432
|
+
display: flex;
|
|
433
|
+
align-items: center;
|
|
434
|
+
justify-content: center;
|
|
435
|
+
background: transparent;
|
|
436
|
+
border: none;
|
|
437
|
+
cursor: pointer;
|
|
438
|
+
font-size: 1.25rem;
|
|
439
|
+
color: var(--nice-text-secondary);
|
|
440
|
+
border-radius: var(--nice-radius-md, 0.375rem);
|
|
441
|
+
transition: all 0.15s ease;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
.nice-reconciliation__detail-close:hover {
|
|
445
|
+
background: var(--nice-bg-hover, #f3f4f6);
|
|
446
|
+
color: var(--nice-text-primary);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
.nice-reconciliation__detail-content {
|
|
450
|
+
flex: 1;
|
|
451
|
+
overflow: auto;
|
|
452
|
+
padding: 1rem;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
.nice-reconciliation__detail-section {
|
|
456
|
+
margin-bottom: 1.5rem;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
.nice-reconciliation__detail-section-title {
|
|
460
|
+
font-weight: 600;
|
|
461
|
+
font-size: 0.875rem;
|
|
462
|
+
color: var(--nice-text-primary);
|
|
463
|
+
margin-bottom: 0.75rem;
|
|
464
|
+
display: flex;
|
|
465
|
+
align-items: center;
|
|
466
|
+
gap: 0.375rem;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
.nice-reconciliation__detail-row {
|
|
470
|
+
display: flex;
|
|
471
|
+
justify-content: space-between;
|
|
472
|
+
align-items: flex-start;
|
|
473
|
+
padding: 0.5rem 0;
|
|
474
|
+
border-bottom: 1px solid var(--nice-border-divider, #f3f4f6);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
.nice-reconciliation__detail-row:last-child {
|
|
478
|
+
border-bottom: none;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
.nice-reconciliation__detail-label {
|
|
482
|
+
font-size: 0.8125rem;
|
|
483
|
+
color: var(--nice-text-secondary);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
.nice-reconciliation__detail-value {
|
|
487
|
+
font-size: 0.8125rem;
|
|
488
|
+
font-weight: 500;
|
|
489
|
+
color: var(--nice-text-primary);
|
|
490
|
+
text-align: end;
|
|
491
|
+
max-width: 60%;
|
|
492
|
+
word-break: break-word;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
.nice-reconciliation__detail-divider {
|
|
496
|
+
height: 1px;
|
|
497
|
+
background: var(--nice-border-color, #e5e7eb);
|
|
498
|
+
margin: 1rem 0;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
.nice-reconciliation__detail-match-info {
|
|
502
|
+
padding: 0.75rem;
|
|
503
|
+
background: var(--nice-success-bg, rgba(16, 185, 129, 0.08));
|
|
504
|
+
border-radius: var(--nice-radius-md, 0.375rem);
|
|
505
|
+
margin-bottom: 1rem;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
.nice-reconciliation__detail-match-header {
|
|
509
|
+
display: flex;
|
|
510
|
+
align-items: center;
|
|
511
|
+
gap: 0.5rem;
|
|
512
|
+
font-weight: 600;
|
|
513
|
+
font-size: 0.8125rem;
|
|
514
|
+
color: var(--nice-success-dark, #059669);
|
|
515
|
+
margin-bottom: 0.5rem;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
.nice-reconciliation__detail-match-detail {
|
|
519
|
+
font-size: 0.75rem;
|
|
520
|
+
color: var(--nice-text-secondary);
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
.nice-reconciliation__detail-side-by-side {
|
|
524
|
+
display: grid;
|
|
525
|
+
grid-template-columns: 1fr 1fr;
|
|
526
|
+
gap: 1rem;
|
|
527
|
+
padding: 0.75rem;
|
|
528
|
+
background: var(--nice-bg-secondary, #f9fafb);
|
|
529
|
+
border-radius: var(--nice-radius-md, 0.375rem);
|
|
530
|
+
margin-top: 0.75rem;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
.nice-reconciliation__detail-side-item {
|
|
534
|
+
padding: 0.5rem;
|
|
535
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
536
|
+
border-radius: var(--nice-radius-sm, 0.25rem);
|
|
537
|
+
border: 1px solid var(--nice-border-color, #e5e7eb);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
.nice-reconciliation__detail-side-label {
|
|
541
|
+
font-size: 0.6875rem;
|
|
542
|
+
font-weight: 500;
|
|
543
|
+
text-transform: uppercase;
|
|
544
|
+
color: var(--nice-text-tertiary);
|
|
545
|
+
margin-bottom: 0.375rem;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
.nice-reconciliation__detail-side-amount {
|
|
549
|
+
font-size: 1.125rem;
|
|
550
|
+
font-weight: 600;
|
|
551
|
+
font-variant-numeric: tabular-nums;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
.nice-reconciliation__detail-backdrop {
|
|
555
|
+
position: fixed;
|
|
556
|
+
inset: 0;
|
|
557
|
+
background: var(--nice-overlay-30, rgba(0, 0, 0, 0.3));
|
|
558
|
+
z-index: 999;
|
|
559
|
+
opacity: 0;
|
|
560
|
+
pointer-events: none;
|
|
561
|
+
transition: opacity 0.2s ease;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
.nice-reconciliation__detail-backdrop--visible {
|
|
565
|
+
opacity: 1;
|
|
566
|
+
pointer-events: auto;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
.dark .nice-reconciliation__detail-panel {
|
|
570
|
+
background: var(--nice-bg-primary-dark, #111827);
|
|
571
|
+
box-shadow: -4px 0 24px var(--nice-overlay-40, rgba(0, 0, 0, 0.4));
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
.dark .nice-reconciliation__detail-header {
|
|
575
|
+
background: var(--nice-bg-secondary-dark, #1f2937);
|
|
576
|
+
border-color: var(--nice-border-color-dark, #374151);
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
.dark .nice-reconciliation__detail-side-by-side {
|
|
580
|
+
background: var(--nice-bg-secondary-dark, #1f2937);
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
.dark .nice-reconciliation__detail-side-item {
|
|
584
|
+
background: var(--nice-bg-primary-dark, #111827);
|
|
585
|
+
border-color: var(--nice-border-color-dark, #374151);
|
|
586
|
+
}
|
|
587
|
+
`;function Ct(t,a="PLN",s="pl-PL"){return new Intl.NumberFormat(s,{style:"currency",currency:a,minimumFractionDigits:2,maximumFractionDigits:2}).format(t)}function rn(t,a="pl-PL"){return t?(typeof t=="string"?new Date(t):t).toLocaleDateString(a,{year:"numeric",month:"2-digit",day:"2-digit"}):"-"}function Ba(t){return t>=80?"high":t>=50?"medium":"low"}function Ua(){return`match-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function Gn(t){t?.querySelector('[role="option"][tabindex="0"]')?.focus()}function Xn(t,a,s){t.target===t.currentTarget&&(t.key===" "||t.key==="Enter"&&!s?(t.preventDefault(),a()):t.key==="Enter"&&s&&(t.preventDefault(),s()))}function Ga({item:t,isSelected:a,isDragging:s,isDropTarget:r,suggestion:l,currency:o,locale:d,onSelect:c,onDoubleClick:f,onDragStart:m,onDragEnd:w,onDrop:E,disabled:P}){const R=t.status??"unmatched",T=l?.confidence??t.confidence,K=b=>{b.dataTransfer.setData("text/plain",t.id),b.dataTransfer.setData("source","statement"),b.dataTransfer.effectAllowed="move",m()},p=b=>{b.dataTransfer.types.includes("source")&&b.dataTransfer.getData("source")!=="statement"&&b.preventDefault()};return e.jsxs("div",{className:`nice-reconciliation__row nice-reconciliation__row--${R} ${a?"nice-reconciliation__row--selected":""} ${s?"nice-reconciliation__row--dragging":""} ${r?"nice-reconciliation__row--drop-target":""}`,draggable:!P&&R!=="matched",onDragStart:K,onDragEnd:w,onDragOver:p,onDrop:E,onClick:c,onDoubleClick:f,onKeyDown:b=>Xn(b,c,f),role:"option","aria-selected":a,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:rn(t.date,d)}),e.jsx("div",{className:"nice-reconciliation__row-description",title:t.description,children:t.description}),t.counterparty&&e.jsx("div",{className:"nice-reconciliation__row-counterparty",children:t.counterparty})]}),T!=null&&e.jsxs("span",{className:`nice-reconciliation__confidence nice-reconciliation__confidence--${Ba(T)}`,children:[T,"%"]}),e.jsx("span",{className:`nice-reconciliation__row-amount ${t.amount>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:Ct(t.amount,o,d)})]})}function Wa({item:t,isSelected:a,isDragging:s,isDropTarget:r,currency:l,locale:o,onSelect:d,onDoubleClick:c,onDragStart:f,onDragEnd:m,onDrop:w,disabled:E}){const P=t.status??"unmatched",R=K=>{K.dataTransfer.setData("text/plain",t.id),K.dataTransfer.setData("source","entry"),K.dataTransfer.effectAllowed="move",f()},T=K=>{K.dataTransfer.types.includes("source")&&K.dataTransfer.getData("source")!=="entry"&&K.preventDefault()};return e.jsxs("div",{className:`nice-reconciliation__row nice-reconciliation__row--${P} ${a?"nice-reconciliation__row--selected":""} ${s?"nice-reconciliation__row--dragging":""} ${r?"nice-reconciliation__row--drop-target":""}`,draggable:!E&&P!=="matched",onDragStart:R,onDragEnd:m,onDragOver:T,onDrop:w,onClick:d,onDoubleClick:c,onKeyDown:K=>Xn(K,d,c),role:"option","aria-selected":a,children:[e.jsx("span",{className:`nice-reconciliation__status nice-reconciliation__status--${P}`}),e.jsxs("div",{className:"nice-reconciliation__row-main",children:[e.jsxs("div",{className:"nice-reconciliation__row-date",children:[rn(t.date,o),t.documentNumber&&e.jsxs("span",{children:[" · ",t.documentNumber]})]}),e.jsx("div",{className:"nice-reconciliation__row-description",title:t.description,children:t.description}),t.partyName&&e.jsx("div",{className:"nice-reconciliation__row-counterparty",children:t.partyName})]}),e.jsx("span",{className:`nice-reconciliation__row-amount ${t.amount>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:Ct(t.amount,l,o)})]})}const Qa=n.forwardRef(function(a,s){const{t:r}=N.useNiceTranslation(),{statements:l,bankTransactions:o,entries:d,accountingEntries:c,matches:f,defaultMatches:m=[],suggestions:w=[],config:E={},currency:P,showConfidence:R,statementPanelConfig:T,entryPanelConfig:K,onMatch:p,onAutoMatch:b,onUnmatch:I,onBatchAction:_,onFilterChange:z,onRequestSuggestions:C,onSelectionChange:G,onComplete:H,size:he="medium",showToolbar:se=!0,showFilters:fe=!0,showSummary:Ie=!0,showSuggestions:ee=!0,layout:we="horizontal",enableDragDrop:B=!0,enableKeyboard:$e=!0,enableDetailPanel:ke=!0,loading:Pe=!1,disabled:Z=!1,readOnly:$=!1,locale:O="pl-PL",labels:A={},className:g,style:pe}=a,re=n.useMemo(()=>l??o??[],[l,o]),k=n.useMemo(()=>d??c??[],[d,c]),ae=P??E.currency??"PLN",[de,ge]=n.useState(m),[D,le]=n.useState(new Set),[_e,ze]=n.useState(new Set),[oe,je]=n.useState(null),[Le,Me]=n.useState(null),[Se,ct]=n.useState({}),[it,at]=n.useState(null),ve=f??de,W=n.useRef(null),be=n.useRef(null),De={orientation:"vertical",pageSize:10};N.useRovingFocus(W,De),N.useRovingFocus(be,De),n.useEffect(()=>{const S="nice-reconciliation-styles";if(!document.getElementById(S)){const X=document.createElement("style");X.id=S,X.textContent=Ka,document.head.appendChild(X)}},[]);const qe=n.useMemo(()=>{const S=new Set;return ve.forEach(X=>X.statementIds.forEach(me=>S.add(me))),S},[ve]),Re=n.useMemo(()=>{const S=new Set;return ve.forEach(X=>X.entryIds.forEach(me=>S.add(me))),S},[ve]),ie=n.useMemo(()=>{const S=re.filter(Q=>!qe.has(Q.id)),X=k.filter(Q=>!Re.has(Q.id)),me=re.reduce((Q,Ae)=>Q+Ae.amount,0),Ee=k.reduce((Q,Ae)=>Q+Ae.amount,0),st=re.filter(Q=>qe.has(Q.id)).reduce((Q,Ae)=>Q+Ae.amount,0);return{totalStatements:re.length,totalEntries:k.length,matchedStatements:re.length-S.length,matchedEntries:k.length-X.length,unmatchedStatements:S.length,unmatchedEntries:X.length,statementTotal:me,entryTotal:Ee,matchedAmount:st,unmatchedStatementAmount:S.reduce((Q,Ae)=>Q+Ae.amount,0),unmatchedEntryAmount:X.reduce((Q,Ae)=>Q+Ae.amount,0),difference:me-Ee,matchPercentage:re.length>0?Math.round((re.length-S.length)/re.length*100):0,matchCount:ve.length,partialMatchCount:ve.filter(Q=>Q.status==="partial").length,pendingSuggestions:w.length}},[re,k,ve,w,qe,Re]),J=n.useCallback((S,X)=>{const me=re.filter(We=>S.includes(We.id)),Ee=k.filter(We=>X.includes(We.id));if(me.length===0||Ee.length===0)return null;const st=me.reduce((We,Qe)=>We+Qe.amount,0),Q=Ee.reduce((We,Qe)=>We+Qe.amount,0),Ae=Math.abs(st-Q),Fe=E.amountTolerance??.01,Ge={id:Ua(),statementIds:S,entryIds:X,status:Ae<=Fe?"matched":"partial",statementTotal:st,entryTotal:Q,difference:Ae,confidence:Ae<=Fe?100:Math.max(0,100-Ae/Math.max(Math.abs(st),1)*100),matchedBy:"user",matchedAt:new Date};return f||ge(We=>[...We,Ge]),p?.(Ge,me,Ee),le(new Set),ze(new Set),Ge},[re,k,E.amountTolerance,f,p]),v=n.useCallback(S=>{const X=ve.find(me=>me.id===S);X&&(f||ge(me=>me.filter(Ee=>Ee.id!==S)),I?.(S,X.statementIds,X.entryIds))},[ve,f,I]),xe=n.useCallback(async()=>{const S=[],X=new Set(qe),me=new Set(Re),Ee=E.amountTolerance??.01,st=E.dateTolerance??3;for(const Q of re){if(X.has(Q.id))continue;const Ae=k.filter(Fe=>{if(me.has(Fe.id)||Math.abs(Q.amount-Fe.amount)>Ee)return!1;const We=new Date(Q.date),Qe=new Date(Fe.date);return!(Math.abs(We.getTime()-Qe.getTime())/(1e3*60*60*24)>st)});if(Ae.length===1){const Fe=Ae[0],Ge=J([Q.id],[Fe.id]);Ge&&(S.push(Ge),X.add(Q.id),me.add(Fe.id))}}return _?.("autoMatch",S),S},[re,k,qe,Re,E,J,_]),te=n.useCallback((S,X,me,Ee)=>{Ee!==X&&(Ee==="statement"?J([me],[S]):J([S],[me]),je(null),Me(null))},[J]),Ve=n.useCallback(()=>{const S=Array.from(D),X=Array.from(_e);S.length>0&&X.length>0&&J(S,X)},[D,_e,J]);n.useEffect(()=>{G?.(Array.from(D),Array.from(_e))},[D,_e,G]),n.useImperativeHandle(s,()=>({getMatches:()=>ve,getUnmatchedStatements:()=>re.filter(S=>!qe.has(S.id)),getUnmatchedEntries:()=>k.filter(S=>!Re.has(S.id)),createMatch:J,removeMatch:v,autoMatch:xe,getSuggestions:async S=>C?C(S??re.filter(X=>!qe.has(X.id)).map(X=>X.id)):[],applySuggestion:S=>J([S.statementId],S.entryIds),approveAll:()=>{_?.("approveAll",ve)},clearAll:()=>{f||ge([]),_?.("clearAll",[])},exportMatched:S=>{_?.("exportMatched",ve)},getSummary:()=>ie,reset:()=>{f||ge([]),le(new Set),ze(new Set),ct({})},focusStatements:()=>Gn(W.current),focusEntries:()=>Gn(be.current)}),[ve,re,k,qe,Re,J,v,xe,C,_,f,ie]);const ue=n.useMemo(()=>re.filter(S=>{if(Se.status&&Se.status.length>0){const X=qe.has(S.id)?"matched":"unmatched";if(!Se.status.includes(X))return!1}if(Se.searchText){const X=Se.searchText.toLowerCase();if(!S.description?.toLowerCase().includes(X)&&!S.counterparty?.toLowerCase().includes(X))return!1}return!0}),[re,Se,qe]),Ue=n.useMemo(()=>k.filter(S=>{if(Se.status&&Se.status.length>0){const X=Re.has(S.id)?"matched":"unmatched";if(!Se.status.includes(X))return!1}if(Se.searchText){const X=Se.searchText.toLowerCase();if(!S.description?.toLowerCase().includes(X)&&!S.partyName?.toLowerCase().includes(X))return!1}return!0}),[k,Se,Re]),Ke=D.size>0&&_e.size>0&&!$&&!Z;return e.jsxs("div",{className:`nice-reconciliation nice-reconciliation--${we} ${g??""}`,style:pe,children:[se&&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:xe,disabled:Z||$||Pe,children:[e.jsx(N.NiceIcon,{name:"zap",size:14})," ",A.autoMatch??r("reconciliationView.autoMatch","Auto-match")]}),e.jsxs("button",{type:"button",className:"nice-reconciliation__btn nice-reconciliation__btn--success",onClick:Ve,disabled:!Ke||Pe,children:[e.jsx(N.NiceIcon,{name:"link",size:14})," ",r("reconciliationView.matchSelected","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:()=>_?.("approveAll",ve),disabled:ve.length===0||Z||Pe,children:[e.jsx(N.NiceIcon,{name:"check",size:14})," ",A.approveAll??r("reconciliationView.approveAll","Approve All")]}),e.jsxs("button",{type:"button",className:"nice-reconciliation__btn",onClick:()=>{f||ge([]),_?.("clearAll",[])},disabled:ve.length===0||Z||$||Pe,children:[e.jsx(N.NiceIcon,{name:"close",size:14})," ",A.clearAll??r("reconciliationView.clearAll","Clear All")]})]})]}),e.jsxs("div",{className:"nice-reconciliation__content",children:[e.jsxs("div",{className:"nice-reconciliation__panel nice-reconciliation__panel--statements",children:[e.jsx("div",{className:"nice-reconciliation__panel-header",children:e.jsxs("span",{className:"nice-reconciliation__panel-title",children:[e.jsx(N.NiceIcon,{name:"file",size:14})," ",A.statementPanelTitle??r("reconciliationView.bankStatement","Bank Statement"),e.jsx("span",{className:"nice-reconciliation__panel-badge",children:ue.length})]})}),e.jsx("div",{ref:W,className:"nice-reconciliation__panel-content",role:"listbox","aria-multiselectable":"true",children:ue.length===0?e.jsxs("div",{className:"nice-reconciliation__empty",children:[e.jsx("div",{className:"nice-reconciliation__empty-icon",children:e.jsx(N.NiceIcon,{name:"clipboard",size:32})}),A.noStatements??r("reconciliationView.noStatementItems","No statement items")]}):ue.map(S=>e.jsx(Ga,{item:{...S,status:qe.has(S.id)?"matched":"unmatched"},isSelected:D.has(S.id),isDragging:oe===S.id,isDropTarget:Le===S.id,suggestion:w.find(X=>X.statementId===S.id),currency:ae,locale:O,onSelect:()=>{Z||le(X=>{const me=new Set(X);return me.has(S.id)?me.delete(S.id):me.add(S.id),me})},onDoubleClick:ke?()=>at({type:"statement",id:S.id}):void 0,onDragStart:()=>je(S.id),onDragEnd:()=>{je(null),Me(null)},onDrop:()=>{oe&&oe!==S.id&&te(S.id,"statement",oe,"entry")},disabled:Z||$||!B},S.id))})]}),e.jsxs("div",{className:"nice-reconciliation__panel nice-reconciliation__panel--entries",children:[e.jsx("div",{className:"nice-reconciliation__panel-header",children:e.jsxs("span",{className:"nice-reconciliation__panel-title",children:[e.jsx(N.NiceIcon,{name:"book",size:14})," ",A.entryPanelTitle??r("reconciliationView.bookEntries","Book Entries"),e.jsx("span",{className:"nice-reconciliation__panel-badge",children:Ue.length})]})}),e.jsx("div",{ref:be,className:"nice-reconciliation__panel-content",role:"listbox","aria-multiselectable":"true",children:Ue.length===0?e.jsxs("div",{className:"nice-reconciliation__empty",children:[e.jsx("div",{className:"nice-reconciliation__empty-icon",children:e.jsx(N.NiceIcon,{name:"book",size:32})}),A.noEntries??r("reconciliationView.noBookEntries","No book entries")]}):Ue.map(S=>e.jsx(Wa,{item:{...S,status:Re.has(S.id)?"matched":"unmatched"},isSelected:_e.has(S.id),isDragging:oe===S.id,isDropTarget:Le===S.id,currency:ae,locale:O,onSelect:()=>{Z||ze(X=>{const me=new Set(X);return me.has(S.id)?me.delete(S.id):me.add(S.id),me})},onDoubleClick:ke?()=>at({type:"entry",id:S.id}):void 0,onDragStart:()=>je(S.id),onDragEnd:()=>{je(null),Me(null)},onDrop:()=>{oe&&oe!==S.id&&te(S.id,"entry",oe,"statement")},disabled:Z||$||!B},S.id))})]})]}),Ie&&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:r("reconciliationView.matched","Matched:")}),e.jsxs("span",{className:"nice-reconciliation__summary-value nice-reconciliation__summary-value--success",children:[ie.matchedStatements,"/",ie.totalStatements," (",ie.matchPercentage,"%)"]})]}),e.jsxs("div",{className:"nice-reconciliation__summary-item",children:[e.jsx("span",{className:"nice-reconciliation__summary-label",children:r("reconciliationView.matchedAmount","Matched Amount:")}),e.jsx("span",{className:"nice-reconciliation__summary-value",children:Ct(ie.matchedAmount,ae,O)})]}),e.jsxs("div",{className:"nice-reconciliation__summary-item",children:[e.jsx("span",{className:"nice-reconciliation__summary-label",children:r("reconciliationView.unmatched","Unmatched:")}),e.jsx("span",{className:"nice-reconciliation__summary-value nice-reconciliation__summary-value--warning",children:Ct(ie.unmatchedStatementAmount,ae,O)})]}),e.jsxs("div",{className:"nice-reconciliation__summary-item",children:[e.jsx("span",{className:"nice-reconciliation__summary-label",children:r("reconciliationView.difference","Difference:")}),e.jsx("span",{className:`nice-reconciliation__summary-value ${Math.abs(ie.difference)<.01?"nice-reconciliation__summary-value--success":"nice-reconciliation__summary-value--danger"}`,children:Ct(ie.difference,ae,O)})]})]}),ke&&e.jsxs(e.Fragment,{children:[e.jsx("div",{role:"presentation",className:`nice-reconciliation__detail-backdrop ${it?"nice-reconciliation__detail-backdrop--visible":""}`,onClick:()=>at(null)}),e.jsx("div",{className:`nice-reconciliation__detail-panel ${it?"nice-reconciliation__detail-panel--open":""}`,children:it&&e.jsx(qa,{type:it.type,id:it.id,statements:re,entries:k,matches:ve,currency:ae,locale:O,labels:A,onClose:()=>at(null)})})]})]})});function qa({type:t,id:a,statements:s,entries:r,matches:l,currency:o,locale:d,labels:c,onClose:f}){const{t:m}=N.useNiceTranslation(),w=t==="statement"?s.find(p=>p.id===a):r.find(p=>p.id===a),E=t==="statement"?l.find(p=>p.statementIds.includes(a)):l.find(p=>p.entryIds.includes(a)),P=E?t==="statement"?r.filter(p=>E.entryIds.includes(p.id)):s.filter(p=>E.statementIds.includes(p.id)):[];if(!w)return null;const R=t==="statement",T=R?w:null,K=R?null:w;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-reconciliation__detail-header",children:[e.jsxs("span",{className:"nice-reconciliation__detail-title",children:[e.jsx(N.NiceIcon,{name:R?"file":"book",size:14})," ",R?c.statementDetails??m("reconciliationView.transactionDetails","Transaction Details"):c.entryDetails??m("reconciliationView.entryDetails","Entry Details")]}),e.jsx("button",{type:"button",className:"nice-reconciliation__detail-close",onClick:f,"aria-label":m("reconciliationView.close","Close"),children:e.jsx(N.NiceIcon,{name:"close",size:14})})]}),e.jsxs("div",{className:"nice-reconciliation__detail-content",children:[E&&e.jsxs("div",{className:"nice-reconciliation__detail-match-info",children:[e.jsxs("div",{className:"nice-reconciliation__detail-match-header",children:[e.jsx(N.NiceIcon,{name:"check",size:14})," ",m("reconciliationView.matchedConfidence","{label} ({confidence}% confidence)").replace("{label}",c.matchedWith??m("reconciliationView.matched2","Matched")).replace("{confidence}",String(E.confidence?.toFixed(0)??100))]}),e.jsx("div",{className:"nice-reconciliation__detail-match-detail",children:E.matchedBy==="ai"?c.matchedByAI??m("reconciliationView.matchedAutomaticallyByAi","Matched automatically by AI"):c.matchedManually??m("reconciliationView.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??m("reconciliationView.statement","Statement")}),e.jsx("div",{className:`nice-reconciliation__detail-side-amount ${E.statementTotal>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:Ct(E.statementTotal,o,d)})]}),e.jsxs("div",{className:"nice-reconciliation__detail-side-item",children:[e.jsx("div",{className:"nice-reconciliation__detail-side-label",children:c.entryTotal??m("reconciliationView.bookEntry","Book Entry")}),e.jsx("div",{className:`nice-reconciliation__detail-side-amount ${E.entryTotal>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:Ct(E.entryTotal,o,d)})]})]}),E.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??m("reconciliationView.difference2","Difference"),":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",style:{color:"var(--nice-warning, #f59e0b)"},children:Ct(E.difference,o,d)})]})]}),e.jsxs("div",{className:"nice-reconciliation__detail-section",children:[e.jsxs("div",{className:"nice-reconciliation__detail-section-title",children:[e.jsx(N.NiceIcon,{name:"clipboard",size:14})," ",R?c.transactionInfo??m("reconciliationView.transactionInformation","Transaction Information"):c.entryInfo??m("reconciliationView.entryInformation","Entry Information")]}),e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[c.date??m("reconciliationView.date","Date"),":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",children:rn(w.date,d)})]}),e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[c.description??m("reconciliationView.description","Description"),":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",children:w.description})]}),e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[c.amount??m("reconciliationView.amount","Amount"),":"]}),e.jsx("span",{className:`nice-reconciliation__detail-value ${w.amount>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:Ct(w.amount,o,d)})]}),R&&T?.counterparty&&e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[c.counterparty??m("reconciliationView.counterparty","Counterparty"),":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",children:T.counterparty})]}),R&&T?.counterpartyAccount&&e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[c.accountNumber??m("reconciliationView.account","Account"),":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",style:{fontFamily:"monospace",fontSize:"0.75rem"},children:T.counterpartyAccount})]}),!R&&K?.partyName&&e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[c.party??m("reconciliationView.party","Party"),":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",children:K.partyName})]}),!R&&K?.documentNumber&&e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[c.documentRef??m("reconciliationView.documentRef","Document Ref"),":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",children:K.documentNumber})]}),R&&T?.referenceNumber&&e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[c.reference??m("reconciliationView.reference","Reference"),":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",children:T.referenceNumber})]})]}),P.length>0&&e.jsxs("div",{className:"nice-reconciliation__detail-section",children:[e.jsxs("div",{className:"nice-reconciliation__detail-section-title",children:[e.jsx(N.NiceIcon,{name:"link",size:14})," ",R?c.matchedEntries??m("reconciliationView.matchedEntries","Matched Entries"):c.matchedStatements??m("reconciliationView.matchedStatements","Matched Statements")]}),P.map(p=>e.jsxs("div",{style:{padding:"0.5rem",background:"var(--nice-bg-secondary, #f9fafb)",borderRadius:"0.25rem",marginBottom:"0.5rem",fontSize:"0.8125rem"},children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"0.25rem"},children:p.description}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",color:"var(--nice-text-secondary)"},children:[e.jsx("span",{children:rn(p.date,d)}),e.jsx("span",{style:{fontWeight:600,color:p.amount>=0?"var(--nice-success)":"var(--nice-danger)"},children:Ct(p.amount,o,d)})]})]},p.id))]})]})]})}const Ya=[],Ha=({queries:t=Ya,currentFilter:a,currentColumns:s,currentSort:r,onLoad:l,onSave:o,onUpdate:d,onDelete:c,onShare:f,onSetDefault:m,allowSharing:w=!0,allowPinning:E=!0,position:P="dropdown",className:R,style:T,"data-testid":K})=>{const{t:p}=N.useNiceTranslation(),[b,I]=n.useState(!1),[_,z]=n.useState(""),[C,G]=n.useState(!1),[H,he]=n.useState(""),[se,fe]=n.useState(""),[Ie,ee]=n.useState(!1),we=n.useRef(null);N.useOverlayFocus(we,{open:b,modal:!1,onClose:()=>I(!1)});const B=t.filter($=>$.name.toLowerCase().includes(_.toLowerCase())),$e=B.filter($=>!$.isShared),ke=B.filter($=>$.isShared),Pe=async()=>{if(H.trim()){G(!0);try{await o({name:H,description:se||void 0,filter:a??{},columns:s,sort:r}),ee(!1),he(""),fe("")}finally{G(!1)}}},Z=$=>e.jsxs("div",{className:"nice-saved-query__item",children:[$.icon&&e.jsx("span",{className:"nice-saved-query__icon","aria-hidden":"true",children:$.icon}),e.jsx("span",{className:"nice-saved-query__name",children:$.name}),$.isDefault&&e.jsx("span",{className:"nice-saved-query__badge nice-saved-query__badge--default",children:p("savedQuery.default","default")}),$.isShared&&e.jsx("span",{className:"nice-saved-query__badge nice-saved-query__badge--shared",children:p("savedQuery.shared","shared")}),$.isPinned&&e.jsx("span",{className:"nice-saved-query__badge nice-saved-query__badge--pinned",children:p("savedQuery.pinned","pinned")}),e.jsxs("div",{className:"nice-saved-query__actions",children:[e.jsx("button",{onClick:()=>{l($),I(!1)},type:"button",children:p("savedQuery.load","Load")}),m&&e.jsx("button",{onClick:()=>m($.id),type:"button",title:p("savedQuery.setDefault","Set as default"),"aria-label":p("savedQuery.setDefault","Set as default"),children:e.jsx(N.NiceIcon,{name:"star",size:14})}),w&&f&&e.jsx("button",{onClick:()=>f($.id,[]),type:"button",title:p("savedQuery.share","Share"),"aria-label":p("savedQuery.share","Share"),children:e.jsx(N.NiceIcon,{name:"external-link",size:14})}),E&&e.jsx("button",{onClick:()=>d($.id,{...$}),type:"button",title:p("savedQuery.pin","Pin"),"aria-label":p("savedQuery.pin","Pin"),children:e.jsx(N.NiceIcon,{name:"map-pin",size:14})}),e.jsx("button",{onClick:()=>c($.id),type:"button",title:p("savedQuery.remove","Remove"),"aria-label":`${p("savedQuery.removeQuery","Remove query")} ${$.name}`,children:e.jsx(N.NiceIcon,{name:"close",size:14})})]})]},$.id);return e.jsxs("div",{className:`nice-saved-query nice-saved-query--${P} ${b?"nice-saved-query--open":""} ${R??""}`,style:T,"data-testid":K,children:[e.jsx("button",{className:"nice-saved-query__trigger",onClick:()=>I($=>!$),"aria-expanded":b,"aria-haspopup":"dialog",type:"button",children:p("savedQuery.trigger","Views and queries")}),b&&e.jsxs("div",{ref:we,className:"nice-saved-query__panel",role:"dialog","aria-label":p("savedQuery.manage","Manage saved queries"),children:[e.jsxs("div",{className:"nice-saved-query__search-row",children:[e.jsx("input",{type:"search",placeholder:p("savedQuery.searchPlaceholder","Search queries…"),value:_,onChange:$=>z($.target.value),"aria-label":p("savedQuery.search","Search queries")}),e.jsxs("button",{onClick:()=>ee($=>!$),type:"button",children:[e.jsx(N.NiceIcon,{name:"plus",size:12})," ",p("savedQuery.saveCurrent","Save current view")]})]}),Ie&&e.jsxs("div",{className:"nice-saved-query__save-form",children:[e.jsx("input",{type:"text",placeholder:p("savedQuery.name","Query name"),value:H,onChange:$=>he($.target.value),"aria-label":p("savedQuery.name","Query name")}),e.jsx("input",{type:"text",placeholder:p("savedQuery.descriptionPlaceholder","Description (optional)"),value:se,onChange:$=>fe($.target.value),"aria-label":p("savedQuery.description","Query description")}),e.jsx("button",{onClick:Pe,disabled:C||!H.trim(),type:"button",children:C?p("savedQuery.saving","Saving…"):p("savedQuery.save","Save")}),e.jsx("button",{onClick:()=>ee(!1),type:"button",children:p("savedQuery.cancel","Cancel")})]}),$e.length>0&&e.jsxs("section",{className:"nice-saved-query__group","aria-labelledby":"nice-saved-query-mine",children:[e.jsx("h3",{id:"nice-saved-query-mine",className:"nice-saved-query__group-title",children:p("savedQuery.mine","Mine")}),$e.map(Z)]}),ke.length>0&&e.jsxs("section",{className:"nice-saved-query__group","aria-labelledby":"nice-saved-query-shared",children:[e.jsx("h3",{id:"nice-saved-query-shared",className:"nice-saved-query__group-title",children:p("savedQuery.sharedSection","Shared")}),ke.map(Z)]}),B.length===0&&e.jsx("p",{className:"nice-saved-query__empty",children:p("savedQuery.empty","No saved queries")})]})]})};exports.NiceDataGridAI=ki;exports.NiceHighlight=yn;exports.NiceKanbanBoard=ra;exports.NiceList=Yi;exports.NiceModuleGrid=ja;exports.NiceReconciliationView=Qa;exports.NiceSavedQueryPanel=Ha;exports.NiceSpreadsheet=Va;exports.NiceTable=Xi;exports.NiceTileView=ea;exports.NiceTreeGrid=Fi;exports.NiceTreeList=Gi;exports.NiceTreeView=Qi;
|