@falcondev-oss/nuxt-layers-base 0.10.3 → 0.12.0

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,5 +1,14 @@
1
1
  <script setup lang="ts">
2
- import type { NavigationMenuItem } from '@nuxt/ui'
2
+ import type {
3
+ DashboardNavbarProps,
4
+ DashboardNavbarSlots,
5
+ DashboardPanelProps,
6
+ DashboardSidebarProps,
7
+ DashboardToolbarProps,
8
+ NavigationMenuItem,
9
+ } from '@nuxt/ui'
10
+ import type { AddPropertyPrefix } from '~/types/helpers'
11
+ import { keys, omit, pickBy, pipe, pullObject } from 'remeda'
3
12
 
4
13
  defineProps<{
5
14
  sidebar?: {
@@ -13,27 +22,61 @@ defineProps<{
13
22
  name: string
14
23
  avatarSrc?: string
15
24
  }
25
+ ui?: DashboardSidebarProps['ui']
26
+ itemsUi?: NavigationMenuItem['ui']
27
+ bottomItemsUi?: NavigationMenuItem['ui']
16
28
  }
17
- navbar?: {
18
- title?: string
19
- }
20
- toolbar?: {
21
- items?: NavigationMenuItem[]
22
- itemsEnd?: NavigationMenuItem[]
29
+ panel?: {
30
+ navbar?: {
31
+ title?: string
32
+ ui?: DashboardNavbarProps['ui']
33
+ }
34
+ toolbar?: {
35
+ items?: NavigationMenuItem[]
36
+ itemsEnd?: NavigationMenuItem[]
37
+ ui?: DashboardToolbarProps['ui']
38
+ itemsUi?: NavigationMenuItem['ui']
39
+ itemsEndUi?: NavigationMenuItem['ui']
40
+ }
41
+ container?: boolean
42
+ ui?: DashboardPanelProps['ui']
23
43
  }
24
- container?: boolean
25
44
  }>()
26
45
 
27
- defineSlots<{
28
- default: any
29
- }>()
46
+ const slots = defineSlots<
47
+ {
48
+ default: any
49
+ } & AddPropertyPrefix<DashboardNavbarSlots, 'navbar'>
50
+ >()
51
+
52
+ const omitNavbarSlots = ['navbar-leading'] satisfies (keyof typeof slots)[]
53
+
54
+ const navbarSlots = computed(() =>
55
+ pipe(
56
+ slots,
57
+ pickBy((_, key) => key.startsWith('navbar-')),
58
+ omit(omitNavbarSlots),
59
+ keys(),
60
+ pullObject(
61
+ (key) => key.replace('navbar-', ''),
62
+ (key) => key,
63
+ ),
64
+ ),
65
+ )
30
66
 
31
67
  const config = useRuntimeConfig()
32
68
  </script>
33
69
 
34
70
  <template>
35
71
  <UDashboardGroup storage="local" :storage-key="`${config.public.projectId}-dashboard`" unit="rem">
36
- <UDashboardSidebar v-if="sidebar" collapsible resizable class="bg-white" mode="drawer">
72
+ <UDashboardSidebar
73
+ v-if="sidebar"
74
+ :ui="sidebar.ui"
75
+ collapsible
76
+ resizable
77
+ class="bg-white"
78
+ mode="drawer"
79
+ >
37
80
  <template v-if="sidebar.logo?.src || sidebar.logo?.iconSrc" #header="{ collapsed }">
38
81
  <img
39
82
  v-if="!collapsed && sidebar.logo.src"
@@ -55,6 +98,7 @@ const config = useRuntimeConfig()
55
98
  :collapsed="collapsed"
56
99
  :items="sidebar.items"
57
100
  orientation="vertical"
101
+ :ui="sidebar.itemsUi"
58
102
  />
59
103
 
60
104
  <UNavigationMenu
@@ -63,6 +107,7 @@ const config = useRuntimeConfig()
63
107
  :items="sidebar.bottomItems"
64
108
  orientation="vertical"
65
109
  class="mt-auto"
110
+ :ui="sidebar.bottomItemsUi"
66
111
  />
67
112
  </template>
68
113
  <template v-if="sidebar.userMenu" #footer="{ collapsed }">
@@ -81,18 +126,33 @@ const config = useRuntimeConfig()
81
126
  </UDashboardSidebar>
82
127
  <UDashboardPanel>
83
128
  <template #header>
84
- <UDashboardNavbar v-if="navbar" class="bg-white" :title="navbar.title">
129
+ <UDashboardNavbar
130
+ v-if="panel?.navbar"
131
+ :ui="panel.navbar.ui"
132
+ class="bg-white"
133
+ :title="panel.navbar.title"
134
+ >
85
135
  <template #leading>
86
136
  <UDashboardSidebarCollapse />
87
137
  </template>
138
+
139
+ <template v-for="(originalName, slotName) in navbarSlots" #[slotName]="slotData">
140
+ <!-- @vue-ignore -->
141
+ <slot :name="originalName" v-bind="slotData || {}" />
142
+ </template>
88
143
  </UDashboardNavbar>
89
- <UDashboardToolbar v-if="toolbar" class="bg-white">
90
- <UNavigationMenu :items="toolbar.items" highlight />
91
- <UNavigationMenu :items="toolbar.itemsEnd" class="ml-auto" highlight />
144
+ <UDashboardToolbar v-if="panel?.toolbar" :ui="panel.toolbar.ui" class="bg-white">
145
+ <UNavigationMenu :items="panel.toolbar.items" highlight :ui="panel.toolbar.itemsUi" />
146
+ <UNavigationMenu
147
+ :items="panel.toolbar.itemsEnd"
148
+ class="ml-auto"
149
+ highlight
150
+ :ui="panel.toolbar.itemsEndUi"
151
+ />
92
152
  </UDashboardToolbar>
93
153
  </template>
94
154
  <template #body>
95
- <UContainer v-if="container">
155
+ <UContainer v-if="panel?.container">
96
156
  <slot />
97
157
  </UContainer>
98
158
  <slot v-else />
@@ -8,6 +8,7 @@ import type {
8
8
  NavigationMenuItem,
9
9
  NavigationMenuProps,
10
10
  } from '@nuxt/ui'
11
+ import type { AddPropertyPrefix } from '~/types/helpers'
11
12
  import { keys, omit, pickBy, pipe, pullObject } from 'remeda'
12
13
 
13
14
  defineProps<{
@@ -34,10 +35,6 @@ const slots = defineSlots<
34
35
  AddPropertyPrefix<FooterSlots, 'footer'>
35
36
  >()
36
37
 
37
- type AddPropertyPrefix<T extends object, P extends string> = {
38
- [K in keyof T as `${P}-${K & string}`]: T[K]
39
- }
40
-
41
38
  const omitHeaderSlots = [
42
39
  'header-title',
43
40
  'header-right',
@@ -0,0 +1,3 @@
1
+ export type AddPropertyPrefix<T extends object, P extends string> = {
2
+ [K in keyof T as `${P}-${K & string}`]: T[K]
3
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@falcondev-oss/nuxt-layers-base",
3
3
  "type": "module",
4
- "version": "0.10.3",
4
+ "version": "0.12.0",
5
5
  "description": "Nuxt layer with lots of useful helpers and @nuxt/ui components",
6
6
  "license": "MIT",
7
7
  "repository": "github:falcondev-oss/nuxt-layers",