@salesforcedevs/dx-components 0.19.3-alpha.19 → 0.19.3-alpha.23

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.19",
3
+ "version": "0.19.3-alpha.23",
4
4
  "description": "DX Lightning web components",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -144,9 +144,7 @@ export default class SidebarSearch extends LightningElement {
144
144
  // If this is the first render and there is a search value, trigger
145
145
  // term highlighting
146
146
  if (!this.didRender && this.value) {
147
- console.log('dispatching highlight term in the render')
148
147
  this.dispatchHighlightedTermChange();
149
- window.addEventListener('search-syncer-initialized', () => console.log('SEARCH SYNCER INITD'))
150
148
  }
151
149
 
152
150
  this.didRender = true;
@@ -322,6 +320,7 @@ export default class SidebarSearch extends LightningElement {
322
320
 
323
321
  private dispatchOnChangeEvent(results: Result[]) {
324
322
  this.updateSessionStorage();
323
+ this.dispatchHighlightedTermChange();
325
324
  this.dispatchEvent(
326
325
  new CustomEvent("change", {
327
326
  detail: {
@@ -337,6 +336,19 @@ export default class SidebarSearch extends LightningElement {
337
336
  }
338
337
 
339
338
  private dispatchHighlightedTermChange = debounce(() => {
339
+ const { termsToHighlight, phrasesToHighlight } =
340
+ this.engine?.state?.search?.response;
341
+ if (!termsToHighlight || !phrasesToHighlight) {
342
+ return;
343
+ }
344
+ const terms = new Set(
345
+ [
346
+ Object.values(termsToHighlight),
347
+ Object.values(phrasesToHighlight),
348
+ this.value
349
+ ].flat()
350
+ );
351
+ console.log({ terms });
340
352
  this.dispatchEvent(
341
353
  new CustomEvent("highlightedtermchange", {
342
354
  detail: this.value,
@@ -399,7 +411,6 @@ export default class SidebarSearch extends LightningElement {
399
411
  this.value = e.detail;
400
412
 
401
413
  this.handleValueChange(false);
402
- this.dispatchHighlightedTermChange();
403
414
  }
404
415
 
405
416
  private onInputFocus() {
@@ -2,9 +2,7 @@ import { createSearchRegExp } from "utils/regexps";
2
2
 
3
3
  const MARK_TAGS = /<\/?mark>/gi;
4
4
 
5
- // mark tags not being removed from ref page
6
5
  // mark tags dif color on ref page
7
- // need to reset to first match on highlight change
8
6
 
9
7
  export const highlightTerms = (
10
8
  // eslint-disable-next-line no-undef
@@ -14,7 +12,6 @@ export const highlightTerms = (
14
12
  searchTerm = searchTerm.trim();
15
13
  const searchExp = createSearchRegExp(searchTerm);
16
14
  let scrolled = false;
17
- console.log('highlighting called', elements)
18
15
  elements.forEach((element) => {
19
16
  if (
20
17
  element?.innerHTML.includes("<dx-") ||
@@ -34,17 +31,21 @@ export const highlightTerms = (
34
31
  innerHtml = innerHtml.replace(searchExp, "<mark>$&</mark>");
35
32
  }
36
33
 
37
- element.setAttribute('lwc:dom', 'manual')
38
34
  element.innerHTML = innerHtml;
39
35
  } catch (e) {
40
36
  console.error(e, element);
41
37
  }
42
38
 
43
- console.log("should i scroll?");
39
+ element
40
+ .querySelectorAll("mark")
41
+ .forEach(
42
+ (el) =>
43
+ (el.style.backgroundColor = "var(--dx-g-yellow-vibrant-90)")
44
+ );
45
+
44
46
  const mark = element.querySelector("mark");
45
47
  if (mark && !scrolled) {
46
48
  scrolled = true;
47
- console.log("scrolling", mark);
48
49
  mark.scrollIntoView({ block: "nearest" });
49
50
  }
50
51
  });