@salesforcedevs/dw-components 1.3.157-canary.6 → 1.3.162

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.
@@ -1,152 +0,0 @@
1
- import { api, LightningElement } from "lwc";
2
- import { DrmFormData, StepDatum } from "dw/j2sCardSequence";
3
- import { track } from "dxUtils/analytics";
4
- import J2sForm from "dw/j2sForm";
5
-
6
- export default class J2sCardSequenceStep extends LightningElement {
7
- @api countryOptions: any[] = [];
8
- @api isLoading = false;
9
- @api recaptchaToken = "";
10
- @api selectedCountry = "";
11
- @api stepDatum!: StepDatum;
12
- @api stepIndex = 0;
13
- @api stepTotalCount = 0;
14
- @api userInfo: any = {};
15
-
16
- @api
17
- public notifyFormSubmitFailure(formFailureData: Partial<DrmFormData>) {
18
- (
19
- this.template.querySelector("dw-j2s-form") as unknown as J2sForm
20
- )?.notifySubmitFailure(formFailureData);
21
- }
22
-
23
- private _isJ2sFormInvalid = false;
24
-
25
- private get stepClassName() {
26
- return this.stepIndex === 2 && this.selectedCountry === "IN"
27
- ? "final-card-with-action"
28
- : "";
29
- }
30
-
31
- private get isJ2sFormInvalid() {
32
- return this.stepIndex === 1 && this._isJ2sFormInvalid;
33
- }
34
- private set isJ2sFormInvalid(value: boolean) {
35
- this._isJ2sFormInvalid = value;
36
- }
37
-
38
- private get primaryActionLink() {
39
- const { link } = this.stepDatum.primaryAction;
40
- return typeof link === "string"
41
- ? link
42
- : link?.[this.selectedCountry] || link?.default;
43
- }
44
-
45
- private get primaryActionText() {
46
- const { text } = this.stepDatum.primaryAction;
47
- return typeof text === "string"
48
- ? text
49
- : text[this.selectedCountry] || text.default;
50
- }
51
-
52
- private get primaryActionVariant() {
53
- if (this.stepIndex === 1 && this.isJ2sFormInvalid) {
54
- return "custom"; // override for disabled button styling
55
- }
56
- return this.stepDatum.primaryAction.variant;
57
- }
58
-
59
- private get primaryActionLinkTarget() {
60
- return this.stepDatum.primaryAction.linkTarget || "_blank";
61
- }
62
-
63
- private get showPrimaryAction() {
64
- return this.stepIndex !== 2 || this.selectedCountry === "IN";
65
- }
66
-
67
- private get showSecondaryAction() {
68
- return this.showPrimaryAction; // same requirement as above for now
69
- }
70
-
71
- renderedCallback() {
72
- this.updateStaticInnerHtml();
73
- }
74
-
75
- handleFormValidityChange({ detail }: CustomEvent) {
76
- this.isJ2sFormInvalid = !detail.isValid;
77
- }
78
-
79
- handlePrimaryAction(evt: Event) {
80
- this.track(evt);
81
-
82
- if (this.stepIndex === 0) {
83
- this.dispatchEvent(new CustomEvent("getstarted"));
84
- } else if (this.stepIndex === 1 && !this.isJ2sFormInvalid) {
85
- const j2sFormEl = this.template.querySelector(
86
- "dw-j2s-form"
87
- ) as unknown as J2sForm;
88
- const formData = j2sFormEl.formDataForDrm;
89
-
90
- // For some countries, explicit approvals will be present; for others, it is implicitly assumed
91
- if (typeof formData.Opt_In__c !== "boolean") {
92
- formData.Opt_In__c = true;
93
- }
94
- if (typeof formData.Privacy_Statement__c !== "boolean") {
95
- formData.Privacy_Statement__c = true;
96
- }
97
-
98
- this.dispatchEvent(
99
- new CustomEvent("formsubmit", {
100
- detail: formData
101
- })
102
- );
103
- }
104
- }
105
-
106
- private updateStaticInnerHtml() {
107
- const { bodyHtml, secondaryActionHtml } = this.stepDatum;
108
- const bodyMarkupContainer =
109
- this.template.querySelector("span.body-markup");
110
- const secondaryActionMarkupContainer = this.template.querySelector(
111
- "span.secondary-action-markup"
112
- );
113
-
114
- if (bodyMarkupContainer) {
115
- let markup =
116
- typeof bodyHtml === "string"
117
- ? bodyHtml
118
- : bodyHtml?.[this.selectedCountry] || bodyHtml?.default;
119
-
120
- if (this.stepIndex === 2) {
121
- // User's email is supposed to show on final step
122
- markup = `${markup}${
123
- !this.userInfo.Email
124
- ? ""
125
- : `<span class="final-email-address">${this.userInfo.Email}</span>`
126
- }`;
127
- }
128
-
129
- bodyMarkupContainer.innerHTML = markup || "";
130
- }
131
-
132
- if (secondaryActionMarkupContainer) {
133
- // new special exception on step 2 to only show secondary action for IN
134
- secondaryActionMarkupContainer.innerHTML =
135
- secondaryActionHtml && this.showSecondaryAction
136
- ? secondaryActionHtml
137
- : "";
138
- }
139
- }
140
-
141
- private track(evt: Event) {
142
- const target = evt.target as HTMLButtonElement;
143
-
144
- track(target, "custEv_ctaButtonClick", {
145
- click_text: target.textContent,
146
- element_title: this.stepDatum.stepTitle,
147
- click_url: this.stepDatum.primaryAction.link || "",
148
- element_type: "button",
149
- content_category: "cta"
150
- });
151
- }
152
- }
@@ -1,69 +0,0 @@
1
- .hidden {
2
- display: none;
3
- }
4
-
5
- .form-row {
6
- display: flex;
7
- justify-content: space-between;
8
- padding-bottom: var(--dx-g-spacing-md);
9
- }
10
-
11
- .form-row > * {
12
- --dx-c-input-width: 100%;
13
-
14
- font-family: var(--dx-g-font-sans);
15
- width: calc(50% - 20px);
16
- }
17
-
18
- .form-row > :only-child {
19
- max-width: 100%;
20
- width: 100%;
21
- }
22
-
23
- .form-row .terms {
24
- --dx-c-checkbox-text-line-height: var(--dx-g-text-lg);
25
- --dx-c-checkbox-font-size: var(--dx-g-text-sm);
26
-
27
- font-family: var(--dx-g-font-sans);
28
- font-size: var(--dx-c-checkbox-font-size);
29
- font-weight: var(--dx-g-font-normal);
30
- }
31
-
32
- .form-row .legal-terms-learn-more:not(.hidden) {
33
- display: block;
34
- padding-top: var(--dx-g-spacing-md);
35
- }
36
-
37
- .form-row .legal-terms.no-checkbox {
38
- font-family: var(--dx-g-font-sans);
39
- font-size: var(--dx-g-text-xs);
40
- font-weight: var(--dx-g-font-normal);
41
- margin-left: 28px;
42
- }
43
-
44
- .form-terms-container {
45
- padding-top: var(--dx-g-spacing-sm);
46
- }
47
-
48
- .form-captcha-slot {
49
- align-items: center;
50
- display: flex;
51
- justify-content: center;
52
- }
53
-
54
- dx-input[disabled] {
55
- --dx-c-input-background: revert;
56
- }
57
-
58
- /* Small Devices */
59
- @media screen and (max-width: 480px) {
60
- .form-row {
61
- flex-wrap: wrap;
62
- padding-bottom: unset;
63
- }
64
-
65
- .form-row > * {
66
- padding-bottom: var(--dx-g-spacing-md);
67
- width: 100%;
68
- }
69
- }
@@ -1,208 +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
- onchange={handleFormFieldChange}
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
- onchange={handleFormFieldChange}
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
- value={state.Company__c}
38
- onchange={handleFormFieldChange}
39
- ></dx-input>
40
- <dx-select
41
- class="job-role-field"
42
- label="Job Role"
43
- message-when-value-missing="Select your job role"
44
- name="DRM_Role__c"
45
- options={jobRoles}
46
- placeholder="Select Job Role"
47
- required
48
- value={state.DRM_Role__c}
49
- onchange={handleFormFieldChange}
50
- ></dx-select>
51
- </div>
52
- <template if:false={showStateProvince}>
53
- <div class="form-row">
54
- <dx-input
55
- name="Email"
56
- type="email"
57
- placeholder="Your email address"
58
- label="Email"
59
- missing-error-message="Enter your email address"
60
- validity-on-blur="true"
61
- disabled
62
- readonly="true"
63
- required
64
- value={state.Email}
65
- ></dx-input>
66
- <dx-select
67
- label="Country/Region"
68
- message-when-value-missing="Select your country/region"
69
- name="MailingCountry"
70
- options={countries}
71
- placeholder="Select Country/Region"
72
- required
73
- value={state.MailingCountry}
74
- onchange={handleFormFieldChange}
75
- ></dx-select>
76
- </div>
77
- </template>
78
- <template if:true={showStateProvince}>
79
- <div class="form-row">
80
- <dx-select
81
- label="Country/Region"
82
- message-when-value-missing="Select your country/region"
83
- name="MailingCountry"
84
- options={countries}
85
- placeholder="Select Country/Region"
86
- required
87
- value={state.MailingCountry}
88
- onchange={handleFormFieldChange}
89
- ></dx-select>
90
- <dx-select
91
- label="State/Province"
92
- message-when-value-missing="Select your state/province"
93
- name="MailingState"
94
- options={states}
95
- placeholder="Select State/Province"
96
- required
97
- value={state.MailingState}
98
- onchange={handleFormFieldChange}
99
- ></dx-select>
100
- </div>
101
- <div class="form-row">
102
- <dx-input
103
- name="Email"
104
- class="full-width-input-field"
105
- type="email"
106
- placeholder="Your email address"
107
- label="Email"
108
- missing-error-message="Enter your email address"
109
- validity-on-blur="true"
110
- disabled
111
- readonly="true"
112
- required
113
- value={state.Email}
114
- ></dx-input>
115
- </div>
116
- </template>
117
- <div class="form-row" if:true={isCountryWithReferralInput}>
118
- <dx-input
119
- name="Referral_Email__c"
120
- class="full-width-input-field"
121
- label="If anyone has referred you, please share their Email ID below, with their consent."
122
- validity-on-blur="true"
123
- type="email"
124
- value={state.Referral_Email__c}
125
- onchange={handleFormFieldChange}
126
- ></dx-input>
127
- </div>
128
- <div class="form-row" if:true={isNotParticipatingCountry}>
129
- <dx-alert
130
- alert-info={notAvailableAlertInfo}
131
- type="danger"
132
- variant="accented"
133
- ></dx-alert>
134
- </div>
135
- <div class="form-row" if:true={isSalesforceEmployee}>
136
- <dx-alert
137
- alert-info={salesforceEmployeeAlertInfo}
138
- type="danger"
139
- variant="accented"
140
- ></dx-alert>
141
- </div>
142
- <div class="form-row" if:true={showSubmitFailureAlert}>
143
- <dx-alert
144
- alert-info={formSubmitFailureAlertInfo}
145
- type="danger"
146
- variant="accented"
147
- ></dx-alert>
148
- </div>
149
- <div class="form-terms-container">
150
- <div class="form-row" if:true={state.showMarketingText}>
151
- <dx-checkbox
152
- value="marketing-terms"
153
- name="Opt_In__c"
154
- required
155
- class="terms"
156
- onchange={handleFormFieldChange}
157
- disabled={disableCheckboxes}
158
- >
159
- <span lwc:dom="manual" class="marketing-terms"></span>
160
- </dx-checkbox>
161
- </div>
162
- <div class="form-row">
163
- <dx-checkbox
164
- value="j2s-terms"
165
- name="j2s_terms"
166
- required
167
- class="terms"
168
- onchange={handleFormFieldChange}
169
- disabled={disableCheckboxes}
170
- >
171
- <span lwc:dom="manual" class="j2s-terms"></span>
172
- </dx-checkbox>
173
- </div>
174
- <div class="form-row">
175
- <dx-checkbox
176
- if:true={state.showLegalCheckbox}
177
- value="legal-terms"
178
- name="Privacy_Statement__c"
179
- required
180
- class="terms"
181
- onchange={handleFormFieldChange}
182
- disabled={disableCheckboxes}
183
- >
184
- <span lwc:dom="manual" class="legal-terms"></span>
185
- <template if:true={state.learnMore}>
186
- &nbsp;
187
- <dx-button
188
- variant="inline-inherit"
189
- onclick={handleLearnMore}
190
- >
191
- Learn more.
192
- </dx-button>
193
- <span
194
- lwc:dom="manual"
195
- class="legal-terms-learn-more hidden"
196
- ></span>
197
- </template>
198
- </dx-checkbox>
199
- <span
200
- if:false={state.showLegalCheckbox}
201
- lwc:dom="manual"
202
- class="legal-terms no-checkbox"
203
- ></span>
204
- </div>
205
- <slot class="form-captcha-slot" name="form-captcha-slot"></slot>
206
- </div>
207
- </form>
208
- </template>