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.
563 lines
25 KiB
563 lines
25 KiB
<script lang="ts">
|
|
import ImagePicker, {
|
|
type ImagePickerFit,
|
|
type ImagePickerValue
|
|
} from '$uix/eidos/components/image-picker';
|
|
import type { ImageAdjustmentValues } from '$uix/eidos/components/image-adjustments';
|
|
import { compileMorfo } from '$uix/morfo';
|
|
import { imagePickerMorfo } from '@/uix/morfo/components/image-picker';
|
|
import { getActiveUix } from '$active-uix';
|
|
|
|
const uix = getActiveUix();
|
|
|
|
type Tab = 'live' | 'api' | 'morfo' | 'sema' | 'recipe' | 'a11y';
|
|
let tab = $state<Tab>('live');
|
|
|
|
// ── Live state ────────────────────────────────────────────────────────
|
|
let file = $state<File | null>(null);
|
|
let fit = $state<ImagePickerFit>('cover');
|
|
let rotation = $state<0 | 90 | 180 | 270>(0);
|
|
let adjustments = $state<ImageAdjustmentValues>({});
|
|
let size = $state<'sm' | 'md' | 'lg'>('sm');
|
|
let showAdjustments = $state(true);
|
|
let disabled = $state(false);
|
|
let lastValue = $state<ImagePickerValue | null>(null);
|
|
|
|
const pickerState = $derived(file ? 'ready' : 'empty');
|
|
|
|
// A synthetic sample image (inline SVG → File) so the "ready" state is
|
|
// demoable without a real upload. Deliberately WIDE (16:9) so it differs from
|
|
// the 4:3 preview box — that's what makes the `fit` modes visibly distinct:
|
|
// cover crops the sides, contain letterboxes, fill stretches. The real
|
|
// dropzone also accepts files.
|
|
const sampleSvg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 360">
|
|
<defs><linearGradient id="s" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#4ea8ff"/><stop offset="1" stop-color="#bfe3ff"/></linearGradient></defs>
|
|
<rect width="640" height="360" fill="url(#s)"/>
|
|
<circle cx="510" cy="86" r="46" fill="#ffd24a"/>
|
|
<path d="M0 250 Q160 190 320 240 T640 220 V360 H0 Z" fill="#2f9e57"/>
|
|
<path d="M0 296 Q190 250 400 286 T640 276 V360 H0 Z" fill="#1f7a42"/>
|
|
</svg>`;
|
|
function loadSample() {
|
|
file = new File([sampleSvg], 'sample.svg', { type: 'image/svg+xml' });
|
|
}
|
|
|
|
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(imagePickerMorfo);
|
|
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 ImagePicker from '$soma/components/image-picker';",
|
|
" import { FileUpload } from '$uix/eidos/components/file-upload';",
|
|
" import { Image } from '$uix/eidos/components/image';",
|
|
" import ImageAdjustments from '$uix/eidos/components/image-adjustments';",
|
|
' let file = $state(null);',
|
|
'</' + 'script>',
|
|
'',
|
|
'<ImagePicker.Provider bind:file onChange={(v) => save(v)}>',
|
|
' {#snippet children({ state, url, filter, fit, prompt, setFile })}',
|
|
" {#if state === 'empty'}",
|
|
' <FileUpload accept="image/*" multiple={false}',
|
|
' onFilesChange={(f) => setFile(f[0] ?? null)}>',
|
|
' <FileUpload.Dropzone><FileUpload.HiddenInput />',
|
|
' <FileUpload.Trigger>{prompt}</FileUpload.Trigger>',
|
|
' </FileUpload.Dropzone>',
|
|
' </FileUpload>',
|
|
' {:else}',
|
|
' <ImagePicker.Preview>',
|
|
' <Image src={url} alt="" {fit} style="filter: {filter}" />',
|
|
' <ImagePicker.Toolbar>',
|
|
' <ImagePicker.Rotate>⟳</ImagePicker.Rotate>',
|
|
' <ImagePicker.Remove>✕</ImagePicker.Remove>',
|
|
' </ImagePicker.Toolbar>',
|
|
' </ImagePicker.Preview>',
|
|
' <ImageAdjustments bind:value={adjustments} />',
|
|
' {/if}',
|
|
' {/snippet}',
|
|
'</ImagePicker.Provider>'
|
|
].join('\n')
|
|
);
|
|
|
|
const eidosSnippet = $derived(
|
|
[
|
|
"<script lang='ts'>",
|
|
" import ImagePicker from '$uix/eidos/components/image-picker';",
|
|
' let file = $state(null);',
|
|
'</' + 'script>',
|
|
'',
|
|
'<ImagePicker',
|
|
' bind:file',
|
|
' onChange={(v) => save(v)}',
|
|
fit !== 'cover' && ` fit="${fit}"`,
|
|
size !== 'sm' && ` size="${size}"`,
|
|
!showAdjustments && ' showAdjustments={false}',
|
|
disabled && ' disabled',
|
|
'/>'
|
|
]
|
|
.filter(Boolean)
|
|
.join('\n')
|
|
);
|
|
</script>
|
|
|
|
<div data-uix-canvas-inner>
|
|
<header>
|
|
<div data-uix-eyebrow>Media · Image picker</div>
|
|
<h1 data-uix-page-title>ImagePicker</h1>
|
|
<p data-uix-page-lede>
|
|
Pick, preview and adjust an image. A pure composition — it wires the framework's
|
|
<code>FileUpload</code> (drop + click), <code>Image</code> (fit modes),
|
|
<code>ImageAdjustments</code> (filter sliders) and adds 90° rotation. The soma owns the file,
|
|
the object-URL lifecycle and the composed CSS <code>filter</code>; its streamed value is
|
|
cropper-ready. Five parts, three events.
|
|
</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>composes</span>3</span>
|
|
<span data-uix-meta-pill><span data-uix-meta-key>output</span>File + filter</span>
|
|
</div>
|
|
</header>
|
|
|
|
<!-- Live preview always rendered -->
|
|
<div data-uix-stage>
|
|
<div data-uix-stage-area bind:this={stageRef}>
|
|
<div class="ip-stage">
|
|
<ImagePicker
|
|
bind:file
|
|
bind:fit
|
|
bind:rotation
|
|
bind:adjustments
|
|
{size}
|
|
{showAdjustments}
|
|
{disabled}
|
|
onChange={(v) => (lastValue = v)}
|
|
aria-label="Photo picker"
|
|
/>
|
|
<button data-uix-chip onclick={loadSample} style="align-self: flex-start;">
|
|
Load sample image
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<div data-uix-stage-trace>
|
|
<span data-uix-stage-trace-key>trace</span>
|
|
{#if trace.length === 0}
|
|
<span>select / rotate / remove an image 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>state</span>
|
|
{pickerState} · {rotation}°
|
|
</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>9</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 the architectural layer that owns them: <span data-uix-layer-badge="soma">soma</span>
|
|
headless behavior, <span data-uix-layer-badge="eidos">eidos</span> composition. Load the
|
|
sample (or drop a real image), then rotate / adjust / remove. 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>fit <span data-uix-control-hint>fill mode</span></span>
|
|
<span data-uix-chips role="radiogroup">
|
|
{#each ['cover', 'contain', 'fill'] as const as f}
|
|
<button data-uix-chip data-active={fit === f} onclick={() => (fit = f)}>{f}</button>
|
|
{/each}
|
|
</span>
|
|
</label>
|
|
<div data-uix-control>
|
|
<span data-uix-control-label>rotation <span data-uix-control-hint>via Rotate button</span></span>
|
|
<code style="font-size: var(--font-size-xs); color: var(--uix-text-muted);">{rotation}°</code>
|
|
</div>
|
|
<div data-uix-control>
|
|
<span data-uix-control-label>file <span data-uix-control-hint>bindable</span></span>
|
|
<code style="font-size: var(--font-size-xs); color: var(--uix-text-muted);">{file ? file.name : 'null'}</code>
|
|
</div>
|
|
<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>
|
|
</div>
|
|
|
|
<div data-uix-subsection-head>
|
|
<span data-uix-layer-badge="eidos">eidos</span> props · composition
|
|
</div>
|
|
<div data-uix-controls>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>size <span data-uix-control-hint>adjustments scale</span></span>
|
|
<span data-uix-chips role="radiogroup">
|
|
{#each ['sm', 'md', 'lg'] as const as s}
|
|
<button data-uix-chip data-active={size === s} onclick={() => (size = s)}>{s}</button>
|
|
{/each}
|
|
</span>
|
|
</label>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>showAdjustments</span>
|
|
<span data-uix-switch>
|
|
<input type="checkbox" bind:checked={showAdjustments} />
|
|
<span data-uix-switch-label>{showAdjustments ? 'on' : 'off'}</span>
|
|
</span>
|
|
</label>
|
|
<div data-uix-control>
|
|
<span data-uix-control-label>filter <span data-uix-control-hint>onChange output</span></span>
|
|
<code style="font-size: var(--font-size-xs); color: var(--uix-text-muted); max-inline-size: 16rem; overflow: hidden; text-overflow: ellipsis;">{lastValue?.filter ?? 'none'}</code>
|
|
</div>
|
|
</div>
|
|
|
|
<div data-uix-code>
|
|
<div data-uix-code-head>
|
|
<span data-uix-layer-badge="soma">soma</span>
|
|
<span>headless · composes FileUpload + Image + ImageAdjustments</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 · the configured composition</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>All public props. Eidos additions are tagged.</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">file <span data-uix-tag data-kind="bindable">bindable</span></td><td class="type">{`File | null`}</td><td class="default">null</td><td>The selected file.</td></tr>
|
|
<tr><td class="name">fit <span data-uix-tag data-kind="bindable">bindable</span></td><td class="type">{`'cover' | 'contain' | 'fill'`}</td><td class="default">'cover'</td><td>Fill mode → the composed Image.</td></tr>
|
|
<tr><td class="name">rotation <span data-uix-tag data-kind="bindable">bindable</span></td><td class="type">0 | 90 | 180 | 270</td><td class="default">0</td><td>Clockwise rotation, driven by the Rotate button.</td></tr>
|
|
<tr><td class="name">adjustments <span data-uix-tag data-kind="bindable">bindable</span></td><td class="type">ImageAdjustmentValues</td><td class="default">{`{}`}</td><td>Filter values → the composed ImageAdjustments.</td></tr>
|
|
<tr><td class="name">onChange</td><td class="type">{`(v: ImagePickerValue) => void`}</td><td class="default empty">—</td><td>{`{ file, url, fit, rotation, filter, adjustments }`} on any change. Cropper-ready.</td></tr>
|
|
<tr><td class="name">onSelect / onRemove</td><td class="type">{`(file) => void`} / {`() => void`}</td><td class="default empty">—</td><td>Fire on select / remove.</td></tr>
|
|
<tr><td class="name">disabled</td><td class="type">boolean</td><td class="default">false</td><td>Disable picking + all controls.</td></tr>
|
|
<tr><td class="name">accept <span data-uix-tag data-kind="eidos">eidos</span></td><td class="type">string</td><td class="default">'image/*'</td><td>→ FileUpload.</td></tr>
|
|
<tr><td class="name">maxSize <span data-uix-tag data-kind="eidos">eidos</span></td><td class="type">number</td><td class="default empty">—</td><td>Max bytes → FileUpload.</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">'sm'</td><td>Adjustments panel scale.</td></tr>
|
|
<tr><td class="name">showAdjustments <span data-uix-tag data-kind="eidos">eidos</span></td><td class="type">boolean</td><td class="default">true</td><td>Render the filters panel.</td></tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<div data-uix-subsection-head>Reference comparison</div>
|
|
<div data-uix-table-wrap>
|
|
<table data-uix-table>
|
|
<thead><tr><th>Capability</th><th>Untitled</th><th>Chakra</th><th>Radix</th><th>MUI</th><th>UIX</th></tr></thead>
|
|
<tbody>
|
|
<tr><td class="name">Image picker primitive</td><td>✅</td><td>❌</td><td>❌</td><td>❌</td><td>✅</td></tr>
|
|
<tr><td class="name">File upload base</td><td>✅</td><td>✅</td><td>❌</td><td>❌</td><td>✅ reuse</td></tr>
|
|
<tr><td class="name">Fill modes + 90° rotation</td><td>✅</td><td>❌</td><td>❌</td><td>❌</td><td>✅</td></tr>
|
|
<tr><td class="name">Built-in filter sliders</td><td>✅</td><td>❌</td><td>❌</td><td>❌</td><td>✅ reuse</td></tr>
|
|
<tr><td class="name">Cropper-ready output</td><td>⚠️</td><td>—</td><td>—</td><td>—</td><td>✅ File + url</td></tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<p data-uix-section-desc>
|
|
No mainstream component library ships an image picker as a primitive — it's app code on top
|
|
of a file input. UIX composes three resolved components and emits a cropper-ready value.
|
|
</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>
|
|
The morfo declares only the picker's OWN orchestration — the empty↔ready state, the
|
|
<code>fit</code> + <code>rotation</code> transforms, and the select / remove / rotate
|
|
events. The dropzone, image and sliders carry their own morfos. Source:
|
|
<code>src/uix/morfo/components/image-picker.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">"{imagePickerMorfo.name}"</td></tr>
|
|
<tr><td class="name">kebab</td><td class="type">"{imagePickerMorfo.kebab}"</td></tr>
|
|
<tr><td class="name">scope</td><td class="type">[{imagePickerMorfo.scope.map((s) => `"${s}"`).join(', ')}]</td></tr>
|
|
<tr><td class="name">parts.length</td><td class="default">{imagePickerMorfo.parts.length}</td></tr>
|
|
<tr><td class="name">events.length</td><td class="default">{imagePickerMorfo.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"><{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>
|
|
|
|
{#each imagePickerMorfo.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 }> }}
|
|
{@const dataAttrs = compiled.contracts.dataAttrsByPart.get(partAny.kebab) ?? []}
|
|
{@const ariaAttrs = partAny.aria ?? []}
|
|
{#if dataAttrs.length || ariaAttrs.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>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.severity ?? 'required'}</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}
|
|
<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">{typeof intentDecl === 'string' ? intentDecl : '—'}</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>
|
|
Three events: <code>commit-select</code> (commit · affirm — the pickup of a chosen image),
|
|
<code>commit-remove</code> (commit · neutral), <code>handle-rotate</code> (handle · neutral
|
|
— a spatial nudge, haptic tick). The per-slider feedback is owned by ImageAdjustments.
|
|
Click <strong>play</strong> to fire on the live picker.
|
|
</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-image-picker-${action.target === 'preview' ? 'preview' : 'provider'}]`) ?? stageRef?.querySelector('[data-image-picker]') ?? 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/image-picker/image-picker.css</code>. Tokens
|
|
bare-prefixed (<code>--image-picker-*</code>). The recipe owns only the orchestration chrome
|
|
— the preview box, the rotation transform, the floating toolbar; the composed components
|
|
bring their own recipes.
|
|
</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-image-picker]</td><td><span data-uix-tag data-kind="soma">morfo</span></td></tr>
|
|
<tr><td class="name">[data-image-picker][data-disabled]</td><td><span data-uix-tag data-kind="soma">morfo</span></td></tr>
|
|
<tr><td class="name">[data-image-picker-preview]</td><td><span data-uix-tag data-kind="soma">morfo</span></td></tr>
|
|
<tr><td class="name">[data-image-picker-preview][data-rotation]</td><td><span data-uix-tag data-kind="soma">morfo</span></td></tr>
|
|
<tr><td class="name">[data-image-picker-toolbar]</td><td><span data-uix-tag data-kind="soma">morfo</span></td></tr>
|
|
<tr><td class="name">[data-image-picker-rotate] / [data-image-picker-remove]</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>
|
|
The picker is a labelled <code>role="group"</code>. The dropzone (FileUpload) and the
|
|
sliders (ImageAdjustments) carry their own APG-pattern keyboard + ARIA; the toolbar buttons
|
|
are plain buttons with explicit <code>aria-label</code>s.
|
|
</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>Tab</span></td><td>Move between the dropzone / preview / toolbar / sliders.</td></tr>
|
|
<tr><td><span data-uix-kbd>Enter</span> / <span data-uix-kbd>Space</span></td><td>Activate the focused control (browse, rotate, remove).</td></tr>
|
|
<tr><td><span data-uix-kbd>←</span> <span data-uix-kbd>→</span> <span data-uix-kbd>↑</span> <span data-uix-kbd>↓</span></td><td>Adjust the focused filter slider.</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">provider</td><td>role</td><td class="type">"group"</td></tr>
|
|
<tr><td class="name">provider</td><td>aria-label</td><td class="type">"Image picker" (or prop)</td></tr>
|
|
<tr><td class="name">provider</td><td>data-state</td><td class="type">"empty" | "ready"</td></tr>
|
|
<tr><td class="name">rotate</td><td>aria-label</td><td class="type">"Rotate 90°"</td></tr>
|
|
<tr><td class="name">remove</td><td>aria-label</td><td class="type">"Remove image"</td></tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</section>
|
|
{/if}
|
|
</div>
|
|
|
|
<style>
|
|
.ip-stage {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: var(--uix-space-2);
|
|
inline-size: 100%;
|
|
max-inline-size: 420px;
|
|
}
|
|
</style>
|