@onsvisual/svelte-components 1.1.26 → 1.1.27
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
|