Repository URL to install this package:
|
Version:
2.1.0 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importDefault(require("react"));
const mobx_react_1 = require("xmobx/mobx-react");
const exotic_1 = require("exotic");
const forms_1 = require("@skava/ui/dist/forms");
const words_1 = require("@skava/ui/dist/words");
const fixture_1 = require("./fixture");
const styled_1 = require("./styled"); // @todo - radiogroup
class FormStateCard extends forms_1.FormState {
constructor() {
super(...arguments);
this.inputsList = fixture_1.inputList;
}
}
const formStateCard = new FormStateCard();
class FormButton extends react_1.default.PureComponent {
render() {
return react_1.default.createElement(styled_1.StyledPrimaryButton, Object.assign({}, this.props, {
"data-input-eh": true
}));
}
}
let FormCard = class FormCard extends forms_1.ObserverForm {
constructor() {
super(...arguments);
this.SubmitButton = FormButton;
this.defaultSubmitButtonLabel = words_1.wording.saveLabel;
this.handleSubmit = event => {
const {
onShippingCardSave
} = this.props;
event.preventDefault();
console.log('data:', this.state.toSerialized());
if (this.validateForm()) {
if (exotic_1.isFunction(onShippingCardSave)) {
onShippingCardSave(this.state);
}
}
};
}
onPrefil(inputState) {
const {
item
} = this.props;
if (exotic_1.isObj(item)) {
const fullName = (exotic_1.isSafe(item.firstName) ? item.firstName : '') + ' ' + (exotic_1.isSafe(item.lastName) ? item.lastName : '');
item.name = fullName;
if (exotic_1.isSafe(item[inputState.name]) && inputState.value !== item[inputState.name]) {
inputState.setValue(item[inputState.name]);
}
}
}
};
FormCard.FormState = formStateCard;
FormCard.defaultProps = {
state: formStateCard
};
FormCard = tslib_1.__decorate([mobx_react_1.observer], FormCard);
class Form extends react_1.default.Component {
render() {
return react_1.default.createElement(styled_1.StyledShippingForm, null, react_1.default.createElement(FormCard, Object.assign({}, this.props)));
}
}
exports.Form = Form;
exports.default = Form;