melt-parser
Version:
通过链式语法生成 JSON Schema, 主要用于表单和表格的增删改查
129 lines (128 loc) • 6.01 kB
TypeScript
import { CommonRequestProps } from "./ICrudOptions";
export interface IFormSchema extends CommonWidgetProps<IFormSchema> {
parse: (schema?: {}) => IFormSchema;
enabled: (enabled?: boolean) => IFormSchema;
disabled: (disabled?: boolean) => IFormSchema;
visible: (visible?: boolean) => IFormSchema;
editable: (editable?: boolean) => IFormSchema;
bind: (keys: []) => IFormSchema;
string: () => IFormSchema;
number: () => IFormSchema;
boolean: () => IFormSchema;
widget: (widgetName?: string) => IFormSchema;
/**
* form里是label, table里是表头标题
*/
title: (title: string) => TitleProps & IFormSchema;
extra: (extraText: string) => IFormSchema;
help: (helpText: string) => IFormSchema;
ellipsis: () => EllipsisProps & IFormSchema;
validate: () => ValidateProps & IFormSchema;
fixed: () => FixedProps & IFormSchema;
sort: () => SortProps & IFormSchema;
filter: () => FilterProps & IFormSchema;
search: () => SearchProps<IFormSchema> & CommonWidgetProps<IFormSchema & SearchProps<IFormSchema>> & IFormSchema;
}
declare type CommonWidgetProps<T> = {
input: () => InputProps<T> & T;
numberInput: () => NumberInputProps<T> & T;
textArea: () => TextAreaProps<T> & T;
select: () => CommonRequestProps<T> & SelectProps & T;
datePicker: () => DatePickerProps<T> & T;
uploader: () => CommonRequestProps<T & UploadProps<T>> & UploadProps<T> & T;
tagInput: () => InputProps<T> & T;
radio: () => InputProps<T> & T;
colorPicker: () => InputProps<T> & T;
cascader: () => CommonRequestProps<T> & SelectProps & T;
checkbox: () => CommonRequestProps<T> & SelectProps & T;
slider: () => CommonRequestProps<T> & SelectProps & T;
switch: () => CommonRequestProps<T> & SelectProps & T;
rate: () => CommonRequestProps<T> & SelectProps & T;
progress: () => CommonRequestProps<T> & SelectProps & T;
};
declare type ValidateRuleProps = {
message?: string;
};
declare type ValidateProps = {
required: (message?: string | ValidateRuleProps) => ValidateProps & IFormSchema;
max: (length: number, message?: string | ValidateRuleProps) => ValidateProps & IFormSchema;
min: (length: number, message?: string | ValidateRuleProps) => ValidateProps & IFormSchema;
length: (length: number, message?: string | ValidateRuleProps) => ValidateProps & IFormSchema;
equal: (eq: number | string, message?: string | ValidateRuleProps) => ValidateProps & IFormSchema;
eq: (eq: number | string, message?: string | ValidateRuleProps) => ValidateProps & IFormSchema;
email: (message?: string | ValidateRuleProps) => ValidateProps & IFormSchema;
url: (message?: string | ValidateRuleProps) => ValidateProps & IFormSchema;
regex: (regex: string, message?: string | ValidateRuleProps) => ValidateProps & IFormSchema;
nonempty: (message?: string | ValidateRuleProps) => ValidateProps & IFormSchema;
gt: (num: number, message?: string | ValidateRuleProps) => ValidateProps & IFormSchema;
gte: (num: number, message?: string | ValidateRuleProps) => ValidateProps & IFormSchema;
lt: (num: number, message?: string | ValidateRuleProps) => ValidateProps & IFormSchema;
lte: (num: number, message?: string | ValidateRuleProps) => ValidateProps & IFormSchema;
rules: (rules: any[]) => ValidateProps & IFormSchema;
};
declare type InputProps<T> = {
readonly: () => InputProps<T> & T;
clearable: () => InputProps<T> & T;
copyable: () => InputProps<T> & T;
placeholder: (placeholder: string) => InputProps<T> & T;
};
declare type TextAreaProps<T> = {
readonly: () => InputProps<T> & T;
autoSize: () => TextAreaProps<T> & T;
};
declare type NumberInputProps<T> = {
readonly: () => NumberInputProps<T> & T;
clearable: () => NumberInputProps<T> & T;
};
declare type DatePickerProps<T> = {
readonly: () => DatePickerProps<T> & T;
range: () => DatePickerProps<T> & T;
format: (fmt: string) => DatePickerProps<T> & T;
yyyy: () => DatePickerProps<T> & T;
yyyyMMdd: () => DatePickerProps<T> & T;
};
declare type TitleProps = {
width: (width: number) => TitleProps & IFormSchema;
upperFirst: () => TitleProps & IFormSchema;
};
declare type EllipsisProps = {
width: (width: number) => EllipsisProps & IFormSchema;
tooltip: () => EllipsisProps & IFormSchema;
left: () => EllipsisProps & IFormSchema;
right: () => EllipsisProps & IFormSchema;
top: () => EllipsisProps & IFormSchema;
bottom: () => EllipsisProps & IFormSchema;
auto: () => EllipsisProps & IFormSchema;
};
declare type SortProps = {
asc: () => SortProps & IFormSchema;
desc: () => SortProps & IFormSchema;
};
declare type FilterProps = {
asc: () => FilterProps & IFormSchema;
desc: () => FilterProps & IFormSchema;
eq: (eq: number | string) => FilterProps & IFormSchema;
gt: (num: number) => FilterProps & IFormSchema;
gte: (num: number) => FilterProps & IFormSchema;
lt: (num: number) => FilterProps & IFormSchema;
lte: (num: number) => FilterProps & IFormSchema;
};
declare type FixedProps = {
left: () => FixedProps & IFormSchema;
right: () => FixedProps & IFormSchema;
width: (width: number) => FixedProps & IFormSchema;
};
declare type SelectProps = {
options: (options: []) => SelectProps & IFormSchema;
};
declare type UploadProps<T> = {
uploadEmit: (eventName: string) => CommonRequestProps<T> & UploadProps<T> & T;
pictureCard: () => CommonRequestProps<T> & UploadProps<T> & IFormSchema;
withFileParam: (fileParam: string) => CommonRequestProps<T> & UploadProps<T> & IFormSchema;
withFileResult: (fileParam: string) => CommonRequestProps<T> & UploadProps<T> & IFormSchema;
};
declare type SearchProps<T> = {
idx: (idx: number) => SearchProps<T> & T;
advancedOnly: () => SearchProps<T> & T;
};
export {};