UNPKG

@rjsf/core

Version:

A simple React component capable of building HTML forms out of a JSON schema.

24 lines (23 loc) 1.31 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { getTemplate, getUiOptions, titleId, } from '@rjsf/utils'; /** The `LayoutHeaderField` component renders a `TitleFieldTemplate` with an `id` derived from the `fieldPathId` * and whether it is `required` from the props. The `title` is derived from the props as follows: * - If there is a title in the `uiSchema`, it is displayed * - Else, if there is an explicit `title` passed in the props, it is displayed * - Otherwise, if there is a title in the `schema`, it is displayed * - Finally, the `name` prop is displayed as the title * * @param props - The `LayoutHeaderField` for the component */ export default function LayoutHeaderField(props) { const { fieldPathId, title, schema, uiSchema, required, registry, name } = props; const options = getUiOptions(uiSchema, registry.globalUiOptions); const { title: uiTitle } = options; const { title: schemaTitle } = schema; const fieldTitle = uiTitle || title || schemaTitle || name; if (!fieldTitle) { return null; } const TitleFieldTemplate = getTemplate('TitleFieldTemplate', registry, options); return (_jsx(TitleFieldTemplate, { id: titleId(fieldPathId), title: fieldTitle, required: required, schema: schema, uiSchema: uiSchema, registry: registry })); }