Translation support

This commit is contained in:
Maxime Renou 2019-03-01 14:49:23 +01:00
parent 31c121bb19
commit c274761818
5 changed files with 75 additions and 75 deletions

72
dist/index.es.js vendored
View File

@ -91,6 +91,37 @@ var FormConsumer = function (_Component) {
return FormConsumer; return FormConsumer;
}(Component); }(Component);
var FormTranslationContext = React.createContext({
renderText: function renderText(text) {
return text;
}
});
var FormTranslationConsumer = function (_Component) {
inherits(FormTranslationConsumer, _Component);
function FormTranslationConsumer() {
classCallCheck(this, FormTranslationConsumer);
return possibleConstructorReturn(this, (FormTranslationConsumer.__proto__ || Object.getPrototypeOf(FormTranslationConsumer)).apply(this, arguments));
}
createClass(FormTranslationConsumer, [{
key: 'render',
value: function render() {
var _this2 = this;
return React.createElement(
FormTranslationContext.Consumer,
null,
function (props) {
return _this2.props.children(props);
}
);
}
}]);
return FormTranslationConsumer;
}(Component);
var FormItemError = function (_Component) { var FormItemError = function (_Component) {
inherits(FormItemError, _Component); inherits(FormItemError, _Component);
@ -100,7 +131,7 @@ var FormItemError = function (_Component) {
} }
createClass(FormItemError, [{ createClass(FormItemError, [{
key: "render", key: 'render',
value: function render() { value: function render() {
var _this2 = this; var _this2 = this;
@ -117,12 +148,12 @@ var FormItemError = function (_Component) {
); );
} }
}, { }, {
key: "renderError", key: 'renderError',
value: function renderError(data, translator) { value: function renderError(data, translator) {
return React.createElement( return React.createElement(
"p", 'p',
{ className: "text-danger" }, { className: 'text-danger' },
translator.handleText(data.errors[this.props.name].error) translator.renderText(data.errors[this.props.name].error)
); );
} }
}]); }]);
@ -3286,36 +3317,5 @@ TextArea.defaultProps = {
onChangeValue: function onChangeValue(text) {} onChangeValue: function onChangeValue(text) {}
}; };
var FormTranslationContext = React.createContext({
renderText: function renderText(text) {
return text;
}
});
var FormTranslationConsumer$1 = function (_Component) {
inherits(FormTranslationConsumer, _Component);
function FormTranslationConsumer() {
classCallCheck(this, FormTranslationConsumer);
return possibleConstructorReturn(this, (FormTranslationConsumer.__proto__ || Object.getPrototypeOf(FormTranslationConsumer)).apply(this, arguments));
}
createClass(FormTranslationConsumer, [{
key: 'render',
value: function render() {
var _this2 = this;
return React.createElement(
FormTranslationContext.Consumer,
null,
function (props) {
return _this2.props.children(props);
}
);
}
}]);
return FormTranslationConsumer;
}(Component);
export { CheckBox, Form, Input, Option, OptionGroup, RadioGroup, Radio, Submit, TextArea, FormTranslationContext }; export { CheckBox, Form, Input, Option, OptionGroup, RadioGroup, Radio, Submit, TextArea, FormTranslationContext };
//# sourceMappingURL=index.es.js.map //# sourceMappingURL=index.es.js.map

File diff suppressed because one or more lines are too long

72
dist/index.js vendored
View File

@ -98,6 +98,37 @@ var FormConsumer = function (_Component) {
return FormConsumer; return FormConsumer;
}(React.Component); }(React.Component);
var FormTranslationContext = React__default.createContext({
renderText: function renderText(text) {
return text;
}
});
var FormTranslationConsumer = function (_Component) {
inherits(FormTranslationConsumer, _Component);
function FormTranslationConsumer() {
classCallCheck(this, FormTranslationConsumer);
return possibleConstructorReturn(this, (FormTranslationConsumer.__proto__ || Object.getPrototypeOf(FormTranslationConsumer)).apply(this, arguments));
}
createClass(FormTranslationConsumer, [{
key: 'render',
value: function render() {
var _this2 = this;
return React__default.createElement(
FormTranslationContext.Consumer,
null,
function (props) {
return _this2.props.children(props);
}
);
}
}]);
return FormTranslationConsumer;
}(React.Component);
var FormItemError = function (_Component) { var FormItemError = function (_Component) {
inherits(FormItemError, _Component); inherits(FormItemError, _Component);
@ -107,7 +138,7 @@ var FormItemError = function (_Component) {
} }
createClass(FormItemError, [{ createClass(FormItemError, [{
key: "render", key: 'render',
value: function render() { value: function render() {
var _this2 = this; var _this2 = this;
@ -124,12 +155,12 @@ var FormItemError = function (_Component) {
); );
} }
}, { }, {
key: "renderError", key: 'renderError',
value: function renderError(data, translator) { value: function renderError(data, translator) {
return React__default.createElement( return React__default.createElement(
"p", 'p',
{ className: "text-danger" }, { className: 'text-danger' },
translator.handleText(data.errors[this.props.name].error) translator.renderText(data.errors[this.props.name].error)
); );
} }
}]); }]);
@ -3293,37 +3324,6 @@ TextArea.defaultProps = {
onChangeValue: function onChangeValue(text) {} onChangeValue: function onChangeValue(text) {}
}; };
var FormTranslationContext = React__default.createContext({
renderText: function renderText(text) {
return text;
}
});
var FormTranslationConsumer$1 = function (_Component) {
inherits(FormTranslationConsumer, _Component);
function FormTranslationConsumer() {
classCallCheck(this, FormTranslationConsumer);
return possibleConstructorReturn(this, (FormTranslationConsumer.__proto__ || Object.getPrototypeOf(FormTranslationConsumer)).apply(this, arguments));
}
createClass(FormTranslationConsumer, [{
key: 'render',
value: function render() {
var _this2 = this;
return React__default.createElement(
FormTranslationContext.Consumer,
null,
function (props) {
return _this2.props.children(props);
}
);
}
}]);
return FormTranslationConsumer;
}(React.Component);
exports.CheckBox = CheckBox; exports.CheckBox = CheckBox;
exports.Form = Form; exports.Form = Form;
exports.Input = Input; exports.Input = Input;

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -17,6 +17,6 @@ export default class FormItemError extends Component
renderError(data, translator) renderError(data, translator)
{ {
return <p className="text-danger">{translator.handleText(data.errors[this.props.name].error)}</p> return <p className="text-danger">{translator.renderText(data.errors[this.props.name].error)}</p>
} }
} }