@ulu/frontend-vue 0.6.10 → 0.6.12
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/UluTabGroup.vue.d.ts +3 -0
- package/dist/components/collapsible/UluTabGroup.vue.d.ts.map +1 -1
- package/dist/components/collapsible/UluTabGroup.vue.js +28 -21
- package/dist/components/utils/UluRouteAnnouncer.vue.d.ts +2 -0
- package/dist/components/utils/UluRouteAnnouncer.vue.js +25 -21
- package/dist/mcp-data.json +3315 -3281
- package/lib/components/collapsible/UluTabGroup.vue +11 -2
- package/lib/components/utils/UluRouteAnnouncer.vue +28 -16
- package/package.json +1 -1
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
<TabGroup
|
|
3
3
|
v-slot="slotProps"
|
|
4
4
|
:defaultIndex="defaultIndex"
|
|
5
|
+
:selectedIndex="selectedIndex"
|
|
5
6
|
:vertical="vertical"
|
|
7
|
+
@change="$emit('change', $event)"
|
|
6
8
|
>
|
|
7
9
|
<div
|
|
8
10
|
v-bind="$attrs"
|
|
@@ -22,12 +24,15 @@
|
|
|
22
24
|
defineOptions({
|
|
23
25
|
inheritAttrs: false
|
|
24
26
|
});
|
|
25
|
-
|
|
26
27
|
const props = defineProps({
|
|
27
28
|
/**
|
|
28
|
-
* Active tab index by default
|
|
29
|
+
* Active tab index by default (uncontrolled)
|
|
29
30
|
*/
|
|
30
31
|
defaultIndex: Number,
|
|
32
|
+
/**
|
|
33
|
+
* Actively selected tab index (controlled)
|
|
34
|
+
*/
|
|
35
|
+
selectedIndex: Number,
|
|
31
36
|
/**
|
|
32
37
|
* Whether or not to use vertical layout
|
|
33
38
|
*/
|
|
@@ -46,6 +51,10 @@
|
|
|
46
51
|
modifiers: [String, Array]
|
|
47
52
|
});
|
|
48
53
|
|
|
54
|
+
// Explicitly declare the emit so Vue knows to capture the @change listener
|
|
55
|
+
// from the parent and NOT bundle it into $attrs
|
|
56
|
+
defineEmits(['change']);
|
|
57
|
+
|
|
49
58
|
const { resolvedModifiers } = useModifiers({
|
|
50
59
|
props,
|
|
51
60
|
baseClass: "tabs",
|
|
@@ -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