Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
};
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ open http://localhost:9001/
```js
import Form, { Field } from 'rc-field-form';

<StateForm
<Form
onFinish={values => {
console.log('Finish:', values);
}}
Expand All @@ -50,7 +50,7 @@ import Form, { Field } from 'rc-field-form';
</Field>

<button>Submit</button>
</StateForm>;
</Form>;

export default Demo;
```
Expand Down
6 changes: 3 additions & 3 deletions examples/StateForm-basic.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import StateForm, { Field } from '../src/';
import Form, { Field } from '../src/';
import Input from './components/Input';


Expand All @@ -12,7 +12,7 @@ export default class Demo extends React.Component {
return (
<div>
<h3>State Form ({list.length} inputs)</h3>
<StateForm>
<Form>
<Field name="username">
<Input placeholder="Username" />
</Field>
Expand Down Expand Up @@ -48,7 +48,7 @@ export default class Demo extends React.Component {
<Input placeholder={`field_${index}`} />
</Field>
))}
</StateForm>
</Form>
</div>
);
}
Expand Down
14 changes: 7 additions & 7 deletions examples/StateForm-context.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -16,10 +16,10 @@ const formStyle: React.CSSProperties = {
};

const Form1 = () => {
const [form] = StateForm.useForm();
const [form] = Form.useForm();

return (
<StateForm form={form} style={{ ...formStyle, border: '1px solid #000' }} name="first">
<Form form={form} style={{ ...formStyle, border: '1px solid #000' }} name="first">
<h4>Form 1</h4>
<p>Change me!</p>
<LabelField name="username" rules={[{ required: true }]}>
Expand All @@ -30,15 +30,15 @@ const Form1 = () => {
</LabelField>

<button type="submit">Submit</button>
</StateForm>
</Form>
);
};

const Form2 = () => {
const [form] = StateForm.useForm();
const [form] = Form.useForm();

return (
<StateForm form={form} style={{ ...formStyle, border: '1px solid #F00' }} name="second">
<Form form={form} style={{ ...formStyle, border: '1px solid #F00' }} name="second">
<h4>Form 2</h4>
<p>Will follow Form 1 but not sync back</p>
<LabelField name="username" rules={[{ required: true }]}>
Expand All @@ -49,7 +49,7 @@ const Form2 = () => {
</LabelField>

<button type="submit">Submit</button>
</StateForm>
</Form>
);
};

Expand Down
6 changes: 3 additions & 3 deletions examples/StateForm-layout.tsx
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -14,7 +14,7 @@ export default class Demo extends React.Component {
return (
<div>
<h3>State Form ({list.length} inputs)</h3>
<StateForm>
<Form>
<LabelField name="username">
<Input placeholder="Username" />
</LabelField>
Expand All @@ -24,7 +24,7 @@ export default class Demo extends React.Component {
<LabelField name={['path1', 'path2']} label="Nest Path" rules={[ { required: true } ]}>
<Input placeholder="nest" />
</LabelField>
</StateForm>
</Form>
</div>
);
}
Expand Down
8 changes: 4 additions & 4 deletions examples/StateForm-list.tsx
Original file line number Diff line number Diff line change
@@ -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();
Expand All @@ -15,7 +15,7 @@ const Demo = () => {
<h3>List of Form</h3>
<p>You can set Field as List</p>

<StateForm
<Form
form={form}
onValuesChange={(_, values) => {
console.log('values:', values);
Expand Down Expand Up @@ -62,7 +62,7 @@ const Demo = () => {
);
}}
</List>
</StateForm>
</Form>

<div style={{ border: '1px solid #000', padding: 15 }}>
<h4>Out Of Form</h4>
Expand Down
10 changes: 5 additions & 5 deletions examples/StateForm-redux.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -22,7 +22,7 @@ let App: any = ({ dispatch, fields }) => {
console.log('=>', fields);

return (
<StateForm
<Form
fields={fields}
onValuesChange={(changedValues, allValues) => {
console.log('Value Change:', changedValues, allValues);
Expand All @@ -42,8 +42,8 @@ let App: any = ({ dispatch, fields }) => {
<Input />
</LabelField>

<LabelField name="required" placeholder="required" rules={[{ required: true }]}>
<Input />
<LabelField name="required" rules={[{ required: true }]}>
<Input placeholder="required" />
</LabelField>

<button
Expand Down Expand Up @@ -71,7 +71,7 @@ let App: any = ({ dispatch, fields }) => {
>
dispatch to change
</button>
</StateForm>
</Form>
);
};
App = connect((fields: any) => ({ fields }))(App);
Expand Down
8 changes: 4 additions & 4 deletions examples/StateForm-renderProps.tsx
Original file line number Diff line number Diff line change
@@ -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);

Expand All @@ -15,7 +15,7 @@ export default class Demo extends React.Component {
<div>
<h3>Render Props ({list.length} inputs)</h3>
<p>Render Props is easy to use but bad performance</p>
<StateForm>
<Form>
{(values) => {
return (
<React.Fragment>
Expand Down Expand Up @@ -55,7 +55,7 @@ export default class Demo extends React.Component {
</React.Fragment>
);
}}
</StateForm>
</Form>
</div>
);
}
Expand Down
10 changes: 5 additions & 5 deletions examples/StateForm-reset.tsx
Original file line number Diff line number Diff line change
@@ -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 (
Expand All @@ -24,11 +24,11 @@ function Item({ children, ...restProps }) {
}

const Demo = () => {
const [form] = StateForm.useForm();
const [form] = Form.useForm();
return (
<div>
<h3>Reset / Set Form</h3>
<StateForm form={form} initialValues={{ username: 'strange', path1: { path2: '233' } }}>
<Form form={form} initialValues={{ username: 'strange', path1: { path2: '233' } }}>
<Item name="username" rules={[{ required: true }]}>
<Input placeholder="Username" />
</Item>
Expand Down Expand Up @@ -64,7 +64,7 @@ const Demo = () => {
>
Set Password with Errors
</button>
</StateForm>
</Form>
</div>
);
};
Expand Down
8 changes: 4 additions & 4 deletions examples/StateForm-useForm.tsx
Original file line number Diff line number Diff line change
@@ -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);

Expand All @@ -22,7 +22,7 @@ export default () => {
Fill Values
</button>

<StateForm form={form}>
<Form form={form}>
<React.Fragment>
<Field name="username">
<Input placeholder="Username" />
Expand All @@ -43,7 +43,7 @@ export default () => {
</Field>
))}
</React.Fragment>
</StateForm>
</Form>
</div>
);
};
6 changes: 3 additions & 3 deletions examples/StateForm-validate-perf.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -34,7 +34,7 @@ export default class Demo extends React.Component {
return (
<div>
<h3>High Perf Validate Form</h3>
<StateForm
<Form
ref={this.setForm}
style={{ padding: 16 }}
onFinish={this.onFinish}
Expand Down Expand Up @@ -87,7 +87,7 @@ export default class Demo extends React.Component {
>
Reset
</button>
</StateForm>
</Form>
</div>
);
}
Expand Down
8 changes: 4 additions & 4 deletions examples/StateForm-validate.tsx
Original file line number Diff line number Diff line change
@@ -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 }) => (
<ul style={{ color: 'red' }}>
Expand Down Expand Up @@ -35,7 +35,7 @@ export default class Demo extends React.Component {
return (
<div>
<h3>Validate Form</h3>
<StateForm style={{ padding: 16 }} onFinish={this.onFinish}>
<Form style={{ padding: 16 }} onFinish={this.onFinish}>
{(values, form) => {
const usernameError = form.getFieldError('username');
const passwordError = form.getFieldError('password');
Expand Down Expand Up @@ -161,7 +161,7 @@ export default class Demo extends React.Component {
</React.Fragment>
);
}}
</StateForm>
</Form>
</div>
);
}
Expand Down
4 changes: 2 additions & 2 deletions examples/components/LabelField.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from 'react';
import StateForm, { FormInstance } from '../../src/';
import Form, { FormInstance } from '../../src/';
import { FieldProps } from '../../src/Field';

const { Field } = StateForm;
const { Field } = Form;

const Error = ({ children }) => (
<ul style={{ color: 'red' }}>
Expand Down
Loading