@gopowerteam/modal-render 0.0.31 → 0.0.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +1 -1
- package/dist/es/index.mjs +151 -152
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue");const A=Symbol("__MODAL__");function W(o){return e.getCurrentScope()?(e.onScopeDispose(o),!0):!1}function b(o){return typeof o=="function"?o():e.unref(o)}const j=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const J=Object.prototype.toString,Q=o=>J.call(o)==="[object Object]",Z=()=>{};function ee(o,i={}){if(!e.isRef(o))return e.toRefs(o);const n=Array.isArray(o.value)?Array.from({length:o.value.length}):{};for(const t in o.value)n[t]=e.customRef(()=>({get(){return o.value[t]},set(c){var s;if((s=b(i.replaceRef))!=null?s:!0)if(Array.isArray(o.value)){const h=[...o.value];h[t]=c,o.value=h}else{const h={...o.value,[t]:c};Object.setPrototypeOf(h,Object.getPrototypeOf(o.value)),o.value=h}else o.value[t]=c}}));return n}function te(o,i=!0){e.getCurrentInstance()?e.onMounted(o):i?o():e.nextTick(o)}function R(o){var i;const n=b(o);return(i=n==null?void 0:n.$el)!=null?i:n}const P=j?window:void 0;function F(...o){let i,n,t,c;if(typeof o[0]=="string"||Array.isArray(o[0])?([n,t,c]=o,i=P):[i,n,t,c]=o,!i)return Z;Array.isArray(n)||(n=[n]),Array.isArray(t)||(t=[t]);const s=[],u=()=>{s.forEach(v=>v()),s.length=0},h=(v,d,l,f)=>(v.addEventListener(d,l,f),()=>v.removeEventListener(d,l,f)),_=e.watch(()=>[R(i),b(c)],([v,d])=>{if(u(),!v)return;const l=Q(d)?{...d}:d;s.push(...n.flatMap(f=>t.map(a=>h(v,f,a,l))))},{immediate:!0,flush:"post"}),y=()=>{_(),u()};return W(y),y}function oe(){const o=e.ref(!1);return e.getCurrentInstance()&&e.onMounted(()=>{o.value=!0}),o}function ne(o){const i=oe();return e.computed(()=>(i.value,!!o()))}function re(o,i={}){var n,t;const{pointerTypes:c,preventDefault:s,stopPropagation:u,exact:h,onMove:_,onEnd:y,onStart:v,initialValue:d,axis:l="both",draggingElement:f=P,containerElement:a,handle:g=o}=i,p=e.ref((n=b(d))!=null?n:{x:0,y:0}),k=e.ref(),C=m=>c?c.includes(m.pointerType):!0,B=m=>{b(s)&&m.preventDefault(),b(u)&&m.stopPropagation()},O=m=>{var M;if(!C(m)||b(h)&&m.target!==b(o))return;const w=b(a),N=(M=w==null?void 0:w.getBoundingClientRect)==null?void 0:M.call(w),E=b(o).getBoundingClientRect(),S={x:m.clientX-(w?E.left-N.left:E.left),y:m.clientY-(w?E.top-N.top:E.top)};(v==null?void 0:v(S,m))!==!1&&(k.value=S,B(m))},D=m=>{var M;if(!C(m)||!k.value)return;const w=b(a),N=(M=w==null?void 0:w.getBoundingClientRect)==null?void 0:M.call(w),E=b(o).getBoundingClientRect();let{x:S,y:$}=p.value;(l==="x"||l==="both")&&(S=m.clientX-k.value.x,w&&(S=Math.min(Math.max(0,S),N.width-E.width))),(l==="y"||l==="both")&&($=m.clientY-k.value.y,w&&($=Math.min(Math.max(0,$),N.height-E.height))),p.value={x:S,y:$},_==null||_(p.value,m),B(m)},T=m=>{C(m)&&k.value&&(k.value=void 0,y==null||y(p.value,m),B(m))};if(j){const m={capture:(t=i.capture)!=null?t:!0};F(g,"pointerdown",O,m),F(f,"pointermove",D,m),F(f,"pointerup",T,m)}return{...ee(p),position:p,isDragging:e.computed(()=>!!k.value),style:e.computed(()=>`left:${p.value.x}px;top:${p.value.y}px;`)}}function le(o,i,n={}){const{window:t=P,...c}=n;let s;const u=ne(()=>t&&"ResizeObserver"in t),h=()=>{s&&(s.disconnect(),s=void 0)},_=e.computed(()=>Array.isArray(o)?o.map(d=>R(d)):[R(o)]),y=e.watch(_,d=>{if(h(),u.value&&t){s=new ResizeObserver(i);for(const l of d)l&&s.observe(l,c)}},{immediate:!0,flush:"post",deep:!0}),v=()=>{h(),y()};return W(v),{isSupported:u,stop:v}}function V(o,i={width:0,height:0},n={}){const{window:t=P,box:c="content-box"}=n,s=e.computed(()=>{var d,l;return(l=(d=R(o))==null?void 0:d.namespaceURI)==null?void 0:l.includes("svg")}),u=e.ref(i.width),h=e.ref(i.height),{stop:_}=le(o,([d])=>{const l=c==="border-box"?d.borderBoxSize:c==="content-box"?d.contentBoxSize:d.devicePixelContentBoxSize;if(t&&s.value){const f=R(o);if(f){const a=t.getComputedStyle(f);u.value=Number.parseFloat(a.width),h.value=Number.parseFloat(a.height)}}else if(l){const f=Array.isArray(l)?l:[l];u.value=f.reduce((a,{inlineSize:g})=>a+g,0),h.value=f.reduce((a,{blockSize:g})=>a+g,0)}else u.value=d.contentRect.width,h.value=d.contentRect.height},n);te(()=>{const d=R(o);d&&(u.value="offsetWidth"in d?d.offsetWidth:i.width,h.value="offsetHeight"in d?d.offsetHeight:i.height)});const y=e.watch(()=>R(o),d=>{u.value=d?i.width:0,h.value=d?i.height:0});function v(){_(),y()}return{width:u,height:h,stop:v}}const ie=o=>(e.pushScopeId("data-v-d92528b3"),o=o(),e.popScopeId(),o),se={class:"title text-16px font-bold"},ae={class:"action"},ce=["form"],de={key:2,class:"modal-loading"},ue=ie(()=>e.createElementVNode("div",{class:"lds-ring"},[e.createElementVNode("div"),e.createElementVNode("div"),e.createElementVNode("div"),e.createElementVNode("div")],-1)),fe=[ue],pe={name:"ModalContainer",inheritAttrs:!0},me=e.defineComponent({...pe,props:{id:{},form:{},component:{},componentProps:{},width:{},maxWidth:{},maxHeight:{default:90},sizes:{},size:{default:"middle"},fullscreen:{type:Boolean},title:{},header:{type:Boolean,default:!0},footer:{type:Boolean,default:!1},closeable:{type:Boolean,default:!0},esc:{type:Boolean,default:!1},maskClosable:{type:Boolean,default:!1},draggable:{type:Boolean,default:!1},mode:{default:"dialog"},type:{},offset:{},backgroundColor:{},bodyStyle:{},submitText:{default:"确定"},cancelText:{default:"取消"}},emits:["submit"],setup(o,{expose:i,emit:n}){const t=o,c=n,s=e.inject(A),u=e.ref(!1);let h=0,_=0;const y=e.shallowRef(),v=e.shallowRef(),d=e.shallowRef(),l=e.shallowRef(),f=e.shallowRef(),a=e.shallowRef(),{height:g}=V(y),{height:p}=V(d,void 0,{box:"border-box"}),{height:k}=V(l,void 0,{box:"border-box"}),{height:C}=V(f),{height:B}=V(a),{x:O,y:D}=re(d,{initialValue:{x:0,y:0}});function T(){s==null||s.close(t.id)}function m(r){return typeof r=="number"?`${r}px`:r}const M=e.computed(()=>{const r={};return t.mode==="dialog"&&(r.justifyContent="center"),t.mode==="drawer"&&(r.justifyContent="flex-end"),r}),w=e.computed(()=>{const r={};return t.size&&(r.width=m(t.sizes[t.size])),t.width&&(r.width=m(t.width)),t.maxWidth&&(r.maxWidth=m(t.maxWidth)),t.fullscreen&&(r.maxWidth="unset",r.width="100%",r.position="fixed",r.top=0,r.left=0,r.bottom=0,r.right=0,r.borderRadius=0),t.draggable&&!t.fullscreen&&t.mode==="dialog"&&(r.transform=`translate3d(${O.value-h}px, ${D.value-_}px, 0px)`),t.mode==="drawer"&&(r.borderRadius=0,r.height="100%"),t.offset&&t.mode==="dialog"&&(r.marginLeft=`${t.offset.x||0}px`,r.marginTop=`${t.offset.y||0}px`),t.backgroundColor&&(r.backgroundColor=t.backgroundColor),r}),N=e.computed(()=>{const r={};return t.draggable&&!t.fullscreen&&t.mode==="dialog"&&(r.cursor="move"),r}),E=e.computed(()=>{const r={},x=C.value+B.value+p.value+k.value,H=Math.floor(g.value*(Number(m(t.maxHeight).replace("%",""))/100));return t.maxHeight&&(r.maxHeight=`${H-x}px`),t.mode==="drawer"&&(r.maxHeight="unset",r.height=`${H-x}px`),t.fullscreen&&(r.maxHeight="unset",r.height=`calc(100% - ${x}px)`),t.type!=="component"&&(r.padding="0"),t.bodyStyle&&Object.assign(r,t.bodyStyle),r});function S(){const r=v.value;if(t.form&&r){const x=r.querySelector(`form[name="${t.form}"]`);x&&x.dispatchEvent(new Event("submit"))}c("submit")}function $(){s==null||s.close(t.id)}function X(){window&&window.addEventListener("resize",()=>{e.triggerRef(y),e.triggerRef(v),v.value&&(h=v.value.offsetLeft,_=v.value.offsetTop)})}function Y(){if(t.closeable&&t.esc){const r=({key:x})=>{x==="Escape"&&(s==null||s.close(t.id),window.removeEventListener("keydown",r))};window.addEventListener("keydown",r)}}function q(){h=v.value.offsetLeft,_=v.value.offsetTop}e.onMounted(()=>{Y(),X()}),e.onUnmounted(()=>{});function U(){return u.value=!0,()=>I()}function I(){u.value=!1}return i({showLoading:U,hideLoading:I}),(r,x)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"wrapperRef",ref:y,class:"modal-wrapper",style:e.normalizeStyle(M.value),onClick:x[0]||(x[0]=e.withModifiers(H=>r.maskClosable&&T(),["self"]))},[e.createTextVNode(e.toDisplayString(e.unref(C))+" ",1),e.createElementVNode("div",{ref_key:"contentRef",ref:v,class:e.normalizeClass(["modal-content",{[`${r.mode}-mode`]:!0}]),style:e.normalizeStyle(w.value)},[r.header?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"headerRef",ref:d,class:"modal-header",style:e.normalizeStyle(N.value),onMousedown:q},[e.createElementVNode("div",se,e.toDisplayString(r.title),1),e.createElementVNode("div",ae,[r.closeable?(e.openBlock(),e.createElementBlock("div",{key:0,class:"i-icon-park-outline:close block cursor-pointer",onClick:T})):e.createCommentVNode("",!0)])],36)):e.createCommentVNode("",!0),e.createElementVNode("div",{id:"modal-header-slot",ref_key:"headerSlotRef",ref:f},null,512),e.createElementVNode("div",{class:"modal-body",style:e.normalizeStyle(E.value)},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(r.component),e.normalizeProps(e.guardReactiveProps(r.componentProps)),null,16))],4),e.createElementVNode("div",{id:"modal-footer-slot",ref_key:"footerSlotRef",ref:a},null,512),r.footer?(e.openBlock(),e.createElementBlock("div",{key:1,ref_key:"footerRef",ref:l,class:"modal-footer space-x-2"},[e.createElementVNode("button",{class:"cancel-button",type:"button",onClick:$},e.toDisplayString(r.cancelText),1),e.createElementVNode("button",{class:"submit-button",form:r.form,type:"submit",onClick:S},e.toDisplayString(r.submitText),9,ce)],512)):e.createCommentVNode("",!0),u.value?(e.openBlock(),e.createElementBlock("div",de,fe)):e.createCommentVNode("",!0)],6)],4))}});const L=(o,i)=>{const n=o.__vccOpts||o;for(const[t,c]of i)n[t]=c;return n},G=L(me,[["__scopeId","data-v-d92528b3"]]),he={class:"modal-dialog"},ve={class:"dialog-body"},ge={class:"dialog-title"},ye={class:"dialog-content"},_e=e.defineComponent({__name:"modal-dialog",props:{type:{},title:{},content:{},okText:{default:"确定"},cancelText:{default:"取消"},onOk:{},onCancel:{},footer:{}},setup(o){const i=o,n=K(),t=e.computed(()=>i.title?i.title:{confirm:"提示",info:"提示",warning:"警告",error:"错误",success:"成功"}[i.type]);async function c(){i.onOk&&await i.onOk(),n.close()}async function s(){i.onCancel&&await i.onCancel(),n.close()}return(u,h)=>(e.openBlock(),e.createElementBlock("section",he,[e.createElementVNode("div",ve,[e.createElementVNode("div",ge,e.toDisplayString(t.value),1),e.createElementVNode("div",ye,e.toDisplayString(u.content),1)]),e.createElementVNode("div",{class:"dialog-footer space-x-2",style:e.normalizeStyle(u.type==="confirm"?{"justify-content":"end"}:{"border-top":"none"})},[u.footer?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(u.footer),{key:0})):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("button",{class:"submit-button",type:"submit",onClick:c},e.toDisplayString(u.okText),1),u.type==="confirm"?(e.openBlock(),e.createElementBlock("button",{key:0,class:"cancel-button",type:"button",onClick:s},e.toDisplayString(u.cancelText),1)):e.createCommentVNode("",!0)],64))],4)]))}});const we=L(_e,[["__scopeId","data-v-8326e5a5"]]),be={key:0,class:"modal-teleport"},ke={name:"ModalProvider",inheritAttrs:!0},Ce=e.defineComponent({...ke,props:{appendToBody:{type:[Boolean,String],default:!1},sizes:{default:()=>({small:520,middle:860,large:1190})},maxWidth:{default:"90%"},maxHeight:{default:"90%"},offset:{default:()=>({x:0,y:0})}},setup(o,{expose:i}){const n=e.shallowRef([]),t=e.ref(!1),c=e.getCurrentInstance();function s(l,f={},a={}){const g=e.defineAsyncComponent(()=>Promise.resolve(typeof l=="string"?we:l));typeof l=="string"&&(f.type=l,a.size="small",a.fullscreen=!1,a.mode="dialog",a.footer=!1,a.header=!1);const p=Math.random().toString(32).slice(2),k=new Promise((C,B)=>{n.value.push({id:p,component:g,props:f||{},options:{...a,type:typeof l=="string"?l:"component"},resolve:C,reject:B,listeners:[]}),e.triggerRef(n)}).catch(C=>C==="CANCEL"?new Promise(()=>{}):Promise.reject(C));return Object.assign(k,{close:()=>u(p)})}function u(l,f){const a=n.value.findIndex(p=>p.id===l);if(a<0)return;const g=n.value[a];f===void 0?g==null||g.reject("CANCEL"):g==null||g.resolve(f),n.value.splice(a,1),e.triggerRef(n)}function h(){!n.value||n.value.length===0||(n.value.forEach(l=>{l==null||l.reject("CANCEL")}),n.value=[],e.triggerRef(n))}function _(l,f){const a=n.value.find(p=>p.id===l);if(!a)return;const g=a.listeners.find(p=>p.event===f);g&&g.callback({open:s,close:p=>u(a.id,p),closeAll:h,showLoading:()=>y(a.id),hideLoading:()=>v(a.id),confirm:p=>s("confirm",p),success:p=>s("success",p),error:p=>s("error",p),warning:p=>s("warning",p),info:p=>s("info",p)})}function y(l){if(!c)return;const[f]=c.refs[`modal-container_${l}`];if(f)return f.showLoading()}function v(l){if(!c)return;const[f]=c.refs[`modal-container_${l}`];if(f)return f.hideLoading()}function d(l,f,a){const g=n.value.find(p=>p.id===l);g&&g.listeners.push({event:f,callback:a})}return e.provide(A,{open:s,close:u,closeAll:h,addEventListener:d}),i({elements:n,open:s,close:u,closeAll:h}),e.onMounted(()=>{t.value=!0}),(l,f)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.renderSlot(l.$slots,"default",{},void 0,!0),t.value?(e.openBlock(),e.createElementBlock("div",be,[(e.openBlock(),e.createBlock(e.Teleport,{disabled:!l.appendToBody,to:typeof l.appendToBody=="string"?l.appendToBody:"body"},[e.createVNode(e.TransitionGroup,{name:"modal-fade"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,a=>(e.openBlock(),e.createBlock(G,e.mergeProps({id:a.id,key:a.id,ref_for:!0,ref:`modal-container_${a.id}`,component:a.component,"component-props":a.props,"max-height":l.maxHeight,"max-width":l.maxWidth,offset:l.offset,sizes:l.sizes},a.options,{onSubmit:()=>_(a.id,"submit")}),null,16,["id","component","component-props","max-height","max-width","offset","sizes","onSubmit"]))),128))]),_:1})],8,["disabled","to"]))])):e.createCommentVNode("",!0)],64))}});const xe=L(Ce,[["__scopeId","data-v-241a8304"]]);const Ee={},Se={class:"modal-footer"};function Be(o,i){return e.openBlock(),e.createBlock(e.Teleport,{to:"#modal-footer-slot"},[e.createElementVNode("div",Se,[e.renderSlot(o.$slots,"default",{},void 0,!0)])])}const Me=L(Ee,[["render",Be],["__scopeId","data-v-2080a86e"]]);const Ne={},Re={class:"modal-header"};function $e(o,i){return e.openBlock(),e.createBlock(e.Teleport,{to:"#modal-header-slot"},[e.createElementVNode("div",Re,[e.renderSlot(o.$slots,"default",{},void 0,!0)])])}const Ve=L(Ne,[["render",$e],["__scopeId","data-v-d0247172"]]);function z(o,i){var t,c;let n=o==null?void 0:o.parent;for(;n&&((t=n==null?void 0:n.type)==null?void 0:t.name)!==i;)n=n.parent;return((c=n==null?void 0:n.type)==null?void 0:c.name)===i?n:null}function K(){const o=e.inject(A),i=e.getCurrentInstance();function n(t,c,s){if(!o)throw new Error("Not Found Modal Provider Component");return o.open(t,c,s)}return{open:n,close(t){var u;if(!o)throw new Error("Not Found Modal Provider Component");const c=z(i,"ModalContainer"),s=(u=c==null?void 0:c.props)==null?void 0:u.id;if(!s)throw new Error("Not Found Current Modal Container");o.close(s,t)},closeAll(){if(!o)throw new Error("Not Found Modal Provider Component");o.closeAll()},showLoading(){var s;if(!o)throw new Error("Not Found Modal Provider Component");const t=z(i,"ModalContainer");if(!((s=t==null?void 0:t.props)==null?void 0:s.id))throw new Error("Not Found Current Modal Container");t!=null&&t.exposed&&(t==null||t.exposed.showLoading())},hideLoading(){var s;if(!o)throw new Error("Not Found Modal Provider Component");const t=z(i,"ModalContainer");if(!((s=t==null?void 0:t.props)==null?void 0:s.id))throw new Error("Not Found Current Modal Container");t!=null&&t.exposed&&(t==null||t.exposed.hideLoading())},confirm(t){return this.open("confirm",t)},info(t){return this.open("info",t)},error(t){return this.open("error",t)},warning(t){return this.open("warning",t)},success(t){return this.open("success",t)}}}function Ae(o){var s;const i=e.inject(A),n=e.getCurrentInstance(),t=z(n,"ModalContainer"),c=(s=t==null?void 0:t.props)==null?void 0:s.id;i&&c&&i.addEventListener(c,"submit",o)}exports.ModalContainer=G;exports.ModalFooter=Me;exports.ModalHeader=Ve;exports.ModalKey=A;exports.ModalProvider=xe;exports.onSubmit=Ae;exports.useModal=K;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue");const A=Symbol("__MODAL__");function W(o){return e.getCurrentScope()?(e.onScopeDispose(o),!0):!1}function b(o){return typeof o=="function"?o():e.unref(o)}const j=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const J=Object.prototype.toString,Q=o=>J.call(o)==="[object Object]",Z=()=>{};function ee(o,i={}){if(!e.isRef(o))return e.toRefs(o);const n=Array.isArray(o.value)?Array.from({length:o.value.length}):{};for(const t in o.value)n[t]=e.customRef(()=>({get(){return o.value[t]},set(c){var s;if((s=b(i.replaceRef))!=null?s:!0)if(Array.isArray(o.value)){const h=[...o.value];h[t]=c,o.value=h}else{const h={...o.value,[t]:c};Object.setPrototypeOf(h,Object.getPrototypeOf(o.value)),o.value=h}else o.value[t]=c}}));return n}function te(o,i=!0){e.getCurrentInstance()?e.onMounted(o):i?o():e.nextTick(o)}function R(o){var i;const n=b(o);return(i=n==null?void 0:n.$el)!=null?i:n}const P=j?window:void 0;function D(...o){let i,n,t,c;if(typeof o[0]=="string"||Array.isArray(o[0])?([n,t,c]=o,i=P):[i,n,t,c]=o,!i)return Z;Array.isArray(n)||(n=[n]),Array.isArray(t)||(t=[t]);const s=[],u=()=>{s.forEach(v=>v()),s.length=0},h=(v,d,l,f)=>(v.addEventListener(d,l,f),()=>v.removeEventListener(d,l,f)),_=e.watch(()=>[R(i),b(c)],([v,d])=>{if(u(),!v)return;const l=Q(d)?{...d}:d;s.push(...n.flatMap(f=>t.map(a=>h(v,f,a,l))))},{immediate:!0,flush:"post"}),y=()=>{_(),u()};return W(y),y}function oe(){const o=e.ref(!1);return e.getCurrentInstance()&&e.onMounted(()=>{o.value=!0}),o}function ne(o){const i=oe();return e.computed(()=>(i.value,!!o()))}function re(o,i={}){var n,t;const{pointerTypes:c,preventDefault:s,stopPropagation:u,exact:h,onMove:_,onEnd:y,onStart:v,initialValue:d,axis:l="both",draggingElement:f=P,containerElement:a,handle:g=o}=i,p=e.ref((n=b(d))!=null?n:{x:0,y:0}),k=e.ref(),x=m=>c?c.includes(m.pointerType):!0,B=m=>{b(s)&&m.preventDefault(),b(u)&&m.stopPropagation()},O=m=>{var M;if(!x(m)||b(h)&&m.target!==b(o))return;const w=b(a),N=(M=w==null?void 0:w.getBoundingClientRect)==null?void 0:M.call(w),E=b(o).getBoundingClientRect(),S={x:m.clientX-(w?E.left-N.left:E.left),y:m.clientY-(w?E.top-N.top:E.top)};(v==null?void 0:v(S,m))!==!1&&(k.value=S,B(m))},H=m=>{var M;if(!x(m)||!k.value)return;const w=b(a),N=(M=w==null?void 0:w.getBoundingClientRect)==null?void 0:M.call(w),E=b(o).getBoundingClientRect();let{x:S,y:$}=p.value;(l==="x"||l==="both")&&(S=m.clientX-k.value.x,w&&(S=Math.min(Math.max(0,S),N.width-E.width))),(l==="y"||l==="both")&&($=m.clientY-k.value.y,w&&($=Math.min(Math.max(0,$),N.height-E.height))),p.value={x:S,y:$},_==null||_(p.value,m),B(m)},T=m=>{x(m)&&k.value&&(k.value=void 0,y==null||y(p.value,m),B(m))};if(j){const m={capture:(t=i.capture)!=null?t:!0};D(g,"pointerdown",O,m),D(f,"pointermove",H,m),D(f,"pointerup",T,m)}return{...ee(p),position:p,isDragging:e.computed(()=>!!k.value),style:e.computed(()=>`left:${p.value.x}px;top:${p.value.y}px;`)}}function le(o,i,n={}){const{window:t=P,...c}=n;let s;const u=ne(()=>t&&"ResizeObserver"in t),h=()=>{s&&(s.disconnect(),s=void 0)},_=e.computed(()=>Array.isArray(o)?o.map(d=>R(d)):[R(o)]),y=e.watch(_,d=>{if(h(),u.value&&t){s=new ResizeObserver(i);for(const l of d)l&&s.observe(l,c)}},{immediate:!0,flush:"post",deep:!0}),v=()=>{h(),y()};return W(v),{isSupported:u,stop:v}}function V(o,i={width:0,height:0},n={}){const{window:t=P,box:c="content-box"}=n,s=e.computed(()=>{var d,l;return(l=(d=R(o))==null?void 0:d.namespaceURI)==null?void 0:l.includes("svg")}),u=e.ref(i.width),h=e.ref(i.height),{stop:_}=le(o,([d])=>{const l=c==="border-box"?d.borderBoxSize:c==="content-box"?d.contentBoxSize:d.devicePixelContentBoxSize;if(t&&s.value){const f=R(o);if(f){const a=t.getComputedStyle(f);u.value=Number.parseFloat(a.width),h.value=Number.parseFloat(a.height)}}else if(l){const f=Array.isArray(l)?l:[l];u.value=f.reduce((a,{inlineSize:g})=>a+g,0),h.value=f.reduce((a,{blockSize:g})=>a+g,0)}else u.value=d.contentRect.width,h.value=d.contentRect.height},n);te(()=>{const d=R(o);d&&(u.value="offsetWidth"in d?d.offsetWidth:i.width,h.value="offsetHeight"in d?d.offsetHeight:i.height)});const y=e.watch(()=>R(o),d=>{u.value=d?i.width:0,h.value=d?i.height:0});function v(){_(),y()}return{width:u,height:h,stop:v}}const ie=o=>(e.pushScopeId("data-v-d6dd5541"),o=o(),e.popScopeId(),o),se={class:"title text-16px font-bold"},ae={class:"action"},ce=["form"],de={key:2,class:"modal-loading"},ue=ie(()=>e.createElementVNode("div",{class:"lds-ring"},[e.createElementVNode("div"),e.createElementVNode("div"),e.createElementVNode("div"),e.createElementVNode("div")],-1)),fe=[ue],pe={name:"ModalContainer",inheritAttrs:!0},me=e.defineComponent({...pe,props:{id:{},form:{},component:{},componentProps:{},width:{},maxWidth:{},maxHeight:{default:90},sizes:{},size:{default:"middle"},fullscreen:{type:Boolean},title:{},header:{type:Boolean,default:!0},footer:{type:Boolean,default:!1},closeable:{type:Boolean,default:!0},esc:{type:Boolean,default:!1},maskClosable:{type:Boolean,default:!1},draggable:{type:Boolean,default:!1},mode:{default:"dialog"},type:{},offset:{},backgroundColor:{},bodyStyle:{},submitText:{default:"确定"},cancelText:{default:"取消"}},emits:["submit"],setup(o,{expose:i,emit:n}){const t=o,c=n,s=e.inject(A),u=e.ref(!1);let h=0,_=0;const y=e.shallowRef(),v=e.shallowRef(),d=e.shallowRef(),l=e.shallowRef(),f=e.shallowRef(),a=e.shallowRef(),{height:g}=V(y),{height:p}=V(d,void 0,{box:"border-box"}),{height:k}=V(l,void 0,{box:"border-box"}),{height:x}=V(f),{height:B}=V(a),{x:O,y:H}=re(d,{initialValue:{x:0,y:0}});function T(){s==null||s.close(t.id)}function m(r){return typeof r=="number"?`${r}px`:r}const M=e.computed(()=>{const r={};return t.mode==="dialog"&&(r.justifyContent="center"),t.mode==="drawer"&&(r.justifyContent="flex-end"),r}),w=e.computed(()=>{const r={};return t.size&&(r.width=m(t.sizes[t.size])),t.width&&(r.width=m(t.width)),t.maxWidth&&(r.maxWidth=m(t.maxWidth)),t.fullscreen&&(r.maxWidth="unset",r.width="100%",r.position="fixed",r.top=0,r.left=0,r.bottom=0,r.right=0,r.borderRadius=0),t.draggable&&!t.fullscreen&&t.mode==="dialog"&&(r.transform=`translate3d(${O.value-h}px, ${H.value-_}px, 0px)`),t.mode==="drawer"&&(r.borderRadius=0,r.height="100%"),t.offset&&t.mode==="dialog"&&(r.marginLeft=`${t.offset.x||0}px`,r.marginTop=`${t.offset.y||0}px`),t.backgroundColor&&(r.backgroundColor=t.backgroundColor),r}),N=e.computed(()=>{const r={};return t.draggable&&!t.fullscreen&&t.mode==="dialog"&&(r.cursor="move"),r}),E=e.computed(()=>{const r={},C=x.value+B.value+p.value+k.value,I=Math.floor(g.value*(Number(m(t.maxHeight).replace("%",""))/100));return t.maxHeight&&(r.maxHeight=`${I-C}px`),t.mode==="drawer"&&(r.maxHeight="unset",r.height=`${g.value-C}px`),t.fullscreen&&(r.maxHeight="unset",r.height=`calc(100% - ${C}px)`),t.type!=="component"&&(r.padding="0"),t.bodyStyle&&Object.assign(r,t.bodyStyle),r});function S(){const r=v.value;if(t.form&&r){const C=r.querySelector(`form[name="${t.form}"]`);C&&C.dispatchEvent(new Event("submit"))}c("submit")}function $(){s==null||s.close(t.id)}function X(){window&&window.addEventListener("resize",()=>{e.triggerRef(y),e.triggerRef(v),v.value&&(h=v.value.offsetLeft,_=v.value.offsetTop)})}function Y(){if(t.closeable&&t.esc){const r=({key:C})=>{C==="Escape"&&(s==null||s.close(t.id),window.removeEventListener("keydown",r))};window.addEventListener("keydown",r)}}function q(){h=v.value.offsetLeft,_=v.value.offsetTop}e.onMounted(()=>{Y(),X()}),e.onUnmounted(()=>{});function U(){return u.value=!0,()=>F()}function F(){u.value=!1}return i({showLoading:U,hideLoading:F}),(r,C)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"wrapperRef",ref:y,class:"modal-wrapper",style:e.normalizeStyle(M.value),onClick:C[0]||(C[0]=e.withModifiers(I=>r.maskClosable&&T(),["self"]))},[e.createElementVNode("div",{ref_key:"contentRef",ref:v,class:e.normalizeClass(["modal-content",{[`${r.mode}-mode`]:!0}]),style:e.normalizeStyle(w.value)},[r.header?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"headerRef",ref:d,class:"modal-header",style:e.normalizeStyle(N.value),onMousedown:q},[e.createElementVNode("div",se,e.toDisplayString(r.title),1),e.createElementVNode("div",ae,[r.closeable?(e.openBlock(),e.createElementBlock("div",{key:0,class:"i-icon-park-outline:close block cursor-pointer",onClick:T})):e.createCommentVNode("",!0)])],36)):e.createCommentVNode("",!0),e.createElementVNode("div",{id:"modal-header-slot",ref_key:"headerSlotRef",ref:f},null,512),e.createElementVNode("div",{class:"modal-body",style:e.normalizeStyle(E.value)},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(r.component),e.normalizeProps(e.guardReactiveProps(r.componentProps)),null,16))],4),e.createElementVNode("div",{id:"modal-footer-slot",ref_key:"footerSlotRef",ref:a},null,512),r.footer?(e.openBlock(),e.createElementBlock("div",{key:1,ref_key:"footerRef",ref:l,class:"modal-footer space-x-2"},[e.createElementVNode("button",{class:"cancel-button",type:"button",onClick:$},e.toDisplayString(r.cancelText),1),e.createElementVNode("button",{class:"submit-button",form:r.form,type:"submit",onClick:S},e.toDisplayString(r.submitText),9,ce)],512)):e.createCommentVNode("",!0),u.value?(e.openBlock(),e.createElementBlock("div",de,fe)):e.createCommentVNode("",!0)],6)],4))}});const L=(o,i)=>{const n=o.__vccOpts||o;for(const[t,c]of i)n[t]=c;return n},G=L(me,[["__scopeId","data-v-d6dd5541"]]),he={class:"modal-dialog"},ve={class:"dialog-body"},ge={class:"dialog-title"},ye={class:"dialog-content"},_e=e.defineComponent({__name:"modal-dialog",props:{type:{},title:{},content:{},okText:{default:"确定"},cancelText:{default:"取消"},onOk:{},onCancel:{},footer:{}},setup(o){const i=o,n=K(),t=e.computed(()=>i.title?i.title:{confirm:"提示",info:"提示",warning:"警告",error:"错误",success:"成功"}[i.type]);async function c(){i.onOk&&await i.onOk(),n.close()}async function s(){i.onCancel&&await i.onCancel(),n.close()}return(u,h)=>(e.openBlock(),e.createElementBlock("section",he,[e.createElementVNode("div",ve,[e.createElementVNode("div",ge,e.toDisplayString(t.value),1),e.createElementVNode("div",ye,e.toDisplayString(u.content),1)]),e.createElementVNode("div",{class:"dialog-footer space-x-2",style:e.normalizeStyle(u.type==="confirm"?{"justify-content":"end"}:{"border-top":"none"})},[u.footer?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(u.footer),{key:0})):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("button",{class:"submit-button",type:"submit",onClick:c},e.toDisplayString(u.okText),1),u.type==="confirm"?(e.openBlock(),e.createElementBlock("button",{key:0,class:"cancel-button",type:"button",onClick:s},e.toDisplayString(u.cancelText),1)):e.createCommentVNode("",!0)],64))],4)]))}});const we=L(_e,[["__scopeId","data-v-8326e5a5"]]),be={key:0,class:"modal-teleport"},ke={name:"ModalProvider",inheritAttrs:!0},Ce=e.defineComponent({...ke,props:{appendToBody:{type:[Boolean,String],default:!1},sizes:{default:()=>({small:520,middle:860,large:1190})},maxWidth:{default:"90%"},maxHeight:{default:"90%"},offset:{default:()=>({x:0,y:0})}},setup(o,{expose:i}){const n=e.shallowRef([]),t=e.ref(!1),c=e.getCurrentInstance();function s(l,f={},a={}){const g=e.defineAsyncComponent(()=>Promise.resolve(typeof l=="string"?we:l));typeof l=="string"&&(f.type=l,a.size="small",a.fullscreen=!1,a.mode="dialog",a.footer=!1,a.header=!1);const p=Math.random().toString(32).slice(2),k=new Promise((x,B)=>{n.value.push({id:p,component:g,props:f||{},options:{...a,type:typeof l=="string"?l:"component"},resolve:x,reject:B,listeners:[]}),e.triggerRef(n)}).catch(x=>x==="CANCEL"?new Promise(()=>{}):Promise.reject(x));return Object.assign(k,{close:()=>u(p)})}function u(l,f){const a=n.value.findIndex(p=>p.id===l);if(a<0)return;const g=n.value[a];f===void 0?g==null||g.reject("CANCEL"):g==null||g.resolve(f),n.value.splice(a,1),e.triggerRef(n)}function h(){!n.value||n.value.length===0||(n.value.forEach(l=>{l==null||l.reject("CANCEL")}),n.value=[],e.triggerRef(n))}function _(l,f){const a=n.value.find(p=>p.id===l);if(!a)return;const g=a.listeners.find(p=>p.event===f);g&&g.callback({open:s,close:p=>u(a.id,p),closeAll:h,showLoading:()=>y(a.id),hideLoading:()=>v(a.id),confirm:p=>s("confirm",p),success:p=>s("success",p),error:p=>s("error",p),warning:p=>s("warning",p),info:p=>s("info",p)})}function y(l){if(!c)return;const[f]=c.refs[`modal-container_${l}`];if(f)return f.showLoading()}function v(l){if(!c)return;const[f]=c.refs[`modal-container_${l}`];if(f)return f.hideLoading()}function d(l,f,a){const g=n.value.find(p=>p.id===l);g&&g.listeners.push({event:f,callback:a})}return e.provide(A,{open:s,close:u,closeAll:h,addEventListener:d}),i({elements:n,open:s,close:u,closeAll:h}),e.onMounted(()=>{t.value=!0}),(l,f)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.renderSlot(l.$slots,"default",{},void 0,!0),t.value?(e.openBlock(),e.createElementBlock("div",be,[(e.openBlock(),e.createBlock(e.Teleport,{disabled:!l.appendToBody,to:typeof l.appendToBody=="string"?l.appendToBody:"body"},[e.createVNode(e.TransitionGroup,{name:"modal-fade"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,a=>(e.openBlock(),e.createBlock(G,e.mergeProps({id:a.id,key:a.id,ref_for:!0,ref:`modal-container_${a.id}`,component:a.component,"component-props":a.props,"max-height":l.maxHeight,"max-width":l.maxWidth,offset:l.offset,sizes:l.sizes},a.options,{onSubmit:()=>_(a.id,"submit")}),null,16,["id","component","component-props","max-height","max-width","offset","sizes","onSubmit"]))),128))]),_:1})],8,["disabled","to"]))])):e.createCommentVNode("",!0)],64))}});const xe=L(Ce,[["__scopeId","data-v-241a8304"]]);const Ee={},Se={class:"modal-footer"};function Be(o,i){return e.openBlock(),e.createBlock(e.Teleport,{to:"#modal-footer-slot"},[e.createElementVNode("div",Se,[e.renderSlot(o.$slots,"default",{},void 0,!0)])])}const Me=L(Ee,[["render",Be],["__scopeId","data-v-2080a86e"]]);const Ne={},Re={class:"modal-header"};function $e(o,i){return e.openBlock(),e.createBlock(e.Teleport,{to:"#modal-header-slot"},[e.createElementVNode("div",Re,[e.renderSlot(o.$slots,"default",{},void 0,!0)])])}const Ve=L(Ne,[["render",$e],["__scopeId","data-v-d0247172"]]);function z(o,i){var t,c;let n=o==null?void 0:o.parent;for(;n&&((t=n==null?void 0:n.type)==null?void 0:t.name)!==i;)n=n.parent;return((c=n==null?void 0:n.type)==null?void 0:c.name)===i?n:null}function K(){const o=e.inject(A),i=e.getCurrentInstance();function n(t,c,s){if(!o)throw new Error("Not Found Modal Provider Component");return o.open(t,c,s)}return{open:n,close(t){var u;if(!o)throw new Error("Not Found Modal Provider Component");const c=z(i,"ModalContainer"),s=(u=c==null?void 0:c.props)==null?void 0:u.id;if(!s)throw new Error("Not Found Current Modal Container");o.close(s,t)},closeAll(){if(!o)throw new Error("Not Found Modal Provider Component");o.closeAll()},showLoading(){var s;if(!o)throw new Error("Not Found Modal Provider Component");const t=z(i,"ModalContainer");if(!((s=t==null?void 0:t.props)==null?void 0:s.id))throw new Error("Not Found Current Modal Container");t!=null&&t.exposed&&(t==null||t.exposed.showLoading())},hideLoading(){var s;if(!o)throw new Error("Not Found Modal Provider Component");const t=z(i,"ModalContainer");if(!((s=t==null?void 0:t.props)==null?void 0:s.id))throw new Error("Not Found Current Modal Container");t!=null&&t.exposed&&(t==null||t.exposed.hideLoading())},confirm(t){return this.open("confirm",t)},info(t){return this.open("info",t)},error(t){return this.open("error",t)},warning(t){return this.open("warning",t)},success(t){return this.open("success",t)}}}function Ae(o){var s;const i=e.inject(A),n=e.getCurrentInstance(),t=z(n,"ModalContainer"),c=(s=t==null?void 0:t.props)==null?void 0:s.id;i&&c&&i.addEventListener(c,"submit",o)}exports.ModalContainer=G;exports.ModalFooter=Me;exports.ModalHeader=Ve;exports.ModalKey=A;exports.ModalProvider=xe;exports.onSubmit=Ae;exports.useModal=K;
|
package/dist/es/index.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { unref as
|
|
1
|
+
import { unref as ve, isRef as he, toRefs as me, customRef as ge, getCurrentInstance as V, onMounted as Y, nextTick as ye, getCurrentScope as _e, onScopeDispose as we, ref as H, computed as E, watch as ee, defineComponent as te, inject as oe, shallowRef as P, onUnmounted as be, openBlock as y, createElementBlock as M, normalizeStyle as D, withModifiers as xe, createElementVNode as g, normalizeClass as Ce, toDisplayString as O, createCommentVNode as N, createBlock as F, resolveDynamicComponent as le, normalizeProps as ke, guardReactiveProps as Me, triggerRef as I, pushScopeId as Se, popScopeId as Ee, Fragment as Z, provide as $e, renderSlot as ne, Teleport as re, createVNode as Ae, TransitionGroup as Le, withCtx as Re, renderList as Be, mergeProps as Pe, defineAsyncComponent as Oe } from "vue";
|
|
2
2
|
const K = Symbol("__MODAL__");
|
|
3
|
-
function
|
|
4
|
-
return _e() ? (
|
|
3
|
+
function ae(t) {
|
|
4
|
+
return _e() ? (we(t), !0) : !1;
|
|
5
5
|
}
|
|
6
6
|
function x(t) {
|
|
7
|
-
return typeof t == "function" ? t() :
|
|
7
|
+
return typeof t == "function" ? t() : ve(t);
|
|
8
8
|
}
|
|
9
|
-
const
|
|
9
|
+
const de = typeof window < "u" && typeof document < "u";
|
|
10
10
|
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
11
|
-
const
|
|
11
|
+
const Te = Object.prototype.toString, He = (t) => Te.call(t) === "[object Object]", ze = () => {
|
|
12
12
|
};
|
|
13
|
-
function
|
|
13
|
+
function Ne(t, s = {}) {
|
|
14
14
|
if (!he(t))
|
|
15
15
|
return me(t);
|
|
16
16
|
const o = Array.isArray(t.value) ? Array.from({ length: t.value.length }) : {};
|
|
@@ -35,56 +35,56 @@ function Fe(t, s = {}) {
|
|
|
35
35
|
}));
|
|
36
36
|
return o;
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function Fe(t, s = !0) {
|
|
39
39
|
V() ? Y(t) : s ? t() : ye(t);
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function T(t) {
|
|
42
42
|
var s;
|
|
43
43
|
const o = x(t);
|
|
44
44
|
return (s = o == null ? void 0 : o.$el) != null ? s : o;
|
|
45
45
|
}
|
|
46
|
-
const U =
|
|
47
|
-
function
|
|
46
|
+
const U = de ? window : void 0;
|
|
47
|
+
function Q(...t) {
|
|
48
48
|
let s, o, e, a;
|
|
49
49
|
if (typeof t[0] == "string" || Array.isArray(t[0]) ? ([o, e, a] = t, s = U) : [s, o, e, a] = t, !s)
|
|
50
|
-
return
|
|
50
|
+
return ze;
|
|
51
51
|
Array.isArray(o) || (o = [o]), Array.isArray(e) || (e = [e]);
|
|
52
52
|
const i = [], c = () => {
|
|
53
53
|
i.forEach((h) => h()), i.length = 0;
|
|
54
|
-
}, v = (h, d, r, u) => (h.addEventListener(d, r, u), () => h.removeEventListener(d, r, u)),
|
|
55
|
-
() => [
|
|
54
|
+
}, v = (h, d, r, u) => (h.addEventListener(d, r, u), () => h.removeEventListener(d, r, u)), w = ee(
|
|
55
|
+
() => [T(s), x(a)],
|
|
56
56
|
([h, d]) => {
|
|
57
57
|
if (c(), !h)
|
|
58
58
|
return;
|
|
59
|
-
const r =
|
|
59
|
+
const r = He(d) ? { ...d } : d;
|
|
60
60
|
i.push(
|
|
61
61
|
...o.flatMap((u) => e.map((l) => v(h, u, l, r)))
|
|
62
62
|
);
|
|
63
63
|
},
|
|
64
64
|
{ immediate: !0, flush: "post" }
|
|
65
65
|
), _ = () => {
|
|
66
|
-
|
|
66
|
+
w(), c();
|
|
67
67
|
};
|
|
68
|
-
return
|
|
68
|
+
return ae(_), _;
|
|
69
69
|
}
|
|
70
|
-
function
|
|
70
|
+
function We() {
|
|
71
71
|
const t = H(!1);
|
|
72
72
|
return V() && Y(() => {
|
|
73
73
|
t.value = !0;
|
|
74
74
|
}), t;
|
|
75
75
|
}
|
|
76
|
-
function
|
|
77
|
-
const s =
|
|
76
|
+
function De(t) {
|
|
77
|
+
const s = We();
|
|
78
78
|
return E(() => (s.value, !!t()));
|
|
79
79
|
}
|
|
80
|
-
function
|
|
80
|
+
function Ie(t, s = {}) {
|
|
81
81
|
var o, e;
|
|
82
82
|
const {
|
|
83
83
|
pointerTypes: a,
|
|
84
84
|
preventDefault: i,
|
|
85
85
|
stopPropagation: c,
|
|
86
86
|
exact: v,
|
|
87
|
-
onMove:
|
|
87
|
+
onMove: w,
|
|
88
88
|
onEnd: _,
|
|
89
89
|
onStart: h,
|
|
90
90
|
initialValue: d,
|
|
@@ -94,36 +94,36 @@ function Ve(t, s = {}) {
|
|
|
94
94
|
handle: m = t
|
|
95
95
|
} = s, f = H(
|
|
96
96
|
(o = x(d)) != null ? o : { x: 0, y: 0 }
|
|
97
|
-
), C = H(),
|
|
97
|
+
), C = H(), S = (p) => a ? a.includes(p.pointerType) : !0, L = (p) => {
|
|
98
98
|
x(i) && p.preventDefault(), x(c) && p.stopPropagation();
|
|
99
99
|
}, q = (p) => {
|
|
100
|
-
var
|
|
101
|
-
if (!
|
|
100
|
+
var R;
|
|
101
|
+
if (!S(p) || x(v) && p.target !== x(t))
|
|
102
102
|
return;
|
|
103
|
-
const
|
|
104
|
-
x: p.clientX - (
|
|
105
|
-
y: p.clientY - (
|
|
103
|
+
const b = x(l), B = (R = b == null ? void 0 : b.getBoundingClientRect) == null ? void 0 : R.call(b), $ = x(t).getBoundingClientRect(), A = {
|
|
104
|
+
x: p.clientX - (b ? $.left - B.left : $.left),
|
|
105
|
+
y: p.clientY - (b ? $.top - B.top : $.top)
|
|
106
106
|
};
|
|
107
|
-
(h == null ? void 0 : h(A, p)) !== !1 && (C.value = A,
|
|
107
|
+
(h == null ? void 0 : h(A, p)) !== !1 && (C.value = A, L(p));
|
|
108
108
|
}, J = (p) => {
|
|
109
|
-
var
|
|
110
|
-
if (!
|
|
109
|
+
var R;
|
|
110
|
+
if (!S(p) || !C.value)
|
|
111
111
|
return;
|
|
112
|
-
const
|
|
112
|
+
const b = x(l), B = (R = b == null ? void 0 : b.getBoundingClientRect) == null ? void 0 : R.call(b), $ = x(t).getBoundingClientRect();
|
|
113
113
|
let { x: A, y: z } = f.value;
|
|
114
|
-
(r === "x" || r === "both") && (A = p.clientX - C.value.x,
|
|
114
|
+
(r === "x" || r === "both") && (A = p.clientX - C.value.x, b && (A = Math.min(Math.max(0, A), B.width - $.width))), (r === "y" || r === "both") && (z = p.clientY - C.value.y, b && (z = Math.min(Math.max(0, z), B.height - $.height))), f.value = {
|
|
115
115
|
x: A,
|
|
116
116
|
y: z
|
|
117
|
-
},
|
|
117
|
+
}, w == null || w(f.value, p), L(p);
|
|
118
118
|
}, G = (p) => {
|
|
119
|
-
|
|
119
|
+
S(p) && C.value && (C.value = void 0, _ == null || _(f.value, p), L(p));
|
|
120
120
|
};
|
|
121
|
-
if (
|
|
121
|
+
if (de) {
|
|
122
122
|
const p = { capture: (e = s.capture) != null ? e : !0 };
|
|
123
|
-
|
|
123
|
+
Q(m, "pointerdown", q, p), Q(u, "pointermove", J, p), Q(u, "pointerup", G, p);
|
|
124
124
|
}
|
|
125
125
|
return {
|
|
126
|
-
...
|
|
126
|
+
...Ne(f),
|
|
127
127
|
position: f,
|
|
128
128
|
isDragging: E(() => !!C.value),
|
|
129
129
|
style: E(
|
|
@@ -131,13 +131,13 @@ function Ve(t, s = {}) {
|
|
|
131
131
|
)
|
|
132
132
|
};
|
|
133
133
|
}
|
|
134
|
-
function
|
|
134
|
+
function Ve(t, s, o = {}) {
|
|
135
135
|
const { window: e = U, ...a } = o;
|
|
136
136
|
let i;
|
|
137
|
-
const c =
|
|
137
|
+
const c = De(() => e && "ResizeObserver" in e), v = () => {
|
|
138
138
|
i && (i.disconnect(), i = void 0);
|
|
139
|
-
},
|
|
140
|
-
|
|
139
|
+
}, w = E(() => Array.isArray(t) ? t.map((d) => T(d)) : [T(t)]), _ = ee(
|
|
140
|
+
w,
|
|
141
141
|
(d) => {
|
|
142
142
|
if (v(), c.value && e) {
|
|
143
143
|
i = new ResizeObserver(s);
|
|
@@ -149,7 +149,7 @@ function je(t, s, o = {}) {
|
|
|
149
149
|
), h = () => {
|
|
150
150
|
v(), _();
|
|
151
151
|
};
|
|
152
|
-
return
|
|
152
|
+
return ae(h), {
|
|
153
153
|
isSupported: c,
|
|
154
154
|
stop: h
|
|
155
155
|
};
|
|
@@ -157,13 +157,13 @@ function je(t, s, o = {}) {
|
|
|
157
157
|
function W(t, s = { width: 0, height: 0 }, o = {}) {
|
|
158
158
|
const { window: e = U, box: a = "content-box" } = o, i = E(() => {
|
|
159
159
|
var d, r;
|
|
160
|
-
return (r = (d =
|
|
161
|
-
}), c = H(s.width), v = H(s.height), { stop:
|
|
160
|
+
return (r = (d = T(t)) == null ? void 0 : d.namespaceURI) == null ? void 0 : r.includes("svg");
|
|
161
|
+
}), c = H(s.width), v = H(s.height), { stop: w } = Ve(
|
|
162
162
|
t,
|
|
163
163
|
([d]) => {
|
|
164
164
|
const r = a === "border-box" ? d.borderBoxSize : a === "content-box" ? d.contentBoxSize : d.devicePixelContentBoxSize;
|
|
165
165
|
if (e && i.value) {
|
|
166
|
-
const u =
|
|
166
|
+
const u = T(t);
|
|
167
167
|
if (u) {
|
|
168
168
|
const l = e.getComputedStyle(u);
|
|
169
169
|
c.value = Number.parseFloat(l.width), v.value = Number.parseFloat(l.height);
|
|
@@ -176,18 +176,18 @@ function W(t, s = { width: 0, height: 0 }, o = {}) {
|
|
|
176
176
|
},
|
|
177
177
|
o
|
|
178
178
|
);
|
|
179
|
-
|
|
180
|
-
const d =
|
|
179
|
+
Fe(() => {
|
|
180
|
+
const d = T(t);
|
|
181
181
|
d && (c.value = "offsetWidth" in d ? d.offsetWidth : s.width, v.value = "offsetHeight" in d ? d.offsetHeight : s.height);
|
|
182
182
|
});
|
|
183
|
-
const _ =
|
|
184
|
-
() =>
|
|
183
|
+
const _ = ee(
|
|
184
|
+
() => T(t),
|
|
185
185
|
(d) => {
|
|
186
186
|
c.value = d ? s.width : 0, v.value = d ? s.height : 0;
|
|
187
187
|
}
|
|
188
188
|
);
|
|
189
189
|
function h() {
|
|
190
|
-
|
|
190
|
+
w(), _();
|
|
191
191
|
}
|
|
192
192
|
return {
|
|
193
193
|
width: c,
|
|
@@ -195,21 +195,21 @@ function W(t, s = { width: 0, height: 0 }, o = {}) {
|
|
|
195
195
|
stop: h
|
|
196
196
|
};
|
|
197
197
|
}
|
|
198
|
-
const
|
|
198
|
+
const je = (t) => (Se("data-v-d6dd5541"), t = t(), Ee(), t), Ge = { class: "title text-16px font-bold" }, Xe = { class: "action" }, Ye = ["form"], Ke = {
|
|
199
199
|
key: 2,
|
|
200
200
|
class: "modal-loading"
|
|
201
|
-
},
|
|
201
|
+
}, Ue = /* @__PURE__ */ je(() => /* @__PURE__ */ g("div", { class: "lds-ring" }, [
|
|
202
202
|
/* @__PURE__ */ g("div"),
|
|
203
203
|
/* @__PURE__ */ g("div"),
|
|
204
204
|
/* @__PURE__ */ g("div"),
|
|
205
205
|
/* @__PURE__ */ g("div")
|
|
206
|
-
], -1)),
|
|
207
|
-
|
|
208
|
-
],
|
|
206
|
+
], -1)), qe = [
|
|
207
|
+
Ue
|
|
208
|
+
], Je = {
|
|
209
209
|
name: "ModalContainer",
|
|
210
210
|
inheritAttrs: !0
|
|
211
|
-
},
|
|
212
|
-
...
|
|
211
|
+
}, Qe = /* @__PURE__ */ te({
|
|
212
|
+
...Je,
|
|
213
213
|
props: {
|
|
214
214
|
id: {},
|
|
215
215
|
form: {},
|
|
@@ -238,9 +238,9 @@ const Ge = (t) => (Ee("data-v-d92528b3"), t = t(), $e(), t), Xe = { class: "titl
|
|
|
238
238
|
},
|
|
239
239
|
emits: ["submit"],
|
|
240
240
|
setup(t, { expose: s, emit: o }) {
|
|
241
|
-
const e = t, a = o, i =
|
|
242
|
-
let v = 0,
|
|
243
|
-
const _ =
|
|
241
|
+
const e = t, a = o, i = oe(K), c = H(!1);
|
|
242
|
+
let v = 0, w = 0;
|
|
243
|
+
const _ = P(), h = P(), d = P(), r = P(), u = P(), l = P(), { height: m } = W(_), { height: f } = W(d, void 0, { box: "border-box" }), { height: C } = W(r, void 0, { box: "border-box" }), { height: S } = W(u), { height: L } = W(l), { x: q, y: J } = Ie(d, {
|
|
244
244
|
initialValue: { x: 0, y: 0 }
|
|
245
245
|
});
|
|
246
246
|
function G() {
|
|
@@ -249,84 +249,83 @@ const Ge = (t) => (Ee("data-v-d92528b3"), t = t(), $e(), t), Xe = { class: "titl
|
|
|
249
249
|
function p(n) {
|
|
250
250
|
return typeof n == "number" ? `${n}px` : n;
|
|
251
251
|
}
|
|
252
|
-
const
|
|
252
|
+
const R = E(() => {
|
|
253
253
|
const n = {};
|
|
254
254
|
return e.mode === "dialog" && (n.justifyContent = "center"), e.mode === "drawer" && (n.justifyContent = "flex-end"), n;
|
|
255
|
-
}),
|
|
255
|
+
}), b = E(() => {
|
|
256
256
|
const n = {};
|
|
257
|
-
return e.size && (n.width = p(e.sizes[e.size])), e.width && (n.width = p(e.width)), e.maxWidth && (n.maxWidth = p(e.maxWidth)), e.fullscreen && (n.maxWidth = "unset", n.width = "100%", n.position = "fixed", n.top = 0, n.left = 0, n.bottom = 0, n.right = 0, n.borderRadius = 0), e.draggable && !e.fullscreen && e.mode === "dialog" && (n.transform = `translate3d(${q.value - v}px, ${J.value -
|
|
258
|
-
}),
|
|
257
|
+
return e.size && (n.width = p(e.sizes[e.size])), e.width && (n.width = p(e.width)), e.maxWidth && (n.maxWidth = p(e.maxWidth)), e.fullscreen && (n.maxWidth = "unset", n.width = "100%", n.position = "fixed", n.top = 0, n.left = 0, n.bottom = 0, n.right = 0, n.borderRadius = 0), e.draggable && !e.fullscreen && e.mode === "dialog" && (n.transform = `translate3d(${q.value - v}px, ${J.value - w}px, 0px)`), e.mode === "drawer" && (n.borderRadius = 0, n.height = "100%"), e.offset && e.mode === "dialog" && (n.marginLeft = `${e.offset.x || 0}px`, n.marginTop = `${e.offset.y || 0}px`), e.backgroundColor && (n.backgroundColor = e.backgroundColor), n;
|
|
258
|
+
}), B = E(() => {
|
|
259
259
|
const n = {};
|
|
260
260
|
return e.draggable && !e.fullscreen && e.mode === "dialog" && (n.cursor = "move"), n;
|
|
261
261
|
}), $ = E(() => {
|
|
262
|
-
const n = {},
|
|
263
|
-
return e.maxHeight && (n.maxHeight = `${
|
|
262
|
+
const n = {}, k = S.value + L.value + f.value + C.value, ie = Math.floor(m.value * (Number(p(e.maxHeight).replace("%", "")) / 100));
|
|
263
|
+
return e.maxHeight && (n.maxHeight = `${ie - k}px`), e.mode === "drawer" && (n.maxHeight = "unset", n.height = `${m.value - k}px`), e.fullscreen && (n.maxHeight = "unset", n.height = `calc(100% - ${k}px)`), e.type !== "component" && (n.padding = "0"), e.bodyStyle && Object.assign(n, e.bodyStyle), n;
|
|
264
264
|
});
|
|
265
265
|
function A() {
|
|
266
266
|
const n = h.value;
|
|
267
267
|
if (e.form && n) {
|
|
268
|
-
const
|
|
269
|
-
|
|
268
|
+
const k = n.querySelector(`form[name="${e.form}"]`);
|
|
269
|
+
k && k.dispatchEvent(new Event("submit"));
|
|
270
270
|
}
|
|
271
271
|
a("submit");
|
|
272
272
|
}
|
|
273
273
|
function z() {
|
|
274
274
|
i == null || i.close(e.id);
|
|
275
275
|
}
|
|
276
|
-
function
|
|
276
|
+
function ce() {
|
|
277
277
|
window && window.addEventListener("resize", () => {
|
|
278
|
-
I(_), I(h), h.value && (v = h.value.offsetLeft,
|
|
278
|
+
I(_), I(h), h.value && (v = h.value.offsetLeft, w = h.value.offsetTop);
|
|
279
279
|
});
|
|
280
280
|
}
|
|
281
|
-
function
|
|
281
|
+
function ue() {
|
|
282
282
|
if (e.closeable && e.esc) {
|
|
283
|
-
const n = ({ key:
|
|
284
|
-
|
|
283
|
+
const n = ({ key: k }) => {
|
|
284
|
+
k === "Escape" && (i == null || i.close(e.id), window.removeEventListener("keydown", n));
|
|
285
285
|
};
|
|
286
286
|
window.addEventListener("keydown", n);
|
|
287
287
|
}
|
|
288
288
|
}
|
|
289
|
-
function
|
|
290
|
-
v = h.value.offsetLeft,
|
|
289
|
+
function fe() {
|
|
290
|
+
v = h.value.offsetLeft, w = h.value.offsetTop;
|
|
291
291
|
}
|
|
292
292
|
Y(() => {
|
|
293
|
-
|
|
294
|
-
}),
|
|
293
|
+
ue(), ce();
|
|
294
|
+
}), be(() => {
|
|
295
295
|
});
|
|
296
|
-
function
|
|
297
|
-
return c.value = !0, () =>
|
|
296
|
+
function pe() {
|
|
297
|
+
return c.value = !0, () => se();
|
|
298
298
|
}
|
|
299
|
-
function
|
|
299
|
+
function se() {
|
|
300
300
|
c.value = !1;
|
|
301
301
|
}
|
|
302
302
|
return s({
|
|
303
|
-
showLoading:
|
|
304
|
-
hideLoading:
|
|
305
|
-
}), (n,
|
|
303
|
+
showLoading: pe,
|
|
304
|
+
hideLoading: se
|
|
305
|
+
}), (n, k) => (y(), M("div", {
|
|
306
306
|
ref_key: "wrapperRef",
|
|
307
307
|
ref: _,
|
|
308
308
|
class: "modal-wrapper",
|
|
309
|
-
style: D(
|
|
310
|
-
onClick:
|
|
309
|
+
style: D(R.value),
|
|
310
|
+
onClick: k[0] || (k[0] = xe((ie) => n.maskClosable && G(), ["self"]))
|
|
311
311
|
}, [
|
|
312
|
-
Ce(L(le(k)) + " ", 1),
|
|
313
312
|
g("div", {
|
|
314
313
|
ref_key: "contentRef",
|
|
315
314
|
ref: h,
|
|
316
|
-
class:
|
|
317
|
-
style: D(
|
|
315
|
+
class: Ce(["modal-content", { [`${n.mode}-mode`]: !0 }]),
|
|
316
|
+
style: D(b.value)
|
|
318
317
|
}, [
|
|
319
|
-
n.header ? (y(),
|
|
318
|
+
n.header ? (y(), M("div", {
|
|
320
319
|
key: 0,
|
|
321
320
|
ref_key: "headerRef",
|
|
322
321
|
ref: d,
|
|
323
322
|
class: "modal-header",
|
|
324
|
-
style: D(
|
|
325
|
-
onMousedown:
|
|
323
|
+
style: D(B.value),
|
|
324
|
+
onMousedown: fe
|
|
326
325
|
}, [
|
|
327
|
-
g("div",
|
|
328
|
-
g("div",
|
|
329
|
-
n.closeable ? (y(),
|
|
326
|
+
g("div", Ge, O(n.title), 1),
|
|
327
|
+
g("div", Xe, [
|
|
328
|
+
n.closeable ? (y(), M("div", {
|
|
330
329
|
key: 0,
|
|
331
330
|
class: "i-icon-park-outline:close block cursor-pointer",
|
|
332
331
|
onClick: G
|
|
@@ -342,14 +341,14 @@ const Ge = (t) => (Ee("data-v-d92528b3"), t = t(), $e(), t), Xe = { class: "titl
|
|
|
342
341
|
class: "modal-body",
|
|
343
342
|
style: D($.value)
|
|
344
343
|
}, [
|
|
345
|
-
(y(), F(
|
|
344
|
+
(y(), F(le(n.component), ke(Me(n.componentProps)), null, 16))
|
|
346
345
|
], 4),
|
|
347
346
|
g("div", {
|
|
348
347
|
id: "modal-footer-slot",
|
|
349
348
|
ref_key: "footerSlotRef",
|
|
350
349
|
ref: l
|
|
351
350
|
}, null, 512),
|
|
352
|
-
n.footer ? (y(),
|
|
351
|
+
n.footer ? (y(), M("div", {
|
|
353
352
|
key: 1,
|
|
354
353
|
ref_key: "footerRef",
|
|
355
354
|
ref: r,
|
|
@@ -359,15 +358,15 @@ const Ge = (t) => (Ee("data-v-d92528b3"), t = t(), $e(), t), Xe = { class: "titl
|
|
|
359
358
|
class: "cancel-button",
|
|
360
359
|
type: "button",
|
|
361
360
|
onClick: z
|
|
362
|
-
},
|
|
361
|
+
}, O(n.cancelText), 1),
|
|
363
362
|
g("button", {
|
|
364
363
|
class: "submit-button",
|
|
365
364
|
form: n.form,
|
|
366
365
|
type: "submit",
|
|
367
366
|
onClick: A
|
|
368
|
-
},
|
|
367
|
+
}, O(n.submitText), 9, Ye)
|
|
369
368
|
], 512)) : N("", !0),
|
|
370
|
-
c.value ? (y(),
|
|
369
|
+
c.value ? (y(), M("div", Ke, qe)) : N("", !0)
|
|
371
370
|
], 6)
|
|
372
371
|
], 4));
|
|
373
372
|
}
|
|
@@ -377,7 +376,7 @@ const j = (t, s) => {
|
|
|
377
376
|
for (const [e, a] of s)
|
|
378
377
|
o[e] = a;
|
|
379
378
|
return o;
|
|
380
|
-
},
|
|
379
|
+
}, Ze = /* @__PURE__ */ j(Qe, [["__scopeId", "data-v-d6dd5541"]]), et = { class: "modal-dialog" }, tt = { class: "dialog-body" }, ot = { class: "dialog-title" }, nt = { class: "dialog-content" }, rt = /* @__PURE__ */ te({
|
|
381
380
|
__name: "modal-dialog",
|
|
382
381
|
props: {
|
|
383
382
|
type: {},
|
|
@@ -390,7 +389,7 @@ const j = (t, s) => {
|
|
|
390
389
|
footer: {}
|
|
391
390
|
},
|
|
392
391
|
setup(t) {
|
|
393
|
-
const s = t, o =
|
|
392
|
+
const s = t, o = ht(), e = E(() => s.title ? s.title : {
|
|
394
393
|
confirm: "提示",
|
|
395
394
|
info: "提示",
|
|
396
395
|
warning: "警告",
|
|
@@ -403,40 +402,40 @@ const j = (t, s) => {
|
|
|
403
402
|
async function i() {
|
|
404
403
|
s.onCancel && await s.onCancel(), o.close();
|
|
405
404
|
}
|
|
406
|
-
return (c, v) => (y(),
|
|
407
|
-
g("div",
|
|
408
|
-
g("div",
|
|
409
|
-
g("div",
|
|
405
|
+
return (c, v) => (y(), M("section", et, [
|
|
406
|
+
g("div", tt, [
|
|
407
|
+
g("div", ot, O(e.value), 1),
|
|
408
|
+
g("div", nt, O(c.content), 1)
|
|
410
409
|
]),
|
|
411
410
|
g("div", {
|
|
412
411
|
class: "dialog-footer space-x-2",
|
|
413
412
|
style: D(c.type === "confirm" ? { "justify-content": "end" } : { "border-top": "none" })
|
|
414
413
|
}, [
|
|
415
|
-
c.footer ? (y(), F(
|
|
414
|
+
c.footer ? (y(), F(le(c.footer), { key: 0 })) : (y(), M(Z, { key: 1 }, [
|
|
416
415
|
g("button", {
|
|
417
416
|
class: "submit-button",
|
|
418
417
|
type: "submit",
|
|
419
418
|
onClick: a
|
|
420
|
-
},
|
|
421
|
-
c.type === "confirm" ? (y(),
|
|
419
|
+
}, O(c.okText), 1),
|
|
420
|
+
c.type === "confirm" ? (y(), M("button", {
|
|
422
421
|
key: 0,
|
|
423
422
|
class: "cancel-button",
|
|
424
423
|
type: "button",
|
|
425
424
|
onClick: i
|
|
426
|
-
},
|
|
425
|
+
}, O(c.cancelText), 1)) : N("", !0)
|
|
427
426
|
], 64))
|
|
428
427
|
], 4)
|
|
429
428
|
]));
|
|
430
429
|
}
|
|
431
430
|
});
|
|
432
|
-
const
|
|
431
|
+
const st = /* @__PURE__ */ j(rt, [["__scopeId", "data-v-8326e5a5"]]), it = {
|
|
433
432
|
key: 0,
|
|
434
433
|
class: "modal-teleport"
|
|
435
|
-
},
|
|
434
|
+
}, lt = {
|
|
436
435
|
name: "ModalProvider",
|
|
437
436
|
inheritAttrs: !0
|
|
438
|
-
},
|
|
439
|
-
...
|
|
437
|
+
}, at = /* @__PURE__ */ te({
|
|
438
|
+
...lt,
|
|
440
439
|
props: {
|
|
441
440
|
appendToBody: { type: [Boolean, String], default: !1 },
|
|
442
441
|
sizes: { default: () => ({
|
|
@@ -449,13 +448,13 @@ const it = /* @__PURE__ */ j(st, [["__scopeId", "data-v-8326e5a5"]]), lt = {
|
|
|
449
448
|
offset: { default: () => ({ x: 0, y: 0 }) }
|
|
450
449
|
},
|
|
451
450
|
setup(t, { expose: s }) {
|
|
452
|
-
const o =
|
|
451
|
+
const o = P([]), e = H(!1), a = V();
|
|
453
452
|
function i(r, u = {}, l = {}) {
|
|
454
453
|
const m = Oe(
|
|
455
|
-
() => Promise.resolve(typeof r == "string" ?
|
|
454
|
+
() => Promise.resolve(typeof r == "string" ? st : r)
|
|
456
455
|
);
|
|
457
456
|
typeof r == "string" && (u.type = r, l.size = "small", l.fullscreen = !1, l.mode = "dialog", l.footer = !1, l.header = !1);
|
|
458
|
-
const f = Math.random().toString(32).slice(2), C = new Promise((
|
|
457
|
+
const f = Math.random().toString(32).slice(2), C = new Promise((S, L) => {
|
|
459
458
|
o.value.push({
|
|
460
459
|
id: f,
|
|
461
460
|
component: m,
|
|
@@ -464,12 +463,12 @@ const it = /* @__PURE__ */ j(st, [["__scopeId", "data-v-8326e5a5"]]), lt = {
|
|
|
464
463
|
...l,
|
|
465
464
|
type: typeof r == "string" ? r : "component"
|
|
466
465
|
},
|
|
467
|
-
resolve:
|
|
468
|
-
reject:
|
|
466
|
+
resolve: S,
|
|
467
|
+
reject: L,
|
|
469
468
|
listeners: []
|
|
470
469
|
}), I(o);
|
|
471
|
-
}).catch((
|
|
472
|
-
}) : Promise.reject(
|
|
470
|
+
}).catch((S) => S === "CANCEL" ? new Promise(() => {
|
|
471
|
+
}) : Promise.reject(S));
|
|
473
472
|
return Object.assign(C, {
|
|
474
473
|
close: () => c(f)
|
|
475
474
|
});
|
|
@@ -486,7 +485,7 @@ const it = /* @__PURE__ */ j(st, [["__scopeId", "data-v-8326e5a5"]]), lt = {
|
|
|
486
485
|
r == null || r.reject("CANCEL");
|
|
487
486
|
}), o.value = [], I(o));
|
|
488
487
|
}
|
|
489
|
-
function
|
|
488
|
+
function w(r, u) {
|
|
490
489
|
const l = o.value.find((f) => f.id === r);
|
|
491
490
|
if (!l)
|
|
492
491
|
return;
|
|
@@ -525,7 +524,7 @@ const it = /* @__PURE__ */ j(st, [["__scopeId", "data-v-8326e5a5"]]), lt = {
|
|
|
525
524
|
callback: l
|
|
526
525
|
});
|
|
527
526
|
}
|
|
528
|
-
return
|
|
527
|
+
return $e(K, {
|
|
529
528
|
open: i,
|
|
530
529
|
close: c,
|
|
531
530
|
closeAll: v,
|
|
@@ -537,16 +536,16 @@ const it = /* @__PURE__ */ j(st, [["__scopeId", "data-v-8326e5a5"]]), lt = {
|
|
|
537
536
|
closeAll: v
|
|
538
537
|
}), Y(() => {
|
|
539
538
|
e.value = !0;
|
|
540
|
-
}), (r, u) => (y(),
|
|
541
|
-
|
|
542
|
-
e.value ? (y(),
|
|
543
|
-
(y(), F(
|
|
539
|
+
}), (r, u) => (y(), M(Z, null, [
|
|
540
|
+
ne(r.$slots, "default", {}, void 0, !0),
|
|
541
|
+
e.value ? (y(), M("div", it, [
|
|
542
|
+
(y(), F(re, {
|
|
544
543
|
disabled: !r.appendToBody,
|
|
545
544
|
to: typeof r.appendToBody == "string" ? r.appendToBody : "body"
|
|
546
545
|
}, [
|
|
547
|
-
Le
|
|
548
|
-
default:
|
|
549
|
-
(y(!0),
|
|
546
|
+
Ae(Le, { name: "modal-fade" }, {
|
|
547
|
+
default: Re(() => [
|
|
548
|
+
(y(!0), M(Z, null, Be(o.value, (l) => (y(), F(Ze, Pe({
|
|
550
549
|
id: l.id,
|
|
551
550
|
key: l.id,
|
|
552
551
|
ref_for: !0,
|
|
@@ -558,7 +557,7 @@ const it = /* @__PURE__ */ j(st, [["__scopeId", "data-v-8326e5a5"]]), lt = {
|
|
|
558
557
|
offset: r.offset,
|
|
559
558
|
sizes: r.sizes
|
|
560
559
|
}, l.options, {
|
|
561
|
-
onSubmit: () =>
|
|
560
|
+
onSubmit: () => w(l.id, "submit")
|
|
562
561
|
}), null, 16, ["id", "component", "component-props", "max-height", "max-width", "offset", "sizes", "onSubmit"]))), 128))
|
|
563
562
|
]),
|
|
564
563
|
_: 1
|
|
@@ -568,25 +567,25 @@ const it = /* @__PURE__ */ j(st, [["__scopeId", "data-v-8326e5a5"]]), lt = {
|
|
|
568
567
|
], 64));
|
|
569
568
|
}
|
|
570
569
|
});
|
|
571
|
-
const
|
|
572
|
-
const
|
|
573
|
-
function
|
|
574
|
-
return y(), F(
|
|
575
|
-
g("div",
|
|
576
|
-
|
|
570
|
+
const gt = /* @__PURE__ */ j(at, [["__scopeId", "data-v-241a8304"]]);
|
|
571
|
+
const dt = {}, ct = { class: "modal-footer" };
|
|
572
|
+
function ut(t, s) {
|
|
573
|
+
return y(), F(re, { to: "#modal-footer-slot" }, [
|
|
574
|
+
g("div", ct, [
|
|
575
|
+
ne(t.$slots, "default", {}, void 0, !0)
|
|
577
576
|
])
|
|
578
577
|
]);
|
|
579
578
|
}
|
|
580
|
-
const
|
|
581
|
-
const
|
|
582
|
-
function
|
|
583
|
-
return y(), F(
|
|
584
|
-
g("div",
|
|
585
|
-
|
|
579
|
+
const yt = /* @__PURE__ */ j(dt, [["render", ut], ["__scopeId", "data-v-2080a86e"]]);
|
|
580
|
+
const ft = {}, pt = { class: "modal-header" };
|
|
581
|
+
function vt(t, s) {
|
|
582
|
+
return y(), F(re, { to: "#modal-header-slot" }, [
|
|
583
|
+
g("div", pt, [
|
|
584
|
+
ne(t.$slots, "default", {}, void 0, !0)
|
|
586
585
|
])
|
|
587
586
|
]);
|
|
588
587
|
}
|
|
589
|
-
const
|
|
588
|
+
const _t = /* @__PURE__ */ j(ft, [["render", vt], ["__scopeId", "data-v-d0247172"]]);
|
|
590
589
|
function X(t, s) {
|
|
591
590
|
var e, a;
|
|
592
591
|
let o = t == null ? void 0 : t.parent;
|
|
@@ -594,8 +593,8 @@ function X(t, s) {
|
|
|
594
593
|
o = o.parent;
|
|
595
594
|
return ((a = o == null ? void 0 : o.type) == null ? void 0 : a.name) === s ? o : null;
|
|
596
595
|
}
|
|
597
|
-
function
|
|
598
|
-
const t =
|
|
596
|
+
function ht() {
|
|
597
|
+
const t = oe(K), s = V();
|
|
599
598
|
function o(e, a, i) {
|
|
600
599
|
if (!t)
|
|
601
600
|
throw new Error("Not Found Modal Provider Component");
|
|
@@ -654,15 +653,15 @@ function mt() {
|
|
|
654
653
|
}
|
|
655
654
|
function wt(t) {
|
|
656
655
|
var i;
|
|
657
|
-
const s =
|
|
656
|
+
const s = oe(K), o = V(), e = X(o, "ModalContainer"), a = (i = e == null ? void 0 : e.props) == null ? void 0 : i.id;
|
|
658
657
|
s && a && s.addEventListener(a, "submit", t);
|
|
659
658
|
}
|
|
660
659
|
export {
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
660
|
+
Ze as ModalContainer,
|
|
661
|
+
yt as ModalFooter,
|
|
662
|
+
_t as ModalHeader,
|
|
664
663
|
K as ModalKey,
|
|
665
|
-
|
|
664
|
+
gt as ModalProvider,
|
|
666
665
|
wt as onSubmit,
|
|
667
|
-
|
|
666
|
+
ht as useModal
|
|
668
667
|
};
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
*,:before,:after{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 rgb(0 0 0 / 0);--un-ring-shadow:0 0 rgb(0 0 0 / 0);--un-shadow-inset: ;--un-shadow:0 0 rgb(0 0 0 / 0);--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgb(147 197 253 / .5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }::backdrop{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 rgb(0 0 0 / 0);--un-ring-shadow:0 0 rgb(0 0 0 / 0);--un-shadow-inset: ;--un-shadow:0 0 rgb(0 0 0 / 0);--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgb(147 197 253 / .5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }.i-icon-park-outline\:close{--un-icon:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 48 48' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='4' d='m8 8l32 32M8 40L40 8'/%3E%3C/svg%3E");-webkit-mask:var(--un-icon) no-repeat;mask:var(--un-icon) no-repeat;-webkit-mask-size:100% 100%;mask-size:100% 100%;background-color:currentColor;color:inherit;width:1em;height:1em}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.block{display:block}.inline-block{display:inline-block}.flex{display:flex}.transform{transform:translate(var(--un-translate-x)) translateY(var(--un-translate-y)) translateZ(var(--un-translate-z)) rotate(var(--un-rotate)) rotateX(var(--un-rotate-x)) rotateY(var(--un-rotate-y)) rotate(var(--un-rotate-z)) skew(var(--un-skew-x)) skewY(var(--un-skew-y)) scaleX(var(--un-scale-x)) scaleY(var(--un-scale-y)) scaleZ(var(--un-scale-z))}.cursor-pointer{cursor:pointer}.resize{resize:both}.space-x-2>:not([hidden])~:not([hidden]){--un-space-x-reverse:0;margin-left:calc(.5rem * calc(1 - var(--un-space-x-reverse)));margin-right:calc(.5rem * var(--un-space-x-reverse))}.border{border-width:1px}.px{padding-left:1rem;padding-right:1rem}.text-16px{font-size:16px}.font-bold{font-weight:700}.outline{outline-style:solid}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.ease{transition-timing-function:cubic-bezier(.4,0,.2,1)}.modal-wrapper[data-v-
|
|
1
|
+
*,:before,:after{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 rgb(0 0 0 / 0);--un-ring-shadow:0 0 rgb(0 0 0 / 0);--un-shadow-inset: ;--un-shadow:0 0 rgb(0 0 0 / 0);--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgb(147 197 253 / .5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }::backdrop{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 rgb(0 0 0 / 0);--un-ring-shadow:0 0 rgb(0 0 0 / 0);--un-shadow-inset: ;--un-shadow:0 0 rgb(0 0 0 / 0);--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgb(147 197 253 / .5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }.i-icon-park-outline\:close{--un-icon:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 48 48' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='4' d='m8 8l32 32M8 40L40 8'/%3E%3C/svg%3E");-webkit-mask:var(--un-icon) no-repeat;mask:var(--un-icon) no-repeat;-webkit-mask-size:100% 100%;mask-size:100% 100%;background-color:currentColor;color:inherit;width:1em;height:1em}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.block{display:block}.inline-block{display:inline-block}.flex{display:flex}.transform{transform:translate(var(--un-translate-x)) translateY(var(--un-translate-y)) translateZ(var(--un-translate-z)) rotate(var(--un-rotate)) rotateX(var(--un-rotate-x)) rotateY(var(--un-rotate-y)) rotate(var(--un-rotate-z)) skew(var(--un-skew-x)) skewY(var(--un-skew-y)) scaleX(var(--un-scale-x)) scaleY(var(--un-scale-y)) scaleZ(var(--un-scale-z))}.cursor-pointer{cursor:pointer}.resize{resize:both}.space-x-2>:not([hidden])~:not([hidden]){--un-space-x-reverse:0;margin-left:calc(.5rem * calc(1 - var(--un-space-x-reverse)));margin-right:calc(.5rem * var(--un-space-x-reverse))}.border{border-width:1px}.px{padding-left:1rem;padding-right:1rem}.text-16px{font-size:16px}.font-bold{font-weight:700}.outline{outline-style:solid}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.ease{transition-timing-function:cubic-bezier(.4,0,.2,1)}.modal-wrapper[data-v-d6dd5541]{z-index:1000;position:fixed;top:0;right:0;bottom:0;left:0;display:flex;align-items:center;background:rgba(0,0,0,.3)}.modal-content[data-v-d6dd5541]{background:#ffffff;border-radius:5px;position:relative}.modal-header[data-v-d6dd5541]{box-sizing:border-box;padding:10px;height:50px;display:flex;justify-content:space-between;align-items:center;border-bottom:solid 1px var(--color-border-1, #e8e8e8);color:var(--color-text-2, #4E5969)}.modal-body[data-v-d6dd5541]{padding:10px;box-sizing:border-box;overflow:auto;position:relative}.modal-footer[data-v-d6dd5541]{box-sizing:border-box;height:50px;border-top:solid 1px var(--color-border-1, #e8e8e8);display:flex;justify-content:flex-end;padding:10px}.modal-footer button[data-v-d6dd5541]{height:28px;line-height:28px;width:80px;outline:none;border-color:transparent;font-size:14px;border-radius:4px;padding:0;box-sizing:content-box}.modal-footer button.submit-button[data-v-d6dd5541]{color:#fff;background-color:rgb(var(--primary-6, 45, 106, 251))}.modal-footer button.submit-button[data-v-d6dd5541]:hover{background-color:rgb(var(--primary-5, 28, 76, 207))}.modal-footer button.cancel-button[data-v-d6dd5541]{color:rgb(var(--color-text-2, 78, 89, 105));background-color:var(--color-fill-1, #f5f5f5)}.modal-footer button.cancel-button[data-v-d6dd5541]:hover{background-color:var(--color-fill-4, #c9cdd4)}.modal-loading[data-v-d6dd5541]{position:absolute;z-index:1001;top:0;right:0;bottom:0;left:0;display:flex;justify-content:center;align-items:center;background-color:#0000001a}.modal-loading .lds-ring[data-v-d6dd5541]{display:inline-block;position:relative;width:80px;height:80px}.modal-loading .lds-ring div[data-v-d6dd5541]{box-sizing:border-box;display:block;position:absolute;width:48px;height:48px;margin:8px;border:5px solid #fff;border-radius:50%;animation:lds-ring-d6dd5541 1.2s cubic-bezier(.5,0,.5,1) infinite;border-color:#fff transparent transparent transparent}.modal-loading .lds-ring div[data-v-d6dd5541]:nth-child(1){animation-delay:-.45s}.modal-loading .lds-ring div[data-v-d6dd5541]:nth-child(2){animation-delay:-.3s}.modal-loading .lds-ring div[data-v-d6dd5541]:nth-child(3){animation-delay:-.15s}@keyframes lds-ring-d6dd5541{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.dialog-body[data-v-8326e5a5]{padding:20px 10px 10px}.dialog-title[data-v-8326e5a5]{padding:5px;font-weight:700;font-size:16px}.dialog-content[data-v-8326e5a5]{padding:5px}.dialog-footer[data-v-8326e5a5]{box-sizing:border-box;height:50px;border-top:solid 1px var(--color-border-1, #e8e8e8);display:flex;justify-content:center;align-items:center;padding:0 10px}.dialog-footer button[data-v-8326e5a5]{height:28px;line-height:28px;width:80px;outline:none;border-color:transparent;font-size:14px;border-radius:4px;padding:0;box-sizing:content-box}.dialog-footer button.submit-button[data-v-8326e5a5]{color:#fff;background-color:rgb(var(--primary-6, 45, 106, 251))}.dialog-footer button.submit-button[data-v-8326e5a5]:hover{background-color:rgb(var(--primary-5, 28, 76, 207))}.dialog-footer button.cancel-button[data-v-8326e5a5]{color:rgb(var(--color-text-2, 78, 89, 105));background-color:var(--color-fill-1, #f5f5f5)}.dialog-footer button.cancel-button[data-v-8326e5a5]:hover{background-color:var(--color-fill-4, #c9cdd4)}.modal-fade-enter-active[data-v-241a8304],.modal-fade-leave-active[data-v-241a8304]{transition:opacity .5s ease}.modal-fade-enter-active[data-v-241a8304] .modal-content.drawer-mode,.modal-fade-leave-active[data-v-241a8304] .modal-content.drawer-mode{transition:transform .5s ease}.modal-fade-enter-from[data-v-241a8304],.modal-fade-leave-to[data-v-241a8304]{opacity:0}.modal-fade-enter-from[data-v-241a8304] .modal-content.drawer-mode,.modal-fade-leave-to[data-v-241a8304] .modal-content.drawer-mode{transform:translate3d(100%,0,0)}.modal-footer[data-v-2080a86e]{box-sizing:border-box;min-height:50px;border-top:solid 1px var(--color-border-1, rgb(232, 232, 232));padding:10px}.modal-footer button[data-v-2080a86e]{height:28px;line-height:28px;width:80px;outline:none;border-color:transparent;font-size:14px;border-radius:4px;padding:0;box-sizing:content-box}.modal-footer button.submit-button[data-v-2080a86e]{color:#fff;background-color:rgb(var(--primary-6, 45, 106, 251))}.modal-footer button.submit-button[data-v-2080a86e]:hover{background-color:rgb(var(--primary-5, 28, 76, 207))}.modal-footer button.cancel-button[data-v-2080a86e]{color:rgb(var(--color-text-2, 78, 89, 105));background-color:var(--color-fill-1, #f5f5f5)}.modal-footer button.cancel-button[data-v-2080a86e]:hover{background-color:var(--color-fill-4, #c9cdd4)}.modal-header[data-v-d0247172]{box-sizing:border-box;padding:10px;min-height:50px;border-bottom:solid 1px var(--color-border-1, rgb(232, 232, 232));color:var(--color-text-2, #4E5969)}
|