[d565449] | 1 | "use strict";
|
---|
| 2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
| 3 | exports.divWrapper = void 0;
|
---|
| 4 | var tslib_1 = require("tslib");
|
---|
| 5 | var React = tslib_1.__importStar(require("react"));
|
---|
| 6 | var addClassDecoratorSupport_1 = tslib_1.__importDefault(require("./addClassDecoratorSupport"));
|
---|
| 7 | var h = React.createElement;
|
---|
| 8 | var noWrap = function (Comp, propName, props, state) {
|
---|
| 9 | var _a;
|
---|
| 10 | return h(Comp, propName ? tslib_1.__assign((_a = {}, _a[propName] = state, _a), props) : tslib_1.__assign(tslib_1.__assign({}, state), props));
|
---|
| 11 | };
|
---|
| 12 | exports.divWrapper = function (Comp, propName, props, state) {
|
---|
| 13 | return h('div', null, noWrap(Comp, propName, props, state));
|
---|
| 14 | };
|
---|
| 15 | var createEnhancer = function (Facc, prop, wrapper) {
|
---|
| 16 | if (wrapper === void 0) { wrapper = noWrap; }
|
---|
| 17 | var enhancer = function (Comp, propName, faccProps) {
|
---|
| 18 | if (propName === void 0) { propName = prop; }
|
---|
| 19 | if (faccProps === void 0) { faccProps = null; }
|
---|
| 20 | var isClassDecoratorMethodCall = typeof Comp === 'string';
|
---|
| 21 | if (isClassDecoratorMethodCall) {
|
---|
| 22 | return function (Klass) { return enhancer(Klass, Comp || prop, propName); };
|
---|
| 23 | }
|
---|
| 24 | var Enhanced = function (props) {
|
---|
| 25 | return h(Facc, faccProps, function (state) { return wrapper(Comp, propName, props, state); });
|
---|
| 26 | };
|
---|
| 27 | if (process.env.NODE_ENV !== 'production') {
|
---|
| 28 | Enhanced.displayName = (Facc.displayName || Facc.name) + "(" + (Comp.displayName || Comp.name) + ")";
|
---|
| 29 | }
|
---|
| 30 | return isClassDecoratorMethodCall ? addClassDecoratorSupport_1.default(Enhanced) : Enhanced;
|
---|
| 31 | };
|
---|
| 32 | return enhancer;
|
---|
| 33 | };
|
---|
| 34 | exports.default = createEnhancer;
|
---|
| 35 | //# sourceMappingURL=createEnhancer.js.map |
---|