antd-schema
Version:
545 lines (533 loc) • 19.4 kB
TypeScript
import * as react from 'react';
import { z } from 'zod';
declare const viewportSchema: z.ZodObject<z.objectUtil.extendShape<{
type: z.ZodString;
storeId: z.ZodOptional<z.ZodString>;
storeIdRef: z.ZodOptional<z.ZodString>;
}, {
type: z.ZodLiteral<"viewport">;
body: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
}>, "strip", z.ZodTypeAny, {
type: "viewport";
storeId?: string | undefined;
storeIdRef?: string | undefined;
body?: any[] | undefined;
data?: Record<string, any> | undefined;
}, {
type: "viewport";
storeId?: string | undefined;
storeIdRef?: string | undefined;
body?: any[] | undefined;
data?: Record<string, any> | undefined;
}>;
type ViewportSchema = z.infer<typeof viewportSchema>;
declare const baseSchema: z.ZodObject<{
type: z.ZodString;
storeId: z.ZodOptional<z.ZodString>;
storeIdRef: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
type: string;
storeId?: string | undefined;
storeIdRef?: string | undefined;
}, {
type: string;
storeId?: string | undefined;
storeIdRef?: string | undefined;
}>;
type BaseSchema = z.infer<typeof baseSchema>;
declare const buttonSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<z.objectUtil.extendShape<{
type: z.ZodString;
storeId: z.ZodOptional<z.ZodString>;
storeIdRef: z.ZodOptional<z.ZodString>;
}, {
type: z.ZodLiteral<"button">;
code: z.ZodOptional<z.ZodString>;
buttonType: z.ZodOptional<z.ZodEnum<["primary", "default", "dashed", "link", "text"]>>;
action: z.ZodOptional<z.ZodEnum<["modal", "download"]>>;
text: z.ZodOptional<z.ZodString>;
data: z.ZodOptional<z.ZodAny>;
method: z.ZodOptional<z.ZodEnum<["GET", "POST"]>>;
url: z.ZodOptional<z.ZodString>;
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
body: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
showLoading: z.ZodDefault<z.ZodBoolean>;
modal: z.ZodOptional<z.ZodObject<{
title: z.ZodString;
body: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
width: z.ZodOptional<z.ZodNumber>;
}, "strip", z.ZodTypeAny, {
title: string;
body?: any[] | undefined;
data?: Record<string, any> | undefined;
width?: number | undefined;
}, {
title: string;
body?: any[] | undefined;
data?: Record<string, any> | undefined;
width?: number | undefined;
}>>;
}>, "strip", z.ZodTypeAny, {
type: "button";
showLoading: boolean;
storeId?: string | undefined;
storeIdRef?: string | undefined;
code?: string | undefined;
params?: Record<string, any> | undefined;
body?: Record<string, any> | undefined;
data?: any;
text?: string | undefined;
buttonType?: "link" | "primary" | "default" | "dashed" | "text" | undefined;
modal?: {
title: string;
body?: any[] | undefined;
data?: Record<string, any> | undefined;
width?: number | undefined;
} | undefined;
action?: "modal" | "download" | undefined;
method?: "GET" | "POST" | undefined;
url?: string | undefined;
}, {
type: "button";
storeId?: string | undefined;
storeIdRef?: string | undefined;
code?: string | undefined;
params?: Record<string, any> | undefined;
body?: Record<string, any> | undefined;
data?: any;
text?: string | undefined;
buttonType?: "link" | "primary" | "default" | "dashed" | "text" | undefined;
modal?: {
title: string;
body?: any[] | undefined;
data?: Record<string, any> | undefined;
width?: number | undefined;
} | undefined;
action?: "modal" | "download" | undefined;
method?: "GET" | "POST" | undefined;
url?: string | undefined;
showLoading?: boolean | undefined;
}>, {
type: "button";
showLoading: boolean;
storeId?: string | undefined;
storeIdRef?: string | undefined;
code?: string | undefined;
params?: Record<string, any> | undefined;
body?: Record<string, any> | undefined;
data?: any;
text?: string | undefined;
buttonType?: "link" | "primary" | "default" | "dashed" | "text" | undefined;
modal?: {
title: string;
body?: any[] | undefined;
data?: Record<string, any> | undefined;
width?: number | undefined;
} | undefined;
action?: "modal" | "download" | undefined;
method?: "GET" | "POST" | undefined;
url?: string | undefined;
}, {
type: "button";
storeId?: string | undefined;
storeIdRef?: string | undefined;
code?: string | undefined;
params?: Record<string, any> | undefined;
body?: Record<string, any> | undefined;
data?: any;
text?: string | undefined;
buttonType?: "link" | "primary" | "default" | "dashed" | "text" | undefined;
modal?: {
title: string;
body?: any[] | undefined;
data?: Record<string, any> | undefined;
width?: number | undefined;
} | undefined;
action?: "modal" | "download" | undefined;
method?: "GET" | "POST" | undefined;
url?: string | undefined;
showLoading?: boolean | undefined;
}>, {
type: "button";
showLoading: boolean;
storeId?: string | undefined;
storeIdRef?: string | undefined;
code?: string | undefined;
params?: Record<string, any> | undefined;
body?: Record<string, any> | undefined;
data?: any;
text?: string | undefined;
buttonType?: "link" | "primary" | "default" | "dashed" | "text" | undefined;
modal?: {
title: string;
body?: any[] | undefined;
data?: Record<string, any> | undefined;
width?: number | undefined;
} | undefined;
action?: "modal" | "download" | undefined;
method?: "GET" | "POST" | undefined;
url?: string | undefined;
}, {
type: "button";
storeId?: string | undefined;
storeIdRef?: string | undefined;
code?: string | undefined;
params?: Record<string, any> | undefined;
body?: Record<string, any> | undefined;
data?: any;
text?: string | undefined;
buttonType?: "link" | "primary" | "default" | "dashed" | "text" | undefined;
modal?: {
title: string;
body?: any[] | undefined;
data?: Record<string, any> | undefined;
width?: number | undefined;
} | undefined;
action?: "modal" | "download" | undefined;
method?: "GET" | "POST" | undefined;
url?: string | undefined;
showLoading?: boolean | undefined;
}>;
type ButtonSchema = z.infer<typeof buttonSchema>;
declare const baseCardSchema: z.ZodObject<z.objectUtil.extendShape<{
type: z.ZodString;
storeId: z.ZodOptional<z.ZodString>;
storeIdRef: z.ZodOptional<z.ZodString>;
}, {
type: z.ZodLiteral<"card">;
title: z.ZodOptional<z.ZodString>;
extra: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
}>, "strip", z.ZodTypeAny, {
type: "card";
storeId?: string | undefined;
storeIdRef?: string | undefined;
title?: string | undefined;
extra?: any[] | undefined;
}, {
type: "card";
storeId?: string | undefined;
storeIdRef?: string | undefined;
title?: string | undefined;
extra?: any[] | undefined;
}>;
declare const cardBodySchema: z.ZodLazy<z.ZodArray<z.ZodAny, "many">>;
type Card = z.infer<typeof baseCardSchema> & {
body?: z.infer<typeof cardBodySchema>;
};
declare const cardSchema: z.ZodType<Card>;
type CardSchema = z.infer<typeof cardSchema>;
declare const formSchema: z.ZodObject<z.objectUtil.extendShape<{
type: z.ZodString;
storeId: z.ZodOptional<z.ZodString>;
storeIdRef: z.ZodOptional<z.ZodString>;
}, {
type: z.ZodLiteral<"form">;
name: z.ZodOptional<z.ZodString>;
preserve: z.ZodOptional<z.ZodBoolean>;
fields: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
initialValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
layout: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"horizontal">, z.ZodLiteral<"inline">, z.ZodLiteral<"vertical">]>>;
labelWidth: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodString]>>;
labelAlign: z.ZodOptional<z.ZodEnum<["left", "right"]>>;
clearOnDestroy: z.ZodOptional<z.ZodBoolean>;
gutter: z.ZodDefault<z.ZodUnion<[z.ZodNumber, z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>]>>;
}>, "strip", z.ZodTypeAny, {
type: "form";
layout: "vertical" | "horizontal" | "inline";
gutter: number | [number, number];
storeId?: string | undefined;
storeIdRef?: string | undefined;
name?: string | undefined;
preserve?: boolean | undefined;
fields?: any[] | undefined;
initialValues?: Record<string, any> | undefined;
labelWidth?: string | number | undefined;
labelAlign?: "left" | "right" | undefined;
clearOnDestroy?: boolean | undefined;
}, {
type: "form";
storeId?: string | undefined;
storeIdRef?: string | undefined;
name?: string | undefined;
preserve?: boolean | undefined;
fields?: any[] | undefined;
initialValues?: Record<string, any> | undefined;
layout?: "vertical" | "horizontal" | "inline" | undefined;
labelWidth?: string | number | undefined;
labelAlign?: "left" | "right" | undefined;
clearOnDestroy?: boolean | undefined;
gutter?: number | [number, number] | undefined;
}>;
type FormSchema = z.infer<typeof formSchema>;
declare const inputNumberSchema: z.ZodObject<z.objectUtil.extendShape<z.objectUtil.extendShape<{
type: z.ZodString;
storeId: z.ZodOptional<z.ZodString>;
storeIdRef: z.ZodOptional<z.ZodString>;
}, {
label: z.ZodString;
name: z.ZodString;
preserve: z.ZodOptional<z.ZodBoolean>;
span: z.ZodOptional<z.ZodNumber>;
rules: z.ZodOptional<z.ZodArray<z.ZodObject<{
type: z.ZodOptional<z.ZodEnum<["string", "number", "boolean", "integer"]>>;
required: z.ZodOptional<z.ZodBoolean>;
message: z.ZodOptional<z.ZodString>;
min: z.ZodOptional<z.ZodNumber>;
max: z.ZodOptional<z.ZodNumber>;
}, "strip", z.ZodTypeAny, {
type?: "string" | "number" | "boolean" | "integer" | undefined;
message?: string | undefined;
required?: boolean | undefined;
min?: number | undefined;
max?: number | undefined;
}, {
type?: "string" | "number" | "boolean" | "integer" | undefined;
message?: string | undefined;
required?: boolean | undefined;
min?: number | undefined;
max?: number | undefined;
}>, "many">>;
}>, {
type: z.ZodLiteral<"input-number">;
clearable: z.ZodOptional<z.ZodBoolean>;
min: z.ZodOptional<z.ZodNumber>;
max: z.ZodOptional<z.ZodNumber>;
step: z.ZodOptional<z.ZodNumber>;
width: z.ZodDefault<z.ZodString>;
controls: z.ZodDefault<z.ZodBoolean>;
}>, "strip", z.ZodTypeAny, {
type: "input-number";
width: string;
label: string;
name: string;
controls: boolean;
storeId?: string | undefined;
storeIdRef?: string | undefined;
preserve?: boolean | undefined;
span?: number | undefined;
min?: number | undefined;
max?: number | undefined;
rules?: {
type?: "string" | "number" | "boolean" | "integer" | undefined;
message?: string | undefined;
required?: boolean | undefined;
min?: number | undefined;
max?: number | undefined;
}[] | undefined;
clearable?: boolean | undefined;
step?: number | undefined;
}, {
type: "input-number";
label: string;
name: string;
storeId?: string | undefined;
storeIdRef?: string | undefined;
width?: string | undefined;
preserve?: boolean | undefined;
span?: number | undefined;
min?: number | undefined;
max?: number | undefined;
rules?: {
type?: "string" | "number" | "boolean" | "integer" | undefined;
message?: string | undefined;
required?: boolean | undefined;
min?: number | undefined;
max?: number | undefined;
}[] | undefined;
clearable?: boolean | undefined;
step?: number | undefined;
controls?: boolean | undefined;
}>;
type InputNumberSchema = z.infer<typeof inputNumberSchema>;
declare const inputTextSchema: z.ZodObject<z.objectUtil.extendShape<z.objectUtil.extendShape<{
type: z.ZodString;
storeId: z.ZodOptional<z.ZodString>;
storeIdRef: z.ZodOptional<z.ZodString>;
}, {
label: z.ZodString;
name: z.ZodString;
preserve: z.ZodOptional<z.ZodBoolean>;
span: z.ZodOptional<z.ZodNumber>;
rules: z.ZodOptional<z.ZodArray<z.ZodObject<{
type: z.ZodOptional<z.ZodEnum<["string", "number", "boolean", "integer"]>>;
required: z.ZodOptional<z.ZodBoolean>;
message: z.ZodOptional<z.ZodString>;
min: z.ZodOptional<z.ZodNumber>;
max: z.ZodOptional<z.ZodNumber>;
}, "strip", z.ZodTypeAny, {
type?: "string" | "number" | "boolean" | "integer" | undefined;
message?: string | undefined;
required?: boolean | undefined;
min?: number | undefined;
max?: number | undefined;
}, {
type?: "string" | "number" | "boolean" | "integer" | undefined;
message?: string | undefined;
required?: boolean | undefined;
min?: number | undefined;
max?: number | undefined;
}>, "many">>;
}>, {
type: z.ZodLiteral<"input-text">;
clearable: z.ZodOptional<z.ZodBoolean>;
}>, "strip", z.ZodTypeAny, {
type: "input-text";
label: string;
name: string;
storeId?: string | undefined;
storeIdRef?: string | undefined;
preserve?: boolean | undefined;
span?: number | undefined;
rules?: {
type?: "string" | "number" | "boolean" | "integer" | undefined;
message?: string | undefined;
required?: boolean | undefined;
min?: number | undefined;
max?: number | undefined;
}[] | undefined;
clearable?: boolean | undefined;
}, {
type: "input-text";
label: string;
name: string;
storeId?: string | undefined;
storeIdRef?: string | undefined;
preserve?: boolean | undefined;
span?: number | undefined;
rules?: {
type?: "string" | "number" | "boolean" | "integer" | undefined;
message?: string | undefined;
required?: boolean | undefined;
min?: number | undefined;
max?: number | undefined;
}[] | undefined;
clearable?: boolean | undefined;
}>;
type InputTextSchema = z.infer<typeof inputTextSchema>;
declare const serviceSchema: z.ZodObject<z.objectUtil.extendShape<{
type: z.ZodString;
storeId: z.ZodOptional<z.ZodString>;
storeIdRef: z.ZodOptional<z.ZodString>;
}, {
type: z.ZodLiteral<"service">;
method: z.ZodOptional<z.ZodEnum<["GET", "POST"]>>;
url: z.ZodOptional<z.ZodString>;
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
body: z.ZodOptional<z.ZodAny>;
}>, "strip", z.ZodTypeAny, {
type: "service";
storeId?: string | undefined;
storeIdRef?: string | undefined;
params?: Record<string, any> | undefined;
body?: any;
method?: "GET" | "POST" | undefined;
url?: string | undefined;
}, {
type: "service";
storeId?: string | undefined;
storeIdRef?: string | undefined;
params?: Record<string, any> | undefined;
body?: any;
method?: "GET" | "POST" | undefined;
url?: string | undefined;
}>;
type ServiceSchema = z.infer<typeof serviceSchema>;
declare const tableSchema: z.ZodObject<z.objectUtil.extendShape<{
type: z.ZodString;
storeId: z.ZodOptional<z.ZodString>;
storeIdRef: z.ZodOptional<z.ZodString>;
}, {
type: z.ZodLiteral<"table">;
rowKey: z.ZodOptional<z.ZodString>;
columns: z.ZodOptional<z.ZodArray<z.ZodObject<{
title: z.ZodString;
dataIndex: z.ZodOptional<z.ZodString>;
width: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodString]>>;
align: z.ZodOptional<z.ZodEnum<["left", "right", "center"]>>;
tpl: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
title: string;
width?: string | number | undefined;
dataIndex?: string | undefined;
align?: "center" | "left" | "right" | undefined;
tpl?: string | undefined;
}, {
title: string;
width?: string | number | undefined;
dataIndex?: string | undefined;
align?: "center" | "left" | "right" | undefined;
tpl?: string | undefined;
}>, "many">>;
footer: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
api: z.ZodOptional<z.ZodString>;
data: z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodAny, "many">, z.ZodString]>>;
bordered: z.ZodOptional<z.ZodBoolean>;
size: z.ZodDefault<z.ZodEnum<["small", "middle", "large"]>>;
tableLayout: z.ZodOptional<z.ZodEnum<["fixed", "auto"]>>;
pagination: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<false>, z.ZodObject<{
current: z.ZodOptional<z.ZodNumber>;
pageSize: z.ZodOptional<z.ZodNumber>;
total: z.ZodOptional<z.ZodNumber>;
}, "strip", z.ZodTypeAny, {
current?: number | undefined;
pageSize?: number | undefined;
total?: number | undefined;
}, {
current?: number | undefined;
pageSize?: number | undefined;
total?: number | undefined;
}>]>>;
}>, "strip", z.ZodTypeAny, {
type: "table";
size: "small" | "middle" | "large";
pagination: false | {
current?: number | undefined;
pageSize?: number | undefined;
total?: number | undefined;
};
storeId?: string | undefined;
storeIdRef?: string | undefined;
data?: string | any[] | undefined;
rowKey?: string | undefined;
columns?: {
title: string;
width?: string | number | undefined;
dataIndex?: string | undefined;
align?: "center" | "left" | "right" | undefined;
tpl?: string | undefined;
}[] | undefined;
footer?: any[] | undefined;
api?: string | undefined;
bordered?: boolean | undefined;
tableLayout?: "fixed" | "auto" | undefined;
}, {
type: "table";
storeId?: string | undefined;
storeIdRef?: string | undefined;
data?: string | any[] | undefined;
rowKey?: string | undefined;
columns?: {
title: string;
width?: string | number | undefined;
dataIndex?: string | undefined;
align?: "center" | "left" | "right" | undefined;
tpl?: string | undefined;
}[] | undefined;
footer?: any[] | undefined;
api?: string | undefined;
bordered?: boolean | undefined;
size?: "small" | "middle" | "large" | undefined;
tableLayout?: "fixed" | "auto" | undefined;
pagination?: false | {
current?: number | undefined;
pageSize?: number | undefined;
total?: number | undefined;
} | undefined;
}>;
type TableSchema = z.infer<typeof tableSchema>;
interface SchemaRendererProps {
schema?: ViewportSchema;
}
declare const SchemaRenderer: react.ForwardRefExoticComponent<SchemaRendererProps & react.RefAttributes<any>>;
export { type BaseSchema, type ButtonSchema, type CardSchema, type FormSchema, type InputNumberSchema, type InputTextSchema, SchemaRenderer, type ServiceSchema, type TableSchema, type ViewportSchema, baseSchema, buttonSchema, cardSchema, formSchema, inputNumberSchema, inputTextSchema, serviceSchema, tableSchema, viewportSchema };