morfo: cross-layer contract + 14 new WAI-ARIA components + Dialog wired
Morfo (src/uix/morfo/): machine-readable contract of a component's public
DOM surface, shared between soma/sema/eidos. Shape v5 consolidated across
three independent AI reviews (Gemini, Grok, ChatGPT) plus Sema alignment.
Types, sium-based validator with cross-field invariants, dialog.ts as the
first canonical morfo with data-last-action for Sema-causal exits, 7 passing
unit tests.
createAttrs(morfo) and registerContract(morfo) now consume a Morfo — legacy
inline signature removed. Dialog provider refactored to derive parts +
data contract from dialogMorfo. The other 65 soma components need porting
(svelte-check lists them) — tracked work.
Tooling:
scripts/smoke-check.mjs — Playwright smoke over 65 soma demo routes
scripts/morfo-check.ts — validates emitted DOM vs morfo
scripts/morfo-vocabulary-check.ts — canonical vocabulary consistency
npm run smoke / morfo:check / morfo:vocabulary
WAI-ARIA APG components added (100% APG coverage now):
Announce, Avatar, Clipboard, DragDrop, Feed, GridList, Meter, Progress,
SearchField, TagGroup, TreeGrid + Table.RowDetail/Trigger (detail panel
pattern; hierarchical Table rows deprecated — use TreeGrid instead).
air: Link, Banner.
Sema prep:
src/uix/sema/sema_pre.md documents the semantic layer's DOM requirements.
Morfo already provides everything Sema needs (data-last-action patterns,
transition markers, enumerable state values, cross-component consistency).
Sema implementation deferred.
COMPONENT_GUIDE updated: items 37-39 (translation namespace grep, DOM
topology vs .require() audit, npm run smoke is part of done) + A34 rule
with incident log. WAI-ARIA pattern listed as soma membership criterion.
Pagination translation bug fixed (soma.pagination.page -> idlangref
PAGINATION_LANGS.PAGE). Table demo namespace fix (soma.table.*
-> components.table.*). Avatar demo now offline-safe (SVG data URL).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
6 months ago
|
|
|
/**
|
|
|
|
|
* Dialog morfo — canonical first example.
|
|
|
|
|
*
|
|
|
|
|
* Authored from the current `dialog-provider.svelte.ts` + `sema_pre.md`
|
|
|
|
|
* guidelines (data-last-action for asymmetric exits, transition markers).
|
|
|
|
|
*
|
|
|
|
|
* When the provider is refactored to consume `createAttrs(dialogMorfo)` +
|
|
|
|
|
* `registerContract(dialogMorfo)`, this becomes the single source of
|
|
|
|
|
* truth for parts, data-attrs, ARIA contract, keyboard, and focus.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import type { Morfo } from '../types';
|
|
|
|
|
import { v } from '../types';
|
|
|
|
|
|
soma/morfo: typed createAttrs + 6 audit batches + form hang fix + A36
## morfo: typed createAttrs
- `types.ts`: all array fields are now `readonly` so morfos can be authored
with `as const satisfies Morfo` without casts.
- `createAttrs` is a generic `<const M extends MorfoShape>` that infers the
emitted attr map from the morfo's literal shape. Typos like `attrs.trigerr`
are now compile errors; autocomplete lists every valid part.
- All 66 morfos migrated: `export const xMorfo = { ... } as const satisfies Morfo`.
- Two latent bugs the new typing caught: `dateRangeFieldAttrs.root` and
`timeRangeFieldAttrs.root` — legacy from the root→provider refactor, fixed
to `.provider`.
- Docs (morfo/README, COMPONENT_GUIDE) mandate `as const satisfies Morfo`;
the older `: Morfo` annotation widens literals and loses autocomplete.
## Audit batches 1–7 (soma-audit-2026-04-20)
Batch 1 — Keyboard a11y (A14/A12):
- Tabs: `isFallbackTabStop(el)` using `untrack` → first trigger gets
`tabindex=0` when no tab matches (WCAG 2.1.1 was failing).
- RatingGroup: `dir` prop + `getDirectionalKeys(dir, 'horizontal')` for RTL.
- Accordion P1-1/P1-6 dismissed: roving/labelledby already correct per APG.
Batch 2 — A33 reactive collections: Select `labelRegistry` and NavigationMenu
`triggerRefs` migrated to `SvelteMap`.
Batch 3 — A31 O(N²) fix: RadioGroup lifts `hasSelection` + `isFallbackTabStop`
to the provider with `untrack`-wrapped DOM walk. Per-item derivations drop
from O(N²) to O(1) per trigger.
Batch 4 — Morfo aria sync: toast / time-field / date-field / tabs /
tag-group / navigation-menu declare every aria the provider emits
(14 entries across 6 files).
Batch 5 — Accessible naming props: Tabs.List, ToggleGroup, TreeView,
NavigationMenu expose `aria-label?` / `aria-labelledby?` with explicit
"required unless labelledby is set" JSDoc.
Batch 6 — A30 cleanup: Checkbox `setLabelId` and 5 trigger-ref providers
(select/tooltip/link-preview/dropdown-menu/context-menu) migrated from
`$effect(() => parent.ref = opts.ref)` to the `Provider` base's
`onRefChange` callback (fires via attachRef inside `untrack`).
Batch 7 — A11 wrapper thinning: stepper/tree-view wrappers removed
`ctx.get()`, providers expose proxy derivations; time/date-range-field
inputs use `untrack(() => …)` for one-shot id registration; menubar
content's 40-line keyboard nav moved to `MenubarMenuProvider.onContentKeydown`;
color-picker area + channel-slider pointer state machines moved to the
providers with `onpointerdown/move/up` emitted via `props`.
form-auto-fields deferred with justification (reflective schema renderer,
not a state-holding wrapper).
## Form hang fix (A36)
`runValidate` entered the `isPromiseLike` branch even for sync schemas
because sium's Standard-Schema adapter declares `validate: async`. The
fallback `return { errors, issues }` read both reactive vars inside the
validation `$effect` while the `.then(...)` microtask wrote them
→ microtask-mediated loop, silent to Svelte's sync effect-depth guard.
Symptom: kitchen-sink hung the tab on mount with onChange / onBlur.
Fix: `return untrack(() => ({ errors, issues }))`. Regression locked by
two new 5s-timeout tests in `form-auto-fields.svelte.test.ts`.
Pattern codified as A36 in COMPONENT_GUIDE; CLAUDE.md count updated to
A1–A36 / 39 items.
## Verification
- `npm run check`: 0 errors in soma/morfo scope (sema demo pre-existing
errors untouched).
- `npx vitest run src/uix/soma src/uix/morfo`: all tests green
(94 + 7 = 101 tests, inc. 2 new form regression tests).
- `npm run smoke`: 65/65 routes.
- `npx tsx scripts/morfo-check.ts`: 66/66 morfos.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
6 months ago
|
|
|
export const dialogMorfo = {
|
morfo: cross-layer contract + 14 new WAI-ARIA components + Dialog wired
Morfo (src/uix/morfo/): machine-readable contract of a component's public
DOM surface, shared between soma/sema/eidos. Shape v5 consolidated across
three independent AI reviews (Gemini, Grok, ChatGPT) plus Sema alignment.
Types, sium-based validator with cross-field invariants, dialog.ts as the
first canonical morfo with data-last-action for Sema-causal exits, 7 passing
unit tests.
createAttrs(morfo) and registerContract(morfo) now consume a Morfo — legacy
inline signature removed. Dialog provider refactored to derive parts +
data contract from dialogMorfo. The other 65 soma components need porting
(svelte-check lists them) — tracked work.
Tooling:
scripts/smoke-check.mjs — Playwright smoke over 65 soma demo routes
scripts/morfo-check.ts — validates emitted DOM vs morfo
scripts/morfo-vocabulary-check.ts — canonical vocabulary consistency
npm run smoke / morfo:check / morfo:vocabulary
WAI-ARIA APG components added (100% APG coverage now):
Announce, Avatar, Clipboard, DragDrop, Feed, GridList, Meter, Progress,
SearchField, TagGroup, TreeGrid + Table.RowDetail/Trigger (detail panel
pattern; hierarchical Table rows deprecated — use TreeGrid instead).
air: Link, Banner.
Sema prep:
src/uix/sema/sema_pre.md documents the semantic layer's DOM requirements.
Morfo already provides everything Sema needs (data-last-action patterns,
transition markers, enumerable state values, cross-component consistency).
Sema implementation deferred.
COMPONENT_GUIDE updated: items 37-39 (translation namespace grep, DOM
topology vs .require() audit, npm run smoke is part of done) + A34 rule
with incident log. WAI-ARIA pattern listed as soma membership criterion.
Pagination translation bug fixed (soma.pagination.page -> idlangref
PAGINATION_LANGS.PAGE). Table demo namespace fix (soma.table.*
-> components.table.*). Avatar demo now offline-safe (SVG data URL).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
6 months ago
|
|
|
name: 'Dialog',
|
|
|
|
|
kebab: 'dialog',
|
|
|
|
|
scope: ['soma'],
|
|
|
|
|
apg: 'https://www.w3.org/WAI/ARIA/apg/patterns/dialog/',
|
|
|
|
|
|
|
|
|
|
focus: {
|
|
|
|
|
initial: 'first-focusable',
|
|
|
|
|
trap: true,
|
|
|
|
|
return: 'trigger',
|
|
|
|
|
restore: true
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
parts: [
|
|
|
|
|
{
|
|
|
|
|
name: 'Provider',
|
|
|
|
|
kebab: 'provider',
|
morfo: cross-layer contract + 14 new WAI-ARIA components + Dialog wired
Morfo (src/uix/morfo/): machine-readable contract of a component's public
DOM surface, shared between soma/sema/eidos. Shape v5 consolidated across
three independent AI reviews (Gemini, Grok, ChatGPT) plus Sema alignment.
Types, sium-based validator with cross-field invariants, dialog.ts as the
first canonical morfo with data-last-action for Sema-causal exits, 7 passing
unit tests.
createAttrs(morfo) and registerContract(morfo) now consume a Morfo — legacy
inline signature removed. Dialog provider refactored to derive parts +
data contract from dialogMorfo. The other 65 soma components need porting
(svelte-check lists them) — tracked work.
Tooling:
scripts/smoke-check.mjs — Playwright smoke over 65 soma demo routes
scripts/morfo-check.ts — validates emitted DOM vs morfo
scripts/morfo-vocabulary-check.ts — canonical vocabulary consistency
npm run smoke / morfo:check / morfo:vocabulary
WAI-ARIA APG components added (100% APG coverage now):
Announce, Avatar, Clipboard, DragDrop, Feed, GridList, Meter, Progress,
SearchField, TagGroup, TreeGrid + Table.RowDetail/Trigger (detail panel
pattern; hierarchical Table rows deprecated — use TreeGrid instead).
air: Link, Banner.
Sema prep:
src/uix/sema/sema_pre.md documents the semantic layer's DOM requirements.
Morfo already provides everything Sema needs (data-last-action patterns,
transition markers, enumerable state values, cross-component consistency).
Sema implementation deferred.
COMPONENT_GUIDE updated: items 37-39 (translation namespace grep, DOM
topology vs .require() audit, npm run smoke is part of done) + A34 rule
with incident log. WAI-ARIA pattern listed as soma membership criterion.
Pagination translation bug fixed (soma.pagination.page -> idlangref
PAGINATION_LANGS.PAGE). Table demo namespace fix (soma.table.*
-> components.table.*). Avatar demo now offline-safe (SVG data URL).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
6 months ago
|
|
|
kind: 'virtual',
|
|
|
|
|
defaultElement: 'none',
|
|
|
|
|
optional: false,
|
|
|
|
|
states: ['open', 'closed'],
|
|
|
|
|
data: [
|
|
|
|
|
{ attr: 'data-state', values: ['open', 'closed'] },
|
|
|
|
|
{ attr: 'data-disabled', severity: 'optional' }
|
|
|
|
|
],
|
|
|
|
|
aria: []
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Trigger',
|
|
|
|
|
kebab: 'trigger',
|
|
|
|
|
kind: 'public',
|
|
|
|
|
defaultElement: 'button',
|
|
|
|
|
role: 'button',
|
|
|
|
|
optional: false,
|
|
|
|
|
states: ['open', 'closed'],
|
|
|
|
|
data: [{ attr: 'data-state', values: ['open', 'closed'] }],
|
|
|
|
|
aria: [
|
|
|
|
|
{ attr: 'type', value: v.literal('button') },
|
|
|
|
|
{ attr: 'aria-haspopup', value: v.literal('dialog') },
|
|
|
|
|
{ attr: 'aria-expanded', value: v.stateRef('open') },
|
|
|
|
|
{ attr: 'aria-controls', value: v.partRef('content') }
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Content',
|
|
|
|
|
kebab: 'content',
|
|
|
|
|
kind: 'public',
|
|
|
|
|
defaultElement: 'div',
|
|
|
|
|
role: 'dialog',
|
|
|
|
|
optional: false,
|
|
|
|
|
supportsNesting: true,
|
|
|
|
|
states: ['open', 'closed'],
|
|
|
|
|
data: [
|
|
|
|
|
{ attr: 'data-state', values: ['open', 'closed'] },
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Sema alignment (sema_pre.md §9): causal exit reason. Updated
|
|
|
|
|
* BEFORE `data-state` flips to `'closed'` so Sema can tint the
|
|
|
|
|
* exit animation per-action. Ordering is validated by a
|
|
|
|
|
* dedicated MutationObserver test in the smoke suite.
|
|
|
|
|
*/
|
|
|
|
|
attr: 'data-last-action',
|
|
|
|
|
values: ['saved', 'cancelled', 'dismissed', 'dismissed-outside', 'failed'],
|
|
|
|
|
severity: 'optional'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
attr: 'data-nested',
|
|
|
|
|
severity: 'optional'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
attr: 'data-nested-open',
|
|
|
|
|
severity: 'optional'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
attr: 'data-starting-style',
|
|
|
|
|
severity: 'optional',
|
|
|
|
|
condition: { when: 'state-equals', state: 'open', value: 'starting' }
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
attr: 'data-ending-style',
|
|
|
|
|
severity: 'optional',
|
|
|
|
|
condition: { when: 'state-equals', state: 'closed', value: 'ending' }
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
aria: [
|
|
|
|
|
{ attr: 'aria-modal', value: v.literal('true'), condition: { when: 'prop-truthy', prop: 'modal' } },
|
|
|
|
|
{
|
|
|
|
|
attr: 'aria-labelledby',
|
|
|
|
|
value: v.partRef('title'),
|
|
|
|
|
condition: { when: 'part-present', part: 'title' },
|
|
|
|
|
severity: 'recommended'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* APG advises against `aria-describedby` on Dialog with rich
|
|
|
|
|
* content (lists, tables) — AT announces everything as a
|
|
|
|
|
* single string. Optional by design.
|
|
|
|
|
*/
|
|
|
|
|
attr: 'aria-describedby',
|
|
|
|
|
value: v.partRef('description'),
|
|
|
|
|
condition: { when: 'part-present', part: 'description' },
|
|
|
|
|
severity: 'optional'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
attr: 'aria-roledescription',
|
|
|
|
|
value: v.translationRef('#?components.dialog.content.roledescription|dialog window'),
|
|
|
|
|
severity: 'optional'
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
keyboard: [
|
|
|
|
|
{ key: 'Escape', action: 'close' },
|
|
|
|
|
{ key: 'Tab', action: 'focus-next' },
|
|
|
|
|
{ key: 'Shift+Tab', action: 'focus-prev' }
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Overlay',
|
|
|
|
|
kebab: 'overlay',
|
|
|
|
|
kind: 'public',
|
|
|
|
|
defaultElement: 'div',
|
|
|
|
|
optional: true,
|
|
|
|
|
supportsNesting: true,
|
|
|
|
|
states: ['open', 'closed'],
|
|
|
|
|
data: [
|
|
|
|
|
{ attr: 'data-state', values: ['open', 'closed'] },
|
|
|
|
|
{ attr: 'data-nested', severity: 'optional' },
|
|
|
|
|
{ attr: 'data-nested-open', severity: 'optional' },
|
|
|
|
|
{
|
|
|
|
|
attr: 'data-starting-style',
|
|
|
|
|
severity: 'optional',
|
|
|
|
|
condition: { when: 'state-equals', state: 'open', value: 'starting' }
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
attr: 'data-ending-style',
|
|
|
|
|
severity: 'optional',
|
|
|
|
|
condition: { when: 'state-equals', state: 'closed', value: 'ending' }
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
aria: [{ attr: 'aria-hidden', value: v.literal('true') }]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Title contributes to the accessible name of Content via
|
|
|
|
|
* `aria-labelledby`. Emitted as heading for AT hierarchy, but
|
|
|
|
|
* level is consumer-controlled (`propRef('level')`) — not a
|
|
|
|
|
* hardcoded '2' — so a dialog can be h1 at top level or h3 in
|
|
|
|
|
* a nested context without overriding prose.
|
|
|
|
|
*/
|
|
|
|
|
name: 'Title',
|
|
|
|
|
kebab: 'title',
|
|
|
|
|
kind: 'public',
|
|
|
|
|
defaultElement: 'div',
|
|
|
|
|
role: 'heading',
|
|
|
|
|
optional: true,
|
|
|
|
|
data: [],
|
|
|
|
|
aria: [
|
|
|
|
|
{
|
|
|
|
|
attr: 'aria-level',
|
|
|
|
|
value: v.propRef('level'),
|
|
|
|
|
severity: 'recommended'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Description',
|
|
|
|
|
kebab: 'description',
|
|
|
|
|
kind: 'public',
|
|
|
|
|
defaultElement: 'div',
|
|
|
|
|
optional: true,
|
|
|
|
|
data: [],
|
|
|
|
|
aria: []
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Close',
|
|
|
|
|
kebab: 'close',
|
|
|
|
|
kind: 'public',
|
|
|
|
|
defaultElement: 'button',
|
|
|
|
|
role: 'button',
|
|
|
|
|
optional: true,
|
|
|
|
|
data: [],
|
|
|
|
|
aria: [
|
|
|
|
|
{ attr: 'type', value: v.literal('button') },
|
|
|
|
|
{
|
|
|
|
|
attr: 'aria-label',
|
|
|
|
|
value: v.propRef('aria-label'),
|
|
|
|
|
severity: 'recommended',
|
|
|
|
|
condition: { when: 'prop-truthy', prop: 'aria-label' }
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
]
|
soma/morfo: typed createAttrs + 6 audit batches + form hang fix + A36
## morfo: typed createAttrs
- `types.ts`: all array fields are now `readonly` so morfos can be authored
with `as const satisfies Morfo` without casts.
- `createAttrs` is a generic `<const M extends MorfoShape>` that infers the
emitted attr map from the morfo's literal shape. Typos like `attrs.trigerr`
are now compile errors; autocomplete lists every valid part.
- All 66 morfos migrated: `export const xMorfo = { ... } as const satisfies Morfo`.
- Two latent bugs the new typing caught: `dateRangeFieldAttrs.root` and
`timeRangeFieldAttrs.root` — legacy from the root→provider refactor, fixed
to `.provider`.
- Docs (morfo/README, COMPONENT_GUIDE) mandate `as const satisfies Morfo`;
the older `: Morfo` annotation widens literals and loses autocomplete.
## Audit batches 1–7 (soma-audit-2026-04-20)
Batch 1 — Keyboard a11y (A14/A12):
- Tabs: `isFallbackTabStop(el)` using `untrack` → first trigger gets
`tabindex=0` when no tab matches (WCAG 2.1.1 was failing).
- RatingGroup: `dir` prop + `getDirectionalKeys(dir, 'horizontal')` for RTL.
- Accordion P1-1/P1-6 dismissed: roving/labelledby already correct per APG.
Batch 2 — A33 reactive collections: Select `labelRegistry` and NavigationMenu
`triggerRefs` migrated to `SvelteMap`.
Batch 3 — A31 O(N²) fix: RadioGroup lifts `hasSelection` + `isFallbackTabStop`
to the provider with `untrack`-wrapped DOM walk. Per-item derivations drop
from O(N²) to O(1) per trigger.
Batch 4 — Morfo aria sync: toast / time-field / date-field / tabs /
tag-group / navigation-menu declare every aria the provider emits
(14 entries across 6 files).
Batch 5 — Accessible naming props: Tabs.List, ToggleGroup, TreeView,
NavigationMenu expose `aria-label?` / `aria-labelledby?` with explicit
"required unless labelledby is set" JSDoc.
Batch 6 — A30 cleanup: Checkbox `setLabelId` and 5 trigger-ref providers
(select/tooltip/link-preview/dropdown-menu/context-menu) migrated from
`$effect(() => parent.ref = opts.ref)` to the `Provider` base's
`onRefChange` callback (fires via attachRef inside `untrack`).
Batch 7 — A11 wrapper thinning: stepper/tree-view wrappers removed
`ctx.get()`, providers expose proxy derivations; time/date-range-field
inputs use `untrack(() => …)` for one-shot id registration; menubar
content's 40-line keyboard nav moved to `MenubarMenuProvider.onContentKeydown`;
color-picker area + channel-slider pointer state machines moved to the
providers with `onpointerdown/move/up` emitted via `props`.
form-auto-fields deferred with justification (reflective schema renderer,
not a state-holding wrapper).
## Form hang fix (A36)
`runValidate` entered the `isPromiseLike` branch even for sync schemas
because sium's Standard-Schema adapter declares `validate: async`. The
fallback `return { errors, issues }` read both reactive vars inside the
validation `$effect` while the `.then(...)` microtask wrote them
→ microtask-mediated loop, silent to Svelte's sync effect-depth guard.
Symptom: kitchen-sink hung the tab on mount with onChange / onBlur.
Fix: `return untrack(() => ({ errors, issues }))`. Regression locked by
two new 5s-timeout tests in `form-auto-fields.svelte.test.ts`.
Pattern codified as A36 in COMPONENT_GUIDE; CLAUDE.md count updated to
A1–A36 / 39 items.
## Verification
- `npm run check`: 0 errors in soma/morfo scope (sema demo pre-existing
errors untouched).
- `npx vitest run src/uix/soma src/uix/morfo`: all tests green
(94 + 7 = 101 tests, inc. 2 new form regression tests).
- `npm run smoke`: 65/65 routes.
- `npx tsx scripts/morfo-check.ts`: 66/66 morfos.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
6 months ago
|
|
|
} as const satisfies Morfo;
|