UNPKG

@nu-art/thunder

Version:

Thunder - React & Typescript based frontend framework

116 lines 4.52 kB
"use strict"; /* * Thunder is a typescript & react frontend foundation that natively * runs on firebase function and is a part of the Thunderstorm larger project * * Copyright (C) 2018 Adam van der Kruk aka TacB0sS * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); /** * Created by tacb0ss on 28/07/2018. */ var React = require("react"); var ts_common_1 = require("@nu-art/ts-common"); var __1 = require(".."); // @ts-ignore var BaseComponent = /** @class */ (function (_super) { __extends(BaseComponent, _super); function BaseComponent(props) { var _this = _super.call(this, props) || this; _this.logger = new ts_common_1.Logger(_this.constructor.name); _this._componentDidMount = _this.componentDidMount; _this.componentDidMount = function () { // @ts-ignore __1.Thunder.addUIListener(_this); if (_this._componentDidMount) _this._componentDidMount(); }; _this._componentWillUnmount = _this.componentWillUnmount; _this.componentWillUnmount = function () { if (_this._componentWillUnmount) _this._componentWillUnmount(); // @ts-ignore __1.Thunder.removeUIListener(_this); }; return _this; } BaseComponent.prototype.logVerbose = function (message, error) { this.logger.logVerbose(message, error); }; BaseComponent.prototype.logDebug = function (message, error) { this.logger.logDebug(message, error); }; BaseComponent.prototype.logInfo = function (message, error) { this.logger.logInfo(message, error); }; BaseComponent.prototype.logWarning = function (message, error) { this.logger.logWarning(message, error); }; BaseComponent.prototype.logError = function (message, error) { this.logger.logError(message, error); }; BaseComponent.prototype.log = function (level, bold, message, error) { this.logger.log(level, bold, message, error); }; BaseComponent.store = function (key, value) { __1.StorageModule.set(key, value); }; BaseComponent.load = function (key, defaultValue) { return __1.StorageModule.get(key, defaultValue); }; BaseComponent.getElementId = function (e) { return e.currentTarget.id; }; BaseComponent.getImageUrl = function (_relativePath) { var relativePath = _relativePath; if (!relativePath) return ""; if (relativePath.indexOf(".") === -1) relativePath += ".png"; return __1.ResourcesModule.getImageUrl(relativePath); }; BaseComponent.getQueryParameter = function (name) { return __1.BrowserHistoryModule.getQueryParams()[name]; }; BaseComponent.getUrl = function () { return __1.BrowserHistoryModule.getCurrent().pathname; }; BaseComponent.getLocalizedString = function (key) { var params = []; for (var _i = 1; _i < arguments.length; _i++) { params[_i - 1] = arguments[_i]; } return __1.LocalizationModule.getString(key, params); }; BaseComponent.prototype.toString = function () { return this.constructor.name; }; return BaseComponent; }(React.Component)); exports.BaseComponent = BaseComponent; //# sourceMappingURL=BaseComponent.js.map