Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ should change the heading of the (upcoming) version to include a major version b

- Added documentation for the new `MultiSchemaFieldTemplate`

## @rjsf/chakra-ui
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you consolidate this with the new @rjsf/chakra-ui above. Also, since we just created a new MultiSchemaFieldTemplate for chakra-ui, can you take a look at that and see if you wanted to improve its UI.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, done


- Improve visual styling of error validation boxes
- Update `chakra-ui/react` package to `^3.19.1`

# 6.0.0-beta.10

## @rjsf/mui
Expand Down
1,196 changes: 560 additions & 636 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions packages/chakra-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,11 @@
],
"license": "Apache-2.0",
"devDependencies": {
"@chakra-ui/cli": "^3.16.1",
"@chakra-ui/react": "^3.16.1",
"@chakra-ui/cli": "^3.19.1",
"@chakra-ui/react": "^3.19.1",
"@emotion/eslint-plugin": "^11.12.0",
"@emotion/jest": "^11.13.0",
"@emotion/react": "^11.14.0",
"@emotion/styled": "^11.14.0",
"@rjsf/core": "^6.0.0-beta.10",
"@rjsf/snapshot-tests": "^6.0.0-beta.10",
"@rjsf/utils": "^6.0.0-beta.10",
Expand Down
20 changes: 4 additions & 16 deletions packages/chakra-ui/src/ErrorList/ErrorList.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ErrorListProps, FormContextType, RJSFSchema, StrictRJSFSchema, TranslatableString } from '@rjsf/utils';
import { ListIndicator, ListItem, ListRoot } from '@chakra-ui/react';
import { TriangleAlert } from 'lucide-react';
import { ListItem, ListRoot } from '@chakra-ui/react';

import { Alert } from '../components/ui/alert';

Expand All @@ -10,21 +9,10 @@ export default function ErrorList<T = any, S extends StrictRJSFSchema = RJSFSche
}: ErrorListProps<T, S, F>) {
const { translateString } = registry;
return (
<Alert
flexDirection='column'
alignItems='flex-start'
gap={3}
status='error'
title={translateString(TranslatableString.ErrorsLabel)}
>
<ListRoot>
<Alert status='error' title={translateString(TranslatableString.ErrorsLabel)} mb={3}>
<ListRoot listStylePosition='inside'>
{errors.map((error, i) => (
<ListItem key={i}>
<ListIndicator asChild color='red.500'>
<TriangleAlert />
</ListIndicator>
{error.stack}
</ListItem>
<ListItem key={i}>{error.stack}</ListItem>
))}
</ListRoot>
</Alert>
Expand Down
20 changes: 8 additions & 12 deletions packages/chakra-ui/src/FieldErrorTemplate/FieldErrorTemplate.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { errorId, FieldErrorProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
import { ListItem, ListRoot, Text } from '@chakra-ui/react';
import { Fieldset } from '@chakra-ui/react';

/** The `FieldErrorTemplate` component renders the errors local to the particular field
*
Expand All @@ -16,15 +16,11 @@ export default function FieldErrorTemplate<
}
const id = errorId<T>(idSchema);

return (
<ListRoot>
{errors.map((error, i: number) => {
return (
<ListItem key={i}>
<Text id={id}>{error}</Text>
</ListItem>
);
})}
</ListRoot>
);
return errors.map((error, i: number) => {
return (
<Fieldset.ErrorText mt={0} key={i} id={id}>
{error}
</Fieldset.ErrorText>
);
});
}
2 changes: 1 addition & 1 deletion packages/chakra-ui/src/FieldTemplate/FieldTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default function FieldTemplate<
{displayLabel && rawDescription ? <Fieldset.Legend mt={2}>{description}</Fieldset.Legend> : null}
{help}
<Fieldset.Content>{children}</Fieldset.Content>
{errors && <Fieldset.ErrorText>{errors}</Fieldset.ErrorText>}
{errors}
</Fieldset.Root>
</WrapIfAdditionalTemplate>
);
Expand Down
8 changes: 3 additions & 5 deletions packages/chakra-ui/src/components/ui/alert.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { forwardRef, ReactElement, ReactNode } from 'react';
import { forwardRef, ReactNode } from 'react';
import { Alert as ChakraAlert } from '@chakra-ui/react';

import { CloseButton } from './close-button';
Expand All @@ -10,7 +10,6 @@ import { CloseButton } from './close-button';
* @param {ReactNode} [props.startElement] - The element to display at the start of the alert.
* @param {ReactNode} [props.endElement] - The element to display at the end of the alert.
* @param {ReactNode} [props.title] - The title of the alert.
* @param {ReactElement} [props.icon] - The icon to display in the alert.
* @param {boolean} [props.closable] - Whether to show the close button.
* @param {function} [props.onClose] - The function to call when the close button is clicked.
*
Expand All @@ -20,16 +19,15 @@ export interface AlertProps extends Omit<ChakraAlert.RootProps, 'title'> {
startElement?: ReactNode;
endElement?: ReactNode;
title?: ReactNode;
icon?: ReactElement;
closable?: boolean;
onClose?: () => void;
}

export const Alert = forwardRef<HTMLDivElement, AlertProps>(function Alert(props, ref) {
const { title, children, icon, closable, onClose, startElement, endElement, ...rest } = props;
const { title, children, closable, onClose, startElement, endElement, ...rest } = props;
return (
<ChakraAlert.Root ref={ref} {...rest}>
{startElement || <ChakraAlert.Indicator>{icon}</ChakraAlert.Indicator>}
{startElement || <ChakraAlert.Indicator />}
{children ? (
<ChakraAlert.Content>
<ChakraAlert.Title>{title}</ChakraAlert.Title>
Expand Down
Loading