@dargmuesli/nuxt-vio 6.0.0 → 8.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,7 +16,7 @@
16
16
  'form-input-warning': warning,
17
17
  'form-input-error': value?.$error,
18
18
  }"
19
- :for="idLabel"
19
+ :for="idLabelFull"
20
20
  >
21
21
  <span>{{ title }}</span>
22
22
  <span
@@ -36,7 +36,7 @@
36
36
  <slot v-if="$slots.default" />
37
37
  <input
38
38
  v-else
39
- :id="idLabel"
39
+ :id="idLabelFull"
40
40
  class="form-input"
41
41
  :class="{
42
42
  'rounded-r-none': $slots.icon,
@@ -58,14 +58,14 @@
58
58
  </VioFormInputIconWrapper>
59
59
  <VioFormInputIconWrapper
60
60
  v-else-if="
61
- validationProperty.$model && !validationProperty.$invalid
61
+ !!validationProperty.$model && !validationProperty.$invalid
62
62
  "
63
63
  >
64
64
  <VioIconCheckCircle class="text-green-600" :title="t('valid')" />
65
65
  </VioFormInputIconWrapper>
66
66
  <VioFormInputIconWrapper
67
67
  v-else-if="
68
- validationProperty.$model && validationProperty.$invalid
68
+ !!validationProperty.$model && validationProperty.$invalid
69
69
  "
70
70
  >
71
71
  <VioIconExclamationCircle
@@ -84,6 +84,10 @@
84
84
  </span>
85
85
  </div>
86
86
  <div class="md:w-1/3" />
87
+ <div class="md:w-2/3">
88
+ <slot name="inputSuffix" />
89
+ </div>
90
+ <div class="md:w-1/3" />
87
91
  <div class="md:w-2/3">
88
92
  <slot name="stateSuccess" />
89
93
  </div>
@@ -102,6 +106,10 @@
102
106
  <div class="md:w-2/3">
103
107
  <slot name="stateError" />
104
108
  </div>
109
+ <div class="md:w-1/3" />
110
+ <div class="md:w-2/3">
111
+ <slot name="assistance" />
112
+ </div>
105
113
  </div>
106
114
  </div>
107
115
  </template>
@@ -119,7 +127,7 @@ export interface Props {
119
127
  idLabel?: string
120
128
  placeholder?: string
121
129
  success?: boolean
122
- title?: string
130
+ title: string
123
131
  type?: string
124
132
  validationProperty?: BaseValidation
125
133
  value?: BaseValidation
@@ -135,14 +143,12 @@ const props = withDefaults(defineProps<Props>(), {
135
143
  idLabel: undefined,
136
144
  placeholder: undefined,
137
145
  success: false,
138
- title: undefined,
139
146
  type: undefined,
140
147
  validationProperty: undefined,
141
148
  value: undefined,
142
149
  valueFormatter: (x?: string) => x,
143
150
  warning: false,
144
151
  })
145
- const typeProp = toRef(() => props.type)
146
152
 
147
153
  const emit = defineEmits<{
148
154
  icon: []
@@ -151,11 +157,19 @@ const emit = defineEmits<{
151
157
  }>()
152
158
 
153
159
  const { t } = useI18n()
160
+ const runtimeConfig = useRuntimeConfig()
161
+
162
+ // data
163
+ const idLabelFull = props.idLabel
164
+ ? `maevsi-${runtimeConfig.public.vio.isInProduction ? 'prod' : 'dev'}-${
165
+ props.idLabel
166
+ }`
167
+ : undefined
154
168
 
155
169
  // initialization
156
170
  if (
157
171
  !props.placeholder &&
158
- typeProp.value &&
172
+ props.type &&
159
173
  ![
160
174
  'checkbox',
161
175
  'datetime-local',
@@ -164,15 +178,15 @@ if (
164
178
  'textarea',
165
179
  'tiptap',
166
180
  'radio',
167
- ].includes(typeProp.value)
181
+ ].includes(props.type)
168
182
  ) {
169
183
  consola.warn(`placeholder is missing for ${props.idLabel}!`)
170
184
  }
171
185
 
172
186
  if (
173
187
  !props.value &&
174
- typeProp.value &&
175
- !['checkbox', 'select'].includes(typeProp.value)
188
+ props.type &&
189
+ !['checkbox', 'select'].includes(props.type)
176
190
  ) {
177
191
  consola.warn(`value is missing for ${props.idLabel}!`)
178
192
  }
@@ -0,0 +1,65 @@
1
+ <template>
2
+ <VioFormInput
3
+ v-if="formInput"
4
+ :is-optional="isOptional"
5
+ :id-label="`input-${id}`"
6
+ :placeholder="t('globalPlaceholderEmailAddress')"
7
+ :title="title || t('emailAddress')"
8
+ type="email"
9
+ :value="formInput"
10
+ @input="emit('input', $event)"
11
+ >
12
+ <template #stateError>
13
+ <VioFormInputStateError
14
+ :form-input="formInput"
15
+ validation-property="email"
16
+ >
17
+ {{ t('globalValidationFormat') }}
18
+ </VioFormInputStateError>
19
+ <VioFormInputStateError
20
+ :form-input="formInput"
21
+ validation-property="lengthMax"
22
+ >
23
+ {{ t('globalValidationLength') }}
24
+ </VioFormInputStateError>
25
+ <VioFormInputStateError
26
+ v-if="isRequired"
27
+ :form-input="formInput"
28
+ validation-property="required"
29
+ >
30
+ {{ t('globalValidationRequired') }}
31
+ </VioFormInputStateError>
32
+ </template>
33
+ </VioFormInput>
34
+ </template>
35
+
36
+ <script setup lang="ts">
37
+ import type { BaseValidation } from '@vuelidate/core'
38
+
39
+ export interface Props {
40
+ formInput: BaseValidation
41
+ id?: string
42
+ isOptional?: boolean
43
+ isRequired?: boolean
44
+ title?: string
45
+ }
46
+ withDefaults(defineProps<Props>(), {
47
+ id: 'email-address',
48
+ isOptional: false,
49
+ isRequired: false,
50
+ title: undefined,
51
+ })
52
+
53
+ const emit = defineEmits<{
54
+ input: [event: string]
55
+ }>()
56
+
57
+ const { t } = useI18n()
58
+ </script>
59
+
60
+ <i18n lang="yaml">
61
+ de:
62
+ emailAddress: E-Mail-Adresse
63
+ en:
64
+ emailAddress: Email address
65
+ </i18n>
@@ -0,0 +1,9 @@
1
+ <template>
2
+ <VioIconContainer>
3
+ <ArrowLeftIcon />
4
+ </VioIconContainer>
5
+ </template>
6
+
7
+ <script setup lang="ts">
8
+ import { ArrowLeftIcon } from '@heroicons/vue/24/outline'
9
+ </script>
@@ -7,9 +7,10 @@
7
7
  <script setup lang="ts">
8
8
  export interface Props {
9
9
  classes?: string
10
- title: string
10
+ title?: string
11
11
  }
12
12
  withDefaults(defineProps<Props>(), {
13
13
  classes: 'h-5 md:h-6 w-5 md:w-6 shrink-0',
14
+ title: undefined,
14
15
  })
15
16
  </script>
@@ -1,8 +1,14 @@
1
1
  <template>
2
2
  <div class="container mx-auto p-4 md:px-8">
3
+ <header v-if="$slots.header">
4
+ <slot name="header" />
5
+ </header>
3
6
  <main>
4
7
  <slot />
5
8
  </main>
9
+ <footer v-if="$slots.footer">
10
+ <slot name="footer" />
11
+ </footer>
6
12
  <CookieControl :locale="locale" />
7
13
  </div>
8
14
  </template>
package/locales/de.json CHANGED
@@ -1,9 +1,11 @@
1
1
  {
2
+ "globalPlaceholderEmailAddress": "e-mail{'@'}adres.se",
2
3
  "globalPlaceholderUrl": "https://websei.te",
3
4
  "globalSeoSiteDescription": "Vio ist {'@'}dargmueslis Nuxt layer.",
4
5
  "globalStatusError": "Fehler",
5
6
  "globalStatusLoading": "Lade...",
6
7
  "globalValidationFailed": "Bitte überprüfe deine Eingaben 🙈",
8
+ "globalValidationFormat": "Falsches Format",
7
9
  "globalValidationFormatIncorrect": "Falsches Format",
8
10
  "globalValidationFormatUrlHttps": "Muss mit \"https://\" beginnen",
9
11
  "globalValidationLength": "Zu lang",
package/locales/en.json CHANGED
@@ -1,9 +1,11 @@
1
1
  {
2
+ "globalPlaceholderEmailAddress": "email{'@'}addre.ss",
2
3
  "globalPlaceholderUrl": "https://websi.te",
3
4
  "globalSeoSiteDescription": "Vio is {'@'}dargmuesli's Nuxt layer.",
4
5
  "globalStatusError": "Error",
5
6
  "globalStatusLoading": "Loading...",
6
7
  "globalValidationFailed": "Please check your input 🙈",
8
+ "globalValidationFormat": "Incorrect format",
7
9
  "globalValidationFormatIncorrect": "Incorrect format",
8
10
  "globalValidationFormatUrlHttps": "Must start with \"https://\"",
9
11
  "globalValidationLength": "Too long",
package/nuxt.config.ts CHANGED
@@ -126,7 +126,7 @@ export default defineNuxtConfig(
126
126
  locales: ['en', 'de'],
127
127
  },
128
128
  htmlValidator: {
129
- failOnError: false, // TODO: fix invalid html in nuxt html template (https://github.com/nuxt/nuxt/issues/22526)
129
+ failOnError: true,
130
130
  logLevel: 'warning',
131
131
  },
132
132
  i18n: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dargmuesli/nuxt-vio",
3
- "version": "6.0.0",
3
+ "version": "8.0.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/dargmuesli/vio.git"
@@ -67,9 +67,10 @@
67
67
  "dependencies": {
68
68
  "@axe-core/playwright": "4.7.3",
69
69
  "@dargmuesli/nuxt-cookie-control": "6.4.2",
70
+ "@heroicons/vue": "2.0.18",
70
71
  "@http-util/status-i18n": "0.8.1",
71
72
  "@intlify/eslint-plugin-vue-i18n": "3.0.0-next.3",
72
- "@nuxt/image": "1.0.0-rc.1",
73
+ "@nuxt/image": "1.0.0-rc.2",
73
74
  "@nuxtjs/color-mode": "3.3.0",
74
75
  "@nuxtjs/eslint-config-typescript": "12.1.0",
75
76
  "@nuxtjs/html-validator": "1.5.2",
@@ -136,17 +136,17 @@ export default {
136
136
  },
137
137
  },
138
138
  '.form-input-error': {
139
- input: {
139
+ '.form-input': {
140
140
  borderColor: theme('colors.red.500'),
141
141
  },
142
142
  },
143
143
  '.form-input-success': {
144
- input: {
144
+ '.form-input': {
145
145
  borderColor: theme('colors.green.600'),
146
146
  },
147
147
  },
148
148
  '.form-input-warning': {
149
- input: {
149
+ '.form-input': {
150
150
  borderColor: theme('colors.yellow.600'),
151
151
  },
152
152
  },
@@ -49,7 +49,6 @@ export const TITLE_TEMPLATE = ({
49
49
  siteName: string
50
50
  title?: string
51
51
  }) => (title && title !== siteName ? `${title} · ${siteName}` : siteName)
52
- export const VALIDATION_SUGGESTION_TITLE_LENGTH_MAXIMUM = 300
53
52
  export const VERIFICATION_FORMAT_UUID = helpers.regex(REGEX_UUID)
54
53
  export const VIO_NUXT_BASE_CONFIG = ({
55
54
  defaultLocale,
package/utils/form.ts CHANGED
@@ -1,19 +1,20 @@
1
- import type { ApiData } from '../types/api'
1
+ import { consola } from 'consola'
2
2
 
3
- export const formPreSubmit = async (
4
- api: ApiData,
5
- v$: any,
6
- isFormSent: Ref<boolean>,
7
- ): Promise<boolean> => {
8
- api.value.errors = []
3
+ export const isFormValid = async ({
4
+ v$,
5
+ isFormSent,
6
+ }: {
7
+ v$: any
8
+ isFormSent: Ref<boolean>
9
+ }): Promise<boolean> => {
9
10
  v$.value.$touch()
10
11
 
11
- const isFormValid = await v$.value.$validate()
12
- isFormSent.value = isFormValid
12
+ const isValid = await v$.value.$validate()
13
+ isFormSent.value = isValid
13
14
 
14
- if (!isFormValid) {
15
- throw new Error('Form is invalid!')
15
+ if (!isValid) {
16
+ consola.error('Form in invalid!')
16
17
  }
17
18
 
18
- return isFormValid
19
+ return isValid
19
20
  }