@salesforcedevs/docs-components 1.3.324 → 1.3.325-rnbtab-alpha1
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/docs-components",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.325-rnbtab-alpha1",
|
|
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": "
|
|
27
|
+
"gitHead": "4629fdd9ca18a13480044ad43515b91945d16aad"
|
|
28
28
|
}
|
|
@@ -384,7 +384,10 @@ mark {
|
|
|
384
384
|
|
|
385
385
|
/* offset page jump link due to fixed header */
|
|
386
386
|
[id] {
|
|
387
|
-
scroll-margin-top: calc(
|
|
388
|
-
var(--dx-g-global-header-height) + var(--dx-g-doc-header-height)
|
|
387
|
+
--dx-c-content-scroll-margin-top: calc(
|
|
388
|
+
var(--dx-g-global-header-height) + var(--dx-g-doc-header-height) +
|
|
389
|
+
var(--dx-g-spacing-2xl)
|
|
389
390
|
);
|
|
391
|
+
|
|
392
|
+
scroll-margin-top: var(--dx-c-content-scroll-margin-top);
|
|
390
393
|
}
|
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
var(--dx-g-global-header-height) + var(--dx-g-doc-header-height)
|
|
10
10
|
)
|
|
11
11
|
);
|
|
12
|
+
--dx-c-content-scroll-margin-top: calc(
|
|
13
|
+
var(--dx-g-global-header-height) + var(--dx-g-doc-header-height) +
|
|
14
|
+
var(--dx-g-spacing-2xl)
|
|
15
|
+
);
|
|
12
16
|
|
|
13
17
|
display: block;
|
|
14
18
|
}
|
|
@@ -42,9 +46,7 @@ dx-toc {
|
|
|
42
46
|
|
|
43
47
|
/* offset page jump link due to fixed header */
|
|
44
48
|
::slotted(doc-heading) {
|
|
45
|
-
scroll-margin-top:
|
|
46
|
-
var(--dx-g-global-header-height) + var(--dx-g-doc-header-height)
|
|
47
|
-
);
|
|
49
|
+
scroll-margin-top: var(--dx-c-content-scroll-margin-top);
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
.content {
|
|
@@ -11,6 +11,7 @@ type AnchorMap = { [key: string]: { intersect: boolean; id: string } };
|
|
|
11
11
|
declare const Sprig: (eventType: string, eventNme: string) => void;
|
|
12
12
|
|
|
13
13
|
const TOC_HEADER_TAG = "doc-heading";
|
|
14
|
+
const RNB_BY_TAB = "docs-tab";
|
|
14
15
|
const HIGHLIGHTABLE_SELECTOR = [
|
|
15
16
|
"p",
|
|
16
17
|
"h1",
|
|
@@ -41,6 +42,7 @@ export default class ContentLayout extends LightningElement {
|
|
|
41
42
|
@api language!: string;
|
|
42
43
|
@api bailHref!: string;
|
|
43
44
|
@api bailLabel!: string;
|
|
45
|
+
@track initialIndex: number = 0;
|
|
44
46
|
|
|
45
47
|
// This is needed for now to prevent failing snapshot tests due to links in the footer
|
|
46
48
|
@api showFooter = false;
|
|
@@ -101,6 +103,68 @@ export default class ContentLayout extends LightningElement {
|
|
|
101
103
|
return this.contentLoaded && typeof Sprig !== "undefined";
|
|
102
104
|
}
|
|
103
105
|
|
|
106
|
+
get showTabBasedRNB() {
|
|
107
|
+
const tabPanelListItem: any = this.selectTabElement();
|
|
108
|
+
return tabPanelListItem?.id === RNB_BY_TAB ? true : false;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
onTabChanged = () => {
|
|
112
|
+
this.updateRNB();
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
private selectTabElement() {
|
|
116
|
+
return document.querySelector("dx-tab-panel-list");
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
updateRNB = () => {
|
|
120
|
+
const headingElements = this.getHeadingElements();
|
|
121
|
+
headingElements.forEach((headingElement: any) => {
|
|
122
|
+
headingElement.hash = headingElement.attributes.hash?.nodeValue;
|
|
123
|
+
});
|
|
124
|
+
this.updateTocItems(headingElements);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
private getHeadingElements() {
|
|
128
|
+
let headingElements = document.querySelectorAll(TOC_HEADER_TAG);
|
|
129
|
+
if (this.showTabBasedRNB) {
|
|
130
|
+
const tabPanelListItem: any = this.selectTabElement();
|
|
131
|
+
const tabPanels =
|
|
132
|
+
tabPanelListItem?.querySelectorAll("dx-tab-panel");
|
|
133
|
+
for (const tabPanelItem of tabPanels) {
|
|
134
|
+
if (tabPanelItem.active) {
|
|
135
|
+
headingElements =
|
|
136
|
+
tabPanelItem.querySelectorAll(TOC_HEADER_TAG);
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return headingElements;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
private updateURL() {
|
|
145
|
+
const tabPanelListItem: any = this.selectTabElement();
|
|
146
|
+
if (tabPanelListItem?.shadowRoot) {
|
|
147
|
+
const tabPanelItems =
|
|
148
|
+
tabPanelListItem.shadowRoot.querySelectorAll(
|
|
149
|
+
"dx-tab-panel-item"
|
|
150
|
+
);
|
|
151
|
+
if (tabPanelItems) {
|
|
152
|
+
tabPanelItems.forEach((tabPanelItem: any) => {
|
|
153
|
+
const tab = tabPanelItem.shadowRoot.querySelector("button");
|
|
154
|
+
if (tab?.getAttribute("aria-selected") === "true") {
|
|
155
|
+
const tabID = tab?.getAttribute("aria-label");
|
|
156
|
+
const url = new URL(window.location.href);
|
|
157
|
+
if (url.searchParams.get("type") !== tabID) {
|
|
158
|
+
url.searchParams.set("type", tabID);
|
|
159
|
+
url.hash = "";
|
|
160
|
+
window.history.pushState({}, "", url.toString());
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
104
168
|
private searchSyncer = new SearchSyncer({
|
|
105
169
|
callbacks: {
|
|
106
170
|
onSearchChange: (nextSearchString: string): void => {
|
|
@@ -148,6 +212,41 @@ export default class ContentLayout extends LightningElement {
|
|
|
148
212
|
);
|
|
149
213
|
this.searchSyncer.init();
|
|
150
214
|
}
|
|
215
|
+
|
|
216
|
+
if (this.showTabBasedRNB) {
|
|
217
|
+
window.addEventListener("tabchanged", this.onTabChanged);
|
|
218
|
+
this.restoreTabSelection();
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
private restoreTabSelection() {
|
|
223
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
224
|
+
const selectedTabId = urlParams.get("type");
|
|
225
|
+
|
|
226
|
+
if (selectedTabId) {
|
|
227
|
+
this.selectTabById(selectedTabId);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
private selectTabById(tabId: string) {
|
|
232
|
+
requestAnimationFrame(() => {
|
|
233
|
+
const tabPanelListItem: any = this.selectTabElement();
|
|
234
|
+
if (tabPanelListItem?.shadowRoot) {
|
|
235
|
+
const tabPanelItems =
|
|
236
|
+
tabPanelListItem.shadowRoot.querySelectorAll(
|
|
237
|
+
"dx-tab-panel-item"
|
|
238
|
+
);
|
|
239
|
+
if (tabPanelItems) {
|
|
240
|
+
tabPanelItems.forEach((tabPanelItem: any) => {
|
|
241
|
+
const tab =
|
|
242
|
+
tabPanelItem.shadowRoot.querySelector("button");
|
|
243
|
+
if (tab?.getAttribute("aria-label") === tabId) {
|
|
244
|
+
tab?.click();
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
});
|
|
151
250
|
}
|
|
152
251
|
|
|
153
252
|
renderedCallback(): void {
|
|
@@ -215,10 +314,16 @@ export default class ContentLayout extends LightningElement {
|
|
|
215
314
|
".sticky-doc-header"
|
|
216
315
|
) as HTMLElement;
|
|
217
316
|
|
|
218
|
-
|
|
317
|
+
let docPhaseEl = (
|
|
219
318
|
this.template.querySelector("[name=doc-phase]")! as any
|
|
220
319
|
).assignedElements()[0] as HTMLSlotElement;
|
|
221
320
|
|
|
321
|
+
if (!docPhaseEl) {
|
|
322
|
+
docPhaseEl = (
|
|
323
|
+
this.template.querySelector("[name=version-banner]")! as any
|
|
324
|
+
).assignedElements()[0] as HTMLSlotElement;
|
|
325
|
+
}
|
|
326
|
+
|
|
222
327
|
if (!sidebarEl || !globalNavEl || !contextNavEl || !docHeaderEl) {
|
|
223
328
|
console.warn("One or more required elements are missing.");
|
|
224
329
|
return;
|
|
@@ -231,6 +336,14 @@ export default class ContentLayout extends LightningElement {
|
|
|
231
336
|
(globalNavEl.getBoundingClientRect().height !== 72 ? 0 : 72) +
|
|
232
337
|
contextNavEl.getBoundingClientRect().height;
|
|
233
338
|
const docHeaderHeight = docHeaderEl.getBoundingClientRect().height;
|
|
339
|
+
const totalHeaderHeight = globalNavHeight + docHeaderHeight;
|
|
340
|
+
|
|
341
|
+
// Selecting the doc section heading and RNB here.
|
|
342
|
+
const docHeadingEls = Array.from(
|
|
343
|
+
document.querySelectorAll("doc-heading")
|
|
344
|
+
);
|
|
345
|
+
const rightNavBarEl = this.template.querySelector(".right-nav-bar");
|
|
346
|
+
|
|
234
347
|
sidebarEl.style.setProperty(
|
|
235
348
|
"--dx-c-content-sidebar-sticky-top",
|
|
236
349
|
`${globalNavHeight + docHeaderHeight}px`
|
|
@@ -241,6 +354,27 @@ export default class ContentLayout extends LightningElement {
|
|
|
241
354
|
`${globalNavHeight}px`
|
|
242
355
|
);
|
|
243
356
|
|
|
357
|
+
// Adjusting the doc section heading on scroll.
|
|
358
|
+
docHeadingEls.forEach((docHeadingEl) => {
|
|
359
|
+
(docHeadingEl as any).style.scrollMarginTop = docPhaseEl
|
|
360
|
+
? `${
|
|
361
|
+
totalHeaderHeight +
|
|
362
|
+
docPhaseEl.getBoundingClientRect().height +
|
|
363
|
+
40
|
|
364
|
+
}px`
|
|
365
|
+
: `${totalHeaderHeight + 40}px`;
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
// Adjusting the right nav bar on scroll.
|
|
369
|
+
if (rightNavBarEl) {
|
|
370
|
+
rightNavBarEl.style.top = docPhaseEl
|
|
371
|
+
? `${
|
|
372
|
+
totalHeaderHeight +
|
|
373
|
+
docPhaseEl.getBoundingClientRect().height
|
|
374
|
+
}px`
|
|
375
|
+
: `${totalHeaderHeight}px`;
|
|
376
|
+
}
|
|
377
|
+
|
|
244
378
|
// If doc phase element exists, we need to account for its sticky position. Mobile should include the sidebar height (since it becomes sticky aswell).
|
|
245
379
|
if (docPhaseEl) {
|
|
246
380
|
docPhaseEl.style.setProperty(
|
|
@@ -253,30 +387,6 @@ export default class ContentLayout extends LightningElement {
|
|
|
253
387
|
: globalNavHeight + docHeaderHeight
|
|
254
388
|
}px`
|
|
255
389
|
);
|
|
256
|
-
|
|
257
|
-
// Adjust scroll margin for doc headings when doc phase is present
|
|
258
|
-
const docHeadingEls = Array.from(
|
|
259
|
-
document.querySelectorAll("doc-heading")
|
|
260
|
-
);
|
|
261
|
-
docHeadingEls.forEach((docHeadingEl) => {
|
|
262
|
-
(docHeadingEl as any).style.scrollMarginTop = `${
|
|
263
|
-
globalNavHeight +
|
|
264
|
-
docHeaderHeight +
|
|
265
|
-
docPhaseEl.getBoundingClientRect().height
|
|
266
|
-
}px`;
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
// Adjust right nav bar position when doc phase is present
|
|
270
|
-
const rightNavBarEl =
|
|
271
|
-
this.template.querySelector(".right-nav-bar");
|
|
272
|
-
|
|
273
|
-
if (rightNavBarEl) {
|
|
274
|
-
rightNavBarEl.style.top = `${
|
|
275
|
-
globalNavHeight +
|
|
276
|
-
docHeaderHeight +
|
|
277
|
-
docPhaseEl.getBoundingClientRect().height
|
|
278
|
-
}px`;
|
|
279
|
-
}
|
|
280
390
|
}
|
|
281
391
|
});
|
|
282
392
|
};
|
|
@@ -313,7 +423,13 @@ export default class ContentLayout extends LightningElement {
|
|
|
313
423
|
);
|
|
314
424
|
|
|
315
425
|
// Note: We are doing document.querySelectorAll as a quick fix as we are not getting heading elements reference this.querySelectorAll
|
|
316
|
-
const headingElements =
|
|
426
|
+
const headingElements = this.getHeadingElements();
|
|
427
|
+
|
|
428
|
+
// We only need to update URL in case of /docs and ignore if tabs are used anywhere else in DSC
|
|
429
|
+
if (this.showTabBasedRNB) {
|
|
430
|
+
this.updateURL();
|
|
431
|
+
}
|
|
432
|
+
|
|
317
433
|
for (const headingElement of headingElements as any) {
|
|
318
434
|
// Add headingElements to intersectionObserver for highlighting respective RNB item when user scroll
|
|
319
435
|
const id = headingElement.getAttribute("id")!;
|
|
@@ -329,49 +445,43 @@ export default class ContentLayout extends LightningElement {
|
|
|
329
445
|
}
|
|
330
446
|
};
|
|
331
447
|
|
|
332
|
-
onSlotChange(
|
|
333
|
-
const
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
for (const headingElement of headingElements as any) {
|
|
346
|
-
// Sometimes elements hash and header is not being set when slot content is wrapped with div
|
|
347
|
-
headingElement.hash = headingElement.attributes.hash?.nodeValue;
|
|
348
|
-
headingElement.header =
|
|
349
|
-
headingElement.attributes.header?.nodeValue;
|
|
350
|
-
}
|
|
448
|
+
onSlotChange(e): void {
|
|
449
|
+
const slot = e.target;
|
|
450
|
+
const child = slot.assignedElements();
|
|
451
|
+
const tabComponent = child.find(
|
|
452
|
+
(element: any) =>
|
|
453
|
+
element.tagName.toLowerCase() === "dx-tab-panel-list"
|
|
454
|
+
);
|
|
455
|
+
if (tabComponent) {
|
|
456
|
+
tabComponent.initialIndex = this.initialIndex; // Set the index value on the child component
|
|
457
|
+
}
|
|
458
|
+
this.updateRNB();
|
|
459
|
+
}
|
|
351
460
|
|
|
352
|
-
|
|
461
|
+
// eslint-disable-next-line no-undef
|
|
462
|
+
private updateTocItems(headingElements: NodeListOf<Element>): void {
|
|
463
|
+
const tocOptions = [];
|
|
353
464
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
}
|
|
465
|
+
for (const headingElement of headingElements as any) {
|
|
466
|
+
headingElement.id = headingElement.hash;
|
|
467
|
+
|
|
468
|
+
// Update tocOptions from anchorTags only for H2, consider default as 2 as per component
|
|
469
|
+
const headingAriaLevel =
|
|
470
|
+
headingElement.attributes["aria-level"]?.nodeValue || "2";
|
|
471
|
+
const isH2 = headingAriaLevel === "2";
|
|
472
|
+
|
|
473
|
+
if (isH2) {
|
|
474
|
+
const tocItem = {
|
|
475
|
+
anchor: `#${headingElement.hash}`,
|
|
476
|
+
id: headingElement.id,
|
|
477
|
+
label: headingElement.header
|
|
478
|
+
};
|
|
479
|
+
tocOptions.push(tocItem);
|
|
480
|
+
this.tocOptionIdsSet.add(headingElement.id);
|
|
371
481
|
}
|
|
372
|
-
|
|
373
|
-
this._tocOptions = tocOptions;
|
|
374
482
|
}
|
|
483
|
+
|
|
484
|
+
this._tocOptions = tocOptions;
|
|
375
485
|
}
|
|
376
486
|
|
|
377
487
|
private disconnectObserver(): void {
|
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.
|