-
-## 弹窗使用
-
-
-
-## 依赖使用
-
-
diff --git a/docs/guide/getting-started.md b/docs/guide/getting-started.md
index 30c68f6..869c0b3 100644
--- a/docs/guide/getting-started.md
+++ b/docs/guide/getting-started.md
@@ -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 (
diff --git a/docs/guide/index.md b/docs/guide/index.md
index 800402a..861f56c 100644
--- a/docs/guide/index.md
+++ b/docs/guide/index.md
@@ -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。
diff --git a/docs/index.md b/docs/index.md
index 74be8a2..4fb5494 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -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: 快速上手
@@ -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';
diff --git a/docs/types/demo/custom.tsx b/docs/types/demo/custom.tsx
index 5703272..dbcd943 100644
--- a/docs/types/demo/custom.tsx
+++ b/docs/types/demo/custom.tsx
@@ -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 } };
diff --git a/docs/types/demo/index.tsx b/docs/types/demo/index.tsx
index 495a93a..682b8f1 100644
--- a/docs/types/demo/index.tsx
+++ b/docs/types/demo/index.tsx
@@ -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 } };
diff --git a/docs/types/demo/list.tsx b/docs/types/demo/list.tsx
index 65e624b..053910a 100644
--- a/docs/types/demo/list.tsx
+++ b/docs/types/demo/list.tsx
@@ -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 } };
diff --git a/docs/types/demo/oneLine.tsx b/docs/types/demo/oneLine.tsx
index 9210828..ff42feb 100644
--- a/docs/types/demo/oneLine.tsx
+++ b/docs/types/demo/oneLine.tsx
@@ -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 } };
diff --git a/docs/types/demo/secureButton.tsx b/docs/types/demo/secureButton.tsx
index ac9bb38..4851373 100644
--- a/docs/types/demo/secureButton.tsx
+++ b/docs/types/demo/secureButton.tsx
@@ -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 } };
diff --git a/docs/types/demo/submit.tsx b/docs/types/demo/submit.tsx
index db4f2c6..cf1abfa 100644
--- a/docs/types/demo/submit.tsx
+++ b/docs/types/demo/submit.tsx
@@ -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 } };
diff --git a/docs/types/index.md b/docs/types/index.md
index 7a71107..58be5f8 100644
--- a/docs/types/index.md
+++ b/docs/types/index.md
@@ -13,6 +13,10 @@ nav:
## API
+| 参数 | 说明 | 类型 | 默认值 |
+| ------ | ---------------- | ------------- | ------ |
+| format | 提交前格式化数据 | (value?:T)=>T | - |
+
### 共同的 API
- 以下 API 为 `checkboxGroup` `radio` `select` 共享的 API。
diff --git a/jest.config.js b/jest.config.js
index 3113bd6..4531e6e 100644
--- a/jest.config.js
+++ b/jest.config.js
@@ -5,6 +5,6 @@ module.exports = {
setupFiles: ['./setupTests.js'],
modulePathIgnorePatterns: ['/docs/', '/__snapshots__/'],
// coveragePathIgnorePatterns: ['/src/JackBox/'],
- // testPathIgnorePatterns: ['/packages/yform'],
+ // testPathIgnorePatterns: ['/packages/yforms'],
collectCoverage: true,
};
diff --git a/lerna.json b/lerna.json
index a9422a7..849d806 100644
--- a/lerna.json
+++ b/lerna.json
@@ -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/*"],
@@ -24,5 +24,6 @@
"publishConfig": {
"registry": "https://registry.npmjs.org"
},
+ "useWorkspaces": true,
"version": "independent"
}
diff --git a/package.json b/package.json
index cce31fc..5550111 100644
--- a/package.json
+++ b/package.json
@@ -1,22 +1,24 @@
{
- "name": "father-doc-yform",
+ "workspaces": [
+ "packages/*"
+ ],
+ "private": true,
"repository": {
"type": "git",
- "url": "git+https://github.com/crazyair/father-doc-yform.git"
+ "url": "git+https://github.com/crazyair/yforms.git"
},
"scripts": {
- "bootstrap": "lerna bootstrap",
"start": "dumi dev",
"build": "father-build",
"doc:build": "dumi build",
- "now-build": "yarn && yarn bootstrap && yarn doc:build",
+ "now-build": "yarn && yarn doc:build",
"fa:build": "father build",
"test": "umi-test",
"lint": "eslint --ext .js,jsx,ts,tsx packages/**/src --fix",
"lint:es": "eslint --ext .js,jsx,ts,tsx packages/**/src",
"lint:tsc": "tsc -p tsconfig.json --noEmit",
"changelog": "lerna-changelog",
- "pub": "npm run changelog && npm run build && lerna publish"
+ "pub": "npm run build && lerna publish"
},
"lint-staged": {
"*.{ts,tsx,js,jsx}": [
@@ -37,11 +39,11 @@
"@babel/plugin-proposal-optional-chaining": "^7.6.0",
"@commitlint/cli": "^8.3.5",
"@commitlint/config-conventional": "^8.3.4",
- "@testing-library/react": "^9.4.0",
+ "@testing-library/react": "^10.0.4",
"@testing-library/react-hooks": "^3.1.1",
"@types/classnames": "^2.2.9",
"@types/enzyme": "^3.10.5",
- "@types/jest": "^24.0.13",
+ "@types/jest": "^25.2.3",
"@types/lodash": "^4.14.149",
"@types/react": "^16.7.18",
"@types/react-dom": "^16.0.11",
@@ -51,36 +53,44 @@
"@typescript-eslint/eslint-plugin": "^2.13.0",
"@typescript-eslint/parser": "^2.18.0",
"@umijs/fabric": "^2.0.3",
- "antd": "^4.0.2",
- "babel-eslint": "^9.0.0",
+ "babel-eslint": "^10.1.0",
"babel-plugin-import": "^1.13.0",
- "cross-env": "^6.0.3",
+ "cross-env": "^7.0.2",
"dumi": "^1.0.25",
"enzyme": "^3.11.0",
"eslint": "^6.7.2",
"eslint-config-umi": "^1.6.0",
- "eslint-plugin-flowtype": "^2.50.0",
+ "eslint-plugin-flowtype": "^5.1.0",
"eslint-plugin-import": "^2.14.0",
- "eslint-plugin-jsx-a11y": "^5.1.1",
+ "eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.11.1",
- "eslint-plugin-react-hooks": "^2.3.0",
+ "eslint-plugin-react-hooks": "^4.0.2",
"father-build": "^1.17.2",
"husky": "^4.2.3",
"lerna": "^3.20.2",
- "lerna-changelog": "^0.8.2",
+ "lerna-changelog": "^1.0.1",
"lint-staged": "^10.0.8",
- "prettier": "^1.19.1",
+ "prettier": "^2.0.5",
"rc-util": "^4.19.0",
"react": "^16.12.0",
"react-dom": "^16.12.0",
- "react-router-dom": "^5.1.2",
+ "react-router-dom": "^5.2.0",
"react-test-renderer": "^16.7.0",
"typescript": "^3.7.5",
"umi": "^3.1.4",
+ "@babel/polyfill": "^7.8.3",
"umi-test": "^1.9.3"
},
"license": "MIT",
"dependencies": {
+ "warning": "^4.0.3",
+ "antd": "^4.2.4",
+ "@ant-design/icons": "^4.0.3",
+ "lodash": "^4.17.15",
+ "moment": "^2.24.0",
+ "numbro": "^2.2.0",
+ "nzh": "^1.0.4",
+ "dayjs": "^1.8.27",
"rc-queue-anim": "^1.8.4"
}
}
diff --git a/packages/yform/README.md b/packages/yform/README.md
deleted file mode 100644
index debaa25..0000000
--- a/packages/yform/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# yform
-
-See our [main repo](https://github.com/crazyair/father-doc-yform) for more information.
diff --git a/packages/yform/package.json b/packages/yform/package.json
deleted file mode 100644
index 16c2656..0000000
--- a/packages/yform/package.json
+++ /dev/null
@@ -1,45 +0,0 @@
-{
- "name": "father-doc-yform",
- "version": "0.7.0",
- "description": "自定义表单组件",
- "main": "lib/index.js",
- "typings": "lib/index.d.ts",
- "authors": {
- "name": "crazyair",
- "email": "645381995@qq.com"
- },
- "files": [
- "es",
- "lib",
- "dist"
- ],
- "scripts": {
- "lint:tsc": "tsc -p tsconfig.json --noEmit",
- "build": "father-build"
- },
- "repository": {
- "type": "git",
- "url": "http://github.com/crazyair/father-doc-yform",
- "directory": "yform"
- },
- "homepage": "http://github.com/crazyair/father-doc-yform",
- "bugs": "http://github.com/crazyair/father-doc-yform/issues",
- "dependencies": {
- "@ant-design/icons": "^4.0.3",
- "@babel/runtime": "^7.8.4",
- "antd": "^4.2.2",
- "classnames": "^2.2.6",
- "lodash": "^4.17.15",
- "moment": "^2.24.0",
- "numbro": "^2.2.0",
- "nzh": "^1.0.4",
- "warning": "^4.0.3"
- },
- "devDependencies": {
- "@babel/polyfill": "^7.8.3"
- },
- "publishConfig": {
- "registry": "https://registry.npmjs.org/"
- },
- "license": "MIT"
-}
diff --git a/packages/yform/src/index.tsx b/packages/yform/src/index.tsx
deleted file mode 100644
index 3fd614d..0000000
--- a/packages/yform/src/index.tsx
+++ /dev/null
@@ -1,4 +0,0 @@
-export { default as YForm } from './YForm';
-
-// import YForm from './YForm';
-// export default YForm;
diff --git a/packages/yform/.fatherrc.ts b/packages/yforms/.fatherrc.ts
similarity index 100%
rename from packages/yform/.fatherrc.ts
rename to packages/yforms/.fatherrc.ts
diff --git a/packages/yforms/README.md b/packages/yforms/README.md
new file mode 100644
index 0000000..0bd16ae
--- /dev/null
+++ b/packages/yforms/README.md
@@ -0,0 +1,3 @@
+# yforms
+
+See our [main repo](https://github.com/crazyair/yforms) for more information.
diff --git a/packages/yforms/package.json b/packages/yforms/package.json
new file mode 100644
index 0000000..8433c36
--- /dev/null
+++ b/packages/yforms/package.json
@@ -0,0 +1,32 @@
+{
+ "name": "yforms",
+ "version": "0.8.0",
+ "description": "自定义表单组件",
+ "main": "lib/index.js",
+ "typings": "lib/index.d.ts",
+ "authors": {
+ "name": "crazyair",
+ "email": "645381995@qq.com"
+ },
+ "files": [
+ "es",
+ "lib",
+ "dist"
+ ],
+ "scripts": {
+ "lint:tsc": "tsc -p tsconfig.json --noEmit",
+ "build": "father-build"
+ },
+ "repository": {
+ "type": "git",
+ "url": "http://github.com/crazyair/yforms",
+ "directory": "yforms"
+ },
+ "homepage": "http://github.com/crazyair/yforms",
+ "bugs": "http://github.com/crazyair/yforms/issues",
+ "publishConfig": {
+ "access": "public",
+ "registry": "https://registry.npmjs.org/"
+ },
+ "license": "MIT"
+}
diff --git a/packages/yform/src/YForm/Context.ts b/packages/yforms/src/YForm/Context.ts
similarity index 100%
rename from packages/yform/src/YForm/Context.ts
rename to packages/yforms/src/YForm/Context.ts
diff --git a/packages/yform/src/YForm/Form.tsx b/packages/yforms/src/YForm/Form.tsx
similarity index 82%
rename from packages/yform/src/YForm/Form.tsx
rename to packages/yforms/src/YForm/Form.tsx
index c812686..6ce68cb 100644
--- a/packages/yform/src/YForm/Form.tsx
+++ b/packages/yforms/src/YForm/Form.tsx
@@ -1,15 +1,16 @@
import { Form, Spin } from 'antd';
import React, { useRef, useEffect, useCallback, useState } from 'react';
-import { merge } from 'lodash';
+import { merge, concat } from 'lodash';
import classNames from 'classnames';
-import { FormProps } from 'antd/lib/form';
+import { FormProps, FormInstance } from 'antd/lib/form';
import baseItemsType, { YFormItemsType, YFormFieldBaseProps, modifyType } from './ItemsType';
import Items, { FormatFieldsValue, YFormItemProps } from './Items';
import { YFormContext } from './Context';
import { onFormatFieldsValue, submitFormatValues, paramsType } from './utils';
import { YFormSubmitProps } from './component/Submit';
+import useForm from './useForm';
type pluginsType = boolean | YFormFieldBaseProps['modifyProps'];
@@ -66,12 +67,20 @@ export interface ParamsObjType {
typeName?: string;
}
-export interface YFormProps extends FormProps, YFormConfig {
+export interface YFormInstance