@frigear-nu/dashboard 0.0.0 → 0.0.1

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 CHANGED
@@ -55,7 +55,24 @@ interface DashboardHomeTabOptions {
55
55
  /** Nuxt UI icon of the web tab bar. Default `i-lucide-house`. */
56
56
  icon?: string;
57
57
  }
58
+ /** The pages of the signed-in hub. */
59
+ interface DashboardPagesOptions {
60
+ /**
61
+ * The hub: a signed-in page with shortcuts to the areas of the `dashboard` menu and the `settings.home.dashboard`
62
+ * dashboard, in the `dashboard` layout. A path, `true` for `/dashboard` (the default), or `false` to turn the area
63
+ * off. Needs `@frigear-nu/auth`.
64
+ */
65
+ home?: string | boolean;
66
+ }
67
+ interface DashboardSettings {
68
+ pages?: DashboardPagesOptions;
69
+ home?: {
70
+ /** The dashboard the hub page renders below its shortcuts. Default `home`. */
71
+ dashboard?: string;
72
+ };
73
+ }
58
74
  interface ModuleOptions {
75
+ settings?: DashboardSettings;
59
76
  /**
60
77
  * With `@frigear-nu/mobile`: a Home tab and a page at `path` rendering `<Dashboard :name>`. `false` turns it off.
61
78
  * Without mobile nothing is registered: a web app places `<Dashboard>` on a page itself.
@@ -65,6 +82,12 @@ interface ModuleOptions {
65
82
  interface DashboardPublicConfig {
66
83
  /** The dashboard the Home tab page renders, `''` without one. */
67
84
  home: string;
85
+ pages: {
86
+ /** The hub's path, unset when the area is off. */
87
+ home?: string;
88
+ };
89
+ /** The dashboard the hub page renders, `''` when the area is off. */
90
+ homeDashboard: string;
68
91
  }
69
92
 
70
93
  declare module 'nuxt/schema' {
@@ -78,4 +101,4 @@ declare module 'nuxt/schema' {
78
101
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
79
102
 
80
103
  export { _default as default };
81
- export type { DashboardHomeTabOptions, DashboardItem, DashboardItemCondition, DashboardLayout, DashboardLayoutsDto, DashboardPlatform, DashboardPublicConfig, DashboardRegistryEntry, ModuleOptions };
104
+ export type { DashboardHomeTabOptions, DashboardItem, DashboardItemCondition, DashboardLayout, DashboardLayoutsDto, DashboardPagesOptions, DashboardPlatform, DashboardPublicConfig, DashboardRegistryEntry, DashboardSettings, ModuleOptions };
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=4.0.0"
6
6
  },
7
- "version": "0.0.0",
7
+ "version": "0.0.1",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.4",
10
10
  "unbuild": "unknown"
package/dist/module.mjs CHANGED
@@ -1,8 +1,9 @@
1
1
  import { defineNuxtModule, createResolver, addImports, addComponent, hasNuxtModule, addTypeTemplate, useLogger } from '@nuxt/kit';
2
- import { registerModule, inlineModuleRuntime, registerLocales, registerTailwindSource, addOptionalImports, defineVirtualRegistry, addModuleRoutes, addModulePages } from '@frigear-nu/module-kit/utils';
2
+ import { registerModule, inlineModuleRuntime, registerLocales, registerTailwindSource, addOptionalImports, defineVirtualRegistry, addModuleRoutes, addModulePages, addOptionalMenuSource } from '@frigear-nu/module-kit/utils';
3
3
  import { getDashboardItems } from '../dist/runtime/utils/dashboard.js';
4
4
  import { dashboardRegistryTemplate, resolveDashboardRegistry, dashboardOfArea, isModuleConditionMet } from '../dist/runtime/shared/registry.js';
5
5
  import { resolveHomeTab } from '../dist/runtime/shared/home-tab.js';
6
+ import { resolveHub } from '../dist/runtime/shared/hub.js';
6
7
 
7
8
  const MODULE_NAME = "@frigear-nu/dashboard";
8
9
  const module$1 = defineNuxtModule({
@@ -23,7 +24,12 @@ const module$1 = defineNuxtModule({
23
24
  "@frigear-nu/mobile": { version: ">=0.0.0", optional: true },
24
25
  // Soft: whether someone is signed in, so a layout is only saved for a user; with Preferences, the `authorize` of
25
26
  // the layout routes and their `dashboard:layouts` permission.
26
- "@frigear-nu/auth": { version: ">=0.0.0", optional: true }
27
+ "@frigear-nu/auth": { version: ">=0.0.0", optional: true },
28
+ // Soft: the hub's navigation is the `dashboard` menu (other modules add their areas to it), and its entry in
29
+ // `account.dropdown`. Without it the hub lists only its Overview.
30
+ "@frigear-nu/menu": { version: ">=0.0.0", optional: true },
31
+ // Soft: guards the hub (signed-in only, through `guardPages`).
32
+ "@frigear-nu/authorization": { version: ">=0.0.0", optional: true }
27
33
  },
28
34
  async setup(options, nuxt) {
29
35
  registerModule(MODULE_NAME, nuxt);
@@ -37,7 +43,8 @@ const module$1 = defineNuxtModule({
37
43
  { name: "useDashboardLayout", from: resolver.resolve("./runtime/app/composables/useDashboardLayout") },
38
44
  { name: "useDashboardPlatform", from: resolver.resolve("./runtime/app/composables/useDashboardPlatform") },
39
45
  { name: "dashboardSpanClass", from: resolver.resolve("./runtime/app/utils/span") },
40
- { name: "useSavedDashboardLayouts", from: resolver.resolve("./runtime/app/composables/useSavedDashboardLayouts") }
46
+ { name: "useSavedDashboardLayouts", from: resolver.resolve("./runtime/app/composables/useSavedDashboardLayouts") },
47
+ { name: "useDashboardNav", from: resolver.resolve("./runtime/app/composables/useDashboardNav") }
41
48
  ]);
42
49
  for (const name of ["Dashboard", "DashboardGrid", "DashboardItem", "ChartCard", "ActionCard", "EmptyCard"]) {
43
50
  addComponent({ name, filePath: resolver.resolve(`./runtime/app/components/${name}.vue`) });
@@ -57,6 +64,12 @@ const module$1 = defineNuxtModule({
57
64
  fallback: "undefined",
58
65
  fallbackType: `undefined | (() => { loggedIn: import('vue').Ref<boolean> | import('vue').ComputedRef<boolean>, user: import('vue').Ref<{ id?: string | number } | null | undefined> })`
59
66
  },
67
+ {
68
+ name: "useMenu",
69
+ available: () => hasNuxtModule("@frigear-nu/menu", nuxt),
70
+ fallback: "undefined",
71
+ fallbackType: `undefined | ((path: string) => PromiseLike<unknown> & { data: import('vue').Ref<import('@frigear-nu/menu').MenuItem[] | null | undefined> })`
72
+ },
60
73
  {
61
74
  name: "useCapacitor",
62
75
  available: () => hasNuxtModule("@frigear-nu/mobile", nuxt),
@@ -95,14 +108,48 @@ const module$1 = defineNuxtModule({
95
108
  }
96
109
  const home = resolveHomeTab(options.homeTab, { mobile: hasNuxtModule("@frigear-nu/mobile", nuxt) });
97
110
  const publicConfig = nuxt.options.runtimeConfig.public;
98
- publicConfig.dashboard = { home: home?.dashboard ?? "", ...publicConfig.dashboard };
111
+ publicConfig.dashboard = { home: home?.dashboard ?? "", pages: {}, homeDashboard: "", ...publicConfig.dashboard };
99
112
  if (home) {
100
113
  addModulePages(MODULE_NAME, resolver, [{ name: "dashboard-home", path: home.path, file: "./runtime/app/pages/home.vue" }]);
101
114
  const { extendMobileTabs } = await import('@frigear-nu/mobile/utils');
102
115
  extendMobileTabs(nuxt, home.tab);
103
116
  }
117
+ await setupHub(nuxt, resolver, options);
104
118
  }
105
119
  });
120
+ async function setupHub(nuxt, resolver, options) {
121
+ const planned = resolveHub(options.settings, { auth: true });
122
+ if (!planned) return;
123
+ const authUtils = await import('@frigear-nu/auth/utils').catch(() => void 0);
124
+ if (!authUtils) return;
125
+ const areaBase = [planned.path, `${planned.path}/**`];
126
+ const rules = nuxt.options.routeRules ||= {};
127
+ for (const pattern of authUtils.localizedRoutePatterns(nuxt, areaBase)) {
128
+ rules[pattern] = { appLayout: "dashboard", ...rules[pattern] };
129
+ }
130
+ authUtils.guardPages(nuxt, areaBase);
131
+ nuxt.hook("modules:done", () => {
132
+ const logger = useLogger("dashboard");
133
+ const hub = resolveHub(options.settings, { auth: hasNuxtModule("@frigear-nu/auth", nuxt) });
134
+ if (!hub) {
135
+ if (typeof options.settings?.pages?.home === "string") {
136
+ logger.warn("`dashboard.settings.pages.home` was set, but `@frigear-nu/auth` is not installed - skipping the hub.");
137
+ }
138
+ return;
139
+ }
140
+ if (!hasNuxtModule("@frigear-nu/authorization", nuxt)) {
141
+ logger.warn(`@frigear-nu/authorization is not installed: the hub is not guarded. Install it and guard \`${hub.path}/**\` yourself.`);
142
+ }
143
+ const publicConfig = nuxt.options.runtimeConfig.public.dashboard;
144
+ publicConfig.pages = { ...publicConfig.pages, home: hub.path };
145
+ publicConfig.homeDashboard = hub.dashboard;
146
+ addModulePages(MODULE_NAME, resolver, [{ name: "dashboard-hub", path: hub.path, file: "./runtime/app/pages/hub.vue" }]);
147
+ nuxt.hook("app:resolve", (app) => {
148
+ app.layouts.dashboard ||= { name: "dashboard", file: resolver.resolve("./runtime/app/layouts/dashboard.vue") };
149
+ });
150
+ addOptionalMenuSource(nuxt, { file: resolver.resolve("./runtime/menus"), menu: "dashboard" });
151
+ });
152
+ }
106
153
  function pruneWidgetsByCondition(nuxt, hasModule) {
107
154
  const logger = useLogger("dashboard");
108
155
  const hooks = nuxt.hooks;
@@ -3,7 +3,9 @@
3
3
  </script>
4
4
 
5
5
  <template>
6
- <div class="grid grid-cols-1 items-start gap-4 md:grid-cols-2 xl:grid-cols-4">
7
- <slot />
6
+ <div class="@container">
7
+ <div class="grid grid-cols-1 gap-4 @2xl:grid-cols-2 @4xl:grid-cols-4">
8
+ <slot />
9
+ </div>
8
10
  </div>
9
11
  </template>
@@ -1,8 +1,8 @@
1
1
  import type { DashboardEntry } from '../composables/useDashboard.js';
2
2
  /**
3
3
  * The frame of one dashboard item: its title with a collapse toggle, the item's component, a skeleton while the item
4
- * reports `loading` and an error with a retry. Provides `useDashboardItem()` to the component. In `editing` mode it
5
- * shows the buttons to move and hide the item (the dashboard handles the events).
4
+ * reports `loading`, an error with a retry, and nothing while it reports `empty` or renders nothing at all (a `v-if` on
5
+ * its root, as widgets shared with other widget areas do). Provides `useDashboardItem()` to the component. In `editing` mode it shows the buttons to move and hide the item (the dashboard handles the events).
6
6
  */
7
7
  type __VLS_Props = {
8
8
  item: DashboardEntry;
@@ -1,5 +1,5 @@
1
1
  <script setup>
2
- import { computed, onErrorCaptured, provide, ref } from "vue";
2
+ import { computed, onBeforeUnmount, onErrorCaptured, provide, ref, watch } from "vue";
3
3
  import { errorMessage, surfaceClass, useModuleT } from "#imports";
4
4
  import { dashboardItemKey } from "../composables/useDashboardItem";
5
5
  import { useDashboardLayout } from "../composables/useDashboardLayout";
@@ -21,6 +21,7 @@ const component = computed(() => getDashboardComponent(props.item.dashboard, pro
21
21
  const label = computed(() => props.item.title ?? props.item.id);
22
22
  const loading = ref(false);
23
23
  const error = ref(null);
24
+ const empty = ref(false);
24
25
  const renderKey = ref(0);
25
26
  let refreshHandler;
26
27
  const collapsed = computed(() => layout.value.collapsed.includes(props.item.id));
@@ -29,6 +30,7 @@ const itemContext = {
29
30
  id: props.item.id,
30
31
  loading,
31
32
  error,
33
+ empty,
32
34
  collapsed,
33
35
  settings: computed(() => layout.value.settings?.[props.item.id] ?? {}),
34
36
  setSettings: (value) => update((current) => setItemSettings(current, props.item.id, value)),
@@ -47,10 +49,28 @@ onErrorCaptured((cause) => {
47
49
  return false;
48
50
  });
49
51
  const toggle = () => update((current) => toggleCollapsed(current, props.item.id));
52
+ const blank = ref(false);
53
+ const content = ref(null);
54
+ let observer;
55
+ const check = () => {
56
+ if (content.value) blank.value = content.value.childElementCount === 0 && !content.value.textContent?.trim();
57
+ };
58
+ watch(content, (element) => {
59
+ observer?.disconnect();
60
+ if (!element || typeof MutationObserver === "undefined") return;
61
+ check();
62
+ observer = new MutationObserver(check);
63
+ observer.observe(element, { childList: true, subtree: true, characterData: true });
64
+ }, { flush: "post" });
65
+ onBeforeUnmount(() => observer?.disconnect());
66
+ const visible = computed(() => props.editing || !!error.value || !empty.value && (loading.value || !blank.value));
50
67
  </script>
51
68
 
52
69
  <template>
70
+ <!-- An item with nothing to show (`empty`, or nothing rendered) stays mounted, so it can come back, but takes no place in
71
+ the grid. -->
53
72
  <div
73
+ v-show="visible"
54
74
  :class="['flex min-w-0 flex-col gap-2', dashboardSpanClass(item.span)]"
55
75
  :data-dashboard-item="item.id"
56
76
  >
@@ -138,9 +158,11 @@ const toggle = () => update((current) => toggleCollapsed(current, props.item.id)
138
158
  <USkeleton class="h-5 w-2/3" />
139
159
  <USkeleton class="h-4 w-1/2" />
140
160
  </div>
161
+ <!-- Grows to the row's height, and so does the component's root, so cards in a row line up. -->
141
162
  <div
142
163
  v-show="!error && !loading"
143
- class="h-full"
164
+ ref="content"
165
+ class="flex min-h-0 flex-1 flex-col *:flex-1"
144
166
  >
145
167
  <component
146
168
  :is="component"
@@ -1,8 +1,8 @@
1
1
  import type { DashboardEntry } from '../composables/useDashboard.js';
2
2
  /**
3
3
  * The frame of one dashboard item: its title with a collapse toggle, the item's component, a skeleton while the item
4
- * reports `loading` and an error with a retry. Provides `useDashboardItem()` to the component. In `editing` mode it
5
- * shows the buttons to move and hide the item (the dashboard handles the events).
4
+ * reports `loading`, an error with a retry, and nothing while it reports `empty` or renders nothing at all (a `v-if` on
5
+ * its root, as widgets shared with other widget areas do). Provides `useDashboardItem()` to the component. In `editing` mode it shows the buttons to move and hide the item (the dashboard handles the events).
6
6
  */
7
7
  type __VLS_Props = {
8
8
  item: DashboardEntry;
@@ -8,6 +8,11 @@ export interface DashboardItemContext {
8
8
  loading: Ref<boolean>;
9
9
  /** Set by the item when its data failed: the frame shows the error with a retry button. */
10
10
  error: Ref<unknown>;
11
+ /**
12
+ * Set by the item when it has nothing to show this viewer (no apps, no mailbox): the frame, title included, is left
13
+ * out of the grid until it has something, except while the user edits the layout.
14
+ */
15
+ empty: Ref<boolean>;
11
16
  /** Whether the user collapsed the item. A collapsed item is not rendered. */
12
17
  collapsed: ComputedRef<boolean>;
13
18
  /** The user's settings of this item (stored in their layout). */
@@ -9,6 +9,7 @@ function standalone() {
9
9
  id: "",
10
10
  loading: ref(false),
11
11
  error,
12
+ empty: ref(false),
12
13
  collapsed: computed(() => false),
13
14
  settings: computed(() => settings.value),
14
15
  setSettings: async (value) => {
@@ -0,0 +1,23 @@
1
+ /** An entry of the hub navigation: an item of the `dashboard` menu, or the Overview without the menu module. */
2
+ export interface DashboardNavItem {
3
+ id: string;
4
+ label: string;
5
+ description?: string;
6
+ icon?: string;
7
+ to: string;
8
+ external?: boolean;
9
+ }
10
+ /** The id of the hub's own entry, the first of the `dashboard` menu. */
11
+ export declare const DASHBOARD_OVERVIEW_ID = "dashboard-overview";
12
+ /**
13
+ * The hub navigation: the items of the `dashboard` menu (the areas other modules add, filtered by their `permission`),
14
+ * or, without `@frigear-nu/menu`, only the Overview. `links` are ready for `AreaNavLayout`/`UNavigationMenu`
15
+ * (localised, `active` set, the Overview only active on the hub page), `shortcuts` are the items other than the
16
+ * Overview, and `current` is the item the route belongs to. Await it, so the menu is resolved before the page renders.
17
+ */
18
+ export declare function useDashboardNav(): Promise<{
19
+ items: import("vue").ComputedRef<DashboardNavItem[]>;
20
+ shortcuts: import("vue").ComputedRef<DashboardNavItem[]>;
21
+ links: import("vue").ComputedRef<import("@nuxt/ui").NavigationMenuItem[]>;
22
+ current: import("vue").ComputedRef<DashboardNavItem | undefined>;
23
+ }>;
@@ -0,0 +1,16 @@
1
+ import { computed, useLocaleLink, useModuleT, useNavLinks, useRuntimeConfig } from "#imports";
2
+ import { useMenu } from "#dashboard/optional";
3
+ export const DASHBOARD_OVERVIEW_ID = "dashboard-overview";
4
+ export async function useDashboardNav() {
5
+ const t = useModuleT("dashboard");
6
+ const home = useRuntimeConfig().public.dashboard?.pages?.home;
7
+ const { isActive, strip } = useLocaleLink();
8
+ const menu = typeof useMenu === "function" ? useMenu("dashboard") : void 0;
9
+ const fallback = () => home ? [{ id: DASHBOARD_OVERVIEW_ID, to: home, label: t("menu.overview.label", "Overview"), description: t("menu.overview.description", "Your shortcuts and overview."), icon: "i-lucide-layout-dashboard" }] : [];
10
+ const items = computed(() => menu ? (menu.data.value ?? []).filter((item) => !!item.to).map((item) => ({ id: item.id ?? item.to, label: item.label, description: item.description, icon: item.icon, to: item.to, external: item.external })) : fallback());
11
+ const shortcuts = computed(() => items.value.filter((item) => item.id !== DASHBOARD_OVERVIEW_ID));
12
+ const links = useNavLinks(items, { exact: home ? [home] : [] });
13
+ const current = computed(() => items.value.filter((item) => !item.external && isActive(item.to, { exact: item.to === home })).sort((a, b) => strip(b.to).length - strip(a.to).length)[0]);
14
+ if (menu) await menu;
15
+ return { items, shortcuts, links, current };
16
+ }
@@ -0,0 +1,15 @@
1
+ declare const __VLS_template: () => {
2
+ __VLS_Slots: {
3
+ default?: (props: {}) => any;
4
+ };
5
+ };
6
+ type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
7
+ declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
8
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
9
+ declare const _default: typeof __VLS_export;
10
+ export default _default;
11
+ type __VLS_WithSlots<T, S> = T & {
12
+ new (): {
13
+ $slots: S;
14
+ };
15
+ };
@@ -0,0 +1,32 @@
1
+ <script setup>
2
+ import { computed, useDashboardNav, useHead, useModuleT } from "#imports";
3
+ import { useUserSession } from "#dashboard/optional";
4
+ defineOptions({ name: "DashboardLayout" });
5
+ const siteLayout = "default";
6
+ const t = useModuleT("dashboard");
7
+ const session = typeof useUserSession === "function" ? useUserSession() : void 0;
8
+ const { links, current } = await useDashboardNav();
9
+ const user = computed(() => {
10
+ const value = session?.user.value;
11
+ if (!value) return void 0;
12
+ const name = value.name || value.email || t("hub.title", "Your dashboard");
13
+ return {
14
+ name,
15
+ description: value.name ? value.email ?? void 0 : void 0,
16
+ avatar: { src: value.avatar || void 0, alt: name }
17
+ };
18
+ });
19
+ useHead({ title: () => current.value?.label ?? t("hub.title", "Your dashboard") }, { tagPriority: "low" });
20
+ </script>
21
+
22
+ <template>
23
+ <NuxtLayout :name="siteLayout">
24
+ <AreaNavLayout
25
+ :links="links"
26
+ :user="user"
27
+ :label="t('nav.label', 'Dashboard navigation')"
28
+ >
29
+ <slot />
30
+ </AreaNavLayout>
31
+ </NuxtLayout>
32
+ </template>
@@ -0,0 +1,15 @@
1
+ declare const __VLS_template: () => {
2
+ __VLS_Slots: {
3
+ default?: (props: {}) => any;
4
+ };
5
+ };
6
+ type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
7
+ declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
8
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
9
+ declare const _default: typeof __VLS_export;
10
+ export default _default;
11
+ type __VLS_WithSlots<T, S> = T & {
12
+ new (): {
13
+ $slots: S;
14
+ };
15
+ };
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -0,0 +1,63 @@
1
+ <script setup>
2
+ import { computed, useDashboardNav, useLocaleLink, useModuleT, useRuntimeConfig } from "#imports";
3
+ import { useUserSession } from "#dashboard/optional";
4
+ defineOptions({ name: "DashboardHubPage" });
5
+ const t = useModuleT("dashboard");
6
+ const { localize } = useLocaleLink();
7
+ const name = useRuntimeConfig().public.dashboard?.homeDashboard || "home";
8
+ const session = typeof useUserSession === "function" ? useUserSession() : void 0;
9
+ const { shortcuts } = await useDashboardNav();
10
+ const firstName = computed(() => {
11
+ const user = session?.user.value;
12
+ return user?.name?.trim().split(/\s+/)[0] || "";
13
+ });
14
+ </script>
15
+
16
+ <template>
17
+ <div class="flex flex-col gap-4">
18
+ <PageHeading
19
+ :title="firstName ? t('hub.greeting', 'Hi {name}', { name: firstName }) : t('hub.title', 'Your dashboard')"
20
+ :description="t('hub.description', 'Your shortcuts and what is happening.')"
21
+ />
22
+
23
+ <UPageGrid
24
+ v-if="shortcuts.length"
25
+ class="lg:grid-cols-3"
26
+ data-dashboard-shortcuts
27
+ >
28
+ <UPageCard
29
+ v-for="item in shortcuts"
30
+ :key="item.id"
31
+ :title="item.label"
32
+ :description="item.description"
33
+ :icon="item.icon"
34
+ :to="item.external ? item.to : localize(item.to)"
35
+ variant="subtle"
36
+ :ui="{
37
+ container: 'gap-y-1.5',
38
+ wrapper: 'items-start',
39
+ leading: 'p-2.5 rounded-full bg-primary/10 ring ring-inset ring-primary/25 flex-col'
40
+ }"
41
+ />
42
+ </UPageGrid>
43
+
44
+ <Dashboard :name="name">
45
+ <!-- An empty dashboard: the hub's own empty state, or nothing below the shortcuts (an empty slot would show the
46
+ dashboard's default one). -->
47
+ <template #empty>
48
+ <UEmpty
49
+ v-if="!shortcuts.length"
50
+ icon="i-lucide-layout-dashboard"
51
+ :title="t('hub.empty.title', 'Nothing here yet')"
52
+ :description="t('hub.empty.description', 'Shortcuts and overviews appear here as your organisation turns on more features.')"
53
+ variant="naked"
54
+ />
55
+ <div
56
+ v-else
57
+ class="hidden"
58
+ data-dashboard-empty
59
+ />
60
+ </template>
61
+ </Dashboard>
62
+ </div>
63
+ </template>
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -1,8 +1,8 @@
1
1
  const spans = {
2
2
  1: "",
3
- 2: "md:col-span-2",
4
- 3: "md:col-span-2 xl:col-span-3",
5
- 4: "md:col-span-2 xl:col-span-4"
3
+ 2: "@2xl:col-span-2",
4
+ 3: "@2xl:col-span-2 @4xl:col-span-3",
5
+ 4: "@2xl:col-span-2 @4xl:col-span-4"
6
6
  };
7
7
  export function dashboardSpanClass(span) {
8
8
  const key = Math.min(4, Math.max(1, Math.trunc(span ?? 1)));
@@ -44,6 +44,28 @@
44
44
  "permissions": {
45
45
  "layouts": "Dine oversigter",
46
46
  "layoutsDescription": "Se og ændr rækkefølgen og de skjulte og sammenklappede elementer på dine oversigter."
47
+ },
48
+ "hub": {
49
+ "title": "Dit dashboard",
50
+ "greeting": "Hej {name}",
51
+ "description": "Dine genveje og hvad der sker.",
52
+ "empty": {
53
+ "title": "Intet her endnu",
54
+ "description": "Genveje og overblik dukker op her, efterhånden som jeres organisation slår flere funktioner til."
55
+ }
56
+ },
57
+ "nav": {
58
+ "label": "Dashboardnavigation"
59
+ },
60
+ "menu": {
61
+ "dashboard": {
62
+ "label": "Dashboard",
63
+ "description": "Dine genveje og dit overblik."
64
+ },
65
+ "overview": {
66
+ "label": "Overblik",
67
+ "description": "Dine genveje og dit overblik."
68
+ }
47
69
  }
48
70
  }
49
71
  }
@@ -44,6 +44,28 @@
44
44
  "permissions": {
45
45
  "layouts": "Your dashboard layouts",
46
46
  "layoutsDescription": "See and change the order, hidden and collapsed items of your dashboards."
47
+ },
48
+ "hub": {
49
+ "title": "Your dashboard",
50
+ "greeting": "Hi {name}",
51
+ "description": "Your shortcuts and what is happening.",
52
+ "empty": {
53
+ "title": "Nothing here yet",
54
+ "description": "Shortcuts and overviews appear here as your organisation turns on more features."
55
+ }
56
+ },
57
+ "nav": {
58
+ "label": "Dashboard navigation"
59
+ },
60
+ "menu": {
61
+ "dashboard": {
62
+ "label": "Dashboard",
63
+ "description": "Your shortcuts and overview."
64
+ },
65
+ "overview": {
66
+ "label": "Overview",
67
+ "description": "Your shortcuts and overview."
68
+ }
47
69
  }
48
70
  }
49
71
  }
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@frigear-nu/menu").MenuSource;
2
+ export default _default;
@@ -0,0 +1,26 @@
1
+ import { extendMenuItem, defineMenuSource } from "@frigear-nu/menu/utils";
2
+ import { useRuntimeConfig } from "#imports";
3
+ export default defineMenuSource(() => {
4
+ const path = useRuntimeConfig().public.dashboard?.pages?.home;
5
+ if (!path) return;
6
+ extendMenuItem("account.dropdown", {
7
+ id: "dashboard",
8
+ label: "Dashboard",
9
+ labelKey: "dashboard.menu.dashboard.label",
10
+ description: "Your shortcuts and overview.",
11
+ descriptionKey: "dashboard.menu.dashboard.description",
12
+ icon: "i-lucide-layout-dashboard",
13
+ to: path,
14
+ order: -100
15
+ });
16
+ extendMenuItem("dashboard", {
17
+ id: "dashboard-overview",
18
+ label: "Overview",
19
+ labelKey: "dashboard.menu.overview.label",
20
+ description: "Your shortcuts and overview.",
21
+ descriptionKey: "dashboard.menu.overview.description",
22
+ icon: "i-lucide-layout-dashboard",
23
+ to: path,
24
+ order: 0
25
+ });
26
+ });
@@ -0,0 +1,18 @@
1
+ import type { DashboardSettings } from '../../types.js';
2
+ export declare const HUB_DEFAULTS: {
3
+ readonly path: "/dashboard";
4
+ readonly dashboard: "home";
5
+ };
6
+ export interface ResolvedHub {
7
+ /** The hub page's path, also the base of the `dashboard` layout's area. */
8
+ path: string;
9
+ /** The dashboard the hub page renders. */
10
+ dashboard: string;
11
+ }
12
+ /**
13
+ * The signed-in hub, or `undefined` when there is none: `settings.pages.home: false`, or no `@frigear-nu/auth` (a hub
14
+ * for signed-in users needs users).
15
+ */
16
+ export declare function resolveHub(settings: DashboardSettings | undefined, { auth }: {
17
+ auth: boolean;
18
+ }): ResolvedHub | undefined;
@@ -0,0 +1,8 @@
1
+ export const HUB_DEFAULTS = { path: "/dashboard", dashboard: "home" };
2
+ export function resolveHub(settings, { auth }) {
3
+ const option = settings?.pages?.home ?? true;
4
+ if (option === false || !auth) return void 0;
5
+ const raw = typeof option === "string" && option ? option : HUB_DEFAULTS.path;
6
+ const path = raw.startsWith("/") ? raw : `/${raw}`;
7
+ return { path, dashboard: settings?.home?.dashboard || HUB_DEFAULTS.dashboard };
8
+ }
@@ -0,0 +1,8 @@
1
+ import type { Nuxt } from '@nuxt/schema';
2
+ /**
3
+ * The name of the dashboard the signed-in hub renders (`dashboard.settings.home.dashboard`, `home` by default), read
4
+ * from the app's options so it works from a module set up before the dashboard. Modules add hub items with
5
+ * `extendDashboard(nuxt, resolveHubDashboardName(nuxt), ...)`; whether there is a hub at all is
6
+ * `resolveDashboardHubPath` of `@frigear-nu/module-kit/utils`.
7
+ */
8
+ export declare function resolveHubDashboardName(nuxt: Nuxt): string;
@@ -0,0 +1,5 @@
1
+ import { HUB_DEFAULTS } from "../shared/hub.js";
2
+ export function resolveHubDashboardName(nuxt) {
3
+ const options = nuxt.options.dashboard;
4
+ return options && options.settings?.home?.dashboard || HUB_DEFAULTS.dashboard;
5
+ }
@@ -1,4 +1,5 @@
1
1
  export { extendDashboard, getDashboardItems } from './dashboard.js';
2
+ export { resolveHubDashboardName } from './hub.js';
2
3
  export { dashboardArea, resolveDashboardRegistry } from '../shared/registry.js';
3
4
  export { applyLayout, emptyLayout, filterByPlatform, hideItem, isOnPlatform, minimalOrder, moveItem, normalizeLayout, orderItems, pruneLayout, resetLayout, setItemSettings, showItem, toggleCollapsed, } from '../shared/layout.js';
4
5
  export type { DashboardItem, DashboardItemCondition, DashboardLayout, DashboardPlatform, DashboardRegistryEntry, } from '../../types.js';
@@ -1,4 +1,5 @@
1
1
  export { extendDashboard, getDashboardItems } from "./dashboard.js";
2
+ export { resolveHubDashboardName } from "./hub.js";
2
3
  export { dashboardArea, resolveDashboardRegistry } from "../shared/registry.js";
3
4
  export {
4
5
  applyLayout,
package/dist/types.d.mts CHANGED
@@ -1,3 +1,3 @@
1
1
  export { default } from './module.mjs'
2
2
 
3
- export { type DashboardHomeTabOptions, type DashboardItem, type DashboardItemCondition, type DashboardLayout, type DashboardLayoutsDto, type DashboardPlatform, type DashboardPublicConfig, type DashboardRegistryEntry, type ModuleOptions } from './module.mjs'
3
+ export { type DashboardHomeTabOptions, type DashboardItem, type DashboardItemCondition, type DashboardLayout, type DashboardLayoutsDto, type DashboardPagesOptions, type DashboardPlatform, type DashboardPublicConfig, type DashboardRegistryEntry, type DashboardSettings, type ModuleOptions } from './module.mjs'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frigear-nu/dashboard",
3
- "version": "0.0.0",
3
+ "version": "0.0.1",
4
4
  "description": "Customisable dashboards: modules add items to a named dashboard (extendDashboard), pages render them with <Dashboard> or their own layout (useDashboard), and each user reorders, hides and collapses items.",
5
5
  "homepage": "https://docs.frigear.dev/modules/interface/dashboard",
6
6
  "repository": {
@@ -36,17 +36,18 @@
36
36
  "dist"
37
37
  ],
38
38
  "dependencies": {
39
- "@frigear-nu/module-kit": "^1.3.7",
40
- "@frigear-nu/ui": "^0.2.7",
41
- "@frigear-nu/widget": "^0.4.0",
39
+ "@frigear-nu/module-kit": "^1.3.8",
40
+ "@frigear-nu/ui": "^0.2.8",
41
+ "@frigear-nu/widget": "^0.4.1",
42
42
  "@nuxt/kit": "^4.6.4",
43
43
  "drizzle-orm": "^0.45.4",
44
44
  "zod": "^4.6.7"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "@frigear-nu/auth": "^0.6.4",
48
+ "@frigear-nu/menu": "^0.4.0",
48
49
  "@frigear-nu/mobile": "^0.6.2",
49
- "@frigear-nu/preferences": "^0.3.1",
50
+ "@frigear-nu/preferences": "^0.3.2",
50
51
  "@nuxt/ui": "^4.12.0",
51
52
  "@nuxthub/core": "^0.10.12",
52
53
  "vue": "3.x"
@@ -55,6 +56,9 @@
55
56
  "@frigear-nu/auth": {
56
57
  "optional": true
57
58
  },
59
+ "@frigear-nu/menu": {
60
+ "optional": true
61
+ },
58
62
  "@frigear-nu/mobile": {
59
63
  "optional": true
60
64
  },
@@ -67,8 +71,10 @@
67
71
  },
68
72
  "devDependencies": {
69
73
  "@frigear-nu/auth": "^0.6.4",
74
+ "@frigear-nu/authorization": "^0.6.2",
75
+ "@frigear-nu/menu": "^0.4.0",
70
76
  "@frigear-nu/mobile": "^0.6.2",
71
- "@frigear-nu/preferences": "^0.3.1",
77
+ "@frigear-nu/preferences": "^0.3.2",
72
78
  "@frigear-nu/users": "^3.1.2",
73
79
  "@libsql/client": "^0.18.0",
74
80
  "@nuxt/eslint-config": "^1.17.0",