vue-stack-tabs 0.1.4 → 0.1.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-stack-tabs",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Vue.js component for router tab.",
5
5
  "private": false,
6
6
  "type": "module",
@@ -39,8 +39,7 @@
39
39
  "lz-string": "^1.5.0",
40
40
  "ulidx": "^2.3.0",
41
41
  "uuid": "^9.0.1",
42
- "vue-i18n": "^9.10.1",
43
- "vue-loading-overlay": "^6.0.4"
42
+ "vue-i18n": "^9.10.1"
44
43
  },
45
44
  "devDependencies": {
46
45
  "@mdit/plugin-tasklist": "^0.8.0",
@@ -77,8 +76,7 @@
77
76
  "vitepress": "1.0.0-rc.44",
78
77
  "vue-tsc": "^1.8.27",
79
78
  "vue-router": "^4.3.0",
80
- "vue": "^3.4.21",
81
- "vue-stack-tabs": "^0.1.4"
79
+ "vue": "^3.4.21"
82
80
  },
83
81
  "scripts": {
84
82
  "docs:dev": "vitepress dev docs",
@@ -39,7 +39,6 @@
39
39
  </template>
40
40
 
41
41
  <script lang="tsx" setup>
42
- import 'vue-loading-overlay/dist/css/index.css'
43
42
  import { onBeforeMount, onUnmounted, provide, ref, watch } from 'vue'
44
43
  import type { TransitionProps, DefineComponent, VNode } from 'vue'
45
44
  import { type RouteLocationNormalizedLoaded, useRouter } from 'vue-router'
@@ -1,3 +1,4 @@
1
1
  @import 'stackTab';
2
2
  @import 'icon';
3
3
  @import 'transition';
4
+ @import 'overlayer';
@@ -0,0 +1,40 @@
1
+ .vl-shown {
2
+ overflow: hidden;
3
+ }
4
+
5
+ .vl-overlay {
6
+ bottom: 0;
7
+ left: 0;
8
+ position: absolute;
9
+ right: 0;
10
+ top: 0;
11
+ align-items: center;
12
+ display: none;
13
+ justify-content: center;
14
+ overflow: hidden;
15
+ z-index: 9999;
16
+ }
17
+
18
+ .vl-overlay.vl-active {
19
+ display: flex;
20
+ }
21
+
22
+ .vl-overlay.vl-full-page {
23
+ z-index: 9999;
24
+ position: fixed;
25
+ }
26
+
27
+ .vl-overlay .vl-background {
28
+ bottom: 0;
29
+ left: 0;
30
+ position: absolute;
31
+ right: 0;
32
+ top: 0;
33
+ background: #fff;
34
+ opacity: 0.5;
35
+ }
36
+
37
+ .vl-overlay .vl-icon,
38
+ .vl-parent {
39
+ position: relative;
40
+ }
@@ -0,0 +1,12 @@
1
+ import { useLoading } from './js/api'
2
+ import Component from './js/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 }
@@ -0,0 +1,185 @@
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
+ import {
27
+ defineProps,
28
+ withDefaults,
29
+ render,
30
+ ref,
31
+ onMounted,
32
+ onBeforeUnmount,
33
+ computed,
34
+ watch
35
+ } from 'vue'
36
+ import { removeElement } from './helpers'
37
+ import Loaders from '../loaders'
38
+
39
+ const props = withDefaults(
40
+ defineProps<{
41
+ active: boolean
42
+ programmatic: boolean
43
+ container: HTMLElement | Object | Function
44
+ isFullPage: boolean
45
+ enforceFocus: boolean
46
+ lockScroll: boolean
47
+ transition: string
48
+ /**
49
+ * Allow user to hide the loader
50
+ */
51
+ canCancel: boolean
52
+ /**
53
+ * Do something on cancel
54
+ */
55
+ onCancel: Function
56
+ color: string
57
+ backgroundColor: string
58
+ opacity: number
59
+ width: number
60
+ height: number
61
+ zIndex: number
62
+ loader: string
63
+ }>(),
64
+ {
65
+ isFullPage: true,
66
+ enforceFocus: true,
67
+ transition: 'fade',
68
+ onCancel: () => {},
69
+ loader: 'spinner'
70
+ }
71
+ )
72
+ const overlay = ref<HTMLDivElement>()
73
+ const isActive = ref<boolean>(props.active)
74
+ const emit = defineEmits(['hide', 'update:active'])
75
+ /**
76
+ * Proxy to hide() method.
77
+ * Gets called by ESC button or when click outside
78
+ */
79
+ const cancel = () => {
80
+ if (!props.canCancel || !isActive.value) return
81
+ hide()
82
+ props.onCancel.apply(null, null)
83
+ }
84
+ /**
85
+ * Hide and destroy component if it's programmatic.
86
+ */
87
+ const hide = () => {
88
+ emit('hide')
89
+ emit('update:active', false)
90
+
91
+ if (props.programmatic) {
92
+ isActive.value = false
93
+
94
+ // Timeout for the animation complete before destroying
95
+ setTimeout(() => {
96
+ const parent = overlay.value!.parentElement
97
+ // unmount the component
98
+ render(null, parent!)
99
+ removeElement(parent)
100
+ }, 150)
101
+ }
102
+ }
103
+ const disableScroll = () => {
104
+ if (props.isFullPage && props.lockScroll) {
105
+ document.body.classList.add('vl-shown')
106
+ }
107
+ }
108
+ const enableScroll = () => {
109
+ if (props.isFullPage && props.lockScroll) {
110
+ document.body.classList.remove('vl-shown')
111
+ }
112
+ }
113
+ /**
114
+ * Key press event to hide on ESC.
115
+ */
116
+ const keyPress = (event: KeyboardEvent) => {
117
+ // todo keyCode is deprecated
118
+ if (event.code === 'Escape') cancel()
119
+ }
120
+
121
+ const focusIn = (event: FocusEvent) => {
122
+ // Ignore when loading is not active
123
+ if (!isActive.value) return
124
+
125
+ if (
126
+ // Event target is the loading div element itself
127
+ event.target === overlay.value ||
128
+ // Event target is inside the loading div
129
+ overlay.value!.contains(event.target)
130
+ )
131
+ return
132
+
133
+ // Use container as parent when available otherwise use parent element when isFullPage is false
134
+ const parent = props.container
135
+ ? props.container
136
+ : props.isFullPage
137
+ ? null
138
+ : overlay.value!.parentElement
139
+
140
+ if (
141
+ // Always prevent when loading is full screen
142
+ props.isFullPage ||
143
+ // When a parent exist means loader is running inside a container
144
+ // When loading is NOT full screen and event target is inside the given container
145
+ (parent && parent.contains(event.target))
146
+ ) {
147
+ event.preventDefault()
148
+ overlay.value!.focus()
149
+ }
150
+ }
151
+
152
+ const bgStyle = computed(() => {
153
+ return {
154
+ background: props.backgroundColor,
155
+ opacity: props.opacity
156
+ }
157
+ })
158
+ watch(
159
+ () => props.active,
160
+ (value) => {
161
+ isActive.value = value
162
+ }
163
+ )
164
+ watch(
165
+ () => isActive,
166
+ (value) => {
167
+ if (value) {
168
+ disableScroll()
169
+ } else {
170
+ enableScroll()
171
+ }
172
+ }
173
+ )
174
+
175
+ onMounted(() => {
176
+ if (props.enforceFocus) {
177
+ document.addEventListener('focusin', focusIn)
178
+ }
179
+ document.addEventListener('keyup', keyPress)
180
+ })
181
+ onBeforeUnmount(() => {
182
+ document.removeEventListener('keyup', keyPress)
183
+ document.removeEventListener('focusin', focusIn)
184
+ })
185
+ </script>
@@ -0,0 +1,30 @@
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
+ let container = propsData.container
16
+
17
+ if (!propsData.container) {
18
+ container = document.body
19
+ propsData.isFullPage = true
20
+ }
21
+
22
+ const mergedSlots = { ...globalSlots, ...slots }
23
+ const instance = createComponent(LoadingComponent, propsData, container, mergedSlots)
24
+
25
+ return {
26
+ hide: instance.ctx.hide
27
+ }
28
+ }
29
+ }
30
+ }
@@ -0,0 +1,26 @@
1
+ import { h, render } from 'vue'
2
+
3
+ export const removeElement = (el) => {
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(component, props, parentContainer, slots = {}) {
13
+ const vNode = h(component, props, slots)
14
+ const container = document.createElement('div')
15
+ container.classList.add('vld-container')
16
+ parentContainer.appendChild(container)
17
+ render(vNode, container)
18
+
19
+ return vNode.component
20
+ }
21
+
22
+ export const hasWindow = () => {
23
+ return typeof window !== 'undefined'
24
+ }
25
+
26
+ export const MayBeHTMLElement = hasWindow() ? window.HTMLElement : Object
@@ -0,0 +1,79 @@
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 { defineProps, 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>
@@ -0,0 +1,92 @@
1
+ <template>
2
+ <svg
3
+ viewBox="0 0 120 30"
4
+ xmlns="http://www.w3.org/2000/svg"
5
+ :fill="color"
6
+ :width="width"
7
+ :height="height"
8
+ >
9
+ <circle cx="15" cy="15" r="15">
10
+ <animate
11
+ attributeName="r"
12
+ from="15"
13
+ to="15"
14
+ begin="0s"
15
+ dur="0.8s"
16
+ values="15;9;15"
17
+ calcMode="linear"
18
+ repeatCount="indefinite"
19
+ />
20
+ <animate
21
+ attributeName="fill-opacity"
22
+ from="1"
23
+ to="1"
24
+ begin="0s"
25
+ dur="0.8s"
26
+ values="1;.5;1"
27
+ calcMode="linear"
28
+ repeatCount="indefinite"
29
+ />
30
+ </circle>
31
+ <circle cx="60" cy="15" r="9" fill-opacity="0.3">
32
+ <animate
33
+ attributeName="r"
34
+ from="9"
35
+ to="9"
36
+ begin="0s"
37
+ dur="0.8s"
38
+ values="9;15;9"
39
+ calcMode="linear"
40
+ repeatCount="indefinite"
41
+ />
42
+ <animate
43
+ attributeName="fill-opacity"
44
+ from="0.5"
45
+ to="0.5"
46
+ begin="0s"
47
+ dur="0.8s"
48
+ values=".5;1;.5"
49
+ calcMode="linear"
50
+ repeatCount="indefinite"
51
+ />
52
+ </circle>
53
+ <circle cx="105" cy="15" r="15">
54
+ <animate
55
+ attributeName="r"
56
+ from="15"
57
+ to="15"
58
+ begin="0s"
59
+ dur="0.8s"
60
+ values="15;9;15"
61
+ calcMode="linear"
62
+ repeatCount="indefinite"
63
+ />
64
+ <animate
65
+ attributeName="fill-opacity"
66
+ from="1"
67
+ to="1"
68
+ begin="0s"
69
+ dur="0.8s"
70
+ values="1;.5;1"
71
+ calcMode="linear"
72
+ repeatCount="indefinite"
73
+ />
74
+ </circle>
75
+ </svg>
76
+ </template>
77
+
78
+ <script lang="ts" setup>
79
+ import { defineProps, withDefaults } from 'vue'
80
+ withDefaults(
81
+ defineProps<{
82
+ color?: string
83
+ height?: number
84
+ width?: number
85
+ }>(),
86
+ {
87
+ color: '#000',
88
+ height: 240,
89
+ width: 60
90
+ }
91
+ )
92
+ </script>
@@ -0,0 +1,9 @@
1
+ import Spinner from './spinner.vue'
2
+ import Dots from './dots.vue'
3
+ import Bars from './bars.vue'
4
+
5
+ export default {
6
+ spinner: Spinner,
7
+ dots: Dots,
8
+ bars: Bars
9
+ }
@@ -0,0 +1,41 @@
1
+ <template>
2
+ <svg
3
+ viewBox="0 0 38 38"
4
+ xmlns="http://www.w3.org/2000/svg"
5
+ :width="width"
6
+ :height="height"
7
+ :stroke="color"
8
+ >
9
+ <g fill="none" fill-rule="evenodd">
10
+ <g transform="translate(1 1)" stroke-width="2">
11
+ <circle stroke-opacity=".25" cx="18" cy="18" r="18" />
12
+ <path d="M36 18c0-9.94-8.06-18-18-18">
13
+ <animateTransform
14
+ attributeName="transform"
15
+ type="rotate"
16
+ from="0 18 18"
17
+ to="360 18 18"
18
+ dur="0.8s"
19
+ repeatCount="indefinite"
20
+ />
21
+ </path>
22
+ </g>
23
+ </g>
24
+ </svg>
25
+ </template>
26
+
27
+ <script lang="ts" setup>
28
+ import { defineProps, withDefaults } from 'vue'
29
+ withDefaults(
30
+ defineProps<{
31
+ color?: string
32
+ height?: number
33
+ width?: number
34
+ }>(),
35
+ {
36
+ color: '#000',
37
+ height: 64,
38
+ width: 64
39
+ }
40
+ )
41
+ </script>
@@ -32,7 +32,7 @@ export default () => {
32
32
  if (!tabInfo.id) {
33
33
  tabInfo.id = ulid()
34
34
  }
35
- const __tab = await encodeTabInfo(tabInfo)
35
+ const __tab = encodeTabInfo(tabInfo)
36
36
  let query = defu(
37
37
  {
38
38
  __tab
@@ -1,4 +1,4 @@
1
- import { useLoading } from 'vue-loading-overlay'
1
+ import { useLoading } from '../components/OverlayLoading'
2
2
  import type { ActiveLoader } from 'vue-loading-overlay'
3
3
  import { type ComponentInternalInstance, getCurrentInstance, onUnmounted } from 'vue'
4
4
 
@@ -11,19 +11,6 @@ export default () => {
11
11
  })
12
12
  const openTabLoading = () => {
13
13
  const container = document.querySelector(`#${attrs.tId}`)
14
- // const wrappers = document.getElementsByClassName('cache-page-wrapper')
15
- // for(const wrapper of wrappers){
16
- // const childs = wrapper.children
17
- // for(const child of childs){
18
- // if(child.getAttribute("tId")===attrs.tId){
19
- // container=wrapper
20
- // break;
21
- // }
22
- // }
23
- // if(container!==null){
24
- // break;
25
- // }
26
- // }
27
14
  if (loadingInstance === null) {
28
15
  loadingInstance = $loading.show({
29
16
  canCancel: false,