@salesforcedevs/docs-components 1.3.345-refactor-tab-alpha1 → 1.3.345-refactor-tab-alpha3
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
|
@@ -151,6 +151,9 @@ export default class ContentLayout extends LightningElement {
|
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
+
// Placeholder for childs renderedCallback
|
|
155
|
+
protected renderedCallbackForLwcContentLayout?(): void;
|
|
156
|
+
|
|
154
157
|
renderedCallback(): void {
|
|
155
158
|
/**
|
|
156
159
|
* Note: We are adding timeout because chrome is optimizing and not triggering recent renderedCallback though elements reference is changed
|
|
@@ -169,6 +172,9 @@ export default class ContentLayout extends LightningElement {
|
|
|
169
172
|
if (!this.hasRendered) {
|
|
170
173
|
this.hasRendered = true;
|
|
171
174
|
this.restoreScroll();
|
|
175
|
+
|
|
176
|
+
// Dynamically call `renderedCallbackForLwcContentLayout` if it exists
|
|
177
|
+
this.renderedCallbackForLwcContentLayout?.();
|
|
172
178
|
}
|
|
173
179
|
}
|
|
174
180
|
|
|
@@ -299,6 +305,34 @@ export default class ContentLayout extends LightningElement {
|
|
|
299
305
|
(event as CustomEvent<string>).detail
|
|
300
306
|
);
|
|
301
307
|
|
|
308
|
+
protected getHeadingElements() {
|
|
309
|
+
// Note: We are doing document.querySelectorAll as a quick fix as we are not getting heading elements reference this.querySelectorAll
|
|
310
|
+
const headingElements = document.querySelectorAll(TOC_HEADER_TAG);
|
|
311
|
+
return headingElements;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
updateHeadingForRNB(): void {
|
|
315
|
+
const headingElements = this.getHeadingElements();
|
|
316
|
+
this.addObserverAndScroll(headingElements);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
addObserverAndScroll(headingElements: any) {
|
|
320
|
+
for (const headingElement of headingElements as any) {
|
|
321
|
+
// Add headingElements to intersectionObserver for highlighting respective RNB item when user scroll
|
|
322
|
+
const id = headingElement.getAttribute("id")!;
|
|
323
|
+
this.anchoredElements[id] = {
|
|
324
|
+
id,
|
|
325
|
+
intersect: false
|
|
326
|
+
};
|
|
327
|
+
this.observer?.observe(headingElement);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
if (!this.didScrollToSelectedHash) {
|
|
331
|
+
this.didScrollToSelectedHash = true;
|
|
332
|
+
this.scrollToHash(headingElements);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
302
336
|
attachInteractionObserver = (): void => {
|
|
303
337
|
if (!this.enableSlotChange) {
|
|
304
338
|
return;
|
|
@@ -323,24 +357,7 @@ export default class ContentLayout extends LightningElement {
|
|
|
323
357
|
rootMargin: globalNavOffset.trim()
|
|
324
358
|
}
|
|
325
359
|
);
|
|
326
|
-
|
|
327
|
-
// Note: We are doing document.querySelectorAll as a quick fix as we are not getting heading elements reference this.querySelectorAll
|
|
328
|
-
const headingElements = document.querySelectorAll(TOC_HEADER_TAG);
|
|
329
|
-
|
|
330
|
-
for (const headingElement of headingElements as any) {
|
|
331
|
-
// Add headingElements to intersectionObserver for highlighting respective RNB item when user scroll
|
|
332
|
-
const id = headingElement.getAttribute("id")!;
|
|
333
|
-
this.anchoredElements[id] = {
|
|
334
|
-
id,
|
|
335
|
-
intersect: false
|
|
336
|
-
};
|
|
337
|
-
this.observer.observe(headingElement);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
if (!this.didScrollToSelectedHash) {
|
|
341
|
-
this.didScrollToSelectedHash = true;
|
|
342
|
-
this.scrollToHash(headingElements);
|
|
343
|
-
}
|
|
360
|
+
this.updateHeadingForRNB();
|
|
344
361
|
};
|
|
345
362
|
|
|
346
363
|
onSlotChange(event: Event): void {
|
|
@@ -49,7 +49,7 @@ export default class LwcContentLayout extends ContentLayout {
|
|
|
49
49
|
this.updateTocItems(headingElements);
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
protected getHeadingElements() {
|
|
53
53
|
let headingElements = document.querySelectorAll(TOC_HEADER_TAG);
|
|
54
54
|
if (this.showTabBasedRNB) {
|
|
55
55
|
const tabPanelListItem: any = this.getTabPanelList();
|
|
@@ -142,26 +142,23 @@ export default class LwcContentLayout extends ContentLayout {
|
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
this.
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
)
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
);
|
|
158
|
-
this.restoreTabSelection();
|
|
159
|
-
}
|
|
160
|
-
this.restoreScroll();
|
|
145
|
+
renderedCallbackForLwcContentLayout(): void {
|
|
146
|
+
this.setRNBByTab();
|
|
147
|
+
if (this.showTabBasedRNB) {
|
|
148
|
+
window.addEventListener("tabchanged", this.onTabChanged);
|
|
149
|
+
window.addEventListener(
|
|
150
|
+
"specificationdatarendered",
|
|
151
|
+
this.onTabChanged
|
|
152
|
+
);
|
|
153
|
+
window.addEventListener("selectedcontent", (event) =>
|
|
154
|
+
this.onRNBClick(event as CustomEvent)
|
|
155
|
+
);
|
|
156
|
+
this.restoreTabSelection();
|
|
161
157
|
}
|
|
162
158
|
}
|
|
163
159
|
|
|
164
160
|
disconnectedCallback(): void {
|
|
161
|
+
super.disconnectedCallback();
|
|
165
162
|
if (this.showTabBasedRNB) {
|
|
166
163
|
window.removeEventListener("tabchanged", this.onTabChanged);
|
|
167
164
|
window.removeEventListener(
|
|
@@ -175,31 +172,7 @@ export default class LwcContentLayout extends ContentLayout {
|
|
|
175
172
|
}
|
|
176
173
|
}
|
|
177
174
|
|
|
178
|
-
|
|
179
|
-
if (!this.enableSlotChange) {
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
this.disconnectObserver();
|
|
183
|
-
|
|
184
|
-
const globalNavOffset = `-${getComputedStyle(
|
|
185
|
-
document.documentElement
|
|
186
|
-
).getPropertyValue("--dx-g-doc-header-main-nav-height")}`;
|
|
187
|
-
|
|
188
|
-
this.observer = new IntersectionObserver(
|
|
189
|
-
(entries) => {
|
|
190
|
-
entries.forEach(
|
|
191
|
-
(entry) =>
|
|
192
|
-
(this.anchoredElements[
|
|
193
|
-
entry.target.getAttribute("id")!
|
|
194
|
-
].intersect = entry.isIntersecting)
|
|
195
|
-
);
|
|
196
|
-
this.calculateActualSection();
|
|
197
|
-
},
|
|
198
|
-
{
|
|
199
|
-
rootMargin: globalNavOffset.trim()
|
|
200
|
-
}
|
|
201
|
-
);
|
|
202
|
-
|
|
175
|
+
updateHeadingForRNB(): void {
|
|
203
176
|
// Note: We are doing document.querySelectorAll as a quick fix as we are not getting heading elements reference this.querySelectorAll
|
|
204
177
|
const headingElements = this.getHeadingElements();
|
|
205
178
|
|
|
@@ -207,22 +180,8 @@ export default class LwcContentLayout extends ContentLayout {
|
|
|
207
180
|
if (this.showTabBasedRNB) {
|
|
208
181
|
this.updateURL();
|
|
209
182
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
// Add headingElements to intersectionObserver for highlighting respective RNB item when user scroll
|
|
213
|
-
const id = headingElement.getAttribute("id")!;
|
|
214
|
-
this.anchoredElements[id] = {
|
|
215
|
-
id,
|
|
216
|
-
intersect: false
|
|
217
|
-
};
|
|
218
|
-
this.observer.observe(headingElement);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
if (!this.didScrollToSelectedHash) {
|
|
222
|
-
this.didScrollToSelectedHash = true;
|
|
223
|
-
this.scrollToHash(headingElements);
|
|
224
|
-
}
|
|
225
|
-
};
|
|
183
|
+
this.addObserverAndScroll(headingElements);
|
|
184
|
+
}
|
|
226
185
|
|
|
227
186
|
onSlotChange(): void {
|
|
228
187
|
this.updateRNB();
|