// @flow
import PropTypes from 'prop-types';
import { translatedContentPropType } from '../../../types';
import type { TranslatedContent } from '../../../types';
import { formInputPropTypes } from '../form-input/form-input.proptypes';
import type { FormInputProps } from '../form-input/form-input.proptypes';
import { maskedTextInputOptionsPropTypes } from '../masked-text-input/masked-text-input.proptypes';
import type { MaskedTextInputOptions } from '../masked-text-input/masked-text-input.proptypes';

type LabelProps = {
  label: TranslatedContent,
};

export type TextInputProps<ValueType> = LabelProps &
  FormInputProps<ValueType> & {
    iconType?: 'lock' | 'error',
    disabled?: boolean,
    hideLabel?: boolean,
    large?: boolean,
    className?: string,
    mask?: boolean,
    maskOptions?: MaskedTextInputOptions,
  };

export const textInputPropTypes = {
  ...formInputPropTypes,
  label: translatedContentPropType.isRequired,
  iconType: PropTypes.oneOf(['lock', 'error']),
  disabled: PropTypes.bool,
  large: PropTypes.bool,
  mask: PropTypes.bool,
  maskOptions: PropTypes.shape(maskedTextInputOptionsPropTypes),
};
