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