@fluid-topics/ft-reader-toc 0.3.31 → 0.3.33
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.css.d.ts +1 -0
- package/build/ft-reader-toc.css.js +24 -3
- package/build/ft-reader-toc.d.ts +13 -0
- package/build/ft-reader-toc.js +105 -28
- package/build/ft-reader-toc.light.js +197 -150
- package/build/ft-reader-toc.min.js +146 -99
- package/build/ft-reader-toc.properties.d.ts +12 -0
- package/build/ft-reader-toc.properties.js +4 -0
- package/package.json +7 -7
|
@@ -2,6 +2,7 @@ export declare const FtReaderTocCssVariables: {
|
|
|
2
2
|
tabulationSize: import("@fluid-topics/ft-wc-utils").FtCssVariable;
|
|
3
3
|
verticalSpacing: import("@fluid-topics/ft-wc-utils").FtCssVariable;
|
|
4
4
|
textColor: import("@fluid-topics/ft-wc-utils").FtCssVariable;
|
|
5
|
+
hoverColor: import("@fluid-topics/ft-wc-utils").FtCssVariable;
|
|
5
6
|
highlightedTextColor: import("@fluid-topics/ft-wc-utils").FtCssVariable;
|
|
6
7
|
highlightedFontWeight: import("@fluid-topics/ft-wc-utils").FtCssVariable;
|
|
7
8
|
highlightedBackgroundColor: import("@fluid-topics/ft-wc-utils").FtCssVariable;
|
|
@@ -6,6 +6,7 @@ export const FtReaderTocCssVariables = {
|
|
|
6
6
|
tabulationSize: FtCssVariableFactory.create("--ft-reader-toc-tabulation-size", "SIZE", "16px"),
|
|
7
7
|
verticalSpacing: FtCssVariableFactory.create("--ft-reader-toc-vertical-spacing", "SIZE", "4px"),
|
|
8
8
|
textColor: FtCssVariableFactory.extend("--ft-reader-toc-text-color", designSystemVariables.colorOnSurface),
|
|
9
|
+
hoverColor: FtCssVariableFactory.extend("--ft-reader-toc-hover-color", designSystemVariables.colorPrimary),
|
|
9
10
|
highlightedTextColor: FtCssVariableFactory.extend("--ft-reader-toc-highlighted-text-color", designSystemVariables.colorPrimary),
|
|
10
11
|
highlightedFontWeight: FtCssVariableFactory.create("--ft-reader-toc-highlighted-font-weight", "UNKNOWN", "bold"),
|
|
11
12
|
highlightedBackgroundColor: FtCssVariableFactory.create("--ft-reader-toc-highlighted-background-color", "COLOR", "transparent"),
|
|
@@ -30,6 +31,14 @@ export const styles = css `
|
|
|
30
31
|
align-items: center;
|
|
31
32
|
}
|
|
32
33
|
|
|
34
|
+
.ft-reader-toc--link-container ft-reader-internal-link:hover {
|
|
35
|
+
color: ${FtReaderTocCssVariables.hoverColor};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
ft-button {
|
|
39
|
+
${setVariable(FtButtonCssVariables.iconSize, FtReaderTocCssVariables.iconFontSize)};
|
|
40
|
+
}
|
|
41
|
+
|
|
33
42
|
.ft-reader-toc--toggle-container {
|
|
34
43
|
flex-shrink: 0;
|
|
35
44
|
}
|
|
@@ -46,9 +55,21 @@ export const styles = css `
|
|
|
46
55
|
width: 0;
|
|
47
56
|
}
|
|
48
57
|
|
|
49
|
-
ft-
|
|
50
|
-
|
|
51
|
-
|
|
58
|
+
.ft-reader-toc-expand-collapse-all-container {
|
|
59
|
+
margin: 8px 4px;
|
|
60
|
+
display: flex;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.ft-reader-toc-expand-collapse-all-right {
|
|
64
|
+
justify-content: flex-end;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.ft-reader-toc-expand-collapse-all-center {
|
|
68
|
+
justify-content: center;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.ft-reader-toc-expand-collapse-all-justify ft-button {
|
|
72
|
+
flex-grow: 1;
|
|
52
73
|
}
|
|
53
74
|
`;
|
|
54
75
|
//# sourceMappingURL=ft-reader-toc.css.js.map
|
package/build/ft-reader-toc.d.ts
CHANGED
|
@@ -10,6 +10,14 @@ export declare class FtReaderToc extends FtReaderComponent implements FtReaderTo
|
|
|
10
10
|
iconVariant: FtIconVariants;
|
|
11
11
|
collapseIcon: string;
|
|
12
12
|
expandIcon: string;
|
|
13
|
+
expandCollapseAll: boolean;
|
|
14
|
+
expandCollapseAllHideLabel: boolean;
|
|
15
|
+
expandCollapseAllTrailingIcon: boolean;
|
|
16
|
+
expandCollapseAllAlignment: "left" | "right" | "center" | "justify";
|
|
17
|
+
expandCollapseAllHideIcon: boolean;
|
|
18
|
+
expandCollapseAllIconVariant: FtIconVariants;
|
|
19
|
+
collapseAllIcon: string;
|
|
20
|
+
expandAllIcon: string;
|
|
13
21
|
autoCollapse: boolean;
|
|
14
22
|
scope: FtReaderTocProperties["scope"];
|
|
15
23
|
hideIfEmpty: boolean;
|
|
@@ -23,13 +31,18 @@ export declare class FtReaderToc extends FtReaderComponent implements FtReaderTo
|
|
|
23
31
|
private automaticallyExpandedNodes;
|
|
24
32
|
private manuallyExpandedNodes;
|
|
25
33
|
private manuallyCollapsedNodes;
|
|
34
|
+
private expandAll;
|
|
26
35
|
private viewportSize;
|
|
36
|
+
private nodesToExpandExist;
|
|
27
37
|
get isCurrentPageToc(): boolean;
|
|
28
38
|
protected update(changedProperties: PropertyValues): void;
|
|
29
39
|
protected render(): TemplateResult<1>;
|
|
40
|
+
private renderExpandCollapseAll;
|
|
30
41
|
private renderNode;
|
|
31
42
|
private buildAutomaticallyExpandedNodes;
|
|
32
43
|
private manuallyToggle;
|
|
33
44
|
private onViewportSizeChange;
|
|
45
|
+
private toggleExpandCollapseAll;
|
|
46
|
+
private getExpandCollapseAllTooltipPosition;
|
|
34
47
|
}
|
|
35
48
|
//# sourceMappingURL=ft-reader-toc.d.ts.map
|
package/build/ft-reader-toc.js
CHANGED
|
@@ -25,6 +25,14 @@ export class FtReaderToc extends FtReaderComponent {
|
|
|
25
25
|
this.iconVariant = FtIconVariants.fluid_topics;
|
|
26
26
|
this.collapseIcon = "MINUS";
|
|
27
27
|
this.expandIcon = "PLUS";
|
|
28
|
+
this.expandCollapseAll = false;
|
|
29
|
+
this.expandCollapseAllHideLabel = false;
|
|
30
|
+
this.expandCollapseAllTrailingIcon = false;
|
|
31
|
+
this.expandCollapseAllAlignment = "left";
|
|
32
|
+
this.expandCollapseAllHideIcon = false;
|
|
33
|
+
this.expandCollapseAllIconVariant = FtIconVariants.fluid_topics;
|
|
34
|
+
this.collapseAllIcon = "ICON_COLLAPSE";
|
|
35
|
+
this.expandAllIcon = "ICON_EXPAND";
|
|
28
36
|
this.autoCollapse = false;
|
|
29
37
|
this.scope = "pages";
|
|
30
38
|
this.hideIfEmpty = false;
|
|
@@ -34,21 +42,26 @@ export class FtReaderToc extends FtReaderComponent {
|
|
|
34
42
|
this.automaticallyExpandedNodes = new Set();
|
|
35
43
|
this.manuallyExpandedNodes = new Set();
|
|
36
44
|
this.manuallyCollapsedNodes = new Set();
|
|
45
|
+
this.expandAll = false;
|
|
37
46
|
this.viewportSize = FtSizeCategory.M;
|
|
47
|
+
this.nodesToExpandExist = false;
|
|
38
48
|
}
|
|
39
49
|
get isCurrentPageToc() {
|
|
40
50
|
return this.scope === "current-page";
|
|
41
51
|
}
|
|
42
52
|
update(changedProperties) {
|
|
43
|
-
var _a, _b;
|
|
53
|
+
var _a, _b, _c;
|
|
44
54
|
super.update(changedProperties);
|
|
55
|
+
if (changedProperties.has("toc")) {
|
|
56
|
+
this.nodesToExpandExist = ((_a = this.toc) !== null && _a !== void 0 ? _a : []).some(n => n.children.length > 0);
|
|
57
|
+
}
|
|
45
58
|
if (changedProperties.has("labels")) {
|
|
46
59
|
this.labelResolver = new ParametrizedLabelResolver(DEFAULT_LABELS, this.labels);
|
|
47
60
|
}
|
|
48
61
|
if (changedProperties.has("highlightedTocIds") && !this.expanded) {
|
|
49
|
-
this.automaticallyExpandedNodes = this.buildAutomaticallyExpandedNodes((
|
|
62
|
+
this.automaticallyExpandedNodes = this.buildAutomaticallyExpandedNodes((_b = this.highlightedTocIds) !== null && _b !== void 0 ? _b : []);
|
|
50
63
|
}
|
|
51
|
-
this.empty = ((
|
|
64
|
+
this.empty = ((_c = this.toc) !== null && _c !== void 0 ? _c : []).length === 0;
|
|
52
65
|
}
|
|
53
66
|
render() {
|
|
54
67
|
var _a;
|
|
@@ -69,16 +82,34 @@ export class FtReaderToc extends FtReaderComponent {
|
|
|
69
82
|
` : nothing}
|
|
70
83
|
<div class=${classMap(classes)}>
|
|
71
84
|
<ft-size-watcher @change=${this.onViewportSizeChange}></ft-size-watcher>
|
|
85
|
+
${this.renderExpandCollapseAll()}
|
|
72
86
|
${repeat((_a = this.toc) !== null && _a !== void 0 ? _a : [], node => node.tocId, node => this.renderNode(node))}
|
|
73
87
|
</div>
|
|
74
88
|
`;
|
|
75
89
|
}
|
|
90
|
+
renderExpandCollapseAll() {
|
|
91
|
+
return this.expandCollapseAll && !this.expanded && this.nodesToExpandExist ? html `
|
|
92
|
+
<div part="expand-collapse-all-container"
|
|
93
|
+
class="ft-reader-toc-expand-collapse-all-container ft-reader-toc-expand-collapse-all-${this.expandCollapseAllAlignment}">
|
|
94
|
+
<ft-button
|
|
95
|
+
part="expand-collapse-all"
|
|
96
|
+
iconVariant="${this.expandCollapseAllIconVariant}"
|
|
97
|
+
icon="${this.expandCollapseAllHideIcon ? "" : (this.expandAll ? (this.collapseAllIcon || "ICON_COLLAPSE") : (this.expandAllIcon || "ICON_EXPAND"))}"
|
|
98
|
+
label="${this.labelResolver.resolve(this.expandAll ? "collapseAllLong" : "expandAllLong")}"
|
|
99
|
+
tooltipPosition="${this.getExpandCollapseAllTooltipPosition()}"
|
|
100
|
+
?trailingIcon=${this.expandCollapseAllTrailingIcon}
|
|
101
|
+
@click=${() => this.toggleExpandCollapseAll()}
|
|
102
|
+
>
|
|
103
|
+
${this.expandCollapseAllHideLabel ? "" : this.labelResolver.resolve(this.expandAll ? "collapseAll" : "expandAll")}
|
|
104
|
+
</ft-button>
|
|
105
|
+
</div>
|
|
106
|
+
` : nothing;
|
|
107
|
+
}
|
|
76
108
|
renderNode(node) {
|
|
77
109
|
var _a, _b, _c;
|
|
78
110
|
const isHighlighted = (_a = this.highlightedTocIds) === null || _a === void 0 ? void 0 : _a.includes(node.tocId);
|
|
79
|
-
const isExpanded = this.expanded || this.manuallyExpandedNodes.has(node.tocId) || (this.automaticallyExpandedNodes.has(node.tocId) && !this.manuallyCollapsedNodes.has(node.tocId));
|
|
111
|
+
const isExpanded = this.expanded || this.manuallyExpandedNodes.has(node.tocId) || ((this.expandAll || this.automaticallyExpandedNodes.has(node.tocId)) && !this.manuallyCollapsedNodes.has(node.tocId));
|
|
80
112
|
const canDisplayChildren = node.children.length > 0;
|
|
81
|
-
const displayToggle = canDisplayChildren && !this.expanded;
|
|
82
113
|
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;
|
|
83
114
|
const tabNumber = node.depth - 1 - currentPageDepth;
|
|
84
115
|
const styles = {
|
|
@@ -87,36 +118,39 @@ export class FtReaderToc extends FtReaderComponent {
|
|
|
87
118
|
return html `
|
|
88
119
|
<div class="ft-reader-toc--node ${isHighlighted ? "ft-reader-toc--node-highlighted" : ""}">
|
|
89
120
|
<div class="ft-reader-toc--link-container" data-depth="${node.depth}" style=${styleMap(styles)}>
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
121
|
+
${this.nodesToExpandExist && !this.expanded ? html `
|
|
122
|
+
<div class="ft-reader-toc--toggle-container">
|
|
123
|
+
${canDisplayChildren ? html `
|
|
124
|
+
<ft-button
|
|
125
|
+
part="expand-collapse-node"
|
|
126
|
+
round hideTooltip
|
|
127
|
+
?dense=${this.viewportSize !== FtSizeCategory.S}
|
|
128
|
+
label="${this.labelResolver.resolve(isExpanded ? "collapse" : "expand", node.title)}"
|
|
129
|
+
iconVariant="${this.iconVariant}"
|
|
130
|
+
icon="${isExpanded ? (this.collapseIcon || "MINUS") : (this.expandIcon || "PLUS")}"
|
|
131
|
+
@click=${() => this.manuallyToggle(node.tocId, isExpanded)}
|
|
132
|
+
data-expand-node="${node.tocId}"
|
|
133
|
+
aria-controls="${node.tocId}-children"
|
|
134
|
+
aria-expanded="${isExpanded}"
|
|
135
|
+
>
|
|
136
|
+
</ft-button>
|
|
137
|
+
` : nothing}
|
|
138
|
+
</div>
|
|
139
|
+
` : nothing}
|
|
105
140
|
<ft-reader-internal-link
|
|
141
|
+
part="node-link"
|
|
106
142
|
tocId="${node.tocId}"
|
|
107
143
|
removeStyle>
|
|
108
|
-
<ft-typography variant="body2">${node.title}</ft-typography>
|
|
144
|
+
<ft-typography part="node-label" variant="body2">${node.title}</ft-typography>
|
|
109
145
|
</ft-reader-internal-link>
|
|
110
146
|
</div>
|
|
111
|
-
${canDisplayChildren
|
|
112
|
-
|
|
113
|
-
<div class="ft-reader-toc--node-children">
|
|
147
|
+
${canDisplayChildren ? html `
|
|
148
|
+
<div class="ft-reader-toc--node-children" id="${node.tocId}-children" ?hidden=${!isExpanded}>
|
|
114
149
|
${isExpanded
|
|
115
|
-
|
|
116
|
-
: nothing}
|
|
117
|
-
</div>
|
|
118
|
-
`
|
|
150
|
+
? repeat(node.children, (child) => child.tocId, child => this.renderNode(child))
|
|
119
151
|
: nothing}
|
|
152
|
+
</div>
|
|
153
|
+
` : nothing}
|
|
120
154
|
</div>
|
|
121
155
|
`;
|
|
122
156
|
}
|
|
@@ -147,6 +181,22 @@ export class FtReaderToc extends FtReaderComponent {
|
|
|
147
181
|
onViewportSizeChange(event) {
|
|
148
182
|
this.viewportSize = event.detail.category;
|
|
149
183
|
}
|
|
184
|
+
toggleExpandCollapseAll() {
|
|
185
|
+
this.expandAll = !this.expandAll;
|
|
186
|
+
this.automaticallyExpandedNodes = new Set();
|
|
187
|
+
this.manuallyExpandedNodes = new Set();
|
|
188
|
+
this.manuallyCollapsedNodes = new Set();
|
|
189
|
+
}
|
|
190
|
+
getExpandCollapseAllTooltipPosition() {
|
|
191
|
+
switch (this.expandCollapseAllAlignment) {
|
|
192
|
+
case "right":
|
|
193
|
+
return "left";
|
|
194
|
+
case "left":
|
|
195
|
+
return "right";
|
|
196
|
+
default:
|
|
197
|
+
return "bottom";
|
|
198
|
+
}
|
|
199
|
+
}
|
|
150
200
|
}
|
|
151
201
|
// Uncomment to use scoped web components
|
|
152
202
|
FtReaderToc.elementDefinitions = {
|
|
@@ -169,6 +219,30 @@ __decorate([
|
|
|
169
219
|
__decorate([
|
|
170
220
|
property()
|
|
171
221
|
], FtReaderToc.prototype, "expandIcon", void 0);
|
|
222
|
+
__decorate([
|
|
223
|
+
property({ type: Boolean })
|
|
224
|
+
], FtReaderToc.prototype, "expandCollapseAll", void 0);
|
|
225
|
+
__decorate([
|
|
226
|
+
property({ type: Boolean })
|
|
227
|
+
], FtReaderToc.prototype, "expandCollapseAllHideLabel", void 0);
|
|
228
|
+
__decorate([
|
|
229
|
+
property({ type: Boolean })
|
|
230
|
+
], FtReaderToc.prototype, "expandCollapseAllTrailingIcon", void 0);
|
|
231
|
+
__decorate([
|
|
232
|
+
property()
|
|
233
|
+
], FtReaderToc.prototype, "expandCollapseAllAlignment", void 0);
|
|
234
|
+
__decorate([
|
|
235
|
+
property({ type: Boolean })
|
|
236
|
+
], FtReaderToc.prototype, "expandCollapseAllHideIcon", void 0);
|
|
237
|
+
__decorate([
|
|
238
|
+
property()
|
|
239
|
+
], FtReaderToc.prototype, "expandCollapseAllIconVariant", void 0);
|
|
240
|
+
__decorate([
|
|
241
|
+
property()
|
|
242
|
+
], FtReaderToc.prototype, "collapseAllIcon", void 0);
|
|
243
|
+
__decorate([
|
|
244
|
+
property()
|
|
245
|
+
], FtReaderToc.prototype, "expandAllIcon", void 0);
|
|
172
246
|
__decorate([
|
|
173
247
|
property({ type: Boolean })
|
|
174
248
|
], FtReaderToc.prototype, "autoCollapse", void 0);
|
|
@@ -211,6 +285,9 @@ __decorate([
|
|
|
211
285
|
__decorate([
|
|
212
286
|
state({ hasChanged: (value, oldValue) => !deepEqual(value, oldValue) })
|
|
213
287
|
], FtReaderToc.prototype, "manuallyCollapsedNodes", void 0);
|
|
288
|
+
__decorate([
|
|
289
|
+
state()
|
|
290
|
+
], FtReaderToc.prototype, "expandAll", void 0);
|
|
214
291
|
__decorate([
|
|
215
292
|
state()
|
|
216
293
|
], FtReaderToc.prototype, "viewportSize", void 0);
|