-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
iberdinsky-skilld
committed
Sep 10, 2024
1 parent
43fc351
commit a0da214
Showing
22 changed files
with
388 additions
and
337 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
// This is override of | ||
// https://github.com/rjsf-team/react-jsonschema-form/blob/main/packages/mui/src/ObjectFieldTemplate/ObjectFieldTemplate.tsx | ||
|
||
import Grid from '@mui/material/Grid'; | ||
|
||
import { | ||
FormContextType, | ||
ObjectFieldTemplateProps, | ||
RJSFSchema, | ||
StrictRJSFSchema, | ||
canExpand, | ||
descriptionId, | ||
getTemplate, | ||
getUiOptions, | ||
titleId, | ||
} from '@rjsf/utils'; | ||
|
||
export default function CustomObjectFieldTemplate< | ||
T = any, | ||
S extends StrictRJSFSchema = RJSFSchema, | ||
F extends FormContextType = any | ||
>(props: ObjectFieldTemplateProps<T, S, F>) { | ||
const { | ||
description, | ||
title, | ||
properties, | ||
required, | ||
disabled, | ||
readonly, | ||
uiSchema, | ||
idSchema, | ||
schema, | ||
formData, | ||
onAddClick, | ||
registry, | ||
} = props; | ||
const uiOptions = getUiOptions<T, S, F>(uiSchema); | ||
const TitleFieldTemplate = getTemplate<'TitleFieldTemplate', T, S, F>('TitleFieldTemplate', registry, uiOptions); | ||
const DescriptionFieldTemplate = getTemplate<'DescriptionFieldTemplate', T, S, F>( | ||
'DescriptionFieldTemplate', | ||
registry, | ||
uiOptions | ||
); | ||
// Button templates are not overridden in the uiSchema | ||
const { | ||
ButtonTemplates: { AddButton }, | ||
} = registry.templates; | ||
|
||
|
||
|
||
|
||
if (uiOptions.CustomObjectTemplate === 'domains') { | ||
// return (<>eee</>) | ||
} | ||
|
||
return ( | ||
<> | ||
{title && ( | ||
<TitleFieldTemplate | ||
id={titleId<T>(idSchema)} | ||
title={title} | ||
required={required} | ||
schema={schema} | ||
uiSchema={uiSchema} | ||
registry={registry} | ||
/> | ||
)} | ||
{description && ( | ||
<DescriptionFieldTemplate | ||
id={descriptionId<T>(idSchema)} | ||
description={description} | ||
schema={schema} | ||
uiSchema={uiSchema} | ||
registry={registry} | ||
/> | ||
)} | ||
<Grid container={true} spacing={2} style={{ marginTop: '10px' }}> | ||
{properties.map((element, index) => | ||
// Remove the <Grid> if the inner element is hidden as the <Grid> | ||
// itself would otherwise still take up space. | ||
element.hidden ? ( | ||
element.content | ||
) : ( | ||
<Grid item={true} xs={12} key={index} style={{ marginBottom: '10px' }}> | ||
test | ||
{element.content} | ||
</Grid> | ||
) | ||
)} | ||
{canExpand<T, S, F>(schema, uiSchema, formData) && ( | ||
<Grid container justifyContent='flex-end'> | ||
<Grid item={true}> | ||
<AddButton | ||
className='object-property-expand' | ||
onClick={onAddClick(schema)} | ||
disabled={disabled || readonly} | ||
uiSchema={uiSchema} | ||
registry={registry} | ||
/> | ||
</Grid> | ||
</Grid> | ||
)} | ||
</Grid> | ||
</> | ||
); | ||
} |
Oops, something went wrong.