"use strict";

exports.__esModule = true;
exports.default = void 0;

require("core-js/modules/es6.object.assign");

require("core-js/modules/web.dom.iterable");

require("core-js/modules/es6.array.iterator");

require("core-js/modules/es6.object.keys");

var _react = _interopRequireDefault(require("react"));

var _propTypes = _interopRequireDefault(require("prop-types"));

var _lodash = require("lodash");

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

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

/**
 * @category communication
 * @component loader-spinner
 * @variations collab-ui-react
 */
var Spinner = function Spinner(props) {
  var className = props.className,
      color = props.color,
      showCheck = props.showCheck,
      percentage = props.percentage,
      showPercentage = props.showPercentage,
      size = props.size,
      otherHTMLProps = _objectWithoutPropertiesLoose(props, ["className", "color", "showCheck", "percentage", "showPercentage", "size"]);

  if ((0, _lodash.isNumber)(percentage)) {
    if (size !== 36 && showPercentage) {
      /* eslint-disable no-console */
      console.warn('[@collab-ui/react] Spinner: Percentage will not be shown for sizes smaller than 36');
      /* eslint-enable no-console */
    }

    return _react.default.createElement("div", _extends({
      className: "cui-spinner-progress" + (" cui-spinner-progress__percentage-" + (0, _lodash.round)(percentage)) + ("" + (size && " cui-spinner-progress--" + size || '')) + ("" + (color && " cui-spinner-progress--" + color || '')) + ("" + (className && " " + className || ''))
    }, otherHTMLProps), _react.default.createElement("div", {
      className: "cui-spinner-progress__circle"
    }, _react.default.createElement("div", {
      className: "cui-spinner-progress__mask cui-spinner-progress__full"
    }, _react.default.createElement("div", {
      className: "cui-spinner-progress__fill"
    })), _react.default.createElement("div", {
      className: "cui-spinner-progress__mask cui-spinner-progress__half"
    }, _react.default.createElement("div", {
      className: "cui-spinner-progress__fill"
    }), _react.default.createElement("div", {
      className: "cui-spinner-progress__fill cui-spinner-progress__fix"
    })), _react.default.createElement("div", {
      className: "cui-spinner-progress__inset-circle" + ("" + (showCheck && percentage === 100 && ' cui-spinner-progress__inset-circle--check' || ''))
    }, size === 36 && showPercentage && !showCheck && _react.default.createElement("div", {
      className: "cui-spinner-progress__percentage"
    }, (0, _lodash.round)(percentage)))));
  } else {
    return _react.default.createElement("i", _extends({
      className: "cui-spinner" + ("" + (size && " cui-spinner--" + size || '')) + ("" + (color && " cui-spinner--" + color || '')) + ("" + (className && " " + className || ''))
    }, otherHTMLProps));
  }
};

Spinner.propTypes = {
  /**
   * css class names
   */
  className: _propTypes.default.string,

  /**
   * color
   */
  color: _propTypes.default.string,

  /**
   * percentage value to show on progress
   */
  percentage: _propTypes.default.number,

  /**
   * show the check mark if percentage 100
   */
  showCheck: _propTypes.default.bool,

  /**
   * show the number value for progress
   */
  showPercentage: _propTypes.default.bool,

  /**
   * size
   */
  size: _propTypes.default.oneOf([16, 20, 28, 36])
};
Spinner.defaultProps = {
  className: '',
  color: 'black',
  percentage: null,
  showCheck: false,
  showPercentage: false,
  size: 36
};
Spinner.displayName = 'Spinner';
var _default = Spinner;
/**
* @name Spinner
* @description Different states of spinners.
*
* @category communication
* @component loader-spinner
* @section states
*
* @js

import {Spinner} from '@collab-ui/react';

export default function Default() {
  return (
    <div className="row">

      <div className="docs-example docs-example--spacing">
        <h3>
          <p><code className="small">size=(16)</code></p>
        </h3>
        <Spinner size={16}/>
      </div>

      <div className="docs-example docs-example--spacing">
        <h3>
          <p><code className="small">size=(20)</code></p>
        </h3>
        <Spinner size={20}/>
      </div>

      <div className="docs-example docs-example--spacing">
        <h3>
          <p><code className="small">size=(28)</code></p>
        </h3>
        <Spinner size={28}/>
      </div>

      <div className="docs-example docs-example--spacing">
        <h3>
          <p><code className="small">Default size=(36)</code></p>
        </h3>
        <Spinner />
      </div>

      <div className="docs-example docs-example--spacing">
        <h3>
          <p><code className="small">color=(blue)</code></p>
        </h3>
        <Spinner color='blue'/>
      </div>

      <div className="docs-example docs-example--spacing cui--dark docs-example--dark">
        <h3>Dark Spinner</h3>
        <Spinner />
      </div>

      <div className="docs-example docs-example--spacing">
          <h3>
            <p><code className="small">percentage=(65)</code></p>
          </h3>
          <Spinner percentage={65}/>
      </div>

    </div>
  );
}

**/

/**
* @name Check Prop
* @description Set showCheck to true to show and percentage to 100.
*
* @category communication
* @component loader-spinner
* @section check
*
* @js

import {Spinner} from '@collab-ui/react';

export default function Default() {
  return (
    <div className='row'>

      <div className="docs-example docs-example--spacing">
        <h3>
          <p><code className="small">size=(16)</code></p>
        </h3>
        <Spinner
          size={16}
          percentage={100}
          showCheck
        />
      </div>

      <div className="docs-example docs-example--spacing">
        <h3>
          <p><code className="small">size=(20)</code></p>
        </h3>
          <Spinner
            size={20}
            percentage={100}
            showCheck
          />
      </div>

      <div className="docs-example docs-example--spacing">
        <h3>
          <p><code className="small">size=(28)</code></p>
        </h3>
          <Spinner
            size={28}
            percentage={100}
            showCheck
          />
      </div>

      <div>
        <h3>
          <p><code className="small">size=(36)</code></p>
        </h3>
          <Spinner
            size={36}
            percentage={100}
            showCheck
          />
      </div>

    </div>
  );
}

**/

exports.default = _default;