@arche-mc2/arche-controls
Version:
We know that there are a ton of react UI library projects to choose from. Our hope with this one is to provide the next generation of react components that you can use to bootstrap your next project, or as a reference for building a UIKit. Read on to get
57 lines • 2.22 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var React = require("react");
var Input_1 = require("../Input");
var _ = require("lodash");
var UpEmail = (function (_super) {
tslib_1.__extends(UpEmail, _super);
function UpEmail(p, c) {
var _this = _super.call(this, p, c) || this;
_this.emailHandleChangeEvent = function (event, value, error) {
_this.setState({ value: value, error: error }, function () {
if (_this.props.onChange) {
_this.props.onChange(event, value, error);
}
});
};
_this.state = {};
return _this;
}
Object.defineProperty(UpEmail.prototype, "isControlled", {
get: function () {
return this.props.value !== undefined;
},
enumerable: true,
configurable: true
});
Object.defineProperty(UpEmail.prototype, "currentValue", {
get: function () {
return this.isControlled ? this.props.value : this.state.value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(UpEmail.prototype, "currentError", {
get: function () {
return this.isControlled ? this.props.error : this.state.error;
},
enumerable: true,
configurable: true
});
UpEmail.prototype.render = function () {
return (React.createElement(Input_1.default, tslib_1.__assign({}, this.props, { iconName: "mail", value: this.currentValue, onChange: this.emailHandleChangeEvent, error: this.currentError, hasError: !_.isEmpty(this.currentError) })));
};
UpEmail.defaultProps = {
showError: true,
defaultValue: '',
validation: [{
pattern: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
errorMessage: "Le champ doit être un courriel"
}]
};
return UpEmail;
}(React.Component));
exports.default = UpEmail;
;
//# sourceMappingURL=UpEmail.js.map