UNPKG

1.7 kBJavaScriptView Raw
1import classNames from 'classnames';
2import PropTypes from 'prop-types';
3import * as React from 'react';
4import FormCheck from './FormCheck';
5import FormControl from './FormControl';
6import FormFloating from './FormFloating';
7import FormGroup from './FormGroup';
8import FormLabel from './FormLabel';
9import FormRange from './FormRange';
10import FormSelect from './FormSelect';
11import FormText from './FormText';
12import Switch from './Switch';
13import FloatingLabel from './FloatingLabel';
14import { jsx as _jsx } from "react/jsx-runtime";
15const propTypes = {
16 /**
17 * The Form `ref` will be forwarded to the underlying element,
18 * which means, unless it's rendered `as` a composite component,
19 * it will be a DOM node, when resolved.
20 *
21 * @type {ReactRef}
22 * @alias ref
23 */
24 _ref: PropTypes.any,
25 /**
26 * Mark a form as having been validated. Setting it to `true` will
27 * toggle any validation styles on the forms elements.
28 */
29 validated: PropTypes.bool,
30 as: PropTypes.elementType
31};
32const Form = /*#__PURE__*/React.forwardRef(({
33 className,
34 validated,
35 // Need to define the default "as" during prop destructuring to be compatible with styled-components github.com/react-bootstrap/react-bootstrap/issues/3595
36 as: Component = 'form',
37 ...props
38}, ref) => /*#__PURE__*/_jsx(Component, {
39 ...props,
40 ref: ref,
41 className: classNames(className, validated && 'was-validated')
42}));
43Form.displayName = 'Form';
44Form.propTypes = propTypes;
45export default Object.assign(Form, {
46 Group: FormGroup,
47 Control: FormControl,
48 Floating: FormFloating,
49 Check: FormCheck,
50 Switch,
51 Label: FormLabel,
52 Text: FormText,
53 Range: FormRange,
54 Select: FormSelect,
55 FloatingLabel
56});
\No newline at end of file