You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
602 lines
25 KiB
602 lines
25 KiB
<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>
|