@fluid-topics/ft-reader-toc 1.2.24 → 1.2.25
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/FtReaderTocMessages.d.ts +11 -0
- package/build/FtReaderTocMessages.js +10 -0
- package/build/ft-reader-toc.d.ts +5 -5
- package/build/ft-reader-toc.js +12 -20
- package/build/ft-reader-toc.light.js +419 -404
- package/build/ft-reader-toc.min.js +241 -233
- package/build/ft-reader-toc.properties.d.ts +0 -10
- package/build/ft-reader-toc.properties.js +1 -8
- package/package.json +7 -7
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DefaultI18nMessages, I18nMessageContext, I18nMessages } from "@fluid-topics/ft-i18n";
|
|
2
|
+
export interface FtReaderTocMessages extends I18nMessages {
|
|
3
|
+
expand(title: string): string;
|
|
4
|
+
collapse(title: string): string;
|
|
5
|
+
expandAll(): string;
|
|
6
|
+
expandAllLong(): string;
|
|
7
|
+
collapseAll(): string;
|
|
8
|
+
collapseAllLong(): string;
|
|
9
|
+
}
|
|
10
|
+
export declare const readerToc: I18nMessageContext<FtReaderTocMessages>;
|
|
11
|
+
export declare const readerTocDefaultMessages: DefaultI18nMessages<FtReaderTocMessages>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { I18nMessageContext } from "@fluid-topics/ft-i18n";
|
|
2
|
+
export const readerToc = I18nMessageContext.build("designedReaderToc");
|
|
3
|
+
export const readerTocDefaultMessages = {
|
|
4
|
+
expand: "Expand {0}",
|
|
5
|
+
collapse: "Collapse {0}",
|
|
6
|
+
expandAll: "Expand all",
|
|
7
|
+
expandAllLong: "Expand all table of contents",
|
|
8
|
+
collapseAll: "Collapse all",
|
|
9
|
+
collapseAllLong: "Collapse all table of contents",
|
|
10
|
+
};
|
package/build/ft-reader-toc.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { PropertyValues, TemplateResult } from "lit";
|
|
2
|
-
import { ElementDefinitionsMap
|
|
2
|
+
import { ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
|
|
3
3
|
import { FtReaderComponent, FtReaderPage, FtReaderTocNode } from "@fluid-topics/ft-reader-context/build/registration";
|
|
4
4
|
import { FtIconVariants } from "@fluid-topics/ft-icon";
|
|
5
5
|
import { FtSizeCategory } from "@fluid-topics/ft-size-watcher";
|
|
6
|
-
import {
|
|
6
|
+
import { FtReaderTocProperties } from "./ft-reader-toc.properties";
|
|
7
7
|
import { FtPagesTocNode } from "@fluid-topics/ft-reader-context/build/store/model";
|
|
8
8
|
type TocNode = FtReaderTocNode | FtPagesTocNode;
|
|
9
|
-
|
|
9
|
+
declare const FtReaderToc_base: typeof FtReaderComponent & import("@fluid-topics/ft-wc-utils").Constructor<import("@fluid-topics/ft-i18n").FtLitElementWithI18nInterface>;
|
|
10
|
+
export declare class FtReaderToc extends FtReaderToc_base implements FtReaderTocProperties {
|
|
10
11
|
static elementDefinitions: ElementDefinitionsMap;
|
|
11
12
|
static styles: import("lit").CSSResult;
|
|
12
13
|
expanded: boolean;
|
|
@@ -27,8 +28,6 @@ export declare class FtReaderToc extends FtReaderComponent implements FtReaderTo
|
|
|
27
28
|
scrollCurrentTopicIntoView: boolean;
|
|
28
29
|
scope: FtReaderTocProperties["scope"];
|
|
29
30
|
empty: boolean;
|
|
30
|
-
labels: FtReaderTocLabels;
|
|
31
|
-
labelResolver: ParametrizedLabelResolver<FtReaderTocLabels>;
|
|
32
31
|
toc?: Array<TocNode>;
|
|
33
32
|
currentPage?: FtReaderPage;
|
|
34
33
|
highlightedTocIds?: string[];
|
|
@@ -39,6 +38,7 @@ export declare class FtReaderToc extends FtReaderComponent implements FtReaderTo
|
|
|
39
38
|
viewportSize: FtSizeCategory;
|
|
40
39
|
nodesToExpandExist: boolean;
|
|
41
40
|
get isCurrentPageToc(): boolean;
|
|
41
|
+
constructor();
|
|
42
42
|
protected update(changedProperties: PropertyValues<FtReaderToc>): void;
|
|
43
43
|
protected contentAvailableCallback(props: PropertyValues<FtReaderToc>): void;
|
|
44
44
|
protected render(): TemplateResult<1>;
|
package/build/ft-reader-toc.js
CHANGED
|
@@ -9,18 +9,22 @@ 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,
|
|
12
|
+
import { hasChanged, 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";
|
|
16
16
|
import { FtIcon, FtIconVariants } from "@fluid-topics/ft-icon";
|
|
17
17
|
import { FtButton } from "@fluid-topics/ft-button";
|
|
18
18
|
import { FtSizeCategory, FtSizeWatcher } from "@fluid-topics/ft-size-watcher";
|
|
19
|
-
import { DEFAULT_LABELS } from "./ft-reader-toc.properties";
|
|
20
19
|
import { FtReaderTocCssVariables, styles } from "./ft-reader-toc.styles";
|
|
21
|
-
|
|
20
|
+
import { withI18n } from "@fluid-topics/ft-i18n";
|
|
21
|
+
import { readerToc, readerTocDefaultMessages } from "./FtReaderTocMessages";
|
|
22
|
+
class FtReaderToc extends withI18n(FtReaderComponent) {
|
|
23
|
+
get isCurrentPageToc() {
|
|
24
|
+
return this.scope === "current-page";
|
|
25
|
+
}
|
|
22
26
|
constructor() {
|
|
23
|
-
super(
|
|
27
|
+
super();
|
|
24
28
|
this.expanded = false;
|
|
25
29
|
this.iconVariant = FtIconVariants.fluid_topics;
|
|
26
30
|
this.collapseIcon = "MINUS";
|
|
@@ -38,17 +42,13 @@ class FtReaderToc extends FtReaderComponent {
|
|
|
38
42
|
this.scrollCurrentTopicIntoView = false;
|
|
39
43
|
this.scope = "pages";
|
|
40
44
|
this.empty = true;
|
|
41
|
-
this.labels = {};
|
|
42
|
-
this.labelResolver = new ParametrizedLabelResolver(DEFAULT_LABELS, {});
|
|
43
45
|
this.automaticallyExpandedNodes = new Set();
|
|
44
46
|
this.manuallyExpandedNodes = new Set();
|
|
45
47
|
this.manuallyCollapsedNodes = new Set();
|
|
46
48
|
this.expandAll = false;
|
|
47
49
|
this.viewportSize = FtSizeCategory.M;
|
|
48
50
|
this.nodesToExpandExist = false;
|
|
49
|
-
|
|
50
|
-
get isCurrentPageToc() {
|
|
51
|
-
return this.scope === "current-page";
|
|
51
|
+
this.addI18nContext(readerToc, readerTocDefaultMessages);
|
|
52
52
|
}
|
|
53
53
|
update(changedProperties) {
|
|
54
54
|
var _a, _b, _c;
|
|
@@ -56,9 +56,6 @@ class FtReaderToc extends FtReaderComponent {
|
|
|
56
56
|
if (changedProperties.has("toc")) {
|
|
57
57
|
this.nodesToExpandExist = ((_a = this.toc) !== null && _a !== void 0 ? _a : []).some(n => n.children.length > 0);
|
|
58
58
|
}
|
|
59
|
-
if (changedProperties.has("labels")) {
|
|
60
|
-
this.labelResolver = new ParametrizedLabelResolver(DEFAULT_LABELS, this.labels);
|
|
61
|
-
}
|
|
62
59
|
if (changedProperties.has("highlightedTocIds") && !this.expanded) {
|
|
63
60
|
this.automaticallyExpandedNodes = this.buildAutomaticallyExpandedNodes((_b = this.highlightedTocIds) !== null && _b !== void 0 ? _b : []);
|
|
64
61
|
}
|
|
@@ -101,11 +98,11 @@ class FtReaderToc extends FtReaderComponent {
|
|
|
101
98
|
icon="${this.expandCollapseAllHideIcon ? "" : (this.expandAll
|
|
102
99
|
? (this.collapseAllIcon || "ICON_COLLAPSE")
|
|
103
100
|
: (this.expandAllIcon || "ICON_EXPAND"))}"
|
|
104
|
-
label="${this.
|
|
101
|
+
label="${this.expandAll ? readerToc.messages.collapseAllLong() : readerToc.messages.expandAllLong()}"
|
|
105
102
|
tooltipPosition="${this.getExpandCollapseAllTooltipPosition()}"
|
|
106
103
|
?trailingIcon=${this.expandCollapseAllTrailingIcon}
|
|
107
104
|
@click=${() => this.toggleExpandCollapseAll()}>
|
|
108
|
-
${this.expandCollapseAllHideLabel ? "" : this.
|
|
105
|
+
${this.expandCollapseAllHideLabel ? "" : this.expandAll ? readerToc.messages.collapseAll() : readerToc.messages.expandAll()}
|
|
109
106
|
</ft-button>
|
|
110
107
|
</div>
|
|
111
108
|
` : nothing;
|
|
@@ -130,9 +127,7 @@ class FtReaderToc extends FtReaderComponent {
|
|
|
130
127
|
class="ft-reader-toc--tree-node-button"
|
|
131
128
|
round hideTooltip
|
|
132
129
|
?dense=${this.viewportSize !== FtSizeCategory.S}
|
|
133
|
-
label="${
|
|
134
|
-
? "collapse"
|
|
135
|
-
: "expand", node.title)}"
|
|
130
|
+
label="${isExpanded ? readerToc.messages.collapse(node.title) : readerToc.messages.expand(node.title)}"
|
|
136
131
|
.iconVariant="${this.iconVariant}"
|
|
137
132
|
icon="${isExpanded
|
|
138
133
|
? (this.collapseIcon || "MINUS")
|
|
@@ -276,9 +271,6 @@ __decorate([
|
|
|
276
271
|
__decorate([
|
|
277
272
|
property({ type: Boolean, reflect: true })
|
|
278
273
|
], FtReaderToc.prototype, "empty", void 0);
|
|
279
|
-
__decorate([
|
|
280
|
-
jsonProperty({})
|
|
281
|
-
], FtReaderToc.prototype, "labels", void 0);
|
|
282
274
|
__decorate([
|
|
283
275
|
redux({
|
|
284
276
|
selector: (s, self) => {
|