@salesforcedevs/docs-components 1.3.345-refactor-tab-alpha2 → 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,48 +142,23 @@ export default class LwcContentLayout extends ContentLayout {
|
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
window.addEventListener("scroll", this.adjustNavPosition);
|
|
158
|
-
window.addEventListener("resize", this.adjustNavPosition);
|
|
159
|
-
|
|
160
|
-
if (!this.hasRendered) {
|
|
161
|
-
this.hasRendered = true;
|
|
162
|
-
this.setRNBByTab();
|
|
163
|
-
if (this.showTabBasedRNB) {
|
|
164
|
-
window.addEventListener("tabchanged", this.onTabChanged);
|
|
165
|
-
window.addEventListener(
|
|
166
|
-
"specificationdatarendered",
|
|
167
|
-
this.onTabChanged
|
|
168
|
-
);
|
|
169
|
-
window.addEventListener("selectedcontent", (event) =>
|
|
170
|
-
this.onRNBClick(event as CustomEvent)
|
|
171
|
-
);
|
|
172
|
-
this.restoreTabSelection();
|
|
173
|
-
}
|
|
174
|
-
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();
|
|
175
157
|
}
|
|
176
158
|
}
|
|
177
159
|
|
|
178
160
|
disconnectedCallback(): void {
|
|
179
|
-
|
|
180
|
-
window.removeEventListener(
|
|
181
|
-
"highlightedtermchange",
|
|
182
|
-
this.updateHighlighted
|
|
183
|
-
);
|
|
184
|
-
window.removeEventListener("scroll", this.adjustNavPosition);
|
|
185
|
-
window.removeEventListener("resize", this.adjustNavPosition);
|
|
186
|
-
|
|
161
|
+
super.disconnectedCallback();
|
|
187
162
|
if (this.showTabBasedRNB) {
|
|
188
163
|
window.removeEventListener("tabchanged", this.onTabChanged);
|
|
189
164
|
window.removeEventListener(
|
|
@@ -195,37 +170,9 @@ export default class LwcContentLayout extends ContentLayout {
|
|
|
195
170
|
);
|
|
196
171
|
window.removeEventListener("popstate", this.handlePopState);
|
|
197
172
|
}
|
|
198
|
-
this.searchSyncer.dispose();
|
|
199
|
-
this.clearRenderObserverTimer();
|
|
200
|
-
|
|
201
|
-
window.clearInterval(this._scrollInterval);
|
|
202
173
|
}
|
|
203
174
|
|
|
204
|
-
|
|
205
|
-
if (!this.enableSlotChange) {
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
this.disconnectObserver();
|
|
209
|
-
|
|
210
|
-
const globalNavOffset = `-${getComputedStyle(
|
|
211
|
-
document.documentElement
|
|
212
|
-
).getPropertyValue("--dx-g-doc-header-main-nav-height")}`;
|
|
213
|
-
|
|
214
|
-
this.observer = new IntersectionObserver(
|
|
215
|
-
(entries) => {
|
|
216
|
-
entries.forEach(
|
|
217
|
-
(entry) =>
|
|
218
|
-
(this.anchoredElements[
|
|
219
|
-
entry.target.getAttribute("id")!
|
|
220
|
-
].intersect = entry.isIntersecting)
|
|
221
|
-
);
|
|
222
|
-
this.calculateActualSection();
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
rootMargin: globalNavOffset.trim()
|
|
226
|
-
}
|
|
227
|
-
);
|
|
228
|
-
|
|
175
|
+
updateHeadingForRNB(): void {
|
|
229
176
|
// Note: We are doing document.querySelectorAll as a quick fix as we are not getting heading elements reference this.querySelectorAll
|
|
230
177
|
const headingElements = this.getHeadingElements();
|
|
231
178
|
|
|
@@ -233,22 +180,8 @@ export default class LwcContentLayout extends ContentLayout {
|
|
|
233
180
|
if (this.showTabBasedRNB) {
|
|
234
181
|
this.updateURL();
|
|
235
182
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
// Add headingElements to intersectionObserver for highlighting respective RNB item when user scroll
|
|
239
|
-
const id = headingElement.getAttribute("id")!;
|
|
240
|
-
this.anchoredElements[id] = {
|
|
241
|
-
id,
|
|
242
|
-
intersect: false
|
|
243
|
-
};
|
|
244
|
-
this.observer.observe(headingElement);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
if (!this.didScrollToSelectedHash) {
|
|
248
|
-
this.didScrollToSelectedHash = true;
|
|
249
|
-
this.scrollToHash(headingElements);
|
|
250
|
-
}
|
|
251
|
-
};
|
|
183
|
+
this.addObserverAndScroll(headingElements);
|
|
184
|
+
}
|
|
252
185
|
|
|
253
186
|
onSlotChange(): void {
|
|
254
187
|
this.updateRNB();
|