-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
93 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import React, { useState } from 'react'; | ||
import { Button, Form, Input } from 'antd'; | ||
import { Modal } from 'dt-react-component'; | ||
import { IModalFormProps } from '../form'; | ||
|
||
interface FormValue { | ||
username: string; | ||
} | ||
|
||
interface CustomModalFormProps { | ||
customAttr: string; | ||
} | ||
|
||
type FormItemsProps = CustomModalFormProps & IModalFormProps<FormValue>; | ||
|
||
class FormItems extends React.Component<FormItemsProps> { | ||
render(): React.ReactNode { | ||
return ( | ||
<> | ||
<Form.Item | ||
label="我是自定义参数" | ||
name={'name'} | ||
initialValue={this.props.customAttr} | ||
> | ||
<Input disabled /> | ||
</Form.Item> | ||
<Form.Item label="username" name={'username'} rules={[{ max: 10 }]}> | ||
<Input /> | ||
</Form.Item> | ||
</> | ||
); | ||
} | ||
} | ||
|
||
const ModalForm = Modal.Form<CustomModalFormProps, FormValue>(FormItems); | ||
|
||
export default () => { | ||
const [visible, setVisible] = useState(false); | ||
return ( | ||
<> | ||
<Button onClick={() => setVisible(true)}>click</Button> | ||
<ModalForm | ||
title="BasicModalForm" | ||
visible={visible} | ||
onCancel={() => setVisible((v) => !v)} | ||
onSubmit={(value) => { | ||
console.log(value); | ||
}} | ||
customAttr={'customAttr'} | ||
/> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters