This commit is contained in:
Maxime Renou
2019-03-01 15:05:03 +01:00
parent 0b0db31166
commit e9fbdcfd2e
5 changed files with 92 additions and 50 deletions

56
dist/index.es.js vendored
View File

@@ -1,4 +1,4 @@
import React, { Component, useContext } from 'react';
import React, { Component } from 'react';
import require$$1 from 'prop-types';
import reactDom from 'react-dom';
@@ -2765,13 +2765,13 @@ var lib_7 = lib.ToastType;
var lib_8 = lib.toast;
var lib_9 = lib.cssTransition;
var Form = function (_Component) {
inherits(Form, _Component);
var ContextAwareForm = function (_Component) {
inherits(ContextAwareForm, _Component);
function Form(props) {
classCallCheck(this, Form);
function ContextAwareForm(props) {
classCallCheck(this, ContextAwareForm);
var _this = possibleConstructorReturn(this, (Form.__proto__ || Object.getPrototypeOf(Form)).call(this, props));
var _this = possibleConstructorReturn(this, (ContextAwareForm.__proto__ || Object.getPrototypeOf(ContextAwareForm)).call(this, props));
_this._onSubmit = function (e) {
e.preventDefault();
@@ -2789,7 +2789,7 @@ var Form = function (_Component) {
return _this;
}
createClass(Form, [{
createClass(ContextAwareForm, [{
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(props) {
this.handleError(props);
@@ -2801,8 +2801,7 @@ var Form = function (_Component) {
key: 'handleError',
value: function handleError(props) {
if (props.data && props.data.error && props.toast && this.displayError == true) {
var contextValue = useContext(FormTranslationContext);
lib_8.error(contextValue.renderText(props.data.error));
lib_8.error(this.props.translator.renderText(props.data.error));
this.displayError = false;
}
}
@@ -2824,25 +2823,42 @@ var Form = function (_Component) {
}, {
key: 'renderError',
value: function renderError() {
var _this2 = this;
if (this.state.data && this.state.data.error && !this.props.toast) {
return React.createElement(
FormTranslationConsumer,
null,
function (translator) {
return React.createElement(
'p',
{ className: 'alert alert-danger' },
translator.renderText(_this2.state.data.error)
);
}
'p',
{ className: 'alert alert-danger' },
this.props.translator.renderText(this.state.data.error)
);
}
return null;
}
}]);
return ContextAwareForm;
}(Component);
var Form = function (_Component2) {
inherits(Form, _Component2);
function Form() {
classCallCheck(this, Form);
return possibleConstructorReturn(this, (Form.__proto__ || Object.getPrototypeOf(Form)).apply(this, arguments));
}
createClass(Form, [{
key: 'render',
value: function render() {
var _this3 = this;
return React.createElement(
FormTranslationConsumer,
null,
function (translator) {
return React.createElement(ContextAwareForm, _extends({ translator: translator }, _this3.props));
}
);
}
}]);
return Form;
}(Component);

File diff suppressed because one or more lines are too long

54
dist/index.js vendored
View File

@@ -2772,13 +2772,13 @@ var lib_7 = lib.ToastType;
var lib_8 = lib.toast;
var lib_9 = lib.cssTransition;
var Form = function (_Component) {
inherits(Form, _Component);
var ContextAwareForm = function (_Component) {
inherits(ContextAwareForm, _Component);
function Form(props) {
classCallCheck(this, Form);
function ContextAwareForm(props) {
classCallCheck(this, ContextAwareForm);
var _this = possibleConstructorReturn(this, (Form.__proto__ || Object.getPrototypeOf(Form)).call(this, props));
var _this = possibleConstructorReturn(this, (ContextAwareForm.__proto__ || Object.getPrototypeOf(ContextAwareForm)).call(this, props));
_this._onSubmit = function (e) {
e.preventDefault();
@@ -2796,7 +2796,7 @@ var Form = function (_Component) {
return _this;
}
createClass(Form, [{
createClass(ContextAwareForm, [{
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(props) {
this.handleError(props);
@@ -2808,8 +2808,7 @@ var Form = function (_Component) {
key: 'handleError',
value: function handleError(props) {
if (props.data && props.data.error && props.toast && this.displayError == true) {
var contextValue = React.useContext(FormTranslationContext);
lib_8.error(contextValue.renderText(props.data.error));
lib_8.error(this.props.translator.renderText(props.data.error));
this.displayError = false;
}
}
@@ -2831,25 +2830,42 @@ var Form = function (_Component) {
}, {
key: 'renderError',
value: function renderError() {
var _this2 = this;
if (this.state.data && this.state.data.error && !this.props.toast) {
return React__default.createElement(
FormTranslationConsumer,
null,
function (translator) {
return React__default.createElement(
'p',
{ className: 'alert alert-danger' },
translator.renderText(_this2.state.data.error)
);
}
'p',
{ className: 'alert alert-danger' },
this.props.translator.renderText(this.state.data.error)
);
}
return null;
}
}]);
return ContextAwareForm;
}(React.Component);
var Form = function (_Component2) {
inherits(Form, _Component2);
function Form() {
classCallCheck(this, Form);
return possibleConstructorReturn(this, (Form.__proto__ || Object.getPrototypeOf(Form)).apply(this, arguments));
}
createClass(Form, [{
key: 'render',
value: function render() {
var _this3 = this;
return React__default.createElement(
FormTranslationConsumer,
null,
function (translator) {
return React__default.createElement(ContextAwareForm, _extends({ translator: translator }, _this3.props));
}
);
}
}]);
return Form;
}(React.Component);

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long