@fluid-topics/ft-search-bar 1.2.1 → 1.2.3

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.
@@ -106,11 +106,12 @@ class DesktopSearchBarManager {
106
106
  <div class="ft-search-bar--separator"></div>
107
107
  ` : null}
108
108
  <ft-button class="ft-search-bar--launch-search"
109
+ href="${this.searchBar.searchRequestSerializer(this.searchBar.request)}"
109
110
  part="launch-search-in-bar"
110
111
  icon="search"
111
112
  round dense
112
113
  label="${this.searchBar.labelResolver.resolve("searchButton")}"
113
- @click=${() => this.searchBar.launchSearch()}
114
+ @click=${() => this.searchBar.onLaunchSearch()}
114
115
  ></ft-button>
115
116
  </div>
116
117
  `;
@@ -130,8 +131,9 @@ class DesktopSearchBarManager {
130
131
  }
131
132
  }
132
133
  onSearchBarKeyUp(e) {
134
+ var _a;
133
135
  if (e.key === "Enter") {
134
- this.searchBar.launchSearch();
136
+ (_a = this.searchBar.launchSearchButton) === null || _a === void 0 ? void 0 : _a.click();
135
137
  }
136
138
  }
137
139
  onInput(e) {
@@ -41,9 +41,10 @@ class MobileSearchBarManager {
41
41
  ${this.searchBar.displayFacets ? this.searchBar.renderMobileFacets() : this.suggestManager.render()}
42
42
  ${this.searchBar.isMobileMenuOpen() || this.searchBar.displayFacets ? html `
43
43
  <ft-button class="ft-search-bar--launch-search"
44
+ href="${this.searchBar.searchRequestSerializer(this.searchBar.request)}"
44
45
  part="launch-search-in-panel"
45
46
  icon="search"
46
- @click=${this.searchBar.launchSearch}>
47
+ @click=${() => this.searchBar.onLaunchSearch()}>
47
48
  ${this.searchBar.labelResolver.resolve("searchButton")}
48
49
  </ft-button>
49
50
  ` : nothing}
@@ -71,6 +72,9 @@ class MobileSearchBarManager {
71
72
  <div class="ft-search-bar--separator"></div>
72
73
  ` : nothing}
73
74
  <ft-button class="ft-search-bar--launch-search"
75
+ href="${this.searchBar.isMobileMenuOpen()
76
+ ? this.searchBar.searchRequestSerializer(this.searchBar.request)
77
+ : ""}"
74
78
  part="launch-search-in-bar"
75
79
  icon="search"
76
80
  round
@@ -79,7 +83,7 @@ class MobileSearchBarManager {
79
83
  @click=${() => {
80
84
  var _a;
81
85
  return this.searchBar.isMobileMenuOpen()
82
- ? this.searchBar.launchSearch()
86
+ ? this.searchBar.onLaunchSearch()
83
87
  : (_a = this.searchBar.input) === null || _a === void 0 ? void 0 : _a.focus();
84
88
  }}
85
89
  ></ft-button>
@@ -87,8 +91,9 @@ class MobileSearchBarManager {
87
91
  `;
88
92
  }
89
93
  onSearchBarKeyUp(e) {
94
+ var _a;
90
95
  if (e.key === "Enter") {
91
- this.searchBar.launchSearch();
96
+ (_a = this.searchBar.launchSearchButton) === null || _a === void 0 ? void 0 : _a.click();
92
97
  }
93
98
  }
94
99
  onInput(e) {
@@ -5,13 +5,13 @@ export declare class SuggestManager {
5
5
  constructor(searchBar: FtSearchBar, debounceTime?: number);
6
6
  static styles: import("lit").CSSResult[];
7
7
  render(): import("lit").TemplateResult<1>;
8
+ private getRequestWithQuery;
8
9
  update(): Promise<void>;
9
10
  private onSuggestKeyDown;
10
11
  private nextSuggestionElement;
11
12
  private previousSuggestionElement;
12
13
  private onSuggestKeyUp;
13
14
  private onSuggestClick;
14
- private onSuggestSelected;
15
15
  private removeRecentSearch;
16
16
  private getIcon;
17
17
  private getFocusedSuggestionElement;
@@ -12,20 +12,15 @@ class SuggestManager {
12
12
  const filteredRecentSearches = this.searchBar.recentSearches.filter(q => q.toLowerCase().includes(this.searchBar.query.toLowerCase()));
13
13
  const shouldDisplaySuggestions = this.searchBar.suggestions.length > 0 || filteredRecentSearches.length > 0;
14
14
  return html `
15
- <div class="ft-search-bar--suggestions ft-word-wrap ${shouldDisplaySuggestions
16
- ? "ft-search-bar--suggestions-not-empty"
17
- : ""}"
15
+ <div class="ft-search-bar--suggestions ft-word-wrap ${shouldDisplaySuggestions ? "ft-search-bar--suggestions-not-empty" : ""}"
18
16
  part="suggestions-container"
19
17
  @keydown=${(e) => this.onSuggestKeyDown(e)}>
20
18
  ${repeat(filteredRecentSearches.slice(0, 5), query => query, query => html `
21
19
  <div part="suggestion-container">
22
- <a href="${this.searchBar.searchRequestSerializer({
23
- ...this.searchBar.request,
24
- query: query
25
- })}"
20
+ <a href="${this.getRequestWithQuery(query)}"
26
21
  part="suggestions"
27
22
  class="ft-search-bar--suggestion ft-search-bar--recent-search"
28
- @keyup=${(e) => this.onSuggestKeyUp(e, query)}
23
+ @keyup=${(e) => this.onSuggestKeyUp(e)}
29
24
  @click=${(e) => this.onSuggestClick(e, query)}>
30
25
  <ft-ripple></ft-ripple>
31
26
  <ft-icon variant="material" value="history" part="suggestion-icon"></ft-icon>
@@ -43,13 +38,10 @@ class SuggestManager {
43
38
  `)}
44
39
  ${repeat(this.searchBar.suggestions, suggest => suggest.value, suggest => html `
45
40
  <div part="suggestion-container">
46
- <a href="${this.searchBar.searchRequestSerializer({
47
- ...this.searchBar.request,
48
- query: suggest.value
49
- })}"
41
+ <a href="${(this.getRequestWithQuery(suggest.value))}"
50
42
  part="suggestions"
51
43
  class="ft-search-bar--suggestion"
52
- @keyup=${(e) => this.onSuggestKeyUp(e, suggest.value)}
44
+ @keyup=${(e) => this.onSuggestKeyUp(e)}
53
45
  @click=${(e) => this.onSuggestClick(e, suggest.value)}>
54
46
  <ft-ripple></ft-ripple>
55
47
  ${this.getIcon(suggest)}
@@ -60,6 +52,13 @@ class SuggestManager {
60
52
  </div>
61
53
  `;
62
54
  }
55
+ getRequestWithQuery(query) {
56
+ return this.searchBar.searchRequestSerializer({
57
+ ...this.searchBar.request,
58
+ paging: { page: 1 },
59
+ query
60
+ });
61
+ }
63
62
  update() {
64
63
  return new Promise((accept, reject) => {
65
64
  this.updateDebouncer.run(async () => {
@@ -97,21 +96,14 @@ class SuggestManager {
97
96
  const nextDivElement = (_b = divElement === null || divElement === void 0 ? void 0 : divElement.previousElementSibling) === null || _b === void 0 ? void 0 : _b.querySelector("[part=suggestions]");
98
97
  return nextDivElement !== null && nextDivElement !== void 0 ? nextDivElement : this.getLastSuggestionElement();
99
98
  }
100
- onSuggestKeyUp(e, suggest) {
99
+ onSuggestKeyUp(e) {
101
100
  if (e.key === "Enter" || e.key === " ") {
102
- this.onSuggestSelected(e, suggest);
101
+ e.target.click();
103
102
  }
104
103
  }
105
104
  onSuggestClick(e, suggest) {
106
- if (!e.ctrlKey && !e.metaKey) {
107
- this.onSuggestSelected(e, suggest);
108
- }
109
- }
110
- onSuggestSelected(e, suggest) {
111
- e.preventDefault();
112
- e.stopPropagation();
113
105
  this.searchBar.setQuery(suggest);
114
- this.searchBar.launchSearch();
106
+ this.searchBar.onLaunchSearch();
115
107
  }
116
108
  removeRecentSearch(e, query) {
117
109
  var _a, _b, _c, _d;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-search-bar",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "description": "Search bar component using Fluid Topics public API",
5
5
  "keywords": [
6
6
  "Lit"
@@ -19,23 +19,23 @@
19
19
  "url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
20
20
  },
21
21
  "dependencies": {
22
- "@fluid-topics/ft-accordion": "1.2.1",
23
- "@fluid-topics/ft-app-context": "1.2.1",
24
- "@fluid-topics/ft-button": "1.2.1",
25
- "@fluid-topics/ft-chip": "1.2.1",
26
- "@fluid-topics/ft-filter": "1.2.1",
27
- "@fluid-topics/ft-icon": "1.2.1",
28
- "@fluid-topics/ft-select": "1.2.1",
29
- "@fluid-topics/ft-size-watcher": "1.2.1",
30
- "@fluid-topics/ft-skeleton": "1.2.1",
31
- "@fluid-topics/ft-snap-scroll": "1.2.1",
32
- "@fluid-topics/ft-tooltip": "1.2.1",
33
- "@fluid-topics/ft-typography": "1.2.1",
34
- "@fluid-topics/ft-wc-utils": "1.2.1",
22
+ "@fluid-topics/ft-accordion": "1.2.3",
23
+ "@fluid-topics/ft-app-context": "1.2.3",
24
+ "@fluid-topics/ft-button": "1.2.3",
25
+ "@fluid-topics/ft-chip": "1.2.3",
26
+ "@fluid-topics/ft-filter": "1.2.3",
27
+ "@fluid-topics/ft-icon": "1.2.3",
28
+ "@fluid-topics/ft-select": "1.2.3",
29
+ "@fluid-topics/ft-size-watcher": "1.2.3",
30
+ "@fluid-topics/ft-skeleton": "1.2.3",
31
+ "@fluid-topics/ft-snap-scroll": "1.2.3",
32
+ "@fluid-topics/ft-tooltip": "1.2.3",
33
+ "@fluid-topics/ft-typography": "1.2.3",
34
+ "@fluid-topics/ft-wc-utils": "1.2.3",
35
35
  "lit": "3.1.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@fluid-topics/public-api": "1.0.77"
38
+ "@fluid-topics/public-api": "1.0.78"
39
39
  },
40
- "gitHead": "bbad4c991ddc3e9bbff3b1120c7e56bc0bd6c916"
40
+ "gitHead": "31c1696257f82afca00cddf81033e8984f665c43"
41
41
  }