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-19 15:04:07 +02:00
|
|
|
export let readonly = 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 = []
|
2021-04-16 12:04:50 +02:00
|
|
|
export let getOptionLabel = option => extractProperty(option, "label")
|
|
|
|
export let getOptionValue = option => extractProperty(option, "value")
|
2023-11-24 17:19:39 +01:00
|
|
|
export let getOptionSubtitle = option => option?.subtitle
|
2021-07-13 18:30:59 +02:00
|
|
|
export let getOptionIcon = option => option?.icon
|
2022-05-10 14:32:09 +02:00
|
|
|
export let getOptionColour = option => option?.colour
|
2023-11-24 17:19:39 +01:00
|
|
|
export let useOptionIconImage = false
|
2022-08-01 16:23:41 +02:00
|
|
|
export let isOptionEnabled
|
2021-05-06 14:57:36 +02:00
|
|
|
export let quiet = false
|
2021-06-23 15:21:37 +02:00
|
|
|
export let autoWidth = false
|
2021-08-20 11:03:21 +02:00
|
|
|
export let sort = false
|
2022-01-19 19:33:58 +01:00
|
|
|
export let tooltip = ""
|
2023-02-13 10:47:08 +01:00
|
|
|
export let autocomplete = false
|
2023-02-22 13:31:04 +01:00
|
|
|
export let customPopoverHeight
|
2023-02-28 13:29:13 +01:00
|
|
|
export let align
|
2023-02-28 13:49:40 +01:00
|
|
|
export let footer = null
|
2023-08-24 12:38:50 +02:00
|
|
|
export let tag = null
|
2023-11-20 16:05:58 +01:00
|
|
|
export let helpText = null
|
2021-04-15 12:50:56 +02:00
|
|
|
const dispatch = createEventDispatcher()
|
|
|
|
const onChange = e => {
|
|
|
|
value = e.detail
|
2021-04-20 13:49:02 +02:00
|
|
|
dispatch("change", e.detail)
|
2021-03-31 11:59:07 +02:00
|
|
|
}
|
2021-07-07 14:41:09 +02:00
|
|
|
|
2021-04-16 12:04:50 +02:00
|
|
|
const extractProperty = (value, property) => {
|
|
|
|
if (value && typeof value === "object") {
|
|
|
|
return value[property]
|
|
|
|
}
|
|
|
|
return value
|
|
|
|
}
|
2021-04-15 12:50:56 +02:00
|
|
|
</script>
|
2021-03-31 11:59:07 +02:00
|
|
|
|
2023-11-20 16:05:58 +01:00
|
|
|
<Field {helpText} {label} {labelPosition} {error} {tooltip}>
|
2021-04-15 12:50:56 +02:00
|
|
|
<Select
|
2021-05-06 14:57:36 +02:00
|
|
|
{quiet}
|
2021-04-15 12:50:56 +02:00
|
|
|
{error}
|
|
|
|
{disabled}
|
2021-04-19 15:04:07 +02:00
|
|
|
{readonly}
|
2021-04-15 12:50:56 +02:00
|
|
|
{value}
|
|
|
|
{options}
|
|
|
|
{placeholder}
|
2021-06-23 15:21:37 +02:00
|
|
|
{autoWidth}
|
2021-08-20 11:03:21 +02:00
|
|
|
{sort}
|
2023-02-28 13:29:13 +01:00
|
|
|
{align}
|
2023-02-28 13:49:40 +01:00
|
|
|
{footer}
|
2021-04-15 12:50:56 +02:00
|
|
|
{getOptionLabel}
|
|
|
|
{getOptionValue}
|
2021-07-07 14:41:09 +02:00
|
|
|
{getOptionIcon}
|
2022-05-10 14:32:09 +02:00
|
|
|
{getOptionColour}
|
2023-11-24 17:19:39 +01:00
|
|
|
{getOptionSubtitle}
|
2023-02-28 17:21:54 +01:00
|
|
|
{useOptionIconImage}
|
2022-08-01 16:23:41 +02:00
|
|
|
{isOptionEnabled}
|
2023-02-13 10:47:08 +01:00
|
|
|
{autocomplete}
|
2023-02-22 13:31:04 +01:00
|
|
|
{customPopoverHeight}
|
2023-08-24 12:38:50 +02:00
|
|
|
{tag}
|
2021-04-19 15:04:07 +02:00
|
|
|
on:change={onChange}
|
2021-05-04 12:04:42 +02:00
|
|
|
on:click
|
|
|
|
/>
|
2021-04-15 12:50:56 +02:00
|
|
|
</Field>
|