46 lines
1.2 KiB
Svelte
46 lines
1.2 KiB
Svelte
<!-- SPDX-License-Identifier: CPAL-1.0
|
|
- Copyright (c) 2026 Marek Novák. Part of Ianitor, under the Common Public Attribution
|
|
- License 1.0: see LICENSE (its Exhibit A is this file's notice). -->
|
|
<script lang="ts" generics="T extends string">
|
|
// Handoff §2.10: a radio group in a fieldset; arrows move and select (native radios).
|
|
let {
|
|
legend,
|
|
name,
|
|
options,
|
|
value = $bindable(),
|
|
disabled = [],
|
|
describedby,
|
|
onchange,
|
|
}: {
|
|
legend: string;
|
|
name: string;
|
|
options: { value: T; label: string }[];
|
|
value: T;
|
|
disabled?: T[];
|
|
describedby?: string;
|
|
onchange?: (v: T) => void;
|
|
} = $props();
|
|
</script>
|
|
|
|
<fieldset class="domi-field" aria-describedby={describedby}>
|
|
<legend class="domi-field-label">{legend}</legend>
|
|
<div class="ia-seg">
|
|
{#each options as o (o.value)}
|
|
<label>
|
|
<input
|
|
type="radio"
|
|
{name}
|
|
value={o.value}
|
|
checked={value === o.value}
|
|
disabled={disabled.includes(o.value)}
|
|
onchange={() => {
|
|
value = o.value;
|
|
onchange?.(o.value);
|
|
}}
|
|
/>
|
|
{o.label}
|
|
</label>
|
|
{/each}
|
|
</div>
|
|
</fieldset>
|