diff --git a/src/lib/components/listbox/Listbox.svelte b/src/lib/components/listbox/Listbox.svelte index c0f323d9..67cb34d7 100644 --- a/src/lib/components/listbox/Listbox.svelte +++ b/src/lib/components/listbox/Listbox.svelte @@ -61,6 +61,8 @@ horizontal?: boolean; /** The selected value */ value?: StateDefinition["value"]; + /** The name used when using this component inside a form. */ + name?: string; }; @@ -80,6 +82,8 @@ import type { HTMLActionArray } from "$lib/hooks/use-actions"; import Render from "$lib/utils/Render.svelte"; import type { TPassThroughProps } from "$lib/types"; + import Hidden, { Features as HiddenFeatures } from "$lib/internal/Hidden.svelte"; + import { objectToFormEntries } from "$lib/utils/form"; /***** Props *****/ type TAsProp = $$Generic; @@ -90,6 +94,7 @@ export let disabled = false; export let horizontal = false; export let value: StateDefinition["value"]; + export let name: string | null = null; /***** Events *****/ const forwardEvents = forwardEventsBuilder(get_current_component(), [ @@ -276,6 +281,21 @@ + +{#if name != null && value != null} + {@const options = objectToFormEntries({ [name]: value })} + {#each options as [optionName, optionValue], index (index)} +