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/src/uix/eidos/components/switch/switch.svelte

38 lines
1.2 KiB

docs + switch: align active docs to canon, migrate switch to eidos wrapper Phase 4 (docs alignment with the canonical guide): - active_architecture.md — Dialog example refactored to the new event shape (target inside semantic, explicit verb + sequence). Verbs table grouped by family with the post-canon vocabulary (select/ toggle moved to commit, edit removed from handle, new verbs added). Section 10 (Estado actual) updated to 2026-05-08 with current progress: doctrina cerrada, eidos en producción, SoundChannel eager-init, switch migrated, etc. "Para profundizar" §14 points at the canonical guide. - morfo/README.md — Step 5.5 added covering the doctrinal event shape with all fields (semantic.family, .verb, .target, .sequence, .intent) and the two naming shapes ({verb}-{variant} and {family}-{verb}). - sema/README.md — verbs section restructured to Record-by-family matching the runtime; documents the verbs that moved between families per the canon. Naming shapes section updated with both forms and validateEventName signature. - CLAUDE.md — "Session hand-off" rewritten with the post-canon state. Pointer at GUIA_IMPLEMENTACION_SEMAUIX.md as the canonical source. Pending list refreshed: switch is the immediate next component, persistence/a11ySemantic/polymorphism deferred until real consumers appear. Switch migration to the eidos wrapper pattern: - morfo/components/switch.ts — adds events: [{ commit-toggle }] with the doctrinal shape (verb=toggle, sequence=post, intent fromProp binding to the 4 supported intents). New data-* (data-color with the 6-token Toggle/Switch subset, data-readonly, data-invalid, data-required) and corresponding aria-*. scope expanded to ['soma', 'sema']. - soma/components/switch/types.ts — adds intent, color, readonly, invalid, aria-labelledby props with full JSDoc. Subset constrained per guide §3.1 (Toggle/Switch row). - soma/components/switch/switch-provider.svelte.ts — runtime-direct, Field integration via FieldProvider.get(), isDisabled/isReadonly/ isRequired/isInvalid OR-merge derivations, intent ↔ color resolution (intent wins when evaluative), runtime.trigger( 'commit-toggle') in onclick. - soma/components/switch/components/switch.svelte — wires the new props through bindProps. - eidos/components/switch/{switch.css, switch.svelte, types.ts, index.ts, README.md} — full subdirectory pattern, mirroring toggle. Recipe drops legacy success/warning/danger/info selectors; declares the 6 doctrinal data-color values directly. Wrapper auto-renders Switch.Thumb inside the track and exposes an optional `thumb` snippet for in-thumb glyphs. - eidos/components/switch.css (legacy flat) deleted; eidos/index.css updated to import the subdirectory recipe. - web/routes/switch/+page.svelte — interactive testbed with all soma props as live controls + tabs (Live, Soma, Morfo, Sema, Eidos, Notes). Mirrors toggle's structure. npm run check holds at the 39-error baseline. Tests 217/217 green. Pending: - Migrate collapsible / dialog / drawer / popover / toast / avatar to the eidos wrapper pattern. - Persistence + holds-by-intent — defer until first signal.warn / signal.alert consumer. - a11ySemantic + polymorphic events — defer until concrete need. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5 months ago
<script lang="ts">
/**
* Eidos `<Switch>` — visual wrapper over `$soma/components/switch`.
*
* Soma owns: `checked` state, `data-state='checked|unchecked'`,
* `aria-checked`, the `commit-toggle` perceptual event, intent
* resolution, field integration. Eidos adds the visual API: `size`
* + an optional `thumb` snippet for in-thumb glyphs, and emits the
* `data-size` attr that the recipe consumes.
*
* `Switch.Thumb` from soma is rendered automatically inside the
* track — the consumer doesn't have to compose it. If they need
* raw access to the thumb, they can fall back to the soma compound
* primitive via `import * as Switch from '$soma/components/switch'`.
docs + switch: align active docs to canon, migrate switch to eidos wrapper Phase 4 (docs alignment with the canonical guide): - active_architecture.md — Dialog example refactored to the new event shape (target inside semantic, explicit verb + sequence). Verbs table grouped by family with the post-canon vocabulary (select/ toggle moved to commit, edit removed from handle, new verbs added). Section 10 (Estado actual) updated to 2026-05-08 with current progress: doctrina cerrada, eidos en producción, SoundChannel eager-init, switch migrated, etc. "Para profundizar" §14 points at the canonical guide. - morfo/README.md — Step 5.5 added covering the doctrinal event shape with all fields (semantic.family, .verb, .target, .sequence, .intent) and the two naming shapes ({verb}-{variant} and {family}-{verb}). - sema/README.md — verbs section restructured to Record-by-family matching the runtime; documents the verbs that moved between families per the canon. Naming shapes section updated with both forms and validateEventName signature. - CLAUDE.md — "Session hand-off" rewritten with the post-canon state. Pointer at GUIA_IMPLEMENTACION_SEMAUIX.md as the canonical source. Pending list refreshed: switch is the immediate next component, persistence/a11ySemantic/polymorphism deferred until real consumers appear. Switch migration to the eidos wrapper pattern: - morfo/components/switch.ts — adds events: [{ commit-toggle }] with the doctrinal shape (verb=toggle, sequence=post, intent fromProp binding to the 4 supported intents). New data-* (data-color with the 6-token Toggle/Switch subset, data-readonly, data-invalid, data-required) and corresponding aria-*. scope expanded to ['soma', 'sema']. - soma/components/switch/types.ts — adds intent, color, readonly, invalid, aria-labelledby props with full JSDoc. Subset constrained per guide §3.1 (Toggle/Switch row). - soma/components/switch/switch-provider.svelte.ts — runtime-direct, Field integration via FieldProvider.get(), isDisabled/isReadonly/ isRequired/isInvalid OR-merge derivations, intent ↔ color resolution (intent wins when evaluative), runtime.trigger( 'commit-toggle') in onclick. - soma/components/switch/components/switch.svelte — wires the new props through bindProps. - eidos/components/switch/{switch.css, switch.svelte, types.ts, index.ts, README.md} — full subdirectory pattern, mirroring toggle. Recipe drops legacy success/warning/danger/info selectors; declares the 6 doctrinal data-color values directly. Wrapper auto-renders Switch.Thumb inside the track and exposes an optional `thumb` snippet for in-thumb glyphs. - eidos/components/switch.css (legacy flat) deleted; eidos/index.css updated to import the subdirectory recipe. - web/routes/switch/+page.svelte — interactive testbed with all soma props as live controls + tabs (Live, Soma, Morfo, Sema, Eidos, Notes). Mirrors toggle's structure. npm run check holds at the 39-error baseline. Tests 217/217 green. Pending: - Migrate collapsible / dialog / drawer / popover / toast / avatar to the eidos wrapper pattern. - Persistence + holds-by-intent — defer until first signal.warn / signal.alert consumer. - a11ySemantic + polymorphic events — defer until concrete need. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5 months ago
*/
import * as Switch from '$soma/components/switch';
import type { SwitchProps } from './types';
// `checked` is re-bindable: consumers using `bind:checked` need the
// eidos wrapper to forward the binding, not just the value.
let {
size = 'md',
thumb,
checked = $bindable(false),
...somaProps
}: SwitchProps = $props();
</script>
<Switch.Provider {...somaProps} bind:checked data-size={size}>
{#snippet children({ checked: c })}
<Switch.Thumb>
{#if thumb}
{@render thumb({ checked: c })}
{/if}
</Switch.Thumb>
{/snippet}
</Switch.Provider>

Powered by TurnKey Linux.