@salesforcedevs/dw-components 1.3.265 → 1.3.276-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/lwc.config.json +1 -0
- package/package.json +2 -3
- package/src/modules/dw/j2sCardSequence/j2sCardSequence.ts +2 -3
- package/src/modules/dw/j2sForm/j2sForm.ts +3 -16
- package/src/modules/dw/languageSelector/languageSelector.html +9 -0
- package/src/modules/dw/languageSelector/languageSelector.ts +86 -0
- package/LICENSE +0 -12
package/lwc.config.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/dw-components",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.276-alpha.0",
|
|
4
4
|
"description": "Lightning web components for https://developer.salesforce.com",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -25,6 +25,5 @@
|
|
|
25
25
|
"@types/lodash.uniqby": "^4.7.7",
|
|
26
26
|
"@types/setimmediate": "^1.0.2",
|
|
27
27
|
"setimmediate": "^1.0.5"
|
|
28
|
-
}
|
|
29
|
-
"gitHead": "840b94133684a800cbdc7432f9df4d69a15cc0e9"
|
|
28
|
+
}
|
|
30
29
|
}
|
|
@@ -3,7 +3,6 @@ import StepSequence from "dx/stepSequence";
|
|
|
3
3
|
import { getListWithUuids } from "dxUtils/list";
|
|
4
4
|
import { toJson } from "dxUtils/normalizers";
|
|
5
5
|
import J2sCardSequenceStep from "dw/j2sCardSequenceStep";
|
|
6
|
-
import { AlertInfo } from "typings/custom";
|
|
7
6
|
|
|
8
7
|
const DRM_SUCCESS_STRING = "success";
|
|
9
8
|
|
|
@@ -19,8 +18,8 @@ export type StepDatum = {
|
|
|
19
18
|
formId?: string;
|
|
20
19
|
j2sTerms?: string;
|
|
21
20
|
notAvailableAlertInfo?: {
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
title: string;
|
|
22
|
+
body: string;
|
|
24
23
|
};
|
|
25
24
|
participatingCountryCodes?: string[];
|
|
26
25
|
salesforceEmployeeAlertInfo?: {
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import { toJson } from "dxUtils/normalizers";
|
|
2
2
|
import { stateMap } from "dwUtils/forms";
|
|
3
|
-
import { DateTime } from "luxon";
|
|
4
3
|
import { api } from "lwc";
|
|
5
4
|
import debounce from "debounce";
|
|
6
5
|
import { LightningElementWithState } from "dxBaseElements/lightningElementWithState";
|
|
7
6
|
import { DrmFormData } from "dw/j2sCardSequence";
|
|
8
7
|
|
|
9
|
-
const closingTimeUSCanada = DateTime.fromISO("2024-05-09", {
|
|
10
|
-
zone: "America/Los_Angeles"
|
|
11
|
-
});
|
|
12
|
-
|
|
13
8
|
// Hard-coding for now because we can't get information about an endpoint for this
|
|
14
9
|
const tbidValidRoles = [
|
|
15
10
|
"Developer",
|
|
@@ -101,17 +96,11 @@ export default class J2sForm extends LightningElementWithState<J2sFormState> {
|
|
|
101
96
|
}
|
|
102
97
|
}
|
|
103
98
|
|
|
104
|
-
private
|
|
99
|
+
private participatingCountryCodes = ["US", "CA", "IN"];
|
|
100
|
+
private countriesWithReferralInput = ["US", "CA", "IN"];
|
|
105
101
|
private requiredFormFields: HTMLElement[] = [];
|
|
106
102
|
private showSubmitFailureAlert = false;
|
|
107
103
|
|
|
108
|
-
get participatingCountryCodes() {
|
|
109
|
-
if (DateTime.local() >= closingTimeUSCanada) {
|
|
110
|
-
return ["IN"];
|
|
111
|
-
}
|
|
112
|
-
return ["US", "CA", "IN"];
|
|
113
|
-
}
|
|
114
|
-
|
|
115
104
|
get isNotParticipatingCountry() {
|
|
116
105
|
return !this.isParticipatingCountry(this.state.MailingCountry);
|
|
117
106
|
}
|
|
@@ -135,9 +124,7 @@ export default class J2sForm extends LightningElementWithState<J2sFormState> {
|
|
|
135
124
|
}
|
|
136
125
|
|
|
137
126
|
get notAvailableAlertInfo() {
|
|
138
|
-
return this.formMetadata.notAvailableAlertInfo
|
|
139
|
-
this.state.MailingCountry || "default"
|
|
140
|
-
];
|
|
127
|
+
return this.formMetadata.notAvailableAlertInfo;
|
|
141
128
|
}
|
|
142
129
|
|
|
143
130
|
get salesforceEmployeeAlertInfo() {
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { track as trackClick } from "dxUtils/analytics";
|
|
2
|
+
import { api, LightningElement, track } from "lwc";
|
|
3
|
+
import { SelectOption } from "typings/custom";
|
|
4
|
+
|
|
5
|
+
const ANALYTICS_INFO = {
|
|
6
|
+
element_title: "Select Language",
|
|
7
|
+
content_category: "cta"
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const language_local_names_map: any = {
|
|
11
|
+
japanese: "日本語",
|
|
12
|
+
english: "english"
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default class LanguageSelector extends LightningElement {
|
|
16
|
+
@track languages = [] as SelectOption[];
|
|
17
|
+
@track selectedLanguage?: string;
|
|
18
|
+
@api postAcf!: string;
|
|
19
|
+
@api postId?: string;
|
|
20
|
+
|
|
21
|
+
_languageMap = {} as any;
|
|
22
|
+
|
|
23
|
+
generateTranslationOptions = async () => {
|
|
24
|
+
const acf = JSON.parse(this.postAcf);
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
const canonicalId = acf?.canonicalid;
|
|
28
|
+
|
|
29
|
+
const alternatePosts: any[] = await (
|
|
30
|
+
await fetch(
|
|
31
|
+
`https://developer.salesforce.com/blogs/wp-json/wp/v2/post-translations/${
|
|
32
|
+
canonicalId || this.postId
|
|
33
|
+
}`
|
|
34
|
+
)
|
|
35
|
+
).json();
|
|
36
|
+
|
|
37
|
+
alternatePosts.forEach(
|
|
38
|
+
(post: { acf: { language: string }; link: string }) => {
|
|
39
|
+
const localLanguageName =
|
|
40
|
+
language_local_names_map[post.acf.language] ||
|
|
41
|
+
language_local_names_map.english;
|
|
42
|
+
this._languageMap[localLanguageName] = post.link;
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
this.languages = alternatePosts.map((post) => {
|
|
47
|
+
return {
|
|
48
|
+
value:
|
|
49
|
+
language_local_names_map[post.acf.language] ||
|
|
50
|
+
language_local_names_map.english,
|
|
51
|
+
label:
|
|
52
|
+
language_local_names_map[post.acf.language] ||
|
|
53
|
+
language_local_names_map.english,
|
|
54
|
+
disabled: false
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
} catch (e) {
|
|
58
|
+
console.error(e);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
this.selectedLanguage =
|
|
62
|
+
language_local_names_map[acf?.language] ||
|
|
63
|
+
language_local_names_map.english;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
connectedCallback() {
|
|
67
|
+
this.generateTranslationOptions();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
handleLanguageChange(evt: CustomEvent): void {
|
|
71
|
+
const selectedLanguage = evt.detail.value;
|
|
72
|
+
const url = this._languageMap[selectedLanguage];
|
|
73
|
+
trackClick(this.template.activeElement!, "custEv_ctaButtonClick", {
|
|
74
|
+
...ANALYTICS_INFO,
|
|
75
|
+
element_type: "button",
|
|
76
|
+
click_text: selectedLanguage,
|
|
77
|
+
click_url: url
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
window.location.href = url;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
get noTranslationsAvailable() {
|
|
84
|
+
return this.languages.length === 0;
|
|
85
|
+
}
|
|
86
|
+
}
|
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.
|