1 | import { __extends } from "tslib";
|
2 | import * as React from 'react';
|
3 | import { Customizations } from './Customizations';
|
4 | import { CustomizerContext } from './CustomizerContext';
|
5 | import { mergeCustomizations } from './mergeCustomizations';
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | var Customizer = (function (_super) {
|
21 | __extends(Customizer, _super);
|
22 | function Customizer() {
|
23 | var _this = _super !== null && _super.apply(this, arguments) || this;
|
24 | _this._onCustomizationChange = function () { return _this.forceUpdate(); };
|
25 | return _this;
|
26 | }
|
27 | Customizer.prototype.componentDidMount = function () {
|
28 | Customizations.observe(this._onCustomizationChange);
|
29 | };
|
30 | Customizer.prototype.componentWillUnmount = function () {
|
31 | Customizations.unobserve(this._onCustomizationChange);
|
32 | };
|
33 | Customizer.prototype.render = function () {
|
34 | var _this = this;
|
35 | var contextTransform = this.props.contextTransform;
|
36 | return (React.createElement(CustomizerContext.Consumer, null, function (parentContext) {
|
37 | var newContext = mergeCustomizations(_this.props, parentContext);
|
38 | if (contextTransform) {
|
39 | newContext = contextTransform(newContext);
|
40 | }
|
41 | return React.createElement(CustomizerContext.Provider, { value: newContext }, _this.props.children);
|
42 | }));
|
43 | };
|
44 | return Customizer;
|
45 | }(React.Component));
|
46 | export { Customizer };
|
47 |
|
\ | No newline at end of file |