@syntify/office 0.1.7-beta.2 → 0.1.7

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.
@@ -8884,7 +8884,7 @@ const G_ = { class: "synt-office-relation-wrapper" }, Z_ = { class: "synt-office
8884
8884
  setup(d, { emit: m }) {
8885
8885
  const a = d, z = m, T = rv(d, "modelValue"), { options: F, isLoading: w, fetchData: B } = K_({
8886
8886
  relation: a.fields.relation
8887
- }), q = et(""), ie = et(10), oe = et(null), fe = et(null), ee = et(!1), M = Ar(() => {
8887
+ }), q = et(""), ie = et(99999), oe = et(null), fe = et(null), ee = et(!1), M = Ar(() => {
8888
8888
  var j, re;
8889
8889
  return (re = (j = a.fields) == null ? void 0 : j.options) == null ? void 0 : re.isMultiple;
8890
8890
  }), Z = Ar(() => {
@@ -8919,7 +8919,7 @@ const G_ = { class: "synt-office-relation-wrapper" }, Z_ = { class: "synt-office
8919
8919
  ie.value += 10, await Jg(), Dt.scrollTop = en;
8920
8920
  }
8921
8921
  }, tt = async () => {
8922
- await B({ query: Ct.value });
8922
+ F.value.length || await B({ query: Ct.value });
8923
8923
  }, Fe = async (j) => {
8924
8924
  Array.isArray(T.value) && (T.value.includes(j) ? T.value = T.value.filter((Dt) => Dt !== j) : T.value.push(j)), await tt();
8925
8925
  }, gt = Ar(() => {
@@ -58,4 +58,4 @@ function print() { __p += __j.call(arguments, '') }
58
58
  * @license MIT licensed
59
59
  *
60
60
  * Copyright (C) 2018 Varun A P
61
- */var o0=El.exports,bg;function u0(){return bg||(bg=1,function(g){(function(w,l){g.exports?g.exports=l():w.Toastify=l()})(o0,function(w){var l=function(b){return new l.lib.init(b)},U="1.12.0";l.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:""}},l.lib=l.prototype={toastify:U,constructor:l,init:function(b){return b||(b={}),this.options={},this.toastElement=null,this.options.text=b.text||l.defaults.text,this.options.node=b.node||l.defaults.node,this.options.duration=b.duration===0?0:b.duration||l.defaults.duration,this.options.selector=b.selector||l.defaults.selector,this.options.callback=b.callback||l.defaults.callback,this.options.destination=b.destination||l.defaults.destination,this.options.newWindow=b.newWindow||l.defaults.newWindow,this.options.close=b.close||l.defaults.close,this.options.gravity=b.gravity==="bottom"?"toastify-bottom":l.defaults.gravity,this.options.positionLeft=b.positionLeft||l.defaults.positionLeft,this.options.position=b.position||l.defaults.position,this.options.backgroundColor=b.backgroundColor||l.defaults.backgroundColor,this.options.avatar=b.avatar||l.defaults.avatar,this.options.className=b.className||l.defaults.className,this.options.stopOnFocus=b.stopOnFocus===void 0?l.defaults.stopOnFocus:b.stopOnFocus,this.options.onClick=b.onClick||l.defaults.onClick,this.options.offset=b.offset||l.defaults.offset,this.options.escapeMarkup=b.escapeMarkup!==void 0?b.escapeMarkup:l.defaults.escapeMarkup,this.options.ariaLive=b.ariaLive||l.defaults.ariaLive,this.options.style=b.style||l.defaults.style,b.backgroundColor&&(this.options.style.background=b.backgroundColor),this},buildToast:function(){if(!this.options)throw"Toastify is not initialized";var b=document.createElement("div");b.className="toastify on "+this.options.className,this.options.position?b.className+=" toastify-"+this.options.position:this.options.positionLeft===!0?(b.className+=" toastify-left",console.warn("Property `positionLeft` will be depreciated in further versions. Please use `position` instead.")):b.className+=" toastify-right",b.className+=" "+this.options.gravity,this.options.backgroundColor&&console.warn('DEPRECATION NOTICE: "backgroundColor" is being deprecated. Please use the "style.background" property.');for(var R in this.options.style)b.style[R]=this.options.style[R];if(this.options.ariaLive&&b.setAttribute("aria-live",this.options.ariaLive),this.options.node&&this.options.node.nodeType===Node.ELEMENT_NODE)b.appendChild(this.options.node);else if(this.options.escapeMarkup?b.innerText=this.options.text:b.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?b.appendChild(z):b.insertAdjacentElement("afterbegin",z)}if(this.options.close===!0){var re=document.createElement("button");re.type="button",re.setAttribute("aria-label","Close"),re.className="toast-close",re.innerHTML="&#10006;",re.addEventListener("click",(function(q){q.stopPropagation(),this.removeElement(this.toastElement),window.clearTimeout(this.toastElement.timeOutValue)}).bind(this));var ie=window.innerWidth>0?window.innerWidth:screen.width;(this.options.position=="left"||this.options.positionLeft===!0)&&ie>360?b.insertAdjacentElement("afterbegin",re):b.appendChild(re)}if(this.options.stopOnFocus&&this.options.duration>0){var ae=this;b.addEventListener("mouseover",function(q){window.clearTimeout(b.timeOutValue)}),b.addEventListener("mouseleave",function(){b.timeOutValue=window.setTimeout(function(){ae.removeElement(b)},ae.options.duration)})}if(typeof this.options.destination<"u"&&b.addEventListener("click",(function(q){q.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"&&b.addEventListener("click",(function(q){q.stopPropagation(),this.options.onClick()}).bind(this)),typeof this.options.offset=="object"){var j=L("x",this.options),$=L("y",this.options),Z=this.options.position=="left"?j:"-"+j,He=this.options.gravity=="toastify-top"?$:"-"+$;b.style.transform="translate("+Z+","+He+")"}return b},showToast:function(){this.toastElement=this.buildToast();var b;if(typeof this.options.selector=="string"?b=document.getElementById(this.options.selector):this.options.selector instanceof HTMLElement||typeof ShadowRoot<"u"&&this.options.selector instanceof ShadowRoot?b=this.options.selector:b=document.body,!b)throw"Root element is not defined";var R=l.defaults.oldestFirst?b.firstChild:b.lastChild;return b.insertBefore(this.toastElement,R),l.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(b){b.className=b.className.replace(" on",""),window.setTimeout((function(){this.options.node&&this.options.node.parentNode&&this.options.node.parentNode.removeChild(this.options.node),b.parentNode&&b.parentNode.removeChild(b),this.options.callback.call(b),l.reposition()}).bind(this),400)}},l.reposition=function(){for(var b={top:15,bottom:15},R={top:15,bottom:15},z={top:15,bottom:15},re=document.getElementsByClassName("toastify"),ie,ae=0;ae<re.length;ae++){P(re[ae],"toastify-top")===!0?ie="toastify-top":ie="toastify-bottom";var j=re[ae].offsetHeight;ie=ie.substr(9,ie.length-1);var $=15,Z=window.innerWidth>0?window.innerWidth:screen.width;Z<=360?(re[ae].style[ie]=z[ie]+"px",z[ie]+=j+$):P(re[ae],"toastify-left")===!0?(re[ae].style[ie]=b[ie]+"px",b[ie]+=j+$):(re[ae].style[ie]=R[ie]+"px",R[ie]+=j+$)}return this};function L(b,R){return R.offset[b]?isNaN(R.offset[b])?R.offset[b]:R.offset[b]+"px":"0px"}function P(b,R){return!b||typeof R!="string"?!1:!!(b.className&&b.className.trim().split(/\s+/gi).indexOf(R)>-1)}return l.lib.init.prototype=l.lib,l})}(El)),El.exports}u0();function l0(g){const[w,l,U]=g.relation.definition.split(":"),L=g.relation.api[l],P=s.ref(!1),b=s.ref([]),R=s.ref({limit:99999,page:1});return{options:b,isLoading:P,finalQuery:R,fetchData:async(z={query:[]})=>{P.value=!0;try{const re=s.computed(()=>({limit:R.value.limit,page:R.value.page,filter:JSON.stringify(z.query)}));await L.get(`/api/${U}`,{params:re.value}).then(ie=>ie.data).then(ie=>{ie.code==200&&(b.value=ie==null?void 0:ie.data)})}catch(re){console.error("Error fetching data:",re)}finally{P.value=!1}}}}const a0={class:"synt-office-relation-wrapper"},s0={class:"synt-office-relation-label"},f0={class:"synt-office-relation-note"},c0={class:"synt-office-relation-group-input-wrapper"},h0={class:"synt-office-relation-input-wrapper"},p0={class:"synt-office-relation-skeleton-wrapper"},d0={key:0,class:"synt-office-relation-modal-overlay"},g0={class:"synt-office-relation-modal-wrapper"},_0={class:"synt-office-relation-modal-header-end"},v0={class:"synt-office-relation-modal-option"},m0={class:"synt-office-relation-modal-table-wrapper"},y0={id:"table-relation-collection"},w0=["checked"],b0={class:"synt-office-relation-modal-table-label"},x0=["checked","onChange"],E0={class:"synt-badge-tabel"},C0={class:"synt-office-relation-modal-table-footer"},O0={class:"synt-office-relation-modal-table-footer-end"},A0={class:"synt-office-relation-font-bold"},S0={class:"synt-office-relation-font-bold"},L0=s.defineComponent({__name:"OfficeRelation",props:s.mergeModels({fields:{},isDisabled:{},isError:{},query:{}},{modelValue:{},modelModifiers:{}}),emits:s.mergeModels(["update:selected"],["update:modelValue"]),setup(g,{emit:w}){const l=g,U=w,L=s.useModel(g,"modelValue"),{options:P,isLoading:b,fetchData:R}=l0({relation:l.fields.relation}),z=s.ref(""),re=s.ref(10),ie=s.ref(null),ae=s.ref(null),j=s.ref(!1),$=s.computed(()=>{var Q,ne;return(ne=(Q=l.fields)==null?void 0:Q.options)==null?void 0:ne.isMultiple}),Z=s.computed(()=>{var Q;return(Q=P.value)==null?void 0:Q.filter(ne=>{var Tt,Zt,Yt,wn;return(wn=(Yt=ne==null?void 0:ne[(Zt=(Tt=l.fields)==null?void 0:Tt.relation)==null?void 0:Zt.display])==null?void 0:Yt.toLowerCase())==null?void 0:wn.includes(z.value)})}),He=s.computed(()=>Z.value.slice(0,re.value)),q=s.computed(()=>He.value.length<Z.value.length),se=s.computed(()=>{var Q;return((Q=P.value)==null?void 0:Q.find(ne=>ne.id===L.value))||null}),yt=s.ref([]);s.watch(()=>l.query,async Q=>{yt.value=Q},{immediate:!0}),s.watch(()=>yt.value,async Q=>{Q&&await R({query:Q})}),s.watch(se,Q=>{U("update:selected",Q)});const Ve=async([{isIntersecting:Q,target:ne}])=>{if(Q){const Tt=ne.offsetParent,Zt=Tt.scrollTop;re.value+=10,await s.nextTick(),Tt.scrollTop=Zt}},Je=async()=>{await R({query:yt.value})},$e=async Q=>{Array.isArray(L.value)&&(L.value.includes(Q)?L.value=L.value.filter(Tt=>Tt!==Q):L.value.push(Q)),await Je()},st=s.computed(()=>{if(Array.isArray(L.value))return Z.value.length>0&&Z.value.every(Q=>Array.isArray(L.value)&&L.value.includes(Q.id))});function Ke(){if(Array.isArray(L.value))if(st.value)L.value=L.value.filter(Q=>!Z.value.map(ne=>ne.id).includes(Q));else{const Q=Z.value.map(ne=>ne.id);L.value=Array.from(new Set([...L.value,...Q]))}}const Nt=async()=>{await Je(),j.value=!0},yn=async()=>{z.value="",j.value=!1};return s.watch(()=>L.value,async()=>{P.value.length||(b.value=!0,L.value&&await Je(),b.value=!1)}),s.onMounted(async()=>{ie.value=new IntersectionObserver(Ve)}),(Q,ne)=>{var Tt,Zt,Yt,wn,Di;return s.openBlock(),s.createElementBlock("div",null,[s.createElementVNode("div",a0,[s.createElementVNode("label",s0,s.toDisplayString((Tt=Q.fields)==null?void 0:Tt.name),1),s.createElementVNode("span",f0,s.toDisplayString((Yt=(Zt=Q.fields)==null?void 0:Zt.options)==null?void 0:Yt.note),1),s.createElementVNode("div",c0,[s.createElementVNode("div",h0,[s.withDirectives(s.createElementVNode("div",p0,ne[3]||(ne[3]=[s.createElementVNode("div",{class:"synt-office-relation-skeleton"},[s.createElementVNode("div",{class:"synt-office-relation-content"})],-1)]),512),[[s.vShow,s.unref(b)]]),s.createVNode(s.unref(n0),{modelValue:L.value,"onUpdate:modelValue":ne[0]||(ne[0]=lt=>L.value=lt),class:s.normalizeClass(["synt-relation-control",{"synt-office-relation-error":Q.isError,"synt-office-relation-disabled":Q.isDisabled,"synt-office-relation-normal":!Q.isError&&!Q.isDisabled}]),options:He.value,reduce:lt=>lt.id,label:(Di=(wn=Q.fields)==null?void 0:wn.relation)==null?void 0:Di.display,placeholder:"Please enter at least 3 letters...",disabled:Q.isDisabled,multiple:$.value,onOpen:Je},{option:s.withCtx(lt=>{var De,bn;return[s.createElementVNode("span",null,s.toDisplayString(lt[(bn=(De=Q.fields)==null?void 0:De.relation)==null?void 0:bn.display]),1)]}),"list-footer":s.withCtx(()=>[s.withDirectives(s.createElementVNode("li",{ref_key:"load",ref:ae,class:"synt-office-relation-loading"},ne[4]||(ne[4]=[s.createElementVNode("i",{class:"synt-office-relation-loading-spin fa-solid fa-spinner"},null,-1)]),512),[[s.vShow,q.value]])]),_:1},8,["modelValue","class","options","reduce","label","disabled","multiple"])]),$.value?(s.openBlock(),s.createElementBlock("button",{key:0,type:"button",class:"synt-office-relation-btn-expands",onClick:s.withModifiers(Nt,["prevent"])},ne[5]||(ne[5]=[s.createElementVNode("i",{class:"synt-office-relation-btn-expands-icon fa-solid fa-up-right-and-down-left-from-center"},null,-1)]))):s.createCommentVNode("",!0)])]),s.createVNode(s.Transition,{name:"fade"},{default:s.withCtx(()=>{var lt;return[j.value?(s.openBlock(),s.createElementBlock("div",d0,[s.createElementVNode("div",g0,[s.createVNode(s.unref(wl),{label:Q.fields.name,icon:"fa-solid fa-table"},{end:s.withCtx(()=>[s.createElementVNode("div",_0,[s.createElementVNode("button",{type:"button",class:"synt-office-relation-modal-btn-close",onClick:s.withModifiers(yn,["prevent"])},ne[6]||(ne[6]=[s.createElementVNode("i",{class:"fa-solid fa-xmark"},null,-1)]))])]),_:1},8,["label"]),s.createElementVNode("div",v0,[s.withDirectives(s.createElementVNode("input",{"onUpdate:modelValue":ne[1]||(ne[1]=De=>z.value=De),type:"search",placeholder:"Cari...",class:"synt-office-relation-modal-search"},null,512),[[s.vModelText,z.value]]),s.createElementVNode("button",{type:"button",class:"synt-office-relation-modal-btn-refresh",onClick:ne[2]||(ne[2]=s.withModifiers(De=>s.unref(R)(),["prevent"]))},ne[7]||(ne[7]=[s.createElementVNode("i",{class:"synt-office-relation-modal-btn-icon fa-solid fa-sync"},null,-1)]))]),s.createElementVNode("div",m0,[s.createElementVNode("table",y0,[s.createElementVNode("thead",null,[s.createElementVNode("tr",null,[s.createElementVNode("th",null,[z.value?s.createCommentVNode("",!0):(s.openBlock(),s.createElementBlock("input",{key:0,type:"checkbox",class:"synt-office-relation-modal-table-checkbox",checked:st.value,onChange:Ke},null,40,w0))]),s.createElementVNode("th",b0,s.toDisplayString((lt=Q.fields)==null?void 0:lt.name),1)])]),s.createElementVNode("tbody",null,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(Z.value,De=>{var bn,Gt;return s.openBlock(),s.createElementBlock("tr",{key:De.id},[s.createElementVNode("td",null,[s.createElementVNode("input",{type:"checkbox",class:"synt-office-relation-modal-table-checkbox",checked:Array.isArray(L.value)&&L.value.includes(De.id),onChange:qe=>$e(De.id)},null,40,x0)]),s.createElementVNode("td",null,[s.createElementVNode("div",E0,s.toDisplayString(De[(Gt=(bn=Q.fields)==null?void 0:bn.relation)==null?void 0:Gt.display]),1)])])}),128))])])]),s.createElementVNode("div",C0,[s.createElementVNode("div",O0,[ne[8]||(ne[8]=s.createElementVNode("span",{class:"synt-office-relation-font-bold"},s.toDisplayString(1),-1)),ne[9]||(ne[9]=s.createTextVNode(" - ")),s.createElementVNode("span",A0,s.toDisplayString(Z.value.length),1),ne[10]||(ne[10]=s.createTextVNode(" dari ")),s.createElementVNode("span",S0,s.toDisplayString(Z.value.length),1)])])])])):s.createCommentVNode("",!0)]}),_:1})])}}});at.OfficeCollection=Ig,at.OfficeCollectionTable=Xg,at.OfficeHeader=wl,at.OfficeLayout=bl,at.OfficeLayoutWrapper=dg,at.OfficeLink=Eg,at.OfficeRelation=L0,at.OfficeSingle=v_,at.OfficeTab=a_,at.OfficeTabs=u_,Object.defineProperty(at,Symbol.toStringTag,{value:"Module"})});
61
+ */var o0=El.exports,bg;function u0(){return bg||(bg=1,function(g){(function(w,l){g.exports?g.exports=l():w.Toastify=l()})(o0,function(w){var l=function(b){return new l.lib.init(b)},U="1.12.0";l.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:""}},l.lib=l.prototype={toastify:U,constructor:l,init:function(b){return b||(b={}),this.options={},this.toastElement=null,this.options.text=b.text||l.defaults.text,this.options.node=b.node||l.defaults.node,this.options.duration=b.duration===0?0:b.duration||l.defaults.duration,this.options.selector=b.selector||l.defaults.selector,this.options.callback=b.callback||l.defaults.callback,this.options.destination=b.destination||l.defaults.destination,this.options.newWindow=b.newWindow||l.defaults.newWindow,this.options.close=b.close||l.defaults.close,this.options.gravity=b.gravity==="bottom"?"toastify-bottom":l.defaults.gravity,this.options.positionLeft=b.positionLeft||l.defaults.positionLeft,this.options.position=b.position||l.defaults.position,this.options.backgroundColor=b.backgroundColor||l.defaults.backgroundColor,this.options.avatar=b.avatar||l.defaults.avatar,this.options.className=b.className||l.defaults.className,this.options.stopOnFocus=b.stopOnFocus===void 0?l.defaults.stopOnFocus:b.stopOnFocus,this.options.onClick=b.onClick||l.defaults.onClick,this.options.offset=b.offset||l.defaults.offset,this.options.escapeMarkup=b.escapeMarkup!==void 0?b.escapeMarkup:l.defaults.escapeMarkup,this.options.ariaLive=b.ariaLive||l.defaults.ariaLive,this.options.style=b.style||l.defaults.style,b.backgroundColor&&(this.options.style.background=b.backgroundColor),this},buildToast:function(){if(!this.options)throw"Toastify is not initialized";var b=document.createElement("div");b.className="toastify on "+this.options.className,this.options.position?b.className+=" toastify-"+this.options.position:this.options.positionLeft===!0?(b.className+=" toastify-left",console.warn("Property `positionLeft` will be depreciated in further versions. Please use `position` instead.")):b.className+=" toastify-right",b.className+=" "+this.options.gravity,this.options.backgroundColor&&console.warn('DEPRECATION NOTICE: "backgroundColor" is being deprecated. Please use the "style.background" property.');for(var R in this.options.style)b.style[R]=this.options.style[R];if(this.options.ariaLive&&b.setAttribute("aria-live",this.options.ariaLive),this.options.node&&this.options.node.nodeType===Node.ELEMENT_NODE)b.appendChild(this.options.node);else if(this.options.escapeMarkup?b.innerText=this.options.text:b.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?b.appendChild(z):b.insertAdjacentElement("afterbegin",z)}if(this.options.close===!0){var re=document.createElement("button");re.type="button",re.setAttribute("aria-label","Close"),re.className="toast-close",re.innerHTML="&#10006;",re.addEventListener("click",(function(q){q.stopPropagation(),this.removeElement(this.toastElement),window.clearTimeout(this.toastElement.timeOutValue)}).bind(this));var ie=window.innerWidth>0?window.innerWidth:screen.width;(this.options.position=="left"||this.options.positionLeft===!0)&&ie>360?b.insertAdjacentElement("afterbegin",re):b.appendChild(re)}if(this.options.stopOnFocus&&this.options.duration>0){var ae=this;b.addEventListener("mouseover",function(q){window.clearTimeout(b.timeOutValue)}),b.addEventListener("mouseleave",function(){b.timeOutValue=window.setTimeout(function(){ae.removeElement(b)},ae.options.duration)})}if(typeof this.options.destination<"u"&&b.addEventListener("click",(function(q){q.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"&&b.addEventListener("click",(function(q){q.stopPropagation(),this.options.onClick()}).bind(this)),typeof this.options.offset=="object"){var j=L("x",this.options),$=L("y",this.options),Z=this.options.position=="left"?j:"-"+j,He=this.options.gravity=="toastify-top"?$:"-"+$;b.style.transform="translate("+Z+","+He+")"}return b},showToast:function(){this.toastElement=this.buildToast();var b;if(typeof this.options.selector=="string"?b=document.getElementById(this.options.selector):this.options.selector instanceof HTMLElement||typeof ShadowRoot<"u"&&this.options.selector instanceof ShadowRoot?b=this.options.selector:b=document.body,!b)throw"Root element is not defined";var R=l.defaults.oldestFirst?b.firstChild:b.lastChild;return b.insertBefore(this.toastElement,R),l.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(b){b.className=b.className.replace(" on",""),window.setTimeout((function(){this.options.node&&this.options.node.parentNode&&this.options.node.parentNode.removeChild(this.options.node),b.parentNode&&b.parentNode.removeChild(b),this.options.callback.call(b),l.reposition()}).bind(this),400)}},l.reposition=function(){for(var b={top:15,bottom:15},R={top:15,bottom:15},z={top:15,bottom:15},re=document.getElementsByClassName("toastify"),ie,ae=0;ae<re.length;ae++){P(re[ae],"toastify-top")===!0?ie="toastify-top":ie="toastify-bottom";var j=re[ae].offsetHeight;ie=ie.substr(9,ie.length-1);var $=15,Z=window.innerWidth>0?window.innerWidth:screen.width;Z<=360?(re[ae].style[ie]=z[ie]+"px",z[ie]+=j+$):P(re[ae],"toastify-left")===!0?(re[ae].style[ie]=b[ie]+"px",b[ie]+=j+$):(re[ae].style[ie]=R[ie]+"px",R[ie]+=j+$)}return this};function L(b,R){return R.offset[b]?isNaN(R.offset[b])?R.offset[b]:R.offset[b]+"px":"0px"}function P(b,R){return!b||typeof R!="string"?!1:!!(b.className&&b.className.trim().split(/\s+/gi).indexOf(R)>-1)}return l.lib.init.prototype=l.lib,l})}(El)),El.exports}u0();function l0(g){const[w,l,U]=g.relation.definition.split(":"),L=g.relation.api[l],P=s.ref(!1),b=s.ref([]),R=s.ref({limit:99999,page:1});return{options:b,isLoading:P,finalQuery:R,fetchData:async(z={query:[]})=>{P.value=!0;try{const re=s.computed(()=>({limit:R.value.limit,page:R.value.page,filter:JSON.stringify(z.query)}));await L.get(`/api/${U}`,{params:re.value}).then(ie=>ie.data).then(ie=>{ie.code==200&&(b.value=ie==null?void 0:ie.data)})}catch(re){console.error("Error fetching data:",re)}finally{P.value=!1}}}}const a0={class:"synt-office-relation-wrapper"},s0={class:"synt-office-relation-label"},f0={class:"synt-office-relation-note"},c0={class:"synt-office-relation-group-input-wrapper"},h0={class:"synt-office-relation-input-wrapper"},p0={class:"synt-office-relation-skeleton-wrapper"},d0={key:0,class:"synt-office-relation-modal-overlay"},g0={class:"synt-office-relation-modal-wrapper"},_0={class:"synt-office-relation-modal-header-end"},v0={class:"synt-office-relation-modal-option"},m0={class:"synt-office-relation-modal-table-wrapper"},y0={id:"table-relation-collection"},w0=["checked"],b0={class:"synt-office-relation-modal-table-label"},x0=["checked","onChange"],E0={class:"synt-badge-tabel"},C0={class:"synt-office-relation-modal-table-footer"},O0={class:"synt-office-relation-modal-table-footer-end"},A0={class:"synt-office-relation-font-bold"},S0={class:"synt-office-relation-font-bold"},L0=s.defineComponent({__name:"OfficeRelation",props:s.mergeModels({fields:{},isDisabled:{},isError:{},query:{}},{modelValue:{},modelModifiers:{}}),emits:s.mergeModels(["update:selected"],["update:modelValue"]),setup(g,{emit:w}){const l=g,U=w,L=s.useModel(g,"modelValue"),{options:P,isLoading:b,fetchData:R}=l0({relation:l.fields.relation}),z=s.ref(""),re=s.ref(99999),ie=s.ref(null),ae=s.ref(null),j=s.ref(!1),$=s.computed(()=>{var Q,ne;return(ne=(Q=l.fields)==null?void 0:Q.options)==null?void 0:ne.isMultiple}),Z=s.computed(()=>{var Q;return(Q=P.value)==null?void 0:Q.filter(ne=>{var Tt,Zt,Yt,wn;return(wn=(Yt=ne==null?void 0:ne[(Zt=(Tt=l.fields)==null?void 0:Tt.relation)==null?void 0:Zt.display])==null?void 0:Yt.toLowerCase())==null?void 0:wn.includes(z.value)})}),He=s.computed(()=>Z.value.slice(0,re.value)),q=s.computed(()=>He.value.length<Z.value.length),se=s.computed(()=>{var Q;return((Q=P.value)==null?void 0:Q.find(ne=>ne.id===L.value))||null}),yt=s.ref([]);s.watch(()=>l.query,async Q=>{yt.value=Q},{immediate:!0}),s.watch(()=>yt.value,async Q=>{Q&&await R({query:Q})}),s.watch(se,Q=>{U("update:selected",Q)});const Ve=async([{isIntersecting:Q,target:ne}])=>{if(Q){const Tt=ne.offsetParent,Zt=Tt.scrollTop;re.value+=10,await s.nextTick(),Tt.scrollTop=Zt}},Je=async()=>{P.value.length||await R({query:yt.value})},$e=async Q=>{Array.isArray(L.value)&&(L.value.includes(Q)?L.value=L.value.filter(Tt=>Tt!==Q):L.value.push(Q)),await Je()},st=s.computed(()=>{if(Array.isArray(L.value))return Z.value.length>0&&Z.value.every(Q=>Array.isArray(L.value)&&L.value.includes(Q.id))});function Ke(){if(Array.isArray(L.value))if(st.value)L.value=L.value.filter(Q=>!Z.value.map(ne=>ne.id).includes(Q));else{const Q=Z.value.map(ne=>ne.id);L.value=Array.from(new Set([...L.value,...Q]))}}const Nt=async()=>{await Je(),j.value=!0},yn=async()=>{z.value="",j.value=!1};return s.watch(()=>L.value,async()=>{P.value.length||(b.value=!0,L.value&&await Je(),b.value=!1)}),s.onMounted(async()=>{ie.value=new IntersectionObserver(Ve)}),(Q,ne)=>{var Tt,Zt,Yt,wn,Di;return s.openBlock(),s.createElementBlock("div",null,[s.createElementVNode("div",a0,[s.createElementVNode("label",s0,s.toDisplayString((Tt=Q.fields)==null?void 0:Tt.name),1),s.createElementVNode("span",f0,s.toDisplayString((Yt=(Zt=Q.fields)==null?void 0:Zt.options)==null?void 0:Yt.note),1),s.createElementVNode("div",c0,[s.createElementVNode("div",h0,[s.withDirectives(s.createElementVNode("div",p0,ne[3]||(ne[3]=[s.createElementVNode("div",{class:"synt-office-relation-skeleton"},[s.createElementVNode("div",{class:"synt-office-relation-content"})],-1)]),512),[[s.vShow,s.unref(b)]]),s.createVNode(s.unref(n0),{modelValue:L.value,"onUpdate:modelValue":ne[0]||(ne[0]=lt=>L.value=lt),class:s.normalizeClass(["synt-relation-control",{"synt-office-relation-error":Q.isError,"synt-office-relation-disabled":Q.isDisabled,"synt-office-relation-normal":!Q.isError&&!Q.isDisabled}]),options:He.value,reduce:lt=>lt.id,label:(Di=(wn=Q.fields)==null?void 0:wn.relation)==null?void 0:Di.display,placeholder:"Please enter at least 3 letters...",disabled:Q.isDisabled,multiple:$.value,onOpen:Je},{option:s.withCtx(lt=>{var De,bn;return[s.createElementVNode("span",null,s.toDisplayString(lt[(bn=(De=Q.fields)==null?void 0:De.relation)==null?void 0:bn.display]),1)]}),"list-footer":s.withCtx(()=>[s.withDirectives(s.createElementVNode("li",{ref_key:"load",ref:ae,class:"synt-office-relation-loading"},ne[4]||(ne[4]=[s.createElementVNode("i",{class:"synt-office-relation-loading-spin fa-solid fa-spinner"},null,-1)]),512),[[s.vShow,q.value]])]),_:1},8,["modelValue","class","options","reduce","label","disabled","multiple"])]),$.value?(s.openBlock(),s.createElementBlock("button",{key:0,type:"button",class:"synt-office-relation-btn-expands",onClick:s.withModifiers(Nt,["prevent"])},ne[5]||(ne[5]=[s.createElementVNode("i",{class:"synt-office-relation-btn-expands-icon fa-solid fa-up-right-and-down-left-from-center"},null,-1)]))):s.createCommentVNode("",!0)])]),s.createVNode(s.Transition,{name:"fade"},{default:s.withCtx(()=>{var lt;return[j.value?(s.openBlock(),s.createElementBlock("div",d0,[s.createElementVNode("div",g0,[s.createVNode(s.unref(wl),{label:Q.fields.name,icon:"fa-solid fa-table"},{end:s.withCtx(()=>[s.createElementVNode("div",_0,[s.createElementVNode("button",{type:"button",class:"synt-office-relation-modal-btn-close",onClick:s.withModifiers(yn,["prevent"])},ne[6]||(ne[6]=[s.createElementVNode("i",{class:"fa-solid fa-xmark"},null,-1)]))])]),_:1},8,["label"]),s.createElementVNode("div",v0,[s.withDirectives(s.createElementVNode("input",{"onUpdate:modelValue":ne[1]||(ne[1]=De=>z.value=De),type:"search",placeholder:"Cari...",class:"synt-office-relation-modal-search"},null,512),[[s.vModelText,z.value]]),s.createElementVNode("button",{type:"button",class:"synt-office-relation-modal-btn-refresh",onClick:ne[2]||(ne[2]=s.withModifiers(De=>s.unref(R)(),["prevent"]))},ne[7]||(ne[7]=[s.createElementVNode("i",{class:"synt-office-relation-modal-btn-icon fa-solid fa-sync"},null,-1)]))]),s.createElementVNode("div",m0,[s.createElementVNode("table",y0,[s.createElementVNode("thead",null,[s.createElementVNode("tr",null,[s.createElementVNode("th",null,[z.value?s.createCommentVNode("",!0):(s.openBlock(),s.createElementBlock("input",{key:0,type:"checkbox",class:"synt-office-relation-modal-table-checkbox",checked:st.value,onChange:Ke},null,40,w0))]),s.createElementVNode("th",b0,s.toDisplayString((lt=Q.fields)==null?void 0:lt.name),1)])]),s.createElementVNode("tbody",null,[(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(Z.value,De=>{var bn,Gt;return s.openBlock(),s.createElementBlock("tr",{key:De.id},[s.createElementVNode("td",null,[s.createElementVNode("input",{type:"checkbox",class:"synt-office-relation-modal-table-checkbox",checked:Array.isArray(L.value)&&L.value.includes(De.id),onChange:qe=>$e(De.id)},null,40,x0)]),s.createElementVNode("td",null,[s.createElementVNode("div",E0,s.toDisplayString(De[(Gt=(bn=Q.fields)==null?void 0:bn.relation)==null?void 0:Gt.display]),1)])])}),128))])])]),s.createElementVNode("div",C0,[s.createElementVNode("div",O0,[ne[8]||(ne[8]=s.createElementVNode("span",{class:"synt-office-relation-font-bold"},s.toDisplayString(1),-1)),ne[9]||(ne[9]=s.createTextVNode(" - ")),s.createElementVNode("span",A0,s.toDisplayString(Z.value.length),1),ne[10]||(ne[10]=s.createTextVNode(" dari ")),s.createElementVNode("span",S0,s.toDisplayString(Z.value.length),1)])])])])):s.createCommentVNode("",!0)]}),_:1})])}}});at.OfficeCollection=Ig,at.OfficeCollectionTable=Xg,at.OfficeHeader=wl,at.OfficeLayout=bl,at.OfficeLayoutWrapper=dg,at.OfficeLink=Eg,at.OfficeRelation=L0,at.OfficeSingle=v_,at.OfficeTab=a_,at.OfficeTabs=u_,Object.defineProperty(at,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syntify/office",
3
- "version": "0.1.7-beta.2",
3
+ "version": "0.1.7",
4
4
  "description": "Office of Syntify Applications",
5
5
  "main": "dist/syntify-office.umd.js",
6
6
  "module": "dist/syntify-office.es.js",