UNPKG

2.13 kBJavaScriptView Raw
1import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2import _extends from "@babel/runtime/helpers/esm/extends";
3var _excluded = ["bsPrefix", "size", "hasValidation", "className", "as"];
4import classNames from 'classnames';
5import React from 'react';
6import createWithBsPrefix from './createWithBsPrefix';
7import { useBootstrapPrefix } from './ThemeProvider';
8var InputGroupAppend = createWithBsPrefix('input-group-append');
9var InputGroupPrepend = createWithBsPrefix('input-group-prepend');
10var InputGroupText = createWithBsPrefix('input-group-text', {
11 Component: 'span'
12});
13
14var InputGroupCheckbox = function InputGroupCheckbox(props) {
15 return /*#__PURE__*/React.createElement(InputGroupText, null, /*#__PURE__*/React.createElement("input", _extends({
16 type: "checkbox"
17 }, props)));
18};
19
20var InputGroupRadio = function InputGroupRadio(props) {
21 return /*#__PURE__*/React.createElement(InputGroupText, null, /*#__PURE__*/React.createElement("input", _extends({
22 type: "radio"
23 }, props)));
24};
25
26/**
27 *
28 * @property {InputGroupAppend} Append
29 * @property {InputGroupPrepend} Prepend
30 * @property {InputGroupText} Text
31 * @property {InputGroupRadio} Radio
32 * @property {InputGroupCheckbox} Checkbox
33 */
34var InputGroup = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
35 var bsPrefix = _ref.bsPrefix,
36 size = _ref.size,
37 hasValidation = _ref.hasValidation,
38 className = _ref.className,
39 _ref$as = _ref.as,
40 Component = _ref$as === void 0 ? 'div' : _ref$as,
41 props = _objectWithoutPropertiesLoose(_ref, _excluded);
42
43 bsPrefix = useBootstrapPrefix(bsPrefix, 'input-group');
44 return /*#__PURE__*/React.createElement(Component, _extends({
45 ref: ref
46 }, props, {
47 className: classNames(className, bsPrefix, size && bsPrefix + "-" + size, hasValidation && 'has-validation')
48 }));
49});
50InputGroup.displayName = 'InputGroup';
51InputGroup.Text = InputGroupText;
52InputGroup.Radio = InputGroupRadio;
53InputGroup.Checkbox = InputGroupCheckbox;
54InputGroup.Append = InputGroupAppend;
55InputGroup.Prepend = InputGroupPrepend;
56export default InputGroup;
\No newline at end of file