<commit_before>'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _classnames = require('classnames');

var _classnames2 = _interopRequireDefault(_classnames);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var MultiToggle = function MultiToggle(_ref) {
  var selectedOption = _ref.selectedOption;
  var options = _ref.options;
  var onSelectOption = _ref.onSelectOption;
  var className = _ref.className;
  var label = _ref.label;

  // If required variables aren't passed, return empty
  if (!options || !selectedOption) return _react2.default.createElement('span', null);

  var selectOption = function selectOption(event) {
    var value = parseInt(event.target.getAttribute('data-value'), 10);
    // Function to parse values if needed
    var returnValue = isNaN(value) ? event.target.getAttribute('data-value') : value;
    onSelectOption(returnValue);
  };

  var numOptions = options.length;

  var columnWidth = numOptions ? 100 / numOptions : numOptions;

  var isSelectedOption = function isSelectedOption(option) {
    return option.value == selectedOption;
  };

  var getSelectedIndex = function getSelectedIndex() {
    var indexFound = options.findIndex(function (option) {
      return isSelectedOption(option);
    });
    return indexFound > -1 ? indexFound : 0;
  };

  var createToggleOption = function createToggleOption() {
    for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    var optionClass = (0, _classnames2.default)('toggleOption', { selected: isSelectedOption(args[0]) });
    var optionStyle = {
      width: columnWidth + '%'
    };
    return _react2.default.createElement(
      'div',
      {
        key: args[1],
        'data-value': args[0].value,
        onClick: selectOption,
        className: optionClass,
        style: optionStyle
      },
      args[0].displayName || args[0].value
    );
  };

  var toggleClass = (0, _classnames2.default)('toggleContainer', className);
  var toggleStyle = {
    width: columnWidth + '%',
    transform: 'translateX(' + 100 * getSelectedIndex() + '%)',
    WebkitTransform: 'translateX(' + 100 * getSelectedIndex() + '%)',
    MozTransform: 'translateX(' + 100 * getSelectedIndex() + '%)',
    msTransform: 'translateX(' + 100 * getSelectedIndex() + '%)'
  };

  var selectedToggleClass = (0, _classnames2.default)('toggle', options[getSelectedIndex()].optionClass);

  var renderLabel = label ? _react2.default.createElement(
    'label',
    null,
    label
  ) : null;

  return _react2.default.createElement(
    'div',
    { className: 'toggle-wrapper' },
    renderLabel,
    _react2.default.createElement(
      'div',<commit_msg>Fix bug where option content wouldn't render properly when JSX or boolean<commit_after>'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _classnames = require('classnames');

var _classnames2 = _interopRequireDefault(_classnames);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var MultiToggle = function MultiToggle(_ref) {
  var selectedOption = _ref.selectedOption;
  var options = _ref.options;
  var onSelectOption = _ref.onSelectOption;
  var className = _ref.className;
  var label = _ref.label;

  // If required variables aren't passed, return empty
  if (!options || selectedOption === null) return null;

  var numOptions = options.length;

  var columnWidth = numOptions ? 100 / numOptions : numOptions;

  var isSelectedOption = function isSelectedOption(option) {
    return option.value == selectedOption;
  };

  var getSelectedIndex = function getSelectedIndex() {
    var indexFound = options.findIndex(function (option) {
      return isSelectedOption(option);
    });
    return indexFound > -1 ? indexFound : 0;
  };

  var createToggleOption = function createToggleOption() {
    for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    var selectOption = function selectOption() {
      return onSelectOption(args[0].value);
    };

    var optionClass = (0, _classnames2.default)('toggleOption', { selected: isSelectedOption(args[0]) });
    var optionStyle = {
      width: columnWidth + '%'
    };
    return _react2.default.createElement(
      'div',
      {
        key: args[1],
        onClick: selectOption,
        className: optionClass,
        style: optionStyle
      },
      args[0].displayName || args[0].value
    );
  };

  var toggleClass = (0, _classnames2.default)('toggleContainer', className);
  var toggleStyle = {
    width: columnWidth + '%',
    transform: 'translateX(' + 100 * getSelectedIndex() + '%)',
    WebkitTransform: 'translateX(' + 100 * getSelectedIndex() + '%)',
    MozTransform: 'translateX(' + 100 * getSelectedIndex() + '%)',
    msTransform: 'translateX(' + 100 * getSelectedIndex() + '%)'
  };

  var selectedToggleClass = (0, _classnames2.default)('toggle', options[getSelectedIndex()].optionClass);

  var renderLabel = label ? _react2.default.createElement(
    'label',
    null,
    label
  ) : null;

  return _react2.default.createElement(
    'div',
    { className: 'toggle-wrapper' },
    renderLabel,
    _react2.default.createElement(
      'div',
{'fraction_non_alphanumeric': 0.13070951435277126, 'fraction_numerical': 0.013179274237226936, 'mean_word_length': 3.730999146029035, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5459849', 'n_tokens_mistral': 1674, 'n_tokens_neox': 1619, 'n_words': 388}