@fluid-topics/ft-reader-topic-metadata 0.3.21
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/README.md +19 -0
- package/build/ft-reader-topic-metadata.css.d.ts +3 -0
- package/build/ft-reader-topic-metadata.css.js +9 -0
- package/build/ft-reader-topic-metadata.d.ts +20 -0
- package/build/ft-reader-topic-metadata.js +91 -0
- package/build/ft-reader-topic-metadata.light.js +471 -0
- package/build/ft-reader-topic-metadata.min.js +589 -0
- package/build/ft-reader-topic-metadata.properties.d.ts +4 -0
- package/build/ft-reader-topic-metadata.properties.js +2 -0
- package/build/index.d.ts +4 -0
- package/build/index.js +7 -0
- package/package.json +26 -0
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Metadata of a topic in integrated reader.
|
|
2
|
+
|
|
3
|
+
## Install
|
|
4
|
+
|
|
5
|
+
```shell
|
|
6
|
+
npm install @fluid-topics/ft-reader-topic-metadata
|
|
7
|
+
yarn add @fluid-topics/ft-reader-topic-metadata
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
import { html } from "lit"
|
|
14
|
+
import "@fluid-topics/ft-reader-topic-metadata"
|
|
15
|
+
|
|
16
|
+
function render() {
|
|
17
|
+
return html` <ft-reader-topic-metadata foo="bar"></ft-reader-topic-metadata> `
|
|
18
|
+
}
|
|
19
|
+
```
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { PropertyValues } from "lit";
|
|
2
|
+
import { FtReaderTopicMetadataProperties } from "./ft-reader-topic-metadata.properties";
|
|
3
|
+
import { FtReaderTopicComponent } from "@fluid-topics/ft-reader-topic-context/build/registration";
|
|
4
|
+
import { ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
|
|
5
|
+
export declare class FtReaderTopicMetadata extends FtReaderTopicComponent implements FtReaderTopicMetadataProperties {
|
|
6
|
+
static elementDefinitions: ElementDefinitionsMap;
|
|
7
|
+
static styles: import("lit").CSSResult;
|
|
8
|
+
key?: string;
|
|
9
|
+
editorMode: boolean;
|
|
10
|
+
private metadata?;
|
|
11
|
+
protected render(): import("lit-html").TemplateResult<1>;
|
|
12
|
+
private renderContent;
|
|
13
|
+
private hideIfEmpty;
|
|
14
|
+
private get valueText();
|
|
15
|
+
private get tooltipText();
|
|
16
|
+
protected updated(props: PropertyValues): void;
|
|
17
|
+
protected onStoreAvailable(): void;
|
|
18
|
+
private updateContent;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=ft-reader-topic-metadata.d.ts.map
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { html, nothing } from "lit";
|
|
8
|
+
import { property, state } from "lit/decorators.js";
|
|
9
|
+
import { styles } from "./ft-reader-topic-metadata.css";
|
|
10
|
+
import { FtReaderTopicComponent } from "@fluid-topics/ft-reader-topic-context/build/registration";
|
|
11
|
+
import { FtTooltip } from "@fluid-topics/ft-tooltip";
|
|
12
|
+
import { FtChip } from "@fluid-topics/ft-chip";
|
|
13
|
+
export class FtReaderTopicMetadata extends FtReaderTopicComponent {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.editorMode = false;
|
|
17
|
+
}
|
|
18
|
+
render() {
|
|
19
|
+
return html `
|
|
20
|
+
<ft-tooltip text="${this.tooltipText}">
|
|
21
|
+
<ft-chip>
|
|
22
|
+
${this.renderContent()}
|
|
23
|
+
</ft-chip>
|
|
24
|
+
</ft-tooltip>
|
|
25
|
+
${this.hideIfEmpty()}
|
|
26
|
+
`;
|
|
27
|
+
}
|
|
28
|
+
renderContent() {
|
|
29
|
+
if (this.metadata) {
|
|
30
|
+
return html `${this.valueText}`;
|
|
31
|
+
}
|
|
32
|
+
if (this.key) {
|
|
33
|
+
return html `no value for ${this.key}`;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
return html `no metadata selected`;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
hideIfEmpty() {
|
|
40
|
+
if (!this.editorMode && !this.metadata) {
|
|
41
|
+
return html `
|
|
42
|
+
<style>
|
|
43
|
+
:host {
|
|
44
|
+
display: none !important;
|
|
45
|
+
}
|
|
46
|
+
</style>
|
|
47
|
+
`;
|
|
48
|
+
}
|
|
49
|
+
return nothing;
|
|
50
|
+
}
|
|
51
|
+
get valueText() {
|
|
52
|
+
var _a, _b;
|
|
53
|
+
return (_b = (_a = this.metadata) === null || _a === void 0 ? void 0 : _a.values.join(", ")) !== null && _b !== void 0 ? _b : "";
|
|
54
|
+
}
|
|
55
|
+
get tooltipText() {
|
|
56
|
+
var _a, _b;
|
|
57
|
+
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}` : "";
|
|
58
|
+
}
|
|
59
|
+
updated(props) {
|
|
60
|
+
super.updated(props);
|
|
61
|
+
if (["key", "tocNode"].some(p => props.has(p))) {
|
|
62
|
+
this.updateContent();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
onStoreAvailable() {
|
|
66
|
+
super.onStoreAvailable();
|
|
67
|
+
this.updateContent();
|
|
68
|
+
}
|
|
69
|
+
updateContent() {
|
|
70
|
+
var _a;
|
|
71
|
+
this.metadata = undefined;
|
|
72
|
+
if (this.tocNode && this.key) {
|
|
73
|
+
(_a = this.service) === null || _a === void 0 ? void 0 : _a.getTopicInfo(this.tocNode.contentId).then(topic => this.metadata = topic.metadata.find(m => m.key === this.key)).catch(() => null);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
FtReaderTopicMetadata.elementDefinitions = {
|
|
78
|
+
"ft-tooltip": FtTooltip,
|
|
79
|
+
"ft-chip": FtChip,
|
|
80
|
+
};
|
|
81
|
+
FtReaderTopicMetadata.styles = styles;
|
|
82
|
+
__decorate([
|
|
83
|
+
property()
|
|
84
|
+
], FtReaderTopicMetadata.prototype, "key", void 0);
|
|
85
|
+
__decorate([
|
|
86
|
+
state()
|
|
87
|
+
], FtReaderTopicMetadata.prototype, "editorMode", void 0);
|
|
88
|
+
__decorate([
|
|
89
|
+
state()
|
|
90
|
+
], FtReaderTopicMetadata.prototype, "metadata", void 0);
|
|
91
|
+
//# sourceMappingURL=ft-reader-topic-metadata.js.map
|