vue-stack-tabs 0.1.11 → 0.1.13

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.
Files changed (72) hide show
  1. package/{types → dist}/src/lib/hooks/useStackTab.d.ts +2 -2
  2. package/{types → dist}/src/lib/hooks/useTabpanel.d.ts +6 -2
  3. package/{types → dist}/src/lib/index.d.ts +7 -1
  4. package/{types → dist}/src/lib/model/TabModel.d.ts +2 -1
  5. package/dist/style.css +1 -1
  6. package/dist/vue-stack-tabs.es.js +2340 -2321
  7. package/dist/vue-stack-tabs.umd.js +10 -10
  8. package/package.json +3 -4
  9. package/src/lib/StackTabs.vue +136 -126
  10. package/src/lib/assets/style/common/mixins.scss +45 -45
  11. package/src/lib/assets/style/common/var.scss +65 -65
  12. package/src/lib/assets/style/icon.scss +93 -93
  13. package/src/lib/assets/style/index.scss +4 -4
  14. package/src/lib/assets/style/overlayer.scss +40 -40
  15. package/src/lib/assets/style/stackTab.scss +395 -395
  16. package/src/lib/assets/style/transition.scss +40 -40
  17. package/src/lib/banner.ts +51 -51
  18. package/src/lib/components/ContextMenu/ContextMenuItem.vue +15 -15
  19. package/src/lib/components/ContextMenu/index.vue +129 -129
  20. package/src/lib/components/OverlayLoading/Component.vue +182 -191
  21. package/src/lib/components/OverlayLoading/api.ts +31 -31
  22. package/src/lib/components/OverlayLoading/helpers.ts +31 -31
  23. package/src/lib/components/OverlayLoading/index.ts +12 -12
  24. package/src/lib/components/OverlayLoading/loaders/bars.vue +79 -79
  25. package/src/lib/components/OverlayLoading/loaders/dots.vue +92 -92
  26. package/src/lib/components/OverlayLoading/loaders/index.ts +9 -9
  27. package/src/lib/components/OverlayLoading/loaders/spinner.vue +41 -41
  28. package/src/lib/components/TabHeader/TabHeaderButton.vue +35 -35
  29. package/src/lib/components/TabHeader/TabHeaderItem.vue +63 -63
  30. package/src/lib/components/TabHeader/TabHeaderScroll.vue +240 -240
  31. package/src/lib/components/TabHeader/index.vue +135 -135
  32. package/src/lib/hooks/useContextMenu.ts +50 -50
  33. package/src/lib/hooks/useStackTab.ts +74 -65
  34. package/src/lib/hooks/useTabLoading.ts +34 -34
  35. package/src/lib/hooks/useTabRouter.ts +94 -94
  36. package/src/lib/hooks/useTabpanel.tsx +516 -491
  37. package/src/lib/i18n/index.ts +72 -72
  38. package/src/lib/i18n/lang/en.ts +15 -15
  39. package/src/lib/i18n/lang/zh-CN.ts +15 -15
  40. package/src/lib/iframe.vue +7 -7
  41. package/src/lib/index.ts +32 -23
  42. package/src/lib/model/TabModel.ts +178 -169
  43. package/src/lib/utils/TabIdHelper.ts +70 -70
  44. package/src/lib/utils/TabScrollHelper.ts +104 -104
  45. package/src/lib/utils/UriHelper.ts +22 -22
  46. /package/{types → dist}/index.d.ts +0 -0
  47. /package/{types → dist}/src/lib/StackTabs.vue.d.ts +0 -0
  48. /package/{types → dist}/src/lib/banner.d.ts +0 -0
  49. /package/{types → dist}/src/lib/components/ContextMenu/ContextMenuItem.vue.d.ts +0 -0
  50. /package/{types → dist}/src/lib/components/ContextMenu/index.vue.d.ts +0 -0
  51. /package/{types → dist}/src/lib/components/OverlayLoading/Component.vue.d.ts +0 -0
  52. /package/{types → dist}/src/lib/components/OverlayLoading/api.d.ts +0 -0
  53. /package/{types → dist}/src/lib/components/OverlayLoading/helpers.d.ts +0 -0
  54. /package/{types → dist}/src/lib/components/OverlayLoading/index.d.ts +0 -0
  55. /package/{types → dist}/src/lib/components/OverlayLoading/loaders/bars.vue.d.ts +0 -0
  56. /package/{types → dist}/src/lib/components/OverlayLoading/loaders/dots.vue.d.ts +0 -0
  57. /package/{types → dist}/src/lib/components/OverlayLoading/loaders/index.d.ts +0 -0
  58. /package/{types → dist}/src/lib/components/OverlayLoading/loaders/spinner.vue.d.ts +0 -0
  59. /package/{types → dist}/src/lib/components/TabHeader/TabHeaderButton.vue.d.ts +0 -0
  60. /package/{types → dist}/src/lib/components/TabHeader/TabHeaderItem.vue.d.ts +0 -0
  61. /package/{types → dist}/src/lib/components/TabHeader/TabHeaderScroll.vue.d.ts +0 -0
  62. /package/{types → dist}/src/lib/components/TabHeader/index.vue.d.ts +0 -0
  63. /package/{types → dist}/src/lib/hooks/useContextMenu.d.ts +0 -0
  64. /package/{types → dist}/src/lib/hooks/useTabLoading.d.ts +0 -0
  65. /package/{types → dist}/src/lib/hooks/useTabRouter.d.ts +0 -0
  66. /package/{types → dist}/src/lib/i18n/index.d.ts +0 -0
  67. /package/{types → dist}/src/lib/i18n/lang/en.d.ts +0 -0
  68. /package/{types → dist}/src/lib/i18n/lang/zh-CN.d.ts +0 -0
  69. /package/{types → dist}/src/lib/iframe.vue.d.ts +0 -0
  70. /package/{types → dist}/src/lib/utils/TabIdHelper.d.ts +0 -0
  71. /package/{types → dist}/src/lib/utils/TabScrollHelper.d.ts +0 -0
  72. /package/{types → dist}/src/lib/utils/UriHelper.d.ts +0 -0
@@ -1,191 +1,182 @@
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 {
28
- defineProps,
29
- withDefaults,
30
- render,
31
- ref,
32
- onMounted,
33
- onBeforeUnmount,
34
- computed,
35
- watch
36
- } from 'vue'
37
- import { removeElement } from './helpers'
38
- import Loaders from './loaders'
39
-
40
- const props = withDefaults(
41
- defineProps<{
42
- active: boolean
43
- programmatic: boolean
44
- container: HTMLElement | Object | Function
45
- isFullPage: boolean
46
- enforceFocus?: boolean
47
- lockScroll: boolean
48
- transition: string
49
- /**
50
- * Allow user to hide the loader
51
- */
52
- canCancel: boolean
53
- /**
54
- * Do something on cancel
55
- */
56
- onCancel: Function
57
- color: string
58
- backgroundColor: string
59
- opacity: number
60
- width: number
61
- height: number
62
- zIndex: number
63
- loader: string
64
- }>(),
65
- {
66
- isFullPage: true,
67
- enforceFocus: true,
68
- transition: 'fade',
69
- onCancel: () => {},
70
- loader: 'spinner'
71
- }
72
- )
73
- const overlay = ref<HTMLDivElement>()
74
- const isActive = ref<boolean>(props.active)
75
- const emit = defineEmits(['hide', 'update:active'])
76
- /**
77
- * Proxy to hide() method.
78
- * Gets called by ESC button or when click outside
79
- */
80
- const cancel = () => {
81
- if (!props.canCancel || !isActive.value) return
82
- hide()
83
- props.onCancel.apply(null, null)
84
- }
85
- /**
86
- * Hide and destroy component if it's programmatic.
87
- */
88
- const hide = () => {
89
- emit('hide')
90
- emit('update:active', false)
91
-
92
- if (props.programmatic) {
93
- isActive.value = false
94
-
95
- // Timeout for the animation complete before destroying
96
- setTimeout(() => {
97
- const parent = overlay.value!.parentElement
98
- // unmount the component
99
- render(null, parent!)
100
- removeElement(parent)
101
- }, 150)
102
- }
103
- }
104
- const disableScroll = () => {
105
- if (props.isFullPage && props.lockScroll) {
106
- document.body.classList.add('vl-shown')
107
- }
108
- }
109
- const enableScroll = () => {
110
- if (props.isFullPage && props.lockScroll) {
111
- document.body.classList.remove('vl-shown')
112
- }
113
- }
114
- /**
115
- * Key press event to hide on ESC.
116
- */
117
- const keyPress = (event: KeyboardEvent) => {
118
- // todo keyCode is deprecated
119
- if (event.code === 'Escape') cancel()
120
- }
121
-
122
- const focusIn = (event: FocusEvent) => {
123
- // Ignore when loading is not active
124
- if (!isActive.value) return
125
-
126
- if (
127
- // Event target is the loading div element itself
128
- event.target === overlay.value ||
129
- // Event target is inside the loading div
130
- // @ts-ignore
131
- overlay.value!.contains(event.target)
132
- )
133
- return
134
-
135
- // Use container as parent when available otherwise use parent element when isFullPage is false
136
- const parent = props.container
137
- ? props.container
138
- : props.isFullPage
139
- ? null
140
- : overlay.value!.parentElement
141
-
142
- if (
143
- // Always prevent when loading is full screen
144
- props.isFullPage ||
145
- // When a parent exist means loader is running inside a container
146
- // When loading is NOT full screen and event target is inside the given container
147
- // @ts-ignore
148
- (parent && parent.contains(event.target))
149
- ) {
150
- event.preventDefault()
151
- overlay.value!.focus()
152
- }
153
- }
154
-
155
- const bgStyle = computed(() => {
156
- return {
157
- background: props.backgroundColor,
158
- opacity: props.opacity
159
- }
160
- })
161
- watch(
162
- () => props.active,
163
- (value) => {
164
- isActive.value = value
165
- }
166
- )
167
- watch(
168
- () => isActive,
169
- (value) => {
170
- if (value) {
171
- disableScroll()
172
- } else {
173
- enableScroll()
174
- }
175
- }
176
- )
177
-
178
- onMounted(() => {
179
- if (props.enforceFocus) {
180
- document.addEventListener('focusin', focusIn)
181
- }
182
- document.addEventListener('keyup', keyPress)
183
- })
184
- onBeforeUnmount(() => {
185
- document.removeEventListener('keyup', keyPress)
186
- document.removeEventListener('focusin', focusIn)
187
- })
188
- defineExpose({
189
- hide
190
- })
191
- </script>
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 +1,31 @@
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
+ 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 +1,31 @@
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
+ 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 +1,12 @@
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
+ 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 }