@fluid-topics/ft-search-selected-facets 2.2.33 → 2.2.35
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PropertyValues } from "lit";
|
|
2
2
|
import { Debouncer, ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
|
|
3
3
|
import { FtSearchSelectedFacetsProperties } from "./ft-search-selected-facets.properties";
|
|
4
4
|
import { FtSearchComponent } from "@fluid-topics/ft-search-context/build/registration";
|
|
@@ -19,12 +19,18 @@ export declare class FtSearchSelectedFacets extends FtSearchSelectedFacets_base
|
|
|
19
19
|
filters?: FtMetadataFilter[];
|
|
20
20
|
scope?: FtSearchScopeKeys;
|
|
21
21
|
selectedFacetsAriaNotification: I18nAttributeValue;
|
|
22
|
+
nothingToDisplayMessage: I18nAttributeValue;
|
|
23
|
+
readOnly: boolean;
|
|
24
|
+
dense: boolean;
|
|
25
|
+
displayAllFilers: boolean;
|
|
22
26
|
neededSearchRequests: FtSearchStateResourceRequest[];
|
|
23
27
|
protected ariaNotificationDebouncer: Debouncer;
|
|
24
28
|
get hasSomethingToDisplay(): boolean | undefined;
|
|
25
29
|
get numberOfChips(): number;
|
|
26
30
|
constructor();
|
|
27
|
-
protected render():
|
|
31
|
+
protected render(): string | import("lit").TemplateResult<1>;
|
|
32
|
+
private renderAllValueFilters;
|
|
33
|
+
private renderFacets;
|
|
28
34
|
private isFacetNegative;
|
|
29
35
|
private renderFacet;
|
|
30
36
|
private getNextChipToFocusOn;
|
|
@@ -25,8 +25,8 @@ export class FtSearchSelectedFacets extends withAriaNotification(withDateFormat(
|
|
|
25
25
|
var _a, _b;
|
|
26
26
|
return this.searchInDocumentTitlesOnly
|
|
27
27
|
|| this.keywordMatch
|
|
28
|
-
|| ((_a = this.
|
|
29
|
-
|| ((_b = this.
|
|
28
|
+
|| ((_a = this.filters) === null || _a === void 0 ? void 0 : _a.some((f) => this.displayAllFilers || f.dateFilter || f.rangeFilter))
|
|
29
|
+
|| ((_b = this.facets) === null || _b === void 0 ? void 0 : _b.some((facet) => this.getSelectedValues(facet).length > 0));
|
|
30
30
|
}
|
|
31
31
|
get numberOfChips() {
|
|
32
32
|
return shadowQuerySelectorAll(this.shadowRoot, "ft-chip").length;
|
|
@@ -42,6 +42,12 @@ export class FtSearchSelectedFacets extends withAriaNotification(withDateFormat(
|
|
|
42
42
|
key: "searchSelectedFacetsAriaNotification",
|
|
43
43
|
message: "",
|
|
44
44
|
};
|
|
45
|
+
this.nothingToDisplayMessage = {
|
|
46
|
+
message: "",
|
|
47
|
+
};
|
|
48
|
+
this.readOnly = false;
|
|
49
|
+
this.dense = false;
|
|
50
|
+
this.displayAllFilers = false;
|
|
45
51
|
this.neededSearchRequests = [FtSearchStateResourceRequest.CLUSTERED_SEARCH];
|
|
46
52
|
this.ariaNotificationDebouncer = new Debouncer(100);
|
|
47
53
|
this.addI18nContext(searchTypeContext, searchTypeDefaultMessages);
|
|
@@ -52,19 +58,27 @@ export class FtSearchSelectedFacets extends withAriaNotification(withDateFormat(
|
|
|
52
58
|
var _a;
|
|
53
59
|
var _b;
|
|
54
60
|
if (!this.hasSomethingToDisplay) {
|
|
55
|
-
return
|
|
61
|
+
return this.nothingToDisplayMessage.message;
|
|
56
62
|
}
|
|
57
63
|
return html `
|
|
58
64
|
<div role="group" class="ft-search-selected-facets--container" aria-label="${searchSelectedFacets.messages.filterGroupLabel()}">
|
|
59
|
-
${
|
|
60
|
-
const values = this.getSelectedValues(facet);
|
|
61
|
-
return repeat(values, (value) => facet.key + "-" + value, (value) => this.renderFacet(facet.key, facet.label, values, value));
|
|
62
|
-
})}
|
|
65
|
+
${this.displayAllFilers ? this.renderAllValueFilters() : this.renderFacets()}
|
|
63
66
|
${this.renderSearchScope()}
|
|
64
67
|
${repeat((_b = (_a = this.filters) === null || _a === void 0 ? void 0 : _a.filter((f) => f.dateFilter || f.rangeFilter)) !== null && _b !== void 0 ? _b : [], (f) => f.key, (f) => this.renderPeriodFilter(f))}
|
|
65
68
|
</div>
|
|
66
69
|
`;
|
|
67
70
|
}
|
|
71
|
+
renderAllValueFilters() {
|
|
72
|
+
return repeat((this.filters || []).filter((f) => !!f.valueFilter), (filter) => filter.key, (filter) => {
|
|
73
|
+
return repeat(filter.valueFilter.values, (value) => filter.key + "-" + value, (value) => this.renderFacet(filter.key, filter.key, filter.valueFilter.values, value));
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
renderFacets() {
|
|
77
|
+
return repeat(this.facets || [], (facet) => facet.key, (facet) => {
|
|
78
|
+
const values = this.getSelectedValues(facet);
|
|
79
|
+
return repeat(values, (value) => facet.key + "-" + value, (value) => this.renderFacet(facet.key, facet.label, values, value));
|
|
80
|
+
});
|
|
81
|
+
}
|
|
68
82
|
isFacetNegative(key, value) {
|
|
69
83
|
var _a;
|
|
70
84
|
var _b;
|
|
@@ -73,7 +87,7 @@ export class FtSearchSelectedFacets extends withAriaNotification(withDateFormat(
|
|
|
73
87
|
&& ((_b = filter.valueFilter.values) === null || _b === void 0 ? void 0 : _b.includes(value)); })) !== null && _b !== void 0 ? _b : false;
|
|
74
88
|
}
|
|
75
89
|
renderFacet(facetKey, facetLabel, selectedValues, value) {
|
|
76
|
-
if (facetKey === "ft:publicationId") {
|
|
90
|
+
if (facetKey === "ft:publicationId" && !this.displayAllFilers) {
|
|
77
91
|
return nothing;
|
|
78
92
|
}
|
|
79
93
|
const keyWithNoColumn = facetKey.replace(":", "-");
|
|
@@ -84,7 +98,9 @@ export class FtSearchSelectedFacets extends withAriaNotification(withDateFormat(
|
|
|
84
98
|
const chip = html `
|
|
85
99
|
<ft-chip
|
|
86
100
|
part="ft-search-selected-facets ft-search-selected-facet-${keyWithNoColumn}"
|
|
87
|
-
|
|
101
|
+
?dense=${this.dense}
|
|
102
|
+
?removable=${!this.readOnly}
|
|
103
|
+
hideIconTooltip accessibleLabelOnIcon
|
|
88
104
|
iconLabel="${searchSelectedFacets.messages.removeNamedFilterLabel(label)}"
|
|
89
105
|
label="${label}"
|
|
90
106
|
@icon-click=${(e) => {
|
|
@@ -173,7 +189,8 @@ export class FtSearchSelectedFacets extends withAriaNotification(withDateFormat(
|
|
|
173
189
|
<ft-chip
|
|
174
190
|
part="ft-search-selected-facets ft-search-selected-facet-search-in-document-titles-only"
|
|
175
191
|
label="${label}"
|
|
176
|
-
|
|
192
|
+
?dense=${this.dense}
|
|
193
|
+
?removable=${!this.readOnly}
|
|
177
194
|
hideIconTooltip accessibleLabelOnIcon
|
|
178
195
|
iconLabel="${searchSelectedFacets.messages.removeNamedFilterLabel(label)}"
|
|
179
196
|
@icon-click=${(e) => {
|
|
@@ -201,7 +218,8 @@ export class FtSearchSelectedFacets extends withAriaNotification(withDateFormat(
|
|
|
201
218
|
<ft-chip
|
|
202
219
|
part="ft-search-selected-facets ft-search-selected-facet-match-all-keywords"
|
|
203
220
|
label="${label}"
|
|
204
|
-
|
|
221
|
+
?dense=${this.dense}
|
|
222
|
+
?removable=${!this.readOnly}
|
|
205
223
|
hideIconTooltip accessibleLabelOnIcon
|
|
206
224
|
iconLabel="${searchSelectedFacets.messages.removeNamedFilterLabel(label)}"
|
|
207
225
|
@icon-click=${(e) => {
|
|
@@ -236,7 +254,8 @@ export class FtSearchSelectedFacets extends withAriaNotification(withDateFormat(
|
|
|
236
254
|
part=" tooltips tooltip-search-period-filter">
|
|
237
255
|
<ft-chip
|
|
238
256
|
part="ft-search-selected-facets ft-search-selected-facet-period-filter"
|
|
239
|
-
|
|
257
|
+
?dense=${this.dense}
|
|
258
|
+
?removable=${!this.readOnly}
|
|
240
259
|
hideIconTooltip accessibleLabelOnIcon
|
|
241
260
|
label="${label}"
|
|
242
261
|
iconLabel="${searchSelectedFacets.messages.removeNamedFilterLabel(label)}"
|
|
@@ -259,7 +278,8 @@ export class FtSearchSelectedFacets extends withAriaNotification(withDateFormat(
|
|
|
259
278
|
<ft-chip
|
|
260
279
|
part="ft-search-selected-facets ft-search-selected-facet-period-filter"
|
|
261
280
|
label="${label}"
|
|
262
|
-
|
|
281
|
+
?dense=${this.dense}
|
|
282
|
+
?removable=${!this.readOnly}
|
|
263
283
|
hideIconTooltip accessibleLabelOnIcon
|
|
264
284
|
iconLabel="${searchSelectedFacets.messages.removeNamedFilterLabel(label)}"
|
|
265
285
|
@icon-click=${(e) => {
|
|
@@ -347,3 +367,15 @@ __decorate([
|
|
|
347
367
|
__decorate([
|
|
348
368
|
jsonProperty({ context: "officialContext", key: "searchSelectedFacetsAriaNotification" })
|
|
349
369
|
], FtSearchSelectedFacets.prototype, "selectedFacetsAriaNotification", void 0);
|
|
370
|
+
__decorate([
|
|
371
|
+
jsonProperty({ message: "" })
|
|
372
|
+
], FtSearchSelectedFacets.prototype, "nothingToDisplayMessage", void 0);
|
|
373
|
+
__decorate([
|
|
374
|
+
property({ type: Boolean })
|
|
375
|
+
], FtSearchSelectedFacets.prototype, "readOnly", void 0);
|
|
376
|
+
__decorate([
|
|
377
|
+
property({ type: Boolean })
|
|
378
|
+
], FtSearchSelectedFacets.prototype, "dense", void 0);
|
|
379
|
+
__decorate([
|
|
380
|
+
property({ type: Boolean })
|
|
381
|
+
], FtSearchSelectedFacets.prototype, "displayAllFilers", void 0);
|