[web] Domi UI: the web UI on @domi/ui v1.0.0 (fonts, roles, Button, TextField with seals, Checkbox, Select, Segmented)

This commit is contained in:
2026-11-22 23:24:03 +01:00
parent 8b4570ca1a
commit afade6d98c
24 changed files with 356 additions and 380 deletions
+19 -22
View File
@@ -2,10 +2,14 @@
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at https://mozilla.org/MPL/2.0/. -->
<script lang="ts" generics="T extends string">
// Handoff §2.10: a radio group in a fieldset; arrows move and select (native radios).
import { Segmented as DomiSegmented } from "@domi/ui";
// Handoff §2.10: a few choices of one thing, with its name shown above them. The control is @domi/ui's Segmented
// (a radio group with one Tab stop; arrows, Home and End move the choice); Ianitor keeps the visible name.
// `name` is kept for the call sites; @domi/ui's group needs none.
let {
legend,
name,
name: _name,
options,
value = $bindable(),
disabled = [],
@@ -20,26 +24,19 @@
describedby?: string;
onchange?: (v: T) => void;
} = $props();
const uid = $props.id();
const choices = $derived(options.map((o) => ({ value: o.value, label: o.label, disabled: disabled.includes(o.value) })));
</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 class="ia-field" role="group" aria-labelledby="ia-seg-{uid}" aria-describedby={describedby}>
<span class="ia-field-label" id="ia-seg-{uid}">{legend}</span>
<div>
<DomiSegmented
label={legend}
options={choices}
bind:value={() => value, (v) => (value = v as T)}
onchange={(v) => onchange?.(v as T)}
/>
</div>
</fieldset>
</div>