UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

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