@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.15 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 UpPhone = (function (_super) {
tslib_1.__extends(UpPhone, _super);
function UpPhone(p, c) {
var _this = _super.call(this, p, c) || this;
_this.phoneHandleChangeEvent = 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(UpPhone.prototype, "isControlled", {
get: function () {
return this.props.value !== undefined;
},
enumerable: true,
configurable: true
});
Object.defineProperty(UpPhone.prototype, "currentValue", {
get: function () {
return this.isControlled ? this.props.value : this.state.value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(UpPhone.prototype, "currentError", {
get: function () {
return this.isControlled ? this.props.error : this.state.error;
},
enumerable: true,
configurable: true
});
UpPhone.prototype.render = function () {
return (React.createElement(Input_1.default, tslib_1.__assign({}, this.props, { iconName: "phone", value: this.currentValue, onChange: this.phoneHandleChangeEvent, error: this.currentError, hasError: !_.isEmpty(this.currentError), tabIndex: this.props.tabIndex })));
};
UpPhone.defaultProps = {
showError: true,
defaultValue: "",
validation: [{
pattern: /^(0|\+33)[1-9]([-. ]*[0-9]{2}){4}$/,
errorMessage: "Le champ doit être un numéro de téléphone"
}]
};
return UpPhone;
}(React.Component));
exports.default = UpPhone;
;
//# sourceMappingURL=UpPhone.js.map