Repository URL to install this package:
|
Version:
2.3.9 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importDefault(require("react"));
const exotic_1 = require("exotic");
const forms_1 = require("../../..");
const styled_1 = require("../styled");
const fixture_1 = require("./fixture");
class FormStateCard extends forms_1.FormState {
constructor() {
super(...arguments);
this.inputsList = fixture_1.inputList;
}
}
const formStateCard = new FormStateCard();
const SubmitButtonComponent = props => {
return react_1.default.createElement(styled_1.StyledSubmitButton, Object.assign({}, props));
};
exports.SubmitButtonComponent = SubmitButtonComponent;
const CancelButtonComponent = props => {
return react_1.default.createElement(styled_1.StyledCancelButton, Object.assign({}, props));
};
exports.CancelButtonComponent = CancelButtonComponent;
class Form extends forms_1.ObserverForm {
constructor() {
super(...arguments);
this.isCancelButtonNeeded = true;
this.SubmitButton = SubmitButtonComponent;
this.CancelButton = CancelButtonComponent;
this.handleSubmit = event => {
const {
onSubmit
} = this.props;
event.preventDefault();
if (this.validateForm()) {
if (exotic_1.isFunction(onSubmit)) {
onSubmit(this.state);
}
}
};
this.handleCancel = event => {
const {
onCancel
} = this.props;
event.preventDefault();
if (exotic_1.isFunction(onCancel)) {
onCancel(this.state);
}
};
}
componentWillUpdate() {
const {
submitButtonLabel,
cancelButtonLabel,
submitButtonDataQa,
cancelButtonDataQa,
placeHolder,
textAreaDataQa
} = this.props;
this.defaultSubmitButtonLabel = exotic_1.isSafe(submitButtonLabel) ? submitButtonLabel : fixture_1.wording.submitLabel;
this.defaultCancelButtonLabel = exotic_1.isSafe(cancelButtonLabel) ? cancelButtonLabel : fixture_1.wording.cancelLabel;
this.submitDataQa = submitButtonDataQa;
this.cancelDataQa = cancelButtonDataQa;
const inputList = this.state.get('commentBox');
const passThroughProps = {
placeholder: exotic_1.isSafe(placeHolder) ? placeHolder : fixture_1.wording.placeholderText,
dataQa: textAreaDataQa
};
Object.keys(passThroughProps).forEach(key => {
inputList[key] = passThroughProps[key];
});
}
}
Form.FormState = formStateCard;
Form.defaultProps = {
state: formStateCard
};
exports.Form = Form;
exports.default = Form; //# sourceMappingURL=Form.js.map