import "core-js/modules/es6.object.assign";
import "core-js/modules/web.dom.iterable";
import "core-js/modules/es6.array.iterator";
import "core-js/modules/es6.object.keys";
import "core-js/modules/es6.function.name";

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { EuiToggle, TOGGLE_TYPES } from '../../toggle';
import { EuiButton } from '../button';
export var EuiButtonToggle = function EuiButtonToggle(_ref) {
  var className = _ref.className,
      color = _ref.color,
      isDisabled = _ref.isDisabled,
      isEmpty = _ref.isEmpty,
      isIconOnly = _ref.isIconOnly,
      isSelected = _ref.isSelected,
      label = _ref.label,
      name = _ref.name,
      onChange = _ref.onChange,
      toggleClassName = _ref.toggleClassName,
      type = _ref.type,
      value = _ref.value,
      rest = _objectWithoutProperties(_ref, ["className", "color", "isDisabled", "isEmpty", "isIconOnly", "isSelected", "label", "name", "onChange", "toggleClassName", "type", "value"]);

  var classes = classNames('euiButtonToggle', {
    'euiButtonToggle--isIconOnly': isIconOnly,
    'euiButtonToggle--isEmpty': isEmpty
  }, className);
  var wrapperClasses = classNames('euiButtonToggle__wrapper', {
    'euiButtonToggle--isDisabled': isDisabled
  }, toggleClassName);
  var buttonContent = isIconOnly ? '' : label;
  return React.createElement(EuiToggle, {
    className: wrapperClasses,
    inputClassName: "euiButtonToggle__input",
    checked: isSelected,
    isDisabled: isDisabled,
    label: label,
    name: name,
    onChange: onChange,
    type: type,
    title: label,
    value: value
  }, React.createElement(EuiButton, _extends({
    tabIndex: "-1" // prevents double focus from input to button
    ,
    className: classes,
    color: color,
    disabled: isDisabled,
    size: isIconOnly ? 's' : undefined // only force small if it's the icon only version

  }, rest), buttonContent));
};
EuiButtonToggle.propTypes = {
  className: PropTypes.string,

  /**
   * Button label, which is also passed to `EuiToggle` as the input's label
   */
  label: PropTypes.string.isRequired,
  onChange: PropTypes.func,

  /**
   * See `EuiButton`
   */
  color: PropTypes.string,
  isDisabled: PropTypes.bool,

  /**
   * Hides the label from the button content and only displays the icon
   */
  isIconOnly: PropTypes.bool,

  /**
   * Simulates a `EuiButtonEmpty`
   */
  isEmpty: PropTypes.bool,

  /**
   * Classnames to add to `EuiToggle` instead of the `EuiButton`
   */
  toggleClassName: PropTypes.string,

  /**
   * Is the button a single action or part of a group (multi)?
   * Used primarily for `EuiButtonGroup`
   */
  type: PropTypes.oneOf(TOGGLE_TYPES)
};
EuiButtonToggle.defaultProps = {
  color: 'primary'
};
EuiButtonToggle.__docgenInfo = {
  "description": "",
  "methods": [],
  "displayName": "EuiButtonToggle",
  "props": {
    "color": {
      "defaultValue": {
        "value": "'primary'",
        "computed": false
      },
      "type": {
        "name": "string"
      },
      "required": false,
      "description": "See `EuiButton`"
    },
    "className": {
      "type": {
        "name": "string"
      },
      "required": false,
      "description": ""
    },
    "label": {
      "type": {
        "name": "string"
      },
      "required": true,
      "description": "Button label, which is also passed to `EuiToggle` as the input's label"
    },
    "onChange": {
      "type": {
        "name": "func"
      },
      "required": false,
      "description": ""
    },
    "isDisabled": {
      "type": {
        "name": "bool"
      },
      "required": false,
      "description": ""
    },
    "isIconOnly": {
      "type": {
        "name": "bool"
      },
      "required": false,
      "description": "Hides the label from the button content and only displays the icon"
    },
    "isEmpty": {
      "type": {
        "name": "bool"
      },
      "required": false,
      "description": "Simulates a `EuiButtonEmpty`"
    },
    "toggleClassName": {
      "type": {
        "name": "string"
      },
      "required": false,
      "description": "Classnames to add to `EuiToggle` instead of the `EuiButton`"
    },
    "type": {
      "type": {
        "name": "enum",
        "computed": true,
        "value": "TOGGLE_TYPES"
      },
      "required": false,
      "description": "Is the button a single action or part of a group (multi)?\nUsed primarily for `EuiButtonGroup`"
    }
  }
};