@fluid-topics/ft-reader-context 2.2.16 → 2.2.18
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 +50 -5
- 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 +97 -28
- 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 +1 -0
- package/build/store/utils/FtReaderService.d.ts +9 -4
- package/build/store/utils/FtReaderService.js +34 -7
- 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,7 +36,18 @@ 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() {
|
|
@@ -57,6 +70,18 @@ export class FtReaderContext extends FtLitElementRedux {
|
|
|
57
70
|
}
|
|
58
71
|
return this._stateManager;
|
|
59
72
|
}
|
|
73
|
+
get filters() {
|
|
74
|
+
return [
|
|
75
|
+
{
|
|
76
|
+
key: "ft:publicationId",
|
|
77
|
+
valueFilter: {
|
|
78
|
+
negative: false,
|
|
79
|
+
values: [this.mapId],
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
...this.metadataFilters,
|
|
83
|
+
];
|
|
84
|
+
}
|
|
60
85
|
connectedCallback() {
|
|
61
86
|
super.connectedCallback();
|
|
62
87
|
this.stateManager.setMapId(this.mapId);
|
|
@@ -77,6 +102,7 @@ export class FtReaderContext extends FtLitElementRedux {
|
|
|
77
102
|
ftAppInfoStore.addEventListener(AuthenticationChangeEvent.eventName, this.updateConfiguration);
|
|
78
103
|
}
|
|
79
104
|
update(props) {
|
|
105
|
+
var _a;
|
|
80
106
|
super.update(props);
|
|
81
107
|
if (props.has("readerServiceProvider") && this.readerServiceProvider) {
|
|
82
108
|
this.stateManager.initService(this.readerServiceProvider);
|
|
@@ -88,12 +114,22 @@ export class FtReaderContext extends FtLitElementRedux {
|
|
|
88
114
|
if (props.has("searchInDocumentQuery") && this.searchInDocumentQuery != null) {
|
|
89
115
|
this.stateManager.setSearchInDocumentQuery(this.searchInDocumentQuery);
|
|
90
116
|
}
|
|
91
|
-
|
|
92
|
-
|
|
117
|
+
// 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
|
|
118
|
+
const filtersChanged = props.has("metadataFilters") && props.get("metadataFilters") != undefined;
|
|
119
|
+
if (filtersChanged) {
|
|
120
|
+
this.stateManager.setFilters((_a = this.metadataFilters) !== null && _a !== void 0 ? _a : []);
|
|
93
121
|
}
|
|
122
|
+
// reload() re-navigates to the current target once the filtered data is loaded,
|
|
123
|
+
// so it must not race with a direct navigateToTarget() call from this same update.
|
|
94
124
|
if (props.has("session")) {
|
|
95
125
|
this.reload();
|
|
96
126
|
}
|
|
127
|
+
else if (filtersChanged) {
|
|
128
|
+
this.stateManager.reloadFromFilter(this.section, this.page);
|
|
129
|
+
}
|
|
130
|
+
else if (["tocId", "section", "page", "mapId", "topicPivot"].some((p) => props.has(p)) && this.mapId) {
|
|
131
|
+
this.navigateToTarget();
|
|
132
|
+
}
|
|
97
133
|
}
|
|
98
134
|
contentAvailableCallback(props) {
|
|
99
135
|
var _a, _b;
|
|
@@ -194,6 +230,9 @@ export class FtReaderContext extends FtLitElementRedux {
|
|
|
194
230
|
});
|
|
195
231
|
}
|
|
196
232
|
}
|
|
233
|
+
FtReaderContext.elementDefinitions = {
|
|
234
|
+
"ft-toc-filtering-search-context": FtSearchContext,
|
|
235
|
+
};
|
|
197
236
|
// language=CSS
|
|
198
237
|
FtReaderContext.styles = styles;
|
|
199
238
|
__decorate([
|
|
@@ -217,6 +256,9 @@ __decorate([
|
|
|
217
256
|
__decorate([
|
|
218
257
|
property()
|
|
219
258
|
], FtReaderContext.prototype, "searchInDocumentQuery", void 0);
|
|
259
|
+
__decorate([
|
|
260
|
+
redux({ store: "reader", converter: jsonPropertyConverter([]), attribute: true })
|
|
261
|
+
], FtReaderContext.prototype, "metadataFilters", void 0);
|
|
220
262
|
__decorate([
|
|
221
263
|
numberProperty({ min: 1 })
|
|
222
264
|
], FtReaderContext.prototype, "page", void 0);
|
|
@@ -238,3 +280,6 @@ __decorate([
|
|
|
238
280
|
__decorate([
|
|
239
281
|
property({ attribute: false })
|
|
240
282
|
], FtReaderContext.prototype, "readerServiceProvider", void 0);
|
|
283
|
+
__decorate([
|
|
284
|
+
query("ft-toc-filtering-search-context")
|
|
285
|
+
], FtReaderContext.prototype, "tocFilteringContext", void 0);
|