Devendra174's picture
Upload folder using huggingface_hub
1e92f2d verified
import { ARIA_STATES, ARIA_PROPERTIES } from './constants';
import type {
AriaProps,
AriaAttributes,
AriaState,
AriaProperty,
RawAriaState,
RawAriaProperty,
} from './types';
export default function useAriaProps( props: AriaProps ): AriaAttributes {
const attrs = {} as AriaAttributes;
for ( const key in props ) {
if ( ARIA_STATES.includes( key as RawAriaState ) ) {
attrs[ `aria-${ key }` as AriaState ] = !! props[ key ];
} else if ( ARIA_PROPERTIES.includes( key as RawAriaProperty ) ) {
attrs[ `aria-${ key }` as AriaProperty ] = props[ key ];
}
}
return attrs;
}