{"dependencies":[{"name":"babel-runtime/helpers/extends","loc":{"line":7,"column":24}},{"name":"babel-runtime/helpers/objectWithoutProperties","loc":{"line":11,"column":40}},{"name":"babel-runtime/core-js/object/get-prototype-of","loc":{"line":15,"column":30}},{"name":"babel-runtime/helpers/classCallCheck","loc":{"line":19,"column":31}},{"name":"babel-runtime/helpers/createClass","loc":{"line":23,"column":28}},{"name":"babel-runtime/helpers/possibleConstructorReturn","loc":{"line":27,"column":42}},{"name":"babel-runtime/helpers/inherits","loc":{"line":31,"column":25}},{"name":"simple-assign","loc":{"line":35,"column":28}},{"name":"react","loc":{"line":39,"column":21}},{"name":"prop-types","loc":{"line":43,"column":25}},{"name":"../styles/transitions","loc":{"line":47,"column":27}},{"name":"../Paper","loc":{"line":51,"column":21}},{"name":"../internal/EnhancedSwitch","loc":{"line":55,"column":30}}],"generated":{"js":"'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n  value: true\n});\n\nvar _extends2 = require('babel-runtime/helpers/extends');\n\nvar _extends3 = _interopRequireDefault(_extends2);\n\nvar _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');\n\nvar _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);\n\nvar _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');\n\nvar _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);\n\nvar _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');\n\nvar _classCallCheck3 = _interopRequireDefault(_classCallCheck2);\n\nvar _createClass2 = require('babel-runtime/helpers/createClass');\n\nvar _createClass3 = _interopRequireDefault(_createClass2);\n\nvar _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');\n\nvar _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);\n\nvar _inherits2 = require('babel-runtime/helpers/inherits');\n\nvar _inherits3 = _interopRequireDefault(_inherits2);\n\nvar _simpleAssign = require('simple-assign');\n\nvar _simpleAssign2 = _interopRequireDefault(_simpleAssign);\n\nvar _react = require('react');\n\nvar _react2 = _interopRequireDefault(_react);\n\nvar _propTypes = require('prop-types');\n\nvar _propTypes2 = _interopRequireDefault(_propTypes);\n\nvar _transitions = require('../styles/transitions');\n\nvar _transitions2 = _interopRequireDefault(_transitions);\n\nvar _Paper = require('../Paper');\n\nvar _Paper2 = _interopRequireDefault(_Paper);\n\nvar _EnhancedSwitch = require('../internal/EnhancedSwitch');\n\nvar _EnhancedSwitch2 = _interopRequireDefault(_EnhancedSwitch);\n\nfunction _interopRequireDefault(obj) {\n  return obj && obj.__esModule ? obj : { default: obj };\n}\n\nfunction getStyles(props, context, state) {\n  var disabled = props.disabled,\n      elementStyle = props.elementStyle,\n      trackSwitchedStyle = props.trackSwitchedStyle,\n      thumbSwitchedStyle = props.thumbSwitchedStyle,\n      trackStyle = props.trackStyle,\n      thumbStyle = props.thumbStyle,\n      iconStyle = props.iconStyle,\n      rippleStyle = props.rippleStyle,\n      labelStyle = props.labelStyle;\n  var _context$muiTheme = context.muiTheme,\n      baseTheme = _context$muiTheme.baseTheme,\n      toggle = _context$muiTheme.toggle;\n\n  var toggleSize = 20;\n  var toggleTrackWidth = 36;\n  var styles = {\n    icon: {\n      width: 36,\n      padding: '4px 0px 6px 2px'\n    },\n    ripple: {\n      top: -10,\n      left: -10,\n      color: state.switched ? toggle.thumbOnColor : baseTheme.palette.textColor\n    },\n    toggleElement: {\n      width: toggleTrackWidth\n    },\n    track: {\n      transition: _transitions2.default.easeOut(),\n      width: '100%',\n      height: 14,\n      borderRadius: 30,\n      backgroundColor: toggle.trackOffColor\n    },\n    thumb: {\n      transition: _transitions2.default.easeOut(),\n      position: 'absolute',\n      top: 1,\n      left: 0,\n      width: toggleSize,\n      height: toggleSize,\n      lineHeight: '24px',\n      borderRadius: '50%',\n      backgroundColor: toggle.thumbOffColor\n    },\n    trackWhenSwitched: {\n      backgroundColor: toggle.trackOnColor\n    },\n    thumbWhenSwitched: {\n      backgroundColor: toggle.thumbOnColor,\n      left: '100%'\n    },\n    trackWhenDisabled: {\n      backgroundColor: toggle.trackDisabledColor\n    },\n    thumbWhenDisabled: {\n      backgroundColor: toggle.thumbDisabledColor\n    },\n    label: {\n      color: disabled ? toggle.labelDisabledColor : toggle.labelColor,\n      width: 'calc(100% - ' + (toggleTrackWidth + 10) + 'px)'\n    }\n  };\n\n  (0, _simpleAssign2.default)(styles.track, trackStyle, state.switched && styles.trackWhenSwitched, state.switched && trackSwitchedStyle, disabled && styles.trackWhenDisabled);\n\n  (0, _simpleAssign2.default)(styles.thumb, thumbStyle, state.switched && styles.thumbWhenSwitched, state.switched && thumbSwitchedStyle, disabled && styles.thumbWhenDisabled);\n\n  if (state.switched) {\n    styles.thumb.marginLeft = 0 - styles.thumb.width;\n  }\n\n  (0, _simpleAssign2.default)(styles.icon, iconStyle);\n\n  (0, _simpleAssign2.default)(styles.ripple, rippleStyle);\n\n  (0, _simpleAssign2.default)(styles.label, labelStyle);\n\n  (0, _simpleAssign2.default)(styles.toggleElement, elementStyle);\n\n  return styles;\n}\n\nvar Toggle = function (_Component) {\n  (0, _inherits3.default)(Toggle, _Component);\n\n  function Toggle() {\n    var _ref;\n\n    var _temp, _this, _ret;\n\n    (0, _classCallCheck3.default)(this, Toggle);\n\n    for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n      args[_key] = arguments[_key];\n    }\n\n    return _ret = (_temp = (_this = (0, _possibleConstructorReturn3.default)(this, (_ref = Toggle.__proto__ || (0, _getPrototypeOf2.default)(Toggle)).call.apply(_ref, [this].concat(args))), _this), _this.state = {\n      switched: false\n    }, _this.handleStateChange = function (newSwitched) {\n      _this.setState({\n        switched: newSwitched\n      });\n    }, _this.handleToggle = function (event, isInputChecked) {\n      if (_this.props.onToggle) {\n        _this.props.onToggle(event, isInputChecked);\n      }\n    }, _temp), (0, _possibleConstructorReturn3.default)(_this, _ret);\n  }\n\n  (0, _createClass3.default)(Toggle, [{\n    key: 'componentWillMount',\n    value: function componentWillMount() {\n      var _props = this.props,\n          toggled = _props.toggled,\n          defaultToggled = _props.defaultToggled,\n          valueLink = _props.valueLink;\n\n      if (toggled || defaultToggled || valueLink && valueLink.value) {\n        this.setState({\n          switched: true\n        });\n      }\n    }\n  }, {\n    key: 'isToggled',\n    value: function isToggled() {\n      return this.refs.enhancedSwitch.isSwitched();\n    }\n  }, {\n    key: 'setToggled',\n    value: function setToggled(newToggledValue) {\n      this.refs.enhancedSwitch.setSwitched(newToggledValue);\n    }\n  }, {\n    key: 'render',\n    value: function render() {\n      var _props2 = this.props,\n          defaultToggled = _props2.defaultToggled,\n          elementStyle = _props2.elementStyle,\n          onToggle = _props2.onToggle,\n          trackSwitchedStyle = _props2.trackSwitchedStyle,\n          thumbSwitchedStyle = _props2.thumbSwitchedStyle,\n          toggled = _props2.toggled,\n          other = (0, _objectWithoutProperties3.default)(_props2, ['defaultToggled', 'elementStyle', 'onToggle', 'trackSwitchedStyle', 'thumbSwitchedStyle', 'toggled']);\n      var prepareStyles = this.context.muiTheme.prepareStyles;\n\n      var styles = getStyles(this.props, this.context, this.state);\n\n      var toggleElement = _react2.default.createElement('div', { style: prepareStyles((0, _simpleAssign2.default)({}, styles.toggleElement)) }, _react2.default.createElement('div', { style: prepareStyles((0, _simpleAssign2.default)({}, styles.track)) }), _react2.default.createElement(_Paper2.default, { style: styles.thumb, circle: true, zDepth: 1 }));\n\n      var enhancedSwitchProps = {\n        ref: 'enhancedSwitch',\n        inputType: 'checkbox',\n        switchElement: toggleElement,\n        rippleStyle: styles.ripple,\n        rippleColor: styles.ripple.color,\n        iconStyle: styles.icon,\n        trackStyle: styles.track,\n        thumbStyle: styles.thumb,\n        labelStyle: styles.label,\n        switched: this.state.switched,\n        onSwitch: this.handleToggle,\n        onParentShouldUpdate: this.handleStateChange,\n        labelPosition: this.props.labelPosition\n      };\n\n      if (this.props.hasOwnProperty('toggled')) {\n        enhancedSwitchProps.checked = toggled;\n      } else if (this.props.hasOwnProperty('defaultToggled')) {\n        enhancedSwitchProps.defaultChecked = defaultToggled;\n      }\n\n      return _react2.default.createElement(_EnhancedSwitch2.default, (0, _extends3.default)({}, other, enhancedSwitchProps));\n    }\n  }]);\n  return Toggle;\n}(_react.Component);\n\nToggle.defaultProps = {\n  defaultToggled: false,\n  disabled: false,\n  labelPosition: 'left'\n};\nToggle.contextTypes = {\n  muiTheme: _propTypes2.default.object.isRequired\n};\nToggle.propTypes = \"development\" !== \"production\" ? {\n  /**\n   * Determines whether the Toggle is initially turned on.\n   * **Warning:** This cannot be used in conjunction with `toggled`.\n   * Decide between using a controlled or uncontrolled input element and remove one of these props.\n   * More info: https://fb.me/react-controlled-components\n   */\n  defaultToggled: _propTypes2.default.bool,\n  /**\n   * Will disable the toggle if true.\n   */\n  disabled: _propTypes2.default.bool,\n  /**\n   * Overrides the inline-styles of the Toggle element.\n   */\n  elementStyle: _propTypes2.default.object,\n  /**\n   * Overrides the inline-styles of the Icon element.\n   */\n  iconStyle: _propTypes2.default.object,\n  /**\n   * Overrides the inline-styles of the input element.\n   */\n  inputStyle: _propTypes2.default.object,\n  /**\n   * Label for toggle.\n   */\n  label: _propTypes2.default.node,\n  /**\n   * Where the label will be placed next to the toggle.\n   */\n  labelPosition: _propTypes2.default.oneOf(['left', 'right']),\n  /**\n   * Overrides the inline-styles of the Toggle element label.\n   */\n  labelStyle: _propTypes2.default.object,\n  /**\n   * Callback function that is fired when the toggle switch is toggled.\n   *\n   * @param {object} event Change event targeting the toggle.\n   * @param {bool} isInputChecked The new value of the toggle.\n   */\n  onToggle: _propTypes2.default.func,\n  /**\n   * Override style of ripple.\n   */\n  rippleStyle: _propTypes2.default.object,\n  /**\n   * Override the inline-styles of the root element.\n   */\n  style: _propTypes2.default.object,\n  /**\n   * Override style for thumb.\n   */\n  thumbStyle: _propTypes2.default.object,\n  /**\n  * Override the inline styles for thumb when the toggle switch is toggled on.\n  */\n  thumbSwitchedStyle: _propTypes2.default.object,\n  /**\n   * Toggled if set to true.\n   */\n  toggled: _propTypes2.default.bool,\n  /**\n   * Override style for track.\n   */\n  trackStyle: _propTypes2.default.object,\n  /**\n  * Override the inline styles for track when the toggle switch is toggled on.\n  */\n  trackSwitchedStyle: _propTypes2.default.object,\n  /**\n   * ValueLink prop for when using controlled toggle.\n   */\n  valueLink: _propTypes2.default.object\n} : {};\nexports.default = Toggle;"},"hash":"82d239da80cf2bcb285f18c6aeb14f9b"}