choerodon-ui
Version:
An enterprise-class UI design language and React-based implementation
97 lines (78 loc) • 2.87 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _inherits from "@babel/runtime/helpers/inherits";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
function _createSuper(Derived) {
function isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
return true;
} catch (e) {
return false;
}
}
return function () {
var Super = _getPrototypeOf(Derived),
result;
if (isNativeReflectConstruct()) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}
import React, { Children, cloneElement, isValidElement, PureComponent } from 'react';
import RippleChild from './RippleChild';
import { getConfig, getPrefixCls } from '../configure';
import createChains from '../_util/createChains';
var Ripple =
/*#__PURE__*/
function (_PureComponent) {
_inherits(Ripple, _PureComponent);
var _super = _createSuper(Ripple);
function Ripple() {
_classCallCheck(this, Ripple);
return _super.apply(this, arguments);
}
_createClass(Ripple, [{
key: "render",
value: function render() {
var _this = this;
var _this$props = this.props,
disabled = _this$props.disabled,
children = _this$props.children,
rest = _objectWithoutProperties(_this$props, ["disabled", "children"]);
if (disabled || !children || !getConfig('ripple')) {
if (children) {
return Children.map(children, function (child) {
return isValidElement(child) ? cloneElement(child, createChains(rest, child.props)) : child;
});
}
return children;
}
return Children.map(children, function (child) {
return _this.rippleChild(child, rest);
});
}
}, {
key: "rippleChild",
value: function rippleChild(child, rest) {
var prefixCls = this.props.prefixCls;
return React.createElement(RippleChild, _extends({
prefixCls: getPrefixCls('ripple', prefixCls)
}, rest), child);
}
}]);
return Ripple;
}(PureComponent);
export { Ripple as default };
Ripple.displayName = 'Ripple';
//# sourceMappingURL=index.js.map