@falcondev-oss/nuxt-layers-base 0.31.1 → 0.31.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.
@@ -145,7 +145,7 @@ const columns = useTableColumns<typeof data>(
145
145
  ]"
146
146
  :user-menu="{
147
147
  name: 'Benjamin Canac',
148
- avatar: { src: 'https://github.com/benjamincanac.png' },
148
+ // avatar: { src: 'https://github.com/benjamincanac.png' },
149
149
  items: [
150
150
  {
151
151
  icon: 'lucide:log-out',
@@ -259,7 +259,7 @@ const columns = useTableColumns<typeof data>(
259
259
  class="flex flex-col gap-4"
260
260
  >
261
261
  {{ form.data }}
262
- <UField v-slot="{ bind, field }" :field="form.fields.text.$use()">
262
+ <UField v-slot="{ bind, field }" :field="form.fields.text.$use()" error-inline>
263
263
  {{ field.schema }}
264
264
  <UInput class="w-full" v-bind="bind" />
265
265
  </UField>
@@ -43,8 +43,8 @@ const config = useRuntimeConfig()
43
43
  collapsible
44
44
  :ui="{
45
45
  ...sidebar?.ui,
46
- header: [sidebar?.ui?.header ?? '', 'border-b border-default'].join(' ').trim(),
47
- footer: [sidebar?.ui?.footer ?? '', 'border-t border-default'].join(' ').trim(),
46
+ header: [sidebar?.ui?.header, 'border-b border-default'],
47
+ footer: [sidebar?.ui?.footer, 'border-t border-default'],
48
48
  }"
49
49
  >
50
50
  <template
@@ -1,6 +1,7 @@
1
1
  <script setup lang="ts" generic="T">
2
2
  import type { FormField } from '@falcondev-oss/form-core'
3
3
  import type { FormFieldProps, FormFieldSlots } from '@nuxt/ui'
4
+ import { createReusableTemplate } from '@vueuse/core'
4
5
  import { useForwardProps } from 'reka-ui'
5
6
  import * as R from 'remeda'
6
7
 
@@ -17,6 +18,7 @@ type InputProps<T> = {
17
18
  const props = defineProps<
18
19
  FormFieldProps & {
19
20
  field: FormField<T>
21
+ errorInline?: boolean
20
22
  }
21
23
  >()
22
24
 
@@ -83,6 +85,12 @@ const model = computed({
83
85
  })
84
86
 
85
87
  const model_ = { model }
88
+
89
+ const [DefineErrorTemplate, ErrorTemplate] = createReusableTemplate({
90
+ props: {
91
+ errors: Array as PropType<string[]>,
92
+ },
93
+ })
86
94
  </script>
87
95
 
88
96
  <template>
@@ -90,11 +98,33 @@ const model_ = { model }
90
98
  v-bind="formFieldProps"
91
99
  :ui="{
92
100
  ...formFieldProps.ui,
93
- hint: [formFieldProps.ui?.hint ?? '', isOverMaxLength ? 'text-error' : ''].join(' ').trim(),
101
+ hint: [formFieldProps.ui?.hint, isOverMaxLength ? 'text-error' : ''],
102
+ error: [formFieldProps.ui?.error, 'mt-1!'],
94
103
  }"
95
104
  :error="!!field.errors"
105
+ :class="props.class"
96
106
  >
97
- <template #hint="{ hint }">
107
+ <DefineErrorTemplate v-slot="{ errors }">
108
+ <p v-if="errors.length === 1">
109
+ {{ errors.join('\n') }}
110
+ </p>
111
+
112
+ <ul v-else>
113
+ <li v-for="(error, index) in errors" :key="error + index" class="list-inside">
114
+ {{ error }}
115
+ </li>
116
+ </ul>
117
+ </DefineErrorTemplate>
118
+
119
+ <template v-if="field.errors && errorInline" #error>
120
+ <ErrorTemplate :errors="field.errors" />
121
+
122
+ <template v-if="typeof error === 'string'">
123
+ {{ error }}
124
+ </template>
125
+ </template>
126
+
127
+ <template v-else #hint="{ hint }">
98
128
  <span class="flex items-center gap-1.5">
99
129
  <UPopover
100
130
  v-if="!!field.errors"
@@ -107,15 +137,7 @@ const model_ = { model }
107
137
  <UIcon name="lucide:circle-alert" class="text-error" />
108
138
  <template #content>
109
139
  <div class="text-(--ui-color-neutral-800) max-w-sm text-xs">
110
- <p v-if="field.errors.length === 1">
111
- {{ field.errors.join('\n') }}
112
- </p>
113
-
114
- <ul v-else>
115
- <li v-for="(error, index) in field.errors" :key="error + index" class="list-inside">
116
- {{ error }}
117
- </li>
118
- </ul>
140
+ <ErrorTemplate :errors="field.errors" />
119
141
  </div>
120
142
  </template>
121
143
  </UPopover>
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.31.1",
4
+ "version": "0.31.3",
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",