improve tabs
This commit is contained in:
parent
f997b4bebb
commit
6ff216be6b
@ -12,7 +12,7 @@ import { uid } from '@formily/shared';
|
|||||||
import { DragHandle, SortableItem } from '../../components/Sortable';
|
import { DragHandle, SortableItem } from '../../components/Sortable';
|
||||||
import { DndContext, DragOverlay } from '@dnd-kit/core';
|
import { DndContext, DragOverlay } from '@dnd-kit/core';
|
||||||
|
|
||||||
const useTabs = () => {
|
const useTabs = ({ singleton }) => {
|
||||||
const tabsField = useField();
|
const tabsField = useField();
|
||||||
const { schema } = useDesignable();
|
const { schema } = useDesignable();
|
||||||
const tabs: { name: SchemaKey; props: any; schema: Schema }[] = [];
|
const tabs: { name: SchemaKey; props: any; schema: Schema }[] = [];
|
||||||
@ -30,13 +30,16 @@ const useTabs = () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (singleton) {
|
||||||
|
return [tabs.shift()].filter(Boolean);
|
||||||
|
}
|
||||||
return tabs;
|
return tabs;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Tabs: any = observer((props: any) => {
|
export const Tabs: any = observer((props: any) => {
|
||||||
const { singleton, ...others } = props;
|
const { singleton, ...others } = props;
|
||||||
const { schema, DesignableBar, appendChild, root, remove, insertAfter } = useDesignable();
|
const { schema, DesignableBar, appendChild, root, remove, insertAfter } = useDesignable();
|
||||||
const tabs = useTabs();
|
const tabs = useTabs({ singleton });
|
||||||
const [dragOverlayContent, setDragOverlayContent] = useState('');
|
const [dragOverlayContent, setDragOverlayContent] = useState('');
|
||||||
|
|
||||||
const moveToAfter = (path1, path2) => {
|
const moveToAfter = (path1, path2) => {
|
||||||
@ -182,7 +185,7 @@ Tabs.DesignableBar = () => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
禁用标签页 <span style={{ marginRight: 24 }}></span>{' '}
|
禁用标签页 <span style={{ marginRight: 24 }}></span>{' '}
|
||||||
<Switch size={'small'} />
|
<Switch size={'small'} checked={!!field.componentProps.singleton}/>
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
</Menu>
|
</Menu>
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user