"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
Object.defineProperty(exports, "HELPER_TEXT_POSITION", {
  enumerable: true,
  get: function () {
    return _formField.HELPER_TEXT_POSITION;
  }
});
exports.default = exports.INPUT_SIZES = void 0;
var _react = _interopRequireDefault(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _formField = require("../form-field");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const INPUT_SIZES = exports.INPUT_SIZES = {
  SM: 'sm',
  MD: 'md',
  // The default size
  LG: 'lg',
  XL: 'xl'
};
/**
 * Input component, which supports label, helper text and validation
 * [CAPITALIZATION] Use sentence case for label and placeholder, no colon
 * [CAPITALIZATION] Helper text, in most cases, should be a complete sentence with a period
 * [CAPITALIZATION] Don't have mixed format in one text block, use sentence case
 * @midnight-gray-supported
 * @alpine-light-supported
 */
const Input = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
  const {
    type,
    className,
    inputSize,
    fieldClass,
    spellCheck,
    useFont,
    ...rest
  } = props;
  const overriddenSpellCheck = type === 'password' && spellCheck === undefined ? false : spellCheck;

  // [PLT-1993] Fix issue of onwheel listeners
  const onWheel = type === 'number' ? e => e.target.blur(e) : undefined;
  const formFieldClassName = (0, _classnames.default)(className, {
    sm: inputSize === INPUT_SIZES.SM,
    md: !inputSize || inputSize === INPUT_SIZES.MD,
    lg: inputSize === INPUT_SIZES.LG,
    xl: inputSize === INPUT_SIZES.XL
  });
  const fieldClassName = (0, _classnames.default)(fieldClass, {
    'no-font': !useFont
  });
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_formField.FormField, {
    ...rest,
    type: type,
    spellCheck: overriddenSpellCheck,
    onWheel: onWheel,
    className: formFieldClassName,
    fieldClass: fieldClassName,
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
      ref: ref
    })
  });
});
Input.displayName = 'Input';
Input.defaultProps = {
  value: '',
  label: '',
  helperText: '',
  className: '',
  isDisabled: false,
  isOptional: false,
  isHighlighted: false,
  autoFocus: false,
  touched: false,
  required: false,
  shouldDisplayControls: false,
  leftIcon: null,
  rightIcon: null,
  iconTooltipText: '',
  asyncValidation: {
    isValidating: false,
    isRetryShown: false,
    onRetry: () => {}
  },
  labelIcon: null,
  placeholder: '',
  onChange() {},
  onBlur() {},
  onFocus() {},
  type: _formField.INPUT_TYPES.TEXT,
  useFont: true
};
var _default = exports.default = Input;