"use strict";

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

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 _objectWithoutProperties(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]; } 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; }

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

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

    return _react.default.createElement("div", _extends({
      className: "cui-spinner-progress" + ("" + (size && " cui-spinner-progress--" + size || '')) + ("" + (color && " cui-spinner-progress--" + color || '')) + ("" + (className && " " + className || '')) + (" cui-spinner-progress__percentage-" + (0, _lodash.round)(percentage))
    }, 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"
    }, size === 36 && showPercentage && _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 number value for progress
   */
  showPercentage: _propTypes.default.bool,

  /**
   * size
   */
  size: _propTypes.default.oneOf([16, 20, 28, 36])
};
Spinner.defaultProps = {
  className: '',
  color: 'black',
  percentage: null,
  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>

      <div className="docs-example docs-example--spacing">
        <h3>Size Prop</h3>
        <h3><code className="small">size=(16)</code></h3>
        <Spinner size={16}/>
        <h3><code className="small">size=(20)</code></h3>
        <Spinner size={20}/>
        <h3><code className="small">size=(28)</code></h3>
        <Spinner size={28}/>
        <h3><code className="small">Default size=(36)</code></h3>
        <Spinner />
      </div>

      <div className="docs-example docs-example--spacing">
        <h3>Color Prop</h3>
        <h3><code className="small">color:blue</code></h3>
        <Spinner color='blue'/>
      </div>

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

      <div className="docs-example docs-example--spacing">
        <h3>Percentage Prop</h3>
        <h3><code className="small">percentage:65</code></h3>
        <Spinner percentage={65}/>
      </div>
      
    </div>
  );
}

**/

exports.default = _default;