@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
- const filteredResults =
98
- mode !== "search" && (!query || options.map((opt) => opt[labelKey]).includes(query))
99
- ? options
100
- : options.filter((opt) =>
101
- opt[labelKey].match(new RegExp(`\\b${query.replace(/[^\w\s]/gi, "")}`, "i"))
102
- );
103
- populateResults(filteredResults);
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onsvisual/svelte-components",
3
- "version": "1.1.26",
3
+ "version": "1.1.27",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "npm run build:package && npm run build:docs",