import React from 'react'; // fallow-ignore-next-line complexity export const handleButtonActivationKey = ({ e, onClick, disabled, onKeyDown }: { e: React.KeyboardEvent; onClick?: React.MouseEventHandler; disabled?: boolean; onKeyDown?: React.KeyboardEventHandler; }) => { if ( ( 'Enter' === e.key || ' ' === e.key ) && onClick && ! disabled ) { e.preventDefault(); onClick( e as unknown as React.MouseEvent ); } onKeyDown?.( e ); }; export const getDefinedAriaAttributes = ( attributes: Record ): Record => { return Object.fromEntries( Object.entries( attributes ).filter( ([ , value ]) => value !== undefined ) ); };