@ulu/frontend-vue 0.6.9 → 0.6.11
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/components/collapsible/UluTab.vue.d.ts.map +1 -1
- package/dist/components/collapsible/UluTabPanel.vue.d.ts.map +1 -1
- package/dist/components/collapsible/UluTabPanels.vue.d.ts.map +1 -1
- package/dist/components/utils/UluRouteAnnouncer.vue.d.ts +2 -0
- package/dist/components/utils/UluRouteAnnouncer.vue.js +25 -21
- package/dist/mcp-data.json +4604 -4572
- package/lib/components/collapsible/UluTab.vue +4 -2
- package/lib/components/collapsible/UluTabPanel.vue +4 -2
- package/lib/components/collapsible/UluTabPanels.vue +4 -2
- package/lib/components/utils/UluRouteAnnouncer.vue +28 -16
- package/package.json +1 -1
|
@@ -21,16 +21,16 @@
|
|
|
21
21
|
</template>
|
|
22
22
|
|
|
23
23
|
<script setup>
|
|
24
|
-
import { ref, computed, watch, nextTick } from
|
|
25
|
-
import { useRoute } from
|
|
26
|
-
import { getRouteTitle } from
|
|
24
|
+
import { ref, computed, watch, nextTick } from "vue";
|
|
25
|
+
import { useRoute, useRouter, START_LOCATION } from "vue-router";
|
|
26
|
+
import { getRouteTitle } from "../../utils/router.js";
|
|
27
27
|
|
|
28
28
|
const props = defineProps({
|
|
29
29
|
/**
|
|
30
30
|
* Allow user to bypass this functionality
|
|
31
31
|
* - Function should return true if the page should be announced
|
|
32
|
-
* - Function is passed
|
|
33
|
-
* - to/from are
|
|
32
|
+
* - Function is passed (to, from) => {}
|
|
33
|
+
* - to/from are RouteLocationNormalizedLoaded objects
|
|
34
34
|
*/
|
|
35
35
|
validator: {
|
|
36
36
|
type: Function,
|
|
@@ -51,15 +51,20 @@
|
|
|
51
51
|
getTitle: {
|
|
52
52
|
type: Function,
|
|
53
53
|
default: (route) => getRouteTitle(route)
|
|
54
|
-
}
|
|
54
|
+
},
|
|
55
|
+
/**
|
|
56
|
+
* Enable debug logging
|
|
57
|
+
*/
|
|
58
|
+
debug: Boolean
|
|
55
59
|
});
|
|
56
60
|
|
|
57
61
|
const route = useRoute();
|
|
62
|
+
const router = useRouter();
|
|
58
63
|
const el = ref(null);
|
|
59
64
|
|
|
60
65
|
const title = computed(() => {
|
|
61
|
-
//
|
|
62
|
-
if (!route) return "";
|
|
66
|
+
// Prevent errors if not in router context, or if it's the initial ghost route
|
|
67
|
+
if (!route || route.matched.length === 0) return "";
|
|
63
68
|
const t = props.getTitle(route);
|
|
64
69
|
if (!t) {
|
|
65
70
|
console.warn("RouteAnnouncer: No page title!");
|
|
@@ -67,23 +72,30 @@
|
|
|
67
72
|
return t;
|
|
68
73
|
});
|
|
69
74
|
|
|
70
|
-
if (
|
|
75
|
+
if (router) {
|
|
71
76
|
watch(
|
|
72
|
-
|
|
77
|
+
router.currentRoute,
|
|
73
78
|
async (to, from) => {
|
|
74
|
-
|
|
79
|
+
// Skip the very first route transition from the initial ghost route
|
|
80
|
+
if (from === START_LOCATION || from.matched.length === 0) {
|
|
75
81
|
return;
|
|
76
82
|
}
|
|
77
|
-
|
|
83
|
+
if (to.hash) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const isValid = props.validator(to, from);
|
|
78
87
|
const isExcluded = props.exclude.some(ex => {
|
|
79
88
|
// Allow wildcard at end to exclude entire sections, etc
|
|
80
89
|
if (ex.endsWith("*")) {
|
|
81
|
-
return to.startsWith(ex.slice(0, ex.length - 1));
|
|
90
|
+
return to.path.startsWith(ex.slice(0, ex.length - 1));
|
|
82
91
|
} else {
|
|
83
|
-
return to === ex;
|
|
92
|
+
return to.path === ex;
|
|
84
93
|
}
|
|
85
94
|
});
|
|
86
|
-
if (isValid && !isExcluded) {
|
|
95
|
+
if (title.value && isValid && !isExcluded) {
|
|
96
|
+
if (props.debug) {
|
|
97
|
+
console.log("RouteAnnouncer: Focused title:", title.value);
|
|
98
|
+
}
|
|
87
99
|
await nextTick();
|
|
88
100
|
el.value?.focus();
|
|
89
101
|
}
|
|
@@ -92,4 +104,4 @@
|
|
|
92
104
|
} else {
|
|
93
105
|
console.error("RouteAnnouncer: No route found (install vue-router).");
|
|
94
106
|
}
|
|
95
|
-
</script>
|
|
107
|
+
</script>
|
package/package.json
CHANGED