Skip to content

Commit 4f8b330

Browse files
committed
add chakra Fieldset to FieldTemplate
1 parent 4e6990b commit 4f8b330

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

packages/chakra-ui/src/FieldTemplate/FieldTemplate.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Fieldset, Text } from '@chakra-ui/react';
12
import {
23
FieldTemplateProps,
34
FormContextType,
@@ -18,13 +19,19 @@ export default function FieldTemplate<
1819
classNames,
1920
style,
2021
disabled,
22+
displayLabel,
2123
hidden,
2224
label,
2325
onDropPropertyClick,
2426
onKeyChange,
2527
readonly,
2628
registry,
2729
required,
30+
rawErrors = [],
31+
errors,
32+
help,
33+
description,
34+
rawDescription,
2835
schema,
2936
uiSchema,
3037
} = props;
@@ -54,7 +61,12 @@ export default function FieldTemplate<
5461
uiSchema={uiSchema}
5562
registry={registry}
5663
>
57-
{children}
64+
<Fieldset.Root disabled={disabled} invalid={rawErrors && rawErrors.length > 0}>
65+
{displayLabel && rawDescription ? <Fieldset.Legend mt={2}>{description}</Fieldset.Legend> : null}
66+
{help && <Text>{help}</Text>}
67+
<Fieldset.Content>{children}</Fieldset.Content>
68+
{errors && <Fieldset.ErrorText>{errors}</Fieldset.ErrorText>}
69+
</Fieldset.Root>
5870
</WrapIfAdditionalTemplate>
5971
);
6072
}

0 commit comments

Comments
 (0)