UNPKG

react-json-schema-editor-antd

Version:

Json Schema Editor

216 lines (215 loc) 7.37 kB
/// <reference types="react" /> export type SchemaEditorProps = { keyWidth?: number; onKeyWidthChange?: (val: number) => void; schema?: JSONSchema7 | undefined | string; onSchemaChange?: (schema: JSONSchema7) => void; components?: any; language?: 'en' | 'zh' | 'ja' | 'zh-Hant' | 'id'; parentAntdConfig?: any; theme?: string; refId?: string; renderValueComponents?: (data: { disabled: boolean; lineThrough: boolean; value: string; onChange: (val: string) => void; onBlur: () => void; onDirectChange: (val: string) => void; }) => JSX.Element | React.ReactNode; renderKeyComponents?: (data: { disabled: boolean; lineThrough: boolean; value: string; onChange: (val: string) => void; onBlur: () => void; onSchemaRowUpdate: (key: string, val: any) => void; getSchemaData: (schema: JSONSchema7) => void; error: boolean; }) => JSX.Element | React.ReactNode; }; /** * Primitive type * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1.1 */ export type JSONSchema7TypeName = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null' | 'any' | 'allOf' | 'anyOf' | 'oneOf'; /** * Primitive type * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1.1 */ export type JSONSchema7Type = string | number | boolean | JSONSchema7Object | JSONSchema7Array | null; export interface JSONSchema7Object { [key: string]: JSONSchema7Type; } export type JSONSchema7Array = Array<JSONSchema7Type>; /** * Meta schema * * Recommended values: * - 'http://json-schema.org/schema#' * - 'http://json-schema.org/hyper-schema#' * - 'http://json-schema.org/draft-07/schema#' * - 'http://json-schema.org/draft-07/hyper-schema#' * * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-5 */ export type JSONSchema7Version = string; /** * JSON Schema v7 * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01 */ export type JSONSchema7Definition = JSONSchema7 | boolean; export interface JSONSchema7 { $id?: string; $ref?: string; $schema?: JSONSchema7Version; $comment?: string; /** * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1 */ type?: JSONSchema7TypeName | JSONSchema7TypeName[]; enum?: JSONSchema7Type[]; const?: JSONSchema7Type; /** * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.2 */ multipleOf?: number; maximum?: number; exclusiveMaximum?: number; minimum?: number; exclusiveMinimum?: number; /** * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.3 */ maxLength?: number; minLength?: number; pattern?: string; /** * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.4 */ items?: JSONSchema7Definition | JSONSchema7Definition[]; additionalItems?: JSONSchema7Definition; maxItems?: number; minItems?: number; uniqueItems?: boolean; contains?: JSONSchema7; /** * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.5 */ maxProperties?: number; minProperties?: number; required?: string[]; properties?: { [key: string]: JSONSchema7Definition; }; patternProperties?: { [key: string]: JSONSchema7Definition; }; additionalProperties?: JSONSchema7Definition; dependencies?: { [key: string]: JSONSchema7Definition | string[]; }; propertyNames?: JSONSchema7Definition; /** * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.6 */ if?: JSONSchema7Definition; then?: JSONSchema7Definition; else?: JSONSchema7Definition; /** * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.7 */ allOf?: JSONSchema7Definition[]; anyOf?: JSONSchema7Definition[]; oneOf?: JSONSchema7Definition[]; not?: JSONSchema7Definition; /** * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-7 */ format?: string; /** * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-8 */ contentMediaType?: string; contentEncoding?: string; /** * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-9 */ definitions?: { [key: string]: JSONSchema7Definition; }; /** * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-10 */ title?: string; description?: string; default?: JSONSchema7Type; example?: string; readOnly?: boolean; writeOnly?: boolean; examples?: any[]; [extension: `x-${string}`]: any; } export type SchemaItemProps = { propertyName?: string; uniqueKey?: string; nodeDepth?: number; modalDepth?: number; namePath?: any[]; nameType?: string; isArrayItems?: boolean; isCombinedItems?: boolean; isDataModelItems?: boolean; isUnLinkDataModelItems?: boolean; isFirstCombinedData?: boolean; fieldDirectRef?: boolean; isRequire?: boolean; allowNull?: boolean; isHidden?: boolean; isRepeat?: boolean; displayRefPropertyActions?: boolean; schema: JSONSchema7; refSchema?: JSONSchema7; widthClass?: number; nodeDepthPathObj?: any; renameProperty?: (namePath: number[], name: string) => void; renamePropertySource?: (namePath: number[], name: string) => void; removeProperty?: (namePath: number[]) => void; addProperty?: (path: number[], isChild?: boolean) => void; updateRequiredProperty?: (namePath: number[], propertyName: string, removed: boolean) => void; updateAllowNull?: (namePath: number[], allowNull: boolean) => void; removeRef?: (namePath: any[]) => void; addRef?: (namePath: any[], refData: any, update?: boolean) => void; hiddenRefProperty?: (namePath: any[], isHidden: boolean) => void; linkRefProperty?: (namePath: any[], propertySchema: any, link: boolean) => void; unreferenceRef?: (namePath: any[], refSchema: any, schema?: any) => void; updateSchema?: (namePath: any[], value: any) => void; renderValueComponents?: (data: { disabled: boolean; lineThrough: boolean; value: string; onChange: (val: string) => void; onBlur: () => void; onFocus: () => void; onDirectChange: (val: string) => void; }) => JSX.Element | React.ReactNode; renderKeyComponents?: (data: { disabled: boolean; lineThrough: boolean; value: string; onChange: (val: string) => void; onSchemaRowUpdate: (key: string, val: any) => void; getSchemaData: (schema: JSONSchema7) => void; onBlur: () => void; onFocus: () => void; error: boolean; uniqueKey: string; }) => JSX.Element | React.ReactNode; onSchemaRowUpdate?: any; components?: any; combinedData?: JSONSchema7Definition[]; refData?: any; refIds?: string[]; current_ref_id?: string; refName?: string; };