vue-stack-tabs 0.1.8 → 0.1.10

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 (76) hide show
  1. package/README.md +2 -2
  2. package/dist/favicon.svg +9 -9
  3. package/dist/style.css +1 -1
  4. package/dist/vue-stack-tabs.es.js +727 -757
  5. package/dist/vue-stack-tabs.umd.js +10 -10
  6. package/package.json +4 -4
  7. package/src/lib/StackTabs.vue +126 -127
  8. package/src/lib/assets/style/common/mixins.scss +45 -45
  9. package/src/lib/assets/style/common/var.scss +65 -65
  10. package/src/lib/assets/style/icon.scss +93 -93
  11. package/src/lib/assets/style/index.scss +4 -4
  12. package/src/lib/assets/style/overlayer.scss +40 -40
  13. package/src/lib/assets/style/stackTab.scss +395 -395
  14. package/src/lib/assets/style/transition.scss +40 -40
  15. package/src/lib/banner.ts +51 -51
  16. package/src/lib/components/ContextMenu/ContextMenuItem.vue +15 -15
  17. package/src/lib/components/ContextMenu/index.vue +129 -128
  18. package/src/lib/components/OverlayLoading/Component.vue +191 -188
  19. package/src/lib/components/OverlayLoading/api.ts +31 -31
  20. package/src/lib/components/OverlayLoading/helpers.ts +31 -31
  21. package/src/lib/components/OverlayLoading/index.ts +12 -12
  22. package/src/lib/components/OverlayLoading/loaders/bars.vue +79 -79
  23. package/src/lib/components/OverlayLoading/loaders/dots.vue +92 -92
  24. package/src/lib/components/OverlayLoading/loaders/index.ts +9 -9
  25. package/src/lib/components/OverlayLoading/loaders/spinner.vue +41 -41
  26. package/src/lib/components/TabHeader/TabHeaderButton.vue +35 -35
  27. package/src/lib/components/TabHeader/TabHeaderItem.vue +63 -63
  28. package/src/lib/components/TabHeader/TabHeaderScroll.vue +240 -240
  29. package/src/lib/components/TabHeader/index.vue +135 -134
  30. package/src/lib/hooks/useContextMenu.ts +50 -50
  31. package/src/lib/hooks/useStackTab.ts +65 -65
  32. package/src/lib/hooks/useTabLoading.ts +34 -35
  33. package/src/lib/hooks/useTabRouter.ts +94 -95
  34. package/src/lib/hooks/useTabpanel.tsx +490 -490
  35. package/src/lib/i18n/index.ts +72 -72
  36. package/src/lib/i18n/lang/en.ts +15 -15
  37. package/src/lib/i18n/lang/zh-CN.ts +15 -15
  38. package/src/lib/iframe.vue +7 -7
  39. package/src/lib/index.ts +23 -23
  40. package/src/lib/model/TabModel.ts +169 -182
  41. package/src/lib/utils/TabIdHelper.ts +70 -70
  42. package/src/lib/utils/TabScrollHelper.ts +104 -104
  43. package/src/lib/utils/UriHelper.ts +22 -22
  44. package/types/index.d.ts +3 -11
  45. package/types/src/lib/StackTabs.vue.d.ts +122 -0
  46. package/types/src/lib/components/ContextMenu/ContextMenuItem.vue.d.ts +17 -0
  47. package/types/src/lib/components/ContextMenu/index.vue.d.ts +45 -0
  48. package/types/src/lib/components/OverlayLoading/Component.vue.d.ts +100 -0
  49. package/types/src/lib/components/OverlayLoading/api.d.ts +5 -0
  50. package/types/src/lib/components/OverlayLoading/helpers.d.ts +7 -0
  51. package/types/src/lib/components/OverlayLoading/index.d.ts +6 -0
  52. package/types/src/lib/components/OverlayLoading/loaders/bars.vue.d.ts +39 -0
  53. package/types/src/lib/components/OverlayLoading/loaders/dots.vue.d.ts +39 -0
  54. package/types/src/lib/components/OverlayLoading/loaders/index.d.ts +96 -0
  55. package/types/src/lib/components/OverlayLoading/loaders/spinner.vue.d.ts +39 -0
  56. package/types/src/lib/components/TabHeader/TabHeaderButton.vue.d.ts +48 -0
  57. package/types/src/lib/components/TabHeader/TabHeaderItem.vue.d.ts +21 -0
  58. package/types/src/lib/components/TabHeader/TabHeaderScroll.vue.d.ts +49 -0
  59. package/types/src/lib/components/TabHeader/index.vue.d.ts +64 -0
  60. package/types/src/lib/hooks/useContextMenu.d.ts +13 -0
  61. package/types/src/lib/hooks/useStackTab.d.ts +8 -0
  62. package/types/{hooks → src/lib/hooks}/useTabRouter.d.ts +2 -1
  63. package/types/src/lib/hooks/useTabpanel.d.ts +68 -0
  64. package/types/src/lib/i18n/index.d.ts +4 -0
  65. package/types/src/lib/i18n/lang/en.d.ts +16 -0
  66. package/types/src/lib/i18n/lang/zh-CN.d.ts +16 -0
  67. package/types/src/lib/iframe.vue.d.ts +2 -0
  68. package/types/src/lib/index.d.ts +12 -0
  69. package/types/{model → src/lib/model}/TabModel.d.ts +0 -20
  70. package/types/src/lib/utils/TabScrollHelper.d.ts +33 -0
  71. package/types/hooks/useStackTab.d.ts +0 -9
  72. package/types/iframe.vue.d.ts +0 -2
  73. /package/types/{banner.d.ts → src/lib/banner.d.ts} +0 -0
  74. /package/types/{hooks → src/lib/hooks}/useTabLoading.d.ts +0 -0
  75. /package/types/{utils → src/lib/utils}/TabIdHelper.d.ts +0 -0
  76. /package/types/{utils → src/lib/utils}/UriHelper.d.ts +0 -0
@@ -1,188 +1,191 @@
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
- defineExpose({
186
- hide
187
- })
188
- </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 {
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,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 }