var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

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

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';

/**
 * Performs a key comparison between two objects, deleting from the first where
 * the keys exist in the second
 *
 * Can be used to remove unwanted component prop values. For example:
 *
 * ```jsx
 * render() {
 *   const { children, className, ...props } = this.props;
 *
 *    return (
 *      <div
 *        {...objectKeyFilter(props, Item.propTypes)}
 *        className={classNames('dp-item', className)}
 *       >
 *        {children}
 *      </div>
 *    )
 * }
 * ```
 *
 * @param {Object} obj1
 * @param {Object} obj2
 * @returns {*}
 */
export function objectKeyFilter(obj1, obj2) {
  var obj2Keys = Object.keys(obj2);
  var newProps = Object.assign({}, obj1);
  Object.keys(newProps).filter(function (key) {
    return obj2Keys.indexOf(key) !== -1;
  }).forEach(function (key) {
    return delete newProps[key];
  });

  return newProps;
}

/**
 * Renders a progress bar.
 */

var Progress = function (_React$Component) {
  _inherits(Progress, _React$Component);

  function Progress() {
    _classCallCheck(this, Progress);

    return _possibleConstructorReturn(this, (Progress.__proto__ || Object.getPrototypeOf(Progress)).apply(this, arguments));
  }

  _createClass(Progress, [{
    key: 'render',
    value: function render() {
      var _props = this.props,
          size = _props.size,
          type = _props.type,
          className = _props.className,
          children = _props.children,
          props = _objectWithoutProperties(_props, ['size', 'type', 'className', 'children']);

      return React.createElement(
        'div',
        Object.assign({
          className: classNames('dp-progress', 'dp-progress--' + type, 'dp-progress--' + size[0], className)
        }, objectKeyFilter(props, Progress.propTypes)),
        children
      );
    }
  }]);

  return Progress;
}(React.Component);

Progress.propTypes = {
  /**
   * The size of the progress bar.
   */
  size: PropTypes.oneOf(['s', 'm', 'l', 'small', 'medium', 'large']),
  /**
   * The type of progress bar to render.
   */
  type: PropTypes.oneOf(['primary', 'cta']),
  /**
   * CSS classes to apply to the element.
   */
  className: PropTypes.string,
  /**
   * Children to render.
   */
  children: PropTypes.node
};
Progress.defaultProps = {
  size: 'large',
  type: 'primary',
  className: '',
  children: ''
};
export default Progress;