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