diff --git a/apps/storybook/src/setting-form.stories.tsx b/apps/storybook/src/setting-form.stories.tsx
index 385cf38..85393dd 100644
--- a/apps/storybook/src/setting-form.stories.tsx
+++ b/apps/storybook/src/setting-form.stories.tsx
@@ -262,7 +262,13 @@ export function Basic() {
export function Lite() {
return (
-
+
);
}
diff --git a/packages/setting-form/src/context.tsx b/packages/setting-form/src/context.tsx
index 58d5fc9..6d0c997 100644
--- a/packages/setting-form/src/context.tsx
+++ b/packages/setting-form/src/context.tsx
@@ -15,6 +15,10 @@ export interface FormVariableContextType {
* 是否允许表单项切换到表达式设置器
*/
disableSwitchExpressionSetter?: boolean;
+ /**
+ * 是否展示表单项的副标题
+ */
+ showItemSubtitle?: boolean;
}
const FormVariableContext = createContext(null);
diff --git a/packages/setting-form/src/form-item.tsx b/packages/setting-form/src/form-item.tsx
index 95a55d5..8960079 100644
--- a/packages/setting-form/src/form-item.tsx
+++ b/packages/setting-form/src/form-item.tsx
@@ -79,7 +79,7 @@ export function createFormItem(options: IFormItemCreateOptions) {
extra,
footer,
}: FormItemProps) {
- const { disableSwitchExpressionSetter } = useFormVariable();
+ const { disableSwitchExpressionSetter, showItemSubtitle } = useFormVariable();
const model = useFormModel();
const field = model.getField(name);
const value = toJS(field.value ?? defaultValue);
@@ -141,7 +141,7 @@ export function createFormItem(options: IFormItemCreateOptions) {
React.ReactNode;
/**
* 选项分组信息,用于对表单项进行分组展示,如未提供,则使用内置的分组信息
*/
@@ -113,6 +121,8 @@ export function SettingForm({
onChange = noop,
showSearch = true,
showGroups = true,
+ showItemSubtitle = true,
+ renderItemExtra,
groupOptions = internalGroups,
}: SettingFormProps) {
const [keyword, setKeyword] = useState('');
@@ -149,14 +159,19 @@ export function SettingForm({
(props: ComponentPropType[]) =>
props.map((item) => {
const { getProp, ...rest } = item;
- const childProto = {
+ const childProp = {
...rest,
...getProp?.(model),
};
- const FormChild = isValidNestProps(childProto.props) ? SettingFormObject : SettingFormItem;
- return ;
+ if (isValidNestProps(childProp.props)) {
+ return ;
+ } else {
+ return (
+
+ );
+ }
}),
- [model],
+ [model, renderItemExtra],
);
useEffect(() => {
@@ -167,7 +182,7 @@ export function SettingForm({
}, [modelProp]);
return (
-
+