@buildocsdev/sdk 1.1.65 → 1.1.67

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buildocsdev/sdk",
3
- "version": "1.1.65",
3
+ "version": "1.1.67",
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-7V25SP3L.js';import {b as b$1}from'./chunk-VUS3THHW.js';import {c}from'./chunk-AY7MKCIL.js';import {U,T,j}from'./chunk-C3S4PZ7O.js';import'./chunk-U4T4ACDE.js';import {b}from'./chunk-LBMVBVXW.js';import {d as d$1,t,p,V,h,q,g,N,P,Y,W,X,Z,r,n,i,w,A,b as b$2,y,x,C,l,O,o}from'./chunk-XX7GDJZT.js';import'./chunk-EX7TRSJS.js';import ut,{lazy,memo,useRef,useState,useEffect,useCallback,useMemo,Suspense}from'react';import {withTranslation,useTranslation}from'react-i18next';import $n from'@mui/material/CircularProgress';import en from'@mui/material/Box';import Fe from'@mui/material/Button';import Kn from'@mui/material/Checkbox';import Qn from'@mui/material/ClickAwayListener';import Qe from'@mui/material/IconButton';import Xe from'@mui/material/ListItemIcon';import Ze from'@mui/material/ListItemText';import et from'@mui/material/MenuItem';import Xn from'@mui/material/MenuList';import le from'@mui/material/Tooltip';import Zn from'@mui/icons-material/Search';import ea from'@mui/icons-material/SearchOff';import ta from'@mui/material/InputBase';import {nanoid}from'@reduxjs/toolkit';import {useNavigate,useLocation}from'react-router-dom';import nn from'@mui/material/Menu';import aa from'axios';import oa from'@mui/icons-material/MoreVert';import {jsx,Fragment,jsxs}from'react/jsx-runtime';var ia=lazy(()=>import('./buildocslib.esm-KHP2KSIY.js').then(d=>({default:d.DatatableImb}))),ra="#1976d2";var gt=(r=>(r[r.SIGN=0]="SIGN",r[r.CONFIRM=1]="CONFIRM",r))(gt||{}),an=(l=>(l[l.SIGN=0]="SIGN",l[l.CONFIRM=1]="CONFIRM",l[l.EDIT=2]="EDIT",l))(an||{}),tt=(d,e,r,l,g)=>{var de,G,me,O,C;return e.methodProvider.eventDispatcher({skipFormDataItem:true,widgetName:e.properties.name.toLowerCase(),widgetValue:JSON.stringify({action:d,rowData:{_id:(de=r._id)!=null?de:null,_sk:(G=r._sk)!=null?G:null,_code:(me=r._fcode)!=null?me:r._code,_origformcode:(O=r._origformcode)!=null?O:null,_plugincode:(C=r._plcode)!=null?C: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})})},Ie=(d,e)=>{var r,l;return !(d==="file"&&e.formLayout==="folders"&&((r=e.params.folderData)!=null&&r.isRoot||((l=e.params.folderData)==null?void 0:l.id)===null))},la=({anchorEl:d,handleClose:e,setUploadMode:r,uploadMode:l,props:g,setLoaded:de})=>{let{runFormUploadFiles:G}=b(),me=c(),O=!!d,C=useRef(null),[se,K]=useState([]),{t:ue}=useTranslation(),oe=(fe="file")=>{if(!Ie(fe,g.context)){me({toastID:nanoid(11),msg:ue("Please select a folder before uploading a file"),clearQueue:false,hideProgressBar:false});return}C.current&&C.current.click(),r(fe),e();},Q=async fe=>{var u,R;let ge=fe.target.files;if(ge){de(false);let F=Array.from(ge).map(S=>({...S,uploadProgress:0})),w=new FormData;if(g.context.params)for(let S in g.context.params)g.context.params.hasOwnProperty(S)&&w.append(S,g.context.params[S]);w.append("fieldName",g.properties.name),Array.from(ge).forEach(S=>{w.append("files",S);}),w.append("widgetContext",JSON.stringify({hasParentForm:T.hasParentForm(),originator:(u=g.context.params)==null?void 0:u.originator,folderData:(R=g.context.params)==null?void 0:R.folderData})),w.append("widgetEvent",U.onFileUploadCreateDocumentEvent),w.append("widgetName","attached_files"),w.append("formData",JSON.stringify({...g.context.formData})),w.append("uploadMode",l);let Y=aa.CancelToken.source();try{let S=await G({content:w,cancelTokenSource:Y,onUploadProgress:Z=>{let he=Math.round(Z.loaded/F.length),xe=F.map(be=>({...be,uploadProgress:Z.loaded===Z.total?100:Math.round(he*100/be.size)}));K(be=>be.concat(xe));}});if(S.meta.requestStatus==="fulfilled"){let Z={...S.payload};g.methodProvider.execCommands(Z.FECommand);}}catch(S){}C.current&&(C.current.value="");}},Te=Ie("file",g.context)?"inherit":"#C0C0C0";return jsxs(Fragment,{children:[jsx("input",{type:"file",name:"files",ref:C,style:{display:"none"},onChange:Q,multiple:true}),jsxs(nn,{anchorEl:d,open:O,onClose:e,MenuListProps:{"aria-labelledby":"upload-button"},children:[jsxs(et,{onPointerUp:()=>oe("file"),children:[jsx(Xe,{sx:{color:Te},children:jsx(Pe,{action:"uploadfile",applyInternalStyle:true})}),jsx(Ze,{primary:ue("Upload File(s)"),primaryTypographyProps:{fontSize:"0.875rem",color:Te}})]},"Upload File(s)"),jsxs(et,{onPointerUp:()=>oe("container"),children:[jsx(Xe,{children:jsx(Pe,{action:"uploadzipfile",applyInternalStyle:true})}),jsx(Ze,{primary:ue("Upload .ZIP Archive"),primaryTypographyProps:{fontSize:"0.875rem"}})]},"Upload .ZIP Archive")]})]})},sa=(d,e,r,l)=>(d._plugincode=e.context.params.pluginCode,d._origformcode=d._code=e.context.params.formCode,tt("onrowcheckboxclicked",e,d,r,l)),ca=({value:d,style:e})=>{let[r,l]=ut.useState(false),g=ut.useRef(null);return jsx(le,{title:String(d!=null?d:"").trim()?d:"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:d||""})})},pt=d=>!!(d.readonly&&!d.ignorereadonly),dt=d=>{let e=d.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)},Zt=(d,e,r,l)=>d===0?"first":d<e?"previous":l>0&&(d+1)*r>=l?"last":"next",mt={rowsPerPage:0,pageIndex:0,serverPaginationEnabled:false,nextToken:"",paginationDirection:"first",previousToken:"",rowCount:0,qId:""},da={string:"freetext",freetext:"freetext",currency:"price",price:"price",date:"date",datetime:"datetime",number:"number",checkbox:"checkbox"},on=withTranslation()(memo(function(e){var Ft,Tt,Mt;let r$1=useRef(false),{runFormEvent:l,viewPort:g$1}=b(),de=c(),{UserDialog:G}=b$1(),me=e.properties.name,O=d(me,e.properties.pagesize||50),{pageIndex:C,pageSize:se}=O,[K,ue]=useState(null),[oe,Q]=useState(false),[Te,fe]=useState("single"),[ge,u]=useState([]),[R,F]=useState(0),[w,Y$1]=useState(),[S,Z$1]=useState(),[he,xe]=useState(false),[be,Be]=useState(false),[I,v]=useState({delete:{buttonAgree:"",buttonDisagree:"",dialogTitle:"",dialogContent:"",showDialog:false,callBackFunc:()=>{}}}),[P$1,U$1]=useState(true),[ee,Oe]=useState({}),[Ce,xt]=useState(false),[wt,Ye]=useState(""),ce=useRef(e),ve=useRef(e.context.formData);useEffect(()=>{ce.current=e;},[e]),useEffect(()=>{ve.current=e.context.formData;},[e.context.formData]);let[ua,rn]=useState((Ft=e.context)==null?void 0:Ft.widgetRelatedData),ke=useCallback(async(a,t,i,m,o)=>{Q(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:m.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(f=>{var h;if(f.meta.requestStatus==="fulfilled"){let p={...f.payload};p.FECommand={...p.FECommand,UpdateFieldAllowedValues:p.fieldAllowedValues,UpdateFormData:p.data,UpdateFormDataItem:{name:t.properties.name,value:(h=p.data)==null?void 0:h[t.properties.name]}},t.methodProvider.execCommands(p.FECommand);}});},[]),Me=useCallback(async(a,t,i,m,o,f)=>{Q(false),f.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:m.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(h=>{if(h.meta.requestStatus==="fulfilled"){let p={...h.payload};p.widgetData&&u(Object.values(p.widgetData)),U$1(true),Q(true),p.FECommand&&t.methodProvider.execCommands(p.FECommand);}});},[e.context.params.pluginCode,e.context.params.formCode,e.context.params.guid,e.context.params.pGuid,e.properties.name,e.context.formData]),ln=useCallback((a,t,i,m,o,f)=>{a&&(i.properties.alloweditrow?ke("delete",i,JSON.stringify(m),o,f):tt(t,i,m,o,f)),v({delete:{buttonAgree:"",buttonDisagree:"",dialogTitle:"",dialogContent:"",showDialog:false,callBackFunc:()=>{}}});},[e.properties.alloweditrow]),ht=useCallback((a,t,i,m,o,f,h)=>{a&&Me(t,i,m,f,h,o),v({delete:{buttonAgree:"",buttonDisagree:"",dialogTitle:"",dialogContent:"",showDialog:false,callBackFunc:()=>{}}});},[Me,v]),sn=a=>I.delete.callBackFunc(a),nt=a=>{v(a);},{alloweditrow:De,backendpagination:ie,colactions:cn,colgrouping:dn,colordering:mn,colresizing:un,enableuploadfiles:fn,height:gn,hideaddbutton:pn,newrecordurl:bt,folders:Ue,pagination:yn,pagesize:Ve,rowactions:xn,rowactiontype:He,rowclickas:Ge,rowdensity:wn,rownumber:hn,rowselection:bn,rowvirtualization:Cn,search:Ct,searchtype:We,selectall:Dn,stickyheader:Rn,toolbarInternalActions:_n,topToolbar:Fn,visible:Tn}=e.properties,at=yn===true,Mn=Cn!==false&&!at,Sn=at,Dt=He==="flat"||He==="menu"||He==="primary",Rt=useNavigate(),T$1=useLocation(),{tabId:k}=e,{t:V$1,i18n:ot}=useTranslation(),W$1=(Tt=ot==null?void 0:ot.language)==null?void 0:Tt.substring(0,2),_t=useCallback((a,t)=>{O.setLastEvaluatedKey(Number(a),t||null);},[O]),je=useCallback(a=>O.getLastEvaluatedKey(Number(a)),[O]),Le=useCallback(async(a,t,i,m,o)=>{var L,N;Q(false),a&&(F(0),Y$1(null),Z$1(mt));let f=Zt(i.pageIndex,C,i.pageSize,R),h=je(i.pageIndex-1),p=f==="last"?"":m;he&&f!=="last"&&(f==="next"&&(p=je(i.pageIndex+1)),f==="previous"&&(h=je(i.pageIndex+1))),await l({DataTableMeta:{serverPaginationEnabled:ie,rowsPerPage:i.pageSize,pageIndex:i.pageIndex,nextToken:p,previousToken:h,paginationDirection:f==="last"?"last":t,rowCount:R,qId:o==null?void 0:o.qId,lastRequestLimit:o==null?void 0:o.lastRequestLimit,oppositeDirection:f==="last"||he},pluginCode:e.context.params.pluginCode,formCode:e.context.params.formCode,guid:e.context.params.guid,projectGuid:e.context.params.pGuid,pGuid:e.context.params.pGuid,widgetContext:JSON.stringify({referer:T$1.pathname,parentWidgetId:k,hasParentForm:T.hasParentForm(),originator:(L=e.context.params)==null?void 0:L.originator,parent:e.context.params,folderData:(N=e.context.params)==null?void 0:N.folderData}),widgetEvent:De?U.onTableEditDataLoad:U.onTableDataLoad,widgetName:e.properties.name.toLowerCase(),formData:e.context.formData}).then(re=>{var pe,z,D,Re,ne,we,Ae,Ee,ae;if(re.meta.requestStatus==="fulfilled"){let s={...re.payload},c=(pe=s.data)==null?void 0:pe[e.properties.name];if(Array.isArray(s.widgetData)&&s.widgetData.length===0&&typeof c=="string"&&c.trim()!==""&&c!=="null"&&c!=="undefined"){let M=JSON.parse(c);u(M!=null?M:{});}else u(Object.values((z=s.widgetData)!=null?z:{})),F((Re=(D=s.tableMeta)==null?void 0:D.rowCount)!=null?Re:0),Y$1((we=(ne=s.tableMeta)==null?void 0:ne.nextToken)!=null?we:null),Z$1((Ae=s.tableMeta)!=null?Ae:{}),(Ee=s.tableMeta)!=null&&Ee.nextToken&&_t(i.pageIndex,(ae=s.tableMeta)==null?void 0:ae.nextToken),Be(false),s.widgetRelatedData&&Object.keys(s.widgetRelatedData).length>0&&(ce.current.context.widgetRelatedData=s.widgetRelatedData);U$1(a),Q(true);}});},[ie,De,je,he,T$1.pathname,C,e.context.formData,e.context.params,e.properties.name,R,U$1,Q,Y$1,Be,F,u,Z$1,_t,k]),In=useCallback(a=>{if(r$1.current&&!ie){r$1.current=false;return}let t;typeof a=="function"?t=a({pageIndex:C,pageSize:se}):t=a;let i=Zt(t.pageIndex,C,t.pageSize,R);if(oe&&P$1&&C>0){U$1(false);return}t.pageIndex!==C&&O.setPageIndex(Number(t.pageIndex)),t.pageSize!==se&&O.setPageSize(Number(t.pageSize)),(ie&&t.pageIndex!==C||t.pageSize!==se)&&(Be(true),i==="last"&&xe(true),i==="first"&&xe(false),Le(false,i,t,w,S));},[ie,C,R,oe,P$1,se,Le,w,S]);useEffect(()=>{var a;rn((a=e.context)==null?void 0:a.widgetRelatedData);},[(Mt=e.context)==null?void 0:Mt.widgetRelatedData]),useEffect(()=>{r$1.current=true,O.reset(Number(Ve));},[e.properties.name,e.context.params]),useEffect(()=>{var a;if(De){let t=(a=e.context.formData)==null?void 0:a[e.properties.name];if(t){let i=typeof t=="string"?JSON.parse(t):t;u(i);}}},[e.context.formData]),useEffect(()=>{(async()=>{var a,t,i,m;if(e.context.enableEventHandlers){if(e.context.formLayout==="folders"&&!((t=(a=e.context.params)==null?void 0:a.folderData)!=null&&t.id)&&!((m=(i=e.context.params)==null?void 0:i.folderData)!=null&&m.isRoot))return;ie?C===0?Le(true,"first",{pageIndex:0,pageSize:Ve||100},"",mt):Le(false,"current",{pageIndex:C,pageSize:se},w,S):Le(true,"first",{pageIndex:0,pageSize:Ve||100},"",mt);}else Q(true);})();},[e.properties.name,e.context.redrawComponent,De,ie]);let te=e.methodProvider.findWidgetItem(e.id),Ne=[],Je={};((te==null?void 0:te.item.properties.datasource.columns)||[]).forEach(a=>{var t;Ne[a[1]]=a[0],a[2]&&(Je[a[1]]=(t=da[a[2]])!=null?t:"freetext");});let Pn=((te==null?void 0:te.item._children)||[]).some(({properties:a})=>{var i,m;if(!a.item_bottomcalc)return false;let t=(m=(i=Je[a.item_name])!=null?i:a.item_columntype)!=null?m:a.item_isprice?"price":"freetext";return t==="price"||t==="number"}),vn=useMemo(()=>{let a$1=[];return ((te==null?void 0:te.item._children)||[]).map(({properties:t})=>{var i,m,o,f,h,p,L,N,re,pe,z;if(t.item_name.toString()!==""){let D=(i=Je[t.item_name])!=null?i:"";D||(D=(m=t.item_columntype)!=null?m:"freetext",t.item_columntype||(t.item_isdate===true?D="date":t.item_isdatetime===true?D="datetime":t.item_ischeckbox===true?D="checkbox":t.item_isprice===true?D="price":D="freetext"));let Re=D==="checkbox",ne=D==="price",we=D==="number",Ae=D==="date",Ee=D==="datetime",ae={};Re?ae={accessorKey:t.item_name,muiTableHeadCellProps:{align:(o=t.style.item_textalign)!=null?o:"left"},muiTableBodyCellProps:{align:(f=t.style.item_ctextalign)!=null?f:"left"},header:t.item_title||Ne[t.item_name],Header:()=>{let s=t.item_title||Ne[t.item_name];return t.item_displaytooltip?jsx(le,{title:s,arrow:true,children:jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"block"},children:s})}):jsx("span",{children:s})},Cell:({row:s})=>{var c;return jsx("span",{style:{borderBottom:"none",padding:"0px",height:"36px"},children:jsx(Kn,{checked:Array.isArray((c=ce.current.context)==null?void 0:c.widgetRelatedData)&&ce.current.context.widgetRelatedData.includes(s.original._sk),onPointerUp:()=>sa(s.original,ce.current,T$1,k),style:{margin:0}})})},size:parseInt(t.item_minsize,10)||void 0,enableSorting:(h=t.item_enablesorting)!=null?h:false,enableHiding:(p=t.item_visible)!=null?p:true,grow:true}:(ae={accessorKey:t.item_name.toString(),muiTableHeadCellProps:{align:(L=t.style.item_textalign)!=null?L:"left"},muiTableBodyCellProps:{align:(N=t.style.item_ctextalign)!=null?N:"left"},header:t.item_title.toString()||Ne[t.item_name],Header:()=>{let s=t.item_title.toString()||Ne[t.item_name];return t.item_displaytooltip?jsx(le,{title:s,arrow:true,children:jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"block"},children:s})}):jsx("span",{children:s})},size:parseInt(t.item_minsize,10)||void 0,enableSorting:(re=t.item_enablesorting)!=null?re:false,enableHiding:t.item_visible===true,grow:true,muiEditTextFieldProps:{required:true,error:!!(ee!=null&&ee.firstName),helperText:ee==null?void 0:ee.firstName,onFocus:()=>Oe({...ee,[t.item_name.toString()]:void 0})},Cell:({cell:s})=>{var M;let c=(M=s.getValue())!=null?M:"";if(ne&&c){let y=dt(c);if(!isNaN(y)){let b=t.item_fixedlocale||"",j$1=t.item_format==="fixed-locale"&&b?b:W$1||void 0,_=t.item_inputfield&&ve.current&&ve.current[t.item_inputfield]||""||t.item_currency||"",X=t.item_format==="locale"?j(W$1!=null?W$1:""):t.item_format==="fixed-locale"&&b?j(b):void 0,A=_||X||"";try{let J=t.item_currencydisplay||"";A&&J!==""?c=new Intl.NumberFormat(j$1,{style:"currency",currency:A,currencyDisplay:J,minimumFractionDigits:2,maximumFractionDigits:2}).format(y):c=new Intl.NumberFormat(j$1,{style:"decimal",minimumFractionDigits:2,maximumFractionDigits:2}).format(y);}catch(J){c=y.toFixed(2);}}}if(we&&c){let y=dt(c);isNaN(y)||(c=y.toLocaleString());}if(Ae&&c){let y=(()=>{if(/^\d{4}-\d{2}-\d{2}/.test(c)){let b=a(c);if(b.isValid())return b}return a(c,"DD.MM.YYYY",true)})();if(y.isValid())try{c=new Intl.DateTimeFormat(W$1||void 0,{dateStyle:"short"}).format(y.toDate());}catch(b){}}if(Ee&&c){let y=(()=>{if(/^\d{4}-\d{2}-\d{2}/.test(c)){let b=a(c);if(b.isValid())return b}return a(c,"DD.MM.YYYY HH:mm",true)})();if(y.isValid())try{c=new Intl.DateTimeFormat(W$1||void 0,{dateStyle:"short",timeStyle:"short"}).format(y.toDate());}catch(b){}}return t.item_displaytooltip?jsx(ca,{value:c,style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:`${parseInt(t.item_maxsize,10)||150}px`,minWidth:"50px",cursor:"default"}}):jsx(Fragment,{children:c})}},t.item_bottomcalc&&(ne||we)&&(ae.muiTableFooterCellProps={align:(z=(pe=t.style)==null?void 0:pe.item_ctextalign)!=null?z:"left"},ae.Footer=({table:s})=>{var j$1,x;let c=(j$1=s.getState().creatingRow)==null?void 0:j$1.id,M=(x=s.getState().editingRow)==null?void 0:x.id,y=s.getFilteredRowModel().rows.reduce((_,X)=>{if(X.id===c||X.id===M)return _;let A=X.getValue(t.item_name.toString()),J=dt(String(A!=null?A:""));return _+(isNaN(J)?0:J)},0),b=y.toLocaleString(W$1||void 0,{minimumFractionDigits:ne||we?2:0,maximumFractionDigits:ne||we?2:0});if(ne){let _=t.item_fixedlocale||"",X=t.item_format==="fixed-locale"&&_?_:W$1||void 0,J=t.item_inputfield&&ve.current&&ve.current[t.item_inputfield]||""||t.item_currency||"",Hn=t.item_format==="locale"?j(W$1!=null?W$1:""):t.item_format==="fixed-locale"&&_?j(_):void 0,St=J||Hn||"",It=t.item_currencydisplay||"";if(St&&It!=="")try{b=new Intl.NumberFormat(X,{style:"currency",currency:St,currencyDisplay:It,minimumFractionDigits:2,maximumFractionDigits:2}).format(y);}catch(pa){b=y.toFixed(2);}}return jsx("b",{children:b})})),Ae?ae.sortingFn=(s,c,M)=>{let y=s.getValue(M),b=c.getValue(M),j=x=>{if(!x)return a("1900-01-01");if(/^\d{4}-\d{2}-\d{2}/.test(x)){let A=a(x);if(A.isValid())return A}let _=["DD.MM.YYYY","DD/MM/YYYY","DD.MM.YY","DD/MM/YY","M/D/YYYY","M/D/YY"];for(let A of _){let J=a(x,A,true);if(J.isValid())return J}let X=a(x);return X.isValid()?X:a("1900-01-01")};try{let x=j(y),_=j(b);return x.isBefore(_)?-1:x.isAfter(_)?1:0}catch(x){return 0}}:Ee?ae.sortingFn=(s,c,M)=>{let y=s.getValue(M),b=c.getValue(M),j=x=>{if(!x)return a("1900-01-01T00:00:00");if(/^\d{4}-\d{2}-\d{2}/.test(x)){let A=a(x);if(A.isValid())return A}let _=["DD.MM.YYYY HH:mm","DD/MM/YYYY HH:mm","DD.MM.YY HH:mm","DD/MM/YY HH:mm","M/D/YYYY h:mm A","M/D/YY h:mm A"];for(let A of _){let J=a(x,A,true);if(J.isValid())return J}let X=a(x);return X.isValid()?X:a("1900-01-01T00:00:00")};try{let x=j(y),_=j(b);return x.isBefore(_)?-1:x.isAfter(_)?1:0}catch(x){return 0}}:(ne||we)&&(ae.sortingFn=(s,c,M)=>{let y=parseFloat(s.getValue(M))||0,b=parseFloat(c.getValue(M))||0;return y-b}),Ge&&Ge!=="none"&&(ae.Cell=({row:s})=>jsx("div",{style:{cursor:"pointer",width:"100%",padding:"0.7em"},onPointerUp:()=>{var M,y,b,j,x,_;let c={pluginCode:s.original._plugincode,formCode:s.original._origformcode,guid:null,originator:(M=ce.current.context.params)==null?void 0:M.originator,pGuid:(y=ce.current.context.params)==null?void 0:y.pGuid,folderData:ce.current.context.params.folderData};Ge==="new"&&(j=(b=ce.current.context)==null?void 0:b.params)!=null&&j.modalCloseFn&&((_=(x=ce.current.context)==null?void 0:x.params)==null||_.modalCloseAndOpenFn(c));},children:s.getValue(t.item_name.toString())})),a$1.push(ae);}}),a$1},[W$1,ee,Ge,k]),kn=a=>{ue(a.currentTarget);},Ln=()=>{ue(null);},Nn=useCallback(()=>{var t,i;if(!Ue)return null;var a=(i=(t=e.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((m,o)=>jsxs("span",{style:{display:"inline-flex",alignItems:"center"},children:[m,o<a.length-1&&jsx(d$1,{style:{margin:"0 8px",fontSize:"0.6rem",color:"#666"}},`chevron-${o}`)]},`caption-${o}`))}))},[Ue,e.context.params.folderData]),An={density:wn,expanded:true,grouping:[],isFullScreen:false,pagination:{pageIndex:C||0,pageSize:Number(se)||Ve},columnVisibility:{id:false}},En=useCallback((a,t)=>{var i=[];a.forEach(m=>{var f,h,p,L,N,re;let o=m.original;i.push({_sk:(f=o._sk)!=null?f:null,_code:(h=o._fcode)!=null?h:o._code,_origformcode:(L=(p=o._origformcode)!=null?p:o._fcode)!=null?L:o._code,_plugincode:(N=o._plcode)!=null?N:o._plugincode,_desc:(re=o._desc)!=null?re:null});}),i.length>0&&Me("createsigncontainer",e,i,T$1,k,t);},[Me,e,T$1,k]),zn=useCallback((a,t)=>{var i=[];a.forEach(m=>{var f,h,p,L,N;let o=m.original;i.push({_sk:(f=o._sk)!=null?f:null,_code:(h=o._fcode)!=null?h:o._code,_origformcode:(L=(p=o._origformcode)!=null?p:o._fcode)!=null?L:o._code,_plugincode:(N=o._plcode)!=null?N:o._plugincode});}),i.length>0&&Me("download",e,i,T$1,k,t);},[Me,e,T$1,k]),Bn=useCallback((a,t)=>{var i=[];a.forEach(m=>{var f,h,p,L,N;let o=m.original;i.push({_sk:(f=o._sk)!=null?f:null,_code:(h=o._fcode)!=null?h:o._code,_origformcode:(L=(p=o._origformcode)!=null?p:o._fcode)!=null?L:o._code,_plugincode:(N=o._plcode)!=null?N:o._plugincode});}),nt({delete:{showDialog:true,dialogTitle:V$1("Delete")+" ?",dialogContent:V$1("Are you certain that you wish to delete selected records?"),buttonAgree:V$1("Continue"),buttonDisagree:V$1("Close"),callBackFunc:m=>ht(m,"delete",e,i,t,T$1,k)}});},[nt,ht,V$1,e,T$1,k]),On=useCallback(async({values:a,table:t})=>{ke("add",e,JSON.stringify(a),T$1,k),t.setCreatingRow(null);},[ke,e,T$1,k]),Yn=useCallback(async({values:a,table:t,row:i})=>{let m={...i.original,...a};ke("edit",e,JSON.stringify(m),T$1,k),t.setEditingRow(null);},[ke,e,T$1,k]),[fa,Un]=useState(null);if(!Tn)return null;let qe=Ie("file",e.context)?"primary":"#C0C0C0",Vn=Ie("file",e.context)?"contained":"outlined";return jsxs(Fragment,{children:[Ue&&jsx("div",{style:{paddingBottom:"0.8rem",fontSize:"0.85rem",color:"#666",marginLeft:"0.2rem"},children:Nn()}),jsx("div",{style:{maxWidth:e.context.isModal?g$1.width-30:void 0},children:jsx(Suspense,{fallback:jsx($n,{}),children:jsx(ia,{locale:W$1,columns:vn,enableBottomToolbar:Sn,enableTableFooter:Pn,createDisplayMode:"row",editDisplayMode:"row",enableEditing:false,enableColumnActions:cn,enableColumnOrdering:mn,enableColumnResizing:un,enableGlobalFilter:Ct,enableGlobalFilterModes:true,globalFilterModeOptions:[We||"startsWith"],globalFilterFn:We||"startsWith",enableGrouping:dn,enablePagination:at,manualPagination:ie!=null?ie:false,enableRowActions:Dt,enableRowNumbers:hn,enableRowSelection:bn,enableRowVirtualization:Mn,enableSelectAll:Dn,enableStickyHeader:Rn,enableToolbarInternalActions:_n,enableTopToolbar:Fn,onCreatingRowSave:On,onEditingRowSave:Yn,darkMode:false,data:ge,icons:{SaveIcon:()=>jsx(r,{color:ra,style:{fontSize:"1.2rem"}}),CancelIcon:()=>jsx(P,{color:"gray",style:{fontSize:"1.2rem"}})},initialState:An,isLoading:!oe,muiTableContainerProps:{sx:{maxHeight:gn}},name:e.properties.name,pageIndex:C,pageSize:se,muiPaginationProps:{rowsPerPageOptions:[50,100,300,500],disabled:be},onPaginationChange:In,positionActionsColumn:"last",displayColumnDefOptions:{"mrt-row-actions":Dt?{header:"",minSize:g$1.isMobileDevice?75:270,enableHiding:false}:void 0},rowOnDoubleClick:a=>{!De&&!pt(e.properties)&&tt("edit",e,a,T$1,k);},rowCount:ie?R:void 0,renderToolbarInternalActions:({table:a})=>jsx(en,{sx:{display:"flex",alignItems:"center"},children:!g$1.isMobileDevice&&jsxs(Fragment,{children:[!De&&Ct&&jsxs(Fragment,{children:[Ce&&jsx(ta,{autoFocus:true,size:"small",value:wt,placeholder:V$1("Search..."),onChange:t=>{Ye(t.target.value),a.setGlobalFilter(t.target.value||void 0);},onKeyDown:t=>{t.key==="Escape"&&(Ye(""),xt(false),a.setGlobalFilter(void 0));},endAdornment:wt?jsx(Qe,{size:"small",onClick:()=>{Ye(""),a.setGlobalFilter(void 0);},children:jsx(P,{size:10})}):void 0,sx:{border:"1px solid",borderColor:"divider",borderRadius:1,px:1,py:.25,fontSize:"0.875rem",mr:.5}}),jsx(le,{title:V$1(Ce?"Hide Search":"Search"),children:jsx(Qe,{size:"small",onClick:()=>{Ce&&(Ye(""),a.setGlobalFilter(void 0)),xt(!Ce);},children:Ce?jsx(ea,{fontSize:"small"}):jsx(Zn,{fontSize:"small"})})})]}),jsx(Y,{table:a}),jsx(W,{table:a}),jsx(X,{table:a}),!e.context.isModal&&jsx(Z,{table:a})]})}),renderTopToolbarCustomActions:({table:a})=>{var t$1,i,m,o,f,h$1,p$1,L,N$1,re;return jsxs("div",{style:{display:"flex",flexDirection:"row"},children:[a.getSelectedRowModel().rows.length===0&&Ue&&e.context.formLayout==="folders"&&jsx(Fragment,{children:jsx(le,{title:(i=(t$1=e.properties)==null?void 0:t$1.newFolderLabel)!=null?i:V$1("New Folder"),children:jsx(Fe,{style:{marginRight:"5px"},color:"primary",onPointerUp:()=>e.context.isModal||e.context.hasParentForm?e.methodProvider.eventDispatcher({widgetName:e.properties.name.toLowerCase(),widgetValue:null,widgetEvent:U.onFolderCreateRecordEvent,widgetContext:JSON.stringify({referer:T$1.pathname,parentWidgetId:k,hasParentForm:T.hasParentForm(),parentOriginator:{params:e.context.params.originator?e.context.params.originator.params:{}},originator:{params:e.context.params,widgetName:e.properties.name.toLowerCase()},parent:{widgetName:e.properties.name.toLowerCase(),params:e.context.params},isModal:e.context.isModal,folderData:e.context.params.folderData})}):Rt(`${T$1.pathname}/new`,{state:{from:T$1.pathname}}),variant:"outlined",children:jsx(t,{})})})}),a.getSelectedRowModel().rows.length===0&&!pn&&jsx(Fragment,{children:jsx(le,{title:(o=(m=e.properties)==null?void 0:m.addrecordlabel)!=null?o:V$1("Add Record"),children:jsx(Fe,{disabled:pt(e.properties),color:"primary",sx:{color:qe,borderColor:qe},style:{marginRight:"5px"},onPointerUp:()=>{if(!Ie("file",e.context)){de({toastID:nanoid(11),msg:V$1("Please select a folder before adding a document"),clearQueue:false,hideProgressBar:false});return}if(De){let pe={};((te==null?void 0:te.item._children)||[]).forEach(({properties:z})=>{var Re,ne;if(!z.item_increment||!z.item_name)return;let D=(Re=Je[z.item_name])!=null?Re:"";D||(D=(ne=z.item_columntype)!=null?ne:"freetext",z.item_columntype||(z.item_isdate?D="date":z.item_isdatetime?D="datetime":z.item_ischeckbox?D="checkbox":z.item_isprice?D="price":D="freetext")),D==="number"&&(pe[z.item_name.toString()]=ge.length+1);}),Object.keys(pe).length>0?a.setCreatingRow(V(a,pe)):a.setCreatingRow(true);}else return bt?Rt(`${T$1.pathname}/${bt}`,{state:{from:T$1.pathname}}):e.methodProvider.eventDispatcher({widgetName:e.properties.name.toLowerCase(),widgetValue:null,widgetEvent:U.onTableCreateRecordEvent,widgetContext:JSON.stringify({referer:T$1.pathname,parentWidgetId:k,hasParentForm:true,parentOriginator:{params:e.context.params.originator?e.context.params.originator.params:{}},originator:{params:e.context.params,widgetName:e.properties.name.toLowerCase()},parent:{widgetName:e.properties.name.toLowerCase(),params:e.context.params},isModal:e.context.isModal,folderData:e.context.params.folderData})})},variant:"outlined",children:jsx(p,{})})})}),a.getSelectedRowModel().rows.length===0&&fn&&jsx(Fragment,{children:jsx(le,{title:(h$1=(f=e.properties)==null?void 0:f.uploadFilesLabel)!=null?h$1:V$1("Upload Files"),children:jsx(Fe,{color:"primary",onPointerUp:kn,variant:"outlined",children:jsx(h,{})})})}),a.getSelectedRowModel().rows.length>0&&jsxs(Fragment,{children:[e.context.formLayout==="folders"&&a.getSelectedRowModel().rows.length>1&&jsx(Fragment,{children:jsx(le,{title:V$1("Create Container"),children:jsx(Fe,{style:{marginRight:"5px",color:qe,borderColor:qe},onPointerUp:()=>{if(!Ie("file",e.context)){de({toastID:nanoid(11),msg:V$1("Please select a folder before creating a container"),clearQueue:false,hideProgressBar:false});return}En(a.getSelectedRowModel().rows,a);},variant:Vn,children:jsx(q,{})})})}),jsxs(Fragment,{children:[jsx(le,{title:(L=(p$1=e.properties)==null?void 0:p$1.downloadLabel)!=null?L:V$1("Download"),children:jsx(Fe,{style:{marginRight:"5px"},onPointerUp:()=>zn(a.getSelectedRowModel().rows,a),variant:"contained",children:jsx(g,{})})}),jsx(le,{title:(re=(N$1=e.properties)==null?void 0:N$1.deleteLabel)!=null?re:V$1("Delete"),children:jsx(Fe,{style:{marginRight:"5px"},onPointerUp:()=>Bn(a.getSelectedRowModel().rows,a),variant:"contained",children:jsx(N,{})})})]})]}),jsx(la,{anchorEl:K,handleClose:Ln,setUploadMode:fe,uploadMode:Te,props:e,setLoaded:Q})]})},...ma(e,xn,He,g$1.isMobileDevice,nt,ln)},W$1)})}),jsx(G,{...I.delete,handleDialogClose:sn})]})})),Pe=d=>{let e=null,r=d.action,l$1=d.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},ma=(d,e,r,l,g,de)=>{var fe,ge;let G=typeof e=="string"?JSON.parse(e):e!=null?e:[],me=useLocation(),{t:O}=useTranslation(),{tabId:C}=d,se=(ge=(fe=d.properties)==null?void 0:fe.rowactionlabels)!=null?ge:{},K=(u,R)=>se[u]||O(R),ue={color:"text.secondary","&:hover":{color:"primary.main"},"&:focus":{color:"primary.main"},fontSize:"1.1em",marginRight:"0.5em"},oe=(u,R,F)=>u==="delete"?()=>{g({delete:{showDialog:true,dialogTitle:`${K("delete","Delete")} ?`,dialogContent:K("deleteConfirmContent","Are you certain that you wish to delete this record?"),buttonAgree:K("deleteConfirmAgree","Continue"),buttonDisagree:K("deleteConfirmDisagree","Close"),callBackFunc:w=>de(w,"delete",d,F,me,C)}});}:u==="editrow"?()=>{R.closeMenu(),R.table.setEditingRow(R.row);}:()=>{var w;(w=R.closeMenu)==null||w.call(R),tt(u,d,F,me,C);},Q=({entryType:u,mode:R})=>{let F=u.row.original,[w,Y]=ut.useState(null),S=I=>{Y(I.currentTarget);},Z=()=>{Y(null);},he=()=>jsx(Fragment,{children:Object.entries(G).map(([I,v])=>{if(!v)return null;let P=I.replace("action_",""),U=oe(P,u,F);return jsx("span",{children:jsx(le,{title:K(P,P.charAt(0).toUpperCase()+P.slice(1)),children:jsx(Qe,{sx:ue,onPointerUp:U,children:jsx(Pe,{action:P})})})},I)})}),xe={};if(F._primAct){let I=F._primAct;if(Object.values(an).includes(I)){Object.values(gt).includes(I)&&(xe.edit=true,G.action_edit&&delete G.action_edit);let v="action_"+I.toLowerCase();xe[v]=true,G[v]&&delete G[v];}}return jsxs(en,{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(xe).map(([I,v])=>{if(!v)return null;let P=I.replace("action_",""),U=oe(P,u,F),ee=Object.values(gt).includes(P.toUpperCase()),Oe=P.charAt(0).toUpperCase()+P.slice(1),Ce=Oe==="Edit"?K("open","Open"):K(P,Oe);return jsx(Fe,{onClick:U,startIcon:jsx(Pe,{action:P==="edit"?"open":P}),variant:"contained",size:"small",sx:{textTransform:"none",fontSize:"0.75rem",height:"28px",borderRadius:"4px",boxShadow:"none",backgroundColor:ee?"actionbtnok.main":"regularbtn.main",color:"#fff","&:hover":{backgroundColor:ee?"actionbtnok.hover":"regularbtn.hover",boxShadow:"none"},minInlineSize:"7.5em"},children:Ce},I)})}),{}),jsx(()=>{let I=w?w.getBoundingClientRect():null;return jsxs("span",{style:{paddingLeft:"1.5em"},children:[jsx(Qe,{sx:ue,onClick:S,id:"dropdown-button",children:jsx(oa,{})}),jsx(nn,{anchorEl:w,open:!!w,onClose:Z,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:v=>v.zIndex.modal+1}},children:Object.entries(G).map(([v,P])=>{if(!P)return null;let U=v.replace("action_","");return jsxs(et,{onClick:()=>{Z(),oe(U,u,F)();},sx:{px:2,py:1},children:[jsx(Xe,{sx:{minWidth:"unset",mr:1},children:jsx(Pe,{action:U==="print"?"preview":U,applyInternalStyle:true})}),jsx(Ze,{primaryTypographyProps:{fontSize:"0.875rem"},children:K(U,U.charAt(0).toUpperCase()+U.slice(1))})]},v)})})]})},{})]})]})},Te=u=>{let R=u.row.original;return [jsx(Qn,{onClickAway:()=>{var F;return (F=u.closeMenu)==null?void 0:F.call(u)},children:jsx(Xn,{sx:{minWidth:"12em",py:0,background:"none"},children:Object.entries(G).map(([F,w])=>{if(!w)return null;let Y=F.replace("action_",""),S=oe(Y,u,R);return jsxs(et,{disabled:pt(d.properties),onPointerUp:S,children:[jsx(Xe,{children:jsx(Pe,{action:Y==="print"?"preview":Y,applyInternalStyle:true})}),jsx(Ze,{primaryTypographyProps:{fontSize:"0.875rem"},children:K(Y,Y.charAt(0).toUpperCase()+Y.slice(1))})]},F)})})},"row-action-menu")]};return r==="flat"&&!l?{renderRowActions:u=>jsx(Q,{entryType:u,mode:0})}:r==="menu"||r!=="none"&&l?{renderRowActionMenuItems:u=>Te(u)}:r==="primary"?{renderRowActions:u=>jsx(Q,{entryType:u,mode:1})}:{}};on.displayName="_Datatable";var Za=on;export{Za as Datatable};