@fluid-topics/ft-reader-toc 2.2.5 → 2.2.6

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.
@@ -1,5 +1,7 @@
1
1
  import { FtReaderToc } from "./ft-reader-toc";
2
+ import { FtReaderAccessibleToc } from "./ft-reader-accessible-toc";
2
3
  declare const _default: {
3
4
  "ft-reader-toc": typeof FtReaderToc;
5
+ "ft-reader-accessible-toc": typeof FtReaderAccessibleToc;
4
6
  };
5
7
  export default _default;
@@ -1,4 +1,6 @@
1
1
  import { FtReaderToc } from "./ft-reader-toc";
2
+ import { FtReaderAccessibleToc } from "./ft-reader-accessible-toc";
2
3
  export default {
3
4
  "ft-reader-toc": FtReaderToc,
5
+ "ft-reader-accessible-toc": FtReaderAccessibleToc,
4
6
  };
@@ -0,0 +1,19 @@
1
+ import { PropertyValues, TemplateResult } from "lit";
2
+ import { ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
3
+ import { TocNode } from "./ft-reader-toc.properties";
4
+ import { FtReaderBaseToc } from "./ft-reader-base-toc";
5
+ export declare class FtReaderAccessibleToc extends FtReaderBaseToc {
6
+ static elementDefinitions: ElementDefinitionsMap;
7
+ static styles: import("lit").CSSResult;
8
+ private currentTocNode?;
9
+ protected willUpdate(props: PropertyValues<FtReaderBaseToc>): void;
10
+ private allTocIds;
11
+ protected render(): TemplateResult<1>;
12
+ protected renderNode(node: TocNode): TemplateResult;
13
+ private renderLinkIcon;
14
+ private renderNodeTag;
15
+ private onLinkClick;
16
+ private onKeyDown;
17
+ private get allLinks();
18
+ private selectNextNode;
19
+ }
@@ -0,0 +1,219 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { html, nothing, } from "lit";
8
+ import { map } from "lit/directives/map.js";
9
+ import { styleMap } from "lit/directives/style-map.js";
10
+ import { ifDefined } from "lit/directives/if-defined.js";
11
+ import { FtTypography, FtTypographyVariants, } from "@fluid-topics/ft-typography";
12
+ import { FtReaderTocCssVariables } from "./ft-reader-toc.styles";
13
+ import { FtSkeleton } from "@fluid-topics/ft-skeleton";
14
+ import { FtRipple } from "@fluid-topics/ft-ripple";
15
+ import { accessibleStyles } from "./ft-reader-accessible-toc.styles";
16
+ import { FtReaderBaseToc } from "./ft-reader-base-toc";
17
+ import { classMap } from "lit/directives/class-map.js";
18
+ import { FtChip } from "@fluid-topics/ft-chip";
19
+ import { state } from "lit/decorators.js";
20
+ export class FtReaderAccessibleToc extends FtReaderBaseToc {
21
+ willUpdate(props) {
22
+ var _a, _b, _c;
23
+ super.willUpdate(props);
24
+ if (props.has("toc") || props.has("highlightedTocIds")) {
25
+ const allTocIds = (_b = (_a = this.toc) === null || _a === void 0 ? void 0 : _a.flatMap((t) => this.allTocIds(t))) !== null && _b !== void 0 ? _b : [];
26
+ for (const tocId of allTocIds) {
27
+ if ((_c = this.highlightedTocIds) === null || _c === void 0 ? void 0 : _c.includes(tocId)) {
28
+ this.currentTocNode = tocId;
29
+ break;
30
+ }
31
+ }
32
+ }
33
+ }
34
+ allTocIds(toc) {
35
+ return [toc.tocId, ...(toc.children.flatMap((t) => this.allTocIds(t)))];
36
+ }
37
+ render() {
38
+ var _a, _b;
39
+ return html `
40
+ <div class="${classMap(this.tocClasses)}" part="container">
41
+ <ft-size-watcher @change=${this.onViewportSizeChange}></ft-size-watcher>
42
+ ${this.renderExpandCollapseAll()}
43
+ <div part="tree" role="tree" aria-label="${(_a = this.currentPage) === null || _a === void 0 ? void 0 : _a.title}">
44
+ ${map((_b = this.toc) !== null && _b !== void 0 ? _b : [], (node) => this.renderNode(node))}
45
+ </div>
46
+ </div>
47
+ `;
48
+ }
49
+ renderNode(node) {
50
+ var _a, _b, _c, _d;
51
+ const isHighlighted = (_a = this.highlightedTocIds) === null || _a === void 0 ? void 0 : _a.includes(node.tocId);
52
+ const isCurrent = node.tocId === this.currentTocNode;
53
+ const isExpanded = this.nodeIsExpanded(node);
54
+ const canDisplayChildren = node.children.length > 0;
55
+ const currentPageDepth = this.isCurrentPageToc ? ((_c = (_b = this.currentPage) === null || _b === void 0 ? void 0 : _b.breadcrumb.length) !== null && _c !== void 0 ? _c : 0) + 1 : 0;
56
+ const tabNumber = node.depth - 1 - currentPageDepth;
57
+ const styles = {
58
+ "padding-left": `calc( ${FtReaderTocCssVariables.tabulationSize} * ${tabNumber} + 4px)`, // +4px for padding before button
59
+ };
60
+ return html `
61
+ <div part="node ${isHighlighted ? "node-highlighted" : ""}"
62
+ class="ft-reader-toc--node ${isHighlighted ? "ft-reader-toc--node-highlighted" : ""}"
63
+ data-depth="${node.depth}">
64
+ ${this.translationLoading
65
+ ? html `
66
+ <ft-skeleton></ft-skeleton>`
67
+ : html `
68
+ <a part="node-link ${node.contentClass ? `node-link-class-${node.contentClass}` : ""}"
69
+ class="ft-reader-toc--node-link"
70
+ style="${styleMap(styles)}"
71
+ href="${(_d = this.service) === null || _d === void 0 ? void 0 : _d.getLink(node.tocId)}"
72
+ tabindex="${isCurrent ? "0" : "-1"}"
73
+ data-tocId="${node.tocId}"
74
+ data-depth="${node.depth}"
75
+ role="treeitem"
76
+ aria-owns="${ifDefined(canDisplayChildren ? `${node.tocId}-children` : undefined)}"
77
+ aria-expanded="${ifDefined(canDisplayChildren ? isExpanded : undefined)}"
78
+ aria-current="${ifDefined(isHighlighted ? "page" : undefined)}"
79
+ @click=${(e) => this.onLinkClick(e, node.tocId)}
80
+ @keydown=${this.onKeyDown}>
81
+ ${this.renderLinkIcon(node)}
82
+ ${this.renderNodeTag(node)}
83
+ <ft-typography part="node-label" variant="${FtTypographyVariants.body2}">${node.title}</ft-typography>
84
+ </a>
85
+ `}
86
+ ${canDisplayChildren ? html `
87
+ <div id="${node.tocId}-children"
88
+ part="node-children"
89
+ class="ft-reader-toc--node-children"
90
+ role="group"
91
+ ?hidden=${!isExpanded}>
92
+ ${map(isExpanded ? node.children : [], (child) => this.renderNode(child))}
93
+ </div>
94
+ ` : nothing}
95
+ </div>
96
+ `;
97
+ }
98
+ renderLinkIcon(node) {
99
+ const canDisplayChildren = node.children.length > 0;
100
+ const isExpanded = this.nodeIsExpanded(node);
101
+ if (this.nodesToExpandExist && !this.expanded) {
102
+ if (canDisplayChildren) {
103
+ return html `
104
+ <div part="node-icon-container">
105
+ <ft-icon part="node-icon"
106
+ class="ft-reader-toc--node-icon"
107
+ data-expand-node="${node.tocId}"
108
+ .value=${isExpanded ? (this.collapseIcon || "MINUS") : (this.expandIcon || "PLUS")}
109
+ variant="${this.iconVariant}"
110
+ @click=${(e) => this.manuallyToggle(node.tocId, isExpanded, e)}
111
+ aria-hidden="true">
112
+ </ft-icon>
113
+ <ft-ripple>
114
+
115
+ </ft-ripple>
116
+ </div>
117
+ `;
118
+ }
119
+ else {
120
+ return this.getLeafNodeIcon();
121
+ }
122
+ }
123
+ else {
124
+ return !canDisplayChildren ? this.getLeafNodeIcon() : nothing;
125
+ }
126
+ }
127
+ renderNodeTag(node) {
128
+ if (!node.contentTag) {
129
+ return nothing;
130
+ }
131
+ const parts = ["node-tag", `node-tag-${node.contentTag}`];
132
+ if (node.contentClass) {
133
+ parts.push(`node-tag-class-${node.contentClass}`);
134
+ }
135
+ return html `
136
+ <ft-chip dense
137
+ part="${parts.join(" ")}">
138
+ ${node.contentTag}
139
+ </ft-chip>
140
+ `;
141
+ }
142
+ onLinkClick(e, tocId) {
143
+ var _a, _b, _c;
144
+ if (!e.ctrlKey && !e.metaKey) {
145
+ e.preventDefault();
146
+ performance.mark(`fluid_topics__reader_link_click__${tocId}`);
147
+ (_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.navigateToTopic(tocId);
148
+ (_b = this.stateManager) === null || _b === void 0 ? void 0 : _b.store.commands.clear(/^focus-topic-/);
149
+ (_c = this.stateManager) === null || _c === void 0 ? void 0 : _c.store.commands.add({ type: `focus-topic-${tocId}` });
150
+ }
151
+ }
152
+ onKeyDown(e) {
153
+ var _a, _b, _c, _d, _e;
154
+ const target = e.currentTarget;
155
+ switch (e.key) {
156
+ case "Home":
157
+ (_a = this.allLinks.shift()) === null || _a === void 0 ? void 0 : _a.focus();
158
+ break;
159
+ case "End":
160
+ (_b = this.allLinks.pop()) === null || _b === void 0 ? void 0 : _b.focus();
161
+ break;
162
+ case "ArrowDown":
163
+ this.selectNextNode(target, this.allLinks);
164
+ e.preventDefault();
165
+ break;
166
+ case "ArrowUp":
167
+ this.selectNextNode(target, this.allLinks.reverse());
168
+ e.preventDefault();
169
+ break;
170
+ case "ArrowRight":
171
+ if (target.ariaExpanded === "true") {
172
+ this.selectNextNode(target, this.allLinks);
173
+ }
174
+ else if (target.ariaExpanded === "false") {
175
+ this.manuallyToggle(target.getAttribute("data-tocId"), false);
176
+ }
177
+ e.preventDefault();
178
+ break;
179
+ case "ArrowLeft":
180
+ if (target.ariaExpanded === "true") {
181
+ this.manuallyToggle(target.getAttribute("data-tocId"), true);
182
+ }
183
+ else {
184
+ // node-link -> node -> node-children -> node (parent) -> link
185
+ const parentNode = (_e = (_d = (_c = target.parentElement) === null || _c === void 0 ? void 0 : _c.parentElement) === null || _d === void 0 ? void 0 : _d.parentElement) === null || _e === void 0 ? void 0 : _e.querySelector("[part=\"node-link\"]");
186
+ parentNode === null || parentNode === void 0 ? void 0 : parentNode.focus();
187
+ }
188
+ e.preventDefault();
189
+ break;
190
+ }
191
+ }
192
+ get allLinks() {
193
+ var _a, _b;
194
+ return Array.from((_b = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll("[part~=\"node-link\"]")) !== null && _b !== void 0 ? _b : []);
195
+ }
196
+ selectNextNode(target, nodes) {
197
+ let useNextNode = false;
198
+ for (const node of nodes) {
199
+ if (useNextNode) {
200
+ node.focus();
201
+ return;
202
+ }
203
+ if (node.getAttribute("data-tocId") === target.getAttribute("data-tocId")) {
204
+ useNextNode = true;
205
+ }
206
+ }
207
+ }
208
+ }
209
+ FtReaderAccessibleToc.elementDefinitions = {
210
+ ...FtReaderBaseToc.elementDefinitions,
211
+ "ft-typography": FtTypography,
212
+ "ft-skeleton": FtSkeleton,
213
+ "ft-ripple": FtRipple,
214
+ "ft-chip": FtChip,
215
+ };
216
+ FtReaderAccessibleToc.styles = accessibleStyles;
217
+ __decorate([
218
+ state()
219
+ ], FtReaderAccessibleToc.prototype, "currentTocNode", void 0);
@@ -0,0 +1 @@
1
+ export declare const accessibleStyles: import("lit").CSSResult;
@@ -0,0 +1,75 @@
1
+ import { css } from "lit";
2
+ import { setVariable } from "@fluid-topics/ft-wc-utils";
3
+ import { FtTypographyCssVariables } from "@fluid-topics/ft-typography/build/ft-typography.styles";
4
+ import { FtButtonCssVariables } from "@fluid-topics/ft-button/build/ft-button.styles";
5
+ import { FtReaderInternalLinkCssVariables } from "@fluid-topics/ft-reader-internal-link";
6
+ import { FtIconCssVariables } from "@fluid-topics/ft-icon";
7
+ import { FtReaderTocCssVariables } from "./ft-reader-toc.styles";
8
+ // language=CSS
9
+ export const accessibleStyles = css `
10
+ .ft-reader-toc {
11
+ color: ${FtReaderTocCssVariables.textColor};
12
+ }
13
+
14
+ [part~="node-highlighted"] > [part~="node-link"] {
15
+ background-color: ${FtReaderTocCssVariables.highlightedBackgroundColor};
16
+ color: ${FtReaderTocCssVariables.highlightedTextColor};
17
+ ${setVariable(FtTypographyCssVariables.fontWeight, FtReaderTocCssVariables.highlightedFontWeight)}
18
+ }
19
+
20
+ [part~="node-link"] {
21
+ display: flex;
22
+ gap: 4px;
23
+ padding: ${FtReaderTocCssVariables.verticalSpacing} 4px; /* left padding is override on inline style */
24
+ align-items: center;
25
+ text-decoration: none;
26
+ color: inherit;
27
+
28
+ &:hover {
29
+ color: ${FtReaderTocCssVariables.hoverColor};
30
+ }
31
+
32
+ &:focus {
33
+ outline-color: ${FtReaderInternalLinkCssVariables.outlineColor};
34
+ }
35
+ }
36
+
37
+ [part~="node-icon-container"] {
38
+ position: relative;
39
+ display: flex;
40
+ border-radius: 100%;
41
+ overflow: hidden;
42
+ color: ${FtReaderTocCssVariables.treeNodeIconColor};
43
+ }
44
+
45
+ [part~="node-icon"] {
46
+ ${setVariable(FtIconCssVariables.size, FtReaderTocCssVariables.iconFontSize)};
47
+ }
48
+
49
+ [part~="leaf-node-icon"] {
50
+ color: ${FtReaderTocCssVariables.leafNodeIconColor};
51
+ width: ${FtReaderTocCssVariables.iconFontSize};
52
+ }
53
+
54
+ .ft-reader-toc--expand-collapse-all-button {
55
+ ${setVariable(FtButtonCssVariables.color, FtReaderTocCssVariables.expandCollapseAllButtonColor)};
56
+ ${setVariable(FtButtonCssVariables.backgroundColor, FtReaderTocCssVariables.expandCollapseAllButtonBackgroundColor)};
57
+ }
58
+
59
+ .ft-reader-toc-expand-collapse-all-container {
60
+ margin: 8px 4px;
61
+ display: flex;
62
+ }
63
+
64
+ .ft-reader-toc-expand-collapse-all-right {
65
+ justify-content: flex-end;
66
+ }
67
+
68
+ .ft-reader-toc-expand-collapse-all-center {
69
+ justify-content: center;
70
+ }
71
+
72
+ .ft-reader-toc-expand-collapse-all-justify ft-button {
73
+ flex-grow: 1;
74
+ }
75
+ `;
@@ -0,0 +1,61 @@
1
+ import { nothing, PropertyValues, TemplateResult } from "lit";
2
+ import { ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
3
+ import { FtReaderComponent, FtReaderPage, FtReaderTocNode } from "@fluid-topics/ft-reader-context/build/registration";
4
+ import { FtIconVariants } from "@fluid-topics/ft-icon";
5
+ import { FtSizeCategory, FtSizeChangeEvent } from "@fluid-topics/ft-size-watcher";
6
+ import { FtReaderTocProperties } from "./ft-reader-toc.properties";
7
+ import { FtPagesTocNode } from "@fluid-topics/ft-reader-context/build/store/model";
8
+ type TocNode = FtReaderTocNode | FtPagesTocNode;
9
+ declare const FtReaderBaseToc_base: typeof FtReaderComponent & import("@fluid-topics/ft-wc-utils").Constructor<import("@fluid-topics/ft-i18n").FtLitElementWithI18nInterface>;
10
+ export declare abstract class FtReaderBaseToc extends FtReaderBaseToc_base implements FtReaderTocProperties {
11
+ static elementDefinitions: ElementDefinitionsMap;
12
+ expanded: boolean;
13
+ iconVariant: FtIconVariants;
14
+ collapseIcon: string;
15
+ expandIcon: string;
16
+ leafNodeIconVariant: FtIconVariants;
17
+ leafNodeIcon: string;
18
+ expandCollapseAll: boolean;
19
+ expandCollapseAllHideLabel: boolean;
20
+ expandCollapseAllTrailingIcon: boolean;
21
+ expandCollapseAllAlignment: "left" | "right" | "center" | "justify";
22
+ expandCollapseAllHideIcon: boolean;
23
+ expandCollapseAllIconVariant?: FtIconVariants;
24
+ collapseAllIcon: string;
25
+ expandAllIcon: string;
26
+ autoCollapse: boolean;
27
+ scrollCurrentTopicIntoView: boolean;
28
+ scope: FtReaderTocProperties["scope"];
29
+ empty: boolean;
30
+ toc?: Array<TocNode>;
31
+ currentPage?: FtReaderPage;
32
+ highlightedTocIds?: string[];
33
+ translationLoading?: boolean;
34
+ automaticallyExpandedNodes: Set<string>;
35
+ manuallyExpandedNodes: Set<string>;
36
+ manuallyCollapsedNodes: Set<string>;
37
+ expandAll: boolean;
38
+ viewportSize: FtSizeCategory;
39
+ nodesToExpandExist: boolean;
40
+ get isCurrentPageToc(): boolean;
41
+ protected nodeIsExpanded(node: TocNode): boolean;
42
+ constructor();
43
+ protected willUpdate(changedProperties: PropertyValues<FtReaderBaseToc>): void;
44
+ protected contentAvailableCallback(props: PropertyValues<FtReaderBaseToc>): void;
45
+ protected get tocClasses(): {
46
+ "ft-reader-toc": boolean;
47
+ "ft-reader-toc-mobile": boolean;
48
+ "ft-reader-toc-desktop": boolean;
49
+ "ft-reader-toc-loaded": boolean;
50
+ "ft-reader-toc-expanded": boolean;
51
+ };
52
+ protected renderExpandCollapseAll(): TemplateResult<1> | typeof nothing;
53
+ protected abstract renderNode(node: TocNode): TemplateResult;
54
+ protected buildAutomaticallyExpandedNodes(tocIdsToShow: Array<string>): Set<string>;
55
+ protected manuallyToggle(tocId: string, isExpanded: boolean, e?: MouseEvent): void;
56
+ protected onViewportSizeChange(event: FtSizeChangeEvent): void;
57
+ protected toggleExpandCollapseAll(): void;
58
+ protected getExpandCollapseAllTooltipPosition(): "left" | "right" | "bottom";
59
+ protected getLeafNodeIcon(): TemplateResult<1>;
60
+ }
61
+ export {};
@@ -0,0 +1,253 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { html, nothing, } from "lit";
8
+ import { property, state, } from "lit/decorators.js";
9
+ import { hasChanged, redux, scrollHelper, } from "@fluid-topics/ft-wc-utils";
10
+ import { FtReaderComponent, } from "@fluid-topics/ft-reader-context/build/registration";
11
+ import { FtIcon, FtIconVariants, } from "@fluid-topics/ft-icon";
12
+ import { FtButton } from "@fluid-topics/ft-button";
13
+ import { FtSizeCategory, FtSizeWatcher, } from "@fluid-topics/ft-size-watcher";
14
+ import { withI18n } from "@fluid-topics/ft-i18n";
15
+ import { readerToc, readerTocDefaultMessages, } from "./FtReaderTocMessages";
16
+ export class FtReaderBaseToc extends withI18n(FtReaderComponent) {
17
+ get isCurrentPageToc() {
18
+ return this.scope === "current-page";
19
+ }
20
+ nodeIsExpanded(node) {
21
+ return this.expanded || this.manuallyExpandedNodes.has(node.tocId) || ((this.expandAll || this.automaticallyExpandedNodes.has(node.tocId)) && !this.manuallyCollapsedNodes.has(node.tocId));
22
+ }
23
+ constructor() {
24
+ super();
25
+ this.expanded = false;
26
+ this.iconVariant = FtIconVariants.fluid_topics;
27
+ this.collapseIcon = "MINUS";
28
+ this.expandIcon = "PLUS";
29
+ this.leafNodeIconVariant = FtIconVariants.fluid_topics;
30
+ this.leafNodeIcon = "DOT";
31
+ this.expandCollapseAll = false;
32
+ this.expandCollapseAllHideLabel = false;
33
+ this.expandCollapseAllTrailingIcon = false;
34
+ this.expandCollapseAllAlignment = "left";
35
+ this.expandCollapseAllHideIcon = false;
36
+ this.collapseAllIcon = "ICON_COLLAPSE";
37
+ this.expandAllIcon = "ICON_EXPAND";
38
+ this.autoCollapse = false;
39
+ this.scrollCurrentTopicIntoView = false;
40
+ this.scope = "pages";
41
+ this.empty = true;
42
+ this.automaticallyExpandedNodes = new Set();
43
+ this.manuallyExpandedNodes = new Set();
44
+ this.manuallyCollapsedNodes = new Set();
45
+ this.expandAll = false;
46
+ this.viewportSize = FtSizeCategory.M;
47
+ this.nodesToExpandExist = false;
48
+ this.addI18nContext(readerToc, readerTocDefaultMessages);
49
+ }
50
+ willUpdate(changedProperties) {
51
+ var _a, _b, _c;
52
+ super.willUpdate(changedProperties);
53
+ if (changedProperties.has("toc")) {
54
+ this.nodesToExpandExist = ((_a = this.toc) !== null && _a !== void 0 ? _a : []).some((n) => n.children.length > 0);
55
+ }
56
+ if (changedProperties.has("highlightedTocIds") && !this.expanded) {
57
+ this.automaticallyExpandedNodes = this.buildAutomaticallyExpandedNodes((_b = this.highlightedTocIds) !== null && _b !== void 0 ? _b : []);
58
+ }
59
+ this.empty = ((_c = this.toc) !== null && _c !== void 0 ? _c : []).length === 0;
60
+ }
61
+ contentAvailableCallback(props) {
62
+ var _a, _b;
63
+ super.contentAvailableCallback(props);
64
+ if (this.scrollCurrentTopicIntoView && props.has("highlightedTocIds") && this.highlightedTocIds && ((_a = this.highlightedTocIds) === null || _a === void 0 ? void 0 : _a.length) > 0) {
65
+ const target = (_b = this.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector(`[tocId="${this.highlightedTocIds[0]}"]`);
66
+ if (target) {
67
+ scrollHelper.scrollIntoViewIfPossible(target, { behavior: "instant", position: 0.25 });
68
+ }
69
+ }
70
+ }
71
+ get tocClasses() {
72
+ return {
73
+ "ft-reader-toc": true,
74
+ "ft-reader-toc-mobile": this.viewportSize === FtSizeCategory.S,
75
+ "ft-reader-toc-desktop": this.viewportSize !== FtSizeCategory.S,
76
+ "ft-reader-toc-loaded": this.currentPage != null,
77
+ "ft-reader-toc-expanded": this.expanded,
78
+ };
79
+ }
80
+ renderExpandCollapseAll() {
81
+ return this.expandCollapseAll && !this.expanded && this.nodesToExpandExist ? html `
82
+ <div part="expand-collapse-all-container"
83
+ class="ft-reader-toc-expand-collapse-all-container ft-reader-toc-expand-collapse-all-${this.expandCollapseAllAlignment}">
84
+ <ft-button part="expand-collapse-all"
85
+ class="ft-reader-toc--expand-collapse-all-button"
86
+ iconVariant="${this.expandCollapseAllIconVariant}"
87
+ icon="${this.expandCollapseAllHideIcon ? "" : (this.expandAll
88
+ ? (this.collapseAllIcon || "ICON_COLLAPSE")
89
+ : (this.expandAllIcon || "ICON_EXPAND"))}"
90
+ label="${this.expandAll ? readerToc.messages.collapseAllLong() : readerToc.messages.expandAllLong()}"
91
+ tooltipPosition="${this.getExpandCollapseAllTooltipPosition()}"
92
+ ?trailingIcon=${this.expandCollapseAllTrailingIcon}
93
+ @click=${() => this.toggleExpandCollapseAll()}>
94
+ ${this.expandCollapseAllHideLabel ? "" : this.expandAll ? readerToc.messages.collapseAll() : readerToc.messages.expandAll()}
95
+ </ft-button>
96
+ </div>
97
+ ` : nothing;
98
+ }
99
+ buildAutomaticallyExpandedNodes(tocIdsToShow) {
100
+ var _a, _b;
101
+ const topicsToExpand = new Set(this.autoCollapse ? [] : this.automaticallyExpandedNodes);
102
+ for (const tocIdToShow of tocIdsToShow) {
103
+ let tocIdToExpand = tocIdToShow;
104
+ while (tocIdToExpand && !topicsToExpand.has(tocIdToExpand)) {
105
+ topicsToExpand.add(tocIdToExpand);
106
+ this.manuallyCollapsedNodes.delete(tocIdToExpand);
107
+ tocIdToExpand = (_b = (_a = this.service) === null || _a === void 0 ? void 0 : _a.getTocNodeNow(tocIdToExpand)) === null || _b === void 0 ? void 0 : _b.parentTocId;
108
+ }
109
+ }
110
+ return topicsToExpand;
111
+ }
112
+ manuallyToggle(tocId, isExpanded, e) {
113
+ e === null || e === void 0 ? void 0 : e.stopPropagation();
114
+ e === null || e === void 0 ? void 0 : e.preventDefault();
115
+ if (isExpanded) {
116
+ this.manuallyCollapsedNodes.add(tocId);
117
+ this.manuallyExpandedNodes.delete(tocId);
118
+ }
119
+ else {
120
+ this.manuallyExpandedNodes.add(tocId);
121
+ this.manuallyCollapsedNodes.delete(tocId);
122
+ }
123
+ this.requestUpdate();
124
+ }
125
+ onViewportSizeChange(event) {
126
+ this.viewportSize = event.detail.category;
127
+ }
128
+ toggleExpandCollapseAll() {
129
+ this.expandAll = !this.expandAll;
130
+ this.automaticallyExpandedNodes = new Set();
131
+ this.manuallyExpandedNodes = new Set();
132
+ this.manuallyCollapsedNodes = new Set();
133
+ }
134
+ getExpandCollapseAllTooltipPosition() {
135
+ switch (this.expandCollapseAllAlignment) {
136
+ case "right":
137
+ return "left";
138
+ case "left":
139
+ return "right";
140
+ default:
141
+ return "bottom";
142
+ }
143
+ }
144
+ getLeafNodeIcon() {
145
+ return html `
146
+ <ft-icon class="ft-reader-toc--leaf-node-icon"
147
+ part="leaf-node-icon"
148
+ .variant=${this.leafNodeIconVariant}
149
+ .value=${this.leafNodeIcon}></ft-icon>
150
+ `;
151
+ }
152
+ }
153
+ FtReaderBaseToc.elementDefinitions = {
154
+ "ft-button": FtButton,
155
+ "ft-icon": FtIcon,
156
+ "ft-size-watcher": FtSizeWatcher,
157
+ };
158
+ __decorate([
159
+ property({ type: Boolean })
160
+ ], FtReaderBaseToc.prototype, "expanded", void 0);
161
+ __decorate([
162
+ property()
163
+ ], FtReaderBaseToc.prototype, "iconVariant", void 0);
164
+ __decorate([
165
+ property()
166
+ ], FtReaderBaseToc.prototype, "collapseIcon", void 0);
167
+ __decorate([
168
+ property()
169
+ ], FtReaderBaseToc.prototype, "expandIcon", void 0);
170
+ __decorate([
171
+ property()
172
+ ], FtReaderBaseToc.prototype, "leafNodeIconVariant", void 0);
173
+ __decorate([
174
+ property()
175
+ ], FtReaderBaseToc.prototype, "leafNodeIcon", void 0);
176
+ __decorate([
177
+ property({ type: Boolean })
178
+ ], FtReaderBaseToc.prototype, "expandCollapseAll", void 0);
179
+ __decorate([
180
+ property({ type: Boolean })
181
+ ], FtReaderBaseToc.prototype, "expandCollapseAllHideLabel", void 0);
182
+ __decorate([
183
+ property({ type: Boolean })
184
+ ], FtReaderBaseToc.prototype, "expandCollapseAllTrailingIcon", void 0);
185
+ __decorate([
186
+ property()
187
+ ], FtReaderBaseToc.prototype, "expandCollapseAllAlignment", void 0);
188
+ __decorate([
189
+ property({ type: Boolean })
190
+ ], FtReaderBaseToc.prototype, "expandCollapseAllHideIcon", void 0);
191
+ __decorate([
192
+ property()
193
+ ], FtReaderBaseToc.prototype, "expandCollapseAllIconVariant", void 0);
194
+ __decorate([
195
+ property()
196
+ ], FtReaderBaseToc.prototype, "collapseAllIcon", void 0);
197
+ __decorate([
198
+ property()
199
+ ], FtReaderBaseToc.prototype, "expandAllIcon", void 0);
200
+ __decorate([
201
+ property({ type: Boolean })
202
+ ], FtReaderBaseToc.prototype, "autoCollapse", void 0);
203
+ __decorate([
204
+ property({ type: Boolean })
205
+ ], FtReaderBaseToc.prototype, "scrollCurrentTopicIntoView", void 0);
206
+ __decorate([
207
+ property()
208
+ ], FtReaderBaseToc.prototype, "scope", void 0);
209
+ __decorate([
210
+ property({ type: Boolean, reflect: true })
211
+ ], FtReaderBaseToc.prototype, "empty", void 0);
212
+ __decorate([
213
+ redux({
214
+ selector: (s, self) => {
215
+ var _a, _b, _c;
216
+ if (self.isCurrentPageToc) {
217
+ return ((_a = s.paginationConfiguration) === null || _a === void 0 ? void 0 : _a.splitCurrentPageToc) ? (_b = s.currentPage) === null || _b === void 0 ? void 0 : _b.toc : undefined;
218
+ }
219
+ return ((_c = s.paginationConfiguration) === null || _c === void 0 ? void 0 : _c.splitCurrentPageToc) ? s.pagesToc : s.toc;
220
+ },
221
+ })
222
+ ], FtReaderBaseToc.prototype, "toc", void 0);
223
+ __decorate([
224
+ redux()
225
+ ], FtReaderBaseToc.prototype, "currentPage", void 0);
226
+ __decorate([
227
+ redux({
228
+ selector: (s, self) => {
229
+ var _a, _b;
230
+ return ((_a = s.paginationConfiguration) === null || _a === void 0 ? void 0 : _a.splitCurrentPageToc) && !self.isCurrentPageToc
231
+ ? (((_b = s.currentPage) === null || _b === void 0 ? void 0 : _b.rootTocId) ? [s.currentPage.rootTocId] : [])
232
+ : s.visibleTopics;
233
+ },
234
+ })
235
+ ], FtReaderBaseToc.prototype, "highlightedTocIds", void 0);
236
+ __decorate([
237
+ redux({ selector: (s) => s.translation.isLoading })
238
+ ], FtReaderBaseToc.prototype, "translationLoading", void 0);
239
+ __decorate([
240
+ state({ hasChanged })
241
+ ], FtReaderBaseToc.prototype, "automaticallyExpandedNodes", void 0);
242
+ __decorate([
243
+ state({ hasChanged })
244
+ ], FtReaderBaseToc.prototype, "manuallyExpandedNodes", void 0);
245
+ __decorate([
246
+ state({ hasChanged })
247
+ ], FtReaderBaseToc.prototype, "manuallyCollapsedNodes", void 0);
248
+ __decorate([
249
+ state()
250
+ ], FtReaderBaseToc.prototype, "expandAll", void 0);
251
+ __decorate([
252
+ state()
253
+ ], FtReaderBaseToc.prototype, "viewportSize", void 0);