import React from 'react';
import classNames from 'classnames';
import { FormField, INPUT_TYPES, HELPER_TEXT_POSITION } from '../form-field';
import { jsx as _jsx } from "react/jsx-runtime";
export const INPUT_SIZES = {
  SM: 'sm',
  MD: 'md',
  // The default size
  LG: 'lg',
  XL: 'xl'
};
export { HELPER_TEXT_POSITION };
/**
 * 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.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 = classNames(className, {
    sm: inputSize === INPUT_SIZES.SM,
    md: !inputSize || inputSize === INPUT_SIZES.MD,
    lg: inputSize === INPUT_SIZES.LG,
    xl: inputSize === INPUT_SIZES.XL
  });
  const fieldClassName = classNames(fieldClass, {
    'no-font': !useFont
  });
  return /*#__PURE__*/_jsx(FormField, {
    ...rest,
    type: type,
    spellCheck: overriddenSpellCheck,
    onWheel: onWheel,
    className: formFieldClassName,
    fieldClass: fieldClassName,
    children: /*#__PURE__*/_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: INPUT_TYPES.TEXT,
  useFont: true
};
export default Input;