@fluid-topics/ft-search-type 1.3.44 → 1.3.45

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.
@@ -2,6 +2,7 @@ import { DefaultI18nMessages, I18nMessageContext, I18nMessages } from "@fluid-to
2
2
  export interface SearchTypeMessages extends I18nMessages {
3
3
  label(): string;
4
4
  documentTitlesOnly(): string;
5
+ matchAllKeywords(): string;
5
6
  }
6
7
  export declare const searchTypeContext: I18nMessageContext<SearchTypeMessages>;
7
8
  export declare const searchTypeDefaultMessages: DefaultI18nMessages<SearchTypeMessages>;
@@ -3,4 +3,5 @@ export const searchTypeContext = I18nMessageContext.build("designedSearchType");
3
3
  export const searchTypeDefaultMessages = {
4
4
  label: "Search scope",
5
5
  documentTitlesOnly: "Search in document titles only",
6
+ matchAllKeywords: "Match all search terms",
6
7
  };
@@ -1,12 +1,16 @@
1
1
  import { ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
2
2
  import { FtSearchTypeProperties } from "./ft-search-type.properties";
3
+ import { FtFilter } from "@fluid-topics/ft-filter";
3
4
  import { FtSearchComponent } from "@fluid-topics/ft-search-context/build/registration";
4
5
  declare const FtSearchType_base: typeof FtSearchComponent & import("@fluid-topics/ft-wc-utils").Constructor<import("@fluid-topics/ft-i18n").FtLitElementWithI18nInterface>;
5
6
  export declare class FtSearchType extends FtSearchType_base implements FtSearchTypeProperties {
6
7
  static elementDefinitions: ElementDefinitionsMap;
7
8
  static styles: import("lit").CSSResult;
8
- private searchInDocumentTitlesOnly?;
9
- private filter?;
9
+ searchInDocumentTitlesOnly?: boolean;
10
+ hideSearchInDocumentTitlesOnly?: boolean;
11
+ matchAllKeywords?: boolean;
12
+ displayMatchAllKeywords?: boolean;
13
+ filter?: FtFilter;
10
14
  constructor();
11
15
  private readonly options;
12
16
  protected render(): import("lit-html").TemplateResult<1>;
@@ -11,8 +11,9 @@ import { FtFilter } from "@fluid-topics/ft-filter";
11
11
  import { withI18n } from "@fluid-topics/ft-i18n";
12
12
  import { FtSearchComponent } from "@fluid-topics/ft-search-context/build/registration";
13
13
  import { searchTypeContext, searchTypeDefaultMessages } from "./FtSearchTypeMessages";
14
- import { query } from "lit/decorators.js";
15
- import { searchInDocumentTitlesOnlySelector } from "@fluid-topics/ft-search-context";
14
+ import { property, query } from "lit/decorators.js";
15
+ import { keywordMatchSelector, searchInDocumentTitlesOnlySelector } from "@fluid-topics/ft-search-context";
16
+ import { FtSearchKeywordMatch } from "@fluid-topics/public-api";
16
17
  class FtSearchType extends withI18n(FtSearchComponent) {
17
18
  constructor() {
18
19
  super();
@@ -20,20 +21,28 @@ class FtSearchType extends withI18n(FtSearchComponent) {
20
21
  "searchInDocumentTitlesOnly": {
21
22
  label: () => searchTypeContext.messages.documentTitlesOnly(),
22
23
  selected: () => !!this.searchInDocumentTitlesOnly,
23
- onChange: (selected) => { var _a; return (_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.setSearchInDocumentTitlesOnly(selected); }
24
- }
24
+ onChange: (selected) => { var _a; return (_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.setSearchInDocumentTitlesOnly(selected); },
25
+ display: () => !this.hideSearchInDocumentTitlesOnly,
26
+ },
27
+ "matchAllKeywords": {
28
+ label: () => searchTypeContext.messages.matchAllKeywords(),
29
+ selected: () => !!this.matchAllKeywords,
30
+ onChange: (selected) => { var _a; return (_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.setKeywordMatch(selected ? FtSearchKeywordMatch.MANDATORY : FtSearchKeywordMatch.OPTIONAL); },
31
+ display: () => !!this.displayMatchAllKeywords,
32
+ },
25
33
  };
26
34
  this.addI18nContext(searchTypeContext, searchTypeDefaultMessages);
27
35
  }
28
36
  render() {
29
- return html `
30
- <ft-filter
31
- label=${searchTypeContext.messages.label()}
32
- .options=${Object.keys(this.options).map(value => ({
37
+ const options = Object.keys(this.options).filter((option) => this.options[option].display()).map((value) => ({
33
38
  value,
34
39
  label: this.options[value].label(),
35
40
  selected: this.options[value].selected(),
36
- }))}
41
+ }));
42
+ return html `
43
+ <ft-filter
44
+ label="${searchTypeContext.messages.label()}"
45
+ .options=${options}
37
46
  part="filter"
38
47
  .exportpartsPrefixes=${["filter"]}
39
48
  multivalued
@@ -43,7 +52,7 @@ class FtSearchType extends withI18n(FtSearchComponent) {
43
52
  }
44
53
  onSelectionChange() {
45
54
  var _a;
46
- (_a = this.filter) === null || _a === void 0 ? void 0 : _a.options.forEach(o => this.options[o.value].onChange(!!o.selected));
55
+ (_a = this.filter) === null || _a === void 0 ? void 0 : _a.options.forEach((o) => this.options[o.value].onChange(!!o.selected));
47
56
  }
48
57
  }
49
58
  FtSearchType.elementDefinitions = {
@@ -53,6 +62,15 @@ FtSearchType.styles = styles;
53
62
  __decorate([
54
63
  redux({ selector: searchInDocumentTitlesOnlySelector })
55
64
  ], FtSearchType.prototype, "searchInDocumentTitlesOnly", void 0);
65
+ __decorate([
66
+ property({ type: Boolean })
67
+ ], FtSearchType.prototype, "hideSearchInDocumentTitlesOnly", void 0);
68
+ __decorate([
69
+ redux({ selector: keywordMatchSelector })
70
+ ], FtSearchType.prototype, "matchAllKeywords", void 0);
71
+ __decorate([
72
+ property({ type: Boolean })
73
+ ], FtSearchType.prototype, "displayMatchAllKeywords", void 0);
56
74
  __decorate([
57
75
  query("ft-filter")
58
76
  ], FtSearchType.prototype, "filter", void 0);