UNPKG

2.63 kBJavaScriptView Raw
1var _excluded = ["className", "cssModule", "tag", "type", "size"];
2function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
4function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
5import React from 'react';
6import PropTypes from 'prop-types';
7import classNames from 'classnames';
8import { mapToCssModules, tagPropType } from './utils';
9import Dropdown from './Dropdown';
10import { InputGroupContext } from './InputGroupContext';
11var propTypes = {
12 /** Add custom class */
13 className: PropTypes.string,
14 /** Change underlying component's CSS base class name */
15 cssModule: PropTypes.object,
16 /** Sets size of InputGroup */
17 size: PropTypes.string,
18 /** Set a custom element for this component */
19 tag: tagPropType,
20 type: PropTypes.string
21};
22function InputGroup(props) {
23 var className = props.className,
24 cssModule = props.cssModule,
25 _props$tag = props.tag,
26 Tag = _props$tag === void 0 ? 'div' : _props$tag,
27 type = props.type,
28 size = props.size,
29 attributes = _objectWithoutProperties(props, _excluded);
30 var classes = mapToCssModules(classNames(className, 'input-group', size ? "input-group-".concat(size) : null), cssModule);
31 if (props.type === 'dropdown') {
32 return /*#__PURE__*/React.createElement(Dropdown, _extends({}, attributes, {
33 className: classes
34 }));
35 }
36 return /*#__PURE__*/React.createElement(InputGroupContext.Provider, {
37 value: {
38 insideInputGroup: true
39 }
40 }, /*#__PURE__*/React.createElement(Tag, _extends({}, attributes, {
41 className: classes
42 })));
43}
44InputGroup.propTypes = propTypes;
45export default InputGroup;
\No newline at end of file