UNPKG

@rjsf/utils

Version:
19 lines 1.05 kB
/** Returns the template with the given `name` from either the `uiSchema` if it is defined or from the `registry` * otherwise. NOTE, since `ButtonTemplates` are not overridden in `uiSchema` only those in the `registry` are returned. * * @param name - The name of the template to fetch, restricted to the keys of `TemplatesType` * @param registry - The `Registry` from which to read the template * @param [uiOptions={}] - The `UIOptionsType` from which to read an alternate template * @returns - The template from either the `uiSchema` or `registry` for the `name` */ export default function getTemplate(name, registry, uiOptions = {}) { const { templates } = registry; if (name === 'ButtonTemplates') { return templates[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 uiOptions[name] || templates[name]); } //# sourceMappingURL=getTemplate.js.map