@salesforcedevs/dw-components 1.3.148-canary.19 → 1.3.148-canary.20

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/dw-components",
3
- "version": "1.3.148-canary.19",
3
+ "version": "1.3.148-canary.20",
4
4
  "description": "Lightning web components for https://developer.salesforce.com",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -40,7 +40,13 @@ dx-step-sequence-step:last-child dx-card-step::part(footer-container) {
40
40
 
41
41
  .body-markup {
42
42
  display: block;
43
- padding-bottom: var(--dx-g-spacing-md);
43
+ }
44
+
45
+ .final-email-address {
46
+ display: block;
47
+ margin-top: 20px;
48
+ line-height: 24px;
49
+ color: var(--dx-g-blue-vibrant-50);
44
50
  }
45
51
 
46
52
  .referral-email-field {
@@ -63,6 +63,7 @@
63
63
  loading={isLoading}
64
64
  onclick={primaryActionHandler}
65
65
  size="large"
66
+ target={primaryActionLinkTarget}
66
67
  variant={primaryActionVariant}
67
68
  >
68
69
  {stepDatum.primaryAction.text}
@@ -29,6 +29,7 @@ export type StepDatum = {
29
29
  iconSprite?: string;
30
30
  iconSymbol?: string;
31
31
  link?: string;
32
+ linkTarget?: string;
32
33
  text: string;
33
34
  variant?: string;
34
35
  };
@@ -78,6 +79,7 @@ export default class J2sCardSequence extends LightningElement {
78
79
 
79
80
  private countries = "[]";
80
81
  private currentSequenceStep = 0;
82
+ private didFormSubmissionFail = false;
81
83
  private recaptchaToken = "";
82
84
  private sessionStorageId = "j2s-card-sequence";
83
85
  private tbidUserInfo: any; // TODO typings?
@@ -107,6 +109,13 @@ export default class J2sCardSequence extends LightningElement {
107
109
  .variant;
108
110
  }
109
111
 
112
+ private get primaryActionLinkTarget() {
113
+ return (
114
+ this.stepsData[this.currentSequenceStep || 0].primaryAction
115
+ .linkTarget || "_blank"
116
+ );
117
+ }
118
+
110
119
  private get formIncomingUserInfo() {
111
120
  if (!this.tbidUserInfo) {
112
121
  return {};
@@ -182,6 +191,14 @@ export default class J2sCardSequence extends LightningElement {
182
191
  this.updateStaticInnerHtml();
183
192
  this._didRenderStaticInnerHtml = true;
184
193
  }
194
+
195
+ if (this.didFormSubmissionFail) {
196
+ const j2sFormEl = (this.template.querySelector(
197
+ "dw-j2s-form"
198
+ ) as unknown) as J2sForm | null;
199
+ j2sFormEl?.notifySubmitFailure();
200
+ this.didFormSubmissionFail = false;
201
+ }
185
202
  }
186
203
 
187
204
  handleFormValidityChange({ detail }: CustomEvent) {
@@ -228,11 +245,10 @@ export default class J2sCardSequence extends LightningElement {
228
245
  evt.preventDefault(); // don't proceed automatically to next step
229
246
  this._isFormSubmitting = true;
230
247
 
231
- const j2sFormEl = (this.template.querySelector(
232
- "dw-j2s-form"
233
- ) as unknown) as J2sForm | null;
234
-
235
248
  try {
249
+ const j2sFormEl = (this.template.querySelector(
250
+ "dw-j2s-form"
251
+ ) as unknown) as J2sForm | null;
236
252
  const formData = j2sFormEl?.formDataForDrm;
237
253
  // For some countries, explicit approvals will be present; for others, it is implicitly assumed
238
254
  if (typeof formData.Opt_In__c !== "boolean") {
@@ -271,8 +287,8 @@ export default class J2sCardSequence extends LightningElement {
271
287
  );
272
288
  }
273
289
  } catch (ex) {
274
- j2sFormEl?.notifySubmitFailure();
275
- console.error(ex); // TODO
290
+ this.didFormSubmissionFail = true;
291
+ console.error(ex);
276
292
  }
277
293
 
278
294
  this._isFormSubmitting = false;
@@ -353,7 +369,16 @@ export default class J2sCardSequence extends LightningElement {
353
369
  secondaryActionMarkupContainers[stepIndex];
354
370
 
355
371
  if (bodyMarkupContainer) {
356
- bodyMarkupContainer.innerHTML = bodyHtml || "";
372
+ let markup = bodyHtml;
373
+ if (stepIndex === 2) {
374
+ // User's email is supposed to show on final step
375
+ markup = `${bodyHtml}${
376
+ !this.formIncomingUserInfo.email
377
+ ? ""
378
+ : `<span class="final-email-address">${this.formIncomingUserInfo.email}</span>`
379
+ }`;
380
+ }
381
+ bodyMarkupContainer.innerHTML = markup || "";
357
382
  }
358
383
  if (secondaryActionMarkupContainer) {
359
384
  secondaryActionMarkupContainer.innerHTML =
@@ -83,8 +83,10 @@ export default class J2sForm extends LightningElementWithState<J2sFormState> {
83
83
  }
84
84
  set recaptchaToken(value: string) {
85
85
  this._recaptchaToken = value;
86
- // Treat recaptcha checkbox as a required form field even though not technically marked as such:
87
- this.handleFormFieldChange({ target: { required: true } } as any);
86
+ if (!this._isInitialRender) {
87
+ // Treat recaptcha checkbox as a required form field even though not technically marked as such:
88
+ this.handleFormFieldChange({ target: { required: true } } as any);
89
+ }
88
90
  }
89
91
 
90
92
  private participatingCountryCodes = ["US", "CA", "IN"];
@@ -141,6 +143,7 @@ export default class J2sForm extends LightningElementWithState<J2sFormState> {
141
143
  renderedCallback(): void {
142
144
  if (this._isInitialRender) {
143
145
  this.updateInnerHtml("span.j2s-terms", this.formMetadata.j2sTerms);
146
+ this._isInitialRender = false;
144
147
  }
145
148
 
146
149
  if (
@@ -271,7 +274,7 @@ export default class J2sForm extends LightningElementWithState<J2sFormState> {
271
274
 
272
275
  private checkValidity() {
273
276
  return (
274
- Boolean(this.recaptchaToken) &&
277
+ // Boolean(this.recaptchaToken) &&
275
278
  this.isParticipatingCountry(this.state.country) &&
276
279
  this.requiredFormFields.every(
277
280
  (requiredFormField) =>