Type CheckboxGroup.svelte.

This commit is contained in:
Sam Rose 2025-01-27 16:25:07 +00:00
parent d4e63c0716
commit aec4d4d8ac
No known key found for this signature in database
1 changed files with 8 additions and 8 deletions

View File

@ -1,19 +1,19 @@
<script> <script lang="ts" generics="O, V">
import "@spectrum-css/fieldgroup/dist/index-vars.css" import "@spectrum-css/fieldgroup/dist/index-vars.css"
import "@spectrum-css/radio/dist/index-vars.css" import "@spectrum-css/radio/dist/index-vars.css"
import { createEventDispatcher } from "svelte" import { createEventDispatcher } from "svelte"
export let direction = "vertical" export let direction: "horizontal" | "vertical" = "vertical"
export let value = [] export let value: V[] = []
export let options = [] export let options: O[] = []
export let disabled = false export let disabled = false
export let readonly = false export let readonly = false
export let getOptionLabel = option => option export let getOptionLabel: (option: O) => string = (option: O) => `${option}`
export let getOptionValue = option => option export let getOptionValue: (option: O) => V = option => option as unknown as V
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher<{ change: V[] }>()
const onChange = optionValue => { const onChange = (optionValue: V) => {
if (!value.includes(optionValue)) { if (!value.includes(optionValue)) {
dispatch("change", [...value, optionValue]) dispatch("change", [...value, optionValue])
} else { } else {