UNPKG

choerodon-ui

Version:

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

106 lines (83 loc) 2.76 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 _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn"; import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf"; function _createSuper(Derived) { function isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } return function () { var Super = _getPrototypeOf(Derived), result; if (isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } 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 cloneElement(children, _objectSpread({}, props, { ref: this.saveRef }), null); } }]); return InputElement; }(Component); export { InputElement as default }; //# sourceMappingURL=InputElement.js.map