@fluid-topics/ft-reader-metadata 1.1.26 → 1.1.28
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-metadata.css.js +13 -0
- package/build/ft-reader-metadata.d.ts +14 -1
- package/build/ft-reader-metadata.js +113 -7
- package/build/ft-reader-metadata.light.js +387 -225
- package/build/ft-reader-metadata.min.js +452 -275
- package/package.json +8 -6
|
@@ -5,4 +5,17 @@ export const styles = css `
|
|
|
5
5
|
:host {
|
|
6
6
|
display: inline-block;
|
|
7
7
|
}
|
|
8
|
+
|
|
9
|
+
.ft-reader-metadata--container {
|
|
10
|
+
position: relative;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.ft-reader-metadata--container ft-chip {
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
a {
|
|
18
|
+
all: unset;
|
|
19
|
+
position: relative;
|
|
20
|
+
}
|
|
8
21
|
`;
|
|
@@ -1,15 +1,28 @@
|
|
|
1
|
+
import { PropertyValues } from "lit";
|
|
1
2
|
import { ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
|
|
2
3
|
import { FtReaderMetadataProperties } from "./ft-reader-metadata.properties";
|
|
3
|
-
import { FtReaderComponent } from "@fluid-topics/ft-reader-context/build/registration";
|
|
4
|
+
import { FtReaderComponent, FtReaderStateManager } from "@fluid-topics/ft-reader-context/build/registration";
|
|
4
5
|
export declare class FtReaderMetadata extends FtReaderComponent implements FtReaderMetadataProperties {
|
|
5
6
|
static elementDefinitions: ElementDefinitionsMap;
|
|
6
7
|
static styles: import("lit").CSSResult;
|
|
7
8
|
key?: string;
|
|
9
|
+
useForSwitchingToRelatives: boolean;
|
|
8
10
|
editorMode: boolean;
|
|
9
11
|
private metadata?;
|
|
12
|
+
private mapRelatives?;
|
|
13
|
+
private map?;
|
|
14
|
+
private relativeTopicPivotMetadata?;
|
|
15
|
+
private relatives;
|
|
16
|
+
setReaderStateManager(readerStateManager: FtReaderStateManager): void;
|
|
10
17
|
protected render(): import("lit").TemplateResult<1>;
|
|
11
18
|
private renderContent;
|
|
19
|
+
private renderSwitchToRelatives;
|
|
20
|
+
private renderRelativeItem;
|
|
21
|
+
private renderRelativeItemValue;
|
|
12
22
|
private hideIfEmpty;
|
|
13
23
|
private get valueText();
|
|
14
24
|
private get tooltipText();
|
|
25
|
+
private addTopicPivotCommand;
|
|
26
|
+
private setRelatives;
|
|
27
|
+
protected update(props: PropertyValues): void;
|
|
15
28
|
}
|
|
@@ -5,29 +5,47 @@ 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";
|
|
8
|
+
import { property, state } from "lit/decorators.js";
|
|
9
9
|
import { redux, reduxReactive } from "@fluid-topics/ft-wc-utils";
|
|
10
10
|
import { styles } from "./ft-reader-metadata.css";
|
|
11
11
|
import { FtReaderComponent } from "@fluid-topics/ft-reader-context/build/registration";
|
|
12
12
|
import { FtTooltip } from "@fluid-topics/ft-tooltip";
|
|
13
13
|
import { FtChip } from "@fluid-topics/ft-chip";
|
|
14
|
+
import { FtFloatingMenu, FtFloatingMenuItem } from "@fluid-topics/ft-floating-menu";
|
|
15
|
+
import { getResultUrl } from "@fluid-topics/ft-search-result-context/build/utils";
|
|
16
|
+
import { repeat } from "lit/directives/repeat.js";
|
|
17
|
+
import { FtRipple } from "@fluid-topics/ft-ripple";
|
|
14
18
|
class FtReaderMetadata extends FtReaderComponent {
|
|
15
19
|
constructor() {
|
|
16
20
|
super(...arguments);
|
|
21
|
+
this.useForSwitchingToRelatives = false;
|
|
17
22
|
this.editorMode = false;
|
|
23
|
+
this.relatives = [];
|
|
24
|
+
}
|
|
25
|
+
setReaderStateManager(readerStateManager) {
|
|
26
|
+
var _a;
|
|
27
|
+
super.setReaderStateManager(readerStateManager);
|
|
28
|
+
if (this.key && this.useForSwitchingToRelatives) {
|
|
29
|
+
readerStateManager.registerMetadataForSwitchToRelatives(this.key);
|
|
30
|
+
}
|
|
31
|
+
(_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.store.eventBus.addEventListener("clustering-helper-created", this.setRelatives);
|
|
18
32
|
}
|
|
19
33
|
render() {
|
|
20
34
|
return html `
|
|
21
35
|
<ft-tooltip text="${this.tooltipText}">
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
36
|
+
${this.useForSwitchingToRelatives && this.metadata && this.metadata.values.length > 0
|
|
37
|
+
? this.renderSwitchToRelatives()
|
|
38
|
+
: html `
|
|
39
|
+
<ft-chip>
|
|
40
|
+
${this.renderContent()}
|
|
41
|
+
</ft-chip>
|
|
42
|
+
`}
|
|
25
43
|
</ft-tooltip>
|
|
26
44
|
${this.hideIfEmpty()}
|
|
27
45
|
`;
|
|
28
46
|
}
|
|
29
47
|
renderContent() {
|
|
30
|
-
if (this.metadata) {
|
|
48
|
+
if (this.metadata && this.metadata.values.length > 0) {
|
|
31
49
|
return html `${this.valueText}`;
|
|
32
50
|
}
|
|
33
51
|
if (this.editorMode) {
|
|
@@ -40,8 +58,35 @@ class FtReaderMetadata extends FtReaderComponent {
|
|
|
40
58
|
}
|
|
41
59
|
return nothing;
|
|
42
60
|
}
|
|
61
|
+
renderSwitchToRelatives() {
|
|
62
|
+
return html `
|
|
63
|
+
<div class="ft-reader-metadata--container">
|
|
64
|
+
<ft-floating-menu text="Toggle collapsible" trailingIcon>
|
|
65
|
+
<ft-chip trailingIcon icon="thin_arrow" slot="toggle" clickable>
|
|
66
|
+
${this.renderContent()}
|
|
67
|
+
</ft-chip>
|
|
68
|
+
|
|
69
|
+
${repeat(this.relatives, relative => relative.metadata.value, relative => this.renderRelativeItem(relative.result, relative.metadata))}
|
|
70
|
+
</ft-floating-menu>
|
|
71
|
+
</div>
|
|
72
|
+
`;
|
|
73
|
+
}
|
|
74
|
+
renderRelativeItem(result, metadata) {
|
|
75
|
+
return html `
|
|
76
|
+
<a href=${getResultUrl(result)} @click=${(e) => this.addTopicPivotCommand(e, result)}>
|
|
77
|
+
<ft-ripple></ft-ripple>
|
|
78
|
+
<ft-floating-menu-item value="${metadata.value}" notFocusable="true">
|
|
79
|
+
${this.renderRelativeItemValue(metadata.value, metadata.displayValue)}
|
|
80
|
+
</ft-floating-menu-item>
|
|
81
|
+
</a>
|
|
82
|
+
`;
|
|
83
|
+
}
|
|
84
|
+
renderRelativeItemValue(value, displayValue) {
|
|
85
|
+
return value === displayValue ? value : html `
|
|
86
|
+
<ft-tooltip text="${value}">${displayValue}</ft-tooltip>`;
|
|
87
|
+
}
|
|
43
88
|
hideIfEmpty() {
|
|
44
|
-
if (!this.editorMode && !this.metadata) {
|
|
89
|
+
if (!this.editorMode && (!this.metadata || this.metadata.values.length == 0)) {
|
|
45
90
|
return html `
|
|
46
91
|
<style>
|
|
47
92
|
:host {
|
|
@@ -60,20 +105,81 @@ class FtReaderMetadata extends FtReaderComponent {
|
|
|
60
105
|
var _a, _b;
|
|
61
106
|
return this.metadata ? `${(_b = (_a = this.metadata) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : this.metadata.key}: ${this.valueText}` : "";
|
|
62
107
|
}
|
|
108
|
+
addTopicPivotCommand(e, result) {
|
|
109
|
+
var _a, _b;
|
|
110
|
+
const currentTocId = this.stateManager.store.getState().visibleTopics[0];
|
|
111
|
+
if (!e.ctrlKey && !e.metaKey && currentTocId) {
|
|
112
|
+
e.stopPropagation();
|
|
113
|
+
e.preventDefault();
|
|
114
|
+
const tocNode = (_a = this.service) === null || _a === void 0 ? void 0 : _a.getTocNodeNow(currentTocId);
|
|
115
|
+
(_b = this.service) === null || _b === void 0 ? void 0 : _b.getTopicInfo(tocNode).then((topicInfo) => {
|
|
116
|
+
var _a, _b;
|
|
117
|
+
const topicPivotMetadataValue = topicInfo === null || topicInfo === void 0 ? void 0 : topicInfo.metadata.find((metadata) => metadata.key == this.relativeTopicPivotMetadata);
|
|
118
|
+
(_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.navigateToRelativeTopicIfFound((_b = result.map) === null || _b === void 0 ? void 0 : _b.mapId, topicPivotMetadataValue);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
setRelatives() {
|
|
123
|
+
var _a;
|
|
124
|
+
if (this.metadata && this.mapRelatives) {
|
|
125
|
+
this.relatives = this.stateManager.clusteringHelper.computeClustersItemsForMetadata(this.key, ((_a = this.map) === null || _a === void 0 ? void 0 : _a.lang) || "en");
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
update(props) {
|
|
129
|
+
var _a, _b, _c, _d;
|
|
130
|
+
super.update(props);
|
|
131
|
+
if ((props.has("metadata") || props.has("mapRelatives"))) {
|
|
132
|
+
this.setRelatives();
|
|
133
|
+
}
|
|
134
|
+
if (props.has("key") && this.useForSwitchingToRelatives) {
|
|
135
|
+
if (props.get("key")) {
|
|
136
|
+
(_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.unregisterMetadataForSwitchToRelatives(props.get("key"));
|
|
137
|
+
}
|
|
138
|
+
if (this.key) {
|
|
139
|
+
(_b = this.stateManager) === null || _b === void 0 ? void 0 : _b.registerMetadataForSwitchToRelatives(this.key);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (props.has("useForSwitchingToRelatives") && this.key) {
|
|
143
|
+
if (this.useForSwitchingToRelatives) {
|
|
144
|
+
(_c = this.stateManager) === null || _c === void 0 ? void 0 : _c.registerMetadataForSwitchToRelatives(this.key);
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
(_d = this.stateManager) === null || _d === void 0 ? void 0 : _d.unregisterMetadataForSwitchToRelatives(this.key);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
63
151
|
}
|
|
64
152
|
FtReaderMetadata.elementDefinitions = {
|
|
65
|
-
"ft-tooltip": FtTooltip,
|
|
66
153
|
"ft-chip": FtChip,
|
|
154
|
+
"ft-floating-menu": FtFloatingMenu,
|
|
155
|
+
"ft-floating-menu-item": FtFloatingMenuItem,
|
|
156
|
+
"ft-ripple": FtRipple,
|
|
157
|
+
"ft-tooltip": FtTooltip,
|
|
67
158
|
};
|
|
68
159
|
FtReaderMetadata.styles = styles;
|
|
69
160
|
__decorate([
|
|
70
161
|
property(),
|
|
71
162
|
reduxReactive()
|
|
72
163
|
], FtReaderMetadata.prototype, "key", void 0);
|
|
164
|
+
__decorate([
|
|
165
|
+
property({ type: Boolean })
|
|
166
|
+
], FtReaderMetadata.prototype, "useForSwitchingToRelatives", void 0);
|
|
73
167
|
__decorate([
|
|
74
168
|
property({ attribute: false })
|
|
75
169
|
], FtReaderMetadata.prototype, "editorMode", void 0);
|
|
76
170
|
__decorate([
|
|
77
171
|
redux({ selector: (s, e) => { var _a, _b; return (_b = (_a = s.map) === null || _a === void 0 ? void 0 : _a.metadata) === null || _b === void 0 ? void 0 : _b.find(m => m.key === e.key); } })
|
|
78
172
|
], FtReaderMetadata.prototype, "metadata", void 0);
|
|
173
|
+
__decorate([
|
|
174
|
+
redux({ selector: (s) => s.relatives })
|
|
175
|
+
], FtReaderMetadata.prototype, "mapRelatives", void 0);
|
|
176
|
+
__decorate([
|
|
177
|
+
redux()
|
|
178
|
+
], FtReaderMetadata.prototype, "map", void 0);
|
|
179
|
+
__decorate([
|
|
180
|
+
redux({ selector: (s) => { var _a; return (_a = s.configuration) === null || _a === void 0 ? void 0 : _a.relativeTopicPivotMetadata; } })
|
|
181
|
+
], FtReaderMetadata.prototype, "relativeTopicPivotMetadata", void 0);
|
|
182
|
+
__decorate([
|
|
183
|
+
state()
|
|
184
|
+
], FtReaderMetadata.prototype, "relatives", void 0);
|
|
79
185
|
export { FtReaderMetadata };
|