import useFocusVisible from '@zohodesk/hooks/es/accessiblity/useFocusVisible';

const useLinkAriaProps = props => {
  let {
    elementType = 'a',
    disabled,
    text,
    ariaLabel,
    ariaLabelledBy,
    focusClass
  } = props;
  let {
    focusVisible,
    focusProps
  } = useFocusVisible(props);
  let linkProp;

  if (elementType !== 'a') {
    linkProp = {
      role: 'link',
      tabIndex: !disabled ? 0 : undefined
    };
  }

  return {
    linkProps: { ...linkProp,
      'aria-label': ariaLabel || text,
      'aria-disabled': disabled || undefined,
      'aria-labelledby': ariaLabelledBy,
      'data-aria-focusstyle': focusClass
    },
    focusVisible,
    focusProps
  };
};

export default useLinkAriaProps;