@salesforcedevs/dw-components 1.3.148-canary.26 → 1.3.148-canary.27
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/package.json
CHANGED
|
@@ -15,7 +15,8 @@ dx-step-sequence {
|
|
|
15
15
|
scroll-margin-top: var(--dx-g-global-header-height);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
dx-step-sequence-step:last-child
|
|
18
|
+
dx-step-sequence-step:last-child[data-has-primary-action="true"]
|
|
19
|
+
dx-card-step::part(footer-container) {
|
|
19
20
|
background-color: var(--dx-g-indigo-vibrant-95);
|
|
20
21
|
border-radius: 8px;
|
|
21
22
|
margin: 0 30px 30px 30px;
|
|
@@ -8,7 +8,11 @@
|
|
|
8
8
|
use-history={useHistory}
|
|
9
9
|
>
|
|
10
10
|
<template for:each={stepsData} for:item="stepDatum" for:index="index">
|
|
11
|
-
<dx-step-sequence-step
|
|
11
|
+
<dx-step-sequence-step
|
|
12
|
+
key={stepDatum.id}
|
|
13
|
+
class={stepClassName}
|
|
14
|
+
data-has-primary-action={hasPrimaryAction}
|
|
15
|
+
>
|
|
12
16
|
<dx-card-step
|
|
13
17
|
header-icon-symbol={stepDatum.headerData.iconSymbol}
|
|
14
18
|
header-icon-sprite={stepDatum.headerData.iconSprite}
|
|
@@ -55,9 +59,10 @@
|
|
|
55
59
|
</div>
|
|
56
60
|
<div slot="primary-action-section">
|
|
57
61
|
<dx-button
|
|
62
|
+
if:true={hasPrimaryAction}
|
|
58
63
|
class="primary-action"
|
|
59
64
|
disabled={isJ2sFormInvalid}
|
|
60
|
-
href={
|
|
65
|
+
href={primaryActionLink}
|
|
61
66
|
icon-sprite={stepDatum.primaryAction.iconSprite}
|
|
62
67
|
icon-symbol={stepDatum.primaryAction.iconSymbol}
|
|
63
68
|
loading={isLoading}
|
|
@@ -66,7 +71,7 @@
|
|
|
66
71
|
target={primaryActionLinkTarget}
|
|
67
72
|
variant={primaryActionVariant}
|
|
68
73
|
>
|
|
69
|
-
{
|
|
74
|
+
{primaryActionText}
|
|
70
75
|
</dx-button>
|
|
71
76
|
</div>
|
|
72
77
|
</dx-card-step>
|
|
@@ -6,7 +6,12 @@ import { toJson } from "dxUtils/normalizers";
|
|
|
6
6
|
import J2sForm from "dw/j2sForm";
|
|
7
7
|
|
|
8
8
|
export type StepDatum = {
|
|
9
|
-
bodyHtml?:
|
|
9
|
+
bodyHtml?:
|
|
10
|
+
| string
|
|
11
|
+
| {
|
|
12
|
+
default: string;
|
|
13
|
+
[countryCode: string]: string;
|
|
14
|
+
};
|
|
10
15
|
formData?: {
|
|
11
16
|
countriesWithReferralInput?: string[];
|
|
12
17
|
countriesWithRequiredJobRole?: string[];
|
|
@@ -28,9 +33,19 @@ export type StepDatum = {
|
|
|
28
33
|
primaryAction: {
|
|
29
34
|
iconSprite?: string;
|
|
30
35
|
iconSymbol?: string;
|
|
31
|
-
link?:
|
|
36
|
+
link?:
|
|
37
|
+
| string
|
|
38
|
+
| {
|
|
39
|
+
default: string;
|
|
40
|
+
[countryCode: string]: string;
|
|
41
|
+
};
|
|
32
42
|
linkTarget?: string;
|
|
33
|
-
text:
|
|
43
|
+
text:
|
|
44
|
+
| string
|
|
45
|
+
| {
|
|
46
|
+
default: string;
|
|
47
|
+
[countryCode: string]: string;
|
|
48
|
+
};
|
|
34
49
|
variant?: string;
|
|
35
50
|
};
|
|
36
51
|
secondaryActionHtml?: string;
|
|
@@ -92,9 +107,10 @@ export default class J2sCardSequence extends LightningElement {
|
|
|
92
107
|
});
|
|
93
108
|
}
|
|
94
109
|
|
|
110
|
+
private confirmedCountry = "";
|
|
95
111
|
private countries = "[]";
|
|
96
112
|
private currentSequenceStep = 0;
|
|
97
|
-
private formSubmissionFailureState = null;
|
|
113
|
+
private formSubmissionFailureState: Partial<DrmFormData> | null = null;
|
|
98
114
|
private recaptchaToken = "";
|
|
99
115
|
private sessionStorageId = "j2s-card-sequence";
|
|
100
116
|
private tbidUserInfo: any; // TODO typings?
|
|
@@ -116,19 +132,38 @@ export default class J2sCardSequence extends LightningElement {
|
|
|
116
132
|
this._isJ2sFormInvalid = isFormInvalid;
|
|
117
133
|
}
|
|
118
134
|
|
|
135
|
+
private get primaryAction() {
|
|
136
|
+
return this.stepsData[this.currentSequenceStep || 0].primaryAction;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
private get primaryActionLink() {
|
|
140
|
+
const { link } = this.primaryAction;
|
|
141
|
+
return typeof link === "string"
|
|
142
|
+
? link
|
|
143
|
+
: link?.[this.confirmedCountry] || link?.default;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
private get primaryActionText() {
|
|
147
|
+
const { text } = this.primaryAction;
|
|
148
|
+
return typeof text === "string"
|
|
149
|
+
? text
|
|
150
|
+
: text[this.confirmedCountry] || text.default;
|
|
151
|
+
}
|
|
152
|
+
|
|
119
153
|
private get primaryActionVariant() {
|
|
120
154
|
if (this.currentSequenceStep === 1 && this.isJ2sFormInvalid) {
|
|
121
155
|
return "custom"; // override for disabled button styling
|
|
122
156
|
}
|
|
123
|
-
return this.
|
|
124
|
-
.variant;
|
|
157
|
+
return this.primaryAction.variant;
|
|
125
158
|
}
|
|
126
159
|
|
|
127
160
|
private get primaryActionLinkTarget() {
|
|
128
|
-
return
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
161
|
+
return this.primaryAction.linkTarget || "_blank";
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
private get hasPrimaryAction() {
|
|
165
|
+
// new requirement: don't show primary action on final step if country isn't India
|
|
166
|
+
return this.currentSequenceStep !== 2 || this.confirmedCountry === "IN";
|
|
132
167
|
}
|
|
133
168
|
|
|
134
169
|
private get formIncomingUserInfo() {
|
|
@@ -262,8 +297,9 @@ export default class J2sCardSequence extends LightningElement {
|
|
|
262
297
|
|
|
263
298
|
const j2sFormEl = (this.template.querySelector(
|
|
264
299
|
"dw-j2s-form"
|
|
265
|
-
) as unknown) as J2sForm
|
|
266
|
-
const formData = j2sFormEl
|
|
300
|
+
) as unknown) as J2sForm;
|
|
301
|
+
const formData = j2sFormEl.formDataForDrm;
|
|
302
|
+
|
|
267
303
|
// For some countries, explicit approvals will be present; for others, it is implicitly assumed
|
|
268
304
|
if (typeof formData.Opt_In__c !== "boolean") {
|
|
269
305
|
formData.Opt_In__c = true;
|
|
@@ -290,6 +326,7 @@ export default class J2sCardSequence extends LightningElement {
|
|
|
290
326
|
const resData = await res.json();
|
|
291
327
|
const resOutput = resData.handlePostRequestOutput || resData;
|
|
292
328
|
if (resOutput?.status === "success") {
|
|
329
|
+
this.confirmedCountry = formData.MailingCountry as string;
|
|
293
330
|
this.jumpToStepIndex(2, false);
|
|
294
331
|
this.initialStepIndex = 0; // don't save final step in storage; rather, reset the starting step
|
|
295
332
|
} else {
|
|
@@ -385,20 +422,32 @@ export default class J2sCardSequence extends LightningElement {
|
|
|
385
422
|
secondaryActionMarkupContainers[stepIndex];
|
|
386
423
|
|
|
387
424
|
if (bodyMarkupContainer) {
|
|
388
|
-
let markup =
|
|
425
|
+
let markup =
|
|
426
|
+
typeof bodyHtml === "string"
|
|
427
|
+
? bodyHtml
|
|
428
|
+
: bodyHtml?.[this.confirmedCountry] ||
|
|
429
|
+
bodyHtml?.default;
|
|
430
|
+
|
|
389
431
|
if (stepIndex === 2) {
|
|
390
432
|
// User's email is supposed to show on final step
|
|
391
|
-
markup = `${
|
|
433
|
+
markup = `${markup}${
|
|
392
434
|
!this.formIncomingUserInfo.Email
|
|
393
435
|
? ""
|
|
394
436
|
: `<span class="final-email-address">${this.formIncomingUserInfo.Email}</span>`
|
|
395
437
|
}`;
|
|
396
438
|
}
|
|
439
|
+
|
|
397
440
|
bodyMarkupContainer.innerHTML = markup || "";
|
|
398
441
|
}
|
|
442
|
+
|
|
399
443
|
if (secondaryActionMarkupContainer) {
|
|
400
|
-
|
|
401
|
-
secondaryActionHtml ||
|
|
444
|
+
const secondaryActionInnerHtml =
|
|
445
|
+
!secondaryActionHtml ||
|
|
446
|
+
// ugh, new special exception on step 2 to only show secondary action for IN
|
|
447
|
+
(stepIndex === 2 && this.confirmedCountry !== "IN")
|
|
448
|
+
? ""
|
|
449
|
+
: secondaryActionHtml;
|
|
450
|
+
secondaryActionMarkupContainer.innerHTML = secondaryActionInnerHtml;
|
|
402
451
|
}
|
|
403
452
|
});
|
|
404
453
|
}
|
|
@@ -60,7 +60,7 @@ export default class J2sForm extends LightningElementWithState<J2sFormState> {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
@api
|
|
63
|
-
get formDataForDrm() {
|
|
63
|
+
get formDataForDrm(): Partial<DrmFormData> {
|
|
64
64
|
// We should be able to just get the formData from the form automatically using `new FormData(theForm)`,
|
|
65
65
|
// but our custom form elements don't seem to implement what it is required for that currently. See:
|
|
66
66
|
// https://web.dev/more-capable-form-controls/#defining-a-form-associated-custom-element
|
|
@@ -234,7 +234,7 @@ export default class J2sForm extends LightningElementWithState<J2sFormState> {
|
|
|
234
234
|
};
|
|
235
235
|
|
|
236
236
|
@api
|
|
237
|
-
notifySubmitFailure(formSubmissionFailureState: DrmFormData) {
|
|
237
|
+
notifySubmitFailure(formSubmissionFailureState: Partial<DrmFormData>) {
|
|
238
238
|
this.showSubmitFailureAlert = true;
|
|
239
239
|
// After form submission failure, restore at most the following values to the form:
|
|
240
240
|
const {
|