@m3e/web 2.5.6 → 2.5.8
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/dist/all.js +3844 -911
- package/dist/all.js.map +1 -1
- package/dist/all.min.js +120 -57
- package/dist/all.min.js.map +1 -1
- package/dist/card.js +2 -2
- package/dist/card.js.map +1 -1
- package/dist/card.min.js +1 -1
- package/dist/card.min.js.map +1 -1
- package/dist/content-pane.js +1 -1
- package/dist/content-pane.js.map +1 -1
- package/dist/content-pane.min.js +1 -1
- package/dist/content-pane.min.js.map +1 -1
- package/dist/core.js +20 -4
- package/dist/core.js.map +1 -1
- package/dist/core.min.js +1 -1
- package/dist/core.min.js.map +1 -1
- package/dist/css-custom-data.json +307 -292
- package/dist/custom-elements.json +2749 -2542
- package/dist/drawer-container.js +13 -7
- package/dist/drawer-container.js.map +1 -1
- package/dist/drawer-container.min.js +1 -1
- package/dist/drawer-container.min.js.map +1 -1
- package/dist/html-custom-data.json +105 -105
- package/dist/loading-indicator.js +8 -8
- package/dist/loading-indicator.js.map +1 -1
- package/dist/loading-indicator.min.js +1 -1
- package/dist/loading-indicator.min.js.map +1 -1
- package/dist/slide-group.js +6 -1
- package/dist/slide-group.js.map +1 -1
- package/dist/slide-group.min.js +1 -1
- package/dist/slide-group.min.js.map +1 -1
- package/dist/snackbar.js +2 -2
- package/dist/snackbar.js.map +1 -1
- package/dist/snackbar.min.js +1 -1
- package/dist/snackbar.min.js.map +1 -1
- package/dist/src/card/styles/CardStyle.d.ts.map +1 -1
- package/dist/src/content-pane/ContentPaneElement.d.ts.map +1 -1
- package/dist/src/core/shared/controllers/ScrollController.d.ts.map +1 -1
- package/dist/src/drawer-container/DrawerContainerElement.d.ts.map +1 -1
- package/dist/src/drawer-container/DrawerToggleElement.d.ts.map +1 -1
- package/dist/src/loading-indicator/LoadingIndicatorElement.d.ts +1 -1
- package/dist/src/loading-indicator/LoadingIndicatorElement.d.ts.map +1 -1
- package/dist/src/slide-group/SlideGroupElement.d.ts.map +1 -1
- package/dist/src/snackbar/SnackbarElement.d.ts.map +1 -1
- package/dist/src/tabs/TabsElement.d.ts +2 -1
- package/dist/src/tabs/TabsElement.d.ts.map +1 -1
- package/dist/src/theme/ThemeElement.d.ts.map +1 -1
- package/dist/src/toc/TocElement.d.ts +4 -0
- package/dist/src/toc/TocElement.d.ts.map +1 -1
- package/dist/tabs.js +186 -15
- package/dist/tabs.js.map +1 -1
- package/dist/tabs.min.js +1 -1
- package/dist/tabs.min.js.map +1 -1
- package/dist/theme.js +3564 -846
- package/dist/theme.js.map +1 -1
- package/dist/theme.min.js +94 -31
- package/dist/theme.min.js.map +1 -1
- package/dist/toc.js +23 -6
- package/dist/toc.js.map +1 -1
- package/dist/toc.min.js +1 -1
- package/dist/toc.min.js.map +1 -1
- package/package.json +2 -2
package/dist/toc.js
CHANGED
|
@@ -152,6 +152,9 @@ var _M3eTocElement_instances, _M3eTocElement_ignoreScroll, _M3eTocElement_select
|
|
|
152
152
|
* @attr max-depth - The maximum depth of the table of contents.
|
|
153
153
|
*
|
|
154
154
|
* @cssprop --m3e-toc-width - Width of the table of contents.
|
|
155
|
+
* @cssprop --m3e-toc-container-color - Background color of the table of contents container.
|
|
156
|
+
* @cssprop --m3e-toc-container-padding-inline - Inline padding of the table of contents container.
|
|
157
|
+
* @cssprop --m3e-toc-container-padding-block - Block padding of the table of contents container.
|
|
155
158
|
* @cssprop --m3e-toc-item-shape - Border radius of TOC items and active indicator.
|
|
156
159
|
* @cssprop --m3e-toc-active-indicator-color - Border color of the active indicator.
|
|
157
160
|
* @cssprop --m3e-toc-active-indicator-animation-duration - Animation duration for the active indicator.
|
|
@@ -186,10 +189,23 @@ let M3eTocElement = class M3eTocElement extends HtmlFor(AttachInternals(Role(Lit
|
|
|
186
189
|
this._activeIndicator.style.height = `0px`;
|
|
187
190
|
this._activeIndicator.style.visibility = "hidden";
|
|
188
191
|
} else {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
192
|
+
const scrollContainer = this._scrollContainer;
|
|
193
|
+
if (item === __classPrivateFieldGet(this, _M3eTocElement_selectionManager, "f").items[0]) {
|
|
194
|
+
scrollContainer.scrollTo({
|
|
195
|
+
top: 0,
|
|
196
|
+
behavior: "smooth"
|
|
197
|
+
});
|
|
198
|
+
} else if (item === __classPrivateFieldGet(this, _M3eTocElement_selectionManager, "f").items[__classPrivateFieldGet(this, _M3eTocElement_selectionManager, "f").items.length - 1]) {
|
|
199
|
+
scrollContainer.scrollTo({
|
|
200
|
+
top: scrollContainer.scrollHeight - scrollContainer.clientHeight,
|
|
201
|
+
behavior: "smooth"
|
|
202
|
+
});
|
|
203
|
+
} else {
|
|
204
|
+
scrollIntoViewIfNeeded(item, this._scrollContainer, {
|
|
205
|
+
block: "nearest",
|
|
206
|
+
behavior: "smooth"
|
|
207
|
+
});
|
|
208
|
+
}
|
|
193
209
|
this._activeIndicator.style.top = `${item.offsetTop}px`;
|
|
194
210
|
this._activeIndicator.style.height = `${item.clientHeight}px`;
|
|
195
211
|
this._activeIndicator.style.visibility = item.clientHeight == 0 ? "hidden" : "";
|
|
@@ -293,7 +309,7 @@ let M3eTocElement = class M3eTocElement extends HtmlFor(AttachInternals(Role(Lit
|
|
|
293
309
|
}
|
|
294
310
|
/** @inheritdoc */
|
|
295
311
|
render() {
|
|
296
|
-
return html`<div class="header"><div class="overline"><slot name="overline" @slotchange="${__classPrivateFieldGet(this, _M3eTocElement_instances, "m", _M3eTocElement_handleOverlineSlotChange)}"></slot></div><div class="title"><slot name="title" @slotchange="${__classPrivateFieldGet(this, _M3eTocElement_instances, "m", _M3eTocElement_handleTitleSlotChange)}"></slot></div></div><slot></slot><ul class="list">${this._toc.map(x => __classPrivateFieldGet(this, _M3eTocElement_instances, "m", _M3eTocElement_renderNode).call(this, x))}</ul><div class="active-indicator" aria-hidden="true"></div>`;
|
|
312
|
+
return html`<div class="base"><div class="scroll-container"><div class="header"><div class="overline"><slot name="overline" @slotchange="${__classPrivateFieldGet(this, _M3eTocElement_instances, "m", _M3eTocElement_handleOverlineSlotChange)}"></slot></div><div class="title"><slot name="title" @slotchange="${__classPrivateFieldGet(this, _M3eTocElement_instances, "m", _M3eTocElement_handleTitleSlotChange)}"></slot></div></div><slot></slot><ul class="list">${this._toc.map(x => __classPrivateFieldGet(this, _M3eTocElement_instances, "m", _M3eTocElement_renderNode).call(this, x))}</ul><div class="active-indicator" aria-hidden="true"></div></div></div>`;
|
|
297
313
|
}
|
|
298
314
|
/** @private */
|
|
299
315
|
_updateToc() {
|
|
@@ -330,7 +346,7 @@ _M3eTocElement_generateToc = function _M3eTocElement_generateToc() {
|
|
|
330
346
|
this._toc = this.control ? TocGenerator.generate(this.control, Math.max(1, Math.min(this.maxDepth, 6))) : [];
|
|
331
347
|
};
|
|
332
348
|
/** The styles of the element. */
|
|
333
|
-
M3eTocElement.styles = css`:host { display: inline-block; position: relative; overflow-y: auto; scrollbar-width: ${DesignToken.scrollbar.thinWidth}; scrollbar-color: ${DesignToken.scrollbar.color};
|
|
349
|
+
M3eTocElement.styles = css`:host { display: inline-block; width: calc(var(--m3e-toc-width, 9.75rem)); } .base { border-radius: var(--m3e-toc-container-shape, ${DesignToken.shape.corner.none}); box-sizing: border-box; overflow: hidden; height: 100%; width: 100%; } .scroll-container { height: inherit; width: inherit; box-sizing: inherit; background-color: var(--m3e-toc-container-color, transparent); border-radius: inherit; padding-inline: var(--m3e-toc-container-padding-inline, 0px); padding-block: var(--m3e-toc-container-padding-block, 0px); position: relative; overflow-y: auto; overflow-x: hidden; scrollbar-width: ${DesignToken.scrollbar.thinWidth}; scrollbar-color: ${DesignToken.scrollbar.color}; } ul { list-style: none; padding-inline-start: unset; margin-block-start: unset; margin-block-end: unset; } ul, li { display: flex; flex-direction: column; align-items: stretch; } m3e-toc-item { flex: none; } .active-indicator { position: absolute; pointer-events: none; box-sizing: border-box; left: var(--m3e-toc-container-padding-inline, 0px); right: var(--m3e-toc-container-padding-inline, 0px); border-radius: var(--m3e-toc-item-shape, ${DesignToken.shape.corner.largeIncreased}); border: 1px solid var(--m3e-toc-active-indicator-color, ${DesignToken.color.outline}); transition: ${unsafeCSS(`visibility var(--m3e-toc-active-indicator-animation-duration, ${DesignToken.motion.duration.long1})
|
|
334
350
|
${DesignToken.motion.easing.standard},
|
|
335
351
|
height var(--m3e-toc-active-indicator-animation-duration, ${DesignToken.motion.duration.long1})
|
|
336
352
|
${DesignToken.motion.easing.standard},
|
|
@@ -338,6 +354,7 @@ M3eTocElement.styles = css`:host { display: inline-block; position: relative; ov
|
|
|
338
354
|
${DesignToken.motion.easing.standard}`)}; } .header { display: flex; flex-direction: column; align-items: stretch; padding-inline-start: var(--m3e-toc-item-padding, 1rem); padding-block-end: var(--m3e-toc-header-space, 0.5rem); row-gap: var(--m3e-toc-header-space, 0.5rem); } .overline { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-clamp: 2; } :host(:not(:is(:state(--with-overline), :--with-overline))) .overline, :host(:not(:is(:state(--with-title), :--with-title))) .title, :host(:not(:is(:state(--with-overline), :--with-overline)):not(:is(:state(--with-title), :--with-title))) .header { display: none; } ::slotted([slot="overline"]) { font-size: var(--m3e-toc-overline-font-size, ${DesignToken.typescale.standard.label.small.fontSize}); font-weight: var(--m3e-toc-overline-font-weight, ${DesignToken.typescale.standard.label.small.fontWeight}); line-height: var(--m3e-toc-overline-line-height, ${DesignToken.typescale.standard.label.small.lineHeight}); letter-spacing: var(--m3e-toc-overline-tracking, ${DesignToken.typescale.standard.label.small.tracking}); color: var(--m3e-toc-overline-color, ${DesignToken.color.onSurfaceVariant}); } ::slotted([slot="title"]) { font-size: var(--m3e-toc-title-font-size, ${DesignToken.typescale.standard.headline.small.fontSize}); font-weight: var(--m3e-toc-title-font-weight, ${DesignToken.typescale.standard.headline.small.fontWeight}); line-height: var(--m3e-toc-title-line-height, ${DesignToken.typescale.standard.headline.small.lineHeight}); letter-spacing: var(--m3e-toc-title-tracking, ${DesignToken.typescale.standard.headline.small.tracking}); color: var(--m3e-toc-title-color, ${DesignToken.color.onSurface}); } :host(:is(:state(--no-animate), :--no-animate)) .active-indicator { transition: none; } @media (prefers-reduced-motion) { .active-indicator { transition: none; } }`;
|
|
339
355
|
__decorate([state()], M3eTocElement.prototype, "_toc", void 0);
|
|
340
356
|
__decorate([query(".active-indicator")], M3eTocElement.prototype, "_activeIndicator", void 0);
|
|
357
|
+
__decorate([query(".scroll-container")], M3eTocElement.prototype, "_scrollContainer", void 0);
|
|
341
358
|
__decorate([property({
|
|
342
359
|
attribute: "max-depth",
|
|
343
360
|
type: Number
|
package/dist/toc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toc.js","sources":["../../src/toc/TocItemElement.ts","../../src/toc/TocGenerator.ts","../../src/toc/TocElement.ts"],"sourcesContent":["import { css, CSSResultGroup, html, LitElement, PropertyValues, unsafeCSS } from \"lit\";\r\nimport { query, state } from \"lit/decorators.js\";\r\n\r\nimport {\r\n AttachInternals,\r\n customElement,\r\n DesignToken,\r\n Disabled,\r\n M3eStateLayerElement,\r\n Role,\r\n Selected,\r\n} from \"@m3e/web/core\";\r\n\r\nimport { TocNode } from \"./TocGenerator\";\r\n\r\n/**\r\n * An item in a table of contents.\r\n * @tag m3e-toc-item\r\n *\r\n * @slot - Renders the label of the item.\r\n *\r\n * @attr disabled - A value indicating whether the element is disabled.\r\n *\r\n * @fires click - Dispatched when the element is clicked.\r\n *\r\n * @cssprop --m3e-toc-item-shape - Border radius of the TOC item.\r\n * @cssprop --m3e-toc-item-padding-block - Block padding for the TOC item.\r\n * @cssprop --m3e-toc-item-padding - Inline padding for the TOC item.\r\n * @cssprop --m3e-toc-item-inset - Indentation per level for the TOC item.\r\n * @cssprop --m3e-toc-active-indicator-animation-duration - Animation duration for the active indicator.\r\n * @cssprop --m3e-toc-item-font-size - Font size for unselected items.\r\n * @cssprop --m3e-toc-item-font-weight - Font weight for unselected items.\r\n * @cssprop --m3e-toc-item-line-height - Line height for unselected items.\r\n * @cssprop --m3e-toc-item-tracking - Letter spacing for unselected items.\r\n * @cssprop --m3e-toc-item-color - Text color for unselected items.\r\n * @cssprop --m3e-toc-item-selected-font-size - Font size for selected items.\r\n * @cssprop --m3e-toc-item-selected-font-weight - Font weight for selected items.\r\n * @cssprop --m3e-toc-item-selected-line-height - Line height for selected items.\r\n * @cssprop --m3e-toc-item-selected-tracking - Letter spacing for selected items.\r\n * @cssprop --m3e-toc-item-selected-color - Text color for selected items.\r\n */\r\n@customElement(\"m3e-toc-item\")\r\nexport class M3eTocItemElement extends Selected(Disabled(AttachInternals(Role(LitElement, \"link\")))) {\r\n /** The styles of the element. */\r\n static override styles: CSSResultGroup = css`\r\n :host {\r\n display: inline-block;\r\n position: relative;\r\n user-select: none;\r\n outline: none;\r\n border-radius: var(--m3e-toc-item-shape, ${DesignToken.shape.corner.largeIncreased});\r\n padding-block: var(--m3e-toc-item-padding-block, 0.5rem);\r\n -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\r\n }\r\n :host(:not(:disabled)) {\r\n cursor: pointer;\r\n }\r\n .base {\r\n padding-inline-start: calc(\r\n var(--m3e-toc-item-padding, 1rem) + calc(var(--m3e-toc-item-inset, 0.75rem) * var(--_level, 0))\r\n );\r\n padding-inline-end: var(--m3e-toc-item-padding, 1rem);\r\n transition: ${unsafeCSS(\r\n `color var(--m3e-toc-active-indicator-animation-duration, ${DesignToken.motion.duration.long1}) ${DesignToken.motion.easing.standard}`,\r\n )};\r\n }\r\n :host(:not([selected])) {\r\n font-size: var(--m3e-toc-item-font-size, ${DesignToken.typescale.standard.body.large.fontSize});\r\n font-weight: var(--m3e-toc-item-font-weight, ${DesignToken.typescale.standard.body.large.fontWeight});\r\n line-height: var(--m3e-toc-item-line-height, ${DesignToken.typescale.standard.body.large.lineHeight});\r\n letter-spacing: var(--m3e-toc-item-tracking, ${DesignToken.typescale.standard.body.large.tracking});\r\n color: var(--m3e-toc-item-color, ${DesignToken.color.onSurfaceVariant});\r\n }\r\n :host([selected]) {\r\n font-size: var(--m3e-toc-item-selected-font-size, ${DesignToken.typescale.emphasized.body.large.fontSize});\r\n font-weight: var(--m3e-toc-item-selected-font-weight, ${DesignToken.typescale.emphasized.body.large.fontWeight});\r\n line-height: var(--m3e-toc-item-selected-line-height, ${DesignToken.typescale.emphasized.body.large.lineHeight});\r\n letter-spacing: var(--m3e-toc-item-selected-tracking, ${DesignToken.typescale.emphasized.body.large.tracking});\r\n color: var(--m3e-toc-item-selected-color, ${DesignToken.color.onSurface});\r\n }\r\n .base {\r\n justify-content: unset;\r\n }\r\n .state-layer {\r\n --m3e-state-layer-focus-opacity: 0;\r\n }\r\n @media (prefers-reduced-motion) {\r\n .base {\r\n transition: none;\r\n }\r\n }\r\n `;\r\n\r\n /** @private */ @query(\".base\") private readonly _base?: HTMLElement;\r\n /** @private */ @query(\".state-layer\") private readonly _stateLayer?: M3eStateLayerElement;\r\n /** @internal */ @state() node?: TocNode;\r\n\r\n /** @internal */\r\n protected override update(changedProperties: PropertyValues<this>): void {\r\n super.update(changedProperties);\r\n\r\n if (changedProperties.has(\"selected\")) {\r\n this.ariaSelected = null;\r\n this.ariaCurrent = this.selected ? \"true\" : null;\r\n }\r\n\r\n if (changedProperties.has(\"node\")) {\r\n if (this.node) {\r\n this._base?.style.setProperty(\"--_level\", `${this.node.level - 1}`);\r\n } else {\r\n this._base?.style.removeProperty(\"--_level\");\r\n }\r\n }\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override firstUpdated(_changedProperties: PropertyValues<this>): void {\r\n super.firstUpdated(_changedProperties);\r\n this._stateLayer?.attach(this);\r\n }\r\n\r\n /** @inheritdoc */\r\n override render(): unknown {\r\n return html`<m3e-state-layer class=\"state-layer\"></m3e-state-layer>\r\n <div class=\"base\"><slot></slot></div>`;\r\n }\r\n}\r\n\r\ndeclare global {\r\n interface HTMLElementTagNameMap {\r\n \"m3e-toc-item\": M3eTocItemElement;\r\n }\r\n}\r\n","import { getTextContent, guid } from \"@m3e/web/core\";\r\n\r\n/** A node in a table of contents. */\r\nexport interface TocNode {\r\n /** An opaque identifier that uniquely identifies the node. */\r\n id: string;\r\n\r\n /** The level of the node. */\r\n level: number;\r\n\r\n /** The text to display for the node. */\r\n label: string;\r\n\r\n /** The element of the node. */\r\n element: HTMLElement;\r\n\r\n /** The child nodes. */\r\n nodes: TocNode[];\r\n}\r\n\r\n/** Provides functionality used to generate a table of contents used for in-page navigation. */\r\nexport class TocGenerator {\r\n /**\r\n * Generates nodes from which to construct a table of contents for in-page navigation.\r\n * @param {HTMLElement} element The element for which to generate a table of contents.\r\n * @param {number} [maxDepth=6] The maximum depth of the table of contents.\r\n * @returns {Array<TocNode>} The top-level nodes of the table of contents.\r\n */\r\n static generate(element: HTMLElement, maxDepth: number = 6): Array<TocNode> {\r\n const maxLevel = 6;\r\n let topLevel = maxLevel;\r\n const nodes = new Array<TocNode>();\r\n element\r\n .querySelectorAll<HTMLElement>(\r\n \"h1:not([m3e-toc-ignore]),h2:not([m3e-toc-ignore]),h3:not([m3e-toc-ignore]),h4:not([m3e-toc-ignore]),h5:not([m3e-toc-ignore]),h6:not([m3e-toc-ignore]),m3e-heading[level]:not([m3e-toc-ignore])\",\r\n )\r\n .forEach((element) => {\r\n const level = TocGenerator.#getHeaderLevel(element);\r\n topLevel = Math.min(level, topLevel);\r\n nodes.push({\r\n id: element.id || guid(),\r\n element,\r\n level,\r\n label: getTextContent(element, true),\r\n nodes: new Array<TocNode>(),\r\n });\r\n });\r\n\r\n for (let level = topLevel + maxDepth - 1; level > topLevel; level--) {\r\n for (let i = 0; i < nodes.length; i++) {\r\n const node = nodes[i];\r\n if (node.level === level) {\r\n for (let j = i; j >= 0; j--) {\r\n const prev = nodes[j];\r\n if (prev.level < level) {\r\n prev.nodes.push(node);\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n nodes.forEach((x) => (x.level -= topLevel - 1));\r\n return nodes.filter((x) => x.level === 1);\r\n }\r\n\r\n /** @internal */\r\n static #getHeaderLevel(element: HTMLElement): number {\r\n return element.tagName.startsWith(\"H\")\r\n ? parseInt(element.tagName.substring(1))\r\n : parseInt(element.getAttribute(\"level\") ?? \"0\");\r\n }\r\n}\r\n","import { css, CSSResultGroup, html, LitElement, nothing, PropertyValues, unsafeCSS } from \"lit\";\r\nimport { property, query, state } from \"lit/decorators.js\";\r\n\r\nimport {\r\n AttachInternals,\r\n customElement,\r\n debounce,\r\n DesignToken,\r\n hasAssignedNodes,\r\n hasCustomState,\r\n HtmlFor,\r\n IntersectionController,\r\n MutationController,\r\n Role,\r\n ScrollController,\r\n scrollIntoViewIfNeeded,\r\n setCustomState,\r\n} from \"@m3e/web/core\";\r\n\r\nimport { SelectionManager } from \"@m3e/web/core/a11y\";\r\n\r\nimport { M3eTocItemElement } from \"./TocItemElement\";\r\nimport { TocGenerator, TocNode } from \"./TocGenerator\";\r\n\r\n/**\r\n * A table of contents that provides in-page scroll navigation.\r\n *\r\n * @description\r\n * The `m3e-toc` component generates a hierarchical table of contents for in-page navigation.\r\n * It automatically detects headings or sections in a target element, builds a navigable list,\r\n * and highlights the active section as the user scrolls. The component supports custom header\r\n * slots, depth limiting, smooth scrolling, and extensive theming via CSS custom properties.\r\n *\r\n * To exclude a heading from the generated table of contents, add the `m3e-toc-ignore` attribute\r\n * to that heading element.\r\n *\r\n * @example\r\n * ```html\r\n * <m3e-toc for=\"content\" max-depth=\"3\">\r\n * <span slot=\"overline\">Contents</span>\r\n * <span slot=\"title\">Documentation</span>\r\n * </m3e-toc>\r\n * <div id=\"content\">\r\n * <h2>Introduction</h2>\r\n * <h2>Getting Started</h2>\r\n * <h3>Installation</h3>\r\n * <h3>Usage</h3>\r\n * <h2>API Reference</h2>\r\n * </div>\r\n * ```\r\n *\r\n * @tag m3e-toc\r\n *\r\n * @slot - Renders content between the header and items.\r\n * @slot overline - Renders the overline of the table of contents.\r\n * @slot title - Renders the title of the table of contents.\r\n *\r\n * @attr for - The identifier of the interactive control to which this element is attached.\r\n * @attr max-depth - The maximum depth of the table of contents.\r\n *\r\n * @cssprop --m3e-toc-width - Width of the table of contents.\r\n * @cssprop --m3e-toc-item-shape - Border radius of TOC items and active indicator.\r\n * @cssprop --m3e-toc-active-indicator-color - Border color of the active indicator.\r\n * @cssprop --m3e-toc-active-indicator-animation-duration - Animation duration for the active indicator.\r\n * @cssprop --m3e-toc-item-padding - Inline padding for TOC items and header.\r\n * @cssprop --m3e-toc-header-space - Block space below and between header elements.\r\n * @cssprop --m3e-toc-overline-font-size - Font size for the overline slot.\r\n * @cssprop --m3e-toc-overline-font-weight - Font weight for the overline slot.\r\n * @cssprop --m3e-toc-overline-line-height - Line height for the overline slot.\r\n * @cssprop --m3e-toc-overline-tracking - Letter spacing for the overline slot.\r\n * @cssprop --m3e-toc-overline-color - Text color for the overline slot.\r\n * @cssprop --m3e-toc-title-font-size - Font size for the title slot.\r\n * @cssprop --m3e-toc-title-font-weight - Font weight for the title slot.\r\n * @cssprop --m3e-toc-title-line-height - Line height for the title slot.\r\n * @cssprop --m3e-toc-title-tracking - Letter spacing for the title slot.\r\n * @cssprop --m3e-toc-title-color - Text color for the title slot.\r\n */\r\n@customElement(\"m3e-toc\")\r\nexport class M3eTocElement extends HtmlFor(AttachInternals(Role(LitElement, \"navigation\"))) {\r\n /** The styles of the element. */\r\n static override styles: CSSResultGroup = css`\r\n :host {\r\n display: inline-block;\r\n position: relative;\r\n overflow-y: auto;\r\n scrollbar-width: ${DesignToken.scrollbar.thinWidth};\r\n scrollbar-color: ${DesignToken.scrollbar.color};\r\n width: var(--m3e-toc-width, 9.75rem);\r\n }\r\n ul {\r\n list-style: none;\r\n padding-inline-start: unset;\r\n margin-block-start: unset;\r\n margin-block-end: unset;\r\n }\r\n ul,\r\n li {\r\n display: flex;\r\n flex-direction: column;\r\n align-items: stretch;\r\n }\r\n m3e-toc-item {\r\n flex: none;\r\n }\r\n .active-indicator {\r\n position: absolute;\r\n pointer-events: none;\r\n box-sizing: border-box;\r\n left: 0;\r\n right: 0;\r\n\r\n border-radius: var(--m3e-toc-item-shape, ${DesignToken.shape.corner.largeIncreased});\r\n border: 1px solid var(--m3e-toc-active-indicator-color, ${DesignToken.color.outline});\r\n transition: ${unsafeCSS(`visibility var(--m3e-toc-active-indicator-animation-duration, ${DesignToken.motion.duration.long1})\r\n ${DesignToken.motion.easing.standard},\r\n height var(--m3e-toc-active-indicator-animation-duration, ${DesignToken.motion.duration.long1})\r\n ${DesignToken.motion.easing.standard},\r\n top var(--m3e-toc-active-indicator-animation-duration, ${DesignToken.motion.duration.long1})\r\n ${DesignToken.motion.easing.standard}`)};\r\n }\r\n .header {\r\n display: flex;\r\n flex-direction: column;\r\n align-items: stretch;\r\n padding-inline-start: var(--m3e-toc-item-padding, 1rem);\r\n padding-block-end: var(--m3e-toc-header-space, 0.5rem);\r\n row-gap: var(--m3e-toc-header-space, 0.5rem);\r\n }\r\n .overline {\r\n white-space: nowrap;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\r\n }\r\n .title {\r\n display: -webkit-box;\r\n -webkit-line-clamp: 2;\r\n -webkit-box-orient: vertical;\r\n overflow: hidden;\r\n line-clamp: 2;\r\n }\r\n :host(:not(:is(:state(--with-overline), :--with-overline))) .overline,\r\n :host(:not(:is(:state(--with-title), :--with-title))) .title,\r\n :host(:not(:is(:state(--with-overline), :--with-overline)):not(:is(:state(--with-title), :--with-title))) .header {\r\n display: none;\r\n }\r\n ::slotted([slot=\"overline\"]) {\r\n font-size: var(--m3e-toc-overline-font-size, ${DesignToken.typescale.standard.label.small.fontSize});\r\n font-weight: var(--m3e-toc-overline-font-weight, ${DesignToken.typescale.standard.label.small.fontWeight});\r\n line-height: var(--m3e-toc-overline-line-height, ${DesignToken.typescale.standard.label.small.lineHeight});\r\n letter-spacing: var(--m3e-toc-overline-tracking, ${DesignToken.typescale.standard.label.small.tracking});\r\n color: var(--m3e-toc-overline-color, ${DesignToken.color.onSurfaceVariant});\r\n }\r\n ::slotted([slot=\"title\"]) {\r\n font-size: var(--m3e-toc-title-font-size, ${DesignToken.typescale.standard.headline.small.fontSize});\r\n font-weight: var(--m3e-toc-title-font-weight, ${DesignToken.typescale.standard.headline.small.fontWeight});\r\n line-height: var(--m3e-toc-title-line-height, ${DesignToken.typescale.standard.headline.small.lineHeight});\r\n letter-spacing: var(--m3e-toc-title-tracking, ${DesignToken.typescale.standard.headline.small.tracking});\r\n color: var(--m3e-toc-title-color, ${DesignToken.color.onSurface});\r\n }\r\n :host(:is(:state(--no-animate), :--no-animate)) .active-indicator {\r\n transition: none;\r\n }\r\n @media (prefers-reduced-motion) {\r\n .active-indicator {\r\n transition: none;\r\n }\r\n }\r\n `;\r\n\r\n /** @private */ @state() private _toc: Array<TocNode> = [];\r\n /** @private */ @query(\".active-indicator\") private readonly _activeIndicator!: HTMLElement;\r\n /** @private */ #ignoreScroll = false;\r\n\r\n /** @private */ readonly #selectionManager = new SelectionManager<M3eTocItemElement>()\r\n .withHomeAndEnd()\r\n .withVerticalOrientation()\r\n .disableRovingTabIndex()\r\n .onSelectedItemsChange(() => {\r\n if (this._activeIndicator) {\r\n const item = this.#selectionManager.selectedItems[0];\r\n if (!item) {\r\n setCustomState(this, \"--no-animate\", true);\r\n this._activeIndicator.style.top = `0px`;\r\n this._activeIndicator.style.height = `0px`;\r\n this._activeIndicator.style.visibility = \"hidden\";\r\n } else {\r\n scrollIntoViewIfNeeded(item, this, { block: \"nearest\", behavior: \"smooth\" });\r\n this._activeIndicator.style.top = `${item.offsetTop}px`;\r\n this._activeIndicator.style.height = `${item.clientHeight}px`;\r\n this._activeIndicator.style.visibility = item.clientHeight == 0 ? \"hidden\" : \"\";\r\n\r\n if (hasCustomState(this, \"--no-animate\")) {\r\n setTimeout(() => setCustomState(this, \"--no-animate\", false), 40);\r\n }\r\n }\r\n }\r\n });\r\n\r\n /** @private */\r\n readonly #intersectionController = new IntersectionController(this, {\r\n target: null,\r\n callback: (entries) => {\r\n if (!this.control || this.#ignoreScroll) return;\r\n\r\n const targetOffset = this.control.scrollTop;\r\n let closestElement: HTMLElement | null = null;\r\n let closestDistance = Number.POSITIVE_INFINITY;\r\n\r\n entries\r\n .filter((x) => x.isIntersecting)\r\n .map((x) => <HTMLElement>x.target)\r\n .forEach((item) => {\r\n const offsetTop = item.offsetTop;\r\n const distance = Math.abs(offsetTop - targetOffset);\r\n if (distance < closestDistance) {\r\n closestDistance = distance;\r\n closestElement = item;\r\n }\r\n });\r\n\r\n if (closestElement) {\r\n const item = this.#selectionManager.items.find((x) => x.node?.element === closestElement);\r\n if (item) {\r\n this.#selectionManager.select(item);\r\n }\r\n }\r\n },\r\n });\r\n\r\n /** @private */\r\n readonly #scrollController = new ScrollController(this, {\r\n target: null,\r\n callback: () => (this.#ignoreScroll = false),\r\n debounce: true,\r\n });\r\n\r\n /** @private */\r\n readonly #mutationController = new MutationController(this, {\r\n target: null,\r\n config: {\r\n childList: true,\r\n subtree: true,\r\n },\r\n callback: () => this._updateToc(),\r\n });\r\n\r\n /**\r\n * The maximum depth of the table of contents.\r\n * @default 2\r\n */\r\n @property({ attribute: \"max-depth\", type: Number }) maxDepth = 2;\r\n\r\n /** @inheritdoc */\r\n override attach(control: HTMLElement): void {\r\n super.attach(control);\r\n this.#mutationController.observe(control);\r\n this.#scrollController.observe(control);\r\n this.#generateToc();\r\n }\r\n\r\n /** @inheritdoc */\r\n override detach(): void {\r\n if (this.control) {\r\n this.#mutationController.unobserve(this.control);\r\n this.#scrollController.unobserve(this.control);\r\n }\r\n super.detach();\r\n this.#generateToc();\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override willUpdate(changedProperties: PropertyValues<this>): void {\r\n super.willUpdate(changedProperties);\r\n\r\n if (changedProperties.has(\"maxDepth\")) {\r\n this.#generateToc();\r\n }\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override updated(_changedProperties: PropertyValues): void {\r\n super.updated(_changedProperties);\r\n\r\n if (_changedProperties.has(\"_toc\")) {\r\n const { added, removed } = this.#selectionManager.setItems([\r\n ...(this.shadowRoot?.querySelectorAll(\"m3e-toc-item\") ?? []),\r\n ]);\r\n\r\n if (!this.#selectionManager.activeItem) {\r\n setCustomState(this, \"--no-animate\", true);\r\n this.#selectionManager.updateActiveItem(added.find((x) => !x.disabled));\r\n }\r\n\r\n for (const item of added) {\r\n if (item.node) {\r\n this.#intersectionController.observe(item.node.element);\r\n }\r\n }\r\n\r\n for (const item of removed) {\r\n if (item.node) {\r\n this.#intersectionController.unobserve(item.node.element);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override render(): unknown {\r\n return html`<div class=\"header\">\r\n <div class=\"overline\">\r\n <slot name=\"overline\" @slotchange=\"${this.#handleOverlineSlotChange}\"></slot>\r\n </div>\r\n <div class=\"title\">\r\n <slot name=\"title\" @slotchange=\"${this.#handleTitleSlotChange}\"></slot>\r\n </div>\r\n </div>\r\n <slot></slot>\r\n <ul class=\"list\">\r\n ${this._toc.map((x) => this.#renderNode(x))}\r\n </ul>\r\n <div class=\"active-indicator\" aria-hidden=\"true\"></div>`;\r\n }\r\n\r\n /** @private */\r\n #renderNode(node: TocNode): unknown {\r\n return html`<li>\r\n <m3e-toc-item tabindex=\"-1\" .node=\"${node}\" @click=\"${this.#handleClick}\">${node.label}</m3e-toc-item>\r\n ${node.nodes.length == 0\r\n ? nothing\r\n : html`<ul>\r\n ${node.nodes.map((x) => this.#renderNode(x))}\r\n </ul>`}\r\n </li>`;\r\n }\r\n\r\n /** @private */\r\n #handleOverlineSlotChange(e: Event): void {\r\n setCustomState(this, \"--with-overline\", hasAssignedNodes(<HTMLSlotElement>e.target));\r\n }\r\n\r\n /** @private */\r\n #handleTitleSlotChange(e: Event): void {\r\n setCustomState(this, \"--with-title\", hasAssignedNodes(<HTMLSlotElement>e.target));\r\n }\r\n\r\n /** @private */\r\n #handleClick(e: Event): void {\r\n if (e.target instanceof M3eTocItemElement && !e.target.disabled && e.target.node?.element) {\r\n this.#ignoreScroll = true;\r\n e.target.node.element.scrollIntoView({ block: \"start\", behavior: \"smooth\" });\r\n this.#selectionManager.updateActiveItem(e.target);\r\n this.#selectionManager.select(e.target);\r\n }\r\n }\r\n\r\n /** @private */\r\n #generateToc(): void {\r\n this._toc = this.control ? TocGenerator.generate(this.control, Math.max(1, Math.min(this.maxDepth, 6))) : [];\r\n }\r\n\r\n /** @private */\r\n @debounce(40)\r\n private _updateToc(): void {\r\n this.#generateToc();\r\n }\r\n}\r\n\r\ndeclare global {\r\n interface HTMLElementTagNameMap {\r\n \"m3e-toc\": M3eTocElement;\r\n }\r\n}\r\n"],"names":["M3eTocItemElement","Selected","Disabled","AttachInternals","Role","LitElement","update","changedProperties","has","ariaSelected","ariaCurrent","selected","node","_base","style","setProperty","level","removeProperty","firstUpdated","_changedProperties","_stateLayer","attach","render","html","styles","css","DesignToken","shape","corner","largeIncreased","unsafeCSS","motion","duration","long1","easing","standard","typescale","body","large","fontSize","fontWeight","lineHeight","tracking","color","onSurfaceVariant","emphasized","onSurface","__decorate","query","prototype","state","customElement","TocGenerator","generate","element","maxDepth","maxLevel","topLevel","nodes","Array","querySelectorAll","forEach","__classPrivateFieldGet","_a","_TocGenerator_getHeaderLevel","Math","min","push","id","guid","label","getTextContent","i","length","j","prev","x","filter","tagName","startsWith","parseInt","substring","getAttribute","M3eTocElement","HtmlFor","constructor","_toc","_M3eTocElement_ignoreScroll","set","_M3eTocElement_selectionManager","SelectionManager","withHomeAndEnd","withVerticalOrientation","disableRovingTabIndex","onSelectedItemsChange","_activeIndicator","item","selectedItems","setCustomState","top","height","visibility","scrollIntoViewIfNeeded","block","behavior","offsetTop","clientHeight","hasCustomState","setTimeout","_M3eTocElement_intersectionController","IntersectionController","target","callback","entries","control","targetOffset","scrollTop","closestElement","closestDistance","Number","POSITIVE_INFINITY","isIntersecting","map","distance","abs","items","find","select","_M3eTocElement_scrollController","ScrollController","__classPrivateFieldSet","debounce","_M3eTocElement_mutationController","MutationController","config","childList","subtree","_updateToc","observe","_M3eTocElement_instances","_M3eTocElement_generateToc","call","detach","unobserve","willUpdate","updated","added","removed","setItems","shadowRoot","activeItem","updateActiveItem","disabled","_M3eTocElement_handleOverlineSlotChange","_M3eTocElement_handleTitleSlotChange","_M3eTocElement_renderNode","nothing","e","hasAssignedNodes","scrollIntoView","max","scrollbar","thinWidth","outline","small","headline","property","attribute","type"],"mappings":";;;;;;;;;;;AAeA;;;;;;;;;;;;;;;;;;;;;;;;;AAyBG;AAEI,IAAMA,iBAAiB,GAAvB,MAAMA,iBAAkB,SAAQC,QAAQ,CAACC,QAAQ,CAACC,eAAe,CAACC,IAAI,CAACC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;AAuDlG;EACmBC,MAAMA,CAACC,iBAAuC,EAAA;AAC/D,IAAA,KAAK,CAACD,MAAM,CAACC,iBAAiB,CAAC;AAE/B,IAAA,IAAIA,iBAAiB,CAACC,GAAG,CAAC,UAAU,CAAC,EAAE;MACrC,IAAI,CAACC,YAAY,GAAG,IAAI;MACxB,IAAI,CAACC,WAAW,GAAG,IAAI,CAACC,QAAQ,GAAG,MAAM,GAAG,IAAI;AAClD,IAAA;AAEA,IAAA,IAAIJ,iBAAiB,CAACC,GAAG,CAAC,MAAM,CAAC,EAAE;MACjC,IAAI,IAAI,CAACI,IAAI,EAAE;AACb,QAAA,IAAI,CAACC,KAAK,EAAEC,KAAK,CAACC,WAAW,CAAC,UAAU,EAAE,CAAA,EAAG,IAAI,CAACH,IAAI,CAACI,KAAK,GAAG,CAAC,EAAE,CAAC;AACrE,MAAA,CAAC,MAAM;QACL,IAAI,CAACH,KAAK,EAAEC,KAAK,CAACG,cAAc,CAAC,UAAU,CAAC;AAC9C,MAAA;AACF,IAAA;AACF,EAAA;AAEA;EACmBC,YAAYA,CAACC,kBAAwC,EAAA;AACtE,IAAA,KAAK,CAACD,YAAY,CAACC,kBAAkB,CAAC;AACtC,IAAA,IAAI,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,CAAA;AACEF,UAAA,CAAA,CAA5CC,KAAK,CAAC,mBAAmB,CAAC,CAAiD,EAAAmC,aAAA,CAAAlC,SAAA,EAAA,kBAAA,EAAA,MAAA,CAAA;AAgFxCF,UAAA,CAAA,CAAnDuH,QAAQ,CAAC;AAAEC,EAAAA,SAAS,EAAE,WAAW;AAAEC,EAAAA,IAAI,EAAEjD;AAAM,CAAE,CAAC,CAAc,EAAApC,aAAA,CAAAlC,SAAA,EAAA,UAAA,EAAA,MAAA,CAAA;AAiHzDF,UAAA,CAAA,CADPoF,QAAQ,CAAC,EAAE,CAAC,CAGZ,EAAAhD,aAAA,CAAAlC,SAAA,EAAA,YAAA,EAAA,IAAA,CAAA;AA/RUkC,aAAa,GAAApC,UAAA,CAAA,CADzBI,aAAa,CAAC,SAAS,CAAC,CACZ,EAAAgC,aAAa,CAgSzB;;;;"}
|
|
1
|
+
{"version":3,"file":"toc.js","sources":["../../src/toc/TocItemElement.ts","../../src/toc/TocGenerator.ts","../../src/toc/TocElement.ts"],"sourcesContent":["import { css, CSSResultGroup, html, LitElement, PropertyValues, unsafeCSS } from \"lit\";\r\nimport { query, state } from \"lit/decorators.js\";\r\n\r\nimport {\r\n AttachInternals,\r\n customElement,\r\n DesignToken,\r\n Disabled,\r\n M3eStateLayerElement,\r\n Role,\r\n Selected,\r\n} from \"@m3e/web/core\";\r\n\r\nimport { TocNode } from \"./TocGenerator\";\r\n\r\n/**\r\n * An item in a table of contents.\r\n * @tag m3e-toc-item\r\n *\r\n * @slot - Renders the label of the item.\r\n *\r\n * @attr disabled - A value indicating whether the element is disabled.\r\n *\r\n * @fires click - Dispatched when the element is clicked.\r\n *\r\n * @cssprop --m3e-toc-item-shape - Border radius of the TOC item.\r\n * @cssprop --m3e-toc-item-padding-block - Block padding for the TOC item.\r\n * @cssprop --m3e-toc-item-padding - Inline padding for the TOC item.\r\n * @cssprop --m3e-toc-item-inset - Indentation per level for the TOC item.\r\n * @cssprop --m3e-toc-active-indicator-animation-duration - Animation duration for the active indicator.\r\n * @cssprop --m3e-toc-item-font-size - Font size for unselected items.\r\n * @cssprop --m3e-toc-item-font-weight - Font weight for unselected items.\r\n * @cssprop --m3e-toc-item-line-height - Line height for unselected items.\r\n * @cssprop --m3e-toc-item-tracking - Letter spacing for unselected items.\r\n * @cssprop --m3e-toc-item-color - Text color for unselected items.\r\n * @cssprop --m3e-toc-item-selected-font-size - Font size for selected items.\r\n * @cssprop --m3e-toc-item-selected-font-weight - Font weight for selected items.\r\n * @cssprop --m3e-toc-item-selected-line-height - Line height for selected items.\r\n * @cssprop --m3e-toc-item-selected-tracking - Letter spacing for selected items.\r\n * @cssprop --m3e-toc-item-selected-color - Text color for selected items.\r\n */\r\n@customElement(\"m3e-toc-item\")\r\nexport class M3eTocItemElement extends Selected(Disabled(AttachInternals(Role(LitElement, \"link\")))) {\r\n /** The styles of the element. */\r\n static override styles: CSSResultGroup = css`\r\n :host {\r\n display: inline-block;\r\n position: relative;\r\n user-select: none;\r\n outline: none;\r\n border-radius: var(--m3e-toc-item-shape, ${DesignToken.shape.corner.largeIncreased});\r\n padding-block: var(--m3e-toc-item-padding-block, 0.5rem);\r\n -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\r\n }\r\n :host(:not(:disabled)) {\r\n cursor: pointer;\r\n }\r\n .base {\r\n padding-inline-start: calc(\r\n var(--m3e-toc-item-padding, 1rem) + calc(var(--m3e-toc-item-inset, 0.75rem) * var(--_level, 0))\r\n );\r\n padding-inline-end: var(--m3e-toc-item-padding, 1rem);\r\n transition: ${unsafeCSS(\r\n `color var(--m3e-toc-active-indicator-animation-duration, ${DesignToken.motion.duration.long1}) ${DesignToken.motion.easing.standard}`,\r\n )};\r\n }\r\n :host(:not([selected])) {\r\n font-size: var(--m3e-toc-item-font-size, ${DesignToken.typescale.standard.body.large.fontSize});\r\n font-weight: var(--m3e-toc-item-font-weight, ${DesignToken.typescale.standard.body.large.fontWeight});\r\n line-height: var(--m3e-toc-item-line-height, ${DesignToken.typescale.standard.body.large.lineHeight});\r\n letter-spacing: var(--m3e-toc-item-tracking, ${DesignToken.typescale.standard.body.large.tracking});\r\n color: var(--m3e-toc-item-color, ${DesignToken.color.onSurfaceVariant});\r\n }\r\n :host([selected]) {\r\n font-size: var(--m3e-toc-item-selected-font-size, ${DesignToken.typescale.emphasized.body.large.fontSize});\r\n font-weight: var(--m3e-toc-item-selected-font-weight, ${DesignToken.typescale.emphasized.body.large.fontWeight});\r\n line-height: var(--m3e-toc-item-selected-line-height, ${DesignToken.typescale.emphasized.body.large.lineHeight});\r\n letter-spacing: var(--m3e-toc-item-selected-tracking, ${DesignToken.typescale.emphasized.body.large.tracking});\r\n color: var(--m3e-toc-item-selected-color, ${DesignToken.color.onSurface});\r\n }\r\n .base {\r\n justify-content: unset;\r\n }\r\n .state-layer {\r\n --m3e-state-layer-focus-opacity: 0;\r\n }\r\n @media (prefers-reduced-motion) {\r\n .base {\r\n transition: none;\r\n }\r\n }\r\n `;\r\n\r\n /** @private */ @query(\".base\") private readonly _base?: HTMLElement;\r\n /** @private */ @query(\".state-layer\") private readonly _stateLayer?: M3eStateLayerElement;\r\n /** @internal */ @state() node?: TocNode;\r\n\r\n /** @internal */\r\n protected override update(changedProperties: PropertyValues<this>): void {\r\n super.update(changedProperties);\r\n\r\n if (changedProperties.has(\"selected\")) {\r\n this.ariaSelected = null;\r\n this.ariaCurrent = this.selected ? \"true\" : null;\r\n }\r\n\r\n if (changedProperties.has(\"node\")) {\r\n if (this.node) {\r\n this._base?.style.setProperty(\"--_level\", `${this.node.level - 1}`);\r\n } else {\r\n this._base?.style.removeProperty(\"--_level\");\r\n }\r\n }\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override firstUpdated(_changedProperties: PropertyValues<this>): void {\r\n super.firstUpdated(_changedProperties);\r\n this._stateLayer?.attach(this);\r\n }\r\n\r\n /** @inheritdoc */\r\n override render(): unknown {\r\n return html`<m3e-state-layer class=\"state-layer\"></m3e-state-layer>\r\n <div class=\"base\"><slot></slot></div>`;\r\n }\r\n}\r\n\r\ndeclare global {\r\n interface HTMLElementTagNameMap {\r\n \"m3e-toc-item\": M3eTocItemElement;\r\n }\r\n}\r\n","import { getTextContent, guid } from \"@m3e/web/core\";\r\n\r\n/** A node in a table of contents. */\r\nexport interface TocNode {\r\n /** An opaque identifier that uniquely identifies the node. */\r\n id: string;\r\n\r\n /** The level of the node. */\r\n level: number;\r\n\r\n /** The text to display for the node. */\r\n label: string;\r\n\r\n /** The element of the node. */\r\n element: HTMLElement;\r\n\r\n /** The child nodes. */\r\n nodes: TocNode[];\r\n}\r\n\r\n/** Provides functionality used to generate a table of contents used for in-page navigation. */\r\nexport class TocGenerator {\r\n /**\r\n * Generates nodes from which to construct a table of contents for in-page navigation.\r\n * @param {HTMLElement} element The element for which to generate a table of contents.\r\n * @param {number} [maxDepth=6] The maximum depth of the table of contents.\r\n * @returns {Array<TocNode>} The top-level nodes of the table of contents.\r\n */\r\n static generate(element: HTMLElement, maxDepth: number = 6): Array<TocNode> {\r\n const maxLevel = 6;\r\n let topLevel = maxLevel;\r\n const nodes = new Array<TocNode>();\r\n element\r\n .querySelectorAll<HTMLElement>(\r\n \"h1:not([m3e-toc-ignore]),h2:not([m3e-toc-ignore]),h3:not([m3e-toc-ignore]),h4:not([m3e-toc-ignore]),h5:not([m3e-toc-ignore]),h6:not([m3e-toc-ignore]),m3e-heading[level]:not([m3e-toc-ignore])\",\r\n )\r\n .forEach((element) => {\r\n const level = TocGenerator.#getHeaderLevel(element);\r\n topLevel = Math.min(level, topLevel);\r\n nodes.push({\r\n id: element.id || guid(),\r\n element,\r\n level,\r\n label: getTextContent(element, true),\r\n nodes: new Array<TocNode>(),\r\n });\r\n });\r\n\r\n for (let level = topLevel + maxDepth - 1; level > topLevel; level--) {\r\n for (let i = 0; i < nodes.length; i++) {\r\n const node = nodes[i];\r\n if (node.level === level) {\r\n for (let j = i; j >= 0; j--) {\r\n const prev = nodes[j];\r\n if (prev.level < level) {\r\n prev.nodes.push(node);\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n nodes.forEach((x) => (x.level -= topLevel - 1));\r\n return nodes.filter((x) => x.level === 1);\r\n }\r\n\r\n /** @internal */\r\n static #getHeaderLevel(element: HTMLElement): number {\r\n return element.tagName.startsWith(\"H\")\r\n ? parseInt(element.tagName.substring(1))\r\n : parseInt(element.getAttribute(\"level\") ?? \"0\");\r\n }\r\n}\r\n","import { css, CSSResultGroup, html, LitElement, nothing, PropertyValues, unsafeCSS } from \"lit\";\r\nimport { property, query, state } from \"lit/decorators.js\";\r\n\r\nimport {\r\n AttachInternals,\r\n customElement,\r\n debounce,\r\n DesignToken,\r\n hasAssignedNodes,\r\n hasCustomState,\r\n HtmlFor,\r\n IntersectionController,\r\n MutationController,\r\n Role,\r\n ScrollController,\r\n scrollIntoViewIfNeeded,\r\n setCustomState,\r\n} from \"@m3e/web/core\";\r\n\r\nimport { SelectionManager } from \"@m3e/web/core/a11y\";\r\n\r\nimport { M3eTocItemElement } from \"./TocItemElement\";\r\nimport { TocGenerator, TocNode } from \"./TocGenerator\";\r\n\r\n/**\r\n * A table of contents that provides in-page scroll navigation.\r\n *\r\n * @description\r\n * The `m3e-toc` component generates a hierarchical table of contents for in-page navigation.\r\n * It automatically detects headings or sections in a target element, builds a navigable list,\r\n * and highlights the active section as the user scrolls. The component supports custom header\r\n * slots, depth limiting, smooth scrolling, and extensive theming via CSS custom properties.\r\n *\r\n * To exclude a heading from the generated table of contents, add the `m3e-toc-ignore` attribute\r\n * to that heading element.\r\n *\r\n * @example\r\n * ```html\r\n * <m3e-toc for=\"content\" max-depth=\"3\">\r\n * <span slot=\"overline\">Contents</span>\r\n * <span slot=\"title\">Documentation</span>\r\n * </m3e-toc>\r\n * <div id=\"content\">\r\n * <h2>Introduction</h2>\r\n * <h2>Getting Started</h2>\r\n * <h3>Installation</h3>\r\n * <h3>Usage</h3>\r\n * <h2>API Reference</h2>\r\n * </div>\r\n * ```\r\n *\r\n * @tag m3e-toc\r\n *\r\n * @slot - Renders content between the header and items.\r\n * @slot overline - Renders the overline of the table of contents.\r\n * @slot title - Renders the title of the table of contents.\r\n *\r\n * @attr for - The identifier of the interactive control to which this element is attached.\r\n * @attr max-depth - The maximum depth of the table of contents.\r\n *\r\n * @cssprop --m3e-toc-width - Width of the table of contents.\r\n * @cssprop --m3e-toc-container-color - Background color of the table of contents container.\r\n * @cssprop --m3e-toc-container-padding-inline - Inline padding of the table of contents container.\r\n * @cssprop --m3e-toc-container-padding-block - Block padding of the table of contents container.\r\n * @cssprop --m3e-toc-item-shape - Border radius of TOC items and active indicator.\r\n * @cssprop --m3e-toc-active-indicator-color - Border color of the active indicator.\r\n * @cssprop --m3e-toc-active-indicator-animation-duration - Animation duration for the active indicator.\r\n * @cssprop --m3e-toc-item-padding - Inline padding for TOC items and header.\r\n * @cssprop --m3e-toc-header-space - Block space below and between header elements.\r\n * @cssprop --m3e-toc-overline-font-size - Font size for the overline slot.\r\n * @cssprop --m3e-toc-overline-font-weight - Font weight for the overline slot.\r\n * @cssprop --m3e-toc-overline-line-height - Line height for the overline slot.\r\n * @cssprop --m3e-toc-overline-tracking - Letter spacing for the overline slot.\r\n * @cssprop --m3e-toc-overline-color - Text color for the overline slot.\r\n * @cssprop --m3e-toc-title-font-size - Font size for the title slot.\r\n * @cssprop --m3e-toc-title-font-weight - Font weight for the title slot.\r\n * @cssprop --m3e-toc-title-line-height - Line height for the title slot.\r\n * @cssprop --m3e-toc-title-tracking - Letter spacing for the title slot.\r\n * @cssprop --m3e-toc-title-color - Text color for the title slot.\r\n */\r\n@customElement(\"m3e-toc\")\r\nexport class M3eTocElement extends HtmlFor(AttachInternals(Role(LitElement, \"navigation\"))) {\r\n /** The styles of the element. */\r\n static override styles: CSSResultGroup = css`\r\n :host {\r\n display: inline-block;\r\n width: calc(var(--m3e-toc-width, 9.75rem));\r\n }\r\n .base {\r\n border-radius: var(--m3e-toc-container-shape, ${DesignToken.shape.corner.none});\r\n box-sizing: border-box;\r\n overflow: hidden;\r\n height: 100%;\r\n width: 100%;\r\n }\r\n .scroll-container {\r\n height: inherit;\r\n width: inherit;\r\n box-sizing: inherit;\r\n background-color: var(--m3e-toc-container-color, transparent);\r\n border-radius: inherit;\r\n padding-inline: var(--m3e-toc-container-padding-inline, 0px);\r\n padding-block: var(--m3e-toc-container-padding-block, 0px);\r\n position: relative;\r\n overflow-y: auto;\r\n overflow-x: hidden;\r\n scrollbar-width: ${DesignToken.scrollbar.thinWidth};\r\n scrollbar-color: ${DesignToken.scrollbar.color};\r\n }\r\n ul {\r\n list-style: none;\r\n padding-inline-start: unset;\r\n margin-block-start: unset;\r\n margin-block-end: unset;\r\n }\r\n ul,\r\n li {\r\n display: flex;\r\n flex-direction: column;\r\n align-items: stretch;\r\n }\r\n m3e-toc-item {\r\n flex: none;\r\n }\r\n .active-indicator {\r\n position: absolute;\r\n pointer-events: none;\r\n box-sizing: border-box;\r\n left: var(--m3e-toc-container-padding-inline, 0px);\r\n right: var(--m3e-toc-container-padding-inline, 0px);\r\n\r\n border-radius: var(--m3e-toc-item-shape, ${DesignToken.shape.corner.largeIncreased});\r\n border: 1px solid var(--m3e-toc-active-indicator-color, ${DesignToken.color.outline});\r\n transition: ${unsafeCSS(`visibility var(--m3e-toc-active-indicator-animation-duration, ${DesignToken.motion.duration.long1})\r\n ${DesignToken.motion.easing.standard},\r\n height var(--m3e-toc-active-indicator-animation-duration, ${DesignToken.motion.duration.long1})\r\n ${DesignToken.motion.easing.standard},\r\n top var(--m3e-toc-active-indicator-animation-duration, ${DesignToken.motion.duration.long1})\r\n ${DesignToken.motion.easing.standard}`)};\r\n }\r\n .header {\r\n display: flex;\r\n flex-direction: column;\r\n align-items: stretch;\r\n padding-inline-start: var(--m3e-toc-item-padding, 1rem);\r\n padding-block-end: var(--m3e-toc-header-space, 0.5rem);\r\n row-gap: var(--m3e-toc-header-space, 0.5rem);\r\n }\r\n .overline {\r\n white-space: nowrap;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\r\n }\r\n .title {\r\n display: -webkit-box;\r\n -webkit-line-clamp: 2;\r\n -webkit-box-orient: vertical;\r\n overflow: hidden;\r\n line-clamp: 2;\r\n }\r\n :host(:not(:is(:state(--with-overline), :--with-overline))) .overline,\r\n :host(:not(:is(:state(--with-title), :--with-title))) .title,\r\n :host(:not(:is(:state(--with-overline), :--with-overline)):not(:is(:state(--with-title), :--with-title))) .header {\r\n display: none;\r\n }\r\n ::slotted([slot=\"overline\"]) {\r\n font-size: var(--m3e-toc-overline-font-size, ${DesignToken.typescale.standard.label.small.fontSize});\r\n font-weight: var(--m3e-toc-overline-font-weight, ${DesignToken.typescale.standard.label.small.fontWeight});\r\n line-height: var(--m3e-toc-overline-line-height, ${DesignToken.typescale.standard.label.small.lineHeight});\r\n letter-spacing: var(--m3e-toc-overline-tracking, ${DesignToken.typescale.standard.label.small.tracking});\r\n color: var(--m3e-toc-overline-color, ${DesignToken.color.onSurfaceVariant});\r\n }\r\n ::slotted([slot=\"title\"]) {\r\n font-size: var(--m3e-toc-title-font-size, ${DesignToken.typescale.standard.headline.small.fontSize});\r\n font-weight: var(--m3e-toc-title-font-weight, ${DesignToken.typescale.standard.headline.small.fontWeight});\r\n line-height: var(--m3e-toc-title-line-height, ${DesignToken.typescale.standard.headline.small.lineHeight});\r\n letter-spacing: var(--m3e-toc-title-tracking, ${DesignToken.typescale.standard.headline.small.tracking});\r\n color: var(--m3e-toc-title-color, ${DesignToken.color.onSurface});\r\n }\r\n :host(:is(:state(--no-animate), :--no-animate)) .active-indicator {\r\n transition: none;\r\n }\r\n @media (prefers-reduced-motion) {\r\n .active-indicator {\r\n transition: none;\r\n }\r\n }\r\n `;\r\n\r\n /** @private */ @state() private _toc: Array<TocNode> = [];\r\n /** @private */ @query(\".active-indicator\") private readonly _activeIndicator!: HTMLElement;\r\n /** @private */ @query(\".scroll-container\") private readonly _scrollContainer!: HTMLElement;\r\n /** @private */ #ignoreScroll = false;\r\n\r\n /** @private */ readonly #selectionManager = new SelectionManager<M3eTocItemElement>()\r\n .withHomeAndEnd()\r\n .withVerticalOrientation()\r\n .disableRovingTabIndex()\r\n .onSelectedItemsChange(() => {\r\n if (this._activeIndicator) {\r\n const item = this.#selectionManager.selectedItems[0];\r\n if (!item) {\r\n setCustomState(this, \"--no-animate\", true);\r\n this._activeIndicator.style.top = `0px`;\r\n this._activeIndicator.style.height = `0px`;\r\n this._activeIndicator.style.visibility = \"hidden\";\r\n } else {\r\n const scrollContainer = this._scrollContainer;\r\n\r\n if (item === this.#selectionManager.items[0]) {\r\n scrollContainer.scrollTo({ top: 0, behavior: \"smooth\" });\r\n } else if (item === this.#selectionManager.items[this.#selectionManager.items.length - 1]) {\r\n scrollContainer.scrollTo({\r\n top: scrollContainer.scrollHeight - scrollContainer.clientHeight,\r\n behavior: \"smooth\",\r\n });\r\n } else {\r\n scrollIntoViewIfNeeded(item, this._scrollContainer, { block: \"nearest\", behavior: \"smooth\" });\r\n }\r\n this._activeIndicator.style.top = `${item.offsetTop}px`;\r\n this._activeIndicator.style.height = `${item.clientHeight}px`;\r\n this._activeIndicator.style.visibility = item.clientHeight == 0 ? \"hidden\" : \"\";\r\n\r\n if (hasCustomState(this, \"--no-animate\")) {\r\n setTimeout(() => setCustomState(this, \"--no-animate\", false), 40);\r\n }\r\n }\r\n }\r\n });\r\n\r\n /** @private */\r\n readonly #intersectionController = new IntersectionController(this, {\r\n target: null,\r\n callback: (entries) => {\r\n if (!this.control || this.#ignoreScroll) return;\r\n\r\n const targetOffset = this.control.scrollTop;\r\n let closestElement: HTMLElement | null = null;\r\n let closestDistance = Number.POSITIVE_INFINITY;\r\n\r\n entries\r\n .filter((x) => x.isIntersecting)\r\n .map((x) => <HTMLElement>x.target)\r\n .forEach((item) => {\r\n const offsetTop = item.offsetTop;\r\n const distance = Math.abs(offsetTop - targetOffset);\r\n if (distance < closestDistance) {\r\n closestDistance = distance;\r\n closestElement = item;\r\n }\r\n });\r\n\r\n if (closestElement) {\r\n const item = this.#selectionManager.items.find((x) => x.node?.element === closestElement);\r\n if (item) {\r\n this.#selectionManager.select(item);\r\n }\r\n }\r\n },\r\n });\r\n\r\n /** @private */\r\n readonly #scrollController = new ScrollController(this, {\r\n target: null,\r\n callback: () => (this.#ignoreScroll = false),\r\n debounce: true,\r\n });\r\n\r\n /** @private */\r\n readonly #mutationController = new MutationController(this, {\r\n target: null,\r\n config: {\r\n childList: true,\r\n subtree: true,\r\n },\r\n callback: () => this._updateToc(),\r\n });\r\n\r\n /**\r\n * The maximum depth of the table of contents.\r\n * @default 2\r\n */\r\n @property({ attribute: \"max-depth\", type: Number }) maxDepth = 2;\r\n\r\n /** @inheritdoc */\r\n override attach(control: HTMLElement): void {\r\n super.attach(control);\r\n this.#mutationController.observe(control);\r\n this.#scrollController.observe(control);\r\n this.#generateToc();\r\n }\r\n\r\n /** @inheritdoc */\r\n override detach(): void {\r\n if (this.control) {\r\n this.#mutationController.unobserve(this.control);\r\n this.#scrollController.unobserve(this.control);\r\n }\r\n super.detach();\r\n this.#generateToc();\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override willUpdate(changedProperties: PropertyValues<this>): void {\r\n super.willUpdate(changedProperties);\r\n\r\n if (changedProperties.has(\"maxDepth\")) {\r\n this.#generateToc();\r\n }\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override updated(_changedProperties: PropertyValues): void {\r\n super.updated(_changedProperties);\r\n\r\n if (_changedProperties.has(\"_toc\")) {\r\n const { added, removed } = this.#selectionManager.setItems([\r\n ...(this.shadowRoot?.querySelectorAll(\"m3e-toc-item\") ?? []),\r\n ]);\r\n\r\n if (!this.#selectionManager.activeItem) {\r\n setCustomState(this, \"--no-animate\", true);\r\n this.#selectionManager.updateActiveItem(added.find((x) => !x.disabled));\r\n }\r\n\r\n for (const item of added) {\r\n if (item.node) {\r\n this.#intersectionController.observe(item.node.element);\r\n }\r\n }\r\n\r\n for (const item of removed) {\r\n if (item.node) {\r\n this.#intersectionController.unobserve(item.node.element);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override render(): unknown {\r\n return html`<div class=\"base\">\r\n <div class=\"scroll-container\">\r\n <div class=\"header\">\r\n <div class=\"overline\">\r\n <slot name=\"overline\" @slotchange=\"${this.#handleOverlineSlotChange}\"></slot>\r\n </div>\r\n <div class=\"title\">\r\n <slot name=\"title\" @slotchange=\"${this.#handleTitleSlotChange}\"></slot>\r\n </div>\r\n </div>\r\n <slot></slot>\r\n <ul class=\"list\">\r\n ${this._toc.map((x) => this.#renderNode(x))}\r\n </ul>\r\n <div class=\"active-indicator\" aria-hidden=\"true\"></div>\r\n </div>\r\n </div>`;\r\n }\r\n\r\n /** @private */\r\n #renderNode(node: TocNode): unknown {\r\n return html`<li>\r\n <m3e-toc-item tabindex=\"-1\" .node=\"${node}\" @click=\"${this.#handleClick}\">${node.label}</m3e-toc-item>\r\n ${node.nodes.length == 0\r\n ? nothing\r\n : html`<ul>\r\n ${node.nodes.map((x) => this.#renderNode(x))}\r\n </ul>`}\r\n </li>`;\r\n }\r\n\r\n /** @private */\r\n #handleOverlineSlotChange(e: Event): void {\r\n setCustomState(this, \"--with-overline\", hasAssignedNodes(<HTMLSlotElement>e.target));\r\n }\r\n\r\n /** @private */\r\n #handleTitleSlotChange(e: Event): void {\r\n setCustomState(this, \"--with-title\", hasAssignedNodes(<HTMLSlotElement>e.target));\r\n }\r\n\r\n /** @private */\r\n #handleClick(e: Event): void {\r\n if (e.target instanceof M3eTocItemElement && !e.target.disabled && e.target.node?.element) {\r\n this.#ignoreScroll = true;\r\n e.target.node.element.scrollIntoView({ block: \"start\", behavior: \"smooth\" });\r\n this.#selectionManager.updateActiveItem(e.target);\r\n this.#selectionManager.select(e.target);\r\n }\r\n }\r\n\r\n /** @private */\r\n #generateToc(): void {\r\n this._toc = this.control ? TocGenerator.generate(this.control, Math.max(1, Math.min(this.maxDepth, 6))) : [];\r\n }\r\n\r\n /** @private */\r\n @debounce(40)\r\n private _updateToc(): void {\r\n this.#generateToc();\r\n }\r\n}\r\n\r\ndeclare global {\r\n interface HTMLElementTagNameMap {\r\n \"m3e-toc\": M3eTocElement;\r\n }\r\n}\r\n"],"names":["M3eTocItemElement","Selected","Disabled","AttachInternals","Role","LitElement","update","changedProperties","has","ariaSelected","ariaCurrent","selected","node","_base","style","setProperty","level","removeProperty","firstUpdated","_changedProperties","_stateLayer","attach","render","html","styles","css","DesignToken","shape","corner","largeIncreased","unsafeCSS","motion","duration","long1","easing","standard","typescale","body","large","fontSize","fontWeight","lineHeight","tracking","color","onSurfaceVariant","emphasized","onSurface","__decorate","query","prototype","state","customElement","TocGenerator","generate","element","maxDepth","maxLevel","topLevel","nodes","Array","querySelectorAll","forEach","__classPrivateFieldGet","_a","_TocGenerator_getHeaderLevel","Math","min","push","id","guid","label","getTextContent","i","length","j","prev","x","filter","tagName","startsWith","parseInt","substring","getAttribute","M3eTocElement","HtmlFor","constructor","_toc","_M3eTocElement_ignoreScroll","set","_M3eTocElement_selectionManager","SelectionManager","withHomeAndEnd","withVerticalOrientation","disableRovingTabIndex","onSelectedItemsChange","_activeIndicator","item","selectedItems","setCustomState","top","height","visibility","scrollContainer","_scrollContainer","items","scrollTo","behavior","scrollHeight","clientHeight","scrollIntoViewIfNeeded","block","offsetTop","hasCustomState","setTimeout","_M3eTocElement_intersectionController","IntersectionController","target","callback","entries","control","targetOffset","scrollTop","closestElement","closestDistance","Number","POSITIVE_INFINITY","isIntersecting","map","distance","abs","find","select","_M3eTocElement_scrollController","ScrollController","__classPrivateFieldSet","debounce","_M3eTocElement_mutationController","MutationController","config","childList","subtree","_updateToc","observe","_M3eTocElement_instances","_M3eTocElement_generateToc","call","detach","unobserve","willUpdate","updated","added","removed","setItems","shadowRoot","activeItem","updateActiveItem","disabled","_M3eTocElement_handleOverlineSlotChange","_M3eTocElement_handleTitleSlotChange","_M3eTocElement_renderNode","nothing","e","hasAssignedNodes","scrollIntoView","max","none","scrollbar","thinWidth","outline","small","headline","property","attribute","type"],"mappings":";;;;;;;;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
|
4
4
|
* See LICENSE file in the project root for full license text.
|
|
5
5
|
*/
|
|
6
|
-
import{__decorate as e,__classPrivateFieldGet as t,__classPrivateFieldSet as i}from"tslib";import{LitElement as o,html as a,unsafeCSS as n,css as s,nothing as l}from"lit";import{query as r,state as c,property as d}from"lit/decorators.js";import{Selected as h,Disabled as m,AttachInternals as p,Role as v,DesignToken as g,customElement as f,getTextContent as u,guid as b,HtmlFor as y,setCustomState as w,scrollIntoViewIfNeeded as $,hasCustomState as k,IntersectionController as x,ScrollController as I,MutationController as _,hasAssignedNodes as z,debounce as S}from"@m3e/web/core";import{SelectionManager as W}from"@m3e/web/core/a11y";let T=class extends(h(m(p(v(o,"link"))))){update(e){super.update(e),e.has("selected")&&(this.ariaSelected=null,this.ariaCurrent=this.selected?"true":null),e.has("node")&&(this.node?this._base?.style.setProperty("--_level",""+(this.node.level-1)):this._base?.style.removeProperty("--_level"))}firstUpdated(e){super.firstUpdated(e),this._stateLayer?.attach(this)}render(){return a`<m3e-state-layer class="state-layer"></m3e-state-layer><div class="base"><slot></slot></div>`}};var M,A,H,N,E,V,D,U,L,P,j,q,C;T.styles=s`:host { display: inline-block; position: relative; user-select: none; outline: none; border-radius: var(--m3e-toc-item-shape, ${g.shape.corner.largeIncreased}); padding-block: var(--m3e-toc-item-padding-block, 0.5rem); -webkit-tap-highlight-color: rgba(0, 0, 0, 0); } :host(:not(:disabled)) { cursor: pointer; } .base { padding-inline-start: calc( var(--m3e-toc-item-padding, 1rem) + calc(var(--m3e-toc-item-inset, 0.75rem) * var(--_level, 0)) ); padding-inline-end: var(--m3e-toc-item-padding, 1rem); transition: ${n(`color var(--m3e-toc-active-indicator-animation-duration, ${g.motion.duration.long1}) ${g.motion.easing.standard}`)}; } :host(:not([selected])) { font-size: var(--m3e-toc-item-font-size, ${g.typescale.standard.body.large.fontSize}); font-weight: var(--m3e-toc-item-font-weight, ${g.typescale.standard.body.large.fontWeight}); line-height: var(--m3e-toc-item-line-height, ${g.typescale.standard.body.large.lineHeight}); letter-spacing: var(--m3e-toc-item-tracking, ${g.typescale.standard.body.large.tracking}); color: var(--m3e-toc-item-color, ${g.color.onSurfaceVariant}); } :host([selected]) { font-size: var(--m3e-toc-item-selected-font-size, ${g.typescale.emphasized.body.large.fontSize}); font-weight: var(--m3e-toc-item-selected-font-weight, ${g.typescale.emphasized.body.large.fontWeight}); line-height: var(--m3e-toc-item-selected-line-height, ${g.typescale.emphasized.body.large.lineHeight}); letter-spacing: var(--m3e-toc-item-selected-tracking, ${g.typescale.emphasized.body.large.tracking}); color: var(--m3e-toc-item-selected-color, ${g.color.onSurface}); } .base { justify-content: unset; } .state-layer { --m3e-state-layer-focus-opacity: 0; } @media (prefers-reduced-motion) { .base { transition: none; } }`,e([r(".base")],T.prototype,"_base",void 0),e([r(".state-layer")],T.prototype,"_stateLayer",void 0),e([c()],T.prototype,"node",void 0),T=e([f("m3e-toc-item")],T);class O{static generate(e,i=6){let o=6;const a=new Array;e.querySelectorAll("h1:not([m3e-toc-ignore]),h2:not([m3e-toc-ignore]),h3:not([m3e-toc-ignore]),h4:not([m3e-toc-ignore]),h5:not([m3e-toc-ignore]),h6:not([m3e-toc-ignore]),m3e-heading[level]:not([m3e-toc-ignore])").forEach(e=>{const i=t(M,M,"m",A).call(M,e);o=Math.min(i,o),a.push({id:e.id||b(),element:e,level:i,label:u(e,!0),nodes:new Array})});for(let e=o+i-1;e>o;e--)for(let t=0;t<a.length;t++){const i=a[t];if(i.level===e)for(let o=t;o>=0;o--){const t=a[o];if(t.level<e){t.nodes.push(i);break}}}return a.forEach(e=>e.level-=o-1),a.filter(e=>1===e.level)}}M=O,A=function(e){return e.tagName.startsWith("H")?parseInt(e.tagName.substring(1)):parseInt(e.getAttribute("level")??"0")};let R=class extends(y(p(v(o,"navigation")))){constructor(){super(...arguments),H.add(this),this._toc=[],N.set(this,!1),E.set(this,(new W).withHomeAndEnd().withVerticalOrientation().disableRovingTabIndex().onSelectedItemsChange(()=>{if(this._activeIndicator){const e=t(this,E,"f").selectedItems[0];e?($(e,this,{block:"nearest",behavior:"smooth"}),this._activeIndicator.style.top=`${e.offsetTop}px`,this._activeIndicator.style.height=`${e.clientHeight}px`,this._activeIndicator.style.visibility=0==e.clientHeight?"hidden":"",k(this,"--no-animate")&&setTimeout(()=>w(this,"--no-animate",!1),40)):(w(this,"--no-animate",!0),this._activeIndicator.style.top="0px",this._activeIndicator.style.height="0px",this._activeIndicator.style.visibility="hidden")}})),V.set(this,new x(this,{target:null,callback:e=>{if(!this.control||t(this,N,"f"))return;const i=this.control.scrollTop;let o=null,a=Number.POSITIVE_INFINITY;if(e.filter(e=>e.isIntersecting).map(e=>e.target).forEach(e=>{const t=e.offsetTop,n=Math.abs(t-i);n<a&&(a=n,o=e)}),o){const e=t(this,E,"f").items.find(e=>e.node?.element===o);e&&t(this,E,"f").select(e)}}})),D.set(this,new I(this,{target:null,callback:()=>i(this,N,!1,"f"),debounce:!0})),U.set(this,new _(this,{target:null,config:{childList:!0,subtree:!0},callback:()=>this._updateToc()})),this.maxDepth=2}attach(e){super.attach(e),t(this,U,"f").observe(e),t(this,D,"f").observe(e),t(this,H,"m",C).call(this)}detach(){this.control&&(t(this,U,"f").unobserve(this.control),t(this,D,"f").unobserve(this.control)),super.detach(),t(this,H,"m",C).call(this)}willUpdate(e){super.willUpdate(e),e.has("maxDepth")&&t(this,H,"m",C).call(this)}updated(e){if(super.updated(e),e.has("_toc")){const{added:e,removed:i}=t(this,E,"f").setItems([...this.shadowRoot?.querySelectorAll("m3e-toc-item")??[]]);t(this,E,"f").activeItem||(w(this,"--no-animate",!0),t(this,E,"f").updateActiveItem(e.find(e=>!e.disabled)));for(const i of e)i.node&&t(this,V,"f").observe(i.node.element);for(const e of i)e.node&&t(this,V,"f").unobserve(e.node.element)}}render(){return a`<div class="header"><div class="overline"><slot name="overline" @slotchange="${t(this,H,"m",P)}"></slot></div><div class="title"><slot name="title" @slotchange="${t(this,H,"m",j)}"></slot></div></div><slot></slot><ul class="list">${this._toc.map(e=>t(this,H,"m",L).call(this,e))}</ul><div class="active-indicator" aria-hidden="true"></div>`}_updateToc(){t(this,H,"m",C).call(this)}};N=new WeakMap,E=new WeakMap,V=new WeakMap,D=new WeakMap,U=new WeakMap,H=new WeakSet,L=function e(i){return a`<li><m3e-toc-item tabindex="-1" .node="${i}" @click="${t(this,H,"m",q)}">${i.label}</m3e-toc-item>${0==i.nodes.length?l:a`<ul>${i.nodes.map(i=>t(this,H,"m",e).call(this,i))}</ul>`}</li>`},P=function(e){w(this,"--with-overline",z(e.target))},j=function(e){w(this,"--with-title",z(e.target))},q=function(e){e.target instanceof T&&!e.target.disabled&&e.target.node?.element&&(i(this,N,!0,"f"),e.target.node.element.scrollIntoView({block:"start",behavior:"smooth"}),t(this,E,"f").updateActiveItem(e.target),t(this,E,"f").select(e.target))},C=function(){this._toc=this.control?O.generate(this.control,Math.max(1,Math.min(this.maxDepth,6))):[]},R.styles=s`:host { display: inline-block; position: relative; overflow-y: auto; scrollbar-width: ${g.scrollbar.thinWidth}; scrollbar-color: ${g.scrollbar.color}; width: var(--m3e-toc-width, 9.75rem); } ul { list-style: none; padding-inline-start: unset; margin-block-start: unset; margin-block-end: unset; } ul, li { display: flex; flex-direction: column; align-items: stretch; } m3e-toc-item { flex: none; } .active-indicator { position: absolute; pointer-events: none; box-sizing: border-box; left: 0; right: 0; border-radius: var(--m3e-toc-item-shape, ${g.shape.corner.largeIncreased}); border: 1px solid var(--m3e-toc-active-indicator-color, ${g.color.outline}); transition: ${n(`visibility var(--m3e-toc-active-indicator-animation-duration, ${g.motion.duration.long1})\n ${g.motion.easing.standard},\n height var(--m3e-toc-active-indicator-animation-duration, ${g.motion.duration.long1})\n ${g.motion.easing.standard},\n top var(--m3e-toc-active-indicator-animation-duration, ${g.motion.duration.long1})\n ${g.motion.easing.standard}`)}; } .header { display: flex; flex-direction: column; align-items: stretch; padding-inline-start: var(--m3e-toc-item-padding, 1rem); padding-block-end: var(--m3e-toc-header-space, 0.5rem); row-gap: var(--m3e-toc-header-space, 0.5rem); } .overline { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-clamp: 2; } :host(:not(:is(:state(--with-overline), :--with-overline))) .overline, :host(:not(:is(:state(--with-title), :--with-title))) .title, :host(:not(:is(:state(--with-overline), :--with-overline)):not(:is(:state(--with-title), :--with-title))) .header { display: none; } ::slotted([slot="overline"]) { font-size: var(--m3e-toc-overline-font-size, ${g.typescale.standard.label.small.fontSize}); font-weight: var(--m3e-toc-overline-font-weight, ${g.typescale.standard.label.small.fontWeight}); line-height: var(--m3e-toc-overline-line-height, ${g.typescale.standard.label.small.lineHeight}); letter-spacing: var(--m3e-toc-overline-tracking, ${g.typescale.standard.label.small.tracking}); color: var(--m3e-toc-overline-color, ${g.color.onSurfaceVariant}); } ::slotted([slot="title"]) { font-size: var(--m3e-toc-title-font-size, ${g.typescale.standard.headline.small.fontSize}); font-weight: var(--m3e-toc-title-font-weight, ${g.typescale.standard.headline.small.fontWeight}); line-height: var(--m3e-toc-title-line-height, ${g.typescale.standard.headline.small.lineHeight}); letter-spacing: var(--m3e-toc-title-tracking, ${g.typescale.standard.headline.small.tracking}); color: var(--m3e-toc-title-color, ${g.color.onSurface}); } :host(:is(:state(--no-animate), :--no-animate)) .active-indicator { transition: none; } @media (prefers-reduced-motion) { .active-indicator { transition: none; } }`,e([c()],R.prototype,"_toc",void 0),e([r(".active-indicator")],R.prototype,"_activeIndicator",void 0),e([d({attribute:"max-depth",type:Number})],R.prototype,"maxDepth",void 0),e([S(40)],R.prototype,"_updateToc",null),R=e([f("m3e-toc")],R);export{R as M3eTocElement,T as M3eTocItemElement,O as TocGenerator};
|
|
6
|
+
import{__decorate as e,__classPrivateFieldGet as t,__classPrivateFieldSet as i}from"tslib";import{LitElement as o,html as a,unsafeCSS as n,css as r,nothing as s}from"lit";import{query as l,state as c,property as d}from"lit/decorators.js";import{Selected as h,Disabled as m,AttachInternals as p,Role as v,DesignToken as g,customElement as f,getTextContent as b,guid as u,HtmlFor as y,setCustomState as w,scrollIntoViewIfNeeded as $,hasCustomState as k,IntersectionController as x,ScrollController as _,MutationController as I,hasAssignedNodes as z,debounce as S}from"@m3e/web/core";import{SelectionManager as T}from"@m3e/web/core/a11y";let W=class extends(h(m(p(v(o,"link"))))){update(e){super.update(e),e.has("selected")&&(this.ariaSelected=null,this.ariaCurrent=this.selected?"true":null),e.has("node")&&(this.node?this._base?.style.setProperty("--_level",""+(this.node.level-1)):this._base?.style.removeProperty("--_level"))}firstUpdated(e){super.firstUpdated(e),this._stateLayer?.attach(this)}render(){return a`<m3e-state-layer class="state-layer"></m3e-state-layer><div class="base"><slot></slot></div>`}};var H,M,A,N,C,E,V,D,U,L,P,j,q;W.styles=r`:host { display: inline-block; position: relative; user-select: none; outline: none; border-radius: var(--m3e-toc-item-shape, ${g.shape.corner.largeIncreased}); padding-block: var(--m3e-toc-item-padding-block, 0.5rem); -webkit-tap-highlight-color: rgba(0, 0, 0, 0); } :host(:not(:disabled)) { cursor: pointer; } .base { padding-inline-start: calc( var(--m3e-toc-item-padding, 1rem) + calc(var(--m3e-toc-item-inset, 0.75rem) * var(--_level, 0)) ); padding-inline-end: var(--m3e-toc-item-padding, 1rem); transition: ${n(`color var(--m3e-toc-active-indicator-animation-duration, ${g.motion.duration.long1}) ${g.motion.easing.standard}`)}; } :host(:not([selected])) { font-size: var(--m3e-toc-item-font-size, ${g.typescale.standard.body.large.fontSize}); font-weight: var(--m3e-toc-item-font-weight, ${g.typescale.standard.body.large.fontWeight}); line-height: var(--m3e-toc-item-line-height, ${g.typescale.standard.body.large.lineHeight}); letter-spacing: var(--m3e-toc-item-tracking, ${g.typescale.standard.body.large.tracking}); color: var(--m3e-toc-item-color, ${g.color.onSurfaceVariant}); } :host([selected]) { font-size: var(--m3e-toc-item-selected-font-size, ${g.typescale.emphasized.body.large.fontSize}); font-weight: var(--m3e-toc-item-selected-font-weight, ${g.typescale.emphasized.body.large.fontWeight}); line-height: var(--m3e-toc-item-selected-line-height, ${g.typescale.emphasized.body.large.lineHeight}); letter-spacing: var(--m3e-toc-item-selected-tracking, ${g.typescale.emphasized.body.large.tracking}); color: var(--m3e-toc-item-selected-color, ${g.color.onSurface}); } .base { justify-content: unset; } .state-layer { --m3e-state-layer-focus-opacity: 0; } @media (prefers-reduced-motion) { .base { transition: none; } }`,e([l(".base")],W.prototype,"_base",void 0),e([l(".state-layer")],W.prototype,"_stateLayer",void 0),e([c()],W.prototype,"node",void 0),W=e([f("m3e-toc-item")],W);class O{static generate(e,i=6){let o=6;const a=new Array;e.querySelectorAll("h1:not([m3e-toc-ignore]),h2:not([m3e-toc-ignore]),h3:not([m3e-toc-ignore]),h4:not([m3e-toc-ignore]),h5:not([m3e-toc-ignore]),h6:not([m3e-toc-ignore]),m3e-heading[level]:not([m3e-toc-ignore])").forEach(e=>{const i=t(H,H,"m",M).call(H,e);o=Math.min(i,o),a.push({id:e.id||u(),element:e,level:i,label:b(e,!0),nodes:new Array})});for(let e=o+i-1;e>o;e--)for(let t=0;t<a.length;t++){const i=a[t];if(i.level===e)for(let o=t;o>=0;o--){const t=a[o];if(t.level<e){t.nodes.push(i);break}}}return a.forEach(e=>e.level-=o-1),a.filter(e=>1===e.level)}}H=O,M=function(e){return e.tagName.startsWith("H")?parseInt(e.tagName.substring(1)):parseInt(e.getAttribute("level")??"0")};let R=class extends(y(p(v(o,"navigation")))){constructor(){super(...arguments),A.add(this),this._toc=[],N.set(this,!1),C.set(this,(new T).withHomeAndEnd().withVerticalOrientation().disableRovingTabIndex().onSelectedItemsChange(()=>{if(this._activeIndicator){const e=t(this,C,"f").selectedItems[0];if(e){const i=this._scrollContainer;e===t(this,C,"f").items[0]?i.scrollTo({top:0,behavior:"smooth"}):e===t(this,C,"f").items[t(this,C,"f").items.length-1]?i.scrollTo({top:i.scrollHeight-i.clientHeight,behavior:"smooth"}):$(e,this._scrollContainer,{block:"nearest",behavior:"smooth"}),this._activeIndicator.style.top=`${e.offsetTop}px`,this._activeIndicator.style.height=`${e.clientHeight}px`,this._activeIndicator.style.visibility=0==e.clientHeight?"hidden":"",k(this,"--no-animate")&&setTimeout(()=>w(this,"--no-animate",!1),40)}else w(this,"--no-animate",!0),this._activeIndicator.style.top="0px",this._activeIndicator.style.height="0px",this._activeIndicator.style.visibility="hidden"}})),E.set(this,new x(this,{target:null,callback:e=>{if(!this.control||t(this,N,"f"))return;const i=this.control.scrollTop;let o=null,a=Number.POSITIVE_INFINITY;if(e.filter(e=>e.isIntersecting).map(e=>e.target).forEach(e=>{const t=e.offsetTop,n=Math.abs(t-i);n<a&&(a=n,o=e)}),o){const e=t(this,C,"f").items.find(e=>e.node?.element===o);e&&t(this,C,"f").select(e)}}})),V.set(this,new _(this,{target:null,callback:()=>i(this,N,!1,"f"),debounce:!0})),D.set(this,new I(this,{target:null,config:{childList:!0,subtree:!0},callback:()=>this._updateToc()})),this.maxDepth=2}attach(e){super.attach(e),t(this,D,"f").observe(e),t(this,V,"f").observe(e),t(this,A,"m",q).call(this)}detach(){this.control&&(t(this,D,"f").unobserve(this.control),t(this,V,"f").unobserve(this.control)),super.detach(),t(this,A,"m",q).call(this)}willUpdate(e){super.willUpdate(e),e.has("maxDepth")&&t(this,A,"m",q).call(this)}updated(e){if(super.updated(e),e.has("_toc")){const{added:e,removed:i}=t(this,C,"f").setItems([...this.shadowRoot?.querySelectorAll("m3e-toc-item")??[]]);t(this,C,"f").activeItem||(w(this,"--no-animate",!0),t(this,C,"f").updateActiveItem(e.find(e=>!e.disabled)));for(const i of e)i.node&&t(this,E,"f").observe(i.node.element);for(const e of i)e.node&&t(this,E,"f").unobserve(e.node.element)}}render(){return a`<div class="base"><div class="scroll-container"><div class="header"><div class="overline"><slot name="overline" @slotchange="${t(this,A,"m",L)}"></slot></div><div class="title"><slot name="title" @slotchange="${t(this,A,"m",P)}"></slot></div></div><slot></slot><ul class="list">${this._toc.map(e=>t(this,A,"m",U).call(this,e))}</ul><div class="active-indicator" aria-hidden="true"></div></div></div>`}_updateToc(){t(this,A,"m",q).call(this)}};N=new WeakMap,C=new WeakMap,E=new WeakMap,V=new WeakMap,D=new WeakMap,A=new WeakSet,U=function e(i){return a`<li><m3e-toc-item tabindex="-1" .node="${i}" @click="${t(this,A,"m",j)}">${i.label}</m3e-toc-item>${0==i.nodes.length?s:a`<ul>${i.nodes.map(i=>t(this,A,"m",e).call(this,i))}</ul>`}</li>`},L=function(e){w(this,"--with-overline",z(e.target))},P=function(e){w(this,"--with-title",z(e.target))},j=function(e){e.target instanceof W&&!e.target.disabled&&e.target.node?.element&&(i(this,N,!0,"f"),e.target.node.element.scrollIntoView({block:"start",behavior:"smooth"}),t(this,C,"f").updateActiveItem(e.target),t(this,C,"f").select(e.target))},q=function(){this._toc=this.control?O.generate(this.control,Math.max(1,Math.min(this.maxDepth,6))):[]},R.styles=r`:host { display: inline-block; width: calc(var(--m3e-toc-width, 9.75rem)); } .base { border-radius: var(--m3e-toc-container-shape, ${g.shape.corner.none}); box-sizing: border-box; overflow: hidden; height: 100%; width: 100%; } .scroll-container { height: inherit; width: inherit; box-sizing: inherit; background-color: var(--m3e-toc-container-color, transparent); border-radius: inherit; padding-inline: var(--m3e-toc-container-padding-inline, 0px); padding-block: var(--m3e-toc-container-padding-block, 0px); position: relative; overflow-y: auto; overflow-x: hidden; scrollbar-width: ${g.scrollbar.thinWidth}; scrollbar-color: ${g.scrollbar.color}; } ul { list-style: none; padding-inline-start: unset; margin-block-start: unset; margin-block-end: unset; } ul, li { display: flex; flex-direction: column; align-items: stretch; } m3e-toc-item { flex: none; } .active-indicator { position: absolute; pointer-events: none; box-sizing: border-box; left: var(--m3e-toc-container-padding-inline, 0px); right: var(--m3e-toc-container-padding-inline, 0px); border-radius: var(--m3e-toc-item-shape, ${g.shape.corner.largeIncreased}); border: 1px solid var(--m3e-toc-active-indicator-color, ${g.color.outline}); transition: ${n(`visibility var(--m3e-toc-active-indicator-animation-duration, ${g.motion.duration.long1})\n ${g.motion.easing.standard},\n height var(--m3e-toc-active-indicator-animation-duration, ${g.motion.duration.long1})\n ${g.motion.easing.standard},\n top var(--m3e-toc-active-indicator-animation-duration, ${g.motion.duration.long1})\n ${g.motion.easing.standard}`)}; } .header { display: flex; flex-direction: column; align-items: stretch; padding-inline-start: var(--m3e-toc-item-padding, 1rem); padding-block-end: var(--m3e-toc-header-space, 0.5rem); row-gap: var(--m3e-toc-header-space, 0.5rem); } .overline { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-clamp: 2; } :host(:not(:is(:state(--with-overline), :--with-overline))) .overline, :host(:not(:is(:state(--with-title), :--with-title))) .title, :host(:not(:is(:state(--with-overline), :--with-overline)):not(:is(:state(--with-title), :--with-title))) .header { display: none; } ::slotted([slot="overline"]) { font-size: var(--m3e-toc-overline-font-size, ${g.typescale.standard.label.small.fontSize}); font-weight: var(--m3e-toc-overline-font-weight, ${g.typescale.standard.label.small.fontWeight}); line-height: var(--m3e-toc-overline-line-height, ${g.typescale.standard.label.small.lineHeight}); letter-spacing: var(--m3e-toc-overline-tracking, ${g.typescale.standard.label.small.tracking}); color: var(--m3e-toc-overline-color, ${g.color.onSurfaceVariant}); } ::slotted([slot="title"]) { font-size: var(--m3e-toc-title-font-size, ${g.typescale.standard.headline.small.fontSize}); font-weight: var(--m3e-toc-title-font-weight, ${g.typescale.standard.headline.small.fontWeight}); line-height: var(--m3e-toc-title-line-height, ${g.typescale.standard.headline.small.lineHeight}); letter-spacing: var(--m3e-toc-title-tracking, ${g.typescale.standard.headline.small.tracking}); color: var(--m3e-toc-title-color, ${g.color.onSurface}); } :host(:is(:state(--no-animate), :--no-animate)) .active-indicator { transition: none; } @media (prefers-reduced-motion) { .active-indicator { transition: none; } }`,e([c()],R.prototype,"_toc",void 0),e([l(".active-indicator")],R.prototype,"_activeIndicator",void 0),e([l(".scroll-container")],R.prototype,"_scrollContainer",void 0),e([d({attribute:"max-depth",type:Number})],R.prototype,"maxDepth",void 0),e([S(40)],R.prototype,"_updateToc",null),R=e([f("m3e-toc")],R);export{R as M3eTocElement,W as M3eTocItemElement,O as TocGenerator};
|
|
7
7
|
//# sourceMappingURL=toc.min.js.map
|
package/dist/toc.min.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toc.min.js","sources":["../../src/toc/TocItemElement.ts","../../src/toc/TocGenerator.ts","../../src/toc/TocElement.ts"],"sourcesContent":["import { css, CSSResultGroup, html, LitElement, PropertyValues, unsafeCSS } from \"lit\";\r\nimport { query, state } from \"lit/decorators.js\";\r\n\r\nimport {\r\n AttachInternals,\r\n customElement,\r\n DesignToken,\r\n Disabled,\r\n M3eStateLayerElement,\r\n Role,\r\n Selected,\r\n} from \"@m3e/web/core\";\r\n\r\nimport { TocNode } from \"./TocGenerator\";\r\n\r\n/**\r\n * An item in a table of contents.\r\n * @tag m3e-toc-item\r\n *\r\n * @slot - Renders the label of the item.\r\n *\r\n * @attr disabled - A value indicating whether the element is disabled.\r\n *\r\n * @fires click - Dispatched when the element is clicked.\r\n *\r\n * @cssprop --m3e-toc-item-shape - Border radius of the TOC item.\r\n * @cssprop --m3e-toc-item-padding-block - Block padding for the TOC item.\r\n * @cssprop --m3e-toc-item-padding - Inline padding for the TOC item.\r\n * @cssprop --m3e-toc-item-inset - Indentation per level for the TOC item.\r\n * @cssprop --m3e-toc-active-indicator-animation-duration - Animation duration for the active indicator.\r\n * @cssprop --m3e-toc-item-font-size - Font size for unselected items.\r\n * @cssprop --m3e-toc-item-font-weight - Font weight for unselected items.\r\n * @cssprop --m3e-toc-item-line-height - Line height for unselected items.\r\n * @cssprop --m3e-toc-item-tracking - Letter spacing for unselected items.\r\n * @cssprop --m3e-toc-item-color - Text color for unselected items.\r\n * @cssprop --m3e-toc-item-selected-font-size - Font size for selected items.\r\n * @cssprop --m3e-toc-item-selected-font-weight - Font weight for selected items.\r\n * @cssprop --m3e-toc-item-selected-line-height - Line height for selected items.\r\n * @cssprop --m3e-toc-item-selected-tracking - Letter spacing for selected items.\r\n * @cssprop --m3e-toc-item-selected-color - Text color for selected items.\r\n */\r\n@customElement(\"m3e-toc-item\")\r\nexport class M3eTocItemElement extends Selected(Disabled(AttachInternals(Role(LitElement, \"link\")))) {\r\n /** The styles of the element. */\r\n static override styles: CSSResultGroup = css`\r\n :host {\r\n display: inline-block;\r\n position: relative;\r\n user-select: none;\r\n outline: none;\r\n border-radius: var(--m3e-toc-item-shape, ${DesignToken.shape.corner.largeIncreased});\r\n padding-block: var(--m3e-toc-item-padding-block, 0.5rem);\r\n -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\r\n }\r\n :host(:not(:disabled)) {\r\n cursor: pointer;\r\n }\r\n .base {\r\n padding-inline-start: calc(\r\n var(--m3e-toc-item-padding, 1rem) + calc(var(--m3e-toc-item-inset, 0.75rem) * var(--_level, 0))\r\n );\r\n padding-inline-end: var(--m3e-toc-item-padding, 1rem);\r\n transition: ${unsafeCSS(\r\n `color var(--m3e-toc-active-indicator-animation-duration, ${DesignToken.motion.duration.long1}) ${DesignToken.motion.easing.standard}`,\r\n )};\r\n }\r\n :host(:not([selected])) {\r\n font-size: var(--m3e-toc-item-font-size, ${DesignToken.typescale.standard.body.large.fontSize});\r\n font-weight: var(--m3e-toc-item-font-weight, ${DesignToken.typescale.standard.body.large.fontWeight});\r\n line-height: var(--m3e-toc-item-line-height, ${DesignToken.typescale.standard.body.large.lineHeight});\r\n letter-spacing: var(--m3e-toc-item-tracking, ${DesignToken.typescale.standard.body.large.tracking});\r\n color: var(--m3e-toc-item-color, ${DesignToken.color.onSurfaceVariant});\r\n }\r\n :host([selected]) {\r\n font-size: var(--m3e-toc-item-selected-font-size, ${DesignToken.typescale.emphasized.body.large.fontSize});\r\n font-weight: var(--m3e-toc-item-selected-font-weight, ${DesignToken.typescale.emphasized.body.large.fontWeight});\r\n line-height: var(--m3e-toc-item-selected-line-height, ${DesignToken.typescale.emphasized.body.large.lineHeight});\r\n letter-spacing: var(--m3e-toc-item-selected-tracking, ${DesignToken.typescale.emphasized.body.large.tracking});\r\n color: var(--m3e-toc-item-selected-color, ${DesignToken.color.onSurface});\r\n }\r\n .base {\r\n justify-content: unset;\r\n }\r\n .state-layer {\r\n --m3e-state-layer-focus-opacity: 0;\r\n }\r\n @media (prefers-reduced-motion) {\r\n .base {\r\n transition: none;\r\n }\r\n }\r\n `;\r\n\r\n /** @private */ @query(\".base\") private readonly _base?: HTMLElement;\r\n /** @private */ @query(\".state-layer\") private readonly _stateLayer?: M3eStateLayerElement;\r\n /** @internal */ @state() node?: TocNode;\r\n\r\n /** @internal */\r\n protected override update(changedProperties: PropertyValues<this>): void {\r\n super.update(changedProperties);\r\n\r\n if (changedProperties.has(\"selected\")) {\r\n this.ariaSelected = null;\r\n this.ariaCurrent = this.selected ? \"true\" : null;\r\n }\r\n\r\n if (changedProperties.has(\"node\")) {\r\n if (this.node) {\r\n this._base?.style.setProperty(\"--_level\", `${this.node.level - 1}`);\r\n } else {\r\n this._base?.style.removeProperty(\"--_level\");\r\n }\r\n }\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override firstUpdated(_changedProperties: PropertyValues<this>): void {\r\n super.firstUpdated(_changedProperties);\r\n this._stateLayer?.attach(this);\r\n }\r\n\r\n /** @inheritdoc */\r\n override render(): unknown {\r\n return html`<m3e-state-layer class=\"state-layer\"></m3e-state-layer>\r\n <div class=\"base\"><slot></slot></div>`;\r\n }\r\n}\r\n\r\ndeclare global {\r\n interface HTMLElementTagNameMap {\r\n \"m3e-toc-item\": M3eTocItemElement;\r\n }\r\n}\r\n","import { getTextContent, guid } from \"@m3e/web/core\";\r\n\r\n/** A node in a table of contents. */\r\nexport interface TocNode {\r\n /** An opaque identifier that uniquely identifies the node. */\r\n id: string;\r\n\r\n /** The level of the node. */\r\n level: number;\r\n\r\n /** The text to display for the node. */\r\n label: string;\r\n\r\n /** The element of the node. */\r\n element: HTMLElement;\r\n\r\n /** The child nodes. */\r\n nodes: TocNode[];\r\n}\r\n\r\n/** Provides functionality used to generate a table of contents used for in-page navigation. */\r\nexport class TocGenerator {\r\n /**\r\n * Generates nodes from which to construct a table of contents for in-page navigation.\r\n * @param {HTMLElement} element The element for which to generate a table of contents.\r\n * @param {number} [maxDepth=6] The maximum depth of the table of contents.\r\n * @returns {Array<TocNode>} The top-level nodes of the table of contents.\r\n */\r\n static generate(element: HTMLElement, maxDepth: number = 6): Array<TocNode> {\r\n const maxLevel = 6;\r\n let topLevel = maxLevel;\r\n const nodes = new Array<TocNode>();\r\n element\r\n .querySelectorAll<HTMLElement>(\r\n \"h1:not([m3e-toc-ignore]),h2:not([m3e-toc-ignore]),h3:not([m3e-toc-ignore]),h4:not([m3e-toc-ignore]),h5:not([m3e-toc-ignore]),h6:not([m3e-toc-ignore]),m3e-heading[level]:not([m3e-toc-ignore])\",\r\n )\r\n .forEach((element) => {\r\n const level = TocGenerator.#getHeaderLevel(element);\r\n topLevel = Math.min(level, topLevel);\r\n nodes.push({\r\n id: element.id || guid(),\r\n element,\r\n level,\r\n label: getTextContent(element, true),\r\n nodes: new Array<TocNode>(),\r\n });\r\n });\r\n\r\n for (let level = topLevel + maxDepth - 1; level > topLevel; level--) {\r\n for (let i = 0; i < nodes.length; i++) {\r\n const node = nodes[i];\r\n if (node.level === level) {\r\n for (let j = i; j >= 0; j--) {\r\n const prev = nodes[j];\r\n if (prev.level < level) {\r\n prev.nodes.push(node);\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n nodes.forEach((x) => (x.level -= topLevel - 1));\r\n return nodes.filter((x) => x.level === 1);\r\n }\r\n\r\n /** @internal */\r\n static #getHeaderLevel(element: HTMLElement): number {\r\n return element.tagName.startsWith(\"H\")\r\n ? parseInt(element.tagName.substring(1))\r\n : parseInt(element.getAttribute(\"level\") ?? \"0\");\r\n }\r\n}\r\n","import { css, CSSResultGroup, html, LitElement, nothing, PropertyValues, unsafeCSS } from \"lit\";\r\nimport { property, query, state } from \"lit/decorators.js\";\r\n\r\nimport {\r\n AttachInternals,\r\n customElement,\r\n debounce,\r\n DesignToken,\r\n hasAssignedNodes,\r\n hasCustomState,\r\n HtmlFor,\r\n IntersectionController,\r\n MutationController,\r\n Role,\r\n ScrollController,\r\n scrollIntoViewIfNeeded,\r\n setCustomState,\r\n} from \"@m3e/web/core\";\r\n\r\nimport { SelectionManager } from \"@m3e/web/core/a11y\";\r\n\r\nimport { M3eTocItemElement } from \"./TocItemElement\";\r\nimport { TocGenerator, TocNode } from \"./TocGenerator\";\r\n\r\n/**\r\n * A table of contents that provides in-page scroll navigation.\r\n *\r\n * @description\r\n * The `m3e-toc` component generates a hierarchical table of contents for in-page navigation.\r\n * It automatically detects headings or sections in a target element, builds a navigable list,\r\n * and highlights the active section as the user scrolls. The component supports custom header\r\n * slots, depth limiting, smooth scrolling, and extensive theming via CSS custom properties.\r\n *\r\n * To exclude a heading from the generated table of contents, add the `m3e-toc-ignore` attribute\r\n * to that heading element.\r\n *\r\n * @example\r\n * ```html\r\n * <m3e-toc for=\"content\" max-depth=\"3\">\r\n * <span slot=\"overline\">Contents</span>\r\n * <span slot=\"title\">Documentation</span>\r\n * </m3e-toc>\r\n * <div id=\"content\">\r\n * <h2>Introduction</h2>\r\n * <h2>Getting Started</h2>\r\n * <h3>Installation</h3>\r\n * <h3>Usage</h3>\r\n * <h2>API Reference</h2>\r\n * </div>\r\n * ```\r\n *\r\n * @tag m3e-toc\r\n *\r\n * @slot - Renders content between the header and items.\r\n * @slot overline - Renders the overline of the table of contents.\r\n * @slot title - Renders the title of the table of contents.\r\n *\r\n * @attr for - The identifier of the interactive control to which this element is attached.\r\n * @attr max-depth - The maximum depth of the table of contents.\r\n *\r\n * @cssprop --m3e-toc-width - Width of the table of contents.\r\n * @cssprop --m3e-toc-item-shape - Border radius of TOC items and active indicator.\r\n * @cssprop --m3e-toc-active-indicator-color - Border color of the active indicator.\r\n * @cssprop --m3e-toc-active-indicator-animation-duration - Animation duration for the active indicator.\r\n * @cssprop --m3e-toc-item-padding - Inline padding for TOC items and header.\r\n * @cssprop --m3e-toc-header-space - Block space below and between header elements.\r\n * @cssprop --m3e-toc-overline-font-size - Font size for the overline slot.\r\n * @cssprop --m3e-toc-overline-font-weight - Font weight for the overline slot.\r\n * @cssprop --m3e-toc-overline-line-height - Line height for the overline slot.\r\n * @cssprop --m3e-toc-overline-tracking - Letter spacing for the overline slot.\r\n * @cssprop --m3e-toc-overline-color - Text color for the overline slot.\r\n * @cssprop --m3e-toc-title-font-size - Font size for the title slot.\r\n * @cssprop --m3e-toc-title-font-weight - Font weight for the title slot.\r\n * @cssprop --m3e-toc-title-line-height - Line height for the title slot.\r\n * @cssprop --m3e-toc-title-tracking - Letter spacing for the title slot.\r\n * @cssprop --m3e-toc-title-color - Text color for the title slot.\r\n */\r\n@customElement(\"m3e-toc\")\r\nexport class M3eTocElement extends HtmlFor(AttachInternals(Role(LitElement, \"navigation\"))) {\r\n /** The styles of the element. */\r\n static override styles: CSSResultGroup = css`\r\n :host {\r\n display: inline-block;\r\n position: relative;\r\n overflow-y: auto;\r\n scrollbar-width: ${DesignToken.scrollbar.thinWidth};\r\n scrollbar-color: ${DesignToken.scrollbar.color};\r\n width: var(--m3e-toc-width, 9.75rem);\r\n }\r\n ul {\r\n list-style: none;\r\n padding-inline-start: unset;\r\n margin-block-start: unset;\r\n margin-block-end: unset;\r\n }\r\n ul,\r\n li {\r\n display: flex;\r\n flex-direction: column;\r\n align-items: stretch;\r\n }\r\n m3e-toc-item {\r\n flex: none;\r\n }\r\n .active-indicator {\r\n position: absolute;\r\n pointer-events: none;\r\n box-sizing: border-box;\r\n left: 0;\r\n right: 0;\r\n\r\n border-radius: var(--m3e-toc-item-shape, ${DesignToken.shape.corner.largeIncreased});\r\n border: 1px solid var(--m3e-toc-active-indicator-color, ${DesignToken.color.outline});\r\n transition: ${unsafeCSS(`visibility var(--m3e-toc-active-indicator-animation-duration, ${DesignToken.motion.duration.long1})\r\n ${DesignToken.motion.easing.standard},\r\n height var(--m3e-toc-active-indicator-animation-duration, ${DesignToken.motion.duration.long1})\r\n ${DesignToken.motion.easing.standard},\r\n top var(--m3e-toc-active-indicator-animation-duration, ${DesignToken.motion.duration.long1})\r\n ${DesignToken.motion.easing.standard}`)};\r\n }\r\n .header {\r\n display: flex;\r\n flex-direction: column;\r\n align-items: stretch;\r\n padding-inline-start: var(--m3e-toc-item-padding, 1rem);\r\n padding-block-end: var(--m3e-toc-header-space, 0.5rem);\r\n row-gap: var(--m3e-toc-header-space, 0.5rem);\r\n }\r\n .overline {\r\n white-space: nowrap;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\r\n }\r\n .title {\r\n display: -webkit-box;\r\n -webkit-line-clamp: 2;\r\n -webkit-box-orient: vertical;\r\n overflow: hidden;\r\n line-clamp: 2;\r\n }\r\n :host(:not(:is(:state(--with-overline), :--with-overline))) .overline,\r\n :host(:not(:is(:state(--with-title), :--with-title))) .title,\r\n :host(:not(:is(:state(--with-overline), :--with-overline)):not(:is(:state(--with-title), :--with-title))) .header {\r\n display: none;\r\n }\r\n ::slotted([slot=\"overline\"]) {\r\n font-size: var(--m3e-toc-overline-font-size, ${DesignToken.typescale.standard.label.small.fontSize});\r\n font-weight: var(--m3e-toc-overline-font-weight, ${DesignToken.typescale.standard.label.small.fontWeight});\r\n line-height: var(--m3e-toc-overline-line-height, ${DesignToken.typescale.standard.label.small.lineHeight});\r\n letter-spacing: var(--m3e-toc-overline-tracking, ${DesignToken.typescale.standard.label.small.tracking});\r\n color: var(--m3e-toc-overline-color, ${DesignToken.color.onSurfaceVariant});\r\n }\r\n ::slotted([slot=\"title\"]) {\r\n font-size: var(--m3e-toc-title-font-size, ${DesignToken.typescale.standard.headline.small.fontSize});\r\n font-weight: var(--m3e-toc-title-font-weight, ${DesignToken.typescale.standard.headline.small.fontWeight});\r\n line-height: var(--m3e-toc-title-line-height, ${DesignToken.typescale.standard.headline.small.lineHeight});\r\n letter-spacing: var(--m3e-toc-title-tracking, ${DesignToken.typescale.standard.headline.small.tracking});\r\n color: var(--m3e-toc-title-color, ${DesignToken.color.onSurface});\r\n }\r\n :host(:is(:state(--no-animate), :--no-animate)) .active-indicator {\r\n transition: none;\r\n }\r\n @media (prefers-reduced-motion) {\r\n .active-indicator {\r\n transition: none;\r\n }\r\n }\r\n `;\r\n\r\n /** @private */ @state() private _toc: Array<TocNode> = [];\r\n /** @private */ @query(\".active-indicator\") private readonly _activeIndicator!: HTMLElement;\r\n /** @private */ #ignoreScroll = false;\r\n\r\n /** @private */ readonly #selectionManager = new SelectionManager<M3eTocItemElement>()\r\n .withHomeAndEnd()\r\n .withVerticalOrientation()\r\n .disableRovingTabIndex()\r\n .onSelectedItemsChange(() => {\r\n if (this._activeIndicator) {\r\n const item = this.#selectionManager.selectedItems[0];\r\n if (!item) {\r\n setCustomState(this, \"--no-animate\", true);\r\n this._activeIndicator.style.top = `0px`;\r\n this._activeIndicator.style.height = `0px`;\r\n this._activeIndicator.style.visibility = \"hidden\";\r\n } else {\r\n scrollIntoViewIfNeeded(item, this, { block: \"nearest\", behavior: \"smooth\" });\r\n this._activeIndicator.style.top = `${item.offsetTop}px`;\r\n this._activeIndicator.style.height = `${item.clientHeight}px`;\r\n this._activeIndicator.style.visibility = item.clientHeight == 0 ? \"hidden\" : \"\";\r\n\r\n if (hasCustomState(this, \"--no-animate\")) {\r\n setTimeout(() => setCustomState(this, \"--no-animate\", false), 40);\r\n }\r\n }\r\n }\r\n });\r\n\r\n /** @private */\r\n readonly #intersectionController = new IntersectionController(this, {\r\n target: null,\r\n callback: (entries) => {\r\n if (!this.control || this.#ignoreScroll) return;\r\n\r\n const targetOffset = this.control.scrollTop;\r\n let closestElement: HTMLElement | null = null;\r\n let closestDistance = Number.POSITIVE_INFINITY;\r\n\r\n entries\r\n .filter((x) => x.isIntersecting)\r\n .map((x) => <HTMLElement>x.target)\r\n .forEach((item) => {\r\n const offsetTop = item.offsetTop;\r\n const distance = Math.abs(offsetTop - targetOffset);\r\n if (distance < closestDistance) {\r\n closestDistance = distance;\r\n closestElement = item;\r\n }\r\n });\r\n\r\n if (closestElement) {\r\n const item = this.#selectionManager.items.find((x) => x.node?.element === closestElement);\r\n if (item) {\r\n this.#selectionManager.select(item);\r\n }\r\n }\r\n },\r\n });\r\n\r\n /** @private */\r\n readonly #scrollController = new ScrollController(this, {\r\n target: null,\r\n callback: () => (this.#ignoreScroll = false),\r\n debounce: true,\r\n });\r\n\r\n /** @private */\r\n readonly #mutationController = new MutationController(this, {\r\n target: null,\r\n config: {\r\n childList: true,\r\n subtree: true,\r\n },\r\n callback: () => this._updateToc(),\r\n });\r\n\r\n /**\r\n * The maximum depth of the table of contents.\r\n * @default 2\r\n */\r\n @property({ attribute: \"max-depth\", type: Number }) maxDepth = 2;\r\n\r\n /** @inheritdoc */\r\n override attach(control: HTMLElement): void {\r\n super.attach(control);\r\n this.#mutationController.observe(control);\r\n this.#scrollController.observe(control);\r\n this.#generateToc();\r\n }\r\n\r\n /** @inheritdoc */\r\n override detach(): void {\r\n if (this.control) {\r\n this.#mutationController.unobserve(this.control);\r\n this.#scrollController.unobserve(this.control);\r\n }\r\n super.detach();\r\n this.#generateToc();\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override willUpdate(changedProperties: PropertyValues<this>): void {\r\n super.willUpdate(changedProperties);\r\n\r\n if (changedProperties.has(\"maxDepth\")) {\r\n this.#generateToc();\r\n }\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override updated(_changedProperties: PropertyValues): void {\r\n super.updated(_changedProperties);\r\n\r\n if (_changedProperties.has(\"_toc\")) {\r\n const { added, removed } = this.#selectionManager.setItems([\r\n ...(this.shadowRoot?.querySelectorAll(\"m3e-toc-item\") ?? []),\r\n ]);\r\n\r\n if (!this.#selectionManager.activeItem) {\r\n setCustomState(this, \"--no-animate\", true);\r\n this.#selectionManager.updateActiveItem(added.find((x) => !x.disabled));\r\n }\r\n\r\n for (const item of added) {\r\n if (item.node) {\r\n this.#intersectionController.observe(item.node.element);\r\n }\r\n }\r\n\r\n for (const item of removed) {\r\n if (item.node) {\r\n this.#intersectionController.unobserve(item.node.element);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override render(): unknown {\r\n return html`<div class=\"header\">\r\n <div class=\"overline\">\r\n <slot name=\"overline\" @slotchange=\"${this.#handleOverlineSlotChange}\"></slot>\r\n </div>\r\n <div class=\"title\">\r\n <slot name=\"title\" @slotchange=\"${this.#handleTitleSlotChange}\"></slot>\r\n </div>\r\n </div>\r\n <slot></slot>\r\n <ul class=\"list\">\r\n ${this._toc.map((x) => this.#renderNode(x))}\r\n </ul>\r\n <div class=\"active-indicator\" aria-hidden=\"true\"></div>`;\r\n }\r\n\r\n /** @private */\r\n #renderNode(node: TocNode): unknown {\r\n return html`<li>\r\n <m3e-toc-item tabindex=\"-1\" .node=\"${node}\" @click=\"${this.#handleClick}\">${node.label}</m3e-toc-item>\r\n ${node.nodes.length == 0\r\n ? nothing\r\n : html`<ul>\r\n ${node.nodes.map((x) => this.#renderNode(x))}\r\n </ul>`}\r\n </li>`;\r\n }\r\n\r\n /** @private */\r\n #handleOverlineSlotChange(e: Event): void {\r\n setCustomState(this, \"--with-overline\", hasAssignedNodes(<HTMLSlotElement>e.target));\r\n }\r\n\r\n /** @private */\r\n #handleTitleSlotChange(e: Event): void {\r\n setCustomState(this, \"--with-title\", hasAssignedNodes(<HTMLSlotElement>e.target));\r\n }\r\n\r\n /** @private */\r\n #handleClick(e: Event): void {\r\n if (e.target instanceof M3eTocItemElement && !e.target.disabled && e.target.node?.element) {\r\n this.#ignoreScroll = true;\r\n e.target.node.element.scrollIntoView({ block: \"start\", behavior: \"smooth\" });\r\n this.#selectionManager.updateActiveItem(e.target);\r\n this.#selectionManager.select(e.target);\r\n }\r\n }\r\n\r\n /** @private */\r\n #generateToc(): void {\r\n this._toc = this.control ? TocGenerator.generate(this.control, Math.max(1, Math.min(this.maxDepth, 6))) : [];\r\n }\r\n\r\n /** @private */\r\n @debounce(40)\r\n private _updateToc(): void {\r\n this.#generateToc();\r\n }\r\n}\r\n\r\ndeclare global {\r\n interface HTMLElementTagNameMap {\r\n \"m3e-toc\": M3eTocElement;\r\n }\r\n}\r\n"],"names":["M3eTocItemElement","Selected","Disabled","AttachInternals","Role","LitElement","update","changedProperties","super","has","this","ariaSelected","ariaCurrent","selected","node","_base","style","setProperty","level","removeProperty","firstUpdated","_changedProperties","_stateLayer","attach","render","html","styles","css","DesignToken","shape","corner","largeIncreased","unsafeCSS","motion","duration","long1","easing","standard","typescale","body","large","fontSize","fontWeight","lineHeight","tracking","color","onSurfaceVariant","emphasized","onSurface","__decorate","query","prototype","state","customElement","TocGenerator","generate","element","maxDepth","topLevel","nodes","Array","querySelectorAll","forEach","__classPrivateFieldGet","_a","_TocGenerator_getHeaderLevel","Math","min","push","id","guid","label","getTextContent","i","length","j","prev","x","filter","tagName","startsWith","parseInt","substring","getAttribute","M3eTocElement","HtmlFor","constructor","_toc","_M3eTocElement_ignoreScroll","set","_M3eTocElement_selectionManager","SelectionManager","withHomeAndEnd","withVerticalOrientation","disableRovingTabIndex","onSelectedItemsChange","_activeIndicator","item","selectedItems","scrollIntoViewIfNeeded","block","behavior","top","offsetTop","height","clientHeight","visibility","hasCustomState","setTimeout","setCustomState","_M3eTocElement_intersectionController","IntersectionController","target","callback","entries","control","targetOffset","scrollTop","closestElement","closestDistance","Number","POSITIVE_INFINITY","isIntersecting","map","distance","abs","items","find","select","_M3eTocElement_scrollController","ScrollController","__classPrivateFieldSet","debounce","_M3eTocElement_mutationController","MutationController","config","childList","subtree","_updateToc","observe","_M3eTocElement_instances","_M3eTocElement_generateToc","call","detach","unobserve","willUpdate","updated","added","removed","setItems","shadowRoot","activeItem","updateActiveItem","disabled","_M3eTocElement_handleOverlineSlotChange","_M3eTocElement_handleTitleSlotChange","_M3eTocElement_renderNode","nothing","e","hasAssignedNodes","scrollIntoView","max","scrollbar","thinWidth","outline","small","headline","property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rH,mZAyBEjB,EAAYC,MAAMC,OAAOC,4EACVH,EAAYiB,MAAMuH,yBAC9DpI,EAAU,iEAAiEJ,EAAYK,OAAOC,SAASC,qBAC/GP,EAAYK,OAAOG,OAAOC,gFAC8BT,EAAYK,OAAOC,SAASC,qBACpFP,EAAYK,OAAOG,OAAOC,6EAC2BT,EAAYK,OAAOC,SAASC,qBACjFP,EAAYK,OAAOG,OAAOC,qxBA4BeT,EAAYU,UAAUD,SAASkC,MAAM8F,MAAM5H,+DACvCb,EAAYU,UAAUD,SAASkC,MAAM8F,MAAM3H,iEAC3Cd,EAAYU,UAAUD,SAASkC,MAAM8F,MAAM1H,iEAC3Cf,EAAYU,UAAUD,SAASkC,MAAM8F,MAAMzH,mDACvDhB,EAAYiB,MAAMC,8FAGblB,EAAYU,UAAUD,SAASiI,SAASD,MAAM5H,4DAC1Cb,EAAYU,UAAUD,SAASiI,SAASD,MAAM3H,8DAC9Cd,EAAYU,UAAUD,SAASiI,SAASD,MAAM1H,8DAC9Cf,EAAYU,UAAUD,SAASiI,SAASD,MAAMzH,gDAC1DhB,EAAYiB,MAAMG,oLAYzBC,EAAA,CAAhBG,KAA0CgC,EAAAjC,UAAA,eACEF,EAAA,CAA5CC,EAAM,sBAAqEkC,EAAAjC,UAAA,2BAgFxCF,EAAA,CAAnDsH,EAAS,CAAEC,UAAW,YAAaC,KAAMjD,UAAuBpC,EAAAjC,UAAA,gBAAA,GAiHzDF,EAAA,CADPmF,EAAS,KAGThD,EAAAjC,UAAA,aAAA,MA/RUiC,EAAanC,EAAA,CADzBI,EAAc,YACF+B"}
|
|
1
|
+
{"version":3,"file":"toc.min.js","sources":["../../src/toc/TocItemElement.ts","../../src/toc/TocGenerator.ts","../../src/toc/TocElement.ts"],"sourcesContent":["import { css, CSSResultGroup, html, LitElement, PropertyValues, unsafeCSS } from \"lit\";\r\nimport { query, state } from \"lit/decorators.js\";\r\n\r\nimport {\r\n AttachInternals,\r\n customElement,\r\n DesignToken,\r\n Disabled,\r\n M3eStateLayerElement,\r\n Role,\r\n Selected,\r\n} from \"@m3e/web/core\";\r\n\r\nimport { TocNode } from \"./TocGenerator\";\r\n\r\n/**\r\n * An item in a table of contents.\r\n * @tag m3e-toc-item\r\n *\r\n * @slot - Renders the label of the item.\r\n *\r\n * @attr disabled - A value indicating whether the element is disabled.\r\n *\r\n * @fires click - Dispatched when the element is clicked.\r\n *\r\n * @cssprop --m3e-toc-item-shape - Border radius of the TOC item.\r\n * @cssprop --m3e-toc-item-padding-block - Block padding for the TOC item.\r\n * @cssprop --m3e-toc-item-padding - Inline padding for the TOC item.\r\n * @cssprop --m3e-toc-item-inset - Indentation per level for the TOC item.\r\n * @cssprop --m3e-toc-active-indicator-animation-duration - Animation duration for the active indicator.\r\n * @cssprop --m3e-toc-item-font-size - Font size for unselected items.\r\n * @cssprop --m3e-toc-item-font-weight - Font weight for unselected items.\r\n * @cssprop --m3e-toc-item-line-height - Line height for unselected items.\r\n * @cssprop --m3e-toc-item-tracking - Letter spacing for unselected items.\r\n * @cssprop --m3e-toc-item-color - Text color for unselected items.\r\n * @cssprop --m3e-toc-item-selected-font-size - Font size for selected items.\r\n * @cssprop --m3e-toc-item-selected-font-weight - Font weight for selected items.\r\n * @cssprop --m3e-toc-item-selected-line-height - Line height for selected items.\r\n * @cssprop --m3e-toc-item-selected-tracking - Letter spacing for selected items.\r\n * @cssprop --m3e-toc-item-selected-color - Text color for selected items.\r\n */\r\n@customElement(\"m3e-toc-item\")\r\nexport class M3eTocItemElement extends Selected(Disabled(AttachInternals(Role(LitElement, \"link\")))) {\r\n /** The styles of the element. */\r\n static override styles: CSSResultGroup = css`\r\n :host {\r\n display: inline-block;\r\n position: relative;\r\n user-select: none;\r\n outline: none;\r\n border-radius: var(--m3e-toc-item-shape, ${DesignToken.shape.corner.largeIncreased});\r\n padding-block: var(--m3e-toc-item-padding-block, 0.5rem);\r\n -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\r\n }\r\n :host(:not(:disabled)) {\r\n cursor: pointer;\r\n }\r\n .base {\r\n padding-inline-start: calc(\r\n var(--m3e-toc-item-padding, 1rem) + calc(var(--m3e-toc-item-inset, 0.75rem) * var(--_level, 0))\r\n );\r\n padding-inline-end: var(--m3e-toc-item-padding, 1rem);\r\n transition: ${unsafeCSS(\r\n `color var(--m3e-toc-active-indicator-animation-duration, ${DesignToken.motion.duration.long1}) ${DesignToken.motion.easing.standard}`,\r\n )};\r\n }\r\n :host(:not([selected])) {\r\n font-size: var(--m3e-toc-item-font-size, ${DesignToken.typescale.standard.body.large.fontSize});\r\n font-weight: var(--m3e-toc-item-font-weight, ${DesignToken.typescale.standard.body.large.fontWeight});\r\n line-height: var(--m3e-toc-item-line-height, ${DesignToken.typescale.standard.body.large.lineHeight});\r\n letter-spacing: var(--m3e-toc-item-tracking, ${DesignToken.typescale.standard.body.large.tracking});\r\n color: var(--m3e-toc-item-color, ${DesignToken.color.onSurfaceVariant});\r\n }\r\n :host([selected]) {\r\n font-size: var(--m3e-toc-item-selected-font-size, ${DesignToken.typescale.emphasized.body.large.fontSize});\r\n font-weight: var(--m3e-toc-item-selected-font-weight, ${DesignToken.typescale.emphasized.body.large.fontWeight});\r\n line-height: var(--m3e-toc-item-selected-line-height, ${DesignToken.typescale.emphasized.body.large.lineHeight});\r\n letter-spacing: var(--m3e-toc-item-selected-tracking, ${DesignToken.typescale.emphasized.body.large.tracking});\r\n color: var(--m3e-toc-item-selected-color, ${DesignToken.color.onSurface});\r\n }\r\n .base {\r\n justify-content: unset;\r\n }\r\n .state-layer {\r\n --m3e-state-layer-focus-opacity: 0;\r\n }\r\n @media (prefers-reduced-motion) {\r\n .base {\r\n transition: none;\r\n }\r\n }\r\n `;\r\n\r\n /** @private */ @query(\".base\") private readonly _base?: HTMLElement;\r\n /** @private */ @query(\".state-layer\") private readonly _stateLayer?: M3eStateLayerElement;\r\n /** @internal */ @state() node?: TocNode;\r\n\r\n /** @internal */\r\n protected override update(changedProperties: PropertyValues<this>): void {\r\n super.update(changedProperties);\r\n\r\n if (changedProperties.has(\"selected\")) {\r\n this.ariaSelected = null;\r\n this.ariaCurrent = this.selected ? \"true\" : null;\r\n }\r\n\r\n if (changedProperties.has(\"node\")) {\r\n if (this.node) {\r\n this._base?.style.setProperty(\"--_level\", `${this.node.level - 1}`);\r\n } else {\r\n this._base?.style.removeProperty(\"--_level\");\r\n }\r\n }\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override firstUpdated(_changedProperties: PropertyValues<this>): void {\r\n super.firstUpdated(_changedProperties);\r\n this._stateLayer?.attach(this);\r\n }\r\n\r\n /** @inheritdoc */\r\n override render(): unknown {\r\n return html`<m3e-state-layer class=\"state-layer\"></m3e-state-layer>\r\n <div class=\"base\"><slot></slot></div>`;\r\n }\r\n}\r\n\r\ndeclare global {\r\n interface HTMLElementTagNameMap {\r\n \"m3e-toc-item\": M3eTocItemElement;\r\n }\r\n}\r\n","import { getTextContent, guid } from \"@m3e/web/core\";\r\n\r\n/** A node in a table of contents. */\r\nexport interface TocNode {\r\n /** An opaque identifier that uniquely identifies the node. */\r\n id: string;\r\n\r\n /** The level of the node. */\r\n level: number;\r\n\r\n /** The text to display for the node. */\r\n label: string;\r\n\r\n /** The element of the node. */\r\n element: HTMLElement;\r\n\r\n /** The child nodes. */\r\n nodes: TocNode[];\r\n}\r\n\r\n/** Provides functionality used to generate a table of contents used for in-page navigation. */\r\nexport class TocGenerator {\r\n /**\r\n * Generates nodes from which to construct a table of contents for in-page navigation.\r\n * @param {HTMLElement} element The element for which to generate a table of contents.\r\n * @param {number} [maxDepth=6] The maximum depth of the table of contents.\r\n * @returns {Array<TocNode>} The top-level nodes of the table of contents.\r\n */\r\n static generate(element: HTMLElement, maxDepth: number = 6): Array<TocNode> {\r\n const maxLevel = 6;\r\n let topLevel = maxLevel;\r\n const nodes = new Array<TocNode>();\r\n element\r\n .querySelectorAll<HTMLElement>(\r\n \"h1:not([m3e-toc-ignore]),h2:not([m3e-toc-ignore]),h3:not([m3e-toc-ignore]),h4:not([m3e-toc-ignore]),h5:not([m3e-toc-ignore]),h6:not([m3e-toc-ignore]),m3e-heading[level]:not([m3e-toc-ignore])\",\r\n )\r\n .forEach((element) => {\r\n const level = TocGenerator.#getHeaderLevel(element);\r\n topLevel = Math.min(level, topLevel);\r\n nodes.push({\r\n id: element.id || guid(),\r\n element,\r\n level,\r\n label: getTextContent(element, true),\r\n nodes: new Array<TocNode>(),\r\n });\r\n });\r\n\r\n for (let level = topLevel + maxDepth - 1; level > topLevel; level--) {\r\n for (let i = 0; i < nodes.length; i++) {\r\n const node = nodes[i];\r\n if (node.level === level) {\r\n for (let j = i; j >= 0; j--) {\r\n const prev = nodes[j];\r\n if (prev.level < level) {\r\n prev.nodes.push(node);\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n nodes.forEach((x) => (x.level -= topLevel - 1));\r\n return nodes.filter((x) => x.level === 1);\r\n }\r\n\r\n /** @internal */\r\n static #getHeaderLevel(element: HTMLElement): number {\r\n return element.tagName.startsWith(\"H\")\r\n ? parseInt(element.tagName.substring(1))\r\n : parseInt(element.getAttribute(\"level\") ?? \"0\");\r\n }\r\n}\r\n","import { css, CSSResultGroup, html, LitElement, nothing, PropertyValues, unsafeCSS } from \"lit\";\r\nimport { property, query, state } from \"lit/decorators.js\";\r\n\r\nimport {\r\n AttachInternals,\r\n customElement,\r\n debounce,\r\n DesignToken,\r\n hasAssignedNodes,\r\n hasCustomState,\r\n HtmlFor,\r\n IntersectionController,\r\n MutationController,\r\n Role,\r\n ScrollController,\r\n scrollIntoViewIfNeeded,\r\n setCustomState,\r\n} from \"@m3e/web/core\";\r\n\r\nimport { SelectionManager } from \"@m3e/web/core/a11y\";\r\n\r\nimport { M3eTocItemElement } from \"./TocItemElement\";\r\nimport { TocGenerator, TocNode } from \"./TocGenerator\";\r\n\r\n/**\r\n * A table of contents that provides in-page scroll navigation.\r\n *\r\n * @description\r\n * The `m3e-toc` component generates a hierarchical table of contents for in-page navigation.\r\n * It automatically detects headings or sections in a target element, builds a navigable list,\r\n * and highlights the active section as the user scrolls. The component supports custom header\r\n * slots, depth limiting, smooth scrolling, and extensive theming via CSS custom properties.\r\n *\r\n * To exclude a heading from the generated table of contents, add the `m3e-toc-ignore` attribute\r\n * to that heading element.\r\n *\r\n * @example\r\n * ```html\r\n * <m3e-toc for=\"content\" max-depth=\"3\">\r\n * <span slot=\"overline\">Contents</span>\r\n * <span slot=\"title\">Documentation</span>\r\n * </m3e-toc>\r\n * <div id=\"content\">\r\n * <h2>Introduction</h2>\r\n * <h2>Getting Started</h2>\r\n * <h3>Installation</h3>\r\n * <h3>Usage</h3>\r\n * <h2>API Reference</h2>\r\n * </div>\r\n * ```\r\n *\r\n * @tag m3e-toc\r\n *\r\n * @slot - Renders content between the header and items.\r\n * @slot overline - Renders the overline of the table of contents.\r\n * @slot title - Renders the title of the table of contents.\r\n *\r\n * @attr for - The identifier of the interactive control to which this element is attached.\r\n * @attr max-depth - The maximum depth of the table of contents.\r\n *\r\n * @cssprop --m3e-toc-width - Width of the table of contents.\r\n * @cssprop --m3e-toc-container-color - Background color of the table of contents container.\r\n * @cssprop --m3e-toc-container-padding-inline - Inline padding of the table of contents container.\r\n * @cssprop --m3e-toc-container-padding-block - Block padding of the table of contents container.\r\n * @cssprop --m3e-toc-item-shape - Border radius of TOC items and active indicator.\r\n * @cssprop --m3e-toc-active-indicator-color - Border color of the active indicator.\r\n * @cssprop --m3e-toc-active-indicator-animation-duration - Animation duration for the active indicator.\r\n * @cssprop --m3e-toc-item-padding - Inline padding for TOC items and header.\r\n * @cssprop --m3e-toc-header-space - Block space below and between header elements.\r\n * @cssprop --m3e-toc-overline-font-size - Font size for the overline slot.\r\n * @cssprop --m3e-toc-overline-font-weight - Font weight for the overline slot.\r\n * @cssprop --m3e-toc-overline-line-height - Line height for the overline slot.\r\n * @cssprop --m3e-toc-overline-tracking - Letter spacing for the overline slot.\r\n * @cssprop --m3e-toc-overline-color - Text color for the overline slot.\r\n * @cssprop --m3e-toc-title-font-size - Font size for the title slot.\r\n * @cssprop --m3e-toc-title-font-weight - Font weight for the title slot.\r\n * @cssprop --m3e-toc-title-line-height - Line height for the title slot.\r\n * @cssprop --m3e-toc-title-tracking - Letter spacing for the title slot.\r\n * @cssprop --m3e-toc-title-color - Text color for the title slot.\r\n */\r\n@customElement(\"m3e-toc\")\r\nexport class M3eTocElement extends HtmlFor(AttachInternals(Role(LitElement, \"navigation\"))) {\r\n /** The styles of the element. */\r\n static override styles: CSSResultGroup = css`\r\n :host {\r\n display: inline-block;\r\n width: calc(var(--m3e-toc-width, 9.75rem));\r\n }\r\n .base {\r\n border-radius: var(--m3e-toc-container-shape, ${DesignToken.shape.corner.none});\r\n box-sizing: border-box;\r\n overflow: hidden;\r\n height: 100%;\r\n width: 100%;\r\n }\r\n .scroll-container {\r\n height: inherit;\r\n width: inherit;\r\n box-sizing: inherit;\r\n background-color: var(--m3e-toc-container-color, transparent);\r\n border-radius: inherit;\r\n padding-inline: var(--m3e-toc-container-padding-inline, 0px);\r\n padding-block: var(--m3e-toc-container-padding-block, 0px);\r\n position: relative;\r\n overflow-y: auto;\r\n overflow-x: hidden;\r\n scrollbar-width: ${DesignToken.scrollbar.thinWidth};\r\n scrollbar-color: ${DesignToken.scrollbar.color};\r\n }\r\n ul {\r\n list-style: none;\r\n padding-inline-start: unset;\r\n margin-block-start: unset;\r\n margin-block-end: unset;\r\n }\r\n ul,\r\n li {\r\n display: flex;\r\n flex-direction: column;\r\n align-items: stretch;\r\n }\r\n m3e-toc-item {\r\n flex: none;\r\n }\r\n .active-indicator {\r\n position: absolute;\r\n pointer-events: none;\r\n box-sizing: border-box;\r\n left: var(--m3e-toc-container-padding-inline, 0px);\r\n right: var(--m3e-toc-container-padding-inline, 0px);\r\n\r\n border-radius: var(--m3e-toc-item-shape, ${DesignToken.shape.corner.largeIncreased});\r\n border: 1px solid var(--m3e-toc-active-indicator-color, ${DesignToken.color.outline});\r\n transition: ${unsafeCSS(`visibility var(--m3e-toc-active-indicator-animation-duration, ${DesignToken.motion.duration.long1})\r\n ${DesignToken.motion.easing.standard},\r\n height var(--m3e-toc-active-indicator-animation-duration, ${DesignToken.motion.duration.long1})\r\n ${DesignToken.motion.easing.standard},\r\n top var(--m3e-toc-active-indicator-animation-duration, ${DesignToken.motion.duration.long1})\r\n ${DesignToken.motion.easing.standard}`)};\r\n }\r\n .header {\r\n display: flex;\r\n flex-direction: column;\r\n align-items: stretch;\r\n padding-inline-start: var(--m3e-toc-item-padding, 1rem);\r\n padding-block-end: var(--m3e-toc-header-space, 0.5rem);\r\n row-gap: var(--m3e-toc-header-space, 0.5rem);\r\n }\r\n .overline {\r\n white-space: nowrap;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\r\n }\r\n .title {\r\n display: -webkit-box;\r\n -webkit-line-clamp: 2;\r\n -webkit-box-orient: vertical;\r\n overflow: hidden;\r\n line-clamp: 2;\r\n }\r\n :host(:not(:is(:state(--with-overline), :--with-overline))) .overline,\r\n :host(:not(:is(:state(--with-title), :--with-title))) .title,\r\n :host(:not(:is(:state(--with-overline), :--with-overline)):not(:is(:state(--with-title), :--with-title))) .header {\r\n display: none;\r\n }\r\n ::slotted([slot=\"overline\"]) {\r\n font-size: var(--m3e-toc-overline-font-size, ${DesignToken.typescale.standard.label.small.fontSize});\r\n font-weight: var(--m3e-toc-overline-font-weight, ${DesignToken.typescale.standard.label.small.fontWeight});\r\n line-height: var(--m3e-toc-overline-line-height, ${DesignToken.typescale.standard.label.small.lineHeight});\r\n letter-spacing: var(--m3e-toc-overline-tracking, ${DesignToken.typescale.standard.label.small.tracking});\r\n color: var(--m3e-toc-overline-color, ${DesignToken.color.onSurfaceVariant});\r\n }\r\n ::slotted([slot=\"title\"]) {\r\n font-size: var(--m3e-toc-title-font-size, ${DesignToken.typescale.standard.headline.small.fontSize});\r\n font-weight: var(--m3e-toc-title-font-weight, ${DesignToken.typescale.standard.headline.small.fontWeight});\r\n line-height: var(--m3e-toc-title-line-height, ${DesignToken.typescale.standard.headline.small.lineHeight});\r\n letter-spacing: var(--m3e-toc-title-tracking, ${DesignToken.typescale.standard.headline.small.tracking});\r\n color: var(--m3e-toc-title-color, ${DesignToken.color.onSurface});\r\n }\r\n :host(:is(:state(--no-animate), :--no-animate)) .active-indicator {\r\n transition: none;\r\n }\r\n @media (prefers-reduced-motion) {\r\n .active-indicator {\r\n transition: none;\r\n }\r\n }\r\n `;\r\n\r\n /** @private */ @state() private _toc: Array<TocNode> = [];\r\n /** @private */ @query(\".active-indicator\") private readonly _activeIndicator!: HTMLElement;\r\n /** @private */ @query(\".scroll-container\") private readonly _scrollContainer!: HTMLElement;\r\n /** @private */ #ignoreScroll = false;\r\n\r\n /** @private */ readonly #selectionManager = new SelectionManager<M3eTocItemElement>()\r\n .withHomeAndEnd()\r\n .withVerticalOrientation()\r\n .disableRovingTabIndex()\r\n .onSelectedItemsChange(() => {\r\n if (this._activeIndicator) {\r\n const item = this.#selectionManager.selectedItems[0];\r\n if (!item) {\r\n setCustomState(this, \"--no-animate\", true);\r\n this._activeIndicator.style.top = `0px`;\r\n this._activeIndicator.style.height = `0px`;\r\n this._activeIndicator.style.visibility = \"hidden\";\r\n } else {\r\n const scrollContainer = this._scrollContainer;\r\n\r\n if (item === this.#selectionManager.items[0]) {\r\n scrollContainer.scrollTo({ top: 0, behavior: \"smooth\" });\r\n } else if (item === this.#selectionManager.items[this.#selectionManager.items.length - 1]) {\r\n scrollContainer.scrollTo({\r\n top: scrollContainer.scrollHeight - scrollContainer.clientHeight,\r\n behavior: \"smooth\",\r\n });\r\n } else {\r\n scrollIntoViewIfNeeded(item, this._scrollContainer, { block: \"nearest\", behavior: \"smooth\" });\r\n }\r\n this._activeIndicator.style.top = `${item.offsetTop}px`;\r\n this._activeIndicator.style.height = `${item.clientHeight}px`;\r\n this._activeIndicator.style.visibility = item.clientHeight == 0 ? \"hidden\" : \"\";\r\n\r\n if (hasCustomState(this, \"--no-animate\")) {\r\n setTimeout(() => setCustomState(this, \"--no-animate\", false), 40);\r\n }\r\n }\r\n }\r\n });\r\n\r\n /** @private */\r\n readonly #intersectionController = new IntersectionController(this, {\r\n target: null,\r\n callback: (entries) => {\r\n if (!this.control || this.#ignoreScroll) return;\r\n\r\n const targetOffset = this.control.scrollTop;\r\n let closestElement: HTMLElement | null = null;\r\n let closestDistance = Number.POSITIVE_INFINITY;\r\n\r\n entries\r\n .filter((x) => x.isIntersecting)\r\n .map((x) => <HTMLElement>x.target)\r\n .forEach((item) => {\r\n const offsetTop = item.offsetTop;\r\n const distance = Math.abs(offsetTop - targetOffset);\r\n if (distance < closestDistance) {\r\n closestDistance = distance;\r\n closestElement = item;\r\n }\r\n });\r\n\r\n if (closestElement) {\r\n const item = this.#selectionManager.items.find((x) => x.node?.element === closestElement);\r\n if (item) {\r\n this.#selectionManager.select(item);\r\n }\r\n }\r\n },\r\n });\r\n\r\n /** @private */\r\n readonly #scrollController = new ScrollController(this, {\r\n target: null,\r\n callback: () => (this.#ignoreScroll = false),\r\n debounce: true,\r\n });\r\n\r\n /** @private */\r\n readonly #mutationController = new MutationController(this, {\r\n target: null,\r\n config: {\r\n childList: true,\r\n subtree: true,\r\n },\r\n callback: () => this._updateToc(),\r\n });\r\n\r\n /**\r\n * The maximum depth of the table of contents.\r\n * @default 2\r\n */\r\n @property({ attribute: \"max-depth\", type: Number }) maxDepth = 2;\r\n\r\n /** @inheritdoc */\r\n override attach(control: HTMLElement): void {\r\n super.attach(control);\r\n this.#mutationController.observe(control);\r\n this.#scrollController.observe(control);\r\n this.#generateToc();\r\n }\r\n\r\n /** @inheritdoc */\r\n override detach(): void {\r\n if (this.control) {\r\n this.#mutationController.unobserve(this.control);\r\n this.#scrollController.unobserve(this.control);\r\n }\r\n super.detach();\r\n this.#generateToc();\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override willUpdate(changedProperties: PropertyValues<this>): void {\r\n super.willUpdate(changedProperties);\r\n\r\n if (changedProperties.has(\"maxDepth\")) {\r\n this.#generateToc();\r\n }\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override updated(_changedProperties: PropertyValues): void {\r\n super.updated(_changedProperties);\r\n\r\n if (_changedProperties.has(\"_toc\")) {\r\n const { added, removed } = this.#selectionManager.setItems([\r\n ...(this.shadowRoot?.querySelectorAll(\"m3e-toc-item\") ?? []),\r\n ]);\r\n\r\n if (!this.#selectionManager.activeItem) {\r\n setCustomState(this, \"--no-animate\", true);\r\n this.#selectionManager.updateActiveItem(added.find((x) => !x.disabled));\r\n }\r\n\r\n for (const item of added) {\r\n if (item.node) {\r\n this.#intersectionController.observe(item.node.element);\r\n }\r\n }\r\n\r\n for (const item of removed) {\r\n if (item.node) {\r\n this.#intersectionController.unobserve(item.node.element);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override render(): unknown {\r\n return html`<div class=\"base\">\r\n <div class=\"scroll-container\">\r\n <div class=\"header\">\r\n <div class=\"overline\">\r\n <slot name=\"overline\" @slotchange=\"${this.#handleOverlineSlotChange}\"></slot>\r\n </div>\r\n <div class=\"title\">\r\n <slot name=\"title\" @slotchange=\"${this.#handleTitleSlotChange}\"></slot>\r\n </div>\r\n </div>\r\n <slot></slot>\r\n <ul class=\"list\">\r\n ${this._toc.map((x) => this.#renderNode(x))}\r\n </ul>\r\n <div class=\"active-indicator\" aria-hidden=\"true\"></div>\r\n </div>\r\n </div>`;\r\n }\r\n\r\n /** @private */\r\n #renderNode(node: TocNode): unknown {\r\n return html`<li>\r\n <m3e-toc-item tabindex=\"-1\" .node=\"${node}\" @click=\"${this.#handleClick}\">${node.label}</m3e-toc-item>\r\n ${node.nodes.length == 0\r\n ? nothing\r\n : html`<ul>\r\n ${node.nodes.map((x) => this.#renderNode(x))}\r\n </ul>`}\r\n </li>`;\r\n }\r\n\r\n /** @private */\r\n #handleOverlineSlotChange(e: Event): void {\r\n setCustomState(this, \"--with-overline\", hasAssignedNodes(<HTMLSlotElement>e.target));\r\n }\r\n\r\n /** @private */\r\n #handleTitleSlotChange(e: Event): void {\r\n setCustomState(this, \"--with-title\", hasAssignedNodes(<HTMLSlotElement>e.target));\r\n }\r\n\r\n /** @private */\r\n #handleClick(e: Event): void {\r\n if (e.target instanceof M3eTocItemElement && !e.target.disabled && e.target.node?.element) {\r\n this.#ignoreScroll = true;\r\n e.target.node.element.scrollIntoView({ block: \"start\", behavior: \"smooth\" });\r\n this.#selectionManager.updateActiveItem(e.target);\r\n this.#selectionManager.select(e.target);\r\n }\r\n }\r\n\r\n /** @private */\r\n #generateToc(): void {\r\n this._toc = this.control ? TocGenerator.generate(this.control, Math.max(1, Math.min(this.maxDepth, 6))) : [];\r\n }\r\n\r\n /** @private */\r\n @debounce(40)\r\n private _updateToc(): void {\r\n this.#generateToc();\r\n }\r\n}\r\n\r\ndeclare global {\r\n interface HTMLElementTagNameMap {\r\n \"m3e-toc\": M3eTocElement;\r\n }\r\n}\r\n"],"names":["M3eTocItemElement","Selected","Disabled","AttachInternals","Role","LitElement","update","changedProperties","super","has","this","ariaSelected","ariaCurrent","selected","node","_base","style","setProperty","level","removeProperty","firstUpdated","_changedProperties","_stateLayer","attach","render","html","styles","css","DesignToken","shape","corner","largeIncreased","unsafeCSS","motion","duration","long1","easing","standard","typescale","body","large","fontSize","fontWeight","lineHeight","tracking","color","onSurfaceVariant","emphasized","onSurface","__decorate","query","prototype","state","customElement","TocGenerator","generate","element","maxDepth","topLevel","nodes","Array","querySelectorAll","forEach","__classPrivateFieldGet","_a","_TocGenerator_getHeaderLevel","Math","min","push","id","guid","label","getTextContent","i","length","j","prev","x","filter","tagName","startsWith","parseInt","substring","getAttribute","M3eTocElement","HtmlFor","constructor","_toc","_M3eTocElement_ignoreScroll","set","_M3eTocElement_selectionManager","SelectionManager","withHomeAndEnd","withVerticalOrientation","disableRovingTabIndex","onSelectedItemsChange","_activeIndicator","item","selectedItems","scrollContainer","_scrollContainer","items","scrollTo","top","behavior","scrollHeight","clientHeight","scrollIntoViewIfNeeded","block","offsetTop","height","visibility","hasCustomState","setTimeout","setCustomState","_M3eTocElement_intersectionController","IntersectionController","target","callback","entries","control","targetOffset","scrollTop","closestElement","closestDistance","Number","POSITIVE_INFINITY","isIntersecting","map","distance","abs","find","select","_M3eTocElement_scrollController","ScrollController","__classPrivateFieldSet","debounce","_M3eTocElement_mutationController","MutationController","config","childList","subtree","_updateToc","observe","_M3eTocElement_instances","_M3eTocElement_generateToc","call","detach","unobserve","willUpdate","updated","added","removed","setItems","shadowRoot","activeItem","updateActiveItem","disabled","_M3eTocElement_handleOverlineSlotChange","_M3eTocElement_handleTitleSlotChange","_M3eTocElement_renderNode","nothing","e","hasAssignedNodes","scrollIntoView","max","none","scrollbar","thinWidth","outline","small","headline","property","attribute","type"],"mappings":";;;;;2nBA0CO,IAAMA,EAAN,cAAgCC,EAASC,EAASC,EAAgBC,EAAKC,EAAY,YAwDrEC,MAAAA,CAAOC,GACxBC,MAAMF,OAAOC,GAETA,EAAkBE,IAAI,cACxBC,KAAKC,aAAe,KACpBD,KAAKE,YAAcF,KAAKG,SAAW,OAAS,MAG1CN,EAAkBE,IAAI,UACpBC,KAAKI,KACPJ,KAAKK,OAAOC,MAAMC,YAAY,WAAY,IAAGP,KAAKI,KAAKI,MAAQ,IAE/DR,KAAKK,OAAOC,MAAMG,eAAe,YAGvC,CAGmBC,YAAAA,CAAaC,GAC9Bb,MAAMY,aAAaC,GACnBX,KAAKY,aAAaC,OAAOb,KAC3B,CAGSc,MAAAA,GACP,OAAOC,CAAI,8FAEb,iCAjFgBzB,EAAA0B,OAAyBC,CAAG,iIAMGC,EAAYC,MAAMC,OAAOC,qXAYtDC,EACZ,4DAA4DJ,EAAYK,OAAOC,SAASC,UAAUP,EAAYK,OAAOG,OAAOC,qFAInFT,EAAYU,UAAUD,SAASE,KAAKC,MAAMC,2DACtCb,EAAYU,UAAUD,SAASE,KAAKC,MAAME,6DAC1Cd,EAAYU,UAAUD,SAASE,KAAKC,MAAMG,6DAC1Cf,EAAYU,UAAUD,SAASE,KAAKC,MAAMI,+CAC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C,MAAMmG,MAAM9H,mDACvDhB,EAAYiB,MAAMC,8FAGblB,EAAYU,UAAUD,SAASsI,SAASD,MAAMjI,4DAC1Cb,EAAYU,UAAUD,SAASsI,SAASD,MAAMhI,8DAC9Cd,EAAYU,UAAUD,SAASsI,SAASD,MAAM/H,8DAC9Cf,EAAYU,UAAUD,SAASsI,SAASD,MAAM9H,gDAC1DhB,EAAYiB,MAAMG,oLAYzBC,EAAA,CAAhBG,KAA0CgC,EAAAjC,UAAA,eACEF,EAAA,CAA5CC,EAAM,sBAAqEkC,EAAAjC,UAAA,2BAC/BF,EAAA,CAA5CC,EAAM,sBAAqEkC,EAAAjC,UAAA,2BA2FxCF,EAAA,CAAnD2H,EAAS,CAAEC,UAAW,YAAaC,KAAMjD,UAAuBzC,EAAAjC,UAAA,gBAAA,GAqHzDF,EAAA,CADPuF,EAAS,KAGTpD,EAAAjC,UAAA,aAAA,MAhUUiC,EAAanC,EAAA,CADzBI,EAAc,YACF+B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m3e/web",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.8",
|
|
4
4
|
"description": "Platform-native Web Components for M3E",
|
|
5
5
|
"author": "matraic <matraic@yahoo.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -317,7 +317,7 @@
|
|
|
317
317
|
},
|
|
318
318
|
"dependencies": {
|
|
319
319
|
"@floating-ui/dom": "^1.6.13",
|
|
320
|
-
"@material/material-color-utilities": "^0.
|
|
320
|
+
"@material/material-color-utilities": "^0.4.0",
|
|
321
321
|
"composed-offset-position": "^0.0.6"
|
|
322
322
|
},
|
|
323
323
|
"peerDependencies": {
|