"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _classnames = _interopRequireDefault(require("classnames"));
var _constants = require("../../constants");
var _FormField = _interopRequireDefault(require("../FormField"));
var _Input = _interopRequireDefault(require("../Input"));
var _TextArea = _interopRequireDefault(require("../TextArea"));
var _jsxRuntime = require("react/jsx-runtime");
// Copyright 1999-2023. Plesk International GmbH. All rights reserved.

/**
 * `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 = `${_constants.CLS_PREFIX}form-field-text`,
    className,
    size,
    placeholder,
    rows = 4,
    autoFocus,
    multiline = false,
    autoComplete,
    autoheight = false,
    inputProps,
    ...otherProps
  } = props;
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_FormField.default, {
    className: (0, _classnames.default)(baseClassName, {
      [`${baseClassName}--multiline`]: multiline
    }, className),
    ...otherProps,
    children: _ref => {
      let {
        getId,
        getName,
        getValue,
        setValue,
        isDisabled
      } = _ref;
      return props.multiline ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextArea.default, {
        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__*/(0, _jsxRuntime.jsx)(_Input.default, {
        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 ?? {})
      });
    }
  });
};
var _default = exports.default = FormFieldText;