@fluid-topics/ft-search-facet 2.1.18 → 2.1.20

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,52 +1,52 @@
1
1
  export class FacetHelper {
2
2
  addValueForFacet(facet, value) {
3
- let newFacet = JSON.parse(JSON.stringify(facet));
3
+ const newFacet = JSON.parse(JSON.stringify(facet));
4
4
  this.selectValue(newFacet, value);
5
- return newFacet.rootNodes.flatMap(e => this.factoriseFacetValueWhenAllChildSelected(e));
5
+ return newFacet.rootNodes.flatMap((e) => this.factoriseFacetValueWhenAllChildSelected(e));
6
6
  }
7
7
  removeValueForFacet(facet, value) {
8
- let newFacet = JSON.parse(JSON.stringify(facet));
8
+ const newFacet = JSON.parse(JSON.stringify(facet));
9
9
  this.unselectValue(newFacet, value);
10
- return newFacet.rootNodes.flatMap(e => this.factoriseFacetValueWhenAllChildSelected(e));
10
+ return newFacet.rootNodes.flatMap((e) => this.factoriseFacetValueWhenAllChildSelected(e));
11
11
  }
12
12
  selectValue(facet, value) {
13
- facet.rootNodes.forEach(entry => this.selectEntryValue(entry, value));
13
+ facet.rootNodes.forEach((entry) => this.selectEntryValue(entry, value));
14
14
  }
15
15
  unselectValue(facet, value) {
16
- facet.rootNodes.forEach(entry => this.unselectEntryValue(entry, value));
16
+ facet.rootNodes.forEach((entry) => this.unselectEntryValue(entry, value));
17
17
  }
18
18
  selectEntryValue(entry, value) {
19
19
  if (entry.value == value) {
20
20
  entry.selected = true;
21
- entry.childNodes.forEach(e => this.recurcivlySetSelected(e, true));
21
+ entry.childNodes.forEach((e) => this.recurcivlySetSelected(e, true));
22
22
  }
23
23
  else if (value.startsWith(entry.value + "|")) {
24
- entry.childNodes.forEach(e => this.selectEntryValue(e, value));
24
+ entry.childNodes.forEach((e) => this.selectEntryValue(e, value));
25
25
  }
26
26
  }
27
27
  unselectEntryValue(entry, value) {
28
28
  if (entry.value == value) {
29
29
  entry.selected = false;
30
- entry.childNodes.forEach(e => this.recurcivlySetSelected(e, false));
30
+ entry.childNodes.forEach((e) => this.recurcivlySetSelected(e, false));
31
31
  }
32
32
  else if (value.startsWith(entry.value + "|")) {
33
- entry.childNodes.forEach(e => this.unselectEntryValue(e, value));
34
- if (entry.childNodes.some(e => !e.selected)) {
33
+ entry.childNodes.forEach((e) => this.unselectEntryValue(e, value));
34
+ if (entry.childNodes.some((e) => !e.selected)) {
35
35
  entry.selected = false;
36
36
  }
37
37
  }
38
38
  }
39
39
  recurcivlySetSelected(entry, selected) {
40
40
  entry.selected = selected;
41
- entry.childNodes.forEach(e => this.recurcivlySetSelected(e, selected));
41
+ entry.childNodes.forEach((e) => this.recurcivlySetSelected(e, selected));
42
42
  }
43
43
  factoriseFacetValueWhenAllChildSelected(entry) {
44
44
  if (entry.selected) {
45
45
  return [entry.value];
46
46
  }
47
47
  else {
48
- let selectedValues = entry.childNodes.flatMap(e => this.factoriseFacetValueWhenAllChildSelected(e)) || [];
49
- if (entry.childNodes.length > 0 && entry.childNodes.every(child => selectedValues.includes(child.value))) {
48
+ const selectedValues = entry.childNodes.flatMap((e) => this.factoriseFacetValueWhenAllChildSelected(e)) || [];
49
+ if (entry.childNodes.length > 0 && entry.childNodes.every((child) => selectedValues.includes(child.value))) {
50
50
  return [entry.value];
51
51
  }
52
52
  else {
@@ -55,6 +55,6 @@ export class FacetHelper {
55
55
  }
56
56
  }
57
57
  allSubEntrySelected(entry) {
58
- return entry.childNodes.every(e => e.selected && e.childNodes.every(c => this.allSubEntrySelected(c)));
58
+ return entry.childNodes.every((e) => e.selected && e.childNodes.every((c) => this.allSubEntrySelected(c)));
59
59
  }
60
60
  }
@@ -1,2 +1,2 @@
1
- import { I18nMessageContext } from "@fluid-topics/ft-i18n";
1
+ import { I18nMessageContext, } from "@fluid-topics/ft-i18n";
2
2
  export const searchFacetContext = I18nMessageContext.build("designedSearchFacet");
@@ -1,12 +1,12 @@
1
1
  export function convertFacetToFilterOptions(facet) {
2
- return facet.rootNodes.map(node => convertFacetNodeToFilterOptions(node));
2
+ return facet.rootNodes.map((node) => convertFacetNodeToFilterOptions(node));
3
3
  }
4
4
  function convertFacetNodeToFilterOptions(facetNode, parentSelected = false) {
5
5
  return {
6
6
  label: facetNode.label,
7
7
  value: facetNode.value,
8
8
  selected: facetNode.selected && !parentSelected,
9
- subOptions: facetNode.childNodes.map(node => convertFacetNodeToFilterOptions(node, facetNode.selected)),
9
+ subOptions: facetNode.childNodes.map((node) => convertFacetNodeToFilterOptions(node, facetNode.selected)),
10
10
  count: facetNode.totalResultsCount,
11
11
  };
12
12
  }