@salesforcedevs/docs-components 1.3.228-version-picker3 → 1.3.242

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/lwc.config.json CHANGED
@@ -17,7 +17,6 @@
17
17
  "doc/headingAnchor",
18
18
  "doc/overview",
19
19
  "doc/phase",
20
- "doc/versionPicker",
21
20
  "doc/xmlContent",
22
21
  "docUtils/utils"
23
22
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/docs-components",
3
- "version": "1.3.228-version-picker3",
3
+ "version": "1.3.242",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -24,5 +24,5 @@
24
24
  "@types/lodash.orderby": "^4.6.7",
25
25
  "@types/lodash.uniqby": "^4.7.7"
26
26
  },
27
- "gitHead": "4629fdd9ca18a13480044ad43515b91945d16aad"
27
+ "gitHead": "f53c5d4c4cf5fe27cc7c9cb520d2a93f8bc82973"
28
28
  }
@@ -22,3 +22,11 @@ doc-phase:nth-child(2) {
22
22
  .api-documentation {
23
23
  margin-top: 48px;
24
24
  }
25
+
26
+ .version-picker {
27
+ margin-left: auto;
28
+ }
29
+
30
+ .version-picker-text {
31
+ border-bottom: 1px dashed var(--dx-g-blue-vibrant-50);
32
+ }
@@ -17,8 +17,6 @@
17
17
  toc-title={tocTitle}
18
18
  toc-options={tocOptions}
19
19
  enable-slot-change="true"
20
- languages={languages}
21
- language={language}
22
20
  >
23
21
  <doc-phase
24
22
  slot="doc-phase"
@@ -33,14 +31,20 @@
33
31
  dismissible="true"
34
32
  ondismissphase={handleDismissVersionBanner}
35
33
  ></doc-phase>
36
- <div if:true={isVersionEnabled} slot="sidebar-header">
37
- <doc-version-picker
38
- onchange={handleVersionChange}
39
- data-type="version"
40
- versions={versions}
41
- selected-version={selectedVersion}
42
- latest-version={latestVersion}
43
- ></doc-version-picker>
34
+ <div slot="sidebar-header" class="version-picker">
35
+ <template if:true={isVersionEnabled}>
36
+ <dx-dropdown
37
+ onchange={handleVersionChange}
38
+ data-type="version"
39
+ options={versions}
40
+ value={selectedVersion.id}
41
+ width="290px"
42
+ >
43
+ <dx-button variant="inline" class="version-picker-text">
44
+ {selectedVersion.id}
45
+ </dx-button>
46
+ </dx-dropdown>
47
+ </template>
44
48
  </div>
45
49
  <template if:false={showSpecBasedReference}>
46
50
  <slot></slot>
@@ -4,7 +4,6 @@ import { sentenceCase } from "sentence-case";
4
4
  import qs from "query-string";
5
5
  import { AmfModelParser } from "doc/amfModelParser";
6
6
  import { normalizeBoolean, toJson } from "dxUtils/normalizers";
7
- import type { OptionWithLink } from "typings/custom";
8
7
  import type {
9
8
  AmfConfig,
10
9
  AmfMetadataTopic,
@@ -48,8 +47,6 @@ export default class AmfReference extends LightningElement {
48
47
  @api useOldSidebar: boolean = false;
49
48
  @api tocTitle?: string;
50
49
  @api tocOptions?: string;
51
- @api languages!: OptionWithLink[];
52
- @api language!: string;
53
50
  @track navigation = [] as NavigationItem[];
54
51
  @track versions: Array<ReferenceVersion> = [];
55
52
  @track showVersionBanner = false;
@@ -121,8 +118,6 @@ export default class AmfReference extends LightningElement {
121
118
  this.isVersionFetched = true;
122
119
  if (this.oldVersionInfo) {
123
120
  this.showVersionBanner = true;
124
- } else {
125
- this.latestVersion = true;
126
121
  }
127
122
  }
128
123
  } else {
@@ -205,7 +200,6 @@ export default class AmfReference extends LightningElement {
205
200
  private selectedReferenceDocPhase?: string | null = null;
206
201
  private _expandChildren?: boolean = false;
207
202
  private isVersionFetched = false;
208
- private latestVersion = false;
209
203
 
210
204
  /**
211
205
  * Key for storing the currently selected reference url. This will be used to save the
@@ -1316,8 +1310,6 @@ export default class AmfReference extends LightningElement {
1316
1310
  this.versions = this.getVersions();
1317
1311
  if (this.oldVersionInfo) {
1318
1312
  this.showVersionBanner = true;
1319
- } else {
1320
- this.latestVersion = true;
1321
1313
  }
1322
1314
 
1323
1315
  this.isVersionFetched = true;
@@ -61,16 +61,12 @@ dx-toc {
61
61
  flex-direction: row;
62
62
  justify-content: center;
63
63
  max-width: var(--dx-g-doc-content-max-width);
64
-
65
- /* Derived this manually by substracting (topHeader, doc header, banner and the content). */
66
- min-height: 62vh;
67
64
  margin: auto;
68
65
  padding: 0 var(--dx-g-global-header-padding-horizontal);
69
- margin-bottom: calc(2 * (var(--dx-g-spacing-5xl) + 4px));
70
66
  }
71
67
 
72
68
  .content-body {
73
- margin: var(--dx-g-spacing-sm) 0 0;
69
+ margin: var(--dx-g-spacing-sm) 0 var(--dx-g-spacing-xl);
74
70
  max-width: 900px;
75
71
  flex: 1;
76
72
  width: 0;
@@ -110,7 +106,6 @@ dx-toc {
110
106
  .content-body-container {
111
107
  padding-right: 0;
112
108
  overflow-x: auto;
113
- margin-bottom: calc(var(--dx-g-spacing-5xl) + 4px);
114
109
  }
115
110
 
116
111
  .left-nav-bar {
@@ -7,12 +7,8 @@
7
7
  value={sidebarValue}
8
8
  header={sidebarHeader}
9
9
  ontogglesidebar={onToggleSidebar}
10
- languages={languages}
11
- language={language}
12
- bail-href={bailHref}
13
- bail-label={bailLabel}
14
10
  >
15
- <slot name="sidebar-header" slot="version-picker"></slot>
11
+ <slot name="sidebar-header" slot="header"></slot>
16
12
  </dx-sidebar-old>
17
13
  </template>
18
14
  <template if:false={useOldSidebar}>
@@ -26,12 +22,8 @@
26
22
  coveo-search-hub={coveoSearchHub}
27
23
  coveo-advanced-query-config={coveoAdvancedQueryConfig}
28
24
  ontogglesidebar={onToggleSidebar}
29
- languages={languages}
30
- language={language}
31
- bail-href={bailHref}
32
- bail-label={bailLabel}
33
25
  >
34
- <slot name="sidebar-header" slot="version-picker"></slot>
26
+ <slot name="sidebar-header" slot="header"></slot>
35
27
  </dx-sidebar>
36
28
  </template>
37
29
  <div class="content-body-doc-phase-container">
@@ -56,9 +48,6 @@
56
48
  ></dx-toc>
57
49
  </div>
58
50
  </div>
59
- <div class="footer-container">
60
- <dx-footer variant="no-signup"></dx-footer>
61
- </div>
62
51
  </div>
63
52
  </div>
64
53
  </template>
@@ -4,7 +4,6 @@ import { closest } from "kagekiri";
4
4
  import { toJson } from "dxUtils/normalizers";
5
5
  import { highlightTerms } from "dxUtils/highlight";
6
6
  import { SearchSyncer } from "docUtils/searchSyncer";
7
- import type { OptionWithLink } from "typings/custom";
8
7
 
9
8
  type AnchorMap = { [key: string]: { intersect: boolean; id: string } };
10
9
 
@@ -37,10 +36,6 @@ export default class ContentLayout extends LightningElement {
37
36
  @api coveoSearchHub!: string;
38
37
  @api coveoAdvancedQueryConfig!: string;
39
38
  @api useOldSidebar?: boolean = false;
40
- @api languages!: OptionWithLink[];
41
- @api language!: string;
42
- @api bailHref!: string;
43
- @api bailLabel!: string;
44
39
 
45
40
  @api
46
41
  get breadcrumbs() {
@@ -7,8 +7,6 @@ dx-logo {
7
7
  .header_l2 {
8
8
  justify-content: space-between;
9
9
  height: var(--dx-g-doc-header-main-nav-height);
10
- padding-bottom: var(--dx-g-spacing-xs);
11
- background: white;
12
10
  }
13
11
 
14
12
  .nav_menu-button {
@@ -18,32 +16,44 @@ dx-logo {
18
16
  );
19
17
  }
20
18
 
21
- .has-brand.has-scoped-nav-items {
22
- border-bottom: 1px solid var(--dx-g-gray-90);
23
- border-top: 1px solid var(--dx-g-gray-90);
24
- }
25
-
26
19
  .nav_menu-ctas {
27
20
  margin-right: var(--dx-g-spacing-sm);
28
21
  }
29
22
 
30
23
  header:not(.has-brand) > .header_l1 {
31
- background: white;
32
- border-bottom: 1px solid var(--dx-g-gray-90);
24
+ background: var(--dx-g-brand-current-color-background);
33
25
  }
34
26
 
35
27
  header:not(.has-brand) > .header_l2 {
36
- border-bottom: 1px solid var(--dx-g-gray-90);
37
- border-top: 1px solid var(--dx-g-gray-90);
38
- padding-bottom: var(--dx-g-spacing-lg);
28
+ background: var(--dx-g-brand-current-color-background-2);
39
29
  }
40
30
 
41
31
  .header_l2_group.header_l2_group-right-ctas {
42
32
  align-items: baseline;
43
33
  }
44
34
 
45
- .has-brand .header_l2_group-title {
46
- padding-bottom: calc(var(--dx-g-spacing-md) + 2px);
35
+ .header_bail-link {
36
+ --dx-c-button-horizontal-spacing: var(--dx-g-spacing-sm);
37
+
38
+ margin-left: var(--dx-g-spacing-sm);
39
+ }
40
+
41
+ .header_lang-dropdown {
42
+ --button-primary-color: var(--dx-g-blue-vibrant-40);
43
+ --button-primary-color-hover: var(--dx-g-blue-vibrant-30);
44
+ }
45
+
46
+ .header_lang-dropdown > dx-button {
47
+ --dx-c-button-primary-color: var(--button-primary-color);
48
+ --dx-c-button-primary-color-hover: var(--button-primary-color-hover);
49
+ --dx-c-slot-empty-width: min-content;
50
+ --border-color: var(--button-primary-color);
51
+
52
+ border-bottom: 1px dashed var(--border-color);
53
+ }
54
+
55
+ .header_lang-dropdown > dx-button:hover {
56
+ --border-color: var(--button-primary-color-hover);
47
57
  }
48
58
 
49
59
  @media (max-width: 768px) {
@@ -72,10 +82,6 @@ header:not(.has-brand) > .header_l2 {
72
82
  margin-right: var(--dx-g-spacing-sm);
73
83
  }
74
84
 
75
- .has-brand .header_l2_group-title {
76
- padding-bottom: var(--dx-g-spacing-smd);
77
- }
78
-
79
85
  .header_l2_group-title {
80
86
  margin-right: 0;
81
87
  padding: var(--dx-g-spacing-smd)
@@ -83,15 +89,19 @@ header:not(.has-brand) > .header_l2 {
83
89
  min-height: var(--dx-g-doc-header-main-nav-height);
84
90
  }
85
91
 
92
+ .header_l2_group-title .header_lang-dropdown {
93
+ margin-left: auto;
94
+ }
95
+
96
+ .header_lang-dropdown > dx-button {
97
+ padding: var(--dx-g-spacing-2xs) 0;
98
+ }
99
+
86
100
  .has-scoped-nav-items > .header_l2 {
87
101
  height: unset;
88
102
  }
89
103
 
90
104
  .has-scoped-nav-items .header_l2_group-title {
91
- border-bottom: 1px solid var(--dx-g-gray-90);
92
- }
93
-
94
- header:not(.has-brand) > .header_l2 {
95
- padding-bottom: 0;
105
+ border-bottom: 1px solid var(--dx-g-brand-current-color-border-2);
96
106
  }
97
107
  }
@@ -14,12 +14,28 @@
14
14
  if:true={isValidBrand}
15
15
  sprite="salesforcebrand"
16
16
  symbol={brand}
17
- size="large"
17
+ size="xlarge"
18
18
  ></dx-icon>
19
- <span class="subtitle dx-text-display-7">
19
+ <span class="subtitle dx-text-display-6">
20
20
  {subtitle}
21
21
  </span>
22
22
  </a>
23
+ <dx-dropdown
24
+ if:true={showMobileLanguages}
25
+ class="header_lang-dropdown"
26
+ options={languages}
27
+ small
28
+ value={language}
29
+ value-path={langValuePath}
30
+ onchange={onLangChange}
31
+ >
32
+ <dx-button
33
+ aria-label="Select Language"
34
+ variant="inline"
35
+ icon-size="large"
36
+ icon-symbol="world"
37
+ ></dx-button>
38
+ </dx-dropdown>
23
39
  </div>
24
40
  <div
25
41
  if:true={hasScopedNavItems}
@@ -36,6 +52,41 @@
36
52
  ></dx-header-nav>
37
53
  </div>
38
54
  </div>
55
+ <div
56
+ if:false={smallMobile}
57
+ class="header_l2_group header_l2_group-right-ctas"
58
+ >
59
+ <dx-dropdown
60
+ if:true={hasLanguages}
61
+ class="header_lang-dropdown"
62
+ options={languages}
63
+ small
64
+ value-path={langValuePath}
65
+ value={language}
66
+ onchange={onLangChange}
67
+ >
68
+ <dx-button
69
+ aria-label="Select Language"
70
+ variant="inline"
71
+ icon-size="small"
72
+ icon-symbol="world"
73
+ >
74
+ {languageLabel}
75
+ </dx-button>
76
+ </dx-dropdown>
77
+ <dx-button
78
+ if:true={hasBailLink}
79
+ aria-label={bailLabel}
80
+ class="header_bail-link"
81
+ href={bailHref}
82
+ onclick={handleBailClick}
83
+ variant="tertiary"
84
+ icon-symbol="new_window"
85
+ target="_blank"
86
+ >
87
+ {bailLabel}
88
+ </dx-button>
89
+ </div>
39
90
  </div>
40
91
  </header>
41
92
  </dx-brand-theme-provider>
@@ -1,11 +1,14 @@
1
1
  import { api } from "lwc";
2
2
  import cx from "classnames";
3
- import type { OptionWithNested } from "typings/custom";
3
+ import type { OptionWithNested, OptionWithLink } from "typings/custom";
4
4
  import { HeaderBase } from "dxBaseElements/headerBase";
5
5
  import { toJson } from "dxUtils/normalizers";
6
+ import get from "lodash.get";
7
+ import { track } from "dxUtils/analytics";
6
8
 
7
9
  const TABLET_MATCH = "980px";
8
10
  const MOBILE_MATCH = "880px";
11
+ const SMALL_MOBILE_MATCH = "768px";
9
12
 
10
13
  export default class Header extends HeaderBase {
11
14
  @api langValuePath: string = "id"; // allows to override how language property is interpreted, follows valuePath dropdown api.
@@ -20,7 +23,31 @@ export default class Header extends HeaderBase {
20
23
  this._scopedNavItems = toJson(value);
21
24
  }
22
25
 
26
+ @api
27
+ get languages() {
28
+ return this._languages;
29
+ }
30
+
31
+ set languages(value) {
32
+ this._languages = toJson(value);
33
+ }
34
+
35
+ @api
36
+ get language() {
37
+ return this._language;
38
+ }
39
+
40
+ set language(value) {
41
+ if (this._language !== value) {
42
+ this._language = value;
43
+ }
44
+ }
45
+
46
+ private _language: string | null = null;
47
+ private _languages!: OptionWithLink[];
23
48
  private _scopedNavItems!: OptionWithNested[];
49
+ private smallMobile = false;
50
+ private smallMobileMatchMedia!: MediaQueryList;
24
51
  private tablet = false;
25
52
  private tabletMatchMedia!: MediaQueryList;
26
53
  private shouldRender = false;
@@ -33,6 +60,24 @@ export default class Header extends HeaderBase {
33
60
  return this.scopedNavItems && this.scopedNavItems.length > 0;
34
61
  }
35
62
 
63
+ private get hasLanguages(): boolean {
64
+ return !!(this.languages && this.languages.length);
65
+ }
66
+
67
+ private get showMobileLanguages(): boolean {
68
+ return this.smallMobile && this.hasLanguages;
69
+ }
70
+
71
+ private get languageLabel(): string {
72
+ return (
73
+ (this.language &&
74
+ this.languages.find(
75
+ (lang) => get(lang, this.langValuePath) === this.language
76
+ )?.label) ||
77
+ this.languages[0].label
78
+ );
79
+ }
80
+
36
81
  connectedCallback(): void {
37
82
  super.connectedCallback();
38
83
  this.tabletMatchMedia = window.matchMedia(
@@ -41,6 +86,14 @@ export default class Header extends HeaderBase {
41
86
  this.onTabletChange(this.tabletMatchMedia);
42
87
  this.tabletMatchMedia.addEventListener("change", this.onTabletChange);
43
88
 
89
+ this.smallMobileMatchMedia = window.matchMedia(
90
+ `(max-width: ${SMALL_MOBILE_MATCH})`
91
+ );
92
+ this.onSmallMobileChange(this.smallMobileMatchMedia);
93
+ this.smallMobileMatchMedia.addEventListener(
94
+ "change",
95
+ this.onSmallMobileChange
96
+ );
44
97
  if (
45
98
  (window.location.pathname.includes("/docs/") &&
46
99
  window.location.pathname !== "/docs/apis") ||
@@ -59,15 +112,53 @@ export default class Header extends HeaderBase {
59
112
  "change",
60
113
  this.onTabletChange
61
114
  );
115
+
116
+ this.smallMobileMatchMedia.removeEventListener(
117
+ "change",
118
+ this.onSmallMobileChange
119
+ );
62
120
  }
63
121
 
64
122
  private onTabletChange = (e: MediaQueryListEvent | MediaQueryList) =>
65
123
  (this.tablet = e.matches);
66
124
 
125
+ private onSmallMobileChange = (e: MediaQueryListEvent | MediaQueryList) =>
126
+ (this.smallMobile = e.matches);
127
+
67
128
  protected additionalClasses(): string {
68
129
  return cx(
69
130
  this.brand && "has-brand",
70
131
  this.hasScopedNavItems && "has-scoped-nav-items"
71
132
  );
72
133
  }
134
+
135
+ private onLangChange(event: CustomEvent<string>): void {
136
+ const { detail } = event;
137
+ this._language = detail;
138
+
139
+ this.dispatchEvent(new CustomEvent("langchange", { detail }));
140
+ }
141
+
142
+ private handleBailClick(event: Event) {
143
+ const payload = {
144
+ click_text: "pdf",
145
+ click_url: this.bailHref,
146
+ element_title: "pdf",
147
+ element_type: "link",
148
+ content_category: "download"
149
+ };
150
+ track(event.target!, "custEv_pdfDownload", {
151
+ ...payload,
152
+ file_name: this.getFilename(this.bailHref!),
153
+ file_extension: "pdf"
154
+ });
155
+
156
+ track(event.target!, "custEv_linkClick", {
157
+ ...payload
158
+ });
159
+ }
160
+
161
+ private getFilename = function (path: string) {
162
+ return path.substring(path.lastIndexOf("/") + 1);
163
+ };
73
164
  }
@@ -61,15 +61,12 @@ export type ApiDocLanguage = {
61
61
 
62
62
  export interface Header extends Element {
63
63
  subtitle: string;
64
- headerHref: string;
65
- }
66
-
67
- export type SiderbarFooter = {
68
64
  bailHref: string;
69
65
  bailLabel: string;
70
66
  languages: Array<DocLanguage>;
71
67
  language?: string;
72
- };
68
+ headerHref: string;
69
+ }
73
70
 
74
71
  export type ApiNavItem = {
75
72
  children: Array<ApiNavItem>;
@@ -40,6 +40,11 @@ dx-dropdown > dx-button:hover {
40
40
  --border-color: var(--button-primary-color-hover);
41
41
  }
42
42
 
43
+ .document-pickers {
44
+ margin-left: auto;
45
+ margin-right: var(--dx-g-spacing-sm);
46
+ }
47
+
43
48
  doc-phase {
44
49
  --doc-c-phase-top: calc(
45
50
  var(--dx-g-global-header-height) + var(--dx-g-doc-header-height)
@@ -11,10 +11,6 @@
11
11
  sidebar-value={sidebarValue}
12
12
  onselect={handleSelect}
13
13
  use-old-sidebar={useOldSidebar}
14
- languages={sidebarFooterContent.languages}
15
- language={sidebarFooterContent.language}
16
- bail-href={sidebarFooterContent.bailHref}
17
- bail-label={sidebarFooterContent.bailLabel}
18
14
  >
19
15
  <doc-phase
20
16
  slot="version-banner"
@@ -24,16 +20,19 @@
24
20
  dismissible="true"
25
21
  ondismissphase={handleDismissVersionBanner}
26
22
  ></doc-phase>
27
- <div if:false={disableVersion} slot="sidebar-header">
28
- <doc-version-picker
23
+ <div slot="sidebar-header" class="document-pickers">
24
+ <dx-dropdown
29
25
  data-type="version"
30
26
  analytics-event="custEv_ctaLinkClick"
31
27
  analytics-payload={ANALYTICS_PAYLOAD}
32
- versions={versionOptions}
33
- selected-version={version}
34
- latest-version={latestVersion}
35
- hide-badge={previewVersion}
36
- ></doc-version-picker>
28
+ options={versionOptions}
29
+ value={version.id}
30
+ width="290px"
31
+ >
32
+ <dx-button variant="inline" disabled={disableVersion}>
33
+ {version.releaseVersion}
34
+ </dx-button>
35
+ </dx-dropdown>
37
36
  </div>
38
37
  <doc-breadcrumbs
39
38
  if:true={showBreadcrumbs}
@@ -8,7 +8,6 @@ import {
8
8
  DocVersion,
9
9
  TreeNode,
10
10
  Header,
11
- SiderbarFooter,
12
11
  HistoryState,
13
12
  PageReference,
14
13
  TocMap
@@ -27,12 +26,6 @@ const PIXEL_PER_CHARACTER_MAP: { [key: string]: number } = {
27
26
  "ja-jp": 12.5
28
27
  };
29
28
 
30
- const defaultSidebarFooter: SiderbarFooter = {
31
- bailHref: "",
32
- bailLabel: "",
33
- languages: [],
34
- language: ""
35
- };
36
29
  export default class DocXmlContent extends LightningElementWithState<{
37
30
  isFetchingDocument: boolean;
38
31
  isFetchingContent: boolean;
@@ -71,18 +64,15 @@ export default class DocXmlContent extends LightningElementWithState<{
71
64
  private docContent = "";
72
65
  private language?: DocLanguage | null = null;
73
66
  private loaded = false;
74
- private _pageHeader?: Header;
75
67
  private pdfUrl = "";
76
68
  private tocMap: TocMap = {};
77
69
  private sidebarContent: Array<TreeNode> | null = null;
78
70
  private version: DocVersion | null = null;
79
71
  private docTitle = "";
80
72
  private _pathName = "";
73
+ private _pageHeader?: Header;
81
74
  private listenerAttached = false;
82
75
  private _enableCoveo?: boolean = false;
83
- private sidebarFooterContent: SiderbarFooter = { ...defaultSidebarFooter };
84
- private latestVersion = false;
85
- private previewVersion = false;
86
76
 
87
77
  private searchSyncer = new SearchSyncer({
88
78
  callbacks: {
@@ -137,10 +127,6 @@ export default class DocXmlContent extends LightningElementWithState<{
137
127
  try {
138
128
  if (parseFloat(this.version.id) < parseFloat(versionNo)) {
139
129
  info = oldVersionDocInfo(currentGAVersion.link.href);
140
- } else if (
141
- parseFloat(this.version.id) > parseFloat(versionNo)
142
- ) {
143
- this.previewVersion = true;
144
130
  }
145
131
  } catch (exception) {
146
132
  /* Ideally this use case should not happen, but just added to not to break the page*/
@@ -228,6 +214,13 @@ export default class DocXmlContent extends LightningElementWithState<{
228
214
  disconnectedCallback(): void {
229
215
  window.removeEventListener("popstate", this.handlePopState);
230
216
  this.searchSyncer.dispose();
217
+ if (this.listenerAttached) {
218
+ this.pageHeader.removeEventListener(
219
+ "langchange",
220
+ this.handleLanguageChange
221
+ );
222
+ this.listenerAttached = false;
223
+ }
231
224
  }
232
225
 
233
226
  private get languageId(): string | undefined {
@@ -421,8 +414,12 @@ export default class DocXmlContent extends LightningElementWithState<{
421
414
  }
422
415
 
423
416
  getReferenceFromUrl(): PageReference {
424
- const [page, docId, deliverable, contentDocumentId] =
425
- window.location.pathname.substr(1).split("/");
417
+ const [
418
+ page,
419
+ docId,
420
+ deliverable,
421
+ contentDocumentId
422
+ ] = window.location.pathname.substr(1).split("/");
426
423
 
427
424
  const { origin: domain, hash, search } = window.location;
428
425
 
@@ -472,7 +469,7 @@ export default class DocXmlContent extends LightningElementWithState<{
472
469
  this.availableVersions = data.availableVersions;
473
470
  this.pdfUrl = data.pdfUrl;
474
471
 
475
- this.updateHeaderAndSidebarFooter();
472
+ this.updateHeader();
476
473
 
477
474
  this.buildBreadcrumbs();
478
475
 
@@ -483,8 +480,6 @@ export default class DocXmlContent extends LightningElementWithState<{
483
480
 
484
481
  if (this.oldVersionInfo) {
485
482
  this.showVersionBanner = true;
486
- } else {
487
- this.latestVersion = true;
488
483
  }
489
484
 
490
485
  if (
@@ -538,7 +533,7 @@ export default class DocXmlContent extends LightningElementWithState<{
538
533
  });
539
534
  }
540
535
 
541
- updateHeaderAndSidebarFooter(): void {
536
+ updateHeader(): void {
542
537
  if (!this.pageHeader) {
543
538
  return;
544
539
  }
@@ -548,12 +543,20 @@ export default class DocXmlContent extends LightningElementWithState<{
548
543
  }
549
544
 
550
545
  if (this.pdfUrl) {
551
- this.sidebarFooterContent.bailHref = this.pdfUrl;
552
- this.sidebarFooterContent.bailLabel = "PDF";
546
+ this.pageHeader.bailHref = this.pdfUrl;
547
+ this.pageHeader.bailLabel = "PDF";
553
548
  }
554
549
 
555
- this.sidebarFooterContent.languages = this.availableLanguages;
556
- this.sidebarFooterContent.language = this.language?.id;
550
+ if (!this.listenerAttached) {
551
+ this.pageHeader.addEventListener(
552
+ "langchange",
553
+ this.handleLanguageChange
554
+ );
555
+ this.listenerAttached = true;
556
+ }
557
+
558
+ this.pageHeader.languages = this.availableLanguages;
559
+ this.pageHeader.language = this.language?.id;
557
560
 
558
561
  if (this.pageReference) {
559
562
  const { docId, deliverable, page } = this.pageReference;
@@ -578,14 +581,20 @@ export default class DocXmlContent extends LightningElementWithState<{
578
581
  }
579
582
 
580
583
  private updateSearchInput(searchParam: string): void {
581
- (
582
- this.template.querySelector("doc-content-layout") as any
583
- )?.setSidebarInputValue(searchParam);
584
+ (this.template.querySelector(
585
+ "doc-content-layout"
586
+ ) as any)?.setSidebarInputValue(searchParam);
584
587
  }
585
588
 
586
589
  private pageReferenceToString(reference: PageReference): string {
587
- const { page, docId, deliverable, contentDocumentId, hash, search } =
588
- reference;
590
+ const {
591
+ page,
592
+ docId,
593
+ deliverable,
594
+ contentDocumentId,
595
+ hash,
596
+ search
597
+ } = reference;
589
598
  return `/${page}/${docId}/${deliverable}/${contentDocumentId}${this.normalizeSearch(
590
599
  search!
591
600
  )}${this.normalizeHash(hash)}`;
@@ -1,64 +0,0 @@
1
- @import "dxHelpers/reset";
2
-
3
- /* NOTE: doc-version-picker-width width variable is used by both dx-button and dx-dropdown to maintain a consistent width. */
4
- :host {
5
- --dx-c-dropdown-option-font-weight: normal;
6
- --dx-c-dropdown-option-label-color: var(--dx-g-gray-10);
7
- --popover-container-open-transform: translateY(4px);
8
- }
9
-
10
- .version-picker-container {
11
- padding: 8px var(--dx-g-spacing-lg) 8px
12
- var(--dx-g-global-header-padding-horizontal);
13
- border-top: 1px solid var(--dx-g-gray-90);
14
- border-bottom: 1px solid var(--dx-g-gray-90);
15
- }
16
-
17
- .version-picker-button {
18
- display: flex;
19
- width: var(--doc-version-picker-width, 296px);
20
- }
21
-
22
- .version-picker-button:hover,
23
- .version-picker-button:active,
24
- .version-picker-button:focus {
25
- --dx-c-button-secondary-color-hover: var(--dx-g-cloud-blue-vibrant-95);
26
- --dx-c-button-primary-color: var(--dx-g-blue-vibrant-40);
27
- }
28
-
29
- /**
30
- * NOTE: This CSS ensures the span inside the button stays within the parent's width, avoiding overflow.
31
- * Not keeping this in common component to ensure that existing functionality works as it is.
32
- */
33
- dx-button::part(content) {
34
- width: inherit;
35
- overflow: hidden;
36
- }
37
-
38
- .selected-version {
39
- display: flex;
40
- flex-direction: row;
41
- align-items: center;
42
- }
43
-
44
- .selected-version-label {
45
- flex: 1;
46
- overflow: hidden;
47
- text-align: left;
48
- text-overflow: ellipsis;
49
- white-space: nowrap;
50
- }
51
-
52
- dx-type-badge.latest-badge {
53
- --dx-c-type-badge-color: var(--dx-g-green-vibrant-40);
54
- --dx-c-type-badge-background: var(--dx-g-green-vibrant-95);
55
-
56
- margin-left: var(--dx-g-spacing-sm);
57
- }
58
-
59
- dx-type-badge.not-latest-badge {
60
- --dx-c-type-badge-color: var(--dx-g-red-vibrant-40);
61
- --dx-c-type-badge-background: var(--dx-g-red-vibrant-95);
62
-
63
- margin-left: var(--dx-g-spacing-sm);
64
- }
@@ -1,37 +0,0 @@
1
- <template>
2
- <div if:true={showVersionPicker} class="version-picker-container">
3
- <dx-dropdown
4
- options={versions}
5
- value={selectedVersion.id}
6
- width="var(--doc-version-picker-width)"
7
- >
8
- <dx-button
9
- class="version-picker-button"
10
- variant="tertiary"
11
- size="small"
12
- icon-symbol="chevrondown"
13
- icon-size="medium"
14
- >
15
- <div class="selected-version">
16
- <p class="selected-version-label">
17
- {selectedVersion.label}
18
- </p>
19
- <template if:false={hideBadge}>
20
- <dx-type-badge
21
- class="latest-badge"
22
- if:true={latestVersion}
23
- value="Latest"
24
- size="small"
25
- ></dx-type-badge>
26
- <dx-type-badge
27
- class="not-latest-badge"
28
- if:false={latestVersion}
29
- value="Not Latest"
30
- size="small"
31
- ></dx-type-badge>
32
- </template>
33
- </div>
34
- </dx-button>
35
- </dx-dropdown>
36
- </div>
37
- </template>
@@ -1,57 +0,0 @@
1
- import { LightningElement, api } from "lwc";
2
-
3
- import { AnalyticsPayload, OptionWithNested } from "typings/custom";
4
-
5
- import { toJson, normalizeBoolean } from "dxUtils/normalizers";
6
-
7
- export default class VersionPicker extends LightningElement {
8
- @api analyticsEvent?: string;
9
- @api analyticsPayload?: AnalyticsPayload;
10
-
11
- private _versions!: OptionWithNested[];
12
- private _selectedVersion?: OptionWithNested;
13
- private _latestVersion: boolean = false;
14
- private _hideBadge: boolean = false;
15
-
16
- @api
17
- get versions() {
18
- return this._versions;
19
- }
20
-
21
- set versions(value: OptionWithNested[]) {
22
- this._versions = toJson(value);
23
- }
24
-
25
- @api
26
- get selectedVersion(): OptionWithNested | undefined {
27
- return this._selectedVersion || this.versions[0];
28
- }
29
-
30
- set selectedVersion(value: OptionWithNested) {
31
- if (value) {
32
- this._selectedVersion = toJson(value);
33
- }
34
- }
35
-
36
- @api
37
- get latestVersion() {
38
- return this._latestVersion;
39
- }
40
-
41
- set latestVersion(value) {
42
- this._latestVersion = normalizeBoolean(value);
43
- }
44
-
45
- @api
46
- get hideBadge() {
47
- return this._hideBadge;
48
- }
49
-
50
- set hideBadge(value) {
51
- this._hideBadge = normalizeBoolean(value);
52
- }
53
-
54
- private get showVersionPicker() {
55
- return this._versions && this._versions.length !== 0;
56
- }
57
- }