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/toolbar.ts

183 lines
4.5 KiB

import type { Morfo } from '../types';
import { v } from '../types';
export const toolbarMorfo = {
name: 'Toolbar',
kebab: 'toolbar',
scope: ['soma', 'sema', 'eidos'],
expression: 'pack',
texts: {
label: '#?components.toolbar.label|Toolbar'
},
apg: 'https://www.w3.org/WAI/ARIA/apg/patterns/toolbar/',
events: [
{
name: 'commit-toggle',
semantic: {
family: 'commit',
verb: 'toggle',
target: v.partRef('provider'),
intent: 'neutral',
sequence: 'post',
// The toggled item of a group is a repeated part; the provider
// hands the one that flipped.
allowedTargets: [v.partRef('group-item')]
}
}
],
direction: {},
focus: {
kind: 'roving',
// The composite roves across every interactive child class — a singular
// part would misdeclare this family (eje focus-first, 2026-08-26).
parts: ['button', 'link', 'group-item'],
orientation: 'horizontal',
loop: true
},
parts: [
{
name: 'Provider',
kebab: 'provider',
archetype: 'provider',
kind: 'public',
defaultElement: 'div',
role: 'toolbar',
optional: false,
data: [
{
attr: 'data-orientation',
values: ['horizontal', 'vertical'],
value: v.propRef('orientation')
}
],
aria: [{ attr: 'aria-orientation', value: v.propRef('orientation') }],
// Conditions added in the P1·CONTRATO keyboard wave: four arrows were
// declared unconditionally while only TWO ever move. The shared
// roving primitive resolves its pair through `getDirectionalKeys`
// (toolbar-provider :77), so the cross-axis pair is inert.
keyboard: [
{
key: 'ArrowRight',
action: 'next-item',
condition: { when: 'prop-equals', prop: 'orientation', value: 'horizontal' }
},
{
key: 'ArrowLeft',
action: 'prev-item',
condition: { when: 'prop-equals', prop: 'orientation', value: 'horizontal' }
},
{
key: 'ArrowDown',
action: 'next-item',
condition: { when: 'prop-equals', prop: 'orientation', value: 'vertical' }
},
{
key: 'ArrowUp',
action: 'prev-item',
condition: { when: 'prop-equals', prop: 'orientation', value: 'vertical' }
},
{ key: 'Home', action: 'first-item' },
{ key: 'End', action: 'last-item' }
]
},
{
name: 'Button',
kebab: 'button',
kind: 'public',
defaultElement: 'button',
role: 'button',
optional: true,
data: [
{ attr: 'data-disabled', value: v.propRef('disabled'), severity: 'optional' },
{
attr: 'data-orientation',
values: ['horizontal', 'vertical'],
value: v.propRef('orientation')
}
],
attrs: [{ attr: 'type', value: v.literal('button') }],
aria: []
},
{
name: 'Link',
kebab: 'link',
archetype: 'trigger',
kind: 'public',
defaultElement: 'a',
optional: true,
data: [
{
attr: 'data-orientation',
values: ['horizontal', 'vertical'],
value: v.propRef('orientation')
}
],
aria: []
},
{
name: 'Group',
kebab: 'group',
archetype: 'group',
kind: 'public',
defaultElement: 'div',
role: 'group',
optional: true,
data: [
{
attr: 'data-orientation',
values: ['horizontal', 'vertical'],
value: v.propRef('orientation')
},
{ attr: 'data-disabled', value: v.propRef('disabled'), severity: 'optional' }
],
aria: [
{
attr: 'aria-disabled',
value: v.literal('true'),
severity: 'optional',
condition: { when: 'prop-truthy', prop: 'disabled' }
}
]
},
{
name: 'GroupItem',
kebab: 'group-item',
kind: 'public',
defaultElement: 'button',
role: 'button',
optional: true,
states: ['on', 'off'],
data: [
{ attr: 'data-state', values: ['on', 'off'], value: v.stateRef('on') },
{ attr: 'data-value', value: v.propRef('value'), emit: 'value' },
{ attr: 'data-disabled', value: v.propRef('disabled'), severity: 'optional' },
{
attr: 'data-orientation',
values: ['horizontal', 'vertical'],
value: v.propRef('orientation')
}
],
attrs: [{ attr: 'type', value: v.literal('button') }],
aria: [{ attr: 'aria-pressed', value: v.stateRef('on') }]
},
{
name: 'Separator',
kebab: 'separator',
archetype: 'separator',
kind: 'public',
defaultElement: 'div',
role: 'separator',
optional: true,
data: [
{
attr: 'data-orientation',
values: ['horizontal', 'vertical'],
value: v.propRef('orientation')
}
],
aria: [{ attr: 'aria-orientation', value: v.propRef('orientation') }]
}
]
} as const satisfies Morfo;

Powered by TurnKey Linux.