choerodon-ui
Version:
An enterprise-class UI design language and React-based implementation
113 lines (96 loc) • 3.12 kB
JavaScript
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";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
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 { Component } from 'react';
import PropTypes from 'prop-types';
import { createPortal, unstable_renderSubtreeIntoContainer } from 'react-dom';
var IS_REACT_16 = !!createPortal;
var SuggestionWrapper =
/*#__PURE__*/
function (_Component) {
_inherits(SuggestionWrapper, _Component);
var _super = _createSuper(SuggestionWrapper);
function SuggestionWrapper() {
_classCallCheck(this, SuggestionWrapper);
return _super.apply(this, arguments);
}
_createClass(SuggestionWrapper, [{
key: "componentDidMount",
value: function componentDidMount() {
this.renderOrReady();
}
}, {
key: "componentDidUpdate",
value: function componentDidUpdate() {
this.renderOrReady();
}
}, {
key: "renderOrReady",
value: function renderOrReady() {
if (IS_REACT_16) {
this.props.renderReady();
} else {
this.renderComponent();
}
}
}, {
key: "renderComponent",
value: function renderComponent() {
var _this$props = this.props,
children = _this$props.children,
container = _this$props.container,
renderReady = _this$props.renderReady;
unstable_renderSubtreeIntoContainer(this, children, container, function callback() {
if (renderReady) {
renderReady.call(this);
}
});
}
}, {
key: "render",
value: function render() {
if (IS_REACT_16) {
var _this$props2 = this.props,
children = _this$props2.children,
container = _this$props2.container;
return createPortal(children, container);
}
return null;
}
}]);
return SuggestionWrapper;
}(Component);
_defineProperty(SuggestionWrapper, "propTypes", {
children: PropTypes.any,
renderReady: PropTypes.func,
container: PropTypes.any
});
export { SuggestionWrapper as default };
//# sourceMappingURL=SuggestionWrapper.react.js.map