eagle-ui
Version:
This is a used to develop the background management system based on the react to develop a set of UI framework
93 lines (71 loc) • 3.76 kB
JavaScript
;
exports.__esModule = true;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _ValidatorBaseJs = require('./ValidatorBase.js');
var _ValidatorBaseJs2 = _interopRequireDefault(_ValidatorBaseJs);
var _classnames = require('classnames');
var _classnames2 = _interopRequireDefault(_classnames);
var ValidatorPanel = (function (_ValidatorBase) {
_inherits(ValidatorPanel, _ValidatorBase);
function ValidatorPanel(props, context) {
_classCallCheck(this, ValidatorPanel);
_ValidatorBase.call(this, props, context);
}
//验证
ValidatorPanel.prototype.validate = function validate(element) {
var message = this.check(element) || '';
if (message !== '' && element.style.display != 'none' && !this.isUpdate) {
//错误提示
//this.elements[element.name].status=1;
this.setTipsOffset(element);
//设置错误消息
this.setState({
message: message,
show: message
});
//this.highlight(this.parent, this.options.errorClass, this.options.validClass);
if (this.props.timeout) {
clearTimeout(this.validateTimeout);
this.validateTimeout = setTimeout((function () {
this.setState({
show: ''
});
}).bind(this), this.props.timeout);
}
return false;
}
this.setState({
show: null
});
this.unhighlight(element);
this.isUpdate = false;
//this.hide();
return true;
};
ValidatorPanel.prototype.render = function render() {
var _props = this.props;
var Component = _props.componentTag;
var direction = _props.direction;
var id = _props.id;
this.removeFadeout();
return _react2['default'].createElement(
Component,
_extends({}, this.props, { ref: id ? id : this.formName, className: this.getClassName('validate') }),
this.props.children,
_react2['default'].createElement(
'div',
{ ref: 'ref-validateTips', className: _classnames2['default'](this.getClassName('validate-tips'), 'animated', '' + (direction === "bottom" || direction === "top" ? 'bottom' : ''), '' + (this.init ? "" : this.state.show ? "fadein" : "fadeout"), 'absolute') },
_react2['default'].createElement('i', null),
this.state.message
)
);
};
return ValidatorPanel;
})(_ValidatorBaseJs2['default']);
exports['default'] = ValidatorPanel;
module.exports = exports['default'];