-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/custom template per field #4352
base: main
Are you sure you want to change the base?
Feat/custom template per field #4352
Conversation
/** The `registry` object */ | ||
registry: Registry<T, S, F>; | ||
}; | ||
|
||
/** The set of RJSF templates that can be overridden by themes or users */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding documentation around the change you made below, here as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what kind of documentation I should add, could you specify please ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest mentioning the ability to add per-field customizations and maybe add an example of a custom template since it is now supported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, I'm super glad this feature is finally getting into the master branch. It's almost having an one year birthday 🎂. We use this feature extensively to customize the layout of the form. I think its a very nice use case to describe in the docs, since I'm aware it's a very long desired flexibility. I could also contribute by providing the Layout template.
@lucasmcht Also, can you fix the type errors in the themes? |
…ucasmcht/react-jsonschema-form into feat/custom-template-per-field
@lucasmcht Some of your tests are failing |
Fixes #3695 (Rework of PR #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.