@fluid-topics/ft-reader-toc 0.3.30 → 0.3.32
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 +102 -27
- package/build/ft-reader-toc.light.js +193 -148
- package/build/ft-reader-toc.min.js +144 -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,37 @@ 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
|
+
>
|
|
134
|
+
</ft-button>
|
|
135
|
+
` : nothing}
|
|
136
|
+
</div>
|
|
137
|
+
` : nothing}
|
|
105
138
|
<ft-reader-internal-link
|
|
139
|
+
part="node-link"
|
|
106
140
|
tocId="${node.tocId}"
|
|
107
141
|
removeStyle>
|
|
108
|
-
<ft-typography variant="body2">${node.title}</ft-typography>
|
|
142
|
+
<ft-typography part="node-label" variant="body2">${node.title}</ft-typography>
|
|
109
143
|
</ft-reader-internal-link>
|
|
110
144
|
</div>
|
|
111
|
-
${canDisplayChildren
|
|
112
|
-
? html `
|
|
145
|
+
${canDisplayChildren ? html `
|
|
113
146
|
<div class="ft-reader-toc--node-children">
|
|
114
147
|
${isExpanded
|
|
115
|
-
|
|
116
|
-
: nothing}
|
|
117
|
-
</div>
|
|
118
|
-
`
|
|
148
|
+
? repeat(node.children, (child) => child.tocId, child => this.renderNode(child))
|
|
119
149
|
: nothing}
|
|
150
|
+
</div>
|
|
151
|
+
` : nothing}
|
|
120
152
|
</div>
|
|
121
153
|
`;
|
|
122
154
|
}
|
|
@@ -147,6 +179,22 @@ export class FtReaderToc extends FtReaderComponent {
|
|
|
147
179
|
onViewportSizeChange(event) {
|
|
148
180
|
this.viewportSize = event.detail.category;
|
|
149
181
|
}
|
|
182
|
+
toggleExpandCollapseAll() {
|
|
183
|
+
this.expandAll = !this.expandAll;
|
|
184
|
+
this.automaticallyExpandedNodes = new Set();
|
|
185
|
+
this.manuallyExpandedNodes = new Set();
|
|
186
|
+
this.manuallyCollapsedNodes = new Set();
|
|
187
|
+
}
|
|
188
|
+
getExpandCollapseAllTooltipPosition() {
|
|
189
|
+
switch (this.expandCollapseAllAlignment) {
|
|
190
|
+
case "right":
|
|
191
|
+
return "left";
|
|
192
|
+
case "left":
|
|
193
|
+
return "right";
|
|
194
|
+
default:
|
|
195
|
+
return "bottom";
|
|
196
|
+
}
|
|
197
|
+
}
|
|
150
198
|
}
|
|
151
199
|
// Uncomment to use scoped web components
|
|
152
200
|
FtReaderToc.elementDefinitions = {
|
|
@@ -169,6 +217,30 @@ __decorate([
|
|
|
169
217
|
__decorate([
|
|
170
218
|
property()
|
|
171
219
|
], FtReaderToc.prototype, "expandIcon", void 0);
|
|
220
|
+
__decorate([
|
|
221
|
+
property({ type: Boolean })
|
|
222
|
+
], FtReaderToc.prototype, "expandCollapseAll", void 0);
|
|
223
|
+
__decorate([
|
|
224
|
+
property({ type: Boolean })
|
|
225
|
+
], FtReaderToc.prototype, "expandCollapseAllHideLabel", void 0);
|
|
226
|
+
__decorate([
|
|
227
|
+
property({ type: Boolean })
|
|
228
|
+
], FtReaderToc.prototype, "expandCollapseAllTrailingIcon", void 0);
|
|
229
|
+
__decorate([
|
|
230
|
+
property()
|
|
231
|
+
], FtReaderToc.prototype, "expandCollapseAllAlignment", void 0);
|
|
232
|
+
__decorate([
|
|
233
|
+
property({ type: Boolean })
|
|
234
|
+
], FtReaderToc.prototype, "expandCollapseAllHideIcon", void 0);
|
|
235
|
+
__decorate([
|
|
236
|
+
property()
|
|
237
|
+
], FtReaderToc.prototype, "expandCollapseAllIconVariant", void 0);
|
|
238
|
+
__decorate([
|
|
239
|
+
property()
|
|
240
|
+
], FtReaderToc.prototype, "collapseAllIcon", void 0);
|
|
241
|
+
__decorate([
|
|
242
|
+
property()
|
|
243
|
+
], FtReaderToc.prototype, "expandAllIcon", void 0);
|
|
172
244
|
__decorate([
|
|
173
245
|
property({ type: Boolean })
|
|
174
246
|
], FtReaderToc.prototype, "autoCollapse", void 0);
|
|
@@ -211,6 +283,9 @@ __decorate([
|
|
|
211
283
|
__decorate([
|
|
212
284
|
state({ hasChanged: (value, oldValue) => !deepEqual(value, oldValue) })
|
|
213
285
|
], FtReaderToc.prototype, "manuallyCollapsedNodes", void 0);
|
|
286
|
+
__decorate([
|
|
287
|
+
state()
|
|
288
|
+
], FtReaderToc.prototype, "expandAll", void 0);
|
|
214
289
|
__decorate([
|
|
215
290
|
state()
|
|
216
291
|
], FtReaderToc.prototype, "viewportSize", void 0);
|