#131. Eidos wrapper + types + recipe + canonical-depth demo. Soma owns single/multi selection (value as string[]), roving-tabindex keyboard nav (Arrow + Home/End + typeahead + Ctrl+A), Field-merged flags (disabled/readonly/required/invalid), hidden form inputs. Eidos adds the visual surface and exposes variant + size + color. Reference parity (no air baseline — port directly from soma): | Feature | soma | react-aria | Headless UI | bits-ui | this port | |---|---|---|---|---|---| | Single + multiple selection | ✓ | ✓ | ✓ | ✓ | ✓ | | bind:value (controlled) | ✓ | ✓ | ✓ | ✓ | ✓ | | Typeahead + Arrow / Home / End | ✓ | ✓ | ✓ | ✓ | ✓ | | Loop nav | ✓ | ✗ | ✗ | ✗ | ✓ | | Section / Group + label | ✓ | ✓ | ✗ | ✓ | ✓ | | Ctrl+A select-all (multi) | ✓ | ✓ | ✗ | ✗ | ✓ | | Form participation (hidden inputs) | ✓ | ✗ | ✓ | ✗ | ✓ | | Field.Provider merge (disabled/invalid/…) | ✓ | ✗ | ✗ | ✗ | ✓ | | Horizontal orientation | ✓ | ✓ | ✓ | ✓ | ✓ | | Item indicator (✓ glyph) | ✓ | ✓ | ✗ | ✓ | ✓ shared partial | | Drag-to-reorder | ✗ | ✓ | ✗ | ✗ | ⚠ deferred | | Async / infinite loading | ✗ | ✓ | ✗ | ✗ | ⚠ deferred | | selectionBehavior (toggle/replace) | ⚠ implicit | ✓ | ✗ | ✓ | ⚠ deferred | | PageUp/Down nav | ✗ | ✓ | ✗ | ✗ | ⚠ deferred | Parts (5): Listbox (Root, replaces soma's Provider name), Item, ItemIndicator, Group, GroupLabel. Variant set: - variant: ControlVariant (`'surface' | 'outline' | 'ghost'`), default 'surface' - size: xs..xl (5-step canonical form-control scale) - color: ColorRole (primary/secondary/neutral/affirm/fulfill/risk/threat/loss) - block: stretch to container width Cross-component reuse: - `ItemIndicator` shares the menu-indicator visual (`a2709476`) — ✓ glyph identical to standalone Checkbox and Dropdown/Context Menu CheckboxItems. CSS-only difference: shown only inside `[data-listbox-item][data-selected]`. - Item row hover / highlight tokens mirror Combobox.Item / Command.Item — the form-control surface family stays coherent. Disambiguation note (in index.ts comment): - Listbox: atomic options, text rows, no inner interactive elements (ARIA forbids interactive descendants inside role="listbox") - GridList: rows with buttons / links / checkboxes inside (2D nav) - Select / Combobox: closed picker surface (Listbox-like dropdown) Gotcha: listbox.svelte and listbox-item.svelte rename `children` to `bodyContent` on destructure to avoid shadowing the inner `{#snippet children}` block (same recursion trap documented in `feedback_button_consumer_pattern.md` Rule 3). Demo: 6 tabs at canonical depth — Live wires all soma + eidos props, all 3 ControlVariant chips, 5 size chips, 8 ColorRole chips, single + multi mode toggle, RTL/horizontal toggle. Sidebar entry added under Forms (between Combobox and Calendar). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>active-uix
parent
d58b684c5c
commit
80b21f63ba
@ -0,0 +1,69 @@
|
||||
// Listbox — eidos compound API.
|
||||
//
|
||||
// import { Listbox } from '$uix/eidos/components/listbox';
|
||||
//
|
||||
// <Listbox bind:value selectionMode="single">
|
||||
// <Listbox.Item value="apple">
|
||||
// <Listbox.ItemIndicator />
|
||||
// Apple
|
||||
// </Listbox.Item>
|
||||
// <Listbox.Item value="banana" disabled>
|
||||
// <Listbox.ItemIndicator />
|
||||
// Banana
|
||||
// </Listbox.Item>
|
||||
// <Listbox.Group>
|
||||
// <Listbox.GroupLabel>Citrus</Listbox.GroupLabel>
|
||||
// <Listbox.Item value="orange">
|
||||
// <Listbox.ItemIndicator />
|
||||
// Orange
|
||||
// </Listbox.Item>
|
||||
// </Listbox.Group>
|
||||
// </Listbox>
|
||||
//
|
||||
// Soma owns single/multi selection (value as string[]), roving-tabindex
|
||||
// keyboard nav (Arrow + Home/End + typeahead + Ctrl+A), Field
|
||||
// integration (disabled/readonly/required/invalid OR-merged), and
|
||||
// hidden form inputs. Eidos paints the visual surface and exposes
|
||||
// `variant` (ControlVariant — surface/outline/ghost), `size` (xs..xl),
|
||||
// `color` (ColorRole). The ItemIndicator ✓ glyph mirrors the shared
|
||||
// menu-indicator partial used by Dropdown/Context Menu CheckboxItems.
|
||||
//
|
||||
// Disambiguation: use Listbox for atomic options (text rows, no inner
|
||||
// interactive elements). For row-with-button/link/checkbox patterns
|
||||
// use `GridList` instead (ARIA forbids interactive descendants inside
|
||||
// role="listbox").
|
||||
import ListboxRoot from './listbox.svelte';
|
||||
import Item from './listbox-item.svelte';
|
||||
import ItemIndicator from './listbox-item-indicator.svelte';
|
||||
import Group from './listbox-group.svelte';
|
||||
import GroupLabel from './listbox-group-label.svelte';
|
||||
|
||||
type ListboxNamespace = typeof ListboxRoot & {
|
||||
Item: typeof Item;
|
||||
ItemIndicator: typeof ItemIndicator;
|
||||
Group: typeof Group;
|
||||
GroupLabel: typeof GroupLabel;
|
||||
};
|
||||
|
||||
const Listbox = ListboxRoot as ListboxNamespace;
|
||||
Listbox.Item = Item;
|
||||
Listbox.ItemIndicator = ItemIndicator;
|
||||
Listbox.Group = Group;
|
||||
Listbox.GroupLabel = GroupLabel;
|
||||
|
||||
export { Listbox };
|
||||
export default Listbox;
|
||||
|
||||
export type {
|
||||
ListboxProps,
|
||||
ListboxItemProps as ItemProps,
|
||||
ListboxItemIndicatorProps as ItemIndicatorProps,
|
||||
ListboxGroupProps as GroupProps,
|
||||
ListboxGroupLabelProps as GroupLabelProps,
|
||||
ListboxSize,
|
||||
ListboxVariant,
|
||||
ListboxColor,
|
||||
ListboxSelectionMode,
|
||||
ListboxProviderSnippetProps,
|
||||
ListboxItemSnippetProps
|
||||
} from './types';
|
||||
@ -0,0 +1,7 @@
|
||||
<script lang="ts">
|
||||
import * as Listbox from '$soma/components/listbox';
|
||||
import type { ListboxGroupLabelProps } from './types';
|
||||
let { children, ...rest }: ListboxGroupLabelProps = $props();
|
||||
</script>
|
||||
|
||||
<Listbox.GroupLabel {...rest}>{@render children?.()}</Listbox.GroupLabel>
|
||||
@ -0,0 +1,7 @@
|
||||
<script lang="ts">
|
||||
import * as Listbox from '$soma/components/listbox';
|
||||
import type { ListboxGroupProps } from './types';
|
||||
let { children, ...rest }: ListboxGroupProps = $props();
|
||||
</script>
|
||||
|
||||
<Listbox.Group {...rest}>{@render children?.()}</Listbox.Group>
|
||||
@ -0,0 +1,7 @@
|
||||
<script lang="ts">
|
||||
import * as Listbox from '$soma/components/listbox';
|
||||
import type { ListboxItemIndicatorProps } from './types';
|
||||
let { children, ...rest }: ListboxItemIndicatorProps = $props();
|
||||
</script>
|
||||
|
||||
<Listbox.ItemIndicator {...rest}>{@render children?.()}</Listbox.ItemIndicator>
|
||||
@ -0,0 +1,14 @@
|
||||
<script lang="ts">
|
||||
import * as Listbox from '$soma/components/listbox';
|
||||
import type { ListboxItemProps } from './types';
|
||||
// Rename `children` to `bodyContent` to avoid shadowing the inner
|
||||
// `{#snippet children}` block — same recursion gotcha documented in
|
||||
// `feedback_button_consumer_pattern.md`.
|
||||
let { children: bodyContent, ...rest }: ListboxItemProps = $props();
|
||||
</script>
|
||||
|
||||
<Listbox.Item {...rest}>
|
||||
{#snippet children(snippetProps)}
|
||||
{@render bodyContent?.(snippetProps)}
|
||||
{/snippet}
|
||||
</Listbox.Item>
|
||||
@ -0,0 +1,211 @@
|
||||
/*
|
||||
* Listbox recipe.
|
||||
*
|
||||
* [data-listbox] → root container
|
||||
* [data-listbox-item] → option row
|
||||
* [data-listbox-item-indicator] → ✓ glyph on selected items
|
||||
* [data-listbox-group] → group container
|
||||
* [data-listbox-group-label] → muted group label
|
||||
*
|
||||
* Sizes — xs..xl on the root; cascades to item height + font-size.
|
||||
* Variant `'surface' | 'outline' | 'ghost'` (ControlVariant).
|
||||
* Color cascades the accent for selected-item highlight + focus ring.
|
||||
*
|
||||
* Cross-component reuse:
|
||||
* - The ItemIndicator visual is the canonical check glyph — same as
|
||||
* [data-checkbox-indicator] / menu-item indicators. Painted here as
|
||||
* a filled accent square with white ✓ on selected items.
|
||||
*/
|
||||
|
||||
[data-listbox] {
|
||||
--_listbox-item-height: var(--control-height-md);
|
||||
--_listbox-item-px: var(--space-3);
|
||||
--_listbox-item-font-size: var(--font-size-sm);
|
||||
--_listbox-accent: var(--color-primary-solid);
|
||||
--_listbox-accent-soft: var(--color-primary-element);
|
||||
--_listbox-accent-text: var(--color-content-on-solid);
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-1);
|
||||
padding: var(--space-1);
|
||||
border: 1px solid var(--color-border-default);
|
||||
border-radius: var(--radius-md);
|
||||
background: var(--color-surface-default);
|
||||
color: var(--color-content-primary);
|
||||
font-family: var(--font-ui);
|
||||
font-size: var(--_listbox-item-font-size);
|
||||
line-height: var(--leading-ui);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
[data-listbox][data-block] {
|
||||
display: flex;
|
||||
inline-size: 100%;
|
||||
}
|
||||
|
||||
[data-listbox][data-orientation='horizontal'] {
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
/* ── Variant — surface (default) ─ */
|
||||
[data-listbox][data-variant='surface'] {
|
||||
background: var(--color-surface-default);
|
||||
border-color: var(--color-border-default);
|
||||
}
|
||||
|
||||
[data-listbox][data-variant='outline'] {
|
||||
background: transparent;
|
||||
border-color: var(--color-border-default);
|
||||
}
|
||||
|
||||
[data-listbox][data-variant='ghost'] {
|
||||
background: transparent;
|
||||
border-color: transparent;
|
||||
}
|
||||
|
||||
/* ── Sizes ─ */
|
||||
[data-listbox][data-size='xs'] {
|
||||
--_listbox-item-height: var(--control-height-xs);
|
||||
--_listbox-item-px: var(--space-2);
|
||||
--_listbox-item-font-size: var(--font-size-xs);
|
||||
}
|
||||
|
||||
[data-listbox][data-size='sm'] {
|
||||
--_listbox-item-height: var(--control-height-sm);
|
||||
--_listbox-item-px: var(--space-2);
|
||||
--_listbox-item-font-size: var(--font-size-sm);
|
||||
}
|
||||
|
||||
[data-listbox][data-size='lg'] {
|
||||
--_listbox-item-height: var(--control-height-lg);
|
||||
--_listbox-item-px: var(--space-4);
|
||||
--_listbox-item-font-size: var(--font-size-md);
|
||||
}
|
||||
|
||||
[data-listbox][data-size='xl'] {
|
||||
--_listbox-item-height: var(--control-height-xl);
|
||||
--_listbox-item-px: var(--space-5);
|
||||
--_listbox-item-font-size: var(--font-size-lg);
|
||||
}
|
||||
|
||||
/* ── Color cascades ─ */
|
||||
[data-listbox][data-color='secondary'] {
|
||||
--_listbox-accent: var(--color-secondary-solid);
|
||||
--_listbox-accent-soft: var(--color-secondary-element);
|
||||
}
|
||||
[data-listbox][data-color='affirm'] {
|
||||
--_listbox-accent: var(--color-affirm-solid);
|
||||
--_listbox-accent-soft: var(--color-affirm-element);
|
||||
}
|
||||
[data-listbox][data-color='risk'] {
|
||||
--_listbox-accent: var(--color-risk-solid);
|
||||
--_listbox-accent-soft: var(--color-risk-element);
|
||||
}
|
||||
[data-listbox][data-color='threat'] {
|
||||
--_listbox-accent: var(--color-threat-solid);
|
||||
--_listbox-accent-soft: var(--color-threat-element);
|
||||
}
|
||||
[data-listbox][data-color='fulfill'] {
|
||||
--_listbox-accent: var(--color-fulfill-solid);
|
||||
--_listbox-accent-soft: var(--color-fulfill-element);
|
||||
}
|
||||
[data-listbox][data-color='loss'] {
|
||||
--_listbox-accent: var(--color-loss-solid);
|
||||
--_listbox-accent-soft: var(--color-loss-element);
|
||||
}
|
||||
[data-listbox][data-color='neutral'] {
|
||||
--_listbox-accent: var(--color-neutral-solid);
|
||||
--_listbox-accent-soft: var(--color-neutral-element);
|
||||
}
|
||||
|
||||
[data-listbox][data-disabled] {
|
||||
opacity: 0.55;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
[data-listbox][data-invalid] {
|
||||
border-color: var(--color-threat-element);
|
||||
}
|
||||
|
||||
[data-listbox]:focus-visible,
|
||||
[data-listbox][data-focused] {
|
||||
outline: var(--focus-ring-width) solid var(--focus-ring-color);
|
||||
outline-offset: var(--focus-ring-offset);
|
||||
}
|
||||
|
||||
/* ── Item ─ */
|
||||
[data-listbox-item] {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-2);
|
||||
min-block-size: var(--_listbox-item-height);
|
||||
padding-block: var(--space-1);
|
||||
padding-inline: var(--_listbox-item-px);
|
||||
border-radius: var(--radius-sm);
|
||||
color: var(--color-content-primary);
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
transition:
|
||||
background var(--duration-fast) var(--ease-default),
|
||||
color var(--duration-fast) var(--ease-default);
|
||||
}
|
||||
|
||||
[data-listbox-item][data-highlighted]:not([data-disabled]) {
|
||||
background: var(--color-surface-overlay);
|
||||
}
|
||||
|
||||
[data-listbox-item][data-selected]:not([data-disabled]) {
|
||||
background: var(--_listbox-accent-soft);
|
||||
color: var(--color-content-primary);
|
||||
}
|
||||
|
||||
[data-listbox-item][data-selected][data-highlighted]:not([data-disabled]) {
|
||||
background: var(--_listbox-accent-soft);
|
||||
}
|
||||
|
||||
[data-listbox-item][data-disabled] {
|
||||
color: var(--color-content-muted);
|
||||
cursor: default;
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
/* ── ItemIndicator (✓ glyph on selected items) ─
|
||||
*
|
||||
* Painted as a 0.875rem filled-accent rounded square with white check —
|
||||
* same shape as the menu-indicator partial used by Dropdown/Context
|
||||
* Menu CheckboxItems. The ItemIndicator is rendered by the consumer
|
||||
* (soma emits the data-attr; visibility is gated to selected).
|
||||
*/
|
||||
[data-listbox-item-indicator] {
|
||||
display: none;
|
||||
inline-size: 0.875rem;
|
||||
block-size: 0.875rem;
|
||||
flex: 0 0 auto;
|
||||
color: var(--_listbox-accent);
|
||||
}
|
||||
|
||||
[data-listbox-item][data-selected] [data-listbox-item-indicator] {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
/* ── Group / GroupLabel ─ */
|
||||
[data-listbox-group] {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-1);
|
||||
}
|
||||
|
||||
[data-listbox-group-label] {
|
||||
padding-block: var(--space-1);
|
||||
padding-inline: var(--_listbox-item-px);
|
||||
color: var(--color-content-muted);
|
||||
font-size: var(--font-size-xs);
|
||||
font-weight: 500;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.04em;
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
<script lang="ts">
|
||||
/**
|
||||
* Eidos `<Listbox>` — visual wrapper over Soma's `<Listbox.Provider>`.
|
||||
*
|
||||
* <Listbox bind:value selectionMode="single">
|
||||
* <Listbox.Item value="apple">Apple</Listbox.Item>
|
||||
* <Listbox.Item value="banana">Banana</Listbox.Item>
|
||||
* <Listbox.Group>
|
||||
* <Listbox.GroupLabel>Citrus</Listbox.GroupLabel>
|
||||
* <Listbox.Item value="orange">Orange</Listbox.Item>
|
||||
* </Listbox.Group>
|
||||
* </Listbox>
|
||||
*
|
||||
* Soma owns single/multi selection, roving-tabindex keyboard nav
|
||||
* (Arrow / Home / End / typeahead / Ctrl+A), form participation,
|
||||
* Field integration. Eidos adds the visual surface (variant +
|
||||
* size + color) — Item rows reuse the option-row visuals shared
|
||||
* with Select / Combobox / Command.Item; ItemIndicator reuses the
|
||||
* menu-indicator partial (✓ glyph identical to standalone Checkbox).
|
||||
*/
|
||||
import { ActiveEidos } from '$uix/eidos';
|
||||
import * as Listbox from '$soma/components/listbox';
|
||||
import type { ListboxProps } from './types';
|
||||
|
||||
let {
|
||||
size = 'md',
|
||||
variant = 'surface',
|
||||
color = 'primary',
|
||||
block = false,
|
||||
value = $bindable([] as string[]),
|
||||
children: bodyContent,
|
||||
...rest
|
||||
}: ListboxProps = $props();
|
||||
|
||||
const eidos = ActiveEidos.require();
|
||||
const resolvedSize = $derived(eidos.resolve(size, 'md'));
|
||||
const resolvedVariant = $derived(eidos.resolve(variant, 'surface'));
|
||||
const resolvedColor = $derived(eidos.resolve(color, 'primary'));
|
||||
const resolvedBlock = $derived(eidos.resolve(block, false));
|
||||
</script>
|
||||
|
||||
<Listbox.Provider
|
||||
{...rest}
|
||||
bind:value
|
||||
data-size={resolvedSize}
|
||||
data-variant={resolvedVariant}
|
||||
data-color={resolvedColor}
|
||||
data-block={resolvedBlock ? '' : undefined}
|
||||
>
|
||||
{#snippet children(snippetProps)}
|
||||
{@render bodyContent?.(snippetProps)}
|
||||
{/snippet}
|
||||
</Listbox.Provider>
|
||||
@ -0,0 +1,42 @@
|
||||
import type { ColorRole, ControlVariant, ResponsiveProp, Size } from '$uix/eidos/lib/types';
|
||||
import type {
|
||||
ProviderProps,
|
||||
ItemProps,
|
||||
ItemIndicatorProps,
|
||||
GroupProps,
|
||||
GroupLabelProps,
|
||||
ProviderSnippetProps,
|
||||
ItemSnippetProps,
|
||||
ListboxSelectionMode
|
||||
} from '$soma/components/listbox';
|
||||
|
||||
/**
|
||||
* Listbox visual size — five-step subset matching the rest of the
|
||||
* form-control family (Select, Combobox, Field, etc.).
|
||||
*/
|
||||
export type ListboxSize = Extract<Size, 'xs' | 'sm' | 'md' | 'lg' | 'xl'>;
|
||||
|
||||
export type ListboxVariant = ControlVariant;
|
||||
export type ListboxColor = ColorRole;
|
||||
|
||||
export type ListboxProps = ProviderProps & {
|
||||
/** Visual size — drives item height + font-size. @default 'md' */
|
||||
size?: ResponsiveProp<ListboxSize>;
|
||||
/** Container chrome variant. @default 'surface' */
|
||||
variant?: ListboxVariant;
|
||||
/** Accent palette for selected items + focus ring. @default 'primary' */
|
||||
color?: ListboxColor;
|
||||
/** Stretch to fill the container's inline-size. @default false */
|
||||
block?: boolean;
|
||||
};
|
||||
|
||||
export type ListboxItemProps = ItemProps;
|
||||
export type ListboxItemIndicatorProps = ItemIndicatorProps;
|
||||
export type ListboxGroupProps = GroupProps;
|
||||
export type ListboxGroupLabelProps = GroupLabelProps;
|
||||
|
||||
export type {
|
||||
ProviderSnippetProps as ListboxProviderSnippetProps,
|
||||
ItemSnippetProps as ListboxItemSnippetProps,
|
||||
ListboxSelectionMode
|
||||
};
|
||||
@ -0,0 +1,601 @@
|
||||
<script lang="ts">
|
||||
import {
|
||||
Listbox,
|
||||
type ListboxSize,
|
||||
type ListboxVariant,
|
||||
type ListboxColor,
|
||||
type ListboxSelectionMode
|
||||
} from '$uix/eidos/components/listbox';
|
||||
import { compileMorfo } from '$uix/morfo';
|
||||
import { listboxMorfo } from '@/uix/morfo/components/listbox';
|
||||
import { getActiveUix } from '$active-uix';
|
||||
|
||||
const uix = getActiveUix();
|
||||
|
||||
type Tab = 'live' | 'api' | 'morfo' | 'sema' | 'recipe' | 'a11y';
|
||||
let tab = $state<Tab>('live');
|
||||
|
||||
// ── Live state ────────────────────────────────────────────────────────
|
||||
let value = $state<string[]>(['banana']);
|
||||
let selectionMode = $state<ListboxSelectionMode>('single');
|
||||
let size = $state<ListboxSize>('md');
|
||||
let variant = $state<ListboxVariant>('surface');
|
||||
let color = $state<ListboxColor>('primary');
|
||||
let orientation = $state<'vertical' | 'horizontal'>('vertical');
|
||||
let loop = $state(true);
|
||||
let typeahead = $state(true);
|
||||
let disabled = $state(false);
|
||||
let invalid = $state(false);
|
||||
let block = $state(false);
|
||||
|
||||
type TraceEntry = { event: string; family: string; intent?: string; at: number };
|
||||
let trace = $state<TraceEntry[]>([]);
|
||||
let stageRef = $state<HTMLElement | null>(null);
|
||||
|
||||
$effect(() => {
|
||||
const el = stageRef;
|
||||
if (!el) return;
|
||||
const obs = new MutationObserver((mutations) => {
|
||||
for (const m of mutations) {
|
||||
if (m.attributeName !== 'data-event') continue;
|
||||
const target = m.target as Element;
|
||||
const ev = target.getAttribute('data-event');
|
||||
if (!ev) continue;
|
||||
trace = [
|
||||
{
|
||||
event: ev,
|
||||
family: target.getAttribute('data-event-family') ?? '—',
|
||||
intent: target.getAttribute('data-event-intent') ?? undefined,
|
||||
at: Date.now()
|
||||
},
|
||||
...trace
|
||||
].slice(0, 6);
|
||||
}
|
||||
});
|
||||
obs.observe(el, { attributes: true, subtree: true, attributeFilter: ['data-event'] });
|
||||
return () => obs.disconnect();
|
||||
});
|
||||
|
||||
const compiled = compileMorfo(listboxMorfo);
|
||||
const partsList = $derived([...compiled.parts.byKebab.values()]);
|
||||
const events = $derived([...compiled.actions.byName.values()]);
|
||||
|
||||
function fmtTime(at: number): string {
|
||||
const d = new Date(at);
|
||||
return `${String(d.getSeconds()).padStart(2, '0')}.${String(d.getMilliseconds()).padStart(3, '0')}`;
|
||||
}
|
||||
|
||||
const somaSnippet = $derived(
|
||||
[
|
||||
"<script lang='ts'>",
|
||||
" import * as Listbox from '$soma/components/listbox';",
|
||||
' let value = $state<string[]>([]);',
|
||||
'</' + 'script>',
|
||||
'',
|
||||
'<Listbox.Provider',
|
||||
' bind:value',
|
||||
selectionMode !== 'single' && ` selectionMode="${selectionMode}"`,
|
||||
orientation !== 'vertical' && ` orientation="${orientation}"`,
|
||||
!loop && ' loop={false}',
|
||||
!typeahead && ' typeahead={false}',
|
||||
disabled && ' disabled',
|
||||
invalid && ' invalid',
|
||||
'>',
|
||||
' <Listbox.Item value="apple">Apple</Listbox.Item>',
|
||||
' <Listbox.Item value="banana">Banana</Listbox.Item>',
|
||||
' <Listbox.Item value="cherry" disabled>Cherry</Listbox.Item>',
|
||||
'</Listbox.Provider>'
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join('\n')
|
||||
);
|
||||
|
||||
const eidosSnippet = $derived(
|
||||
[
|
||||
"<script lang='ts'>",
|
||||
" import { Listbox } from '$uix/eidos/components/listbox';",
|
||||
' let value = $state<string[]>([]);',
|
||||
'</' + 'script>',
|
||||
'',
|
||||
'<Listbox',
|
||||
' bind:value',
|
||||
selectionMode !== 'single' && ` selectionMode="${selectionMode}"`,
|
||||
size !== 'md' && ` size="${size}"`,
|
||||
variant !== 'surface' && ` variant="${variant}"`,
|
||||
color !== 'primary' && ` color="${color}"`,
|
||||
orientation !== 'vertical' && ` orientation="${orientation}"`,
|
||||
!loop && ' loop={false}',
|
||||
block && ' block',
|
||||
disabled && ' disabled',
|
||||
invalid && ' invalid',
|
||||
'>',
|
||||
' <Listbox.Item value="apple">',
|
||||
' <Listbox.ItemIndicator />',
|
||||
' Apple',
|
||||
' </Listbox.Item>',
|
||||
' <Listbox.Item value="banana">',
|
||||
' <Listbox.ItemIndicator />',
|
||||
' Banana',
|
||||
' </Listbox.Item>',
|
||||
' <Listbox.Group>',
|
||||
' <Listbox.GroupLabel>Citrus</Listbox.GroupLabel>',
|
||||
' <Listbox.Item value="orange">Orange</Listbox.Item>',
|
||||
' </Listbox.Group>',
|
||||
'</Listbox>'
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join('\n')
|
||||
);
|
||||
</script>
|
||||
|
||||
<div data-uix-canvas-inner>
|
||||
<header>
|
||||
<div data-uix-eyebrow>Forms · Listbox</div>
|
||||
<h1 data-uix-page-title>Listbox</h1>
|
||||
<p data-uix-page-lede>
|
||||
Embedded selection list (<code>role="listbox"</code>) with single
|
||||
or multiple selection, roving-tabindex keyboard nav, alphanumeric
|
||||
typeahead, ARIA-grouped sections, and form participation. Soma
|
||||
OR-merges <code>disabled</code> / <code>readonly</code> /
|
||||
<code>required</code> / <code>invalid</code> with
|
||||
<code>Field.Provider</code> when nested. For atomic options
|
||||
only — use <code>GridList</code> when rows contain interactive
|
||||
children, or <code>Select</code> / <code>Combobox</code> when
|
||||
the surface is a closed combobox-style picker.
|
||||
</p>
|
||||
<div data-uix-page-meta>
|
||||
<span data-uix-meta-pill>
|
||||
<span data-uix-meta-key>parts</span>{compiled.parts.order.length}
|
||||
</span>
|
||||
<span data-uix-meta-pill>
|
||||
<span data-uix-meta-key>events</span>{events.length}
|
||||
</span>
|
||||
<span data-uix-meta-pill>
|
||||
<span data-uix-meta-key>sizes</span>5
|
||||
</span>
|
||||
<span data-uix-meta-pill>
|
||||
<span data-uix-meta-key>apg</span>
|
||||
<a href={listboxMorfo.apg} target="_blank" rel="noreferrer">listbox ↗</a>
|
||||
</span>
|
||||
<span data-uix-meta-pill>
|
||||
<span data-uix-meta-key>selected</span> {value.join(', ') || '—'}
|
||||
</span>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div data-uix-stage>
|
||||
<div data-uix-stage-area bind:this={stageRef} style="min-block-size: 14rem; padding: var(--uix-space-3); display: flex; justify-content: center;">
|
||||
<div style="inline-size: min(20rem, 100%);">
|
||||
<Listbox
|
||||
bind:value
|
||||
{selectionMode}
|
||||
{size}
|
||||
{variant}
|
||||
{color}
|
||||
{orientation}
|
||||
{loop}
|
||||
{typeahead}
|
||||
{disabled}
|
||||
{invalid}
|
||||
{block}
|
||||
>
|
||||
<Listbox.Item value="apple">
|
||||
<Listbox.ItemIndicator />
|
||||
Apple
|
||||
</Listbox.Item>
|
||||
<Listbox.Item value="banana">
|
||||
<Listbox.ItemIndicator />
|
||||
Banana
|
||||
</Listbox.Item>
|
||||
<Listbox.Item value="cherry" disabled>
|
||||
<Listbox.ItemIndicator />
|
||||
Cherry (disabled)
|
||||
</Listbox.Item>
|
||||
<Listbox.Group>
|
||||
<Listbox.GroupLabel>Citrus</Listbox.GroupLabel>
|
||||
<Listbox.Item value="orange">
|
||||
<Listbox.ItemIndicator />
|
||||
Orange
|
||||
</Listbox.Item>
|
||||
<Listbox.Item value="lemon">
|
||||
<Listbox.ItemIndicator />
|
||||
Lemon
|
||||
</Listbox.Item>
|
||||
<Listbox.Item value="grapefruit">
|
||||
<Listbox.ItemIndicator />
|
||||
Grapefruit
|
||||
</Listbox.Item>
|
||||
</Listbox.Group>
|
||||
<Listbox.Group>
|
||||
<Listbox.GroupLabel>Berries</Listbox.GroupLabel>
|
||||
<Listbox.Item value="strawberry">
|
||||
<Listbox.ItemIndicator />
|
||||
Strawberry
|
||||
</Listbox.Item>
|
||||
<Listbox.Item value="blueberry">
|
||||
<Listbox.ItemIndicator />
|
||||
Blueberry
|
||||
</Listbox.Item>
|
||||
</Listbox.Group>
|
||||
</Listbox>
|
||||
</div>
|
||||
</div>
|
||||
<div data-uix-stage-trace>
|
||||
<span data-uix-stage-trace-key>trace</span>
|
||||
{#if trace.length === 0}
|
||||
<span>focus the listbox + arrow / type to highlight</span>
|
||||
{:else}
|
||||
{#each trace.slice(0, 3) as entry (entry.at)}
|
||||
<span><span data-uix-stage-trace-event>{entry.event}</span> · {entry.family}{entry.intent ? ' · ' + entry.intent : ''}</span>
|
||||
<span style="color: var(--uix-text-faint)">{fmtTime(entry.at)}</span>
|
||||
{/each}
|
||||
{/if}
|
||||
<span style="margin-inline-start: auto;">
|
||||
<span data-uix-stage-trace-key>value</span> [{value.join(', ')}]
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div data-uix-tabs role="tablist">
|
||||
<button data-uix-tab data-active={tab === 'live'} onclick={() => (tab = 'live')}>Live</button>
|
||||
<button data-uix-tab data-active={tab === 'api'} onclick={() => (tab = 'api')}>
|
||||
API <span data-uix-tab-count>5</span>
|
||||
</button>
|
||||
<button data-uix-tab data-active={tab === 'morfo'} onclick={() => (tab = 'morfo')}>
|
||||
<span data-uix-layer-badge="morfo">morfo</span>
|
||||
<span data-uix-tab-count>{partsList.length}p · {events.length}e</span>
|
||||
</button>
|
||||
<button data-uix-tab data-active={tab === 'sema'} onclick={() => (tab = 'sema')}>
|
||||
<span data-uix-layer-badge="sema">sema</span>
|
||||
<span data-uix-tab-count>{events.length}</span>
|
||||
</button>
|
||||
<button data-uix-tab data-active={tab === 'recipe'} onclick={() => (tab = 'recipe')}>Recipe</button>
|
||||
<button data-uix-tab data-active={tab === 'a11y'} onclick={() => (tab = 'a11y')}>A11y</button>
|
||||
</div>
|
||||
|
||||
{#if tab === 'live'}
|
||||
<section data-uix-section>
|
||||
<h2 data-uix-section-title>Controls</h2>
|
||||
<p data-uix-section-desc>
|
||||
Soma owns selection + nav + typeahead. Eidos adds
|
||||
<code>variant</code> / <code>size</code> / <code>color</code> chrome.
|
||||
</p>
|
||||
|
||||
<div data-uix-subsection-head>
|
||||
<span data-uix-layer-badge="soma">soma</span> Provider props
|
||||
</div>
|
||||
<div data-uix-controls>
|
||||
<label data-uix-control>
|
||||
<span data-uix-control-label>selectionMode</span>
|
||||
<span data-uix-chips role="radiogroup">
|
||||
{#each ['single', 'multiple'] as m (m)}
|
||||
<button data-uix-chip data-active={selectionMode === m} onclick={() => (selectionMode = m as ListboxSelectionMode)}>{m}</button>
|
||||
{/each}
|
||||
</span>
|
||||
</label>
|
||||
<label data-uix-control>
|
||||
<span data-uix-control-label>orientation</span>
|
||||
<span data-uix-chips role="radiogroup">
|
||||
{#each ['vertical', 'horizontal'] as o (o)}
|
||||
<button data-uix-chip data-active={orientation === o} onclick={() => (orientation = o as typeof orientation)}>{o}</button>
|
||||
{/each}
|
||||
</span>
|
||||
</label>
|
||||
<label data-uix-control>
|
||||
<span data-uix-control-label>loop</span>
|
||||
<span data-uix-switch>
|
||||
<input type="checkbox" bind:checked={loop} />
|
||||
<span data-uix-switch-label>{loop ? 'on' : 'off'}</span>
|
||||
</span>
|
||||
</label>
|
||||
<label data-uix-control>
|
||||
<span data-uix-control-label>typeahead</span>
|
||||
<span data-uix-switch>
|
||||
<input type="checkbox" bind:checked={typeahead} />
|
||||
<span data-uix-switch-label>{typeahead ? 'on' : 'off'}</span>
|
||||
</span>
|
||||
</label>
|
||||
<label data-uix-control>
|
||||
<span data-uix-control-label>disabled</span>
|
||||
<span data-uix-switch>
|
||||
<input type="checkbox" bind:checked={disabled} />
|
||||
<span data-uix-switch-label>{disabled ? 'on' : 'off'}</span>
|
||||
</span>
|
||||
</label>
|
||||
<label data-uix-control>
|
||||
<span data-uix-control-label>invalid</span>
|
||||
<span data-uix-switch>
|
||||
<input type="checkbox" bind:checked={invalid} />
|
||||
<span data-uix-switch-label>{invalid ? 'on' : 'off'}</span>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div data-uix-subsection-head>
|
||||
<span data-uix-layer-badge="eidos">eidos</span> visual props
|
||||
</div>
|
||||
<div data-uix-controls>
|
||||
<label data-uix-control>
|
||||
<span data-uix-control-label>variant <span data-uix-control-hint>ControlVariant</span></span>
|
||||
<span data-uix-chips role="radiogroup">
|
||||
{#each ['surface', 'outline', 'ghost'] as v (v)}
|
||||
<button data-uix-chip data-active={variant === v} onclick={() => (variant = v as ListboxVariant)}>{v}</button>
|
||||
{/each}
|
||||
</span>
|
||||
</label>
|
||||
<label data-uix-control>
|
||||
<span data-uix-control-label>size</span>
|
||||
<span data-uix-chips role="radiogroup">
|
||||
{#each ['xs', 'sm', 'md', 'lg', 'xl'] as s (s)}
|
||||
<button data-uix-chip data-active={size === s} onclick={() => (size = s as ListboxSize)}>{s}</button>
|
||||
{/each}
|
||||
</span>
|
||||
</label>
|
||||
<label data-uix-control>
|
||||
<span data-uix-control-label>color</span>
|
||||
<span data-uix-chips role="radiogroup">
|
||||
{#each ['primary', 'secondary', 'neutral', 'affirm', 'fulfill', 'risk', 'threat', 'loss'] as c (c)}
|
||||
<button data-uix-chip data-active={color === c} onclick={() => (color = c as ListboxColor)}>{c}</button>
|
||||
{/each}
|
||||
</span>
|
||||
</label>
|
||||
<label data-uix-control>
|
||||
<span data-uix-control-label>block</span>
|
||||
<span data-uix-switch>
|
||||
<input type="checkbox" bind:checked={block} />
|
||||
<span data-uix-switch-label>{block ? 'on' : 'off'}</span>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div data-uix-code>
|
||||
<div data-uix-code-head>
|
||||
<span data-uix-layer-badge="soma">soma</span>
|
||||
<span>headless · selection + keyboard + Field merge</span>
|
||||
<span data-uix-code-lang>svelte</span>
|
||||
</div>
|
||||
<pre><code>{somaSnippet}</code></pre>
|
||||
</div>
|
||||
|
||||
<div data-uix-code style="margin-top: var(--uix-space-3);">
|
||||
<div data-uix-code-head>
|
||||
<span data-uix-layer-badge="eidos">eidos</span>
|
||||
<span>visual · variant + size + color</span>
|
||||
<span data-uix-code-lang>svelte</span>
|
||||
</div>
|
||||
<pre><code>{eidosSnippet}</code></pre>
|
||||
</div>
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
{#if tab === 'api'}
|
||||
<section data-uix-section>
|
||||
<h2 data-uix-section-title>API reference</h2>
|
||||
<p data-uix-section-desc>5 parts: Root, Item, ItemIndicator, Group, GroupLabel.</p>
|
||||
|
||||
<div data-uix-subsection-head>Root (Listbox)</div>
|
||||
<div data-uix-table-wrap>
|
||||
<table data-uix-table>
|
||||
<thead><tr><th>Prop</th><th>Type</th><th>Default</th><th>Description</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td class="name">value <span data-uix-tag data-kind="bindable">bindable</span></td><td class="type">string[]</td><td class="default">[]</td><td>Current selection. Always string[]; single mode keeps at most one entry.</td></tr>
|
||||
<tr><td class="name">selectionMode</td><td class="type">'single' | 'multiple'</td><td class="default">'single'</td><td>Selection behavior.</td></tr>
|
||||
<tr><td class="name">loop</td><td class="type">boolean</td><td class="default">true</td><td>Wrap arrow nav at edges.</td></tr>
|
||||
<tr><td class="name">typeahead</td><td class="type">boolean</td><td class="default">true</td><td>Alphanumeric jump-to-item.</td></tr>
|
||||
<tr><td class="name">orientation</td><td class="type">'vertical' | 'horizontal'</td><td class="default">'vertical'</td><td>Arrow nav axis.</td></tr>
|
||||
<tr><td class="name">disabled · readonly · required · invalid</td><td class="type">boolean</td><td class="default">false</td><td>OR-merged with Field.Provider when nested.</td></tr>
|
||||
<tr><td class="name">name</td><td class="type">string</td><td class="default empty">—</td><td>Form name → hidden inputs per selected value.</td></tr>
|
||||
<tr><td class="name">variant <span data-uix-tag data-kind="eidos">eidos</span></td><td class="type">ControlVariant: 'surface' | 'outline' | 'ghost'</td><td class="default">'surface'</td><td>Container chrome.</td></tr>
|
||||
<tr><td class="name">size <span data-uix-tag data-kind="eidos">eidos</span></td><td class="type">'xs' | 'sm' | 'md' | 'lg' | 'xl'</td><td class="default">'md'</td><td>Item height + font-size.</td></tr>
|
||||
<tr><td class="name">color <span data-uix-tag data-kind="eidos">eidos</span></td><td class="type">ColorRole</td><td class="default">'primary'</td><td>Selected-item highlight + focus ring accent.</td></tr>
|
||||
<tr><td class="name">block <span data-uix-tag data-kind="eidos">eidos</span></td><td class="type">boolean</td><td class="default">false</td><td>Fill container's inline-size.</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div data-uix-subsection-head>Item</div>
|
||||
<div data-uix-table-wrap>
|
||||
<table data-uix-table>
|
||||
<thead><tr><th>Prop</th><th>Type</th><th>Default</th><th>Description</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td class="name">value</td><td class="type">string</td><td class="default empty">required</td><td>Unique identifier in the listbox.</td></tr>
|
||||
<tr><td class="name">disabled</td><td class="type">boolean</td><td class="default">false</td><td>Skip the item from keyboard nav + click selection.</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div data-uix-subsection-head>ItemIndicator · Group · GroupLabel</div>
|
||||
<p data-uix-section-desc style="margin-top: 0.25rem;">
|
||||
<code>ItemIndicator</code> renders a ✓ glyph inside selected items
|
||||
(same recipe as menu-indicator partial). <code>Group</code> wraps a
|
||||
logical section; <code>GroupLabel</code> is the muted heading
|
||||
(ARIA-linked via <code>aria-labelledby</code>).
|
||||
</p>
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
{#if tab === 'morfo'}
|
||||
<section data-uix-section>
|
||||
<h2 data-uix-section-title>
|
||||
<span data-uix-layer-badge="morfo">morfo</span>
|
||||
· declarative contract
|
||||
</h2>
|
||||
<p data-uix-section-desc>Source: <code>src/uix/morfo/components/listbox.ts</code>.</p>
|
||||
|
||||
<div data-uix-table-wrap>
|
||||
<table data-uix-table>
|
||||
<thead><tr><th>Field</th><th>Value</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td class="name">name</td><td class="type">"{listboxMorfo.name}"</td></tr>
|
||||
<tr><td class="name">kebab</td><td class="type">"{listboxMorfo.kebab}"</td></tr>
|
||||
<tr><td class="name">scope</td><td class="type">[{listboxMorfo.scope.map((s) => `"${s}"`).join(', ')}]</td></tr>
|
||||
<tr><td class="name">apg</td><td><a href={listboxMorfo.apg} target="_blank" rel="noreferrer">{listboxMorfo.apg}</a></td></tr>
|
||||
<tr><td class="name">parts.length</td><td class="default">{listboxMorfo.parts.length}</td></tr>
|
||||
<tr><td class="name">events.length</td><td class="default">{events.length}</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div data-uix-subsection-head>Parts</div>
|
||||
<div data-uix-table-wrap>
|
||||
<table data-uix-table>
|
||||
<thead><tr><th>Part</th><th>Marker</th><th>Element</th><th>Role</th><th>Archetype</th><th>States</th><th>Optional</th></tr></thead>
|
||||
<tbody>
|
||||
{#each partsList as part (part.kebab)}
|
||||
<tr>
|
||||
<td class="name">{part.kebab}</td>
|
||||
<td><code data-uix-part-marker>[{part.marker}]</code></td>
|
||||
<td class="type"><{part.defaultElement}></td>
|
||||
<td class="type">{part.role ?? '—'}</td>
|
||||
<td class="default">{part.archetype ?? '—'}</td>
|
||||
<td class="default">{part.states.length ? part.states.join(' | ') : '—'}</td>
|
||||
<td class="default">{part.optional ? 'yes' : 'no'}</td>
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div data-uix-subsection-head>Events declaration</div>
|
||||
<div data-uix-table-wrap>
|
||||
<table data-uix-table>
|
||||
<thead><tr><th>name</th><th>family</th><th>verb</th><th>sequence</th><th>intent</th><th>target</th></tr></thead>
|
||||
<tbody>
|
||||
{#each events as action (action.name)}
|
||||
{@const sem = action.semantic}
|
||||
{@const intentDecl = 'intent' in sem ? sem.intent : undefined}
|
||||
{@const intentStr = typeof intentDecl === 'string' ? intentDecl : intentDecl ? `fromProp:${(intentDecl as { fromProp?: string }).fromProp ?? '?'}` : '—'}
|
||||
<tr>
|
||||
<td class="name">{action.name}</td>
|
||||
<td class="type">{sem.family}</td>
|
||||
<td>{sem.verb ?? '—'}</td>
|
||||
<td>{sem.sequence ?? 'pre'}</td>
|
||||
<td class="default">{intentStr}</td>
|
||||
<td>{action.target}</td>
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
{#if tab === 'sema'}
|
||||
<section data-uix-section id="sema">
|
||||
<h2 data-uix-section-title>
|
||||
<span data-uix-layer-badge="sema">sema</span>
|
||||
· events
|
||||
</h2>
|
||||
<p data-uix-section-desc>
|
||||
Two events: <code>commit-select</code> (intent <code>affirm</code>)
|
||||
when an item enters the selection; <code>commit-unselect</code>
|
||||
(intent <code>neutral</code>) when it leaves.
|
||||
</p>
|
||||
|
||||
<div data-uix-table-wrap>
|
||||
<table data-uix-table>
|
||||
<thead><tr><th>Name</th><th>Family</th><th>Verb</th><th>Sequence</th><th>Intent</th><th>Play</th></tr></thead>
|
||||
<tbody>
|
||||
{#each events as action (action.name)}
|
||||
{@const intentDecl = 'intent' in action.semantic ? action.semantic.intent : undefined}
|
||||
{@const effectiveIntent = typeof intentDecl === 'string' ? intentDecl : undefined}
|
||||
<tr>
|
||||
<td class="name">{action.name}</td>
|
||||
<td class="type">{action.semantic.family}</td>
|
||||
<td>{action.semantic.verb ?? '—'}</td>
|
||||
<td>{action.semantic.sequence ?? 'pre'}</td>
|
||||
<td class="default">{effectiveIntent ?? '—'}</td>
|
||||
<td>
|
||||
<button
|
||||
data-uix-play
|
||||
onclick={() => {
|
||||
const target = (stageRef?.querySelector('[data-listbox-item]') ?? stageRef) as HTMLElement | null;
|
||||
if (!target) return;
|
||||
void uix.events?.emit({
|
||||
name: action.name,
|
||||
family: action.semantic.family,
|
||||
target,
|
||||
...(effectiveIntent ? { intent: effectiveIntent } : {})
|
||||
});
|
||||
}}
|
||||
>▶ play</button>
|
||||
</td>
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
{#if tab === 'recipe'}
|
||||
<section data-uix-section>
|
||||
<h2 data-uix-section-title>Eidos recipe</h2>
|
||||
<p data-uix-section-desc>Selectors at <code>src/uix/eidos/components/listbox/listbox.css</code>.</p>
|
||||
<div data-uix-table-wrap>
|
||||
<table data-uix-table>
|
||||
<thead><tr><th>Selector</th><th>Source</th><th>What it paints</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td class="name">[data-listbox]</td><td><span data-uix-tag data-kind="eidos">eidos</span></td><td>Container — flex column, gap, border, padding.</td></tr>
|
||||
<tr><td class="name">[data-listbox][data-size]</td><td><span data-uix-tag data-kind="eidos">eidos</span></td><td>Item height + font-size scale.</td></tr>
|
||||
<tr><td class="name">[data-listbox][data-variant='outline' | 'ghost']</td><td><span data-uix-tag data-kind="eidos">eidos</span></td><td>Container chrome (border + bg).</td></tr>
|
||||
<tr><td class="name">[data-listbox][data-color]</td><td><span data-uix-tag data-kind="eidos">eidos</span></td><td>Accent palette for selected highlight + focus ring.</td></tr>
|
||||
<tr><td class="name">[data-listbox][data-invalid]</td><td><span data-uix-tag data-kind="soma">morfo</span></td><td>Threat-coloured border override.</td></tr>
|
||||
<tr><td class="name">[data-listbox-item]</td><td><span data-uix-tag data-kind="soma">morfo</span></td><td>Option row — flex, padding, hover/highlight states.</td></tr>
|
||||
<tr><td class="name">[data-listbox-item][data-selected]</td><td><span data-uix-tag data-kind="soma">morfo</span></td><td>Selected-state band (accent-soft fill).</td></tr>
|
||||
<tr><td class="name">[data-listbox-item-indicator]</td><td><span data-uix-tag data-kind="soma">morfo</span></td><td>Hidden by default; revealed inside selected items.</td></tr>
|
||||
<tr><td class="name">[data-listbox-group-label]</td><td><span data-uix-tag data-kind="soma">morfo</span></td><td>Muted uppercase section heading.</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
{#if tab === 'a11y'}
|
||||
<section data-uix-section>
|
||||
<h2 data-uix-section-title>Accessibility</h2>
|
||||
<p data-uix-section-desc>
|
||||
Follows the APG <a href={listboxMorfo.apg} target="_blank" rel="noreferrer">listbox pattern</a>.
|
||||
Container is <code>role="listbox"</code>; each Item is
|
||||
<code>role="option"</code> with <code>aria-selected</code>;
|
||||
Group is <code>role="group"</code> with
|
||||
<code>aria-labelledby</code> pointing to GroupLabel.
|
||||
<code>aria-multiselectable</code> is stamped automatically
|
||||
in <code>multiple</code> mode.
|
||||
</p>
|
||||
|
||||
<div data-uix-subsection-head>Keyboard</div>
|
||||
<div data-uix-table-wrap>
|
||||
<table data-uix-table>
|
||||
<thead><tr><th>Key</th><th>Action</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td><span data-uix-kbd>ArrowDown</span> / <span data-uix-kbd>ArrowUp</span></td><td>Move highlight ±1 (vertical orientation).</td></tr>
|
||||
<tr><td><span data-uix-kbd>ArrowRight</span> / <span data-uix-kbd>ArrowLeft</span></td><td>Same but for horizontal orientation; RTL inverts.</td></tr>
|
||||
<tr><td><span data-uix-kbd>Home</span> / <span data-uix-kbd>End</span></td><td>First / last item.</td></tr>
|
||||
<tr><td><span data-uix-kbd>Enter</span> / <span data-uix-kbd>Space</span></td><td>Toggle selection of highlighted item.</td></tr>
|
||||
<tr><td><span data-uix-kbd>Ctrl/Cmd+A</span></td><td>Select all (multiple mode only).</td></tr>
|
||||
<tr><td>Letter / digit</td><td>Typeahead — focus next item starting with that character.</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div data-uix-subsection-head>ARIA contract</div>
|
||||
<div data-uix-table-wrap>
|
||||
<table data-uix-table>
|
||||
<thead><tr><th>Part</th><th>Attribute</th><th>Value</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td class="name">listbox</td><td>role</td><td class="type">"listbox"</td></tr>
|
||||
<tr><td class="name">listbox</td><td>aria-multiselectable</td><td class="type">"true" (multiple mode)</td></tr>
|
||||
<tr><td class="name">listbox</td><td>aria-orientation</td><td class="type">"horizontal" | "vertical"</td></tr>
|
||||
<tr><td class="name">listbox</td><td>aria-disabled / aria-readonly / aria-required / aria-invalid</td><td class="type">flags</td></tr>
|
||||
<tr><td class="name">item</td><td>role</td><td class="type">"option"</td></tr>
|
||||
<tr><td class="name">item</td><td>aria-selected</td><td class="type">"true" | "false"</td></tr>
|
||||
<tr><td class="name">item</td><td>aria-disabled</td><td class="type">"true" (disabled)</td></tr>
|
||||
<tr><td class="name">group</td><td>role</td><td class="type">"group"</td></tr>
|
||||
<tr><td class="name">group</td><td>aria-labelledby</td><td class="type">{`<group-label id>`}</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
{/if}
|
||||
</div>
|
||||
Loading…
Reference in new issue