@salesforcedevs/docs-components 1.15.6 → 1.17.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 +2 -2
- package/src/modules/doc/content/content.ts +7 -32
- package/src/modules/doc/contentLayout/contentLayout.html +4 -0
- package/src/modules/doc/contentLayout/contentLayout.ts +2 -0
- package/src/modules/doc/header/header.html +3 -2
- package/src/modules/doc/header/header.ts +31 -8
- package/src/modules/doc/lwcContentLayout/lwcContentLayout.html +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/docs-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.0",
|
|
4
4
|
"description": "Docs Lightning web components for DSC",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "index.js",
|
|
@@ -25,5 +25,5 @@
|
|
|
25
25
|
"@types/lodash.orderby": "4.6.9",
|
|
26
26
|
"@types/lodash.uniqby": "4.7.9"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "1ffac16d66295e04f390e3240328e7f7a9541268"
|
|
29
29
|
}
|
|
@@ -43,26 +43,10 @@ export default class Content extends LightningElement {
|
|
|
43
43
|
return this.docContent;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
@api
|
|
47
|
-
set codeBlockTheme(value) {
|
|
48
|
-
this._codeBlockTheme = value;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
get codeBlockTheme() {
|
|
52
|
-
return this._codeBlockTheme;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
46
|
@track docContent: DocContent = "";
|
|
56
|
-
_codeBlockTheme: string = "dark";
|
|
57
47
|
_docRendered: boolean = false;
|
|
58
|
-
originalCodeBlockThemeValue: String = "";
|
|
59
48
|
|
|
60
49
|
connectedCallback() {
|
|
61
|
-
this.template.addEventListener(
|
|
62
|
-
"themechange",
|
|
63
|
-
this.updateTheme.bind(this) // eslint-disableline no-use-before-define
|
|
64
|
-
);
|
|
65
|
-
|
|
66
50
|
window.addEventListener(
|
|
67
51
|
"highlightedtermchange",
|
|
68
52
|
this.updateHighlighted
|
|
@@ -76,15 +60,6 @@ export default class Content extends LightningElement {
|
|
|
76
60
|
);
|
|
77
61
|
}
|
|
78
62
|
|
|
79
|
-
updateTheme() {
|
|
80
|
-
this._codeBlockTheme =
|
|
81
|
-
this._codeBlockTheme === "dark" ? "light" : "dark";
|
|
82
|
-
const codeBlockEls = this.template.querySelectorAll("dx-code-block");
|
|
83
|
-
codeBlockEls.forEach((codeBlockEl) => {
|
|
84
|
-
codeBlockEl.setAttribute("theme", this._codeBlockTheme);
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
|
|
88
63
|
renderPaginationButton(anchorEl: HTMLElement) {
|
|
89
64
|
const isNext = anchorEl.textContent!.includes("Next →");
|
|
90
65
|
anchorEl.innerHTML = "";
|
|
@@ -116,11 +91,11 @@ export default class Content extends LightningElement {
|
|
|
116
91
|
const codeBlockEls = divEl.querySelectorAll(".codeSection");
|
|
117
92
|
codeBlockEls.forEach((codeBlockEl) => {
|
|
118
93
|
codeBlockEl.setAttribute("lwc:dom", "manual");
|
|
119
|
-
const classList =
|
|
94
|
+
const classList = codeBlockEl.firstElementChild?.classList;
|
|
120
95
|
let language = "";
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
const className = classList[
|
|
96
|
+
if (classList) {
|
|
97
|
+
for (let i = 0; i < classList.length; i++) {
|
|
98
|
+
const className = classList[i];
|
|
124
99
|
if (className.startsWith("brush:")) {
|
|
125
100
|
language = className.split(":")[1];
|
|
126
101
|
}
|
|
@@ -133,7 +108,6 @@ export default class Content extends LightningElement {
|
|
|
133
108
|
codeBlock: codeBlockEl.innerHTML,
|
|
134
109
|
// ! Hot fix for incoming html tags from couchdb for xml blocks, fix me soon please
|
|
135
110
|
language: LANGUAGE_MAP[language] || language,
|
|
136
|
-
theme: this.codeBlockTheme,
|
|
137
111
|
header: "", // Default no title.
|
|
138
112
|
variant: this.codeBlockType,
|
|
139
113
|
isEncoded: true
|
|
@@ -158,6 +132,7 @@ export default class Content extends LightningElement {
|
|
|
158
132
|
}
|
|
159
133
|
});
|
|
160
134
|
|
|
135
|
+
// Set a flag to 1 (true) if and only if all detailEls have no content.
|
|
161
136
|
let flag = 1;
|
|
162
137
|
for (let i: number = 0; i < detailEls.length; i++) {
|
|
163
138
|
flag &= (detailEls[i].innerHTML.trim() === "") as any; // Dark Magic TM
|
|
@@ -359,7 +334,7 @@ export default class Content extends LightningElement {
|
|
|
359
334
|
);
|
|
360
335
|
|
|
361
336
|
@api
|
|
362
|
-
public navigateToHash(hash: String) {
|
|
337
|
+
public navigateToHash = (hash: String) => {
|
|
363
338
|
const splitHash = hash.split("#");
|
|
364
339
|
if (splitHash.length === 2) {
|
|
365
340
|
hash = splitHash[1];
|
|
@@ -370,7 +345,7 @@ export default class Content extends LightningElement {
|
|
|
370
345
|
} else {
|
|
371
346
|
window.scrollTo({ top: 0, behavior: "smooth" });
|
|
372
347
|
}
|
|
373
|
-
}
|
|
348
|
+
};
|
|
374
349
|
|
|
375
350
|
renderedCallback() {
|
|
376
351
|
if (this._docRendered) {
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
language={language}
|
|
12
12
|
bail-href={bailHref}
|
|
13
13
|
bail-label={bailLabel}
|
|
14
|
+
dev-center={devCenter}
|
|
15
|
+
brand={brand}
|
|
14
16
|
>
|
|
15
17
|
<slot name="sidebar-header" slot="version-picker"></slot>
|
|
16
18
|
</dx-sidebar-old>
|
|
@@ -30,6 +32,8 @@
|
|
|
30
32
|
language={language}
|
|
31
33
|
bail-href={bailHref}
|
|
32
34
|
bail-label={bailLabel}
|
|
35
|
+
dev-center={devCenter}
|
|
36
|
+
brand={brand}
|
|
33
37
|
>
|
|
34
38
|
<slot name="sidebar-header" slot="version-picker"></slot>
|
|
35
39
|
</dx-sidebar>
|
|
@@ -42,6 +42,8 @@ export default class ContentLayout extends LightningElement {
|
|
|
42
42
|
@api language!: string;
|
|
43
43
|
@api bailHref!: string;
|
|
44
44
|
@api bailLabel!: string;
|
|
45
|
+
@api devCenter: any;
|
|
46
|
+
@api brand: any;
|
|
45
47
|
|
|
46
48
|
// This is needed for now to prevent failing snapshot tests due to links in the footer
|
|
47
49
|
@api showFooter = false;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
lwc:if={showBanner}
|
|
7
7
|
banner-markup={bannerMarkup}
|
|
8
8
|
></dx-banner>
|
|
9
|
+
<!-- To-Do: Move the devCenter as a new component and use it here, as devCenter is also used in Sidebar now -->
|
|
9
10
|
<div lwc:if={devCenter} class="dev-center-link">
|
|
10
11
|
<a href={devCenter.link} class="dev-center-content">
|
|
11
12
|
<dx-icon symbol="back"></dx-icon>
|
|
@@ -30,7 +31,7 @@
|
|
|
30
31
|
</a>
|
|
31
32
|
</div>
|
|
32
33
|
<div
|
|
33
|
-
lwc:if={
|
|
34
|
+
lwc:if={showScopedNavItems}
|
|
34
35
|
class="header_l2_group header_l2_group-nav"
|
|
35
36
|
>
|
|
36
37
|
<div
|
|
@@ -48,7 +49,7 @@
|
|
|
48
49
|
</header>
|
|
49
50
|
</dx-brand-theme-provider>
|
|
50
51
|
</template>
|
|
51
|
-
<template lwc:if={
|
|
52
|
+
<template lwc:if={shouldHideHeader}>
|
|
52
53
|
<div class="no-header-content"></div>
|
|
53
54
|
</template>
|
|
54
55
|
</template>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { api } from "lwc";
|
|
2
2
|
import cx from "classnames";
|
|
3
|
-
import type { OptionWithNested } from "typings/custom";
|
|
3
|
+
import type { OptionWithNested, DevCenterConfig } from "typings/custom";
|
|
4
4
|
import { HeaderBase } from "dxBaseElements/headerBase";
|
|
5
|
-
import { toJson } from "dxUtils/normalizers";
|
|
5
|
+
import { toJson, normalizeBoolean } from "dxUtils/normalizers";
|
|
6
6
|
|
|
7
7
|
const TABLET_MATCH = "980px";
|
|
8
8
|
const MOBILE_MATCH = "768px";
|
|
@@ -18,6 +18,15 @@ export default class Header extends HeaderBase {
|
|
|
18
18
|
@api langValuePath: string = "id"; // allows to override how language property is interpreted, follows valuePath dropdown api.
|
|
19
19
|
@api headerHref: string = "/";
|
|
20
20
|
|
|
21
|
+
@api
|
|
22
|
+
get hideDocHeader() {
|
|
23
|
+
return this._hideDocHeader;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
set hideDocHeader(value) {
|
|
27
|
+
this._hideDocHeader = normalizeBoolean(value);
|
|
28
|
+
}
|
|
29
|
+
|
|
21
30
|
@api
|
|
22
31
|
get scopedNavItems() {
|
|
23
32
|
return this._scopedNavItems;
|
|
@@ -28,7 +37,7 @@ export default class Header extends HeaderBase {
|
|
|
28
37
|
}
|
|
29
38
|
|
|
30
39
|
@api
|
|
31
|
-
get devCenter() {
|
|
40
|
+
get devCenter(): DevCenterConfig {
|
|
32
41
|
return this._devCenter;
|
|
33
42
|
}
|
|
34
43
|
|
|
@@ -41,14 +50,27 @@ export default class Header extends HeaderBase {
|
|
|
41
50
|
private tabletMatchMedia!: MediaQueryList;
|
|
42
51
|
private shouldRender: boolean = false;
|
|
43
52
|
private showDocDivider: boolean = false;
|
|
44
|
-
private _devCenter
|
|
53
|
+
private _devCenter!: DevCenterConfig;
|
|
54
|
+
private _hideDocHeader: boolean = false;
|
|
45
55
|
|
|
46
56
|
protected mobileBreakpoint(): string {
|
|
47
57
|
return MOBILE_MATCH;
|
|
48
58
|
}
|
|
49
59
|
|
|
50
|
-
private get
|
|
51
|
-
return
|
|
60
|
+
private get showScopedNavItems(): boolean {
|
|
61
|
+
return (
|
|
62
|
+
this.scopedNavItems &&
|
|
63
|
+
this.scopedNavItems.length > 0 &&
|
|
64
|
+
!this.hideDocHeader
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* This function returns true if the hideDocHeader is true and the view is not mobile.
|
|
70
|
+
* Also we need to show the header border in case the doc is hidden or if the brand information doesn't exists.
|
|
71
|
+
*/
|
|
72
|
+
private get shouldHideHeader(): boolean {
|
|
73
|
+
return (this.hideDocHeader && !this.mobile) || this.showDocDivider;
|
|
52
74
|
}
|
|
53
75
|
|
|
54
76
|
connectedCallback(): void {
|
|
@@ -60,7 +82,8 @@ export default class Header extends HeaderBase {
|
|
|
60
82
|
this.tabletMatchMedia.addEventListener("change", this.onTabletChange);
|
|
61
83
|
|
|
62
84
|
if (
|
|
63
|
-
(
|
|
85
|
+
(!this.shouldHideHeader &&
|
|
86
|
+
window.location.pathname.includes("/docs/") &&
|
|
64
87
|
window.location.pathname !== "/docs/apis") ||
|
|
65
88
|
window.location.pathname ===
|
|
66
89
|
"/tableau/embedding-playground/overview" ||
|
|
@@ -91,7 +114,7 @@ export default class Header extends HeaderBase {
|
|
|
91
114
|
protected additionalClasses(): string {
|
|
92
115
|
return cx(
|
|
93
116
|
this.brand && "has-brand",
|
|
94
|
-
this.
|
|
117
|
+
this.showScopedNavItems && "has-scoped-nav-items"
|
|
95
118
|
);
|
|
96
119
|
}
|
|
97
120
|
}
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
language={language}
|
|
12
12
|
bail-href={bailHref}
|
|
13
13
|
bail-label={bailLabel}
|
|
14
|
+
dev-center={devCenter}
|
|
15
|
+
brand={brand}
|
|
14
16
|
>
|
|
15
17
|
<slot name="sidebar-header" slot="version-picker"></slot>
|
|
16
18
|
</dx-sidebar-old>
|
|
@@ -30,6 +32,8 @@
|
|
|
30
32
|
language={language}
|
|
31
33
|
bail-href={bailHref}
|
|
32
34
|
bail-label={bailLabel}
|
|
35
|
+
dev-center={devCenter}
|
|
36
|
+
brand={brand}
|
|
33
37
|
>
|
|
34
38
|
<slot name="sidebar-header" slot="version-picker"></slot>
|
|
35
39
|
</dx-sidebar>
|