ming-demo3
Version:
mdf metaui web
148 lines (122 loc) • 5.27 kB
JavaScript
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _extends3 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _react = _interopRequireWildcard(require("react"));
var _antd = require("antd");
var FormInputControl = function (_Component) {
(0, _inherits2["default"])(FormInputControl, _Component);
function FormInputControl(props) {
var _this;
(0, _classCallCheck2["default"])(this, FormInputControl);
_this = (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(FormInputControl).call(this, props));
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChange", function (e) {
if (_this.props.onChange) {
_this.props.onChange(e.target.value);
}
});
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChange2", function (e) {
if (_this.props.onChange) {
_this.props.onChange(e.target.value);
}
});
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onFocus", function (e) {
_this.setSelectionRange();
});
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onBlur", function (e) {
if (_this.props.onBlur) {
_this.props.onBlur(e.target.value);
}
});
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onClick", function (e) {
_this.props.onClick && _this.props.onClick(e);
});
_this.onChange = _this.onChange.bind((0, _assertThisInitialized2["default"])(_this));
_this.onChange2 = _this.onChange2.bind((0, _assertThisInitialized2["default"])(_this));
_this.onFocus = _this.onFocus.bind((0, _assertThisInitialized2["default"])(_this));
_this.onBlur = _this.onBlur.bind((0, _assertThisInitialized2["default"])(_this));
_this.onClick = _this.onClick.bind((0, _assertThisInitialized2["default"])(_this));
return _this;
}
(0, _createClass2["default"])(FormInputControl, [{
key: "componentDidMount",
value: function componentDidMount() {
if (this.props.focus) {
this.focus();
this.setSelectionRange();
}
}
}, {
key: "componentDidUpdate",
value: function componentDidUpdate(prevProps, prevState) {
if (this.props.focus) {
console.error('=============================FormInputControls.componentDidUpdate', prevProps == this.props, prevProps, this.props);
this.focus();
}
}
}, {
key: "focus",
value: function focus() {
var _self = this;
if (_self._input) {
if (_self._input) {
_self._input.focus();
} else {
debugger;
}
}
}
}, {
key: "setSelectionRange",
value: function setSelectionRange() {
var _self = this;
if (_self._input) {
if (_self._input) {
_self._input.setSelectionRange(0, this._input.value.length);
} else {
debugger;
}
}
}
}, {
key: "render",
value: function render() {
var _this2 = this,
_extends2;
var classNames = 'u-form-control ant-input multi-lang';
if (this.props.className) {
classNames += ' ' + this.props.className;
}
var inputProps = {};
for (var propKey in this.props) {
if (['onChange', 'onBlur', 'onClick'].indexOf(propKey) > -1) {
continue;
}
inputProps[propKey] = this.props[propKey];
}
console.error('this.props and inputProps:', this.props, inputProps);
return _react["default"].createElement("input", (0, _extends3["default"])({}, inputProps, (_extends2 = {
ref: function ref(input) {
_this2._input = input;
},
className: classNames,
onChange: this.onChange
}, (0, _defineProperty2["default"])(_extends2, "onChange", this.onChange2), (0, _defineProperty2["default"])(_extends2, "onFocus", this.onFocus), (0, _defineProperty2["default"])(_extends2, "onBlur", this.onBlur), (0, _defineProperty2["default"])(_extends2, "onClick", this.onClick), _extends2)));
}
}]);
return FormInputControl;
}(_react.Component);
var _default = FormInputControl;
exports["default"] = _default;
//# sourceMappingURL=FormInputControl.js.map
;