@codecavepro/brand 3.1.0 → 3.2.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.
|
@@ -54,25 +54,24 @@ const createFormField = <T,>(name: keyof ContactFormDefinition, value: T): FormF
|
|
|
54
54
|
const formData = ref({
|
|
55
55
|
email: createFormField('email', ''),
|
|
56
56
|
firstName: createFormField('firstName', ''),
|
|
57
|
-
lastName: createFormField('lastName', ''),
|
|
58
57
|
companyName: createFormField('companyName', ''),
|
|
59
58
|
linkedinCompanyPage: createFormField('linkedinCompanyPage', ''),
|
|
60
59
|
services: createFormField('services', ''),
|
|
61
60
|
description: createFormField('description', ''),
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
communicationConsent: {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
},
|
|
61
|
+
|
|
62
|
+
consentToProcess: {
|
|
63
|
+
value: false,
|
|
64
|
+
error: '',
|
|
65
|
+
label: props.definition.consentToProcess.label,
|
|
66
|
+
required: props.definition.consentToProcess.required,
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
communicationConsent: {
|
|
70
|
+
value: false,
|
|
71
|
+
error: '',
|
|
72
|
+
label: props.definition.communicationConsent.label,
|
|
73
|
+
required: props.definition.communicationConsent.required,
|
|
74
|
+
},
|
|
76
75
|
})
|
|
77
76
|
|
|
78
77
|
const services = computed(() => props.definition.services.options ?? [])
|
|
@@ -123,7 +122,6 @@ const validateRequiredFields = () => {
|
|
|
123
122
|
const resetForm = () => {
|
|
124
123
|
formData.value.email.value = '';
|
|
125
124
|
formData.value.firstName.value = '';
|
|
126
|
-
formData.value.lastName.value = '';
|
|
127
125
|
formData.value.companyName.value = '';
|
|
128
126
|
formData.value.linkedinCompanyPage.value = '';
|
|
129
127
|
formData.value.description.value = '';
|
|
@@ -136,7 +134,6 @@ const resetForm = () => {
|
|
|
136
134
|
const currentValues = (): ContactFormValues => ({
|
|
137
135
|
email: formData.value.email.value,
|
|
138
136
|
firstName: formData.value.firstName.value,
|
|
139
|
-
lastName: formData.value.lastName.value,
|
|
140
137
|
companyName: formData.value.companyName.value,
|
|
141
138
|
linkedinCompanyPage: formData.value.linkedinCompanyPage.value,
|
|
142
139
|
services: formData.value.services.value,
|
|
@@ -233,6 +230,22 @@ fields.forEach((key) => {
|
|
|
233
230
|
)
|
|
234
231
|
})
|
|
235
232
|
|
|
233
|
+
const companyNamePattern = /[^\p{L}\p{N} &]/u;
|
|
234
|
+
const firstNamePattern = /[^\p{L} ]/u;
|
|
235
|
+
|
|
236
|
+
const createSanitizer = (pattern) => {
|
|
237
|
+
return (value) => value.replace(pattern, '');
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
const sanitizeCompanyName = createSanitizer(companyNamePattern);
|
|
241
|
+
const sanitizeFirstName = createSanitizer(firstNamePattern);
|
|
242
|
+
|
|
243
|
+
const preventInvalidInput = (event, pattern) => {
|
|
244
|
+
if (event.data && pattern.test(event.data)) {
|
|
245
|
+
event.preventDefault();
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
|
|
236
249
|
</script>
|
|
237
250
|
|
|
238
251
|
<template>
|
|
@@ -241,11 +254,10 @@ fields.forEach((key) => {
|
|
|
241
254
|
<fieldset class="space-y-2">
|
|
242
255
|
<InputText id="email" v-model="formData.email.value" :isRequired=formData.email.required :label=formData.email.label type="email" :isError="!!formData.email.error" :errorMessage="formData.email.error" :placeholder="formData.email.placeholder ?? ''" autocomplete="email" />
|
|
243
256
|
<div class="flex flex-col xl:flex-row gap-2">
|
|
244
|
-
<InputText id="firstname" v-model="formData.firstName.value" :isRequired=formData.firstName.required :label=formData.firstName.label type="text" :isError="!!formData.firstName.error" :errorMessage="formData.firstName.error" :placeholder="formData.firstName.placeholder ?? ''" autocomplete="given-name" />
|
|
245
|
-
<InputText id="
|
|
257
|
+
<InputText id="firstname" v-model="formData.firstName.value" @beforeinput="event => preventInvalidInput(event, firstNamePattern)" @update:model-value="value => { formData.firstName.value = sanitizeFirstName(value) }" :isRequired="formData.firstName.required" :label="formData.firstName.label" type="text" :isError="!!formData.firstName.error" :errorMessage="formData.firstName.error" :placeholder="formData.firstName.placeholder ?? ''" autocomplete="given-name" />
|
|
258
|
+
<InputText id="companyName" v-model="formData.companyName.value" @beforeinput="event => preventInvalidInput(event, companyNamePattern)" @update:model-value="value => { formData.companyName.value = sanitizeCompanyName(value) }" :isRequired="formData.companyName.required" :label="formData.companyName.label" type="text" :isError="!!formData.companyName.error" :errorMessage="formData.companyName.error" :placeholder="formData.companyName.placeholder ?? ''" />
|
|
246
259
|
</div>
|
|
247
260
|
<div class="flex flex-col xl:flex-row gap-2">
|
|
248
|
-
<InputText id="companyName" v-model="formData.companyName.value" :isRequired=formData.companyName.required :label=formData.companyName.label type="text" :isError="!!formData.companyName.error" :errorMessage="formData.companyName.error" :placeholder="formData.companyName.placeholder ?? ''" />
|
|
249
261
|
<InputText id="linkedinCompanyPage" v-model="formData.linkedinCompanyPage.value" :isRequired=formData.linkedinCompanyPage.required :label=formData.linkedinCompanyPage.label type="text" :isError="!!formData.linkedinCompanyPage.error" :errorMessage="formData.linkedinCompanyPage.error" :placeholder="formData.linkedinCompanyPage.placeholder ?? ''" />
|
|
250
262
|
</div>
|
|
251
263
|
</fieldset>
|
|
@@ -260,22 +272,22 @@ fields.forEach((key) => {
|
|
|
260
272
|
</fieldset>
|
|
261
273
|
<div class="space-y-2">
|
|
262
274
|
<Checkbox id="privacy" v-model="formData.consentToProcess.value" :label="formData.consentToProcess.label" :isRequired="formData.consentToProcess.required" :isError="!!formData.consentToProcess.error" />
|
|
263
|
-
<Checkbox id="promotions" v-model="formData.communicationConsent.value" :label="formData.communicationConsent.label" :isRequired="formData.communicationConsent.required" :isError="!!formData.communicationConsent.error"
|
|
275
|
+
<Checkbox id="promotions" v-model="formData.communicationConsent.value" :label="formData.communicationConsent.label" :isRequired="formData.communicationConsent.required" :isError="!!formData.communicationConsent.error" />
|
|
264
276
|
</div>
|
|
265
277
|
</div>
|
|
266
278
|
<GlowButton @click="submitContactsForm" title="Leave consultation request" class="self-center lg:self-start" />
|
|
267
279
|
</form>
|
|
268
280
|
<div v-show="isAlertVisible" class="border border-action group absolute bottom-19.25 md:fixed z-350 left-1/2 -translate-x-1/2 md:top-40 form-alert flex gap-2 md:gap-8 items-center justify-between w-full h-fit max-w-139 bg-surface-secondary p-4 md:px-6 md:py-2.5 rounded-3xl">
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
</div>
|
|
272
|
-
<p class="text-sm md:text-lg font-bold text-heading md:max-w-sm ">
|
|
273
|
-
{{ alertKind ? ALERT_TEXT[alertKind] : '' }}
|
|
274
|
-
</p>
|
|
275
|
-
<button @click="alertKind = null" class="group-hover:text-action text-heading transition-colors cursor-pointer">
|
|
276
|
-
<component :is="CloseIcon" />
|
|
277
|
-
</button>
|
|
281
|
+
<div v-if="alertKind === 'success'" class="w-8 h-8">
|
|
282
|
+
<component :is="SuccessIcon" class="w-8 h-8" />
|
|
278
283
|
</div>
|
|
284
|
+
<p class="text-sm md:text-lg font-bold text-heading md:max-w-sm ">
|
|
285
|
+
{{ alertKind ? ALERT_TEXT[alertKind] : '' }}
|
|
286
|
+
</p>
|
|
287
|
+
<button @click="alertKind = null" class="group-hover:text-action text-heading transition-colors cursor-pointer">
|
|
288
|
+
<component :is="CloseIcon" />
|
|
289
|
+
</button>
|
|
290
|
+
</div>
|
|
279
291
|
</template>
|
|
280
292
|
|
|
281
293
|
<style scoped>
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/
|
|
2
|
-
const linkedInRegex = /^https?:\/\/([a-z]{2,3}\.)?linkedin\.com\/.*$/
|
|
2
|
+
const linkedInRegex = /^https?:\/\/([a-z]{2,3}\.)?linkedin\.com\/.*$/im
|
|
3
3
|
|
|
4
4
|
export const isCorrectEmailFormat = (email: string | null): boolean => {
|
|
5
5
|
return !!email && emailRegex.test(email)
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
|
|
8
|
+
export const isCorrectLinkedInFormat = (linkedIn: string | null): boolean => {
|
|
9
|
+
return !!linkedIn && linkedInRegex.test(linkedIn)
|
|
9
10
|
}
|
|
@@ -26,7 +26,6 @@ export interface CrmFormFieldSpec {
|
|
|
26
26
|
export type ContactFormFieldName =
|
|
27
27
|
| 'email'
|
|
28
28
|
| 'firstName'
|
|
29
|
-
| 'lastName'
|
|
30
29
|
| 'companyName'
|
|
31
30
|
| 'linkedinCompanyPage'
|
|
32
31
|
| 'services'
|
|
@@ -41,7 +40,6 @@ export type ContactFormDefinition = Record<ContactFormFieldName, CrmFormFieldSpe
|
|
|
41
40
|
export interface ContactFormValues {
|
|
42
41
|
email: string;
|
|
43
42
|
firstName: string;
|
|
44
|
-
lastName: string;
|
|
45
43
|
companyName: string;
|
|
46
44
|
linkedinCompanyPage: string;
|
|
47
45
|
services: string;
|
package/package.json
CHANGED