Skip to content

Commit

Permalink
feat(templates): Allow customization per-field by using string key fr…
Browse files Browse the repository at this point in the history
…om registry

Fixes rjsf-team#3695
  • Loading branch information
nagaozen authored Sep 26, 2023
1 parent 1576c27 commit 0f70152
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/utils/src/getTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export default function getTemplate<
if (name === 'ButtonTemplates') {
return templates[name];
}
// Allow templates to be customized per-field by using string keys from the registry
if (Object.hasOwn(uiOptions, name) && Object.hasOwn(templates, uiOptions[name])) {
return templates[uiOptions[name]]
}
return (
// Evaluating uiOptions[name] results in TS2590: Expression produces a union type that is too complex to represent
// To avoid that, we cast uiOptions to `any` before accessing the name field
Expand Down

0 comments on commit 0f70152

Please sign in to comment.