fix: hide child when useVisible() is false (#3803)
This commit is contained in:
parent
e82a33f1f7
commit
b879d11235
@ -72,7 +72,8 @@ export const SchemaInitializerMenu: FC<MenuProps> = (props) => {
|
||||
export const SchemaInitializerSubMenu: FC<SchemaInitializerSubMenuProps> = (props) => {
|
||||
const { children, title, name = uid(), onOpenChange, icon, ...others } = props;
|
||||
const compile = useCompile();
|
||||
const childrenItems = useSchemaInitializerMenuItems(children, name);
|
||||
const validChildren = children?.filter((item) => (item.useVisible ? item.useVisible() : true));
|
||||
const childrenItems = useSchemaInitializerMenuItems(validChildren, name);
|
||||
|
||||
const items = useMemo(() => {
|
||||
return [
|
||||
|
@ -35,9 +35,9 @@ export function useSchemaSettingsRender<T = {}>(name: string, options?: UseSchem
|
||||
}
|
||||
return {
|
||||
exists: true,
|
||||
render: (options2?: UseSchemaSettingsRenderOptions) => {
|
||||
const key = JSON.stringify(options) || '{}';
|
||||
if (renderCache.current[key]) {
|
||||
render: (options2: UseSchemaSettingsRenderOptions = {}) => {
|
||||
const key = JSON.stringify(options2);
|
||||
if (key && renderCache.current[key]) {
|
||||
return renderCache.current[key];
|
||||
}
|
||||
return (renderCache.current[key] = React.createElement(SchemaSettingsWrapper, {
|
||||
|
@ -40,10 +40,6 @@ export interface SchemaSettingItemGroupType extends SchemaSettingsItemCommon<Sch
|
||||
type: 'itemGroup';
|
||||
}
|
||||
|
||||
export interface SchemaSettingItemSubMenuType extends SchemaSettingsItemCommon<SchemaSettingsSubMenuProps> {
|
||||
type: 'subMenu';
|
||||
}
|
||||
|
||||
export interface SchemaSettingItemDividerProps extends SchemaSettingsItemCommon {
|
||||
type: 'divider';
|
||||
}
|
||||
@ -76,6 +72,10 @@ export type SchemaSettingItemActionModalType = SchemaSettingsItemCommon<SchemaSe
|
||||
type: 'actionModal';
|
||||
};
|
||||
|
||||
export interface SchemaSettingItemSubMenuType extends SchemaSettingsItemCommon<SchemaSettingsSubMenuProps> {
|
||||
type: 'subMenu';
|
||||
}
|
||||
|
||||
export interface SchemaSettingItemComponentType<T = {}> extends SchemaSettingsItemCommon<T> {
|
||||
Component: string | ComponentType<T>;
|
||||
}
|
||||
@ -90,6 +90,7 @@ export type SchemaSettingItemAllBuiltType =
|
||||
| SchemaSettingItemModalType
|
||||
| SchemaSettingItemItemType
|
||||
| SchemaSettingItemSelectType
|
||||
| SchemaSettingItemSubMenuType
|
||||
| SchemaSettingItemGroupType;
|
||||
|
||||
export type SchemaSettingsItemType = SchemaSettingItemComponentType | SchemaSettingItemAllBuiltType;
|
||||
|
Loading…
Reference in New Issue
Block a user