react-application-core
Version:
A react-based application core for the business applications.
105 lines • 4.75 kB
JavaScript
;
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 __());
};
})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ApplicationContainer = void 0;
var React = require("react");
var react_router_dom_1 = require("react-router-dom");
var di_1 = require("../../di");
var definition_1 = require("../../definition");
var root_1 = require("../root");
var universal_application_container_1 = require("./universal-application.container");
var util_1 = require("../../util");
var ApplicationContainer = /** @class */ (function (_super) {
__extends(ApplicationContainer, _super);
function ApplicationContainer() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.routerRef = React.createRef();
return _this;
}
/**
* @stable [24.09.2019]
* @returns {JSX.Element}
*/
ApplicationContainer.prototype.render = function () {
return (React.createElement(react_router_dom_1.BrowserRouter, { ref: this.routerRef, basename: this.props.basename || this.environment.basePath },
React.createElement(react_router_dom_1.Switch, null, this.getRoutes())));
};
/**
* @stable [24.09.2019]
*/
ApplicationContainer.prototype.componentDidMount = function () {
di_1.bindToConstantValue(di_1.DI_TYPES.Router, this.dynamicRouter);
_super.prototype.componentDidMount.call(this);
if (this.storageSettings.appStateSyncEnabled) {
// No need unsubscribe because "unload event"d
this.eventManager.subscribe(this.environment.window, definition_1.EventsEnum.UNLOAD, this.syncAppState);
}
};
/**
* @stable [16.11.2019]
* @param {IGenericContainerCtor} ctor
* @param {IConnectorEntity} connectorEntity
* @returns {JSX.Element}
*/
ApplicationContainer.prototype.buildRoute = function (ctor, connectorEntity) {
var routeEntity = connectorEntity.routeConfiguration;
var Component = routeEntity.type === definition_1.ContainerVisibilityTypesEnum.PRIVATE
? root_1.PrivateRootContainer
: root_1.PublicRootContainer;
var props = __assign(__assign({}, routeEntity), util_1.ifNotEmptyThanValue(routeEntity.path, function () { return ({ path: util_1.calc(routeEntity.path) }); }));
return (React.createElement(Component, __assign({ exact: true, accessConfiguration: connectorEntity.accessConfiguration, container: ctor }, props, { key: this.toRouteId(routeEntity) })));
};
/**
* @stable [28.11.2019]
* @returns {React.ReactNode}
*/
ApplicationContainer.prototype.getMessageElement = function () {
return (React.createElement(React.Fragment, null, _super.prototype.getMessageElement.call(this)));
};
/**
* @stable [28.11.2019]
* @param {IUiMessageConfigEntity} message
* @returns {IUiMessageConfigEntity}
*/
ApplicationContainer.prototype.prepareMessage = function (message) {
return __assign(__assign({}, message), { wrapperClassName: 'rac-application-message' });
};
Object.defineProperty(ApplicationContainer.prototype, "dynamicRouter", {
/**
* @stable [24.09.2019]
* @returns {IRouter}
*/
get: function () {
// We cannot to get access to history instance other way. This instance is private
return this.routerRef.current.history;
},
enumerable: false,
configurable: true
});
return ApplicationContainer;
}(universal_application_container_1.UniversalApplicationContainer));
exports.ApplicationContainer = ApplicationContainer;
//# sourceMappingURL=application.container.js.map