@fluid-topics/ft-reader-toc 1.1.99 → 1.1.101
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/build/ft-reader-toc.d.ts +2 -0
- package/build/ft-reader-toc.js +54 -42
- package/build/ft-reader-toc.light.js +119 -115
- package/build/ft-reader-toc.min.js +145 -141
- package/build/ft-reader-toc.properties.d.ts +1 -0
- package/build/ft-reader-toc.styles.js +6 -2
- package/package.json +7 -7
package/build/ft-reader-toc.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export declare class FtReaderToc extends FtReaderComponent implements FtReaderTo
|
|
|
21
21
|
collapseAllIcon: string;
|
|
22
22
|
expandAllIcon: string;
|
|
23
23
|
autoCollapse: boolean;
|
|
24
|
+
scrollCurrentTopicIntoView: boolean;
|
|
24
25
|
scope: FtReaderTocProperties["scope"];
|
|
25
26
|
empty: boolean;
|
|
26
27
|
labels: FtReaderTocLabels;
|
|
@@ -36,6 +37,7 @@ export declare class FtReaderToc extends FtReaderComponent implements FtReaderTo
|
|
|
36
37
|
private nodesToExpandExist;
|
|
37
38
|
get isCurrentPageToc(): boolean;
|
|
38
39
|
protected update(changedProperties: PropertyValues): void;
|
|
40
|
+
protected contentAvailableCallback(props: PropertyValues): void;
|
|
39
41
|
protected render(): TemplateResult<1>;
|
|
40
42
|
private renderExpandCollapseAll;
|
|
41
43
|
private renderNode;
|
package/build/ft-reader-toc.js
CHANGED
|
@@ -9,7 +9,7 @@ import { repeat } from "lit/directives/repeat.js";
|
|
|
9
9
|
import { classMap } from "lit/directives/class-map.js";
|
|
10
10
|
import { styleMap } from "lit/directives/style-map.js";
|
|
11
11
|
import { property, state } from "lit/decorators.js";
|
|
12
|
-
import { hasChanged, jsonProperty, ParametrizedLabelResolver, redux } from "@fluid-topics/ft-wc-utils";
|
|
12
|
+
import { hasChanged, jsonProperty, ParametrizedLabelResolver, redux, scrollHelper } from "@fluid-topics/ft-wc-utils";
|
|
13
13
|
import { FtReaderComponent, } from "@fluid-topics/ft-reader-context/build/registration";
|
|
14
14
|
import { FtTypography } from "@fluid-topics/ft-typography";
|
|
15
15
|
import { FtReaderInternalLink } from "@fluid-topics/ft-reader-internal-link";
|
|
@@ -35,6 +35,7 @@ class FtReaderToc extends FtReaderComponent {
|
|
|
35
35
|
this.collapseAllIcon = "ICON_COLLAPSE";
|
|
36
36
|
this.expandAllIcon = "ICON_EXPAND";
|
|
37
37
|
this.autoCollapse = false;
|
|
38
|
+
this.scrollCurrentTopicIntoView = false;
|
|
38
39
|
this.scope = "pages";
|
|
39
40
|
this.empty = true;
|
|
40
41
|
this.labels = {};
|
|
@@ -63,6 +64,16 @@ class FtReaderToc extends FtReaderComponent {
|
|
|
63
64
|
}
|
|
64
65
|
this.empty = ((_c = this.toc) !== null && _c !== void 0 ? _c : []).length === 0;
|
|
65
66
|
}
|
|
67
|
+
contentAvailableCallback(props) {
|
|
68
|
+
var _a, _b;
|
|
69
|
+
super.contentAvailableCallback(props);
|
|
70
|
+
if (this.scrollCurrentTopicIntoView && props.has("highlightedTocIds") && this.highlightedTocIds && ((_a = this.highlightedTocIds) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
71
|
+
const target = (_b = this.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector(`[tocId="${this.highlightedTocIds[0]}"]`);
|
|
72
|
+
if (target) {
|
|
73
|
+
scrollHelper.scrollIntoViewIfPossible(target, { behavior: "smooth", position: .25 });
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
66
77
|
render() {
|
|
67
78
|
var _a;
|
|
68
79
|
const classes = {
|
|
@@ -84,18 +95,16 @@ class FtReaderToc extends FtReaderComponent {
|
|
|
84
95
|
return this.expandCollapseAll && !this.expanded && this.nodesToExpandExist ? html `
|
|
85
96
|
<div part="expand-collapse-all-container"
|
|
86
97
|
class="ft-reader-toc-expand-collapse-all-container ft-reader-toc-expand-collapse-all-${this.expandCollapseAllAlignment}">
|
|
87
|
-
<ft-button
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
icon="${this.expandCollapseAllHideIcon ? "" : (this.expandAll
|
|
98
|
+
<ft-button part="expand-collapse-all"
|
|
99
|
+
class="ft-reader-toc--expand-collapse-all-button"
|
|
100
|
+
iconVariant="${this.expandCollapseAllIconVariant}"
|
|
101
|
+
icon="${this.expandCollapseAllHideIcon ? "" : (this.expandAll
|
|
92
102
|
? (this.collapseAllIcon || "ICON_COLLAPSE")
|
|
93
103
|
: (this.expandAllIcon || "ICON_EXPAND"))}"
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
>
|
|
104
|
+
label="${this.labelResolver.resolve(this.expandAll ? "collapseAllLong" : "expandAllLong")}"
|
|
105
|
+
tooltipPosition="${this.getExpandCollapseAllTooltipPosition()}"
|
|
106
|
+
?trailingIcon=${this.expandCollapseAllTrailingIcon}
|
|
107
|
+
@click=${() => this.toggleExpandCollapseAll()}>
|
|
99
108
|
${this.expandCollapseAllHideLabel ? "" : this.labelResolver.resolve(this.expandAll ? "collapseAll" : "expandAll")}
|
|
100
109
|
</ft-button>
|
|
101
110
|
</div>
|
|
@@ -115,44 +124,40 @@ class FtReaderToc extends FtReaderComponent {
|
|
|
115
124
|
<div class="ft-reader-toc--node ${isHighlighted ? "ft-reader-toc--node-highlighted" : ""}">
|
|
116
125
|
<div class="ft-reader-toc--link-container" data-depth="${node.depth}" style=${styleMap(styles)}>
|
|
117
126
|
${this.nodesToExpandExist && !this.expanded ? html `
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
label="${this.labelResolver.resolve(isExpanded
|
|
127
|
+
<div class="ft-reader-toc--toggle-container">
|
|
128
|
+
${canDisplayChildren ? html `
|
|
129
|
+
<ft-button part="expand-collapse-node"
|
|
130
|
+
class="ft-reader-toc--tree-node-button"
|
|
131
|
+
round hideTooltip
|
|
132
|
+
?dense=${this.viewportSize !== FtSizeCategory.S}
|
|
133
|
+
label="${this.labelResolver.resolve(isExpanded
|
|
126
134
|
? "collapse"
|
|
127
135
|
: "expand", node.title)}"
|
|
128
|
-
|
|
129
|
-
|
|
136
|
+
.iconVariant="${this.iconVariant}"
|
|
137
|
+
icon="${isExpanded
|
|
130
138
|
? (this.collapseIcon || "MINUS")
|
|
131
139
|
: (this.expandIcon || "PLUS")}"
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
tocId="${node.tocId}"
|
|
144
|
-
removeStyle>
|
|
140
|
+
@click=${() => this.manuallyToggle(node.tocId, isExpanded)}
|
|
141
|
+
data-expand-node="${node.tocId}"
|
|
142
|
+
aria-controls="${node.tocId}-children"
|
|
143
|
+
aria-expanded="${isExpanded}">
|
|
144
|
+
</ft-button>
|
|
145
|
+
` : this.getLeafNodeIcon()}
|
|
146
|
+
</div>
|
|
147
|
+
` : !canDisplayChildren ? this.getLeafNodeIcon() : nothing}
|
|
148
|
+
<ft-reader-internal-link part="node-link"
|
|
149
|
+
tocId="${node.tocId}"
|
|
150
|
+
removeStyle>
|
|
145
151
|
<ft-typography part="node-label" variant="body2">${node.title}</ft-typography>
|
|
146
152
|
</ft-reader-internal-link>
|
|
147
153
|
</div>
|
|
148
154
|
${canDisplayChildren ? html `
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
` : nothing}
|
|
155
|
+
<div id="${node.tocId}-children"
|
|
156
|
+
class="ft-reader-toc--node-children"
|
|
157
|
+
?hidden=${!isExpanded}>
|
|
158
|
+
${repeat(isExpanded ? node.children : [], (child) => child.tocId, child => this.renderNode(child))}
|
|
159
|
+
</div>
|
|
160
|
+
` : nothing}
|
|
156
161
|
</div>
|
|
157
162
|
`;
|
|
158
163
|
}
|
|
@@ -201,7 +206,11 @@ class FtReaderToc extends FtReaderComponent {
|
|
|
201
206
|
}
|
|
202
207
|
getLeafNodeIcon() {
|
|
203
208
|
return html `
|
|
204
|
-
<ft-icon class="ft-reader-toc--leaf-node-icon"
|
|
209
|
+
<ft-icon class="ft-reader-toc--leaf-node-icon"
|
|
210
|
+
part="leaf-node-icon"
|
|
211
|
+
.variant="${this.leafNodeIconVariant}"
|
|
212
|
+
.value="${this.leafNodeIcon}"></ft-icon>
|
|
213
|
+
`;
|
|
205
214
|
}
|
|
206
215
|
}
|
|
207
216
|
FtReaderToc.elementDefinitions = {
|
|
@@ -258,6 +267,9 @@ __decorate([
|
|
|
258
267
|
__decorate([
|
|
259
268
|
property({ type: Boolean })
|
|
260
269
|
], FtReaderToc.prototype, "autoCollapse", void 0);
|
|
270
|
+
__decorate([
|
|
271
|
+
property({ type: Boolean })
|
|
272
|
+
], FtReaderToc.prototype, "scrollCurrentTopicIntoView", void 0);
|
|
261
273
|
__decorate([
|
|
262
274
|
property()
|
|
263
275
|
], FtReaderToc.prototype, "scope", void 0);
|