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.
227 lines
5.6 KiB
227 lines
5.6 KiB
import type { Morfo } from '../types';
|
|
import { v } from '../types';
|
|
|
|
export const editableMorfo = {
|
|
name: 'Editable',
|
|
kebab: 'editable',
|
|
scope: ['soma', 'sema'],
|
|
texts: {
|
|
label: '#?components.editable.label|Editable'
|
|
},
|
|
apg: 'https://www.w3.org/WAI/ARIA/apg/patterns/textbox/',
|
|
events: [
|
|
{
|
|
name: 'shift-enter-mode',
|
|
semantic: {
|
|
family: 'shift',
|
|
verb: 'enter-mode',
|
|
target: v.partRef('provider'),
|
|
sequence: 'post'
|
|
}
|
|
},
|
|
{
|
|
name: 'commit-save',
|
|
semantic: {
|
|
family: 'commit',
|
|
verb: 'save',
|
|
target: v.partRef('provider'),
|
|
intent: 'affirm',
|
|
sequence: 'post'
|
|
}
|
|
},
|
|
{
|
|
name: 'commit-cancel',
|
|
semantic: {
|
|
family: 'commit',
|
|
verb: 'cancel',
|
|
target: v.partRef('provider'),
|
|
intent: 'neutral',
|
|
sequence: 'post'
|
|
}
|
|
}
|
|
],
|
|
parts: [
|
|
{
|
|
name: 'Provider',
|
|
kebab: 'provider',
|
|
archetype: 'provider',
|
|
kind: 'public',
|
|
defaultElement: 'div',
|
|
optional: false,
|
|
data: [
|
|
{ attr: 'data-editing', value: v.propRef('editing'), severity: 'optional' },
|
|
{ attr: 'data-empty', value: v.propRef('empty'), severity: 'optional' },
|
|
{ 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' }
|
|
],
|
|
aria: [
|
|
{
|
|
attr: 'aria-required',
|
|
value: v.literal('true'),
|
|
severity: 'optional',
|
|
condition: { when: 'prop-truthy', prop: 'required' }
|
|
},
|
|
{
|
|
attr: 'aria-invalid',
|
|
value: v.literal('true'),
|
|
severity: 'optional',
|
|
condition: { when: 'prop-truthy', prop: 'invalid' }
|
|
}
|
|
]
|
|
},
|
|
{
|
|
name: 'Area',
|
|
kebab: 'area',
|
|
kind: 'public',
|
|
defaultElement: 'div',
|
|
optional: true,
|
|
data: [
|
|
{ attr: 'data-editing', value: v.propRef('editing'), severity: 'optional' },
|
|
{ attr: 'data-disabled', value: v.propRef('disabled'), severity: 'optional' },
|
|
{ attr: 'data-readonly', value: v.propRef('readonly'), severity: 'optional' }
|
|
],
|
|
aria: []
|
|
},
|
|
{
|
|
name: 'Control',
|
|
kebab: 'control',
|
|
kind: 'public',
|
|
defaultElement: 'div',
|
|
optional: true,
|
|
data: [
|
|
{ attr: 'data-editing', value: v.propRef('editing'), severity: 'optional' },
|
|
{ attr: 'data-disabled', value: v.propRef('disabled'), severity: 'optional' },
|
|
{ attr: 'data-readonly', value: v.propRef('readonly'), severity: 'optional' }
|
|
],
|
|
aria: []
|
|
},
|
|
{
|
|
name: 'Preview',
|
|
kebab: 'preview',
|
|
archetype: 'preview',
|
|
kind: 'public',
|
|
defaultElement: 'div',
|
|
role: 'textbox',
|
|
optional: false,
|
|
data: [
|
|
{ attr: 'data-placeholder-shown', severity: 'optional' },
|
|
{ attr: 'data-disabled', severity: 'optional' },
|
|
{ attr: 'data-readonly', severity: 'optional' }
|
|
],
|
|
aria: [
|
|
{ attr: 'aria-readonly', value: v.literal('true') },
|
|
{ attr: 'aria-label', value: v.propRef('placeholder'), severity: 'optional' }
|
|
]
|
|
},
|
|
{
|
|
name: 'Input',
|
|
kebab: 'input',
|
|
archetype: 'input',
|
|
kind: 'public',
|
|
defaultElement: 'input',
|
|
optional: false,
|
|
data: [
|
|
{ attr: 'data-disabled', severity: 'optional' },
|
|
{ attr: 'data-readonly', severity: 'optional' },
|
|
{ attr: 'data-invalid', severity: 'optional' }
|
|
],
|
|
aria: [
|
|
{
|
|
attr: 'aria-disabled',
|
|
value: v.literal('true'),
|
|
severity: 'optional',
|
|
condition: { when: 'prop-truthy', prop: 'disabled' }
|
|
},
|
|
{
|
|
attr: 'aria-invalid',
|
|
value: v.literal('true'),
|
|
severity: 'optional',
|
|
condition: { when: 'prop-truthy', prop: 'invalid' }
|
|
}
|
|
],
|
|
keyboard: [
|
|
{ key: 'Enter', action: 'submit' },
|
|
{ key: 'Escape', action: 'cancel' }
|
|
]
|
|
},
|
|
{
|
|
name: 'HiddenInput',
|
|
kebab: 'hidden-input',
|
|
archetype: 'input',
|
|
kind: 'public',
|
|
defaultElement: 'input',
|
|
optional: true,
|
|
data: [],
|
|
aria: [{ attr: 'aria-hidden', value: v.literal('true') }]
|
|
},
|
|
{
|
|
name: 'EditTrigger',
|
|
kebab: 'edit-trigger',
|
|
archetype: 'trigger',
|
|
kind: 'public',
|
|
defaultElement: 'button',
|
|
role: 'button',
|
|
optional: true,
|
|
data: [
|
|
{ attr: 'data-editing', value: v.propRef('editing'), severity: 'optional' },
|
|
{ attr: 'data-disabled', severity: 'optional' },
|
|
{ attr: 'data-readonly', severity: 'optional' }
|
|
],
|
|
aria: [
|
|
{ attr: 'type', value: v.literal('button') },
|
|
{
|
|
attr: 'aria-label',
|
|
value: v.commonRef('buttons.edit', 'Edit'),
|
|
severity: 'recommended'
|
|
}
|
|
]
|
|
},
|
|
{
|
|
name: 'SubmitTrigger',
|
|
kebab: 'submit-trigger',
|
|
archetype: 'action',
|
|
kind: 'public',
|
|
defaultElement: 'button',
|
|
role: 'button',
|
|
optional: true,
|
|
data: [
|
|
{ attr: 'data-editing', value: v.propRef('editing'), severity: 'optional' },
|
|
{ attr: 'data-disabled', severity: 'optional' },
|
|
{ attr: 'data-readonly', severity: 'optional' }
|
|
],
|
|
aria: [
|
|
{ attr: 'type', value: v.literal('button') },
|
|
{
|
|
attr: 'aria-label',
|
|
value: v.commonRef('buttons.save', 'Save'),
|
|
severity: 'recommended'
|
|
}
|
|
]
|
|
},
|
|
{
|
|
name: 'CancelTrigger',
|
|
kebab: 'cancel-trigger',
|
|
archetype: 'action',
|
|
kind: 'public',
|
|
defaultElement: 'button',
|
|
role: 'button',
|
|
optional: true,
|
|
data: [
|
|
{ attr: 'data-editing', value: v.propRef('editing'), severity: 'optional' },
|
|
{ attr: 'data-disabled', severity: 'optional' },
|
|
{ attr: 'data-readonly', severity: 'optional' }
|
|
],
|
|
aria: [
|
|
{ attr: 'type', value: v.literal('button') },
|
|
{
|
|
attr: 'aria-label',
|
|
value: v.commonRef('buttons.cancel', 'Cancel'),
|
|
severity: 'recommended'
|
|
}
|
|
]
|
|
}
|
|
]
|
|
} as const satisfies Morfo;
|