UNPKG

@sishuguojixuefu/react-native-form

Version:
185 lines (184 loc) 4.62 kB
/// <reference types="react" /> import { KeyboardTypeOptions, ImageSourcePropType } from 'react-native'; export declare type TextAreaEventHandle = (val?: string) => void; /** * 正则规则类型定义 */ export interface RulePatternPropsType { pattern?: RegExp; message?: string; } /** * 正则规则类型定义 */ export interface RuleRequiredPropsType { required?: boolean; message?: string; } /** * 正则函数类型定义 */ export interface RuleValidatorPropsType { pattern?: RegExp; validator?: boolean; message?: string; } /** * 正则自定义规则类型定义 */ export interface RuleMessagePropsType { type: 'zip' | 'email' | 'zh' | 'zhName' | 'url' | 'phone' | 'mobilePhone' | 'telephone' | 'idCard' | 'money' | 'date' | 'number' | 'integer' | 'floating' | 'twoTimes' | 'threeTimes' | 'fourTimes' | 'fiveTimes'; message?: string; } export declare type RulePropsType = (string | RulePatternPropsType | RuleRequiredPropsType | RuleMessagePropsType | RuleValidatorPropsType)[]; /** * FormItems属性的类型定义 */ export interface FormItemPropsType { componentName: string; props: FormItemOptionPropsType; } /** * FormItem 类型定义 */ export interface FormItemOptionPropsType { name?: string; id: string; placeholder?: string; initialValue?: string; required?: boolean; rules?: RulePropsType; form?: any; } /** * SsDescription组件PropsType */ export interface SsDescriptionPropsType { name?: string; id: string; initialValue?: string; icon?: string; } /** * Input组件PropsType */ export interface SwitchPropsType extends FormItemOptionPropsType { label: string; onChange?: (checked: boolean) => void; last?: boolean; } /** * Input组件PropsType */ export interface InputPropsType extends FormItemOptionPropsType { icon?: ImageSourcePropType; label: string; onChange?: (value: string) => void; type?: 'text' | 'bankCard' | 'phone' | 'password' | 'number' | 'digit' | KeyboardTypeOptions; textAlign?: 'left' | 'center' | 'right'; extra?: React.ReactNode; maxLength?: number; last?: boolean; multiline?: boolean; height?: number; } /** * Textarea组件PropsType */ export interface TextareaPropsType extends FormItemOptionPropsType { label: string; onChange?: TextAreaEventHandle; count?: number; last?: boolean; } /** * SsSelect组件PropsType */ export interface SsSelectPropsType extends FormItemOptionPropsType { icon?: ImageSourcePropType; label: string; onChange?: (value?: React.ReactText[]) => void; options: ({ label: string; value: string; } | string)[]; cols?: number; last?: boolean; } /** * SsMultiSelect组件PropsType */ export interface SsMultiSelectPropsType extends FormItemOptionPropsType { label: string; onChange?: (value?: React.ReactText[]) => void; options: ({ label: string; value: string; } | string)[]; } /** * SsDropDown组件PropsType */ export interface SsDropDownPropsType extends FormItemOptionPropsType { icon?: ImageSourcePropType; label: string; onChange?: (value?: React.ReactText[]) => void; options: ({ label: string; value: string; } | string)[]; multiple: boolean; } /** * SsDate组件PropsType */ export interface SsDateProps extends FormItemOptionPropsType { label: string; onChange?: (value: Date) => void; type: 'year' | 'month' | 'date' | 'datetime' | 'time'; minDate: Date; maxDate: Date; } /** * SsDateRange组件PropsType */ export interface SsDateRangeProps { name?: string; id: string[]; placeholder?: string[]; initialValue?: string[]; required?: boolean; rules?: RulePropsType; form?: any; label: string[]; onChange?: (value: Date | Date[]) => void; } /** * SsAmount组件PropsType */ export interface SsAmountProps extends InputPropsType { upper?: boolean; } export interface RatingProps { form?: any; id: string; label: string; rules?: RulePropsType; allowHalf?: boolean; onChange?: (value: number) => void; initialValue: number; required?: boolean; } export interface ImagePickerProps extends FormItemOptionPropsType { label: string; onChange?: (value: any[]) => void; } export interface LocationProps extends FormItemOptionPropsType { label: string; onChange?: (value: any) => void; } export interface CalculateProps extends FormItemOptionPropsType { label: string; formula: any[]; onChange?: (value: any) => void; }