From c663abc020cb735e31691af0d7aa8070d0f97033 Mon Sep 17 00:00:00 2001 From: zsirfs Date: Fri, 26 Apr 2019 14:31:42 +0800 Subject: [PATCH] feat(packages): some the antd component and the react component --- package.json | 4 +- packages/antd/index.d.ts | 87 +++++++++++++++++++++++++++++++++++++ packages/antd/package.json | 1 + packages/react/index.d.ts | 56 ++++++++++++++++++++++++ packages/react/package.json | 1 + 5 files changed, 147 insertions(+), 2 deletions(-) create mode 100644 packages/antd/index.d.ts create mode 100644 packages/react/index.d.ts diff --git a/package.json b/package.json index 05e0421a11d..774996c1f2f 100644 --- a/package.json +++ b/package.json @@ -23,8 +23,8 @@ "version:patch": "npm run prevesion && lerna version patch --exact", "version:minor": "npm run prevesion && lerna version minor --exact", "version:major": "npm run prevesion && lerna version major --exact", - "release:force":"lerna publish from-package --yes", - "release":"lerna publish", + "release:force": "lerna publish from-package --yes", + "release": "lerna publish", "lint": "eslint \"packages/!(docs)/**/*.js\" \"scripts/**/*.js\"" }, "devDependencies": { diff --git a/packages/antd/index.d.ts b/packages/antd/index.d.ts new file mode 100644 index 00000000000..7d4a4be03f9 --- /dev/null +++ b/packages/antd/index.d.ts @@ -0,0 +1,87 @@ +import { ButtonProps } from 'antd/lib/button'; + +declare type SumbitProps = { + status: 'submitting' | string; +} & ButtonProps; + +export function Submit( + props: React.ComponentPropsWithRef +): React.ComponentType; + +declare type ResetProps = { + reset: (event: React.MouseEvent) => void; +} & ButtonProps; + +export function Reset(props: React.PropsWithChildren): React.ComponentType; + +declare type FormButtonGroupProps = { + itemStyle: React.CSSProperties; +}; + +export function FormButtonGroup( + props: FormButtonGroupProps +): React.ComponentType; + +declare type RowProps = { + prefix?: string; + pure?: boolean; + fixed?: boolean; + gutter?: number; + wrap?: boolean; + component?: string; + fixedWidth?: number; + align?: string; + justify?: string; + hidden?: boolean; + className?: string; + [x: string]: any; +}; + +export class Row extends React.Component { + static defaultProps: { + prefix: string; + pure: boolean; + fixed: boolean; + gutter: number; + wrap: boolean; + component: string; + }; + + render(): JSX.Element; +} + +type PointType = + | { + span?: string | number; + offset?: string | number; + } + | string + | number; + +declare type ColProps = { + prefix?: string; + pure?: boolean; + component?: string; + span?: string | number; + offset?: string | number; + fixedSpan?: string | number; + align?: string | number; + hidden?: boolean; + xxs?: PointType; + xs?: PointType; + s?: PointType; + m?: PointType; + l?: PointType; + xl?: PointType; +}; + +export class Col extends React.Component { + static isNextCol: boolean; + static defaultProps: { + prefix: string; + pure: boolean; + component: string; + }; + + render(): JSX.Element; +} diff --git a/packages/antd/package.json b/packages/antd/package.json index d88ec7bdc8a..7654bc0800b 100644 --- a/packages/antd/package.json +++ b/packages/antd/package.json @@ -3,6 +3,7 @@ "version": "0.1.5", "license": "MIT", "main": "lib", + "types": "./index.d.ts", "repository": { "type": "git", "url": "git+https://github.com/alibaba/uform.git" diff --git a/packages/react/index.d.ts b/packages/react/index.d.ts new file mode 100644 index 00000000000..a018a3d8790 --- /dev/null +++ b/packages/react/index.d.ts @@ -0,0 +1,56 @@ +export type SchemaFormProps = { + className?: string; + [x: string]: any; +}; + +export const SchemaForm: React.SFC; + +export type SchemaFieldProps = { + [x: string]: any; +}; + +type ParamsWithContext

= ( + props: React.PropsWithChildren

, + context: React.Context +) => JSX.Element; + +export const Field: ParamsWithContext; + +/** + * set the validation internationalization + */ +export const setValidationLocale: (locale: Record) => void; + +/** + * set the validation langage + */ +export const setValidationLanguage: (lang: string) => void; + +declare type FormActionType = { + getFormState: (callback?: any) => any; + getFieldState: (path?: string, callback: any) => any; + setFormState: (callback?: any) => any; + setFieldState: (path?: string, buffer?: any, callback?: any) => any; + getSchema: (path?: string) => any; + reset: (forceClear?: boolean) => void; + submit: () => Promise; + validate: () => Promise; + dispatch: (type: string, payload?: any) => void; +}; + +export const createFormActions: () => FormActionType; + +declare type FormAsyncActionType = { + getFormState: (callback?: any) => Promise; + getFieldState: (path?: string, callback: any) => Promise; + setFormState: (callback?: any) => Promise; + setFieldState: (path?: string, buffer?: any, callback?: any) => Promise; + getSchema: (path?: string) => Promise; + reset: (forceClear?: boolean) => Promise; + submit: () => Promise; + validate: () => Promise; + dispatch: (type: string, payload?: any) => Promise; +}; + +export const createAsyncFormActions: () => FormAsyncActionType; + diff --git a/packages/react/package.json b/packages/react/package.json index f55bc0210a7..45481615bf6 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -3,6 +3,7 @@ "version": "0.1.5", "license": "MIT", "main": "lib", + "types": "./index.d.ts", "repository": { "type": "git", "url": "git+https://github.com/alibaba/uform.git"