@salesforcedevs/dw-components 1.3.148-canary.9 → 1.3.150
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/LICENSE +12 -0
- package/lwc.config.json +0 -2
- package/package.json +4 -3
- package/src/modules/dw/j2sCardSequence/j2sCardSequence.css +0 -53
- package/src/modules/dw/j2sCardSequence/j2sCardSequence.html +0 -75
- package/src/modules/dw/j2sCardSequence/j2sCardSequence.ts +0 -395
- package/src/modules/dw/j2sCardSequence/mockProps.ts +0 -46
- package/src/modules/dw/j2sForm/j2sForm.css +0 -52
- package/src/modules/dw/j2sForm/j2sForm.html +0 -160
- package/src/modules/dw/j2sForm/j2sForm.ts +0 -263
- package/src/modules/dw/j2sForm/mockProps.ts +0 -3095
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<!-- For the names of the form fields, see: https://salesforce.quip.com/daInAFETbPGm -->
|
|
3
|
-
<form class="j2s-form">
|
|
4
|
-
<div class="form-row">
|
|
5
|
-
<dx-input
|
|
6
|
-
class="first-name-field"
|
|
7
|
-
label="First Name"
|
|
8
|
-
missing-error-message="Enter your first name"
|
|
9
|
-
name="FirstName"
|
|
10
|
-
placeholder="Your first name"
|
|
11
|
-
required
|
|
12
|
-
validity-on-blur
|
|
13
|
-
onblur={handleRequiredFieldUpdate}
|
|
14
|
-
value={state.firstName}
|
|
15
|
-
></dx-input>
|
|
16
|
-
<dx-input
|
|
17
|
-
class="last-name-field"
|
|
18
|
-
label="Last Name"
|
|
19
|
-
missing-error-message="Enter your last name"
|
|
20
|
-
name="LastName"
|
|
21
|
-
placeholder="Your last name"
|
|
22
|
-
required
|
|
23
|
-
validity-on-blur
|
|
24
|
-
onblur={handleRequiredFieldUpdate}
|
|
25
|
-
value={state.lastName}
|
|
26
|
-
></dx-input>
|
|
27
|
-
</div>
|
|
28
|
-
<div class="form-row">
|
|
29
|
-
<dx-input
|
|
30
|
-
class="company-name-field"
|
|
31
|
-
label="Company Name"
|
|
32
|
-
missing-error-message="Enter your company name"
|
|
33
|
-
name="Company__c"
|
|
34
|
-
placeholder="Your company name"
|
|
35
|
-
required
|
|
36
|
-
validity-on-blur
|
|
37
|
-
onblur={handleRequiredFieldUpdate}
|
|
38
|
-
value={state.companyName}
|
|
39
|
-
></dx-input>
|
|
40
|
-
<dx-select
|
|
41
|
-
if:false={isJobRoleRequired}
|
|
42
|
-
class="job-role-field"
|
|
43
|
-
label="Job Role"
|
|
44
|
-
message-when-value-missing="Select your job role"
|
|
45
|
-
name="DRM_Role__c"
|
|
46
|
-
options={jobRoles}
|
|
47
|
-
placeholder="Select Job Role"
|
|
48
|
-
value={state.jobRole}
|
|
49
|
-
></dx-select>
|
|
50
|
-
<dx-select
|
|
51
|
-
if:true={isJobRoleRequired}
|
|
52
|
-
class="job-role-field"
|
|
53
|
-
label="Job Role"
|
|
54
|
-
message-when-value-missing="Select your job role"
|
|
55
|
-
name="DRM_Role__c"
|
|
56
|
-
options={jobRoles}
|
|
57
|
-
placeholder="Select Job Role"
|
|
58
|
-
required
|
|
59
|
-
value={state.jobRole}
|
|
60
|
-
onchange={handleRequiredFieldUpdate}
|
|
61
|
-
></dx-select>
|
|
62
|
-
</div>
|
|
63
|
-
<div class="form-row">
|
|
64
|
-
<dx-input
|
|
65
|
-
name="Email"
|
|
66
|
-
type="email"
|
|
67
|
-
placeholder="Your email address"
|
|
68
|
-
label="Email"
|
|
69
|
-
missing-error-message="Enter your email address"
|
|
70
|
-
validity-on-blur="true"
|
|
71
|
-
required
|
|
72
|
-
onblur={handleRequiredFieldUpdate}
|
|
73
|
-
value={state.email}
|
|
74
|
-
></dx-input>
|
|
75
|
-
<dx-select
|
|
76
|
-
label="Country/Region"
|
|
77
|
-
message-when-value-missing="Select your country/region"
|
|
78
|
-
name="MailingCountry"
|
|
79
|
-
options={countries}
|
|
80
|
-
placeholder="Select Country/Region"
|
|
81
|
-
required
|
|
82
|
-
value={state.country}
|
|
83
|
-
onchange={handleCountryChange}
|
|
84
|
-
></dx-select>
|
|
85
|
-
</div>
|
|
86
|
-
<div class="form-row" if:true={isCountryWithReferralInput}>
|
|
87
|
-
<dx-input
|
|
88
|
-
name="Referral_Email__c"
|
|
89
|
-
class="referral-email-field full-width"
|
|
90
|
-
label="If anyone has referred you, please share their Email ID below, with their consent."
|
|
91
|
-
type="email"
|
|
92
|
-
></dx-input>
|
|
93
|
-
</div>
|
|
94
|
-
<div class="form-row" if:true={isNotParticipatingCountry}>
|
|
95
|
-
<dx-alert
|
|
96
|
-
alert-info={notAvailableAlertInfo}
|
|
97
|
-
class="full-width"
|
|
98
|
-
type="danger"
|
|
99
|
-
variant="accented"
|
|
100
|
-
></dx-alert>
|
|
101
|
-
</div>
|
|
102
|
-
<div class="form-terms-container">
|
|
103
|
-
<div class="form-row" if:true={state.showMarketingText}>
|
|
104
|
-
<dx-checkbox
|
|
105
|
-
value="marketing-terms"
|
|
106
|
-
name="Opt_In__c"
|
|
107
|
-
required
|
|
108
|
-
class="terms"
|
|
109
|
-
onchange={handleRequiredFieldUpdate}
|
|
110
|
-
disabled={isNotParticipatingCountry}
|
|
111
|
-
>
|
|
112
|
-
<span lwc:dom="manual" class="marketing-terms"></span>
|
|
113
|
-
</dx-checkbox>
|
|
114
|
-
</div>
|
|
115
|
-
<div class="form-row">
|
|
116
|
-
<dx-checkbox
|
|
117
|
-
value="j2s-terms"
|
|
118
|
-
name="j2s_terms"
|
|
119
|
-
required
|
|
120
|
-
class="terms"
|
|
121
|
-
onchange={handleRequiredFieldUpdate}
|
|
122
|
-
disabled={isNotParticipatingCountry}
|
|
123
|
-
>
|
|
124
|
-
<span lwc:dom="manual" class="j2s-terms"></span>
|
|
125
|
-
</dx-checkbox>
|
|
126
|
-
</div>
|
|
127
|
-
<div class="form-row">
|
|
128
|
-
<dx-checkbox
|
|
129
|
-
if:true={state.showLegalCheckbox}
|
|
130
|
-
value="legal-terms"
|
|
131
|
-
name="Privacy_Statement__c"
|
|
132
|
-
required
|
|
133
|
-
class="terms"
|
|
134
|
-
onchange={handleRequiredFieldUpdate}
|
|
135
|
-
disabled={isNotParticipatingCountry}
|
|
136
|
-
>
|
|
137
|
-
<span lwc:dom="manual" class="legal-terms"></span>
|
|
138
|
-
<template if:true={state.learnMore}>
|
|
139
|
-
<dx-button
|
|
140
|
-
variant="inline-inherit"
|
|
141
|
-
onclick={handleLearnMore}
|
|
142
|
-
>
|
|
143
|
-
Learn More
|
|
144
|
-
</dx-button>
|
|
145
|
-
<span
|
|
146
|
-
lwc:dom="manual"
|
|
147
|
-
class="legal-terms-learn-more hidden"
|
|
148
|
-
></span>
|
|
149
|
-
</template>
|
|
150
|
-
</dx-checkbox>
|
|
151
|
-
<span
|
|
152
|
-
if:false={state.showLegalCheckbox}
|
|
153
|
-
lwc:dom="manual"
|
|
154
|
-
class="legal-terms no-checkbox"
|
|
155
|
-
></span>
|
|
156
|
-
</div>
|
|
157
|
-
<slot class="form-captcha-slot" name="form-captcha-slot"></slot>
|
|
158
|
-
</div>
|
|
159
|
-
</form>
|
|
160
|
-
</template>
|
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
import { toJson } from "dxUtils/normalizers";
|
|
2
|
-
import { api } from "lwc";
|
|
3
|
-
import { LightningElementWithState } from "dxBaseElements/lightningElementWithState";
|
|
4
|
-
|
|
5
|
-
// Hard-coding for now because we can't get information about an endpoint for this
|
|
6
|
-
const tbidValidRoles = [
|
|
7
|
-
"Developer",
|
|
8
|
-
"Administrator",
|
|
9
|
-
"Architect",
|
|
10
|
-
"Sales Representative / Manager",
|
|
11
|
-
"Marketer",
|
|
12
|
-
"Service Agent / Supervisor",
|
|
13
|
-
"Data Analyst",
|
|
14
|
-
"Consultant",
|
|
15
|
-
"Business Operations Manager",
|
|
16
|
-
"Designer",
|
|
17
|
-
"Educator",
|
|
18
|
-
"Student",
|
|
19
|
-
"Executive",
|
|
20
|
-
"Product Manager"
|
|
21
|
-
];
|
|
22
|
-
|
|
23
|
-
export type J2sFormState = {
|
|
24
|
-
country: string;
|
|
25
|
-
legalText: string;
|
|
26
|
-
marketingText: string;
|
|
27
|
-
learnMore: string;
|
|
28
|
-
showLegalCheckbox: boolean;
|
|
29
|
-
showMarketingText: boolean;
|
|
30
|
-
isFormValid: boolean;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export default class J2sForm extends LightningElementWithState<J2sFormState> {
|
|
34
|
-
private _countriesJson = "";
|
|
35
|
-
private _countriesLookup: any = {}; // TODO typings
|
|
36
|
-
private _didSetFormId = false;
|
|
37
|
-
private _formMetadata: any = {}; // TODO typings
|
|
38
|
-
private _incomingUserInfo: any = {}; // TODO typings
|
|
39
|
-
private _isInitialRender = true;
|
|
40
|
-
private _recaptchaToken = "";
|
|
41
|
-
|
|
42
|
-
@api id = "";
|
|
43
|
-
@api referralText = "";
|
|
44
|
-
|
|
45
|
-
@api
|
|
46
|
-
get countries() {
|
|
47
|
-
return this._countriesJson || "[]";
|
|
48
|
-
}
|
|
49
|
-
set countries(value: string) {
|
|
50
|
-
this._countriesJson = value;
|
|
51
|
-
|
|
52
|
-
// Store a lookup table of country data by value so that we don't have to loop all the time
|
|
53
|
-
const countries = toJson(value);
|
|
54
|
-
const countriesLookup: any = {};
|
|
55
|
-
countries.forEach((country: any) => {
|
|
56
|
-
countriesLookup[country.value] = country;
|
|
57
|
-
});
|
|
58
|
-
this._countriesLookup = countriesLookup;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
@api
|
|
62
|
-
get incomingUserInfo() {
|
|
63
|
-
return this._incomingUserInfo;
|
|
64
|
-
}
|
|
65
|
-
set incomingUserInfo(value: string) {
|
|
66
|
-
this._incomingUserInfo = toJson(value);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
@api
|
|
70
|
-
get formMetadata() {
|
|
71
|
-
return this._formMetadata;
|
|
72
|
-
}
|
|
73
|
-
set formMetadata(value: string) {
|
|
74
|
-
this._formMetadata = toJson(value);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
@api
|
|
78
|
-
get formDataForDrm() {
|
|
79
|
-
// We should be able to just get the formData from the form automatically using `new FormData(theForm)`,
|
|
80
|
-
// but our custom form elements don't seem to implement what it is required for that currently. See:
|
|
81
|
-
// https://web.dev/more-capable-form-controls/#defining-a-form-associated-custom-element
|
|
82
|
-
const formData: any = {};
|
|
83
|
-
this.template
|
|
84
|
-
.querySelectorAll("form [name]")
|
|
85
|
-
.forEach((namedElement) => {
|
|
86
|
-
const typedElement = namedElement as HTMLInputElement;
|
|
87
|
-
formData[typedElement.name] =
|
|
88
|
-
typeof typedElement.checked === "boolean"
|
|
89
|
-
? typedElement.checked
|
|
90
|
-
: typedElement.value;
|
|
91
|
-
});
|
|
92
|
-
return formData;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
@api
|
|
96
|
-
get recaptchaToken() {
|
|
97
|
-
return this._recaptchaToken;
|
|
98
|
-
}
|
|
99
|
-
set recaptchaToken(value: string) {
|
|
100
|
-
this._recaptchaToken = value;
|
|
101
|
-
this.handleRequiredFieldUpdate();
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
private participatingCountryCodes = ["US", "CA", "IN"];
|
|
105
|
-
private countriesWithReferralInput = ["IN"];
|
|
106
|
-
private countriesWithRequiredJobRole = ["CA"];
|
|
107
|
-
private requiredFormFields: HTMLElement[] = [];
|
|
108
|
-
|
|
109
|
-
get isNotParticipatingCountry() {
|
|
110
|
-
return !this.isParticipatingCountry(this.state.country);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
get isCountryWithReferralInput() {
|
|
114
|
-
return this.countriesWithReferralInput.includes(this.state.country);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
get isJobRoleRequired() {
|
|
118
|
-
return this.countriesWithRequiredJobRole.includes(this.state.country);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
get notAvailableAlertInfo() {
|
|
122
|
-
return (this.formMetadata as any).notAvailableAlertInfo;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
get jobRoles() {
|
|
126
|
-
return tbidValidRoles.map((role) => ({
|
|
127
|
-
label: role,
|
|
128
|
-
value: role
|
|
129
|
-
}));
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
connectedCallback() {
|
|
133
|
-
const initialState: Partial<J2sFormState> = {
|
|
134
|
-
...this._incomingUserInfo,
|
|
135
|
-
isFormValid: false,
|
|
136
|
-
showMarketingText: true
|
|
137
|
-
};
|
|
138
|
-
const initialCountry = initialState.country;
|
|
139
|
-
const initialCountryData =
|
|
140
|
-
initialCountry && this._countriesLookup[initialCountry];
|
|
141
|
-
if (initialCountryData) {
|
|
142
|
-
initialState.showLegalCheckbox =
|
|
143
|
-
initialCountryData.showLegalCheckbox;
|
|
144
|
-
initialState.legalText = initialCountryData.legalText;
|
|
145
|
-
initialState.marketingText = initialCountryData.marketingText;
|
|
146
|
-
initialState.learnMore = initialCountryData.learnMore;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
this.state = initialState as J2sFormState;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
renderedCallback(): void {
|
|
153
|
-
if (this._isInitialRender) {
|
|
154
|
-
this.updateInnerHtml(
|
|
155
|
-
"span.j2s-terms",
|
|
156
|
-
(this.formMetadata as any).j2sTerms
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
if (
|
|
161
|
-
this.state.country &&
|
|
162
|
-
this.state.country !== this.prevState.country
|
|
163
|
-
) {
|
|
164
|
-
// Re-render new country's terms
|
|
165
|
-
this.updateInnerHtml(
|
|
166
|
-
"span.marketing-terms",
|
|
167
|
-
this.state.marketingText
|
|
168
|
-
);
|
|
169
|
-
this.updateInnerHtml("span.legal-terms", this.state.legalText);
|
|
170
|
-
if (this.state.learnMore) {
|
|
171
|
-
this.updateInnerHtml(
|
|
172
|
-
"span.legal-terms-learn-more",
|
|
173
|
-
` ${this.state.learnMore}`
|
|
174
|
-
);
|
|
175
|
-
} else {
|
|
176
|
-
this.updateInnerHtml("span.legal-terms-learn-more", "");
|
|
177
|
-
this.template
|
|
178
|
-
.querySelector(".legal-terms-learn-more")
|
|
179
|
-
?.classList.add("hidden");
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
if (this.state.isFormValid !== this.prevState.isFormValid) {
|
|
184
|
-
this.dispatchEvent(
|
|
185
|
-
new CustomEvent("formvaliditychange", {
|
|
186
|
-
detail: {
|
|
187
|
-
isValid: this.state.isFormValid
|
|
188
|
-
},
|
|
189
|
-
bubbles: true,
|
|
190
|
-
composed: true
|
|
191
|
-
})
|
|
192
|
-
);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
this.requiredFormFields = Array.from(
|
|
196
|
-
this.template.querySelectorAll("[required]")
|
|
197
|
-
);
|
|
198
|
-
|
|
199
|
-
if (this.id && !this._didSetFormId) {
|
|
200
|
-
this._didSetFormId = true;
|
|
201
|
-
this.template.querySelector("form")?.setAttribute("id", this.id);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
handleRequiredFieldUpdate() {
|
|
206
|
-
const isFormNowValid = this.checkValidity();
|
|
207
|
-
if (this.state.isFormValid !== isFormNowValid) {
|
|
208
|
-
this.setState({
|
|
209
|
-
isFormValid: isFormNowValid
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
handleCountryChange({ detail }: CustomEvent) {
|
|
215
|
-
const { value } = detail;
|
|
216
|
-
const countryData = this._countriesLookup[value];
|
|
217
|
-
|
|
218
|
-
this.setState({
|
|
219
|
-
country: value,
|
|
220
|
-
learnMore: countryData.learnMore,
|
|
221
|
-
legalText: countryData.legalText,
|
|
222
|
-
marketingText: countryData.marketingText,
|
|
223
|
-
showLegalCheckbox: countryData.showLegalCheckbox
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
// Because updating the country can update the required fields, we need to re-set form
|
|
227
|
-
// validity after render
|
|
228
|
-
requestAnimationFrame(() =>
|
|
229
|
-
this.setState({
|
|
230
|
-
isFormValid: this.checkValidity()
|
|
231
|
-
})
|
|
232
|
-
);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
handleLearnMore() {
|
|
236
|
-
this.template
|
|
237
|
-
.querySelector(".legal-terms-learn-more")
|
|
238
|
-
?.classList.toggle("hidden");
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
private updateInnerHtml(selector: string, html: string): void {
|
|
242
|
-
const element = this.template.querySelector(selector);
|
|
243
|
-
if (element) {
|
|
244
|
-
element.innerHTML = html;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
private isParticipatingCountry(country: string) {
|
|
249
|
-
return this.participatingCountryCodes.includes(country);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
private checkValidity() {
|
|
253
|
-
return (
|
|
254
|
-
Boolean(this.recaptchaToken) &&
|
|
255
|
-
this.isParticipatingCountry(this.state.country) &&
|
|
256
|
-
this.requiredFormFields.every(
|
|
257
|
-
(requiredFormField) =>
|
|
258
|
-
// @ts-ignore
|
|
259
|
-
requiredFormField.checkValidity?.() === true
|
|
260
|
-
)
|
|
261
|
-
);
|
|
262
|
-
}
|
|
263
|
-
}
|