UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

2 lines (1 loc) 20.9 kB
(function(z,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(z=typeof globalThis<"u"?globalThis:z||self,e(z.modal={},z.Vue))})(this,function(z,e){"use strict";var Ne=Object.defineProperty;var He=(z,e,P)=>e in z?Ne(z,e,{enumerable:!0,configurable:!0,writable:!0,value:P}):z[e]=P;var Y=(z,e,P)=>He(z,typeof e!="symbol"?e+"":e,P);const P={class:{type:String,default:""},title:{type:String,default:""},width:{type:Number,default:500},height:{type:Number,default:320},buttons:{type:Array,default:[]},modelValue:{type:Boolean,default:!1},showHeader:{type:Boolean,default:!0},showButtons:{type:Boolean,default:!0},fitContent:{type:Boolean,default:!0},showCloseButton:{type:Boolean,default:!0},showMaxButton:{type:Boolean,default:!1},minHeight:{type:Number},maxHeight:{type:Number},minWidth:{type:Number},maxWidth:{type:Number},containment:{type:Object,default:null},resizeable:{type:Boolean,default:!1},draggable:{type:Boolean,default:!1},dragHandle:{type:Object,default:null},closedCallback:{type:Function,default:null},resizeHandle:{type:Function,default:null},render:{type:Function,default:null},acceptCallback:{type:Function,default:null},rejectCallback:{type:Function,default:null},enableEsc:{type:Boolean,default:!0},enableEnter:{type:Boolean,default:!1},dialogType:{type:String,default:""},src:{type:String,default:""},footerHeight:{type:Number,default:60}};class C{constructor(t,n){this.x=t,this.y=n}static getTransformInfo(t){const o=window.getComputedStyle(t).getPropertyValue("transform").replace(/[^-\d,]/g,"").split(",");if(o.length>=6){const h=parseInt(o[4],10),v=parseInt(o[5],10);return{x:h,y:v}}return{x:0,y:0}}static fromEvent(t,n=null){if(this.isMouseEvent(t))return new C(t.clientX,t.clientY);if(n===null||t.changedTouches.length===1)return new C(t.changedTouches[0].clientX,t.changedTouches[0].clientY);for(let o=0;o<t.changedTouches.length;o++)if(t.changedTouches[o].target===n)return new C(t.changedTouches[o].clientX,t.changedTouches[o].clientY)}static isMouseEvent(t){return Object.prototype.toString.apply(t).indexOf("MouseEvent")===8}static isIPosition(t){return!!t&&"x"in t&&"y"in t}static getCurrent(t){const n=new C(0,0);if(window){const o=window.getComputedStyle(t);if(o){const h=parseInt(o.getPropertyValue("left"),10),v=parseInt(o.getPropertyValue("top"),10);n.x=isNaN(h)?0:h,n.y=isNaN(v)?0:v}return n}return null}static copy(t){return new C(0,0).set(t)}get value(){return{x:this.x,y:this.y}}add(t){return this.x+=t.x,this.y+=t.y,this}subtract(t){return this.x-=t.x,this.y-=t.y,this}multiply(t){this.x*=t,this.y*=t}divide(t){this.x/=t,this.y/=t}reset(){return this.x=0,this.y=0,this}set(t){return this.x=t.x,this.y=t.y,this}}class W{constructor(t,n){this.width=t,this.height=n}static getCurrent(t){const n=new W(0,0);if(window){const o=window.getComputedStyle(t);return o&&(n.width=parseInt(o.getPropertyValue("width"),10),n.height=parseInt(o.getPropertyValue("height"),10)),n}return null}static copy(t){return new W(0,0).set(t)}set(t){return this.width=t.width,this.height=t.height,this}}function ne(a,t){const n=e.ref(),o=e.ref(),h=e.ref(),v=e.ref(),d=e.ref(),u=e.ref(),c=e.ref(),f=e.ref(),M=e.ref(),p=e.ref(),B=e.ref(),H=e.ref(),k=e.ref(a.draggable),S=e.ref(!1);function O(){const s=o.value||document.body,i=window.getComputedStyle(s);if(!i||!n.value)return;const y=C.getTransformInfo(n.value),g={};c.value&&(g.deltaL=n.value.offsetLeft-c.value.x,g.deltaT=n.value.offsetTop-c.value.y);const E=i.getPropertyValue("position");g.width=s.clientWidth,g.height=s.clientHeight,g.pr=parseInt(i.getPropertyValue("padding-right"),10),g.pb=parseInt(i.getPropertyValue("padding-bottom"),10),g.position=i.getPropertyValue("position"),E==="static"&&(s.style.position="relative"),g.translateX=y.x,g.translateY=y.y,p.value=g}function I(s){if(n.value){v.value=W.getCurrent(n.value),d.value=C.getCurrent(n.value),u.value=v.value?W.copy(v.value):null,c.value=d.value?C.copy(d.value):null,O();const i=s.target.getAttribute("type")||"";f.value={n:!!i.match(/n/),s:!!i.match(/s/),w:!!i.match(/w/),e:!!i.match(/e/)}}}function R(){var s,i,y,g;if(n.value){const E=n.value;f.value&&((f.value.n||f.value.s)&&((s=u.value)!=null&&s.height)&&(E.style.height=u.value.height+"px"),(f.value.w||f.value.e)&&((i=u.value)!=null&&i.width)&&(E.style.width=u.value.width+"px"),c.value&&((y=c.value)!=null&&y.x&&(E.style.left=c.value.x+"px"),(g=c.value)!=null&&g.y&&(E.style.top=c.value.y+"px")))}}function j(){const s=a.minHeight?a.minHeight:1,i=a.minWidth?a.minWidth:1;u.value&&c.value&&f.value&&v.value&&(u.value.height<s&&(u.value.height=s,f.value.n&&d.value&&(c.value.y=d.value.y+(v.value.height-s))),u.value.width<i&&(u.value.width=i,f.value.w&&d.value&&(c.value.x=d.value.x+(v.value.width-i))),a.maxHeight&&u.value.height>a.maxHeight&&(u.value.height=a.maxHeight,d.value&&f.value.n&&(c.value.y=d.value.y+(v.value.height-a.maxHeight))),a.maxWidth&&u.value.width>a.maxWidth&&(u.value.width=a.maxWidth,f.value.w&&d.value&&(c.value.x=d.value.x+(v.value.width-a.maxWidth))))}function w(){if(o.value){const s=p.value;if(c.value&&u.value&&f.value&&v.value){const i=s.width-s.pr-s.deltaL-s.translateX-c.value.x,y=s.height-s.pb-s.deltaT-s.translateY-c.value.y;f.value.n&&c.value.y+s.translateY<0&&d.value&&(c.value.y=-s.translateY,u.value.height=v.value.height+d.value.y+s.translateY),f.value.w&&c.value.x+s.translateX<0&&d.value&&(c.value.x=-s.translateX,u.value.width=v.value.width+d.value.x+s.translateX),u.value.width>i&&(u.value.width=i),u.value.height>y&&(u.value.height=y)}}}function x(s){if(!h.value||!v.value||!d.value||!f.value)return;s.subtract(h.value);const i=s.x,y=s.y;f.value.n?(c.value.y=d.value.y+y,u.value.height=v.value.height-y):f.value.s&&(u.value.height=v.value.height+y),f.value.e?u.value.width=v.value.width+i:f.value.w&&(u.value.width=v.value.width-i,c.value.x=d.value.x+i),w(),j(),R()}function T(s){if(!M.value)return;const i=C.fromEvent(s);i&&x(i)}function r(){if(n.value){const{width:s,height:i,x:y,y:g}=n.value.getBoundingClientRect(),E=C.getTransformInfo(n.value);return{size:{width:s,height:i},position:{x:y-E.x,y:g-E.y}}}return null}function m(s){if(n.value){const i=r();B.value=i}h.value=void 0,v.value=null,d.value=null,u.value=null,c.value=null,f.value=null,M.value=null,document.removeEventListener("mousemove",T),document.removeEventListener("mouseup",m)}function V(){document.addEventListener("mousemove",T),document.addEventListener("mouseup",m)}function N(s){s instanceof MouseEvent&&s.button===2||k.value&&(document.body.click(),s.stopPropagation(),s.preventDefault(),h.value=C.fromEvent(s),M.value=s.target,I(s),V())}function D(s){return n.value=s,e.createVNode(e.Fragment,null,[e.createVNode("div",{class:"fv-resizable-handle fv-resizable-n",type:"n",onMousedown:i=>N(i)},null),e.createVNode("div",{class:"fv-resizable-handle fv-resizable-e",type:"e",onMousedown:i=>N(i)},null),e.createVNode("div",{class:"fv-resizable-handle fv-resizable-s",type:"s",onMousedown:i=>N(i)},null),e.createVNode("div",{class:"fv-resizable-handle fv-resizable-w",type:"w",onMousedown:i=>N(i)},null),e.createVNode("div",{class:"fv-resizable-handle fv-resizable-ne",type:"ne",onMousedown:i=>N(i)},null),e.createVNode("div",{class:"fv-resizable-handle fv-resizable-se fv-resizable-diagonal",type:"se",onMousedown:i=>N(i)},null),e.createVNode("div",{class:"fv-resizable-handle fv-resizable-sw",type:"sw",onMousedown:i=>N(i)},null),e.createVNode("div",{class:"fv-resizable-handle fv-resizable-nw",type:"nw",onMousedown:i=>N(i)},null)])}function L(s=!0){document.body.click();const i=o.value||document.body,y=W.getCurrent(i),g=n.value;s&&g&&(H.value=r(),H.value.transform=g.style.transform),y&&g&&(u.value=y,g.style.height=u.value.height-14+"px",g.style.width=u.value.width-14+"px",g.style.left="7px",g.style.top="7px",g.style.transform="",B.value={size:u.value,position:{x:0,y:0}},k.value=!1,S.value=!0)}function X(){var s,i;if(document.body.click(),H.value){const y={width:H.value.size.width||0,height:H.value.size.height||0},g={x:(window.innerWidth-y.width)/2,y:(window.innerHeight-y.height)/2};(s=u.value)==null||s.set(y),(i=c.value)==null||i.set(g);const E=n.value;E.style.height=y.height+"px",E.style.width=y.width+"px",E.style.left=`${g.x}px`,E.style.top=`${g.y}px`,E.style.transform="",B.value={size:y,position:g},k.value=a.draggable,S.value=!1}}function $(){if(n.value){const s=W.getCurrent(n.value);if(s){const{width:i,height:y}=s;n.value.style.left=`${(window.innerWidth-i)/2}px`,n.value.style.top=`${(window.innerHeight-y)/2}px`,n.value.style.transform=""}}}function _(){const s=()=>{S.value?L(!1):$(),document.body.click()};return window.addEventListener("resize",s),()=>{window.removeEventListener("resize",s)}}const q=_();return{renderResizeBar:D,boundingElement:o,resizedEventParam:B,maximize:L,restore:X,allowDrag:k,isMaximized:S,unWindowResizeHandle:q}}function oe(a,t,n){const o=e.ref(),h=e.ref(a.draggable),v=e.ref(a.lockAxis),d=e.ref(),u=e.ref(),c=e.ref(!1),f=e.ref(new C(0,0)),M=e.ref(new C(0,0)),p=e.ref(new C(0,0)),B=e.ref(new C(0,0));e.watch(()=>n.value,r=>{d.value.style.cursor=r?"move":"default"});function H(r,m){if(m.tagName==="BUTTON")return!1;if(m===r)return!0;for(const V in m.children)if(Object.prototype.hasOwnProperty.call(m.children,V)&&H(r,m.children[V]))return!0;return!1}function k(){var N,D;let r=p.value.x+M.value.x,m=p.value.y+M.value.y;v.value==="x"?(r=((N=f.value)==null?void 0:N.x)||0,p.value.x=0):v.value==="y"&&(m=((D=f.value)==null?void 0:D.y)||0,p.value.y=0);const V=`translate3d(${Math.round(r)}px, ${Math.round(m)}px, 0px)`;o.value&&(o.value.style.transform=V),B.value.x=r,B.value.y=m}function S(){if(!u.value||!o.value)return null;const r=u.value.getBoundingClientRect(),m=o.value.getBoundingClientRect(),V={top:r.top<m.top,right:r.right>m.right,bottom:r.bottom>m.bottom,left:r.left<m.left};return V.top||(p.value.y-=m.top-r.top),V.bottom||(p.value.y-=m.bottom-r.bottom),V.right||(p.value.x-=m.right-r.right),V.left||(p.value.x-=m.left-r.left),k(),V}function O(r){r&&(f.value&&r.subtract(f.value),p.value.set(r),k(),S())}function I(r){c.value&&h.value&&(r.stopPropagation(),r.preventDefault(),O(C.fromEvent(r,d.value)))}function R(){var r;c.value&&(c.value=!1,M.value.add(p.value),p.value.reset(),(r=o.value)==null||r.classList.remove("ng-dragging"),document.removeEventListener("mousemove",I),document.removeEventListener("mouseup",R))}function j(){!c.value&&d.value&&(c.value=!0,d.value.classList.add("ng-dragging"),document.addEventListener("mousemove",I),document.addEventListener("mouseup",R))}function w(){if(o.value){const r=C.getTransformInfo(o.value);M.value.set(r);return}M.value.reset()}function x(r){if(!n.value||r instanceof MouseEvent&&r.button===2)return;const m=r.target||r.srcElement;d.value!==void 0&&m&&!H(m,d.value)||h.value!==!1&&(document.body.click(),r.stopPropagation(),r.preventDefault(),f.value=C.fromEvent(r,o.value),w(),j())}function T(r,m,V){if(h.value&&m){if(r)d.value=r;else if(a.dragHandle){if(a.dragHandle instanceof HTMLElement)d.value=a.dragHandle;else if(typeof a.dragHandle=="string"){const N=m.querySelector(a.dragHandle);N&&(d.value=N)}}o.value=m,u.value=V,d.value?(d.value.classList.add("ng-draggable"),d.value.addEventListener("mousedown",x)):h.value=!1}}return{registerDraggle:T,resetTranslate:w}}function Q(a,t){if(a){const n=o=>{o.key.toLowerCase()===a.toLowerCase()&&t({event:o,key:a})};return document.addEventListener("keydown",n),()=>{document.removeEventListener("keydown",n)}}}function se(a,t){const n=e.ref(a.enableEsc);let o=null;return n.value?(o=Q("Escape",h=>{t.emit("esc",{event:h.event,type:"esc"})}),{remove:o}):null}function ie(a,t){const n=e.ref(a.enableEnter);let o=null;return n.value?(o=Q("Enter",h=>{t.emit("enter",{event:h.event,type:"enter"})}),{remove:o}):null}const F=e.defineComponent({name:"FModal",props:P,emits:["update:modelValue","accept","cancel","closed","resize","esc","enter"],setup(a,t){const n=e.ref(a.width||300),o=e.ref(a.height||200),h=e.ref(a.modelValue),v=e.ref(""),d=e.ref(a.class),u=e.ref(a.fitContent),c=e.ref(a.showHeader),f=e.ref(""),M=e.ref(a.showCloseButton),p=e.ref(a.showMaxButton),B=e.ref(!1),H=e.ref(a.dialogType),k=e.ref(a.src),S=e.ref(""),O=e.ref(a.showButtons),I=e.ref(a.title),R=e.ref(a.resizeable),j=e.ref(a.containment||null),w=e.ref(),x=e.ref(!1);function T(l,b){h.value=!1,t.emit("update:modelValue",!1),b!=null&&t.emit(b?"accept":"cancel"),t.emit("closed",l)}const r=[{name:"cancel",text:"取消",class:"btn btn-secondary",handle:l=>{T(l,!1)}},{name:"accept",text:"确定",class:"btn btn-primary",handle:l=>{T(l,!0)}}],m=e.ref(a.buttons&&a.buttons.length?a.buttons:r),V=e.computed(()=>!!f.value),N=e.computed(()=>!!O.value&&!!m.value),D=e.ref(),L=e.ref(),X=e.ref(!1),{renderResizeBar:$,maximize:_,restore:q,boundingElement:s,resizedEventParam:i,allowDrag:y,unWindowResizeHandle:g}=ne(a),{registerDraggle:E}=oe(a,t,y);function ae(){return!!document.querySelectorAll(".farris-modal").length&&document.body.classList.contains("modal-open")}function ue(){const l=document.querySelectorAll(".farris-modal").length;(!l||l-1<=0)&&document.body.classList.remove("modal-open"),w.value&&w.value.classList.remove("show")}e.watch(()=>a.title,(l,b)=>{l!==b&&(I.value=l)}),e.watch(()=>a.modelValue,(l,b)=>{l!==b&&(h.value=l,l||ue()),h.value&&(x.value=ae())}),e.watch(()=>a.showHeader,(l,b)=>{l!==b&&(c.value=l)}),e.watch(()=>a.showButtons,(l,b)=>{l!==b&&(O.value=l)}),e.watch(()=>i.value,(l,b)=>{const A=l||{},U=b||{};JSON.stringify(A)!==JSON.stringify(U)&&t.emit("resize",{newSize:l,oldSize:b})});const K=e.computed(()=>(h.value&&document.body.classList.add("modal-open"),h.value)),ce=e.computed(()=>{const l={modal:!0,"farris-modal":!0,fade:!0};return l["f-modal-fitContent"]=!!u.value,l.show=!!K.value,l}),de=e.computed(()=>{var A;const l={"modal-dialog":!0},b=(A=d.value)==null?void 0:A.split(" ");return b==null||b.reduce((U,Ve)=>(U[Ve]=!0,U),l),l}),fe=e.computed(()=>({position:"absolute",top:`${(window.innerHeight-o.value)/2}px`,left:`${(window.innerWidth-n.value)/2}px`,width:`${n.value}px`,height:u.value?"auto":`${o.value}px`})),he=e.computed(()=>({"modal-content":!0,"modal-content-has-header":c.value})),ve=e.computed(()=>{const l={display:c.value?"":"none"};return l["pointer-events"]=y.value?"auto":"none",l}),me=e.computed(()=>({"f-icon":!0,modal_maximize:!0,modalrevert:X.value})),ge=e.computed(()=>({"modal-body":!0,"f-utils-flex-column":H.value==="iframe","f-utils-fill":!0}));function ye(){return{height:`${a.footerHeight||60}px`}}const we=e.computed(()=>{const l={textAlgin:S.value},b=ye();return Object.assign(l,b)});function le(l){if(l.stopPropagation(),X.value){X.value=!1,q();return}_(),X.value=!0}async function be(l,b){l.handle&&await l.handle(b,l)&&t.emit("closed",b)}function pe(l){l.width&&(n.value=l.width),l.height&&(o.value=l.height),l.buttons&&(m.value=l.buttons),l.title&&(I.value=l.title)}const xe=e.computed(()=>{const l={display:"inline-block"};return x.value&&(l["background-color"]="transparent"),l});let J=null,G=null;e.onBeforeMount(()=>{x.value=ae()}),e.onMounted(()=>{L.value&&!j.value&&(j.value=L.value.parentElement,s.value=j.value,E(D.value,L.value,s.value)),K.value&&document.body.classList.add("modal-open"),J=se(a,t),G=ie(a,t)}),e.onUnmounted(()=>{g&&g(),J&&J.remove(),G&&G.remove()}),t.expose({modalElementRef:L,updateModalOptions:pe,close:T,maxDialog:le});function Ce(){return e.createVNode("ul",null,[B.value&&e.createVNode("li",{class:"f-btn-icon f-bare"},[e.createVNode("span",{class:"f-icon modal_minimize"},null)]),p.value&&e.createVNode("li",{onClick:le,class:"f-btn-icon f-bare",style:"pointer-events: auto;"},[e.createVNode("span",{class:me.value},null)]),M.value&&e.createVNode("li",{class:"f-btn-icon f-bare",onClick:l=>T(l,!1),style:"pointer-events: auto;"},[e.createVNode("span",{class:"f-icon modal_close"},null)])])}function Me(){return e.createVNode("div",{class:"modal-footer",style:we.value},[m.value&&m.value.map(l=>e.createVNode("button",{name:l.name,type:"button",class:l.class+(l.iconClass?" btn-icontext":""),onClick:b=>{be(l,b)}},[!!l.iconClass&&e.createVNode("i",{class:l.iconClass},null),l.text]))])}function ze(){return e.createVNode("div",{ref:D,class:"modal-header",style:ve.value},[e.createVNode("div",{class:"modal-title"},[V.value&&e.createVNode("span",{class:f.value,style:"margin-right: 8px"},null),e.createVNode("span",{class:"modal-title-label"},[I.value])]),e.createVNode("div",{class:"actions"},[Ce()])])}function Ee(l){l.stopPropagation()}return()=>e.createVNode(e.Teleport,{to:"body"},{default:()=>[K.value&&e.createVNode(e.Transition,{name:"fade",appear:!0},{default:()=>{var l,b;return[e.createVNode("div",{class:ce.value,style:xe.value,ref:w,onClick:Ee},[e.createVNode("div",{id:v.value,class:de.value,style:fe.value,ref:L},[e.createVNode("div",{class:he.value},[c.value&&ze(),e.createVNode("div",{class:ge.value},[(b=(l=t.slots).default)==null?void 0:b.call(l),H.value==="iframe"&&e.createVNode("iframe",{title:v.value,class:"f-utils-fill",width:"100%",frameborder:"0",src:k.value},null)]),N.value&&Me()]),!u.value&&R.value&&L.value&&!X.value&&$(L.value)])])]}})]})}});function Z(a){if(a.content&&a.content.render)return a.content.render;if(a.render&&typeof a.render=="function")return a.render}function re(a){const t=document.createElement("div");t.style.display="contents";const n=e.createApp({setup(o,h){e.onUnmounted(()=>{document.body.removeChild(t)});const v=e.ref(),d=e.ref(a.class||""),u=e.ref(!!a.showButtons),c=e.ref(!!a.showHeader),f=e.ref(a.showCloseButton==null?!0:a.showCloseButton),M=e.ref(!0),p=e.ref(a.title||""),B=a.acceptCallback||(()=>{}),H=a.rejectCallback||(()=>{}),k=a.closedCallback||(R=>{}),S=a.resizeHandle||(R=>{}),O=Z(a),I=R=>{M.value=!1,n.unmount(),k(R)};return e.onMounted(()=>{}),h.expose({modalRef:v}),()=>e.createVNode(F,{ref:v,class:d.value,modelValue:M.value,"onUpdate:modelValue":R=>M.value=R,title:p.value,width:a.width,height:a.height,buttons:a.buttons,"show-header":c.value,"show-buttons":u.value,"show-close-button":f.value,"show-max-button":!1,onAccept:B,onCancel:H,fitContent:a.fitContent==null?!0:a.fitContent,onClosed:I,onResize:S},{default:()=>[O&&O(n)]})}});return document.body.appendChild(t),n.mount(t),n}class ee{constructor(t){Y(this,"appContext",null);Y(this,"modalRef",e.ref());Y(this,"activeModalIndex",e.ref(0));Y(this,"modalRefs",{});Y(this,"isUseEscCloseModal",e.ref(!1));Y(this,"activeModalInstance",e.computed(()=>this.modalRefs[this.activeModalIndex.value]));this.app=t,this.appContext=t?t._context:null}getCurrentModal(){return this.activeModalInstance.value}adaptToWindow(t,n){const{width:o,height:h}={width:window.innerWidth,height:window.innerHeight};return o<t&&(t=o),h<n&&(n=h),{width:t,height:n}}static show(t){const n=Object.assign({title:"",showButtons:!0,showHeader:!0},t);return re(n)}close(t){var n,o;t?(o=t.value)==null||o.close():(n=this.getCurrentModal())==null||n.close()}open(t){const n=document.createDocumentFragment();t.showMaxButton&&t.fitContent&&(t.showMaxButton=!1);const o=e.shallowRef(Object.assign({title:"",showButtons:!0,showHeader:!0},t)),h=e.ref(!0),v=o.value.acceptCallback||(()=>{}),d=o.value.rejectCallback||(()=>{}),u=o.value.closedCallback||((w,x)=>{}),c=o.value.resizeHandle||(w=>{});let f;const M=Z(o.value),p=w=>{var T;h.value=!1;const x=(T=w==null?void 0:w.target)==null?void 0:T.classList.contains("modal_close");u(w,this.isUseEscCloseModal.value?"esc":x?"icon":"button")},B=w=>{p(w),f&&e.nextTick(()=>{if(this.modalRefs[this.activeModalIndex.value]&&delete this.modalRefs[this.activeModalIndex.value],e.render(null,n),f=null,this.modalRef.value=null,this.modalRefs){const x=Object.keys(this.modalRefs).map(T=>Number(T));x.length>0?this.activeModalIndex.value=Math.max(...x):this.activeModalIndex.value=0}this.isUseEscCloseModal.value=!1})},H=w=>{var x;this.isUseEscCloseModal.value=!0,this.activeModalInstance&&((x=this.activeModalInstance.value)==null||x.close(w==null?void 0:w.event))},{width:k,height:S}=o.value,O=this.adaptToWindow(k||500,S||320);Object.assign(o.value,O);const I=()=>e.createVNode(F,e.mergeProps({ref:this.modalRef,modelValue:h.value,"onUpdate:modelValue":w=>h.value=w},o.value,{onAccept:v,onCancel:d,onClosed:B,onResize:c,onEsc:H}),{default:()=>[M&&M(this.app)]});return f=(w=>{const x=e.h(I,w);return x.appContext=this.appContext,e.render(x,n),x})({...o.value}),this.activeModalIndex.value++,this.modalRefs[this.activeModalIndex.value]=this.modalRef.value,{update:w=>{o.value={...o.value,...w},f&&e.render(e.cloneVNode(f,{...o}),n)},destroy:B,modalRef:this.activeModalInstance,close:this.close}}}const te=Symbol("FModalService");F.install=a=>{a.component(F.name,F);const t=new ee(a);a.provide(te,t),a.provide("FModalService",t)},z.FModal=F,z.FModalService=ee,z.F_MODAL_SERVICE_TOKEN=te,z.default=F,z.modalProps=P,Object.defineProperties(z,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});