diff --git a/web/src/lib/components/ui/Field.svelte b/web/src/lib/components/ui/Field.svelte index e92a36461..d75d7493f 100644 --- a/web/src/lib/components/ui/Field.svelte +++ b/web/src/lib/components/ui/Field.svelte @@ -27,8 +27,9 @@ interface Props extends Omit, "class" | "children"> { label?: string; - subtitle?: string; + subtitle?: string | Snippet; for?: string; + group?: boolean; required?: boolean; labelCase?: FieldVariants["labelCase"]; class?: string; @@ -39,6 +40,7 @@ label, subtitle, for: forId, + group = false, required = false, labelCase, class: className, @@ -48,20 +50,32 @@ const generatedId = $props.id(); const id = $derived(forId ?? generatedId); + const labelId = $derived(`${id}-label`); const slot = $derived(field({ labelCase })); -
- {#if label} - +{#snippet labelText()} + {label} + {#if required} + * + {/if} +{/snippet} + +
+ {#if label && group} + {@render labelText()} + {:else if label} + {/if} {@render children({ id })} - {#if subtitle} + {#if typeof subtitle === "function"} +

{@render subtitle()}

+ {:else if subtitle}

{subtitle}

{/if}