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.
232 lines
6.0 KiB
232 lines
6.0 KiB
import type { Morfo } from '../types';
|
|
import { v } from '../types';
|
|
|
|
export const treeViewMorfo = {
|
|
name: 'TreeView',
|
|
kebab: 'tree-view',
|
|
scope: ['soma', 'sema', 'eidos'],
|
|
// expression resolved via the sema pack at
|
|
// `src/uix/sema/components/tree-view.ts` — soft emerge expand/collapse
|
|
// + subtle commit on item select. Trees are explored repeatedly;
|
|
// signature stays sober.
|
|
expression: 'pack',
|
|
apg: 'https://www.w3.org/WAI/ARIA/apg/patterns/treeview/',
|
|
texts: {
|
|
label: '#?components.tree-view.label|Tree'
|
|
},
|
|
events: [
|
|
{
|
|
name: 'commit-select',
|
|
semantic: {
|
|
family: 'commit',
|
|
verb: 'select',
|
|
target: v.partRef('item'),
|
|
intent: 'affirm',
|
|
sequence: 'post',
|
|
// A branch is selectable too, and it is a different part from a
|
|
// leaf: the provider hands whichever node was chosen, which is
|
|
// why the pack carries a rule for each.
|
|
allowedTargets: [v.partRef('branch')]
|
|
}
|
|
},
|
|
{
|
|
// Expand a node — content contained in the tree becomes part of
|
|
// the visible field. Per book cap. 26 literal: "emerge.expand —
|
|
// una región crece y revela contenido (accordion, details,
|
|
// sección desplegable)." Tree expand fits exactly. Was
|
|
// misclassified as `shift.navigate` (which is for context/regime
|
|
// change, not content revealing).
|
|
//
|
|
// Target is `branch` (not `item`): items are leaves — they
|
|
// don't expand. The data-event-* stamp lands on the branch
|
|
// element (`data-tree-view-branch`), which is what the sema
|
|
// pack selector targets.
|
|
name: 'emerge-expand',
|
|
semantic: {
|
|
family: 'emerge',
|
|
verb: 'expand',
|
|
target: v.partRef('branch'),
|
|
sequence: 'post'
|
|
}
|
|
},
|
|
{
|
|
// Collapse a node — per book cap. 26: "emerge.collapse — una
|
|
// región se contrae." Target is `branch` for the same reason
|
|
// as emerge-expand above.
|
|
name: 'emerge-collapse',
|
|
semantic: {
|
|
family: 'emerge',
|
|
verb: 'collapse',
|
|
target: v.partRef('branch'),
|
|
sequence: 'post'
|
|
}
|
|
}
|
|
],
|
|
direction: {},
|
|
focus: {
|
|
kind: 'roving',
|
|
parts: ['item'],
|
|
orientation: 'vertical',
|
|
executor: {
|
|
custom:
|
|
'Flattened-tree projection with typeahead and expand/collapse/* keys: the movement set exceeds next/prev over a static candidate list (eje focus-first F2).'
|
|
}
|
|
},
|
|
|
|
parts: [
|
|
{
|
|
name: 'Provider',
|
|
kebab: 'provider',
|
|
archetype: 'provider',
|
|
kind: 'public',
|
|
defaultElement: 'ul',
|
|
role: 'tree',
|
|
optional: false,
|
|
data: [],
|
|
aria: [
|
|
{
|
|
attr: 'aria-label',
|
|
value: v.translationRef('#?components.tree-view.label|Tree'),
|
|
severity: 'recommended'
|
|
},
|
|
{
|
|
attr: 'aria-multiselectable',
|
|
value: v.literal('true'),
|
|
severity: 'optional',
|
|
condition: { when: 'prop-truthy', prop: 'multiple' }
|
|
}
|
|
],
|
|
keyboard: [
|
|
{ key: 'ArrowDown', action: 'next-item' },
|
|
{ key: 'ArrowUp', action: 'prev-item' },
|
|
{ key: 'ArrowRight', action: 'expand' },
|
|
{ key: 'ArrowLeft', action: 'collapse' },
|
|
{ key: 'Home', action: 'first-item' },
|
|
{ key: 'End', action: 'last-item' },
|
|
{ key: 'Enter', action: 'activate' },
|
|
{ key: ' ', action: 'select' }
|
|
]
|
|
},
|
|
{
|
|
name: 'Branch',
|
|
kebab: 'branch',
|
|
archetype: 'item',
|
|
kind: 'public',
|
|
defaultElement: 'div',
|
|
role: 'treeitem',
|
|
optional: false,
|
|
states: ['open', 'closed'],
|
|
data: [
|
|
{ attr: 'data-state', values: ['open', 'closed'] },
|
|
{ attr: 'data-value' },
|
|
{ attr: 'data-selected', severity: 'optional' },
|
|
{ attr: 'data-disabled', severity: 'optional' },
|
|
{ attr: 'data-depth' }
|
|
],
|
|
aria: [
|
|
{ attr: 'aria-expanded', value: v.stateRef('open') },
|
|
{
|
|
attr: 'aria-selected',
|
|
value: v.literal('true'),
|
|
severity: 'optional',
|
|
condition: { when: 'prop-truthy', prop: 'selected' }
|
|
},
|
|
{ attr: 'aria-level', value: v.propRef('depth') },
|
|
{
|
|
attr: 'aria-disabled',
|
|
value: v.literal('true'),
|
|
severity: 'optional',
|
|
condition: { when: 'prop-truthy', prop: 'disabled' }
|
|
}
|
|
]
|
|
},
|
|
{
|
|
name: 'BranchControl',
|
|
kebab: 'branch-control',
|
|
kind: 'public',
|
|
defaultElement: 'div',
|
|
optional: false,
|
|
states: ['open', 'closed'],
|
|
data: [
|
|
{ attr: 'data-state', values: ['open', 'closed'] },
|
|
{ attr: 'data-value' },
|
|
{ attr: 'data-selected', severity: 'optional' },
|
|
{ attr: 'data-disabled', severity: 'optional' }
|
|
],
|
|
aria: []
|
|
},
|
|
{
|
|
name: 'BranchContent',
|
|
kebab: 'branch-content',
|
|
archetype: 'content',
|
|
kind: 'public',
|
|
defaultElement: 'div',
|
|
role: 'group',
|
|
optional: false,
|
|
states: ['open', 'closed'],
|
|
data: [{ attr: 'data-state', values: ['open', 'closed'] }],
|
|
aria: []
|
|
},
|
|
{
|
|
name: 'BranchIndicator',
|
|
kebab: 'branch-indicator',
|
|
archetype: 'indicator',
|
|
kind: 'public',
|
|
defaultElement: 'div',
|
|
optional: true,
|
|
states: ['open', 'closed'],
|
|
data: [{ attr: 'data-state', values: ['open', 'closed'] }],
|
|
aria: [{ attr: 'aria-hidden', value: v.literal('true') }]
|
|
},
|
|
{
|
|
name: 'BranchIndentGuide',
|
|
kebab: 'branch-indent-guide',
|
|
kind: 'public',
|
|
defaultElement: 'div',
|
|
optional: true,
|
|
data: [],
|
|
aria: [{ attr: 'aria-hidden', value: v.literal('true') }]
|
|
},
|
|
{
|
|
name: 'Item',
|
|
kebab: 'item',
|
|
archetype: 'item',
|
|
kind: 'public',
|
|
defaultElement: 'div',
|
|
role: 'treeitem',
|
|
optional: false,
|
|
data: [
|
|
{ attr: 'data-value' },
|
|
{ attr: 'data-selected', severity: 'optional' },
|
|
{ attr: 'data-disabled', severity: 'optional' },
|
|
{ attr: 'data-depth' }
|
|
],
|
|
aria: [
|
|
{
|
|
attr: 'aria-selected',
|
|
value: v.literal('true'),
|
|
severity: 'optional',
|
|
condition: { when: 'prop-truthy', prop: 'selected' }
|
|
},
|
|
{ attr: 'aria-level', value: v.propRef('depth') },
|
|
{
|
|
attr: 'aria-disabled',
|
|
value: v.literal('true'),
|
|
severity: 'optional',
|
|
condition: { when: 'prop-truthy', prop: 'disabled' }
|
|
}
|
|
]
|
|
},
|
|
{
|
|
name: 'Label',
|
|
kebab: 'label',
|
|
archetype: 'label',
|
|
kind: 'public',
|
|
defaultElement: 'div',
|
|
optional: true,
|
|
data: [],
|
|
aria: []
|
|
}
|
|
]
|
|
} as const satisfies Morfo;
|