@fluid-topics/ft-search-context 1.3.53 → 1.3.55

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,14 +1,16 @@
1
1
  import { Constructor, FtLitElementRedux } from "@fluid-topics/ft-wc-utils";
2
2
  import { FtSearchStateManager } from "./store/FtSearchStateManager";
3
+ import { FtSearchStateResourceRequest } from "./store/model";
3
4
  export * from "./store/model";
4
5
  export { FtSearchStateManager } from "./store/FtSearchStateManager";
5
6
  export declare class RegisterSearchComponentEvent extends Event {
6
7
  constructor();
7
8
  }
8
- export type FtSearchComponentInterface = {
9
+ export interface FtSearchComponentInterface {
9
10
  stateManager?: FtSearchStateManager;
11
+ neededSearchRequests: FtSearchStateResourceRequest[];
10
12
  setSearchStateManager(stateManager: FtSearchStateManager): void;
11
- };
13
+ }
12
14
  export type FtSearchComponentType<T extends Constructor<FtLitElementRedux>> = T & Constructor<FtSearchComponentInterface>;
13
15
  export declare const toFtSearchComponent: <T extends Constructor<FtLitElementRedux>>(c: T) => FtSearchComponentType<T>;
14
16
  declare const FtSearchComponent_base: FtSearchComponentType<typeof FtLitElementRedux>;
@@ -4,7 +4,7 @@ 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 { applyMixinOnce, FtLitElementRedux } from "@fluid-topics/ft-wc-utils";
7
+ import { applyMixinOnce, FtLitElementRedux, hasChanged } from "@fluid-topics/ft-wc-utils";
8
8
  import { state } from "lit/decorators.js";
9
9
  export * from "./store/model";
10
10
  export { FtSearchStateManager } from "./store/FtSearchStateManager";
@@ -18,13 +18,27 @@ const registerAttempts = Symbol("registerAttempts");
18
18
  const MAX_REGISTER_ATTEMPTS = 40;
19
19
  export const toFtSearchComponent = applyMixinOnce(Symbol("toFtSearchComponent"), function (ReduxClass) {
20
20
  class FtSearchComponentClass extends ReduxClass {
21
+ constructor() {
22
+ super(...arguments);
23
+ this.neededSearchRequests = [];
24
+ }
25
+ willUpdate(props) {
26
+ var _a, _b, _c;
27
+ super.willUpdate(props);
28
+ 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);
31
+ }
32
+ }
21
33
  setSearchStateManager(stateManager) {
22
34
  this.clearStateManager();
23
35
  this.stateManager = stateManager;
36
+ this.stateManager.registerComponent(this, this.neededSearchRequests);
24
37
  this.addStore(stateManager.store, "search");
25
38
  }
26
39
  clearStateManager() {
27
40
  if (this.stateManager) {
41
+ this.stateManager.unregisterComponent(this, this.neededSearchRequests);
28
42
  this.removeStore(this.stateManager.store);
29
43
  this.stateManager = undefined;
30
44
  }
@@ -32,6 +46,7 @@ export const toFtSearchComponent = applyMixinOnce(Symbol("toFtSearchComponent"),
32
46
  connectedCallback() {
33
47
  super.connectedCallback();
34
48
  this[registerAttempts] = 0;
49
+ this.tryToRegisterToContext();
35
50
  this[registerInterval] = window.setInterval(() => this.tryToRegisterToContext(), 50);
36
51
  }
37
52
  tryToRegisterToContext() {
@@ -51,6 +66,9 @@ export const toFtSearchComponent = applyMixinOnce(Symbol("toFtSearchComponent"),
51
66
  __decorate([
52
67
  state()
53
68
  ], FtSearchComponentClass.prototype, "stateManager", void 0);
69
+ __decorate([
70
+ state({ hasChanged })
71
+ ], FtSearchComponentClass.prototype, "neededSearchRequests", void 0);
54
72
  return FtSearchComponentClass;
55
73
  });
56
74
  export class FtSearchComponent extends toFtSearchComponent(FtLitElementRedux) {
@@ -1,5 +1,5 @@
1
1
  import { FtSearchPageState } from "./model";
2
- import { FtReduxStore, ReduxWatcher } from "@fluid-topics/ft-wc-utils";
2
+ import { FtReduxStore, FtStateManager, ReduxWatcher } from "@fluid-topics/ft-wc-utils";
3
3
  import { FtSearchPageStateReducers } from "./redux";
4
4
  import { FtDateFilterTypeKeys, FtMetadataFilter, FtPublicClusterSortCriterion, FtSearchKeywordMatch, FtSearchRequest, FtSearchScope, FtSearchSortCriterion, FtSuggestRequest, FtVirtualField } from "@fluid-topics/public-api";
5
5
  import { FtSearchService } from "./utils/FtSearchService";
@@ -9,7 +9,7 @@ export declare class ClearAllFiltersEvent extends Event {
9
9
  static eventName: string;
10
10
  constructor();
11
11
  }
12
- export declare class FtSearchStateManager {
12
+ export declare class FtSearchStateManager extends FtStateManager {
13
13
  readonly store: FtReduxStore<FtSearchPageState, FtSearchPageStateReducers>;
14
14
  static build(id: string, service?: FtSearchService): FtSearchStateManager;
15
15
  readonly service: FtSearchService;
@@ -1,4 +1,5 @@
1
- import { cancelable, CanceledPromiseError, Debouncer, watch } from "@fluid-topics/ft-wc-utils";
1
+ import { FtSearchStateResourceRequest } from "./model";
2
+ import { cancelable, CanceledPromiseError, Debouncer, FtStateManager, watch } from "@fluid-topics/ft-wc-utils";
2
3
  import { createSearchPageStore } from "./redux";
3
4
  import { FtSearchKeywordMatch, FtSearchScope, FtVirtualField } from "@fluid-topics/public-api";
4
5
  import { FtSearchService } from "./utils/FtSearchService";
@@ -12,11 +13,12 @@ class ClearAllFiltersEvent extends Event {
12
13
  }
13
14
  ClearAllFiltersEvent.eventName = "search-context-clear-all-filters";
14
15
  export { ClearAllFiltersEvent };
15
- export class FtSearchStateManager {
16
+ export class FtSearchStateManager extends FtStateManager {
16
17
  static build(id, service) {
17
18
  return new FtSearchStateManager(createSearchPageStore(id.trim() || "context"), service);
18
19
  }
19
20
  constructor(store, service) {
21
+ super();
20
22
  this.store = store;
21
23
  this.ignoreEmptyQuery = false;
22
24
  this.openExternalDocumentInNewTab = false;
@@ -269,8 +271,11 @@ export class FtSearchStateManager {
269
271
  }
270
272
  async fetchSearchData(request) {
271
273
  var _a, _b, _c, _d;
274
+ (_a = this.cancelableSearch) === null || _a === void 0 ? void 0 : _a.cancel();
275
+ if (!this.isRequestNeeded(FtSearchStateResourceRequest.CLUSTERED_SEARCH)) {
276
+ return;
277
+ }
272
278
  try {
273
- (_a = this.cancelableSearch) === null || _a === void 0 ? void 0 : _a.cancel();
274
279
  this.store.actions.paging(undefined);
275
280
  if (this.ignoreEmptyQuery && request.query.length == 0) {
276
281
  this.store.actions.results(undefined);
@@ -17,3 +17,6 @@ export interface FtSearchResultsChangeEventDetail {
17
17
  paging: FtSearchResultsPageInfo;
18
18
  spellcheck?: FtSpellcheck;
19
19
  }
20
+ export declare enum FtSearchStateResourceRequest {
21
+ CLUSTERED_SEARCH = "CLUSTERED_SEARCH"
22
+ }
@@ -1 +1,4 @@
1
- export {};
1
+ export var FtSearchStateResourceRequest;
2
+ (function (FtSearchStateResourceRequest) {
3
+ FtSearchStateResourceRequest["CLUSTERED_SEARCH"] = "CLUSTERED_SEARCH";
4
+ })(FtSearchStateResourceRequest || (FtSearchStateResourceRequest = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-search-context",
3
- "version": "1.3.53",
3
+ "version": "1.3.55",
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": "1.3.53",
23
- "@fluid-topics/ft-wc-utils": "1.3.53",
22
+ "@fluid-topics/ft-app-context": "1.3.55",
23
+ "@fluid-topics/ft-wc-utils": "1.3.55",
24
24
  "lit": "3.1.0"
25
25
  },
26
26
  "devDependencies": {
27
- "@fluid-topics/public-api": "1.0.112"
27
+ "@fluid-topics/public-api": "1.0.113"
28
28
  },
29
- "gitHead": "1eb4ee8a448ded2e0d54517a08200d0109c0722e"
29
+ "gitHead": "4b1a60c10c8b8d68e0b9075038c0508a94ff7d38"
30
30
  }