vue-stack-tabs 0.1.36 → 0.1.38

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 (30) hide show
  1. package/README.md +2 -2
  2. package/dist/favicon.svg +9 -9
  3. package/dist/src/lib/StackTabs.vue.d.ts +131 -49
  4. package/dist/src/lib/components/ContextMenu/ContextMenuItem.vue.d.ts +3 -12
  5. package/dist/src/lib/components/ContextMenu/index.vue.d.ts +6 -30
  6. package/dist/src/lib/components/PageLoading.vue.d.ts +3 -12
  7. package/dist/src/lib/components/TabHeader/TabHeaderButton.vue.d.ts +4 -29
  8. package/dist/src/lib/components/TabHeader/TabHeaderItem.vue.d.ts +7 -16
  9. package/dist/src/lib/components/TabHeader/TabHeaderScroll.vue.d.ts +5 -30
  10. package/dist/src/lib/components/TabHeader/index.vue.d.ts +8 -38
  11. package/dist/src/lib/hooks/useContextMenu.d.ts +3 -2
  12. package/dist/src/lib/hooks/useStackTab.d.ts +5 -2
  13. package/dist/src/lib/hooks/useTabMitt.d.ts +3 -2
  14. package/dist/src/lib/hooks/useTabRouter.d.ts +2 -1
  15. package/dist/src/lib/hooks/useTabpanel.d.ts +26 -6
  16. package/dist/src/lib/i18n/index.d.ts +1 -1
  17. package/dist/src/lib/iframe.vue.d.ts +1 -1
  18. package/dist/src/lib/index.d.ts +8 -8
  19. package/dist/src/lib/utils/TabIdHelper.d.ts +2 -1
  20. package/dist/src/lib/utils/TabScrollHelper.d.ts +3 -3
  21. package/dist/style.css +1 -1
  22. package/dist/vue-stack-tabs.es.js +1355 -1508
  23. package/dist/vue-stack-tabs.umd.js +2 -3
  24. package/package.json +49 -52
  25. package/src/lib/StackTabs.vue +135 -124
  26. package/src/lib/assets/style/transition.scss +62 -40
  27. package/src/lib/hooks/useStackTab.ts +119 -112
  28. package/src/lib/hooks/useTabRouter.ts +103 -99
  29. package/src/lib/hooks/useTabpanel.tsx +685 -684
  30. package/src/lib/utils/TabIdHelper.ts +70 -70
@@ -1,99 +1,103 @@
1
- import { defu } from 'defu'
2
-
3
- import { getCurrentInstance } from 'vue'
4
- import type { ComponentInternalInstance } from 'vue'
5
- import { type RouteLocationPathRaw, useRoute, useRouter } from 'vue-router'
6
-
7
- import useTabpanel from '@/lib/hooks/useTabpanel'
8
- import { uriDecode } from '@/lib/utils/UriHelper'
9
- export default () => {
10
- const { attrs, props } = getCurrentInstance() as ComponentInternalInstance
11
- const { pageShown, getTab, markDeletableCache, removeComponent, getComponent, addPageScroller } =
12
- useTabpanel()
13
- const route = useRoute()
14
- const router = useRouter()
15
- let currentId = ''
16
- // const currentPageId = ''
17
- let currentTab = ''
18
- currentId = (attrs.tId || props.tId) as string
19
- const currentPageId = (attrs.pId || props.pId) as string
20
- // currentPageId = attrs.pId as string
21
- currentTab = route.query.__tab as string
22
-
23
- const addScroller = (...scroller: string[]) => {
24
- addPageScroller(currentPageId, ...scroller)
25
- }
26
- const forward = (to: RouteLocationPathRaw) => {
27
- // pageShown.value = false
28
- const query = defu(
29
- {
30
- __tab: currentTab
31
- },
32
- to.query
33
- )
34
- router.push({
35
- path: to.path,
36
- query
37
- })
38
- }
39
- /**
40
- * 返回
41
- * @param to url or step
42
- * @param query 返回时要加截的数据
43
- */
44
- const backward = (to: number | string, query?: Object) => {
45
- // pageShown.value = false
46
-
47
- const tab = getTab(currentId)
48
- if (!tab) {
49
- return
50
- }
51
- const tabStack = tab.pages
52
- let absTo = 0
53
- if (typeof to === 'number') {
54
- absTo = Math.abs(to)
55
- } else {
56
- let index = 1
57
- let hasPath = false
58
- const pageItems = tabStack.list()
59
- const url = uriDecode(to)
60
- query = defu(url.query, query)
61
- for (let i = tabStack.size() - 2; i >= 0; i--) {
62
- if (pageItems[i].path === url.path) {
63
- hasPath = true
64
- break
65
- }
66
- index += 1
67
- }
68
- if (hasPath) {
69
- absTo = index
70
- }
71
- }
72
-
73
- if (absTo === 0 || tabStack!.size() <= absTo) {
74
- return
75
- }
76
- // const removeCaches = new Set()
77
- for (let i = 0; i < absTo; i++) {
78
- const popRoute = tabStack.pop()
79
- removeComponent(popRoute!.id)
80
- markDeletableCache(popRoute!.id)
81
- }
82
- const pageRoute = tabStack?.peek()
83
- const component = getComponent(pageRoute!.id)
84
- if (component !== null && component !== undefined) {
85
- const sourceComponent = component.components.DynamicComponent
86
- sourceComponent.props = defu(query, sourceComponent.props)
87
- }
88
- router.push({
89
- path: pageRoute!.path,
90
- query: pageRoute!.query
91
- })
92
- }
93
-
94
- return {
95
- forward,
96
- backward,
97
- addScroller
98
- }
99
- }
1
+ import { defu } from 'defu'
2
+
3
+ import { getCurrentInstance } from 'vue'
4
+ import type { ComponentInternalInstance } from 'vue'
5
+ import { type RouteLocationPathRaw, useRoute, useRouter } from 'vue-router'
6
+
7
+ import useTabpanel from '@/lib/hooks/useTabpanel'
8
+ import { uriDecode } from '@/lib/utils/UriHelper'
9
+ import { useEmitter } from '@/lib/hooks/useTabMitt'
10
+ export default () => {
11
+ const { attrs, props } = getCurrentInstance() as ComponentInternalInstance
12
+ const { pageShown, getTab, markDeletableCache, removeComponent, getComponent, addPageScroller } =
13
+ useTabpanel()
14
+ const route = useRoute()
15
+ const router = useRouter()
16
+ const emitter = useEmitter()
17
+ let currentId = ''
18
+ // const currentPageId = ''
19
+ let currentTab = ''
20
+ currentId = (attrs.tId || props.tId) as string
21
+ const currentPageId = (attrs.pId || props.pId) as string
22
+ // currentPageId = attrs.pId as string
23
+ currentTab = route.query.__tab as string
24
+
25
+ const addScroller = (...scroller: string[]) => {
26
+ addPageScroller(currentPageId, ...scroller)
27
+ }
28
+ const forward = (to: RouteLocationPathRaw) => {
29
+ // pageShown.value = false
30
+ const query = defu(
31
+ {
32
+ __tab: currentTab
33
+ },
34
+ to.query
35
+ )
36
+ emitter.emit('FORWARD')
37
+ router.push({
38
+ path: to.path,
39
+ query
40
+ })
41
+ }
42
+ /**
43
+ * 返回
44
+ * @param to url or step
45
+ * @param query 返回时要加截的数据
46
+ */
47
+ const backward = (to: number | string, query?: Object) => {
48
+ // pageShown.value = false
49
+
50
+ const tab = getTab(currentId)
51
+ if (!tab) {
52
+ return
53
+ }
54
+ const tabStack = tab.pages
55
+ let absTo = 0
56
+ if (typeof to === 'number') {
57
+ absTo = Math.abs(to)
58
+ } else {
59
+ let index = 1
60
+ let hasPath = false
61
+ const pageItems = tabStack.list()
62
+ const url = uriDecode(to)
63
+ query = defu(url.query, query)
64
+ for (let i = tabStack.size() - 2; i >= 0; i--) {
65
+ if (pageItems[i].path === url.path) {
66
+ hasPath = true
67
+ break
68
+ }
69
+ index += 1
70
+ }
71
+ if (hasPath) {
72
+ absTo = index
73
+ }
74
+ }
75
+
76
+ if (absTo === 0 || tabStack!.size() <= absTo) {
77
+ return
78
+ }
79
+ // const removeCaches = new Set()
80
+ for (let i = 0; i < absTo; i++) {
81
+ const popRoute = tabStack.pop()
82
+ removeComponent(popRoute!.id)
83
+ markDeletableCache(popRoute!.id)
84
+ }
85
+ const pageRoute = tabStack?.peek()
86
+ const component = getComponent(pageRoute!.id)
87
+ if (component !== null && component !== undefined) {
88
+ const sourceComponent = component.components.DynamicComponent
89
+ sourceComponent.props = defu(query, sourceComponent.props)
90
+ }
91
+ emitter.emit('BACKWARD')
92
+ router.push({
93
+ path: pageRoute!.path,
94
+ query: pageRoute!.query
95
+ })
96
+ }
97
+
98
+ return {
99
+ forward,
100
+ backward,
101
+ addScroller
102
+ }
103
+ }