@fluid-topics/ft-search-result-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.
@@ -35,6 +35,7 @@ export declare class FtSearchResultMetadata extends FtSearchResultMetadata_base
35
35
  private renderChip;
36
36
  private renderContent;
37
37
  private get displayCluster();
38
+ private get clusterHasMultipleValues();
38
39
  private getEllipsis;
39
40
  protected update(props: PropertyValues): void;
40
41
  private get resultData();
@@ -6,7 +6,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  };
7
7
  import { html, nothing } from "lit";
8
8
  import { property, state } from "lit/decorators.js";
9
- import { redux } from "@fluid-topics/ft-wc-utils";
9
+ import { ClusteringHelper, redux } from "@fluid-topics/ft-wc-utils";
10
10
  import { styles } from "./ft-search-result-metadata.css";
11
11
  import { FtSearchResultComponent } from "@fluid-topics/ft-search-result-context/build/registration";
12
12
  import { ftAppInfoStore } from "@fluid-topics/ft-app-context";
@@ -16,7 +16,6 @@ import { FtTooltip } from "@fluid-topics/ft-tooltip";
16
16
  import { FtChip } from "@fluid-topics/ft-chip";
17
17
  import { FtFloatingMenu, FtFloatingMenuItem, FtFloatingMenuLabel } from "@fluid-topics/ft-floating-menu";
18
18
  import { getResultUrl, SearchResultClickEvent } from "@fluid-topics/ft-search-result-context/build/utils";
19
- import { ClusteringHelper } from "@fluid-topics/ft-search-result-context/build/ClusteringHelper";
20
19
  import { repeat } from "lit/directives/repeat.js";
21
20
  class FtSearchResultMetadata extends withI18n(FtSearchResultComponent) {
22
21
  constructor() {
@@ -73,10 +72,10 @@ class FtSearchResultMetadata extends withI18n(FtSearchResultComponent) {
73
72
  (_a = this.resultStateManager) === null || _a === void 0 ? void 0 : _a.selectResult(this.clustersByValue[e.detail].result);
74
73
  }
75
74
  computeClusters() {
76
- var _a;
75
+ var _a, _b;
77
76
  const clustersByValue = {};
78
- const clusteringHelper = new ClusteringHelper(this.cluster, this.result, this.resultStateManager.registeredMetadata, this.metadataDescriptors);
79
- this.clusters = clusteringHelper.computeClustersItemsForMetadata(this.key, ((_a = this.request) === null || _a === void 0 ? void 0 : _a.contentLocale) || "en");
77
+ const clusteringHelper = new ClusteringHelper((_a = this.cluster) === null || _a === void 0 ? void 0 : _a.entries, this.result, this.resultStateManager.registeredMetadata, this.metadataDescriptors);
78
+ this.clusters = clusteringHelper.computeClustersItemsForMetadata(this.key, ((_b = this.request) === null || _b === void 0 ? void 0 : _b.contentLocale) || "en");
80
79
  this.clusters.forEach(item => {
81
80
  clustersByValue[item.metadata.value] = item;
82
81
  });
@@ -141,7 +140,13 @@ class FtSearchResultMetadata extends withI18n(FtSearchResultComponent) {
141
140
  get displayCluster() {
142
141
  var _a, _b;
143
142
  return this.useAsClusterSwitch
144
- && ((_b = (_a = this.cluster) === null || _a === void 0 ? void 0 : _a.entries.length) !== null && _b !== void 0 ? _b : 0) > 1;
143
+ && ((_b = (_a = this.cluster) === null || _a === void 0 ? void 0 : _a.entries.length) !== null && _b !== void 0 ? _b : 0) > 1
144
+ && this.clusterHasMultipleValues;
145
+ }
146
+ get clusterHasMultipleValues() {
147
+ var _a, _b, _c;
148
+ let values = (_c = (_b = (_a = this.cluster) === null || _a === void 0 ? void 0 : _a.entries) === null || _b === void 0 ? void 0 : _b.map(e => ClusteringHelper.extractResultMetadata(e))) === null || _c === void 0 ? void 0 : _c.map(e => { var _a; return (_a = e.find(m => m.key == this.key)) === null || _a === void 0 ? void 0 : _a.value; });
149
+ return new Set(values).size > 1;
145
150
  }
146
151
  getEllipsis(text) {
147
152
  let cutText = this.maxLength ? text.substring(0, this.maxLength) : text;
@@ -225,7 +230,7 @@ __decorate([
225
230
  redux({ store: ftAppInfoStore.name })
226
231
  ], FtSearchResultMetadata.prototype, "editorMode", void 0);
227
232
  __decorate([
228
- redux({ store: ftAppInfoStore.name })
233
+ redux({ store: ftAppInfoStore.name, selector: (s) => { var _a, _b; return (_b = (_a = s.metadataConfiguration) === null || _a === void 0 ? void 0 : _a.descriptors) !== null && _b !== void 0 ? _b : []; } })
229
234
  ], FtSearchResultMetadata.prototype, "metadataDescriptors", void 0);
230
235
  __decorate([
231
236
  redux({ store: "search" })