chore(ui): consolidates field label, error, and description components

This commit is contained in:
Jacob Fletcher
2024-03-21 11:23:51 -04:00
parent 85ffc5d8bf
commit 64d6163f13
30 changed files with 124 additions and 87 deletions

View File

@@ -10,8 +10,9 @@ import { useFieldProps } from '../FieldPropsProvider/index.js'
import { useForm } from '../Form/context.js'
import './index.scss'
export const FieldLabel: React.FC<LabelProps> = (props) => {
const DefaultFieldLabel: React.FC<LabelProps> = (props) => {
const { htmlFor: htmlForFromProps, label: labelFromProps, required = false } = props
const { uuid } = useForm()
const { path } = useFieldProps()
const htmlFor = htmlForFromProps || generateFieldID(path, uuid)
@@ -29,3 +30,13 @@ export const FieldLabel: React.FC<LabelProps> = (props) => {
return null
}
export const FieldLabel: React.FC<LabelProps> = (props) => {
const { CustomLabel } = props
if (CustomLabel !== undefined) {
return CustomLabel
}
return <DefaultFieldLabel {...props} />
}