1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | "use strict";
|
8 | Object.defineProperty(exports, "__esModule", { value: true });
|
9 | var BaseComponentWrapper = (function () {
|
10 | function BaseComponentWrapper() {
|
11 | }
|
12 | BaseComponentWrapper.prototype.wrap = function (OriginalConstructor, mandatoryMethodList, optionalMethodList, componentName) {
|
13 | var _this = this;
|
14 | var wrapper = this.createWrapper(OriginalConstructor, componentName);
|
15 | mandatoryMethodList.forEach((function (methodName) {
|
16 | _this.createMethod(wrapper, methodName, true);
|
17 | }));
|
18 | if (optionalMethodList) {
|
19 | optionalMethodList.forEach((function (methodName) {
|
20 | _this.createMethod(wrapper, methodName, false);
|
21 | }));
|
22 | }
|
23 | return wrapper;
|
24 | };
|
25 | BaseComponentWrapper.prototype.createMethod = function (wrapper, methodName, mandatory) {
|
26 | wrapper.addMethod(methodName, this.createMethodProxy(wrapper, methodName, mandatory));
|
27 | };
|
28 | BaseComponentWrapper.prototype.createMethodProxy = function (wrapper, methodName, mandatory) {
|
29 | return function () {
|
30 | if (wrapper.hasMethod(methodName)) {
|
31 | return wrapper.callMethod(methodName, arguments);
|
32 | }
|
33 | if (mandatory) {
|
34 | console.warn('ag-Grid: Framework component is missing the method ' + methodName + '()');
|
35 | }
|
36 | return null;
|
37 | };
|
38 | };
|
39 | return BaseComponentWrapper;
|
40 | }());
|
41 | exports.BaseComponentWrapper = BaseComponentWrapper;
|