diff --git a/.eslintrc.js b/.eslintrc.js index 443f8748..f30d7a7e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -7,5 +7,6 @@ module.exports = { 'no-template-curly-in-string': 0, 'prefer-promise-reject-errors': 0, 'react/no-array-index-key': 0, + 'react/sort-comp': 0, }, }; diff --git a/README.md b/README.md index 3abe4b85..ca6c1043 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ open http://localhost:9001/ ```js import Form, { Field } from 'rc-field-form'; - { console.log('Finish:', values); }} @@ -50,7 +50,7 @@ import Form, { Field } from 'rc-field-form'; -; +; export default Demo; ``` diff --git a/examples/StateForm-basic.tsx b/examples/StateForm-basic.tsx index 9835622a..96b5cd27 100644 --- a/examples/StateForm-basic.tsx +++ b/examples/StateForm-basic.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import StateForm, { Field } from '../src/'; +import Form, { Field } from '../src/'; import Input from './components/Input'; @@ -12,7 +12,7 @@ export default class Demo extends React.Component { return (

State Form ({list.length} inputs)

- +
@@ -48,7 +48,7 @@ export default class Demo extends React.Component { ))} - +
); } diff --git a/examples/StateForm-context.tsx b/examples/StateForm-context.tsx index 389a20cc..658a4be3 100644 --- a/examples/StateForm-context.tsx +++ b/examples/StateForm-context.tsx @@ -1,7 +1,7 @@ /* eslint-disable react/prop-types */ import React from 'react'; -import StateForm, { FormProvider } from '../src'; +import Form, { FormProvider } from '../src'; import Input from './components/Input'; import LabelField from './components/LabelField'; import { ValidateMessages } from '../src/interface'; @@ -16,10 +16,10 @@ const formStyle: React.CSSProperties = { }; const Form1 = () => { - const [form] = StateForm.useForm(); + const [form] = Form.useForm(); return ( - +

Form 1

Change me!

@@ -30,15 +30,15 @@ const Form1 = () => { - +
); }; const Form2 = () => { - const [form] = StateForm.useForm(); + const [form] = Form.useForm(); return ( - +

Form 2

Will follow Form 1 but not sync back

@@ -49,7 +49,7 @@ const Form2 = () => { - +
); }; diff --git a/examples/StateForm-layout.tsx b/examples/StateForm-layout.tsx index c4c84beb..334ed92e 100644 --- a/examples/StateForm-layout.tsx +++ b/examples/StateForm-layout.tsx @@ -1,7 +1,7 @@ /* eslint-disable jsx-a11y/label-has-associated-control, react/prop-types */ import React from 'react'; -import StateForm from '../src'; +import Form from '../src'; import Input from './components/Input'; import LabelField from './components/LabelField'; @@ -14,7 +14,7 @@ export default class Demo extends React.Component { return (

State Form ({list.length} inputs)

- +
@@ -24,7 +24,7 @@ export default class Demo extends React.Component { - +
); } diff --git a/examples/StateForm-list.tsx b/examples/StateForm-list.tsx index beea04e5..5c02ce14 100644 --- a/examples/StateForm-list.tsx +++ b/examples/StateForm-list.tsx @@ -1,11 +1,11 @@ /* eslint-disable react/prop-types */ import React from 'react'; -import StateForm from '../src/'; +import Form from '../src/'; import Input from './components/Input'; import LabelField from './components/LabelField'; -const { List, useForm } = StateForm; +const { List, useForm } = Form; const Demo = () => { const [form] = useForm(); @@ -15,7 +15,7 @@ const Demo = () => {

List of Form

You can set Field as List

- { console.log('values:', values); @@ -62,7 +62,7 @@ const Demo = () => { ); }} - +

Out Of Form

diff --git a/examples/StateForm-redux.tsx b/examples/StateForm-redux.tsx index f3eac655..3c46c5fc 100644 --- a/examples/StateForm-redux.tsx +++ b/examples/StateForm-redux.tsx @@ -3,7 +3,7 @@ import React from 'react'; import { connect, Provider } from 'react-redux'; import { createStore } from 'redux'; -import StateForm from '../src/'; +import Form from '../src/'; import Input from './components/Input'; import LabelField from './components/LabelField'; @@ -22,7 +22,7 @@ let App: any = ({ dispatch, fields }) => { console.log('=>', fields); return ( - { console.log('Value Change:', changedValues, allValues); @@ -42,8 +42,8 @@ let App: any = ({ dispatch, fields }) => { - - + + - + ); }; App = connect((fields: any) => ({ fields }))(App); diff --git a/examples/StateForm-renderProps.tsx b/examples/StateForm-renderProps.tsx index ca192011..cf911558 100644 --- a/examples/StateForm-renderProps.tsx +++ b/examples/StateForm-renderProps.tsx @@ -1,9 +1,9 @@ /* eslint-disable jsx-a11y/label-has-associated-control */ import React from 'react'; -import StateForm from '../src'; +import Form from '../src'; import Input from './components/Input'; -const { Field } = StateForm; +const { Field } = Form; const list = new Array(1111).fill(() => undefined); @@ -15,7 +15,7 @@ export default class Demo extends React.Component {

Render Props ({list.length} inputs)

Render Props is easy to use but bad performance

- +
{(values) => { return ( @@ -55,7 +55,7 @@ export default class Demo extends React.Component { ); }} - +
); } diff --git a/examples/StateForm-reset.tsx b/examples/StateForm-reset.tsx index 4db55c1b..32b41660 100644 --- a/examples/StateForm-reset.tsx +++ b/examples/StateForm-reset.tsx @@ -1,9 +1,9 @@ /* eslint-disable react/prop-types */ import React from 'react'; -import StateForm from '../src'; +import Form from '../src'; import Input from './components/Input'; -const { Field } = StateForm; +const { Field } = Form; function Item({ children, ...restProps }) { return ( @@ -24,11 +24,11 @@ function Item({ children, ...restProps }) { } const Demo = () => { - const [form] = StateForm.useForm(); + const [form] = Form.useForm(); return (

Reset / Set Form

- +
@@ -64,7 +64,7 @@ const Demo = () => { > Set Password with Errors - +
); }; diff --git a/examples/StateForm-useForm.tsx b/examples/StateForm-useForm.tsx index c2740df4..b66ed8c5 100644 --- a/examples/StateForm-useForm.tsx +++ b/examples/StateForm-useForm.tsx @@ -1,8 +1,8 @@ import React from 'react'; -import StateForm from '../src'; +import Form from '../src'; import Input from './components/Input'; -const { Field, useForm } = StateForm; +const { Field, useForm } = Form; const list = new Array(0).fill(() => undefined); @@ -22,7 +22,7 @@ export default () => { Fill Values - +
@@ -43,7 +43,7 @@ export default () => { ))} - +
); }; diff --git a/examples/StateForm-validate-perf.tsx b/examples/StateForm-validate-perf.tsx index a2485d76..0523f493 100644 --- a/examples/StateForm-validate-perf.tsx +++ b/examples/StateForm-validate-perf.tsx @@ -1,7 +1,7 @@ /* eslint-disable react/prop-types */ import React from 'react'; -import StateForm, { FormInstance } from '../src/'; +import Form, { FormInstance } from '../src/'; import Input from './components/Input'; import LabelField from './components/LabelField'; import { ValidateMessages } from '../src/interface'; @@ -34,7 +34,7 @@ export default class Demo extends React.Component { return (

High Perf Validate Form

- Reset - +
); } diff --git a/examples/StateForm-validate.tsx b/examples/StateForm-validate.tsx index 253efa53..2302bac9 100644 --- a/examples/StateForm-validate.tsx +++ b/examples/StateForm-validate.tsx @@ -1,10 +1,10 @@ /* eslint-disable react/prop-types */ import React from 'react'; -import StateForm from '../src'; +import Form from '../src'; import Input from './components/Input'; -const { Field } = StateForm; +const { Field } = Form; const Error = ({ children }) => (