@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,14 +0,0 @@
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
- }
@@ -1,37 +0,0 @@
1
- <template>
2
- <dx-step-sequence
3
- animate-transitions="true"
4
- communicate-step-changes="true"
5
- force-initially-visible={forceInitiallyVisible}
6
- initial-step-index={initialStepIndex}
7
- onstepsequencechange={handleStepSequenceChange}
8
- optimize-position-after-animation="true"
9
- session-storage-id={sessionStorageId}
10
- use-history={useHistory}
11
- >
12
- <template for:each={stepsData} for:item="stepDatum" for:index="index">
13
- <dx-step-sequence-step key={stepDatum.id}>
14
- <dw-j2s-card-sequence-step
15
- country-options={countries}
16
- is-loading={isLoading}
17
- oncountrychange={handleCountryChange}
18
- ongetstarted={handleGetStarted}
19
- onformsubmit={handleFormSubmit}
20
- recaptcha-token={recaptchaToken}
21
- selected-country={selectedCountry}
22
- step-datum={stepDatum}
23
- step-index={index}
24
- step-total-count={stepsData.length}
25
- user-info={formIncomingUserInfo}
26
- >
27
- <div
28
- if:true={stepDatum.formData}
29
- slot="card-step-captcha-slot"
30
- >
31
- <slot name="captcha-slot"></slot>
32
- </div>
33
- </dw-j2s-card-sequence-step>
34
- </dx-step-sequence-step>
35
- </template>
36
- </dx-step-sequence>
37
- </template>
@@ -1,418 +0,0 @@
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
-
7
- export type StepDatum = {
8
- bodyHtml?:
9
- | string
10
- | {
11
- default: string;
12
- [countryCode: string]: string;
13
- };
14
- formData?: {
15
- countriesWithReferralInput?: string[];
16
- countriesWithRequiredJobRole?: string[];
17
- formId?: string;
18
- j2sTerms?: string;
19
- notAvailableAlertInfo?: {
20
- title: string;
21
- body: string;
22
- };
23
- participatingCountryCodes?: string[];
24
- salesforceEmployeeAlertInfo?: {
25
- title: string;
26
- body: string;
27
- };
28
- };
29
- headerData?: {
30
- backgroundColor?: string;
31
- iconColor?: string;
32
- iconSprite?: string;
33
- iconSymbol?: string;
34
- textColor?: string;
35
- };
36
- primaryAction: {
37
- iconSprite?: string;
38
- iconSymbol?: string;
39
- link?:
40
- | string
41
- | {
42
- default: string;
43
- [countryCode: string]: string;
44
- };
45
- linkTarget?: string;
46
- text:
47
- | string
48
- | {
49
- default: string;
50
- [countryCode: string]: string;
51
- };
52
- variant?: string;
53
- };
54
- secondaryActionHtml?: string;
55
- showStepNumber?: boolean;
56
- stepTitle: string;
57
- };
58
-
59
- // Field names expected by DRM; see: https://salesforce.quip.com/daInAFETbPGm
60
- export type DrmFormData = {
61
- Email: string;
62
- FirstName: string;
63
- LastName: string;
64
- MailingCountry: string;
65
- MailingState?: string;
66
- Company__c: string;
67
- DRM_Role__c: string;
68
- TBID__c: string;
69
- Opt_In__c?: boolean;
70
- Privacy_Statement__c?: boolean;
71
- j2s_terms?: boolean;
72
- Referral_Email__c?: string;
73
- RelationshipToSalesforce: string;
74
- };
75
-
76
- export default class J2sCardSequence extends LightningElement {
77
- _isDrmLoading = false;
78
- _isFormSubmitting = false;
79
- _isTbidLoading = false;
80
- _recaptchaResetTimeoutId: number | null = null;
81
- _stepsData: StepDatum[] = [];
82
- @api drmDomain: string = "https://drm.my.salesforce-sites.com";
83
- @api formHandler: string =
84
- "https://formhandlermule-1s9xrb.5sc6y6-4.usa-e2.cloudhub.io/form_handler";
85
- @api tbidApiBaseUrl: string | undefined;
86
- @api useHistory: boolean = false;
87
-
88
- @api
89
- get stepsData() {
90
- return this._stepsData;
91
- }
92
- set stepsData(value) {
93
- // normalize incoming value with uuid keys and non-required props (for cleaner HTML template), etc.
94
- const valueWithUuids = getListWithUuids<StepDatum>(toJson(value));
95
- this._stepsData = valueWithUuids.map((stepDatum) => {
96
- const normalizedStepDatum = {
97
- ...stepDatum,
98
- headerData: stepDatum.headerData || {},
99
- primaryAction: {
100
- ...stepDatum.primaryAction,
101
- variant: stepDatum.primaryAction.variant || "primary",
102
- iconSprite: stepDatum.primaryAction.iconSprite || "general",
103
- iconSymbol:
104
- stepDatum.primaryAction.iconSymbol || "arrow-right"
105
- }
106
- };
107
-
108
- return normalizedStepDatum;
109
- });
110
- }
111
-
112
- private countries: any[] = [];
113
- private currentSequenceStep = 0;
114
- private forceInitiallyVisible = false;
115
- private formSubmissionFailureState: Partial<DrmFormData> | null = null;
116
- private recaptchaToken = "";
117
- private selectedCountry = "";
118
- private sessionStorageId = "j2s-card-sequence";
119
- private tbidUserInfo: any; // TODO typings?
120
-
121
- private get isLoading() {
122
- return (
123
- this._isDrmLoading || this._isTbidLoading || this._isFormSubmitting
124
- );
125
- }
126
-
127
- private get isLoggedIn() {
128
- return Boolean(this.tbidUserInfo);
129
- }
130
-
131
- private get formIncomingUserInfo() {
132
- if (!this.tbidUserInfo) {
133
- return {} as DrmFormData;
134
- }
135
-
136
- const tbidData = {
137
- FirstName: this.tbidUserInfo.given_name,
138
- LastName: this.tbidUserInfo.family_name,
139
- Email: this.tbidUserInfo.email,
140
- DRM_Role__c: this.tbidUserInfo.custom_attributes?.Role,
141
- Company__c: this.tbidUserInfo.custom_attributes?.CompanyName,
142
- MailingCountry: this.tbidUserInfo.custom_attributes?.Country,
143
- MailingState: this.tbidUserInfo.address?.region,
144
- RelationshipToSalesforce:
145
- this.tbidUserInfo.custom_attributes?.RelationshipToSalesforce
146
- };
147
-
148
- // Return above object but only with keys that have a truthy value, and with any URI-encoded values decoded
149
- return Object.keys(tbidData)
150
- .filter((key) => Boolean(tbidData[key as keyof typeof tbidData]))
151
- .reduce(
152
- (data, keyWithDefinedValue) => ({
153
- ...data,
154
- [keyWithDefinedValue]: decodeURIComponent(
155
- tbidData[keyWithDefinedValue as keyof typeof tbidData]
156
- )
157
- }),
158
- {}
159
- ) as DrmFormData;
160
- }
161
-
162
- private get initialStepIndex() {
163
- let initialStepIndex = 0;
164
-
165
- const storedSessionData = sessionStorage.getItem(this.sessionStorageId);
166
- if (storedSessionData) {
167
- try {
168
- const { currentStepIndex } = JSON.parse(storedSessionData);
169
- initialStepIndex = currentStepIndex;
170
- } catch (ex) {
171
- // noop
172
- }
173
- }
174
-
175
- return initialStepIndex;
176
- }
177
- private set initialStepIndex(value: number) {
178
- sessionStorage.setItem(
179
- this.sessionStorageId,
180
- JSON.stringify({
181
- currentStepIndex: value
182
- })
183
- );
184
- }
185
-
186
- @api
187
- recaptchaCallback(responseToken: string) {
188
- this.recaptchaToken = responseToken;
189
- clearTimeout(this._recaptchaResetTimeoutId as number);
190
- }
191
-
192
- @api
193
- recaptchaExpiredCallback() {
194
- this.recaptchaToken = "";
195
- clearTimeout(this._recaptchaResetTimeoutId as number);
196
- }
197
-
198
- connectedCallback() {
199
- this.getCountryList();
200
- this.getTbidUserInfo();
201
- // This has to be defined here since it depends on a variable that depends on sessionStorage.
202
- this.currentSequenceStep = this.initialStepIndex;
203
- this.resetCustomButtonColors();
204
-
205
- try {
206
- const isLoggingIn = sessionStorage.getItem(
207
- `${this.sessionStorageId}__isLoginRedirect`
208
- );
209
- if (isLoggingIn) {
210
- this.forceInitiallyVisible = true;
211
- sessionStorage.removeItem(
212
- `${this.sessionStorageId}__isLoginRedirect`
213
- );
214
- }
215
- } catch (ex) {
216
- // noop
217
- }
218
- }
219
-
220
- renderedCallback() {
221
- if (!this.isLoading) {
222
- (
223
- this.template.querySelector(
224
- "dx-step-sequence"
225
- ) as unknown as StepSequence
226
- )?.remeasureSteps();
227
- }
228
-
229
- if (
230
- this.formSubmissionFailureState &&
231
- this.stepsData[this.currentSequenceStep].formData
232
- ) {
233
- const j2sCardStep = this.template.querySelectorAll(
234
- "dw-j2s-card-sequence-step"
235
- ) as unknown as J2sCardSequenceStep[];
236
- j2sCardStep[this.currentSequenceStep]?.notifyFormSubmitFailure(
237
- this.formSubmissionFailureState
238
- );
239
- this.formSubmissionFailureState = null;
240
- }
241
- }
242
-
243
- handleCountryChange({ detail }: CustomEvent) {
244
- this.selectedCountry = detail;
245
- }
246
-
247
- handleStepSequenceChange({ detail }: CustomEvent) {
248
- this.currentSequenceStep = detail.stepIndex;
249
- this.resetCustomButtonColors();
250
-
251
- if (
252
- this.currentSequenceStep !== 1 &&
253
- this.recaptchaToken &&
254
- this._recaptchaResetTimeoutId === null
255
- ) {
256
- // If the recaptcha element expires on its own while you are not on the 2nd (form) step, it messes with the
257
- // page's layout (basically breaks it). So, we need to reset it _before_ expiration if you leave that step.
258
- // We do it with a timeout so that the token is not immediately wiped if the user goes back and forth a bit.
259
- this._recaptchaResetTimeoutId = window.setTimeout(
260
- () => this.resetRecaptcha(),
261
- 1000 * 30 /* 30 seconds */
262
- );
263
- }
264
- }
265
-
266
- handleGetStarted() {
267
- // If the user is not yet logged in, we need to prevent moving immediately to the next
268
- // step, but set storage up so that they are on the second step when they return to the
269
- // site in a logged-in state; then, we need to get them to log in.
270
- if (!this.isLoggedIn) {
271
- this.initialStepIndex = 1;
272
- this._isTbidLoading = true;
273
- sessionStorage.setItem(
274
- `${this.sessionStorageId}__isLoginRedirect`,
275
- "1" /* value doesn't matter */
276
- );
277
- (window as any).__startTbidLogin?.(); // call out to DSC tbid controller
278
- } else {
279
- this.jumpToStepIndex(1);
280
- }
281
- }
282
-
283
- async handleFormSubmit({ detail: formData }: CustomEvent<DrmFormData>) {
284
- if (!this.formHandler || !this.isLoggedIn) {
285
- return;
286
- }
287
-
288
- this._isFormSubmitting = true;
289
-
290
- try {
291
- const res = await fetch(this.formHandler, {
292
- method: "POST",
293
- headers: {
294
- "Content-Type": "application/json",
295
- "Captcha-Response": this.recaptchaToken
296
- },
297
- body: JSON.stringify({
298
- ...formData,
299
- handlerName: "J2S Registration Page",
300
- TBID__c: this.tbidUserInfo.user_id
301
- })
302
- });
303
-
304
- if (res.ok) {
305
- const resData = await res.json();
306
- const resOutput = resData.handlePostRequestOutput || resData;
307
- if (resOutput?.status === "success") {
308
- this.jumpToStepIndex(2, false);
309
- this.initialStepIndex = 0; // don't save final step in storage; rather, reset the starting step
310
- this.resetRecaptcha();
311
- } else {
312
- throw new Error(
313
- `Form submission failed. (status: ${resOutput.status}, message: ${resOutput.errorMessage})`
314
- );
315
- }
316
- } else {
317
- throw new Error(
318
- `Form submission failed. Non-ok response received from DRM.`
319
- );
320
- }
321
- } catch (ex) {
322
- this.formSubmissionFailureState = formData;
323
- console.error(ex);
324
- }
325
-
326
- this._isFormSubmitting = false;
327
- }
328
-
329
- private resetCustomButtonColors() {
330
- let bgColor;
331
- let textColor;
332
-
333
- if (this.currentSequenceStep === 1) {
334
- bgColor = "var(--dx-g-gray-80)";
335
- textColor = "white";
336
- } else {
337
- bgColor = "white";
338
- textColor = "var(--dx-g-blue-vibrant-50)";
339
- }
340
-
341
- this.template.host.style.setProperty(
342
- "--dx-c-button-custom-color",
343
- textColor
344
- );
345
- this.template.host.style.setProperty(
346
- "--dx-c-button-custom-background",
347
- bgColor
348
- );
349
- this.template.host.style.setProperty(
350
- "--dx-c-button-custom-border",
351
- bgColor
352
- );
353
- }
354
-
355
- private resetRecaptcha() {
356
- clearTimeout(this._recaptchaResetTimeoutId as number);
357
- this._recaptchaResetTimeoutId = null;
358
- this.recaptchaToken = "";
359
- (window as any).grecaptcha.reset();
360
- }
361
-
362
- private jumpToStepIndex(stepIndex: number, andStoreIndex = true) {
363
- if (andStoreIndex) {
364
- this.initialStepIndex = stepIndex; // update sessionStorage value
365
- }
366
- (
367
- this.template.querySelector(
368
- "dx-step-sequence"
369
- ) as unknown as StepSequence
370
- )?.jumpToStep(stepIndex);
371
- }
372
-
373
- private async getCountryList() {
374
- this._isDrmLoading = true;
375
-
376
- const errorMsg = "Error while getting country list";
377
- try {
378
- const res = await fetch(
379
- `${this.drmDomain}/utilities/services/apexrest/countries`
380
- );
381
- if (!res.ok) {
382
- throw new Error(errorMsg);
383
- }
384
- this.countries = await res.json();
385
- } catch (error) {
386
- console.error(error);
387
- if (this.initialStepIndex > 0) {
388
- // Page loaded on a step higher than the first, but we can't get data for the form;
389
- // send user back to the start for now.
390
- this.jumpToStepIndex(0);
391
- }
392
- }
393
-
394
- this._isDrmLoading = false;
395
- }
396
-
397
- private async getTbidUserInfo() {
398
- this._isTbidLoading = true;
399
-
400
- try {
401
- const res = await fetch(`${this.tbidApiBaseUrl}/userinfo`);
402
- if (res.ok) {
403
- this.tbidUserInfo = await res.json();
404
- this.selectedCountry = this.formIncomingUserInfo.MailingCountry;
405
- }
406
- } catch (ex) {
407
- // noop; nothing to do here
408
- }
409
-
410
- if (!this.tbidUserInfo && this.initialStepIndex > 0) {
411
- // login failed and the user was previously beyond the start step; need to send them
412
- // back to the start:
413
- this.jumpToStepIndex(0);
414
- }
415
-
416
- this._isTbidLoading = false;
417
- }
418
- }
@@ -1,61 +0,0 @@
1
- export const stepSequenceData = {
2
- animateTransitions: "true",
3
- stepsData: [
4
- {
5
- bodyHtml:
6
- '<p class="dx-text-display-7">Register for Journey to Salesforce and you\'ll be on your way to becoming a Salesforce Developer.</p><ul class="dx-text-display-8"><li>Step 1: Log in or sign up for a free Trailblazer.me account</li><li>Step 2: Confirm your program registration</li><li>Step 3: Begin your journey!</li></ul>',
7
- primaryAction: {
8
- text: "Get Started"
9
- },
10
- showStepNumber: "true",
11
- stepTitle: "Get started now."
12
- },
13
- {
14
- bodyHtml:
15
- '<p class="dx-text-display-7">You\'re almost done! Please review your information and agree to the Journey to Salesforce program terms and conditions.</p>',
16
- formData: {
17
- countriesWithReferralInput: ["IN"],
18
- countriesWithRequiredJobRole: ["CA"],
19
- formId: "j2s-form",
20
- j2sTerms:
21
- 'I agree to the Journey to Salesforce Program Terms, subject to the <a href="http://www.google.com">Salesforce Program Agreement</a>.',
22
- notAvailableAlertInfo: {
23
- title: "Not Available",
24
- body:
25
- 'The Journey to Salesforce program is not currently available in your country. See the <a href="https://www.google.com/">program FAQs</a> for a list of participating countries.'
26
- },
27
- participatingCountryCodes: ["US", "CA", "IN"]
28
- },
29
- primaryAction: {
30
- text: "Complete Registration"
31
- },
32
- secondaryActionHtml:
33
- '<span class="required-notice">* Required to participate in Journey to Salesforce</span>',
34
- showStepNumber: "true",
35
- stepTitle: "Complete your registration."
36
- },
37
- {
38
- bodyHtml:
39
- '<div class="dx-text-display-8"><p>Welcome to Journey to Salesforce! Congratulations on taking this step in your journey towards becoming a Salesforce Developer. Through this program you\'ll gain the knowledge, experience, and skills to help you excel in the Salesforce ecosystem.</p><p>To get started, click the button below to join the Journey to Salesforce community, and make sure to check your email for links to bookmark!</p></div>',
40
- headerData: {
41
- backgroundColor: "green-vibrant-95",
42
- iconSymbol: "check-circle",
43
- iconSprite: "general",
44
- iconColor: "green-vibrant-65",
45
- textColor: "indigo-vibrant-20"
46
- },
47
- primaryAction: {
48
- iconSprite: "utility",
49
- iconSymbol: "new_window",
50
- link:
51
- "https://salesforce-external.slack.com/archives/C05HJK4PGJV",
52
- text: "Join Slack",
53
- variant: "custom"
54
- },
55
- secondaryActionHtml:
56
- '<span class="dx-text-display-7">Ready to jump in?</span>',
57
- showStepNumber: "true",
58
- stepTitle: "Your Registration is Confirmed"
59
- }
60
- ]
61
- };
@@ -1,76 +0,0 @@
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 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 20px;
75
- }
76
- }
@@ -1,63 +0,0 @@
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
- incoming-user-info={userInfo}
28
- onformvaliditychange={handleFormValidityChange}
29
- recaptcha-token={recaptchaToken}
30
- >
31
- <div slot="form-captcha-slot">
32
- <slot name="card-step-captcha-slot"></slot>
33
- </div>
34
- </dw-j2s-form>
35
- </template>
36
- </template>
37
- </div>
38
- <div slot="secondary-action-section">
39
- <span
40
- if:false={isLoading}
41
- lwc:dom="manual"
42
- class="secondary-action-markup"
43
- ></span>
44
- </div>
45
- <div slot="primary-action-section">
46
- <dx-button
47
- if:true={showPrimaryAction}
48
- class="primary-action"
49
- disabled={isJ2sFormInvalid}
50
- href={primaryActionLink}
51
- icon-sprite={stepDatum.primaryAction.iconSprite}
52
- icon-symbol={stepDatum.primaryAction.iconSymbol}
53
- loading={isLoading}
54
- onclick={handlePrimaryAction}
55
- size="large"
56
- target={primaryActionLinkTarget}
57
- variant={primaryActionVariant}
58
- >
59
- {primaryActionText}
60
- </dx-button>
61
- </div>
62
- </dx-card-step>
63
- </template>