@salesforcedevs/dx-components 1.28.7-alpha.10 → 1.28.7-alpha.12
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": "1.28.7-alpha.
|
|
3
|
+
"version": "1.28.7-alpha.12",
|
|
4
4
|
"description": "DX Lightning web components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"luxon": "3.4.4",
|
|
45
45
|
"msw": "^2.12.4"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "d90a01c3e0b1366d6f262d986bfa0ef6ede99137"
|
|
48
48
|
}
|
|
@@ -4,8 +4,10 @@ import {
|
|
|
4
4
|
type DataCloudSearchResultItem,
|
|
5
5
|
fetchSearch
|
|
6
6
|
} from "dxUtils/dataCloudSearch";
|
|
7
|
+
import { createSearchRegExp } from "dxUtils/regexps";
|
|
7
8
|
import { RecentSearches } from "dxUtils/recentSearches";
|
|
8
9
|
import {
|
|
10
|
+
type HighlightedSections,
|
|
9
11
|
Option,
|
|
10
12
|
PopoverRequestCloseType,
|
|
11
13
|
SidebarSearchResult
|
|
@@ -13,6 +15,27 @@ import {
|
|
|
13
15
|
|
|
14
16
|
const SEARCH_DEBOUNCE_DELAY = 1200;
|
|
15
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Find all matches of the search query in text and return ranges for highlighting.
|
|
20
|
+
* Uses the same regex as the full-doc highlighter (createSearchRegExp) so sidebar
|
|
21
|
+
* and doc highlight the same phrases (including spaces between words).
|
|
22
|
+
*/
|
|
23
|
+
function getHighlightRanges(
|
|
24
|
+
text: string,
|
|
25
|
+
searchQuery: string
|
|
26
|
+
): HighlightedSections {
|
|
27
|
+
if (!text || !searchQuery.trim()) {
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
const re = createSearchRegExp(searchQuery.trim());
|
|
31
|
+
const ranges: HighlightedSections = [];
|
|
32
|
+
let match: RegExpExecArray | null;
|
|
33
|
+
while ((match = re.exec(text)) !== null) {
|
|
34
|
+
ranges.push({ offset: match.index, length: match[0].length });
|
|
35
|
+
}
|
|
36
|
+
return ranges;
|
|
37
|
+
}
|
|
38
|
+
|
|
16
39
|
const UserRecentSearches = new RecentSearches();
|
|
17
40
|
|
|
18
41
|
const getSearchQueryParam = (): string =>
|
|
@@ -87,11 +110,14 @@ export default class SidebarSearch extends LightningElement {
|
|
|
87
110
|
: href;
|
|
88
111
|
const isSelected =
|
|
89
112
|
!!resultPath && resultPath === window.location.pathname;
|
|
113
|
+
const title = item.title ?? "";
|
|
114
|
+
const excerpt = item.matchedText ?? "";
|
|
115
|
+
const searchQuery = this.value.trim();
|
|
90
116
|
return {
|
|
91
|
-
title
|
|
92
|
-
titleHighlights:
|
|
93
|
-
excerpt
|
|
94
|
-
excerptHighlights:
|
|
117
|
+
title,
|
|
118
|
+
titleHighlights: getHighlightRanges(title, searchQuery),
|
|
119
|
+
excerpt,
|
|
120
|
+
excerptHighlights: getHighlightRanges(excerpt, searchQuery),
|
|
95
121
|
uniqueId: href || `result-${index}`,
|
|
96
122
|
href,
|
|
97
123
|
selected: isSelected,
|
|
@@ -164,6 +190,7 @@ export default class SidebarSearch extends LightningElement {
|
|
|
164
190
|
private onClickRecentSearch(e: CustomEvent) {
|
|
165
191
|
this.value = e.detail;
|
|
166
192
|
this.dispatchSidebarSearchChange(this.value);
|
|
193
|
+
this.dispatchOnLoading(true);
|
|
167
194
|
this.submitSearch(true);
|
|
168
195
|
}
|
|
169
196
|
|