1 | 'use client';
|
2 |
|
3 | var _span;
|
4 | import * as React from 'react';
|
5 | import PropTypes from 'prop-types';
|
6 | import clsx from 'clsx';
|
7 | import composeClasses from '@mui/utils/composeClasses';
|
8 | import formControlState from "../FormControl/formControlState.js";
|
9 | import useFormControl from "../FormControl/useFormControl.js";
|
10 | import { styled } from "../zero-styled/index.js";
|
11 | import memoTheme from "../utils/memoTheme.js";
|
12 | import { useDefaultProps } from "../DefaultPropsProvider/index.js";
|
13 | import capitalize from "../utils/capitalize.js";
|
14 | import formHelperTextClasses, { getFormHelperTextUtilityClasses } from "./formHelperTextClasses.js";
|
15 | import { jsx as _jsx } from "react/jsx-runtime";
|
16 | const useUtilityClasses = ownerState => {
|
17 | const {
|
18 | classes,
|
19 | contained,
|
20 | size,
|
21 | disabled,
|
22 | error,
|
23 | filled,
|
24 | focused,
|
25 | required
|
26 | } = ownerState;
|
27 | const slots = {
|
28 | root: ['root', disabled && 'disabled', error && 'error', size && `size${capitalize(size)}`, contained && 'contained', focused && 'focused', filled && 'filled', required && 'required']
|
29 | };
|
30 | return composeClasses(slots, getFormHelperTextUtilityClasses, classes);
|
31 | };
|
32 | const FormHelperTextRoot = styled('p', {
|
33 | name: 'MuiFormHelperText',
|
34 | slot: 'Root',
|
35 | overridesResolver: (props, styles) => {
|
36 | const {
|
37 | ownerState
|
38 | } = props;
|
39 | return [styles.root, ownerState.size && styles[`size${capitalize(ownerState.size)}`], ownerState.contained && styles.contained, ownerState.filled && styles.filled];
|
40 | }
|
41 | })(memoTheme(({
|
42 | theme
|
43 | }) => ({
|
44 | color: (theme.vars || theme).palette.text.secondary,
|
45 | ...theme.typography.caption,
|
46 | textAlign: 'left',
|
47 | marginTop: 3,
|
48 | marginRight: 0,
|
49 | marginBottom: 0,
|
50 | marginLeft: 0,
|
51 | [`&.${formHelperTextClasses.disabled}`]: {
|
52 | color: (theme.vars || theme).palette.text.disabled
|
53 | },
|
54 | [`&.${formHelperTextClasses.error}`]: {
|
55 | color: (theme.vars || theme).palette.error.main
|
56 | },
|
57 | variants: [{
|
58 | props: {
|
59 | size: 'small'
|
60 | },
|
61 | style: {
|
62 | marginTop: 4
|
63 | }
|
64 | }, {
|
65 | props: ({
|
66 | ownerState
|
67 | }) => ownerState.contained,
|
68 | style: {
|
69 | marginLeft: 14,
|
70 | marginRight: 14
|
71 | }
|
72 | }]
|
73 | })));
|
74 | const FormHelperText = React.forwardRef(function FormHelperText(inProps, ref) {
|
75 | const props = useDefaultProps({
|
76 | props: inProps,
|
77 | name: 'MuiFormHelperText'
|
78 | });
|
79 | const {
|
80 | children,
|
81 | className,
|
82 | component = 'p',
|
83 | disabled,
|
84 | error,
|
85 | filled,
|
86 | focused,
|
87 | margin,
|
88 | required,
|
89 | variant,
|
90 | ...other
|
91 | } = props;
|
92 | const muiFormControl = useFormControl();
|
93 | const fcs = formControlState({
|
94 | props,
|
95 | muiFormControl,
|
96 | states: ['variant', 'size', 'disabled', 'error', 'filled', 'focused', 'required']
|
97 | });
|
98 | const ownerState = {
|
99 | ...props,
|
100 | component,
|
101 | contained: fcs.variant === 'filled' || fcs.variant === 'outlined',
|
102 | variant: fcs.variant,
|
103 | size: fcs.size,
|
104 | disabled: fcs.disabled,
|
105 | error: fcs.error,
|
106 | filled: fcs.filled,
|
107 | focused: fcs.focused,
|
108 | required: fcs.required
|
109 | };
|
110 |
|
111 |
|
112 | delete ownerState.ownerState;
|
113 | const classes = useUtilityClasses(ownerState);
|
114 | return _jsx(FormHelperTextRoot, {
|
115 | as: component,
|
116 | className: clsx(classes.root, className),
|
117 | ref: ref,
|
118 | ...other,
|
119 | ownerState: ownerState,
|
120 | children: children === ' ' ?
|
121 | _span || (_span = _jsx("span", {
|
122 | className: "notranslate",
|
123 | children: "\u200B"
|
124 | })) : children
|
125 | });
|
126 | });
|
127 | process.env.NODE_ENV !== "production" ? FormHelperText.propTypes = {
|
128 |
|
129 |
|
130 |
|
131 |
|
132 | |
133 |
|
134 |
|
135 |
|
136 |
|
137 | children: PropTypes.node,
|
138 | |
139 |
|
140 |
|
141 | classes: PropTypes.object,
|
142 | |
143 |
|
144 |
|
145 | className: PropTypes.string,
|
146 | |
147 |
|
148 |
|
149 |
|
150 | component: PropTypes.elementType,
|
151 | |
152 |
|
153 |
|
154 | disabled: PropTypes.bool,
|
155 | |
156 |
|
157 |
|
158 | error: PropTypes.bool,
|
159 | |
160 |
|
161 |
|
162 | filled: PropTypes.bool,
|
163 | |
164 |
|
165 |
|
166 | focused: PropTypes.bool,
|
167 | |
168 |
|
169 |
|
170 |
|
171 | margin: PropTypes.oneOf(['dense']),
|
172 | |
173 |
|
174 |
|
175 | required: PropTypes.bool,
|
176 | |
177 |
|
178 |
|
179 | sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
180 | |
181 |
|
182 |
|
183 | variant: PropTypes .oneOfType([PropTypes.oneOf(['filled', 'outlined', 'standard']), PropTypes.string])
|
184 | } : void 0;
|
185 | export default FormHelperText; |
\ | No newline at end of file |