<commit_before>import PropTypes from 'prop-types';
import React from 'react';
import classNames from 'classnames';
import CopyButton from '../CopyButton';

const CodeSnippet = ({
  className,
  type,
  children,
  onClick,
  wrappedContentRef,
  ...other
}) => {
  const snippetType =
    type === 'terminal' ? 'bx--snippet--terminal' : 'bx--snippet--code';
  const wrapperClasses = classNames('bx--snippet', className, snippetType);
  return (
    <div className={wrapperClasses} {...other}>
      <div className="bx--snippet-container">
        <code>
          <pre ref={wrappedContentRef}>{children}</pre>
        </code>
      </div>
      <CopyButton onClick={onClick} />
    </div>
  );
};

CodeSnippet.propTypes = {
  type: PropTypes.string,
  className: PropTypes.string,
  children: PropTypes.string,
  onClick: PropTypes.func,
  wrappedContentRef: PropTypes.func,
};

CodeSnippet.defaultProps = {
  type: 'terminal',
};

export default CodeSnippet;
<commit_msg>fix(code-snippet): fixed keyboard interactionm (#666)<commit_after>import PropTypes from 'prop-types';
import React from 'react';
import classNames from 'classnames';
import CopyButton from '../CopyButton';

const CodeSnippet = ({
  className,
  type,
  children,
  onClick,
  wrappedContentRef,
  ...other
}) => {
  const snippetType =
    type === 'terminal' ? 'bx--snippet--terminal' : 'bx--snippet--code';
  const wrapperClasses = classNames('bx--snippet', className, snippetType);
  return (
    <div className={wrapperClasses} {...other}>
      <div role="textbox" tabIndex={0} className="bx--snippet-container">
        <code>
          <pre ref={wrappedContentRef}>{children}</pre>
        </code>
      </div>
      <CopyButton onClick={onClick} />
    </div>
  );
};

CodeSnippet.propTypes = {
  type: PropTypes.string,
  className: PropTypes.string,
  children: PropTypes.string,
  onClick: PropTypes.func,
  wrappedContentRef: PropTypes.func,
};

CodeSnippet.defaultProps = {
  type: 'terminal',
};

export default CodeSnippet;

{'fraction_non_alphanumeric': 0.15159045725646123, 'fraction_numerical': 0.0019880715705765406, 'mean_word_length': 3.6382488479262673, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 23, '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': '4880272', 'n_tokens_mistral': 631, 'n_tokens_neox': 628, 'n_words': 138}