@axos-web-dev/shared-components 1.0.99-leadpriority → 1.0.99-leadpriority.1
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.
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
|
4
|
+
import { Button } from "../Button/Button.js";
|
|
5
|
+
import "../Button/Button.css.js";
|
|
6
|
+
import "react";
|
|
7
|
+
import "react-use";
|
|
8
|
+
import "../Input/Checkbox.js";
|
|
9
|
+
import "../Input/CurrencyInput.js";
|
|
10
|
+
import "../Input/Dropdown.js";
|
|
11
|
+
import "../Input/Dropdown.css.js";
|
|
12
|
+
import { Input } from "../Input/Input.js";
|
|
13
|
+
import "../Input/Input.css.js";
|
|
14
|
+
import "../Input/InputAmount.js";
|
|
15
|
+
import { InputPhone } from "../Input/InputPhone.js";
|
|
16
|
+
import "../Input/InputTextArea.js";
|
|
17
|
+
import "../Input/DownPaymentInput.js";
|
|
18
|
+
import "../Input/RadioButton.js";
|
|
19
|
+
import "../icons/ArrowIcon/ArrowIcon.css.js";
|
|
20
|
+
import SvgAxosX from "../icons/AxosX/index.js";
|
|
21
|
+
import SvgComponent from "../icons/AxosX/Blue.js";
|
|
22
|
+
import "../icons/CheckIcon/CheckIcon.css.js";
|
|
23
|
+
import '../assets/icons/FollowIcon/FollowIcon.css';import '../assets/icons/DownloadIcon/DownloadIcon.css';import '../assets/themes/victorie.css';import '../assets/themes/premier.css';import '../assets/themes/axos.css';/* empty css */
|
|
24
|
+
/* empty css */
|
|
25
|
+
/* empty css */
|
|
26
|
+
/* empty css */
|
|
27
|
+
/* empty css */
|
|
28
|
+
import "../utils/allowedAxosDomains.js";
|
|
29
|
+
import { associatedEmail } from "../utils/EverestValidity.js";
|
|
30
|
+
import { getVariant } from "../utils/getVariant.js";
|
|
31
|
+
import clsx from "clsx";
|
|
32
|
+
import { useForm, FormProvider } from "react-hook-form";
|
|
33
|
+
import * as z from "zod";
|
|
34
|
+
import { iconForm, headerContainer, headerForm, form, descriptionField, formWrapper, disclosureForm, actions, formContainer } from "./Forms.css.js";
|
|
35
|
+
import { honeyPotSchema, isValidHoneyPot, HoneyPot } from "./HoneyPot/index.js";
|
|
36
|
+
import { SalesforceSchema } from "./SalesforceFieldsForm.js";
|
|
37
|
+
const ContactUsNewTest = ({
|
|
38
|
+
icon = false,
|
|
39
|
+
children,
|
|
40
|
+
onSubmit = (values) => {
|
|
41
|
+
console.log(values);
|
|
42
|
+
},
|
|
43
|
+
disclosure,
|
|
44
|
+
variant: fullVariant = "primary",
|
|
45
|
+
headline,
|
|
46
|
+
description,
|
|
47
|
+
callToAction,
|
|
48
|
+
validateEmail,
|
|
49
|
+
onValidate,
|
|
50
|
+
id
|
|
51
|
+
}) => {
|
|
52
|
+
const schema = z.object({
|
|
53
|
+
first_name: z.string().regex(/^[A-Za-z][^0-9_!¡?÷?¿/\\+=@#$%ˆ&*,.^(){}|~<>;:[\]]{1,}$/g).trim().min(1, { message: "First Name is required." }),
|
|
54
|
+
last_name: z.string().regex(/^[A-Za-z][^0-9_!¡?÷?¿/\\+=@#$%ˆ&*,.^(){}|~<>;:[\]]{1,}$/g).trim().min(1, { message: "Last Name is required." }),
|
|
55
|
+
email: z.string().email({ message: "Email is required." }).refine(async (val) => await validateEmail(val)),
|
|
56
|
+
phone: z.string({ message: "Phone is required." }).regex(/[\d-]{10}/, "Invalid phone number.").min(10, { message: "Phone is required." }).max(12, { message: "Phone is required." }).transform((val, ctx) => {
|
|
57
|
+
const removeDashes = val.replace(/-/gi, "");
|
|
58
|
+
if (removeDashes.length !== 10) {
|
|
59
|
+
ctx.addIssue({
|
|
60
|
+
code: z.ZodIssueCode.custom,
|
|
61
|
+
message: "Phone must have at least 10 and no more than 10 characters."
|
|
62
|
+
});
|
|
63
|
+
return z.NEVER;
|
|
64
|
+
}
|
|
65
|
+
if (removeDashes.endsWith("00000") || removeDashes.startsWith("999") || removeDashes.length === 10 && /^[01]/.test(removeDashes)) {
|
|
66
|
+
ctx.addIssue({
|
|
67
|
+
code: z.ZodIssueCode.custom,
|
|
68
|
+
message: "Invalid phone number."
|
|
69
|
+
});
|
|
70
|
+
return z.NEVER;
|
|
71
|
+
}
|
|
72
|
+
return removeDashes;
|
|
73
|
+
})
|
|
74
|
+
});
|
|
75
|
+
const gen_schema = schema.merge(SalesforceSchema).merge(honeyPotSchema).superRefine((data, ctx) => {
|
|
76
|
+
if (!isValidHoneyPot(data)) {
|
|
77
|
+
ctx.addIssue({
|
|
78
|
+
code: z.ZodIssueCode.custom,
|
|
79
|
+
message: "fields are not valid."
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
const methods = useForm({
|
|
84
|
+
resolver: zodResolver(gen_schema, {
|
|
85
|
+
async: true
|
|
86
|
+
}),
|
|
87
|
+
mode: "all",
|
|
88
|
+
defaultValues: {
|
|
89
|
+
email: ""
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
const {
|
|
93
|
+
handleSubmit,
|
|
94
|
+
register,
|
|
95
|
+
formState: { errors, isValid, isSubmitting }
|
|
96
|
+
} = methods;
|
|
97
|
+
const submitForm = async (data) => {
|
|
98
|
+
await onSubmit(data);
|
|
99
|
+
};
|
|
100
|
+
const variant = getVariant(fullVariant);
|
|
101
|
+
return /* @__PURE__ */ jsx("section", { id, className: clsx(formContainer({ variant })), children: /* @__PURE__ */ jsx("div", { className: clsx("containment"), children: /* @__PURE__ */ jsxs(FormProvider, { ...methods, children: [
|
|
102
|
+
icon && /* @__PURE__ */ jsx("div", { className: clsx("text_center", iconForm), children: ["primary", "secondary"].includes(variant) ? /* @__PURE__ */ jsx(SvgComponent, {}) : /* @__PURE__ */ jsx(SvgAxosX, {}) }),
|
|
103
|
+
/* @__PURE__ */ jsxs("div", { className: `${headerContainer} text_center`, children: [
|
|
104
|
+
/* @__PURE__ */ jsx("h2", { className: clsx("header_2", headerForm({ variant })), children: headline }),
|
|
105
|
+
description && /* @__PURE__ */ jsx(
|
|
106
|
+
"div",
|
|
107
|
+
{
|
|
108
|
+
className: `${form} ${descriptionField({ variant })} text_center`,
|
|
109
|
+
children: description
|
|
110
|
+
}
|
|
111
|
+
)
|
|
112
|
+
] }),
|
|
113
|
+
/* @__PURE__ */ jsxs(
|
|
114
|
+
"form",
|
|
115
|
+
{
|
|
116
|
+
className: form,
|
|
117
|
+
onSubmit: async (e) => {
|
|
118
|
+
onValidate && onValidate(e);
|
|
119
|
+
await handleSubmit(submitForm)(e);
|
|
120
|
+
e.preventDefault();
|
|
121
|
+
},
|
|
122
|
+
children: [
|
|
123
|
+
/* @__PURE__ */ jsxs("div", { className: clsx(formWrapper({ variant })), children: [
|
|
124
|
+
/* @__PURE__ */ jsx("div", { className: "", children: /* @__PURE__ */ jsx(
|
|
125
|
+
Input,
|
|
126
|
+
{
|
|
127
|
+
id: "first_name",
|
|
128
|
+
...register("first_name", { required: true }),
|
|
129
|
+
label: "First Name",
|
|
130
|
+
sizes: "medium",
|
|
131
|
+
placeholder: "First Name",
|
|
132
|
+
required: true,
|
|
133
|
+
error: !!errors.first_name,
|
|
134
|
+
helperText: errors.first_name?.message,
|
|
135
|
+
variant
|
|
136
|
+
}
|
|
137
|
+
) }),
|
|
138
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
139
|
+
Input,
|
|
140
|
+
{
|
|
141
|
+
id: "last_name",
|
|
142
|
+
...register("last_name", { required: true }),
|
|
143
|
+
label: "Last Name",
|
|
144
|
+
sizes: "medium",
|
|
145
|
+
placeholder: "Last Name",
|
|
146
|
+
required: true,
|
|
147
|
+
error: !!errors.last_name,
|
|
148
|
+
helperText: errors.last_name?.message,
|
|
149
|
+
variant
|
|
150
|
+
}
|
|
151
|
+
) }),
|
|
152
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
153
|
+
Input,
|
|
154
|
+
{
|
|
155
|
+
id: "email",
|
|
156
|
+
...register("email", {
|
|
157
|
+
required: true,
|
|
158
|
+
validate: {
|
|
159
|
+
isValid: associatedEmail
|
|
160
|
+
}
|
|
161
|
+
}),
|
|
162
|
+
label: "Email",
|
|
163
|
+
sizes: "medium",
|
|
164
|
+
placeholder: "Email",
|
|
165
|
+
required: true,
|
|
166
|
+
error: !!errors.email,
|
|
167
|
+
helperText: errors.email?.message,
|
|
168
|
+
variant
|
|
169
|
+
}
|
|
170
|
+
) }),
|
|
171
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
172
|
+
InputPhone,
|
|
173
|
+
{
|
|
174
|
+
id: "phone",
|
|
175
|
+
...register("phone", { required: true, maxLength: 12 }),
|
|
176
|
+
label: "Phone",
|
|
177
|
+
sizes: "medium",
|
|
178
|
+
placeholder: "Phone",
|
|
179
|
+
required: true,
|
|
180
|
+
error: !!errors.phone,
|
|
181
|
+
helperText: errors.phone?.message,
|
|
182
|
+
variant
|
|
183
|
+
}
|
|
184
|
+
) }),
|
|
185
|
+
/* @__PURE__ */ jsx(HoneyPot, { register, variant })
|
|
186
|
+
] }),
|
|
187
|
+
children,
|
|
188
|
+
/* @__PURE__ */ jsx("div", { className: disclosureForm({ variant }), children: disclosure }),
|
|
189
|
+
/* @__PURE__ */ jsx("div", { className: actions, children: /* @__PURE__ */ jsx(
|
|
190
|
+
Button,
|
|
191
|
+
{
|
|
192
|
+
color: getVariant(callToAction?.variant),
|
|
193
|
+
as: "button",
|
|
194
|
+
type: "submit",
|
|
195
|
+
disabled: !isValid || isSubmitting,
|
|
196
|
+
children: callToAction?.displayText
|
|
197
|
+
}
|
|
198
|
+
) })
|
|
199
|
+
]
|
|
200
|
+
}
|
|
201
|
+
)
|
|
202
|
+
] }) }) }, id);
|
|
203
|
+
};
|
|
204
|
+
export {
|
|
205
|
+
ContactUsNewTest
|
|
206
|
+
};
|
package/dist/Forms/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export * from './ContactUsAAS';
|
|
|
12
12
|
export * from './ContactUsBusiness';
|
|
13
13
|
export * from './ContactUsBusinessNameEmail';
|
|
14
14
|
export * from './ContactUsLVF';
|
|
15
|
+
export * from './ContactUsNewTest';
|
|
15
16
|
export * from './ContactUsNMLSId';
|
|
16
17
|
export * from './CpraRequest';
|
|
17
18
|
export * from './CraPublicFile';
|
package/dist/Forms/index.js
CHANGED
|
@@ -13,6 +13,7 @@ import { ContactUsAAS } from "./ContactUsAAS.js";
|
|
|
13
13
|
import { ContactUsBusiness } from "./ContactUsBusiness.js";
|
|
14
14
|
import { ContactUsBusinessNameAndEmail } from "./ContactUsBusinessNameEmail.js";
|
|
15
15
|
import { ContactUsLVF } from "./ContactUsLVF.js";
|
|
16
|
+
import { ContactUsNewTest } from "./ContactUsNewTest.js";
|
|
16
17
|
import { ContactUsNMLSId } from "./ContactUsNMLSId.js";
|
|
17
18
|
import { CpraRequest } from "./CpraRequest.js";
|
|
18
19
|
import { CraPublicFile } from "./CraPublicFile.js";
|
|
@@ -54,6 +55,7 @@ export {
|
|
|
54
55
|
ContactUsBusinessNameAndEmail,
|
|
55
56
|
ContactUsLVF,
|
|
56
57
|
ContactUsNMLSId,
|
|
58
|
+
ContactUsNewTest,
|
|
57
59
|
CpraRequest,
|
|
58
60
|
CraPublicFile,
|
|
59
61
|
DealerServices,
|
package/dist/main.js
CHANGED
|
@@ -68,6 +68,7 @@ import { ContactUsAAS } from "./Forms/ContactUsAAS.js";
|
|
|
68
68
|
import { ContactUsBusiness } from "./Forms/ContactUsBusiness.js";
|
|
69
69
|
import { ContactUsBusinessNameAndEmail } from "./Forms/ContactUsBusinessNameEmail.js";
|
|
70
70
|
import { ContactUsLVF } from "./Forms/ContactUsLVF.js";
|
|
71
|
+
import { ContactUsNewTest } from "./Forms/ContactUsNewTest.js";
|
|
71
72
|
import { ContactUsNMLSId } from "./Forms/ContactUsNMLSId.js";
|
|
72
73
|
import { CpraRequest } from "./Forms/CpraRequest.js";
|
|
73
74
|
import { CraPublicFile } from "./Forms/CraPublicFile.js";
|
|
@@ -266,6 +267,7 @@ export {
|
|
|
266
267
|
ContactUsBusinessNameAndEmail,
|
|
267
268
|
ContactUsLVF,
|
|
268
269
|
ContactUsNMLSId,
|
|
270
|
+
ContactUsNewTest,
|
|
269
271
|
ContentBanner,
|
|
270
272
|
CpraRequest,
|
|
271
273
|
CraPublicFile,
|
package/package.json
CHANGED