UNPKG

2.25 kBJavaScriptView Raw
1"use strict";
2var __extends = (this && this.__extends) || (function () {
3 var extendStatics = function (d, b) {
4 extendStatics = Object.setPrototypeOf ||
5 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7 return extendStatics(d, b);
8 };
9 return function (d, b) {
10 extendStatics(d, b);
11 function __() { this.constructor = d; }
12 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13 };
14})();
15Object.defineProperty(exports, "__esModule", { value: true });
16exports.getLayoutByName = exports.unRegisterLayout = exports.registerLayout = void 0;
17var base_1 = require("../layout/base");
18var util_1 = require("../util");
19var map = new Map();
20var registerLayout = function (name, layoutOverride) {
21 if (map.get(name)) {
22 throw new Error("The layout with the name " + name + " exists already");
23 }
24 if (util_1.isObject(layoutOverride)) {
25 // tslint:disable-next-line: max-classes-per-file
26 var GLayout = /** @class */ (function (_super) {
27 __extends(GLayout, _super);
28 function GLayout(cfg) {
29 var _this = _super.call(this) || this;
30 var self = _this;
31 var props = {};
32 var defaultCfg = self.getDefaultCfg();
33 Object.assign(props, defaultCfg, layoutOverride, cfg);
34 Object.keys(props).forEach(function (key) {
35 var value = props[key];
36 self[key] = value;
37 });
38 return _this;
39 }
40 return GLayout;
41 }(base_1.Base));
42 map.set(name, GLayout);
43 }
44 else {
45 map.set(name, layoutOverride);
46 }
47};
48exports.registerLayout = registerLayout;
49var unRegisterLayout = function (name) {
50 if (map.has(name)) {
51 map.delete(name);
52 }
53};
54exports.unRegisterLayout = unRegisterLayout;
55var getLayoutByName = function (name) {
56 if (map.has(name)) {
57 return map.get(name);
58 }
59 return null;
60};
61exports.getLayoutByName = getLayoutByName;
62//# sourceMappingURL=index.js.map
\No newline at end of file