@salesforcedevs/dw-components 0.0.0 → 0.0.1

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.
Files changed (75) hide show
  1. package/lwc.config.json +10 -1
  2. package/package.json +8 -4
  3. package/src/modules/dw/blogsGrid/blogsGrid.css +10 -7
  4. package/src/modules/dw/blogsGrid/blogsGrid.html +15 -12
  5. package/src/modules/dw/blogsGrid/blogsGrid.ts +23 -9
  6. package/src/modules/dw/browseTrials/browseTrials.css +35 -0
  7. package/src/modules/dw/browseTrials/browseTrials.html +86 -0
  8. package/src/modules/dw/browseTrials/browseTrials.ts +116 -0
  9. package/src/modules/dw/cardBlogPostProvider/cardBlogPostProvider.css +2 -0
  10. package/src/modules/dw/cardBlogPostProvider/cardBlogPostProvider.html +3 -3
  11. package/src/modules/dw/cardPodcastEpisodeProvider/cardPodcastEpisodeProvider.css +2 -0
  12. package/src/modules/dw/cardPodcastEpisodeProvider/cardPodcastEpisodeProvider.html +2 -1
  13. package/src/modules/dw/codeSamplesGrid/codeSamplesGrid.css +6 -8
  14. package/src/modules/dw/codeSamplesGrid/codeSamplesGrid.html +11 -7
  15. package/src/modules/dw/codeSamplesGrid/codeSamplesGrid.ts +71 -40
  16. package/src/modules/dw/contentArchive/contentArchive.css +5 -4
  17. package/src/modules/dw/contentArchive/contentArchive.html +58 -24
  18. package/src/modules/dw/contentArchive/contentArchive.ts +46 -8
  19. package/src/modules/dw/contentArchive/contentArchive.types.ts +8 -4
  20. package/src/modules/dw/contentArchive/utils.ts +30 -14
  21. package/src/modules/dw/deSignupForm/deSignupForm.css +11 -10
  22. package/src/modules/dw/deSignupForm/deSignupForm.html +39 -25
  23. package/src/modules/dw/deSignupForm/deSignupForm.ts +200 -133
  24. package/src/modules/dw/deSignupForm/submitForm.ts +7 -3
  25. package/src/modules/dw/docsGrid/docsGrid.css +0 -1
  26. package/src/modules/dw/docsGrid/docsGrid.html +6 -2
  27. package/src/modules/dw/docsGrid/docsGrid.ts +103 -38
  28. package/src/modules/dw/eventsList/eventsList.css +4 -4
  29. package/src/modules/dw/eventsList/eventsList.html +5 -5
  30. package/src/modules/dw/eventsList/eventsList.ts +47 -48
  31. package/src/modules/dw/j2sCardSequence/j2sCardSequence.css +14 -0
  32. package/src/modules/dw/j2sCardSequence/j2sCardSequence.html +41 -0
  33. package/src/modules/dw/j2sCardSequence/j2sCardSequence.ts +487 -0
  34. package/src/modules/dw/j2sCardSequenceStep/j2sCardSequenceStep.css +76 -0
  35. package/src/modules/dw/j2sCardSequenceStep/j2sCardSequenceStep.html +64 -0
  36. package/src/modules/dw/j2sCardSequenceStep/j2sCardSequenceStep.ts +157 -0
  37. package/src/modules/dw/j2sForm/j2sForm.css +65 -0
  38. package/src/modules/dw/j2sForm/j2sForm.html +217 -0
  39. package/src/modules/dw/j2sForm/j2sForm.ts +371 -0
  40. package/src/modules/dw/j2sForm/mockProps.ts +3102 -0
  41. package/src/modules/dw/languageSelector/languageSelector.html +11 -0
  42. package/src/modules/dw/languageSelector/languageSelector.ts +106 -0
  43. package/src/modules/dw/newsletterForm/newsletterForm.css +2 -2
  44. package/src/modules/dw/newsletterForm/newsletterForm.html +35 -10
  45. package/src/modules/dw/newsletterForm/newsletterForm.ts +107 -78
  46. package/src/modules/dw/podcastSubscription/podcastSubscription.css +6 -7
  47. package/src/modules/dw/podcastSubscription/podcastSubscription.html +2 -2
  48. package/src/modules/dw/podcastSubscription/podcastSubscription.ts +4 -4
  49. package/src/modules/dw/podcastsGrid/podcastsGrid.css +7 -0
  50. package/src/modules/dw/podcastsGrid/podcastsGrid.html +6 -1
  51. package/src/modules/dw/podcastsGrid/podcastsGrid.ts +3 -3
  52. package/src/modules/dw/podcastsPromo/podcastsPromo.css +14 -0
  53. package/src/modules/dw/podcastsPromo/podcastsPromo.html +16 -8
  54. package/src/modules/dw/podcastsPromo/podcastsPromo.ts +11 -2
  55. package/src/modules/dw/rcgTable/altData.ts +72 -9
  56. package/src/modules/dw/rcgTable/getTableData.ts +1 -1
  57. package/src/modules/dw/rcgTable/rcgTable.ts +3 -3
  58. package/src/modules/dw/slackCta/slackCta.css +5 -6
  59. package/src/modules/dw/slackCta/slackCta.html +1 -1
  60. package/src/modules/dw/slackSuccess/slackSuccess.css +1 -1
  61. package/src/modules/dw/slackSuccess/slackSuccess.html +2 -2
  62. package/src/modules/dw/tbidLoginMenu/tbidLoginMenu.css +119 -0
  63. package/src/modules/dw/tbidLoginMenu/tbidLoginMenu.html +192 -0
  64. package/src/modules/dw/tbidLoginMenu/tbidLoginMenu.ts +148 -0
  65. package/src/modules/dw/videoGrid/types.ts +12 -0
  66. package/src/modules/dw/videoGrid/videoGrid.css +24 -0
  67. package/src/modules/dw/videoGrid/videoGrid.html +41 -0
  68. package/src/modules/dw/videoGrid/videoGrid.ts +41 -0
  69. package/src/modules/dw/youtubeVideoGrid/types.ts +8 -0
  70. package/src/modules/dw/youtubeVideoGrid/youtubeVideoGrid.css +14 -0
  71. package/src/modules/dw/youtubeVideoGrid/youtubeVideoGrid.html +24 -0
  72. package/src/modules/dw/youtubeVideoGrid/youtubeVideoGrid.ts +66 -0
  73. package/src/modules/dwHelpers/mobileDividers/mobileDividers.css +19 -0
  74. package/src/modules/dwUtils/forms/forms.ts +514 -0
  75. package/src/modules/{dwBaseElements → dwUtils}/postsGrid/postsGrid.ts +10 -13
@@ -0,0 +1,14 @@
1
+ @import "dxHelpers/reset";
2
+
3
+ :host {
4
+ --dx-c-button-custom-color: var(--dx-g-blue-vibrant-50);
5
+ --dx-c-button-custom-background: white;
6
+ --dx-c-button-custom-border: var(--dx-g-blue-vibrant-50);
7
+ --dx-c-button-custom-color-hover: var(--dx-g-blue-vibrant-50);
8
+ --dx-c-button-custom-background-hover: var(--dx-g-cloud-blue-vibrant-90);
9
+ --dx-c-button-custom-border-hover: var(--dx-g-cloud-blue-vibrant-50);
10
+ }
11
+
12
+ dx-step-sequence {
13
+ scroll-margin-top: var(--dx-g-global-header-height);
14
+ }
@@ -0,0 +1,41 @@
1
+ <template>
2
+ <dx-step-sequence
3
+ animate-transitions="true"
4
+ communicate-step-changes="true"
5
+ container-scroll-to-id={containerScrollToId}
6
+ force-initially-visible={forceInitiallyVisible}
7
+ initial-step-index={initialStepIndex}
8
+ lwc:ref="stepSequence"
9
+ onslotchange={handleStepSequenceSlotChange}
10
+ onstepsequencechange={handleStepSequenceChange}
11
+ optimize-position-after-animation="true"
12
+ session-storage-id={sessionStorageId}
13
+ use-history={useHistory}
14
+ >
15
+ <template for:each={stepsData} for:item="stepDatum" for:index="index">
16
+ <dx-step-sequence-step key={stepDatum.id}>
17
+ <dw-j2s-card-sequence-step
18
+ country-options={countries}
19
+ has-already-registered={hasAlreadyRegistered}
20
+ is-loading={isLoading}
21
+ oncountrychange={handleCountryChange}
22
+ onformsubmit={handleFormSubmit}
23
+ ongetstarted={handleGetStarted}
24
+ recaptcha-token={recaptchaToken}
25
+ selected-country={selectedCountry}
26
+ step-datum={stepDatum}
27
+ step-index={index}
28
+ step-total-count={stepsData.length}
29
+ user-info={formIncomingUserInfo}
30
+ >
31
+ <div
32
+ if:true={stepDatum.formData}
33
+ slot="card-step-captcha-slot"
34
+ >
35
+ <slot name="captcha-slot"></slot>
36
+ </div>
37
+ </dw-j2s-card-sequence-step>
38
+ </dx-step-sequence-step>
39
+ </template>
40
+ </dx-step-sequence>
41
+ </template>
@@ -0,0 +1,487 @@
1
+ import { api, LightningElement } from "lwc";
2
+ import StepSequence from "dx/stepSequence";
3
+ import { getListWithUuids } from "dxUtils/list";
4
+ import { toJson } from "dxUtils/normalizers";
5
+ import J2sCardSequenceStep from "dw/j2sCardSequenceStep";
6
+ import { AlertInfo } from "typings/custom";
7
+
8
+ const DRM_SUCCESS_STRING = "success";
9
+
10
+ export type StepDatum = {
11
+ bodyHtml?:
12
+ | string
13
+ | {
14
+ default: string;
15
+ [countryCode: string]: string;
16
+ };
17
+ formData?: {
18
+ countriesWithReferralInput?: string[];
19
+ formId?: string;
20
+ j2sTerms?: string;
21
+ notAvailableAlertInfo?: {
22
+ default: AlertInfo;
23
+ [key: string]: AlertInfo;
24
+ };
25
+ participatingCountryCodes?: string[];
26
+ salesforceEmployeeAlertInfo?: {
27
+ title: string;
28
+ body: string;
29
+ };
30
+ };
31
+ headerData?: {
32
+ backgroundColor?: string;
33
+ iconColor?: string;
34
+ iconSprite?: string;
35
+ iconSymbol?: string;
36
+ textColor?: string;
37
+ };
38
+ primaryAction: {
39
+ iconSprite?: string;
40
+ iconSymbol?: string;
41
+ link?:
42
+ | string
43
+ | {
44
+ default: string;
45
+ [countryCode: string]: string;
46
+ };
47
+ linkTarget?: string;
48
+ text:
49
+ | string
50
+ | {
51
+ default: string;
52
+ [countryCode: string]: string;
53
+ };
54
+ variant?: string;
55
+ };
56
+ secondaryActionHtml?: string;
57
+ showStepNumber?: boolean;
58
+ stepTitle: string;
59
+ };
60
+
61
+ // Field names expected by DRM; see: https://salesforce.quip.com/daInAFETbPGm
62
+ export type DrmFormData = {
63
+ Email: string;
64
+ FirstName: string;
65
+ LastName: string;
66
+ MailingCountry: string;
67
+ MailingState?: string;
68
+ Company__c: string;
69
+ DRM_Role__c: string;
70
+ TBID__c: string;
71
+ Opt_In__c?: boolean;
72
+ Privacy_Statement__c?: boolean;
73
+ j2s_terms?: boolean;
74
+ Referral_Email__c?: string;
75
+ RelationshipToSalesforce: string;
76
+ };
77
+
78
+ export default class J2sCardSequence extends LightningElement {
79
+ _isDrmLoading = false;
80
+ _isFormSubmitting = false;
81
+ _isTbidLoading = false;
82
+ _recaptchaResetTimeoutId: number | null = null;
83
+ _stepsData: StepDatum[] = [];
84
+ @api containerScrollToId = "";
85
+ @api drmDomain: string = "https://drm.my.salesforce-sites.com";
86
+ @api drmHandlerBaseUrl: string =
87
+ "https://dev1-infta-proxy.us-w2.cloudhub.io";
88
+ @api tbidApiBaseUrl: string | undefined;
89
+ @api useHistory: boolean = false;
90
+
91
+ @api
92
+ get stepsData() {
93
+ return this._stepsData;
94
+ }
95
+ set stepsData(value) {
96
+ // normalize incoming value with uuid keys and non-required props (for cleaner HTML template), etc.
97
+ const valueWithUuids = getListWithUuids<StepDatum>(toJson(value));
98
+ this._stepsData = valueWithUuids.map((stepDatum) => {
99
+ const normalizedStepDatum = {
100
+ ...stepDatum,
101
+ headerData: stepDatum.headerData || {},
102
+ primaryAction: {
103
+ ...stepDatum.primaryAction,
104
+ variant: stepDatum.primaryAction.variant || "primary",
105
+ iconSprite: stepDatum.primaryAction.iconSprite || "general",
106
+ iconSymbol:
107
+ stepDatum.primaryAction.iconSymbol || "arrow-right"
108
+ }
109
+ };
110
+
111
+ return normalizedStepDatum;
112
+ });
113
+ }
114
+
115
+ private countries: any[] = [];
116
+ private currentSequenceStep = 0;
117
+ private hasAlreadyRegistered = false;
118
+ private forceInitiallyVisible = false;
119
+ private formSubmissionFailureState: Partial<DrmFormData> | null = null;
120
+ private recaptchaToken = "";
121
+ private selectedCountry = "";
122
+ private sessionStorageId = "j2s-card-sequence";
123
+ private tbidUserInfo: any; // TODO typings?
124
+
125
+ private get isLoading() {
126
+ return (
127
+ this._isDrmLoading || this._isTbidLoading || this._isFormSubmitting
128
+ );
129
+ }
130
+
131
+ private get isLoggedIn() {
132
+ return Boolean(this.tbidUserInfo);
133
+ }
134
+
135
+ private get drmEmailUrl() {
136
+ return `${this.drmHandlerBaseUrl}/getEmail`;
137
+ }
138
+
139
+ private get formHandlerUrl() {
140
+ return `${this.drmHandlerBaseUrl}/form_handler`;
141
+ }
142
+
143
+ private get formIncomingUserInfo() {
144
+ if (!this.tbidUserInfo) {
145
+ return {} as DrmFormData;
146
+ }
147
+
148
+ const tbidData = {
149
+ FirstName: this.tbidUserInfo.given_name,
150
+ LastName: this.tbidUserInfo.family_name,
151
+ Email: this.tbidUserInfo.email,
152
+ DRM_Role__c: this.tbidUserInfo.custom_attributes?.Role,
153
+ Company__c: this.tbidUserInfo.custom_attributes?.CompanyName,
154
+ MailingCountry: this.tbidUserInfo.custom_attributes?.Country,
155
+ MailingState: this.tbidUserInfo.address?.region,
156
+ RelationshipToSalesforce:
157
+ this.tbidUserInfo.custom_attributes?.RelationshipToSalesforce
158
+ };
159
+
160
+ // Return above object but only with keys that have a truthy value, and with any URI-encoded values decoded
161
+ return Object.keys(tbidData)
162
+ .filter((key) => Boolean(tbidData[key as keyof typeof tbidData]))
163
+ .reduce(
164
+ (data, keyWithDefinedValue) => ({
165
+ ...data,
166
+ [keyWithDefinedValue]: decodeURIComponent(
167
+ tbidData[keyWithDefinedValue as keyof typeof tbidData]
168
+ )
169
+ }),
170
+ {}
171
+ ) as DrmFormData;
172
+ }
173
+
174
+ private get initialStepIndex() {
175
+ let initialStepIndex = 0;
176
+
177
+ const storedSessionData = sessionStorage.getItem(this.sessionStorageId);
178
+ if (storedSessionData) {
179
+ try {
180
+ const { currentStepIndex } = JSON.parse(storedSessionData);
181
+ initialStepIndex = currentStepIndex;
182
+ } catch (ex) {
183
+ // noop
184
+ }
185
+ }
186
+
187
+ return initialStepIndex;
188
+ }
189
+ private set initialStepIndex(value: number) {
190
+ sessionStorage.setItem(
191
+ this.sessionStorageId,
192
+ JSON.stringify({
193
+ currentStepIndex: value
194
+ })
195
+ );
196
+ }
197
+
198
+ @api
199
+ recaptchaCallback(responseToken: string) {
200
+ this.recaptchaToken = responseToken;
201
+ clearTimeout(this._recaptchaResetTimeoutId as number);
202
+ }
203
+
204
+ @api
205
+ recaptchaExpiredCallback() {
206
+ this.recaptchaToken = "";
207
+ clearTimeout(this._recaptchaResetTimeoutId as number);
208
+ }
209
+
210
+ connectedCallback() {
211
+ this.getCountryList();
212
+ this.getTbidUserInfo();
213
+ // This has to be defined here since it depends on a variable that depends on sessionStorage.
214
+ this.currentSequenceStep = this.initialStepIndex;
215
+ this.resetCustomButtonColors();
216
+
217
+ try {
218
+ const isLoggingIn = sessionStorage.getItem(
219
+ `${this.sessionStorageId}__isLoginRedirect`
220
+ );
221
+ if (isLoggingIn) {
222
+ this.forceInitiallyVisible = true;
223
+ sessionStorage.removeItem(
224
+ `${this.sessionStorageId}__isLoginRedirect`
225
+ );
226
+ }
227
+ } catch (ex) {
228
+ // noop
229
+ }
230
+ }
231
+
232
+ renderedCallback() {
233
+ if (!this.isLoading) {
234
+ (this.refs.stepSequence as StepSequence)?.remeasureSteps();
235
+ }
236
+
237
+ if (
238
+ this.formSubmissionFailureState &&
239
+ this.stepsData[this.currentSequenceStep].formData
240
+ ) {
241
+ const j2sCardStep = this.template.querySelectorAll(
242
+ "dw-j2s-card-sequence-step"
243
+ ) as unknown as J2sCardSequenceStep[];
244
+ j2sCardStep[this.currentSequenceStep]?.notifyFormSubmitFailure(
245
+ this.formSubmissionFailureState
246
+ );
247
+ this.formSubmissionFailureState = null;
248
+ }
249
+ }
250
+
251
+ handleCountryChange({ detail }: CustomEvent) {
252
+ this.selectedCountry = detail;
253
+ }
254
+
255
+ handleStepSequenceChange({ detail }: CustomEvent) {
256
+ if (detail.stepIndex === 1 && this.currentSequenceStep === 2) {
257
+ // User is going back after submitting the form; ensure that `selectedCountry` is reset, since this impacts form behavior
258
+ this.selectedCountry =
259
+ this.formIncomingUserInfo.MailingCountry || "";
260
+ }
261
+
262
+ this.currentSequenceStep = detail.stepIndex;
263
+ this.resetCustomButtonColors();
264
+
265
+ if (
266
+ this.currentSequenceStep !== 1 &&
267
+ this.recaptchaToken &&
268
+ this._recaptchaResetTimeoutId === null
269
+ ) {
270
+ // If the recaptcha element expires on its own while you are not on the 2nd (form) step, it messes with the
271
+ // page's layout (basically breaks it). So, we need to reset it _before_ expiration if you leave that step.
272
+ // We do it with a timeout so that the token is not immediately wiped if the user goes back and forth a bit.
273
+ this._recaptchaResetTimeoutId = window.setTimeout(
274
+ () => this.resetRecaptcha(),
275
+ 1000 * 30 /* 30 seconds */
276
+ );
277
+ }
278
+ }
279
+
280
+ handleStepSequenceSlotChange() {
281
+ requestAnimationFrame(() => {
282
+ // After the slots have slotted and there's been time to animate, we know the browser's layout of the
283
+ // sequence has completed.
284
+ this.dispatchEvent(
285
+ new CustomEvent("j2ssequencelaidout", {
286
+ bubbles: true,
287
+ composed: true
288
+ })
289
+ );
290
+ });
291
+ }
292
+
293
+ handleGetStarted() {
294
+ // If the user is not yet logged in, we need to prevent moving immediately to the next
295
+ // step, but set storage up so that they are on the second step when they return to the
296
+ // site in a logged-in state; then, we need to get them to log in.
297
+ if (!this.isLoggedIn) {
298
+ this.initialStepIndex = 1;
299
+ this._isTbidLoading = true;
300
+ sessionStorage.setItem(
301
+ `${this.sessionStorageId}__isLoginRedirect`,
302
+ "1" /* value doesn't matter */
303
+ );
304
+ (window as any).__startTbidLogin?.(); // call out to DSC tbid controller
305
+ } else {
306
+ this.jumpToStepIndex(1);
307
+ }
308
+ }
309
+
310
+ async handleFormSubmit({ detail: formData }: CustomEvent<DrmFormData>) {
311
+ if (!this.formHandlerUrl || !this.isLoggedIn) {
312
+ return;
313
+ }
314
+
315
+ this._isFormSubmitting = true;
316
+
317
+ try {
318
+ const res = await fetch(this.formHandlerUrl, {
319
+ method: "POST",
320
+ headers: {
321
+ "Content-Type": "application/json",
322
+ "Captcha-Response": this.recaptchaToken
323
+ },
324
+ body: JSON.stringify({
325
+ ...formData,
326
+ handlerName: "J2S Registration Page",
327
+ TBID__c: this.tbidUserInfo.user_id
328
+ })
329
+ });
330
+
331
+ if (res.ok) {
332
+ const resData = await res.json();
333
+ const resOutput = resData.handlePostRequestOutput || resData;
334
+ if (resOutput?.status === DRM_SUCCESS_STRING) {
335
+ this.dispatchEvent(
336
+ new CustomEvent("registration", {
337
+ bubbles: true,
338
+ composed: true
339
+ })
340
+ );
341
+ this.jumpToStepIndex(2, false);
342
+ this.initialStepIndex = 0; // don't save final step in storage; rather, reset the starting step
343
+ this.resetRecaptcha();
344
+ this.hasAlreadyRegistered = true;
345
+ } else {
346
+ throw new Error(
347
+ `Form submission failed. (status: ${resOutput.status}, message: ${resOutput.errorMessage})`
348
+ );
349
+ }
350
+ } else {
351
+ throw new Error(
352
+ `Form submission failed. Non-ok response received from DRM.`
353
+ );
354
+ }
355
+ } catch (ex) {
356
+ this.formSubmissionFailureState = formData;
357
+ console.error(ex);
358
+ }
359
+
360
+ this._isFormSubmitting = false;
361
+ }
362
+
363
+ private resetCustomButtonColors() {
364
+ let bgColor;
365
+ let textColor;
366
+
367
+ if (this.currentSequenceStep === 1) {
368
+ bgColor = "var(--dx-g-gray-80)";
369
+ textColor = "white";
370
+ } else {
371
+ bgColor = "white";
372
+ textColor = "var(--dx-g-blue-vibrant-50)";
373
+ }
374
+
375
+ this.template.host.style.setProperty(
376
+ "--dx-c-button-custom-color",
377
+ textColor
378
+ );
379
+ this.template.host.style.setProperty(
380
+ "--dx-c-button-custom-background",
381
+ bgColor
382
+ );
383
+ this.template.host.style.setProperty(
384
+ "--dx-c-button-custom-border",
385
+ bgColor
386
+ );
387
+ }
388
+
389
+ private resetRecaptcha() {
390
+ clearTimeout(this._recaptchaResetTimeoutId as number);
391
+ this._recaptchaResetTimeoutId = null;
392
+ this.recaptchaToken = "";
393
+ (window as any).grecaptcha.reset();
394
+ }
395
+
396
+ private jumpToStepIndex(stepIndex: number, andStoreIndex = true) {
397
+ if (andStoreIndex) {
398
+ this.initialStepIndex = stepIndex; // update sessionStorage value
399
+ }
400
+ (this.refs.stepSequence as StepSequence)?.jumpToStep(stepIndex);
401
+ }
402
+
403
+ private async getCountryList() {
404
+ this._isDrmLoading = true;
405
+
406
+ const errorMsg = "Error while getting country list";
407
+ try {
408
+ const res = await fetch(
409
+ `${this.drmDomain}/utilities/services/apexrest/countries`
410
+ );
411
+ if (!res.ok) {
412
+ throw new Error(errorMsg);
413
+ }
414
+ this.countries = await res.json();
415
+ } catch (error) {
416
+ console.error(error);
417
+ if (this.initialStepIndex > 0) {
418
+ // Page loaded on a step higher than the first, but we can't get data for the form;
419
+ // send user back to the start for now.
420
+ this.jumpToStepIndex(0);
421
+ }
422
+ }
423
+
424
+ this._isDrmLoading = false;
425
+ }
426
+
427
+ private async getTbidUserInfo() {
428
+ this._isTbidLoading = true;
429
+
430
+ try {
431
+ const res = await fetch(`${this.tbidApiBaseUrl}/userinfo`);
432
+ if (res.ok) {
433
+ const userInfo = await res.json();
434
+ if (userInfo.dsc_auth_error) {
435
+ // API breaks HTTP semantics to avoid logging 4xx errors (due to Lighthouse score)
436
+ throw new Error("Unauthorized");
437
+ }
438
+ const emailOverride = await this.getDrmEmailOverride(
439
+ userInfo?.user_id
440
+ );
441
+ this.tbidUserInfo = !emailOverride
442
+ ? userInfo
443
+ : {
444
+ ...userInfo,
445
+ email: emailOverride
446
+ };
447
+ this.selectedCountry = this.formIncomingUserInfo.MailingCountry;
448
+ }
449
+ } catch (ex) {
450
+ // noop; nothing to do here
451
+ }
452
+
453
+ if (!this.tbidUserInfo && this.initialStepIndex > 0) {
454
+ // login failed and the user was previously beyond the start step; need to send them
455
+ // back to the start:
456
+ this.jumpToStepIndex(0);
457
+ }
458
+
459
+ this._isTbidLoading = false;
460
+ }
461
+
462
+ private async getDrmEmailOverride(
463
+ tbid: string
464
+ ): Promise<string | undefined> {
465
+ let resolvedEmail = "";
466
+
467
+ if (!tbid) {
468
+ return resolvedEmail;
469
+ }
470
+
471
+ try {
472
+ const res = await fetch(`${this.drmEmailUrl}?tbid=${tbid}`);
473
+ if (res.ok) {
474
+ const resData = await res.json();
475
+ if (resData.message === DRM_SUCCESS_STRING) {
476
+ resolvedEmail = resData.Email;
477
+ }
478
+ }
479
+ } catch (ex) {
480
+ console.warn(
481
+ `Could not fetch email address from DRM, defaulting to TBID info. (Exception: ${ex})`
482
+ );
483
+ }
484
+
485
+ return resolvedEmail;
486
+ }
487
+ }
@@ -0,0 +1,76 @@
1
+ @import "dxHelpers/reset";
2
+ @import "dxHelpers/text";
3
+ @import "dxHelpers/card";
4
+
5
+ /* Special styling for the final step's actions if they are shown */
6
+ dx-card-step.final-card-with-action::part(footer-container) {
7
+ background-color: var(--dx-g-indigo-vibrant-95);
8
+ border-radius: 8px;
9
+ margin: 0 30px 30px;
10
+ }
11
+
12
+ [slot="secondary-action-section"] {
13
+ color: var(--dx-g-red-vibrant-50);
14
+ position: relative;
15
+ font-size: var(--dx-g-text-xs, 12px);
16
+ font-family: var(--dx-g-font-sans);
17
+ line-height: 18px;
18
+ text-align: left;
19
+ }
20
+
21
+ .body-container li {
22
+ line-height: var(--dx-g-text-2xl);
23
+ }
24
+
25
+ .body-container p:not(:last-child),
26
+ .body-container p:only-child {
27
+ padding-bottom: 20px;
28
+ }
29
+
30
+ .body-markup {
31
+ display: block;
32
+ }
33
+
34
+ .final-email-address {
35
+ display: block;
36
+ margin-top: 20px;
37
+ line-height: 24px;
38
+ color: var(--dx-g-blue-vibrant-50);
39
+ }
40
+
41
+ .full-width-input-field {
42
+ --dx-c-input-width: 100%;
43
+ }
44
+
45
+ .spinner-container {
46
+ min-height: 200px;
47
+ position: relative;
48
+ }
49
+
50
+ @media screen and (max-width: 480px) {
51
+ .body-container li {
52
+ line-height: var(--dx-g-text-xl);
53
+ padding-bottom: 20px;
54
+ }
55
+
56
+ .body-container p[class] {
57
+ font-size: var(--dx-g-text-md);
58
+ line-height: 24px;
59
+ }
60
+
61
+ .final-email-address {
62
+ font-size: var(--dx-g-text-sm);
63
+ }
64
+
65
+ [slot="secondary-action-section"] {
66
+ text-align: center;
67
+ padding-bottom: 20px;
68
+ }
69
+ }
70
+
71
+ @media screen and (max-width: 320px) {
72
+ /* Special styling for the final step's actions if they are shown */
73
+ dx-card-step.final-card-with-action::part(footer-container) {
74
+ margin: 0 20px 30px;
75
+ }
76
+ }
@@ -0,0 +1,64 @@
1
+ <template>
2
+ <dx-card-step
3
+ class={stepClassName}
4
+ header-icon-symbol={stepDatum.headerData.iconSymbol}
5
+ header-icon-sprite={stepDatum.headerData.iconSprite}
6
+ header-icon-color={stepDatum.headerData.iconColor}
7
+ header-background-color={stepDatum.headerData.backgroundColor}
8
+ header-text-color={stepDatum.headerData.textColor}
9
+ show-step-number={stepDatum.showStepNumber}
10
+ step-count={stepTotalCount}
11
+ step-index={stepIndex}
12
+ step-title={stepDatum.stepTitle}
13
+ >
14
+ <div slot="card-body" class="body-container">
15
+ <template if:true={isLoading}>
16
+ <div class="spinner-container">
17
+ <dx-spinner size="large" variant="brand"></dx-spinner>
18
+ </div>
19
+ </template>
20
+ <template if:false={isLoading}>
21
+ <span lwc:dom="manual" class="body-markup"></span>
22
+ <template if:true={stepDatum.formData}>
23
+ <dw-j2s-form
24
+ id={stepDatum.formData.formId}
25
+ countries={countryOptions}
26
+ form-metadata={stepDatum.formData}
27
+ has-already-registered={hasAlreadyRegistered}
28
+ incoming-user-info={userInfo}
29
+ onformvaliditychange={handleFormValidityChange}
30
+ recaptcha-token={recaptchaToken}
31
+ >
32
+ <div slot="form-captcha-slot">
33
+ <slot name="card-step-captcha-slot"></slot>
34
+ </div>
35
+ </dw-j2s-form>
36
+ </template>
37
+ </template>
38
+ </div>
39
+ <div slot="secondary-action-section">
40
+ <span
41
+ if:false={isLoading}
42
+ lwc:dom="manual"
43
+ class="secondary-action-markup"
44
+ ></span>
45
+ </div>
46
+ <div slot="primary-action-section">
47
+ <dx-button
48
+ if:true={showPrimaryAction}
49
+ class="primary-action"
50
+ disabled={isPrimaryActionDisabled}
51
+ href={primaryActionLink}
52
+ icon-sprite={stepDatum.primaryAction.iconSprite}
53
+ icon-symbol={stepDatum.primaryAction.iconSymbol}
54
+ loading={isLoading}
55
+ onclick={handlePrimaryAction}
56
+ size="large"
57
+ target={primaryActionLinkTarget}
58
+ variant={primaryActionVariant}
59
+ >
60
+ {primaryActionText}
61
+ </dx-button>
62
+ </div>
63
+ </dx-card-step>
64
+ </template>