@fluid-topics/ft-search-bar 2.0.6 → 2.0.8

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.
@@ -92,7 +92,7 @@ export declare class FtSearchBar extends FtLitElement implements FtSearchBarProp
92
92
  private dispatchStateChangeEvent;
93
93
  private updateLocalesDebouncer;
94
94
  private initSearchData;
95
- private facetsLoaded;
95
+ facetsLoaded: boolean;
96
96
  private updateFacetsDebouncer;
97
97
  private updateFacets;
98
98
  protected contentAvailableCallback(props: PropertyValues): void;
@@ -4,29 +4,29 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import { html, nothing } from "lit";
8
- import { property, query, state } from "lit/decorators.js";
7
+ import { html, nothing, } from "lit";
8
+ import { property, query, state, } from "lit/decorators.js";
9
9
  import { repeat } from "lit/directives/repeat.js";
10
- import { Debouncer, flatDeep, FtLitElement, isTouchScreen, jsonProperty, noTextInputDefaultClearButton, ParametrizedLabelResolver, screenReaderStyles, SearchPlaceConverter, waitFor } from "@fluid-topics/ft-wc-utils";
11
- import { FtSizeCategory, FtSizeWatcher } from "@fluid-topics/ft-size-watcher";
12
- import { FtTypography, FtTypographyBody2 } from "@fluid-topics/ft-typography";
13
- import { facetToFilter, selectedValues, unquote } from "./converters";
14
- import { FtFilter, FtFilterOption } from "@fluid-topics/ft-filter";
10
+ import { Debouncer, flatDeep, FtLitElement, isTouchScreen, jsonProperty, noTextInputDefaultClearButton, ParametrizedLabelResolver, screenReaderStyles, SearchPlaceConverter, waitFor, } from "@fluid-topics/ft-wc-utils";
11
+ import { FtSizeCategory, FtSizeWatcher, } from "@fluid-topics/ft-size-watcher";
12
+ import { FtTypography, FtTypographyBody2, } from "@fluid-topics/ft-typography";
13
+ import { facetToFilter, selectedValues, unquote, } from "./converters";
14
+ import { FtFilter, FtFilterOption, } from "@fluid-topics/ft-filter";
15
15
  import { FtIcon } from "@fluid-topics/ft-icon";
16
- import { FtAccordion, FtAccordionItem } from "@fluid-topics/ft-accordion";
16
+ import { FtAccordion, FtAccordionItem, } from "@fluid-topics/ft-accordion";
17
17
  import { FtButton } from "@fluid-topics/ft-button";
18
18
  import { FtChip } from "@fluid-topics/ft-chip";
19
- import { FtSelect, FtSelectOption } from "@fluid-topics/ft-select";
19
+ import { FtSelect, FtSelectOption, } from "@fluid-topics/ft-select";
20
20
  import { FtSnapScroll } from "@fluid-topics/ft-snap-scroll";
21
21
  import { FtTooltip } from "@fluid-topics/ft-tooltip";
22
22
  import { FtRipple } from "@fluid-topics/ft-ripple";
23
- import { facetsCss, searchBarCss } from "./ft-search-bar.styles";
23
+ import { facetsCss, searchBarCss, } from "./ft-search-bar.styles";
24
24
  import { FtSkeleton } from "@fluid-topics/ft-skeleton";
25
25
  import { SuggestManager } from "./managers/SuggestManager";
26
26
  import { FacetsChipsManager } from "./managers/FacetsChipsManager";
27
27
  import { MobileSearchBarManager } from "./managers/MobileSearchBarManager";
28
28
  import { DesktopSearchBarManager } from "./managers/DesktopSearchBarManager";
29
- import { FtRadio, FtRadioGroup } from "@fluid-topics/ft-radio";
29
+ import { FtRadio, FtRadioGroup, } from "@fluid-topics/ft-radio";
30
30
  import { ftAppInfoStore } from "@fluid-topics/ft-app-context";
31
31
  if (window.fluidtopics == null) {
32
32
  console.warn("Fluid Topics public API was not found. You can find it here: https://www.npmjs.com/package/@fluid-topics/public-api");
@@ -102,13 +102,7 @@ class FtSearchBar extends FtLitElement {
102
102
  this.availableContentLocalesInitialized = true;
103
103
  });
104
104
  });
105
- this.updateFacetsDebouncer.run(() => {
106
- this.retrieveFacetsFromSearch()
107
- .then(() => {
108
- this.facetsLoaded = true;
109
- this.facetsInitialized = true;
110
- });
111
- }, this.facetsInitialized ? 500 : 10);
105
+ this.updateFacets();
112
106
  };
113
107
  this.facetsLoaded = false;
114
108
  this.updateFacetsDebouncer = new Debouncer(500);
@@ -488,18 +482,18 @@ class FtSearchBar extends FtLitElement {
488
482
  this.stateChangeEventDebouncer.run(() => this.dispatchEvent(new SearchStateChangeEvent(this.request)));
489
483
  }
490
484
  updateFacets() {
491
- if (this.api) {
492
- if (this.facetsRequest.length > 0) {
493
- this.facetsLoaded = false;
494
- this.updateFacetsDebouncer.run(async () => {
495
- await this.retrieveFacetsFromSearch();
496
- this.facetsLoaded = true;
497
- this.facetsInitialized = true;
498
- }, this.facetsInitialized ? 500 : 10);
499
- }
500
- else {
501
- this.facets = [];
502
- }
485
+ if (this.facetsRequest.length > 0) {
486
+ this.facetsLoaded = false;
487
+ this.updateFacetsDebouncer.run(async () => {
488
+ await this.retrieveFacetsFromSearch();
489
+ this.facetsLoaded = true;
490
+ this.facetsInitialized = true;
491
+ }, this.facetsInitialized ? 500 : 10);
492
+ }
493
+ else {
494
+ this.facets = [];
495
+ this.facetsLoaded = true;
496
+ this.facetsInitialized = true;
503
497
  }
504
498
  }
505
499
  contentAvailableCallback(props) {
@@ -527,6 +521,11 @@ class FtSearchBar extends FtLitElement {
527
521
  }
528
522
  async retrieveFacetsFromSearch() {
529
523
  var _a;
524
+ // Safeguard if facetsRequest is modified during a Debouncer period
525
+ if (this.facetsRequest.length == 0) {
526
+ this.facets = [];
527
+ return;
528
+ }
530
529
  const retrievedFacets = new Map();
531
530
  await ((_a = this.api) === null || _a === void 0 ? void 0 : _a.search({ ...this.request, query: "" }).then((r) => r.facets.forEach((f) => {
532
531
  this.knownFacetLabels.set(f.key, f.label);