mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-29 18:48:45 +08:00
chore: 解决递归依赖 (#11006)
This commit is contained in:
parent
de359199b8
commit
fc0137ba3c
@ -1,7 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {autobind} from 'amis-core';
|
import {autobind} from 'amis-core';
|
||||||
import {Icon} from '../icons';
|
import {Icon} from '../icons';
|
||||||
import {SchemaEditorItemCommon} from './Common';
|
import {ITEMMAP, SchemaEditorItemCommon} from './Common';
|
||||||
import {SchemaEditorItem} from './Item';
|
import {SchemaEditorItem} from './Item';
|
||||||
import {Controller} from '../FormField';
|
import {Controller} from '../FormField';
|
||||||
|
|
||||||
@ -158,3 +158,5 @@ export class SchemaEditorItemArray extends SchemaEditorItemCommon {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ITEMMAP.array = SchemaEditorItemArray;
|
||||||
|
@ -381,3 +381,7 @@ export class SchemaEditorItemCommon<
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const ITEMMAP: {
|
||||||
|
[propsName: string]: typeof SchemaEditorItemCommon;
|
||||||
|
} = {};
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {LocaleProps, ThemeProps} from 'amis-core';
|
import {LocaleProps, ThemeProps} from 'amis-core';
|
||||||
import {SchemaEditorItemArray} from './Array';
|
import {
|
||||||
import {SchemaEditorItemCommon, SchemaEditorItemCommonProps} from './Common';
|
ITEMMAP,
|
||||||
import {SchemaEditorItemObject} from './Object';
|
SchemaEditorItemCommon,
|
||||||
|
SchemaEditorItemCommonProps
|
||||||
|
} from './Common';
|
||||||
|
|
||||||
export interface SchemaEditorItemProps
|
export interface SchemaEditorItemProps
|
||||||
extends SchemaEditorItemCommonProps,
|
extends SchemaEditorItemCommonProps,
|
||||||
@ -14,16 +16,8 @@ export class SchemaEditorItem extends React.Component<SchemaEditorItemProps> {
|
|||||||
const {value} = this.props;
|
const {value} = this.props;
|
||||||
|
|
||||||
// 动态Component要用大写开头的才会被识别
|
// 动态Component要用大写开头的才会被识别
|
||||||
let Renderer = SchemaEditorItemCommon;
|
let Renderer =
|
||||||
switch (value?.type) {
|
(value?.type && ITEMMAP[value?.type as string]) || SchemaEditorItemCommon;
|
||||||
case 'object':
|
|
||||||
Renderer = SchemaEditorItemObject as any;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'array':
|
|
||||||
Renderer = SchemaEditorItemArray as any;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Renderer {...this.props} key={(value?.type as string) || 'string'} />
|
<Renderer {...this.props} key={(value?.type as string) || 'string'} />
|
||||||
|
@ -3,7 +3,7 @@ import {autobind, guid, JSONSchema} from 'amis-core';
|
|||||||
import Button from '../Button';
|
import Button from '../Button';
|
||||||
import {Icon} from '../icons';
|
import {Icon} from '../icons';
|
||||||
import InputBox from '../InputBox';
|
import InputBox from '../InputBox';
|
||||||
import {SchemaEditorItemCommon} from './Common';
|
import {ITEMMAP, SchemaEditorItemCommon} from './Common';
|
||||||
import {SchemaEditorItem} from './Item';
|
import {SchemaEditorItem} from './Item';
|
||||||
|
|
||||||
import type {SchemaEditorItemCommonProps} from './Common';
|
import type {SchemaEditorItemCommonProps} from './Common';
|
||||||
@ -531,3 +531,5 @@ export class SchemaEditorItemObject extends SchemaEditorItemCommon<
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ITEMMAP.object = SchemaEditorItemObject;
|
||||||
|
@ -16,6 +16,8 @@ import {SchemaEditorItem} from './Item';
|
|||||||
import {schemaEditorItemPlaceholder} from './Common';
|
import {schemaEditorItemPlaceholder} from './Common';
|
||||||
import type {JSONSchema7TypeName} from 'json-schema';
|
import type {JSONSchema7TypeName} from 'json-schema';
|
||||||
import type {SchemaEditorItemPlaceholder} from './Common';
|
import type {SchemaEditorItemPlaceholder} from './Common';
|
||||||
|
import './Array';
|
||||||
|
import './Object';
|
||||||
|
|
||||||
export interface SchemaEditorProps extends LocaleProps, ThemeProps {
|
export interface SchemaEditorProps extends LocaleProps, ThemeProps {
|
||||||
value?: JSONSchema;
|
value?: JSONSchema;
|
||||||
|
Loading…
Reference in New Issue
Block a user