@tak-ps/vue-tabler 4.2.1 → 4.3.0

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/CHANGELOG.md CHANGED
@@ -10,6 +10,10 @@
10
10
 
11
11
  ## Version History
12
12
 
13
+ ### v4.3.0
14
+
15
+ - :rocket: If breadcrumb context is not in the vue-router, call Window.Location
16
+
13
17
  ### v4.2.1
14
18
 
15
19
  - :rocket: Fix lints and checks
@@ -6,7 +6,7 @@
6
6
  <li class='breadcrumb-item'>
7
7
  <a
8
8
  class='cursor-pointer'
9
- @click='router.push("/")'
9
+ @click='navigate("/")'
10
10
  >Home</a>
11
11
  </li>
12
12
  <li
@@ -21,16 +21,10 @@
21
21
  v-if='crumb_it === crumbs.length - 1'
22
22
  v-text='crumb'
23
23
  />
24
- <a
25
- v-else-if='normalize'
26
- class='cursor-pointer'
27
- @click='router.push("/" + crumbs.splice(0, crumb_it + 1).join("/").toLowerCase())'
28
- v-text='crumb'
29
- />
30
24
  <a
31
25
  v-else
32
26
  class='cursor-pointer'
33
- @click='router.push("/" + crumbs.splice(0, crumb_it + 1).join("/"))'
27
+ @click='navigate(resolvePath(crumb_it))'
34
28
  v-text='crumb'
35
29
  />
36
30
  </li>
@@ -52,6 +46,29 @@ const props = withDefaults(defineProps<BreadCrumbProps>(), {
52
46
  const router = useRouter()
53
47
  const route = useRoute()
54
48
 
49
+ const navigate = (url: string) => {
50
+ try {
51
+ const resolved = router.resolve(url);
52
+ if (resolved.matched.length > 0) {
53
+ router.push(url);
54
+ } else {
55
+ window.location.href = url;
56
+ }
57
+ } catch (e) {
58
+ window.location.href = url;
59
+ }
60
+ }
61
+
62
+ const resolvePath = (index: number) => {
63
+ const rawCrumbs = route.path.split('/').filter((c) => c.length);
64
+ const subset = rawCrumbs.slice(0, index + 1);
65
+ let path = '/' + subset.join('/');
66
+ if (props.normalize) {
67
+ path = path.toLowerCase();
68
+ }
69
+ return path;
70
+ }
71
+
55
72
  const crumbs = computed(() => {
56
73
  return route.path.split('/').filter((crumb: string) => {
57
74
  return crumb.length
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tak-ps/vue-tabler",
3
3
  "type": "module",
4
- "version": "4.2.1",
4
+ "version": "4.3.0",
5
5
  "lib": "lib.ts",
6
6
  "main": "lib.ts",
7
7
  "module": "lib.ts",