jamis
Version:
一种支持通过JSON配置方式生成页面的组件库
49 lines (48 loc) • 1.72 kB
TypeScript
/**
* 用来定义数据结构的编辑器
*/
import React from 'react';
import type { JSONSchema, ReactPropsBase } from 'jamis-core';
import type { JSONSchema7TypeName } from 'json-schema';
import type { JSONSchemaEditorControlSchema } from '../types';
export interface SchemaEditorProps extends ReactPropsBase, Pick<JSONSchemaEditorControlSchema, 'requireLabel'> {
value?: JSONSchema;
onChange: (value: JSONSchema) => void;
disabled?: boolean;
defaultType: JSONSchema7TypeName;
renderExtraProps?: (value: JSONSchema, onChange: (value: JSONSchema) => void) => JSX.Element;
renderModalProps?: (value: JSONSchema, onChange: (value: JSONSchema) => void) => JSX.Element;
disabledTypes?: Array<string>;
/**
* 预设模板
*/
shared?: {
[propName: string]: {
type: 'string' | 'number' | 'integer' | 'object' | 'array' | 'boolean' | 'null';
title: string;
[propName: string]: any;
};
};
/** @deprecated 请使用`shared` */
definitions?: SchemaEditorProps['shared'];
/**
* 顶层是否允许修改类型
*/
rootTypeMutable: boolean;
/**
* 顶层类型信息是否隐藏
*/
showRootInfo: boolean;
/**
* 是否开启高级配置
*/
enableAdvancedSetting?: boolean;
}
export declare class SchemaEditor extends React.Component<SchemaEditorProps> {
static defaultProps: Pick<SchemaEditorProps, 'defaultType' | 'rootTypeMutable' | 'showRootInfo' | 'disabledTypes'>;
defaultTypes: Array<any>;
constructor(props: SchemaEditorProps);
handleTypeChange(type: string, value: any, origin: any): any;
render(): JSX.Element;
}
export default SchemaEditor;