Skip to content

Commit

Permalink
viewComponent prop
Browse files Browse the repository at this point in the history
  • Loading branch information
PawelSuwinski committed Feb 15, 2024
1 parent d9ede40 commit 87e7bd5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/CreateGuesser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export const IntrospectedCreateGuesser = ({
warnWhenUnsavedChanges,
sanitizeEmptyValues = true,
formComponent,
viewComponent,
children,
...props
}: IntrospectedCreateGuesserProps) => {
Expand Down Expand Up @@ -162,7 +163,7 @@ export const IntrospectedCreateGuesser = ({
const FormType = hasFormTab ? TabbedForm : SimpleForm;

return (
<Create resource={resource} {...props}>
<Create resource={resource} component={viewComponent} {...props}>
<FormType
onSubmit={save}
mode={mode}
Expand Down
2 changes: 2 additions & 0 deletions src/EditGuesser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const IntrospectedEditGuesser = ({
toolbar,
warnWhenUnsavedChanges,
formComponent,
viewComponent,
sanitizeEmptyValues = true,
children,
...props
Expand Down Expand Up @@ -197,6 +198,7 @@ export const IntrospectedEditGuesser = ({
id={id}
mutationMode={mutationMode}
redirect={redirectTo}
component={viewComponent}
transform={(data: Partial<RaRecord>) => ({
...data,
extraInformation: { hasFileField },
Expand Down
3 changes: 2 additions & 1 deletion src/ShowGuesser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const IntrospectedShowGuesser = ({
writableFields,
schema,
schemaAnalyzer,
viewComponent,
children,
...props
}: IntrospectedShowGuesserProps) => {
Expand All @@ -70,7 +71,7 @@ export const IntrospectedShowGuesser = ({
const ShowLayout = hasTab ? TabbedShowLayout : SimpleShowLayout;

return (
<Show {...props}>
<Show component={viewComponent} {...props}>
<ShowLayout>{fieldChildren}</ShowLayout>
</Show>
);
Expand Down
9 changes: 6 additions & 3 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ type CreateFormProps = Omit<
CreateProps & SimpleFormProps & TabbedFormProps,
'children'
> &
Partial<PickRename<CreateProps, 'component', 'viewComponent'>> &
Partial<
PickRename<SimpleFormProps & TabbedFormProps, 'component', 'formComponent'>
> & {
Expand All @@ -388,6 +389,7 @@ type EditFormProps = Omit<
EditProps & SimpleFormProps & TabbedFormProps,
'children'
> &
Partial<PickRename<EditProps, 'component', 'viewComponent'>> &
Partial<
PickRename<SimpleFormProps & TabbedFormProps, 'component', 'formComponent'>
> & {
Expand Down Expand Up @@ -421,9 +423,10 @@ export type ListGuesserProps = Omit<
type ShowFormProps = Omit<
ShowProps & SimpleFormProps & TabbedFormProps,
'children'
> & {
children?: ReactNode;
};
> &
Partial<PickRename<ShowProps, 'component', 'viewComponent'>> & {
children?: ReactNode;
};

export type IntrospectedShowGuesserProps = ShowFormProps &
IntrospectedGuesserProps;
Expand Down

0 comments on commit 87e7bd5

Please sign in to comment.