Standarzing the TextWidget widget

This commit is contained in:
2025-04-21 15:37:18 +02:00
parent 6c480a4971
commit 3005c94010

View File

@@ -1,4 +1,5 @@
import React from "react";
import { getDefaultRegistry } from "@rjsf/core";
import { FormContextType, getTemplate, RJSFSchema, WidgetProps } from "@rjsf/utils";
import Typography from "@mui/material/Typography";
@@ -11,15 +12,14 @@ export default function CrudTextWidget<T = any, S extends CrudTextRJSFSchema = C
props: WidgetProps<T, S, F>
) {
const { schema } = props;
if (schema.hasOwnProperty("foreign_key")) {
if (schema.hasOwnProperty("foreignKey")) {
return <ForeignKeyWidget {...props} />;
} else if (schema.hasOwnProperty("const")) {
return <Typography >{schema.const as string}</Typography>;
} else if (schema.props?.hasOwnProperty("richtext")) {
return <RichtextWidget {...props} />;
} else {
const { options, registry } = props;
const BaseInputTemplate = getTemplate<'BaseInputTemplate', T, S, F>('BaseInputTemplate', registry, options);
return <BaseInputTemplate {...props} />;
const { widgets: { TextWidget } } = getDefaultRegistry<T,S,F>();
return <TextWidget {...props} />;
}
}