@buildocsdev/sdk 1.1.25 → 1.1.26

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.
@@ -1 +1 @@
1
- import {a,b as b$1}from'./chunk-5VSWNFWW.js';import {a as a$1}from'./chunk-POE6K4NQ.js';import {U,T,k}from'./chunk-TYVVEP34.js';import'./chunk-U4T4ACDE.js';import {b}from'./chunk-LBMVBVXW.js';import {q,a as a$2}from'./chunk-AYYTOQGP.js';import {c,d,p,m,N}from'./chunk-AR42AC7J.js';import'./chunk-5TBO732O.js';import {lazy,memo,useRef,useState,useEffect}from'react';import {withTranslation,useTranslation}from'react-i18next';import {useLocation}from'react-router-dom';import {LocalizationProvider,DateTimePicker,DatePicker}from'@mui/x-date-pickers';import Ft from'@mui/material/TextField';import X from'react-dom/client';import Et from'@mui/material/Tooltip';import Zt from'@mui/material/Box';import te from'@mui/material/Button';import Pt from'@mui/material/MenuList';import Nt from'@mui/material/MenuItem';import At from'@mui/material/Paper';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {nanoid}from'@reduxjs/toolkit';import ne from'react-dom/server';import'react-tabulator/lib/styles.css';import'react-tabulator/css/bootstrap/tabulator_bootstrap.min.css';import'react-tabulator/lib/css/bootstrap/tabulator_bootstrap.min.css';var $t=({cellElement:u,cell:t,actionHandler:o})=>{let {t:e}=useTranslation();t.getRow().getPosition();let i=u.getBoundingClientRect(),m=i.bottom+window.scrollY,a=i.left+window.scrollX;return jsx(At,{style:{position:"absolute",top:m+"px",left:a+"px",zIndex:2e3,minWidth:"150px"},children:jsx(Pt,{children:jsxs(Nt,{onClick:()=>o(t),children:[jsx(N,{style:{fontSize:"1em",marginRight:"0.5em"}})," ",e("Delete")]})})})},Ct=$t;var L=class u{static convertToVariables(t){let o={};for(let e in t)if(t.hasOwnProperty(e)&&(typeof t[e]=="string"||typeof t[e]=="number")){let n=Number(t[e]);isNaN(n)||(o[e]=n);}return o}static formulaHasFieldName(t,o){if(t.operands){for(let e of t.operands)if(typeof e=="string"&&e===o||typeof e=="object"&&u.formulaHasFieldName(e,o))return true}return false}static parseExpression(t){t=t.replace(/\s+/g,"");let o=/\(([^()]+)\)/;for(;o.test(t);)t=t.replace(o,(i,m)=>{let a=u.parseExpression(m.trim());return `@${JSON.stringify(a)}`});let n=u.tokenize(t).map(i=>i.startsWith("@")?JSON.parse(i.substring(1)):i);return u.parseTokens(n)}static tokenize(t){let o=[],e="",n=false,i=0;for(let m=0;m<t.length;m++){let a=t[m];if(a==="@"&&t[m+1]==="{"&&(e&&(o.push(e),e=""),n=true,i=0),n){e+=a,a==="{"?i++:a==="}"&&(i--,i===0&&(o.push(e),e="",n=false));continue}if("+-*/()".includes(a)){e&&(o.push(e),e=""),o.push(a);continue}e+=a;}return e&&o.push(e),o}static parseTokens(t){if(t.length===1){let a=t[0];if(typeof a=="string"){let s=parseFloat(a);return isNaN(s)?{operands:[a]}:{value:s}}if(typeof a=="object")return a}let o={"+":1,"-":1,"*":2,"/":2},e=1/0,n=-1;if(t.forEach((a,s)=>{if(typeof a=="string"&&a in o){let d=a;o[d]<=e&&(e=o[d],n=s);}}),n===-1)throw new Error(`Invalid expression: no operator found in tokens ${JSON.stringify(t)}`);let i=t.slice(0,n),m=t.slice(n+1);if(i.length===0||m.length===0)throw new Error(`Invalid expression: operator without operands in tokens ${JSON.stringify(t)}`);return {operator:t[n],operands:[u.parseTokens(i),u.parseTokens(m)]}}static evaluateFormula(t,o){if(t.value!==void 0)return t.value;let{operator:e,operands:n}=t;if(!e||!n||n.length!==2)throw new Error("Invalid parsed formula");let[i,m]=n.map(a=>{if(typeof a=="object"&&a.operands&&a.operands.length===1&&(a=a.operands[0]),typeof a=="string")return o[a]||0;if(typeof a=="number")return a;if(typeof a=="object")return u.evaluateFormula(a,o);throw new Error(`Unsupported operand type: ${JSON.stringify(a)}`)});switch(e){case "+":return i+m;case "-":return i-m;case "*":return i*m;case "/":return i/m;default:throw new Error(`Unsupported operator: ${e}`)}}static convertValuesToStrings(t){return t.map(o=>{let e={};for(let[n,i]of Object.entries(o))e[n]=i===void 0?"":String(i);return e})}static buildDependencyGraph(t){let o={};for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e)){let n=t[e],i=[],m=a=>{a.forEach(s=>{typeof s=="string"?i.push(s):typeof s=="object"&&"operands"in s&&s.operands&&m(s.operands);});};n.operands&&m(n.operands),o[e]=i;}return o}static topologicalSort(t){let o=new Set,e=[],n=i=>{o.has(i)||(o.add(i),(t[i]||[]).forEach(n),e.push(i));};return Object.keys(t).forEach(n),e}};var re=ne.renderToStaticMarkup(jsx(c,{}));if(typeof window!="undefined"&&window.ResizeObserver){let u=window.ResizeObserver;window.ResizeObserver=class extends u{constructor(t){let o;super((e,n)=>{cancelAnimationFrame(o),o=requestAnimationFrame(()=>t(e,n));});}};}var oe=lazy(()=>import('react-tabulator').then(u=>({default:u.ReactTabulator}))),ae=u=>{var o;if(!u.properties.folders)return null;var t=(o=u.context.params.folderData)==null?void 0:o.captions;return t==null||t.length===0?null:(t=t.slice(1),jsx("span",{style:{display:"flex",alignItems:"center"},children:t.map((e,n)=>jsxs("span",{style:{display:"inline-flex",alignItems:"center"},children:[e,n<t.length-1&&jsx(d,{style:{margin:"0 8px",fontSize:"0.6rem",color:"#666"}})]},n))}))},ie=(u,t,o,e,n,i,m,a)=>{let s=document.createElement("div"),d=null,f=u.getValue(),D=f?a$1(f):null,w=null,E=false,R=()=>{let r=null;if(E&&w!==null){if(w.trim()===""){e(),d&&d.unmount();return}if(r=a$1(w),!r.isValid()){let h=["DD.MM.YYYY","YYYY-MM-DD","MM/DD/YYYY","DD/MM/YYYY","M/D/YYYY","D/M/YYYY"];for(let F of h)if(r=a$1(w,F),r.isValid())break}(!r||!r.isValid())&&(r=D);}else r=D;r&&r.isValid()?(m.current=a,o(r.format("YYYY-MM-DD"))):f?o(f):e(),d&&d.unmount();},y=r=>{D=r;},b=r=>{D=r,E=false,R();},H=r=>{w=r.target.value,E=true;},x=jsx("div",{onMouseDown:r=>{r.stopPropagation();},children:jsx(LocalizationProvider,{dateAdapter:a$2,adapterLocale:i,children:jsx(DatePicker,{value:a$1(f),onAccept:b,onChange:y,slots:{actionBar:()=>null,textField:r=>jsx(Ft,{...r,onChange:h=>{r.onChange&&r.onChange(h),H(h);},sx:{"& .MuiOutlinedInput-root":{fontSize:"13px",border:"none"},"& .MuiOutlinedInput-notchedOutline":{border:"none"},"& .MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline":{border:"none"}}})}})})});return t(()=>{d||(d=X.createRoot(s),d.render(x));}),s.addEventListener("blur",r=>{setTimeout(()=>{s.contains(document.activeElement)||R();},200);}),s.addEventListener("keydown",r=>{if(r.key==="Tab"||r.key==="Enter"){r.preventDefault();let h=s.querySelector('input[type="text"]');h&&E&&(w=h.value),R();}}),s},le=(u,t,o,e,n,i,m,a)=>{let s=document.createElement("div"),d=null,f=u.getValue(),D=f?a$1(f):null,w=null,E=false,R=()=>{let r=null;if(E&&w!==null){if(w.trim()===""){e(),d&&d.unmount();return}if(r=a$1(w),!r.isValid()){let h=["DD.MM.YYYY HH:mm:ss","DD.MM.YYYY HH:mm","YYYY-MM-DD HH:mm:ss","YYYY-MM-DD HH:mm","YYYY-MM-DDTHH:mm:ss","MM/DD/YYYY HH:mm:ss","MM/DD/YYYY HH:mm","DD/MM/YYYY HH:mm:ss","DD/MM/YYYY HH:mm"];for(let F of h)if(r=a$1(w,F),r.isValid())break}if(!r||!r.isValid()){let h=["HH:mm:ss","HH:mm"];for(let F of h){let k=a$1(w,F,true);if(k.isValid()){r=(f?a$1(f):a$1()).hour(k.hour()).minute(k.minute()).second(k.second());break}}}(!r||!r.isValid())&&(r=D);}else r=D;r&&r.isValid()?(m.current=a,o(r.format("YYYY-MM-DDTHH:mm:ss"))):f?o(f):e(),d&&d.unmount();},y=r=>{D=r;},b=r=>{D=r,E=false,R();},H=r=>{w=r.target.value,E=true;},x=jsx("div",{onMouseDown:r=>{r.stopPropagation();},children:jsx(LocalizationProvider,{dateAdapter:a$2,adapterLocale:i,children:jsx(DateTimePicker,{value:f?a$1(f):null,onAccept:b,onChange:y,ampm:false,slots:{actionBar:()=>null,textField:r=>jsx(Ft,{...r,onChange:h=>{r.onChange&&r.onChange(h),H(h);},sx:{"& .MuiOutlinedInput-root":{fontSize:"13px",border:"none"},"& .MuiOutlinedInput-notchedOutline":{border:"none"},"& .MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline":{border:"none"}}})}})})});return t(()=>{d||(d=X.createRoot(s),d.render(x));}),s.addEventListener("blur",r=>{setTimeout(()=>{s.contains(document.activeElement)||R();},200);}),s.addEventListener("keydown",r=>{if(r.key==="Tab"||r.key==="Enter"){r.preventDefault();let h=s.querySelector('input[type="text"]');h&&E&&(w=h.value),R();}}),s},se=(u,t,o,e)=>{var m;if(!u.alloweditrow||u.readonly===true)return;let n=(m=t.item_columntype)!=null?m:"freetext";t.item_columntype||(t.item_isdate===true?n="date":t.item_isdatetime===true?n="datetime":t.item_ischeckbox===true?n="checkbox":t.item_isprice===true?n="price":n="freetext");return n==="datetime"?(a,s,d,f,D)=>le(a,s,d,f,D,o.current,e,u.name):n==="date"?(a,s,d,f,D)=>ie(a,s,d,f,D,o.current,e,u.name):t.item_editor==="number"||n==="price"||n==="number"?"number":t.item_editor==="checkbox"||n==="checkbox"?"tickCross":"input"},ue=(u,t,o,e,n)=>{let i=u.getElement();i.style.backgroundColor="#f0f0f0",i.style.color="#555",i.style.pointerEvents="none";},Yt=(u,t,o,e,n,i)=>{var R;let m=(y,b,H)=>{if(!(H==="price"))return `<div class="tabulator-text">${y||""}</div>`;let x=e.item_format==="fixed-locale",h=x&&e.item_fixedlocale||n.current||void 0,F=b!==void 0&&b[e.item_inputfield]?b[e.item_inputfield]:e.item_currency,k$1=e.item_format==="locale"?k(n.current):void 0,A=x?k(e.item_fixedlocale||""):void 0,W=String(F!=null?F:""),K=W&&W.trim()!==""?W.trim():k$1!=null?k$1:A;try{let P,Q=e.item_currencydisplay||(x?"symbol":"");return K&&Q!==""?P=new Intl.NumberFormat(h,{style:"currency",currency:K,currencyDisplay:Q,minimumFractionDigits:2,maximumFractionDigits:2}).format(y||0):P=new Intl.NumberFormat(h,{style:"decimal",minimumFractionDigits:2,maximumFractionDigits:2}).format(y||0),`<div class="tabulator-text">${P}</div>`}catch(P){return `<div class="tabulator-text">${(y||0).toFixed(2)}</div>`}};if(!t.alloweditrow)return;let a=(R=e.item_columntype)!=null?R:"freetext";e.item_columntype||(e.item_isdate===true?a="date":e.item_isdatetime===true?a="datetime":e.item_ischeckbox===true?a="checkbox":e.item_isprice===true||e.item_format==="locale"||e.item_format==="fixed-locale"?a="price":a="freetext");let s=e.item_readonly||i==="totals",d=a==="price",f=a==="number",D=a==="date",w=a==="datetime",E=a==="checkbox";return s?y=>{ue(y,t,e,n.current);let b=y.getValue();return i==="totals"&&(!e.item_bottomcalc||b==="")?"":m(b,o,a)}:w?y=>me(y,n.current)||"":D?y=>ce(y,n.current)||"":E?"tickCross":d?y=>{let b=y.getValue();return m(b,o,a)}:f?y=>{let b=y.getValue();if(b==null||b==="")return '<div class="tabulator-text"></div>';let H=parseFloat(b);return isNaN(H)?`<div class="tabulator-text">${b}</div>`:`<div class="tabulator-text">${H.toLocaleString(n.current||void 0,{minimumFractionDigits:0,maximumFractionDigits:10})}</div>`}:y=>`<div class="tabulator-text">${y.getValue()||""}</div>`},ce=(u,t)=>{let o=u.getValue();if(!o)return "";try{let e=a$1(o);return t&&b$1(t)?e.locale(t).format("L"):(t&&!b$1(t)&&a(t).catch(n=>{}),e.format("L"))}catch(e){return a$1(o).format("YYYY-MM-DD")}},me=(u,t)=>{let o=u.getValue();if(!o)return "";try{let e=a$1(o);return t&&b$1(t)?e.locale(t).format("L LT"):(t&&!b$1(t)&&a(t).catch(n=>{}),e.format("L LT"))}catch(e){return a$1(o).format("YYYY-MM-DD HH:mm")}},de=(u,t)=>{if(u.alloweditrow&&t.item_editor==="checkbox")return {allowEmpty:true,crossElement:false,tickElement:re}},kt=withTranslation()(memo(function(t){var mt;let{runFormEvent:o,viewPort:e}=b(),n=useRef(null),i=useRef(null),m$1=useRef(null),[a$1,s]=useState(false),[d,f]=useState([]),[D,w]=useState([]),[E,R]=useState([]),[y,b$1]=useState(0),{t:H,i18n:z}=useTranslation(),x=(mt=z==null?void 0:z.language)==null?void 0:mt.substring(0,2),r=useRef(x!=null?x:""),h=useLocation(),[F,k]=useState(false),A=useRef(t.context.formData||{});useEffect(()=>{x&&a(x).catch(c=>{});},[x]),useEffect(()=>{if(r.current=x!=null?x:"",n.current)try{n.current.redraw(!0);}catch(c){}},[x]),useEffect(()=>{let c=()=>{n.current&&!e.isMobileDevice&&n.current.redraw();};return window.addEventListener("resize",c),()=>{window.removeEventListener("resize",c);}},[]),useEffect(()=>{A.current=t.context.formData||{};let c=t.context.formData?t.context.formData[t.properties.name]:null;f(c?JSON.parse(c):[]);},[t.context.formData]),useEffect(()=>{var c;if(F&&n.current!=null){let M=(c=n.current)==null?void 0:c.getData();A.current&&(A.current[t.properties.name]=JSON.stringify(M)),k(false);}},[F]),useEffect(()=>((async()=>{var c,M;t.context.enableEventHandlers?await o({pluginCode:t.context.params.pluginCode,formCode:t.context.params.formCode,guid:t.context.params.guid,projectGuid:t.context.params.pGuid,pGuid:t.context.params.pGuid,widgetContext:JSON.stringify({referer:h.pathname,parentWidgetId:It,hasParentForm:T.hasParentForm(),originator:(c=t.context.params)==null?void 0:c.originator,parent:t.context.params,folderData:(M=t.context.params)==null?void 0:M.folderData}),widgetEvent:U.onTableEditDataLoad,widgetName:t.properties.name.toLowerCase(),formData:t.context.formData}).then(C=>{if(C.meta.requestStatus==="fulfilled"){let p={...C.payload};if(Object.keys(p).length===0)return;if(!p.data){s(true);return}let v=p.data[t.properties.name];p.widgetData.length===0&&v!==void 0&&v!==null&&v.length>0?f(JSON.parse(v)):p.widgetData.length>0&&f(Object.values(p.widgetData)),s(true);}}):s(true);})(),()=>{if(n.current){try{typeof n.current.destroy=="function"&&n.current.destroy();}catch(c){}n.current=null;}}),[]);let W=c=>{var M,C;if(n.current){let p=c.getRow().getData()._id,Y=((M=n.current)==null?void 0:M.getData()).filter(_=>_._id!==p);(C=n.current)==null||C.setData(Y),k(true);}},K=(c,M)=>{if(P(t.properties))return;let C=document.querySelector(".menu-container");C&&C.remove();let p=document.createElement("div");p.className="menu-container",document.body.appendChild(p);let v=X.createRoot(p);v.render(jsx(Ct,{cellElement:c,cell:M,actionHandler:_=>{v.unmount(),p.remove(),document.removeEventListener("click",Y),W(_);}}));let Y=_=>{p.contains(_.target)||(v.unmount(),p.remove(),document.removeEventListener("click",Y));};document.addEventListener("click",Y);};useEffect(()=>{let c;(()=>{c=t.methodProvider.findWidgetItem(t.id);let C=[];c.item.properties.datasource.columns&&(c.item.properties.datasource.columns||[]).map(l=>{C[l[1]]=l[0];});let p=[];(c.item._children||[]).map(({properties:l})=>{l.item_name.toString()!==""&&l.item_increment&&p.push(l.item_name);}),R(p);let v=[];v.push({title:"",field:"remove",headerHozAlign:"center",hozAlign:"center",vertAlign:"middle",width:"1",formatter:l=>{let O=document.createElement("div");return O.style.cursor="pointer",O.style.color="#C0C0C0",O.style.fontSize="0.9rem",O.style.textAlign="center",X.createRoot(O).render(jsx(m,{})),O.addEventListener("click",B=>{B.stopPropagation();let $=l.getElement();K($,l);}),O}});let Y={},_={},I={},dt=100,ft=false;c.item._children.forEach(({properties:l})=>{dt+=parseInt(l.item_minsize,10)||0,l.item_bottomcalc&&(ft=true);}),b$1(dt),(c.item._children||[]).map(({properties:l})=>{var O,nt;if(l.item_name.toString()!==""){let B=l.item_title.split("!!!"),$=B.length>1&&B[0]||null,rt=B.length>1?B[1]:l.item_title;l.item_formula!=null&&l.item_formula.trim()!==""&&(_[l.item_name]=l.item_formula,I[l.item_name]=L.parseExpression(_[l.item_name]));let gt={cellEdited:S=>{let G=S.getField();k(true);let ot=(V,N)=>{let Z=L.buildDependencyGraph(I),at=L.topologicalSort(Z);at.forEach(tt=>{let yt=I[tt];if(yt){let jt=N.getData(),zt=L.evaluateFormula(yt,L.convertToVariables(jt));V!==tt&&(N.update({[tt]:parseFloat(zt.toFixed(2)).toFixed(2)}));}});};for(let V in I)if(Object.prototype.hasOwnProperty.call(I,V)){let N=I[V];if(N&&typeof N=="object"&&L.formulaHasFieldName(N,G)){let Z=S.getRow();if(Z){let at=S.getRow().getData(),it=L.evaluateFormula(N,L.convertToVariables(at));Z.update({[V]:parseFloat(it.toFixed(2)).toFixed(2)});}}}ot(G,S.getRow());},editor:se(t.properties,l,r,m$1),editable:!t.properties.readonly&&!l.item_readonly,field:l.item_name,formatter:Yt(n,t.properties,t.context.formData,l,r,"body"),formatterParams:de(t.properties,l),title:rt,titleFormatter:l.item_displaytooltip?()=>{let S=document.createElement("div");return X.createRoot(S).render(jsx(Et,{title:rt,arrow:true,children:jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"block"},children:rt})})),S}:void 0,cssClass:!t.properties.readonly&&!l.item_readonly?"tabulator-ellipsis":"tabulator-readonly",minWidth:parseInt(l.item_minsize,10)||void 0,headerHozAlign:(O=l.style.item_textalign)!=null?O:"center",hozAlign:(nt=l.style.item_ctextalign)!=null?nt:"center",vertAlign:"middle",bottomCalc:S=>l.item_bottomcalc?S.reduce((G,ot)=>{let V=parseFloat(String(ot).replace(",","."));return G+(isNaN(V)?0:V)},0):"",bottomCalcFormatter:ft?Yt(n,t.properties,t.context.formData,l,r,"totals"):void 0,headerSort:l.item_enablesorting};$?(Y[$]||(Y[$]=[]),Y[$].push(gt)):v.push(gt);}}),Object.entries(Y).forEach(([l,O])=>{v.push({title:l,columns:O,cssClass:t.properties.readonly?"tabulator-readonly":"tabulator-ellipsis"});}),w(v),s(true);})();},[t.properties,t.context.params.guid]),useEffect(()=>{n.current&&(n.current.setColumns(D),n.current.redraw());},[D]);let P=c=>!!(c.readonly&&!c.ignorereadonly);function Q(c){let M=C=>C.reduce((p,v)=>{var Y,_;if(v.field&&(p[v.field]="",E.includes(v.field))){let I=(_=(Y=n.current)==null?void 0:Y.getDataCount())!=null?_:0;I!==void 0&&(p[v.field]=String(I+1));}return v.columns&&Array.isArray(v.columns)&&Object.assign(p,M(v.columns)),p},{});return {_id:nanoid(11),...M(c)}}let Ot=()=>jsx(Et,{title:H("Add New"),children:jsx("span",{children:jsx(te,{disabled:P(t.properties),color:"primary",style:{marginRight:"5px"},onClick:()=>{n.current&&n.current.addRow(Q(D));},variant:"outlined",children:jsx(p,{})})})}),{hideaddbutton:_t,folders:Lt,visible:Ht}=t.properties,{tabId:It}=t;if(!Ht)return null;if(!a$1)return jsx(q,{text:"",size:40,textVariant:"body2",variant:void 0});let St={minHeight:t.properties.height,movableRows:false,movableColumns:false,rowHeight:40,layout:"fitColumns"},Vt=()=>{document.querySelectorAll(".tabulator-header-contents > br").forEach(C=>C.remove());document.querySelectorAll(".tabulator-footer");};return jsxs(Fragment,{children:[Lt&&jsx("div",{style:{paddingBottom:"0.8rem",fontSize:"0.85rem",color:"#666",marginLeft:"0.2rem"},children:ae(t)}),jsxs("div",{style:{padding:10,paddingBottom:0,overflowX:"auto"},ref:i,children:[jsx(Zt,{sx:{paddingBottom:1,paddingTop:1,paddingRight:1},children:!_t&&jsx(Ot,{})}),jsx(oe,{onRef:c=>n.current=c==null?void 0:c.current,data:d,columns:D,options:St,events:{tableBuilt:Vt},className:"tabulator",style:{marginBottom:0,minWidth:y+"px"}})]})]})}));kt.displayName="_Tabulator";var Ze=kt;export{Ze as TabulatorTable};
1
+ import {a,b as b$1}from'./chunk-5VSWNFWW.js';import {a as a$1}from'./chunk-POE6K4NQ.js';import {U,T,k}from'./chunk-TYVVEP34.js';import'./chunk-U4T4ACDE.js';import {b}from'./chunk-LBMVBVXW.js';import {q,a as a$2}from'./chunk-AYYTOQGP.js';import {c,d,p,m,N}from'./chunk-AR42AC7J.js';import'./chunk-5TBO732O.js';import {lazy,memo,useRef,useState,useEffect}from'react';import {withTranslation,useTranslation}from'react-i18next';import {useLocation}from'react-router-dom';import {LocalizationProvider,DateTimePicker,DatePicker}from'@mui/x-date-pickers';import Ft from'@mui/material/TextField';import X from'react-dom/client';import Et from'@mui/material/Tooltip';import Zt from'@mui/material/Box';import te from'@mui/material/Button';import Pt from'@mui/material/MenuList';import Nt from'@mui/material/MenuItem';import At from'@mui/material/Paper';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {nanoid}from'@reduxjs/toolkit';import ne from'react-dom/server';import'react-tabulator/lib/styles.css';import'react-tabulator/css/bootstrap/tabulator_bootstrap.min.css';import'react-tabulator/lib/css/bootstrap/tabulator_bootstrap.min.css';var $t=({cellElement:c,cell:t,actionHandler:o})=>{let {t:e}=useTranslation();t.getRow().getPosition();let i=c.getBoundingClientRect(),m=i.bottom+window.scrollY,a=i.left+window.scrollX;return jsx(At,{style:{position:"absolute",top:m+"px",left:a+"px",zIndex:2e3,minWidth:"150px"},children:jsx(Pt,{children:jsxs(Nt,{onClick:()=>o(t),children:[jsx(N,{style:{fontSize:"1em",marginRight:"0.5em"}})," ",e("Delete")]})})})},Ct=$t;var L=class c{static convertToVariables(t){let o={};for(let e in t)if(t.hasOwnProperty(e)&&(typeof t[e]=="string"||typeof t[e]=="number")){let n=Number(t[e]);isNaN(n)||(o[e]=n);}return o}static formulaHasFieldName(t,o){if(t.operands){for(let e of t.operands)if(typeof e=="string"&&e===o||typeof e=="object"&&c.formulaHasFieldName(e,o))return true}return false}static parseExpression(t){t=t.replace(/\s+/g,"");let o=/\(([^()]+)\)/;for(;o.test(t);)t=t.replace(o,(i,m)=>{let a=c.parseExpression(m.trim());return `@${JSON.stringify(a)}`});let n=c.tokenize(t).map(i=>i.startsWith("@")?JSON.parse(i.substring(1)):i);return c.parseTokens(n)}static tokenize(t){let o=[],e="",n=false,i=0;for(let m=0;m<t.length;m++){let a=t[m];if(a==="@"&&t[m+1]==="{"&&(e&&(o.push(e),e=""),n=true,i=0),n){e+=a,a==="{"?i++:a==="}"&&(i--,i===0&&(o.push(e),e="",n=false));continue}if("+-*/()".includes(a)){e&&(o.push(e),e=""),o.push(a);continue}e+=a;}return e&&o.push(e),o}static parseTokens(t){if(t.length===1){let a=t[0];if(typeof a=="string"){let s=parseFloat(a);return isNaN(s)?{operands:[a]}:{value:s}}if(typeof a=="object")return a}let o={"+":1,"-":1,"*":2,"/":2},e=1/0,n=-1;if(t.forEach((a,s)=>{if(typeof a=="string"&&a in o){let d=a;o[d]<=e&&(e=o[d],n=s);}}),n===-1)throw new Error(`Invalid expression: no operator found in tokens ${JSON.stringify(t)}`);let i=t.slice(0,n),m=t.slice(n+1);if(i.length===0||m.length===0)throw new Error(`Invalid expression: operator without operands in tokens ${JSON.stringify(t)}`);return {operator:t[n],operands:[c.parseTokens(i),c.parseTokens(m)]}}static evaluateFormula(t,o){if(t.value!==void 0)return t.value;let{operator:e,operands:n}=t;if(!e||!n||n.length!==2)throw new Error("Invalid parsed formula");let[i,m]=n.map(a=>{if(typeof a=="object"&&a.operands&&a.operands.length===1&&(a=a.operands[0]),typeof a=="string")return o[a]||0;if(typeof a=="number")return a;if(typeof a=="object")return c.evaluateFormula(a,o);throw new Error(`Unsupported operand type: ${JSON.stringify(a)}`)});switch(e){case "+":return i+m;case "-":return i-m;case "*":return i*m;case "/":return i/m;default:throw new Error(`Unsupported operator: ${e}`)}}static convertValuesToStrings(t){return t.map(o=>{let e={};for(let[n,i]of Object.entries(o))e[n]=i===void 0?"":String(i);return e})}static buildDependencyGraph(t){let o={};for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e)){let n=t[e],i=[],m=a=>{a.forEach(s=>{typeof s=="string"?i.push(s):typeof s=="object"&&"operands"in s&&s.operands&&m(s.operands);});};n.operands&&m(n.operands),o[e]=i;}return o}static topologicalSort(t){let o=new Set,e=[],n=i=>{o.has(i)||(o.add(i),(t[i]||[]).forEach(n),e.push(i));};return Object.keys(t).forEach(n),e}};var re=ne.renderToStaticMarkup(jsx(c,{}));if(typeof window!="undefined"&&window.ResizeObserver){let c=window.ResizeObserver;window.ResizeObserver=class extends c{constructor(t){let o;super((e,n)=>{cancelAnimationFrame(o),o=requestAnimationFrame(()=>t(e,n));});}};}var oe=lazy(()=>import('react-tabulator').then(c=>({default:c.ReactTabulator}))),ae=c=>{var o;if(!c.properties.folders)return null;var t=(o=c.context.params.folderData)==null?void 0:o.captions;return t==null||t.length===0?null:(t=t.slice(1),jsx("span",{style:{display:"flex",alignItems:"center"},children:t.map((e,n)=>jsxs("span",{style:{display:"inline-flex",alignItems:"center"},children:[e,n<t.length-1&&jsx(d,{style:{margin:"0 8px",fontSize:"0.6rem",color:"#666"}})]},n))}))},ie=(c,t,o,e,n,i,m,a)=>{let s=document.createElement("div"),d=null,f=c.getValue(),D=f?a$1(f):null,w=null,E=false,R=()=>{let r=null;if(E&&w!==null){if(w.trim()===""){e(),d&&d.unmount();return}if(r=a$1(w),!r.isValid()){let h=["DD.MM.YYYY","YYYY-MM-DD","MM/DD/YYYY","DD/MM/YYYY","M/D/YYYY","D/M/YYYY"];for(let F of h)if(r=a$1(w,F),r.isValid())break}(!r||!r.isValid())&&(r=D);}else r=D;r&&r.isValid()?(m.current=a,o(r.format("YYYY-MM-DD"))):f?o(f):e(),d&&d.unmount();},y=r=>{D=r;},b=r=>{D=r,E=false,R();},H=r=>{w=r.target.value,E=true;},x=jsx("div",{onMouseDown:r=>{r.stopPropagation();},children:jsx(LocalizationProvider,{dateAdapter:a$2,adapterLocale:i,children:jsx(DatePicker,{value:a$1(f),onAccept:b,onChange:y,slots:{actionBar:()=>null,textField:r=>jsx(Ft,{...r,onChange:h=>{r.onChange&&r.onChange(h),H(h);},sx:{"& .MuiOutlinedInput-root":{fontSize:"13px",border:"none"},"& .MuiOutlinedInput-notchedOutline":{border:"none"},"& .MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline":{border:"none"}}})}})})});return t(()=>{d||(d=X.createRoot(s),d.render(x));}),s.addEventListener("blur",r=>{setTimeout(()=>{s.contains(document.activeElement)||R();},200);}),s.addEventListener("keydown",r=>{if(r.key==="Tab"||r.key==="Enter"){r.preventDefault();let h=s.querySelector('input[type="text"]');h&&E&&(w=h.value),R();}}),s},le=(c,t,o,e,n,i,m,a)=>{let s=document.createElement("div"),d=null,f=c.getValue(),D=f?a$1(f):null,w=null,E=false,R=()=>{let r=null;if(E&&w!==null){if(w.trim()===""){e(),d&&d.unmount();return}if(r=a$1(w),!r.isValid()){let h=["DD.MM.YYYY HH:mm:ss","DD.MM.YYYY HH:mm","YYYY-MM-DD HH:mm:ss","YYYY-MM-DD HH:mm","YYYY-MM-DDTHH:mm:ss","MM/DD/YYYY HH:mm:ss","MM/DD/YYYY HH:mm","DD/MM/YYYY HH:mm:ss","DD/MM/YYYY HH:mm"];for(let F of h)if(r=a$1(w,F),r.isValid())break}if(!r||!r.isValid()){let h=["HH:mm:ss","HH:mm"];for(let F of h){let k=a$1(w,F,true);if(k.isValid()){r=(f?a$1(f):a$1()).hour(k.hour()).minute(k.minute()).second(k.second());break}}}(!r||!r.isValid())&&(r=D);}else r=D;r&&r.isValid()?(m.current=a,o(r.format("YYYY-MM-DDTHH:mm:ss"))):f?o(f):e(),d&&d.unmount();},y=r=>{D=r;},b=r=>{D=r,E=false,R();},H=r=>{w=r.target.value,E=true;},x=jsx("div",{onMouseDown:r=>{r.stopPropagation();},children:jsx(LocalizationProvider,{dateAdapter:a$2,adapterLocale:i,children:jsx(DateTimePicker,{value:f?a$1(f):null,onAccept:b,onChange:y,ampm:false,slots:{actionBar:()=>null,textField:r=>jsx(Ft,{...r,onChange:h=>{r.onChange&&r.onChange(h),H(h);},sx:{"& .MuiOutlinedInput-root":{fontSize:"13px",border:"none"},"& .MuiOutlinedInput-notchedOutline":{border:"none"},"& .MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline":{border:"none"}}})}})})});return t(()=>{d||(d=X.createRoot(s),d.render(x));}),s.addEventListener("blur",r=>{setTimeout(()=>{s.contains(document.activeElement)||R();},200);}),s.addEventListener("keydown",r=>{if(r.key==="Tab"||r.key==="Enter"){r.preventDefault();let h=s.querySelector('input[type="text"]');h&&E&&(w=h.value),R();}}),s},se=(c,t,o,e)=>{var m;if(!c.alloweditrow||c.readonly===true)return;let n=(m=t.item_columntype)!=null?m:"freetext";t.item_columntype||(t.item_isdate===true?n="date":t.item_isdatetime===true?n="datetime":t.item_ischeckbox===true?n="checkbox":t.item_isprice===true?n="price":n="freetext");return n==="datetime"?(a,s,d,f,D)=>le(a,s,d,f,D,o.current,e,c.name):n==="date"?(a,s,d,f,D)=>ie(a,s,d,f,D,o.current,e,c.name):t.item_editor==="number"||n==="price"||n==="number"?"number":t.item_editor==="checkbox"||n==="checkbox"?"tickCross":"input"},ue=(c,t,o,e,n)=>{let i=c.getElement();i.style.backgroundColor="#f0f0f0",i.style.color="#555",i.style.pointerEvents="none";},Yt=(c,t,o,e,n,i)=>{var R;let m=(y,b,H)=>{if(!(H==="price"))return `<div class="tabulator-text">${y||""}</div>`;let x=e.item_format==="fixed-locale",h=x&&e.item_fixedlocale||n.current||void 0,F=b!==void 0&&b[e.item_inputfield]?b[e.item_inputfield]:e.item_currency,k$1=e.item_format==="locale"?k(n.current):void 0,A=x?k(e.item_fixedlocale||""):void 0,W=String(F!=null?F:""),K=W&&W.trim()!==""?W.trim():k$1!=null?k$1:A;try{let P,Q=e.item_currencydisplay||(x?"symbol":"");return K&&Q!==""?P=new Intl.NumberFormat(h,{style:"currency",currency:K,currencyDisplay:Q,minimumFractionDigits:2,maximumFractionDigits:2}).format(y||0):P=new Intl.NumberFormat(h,{style:"decimal",minimumFractionDigits:2,maximumFractionDigits:2}).format(y||0),`<div class="tabulator-text">${P}</div>`}catch(P){return `<div class="tabulator-text">${(y||0).toFixed(2)}</div>`}};if(!t.alloweditrow)return;let a=(R=e.item_columntype)!=null?R:"freetext";e.item_columntype||(e.item_isdate===true?a="date":e.item_isdatetime===true?a="datetime":e.item_ischeckbox===true?a="checkbox":e.item_isprice===true||e.item_format==="locale"||e.item_format==="fixed-locale"?a="price":a="freetext");let s=e.item_readonly||i==="totals",d=a==="price",f=a==="number",D=a==="date",w=a==="datetime",E=a==="checkbox";return s?y=>{ue(y,t,e,n.current);let b=y.getValue();return i==="totals"&&(!e.item_bottomcalc||b==="")?"":m(b,o,a)}:w?y=>me(y,n.current)||"":D?y=>ce(y,n.current)||"":E?"tickCross":d?y=>{let b=y.getValue();return m(b,o,a)}:f?y=>{let b=y.getValue();if(b==null||b==="")return '<div class="tabulator-text"></div>';let H=parseFloat(b);return isNaN(H)?`<div class="tabulator-text">${b}</div>`:`<div class="tabulator-text">${H.toLocaleString(n.current||void 0,{minimumFractionDigits:0,maximumFractionDigits:10})}</div>`}:y=>`<div class="tabulator-text">${y.getValue()||""}</div>`},ce=(c,t)=>{let o=c.getValue();if(!o)return "";try{let e=a$1(o);return t&&b$1(t)?e.locale(t).format("L"):(t&&!b$1(t)&&a(t).catch(n=>{}),e.format("L"))}catch(e){return a$1(o).format("YYYY-MM-DD")}},me=(c,t)=>{let o=c.getValue();if(!o)return "";try{let e=a$1(o);return t&&b$1(t)?e.locale(t).format("L LT"):(t&&!b$1(t)&&a(t).catch(n=>{}),e.format("L LT"))}catch(e){return a$1(o).format("YYYY-MM-DD HH:mm")}},de=(c,t)=>{if(c.alloweditrow&&t.item_editor==="checkbox")return {allowEmpty:true,crossElement:false,tickElement:re}},kt=withTranslation()(memo(function(t){var mt;let{runFormEvent:o,viewPort:e}=b(),n=useRef(null),i=useRef(null),m$1=useRef(null),[a$1,s]=useState(false),[d,f]=useState([]),[D,w]=useState([]),[E,R]=useState([]),[y,b$1]=useState(0),{t:H,i18n:z}=useTranslation(),x=(mt=z==null?void 0:z.language)==null?void 0:mt.substring(0,2),r=useRef(x!=null?x:""),h=useLocation(),[F,k]=useState(false),A=useRef(t.context.formData||{});useEffect(()=>{x&&a(x).catch(u=>{});},[x]),useEffect(()=>{if(r.current=x!=null?x:"",n.current)try{n.current.redraw(!0);}catch(u){}},[x]),useEffect(()=>{let u=()=>{n.current&&!e.isMobileDevice&&n.current.redraw();};return window.addEventListener("resize",u),()=>{window.removeEventListener("resize",u);}},[]),useEffect(()=>{A.current=t.context.formData||{};let u=t.context.formData?t.context.formData[t.properties.name]:null;f(u?JSON.parse(u):[]);},[t.context.formData]),useEffect(()=>{var u;if(F&&n.current!=null){let M=(u=n.current)==null?void 0:u.getData();A.current&&(A.current[t.properties.name]=JSON.stringify(M)),k(false);}},[F]),useEffect(()=>((async()=>{var u,M;t.context.enableEventHandlers?await o({pluginCode:t.context.params.pluginCode,formCode:t.context.params.formCode,guid:t.context.params.guid,projectGuid:t.context.params.pGuid,pGuid:t.context.params.pGuid,widgetContext:JSON.stringify({referer:h.pathname,parentWidgetId:It,hasParentForm:T.hasParentForm(),originator:(u=t.context.params)==null?void 0:u.originator,parent:t.context.params,folderData:(M=t.context.params)==null?void 0:M.folderData}),widgetEvent:U.onTableEditDataLoad,widgetName:t.properties.name.toLowerCase(),formData:t.context.formData}).then(C=>{if(C.meta.requestStatus==="fulfilled"){let p={...C.payload};if(Object.keys(p).length===0)return;if(!p.data){s(true);return}let v=p.data[t.properties.name];p.widgetData.length===0&&v!==void 0&&v!==null&&v.length>0?f(JSON.parse(v)):p.widgetData.length>0&&f(Object.values(p.widgetData)),s(true);}}):s(true);})(),()=>{if(n.current){try{typeof n.current.destroy=="function"&&n.current.destroy();}catch(u){}n.current=null;}}),[]);let W=u=>{var M,C;if(n.current){let p=u.getRow().getData()._id,Y=((M=n.current)==null?void 0:M.getData()).filter(_=>_._id!==p);(C=n.current)==null||C.setData(Y),k(true);}},K=(u,M)=>{if(P(t.properties))return;let C=document.querySelector(".menu-container");C&&C.remove();let p=document.createElement("div");p.className="menu-container",document.body.appendChild(p);let v=X.createRoot(p);v.render(jsx(Ct,{cellElement:u,cell:M,actionHandler:_=>{v.unmount(),p.remove(),document.removeEventListener("click",Y),W(_);}}));let Y=_=>{p.contains(_.target)||(v.unmount(),p.remove(),document.removeEventListener("click",Y));};document.addEventListener("click",Y);};useEffect(()=>{let u;(()=>{if(u=t.methodProvider.findWidgetItem(t.id),!u)return;let C=[];u.item.properties.datasource.columns&&(u.item.properties.datasource.columns||[]).map(l=>{C[l[1]]=l[0];});let p=[];(u.item._children||[]).map(({properties:l})=>{l.item_name.toString()!==""&&l.item_increment&&p.push(l.item_name);}),R(p);let v=[];v.push({title:"",field:"remove",headerHozAlign:"center",hozAlign:"center",vertAlign:"middle",width:"1",formatter:l=>{let O=document.createElement("div");return O.style.cursor="pointer",O.style.color="#C0C0C0",O.style.fontSize="0.9rem",O.style.textAlign="center",X.createRoot(O).render(jsx(m,{})),O.addEventListener("click",B=>{B.stopPropagation();let $=l.getElement();K($,l);}),O}});let Y={},_={},I={},dt=100,ft=false;u.item._children.forEach(({properties:l})=>{dt+=parseInt(l.item_minsize,10)||0,l.item_bottomcalc&&(ft=true);}),b$1(dt),(u.item._children||[]).map(({properties:l})=>{var O,nt;if(l.item_name.toString()!==""){let B=l.item_title.split("!!!"),$=B.length>1&&B[0]||null,rt=B.length>1?B[1]:l.item_title;l.item_formula!=null&&l.item_formula.trim()!==""&&(_[l.item_name]=l.item_formula,I[l.item_name]=L.parseExpression(_[l.item_name]));let gt={cellEdited:S=>{let G=S.getField();k(true);let ot=(V,N)=>{let Z=L.buildDependencyGraph(I),at=L.topologicalSort(Z);at.forEach(tt=>{let yt=I[tt];if(yt){let jt=N.getData(),zt=L.evaluateFormula(yt,L.convertToVariables(jt));V!==tt&&(N.update({[tt]:parseFloat(zt.toFixed(2)).toFixed(2)}));}});};for(let V in I)if(Object.prototype.hasOwnProperty.call(I,V)){let N=I[V];if(N&&typeof N=="object"&&L.formulaHasFieldName(N,G)){let Z=S.getRow();if(Z){let at=S.getRow().getData(),it=L.evaluateFormula(N,L.convertToVariables(at));Z.update({[V]:parseFloat(it.toFixed(2)).toFixed(2)});}}}ot(G,S.getRow());},editor:se(t.properties,l,r,m$1),editable:!t.properties.readonly&&!l.item_readonly,field:l.item_name,formatter:Yt(n,t.properties,t.context.formData,l,r,"body"),formatterParams:de(t.properties,l),title:rt,titleFormatter:l.item_displaytooltip?()=>{let S=document.createElement("div");return X.createRoot(S).render(jsx(Et,{title:rt,arrow:true,children:jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"block"},children:rt})})),S}:void 0,cssClass:!t.properties.readonly&&!l.item_readonly?"tabulator-ellipsis":"tabulator-readonly",minWidth:parseInt(l.item_minsize,10)||void 0,headerHozAlign:(O=l.style.item_textalign)!=null?O:"center",hozAlign:(nt=l.style.item_ctextalign)!=null?nt:"center",vertAlign:"middle",bottomCalc:S=>l.item_bottomcalc?S.reduce((G,ot)=>{let V=parseFloat(String(ot).replace(",","."));return G+(isNaN(V)?0:V)},0):"",bottomCalcFormatter:ft?Yt(n,t.properties,t.context.formData,l,r,"totals"):void 0,headerSort:l.item_enablesorting};$?(Y[$]||(Y[$]=[]),Y[$].push(gt)):v.push(gt);}}),Object.entries(Y).forEach(([l,O])=>{v.push({title:l,columns:O,cssClass:t.properties.readonly?"tabulator-readonly":"tabulator-ellipsis"});}),w(v),s(true);})();},[t.properties,t.context.params.guid]),useEffect(()=>{n.current&&(n.current.setColumns(D),n.current.redraw());},[D]);let P=u=>!!(u.readonly&&!u.ignorereadonly);function Q(u){let M=C=>C.reduce((p,v)=>{var Y,_;if(v.field&&(p[v.field]="",E.includes(v.field))){let I=(_=(Y=n.current)==null?void 0:Y.getDataCount())!=null?_:0;I!==void 0&&(p[v.field]=String(I+1));}return v.columns&&Array.isArray(v.columns)&&Object.assign(p,M(v.columns)),p},{});return {_id:nanoid(11),...M(u)}}let Ot=()=>jsx(Et,{title:H("Add New"),children:jsx("span",{children:jsx(te,{disabled:P(t.properties),color:"primary",style:{marginRight:"5px"},onClick:()=>{n.current&&n.current.addRow(Q(D));},variant:"outlined",children:jsx(p,{})})})}),{hideaddbutton:_t,folders:Lt,visible:Ht}=t.properties,{tabId:It}=t;if(!Ht)return null;if(!a$1)return jsx(q,{text:"",size:40,textVariant:"body2",variant:void 0});let St={minHeight:t.properties.height,movableRows:false,movableColumns:false,rowHeight:40,layout:"fitColumns"},Vt=()=>{document.querySelectorAll(".tabulator-header-contents > br").forEach(C=>C.remove());document.querySelectorAll(".tabulator-footer");};return jsxs(Fragment,{children:[Lt&&jsx("div",{style:{paddingBottom:"0.8rem",fontSize:"0.85rem",color:"#666",marginLeft:"0.2rem"},children:ae(t)}),jsxs("div",{style:{padding:10,paddingBottom:0,overflowX:"auto"},ref:i,children:[jsx(Zt,{sx:{paddingBottom:1,paddingTop:1,paddingRight:1},children:!_t&&jsx(Ot,{})}),jsx(oe,{onRef:u=>n.current=u==null?void 0:u.current,data:d,columns:D,options:St,events:{tableBuilt:Vt},className:"tabulator",style:{marginBottom:0,minWidth:y+"px"}})]})]})}));kt.displayName="_Tabulator";var Ze=kt;export{Ze as TabulatorTable};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buildocsdev/sdk",
3
- "version": "1.1.25",
3
+ "version": "1.1.26",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/"
6
6
  },
@@ -1 +0,0 @@
1
- import {d}from'./chunk-SYCZSSRF.js';import {a}from'./chunk-POE6K4NQ.js';import {e,b as b$1}from'./chunk-FRAOYRZD.js';import {U,T,k}from'./chunk-TYVVEP34.js';import'./chunk-U4T4ACDE.js';import {b}from'./chunk-LBMVBVXW.js';import {d as d$1,t,p,V,h,q,g,N,_,Y,W,X,Z,P,r,n,i,w,A,b as b$2,y,x,C,l,O,o}from'./chunk-AR42AC7J.js';import'./chunk-5TBO732O.js';import dt,{lazy,memo,useRef,useState,useEffect,useCallback,useMemo,Suspense}from'react';import {withTranslation,useTranslation}from'react-i18next';import qn from'@mui/material/CircularProgress';import Xt from'@mui/material/Box';import Fe from'@mui/material/Button';import $n from'@mui/material/Checkbox';import Kn from'@mui/material/ClickAwayListener';import Kt from'@mui/material/IconButton';import Qe from'@mui/material/ListItemIcon';import Xe from'@mui/material/ListItemText';import Ze from'@mui/material/MenuItem';import Qn from'@mui/material/MenuList';import re from'@mui/material/Tooltip';import {nanoid}from'@reduxjs/toolkit';import {useNavigate,useLocation}from'react-router-dom';import en from'@mui/material/Menu';import Zn from'axios';import ea from'@mui/icons-material/MoreVert';import {jsx,Fragment,jsxs}from'react/jsx-runtime';var ta=lazy(()=>import('./buildocslib.esm-BUFQH2Q3.js').then(c=>({default:c.DatatableImb}))),na="#1976d2";var ut=(r=>(r[r.SIGN=0]="SIGN",r[r.CONFIRM=1]="CONFIRM",r))(ut||{}),tn=(l=>(l[l.SIGN=0]="SIGN",l[l.CONFIRM=1]="CONFIRM",l[l.EDIT=2]="EDIT",l))(tn||{}),et=(c,e,r,l,g)=>{var le,G,se,E,b;return e.methodProvider.eventDispatcher({skipFormDataItem:true,widgetName:e.properties.name.toLowerCase(),widgetValue:JSON.stringify({action:c,rowData:{_id:(le=r._id)!=null?le:null,_sk:(G=r._sk)!=null?G:null,_code:(se=r._fcode)!=null?se:r._code,_origformcode:(E=r._origformcode)!=null?E:null,_plugincode:(b=r._plcode)!=null?b:r._plugincode}}),widgetEvent:U.onTableRunActionEvent,widgetContext:JSON.stringify({referer:l.pathname,parentWidgetId:g,hasParentForm:T.hasParentForm(),originator:{widgetName:e.properties.name.toLowerCase(),params:e.context.params},parent:{widgetName:e.properties.name.toLowerCase(),params:e.context.params},folderData:e.context.params.folderData})})},Se=(c,e)=>{var r,l;return !(c==="file"&&e.formLayout==="folders"&&((r=e.params.folderData)!=null&&r.isRoot||((l=e.params.folderData)==null?void 0:l.id)===null))},aa=({anchorEl:c,handleClose:e$1,setUploadMode:r,uploadMode:l,props:g,setLoaded:le})=>{let{runFormUploadFiles:G}=b(),se=e(),E=!!c,b$1=useRef(null),[ie,q]=useState([]),{t:ce}=useTranslation(),te=(de="file")=>{if(!Se(de,g.context)){se({toastID:nanoid(11),msg:ce("Please select a folder before uploading a file"),clearQueue:false,hideProgressBar:false});return}b$1.current&&b$1.current.click(),r(de),e$1();},$=async de=>{var m,R;let me=de.target.files;if(me){le(false);let _=Array.from(me).map(T=>({...T,uploadProgress:0})),x=new FormData;if(g.context.params)for(let T in g.context.params)g.context.params.hasOwnProperty(T)&&x.append(T,g.context.params[T]);x.append("fieldName",g.properties.name),Array.from(me).forEach(T=>{x.append("files",T);}),x.append("widgetContext",JSON.stringify({hasParentForm:T.hasParentForm(),originator:(m=g.context.params)==null?void 0:m.originator,folderData:(R=g.context.params)==null?void 0:R.folderData})),x.append("widgetEvent",U.onFileUploadCreateDocumentEvent),x.append("widgetName","attached_files"),x.append("formData",JSON.stringify({...g.context.formData})),x.append("uploadMode",l);let B=Zn.CancelToken.source();try{let T=await G({content:x,cancelTokenSource:B,onUploadProgress:X=>{let he=Math.round(X.loaded/_.length),ye=_.map(be=>({...be,uploadProgress:X.loaded===X.total?100:Math.round(he*100/be.size)}));q(be=>be.concat(ye));}});if(T.meta.requestStatus==="fulfilled"){let X={...T.payload};g.methodProvider.execCommands(X.FECommand);}}catch(T){}b$1.current&&(b$1.current.value="");}},Te=Se("file",g.context)?"inherit":"#C0C0C0";return jsxs(Fragment,{children:[jsx("input",{type:"file",name:"files",ref:b$1,style:{display:"none"},onChange:$,multiple:true}),jsxs(en,{anchorEl:c,open:E,onClose:e$1,MenuListProps:{"aria-labelledby":"upload-button"},children:[jsxs(Ze,{onPointerUp:()=>te("file"),children:[jsx(Qe,{sx:{color:Te},children:jsx(Pe,{action:"uploadfile",applyInternalStyle:true})}),jsx(Xe,{primary:ce("Upload File(s)"),primaryTypographyProps:{fontSize:"0.875rem",color:Te}})]},"Upload File(s)"),jsxs(Ze,{onPointerUp:()=>te("container"),children:[jsx(Qe,{children:jsx(Pe,{action:"uploadzipfile",applyInternalStyle:true})}),jsx(Xe,{primary:ce("Upload .ZIP Archive"),primaryTypographyProps:{fontSize:"0.875rem"}})]},"Upload .ZIP Archive")]})]})},oa=(c,e,r,l)=>(c._plugincode=e.context.params.pluginCode,c._origformcode=c._code=e.context.params.formCode,et("onrowcheckboxclicked",e,c,r,l)),ia=({value:c,style:e})=>{let[r,l]=dt.useState(false),g=dt.useRef(null);return jsx(re,{title:String(c!=null?c:"").trim()?c:"No data",open:r,arrow:true,children:jsx("div",{ref:g,style:e,onMouseEnter:()=>{g.current&&g.current.scrollWidth>g.current.clientWidth&&l(true);},onMouseLeave:()=>l(false),children:c||""})})},gt=c=>!!(c.readonly&&!c.ignorereadonly),st=c=>{let e=c.replace(/\s/g,""),r=e.lastIndexOf(","),l=e.lastIndexOf("."),g;return r>l?g=e.replace(/\./g,"").replace(",","."):l>r?g=e.replace(/,/g,""):g=e,parseFloat(g)},Qt=(c,e,r,l)=>c===0?"first":c<e?"previous":l>0&&(c+1)*r>=l?"last":"next",ct={rowsPerPage:0,pageIndex:0,serverPaginationEnabled:false,nextToken:"",paginationDirection:"first",previousToken:"",rowCount:0,qId:""},ra={string:"freetext",freetext:"freetext",currency:"price",price:"price",date:"date",datetime:"datetime",number:"number",checkbox:"checkbox"},nn=withTranslation()(memo(function(e$1){var bt,Ct,Dt;let r$1=useRef(false),{runFormEvent:l,viewPort:g$1}=b(),le=e(),{UserDialog:G}=b$1(),se=e$1.properties.name,E=d(se,e$1.properties.pagesize||50),{pageIndex:b$2,pageSize:ie}=E,[q$1,ce]=useState(null),[te,$]=useState(false),[Te,de]=useState("single"),[me,m]=useState([]),[R,_$1]=useState(0),[x,B]=useState(),[T$1,X$1]=useState(),[he,ye]=useState(false),[be,Be]=useState(false),[I,P$1]=useState({delete:{buttonAgree:"",buttonDisagree:"",dialogTitle:"",dialogContent:"",showDialog:false,callBackFunc:()=>{}}}),[M,O]=useState(true),[Z$1,Oe]=useState({}),ee=useRef(e$1),ve=useRef(e$1.context.formData);useEffect(()=>{ee.current=e$1;},[e$1]),useEffect(()=>{ve.current=e$1.context.formData;},[e$1.context.formData]);let[sa,an]=useState((bt=e$1.context)==null?void 0:bt.widgetRelatedData),ke=useCallback(async(a,t,i,d,o)=>{$(false),await l({pluginCode:t.context.params.pluginCode,formCode:t.context.params.formCode,guid:t.context.params.guid,projectGuid:t.context.params.pGuid,pGuid:t.context.params.pGuid,formData:t.context.formData,widgetContext:JSON.stringify({referer:d.pathname,parentWidgetId:o,hasParentForm:T.hasParentForm(),originator:{widgetName:t.properties.name.toLowerCase(),params:t.context.params},parent:{widgetName:t.properties.name.toLowerCase(),params:t.context.params},parentOriginator:{params:t.context.params.originator?t.context.params.originator.params:{}},folderData:t.context.params.folderData}),widgetEvent:U.onTableEditRunActionEvent,widgetName:t.properties.name.toLowerCase(),widgetValue:JSON.stringify({action:a,data:i})}).then(u=>{var w;if(u.meta.requestStatus==="fulfilled"){let y={...u.payload};y.FECommand={...y.FECommand,UpdateFieldAllowedValues:y.fieldAllowedValues,UpdateFormData:y.data,UpdateFormDataItem:{name:t.properties.name,value:(w=y.data)==null?void 0:w[t.properties.name]}},t.methodProvider.execCommands(y.FECommand);}});},[]),Ie=useCallback(async(a,t,i,d,o,u)=>{$(false),u.toggleAllRowsSelected(false),await l({pluginCode:t.context.params.pluginCode,formCode:t.context.params.formCode,guid:t.context.params.guid,projectGuid:t.context.params.pGuid,pGuid:t.context.params.pGuid,widgetContext:JSON.stringify({referer:d.pathname,parentWidgetId:o,hasParentForm:T.hasParentForm(),originator:{widgetName:t.properties.name.toLowerCase(),params:t.context.params},parent:{widgetName:t.properties.name.toLowerCase(),params:t.context.params},parentOriginator:{params:t.context.params.originator?t.context.params.originator.params:{}},folderData:t.context.params.folderData}),widgetEvent:U.onTableRunBatchActionEvent,widgetName:t.properties.name.toLowerCase(),widgetValue:JSON.stringify({action:a,data:i})}).then(w=>{if(w.meta.requestStatus==="fulfilled"){let y={...w.payload};y.widgetData&&m(Object.values(y.widgetData)),O(true),$(true),y.FECommand&&t.methodProvider.execCommands(y.FECommand);}});},[e$1.context.params.pluginCode,e$1.context.params.formCode,e$1.context.params.guid,e$1.context.params.pGuid,e$1.properties.name,e$1.context.formData]),on=useCallback((a,t,i,d,o,u)=>{a&&(i.properties.alloweditrow?ke("delete",i,JSON.stringify(d),o,u):et(t,i,d,o,u)),P$1({delete:{buttonAgree:"",buttonDisagree:"",dialogTitle:"",dialogContent:"",showDialog:false,callBackFunc:()=>{}}});},[e$1.properties.alloweditrow]),yt=useCallback((a,t,i,d,o,u,w)=>{a&&Ie(t,i,d,u,w,o),P$1({delete:{buttonAgree:"",buttonDisagree:"",dialogTitle:"",dialogContent:"",showDialog:false,callBackFunc:()=>{}}});},[Ie,P$1]),rn=a=>I.delete.callBackFunc(a),tt=a=>{P$1(a);},{alloweditrow:Ce,backendpagination:ne,colactions:ln,colgrouping:sn,colordering:cn,colresizing:dn,enableuploadfiles:mn,height:un,hideaddbutton:gn,newrecordurl:pt,folders:ze,pagination:fn,pagesize:Ue,rowactions:yn,rowactiontype:Ve,rowclickas:He,rowdensity:pn,rownumber:xn,rowselection:wn,rowvirtualization:hn,search:bn,searchtype:Ge,selectall:Cn,stickyheader:Dn,toolbarInternalActions:Rn,topToolbar:_n,visible:Fn}=e$1.properties,nt=fn===true,Tn=hn!==false&&!nt,In=nt,xt=Ve==="flat"||Ve==="menu"||Ve==="primary",wt=useNavigate(),F=useLocation(),{tabId:v}=e$1,{t:K,i18n:at}=useTranslation(),W$1=(Ct=at==null?void 0:at.language)==null?void 0:Ct.substring(0,2),ht=useCallback((a,t)=>{E.setLastEvaluatedKey(Number(a),t||null);},[E]),We=useCallback(a=>E.getLastEvaluatedKey(Number(a)),[E]),Le=useCallback(async(a,t,i,d,o)=>{var k,L;$(false),a&&(_$1(0),B(null),X$1(ct));let u=Qt(i.pageIndex,b$2,i.pageSize,R),w=We(i.pageIndex-1),y=u==="last"?"":d;he&&u!=="last"&&(u==="next"&&(y=We(i.pageIndex+1)),u==="previous"&&(w=We(i.pageIndex+1))),await l({DataTableMeta:{serverPaginationEnabled:ne,rowsPerPage:i.pageSize,pageIndex:i.pageIndex,nextToken:y,previousToken:w,paginationDirection:u==="last"?"last":t,rowCount:R,qId:o==null?void 0:o.qId,lastRequestLimit:o==null?void 0:o.lastRequestLimit,oppositeDirection:u==="last"||he},pluginCode:e$1.context.params.pluginCode,formCode:e$1.context.params.formCode,guid:e$1.context.params.guid,projectGuid:e$1.context.params.pGuid,pGuid:e$1.context.params.pGuid,widgetContext:JSON.stringify({referer:F.pathname,parentWidgetId:v,hasParentForm:T.hasParentForm(),originator:(k=e$1.context.params)==null?void 0:k.originator,parent:e$1.context.params,folderData:(L=e$1.context.params)==null?void 0:L.folderData}),widgetEvent:Ce?U.onTableEditDataLoad:U.onTableDataLoad,widgetName:e$1.properties.name.toLowerCase(),formData:e$1.context.formData}).then(ae=>{var ue,N,j,pe,S,qe,ge,xe,Ae;if(ae.meta.requestStatus==="fulfilled"){let z={...ae.payload},U=(ue=z.data)==null?void 0:ue[e$1.properties.name];if(Array.isArray(z.widgetData)&&z.widgetData.length===0&&typeof U=="string"&&U.trim()!==""&&U!=="null"&&U!=="undefined"){let f=JSON.parse(U);m(f!=null?f:{});}else m(Object.values((N=z.widgetData)!=null?N:{})),_$1((pe=(j=z.tableMeta)==null?void 0:j.rowCount)!=null?pe:0),B((qe=(S=z.tableMeta)==null?void 0:S.nextToken)!=null?qe:null),X$1((ge=z.tableMeta)!=null?ge:{}),(xe=z.tableMeta)!=null&&xe.nextToken&&ht(i.pageIndex,(Ae=z.tableMeta)==null?void 0:Ae.nextToken),Be(false),z.widgetRelatedData&&Object.keys(z.widgetRelatedData).length>0&&(ee.current.context.widgetRelatedData=z.widgetRelatedData);O(a),$(true);}});},[ne,Ce,We,he,F.pathname,b$2,e$1.context.formData,e$1.context.params,e$1.properties.name,R,O,$,B,Be,_$1,m,X$1,ht,v]),Mn=useCallback(a=>{if(r$1.current&&!ne){r$1.current=false;return}let t;typeof a=="function"?t=a({pageIndex:b$2,pageSize:ie}):t=a;let i=Qt(t.pageIndex,b$2,t.pageSize,R);if(te&&M&&b$2>0){O(false);return}t.pageIndex!==b$2&&E.setPageIndex(Number(t.pageIndex)),t.pageSize!==ie&&E.setPageSize(Number(t.pageSize)),(ne&&t.pageIndex!==b$2||t.pageSize!==ie)&&(Be(true),i==="last"&&ye(true),i==="first"&&ye(false),Le(false,i,t,x,T$1));},[ne,b$2,R,te,M,ie,Le,x,T$1]);useEffect(()=>{var a;an((a=e$1.context)==null?void 0:a.widgetRelatedData);},[(Dt=e$1.context)==null?void 0:Dt.widgetRelatedData]),useEffect(()=>{r$1.current=true,E.reset(Number(Ue));},[e$1.properties.name,e$1.context.params]),useEffect(()=>{var a;if(Ce){let t=(a=e$1.context.formData)==null?void 0:a[e$1.properties.name];if(t){let i=typeof t=="string"?JSON.parse(t):t;m(i);}}},[e$1.context.formData]),useEffect(()=>{(async()=>{var a,t,i,d;if(e$1.context.enableEventHandlers){if(e$1.context.formLayout==="folders"&&!((t=(a=e$1.context.params)==null?void 0:a.folderData)!=null&&t.id)&&!((d=(i=e$1.context.params)==null?void 0:i.folderData)!=null&&d.isRoot))return;ne?b$2===0?Le(true,"first",{pageIndex:0,pageSize:Ue||100},"",ct):Le(false,"current",{pageIndex:b$2,pageSize:ie},x,T$1):Le(true,"first",{pageIndex:0,pageSize:Ue||100},"",ct);}else $(true);})();},[e$1.properties.name,e$1.context.redrawComponent,Ce,ne]);let je=e$1.methodProvider.findWidgetItem(e$1.id),Ne=[],Ye={};(je.item.properties.datasource.columns||[]).forEach(a=>{var t;Ne[a[1]]=a[0],a[2]&&(Ye[a[1]]=(t=ra[a[2]])!=null?t:"freetext");});let Sn=(je.item._children||[]).some(({properties:a})=>{var i,d;if(!a.item_bottomcalc)return false;let t=(d=(i=Ye[a.item_name])!=null?i:a.item_columntype)!=null?d:a.item_isprice?"price":"freetext";return t==="price"||t==="number"}),Pn=useMemo(()=>{let a$1=[];return (je.item._children||[]).map(({properties:t})=>{var i,d,o,u,w,y,k$1,L,ae,ue,N,j,pe;if(t.item_name.toString()!==""){let S=(i=Ye[t.item_name])!=null?i:"";S||(S=(d=t.item_columntype)!=null?d:"freetext",t.item_columntype||(t.item_isdate===true?S="date":t.item_isdatetime===true?S="datetime":t.item_ischeckbox===true?S="checkbox":t.item_isprice===true?S="price":S="freetext"));let qe=S==="checkbox",ge=S==="price",xe=S==="number",Ae=S==="date",z=S==="datetime",U={};qe?U={accessorKey:t.item_name,muiTableHeadCellProps:{align:(o=t.style.item_textalign)!=null?o:"left"},muiTableBodyCellProps:{align:(u=t.style.item_ctextalign)!=null?u:"left"},header:(w=Ne[t.item_name])!=null?w:t.item_title,Header:()=>{var s;let f=(s=Ne[t.item_name])!=null?s:t.item_title;return t.item_displaytooltip?jsx(re,{title:f,arrow:true,children:jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"block"},children:f})}):jsx("span",{children:f})},Cell:({row:f})=>{var s;return jsx("span",{style:{borderBottom:"none",padding:"0px",height:"36px"},children:jsx($n,{checked:Array.isArray((s=ee.current.context)==null?void 0:s.widgetRelatedData)&&ee.current.context.widgetRelatedData.includes(f.original._sk),onPointerUp:()=>oa(f.original,ee.current,F,v),style:{margin:0}})})},size:parseInt(t.item_minsize,10)||void 0,enableSorting:(y=t.item_enablesorting)!=null?y:false,enableHiding:(k$1=t.item_visible)!=null?k$1:true,grow:true}:(U={accessorKey:t.item_name.toString(),muiTableHeadCellProps:{align:(L=t.style.item_textalign)!=null?L:"left"},muiTableBodyCellProps:{align:(ae=t.style.item_ctextalign)!=null?ae:"left"},header:(ue=Ne[t.item_name])!=null?ue:t.item_title.toString(),Header:()=>{var s;let f=(s=Ne[t.item_name])!=null?s:t.item_title.toString();return t.item_displaytooltip?jsx(re,{title:f,arrow:true,children:jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"block"},children:f})}):jsx("span",{children:f})},size:parseInt(t.item_minsize,10)||void 0,enableSorting:(N=t.item_enablesorting)!=null?N:false,enableHiding:t.item_visible===true,grow:true,muiEditTextFieldProps:{required:true,error:!!(Z$1!=null&&Z$1.firstName),helperText:Z$1==null?void 0:Z$1.firstName,onFocus:()=>Oe({...Z$1,[t.item_name.toString()]:void 0})},Cell:({cell:f})=>{var A;let s=(A=f.getValue())!=null?A:"";if(ge&&s){let p=st(s);if(!isNaN(p)){let h=t.item_fixedlocale||"",Y=t.item_format==="fixed-locale"&&h?h:W$1||void 0,D=t.item_inputfield&&ve.current&&ve.current[t.item_inputfield]||""||t.item_currency||"",De=t.item_format==="locale"?k(W$1!=null?W$1:""):t.item_format==="fixed-locale"&&h?k(h):void 0,Re=D||De||"";try{let we=t.item_currencydisplay||"";Re&&we!==""?s=new Intl.NumberFormat(Y,{style:"currency",currency:Re,currencyDisplay:we,minimumFractionDigits:2,maximumFractionDigits:2}).format(p):s=new Intl.NumberFormat(Y,{style:"decimal",minimumFractionDigits:2,maximumFractionDigits:2}).format(p);}catch(we){s=p.toFixed(2);}}}if(xe&&s){let p=st(s);isNaN(p)||(s=p.toLocaleString());}if(Ae&&s){let p=(()=>{if(/^\d{4}-\d{2}-\d{2}/.test(s)){let h=a(s);if(h.isValid())return h}return a(s,"DD.MM.YYYY",true)})();if(p.isValid())try{s=new Intl.DateTimeFormat(W$1||void 0,{dateStyle:"short"}).format(p.toDate());}catch(h){}}if(z&&s){let p=(()=>{if(/^\d{4}-\d{2}-\d{2}/.test(s)){let h=a(s);if(h.isValid())return h}return a(s,"DD.MM.YYYY HH:mm",true)})();if(p.isValid())try{s=new Intl.DateTimeFormat(W$1||void 0,{dateStyle:"short",timeStyle:"short"}).format(p.toDate());}catch(h){}}return t.item_displaytooltip?jsx(ia,{value:s,style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:`${parseInt(t.item_maxsize,10)||150}px`,minWidth:"50px",cursor:"default"}}):jsx(Fragment,{children:s})}},t.item_bottomcalc&&(ge||xe)&&(U.muiTableFooterCellProps={align:(pe=(j=t.style)==null?void 0:j.item_ctextalign)!=null?pe:"left"},U.Footer=({table:f})=>{var Y,C;let s=(Y=f.getState().creatingRow)==null?void 0:Y.id,A=(C=f.getState().editingRow)==null?void 0:C.id,p=f.getFilteredRowModel().rows.reduce((D,De)=>{if(De.id===s||De.id===A)return D;let Re=De.getValue(t.item_name.toString()),we=st(String(Re!=null?Re:""));return D+(isNaN(we)?0:we)},0),h=p.toLocaleString(W$1||void 0,{minimumFractionDigits:ge||xe?2:0,maximumFractionDigits:ge||xe?2:0});if(ge){let D=t.item_fixedlocale||"",De=t.item_format==="fixed-locale"&&D?D:W$1||void 0,we=t.item_inputfield&&ve.current&&ve.current[t.item_inputfield]||""||t.item_currency||"",Hn=t.item_format==="locale"?k(W$1!=null?W$1:""):t.item_format==="fixed-locale"&&D?k(D):void 0,Rt=we||Hn||"",_t=t.item_currencydisplay||"";if(Rt&&_t!=="")try{h=new Intl.NumberFormat(De,{style:"currency",currency:Rt,currencyDisplay:_t,minimumFractionDigits:2,maximumFractionDigits:2}).format(p);}catch(ma){h=p.toFixed(2);}}return jsx("b",{children:h})})),Ae?U.sortingFn=(f,s,A)=>{let p=f.getValue(A),h=s.getValue(A),Y=C=>{if(!C)return a("1900-01-01");if(/^\d{4}-\d{2}-\d{2}/.test(C)){let D=a(C);if(D.isValid())return D}return a(C,"DD.MM.YYYY",true)};try{let C=Y(p),D=Y(h);return C.isBefore(D)?-1:C.isAfter(D)?1:0}catch(C){return 0}}:z?U.sortingFn=(f,s,A)=>{let p=f.getValue(A),h=s.getValue(A),Y=C=>{if(!C)return a("1900-01-01T00:00:00");if(/^\d{4}-\d{2}-\d{2}/.test(C)){let D=a(C);if(D.isValid())return D}return a(C,"DD.MM.YYYY HH:mm",true)};try{let C=Y(p),D=Y(h);return C.isBefore(D)?-1:C.isAfter(D)?1:0}catch(C){return 0}}:(ge||xe)&&(U.sortingFn=(f,s,A)=>{let p=parseFloat(f.getValue(A))||0,h=parseFloat(s.getValue(A))||0;return p-h}),He&&He!=="none"&&(U.Cell=({row:f})=>jsx("div",{style:{cursor:"pointer",width:"100%",padding:"0.7em"},onPointerUp:()=>{var A,p,h,Y,C,D;let s={pluginCode:f.original._plugincode,formCode:f.original._origformcode,guid:null,originator:(A=ee.current.context.params)==null?void 0:A.originator,pGuid:(p=ee.current.context.params)==null?void 0:p.pGuid,folderData:ee.current.context.params.folderData};He==="new"&&(Y=(h=ee.current.context)==null?void 0:h.params)!=null&&Y.modalCloseFn&&((D=(C=ee.current.context)==null?void 0:C.params)==null||D.modalCloseAndOpenFn(s));},children:f.getValue(t.item_name.toString())})),a$1.push(U);}}),a$1},[W$1,Z$1,He,v]),vn=a=>{ce(a.currentTarget);},kn=()=>{ce(null);},Ln=useCallback(()=>{var t,i;if(!ze)return null;var a=(i=(t=e$1.context.params)==null?void 0:t.folderData)==null?void 0:i.captions;return a==null||a.length===0?null:(a=a.slice(1),jsx("span",{style:{display:"flex",alignItems:"center"},children:a.map((d,o)=>jsxs("span",{style:{display:"inline-flex",alignItems:"center"},children:[d,o<a.length-1&&jsx(d$1,{style:{margin:"0 8px",fontSize:"0.6rem",color:"#666"}},`chevron-${o}`)]},`caption-${o}`))}))},[ze,e$1.context.params.folderData]),Nn={density:pn,expanded:true,grouping:[],isFullScreen:false,pagination:{pageIndex:b$2||0,pageSize:Number(ie)||Ue},columnVisibility:{id:false}},An=useCallback((a,t)=>{var i=[];a.forEach(d=>{var u,w,y,k,L,ae;let o=d.original;i.push({_sk:(u=o._sk)!=null?u:null,_code:(w=o._fcode)!=null?w:o._code,_origformcode:(k=(y=o._origformcode)!=null?y:o._fcode)!=null?k:o._code,_plugincode:(L=o._plcode)!=null?L:o._plugincode,_desc:(ae=o._desc)!=null?ae:null});}),i.length>0&&Ie("createsigncontainer",e$1,i,F,v,t);},[Ie,e$1,F,v]),En=useCallback((a,t)=>{var i=[];a.forEach(d=>{var u,w,y,k,L;let o=d.original;i.push({_sk:(u=o._sk)!=null?u:null,_code:(w=o._fcode)!=null?w:o._code,_origformcode:(k=(y=o._origformcode)!=null?y:o._fcode)!=null?k:o._code,_plugincode:(L=o._plcode)!=null?L:o._plugincode});}),i.length>0&&Ie("download",e$1,i,F,v,t);},[Ie,e$1,F,v]),Bn=useCallback((a,t)=>{var i=[];a.forEach(d=>{var u,w,y,k,L;let o=d.original;i.push({_sk:(u=o._sk)!=null?u:null,_code:(w=o._fcode)!=null?w:o._code,_origformcode:(k=(y=o._origformcode)!=null?y:o._fcode)!=null?k:o._code,_plugincode:(L=o._plcode)!=null?L:o._plugincode});}),tt({delete:{showDialog:true,dialogTitle:K("Delete")+" ?",dialogContent:K("Are you certain that you wish to delete selected records?"),buttonAgree:K("Continue"),buttonDisagree:K("Close"),callBackFunc:d=>yt(d,"delete",e$1,i,t,F,v)}});},[tt,yt,K,e$1,F,v]),On=useCallback(async({values:a,table:t})=>{ke("add",e$1,JSON.stringify(a),F,v),t.setCreatingRow(null);},[ke,e$1,F,v]),zn=useCallback(async({values:a,table:t,row:i})=>{let d={...i.original,...a};ke("edit",e$1,JSON.stringify(d),F,v),t.setEditingRow(null);},[ke,e$1,F,v]),[ca,Un]=useState(null);if(!Fn)return null;let Je=Se("file",e$1.context)?"primary":"#C0C0C0",Vn=Se("file",e$1.context)?"contained":"outlined";return jsxs(Fragment,{children:[ze&&jsx("div",{style:{paddingBottom:"0.8rem",fontSize:"0.85rem",color:"#666",marginLeft:"0.2rem"},children:Ln()}),jsx("div",{style:{maxWidth:e$1.context.isModal?g$1.width-30:void 0},children:jsx(Suspense,{fallback:jsx(qn,{}),children:jsx(ta,{locale:W$1,columns:Pn,enableBottomToolbar:In,enableTableFooter:Sn,createDisplayMode:"row",editDisplayMode:"row",enableEditing:false,enableColumnActions:ln,enableColumnOrdering:cn,enableColumnResizing:dn,enableGlobalFilter:bn,enableGlobalFilterModes:true,globalFilterModeOptions:[Ge||"startsWith"],globalFilterFn:Ge||"startsWith",enableGrouping:sn,enablePagination:nt,manualPagination:ne!=null?ne:false,enableRowActions:xt,enableRowNumbers:xn,enableRowSelection:wn,enableRowVirtualization:Tn,enableSelectAll:Cn,enableStickyHeader:Dn,enableToolbarInternalActions:Rn,enableTopToolbar:_n,onCreatingRowSave:On,onEditingRowSave:zn,darkMode:false,data:me,icons:{SaveIcon:()=>jsx(r,{color:na,style:{fontSize:"1.2rem"}}),CancelIcon:()=>jsx(P,{color:"gray",style:{fontSize:"1.2rem"}})},initialState:Nn,isLoading:!te,muiTableContainerProps:{sx:{maxHeight:un}},name:e$1.properties.name,pageIndex:b$2,pageSize:ie,muiPaginationProps:{rowsPerPageOptions:[50,100,300,500],disabled:be},onPaginationChange:Mn,positionActionsColumn:"last",displayColumnDefOptions:{"mrt-row-actions":xt?{header:"",minSize:g$1.isMobileDevice?75:270,enableHiding:false}:void 0},rowOnDoubleClick:a=>{!Ce&&!gt(e$1.properties)&&et("edit",e$1,a,F,v);},rowCount:ne?R:void 0,renderToolbarInternalActions:({table:a})=>jsx(Xt,{children:!g$1.isMobileDevice&&jsxs(Fragment,{children:[!Ce&&jsx(_,{table:a}),jsx(Y,{table:a}),jsx(W,{table:a}),jsx(X,{table:a}),!e$1.context.isModal&&jsx(Z,{table:a})]})}),renderTopToolbarCustomActions:({table:a})=>{var t$1,i,d,o,u,w,y,k,L,ae;return jsxs("div",{style:{display:"flex",flexDirection:"row"},children:[a.getSelectedRowModel().rows.length===0&&ze&&e$1.context.formLayout==="folders"&&jsx(Fragment,{children:jsx(re,{title:(i=(t$1=e$1.properties)==null?void 0:t$1.newFolderLabel)!=null?i:K("New Folder"),children:jsx(Fe,{style:{marginRight:"5px"},color:"primary",onPointerUp:()=>e$1.context.isModal||e$1.context.hasParentForm?e$1.methodProvider.eventDispatcher({widgetName:e$1.properties.name.toLowerCase(),widgetValue:null,widgetEvent:U.onFolderCreateRecordEvent,widgetContext:JSON.stringify({referer:F.pathname,parentWidgetId:v,hasParentForm:T.hasParentForm(),parentOriginator:{params:e$1.context.params.originator?e$1.context.params.originator.params:{}},originator:{params:e$1.context.params,widgetName:e$1.properties.name.toLowerCase()},parent:{widgetName:e$1.properties.name.toLowerCase(),params:e$1.context.params},isModal:e$1.context.isModal,folderData:e$1.context.params.folderData})}):wt(`${F.pathname}/new`,{state:{from:F.pathname}}),variant:"outlined",children:jsx(t,{})})})}),a.getSelectedRowModel().rows.length===0&&!gn&&jsx(Fragment,{children:jsx(re,{title:(o=(d=e$1.properties)==null?void 0:d.addrecordlabel)!=null?o:K("Add Record"),children:jsx(Fe,{disabled:gt(e$1.properties),color:"primary",sx:{color:Je,borderColor:Je},style:{marginRight:"5px"},onPointerUp:()=>{if(!Se("file",e$1.context)){le({toastID:nanoid(11),msg:K("Please select a folder before adding a document"),clearQueue:false,hideProgressBar:false});return}if(Ce){let ue={};(je.item._children||[]).forEach(({properties:N})=>{var pe,S;if(!N.item_increment||!N.item_name)return;let j=(pe=Ye[N.item_name])!=null?pe:"";j||(j=(S=N.item_columntype)!=null?S:"freetext",N.item_columntype||(N.item_isdate?j="date":N.item_isdatetime?j="datetime":N.item_ischeckbox?j="checkbox":N.item_isprice?j="price":j="freetext")),j==="number"&&(ue[N.item_name.toString()]=me.length+1);}),Object.keys(ue).length>0?a.setCreatingRow(V(a,ue)):a.setCreatingRow(true);}else return pt?wt(`${F.pathname}/${pt}`,{state:{from:F.pathname}}):e$1.methodProvider.eventDispatcher({widgetName:e$1.properties.name.toLowerCase(),widgetValue:null,widgetEvent:U.onTableCreateRecordEvent,widgetContext:JSON.stringify({referer:F.pathname,parentWidgetId:v,hasParentForm:true,parentOriginator:{params:e$1.context.params.originator?e$1.context.params.originator.params:{}},originator:{params:e$1.context.params,widgetName:e$1.properties.name.toLowerCase()},parent:{widgetName:e$1.properties.name.toLowerCase(),params:e$1.context.params},isModal:e$1.context.isModal,folderData:e$1.context.params.folderData})})},variant:"outlined",children:jsx(p,{})})})}),a.getSelectedRowModel().rows.length===0&&mn&&jsx(Fragment,{children:jsx(re,{title:(w=(u=e$1.properties)==null?void 0:u.uploadFilesLabel)!=null?w:K("Upload Files"),children:jsx(Fe,{color:"primary",onPointerUp:vn,variant:"outlined",children:jsx(h,{})})})}),a.getSelectedRowModel().rows.length>0&&jsxs(Fragment,{children:[e$1.context.formLayout==="folders"&&a.getSelectedRowModel().rows.length>1&&jsx(Fragment,{children:jsx(re,{title:K("Create Container"),children:jsx(Fe,{style:{marginRight:"5px",color:Je,borderColor:Je},onPointerUp:()=>{if(!Se("file",e$1.context)){le({toastID:nanoid(11),msg:K("Please select a folder before creating a container"),clearQueue:false,hideProgressBar:false});return}An(a.getSelectedRowModel().rows,a);},variant:Vn,children:jsx(q,{})})})}),jsxs(Fragment,{children:[jsx(re,{title:(k=(y=e$1.properties)==null?void 0:y.downloadLabel)!=null?k:K("Download"),children:jsx(Fe,{style:{marginRight:"5px"},onPointerUp:()=>En(a.getSelectedRowModel().rows,a),variant:"contained",children:jsx(g,{})})}),jsx(re,{title:(ae=(L=e$1.properties)==null?void 0:L.deleteLabel)!=null?ae:K("Delete"),children:jsx(Fe,{style:{marginRight:"5px"},onPointerUp:()=>Bn(a.getSelectedRowModel().rows,a),variant:"contained",children:jsx(N,{})})})]})]}),jsx(aa,{anchorEl:q$1,handleClose:kn,setUploadMode:de,uploadMode:Te,props:e$1,setLoaded:$})]})},...la(e$1,yn,Ve,g$1.isMobileDevice,tt,on)},W$1)})}),jsx(G,{...I.delete,handleDialogClose:rn})]})})),Pe=c=>{let e=null,r=c.action,l$1=c.applyInternalStyle?{fontSize:"1em",marginRight:"0.5em"}:{};return r==="open"?e=jsx(n,{style:l$1}):r==="copy"?e=jsx(i,{style:l$1}):r==="confirm"?e=jsx(w,{style:{...l$1,fontSize:"1.6em"}}):r==="edit"?e=jsx(A,{style:l$1}):r==="editrow"?e=jsx(n,{style:l$1}):r==="amend"?e=jsx(b$2,{style:l$1}):r==="delete"?e=jsx(N,{style:l$1}):r==="lock"?e=jsx(y,{style:l$1}):r==="unlock"?e=jsx(x,{style:l$1}):r==="print"?e=jsx(C,{style:l$1}):r==="preview"?e=jsx(n,{style:l$1}):r==="sign"?e=jsx(q,{style:l$1}):r==="download"?e=jsx(l,{style:l$1}):r==="uploadfile"?e=jsx(O,{style:l$1}):r==="uploadzipfile"&&(e=jsx(o,{style:l$1})),e},la=(c,e,r,l,g,le)=>{var de,me;let G=typeof e=="string"?JSON.parse(e):e!=null?e:[],se=useLocation(),{t:E}=useTranslation(),{tabId:b}=c,ie=(me=(de=c.properties)==null?void 0:de.rowactionlabels)!=null?me:{},q=(m,R)=>ie[m]||E(R),ce={color:"text.secondary","&:hover":{color:"primary.main"},"&:focus":{color:"primary.main"},fontSize:"1.1em",marginRight:"0.5em"},te=(m,R,_)=>m==="delete"?()=>{g({delete:{showDialog:true,dialogTitle:`${q("delete","Delete")} ?`,dialogContent:q("deleteConfirmContent","Are you certain that you wish to delete this record?"),buttonAgree:q("deleteConfirmAgree","Continue"),buttonDisagree:q("deleteConfirmDisagree","Close"),callBackFunc:x=>le(x,"delete",c,_,se,b)}});}:m==="editrow"?()=>{R.closeMenu(),R.table.setEditingRow(R.row);}:()=>{var x;(x=R.closeMenu)==null||x.call(R),et(m,c,_,se,b);},$=({entryType:m,mode:R})=>{let _=m.row.original,[x,B]=dt.useState(null),T=I=>{B(I.currentTarget);},X=()=>{B(null);},he=()=>jsx(Fragment,{children:Object.entries(G).map(([I,P])=>{if(!P)return null;let M=I.replace("action_",""),O=te(M,m,_);return jsx("span",{children:jsx(re,{title:q(M,M.charAt(0).toUpperCase()+M.slice(1)),children:jsx(Kt,{sx:ce,onPointerUp:O,children:jsx(Pe,{action:M})})})},I)})}),ye={};if(_._primAct){let I=_._primAct;if(Object.values(tn).includes(I)){Object.values(ut).includes(I)&&(ye.edit=true,G.action_edit&&delete G.action_edit);let P="action_"+I.toLowerCase();ye[P]=true,G[P]&&delete G[P];}}return jsxs(Xt,{sx:{display:"flex",flexWrap:"nowrap",gap:"8px",justifyContent:"center",alignItems:"center"},children:[R===0&&jsx(he,{}),R===1&&jsxs(Fragment,{children:[jsx(()=>jsx(Fragment,{children:Object.entries(ye).map(([I,P])=>{if(!P)return null;let M=I.replace("action_",""),O=te(M,m,_),Z=Object.values(ut).includes(M.toUpperCase()),Oe=M.charAt(0).toUpperCase()+M.slice(1),ee=Oe==="Edit"?q("open","Open"):q(M,Oe);return jsx(Fe,{onClick:O,startIcon:jsx(Pe,{action:M==="edit"?"open":M}),variant:"contained",size:"small",sx:{textTransform:"none",fontSize:"0.75rem",height:"28px",borderRadius:"4px",boxShadow:"none",backgroundColor:Z?"actionbtnok.main":"regularbtn.main",color:"#fff","&:hover":{backgroundColor:Z?"actionbtnok.hover":"regularbtn.hover",boxShadow:"none"},minInlineSize:"7.5em"},children:ee},I)})}),{}),jsx(()=>{let I=x?x.getBoundingClientRect():null;return jsxs("span",{style:{paddingLeft:"1.5em"},children:[jsx(Kt,{sx:ce,onClick:T,id:"dropdown-button",children:jsx(ea,{})}),jsx(en,{anchorEl:x,open:!!x,onClose:X,PaperProps:{sx:{borderRadius:2,minWidth:180,py:1,boxShadow:3,top:I?`${I.top+5}px !important`:"auto",left:I?`${I.left+15}px !important`:"auto",zIndex:P=>P.zIndex.modal+1}},children:Object.entries(G).map(([P,M])=>{if(!M)return null;let O=P.replace("action_","");return jsxs(Ze,{onClick:()=>{X(),te(O,m,_)();},sx:{px:2,py:1},children:[jsx(Qe,{sx:{minWidth:"unset",mr:1},children:jsx(Pe,{action:O==="print"?"preview":O,applyInternalStyle:true})}),jsx(Xe,{primaryTypographyProps:{fontSize:"0.875rem"},children:q(O,O.charAt(0).toUpperCase()+O.slice(1))})]},P)})})]})},{})]})]})},Te=m=>{let R=m.row.original;return [jsx(Kn,{onClickAway:()=>{var _;return (_=m.closeMenu)==null?void 0:_.call(m)},children:jsx(Qn,{sx:{minWidth:"12em",py:0,background:"none"},children:Object.entries(G).map(([_,x])=>{if(!x)return null;let B=_.replace("action_",""),T=te(B,m,R);return jsxs(Ze,{disabled:gt(c.properties),onPointerUp:T,children:[jsx(Qe,{children:jsx(Pe,{action:B==="print"?"preview":B,applyInternalStyle:true})}),jsx(Xe,{primaryTypographyProps:{fontSize:"0.875rem"},children:q(B,B.charAt(0).toUpperCase()+B.slice(1))})]},_)})})},"row-action-menu")]};return r==="flat"&&!l?{renderRowActions:m=>jsx($,{entryType:m,mode:0})}:r==="menu"||r!=="none"&&l?{renderRowActionMenuItems:m=>Te(m)}:r==="primary"?{renderRowActions:m=>jsx($,{entryType:m,mode:1})}:{}};nn.displayName="_Datatable";var Ya=nn;export{Ya as Datatable};