@salesforcedevs/dw-components 1.3.148-canary.12 → 1.3.148-canary.14
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
|
@@ -36,18 +36,13 @@ export type StepDatum = {
|
|
|
36
36
|
stepTitle: string;
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
function isNoAnimationCookieSet() {
|
|
40
|
-
return document.cookie
|
|
41
|
-
.split(";")
|
|
42
|
-
.some((ck) => ck.trim() === "no_j2s_animation=true");
|
|
43
|
-
}
|
|
44
|
-
|
|
45
39
|
export default class J2sCardSequence extends LightningElement {
|
|
46
40
|
_didRenderStaticInnerHtml = false;
|
|
47
41
|
_isDrmLoading = false;
|
|
48
42
|
_isFormSubmitting = false;
|
|
49
43
|
_isJ2sFormInvalid = false;
|
|
50
44
|
_isTbidLoading = false;
|
|
45
|
+
_recaptchaResetTimeoutId: number | null = null;
|
|
51
46
|
_stepsData: StepDatum[] = [];
|
|
52
47
|
@api animateTransitions = false;
|
|
53
48
|
@api drmDomain: string = "https://drm.my.salesforce-sites.com";
|
|
@@ -161,11 +156,13 @@ export default class J2sCardSequence extends LightningElement {
|
|
|
161
156
|
@api
|
|
162
157
|
recaptchaCallback(responseToken: string) {
|
|
163
158
|
this.recaptchaToken = responseToken;
|
|
159
|
+
clearTimeout(this._recaptchaResetTimeoutId as number);
|
|
164
160
|
}
|
|
165
161
|
|
|
166
162
|
@api
|
|
167
163
|
recaptchaExpiredCallback() {
|
|
168
164
|
this.recaptchaToken = "";
|
|
165
|
+
clearTimeout(this._recaptchaResetTimeoutId as number);
|
|
169
166
|
}
|
|
170
167
|
|
|
171
168
|
connectedCallback() {
|
|
@@ -174,13 +171,14 @@ export default class J2sCardSequence extends LightningElement {
|
|
|
174
171
|
// This has to be defined here since it depends on a variable that depends on sessionStorage.
|
|
175
172
|
this.currentSequenceStep = this.initialStepIndex;
|
|
176
173
|
this.resetCustomButtonColors();
|
|
177
|
-
if (isNoAnimationCookieSet()) {
|
|
178
|
-
/* eslint-disable-next-line @lwc/lwc/no-api-reassignments */
|
|
179
|
-
this.animateTransitions = false;
|
|
180
|
-
}
|
|
181
174
|
}
|
|
182
175
|
|
|
183
176
|
renderedCallback() {
|
|
177
|
+
if (this.isLoading) {
|
|
178
|
+
this._didRenderStaticInnerHtml = false; // only when `this.isLoading` is true will static HTML need to be re-rendered, since the content will have been replaced by the spinner
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
|
|
184
182
|
if (!this._didRenderStaticInnerHtml) {
|
|
185
183
|
this.updateStaticInnerHtml();
|
|
186
184
|
this._didRenderStaticInnerHtml = true;
|
|
@@ -194,6 +192,21 @@ export default class J2sCardSequence extends LightningElement {
|
|
|
194
192
|
handleStepSequenceChange({ detail }: CustomEvent) {
|
|
195
193
|
this.currentSequenceStep = detail.stepIndex;
|
|
196
194
|
this.resetCustomButtonColors();
|
|
195
|
+
|
|
196
|
+
if (
|
|
197
|
+
this.currentSequenceStep !== 1 &&
|
|
198
|
+
this.recaptchaToken &&
|
|
199
|
+
this._recaptchaResetTimeoutId === null
|
|
200
|
+
) {
|
|
201
|
+
// If the recaptcha element expires on its own while you are not on the 2nd (form) step, it messes with the
|
|
202
|
+
// page's layout (basically breaks it). So, we need to reset it _before_ expiration if you leave that step.
|
|
203
|
+
// We do it with a timeout so that the token is not immediately wiped if the user goes back and forth a bit.
|
|
204
|
+
this._recaptchaResetTimeoutId = window.setTimeout(() => {
|
|
205
|
+
this._recaptchaResetTimeoutId = null;
|
|
206
|
+
this.recaptchaToken = "";
|
|
207
|
+
(window as any).grecaptcha.reset();
|
|
208
|
+
}, 1000 * 30 /* 30 seconds */);
|
|
209
|
+
}
|
|
197
210
|
}
|
|
198
211
|
|
|
199
212
|
handleGetStarted(evt: Event) {
|
|
@@ -204,8 +217,7 @@ export default class J2sCardSequence extends LightningElement {
|
|
|
204
217
|
evt.preventDefault();
|
|
205
218
|
this.initialStepIndex = 1;
|
|
206
219
|
this._isTbidLoading = true;
|
|
207
|
-
//
|
|
208
|
-
window.__startTbidLogin();
|
|
220
|
+
(window as any).__startTbidLogin?.(); // call out to DSC tbid controller
|
|
209
221
|
}
|
|
210
222
|
}
|
|
211
223
|
|
|
@@ -244,7 +256,8 @@ export default class J2sCardSequence extends LightningElement {
|
|
|
244
256
|
const resData = await res.json();
|
|
245
257
|
const resOutput = resData.handlePostRequestOutput || resData;
|
|
246
258
|
if (resOutput?.status === "success") {
|
|
247
|
-
this.jumpToStepIndex(2);
|
|
259
|
+
this.jumpToStepIndex(2, false);
|
|
260
|
+
this.initialStepIndex = 0; // don't save final step in storage; rather, reset the starting step
|
|
248
261
|
} else {
|
|
249
262
|
throw new Error(
|
|
250
263
|
`Form submission failed. (status: ${resOutput.status}, message: ${resOutput.errorMessage})`
|
|
@@ -309,14 +322,15 @@ export default class J2sCardSequence extends LightningElement {
|
|
|
309
322
|
);
|
|
310
323
|
}
|
|
311
324
|
|
|
312
|
-
private jumpToStepIndex(stepIndex: number) {
|
|
313
|
-
|
|
325
|
+
private jumpToStepIndex(stepIndex: number, andStoreIndex = true) {
|
|
326
|
+
if (andStoreIndex) {
|
|
327
|
+
this.initialStepIndex = stepIndex; // update sessionStorage value
|
|
328
|
+
}
|
|
314
329
|
((this.template.querySelector(
|
|
315
330
|
"dx-step-sequence"
|
|
316
331
|
) as unknown) as StepSequence)?.jumpToStep(stepIndex);
|
|
317
332
|
}
|
|
318
333
|
|
|
319
|
-
// HTML is received via config from DSC and should be static after initial render.
|
|
320
334
|
private updateStaticInnerHtml() {
|
|
321
335
|
const bodyMarkupContainers = this.template.querySelectorAll(
|
|
322
336
|
"span.body-markup"
|