Skip to content

Commit

Permalink
feat: 添加 FormModal (#26)
Browse files Browse the repository at this point in the history
* feat: 优化

* fix: test

* style: 修改样式

* feat: 添加 FormModal

* test: 添加单元测试

* fix: text

* chore: test

* chore: 1.0.6

* test: test

* feat: test

* chore: test

Co-authored-by: crazyair <[email protected]>
  • Loading branch information
crazyair and crazyair authored Jun 10, 2020
1 parent ab960b3 commit 12a7816
Show file tree
Hide file tree
Showing 30 changed files with 5,539 additions and 765 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/codevoc.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: CI
name: codecov

on:
push:
branches-ignore:
branches:
- master

jobs:
Expand All @@ -23,5 +23,5 @@ jobs:
flags: unittests # optional
name: codecov-umbrella # optional
# file: ./codecov.yml # optional
# fail_ci_if_error: true # optional (default = false)
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true # optional (default = false)
21 changes: 21 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: test

on:
push:
branches-ignore:
- master

jobs:

test:
name: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 10
registry-url: https://registry.npmjs.org/
- run: yarn
- run: yarn test

28 changes: 28 additions & 0 deletions docs/apis/demo/modal_base.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* eslint-disable no-console */
import React, { useState } from 'react';
import { YForm } from 'yforms';
import { Button } from 'antd';

const Demo = () => {
const [visible, setVisible] = useState(false);
const onFinish = (values: any) => {
console.log('Success:', values);
};

return (
<div>
<Button type="link" onClick={() => setVisible(true)}>
打开弹窗
</Button>
<YForm.FormModal
visible={visible}
destroyOnClose
title="表单弹窗"
formProps={{ onFinish, onCancel: () => setVisible(false) }}
>
{[{ type: 'input', name: 'age', label: '姓名' }]}
</YForm.FormModal>
</div>
);
};
export default Demo;
22 changes: 22 additions & 0 deletions docs/apis/formModal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: FormModal
nav:
title: 文档
---

# FormModal

弹窗的表单

# 示例

## 基础使用

<code src="./demo/modal_base.tsx" />

## API

| 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| formFooter | 用来渲染到 `footer` 下面的按钮 | - | `[{ type: 'submit', componentProps: { reverseBtns: true } }]` |
| formProps | `YForm` 类型 | - | - |
2 changes: 1 addition & 1 deletion docs/apis/hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export default () => {
const {
submit,
params: { typeName },
} = YForm.useSubmit();
} = YForm.useSubmit({ params: { type: 'view', id: '1' } });

const onFinish = (values) => {
console.log('Success:', values);
Expand Down
4 changes: 1 addition & 3 deletions docs/examples/demo/demo1.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ const Demo = () => {
const [loading, setLoading] = useState(true);
const [form] = YForm.useForm();

const { submit, disabled } = YForm.useSubmit();

const { submit, disabled } = YForm.useSubmit({ params: { type: 'view', id: '1' } });
useEffect(() => {
setTimeout(() => {
setData(initialValues);
Expand Down Expand Up @@ -67,7 +66,6 @@ const Demo = () => {
onFinishFailed={onFinishFailed}
onSave={onSave}
scenes={{ view: disabled }}
params={{ type: 'view' }}
>
{[
// {
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/demo/demo3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const Demo: React.FC<RouteComponentProps> = () => {
{[{ type: 'input', name: 'age', label: '姓名' }]}
</YForm.Items>
<YForm.Items className="ant-modal-footer">
{[{ type: 'submit', className: 'mb0', componentProps: { reverseBtns: true } }]}
{[{ type: 'submit', componentProps: { reverseBtns: true } }]}
</YForm.Items>
</YForm>
</Modal>
Expand Down
Loading

0 comments on commit 12a7816

Please sign in to comment.