choerodon-ui
Version:
An enterprise-class UI design language and React-based implementation
45 lines (36 loc) • 1.63 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["prefixCls", "disabled", "children"];
import React, { Children, cloneElement, isValidElement, memo, useContext } from 'react';
import RippleChild from './RippleChild';
import createChains from '../_util/createChains';
import ConfigContext from '../config-provider/ConfigContext';
var Ripple = function Ripple(props) {
var customizePrefixCls = props.prefixCls,
disabled = props.disabled,
children = props.children,
rest = _objectWithoutProperties(props, _excluded);
var _useContext = useContext(ConfigContext),
getPrefixCls = _useContext.getPrefixCls,
getConfig = _useContext.getConfig;
var prefixCls = getPrefixCls('ripple', customizePrefixCls);
var rippleChild = function rippleChild(child) {
return /*#__PURE__*/React.createElement(RippleChild, _extends({
prefixCls: prefixCls
}, rest), child);
};
if (disabled || !children || !getConfig('ripple')) {
if (children) {
return /*#__PURE__*/React.createElement(React.Fragment, null, Children.map(children, function (child) {
return /*#__PURE__*/isValidElement(child) ? /*#__PURE__*/cloneElement(child, createChains(rest, child.props)) : child;
}));
}
return null;
}
return /*#__PURE__*/React.createElement(React.Fragment, null, Children.map(children, function (child) {
return rippleChild(child);
}));
};
Ripple.displayName = 'Ripple';
export default /*#__PURE__*/memo(Ripple);
//# sourceMappingURL=index.js.map