2021-03-31 11:59:07 +02:00
|
|
|
<script>
|
2021-04-15 12:50:56 +02:00
|
|
|
import Field from "./Field.svelte"
|
2021-04-15 20:28:08 +02:00
|
|
|
import Select from "./Core/Select.svelte"
|
2021-04-15 12:50:56 +02:00
|
|
|
import { createEventDispatcher } from "svelte"
|
2021-03-31 11:59:07 +02:00
|
|
|
|
2021-04-15 12:50:56 +02:00
|
|
|
export let value = null
|
2021-03-31 11:59:07 +02:00
|
|
|
export let label = undefined
|
|
|
|
export let disabled = false
|
2021-04-15 12:50:56 +02:00
|
|
|
export let labelPosition = "above"
|
|
|
|
export let error = null
|
2021-04-16 10:01:21 +02:00
|
|
|
export let placeholder = "Choose an option"
|
2021-04-15 12:50:56 +02:00
|
|
|
export let options = []
|
|
|
|
export let getOptionLabel = option => option
|
|
|
|
export let getOptionValue = option => option
|
2021-03-31 11:59:07 +02:00
|
|
|
|
2021-04-15 12:50:56 +02:00
|
|
|
const dispatch = createEventDispatcher()
|
|
|
|
const onChange = e => {
|
|
|
|
dispatch("change", e.detail)
|
|
|
|
value = e.detail
|
2021-03-31 11:59:07 +02:00
|
|
|
}
|
2021-04-15 12:50:56 +02:00
|
|
|
</script>
|
2021-03-31 11:59:07 +02:00
|
|
|
|
2021-04-15 12:50:56 +02:00
|
|
|
<Field {label} {labelPosition} {disabled} {error}>
|
|
|
|
<Select
|
|
|
|
{error}
|
|
|
|
{disabled}
|
|
|
|
{value}
|
|
|
|
{options}
|
|
|
|
{placeholder}
|
|
|
|
{getOptionLabel}
|
|
|
|
{getOptionValue}
|
|
|
|
on:change={onChange} />
|
|
|
|
</Field>
|