Skip to content

Commit

Permalink
feat: 改名 yforms (#14)
Browse files Browse the repository at this point in the history
* feat: change name yform

* feat: 0.7.0

* feat: 0.7.0

* chore(release): publish

 - [email protected]

* feat: 0.7.2

* feat: 报名 diy-form

* feat: 0.7.4

* docs: crazyair yform

* feat: package

* refactor: yforms

* fix: lerna

* feat: 删除 bootstrap

* feat: 获取表单格式化后的值

* feat: 精简 dmeo

* feat: format

* feat: format

* fix: eslint

* feat: 移动包

* feat: format

Co-authored-by: crazyair <[email protected]>
  • Loading branch information
crazyair and crazyair authored May 20, 2020
1 parent cd73423 commit 1c20a9f
Show file tree
Hide file tree
Showing 62 changed files with 258 additions and 190 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ module.exports = {
'jsx-a11y/click-events-have-key-events': 0,
'jsx-a11y/anchor-is-valid': 0,
'jsx-a11y/no-static-element-interactions': 0,
'arrow-parens': 0,
},
};
1 change: 0 additions & 1 deletion .github/workflows/codevoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ jobs:
node-version: 10
registry-url: https://registry.npmjs.org/
- run: yarn
- run: yarn bootstrap
- run: yarn test
- uses: codecov/codecov-action@v1
with:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
# branches:
# - master
# - master

name: Create Release

Expand Down Expand Up @@ -41,7 +41,6 @@ jobs:
node-version: 10
registry-url: https://registry.npmjs.org/
- run: yarn
- run: yarn bootstrap
- run: yarn pub from-package --force-publish --yes
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
[![codecov](https://codecov.io/gh/crazyair/father-doc-yform/branch/master/graph/badge.svg)](https://codecov.io/gh/crazyair/father-doc-yform)
[![codecov](https://codecov.io/gh/crazyair/yforms/branch/master/graph/badge.svg)](https://codecov.io/gh/crazyair/yforms)

## Usage & Guide

To check out live examples and docs, visit [yform now](https://father-doc-yform.now.sh/).
To check out live examples and docs, visit [yforms now](https://yforms.now.sh/).

## Development

```bash
$ npm install
$ npm run bootstrap
$ npm run dev
```

Expand Down
2 changes: 1 addition & 1 deletion config/config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default {
mode: 'site',
title: 'yform',
title: 'yforms',
favicon: '/favicon.ico',
logo: '/logo.png',
menus: {
Expand Down
22 changes: 20 additions & 2 deletions docs/apis/hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,24 @@ nav:

# Hooks

## useForm

- 获取表单实例

### 用例

```jsx | pure
const [form] = YForm.useForm();
// 获取表单格式化后的值
form.getFormatFieldsValue();
```

### API

| 参数 | 说明 | 类型 | 默认值 |
| -------------------- | -------------------- | ---- | ------ |
| getFormatFieldsValue | 获取表单格式化后的值 | - | - |

## useFormatFieldsValue

- 表单提交前处理数据
Expand All @@ -15,7 +33,7 @@ nav:
```tsx
import React from 'react';
import { Input } from 'antd';
import { YForm } from 'father-doc-yform';
import { YForm } from 'yforms';

const layout = { labelCol: { span: 4 }, wrapperCol: { span: 20 } };

Expand Down Expand Up @@ -69,7 +87,7 @@ export default () => {
```tsx
import React from 'react';
import { Input } from 'antd';
import { YForm } from 'father-doc-yform';
import { YForm } from 'yforms';

const layout = { labelCol: { span: 4 }, wrapperCol: { span: 20 } };

Expand Down
6 changes: 3 additions & 3 deletions docs/apis/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ nav:
- 自定义类型推荐添加前缀或后缀,方便与默认区分。

```tsx | pure
import { YForm } from 'father-doc-yform';
import { YFormItemsType } from 'father-doc-yform/lib/YForm/ItemsType';
import { YForm } from 'yforms';
import { YFormItemsType } from 'yforms/lib/YForm/ItemsType';

declare module 'father-doc-yform/lib/YForm/ItemsType' {
declare module 'yforms/lib/YForm/ItemsType' {
export interface YFormItemsTypeDefine {
my_demo: { componentProps?: { str?: string } };
}
Expand Down
4 changes: 2 additions & 2 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ nav:
order: 5
---

## [0.6.0](https://github.com/crazyair/father-doc-yform/compare/v0.5.9...v0.6.0) (2020-05-16)
## [0.6.0](https://github.com/crazyair/yforms/compare/v0.5.9...v0.6.0) (2020-05-16)

- submitFormatValues 根据 name 长度排序 ([#13](https://github.com/crazyair/father-doc-yform/issues/13)) ([fc1c411](https://github.com/crazyair/father-doc-yform/commit/fc1c41107d10fa798e9298266f7144e2cc5697f8))
- submitFormatValues 根据 name 长度排序 ([#13](https://github.com/crazyair/yforms/issues/13)) ([fc1c411](https://github.com/crazyair/yforms/commit/fc1c41107d10fa798e9298266f7144e2cc5697f8))

## 0.5.9

Expand Down
36 changes: 23 additions & 13 deletions docs/examples/demo/demo1.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
/* eslint-disable no-console */
import React, { useState, useEffect } from 'react';
import { YForm } from 'father-doc-yform';
import { YForm } from 'yforms';
import { message } from 'antd';
import moment from 'moment';

const layout = { labelCol: { span: 4 }, wrapperCol: { span: 20 } };

const Demo = () => {
const [data, setData] = useState({});
const [loading, setLoading] = useState(true);
const { formatFieldsValue, onFormatFieldsValue } = YForm.useFormatFieldsValue();
const [form] = YForm.useForm();

useEffect(() => {
setTimeout(() => {
setData({ name: '张三', age: '10', money: '10' });
setData({ name: '张三', age: '10', money: '10', date: moment() });
setLoading(false);
}, 10);
}, []);

onFormatFieldsValue([
{ name: 'append_field', format: () => '提交前追加字段' },
{ name: 'name', format: ({ name }) => `${name}_改变了` },
]);

const onFinish = (values: any) => {
console.log('Success:', values);
};
Expand All @@ -34,20 +31,33 @@ const Demo = () => {
return (
<YForm
{...layout}
loading={loading}
initialValues={data}
form={form}
name="basic"
initialValues={data}
onFinish={onFinish}
loading={loading}
onFinishFailed={onFinishFailed}
onSave={onSave}
formatFieldsValue={formatFieldsValue}
required
>
{[
{ type: 'input', label: 'name', name: 'name' },
{ type: 'input', label: 'age', name: 'age', componentProps: { suffix: '岁' } },
{ type: 'input', label: 'name', name: 'name', format: ({ name }) => `${name} 修改了` },
{
type: 'datePicker',
label: 'date',
name: 'date',
componentProps: { style: { width: '100%' } },
format: ({ date }) => moment(date).format('YYYY-MM-DD'),
},
{ type: 'money', label: 'money', name: 'money' },
{ type: 'submit' },
{
type: 'button',
componentProps: {
onClick: () => message.success(JSON.stringify(form.getFormatFieldsValue())),
children: '获取提交前数据',
},
},
]}
</YForm>
);
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 @@ -2,7 +2,7 @@
import React, { useState } from 'react';
import { Button, Modal } from 'antd';
import { RouteComponentProps } from 'react-router-dom';
import { YForm } from 'father-doc-yform';
import { YForm } from 'yforms';

const layout = { labelCol: { span: 4 }, wrapperCol: { span: 20 } };

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/demo/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import React, { useState, useEffect } from 'react';
import { message } from 'antd';
import { RouteComponentProps } from 'react-router-dom';
import { YForm } from 'father-doc-yform';
import { YForm } from 'yforms';

const layout = { labelCol: { span: 4 }, wrapperCol: { span: 20 } };

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/demo/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

/* eslint-disable no-console */
import React from 'react';
import { YForm } from 'father-doc-yform';
import { YForm } from 'yforms';
import { Form, Button, Row, Col } from 'antd';
import { DownOutlined, UpOutlined } from '@ant-design/icons';
import QueueAnim from 'rc-queue-anim';
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/demo/shouldUpdate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import React from 'react';
import { YForm } from 'father-doc-yform';
import { YForm } from 'yforms';

const layout = { labelCol: { span: 4 }, wrapperCol: { span: 20 } };

Expand Down
8 changes: 0 additions & 8 deletions docs/examples/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,3 @@ nav:
## 基础使用

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

## 弹窗使用

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

## 依赖使用

<code src="./demo/shouldUpdate.tsx" />
4 changes: 2 additions & 2 deletions docs/guide/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ nav:
在项目目录下执行以下命令进行安装:

```bash
$ yarn add father-doc-yform
$ yarn add yforms
```

## 示例

```jsx | pure
import React from 'react';
import { YForm } from 'father-doc-yform';
import { YForm } from 'yforms';

const Demo = () => {
return (
Expand Down
10 changes: 5 additions & 5 deletions docs/guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ nav:
order: 1
---

## 什么是 yform
## 什么是 yforms

yform 是一个基于 antd v4 开发,为 Form 场景提供可 DIY 配置的表单库,用户可在全局设置每个字段类型的默认行为。
yforms 是一个基于 antd v4 开发,为 Form 场景提供可 DIY 配置的表单库,用户可在全局设置每个字段类型的默认行为。

## 为什么做 yform
## 为什么做 yforms

- 前端项目中对代码统一有了 eslint、prettier、tslint。而表单在系统中各有各的样,而现在为了解决各个业务模块表单交互不统一 `yform` 诞生了。
- 前端项目中对代码统一有了 eslint、prettier、tslint。而表单在系统中各有各的样,而现在为了解决各个业务模块表单交互不统一 `yforms` 诞生了。
- 常常遇到有个表单中 `placeholder` 文案不统一,有的是:请输入姓名,而有的是:姓名必填、`rules` 中有的有 `whitespace` 有的则没有。
- 同样一个字段,在表单中需要添加 `{label:'姓名' placeholder:'请输入姓名'}`,而搜索场景下就变成只需要 `{placeholder:'姓名'}`
- 开发项目中表单字段有太多例如:input、select、radio、switch、upload 等,每个表单单独引入 Input、Upload,慢慢的一个表单中引用多个版本的组件展现形式、api、以及交互不统一。

## yform 解决了什么问题
## yforms 解决了什么问题

- 减少模板代码,一个表单中的字段可无缝应用于表单和搜索场景,2 种场景下的区别交给全局配置。
- 表单交互可全局自定义配置一套,其他人使用时候不用写 placeholder。
Expand Down
8 changes: 4 additions & 4 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
title: yform
title: yforms
order: 10
hero:
title: yform
desc: 一个基于 antd v4 封装的可以 DIY 的 Form,起名叫 yform
title: yforms
desc: 一个基于 antd v4 封装的可以 DIY 的 Form,起名叫 yforms

actions:
- text: 快速上手
Expand Down Expand Up @@ -31,7 +31,7 @@ features:

## 参与贡献

欢迎加入到 yform 的建设队伍中来,请访问 https://github.com/crazyair/father-doc-yform
欢迎加入到 yforms 的建设队伍中来,请访问 https://github.com/crazyair/yforms

```jsx | inline
import React from 'react';
Expand Down
2 changes: 1 addition & 1 deletion docs/types/demo/custom.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { YForm } from 'father-doc-yform';
import { YForm } from 'yforms';

const layout = { labelCol: { span: 4 }, wrapperCol: { span: 20 } };

Expand Down
2 changes: 1 addition & 1 deletion docs/types/demo/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-console */
import React from 'react';
import { Input } from 'antd';
import { YForm } from 'father-doc-yform';
import { YForm } from 'yforms';

const layout = { labelCol: { span: 4 }, wrapperCol: { span: 20 } };

Expand Down
4 changes: 2 additions & 2 deletions docs/types/demo/list.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable no-console */
import React, { useState } from 'react';
import { Card } from 'antd';
import { YForm } from 'father-doc-yform';
import { YFormListProps, YFormListComponentProps } from 'father-doc-yform/lib/YForm/component/List';
import { YForm } from 'yforms';
import { YFormListComponentProps, YFormListProps } from 'yforms/lib/YForm/component/List';

const layout = { labelCol: { span: 4 }, wrapperCol: { span: 20 } };

Expand Down
4 changes: 2 additions & 2 deletions docs/types/demo/oneLine.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { YForm } from 'father-doc-yform';
import { YFormOneLineProps } from 'father-doc-yform/lib/YForm/component/OneLine';
import { YForm } from 'yforms';
import { YFormOneLineProps } from 'yforms/lib/YForm/component/OneLine';

const layout = { labelCol: { span: 4 }, wrapperCol: { span: 20 } };

Expand Down
2 changes: 1 addition & 1 deletion docs/types/demo/secureButton.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { YForm } from 'father-doc-yform';
import { YForm } from 'yforms';

const layout = { labelCol: { span: 4 }, wrapperCol: { span: 20 } };

Expand Down
2 changes: 1 addition & 1 deletion docs/types/demo/submit.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-console */
import React from 'react';
import { YForm } from 'father-doc-yform';
import { YForm } from 'yforms';

const layout = { labelCol: { span: 4 }, wrapperCol: { span: 20 } };

Expand Down
4 changes: 4 additions & 0 deletions docs/types/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ nav:

## API

| 参数 | 说明 | 类型 | 默认值 |
| ------ | ---------------- | ------------- | ------ |
| format | 提交前格式化数据 | (value?:T)=>T | - |

### 共同的 API

- 以下 API 为 `checkboxGroup` `radio` `select` 共享的 API。
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ module.exports = {
setupFiles: ['./setupTests.js'],
modulePathIgnorePatterns: ['/docs/', '/__snapshots__/'],
// coveragePathIgnorePatterns: ['/src/JackBox/'],
// testPathIgnorePatterns: ['/packages/yform'],
// testPathIgnorePatterns: ['/packages/yforms'],
collectCoverage: true,
};
3 changes: 2 additions & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"pr(dependency)": ":deciduous_tree: Dependency",
"pr(chore)": ":turtle: Chore"
},
"repo": "crazyair/father-doc-yform",
"repo": "crazyair/yforms",
"cacheDir": ".changelog"
},
"packages": ["packages/*"],
Expand All @@ -24,5 +24,6 @@
"publishConfig": {
"registry": "https://registry.npmjs.org"
},
"useWorkspaces": true,
"version": "independent"
}
Loading

1 comment on commit 1c20a9f

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for website ready!

Built with commit 1c20a9f

https://father-doc-yform-pe4aquwja.now.sh

Please sign in to comment.