@fluid-topics/ft-reader-topic-metadata 2.2.21 → 2.2.25

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.
@@ -11,15 +11,17 @@ export declare class FtReaderTopicMetadata extends FtReaderTopicMetadata_base im
11
11
  displayLabel: boolean;
12
12
  hierarchicalValueTruncatingLevel?: number;
13
13
  forceTooltip: boolean;
14
+ translateValues: boolean;
14
15
  editorMode: boolean;
15
16
  private metadata?;
16
17
  private flatMetadata?;
17
- protected render(): import("lit-html").TemplateResult<1>;
18
+ private availableContentLocales?;
19
+ protected render(): import("lit").TemplateResult<1>;
18
20
  private renderChip;
19
21
  private get metadataValue();
20
22
  private hideIfEmpty;
21
23
  private get tooltipText();
22
- protected update(props: PropertyValues): void;
24
+ protected willUpdate(props: PropertyValues): void;
23
25
  onStoreAvailable(): void;
24
26
  private updateContent;
25
27
  }
@@ -8,10 +8,11 @@ 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, numberProperty, } from "@fluid-topics/ft-wc-utils";
11
+ import { ClusteringHelper, MetadataValueLocalizer, numberProperty, redux, } from "@fluid-topics/ft-wc-utils";
12
12
  import { FtTooltip } from "@fluid-topics/ft-tooltip";
13
13
  import { FtChip } from "@fluid-topics/ft-chip";
14
14
  import { withDateFormat } from "@fluid-topics/ft-app-context/build/mixins/withDateFormat";
15
+ import { ftAppInfoStore } from "@fluid-topics/ft-app-context";
15
16
  export class FtReaderTopicMetadata extends withDateFormat(FtReaderTopicComponent) {
16
17
  constructor() {
17
18
  super(...arguments);
@@ -19,6 +20,7 @@ export class FtReaderTopicMetadata extends withDateFormat(FtReaderTopicComponent
19
20
  this.displayLabel = false;
20
21
  this.hierarchicalValueTruncatingLevel = 3;
21
22
  this.forceTooltip = false;
23
+ this.translateValues = false;
22
24
  this.editorMode = false;
23
25
  }
24
26
  render() {
@@ -77,15 +79,19 @@ export class FtReaderTopicMetadata extends withDateFormat(FtReaderTopicComponent
77
79
  get tooltipText() {
78
80
  return this.flatMetadata ? this.flatMetadata.label + ": " + this.flatMetadata.displayTooltipValue : "";
79
81
  }
80
- update(props) {
81
- super.update(props);
82
+ willUpdate(props) {
83
+ var _a;
84
+ super.willUpdate(props);
82
85
  if (["key", "tocNode"].some((p) => props.has(p))) {
83
86
  this.updateContent();
84
87
  }
85
- if (props.has("metadata") || props.has("hierarchicalValueTruncatingLevel") || this.dateFormatOptionsChanged(props)) {
88
+ if (props.has("translateValues") || props.has("metadata") || props.has("hierarchicalValueTruncatingLevel") || this.dateFormatOptionsChanged(props)) {
86
89
  this.flatMetadata = this.metadata
87
90
  ? ClusteringHelper.flattenMetadata(this.metadata, this.hierarchicalValueTruncatingLevel, this.getDateFormatter(this.metadata.key))
88
91
  : undefined;
92
+ if (this.translateValues) {
93
+ this.flatMetadata = new MetadataValueLocalizer((_a = this.availableContentLocales) !== null && _a !== void 0 ? _a : []).localize(this.flatMetadata);
94
+ }
89
95
  }
90
96
  }
91
97
  onStoreAvailable() {
@@ -120,6 +126,9 @@ __decorate([
120
126
  __decorate([
121
127
  property({ type: Boolean })
122
128
  ], FtReaderTopicMetadata.prototype, "forceTooltip", void 0);
129
+ __decorate([
130
+ property({ type: Boolean })
131
+ ], FtReaderTopicMetadata.prototype, "translateValues", void 0);
123
132
  __decorate([
124
133
  state()
125
134
  ], FtReaderTopicMetadata.prototype, "editorMode", void 0);
@@ -129,3 +138,6 @@ __decorate([
129
138
  __decorate([
130
139
  state()
131
140
  ], FtReaderTopicMetadata.prototype, "flatMetadata", void 0);
141
+ __decorate([
142
+ redux({ store: ftAppInfoStore.name })
143
+ ], FtReaderTopicMetadata.prototype, "availableContentLocales", void 0);