@fluid-topics/ft-search-selected-facets 1.1.11 → 1.1.13

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.
@@ -3,21 +3,19 @@ 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 { FtSearchFacet } from "@fluid-topics/public-api";
6
- declare const FtSearchSelectedFacets_base: typeof FtSearchComponent & (new (...args: any[]) => 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>;
7
7
  export declare class FtSearchSelectedFacets extends FtSearchSelectedFacets_base implements FtSearchSelectedFacetsProperties {
8
8
  static elementDefinitions: ElementDefinitionsMap;
9
9
  static styles: import("lit").CSSResult;
10
10
  facets?: Array<FtSearchFacet>;
11
11
  searchInDocumentTitlesOnly?: boolean;
12
- editorMode: boolean;
12
+ get hasSomethingToDisplay(): boolean | undefined;
13
13
  constructor();
14
- protected render(): import("lit").TemplateResult<1> | typeof nothing;
15
- private renderDummyFacet;
14
+ protected render(): typeof nothing | import("lit").TemplateResult<1>;
16
15
  private renderFacet;
17
16
  private getSelectedValues;
18
17
  private getLabelFromValue;
19
18
  private getBreadcrumbFromValue;
20
- private quote;
21
19
  private unquote;
22
20
  private renderSearchInDocumentTitlesOnly;
23
21
  }
@@ -11,26 +11,23 @@ import { styles } from "./ft-search-selected-facets.css";
11
11
  import { FtSearchComponent } from "@fluid-topics/ft-search-context/build/registration";
12
12
  import { FtChip } from "@fluid-topics/ft-chip";
13
13
  import { FtTooltip } from "@fluid-topics/ft-tooltip";
14
- import { ftAppInfoStore } from "@fluid-topics/ft-app-context";
15
14
  import { withI18n } from "@fluid-topics/ft-i18n";
16
15
  import { searchInDocumentTitlesOnlySelector } from "@fluid-topics/ft-search-context";
17
16
  import { searchTypeContext, searchTypeDefaultMessages } from "@fluid-topics/ft-search-type";
18
17
  class FtSearchSelectedFacets extends withI18n(FtSearchComponent) {
18
+ get hasSomethingToDisplay() {
19
+ var _a;
20
+ return this.searchInDocumentTitlesOnly || ((_a = this.facets) === null || _a === void 0 ? void 0 : _a.some(facet => this.getSelectedValues(facet).length > 0));
21
+ }
19
22
  constructor() {
20
23
  super();
21
- this.editorMode = false;
22
- this.addStore(ftAppInfoStore);
23
24
  this.addI18nContext(searchTypeContext, searchTypeDefaultMessages);
24
25
  }
25
26
  render() {
26
- if (this.editorMode) {
27
- return this.renderDummyFacet();
28
- }
29
- if ((this.facets == null || this.facets.length === 0) && !this.searchInDocumentTitlesOnly) {
27
+ if (!this.hasSomethingToDisplay) {
30
28
  return nothing;
31
29
  }
32
30
  return html `
33
-
34
31
  <div class="ft-search-selected-facets--container">
35
32
  ${repeat(this.facets || [], facet => facet.key, facet => {
36
33
  const values = this.getSelectedValues(facet);
@@ -40,17 +37,6 @@ class FtSearchSelectedFacets extends withI18n(FtSearchComponent) {
40
37
  </div>
41
38
  `;
42
39
  }
43
- renderDummyFacet() {
44
- return html `
45
-
46
- <div class="ft-search-selected-facets--container">
47
- ${[
48
- this.renderFacet("placeholder", "placeholder", ["value1", "value2", "value3"], "value1"),
49
- this.renderFacet("placeholder", "placeholder", ["value1", "value2", "value3"], "value2"),
50
- this.renderFacet("placeholder", "placeholder", ["value1", "value2", "value3"], "value3")
51
- ]}
52
- </div>`;
53
- }
54
40
  renderFacet(facetKey, facetLabel, selectedValues, value) {
55
41
  let label = facetLabel + ": " + this.getBreadcrumbFromValue(value);
56
42
  const keyWithNoColumn = facetKey.replace(":", "-");
@@ -58,12 +44,12 @@ class FtSearchSelectedFacets extends withI18n(FtSearchComponent) {
58
44
  <ft-tooltip inline text="${label}"
59
45
  part="tooltips tooltip-${keyWithNoColumn}">
60
46
  <ft-chip
61
- part="ft-search-selected-facets ft-search-selected-facet-${keyWithNoColumn}"
62
- removable
63
- label="${label}"
64
- @icon-click=${() => { var _a; return (_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.setFilter(facetKey, selectedValues.filter(v => v !== value)); }}
65
- data-key="${facetKey}"
66
- data-value="${value}">
47
+ part="ft-search-selected-facets ft-search-selected-facet-${keyWithNoColumn}"
48
+ removable
49
+ label="${label}"
50
+ @icon-click=${() => { var _a; return (_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.setFilter(facetKey, selectedValues.filter(v => v !== value)); }}
51
+ data-key="${facetKey}"
52
+ data-value="${value}">
67
53
  ${this.getLabelFromValue(value)}
68
54
  </ft-chip>
69
55
  </ft-tooltip>
@@ -80,9 +66,6 @@ class FtSearchSelectedFacets extends withI18n(FtSearchComponent) {
80
66
  getBreadcrumbFromValue(value) {
81
67
  return this.unquote(value).split("|").join(" > ");
82
68
  }
83
- quote(value) {
84
- return `"${value}"`;
85
- }
86
69
  unquote(value) {
87
70
  if (value.startsWith("\"") && value.endsWith("\"")) {
88
71
  return value.replace(/(^"+)|("+$)/g, "");
@@ -94,9 +77,9 @@ class FtSearchSelectedFacets extends withI18n(FtSearchComponent) {
94
77
  <ft-tooltip inline text="${searchTypeContext.messages.documentTitlesOnly()}"
95
78
  part="tooltips tooltip-search-in-document-titles-only">
96
79
  <ft-chip
97
- part="ft-search-selected-facets ft-search-selected-facet-search-in-document-titles-only"
98
- removable
99
- @icon-click=${() => { var _a; return (_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.setSearchInDocumentTitlesOnly(false); }}>
80
+ part="ft-search-selected-facets ft-search-selected-facet-search-in-document-titles-only"
81
+ removable
82
+ @icon-click=${() => { var _a; return (_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.setSearchInDocumentTitlesOnly(false); }}>
100
83
  ${searchTypeContext.messages.documentTitlesOnly()}
101
84
  </ft-chip>
102
85
  </ft-tooltip>
@@ -114,7 +97,4 @@ __decorate([
114
97
  __decorate([
115
98
  redux({ store: "search", selector: searchInDocumentTitlesOnlySelector })
116
99
  ], FtSearchSelectedFacets.prototype, "searchInDocumentTitlesOnly", void 0);
117
- __decorate([
118
- redux({ store: ftAppInfoStore.name })
119
- ], FtSearchSelectedFacets.prototype, "editorMode", void 0);
120
100
  export { FtSearchSelectedFacets };