vue-stack-tabs 0.1.12 → 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 +5 -0
  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 -2322
  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 -24
  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,94 +1,94 @@
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 } = getCurrentInstance() as ComponentInternalInstance
11
- const { pageShown, getTab, markDeletableCache, removeComponent, getComponent } = useTabpanel()
12
- const route = useRoute()
13
- const router = useRouter()
14
- let currentId = ''
15
- // const currentPageId = ''
16
- let currentTab = ''
17
-
18
- currentId = attrs.tId as string
19
- // currentPageId = attrs.pId as string
20
- currentTab = route.query.__tab as string
21
-
22
- const forward = (to: RouteLocationPathRaw) => {
23
- pageShown.value = false
24
- const query = defu(
25
- {
26
- __tab: currentTab
27
- },
28
- to.query
29
- )
30
- router.push({
31
- path: to.path,
32
- query
33
- })
34
- }
35
- /**
36
- * 返回
37
- * @param to url or step
38
- * @param query 返回时要加截的数据
39
- */
40
- const backward = (to: number | string, query?: Object) => {
41
- pageShown.value = false
42
-
43
- const tab = getTab(currentId)
44
- if (!tab) {
45
- return
46
- }
47
- const tabStack = tab.pages
48
- let absTo = 0
49
- if (typeof to === 'number') {
50
- absTo = Math.abs(to)
51
- } else {
52
- let index = 1
53
- let hasPath = false
54
- const pageItems = tabStack.list()
55
- const url = uriDecode(to)
56
- query = defu(url.query, query)
57
- for (let i = tabStack.size() - 2; i >= 0; i--) {
58
- if (pageItems[i].path === url.path) {
59
- hasPath = true
60
- break
61
- }
62
- index += 1
63
- }
64
- if (hasPath) {
65
- absTo = index
66
- }
67
- }
68
-
69
- if (absTo === 0 || tabStack!.size() <= absTo) {
70
- return
71
- }
72
- // const removeCaches = new Set()
73
- for (let i = 0; i < absTo; i++) {
74
- const popRoute = tabStack.pop()
75
- removeComponent(popRoute!.id)
76
- markDeletableCache(popRoute!.id)
77
- }
78
- const pageRoute = tabStack?.peek()
79
- const component = getComponent(pageRoute!.id)
80
- if (component !== null && component !== undefined) {
81
- const sourceComponent = component.components.DynamicComponent
82
- sourceComponent.props = defu(query, sourceComponent.props)
83
- }
84
- router.push({
85
- path: pageRoute!.path,
86
- query: pageRoute!.query
87
- })
88
- }
89
-
90
- return {
91
- forward,
92
- backward
93
- }
94
- }
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 } = getCurrentInstance() as ComponentInternalInstance
11
+ const { pageShown, getTab, markDeletableCache, removeComponent, getComponent } = useTabpanel()
12
+ const route = useRoute()
13
+ const router = useRouter()
14
+ let currentId = ''
15
+ // const currentPageId = ''
16
+ let currentTab = ''
17
+
18
+ currentId = attrs.tId as string
19
+ // currentPageId = attrs.pId as string
20
+ currentTab = route.query.__tab as string
21
+
22
+ const forward = (to: RouteLocationPathRaw) => {
23
+ pageShown.value = false
24
+ const query = defu(
25
+ {
26
+ __tab: currentTab
27
+ },
28
+ to.query
29
+ )
30
+ router.push({
31
+ path: to.path,
32
+ query
33
+ })
34
+ }
35
+ /**
36
+ * 返回
37
+ * @param to url or step
38
+ * @param query 返回时要加截的数据
39
+ */
40
+ const backward = (to: number | string, query?: Object) => {
41
+ pageShown.value = false
42
+
43
+ const tab = getTab(currentId)
44
+ if (!tab) {
45
+ return
46
+ }
47
+ const tabStack = tab.pages
48
+ let absTo = 0
49
+ if (typeof to === 'number') {
50
+ absTo = Math.abs(to)
51
+ } else {
52
+ let index = 1
53
+ let hasPath = false
54
+ const pageItems = tabStack.list()
55
+ const url = uriDecode(to)
56
+ query = defu(url.query, query)
57
+ for (let i = tabStack.size() - 2; i >= 0; i--) {
58
+ if (pageItems[i].path === url.path) {
59
+ hasPath = true
60
+ break
61
+ }
62
+ index += 1
63
+ }
64
+ if (hasPath) {
65
+ absTo = index
66
+ }
67
+ }
68
+
69
+ if (absTo === 0 || tabStack!.size() <= absTo) {
70
+ return
71
+ }
72
+ // const removeCaches = new Set()
73
+ for (let i = 0; i < absTo; i++) {
74
+ const popRoute = tabStack.pop()
75
+ removeComponent(popRoute!.id)
76
+ markDeletableCache(popRoute!.id)
77
+ }
78
+ const pageRoute = tabStack?.peek()
79
+ const component = getComponent(pageRoute!.id)
80
+ if (component !== null && component !== undefined) {
81
+ const sourceComponent = component.components.DynamicComponent
82
+ sourceComponent.props = defu(query, sourceComponent.props)
83
+ }
84
+ router.push({
85
+ path: pageRoute!.path,
86
+ query: pageRoute!.query
87
+ })
88
+ }
89
+
90
+ return {
91
+ forward,
92
+ backward
93
+ }
94
+ }