@onsvisual/svelte-components 1.1.26 → 1.1.28
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.
|
@@ -94,13 +94,13 @@
|
|
|
94
94
|
* @type {function}
|
|
95
95
|
*/
|
|
96
96
|
export let loadOptions = (query, populateResults) => {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
97
|
+
if (mode !== "search" && (!query || options.map((opt) => opt?.[labelKey]).includes(query)))
|
|
98
|
+
populateResults(options);
|
|
99
|
+
else {
|
|
100
|
+
const regex = new RegExp(`\\b${query.replace(/[^\w\s]/gi, "")}`, "i");
|
|
101
|
+
const filteredResults = options.filter((opt) => regex.test(opt?.[labelKey]));
|
|
102
|
+
populateResults(filteredResults);
|
|
103
|
+
}
|
|
104
104
|
};
|
|
105
105
|
/**
|
|
106
106
|
* Call this function externally to clear the input
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
function highlight(text, query = "") {
|
|
135
|
-
return text.replace(
|
|
135
|
+
return (text || "").replace(
|
|
136
136
|
new RegExp(`\\b${query.replace(/[^\w\s]/gi, "")}`, "i"),
|
|
137
137
|
(str) => `<b>${str}</b>`
|
|
138
138
|
);
|