1 | 'use client';
|
2 |
|
3 | import * as React from 'react';
|
4 | import PropTypes from 'prop-types';
|
5 | import clsx from 'clsx';
|
6 | import composeClasses from '@mui/utils/composeClasses';
|
7 | import { styled } from "../zero-styled/index.js";
|
8 | import { useDefaultProps } from "../DefaultPropsProvider/index.js";
|
9 | import { getFormGroupUtilityClass } from "./formGroupClasses.js";
|
10 | import useFormControl from "../FormControl/useFormControl.js";
|
11 | import formControlState from "../FormControl/formControlState.js";
|
12 | import { jsx as _jsx } from "react/jsx-runtime";
|
13 | const useUtilityClasses = ownerState => {
|
14 | const {
|
15 | classes,
|
16 | row,
|
17 | error
|
18 | } = ownerState;
|
19 | const slots = {
|
20 | root: ['root', row && 'row', error && 'error']
|
21 | };
|
22 | return composeClasses(slots, getFormGroupUtilityClass, classes);
|
23 | };
|
24 | const FormGroupRoot = styled('div', {
|
25 | name: 'MuiFormGroup',
|
26 | slot: 'Root',
|
27 | overridesResolver: (props, styles) => {
|
28 | const {
|
29 | ownerState
|
30 | } = props;
|
31 | return [styles.root, ownerState.row && styles.row];
|
32 | }
|
33 | })({
|
34 | display: 'flex',
|
35 | flexDirection: 'column',
|
36 | flexWrap: 'wrap',
|
37 | variants: [{
|
38 | props: {
|
39 | row: true
|
40 | },
|
41 | style: {
|
42 | flexDirection: 'row'
|
43 | }
|
44 | }]
|
45 | });
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 | const FormGroup = React.forwardRef(function FormGroup(inProps, ref) {
|
53 | const props = useDefaultProps({
|
54 | props: inProps,
|
55 | name: 'MuiFormGroup'
|
56 | });
|
57 | const {
|
58 | className,
|
59 | row = false,
|
60 | ...other
|
61 | } = props;
|
62 | const muiFormControl = useFormControl();
|
63 | const fcs = formControlState({
|
64 | props,
|
65 | muiFormControl,
|
66 | states: ['error']
|
67 | });
|
68 | const ownerState = {
|
69 | ...props,
|
70 | row,
|
71 | error: fcs.error
|
72 | };
|
73 | const classes = useUtilityClasses(ownerState);
|
74 | return _jsx(FormGroupRoot, {
|
75 | className: clsx(classes.root, className),
|
76 | ownerState: ownerState,
|
77 | ref: ref,
|
78 | ...other
|
79 | });
|
80 | });
|
81 | process.env.NODE_ENV !== "production" ? FormGroup.propTypes = {
|
82 |
|
83 |
|
84 |
|
85 |
|
86 | |
87 |
|
88 |
|
89 | children: PropTypes.node,
|
90 | |
91 |
|
92 |
|
93 | classes: PropTypes.object,
|
94 | |
95 |
|
96 |
|
97 | className: PropTypes.string,
|
98 | |
99 |
|
100 |
|
101 |
|
102 | row: PropTypes.bool,
|
103 | |
104 |
|
105 |
|
106 | sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
107 | } : void 0;
|
108 | export default FormGroup; |
\ | No newline at end of file |