@fluid-topics/ft-reader-metadata 1.1.73 → 1.1.75

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.
@@ -9,6 +9,7 @@ export declare class FtReaderMetadata extends FtReaderMetadata_base implements F
9
9
  key?: string;
10
10
  multiLine: boolean;
11
11
  useForSwitchingToRelatives: boolean;
12
+ displayLabel: boolean;
12
13
  editorMode: boolean;
13
14
  private metadata?;
14
15
  private flatMetadata?;
@@ -22,7 +23,7 @@ export declare class FtReaderMetadata extends FtReaderMetadata_base implements F
22
23
  protected render(): import("lit").TemplateResult<1>;
23
24
  private renderSwitchToRelatives;
24
25
  private renderChip;
25
- private renderChipContent;
26
+ private get metadataValue();
26
27
  private renderRelativeItem;
27
28
  private hideIfEmpty;
28
29
  private addTopicPivotParam;
@@ -23,6 +23,7 @@ class FtReaderMetadata extends withI18n(FtReaderComponent) {
23
23
  super();
24
24
  this.multiLine = false;
25
25
  this.useForSwitchingToRelatives = false;
26
+ this.displayLabel = false;
26
27
  this.editorMode = false;
27
28
  this.relatives = [];
28
29
  this.noValueMessage = "No value";
@@ -61,26 +62,32 @@ class FtReaderMetadata extends withI18n(FtReaderComponent) {
61
62
  `;
62
63
  }
63
64
  renderChip(inFloatingMenu = false) {
64
- var _a, _b;
65
- return html `
65
+ var _a, _b, _c, _d, _e, _f;
66
+ let noTooltip = this.displayLabel && ((_a = this.flatMetadata) === null || _a === void 0 ? void 0 : _a.value) == ((_b = this.flatMetadata) === null || _b === void 0 ? void 0 : _b.displayValue);
67
+ let chip = html `
68
+ <ft-chip part="chip"
69
+ exportpartsPrefix="chip"
70
+ slot="${noTooltip && inFloatingMenu ? "toggle" : ""}"
71
+ trailingIcon icon="${inFloatingMenu ? "thin_arrow" : ""}"
72
+ ?clickable=${inFloatingMenu}
73
+ ?multiLine=${this.multiLine}>
74
+ ${this.displayLabel ? html `
75
+ <span part="label">${(_d = (_c = this.metadata) === null || _c === void 0 ? void 0 : _c.label) !== null && _d !== void 0 ? _d : this.key}: </span>
76
+ ` : nothing}
77
+ <span part="values">${this.metadataValue}</span>
78
+ </ft-chip>`;
79
+ return noTooltip ? chip : html `
66
80
  <ft-tooltip part="tooltip"
67
81
  slot="${inFloatingMenu ? "toggle" : ""}"
68
82
  class="${this.multiLine ? "ft-reader-metadata-multi-line" : ""}"
69
- text="${`${this.metadataLabel}: ${(_b = (_a = this.flatMetadata) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : this.noValueMessage}`}">
70
- <ft-chip part="chip"
71
- exportpartsPrefix="chip"
72
- trailingIcon icon="${inFloatingMenu ? "thin_arrow" : ""}"
73
- ?clickable=${inFloatingMenu}
74
- ?multiLine=${this.multiLine}>
75
- ${this.renderChipContent()}
76
- </ft-chip>
83
+ text="${`${this.metadataLabel}: ${(_f = (_e = this.flatMetadata) === null || _e === void 0 ? void 0 : _e.value) !== null && _f !== void 0 ? _f : this.noValueMessage}`}">
84
+ ${chip}
77
85
  </ft-tooltip>
78
86
  `;
79
87
  }
80
- renderChipContent() {
81
- var _a, _b;
82
- if (this.metadata && this.metadata.values.length > 0) {
83
- return (_b = (_a = this.flatMetadata) === null || _a === void 0 ? void 0 : _a.displayValue) !== null && _b !== void 0 ? _b : this.noValueMessage;
88
+ get metadataValue() {
89
+ if (this.flatMetadata) {
90
+ return this.flatMetadata.displayValue;
84
91
  }
85
92
  if (this.editorMode) {
86
93
  if (this.key) {
@@ -107,8 +114,7 @@ class FtReaderMetadata extends withI18n(FtReaderComponent) {
107
114
  `;
108
115
  }
109
116
  hideIfEmpty() {
110
- const theresNoMetadata = !this.metadata || this.metadata.values.length == 0;
111
- const shouldHide = this.useForSwitchingToRelatives ? theresNoMetadata && this.relatives.length === 0 : theresNoMetadata;
117
+ const shouldHide = this.flatMetadata == null && (this.useForSwitchingToRelatives ? this.relatives.length === 0 : true);
112
118
  if (!this.editorMode && shouldHide) {
113
119
  return html `
114
120
  <style>
@@ -163,12 +169,7 @@ class FtReaderMetadata extends withI18n(FtReaderComponent) {
163
169
  }
164
170
  }
165
171
  if (props.has("metadata")) {
166
- this.flatMetadata = this.metadata && this.metadata.values.length > 0 ? ClusteringHelper.flattenMetadata(this.metadata) : ({
167
- key: this.key,
168
- label: this.key,
169
- value: undefined,
170
- displayValue: undefined,
171
- });
172
+ this.flatMetadata = ClusteringHelper.flattenMetadata(this.metadata);
172
173
  }
173
174
  }
174
175
  get metadataLabel() {
@@ -198,6 +199,9 @@ __decorate([
198
199
  __decorate([
199
200
  property({ type: Boolean })
200
201
  ], FtReaderMetadata.prototype, "useForSwitchingToRelatives", void 0);
202
+ __decorate([
203
+ property({ type: Boolean })
204
+ ], FtReaderMetadata.prototype, "displayLabel", void 0);
201
205
  __decorate([
202
206
  property({ attribute: false })
203
207
  ], FtReaderMetadata.prototype, "editorMode", void 0);