@happydesigns/ui 0.15.1 → 0.16.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.
package/app/app.config.ts CHANGED
@@ -35,9 +35,9 @@ export default defineAppConfig({
35
35
  article: {
36
36
  config: {
37
37
  query: {
38
- fields: ['title', 'description', 'status', 'date'],
38
+ fields: ['title', 'description', 'published', 'date'],
39
39
  order: { field: 'date', direction: 'DESC' },
40
- where: [{ field: 'status', operator: '=', value: 'published' }],
40
+ where: [{ field: 'published', operator: '=', value: true }],
41
41
  } as QueryConfig,
42
42
  categories: {} as Record<string, BadgeProps>,
43
43
  breadcrumbs: [],
@@ -52,9 +52,9 @@ export default defineAppConfig({
52
52
  event: {
53
53
  config: {
54
54
  query: {
55
- fields: ['title', 'description', 'status', 'date', 'dateEnd', 'location'],
55
+ fields: ['title', 'description', 'published', 'date', 'dateEnd', 'location'],
56
56
  order: { field: 'date', direction: 'DESC' },
57
- where: [{ field: 'status', operator: '=', value: 'published' }],
57
+ where: [{ field: 'published', operator: '=', value: true }],
58
58
  } as QueryConfig,
59
59
  categories: {} as Record<string, BadgeProps>,
60
60
  breadcrumbs: [],
@@ -13,13 +13,13 @@ const props = withDefaults(defineProps<{
13
13
  where?: ArticleFilter[]
14
14
  /** Field to sort by. Set to false to disable default sorting. */
15
15
  sort?: { field: string, direction: 'ASC' | 'DESC' } | false
16
- /** Status to filter by. Set to false to disable default status filtering. */
17
- status?: string | false
16
+ /** Whether to return only published entries. Defaults to true. */
17
+ publishedOnly?: boolean
18
18
  /** Optional items per page override */
19
19
  itemsPerPage?: number
20
20
  }>(), {
21
21
  sort: undefined,
22
- status: undefined,
22
+ publishedOnly: true,
23
23
  })
24
24
 
25
25
  /** Resolve the configuration for this collection using the smart merger */
@@ -43,7 +43,7 @@ const { data, status: fetchStatus } = await useArticleList({
43
43
  collection: () => props.collection || 'article' as C,
44
44
  where: () => props.where,
45
45
  sort: () => props.sort,
46
- status: () => props.status,
46
+ publishedOnly: () => props.publishedOnly,
47
47
  })
48
48
 
49
49
  const hasArticles = computed(() => Boolean(data.value?.articles.length))
@@ -14,13 +14,13 @@ const props = withDefaults(defineProps<{
14
14
  where?: ArticleFilter[]
15
15
  /** Field to sort by. Set to false to disable default sorting. */
16
16
  sort?: { field: string, direction: 'ASC' | 'DESC' } | false
17
- /** Status to filter by. Set to false to disable default status filtering. */
18
- status?: string | false
17
+ /** Whether to return only published entries. Defaults to true. */
18
+ publishedOnly?: boolean
19
19
  /** Optional items per page override */
20
20
  itemsPerPage?: number
21
21
  }>(), {
22
22
  sort: undefined,
23
- status: undefined,
23
+ publishedOnly: true,
24
24
  })
25
25
 
26
26
  /** Resolve the configuration for this collection using the smart merger */
@@ -69,7 +69,7 @@ const categories = computed(() => {
69
69
  :collection="props.collection"
70
70
  :where="props.where"
71
71
  :sort="props.sort"
72
- :status="props.status"
72
+ :published-only="props.publishedOnly"
73
73
  :items-per-page="props.itemsPerPage"
74
74
  >
75
75
  <template v-for="(_, name) in $slots" #[name]="slotData">
@@ -21,9 +21,9 @@ const { data: surround } = await useAsyncData(
21
21
  const colName = collection.value as any
22
22
  const qc = props.query || {}
23
23
 
24
- const fields = (qc.fields || ['title', 'description', 'status']) as any
24
+ const fields = (qc.fields || ['title', 'description', 'published']) as any
25
25
  const order = qc.order
26
- const where = qc.where || [{ field: 'status', operator: '=', value: 'published' }]
26
+ const where = qc.where || [{ field: 'published', operator: '=', value: true }]
27
27
 
28
28
  let query = queryCollectionItemSurroundings(colName, path.value, { fields })
29
29
 
@@ -20,8 +20,8 @@ export interface UseArticleListOptions<C extends keyof PageCollections = 'articl
20
20
  where?: MaybeRefOrGetter<ArticleFilter[] | undefined>
21
21
  /** Field to sort by. Set to false to disable default sorting. Defaults to { field: 'date', direction: 'DESC' }. */
22
22
  sort?: MaybeRefOrGetter<{ field: string, direction: 'ASC' | 'DESC' } | false | undefined>
23
- /** Status to filter by. Set to false to disable default status filtering. Defaults to 'published'. */
24
- status?: MaybeRefOrGetter<string | false | undefined>
23
+ /** Whether to return only published entries. Defaults to true. */
24
+ publishedOnly?: MaybeRefOrGetter<boolean | undefined>
25
25
  /** Whether the list should load lazily during client-side navigation. Defaults to false. */
26
26
  lazy?: MaybeRefOrGetter<boolean | undefined>
27
27
  }
@@ -45,8 +45,8 @@ export function useArticleList<C extends keyof PageCollections = 'article'>(opti
45
45
  if (w)
46
46
  return w
47
47
 
48
- // Fallback to config where but filter out status if handled separately
49
- return config.value.query?.where?.filter(f => f.field !== 'status') || []
48
+ // Fallback to config where but filter out publication if handled separately
49
+ return config.value.query?.where?.filter(f => f.field !== 'published') || []
50
50
  })
51
51
 
52
52
  const sort = computed(() => {
@@ -57,21 +57,10 @@ export function useArticleList<C extends keyof PageCollections = 'article'>(opti
57
57
  return config.value.query?.order
58
58
  })
59
59
 
60
- const status = computed(() => {
61
- const s = toValue(options.status)
62
- if (s === false)
63
- return false
64
-
65
- if (s)
66
- return s
67
-
68
- // Try to find status in config where
69
- const statusFilter = config.value.query?.where?.find(f => f.field === 'status')
70
- return statusFilter?.value || 'published'
71
- })
60
+ const publishedOnly = computed(() => toValue(options.publishedOnly) ?? true)
72
61
 
73
62
  // The key must be reactive and stable
74
- const queryKey = computed(() => `${String(collection.value)}-list-${page.value}-${itemsPerPage.value}-${category.value || 'all'}-${labelAll.value}-${JSON.stringify(where.value)}-${JSON.stringify(sort.value)}-${status.value}`)
63
+ const queryKey = computed(() => `${String(collection.value)}-list-${page.value}-${itemsPerPage.value}-${category.value || 'all'}-${labelAll.value}-${JSON.stringify(where.value)}-${JSON.stringify(sort.value)}-${publishedOnly.value}`)
75
64
 
76
65
  return useAsyncData(queryKey, async () => {
77
66
  // We cast the query to a version that includes the standard article fields
@@ -82,8 +71,8 @@ export function useArticleList<C extends keyof PageCollections = 'article'>(opti
82
71
  const getDataQuery = () => {
83
72
  let query = queryCollection(collection.value) as unknown as ArticleQueryBuilder
84
73
 
85
- if (status.value) {
86
- query = query.where('status', '=', status.value)
74
+ if (publishedOnly.value) {
75
+ query = query.where('published', '=', true)
87
76
  }
88
77
 
89
78
  if (category.value && category.value !== labelAll.value) {
package/nuxt.config.ts CHANGED
@@ -34,7 +34,7 @@ export default defineNuxtConfig({
34
34
  dates: {},
35
35
  authors: {},
36
36
  category: {},
37
- status: {},
37
+ published: {},
38
38
  header: {},
39
39
  toc: {},
40
40
  links: {},
@@ -52,11 +52,11 @@ export default defineNuxtConfig({
52
52
  // Collection variants — extends chains defined here for graph generation
53
53
  snippet: {},
54
54
  article: {
55
- extends: ['dates', 'authors', 'category', 'status', 'header', 'toc', 'surround', 'copyButton', 'separator', 'backButton', 'user'],
55
+ extends: ['dates', 'authors', 'category', 'published', 'header', 'toc', 'surround', 'copyButton', 'separator', 'backButton'],
56
56
  config: {},
57
57
  },
58
58
  event: {
59
- extends: ['dates', 'location', 'category', 'links', 'status', 'header', 'toc', 'surround', 'copyButton', 'separator', 'backButton', 'user'],
59
+ extends: ['dates', 'location', 'category', 'links', 'published', 'header', 'toc', 'surround', 'copyButton', 'separator', 'backButton'],
60
60
  config: {},
61
61
  },
62
62
  page: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@happydesigns/ui",
3
3
  "type": "module",
4
- "version": "0.15.1",
4
+ "version": "0.16.0",
5
5
  "private": false,
6
6
  "packageManager": "pnpm@11.11.0",
7
7
  "author": "happydesigns",
@@ -59,7 +59,7 @@
59
59
  "cross-env": "^10.1.0",
60
60
  "docus": "5.12.3",
61
61
  "eslint": "^10.6.0",
62
- "nuxt": "^4.4.8",
62
+ "nuxt": "^4.5.0",
63
63
  "typescript": "^6.0.3",
64
64
  "vitest": "^4.1.10",
65
65
  "vue-tsc": "^3.3.7",
package/schemas/traits.ts CHANGED
@@ -20,9 +20,9 @@ export const categoryTrait = {
20
20
  }),
21
21
  }
22
22
 
23
- export const statusTrait = {
23
+ export const publishedTrait = {
24
24
  schema: z.object({
25
- status: z.enum(['published', 'draft', 'archived']).default('published'),
25
+ published: z.boolean().default(true),
26
26
  }),
27
27
  }
28
28
 
@@ -67,7 +67,12 @@ export const userTrait = {
67
67
  name: z.string().optional(),
68
68
  description: z.string().optional(),
69
69
  to: z.string().optional(),
70
- avatar: property(z.object({})).inherit('@nuxt/ui/components/Avatar.vue').optional(),
70
+ avatar: z.object({
71
+ src: property(z.string()).editor({ input: 'media' }).optional(),
72
+ alt: z.string().optional(),
73
+ icon: property(z.string()).editor({ input: 'icon' }).optional(),
74
+ text: z.string().optional(),
75
+ }).optional(),
71
76
  socials: z.array(z.object({
72
77
  name: z.string(),
73
78
  url: z.url(),
@@ -80,7 +85,7 @@ export const variantSchemas = {
80
85
  dates: datesTrait.schema,
81
86
  authors: authorsTrait.schema,
82
87
  category: categoryTrait.schema,
83
- status: statusTrait.schema,
88
+ published: publishedTrait.schema,
84
89
  header: headerTrait.schema,
85
90
  toc: tocTrait.schema,
86
91
  links: linksTrait.schema,