'use strict';

exports.__esModule = true;

var _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; };

exports.default = function (_ref, callback, value) {
  var target = _ref.target,
      event = _objectWithoutProperties(_ref, ['target']);

  var detail = value || 'value' in event && event.value || target.value;
  var e = new CustomEvent('react', {
    bubbles: true,
    detail: detail
  });

  /* istanbul ignore else */
  if (callback && typeof callback === 'function') callback(detail, _extends({ target: target }, event));

  return target.dispatchEvent(e);
};

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }

module.exports = exports['default'];