@buildocsdev/sdk 1.1.19 → 1.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-M26WXNQ2.js → chunk-AEFU7GLK.js} +1 -1
- package/dist/{chunk-KCPTFG5W.js → chunk-WTWFI67X.js} +1 -1
- package/dist/datatable-5D2UONII.js +1 -0
- package/dist/form.js +1 -1
- package/dist/{formeditor-T4TRUU2J.js → formeditor-EEW55OCF.js} +1 -1
- package/dist/formeditor.js +1 -1
- package/dist/metafile-esm.json +1 -1
- package/package.json +1 -1
- package/dist/datatable-BJGT4II2.js +0 -1
package/package.json
CHANGED
|
@@ -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-KW32CT2P.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 Jn from'@mui/material/CircularProgress';import Qt from'@mui/material/Box';import Te from'@mui/material/Button';import qn from'@mui/material/Checkbox';import $n from'@mui/material/ClickAwayListener';import $t from'@mui/material/IconButton';import Qe from'@mui/material/ListItemIcon';import Xe from'@mui/material/ListItemText';import Ze from'@mui/material/MenuItem';import Kn from'@mui/material/MenuList';import re from'@mui/material/Tooltip';import {nanoid}from'@reduxjs/toolkit';import {useNavigate,useLocation}from'react-router-dom';import Zt from'@mui/material/Menu';import Xn from'axios';import Zn from'@mui/icons-material/MoreVert';import {jsx,Fragment,jsxs}from'react/jsx-runtime';var ea=lazy(()=>import('./buildocslib.esm-AQXFL65L.js').then(c=>({default:c.DatatableImb}))),ta="#1976d2";var ut=(o=>(o[o.SIGN=0]="SIGN",o[o.CONFIRM=1]="CONFIRM",o))(ut||{}),en=(l=>(l[l.SIGN=0]="SIGN",l[l.CONFIRM=1]="CONFIRM",l[l.EDIT=2]="EDIT",l))(en||{}),et=(c,e,o,l,g)=>{var le,H,se,E,h;return e.methodProvider.eventDispatcher({skipFormDataItem:true,widgetName:e.properties.name.toLowerCase(),widgetValue:JSON.stringify({action:c,rowData:{_id:(le=o._id)!=null?le:null,_sk:(H=o._sk)!=null?H:null,_code:(se=o._fcode)!=null?se:o._code,_origformcode:(E=o._origformcode)!=null?E:null,_plugincode:(h=o._plcode)!=null?h:o._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})})},Pe=(c,e)=>{var o,l;return !(c==="file"&&e.formLayout==="folders"&&((o=e.params.folderData)!=null&&o.isRoot||((l=e.params.folderData)==null?void 0:l.id)===null))},na=({anchorEl:c,handleClose:e$1,setUploadMode:o,uploadMode:l,props:g,setLoaded:le})=>{let{runFormUploadFiles:H}=b(),se=e(),E=!!c,h=useRef(null),[ie,J]=useState([]),{t:ce}=useTranslation(),te=(de="file")=>{if(!Pe(de,g.context)){se({toastID:nanoid(11),msg:ce("Please select a folder before uploading a file"),clearQueue:false,hideProgressBar:false});return}h.current&&h.current.click(),o(de),e$1();},q=async de=>{var m,D;let me=de.target.files;if(me){le(false);let _=Array.from(me).map(T=>({...T,uploadProgress:0})),x=new FormData;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:(D=g.context.params)==null?void 0:D.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=Xn.CancelToken.source();try{let T=await H({content:x,cancelTokenSource:B,onUploadProgress:X=>{let be=Math.round(X.loaded/_.length),ye=_.map(Ce=>({...Ce,uploadProgress:X.loaded===X.total?100:Math.round(be*100/Ce.size)}));J(Ce=>Ce.concat(ye));}});if(T.meta.requestStatus==="fulfilled"){let X={...T.payload};g.methodProvider.execCommands(X.FECommand);}}catch(T){}h.current&&(h.current.value="");}},Ie=Pe("file",g.context)?"inherit":"#C0C0C0";return jsxs(Fragment,{children:[jsx("input",{type:"file",name:"files",ref:h,style:{display:"none"},onChange:q,multiple:true}),jsxs(Zt,{anchorEl:c,open:E,onClose:e$1,MenuListProps:{"aria-labelledby":"upload-button"},children:[jsxs(Ze,{onPointerUp:()=>te("file"),children:[jsx(Qe,{sx:{color:Ie},children:jsx(ve,{action:"uploadfile",applyInternalStyle:true})}),jsx(Xe,{primary:ce("Upload File(s)"),primaryTypographyProps:{fontSize:"0.875rem",color:Ie}})]},"Upload File(s)"),jsxs(Ze,{onPointerUp:()=>te("container"),children:[jsx(Qe,{children:jsx(ve,{action:"uploadzipfile",applyInternalStyle:true})}),jsx(Xe,{primary:ce("Upload .ZIP Archive"),primaryTypographyProps:{fontSize:"0.875rem"}})]},"Upload .ZIP Archive")]})]})},aa=(c,e,o,l)=>(c._plugincode=e.context.params.pluginCode,c._origformcode=c._code=e.context.params.formCode,et("onrowcheckboxclicked",e,c,o,l)),oa=({value:c,style:e})=>{let[o,l]=dt.useState(false),g=dt.useRef(null);return jsx(re,{title:String(c!=null?c:"").trim()?c:"No data",open:o,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,""),o=e.lastIndexOf(","),l=e.lastIndexOf("."),g;return o>l?g=e.replace(/\./g,"").replace(",","."):l>o?g=e.replace(/,/g,""):g=e,parseFloat(g)},Kt=(c,e,o,l)=>c===0?"first":c<e?"previous":l>0&&(c+1)*o>=l?"last":"next",ct={rowsPerPage:0,pageIndex:0,serverPaginationEnabled:false,nextToken:"",paginationDirection:"first",previousToken:"",rowCount:0,qId:""},ia={string:"freetext",freetext:"freetext",currency:"price",price:"price",date:"date",datetime:"datetime",number:"number",checkbox:"checkbox"},tn=withTranslation()(memo(function(e$1){var ht,bt,Ct;let o=useRef(false),{runFormEvent:l,viewPort:g$1}=b(),le=e(),{UserDialog:H}=b$1(),se=e$1.properties.name,E=d(se,e$1.properties.pagesize||50),{pageIndex:h$1,pageSize:ie}=E,[J,ce]=useState(null),[te,q$1]=useState(false),[Ie,de]=useState("single"),[me,m]=useState([]),[D,_$1]=useState(0),[x,B]=useState(),[T$1,X$1]=useState(),[be,ye]=useState(false),[Ce,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),ke=useRef(e$1.context.formData);useEffect(()=>{ee.current=e$1;},[e$1]),useEffect(()=>{ke.current=e$1.context.formData;},[e$1.context.formData]);let[la,nn]=useState((ht=e$1.context)==null?void 0:ht.widgetRelatedData),Le=useCallback(async(a,t,i,d,r)=>{q$1(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:r,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=>{if(u.meta.requestStatus==="fulfilled"){let f={...u.payload};f.FECommand={...f.FECommand,UpdateFieldAllowedValues:f.fieldAllowedValues,UpdateFormData:f.data,UpdateFormDataItem:{name:t.properties.name,value:f.data[t.properties.name]}},t.methodProvider.execCommands(f.FECommand);}});},[]),Me=useCallback(async(a,t,i,d,r,u)=>{q$1(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:r,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(f=>{if(f.meta.requestStatus==="fulfilled"){let R={...f.payload};R.widgetData&&m(Object.values(R.widgetData)),O(true),q$1(true),R.FECommand&&t.methodProvider.execCommands(R.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]),an=useCallback((a,t,i,d,r,u)=>{a&&(i.properties.alloweditrow?Le("delete",i,JSON.stringify(d),r,u):et(t,i,d,r,u)),P$1({delete:{buttonAgree:"",buttonDisagree:"",dialogTitle:"",dialogContent:"",showDialog:false,callBackFunc:()=>{}}});},[e$1.properties.alloweditrow]),yt=useCallback((a,t,i,d,r,u,f)=>{a&&Me(t,i,d,u,f,r),P$1({delete:{buttonAgree:"",buttonDisagree:"",dialogTitle:"",dialogContent:"",showDialog:false,callBackFunc:()=>{}}});},[Me,P$1]),on=a=>I.delete.callBackFunc(a),tt=a=>{P$1(a);},{alloweditrow:De,backendpagination:ne,colactions:rn,colgrouping:ln,colordering:sn,colresizing:cn,enableuploadfiles:dn,height:mn,hideaddbutton:un,folders:ze,pagination:gn,pagesize:Ue,rowactions:fn,rowactiontype:Ve,rowclickas:He,rowdensity:yn,rownumber:pn,rowselection:xn,rowvirtualization:wn,search:hn,searchtype:Ge,selectall:bn,stickyheader:Cn,toolbarInternalActions:Dn,topToolbar:Rn,visible:_n}=e$1.properties,nt=gn===true,Fn=wn!==false&&!nt,Tn=nt,pt=Ve==="flat"||Ve==="menu"||Ve==="primary",xt=useNavigate(),F=useLocation(),{tabId:v}=e$1,{t:$,i18n:at}=useTranslation(),G=(bt=at==null?void 0:at.language)==null?void 0:bt.substring(0,2),wt=useCallback((a,t)=>{E.setLastEvaluatedKey(Number(a),t||null);},[E]),We=useCallback(a=>E.getLastEvaluatedKey(Number(a)),[E]),Ne=useCallback(async(a,t,i,d,r)=>{var k,L;q$1(false),a&&(_$1(0),B(null),X$1(ct));let u=Kt(i.pageIndex,h$1,i.pageSize,D),f=We(i.pageIndex-1),R=u==="last"?"":d;be&&u!=="last"&&(u==="next"&&(R=We(i.pageIndex+1)),u==="previous"&&(f=We(i.pageIndex+1))),await l({DataTableMeta:{serverPaginationEnabled:ne,rowsPerPage:i.pageSize,pageIndex:i.pageIndex,nextToken:R,previousToken:f,paginationDirection:u==="last"?"last":t,rowCount:D,qId:r==null?void 0:r.qId,lastRequestLimit:r==null?void 0:r.lastRequestLimit,oppositeDirection:u==="last"||be},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:De?U.onTableEditDataLoad:U.onTableDataLoad,widgetName:e$1.properties.name.toLowerCase(),formData:e$1.context.formData}).then(ae=>{var ue,N,W,pe,S,qe,ge,xe;if(ae.meta.requestStatus==="fulfilled"){let z={...ae.payload},we=z.data[e$1.properties.name];if(Array.isArray(z.widgetData)&&z.widgetData.length===0&&typeof we=="string"&&we.trim()!==""&&we!=="null"&&we!=="undefined"){let K=JSON.parse(we);m(K!=null?K:{});}else m(Object.values((ue=z.widgetData)!=null?ue:{})),_$1((W=(N=z.tableMeta)==null?void 0:N.rowCount)!=null?W:0),B((S=(pe=z.tableMeta)==null?void 0:pe.nextToken)!=null?S:null),X$1((qe=z.tableMeta)!=null?qe:{}),(ge=z.tableMeta)!=null&&ge.nextToken&&wt(i.pageIndex,(xe=z.tableMeta)==null?void 0:xe.nextToken),Be(false),z.widgetRelatedData&&Object.keys(z.widgetRelatedData).length>0&&(ee.current.context.widgetRelatedData=z.widgetRelatedData);O(a),q$1(true);}});},[ne,De,We,be,F.pathname,h$1,e$1.context.formData,e$1.context.params,e$1.properties.name,D,O,q$1,B,Be,_$1,m,X$1,wt,v]),In=useCallback(a=>{if(o.current&&!ne){o.current=false;return}let t;typeof a=="function"?t=a({pageIndex:h$1,pageSize:ie}):t=a;let i=Kt(t.pageIndex,h$1,t.pageSize,D);if(te&&M&&h$1>0){O(false);return}t.pageIndex!==h$1&&E.setPageIndex(Number(t.pageIndex)),t.pageSize!==ie&&E.setPageSize(Number(t.pageSize)),(ne&&t.pageIndex!==h$1||t.pageSize!==ie)&&(Be(true),i==="last"&&ye(true),i==="first"&&ye(false),Ne(false,i,t,x,T$1));},[ne,h$1,D,te,M,ie,Ne,x,T$1]);useEffect(()=>{var a;nn((a=e$1.context)==null?void 0:a.widgetRelatedData);},[(Ct=e$1.context)==null?void 0:Ct.widgetRelatedData]),useEffect(()=>{o.current=true,E.reset(Number(Ue));},[e$1.properties.name,e$1.context.params]),useEffect(()=>{De&&e$1.context.formData&&e$1.context.formData[e$1.properties.name]&&m(JSON.parse(e$1.context.formData[e$1.properties.name]));},[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?h$1===0?Ne(true,"first",{pageIndex:0,pageSize:Ue||100},"",ct):Ne(false,"current",{pageIndex:h$1,pageSize:ie},x,T$1):Ne(true,"first",{pageIndex:0,pageSize:Ue||100},"",ct);}else q$1(true);})();},[e$1.properties.name,e$1.context.redrawComponent,De,ne]);let je=e$1.methodProvider.findWidgetItem(e$1.id),Ae=[],Ye={};(je.item.properties.datasource.columns||[]).forEach(a=>{var t;Ae[a[1]]=a[0],a[2]&&(Ye[a[1]]=(t=ia[a[2]])!=null?t:"freetext");});let Mn=(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"}),Sn=useMemo(()=>{let a$1=[];return (je.item._children||[]).map(({properties:t})=>{var i,d,r,u,f,R,k$1,L,ae,ue,N,W,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",z=S==="date",we=S==="datetime",K={};qe?K={accessorKey:t.item_name,muiTableHeadCellProps:{align:(r=t.style.item_textalign)!=null?r:"left"},muiTableBodyCellProps:{align:(u=t.style.item_ctextalign)!=null?u:"left"},header:(f=Ae[t.item_name])!=null?f:t.item_title,Header:()=>{var s;let y=(s=Ae[t.item_name])!=null?s:t.item_title;return t.item_displaytooltip?jsx(re,{title:y,arrow:true,children:jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"block"},children:y})}):jsx("span",{children:y})},Cell:({row:y})=>{var s;return jsx("span",{style:{borderBottom:"none",padding:"0px",height:"36px"},children:jsx(qn,{checked:Array.isArray((s=ee.current.context)==null?void 0:s.widgetRelatedData)&&ee.current.context.widgetRelatedData.includes(y.original._sk),onPointerUp:()=>aa(y.original,ee.current,F,v),style:{margin:0}})})},size:parseInt(t.item_minsize,10)||void 0,enableSorting:(R=t.item_enablesorting)!=null?R:false,enableHiding:(k$1=t.item_visible)!=null?k$1:true,grow:true}:(K={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=Ae[t.item_name])!=null?ue:t.item_title.toString(),Header:()=>{var s;let y=(s=Ae[t.item_name])!=null?s:t.item_title.toString();return t.item_displaytooltip?jsx(re,{title:y,arrow:true,children:jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"block"},children:y})}):jsx("span",{children:y})},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:y})=>{var A;let s=(A=y.getValue())!=null?A:"";if(ge&&s){let p=st(s);if(!isNaN(p)){let w=t.item_fixedlocale||"",j=t.item_format==="fixed-locale"&&w?w:G||void 0,C=t.item_inputfield&&ke.current&&ke.current[t.item_inputfield]||""||t.item_currency||"",Re=t.item_format==="locale"?k(G!=null?G:""):t.item_format==="fixed-locale"&&w?k(w):void 0,_e=C||Re||"";try{let he=t.item_currencydisplay||"";_e&&he!==""?s=new Intl.NumberFormat(j,{style:"currency",currency:_e,currencyDisplay:he,minimumFractionDigits:2,maximumFractionDigits:2}).format(p):s=new Intl.NumberFormat(j,{style:"decimal",minimumFractionDigits:2,maximumFractionDigits:2}).format(p);}catch(he){s=p.toFixed(2);}}}if(xe&&s){let p=st(s);isNaN(p)||(s=p.toLocaleString());}if(z&&s){let p=(()=>{if(/^\d{4}-\d{2}-\d{2}/.test(s)){let w=a(s);if(w.isValid())return w}return a(s,"DD.MM.YYYY",true)})();if(p.isValid())try{s=new Intl.DateTimeFormat(G||void 0,{dateStyle:"short"}).format(p.toDate());}catch(w){}}if(we&&s){let p=(()=>{if(/^\d{4}-\d{2}-\d{2}/.test(s)){let w=a(s);if(w.isValid())return w}return a(s,"DD.MM.YYYY HH:mm",true)})();if(p.isValid())try{s=new Intl.DateTimeFormat(G||void 0,{dateStyle:"short",timeStyle:"short"}).format(p.toDate());}catch(w){}}return t.item_displaytooltip?jsx(oa,{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)&&(K.muiTableFooterCellProps={align:(pe=(W=t.style)==null?void 0:W.item_ctextalign)!=null?pe:"left"},K.Footer=({table:y})=>{var j,b;let s=(j=y.getState().creatingRow)==null?void 0:j.id,A=(b=y.getState().editingRow)==null?void 0:b.id,p=y.getFilteredRowModel().rows.reduce((C,Re)=>{if(Re.id===s||Re.id===A)return C;let _e=Re.getValue(t.item_name.toString()),he=st(String(_e!=null?_e:""));return C+(isNaN(he)?0:he)},0),w=p.toLocaleString(G||void 0,{minimumFractionDigits:ge||xe?2:0,maximumFractionDigits:ge||xe?2:0});if(ge){let C=t.item_fixedlocale||"",Re=t.item_format==="fixed-locale"&&C?C:G||void 0,he=t.item_inputfield&&ke.current&&ke.current[t.item_inputfield]||""||t.item_currency||"",Vn=t.item_format==="locale"?k(G!=null?G:""):t.item_format==="fixed-locale"&&C?k(C):void 0,Dt=he||Vn||"",Rt=t.item_currencydisplay||"";if(Dt&&Rt!=="")try{w=new Intl.NumberFormat(Re,{style:"currency",currency:Dt,currencyDisplay:Rt,minimumFractionDigits:2,maximumFractionDigits:2}).format(p);}catch(da){w=p.toFixed(2);}}return jsx("b",{children:w})})),z?K.sortingFn=(y,s,A)=>{let p=y.getValue(A),w=s.getValue(A),j=b=>{if(!b)return a("1900-01-01");if(/^\d{4}-\d{2}-\d{2}/.test(b)){let C=a(b);if(C.isValid())return C}return a(b,"DD.MM.YYYY",true)};try{let b=j(p),C=j(w);return b.isBefore(C)?-1:b.isAfter(C)?1:0}catch(b){return 0}}:we?K.sortingFn=(y,s,A)=>{let p=y.getValue(A),w=s.getValue(A),j=b=>{if(!b)return a("1900-01-01T00:00:00");if(/^\d{4}-\d{2}-\d{2}/.test(b)){let C=a(b);if(C.isValid())return C}return a(b,"DD.MM.YYYY HH:mm",true)};try{let b=j(p),C=j(w);return b.isBefore(C)?-1:b.isAfter(C)?1:0}catch(b){return 0}}:(ge||xe)&&(K.sortingFn=(y,s,A)=>{let p=parseFloat(y.getValue(A))||0,w=parseFloat(s.getValue(A))||0;return p-w}),He&&He!=="none"&&(K.Cell=({row:y})=>jsx("div",{style:{cursor:"pointer",width:"100%",padding:"0.7em"},onPointerUp:()=>{var A,p,w,j,b,C;let s={pluginCode:y.original._plugincode,formCode:y.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"&&(j=(w=ee.current.context)==null?void 0:w.params)!=null&&j.modalCloseFn&&((C=(b=ee.current.context)==null?void 0:b.params)==null||C.modalCloseAndOpenFn(s));},children:y.getValue(t.item_name.toString())})),a$1.push(K);}}),a$1},[G,Z$1,He,v]),Pn=a=>{ce(a.currentTarget);},vn=()=>{ce(null);},kn=useCallback(()=>{var t;if(!ze)return null;var a=(t=e$1.context.params.folderData)==null?void 0:t.captions;return a==null||a.length===0?null:(a=a.slice(1),jsx("span",{style:{display:"flex",alignItems:"center"},children:a.map((i,d)=>jsxs("span",{style:{display:"inline-flex",alignItems:"center"},children:[i,d<a.length-1&&jsx(d$1,{style:{margin:"0 8px",fontSize:"0.6rem",color:"#666"}},`chevron-${d}`)]},`caption-${d}`))}))},[ze,e$1.context.params.folderData]),Ln={density:yn,expanded:true,grouping:[],isFullScreen:false,pagination:{pageIndex:h$1||0,pageSize:Number(ie)||Ue},columnVisibility:{id:false}},Nn=useCallback((a,t)=>{var i=[];a.forEach(d=>{var u,f,R,k,L,ae;let r=d.original;i.push({_sk:(u=r._sk)!=null?u:null,_code:(f=r._fcode)!=null?f:r._code,_origformcode:(k=(R=r._origformcode)!=null?R:r._fcode)!=null?k:r._code,_plugincode:(L=r._plcode)!=null?L:r._plugincode,_desc:(ae=r._desc)!=null?ae:null});}),i.length>0&&Me("createsigncontainer",e$1,i,F,v,t);},[Me,e$1,F,v]),An=useCallback((a,t)=>{var i=[];a.forEach(d=>{var u,f,R,k,L;let r=d.original;i.push({_sk:(u=r._sk)!=null?u:null,_code:(f=r._fcode)!=null?f:r._code,_origformcode:(k=(R=r._origformcode)!=null?R:r._fcode)!=null?k:r._code,_plugincode:(L=r._plcode)!=null?L:r._plugincode});}),i.length>0&&Me("download",e$1,i,F,v,t);},[Me,e$1,F,v]),En=useCallback((a,t)=>{var i=[];a.forEach(d=>{var u,f,R,k,L;let r=d.original;i.push({_sk:(u=r._sk)!=null?u:null,_code:(f=r._fcode)!=null?f:r._code,_origformcode:(k=(R=r._origformcode)!=null?R:r._fcode)!=null?k:r._code,_plugincode:(L=r._plcode)!=null?L:r._plugincode});}),tt({delete:{showDialog:true,dialogTitle:$("Delete")+" ?",dialogContent:$("Are you certain that you wish to delete selected records?"),buttonAgree:$("Continue"),buttonDisagree:$("Close"),callBackFunc:d=>yt(d,"delete",e$1,i,t,F,v)}});},[tt,yt,$,e$1,F,v]),Bn=useCallback(async({values:a,table:t})=>{Le("add",e$1,JSON.stringify(a),F,v),t.setCreatingRow(null);},[Le,e$1,F,v]),On=useCallback(async({values:a,table:t,row:i})=>{let d={...i.original,...a};Le("edit",e$1,JSON.stringify(d),F,v),t.setEditingRow(null);},[Le,e$1,F,v]),[sa,zn]=useState(null);if(!_n)return null;let Je=Pe("file",e$1.context)?"primary":"#C0C0C0",Un=Pe("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:kn()}),jsx("div",{style:{maxWidth:e$1.context.isModal?g$1.width-30:void 0},children:jsx(Suspense,{fallback:jsx(Jn,{}),children:jsx(ea,{locale:G,columns:Sn,enableBottomToolbar:Tn,enableTableFooter:Mn,createDisplayMode:"row",editDisplayMode:"row",enableEditing:false,enableColumnActions:rn,enableColumnOrdering:sn,enableColumnResizing:cn,enableGlobalFilter:hn,enableGlobalFilterModes:true,globalFilterModeOptions:[Ge||"startsWith"],globalFilterFn:Ge||"startsWith",enableGrouping:ln,enablePagination:nt,manualPagination:ne!=null?ne:false,enableRowActions:pt,enableRowNumbers:pn,enableRowSelection:xn,enableRowVirtualization:Fn,enableSelectAll:bn,enableStickyHeader:Cn,enableToolbarInternalActions:Dn,enableTopToolbar:Rn,onCreatingRowSave:Bn,onEditingRowSave:On,darkMode:false,data:me,icons:{SaveIcon:()=>jsx(r,{color:ta,style:{fontSize:"1.2rem"}}),CancelIcon:()=>jsx(P,{color:"gray",style:{fontSize:"1.2rem"}})},initialState:Ln,isLoading:!te,muiTableContainerProps:{sx:{maxHeight:mn}},name:e$1.properties.name,pageIndex:h$1,pageSize:ie,muiPaginationProps:{rowsPerPageOptions:[50,100,300,500],disabled:Ce},onPaginationChange:In,positionActionsColumn:"last",displayColumnDefOptions:{"mrt-row-actions":pt?{header:"",minSize:g$1.isMobileDevice?75:270,enableHiding:false}:void 0},rowOnDoubleClick:a=>{!De&&!gt(e$1.properties)&&et("edit",e$1,a,F,v);},rowCount:ne?D:void 0,renderToolbarInternalActions:({table:a})=>jsx(Qt,{children:!g$1.isMobileDevice&&jsxs(Fragment,{children:[!De&&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,r,u,f,R,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:$("New Folder"),children:jsx(Te,{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})}):xt(`${F.pathname}/new`,{state:{from:F.pathname}}),variant:"outlined",children:jsx(t,{})})})}),a.getSelectedRowModel().rows.length===0&&!un&&jsx(Fragment,{children:jsx(re,{title:(r=(d=e$1.properties)==null?void 0:d.addrecordlabel)!=null?r:$("Add Record"),children:jsx(Te,{disabled:gt(e$1.properties),color:"primary",sx:{color:Je,borderColor:Je},style:{marginRight:"5px"},onPointerUp:()=>{if(!Pe("file",e$1.context)){le({toastID:nanoid(11),msg:$("Please select a folder before adding a document"),clearQueue:false,hideProgressBar:false});return}if(De){let ue={};(je.item._children||[]).forEach(({properties:N})=>{var pe,S;if(!N.item_increment||!N.item_name)return;let W=(pe=Ye[N.item_name])!=null?pe:"";W||(W=(S=N.item_columntype)!=null?S:"freetext",N.item_columntype||(N.item_isdate?W="date":N.item_isdatetime?W="datetime":N.item_ischeckbox?W="checkbox":N.item_isprice?W="price":W="freetext")),W==="number"&&(ue[N.item_name.toString()]=me.length+1);}),Object.keys(ue).length>0?a.setCreatingRow(V(a,ue)):a.setCreatingRow(true);}else return e$1.context.isModal||e$1.context.hasParentForm?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})}):xt(`${F.pathname}/new`,{state:{from:F.pathname}})},variant:"outlined",children:jsx(p,{})})})}),a.getSelectedRowModel().rows.length===0&&dn&&jsx(Fragment,{children:jsx(re,{title:(f=(u=e$1.properties)==null?void 0:u.uploadFilesLabel)!=null?f:$("Upload Files"),children:jsx(Te,{color:"primary",onPointerUp:Pn,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:$("Create Container"),children:jsx(Te,{style:{marginRight:"5px",color:Je,borderColor:Je},onPointerUp:()=>{if(!Pe("file",e$1.context)){le({toastID:nanoid(11),msg:$("Please select a folder before creating a container"),clearQueue:false,hideProgressBar:false});return}Nn(a.getSelectedRowModel().rows,a);},variant:Un,children:jsx(q,{})})})}),jsxs(Fragment,{children:[jsx(re,{title:(k=(R=e$1.properties)==null?void 0:R.downloadLabel)!=null?k:$("Download"),children:jsx(Te,{style:{marginRight:"5px"},onPointerUp:()=>An(a.getSelectedRowModel().rows,a),variant:"contained",children:jsx(g,{})})}),jsx(re,{title:(ae=(L=e$1.properties)==null?void 0:L.deleteLabel)!=null?ae:$("Delete"),children:jsx(Te,{style:{marginRight:"5px"},onPointerUp:()=>En(a.getSelectedRowModel().rows,a),variant:"contained",children:jsx(N,{})})})]})]}),jsx(na,{anchorEl:J,handleClose:vn,setUploadMode:de,uploadMode:Ie,props:e$1,setLoaded:q$1})]})},...ra(e$1,fn,Ve,g$1.isMobileDevice,tt,an)},G)})}),jsx(H,{...I.delete,handleDialogClose:on})]})})),ve=c=>{let e=null,o$1=c.action,l$1=c.applyInternalStyle?{fontSize:"1em",marginRight:"0.5em"}:{};return o$1==="open"?e=jsx(n,{style:l$1}):o$1==="copy"?e=jsx(i,{style:l$1}):o$1==="confirm"?e=jsx(w,{style:{...l$1,fontSize:"1.6em"}}):o$1==="edit"?e=jsx(A,{style:l$1}):o$1==="editrow"?e=jsx(n,{style:l$1}):o$1==="amend"?e=jsx(b$2,{style:l$1}):o$1==="delete"?e=jsx(N,{style:l$1}):o$1==="lock"?e=jsx(y,{style:l$1}):o$1==="unlock"?e=jsx(x,{style:l$1}):o$1==="print"?e=jsx(C,{style:l$1}):o$1==="preview"?e=jsx(n,{style:l$1}):o$1==="sign"?e=jsx(q,{style:l$1}):o$1==="download"?e=jsx(l,{style:l$1}):o$1==="uploadfile"?e=jsx(O,{style:l$1}):o$1==="uploadzipfile"&&(e=jsx(o,{style:l$1})),e},ra=(c,e,o,l,g,le)=>{var de,me;let H=JSON.parse(e),se=useLocation(),{t:E}=useTranslation(),{tabId:h}=c,ie=(me=(de=c.properties)==null?void 0:de.rowactionlabels)!=null?me:{},J=(m,D)=>ie[m]||E(D),ce={color:"text.secondary","&:hover":{color:"primary.main"},"&:focus":{color:"primary.main"},fontSize:"1.1em",marginRight:"0.5em"},te=(m,D,_)=>m==="delete"?()=>{g({delete:{showDialog:true,dialogTitle:`${J("delete","Delete")} ?`,dialogContent:J("deleteConfirmContent","Are you certain that you wish to delete this record?"),buttonAgree:J("deleteConfirmAgree","Continue"),buttonDisagree:J("deleteConfirmDisagree","Close"),callBackFunc:x=>le(x,"delete",c,_,se,h)}});}:m==="editrow"?()=>{D.closeMenu(),D.table.setEditingRow(D.row);}:()=>{var x;(x=D.closeMenu)==null||x.call(D),et(m,c,_,se,h);},q=({entryType:m,mode:D})=>{let _=m.row.original,[x,B]=dt.useState(null),T=I=>{B(I.currentTarget);},X=()=>{B(null);},be=()=>jsx(Fragment,{children:Object.entries(H).map(([I,P])=>{if(!P)return null;let M=I.replace("action_",""),O=te(M,m,_);return jsx("span",{children:jsx(re,{title:J(M,M.charAt(0).toUpperCase()+M.slice(1)),children:jsx($t,{sx:ce,onPointerUp:O,children:jsx(ve,{action:M})})})},I)})}),ye={};if(_._primAct){let I=_._primAct;if(Object.values(en).includes(I)){Object.values(ut).includes(I)&&(ye.edit=true,H.action_edit&&delete H.action_edit);let P="action_"+I.toLowerCase();ye[P]=true,H[P]&&delete H[P];}}return jsxs(Qt,{sx:{display:"flex",flexWrap:"nowrap",gap:"8px",justifyContent:"center",alignItems:"center"},children:[D===0&&jsx(be,{}),D===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"?J("open","Open"):J(M,Oe);return jsx(Te,{onClick:O,startIcon:jsx(ve,{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($t,{sx:ce,onClick:T,id:"dropdown-button",children:jsx(Zn,{})}),jsx(Zt,{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(H).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(ve,{action:O==="print"?"preview":O,applyInternalStyle:true})}),jsx(Xe,{primaryTypographyProps:{fontSize:"0.875rem"},children:J(O,O.charAt(0).toUpperCase()+O.slice(1))})]},P)})})]})},{})]})]})},Ie=m=>{let D=m.row.original;return [jsx($n,{onClickAway:()=>{var _;return (_=m.closeMenu)==null?void 0:_.call(m)},children:jsx(Kn,{sx:{minWidth:"12em",py:0,background:"none"},children:Object.entries(H).map(([_,x])=>{if(!x)return null;let B=_.replace("action_",""),T=te(B,m,D);return jsxs(Ze,{disabled:gt(c.properties),onPointerUp:T,children:[jsx(Qe,{children:jsx(ve,{action:B==="print"?"preview":B,applyInternalStyle:true})}),jsx(Xe,{primaryTypographyProps:{fontSize:"0.875rem"},children:J(B,B.charAt(0).toUpperCase()+B.slice(1))})]},_)})})},"row-action-menu")]};return o==="flat"&&!l?{renderRowActions:m=>jsx(q,{entryType:m,mode:0})}:o==="menu"||o!=="none"&&l?{renderRowActionMenuItems:m=>Ie(m)}:o==="primary"?{renderRowActions:m=>jsx(q,{entryType:m,mode:1})}:{}};tn.displayName="_Datatable";var ja=tn;export{ja as Datatable};
|