@happydesigns/ui 0.19.1 → 0.19.3

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/app/app.config.ts CHANGED
@@ -1,84 +1,80 @@
1
- import type { AppConfigInput as NuxtUiConfigInput } from '@nuxt/schema'
2
- import type { BadgeProps, ButtonProps } from '@nuxt/ui'
3
- import type { AppConfigInput as LayerAppConfigInput } from 'nuxt/schema'
4
- import type { QueryConfig, SearchConfig } from './types/config'
5
-
6
- export * from './types/config'
7
-
8
- const ui = {
9
- main: {
10
- base: 'wrap-break-word',
11
- },
12
- } satisfies NonNullable<NuxtUiConfigInput['ui']>
13
-
14
- export default defineAppConfig({
15
- variants: {
16
- // UI feature variants — config overrides (extends defined in nuxt.config.ts)
17
- user: { config: { user: { target: '_blank' } } },
18
- backButton: { config: { backButton: { icon: 'i-ph-arrow-left', label: 'Back' } as Pick<ButtonProps, 'icon' | 'label' | 'to'> } },
19
- copyButton: {
20
- config: {
21
- copyButton: {
22
- icon: 'i-ph-link-simple-duotone',
23
- label: 'Copy URL',
24
- successIcon: 'i-lucide-copy-check',
25
- successLabel: 'Link copied to clipboard',
26
- errorIcon: 'i-lucide-copy-x',
27
- errorLabel: 'Link could not be copied',
28
- },
29
- },
30
- },
31
- separator: { config: { separator: { buttons: [], separator: 'or' } } },
32
- surround: {
33
- config: {
34
- surround: {
35
- show: true,
36
- prevIcon: 'i-lucide-arrow-left',
37
- nextIcon: 'i-lucide-arrow-right',
38
- prevLabel: 'Previous',
39
- nextLabel: 'Next',
40
- },
41
- },
42
- },
43
-
44
- // Collection variants — runtime config overrides only
45
- article: {
46
- config: {
47
- query: {
48
- fields: ['title', 'description', 'published', 'date'],
49
- order: { field: 'date', direction: 'DESC' },
50
- where: [{ field: 'published', operator: '=', value: true }],
51
- } as QueryConfig,
52
- categories: {} as Record<string, BadgeProps>,
53
- breadcrumbs: [],
54
- list: {
55
- itemsPerPage: 12,
56
- labelAll: 'All',
57
- noResultsMessage: 'No articles found.',
58
- noResultsIcon: 'i-ph-article-ny-times-light',
59
- },
60
- },
61
- },
62
- event: {
63
- config: {
64
- query: {
65
- fields: ['title', 'description', 'published', 'date', 'dateEnd', 'location'],
66
- order: { field: 'date', direction: 'DESC' },
67
- where: [{ field: 'published', operator: '=', value: true }],
68
- } as QueryConfig,
69
- categories: {} as Record<string, BadgeProps>,
70
- breadcrumbs: [],
71
- list: {
72
- itemsPerPage: 12,
73
- labelAll: 'All',
74
- noResultsMessage: 'No events found.',
75
- noResultsIcon: 'i-ph-calendar-blank',
76
- },
77
- },
78
- },
79
- },
80
-
81
- app: {
1
+ import type { AppConfigInput } from '@nuxt/schema'
2
+ import type { BadgeProps, ButtonProps } from '@nuxt/ui'
3
+ import type { QueryConfig, SearchConfig } from './types/config'
4
+
5
+ export * from './types/config'
6
+
7
+ const ui = {
8
+ main: {
9
+ base: 'wrap-break-word',
10
+ },
11
+ } satisfies NonNullable<AppConfigInput['ui']>
12
+
13
+ export default defineAppConfig({
14
+ variants: {
15
+ user: { config: { user: { target: '_blank' } } },
16
+ backButton: { config: { backButton: { icon: 'i-ph-arrow-left', label: 'Back' } as Pick<ButtonProps, 'icon' | 'label' | 'to'> } },
17
+ copyButton: {
18
+ config: {
19
+ copyButton: {
20
+ icon: 'i-ph-link-simple-duotone',
21
+ label: 'Copy URL',
22
+ successIcon: 'i-lucide-copy-check',
23
+ successLabel: 'Link copied to clipboard',
24
+ errorIcon: 'i-lucide-copy-x',
25
+ errorLabel: 'Link could not be copied',
26
+ },
27
+ },
28
+ },
29
+ separator: { config: { separator: { buttons: [], separator: 'or' } } },
30
+ surround: {
31
+ config: {
32
+ surround: {
33
+ show: true,
34
+ prevIcon: 'i-lucide-arrow-left',
35
+ nextIcon: 'i-lucide-arrow-right',
36
+ prevLabel: 'Previous',
37
+ nextLabel: 'Next',
38
+ },
39
+ },
40
+ },
41
+ article: {
42
+ config: {
43
+ query: {
44
+ fields: ['title', 'description', 'published', 'date'],
45
+ order: { field: 'date', direction: 'DESC' },
46
+ where: [{ field: 'published', operator: '=', value: true }],
47
+ } as QueryConfig,
48
+ categories: {} as Record<string, BadgeProps>,
49
+ breadcrumbs: [],
50
+ list: {
51
+ itemsPerPage: 12,
52
+ labelAll: 'All',
53
+ noResultsMessage: 'No articles found.',
54
+ noResultsIcon: 'i-ph-article-ny-times-light',
55
+ },
56
+ },
57
+ },
58
+ event: {
59
+ config: {
60
+ query: {
61
+ fields: ['title', 'description', 'published', 'date', 'dateEnd', 'location'],
62
+ order: { field: 'date', direction: 'DESC' },
63
+ where: [{ field: 'published', operator: '=', value: true }],
64
+ } as QueryConfig,
65
+ categories: {} as Record<string, BadgeProps>,
66
+ breadcrumbs: [],
67
+ list: {
68
+ itemsPerPage: 12,
69
+ labelAll: 'All',
70
+ noResultsMessage: 'No events found.',
71
+ noResultsIcon: 'i-ph-calendar-blank',
72
+ },
73
+ },
74
+ },
75
+ },
76
+
77
+ app: {
82
78
  meta: {
83
79
  copyright: {},
84
80
  socials: [],
@@ -138,8 +134,7 @@ export default defineAppConfig({
138
134
  minute: 'numeric',
139
135
  } as Intl.DateTimeFormatOptions,
140
136
  },
141
- },
142
-
143
- // The object is validated above; this bridges Nuxt's generated runtime-complete layer type.
144
- ui: ui as unknown as LayerAppConfigInput['ui'],
145
- })
137
+ },
138
+
139
+ ui,
140
+ })
@@ -0,0 +1,54 @@
1
+ <script setup lang="ts" generic="C extends PageCollectionName = 'page'">
2
+ import type { PageCollectionItemBase } from '@nuxt/content'
3
+ import type { PageCollectionName } from '../types/content'
4
+
5
+ defineOptions({ inheritAttrs: false })
6
+
7
+ const {
8
+ collection = 'page' as C,
9
+ path,
10
+ page: suppliedPage,
11
+ } = defineProps<{
12
+ /** Consumer-owned page collection. */
13
+ collection?: C
14
+ /** Route path override. The current route path is used by default. */
15
+ path?: string
16
+ /** Already resolved document, useful when a route needs project-specific side effects. */
17
+ page?: PageCollectionItemBase | null
18
+ }>()
19
+
20
+ const fetched = suppliedPage === undefined
21
+ ? await usePageContent<C>({
22
+ collection: () => collection,
23
+ path: () => path,
24
+ })
25
+ : undefined
26
+
27
+ const page = computed(() => suppliedPage === undefined ? fetched?.data.value : suppliedPage)
28
+
29
+ if (!page.value) {
30
+ throw createError({
31
+ statusCode: 404,
32
+ statusMessage: `${collection} ${path || useRoute().path} not found`,
33
+ fatal: true,
34
+ })
35
+ }
36
+ </script>
37
+
38
+ <template>
39
+ <NuxtLayout
40
+ v-if="page"
41
+ name="content"
42
+ :collection="collection"
43
+ :path="path"
44
+ :page="page"
45
+ >
46
+ <slot :page="page">
47
+ <ContentRenderer
48
+ :value="page"
49
+ class="h-content"
50
+ v-bind="$attrs"
51
+ />
52
+ </slot>
53
+ </NuxtLayout>
54
+ </template>
@@ -0,0 +1,85 @@
1
+ <script setup lang="ts">
2
+ import type { HeaderProps, NavigationMenuItem, NavigationMenuProps } from '@nuxt/ui'
3
+
4
+ type NavigationProps = Omit<NavigationMenuProps, 'items' | 'orientation' | 'modelValue' | 'defaultValue' | 'type'>
5
+
6
+ interface Props extends HeaderProps {
7
+ /** Override the app-config navigation for this header instance. */
8
+ items?: NavigationMenuItem[]
9
+ /** Props forwarded to the desktop navigation menu. */
10
+ navigation?: NavigationProps
11
+ /** Props forwarded to the mobile navigation menu. */
12
+ mobileNavigation?: NavigationProps
13
+ }
14
+
15
+ const props = withDefaults(defineProps<Props>(), {
16
+ autoClose: true,
17
+ toggle: true,
18
+ })
19
+ const open = defineModel<boolean>('open', { default: false })
20
+
21
+ const { headerLinks } = useHeaderLinks()
22
+ const items = computed(() => props.items ?? headerLinks.value)
23
+ const headerProps = computed<HeaderProps>(() => ({
24
+ as: props.as,
25
+ autoClose: props.autoClose,
26
+ class: props.class,
27
+ menu: props.menu,
28
+ mode: props.mode,
29
+ title: props.title,
30
+ to: props.to,
31
+ toggle: props.toggle,
32
+ toggleSide: props.toggleSide,
33
+ ui: props.ui,
34
+ }))
35
+ </script>
36
+
37
+ <template>
38
+ <UHeader v-model:open="open" v-bind="headerProps">
39
+ <template v-if="$slots.left" #left="slotProps">
40
+ <slot name="left" v-bind="slotProps" />
41
+ </template>
42
+
43
+ <template v-if="$slots.title" #title>
44
+ <slot name="title" />
45
+ </template>
46
+
47
+ <slot name="navigation" :items="items">
48
+ <UNavigationMenu
49
+ v-bind="props.navigation"
50
+ :items="items"
51
+ orientation="horizontal"
52
+ />
53
+ </slot>
54
+
55
+ <template v-if="$slots.right" #right>
56
+ <slot name="right" />
57
+ </template>
58
+
59
+ <template #body="slotProps">
60
+ <slot name="body" v-bind="slotProps" :items="items">
61
+ <slot name="body-before" :items="items" />
62
+ <slot name="mobile-navigation" :items="items">
63
+ <UNavigationMenu
64
+ v-bind="props.mobileNavigation"
65
+ :items="items"
66
+ orientation="vertical"
67
+ />
68
+ </slot>
69
+ <slot name="body-after" :items="items" />
70
+ </slot>
71
+ </template>
72
+
73
+ <template v-if="$slots.content" #content="slotProps">
74
+ <slot name="content" v-bind="slotProps" :items="items" />
75
+ </template>
76
+
77
+ <template v-if="$slots.top" #top>
78
+ <slot name="top" />
79
+ </template>
80
+
81
+ <template v-if="$slots.bottom" #bottom>
82
+ <slot name="bottom" />
83
+ </template>
84
+ </UHeader>
85
+ </template>
@@ -0,0 +1,40 @@
1
+ <script setup lang="ts">
2
+ import type { BreadcrumbItem } from '@nuxt/ui'
3
+
4
+ const props = withDefaults(defineProps<{
5
+ items?: BreadcrumbItem[]
6
+ current?: BreadcrumbItem
7
+ }>(), {
8
+ items: () => [],
9
+ })
10
+
11
+ const breadcrumbItems = computed(() => {
12
+ const baseItems = props.items.map((item, index) => ({
13
+ ...item,
14
+ ui: {
15
+ ...item.ui,
16
+ ...(index === 0 ? { item: 'shrink-0', link: 'shrink-0' } : {}),
17
+ ...(props.current && index === props.items.length - 1
18
+ ? { separator: 'hidden sm:flex' }
19
+ : {}),
20
+ },
21
+ }))
22
+
23
+ return props.current
24
+ ? [
25
+ ...baseItems,
26
+ {
27
+ ...props.current,
28
+ ui: { ...props.current.ui, item: 'hidden sm:flex' },
29
+ },
30
+ ]
31
+ : baseItems
32
+ })
33
+ </script>
34
+
35
+ <template>
36
+ <UBreadcrumb
37
+ :ui="{ root: 'max-w-full' }"
38
+ :items="breadcrumbItems"
39
+ />
40
+ </template>
@@ -2,13 +2,14 @@
2
2
  import type { BreadcrumbItem } from '@nuxt/ui'
3
3
  import type { PageCollectionName } from '../types/content'
4
4
 
5
- const props = defineProps<{
6
- path?: string
7
- collection?: C
8
- }>()
9
-
10
- const route = useRoute()
11
- const collection = computed(() => props.collection ?? 'article')
5
+ const props = defineProps<{
6
+ path?: string
7
+ collection?: C
8
+ }>()
9
+
10
+ const route = useRoute()
11
+ const collection = computed(() => props.collection ?? 'article')
12
+ const surroundCollection = computed<PageCollectionName>(() => collection.value)
12
13
 
13
14
  const { data: page } = await usePageContent({
14
15
  path: () => props.path,
@@ -39,23 +40,10 @@ const header = computed(() => resolvePageHeader(page.value))
39
40
 
40
41
  const breadcrumbsBase = computed(() => (config.value.breadcrumbs ?? []) as BreadcrumbItem[])
41
42
 
42
- const breadcrumbItems = computed(() => {
43
- const baseItems = breadcrumbsBase.value.map((item, index) => ({
44
- ...item,
45
- ...(index === breadcrumbsBase.value.length - 1
46
- ? { ui: { ...item.ui, separator: 'hidden sm:flex' } }
47
- : {}),
48
- }))
49
-
50
- return [
51
- ...baseItems,
52
- {
53
- label: page.value?.title,
54
- to: page.value?.path,
55
- ui: { item: 'hidden sm:flex' },
56
- },
57
- ]
58
- })
43
+ const currentBreadcrumb = computed<BreadcrumbItem>(() => ({
44
+ label: page.value?.title,
45
+ to: page.value?.path,
46
+ }))
59
47
 
60
48
  const backLink = computed(() => {
61
49
  const lastBreadcrumb = breadcrumbsBase.value.at(-1)
@@ -78,10 +66,10 @@ const backLink = computed(() => {
78
66
  }"
79
67
  >
80
68
  <template #headline>
81
- <UBreadcrumb
82
- :ui="{ root: 'max-w-full' }"
83
- :items="breadcrumbItems"
84
- />
69
+ <HBreadcrumbs
70
+ :items="breadcrumbsBase"
71
+ :current="currentBreadcrumb"
72
+ />
85
73
  <HArticleHeadlineMeta :page="page" :collection="collection" />
86
74
  </template>
87
75
  <HArticleHeaderBody :page="page" :collection="collection">
@@ -113,9 +101,9 @@ const backLink = computed(() => {
113
101
  v-bind="config.separator"
114
102
  />
115
103
 
116
- <HSurround
117
- v-if="hasSurround"
118
- :collection="collection"
104
+ <HSurround
105
+ v-if="hasSurround"
106
+ :collection="surroundCollection"
119
107
  v-bind="config.surround"
120
108
  :query="config.query"
121
109
  />
@@ -1,21 +1,27 @@
1
- <script setup lang="ts" generic="C extends PageCollectionName = 'page'">
2
- import type { PageCollectionName } from '../types/content'
1
+ <script setup lang="ts" generic="C extends PageCollectionName = 'page'">
2
+ import type { PageCollectionItemBase } from '@nuxt/content'
3
+ import type { PageCollectionName } from '../types/content'
3
4
 
4
- const {
5
- path,
6
- collection = 'page' as C,
7
- } = defineProps<{
8
- path?: string
9
- collection?: C
10
- }>()
5
+ const {
6
+ path,
7
+ collection = 'page' as C,
8
+ page: suppliedPage,
9
+ } = defineProps<{
10
+ path?: string
11
+ collection?: C
12
+ page?: PageCollectionItemBase | null
13
+ }>()
11
14
 
12
15
  const appConfig = useAppConfig()
13
16
  const route = useRoute()
14
17
 
15
- const { data: page } = await usePageContent<C>({
16
- path: () => path,
17
- collection: () => collection,
18
- })
18
+ const fetched = suppliedPage === undefined
19
+ ? await usePageContent<C>({
20
+ path: () => path,
21
+ collection: () => collection,
22
+ })
23
+ : undefined
24
+ const page = computed(() => suppliedPage === undefined ? fetched?.data.value : suppliedPage)
19
25
 
20
26
  const variant = computed(() => {
21
27
  if (typeof route.meta.variant === 'string' && route.meta.variant) {
@@ -26,7 +32,7 @@ const variant = computed(() => {
26
32
  return route.meta.layout
27
33
  }
28
34
 
29
- return collection
35
+ return collection as string
30
36
  })
31
37
  const { has } = useVariant(variant)
32
38
  const hasHeader = has('header')
@@ -35,7 +41,7 @@ const hasToc = has('toc')
35
41
  if (!page.value) {
36
42
  throw createError({
37
43
  statusCode: 404,
38
- statusMessage: `${collection} ${path || route.path} not found`,
44
+ statusMessage: `${collection} ${path || route.path} not found`,
39
45
  fatal: true,
40
46
  })
41
47
  }
@@ -0,0 +1,20 @@
1
+ interface ContentRouteLocation {
2
+ path?: string
3
+ fullPath?: string
4
+ }
5
+
6
+ const FILE_PATH_PATTERN = /\/[^/]+\.[0-9a-z]+$/i
7
+
8
+ /**
9
+ * Keeps a catch-all content page away from Nuxt internals, API routes and
10
+ * requests that look like public files.
11
+ */
12
+ export function isContentPageRoute(route: ContentRouteLocation): boolean {
13
+ const path = route.path ?? route.fullPath?.split(/[?#]/, 1)[0] ?? ''
14
+
15
+ if (path.startsWith('/_') || path === '/api' || path.startsWith('/api/')) {
16
+ return false
17
+ }
18
+
19
+ return !FILE_PATH_PATTERN.test(path)
20
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@happydesigns/ui",
3
3
  "type": "module",
4
- "version": "0.19.1",
4
+ "version": "0.19.3",
5
5
  "private": false,
6
6
  "packageManager": "pnpm@11.11.0",
7
7
  "description": "A reusable Nuxt foundation for content-driven happydesigns websites and applications.",
@@ -37,6 +37,9 @@
37
37
  "server",
38
38
  "shared"
39
39
  ],
40
+ "engines": {
41
+ "node": "^22.19.0 || ^24.11.0 || >=26.0.0"
42
+ },
40
43
  "publishConfig": {
41
44
  "access": "public"
42
45
  },
@@ -62,10 +65,11 @@
62
65
  "release:beta": "changelogen --release --versionSuffix beta.0"
63
66
  },
64
67
  "peerDependencies": {
65
- "tailwindcss": "^4.3.2"
68
+ "tailwindcss": "^4.3.2",
69
+ "vue": "^3.5.41"
66
70
  },
67
71
  "dependencies": {
68
- "@happydesigns/nuxt-variants": "^0.1.1",
72
+ "@happydesigns/nuxt-variants": "^0.2.0",
69
73
  "@iconify-json/heroicons": "^1.2.3",
70
74
  "@iconify-json/lucide": "^1.2.116",
71
75
  "@iconify-json/simple-icons": "^1.2.89",
package/schemas/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './collections'
2
- export * from './indexes'
2
+ export * from './indexes'
3
+ export * from './primitives'
3
4
  export * from './traits'
4
5
  export * from './variants'
@@ -0,0 +1,19 @@
1
+ import { property } from '@nuxt/content'
2
+ import { z } from 'zod'
3
+
4
+ /** Studio-aware string field for media stored in the consumer application. */
5
+ export const mediaSourceSchema = property(z.string()).editor({ input: 'media' })
6
+
7
+ /** Accessible baseline for content-managed images. Projects can extend it. */
8
+ export const contentImageSchema = z.object({
9
+ src: mediaSourceSchema,
10
+ alt: z.string(),
11
+ })
12
+
13
+ /**
14
+ * Creates a Studio-aware schema that inherits the current Nuxt UI PageSection
15
+ * props while retaining project-specific fields.
16
+ */
17
+ export function createPageSectionSchema<T extends Record<string, z.ZodType>>(shape: T) {
18
+ return property(z.object(shape)).inherit('@nuxt/ui/components/PageSection.vue')
19
+ }
@@ -1,10 +1,12 @@
1
+ import { defineVariantRegistry } from '@happydesigns/nuxt-variants/schemas'
2
+
1
3
  /**
2
4
  * Public variant registry shared by the Nuxt module and schema composition.
3
5
  *
4
6
  * Keeping the registry in one place guarantees that runtime inheritance and
5
7
  * Nuxt Content schemas are derived from the same explicit variant graph.
6
8
  */
7
- export const variantRegistry = {
9
+ export const variantRegistry = defineVariantRegistry({
8
10
  // Data features — schema only, no config
9
11
  dates: {},
10
12
  authors: {},
@@ -17,7 +19,7 @@ export const variantRegistry = {
17
19
  layout: {},
18
20
  separatorButtons: {},
19
21
 
20
- // UI features — config defined in app.config.ts
22
+ // UI features — values are supplied through app.config.ts.
21
23
  user: {},
22
24
  backButton: {},
23
25
  copyButton: {},
@@ -38,4 +40,4 @@ export const variantRegistry = {
38
40
  extends: ['layout', 'header', 'toc'],
39
41
  config: {},
40
42
  },
41
- }
43
+ })
@@ -10,14 +10,4 @@ declare module '@nuxt/schema' {
10
10
  }
11
11
  }
12
12
 
13
- declare module 'nuxt/schema' {
14
- interface AppConfigInput {
15
- app?: HAppConfigInput
16
- }
17
-
18
- interface AppConfig {
19
- app: HAppConfig
20
- }
21
- }
22
-
23
13
  export {}