@syntify/office 0.1.18 → 0.1.19
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.
|
@@ -64,4 +64,4 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
64
64
|
* @license MIT licensed
|
|
65
65
|
*
|
|
66
66
|
* Copyright (C) 2018 Varun A P
|
|
67
|
-
*/var C0=Nu.exports,Ng;function $0(){return Ng||(Ng=1,function(p){(function(E,s){p.exports?p.exports=s():E.Toastify=s()})(C0,function(E){var s=function(_){return new s.lib.init(_)},Q="1.12.0";s.defaults={oldestFirst:!0,text:"Toastify is awesome!",node:void 0,duration:3e3,selector:void 0,callback:function(){},destination:void 0,newWindow:!1,close:!1,gravity:"toastify-top",positionLeft:!1,position:"",backgroundColor:"",avatar:"",className:"",stopOnFocus:!0,onClick:function(){},offset:{x:0,y:0},escapeMarkup:!0,ariaLive:"polite",style:{background:""}},s.lib=s.prototype={toastify:Q,constructor:s,init:function(_){return _||(_={}),this.options={},this.toastElement=null,this.options.text=_.text||s.defaults.text,this.options.node=_.node||s.defaults.node,this.options.duration=_.duration===0?0:_.duration||s.defaults.duration,this.options.selector=_.selector||s.defaults.selector,this.options.callback=_.callback||s.defaults.callback,this.options.destination=_.destination||s.defaults.destination,this.options.newWindow=_.newWindow||s.defaults.newWindow,this.options.close=_.close||s.defaults.close,this.options.gravity=_.gravity==="bottom"?"toastify-bottom":s.defaults.gravity,this.options.positionLeft=_.positionLeft||s.defaults.positionLeft,this.options.position=_.position||s.defaults.position,this.options.backgroundColor=_.backgroundColor||s.defaults.backgroundColor,this.options.avatar=_.avatar||s.defaults.avatar,this.options.className=_.className||s.defaults.className,this.options.stopOnFocus=_.stopOnFocus===void 0?s.defaults.stopOnFocus:_.stopOnFocus,this.options.onClick=_.onClick||s.defaults.onClick,this.options.offset=_.offset||s.defaults.offset,this.options.escapeMarkup=_.escapeMarkup!==void 0?_.escapeMarkup:s.defaults.escapeMarkup,this.options.ariaLive=_.ariaLive||s.defaults.ariaLive,this.options.style=_.style||s.defaults.style,_.backgroundColor&&(this.options.style.background=_.backgroundColor),this},buildToast:function(){if(!this.options)throw"Toastify is not initialized";var _=document.createElement("div");_.className="toastify on "+this.options.className,this.options.position?_.className+=" toastify-"+this.options.position:this.options.positionLeft===!0?(_.className+=" toastify-left",console.warn("Property `positionLeft` will be depreciated in further versions. Please use `position` instead.")):_.className+=" toastify-right",_.className+=" "+this.options.gravity,this.options.backgroundColor&&console.warn('DEPRECATION NOTICE: "backgroundColor" is being deprecated. Please use the "style.background" property.');for(var A in this.options.style)_.style[A]=this.options.style[A];if(this.options.ariaLive&&_.setAttribute("aria-live",this.options.ariaLive),this.options.node&&this.options.node.nodeType===Node.ELEMENT_NODE)_.appendChild(this.options.node);else if(this.options.escapeMarkup?_.innerText=this.options.text:_.innerHTML=this.options.text,this.options.avatar!==""){var z=document.createElement("img");z.src=this.options.avatar,z.className="toastify-avatar",this.options.position=="left"||this.options.positionLeft===!0?_.appendChild(z):_.insertAdjacentElement("afterbegin",z)}if(this.options.close===!0){var Y=document.createElement("button");Y.type="button",Y.setAttribute("aria-label","Close"),Y.className="toast-close",Y.innerHTML="✖",Y.addEventListener("click",(function(tt){tt.stopPropagation(),this.removeElement(this.toastElement),window.clearTimeout(this.toastElement.timeOutValue)}).bind(this));var X=window.innerWidth>0?window.innerWidth:screen.width;(this.options.position=="left"||this.options.positionLeft===!0)&&X>360?_.insertAdjacentElement("afterbegin",Y):_.appendChild(Y)}if(this.options.stopOnFocus&&this.options.duration>0){var Z=this;_.addEventListener("mouseover",function(tt){window.clearTimeout(_.timeOutValue)}),_.addEventListener("mouseleave",function(){_.timeOutValue=window.setTimeout(function(){Z.removeElement(_)},Z.options.duration)})}if(typeof this.options.destination<"u"&&_.addEventListener("click",(function(tt){tt.stopPropagation(),this.options.newWindow===!0?window.open(this.options.destination,"_blank"):window.location=this.options.destination}).bind(this)),typeof this.options.onClick=="function"&&typeof this.options.destination>"u"&&_.addEventListener("click",(function(tt){tt.stopPropagation(),this.options.onClick()}).bind(this)),typeof this.options.offset=="object"){var Nt=k("x",this.options),U=k("y",this.options),V=this.options.position=="left"?Nt:"-"+Nt,ot=this.options.gravity=="toastify-top"?U:"-"+U;_.style.transform="translate("+V+","+ot+")"}return _},showToast:function(){this.toastElement=this.buildToast();var _;if(typeof this.options.selector=="string"?_=document.getElementById(this.options.selector):this.options.selector instanceof HTMLElement||typeof ShadowRoot<"u"&&this.options.selector instanceof ShadowRoot?_=this.options.selector:_=document.body,!_)throw"Root element is not defined";var A=s.defaults.oldestFirst?_.firstChild:_.lastChild;return _.insertBefore(this.toastElement,A),s.reposition(),this.options.duration>0&&(this.toastElement.timeOutValue=window.setTimeout((function(){this.removeElement(this.toastElement)}).bind(this),this.options.duration)),this},hideToast:function(){this.toastElement.timeOutValue&&clearTimeout(this.toastElement.timeOutValue),this.removeElement(this.toastElement)},removeElement:function(_){_.className=_.className.replace(" on",""),window.setTimeout((function(){this.options.node&&this.options.node.parentNode&&this.options.node.parentNode.removeChild(this.options.node),_.parentNode&&_.parentNode.removeChild(_),this.options.callback.call(_),s.reposition()}).bind(this),400)}},s.reposition=function(){for(var _={top:15,bottom:15},A={top:15,bottom:15},z={top:15,bottom:15},Y=document.getElementsByClassName("toastify"),X,Z=0;Z<Y.length;Z++){F(Y[Z],"toastify-top")===!0?X="toastify-top":X="toastify-bottom";var Nt=Y[Z].offsetHeight;X=X.substr(9,X.length-1);var U=15,V=window.innerWidth>0?window.innerWidth:screen.width;V<=360?(Y[Z].style[X]=z[X]+"px",z[X]+=Nt+U):F(Y[Z],"toastify-left")===!0?(Y[Z].style[X]=_[X]+"px",_[X]+=Nt+U):(Y[Z].style[X]=A[X]+"px",A[X]+=Nt+U)}return this};function k(_,A){return A.offset[_]?isNaN(A.offset[_])?A.offset[_]:A.offset[_]+"px":"0px"}function F(_,A){return!_||typeof A!="string"?!1:!!(_.className&&_.className.trim().split(/\s+/gi).indexOf(A)>-1)}return s.lib.init.prototype=s.lib,s})}(Nu)),Nu.exports}$0();var Lu={exports:{}},A0=Lu.exports,Lg;function k0(){return Lg||(Lg=1,function(p,E){(function(s,Q){p.exports=Q()})(A0,function(){var s=1e3,Q=6e4,k=36e5,F="millisecond",_="second",A="minute",z="hour",Y="day",X="week",Z="month",Nt="quarter",U="year",V="date",ot="Invalid Date",tt=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,yt=/\[([^\]]+)]|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,pt={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(N){var S=["th","st","nd","rd"],b=N%100;return"["+N+(S[(b-20)%10]||S[b]||S[0])+"]"}},Ct=function(N,S,b){var C=String(N);return!C||C.length>=S?N:""+Array(S+1-C.length).join(b)+N},Bt={s:Ct,z:function(N){var S=-N.utcOffset(),b=Math.abs(S),C=Math.floor(b/60),w=b%60;return(S<=0?"+":"-")+Ct(C,2,"0")+":"+Ct(w,2,"0")},m:function N(S,b){if(S.date()<b.date())return-N(b,S);var C=12*(b.year()-S.year())+(b.month()-S.month()),w=S.clone().add(C,Z),B=b-w<0,R=S.clone().add(C+(B?-1:1),Z);return+(-(C+(b-w)/(B?w-R:R-w))||0)},a:function(N){return N<0?Math.ceil(N)||0:Math.floor(N)},p:function(N){return{M:Z,y:U,w:X,d:Y,D:V,h:z,m:A,s:_,ms:F,Q:Nt}[N]||String(N||"").toLowerCase().replace(/s$/,"")},u:function(N){return N===void 0}},mt="en",wt={};wt[mt]=pt;var $t="$isDayjsObject",zt=function(N){return N instanceof Mt||!(!N||!N[$t])},ut=function N(S,b,C){var w;if(!S)return mt;if(typeof S=="string"){var B=S.toLowerCase();wt[B]&&(w=B),b&&(wt[B]=b,w=B);var R=S.split("-");if(!w&&R.length>1)return N(R[0])}else{var K=S.name;wt[K]=S,w=K}return!C&&w&&(mt=w),w||!C&&mt},D=function(N,S){if(zt(N))return N.clone();var b=typeof S=="object"?S:{};return b.date=N,b.args=arguments,new Mt(b)},L=Bt;L.l=ut,L.i=zt,L.w=function(N,S){return D(N,{locale:S.$L,utc:S.$u,x:S.$x,$offset:S.$offset})};var Mt=function(){function N(b){this.$L=ut(b.locale,null,!0),this.parse(b),this.$x=this.$x||b.x||{},this[$t]=!0}var S=N.prototype;return S.parse=function(b){this.$d=function(C){var w=C.date,B=C.utc;if(w===null)return new Date(NaN);if(L.u(w))return new Date;if(w instanceof Date)return new Date(w);if(typeof w=="string"&&!/Z$/i.test(w)){var R=w.match(tt);if(R){var K=R[2]-1||0,ct=(R[7]||"0").substring(0,3);return B?new Date(Date.UTC(R[1],K,R[3]||1,R[4]||0,R[5]||0,R[6]||0,ct)):new Date(R[1],K,R[3]||1,R[4]||0,R[5]||0,R[6]||0,ct)}}return new Date(w)}(b),this.init()},S.init=function(){var b=this.$d;this.$y=b.getFullYear(),this.$M=b.getMonth(),this.$D=b.getDate(),this.$W=b.getDay(),this.$H=b.getHours(),this.$m=b.getMinutes(),this.$s=b.getSeconds(),this.$ms=b.getMilliseconds()},S.$utils=function(){return L},S.isValid=function(){return this.$d.toString()!==ot},S.isSame=function(b,C){var w=D(b);return this.startOf(C)<=w&&w<=this.endOf(C)},S.isAfter=function(b,C){return D(b)<this.startOf(C)},S.isBefore=function(b,C){return this.endOf(C)<D(b)},S.$g=function(b,C,w){return L.u(b)?this[C]:this.set(w,b)},S.unix=function(){return Math.floor(this.valueOf()/1e3)},S.valueOf=function(){return this.$d.getTime()},S.startOf=function(b,C){var w=this,B=!!L.u(C)||C,R=L.p(b),K=function(Ht,Lt){var qt=L.w(w.$u?Date.UTC(w.$y,Lt,Ht):new Date(w.$y,Lt,Ht),w);return B?qt:qt.endOf(Y)},ct=function(Ht,Lt){return L.w(w.toDate()[Ht].apply(w.toDate("s"),(B?[0,0,0,0]:[23,59,59,999]).slice(Lt)),w)},vt=this.$W,St=this.$M,bt=this.$D,se="set"+(this.$u?"UTC":"");switch(R){case U:return B?K(1,0):K(31,11);case Z:return B?K(1,St):K(0,St+1);case X:var ve=this.$locale().weekStart||0,ue=(vt<ve?vt+7:vt)-ve;return K(B?bt-ue:bt+(6-ue),St);case Y:case V:return ct(se+"Hours",0);case z:return ct(se+"Minutes",1);case A:return ct(se+"Seconds",2);case _:return ct(se+"Milliseconds",3);default:return this.clone()}},S.endOf=function(b){return this.startOf(b,!1)},S.$set=function(b,C){var w,B=L.p(b),R="set"+(this.$u?"UTC":""),K=(w={},w[Y]=R+"Date",w[V]=R+"Date",w[Z]=R+"Month",w[U]=R+"FullYear",w[z]=R+"Hours",w[A]=R+"Minutes",w[_]=R+"Seconds",w[F]=R+"Milliseconds",w)[B],ct=B===Y?this.$D+(C-this.$W):C;if(B===Z||B===U){var vt=this.clone().set(V,1);vt.$d[K](ct),vt.init(),this.$d=vt.set(V,Math.min(this.$D,vt.daysInMonth())).$d}else K&&this.$d[K](ct);return this.init(),this},S.set=function(b,C){return this.clone().$set(b,C)},S.get=function(b){return this[L.p(b)]()},S.add=function(b,C){var w,B=this;b=Number(b);var R=L.p(C),K=function(St){var bt=D(B);return L.w(bt.date(bt.date()+Math.round(St*b)),B)};if(R===Z)return this.set(Z,this.$M+b);if(R===U)return this.set(U,this.$y+b);if(R===Y)return K(1);if(R===X)return K(7);var ct=(w={},w[A]=Q,w[z]=k,w[_]=s,w)[R]||1,vt=this.$d.getTime()+b*ct;return L.w(vt,this)},S.subtract=function(b,C){return this.add(-1*b,C)},S.format=function(b){var C=this,w=this.$locale();if(!this.isValid())return w.invalidDate||ot;var B=b||"YYYY-MM-DDTHH:mm:ssZ",R=L.z(this),K=this.$H,ct=this.$m,vt=this.$M,St=w.weekdays,bt=w.months,se=w.meridiem,ve=function(Lt,qt,ge,We){return Lt&&(Lt[qt]||Lt(C,B))||ge[qt].slice(0,We)},ue=function(Lt){return L.s(K%12||12,Lt,"0")},Ht=se||function(Lt,qt,ge){var We=Lt<12?"AM":"PM";return ge?We.toLowerCase():We};return B.replace(yt,function(Lt,qt){return qt||function(ge){switch(ge){case"YY":return String(C.$y).slice(-2);case"YYYY":return L.s(C.$y,4,"0");case"M":return vt+1;case"MM":return L.s(vt+1,2,"0");case"MMM":return ve(w.monthsShort,vt,bt,3);case"MMMM":return ve(bt,vt);case"D":return C.$D;case"DD":return L.s(C.$D,2,"0");case"d":return String(C.$W);case"dd":return ve(w.weekdaysMin,C.$W,St,2);case"ddd":return ve(w.weekdaysShort,C.$W,St,3);case"dddd":return St[C.$W];case"H":return String(K);case"HH":return L.s(K,2,"0");case"h":return ue(1);case"hh":return ue(2);case"a":return Ht(K,ct,!0);case"A":return Ht(K,ct,!1);case"m":return String(ct);case"mm":return L.s(ct,2,"0");case"s":return String(C.$s);case"ss":return L.s(C.$s,2,"0");case"SSS":return L.s(C.$ms,3,"0");case"Z":return R}return null}(Lt)||R.replace(":","")})},S.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},S.diff=function(b,C,w){var B,R=this,K=L.p(C),ct=D(b),vt=(ct.utcOffset()-this.utcOffset())*Q,St=this-ct,bt=function(){return L.m(R,ct)};switch(K){case U:B=bt()/12;break;case Z:B=bt();break;case Nt:B=bt()/3;break;case X:B=(St-vt)/6048e5;break;case Y:B=(St-vt)/864e5;break;case z:B=St/k;break;case A:B=St/Q;break;case _:B=St/s;break;default:B=St}return w?B:L.a(B)},S.daysInMonth=function(){return this.endOf(Z).$D},S.$locale=function(){return wt[this.$L]},S.locale=function(b,C){if(!b)return this.$L;var w=this.clone(),B=ut(b,C,!0);return B&&(w.$L=B),w},S.clone=function(){return L.w(this.$d,this)},S.toDate=function(){return new Date(this.valueOf())},S.toJSON=function(){return this.isValid()?this.toISOString():null},S.toISOString=function(){return this.$d.toISOString()},S.toString=function(){return this.$d.toUTCString()},N}(),pe=Mt.prototype;return D.prototype=pe,[["$ms",F],["$s",_],["$m",A],["$H",z],["$W",Y],["$M",Z],["$y",U],["$D",V]].forEach(function(N){pe[N[1]]=function(S){return this.$g(S,N[0],N[1])}}),D.extend=function(N,S){return N.$i||(N(S,Mt,D),N.$i=!0),D},D.locale=ut,D.isDayjs=zt,D.unix=function(N){return D(1e3*N)},D.en=wt[mt],D.Ls=wt,D.p={},D})}(Lu)),Lu.exports}k0();function N0(p){const[E,s,Q]=p.relation.definition.split(":"),k=p.relation.api[s],F=a.ref(!1),_=a.ref([]),A=a.ref({limit:99999,page:1});return{options:_,isLoading:F,finalQuery:A,fetchData:async(z={query:[]})=>{F.value=!0;try{const Y=a.computed(()=>({limit:A.value.limit,page:A.value.page,filter:JSON.stringify(z.query)}));await k.get(`/api/${Q}`,{params:Y.value}).then(X=>X.data).then(X=>{X.code==200&&(_.value=X==null?void 0:X.data)})}catch(Y){console.error("Error fetching data:",Y)}finally{F.value=!1}}}}const L0={class:"synt-office-relation-wrapper"},T0={class:"synt-office-relation-label"},D0={class:"synt-office-relation-note"},B0={class:"synt-office-relation-group-input-wrapper"},M0={class:"synt-office-relation-input-wrapper"},I0={class:"synt-office-relation-skeleton-wrapper"},R0={key:0,class:"danger-alert"},V0={key:0,class:"synt-office-relation-modal-overlay"},P0={class:"synt-office-relation-modal-wrapper"},W0={class:"synt-office-relation-modal-header-end"},F0={class:"synt-office-relation-modal-option"},U0={class:"synt-office-relation-modal-table-wrapper"},z0={id:"table-relation-collection"},H0=["checked"],q0={class:"synt-office-relation-modal-table-label"},Y0=["checked","onChange"],G0={class:"synt-badge-tabel"},K0={class:"synt-office-relation-modal-table-footer"},Z0={class:"synt-office-relation-modal-table-footer-end"},j0={class:"synt-office-relation-font-bold"},Q0={class:"synt-office-relation-font-bold"},X0=a.defineComponent({__name:"OfficeRelation",props:a.mergeModels({fields:{},isDisabled:{},isError:{},query:{},error:{}},{modelValue:{},modelModifiers:{}}),emits:a.mergeModels(["update:selected"],["update:modelValue"]),setup(p,{emit:E}){const s=p,Q=E,k=a.useModel(p,"modelValue"),{options:F,isLoading:_,fetchData:A}=N0({relation:s.fields.relation}),z=a.ref(""),Y=a.ref(99999),X=a.ref(null),Z=a.ref(null),Nt=a.ref(!1),U=a.computed(()=>{var D,L;return(L=(D=s.fields)==null?void 0:D.options)==null?void 0:L.isMultiple}),V=a.computed(()=>{var D;return(D=F.value)==null?void 0:D.filter(L=>{var Mt,pe,N,S;return(S=(N=L==null?void 0:L[(pe=(Mt=s.fields)==null?void 0:Mt.relation)==null?void 0:pe.display])==null?void 0:N.toLowerCase())==null?void 0:S.includes(z.value)})}),ot=a.computed(()=>V.value.slice(0,Y.value)),tt=a.computed(()=>ot.value.length<V.value.length),yt=a.computed(()=>{var D;return((D=F.value)==null?void 0:D.find(L=>L.id===k.value))||null}),pt=a.ref([]);a.watch(()=>s.query,async D=>{pt.value=D},{immediate:!0}),a.watch(()=>pt.value,async D=>{D&&await A({query:D})}),a.watch(yt,D=>{Q("update:selected",D)});const Ct=async([{isIntersecting:D,target:L}])=>{if(D){const Mt=L.offsetParent,pe=Mt.scrollTop;Y.value+=10,await a.nextTick(),Mt.scrollTop=pe}},Bt=async()=>{F.value.length&&!Array.isArray(k.value)||await A({query:pt.value})},mt=async D=>{Array.isArray(k.value)&&(k.value.includes(D)?k.value=k.value.filter(Mt=>Mt!==D):k.value.push(D)),await Bt()},wt=a.computed(()=>{if(Array.isArray(k.value))return V.value.length>0&&V.value.every(D=>Array.isArray(k.value)&&k.value.includes(D.id))});function $t(){if(Array.isArray(k.value))if(wt.value)k.value=k.value.filter(D=>!V.value.map(L=>L.id).includes(D));else{const D=V.value.map(L=>L.id);k.value=Array.from(new Set([...k.value,...D]))}}const zt=async()=>{Array.isArray(k.value)||(k.value=[]),await Bt(),Nt.value=!0},ut=async()=>{z.value="",Nt.value=!1};return a.watch(()=>k.value,async()=>{F.value.length&&!Array.isArray(k.value)||(_.value=!0,k.value&&await Bt(),_.value=!1)}),a.onMounted(async()=>{X.value=new IntersectionObserver(Ct)}),(D,L)=>{var Mt,pe,N,S,b,C;return a.openBlock(),a.createElementBlock("div",null,[a.createElementVNode("div",L0,[a.createElementVNode("label",T0,a.toDisplayString((Mt=D.fields)==null?void 0:Mt.name),1),a.createElementVNode("span",D0,a.toDisplayString((N=(pe=D.fields)==null?void 0:pe.options)==null?void 0:N.note),1),a.createElementVNode("div",B0,[a.createElementVNode("div",M0,[a.withDirectives(a.createElementVNode("div",I0,L[3]||(L[3]=[a.createElementVNode("div",{class:"synt-office-relation-skeleton"},[a.createElementVNode("div",{class:"synt-office-relation-content"})],-1)]),512),[[a.vShow,a.unref(_)]]),a.createVNode(a.unref(Ag),{modelValue:k.value,"onUpdate:modelValue":L[0]||(L[0]=w=>k.value=w),class:a.normalizeClass(["synt-relation-control",{"synt-office-relation-error":D.isError,"synt-office-relation-disabled":D.isDisabled,"synt-office-relation-normal":!D.isError&&!D.isDisabled}]),options:ot.value,reduce:w=>w.id,label:(b=(S=D.fields)==null?void 0:S.relation)==null?void 0:b.display,placeholder:"Please enter at least 3 letters...",disabled:D.isDisabled,multiple:U.value,onOpen:Bt},{option:a.withCtx(w=>{var B,R;return[a.createElementVNode("span",null,a.toDisplayString(w[(R=(B=D.fields)==null?void 0:B.relation)==null?void 0:R.display]),1)]}),"list-footer":a.withCtx(()=>[a.withDirectives(a.createElementVNode("li",{ref_key:"load",ref:Z,class:"synt-office-relation-loading"},L[4]||(L[4]=[a.createElementVNode("i",{class:"synt-office-relation-loading-spin fa-solid fa-spinner"},null,-1)]),512),[[a.vShow,tt.value]])]),_:1},8,["modelValue","class","options","reduce","label","disabled","multiple"])]),U.value?(a.openBlock(),a.createElementBlock("button",{key:0,type:"button",class:"synt-office-relation-btn-expands",onClick:a.withModifiers(zt,["prevent"])},L[5]||(L[5]=[a.createElementVNode("i",{class:"synt-office-relation-btn-expands-icon fa-solid fa-up-right-and-down-left-from-center"},null,-1)]))):a.createCommentVNode("",!0)]),((C=D.error)==null?void 0:C.length)>0?(a.openBlock(),a.createElementBlock("p",R0,"*"+a.toDisplayString(D.error),1)):a.createCommentVNode("",!0)]),a.createVNode(a.Transition,{name:"fade"},{default:a.withCtx(()=>{var w;return[Nt.value?(a.openBlock(),a.createElementBlock("div",V0,[a.createElementVNode("div",P0,[a.createVNode(a.unref(Ou),{label:D.fields.name,icon:"fa-solid fa-table"},{end:a.withCtx(()=>[a.createElementVNode("div",W0,[a.createElementVNode("button",{type:"button",class:"synt-office-relation-modal-btn-close",onClick:a.withModifiers(ut,["prevent"])},L[6]||(L[6]=[a.createElementVNode("i",{class:"fa-solid fa-xmark"},null,-1)]))])]),_:1},8,["label"]),a.createElementVNode("div",F0,[a.withDirectives(a.createElementVNode("input",{"onUpdate:modelValue":L[1]||(L[1]=B=>z.value=B),type:"search",placeholder:"Cari...",class:"synt-office-relation-modal-search"},null,512),[[a.vModelText,z.value]]),a.createElementVNode("button",{type:"button",class:"synt-office-relation-modal-btn-refresh",onClick:L[2]||(L[2]=a.withModifiers(B=>a.unref(A)(),["prevent"]))},L[7]||(L[7]=[a.createElementVNode("i",{class:"synt-office-relation-modal-btn-icon fa-solid fa-sync"},null,-1)]))]),a.createElementVNode("div",U0,[a.createElementVNode("table",z0,[a.createElementVNode("thead",null,[a.createElementVNode("tr",null,[a.createElementVNode("th",null,[a.createElementVNode("input",{type:"checkbox",class:"synt-office-relation-modal-table-checkbox",checked:wt.value,onChange:$t},null,40,H0)]),a.createElementVNode("th",q0,a.toDisplayString((w=D.fields)==null?void 0:w.name),1)])]),a.createElementVNode("tbody",null,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(V.value,B=>{var R,K;return a.openBlock(),a.createElementBlock("tr",{key:B.id},[a.createElementVNode("td",null,[a.createElementVNode("input",{type:"checkbox",class:"synt-office-relation-modal-table-checkbox",checked:Array.isArray(k.value)&&k.value.includes(B.id),onChange:ct=>mt(B.id)},null,40,Y0)]),a.createElementVNode("td",null,[a.createElementVNode("div",G0,a.toDisplayString(B[(K=(R=D.fields)==null?void 0:R.relation)==null?void 0:K.display]),1)])])}),128))])])]),a.createElementVNode("div",K0,[a.createElementVNode("div",Z0,[L[8]||(L[8]=a.createElementVNode("span",{class:"synt-office-relation-font-bold"},a.toDisplayString(1),-1)),L[9]||(L[9]=a.createTextVNode(" - ")),a.createElementVNode("span",j0,a.toDisplayString(V.value.length),1),L[10]||(L[10]=a.createTextVNode(" dari ")),a.createElementVNode("span",Q0,a.toDisplayString(V.value.length),1)])])])])):a.createCommentVNode("",!0)]}),_:1})])}}}),J0={class:"lux-office-relation-wrapper"},t1={class:"lux-office-relation-label"},e1={class:"lux-office-relation-note"},n1={class:"lux-office-relation-group-input-wrapper"},r1={class:"lux-office-relation-input-wrapper"},i1={class:"lux-office-relation-skeleton-wrapper"},o1={key:0,class:"danger-alert"},Tg=20,s1=a.defineComponent({__name:"LuxtRelation",props:a.mergeModels({fields:{},isDisabled:{},isError:{},query:{},error:{}},{modelValue:{},modelModifiers:{}}),emits:a.mergeModels(["update:selected"],["update:modelValue"]),setup(p,{emit:E}){var mt,wt,$t,zt;const s=p,Q=E,k=a.useModel(p,"modelValue"),F=a.ref([]),_=a.ref(1),A=a.ref(!0),z=a.ref(!1),Y=a.ref(""),X=a.ref(null),Z=a.ref(null),[Nt,U,V]=(wt=(mt=s.fields)==null?void 0:mt.relation.definition)==null?void 0:wt.split(":"),ot=(zt=($t=s.fields)==null?void 0:$t.relation)==null?void 0:zt.api[U],tt=a.computed(()=>{var ut;return((ut=F.value)==null?void 0:ut.find(D=>D.id===k.value))||null});async function yt(ut=!1){if(z.value||!A.value)return;z.value=!0;const D=document.querySelector(".vs__dropdown-menu"),L=(D==null?void 0:D.scrollTop)||0;try{const Mt={search:Y.value,limit:Tg,page:_.value,filter:JSON.stringify(s.query)},N=(await ot.get(`/api/${V}/display`,{params:Mt})).data;if(N.code==200){const S=N.data;ut?(F.value=S,_.value=2):(F.value.push(...S),_.value++),S.length<Tg&&(A.value=!1)}}catch(Mt){console.error("fetchAll error",Mt)}finally{await a.nextTick(),!ut&&D&&(D.scrollTop=L),z.value=!1}}async function pt(){if(k.value)try{const ut=await ot.get(`/api/${V}/${k.value}`);ut.data.code==200&&(F.value=[ut.data.data])}catch(ut){console.error("fetchOne error",ut)}}async function Ct(){_.value=1,A.value=!0,await yt(!0),a.nextTick(()=>{Z.value&&X.value&&X.value.observe(Z.value)})}async function Bt(){var ut;(ut=X.value)==null||ut.disconnect(),await pt()}return a.watch(()=>k.value,pt),a.watch(()=>Y.value,Eg.debounce(async()=>{Y.value.length<3||(_.value=1,A.value=!0,await yt(!0))},500)),a.watch(tt,ut=>{Q("update:selected",ut)}),a.onMounted(()=>{X.value=new IntersectionObserver(async([ut])=>{ut.isIntersecting&&await yt()})}),a.onBeforeUnmount(()=>{var ut;(ut=X.value)==null||ut.disconnect()}),(ut,D)=>{var L,Mt,pe,N,S,b;return a.openBlock(),a.createElementBlock("div",J0,[a.createElementVNode("label",t1,a.toDisplayString((L=ut.fields)==null?void 0:L.name),1),a.createElementVNode("span",e1,a.toDisplayString((pe=(Mt=ut.fields)==null?void 0:Mt.options)==null?void 0:pe.note),1),a.createElementVNode("div",n1,[a.createElementVNode("div",r1,[a.withDirectives(a.createElementVNode("div",i1,D[2]||(D[2]=[a.createElementVNode("div",{class:"lux-office-relation-skeleton"},[a.createElementVNode("div",{class:"lux-office-relation-content"})],-1)]),512),[[a.vShow,z.value]]),a.createVNode(a.unref(Ag),{modelValue:k.value,"onUpdate:modelValue":D[0]||(D[0]=C=>k.value=C),class:a.normalizeClass(["lux-relation-control",{"lux-office-relation-error":ut.isError,"lux-office-relation-disabled":ut.isDisabled,"lux-office-relation-normal":!ut.isError&&!ut.isDisabled}]),options:F.value,reduce:C=>C.id,label:(S=(N=ut.fields)==null?void 0:N.relation)==null?void 0:S.display,placeholder:"Ketik 3 huruf untuk mencari...",disabled:ut.isDisabled,filterable:!1,onOpen:Ct,onClose:Bt,onSearch:D[1]||(D[1]=C=>Y.value=C==null?void 0:C.toLowerCase())},{option:a.withCtx(C=>{var w,B;return[a.createElementVNode("span",null,a.toDisplayString(C[(B=(w=ut.fields)==null?void 0:w.relation)==null?void 0:B.display]),1)]}),"list-footer":a.withCtx(()=>[a.withDirectives(a.createElementVNode("li",{ref_key:"loadMoreTrigger",ref:Z,class:"flex items-center justify-center"},D[3]||(D[3]=[a.createElementVNode("i",{class:"fa-solid fa-spinner animate-spin"},null,-1)]),512),[[a.vShow,A.value]])]),_:1},8,["modelValue","class","options","reduce","label","disabled"])])]),ut.error&&((b=ut.error)==null?void 0:b.length)>0?(a.openBlock(),a.createElementBlock("p",o1,"*"+a.toDisplayString(ut.error),1)):a.createCommentVNode("",!0)])}}});Ne.LuxtRelation=s1,Ne.OfficeCollection=qg,Ne.OfficeCollectionTable=w_,Ne.OfficeHeader=Ou,Ne.OfficeLayout=Cu,Ne.OfficeLayoutWrapper=yg,Ne.OfficeLink=Bg,Ne.OfficeRelation=X0,Ne.OfficeSingle=P_,Ne.OfficeTab=N_,Ne.OfficeTabs=A_,Object.defineProperty(Ne,Symbol.toStringTag,{value:"Module"})});
|
|
67
|
+
*/var C0=Nu.exports,Ng;function $0(){return Ng||(Ng=1,function(p){(function(E,s){p.exports?p.exports=s():E.Toastify=s()})(C0,function(E){var s=function(_){return new s.lib.init(_)},Q="1.12.0";s.defaults={oldestFirst:!0,text:"Toastify is awesome!",node:void 0,duration:3e3,selector:void 0,callback:function(){},destination:void 0,newWindow:!1,close:!1,gravity:"toastify-top",positionLeft:!1,position:"",backgroundColor:"",avatar:"",className:"",stopOnFocus:!0,onClick:function(){},offset:{x:0,y:0},escapeMarkup:!0,ariaLive:"polite",style:{background:""}},s.lib=s.prototype={toastify:Q,constructor:s,init:function(_){return _||(_={}),this.options={},this.toastElement=null,this.options.text=_.text||s.defaults.text,this.options.node=_.node||s.defaults.node,this.options.duration=_.duration===0?0:_.duration||s.defaults.duration,this.options.selector=_.selector||s.defaults.selector,this.options.callback=_.callback||s.defaults.callback,this.options.destination=_.destination||s.defaults.destination,this.options.newWindow=_.newWindow||s.defaults.newWindow,this.options.close=_.close||s.defaults.close,this.options.gravity=_.gravity==="bottom"?"toastify-bottom":s.defaults.gravity,this.options.positionLeft=_.positionLeft||s.defaults.positionLeft,this.options.position=_.position||s.defaults.position,this.options.backgroundColor=_.backgroundColor||s.defaults.backgroundColor,this.options.avatar=_.avatar||s.defaults.avatar,this.options.className=_.className||s.defaults.className,this.options.stopOnFocus=_.stopOnFocus===void 0?s.defaults.stopOnFocus:_.stopOnFocus,this.options.onClick=_.onClick||s.defaults.onClick,this.options.offset=_.offset||s.defaults.offset,this.options.escapeMarkup=_.escapeMarkup!==void 0?_.escapeMarkup:s.defaults.escapeMarkup,this.options.ariaLive=_.ariaLive||s.defaults.ariaLive,this.options.style=_.style||s.defaults.style,_.backgroundColor&&(this.options.style.background=_.backgroundColor),this},buildToast:function(){if(!this.options)throw"Toastify is not initialized";var _=document.createElement("div");_.className="toastify on "+this.options.className,this.options.position?_.className+=" toastify-"+this.options.position:this.options.positionLeft===!0?(_.className+=" toastify-left",console.warn("Property `positionLeft` will be depreciated in further versions. Please use `position` instead.")):_.className+=" toastify-right",_.className+=" "+this.options.gravity,this.options.backgroundColor&&console.warn('DEPRECATION NOTICE: "backgroundColor" is being deprecated. Please use the "style.background" property.');for(var A in this.options.style)_.style[A]=this.options.style[A];if(this.options.ariaLive&&_.setAttribute("aria-live",this.options.ariaLive),this.options.node&&this.options.node.nodeType===Node.ELEMENT_NODE)_.appendChild(this.options.node);else if(this.options.escapeMarkup?_.innerText=this.options.text:_.innerHTML=this.options.text,this.options.avatar!==""){var z=document.createElement("img");z.src=this.options.avatar,z.className="toastify-avatar",this.options.position=="left"||this.options.positionLeft===!0?_.appendChild(z):_.insertAdjacentElement("afterbegin",z)}if(this.options.close===!0){var Y=document.createElement("button");Y.type="button",Y.setAttribute("aria-label","Close"),Y.className="toast-close",Y.innerHTML="✖",Y.addEventListener("click",(function(tt){tt.stopPropagation(),this.removeElement(this.toastElement),window.clearTimeout(this.toastElement.timeOutValue)}).bind(this));var X=window.innerWidth>0?window.innerWidth:screen.width;(this.options.position=="left"||this.options.positionLeft===!0)&&X>360?_.insertAdjacentElement("afterbegin",Y):_.appendChild(Y)}if(this.options.stopOnFocus&&this.options.duration>0){var Z=this;_.addEventListener("mouseover",function(tt){window.clearTimeout(_.timeOutValue)}),_.addEventListener("mouseleave",function(){_.timeOutValue=window.setTimeout(function(){Z.removeElement(_)},Z.options.duration)})}if(typeof this.options.destination<"u"&&_.addEventListener("click",(function(tt){tt.stopPropagation(),this.options.newWindow===!0?window.open(this.options.destination,"_blank"):window.location=this.options.destination}).bind(this)),typeof this.options.onClick=="function"&&typeof this.options.destination>"u"&&_.addEventListener("click",(function(tt){tt.stopPropagation(),this.options.onClick()}).bind(this)),typeof this.options.offset=="object"){var Nt=k("x",this.options),U=k("y",this.options),V=this.options.position=="left"?Nt:"-"+Nt,ot=this.options.gravity=="toastify-top"?U:"-"+U;_.style.transform="translate("+V+","+ot+")"}return _},showToast:function(){this.toastElement=this.buildToast();var _;if(typeof this.options.selector=="string"?_=document.getElementById(this.options.selector):this.options.selector instanceof HTMLElement||typeof ShadowRoot<"u"&&this.options.selector instanceof ShadowRoot?_=this.options.selector:_=document.body,!_)throw"Root element is not defined";var A=s.defaults.oldestFirst?_.firstChild:_.lastChild;return _.insertBefore(this.toastElement,A),s.reposition(),this.options.duration>0&&(this.toastElement.timeOutValue=window.setTimeout((function(){this.removeElement(this.toastElement)}).bind(this),this.options.duration)),this},hideToast:function(){this.toastElement.timeOutValue&&clearTimeout(this.toastElement.timeOutValue),this.removeElement(this.toastElement)},removeElement:function(_){_.className=_.className.replace(" on",""),window.setTimeout((function(){this.options.node&&this.options.node.parentNode&&this.options.node.parentNode.removeChild(this.options.node),_.parentNode&&_.parentNode.removeChild(_),this.options.callback.call(_),s.reposition()}).bind(this),400)}},s.reposition=function(){for(var _={top:15,bottom:15},A={top:15,bottom:15},z={top:15,bottom:15},Y=document.getElementsByClassName("toastify"),X,Z=0;Z<Y.length;Z++){F(Y[Z],"toastify-top")===!0?X="toastify-top":X="toastify-bottom";var Nt=Y[Z].offsetHeight;X=X.substr(9,X.length-1);var U=15,V=window.innerWidth>0?window.innerWidth:screen.width;V<=360?(Y[Z].style[X]=z[X]+"px",z[X]+=Nt+U):F(Y[Z],"toastify-left")===!0?(Y[Z].style[X]=_[X]+"px",_[X]+=Nt+U):(Y[Z].style[X]=A[X]+"px",A[X]+=Nt+U)}return this};function k(_,A){return A.offset[_]?isNaN(A.offset[_])?A.offset[_]:A.offset[_]+"px":"0px"}function F(_,A){return!_||typeof A!="string"?!1:!!(_.className&&_.className.trim().split(/\s+/gi).indexOf(A)>-1)}return s.lib.init.prototype=s.lib,s})}(Nu)),Nu.exports}$0();var Lu={exports:{}},A0=Lu.exports,Lg;function k0(){return Lg||(Lg=1,function(p,E){(function(s,Q){p.exports=Q()})(A0,function(){var s=1e3,Q=6e4,k=36e5,F="millisecond",_="second",A="minute",z="hour",Y="day",X="week",Z="month",Nt="quarter",U="year",V="date",ot="Invalid Date",tt=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,yt=/\[([^\]]+)]|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,pt={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(N){var S=["th","st","nd","rd"],b=N%100;return"["+N+(S[(b-20)%10]||S[b]||S[0])+"]"}},Ct=function(N,S,b){var C=String(N);return!C||C.length>=S?N:""+Array(S+1-C.length).join(b)+N},Bt={s:Ct,z:function(N){var S=-N.utcOffset(),b=Math.abs(S),C=Math.floor(b/60),w=b%60;return(S<=0?"+":"-")+Ct(C,2,"0")+":"+Ct(w,2,"0")},m:function N(S,b){if(S.date()<b.date())return-N(b,S);var C=12*(b.year()-S.year())+(b.month()-S.month()),w=S.clone().add(C,Z),B=b-w<0,R=S.clone().add(C+(B?-1:1),Z);return+(-(C+(b-w)/(B?w-R:R-w))||0)},a:function(N){return N<0?Math.ceil(N)||0:Math.floor(N)},p:function(N){return{M:Z,y:U,w:X,d:Y,D:V,h:z,m:A,s:_,ms:F,Q:Nt}[N]||String(N||"").toLowerCase().replace(/s$/,"")},u:function(N){return N===void 0}},mt="en",wt={};wt[mt]=pt;var $t="$isDayjsObject",zt=function(N){return N instanceof Mt||!(!N||!N[$t])},ut=function N(S,b,C){var w;if(!S)return mt;if(typeof S=="string"){var B=S.toLowerCase();wt[B]&&(w=B),b&&(wt[B]=b,w=B);var R=S.split("-");if(!w&&R.length>1)return N(R[0])}else{var K=S.name;wt[K]=S,w=K}return!C&&w&&(mt=w),w||!C&&mt},D=function(N,S){if(zt(N))return N.clone();var b=typeof S=="object"?S:{};return b.date=N,b.args=arguments,new Mt(b)},L=Bt;L.l=ut,L.i=zt,L.w=function(N,S){return D(N,{locale:S.$L,utc:S.$u,x:S.$x,$offset:S.$offset})};var Mt=function(){function N(b){this.$L=ut(b.locale,null,!0),this.parse(b),this.$x=this.$x||b.x||{},this[$t]=!0}var S=N.prototype;return S.parse=function(b){this.$d=function(C){var w=C.date,B=C.utc;if(w===null)return new Date(NaN);if(L.u(w))return new Date;if(w instanceof Date)return new Date(w);if(typeof w=="string"&&!/Z$/i.test(w)){var R=w.match(tt);if(R){var K=R[2]-1||0,ct=(R[7]||"0").substring(0,3);return B?new Date(Date.UTC(R[1],K,R[3]||1,R[4]||0,R[5]||0,R[6]||0,ct)):new Date(R[1],K,R[3]||1,R[4]||0,R[5]||0,R[6]||0,ct)}}return new Date(w)}(b),this.init()},S.init=function(){var b=this.$d;this.$y=b.getFullYear(),this.$M=b.getMonth(),this.$D=b.getDate(),this.$W=b.getDay(),this.$H=b.getHours(),this.$m=b.getMinutes(),this.$s=b.getSeconds(),this.$ms=b.getMilliseconds()},S.$utils=function(){return L},S.isValid=function(){return this.$d.toString()!==ot},S.isSame=function(b,C){var w=D(b);return this.startOf(C)<=w&&w<=this.endOf(C)},S.isAfter=function(b,C){return D(b)<this.startOf(C)},S.isBefore=function(b,C){return this.endOf(C)<D(b)},S.$g=function(b,C,w){return L.u(b)?this[C]:this.set(w,b)},S.unix=function(){return Math.floor(this.valueOf()/1e3)},S.valueOf=function(){return this.$d.getTime()},S.startOf=function(b,C){var w=this,B=!!L.u(C)||C,R=L.p(b),K=function(Ht,Lt){var qt=L.w(w.$u?Date.UTC(w.$y,Lt,Ht):new Date(w.$y,Lt,Ht),w);return B?qt:qt.endOf(Y)},ct=function(Ht,Lt){return L.w(w.toDate()[Ht].apply(w.toDate("s"),(B?[0,0,0,0]:[23,59,59,999]).slice(Lt)),w)},vt=this.$W,St=this.$M,bt=this.$D,se="set"+(this.$u?"UTC":"");switch(R){case U:return B?K(1,0):K(31,11);case Z:return B?K(1,St):K(0,St+1);case X:var ve=this.$locale().weekStart||0,ue=(vt<ve?vt+7:vt)-ve;return K(B?bt-ue:bt+(6-ue),St);case Y:case V:return ct(se+"Hours",0);case z:return ct(se+"Minutes",1);case A:return ct(se+"Seconds",2);case _:return ct(se+"Milliseconds",3);default:return this.clone()}},S.endOf=function(b){return this.startOf(b,!1)},S.$set=function(b,C){var w,B=L.p(b),R="set"+(this.$u?"UTC":""),K=(w={},w[Y]=R+"Date",w[V]=R+"Date",w[Z]=R+"Month",w[U]=R+"FullYear",w[z]=R+"Hours",w[A]=R+"Minutes",w[_]=R+"Seconds",w[F]=R+"Milliseconds",w)[B],ct=B===Y?this.$D+(C-this.$W):C;if(B===Z||B===U){var vt=this.clone().set(V,1);vt.$d[K](ct),vt.init(),this.$d=vt.set(V,Math.min(this.$D,vt.daysInMonth())).$d}else K&&this.$d[K](ct);return this.init(),this},S.set=function(b,C){return this.clone().$set(b,C)},S.get=function(b){return this[L.p(b)]()},S.add=function(b,C){var w,B=this;b=Number(b);var R=L.p(C),K=function(St){var bt=D(B);return L.w(bt.date(bt.date()+Math.round(St*b)),B)};if(R===Z)return this.set(Z,this.$M+b);if(R===U)return this.set(U,this.$y+b);if(R===Y)return K(1);if(R===X)return K(7);var ct=(w={},w[A]=Q,w[z]=k,w[_]=s,w)[R]||1,vt=this.$d.getTime()+b*ct;return L.w(vt,this)},S.subtract=function(b,C){return this.add(-1*b,C)},S.format=function(b){var C=this,w=this.$locale();if(!this.isValid())return w.invalidDate||ot;var B=b||"YYYY-MM-DDTHH:mm:ssZ",R=L.z(this),K=this.$H,ct=this.$m,vt=this.$M,St=w.weekdays,bt=w.months,se=w.meridiem,ve=function(Lt,qt,ge,We){return Lt&&(Lt[qt]||Lt(C,B))||ge[qt].slice(0,We)},ue=function(Lt){return L.s(K%12||12,Lt,"0")},Ht=se||function(Lt,qt,ge){var We=Lt<12?"AM":"PM";return ge?We.toLowerCase():We};return B.replace(yt,function(Lt,qt){return qt||function(ge){switch(ge){case"YY":return String(C.$y).slice(-2);case"YYYY":return L.s(C.$y,4,"0");case"M":return vt+1;case"MM":return L.s(vt+1,2,"0");case"MMM":return ve(w.monthsShort,vt,bt,3);case"MMMM":return ve(bt,vt);case"D":return C.$D;case"DD":return L.s(C.$D,2,"0");case"d":return String(C.$W);case"dd":return ve(w.weekdaysMin,C.$W,St,2);case"ddd":return ve(w.weekdaysShort,C.$W,St,3);case"dddd":return St[C.$W];case"H":return String(K);case"HH":return L.s(K,2,"0");case"h":return ue(1);case"hh":return ue(2);case"a":return Ht(K,ct,!0);case"A":return Ht(K,ct,!1);case"m":return String(ct);case"mm":return L.s(ct,2,"0");case"s":return String(C.$s);case"ss":return L.s(C.$s,2,"0");case"SSS":return L.s(C.$ms,3,"0");case"Z":return R}return null}(Lt)||R.replace(":","")})},S.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},S.diff=function(b,C,w){var B,R=this,K=L.p(C),ct=D(b),vt=(ct.utcOffset()-this.utcOffset())*Q,St=this-ct,bt=function(){return L.m(R,ct)};switch(K){case U:B=bt()/12;break;case Z:B=bt();break;case Nt:B=bt()/3;break;case X:B=(St-vt)/6048e5;break;case Y:B=(St-vt)/864e5;break;case z:B=St/k;break;case A:B=St/Q;break;case _:B=St/s;break;default:B=St}return w?B:L.a(B)},S.daysInMonth=function(){return this.endOf(Z).$D},S.$locale=function(){return wt[this.$L]},S.locale=function(b,C){if(!b)return this.$L;var w=this.clone(),B=ut(b,C,!0);return B&&(w.$L=B),w},S.clone=function(){return L.w(this.$d,this)},S.toDate=function(){return new Date(this.valueOf())},S.toJSON=function(){return this.isValid()?this.toISOString():null},S.toISOString=function(){return this.$d.toISOString()},S.toString=function(){return this.$d.toUTCString()},N}(),pe=Mt.prototype;return D.prototype=pe,[["$ms",F],["$s",_],["$m",A],["$H",z],["$W",Y],["$M",Z],["$y",U],["$D",V]].forEach(function(N){pe[N[1]]=function(S){return this.$g(S,N[0],N[1])}}),D.extend=function(N,S){return N.$i||(N(S,Mt,D),N.$i=!0),D},D.locale=ut,D.isDayjs=zt,D.unix=function(N){return D(1e3*N)},D.en=wt[mt],D.Ls=wt,D.p={},D})}(Lu)),Lu.exports}k0();function N0(p){const[E,s,Q]=p.relation.definition.split(":"),k=p.relation.api[s],F=a.ref(!1),_=a.ref([]),A=a.ref({limit:99999,page:1});return{options:_,isLoading:F,finalQuery:A,fetchData:async(z={query:[]})=>{F.value=!0;try{const Y=a.computed(()=>({limit:A.value.limit,page:A.value.page,filter:JSON.stringify(z.query)}));await k.get(`/api/${Q}`,{params:Y.value}).then(X=>X.data).then(X=>{X.code==200&&(_.value=X==null?void 0:X.data)})}catch(Y){console.error("Error fetching data:",Y)}finally{F.value=!1}}}}const L0={class:"synt-office-relation-wrapper"},T0={class:"synt-office-relation-label"},D0={class:"synt-office-relation-note"},B0={class:"synt-office-relation-group-input-wrapper"},M0={class:"synt-office-relation-input-wrapper"},I0={class:"synt-office-relation-skeleton-wrapper"},R0={key:0,class:"danger-alert"},V0={key:0,class:"synt-office-relation-modal-overlay"},P0={class:"synt-office-relation-modal-wrapper"},W0={class:"synt-office-relation-modal-header-end"},F0={class:"synt-office-relation-modal-option"},U0={class:"synt-office-relation-modal-table-wrapper"},z0={id:"table-relation-collection"},H0=["checked"],q0={class:"synt-office-relation-modal-table-label"},Y0=["checked","onChange"],G0={class:"synt-badge-tabel"},K0={class:"synt-office-relation-modal-table-footer"},Z0={class:"synt-office-relation-modal-table-footer-end"},j0={class:"synt-office-relation-font-bold"},Q0={class:"synt-office-relation-font-bold"},X0=a.defineComponent({__name:"OfficeRelation",props:a.mergeModels({fields:{},isDisabled:{},isError:{},query:{},error:{}},{modelValue:{},modelModifiers:{}}),emits:a.mergeModels(["update:selected","fetch:filtered"],["update:modelValue"]),setup(p,{emit:E}){const s=p,Q=E,k=a.useModel(p,"modelValue"),{options:F,isLoading:_,fetchData:A}=N0({relation:s.fields.relation}),z=a.ref(""),Y=a.ref(99999),X=a.ref(null),Z=a.ref(null),Nt=a.ref(!1),U=a.computed(()=>{var D,L;return(L=(D=s.fields)==null?void 0:D.options)==null?void 0:L.isMultiple}),V=a.computed(()=>{var D;return(D=F.value)==null?void 0:D.filter(L=>{var Mt,pe,N,S;return(S=(N=L==null?void 0:L[(pe=(Mt=s.fields)==null?void 0:Mt.relation)==null?void 0:pe.display])==null?void 0:N.toLowerCase())==null?void 0:S.includes(z.value)})}),ot=a.computed(()=>V.value.slice(0,Y.value)),tt=a.computed(()=>ot.value.length<V.value.length),yt=a.computed(()=>{var D;return((D=F.value)==null?void 0:D.find(L=>L.id===k.value))||null}),pt=a.ref([]);a.watch(()=>s.query,async D=>{pt.value=D},{immediate:!0}),a.watch(()=>pt.value,async D=>{D&&await A({query:D})}),a.watch(yt,D=>{Q("update:selected",D)});const Ct=async([{isIntersecting:D,target:L}])=>{if(D){const Mt=L.offsetParent,pe=Mt.scrollTop;Y.value+=10,await a.nextTick(),Mt.scrollTop=pe}},Bt=async()=>{F.value.length&&!Array.isArray(k.value)||await A({query:pt.value})},mt=async D=>{Array.isArray(k.value)&&(k.value.includes(D)?k.value=k.value.filter(Mt=>Mt!==D):k.value.push(D)),await Bt()},wt=a.computed(()=>{if(Array.isArray(k.value))return V.value.length>0&&V.value.every(D=>Array.isArray(k.value)&&k.value.includes(D.id))});function $t(){if(Array.isArray(k.value))if(wt.value)k.value=k.value.filter(D=>!V.value.map(L=>L.id).includes(D));else{const D=V.value.map(L=>L.id);k.value=Array.from(new Set([...k.value,...D]))}}const zt=async()=>{Array.isArray(k.value)||(k.value=[]),await Q("fetch:filtered"),await Bt(),Nt.value=!0},ut=async()=>{pt.value=[],z.value="",Nt.value=!1};return a.watch(()=>k.value,async()=>{F.value.length&&!Array.isArray(k.value)||(_.value=!0,k.value&&await Bt(),_.value=!1)}),a.onMounted(async()=>{X.value=new IntersectionObserver(Ct)}),(D,L)=>{var Mt,pe,N,S,b,C;return a.openBlock(),a.createElementBlock("div",null,[a.createElementVNode("div",L0,[a.createElementVNode("label",T0,a.toDisplayString((Mt=D.fields)==null?void 0:Mt.name),1),a.createElementVNode("span",D0,a.toDisplayString((N=(pe=D.fields)==null?void 0:pe.options)==null?void 0:N.note),1),a.createElementVNode("div",B0,[a.createElementVNode("div",M0,[a.withDirectives(a.createElementVNode("div",I0,L[3]||(L[3]=[a.createElementVNode("div",{class:"synt-office-relation-skeleton"},[a.createElementVNode("div",{class:"synt-office-relation-content"})],-1)]),512),[[a.vShow,a.unref(_)]]),a.createVNode(a.unref(Ag),{modelValue:k.value,"onUpdate:modelValue":L[0]||(L[0]=w=>k.value=w),class:a.normalizeClass(["synt-relation-control",{"synt-office-relation-error":D.isError,"synt-office-relation-disabled":D.isDisabled,"synt-office-relation-normal":!D.isError&&!D.isDisabled}]),options:ot.value,reduce:w=>w.id,label:(b=(S=D.fields)==null?void 0:S.relation)==null?void 0:b.display,placeholder:"Please enter at least 3 letters...",disabled:D.isDisabled,multiple:U.value,onOpen:Bt},{option:a.withCtx(w=>{var B,R;return[a.createElementVNode("span",null,a.toDisplayString(w[(R=(B=D.fields)==null?void 0:B.relation)==null?void 0:R.display]),1)]}),"list-footer":a.withCtx(()=>[a.withDirectives(a.createElementVNode("li",{ref_key:"load",ref:Z,class:"synt-office-relation-loading"},L[4]||(L[4]=[a.createElementVNode("i",{class:"synt-office-relation-loading-spin fa-solid fa-spinner"},null,-1)]),512),[[a.vShow,tt.value]])]),_:1},8,["modelValue","class","options","reduce","label","disabled","multiple"])]),U.value?(a.openBlock(),a.createElementBlock("button",{key:0,type:"button",class:"synt-office-relation-btn-expands",onClick:a.withModifiers(zt,["prevent"])},L[5]||(L[5]=[a.createElementVNode("i",{class:"synt-office-relation-btn-expands-icon fa-solid fa-up-right-and-down-left-from-center"},null,-1)]))):a.createCommentVNode("",!0)]),((C=D.error)==null?void 0:C.length)>0?(a.openBlock(),a.createElementBlock("p",R0,"*"+a.toDisplayString(D.error),1)):a.createCommentVNode("",!0)]),a.createVNode(a.Transition,{name:"fade"},{default:a.withCtx(()=>{var w;return[Nt.value?(a.openBlock(),a.createElementBlock("div",V0,[a.createElementVNode("div",P0,[a.createVNode(a.unref(Ou),{label:D.fields.name,icon:"fa-solid fa-table"},{end:a.withCtx(()=>[a.createElementVNode("div",W0,[a.createElementVNode("button",{type:"button",class:"synt-office-relation-modal-btn-close",onClick:a.withModifiers(ut,["prevent"])},L[6]||(L[6]=[a.createElementVNode("i",{class:"fa-solid fa-xmark"},null,-1)]))])]),_:1},8,["label"]),a.createElementVNode("div",F0,[a.withDirectives(a.createElementVNode("input",{"onUpdate:modelValue":L[1]||(L[1]=B=>z.value=B),type:"search",placeholder:"Cari...",class:"synt-office-relation-modal-search"},null,512),[[a.vModelText,z.value]]),a.createElementVNode("button",{type:"button",class:"synt-office-relation-modal-btn-refresh",onClick:L[2]||(L[2]=a.withModifiers(B=>a.unref(A)(),["prevent"]))},L[7]||(L[7]=[a.createElementVNode("i",{class:"synt-office-relation-modal-btn-icon fa-solid fa-sync"},null,-1)]))]),a.renderSlot(D.$slots,"default"),a.createElementVNode("div",U0,[a.createElementVNode("table",z0,[a.createElementVNode("thead",null,[a.createElementVNode("tr",null,[a.createElementVNode("th",null,[a.createElementVNode("input",{type:"checkbox",class:"synt-office-relation-modal-table-checkbox",checked:wt.value,onChange:$t},null,40,H0)]),a.createElementVNode("th",q0,a.toDisplayString((w=D.fields)==null?void 0:w.name),1)])]),a.createElementVNode("tbody",null,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(V.value,B=>{var R,K;return a.openBlock(),a.createElementBlock("tr",{key:B.id},[a.createElementVNode("td",null,[a.createElementVNode("input",{type:"checkbox",class:"synt-office-relation-modal-table-checkbox",checked:Array.isArray(k.value)&&k.value.includes(B.id),onChange:ct=>mt(B.id)},null,40,Y0)]),a.createElementVNode("td",null,[a.createElementVNode("div",G0,a.toDisplayString(B[(K=(R=D.fields)==null?void 0:R.relation)==null?void 0:K.display]),1)])])}),128))])])]),a.createElementVNode("div",K0,[a.createElementVNode("div",Z0,[L[8]||(L[8]=a.createElementVNode("span",{class:"synt-office-relation-font-bold"},a.toDisplayString(1),-1)),L[9]||(L[9]=a.createTextVNode(" - ")),a.createElementVNode("span",j0,a.toDisplayString(V.value.length),1),L[10]||(L[10]=a.createTextVNode(" dari ")),a.createElementVNode("span",Q0,a.toDisplayString(V.value.length),1)])])])])):a.createCommentVNode("",!0)]}),_:3})])}}}),J0={class:"lux-office-relation-wrapper"},t1={class:"lux-office-relation-label"},e1={class:"lux-office-relation-note"},n1={class:"lux-office-relation-group-input-wrapper"},r1={class:"lux-office-relation-input-wrapper"},i1={class:"lux-office-relation-skeleton-wrapper"},o1={key:0,class:"danger-alert"},Tg=20,s1=a.defineComponent({__name:"LuxtRelation",props:a.mergeModels({fields:{},isDisabled:{},isError:{},query:{},error:{}},{modelValue:{},modelModifiers:{}}),emits:a.mergeModels(["update:selected"],["update:modelValue"]),setup(p,{emit:E}){var mt,wt,$t,zt;const s=p,Q=E,k=a.useModel(p,"modelValue"),F=a.ref([]),_=a.ref(1),A=a.ref(!0),z=a.ref(!1),Y=a.ref(""),X=a.ref(null),Z=a.ref(null),[Nt,U,V]=(wt=(mt=s.fields)==null?void 0:mt.relation.definition)==null?void 0:wt.split(":"),ot=(zt=($t=s.fields)==null?void 0:$t.relation)==null?void 0:zt.api[U],tt=a.computed(()=>{var ut;return((ut=F.value)==null?void 0:ut.find(D=>D.id===k.value))||null});async function yt(ut=!1){if(z.value||!A.value)return;z.value=!0;const D=document.querySelector(".vs__dropdown-menu"),L=(D==null?void 0:D.scrollTop)||0;try{const Mt={search:Y.value,limit:Tg,page:_.value,filter:JSON.stringify(s.query)},N=(await ot.get(`/api/${V}/display`,{params:Mt})).data;if(N.code==200){const S=N.data;ut?(F.value=S,_.value=2):(F.value.push(...S),_.value++),S.length<Tg&&(A.value=!1)}}catch(Mt){console.error("fetchAll error",Mt)}finally{await a.nextTick(),!ut&&D&&(D.scrollTop=L),z.value=!1}}async function pt(){if(k.value)try{const ut=await ot.get(`/api/${V}/${k.value}`);ut.data.code==200&&(F.value=[ut.data.data])}catch(ut){console.error("fetchOne error",ut)}}async function Ct(){_.value=1,A.value=!0,await yt(!0),a.nextTick(()=>{Z.value&&X.value&&X.value.observe(Z.value)})}async function Bt(){var ut;(ut=X.value)==null||ut.disconnect(),await pt()}return a.watch(()=>k.value,pt),a.watch(()=>Y.value,Eg.debounce(async()=>{Y.value.length<3||(_.value=1,A.value=!0,await yt(!0))},500)),a.watch(tt,ut=>{Q("update:selected",ut)}),a.onMounted(()=>{X.value=new IntersectionObserver(async([ut])=>{ut.isIntersecting&&await yt()})}),a.onBeforeUnmount(()=>{var ut;(ut=X.value)==null||ut.disconnect()}),(ut,D)=>{var L,Mt,pe,N,S,b;return a.openBlock(),a.createElementBlock("div",J0,[a.createElementVNode("label",t1,a.toDisplayString((L=ut.fields)==null?void 0:L.name),1),a.createElementVNode("span",e1,a.toDisplayString((pe=(Mt=ut.fields)==null?void 0:Mt.options)==null?void 0:pe.note),1),a.createElementVNode("div",n1,[a.createElementVNode("div",r1,[a.withDirectives(a.createElementVNode("div",i1,D[2]||(D[2]=[a.createElementVNode("div",{class:"lux-office-relation-skeleton"},[a.createElementVNode("div",{class:"lux-office-relation-content"})],-1)]),512),[[a.vShow,z.value]]),a.createVNode(a.unref(Ag),{modelValue:k.value,"onUpdate:modelValue":D[0]||(D[0]=C=>k.value=C),class:a.normalizeClass(["lux-relation-control",{"lux-office-relation-error":ut.isError,"lux-office-relation-disabled":ut.isDisabled,"lux-office-relation-normal":!ut.isError&&!ut.isDisabled}]),options:F.value,reduce:C=>C.id,label:(S=(N=ut.fields)==null?void 0:N.relation)==null?void 0:S.display,placeholder:"Ketik 3 huruf untuk mencari...",disabled:ut.isDisabled,filterable:!1,onOpen:Ct,onClose:Bt,onSearch:D[1]||(D[1]=C=>Y.value=C==null?void 0:C.toLowerCase())},{option:a.withCtx(C=>{var w,B;return[a.createElementVNode("span",null,a.toDisplayString(C[(B=(w=ut.fields)==null?void 0:w.relation)==null?void 0:B.display]),1)]}),"list-footer":a.withCtx(()=>[a.withDirectives(a.createElementVNode("li",{ref_key:"loadMoreTrigger",ref:Z,class:"flex items-center justify-center"},D[3]||(D[3]=[a.createElementVNode("i",{class:"fa-solid fa-spinner animate-spin"},null,-1)]),512),[[a.vShow,A.value]])]),_:1},8,["modelValue","class","options","reduce","label","disabled"])])]),ut.error&&((b=ut.error)==null?void 0:b.length)>0?(a.openBlock(),a.createElementBlock("p",o1,"*"+a.toDisplayString(ut.error),1)):a.createCommentVNode("",!0)])}}});Ne.LuxtRelation=s1,Ne.OfficeCollection=qg,Ne.OfficeCollectionTable=w_,Ne.OfficeHeader=Ou,Ne.OfficeLayout=Cu,Ne.OfficeLayoutWrapper=yg,Ne.OfficeLink=Bg,Ne.OfficeRelation=X0,Ne.OfficeSingle=P_,Ne.OfficeTab=N_,Ne.OfficeTabs=A_,Object.defineProperty(Ne,Symbol.toStringTag,{value:"Module"})});
|