Currently, to per-field customize the template, it is necessary to send the function/class of the component in the uiSchema, breaking the JSON nature of the uiSchema. It's not possible to provide just the registration key.
This pull request includes updates to the @rjsf/utils package to allow for per-field customization using string keys from the Registry, as well as updates to the documentation to reflect these changes. Additionally, it simplifies the types in the codebase by introducing a new RJSFBaseProps type.
Feature Enhancements
packages/utils/src/getTemplate.ts: Updated getTemplate() to allow per-field customization using string keys from the Registry.
Documentation Updates
packages/docs/docs/advanced-customization/custom-templates.md: Updated to include examples of specifying templates using both components and string values from the Registry.
Type Simplification
packages/utils/src/types.ts: Introduced RJSFBaseProps to simplify and consolidate the properties passed to various template components. This change affects multiple type definitions, including ErrorListProps, FieldErrorProps, FieldHelpProps, FieldTemplateProps, and others.
Fixes https://github.com/rjsf-team/react-jsonschema-form/issues/3695 (Rework of PR https://github.com/rjsf-team/react-jsonschema-form/pull/3881)
Reasons for making this change
Currently, to per-field customize the template, it is necessary to send the function/class of the component in the uiSchema, breaking the JSON nature of the uiSchema. It's not possible to provide just the registration key.
This pull request includes updates to the
@rjsf/utils
package to allow for per-field customization using string keys from theRegistry
, as well as updates to the documentation to reflect these changes. Additionally, it simplifies the types in the codebase by introducing a newRJSFBaseProps
type.Feature Enhancements
packages/utils/src/getTemplate.ts
: UpdatedgetTemplate()
to allow per-field customization using string keys from theRegistry
.Documentation Updates
packages/docs/docs/advanced-customization/custom-templates.md
: Updated to include examples of specifying templates using both components and string values from theRegistry
.Type Simplification
packages/utils/src/types.ts
: IntroducedRJSFBaseProps
to simplify and consolidate the properties passed to various template components. This change affects multiple type definitions, includingErrorListProps
,FieldErrorProps
,FieldHelpProps
,FieldTemplateProps
, and others.Checklist
npx nx run-many --target=build --exclude=@rjsf/docs && npm run test:update
to update snapshots, if needed.