@salesforcedevs/docs-components 1.3.345-refactor-tab-alpha3 → 1.3.345-refactor-tab-alpha4

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.345-refactor-tab-alpha3",
3
+ "version": "1.3.345-refactor-tab-alpha4",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -152,7 +152,7 @@ export default class ContentLayout extends LightningElement {
152
152
  }
153
153
 
154
154
  // Placeholder for childs renderedCallback
155
- protected renderedCallbackForLwcContentLayout?(): void;
155
+ protected postRenderedCallback?(): void;
156
156
 
157
157
  renderedCallback(): void {
158
158
  /**
@@ -174,7 +174,7 @@ export default class ContentLayout extends LightningElement {
174
174
  this.restoreScroll();
175
175
 
176
176
  // Dynamically call `renderedCallbackForLwcContentLayout` if it exists
177
- this.renderedCallbackForLwcContentLayout?.();
177
+ this.postRenderedCallback?.();
178
178
  }
179
179
  }
180
180
 
@@ -360,6 +360,32 @@ export default class ContentLayout extends LightningElement {
360
360
  this.updateHeadingForRNB();
361
361
  };
362
362
 
363
+ // eslint-disable-next-line no-undef
364
+ updateTocItems(headingElements: any): void {
365
+ const tocOptions = [];
366
+
367
+ for (const headingElement of headingElements as any) {
368
+ headingElement.id = headingElement.hash;
369
+
370
+ // Update tocOptions from anchorTags only for H2, consider default as 2 as per component
371
+ const headingAriaLevel =
372
+ headingElement.attributes["aria-level"]?.nodeValue || "2";
373
+ const isH2 = headingAriaLevel === "2";
374
+
375
+ if (isH2) {
376
+ const tocItem = {
377
+ anchor: `#${headingElement.hash}`,
378
+ id: headingElement.id,
379
+ label: headingElement.header
380
+ };
381
+ tocOptions.push(tocItem);
382
+ this.tocOptionIdsSet.add(headingElement.id);
383
+ }
384
+ }
385
+
386
+ this._tocOptions = tocOptions;
387
+ }
388
+
363
389
  onSlotChange(event: Event): void {
364
390
  const slotElements = (
365
391
  event.target as HTMLSlotElement
@@ -380,27 +406,7 @@ export default class ContentLayout extends LightningElement {
380
406
  headingElement.attributes.header?.nodeValue;
381
407
  }
382
408
 
383
- const tocOptions = [];
384
- for (const headingElement of headingElements as any) {
385
- headingElement.id = headingElement.hash;
386
-
387
- // Update tocOptions from anchorTags only for H2, consider default as 2 as per component
388
- const headingAriaLevel =
389
- headingElement.attributes["aria-level"]?.nodeValue || "2";
390
- const isH2 = headingAriaLevel === "2";
391
-
392
- if (isH2) {
393
- const tocItem = {
394
- anchor: `#${headingElement.hash}`,
395
- id: headingElement.id,
396
- label: headingElement.header
397
- };
398
- tocOptions.push(tocItem);
399
- this.tocOptionIdsSet.add(headingElement.id);
400
- }
401
- }
402
-
403
- this._tocOptions = tocOptions;
409
+ this.updateTocItems(headingElements);
404
410
  }
405
411
  }
406
412
 
@@ -142,7 +142,7 @@ export default class LwcContentLayout extends ContentLayout {
142
142
  });
143
143
  }
144
144
 
145
- renderedCallbackForLwcContentLayout(): void {
145
+ postRenderedCallback(): void {
146
146
  this.setRNBByTab();
147
147
  if (this.showTabBasedRNB) {
148
148
  window.addEventListener("tabchanged", this.onTabChanged);
@@ -187,30 +187,4 @@ export default class LwcContentLayout extends ContentLayout {
187
187
  this.updateRNB();
188
188
  this.contentLoaded = true;
189
189
  }
190
-
191
- // eslint-disable-next-line no-undef
192
- private updateTocItems(headingElements: NodeListOf<Element>): void {
193
- const tocOptions = [];
194
-
195
- for (const headingElement of headingElements as any) {
196
- headingElement.id = headingElement.hash;
197
-
198
- // Update tocOptions from anchorTags only for H2, consider default as 2 as per component
199
- const headingAriaLevel =
200
- headingElement.attributes["aria-level"]?.nodeValue || "2";
201
- const isH2 = headingAriaLevel === "2";
202
-
203
- if (isH2) {
204
- const tocItem = {
205
- anchor: `#${headingElement.hash}`,
206
- id: headingElement.id,
207
- label: headingElement.header
208
- };
209
- tocOptions.push(tocItem);
210
- this.tocOptionIdsSet.add(headingElement.id);
211
- }
212
- }
213
-
214
- this._tocOptions = tocOptions;
215
- }
216
190
  }