UNPKG

@rjsf/semantic-ui

Version:

Semantic UI theme, fields and widgets for react-jsonschema-form

23 lines 2.03 kB
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime"; import { Grid } from 'semantic-ui-react'; import { canExpand, descriptionId, getTemplate, getUiOptions, titleId, } from '@rjsf/utils'; /** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the * title and description if available. If the object is expandable, then an `AddButton` is also rendered after all * the properties. * * @param props - The `ObjectFieldTemplateProps` for this component */ export default function ObjectFieldTemplate(props) { const { description, onAddClick, title, properties, disabled, readonly, required, uiSchema, schema, formData, idSchema, registry, } = props; const uiOptions = getUiOptions(uiSchema); const TitleFieldTemplate = getTemplate('TitleFieldTemplate', registry, uiOptions); const DescriptionFieldTemplate = getTemplate('DescriptionFieldTemplate', registry, uiOptions); // Button templates are not overridden in the uiSchema const { ButtonTemplates: { AddButton }, } = registry.templates; return (_jsxs(_Fragment, { children: [title && (_jsx(TitleFieldTemplate, { id: titleId(idSchema), title: title, required: required, schema: schema, uiSchema: uiSchema, registry: registry })), description && (_jsx(DescriptionFieldTemplate, { id: descriptionId(idSchema), description: description, schema: schema, uiSchema: uiSchema, registry: registry })), properties.map((prop) => prop.content), canExpand(schema, uiSchema, formData) && (_jsx(Grid.Column, { width: 16, verticalAlign: 'middle', children: _jsx(Grid.Row, { children: _jsx("div", { style: { marginTop: '1rem', position: 'relative', textAlign: 'right', }, children: _jsx(AddButton, { onClick: onAddClick(schema), disabled: disabled || readonly, uiSchema: uiSchema, registry: registry }) }) }) }))] })); } //# sourceMappingURL=ObjectFieldTemplate.js.map