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