@fluid-topics/ft-search-type 1.1.105 → 1.1.106

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.
@@ -8,7 +8,8 @@ export declare class FtSearchType extends FtSearchType_base implements FtSearchT
8
8
  private searchInDocumentTitlesOnly?;
9
9
  private filter?;
10
10
  constructor();
11
+ private readonly options;
11
12
  protected render(): import("lit").TemplateResult<1>;
12
- private onSelected;
13
+ private onSelectionChange;
13
14
  }
14
15
  export {};
@@ -16,29 +16,34 @@ import { searchInDocumentTitlesOnlySelector } from "@fluid-topics/ft-search-cont
16
16
  class FtSearchType extends withI18n(FtSearchComponent) {
17
17
  constructor() {
18
18
  super();
19
+ this.options = {
20
+ "searchInDocumentTitlesOnly": {
21
+ label: () => searchTypeContext.messages.documentTitlesOnly(),
22
+ selected: () => !!this.searchInDocumentTitlesOnly,
23
+ onChange: (selected) => { var _a; return (_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.setSearchInDocumentTitlesOnly(selected); }
24
+ }
25
+ };
19
26
  this.addI18nContext(searchTypeContext, searchTypeDefaultMessages);
20
27
  }
21
28
  render() {
22
29
  return html `
23
30
  <ft-filter
24
31
  label=${searchTypeContext.messages.label()}
25
- .options=${[
26
- {
27
- label: searchTypeContext.messages.documentTitlesOnly(),
28
- value: (selected) => { var _a; return (_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.setSearchInDocumentTitlesOnly(selected); },
29
- selected: this.searchInDocumentTitlesOnly
30
- }
31
- ]}
32
+ .options=${Object.keys(this.options).map(value => ({
33
+ value,
34
+ label: this.options[value].label(),
35
+ selected: this.options[value].selected(),
36
+ }))}
32
37
  part="filter"
33
38
  .exportpartsPrefixes=${["filter"]}
34
39
  multivalued
35
- @change=${this.onSelected}
40
+ @change=${() => this.onSelectionChange()}
36
41
  ></ft-filter>
37
42
  `;
38
43
  }
39
- onSelected(event) {
44
+ onSelectionChange() {
40
45
  var _a;
41
- (_a = this.filter) === null || _a === void 0 ? void 0 : _a.options.forEach(o => o.value(o.selected));
46
+ (_a = this.filter) === null || _a === void 0 ? void 0 : _a.options.forEach(o => this.options[o.value].onChange(!!o.selected));
42
47
  }
43
48
  }
44
49
  FtSearchType.elementDefinitions = {