import { Accessibility , AccessibilityAttributes , AccessibilityAttributesBySlot , AccessibilityDefinition , } from '@fluentui/accessibility' ; import getKeyDownHandlers from './getKeyDownHandlers' ; import { AccessibilityActionHandlers , ReactAccessibilityBehavior } from './types' ; const emptyBehavior = { attributes : { } , keyHandlers : { } , } ; const getAccessibility = < Props extends Record < string , any > > ( displayName , behavior , behaviorProps , isRtlEnabled , actionHandlers ? ) : ReactAccessibilityBehavior => { if ( behavior === null || behavior === undefined ) { return emptyBehavior ; } const definition = behavior ( behaviorProps ) ; const keyHandlers = actionHandlers && definition . keyActions ? getKeyDownHandlers ( actionHandlers , definition . keyActions , isRtlEnabled ) : { } ; if ( process . env . NODE_ENV !== 'production' ) { if ( definition . attributes ) { Object . keys ( definition . attributes ) . forEach ( slotName => { const validatorName = `${ displayName }${ slotName === 'root' ? '' : `__${ slotName }` }` ; if ( ! ( definition . attributes as AccessibilityAttributesBySlot ) [ slotName ] ) { ; ( definition . attributes as AccessibilityAttributesBySlot ) [ slotName ] = { } as AccessibilityAttributes ; } ; ( definition . attributes as AccessibilityAttributesBySlot ) [ slotName ] [ 'data-aa-class' ] = validatorName ; } ) ; } } return { ... emptyBehavior , ... definition , keyHandlers , } ; } ; export default getAccessibility ;