Download wp-calypso/client/lib/a11y/use-aria-props.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 594 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/lib/a11y/use-aria-props.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/lib/a11y/use-aria-props.ts
-
curl -L -o use-aria-props.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/lib/a11y/use-aria-props.ts
594 Bytes
| 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; | |
| } | |