@gisce/react-ooui 1.2.2 → 1.2.3
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/react-ooui.umd.js
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
.ant-progress-text {
|
|
29
29
|
display: none;
|
|
30
30
|
}
|
|
31
|
-
`,tn=t=>{const{visible:r,onCancel:n,items:s=[],onItemClicked:o}=t,{t:i}=l.useContext(ge);return e.jsx(h.Modal,{title:i("selectAction"),centered:!0,open:r,footer:null,destroyOnClose:!0,onCancel:n,maskClosable:!1,children:e.jsx(h.Space,{direction:"vertical",className:"w-full",children:s.map(a=>e.jsx(h.Button,{className:"w-full",onClick:()=>{o(a)},children:a.name}))})})},Qt=t=>{var S,x;const{id:r,model:n,context:s={}}=t,[o,i]=l.useState(!1),[a,c]=l.useState(!1),[u,f]=l.useState(!1),[p,d]=l.useState(),[g,w]=l.useState(),{t:m}=l.useContext(ge),y=l.useContext(Ye),{openRelate:C}=y||{},v=l.useContext(lt),{processAction:V}=v||{};if(!r)return null;async function _(){f(!0);try{const O=await W.getHandler().getView({model:n,type:"form",context:s});d(O);const{fields:T,arch:H}=O,F=(await W.getHandler().readObjects({model:n,ids:[r],fields:T,context:s}))[0];w({...it(F,T),active_id:r}),f(!1)}catch(O){f(!1),Ie(O);return}}function b(){var T;if(u)return e.jsx(h.Menu,{children:e.jsx("div",{style:{padding:15},children:e.jsx(h.Spin,{})})});if(!p||!p.toolbar)return e.jsx(h.Menu,{});const O=(T=p==null?void 0:p.toolbar)==null?void 0:T.relate.map(H=>e.jsx(h.Menu.Item,{children:H.name},H.id));return e.jsx(h.Menu,{onClick:E,children:[e.jsx(h.Menu.Item,{disabled:!p.toolbar.action||p.toolbar.action.length===0,icon:e.jsx(B.ThunderboltOutlined,{}),children:m("action")},"action"),e.jsx(h.Menu.Item,{disabled:!p.toolbar.print||p.toolbar.print.length===0,icon:e.jsx(B.PrinterOutlined,{}),children:m("report")},"print"),e.jsx(h.Menu.Divider,{}),e.jsx(h.Menu.ItemGroup,{title:e.jsxs(e.Fragment,{children:[e.jsx(B.EnterOutlined,{})," ",e.jsxs("span",{children:[" ",m("related")]})]}),children:O})]})}function E(O){if(O.key==="action")i(!0);else if(O.key==="print")c(!0);else{const T=p.toolbar.relate.find(H=>H.id===parseInt(O.key));if(!T)return;C({relateData:T,values:g,fields:p.fields,action_id:T.id,action_type:T.type})}}function D(O){i(!1),V==null||V({actionData:O,values:g,fields:p.fields,context:{active_id:r,active_ids:[r]}})}function N(O){c(!1),V==null||V({actionData:{...O,datas:{...O.datas||{},ids:[r]}},values:g,fields:p.fields})}return e.jsxs(e.Fragment,{children:[e.jsx(h.Dropdown,{overlay:b(),trigger:["click"],children:e.jsx(B.RightCircleOutlined,{style:{color:"rgba(0,0,0,.45)"},onClick:O=>{O.preventDefault(),_()}})}),e.jsx(tn,{visible:o,items:(S=p==null?void 0:p.toolbar)==null?void 0:S.action,onItemClicked:D,onCancel:()=>i(!1)}),e.jsx(tn,{visible:a,items:(x=p==null?void 0:p.toolbar)==null?void 0:x.print,onItemClicked:N,onCancel:()=>c(!1)})]})},Xi=t=>{const{m2oField:r}=t;return r?e.jsxs(h.Space,{children:[e.jsx(e.Fragment,{children:r.value}),e.jsx(Qt,{id:r.id,model:r.model})]}):e.jsx(e.Fragment,{})},Qi=t=>{const{value:r,context:n,selectionValues:s}=t,[o,i]=l.useState(),[a,c]=l.useState(!1),[u,f]=r?r.split(","):[],p=parseInt(f),d=l.useCallback(async()=>{if(!r||r&&o)return;c(!0);const w=await W.getHandler().execute({action:"name_get",payload:[p],model:u,context:n});i(w[0][1]),c(!1)},[r,o]);if(l.useEffect(()=>{d()},[r]),!r&&!a)return e.jsx(e.Fragment,{});if(a)return e.jsx(B.LoadingOutlined,{});const g=s.get(u);return e.jsxs(h.Space,{children:[e.jsx(e.Fragment,{children:`${g}:`}),e.jsx(e.Fragment,{children:o}),e.jsx(Qt,{id:p,model:u})]})};var rn={exports:{}};(function(t,r){(function(n,s){t.exports=s()})(et,function(){var n=1e3,s=6e4,o=36e5,i="millisecond",a="second",c="minute",u="hour",f="day",p="week",d="month",g="quarter",w="year",m="date",y="Invalid Date",C=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,v=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,V={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(F){var A=["th","st","nd","rd"],M=F%100;return"["+F+(A[(M-20)%10]||A[M]||A[0])+"]"}},_=function(F,A,M){var L=String(F);return!L||L.length>=A?F:""+Array(A+1-L.length).join(M)+F},b={s:_,z:function(F){var A=-F.utcOffset(),M=Math.abs(A),L=Math.floor(M/60),k=M%60;return(A<=0?"+":"-")+_(L,2,"0")+":"+_(k,2,"0")},m:function F(A,M){if(A.date()<M.date())return-F(M,A);var L=12*(M.year()-A.year())+(M.month()-A.month()),k=A.clone().add(L,d),I=M-k<0,K=A.clone().add(L+(I?-1:1),d);return+(-(L+(M-k)/(I?k-K:K-k))||0)},a:function(F){return F<0?Math.ceil(F)||0:Math.floor(F)},p:function(F){return{M:d,y:w,w:p,d:f,D:m,h:u,m:c,s:a,ms:i,Q:g}[F]||String(F||"").toLowerCase().replace(/s$/,"")},u:function(F){return F===void 0}},E="en",D={};D[E]=V;var N=function(F){return F instanceof T},S=function F(A,M,L){var k;if(!A)return E;if(typeof A=="string"){var I=A.toLowerCase();D[I]&&(k=I),M&&(D[I]=M,k=I);var K=A.split("-");if(!k&&K.length>1)return F(K[0])}else{var q=A.name;D[q]=A,k=q}return!L&&k&&(E=k),k||!L&&E},x=function(F,A){if(N(F))return F.clone();var M=typeof A=="object"?A:{};return M.date=F,M.args=arguments,new T(M)},O=b;O.l=S,O.i=N,O.w=function(F,A){return x(F,{locale:A.$L,utc:A.$u,x:A.$x,$offset:A.$offset})};var T=function(){function F(M){this.$L=S(M.locale,null,!0),this.parse(M)}var A=F.prototype;return A.parse=function(M){this.$d=function(L){var k=L.date,I=L.utc;if(k===null)return new Date(NaN);if(O.u(k))return new Date;if(k instanceof Date)return new Date(k);if(typeof k=="string"&&!/Z$/i.test(k)){var K=k.match(C);if(K){var q=K[2]-1||0,z=(K[7]||"0").substring(0,3);return I?new Date(Date.UTC(K[1],q,K[3]||1,K[4]||0,K[5]||0,K[6]||0,z)):new Date(K[1],q,K[3]||1,K[4]||0,K[5]||0,K[6]||0,z)}}return new Date(k)}(M),this.$x=M.x||{},this.init()},A.init=function(){var M=this.$d;this.$y=M.getFullYear(),this.$M=M.getMonth(),this.$D=M.getDate(),this.$W=M.getDay(),this.$H=M.getHours(),this.$m=M.getMinutes(),this.$s=M.getSeconds(),this.$ms=M.getMilliseconds()},A.$utils=function(){return O},A.isValid=function(){return this.$d.toString()!==y},A.isSame=function(M,L){var k=x(M);return this.startOf(L)<=k&&k<=this.endOf(L)},A.isAfter=function(M,L){return x(M)<this.startOf(L)},A.isBefore=function(M,L){return this.endOf(L)<x(M)},A.$g=function(M,L,k){return O.u(M)?this[L]:this.set(k,M)},A.unix=function(){return Math.floor(this.valueOf()/1e3)},A.valueOf=function(){return this.$d.getTime()},A.startOf=function(M,L){var k=this,I=!!O.u(L)||L,K=O.p(M),q=function(le,ce){var re=O.w(k.$u?Date.UTC(k.$y,ce,le):new Date(k.$y,ce,le),k);return I?re:re.endOf(f)},z=function(le,ce){return O.w(k.toDate()[le].apply(k.toDate("s"),(I?[0,0,0,0]:[23,59,59,999]).slice(ce)),k)},Y=this.$W,Z=this.$M,J=this.$D,$="set"+(this.$u?"UTC":"");switch(K){case w:return I?q(1,0):q(31,11);case d:return I?q(1,Z):q(0,Z+1);case p:var P=this.$locale().weekStart||0,ee=(Y<P?Y+7:Y)-P;return q(I?J-ee:J+(6-ee),Z);case f:case m:return z($+"Hours",0);case u:return z($+"Minutes",1);case c:return z($+"Seconds",2);case a:return z($+"Milliseconds",3);default:return this.clone()}},A.endOf=function(M){return this.startOf(M,!1)},A.$set=function(M,L){var k,I=O.p(M),K="set"+(this.$u?"UTC":""),q=(k={},k[f]=K+"Date",k[m]=K+"Date",k[d]=K+"Month",k[w]=K+"FullYear",k[u]=K+"Hours",k[c]=K+"Minutes",k[a]=K+"Seconds",k[i]=K+"Milliseconds",k)[I],z=I===f?this.$D+(L-this.$W):L;if(I===d||I===w){var Y=this.clone().set(m,1);Y.$d[q](z),Y.init(),this.$d=Y.set(m,Math.min(this.$D,Y.daysInMonth())).$d}else q&&this.$d[q](z);return this.init(),this},A.set=function(M,L){return this.clone().$set(M,L)},A.get=function(M){return this[O.p(M)]()},A.add=function(M,L){var k,I=this;M=Number(M);var K=O.p(L),q=function(Z){var J=x(I);return O.w(J.date(J.date()+Math.round(Z*M)),I)};if(K===d)return this.set(d,this.$M+M);if(K===w)return this.set(w,this.$y+M);if(K===f)return q(1);if(K===p)return q(7);var z=(k={},k[c]=s,k[u]=o,k[a]=n,k)[K]||1,Y=this.$d.getTime()+M*z;return O.w(Y,this)},A.subtract=function(M,L){return this.add(-1*M,L)},A.format=function(M){var L=this,k=this.$locale();if(!this.isValid())return k.invalidDate||y;var I=M||"YYYY-MM-DDTHH:mm:ssZ",K=O.z(this),q=this.$H,z=this.$m,Y=this.$M,Z=k.weekdays,J=k.months,$=function(ce,re,X,we){return ce&&(ce[re]||ce(L,I))||X[re].slice(0,we)},P=function(ce){return O.s(q%12||12,ce,"0")},ee=k.meridiem||function(ce,re,X){var we=ce<12?"AM":"PM";return X?we.toLowerCase():we},le={YY:String(this.$y).slice(-2),YYYY:O.s(this.$y,4,"0"),M:Y+1,MM:O.s(Y+1,2,"0"),MMM:$(k.monthsShort,Y,J,3),MMMM:$(J,Y),D:this.$D,DD:O.s(this.$D,2,"0"),d:String(this.$W),dd:$(k.weekdaysMin,this.$W,Z,2),ddd:$(k.weekdaysShort,this.$W,Z,3),dddd:Z[this.$W],H:String(q),HH:O.s(q,2,"0"),h:P(1),hh:P(2),a:ee(q,z,!0),A:ee(q,z,!1),m:String(z),mm:O.s(z,2,"0"),s:String(this.$s),ss:O.s(this.$s,2,"0"),SSS:O.s(this.$ms,3,"0"),Z:K};return I.replace(v,function(ce,re){return re||le[ce]||K.replace(":","")})},A.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},A.diff=function(M,L,k){var I,K=O.p(L),q=x(M),z=(q.utcOffset()-this.utcOffset())*s,Y=this-q,Z=O.m(this,q);return Z=(I={},I[w]=Z/12,I[d]=Z,I[g]=Z/3,I[p]=(Y-z)/6048e5,I[f]=(Y-z)/864e5,I[u]=Y/o,I[c]=Y/s,I[a]=Y/n,I)[K]||Y,k?Z:O.a(Z)},A.daysInMonth=function(){return this.endOf(d).$D},A.$locale=function(){return D[this.$L]},A.locale=function(M,L){if(!M)return this.$L;var k=this.clone(),I=S(M,L,!0);return I&&(k.$L=I),k},A.clone=function(){return O.w(this.$d,this)},A.toDate=function(){return new Date(this.valueOf())},A.toJSON=function(){return this.isValid()?this.toISOString():null},A.toISOString=function(){return this.$d.toISOString()},A.toString=function(){return this.$d.toUTCString()},F}(),H=T.prototype;return x.prototype=H,[["$ms",i],["$s",a],["$m",c],["$H",u],["$W",f],["$M",d],["$y",w],["$D",m]].forEach(function(F){H[F[1]]=function(A){return this.$g(A,F[0],F[1])}}),x.extend=function(F,A){return F.$i||(F(A,T,x),F.$i=!0),x},x.locale=S,x.isDayjs=N,x.unix=function(F){return x(1e3*F)},x.en=D[E],x.Ls=D,x.p={},x})})(rn);const Xe=rn.exports,Ri=t=>{console.log("Avatar Props",t);const{ooui:r,value:n}=t;if(!n)return null;let s=n;r.selectionValues.size?s=r.selectionValues.get(n):Array.isArray(n)&&(s=n[1]);const o=s.toString().split(" ").filter(a=>a.length>1).slice(0,3).map(a=>a[0].toUpperCase()).join(""),i=zt(s);return e.jsx(h.Tooltip,{title:s,children:e.jsx(h.Avatar,{alt:s,style:{backgroundColor:i},children:o})})};var nn={exports:{}};(function(t,r){(function(n,s){t.exports=s()})(et,function(){return function(n,s){s.prototype.weekday=function(o){var i=this.$locale().weekStart||0,a=this.$W,c=(a<i?a+7:a)-i;return this.$utils().u(o)?c:this.subtract(c,"day").add(o,"day")}}})})(nn);const ea=nn.exports;var on={exports:{}};(function(t,r){(function(n,s){t.exports=s()})(et,function(){return function(n,s,o){var i=s.prototype,a=function(d){return d&&(d.indexOf?d:d.s)},c=function(d,g,w,m,y){var C=d.name?d:d.$locale(),v=a(C[g]),V=a(C[w]),_=v||V.map(function(E){return E.slice(0,m)});if(!y)return _;var b=C.weekStart;return _.map(function(E,D){return _[(D+(b||0))%7]})},u=function(){return o.Ls[o.locale()]},f=function(d,g){return d.formats[g]||function(w){return w.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(m,y,C){return y||C.slice(1)})}(d.formats[g.toUpperCase()])},p=function(){var d=this;return{months:function(g){return g?g.format("MMMM"):c(d,"months")},monthsShort:function(g){return g?g.format("MMM"):c(d,"monthsShort","months",3)},firstDayOfWeek:function(){return d.$locale().weekStart||0},weekdays:function(g){return g?g.format("dddd"):c(d,"weekdays")},weekdaysMin:function(g){return g?g.format("dd"):c(d,"weekdaysMin","weekdays",2)},weekdaysShort:function(g){return g?g.format("ddd"):c(d,"weekdaysShort","weekdays",3)},longDateFormat:function(g){return f(d.$locale(),g)},meridiem:this.$locale().meridiem,ordinal:this.$locale().ordinal}};i.localeData=function(){return p.bind(this)()},o.localeData=function(){var d=u();return{firstDayOfWeek:function(){return d.weekStart||0},weekdays:function(){return o.weekdays()},weekdaysShort:function(){return o.weekdaysShort()},weekdaysMin:function(){return o.weekdaysMin()},months:function(){return o.months()},monthsShort:function(){return o.monthsShort()},longDateFormat:function(g){return f(d,g)},meridiem:d.meridiem,ordinal:d.ordinal}},o.months=function(){return c(u(),"months")},o.monthsShort=function(){return c(u(),"monthsShort","months",3)},o.weekdays=function(d){return c(u(),"weekdays",null,null,d)},o.weekdaysShort=function(d){return c(u(),"weekdaysShort","weekdays",3,d)},o.weekdaysMin=function(d){return c(u(),"weekdaysMin","weekdays",2,d)}}})})(on);const ta=on.exports,{useToken:ra}=h.theme;Xe.extend(ea),Xe.extend(ta);const Je={date:{placeholder:"__/__/____",dateDisplayFormat:"DD/MM/YYYY",dateInternalFormat:"YYYY-MM-DD"},time:{placeholder:"__/__/____ __:__:__",dateDisplayFormat:"DD/MM/YYYY HH:mm:ss",dateInternalFormat:"YYYY-MM-DD HH:mm:ss"}},sn=t=>{const{ooui:r,showTime:n=!1}=t,{required:s}=r;return e.jsx(me,{required:s,...t,children:e.jsx(na,{ooui:r,showTime:n})})},na=t=>{const{value:r,onChange:n,ooui:s,showTime:o}=t,{id:i,readOnly:a,required:c}=s,{token:u}=ra(),f=c&&!a?{backgroundColor:u.colorPrimaryBg}:void 0,p=o?"time":"date",d=y=>{n==null||n(y)},g=y=>{if(y===null){d(void 0);return}d(y.format(Je[p].dateInternalFormat))},w=o?{defaultValue:Xe("00:00:00","HH:mm:ss")}:void 0,m=r?Xe(r,Je[p].dateInternalFormat):void 0;return e.jsx(h.DatePicker,{style:{width:"100%",...f},placeholder:o?Je.time.placeholder:Je.date.placeholder,disabled:a,id:i,picker:o?"time":"date",showTime:w,format:Je[p].dateDisplayFormat,value:m,onChange:g})},oa=t=>e.jsx("div",{style:{display:"flex",justifyContent:"center",alignContent:"center"},children:e.jsx(h.Checkbox,{checked:t,disabled:!0})}),sa=t=>e.jsx(Xi,{m2oField:t}),ia=t=>e.jsx(Pt.Interweave,{content:t==null?void 0:t.replace(/(?:\r\n|\r|\n)/g,"<br>")}),aa=t=>{if(!t||t&&t.length===0)return e.jsx(e.Fragment,{});const r=Xe(t,Je.date.dateInternalFormat).format(Je.date.dateDisplayFormat);return e.jsx(e.Fragment,{children:r})},la=t=>{if(!t||t&&t.length===0)return e.jsx(e.Fragment,{});const r=Xe(t,Je.time.dateInternalFormat).format(Je.time.dateDisplayFormat);return e.jsx(e.Fragment,{children:r})},an=t=>{const r=Array.isArray(t==null?void 0:t.items)?t==null?void 0:t.items.length:0;return e.jsx(e.Fragment,{children:`( ${r} )`})},ca=t=>e.jsx(en,{value:t}),da=t=>e.jsx(e.Fragment,{children:Qr(t)}),ln=t=>e.jsx("div",{style:{textAlign:"right"},children:t}),ua=t=>e.jsx("img",{src:`data:image/*;base64,${t}`,style:{maxWidth:"50px",padding:"5px"}}),fa=(t,r,n,s)=>e.jsx(e.Fragment,{children:t?e.jsx(h.Tag,{color:n.colors[t],children:n.selectionValues.get(t)}):null}),ha=(t,r,n,s)=>e.jsx(e.Fragment,{children:n.selectionValues.get(t)}),pa=(t,r,n,s)=>e.jsx(e.Fragment,{children:e.jsx(Qi,{value:t,selectionValues:n.selectionValues,context:s})}),ga=(t,r,n,s)=>e.jsx(Ri,{ooui:n,value:t});function Ct(t){const{page:r=1,limit:n,total:s,treeView:o,results:i,onRequestPageChange:a,loading:c,onRowClicked:u,showPagination:f=!0,rowSelection:p,scrollY:d,colorsForResults:g={},onChangeSort:w,sorter:m,onFetchChildrenForRecord:y,childField:C,rootTree:v=!1,context:V}=t,[_,b]=l.useState([]),[E,D]=l.useState([]),N=l.useRef(!1),S=l.useRef(null),{t:x}=l.useContext(ge),O=l.useRef(n),T=l.useContext(Be),{title:H=void 0,setTitle:F=void 0}=(v?T:{})||{};l.useEffect(()=>{S.current=ot(o);const z=Ys(S.current,{boolean:oa,many2one:sa,text:ia,one2many:an,many2many:an,progressbar:ca,float_time:da,image:ua,integer:ln,float:ln,reference:pa,tag:fa,selection:ha,date:aa,datetime:la,avatar:ga},V);D(z),S.current.string&&H!==S.current.string&&(F==null||F(S.current.string))},[o]),l.useEffect(()=>{N.current=!1;const z=Kr(S.current,i);b(z),O.current=n},[i]);const A=(r-1)*O.current+1,M=A-1+_.length,L=s===void 0?null:s===0?x("no_results"):x("summary").replace("{from}",A==null?void 0:A.toString()).replace("{to}",M==null?void 0:M.toString()).replace("{total}",s==null?void 0:s.toString()),k=()=>!f||o.isExpandable||c?null:s===void 0?e.jsx(h.Spin,{}):e.jsxs(h.Row,{align:"bottom",className:"pb-4",children:[e.jsx(h.Col,{span:12,children:e.jsx(h.Pagination,{total:s,pageSize:O.current===0?s:O.current,current:r,showSizeChanger:!1,onChange:a})}),e.jsx(h.Col,{span:12,className:"text-right",children:L})]});function I(){var $;const Y=S.current.columns.filter(P=>P.sum!==void 0).map(P=>({label:P.sum,field:P.id}));if(!Y||Y.length===0)return null;let Z=[],J=(($=p==null?void 0:p.selectedRowKeys)==null?void 0:$.length)>0?_.filter(P=>p==null?void 0:p.selectedRowKeys.includes(P.id)):_;return Y.forEach(P=>{const ee=J.reduce((le,ce)=>ce[P.field]&&!isNaN(ce[P.field])?le+ce[P.field]:le,0);Z.push(`${P.label}: ${Math.round(ee*100)/100}`)}),e.jsx("div",{className:"p-1 pb-0 pl-2 mt-2 ",children:Z.join(", ")})}let K,q=d;if(S.current!==null){K=zi(E,_,600);const Y=S.current;d&&Y.columns.some(Z=>Z.sum!==void 0)&&(q=d-30)}return S.current===null?e.jsx(h.Spin,{style:{padding:"2rem"}}):e.jsxs("div",{children:[k(),e.jsx(ro.Table,{height:q,columns:K.columns,dataSource:_,loading:c,loadingComponent:e.jsx(h.Spin,{}),onRowStyle:z=>{if(g[z.id])return{color:g[z.id]}},onRowDoubleClick:u,onRowSelectionChange:p==null?void 0:p.onChange,onChangeSort:w,sorter:m,expandableOpts:y?{expandIcon:B.PlusSquareOutlined,collapseIcon:B.MinusSquareOutlined,loadingIcon:B.LoadingOutlined,onFetchChildrenForRecord:y,childField:C}:void 0}),I()]})}function ma(t,r){const{model:n,formView:s,treeView:o,onRowClicked:i,nameSearch:a,treeScrollY:c,domain:u=[],visible:f=!0,rootTree:p=!1,parentContext:d={},onChangeSelectedRowKeys:g}=t,[w,m]=l.useState(!1),[y,C]=l.useState(!1),v=l.useRef(!1),[V,_]=l.useState(),[b,E]=l.useState(),[D,N]=l.useState(),[S,x]=l.useState(),[O,T]=l.useState(200),H=l.useRef(),{height:F}=xt(),A=l.useContext(lt),{processAction:M}=A||{},L=l.useContext(Be),{setResults:k=void 0,setCurrentItemIndex:I=void 0,currentId:K=void 0,results:q=void 0,selectedRowItems:z=void 0,setSelectedRowItems:Y=void 0,searchParams:Z=[],setSearchParams:J=void 0,searchVisible:$=!0,setSearchVisible:P=void 0,sorter:ee=void 0,setSorter:le=void 0,setTotalItems:ce=void 0,setSearchTreeNameSearch:re=void 0,setTreeIsLoading:X=void 0,searchValues:we={},setSearchValues:Ce=void 0,limit:Ve=wt,setLimit:fe=void 0}=(p?L:{})||{},{submit:oe,clear:Se,fetchResults:ye,tableRefreshing:xe,searchFilterLoading:Ee,searchError:ke,page:He,offset:Me,getResults:R,requestPageChange:ae,changeSort:he,fetchChildrenForRecord:Oe,colorsForResults:ue,totalItems:Ae}=zr({model:V,setSearchTreeNameSearch:re,setSelectedRowItems:Y,setSearchParams:J,setSearchValues:Ce,searchParams:Z,setSearchVisible:P,setTreeIsLoading:X,nameSearch:a,searchNameGetDoneRef:v,context:d,formView:D,treeView:b,sorter:ee,setSorter:le,setCurrentItemIndex:I,setResultsActionView:k,resultsActionView:q,domain:u,currentId:K,setActionViewTotalItems:ce,limit:Ve,setLimit:fe});l.useImperativeHandle(r,()=>({refreshResults:()=>{v.current=!1,ye()},getFields:()=>b==null?void 0:b.fields,getDomain:()=>u})),l.useEffect(()=>{!y||f&&(v.current=!1,ye())},[He,Me,y,f,a]);const De=async()=>{C(!1),m(!0),x(void 0),X==null||X(!0);try{await Ze(),C(!0)}catch(pe){x(pe)}finally{m(!1),X==null||X(!1)}},Ze=async()=>{_(n);let pe=s;s||(pe=await W.getHandler().getView({model:n,type:"form",context:d}));let $e=o;o||($e=await W.getHandler().getView({model:n,type:"tree",context:d})),N(pe),E($e)};l.useEffect(()=>{De()},[n]);const Ke=pe=>{fe==null||fe(pe)},Ge=async pe=>{const{id:$e}=pe;H.current||(H.current=await W.getHandler().treeButOpen({id:b.view_id,model:V,context:d}));const Ue=H.current[0][2];await(M==null?void 0:M({actionData:Ue,fields:b.fields,values:{active_id:$e,...pe},context:d}))},Q=async pe=>{const{id:$e}=pe;if(b!=null&&b.isExpandable){try{await Ge(pe)}catch(Ue){Ie(Ue)}return}i({id:$e,model:V,formView:D,treeView:b})};function de(pe){const $e=R().filter(Ue=>pe.includes(Ue.id));Y==null||Y($e),g==null||g(pe)}function Te(){return b!=null&&b.isExpandable?F-160:F-(O+210)}const ie=()=>!b||!D?null:e.jsxs(e.Fragment,{children:[e.jsx(Xt,{fields:{...b.fields,...D.fields},searchFields:Wr([D.search_fields,b.search_fields]),formXml:D.arch,onClear:Se,limit:Ve,offset:Me,isSearching:Ee,onSubmit:oe,onLimitChange:Ke,setSearchFilterHeight:T,searchError:ke,searchVisible:$,searchValues:we}),e.jsx(Ct,{context:d,total:Ae,limit:Ve,page:He,treeView:b,results:R(),onRequestPageChange:ae,loading:xe,onRowClicked:Q,scrollY:c||Te(),colorsForResults:ue,rowSelection:{selectedRowKeys:z==null?void 0:z.map(pe=>pe.id),onChange:de},sorter:ee,onChangeSort:he,onFetchChildrenForRecord:b.isExpandable?Oe:void 0,childField:b.field_parent,rootTree:p})]}),ve=S||ke;return ve?e.jsx(h.Alert,{className:"mt-10",message:ve,type:"error",banner:!0}):e.jsx("div",{style:f?{}:{display:"none"},children:w?e.jsx(h.Spin,{}):ie()})}const Rt=l.forwardRef(ma),er=t=>{const{visible:r,onCloseModal:n,onSelectValues:s,model:o,nameSearch:i,domain:a,context:c={}}=t,[u,f]=l.useState(!1),{modalWidth:p,modalHeight:d}=xt(),{t:g}=l.useContext(ge),[w,m]=l.useState([]),y=async()=>{await new Promise(_=>setTimeout(_,5)),n()},C=async _=>{const{id:b}=_;s([b])};function v(){if(w.length===0){y();return}s(w)}const V=()=>e.jsxs(e.Fragment,{children:[e.jsx(Rt,{model:o,nameSearch:i,onRowClicked:C,treeScrollY:d*.3,domain:a,parentContext:c,onChangeSelectedRowKeys:_=>{m(_)}}),e.jsx(h.Divider,{}),e.jsx(h.Row,{justify:"end",children:e.jsxs(h.Space,{children:[e.jsx(h.Button,{icon:e.jsx(B.FileAddOutlined,{}),onClick:()=>{f(!0)},children:g("new")}),e.jsx(h.Button,{icon:e.jsx(B.CheckOutlined,{}),onClick:()=>{v()},type:"primary",children:g("ok")}),e.jsx(h.Button,{icon:e.jsx(B.CloseOutlined,{}),onClick:y,children:g("cancel")})]})})]});return e.jsxs(e.Fragment,{children:[e.jsx(h.Modal,{title:g("search"),centered:!0,width:p,open:r&&!u,closable:!0,onCancel:y,footer:null,destroyOnClose:!0,maskClosable:!1,children:V()}),e.jsx(dt,{model:o,visible:u,parentContext:c,onSubmitSucceed:_=>{f(!1),y(),s([_])},onCancel:()=>{f(!1),y()}})]})},{error:ya}=h.Modal,_t=t=>{ya({title:"Error",icon:e.jsx(B.ExclamationCircleOutlined,{}),centered:!0,content:t})},{defaultAlgorithm:wa,defaultSeed:va}=h.theme,cn=wa(va),dn=t=>{const{ooui:r}=t,{required:n}=r,s=async(o,i)=>{if(!i)throw new Error;if(!Array.isArray(i))throw new Error;if(Array.isArray(i)&&!i[0])throw new Error};return e.jsx(me,{required:n,type:"array",validator:s,...t,children:e.jsx(un,{ooui:r})})},un=t=>{const{value:r,onChange:n,ooui:s}=t,{required:o,relation:i,readOnly:a,context:c,id:u,domain:f}=s,p=o&&!a?{backgroundColor:cn.colorPrimaryBg}:void 0,[d,g]=l.useState(!1),[w,m]=l.useState(!1),[y,C]=l.useState(!1),[v,V]=l.useState(),_=l.useRef(!1),[b,E]=l.useState(""),D=l.useRef(),N=l.useContext(_e),{domain:S,getValues:x,getFields:O,getContext:T,elementHasLostFocus:H}=N||{},F=l.useRef([]),[A,M]=l.useState([]),L=r&&r[0]||void 0,k=r&&r[1]||"";l.useEffect(()=>{!Array.isArray(r)&&r&&Y(r)},[r]),l.useEffect(()=>{L&&k.length===0?Y(L):L&&k.length>0?E(k):!L&&!k&&E(D.current||"")},[r]);const I=P=>{n==null||n(P),H==null||H()},K=P=>{D.current=P.target.value,I([void 0,""])},q=async()=>{if(!y&&b!==k){if(await new Promise(P=>setTimeout(P,100)),_.current){I([void 0,""]);return}C(!0);try{if(F.current&&F.current.length>0)z(D.current);else{const P=await W.getHandler().nameSearch({model:i,payload:D.current,context:{...T==null?void 0:T(),...c}});P.length===1?(D.current=void 0,I(P[0])):z(D.current)}}catch(P){_t(P)}finally{C(!1)}}},z=async P=>{if(await Z(),F.current&&F.current.length>0){const ee=await W.getHandler().searchAllIds({params:F.current,model:i,context:{...T==null?void 0:T(),...c},totalItems:2});ee.length===1?Y(ee[0]):(V(P),g(!0));return}V(P),g(!0)},Y=async P=>{C(!0);try{const ee=await W.getHandler().execute({action:"name_get",payload:[P],model:i,context:{...T==null?void 0:T(),...c}});I([P,ee[0][1]])}catch(ee){_t(ee)}finally{C(!1)}};async function Z(){f&&(F.current=await W.getHandler().evalDomain({domain:f,values:at({fields:O(),values:x()}),fields:O(),context:T()})),S&&S.length>0&&(F.current=F.current.concat(se.transformDomainForChildWidget({domain:S,widgetFieldName:u}))),M(F.current)}async function J(P){P.keyCode===13?(P.preventDefault(),P.stopPropagation(),await q()):P.code==="Backspace"&&L!==void 0&&(P.preventDefault(),P.stopPropagation(),I([void 0,""]))}const $=o&&!a?Ca:h.Input;return e.jsxs(h.Row,{gutter:8,wrap:!1,children:[e.jsx(h.Col,{flex:"auto",children:e.jsx($,{type:"text",value:b,disabled:a,onChange:K,style:p,onBlur:q,onKeyDown:J,suffix:e.jsx(Qt,{id:L,model:i,context:{...T==null?void 0:T(),...c}})})}),e.jsx(h.Col,{flex:"32px",style:{paddingRight:0},children:e.jsx(h.Button,{icon:e.jsx(B.FolderOpenOutlined,{}),disabled:L===void 0||k===""||b===void 0,onClick:()=>{m(!0)},style:{borderTopRightRadius:0,borderBottomRightRadius:0},tabIndex:-1})}),e.jsx(h.Col,{flex:"32px",style:{paddingLeft:0},children:e.jsx(h.Button,{icon:y?e.jsx(B.LoadingOutlined,{}):e.jsx(B.SearchOutlined,{}),disabled:a||y,onClick:()=>{_.current=!0,z(k)},style:{borderTopLeftRadius:0,borderBottomLeftRadius:0},tabIndex:-1})}),e.jsx(er,{model:i,domain:A,context:{...T==null?void 0:T(),...c},visible:d,nameSearch:L?void 0:v,onSelectValues:P=>{g(!1),Y(P[0]),_.current=!1,D.current=void 0},onCloseModal:()=>{g(!1),_.current=!1}}),e.jsx(dt,{model:i,parentContext:{...T==null?void 0:T(),...c},id:r&&r[0],visible:w,onSubmitSucceed:P=>{m(!1),Y(P)},onCancel:()=>{m(!1)},mustClearAfterSave:!0,readOnly:a})]})},Ca=pt.default(h.Input)`
|
|
31
|
+
`,tn=t=>{const{visible:r,onCancel:n,items:s=[],onItemClicked:o}=t,{t:i}=l.useContext(ge);return e.jsx(h.Modal,{title:i("selectAction"),centered:!0,open:r,footer:null,destroyOnClose:!0,onCancel:n,maskClosable:!1,children:e.jsx(h.Space,{direction:"vertical",className:"w-full",children:s.map(a=>e.jsx(h.Button,{className:"w-full",onClick:()=>{o(a)},children:a.name}))})})},Qt=t=>{var S,x;const{id:r,model:n,context:s={}}=t,[o,i]=l.useState(!1),[a,c]=l.useState(!1),[u,f]=l.useState(!1),[p,d]=l.useState(),[g,w]=l.useState(),{t:m}=l.useContext(ge),y=l.useContext(Ye),{openRelate:C}=y||{},v=l.useContext(lt),{processAction:V}=v||{};if(!r)return null;async function _(){f(!0);try{const O=await W.getHandler().getView({model:n,type:"form",context:s});d(O);const{fields:T,arch:H}=O,F=(await W.getHandler().readObjects({model:n,ids:[r],fields:T,context:s}))[0];w({...it(F,T),active_id:r}),f(!1)}catch(O){f(!1),Ie(O);return}}function b(){var T;if(u)return e.jsx(h.Menu,{children:e.jsx("div",{style:{padding:15},children:e.jsx(h.Spin,{})})});if(!p||!p.toolbar)return e.jsx(h.Menu,{});const O=(T=p==null?void 0:p.toolbar)==null?void 0:T.relate.map(H=>e.jsx(h.Menu.Item,{children:H.name},H.id));return e.jsx(h.Menu,{onClick:E,children:[e.jsx(h.Menu.Item,{disabled:!p.toolbar.action||p.toolbar.action.length===0,icon:e.jsx(B.ThunderboltOutlined,{}),children:m("action")},"action"),e.jsx(h.Menu.Item,{disabled:!p.toolbar.print||p.toolbar.print.length===0,icon:e.jsx(B.PrinterOutlined,{}),children:m("report")},"print"),e.jsx(h.Menu.Divider,{}),e.jsx(h.Menu.ItemGroup,{title:e.jsxs(e.Fragment,{children:[e.jsx(B.EnterOutlined,{})," ",e.jsxs("span",{children:[" ",m("related")]})]}),children:O})]})}function E(O){if(O.key==="action")i(!0);else if(O.key==="print")c(!0);else{const T=p.toolbar.relate.find(H=>H.id===parseInt(O.key));if(!T)return;C({relateData:T,values:g,fields:p.fields,action_id:T.id,action_type:T.type})}}function D(O){i(!1),V==null||V({actionData:O,values:g,fields:p.fields,context:{active_id:r,active_ids:[r]}})}function N(O){c(!1),V==null||V({actionData:{...O,datas:{...O.datas||{},ids:[r]}},values:g,fields:p.fields})}return e.jsxs(e.Fragment,{children:[e.jsx(h.Dropdown,{overlay:b(),trigger:["click"],children:e.jsx(B.RightCircleOutlined,{style:{color:"rgba(0,0,0,.45)"},onClick:O=>{O.preventDefault(),_()}})}),e.jsx(tn,{visible:o,items:(S=p==null?void 0:p.toolbar)==null?void 0:S.action,onItemClicked:D,onCancel:()=>i(!1)}),e.jsx(tn,{visible:a,items:(x=p==null?void 0:p.toolbar)==null?void 0:x.print,onItemClicked:N,onCancel:()=>c(!1)})]})},Xi=t=>{const{m2oField:r}=t;return r?e.jsxs(h.Space,{children:[e.jsx(e.Fragment,{children:r.value}),e.jsx(Qt,{id:r.id,model:r.model})]}):e.jsx(e.Fragment,{})},Qi=t=>{const{value:r,context:n,selectionValues:s}=t,[o,i]=l.useState(),[a,c]=l.useState(!1),[u,f]=r?r.split(","):[],p=parseInt(f),d=l.useCallback(async()=>{if(!r||r&&o)return;c(!0);const w=await W.getHandler().execute({action:"name_get",payload:[p],model:u,context:n});i(w[0][1]),c(!1)},[r,o]);if(l.useEffect(()=>{d()},[r]),!r&&!a)return e.jsx(e.Fragment,{});if(a)return e.jsx(B.LoadingOutlined,{});const g=s.get(u);return e.jsxs(h.Space,{children:[e.jsx(e.Fragment,{children:`${g}:`}),e.jsx(e.Fragment,{children:o}),e.jsx(Qt,{id:p,model:u})]})};var rn={exports:{}};(function(t,r){(function(n,s){t.exports=s()})(et,function(){var n=1e3,s=6e4,o=36e5,i="millisecond",a="second",c="minute",u="hour",f="day",p="week",d="month",g="quarter",w="year",m="date",y="Invalid Date",C=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,v=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,V={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(F){var A=["th","st","nd","rd"],M=F%100;return"["+F+(A[(M-20)%10]||A[M]||A[0])+"]"}},_=function(F,A,M){var L=String(F);return!L||L.length>=A?F:""+Array(A+1-L.length).join(M)+F},b={s:_,z:function(F){var A=-F.utcOffset(),M=Math.abs(A),L=Math.floor(M/60),k=M%60;return(A<=0?"+":"-")+_(L,2,"0")+":"+_(k,2,"0")},m:function F(A,M){if(A.date()<M.date())return-F(M,A);var L=12*(M.year()-A.year())+(M.month()-A.month()),k=A.clone().add(L,d),I=M-k<0,K=A.clone().add(L+(I?-1:1),d);return+(-(L+(M-k)/(I?k-K:K-k))||0)},a:function(F){return F<0?Math.ceil(F)||0:Math.floor(F)},p:function(F){return{M:d,y:w,w:p,d:f,D:m,h:u,m:c,s:a,ms:i,Q:g}[F]||String(F||"").toLowerCase().replace(/s$/,"")},u:function(F){return F===void 0}},E="en",D={};D[E]=V;var N=function(F){return F instanceof T},S=function F(A,M,L){var k;if(!A)return E;if(typeof A=="string"){var I=A.toLowerCase();D[I]&&(k=I),M&&(D[I]=M,k=I);var K=A.split("-");if(!k&&K.length>1)return F(K[0])}else{var q=A.name;D[q]=A,k=q}return!L&&k&&(E=k),k||!L&&E},x=function(F,A){if(N(F))return F.clone();var M=typeof A=="object"?A:{};return M.date=F,M.args=arguments,new T(M)},O=b;O.l=S,O.i=N,O.w=function(F,A){return x(F,{locale:A.$L,utc:A.$u,x:A.$x,$offset:A.$offset})};var T=function(){function F(M){this.$L=S(M.locale,null,!0),this.parse(M)}var A=F.prototype;return A.parse=function(M){this.$d=function(L){var k=L.date,I=L.utc;if(k===null)return new Date(NaN);if(O.u(k))return new Date;if(k instanceof Date)return new Date(k);if(typeof k=="string"&&!/Z$/i.test(k)){var K=k.match(C);if(K){var q=K[2]-1||0,z=(K[7]||"0").substring(0,3);return I?new Date(Date.UTC(K[1],q,K[3]||1,K[4]||0,K[5]||0,K[6]||0,z)):new Date(K[1],q,K[3]||1,K[4]||0,K[5]||0,K[6]||0,z)}}return new Date(k)}(M),this.$x=M.x||{},this.init()},A.init=function(){var M=this.$d;this.$y=M.getFullYear(),this.$M=M.getMonth(),this.$D=M.getDate(),this.$W=M.getDay(),this.$H=M.getHours(),this.$m=M.getMinutes(),this.$s=M.getSeconds(),this.$ms=M.getMilliseconds()},A.$utils=function(){return O},A.isValid=function(){return this.$d.toString()!==y},A.isSame=function(M,L){var k=x(M);return this.startOf(L)<=k&&k<=this.endOf(L)},A.isAfter=function(M,L){return x(M)<this.startOf(L)},A.isBefore=function(M,L){return this.endOf(L)<x(M)},A.$g=function(M,L,k){return O.u(M)?this[L]:this.set(k,M)},A.unix=function(){return Math.floor(this.valueOf()/1e3)},A.valueOf=function(){return this.$d.getTime()},A.startOf=function(M,L){var k=this,I=!!O.u(L)||L,K=O.p(M),q=function(le,ce){var re=O.w(k.$u?Date.UTC(k.$y,ce,le):new Date(k.$y,ce,le),k);return I?re:re.endOf(f)},z=function(le,ce){return O.w(k.toDate()[le].apply(k.toDate("s"),(I?[0,0,0,0]:[23,59,59,999]).slice(ce)),k)},Y=this.$W,Z=this.$M,J=this.$D,$="set"+(this.$u?"UTC":"");switch(K){case w:return I?q(1,0):q(31,11);case d:return I?q(1,Z):q(0,Z+1);case p:var P=this.$locale().weekStart||0,ee=(Y<P?Y+7:Y)-P;return q(I?J-ee:J+(6-ee),Z);case f:case m:return z($+"Hours",0);case u:return z($+"Minutes",1);case c:return z($+"Seconds",2);case a:return z($+"Milliseconds",3);default:return this.clone()}},A.endOf=function(M){return this.startOf(M,!1)},A.$set=function(M,L){var k,I=O.p(M),K="set"+(this.$u?"UTC":""),q=(k={},k[f]=K+"Date",k[m]=K+"Date",k[d]=K+"Month",k[w]=K+"FullYear",k[u]=K+"Hours",k[c]=K+"Minutes",k[a]=K+"Seconds",k[i]=K+"Milliseconds",k)[I],z=I===f?this.$D+(L-this.$W):L;if(I===d||I===w){var Y=this.clone().set(m,1);Y.$d[q](z),Y.init(),this.$d=Y.set(m,Math.min(this.$D,Y.daysInMonth())).$d}else q&&this.$d[q](z);return this.init(),this},A.set=function(M,L){return this.clone().$set(M,L)},A.get=function(M){return this[O.p(M)]()},A.add=function(M,L){var k,I=this;M=Number(M);var K=O.p(L),q=function(Z){var J=x(I);return O.w(J.date(J.date()+Math.round(Z*M)),I)};if(K===d)return this.set(d,this.$M+M);if(K===w)return this.set(w,this.$y+M);if(K===f)return q(1);if(K===p)return q(7);var z=(k={},k[c]=s,k[u]=o,k[a]=n,k)[K]||1,Y=this.$d.getTime()+M*z;return O.w(Y,this)},A.subtract=function(M,L){return this.add(-1*M,L)},A.format=function(M){var L=this,k=this.$locale();if(!this.isValid())return k.invalidDate||y;var I=M||"YYYY-MM-DDTHH:mm:ssZ",K=O.z(this),q=this.$H,z=this.$m,Y=this.$M,Z=k.weekdays,J=k.months,$=function(ce,re,X,we){return ce&&(ce[re]||ce(L,I))||X[re].slice(0,we)},P=function(ce){return O.s(q%12||12,ce,"0")},ee=k.meridiem||function(ce,re,X){var we=ce<12?"AM":"PM";return X?we.toLowerCase():we},le={YY:String(this.$y).slice(-2),YYYY:O.s(this.$y,4,"0"),M:Y+1,MM:O.s(Y+1,2,"0"),MMM:$(k.monthsShort,Y,J,3),MMMM:$(J,Y),D:this.$D,DD:O.s(this.$D,2,"0"),d:String(this.$W),dd:$(k.weekdaysMin,this.$W,Z,2),ddd:$(k.weekdaysShort,this.$W,Z,3),dddd:Z[this.$W],H:String(q),HH:O.s(q,2,"0"),h:P(1),hh:P(2),a:ee(q,z,!0),A:ee(q,z,!1),m:String(z),mm:O.s(z,2,"0"),s:String(this.$s),ss:O.s(this.$s,2,"0"),SSS:O.s(this.$ms,3,"0"),Z:K};return I.replace(v,function(ce,re){return re||le[ce]||K.replace(":","")})},A.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},A.diff=function(M,L,k){var I,K=O.p(L),q=x(M),z=(q.utcOffset()-this.utcOffset())*s,Y=this-q,Z=O.m(this,q);return Z=(I={},I[w]=Z/12,I[d]=Z,I[g]=Z/3,I[p]=(Y-z)/6048e5,I[f]=(Y-z)/864e5,I[u]=Y/o,I[c]=Y/s,I[a]=Y/n,I)[K]||Y,k?Z:O.a(Z)},A.daysInMonth=function(){return this.endOf(d).$D},A.$locale=function(){return D[this.$L]},A.locale=function(M,L){if(!M)return this.$L;var k=this.clone(),I=S(M,L,!0);return I&&(k.$L=I),k},A.clone=function(){return O.w(this.$d,this)},A.toDate=function(){return new Date(this.valueOf())},A.toJSON=function(){return this.isValid()?this.toISOString():null},A.toISOString=function(){return this.$d.toISOString()},A.toString=function(){return this.$d.toUTCString()},F}(),H=T.prototype;return x.prototype=H,[["$ms",i],["$s",a],["$m",c],["$H",u],["$W",f],["$M",d],["$y",w],["$D",m]].forEach(function(F){H[F[1]]=function(A){return this.$g(A,F[0],F[1])}}),x.extend=function(F,A){return F.$i||(F(A,T,x),F.$i=!0),x},x.locale=S,x.isDayjs=N,x.unix=function(F){return x(1e3*F)},x.en=D[E],x.Ls=D,x.p={},x})})(rn);const Xe=rn.exports,Ri=t=>{console.log("Avatar Props",t);const{ooui:r,value:n}=t;if(!n)return null;let s=n;r.selectionValues.size?s=r.selectionValues.get(n):Array.isArray(n)&&(s=n[1]);const o=s.toString().split(" ").filter(a=>a.length>1).slice(0,3).map(a=>a[0].toUpperCase()).join(""),i=zt(s);return e.jsx(h.Tooltip,{title:s,children:e.jsx(h.Avatar,{alt:s,style:{backgroundColor:i},children:o})})};var nn={exports:{}};(function(t,r){(function(n,s){t.exports=s()})(et,function(){return function(n,s){s.prototype.weekday=function(o){var i=this.$locale().weekStart||0,a=this.$W,c=(a<i?a+7:a)-i;return this.$utils().u(o)?c:this.subtract(c,"day").add(o,"day")}}})})(nn);const ea=nn.exports;var on={exports:{}};(function(t,r){(function(n,s){t.exports=s()})(et,function(){return function(n,s,o){var i=s.prototype,a=function(d){return d&&(d.indexOf?d:d.s)},c=function(d,g,w,m,y){var C=d.name?d:d.$locale(),v=a(C[g]),V=a(C[w]),_=v||V.map(function(E){return E.slice(0,m)});if(!y)return _;var b=C.weekStart;return _.map(function(E,D){return _[(D+(b||0))%7]})},u=function(){return o.Ls[o.locale()]},f=function(d,g){return d.formats[g]||function(w){return w.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(m,y,C){return y||C.slice(1)})}(d.formats[g.toUpperCase()])},p=function(){var d=this;return{months:function(g){return g?g.format("MMMM"):c(d,"months")},monthsShort:function(g){return g?g.format("MMM"):c(d,"monthsShort","months",3)},firstDayOfWeek:function(){return d.$locale().weekStart||0},weekdays:function(g){return g?g.format("dddd"):c(d,"weekdays")},weekdaysMin:function(g){return g?g.format("dd"):c(d,"weekdaysMin","weekdays",2)},weekdaysShort:function(g){return g?g.format("ddd"):c(d,"weekdaysShort","weekdays",3)},longDateFormat:function(g){return f(d.$locale(),g)},meridiem:this.$locale().meridiem,ordinal:this.$locale().ordinal}};i.localeData=function(){return p.bind(this)()},o.localeData=function(){var d=u();return{firstDayOfWeek:function(){return d.weekStart||0},weekdays:function(){return o.weekdays()},weekdaysShort:function(){return o.weekdaysShort()},weekdaysMin:function(){return o.weekdaysMin()},months:function(){return o.months()},monthsShort:function(){return o.monthsShort()},longDateFormat:function(g){return f(d,g)},meridiem:d.meridiem,ordinal:d.ordinal}},o.months=function(){return c(u(),"months")},o.monthsShort=function(){return c(u(),"monthsShort","months",3)},o.weekdays=function(d){return c(u(),"weekdays",null,null,d)},o.weekdaysShort=function(d){return c(u(),"weekdaysShort","weekdays",3,d)},o.weekdaysMin=function(d){return c(u(),"weekdaysMin","weekdays",2,d)}}})})(on);const ta=on.exports,{useToken:ra}=h.theme;Xe.extend(ea),Xe.extend(ta);const Je={date:{placeholder:"__/__/____",dateDisplayFormat:"DD/MM/YYYY",dateInternalFormat:"YYYY-MM-DD"},time:{placeholder:"__/__/____ __:__:__",dateDisplayFormat:"DD/MM/YYYY HH:mm:ss",dateInternalFormat:"YYYY-MM-DD HH:mm:ss"}},sn=t=>{const{ooui:r,showTime:n=!1}=t,{required:s}=r;return e.jsx(me,{required:s,...t,children:e.jsx(na,{ooui:r,showTime:n})})},na=t=>{const{value:r,onChange:n,ooui:s,showTime:o}=t,{id:i,readOnly:a,required:c}=s,{token:u}=ra(),f=c&&!a?{backgroundColor:u.colorPrimaryBg}:void 0,p=o?"time":"date",d=y=>{n==null||n(y)},g=y=>{if(y===null){d(void 0);return}d(y.format(Je[p].dateInternalFormat))},w=o?{defaultValue:Xe("00:00:00","HH:mm:ss")}:void 0,m=r?Xe(r,Je[p].dateInternalFormat):void 0;return e.jsx(h.DatePicker,{style:{width:"100%",...f},placeholder:o?Je.time.placeholder:Je.date.placeholder,disabled:a,id:i,picker:"date",showTime:w,format:Je[p].dateDisplayFormat,value:m,onChange:g})},oa=t=>e.jsx("div",{style:{display:"flex",justifyContent:"center",alignContent:"center"},children:e.jsx(h.Checkbox,{checked:t,disabled:!0})}),sa=t=>e.jsx(Xi,{m2oField:t}),ia=t=>e.jsx(Pt.Interweave,{content:t==null?void 0:t.replace(/(?:\r\n|\r|\n)/g,"<br>")}),aa=t=>{if(!t||t&&t.length===0)return e.jsx(e.Fragment,{});const r=Xe(t,Je.date.dateInternalFormat).format(Je.date.dateDisplayFormat);return e.jsx(e.Fragment,{children:r})},la=t=>{if(!t||t&&t.length===0)return e.jsx(e.Fragment,{});const r=Xe(t,Je.time.dateInternalFormat).format(Je.time.dateDisplayFormat);return e.jsx(e.Fragment,{children:r})},an=t=>{const r=Array.isArray(t==null?void 0:t.items)?t==null?void 0:t.items.length:0;return e.jsx(e.Fragment,{children:`( ${r} )`})},ca=t=>e.jsx(en,{value:t}),da=t=>e.jsx(e.Fragment,{children:Qr(t)}),ln=t=>e.jsx("div",{style:{textAlign:"right"},children:t}),ua=t=>e.jsx("img",{src:`data:image/*;base64,${t}`,style:{maxWidth:"50px",padding:"5px"}}),fa=(t,r,n,s)=>e.jsx(e.Fragment,{children:t?e.jsx(h.Tag,{color:n.colors[t],children:n.selectionValues.get(t)}):null}),ha=(t,r,n,s)=>e.jsx(e.Fragment,{children:n.selectionValues.get(t)}),pa=(t,r,n,s)=>e.jsx(e.Fragment,{children:e.jsx(Qi,{value:t,selectionValues:n.selectionValues,context:s})}),ga=(t,r,n,s)=>e.jsx(Ri,{ooui:n,value:t});function Ct(t){const{page:r=1,limit:n,total:s,treeView:o,results:i,onRequestPageChange:a,loading:c,onRowClicked:u,showPagination:f=!0,rowSelection:p,scrollY:d,colorsForResults:g={},onChangeSort:w,sorter:m,onFetchChildrenForRecord:y,childField:C,rootTree:v=!1,context:V}=t,[_,b]=l.useState([]),[E,D]=l.useState([]),N=l.useRef(!1),S=l.useRef(null),{t:x}=l.useContext(ge),O=l.useRef(n),T=l.useContext(Be),{title:H=void 0,setTitle:F=void 0}=(v?T:{})||{};l.useEffect(()=>{S.current=ot(o);const z=Ys(S.current,{boolean:oa,many2one:sa,text:ia,one2many:an,many2many:an,progressbar:ca,float_time:da,image:ua,integer:ln,float:ln,reference:pa,tag:fa,selection:ha,date:aa,datetime:la,avatar:ga},V);D(z),S.current.string&&H!==S.current.string&&(F==null||F(S.current.string))},[o]),l.useEffect(()=>{N.current=!1;const z=Kr(S.current,i);b(z),O.current=n},[i]);const A=(r-1)*O.current+1,M=A-1+_.length,L=s===void 0?null:s===0?x("no_results"):x("summary").replace("{from}",A==null?void 0:A.toString()).replace("{to}",M==null?void 0:M.toString()).replace("{total}",s==null?void 0:s.toString()),k=()=>!f||o.isExpandable||c?null:s===void 0?e.jsx(h.Spin,{}):e.jsxs(h.Row,{align:"bottom",className:"pb-4",children:[e.jsx(h.Col,{span:12,children:e.jsx(h.Pagination,{total:s,pageSize:O.current===0?s:O.current,current:r,showSizeChanger:!1,onChange:a})}),e.jsx(h.Col,{span:12,className:"text-right",children:L})]});function I(){var $;const Y=S.current.columns.filter(P=>P.sum!==void 0).map(P=>({label:P.sum,field:P.id}));if(!Y||Y.length===0)return null;let Z=[],J=(($=p==null?void 0:p.selectedRowKeys)==null?void 0:$.length)>0?_.filter(P=>p==null?void 0:p.selectedRowKeys.includes(P.id)):_;return Y.forEach(P=>{const ee=J.reduce((le,ce)=>ce[P.field]&&!isNaN(ce[P.field])?le+ce[P.field]:le,0);Z.push(`${P.label}: ${Math.round(ee*100)/100}`)}),e.jsx("div",{className:"p-1 pb-0 pl-2 mt-2 ",children:Z.join(", ")})}let K,q=d;if(S.current!==null){K=zi(E,_,600);const Y=S.current;d&&Y.columns.some(Z=>Z.sum!==void 0)&&(q=d-30)}return S.current===null?e.jsx(h.Spin,{style:{padding:"2rem"}}):e.jsxs("div",{children:[k(),e.jsx(ro.Table,{height:q,columns:K.columns,dataSource:_,loading:c,loadingComponent:e.jsx(h.Spin,{}),onRowStyle:z=>{if(g[z.id])return{color:g[z.id]}},onRowDoubleClick:u,onRowSelectionChange:p==null?void 0:p.onChange,onChangeSort:w,sorter:m,expandableOpts:y?{expandIcon:B.PlusSquareOutlined,collapseIcon:B.MinusSquareOutlined,loadingIcon:B.LoadingOutlined,onFetchChildrenForRecord:y,childField:C}:void 0}),I()]})}function ma(t,r){const{model:n,formView:s,treeView:o,onRowClicked:i,nameSearch:a,treeScrollY:c,domain:u=[],visible:f=!0,rootTree:p=!1,parentContext:d={},onChangeSelectedRowKeys:g}=t,[w,m]=l.useState(!1),[y,C]=l.useState(!1),v=l.useRef(!1),[V,_]=l.useState(),[b,E]=l.useState(),[D,N]=l.useState(),[S,x]=l.useState(),[O,T]=l.useState(200),H=l.useRef(),{height:F}=xt(),A=l.useContext(lt),{processAction:M}=A||{},L=l.useContext(Be),{setResults:k=void 0,setCurrentItemIndex:I=void 0,currentId:K=void 0,results:q=void 0,selectedRowItems:z=void 0,setSelectedRowItems:Y=void 0,searchParams:Z=[],setSearchParams:J=void 0,searchVisible:$=!0,setSearchVisible:P=void 0,sorter:ee=void 0,setSorter:le=void 0,setTotalItems:ce=void 0,setSearchTreeNameSearch:re=void 0,setTreeIsLoading:X=void 0,searchValues:we={},setSearchValues:Ce=void 0,limit:Ve=wt,setLimit:fe=void 0}=(p?L:{})||{},{submit:oe,clear:Se,fetchResults:ye,tableRefreshing:xe,searchFilterLoading:Ee,searchError:ke,page:He,offset:Me,getResults:R,requestPageChange:ae,changeSort:he,fetchChildrenForRecord:Oe,colorsForResults:ue,totalItems:Ae}=zr({model:V,setSearchTreeNameSearch:re,setSelectedRowItems:Y,setSearchParams:J,setSearchValues:Ce,searchParams:Z,setSearchVisible:P,setTreeIsLoading:X,nameSearch:a,searchNameGetDoneRef:v,context:d,formView:D,treeView:b,sorter:ee,setSorter:le,setCurrentItemIndex:I,setResultsActionView:k,resultsActionView:q,domain:u,currentId:K,setActionViewTotalItems:ce,limit:Ve,setLimit:fe});l.useImperativeHandle(r,()=>({refreshResults:()=>{v.current=!1,ye()},getFields:()=>b==null?void 0:b.fields,getDomain:()=>u})),l.useEffect(()=>{!y||f&&(v.current=!1,ye())},[He,Me,y,f,a]);const De=async()=>{C(!1),m(!0),x(void 0),X==null||X(!0);try{await Ze(),C(!0)}catch(pe){x(pe)}finally{m(!1),X==null||X(!1)}},Ze=async()=>{_(n);let pe=s;s||(pe=await W.getHandler().getView({model:n,type:"form",context:d}));let $e=o;o||($e=await W.getHandler().getView({model:n,type:"tree",context:d})),N(pe),E($e)};l.useEffect(()=>{De()},[n]);const Ke=pe=>{fe==null||fe(pe)},Ge=async pe=>{const{id:$e}=pe;H.current||(H.current=await W.getHandler().treeButOpen({id:b.view_id,model:V,context:d}));const Ue=H.current[0][2];await(M==null?void 0:M({actionData:Ue,fields:b.fields,values:{active_id:$e,...pe},context:d}))},Q=async pe=>{const{id:$e}=pe;if(b!=null&&b.isExpandable){try{await Ge(pe)}catch(Ue){Ie(Ue)}return}i({id:$e,model:V,formView:D,treeView:b})};function de(pe){const $e=R().filter(Ue=>pe.includes(Ue.id));Y==null||Y($e),g==null||g(pe)}function Te(){return b!=null&&b.isExpandable?F-160:F-(O+210)}const ie=()=>!b||!D?null:e.jsxs(e.Fragment,{children:[e.jsx(Xt,{fields:{...b.fields,...D.fields},searchFields:Wr([D.search_fields,b.search_fields]),formXml:D.arch,onClear:Se,limit:Ve,offset:Me,isSearching:Ee,onSubmit:oe,onLimitChange:Ke,setSearchFilterHeight:T,searchError:ke,searchVisible:$,searchValues:we}),e.jsx(Ct,{context:d,total:Ae,limit:Ve,page:He,treeView:b,results:R(),onRequestPageChange:ae,loading:xe,onRowClicked:Q,scrollY:c||Te(),colorsForResults:ue,rowSelection:{selectedRowKeys:z==null?void 0:z.map(pe=>pe.id),onChange:de},sorter:ee,onChangeSort:he,onFetchChildrenForRecord:b.isExpandable?Oe:void 0,childField:b.field_parent,rootTree:p})]}),ve=S||ke;return ve?e.jsx(h.Alert,{className:"mt-10",message:ve,type:"error",banner:!0}):e.jsx("div",{style:f?{}:{display:"none"},children:w?e.jsx(h.Spin,{}):ie()})}const Rt=l.forwardRef(ma),er=t=>{const{visible:r,onCloseModal:n,onSelectValues:s,model:o,nameSearch:i,domain:a,context:c={}}=t,[u,f]=l.useState(!1),{modalWidth:p,modalHeight:d}=xt(),{t:g}=l.useContext(ge),[w,m]=l.useState([]),y=async()=>{await new Promise(_=>setTimeout(_,5)),n()},C=async _=>{const{id:b}=_;s([b])};function v(){if(w.length===0){y();return}s(w)}const V=()=>e.jsxs(e.Fragment,{children:[e.jsx(Rt,{model:o,nameSearch:i,onRowClicked:C,treeScrollY:d*.3,domain:a,parentContext:c,onChangeSelectedRowKeys:_=>{m(_)}}),e.jsx(h.Divider,{}),e.jsx(h.Row,{justify:"end",children:e.jsxs(h.Space,{children:[e.jsx(h.Button,{icon:e.jsx(B.FileAddOutlined,{}),onClick:()=>{f(!0)},children:g("new")}),e.jsx(h.Button,{icon:e.jsx(B.CheckOutlined,{}),onClick:()=>{v()},type:"primary",children:g("ok")}),e.jsx(h.Button,{icon:e.jsx(B.CloseOutlined,{}),onClick:y,children:g("cancel")})]})})]});return e.jsxs(e.Fragment,{children:[e.jsx(h.Modal,{title:g("search"),centered:!0,width:p,open:r&&!u,closable:!0,onCancel:y,footer:null,destroyOnClose:!0,maskClosable:!1,children:V()}),e.jsx(dt,{model:o,visible:u,parentContext:c,onSubmitSucceed:_=>{f(!1),y(),s([_])},onCancel:()=>{f(!1),y()}})]})},{error:ya}=h.Modal,_t=t=>{ya({title:"Error",icon:e.jsx(B.ExclamationCircleOutlined,{}),centered:!0,content:t})},{defaultAlgorithm:wa,defaultSeed:va}=h.theme,cn=wa(va),dn=t=>{const{ooui:r}=t,{required:n}=r,s=async(o,i)=>{if(!i)throw new Error;if(!Array.isArray(i))throw new Error;if(Array.isArray(i)&&!i[0])throw new Error};return e.jsx(me,{required:n,type:"array",validator:s,...t,children:e.jsx(un,{ooui:r})})},un=t=>{const{value:r,onChange:n,ooui:s}=t,{required:o,relation:i,readOnly:a,context:c,id:u,domain:f}=s,p=o&&!a?{backgroundColor:cn.colorPrimaryBg}:void 0,[d,g]=l.useState(!1),[w,m]=l.useState(!1),[y,C]=l.useState(!1),[v,V]=l.useState(),_=l.useRef(!1),[b,E]=l.useState(""),D=l.useRef(),N=l.useContext(_e),{domain:S,getValues:x,getFields:O,getContext:T,elementHasLostFocus:H}=N||{},F=l.useRef([]),[A,M]=l.useState([]),L=r&&r[0]||void 0,k=r&&r[1]||"";l.useEffect(()=>{!Array.isArray(r)&&r&&Y(r)},[r]),l.useEffect(()=>{L&&k.length===0?Y(L):L&&k.length>0?E(k):!L&&!k&&E(D.current||"")},[r]);const I=P=>{n==null||n(P),H==null||H()},K=P=>{D.current=P.target.value,I([void 0,""])},q=async()=>{if(!y&&b!==k){if(await new Promise(P=>setTimeout(P,100)),_.current){I([void 0,""]);return}C(!0);try{if(F.current&&F.current.length>0)z(D.current);else{const P=await W.getHandler().nameSearch({model:i,payload:D.current,context:{...T==null?void 0:T(),...c}});P.length===1?(D.current=void 0,I(P[0])):z(D.current)}}catch(P){_t(P)}finally{C(!1)}}},z=async P=>{if(await Z(),F.current&&F.current.length>0){const ee=await W.getHandler().searchAllIds({params:F.current,model:i,context:{...T==null?void 0:T(),...c},totalItems:2});ee.length===1?Y(ee[0]):(V(P),g(!0));return}V(P),g(!0)},Y=async P=>{C(!0);try{const ee=await W.getHandler().execute({action:"name_get",payload:[P],model:i,context:{...T==null?void 0:T(),...c}});I([P,ee[0][1]])}catch(ee){_t(ee)}finally{C(!1)}};async function Z(){f&&(F.current=await W.getHandler().evalDomain({domain:f,values:at({fields:O(),values:x()}),fields:O(),context:T()})),S&&S.length>0&&(F.current=F.current.concat(se.transformDomainForChildWidget({domain:S,widgetFieldName:u}))),M(F.current)}async function J(P){P.keyCode===13?(P.preventDefault(),P.stopPropagation(),await q()):P.code==="Backspace"&&L!==void 0&&(P.preventDefault(),P.stopPropagation(),I([void 0,""]))}const $=o&&!a?Ca:h.Input;return e.jsxs(h.Row,{gutter:8,wrap:!1,children:[e.jsx(h.Col,{flex:"auto",children:e.jsx($,{type:"text",value:b,disabled:a,onChange:K,style:p,onBlur:q,onKeyDown:J,suffix:e.jsx(Qt,{id:L,model:i,context:{...T==null?void 0:T(),...c}})})}),e.jsx(h.Col,{flex:"32px",style:{paddingRight:0},children:e.jsx(h.Button,{icon:e.jsx(B.FolderOpenOutlined,{}),disabled:L===void 0||k===""||b===void 0,onClick:()=>{m(!0)},style:{borderTopRightRadius:0,borderBottomRightRadius:0},tabIndex:-1})}),e.jsx(h.Col,{flex:"32px",style:{paddingLeft:0},children:e.jsx(h.Button,{icon:y?e.jsx(B.LoadingOutlined,{}):e.jsx(B.SearchOutlined,{}),disabled:a||y,onClick:()=>{_.current=!0,z(k)},style:{borderTopLeftRadius:0,borderBottomLeftRadius:0},tabIndex:-1})}),e.jsx(er,{model:i,domain:A,context:{...T==null?void 0:T(),...c},visible:d,nameSearch:L?void 0:v,onSelectValues:P=>{g(!1),Y(P[0]),_.current=!1,D.current=void 0},onCloseModal:()=>{g(!1),_.current=!1}}),e.jsx(dt,{model:i,parentContext:{...T==null?void 0:T(),...c},id:r&&r[0],visible:w,onSubmitSucceed:P=>{m(!1),Y(P)},onCancel:()=>{m(!1)},mustClearAfterSave:!0,readOnly:a})]})},Ca=pt.default(h.Input)`
|
|
32
32
|
.ant-input {
|
|
33
33
|
background-color: ${cn.colorPrimaryBg};
|
|
34
34
|
}
|