@fluid-topics/ft-search-context 2.2.17 → 2.2.19

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,8 +3,11 @@ import { FtSearchStateManager } from "./store/FtSearchStateManager";
3
3
  import { FtSearchStateResourceRequest } from "./store/model";
4
4
  export * from "./store/model";
5
5
  export { FtSearchStateManager } from "./store/FtSearchStateManager";
6
- export declare class RegisterSearchComponentEvent extends Event {
7
- constructor();
6
+ export interface RegisterSearchComponentEventDetail {
7
+ registrationId?: string;
8
+ }
9
+ export declare class RegisterSearchComponentEvent extends CustomEvent<RegisterSearchComponentEventDetail> {
10
+ constructor(searchRegistrationId?: string);
8
11
  }
9
12
  export interface FtSearchComponentInterface {
10
13
  stateManager?: FtSearchStateManager;
@@ -5,12 +5,16 @@ 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 { applyMixinOnce, FtLitElementRedux, hasChanged, } from "@fluid-topics/ft-wc-utils";
8
- import { state } from "lit/decorators.js";
8
+ import { property, state, } from "lit/decorators.js";
9
9
  export * from "./store/model";
10
10
  export { FtSearchStateManager } from "./store/FtSearchStateManager";
11
- export class RegisterSearchComponentEvent extends Event {
12
- constructor() {
13
- super("register-ft-search-component", { bubbles: true, composed: true });
11
+ export class RegisterSearchComponentEvent extends CustomEvent {
12
+ constructor(searchRegistrationId) {
13
+ super("register-ft-search-component", {
14
+ bubbles: true, composed: true, detail: {
15
+ registrationId: searchRegistrationId,
16
+ },
17
+ });
14
18
  }
15
19
  }
16
20
  const registerInterval = Symbol("registerInterval");
@@ -23,11 +27,12 @@ export const toFtSearchComponent = applyMixinOnce(Symbol("toFtSearchComponent"),
23
27
  this.neededSearchRequests = [];
24
28
  }
25
29
  willUpdate(props) {
26
- var _a, _b, _c;
30
+ var _a, _b;
31
+ var _c;
27
32
  super.willUpdate(props);
28
33
  if (props.has("neededSearchRequests")) {
29
- (_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.unregisterComponent(this, (_b = props.get("neededSearchRequests")) !== null && _b !== void 0 ? _b : []);
30
- (_c = this.stateManager) === null || _c === void 0 ? void 0 : _c.registerComponent(this, this.neededSearchRequests);
34
+ (_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.unregisterComponent(this, (_c = props.get("neededSearchRequests")) !== null && _c !== void 0 ? _c : []);
35
+ (_b = this.stateManager) === null || _b === void 0 ? void 0 : _b.registerComponent(this, this.neededSearchRequests);
31
36
  }
32
37
  }
33
38
  setSearchStateManager(stateManager) {
@@ -55,7 +60,7 @@ export const toFtSearchComponent = applyMixinOnce(Symbol("toFtSearchComponent"),
55
60
  }
56
61
  else {
57
62
  this[registerAttempts]++;
58
- this.dispatchEvent(new RegisterSearchComponentEvent());
63
+ this.dispatchEvent(new RegisterSearchComponentEvent(this.searchRegistrationId));
59
64
  }
60
65
  }
61
66
  disconnectedCallback() {
@@ -69,6 +74,9 @@ export const toFtSearchComponent = applyMixinOnce(Symbol("toFtSearchComponent"),
69
74
  __decorate([
70
75
  state({ hasChanged })
71
76
  ], FtSearchComponentClass.prototype, "neededSearchRequests", void 0);
77
+ __decorate([
78
+ property()
79
+ ], FtSearchComponentClass.prototype, "searchRegistrationId", void 0);
72
80
  return FtSearchComponentClass;
73
81
  });
74
82
  export class FtSearchComponent extends toFtSearchComponent(FtLitElementRedux) {
@@ -46,6 +46,7 @@ export declare class FtSearchStateManager extends FtStateManager {
46
46
  replaceFacet(oldId: string, newId?: string): void;
47
47
  private get facetIds();
48
48
  private set facetIds(value);
49
+ addPropagatedFacet(facetId: string): void;
49
50
  /** @deprecated */
50
51
  setFilter(key: string, values: string[]): void;
51
52
  setValueFilter(key: string, values: string[]): void;
@@ -58,16 +58,17 @@ export class FtSearchStateManager extends FtStateManager {
58
58
  return this.suggestDebouncer.run(() => this.fetchSuggestData(request !== null && request !== void 0 ? request : this.buildSuggestRequest()));
59
59
  };
60
60
  this.buildSuggestRequest = (searchState = this.store.getState()) => {
61
- var _a, _b;
61
+ var _a;
62
+ var _b;
62
63
  return {
63
64
  input: searchState.liveQuery,
64
65
  metadataFilters: searchState.request.metadataFilters,
65
- sort: (_a = searchState.request.sort) !== null && _a !== void 0 ? _a : [],
66
+ sort: (_b = searchState.request.sort) !== null && _b !== void 0 ? _b : [],
66
67
  sortId: searchState.request.sortId,
67
68
  contentLocale: searchState.request.contentLocale,
68
69
  scope: searchState.request.scope,
69
70
  keywordMatch: searchState.request.keywordMatch,
70
- stickyFiltersId: this.applyStickyFilters ? (_b = ftAppInfoStore.getState().stickyFilters) === null || _b === void 0 ? void 0 : _b.id : undefined,
71
+ stickyFiltersId: this.applyStickyFilters ? (_a = ftAppInfoStore.getState().stickyFilters) === null || _a === void 0 ? void 0 : _a.id : undefined,
71
72
  };
72
73
  };
73
74
  this.service = service !== null && service !== void 0 ? service : new FtSearchService();
@@ -130,8 +131,9 @@ export class FtSearchStateManager extends FtStateManager {
130
131
  this.setLiveQuery(query);
131
132
  }
132
133
  setContentLocale(contentLocale) {
133
- var _a, _b;
134
- const locales = (_a = this.store.getState().locales) !== null && _a !== void 0 ? _a : [];
134
+ var _a;
135
+ var _b;
136
+ const locales = (_b = this.store.getState().locales) !== null && _b !== void 0 ? _b : [];
135
137
  const previousContentLocale = this.store.getState().request.contentLocale;
136
138
  if (contentLocale != previousContentLocale) {
137
139
  if (locales.length > 0) {
@@ -141,7 +143,7 @@ export class FtSearchStateManager extends FtStateManager {
141
143
  }
142
144
  }
143
145
  this.updateSearchRequest({ contentLocale, metadataFilters: [] }, true);
144
- if (this.canUpdateUiLocale && ((_b = ftAppStateManager.store.getState().localesConfiguration) === null || _b === void 0 ? void 0 : _b.searchLanguageSetsUiLanguage) && contentLocale) {
146
+ if (this.canUpdateUiLocale && ((_a = ftAppStateManager.store.getState().localesConfiguration) === null || _a === void 0 ? void 0 : _a.searchLanguageSetsUiLanguage) && contentLocale) {
145
147
  ftAppStateManager.requestUiLocaleUpdate(contentLocale, contentLocale);
146
148
  }
147
149
  }
@@ -169,7 +171,8 @@ export class FtSearchStateManager extends FtStateManager {
169
171
  });
170
172
  }
171
173
  get sortOptions() {
172
- var _a, _b;
174
+ var _a;
175
+ var _b;
173
176
  return (_b = (_a = this.store.getState().configuration) === null || _a === void 0 ? void 0 : _a.sortOptions) !== null && _b !== void 0 ? _b : [];
174
177
  }
175
178
  setSort(sort) {
@@ -243,6 +246,11 @@ export class FtSearchStateManager extends FtStateManager {
243
246
  const facets = uniqIds.map((id) => ({ id: id }));
244
247
  this.updateSearchRequest({ facets });
245
248
  }
249
+ addPropagatedFacet(facetId) {
250
+ const propagatedFacets = new Set(this.store.getState().propagatedFacets);
251
+ propagatedFacets.add(facetId);
252
+ this.store.actions.propagatedFacets([...propagatedFacets]);
253
+ }
246
254
  /** @deprecated */
247
255
  setFilter(key, values) {
248
256
  this.setValueFilter(key, values);
@@ -350,7 +358,8 @@ export class FtSearchStateManager extends FtStateManager {
350
358
  return this.localesDebouncer.run(async () => this.store.actions.locales((await this.service.getAvailableSearchLocales()).contentLocales));
351
359
  }
352
360
  async fetchSearchData(request) {
353
- var _a, _b, _c, _d, _e;
361
+ var _a, _b, _c;
362
+ var _d, _e;
354
363
  (_a = this.cancelableSearch) === null || _a === void 0 ? void 0 : _a.cancel();
355
364
  if (!this.isRequestNeeded(FtSearchStateResourceRequest.CLUSTERED_SEARCH)) {
356
365
  return;
@@ -380,11 +389,11 @@ export class FtSearchStateManager extends FtStateManager {
380
389
  this.store.actions.spellcheck(results.spellcheck);
381
390
  }
382
391
  else {
383
- const newResults = ((_c = this.store.getState().results) !== null && _c !== void 0 ? _c : []).concat(results.results);
392
+ const newResults = ((_d = this.store.getState().results) !== null && _d !== void 0 ? _d : []).concat(results.results);
384
393
  this.store.actions.results(newResults);
385
394
  // Focus on first new result
386
395
  this.store.commands.clear(/^focus-result-/);
387
- this.store.commands.add({ type: `focus-result-${(results.paging.currentPage - 1) * ((_d = request.paging.perPage) !== null && _d !== void 0 ? _d : 20) + 1}` });
396
+ this.store.commands.add({ type: `focus-result-${(results.paging.currentPage - 1) * ((_e = request.paging.perPage) !== null && _e !== void 0 ? _e : 20) + 1}` });
388
397
  }
389
398
  this.store.actions.paging(results.paging);
390
399
  }
@@ -392,7 +401,7 @@ export class FtSearchStateManager extends FtStateManager {
392
401
  catch (e) {
393
402
  if (!(e instanceof CanceledPromiseError)) {
394
403
  console.error(e);
395
- (_e = this.errorHandler) === null || _e === void 0 ? void 0 : _e.call(this, e);
404
+ (_c = this.errorHandler) === null || _c === void 0 ? void 0 : _c.call(this, e);
396
405
  }
397
406
  }
398
407
  }
@@ -7,6 +7,7 @@ export interface FtSearchPageState {
7
7
  results: Array<FtSearchResultCluster> | undefined;
8
8
  announcements: Array<FtSearchResultAnnouncement> | undefined;
9
9
  facets: Array<FtSearchFacet> | undefined;
10
+ propagatedFacets: Array<string>;
10
11
  paging: FtSearchResultsPageInfo | undefined;
11
12
  spellcheck: FtSpellcheck | undefined;
12
13
  liveQuery: string;
@@ -30,6 +30,7 @@ export const createSearchPageStore = (id) => FtReduxStore.get({
30
30
  announcements: undefined,
31
31
  suggestResults: undefined,
32
32
  configuration: undefined,
33
+ propagatedFacets: [],
33
34
  },
34
35
  reducers: searchPageStateReducers,
35
36
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-search-context",
3
- "version": "2.2.17",
3
+ "version": "2.2.19",
4
4
  "description": "Context block for integrated search components",
5
5
  "keywords": [
6
6
  "Lit"
@@ -19,12 +19,12 @@
19
19
  "url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
20
20
  },
21
21
  "dependencies": {
22
- "@fluid-topics/ft-app-context": "2.2.17",
23
- "@fluid-topics/ft-wc-utils": "2.2.17",
22
+ "@fluid-topics/ft-app-context": "2.2.19",
23
+ "@fluid-topics/ft-wc-utils": "2.2.19",
24
24
  "lit": "3.3.3"
25
25
  },
26
26
  "devDependencies": {
27
- "@fluid-topics/public-api": "1.0.142"
27
+ "@fluid-topics/public-api": "1.0.143"
28
28
  },
29
- "gitHead": "36907c574a4cfc29bc07e86865cdb5b7e19d3d03"
29
+ "gitHead": "1ae520afe5e3697dee3c95ba254b53a8f7850594"
30
30
  }