@gopowerteam/modal-render 0.0.46 → 0.0.47
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 +60 -60
- package/dist/cjs/components/modal-dialog.vue.d.ts +14 -14
- package/dist/cjs/components/modal-footer.vue.d.ts +4 -2
- package/dist/cjs/components/modal-header.vue.d.ts +4 -2
- package/dist/cjs/components/modal-loading.vue.d.ts +2 -2
- package/dist/cjs/components/modal-provider.vue.d.ts +8 -8
- package/dist/cjs/constants.d.ts +1 -1
- package/dist/cjs/hooks/use-modal.d.ts +3 -3
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.d.ts +5 -5
- package/dist/cjs/interfaces.d.ts +1 -1
- package/dist/es/components/modal-container.vue.d.ts +60 -60
- package/dist/es/components/modal-dialog.vue.d.ts +14 -14
- package/dist/es/components/modal-footer.vue.d.ts +4 -2
- package/dist/es/components/modal-header.vue.d.ts +4 -2
- package/dist/es/components/modal-loading.vue.d.ts +2 -2
- package/dist/es/components/modal-provider.vue.d.ts +8 -8
- package/dist/es/constants.d.ts +1 -1
- package/dist/es/hooks/use-modal.d.ts +3 -3
- package/dist/es/index.d.ts +5 -5
- package/dist/es/index.mjs +113 -113
- package/dist/es/interfaces.d.ts +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { SizeOptions } from '../interfaces';
|
|
2
1
|
import { CSSProperties, Component } from 'vue';
|
|
2
|
+
import { SizeOptions } from '../interfaces';
|
|
3
3
|
|
|
4
4
|
declare const _default: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
5
5
|
id: string;
|
|
6
|
-
form?: string
|
|
6
|
+
form?: string;
|
|
7
7
|
component: Component;
|
|
8
8
|
componentProps: Record<string, any>;
|
|
9
|
-
width?:
|
|
10
|
-
height?:
|
|
11
|
-
maxWidth?:
|
|
12
|
-
maxHeight?:
|
|
9
|
+
width?: number | string;
|
|
10
|
+
height?: number | string;
|
|
11
|
+
maxWidth?: number | string;
|
|
12
|
+
maxHeight?: number | string;
|
|
13
13
|
sizes: SizeOptions;
|
|
14
|
-
size:
|
|
15
|
-
fullscreen?: boolean
|
|
16
|
-
title?: string
|
|
17
|
-
header?: boolean
|
|
18
|
-
footer?: boolean
|
|
19
|
-
closeable?: boolean
|
|
20
|
-
esc?: boolean
|
|
21
|
-
maskClosable?: boolean
|
|
22
|
-
draggable?: boolean
|
|
23
|
-
mode?: "dialog" | "drawer"
|
|
24
|
-
position?: "
|
|
25
|
-
type?: string
|
|
14
|
+
size: "small" | "middle" | "large";
|
|
15
|
+
fullscreen?: boolean;
|
|
16
|
+
title?: string;
|
|
17
|
+
header?: boolean;
|
|
18
|
+
footer?: boolean;
|
|
19
|
+
closeable?: boolean;
|
|
20
|
+
esc?: boolean;
|
|
21
|
+
maskClosable?: boolean;
|
|
22
|
+
draggable?: boolean;
|
|
23
|
+
mode?: "dialog" | "drawer";
|
|
24
|
+
position?: "left" | "right" | "bottom" | "top";
|
|
25
|
+
type?: string;
|
|
26
26
|
offset?: {
|
|
27
|
-
x?: number
|
|
28
|
-
y?: number
|
|
29
|
-
}
|
|
30
|
-
backgroundColor?: string
|
|
31
|
-
bodyStyle?: CSSProperties
|
|
32
|
-
submitText?: string
|
|
33
|
-
cancelText?: string
|
|
34
|
-
zIndex?: number
|
|
35
|
-
onOk?: (
|
|
27
|
+
x?: number;
|
|
28
|
+
y?: number;
|
|
29
|
+
};
|
|
30
|
+
backgroundColor?: string;
|
|
31
|
+
bodyStyle?: CSSProperties;
|
|
32
|
+
submitText?: string;
|
|
33
|
+
cancelText?: string;
|
|
34
|
+
zIndex?: number;
|
|
35
|
+
onOk?: (options: {
|
|
36
36
|
close: () => void;
|
|
37
|
-
}) => void
|
|
38
|
-
onCancel?: (
|
|
37
|
+
}) => void;
|
|
38
|
+
onCancel?: () => void;
|
|
39
39
|
}>, {
|
|
40
40
|
header: boolean;
|
|
41
41
|
closeable: boolean;
|
|
@@ -58,39 +58,39 @@ declare const _default: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
58
58
|
submit: (...args: any[]) => void;
|
|
59
59
|
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
60
60
|
id: string;
|
|
61
|
-
form?: string
|
|
61
|
+
form?: string;
|
|
62
62
|
component: Component;
|
|
63
63
|
componentProps: Record<string, any>;
|
|
64
|
-
width?:
|
|
65
|
-
height?:
|
|
66
|
-
maxWidth?:
|
|
67
|
-
maxHeight?:
|
|
64
|
+
width?: number | string;
|
|
65
|
+
height?: number | string;
|
|
66
|
+
maxWidth?: number | string;
|
|
67
|
+
maxHeight?: number | string;
|
|
68
68
|
sizes: SizeOptions;
|
|
69
|
-
size:
|
|
70
|
-
fullscreen?: boolean
|
|
71
|
-
title?: string
|
|
72
|
-
header?: boolean
|
|
73
|
-
footer?: boolean
|
|
74
|
-
closeable?: boolean
|
|
75
|
-
esc?: boolean
|
|
76
|
-
maskClosable?: boolean
|
|
77
|
-
draggable?: boolean
|
|
78
|
-
mode?: "dialog" | "drawer"
|
|
79
|
-
position?: "
|
|
80
|
-
type?: string
|
|
69
|
+
size: "small" | "middle" | "large";
|
|
70
|
+
fullscreen?: boolean;
|
|
71
|
+
title?: string;
|
|
72
|
+
header?: boolean;
|
|
73
|
+
footer?: boolean;
|
|
74
|
+
closeable?: boolean;
|
|
75
|
+
esc?: boolean;
|
|
76
|
+
maskClosable?: boolean;
|
|
77
|
+
draggable?: boolean;
|
|
78
|
+
mode?: "dialog" | "drawer";
|
|
79
|
+
position?: "left" | "right" | "bottom" | "top";
|
|
80
|
+
type?: string;
|
|
81
81
|
offset?: {
|
|
82
|
-
x?: number
|
|
83
|
-
y?: number
|
|
84
|
-
}
|
|
85
|
-
backgroundColor?: string
|
|
86
|
-
bodyStyle?: CSSProperties
|
|
87
|
-
submitText?: string
|
|
88
|
-
cancelText?: string
|
|
89
|
-
zIndex?: number
|
|
90
|
-
onOk?: (
|
|
82
|
+
x?: number;
|
|
83
|
+
y?: number;
|
|
84
|
+
};
|
|
85
|
+
backgroundColor?: string;
|
|
86
|
+
bodyStyle?: CSSProperties;
|
|
87
|
+
submitText?: string;
|
|
88
|
+
cancelText?: string;
|
|
89
|
+
zIndex?: number;
|
|
90
|
+
onOk?: (options: {
|
|
91
91
|
close: () => void;
|
|
92
|
-
}) => void
|
|
93
|
-
onCancel?: (
|
|
92
|
+
}) => void;
|
|
93
|
+
onCancel?: () => void;
|
|
94
94
|
}>, {
|
|
95
95
|
header: boolean;
|
|
96
96
|
closeable: boolean;
|
|
@@ -109,7 +109,7 @@ declare const _default: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
109
109
|
}>>> & {
|
|
110
110
|
onSubmit?: ((...args: any[]) => any) | undefined;
|
|
111
111
|
}, {
|
|
112
|
-
size:
|
|
112
|
+
size: "small" | "middle" | "large";
|
|
113
113
|
maxHeight: number | string;
|
|
114
114
|
header: boolean;
|
|
115
115
|
footer: boolean;
|
|
@@ -117,8 +117,8 @@ declare const _default: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
117
117
|
esc: boolean;
|
|
118
118
|
maskClosable: boolean;
|
|
119
119
|
draggable: boolean;
|
|
120
|
-
mode:
|
|
121
|
-
position:
|
|
120
|
+
mode: "dialog" | "drawer";
|
|
121
|
+
position: "left" | "right" | "bottom" | "top";
|
|
122
122
|
submitText: string;
|
|
123
123
|
cancelText: string;
|
|
124
124
|
zIndex: number;
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
declare const _default: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
2
|
-
type:
|
|
3
|
-
title?: string
|
|
2
|
+
type: "confirm" | "success" | "error" | "warning" | "info";
|
|
3
|
+
title?: string;
|
|
4
4
|
content: string;
|
|
5
|
-
okText?: string
|
|
6
|
-
cancelText?: string
|
|
7
|
-
onOk?: (
|
|
8
|
-
onCancel?: (
|
|
9
|
-
footer?: (
|
|
5
|
+
okText?: string;
|
|
6
|
+
cancelText?: string;
|
|
7
|
+
onOk?: () => Promise<void> | void;
|
|
8
|
+
onCancel?: () => Promise<void> | void;
|
|
9
|
+
footer?: () => JSX.Element;
|
|
10
10
|
}>, {
|
|
11
11
|
okText: string;
|
|
12
12
|
cancelText: string;
|
|
13
13
|
}>, {}, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
14
|
-
type:
|
|
15
|
-
title?: string
|
|
14
|
+
type: "confirm" | "success" | "error" | "warning" | "info";
|
|
15
|
+
title?: string;
|
|
16
16
|
content: string;
|
|
17
|
-
okText?: string
|
|
18
|
-
cancelText?: string
|
|
19
|
-
onOk?: (
|
|
20
|
-
onCancel?: (
|
|
21
|
-
footer?: (
|
|
17
|
+
okText?: string;
|
|
18
|
+
cancelText?: string;
|
|
19
|
+
onOk?: () => Promise<void> | void;
|
|
20
|
+
onCancel?: () => Promise<void> | void;
|
|
21
|
+
footer?: () => JSX.Element;
|
|
22
22
|
}>, {
|
|
23
23
|
okText: string;
|
|
24
24
|
cancelText: string;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
declare
|
|
1
|
+
declare function __VLS_template(): {
|
|
2
2
|
default?(_: {}): any;
|
|
3
|
-
}
|
|
3
|
+
};
|
|
4
|
+
declare const __VLS_component: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{}>>, {}, {}>;
|
|
5
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
|
|
4
6
|
export default _default;
|
|
5
7
|
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
6
8
|
new (): {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
declare
|
|
1
|
+
declare function __VLS_template(): {
|
|
2
2
|
default?(_: {}): any;
|
|
3
|
-
}
|
|
3
|
+
};
|
|
4
|
+
declare const __VLS_component: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{}>>, {}, {}>;
|
|
5
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
|
|
4
6
|
export default _default;
|
|
5
7
|
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
6
8
|
new (): {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
declare const _default: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
2
|
-
text?: string
|
|
2
|
+
text?: string;
|
|
3
3
|
}>, {
|
|
4
4
|
text: string;
|
|
5
5
|
}>, {}, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
6
|
-
text?: string
|
|
6
|
+
text?: string;
|
|
7
7
|
}>, {
|
|
8
8
|
text: string;
|
|
9
9
|
}>>>, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ModalElement, OpenModalOptions, SizeOptions } from '../interfaces';
|
|
2
1
|
import { Component } from 'vue';
|
|
2
|
+
import { ModalElement, OpenModalOptions, SizeOptions } from '../interfaces';
|
|
3
3
|
|
|
4
4
|
declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
5
5
|
appendToBody: boolean | string;
|
|
@@ -7,9 +7,9 @@ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<__
|
|
|
7
7
|
maxWidth: string | number;
|
|
8
8
|
maxHeight: string | number;
|
|
9
9
|
offset?: {
|
|
10
|
-
x?: number
|
|
11
|
-
y?: number
|
|
12
|
-
}
|
|
10
|
+
x?: number;
|
|
11
|
+
y?: number;
|
|
12
|
+
};
|
|
13
13
|
}>, {
|
|
14
14
|
appendToBody: boolean;
|
|
15
15
|
maxWidth: string;
|
|
@@ -25,7 +25,7 @@ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<__
|
|
|
25
25
|
};
|
|
26
26
|
}>, {
|
|
27
27
|
elements: import('vue').ShallowRef<ModalElement[]>;
|
|
28
|
-
open: (component: Component |
|
|
28
|
+
open: (component: Component | "confirm" | "info" | "warning" | "error" | "success", props?: Record<string, any>, options?: OpenModalOptions) => Promise<unknown> & {
|
|
29
29
|
close: () => void;
|
|
30
30
|
};
|
|
31
31
|
close: (id: string, data?: any) => void;
|
|
@@ -36,9 +36,9 @@ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<__
|
|
|
36
36
|
maxWidth: string | number;
|
|
37
37
|
maxHeight: string | number;
|
|
38
38
|
offset?: {
|
|
39
|
-
x?: number
|
|
40
|
-
y?: number
|
|
41
|
-
}
|
|
39
|
+
x?: number;
|
|
40
|
+
y?: number;
|
|
41
|
+
};
|
|
42
42
|
}>, {
|
|
43
43
|
appendToBody: boolean;
|
|
44
44
|
maxWidth: string;
|
package/dist/cjs/constants.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { OpenModalOptions, ShowLoadingOptions } from '../interfaces';
|
|
2
1
|
import { Component } from 'vue';
|
|
2
|
+
import { OpenModalOptions, ShowLoadingOptions } from '../interfaces';
|
|
3
3
|
|
|
4
4
|
export declare function useModal(): {
|
|
5
5
|
open: {
|
|
6
|
-
(component:
|
|
6
|
+
(component: "confirm", props: {
|
|
7
7
|
title?: string;
|
|
8
8
|
content: string;
|
|
9
9
|
onOk?: () => Promise<void> | void;
|
|
@@ -12,7 +12,7 @@ export declare function useModal(): {
|
|
|
12
12
|
}): Promise<any> & {
|
|
13
13
|
close: () => void;
|
|
14
14
|
};
|
|
15
|
-
(component:
|
|
15
|
+
(component: "info" | "warning" | "error" | "success", props: {
|
|
16
16
|
title?: string;
|
|
17
17
|
content: string;
|
|
18
18
|
}): Promise<any> & {
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),L=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 F=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){return e.getCurrentInstance()}function te(o,l={}){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=b(l.replaceRef))!=null?i:!0)if(Array.isArray(o.value)){const h=[...o.value];h[t]=a,o.value=h}else{const h={...o.value,[t]:a};Object.setPrototypeOf(h,Object.getPrototypeOf(o.value)),o.value=h}else o.value[t]=a}}));return n}function oe(o,l=!0,n){ee()?e.onMounted(o,n):l?o():e.nextTick(o)}function N(o){var l;const n=b(o);return(l=n==null?void 0:n.$el)!=null?l:n}const z=F?window:void 0;function P(...o){let l,n,t,a;if(typeof o[0]=="string"||Array.isArray(o[0])?([n,t,a]=o,l=z):[l,n,t,a]=o,!l)return Z;Array.isArray(n)||(n=[n]),Array.isArray(t)||(t=[t]);const i=[],u=()=>{i.forEach(v=>v()),i.length=0},h=(v,f,s,d)=>(v.addEventListener(f,s,d),()=>v.removeEventListener(f,s,d)),w=e.watch(()=>[N(l),b(a)],([v,f])=>{if(u(),!v)return;const s=Q(f)?{...f}:f;i.push(...n.flatMap(d=>t.map(c=>h(v,d,c,s))))},{immediate:!0,flush:"post"}),y=()=>{w(),u()};return W(y),y}function ne(){const o=e.ref(!1),l=e.getCurrentInstance();return l&&e.onMounted(()=>{o.value=!0},l),o}function re(o){const l=ne();return e.computed(()=>(l.value,!!o()))}function le(o,l={}){var n,t;const{pointerTypes:a,preventDefault:i,stopPropagation:u,exact:h,onMove:w,onEnd:y,onStart:v,initialValue:f,axis:s="both",draggingElement:d=z,containerElement:c,handle:g=o}=l,p=e.ref((n=b(f))!=null?n:{x:0,y:0}),_=e.ref(),M=m=>a?a.includes(m.pointerType):!0,x=m=>{b(i)&&m.preventDefault(),b(u)&&m.stopPropagation()},$=m=>{var S;if(b(l.disabled)||!M(m)||b(h)&&m.target!==b(o))return;const k=b(c),B=(S=k==null?void 0:k.getBoundingClientRect)==null?void 0:S.call(k),C=b(o).getBoundingClientRect(),O={x:m.clientX-(k?C.left-B.left+k.scrollLeft:C.left),y:m.clientY-(k?C.top-B.top+k.scrollTop:C.top)};(v==null?void 0:v(O,m))!==!1&&(_.value=O,x(m))},H=m=>{if(b(l.disabled)||!M(m)||!_.value)return;const S=b(c),k=b(o).getBoundingClientRect();let{x:B,y:C}=p.value;(s==="x"||s==="both")&&(B=m.clientX-_.value.x,S&&(B=Math.min(Math.max(0,B),S.scrollWidth-k.width))),(s==="y"||s==="both")&&(C=m.clientY-_.value.y,S&&(C=Math.min(Math.max(0,C),S.scrollHeight-k.height))),p.value={x:B,y:C},w==null||w(p.value,m),x(m)},A=m=>{b(l.disabled)||!M(m)||_.value&&(_.value=void 0,y==null||y(p.value,m),x(m))};if(F){const m={capture:(t=l.capture)!=null?t:!0};P(g,"pointerdown",$,m),P(d,"pointermove",H,m),P(d,"pointerup",A,m)}return{...te(p),position:p,isDragging:e.computed(()=>!!_.value),style:e.computed(()=>`left:${p.value.x}px;top:${p.value.y}px;`)}}function ie(o,l,n={}){const{window:t=z,...a}=n;let i;const u=re(()=>t&&"ResizeObserver"in t),h=()=>{i&&(i.disconnect(),i=void 0)},w=e.computed(()=>Array.isArray(o)?o.map(f=>N(f)):[N(o)]),y=e.watch(w,f=>{if(h(),u.value&&t){i=new ResizeObserver(l);for(const s of f)s&&i.observe(s,a)}},{immediate:!0,flush:"post"}),v=()=>{h(),y()};return W(v),{isSupported:u,stop:v}}function R(o,l={width:0,height:0},n={}){const{window:t=z,box:a="content-box"}=n,i=e.computed(()=>{var f,s;return(s=(f=N(o))==null?void 0:f.namespaceURI)==null?void 0:s.includes("svg")}),u=e.ref(l.width),h=e.ref(l.height),{stop:w}=ie(o,([f])=>{const s=a==="border-box"?f.borderBoxSize:a==="content-box"?f.contentBoxSize:f.devicePixelContentBoxSize;if(t&&i.value){const d=N(o);if(d){const c=t.getComputedStyle(d);u.value=Number.parseFloat(c.width),h.value=Number.parseFloat(c.height)}}else if(s){const d=Array.isArray(s)?s:[s];u.value=d.reduce((c,{inlineSize:g})=>c+g,0),h.value=d.reduce((c,{blockSize:g})=>c+g,0)}else u.value=f.contentRect.width,h.value=f.contentRect.height},n);oe(()=>{const f=N(o);f&&(u.value="offsetWidth"in f?f.offsetWidth:l.width,h.value="offsetHeight"in f?f.offsetHeight:l.height)});const y=e.watch(()=>N(o),f=>{u.value=f?l.width:0,h.value=f?l.height:0});function v(){w(),y()}return{width:u,height:h,stop:v}}const se=o=>(e.pushScopeId("data-v-bd04f7a9"),o=o(),e.popScopeId(),o),ae={class:"title text-16px font-bold"},ce={class:"action"},de=["form"],ue={key:2,class:"modal-loading"},fe=se(()=>e.createElementVNode("div",{class:"lds-ring"},[e.createElementVNode("div"),e.createElementVNode("div"),e.createElementVNode("div"),e.createElementVNode("div")],-1)),pe=[fe],me={name:"ModalContainer",inheritAttrs:!1},he=e.defineComponent({...me,props:{id:{},form:{},component:{},componentProps:{},width:{},height:{},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"},position:{default:"right"},type:{},offset:{},backgroundColor:{},bodyStyle:{},submitText:{default:"确定"},cancelText:{default:"取消"},zIndex:{default:1e3},onOk:{},onCancel:{}},emits:["submit"],setup(o,{expose:l,emit:n}){e.useCssVars(r=>({"567c01bd":r.zIndex}));const t=o,a=n,i=e.inject(L),u=e.ref(!1);let h=0,w=0;const y=e.shallowRef(),v=e.shallowRef(),f=e.shallowRef(),s=e.shallowRef(),d=e.shallowRef(),c=e.shallowRef(),{height:g}=R(y),{height:p}=R(f,void 0,{box:"border-box"}),{height:_}=R(s,void 0,{box:"border-box"}),{height:M}=R(d),{height:x}=R(c),{x:$,y:H}=le(f,{initialValue:{x:0,y:0}});function A(){i==null||i.close(t.id)}function m(r){return typeof r=="number"?`${r}px`:r}const S=e.computed(()=>{const r={};return t.mode==="dialog"&&(r.justifyContent="center"),t.mode==="drawer"&&(r.justifyContent={left:"flex-start",right:"flex-end",top:"flex-start",bottom:"flex-end"}[t.position],r.flexDirection={left:"row",right:"row",top:"column",bottom:"column"}[t.position]),r}),k=e.computed(()=>{const r={};return t.mode==="drawer"&&["top","bottom"].includes(t.position)?r.maxHeight=m(t.maxHeight):(r.width=m(t.sizes[t.size]),r.maxWidth=m(t.maxWidth)),t.width&&(r.width=m(t.width)),t.height&&(r.height=m(t.height)),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(${$.value-h}px, ${H.value-w}px, 0px)`),t.mode==="drawer"&&(r.borderRadius=0,["left","right"].includes(t.position)?r.height="100%":r.width="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}),B=e.computed(()=>{const r={};return t.draggable&&!t.fullscreen&&t.mode==="dialog"&&(r.cursor="move"),r}),C=e.computed(()=>{const r={},E=M.value+x.value+p.value+_.value,D=Math.floor(g.value*(Number(m(t.maxHeight).replace("%",""))/100));return t.maxHeight&&(r.maxHeight=`${D-E}px`),t.mode==="drawer"&&(r.maxHeight="unset",["left","right"].includes(t.position)&&(r.height=`${g.value-E}px`)),t.fullscreen&&(r.maxHeight="unset",r.height=`calc(100% - ${E}px)`),t.type!=="component"&&(r.padding="0"),t.bodyStyle&&Object.assign(r,t.bodyStyle),r});function O(){const r=v.value;if(t.form&&r){const E=r.querySelector(`form[name="${t.form}"]`);E&&E.dispatchEvent(new Event("submit"))}t.onOk&&t.onOk({close:()=>i==null?void 0:i.close(t.id)}),a("submit")}function K(){i==null||i.close(t.id),t!=null&&t.onCancel&&t.onCancel()}function X(){window&&window.addEventListener("resize",()=>{e.triggerRef(y),e.triggerRef(v),v.value&&(h=v.value.offsetLeft,w=v.value.offsetTop)})}function Y(){if(t.closeable&&t.esc){const r=({key:E})=>{E==="Escape"&&(i==null||i.close(t.id),window.removeEventListener("keydown",r))};window.addEventListener("keydown",r)}}function q(){h=v.value.offsetLeft,w=v.value.offsetTop}e.onMounted(()=>{Y(),X()}),e.onUnmounted(()=>{});function U(){return u.value=!0,()=>I()}function I(){u.value=!1}return l({showLoading:U,hideLoading:I}),(r,E)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"wrapperRef",ref:y,class:"modal-wrapper",style:e.normalizeStyle(S.value),onClick:E[0]||(E[0]=e.withModifiers(D=>r.maskClosable&&A(),["self"]))},[e.createElementVNode("div",{ref_key:"contentRef",ref:v,class:e.normalizeClass(["modal-content",{[`${r.mode}-mode`]:!0,[`${r.position}-position`]:!0}]),style:e.normalizeStyle(k.value)},[r.header?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"headerRef",ref:f,class:"modal-header",style:e.normalizeStyle(B.value),onMousedown:q},[e.createElementVNode("div",ae,e.toDisplayString(r.title),1),e.createElementVNode("div",ce,[r.closeable?(e.openBlock(),e.createElementBlock("div",{key:0,class:"i-icon-park-outline:close block cursor-pointer",onClick:A})):e.createCommentVNode("",!0)])],36)):e.createCommentVNode("",!0),e.createElementVNode("div",{id:"modal-header-slot",ref_key:"headerSlotRef",ref:d},null,512),e.createElementVNode("div",{class:"modal-body",style:e.normalizeStyle(C.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:c},null,512),r.footer?(e.openBlock(),e.createElementBlock("div",{key:1,ref_key:"footerRef",ref:s,class:"modal-footer space-x-2"},[e.createElementVNode("button",{class:"cancel-button",type:"button",onClick:K},e.toDisplayString(r.cancelText),1),e.createElementVNode("button",{class:"submit-button",form:r.form,type:"submit",onClick:O},e.toDisplayString(r.submitText),9,de)],512)):e.createCommentVNode("",!0),u.value?(e.openBlock(),e.createElementBlock("div",ue,pe)):e.createCommentVNode("",!0)],6)],4))}}),V=(o,l)=>{const n=o.__vccOpts||o;for(const[t,a]of l)n[t]=a;return n},j=V(he,[["__scopeId","data-v-bd04f7a9"]]),ve={class:"modal-dialog"},ge={class:"dialog-body"},ye={class:"dialog-title"},be={class:"dialog-content"},we=e.defineComponent({__name:"modal-dialog",props:{type:{},title:{},content:{},okText:{default:"确定"},cancelText:{default:"取消"},onOk:{},onCancel:{},footer:{}},setup(o){const l=o,n=G(),t=e.computed(()=>l.title?l.title:{confirm:"提示",info:"提示",warning:"警告",error:"错误",success:"成功"}[l.type]);async function a(){l.onOk&&await l.onOk(),n.close()}async function i(){l.onCancel&&await l.onCancel(),n.close()}return(u,h)=>(e.openBlock(),e.createElementBlock("section",ve,[e.createElementVNode("div",ge,[e.createElementVNode("div",ye,e.toDisplayString(t.value),1),e.createElementVNode("div",be,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:a},e.toDisplayString(u.okText),1),u.type==="confirm"?(e.openBlock(),e.createElementBlock("button",{key:0,class:"cancel-button",type:"button",onClick:i},e.toDisplayString(u.cancelText),1)):e.createCommentVNode("",!0)],64))],4)]))}}),ke=V(we,[["__scopeId","data-v-0c6b8db2"]]),_e=o=>(e.pushScopeId("data-v-559bdf2e"),o=o(),e.popScopeId(),o),Ce={class:"flex-center"},Ee=_e(()=>e.createElementVNode("div",{class:"modal-loading"},[e.createElementVNode("div",{class:"lds-ring"},[e.createElementVNode("div"),e.createElementVNode("div"),e.createElementVNode("div"),e.createElementVNode("div")])],-1)),xe={class:"modal-loading-text"},Se=e.defineComponent({__name:"modal-loading",props:{text:{default:"加载中"}},setup(o){return(l,n)=>(e.openBlock(),e.createElementBlock("section",Ce,[Ee,e.createElementVNode("div",xe,e.toDisplayString(l.text),1)]))}}),Be=V(Se,[["__scopeId","data-v-559bdf2e"]]),Me={key:0,class:"modal-teleport"},Ne={name:"ModalProvider",inheritAttrs:!1},Ve=e.defineComponent({...Ne,props:{appendToBody:{type:[Boolean,String],default:!1},sizes:{default:()=>({small:"50%",middle:"70%",large:"90%"})},maxWidth:{default:"90%"},maxHeight:{default:"90%"},offset:{default:()=>({x:0,y:0})}},setup(o,{expose:l}){const n=e.shallowRef([]),t=e.ref(!1),a=e.getCurrentInstance();function i(s,d={},c={}){const g=e.defineAsyncComponent(()=>Promise.resolve(typeof s=="string"?ke:s));typeof s=="string"&&(d.type=s,c.size="small",c.fullscreen=!1,c.mode="dialog",c.footer=!1,c.header=!1);const p=Math.random().toString(32).slice(2),_=Object.assign({zIndex:typeof s=="string"?1100:1e3},c),M=new Promise((x,$)=>{n.value.push({id:p,component:g,props:d||{},options:{..._,type:typeof s=="string"?s:"component"},resolve:x,reject:$,listeners:[]}),e.triggerRef(n)}).catch(x=>x==="CANCEL"?new Promise(()=>{}):Promise.reject(x));return Object.assign(M,{close:()=>u(p)})}function u(s,d){const c=n.value.findIndex(p=>p.id===s);if(c<0)return;const g=n.value[c];d===void 0?g==null||g.reject("CANCEL"):g==null||g.resolve(d),n.value.splice(c,1),e.triggerRef(n)}function h(){!n.value||n.value.length===0||(n.value.forEach(s=>{s==null||s.reject("CANCEL")}),n.value=[],e.triggerRef(n))}function w(s,d){const c=n.value.find(p=>p.id===s);if(!c)return;const g=c.listeners.find(p=>p.event===d);g&&g.callback({open:i,close:p=>u(c.id,p),closeAll:h,showLoading:()=>y(c.id),hideLoading:()=>v(c.id),confirm:p=>i("confirm",p),success:p=>i("success",p),error:p=>i("error",p),warning:p=>i("warning",p),info:p=>i("info",p)})}function y(s,d){if(!a)return;const[c]=a.refs[`modal-container_${s}`]||[];if(c)return c.showLoading();{const{close:g}=i(Be,{text:d==null?void 0:d.text},{footer:!1,header:!1,closeable:!1,backgroundColor:"transparent"});return d!=null&&d.duration&&setTimeout(()=>{g()},d==null?void 0:d.duration),g}}function v(s){if(!a)return;const[d]=a.refs[`modal-container_${s}`];if(d)return d.hideLoading()}function f(s,d,c){const g=n.value.find(p=>p.id===s);g&&g.listeners.push({event:d,callback:c})}return e.provide(L,{open:i,close:u,closeAll:h,addEventListener:f,showLoading:y,hideLoading:v}),l({elements:n,open:i,close:u,closeAll:h}),e.onMounted(()=>{t.value=!0}),(s,d)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.renderSlot(s.$slots,"default",{},void 0,!0),t.value?(e.openBlock(),e.createElementBlock("div",Me,[(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(n.value,c=>(e.openBlock(),e.createBlock(j,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":s.maxHeight,"max-width":s.maxWidth,offset:s.offset,sizes:s.sizes},c.options,{onSubmit:()=>w(c.id,"submit")}),null,16,["id","component","component-props","max-height","max-width","offset","sizes","onSubmit"]))),128))]),_:1})],8,["disabled","to"]))])):e.createCommentVNode("",!0)],64))}}),$e=V(Ve,[["__scopeId","data-v-448d3772"]]),Re={},Le={class:"modal-footer"};function Ae(o,l){return e.openBlock(),e.createBlock(e.Teleport,{to:"#modal-footer-slot"},[e.createElementVNode("div",Le,[e.renderSlot(o.$slots,"default",{},void 0,!0)])])}const Oe=V(Re,[["render",Ae],["__scopeId","data-v-46f8d703"]]),Te={},ze={class:"modal-header"};function He(o,l){return e.openBlock(),e.createBlock(e.Teleport,{to:"#modal-header-slot"},[e.createElementVNode("div",ze,[e.renderSlot(o.$slots,"default",{},void 0,!0)])])}const Pe=V(Te,[["render",He],["__scopeId","data-v-d0247172"]]);function T(o,l){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)!==l;)n=n.parent;return((a=n==null?void 0:n.type)==null?void 0:a.name)===l?n:null}function G(){const o=e.inject(L),l=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 u;if(!o)throw new Error("Not Found Modal Provider Component");const a=T(l,"ModalContainer"),i=(u=a==null?void 0:a.props)==null?void 0:u.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(t){var u;if(!o)throw new Error("Not Found Modal Provider Component");const a=T(l,"ModalContainer"),i=(u=a==null?void 0:a.props)==null?void 0:u.id;return o.showLoading(i,t)},hideLoading(){var i;if(!o)throw new Error("Not Found Modal Provider Component");const t=T(l,"ModalContainer"),a=(i=t==null?void 0:t.props)==null?void 0:i.id;return o.hideLoading(a)},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 Ie(o){var i;const l=e.inject(L),n=e.getCurrentInstance(),t=T(n,"ModalContainer"),a=(i=t==null?void 0:t.props)==null?void 0:i.id;l&&a&&l.addEventListener(a,"submit",o)}exports.ModalContainer=j;exports.ModalFooter=Oe;exports.ModalHeader=Pe;exports.ModalKey=L;exports.ModalProvider=$e;exports.onSubmit=Ie;exports.useModal=G;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),L=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 F=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){return e.getCurrentInstance()}function te(o,l={}){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=b(l.replaceRef))!=null?i:!0)if(Array.isArray(o.value)){const h=[...o.value];h[t]=a,o.value=h}else{const h={...o.value,[t]:a};Object.setPrototypeOf(h,Object.getPrototypeOf(o.value)),o.value=h}else o.value[t]=a}}));return n}function oe(o,l=!0,n){ee()?e.onMounted(o,n):l?o():e.nextTick(o)}function N(o){var l;const n=b(o);return(l=n==null?void 0:n.$el)!=null?l:n}const z=F?window:void 0;function P(...o){let l,n,t,a;if(typeof o[0]=="string"||Array.isArray(o[0])?([n,t,a]=o,l=z):[l,n,t,a]=o,!l)return Z;Array.isArray(n)||(n=[n]),Array.isArray(t)||(t=[t]);const i=[],u=()=>{i.forEach(v=>v()),i.length=0},h=(v,f,s,d)=>(v.addEventListener(f,s,d),()=>v.removeEventListener(f,s,d)),w=e.watch(()=>[N(l),b(a)],([v,f])=>{if(u(),!v)return;const s=Q(f)?{...f}:f;i.push(...n.flatMap(d=>t.map(c=>h(v,d,c,s))))},{immediate:!0,flush:"post"}),y=()=>{w(),u()};return W(y),y}function ne(){const o=e.ref(!1),l=e.getCurrentInstance();return l&&e.onMounted(()=>{o.value=!0},l),o}function re(o){const l=ne();return e.computed(()=>(l.value,!!o()))}function le(o,l={}){var n,t;const{pointerTypes:a,preventDefault:i,stopPropagation:u,exact:h,onMove:w,onEnd:y,onStart:v,initialValue:f,axis:s="both",draggingElement:d=z,containerElement:c,handle:g=o}=l,p=e.ref((n=b(f))!=null?n:{x:0,y:0}),_=e.ref(),M=m=>a?a.includes(m.pointerType):!0,x=m=>{b(i)&&m.preventDefault(),b(u)&&m.stopPropagation()},$=m=>{var S;if(m.button!==0||b(l.disabled)||!M(m)||b(h)&&m.target!==b(o))return;const k=b(c),B=(S=k==null?void 0:k.getBoundingClientRect)==null?void 0:S.call(k),C=b(o).getBoundingClientRect(),O={x:m.clientX-(k?C.left-B.left+k.scrollLeft:C.left),y:m.clientY-(k?C.top-B.top+k.scrollTop:C.top)};(v==null?void 0:v(O,m))!==!1&&(_.value=O,x(m))},H=m=>{if(b(l.disabled)||!M(m)||!_.value)return;const S=b(c),k=b(o).getBoundingClientRect();let{x:B,y:C}=p.value;(s==="x"||s==="both")&&(B=m.clientX-_.value.x,S&&(B=Math.min(Math.max(0,B),S.scrollWidth-k.width))),(s==="y"||s==="both")&&(C=m.clientY-_.value.y,S&&(C=Math.min(Math.max(0,C),S.scrollHeight-k.height))),p.value={x:B,y:C},w==null||w(p.value,m),x(m)},A=m=>{b(l.disabled)||!M(m)||_.value&&(_.value=void 0,y==null||y(p.value,m),x(m))};if(F){const m={capture:(t=l.capture)!=null?t:!0};P(g,"pointerdown",$,m),P(d,"pointermove",H,m),P(d,"pointerup",A,m)}return{...te(p),position:p,isDragging:e.computed(()=>!!_.value),style:e.computed(()=>`left:${p.value.x}px;top:${p.value.y}px;`)}}function ie(o,l,n={}){const{window:t=z,...a}=n;let i;const u=re(()=>t&&"ResizeObserver"in t),h=()=>{i&&(i.disconnect(),i=void 0)},w=e.computed(()=>Array.isArray(o)?o.map(f=>N(f)):[N(o)]),y=e.watch(w,f=>{if(h(),u.value&&t){i=new ResizeObserver(l);for(const s of f)s&&i.observe(s,a)}},{immediate:!0,flush:"post"}),v=()=>{h(),y()};return W(v),{isSupported:u,stop:v}}function R(o,l={width:0,height:0},n={}){const{window:t=z,box:a="content-box"}=n,i=e.computed(()=>{var f,s;return(s=(f=N(o))==null?void 0:f.namespaceURI)==null?void 0:s.includes("svg")}),u=e.ref(l.width),h=e.ref(l.height),{stop:w}=ie(o,([f])=>{const s=a==="border-box"?f.borderBoxSize:a==="content-box"?f.contentBoxSize:f.devicePixelContentBoxSize;if(t&&i.value){const d=N(o);if(d){const c=d.getBoundingClientRect();u.value=c.width,h.value=c.height}}else if(s){const d=Array.isArray(s)?s:[s];u.value=d.reduce((c,{inlineSize:g})=>c+g,0),h.value=d.reduce((c,{blockSize:g})=>c+g,0)}else u.value=f.contentRect.width,h.value=f.contentRect.height},n);oe(()=>{const f=N(o);f&&(u.value="offsetWidth"in f?f.offsetWidth:l.width,h.value="offsetHeight"in f?f.offsetHeight:l.height)});const y=e.watch(()=>N(o),f=>{u.value=f?l.width:0,h.value=f?l.height:0});function v(){w(),y()}return{width:u,height:h,stop:v}}const se=o=>(e.pushScopeId("data-v-e065fedd"),o=o(),e.popScopeId(),o),ae={class:"title text-16px font-bold"},ce={class:"action"},de=["form"],ue={key:2,class:"modal-loading"},fe=se(()=>e.createElementVNode("div",{class:"lds-ring"},[e.createElementVNode("div"),e.createElementVNode("div"),e.createElementVNode("div"),e.createElementVNode("div")],-1)),pe=[fe],me={name:"ModalContainer",inheritAttrs:!1},he=e.defineComponent({...me,props:{id:{},form:{},component:{},componentProps:{},width:{},height:{},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"},position:{default:"right"},type:{},offset:{},backgroundColor:{},bodyStyle:{},submitText:{default:"确定"},cancelText:{default:"取消"},zIndex:{default:1e3},onOk:{},onCancel:{}},emits:["submit"],setup(o,{expose:l,emit:n}){e.useCssVars(r=>({"0b220c17":r.zIndex}));const t=o,a=n,i=e.inject(L),u=e.ref(!1);let h=0,w=0;const y=e.shallowRef(),v=e.shallowRef(),f=e.shallowRef(),s=e.shallowRef(),d=e.shallowRef(),c=e.shallowRef(),{height:g}=R(y),{height:p}=R(f,void 0,{box:"border-box"}),{height:_}=R(s,void 0,{box:"border-box"}),{height:M}=R(d),{height:x}=R(c),{x:$,y:H}=le(f,{initialValue:{x:0,y:0}});function A(){i==null||i.close(t.id)}function m(r){return typeof r=="number"?`${r}px`:r}const S=e.computed(()=>{const r={};return t.mode==="dialog"&&(r.justifyContent="center"),t.mode==="drawer"&&(r.justifyContent={left:"flex-start",right:"flex-end",top:"flex-start",bottom:"flex-end"}[t.position],r.flexDirection={left:"row",right:"row",top:"column",bottom:"column"}[t.position]),r}),k=e.computed(()=>{const r={};return t.mode==="drawer"&&["top","bottom"].includes(t.position)?r.maxHeight=m(t.maxHeight):(r.width=m(t.sizes[t.size]),r.maxWidth=m(t.maxWidth)),t.width&&(r.width=m(t.width)),t.height&&(r.height=m(t.height)),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(${$.value-h}px, ${H.value-w}px, 0px)`),t.mode==="drawer"&&(r.borderRadius=0,["left","right"].includes(t.position)?r.height="100%":r.width="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}),B=e.computed(()=>{const r={};return t.draggable&&!t.fullscreen&&t.mode==="dialog"&&(r.cursor="move"),r}),C=e.computed(()=>{const r={},E=M.value+x.value+p.value+_.value,D=Math.floor(g.value*(Number(m(t.maxHeight).replace("%",""))/100));return t.maxHeight&&(r.maxHeight=`${D-E}px`),t.mode==="drawer"&&(r.maxHeight="unset",["left","right"].includes(t.position)&&(r.height=`${g.value-E}px`)),t.fullscreen&&(r.maxHeight="unset",r.height=`calc(100% - ${E}px)`),t.type!=="component"&&(r.padding="0"),t.bodyStyle&&Object.assign(r,t.bodyStyle),r});function O(){const r=v.value;if(t.form&&r){const E=r.querySelector(`form[name="${t.form}"]`);E&&E.dispatchEvent(new Event("submit"))}t.onOk&&t.onOk({close:()=>i==null?void 0:i.close(t.id)}),a("submit")}function K(){i==null||i.close(t.id),t!=null&&t.onCancel&&t.onCancel()}function X(){window&&window.addEventListener("resize",()=>{e.triggerRef(y),e.triggerRef(v),v.value&&(h=v.value.offsetLeft,w=v.value.offsetTop)})}function Y(){if(t.closeable&&t.esc){const r=({key:E})=>{E==="Escape"&&(i==null||i.close(t.id),window.removeEventListener("keydown",r))};window.addEventListener("keydown",r)}}function q(){h=v.value.offsetLeft,w=v.value.offsetTop}e.onMounted(()=>{Y(),X()}),e.onUnmounted(()=>{});function U(){return u.value=!0,()=>I()}function I(){u.value=!1}return l({showLoading:U,hideLoading:I}),(r,E)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"wrapperRef",ref:y,class:"modal-wrapper",style:e.normalizeStyle(S.value),onClick:E[0]||(E[0]=e.withModifiers(D=>r.maskClosable&&A(),["self"]))},[e.createElementVNode("div",{ref_key:"contentRef",ref:v,class:e.normalizeClass(["modal-content",{[`${r.mode}-mode`]:!0,[`${r.position}-position`]:!0}]),style:e.normalizeStyle(k.value)},[r.header?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"headerRef",ref:f,class:"modal-header",style:e.normalizeStyle(B.value),onMousedown:q},[e.createElementVNode("div",ae,e.toDisplayString(r.title),1),e.createElementVNode("div",ce,[r.closeable?(e.openBlock(),e.createElementBlock("div",{key:0,class:"i-icon-park-outline:close block cursor-pointer",onClick:A})):e.createCommentVNode("",!0)])],36)):e.createCommentVNode("",!0),e.createElementVNode("div",{id:"modal-header-slot",ref_key:"headerSlotRef",ref:d},null,512),e.createElementVNode("div",{class:"modal-body",style:e.normalizeStyle(C.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:c},null,512),r.footer?(e.openBlock(),e.createElementBlock("div",{key:1,ref_key:"footerRef",ref:s,class:"modal-footer space-x-2"},[e.createElementVNode("button",{class:"cancel-button",type:"button",onClick:K},e.toDisplayString(r.cancelText),1),e.createElementVNode("button",{class:"submit-button",form:r.form,type:"button",onClick:O},e.toDisplayString(r.submitText),9,de)],512)):e.createCommentVNode("",!0),u.value?(e.openBlock(),e.createElementBlock("div",ue,pe)):e.createCommentVNode("",!0)],6)],4))}}),V=(o,l)=>{const n=o.__vccOpts||o;for(const[t,a]of l)n[t]=a;return n},j=V(he,[["__scopeId","data-v-e065fedd"]]),ve={class:"modal-dialog"},ge={class:"dialog-body"},ye={class:"dialog-title"},be={class:"dialog-content"},we=e.defineComponent({__name:"modal-dialog",props:{type:{},title:{},content:{},okText:{default:"确定"},cancelText:{default:"取消"},onOk:{},onCancel:{},footer:{}},setup(o){const l=o,n=G(),t=e.computed(()=>l.title?l.title:{confirm:"提示",info:"提示",warning:"警告",error:"错误",success:"成功"}[l.type]);async function a(){l.onOk&&await l.onOk(),n.close()}async function i(){l.onCancel&&await l.onCancel(),n.close()}return(u,h)=>(e.openBlock(),e.createElementBlock("section",ve,[e.createElementVNode("div",ge,[e.createElementVNode("div",ye,e.toDisplayString(t.value),1),e.createElementVNode("div",be,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:a},e.toDisplayString(u.okText),1),u.type==="confirm"?(e.openBlock(),e.createElementBlock("button",{key:0,class:"cancel-button",type:"button",onClick:i},e.toDisplayString(u.cancelText),1)):e.createCommentVNode("",!0)],64))],4)]))}}),ke=V(we,[["__scopeId","data-v-0c6b8db2"]]),_e=o=>(e.pushScopeId("data-v-559bdf2e"),o=o(),e.popScopeId(),o),Ce={class:"flex-center"},Ee=_e(()=>e.createElementVNode("div",{class:"modal-loading"},[e.createElementVNode("div",{class:"lds-ring"},[e.createElementVNode("div"),e.createElementVNode("div"),e.createElementVNode("div"),e.createElementVNode("div")])],-1)),xe={class:"modal-loading-text"},Se=e.defineComponent({__name:"modal-loading",props:{text:{default:"加载中"}},setup(o){return(l,n)=>(e.openBlock(),e.createElementBlock("section",Ce,[Ee,e.createElementVNode("div",xe,e.toDisplayString(l.text),1)]))}}),Be=V(Se,[["__scopeId","data-v-559bdf2e"]]),Me={key:0,class:"modal-teleport"},Ne={name:"ModalProvider",inheritAttrs:!1},Ve=e.defineComponent({...Ne,props:{appendToBody:{type:[Boolean,String],default:!1},sizes:{default:()=>({small:"50%",middle:"70%",large:"90%"})},maxWidth:{default:"90%"},maxHeight:{default:"90%"},offset:{default:()=>({x:0,y:0})}},setup(o,{expose:l}){const n=e.shallowRef([]),t=e.ref(!1),a=e.getCurrentInstance();function i(s,d={},c={}){const g=e.defineAsyncComponent(()=>Promise.resolve(typeof s=="string"?ke:s));typeof s=="string"&&(d.type=s,c.size="small",c.fullscreen=!1,c.mode="dialog",c.footer=!1,c.header=!1);const p=Math.random().toString(32).slice(2),_=Object.assign({zIndex:typeof s=="string"?1100:1e3},c),M=new Promise((x,$)=>{n.value.push({id:p,component:g,props:d||{},options:{..._,type:typeof s=="string"?s:"component"},resolve:x,reject:$,listeners:[]}),e.triggerRef(n)}).catch(x=>x==="CANCEL"?new Promise(()=>{}):Promise.reject(x));return Object.assign(M,{close:()=>u(p)})}function u(s,d){const c=n.value.findIndex(p=>p.id===s);if(c<0)return;const g=n.value[c];d===void 0?g==null||g.reject("CANCEL"):g==null||g.resolve(d),n.value.splice(c,1),e.triggerRef(n)}function h(){!n.value||n.value.length===0||(n.value.forEach(s=>{s==null||s.reject("CANCEL")}),n.value=[],e.triggerRef(n))}function w(s,d){const c=n.value.find(p=>p.id===s);if(!c)return;const g=c.listeners.find(p=>p.event===d);g&&g.callback({open:i,close:p=>u(c.id,p),closeAll:h,showLoading:()=>y(c.id),hideLoading:()=>v(c.id),confirm:p=>i("confirm",p),success:p=>i("success",p),error:p=>i("error",p),warning:p=>i("warning",p),info:p=>i("info",p)})}function y(s,d){if(!a)return;const[c]=a.refs[`modal-container_${s}`]||[];if(c)return c.showLoading();{const{close:g}=i(Be,{text:d==null?void 0:d.text},{footer:!1,header:!1,closeable:!1,backgroundColor:"transparent"});return d!=null&&d.duration&&setTimeout(()=>{g()},d==null?void 0:d.duration),g}}function v(s){if(!a)return;const[d]=a.refs[`modal-container_${s}`];if(d)return d.hideLoading()}function f(s,d,c){const g=n.value.find(p=>p.id===s);g&&g.listeners.push({event:d,callback:c})}return e.provide(L,{open:i,close:u,closeAll:h,addEventListener:f,showLoading:y,hideLoading:v}),l({elements:n,open:i,close:u,closeAll:h}),e.onMounted(()=>{t.value=!0}),(s,d)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.renderSlot(s.$slots,"default",{},void 0,!0),t.value?(e.openBlock(),e.createElementBlock("div",Me,[(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(n.value,c=>(e.openBlock(),e.createBlock(j,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":s.maxHeight,"max-width":s.maxWidth,offset:s.offset,sizes:s.sizes},c.options,{onSubmit:()=>w(c.id,"submit")}),null,16,["id","component","component-props","max-height","max-width","offset","sizes","onSubmit"]))),128))]),_:1})],8,["disabled","to"]))])):e.createCommentVNode("",!0)],64))}}),$e=V(Ve,[["__scopeId","data-v-448d3772"]]),Re={},Le={class:"modal-footer"};function Ae(o,l){return e.openBlock(),e.createBlock(e.Teleport,{to:"#modal-footer-slot"},[e.createElementVNode("div",Le,[e.renderSlot(o.$slots,"default",{},void 0,!0)])])}const Oe=V(Re,[["render",Ae],["__scopeId","data-v-46f8d703"]]),Te={},ze={class:"modal-header"};function He(o,l){return e.openBlock(),e.createBlock(e.Teleport,{to:"#modal-header-slot"},[e.createElementVNode("div",ze,[e.renderSlot(o.$slots,"default",{},void 0,!0)])])}const Pe=V(Te,[["render",He],["__scopeId","data-v-d0247172"]]);function T(o,l){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)!==l;)n=n.parent;return((a=n==null?void 0:n.type)==null?void 0:a.name)===l?n:null}function G(){const o=e.inject(L),l=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 u;if(!o)throw new Error("Not Found Modal Provider Component");const a=T(l,"ModalContainer"),i=(u=a==null?void 0:a.props)==null?void 0:u.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(t){var u;if(!o)throw new Error("Not Found Modal Provider Component");const a=T(l,"ModalContainer"),i=(u=a==null?void 0:a.props)==null?void 0:u.id;return o.showLoading(i,t)},hideLoading(){var i;if(!o)throw new Error("Not Found Modal Provider Component");const t=T(l,"ModalContainer"),a=(i=t==null?void 0:t.props)==null?void 0:i.id;return o.hideLoading(a)},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 Ie(o){var i;const l=e.inject(L),n=e.getCurrentInstance(),t=T(n,"ModalContainer"),a=(i=t==null?void 0:t.props)==null?void 0:i.id;l&&a&&l.addEventListener(a,"submit",o)}exports.ModalContainer=j;exports.ModalFooter=Oe;exports.ModalHeader=Pe;exports.ModalKey=L;exports.ModalProvider=$e;exports.onSubmit=Ie;exports.useModal=G;
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ModalKey } from './constants';
|
|
2
|
-
import { useModal } from './hooks/use-modal';
|
|
3
|
-
import { default as ModalHeader } from './components/modal-header.vue';
|
|
4
|
-
import { default as ModalFooter } from './components/modal-footer.vue';
|
|
5
|
-
import { default as ModalContainer } from './components/modal-container.vue';
|
|
6
1
|
import { default as ModalProvider } from './components/modal-provider.vue';
|
|
2
|
+
import { default as ModalContainer } from './components/modal-container.vue';
|
|
3
|
+
import { default as ModalFooter } from './components/modal-footer.vue';
|
|
4
|
+
import { default as ModalHeader } from './components/modal-header.vue';
|
|
5
|
+
import { useModal } from './hooks/use-modal';
|
|
6
|
+
import { ModalKey } from './constants';
|
|
7
7
|
|
|
8
8
|
export { onSubmit } from './hooks/on-submit';
|
|
9
9
|
export * from './interfaces';
|
package/dist/cjs/interfaces.d.ts
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { SizeOptions } from '../interfaces';
|
|
2
1
|
import { CSSProperties, Component } from 'vue';
|
|
2
|
+
import { SizeOptions } from '../interfaces';
|
|
3
3
|
|
|
4
4
|
declare const _default: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
5
5
|
id: string;
|
|
6
|
-
form?: string
|
|
6
|
+
form?: string;
|
|
7
7
|
component: Component;
|
|
8
8
|
componentProps: Record<string, any>;
|
|
9
|
-
width?:
|
|
10
|
-
height?:
|
|
11
|
-
maxWidth?:
|
|
12
|
-
maxHeight?:
|
|
9
|
+
width?: number | string;
|
|
10
|
+
height?: number | string;
|
|
11
|
+
maxWidth?: number | string;
|
|
12
|
+
maxHeight?: number | string;
|
|
13
13
|
sizes: SizeOptions;
|
|
14
|
-
size:
|
|
15
|
-
fullscreen?: boolean
|
|
16
|
-
title?: string
|
|
17
|
-
header?: boolean
|
|
18
|
-
footer?: boolean
|
|
19
|
-
closeable?: boolean
|
|
20
|
-
esc?: boolean
|
|
21
|
-
maskClosable?: boolean
|
|
22
|
-
draggable?: boolean
|
|
23
|
-
mode?: "dialog" | "drawer"
|
|
24
|
-
position?: "
|
|
25
|
-
type?: string
|
|
14
|
+
size: "small" | "middle" | "large";
|
|
15
|
+
fullscreen?: boolean;
|
|
16
|
+
title?: string;
|
|
17
|
+
header?: boolean;
|
|
18
|
+
footer?: boolean;
|
|
19
|
+
closeable?: boolean;
|
|
20
|
+
esc?: boolean;
|
|
21
|
+
maskClosable?: boolean;
|
|
22
|
+
draggable?: boolean;
|
|
23
|
+
mode?: "dialog" | "drawer";
|
|
24
|
+
position?: "left" | "right" | "bottom" | "top";
|
|
25
|
+
type?: string;
|
|
26
26
|
offset?: {
|
|
27
|
-
x?: number
|
|
28
|
-
y?: number
|
|
29
|
-
}
|
|
30
|
-
backgroundColor?: string
|
|
31
|
-
bodyStyle?: CSSProperties
|
|
32
|
-
submitText?: string
|
|
33
|
-
cancelText?: string
|
|
34
|
-
zIndex?: number
|
|
35
|
-
onOk?: (
|
|
27
|
+
x?: number;
|
|
28
|
+
y?: number;
|
|
29
|
+
};
|
|
30
|
+
backgroundColor?: string;
|
|
31
|
+
bodyStyle?: CSSProperties;
|
|
32
|
+
submitText?: string;
|
|
33
|
+
cancelText?: string;
|
|
34
|
+
zIndex?: number;
|
|
35
|
+
onOk?: (options: {
|
|
36
36
|
close: () => void;
|
|
37
|
-
}) => void
|
|
38
|
-
onCancel?: (
|
|
37
|
+
}) => void;
|
|
38
|
+
onCancel?: () => void;
|
|
39
39
|
}>, {
|
|
40
40
|
header: boolean;
|
|
41
41
|
closeable: boolean;
|
|
@@ -58,39 +58,39 @@ declare const _default: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
58
58
|
submit: (...args: any[]) => void;
|
|
59
59
|
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
60
60
|
id: string;
|
|
61
|
-
form?: string
|
|
61
|
+
form?: string;
|
|
62
62
|
component: Component;
|
|
63
63
|
componentProps: Record<string, any>;
|
|
64
|
-
width?:
|
|
65
|
-
height?:
|
|
66
|
-
maxWidth?:
|
|
67
|
-
maxHeight?:
|
|
64
|
+
width?: number | string;
|
|
65
|
+
height?: number | string;
|
|
66
|
+
maxWidth?: number | string;
|
|
67
|
+
maxHeight?: number | string;
|
|
68
68
|
sizes: SizeOptions;
|
|
69
|
-
size:
|
|
70
|
-
fullscreen?: boolean
|
|
71
|
-
title?: string
|
|
72
|
-
header?: boolean
|
|
73
|
-
footer?: boolean
|
|
74
|
-
closeable?: boolean
|
|
75
|
-
esc?: boolean
|
|
76
|
-
maskClosable?: boolean
|
|
77
|
-
draggable?: boolean
|
|
78
|
-
mode?: "dialog" | "drawer"
|
|
79
|
-
position?: "
|
|
80
|
-
type?: string
|
|
69
|
+
size: "small" | "middle" | "large";
|
|
70
|
+
fullscreen?: boolean;
|
|
71
|
+
title?: string;
|
|
72
|
+
header?: boolean;
|
|
73
|
+
footer?: boolean;
|
|
74
|
+
closeable?: boolean;
|
|
75
|
+
esc?: boolean;
|
|
76
|
+
maskClosable?: boolean;
|
|
77
|
+
draggable?: boolean;
|
|
78
|
+
mode?: "dialog" | "drawer";
|
|
79
|
+
position?: "left" | "right" | "bottom" | "top";
|
|
80
|
+
type?: string;
|
|
81
81
|
offset?: {
|
|
82
|
-
x?: number
|
|
83
|
-
y?: number
|
|
84
|
-
}
|
|
85
|
-
backgroundColor?: string
|
|
86
|
-
bodyStyle?: CSSProperties
|
|
87
|
-
submitText?: string
|
|
88
|
-
cancelText?: string
|
|
89
|
-
zIndex?: number
|
|
90
|
-
onOk?: (
|
|
82
|
+
x?: number;
|
|
83
|
+
y?: number;
|
|
84
|
+
};
|
|
85
|
+
backgroundColor?: string;
|
|
86
|
+
bodyStyle?: CSSProperties;
|
|
87
|
+
submitText?: string;
|
|
88
|
+
cancelText?: string;
|
|
89
|
+
zIndex?: number;
|
|
90
|
+
onOk?: (options: {
|
|
91
91
|
close: () => void;
|
|
92
|
-
}) => void
|
|
93
|
-
onCancel?: (
|
|
92
|
+
}) => void;
|
|
93
|
+
onCancel?: () => void;
|
|
94
94
|
}>, {
|
|
95
95
|
header: boolean;
|
|
96
96
|
closeable: boolean;
|
|
@@ -109,7 +109,7 @@ declare const _default: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
109
109
|
}>>> & {
|
|
110
110
|
onSubmit?: ((...args: any[]) => any) | undefined;
|
|
111
111
|
}, {
|
|
112
|
-
size:
|
|
112
|
+
size: "small" | "middle" | "large";
|
|
113
113
|
maxHeight: number | string;
|
|
114
114
|
header: boolean;
|
|
115
115
|
footer: boolean;
|
|
@@ -117,8 +117,8 @@ declare const _default: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
117
117
|
esc: boolean;
|
|
118
118
|
maskClosable: boolean;
|
|
119
119
|
draggable: boolean;
|
|
120
|
-
mode:
|
|
121
|
-
position:
|
|
120
|
+
mode: "dialog" | "drawer";
|
|
121
|
+
position: "left" | "right" | "bottom" | "top";
|
|
122
122
|
submitText: string;
|
|
123
123
|
cancelText: string;
|
|
124
124
|
zIndex: number;
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
declare const _default: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
2
|
-
type:
|
|
3
|
-
title?: string
|
|
2
|
+
type: "confirm" | "success" | "error" | "warning" | "info";
|
|
3
|
+
title?: string;
|
|
4
4
|
content: string;
|
|
5
|
-
okText?: string
|
|
6
|
-
cancelText?: string
|
|
7
|
-
onOk?: (
|
|
8
|
-
onCancel?: (
|
|
9
|
-
footer?: (
|
|
5
|
+
okText?: string;
|
|
6
|
+
cancelText?: string;
|
|
7
|
+
onOk?: () => Promise<void> | void;
|
|
8
|
+
onCancel?: () => Promise<void> | void;
|
|
9
|
+
footer?: () => JSX.Element;
|
|
10
10
|
}>, {
|
|
11
11
|
okText: string;
|
|
12
12
|
cancelText: string;
|
|
13
13
|
}>, {}, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
14
|
-
type:
|
|
15
|
-
title?: string
|
|
14
|
+
type: "confirm" | "success" | "error" | "warning" | "info";
|
|
15
|
+
title?: string;
|
|
16
16
|
content: string;
|
|
17
|
-
okText?: string
|
|
18
|
-
cancelText?: string
|
|
19
|
-
onOk?: (
|
|
20
|
-
onCancel?: (
|
|
21
|
-
footer?: (
|
|
17
|
+
okText?: string;
|
|
18
|
+
cancelText?: string;
|
|
19
|
+
onOk?: () => Promise<void> | void;
|
|
20
|
+
onCancel?: () => Promise<void> | void;
|
|
21
|
+
footer?: () => JSX.Element;
|
|
22
22
|
}>, {
|
|
23
23
|
okText: string;
|
|
24
24
|
cancelText: string;
|