import _extends from "@babel/runtime/helpers/extends";
// Copyright 1999-2020. Plesk International GmbH. All rights reserved.
import React from 'react';
import classNames from 'classnames';
import { CLS_PREFIX } from '../../constants';

/**
 * `Input` component is used for entering short text (like user name or email address).
 * @since 0.0.57
 */
const Input = ({
  baseClassName = `${CLS_PREFIX}input`,
  className,
  size = 'md',
  type = 'text',
  textAlign,
  prefix,
  suffix,
  innerRef,
  rootProps,
  ...props
}) => {
  const useSizeModifier = typeof size === 'string' && ['sm', 'md', 'lg', 'xl', 'fill'].indexOf(size) !== -1;
  return /*#__PURE__*/React.createElement("span", _extends({
    className: classNames(baseClassName, {
      [`${baseClassName}--size-${size}`]: useSizeModifier,
      [`${baseClassName}--text-${textAlign}`]: textAlign,
      [`${baseClassName}--affix`]: prefix || suffix
    }, className)
  }, rootProps), prefix && /*#__PURE__*/React.createElement("span", {
    className: `${baseClassName}__prefix`
  }, prefix), /*#__PURE__*/React.createElement("input", _extends({
    ref: innerRef,
    type: type,
    size: typeof size === 'number' ? size : undefined,
    className: `${baseClassName}__input`
  }, props)), suffix && /*#__PURE__*/React.createElement("span", {
    className: `${baseClassName}__suffix`
  }, suffix));
};

export default Input;