cec-nuxt-lib 0.3.13 → 0.4.1
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/dist/module.json
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { useState } from '#app';
|
|
3
|
-
import { useRuntimeConfig } from '#app';
|
|
4
3
|
import { useRoute } from 'vue-router';
|
|
5
4
|
|
|
6
5
|
const classicPath = useState('classicPath');
|
|
7
|
-
const config = useRuntimeConfig();
|
|
8
|
-
const path = useState('path');
|
|
9
6
|
const route = useRoute();
|
|
10
|
-
const baseUrl = config.app.baseURL;
|
|
11
7
|
|
|
12
|
-
const trimPath = (str) =>
|
|
13
|
-
|
|
8
|
+
const trimPath = (str) => {
|
|
9
|
+
if (str === '/' || !str) {
|
|
10
|
+
return str;
|
|
11
|
+
}
|
|
12
|
+
return str.replace(/\/$/, '');
|
|
13
|
+
};
|
|
14
14
|
|
|
15
15
|
const makeLink = (i, routes) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
if (!i) {
|
|
17
|
+
return '/';
|
|
18
|
+
}
|
|
19
|
+
return '/' + routes.slice(0, i).join('/');
|
|
19
20
|
};
|
|
20
21
|
|
|
21
22
|
const toTitleCase = (str) => {
|
|
@@ -25,8 +26,8 @@ const toTitleCase = (str) => {
|
|
|
25
26
|
};
|
|
26
27
|
|
|
27
28
|
const makeArr = (str) => {
|
|
28
|
-
return str.split('/').reduce((acc, e
|
|
29
|
-
if (
|
|
29
|
+
return str.split('/').reduce((acc, e) => {
|
|
30
|
+
if (e.length) {
|
|
30
31
|
return [...acc, e];
|
|
31
32
|
}
|
|
32
33
|
return acc;
|
|
@@ -35,25 +36,15 @@ const makeArr = (str) => {
|
|
|
35
36
|
|
|
36
37
|
// Make arrays of the items in the paths
|
|
37
38
|
let routeTrim = trimPath(route.path);
|
|
38
|
-
let pathTrim = trimPath(path.value);
|
|
39
39
|
let routes = makeArr(routeTrim);
|
|
40
|
-
let paths = makeArr(pathTrim);
|
|
41
|
-
//console.log(routes)
|
|
42
|
-
|
|
43
|
-
// Use the route path if it includes the node's path
|
|
44
|
-
if (!routeTrim.toLowerCase().startsWith(pathTrim.toLowerCase())) {
|
|
45
|
-
routes = [...paths, ...routes.filter((e) => e.length)];
|
|
46
|
-
}
|
|
47
40
|
|
|
48
41
|
// Get the classic path for legacy links
|
|
49
42
|
let classic = trimPath(classicPath.value).split('/');
|
|
50
43
|
const length = classic.length;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return classic[i] ? [...acc, classic[i]] : [...acc, e];
|
|
56
|
-
}, []);
|
|
44
|
+
|
|
45
|
+
let hrefs = `${classicPath.value}${routeTrim === '/' ? '' : routeTrim}`.split(
|
|
46
|
+
'/'
|
|
47
|
+
);
|
|
57
48
|
const links = hrefs.map((e, i) => (!i ? 'Home' : toTitleCase(e)));
|
|
58
49
|
</script>
|
|
59
50
|
<template>
|
|
@@ -66,7 +57,9 @@ const links = hrefs.map((e, i) => (!i ? 'Home' : toTitleCase(e)));
|
|
|
66
57
|
<li class="breadcrumb-item" v-for="(l, i) in links" :key="i">
|
|
67
58
|
<span v-if="i === links.length - 1">{{ l }}</span>
|
|
68
59
|
<template v-else-if="i + 1 >= length">
|
|
69
|
-
<NuxtLink :to="makeLink(i, routes)">{{
|
|
60
|
+
<NuxtLink :to="makeLink(i - length + 1, routes)">{{
|
|
61
|
+
l
|
|
62
|
+
}}</NuxtLink>
|
|
70
63
|
</template>
|
|
71
64
|
<a v-else :href="'/' + hrefs.slice(1, i + 1).join('/')">
|
|
72
65
|
{{ l }}</a
|
|
@@ -704,6 +704,21 @@ canvasHtml = canvasHtml.replace(
|
|
|
704
704
|
);
|
|
705
705
|
|
|
706
706
|
onMounted(() => {
|
|
707
|
+
// Expand all buttons
|
|
708
|
+
const expandAll = (btn) => {
|
|
709
|
+
btn.addEventListener('click', (e) => {
|
|
710
|
+
console.log(btn.id);
|
|
711
|
+
const op = btn.innerText;
|
|
712
|
+
btn.innerText = op === 'Expand all' ? 'Close all' : 'Expand all';
|
|
713
|
+
Array.from(document.getElementsByClassName(btn.id)).forEach(
|
|
714
|
+
(e) => (e.checked = op === 'Expand all')
|
|
715
|
+
);
|
|
716
|
+
});
|
|
717
|
+
};
|
|
718
|
+
Array.from(document.getElementsByClassName('expand-all')).forEach((b) => {
|
|
719
|
+
expandAll(b);
|
|
720
|
+
});
|
|
721
|
+
|
|
707
722
|
let forms = Array.from(document.querySelectorAll('a')).filter(
|
|
708
723
|
(a) =>
|
|
709
724
|
regex.test(a.href) &&
|
package/package.json
CHANGED