@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.
@@ -1,6 +1,8 @@
1
1
  <template>
2
- <Tab class="tabs__tab" v-slot="slotProps">
3
- <slot v-bind="slotProps"/>
2
+ <Tab class="tabs__tab">
3
+ <template #default="slotProps">
4
+ <slot v-bind="slotProps"/>
5
+ </template>
4
6
  </Tab>
5
7
  </template>
6
8
 
@@ -1,6 +1,8 @@
1
1
  <template>
2
- <TabPanel v-slot="slotProps" class="tabs__tabpanel">
3
- <slot v-bind="slotProps"/>
2
+ <TabPanel class="tabs__tabpanel">
3
+ <template #default="slotProps">
4
+ <slot v-bind="slotProps"/>
5
+ </template>
4
6
  </TabPanel>
5
7
  </template>
6
8
 
@@ -1,6 +1,8 @@
1
1
  <template>
2
- <TabPanels as="template" v-slot="slotProps">
3
- <slot v-bind="slotProps"/>
2
+ <TabPanels as="template">
3
+ <template #default="slotProps">
4
+ <slot v-bind="slotProps"/>
5
+ </template>
4
6
  </TabPanels>
5
7
  </template>
6
8
 
@@ -21,16 +21,16 @@
21
21
  </template>
22
22
 
23
23
  <script setup>
24
- import { ref, computed, watch, nextTick } from 'vue';
25
- import { useRoute } from 'vue-router';
26
- import { getRouteTitle } from '../../utils/router.js';
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 (to, from, $route) => {}
33
- * - to/from are path strings
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
- // Check if route exists to prevent crash if not in router context (though required)
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 (route) {
75
+ if (router) {
71
76
  watch(
72
- () => route.path,
77
+ router.currentRoute,
73
78
  async (to, from) => {
74
- if (route.hash) {
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
- const isValid = props.validator(to, from, route);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ulu/frontend-vue",
3
- "version": "0.6.9",
3
+ "version": "0.6.11",
4
4
  "description": "A modular, tree-shakeable Vue 3 component library for the Ulu Frontend theming system, plus general utilities for Vue development",
5
5
  "type": "module",
6
6
  "files": [