@lobehub/ui
Version:
Lobe UI is an open-source UI component library for building AIGC web apps
43 lines (40 loc) • 1.5 kB
JavaScript
'use client';
import { itemVariants } from "../style.mjs";
import FormDivider_default from "./FormDivider.mjs";
import FormTitle_default from "./FormTitle.mjs";
import { memo, useMemo } from "react";
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
import { Form } from "antd";
import { cx } from "antd-style";
//#region src/Form/components/FormItem.tsx
const { Item } = Form;
const FormItem = memo(({ desc, tag, minWidth, avatar, className, label, children, divider, layout, variant, ...rest }) => {
const cssVariables = useMemo(() => ({ "--form-item-min-width": minWidth !== void 0 && minWidth !== null && minWidth !== "" ? typeof minWidth === "number" ? `${minWidth}px` : minWidth : "" }), [minWidth]);
const hasMinWidth = minWidth !== void 0 && minWidth !== null && minWidth !== "";
const { style: restStyle, ...restProps } = rest;
return /* @__PURE__ */ jsxs(Fragment$1, { children: [divider && /* @__PURE__ */ jsx(FormDivider_default, { visible: variant !== "borderless" }), /* @__PURE__ */ jsx(Item, {
className: cx(itemVariants({
divider,
itemMinWidth: hasMinWidth,
layout
}), className),
label: /* @__PURE__ */ jsx(FormTitle_default, {
avatar,
desc,
tag,
title: label
}),
layout,
style: {
...cssVariables,
...restStyle
},
...restProps,
children
})] });
});
FormItem.displayName = "FormItem";
var FormItem_default = FormItem;
//#endregion
export { FormItem_default as default };
//# sourceMappingURL=FormItem.mjs.map