<commit_before>import PropTypes from 'prop-types';
import React from 'react';
import classNames from 'classnames';
import { handleScrollOnInputFocus } from '../utils/helpers';

const Dropdown = ({
  alt,
  ariaLabel,
  className,
  disabled,
  hideArrows,
  label,
  name,
  options,
  onChange,
  onFocus,
  selectClassName,
  value,
  visible,
}) => {
  if (!visible) {
    return null;
  }

  const dropdownId = `${name}-dropdown`;
  const labelElement = <label htmlFor={name}>{label}</label>;

  const selectClasses = classNames('vads-u-color--gray', selectClassName, {
    hideArrows,
  });

  return (
    <div className={classNames(className, { disabled })} id={dropdownId}>
      {label && labelElement}
      <label className="wrap vads-u-margin--0">
        <select
          aria-label={ariaLabel}
          className={selectClasses}
          id={name}
          name={name}
          alt={alt}
          value={value}
          onChange={onChange}
          disabled={disabled}
          onFocus={() => onFocus(dropdownId)}
        >
          {options.map(
            ({ optionValue, optionLabel }, index) =>
              optionLabel && (
                <option
                  key={index}
                  value={optionValue}
                  className={
                    optionValue === value
                      ? 'vads-u-font-weight--bold'
                      : 'vads-u-font-weight--normal'
                  }
                >
                  {optionLabel}
                </option>
              ),
          )}
        </select>
      </label>
    </div>
  );
};

Dropdown.propTypes = {
  visible: PropTypes.bool.isRequired,
  name: PropTypes.string.isRequired,
  label: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
  options: PropTypes.arrayOf(
    PropTypes.shape({
      label: PropTypes.string,
      value: PropTypes.string,
    }),
  ).isRequired,
  value: PropTypes.string.isRequired,
  onChange: PropTypes.func.isRequired,
  alt: PropTypes.string.isRequired,
  className: PropTypes.string,
  onFocus: PropTypes.func,
};

Dropdown.defaultProps = {
  className: 'form-group top-aligned',
  visible: false,<commit_msg>29352: Remove duplicate label (#18605)<commit_after>import PropTypes from 'prop-types';
import React from 'react';
import classNames from 'classnames';
import { handleScrollOnInputFocus } from '../utils/helpers';

const Dropdown = ({
  alt,
  ariaLabel,
  className,
  disabled,
  hideArrows,
  label,
  name,
  options,
  onChange,
  onFocus,
  selectClassName,
  value,
  visible,
}) => {
  if (!visible) {
    return null;
  }

  const dropdownId = `${name}-dropdown`;
  const labelElement = <label htmlFor={name}>{label}</label>;

  const selectClasses = classNames('vads-u-color--gray', selectClassName, {
    hideArrows,
  });

  return (
    <div className={classNames(className, { disabled })} id={dropdownId}>
      {label && labelElement}
      <select
        aria-label={ariaLabel}
        className={selectClasses}
        id={name}
        name={name}
        alt={alt}
        value={value}
        onChange={onChange}
        disabled={disabled}
        onFocus={() => onFocus(dropdownId)}
      >
        {options.map(
          ({ optionValue, optionLabel }, index) =>
            optionLabel && (
              <option
                key={index}
                value={optionValue}
                className={
                  optionValue === value
                    ? 'vads-u-font-weight--bold'
                    : 'vads-u-font-weight--normal'
                }
              >
                {optionLabel}
              </option>
            ),
        )}
      </select>
    </div>
  );
};

Dropdown.propTypes = {
  visible: PropTypes.bool.isRequired,
  name: PropTypes.string.isRequired,
  label: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
  options: PropTypes.arrayOf(
    PropTypes.shape({
      label: PropTypes.string,
      value: PropTypes.string,
    }),
  ).isRequired,
  value: PropTypes.string.isRequired,
  onChange: PropTypes.func.isRequired,
  alt: PropTypes.string.isRequired,
  className: PropTypes.string,
  onFocus: PropTypes.func,
};

Dropdown.defaultProps = {
  className: 'form-group top-aligned',
  visible: false,
{'fraction_non_alphanumeric': 0.13104744011272898, 'fraction_numerical': 0.0025833724753405356, 'mean_word_length': 2.1408554572271385, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 27, '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': '1080844', 'n_tokens_mistral': 1235, 'n_tokens_neox': 1237, 'n_words': 235}