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.
svelte-kit-vice/web/routes/uix/components/popover/+page.svelte

674 lines
29 KiB

<script lang="ts">
import {
Popover,
type PopoverSize
} from '$uix/eidos/components/popover';
import type { MotionPresetName } from '$uix/eidos/lib/motion/registry';
import { compileMorfo } from '$uix/morfo';
import { popoverMorfo } from '@/uix/morfo/components/popover';
import { getActiveUix } from '$active-uix';
const uix = getActiveUix();
type Tab = 'live' | 'api' | 'morfo' | 'sema' | 'recipe' | 'a11y';
let tab = $state<Tab>('live');
type Side = 'top' | 'right' | 'bottom' | 'left';
type Align = 'start' | 'center' | 'end';
// ── Live state ────────────────────────────────────────────────────────
let open = $state(false);
let modal = $state(false);
let size = $state<PopoverSize>('md');
let motion = $state<MotionPresetName>('spring-pop');
let side = $state<Side>('bottom');
let sideOffset = $state(8);
let align = $state<Align>('center');
let alignOffset = $state(0);
let openOnHover = $state(false);
let openDelay = $state(700);
let closeDelay = $state(300);
let avoidCollisions = $state(true);
let showArrow = $state(true);
let showClose = $state(true);
let showOverlay = $state(false);
let triggerLabel = $state('Show popover');
let bodyText = $state(
'Popovers are non-modal by default — focus stays free, click outside dismisses, body scroll keeps working. Set modal=true to flip those behaviours.'
);
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();
});
// ── Compiled morfo ────────────────────────────────────────────────────
const compiled = compileMorfo(popoverMorfo);
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 Popover from '$soma/components/popover';",
' let open = $state(false);',
'</' + 'script>',
'',
'<Popover.Provider',
' bind:open',
modal && ' modal',
'>',
` <Popover.Trigger${openOnHover ? ' openOnHover' : ''}>${triggerLabel}</Popover.Trigger>`,
' <Popover.Portal>',
showOverlay && ' <Popover.Overlay />',
' <Popover.Content',
side !== 'bottom' && ` side="${side}"`,
align !== 'center' && ` align="${align}"`,
sideOffset !== 0 && ` sideOffset={${sideOffset}}`,
!avoidCollisions && ' avoidCollisions={false}',
' >',
showArrow && ' <Popover.Arrow />',
' <p>...</p>',
showClose && ' <Popover.Close>Close</Popover.Close>',
' </Popover.Content>',
' </Popover.Portal>',
'</Popover.Provider>'
]
.filter(Boolean)
.join('\n')
);
const eidosSnippet = $derived(
[
"<script lang='ts'>",
" import { Popover } from '$uix/eidos/components/popover';",
' let open = $state(false);',
'</' + 'script>',
'',
'<Popover',
' bind:open',
modal && ' modal',
'>',
` <Popover.Trigger${openOnHover ? ' openOnHover' : ''}>${triggerLabel}</Popover.Trigger>`,
' <Popover.Portal>',
showOverlay && ' <Popover.Overlay />',
' <Popover.Content',
size !== 'md' && ` size="${size}"`,
motion !== 'slide-fade' && ` motion="${motion}"`,
side !== 'bottom' && ` side="${side}"`,
align !== 'center' && ` align="${align}"`,
' >',
showArrow && ' <Popover.Arrow />',
' <p>...</p>',
showClose && ' <Popover.Close>Close</Popover.Close>',
' </Popover.Content>',
' </Popover.Portal>',
'</Popover>'
]
.filter(Boolean)
.join('\n')
);
</script>
<div data-uix-canvas-inner>
<header>
<div data-uix-eyebrow>Overlays · Popover</div>
<h1 data-uix-page-title>Popover</h1>
<p data-uix-page-lede>
Anchored floating panel — non-modal by default (focus free, body
scrollable, click-outside dismisses) but flips to modal on
<code>modal=true</code>. Seven parts; six events covering five
distinct exit reasons surfaced via <code>data-last-action</code>:
saved · cancelled · dismissed · dismissed-outside · failed.
</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>4
</span>
<span data-uix-meta-pill>
<span data-uix-meta-key>apg</span>
<a href={popoverMorfo.apg} target="_blank" rel="noreferrer">dialog-modal ↗</a>
</span>
</div>
</header>
<!-- Live preview always rendered -->
<div data-uix-stage>
<div data-uix-stage-area bind:this={stageRef} style="min-block-size: 14rem;">
<Popover bind:open {modal}>
<Popover.Trigger
{openOnHover}
{openDelay}
{closeDelay}
data-perm-step="0"
data-perm-label="open popover"
>{triggerLabel}</Popover.Trigger>
<Popover.Portal>
{#if showOverlay}<Popover.Overlay />{/if}
<Popover.Content {size} {motion} {side} {sideOffset} {align} {alignOffset} {avoidCollisions}>
{#if showArrow}<Popover.Arrow />{/if}
<p style="margin: 0 0 var(--uix-space-3) 0;">{bodyText}</p>
{#if showClose}
<Popover.Close data-perm-step="1" data-perm-label="close popover">
Close
</Popover.Close>
{/if}
</Popover.Content>
</Popover.Portal>
</Popover>
</div>
<div data-uix-stage-trace>
<span data-uix-stage-trace-key>trace</span>
{#if trace.length === 0}
<span>open the popover to see events</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>open</span> {String(open)}
</span>
</div>
</div>
<!-- Tabs -->
<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>15</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 positioning + dismissal behaviour. Eidos adds size on Content. Sema events live in the dedicated <a href="#sema" onclick={(e) => { e.preventDefault(); tab = 'sema'; }}>Sema</a> tab.
</p>
<!-- ── Soma props ──────────────────────────────────────────────── -->
<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>open <span data-uix-control-hint>bindable</span></span>
<span data-uix-switch>
<input type="checkbox" bind:checked={open} />
<span data-uix-switch-label>{open ? 'open' : 'closed'}</span>
</span>
</label>
<label data-uix-control>
<span data-uix-control-label>modal <span data-uix-control-hint>traps focus, locks scroll</span></span>
<span data-uix-switch>
<input type="checkbox" bind:checked={modal} />
<span data-uix-switch-label>{modal ? 'on' : 'off'}</span>
</span>
</label>
<label data-uix-control>
<span data-uix-control-label>side <span data-uix-control-hint>Content prop</span></span>
<span data-uix-chips role="radiogroup">
{#each ['top', 'right', 'bottom', 'left'] as s}
<button data-uix-chip data-active={side === s} onclick={() => (side = s as Side)}>{s}</button>
{/each}
</span>
</label>
<label data-uix-control>
<span data-uix-control-label>align <span data-uix-control-hint>Content prop</span></span>
<span data-uix-chips role="radiogroup">
{#each ['start', 'center', 'end'] as a}
<button data-uix-chip data-active={align === a} onclick={() => (align = a as Align)}>{a}</button>
{/each}
</span>
</label>
<label data-uix-control>
<span data-uix-control-label>motion <span data-uix-control-hint>Content prop · spring-pop = JS spring engine</span></span>
<span data-uix-chips role="radiogroup">
{#each ['slide-fade', 'scale-fade', 'fade', 'spring-pop'] as m}
<button data-uix-chip data-active={motion === m} onclick={() => (motion = m as MotionPresetName)}>{m}</button>
{/each}
</span>
</label>
<label data-uix-control>
<span data-uix-control-label>sideOffset <span data-uix-control-hint>{sideOffset}px</span></span>
<input type="range" min="0" max="32" step="1" bind:value={sideOffset} />
</label>
<label data-uix-control>
<span data-uix-control-label>alignOffset <span data-uix-control-hint>{alignOffset}px</span></span>
<input type="range" min="-32" max="32" step="1" bind:value={alignOffset} />
</label>
<label data-uix-control>
<span data-uix-control-label>avoidCollisions</span>
<span data-uix-switch>
<input type="checkbox" bind:checked={avoidCollisions} />
<span data-uix-switch-label>{avoidCollisions ? 'on' : 'off'}</span>
</span>
</label>
<label data-uix-control>
<span data-uix-control-label>openOnHover <span data-uix-control-hint>Trigger prop</span></span>
<span data-uix-switch>
<input type="checkbox" bind:checked={openOnHover} />
<span data-uix-switch-label>{openOnHover ? 'on' : 'off'}</span>
</span>
</label>
<label data-uix-control>
<span data-uix-control-label>openDelay <span data-uix-control-hint>{openDelay}ms</span></span>
<input type="range" min="0" max="2000" step="50" bind:value={openDelay} disabled={!openOnHover} />
</label>
<label data-uix-control>
<span data-uix-control-label>closeDelay <span data-uix-control-hint>{closeDelay}ms</span></span>
<input type="range" min="0" max="2000" step="50" bind:value={closeDelay} disabled={!openOnHover} />
</label>
<label data-uix-control>
<span data-uix-control-label>render Overlay part <span data-uix-control-hint>composition</span></span>
<span data-uix-switch>
<input type="checkbox" bind:checked={showOverlay} />
<span data-uix-switch-label>{showOverlay ? 'on' : 'off'}</span>
</span>
</label>
<label data-uix-control>
<span data-uix-control-label>render Arrow part</span>
<span data-uix-switch>
<input type="checkbox" bind:checked={showArrow} />
<span data-uix-switch-label>{showArrow ? 'on' : 'off'}</span>
</span>
</label>
<label data-uix-control>
<span data-uix-control-label>render Close part</span>
<span data-uix-switch>
<input type="checkbox" bind:checked={showClose} />
<span data-uix-switch-label>{showClose ? 'on' : 'off'}</span>
</span>
</label>
</div>
<!-- ── Eidos props ─────────────────────────────────────────────── -->
<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>size <span data-uix-control-hint>Content prop</span></span>
<span data-uix-chips role="radiogroup">
{#each ['sm', 'md', 'lg', 'xl'] as s}
<button data-uix-chip data-active={size === s} onclick={() => (size = s as PopoverSize)}>{s}</button>
{/each}
</span>
</label>
</div>
<!-- ── Demo content ────────────────────────────────────────────── -->
<div data-uix-subsection-head>Demo content <span style="font-weight: normal; color: var(--uix-text-muted);">· literal text</span></div>
<div data-uix-controls>
<label data-uix-control>
<span data-uix-control-label>trigger label</span>
<input type="text" bind:value={triggerLabel} />
</label>
<label data-uix-control>
<span data-uix-control-label>body</span>
<textarea bind:value={bodyText}></textarea>
</label>
</div>
<!-- ── Code snippets per layer ─────────────────────────────────── -->
<div data-uix-code>
<div data-uix-code-head>
<span data-uix-layer-badge="soma">soma</span>
<span>headless · ARIA + behavior + floating positioning</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 size on Content</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>Selected props on Provider / Trigger / Content. Soma's full Content surface (collision boundaries, custom anchors, focus callbacks) passes through unchanged.</p>
<div data-uix-subsection-head>Provider</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">open <span data-uix-tag data-kind="bindable">bindable</span></td><td class="type">boolean</td><td class="default">false</td><td>Whether the popover is open.</td></tr>
<tr><td class="name">modal</td><td class="type">boolean</td><td class="default">false</td><td>Trap focus, lock scroll, ignore click-outside.</td></tr>
<tr><td class="name">onOpenChange / onOpenChangeComplete</td><td class="type">(open: boolean) =&gt; void</td><td class="default empty">—</td><td>Fire on every transition / after settle.</td></tr>
</tbody>
</table>
</div>
<div data-uix-subsection-head>Trigger</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">openOnHover</td><td class="type">boolean</td><td class="default">false</td><td>Open on pointer enter.</td></tr>
<tr><td class="name">openDelay</td><td class="type">number</td><td class="default">700</td><td>Hover-open delay (ms).</td></tr>
<tr><td class="name">closeDelay</td><td class="type">number</td><td class="default">300</td><td>Hover-close delay (ms).</td></tr>
</tbody>
</table>
</div>
<div data-uix-subsection-head>Content</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">size <span data-uix-tag data-kind="eidos">eidos</span></td><td class="type">ResponsiveProp&lt;'sm' | 'md' | 'lg' | 'xl'&gt;</td><td class="default">'md'</td><td>Visual size. Resolved via uix.dom.resolve.</td></tr>
<tr><td class="name">side</td><td class="type">'top' | 'right' | 'bottom' | 'left'</td><td class="default">'bottom'</td><td>Side of trigger.</td></tr>
<tr><td class="name">align</td><td class="type">'start' | 'center' | 'end'</td><td class="default">'center'</td><td>Alignment along the side.</td></tr>
<tr><td class="name">sideOffset</td><td class="type">number</td><td class="default">0</td><td>Distance from trigger.</td></tr>
<tr><td class="name">alignOffset</td><td class="type">number</td><td class="default">0</td><td>Offset along the alignment axis.</td></tr>
<tr><td class="name">avoidCollisions</td><td class="type">boolean</td><td class="default">true</td><td>Flip / shift to avoid viewport edges.</td></tr>
<tr><td class="name">collisionBoundary</td><td class="type">Boundary | Boundary[]</td><td class="default">[]</td><td>Custom boundary element(s).</td></tr>
<tr><td class="name">collisionPadding</td><td class="type">number | Record&lt;Side, number&gt;</td><td class="default">0</td><td>Padding from boundaries.</td></tr>
<tr><td class="name">sticky</td><td class="type">'partial' | 'always'</td><td class="default">'partial'</td><td>Sticking behavior on scroll.</td></tr>
<tr><td class="name">trapFocus</td><td class="type">boolean</td><td class="default">modal</td><td>Defaults to modal value; override explicitly.</td></tr>
<tr><td class="name">preventScroll</td><td class="type">boolean</td><td class="default">modal</td><td>Defaults to modal value.</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/popover.ts</code>. Six
events stamp <code>data-last-action</code> on Content as a
prewrite, so Eidos can colour each exit animation per cause —
saved (fulfill), cancelled (neutral), dismissed (neutral),
dismissed-outside (neutral), failed (threat).
</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">"{popoverMorfo.name}"</td></tr>
<tr><td class="name">kebab</td><td class="type">"{popoverMorfo.kebab}"</td></tr>
<tr><td class="name">scope</td><td class="type">[{popoverMorfo.scope.map((s) => `"${s}"`).join(', ')}]</td></tr>
<tr><td class="name">apg</td><td><a href={popoverMorfo.apg} target="_blank" rel="noreferrer">{popoverMorfo.apg}</a></td></tr>
<tr><td class="name">parts.length</td><td class="default">{popoverMorfo.parts.length}</td></tr>
<tr><td class="name">events.length</td><td class="default">{popoverMorfo.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><th>Optional</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">&lt;{part.defaultElement}&gt;</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>
{#each popoverMorfo.parts as rawPart}
{@const partAny = rawPart as unknown as { kebab: string; aria?: ReadonlyArray<{ attr: string; value: { kind: string }; condition?: { when: string; prop?: string; part?: 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 kind</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 kind</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})` : ''}${a.condition.part ? ` (${a.condition.part})` : ''}` : '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><th>prewrite</th><th>commit</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>
<td class="default">{action.prewrite.length ? action.prewrite.map((p) => `${p.attr}=${p.value}`).join(', ') : '—'}</td>
<td class="default">{action.commit ? `${action.commit.attr}=${action.commit.value}` : '—'}</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>
Six events. <code>present</code> uses emerge; close-* split by
cause: save (commit, fulfill), cancel/dismiss (emerge, no
intent), failed (signal, threat — alarm character). Click
<strong>play</strong> to fire on the live popover.
</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}
{@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-popover-content]') ?? stageRef?.querySelector('[data-popover-trigger]') ?? 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/popover/popover.css</code>. Tokens bare-prefixed (<code>--popover-*</code>).
</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-popover-trigger][data-state]</td><td><span data-uix-tag data-kind="soma">morfo</span></td></tr>
<tr><td class="name">[data-popover-content][data-state]</td><td><span data-uix-tag data-kind="soma">morfo</span></td></tr>
<tr><td class="name">[data-popover-content][data-size]</td><td><span data-uix-tag data-kind="eidos">eidos</span></td></tr>
<tr><td class="name">[data-popover-content][data-state='closed'][data-last-action]</td><td><span data-uix-tag data-kind="soma">morfo</span></td></tr>
<tr><td class="name">[data-popover-arrow]</td><td><span data-uix-tag data-kind="soma">morfo</span></td></tr>
<tr><td class="name">[data-popover-overlay][data-state]</td><td><span data-uix-tag data-kind="soma">morfo</span></td></tr>
<tr><td class="name">[data-popover-close]</td><td><span data-uix-tag data-kind="soma">morfo</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={popoverMorfo.apg} target="_blank" rel="noreferrer">dialog-modal pattern</a>. Trigger has <code>aria-haspopup="dialog"</code>; Content is a dialog. <code>aria-modal</code> stamps only when <code>modal=true</code>.
</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>Open the popover from Trigger.</td></tr>
<tr><td><span data-uix-kbd>Escape</span></td><td>Close (dismiss).</td></tr>
<tr><td><span data-uix-kbd>Tab</span></td><td>Focus next. Cycles when modal=true.</td></tr>
<tr><td><span data-uix-kbd>Shift+Tab</span></td><td>Focus previous.</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">trigger</td><td>aria-haspopup</td><td class="type">"dialog"</td></tr>
<tr><td class="name">trigger</td><td>aria-expanded</td><td class="type">{`{open}`}</td></tr>
<tr><td class="name">trigger</td><td>aria-controls</td><td class="type">{`<content id>`}</td></tr>
<tr><td class="name">content</td><td>role</td><td class="type">"dialog"</td></tr>
<tr><td class="name">content</td><td>aria-modal</td><td class="type">"true" (modal only)</td></tr>
<tr><td class="name">content</td><td>aria-labelledby</td><td class="type">{`<trigger id>`}</td></tr>
<tr><td class="name">overlay</td><td>aria-hidden</td><td class="type">"true"</td></tr>
</tbody>
</table>
</div>
</section>
{/if}
</div>

Powered by TurnKey Linux.