UNPKG

choerodon-ui

Version:

An enterprise-class UI design language and React-based implementation

72 lines (56 loc) 1.92 kB
import _objectSpread from "@babel/runtime/helpers/objectSpread2"; import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; import _createClass from "@babel/runtime/helpers/createClass"; import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized"; import _inherits from "@babel/runtime/helpers/inherits"; import _createSuper from "@babel/runtime/helpers/createSuper"; import { cloneElement, Component } from 'react'; import { findDOMNode } from 'react-dom'; var InputElement = /*#__PURE__*/function (_Component) { _inherits(InputElement, _Component); var _super = _createSuper(InputElement); function InputElement() { var _this; _classCallCheck(this, InputElement); _this = _super.apply(this, arguments); _this.focus = function () { var _assertThisInitialize = _assertThisInitialized(_this), ele = _assertThisInitialize.ele; if (typeof ele.focus === 'function') { ele.focus(); } else { findDOMNode(ele).focus(); } }; _this.blur = function () { var _assertThisInitialize2 = _assertThisInitialized(_this), ele = _assertThisInitialize2.ele; if (typeof ele.blur === 'function') { ele.blur(); } else { findDOMNode(ele).blur(); } }; _this.saveRef = function (ele) { _this.ele = ele; var ref = _this.props.children.ref; if (typeof ref === 'function') { ref(ele); } }; return _this; } _createClass(InputElement, [{ key: "render", value: function render() { var props = this.props, children = this.props.children; return /*#__PURE__*/cloneElement(children, _objectSpread(_objectSpread({}, props), {}, { ref: this.saveRef }), null); } }]); return InputElement; }(Component); export { InputElement as default }; //# sourceMappingURL=InputElement.js.map