@salesforcedevs/docs-components 1.27.16 → 1.27.18

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.27.16",
3
+ "version": "1.27.18",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -25,5 +25,5 @@
25
25
  "@types/lodash.orderby": "4.6.9",
26
26
  "@types/lodash.uniqby": "4.7.9"
27
27
  },
28
- "gitHead": "92787faed8b31ef7128f8cee6421a06857def418"
28
+ "gitHead": "39f762aa6e34b9a3607c0f3ce4c1ad445c79c3bc"
29
29
  }
@@ -10,6 +10,7 @@
10
10
  onexpandcollapse={onExpandCollapse}
11
11
  toc-title={tocTitle}
12
12
  toc-options={tocOptions}
13
+ toc-aria-level={tocAriaLevel}
13
14
  enable-slot-change="true"
14
15
  languages={languages}
15
16
  language={language}
@@ -44,6 +44,7 @@ export default class AmfReference extends LightningElement {
44
44
  @api sidebarHeader!: string;
45
45
  @api tocTitle?: string;
46
46
  @api tocOptions?: string;
47
+ @api tocAriaLevel?: string;
47
48
  @api languages!: OptionWithLink[];
48
49
  @api language!: string;
49
50
  @api hideFooter = false;
@@ -76,6 +76,12 @@ export default class ContentLayout extends LightningElement {
76
76
  this._tocOptions = toJson(value);
77
77
  }
78
78
 
79
+ /**
80
+ * The aria-level to filter headings by when building the TOC.
81
+ * Defaults to "2" (H2 headings).
82
+ */
83
+ @api tocAriaLevel: string = "2";
84
+
79
85
  @api
80
86
  setSidebarInputValue(searchTerm: string): void {
81
87
  (this.template.querySelector("dx-sidebar") as any)?.setInputValue(
@@ -393,19 +399,25 @@ export default class ContentLayout extends LightningElement {
393
399
  updateTocItems(headingElements: any): void {
394
400
  const tocOptions = [];
395
401
 
402
+ const maxLevel = Number.parseInt(this.tocAriaLevel, 10) || 2;
403
+ const minLevel = 2;
404
+
396
405
  for (const headingElement of headingElements as any) {
397
406
  headingElement.id = headingElement.hash;
398
407
 
399
- // Update tocOptions from anchorTags only for H2, consider default as 2 as per component
408
+ // Update tocOptions from anchorTags for aria-levels 2..tocAriaLevel (inclusive)
400
409
  const headingAriaLevel =
401
410
  headingElement.attributes["aria-level"]?.nodeValue || "2";
402
- const isH2 = headingAriaLevel === "2";
411
+ const headingLevel = Number.parseInt(headingAriaLevel, 10) || 2;
412
+ const matchesLevel =
413
+ headingLevel >= minLevel && headingLevel <= maxLevel;
403
414
 
404
- if (isH2) {
415
+ if (matchesLevel) {
405
416
  const tocItem = {
406
417
  anchor: `#${headingElement.hash}`,
407
418
  id: headingElement.id,
408
- label: headingElement.header
419
+ label: headingElement.header,
420
+ level: headingLevel
409
421
  };
410
422
  tocOptions.push(tocItem);
411
423
  this.tocOptionIdsSet.add(headingElement.id);