UNPKG

react-bootstrap-typeahead-portal

Version:
63 lines (49 loc) 2.94 kB
import _extends from "@babel/runtime/helpers/extends"; import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; import _createClass from "@babel/runtime/helpers/createClass"; import _inherits from "@babel/runtime/helpers/inherits"; import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn"; import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf"; import _defineProperty from "@babel/runtime/helpers/defineProperty"; var _excluded = ["className", "isInvalid", "isValid", "size"]; function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } import cx from 'classnames'; import React from 'react'; import { getDisplayName, isSizeLarge, isSizeSmall } from '../utils'; function withClassNames(Component) { // Use a class instead of function component to support refs. /* eslint-disable-next-line react/prefer-stateless-function */ var WrappedComponent = /*#__PURE__*/function (_React$Component) { _inherits(WrappedComponent, _React$Component); var _super = _createSuper(WrappedComponent); function WrappedComponent() { _classCallCheck(this, WrappedComponent); return _super.apply(this, arguments); } _createClass(WrappedComponent, [{ key: "render", value: function render() { var _this$props = this.props, className = _this$props.className, isInvalid = _this$props.isInvalid, isValid = _this$props.isValid, size = _this$props.size, props = _objectWithoutProperties(_this$props, _excluded); return /*#__PURE__*/React.createElement(Component, _extends({}, props, { className: cx('form-control', 'rbt-input', { 'form-control-lg': isSizeLarge(size), 'form-control-sm': isSizeSmall(size), 'is-invalid': isInvalid, 'is-valid': isValid }, className) })); } }]); return WrappedComponent; }(React.Component); _defineProperty(WrappedComponent, "displayName", "withClassNames(".concat(getDisplayName(Component), ")")); return WrappedComponent; } export default withClassNames;