Skip to content

Commit

Permalink
feat(form): ProForm支持第二个泛型参数 (#7318)
Browse files Browse the repository at this point in the history
  • Loading branch information
q1uxu authored Jul 3, 2023
1 parent a30e3e7 commit da90c1a
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions packages/form/src/BaseForm/BaseForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export type CommonFormProps<
readonly?: boolean;
} & ProFormGridConfig;

export type BaseFormProps<T = Record<string, any>> = {
export type BaseFormProps<T = Record<string, any>, U = Record<string, any>> = {
contentRender?: (
items: React.ReactNode[],
submitter: React.ReactElement<SubmitterProps> | undefined,
Expand All @@ -200,7 +200,7 @@ export type BaseFormProps<T = Record<string, any>> = {
/** Form 组件的类型,内部使用 */
formComponentType?: 'DrawerForm' | 'ModalForm' | 'QueryFilter';
} & Omit<FormProps, 'onFinish'> &
CommonFormProps<T>;
CommonFormProps<T, U>;

const genParams = (
syncUrl: BaseFormProps<any>['syncToUrl'],
Expand Down
4 changes: 2 additions & 2 deletions packages/form/src/layouts/DrawerForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import { createPortal } from 'react-dom';
import type { CommonFormProps, ProFormInstance } from '../../BaseForm';
import { BaseForm } from '../../BaseForm';

export type DrawerFormProps<T = Record<string, any>> = Omit<
export type DrawerFormProps<T = Record<string, any>, U = Record<string, any>> = Omit<
FormProps,
'onFinish' | 'title'
> &
CommonFormProps<T> & {
CommonFormProps<T, U> & {
/**
* 接收任意值,返回 真值 会关掉这个抽屉
*
Expand Down
4 changes: 2 additions & 2 deletions packages/form/src/layouts/LightFilter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { BaseForm } from '../../BaseForm';
import type { LightFilterFooterRender } from '../../typing';
import { useStyle } from './style';

export type LightFilterProps<T> = {
export type LightFilterProps<T, U = Record<string, any>> = {
collapse?: boolean;
/**
* @name 收起的label dom
Expand Down Expand Up @@ -52,7 +52,7 @@ export type LightFilterProps<T> = {
*/
placement?: TooltipPlacement;
} & Omit<FormProps<T>, 'onFinish'> &
CommonFormProps<T>;
CommonFormProps<T, U>;

/**
* 单行的查询表单,一般用于配合 table 或者 list使用 有时也会用于 card 的额外区域
Expand Down
4 changes: 2 additions & 2 deletions packages/form/src/layouts/ModalForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import { createPortal } from 'react-dom';
import type { CommonFormProps, ProFormInstance } from '../../BaseForm';
import { BaseForm } from '../../BaseForm';

export type ModalFormProps<T = Record<string, any>> = Omit<
export type ModalFormProps<T = Record<string, any>, U = Record<string, any>> = Omit<
FormProps<T>,
'onFinish' | 'title'
> &
CommonFormProps<T> & {
CommonFormProps<T, U> & {
/**
* 接收任意值,返回 真值 会关掉这个抽屉
*
Expand Down
4 changes: 2 additions & 2 deletions packages/form/src/layouts/ProForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import type { CommonFormProps } from '../../BaseForm';
import { BaseForm } from '../../BaseForm';
import { Group, ProFormItem } from '../../components';

export type ProFormProps<T = Record<string, any>> = Omit<
export type ProFormProps<T = Record<string, any>, U = Record<string, any>> = Omit<
FormProps<T>,
'onFinish'
> &
CommonFormProps<T>;
CommonFormProps<T, U>;

function ProForm<T = Record<string, any>>(
props: ProFormProps<T> & {
Expand Down
4 changes: 2 additions & 2 deletions packages/form/src/layouts/QueryFilter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,11 @@ const flatMapItems = (
});
};

export type QueryFilterProps<T = Record<string, any>> = Omit<
export type QueryFilterProps<T = Record<string, any>, U = Record<string, any>> = Omit<
FormProps<T>,
'onFinish'
> &
CommonFormProps<T> &
CommonFormProps<T, U> &
BaseQueryFilterProps & {
onReset?: (values: T) => void;
};
Expand Down
4 changes: 2 additions & 2 deletions packages/form/src/layouts/StepsForm/StepForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import type { CommonFormProps } from '../../BaseForm';
import { BaseForm } from '../../BaseForm';
import { StepsFormProvide } from './index';

export type StepFormProps<T = Record<string, any>> = {
export type StepFormProps<T = Record<string, any>, U = Record<string, any>> = {
step?: number;
stepProps?: StepProps;
index?: number;
} & Omit<FormProps<T>, 'onFinish' | 'form'> &
Omit<CommonFormProps<T>, 'submitter' | 'form'>;
Omit<CommonFormProps<T, U>, 'submitter' | 'form'>;

function StepForm<T = Record<string, any>>(props: StepFormProps<T>) {
const formRef = useRef<FormInstance | undefined>();
Expand Down

0 comments on commit da90c1a

Please sign in to comment.