@salesforcedevs/docs-components 1.3.324 → 1.3.325-rnbtab-alpha
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-alpha",
|
|
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,113 @@ 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
|
+
// for (const tabPanelListItem of tabPanelListItems) {
|
|
132
|
+
if (tabPanelListItem.id === RNB_BY_TAB) {
|
|
133
|
+
const tabPanels =
|
|
134
|
+
tabPanelListItem.querySelectorAll("dx-tab-panel");
|
|
135
|
+
for (const tabPanelItem of tabPanels) {
|
|
136
|
+
if (tabPanelItem.active) {
|
|
137
|
+
headingElements =
|
|
138
|
+
tabPanelItem.querySelectorAll(TOC_HEADER_TAG);
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return headingElements;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
private updateURL() {
|
|
148
|
+
const tabPanelListItem: any = this.selectTabElement();
|
|
149
|
+
if (tabPanelListItem?.id === RNB_BY_TAB) {
|
|
150
|
+
const tabPanelItems: any =
|
|
151
|
+
tabPanelListItem?.shadowRoot.querySelectorAll(
|
|
152
|
+
"dx-tab-panel-item"
|
|
153
|
+
);
|
|
154
|
+
if (tabPanelItems) {
|
|
155
|
+
for (const tabPanelItem of tabPanelItems as any) {
|
|
156
|
+
const tab = tabPanelItem.shadowRoot.querySelector("button");
|
|
157
|
+
const url = new URL(window.location.href);
|
|
158
|
+
const previousTabID = url.searchParams.get("type");
|
|
159
|
+
const tabID = tab?.getAttribute("aria-label");
|
|
160
|
+
if (
|
|
161
|
+
tab?.getAttribute("aria-selected") === "true" &&
|
|
162
|
+
previousTabID !== tabID
|
|
163
|
+
) {
|
|
164
|
+
url.searchParams.set("type", tabID);
|
|
165
|
+
url.hash = "";
|
|
166
|
+
window.history.pushState({}, "", url.toString());
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
private tabOnPageLoad() {
|
|
175
|
+
const url = new URL(window.location.href);
|
|
176
|
+
const previousTabID = url.searchParams.get("type");
|
|
177
|
+
|
|
178
|
+
if (!previousTabID) {
|
|
179
|
+
this.updateURL();
|
|
180
|
+
} else {
|
|
181
|
+
const tabPanelListItem: any = this.selectTabElement();
|
|
182
|
+
const tabPanelItems: any =
|
|
183
|
+
tabPanelListItem?.shadowRoot.querySelectorAll(
|
|
184
|
+
"dx-tab-panel-item"
|
|
185
|
+
);
|
|
186
|
+
const tabPanels = tabPanelListItem.querySelectorAll("dx-tab-panel");
|
|
187
|
+
if (tabPanelItems) {
|
|
188
|
+
let tabIndex = 0;
|
|
189
|
+
for (const tabPanelItem of tabPanelItems as any) {
|
|
190
|
+
const tab = tabPanelItem.shadowRoot.querySelector("button");
|
|
191
|
+
const activeTab =
|
|
192
|
+
tabPanels[tabIndex]?.shadowRoot.querySelector(
|
|
193
|
+
".tabpanel"
|
|
194
|
+
);
|
|
195
|
+
if (tab?.getAttribute("aria-label") === previousTabID) {
|
|
196
|
+
if (activeTab) {
|
|
197
|
+
activeTab.classList.add("tabpanel-active");
|
|
198
|
+
}
|
|
199
|
+
tab.active = true;
|
|
200
|
+
this.initialIndex = tabIndex;
|
|
201
|
+
} else {
|
|
202
|
+
if (activeTab) {
|
|
203
|
+
activeTab.classList.remove("tabpanel-active");
|
|
204
|
+
}
|
|
205
|
+
tab.active = false;
|
|
206
|
+
}
|
|
207
|
+
tabIndex++;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
104
213
|
private searchSyncer = new SearchSyncer({
|
|
105
214
|
callbacks: {
|
|
106
215
|
onSearchChange: (nextSearchString: string): void => {
|
|
@@ -148,6 +257,11 @@ export default class ContentLayout extends LightningElement {
|
|
|
148
257
|
);
|
|
149
258
|
this.searchSyncer.init();
|
|
150
259
|
}
|
|
260
|
+
|
|
261
|
+
if (this.showTabBasedRNB) {
|
|
262
|
+
window.addEventListener("tabchanged", this.onTabChanged);
|
|
263
|
+
this.tabOnPageLoad();
|
|
264
|
+
}
|
|
151
265
|
}
|
|
152
266
|
|
|
153
267
|
renderedCallback(): void {
|
|
@@ -215,10 +329,16 @@ export default class ContentLayout extends LightningElement {
|
|
|
215
329
|
".sticky-doc-header"
|
|
216
330
|
) as HTMLElement;
|
|
217
331
|
|
|
218
|
-
|
|
332
|
+
let docPhaseEl = (
|
|
219
333
|
this.template.querySelector("[name=doc-phase]")! as any
|
|
220
334
|
).assignedElements()[0] as HTMLSlotElement;
|
|
221
335
|
|
|
336
|
+
if (!docPhaseEl) {
|
|
337
|
+
docPhaseEl = (
|
|
338
|
+
this.template.querySelector("[name=version-banner]")! as any
|
|
339
|
+
).assignedElements()[0] as HTMLSlotElement;
|
|
340
|
+
}
|
|
341
|
+
|
|
222
342
|
if (!sidebarEl || !globalNavEl || !contextNavEl || !docHeaderEl) {
|
|
223
343
|
console.warn("One or more required elements are missing.");
|
|
224
344
|
return;
|
|
@@ -231,6 +351,14 @@ export default class ContentLayout extends LightningElement {
|
|
|
231
351
|
(globalNavEl.getBoundingClientRect().height !== 72 ? 0 : 72) +
|
|
232
352
|
contextNavEl.getBoundingClientRect().height;
|
|
233
353
|
const docHeaderHeight = docHeaderEl.getBoundingClientRect().height;
|
|
354
|
+
const totalHeaderHeight = globalNavHeight + docHeaderHeight;
|
|
355
|
+
|
|
356
|
+
// Selecting the doc section heading and RNB here.
|
|
357
|
+
const docHeadingEls = Array.from(
|
|
358
|
+
document.querySelectorAll("doc-heading")
|
|
359
|
+
);
|
|
360
|
+
const rightNavBarEl = this.template.querySelector(".right-nav-bar");
|
|
361
|
+
|
|
234
362
|
sidebarEl.style.setProperty(
|
|
235
363
|
"--dx-c-content-sidebar-sticky-top",
|
|
236
364
|
`${globalNavHeight + docHeaderHeight}px`
|
|
@@ -241,6 +369,27 @@ export default class ContentLayout extends LightningElement {
|
|
|
241
369
|
`${globalNavHeight}px`
|
|
242
370
|
);
|
|
243
371
|
|
|
372
|
+
// Adjusting the doc section heading on scroll.
|
|
373
|
+
docHeadingEls.forEach((docHeadingEl) => {
|
|
374
|
+
(docHeadingEl as any).style.scrollMarginTop = docPhaseEl
|
|
375
|
+
? `${
|
|
376
|
+
totalHeaderHeight +
|
|
377
|
+
docPhaseEl.getBoundingClientRect().height +
|
|
378
|
+
40
|
|
379
|
+
}px`
|
|
380
|
+
: `${totalHeaderHeight + 40}px`;
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
// Adjusting the right nav bar on scroll.
|
|
384
|
+
if (rightNavBarEl) {
|
|
385
|
+
rightNavBarEl.style.top = docPhaseEl
|
|
386
|
+
? `${
|
|
387
|
+
totalHeaderHeight +
|
|
388
|
+
docPhaseEl.getBoundingClientRect().height
|
|
389
|
+
}px`
|
|
390
|
+
: `${totalHeaderHeight}px`;
|
|
391
|
+
}
|
|
392
|
+
|
|
244
393
|
// 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
394
|
if (docPhaseEl) {
|
|
246
395
|
docPhaseEl.style.setProperty(
|
|
@@ -253,30 +402,6 @@ export default class ContentLayout extends LightningElement {
|
|
|
253
402
|
: globalNavHeight + docHeaderHeight
|
|
254
403
|
}px`
|
|
255
404
|
);
|
|
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
405
|
}
|
|
281
406
|
});
|
|
282
407
|
};
|
|
@@ -313,7 +438,8 @@ export default class ContentLayout extends LightningElement {
|
|
|
313
438
|
);
|
|
314
439
|
|
|
315
440
|
// Note: We are doing document.querySelectorAll as a quick fix as we are not getting heading elements reference this.querySelectorAll
|
|
316
|
-
const headingElements =
|
|
441
|
+
const headingElements = this.getHeadingElements();
|
|
442
|
+
this.updateURL();
|
|
317
443
|
for (const headingElement of headingElements as any) {
|
|
318
444
|
// Add headingElements to intersectionObserver for highlighting respective RNB item when user scroll
|
|
319
445
|
const id = headingElement.getAttribute("id")!;
|
|
@@ -329,49 +455,43 @@ export default class ContentLayout extends LightningElement {
|
|
|
329
455
|
}
|
|
330
456
|
};
|
|
331
457
|
|
|
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
|
-
}
|
|
458
|
+
onSlotChange(e): void {
|
|
459
|
+
const slot = e.target;
|
|
460
|
+
const child = slot.assignedElements();
|
|
461
|
+
const tabComponent = child.find(
|
|
462
|
+
(element: any) =>
|
|
463
|
+
element.tagName.toLowerCase() === "dx-tab-panel-list"
|
|
464
|
+
);
|
|
465
|
+
if (tabComponent) {
|
|
466
|
+
tabComponent.initialIndex = this.initialIndex; // Set the index value on the child component
|
|
467
|
+
}
|
|
468
|
+
this.updateRNB();
|
|
469
|
+
}
|
|
351
470
|
|
|
352
|
-
|
|
471
|
+
// eslint-disable-next-line no-undef
|
|
472
|
+
private updateTocItems(headingElements: NodeListOf<Element>): void {
|
|
473
|
+
const tocOptions = [];
|
|
353
474
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
}
|
|
475
|
+
for (const headingElement of headingElements as any) {
|
|
476
|
+
headingElement.id = headingElement.hash;
|
|
477
|
+
|
|
478
|
+
// Update tocOptions from anchorTags only for H2, consider default as 2 as per component
|
|
479
|
+
const headingAriaLevel =
|
|
480
|
+
headingElement.attributes["aria-level"]?.nodeValue || "2";
|
|
481
|
+
const isH2 = headingAriaLevel === "2";
|
|
482
|
+
|
|
483
|
+
if (isH2) {
|
|
484
|
+
const tocItem = {
|
|
485
|
+
anchor: `#${headingElement.hash}`,
|
|
486
|
+
id: headingElement.id,
|
|
487
|
+
label: headingElement.header
|
|
488
|
+
};
|
|
489
|
+
tocOptions.push(tocItem);
|
|
490
|
+
this.tocOptionIdsSet.add(headingElement.id);
|
|
371
491
|
}
|
|
372
|
-
|
|
373
|
-
this._tocOptions = tocOptions;
|
|
374
492
|
}
|
|
493
|
+
|
|
494
|
+
this._tocOptions = tocOptions;
|
|
375
495
|
}
|
|
376
496
|
|
|
377
497
|
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.
|