@fluid-topics/ft-search-selected-facets 1.2.59 → 1.2.61
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.
- package/build/ft-search-selected-facets.d.ts +6 -1
- package/build/ft-search-selected-facets.js +98 -41
- package/build/ft-search-selected-facets.light.js +270 -245
- package/build/ft-search-selected-facets.min.js +424 -399
- package/build/ft-search-selected-facets.properties.d.ts +4 -0
- package/package.json +8 -8
|
@@ -3,10 +3,14 @@ import { 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";
|
|
5
5
|
import { FtMetadataFilter, FtSearchFacet, FtSearchScopeKeys } from "@fluid-topics/public-api";
|
|
6
|
-
declare const FtSearchSelectedFacets_base: typeof FtSearchComponent & import("@fluid-topics/ft-wc-utils").Constructor<import("@fluid-topics/ft-i18n").FtLitElementWithI18nInterface>;
|
|
6
|
+
declare const FtSearchSelectedFacets_base: typeof FtSearchComponent & import("@fluid-topics/ft-wc-utils").Constructor<import("@fluid-topics/ft-i18n").FtLitElementWithI18nInterface> & import("@fluid-topics/ft-wc-utils").Constructor<import("@fluid-topics/ft-app-context").FtLitElementWithDateFormatInterface>;
|
|
7
7
|
export declare class FtSearchSelectedFacets extends FtSearchSelectedFacets_base implements FtSearchSelectedFacetsProperties {
|
|
8
8
|
static elementDefinitions: ElementDefinitionsMap;
|
|
9
9
|
static styles: import("lit").CSSResult;
|
|
10
|
+
displayLabel: boolean;
|
|
11
|
+
forceTooltip: boolean;
|
|
12
|
+
multiLine: boolean;
|
|
13
|
+
hierarchicalValueTruncatingLevel?: number;
|
|
10
14
|
facets?: Array<FtSearchFacet>;
|
|
11
15
|
searchInDocumentTitlesOnly?: boolean;
|
|
12
16
|
filters?: FtMetadataFilter[];
|
|
@@ -20,6 +24,7 @@ export declare class FtSearchSelectedFacets extends FtSearchSelectedFacets_base
|
|
|
20
24
|
private getSelectedValues;
|
|
21
25
|
private getLabelFromValue;
|
|
22
26
|
private getBreadcrumbFromValue;
|
|
27
|
+
private readAndFormatValueFromFacet;
|
|
23
28
|
private unquote;
|
|
24
29
|
private renderSearchInDocumentTitlesOnly;
|
|
25
30
|
private renderPeriodFilter;
|
|
@@ -5,8 +5,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { html, nothing } from "lit";
|
|
8
|
+
import { property } from "lit/decorators.js";
|
|
8
9
|
import { repeat } from "lit/directives/repeat.js";
|
|
9
|
-
import { flatDeep, FocusMainContentEvent, redux, shadowQuerySelectorAll } from "@fluid-topics/ft-wc-utils";
|
|
10
|
+
import { flatDeep, FocusMainContentEvent, formatHierarchicalValues, redux, shadowQuerySelectorAll } from "@fluid-topics/ft-wc-utils";
|
|
10
11
|
import { styles } from "./ft-search-selected-facets.styles";
|
|
11
12
|
import { FtSearchComponent } from "@fluid-topics/ft-search-context/build/registration";
|
|
12
13
|
import { FtChip } from "@fluid-topics/ft-chip";
|
|
@@ -16,7 +17,8 @@ import { searchInDocumentTitlesOnlySelector } from "@fluid-topics/ft-search-cont
|
|
|
16
17
|
import { searchTypeContext, searchTypeDefaultMessages } from "@fluid-topics/ft-search-type";
|
|
17
18
|
import { periodFilterContext, periodFilterDefaultMessages } from "@fluid-topics/ft-search-period-filter";
|
|
18
19
|
import { searchSelectedFacets, searchSelectedFacetsDefaultMessages } from "./FtSearchSelectedFacetsMessages";
|
|
19
|
-
|
|
20
|
+
import { withDateFormat } from "@fluid-topics/ft-app-context";
|
|
21
|
+
class FtSearchSelectedFacets extends withDateFormat(withI18n(FtSearchComponent)) {
|
|
20
22
|
get hasSomethingToDisplay() {
|
|
21
23
|
var _a, _b;
|
|
22
24
|
return this.searchInDocumentTitlesOnly
|
|
@@ -25,6 +27,10 @@ class FtSearchSelectedFacets extends withI18n(FtSearchComponent) {
|
|
|
25
27
|
}
|
|
26
28
|
constructor() {
|
|
27
29
|
super();
|
|
30
|
+
this.displayLabel = false;
|
|
31
|
+
this.forceTooltip = false;
|
|
32
|
+
this.multiLine = false;
|
|
33
|
+
this.hierarchicalValueTruncatingLevel = 3;
|
|
28
34
|
this.addI18nContext(searchTypeContext, searchTypeDefaultMessages);
|
|
29
35
|
this.addI18nContext(searchSelectedFacets, searchSelectedFacetsDefaultMessages);
|
|
30
36
|
this.addI18nContext(periodFilterContext, periodFilterDefaultMessages);
|
|
@@ -49,25 +55,35 @@ class FtSearchSelectedFacets extends withI18n(FtSearchComponent) {
|
|
|
49
55
|
if (facetKey === "ft:publicationId") {
|
|
50
56
|
return nothing;
|
|
51
57
|
}
|
|
52
|
-
let label = facetLabel + ": " + this.getBreadcrumbFromValue(value);
|
|
53
58
|
const keyWithNoColumn = facetKey.replace(":", "-");
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
const displayValue = this.getLabelFromValue(facetKey, value);
|
|
60
|
+
const displayTooltipValue = this.getBreadcrumbFromValue(facetKey, value);
|
|
61
|
+
const label = facetLabel + ": " + displayTooltipValue;
|
|
62
|
+
const noTooltip = !this.forceTooltip && this.displayLabel && displayTooltipValue == displayValue;
|
|
63
|
+
const chip = html `
|
|
64
|
+
<ft-chip
|
|
65
|
+
part="ft-search-selected-facets ft-search-selected-facet-${keyWithNoColumn}"
|
|
66
|
+
removable hideIconTooltip
|
|
67
|
+
iconLabel="${searchSelectedFacets.messages.removeFilterLabel()}"
|
|
68
|
+
label="${label}"
|
|
69
|
+
@icon-click=${(e) => {
|
|
63
70
|
var _a;
|
|
64
71
|
(_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.setValueFilter(facetKey, selectedValues.filter(v => v !== value));
|
|
65
72
|
this.determineAndApplyFocus(e);
|
|
66
73
|
}}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
74
|
+
?multiLine="${this.multiLine}"
|
|
75
|
+
data-key="${facetKey}"
|
|
76
|
+
data-value="${value}">
|
|
77
|
+
${this.displayLabel ? html `
|
|
78
|
+
<span part="label">${facetLabel}: </span>` : nothing}
|
|
79
|
+
<span part="values">
|
|
80
|
+
${displayValue}
|
|
81
|
+
</span>
|
|
82
|
+
</ft-chip>`;
|
|
83
|
+
return noTooltip ? chip : html `
|
|
84
|
+
<ft-tooltip inline text="${label}"
|
|
85
|
+
part="tooltips tooltip-${keyWithNoColumn}">
|
|
86
|
+
${chip}
|
|
71
87
|
</ft-tooltip>
|
|
72
88
|
`;
|
|
73
89
|
}
|
|
@@ -102,11 +118,18 @@ class FtSearchSelectedFacets extends withI18n(FtSearchComponent) {
|
|
|
102
118
|
.filter(n => n.selected)
|
|
103
119
|
.map(n => n.value);
|
|
104
120
|
}
|
|
105
|
-
getLabelFromValue(value) {
|
|
106
|
-
return this.
|
|
121
|
+
getLabelFromValue(key, value) {
|
|
122
|
+
return this.readAndFormatValueFromFacet(key, value, this.hierarchicalValueTruncatingLevel);
|
|
123
|
+
}
|
|
124
|
+
getBreadcrumbFromValue(key, value) {
|
|
125
|
+
return this.readAndFormatValueFromFacet(key, value);
|
|
107
126
|
}
|
|
108
|
-
|
|
109
|
-
|
|
127
|
+
readAndFormatValueFromFacet(key, value, hierarchicalTruncate) {
|
|
128
|
+
const dateFormatter = this.getDateFormatter(key);
|
|
129
|
+
if (dateFormatter) {
|
|
130
|
+
return dateFormatter(value);
|
|
131
|
+
}
|
|
132
|
+
return formatHierarchicalValues(this.unquote(value).split("|"), hierarchicalTruncate);
|
|
110
133
|
}
|
|
111
134
|
unquote(value) {
|
|
112
135
|
if (value.startsWith("\"") && value.endsWith("\"")) {
|
|
@@ -115,22 +138,32 @@ class FtSearchSelectedFacets extends withI18n(FtSearchComponent) {
|
|
|
115
138
|
return value;
|
|
116
139
|
}
|
|
117
140
|
renderSearchInDocumentTitlesOnly() {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
141
|
+
if (!this.searchInDocumentTitlesOnly) {
|
|
142
|
+
return nothing;
|
|
143
|
+
}
|
|
144
|
+
const label = searchTypeContext.messages.documentTitlesOnly();
|
|
145
|
+
const chip = html `
|
|
146
|
+
<ft-chip
|
|
147
|
+
part="ft-search-selected-facets ft-search-selected-facet-search-in-document-titles-only"
|
|
148
|
+
label="${label}"
|
|
149
|
+
removable
|
|
150
|
+
hideIconTooltip
|
|
151
|
+
iconLabel="${searchSelectedFacets.messages.removeFilterLabel()}"
|
|
152
|
+
@icon-click=${(e) => {
|
|
126
153
|
var _a;
|
|
127
154
|
(_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.setSearchInDocumentTitlesOnly(false);
|
|
128
155
|
this.determineAndApplyFocus(e);
|
|
129
|
-
}}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
156
|
+
}}
|
|
157
|
+
?multiLine="${this.multiLine}">
|
|
158
|
+
<span part="values">
|
|
159
|
+
${label}
|
|
160
|
+
</span>
|
|
161
|
+
</ft-chip>`;
|
|
162
|
+
return !this.forceTooltip ? chip : html `
|
|
163
|
+
<ft-tooltip inline text="${label}"
|
|
164
|
+
part="tooltips tooltip-search-in-document-titles-only">
|
|
165
|
+
${chip}
|
|
166
|
+
</ft-tooltip>`;
|
|
134
167
|
}
|
|
135
168
|
renderPeriodFilter(filter) {
|
|
136
169
|
if (filter.dateFilter) {
|
|
@@ -142,35 +175,47 @@ class FtSearchSelectedFacets extends withI18n(FtSearchComponent) {
|
|
|
142
175
|
return nothing;
|
|
143
176
|
}
|
|
144
177
|
renderDateFilter(key, dateFilter) {
|
|
178
|
+
const label = periodFilterContext.messages.period(periodFilterContext.messages[dateFilter.type]());
|
|
145
179
|
return html `
|
|
146
|
-
<ft-tooltip inline text="${
|
|
180
|
+
<ft-tooltip inline text="${label}"
|
|
147
181
|
part=" tooltips tooltip-search-period-filter">
|
|
148
182
|
<ft-chip
|
|
149
183
|
part="ft-search-selected-facets ft-search-selected-facet-period-filter"
|
|
150
|
-
removable
|
|
184
|
+
removable
|
|
185
|
+
hideIconTooltip
|
|
186
|
+
label="${label}"
|
|
151
187
|
iconLabel="${searchSelectedFacets.messages.removeFilterLabel()}"
|
|
152
188
|
@icon-click=${(e) => {
|
|
153
189
|
var _a;
|
|
154
190
|
(_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.removeDateFilter(key);
|
|
155
191
|
this.determineAndApplyFocus(e);
|
|
156
|
-
}}
|
|
157
|
-
${
|
|
192
|
+
}}
|
|
193
|
+
?multiLine="${this.multiLine}">
|
|
194
|
+
<span part="values">
|
|
195
|
+
${periodFilterContext.messages[dateFilter.type]()}
|
|
196
|
+
</span>
|
|
158
197
|
</ft-chip>
|
|
159
198
|
</ft-tooltip>`;
|
|
160
199
|
}
|
|
161
200
|
renderRangeFilter(key, rangeFilter) {
|
|
201
|
+
const label = periodFilterContext.messages.period(periodFilterContext.messages.customPeriod(rangeFilter.from, rangeFilter.to));
|
|
162
202
|
return html `
|
|
163
|
-
<ft-tooltip inline text="${
|
|
203
|
+
<ft-tooltip inline text="${label}" part=" tooltips tooltip-search-period-filter">
|
|
164
204
|
<ft-chip
|
|
165
205
|
part="ft-search-selected-facets ft-search-selected-facet-period-filter"
|
|
166
|
-
|
|
206
|
+
label="${label}"
|
|
207
|
+
removable
|
|
208
|
+
hideIconTooltip
|
|
167
209
|
iconLabel="${searchSelectedFacets.messages.removeFilterLabel()}"
|
|
168
210
|
@icon-click=${(e) => {
|
|
169
211
|
var _a;
|
|
170
212
|
(_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.removeRangeFilter(key);
|
|
171
213
|
this.determineAndApplyFocus(e);
|
|
172
|
-
}}
|
|
173
|
-
${
|
|
214
|
+
}}
|
|
215
|
+
?multiLine="${this.multiLine}">
|
|
216
|
+
<span part="values">
|
|
217
|
+
${periodFilterContext.messages["CUSTOM"]()}
|
|
218
|
+
</span>
|
|
174
219
|
</ft-chip>
|
|
175
220
|
</ft-tooltip>`;
|
|
176
221
|
}
|
|
@@ -180,6 +225,18 @@ FtSearchSelectedFacets.elementDefinitions = {
|
|
|
180
225
|
"ft-tooltip": FtTooltip,
|
|
181
226
|
};
|
|
182
227
|
FtSearchSelectedFacets.styles = styles;
|
|
228
|
+
__decorate([
|
|
229
|
+
property({ type: Boolean })
|
|
230
|
+
], FtSearchSelectedFacets.prototype, "displayLabel", void 0);
|
|
231
|
+
__decorate([
|
|
232
|
+
property({ type: Boolean })
|
|
233
|
+
], FtSearchSelectedFacets.prototype, "forceTooltip", void 0);
|
|
234
|
+
__decorate([
|
|
235
|
+
property({ type: Boolean })
|
|
236
|
+
], FtSearchSelectedFacets.prototype, "multiLine", void 0);
|
|
237
|
+
__decorate([
|
|
238
|
+
property({ type: Number })
|
|
239
|
+
], FtSearchSelectedFacets.prototype, "hierarchicalValueTruncatingLevel", void 0);
|
|
183
240
|
__decorate([
|
|
184
241
|
redux({ store: "search" })
|
|
185
242
|
], FtSearchSelectedFacets.prototype, "facets", void 0);
|