@fluid-topics/ft-reader-context 2.2.17 → 2.2.19
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-context.d.ts +7 -2
- package/build/ft-reader-context.js +52 -6
- package/build/ft-reader-context.light.js +17 -7
- package/build/ft-reader-context.min.js +34 -24
- package/build/store/FtReaderStateManager.d.ts +6 -1
- package/build/store/FtReaderStateManager.js +111 -41
- package/build/store/model.d.ts +9 -2
- package/build/store/model.js +6 -0
- package/build/store/redux.js +2 -0
- package/build/store/utils/FtOfficialReaderService.d.ts +2 -2
- package/build/store/utils/FtOfficialReaderService.js +4 -2
- package/build/store/utils/FtReaderConverter.d.ts +2 -1
- package/build/store/utils/FtReaderConverter.js +11 -8
- package/build/store/utils/FtReaderService.d.ts +9 -4
- package/build/store/utils/FtReaderService.js +40 -15
- package/package.json +5 -5
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { PropertyValues } from "lit";
|
|
2
|
-
import { FtLitElementRedux, FtRegistrationContext } from "@fluid-topics/ft-wc-utils";
|
|
2
|
+
import { ElementDefinitionsMap, FtLitElementRedux, FtRegistrationContext } from "@fluid-topics/ft-wc-utils";
|
|
3
3
|
import { FtReaderComponentInterface } from "./registration";
|
|
4
4
|
import { FtReaderStateManager } from "./store/FtReaderStateManager";
|
|
5
5
|
import { FtReaderPage, FtReaderScrollTarget, FtReaderTocNode } from "./store/model";
|
|
6
|
-
import
|
|
6
|
+
import { FtMap, FtMetadataFilter, FtSession } from "@fluid-topics/public-api";
|
|
7
7
|
import { FtReaderContextProperties } from "./ft-reader-context.properties";
|
|
8
8
|
import type { FtReaderService } from "./store/utils/FtReaderService";
|
|
9
|
+
import { FtSearchContext } from "@fluid-topics/ft-search-context";
|
|
9
10
|
export declare class FtReaderContext extends FtLitElementRedux implements FtReaderContextProperties, FtRegistrationContext<FtReaderComponentInterface> {
|
|
11
|
+
static elementDefinitions: ElementDefinitionsMap;
|
|
10
12
|
static styles: import("lit").CSSResult;
|
|
11
13
|
baseUrl?: string;
|
|
12
14
|
session?: FtSession;
|
|
@@ -15,6 +17,7 @@ export declare class FtReaderContext extends FtLitElementRedux implements FtRead
|
|
|
15
17
|
section?: string;
|
|
16
18
|
topicPivot?: string;
|
|
17
19
|
searchInDocumentQuery?: string;
|
|
20
|
+
metadataFilters: Array<FtMetadataFilter>;
|
|
18
21
|
page?: number;
|
|
19
22
|
map?: FtMap;
|
|
20
23
|
toc?: FtReaderTocNode[];
|
|
@@ -22,11 +25,13 @@ export declare class FtReaderContext extends FtLitElementRedux implements FtRead
|
|
|
22
25
|
currentPage?: FtReaderPage;
|
|
23
26
|
scrollTarget?: FtReaderScrollTarget;
|
|
24
27
|
readerServiceProvider?: () => Promise<FtReaderService>;
|
|
28
|
+
tocFilteringContext?: FtSearchContext;
|
|
25
29
|
constructor();
|
|
26
30
|
protected render(): import("lit-html").TemplateResult<1>;
|
|
27
31
|
private importStyleIfNeeded;
|
|
28
32
|
private _stateManager?;
|
|
29
33
|
get stateManager(): FtReaderStateManager;
|
|
34
|
+
private get filters();
|
|
30
35
|
connectedCallback(): void;
|
|
31
36
|
disconnectedCallback(): void;
|
|
32
37
|
updateConfiguration: () => void;
|
|
@@ -5,12 +5,13 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { html, nothing, } from "lit";
|
|
8
|
-
import { property } from "lit/decorators.js";
|
|
9
|
-
import { Debouncer, FtLitElementRedux, numberProperty, randomId, redux, } from "@fluid-topics/ft-wc-utils";
|
|
8
|
+
import { property, query, } from "lit/decorators.js";
|
|
9
|
+
import { Debouncer, FtLitElementRedux, jsonPropertyConverter, numberProperty, randomId, redux, } from "@fluid-topics/ft-wc-utils";
|
|
10
10
|
import { FtReaderStateManager } from "./store/FtReaderStateManager";
|
|
11
11
|
import { styles } from "./ft-reader-context.styles";
|
|
12
12
|
import { AuthenticationChangeEvent, ftAppInfoStore, userAssetsActions, } from "@fluid-topics/ft-app-context";
|
|
13
13
|
import { ForbiddenErrorEvent, LoadErrorEvent, MapLoadedEvent, NavigationDoneEvent, NotFoundErrorEvent, TopicRelativeNotFoundEvent, UnauthorizedErrorEvent, VisibleTopicsChangeEvent, } from "./models";
|
|
14
|
+
import { FtSearchContext } from "@fluid-topics/ft-search-context";
|
|
14
15
|
class FluidTopicsReaderServiceImpl {
|
|
15
16
|
constructor(stateManager) {
|
|
16
17
|
this.stateManager = stateManager;
|
|
@@ -22,6 +23,7 @@ class FluidTopicsReaderServiceImpl {
|
|
|
22
23
|
export class FtReaderContext extends FtLitElementRedux {
|
|
23
24
|
constructor() {
|
|
24
25
|
super();
|
|
26
|
+
this.metadataFilters = [];
|
|
25
27
|
this.visibleTopics = [];
|
|
26
28
|
this.updateConfiguration = () => {
|
|
27
29
|
this.stateManager.reloadConfiguration();
|
|
@@ -34,11 +36,23 @@ export class FtReaderContext extends FtLitElementRedux {
|
|
|
34
36
|
render() {
|
|
35
37
|
return html `
|
|
36
38
|
${this.importStyleIfNeeded()}
|
|
37
|
-
<
|
|
39
|
+
<ft-toc-filtering-search-context
|
|
40
|
+
registrationId="reader-toc-filtering"
|
|
41
|
+
.filters=${this.filters}
|
|
42
|
+
@ft-search-request-change=${(e) => {
|
|
43
|
+
var _a;
|
|
44
|
+
if (e.target === this.tocFilteringContext) {
|
|
45
|
+
this.stateManager.setFilters((_a = e.detail.metadataFilters.filter((m) => m.key != "ft:publicationId")) !== null && _a !== void 0 ? _a : []);
|
|
46
|
+
}
|
|
47
|
+
}} }
|
|
48
|
+
>
|
|
49
|
+
<slot @register-ft-reader-component=${this.registerComponent}></slot>
|
|
50
|
+
</ft-toc-filtering-search-context>
|
|
38
51
|
`;
|
|
39
52
|
}
|
|
40
53
|
importStyleIfNeeded() {
|
|
41
|
-
var _a
|
|
54
|
+
var _a;
|
|
55
|
+
var _b;
|
|
42
56
|
const themeStylesheet = (_a = this.stateManager.service) === null || _a === void 0 ? void 0 : _a.themeStylesheet();
|
|
43
57
|
if (!themeStylesheet || window.location.href.startsWith((_b = this.baseUrl) !== null && _b !== void 0 ? _b : "")) {
|
|
44
58
|
return nothing;
|
|
@@ -57,6 +71,18 @@ export class FtReaderContext extends FtLitElementRedux {
|
|
|
57
71
|
}
|
|
58
72
|
return this._stateManager;
|
|
59
73
|
}
|
|
74
|
+
get filters() {
|
|
75
|
+
return [
|
|
76
|
+
{
|
|
77
|
+
key: "ft:publicationId",
|
|
78
|
+
valueFilter: {
|
|
79
|
+
negative: false,
|
|
80
|
+
values: [this.mapId],
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
...this.metadataFilters,
|
|
84
|
+
];
|
|
85
|
+
}
|
|
60
86
|
connectedCallback() {
|
|
61
87
|
super.connectedCallback();
|
|
62
88
|
this.stateManager.setMapId(this.mapId);
|
|
@@ -77,6 +103,7 @@ export class FtReaderContext extends FtLitElementRedux {
|
|
|
77
103
|
ftAppInfoStore.addEventListener(AuthenticationChangeEvent.eventName, this.updateConfiguration);
|
|
78
104
|
}
|
|
79
105
|
update(props) {
|
|
106
|
+
var _a;
|
|
80
107
|
super.update(props);
|
|
81
108
|
if (props.has("readerServiceProvider") && this.readerServiceProvider) {
|
|
82
109
|
this.stateManager.initService(this.readerServiceProvider);
|
|
@@ -88,12 +115,22 @@ export class FtReaderContext extends FtLitElementRedux {
|
|
|
88
115
|
if (props.has("searchInDocumentQuery") && this.searchInDocumentQuery != null) {
|
|
89
116
|
this.stateManager.setSearchInDocumentQuery(this.searchInDocumentQuery);
|
|
90
117
|
}
|
|
91
|
-
|
|
92
|
-
|
|
118
|
+
// metadataFilters is never set to undefined, props.get("metadatFilters") is only undefined at the 1st lit lifecycle, for the [] default value init - we do not want to take it as a filter change
|
|
119
|
+
const filtersChanged = props.has("metadataFilters") && props.get("metadataFilters") != undefined;
|
|
120
|
+
if (filtersChanged) {
|
|
121
|
+
this.stateManager.setFilters((_a = this.metadataFilters) !== null && _a !== void 0 ? _a : []);
|
|
93
122
|
}
|
|
123
|
+
// reload() re-navigates to the current target once the filtered data is loaded,
|
|
124
|
+
// so it must not race with a direct navigateToTarget() call from this same update.
|
|
94
125
|
if (props.has("session")) {
|
|
95
126
|
this.reload();
|
|
96
127
|
}
|
|
128
|
+
else if (filtersChanged) {
|
|
129
|
+
this.stateManager.reloadFromFilter(this.section, this.page);
|
|
130
|
+
}
|
|
131
|
+
else if (["tocId", "section", "page", "mapId", "topicPivot"].some((p) => props.has(p)) && this.mapId) {
|
|
132
|
+
this.navigateToTarget();
|
|
133
|
+
}
|
|
97
134
|
}
|
|
98
135
|
contentAvailableCallback(props) {
|
|
99
136
|
var _a, _b;
|
|
@@ -194,6 +231,9 @@ export class FtReaderContext extends FtLitElementRedux {
|
|
|
194
231
|
});
|
|
195
232
|
}
|
|
196
233
|
}
|
|
234
|
+
FtReaderContext.elementDefinitions = {
|
|
235
|
+
"ft-toc-filtering-search-context": FtSearchContext,
|
|
236
|
+
};
|
|
197
237
|
// language=CSS
|
|
198
238
|
FtReaderContext.styles = styles;
|
|
199
239
|
__decorate([
|
|
@@ -217,6 +257,9 @@ __decorate([
|
|
|
217
257
|
__decorate([
|
|
218
258
|
property()
|
|
219
259
|
], FtReaderContext.prototype, "searchInDocumentQuery", void 0);
|
|
260
|
+
__decorate([
|
|
261
|
+
redux({ store: "reader", converter: jsonPropertyConverter([]), attribute: true })
|
|
262
|
+
], FtReaderContext.prototype, "metadataFilters", void 0);
|
|
220
263
|
__decorate([
|
|
221
264
|
numberProperty({ min: 1 })
|
|
222
265
|
], FtReaderContext.prototype, "page", void 0);
|
|
@@ -238,3 +281,6 @@ __decorate([
|
|
|
238
281
|
__decorate([
|
|
239
282
|
property({ attribute: false })
|
|
240
283
|
], FtReaderContext.prototype, "readerServiceProvider", void 0);
|
|
284
|
+
__decorate([
|
|
285
|
+
query("ft-toc-filtering-search-context")
|
|
286
|
+
], FtReaderContext.prototype, "tocFilteringContext", void 0);
|