Files
ianitor/packages/ui/src/Segmented.svelte
T
mnovak c9aa55ec99 [web] Domi UI: the web UI on @domi/ui v1.0.4, vendored (CPAL-1.0), with the Built on Domi credit (PR #14, squashed)
@domi/ui v1.0.4 vendored unchanged in packages/domi-ui by domi-design's tools/vendor.mjs and used as workspace:*, so
the Nix build fetches nothing from Gitea (web.nix sources the folder; fetchPnpmDeps hash from the NixOS runner).
Its fonts, roles (data-domi-room="ianitor", the same hex) and controls replace Ianitor's copies: Button through
Ianitor's adapter (desktop sizes kept), every text field a TextField with its seal, Checkbox, Select, Segmented.
Ianitor's 22 role names renamed to --domi-*. <DomiCredit /> on every screen and in About, with the CPAL section 15
note beside the source link; the README names the vendored package. Disabled buttons are natively disabled.
2026-11-23 00:52:19 +01:00

43 lines
1.4 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">
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,
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();
const uid = $props.id();
const choices = $derived(options.map((o) => ({ value: o.value, label: o.label, disabled: disabled.includes(o.value) })));
</script>
<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>
</div>