@salesforcedevs/dw-components 1.3.29 → 1.3.33

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.29",
3
+ "version": "1.3.33",
4
4
  "description": "Lightning web components for https://developer.salesforce.com",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -20,7 +20,9 @@
20
20
  "@types/classnames": "^2.2.10",
21
21
  "@types/lodash.clonedeep": "^4.5.7",
22
22
  "@types/lodash.orderby": "^4.6.7",
23
- "@types/lodash.uniqby": "^4.7.7"
23
+ "@types/lodash.uniqby": "^4.7.7",
24
+ "@types/setimmediate": "^1.0.2",
25
+ "setimmediate": "^1.0.5"
24
26
  },
25
- "gitHead": "5d0d8e8ae99896c6f2da9afd8f826a5c37ae45a1"
27
+ "gitHead": "bc1e71ba19a01c9479ba93b8f827cc152c359c33"
26
28
  }
@@ -25,8 +25,7 @@ span {
25
25
  }
26
26
 
27
27
  dx-checkbox,
28
- .privacy-notice {
29
- width: 100%;
28
+ :not(dx-checkbox) > span {
30
29
  margin-bottom: var(--dx-g-spacing-lg);
31
30
  }
32
31
 
@@ -49,6 +48,10 @@ form > .full-name-field {
49
48
  width: calc(50% - var(--dx-g-spacing-lg) / 2);
50
49
  }
51
50
 
51
+ .legal-terms {
52
+ margin-top: var(--dx-g-spacing-lg);
53
+ }
54
+
52
55
  .submit-button {
53
56
  width: 100%;
54
57
  }
@@ -70,32 +70,39 @@
70
70
  description-markup='Your username must be in the form of an email address (it does not have to be real). It must be unique and cannot be associated with another Salesforce login credential. <a href="https://help.salesforce.com/s/articleView?id=sf.basics_intro_usernames_passwords.htm&type=5" target="_blank">Read more about username recommendations.</a>'
71
71
  label="Username"
72
72
  name="username"
73
- placeholder="miles.vandewetering@salesforce.com"
73
+ placeholder="jane@company.sandbox"
74
74
  required
75
75
  type="email"
76
76
  validity-on-blur={checkUsernameValidity}
77
77
  onchange={handleUsernameChange}
78
78
  ></dx-input>
79
- <dx-checkbox required name="eula" value="accepted">
80
- <span lwc:dom="manual" class="legal-terms"></span>
81
- </dx-checkbox>
82
79
  <dx-checkbox
83
- if:true={showMarketingCheckbox}
80
+ if:true={showMarketingField}
84
81
  name="opt_in"
85
82
  value="explicit"
86
83
  >
87
84
  <span lwc:dom="manual" class="marketing-terms"></span>
88
85
  </dx-checkbox>
89
86
  <dx-checkbox
90
- if:true={showPrivacyCheckbox}
87
+ if:true={showLegalCheckbox}
91
88
  required
92
- name="privacy"
93
- value="privacy_accepted"
89
+ name="eula"
90
+ value="accepted"
94
91
  >
95
- <span lwc:dom="manual" class="privacy-terms"></span>
92
+ <span lwc:dom="manual" class="legal-terms"></span>
93
+ <span
94
+ if:true={learnMore}
95
+ lwc:dom="manual"
96
+ class="learn-more"
97
+ ></span>
96
98
  </dx-checkbox>
97
- <template if:false={showPrivacyCheckbox}>
98
- <span lwc:dom="manual" class="privacy-terms privacy-notice"></span>
99
+ <template if:false={showLegalCheckbox}>
100
+ <span lwc:dom="manual" class="legal-terms"></span>
101
+ <span
102
+ if:true={learnMore}
103
+ lwc:dom="manual"
104
+ class="learn-more"
105
+ ></span>
99
106
  </template>
100
107
  <dx-button
101
108
  class="submit-button"
@@ -11,14 +11,24 @@ import {
11
11
 
12
12
  type SelectOption = { value: string; label: string };
13
13
  type Country = SelectOption & {
14
- showMarketingCheckbox: boolean;
15
- privacyText?: string;
16
- privacyOptIn?: boolean;
14
+ showMarketingField: boolean;
15
+ showLegalCheckbox: boolean;
16
+ checkboxTextSet?: string;
17
+ };
18
+
19
+ type CheckboxSet = {
20
+ marketingText: string;
21
+ legalText: string;
22
+ learnMore?: string;
23
+ };
24
+ type CheckboxTextMap = {
25
+ [key: string]: CheckboxSet;
17
26
  };
18
27
 
19
28
  const DEFAULT_DRIVER = "7013000000005wb";
20
29
  const DUPLICATE_USERNAME_MESSAGE =
21
30
  "You are already using that username in another Salesforce login credential. Your username needs to be unique and in the form of an email address.";
31
+ const ACCEPTED = "accepted";
22
32
  const SIGN_UP_LABEL = "Sign me Up";
23
33
 
24
34
  const ANALYTICS_INFO = {
@@ -52,14 +62,20 @@ export default class DeSignupForm extends LightningElement {
52
62
  this._roles = toJson(value);
53
63
  }
54
64
 
55
- @api marketingText: string = "";
56
- @api privacyText: string = "";
57
- @api legalText: string = "";
65
+ @api
66
+ get checkboxTextMap() {
67
+ return this._checkboxTextMap;
68
+ }
69
+
70
+ set checkboxTextMap(value) {
71
+ this._checkboxTextMap = toJson(value);
72
+ }
58
73
 
59
74
  private country: Country = null;
60
75
  private disableSubmit = false;
61
76
  private username = "";
62
77
  private updateCheckboxLabels = true;
78
+ private _checkboxTextMap: CheckboxTextMap = null;
63
79
  private _countries: Array<Country>;
64
80
  private _roles: Array<SelectOption>;
65
81
  @track knownDuplicateUsers = [];
@@ -74,12 +90,35 @@ export default class DeSignupForm extends LightningElement {
74
90
  return !this.knownDuplicateUsers.includes(this.username);
75
91
  }
76
92
 
77
- get showMarketingCheckbox(): boolean {
78
- return this.country && this.country.showMarketingCheckbox;
93
+ get showMarketingField(): boolean {
94
+ return this.country && this.country.showMarketingField;
79
95
  }
80
96
 
81
- get showPrivacyCheckbox(): boolean {
82
- return this.country && !!this.country.privacyOptIn;
97
+ get marketingText(): string {
98
+ return (
99
+ this.checkboxSetByCountry && this.checkboxSetByCountry.marketingText
100
+ );
101
+ }
102
+
103
+ get showLegalCheckbox(): boolean {
104
+ return this.country && this.country.showLegalCheckbox;
105
+ }
106
+
107
+ get legalText(): string {
108
+ return this.checkboxSetByCountry && this.checkboxSetByCountry.legalText;
109
+ }
110
+
111
+ get learnMore(): string | undefined {
112
+ return this.checkboxSetByCountry && this.checkboxSetByCountry.learnMore;
113
+ }
114
+
115
+ get checkboxSetByCountry(): CheckboxSet {
116
+ return (
117
+ (this.country &&
118
+ this.country.checkboxTextSet &&
119
+ this.checkboxTextMap[this.country.checkboxTextSet]) ||
120
+ this.checkboxTextMap.default
121
+ );
83
122
  }
84
123
 
85
124
  get buttonLabel(): string {
@@ -96,11 +135,12 @@ export default class DeSignupForm extends LightningElement {
96
135
  this.updateInnerHtml(
97
136
  "span.marketing-terms",
98
137
  this.marketingText,
99
- this.showMarketingCheckbox
138
+ this.showMarketingField
100
139
  ) ||
101
140
  this.updateInnerHtml(
102
- "span.privacy-terms",
103
- this.country?.privacyText || this.privacyText
141
+ "span.learn-more",
142
+ this.learnMore,
143
+ !!this.learnMore
104
144
  );
105
145
  }
106
146
 
@@ -178,19 +218,18 @@ export default class DeSignupForm extends LightningElement {
178
218
  userData[field.name] = field.value;
179
219
  });
180
220
 
181
- (userData as UserData).opt_in = this.country.showMarketingCheckbox
221
+ (userData as UserData).opt_in = this.country.showMarketingField
182
222
  ? checkboxes.values.opt_in
183
223
  : "implied";
184
224
 
185
225
  const InfoEmail__c =
186
- this.country.showMarketingCheckbox &&
187
- checkboxes.values.opt_in === ""
226
+ this.country.showMarketingField && checkboxes.values.opt_in === ""
188
227
  ? "False"
189
228
  : "True";
190
229
 
191
230
  const formData: SignupForm = {
192
231
  user: userData as UserData,
193
- eula: checkboxes.values.eula,
232
+ eula: this.showLegalCheckbox ? checkboxes.values.eula : ACCEPTED,
194
233
  default_driver: DEFAULT_DRIVER,
195
234
  InfoEmail__c
196
235
  };