UNPKG

react-application-core

Version:

A react-based application core for the business applications.

76 lines 4.03 kB
"use strict"; 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 (Object.prototype.hasOwnProperty.call(b, 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 }); exports.Info = void 0; var React = require("react"); var R = require("ramda"); var util_1 = require("../../util"); var definition_1 = require("../../definition"); var generic_component_1 = require("../base/generic.component"); var Info = /** @class */ (function (_super) { __extends(Info, _super); function Info() { return _super !== null && _super.apply(this, arguments) || this; } /** * @stable [03.04.2020] * @returns {JSX.Element} */ Info.prototype.render = function () { var _a = this.originalProps, full = _a.full, text = _a.text; var props = this.props; var emptyData = props.emptyData, error = props.error, message = props.message, progress = props.progress; var hasChildren = !R.isNil(props.children); var messages = this.settings.messages; var result = progress === true ? { text: messages.PLEASE_WAIT, progress: true } : (util_1.isStringNotEmpty(progress) ? { text: this.t(progress), progress: true } : (error === true ? { text: messages.ERROR, error: true } : (util_1.isStringNotEmpty(error) ? { text: this.t(error), error: true } : (error instanceof Error ? { text: (error.stack), error: true } : (util_1.TypeUtils.isObject(error) ? { text: util_1.JsonUtils.formatJson(error), error: true } : { text: (emptyData ? (util_1.TypeUtils.isString(emptyData) ? emptyData : messages.NOT_DATA_FOUND) : (message === false ? null : (R.isNil(message) ? (hasChildren ? message : messages.NO_DATA) : message))), }))))); return (React.createElement("div", { className: util_1.ClsUtils.joinClassName(definition_1.InfoClassesEnum.INFO, full && definition_1.InfoClassesEnum.FULL_INFO, result.error && definition_1.InfoClassesEnum.ERROR_INFO, result.progress && definition_1.InfoClassesEnum.PROGRESS_INFO, !result.error && !result.progress && definition_1.InfoClassesEnum.MESSAGE_INFO, util_1.CalcUtils.calc(props.className)) }, result.text && (React.createElement("span", { className: definition_1.InfoClassesEnum.INFO_TEXT }, result.progress && this.uiFactory.makeIcon({ type: definition_1.IconsEnum.SPINNER, className: definition_1.InfoClassesEnum.INFO_ICON }), text === false ? null : (util_1.TypeUtils.isString(text) ? text : result.text))), props.children)); }; Info.defaultProps = { full: true, }; return Info; }(generic_component_1.GenericComponent)); exports.Info = Info; //# sourceMappingURL=info.component.js.map