@salesforcedevs/dx-components 0.10.1-alpha.97 → 0.10.1-alpha.98

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/dx-components",
3
- "version": "0.10.1-alpha.97",
3
+ "version": "0.10.1-alpha.98",
4
4
  "description": "DX Lightning web components",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -10,13 +10,13 @@ import {
10
10
  buildSearchBox,
11
11
  loadAdvancedSearchQueryActions,
12
12
  SearchEngine,
13
- buildSearchStatus
13
+ buildSearchStatus,
14
+ SearchAppState
14
15
  } from "@coveo/headless";
15
16
  import { buildSearchEngine, getSidebarSearchParams } from "utils/coveo";
16
17
  import { RecentSearches } from "utils/recentSearches";
17
18
  import { toJson } from "utils/normalizers";
18
19
  import { Option, PopoverRequestCloseType } from "typings/custom";
19
- import preloadedState from "./__tests__/preloadedState";
20
20
 
21
21
  const UserRecentSearches = new RecentSearches();
22
22
 
@@ -59,7 +59,7 @@ export default class SidebarSearch extends LightningElement {
59
59
  private recentSearches: Option[] = [];
60
60
  private resultList: ResultList | null = null;
61
61
  private resultsPerPage: ResultsPerPage | null = null;
62
- private preloadedState: object = preloadedState;
62
+ private preloadedState?: SearchAppState;
63
63
  private searchBox: SearchBox | null = null;
64
64
  private value?: string = "";
65
65
  private engine: SearchEngine | null = null;
@@ -130,9 +130,9 @@ export default class SidebarSearch extends LightningElement {
130
130
  if (!stringified) {
131
131
  return;
132
132
  }
133
- const json = JSON.parse(stringified);
134
- if (json.value === this.value) {
135
- this.preloadedState = json.state;
133
+ const state = JSON.parse(stringified);
134
+ if (state.query.q === this.value) {
135
+ this.preloadedState = state;
136
136
  }
137
137
  }
138
138
 
@@ -141,13 +141,9 @@ export default class SidebarSearch extends LightningElement {
141
141
  organizationId: this.coveoOrganizationId,
142
142
  publicAccessToken: this.coveoPublicAccessToken,
143
143
  searchHub: this.coveoSearchHub,
144
- preloadedState
144
+ preloadedState: this.preloadedState
145
145
  });
146
146
 
147
- // this.engine.subscribe(() => {
148
- // console.log("engine change", this.engine);
149
- // });
150
-
151
147
  if (!this.engine) {
152
148
  return;
153
149
  }
@@ -174,7 +170,7 @@ export default class SidebarSearch extends LightningElement {
174
170
 
175
171
  if (!this.isValueEmpty) {
176
172
  this.dispatchHighlightedTermChange();
177
- this.submitSearch(); // might not be needed
173
+ this.submitSearch(); // might not be needed
178
174
  }
179
175
  this.dispatchOnLoading(false); // might not be needed
180
176
  };
@@ -187,11 +183,20 @@ export default class SidebarSearch extends LightningElement {
187
183
  const { isLoading, firstSearchExecuted, results } =
188
184
  this.resultList.state;
189
185
 
190
- console.log('on results list change', { isLoading, firstSearchExecuted, results });
186
+ console.log("on results list change", {
187
+ isLoading,
188
+ firstSearchExecuted,
189
+ results
190
+ });
191
191
 
192
192
  if ((!firstSearchExecuted && !isLoading) || this.isValueEmpty) {
193
193
  // coveo search is firing off some unwanted payloads on startup
194
- console.log("returning in results list change", this.value, this.isValueEmpty, (!firstSearchExecuted && !isLoading));
194
+ console.log(
195
+ "returning in results list change",
196
+ this.value,
197
+ this.isValueEmpty,
198
+ !firstSearchExecuted && !isLoading
199
+ );
195
200
  return;
196
201
  }
197
202
 
@@ -249,10 +254,7 @@ export default class SidebarSearch extends LightningElement {
249
254
  private updateSessionStorage() {
250
255
  window.sessionStorage.setItem(
251
256
  "dx-sidebar-search-state",
252
- JSON.stringify({
253
- value: this.value,
254
- state: this.engine?.state
255
- })
257
+ JSON.stringify(this.engine?.state)
256
258
  );
257
259
  }
258
260
 
@@ -13,9 +13,9 @@ export const buildSearchEngine = ({
13
13
  }: {
14
14
  organizationId: string;
15
15
  publicAccessToken: string;
16
- searchPipeline: string;
16
+ searchPipeline?: string;
17
17
  searchHub: string;
18
- preloadedState: SearchAppState;
18
+ preloadedState?: SearchAppState;
19
19
  }) => {
20
20
  const search = searchPipeline
21
21
  ? { pipeline: searchPipeline, searchHub }