Skip to content

Commit

Permalink
feat: modifying the ts definition
Browse files Browse the repository at this point in the history
  • Loading branch information
Zaoei committed Jun 7, 2023
1 parent 3253ac1 commit 3d56461
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/modal/demos/classComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ interface FormValue {
username: string;
}

interface IProps {
interface FormItemProps {
customAttr: string;
}

class FormItem extends React.Component<IProps & ModalFormProps<FormValue>> {
class FormItem extends React.Component<FormItemProps & ModalFormProps<FormValue>> {
render(): React.ReactNode {
return (
<>
Expand All @@ -30,7 +30,7 @@ class FormItem extends React.Component<IProps & ModalFormProps<FormValue>> {
}
}

const ModalForm = Modal.Form<IProps, FormValue>(FormItem);
const ModalForm = Modal.Form<FormItemProps, FormValue>(FormItem);

export default () => {
const [visible, setVisible] = useState(false);
Expand Down
17 changes: 7 additions & 10 deletions src/modal/form.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import React, { ReactElement, useMemo } from 'react';
import { Modal, FormProps, ModalFuncProps } from 'antd';
import { Modal, FormProps, ModalProps } from 'antd';
import { FORM_PROPS, MODAL_PROPS } from '../utils/antdProps';
import Utils from '../utils';
import Form from '../form';

export interface ModalFormProps<Values = any> extends FormProps, ModalFuncProps {
/**
* modal title
* @param {string}
*/
title?: string;
export interface ModalFormProps<Values = any>
extends Omit<FormProps, 'title'>,
Omit<ModalProps, 'children'> {
/**
* modal className
* @param {string}
Expand All @@ -22,7 +19,7 @@ export interface ModalFormProps<Values = any> extends FormProps, ModalFuncProps
* @returns
*/
onSubmit?: (values: Values) => void;
[key: string]: any;
// [key: string]: any;
}

const ModalForm = (props: ModalFormProps) => {
Expand Down Expand Up @@ -50,8 +47,8 @@ const ModalForm = (props: ModalFormProps) => {
} catch (error) {}
};

const onCancel = () => {
props.onCancel?.();
const onCancel = (e: React.MouseEvent<HTMLElement, MouseEvent>) => {
props.onCancel?.(e);
};

const afterClose = () => {
Expand Down

0 comments on commit 3d56461

Please sign in to comment.