|
@@ -1,6 +1,6 @@
|
|
|
---
|
|
|
localeCode: en-US
|
|
|
-order: 22
|
|
|
+order: 23
|
|
|
category: Input
|
|
|
title: Form
|
|
|
subTitle: Form
|
|
@@ -107,14 +107,14 @@ import { Form } from '@douyinfe/semi-ui';
|
|
|
() => (
|
|
|
<Form render={({ formState, formApi, values }) => (
|
|
|
<>
|
|
|
- <Form.Select field="role" label='Role' style={{width:120}}>
|
|
|
+ <Form.Select field="role" label='Role' style={{ width:120 }}>
|
|
|
<Form.Select.Option value="admin">Admin</Form.Select.Option>
|
|
|
<Form.Select.Option value="user">User</Form.Select.Option>
|
|
|
<Form.Select.Option value="guest">Guest</Form.Select.Option>
|
|
|
</Form.Select>
|
|
|
<Form.Input field='userName' label='UserName' />
|
|
|
<Form.Input field='password' label='Password' />
|
|
|
- <code style={{marginTop: 30}}>{JSON.stringify(formState)}</code>
|
|
|
+ <code style={{ marginTop: 30 }}>{JSON.stringify(formState)}</code>
|
|
|
</>
|
|
|
)} layout='horizontal'>
|
|
|
</Form>
|
|
@@ -134,14 +134,14 @@ import { Form } from '@douyinfe/semi-ui';
|
|
|
{
|
|
|
({ formState, values, formApi }) => (
|
|
|
<>
|
|
|
- <Form.Select field="role" label='Role' style={{width:120}}>
|
|
|
+ <Form.Select field="role" label='Role' style={{ width:120 }}>
|
|
|
<Form.Select.Option value="admin">Admin</Form.Select.Option>
|
|
|
<Form.Select.Option value="user">User</Form.Select.Option>
|
|
|
<Form.Select.Option value="guest">Guest</Form.Select.Option>
|
|
|
</Form.Select>
|
|
|
<Form.Input field='userName' label='UserName' />
|
|
|
<Form.Input field='password' label='Password' />
|
|
|
- <code style={{marginTop: 30}}>{JSON.stringify(formState)}</code>
|
|
|
+ <code style={{ marginTop: 30 }}>{JSON.stringify(formState)}</code>
|
|
|
</>
|
|
|
)
|
|
|
}
|
|
@@ -165,7 +165,7 @@ class Demo extends React.Component {
|
|
|
<Form.Input field='Role'/>
|
|
|
<Form.Input field='UserName' />
|
|
|
<Form.Input field='Password' />
|
|
|
- <code style={{marginTop: 30}}>{JSON.stringify(formState)}</code>
|
|
|
+ <code style={{ marginTop: 30 }}>{JSON.stringify(formState)}</code>
|
|
|
</>
|
|
|
);
|
|
|
return <Form component={fields} layout='horizontal'/>;
|
|
@@ -410,7 +410,7 @@ import { Form, Row, Col, Toast, TextArea } from '@douyinfe/semi-ui';
|
|
|
<Form.Input field='parents[0].name' placeholder='Try input something'/>
|
|
|
<Form.Input field="parents[1]['name']" placeholder='Try input something'/>
|
|
|
</Col>
|
|
|
- <Col span={10} offset={1} style={{marginTop: 12}}>
|
|
|
+ <Col span={10} offset={1} style={{ marginTop: 12 }}>
|
|
|
<Form.Label text='formState.values in real time:'></Form.Label>
|
|
|
<TextArea value={JSON.stringify(formState.values)}></TextArea>
|
|
|
</Col>
|
|
@@ -436,8 +436,8 @@ import { Form, Button, Toast } from '@douyinfe/semi-ui';
|
|
|
Toast.info('Submit Success');
|
|
|
};
|
|
|
return (
|
|
|
- <Form onSubmit={values => handleSubmit(values)} style={{width: 400}}>
|
|
|
- {({formState, values, formApi}) => (
|
|
|
+ <Form onSubmit={values => handleSubmit(values)} style={{ width: 400 }}>
|
|
|
+ {({ formState, values, formApi }) => (
|
|
|
<>
|
|
|
<Form.Input field='phone' label='PhoneNumber' style={{ width: '100%' }} placeholder='Enter your phone number'></Form.Input>
|
|
|
<Form.Input field='password' label='Password' style={{ width: '100%' }} placeholder='Enter your password'></Form.Input>
|
|
@@ -503,14 +503,14 @@ class BasicDemo extends React.Component {
|
|
|
const { labelPosition, labelAlign, labelWidth } = this.state;
|
|
|
return (
|
|
|
<>
|
|
|
- <div style={{borderBottom: '1px solid var(--semi-color-text-3)', paddingBottom: 10 }}>
|
|
|
+ <div style={{ borderBottom: '1px solid var(--semi-color-text-3)', paddingBottom: 10 }}>
|
|
|
<Form.Label style={{ marginLeft: 10 }}>Switch Label Position:</Form.Label>
|
|
|
- <Select onChange={this.changeLabelPos} value={labelPosition} style={{width: 100}}>
|
|
|
+ <Select onChange={this.changeLabelPos} value={labelPosition} style={{ width: 100 }}>
|
|
|
<Select.Option value='top'>top</Select.Option>
|
|
|
<Select.Option value='left'>left</Select.Option>
|
|
|
</Select>
|
|
|
<Form.Label style={{ marginLeft: 10 }}>Switch Label Text Align</Form.Label>
|
|
|
- <Select onChange={this.changeLabelAlign} value={labelAlign} style={{width: 100}}>
|
|
|
+ <Select onChange={this.changeLabelAlign} value={labelAlign} style={{ width: 100 }}>
|
|
|
<Select.Option value='left'>left</Select.Option>
|
|
|
<Select.Option value='right'>right</Select.Option>
|
|
|
</Select>
|
|
@@ -524,7 +524,7 @@ class BasicDemo extends React.Component {
|
|
|
field="input"
|
|
|
label="PhoneNumber"
|
|
|
trigger='blur'
|
|
|
- style={{width: 200}}
|
|
|
+ style={{ width: 200 }}
|
|
|
rules={[
|
|
|
{ required: true, message: 'required Error' },
|
|
|
{ type: 'string', message: 'type error' },
|
|
@@ -532,11 +532,11 @@ class BasicDemo extends React.Component {
|
|
|
]}
|
|
|
/>
|
|
|
<Form.Switch label="Agree" field='agree'/>
|
|
|
- <Form.InputNumber field='price' label='price' style={{width: 200}}/>
|
|
|
- <Form.Select label="Name" field='name' style={{width: 200}}>
|
|
|
- <Option value="mike">mike</Option>
|
|
|
- <Option value="jane">jane</Option>
|
|
|
- <Option value="kate">kate</Option>
|
|
|
+ <Form.InputNumber field='price' label='price' style={{ width: 200 }}/>
|
|
|
+ <Form.Select label="Name" field='name' style={{ width: 200 }}>
|
|
|
+ <Form.Select.Option value="mike">mike</Form.Select.Option>
|
|
|
+ <Form.Select.Option value="jane">jane</Form.Select.Option>
|
|
|
+ <Form.Select.Option value="kate">kate</Form.Select.Option>
|
|
|
</Form.Select>
|
|
|
<Form.CheckboxGroup label="Role" field='role' direction='horizontal'>
|
|
|
<Checkbox value="admin">admin</Checkbox>
|
|
@@ -645,8 +645,8 @@ import { Form } from '@douyinfe/semi-ui';
|
|
|
labelPosition='left'
|
|
|
labelAlign='right'
|
|
|
>
|
|
|
- <Form.Input field='name' style={{width: 250}} label='Name' placeholder='Input Name' trigger='blur' />
|
|
|
- <Form.Select field="role" label='Role' placeholder='Choose Role' style={{width: 250}}>
|
|
|
+ <Form.Input field='name' style={{ width: 250 }} label='Name' placeholder='Input Name' trigger='blur' />
|
|
|
+ <Form.Select field="role" label='Role' placeholder='Choose Role' style={{ width: 250 }}>
|
|
|
<Form.Select.Option value="qa">Quality Assurance</Form.Select.Option>
|
|
|
<Form.Select.Option value="rd">Software Engineer</Form.Select.Option>
|
|
|
<Form.Select.Option value="pm">Product Manager</Form.Select.Option>
|
|
@@ -666,7 +666,7 @@ import { Form } from '@douyinfe/semi-ui';
|
|
|
|
|
|
() => (
|
|
|
<Form onSubmit={(values) => console.log(values)} style={{ width: 400 }}>
|
|
|
- <Form.Input field='name' label='UserName' trigger='blur' noLabel={true} style={{width: 250}} placeholder='Input userName'/>
|
|
|
+ <Form.Input field='name' label='UserName' trigger='blur' noLabel={true} style={{ width: 250 }} placeholder='Input userName'/>
|
|
|
<Form.Select field="role" label='UserRole' style={{ width: '250px' }} noLabel={true} placeholder='Choose role'>
|
|
|
<Form.Select.Option value="qa">Quality Assurance</Form.Select.Option>
|
|
|
<Form.Select.Option value="rd">Software Engineer</Form.Select.Option>
|
|
@@ -707,13 +707,13 @@ class AssistComponent extends React.Component {
|
|
|
<Form
|
|
|
onChange={v=>console.log(v)}
|
|
|
onSubmit={v=>console.log(v)}
|
|
|
- style={{width: 600}}
|
|
|
+ style={{ width: 600 }}
|
|
|
labelPosition='left'
|
|
|
labelWidth={100}
|
|
|
>
|
|
|
- <Form.Input field='effectName' label='EffectName' style={{width: 250}}/>
|
|
|
+ <Form.Input field='effectName' label='EffectName' style={{ width: 250 }}/>
|
|
|
<Form.Select
|
|
|
- style={{width: 300}}
|
|
|
+ style={{ width: 300 }}
|
|
|
field="type"
|
|
|
label="EffectType"
|
|
|
>
|
|
@@ -722,12 +722,12 @@ class AssistComponent extends React.Component {
|
|
|
</Form.Select>
|
|
|
<Form.ErrorMessage />
|
|
|
<Form.Slot label={{ text: 'SlotA' }}>
|
|
|
- <div style={{display: 'flex', alignItems: 'center', height: '100%'}}>
|
|
|
+ <div style={{ display: 'flex', alignItems: 'center', height: '100%' }}>
|
|
|
{`I'm Semi Form SlotA, a custom ReactNode`}
|
|
|
</div>
|
|
|
</Form.Slot>
|
|
|
<Form.Slot label={{ text: 'SlotB', width: 160, align: 'right' }}>
|
|
|
- <div style={{display: 'flex', alignItems: 'center', height: '100%'}}>
|
|
|
+ <div style={{ display: 'flex', alignItems: 'center', height: '100%' }}>
|
|
|
{`I'm Semi Form SlotA, i have different labelWidth and textAlign.`}
|
|
|
</div>
|
|
|
</Form.Slot>
|
|
@@ -745,7 +745,7 @@ import React from 'react';
|
|
|
import { Form } from '@douyinfe/semi-ui';
|
|
|
() => (
|
|
|
<Form labelPosition='inset' layout='horizontal'>
|
|
|
- <Form.Input field='name' label='UserName' trigger='blur' style={{width: 250}} placeholder='Input userName'/>
|
|
|
+ <Form.Input field='name' label='UserName' trigger='blur' style={{ width: 250 }} placeholder='Input userName'/>
|
|
|
<Form.Select field="role" label='UserRole' style={{ width: '250px' }}>
|
|
|
<Form.Select.Option value="qa">Quality Assurance</Form.Select.Option>
|
|
|
<Form.Select.Option value="rd">Software Engineer</Form.Select.Option>
|
|
@@ -840,7 +840,7 @@ class ModalFormDemo extends React.Component {
|
|
|
title="New"
|
|
|
visible={visible}
|
|
|
onOk={this.handleOk}
|
|
|
- style={{width: 600}}
|
|
|
+ style={{ width: 600 }}
|
|
|
onCancel={this.handleCancel}
|
|
|
>
|
|
|
<Form
|
|
@@ -851,15 +851,17 @@ class ModalFormDemo extends React.Component {
|
|
|
<Form.Select
|
|
|
field='region'
|
|
|
label="Country/Region"
|
|
|
- style={{width:120}}
|
|
|
+ style={{ width:120 }}
|
|
|
rules={[
|
|
|
{ required: true, message },
|
|
|
]}
|
|
|
+ optionList={[
|
|
|
+ { label: 'China', value: 'China' },
|
|
|
+ { label: 'USA', value: 'US' },
|
|
|
+ { label: 'Europe', value: 'Europe' },
|
|
|
+ { label: 'Japan', value: 'Japan' },
|
|
|
+ ]}
|
|
|
>
|
|
|
- <Option value="China">China</Option>
|
|
|
- <Option value="US">USA</Option>
|
|
|
- <Option value="Europe">Europe</Option>
|
|
|
- <Option value="Japan">Japan</Option>
|
|
|
</Form.Select>
|
|
|
</Col>
|
|
|
<Col span={17}>
|
|
@@ -877,7 +879,7 @@ class ModalFormDemo extends React.Component {
|
|
|
field='area'
|
|
|
label="Area"
|
|
|
placeholder='Choose Area'
|
|
|
- style={{width:120}}
|
|
|
+ style={{ width:120 }}
|
|
|
rules={[
|
|
|
{ required: true, message },
|
|
|
]}
|
|
@@ -1000,7 +1002,7 @@ class FormLevelValidateSync extends React.Component {
|
|
|
<Form.Input field='familyName[0].before' trigger='blur'></Form.Input>
|
|
|
<Form.Input field='familyName[0].after' trigger='blur'></Form.Input>
|
|
|
<Form.Input field='familyName[1]' trigger='blur'></Form.Input>
|
|
|
- <div style={{display: 'flex', alignItems: 'flex-end'}}>
|
|
|
+ <div style={{ display: 'flex', alignItems: 'flex-end' }}>
|
|
|
<Button type="primary" htmlType="submit" className="btn-margin-right">
|
|
|
Submit
|
|
|
</Button>
|
|
@@ -1047,7 +1049,7 @@ class FormLevelValidateAsync extends React.Component {
|
|
|
<Form.Input field='familyName[0].before' trigger='blur'></Form.Input>
|
|
|
<Form.Input field='familyName[1]' trigger='blur'></Form.Input>
|
|
|
<Form.Input field='sex' trigger='blur'></Form.Input>
|
|
|
- <div style={{display: 'flex', alignItems: 'flex-end'}}>
|
|
|
+ <div style={{ display: 'flex', alignItems: 'flex-end' }}>
|
|
|
<Button type="primary" htmlType="submit" className="btn-margin-right">
|
|
|
Submit
|
|
|
</Button>
|
|
@@ -1201,7 +1203,7 @@ class ArrayFieldDemo extends React.Component {
|
|
|
const ComponentUsingFormState = () => {
|
|
|
const formState = useFormState();
|
|
|
return (
|
|
|
- <TextArea style={{marginTop: 10}} value={JSON.stringify(formState)} />
|
|
|
+ <TextArea style={{ marginTop: 10 }} value={JSON.stringify(formState)} />
|
|
|
);
|
|
|
};
|
|
|
return (
|
|
@@ -1216,13 +1218,13 @@ class ArrayFieldDemo extends React.Component {
|
|
|
<Form.Input
|
|
|
field={`${field}[name]`}
|
|
|
label={`Effect Name:`}
|
|
|
- style={{width: 200, marginRight: 16}}
|
|
|
+ style={{ width: 200, marginRight: 16 }}
|
|
|
>
|
|
|
</Form.Input>
|
|
|
<Form.Select
|
|
|
field={`${field}[type]`}
|
|
|
label={`Effect Type:`}
|
|
|
- style={{width: 90}}
|
|
|
+ style={{ width: 90 }}
|
|
|
>
|
|
|
<Form.Select.Option value='2D'>2D</Form.Select.Option>
|
|
|
<Form.Select.Option value='3D'>3D</Form.Select.Option>
|
|
@@ -1288,8 +1290,8 @@ class ArrayDemo extends React.Component {
|
|
|
renderItems(formState, values) {
|
|
|
return values.effects && values.effects.map((effect, i) => (
|
|
|
<div key={effect.key} style={{ width: 1000, display: 'flex' }}>
|
|
|
- <Form.Input field={`effects[${i}].name`} style={{width: 200, marginRight: 16}}></Form.Input>
|
|
|
- <Form.Select field={`effects[${i}].type`} style={{width: 90}}>
|
|
|
+ <Form.Input field={`effects[${i}].name`} style={{ width: 200, marginRight: 16 }}></Form.Input>
|
|
|
+ <Form.Select field={`effects[${i}].type`} style={{ width: 90 }}>
|
|
|
<Form.Select.Option value='2D'>2D</Form.Select.Option>
|
|
|
<Form.Select.Option value='3D'>3D</Form.Select.Option>
|
|
|
</Form.Select>
|
|
@@ -1311,7 +1313,7 @@ class ArrayDemo extends React.Component {
|
|
|
<>
|
|
|
<Button onClick={this.add}>add</Button>
|
|
|
{this.renderItems(formState, values)}
|
|
|
- <TextArea style={{marginTop: 10}} value={JSON.stringify(formState.values)} />
|
|
|
+ <TextArea style={{ marginTop: 10 }} value={JSON.stringify(formState.values)} />
|
|
|
</>
|
|
|
)}
|
|
|
</Form>
|
|
@@ -1674,9 +1676,9 @@ class FormApiDemo extends React.Component {
|
|
|
|
|
|
changeValues() {
|
|
|
// use formApi to update formA
|
|
|
- this.formApi.setValues({ a: 1});
|
|
|
+ this.formApi.setValues({ a: 1 });
|
|
|
// use formApi to update formB
|
|
|
- this.formBRef.current.formApi.setValues({ b: 2});
|
|
|
+ this.formBRef.current.formApi.setValues({ b: 2 });
|
|
|
}
|
|
|
|
|
|
render() {
|
|
@@ -1848,6 +1850,21 @@ const { ErrorMessage } = Form;
|
|
|
- [aria-describedby](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-describedby_attribute)
|
|
|
- When the Field is configured with `helpText` or `extraText`, the Field component will be automatically added with the `aria-describedby` attribute, whose value is the id of the DOM element corresponding to helpText and extraText (format like: `${props.field}-helpText` , `${props.field}-extraText`)
|
|
|
|
|
|
+## Content Guidelines
|
|
|
+
|
|
|
+- Form title
|
|
|
+ - The title of the form needs to follow the writing specification of the title
|
|
|
+- Form label
|
|
|
+ - The label is a short description of the input box. The label is not a help text, so it should not be a description of the input
|
|
|
+ - Labels must:
|
|
|
+ - Place it above or below the input box
|
|
|
+ - Short (1-3 words)
|
|
|
+ - Use case conventions for statements (first letter uppercase, others lowercase)
|
|
|
+- Help text
|
|
|
+ - Help text use statement writing conventions, capitalized
|
|
|
+- Form button
|
|
|
+ - For the content Guidelines of the form button, refer to [Button component](/en-US/input/button)
|
|
|
+
|
|
|
## Design Tokens
|
|
|
|
|
|
<DesignToken/>
|