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/morfo/components/css-field.ts

211 lines
5.7 KiB

import type { Morfo } from '../types';
import { v } from '../types';
export const cssFieldMorfo = {
name: 'CssField',
kebab: 'css-field',
scope: ['soma', 'sema'],
texts: {
label: '#?components.css-field.label|CSS Value',
invalid: '#?components.css-field.invalid|Invalid CSS value'
},
apg: 'https://www.w3.org/WAI/ARIA/apg/patterns/spinbutton/',
events: [
{
name: 'commit-set',
semantic: {
family: 'commit',
verb: 'set',
target: v.partRef('provider'),
intent: 'neutral',
sequence: 'post'
}
},
{
name: 'handle-pick',
semantic: {
family: 'handle',
verb: 'pick',
target: v.partRef('scrubber'),
sequence: 'pre',
channels: ['sound', 'haptic']
}
},
{
name: 'handle-drag-scrub',
semantic: {
family: 'handle',
verb: 'drag',
target: v.partRef('scrubber'),
sequence: 'coincident',
channels: ['haptic']
}
},
{
// Book §6.2 — signal.risk = untilFix. Typing a value whose unit is not
// in `values` (or otherwise unparseable) keeps the warning visible until
// the user fixes the input. Provider clears via `runtime.clearTarget(input)`
// before each commit/blur validation pass — the next valid value is the fix.
name: 'signal-warn-invalid',
semantic: {
family: 'signal',
verb: 'warn',
target: v.partRef('input'),
intent: 'risk',
sequence: 'post',
persistence: 'untilFix'
},
a11ySemantic: {
requiresPersistentTrace: true,
reducedMotionFallback: 'text'
}
}
],
parts: [
{
name: 'Provider',
kebab: 'provider',
archetype: 'provider',
kind: 'public',
defaultElement: 'div',
optional: false,
data: [
refactor(eidos): share number-field + css-field visual via spin-field NumberField and CssField are the same visual (a bordered field + input + increment/decrement triggers + scrubber, split/stacked layouts, sizes/ variants/colors, themeable glyphs); only their value model differs. They were two cloned recipes + CSS that drifted — a refinement to one (square flush buttons, divider, contrast) didn't reach the other. Unify into ONE shared source (the toggle-group structural-identity pattern): - New eidos/components/spin-field: recipe key `spin-field` (`--spin-field-*`) + spin-field.css with all the stepper-field rules, selecting `[data-spin- field*]`. Loaded via the foundation @import in index.css. - number-field + css-field morfos declare structural identity (`data-spin- field*` presence attrs on each part). The Provider emits them via syncAttrs; the sub-parts emit them in their soma `props` getter (number-field's soma hardcodes sub-part attrs rather than syncing the morfo). - Removed the `number-field` / `css-field` recipe keys; their CSS files are now stubs. A theme tints one component by scoping `[data-number-field] { --spin-field-… }`. - css-field thereby adopts number-field's refined steppers (square, flush, divider) — the drift fix the user asked for, now structural (no clone). Verified bit-for-bit in browser: number-field identical to baseline (split flush, stacked symmetric xs..xl, RTL, glyph token/children override); css-field now square/flush/divider. eidos-lint invalid 0; recipe contract passes (no orphans, loads-once); check + morfo:check clean for these. Docs: THEMING sections 33 (glyph tokens now `--spin-field-*`) + 34 (the shared layer); number-field / css-field READMEs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
4 months ago
// Structural identity: CssField IS a spin-field. These presence attrs
// let the shared spin-field eidos visual style it without cloning CSS
// per component (see eidos/components/spin-field).
{ attr: 'data-spin-field', value: v.literal(''), severity: 'required' },
{ attr: 'data-disabled', value: v.propRef('disabled'), severity: 'optional' },
{ attr: 'data-readonly', value: v.propRef('readonly'), severity: 'optional' },
{ attr: 'data-required', value: v.propRef('required'), severity: 'optional' },
{ attr: 'data-invalid', value: v.propRef('invalid'), severity: 'optional' },
{ attr: 'data-focused', value: v.propRef('focused'), severity: 'optional' },
{ attr: 'data-scrubbing', value: v.propRef('scrubbing'), severity: 'optional' }
],
aria: []
},
{
name: 'Input',
kebab: 'input',
archetype: 'input',
kind: 'public',
defaultElement: 'input',
role: 'spinbutton',
optional: false,
data: [
refactor(eidos): share number-field + css-field visual via spin-field NumberField and CssField are the same visual (a bordered field + input + increment/decrement triggers + scrubber, split/stacked layouts, sizes/ variants/colors, themeable glyphs); only their value model differs. They were two cloned recipes + CSS that drifted — a refinement to one (square flush buttons, divider, contrast) didn't reach the other. Unify into ONE shared source (the toggle-group structural-identity pattern): - New eidos/components/spin-field: recipe key `spin-field` (`--spin-field-*`) + spin-field.css with all the stepper-field rules, selecting `[data-spin- field*]`. Loaded via the foundation @import in index.css. - number-field + css-field morfos declare structural identity (`data-spin- field*` presence attrs on each part). The Provider emits them via syncAttrs; the sub-parts emit them in their soma `props` getter (number-field's soma hardcodes sub-part attrs rather than syncing the morfo). - Removed the `number-field` / `css-field` recipe keys; their CSS files are now stubs. A theme tints one component by scoping `[data-number-field] { --spin-field-… }`. - css-field thereby adopts number-field's refined steppers (square, flush, divider) — the drift fix the user asked for, now structural (no clone). Verified bit-for-bit in browser: number-field identical to baseline (split flush, stacked symmetric xs..xl, RTL, glyph token/children override); css-field now square/flush/divider. eidos-lint invalid 0; recipe contract passes (no orphans, loads-once); check + morfo:check clean for these. Docs: THEMING sections 33 (glyph tokens now `--spin-field-*`) + 34 (the shared layer); number-field / css-field READMEs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
4 months ago
{ attr: 'data-spin-field-input', value: v.literal(''), severity: 'required' },
{ attr: 'data-disabled', severity: 'optional' },
{ attr: 'data-readonly', severity: 'optional' },
{ attr: 'data-invalid', severity: 'optional' }
],
aria: [
{ attr: 'aria-valuenow', value: v.propRef('value'), severity: 'optional' },
{ attr: 'aria-valuetext', value: v.propRef('value'), severity: 'recommended' },
{
attr: 'aria-required',
value: v.propRef('required'),
severity: 'optional',
ariaBoolean: true
},
{
attr: 'aria-disabled',
value: v.propRef('disabled'),
severity: 'optional',
ariaBoolean: true
},
{
attr: 'aria-readonly',
value: v.propRef('readonly'),
severity: 'optional',
ariaBoolean: true
},
{
attr: 'aria-invalid',
value: v.propRef('invalid'),
severity: 'optional',
ariaBoolean: true
}
],
keyboard: [
{ key: 'ArrowUp', action: 'increment' },
{ key: 'ArrowDown', action: 'decrement' },
{ key: 'Shift+ArrowUp', action: 'increment-large' },
{ key: 'Shift+ArrowDown', action: 'decrement-large' },
{ key: 'PageUp', action: 'increment-large' },
{ key: 'PageDown', action: 'decrement-large' },
{ key: 'Home', action: 'first-item' },
{ key: 'End', action: 'last-item' },
{ key: 'Enter', action: 'commit' }
]
},
{
name: 'IncrementTrigger',
kebab: 'increment-trigger',
archetype: 'trigger',
kind: 'public',
defaultElement: 'button',
role: 'button',
optional: true,
refactor(eidos): share number-field + css-field visual via spin-field NumberField and CssField are the same visual (a bordered field + input + increment/decrement triggers + scrubber, split/stacked layouts, sizes/ variants/colors, themeable glyphs); only their value model differs. They were two cloned recipes + CSS that drifted — a refinement to one (square flush buttons, divider, contrast) didn't reach the other. Unify into ONE shared source (the toggle-group structural-identity pattern): - New eidos/components/spin-field: recipe key `spin-field` (`--spin-field-*`) + spin-field.css with all the stepper-field rules, selecting `[data-spin- field*]`. Loaded via the foundation @import in index.css. - number-field + css-field morfos declare structural identity (`data-spin- field*` presence attrs on each part). The Provider emits them via syncAttrs; the sub-parts emit them in their soma `props` getter (number-field's soma hardcodes sub-part attrs rather than syncing the morfo). - Removed the `number-field` / `css-field` recipe keys; their CSS files are now stubs. A theme tints one component by scoping `[data-number-field] { --spin-field-… }`. - css-field thereby adopts number-field's refined steppers (square, flush, divider) — the drift fix the user asked for, now structural (no clone). Verified bit-for-bit in browser: number-field identical to baseline (split flush, stacked symmetric xs..xl, RTL, glyph token/children override); css-field now square/flush/divider. eidos-lint invalid 0; recipe contract passes (no orphans, loads-once); check + morfo:check clean for these. Docs: THEMING sections 33 (glyph tokens now `--spin-field-*`) + 34 (the shared layer); number-field / css-field READMEs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
4 months ago
data: [
{ attr: 'data-spin-field-increment-trigger', value: v.literal(''), severity: 'required' },
{ attr: 'data-disabled', severity: 'optional' }
],
aria: [
{ attr: 'type', value: v.literal('button') },
{
attr: 'aria-label',
value: v.commonRef('buttons.increment', 'Increment'),
severity: 'recommended'
},
{
attr: 'aria-disabled',
value: v.literal('true'),
severity: 'optional',
condition: { when: 'prop-truthy', prop: 'disabled' }
}
]
},
{
name: 'DecrementTrigger',
kebab: 'decrement-trigger',
archetype: 'trigger',
kind: 'public',
defaultElement: 'button',
role: 'button',
optional: true,
refactor(eidos): share number-field + css-field visual via spin-field NumberField and CssField are the same visual (a bordered field + input + increment/decrement triggers + scrubber, split/stacked layouts, sizes/ variants/colors, themeable glyphs); only their value model differs. They were two cloned recipes + CSS that drifted — a refinement to one (square flush buttons, divider, contrast) didn't reach the other. Unify into ONE shared source (the toggle-group structural-identity pattern): - New eidos/components/spin-field: recipe key `spin-field` (`--spin-field-*`) + spin-field.css with all the stepper-field rules, selecting `[data-spin- field*]`. Loaded via the foundation @import in index.css. - number-field + css-field morfos declare structural identity (`data-spin- field*` presence attrs on each part). The Provider emits them via syncAttrs; the sub-parts emit them in their soma `props` getter (number-field's soma hardcodes sub-part attrs rather than syncing the morfo). - Removed the `number-field` / `css-field` recipe keys; their CSS files are now stubs. A theme tints one component by scoping `[data-number-field] { --spin-field-… }`. - css-field thereby adopts number-field's refined steppers (square, flush, divider) — the drift fix the user asked for, now structural (no clone). Verified bit-for-bit in browser: number-field identical to baseline (split flush, stacked symmetric xs..xl, RTL, glyph token/children override); css-field now square/flush/divider. eidos-lint invalid 0; recipe contract passes (no orphans, loads-once); check + morfo:check clean for these. Docs: THEMING sections 33 (glyph tokens now `--spin-field-*`) + 34 (the shared layer); number-field / css-field READMEs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
4 months ago
data: [
{ attr: 'data-spin-field-decrement-trigger', value: v.literal(''), severity: 'required' },
{ attr: 'data-disabled', severity: 'optional' }
],
aria: [
{ attr: 'type', value: v.literal('button') },
{
attr: 'aria-label',
value: v.commonRef('buttons.decrement', 'Decrement'),
severity: 'recommended'
},
{
attr: 'aria-disabled',
value: v.literal('true'),
severity: 'optional',
condition: { when: 'prop-truthy', prop: 'disabled' }
}
]
},
{
name: 'Scrubber',
kebab: 'scrubber',
archetype: 'thumb',
kind: 'public',
defaultElement: 'div',
role: 'presentation',
optional: true,
data: [
refactor(eidos): share number-field + css-field visual via spin-field NumberField and CssField are the same visual (a bordered field + input + increment/decrement triggers + scrubber, split/stacked layouts, sizes/ variants/colors, themeable glyphs); only their value model differs. They were two cloned recipes + CSS that drifted — a refinement to one (square flush buttons, divider, contrast) didn't reach the other. Unify into ONE shared source (the toggle-group structural-identity pattern): - New eidos/components/spin-field: recipe key `spin-field` (`--spin-field-*`) + spin-field.css with all the stepper-field rules, selecting `[data-spin- field*]`. Loaded via the foundation @import in index.css. - number-field + css-field morfos declare structural identity (`data-spin- field*` presence attrs on each part). The Provider emits them via syncAttrs; the sub-parts emit them in their soma `props` getter (number-field's soma hardcodes sub-part attrs rather than syncing the morfo). - Removed the `number-field` / `css-field` recipe keys; their CSS files are now stubs. A theme tints one component by scoping `[data-number-field] { --spin-field-… }`. - css-field thereby adopts number-field's refined steppers (square, flush, divider) — the drift fix the user asked for, now structural (no clone). Verified bit-for-bit in browser: number-field identical to baseline (split flush, stacked symmetric xs..xl, RTL, glyph token/children override); css-field now square/flush/divider. eidos-lint invalid 0; recipe contract passes (no orphans, loads-once); check + morfo:check clean for these. Docs: THEMING sections 33 (glyph tokens now `--spin-field-*`) + 34 (the shared layer); number-field / css-field READMEs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
4 months ago
{ attr: 'data-spin-field-scrubber', value: v.literal(''), severity: 'required' },
{ attr: 'data-scrubbing', severity: 'optional' },
{ attr: 'data-disabled', severity: 'optional' }
],
aria: [{ attr: 'aria-hidden', value: v.literal('true') }]
}
]
} as const satisfies Morfo;

Powered by TurnKey Linux.