@falcondev-oss/nuxt-layers-base 0.11.0 → 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,11 +1,14 @@
1
1
  <script setup lang="ts">
2
2
  import type {
3
3
  DashboardNavbarProps,
4
+ DashboardNavbarSlots,
4
5
  DashboardPanelProps,
5
6
  DashboardSidebarProps,
6
7
  DashboardToolbarProps,
7
8
  NavigationMenuItem,
8
9
  } from '@nuxt/ui'
10
+ import type { AddPropertyPrefix } from '~/types/helpers'
11
+ import { keys, omit, pickBy, pipe, pullObject } from 'remeda'
9
12
 
10
13
  defineProps<{
11
14
  sidebar?: {
@@ -40,9 +43,26 @@ defineProps<{
40
43
  }
41
44
  }>()
42
45
 
43
- defineSlots<{
44
- default: any
45
- }>()
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
+ )
46
66
 
47
67
  const config = useRuntimeConfig()
48
68
  </script>
@@ -115,6 +135,11 @@ const config = useRuntimeConfig()
115
135
  <template #leading>
116
136
  <UDashboardSidebarCollapse />
117
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>
118
143
  </UDashboardNavbar>
119
144
  <UDashboardToolbar v-if="panel?.toolbar" :ui="panel.toolbar.ui" class="bg-white">
120
145
  <UNavigationMenu :items="panel.toolbar.items" highlight :ui="panel.toolbar.itemsUi" />
@@ -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.11.0",
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",