@aokiapp/rjsf-mantine-theme
Version:
Mantine theme, fields and widgets for react-jsonschema-form
69 lines (66 loc) • 1.85 kB
JavaScript
import { jsxs, jsx } from 'react/jsx-runtime';
import { Group, Fieldset, Box } from '@mantine/core';
import { getUiOptions, getTemplate, titleId, canExpand } from '@rjsf/utils';
import { useFieldContext } from './FieldTemplate.mjs';
function ObjectFieldTemplate(props) {
const {
disabled,
formData,
idSchema,
onAddClick,
properties,
readonly,
registry,
required,
schema,
title,
uiSchema
} = props;
const { description } = useFieldContext();
const options = getUiOptions(uiSchema);
const TitleFieldTemplate = getTemplate("TitleFieldTemplate", registry, options);
const {
ButtonTemplates: { AddButton }
} = registry.templates;
const classNames = options.classNames;
const legendNode = /* @__PURE__ */ jsxs(Group, { gap: "xs", className: "armt-template-objectfield-legend", children: [
title && /* @__PURE__ */ jsx(
TitleFieldTemplate,
{
id: titleId(idSchema),
title,
required,
schema,
uiSchema,
registry
}
),
description
] });
return /* @__PURE__ */ jsxs(
Fieldset,
{
id: idSchema.$id,
legend: legendNode,
style: {
width: "100%"
},
className: `armt-template-objectfield ${classNames ?? ""}`,
children: [
/* @__PURE__ */ jsx(Box, { className: "armt-template-objectfield-item", children: properties.map((prop) => prop.content) }),
canExpand(schema, uiSchema, formData) && /* @__PURE__ */ jsx(
AddButton,
{
className: "object-property-expand",
onClick: onAddClick(schema),
disabled: disabled || readonly,
uiSchema,
registry
}
)
]
}
);
}
export { ObjectFieldTemplate as default };
//# sourceMappingURL=ObjectFieldTemplate.mjs.map