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.
600 lines
25 KiB
600 lines
25 KiB
<script lang="ts">
|
|
import Toggle, {
|
|
type ToggleVariant,
|
|
type ToggleSize
|
|
} from '$uix/eidos/components/toggle';
|
|
import { compileMorfo } from '$uix/morfo';
|
|
import { toggleMorfo } from '@/uix/morfo/components/toggle';
|
|
import { getActiveUix } from '$active-uix';
|
|
import { page } from '$app/state';
|
|
|
|
const uix = getActiveUix();
|
|
const params = page.url.searchParams;
|
|
|
|
type Tab = 'live' | 'api' | 'morfo' | 'sema' | 'recipe' | 'a11y';
|
|
let tab = $state<Tab>('live');
|
|
|
|
// ── State ──────────────────────────────────────────────────────────────
|
|
let pressed = $state(false);
|
|
let disabled = $state(params.get('perm.disabled') === 'true');
|
|
let readonly = $state(false);
|
|
let required = $state(false);
|
|
let invalid = $state(params.get('perm.invalid') === 'true');
|
|
let intent = $state<'neutral' | 'affirm' | 'risk' | 'threat'>('neutral');
|
|
let color = $state<'primary' | 'secondary' | ''>('');
|
|
let size = $state<ToggleSize>('md');
|
|
let variant = $state<ToggleVariant>('solid');
|
|
let block = $state(false);
|
|
let iconOnly = $state(false);
|
|
let showIcon = $state(false);
|
|
let showCheckMark = $state(false);
|
|
let labelText = $state('Bold');
|
|
let nameAttr = $state('bold');
|
|
let valueAttr = $state('on');
|
|
let ariaLabel = $state('');
|
|
|
|
let lastFormSubmit = $state<Record<string, unknown> | null>(null);
|
|
|
|
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(toggleMorfo);
|
|
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')}`;
|
|
}
|
|
|
|
function handleSubmit(e: SubmitEvent) {
|
|
e.preventDefault();
|
|
const data = new FormData(e.currentTarget as HTMLFormElement);
|
|
const obj: Record<string, unknown> = {};
|
|
for (const [k, v] of data.entries()) obj[k] = v;
|
|
lastFormSubmit = obj;
|
|
}
|
|
|
|
// Soma snippet — headless usage
|
|
const somaSnippet = $derived(
|
|
[
|
|
"<script lang='ts'>",
|
|
" import { Provider as Toggle } from '$soma/components/toggle';",
|
|
' let pressed = $state(false);',
|
|
'</' + 'script>',
|
|
'',
|
|
'<Toggle',
|
|
' bind:pressed',
|
|
intent !== 'neutral' && ` intent="${intent}"`,
|
|
color && ` color="${color}"`,
|
|
disabled && ' disabled',
|
|
readonly && ' readonly',
|
|
required && ' required',
|
|
invalid && ' invalid',
|
|
nameAttr && ` name="${nameAttr}"`,
|
|
valueAttr !== 'on' && ` value="${valueAttr}"`,
|
|
ariaLabel && ` aria-label="${ariaLabel}"`,
|
|
`>${labelText}</Toggle>`
|
|
]
|
|
.filter(Boolean)
|
|
.join('\n')
|
|
);
|
|
|
|
// Eidos snippet — visual usage with variant/size/block/iconOnly
|
|
const eidosSnippet = $derived(
|
|
[
|
|
"<script lang='ts'>",
|
|
" import Toggle from '$uix/eidos/components/toggle';",
|
|
' let pressed = $state(false);',
|
|
'</' + 'script>',
|
|
'',
|
|
'<Toggle',
|
|
' bind:pressed',
|
|
variant !== 'solid' && ` variant="${variant}"`,
|
|
size !== 'md' && ` size="${size}"`,
|
|
block && ' block',
|
|
iconOnly && ' iconOnly',
|
|
showCheckMark && ' checkMark',
|
|
intent !== 'neutral' && ` intent="${intent}"`,
|
|
color && ` color="${color}"`,
|
|
disabled && ' disabled',
|
|
nameAttr && ` name="${nameAttr}"`,
|
|
`>${labelText}</Toggle>`
|
|
]
|
|
.filter(Boolean)
|
|
.join('\n')
|
|
);
|
|
</script>
|
|
|
|
<svelte:head>
|
|
<meta name="perm-axes" content="disabled,invalid" />
|
|
</svelte:head>
|
|
|
|
{#snippet boldIcon()}
|
|
<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
<path d="M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z" />
|
|
<path d="M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z" />
|
|
</svg>
|
|
{/snippet}
|
|
|
|
<div data-uix-canvas-inner>
|
|
<header>
|
|
<div data-uix-eyebrow>Controls · Toggle</div>
|
|
<h1 data-uix-page-title>Toggle</h1>
|
|
<p data-uix-page-lede>
|
|
Two-state button (pressed / unpressed) — single APG button pattern,
|
|
form-integrable via <code>name</code> + <code>value</code>, three
|
|
variants (<code>solid</code> / <code>outline</code> / <code>ghost</code>),
|
|
doctrinal intent (<code>neutral | affirm | risk | threat</code>),
|
|
single <code>commit-toggle</code> sema event with <code>sequence: 'post'</code>.
|
|
</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>variants</span>3</span>
|
|
<span data-uix-meta-pill><span data-uix-meta-key>intents</span>4</span>
|
|
<span data-uix-meta-pill>
|
|
<span data-uix-meta-key>apg</span>
|
|
<a href={toggleMorfo.apg} target="_blank" rel="noreferrer">button ↗</a>
|
|
</span>
|
|
</div>
|
|
</header>
|
|
|
|
<div data-uix-stage>
|
|
<div data-uix-stage-area bind:this={stageRef}>
|
|
<form onsubmit={handleSubmit} style="display: flex; flex-direction: column; gap: 0.75rem; align-items: flex-start;">
|
|
<Toggle
|
|
bind:pressed
|
|
{disabled}
|
|
{readonly}
|
|
{required}
|
|
{invalid}
|
|
{intent}
|
|
color={color || undefined}
|
|
{size}
|
|
{variant}
|
|
{block}
|
|
{iconOnly}
|
|
name={nameAttr || undefined}
|
|
value={valueAttr}
|
|
aria-label={ariaLabel || undefined}
|
|
icon={showIcon ? boldIcon : undefined}
|
|
checkMark={showCheckMark}
|
|
data-perm-step={disabled ? undefined : '0'}
|
|
data-perm-label={disabled ? undefined : 'toggle pressed state'}
|
|
>
|
|
{labelText}
|
|
</Toggle>
|
|
<button type="submit" data-uix-play>Submit form</button>
|
|
</form>
|
|
</div>
|
|
<div data-uix-stage-trace>
|
|
<span data-uix-stage-trace-key>trace</span>
|
|
{#if trace.length === 0}
|
|
<span>click toggle to see commit-toggle event</span>
|
|
{:else}
|
|
{#each trace.slice(0, 3) as entry}
|
|
<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>state</span> {pressed ? 'on' : 'off'}
|
|
</span>
|
|
</div>
|
|
{#if lastFormSubmit !== null}
|
|
<div data-uix-stage-trace style="margin-top: 0.5rem;">
|
|
<span data-uix-stage-trace-key>FormData</span>
|
|
<code style="font-size: 0.85em;">{JSON.stringify(lastFormSubmit)}</code>
|
|
</div>
|
|
{/if}
|
|
</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>17</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>Props grouped by layer: <span data-uix-layer-badge="soma">soma</span> headless behavior, <span data-uix-layer-badge="eidos">eidos</span> visual treatment. Sema events live in the <a href="#sema" onclick={(e) => { e.preventDefault(); tab = 'sema'; }}>Sema</a> tab.</p>
|
|
|
|
<div data-uix-subsection-head>
|
|
<span data-uix-layer-badge="soma">soma</span> props · headless behavior
|
|
</div>
|
|
<div data-uix-controls>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>pressed <span data-uix-control-hint>bindable</span></span>
|
|
<span data-uix-switch>
|
|
<input type="checkbox" bind:checked={pressed} />
|
|
<span data-uix-switch-label>{pressed ? '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>readonly</span>
|
|
<span data-uix-switch><input type="checkbox" bind:checked={readonly} /><span data-uix-switch-label>{readonly ? 'on' : 'off'}</span></span>
|
|
</label>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>required</span>
|
|
<span data-uix-switch><input type="checkbox" bind:checked={required} /><span data-uix-switch-label>{required ? '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>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>intent</span>
|
|
<span data-uix-chips role="radiogroup">
|
|
{#each ['neutral', 'affirm', 'risk', 'threat'] as i}
|
|
<button data-uix-chip data-active={intent === i} onclick={() => (intent = i as 'neutral' | 'affirm' | 'risk' | 'threat')}>{i}</button>
|
|
{/each}
|
|
</span>
|
|
</label>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>color <span data-uix-control-hint>only when intent=neutral</span></span>
|
|
<span data-uix-chips role="radiogroup">
|
|
{#each ['', 'primary', 'secondary'] as c}
|
|
<button data-uix-chip data-active={color === c} onclick={() => (color = c as '' | 'primary' | 'secondary')}>{c || 'none'}</button>
|
|
{/each}
|
|
</span>
|
|
</label>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>name</span>
|
|
<input type="text" bind:value={nameAttr} placeholder="(no hidden input)" />
|
|
</label>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>value</span>
|
|
<input type="text" bind:value={valueAttr} />
|
|
</label>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>aria-label override</span>
|
|
<input type="text" bind:value={ariaLabel} placeholder="(uses children)" />
|
|
</label>
|
|
</div>
|
|
|
|
<div data-uix-subsection-head>
|
|
<span data-uix-layer-badge="eidos">eidos</span> props · visual treatment
|
|
</div>
|
|
<div data-uix-controls>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>variant</span>
|
|
<span data-uix-chips role="radiogroup">
|
|
{#each ['solid', 'outline', 'ghost'] as v}
|
|
<button data-uix-chip data-active={variant === v} onclick={() => (variant = v as ToggleVariant)}>{v}</button>
|
|
{/each}
|
|
</span>
|
|
</label>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>size</span>
|
|
<span data-uix-chips role="radiogroup">
|
|
{#each ['sm', 'md', 'lg'] as s}
|
|
<button data-uix-chip data-active={size === s} onclick={() => (size = s as ToggleSize)}>{s}</button>
|
|
{/each}
|
|
</span>
|
|
</label>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>block (full width)</span>
|
|
<span data-uix-switch><input type="checkbox" bind:checked={block} /><span data-uix-switch-label>{block ? 'on' : 'off'}</span></span>
|
|
</label>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>iconOnly</span>
|
|
<span data-uix-switch><input type="checkbox" bind:checked={iconOnly} /><span data-uix-switch-label>{iconOnly ? 'on' : 'off'}</span></span>
|
|
</label>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>icon snippet</span>
|
|
<span data-uix-switch><input type="checkbox" bind:checked={showIcon} /><span data-uix-switch-label>{showIcon ? 'on (Bold)' : 'off'}</span></span>
|
|
</label>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>checkMark</span>
|
|
<span data-uix-switch><input type="checkbox" bind:checked={showCheckMark} /><span data-uix-switch-label>{showCheckMark ? 'on' : 'off'}</span></span>
|
|
</label>
|
|
</div>
|
|
|
|
<div data-uix-subsection-head>Demo content <span style="font-weight: normal; color: var(--uix-text-muted);">· literal label text</span></div>
|
|
<div data-uix-controls>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>label text</span>
|
|
<input type="text" bind:value={labelText} />
|
|
</label>
|
|
</div>
|
|
|
|
<div data-uix-code>
|
|
<div data-uix-code-head>
|
|
<span data-uix-layer-badge="soma">soma</span>
|
|
<span>headless · ARIA + behavior only</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 · adds variant, size, block, iconOnly, icon, checkMark</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>Single-part component — <Toggle> IS the button. All props live on one component.</p>
|
|
<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">pressed <span data-uix-tag data-kind="bindable">bindable</span></td><td class="type">boolean</td><td class="default">false</td><td>Whether the toggle is pressed.</td></tr>
|
|
<tr><td class="name">onPressedChange</td><td class="type">(pressed: boolean) => void</td><td class="default empty">—</td><td>Press change callback.</td></tr>
|
|
<tr><td class="name">disabled / readonly / required / invalid</td><td class="type">boolean</td><td class="default">false</td><td>Field-integration flags.</td></tr>
|
|
<tr><td class="name">intent</td><td class="type">'neutral' | 'affirm' | 'risk' | 'threat'</td><td class="default">'neutral'</td><td>Doctrinal intent of the consequence. Drives sema sound + color.</td></tr>
|
|
<tr><td class="name">color</td><td class="type">'primary' | 'secondary'</td><td class="default empty">—</td><td>Hierarchical accent. Only applies when intent='neutral'.</td></tr>
|
|
<tr><td class="name">name / value</td><td class="type">string</td><td class="default">— / 'on'</td><td>Form field. Hidden input renders only while pressed.</td></tr>
|
|
<tr><td class="name">aria-label</td><td class="type">string</td><td class="default empty">—</td><td>Override accessible name when children isn't sufficient.</td></tr>
|
|
<tr><td class="name">variant <span data-uix-tag data-kind="eidos">eidos</span></td><td class="type">'solid' | 'outline' | 'ghost'</td><td class="default">'solid'</td><td>Visual treatment.</td></tr>
|
|
<tr><td class="name">size <span data-uix-tag data-kind="eidos">eidos</span></td><td class="type">'sm' | 'md' | 'lg'</td><td class="default">'md'</td><td>Padding + font preset.</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>Stretch to fill inline-size.</td></tr>
|
|
<tr><td class="name">iconOnly <span data-uix-tag data-kind="eidos">eidos</span></td><td class="type">boolean</td><td class="default">false</td><td>Square aspect, padding-inline reduced.</td></tr>
|
|
<tr><td class="name">icon <span data-uix-tag data-kind="eidos">eidos</span></td><td class="type">Snippet<{`{pressed}`}></td><td class="default empty">—</td><td>Icon snippet rendered before children.</td></tr>
|
|
<tr><td class="name">checkMark <span data-uix-tag data-kind="eidos">eidos</span></td><td class="type">boolean | Snippet</td><td class="default">false</td><td>Show check mark when pressed.</td></tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</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/toggle.ts</code>. Single-part — Provider IS the button.</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">"{toggleMorfo.name}"</td></tr>
|
|
<tr><td class="name">kebab</td><td class="type">"{toggleMorfo.kebab}"</td></tr>
|
|
<tr><td class="name">scope</td><td class="type">[{toggleMorfo.scope.map((s) => `"${s}"`).join(', ')}]</td></tr>
|
|
<tr><td class="name">apg</td><td><a href={toggleMorfo.apg} target="_blank" rel="noreferrer">{toggleMorfo.apg}</a></td></tr>
|
|
<tr><td class="name">parts.length</td><td class="default">{toggleMorfo.parts.length}</td></tr>
|
|
<tr><td class="name">events.length</td><td class="default">{toggleMorfo.events?.length ?? 0}</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></tr></thead>
|
|
<tbody>
|
|
{#each partsList as part}
|
|
<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>
|
|
</tr>
|
|
{/each}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
{#each toggleMorfo.parts as rawPart}
|
|
{@const partAny = rawPart as unknown as { kebab: string; aria?: ReadonlyArray<{ attr: string; value: { kind: string }; condition?: { when: string; prop?: string }; severity?: string }>; keyboard?: ReadonlyArray<{ key: string; action: string }> }}
|
|
{@const dataAttrs = compiled.contracts.dataAttrsByPart.get(partAny.kebab) ?? []}
|
|
{@const ariaAttrs = partAny.aria ?? []}
|
|
{@const keyboard = partAny.keyboard ?? []}
|
|
{#if dataAttrs.length || ariaAttrs.length || keyboard.length}
|
|
<div data-uix-subsection-head>{partAny.kebab}</div>
|
|
{#if dataAttrs.length}
|
|
<div data-uix-table-wrap>
|
|
<table data-uix-table>
|
|
<thead><tr><th>data-attr</th><th>Values</th><th>Source</th></tr></thead>
|
|
<tbody>
|
|
{#each dataAttrs as attr}
|
|
<tr>
|
|
<td class="name">{attr.attr}</td>
|
|
<td class="type">{attr.values ? attr.values.join(' | ') : '—'}</td>
|
|
<td class="default">{'value' in attr && attr.value ? (attr as { value: { kind: string } }).value.kind : '—'}</td>
|
|
</tr>
|
|
{/each}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{/if}
|
|
{#if ariaAttrs.length}
|
|
<div data-uix-table-wrap style="margin-top: var(--uix-space-2);">
|
|
<table data-uix-table>
|
|
<thead><tr><th>aria-attr</th><th>Source</th><th>Condition</th><th>Severity</th></tr></thead>
|
|
<tbody>
|
|
{#each ariaAttrs as a}
|
|
<tr>
|
|
<td class="name">{a.attr}</td>
|
|
<td class="type">{a.value.kind}</td>
|
|
<td class="default">{a.condition ? `when ${a.condition.when}${a.condition.prop ? ` (${a.condition.prop})` : ''}` : 'always'}</td>
|
|
<td class="default">{a.severity ?? 'required'}</td>
|
|
</tr>
|
|
{/each}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{/if}
|
|
{#if keyboard.length}
|
|
<div data-uix-table-wrap style="margin-top: var(--uix-space-2);">
|
|
<table data-uix-table>
|
|
<thead><tr><th>key</th><th>action</th></tr></thead>
|
|
<tbody>
|
|
{#each keyboard as kb}
|
|
<tr><td><span data-uix-kbd>{kb.key === ' ' ? 'Space' : kb.key}</span></td><td class="default">{kb.action}</td></tr>
|
|
{/each}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{/if}
|
|
{/if}
|
|
{/each}
|
|
|
|
<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}
|
|
{@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 + perceptual signature
|
|
</h2>
|
|
<p data-uix-section-desc>One event — <code>commit-toggle</code> — fires AFTER the state flip (canon <code>sequence: 'post'</code>). The pulse celebrates the resolved state. Intent comes from the <code>intent</code> prop and modulates the perceptual signature via <code>SEMA_MAP.intents</code>.</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 (live)</th><th>Play</th></tr></thead>
|
|
<tbody>
|
|
{#each events as action}
|
|
<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">{intent}</td>
|
|
<td>
|
|
<button
|
|
data-uix-play
|
|
onclick={() => {
|
|
const target = stageRef?.querySelector('[data-toggle]') as HTMLElement | null;
|
|
if (!target) return;
|
|
void uix.events?.emit({
|
|
name: action.name,
|
|
family: action.semantic.family,
|
|
target,
|
|
intent
|
|
});
|
|
}}
|
|
>▶ 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/toggle/toggle.css</code>. Maps <code>data-state</code> + <code>data-color</code> + <code>data-variant</code> + <code>data-size</code> to design tokens.</p>
|
|
<div data-uix-table-wrap>
|
|
<table data-uix-table>
|
|
<thead><tr><th>Selector</th><th>Source</th></tr></thead>
|
|
<tbody>
|
|
<tr><td class="name">[data-toggle]</td><td><span data-uix-tag data-kind="soma">morfo</span></td></tr>
|
|
<tr><td class="name">[data-toggle][data-state='on'/'off']</td><td><span data-uix-tag data-kind="soma">morfo</span></td></tr>
|
|
<tr><td class="name">[data-toggle][data-color]</td><td><span data-uix-tag data-kind="soma">morfo · resolved from intent + color</span></td></tr>
|
|
<tr><td class="name">[data-toggle][data-disabled / readonly / invalid / required]</td><td><span data-uix-tag data-kind="soma">morfo</span></td></tr>
|
|
<tr><td class="name">[data-toggle][data-variant / data-size / data-block / data-icon-only]</td><td><span data-uix-tag data-kind="eidos">eidos</span></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={toggleMorfo.apg} target="_blank" rel="noreferrer">button pattern</a>. Native button keyboard. <code>aria-pressed</code> exposes the toggle state.</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>Enter</span> / <span data-uix-kbd>Space</span></td><td>Toggle pressed state.</td></tr>
|
|
<tr><td><span data-uix-kbd>Tab</span></td><td>Move focus to / from the toggle.</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>Attribute</th><th>Value</th></tr></thead>
|
|
<tbody>
|
|
<tr><td>type</td><td class="type">"button"</td></tr>
|
|
<tr><td>aria-pressed</td><td class="type">"true" / "false"</td></tr>
|
|
<tr><td>aria-label</td><td class="type">{`{aria-label}`} (when set)</td></tr>
|
|
<tr><td>aria-disabled / readonly / required / invalid</td><td class="type">"true" (when set)</td></tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</section>
|
|
{/if}
|
|
</div>
|