"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));

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

var _RippleChild = _interopRequireDefault(require("./RippleChild"));

var _createChains = _interopRequireDefault(require("../_util/createChains"));

var _ConfigContext = _interopRequireDefault(require("../config-provider/ConfigContext"));

var _excluded = ["prefixCls", "disabled", "children"];

var Ripple = function Ripple(props) {
  var customizePrefixCls = props.prefixCls,
      disabled = props.disabled,
      children = props.children,
      rest = (0, _objectWithoutProperties2["default"])(props, _excluded);

  var _useContext = (0, _react.useContext)(_ConfigContext["default"]),
      getPrefixCls = _useContext.getPrefixCls,
      getConfig = _useContext.getConfig;

  var prefixCls = getPrefixCls('ripple', customizePrefixCls);

  var rippleChild = function rippleChild(child) {
    return /*#__PURE__*/_react["default"].createElement(_RippleChild["default"], (0, _extends2["default"])({
      prefixCls: prefixCls
    }, rest), child);
  };

  if (disabled || !children || !getConfig('ripple')) {
    if (children) {
      return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, _react.Children.map(children, function (child) {
        return /*#__PURE__*/(0, _react.isValidElement)(child) ? /*#__PURE__*/(0, _react.cloneElement)(child, (0, _createChains["default"])(rest, child.props)) : child;
      }));
    }

    return null;
  }

  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, _react.Children.map(children, function (child) {
    return rippleChild(child);
  }));
};

Ripple.displayName = 'Ripple';

var _default = /*#__PURE__*/(0, _react.memo)(Ripple);

exports["default"] = _default;
//# sourceMappingURL=index.js.map
