2021-04-12 06:18:30 +02:00
|
|
|
<!--
|
|
|
|
Copyright: Ankitects Pty Ltd and contributors
|
|
|
|
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
-->
|
2023-09-14 01:06:15 +02:00
|
|
|
<script context="module" lang="ts">
|
|
|
|
export interface Choice<T> {
|
|
|
|
label: string;
|
|
|
|
value: T;
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2021-04-12 06:18:30 +02:00
|
|
|
<script lang="ts">
|
2023-09-09 01:00:55 +02:00
|
|
|
import Select from "./Select.svelte";
|
2021-05-30 19:46:39 +02:00
|
|
|
|
2023-09-14 01:06:15 +02:00
|
|
|
type T = $$Generic;
|
|
|
|
|
|
|
|
export let value: T;
|
|
|
|
export let choices: Choice<T>[] = [];
|
|
|
|
export let disabled: boolean = false;
|
|
|
|
export let disabledChoices: T[] = [];
|
2022-12-01 10:24:26 +01:00
|
|
|
|
2023-09-14 01:06:15 +02:00
|
|
|
$: label = choices.find((c) => c.value === value)?.label;
|
2021-04-12 06:18:30 +02:00
|
|
|
</script>
|
|
|
|
|
2023-11-21 05:23:18 +01:00
|
|
|
<Select
|
|
|
|
bind:value
|
|
|
|
{label}
|
|
|
|
{disabled}
|
|
|
|
list={choices}
|
|
|
|
parser={(item) => ({
|
|
|
|
content: item.label,
|
|
|
|
value: item.value,
|
|
|
|
disabled: disabledChoices.includes(item.value),
|
|
|
|
})}
|
|
|
|
/>
|