@salesforcedevs/dx-components 0.19.3-alpha.57 → 0.19.3-alpha.60

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.19.3-alpha.57",
3
+ "version": "0.19.3-alpha.60",
4
4
  "description": "DX Lightning web components",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -27,7 +27,6 @@ export const SESSION_KEY = "dx-sidebar-search-state";
27
27
 
28
28
  const DEFAULT_RESULT_COUNT = 20;
29
29
  const SEARCH_DEBOUNCE_DELAY = 780;
30
- const HIGHLIGHT_DEBOUNCE_DELAY = 200;
31
30
 
32
31
  const UserRecentSearches = new RecentSearches();
33
32
 
@@ -95,17 +94,22 @@ export default class SidebarSearch extends LightningElement {
95
94
  if (!termsToHighlight || !phrasesToHighlight) {
96
95
  return null;
97
96
  }
98
- return Array.from(
99
- new Set(
100
- [
101
- this.value,
102
- Object.keys(termsToHighlight),
103
- Object.keys(phrasesToHighlight),
104
- Object.values(termsToHighlight),
105
- Object.values(phrasesToHighlight)
106
- ].flat(2)
107
- )
108
- ) as string[];
97
+
98
+ const flattenTerms = (terms: Object): string[] =>
99
+ Object.entries(terms).reduce((acc, [key, value]) => {
100
+ if (Array.isArray(value)) {
101
+ return [...acc, key, ...value];
102
+ }
103
+ const values = flattenTerms(value);
104
+ return [...acc, key, ...values];
105
+ }, []);
106
+
107
+ const terms = flattenTerms({
108
+ ...termsToHighlight,
109
+ ...phrasesToHighlight
110
+ });
111
+
112
+ return Array.from(new Set([this.value, ...terms].flat(2))) as string[];
109
113
  }
110
114
 
111
115
  private get hasCorrectCoveoConfig(): boolean {
@@ -9,9 +9,10 @@ export const highlightTerms = (
9
9
  elements: NodeListOf<HTMLElement>,
10
10
  { query, termsToHighlight }: { query: string; termsToHighlight: string[] }
11
11
  ): void => {
12
+ console.log({ elements, query, termsToHighlight });
12
13
  const searchExp = createSearchRegExp(termsToHighlight);
13
14
  let scrolled = false;
14
- console.log({ elements, query, termsToHighlight, searchExp });
15
+ console.log({ searchExp });
15
16
  elements.forEach((element) => {
16
17
  if (
17
18
  element?.innerHTML.includes("<dx-") ||