Sanity filter on change
This commit is contained in:
parent
9b14f50e8f
commit
0702bc6c33
|
@ -5,6 +5,7 @@
|
|||
import { API } from "api"
|
||||
|
||||
export let value = null
|
||||
export let multiple = false
|
||||
|
||||
$: fetch = fetchData({
|
||||
API,
|
||||
|
@ -17,11 +18,21 @@
|
|||
})
|
||||
|
||||
$: options = $fetch.rows
|
||||
|
||||
function onChange(e) {
|
||||
const val = e.detail
|
||||
if (!val) {
|
||||
value = val
|
||||
} else {
|
||||
value = Array.isArray(val) ? val : [val]
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Select
|
||||
value={multiple ? value : value[0]}
|
||||
autocomplete
|
||||
bind:value
|
||||
on:change={onChange}
|
||||
{options}
|
||||
getOptionLabel={option => option.email}
|
||||
getOptionValue={option => option._id}
|
||||
|
|
Loading…
Reference in New Issue