@shwfed/nuxt 0.1.71 → 0.1.72

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@shwfed/nuxt",
3
3
  "configKey": "shwfed",
4
- "version": "0.1.71",
4
+ "version": "0.1.72",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -18,7 +18,8 @@ import { useFavorite } from "../composables/useFavorite";
18
18
  import { useNavigationTabs } from "../composables/useNavigationTabs";
19
19
  import { commandActionSchema, executeCommandAction } from "../utils/command";
20
20
  import { createPaletteItemValue, normalizeCommandsForPalette, splitNavigationForPalette } from "../utils/command-palette";
21
- import { isRouteActive, normalizeRoutePath } from "../utils/route";
21
+ import { resolveNavigationTitle } from "../utils/navigation-title";
22
+ import { isRouteActive } from "../utils/route";
22
23
  import { applyRootNavigationFallback } from "../utils/sidebar-fallback";
23
24
  const { $dsl, $logout, $md, $api, $toast } = useNuxtApp();
24
25
  const { t } = useI18n();
@@ -79,22 +80,7 @@ const {
79
80
  } = useFavorite("navigation", navigationItems);
80
81
  const isNavigationItemActive = (itemRoute) => isRouteActive(route.path, itemRoute);
81
82
  const getTabLabel = (tab) => {
82
- const normalizedTab = normalizeRoutePath(tab);
83
- for (const group of navigations.value) {
84
- if ("children" in group) {
85
- const matchedChild = group.children.find((child) => {
86
- if (!("route" in child))
87
- return false;
88
- return normalizeRoutePath(child.route) === normalizedTab;
89
- });
90
- if (matchedChild)
91
- return matchedChild.title;
92
- continue;
93
- }
94
- if (normalizeRoutePath(group.route) === normalizedTab)
95
- return group.title;
96
- }
97
- return normalizedTab;
83
+ return resolveNavigationTitle(navigations.value, tab);
98
84
  };
99
85
  const activeTabLabel = computed(() => {
100
86
  if (active.value === void 0)
@@ -0,0 +1,10 @@
1
+ type NavigationLeaf = Readonly<{
2
+ title: string;
3
+ route: string;
4
+ }>;
5
+ type NavigationGroup = Readonly<{
6
+ children: Array<NavigationLeaf>;
7
+ }>;
8
+ type NavigationEntry = NavigationLeaf | NavigationGroup;
9
+ export declare function resolveNavigationTitle(entries: Array<NavigationEntry>, path: string): string;
10
+ export {};
@@ -0,0 +1,28 @@
1
+ import { isRouteActive, normalizeRoutePath } from "./route.js";
2
+ export function resolveNavigationTitle(entries, path) {
3
+ const normalizedPath = normalizeRoutePath(path);
4
+ let bestTitle;
5
+ let bestRouteLength = -1;
6
+ for (const entry of entries) {
7
+ if ("children" in entry) {
8
+ for (const child of entry.children) {
9
+ const normalizedRoute2 = normalizeRoutePath(child.route);
10
+ if (!isRouteActive(normalizedPath, normalizedRoute2))
11
+ continue;
12
+ if (normalizedRoute2.length <= bestRouteLength)
13
+ continue;
14
+ bestRouteLength = normalizedRoute2.length;
15
+ bestTitle = child.title;
16
+ }
17
+ continue;
18
+ }
19
+ const normalizedRoute = normalizeRoutePath(entry.route);
20
+ if (!isRouteActive(normalizedPath, normalizedRoute))
21
+ continue;
22
+ if (normalizedRoute.length <= bestRouteLength)
23
+ continue;
24
+ bestRouteLength = normalizedRoute.length;
25
+ bestTitle = entry.title;
26
+ }
27
+ return bestTitle ?? normalizedPath;
28
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shwfed/nuxt",
3
- "version": "0.1.71",
3
+ "version": "0.1.72",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "type": "module",