vue-stack-tabs 0.1.6 → 0.1.8

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.6",
3
+ "version": "0.1.8",
4
4
  "description": "Vue.js component for router tab.",
5
5
  "private": false,
6
6
  "type": "module",
@@ -34,7 +34,7 @@ import {
34
34
  watch
35
35
  } from 'vue'
36
36
  import { removeElement } from './helpers'
37
- import Loaders from '../loaders'
37
+ import Loaders from './loaders'
38
38
 
39
39
  const props = withDefaults(
40
40
  defineProps<{
@@ -42,7 +42,7 @@ const props = withDefaults(
42
42
  programmatic: boolean
43
43
  container: HTMLElement | Object | Function
44
44
  isFullPage: boolean
45
- enforceFocus: boolean
45
+ enforceFocus?: boolean
46
46
  lockScroll: boolean
47
47
  transition: string
48
48
  /**
@@ -182,4 +182,7 @@ onBeforeUnmount(() => {
182
182
  document.removeEventListener('keyup', keyPress)
183
183
  document.removeEventListener('focusin', focusIn)
184
184
  })
185
+ defineExpose({
186
+ hide
187
+ })
185
188
  </script>
@@ -12,8 +12,9 @@ export const useLoading = (globalProps = {}, globalSlots = {}) => {
12
12
  }
13
13
 
14
14
  const propsData = { ...globalProps, ...props, ...forceProps }
15
+ // @ts-ignore
15
16
  let container = propsData.container
16
-
17
+ // @ts-ignore
17
18
  if (!propsData.container) {
18
19
  container = document.body
19
20
  propsData.isFullPage = true
@@ -23,7 +24,7 @@ export const useLoading = (globalProps = {}, globalSlots = {}) => {
23
24
  const instance = createComponent(LoadingComponent, propsData, container, mergedSlots)
24
25
 
25
26
  return {
26
- hide: instance.ctx.hide
27
+ hide: instance!.exposed!.hide
27
28
  }
28
29
  }
29
30
  }
@@ -1,6 +1,6 @@
1
1
  import { h, render } from 'vue'
2
2
 
3
- export const removeElement = (el) => {
3
+ export const removeElement = (el: HTMLElement) => {
4
4
  if (typeof el.remove !== 'undefined') {
5
5
  el.remove()
6
6
  } else {
@@ -9,7 +9,12 @@ export const removeElement = (el) => {
9
9
  }
10
10
 
11
11
  // Taken from https://github.com/moyoujun/vue3-loading-overlay/blob/master/src/index.ts
12
- export function createComponent(component, props, parentContainer, slots = {}) {
12
+ export function createComponent(
13
+ component: any,
14
+ props: any,
15
+ parentContainer: HTMLElement,
16
+ slots = {}
17
+ ) {
13
18
  const vNode = h(component, props, slots)
14
19
  const container = document.createElement('div')
15
20
  container.classList.add('vld-container')
@@ -1,5 +1,5 @@
1
- import { useLoading } from './js/api'
2
- import Component from './js/Component.vue'
1
+ import { useLoading } from './api'
2
+ import Component from './Component.vue'
3
3
  import type { App } from 'vue'
4
4
 
5
5
  const LoadingPlugin = (app: App, props = {}, slots = {}) => {
@@ -194,17 +194,18 @@ export default () => {
194
194
  let activeTabId = ''
195
195
  for (let i = tabs.value.length - 1; i >= 0; i--) {
196
196
  if (id === unref(tabs)[i].id) {
197
+ //if it's not closable then return
197
198
  if (!unref(tabs)[i].closable) {
198
- break
199
+ return id
199
200
  }
200
201
  for (const item of unref(tabs)[i].pages.list()) {
201
202
  removeComponent(item.id)
202
203
  markDeletableCache(item.id)
203
204
  }
204
205
  unref(tabs)[i].pages.clear()
205
- if (tabs.value.length > 1) {
206
+ if (tabs.value.length > 1 && unref(tabs)[i].active) {
206
207
  if (i === 0) {
207
- activeTabId = unref(tabs)[1].id
208
+ activeTabId = unref(tabs)[i + 1].id
208
209
  } else {
209
210
  activeTabId = unref(tabs)[i - 1].id
210
211
  }
@@ -214,11 +215,11 @@ export default () => {
214
215
  break
215
216
  }
216
217
  }
217
- active(activeTabId)
218
- // if remove inactive tab,then we need remove the cache manually.
219
- if (activeTabId !== id) {
220
- removeDeletableCache()
218
+ if (activeTabId !== '') {
219
+ active(activeTabId)
221
220
  }
221
+ // if remove inactive tab,then we need remove the cache manually.
222
+ removeDeletableCache()
222
223
  return activeTabId
223
224
  }
224
225