rob-balfre / svelte-select

Svelte Select. A select component for Svelte
https://svelte-select-examples.vercel.app
Other
1.25k stars 175 forks source link

Pattern based item filters #508

Closed exwhyz closed 1 year ago

exwhyz commented 1 year ago

I would like to make a suggestion to add the ability to switch between vanilla string filters and regex filters:

//Suggested modification of line 34 of Select.svelte and inclusion of a boolean pattern property defaulted to false
export let pattern = false;
export let itemFilter = (label, filterText, pattern) => pattern ? new RegExp(filterText, 'gi').test(`${label}`) : `${label}`.toLowerCase().includes(filterText.toLowerCase());

Update: It appears there is an option to override the itemFilter function so this topic may be moot. It can be closed, sorry for the noise without fully reading the docs.

rob-balfre commented 1 year ago

@exwhyz yeah you have total control of itemFilter as it's exported or you can use loadOptions... https://svelte-select-examples.vercel.app/examples/props/loadOptions

Will close, thanks