add className to list of class names instead of turning off default classes, add hideErrorText prop to hide errors for thresholds

This commit is contained in:
Alex Holliday committed 2024-11-21 12:15:12 +08:00
1 parent 27f651b828
commit a3adb80a6e
1 file changed
+7 -5
+7 -5
View File
@@ -46,7 +46,8 @@ const Field = forwardRef(
error, error,
disabled, disabled,
hidden, hidden,
className className,
hideErrorText = false,
}, },
ref ref
) => { ) => {
@@ -57,7 +58,7 @@ const Field = forwardRef(
return ( return (
<Stack <Stack
gap={theme.spacing(2)} gap={theme.spacing(2)}
className={`${className ?? `field field-${type}`}`} className={`${className} field field-${type}`}
sx={{ sx={{
"& fieldset": { "& fieldset": {
borderColor: theme.palette.border.dark, borderColor: theme.palette.border.dark,
@@ -186,11 +187,11 @@ const Field = forwardRef(
), ),
}} }}
/> />
{ error && ( {error && (
<Typography <Typography
component="span" component="span"
className="input-error" className="input-error"
hidden={className? true: false} hidden={hideErrorText}
color={theme.palette.error.main} color={theme.palette.error.main}
mt={theme.spacing(2)} mt={theme.spacing(2)}
sx={{ sx={{
@@ -225,7 +226,8 @@ Field.propTypes = {
error: PropTypes.string, error: PropTypes.string,
disabled: PropTypes.bool, disabled: PropTypes.bool,
hidden: PropTypes.bool, hidden: PropTypes.bool,
className: PropTypes.string className: PropTypes.string,
showErrorText: PropTypes.bool,
}; };
export default Field; export default Field;