@shwfed/nuxt 0.1.51 → 0.1.53
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.d.mts +1 -0
- package/dist/module.json +1 -1
- package/dist/runtime/components/app.vue +61 -32
- package/package.json +1 -1
package/dist/module.d.mts
CHANGED
package/dist/module.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { useHead, useNuxtApp, useRouter } from "#app";
|
|
2
|
+
import { useHead, useNuxtApp, useRouter, useRuntimeConfig } from "#app";
|
|
3
3
|
import { computed, ref } from "vue";
|
|
4
4
|
import { CommandDialog, CommandInput, CommandList, CommandGroup, CommandEmpty, CommandItem } from "./ui/command";
|
|
5
5
|
import { TooltipProvider } from "./ui/tooltip";
|
|
@@ -14,6 +14,7 @@ import { Sidebar, SidebarContent, SidebarGroup, SidebarGroupLabel, SidebarMenu,
|
|
|
14
14
|
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "./ui/collapsible";
|
|
15
15
|
import Logo from "./logo.vue";
|
|
16
16
|
const { $dsl } = useNuxtApp();
|
|
17
|
+
const config = useRuntimeConfig().public.shwfed;
|
|
17
18
|
const props = defineProps({
|
|
18
19
|
navigation: { type: Array, required: false },
|
|
19
20
|
commands: { type: Array, required: false },
|
|
@@ -38,6 +39,28 @@ whenever(() => meta_k?.value, () => {
|
|
|
38
39
|
});
|
|
39
40
|
const router = useRouter();
|
|
40
41
|
setGlobalDslContext(await props.dsl?.pipe(Effect.scoped).pipe(Effect.runPromise) ?? {});
|
|
42
|
+
function toNavigationKey(groupId, itemId) {
|
|
43
|
+
return groupId ? `${groupId}::${itemId}` : `::${itemId}`;
|
|
44
|
+
}
|
|
45
|
+
function findNavigationByKey(navList, key) {
|
|
46
|
+
const parts = key.split("::");
|
|
47
|
+
if (parts.length < 2) return void 0;
|
|
48
|
+
const groupId = parts[0] ?? "";
|
|
49
|
+
const itemId = parts[1] ?? "";
|
|
50
|
+
if (groupId === "") {
|
|
51
|
+
for (const el of navList) {
|
|
52
|
+
if (el.type === "item" && el.id === itemId) return el;
|
|
53
|
+
}
|
|
54
|
+
return void 0;
|
|
55
|
+
}
|
|
56
|
+
for (const el of navList) {
|
|
57
|
+
if (el.type === "group" && el.id === groupId) {
|
|
58
|
+
const child = el.children.find((c) => c.id === itemId);
|
|
59
|
+
return child;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return void 0;
|
|
63
|
+
}
|
|
41
64
|
const palette = computed(() => {
|
|
42
65
|
const items = [];
|
|
43
66
|
for (const navigation2 of props.navigation ?? []) {
|
|
@@ -62,8 +85,8 @@ const palette = computed(() => {
|
|
|
62
85
|
external: $dsl.evaluate`${child.external}`(),
|
|
63
86
|
effect: Effect.sync(function() {
|
|
64
87
|
if ($dsl.evaluate`${child.external}`() !== true) {
|
|
65
|
-
tabs.value.add(child.id);
|
|
66
|
-
activeTab.value = child.id;
|
|
88
|
+
tabs.value.add(toNavigationKey(navigation2.id, child.id));
|
|
89
|
+
activeTab.value = toNavigationKey(navigation2.id, child.id);
|
|
67
90
|
}
|
|
68
91
|
})
|
|
69
92
|
}))
|
|
@@ -81,8 +104,8 @@ const palette = computed(() => {
|
|
|
81
104
|
external: $dsl.evaluate`${navigation2.external}`(),
|
|
82
105
|
effect: Effect.sync(function() {
|
|
83
106
|
if ($dsl.evaluate`${navigation2.external}`() !== true) {
|
|
84
|
-
tabs.value.add(navigation2.id);
|
|
85
|
-
activeTab.value = navigation2.id;
|
|
107
|
+
tabs.value.add(toNavigationKey("", navigation2.id));
|
|
108
|
+
activeTab.value = toNavigationKey("", navigation2.id);
|
|
86
109
|
}
|
|
87
110
|
})
|
|
88
111
|
});
|
|
@@ -146,8 +169,8 @@ const navigation = computed(() => {
|
|
|
146
169
|
target: child.target,
|
|
147
170
|
effect: Effect.sync(function() {
|
|
148
171
|
if ($dsl.evaluate`${child.external}`() !== true) {
|
|
149
|
-
tabs.value.add(child.id);
|
|
150
|
-
activeTab.value = child.id;
|
|
172
|
+
tabs.value.add(toNavigationKey(navigation2.id, child.id));
|
|
173
|
+
activeTab.value = toNavigationKey(navigation2.id, child.id);
|
|
151
174
|
router.replace(child.target);
|
|
152
175
|
}
|
|
153
176
|
})
|
|
@@ -165,8 +188,8 @@ const navigation = computed(() => {
|
|
|
165
188
|
target: navigation2.target,
|
|
166
189
|
effect: Effect.sync(function() {
|
|
167
190
|
if ($dsl.evaluate`${navigation2.external}`() !== true) {
|
|
168
|
-
tabs.value.add(navigation2.id);
|
|
169
|
-
activeTab.value = navigation2.id;
|
|
191
|
+
tabs.value.add(toNavigationKey("", navigation2.id));
|
|
192
|
+
activeTab.value = toNavigationKey("", navigation2.id);
|
|
170
193
|
router.replace(navigation2.target);
|
|
171
194
|
}
|
|
172
195
|
})
|
|
@@ -219,17 +242,17 @@ const navigationFavorites = useLocalStorage("navigation-favorites", [], {
|
|
|
219
242
|
});
|
|
220
243
|
const navigationFavoritesItems = computed(() => {
|
|
221
244
|
const items = [];
|
|
222
|
-
for (const
|
|
223
|
-
const item = navigation.value
|
|
245
|
+
for (const key of navigationFavorites.value) {
|
|
246
|
+
const item = findNavigationByKey(navigation.value, key);
|
|
224
247
|
if (!item) continue;
|
|
225
248
|
items.push({
|
|
226
|
-
id:
|
|
249
|
+
id: key,
|
|
227
250
|
title: item.title,
|
|
228
251
|
icon: item.icon,
|
|
229
252
|
effect: Effect.sync(function() {
|
|
230
253
|
if (item.external !== true) {
|
|
231
|
-
tabs.value.add(
|
|
232
|
-
activeTab.value =
|
|
254
|
+
tabs.value.add(key);
|
|
255
|
+
activeTab.value = key;
|
|
233
256
|
router.replace(item.target);
|
|
234
257
|
}
|
|
235
258
|
})
|
|
@@ -239,18 +262,18 @@ const navigationFavoritesItems = computed(() => {
|
|
|
239
262
|
});
|
|
240
263
|
const paletteFavorites = computed(() => {
|
|
241
264
|
const items = [];
|
|
242
|
-
for (const
|
|
243
|
-
const item = navigation.value
|
|
265
|
+
for (const key of navigationFavorites.value) {
|
|
266
|
+
const item = findNavigationByKey(navigation.value, key);
|
|
244
267
|
if (!item) continue;
|
|
245
268
|
items.push({
|
|
246
|
-
id:
|
|
269
|
+
id: key,
|
|
247
270
|
title: item.title,
|
|
248
271
|
icon: item.icon,
|
|
249
272
|
external: item.external,
|
|
250
273
|
effect: Effect.sync(function() {
|
|
251
274
|
if (item.external !== true) {
|
|
252
|
-
tabs.value.add(
|
|
253
|
-
activeTab.value =
|
|
275
|
+
tabs.value.add(key);
|
|
276
|
+
activeTab.value = key;
|
|
254
277
|
router.replace(item.target);
|
|
255
278
|
}
|
|
256
279
|
})
|
|
@@ -264,6 +287,9 @@ const tabs = useSessionStorage("navigation-tabs", /* @__PURE__ */ new Set(), {
|
|
|
264
287
|
const activeTab = useSessionStorage("navigation-active-tab", void 0, {
|
|
265
288
|
writeDefaults: false
|
|
266
289
|
});
|
|
290
|
+
useHead({
|
|
291
|
+
title: () => activeTab.value ? findNavigationByKey(navigation.value, activeTab.value)?.title ?? config.title : config.title
|
|
292
|
+
});
|
|
267
293
|
</script>
|
|
268
294
|
|
|
269
295
|
<template>
|
|
@@ -523,7 +549,7 @@ const activeTab = useSessionStorage("navigation-active-tab", void 0, {
|
|
|
523
549
|
<Collapsible
|
|
524
550
|
v-if="el.type === 'group'"
|
|
525
551
|
class="group/collapsible"
|
|
526
|
-
:default-open="el.children.some((child) => child.id === activeTab)"
|
|
552
|
+
:default-open="el.children.some((child) => toNavigationKey(el.id, child.id) === activeTab)"
|
|
527
553
|
as-child
|
|
528
554
|
>
|
|
529
555
|
<SidebarMenuItem>
|
|
@@ -548,7 +574,7 @@ const activeTab = useSessionStorage("navigation-active-tab", void 0, {
|
|
|
548
574
|
>
|
|
549
575
|
<SidebarMenuSubButton
|
|
550
576
|
as-child
|
|
551
|
-
:is-active="item.id === activeTab"
|
|
577
|
+
:is-active="toNavigationKey(el.id, item.id) === activeTab"
|
|
552
578
|
>
|
|
553
579
|
<button
|
|
554
580
|
type="button"
|
|
@@ -563,21 +589,22 @@ const activeTab = useSessionStorage("navigation-active-tab", void 0, {
|
|
|
563
589
|
</button>
|
|
564
590
|
</SidebarMenuSubButton>
|
|
565
591
|
<SidebarMenuAction
|
|
566
|
-
:class="['transition-opacity duration-80 text-yellow-400 -translate-y-1/2', !navigationFavorites.includes(item.id) && 'group-hover/menu-sub-item:opacity-100 opacity-0 ']"
|
|
592
|
+
:class="['transition-opacity duration-80 text-yellow-400 -translate-y-1/2', !navigationFavorites.includes(toNavigationKey(el.id, item.id)) && 'group-hover/menu-sub-item:opacity-100 opacity-0 ']"
|
|
567
593
|
as-child
|
|
568
594
|
>
|
|
569
595
|
<button
|
|
570
596
|
type="button"
|
|
571
597
|
@click="() => {
|
|
572
|
-
|
|
573
|
-
|
|
598
|
+
const key = toNavigationKey(el.id, item.id);
|
|
599
|
+
if (navigationFavorites.includes(key)) {
|
|
600
|
+
navigationFavorites = navigationFavorites.filter((id) => id !== key);
|
|
574
601
|
} else {
|
|
575
|
-
navigationFavorites = Array.from(/* @__PURE__ */ new Set([...navigationFavorites,
|
|
602
|
+
navigationFavorites = Array.from(/* @__PURE__ */ new Set([...navigationFavorites, key]));
|
|
576
603
|
}
|
|
577
604
|
}"
|
|
578
605
|
>
|
|
579
606
|
<Icon
|
|
580
|
-
v-if="navigationFavorites.includes(item.id)"
|
|
607
|
+
v-if="navigationFavorites.includes(toNavigationKey(el.id, item.id))"
|
|
581
608
|
icon="fluent:star-20-filled"
|
|
582
609
|
class="text-yellow-400"
|
|
583
610
|
/>
|
|
@@ -607,7 +634,7 @@ const activeTab = useSessionStorage("navigation-active-tab", void 0, {
|
|
|
607
634
|
</SidebarContent>
|
|
608
635
|
</Sidebar>
|
|
609
636
|
</SidebarProvider>
|
|
610
|
-
<main class="flex-1 flex flex-col bg-zinc-100">
|
|
637
|
+
<main class="flex-1 flex flex-col bg-zinc-100 overflow-hidden">
|
|
611
638
|
<nav class="bg-white p-1 border-b border-zinc-100 h-10 flex items-center justify-start gap-1 overflow-x-hidden cursor-pointer min-w-0">
|
|
612
639
|
<div
|
|
613
640
|
v-for="tab in tabs"
|
|
@@ -615,20 +642,22 @@ const activeTab = useSessionStorage("navigation-active-tab", void 0, {
|
|
|
615
642
|
:class="['border rounded cursor-pointer px-2 py-1 text-sm flex items-center gap-2 truncate', activeTab === tab ? 'text-(--primary) border-(--primary)' : 'text-zinc-500 border-zinc-300 hover:text-zinc-700']"
|
|
616
643
|
@click="() => {
|
|
617
644
|
activeTab = tab;
|
|
618
|
-
|
|
645
|
+
const item2 = findNavigationByKey(navigation, tab);
|
|
646
|
+
$router.replace(item2?.target ?? '');
|
|
619
647
|
}"
|
|
620
648
|
>
|
|
621
|
-
{{ navigation
|
|
649
|
+
{{ findNavigationByKey(navigation, tab)?.title ?? tab ?? "Unknown" }}
|
|
622
650
|
<button
|
|
623
651
|
type="button"
|
|
624
652
|
class="opacity-80 group-hover/tab:opacity-100 transition-opacity cursor-pointer text-zinc-500 hover:text-(--primary) duration-180"
|
|
625
653
|
@click.stop="() => {
|
|
626
654
|
if (activeTab === tab) {
|
|
627
|
-
const idx = Array.from(tabs).findIndex((
|
|
655
|
+
const idx = Array.from(tabs).findIndex((t2) => t2 === activeTab) - 1;
|
|
628
656
|
const previous = Array.from(tabs)[idx];
|
|
629
657
|
if (previous) {
|
|
630
658
|
activeTab = previous;
|
|
631
|
-
|
|
659
|
+
const item2 = findNavigationByKey(navigation, previous);
|
|
660
|
+
$router.replace(item2?.target ?? '');
|
|
632
661
|
} else {
|
|
633
662
|
activeTab = void 0;
|
|
634
663
|
}
|
|
@@ -640,7 +669,7 @@ const activeTab = useSessionStorage("navigation-active-tab", void 0, {
|
|
|
640
669
|
</button>
|
|
641
670
|
</div>
|
|
642
671
|
</nav>
|
|
643
|
-
<main class="m-2 flex-1 p-1 bg-white border border-zinc-100 rounded">
|
|
672
|
+
<main class="m-2 flex-1 p-1 bg-white border border-zinc-100 rounded overflow-hidden">
|
|
644
673
|
<slot />
|
|
645
674
|
</main>
|
|
646
675
|
</main>
|