<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';

import Icon from '../../base/icons/Icon';
import InputBase from './InputBase';
import { Prepend, Append, InputWrapper } from './TextAddons';
import { useTheme } from '../../util/useTheme';
import ValidationContext from '../ValidationContext';

const defaultBorderRadius = '2px';

const TextboxBase = styled(InputBase)`
  border-bottom-left-radius: ${props =>
    props.hasPrepend ? '0' : defaultBorderRadius};
  border-bottom-right-radius: ${props =>
    props.hasAppend ? '0' : defaultBorderRadius};
  border-top-left-radius: ${props =>
    props.hasPrepend ? '0' : defaultBorderRadius};
  border-top-right-radius: ${props =>
    props.hasAppend ? '0' : defaultBorderRadius};
  display: table-cell;
  -webkit-appearance: none;
`;

const Textbox = React.forwardRef(function Textbox(props, ref) {
  const { prependIconName, appendIconName, ...additionalTextProps } = props;
  const theme = useTheme();
  const validationState = React.useContext(ValidationContext);

  const inputRef = React.useRef();
  React.useImperativeHandle(ref, () => inputRef.current);

  const hasPrepend = !!prependIconName;
  const hasAppend = !!appendIconName;
  const hasValidationState = validationState !== 'default';

  const addOnTextColor = hasValidationState
    ? theme.colors.white
    : theme.colors.gray8;
  const addOnBgColor = hasValidationState
    ? theme.validationTextColor[validationState]
    : theme.colors.gray3;

  function focusInput() {
    inputRef.current.focus();
  }

  return (
    <InputWrapper>
      {hasPrepend && (
        <Prepend
          addOnTextColor={addOnTextColor}
          addOnBgColor={addOnBgColor}
          aria-hidden="true"
          onClick={focusInput}
          type="button"
        >
          <Icon aria-hidden="true" name={prependIconName} size={18} />
        </Prepend>
      )}
      <TextboxBase
        hasAppend={hasAppend}
        hasPrepend={hasPrepend}
        ref={inputRef}
        {...additionalTextProps}
        {...theme.validationInputColor[validationState]}
      />
      {hasAppend && (
        <Append
          addOnTextColor={addOnTextColor}
          addOnBgColor={addOnBgColor}
          aria-hidden="true"
          onClick={focusInput}
          type="button"
        >
          <Icon aria-hidden="true" name={appendIconName} size={18} />
        </Append>
      )}
    </InputWrapper>
  );
});

Textbox.propTypes = {
  /** Content to prepend input box with */
  prependIconName: PropTypes.string,
  /** Content to append to input box */
  appendIconName: PropTypes.string
};

Textbox.defaultProps = {
  prependIconName: undefined,
  appendIconName: undefined
};

export default Textbox;<commit_msg>Update: adding a default type for Textbox<commit_after>import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';

import Icon from '../../base/icons/Icon';
import InputBase from './InputBase';
import { Prepend, Append, InputWrapper } from './TextAddons';
import { useTheme } from '../../util/useTheme';
import ValidationContext from '../ValidationContext';

const defaultBorderRadius = '2px';

const TextboxBase = styled(InputBase)`
  border-bottom-left-radius: ${props =>
    props.hasPrepend ? '0' : defaultBorderRadius};
  border-bottom-right-radius: ${props =>
    props.hasAppend ? '0' : defaultBorderRadius};
  border-top-left-radius: ${props =>
    props.hasPrepend ? '0' : defaultBorderRadius};
  border-top-right-radius: ${props =>
    props.hasAppend ? '0' : defaultBorderRadius};
  display: table-cell;
  -webkit-appearance: none;
`;

const Textbox = React.forwardRef(function Textbox(props, ref) {
  const {
    prependIconName,
    appendIconName,
    type,
    ...additionalTextProps
  } = props;
  const theme = useTheme();
  const validationState = React.useContext(ValidationContext);

  const inputRef = React.useRef();
  React.useImperativeHandle(ref, () => inputRef.current);

  const finalType = type || 'text';
  const hasPrepend = !!prependIconName;
  const hasAppend = !!appendIconName;
  const hasValidationState = validationState !== 'default';

  const addOnTextColor = hasValidationState
    ? theme.colors.white
    : theme.colors.gray8;
  const addOnBgColor = hasValidationState
    ? theme.validationTextColor[validationState]
    : theme.colors.gray3;

  function focusInput() {
    inputRef.current.focus();
  }

  return (
    <InputWrapper>
      {hasPrepend && (
        <Prepend
          addOnTextColor={addOnTextColor}
          addOnBgColor={addOnBgColor}
          aria-hidden="true"
          onClick={focusInput}
          type="button"
        >
          <Icon aria-hidden="true" name={prependIconName} size={18} />
        </Prepend>
      )}
      <TextboxBase
        hasAppend={hasAppend}
        hasPrepend={hasPrepend}
        ref={inputRef}
        type={finalType}
        {...additionalTextProps}
        {...theme.validationInputColor[validationState]}
      />
      {hasAppend && (
        <Append
          addOnTextColor={addOnTextColor}
          addOnBgColor={addOnBgColor}
          aria-hidden="true"
          onClick={focusInput}
          type="button"
        >
          <Icon aria-hidden="true" name={appendIconName} size={18} />
        </Append>
      )}
    </InputWrapper>
  );
});

Textbox.propTypes = {
  /** Content to prepend input box with */
  prependIconName: PropTypes.string,
  /** Content to append to input box */
  appendIconName: PropTypes.string,
  /** The type attribute for the textboxa */
  type: PropTypes.string
};

Textbox.defaultProps = {
  prependIconName: undefined,
  appendIconName: undefined,
  type: 'text'
};

export default Textbox;
{'fraction_non_alphanumeric': 0.1290378603681834, 'fraction_numerical': 0.0038207711010767626, 'mean_word_length': 3.119456366237482, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1792235', 'n_tokens_mistral': 1713, 'n_tokens_neox': 1694, 'n_words': 353}