// Copyright 1999-2023. Plesk International GmbH. All rights reserved.
import classNames from 'classnames';
import { CLS_PREFIX } from '../../constants';
import FormField from '../FormField';
import Input from '../Input';
import TextArea from '../TextArea';
import { jsx as _jsx } from "react/jsx-runtime";
/**
 * `FormFieldText` component is used for entering of user data in text format.
 *
 * [FormField](#!/FormField) with [InputNumber](#!/InputNumber) can be used for entering of integer numbers.
 * @since 0.0.58
 */
const FormFieldText = props => {
  const {
    baseClassName = `${CLS_PREFIX}form-field-text`,
    className,
    size,
    placeholder,
    rows = 4,
    autoFocus,
    multiline = false,
    autoComplete,
    autoheight = false,
    inputProps,
    ...otherProps
  } = props;
  return /*#__PURE__*/_jsx(FormField, {
    className: classNames(baseClassName, {
      [`${baseClassName}--multiline`]: multiline
    }, className),
    ...otherProps,
    children: _ref => {
      let {
        getId,
        getName,
        getValue,
        setValue,
        isDisabled
      } = _ref;
      return props.multiline ? /*#__PURE__*/_jsx(TextArea, {
        id: getId(),
        name: getName(),
        value: getValue(''),
        onChange: e => setValue(e.currentTarget.value),
        disabled: isDisabled(),
        size: size,
        rows: rows,
        placeholder: placeholder,
        autoFocus: autoFocus,
        autoComplete: autoComplete,
        autoheight: autoheight,
        ...(props.inputProps ?? {})
      }) : /*#__PURE__*/_jsx(Input, {
        id: getId(),
        name: getName(),
        className: `${baseClassName}__input`,
        value: getValue(''),
        onChange: e => setValue(e.currentTarget.value),
        disabled: isDisabled(),
        size: size,
        placeholder: placeholder,
        autoFocus: autoFocus,
        autoComplete: autoComplete,
        ...(props.inputProps ?? {})
      });
    }
  });
};
export default FormFieldText;