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

301 lines
7.2 KiB

import type { Morfo } from '../types';
import { v } from '../types';
export const comboboxMorfo = {
name: 'Combobox',
kebab: 'combobox',
scope: ['soma', 'sema'],
apg: 'https://www.w3.org/WAI/ARIA/apg/patterns/combobox/',
texts: {
label: '#?components.combobox.label|Combobox',
toggle: '#?components.combobox.toggle|Toggle',
clear: '#?components.combobox.clear|Clear value',
selectedTags: '#?components.combobox.selected-tags|Selected values',
selectedTagRemove: '#?components.combobox.selected-tag-remove|Remove'
},
events: [
{
name: 'commit-select',
semantic: {
family: 'commit',
verb: 'select',
target: v.partRef('item'),
intent: 'affirm',
sequence: 'post'
}
},
{
name: 'commit-unselect',
semantic: {
family: 'commit',
verb: 'unselect',
target: v.partRef('item'),
intent: 'affirm',
sequence: 'post'
}
}
],
parts: [
{
name: 'Provider',
kebab: 'provider',
archetype: 'provider',
kind: 'public',
defaultElement: 'div',
optional: false,
states: ['open', 'closed'],
data: [
{ attr: 'data-state', values: ['open', 'closed'], value: v.stateRef('open') },
{ attr: 'data-disabled', value: v.propRef('disabled'), severity: 'optional' },
{ attr: 'data-type', values: ['single', 'multiple'], value: v.propRef('type') },
{ attr: 'data-empty', value: v.propRef('empty'), severity: 'optional' }
],
aria: []
},
{
name: 'Input',
kebab: 'input',
archetype: 'input',
kind: 'public',
defaultElement: 'input',
role: 'combobox',
optional: false,
states: ['open', 'closed'],
data: [
{ attr: 'data-state', values: ['open', 'closed'] },
{ attr: 'data-disabled', severity: 'optional' }
],
aria: [
{ 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-autocomplete', value: v.literal('list') },
{
attr: 'aria-required',
value: v.literal('true'),
severity: 'optional',
condition: { when: 'prop-truthy', prop: 'required' }
}
],
keyboard: [
{ key: 'ArrowDown', action: 'next-item' },
{ key: 'ArrowUp', action: 'prev-item' },
{ key: 'Home', action: 'first-item' },
{ key: 'End', action: 'last-item' },
{ key: 'Enter', action: 'select' },
{ key: 'Escape', action: 'close' },
{ key: 'Backspace', action: 'remove-last' }
]
},
{
name: 'Trigger',
kebab: 'trigger',
archetype: 'trigger',
kind: 'public',
defaultElement: 'button',
role: 'button',
optional: true,
states: ['open', 'closed'],
data: [
{ attr: 'data-state', values: ['open', 'closed'] },
{ attr: 'data-disabled', severity: 'optional' }
],
aria: [
{ attr: 'type', value: v.literal('button') },
{
attr: 'aria-label',
value: v.translationRef('#?components.combobox.toggle|Toggle'),
severity: 'recommended'
},
{ 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'
}
]
},
{
name: 'ClearButton',
kebab: 'clear-button',
archetype: 'trigger',
kind: 'public',
defaultElement: 'button',
role: 'button',
optional: true,
data: [{ attr: 'data-disabled', value: v.propRef('clearDisabled'), severity: 'optional' }],
aria: [
{ attr: 'type', value: v.literal('button') },
{
attr: 'aria-label',
value: v.translationRef('#?components.combobox.clear|Clear value'),
severity: 'recommended'
}
]
},
{
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('input'),
condition: { when: 'part-present', part: 'input' },
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-label', severity: 'optional' },
{ attr: 'data-highlighted', severity: 'optional' },
{ attr: 'data-disabled', severity: 'optional' }
],
aria: [
{ attr: 'aria-selected', value: v.stateRef('checked') }
]
},
{
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: []
},
{
name: 'SelectedTags',
kebab: 'selected-tags',
archetype: 'group',
kind: 'public',
defaultElement: 'div',
role: 'group',
optional: true,
data: [
{ attr: 'data-empty', value: v.propRef('selectedTagsEmpty'), severity: 'optional' }
],
aria: [
{
attr: 'aria-label',
value: v.translationRef('#?components.combobox.selected-tags|Selected values'),
severity: 'recommended'
}
]
},
{
name: 'SelectedTag',
kebab: 'selected-tag',
archetype: 'item',
kind: 'public',
defaultElement: 'span',
optional: true,
data: [
{ attr: 'data-value' },
{ attr: 'data-label', severity: 'optional' },
{ attr: 'data-disabled', severity: 'optional' }
],
aria: []
},
{
name: 'SelectedTagRemove',
kebab: 'selected-tag-remove',
archetype: 'trigger',
kind: 'public',
defaultElement: 'button',
role: 'button',
optional: true,
data: [{ attr: 'data-disabled', severity: 'optional' }],
aria: [
{ attr: 'type', value: v.literal('button') },
{
attr: 'aria-label',
value: v.translationRef('#?components.combobox.selected-tag-remove|Remove'),
severity: 'recommended'
}
]
}
]
} as const satisfies Morfo;

Powered by TurnKey Linux.