1 | import _extends from "@babel/runtime/helpers/extends";
|
2 | import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
3 | import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
4 | import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
5 | import cx from 'classnames';
|
6 | import React from 'react';
|
7 | import { getDisplayName, isSizeLarge, isSizeSmall } from '../utils';
|
8 |
|
9 | function withClassNames(Component) {
|
10 |
|
11 |
|
12 |
|
13 | var WrappedComponent = function (_React$Component) {
|
14 | _inheritsLoose(WrappedComponent, _React$Component);
|
15 |
|
16 | function WrappedComponent() {
|
17 | return _React$Component.apply(this, arguments) || this;
|
18 | }
|
19 |
|
20 | var _proto = WrappedComponent.prototype;
|
21 |
|
22 | _proto.render = function render() {
|
23 | var _this$props = this.props,
|
24 | className = _this$props.className,
|
25 | isInvalid = _this$props.isInvalid,
|
26 | isValid = _this$props.isValid,
|
27 | size = _this$props.size,
|
28 | props = _objectWithoutPropertiesLoose(_this$props, ["className", "isInvalid", "isValid", "size"]);
|
29 |
|
30 | return React.createElement(Component, _extends({}, props, {
|
31 | className: cx('form-control', 'rbt-input', {
|
32 | 'form-control-lg': isSizeLarge(size),
|
33 | 'form-control-sm': isSizeSmall(size),
|
34 | 'is-invalid': isInvalid,
|
35 | 'is-valid': isValid
|
36 | }, className)
|
37 | }));
|
38 | };
|
39 |
|
40 | return WrappedComponent;
|
41 | }(React.Component);
|
42 |
|
43 | _defineProperty(WrappedComponent, "displayName", "withClassNames(" + getDisplayName(Component) + ")");
|
44 |
|
45 | return WrappedComponent;
|
46 | }
|
47 |
|
48 | export default withClassNames; |
\ | No newline at end of file |