@axos-web-dev/shared-components 1.0.100-dev.68 → 1.0.100-dev.69-mobileLogin

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,12 @@
1
+ import { FormProps } from './FormProps';
2
+
3
+ export type ConstructionLendingDynamicInputs = {
4
+ User_Type__c: string;
5
+ first_name: string;
6
+ last_name: string;
7
+ email: string;
8
+ phone: string;
9
+ description: string;
10
+ Company_NMLS_ID__c: string;
11
+ };
12
+ export declare const ConstructionLendingDynamic: ({ icon, children, onSubmit, disclosure, variant: fullVariant, headline, callToAction, validateEmail, onValidate, description, id, }: FormProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,301 @@
1
+ "use client";
2
+ import { jsx, jsxs, Fragment } 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 { Dropdown } from "../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 { InputTextArea } from "../Input/InputTextArea.js";
17
+ import "../Input/DownPaymentInput.js";
18
+ import "../Input/RadioButton.js";
19
+ import { LoadingIndicator } from "../LoadingIndicator/index.js";
20
+ import "../icons/ArrowIcon/ArrowIcon.css.js";
21
+ import SvgAxosX from "../icons/AxosX/index.js";
22
+ import SvgComponent from "../icons/AxosX/Blue.js";
23
+ import "../icons/CheckIcon/CheckIcon.css.js";
24
+ import '../assets/icons/FollowIcon/FollowIcon.css';import '../assets/icons/DownloadIcon/DownloadIcon.css';import '../assets/themes/victorie.css';import '../assets/themes/ufb.css';import '../assets/themes/premier.css';import '../assets/themes/axos.css';/* empty css */
25
+ /* empty css */
26
+ /* empty css */
27
+ /* empty css */
28
+ /* empty css */
29
+ /* empty css */
30
+ import "../utils/allowedAxosDomains.js";
31
+ import * as z from "zod";
32
+ import { associatedEmail } from "../utils/EverestValidity.js";
33
+ import { getVariant } from "../utils/getVariant.js";
34
+ import { useCachedEmailValidator } from "../utils/useCachedValidators.js";
35
+ import clsx from "clsx";
36
+ import { useForm, FormProvider } from "react-hook-form";
37
+ import { iconForm, headerContainer, headerForm, form, descriptionField, fullRowForm, formWrapper, disclosureForm, actions, formContainer } from "./Forms.css.js";
38
+ import { honeyPotSchema, isValidHoneyPot, HoneyPot } from "./HoneyPot/index.js";
39
+ import { SalesforceSchema } from "./SalesforceFieldsForm.js";
40
+ const HOMEOWNER_VALUE = "I am a homeowner.";
41
+ const BROKER_VALUE = "I am a broker.";
42
+ const ConstructionLendingDynamic = ({
43
+ icon = false,
44
+ children,
45
+ onSubmit = (values) => {
46
+ console.log(values);
47
+ },
48
+ disclosure,
49
+ variant: fullVariant = "primary",
50
+ headline,
51
+ callToAction,
52
+ validateEmail,
53
+ onValidate,
54
+ description,
55
+ id
56
+ }) => {
57
+ const cachedEmailValidator = useCachedEmailValidator(validateEmail);
58
+ const schema = z.object({
59
+ User_Type__c: z.string({
60
+ required_error: "Please select whether you are a homeowner or a broker.",
61
+ invalid_type_error: "Invalid selection"
62
+ }).min(1, {
63
+ message: "Please select whether you are a homeowner or a broker."
64
+ }),
65
+ first_name: z.string({
66
+ required_error: "First name is required",
67
+ invalid_type_error: "Invalid first name"
68
+ }).regex(/^[A-Za-z][^0-9_!¡?÷?¿/\\+=@#$%ˆ&*,.^(){}|~<>;:[\]]{1,}$/g, {
69
+ message: "Invalid first name"
70
+ }).trim().min(1, { message: "First Name is required." }),
71
+ last_name: z.string({
72
+ required_error: "Last name is required",
73
+ invalid_type_error: "Invalid last name"
74
+ }).regex(/^[A-Za-z][^0-9_!¡?÷?¿/\\+=@#$%ˆ&*,.^(){}|~<>;:[\]]{1,}$/g, {
75
+ message: "Invalid last name"
76
+ }).trim().min(1, { message: "Last Name is required." }),
77
+ email: z.string().email({ message: "Email is required." }).refine(cachedEmailValidator, { message: "Invalid email address." }),
78
+ 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) => {
79
+ const removeDashes = val.replace(/-/gi, "");
80
+ if (removeDashes.length !== 10) {
81
+ ctx.addIssue({
82
+ code: z.ZodIssueCode.custom,
83
+ message: "Phone must have at least 10 and no more than 10 characters."
84
+ });
85
+ return z.NEVER;
86
+ }
87
+ if (removeDashes.endsWith("00000") || removeDashes.startsWith("999") || removeDashes.length === 10 && /^[01]/.test(removeDashes)) {
88
+ ctx.addIssue({
89
+ code: z.ZodIssueCode.custom,
90
+ message: "Invalid phone number."
91
+ });
92
+ return z.NEVER;
93
+ }
94
+ return removeDashes;
95
+ }),
96
+ description: z.string().trim().optional().or(z.literal("")),
97
+ Company_NMLS_ID__c: z.string().min(6).max(7).optional().or(z.literal(""))
98
+ });
99
+ const gen_schema = schema.merge(SalesforceSchema).merge(honeyPotSchema).superRefine((data, ctx) => {
100
+ if (!isValidHoneyPot(data)) {
101
+ ctx.addIssue({
102
+ code: z.ZodIssueCode.custom,
103
+ message: "fields are not valid."
104
+ });
105
+ }
106
+ if (data.User_Type__c === BROKER_VALUE) {
107
+ const nmls = data.Company_NMLS_ID__c ?? "";
108
+ if (!nmls || nmls.length < 6 || nmls.length > 7) {
109
+ ctx.addIssue({
110
+ code: z.ZodIssueCode.custom,
111
+ message: "NMLS ID is required for brokers and must be 6-7 characters.",
112
+ path: ["Company_NMLS_ID__c"]
113
+ });
114
+ }
115
+ }
116
+ });
117
+ const methods = useForm({
118
+ resolver: zodResolver(gen_schema, {
119
+ async: true
120
+ }),
121
+ mode: "all",
122
+ defaultValues: {
123
+ User_Type__c: "",
124
+ email: ""
125
+ },
126
+ shouldUnregister: true
127
+ });
128
+ const {
129
+ handleSubmit,
130
+ register,
131
+ watch,
132
+ formState: { errors, isValid, isSubmitting }
133
+ } = methods;
134
+ const userType = watch("User_Type__c");
135
+ const isBroker = userType === BROKER_VALUE;
136
+ const isExpanded = userType === HOMEOWNER_VALUE || userType === BROKER_VALUE;
137
+ const submitForm = async (data) => {
138
+ await onSubmit(data);
139
+ };
140
+ const variant = getVariant(fullVariant);
141
+ return /* @__PURE__ */ jsx("section", { id, className: clsx(formContainer({ variant })), children: /* @__PURE__ */ jsx("div", { className: clsx("containment"), children: /* @__PURE__ */ jsxs(FormProvider, { ...methods, children: [
142
+ icon && /* @__PURE__ */ jsx("div", { className: clsx("text_center", iconForm), children: ["primary", "secondary"].includes(variant) ? /* @__PURE__ */ jsx(SvgComponent, {}) : /* @__PURE__ */ jsx(SvgAxosX, {}) }),
143
+ /* @__PURE__ */ jsxs("div", { className: `${headerContainer} text_center`, children: [
144
+ /* @__PURE__ */ jsx("h2", { className: clsx("header_2", headerForm({ variant })), children: headline }),
145
+ description && /* @__PURE__ */ jsx(
146
+ "div",
147
+ {
148
+ className: clsx(
149
+ "text_center",
150
+ form,
151
+ descriptionField({ variant })
152
+ ),
153
+ children: description
154
+ }
155
+ )
156
+ ] }),
157
+ /* @__PURE__ */ jsxs(
158
+ "form",
159
+ {
160
+ className: form,
161
+ onSubmit: async (e) => {
162
+ onValidate && onValidate(e);
163
+ await handleSubmit(submitForm)(e);
164
+ e.preventDefault();
165
+ },
166
+ children: [
167
+ /* @__PURE__ */ jsxs("div", { className: clsx(formWrapper({ variant })), children: [
168
+ /* @__PURE__ */ jsx("div", { className: fullRowForm, children: /* @__PURE__ */ jsxs(
169
+ Dropdown,
170
+ {
171
+ id: "User_Type__c",
172
+ ...register("User_Type__c", { required: true }),
173
+ label: "Are you a homeowner or a broker?",
174
+ sizes: "medium",
175
+ required: true,
176
+ error: !!errors.User_Type__c,
177
+ helperText: errors.User_Type__c?.message,
178
+ variant,
179
+ children: [
180
+ /* @__PURE__ */ jsx("option", { value: "", disabled: isExpanded, children: "Select Option" }),
181
+ /* @__PURE__ */ jsx("option", { value: HOMEOWNER_VALUE, children: HOMEOWNER_VALUE }),
182
+ /* @__PURE__ */ jsx("option", { value: BROKER_VALUE, children: BROKER_VALUE })
183
+ ]
184
+ }
185
+ ) }),
186
+ isExpanded && /* @__PURE__ */ jsxs(Fragment, { children: [
187
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
188
+ Input,
189
+ {
190
+ id: "first_name",
191
+ ...register("first_name", { required: true }),
192
+ label: "First Name",
193
+ sizes: "medium",
194
+ required: true,
195
+ error: !!errors.first_name,
196
+ helperText: errors.first_name?.message,
197
+ variant
198
+ }
199
+ ) }),
200
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
201
+ Input,
202
+ {
203
+ id: "last_name",
204
+ ...register("last_name", { required: true }),
205
+ label: "Last Name",
206
+ sizes: "medium",
207
+ required: true,
208
+ error: !!errors.last_name,
209
+ helperText: errors.last_name?.message,
210
+ variant
211
+ }
212
+ ) }),
213
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
214
+ Input,
215
+ {
216
+ id: "email",
217
+ ...register("email", {
218
+ required: true,
219
+ validate: {
220
+ isValid: associatedEmail
221
+ }
222
+ }),
223
+ label: "Email",
224
+ sizes: "medium",
225
+ required: true,
226
+ error: !!errors.email,
227
+ helperText: errors.email?.message,
228
+ variant
229
+ }
230
+ ) }),
231
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
232
+ InputPhone,
233
+ {
234
+ id: "phone",
235
+ ...register("phone", {
236
+ required: true,
237
+ maxLength: 12
238
+ }),
239
+ label: "Phone",
240
+ sizes: "medium",
241
+ required: true,
242
+ error: !!errors.phone,
243
+ helperText: errors.phone?.message,
244
+ variant
245
+ }
246
+ ) }),
247
+ /* @__PURE__ */ jsx("div", { className: fullRowForm, children: /* @__PURE__ */ jsx(
248
+ InputTextArea,
249
+ {
250
+ id: "description",
251
+ ...register("description"),
252
+ label: "Message",
253
+ sizes: "medium",
254
+ error: !!errors.description,
255
+ helperText: errors.description?.message,
256
+ variant,
257
+ rows: 2
258
+ }
259
+ ) }),
260
+ isBroker && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
261
+ Input,
262
+ {
263
+ id: "Company_NMLS_ID__c",
264
+ ...register("Company_NMLS_ID__c"),
265
+ label: "Company NMLS ID",
266
+ sizes: "medium",
267
+ required: true,
268
+ error: !!errors.Company_NMLS_ID__c,
269
+ helperText: errors.Company_NMLS_ID__c?.message,
270
+ variant
271
+ }
272
+ ) }),
273
+ /* @__PURE__ */ jsx(HoneyPot, { register, variant })
274
+ ] })
275
+ ] }),
276
+ children,
277
+ /* @__PURE__ */ jsx("div", { className: disclosureForm({ variant }), children: disclosure }),
278
+ /* @__PURE__ */ jsx("div", { className: actions, children: isSubmitting ? /* @__PURE__ */ jsx(
279
+ LoadingIndicator,
280
+ {
281
+ style: { marginInline: "auto" },
282
+ variant
283
+ }
284
+ ) : /* @__PURE__ */ jsx(
285
+ Button,
286
+ {
287
+ color: getVariant(callToAction?.variant),
288
+ as: "button",
289
+ type: "submit",
290
+ disabled: !isExpanded || !isValid || isSubmitting,
291
+ children: callToAction?.displayText
292
+ }
293
+ ) })
294
+ ]
295
+ }
296
+ )
297
+ ] }) }) }, id);
298
+ };
299
+ export {
300
+ ConstructionLendingDynamic
301
+ };
@@ -6,6 +6,7 @@ export * from './CommercialDeposits';
6
6
  export * from './CommercialDepositsNoLendingOption';
7
7
  export * from './CommercialLending';
8
8
  export * from './CommercialPremiumFinance';
9
+ export * from './ConstructionLendingDynamic';
9
10
  export * from './ContactCompany';
10
11
  export * from './ContactCompanyTitle';
11
12
  export * from './ContactUs';
@@ -7,6 +7,7 @@ import { CommercialDeposits } from "./CommercialDeposits.js";
7
7
  import { CommercialDepositsNoLendingOption } from "./CommercialDepositsNoLendingOption.js";
8
8
  import { CommercialLending } from "./CommercialLending.js";
9
9
  import { CommercialPremiumFinance } from "./CommercialPremiumFinance.js";
10
+ import { ConstructionLendingDynamic } from "./ConstructionLendingDynamic.js";
10
11
  import { ContactCompany } from "./ContactCompany.js";
11
12
  import { ContactCompanyTitle } from "./ContactCompanyTitle.js";
12
13
  import { ContactUs } from "./ContactUs.js";
@@ -49,6 +50,7 @@ export {
49
50
  CommercialDepositsNoLendingOption,
50
51
  CommercialLending,
51
52
  CommercialPremiumFinance,
53
+ ConstructionLendingDynamic,
52
54
  ContactCompany,
53
55
  ContactCompanyTitle,
54
56
  ContactUs,