@undermuz/react-json-form
Version:
Generate JSON-based forms with react
32 lines (31 loc) • 861 B
JavaScript
// src/flat-form/FormItem.tsx
import { EnumSchemeItemType } from "../types.mjs";
import { useJsonFormUi } from "../contexts/ui.mjs";
import { JFL_Nothing } from "../components/JsonFormLayout.mjs";
import { jsx } from "react/jsx-runtime";
var FormItem = ({
children,
...props
}) => {
const Ui = useJsonFormUi();
const Item = Ui?.Item ? Ui.Item : JFL_Nothing;
const { as: Cmp = Item, isFormPrimary, isLast, type, title } = props;
const body = /* @__PURE__ */ jsx(Cmp, { ...props, primary: isFormPrimary, children });
if (!Ui?.ItemWrapper) {
return body;
}
return /* @__PURE__ */ jsx(
Ui.ItemWrapper,
{
isLast: isLast || false,
type: type || EnumSchemeItemType.Submit,
primary: isFormPrimary,
title,
children: body
}
);
};
var FormItem_default = FormItem;
export {
FormItem_default as default
};