@dargmuesli/nuxt-vio 6.0.0 → 7.0.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/components/vio/form/input/VioFormInput.vue +25 -11
- package/components/vio/form/input/VioFormInputEmailAddress.vue +65 -0
- package/locales/de.json +2 -0
- package/locales/en.json +2 -0
- package/package.json +1 -1
- package/tailwind.config.ts +3 -3
- package/utils/constants.ts +0 -1
- package/utils/form.ts +13 -12
@@ -16,7 +16,7 @@
|
|
16
16
|
'form-input-warning': warning,
|
17
17
|
'form-input-error': value?.$error,
|
18
18
|
}"
|
19
|
-
:for="
|
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="
|
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
|
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
|
-
|
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(
|
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
|
-
|
175
|
-
!['checkbox', 'select'].includes(
|
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>
|
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/package.json
CHANGED
package/tailwind.config.ts
CHANGED
@@ -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
|
},
|
package/utils/constants.ts
CHANGED
@@ -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
|
1
|
+
import { consola } from 'consola'
|
2
2
|
|
3
|
-
export const
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
12
|
-
isFormSent.value =
|
12
|
+
const isValid = await v$.value.$validate()
|
13
|
+
isFormSent.value = isValid
|
13
14
|
|
14
|
-
if (!
|
15
|
-
|
15
|
+
if (!isValid) {
|
16
|
+
consola.error('Form in invalid!')
|
16
17
|
}
|
17
18
|
|
18
|
-
return
|
19
|
+
return isValid
|
19
20
|
}
|