@up-group-ui/react-controls
Version:
Up shared react controls
31 lines • 1.41 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime");
var react_1 = (0, tslib_1.__importDefault)(require("react"));
var PropTypes = (0, tslib_1.__importStar)(require("prop-types"));
var withTheme = function (WrappedComponent) {
var _a;
return _a = (function (_super) {
(0, tslib_1.__extends)(ComponentWithTheme, _super);
function ComponentWithTheme(props, context) {
return _super.call(this, props, context) || this;
}
ComponentWithTheme.prototype.render = function () {
var theme = this.context.theme;
var _a = this.props, children = _a.children, others = (0, tslib_1.__rest)(_a, ["children"]);
return ((0, jsx_runtime_1.jsx)(WrappedComponent, (0, tslib_1.__assign)({ theme: theme }, others, { children: children }), void 0));
};
return ComponentWithTheme;
}(react_1.default.Component)),
_a.displayName = "WithTheme(" + getDisplayName(WrappedComponent) + ")",
_a.contextTypes = {
theme: PropTypes.object,
},
_a;
};
function getDisplayName(WrappedComponent) {
return WrappedComponent.displayName || WrappedComponent.name || 'Component';
}
exports.default = withTheme;
//# sourceMappingURL=withTheme.js.map