@salesforcedevs/dx-components 0.19.3-alpha.58 → 0.19.3-alpha.61
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
|
@@ -89,6 +89,7 @@ export default class Sidebar extends LightningElement {
|
|
|
89
89
|
|
|
90
90
|
private onSelect(event: CustomEvent) {
|
|
91
91
|
this._value = event.detail.name;
|
|
92
|
+
this.dispatchHighlightedTermChange();
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
private onToggleClick(event: Event) {
|
|
@@ -120,19 +121,23 @@ export default class Sidebar extends LightningElement {
|
|
|
120
121
|
window.clearTimeout(this._searchTimeout);
|
|
121
122
|
this._searchTimeout = window.setTimeout(() => {
|
|
122
123
|
this.assignFilteredTrees();
|
|
123
|
-
this.
|
|
124
|
-
new CustomEvent("highlightedtermchange", {
|
|
125
|
-
detail: {
|
|
126
|
-
query: this.searchText,
|
|
127
|
-
termsToHighlight: [this.searchText]
|
|
128
|
-
},
|
|
129
|
-
composed: true,
|
|
130
|
-
bubbles: true
|
|
131
|
-
})
|
|
132
|
-
);
|
|
124
|
+
this.dispatchHighlightedTermChange();
|
|
133
125
|
}, WAIT_TIME);
|
|
134
126
|
}
|
|
135
127
|
|
|
128
|
+
private dispatchHighlightedTermChange = () => {
|
|
129
|
+
this.dispatchEvent(
|
|
130
|
+
new CustomEvent("highlightedtermchange", {
|
|
131
|
+
detail: {
|
|
132
|
+
query: this.searchText,
|
|
133
|
+
termsToHighlight: [this.searchText]
|
|
134
|
+
},
|
|
135
|
+
composed: true,
|
|
136
|
+
bubbles: true
|
|
137
|
+
})
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
136
141
|
private assignFilteredTrees() {
|
|
137
142
|
this.filteredTrees = this._trees
|
|
138
143
|
.map((singleTree) => {
|
|
@@ -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
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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 {
|