vue-stack-tabs 0.1.14 → 0.1.16
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/src/lib/components/PageLoading.vue.d.ts +15 -0
- package/dist/src/lib/hooks/useTabMitt.d.ts +12 -0
- package/dist/style.css +1 -1
- package/dist/vue-stack-tabs.es.js +2226 -2412
- package/dist/vue-stack-tabs.umd.js +9 -34
- package/package.json +2 -1
- package/src/lib/StackTabs.vue +124 -136
- package/src/lib/assets/style/overlayer.scss +39 -33
- package/src/lib/assets/style/transition.scss +40 -40
- package/src/lib/banner.ts +1 -26
- package/src/lib/components/PageLoading.vue +22 -0
- package/src/lib/hooks/useTabLoading.ts +4 -20
- package/src/lib/hooks/useTabMitt.ts +27 -0
- package/src/lib/hooks/useTabpanel.tsx +517 -516
- package/src/lib/index.ts +2 -1
- package/dist/src/lib/components/OverlayLoading/Component.vue.d.ts +0 -100
- package/dist/src/lib/components/OverlayLoading/api.d.ts +0 -5
- package/dist/src/lib/components/OverlayLoading/helpers.d.ts +0 -7
- package/dist/src/lib/components/OverlayLoading/index.d.ts +0 -6
- package/dist/src/lib/components/OverlayLoading/loaders/bars.vue.d.ts +0 -39
- package/dist/src/lib/components/OverlayLoading/loaders/dots.vue.d.ts +0 -39
- package/dist/src/lib/components/OverlayLoading/loaders/index.d.ts +0 -96
- package/dist/src/lib/components/OverlayLoading/loaders/spinner.vue.d.ts +0 -39
- package/src/lib/components/OverlayLoading/Component.vue +0 -182
- package/src/lib/components/OverlayLoading/api.ts +0 -31
- package/src/lib/components/OverlayLoading/helpers.ts +0 -31
- package/src/lib/components/OverlayLoading/index.ts +0 -12
- package/src/lib/components/OverlayLoading/loaders/bars.vue +0 -79
- package/src/lib/components/OverlayLoading/loaders/dots.vue +0 -92
- package/src/lib/components/OverlayLoading/loaders/index.ts +0 -9
- package/src/lib/components/OverlayLoading/loaders/spinner.vue +0 -41
package/src/lib/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ import useTabLoading from './hooks/useTabLoading'
|
|
|
7
7
|
import useTabRouter from './hooks/useTabRouter'
|
|
8
8
|
import useStackTab from './hooks/useStackTab'
|
|
9
9
|
import TabHeaderButton from '@/lib/components/TabHeader/TabHeaderButton.vue'
|
|
10
|
+
import useTabMitt from '@/lib/hooks/useTabMitt'
|
|
10
11
|
import './assets/style/index.scss'
|
|
11
12
|
|
|
12
13
|
const i18n = createI18n({
|
|
@@ -27,6 +28,6 @@ export { IFrame, useTabLoading, useTabRouter, useStackTab, TabHeaderButton, Stac
|
|
|
27
28
|
export default {
|
|
28
29
|
install(Vue: App): void {
|
|
29
30
|
tabVersion(import.meta.env.PACKAGE_VERSION)
|
|
30
|
-
Vue.component('VueStackTabs', StackTab).use(i18n)
|
|
31
|
+
Vue.component('VueStackTabs', StackTab).use(useTabMitt).use(i18n)
|
|
31
32
|
}
|
|
32
33
|
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
2
|
-
active: boolean;
|
|
3
|
-
programmatic: boolean;
|
|
4
|
-
container: Object | Function | HTMLElement;
|
|
5
|
-
isFullPage: boolean;
|
|
6
|
-
enforceFocus?: boolean | undefined;
|
|
7
|
-
lockScroll: boolean;
|
|
8
|
-
transition: string;
|
|
9
|
-
/**
|
|
10
|
-
* Allow user to hide the loader
|
|
11
|
-
*/
|
|
12
|
-
canCancel: boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Do something on cancel
|
|
15
|
-
*/
|
|
16
|
-
onCancel: Function;
|
|
17
|
-
color: string;
|
|
18
|
-
backgroundColor: string;
|
|
19
|
-
opacity: number;
|
|
20
|
-
width: number;
|
|
21
|
-
height: number;
|
|
22
|
-
zIndex: number;
|
|
23
|
-
loader: string;
|
|
24
|
-
}>, {
|
|
25
|
-
isFullPage: boolean;
|
|
26
|
-
enforceFocus: boolean;
|
|
27
|
-
transition: string;
|
|
28
|
-
onCancel: () => void;
|
|
29
|
-
loader: string;
|
|
30
|
-
}>, {
|
|
31
|
-
hide: () => void;
|
|
32
|
-
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
33
|
-
hide: (...args: any[]) => void;
|
|
34
|
-
"update:active": (...args: any[]) => void;
|
|
35
|
-
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
36
|
-
active: boolean;
|
|
37
|
-
programmatic: boolean;
|
|
38
|
-
container: Object | Function | HTMLElement;
|
|
39
|
-
isFullPage: boolean;
|
|
40
|
-
enforceFocus?: boolean | undefined;
|
|
41
|
-
lockScroll: boolean;
|
|
42
|
-
transition: string;
|
|
43
|
-
/**
|
|
44
|
-
* Allow user to hide the loader
|
|
45
|
-
*/
|
|
46
|
-
canCancel: boolean;
|
|
47
|
-
/**
|
|
48
|
-
* Do something on cancel
|
|
49
|
-
*/
|
|
50
|
-
onCancel: Function;
|
|
51
|
-
color: string;
|
|
52
|
-
backgroundColor: string;
|
|
53
|
-
opacity: number;
|
|
54
|
-
width: number;
|
|
55
|
-
height: number;
|
|
56
|
-
zIndex: number;
|
|
57
|
-
loader: string;
|
|
58
|
-
}>, {
|
|
59
|
-
isFullPage: boolean;
|
|
60
|
-
enforceFocus: boolean;
|
|
61
|
-
transition: string;
|
|
62
|
-
onCancel: () => void;
|
|
63
|
-
loader: string;
|
|
64
|
-
}>>> & {
|
|
65
|
-
onHide?: ((...args: any[]) => any) | undefined;
|
|
66
|
-
"onUpdate:active"?: ((...args: any[]) => any) | undefined;
|
|
67
|
-
}, {
|
|
68
|
-
transition: string;
|
|
69
|
-
onCancel: Function;
|
|
70
|
-
isFullPage: boolean;
|
|
71
|
-
enforceFocus: boolean;
|
|
72
|
-
loader: string;
|
|
73
|
-
}, {}>, {
|
|
74
|
-
before?(_: {}): any;
|
|
75
|
-
default?(_: {}): any;
|
|
76
|
-
after?(_: {}): any;
|
|
77
|
-
}>;
|
|
78
|
-
export default _default;
|
|
79
|
-
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
80
|
-
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
81
|
-
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
82
|
-
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
83
|
-
} : {
|
|
84
|
-
type: import('vue').PropType<T[K]>;
|
|
85
|
-
required: true;
|
|
86
|
-
};
|
|
87
|
-
};
|
|
88
|
-
type __VLS_WithDefaults<P, D> = {
|
|
89
|
-
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
90
|
-
default: D[K];
|
|
91
|
-
}> : P[K];
|
|
92
|
-
};
|
|
93
|
-
type __VLS_Prettify<T> = {
|
|
94
|
-
[K in keyof T]: T[K];
|
|
95
|
-
} & {};
|
|
96
|
-
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
97
|
-
new (): {
|
|
98
|
-
$slots: S;
|
|
99
|
-
};
|
|
100
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare const removeElement: (el: HTMLElement) => void;
|
|
2
|
-
export declare function createComponent(component: any, props: any, parentContainer: HTMLElement, slots?: {}): import("vue").ComponentInternalInstance | null;
|
|
3
|
-
export declare const hasWindow: () => boolean;
|
|
4
|
-
export declare const MayBeHTMLElement: ObjectConstructor | {
|
|
5
|
-
new (): HTMLElement;
|
|
6
|
-
prototype: HTMLElement;
|
|
7
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
2
|
-
color?: string | undefined;
|
|
3
|
-
height?: number | undefined;
|
|
4
|
-
width?: number | undefined;
|
|
5
|
-
}>, {
|
|
6
|
-
color: string;
|
|
7
|
-
height: number;
|
|
8
|
-
width: number;
|
|
9
|
-
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
10
|
-
color?: string | undefined;
|
|
11
|
-
height?: number | undefined;
|
|
12
|
-
width?: number | undefined;
|
|
13
|
-
}>, {
|
|
14
|
-
color: string;
|
|
15
|
-
height: number;
|
|
16
|
-
width: number;
|
|
17
|
-
}>>>, {
|
|
18
|
-
width: number;
|
|
19
|
-
height: number;
|
|
20
|
-
color: string;
|
|
21
|
-
}, {}>;
|
|
22
|
-
export default _default;
|
|
23
|
-
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
24
|
-
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
25
|
-
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
26
|
-
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
27
|
-
} : {
|
|
28
|
-
type: import('vue').PropType<T[K]>;
|
|
29
|
-
required: true;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
type __VLS_WithDefaults<P, D> = {
|
|
33
|
-
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
34
|
-
default: D[K];
|
|
35
|
-
}> : P[K];
|
|
36
|
-
};
|
|
37
|
-
type __VLS_Prettify<T> = {
|
|
38
|
-
[K in keyof T]: T[K];
|
|
39
|
-
} & {};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
2
|
-
color?: string | undefined;
|
|
3
|
-
height?: number | undefined;
|
|
4
|
-
width?: number | undefined;
|
|
5
|
-
}>, {
|
|
6
|
-
color: string;
|
|
7
|
-
height: number;
|
|
8
|
-
width: number;
|
|
9
|
-
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
10
|
-
color?: string | undefined;
|
|
11
|
-
height?: number | undefined;
|
|
12
|
-
width?: number | undefined;
|
|
13
|
-
}>, {
|
|
14
|
-
color: string;
|
|
15
|
-
height: number;
|
|
16
|
-
width: number;
|
|
17
|
-
}>>>, {
|
|
18
|
-
width: number;
|
|
19
|
-
height: number;
|
|
20
|
-
color: string;
|
|
21
|
-
}, {}>;
|
|
22
|
-
export default _default;
|
|
23
|
-
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
24
|
-
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
25
|
-
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
26
|
-
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
27
|
-
} : {
|
|
28
|
-
type: import('vue').PropType<T[K]>;
|
|
29
|
-
required: true;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
type __VLS_WithDefaults<P, D> = {
|
|
33
|
-
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
34
|
-
default: D[K];
|
|
35
|
-
}> : P[K];
|
|
36
|
-
};
|
|
37
|
-
type __VLS_Prettify<T> = {
|
|
38
|
-
[K in keyof T]: T[K];
|
|
39
|
-
} & {};
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
spinner: import("vue").DefineComponent<{
|
|
3
|
-
width: {
|
|
4
|
-
type: import("vue").PropType<number>;
|
|
5
|
-
default: number;
|
|
6
|
-
};
|
|
7
|
-
height: {
|
|
8
|
-
type: import("vue").PropType<number>;
|
|
9
|
-
default: number;
|
|
10
|
-
};
|
|
11
|
-
color: {
|
|
12
|
-
type: import("vue").PropType<string>;
|
|
13
|
-
default: string;
|
|
14
|
-
};
|
|
15
|
-
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
16
|
-
width: {
|
|
17
|
-
type: import("vue").PropType<number>;
|
|
18
|
-
default: number;
|
|
19
|
-
};
|
|
20
|
-
height: {
|
|
21
|
-
type: import("vue").PropType<number>;
|
|
22
|
-
default: number;
|
|
23
|
-
};
|
|
24
|
-
color: {
|
|
25
|
-
type: import("vue").PropType<string>;
|
|
26
|
-
default: string;
|
|
27
|
-
};
|
|
28
|
-
}>>, {
|
|
29
|
-
width: number;
|
|
30
|
-
height: number;
|
|
31
|
-
color: string;
|
|
32
|
-
}, {}>;
|
|
33
|
-
dots: import("vue").DefineComponent<{
|
|
34
|
-
width: {
|
|
35
|
-
type: import("vue").PropType<number>;
|
|
36
|
-
default: number;
|
|
37
|
-
};
|
|
38
|
-
height: {
|
|
39
|
-
type: import("vue").PropType<number>;
|
|
40
|
-
default: number;
|
|
41
|
-
};
|
|
42
|
-
color: {
|
|
43
|
-
type: import("vue").PropType<string>;
|
|
44
|
-
default: string;
|
|
45
|
-
};
|
|
46
|
-
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
47
|
-
width: {
|
|
48
|
-
type: import("vue").PropType<number>;
|
|
49
|
-
default: number;
|
|
50
|
-
};
|
|
51
|
-
height: {
|
|
52
|
-
type: import("vue").PropType<number>;
|
|
53
|
-
default: number;
|
|
54
|
-
};
|
|
55
|
-
color: {
|
|
56
|
-
type: import("vue").PropType<string>;
|
|
57
|
-
default: string;
|
|
58
|
-
};
|
|
59
|
-
}>>, {
|
|
60
|
-
width: number;
|
|
61
|
-
height: number;
|
|
62
|
-
color: string;
|
|
63
|
-
}, {}>;
|
|
64
|
-
bars: import("vue").DefineComponent<{
|
|
65
|
-
width: {
|
|
66
|
-
type: import("vue").PropType<number>;
|
|
67
|
-
default: number;
|
|
68
|
-
};
|
|
69
|
-
height: {
|
|
70
|
-
type: import("vue").PropType<number>;
|
|
71
|
-
default: number;
|
|
72
|
-
};
|
|
73
|
-
color: {
|
|
74
|
-
type: import("vue").PropType<string>;
|
|
75
|
-
default: string;
|
|
76
|
-
};
|
|
77
|
-
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
78
|
-
width: {
|
|
79
|
-
type: import("vue").PropType<number>;
|
|
80
|
-
default: number;
|
|
81
|
-
};
|
|
82
|
-
height: {
|
|
83
|
-
type: import("vue").PropType<number>;
|
|
84
|
-
default: number;
|
|
85
|
-
};
|
|
86
|
-
color: {
|
|
87
|
-
type: import("vue").PropType<string>;
|
|
88
|
-
default: string;
|
|
89
|
-
};
|
|
90
|
-
}>>, {
|
|
91
|
-
width: number;
|
|
92
|
-
height: number;
|
|
93
|
-
color: string;
|
|
94
|
-
}, {}>;
|
|
95
|
-
};
|
|
96
|
-
export default _default;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
2
|
-
color?: string | undefined;
|
|
3
|
-
height?: number | undefined;
|
|
4
|
-
width?: number | undefined;
|
|
5
|
-
}>, {
|
|
6
|
-
color: string;
|
|
7
|
-
height: number;
|
|
8
|
-
width: number;
|
|
9
|
-
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
10
|
-
color?: string | undefined;
|
|
11
|
-
height?: number | undefined;
|
|
12
|
-
width?: number | undefined;
|
|
13
|
-
}>, {
|
|
14
|
-
color: string;
|
|
15
|
-
height: number;
|
|
16
|
-
width: number;
|
|
17
|
-
}>>>, {
|
|
18
|
-
width: number;
|
|
19
|
-
height: number;
|
|
20
|
-
color: string;
|
|
21
|
-
}, {}>;
|
|
22
|
-
export default _default;
|
|
23
|
-
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
24
|
-
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
25
|
-
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
26
|
-
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
27
|
-
} : {
|
|
28
|
-
type: import('vue').PropType<T[K]>;
|
|
29
|
-
required: true;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
type __VLS_WithDefaults<P, D> = {
|
|
33
|
-
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
34
|
-
default: D[K];
|
|
35
|
-
}> : P[K];
|
|
36
|
-
};
|
|
37
|
-
type __VLS_Prettify<T> = {
|
|
38
|
-
[K in keyof T]: T[K];
|
|
39
|
-
} & {};
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<transition :name="transition">
|
|
3
|
-
<div
|
|
4
|
-
tabindex="0"
|
|
5
|
-
class="vl-overlay vl-active"
|
|
6
|
-
:class="{ 'vl-full-page': isFullPage }"
|
|
7
|
-
v-show="isActive"
|
|
8
|
-
:aria-busy="isActive"
|
|
9
|
-
aria-label="Loading"
|
|
10
|
-
:style="{ zIndex }"
|
|
11
|
-
ref="overlay"
|
|
12
|
-
>
|
|
13
|
-
<div class="vl-background" @click.prevent="cancel" :style="bgStyle" />
|
|
14
|
-
<div class="vl-icon">
|
|
15
|
-
<slot name="before" />
|
|
16
|
-
<slot name="default">
|
|
17
|
-
<component :is="Loaders[loader]" :color="color" :width="width" :height="height" />
|
|
18
|
-
</slot>
|
|
19
|
-
<slot name="after" />
|
|
20
|
-
</div>
|
|
21
|
-
</div>
|
|
22
|
-
</transition>
|
|
23
|
-
</template>
|
|
24
|
-
|
|
25
|
-
<script lang="ts" setup>
|
|
26
|
-
// @ts-nocheck
|
|
27
|
-
import { withDefaults, render, ref, onMounted, onBeforeUnmount, computed, watch } from 'vue'
|
|
28
|
-
import { removeElement } from './helpers'
|
|
29
|
-
import Loaders from './loaders'
|
|
30
|
-
|
|
31
|
-
const props = withDefaults(
|
|
32
|
-
defineProps<{
|
|
33
|
-
active: boolean
|
|
34
|
-
programmatic: boolean
|
|
35
|
-
container: HTMLElement | Object | Function
|
|
36
|
-
isFullPage: boolean
|
|
37
|
-
enforceFocus?: boolean
|
|
38
|
-
lockScroll: boolean
|
|
39
|
-
transition: string
|
|
40
|
-
/**
|
|
41
|
-
* Allow user to hide the loader
|
|
42
|
-
*/
|
|
43
|
-
canCancel: boolean
|
|
44
|
-
/**
|
|
45
|
-
* Do something on cancel
|
|
46
|
-
*/
|
|
47
|
-
onCancel: Function
|
|
48
|
-
color: string
|
|
49
|
-
backgroundColor: string
|
|
50
|
-
opacity: number
|
|
51
|
-
width: number
|
|
52
|
-
height: number
|
|
53
|
-
zIndex: number
|
|
54
|
-
loader: string
|
|
55
|
-
}>(),
|
|
56
|
-
{
|
|
57
|
-
isFullPage: true,
|
|
58
|
-
enforceFocus: true,
|
|
59
|
-
transition: 'fade',
|
|
60
|
-
onCancel: () => {},
|
|
61
|
-
loader: 'spinner'
|
|
62
|
-
}
|
|
63
|
-
)
|
|
64
|
-
const overlay = ref<HTMLDivElement>()
|
|
65
|
-
const isActive = ref<boolean>(props.active)
|
|
66
|
-
const emit = defineEmits(['hide', 'update:active'])
|
|
67
|
-
/**
|
|
68
|
-
* Proxy to hide() method.
|
|
69
|
-
* Gets called by ESC button or when click outside
|
|
70
|
-
*/
|
|
71
|
-
const cancel = () => {
|
|
72
|
-
if (!props.canCancel || !isActive.value) return
|
|
73
|
-
hide()
|
|
74
|
-
props.onCancel.apply(null, null)
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Hide and destroy component if it's programmatic.
|
|
78
|
-
*/
|
|
79
|
-
const hide = () => {
|
|
80
|
-
emit('hide')
|
|
81
|
-
emit('update:active', false)
|
|
82
|
-
|
|
83
|
-
if (props.programmatic) {
|
|
84
|
-
isActive.value = false
|
|
85
|
-
|
|
86
|
-
// Timeout for the animation complete before destroying
|
|
87
|
-
setTimeout(() => {
|
|
88
|
-
const parent = overlay.value!.parentElement
|
|
89
|
-
// unmount the component
|
|
90
|
-
render(null, parent!)
|
|
91
|
-
removeElement(parent)
|
|
92
|
-
}, 150)
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
const disableScroll = () => {
|
|
96
|
-
if (props.isFullPage && props.lockScroll) {
|
|
97
|
-
document.body.classList.add('vl-shown')
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
const enableScroll = () => {
|
|
101
|
-
if (props.isFullPage && props.lockScroll) {
|
|
102
|
-
document.body.classList.remove('vl-shown')
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Key press event to hide on ESC.
|
|
107
|
-
*/
|
|
108
|
-
const keyPress = (event: KeyboardEvent) => {
|
|
109
|
-
// todo keyCode is deprecated
|
|
110
|
-
if (event.code === 'Escape') cancel()
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const focusIn = (event: FocusEvent) => {
|
|
114
|
-
// Ignore when loading is not active
|
|
115
|
-
if (!isActive.value) return
|
|
116
|
-
|
|
117
|
-
if (
|
|
118
|
-
// Event target is the loading div element itself
|
|
119
|
-
event.target === overlay.value ||
|
|
120
|
-
// Event target is inside the loading div
|
|
121
|
-
// @ts-ignore
|
|
122
|
-
overlay.value!.contains(event.target)
|
|
123
|
-
)
|
|
124
|
-
return
|
|
125
|
-
|
|
126
|
-
// Use container as parent when available otherwise use parent element when isFullPage is false
|
|
127
|
-
const parent = props.container
|
|
128
|
-
? props.container
|
|
129
|
-
: props.isFullPage
|
|
130
|
-
? null
|
|
131
|
-
: overlay.value!.parentElement
|
|
132
|
-
|
|
133
|
-
if (
|
|
134
|
-
// Always prevent when loading is full screen
|
|
135
|
-
props.isFullPage ||
|
|
136
|
-
// When a parent exist means loader is running inside a container
|
|
137
|
-
// When loading is NOT full screen and event target is inside the given container
|
|
138
|
-
// @ts-ignore
|
|
139
|
-
(parent && parent.contains(event.target))
|
|
140
|
-
) {
|
|
141
|
-
event.preventDefault()
|
|
142
|
-
overlay.value!.focus()
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
const bgStyle = computed(() => {
|
|
147
|
-
return {
|
|
148
|
-
background: props.backgroundColor,
|
|
149
|
-
opacity: props.opacity
|
|
150
|
-
}
|
|
151
|
-
})
|
|
152
|
-
watch(
|
|
153
|
-
() => props.active,
|
|
154
|
-
(value) => {
|
|
155
|
-
isActive.value = value
|
|
156
|
-
}
|
|
157
|
-
)
|
|
158
|
-
watch(
|
|
159
|
-
() => isActive,
|
|
160
|
-
(value) => {
|
|
161
|
-
if (value) {
|
|
162
|
-
disableScroll()
|
|
163
|
-
} else {
|
|
164
|
-
enableScroll()
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
)
|
|
168
|
-
|
|
169
|
-
onMounted(() => {
|
|
170
|
-
if (props.enforceFocus) {
|
|
171
|
-
document.addEventListener('focusin', focusIn)
|
|
172
|
-
}
|
|
173
|
-
document.addEventListener('keyup', keyPress)
|
|
174
|
-
})
|
|
175
|
-
onBeforeUnmount(() => {
|
|
176
|
-
document.removeEventListener('keyup', keyPress)
|
|
177
|
-
document.removeEventListener('focusin', focusIn)
|
|
178
|
-
})
|
|
179
|
-
defineExpose({
|
|
180
|
-
hide
|
|
181
|
-
})
|
|
182
|
-
</script>
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { createComponent } from './helpers'
|
|
2
|
-
import LoadingComponent from './Component.vue'
|
|
3
|
-
|
|
4
|
-
export const useLoading = (globalProps = {}, globalSlots = {}) => {
|
|
5
|
-
return {
|
|
6
|
-
show(props = globalProps, slots = globalSlots) {
|
|
7
|
-
const forceProps = {
|
|
8
|
-
programmatic: true,
|
|
9
|
-
lockScroll: true,
|
|
10
|
-
isFullPage: false,
|
|
11
|
-
active: true
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const propsData = { ...globalProps, ...props, ...forceProps }
|
|
15
|
-
// @ts-ignore
|
|
16
|
-
let container = propsData.container
|
|
17
|
-
// @ts-ignore
|
|
18
|
-
if (!propsData.container) {
|
|
19
|
-
container = document.body
|
|
20
|
-
propsData.isFullPage = true
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const mergedSlots = { ...globalSlots, ...slots }
|
|
24
|
-
const instance = createComponent(LoadingComponent, propsData, container, mergedSlots)
|
|
25
|
-
|
|
26
|
-
return {
|
|
27
|
-
hide: instance!.exposed!.hide
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { h, render } from 'vue'
|
|
2
|
-
|
|
3
|
-
export const removeElement = (el: HTMLElement) => {
|
|
4
|
-
if (typeof el.remove !== 'undefined') {
|
|
5
|
-
el.remove()
|
|
6
|
-
} else {
|
|
7
|
-
el.parentNode?.removeChild(el)
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// Taken from https://github.com/moyoujun/vue3-loading-overlay/blob/master/src/index.ts
|
|
12
|
-
export function createComponent(
|
|
13
|
-
component: any,
|
|
14
|
-
props: any,
|
|
15
|
-
parentContainer: HTMLElement,
|
|
16
|
-
slots = {}
|
|
17
|
-
) {
|
|
18
|
-
const vNode = h(component, props, slots)
|
|
19
|
-
const container = document.createElement('div')
|
|
20
|
-
container.classList.add('vld-container')
|
|
21
|
-
parentContainer.appendChild(container)
|
|
22
|
-
render(vNode, container)
|
|
23
|
-
|
|
24
|
-
return vNode.component
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const hasWindow = () => {
|
|
28
|
-
return typeof window !== 'undefined'
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export const MayBeHTMLElement = hasWindow() ? window.HTMLElement : Object
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { useLoading } from './api'
|
|
2
|
-
import Component from './Component.vue'
|
|
3
|
-
import type { App } from 'vue'
|
|
4
|
-
|
|
5
|
-
const LoadingPlugin = (app: App, props = {}, slots = {}) => {
|
|
6
|
-
const instance = useLoading(props, slots)
|
|
7
|
-
// app.config.globalProperties.$loading = instance
|
|
8
|
-
app.provide('$loading', instance)
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export default Component
|
|
12
|
-
export { useLoading, LoadingPlugin, Component }
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<svg
|
|
3
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
4
|
-
viewBox="0 0 30 30"
|
|
5
|
-
:height="height"
|
|
6
|
-
:width="width"
|
|
7
|
-
:fill="color"
|
|
8
|
-
>
|
|
9
|
-
<rect x="0" y="13" width="4" height="5">
|
|
10
|
-
<animate
|
|
11
|
-
attributeName="height"
|
|
12
|
-
attributeType="XML"
|
|
13
|
-
values="5;21;5"
|
|
14
|
-
begin="0s"
|
|
15
|
-
dur="0.6s"
|
|
16
|
-
repeatCount="indefinite"
|
|
17
|
-
/>
|
|
18
|
-
<animate
|
|
19
|
-
attributeName="y"
|
|
20
|
-
attributeType="XML"
|
|
21
|
-
values="13; 5; 13"
|
|
22
|
-
begin="0s"
|
|
23
|
-
dur="0.6s"
|
|
24
|
-
repeatCount="indefinite"
|
|
25
|
-
/>
|
|
26
|
-
</rect>
|
|
27
|
-
<rect x="10" y="13" width="4" height="5">
|
|
28
|
-
<animate
|
|
29
|
-
attributeName="height"
|
|
30
|
-
attributeType="XML"
|
|
31
|
-
values="5;21;5"
|
|
32
|
-
begin="0.15s"
|
|
33
|
-
dur="0.6s"
|
|
34
|
-
repeatCount="indefinite"
|
|
35
|
-
/>
|
|
36
|
-
<animate
|
|
37
|
-
attributeName="y"
|
|
38
|
-
attributeType="XML"
|
|
39
|
-
values="13; 5; 13"
|
|
40
|
-
begin="0.15s"
|
|
41
|
-
dur="0.6s"
|
|
42
|
-
repeatCount="indefinite"
|
|
43
|
-
/>
|
|
44
|
-
</rect>
|
|
45
|
-
<rect x="20" y="13" width="4" height="5">
|
|
46
|
-
<animate
|
|
47
|
-
attributeName="height"
|
|
48
|
-
attributeType="XML"
|
|
49
|
-
values="5;21;5"
|
|
50
|
-
begin="0.3s"
|
|
51
|
-
dur="0.6s"
|
|
52
|
-
repeatCount="indefinite"
|
|
53
|
-
/>
|
|
54
|
-
<animate
|
|
55
|
-
attributeName="y"
|
|
56
|
-
attributeType="XML"
|
|
57
|
-
values="13; 5; 13"
|
|
58
|
-
begin="0.3s"
|
|
59
|
-
dur="0.6s"
|
|
60
|
-
repeatCount="indefinite"
|
|
61
|
-
/>
|
|
62
|
-
</rect>
|
|
63
|
-
</svg>
|
|
64
|
-
</template>
|
|
65
|
-
<script lang="ts" setup>
|
|
66
|
-
import { withDefaults } from 'vue'
|
|
67
|
-
withDefaults(
|
|
68
|
-
defineProps<{
|
|
69
|
-
color?: string
|
|
70
|
-
height?: number
|
|
71
|
-
width?: number
|
|
72
|
-
}>(),
|
|
73
|
-
{
|
|
74
|
-
color: '#000',
|
|
75
|
-
height: 40,
|
|
76
|
-
width: 40
|
|
77
|
-
}
|
|
78
|
-
)
|
|
79
|
-
</script>
|