@salesforcedevs/dx-components 1.30.5 → 1.31.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 CHANGED
@@ -59,6 +59,7 @@
59
59
  "dx/footerMfe",
60
60
  "dx/formattedDateTime",
61
61
  "dx/formattedRichText",
62
+ "dx/globalHeader",
62
63
  "dx/grid",
63
64
  "dx/groupText",
64
65
  "dx/headerMobileNavMenu",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/dx-components",
3
- "version": "1.30.5",
3
+ "version": "1.31.0",
4
4
  "description": "DX Lightning web components",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -43,6 +43,5 @@
43
43
  "eventsourcemock": "2.0.0",
44
44
  "luxon": "3.4.4",
45
45
  "msw": "^2.12.4"
46
- },
47
- "gitHead": "6d460367150b62b690d135f6b634adb7cb2b4479"
46
+ }
48
47
  }
@@ -150,7 +150,8 @@ function augmentWithNonMFEFooterFunctionality(FooterClass: typeof Footer) {
150
150
 
151
151
  private buildFooterConfigLookupTables(config: any[]) {
152
152
  config.forEach((item: any) => {
153
- this.configItemTitleToItemLookup.set(item.title, item);
153
+ // attr_title is preferable to title because it is not language-specific
154
+ this.configItemTitleToItemLookup.set(item.attr_title || item.title, item);
154
155
  if (item.menu_item_parent) {
155
156
  const parentId = parseInt(item.menu_item_parent, 10);
156
157
  const children =
@@ -189,10 +190,11 @@ function augmentWithNonMFEFooterFunctionality(FooterClass: typeof Footer) {
189
190
 
190
191
  this.socialLinks =
191
192
  socialLinksItems.map((child: any) => {
193
+ const childTitle: string = child.attr_title || child.title || ""; // attr_title is preferable to title because it is not language-specific
192
194
  const iconSymbol =
193
- child.title === "LinkedIn"
195
+ childTitle === "LinkedIn"
194
196
  ? "linked-in"
195
- : child.title.toLowerCase();
197
+ : childTitle.toLocaleLowerCase();
196
198
  const iconUrlHash =
197
199
  iconSymbol === "twitter"
198
200
  ? "#twitter-x"
@@ -291,10 +293,11 @@ function augmentWithNonMFEFooterFunctionality(FooterClass: typeof Footer) {
291
293
  rel: item.rel
292
294
  };
293
295
 
294
- if (item.title === "Cookie Preferences") {
296
+ const itemTitle: string = item.attr_title || item.title || ""; // attr_title is preferable to title because it is not language-specific
297
+ if (itemTitle === "Cookie Preferences") {
295
298
  link.href = "#";
296
299
  link.onclick = this.handleCookiePreferencesClick;
297
- } else if (item.title === "Your Privacy Choices") {
300
+ } else if (itemTitle === "Your Privacy Choices") {
298
301
  link.img = "https://developer.salesforce.com/ns-assets/privacyoptions.svg";
299
302
  }
300
303
 
@@ -0,0 +1,5 @@
1
+ <template>
2
+ <div lwc:ref="globalNavContainer" part="container">
3
+ <dx-skip-nav-link></dx-skip-nav-link>
4
+ </div>
5
+ </template>
@@ -0,0 +1,76 @@
1
+ import kebabCase from "lodash.kebabcase";
2
+ import { LightningElement, api } from "lwc";
3
+
4
+ const defaultDomain = "https://developer.salesforce.com";
5
+ const defaultLocale = "en-us";
6
+ const defaultHeaderSettingsBasePath = "/c/public/header-settings";
7
+ const headerSettingsJsonKeys = ['regionSelectorOverride', 'contactLinksOverride'];
8
+
9
+ export default class DevExNavigation extends LightningElement {
10
+ @api locale: string = defaultLocale;
11
+ @api path: string = defaultHeaderSettingsBasePath;
12
+ @api domain: string = defaultDomain;
13
+
14
+ async connectedCallback(): Promise<void> {
15
+ try {
16
+ const headerSettingsResponse = await fetch(`${this.domain}${this.path}/${this.locale}.json`, {
17
+ headers: {
18
+ "Content-Type": "application/json",
19
+ },
20
+ });
21
+ if (headerSettingsResponse.ok) {
22
+ this.createFullNav(await headerSettingsResponse.json());
23
+ } else {
24
+ this.createBarebonesNav();
25
+ }
26
+ } catch (ex) {
27
+ console.error(`Navigation error: ${ex}`);
28
+ this.createBarebonesNav();
29
+ }
30
+ }
31
+
32
+ private createGlobalNav(globalNavSettings: any): HTMLElement {
33
+ const hgfNav = document.createElement("hgf-c360nav");
34
+
35
+ Object.entries(globalNavSettings).forEach(([key, value]) => {
36
+ if (headerSettingsJsonKeys.includes(key)) {
37
+ value = JSON.stringify(value);
38
+ }
39
+ hgfNav.setAttribute(kebabCase(key), value as string);
40
+ });
41
+
42
+ return hgfNav;
43
+ }
44
+
45
+ private createContextNav(contextNavData: any): HTMLElement {
46
+ const hgfNavContext = document.createElement("hgf-c360contextnav");
47
+ hgfNavContext.setAttribute("data", JSON.stringify(contextNavData));
48
+ return hgfNavContext;
49
+ }
50
+
51
+ private createFullNav(headerData: any): void {
52
+ const hgfNav = this.createGlobalNav(headerData.headerSettings);
53
+ const hgfNavContext = this.createContextNav(headerData.navItems);
54
+ const containerEl = this.refs.globalNavContainer as Element;
55
+ containerEl.appendChild(hgfNav);
56
+ containerEl.appendChild(hgfNavContext);
57
+ }
58
+
59
+ private createBarebonesNav(): void {
60
+ const hgfNav = this.createGlobalNav({
61
+ origin: "",
62
+ contextNavEnabled: "true",
63
+ });
64
+ const hgfNavContext = this.createContextNav({
65
+ variation: "static",
66
+ propertyTitle: {
67
+ label: "Developers",
68
+ url: "/",
69
+ },
70
+ menuGroup: {},
71
+ });
72
+ const containerEl = this.refs.globalNavContainer as Element;
73
+ containerEl.appendChild(hgfNav);
74
+ containerEl.appendChild(hgfNavContext);
75
+ }
76
+ }
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.