| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432 |
- import React, { useState, useLayoutEffect, useEffect, useRef } from 'react';
- import {
- Button,
- Modal,
- TreeSelect,
- Row,
- Col,
- Avatar,
- Tabs,
- TabPane,
- Badge,
- Notification,
- } from '../../index';
- import {
- Form,
- useFormState,
- useFormApi,
- useFieldApi,
- useFieldState,
- withFormState,
- withFormApi,
- withField,
- ArrayField,
- Icon,
- } from '../../index';
- import { BasicDemoWithInit, LinkFieldForm, I18nDemo, DifferentDeclareUsage } from './demo';
- const {
- Input,
- Select,
- DatePicker,
- Switch,
- Slider,
- CheckboxGroup,
- Checkbox,
- RadioGroup,
- Radio,
- TimePicker,
- } = Form;
- import {
- UseFormApiDemo,
- UseFormStateDemo,
- UseFieldApiDemo,
- UseFieldStateDemo,
- WithFormStateDemo,
- WithFormApiDemo,
- ComponentUsingFormState,
- CustomStringify,
- } from './Hook/hookDemo';
- // layout
- import { LayoutDemo, InsetLabelDemo, GroupFormDemo } from './Layout/layoutDemo';
- import { AssistComponent } from './Layout/slotDemo';
- import { ModalFormDemo } from './Layout/modalFormDemo';
- import { WithFieldDemo, CustomFieldDemo, NumberRange } from './HOC/withFieldDemo';
- import {
- CustomValidateDemo,
- ValidateFieldsDemo,
- PartValidAndResetDemo,
- RulesValidateDemo,
- SetBugDemo,
- UnmountedLeafDemo,
- RulesExample,
- } from './Validate/validateDemo';
- // field props
- import { ConvertDemo } from './FieldProps/convert';
- import { HelpAndExtra, ExtraPositionDemo } from './FieldProps/helpAndExtra';
- import { BigNumberFieldDemo } from './FieldProps/bigNumberFieldPath';
- import { UpdateDemo, RuleupdateDemo } from './FieldProps/rulesUpdateDemo';
- import { FieldRefDemo } from './FieldProps/fieldRef';
- // arrayField
- import {
- ArrayFieldCollapseDemo,
- ArrayFieldDemo,
- ArrayFieldWithFormInitValues,
- ArrayFieldWithInitValue,
- } from './DynamicField/arrayFieldDemo';
- import { NestArrayField } from './DynamicField/nestArrayField';
- import { ArrayDemo } from './FormApi/arrayDemo';
- // performance
- import {
- ManyFieldDemo,
- EffectDemo,
- ModalFormSelectWithObject,
- } from './Performance/performanceDemo';
- import { SetValuesDemo, SetValuesWithArrayField } from './FormApi/setValuesDemo';
- import { SetValueUsingParentPath } from './FormApi/formApiDemo';
- import { FieldPathWithArrayDemo } from './Debug/bugDemo';
- import ChildDidMount from './Debug/childDidMount';
- export default {
- title: 'Form'
- }
- const Option = Select.Option;
- export const FormDeclareUsage = () => <DifferentDeclareUsage />;
- FormDeclareUsage.story = {
- name: 'Form declare usage',
- };
- export const BasicDemo = () => <BasicDemoWithInit />;
- BasicDemo.story = {
- name: 'BasicDemo',
- };
- export const LayoutFormInputGroup = () => <GroupFormDemo />;
- LayoutFormInputGroup.story = {
- name: 'Layout-Form.InputGroup',
- };
- export const LayoutFormWrapperColLabelCol = () => <LayoutDemo />;
- LayoutFormWrapperColLabelCol.story = {
- name: 'Layout-Form wrapperCol/labelCol',
- };
- export const LayoutInsetLabel = () => <InsetLabelDemo />;
- LayoutInsetLabel.story = {
- name: 'Layout-insetLabel',
- };
- export const LayoutSlotErrorMessageLabel = () => <AssistComponent />;
- LayoutSlotErrorMessageLabel.story = {
- name: 'Layout-Slot/ErrorMessage/Label',
- };
- export const LayoutModalDemo = () => <ModalFormDemo />;
- LayoutModalDemo.story = {
- name: 'Layout- ModalDemo',
- };
- export const FormApiSetValuesOverride = () => <SetValuesDemo />;
- FormApiSetValuesOverride.story = {
- name: 'formApi-setValues(override)',
- };
- export const FormApiValidate = () => <PartValidAndResetDemo />;
- FormApiValidate.story = {
- name: 'formApi-validate',
- };
- export const FormApiSetValueUsingFieldParentPath = () => <SetValueUsingParentPath />;
- FormApiSetValueUsingFieldParentPath.story = {
- name: 'formApi-setValue using field parent path',
- };
- export const DynamicAddRemoveField = () => (
- <Form>
- {({ formState }) => (
- <React.Fragment>
- <Input field="name" label="First name:" />
- <RadioGroup field="married" label="Are you married?">
- <Radio value="yes">yes</Radio>
- <Radio value="no">no</Radio>
- </RadioGroup>
- {formState.values.married === 'yes' ? <Input field="spouse" label="Spouse name:" /> : null}
- <Button htmlType="submit">Submit</Button>
- <ComponentUsingFormState />
- </React.Fragment>
- )}
- </Form>
- );
- DynamicAddRemoveField.story = {
- name: 'Dynamic Add / Remove Field',
- };
- export const ArrayFieldBasicUsage = () => <ArrayFieldDemo />;
- ArrayFieldBasicUsage.story = {
- name: 'ArrayField-basic usage',
- };
- export const _ArrayFieldWithFormInitValues = () => <ArrayFieldWithFormInitValues />;
- _ArrayFieldWithFormInitValues.story = {
- name: 'ArrayField-with form initValues',
- };
- export const ArrayFieldWithArrayFieldInitValue = () => <ArrayFieldWithInitValue />;
- ArrayFieldWithArrayFieldInitValue.story = {
- name: 'ArrayField-with arrayField initValue',
- };
- export const ArrayFieldNestUsage = () => <NestArrayField />;
- ArrayFieldNestUsage.story = {
- name: 'ArrayField-Nest Usage',
- };
- export const _ArrayFieldCollapseDemo = () => <ArrayFieldCollapseDemo />;
- _ArrayFieldCollapseDemo.story = {
- name: 'ArrayField-CollapseDemo',
- };
- export const ArrayFieldDynamicUpdate = () => <ArrayDemo />;
- ArrayFieldDynamicUpdate.story = {
- name: 'ArrayField-dynamic update',
- };
- export const LinkField = () => <LinkFieldForm />;
- LinkField.story = {
- name: 'LinkField',
- };
- export const ValidateFormLevel = () => <ValidateFieldsDemo />;
- ValidateFormLevel.story = {
- name: 'Validate-FormLevel',
- };
- export const ValidateFieldValel = () => <CustomValidateDemo />;
- ValidateFieldValel.story = {
- name: 'Validate-FieldValel',
- };
- export const ValidateUseRules = () => <RulesValidateDemo />;
- ValidateUseRules.story = {
- name: 'Validate-use rules',
- };
- export const HooksUseFormApi = () => <UseFormApiDemo />;
- HooksUseFormApi.story = {
- name: 'Hooks-useFormApi',
- };
- export const HooksUseFormState = () => <UseFormStateDemo />;
- HooksUseFormState.story = {
- name: 'Hooks-useFormState',
- };
- export const HooksUseFieldApi = () => <UseFieldApiDemo />;
- HooksUseFieldApi.story = {
- name: 'Hooks-useFieldApi',
- };
- export const HooksUseFieldState = () => <UseFieldStateDemo />;
- HooksUseFieldState.story = {
- name: 'Hooks-useFieldState',
- };
- export const HocWithFormApi = () => <WithFormApiDemo />;
- HocWithFormApi.story = {
- name: 'Hoc-withFormApi',
- };
- export const HocWithFormState = () => <WithFormStateDemo />;
- HocWithFormState.story = {
- name: 'Hoc-withFormState',
- };
- export const WithField = () => <CustomFieldDemo />;
- WithField.story = {
- name: 'withField',
- };
- export const WithFieldWithStatefulComponent = () => <WithFieldDemo />;
- WithFieldWithStatefulComponent.story = {
- name: 'withField- with stateful component',
- };
- export const WithFieldNumberRange = () => (
- <Form onChange={v => console.log(v)}>
- <NumberRange field="number" initValue={[1, 2]} noLabel={true}></NumberRange>
- </Form>
- );
- WithFieldNumberRange.story = {
- name: 'withField - NumberRange',
- };
- export const PerformanceManyField = () => <ManyFieldDemo />;
- PerformanceManyField.story = {
- name: 'Performance-ManyField',
- };
- export const PerformanceModalFormSelectWithObject = () => <ModalFormSelectWithObject />;
- PerformanceModalFormSelectWithObject.story = {
- name: 'Performance-ModalFormSelectWithObject',
- };
- export const FiledPropConvert = () => <ConvertDemo />;
- FiledPropConvert.story = {
- name: 'Filed Prop-convert',
- };
- export const FiledPropHelpTextExtraTextExtraTextPosition = () => (
- <>
- <HelpAndExtra />
- <ExtraPositionDemo />
- <GroupFormDemo />
- </>
- );
- FiledPropHelpTextExtraTextExtraTextPosition.story = {
- name: 'Filed Prop-helpText / extraText / extraTextPosition',
- };
- export const FieldPropsDynamicUpdateRulesRequired = () => <RuleupdateDemo />;
- FieldPropsDynamicUpdateRulesRequired.story = {
- name: 'Field Props-dynamic update rules.required',
- };
- export const FieldPropInitValue = () => <InitEmptyStringDemo />;
- FieldPropInitValue.story = {
- name: 'Field Prop-initValue=""',
- };
- export const FieldPropBigNumberFieldSubmit = () => <BigNumberFieldDemo />;
- FieldPropBigNumberFieldSubmit.story = {
- name: 'Field prop-big number field submit',
- };
- export const FieldPropPure = () => (
- <Form>
- <Form.Select
- field="name"
- pure
- className="fefefe"
- fieldClassName="feichang"
- style={{ width: 400 }}
- />
- </Form>
- );
- FieldPropPure.story = {
- name: 'Field Prop-pure',
- };
- export const FieldPropRef = () => <FieldRefDemo />;
- FieldPropRef.story = {
- name: 'Field Prop-ref',
- };
- const InitEmptyStringDemo = () => {
- return (
- <Form allowEmpty>
- <Form.Input field="name" initValue="" />
- <ComponentUsingFormState />
- </Form>
- );
- };
- export const DebugSetBugDemo = () => (
- <>
- <SetBugDemo />
- <UnmountedLeafDemo />
- </>
- );
- DebugSetBugDemo.story = {
- name: 'Debug-SetBugDemo',
- };
- export const DebugSetValuesWithArrayField = () => (
- <>
- <SetValuesWithArrayField />
- </>
- );
- DebugSetValuesWithArrayField.story = {
- name: 'Debug-SetValuesWithArrayField',
- };
- import { SetValuesArray, DoubleRerender } from './Debug/bugDemo';
- export const DebugArrayFieldPath = () => <FieldPathWithArrayDemo />;
- DebugArrayFieldPath.story = {
- name: 'Debug-数组类fieldPath',
- };
- export const DebugSetValuesDemo = () => (
- <>
- <SetValuesArray />
- </>
- );
- DebugSetValuesDemo.story = {
- name: 'Debug-SetValuesDemo',
- };
- export const DebugRerenderTwice = () => (
- <>
- <DoubleRerender />
- </>
- );
- DebugRerenderTwice.story = {
- name: 'Debug-RerenderTwice',
- };
- export const _ChildDidMount = () => <ChildDidMount />;
- _ChildDidMount.story = {
- name: 'child did mount',
- };
|