@salesforcedevs/dx-components 0.10.1-alpha.102 → 0.10.1-alpha.103
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.
package/package.json
CHANGED
|
@@ -10,34 +10,23 @@ import {
|
|
|
10
10
|
buildSearchBox,
|
|
11
11
|
loadAdvancedSearchQueryActions,
|
|
12
12
|
SearchEngine,
|
|
13
|
-
// buildSearchStatus,
|
|
14
13
|
SearchAppState
|
|
15
14
|
} from "@coveo/headless";
|
|
16
15
|
import { buildSearchEngine, getSidebarSearchParams } from "utils/coveo";
|
|
17
16
|
import { RecentSearches } from "utils/recentSearches";
|
|
18
17
|
import { toJson } from "utils/normalizers";
|
|
19
18
|
import { Option, PopoverRequestCloseType } from "typings/custom";
|
|
20
|
-
import preloadedState from "./__tests__/preloadedState";
|
|
21
19
|
|
|
22
20
|
const SESSION_KEY = "dx-sidebar-search-state";
|
|
23
21
|
|
|
24
22
|
const DEFAULT_RESULT_COUNT = 20;
|
|
23
|
+
const SEARCH_DEBOUNCE_DELAY = 780;
|
|
25
24
|
|
|
26
25
|
const UserRecentSearches = new RecentSearches();
|
|
27
26
|
|
|
28
27
|
const normalizeCoveoAdvancedQueryValue = (version: string): string =>
|
|
29
28
|
version.split(".").join("\\.");
|
|
30
29
|
|
|
31
|
-
// function executeFirstSearch(engine: SearchEngine) {
|
|
32
|
-
// return new Promise((resolve) => {
|
|
33
|
-
// const searchStatus = buildSearchStatus(engine);
|
|
34
|
-
// searchStatus.subscribe(
|
|
35
|
-
// () => searchStatus.state.firstSearchExecuted && resolve(true)
|
|
36
|
-
// );
|
|
37
|
-
// engine.executeFirstSearch();
|
|
38
|
-
// });
|
|
39
|
-
// }
|
|
40
|
-
|
|
41
30
|
export default class SidebarSearch extends LightningElement {
|
|
42
31
|
@api coveoOrganizationId!: string;
|
|
43
32
|
@api coveoPublicAccessToken!: string;
|
|
@@ -53,6 +42,7 @@ export default class SidebarSearch extends LightningElement {
|
|
|
53
42
|
@api
|
|
54
43
|
public fetchMoreResults() {
|
|
55
44
|
if (this.resultList) {
|
|
45
|
+
this.fetchingMoreResults = true;
|
|
56
46
|
this.resultList.fetchMoreResults();
|
|
57
47
|
}
|
|
58
48
|
}
|
|
@@ -66,6 +56,7 @@ export default class SidebarSearch extends LightningElement {
|
|
|
66
56
|
private searchBox: SearchBox | null = null;
|
|
67
57
|
private value?: string = "";
|
|
68
58
|
private engine: SearchEngine | null = null;
|
|
59
|
+
private fetchingMoreResults: boolean = false;
|
|
69
60
|
|
|
70
61
|
private get hasCorrectCoveoConfig(): boolean {
|
|
71
62
|
const coveoConfigurations = [
|
|
@@ -124,14 +115,7 @@ export default class SidebarSearch extends LightningElement {
|
|
|
124
115
|
return;
|
|
125
116
|
}
|
|
126
117
|
const state = JSON.parse(stringified);
|
|
127
|
-
console.log(
|
|
128
|
-
{ state },
|
|
129
|
-
state?.query?.q,
|
|
130
|
-
this.value,
|
|
131
|
-
state?.query?.q === this.value
|
|
132
|
-
);
|
|
133
118
|
if (state?.query?.q === this.value) {
|
|
134
|
-
console.log("assigning state");
|
|
135
119
|
this.preloadedState = state;
|
|
136
120
|
}
|
|
137
121
|
}
|
|
@@ -157,21 +141,23 @@ export default class SidebarSearch extends LightningElement {
|
|
|
157
141
|
numberOfResults: DEFAULT_RESULT_COUNT
|
|
158
142
|
}
|
|
159
143
|
});
|
|
144
|
+
|
|
160
145
|
this.searchBox = buildSearchBox(this.engine, {
|
|
161
146
|
options: { numberOfSuggestions: 3 }
|
|
162
147
|
});
|
|
148
|
+
|
|
163
149
|
this.setAdvancedFilters(this.engine);
|
|
164
150
|
|
|
165
151
|
this.resultList?.subscribe(this.onResultListChange);
|
|
166
152
|
|
|
167
|
-
// await executeFirstSearch(this.engine);
|
|
168
|
-
|
|
169
|
-
console.log({ resultList: this.resultList, engine: this.engine });
|
|
170
|
-
|
|
171
153
|
if (!this.isValueEmpty) {
|
|
172
154
|
this.dispatchHighlightedTermChange();
|
|
173
155
|
}
|
|
174
|
-
this.
|
|
156
|
+
console.log('here', this.preloadedState)
|
|
157
|
+
if (!this.preloadedState) {
|
|
158
|
+
console.log(this.preloadedState)
|
|
159
|
+
this.dispatchOnLoading(false);
|
|
160
|
+
}
|
|
175
161
|
};
|
|
176
162
|
|
|
177
163
|
private onResultListChange = () => {
|
|
@@ -200,11 +186,16 @@ export default class SidebarSearch extends LightningElement {
|
|
|
200
186
|
}
|
|
201
187
|
|
|
202
188
|
if (!isLoading) {
|
|
203
|
-
console.log("CHANGING RESULTS");
|
|
204
189
|
this.dispatchOnChangeEvent(results);
|
|
205
190
|
}
|
|
206
191
|
|
|
207
|
-
this.
|
|
192
|
+
if (!this.fetchingMoreResults) {
|
|
193
|
+
this.dispatchOnLoading(isLoading);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (!isLoading && this.fetchingMoreResults) {
|
|
197
|
+
this.fetchingMoreResults = false;
|
|
198
|
+
}
|
|
208
199
|
};
|
|
209
200
|
|
|
210
201
|
private setAdvancedFilters(engine: SearchEngine) {
|
|
@@ -312,7 +303,7 @@ export default class SidebarSearch extends LightningElement {
|
|
|
312
303
|
this.updateRecentSearches();
|
|
313
304
|
this.searchBox.submit();
|
|
314
305
|
}
|
|
315
|
-
},
|
|
306
|
+
}, SEARCH_DEBOUNCE_DELAY);
|
|
316
307
|
|
|
317
308
|
private onClickRecentSearch(e: CustomEvent) {
|
|
318
309
|
this.value = e.detail;
|