@fluid-topics/ft-search-bar 0.2.4 → 0.2.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.
@@ -44,7 +44,11 @@ export const DEFAULT_LABELS = {
44
44
  export { FtSearchBarCssVariables } from "./ft-search-bar.css";
45
45
  export class LaunchSearchEvent extends CustomEvent {
46
46
  constructor(request) {
47
- super("launch-search", { detail: request });
47
+ super("launch-search", {
48
+ detail: request,
49
+ bubbles: true,
50
+ composed: true
51
+ });
48
52
  }
49
53
  }
50
54
  export class SearchStateChangeEvent extends CustomEvent {
@@ -63,6 +67,7 @@ export class FtSearchBar extends FtLitElement {
63
67
  this.labelResolver = new ParametrizedLabelResolver(DEFAULT_LABELS, {});
64
68
  this.displayedFilters = [];
65
69
  this.presets = [];
70
+ this.priors = [];
66
71
  this.searchRequestSerializer = (request) => serializeRequest(this.baseUrl, request);
67
72
  this.searchFilters = [];
68
73
  this.sizeCategory = FtSizeCategory.S;
@@ -99,6 +104,7 @@ export class FtSearchBar extends FtLitElement {
99
104
  contentLocale: this.contentLocale,
100
105
  query: this.query,
101
106
  facets: this.facetsRequest,
107
+ priors: this.hasPriors ? this.priors : undefined,
102
108
  filters: this.searchFilters,
103
109
  paging: { perPage: 0, page: 1 },
104
110
  sort: [],
@@ -113,7 +119,7 @@ export class FtSearchBar extends FtLitElement {
113
119
  contentLocale: this.contentLocale,
114
120
  input: this.query,
115
121
  filters: this.searchFilters,
116
- sort: [],
122
+ sort: []
117
123
  };
118
124
  }
119
125
  get isMobile() {
@@ -123,7 +129,10 @@ export class FtSearchBar extends FtLitElement {
123
129
  return this.facetsRequest.length > 0;
124
130
  }
125
131
  get hasPresets() {
126
- return this.presets.length > 0;
132
+ return this.presets != null && this.presets.length > 0;
133
+ }
134
+ get hasPriors() {
135
+ return this.priors != null && this.priors.length > 0;
127
136
  }
128
137
  get hasLocaleSelector() {
129
138
  return this.availableContentLocales.length > 1;
@@ -370,6 +379,7 @@ export class FtSearchBar extends FtLitElement {
370
379
  `;
371
380
  }
372
381
  renderFacetsActions() {
382
+ var _a;
373
383
  return html `
374
384
  <div class="ft-search-bar--facets-actions">
375
385
  ${this.hasPresets ? html `
@@ -379,7 +389,7 @@ export class FtSearchBar extends FtLitElement {
379
389
  label="${this.labelResolver.resolve("presetsSelector")}"
380
390
  outlined
381
391
  @change=${(e) => this.selectedPreset = e.detail}>
382
- ${repeat(this.presets, p => p.name, p => html `
392
+ ${repeat((_a = this.presets) !== null && _a !== void 0 ? _a : [], p => p.name, p => html `
383
393
  <ft-select-option value="${p.name}"
384
394
  label="${p.name}"
385
395
  ?selected=${p.name === this.selectedPreset}>
@@ -580,7 +590,7 @@ export class FtSearchBar extends FtLitElement {
580
590
  this.availableContentLocales = (_b = await ((_a = this.api) === null || _a === void 0 ? void 0 : _a.getAvailableSearchLocales().then(result => result.contentLocales).catch(() => []))) !== null && _b !== void 0 ? _b : [];
581
591
  }
582
592
  update(props) {
583
- var _a, _b, _c;
593
+ var _a, _b, _c, _d, _e;
584
594
  if (props.has("labels")) {
585
595
  this.labelResolver = new ParametrizedLabelResolver(DEFAULT_LABELS, this.labels);
586
596
  }
@@ -602,13 +612,13 @@ export class FtSearchBar extends FtLitElement {
602
612
  this.recentSearches = JSON.parse((_b = window.localStorage.getItem(this.recentSearchesStorageKey)) !== null && _b !== void 0 ? _b : "[]");
603
613
  }
604
614
  if (props.has("selectedPreset")) {
605
- const currentPreset = this.presets.find(p => p.name === this.selectedPreset);
615
+ const currentPreset = ((_c = this.presets) !== null && _c !== void 0 ? _c : []).find(p => p.name === this.selectedPreset);
606
616
  if (currentPreset && !this.compareRequests(this.request, currentPreset)) {
607
617
  this.setFiltersFromPreset(currentPreset);
608
618
  }
609
619
  }
610
620
  if (["contentLocale", "searchFilters"].some(p => props.has(p))) {
611
- this.selectedPreset = (_c = this.presets.find(p => this.compareRequests(p, this.request))) === null || _c === void 0 ? void 0 : _c.name;
621
+ this.selectedPreset = (_e = ((_d = this.presets) !== null && _d !== void 0 ? _d : []).find(p => this.compareRequests(p, this.request))) === null || _e === void 0 ? void 0 : _e.name;
612
622
  }
613
623
  if (["baseUrl", "apiIntegrationIdentifier"].some(p => props.has(p))) {
614
624
  this.setApi();
@@ -861,6 +871,9 @@ __decorate([
861
871
  __decorate([
862
872
  property({ type: String, reflect: true })
863
873
  ], FtSearchBar.prototype, "selectedPreset", void 0);
874
+ __decorate([
875
+ jsonProperty([])
876
+ ], FtSearchBar.prototype, "priors", void 0);
864
877
  __decorate([
865
878
  property()
866
879
  ], FtSearchBar.prototype, "searchRequestSerializer", void 0);