@fluid-topics/ft-search-result-metadata 1.3.48 → 1.3.50
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.
|
@@ -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 { ClusteringHelper, redux } from "@fluid-topics/ft-wc-utils";
|
|
9
|
+
import { accessResult, ClusteringHelper, numberProperty, redux } from "@fluid-topics/ft-wc-utils";
|
|
10
10
|
import { styles } from "./ft-search-result-metadata.styles";
|
|
11
11
|
import { FtSearchResultComponent } from "@fluid-topics/ft-search-result-context/build/registration";
|
|
12
12
|
import { ftAppInfoStore } from "@fluid-topics/ft-app-context";
|
|
@@ -68,7 +68,7 @@ class FtSearchResultMetadata extends withDateFormat(withI18n(FtSearchResultCompo
|
|
|
68
68
|
<ft-floating-menu @select=${this.onClusterSelected}>
|
|
69
69
|
${this.renderChip("toggle")}
|
|
70
70
|
<ft-floating-menu-label>${this.metadataLabel}</ft-floating-menu-label>
|
|
71
|
-
${repeat((_a = this.clusterItems) !== null && _a !== void 0 ? _a : [], item => item.metadata.value, item => this.renderClusterItem(item.result, item.metadata))}
|
|
71
|
+
${repeat((_a = this.clusterItems) !== null && _a !== void 0 ? _a : [], (item) => item.metadata.value, (item) => this.renderClusterItem(item.result, item.metadata))}
|
|
72
72
|
</ft-floating-menu>
|
|
73
73
|
</div>
|
|
74
74
|
`;
|
|
@@ -78,11 +78,11 @@ class FtSearchResultMetadata extends withDateFormat(withI18n(FtSearchResultCompo
|
|
|
78
78
|
(_a = this.resultStateManager) === null || _a === void 0 ? void 0 : _a.selectResult(this.clustersByValue[e.detail].result);
|
|
79
79
|
}
|
|
80
80
|
computeClusters() {
|
|
81
|
-
var _a
|
|
81
|
+
var _a;
|
|
82
82
|
const clustersByValue = {};
|
|
83
|
-
const clusteringHelper = new ClusteringHelper(
|
|
84
|
-
this.clusterItems = clusteringHelper.computeClustersItemsForMetadata(this.key, ((
|
|
85
|
-
this.clusterItems.forEach(item => {
|
|
83
|
+
const clusteringHelper = new ClusteringHelper(this.cluster.entries, this.result, this.resultStateManager.registeredMetadata, this.metadataDescriptors);
|
|
84
|
+
this.clusterItems = clusteringHelper.computeClustersItemsForMetadata(this.key, ((_a = this.request) === null || _a === void 0 ? void 0 : _a.contentLocale) || "en", context.messages.itemWithNoValueForClusterSwitch(), this.hierarchicalValueTruncatingLevel, this.getDateFormatter(this.key));
|
|
85
|
+
this.clusterItems.forEach((item) => {
|
|
86
86
|
var _a;
|
|
87
87
|
clustersByValue[(_a = item.metadata.value) !== null && _a !== void 0 ? _a : "ft:no_value"] = item;
|
|
88
88
|
});
|
|
@@ -121,7 +121,7 @@ class FtSearchResultMetadata extends withDateFormat(withI18n(FtSearchResultCompo
|
|
|
121
121
|
renderChip(slot) {
|
|
122
122
|
var _a, _b;
|
|
123
123
|
if (this.useChip) {
|
|
124
|
-
|
|
124
|
+
const noTooltip = !this.forceTooltip && this.displayLabel && ((_a = this.flatMetadata) === null || _a === void 0 ? void 0 : _a.displayTooltipValue) == ((_b = this.flatMetadata) === null || _b === void 0 ? void 0 : _b.displayValue);
|
|
125
125
|
const chip = html `
|
|
126
126
|
<ft-chip icon="${this.displayCluster ? "THIN_ARROW" : ""}"
|
|
127
127
|
label="${this.tooltipText}"
|
|
@@ -139,7 +139,7 @@ class FtSearchResultMetadata extends withDateFormat(withI18n(FtSearchResultCompo
|
|
|
139
139
|
`;
|
|
140
140
|
}
|
|
141
141
|
else {
|
|
142
|
-
return html `<span slot
|
|
142
|
+
return html `<span slot="${slot}" part="content">${this.renderContent()}</span>`;
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
renderContent() {
|
|
@@ -168,18 +168,18 @@ class FtSearchResultMetadata extends withDateFormat(withI18n(FtSearchResultCompo
|
|
|
168
168
|
}
|
|
169
169
|
get clusterHasMultipleValues() {
|
|
170
170
|
var _a, _b, _c;
|
|
171
|
-
|
|
171
|
+
const values = (_c = (_b = (_a = this.cluster) === null || _a === void 0 ? void 0 : _a.entries) === null || _b === void 0 ? void 0 : _b.map((result) => ClusteringHelper.extractResultMetadata({ result }))) === 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; });
|
|
172
172
|
return new Set(values).size > 1;
|
|
173
173
|
}
|
|
174
174
|
getEllipsis(text) {
|
|
175
|
-
|
|
175
|
+
const cutText = this.maxLength ? text.substring(0, this.maxLength) : text;
|
|
176
176
|
return cutText + (cutText.length < text.length ? "…" : "");
|
|
177
177
|
}
|
|
178
178
|
update(props) {
|
|
179
179
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
180
180
|
super.update(props);
|
|
181
181
|
if ((props.has("result") || props.has("key") || this.dateFormatOptionsChanged(props)) && this.key && this.result) {
|
|
182
|
-
const metadata = (_a = this.resultData()) === null || _a === void 0 ? void 0 : _a.metadata.find(m => m.key == this.key && m.values.length > 0);
|
|
182
|
+
const metadata = (_a = this.resultData()) === null || _a === void 0 ? void 0 : _a.metadata.find((m) => m.key == this.key && m.values.length > 0);
|
|
183
183
|
this.metadataLabel = (_b = metadata === null || metadata === void 0 ? void 0 : metadata.label) !== null && _b !== void 0 ? _b : this.findClusterMetadataLabel();
|
|
184
184
|
this.flatMetadata = ClusteringHelper.flattenMetadata(metadata, this.hierarchicalValueTruncatingLevel, this.getDateFormatter(this.key));
|
|
185
185
|
}
|
|
@@ -210,9 +210,7 @@ class FtSearchResultMetadata extends withDateFormat(withI18n(FtSearchResultCompo
|
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
resultData(result) {
|
|
213
|
-
|
|
214
|
-
result = result !== null && result !== void 0 ? result : this.result;
|
|
215
|
-
return (_b = (_a = result === null || result === void 0 ? void 0 : result.map) !== null && _a !== void 0 ? _a : result === null || result === void 0 ? void 0 : result.topic) !== null && _b !== void 0 ? _b : result === null || result === void 0 ? void 0 : result.document;
|
|
213
|
+
return accessResult(result !== null && result !== void 0 ? result : this.result);
|
|
216
214
|
}
|
|
217
215
|
get tooltipText() {
|
|
218
216
|
if (this.flatMetadata) {
|
|
@@ -225,7 +223,7 @@ class FtSearchResultMetadata extends withDateFormat(withI18n(FtSearchResultCompo
|
|
|
225
223
|
}
|
|
226
224
|
findClusterMetadataLabel() {
|
|
227
225
|
var _a, _b;
|
|
228
|
-
const metadata = (_a = this.cluster) === null || _a === void 0 ? void 0 : _a.entries.flatMap(result => this.resultData(result).metadata.filter(m => m.key == this.key))[0];
|
|
226
|
+
const metadata = (_a = this.cluster) === null || _a === void 0 ? void 0 : _a.entries.flatMap((result) => this.resultData(result).metadata.filter((m) => m.key == this.key))[0];
|
|
229
227
|
return (_b = metadata === null || metadata === void 0 ? void 0 : metadata.label) !== null && _b !== void 0 ? _b : this.key;
|
|
230
228
|
}
|
|
231
229
|
}
|
|
@@ -253,13 +251,13 @@ __decorate([
|
|
|
253
251
|
property({ type: Boolean })
|
|
254
252
|
], FtSearchResultMetadata.prototype, "displayLabel", void 0);
|
|
255
253
|
__decorate([
|
|
256
|
-
|
|
254
|
+
numberProperty()
|
|
257
255
|
], FtSearchResultMetadata.prototype, "hierarchicalValueTruncatingLevel", void 0);
|
|
258
256
|
__decorate([
|
|
259
257
|
property({ type: Boolean })
|
|
260
258
|
], FtSearchResultMetadata.prototype, "forceTooltip", void 0);
|
|
261
259
|
__decorate([
|
|
262
|
-
|
|
260
|
+
numberProperty({ attribute: "max-length" })
|
|
263
261
|
], FtSearchResultMetadata.prototype, "maxLength", void 0);
|
|
264
262
|
__decorate([
|
|
265
263
|
redux({ store: ftAppInfoStore.name })
|