react-application-core
Version:
A react-based application core for the business applications.
102 lines • 4.06 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.FormContainer = void 0;
var React = require("react");
var generic_container_1 = require("../base/generic.container");
var form_component_1 = require("../form/form.component");
var util_1 = require("../../util");
/**
* @component-container-impl
* @stable [01.08.2020]
*
* Please use the "Mappers.formContainerProps"
*/
var FormContainer = /** @class */ (function (_super) {
__extends(FormContainer, _super);
/**
* @stable [01.08.2020]
* @param originalProps
*/
function FormContainer(originalProps) {
var _this = _super.call(this, originalProps) || this;
_this.onChange = _this.onChange.bind(_this);
_this.onReset = _this.onReset.bind(_this);
_this.onSubmit = _this.onSubmit.bind(_this);
_this.onValid = _this.onValid.bind(_this);
return _this;
}
/**
* @stable [01.08.2020]
*/
FormContainer.prototype.render = function () {
return (React.createElement(form_component_1.Form, __assign({}, util_1.Mappers.formContainerPropsAsFormProps(this.originalProps), { onChange: this.onChange, onReset: this.onReset, onSubmit: this.onSubmit, onValid: this.onValid }), this.originalChildren));
};
/**
* @stable [01.08.2020]
* @param payload
*/
FormContainer.prototype.onChange = function (payload) {
this.formStoreProxy.dispatchFormChanges(payload);
util_1.ConditionUtils.ifNotNilThanValue(this.formConfiguration.onChange, function (onChange) { return onChange(payload); });
};
/**
* @stable [01.08.2020]
* @param valid
*/
FormContainer.prototype.onValid = function (valid) {
this.formStoreProxy.dispatchFormValid(valid);
util_1.ConditionUtils.ifNotNilThanValue(this.formConfiguration.onValid, function (onValid) { return onValid(valid); });
};
/**
* @stable [01.08.2020]
*/
FormContainer.prototype.onReset = function () {
this.formStoreProxy.dispatchFormReset();
util_1.ConditionUtils.ifNotNilThanValue(this.formConfiguration.onReset, function (onReset) { return onReset(); });
};
/**
* @stable [01.08.2020]
* @param apiEntity
*/
FormContainer.prototype.onSubmit = function (apiEntity) {
this.formStoreProxy.dispatchFormSubmit(apiEntity);
util_1.ConditionUtils.ifNotNilThanValue(this.formConfiguration.onSubmit, function (onSubmit) { return onSubmit(apiEntity); });
};
Object.defineProperty(FormContainer.prototype, "formConfiguration", {
/**
* @stable [01.08.2020]
*/
get: function () {
return this.originalProps.formConfiguration || {};
},
enumerable: false,
configurable: true
});
return FormContainer;
}(generic_container_1.GenericContainer));
exports.FormContainer = FormContainer;
//# sourceMappingURL=form.container.js.map