@fluid-topics/ft-reader-topic-metadata 1.1.74 → 1.1.76

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.
@@ -7,12 +7,14 @@ export declare class FtReaderTopicMetadata extends FtReaderTopicComponent implem
7
7
  static styles: import("lit").CSSResult;
8
8
  key?: string;
9
9
  multiLine: boolean;
10
+ displayLabel: boolean;
10
11
  editorMode: boolean;
11
12
  private metadata?;
13
+ private flatMetadata?;
12
14
  protected render(): import("lit").TemplateResult<1>;
13
- private renderContent;
15
+ private renderChip;
16
+ private metadataValues;
14
17
  private hideIfEmpty;
15
- private get valueText();
16
18
  private get tooltipText();
17
19
  protected update(props: PropertyValues): void;
18
20
  protected onStoreAvailable(): void;
@@ -8,29 +8,44 @@ import { html, nothing } from "lit";
8
8
  import { property, state } from "lit/decorators.js";
9
9
  import { styles } from "./ft-reader-topic-metadata.styles";
10
10
  import { FtReaderTopicComponent } from "@fluid-topics/ft-reader-topic-context/build/registration";
11
+ import { ClusteringHelper } from "@fluid-topics/ft-wc-utils";
11
12
  import { FtTooltip } from "@fluid-topics/ft-tooltip";
12
13
  import { FtChip } from "@fluid-topics/ft-chip";
13
14
  class FtReaderTopicMetadata extends FtReaderTopicComponent {
14
15
  constructor() {
15
16
  super(...arguments);
16
17
  this.multiLine = false;
18
+ this.displayLabel = false;
17
19
  this.editorMode = false;
18
20
  }
19
21
  render() {
20
22
  return html `
21
- <ft-tooltip text="${this.tooltipText}">
22
- <ft-chip part="chip"
23
- exportpartsPrefix="chip"
24
- ?multiLine=${this.multiLine}>
25
- ${this.renderContent()}
26
- </ft-chip>
27
- </ft-tooltip>
23
+ ${this.renderChip()}
28
24
  ${this.hideIfEmpty()}
29
25
  `;
30
26
  }
31
- renderContent() {
32
- if (this.metadata) {
33
- return html `${this.valueText}`;
27
+ renderChip() {
28
+ var _a, _b, _c;
29
+ let chip = html `
30
+ <ft-chip part="chip"
31
+ exportpartsPrefix="chip"
32
+ ?multiLine=${this.multiLine}>
33
+ ${this.displayLabel ? html `
34
+ <span part="label">${(_a = this.flatMetadata) === null || _a === void 0 ? void 0 : _a.label}: </span>
35
+ ` : nothing}
36
+ <span part="values">${this.metadataValues()}</span>
37
+ </ft-chip>
38
+ `;
39
+ return this.displayLabel && ((_b = this.flatMetadata) === null || _b === void 0 ? void 0 : _b.value) == ((_c = this.flatMetadata) === null || _c === void 0 ? void 0 : _c.displayValue) ? chip : html `
40
+ <ft-tooltip part="tooltip" text="${this.tooltipText}">
41
+ ${chip}
42
+ </ft-tooltip>
43
+ `;
44
+ }
45
+ metadataValues() {
46
+ var _a;
47
+ if (this.flatMetadata) {
48
+ return html `${(_a = this.flatMetadata) === null || _a === void 0 ? void 0 : _a.displayValue}`;
34
49
  }
35
50
  if (this.key) {
36
51
  return html `no value for ${this.key}`;
@@ -40,7 +55,7 @@ class FtReaderTopicMetadata extends FtReaderTopicComponent {
40
55
  }
41
56
  }
42
57
  hideIfEmpty() {
43
- if (!this.editorMode && !this.metadata) {
58
+ if (!this.editorMode && !this.flatMetadata) {
44
59
  return html `
45
60
  <style>
46
61
  :host {
@@ -51,19 +66,17 @@ class FtReaderTopicMetadata extends FtReaderTopicComponent {
51
66
  }
52
67
  return nothing;
53
68
  }
54
- get valueText() {
55
- var _a, _b;
56
- return (_b = (_a = this.metadata) === null || _a === void 0 ? void 0 : _a.values.join(", ")) !== null && _b !== void 0 ? _b : "";
57
- }
58
69
  get tooltipText() {
59
- var _a, _b;
60
- 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}` : "";
70
+ return this.flatMetadata ? this.flatMetadata.label + ": " + this.flatMetadata.value : "";
61
71
  }
62
72
  update(props) {
63
73
  super.update(props);
64
74
  if (["key", "tocNode"].some(p => props.has(p))) {
65
75
  this.updateContent();
66
76
  }
77
+ if (props.has("metadata")) {
78
+ this.flatMetadata = ClusteringHelper.flattenMetadata(this.metadata);
79
+ }
67
80
  }
68
81
  onStoreAvailable() {
69
82
  super.onStoreAvailable();
@@ -88,10 +101,16 @@ __decorate([
88
101
  __decorate([
89
102
  property({ type: Boolean })
90
103
  ], FtReaderTopicMetadata.prototype, "multiLine", void 0);
104
+ __decorate([
105
+ property({ type: Boolean })
106
+ ], FtReaderTopicMetadata.prototype, "displayLabel", void 0);
91
107
  __decorate([
92
108
  state()
93
109
  ], FtReaderTopicMetadata.prototype, "editorMode", void 0);
94
110
  __decorate([
95
111
  state()
96
112
  ], FtReaderTopicMetadata.prototype, "metadata", void 0);
113
+ __decorate([
114
+ state()
115
+ ], FtReaderTopicMetadata.prototype, "flatMetadata", void 0);
97
116
  export { FtReaderTopicMetadata };