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

190 lines
4.1 KiB

import type { Morfo } from '../types';
import { v } from '../types';
export const selectMorfo = {
name: 'Select',
kebab: 'select',
scope: ['soma'],
apg: 'https://www.w3.org/WAI/ARIA/apg/patterns/combobox/',
focus: {
initial: 'first-focusable',
trap: true,
return: 'trigger',
restore: true
},
parts: [
{
name: 'Provider',
kebab: 'provider',
archetype: 'provider',
kind: 'virtual',
defaultElement: 'none',
optional: false,
data: [],
aria: []
},
{
name: 'Trigger',
kebab: 'trigger',
archetype: 'trigger',
kind: 'public',
defaultElement: 'button',
role: 'combobox',
optional: false,
states: ['open', 'closed'],
data: [
{ attr: 'data-state', values: ['open', 'closed'] },
{ attr: 'data-disabled', severity: 'optional' },
{ attr: 'data-placeholder', severity: 'optional' }
],
aria: [
{ attr: 'type', value: v.literal('button') },
{ attr: 'aria-haspopup', value: v.literal('listbox') },
{ attr: 'aria-expanded', value: v.stateRef('open') },
{
attr: 'aria-controls',
value: v.partRef('content'),
condition: { when: 'part-present', part: 'content' },
severity: 'recommended'
},
{ attr: 'aria-activedescendant', value: v.propRef('highlightedId'), severity: 'optional' },
{
attr: 'aria-required',
value: v.literal('true'),
severity: 'optional',
condition: { when: 'prop-truthy', prop: 'required' }
}
],
keyboard: [
{ key: 'Enter', action: 'open' },
{ key: ' ', action: 'open' },
{ key: 'ArrowDown', action: 'next-item' },
{ key: 'ArrowUp', action: 'prev-item' },
{ key: 'Home', action: 'first-item' },
{ key: 'End', action: 'last-item' },
{ key: 'Escape', action: 'close' }
]
},
{
name: 'Value',
kebab: 'value',
archetype: 'description',
kind: 'public',
defaultElement: 'span',
optional: true,
data: [],
aria: []
},
{
name: 'Content',
kebab: 'content',
archetype: 'content',
kind: 'public',
defaultElement: 'div',
role: 'listbox',
optional: false,
states: ['open', 'closed'],
data: [{ attr: 'data-state', values: ['open', 'closed'] }],
aria: [
{
attr: 'aria-labelledby',
value: v.partRef('trigger'),
condition: { when: 'part-present', part: 'trigger' },
severity: 'recommended'
},
{
attr: 'aria-multiselectable',
value: v.literal('true'),
severity: 'optional',
condition: { when: 'prop-truthy', prop: 'multiple' }
}
]
},
{
name: 'Viewport',
kebab: 'viewport',
archetype: 'viewport',
kind: 'public',
defaultElement: 'div',
optional: true,
data: [],
aria: []
},
{
name: 'Item',
kebab: 'item',
archetype: 'item',
kind: 'public',
defaultElement: 'div',
role: 'option',
optional: false,
states: ['checked', 'unchecked'],
data: [
{ attr: 'data-state', values: ['checked', 'unchecked'] },
{ attr: 'data-value' },
{ attr: 'data-disabled', severity: 'optional' }
],
aria: [
{ attr: 'aria-selected', value: v.stateRef('checked') },
{
attr: 'aria-disabled',
value: v.literal('true'),
severity: 'optional',
condition: { when: 'prop-truthy', prop: 'disabled' }
}
]
},
{
name: 'Group',
kebab: 'group',
archetype: 'group',
kind: 'public',
defaultElement: 'div',
role: 'group',
optional: true,
data: [],
aria: [
{
attr: 'aria-labelledby',
value: v.partRef('group-heading'),
condition: { when: 'part-present', part: 'group-heading' },
severity: 'recommended'
}
]
},
{
name: 'GroupHeading',
kebab: 'group-heading',
archetype: 'header',
kind: 'public',
defaultElement: 'div',
optional: true,
data: [],
aria: []
},
{
name: 'Separator',
kebab: 'separator',
archetype: 'separator',
kind: 'public',
defaultElement: 'div',
role: 'separator',
optional: true,
data: [],
aria: []
},
{
name: 'Arrow',
kebab: 'arrow',
archetype: 'arrow',
kind: 'public',
defaultElement: 'div',
optional: true,
data: [],
aria: []
}
]
} as const satisfies Morfo;

Powered by TurnKey Linux.