@salesforcedevs/dx-components 1.17.8-search-alpha → 1.17.8-search-alpha2

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.17.8-search-alpha",
3
+ "version": "1.17.8-search-alpha2",
4
4
  "description": "DX Lightning web components",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -4,7 +4,6 @@ import { api } from "lwc";
4
4
  import { TreeNode } from "typings/custom";
5
5
  import { toJson } from "dxUtils/normalizers";
6
6
  import { SidebarBase } from "dxBaseElements/sidebarBase";
7
- import { escapeRegExp } from "dxUtils/regexps";
8
7
 
9
8
  const WAIT_TIME = 500;
10
9
  const MOBILE_SIZE_MATCH = "768px";
@@ -120,11 +119,7 @@ export default class Sidebar extends SidebarBase {
120
119
  key: this.makeKey(),
121
120
  tree: this.searchText
122
121
  ? this.findMatch(
123
- new RegExp(
124
- escapeRegExp(
125
- this.searchText.toLowerCase().trim()
126
- )
127
- ),
122
+ new RegExp(this.searchText.toLowerCase().trim()),
128
123
  singleTree
129
124
  )!
130
125
  : singleTree
@@ -142,10 +137,32 @@ export default class Sidebar extends SidebarBase {
142
137
  node: TreeNode
143
138
  ): TreeNode | undefined {
144
139
  const isExpanded = node.isChildrenLoading ? false : true;
140
+
141
+ // Check if label matches
145
142
  if (valuePattern.test(node.label.toLowerCase())) {
146
143
  return { ...node, isExpanded };
147
144
  }
148
145
 
146
+ // Check if endpointsName array exists and contains a match
147
+ if (node.endpointNames && Array.isArray(node.endpointNames)) {
148
+ const hasEndpointMatch = node.endpointNames.some((endpointName) => {
149
+ const endpointWords = endpointName.toLowerCase().split(/\s+/);
150
+ const searchWords = valuePattern.source
151
+ .toLowerCase()
152
+ .split(/\s+/);
153
+ return searchWords.some((searchWord) =>
154
+ endpointWords.some(
155
+ (endpointWord) =>
156
+ endpointWord.includes(searchWord) ||
157
+ searchWord.includes(endpointWord)
158
+ )
159
+ );
160
+ });
161
+ if (hasEndpointMatch) {
162
+ return { ...node, isExpanded };
163
+ }
164
+ }
165
+
149
166
  const filteredChildren = this.filterChildren(
150
167
  valuePattern,
151
168
  node.children