import { ValueType } from '../base/type' ; import { SortDirection } from '../base/enum' ; hidden export class AriaService { public setOptions ( target , options ) { let props = Object . keys ( options ) ; props . forEach ( ( name ) => setStateAndProperties ( target , config [ name ] , options [ name ] ) ) ; } public setExpand ( target , expand ) { setStateAndProperties ( target , config . expand , expand ) ; } public setSort ( target , direction ? ) { setStateAndProperties ( target , config . sort , direction , typeof direction === 'boolean' ) ; } public setBusy ( target , isBusy ) { setStateAndProperties ( target , config . busy , isBusy ) ; setStateAndProperties ( target , config . invalid , null , true ) ; } public setGrabbed ( target , isGrabbed , remove ? ) { setStateAndProperties ( target , config . grabbed , isGrabbed , remove ) ; } public setDropTarget ( target , isTarget ) { setStateAndProperties ( target , config . dropeffect , 'copy' , ! isTarget ) ; } } hidden function setStateAndProperties ( target , attribute ? , value ? , remove ? ) { if ( remove ) { target . removeAttribute ( attribute ) ; return ; } if ( target ) { target . setAttribute ( attribute , < string > value ) ; } } hidden export interface IAriaOptions < T > { role ? : string ; expand ? : T ; collapse ? : T ; selected ? : T ; multiselectable ? : T ; sort ? : T | 'none' ; busy ? : T ; invalid ? : T ; grabbed ? : T ; dropeffect ? : T ; haspopup ? : T ; level ? : T ; colcount ? : string ; } const config = { expand : 'aria-expanded' , role : 'role' , selected : 'aria-selected' , multiselectable : 'aria-multiselectable' , sort : 'aria-sort' , busy : 'aria-busy' , invalid : 'aria-invalid' , grabbed : 'aria-grabbed' , dropeffect : 'aria-dropeffect' , haspopup : 'aria-haspopup' , level : 'aria-level' , colcount : 'aria-colcount' } ;