@salesforcedevs/dw-components 0.64.2-alpha.2 → 0.64.5

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/LICENSE ADDED
@@ -0,0 +1,12 @@
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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/dw-components",
3
- "version": "0.64.2-alpha.2",
3
+ "version": "0.64.5",
4
4
  "description": "Lightning web components for https://developer.salesforce.com",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -22,5 +22,6 @@
22
22
  "@types/lodash.clonedeep": "^4.5.7",
23
23
  "@types/lodash.orderby": "^4.6.7",
24
24
  "@types/lodash.uniqby": "^4.7.7"
25
- }
25
+ },
26
+ "gitHead": "8540b5a441e6b34529a1b40693e712a88f4a8a3a"
26
27
  }
@@ -52,6 +52,7 @@ dx-checkbox:last-of-type {
52
52
  cursor: pointer;
53
53
  }
54
54
 
55
+ .marketing-text,
55
56
  .legal-text {
56
57
  font-size: 14px;
57
58
  margin: 0 0 16px 0;
@@ -6,7 +6,7 @@
6
6
  >
7
7
  <slot name="form-heading">
8
8
  <h4 class="newsletter-form-heading dx-text-heading-8">
9
- Sign up now to receive the newsletter.
9
+ Sign up now to receive developer updates.
10
10
  </h4>
11
11
  </slot>
12
12
  <dx-input
@@ -52,13 +52,7 @@
52
52
  required="true"
53
53
  ></dx-select>
54
54
  <template if:true={checkboxTextSet}>
55
- <template if:true={showMarketingCheckbox}>
56
- <dx-checkbox
57
- class="marketing-checkbox"
58
- value={marketingText}
59
- label={marketingText}
60
- ></dx-checkbox>
61
- </template>
55
+ <p class="marketing-text">{marketingText}</p>
62
56
  <p class="legal-text" lwc:dom="manual"></p>
63
57
  <template if:true={showLegalCheckbox}>
64
58
  <dx-checkbox
@@ -25,7 +25,6 @@ export default class Form extends LightningElement {
25
25
 
26
26
  private showLegalText: boolean = false;
27
27
  private showLegalCheckbox: boolean = false;
28
- private showMarketingCheckbox: boolean = false;
29
28
  private legalText: string = "";
30
29
  private marketingText: string | null = null;
31
30
  private hasRendered: boolean = false;
@@ -81,12 +80,14 @@ export default class Form extends LightningElement {
81
80
  e.preventDefault();
82
81
 
83
82
  const allFormElements = Array.from(
84
- this.template.querySelectorAll("dx-input, dx-select, dx-checkbox")
83
+ this.template.querySelectorAll<HTMLFormElement>(
84
+ "dx-input, dx-select, dx-checkbox"
85
+ )
85
86
  );
86
87
 
87
88
  const legalCheckboxElement = this.template.querySelector(
88
89
  "dx-checkbox.legal-checkbox"
89
- );
90
+ ) as HTMLFormElement;
90
91
 
91
92
  if (legalCheckboxElement) {
92
93
  allFormElements.push(legalCheckboxElement);
@@ -115,20 +116,13 @@ export default class Form extends LightningElement {
115
116
  }
116
117
 
117
118
  getFormData() {
118
- const marketingConsented = this.template.querySelector(
119
- "dx-checkbox.marketing-checkbox"
120
- )?.checked;
121
119
  const date = new Date().toISOString();
122
120
 
123
121
  return {
124
- InfoEmail: marketingConsented ? true : false,
122
+ InfoEmail: true,
125
123
  "First Name": this.firstName,
126
124
  "Last Name": this.lastName,
127
- Consent: marketingConsented
128
- ? "Explicit"
129
- : this.showMarketingCheckbox
130
- ? ""
131
- : "Implied",
125
+ Consent: "Implied",
132
126
  "Email Status Update": date,
133
127
  email: this.email,
134
128
  Country: this.country,
@@ -140,7 +134,9 @@ export default class Form extends LightningElement {
140
134
  async sendFormData() {
141
135
  const formData = this.getFormData();
142
136
  const errorMsg = "Error while subscribing to newsletter";
143
- const submitButtonEl = this.template.querySelector(".form-submit");
137
+ const submitButtonEl = this.template.querySelector(
138
+ ".form-submit"
139
+ ) as HTMLFormElement;
144
140
 
145
141
  submitButtonEl.setAttribute("disabled", "true");
146
142
  submitButtonEl.textContent = "...Processing request";
@@ -169,8 +165,10 @@ export default class Form extends LightningElement {
169
165
 
170
166
  window.location.assign("/newsletter/success");
171
167
  } catch (error) {
172
- submitButtonEl.setAttribute("disabled", "false");
173
- submitButtonEl.textContent = "Subscribe Now";
168
+ if (submitButtonEl) {
169
+ submitButtonEl.setAttribute("disabled", "false");
170
+ submitButtonEl.textContent = "Subscribe Now";
171
+ }
174
172
  console.error(error);
175
173
  }
176
174
  }
@@ -178,7 +176,7 @@ export default class Form extends LightningElement {
178
176
  handleConsent(countrySelectElement: any) {
179
177
  if (this.checkboxTextSet) {
180
178
  const countryOptions = countrySelectElement.options.find(
181
- (option) => option.value === countrySelectElement.value
179
+ (option: any) => option.value === countrySelectElement.value
182
180
  );
183
181
 
184
182
  this.setLegalAndMarketingData(countryOptions);
@@ -200,8 +198,7 @@ export default class Form extends LightningElement {
200
198
  // Toggle visibility of legal/marketing data
201
199
  this.toggleLegalAndMarketingVisibility(
202
200
  countryOptions.showLegalText,
203
- countryOptions.showLegalCheckbox,
204
- countryOptions.showMarketingCheckbox
201
+ countryOptions.showLegalCheckbox
205
202
  );
206
203
 
207
204
  // Grab the legal text paragraph element and set inner html (this is due to text having html elements in the string)
@@ -222,12 +219,10 @@ export default class Form extends LightningElement {
222
219
 
223
220
  toggleLegalAndMarketingVisibility(
224
221
  showLegalText: boolean,
225
- showLegalCheckbox: boolean,
226
- showMarketingCheckbox: boolean
222
+ showLegalCheckbox: boolean
227
223
  ) {
228
224
  this.showLegalText = showLegalText;
229
225
  this.showLegalCheckbox = showLegalCheckbox;
230
- this.showMarketingCheckbox = showMarketingCheckbox;
231
226
  }
232
227
 
233
228
  setInnerHtml(element: HTMLElement, value: string) {