@gopowerteam/modal-render 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/modal-container.vue.d.ts +6 -1
- package/dist/cjs/components/modal-dialog.vue.d.ts +43 -0
- package/dist/cjs/hooks/use-modal.d.ts +20 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/interfaces.d.ts +12 -6
- package/dist/es/components/modal-container.vue.d.ts +6 -1
- package/dist/es/components/modal-dialog.vue.d.ts +43 -0
- package/dist/es/hooks/use-modal.d.ts +20 -1
- package/dist/es/index.mjs +382 -257
- package/dist/es/interfaces.d.ts +12 -6
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -19,6 +19,7 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
19
19
|
maskClosable?: boolean | undefined;
|
|
20
20
|
draggable?: boolean | undefined;
|
|
21
21
|
mode?: "dialog" | "drawer" | undefined;
|
|
22
|
+
type?: string | undefined;
|
|
22
23
|
}>, {
|
|
23
24
|
header: boolean;
|
|
24
25
|
closeable: boolean;
|
|
@@ -29,7 +30,10 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
29
30
|
esc: boolean;
|
|
30
31
|
draggable: boolean;
|
|
31
32
|
mode: string;
|
|
32
|
-
}>, {
|
|
33
|
+
}>, {
|
|
34
|
+
showLoading: () => () => void;
|
|
35
|
+
hideLoading: () => void;
|
|
36
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
33
37
|
submit: (...args: any[]) => void;
|
|
34
38
|
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
35
39
|
id: string;
|
|
@@ -50,6 +54,7 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
50
54
|
maskClosable?: boolean | undefined;
|
|
51
55
|
draggable?: boolean | undefined;
|
|
52
56
|
mode?: "dialog" | "drawer" | undefined;
|
|
57
|
+
type?: string | undefined;
|
|
53
58
|
}>, {
|
|
54
59
|
header: boolean;
|
|
55
60
|
closeable: boolean;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
2
|
+
type: 'confirm' | 'success' | 'error' | 'warning' | 'info';
|
|
3
|
+
title?: string | undefined;
|
|
4
|
+
content: string;
|
|
5
|
+
okText?: string | undefined;
|
|
6
|
+
cancelText?: string | undefined;
|
|
7
|
+
onOk?: (() => Promise<void> | void) | undefined;
|
|
8
|
+
onCancel?: (() => Promise<void> | void) | undefined;
|
|
9
|
+
footer?: (() => JSX.Element) | undefined;
|
|
10
|
+
}>, {
|
|
11
|
+
okText: string;
|
|
12
|
+
cancelText: string;
|
|
13
|
+
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
14
|
+
type: 'confirm' | 'success' | 'error' | 'warning' | 'info';
|
|
15
|
+
title?: string | undefined;
|
|
16
|
+
content: string;
|
|
17
|
+
okText?: string | undefined;
|
|
18
|
+
cancelText?: string | undefined;
|
|
19
|
+
onOk?: (() => Promise<void> | void) | undefined;
|
|
20
|
+
onCancel?: (() => Promise<void> | void) | undefined;
|
|
21
|
+
footer?: (() => JSX.Element) | undefined;
|
|
22
|
+
}>, {
|
|
23
|
+
okText: string;
|
|
24
|
+
cancelText: string;
|
|
25
|
+
}>>>, {
|
|
26
|
+
okText: string;
|
|
27
|
+
cancelText: string;
|
|
28
|
+
}, {}>;
|
|
29
|
+
export default _default;
|
|
30
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
31
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
32
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
33
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
34
|
+
} : {
|
|
35
|
+
type: import('vue').PropType<T[K]>;
|
|
36
|
+
required: true;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
type __VLS_WithDefaults<P, D> = {
|
|
40
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
41
|
+
default: D[K];
|
|
42
|
+
}> : P[K];
|
|
43
|
+
};
|
|
@@ -1,7 +1,26 @@
|
|
|
1
1
|
import type { Component } from 'vue';
|
|
2
2
|
import type { OpenModalOptions } from '../interfaces';
|
|
3
3
|
export declare function useModal(): {
|
|
4
|
-
open
|
|
4
|
+
open: {
|
|
5
|
+
(component: 'confirm', props: {
|
|
6
|
+
title?: string;
|
|
7
|
+
content: string;
|
|
8
|
+
footer?: () => JSX.Element;
|
|
9
|
+
}): Promise<any> & {
|
|
10
|
+
close: () => void;
|
|
11
|
+
};
|
|
12
|
+
(component: 'info' | 'warning' | 'error' | 'sucess', props: {
|
|
13
|
+
title?: string;
|
|
14
|
+
content: string;
|
|
15
|
+
}): Promise<any> & {
|
|
16
|
+
close: () => void;
|
|
17
|
+
};
|
|
18
|
+
(component: Component, props?: Record<string, any>, options?: OpenModalOptions): Promise<any> & {
|
|
19
|
+
close: () => void;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
5
22
|
close(data?: any): void;
|
|
6
23
|
closeAll(): void;
|
|
24
|
+
showLoading(): void;
|
|
25
|
+
hideLoading(): void;
|
|
7
26
|
};
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue");const C=Symbol("__MODAL__");function O(n){return e.getCurrentScope()?(e.onScopeDispose(n),!0):!1}function g(n){return typeof n=="function"?n():e.unref(n)}const $=typeof window<"u"&&typeof document<"u",D=Object.prototype.toString,T=n=>D.call(n)==="[object Object]",H=()=>{};function W(n,i={}){if(!e.isRef(n))return e.toRefs(n);const t=Array.isArray(n.value)?Array.from({length:n.value.length}):{};for(const l in n.value)t[l]=e.customRef(()=>({get(){return n.value[l]},set(r){var u;if((u=g(i.replaceRef))!=null?u:!0)if(Array.isArray(n.value)){const m=[...n.value];m[l]=r,n.value=m}else{const m={...n.value,[l]:r};Object.setPrototypeOf(m,Object.getPrototypeOf(n.value)),n.value=m}else n.value[l]=r}}));return t}function F(n){var i;const t=g(n);return(i=t==null?void 0:t.$el)!=null?i:t}const N=$?window:void 0;function A(...n){let i,t,l,r;if(typeof n[0]=="string"||Array.isArray(n[0])?([t,l,r]=n,i=N):[i,t,l,r]=n,!i)return H;Array.isArray(t)||(t=[t]),Array.isArray(l)||(l=[l]);const u=[],y=()=>{u.forEach(c=>c()),u.length=0},m=(c,a,d,p)=>(c.addEventListener(a,d,p),()=>c.removeEventListener(a,d,p)),v=e.watch(()=>[F(i),g(r)],([c,a])=>{if(y(),!c)return;const d=T(a)?{...a}:a;u.push(...t.flatMap(p=>l.map(_=>m(c,p,_,d))))},{immediate:!0,flush:"post"}),s=()=>{v(),y()};return O(s),s}function I(n,i={}){var t,l;const{pointerTypes:r,preventDefault:u,stopPropagation:y,exact:m,onMove:v,onEnd:s,onStart:c,initialValue:a,axis:d="both",draggingElement:p=N,containerElement:_,handle:B=n}=i,h=e.ref((t=g(a))!=null?t:{x:0,y:0}),w=e.ref(),b=o=>r?r.includes(o.pointerType):!0,k=o=>{g(u)&&o.preventDefault(),g(y)&&o.stopPropagation()},S=o=>{var f;if(!b(o)||g(m)&&o.target!==g(n))return;const P=((f=g(_))!=null?f:g(n)).getBoundingClientRect(),z={x:o.clientX-P.left,y:o.clientY-P.top};(c==null?void 0:c(z,o))!==!1&&(w.value=z,k(o))},x=o=>{if(!b(o)||!w.value)return;let{x:f,y:E}=h.value;(d==="x"||d==="both")&&(f=o.clientX-w.value.x),(d==="y"||d==="both")&&(E=o.clientY-w.value.y),h.value={x:f,y:E},v==null||v(h.value,o),k(o)},M=o=>{b(o)&&w.value&&(w.value=void 0,s==null||s(h.value,o),k(o))};if($){const o={capture:(l=i.capture)!=null?l:!0};A(B,"pointerdown",S,o),A(p,"pointermove",x,o),A(p,"pointerup",M,o)}return{...W(h),position:h,isDragging:e.computed(()=>!!w.value),style:e.computed(()=>`left:${h.value.x}px;top:${h.value.y}px;`)}}const K={class:"title font-bold"},X={class:"action"},Y={key:1,class:"modal-footer space-x-2"},q=["form"],j={name:"ModalContainer",inheritAttrs:!0},G=e.defineComponent({...j,props:{id:{},form:{},component:{},componentProps:{},width:{},maxWidth:{},maxHeight:{},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"}},emits:["submit"],setup(n,{emit:i}){const t=n,l=i,r=e.inject(C);let u=0,y=0;const m=e.shallowRef(),v=e.shallowRef(),s=e.shallowRef(),{x:c,y:a}=I(s,{initialValue:{x:0,y:0}});function d(){r==null||r.close(t.id)}function p(o){if(typeof o=="number")return`${o}px`;if(typeof o=="string")return o}const _=e.computed(()=>{const o={};return t.mode==="dialog"&&(o.justifyContent="center"),t.mode==="drawer"&&(o.justifyContent="flex-end"),o}),B=e.computed(()=>{const o={};return t.size&&(o.width=p(t.sizes[t.size])),t.width&&(o.width=p(t.width)),t.maxWidth&&(o.maxWidth=p(t.maxWidth)),t.fullscreen&&(o.maxWidth="unset",o.width="100%",o.position="fixed",o.top=0,o.left=0,o.bottom=0,o.right=0),t.draggable&&!t.fullscreen&&t.mode==="dialog"&&(o.transform=`translate3d(${c.value-u}px, ${a.value-y}px, 0px)`),o}),h=e.computed(()=>{const o={};return t.draggable&&!t.fullscreen&&t.mode==="dialog"&&(o.cursor="move"),o}),w=e.computed(()=>{var f;const o={};return t.maxHeight&&(o.maxHeight=`calc(${(f=p(t.maxHeight))==null?void 0:f.replace("%","vh")} - 50px)`),t.mode==="drawer"&&(o.maxHeight=`calc(100vh - ${(t.header?50:0)+(t.footer?50:0)}px)`),t.fullscreen&&(o.maxHeight=`calc(100vh - ${(t.header?50:0)+(t.footer?50:0)}px)`),o});function b(){const o=v.value;if(t.form&&o){const f=o.querySelector(`form[name="${t.form}"]`);f&&f.dispatchEvent(new Event("submit"))}l("submit",{open:r==null?void 0:r.open,close:f=>r==null?void 0:r.close(t.id,f)})}function k(){r==null||r.close(t.id)}function S(){window&&window.addEventListener("resize",()=>{e.triggerRef(m),e.triggerRef(v),u=v.value.offsetLeft,y=v.value.offsetTop})}function x(){if(t.closeable&&t.esc){const o=({key:f})=>{f==="Escape"&&(r==null||r.close(t.id),window.removeEventListener("keydown",o))};window.addEventListener("keydown",o)}}function M(){u=v.value.offsetLeft,y=v.value.offsetTop}return e.onMounted(()=>{x(),S()}),e.onUnmounted(()=>{}),(o,f)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"wrapperRef",ref:m,class:"modal-wrapper",style:e.normalizeStyle(_.value),onClick:f[0]||(f[0]=e.withModifiers(E=>o.maskClosable&&d(),["self"]))},[e.createElementVNode("div",{ref_key:"contentRef",ref:v,class:e.normalizeClass(["modal-content",{[`${o.mode}-mode`]:!0}]),style:e.normalizeStyle(B.value)},[o.header?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"headerRef",ref:s,class:"modal-header",style:e.normalizeStyle(h.value),onMousedown:M},[e.createElementVNode("div",K,e.toDisplayString(o.title),1),e.createElementVNode("div",X,[o.closeable?(e.openBlock(),e.createElementBlock("div",{key:0,class:"i-icon-park-outline:close block cursor-pointer",onClick:d})):e.createCommentVNode("",!0)])],36)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"modal-body",style:e.normalizeStyle(w.value)},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.component),e.normalizeProps(e.guardReactiveProps(o.componentProps)),null,16))],4),o.footer?(e.openBlock(),e.createElementBlock("div",Y,[e.createElementVNode("button",{class:"submit-button",form:o.form,type:"submit",onClick:b}," 确定 ",8,q),e.createElementVNode("button",{class:"cancel-button",type:"button",onClick:k}," 取消 ")])):e.createCommentVNode("",!0)],6)],4))}});const V=(n,i)=>{const t=n.__vccOpts||n;for(const[l,r]of i)t[l]=r;return t},R=V(G,[["__scopeId","data-v-33b22316"]]),U={key:0,class:"modal-teleport"},J={name:"ModalProvider",inheritAttrs:!0},Q=e.defineComponent({...J,props:{appendToBody:{type:[Boolean,String],default:!1},sizes:{default:()=>({small:520,middle:860,large:1190})},maxWidth:{default:"80%"},maxHeight:{default:"80%"}},setup(n,{expose:i}){const t=e.shallowRef([]),l=e.ref(!1);async function r(s,c,a){const d=e.defineAsyncComponent(()=>Promise.resolve(s));return new Promise(p=>{t.value.push({id:Math.random().toString(32).slice(2),component:d,props:c,options:a,resolve:p,onSubmit:e.ref(null)}),e.triggerRef(t)})}function u(s,c){const a=t.value.findIndex(p=>p.id===s);if(a<0)return;const d=t.value[a];d==null||d.resolve(c),t.value.splice(a,1),e.triggerRef(t)}function y(){t.value.forEach(s=>{s.resolve()}),t.value=[],e.triggerRef(t)}function m(s){return t.value.find(c=>c.id===s)}function v(s,c){const a=t.value.find(d=>d.id===s);console.log(c,111),a&&(a.onSubmit.value=c)}return e.provide(C,{open:r,close:u,closeAll:y,getElement:m,addSubmitListener:v}),i({elements:t}),e.onMounted(()=>{l.value=!0}),(s,c)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.renderSlot(s.$slots,"default",{},void 0,!0),l.value?(e.openBlock(),e.createElementBlock("div",U,[(e.openBlock(),e.createBlock(e.Teleport,{disabled:!s.appendToBody,to:typeof s.appendToBody=="string"?s.appendToBody:"body"},[e.createVNode(e.TransitionGroup,{name:"modal-fade"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.value,a=>(e.openBlock(),e.createBlock(R,e.mergeProps({id:a.id,key:a.id,component:a.component,"component-props":a.props,"max-height":s.maxHeight,"max-width":s.maxWidth,sizes:s.sizes},a.options,{onSubmit:a.onSubmit.value}),null,16,["id","component","component-props","max-height","max-width","sizes","onSubmit"]))),128))]),_:1})],8,["disabled","to"]))])):e.createCommentVNode("",!0)],64))}});const Z=V(Q,[["__scopeId","data-v-cec9e05a"]]);function L(n,i){var l,r;let t=n==null?void 0:n.parent;for(;t&&((l=t==null?void 0:t.type)==null?void 0:l.name)!==i;)t=t.parent;return((r=t==null?void 0:t.type)==null?void 0:r.name)===i?t:null}function ee(){const n=e.inject(C),i=e.getCurrentInstance();return{open(t,l,r){if(!n)throw new Error("Not Found Modal Provider Component");return n.open(t,l||{},r||{})},close(t){var u;if(!n)throw new Error("Not Found Modal Provider Component");const l=L(i,"ModalContainer"),r=(u=l==null?void 0:l.props)==null?void 0:u.id;if(!r)throw new Error("Not Found Current Modal Container");n.close(r,t)},closeAll(){if(!n)throw new Error("Not Found Modal Provider Component");n.closeAll()}}}function te(n){var u;const i=e.inject(C),t=e.getCurrentInstance(),l=L(t,"ModalContainer"),r=(u=l==null?void 0:l.props)==null?void 0:u.id;i&&r&&i.addSubmitListener(r,n)}exports.ModalContainer=R;exports.ModalKey=C;exports.ModalProvider=Z;exports.onSubmit=te;exports.useModal=ee;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue");const S=Symbol("__MODAL__");function R(o){return e.getCurrentScope()?(e.onScopeDispose(o),!0):!1}function C(o){return typeof o=="function"?o():e.unref(o)}const A=typeof window<"u"&&typeof document<"u",F=Object.prototype.toString,I=o=>F.call(o)==="[object Object]",H=()=>{};function W(o,s={}){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(a){var i;if((i=C(s.replaceRef))!=null?i:!0)if(Array.isArray(o.value)){const y=[...o.value];y[t]=a,o.value=y}else{const y={...o.value,[t]:a};Object.setPrototypeOf(y,Object.getPrototypeOf(o.value)),o.value=y}else o.value[t]=a}}));return n}function j(o){var s;const n=C(o);return(s=n==null?void 0:n.$el)!=null?s:n}const D=A?window:void 0;function P(...o){let s,n,t,a;if(typeof o[0]=="string"||Array.isArray(o[0])?([n,t,a]=o,s=D):[s,n,t,a]=o,!s)return H;Array.isArray(n)||(n=[n]),Array.isArray(t)||(t=[t]);const i=[],f=()=>{i.forEach(m=>m()),i.length=0},y=(m,g,l,u)=>(m.addEventListener(g,l,u),()=>m.removeEventListener(g,l,u)),_=e.watch(()=>[j(s),C(a)],([m,g])=>{if(f(),!m)return;const l=I(g)?{...g}:g;i.push(...n.flatMap(u=>t.map(c=>y(m,u,c,l))))},{immediate:!0,flush:"post"}),w=()=>{_(),f()};return R(w),w}function K(o,s={}){var n,t;const{pointerTypes:a,preventDefault:i,stopPropagation:f,exact:y,onMove:_,onEnd:w,onStart:m,initialValue:g,axis:l="both",draggingElement:u=D,containerElement:c,handle:v=o}=s,p=e.ref((n=C(g))!=null?n:{x:0,y:0}),h=e.ref(),E=d=>a?a.includes(d.pointerType):!0,B=d=>{C(i)&&d.preventDefault(),C(f)&&d.stopPropagation()},V=d=>{var b;if(!E(d)||C(y)&&d.target!==C(o))return;const x=((b=C(c))!=null?b:C(o)).getBoundingClientRect(),r={x:d.clientX-x.left,y:d.clientY-x.top};(m==null?void 0:m(r,d))!==!1&&(h.value=r,B(d))},L=d=>{if(!E(d)||!h.value)return;let{x:b,y:M}=p.value;(l==="x"||l==="both")&&(b=d.clientX-h.value.x),(l==="y"||l==="both")&&(M=d.clientY-h.value.y),p.value={x:b,y:M},_==null||_(p.value,d),B(d)},$=d=>{E(d)&&h.value&&(h.value=void 0,w==null||w(p.value,d),B(d))};if(A){const d={capture:(t=s.capture)!=null?t:!0};P(v,"pointerdown",V,d),P(u,"pointermove",L,d),P(u,"pointerup",$,d)}return{...W(p),position:p,isDragging:e.computed(()=>!!h.value),style:e.computed(()=>`left:${p.value.x}px;top:${p.value.y}px;`)}}const X=o=>(e.pushScopeId("data-v-450bcc09"),o=o(),e.popScopeId(),o),Y={class:"title font-bold"},q={class:"action"},G={key:1,class:"modal-footer space-x-2"},U=["form"],J={key:2,class:"modal-loading"},Q=X(()=>e.createElementVNode("div",{class:"lds-ring"},[e.createElementVNode("div"),e.createElementVNode("div"),e.createElementVNode("div"),e.createElementVNode("div")],-1)),Z=[Q],ee={name:"ModalContainer",inheritAttrs:!0},te=e.defineComponent({...ee,props:{id:{},form:{},component:{},componentProps:{},width:{},maxWidth:{},maxHeight:{},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:{}},emits:["submit"],setup(o,{expose:s,emit:n}){const t=o,a=n,i=e.inject(S),f=e.ref(!1);let y=0,_=0;const w=e.shallowRef(),m=e.shallowRef(),g=e.shallowRef(),{x:l,y:u}=K(g,{initialValue:{x:0,y:0}});function c(){i==null||i.close(t.id)}function v(r){if(typeof r=="number")return`${r}px`;if(typeof r=="string")return r}const p=e.computed(()=>{const r={};return t.mode==="dialog"&&(r.justifyContent="center"),t.mode==="drawer"&&(r.justifyContent="flex-end"),r}),h=e.computed(()=>{const r={};return t.size&&(r.width=v(t.sizes[t.size])),t.width&&(r.width=v(t.width)),t.maxWidth&&(r.maxWidth=v(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(${l.value-y}px, ${u.value-_}px, 0px)`),t.mode==="drawer"&&(r.borderRadius=0),r}),E=e.computed(()=>{const r={};return t.draggable&&!t.fullscreen&&t.mode==="dialog"&&(r.cursor="move"),r}),B=e.computed(()=>{var k;const r={};return t.maxHeight&&(r.maxHeight=`calc(${(k=v(t.maxHeight))==null?void 0:k.replace("%","vh")} - 50px)`),t.mode==="drawer"&&(r.maxHeight="unset",r.height=`calc(100vh - ${(t.header?50:0)+(t.footer?50:0)}px)`),t.fullscreen&&(r.maxHeight="unset",r.height=`calc(100vh - ${(t.header?50:0)+(t.footer?50:0)}px)`),t.type!=="component"&&(r.padding="0"),r});function V(){const r=m.value;if(t.form&&r){const k=r.querySelector(`form[name="${t.form}"]`);k&&k.dispatchEvent(new Event("submit"))}a("submit")}function L(){i==null||i.close(t.id)}function $(){window&&window.addEventListener("resize",()=>{e.triggerRef(w),e.triggerRef(m),y=m.value.offsetLeft,_=m.value.offsetTop})}function d(){if(t.closeable&&t.esc){const r=({key:k})=>{k==="Escape"&&(i==null||i.close(t.id),window.removeEventListener("keydown",r))};window.addEventListener("keydown",r)}}function b(){y=m.value.offsetLeft,_=m.value.offsetTop}e.onMounted(()=>{d(),$()}),e.onUnmounted(()=>{});function M(){return f.value=!0,()=>x()}function x(){f.value=!1}return s({showLoading:M,hideLoading:x}),(r,k)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"wrapperRef",ref:w,class:"modal-wrapper",style:e.normalizeStyle(p.value),onClick:k[0]||(k[0]=e.withModifiers(pe=>r.maskClosable&&c(),["self"]))},[e.createElementVNode("div",{ref_key:"contentRef",ref:m,class:e.normalizeClass(["modal-content",{[`${r.mode}-mode`]:!0}]),style:e.normalizeStyle(h.value)},[r.header?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"headerRef",ref:g,class:"modal-header",style:e.normalizeStyle(E.value),onMousedown:b},[e.createElementVNode("div",Y,e.toDisplayString(r.title),1),e.createElementVNode("div",q,[r.closeable?(e.openBlock(),e.createElementBlock("div",{key:0,class:"i-icon-park-outline:close block cursor-pointer",onClick:c})):e.createCommentVNode("",!0)])],36)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"modal-body",style:e.normalizeStyle(B.value)},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(r.component),e.normalizeProps(e.guardReactiveProps(r.componentProps)),null,16))],4),r.footer?(e.openBlock(),e.createElementBlock("div",G,[e.createElementVNode("button",{class:"submit-button",form:r.form,type:"submit",onClick:V}," 确定 ",8,U),e.createElementVNode("button",{class:"cancel-button",type:"button",onClick:L}," 取消 ")])):e.createCommentVNode("",!0),f.value?(e.openBlock(),e.createElementBlock("div",J,Z)):e.createCommentVNode("",!0)],6)],4))}});const z=(o,s)=>{const n=o.__vccOpts||o;for(const[t,a]of s)n[t]=a;return n},O=z(te,[["__scopeId","data-v-450bcc09"]]),oe={class:"modal-dialog"},ne={class:"dialog-body"},re={class:"dialog-title"},le={class:"dialog-content"},ie=e.defineComponent({__name:"modal-dialog",props:{type:{},title:{},content:{},okText:{default:"确定"},cancelText:{default:"取消"},onOk:{},onCancel:{},footer:{}},setup(o){const s=o,n=T(),t=e.computed(()=>s.title?s.title:{confirm:"提示",info:"提示",warning:"警告",error:"错误",success:"成功"}[s.type]);async function a(){s.onOk&&await s.onOk(),n.close()}async function i(){s.onCancel&&await s.onCancel(),n.close()}return(f,y)=>(e.openBlock(),e.createElementBlock("section",oe,[e.createElementVNode("div",ne,[e.createElementVNode("div",re,e.toDisplayString(t.value),1),e.createElementVNode("div",le,e.toDisplayString(f.content),1)]),e.createElementVNode("div",{class:"dialog-footer space-x-2",style:e.normalizeStyle(f.type==="confirm"?{"justify-content":"end"}:{"border-top":"none"})},[f.footer?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(f.footer),{key:0})):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("button",{class:"submit-button",type:"submit",onClick:a},e.toDisplayString(f.okText),1),f.type==="confirm"?(e.openBlock(),e.createElementBlock("button",{key:0,class:"cancel-button",type:"button",onClick:i},e.toDisplayString(f.cancelText),1)):e.createCommentVNode("",!0)],64))],4)]))}});const se=z(ie,[["__scopeId","data-v-8326e5a5"]]),ae={key:0,class:"modal-teleport"},ce={name:"ModalProvider",inheritAttrs:!0},de=e.defineComponent({...ce,props:{appendToBody:{type:[Boolean,String],default:!1},sizes:{default:()=>({small:520,middle:860,large:1190})},maxWidth:{default:"80%"},maxHeight:{default:"80%"}},setup(o,{expose:s}){const n=e.shallowRef([]),t=e.ref(!1),a=e.getCurrentInstance();function i(l,u={},c={}){const v=e.defineAsyncComponent(()=>Promise.resolve(typeof l=="string"?se:l));typeof l=="string"&&(u.type=l,c.size="small",c.fullscreen=!1,c.mode="dialog",c.footer=!1,c.header=!1);const p=Math.random().toString(32).slice(2),h=new Promise(E=>{n.value.push({id:p,component:v,props:u||{},options:{...c,type:typeof l=="string"?l:"component"},resolve:E,listeners:[]}),e.triggerRef(n)});return Object.assign(h,{close:()=>f(p)})}function f(l,u){const c=n.value.findIndex(p=>p.id===l);if(c<0)return;const v=n.value[c];v==null||v.resolve(u),n.value.splice(c,1),e.triggerRef(n)}function y(){n.value.forEach(l=>{l.resolve()}),n.value=[],e.triggerRef(n)}function _(l,u){const c=n.value.find(p=>p.id===l);if(!c)return;const v=c.listeners.find(p=>p.event===u);v&&v.callback({open:i,close:()=>f(c.id),closeAll:y,showLoading:()=>w(c.id),hideLoading:()=>m(c.id)})}function w(l){if(!a)return;const[u]=a.refs[`modal-container_${l}`];if(u)return u.showLoading()}function m(l){if(!a)return;const[u]=a.refs[`modal-container_${l}`];if(u)return u.hideLoading()}function g(l,u,c){const v=n.value.find(p=>p.id===l);v&&v.listeners.push({event:u,callback:c})}return e.provide(S,{open:i,close:f,closeAll:y,addEventListener:g}),s({elements:n}),e.onMounted(()=>{t.value=!0}),(l,u)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.renderSlot(l.$slots,"default",{},void 0,!0),t.value?(e.openBlock(),e.createElementBlock("div",ae,[(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,c=>(e.openBlock(),e.createBlock(O,e.mergeProps({id:c.id,key:c.id,ref_for:!0,ref:`modal-container_${c.id}`,component:c.component,"component-props":c.props,"max-height":l.maxHeight,"max-width":l.maxWidth,sizes:l.sizes},c.options,{onSubmit:()=>_(c.id,"submit")}),null,16,["id","component","component-props","max-height","max-width","sizes","onSubmit"]))),128))]),_:1})],8,["disabled","to"]))])):e.createCommentVNode("",!0)],64))}});const ue=z(de,[["__scopeId","data-v-09133e47"]]);function N(o,s){var t,a;let n=o==null?void 0:o.parent;for(;n&&((t=n==null?void 0:n.type)==null?void 0:t.name)!==s;)n=n.parent;return((a=n==null?void 0:n.type)==null?void 0:a.name)===s?n:null}function T(){const o=e.inject(S),s=e.getCurrentInstance();function n(t,a,i){if(!o)throw new Error("Not Found Modal Provider Component");return o.open(t,a,i)}return{open:n,close(t){var f;if(!o)throw new Error("Not Found Modal Provider Component");const a=N(s,"ModalContainer"),i=(f=a==null?void 0:a.props)==null?void 0:f.id;if(!i)throw new Error("Not Found Current Modal Container");o.close(i,t)},closeAll(){if(!o)throw new Error("Not Found Modal Provider Component");o.closeAll()},showLoading(){var i;if(!o)throw new Error("Not Found Modal Provider Component");const t=N(s,"ModalContainer");if(!((i=t==null?void 0:t.props)==null?void 0:i.id))throw new Error("Not Found Current Modal Container");t!=null&&t.exposed&&(t==null||t.exposed.showLoading())},hideLoading(){var i;if(!o)throw new Error("Not Found Modal Provider Component");const t=N(s,"ModalContainer");if(!((i=t==null?void 0:t.props)==null?void 0:i.id))throw new Error("Not Found Current Modal Container");t!=null&&t.exposed&&(t==null||t.exposed.hideLoading())}}}function fe(o){var i;const s=e.inject(S),n=e.getCurrentInstance(),t=N(n,"ModalContainer"),a=(i=t==null?void 0:t.props)==null?void 0:i.id;s&&a&&s.addEventListener(a,"submit",o)}exports.ModalContainer=O;exports.ModalKey=S;exports.ModalProvider=ue;exports.onSubmit=fe;exports.useModal=T;
|
package/dist/cjs/interfaces.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Component
|
|
1
|
+
import type { Component } from 'vue';
|
|
2
2
|
import type { useModal } from './hooks/use-modal';
|
|
3
3
|
export interface SizeOptions {
|
|
4
4
|
small: number;
|
|
@@ -25,13 +25,19 @@ export interface ModalElement extends OpenModalOptions {
|
|
|
25
25
|
resolve: (data?: any) => void;
|
|
26
26
|
component: Component;
|
|
27
27
|
props: Record<string, any>;
|
|
28
|
-
options: OpenModalOptions
|
|
29
|
-
|
|
28
|
+
options: OpenModalOptions & {
|
|
29
|
+
type?: string;
|
|
30
|
+
};
|
|
31
|
+
listeners: {
|
|
32
|
+
event: string;
|
|
33
|
+
callback: (actions: ReturnType<typeof useModal>) => void;
|
|
34
|
+
}[];
|
|
30
35
|
}
|
|
31
36
|
export interface ModalActions {
|
|
32
|
-
open: (component: Component, props
|
|
37
|
+
open: (component: Component | 'confirm' | 'info' | 'warning' | 'error' | 'sucess', props?: Record<string, any>, options?: OpenModalOptions) => Promise<any> & {
|
|
38
|
+
close: () => void;
|
|
39
|
+
};
|
|
33
40
|
close: (id: string, data?: any) => void;
|
|
34
41
|
closeAll: () => void;
|
|
35
|
-
|
|
36
|
-
addSubmitListener: (id: string, fun: (modal: ReturnType<typeof useModal>) => void) => void;
|
|
42
|
+
addEventListener: (id: string, event: 'submit', callback: (modal: ReturnType<typeof useModal>) => void) => void;
|
|
37
43
|
}
|
|
@@ -19,6 +19,7 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
19
19
|
maskClosable?: boolean | undefined;
|
|
20
20
|
draggable?: boolean | undefined;
|
|
21
21
|
mode?: "dialog" | "drawer" | undefined;
|
|
22
|
+
type?: string | undefined;
|
|
22
23
|
}>, {
|
|
23
24
|
header: boolean;
|
|
24
25
|
closeable: boolean;
|
|
@@ -29,7 +30,10 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
29
30
|
esc: boolean;
|
|
30
31
|
draggable: boolean;
|
|
31
32
|
mode: string;
|
|
32
|
-
}>, {
|
|
33
|
+
}>, {
|
|
34
|
+
showLoading: () => () => void;
|
|
35
|
+
hideLoading: () => void;
|
|
36
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
33
37
|
submit: (...args: any[]) => void;
|
|
34
38
|
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
35
39
|
id: string;
|
|
@@ -50,6 +54,7 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
50
54
|
maskClosable?: boolean | undefined;
|
|
51
55
|
draggable?: boolean | undefined;
|
|
52
56
|
mode?: "dialog" | "drawer" | undefined;
|
|
57
|
+
type?: string | undefined;
|
|
53
58
|
}>, {
|
|
54
59
|
header: boolean;
|
|
55
60
|
closeable: boolean;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
2
|
+
type: 'confirm' | 'success' | 'error' | 'warning' | 'info';
|
|
3
|
+
title?: string | undefined;
|
|
4
|
+
content: string;
|
|
5
|
+
okText?: string | undefined;
|
|
6
|
+
cancelText?: string | undefined;
|
|
7
|
+
onOk?: (() => Promise<void> | void) | undefined;
|
|
8
|
+
onCancel?: (() => Promise<void> | void) | undefined;
|
|
9
|
+
footer?: (() => JSX.Element) | undefined;
|
|
10
|
+
}>, {
|
|
11
|
+
okText: string;
|
|
12
|
+
cancelText: string;
|
|
13
|
+
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
14
|
+
type: 'confirm' | 'success' | 'error' | 'warning' | 'info';
|
|
15
|
+
title?: string | undefined;
|
|
16
|
+
content: string;
|
|
17
|
+
okText?: string | undefined;
|
|
18
|
+
cancelText?: string | undefined;
|
|
19
|
+
onOk?: (() => Promise<void> | void) | undefined;
|
|
20
|
+
onCancel?: (() => Promise<void> | void) | undefined;
|
|
21
|
+
footer?: (() => JSX.Element) | undefined;
|
|
22
|
+
}>, {
|
|
23
|
+
okText: string;
|
|
24
|
+
cancelText: string;
|
|
25
|
+
}>>>, {
|
|
26
|
+
okText: string;
|
|
27
|
+
cancelText: string;
|
|
28
|
+
}, {}>;
|
|
29
|
+
export default _default;
|
|
30
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
31
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
32
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
33
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
34
|
+
} : {
|
|
35
|
+
type: import('vue').PropType<T[K]>;
|
|
36
|
+
required: true;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
type __VLS_WithDefaults<P, D> = {
|
|
40
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
41
|
+
default: D[K];
|
|
42
|
+
}> : P[K];
|
|
43
|
+
};
|
|
@@ -1,7 +1,26 @@
|
|
|
1
1
|
import type { Component } from 'vue';
|
|
2
2
|
import type { OpenModalOptions } from '../interfaces';
|
|
3
3
|
export declare function useModal(): {
|
|
4
|
-
open
|
|
4
|
+
open: {
|
|
5
|
+
(component: 'confirm', props: {
|
|
6
|
+
title?: string;
|
|
7
|
+
content: string;
|
|
8
|
+
footer?: () => JSX.Element;
|
|
9
|
+
}): Promise<any> & {
|
|
10
|
+
close: () => void;
|
|
11
|
+
};
|
|
12
|
+
(component: 'info' | 'warning' | 'error' | 'sucess', props: {
|
|
13
|
+
title?: string;
|
|
14
|
+
content: string;
|
|
15
|
+
}): Promise<any> & {
|
|
16
|
+
close: () => void;
|
|
17
|
+
};
|
|
18
|
+
(component: Component, props?: Record<string, any>, options?: OpenModalOptions): Promise<any> & {
|
|
19
|
+
close: () => void;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
5
22
|
close(data?: any): void;
|
|
6
23
|
closeAll(): void;
|
|
24
|
+
showLoading(): void;
|
|
25
|
+
hideLoading(): void;
|
|
7
26
|
};
|
package/dist/es/index.mjs
CHANGED
|
@@ -1,127 +1,137 @@
|
|
|
1
|
-
import { unref as
|
|
2
|
-
const
|
|
3
|
-
function
|
|
4
|
-
return
|
|
1
|
+
import { unref as Z, isRef as ee, toRefs as te, customRef as oe, getCurrentScope as ne, onScopeDispose as ie, ref as N, computed as S, watch as re, defineComponent as Y, inject as K, shallowRef as T, onMounted as U, onUnmounted as se, openBlock as h, createElementBlock as w, normalizeStyle as z, withModifiers as le, createElementVNode as y, normalizeClass as ae, toDisplayString as B, createCommentVNode as $, createBlock as F, resolveDynamicComponent as j, normalizeProps as de, guardReactiveProps as ce, triggerRef as O, pushScopeId as ue, popScopeId as fe, Fragment as X, getCurrentInstance as q, provide as pe, renderSlot as me, Teleport as ve, createVNode as ye, TransitionGroup as he, withCtx as ge, renderList as _e, mergeProps as we, defineAsyncComponent as be } from "vue";
|
|
2
|
+
const H = Symbol("__MODAL__");
|
|
3
|
+
function Ce(t) {
|
|
4
|
+
return ne() ? (ie(t), !0) : !1;
|
|
5
5
|
}
|
|
6
|
-
function
|
|
7
|
-
return typeof
|
|
6
|
+
function x(t) {
|
|
7
|
+
return typeof t == "function" ? t() : Z(t);
|
|
8
8
|
}
|
|
9
|
-
const
|
|
9
|
+
const J = typeof window < "u" && typeof document < "u", ke = Object.prototype.toString, xe = (t) => ke.call(t) === "[object Object]", Me = () => {
|
|
10
10
|
};
|
|
11
|
-
function
|
|
12
|
-
if (!
|
|
13
|
-
return
|
|
14
|
-
const
|
|
15
|
-
for (const
|
|
16
|
-
e
|
|
11
|
+
function Ee(t, s = {}) {
|
|
12
|
+
if (!ee(t))
|
|
13
|
+
return te(t);
|
|
14
|
+
const o = Array.isArray(t.value) ? Array.from({ length: t.value.length }) : {};
|
|
15
|
+
for (const e in t.value)
|
|
16
|
+
o[e] = oe(() => ({
|
|
17
17
|
get() {
|
|
18
|
-
return
|
|
18
|
+
return t.value[e];
|
|
19
19
|
},
|
|
20
|
-
set(
|
|
21
|
-
var
|
|
22
|
-
if ((
|
|
23
|
-
if (Array.isArray(
|
|
24
|
-
const
|
|
25
|
-
|
|
20
|
+
set(l) {
|
|
21
|
+
var r;
|
|
22
|
+
if ((r = x(s.replaceRef)) != null ? r : !0)
|
|
23
|
+
if (Array.isArray(t.value)) {
|
|
24
|
+
const v = [...t.value];
|
|
25
|
+
v[e] = l, t.value = v;
|
|
26
26
|
} else {
|
|
27
|
-
const
|
|
28
|
-
Object.setPrototypeOf(
|
|
27
|
+
const v = { ...t.value, [e]: l };
|
|
28
|
+
Object.setPrototypeOf(v, Object.getPrototypeOf(t.value)), t.value = v;
|
|
29
29
|
}
|
|
30
30
|
else
|
|
31
|
-
|
|
31
|
+
t.value[e] = l;
|
|
32
32
|
}
|
|
33
33
|
}));
|
|
34
|
-
return
|
|
34
|
+
return o;
|
|
35
35
|
}
|
|
36
|
-
function Se(
|
|
37
|
-
var
|
|
38
|
-
const
|
|
39
|
-
return (
|
|
36
|
+
function Se(t) {
|
|
37
|
+
var s;
|
|
38
|
+
const o = x(t);
|
|
39
|
+
return (s = o == null ? void 0 : o.$el) != null ? s : o;
|
|
40
40
|
}
|
|
41
|
-
const
|
|
42
|
-
function
|
|
43
|
-
let
|
|
44
|
-
if (typeof
|
|
45
|
-
return
|
|
46
|
-
Array.isArray(
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
},
|
|
50
|
-
() => [Se(
|
|
51
|
-
([
|
|
52
|
-
if (
|
|
41
|
+
const Q = J ? window : void 0;
|
|
42
|
+
function V(...t) {
|
|
43
|
+
let s, o, e, l;
|
|
44
|
+
if (typeof t[0] == "string" || Array.isArray(t[0]) ? ([o, e, l] = t, s = Q) : [s, o, e, l] = t, !s)
|
|
45
|
+
return Me;
|
|
46
|
+
Array.isArray(o) || (o = [o]), Array.isArray(e) || (e = [e]);
|
|
47
|
+
const r = [], u = () => {
|
|
48
|
+
r.forEach((p) => p()), r.length = 0;
|
|
49
|
+
}, v = (p, g, i, c) => (p.addEventListener(g, i, c), () => p.removeEventListener(g, i, c)), b = re(
|
|
50
|
+
() => [Se(s), x(l)],
|
|
51
|
+
([p, g]) => {
|
|
52
|
+
if (u(), !p)
|
|
53
53
|
return;
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
...
|
|
54
|
+
const i = xe(g) ? { ...g } : g;
|
|
55
|
+
r.push(
|
|
56
|
+
...o.flatMap((c) => e.map((a) => v(p, c, a, i)))
|
|
57
57
|
);
|
|
58
58
|
},
|
|
59
59
|
{ immediate: !0, flush: "post" }
|
|
60
|
-
),
|
|
61
|
-
|
|
60
|
+
), C = () => {
|
|
61
|
+
b(), u();
|
|
62
62
|
};
|
|
63
|
-
return
|
|
63
|
+
return Ce(C), C;
|
|
64
64
|
}
|
|
65
|
-
function
|
|
66
|
-
var
|
|
65
|
+
function $e(t, s = {}) {
|
|
66
|
+
var o, e;
|
|
67
67
|
const {
|
|
68
|
-
pointerTypes:
|
|
69
|
-
preventDefault:
|
|
70
|
-
stopPropagation:
|
|
71
|
-
exact:
|
|
72
|
-
onMove:
|
|
73
|
-
onEnd:
|
|
74
|
-
onStart:
|
|
75
|
-
initialValue:
|
|
76
|
-
axis:
|
|
77
|
-
draggingElement:
|
|
78
|
-
containerElement:
|
|
79
|
-
handle:
|
|
80
|
-
} =
|
|
81
|
-
(
|
|
82
|
-
), _ =
|
|
83
|
-
|
|
84
|
-
},
|
|
85
|
-
var
|
|
86
|
-
if (!
|
|
68
|
+
pointerTypes: l,
|
|
69
|
+
preventDefault: r,
|
|
70
|
+
stopPropagation: u,
|
|
71
|
+
exact: v,
|
|
72
|
+
onMove: b,
|
|
73
|
+
onEnd: C,
|
|
74
|
+
onStart: p,
|
|
75
|
+
initialValue: g,
|
|
76
|
+
axis: i = "both",
|
|
77
|
+
draggingElement: c = Q,
|
|
78
|
+
containerElement: a,
|
|
79
|
+
handle: m = t
|
|
80
|
+
} = s, f = N(
|
|
81
|
+
(o = x(g)) != null ? o : { x: 0, y: 0 }
|
|
82
|
+
), _ = N(), M = (d) => l ? l.includes(d.pointerType) : !0, L = (d) => {
|
|
83
|
+
x(r) && d.preventDefault(), x(u) && d.stopPropagation();
|
|
84
|
+
}, R = (d) => {
|
|
85
|
+
var E;
|
|
86
|
+
if (!M(d) || x(v) && d.target !== x(t))
|
|
87
87
|
return;
|
|
88
|
-
const
|
|
89
|
-
x:
|
|
90
|
-
y:
|
|
88
|
+
const P = ((E = x(a)) != null ? E : x(t)).getBoundingClientRect(), n = {
|
|
89
|
+
x: d.clientX - P.left,
|
|
90
|
+
y: d.clientY - P.top
|
|
91
91
|
};
|
|
92
|
-
(
|
|
93
|
-
},
|
|
94
|
-
if (!
|
|
92
|
+
(p == null ? void 0 : p(n, d)) !== !1 && (_.value = n, L(d));
|
|
93
|
+
}, W = (d) => {
|
|
94
|
+
if (!M(d) || !_.value)
|
|
95
95
|
return;
|
|
96
|
-
let { x:
|
|
97
|
-
(
|
|
98
|
-
x:
|
|
99
|
-
y:
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
|
|
96
|
+
let { x: E, y: A } = f.value;
|
|
97
|
+
(i === "x" || i === "both") && (E = d.clientX - _.value.x), (i === "y" || i === "both") && (A = d.clientY - _.value.y), f.value = {
|
|
98
|
+
x: E,
|
|
99
|
+
y: A
|
|
100
|
+
}, b == null || b(f.value, d), L(d);
|
|
101
|
+
}, I = (d) => {
|
|
102
|
+
M(d) && _.value && (_.value = void 0, C == null || C(f.value, d), L(d));
|
|
103
103
|
};
|
|
104
|
-
if (
|
|
105
|
-
const
|
|
106
|
-
|
|
104
|
+
if (J) {
|
|
105
|
+
const d = { capture: (e = s.capture) != null ? e : !0 };
|
|
106
|
+
V(m, "pointerdown", R, d), V(c, "pointermove", W, d), V(c, "pointerup", I, d);
|
|
107
107
|
}
|
|
108
108
|
return {
|
|
109
|
-
...
|
|
110
|
-
position:
|
|
111
|
-
isDragging:
|
|
112
|
-
style:
|
|
113
|
-
() => `left:${
|
|
109
|
+
...Ee(f),
|
|
110
|
+
position: f,
|
|
111
|
+
isDragging: S(() => !!_.value),
|
|
112
|
+
style: S(
|
|
113
|
+
() => `left:${f.value.x}px;top:${f.value.y}px;`
|
|
114
114
|
)
|
|
115
115
|
};
|
|
116
116
|
}
|
|
117
|
-
const
|
|
117
|
+
const Le = (t) => (ue("data-v-450bcc09"), t = t(), fe(), t), Ae = { class: "title font-bold" }, Pe = { class: "action" }, ze = {
|
|
118
118
|
key: 1,
|
|
119
119
|
class: "modal-footer space-x-2"
|
|
120
|
-
},
|
|
120
|
+
}, Be = ["form"], Oe = {
|
|
121
|
+
key: 2,
|
|
122
|
+
class: "modal-loading"
|
|
123
|
+
}, Te = /* @__PURE__ */ Le(() => /* @__PURE__ */ y("div", { class: "lds-ring" }, [
|
|
124
|
+
/* @__PURE__ */ y("div"),
|
|
125
|
+
/* @__PURE__ */ y("div"),
|
|
126
|
+
/* @__PURE__ */ y("div"),
|
|
127
|
+
/* @__PURE__ */ y("div")
|
|
128
|
+
], -1)), De = [
|
|
129
|
+
Te
|
|
130
|
+
], Ne = {
|
|
121
131
|
name: "ModalContainer",
|
|
122
132
|
inheritAttrs: !0
|
|
123
|
-
},
|
|
124
|
-
|
|
133
|
+
}, Fe = /* @__PURE__ */ Y({
|
|
134
|
+
...Ne,
|
|
125
135
|
props: {
|
|
126
136
|
id: {},
|
|
127
137
|
form: {},
|
|
@@ -140,137 +150,198 @@ const Me = { class: "title font-bold" }, ke = { class: "action" }, Ae = {
|
|
|
140
150
|
esc: { type: Boolean, default: !1 },
|
|
141
151
|
maskClosable: { type: Boolean, default: !1 },
|
|
142
152
|
draggable: { type: Boolean, default: !1 },
|
|
143
|
-
mode: { default: "dialog" }
|
|
153
|
+
mode: { default: "dialog" },
|
|
154
|
+
type: {}
|
|
144
155
|
},
|
|
145
156
|
emits: ["submit"],
|
|
146
|
-
setup(
|
|
147
|
-
const e = o, r =
|
|
148
|
-
let
|
|
149
|
-
const
|
|
157
|
+
setup(t, { expose: s, emit: o }) {
|
|
158
|
+
const e = t, l = o, r = K(H), u = N(!1);
|
|
159
|
+
let v = 0, b = 0;
|
|
160
|
+
const C = T(), p = T(), g = T(), { x: i, y: c } = $e(g, {
|
|
150
161
|
initialValue: { x: 0, y: 0 }
|
|
151
162
|
});
|
|
152
|
-
function
|
|
153
|
-
|
|
163
|
+
function a() {
|
|
164
|
+
r == null || r.close(e.id);
|
|
154
165
|
}
|
|
155
|
-
function
|
|
156
|
-
if (typeof
|
|
157
|
-
return `${
|
|
158
|
-
if (typeof
|
|
159
|
-
return
|
|
166
|
+
function m(n) {
|
|
167
|
+
if (typeof n == "number")
|
|
168
|
+
return `${n}px`;
|
|
169
|
+
if (typeof n == "string")
|
|
170
|
+
return n;
|
|
160
171
|
}
|
|
161
|
-
const
|
|
162
|
-
const
|
|
163
|
-
return e.mode === "dialog" && (
|
|
164
|
-
}),
|
|
165
|
-
const
|
|
166
|
-
return e.size && (
|
|
167
|
-
}),
|
|
168
|
-
const
|
|
169
|
-
return e.draggable && !e.fullscreen && e.mode === "dialog" && (
|
|
170
|
-
}),
|
|
171
|
-
var
|
|
172
|
-
const
|
|
173
|
-
return e.maxHeight && (
|
|
172
|
+
const f = S(() => {
|
|
173
|
+
const n = {};
|
|
174
|
+
return e.mode === "dialog" && (n.justifyContent = "center"), e.mode === "drawer" && (n.justifyContent = "flex-end"), n;
|
|
175
|
+
}), _ = S(() => {
|
|
176
|
+
const n = {};
|
|
177
|
+
return e.size && (n.width = m(e.sizes[e.size])), e.width && (n.width = m(e.width)), e.maxWidth && (n.maxWidth = m(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(${i.value - v}px, ${c.value - b}px, 0px)`), e.mode === "drawer" && (n.borderRadius = 0), n;
|
|
178
|
+
}), M = S(() => {
|
|
179
|
+
const n = {};
|
|
180
|
+
return e.draggable && !e.fullscreen && e.mode === "dialog" && (n.cursor = "move"), n;
|
|
181
|
+
}), L = S(() => {
|
|
182
|
+
var k;
|
|
183
|
+
const n = {};
|
|
184
|
+
return e.maxHeight && (n.maxHeight = `calc(${(k = m(e.maxHeight)) == null ? void 0 : k.replace("%", "vh")} - 50px)`), e.mode === "drawer" && (n.maxHeight = "unset", n.height = `calc(100vh - ${(e.header ? 50 : 0) + (e.footer ? 50 : 0)}px)`), e.fullscreen && (n.maxHeight = "unset", n.height = `calc(100vh - ${(e.header ? 50 : 0) + (e.footer ? 50 : 0)}px)`), e.type !== "component" && (n.padding = "0"), n;
|
|
174
185
|
});
|
|
175
|
-
function
|
|
176
|
-
const
|
|
177
|
-
if (e.form &&
|
|
178
|
-
const
|
|
179
|
-
|
|
186
|
+
function R() {
|
|
187
|
+
const n = p.value;
|
|
188
|
+
if (e.form && n) {
|
|
189
|
+
const k = n.querySelector(`form[name="${e.form}"]`);
|
|
190
|
+
k && k.dispatchEvent(new Event("submit"));
|
|
180
191
|
}
|
|
181
|
-
|
|
182
|
-
open: n == null ? void 0 : n.open,
|
|
183
|
-
close: (d) => n == null ? void 0 : n.close(e.id, d)
|
|
184
|
-
});
|
|
192
|
+
l("submit");
|
|
185
193
|
}
|
|
186
|
-
function
|
|
187
|
-
|
|
194
|
+
function W() {
|
|
195
|
+
r == null || r.close(e.id);
|
|
188
196
|
}
|
|
189
|
-
function
|
|
197
|
+
function I() {
|
|
190
198
|
window && window.addEventListener("resize", () => {
|
|
191
|
-
|
|
199
|
+
O(C), O(p), v = p.value.offsetLeft, b = p.value.offsetTop;
|
|
192
200
|
});
|
|
193
201
|
}
|
|
194
|
-
function
|
|
202
|
+
function d() {
|
|
195
203
|
if (e.closeable && e.esc) {
|
|
196
|
-
const
|
|
197
|
-
|
|
204
|
+
const n = ({ key: k }) => {
|
|
205
|
+
k === "Escape" && (r == null || r.close(e.id), window.removeEventListener("keydown", n));
|
|
198
206
|
};
|
|
199
|
-
window.addEventListener("keydown",
|
|
207
|
+
window.addEventListener("keydown", n);
|
|
200
208
|
}
|
|
201
209
|
}
|
|
202
|
-
function
|
|
203
|
-
|
|
210
|
+
function E() {
|
|
211
|
+
v = p.value.offsetLeft, b = p.value.offsetTop;
|
|
212
|
+
}
|
|
213
|
+
U(() => {
|
|
214
|
+
d(), I();
|
|
215
|
+
}), se(() => {
|
|
216
|
+
});
|
|
217
|
+
function A() {
|
|
218
|
+
return u.value = !0, () => P();
|
|
204
219
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
|
|
220
|
+
function P() {
|
|
221
|
+
u.value = !1;
|
|
222
|
+
}
|
|
223
|
+
return s({
|
|
224
|
+
showLoading: A,
|
|
225
|
+
hideLoading: P
|
|
226
|
+
}), (n, k) => (h(), w("div", {
|
|
209
227
|
ref_key: "wrapperRef",
|
|
210
|
-
ref:
|
|
228
|
+
ref: C,
|
|
211
229
|
class: "modal-wrapper",
|
|
212
|
-
style:
|
|
213
|
-
onClick:
|
|
230
|
+
style: z(f.value),
|
|
231
|
+
onClick: k[0] || (k[0] = le((je) => n.maskClosable && a(), ["self"]))
|
|
214
232
|
}, [
|
|
215
|
-
|
|
233
|
+
y("div", {
|
|
216
234
|
ref_key: "contentRef",
|
|
217
|
-
ref:
|
|
218
|
-
class:
|
|
219
|
-
style:
|
|
235
|
+
ref: p,
|
|
236
|
+
class: ae(["modal-content", { [`${n.mode}-mode`]: !0 }]),
|
|
237
|
+
style: z(_.value)
|
|
220
238
|
}, [
|
|
221
|
-
|
|
239
|
+
n.header ? (h(), w("div", {
|
|
222
240
|
key: 0,
|
|
223
241
|
ref_key: "headerRef",
|
|
224
|
-
ref:
|
|
242
|
+
ref: g,
|
|
225
243
|
class: "modal-header",
|
|
226
|
-
style:
|
|
227
|
-
onMousedown:
|
|
244
|
+
style: z(M.value),
|
|
245
|
+
onMousedown: E
|
|
228
246
|
}, [
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
247
|
+
y("div", Ae, B(n.title), 1),
|
|
248
|
+
y("div", Pe, [
|
|
249
|
+
n.closeable ? (h(), w("div", {
|
|
232
250
|
key: 0,
|
|
233
251
|
class: "i-icon-park-outline:close block cursor-pointer",
|
|
234
|
-
onClick:
|
|
252
|
+
onClick: a
|
|
235
253
|
})) : $("", !0)
|
|
236
254
|
])
|
|
237
255
|
], 36)) : $("", !0),
|
|
238
|
-
|
|
256
|
+
y("div", {
|
|
239
257
|
class: "modal-body",
|
|
240
|
-
style:
|
|
258
|
+
style: z(L.value)
|
|
241
259
|
}, [
|
|
242
|
-
(
|
|
260
|
+
(h(), F(j(n.component), de(ce(n.componentProps)), null, 16))
|
|
243
261
|
], 4),
|
|
244
|
-
|
|
245
|
-
|
|
262
|
+
n.footer ? (h(), w("div", ze, [
|
|
263
|
+
y("button", {
|
|
246
264
|
class: "submit-button",
|
|
247
|
-
form:
|
|
265
|
+
form: n.form,
|
|
248
266
|
type: "submit",
|
|
249
|
-
onClick:
|
|
250
|
-
}, " 确定 ", 8,
|
|
251
|
-
|
|
267
|
+
onClick: R
|
|
268
|
+
}, " 确定 ", 8, Be),
|
|
269
|
+
y("button", {
|
|
252
270
|
class: "cancel-button",
|
|
253
271
|
type: "button",
|
|
254
|
-
onClick:
|
|
272
|
+
onClick: W
|
|
255
273
|
}, " 取消 ")
|
|
256
|
-
])) : $("", !0)
|
|
274
|
+
])) : $("", !0),
|
|
275
|
+
u.value ? (h(), w("div", Oe, De)) : $("", !0)
|
|
257
276
|
], 6)
|
|
258
277
|
], 4));
|
|
259
278
|
}
|
|
260
279
|
});
|
|
261
|
-
const G = (
|
|
262
|
-
const
|
|
263
|
-
for (const [
|
|
264
|
-
e
|
|
265
|
-
return
|
|
266
|
-
},
|
|
280
|
+
const G = (t, s) => {
|
|
281
|
+
const o = t.__vccOpts || t;
|
|
282
|
+
for (const [e, l] of s)
|
|
283
|
+
o[e] = l;
|
|
284
|
+
return o;
|
|
285
|
+
}, He = /* @__PURE__ */ G(Fe, [["__scopeId", "data-v-450bcc09"]]), Re = { class: "modal-dialog" }, We = { class: "dialog-body" }, Ie = { class: "dialog-title" }, Ve = { class: "dialog-content" }, Xe = /* @__PURE__ */ Y({
|
|
286
|
+
__name: "modal-dialog",
|
|
287
|
+
props: {
|
|
288
|
+
type: {},
|
|
289
|
+
title: {},
|
|
290
|
+
content: {},
|
|
291
|
+
okText: { default: "确定" },
|
|
292
|
+
cancelText: { default: "取消" },
|
|
293
|
+
onOk: {},
|
|
294
|
+
onCancel: {},
|
|
295
|
+
footer: {}
|
|
296
|
+
},
|
|
297
|
+
setup(t) {
|
|
298
|
+
const s = t, o = Ue(), e = S(() => s.title ? s.title : {
|
|
299
|
+
confirm: "提示",
|
|
300
|
+
info: "提示",
|
|
301
|
+
warning: "警告",
|
|
302
|
+
error: "错误",
|
|
303
|
+
success: "成功"
|
|
304
|
+
}[s.type]);
|
|
305
|
+
async function l() {
|
|
306
|
+
s.onOk && await s.onOk(), o.close();
|
|
307
|
+
}
|
|
308
|
+
async function r() {
|
|
309
|
+
s.onCancel && await s.onCancel(), o.close();
|
|
310
|
+
}
|
|
311
|
+
return (u, v) => (h(), w("section", Re, [
|
|
312
|
+
y("div", We, [
|
|
313
|
+
y("div", Ie, B(e.value), 1),
|
|
314
|
+
y("div", Ve, B(u.content), 1)
|
|
315
|
+
]),
|
|
316
|
+
y("div", {
|
|
317
|
+
class: "dialog-footer space-x-2",
|
|
318
|
+
style: z(u.type === "confirm" ? { "justify-content": "end" } : { "border-top": "none" })
|
|
319
|
+
}, [
|
|
320
|
+
u.footer ? (h(), F(j(u.footer), { key: 0 })) : (h(), w(X, { key: 1 }, [
|
|
321
|
+
y("button", {
|
|
322
|
+
class: "submit-button",
|
|
323
|
+
type: "submit",
|
|
324
|
+
onClick: l
|
|
325
|
+
}, B(u.okText), 1),
|
|
326
|
+
u.type === "confirm" ? (h(), w("button", {
|
|
327
|
+
key: 0,
|
|
328
|
+
class: "cancel-button",
|
|
329
|
+
type: "button",
|
|
330
|
+
onClick: r
|
|
331
|
+
}, B(u.cancelText), 1)) : $("", !0)
|
|
332
|
+
], 64))
|
|
333
|
+
], 4)
|
|
334
|
+
]));
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
const Ye = /* @__PURE__ */ G(Xe, [["__scopeId", "data-v-8326e5a5"]]), Ke = {
|
|
267
338
|
key: 0,
|
|
268
339
|
class: "modal-teleport"
|
|
269
|
-
},
|
|
340
|
+
}, qe = {
|
|
270
341
|
name: "ModalProvider",
|
|
271
342
|
inheritAttrs: !0
|
|
272
|
-
},
|
|
273
|
-
...
|
|
343
|
+
}, Ge = /* @__PURE__ */ Y({
|
|
344
|
+
...qe,
|
|
274
345
|
props: {
|
|
275
346
|
appendToBody: { type: [Boolean, String], default: !1 },
|
|
276
347
|
sizes: { default: () => ({
|
|
@@ -281,71 +352,106 @@ const G = (o, i) => {
|
|
|
281
352
|
maxWidth: { default: "80%" },
|
|
282
353
|
maxHeight: { default: "80%" }
|
|
283
354
|
},
|
|
284
|
-
setup(
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
-
const
|
|
288
|
-
() => Promise.resolve(
|
|
355
|
+
setup(t, { expose: s }) {
|
|
356
|
+
const o = T([]), e = N(!1), l = q();
|
|
357
|
+
function r(i, c = {}, a = {}) {
|
|
358
|
+
const m = be(
|
|
359
|
+
() => Promise.resolve(typeof i == "string" ? Ye : i)
|
|
289
360
|
);
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
361
|
+
typeof i == "string" && (c.type = i, a.size = "small", a.fullscreen = !1, a.mode = "dialog", a.footer = !1, a.header = !1);
|
|
362
|
+
const f = Math.random().toString(32).slice(2), _ = new Promise((M) => {
|
|
363
|
+
o.value.push({
|
|
364
|
+
id: f,
|
|
365
|
+
component: m,
|
|
366
|
+
props: c || {},
|
|
367
|
+
options: {
|
|
368
|
+
...a,
|
|
369
|
+
type: typeof i == "string" ? i : "component"
|
|
370
|
+
},
|
|
371
|
+
resolve: M,
|
|
372
|
+
listeners: []
|
|
373
|
+
}), O(o);
|
|
374
|
+
});
|
|
375
|
+
return Object.assign(_, {
|
|
376
|
+
close: () => u(f)
|
|
299
377
|
});
|
|
300
378
|
}
|
|
301
|
-
function u(
|
|
302
|
-
const
|
|
303
|
-
if (
|
|
379
|
+
function u(i, c) {
|
|
380
|
+
const a = o.value.findIndex((f) => f.id === i);
|
|
381
|
+
if (a < 0)
|
|
304
382
|
return;
|
|
305
|
-
const
|
|
306
|
-
|
|
383
|
+
const m = o.value[a];
|
|
384
|
+
m == null || m.resolve(c), o.value.splice(a, 1), O(o);
|
|
307
385
|
}
|
|
308
386
|
function v() {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
}),
|
|
387
|
+
o.value.forEach((i) => {
|
|
388
|
+
i.resolve();
|
|
389
|
+
}), o.value = [], O(o);
|
|
312
390
|
}
|
|
313
|
-
function
|
|
314
|
-
|
|
391
|
+
function b(i, c) {
|
|
392
|
+
const a = o.value.find((f) => f.id === i);
|
|
393
|
+
if (!a)
|
|
394
|
+
return;
|
|
395
|
+
const m = a.listeners.find((f) => f.event === c);
|
|
396
|
+
m && m.callback({
|
|
397
|
+
open: r,
|
|
398
|
+
close: () => u(a.id),
|
|
399
|
+
closeAll: v,
|
|
400
|
+
showLoading: () => C(a.id),
|
|
401
|
+
hideLoading: () => p(a.id)
|
|
402
|
+
});
|
|
315
403
|
}
|
|
316
|
-
function
|
|
317
|
-
|
|
318
|
-
|
|
404
|
+
function C(i) {
|
|
405
|
+
if (!l)
|
|
406
|
+
return;
|
|
407
|
+
const [c] = l.refs[`modal-container_${i}`];
|
|
408
|
+
if (c)
|
|
409
|
+
return c.showLoading();
|
|
319
410
|
}
|
|
320
|
-
|
|
321
|
-
|
|
411
|
+
function p(i) {
|
|
412
|
+
if (!l)
|
|
413
|
+
return;
|
|
414
|
+
const [c] = l.refs[`modal-container_${i}`];
|
|
415
|
+
if (c)
|
|
416
|
+
return c.hideLoading();
|
|
417
|
+
}
|
|
418
|
+
function g(i, c, a) {
|
|
419
|
+
const m = o.value.find((f) => f.id === i);
|
|
420
|
+
m && m.listeners.push({
|
|
421
|
+
event: c,
|
|
422
|
+
callback: a
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
return pe(H, {
|
|
426
|
+
open: r,
|
|
322
427
|
close: u,
|
|
323
428
|
closeAll: v,
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
to: typeof l.appendToBody == "string" ? l.appendToBody : "body"
|
|
429
|
+
addEventListener: g
|
|
430
|
+
}), s({
|
|
431
|
+
elements: o
|
|
432
|
+
}), U(() => {
|
|
433
|
+
e.value = !0;
|
|
434
|
+
}), (i, c) => (h(), w(X, null, [
|
|
435
|
+
me(i.$slots, "default", {}, void 0, !0),
|
|
436
|
+
e.value ? (h(), w("div", Ke, [
|
|
437
|
+
(h(), F(ve, {
|
|
438
|
+
disabled: !i.appendToBody,
|
|
439
|
+
to: typeof i.appendToBody == "string" ? i.appendToBody : "body"
|
|
336
440
|
}, [
|
|
337
|
-
|
|
338
|
-
default:
|
|
339
|
-
(
|
|
340
|
-
id:
|
|
341
|
-
key:
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
"
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
441
|
+
ye(he, { name: "modal-fade" }, {
|
|
442
|
+
default: ge(() => [
|
|
443
|
+
(h(!0), w(X, null, _e(o.value, (a) => (h(), F(He, we({
|
|
444
|
+
id: a.id,
|
|
445
|
+
key: a.id,
|
|
446
|
+
ref_for: !0,
|
|
447
|
+
ref: `modal-container_${a.id}`,
|
|
448
|
+
component: a.component,
|
|
449
|
+
"component-props": a.props,
|
|
450
|
+
"max-height": i.maxHeight,
|
|
451
|
+
"max-width": i.maxWidth,
|
|
452
|
+
sizes: i.sizes
|
|
453
|
+
}, a.options, {
|
|
454
|
+
onSubmit: () => b(a.id, "submit")
|
|
349
455
|
}), null, 16, ["id", "component", "component-props", "max-height", "max-width", "sizes", "onSubmit"]))), 128))
|
|
350
456
|
]),
|
|
351
457
|
_: 1
|
|
@@ -355,47 +461,66 @@ const G = (o, i) => {
|
|
|
355
461
|
], 64));
|
|
356
462
|
}
|
|
357
463
|
});
|
|
358
|
-
const
|
|
359
|
-
function
|
|
360
|
-
var
|
|
361
|
-
let
|
|
362
|
-
for (;
|
|
363
|
-
|
|
364
|
-
return ((
|
|
464
|
+
const Qe = /* @__PURE__ */ G(Ge, [["__scopeId", "data-v-09133e47"]]);
|
|
465
|
+
function D(t, s) {
|
|
466
|
+
var e, l;
|
|
467
|
+
let o = t == null ? void 0 : t.parent;
|
|
468
|
+
for (; o && ((e = o == null ? void 0 : o.type) == null ? void 0 : e.name) !== s; )
|
|
469
|
+
o = o.parent;
|
|
470
|
+
return ((l = o == null ? void 0 : o.type) == null ? void 0 : l.name) === s ? o : null;
|
|
365
471
|
}
|
|
366
|
-
function
|
|
367
|
-
const
|
|
472
|
+
function Ue() {
|
|
473
|
+
const t = K(H), s = q();
|
|
474
|
+
function o(e, l, r) {
|
|
475
|
+
if (!t)
|
|
476
|
+
throw new Error("Not Found Modal Provider Component");
|
|
477
|
+
return t.open(e, l, r);
|
|
478
|
+
}
|
|
368
479
|
return {
|
|
369
|
-
open
|
|
370
|
-
if (!o)
|
|
371
|
-
throw new Error("Not Found Modal Provider Component");
|
|
372
|
-
return o.open(e, r || {}, n || {});
|
|
373
|
-
},
|
|
480
|
+
open: o,
|
|
374
481
|
close(e) {
|
|
375
482
|
var u;
|
|
376
|
-
if (!
|
|
483
|
+
if (!t)
|
|
377
484
|
throw new Error("Not Found Modal Provider Component");
|
|
378
|
-
const
|
|
379
|
-
if (!
|
|
485
|
+
const l = D(s, "ModalContainer"), r = (u = l == null ? void 0 : l.props) == null ? void 0 : u.id;
|
|
486
|
+
if (!r)
|
|
380
487
|
throw new Error("Not Found Current Modal Container");
|
|
381
|
-
|
|
488
|
+
t.close(r, e);
|
|
382
489
|
},
|
|
383
490
|
closeAll() {
|
|
384
|
-
if (!
|
|
491
|
+
if (!t)
|
|
492
|
+
throw new Error("Not Found Modal Provider Component");
|
|
493
|
+
t.closeAll();
|
|
494
|
+
},
|
|
495
|
+
showLoading() {
|
|
496
|
+
var r;
|
|
497
|
+
if (!t)
|
|
385
498
|
throw new Error("Not Found Modal Provider Component");
|
|
386
|
-
|
|
499
|
+
const e = D(s, "ModalContainer");
|
|
500
|
+
if (!((r = e == null ? void 0 : e.props) == null ? void 0 : r.id))
|
|
501
|
+
throw new Error("Not Found Current Modal Container");
|
|
502
|
+
e != null && e.exposed && (e == null || e.exposed.showLoading());
|
|
503
|
+
},
|
|
504
|
+
hideLoading() {
|
|
505
|
+
var r;
|
|
506
|
+
if (!t)
|
|
507
|
+
throw new Error("Not Found Modal Provider Component");
|
|
508
|
+
const e = D(s, "ModalContainer");
|
|
509
|
+
if (!((r = e == null ? void 0 : e.props) == null ? void 0 : r.id))
|
|
510
|
+
throw new Error("Not Found Current Modal Container");
|
|
511
|
+
e != null && e.exposed && (e == null || e.exposed.hideLoading());
|
|
387
512
|
}
|
|
388
513
|
};
|
|
389
514
|
}
|
|
390
|
-
function
|
|
391
|
-
var
|
|
392
|
-
const
|
|
393
|
-
|
|
515
|
+
function Ze(t) {
|
|
516
|
+
var r;
|
|
517
|
+
const s = K(H), o = q(), e = D(o, "ModalContainer"), l = (r = e == null ? void 0 : e.props) == null ? void 0 : r.id;
|
|
518
|
+
s && l && s.addEventListener(l, "submit", t);
|
|
394
519
|
}
|
|
395
520
|
export {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
521
|
+
He as ModalContainer,
|
|
522
|
+
H as ModalKey,
|
|
523
|
+
Qe as ModalProvider,
|
|
524
|
+
Ze as onSubmit,
|
|
525
|
+
Ue as useModal
|
|
401
526
|
};
|
package/dist/es/interfaces.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Component
|
|
1
|
+
import type { Component } from 'vue';
|
|
2
2
|
import type { useModal } from './hooks/use-modal';
|
|
3
3
|
export interface SizeOptions {
|
|
4
4
|
small: number;
|
|
@@ -25,13 +25,19 @@ export interface ModalElement extends OpenModalOptions {
|
|
|
25
25
|
resolve: (data?: any) => void;
|
|
26
26
|
component: Component;
|
|
27
27
|
props: Record<string, any>;
|
|
28
|
-
options: OpenModalOptions
|
|
29
|
-
|
|
28
|
+
options: OpenModalOptions & {
|
|
29
|
+
type?: string;
|
|
30
|
+
};
|
|
31
|
+
listeners: {
|
|
32
|
+
event: string;
|
|
33
|
+
callback: (actions: ReturnType<typeof useModal>) => void;
|
|
34
|
+
}[];
|
|
30
35
|
}
|
|
31
36
|
export interface ModalActions {
|
|
32
|
-
open: (component: Component, props
|
|
37
|
+
open: (component: Component | 'confirm' | 'info' | 'warning' | 'error' | 'sucess', props?: Record<string, any>, options?: OpenModalOptions) => Promise<any> & {
|
|
38
|
+
close: () => void;
|
|
39
|
+
};
|
|
33
40
|
close: (id: string, data?: any) => void;
|
|
34
41
|
closeAll: () => void;
|
|
35
|
-
|
|
36
|
-
addSubmitListener: (id: string, fun: (modal: ReturnType<typeof useModal>) => void) => void;
|
|
42
|
+
addEventListener: (id: string, event: 'submit', callback: (modal: ReturnType<typeof useModal>) => void) => void;
|
|
37
43
|
}
|
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}.fixed{position:fixed}.block{display: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))}.px{padding-left:1rem;padding-right:1rem}.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}.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-450bcc09]{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-450bcc09]{background:#ffffff;border-radius:5px;position:relative}.modal-header[data-v-450bcc09]{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)}.modal-body[data-v-450bcc09]{padding:20px 10px;box-sizing:border-box;max-height:10vw;overflow:auto}.modal-footer[data-v-450bcc09]{box-sizing:border-box;height:50px;border-top:solid 1px var(--color-border-1, #e8e8e8);display:flex;justify-content:end;padding:10px}.modal-footer button[data-v-450bcc09]{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-450bcc09]{color:#fff;background-color:rgb(var(--primary-6, 45, 106, 251))}.modal-footer button.submit-button[data-v-450bcc09]:hover{background-color:rgb(var(--primary-5, 28, 76, 207))}.modal-footer button.cancel-button[data-v-450bcc09]{color:rgb(var(--color-text-2, 78, 89, 105));background-color:var(--color-fill-1, #f5f5f5)}.modal-footer button.cancel-button[data-v-450bcc09]:hover{background-color:var(--color-fill-4, #c9cdd4)}.modal-loading[data-v-450bcc09]{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-450bcc09]{display:inline-block;position:relative;width:80px;height:80px}.modal-loading .lds-ring div[data-v-450bcc09]{box-sizing:border-box;display:block;position:absolute;width:48px;height:48px;margin:8px;border:5px solid #fff;border-radius:50%;animation:lds-ring-450bcc09 1.2s cubic-bezier(.5,0,.5,1) infinite;border-color:#fff transparent transparent transparent}.modal-loading .lds-ring div[data-v-450bcc09]:nth-child(1){animation-delay:-.45s}.modal-loading .lds-ring div[data-v-450bcc09]:nth-child(2){animation-delay:-.3s}.modal-loading .lds-ring div[data-v-450bcc09]:nth-child(3){animation-delay:-.15s}@keyframes lds-ring-450bcc09{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-09133e47],.modal-fade-leave-active[data-v-09133e47]{transition:opacity .5s ease}.modal-fade-enter-active[data-v-09133e47] .modal-content.drawer-mode,.modal-fade-leave-active[data-v-09133e47] .modal-content.drawer-mode{transition:transform .5s ease}.modal-fade-enter-from[data-v-09133e47],.modal-fade-leave-to[data-v-09133e47]{opacity:0}.modal-fade-enter-from[data-v-09133e47] .modal-content.drawer-mode,.modal-fade-leave-to[data-v-09133e47] .modal-content.drawer-mode{transform:translate3d(100%,0,0)}
|