@salesforcedevs/dw-components 1.3.119 → 1.3.120-alpha.0
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.
|
|
3
|
+
"version": "1.3.120-alpha.0",
|
|
4
4
|
"description": "Lightning web components for https://developer.salesforce.com",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"@types/setimmediate": "^1.0.2",
|
|
25
25
|
"setimmediate": "^1.0.5"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "e10d764cbe3b3e9956eb47572b4dd3b4bed760e3"
|
|
28
28
|
}
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
options={countries}
|
|
52
52
|
placeholder="Select Country/Region"
|
|
53
53
|
required
|
|
54
|
-
value=
|
|
55
|
-
onchange={
|
|
54
|
+
value={country}
|
|
55
|
+
onchange={handleConsent}
|
|
56
56
|
></dx-select>
|
|
57
57
|
<dx-input
|
|
58
58
|
label="Postal Code"
|
|
@@ -77,27 +77,36 @@
|
|
|
77
77
|
onchange={handleUsernameChange}
|
|
78
78
|
></dx-input>
|
|
79
79
|
|
|
80
|
-
<dx-checkbox required name="eula" value="accepted">
|
|
80
|
+
<dx-checkbox required name="eula" value="accepted" if:true={legalText}>
|
|
81
81
|
<span lwc:dom="manual" class="legal-terms"></span>
|
|
82
82
|
</dx-checkbox>
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
name="opt_in"
|
|
86
|
-
value="False"
|
|
87
|
-
>
|
|
83
|
+
|
|
84
|
+
<template if:false={showMarketingCheckbox}>
|
|
88
85
|
<span lwc:dom="manual" class="marketing-terms"></span>
|
|
89
|
-
</
|
|
86
|
+
</template>
|
|
87
|
+
<template if:true={showMarketingCheckbox}>
|
|
88
|
+
<dx-checkbox
|
|
89
|
+
name="marketingCheckbox"
|
|
90
|
+
class="marketing-terms"
|
|
91
|
+
value="false"
|
|
92
|
+
onchange={handleMarketingCheckbox}
|
|
93
|
+
>
|
|
94
|
+
<span>{marketingText}</span>
|
|
95
|
+
</dx-checkbox>
|
|
96
|
+
</template>
|
|
97
|
+
|
|
98
|
+
<template if:false={showLegalCheckbox}>
|
|
99
|
+
<span lwc:dom="manual" class="legal-checkbox privacy-terms"></span>
|
|
100
|
+
</template>
|
|
90
101
|
<dx-checkbox
|
|
91
|
-
if:true={
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
102
|
+
if:true={showLegalCheckbox}
|
|
103
|
+
class="privacy-terms"
|
|
104
|
+
value={legalCheckbox}
|
|
105
|
+
required="true"
|
|
95
106
|
>
|
|
96
|
-
<span lwc:dom="manual" class="privacy-terms"></span>
|
|
107
|
+
<span lwc:dom="manual" class="legal-checkbox privacy-terms"></span>
|
|
97
108
|
</dx-checkbox>
|
|
98
|
-
|
|
99
|
-
<span lwc:dom="manual" class="privacy-terms privacy-notice"></span>
|
|
100
|
-
</template>
|
|
109
|
+
|
|
101
110
|
<dx-button
|
|
102
111
|
class="submit-button"
|
|
103
112
|
disabled={disableSubmit}
|
|
@@ -2,6 +2,7 @@ import { LightningElement, api, track } from "lwc";
|
|
|
2
2
|
import { toJson } from "dxUtils/normalizers";
|
|
3
3
|
import { track as trackGtm } from "dxUtils/analytics";
|
|
4
4
|
import { submitForm, ErrorCode, SignupForm, UserData } from "./submitForm";
|
|
5
|
+
import { CountryOptions } from "typings/custom";
|
|
5
6
|
|
|
6
7
|
type SelectOption = { value: string; label: string };
|
|
7
8
|
type Country = SelectOption & {
|
|
@@ -16,15 +17,6 @@ const DUPLICATE_USERNAME_MESSAGE =
|
|
|
16
17
|
const SIGN_UP_LABEL = "Sign me Up";
|
|
17
18
|
|
|
18
19
|
export default class DeSignupForm extends LightningElement {
|
|
19
|
-
@api
|
|
20
|
-
get countries() {
|
|
21
|
-
return this._countries;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
set countries(value) {
|
|
25
|
-
this._countries = toJson(value);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
20
|
@api
|
|
29
21
|
get roles() {
|
|
30
22
|
return this._roles;
|
|
@@ -33,17 +25,20 @@ export default class DeSignupForm extends LightningElement {
|
|
|
33
25
|
set roles(value) {
|
|
34
26
|
this._roles = toJson(value);
|
|
35
27
|
}
|
|
36
|
-
|
|
37
|
-
@api
|
|
38
|
-
@api privacyText: string = "";
|
|
28
|
+
@api countries: string = "";
|
|
29
|
+
@api drmDomain: string = "";
|
|
39
30
|
@api legalText: string = "";
|
|
40
31
|
|
|
41
32
|
private country: Country = null;
|
|
42
33
|
private disableSubmit = false;
|
|
43
34
|
private username = "";
|
|
44
|
-
private updateCheckboxLabels = true;
|
|
45
|
-
private _countries: Array<Country>;
|
|
46
35
|
private _roles: Array<SelectOption>;
|
|
36
|
+
private showMarketingCheckbox: boolean = false;
|
|
37
|
+
private marketingCheckbox: boolean = false;
|
|
38
|
+
private marketingText: string = "";
|
|
39
|
+
private showLegalCheckbox: boolean = false;
|
|
40
|
+
private privacyText: string = "";
|
|
41
|
+
|
|
47
42
|
@track knownDuplicateUsers = [];
|
|
48
43
|
|
|
49
44
|
get usernameError(): string {
|
|
@@ -56,34 +51,18 @@ export default class DeSignupForm extends LightningElement {
|
|
|
56
51
|
return !this.knownDuplicateUsers.includes(this.username);
|
|
57
52
|
}
|
|
58
53
|
|
|
59
|
-
get showMarketingCheckbox(): boolean {
|
|
60
|
-
return this.country && this.country.showMarketingCheckbox;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
get showPrivacyCheckbox(): boolean {
|
|
64
|
-
return this.country && !!this.country.privacyOptIn;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
54
|
get buttonLabel(): string {
|
|
68
55
|
return this.disableSubmit ? "Beep boop processing" : SIGN_UP_LABEL;
|
|
69
56
|
}
|
|
70
57
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
58
|
+
connectedCallback(): void {
|
|
59
|
+
this.getCountryList();
|
|
60
|
+
}
|
|
75
61
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
this.marketingText,
|
|
81
|
-
this.showMarketingCheckbox
|
|
82
|
-
) ||
|
|
83
|
-
this.updateInnerHtml(
|
|
84
|
-
"span.privacy-terms",
|
|
85
|
-
this.country?.privacyText || this.privacyText
|
|
86
|
-
);
|
|
62
|
+
renderedCallback(): void {
|
|
63
|
+
this.updateInnerHtml("span.legal-terms", this.legalText);
|
|
64
|
+
this.updateInnerHtml("span.marketing-terms", this.marketingText);
|
|
65
|
+
this.updateInnerHtml("span.legal-checkbox", this.privacyText);
|
|
87
66
|
}
|
|
88
67
|
|
|
89
68
|
handleSubmit(event: Event): void {
|
|
@@ -141,13 +120,6 @@ export default class DeSignupForm extends LightningElement {
|
|
|
141
120
|
this.username = event.detail;
|
|
142
121
|
}
|
|
143
122
|
|
|
144
|
-
handleCountryChange(event: CustomEvent<{ value: string }>): void {
|
|
145
|
-
this.country = this.countries.find(
|
|
146
|
-
({ value }) => value === event.detail.value
|
|
147
|
-
);
|
|
148
|
-
this.updateCheckboxLabels = true;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
123
|
private prepareUserData(): SignupForm | null {
|
|
152
124
|
const fields = Array.from(
|
|
153
125
|
this.template.querySelectorAll<HTMLFormElement>(
|
|
@@ -159,9 +131,14 @@ export default class DeSignupForm extends LightningElement {
|
|
|
159
131
|
value: element.value
|
|
160
132
|
}));
|
|
161
133
|
|
|
162
|
-
|
|
134
|
+
let validCheckboxes = true;
|
|
135
|
+
Array.from(
|
|
136
|
+
this.template.querySelectorAll<HTMLInputElement>("dx-checkbox")
|
|
137
|
+
).forEach((checkbox) => {
|
|
138
|
+
validCheckboxes = validCheckboxes && checkbox.reportValidity();
|
|
139
|
+
});
|
|
163
140
|
|
|
164
|
-
if (fields.some((field) => !field.valid) || !
|
|
141
|
+
if (fields.some((field) => !field.valid) || !validCheckboxes) {
|
|
165
142
|
return null;
|
|
166
143
|
}
|
|
167
144
|
|
|
@@ -170,17 +147,15 @@ export default class DeSignupForm extends LightningElement {
|
|
|
170
147
|
userData[field.name] = field.value;
|
|
171
148
|
});
|
|
172
149
|
|
|
173
|
-
(userData as UserData).consent = this.
|
|
150
|
+
(userData as UserData).consent = this.showMarketingCheckbox
|
|
174
151
|
? "Explicit"
|
|
175
|
-
: "Implied
|
|
152
|
+
: "Implied";
|
|
176
153
|
const InfoEmail =
|
|
177
|
-
this.
|
|
154
|
+
this.showMarketingCheckbox && !this.marketingCheckbox
|
|
178
155
|
? "False"
|
|
179
156
|
: "True";
|
|
180
|
-
|
|
181
157
|
const formData: SignupForm = {
|
|
182
158
|
user: userData as UserData,
|
|
183
|
-
eula: checkboxes.values.eula,
|
|
184
159
|
default_driver: DEFAULT_DRIVER,
|
|
185
160
|
info_email: InfoEmail
|
|
186
161
|
};
|
|
@@ -188,24 +163,75 @@ export default class DeSignupForm extends LightningElement {
|
|
|
188
163
|
return formData;
|
|
189
164
|
}
|
|
190
165
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
166
|
+
handleConsent(countrySelectElement: any) {
|
|
167
|
+
this.country = countrySelectElement.target.value;
|
|
168
|
+
countrySelectElement = countrySelectElement.target;
|
|
169
|
+
const countryOptions = countrySelectElement.options.find(
|
|
170
|
+
(option: any) => option.value === countrySelectElement.value
|
|
171
|
+
);
|
|
172
|
+
this.setLegalAndMarketingData(countryOptions);
|
|
173
|
+
this.marketingCheckbox = false;
|
|
174
|
+
}
|
|
200
175
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
valid = valid && checkbox.reportValidity();
|
|
205
|
-
values[checkbox.name] = checkbox.checked;
|
|
206
|
-
});
|
|
176
|
+
handleMarketingCheckbox(marketingCheckbox: any) {
|
|
177
|
+
this.marketingCheckbox = marketingCheckbox.target.checked;
|
|
178
|
+
}
|
|
207
179
|
|
|
208
|
-
|
|
180
|
+
setLegalAndMarketingData(countryOptions: CountryOptions) {
|
|
181
|
+
// Set the checkbox text
|
|
182
|
+
this.setCheckboxTextSet(
|
|
183
|
+
countryOptions.marketingText,
|
|
184
|
+
countryOptions.learnMore
|
|
185
|
+
? `${countryOptions.legalText} </br> ${countryOptions.learnMore}`
|
|
186
|
+
: countryOptions.legalText
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
// Toggle visibility of legal/marketing data
|
|
190
|
+
this.toggleLegalAndMarketingVisibility(
|
|
191
|
+
countryOptions.showMarketingText,
|
|
192
|
+
countryOptions.showLegalCheckbox
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
setCheckboxTextSet(marketingText: string, privacyText: string) {
|
|
197
|
+
this.marketingText = marketingText;
|
|
198
|
+
this.privacyText = privacyText;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
toggleLegalAndMarketingVisibility(
|
|
202
|
+
showMarketingCheckbox: boolean,
|
|
203
|
+
showLegalCheckbox: boolean
|
|
204
|
+
) {
|
|
205
|
+
this.showMarketingCheckbox = showMarketingCheckbox;
|
|
206
|
+
this.showLegalCheckbox = showLegalCheckbox;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
setInnerHtml(element: HTMLElement, value: string) {
|
|
210
|
+
// disable lwc warning because text received from json has HTML
|
|
211
|
+
// eslint-disable-next-line @lwc/lwc/no-inner-html
|
|
212
|
+
element.innerHTML = value;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
async getCountryList() {
|
|
216
|
+
if (!this.drmDomain) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
const errorMsg = "Error while getting county list";
|
|
220
|
+
try {
|
|
221
|
+
const res = await fetch(
|
|
222
|
+
`${this.drmDomain}/utilities/services/apexrest/countries`
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
if (!res.ok) {
|
|
226
|
+
throw new Error(errorMsg);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const data = await res.json();
|
|
230
|
+
// eslint-disable-next-line @lwc/lwc/no-api-reassignments
|
|
231
|
+
this.countries = JSON.stringify(data);
|
|
232
|
+
} catch (error) {
|
|
233
|
+
console.error(error);
|
|
234
|
+
}
|
|
209
235
|
}
|
|
210
236
|
|
|
211
237
|
private updateInnerHtml(
|
package/LICENSE
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2020, Salesforce.com, Inc.
|
|
2
|
-
All rights reserved.
|
|
3
|
-
|
|
4
|
-
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
5
|
-
|
|
6
|
-
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
7
|
-
|
|
8
|
-
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
9
|
-
|
|
10
|
-
* Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
11
|
-
|
|
12
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|