anki/ts/components/SelectOption.svelte

25 lines
592 B
Svelte
Raw Normal View History

2021-04-15 15:59:52 +02:00
<!--
Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="ts">
import { createEventDispatcher } from "svelte";
2021-03-31 15:40:11 +02:00
import DropdownItem from "./DropdownItem.svelte";
export let disabled = false;
const dispatch = createEventDispatcher();
let element: HTMLButtonElement;
function onSelect(): void {
if (!disabled) {
dispatch("select");
}
}
</script>
<DropdownItem {disabled} on:click={onSelect} bind:buttonRef={element}>
<slot />
</DropdownItem>