1import React, { useCallback } from 'react';
2import { Form, FormRenderProps } from 'react-final-form';
3import arrayMutators from 'final-form-arrays';
4import { noop } from 'lodash';
6import ValuesHandler from './ValuesHandler';
7import ValidationPauser from './ValidationPauser';
8import { CSSProperties } from 'styled-components';
9import { FormState } from 'final-form';
12 * BridgeForm adds nice-to-haves for every form in bridge.
13 * + afterSubmit callback for redirects
14 * + default onSubmit to noop so react-final-form doesn't throw
15 * + pauses validation when the form is unmounted
16 * + `onValues` handler for reactive changes
17 * + automatically includes array and field data mutators
19interface BridgeFormProps {
20 // children: React.ReactNode;
22 // onValues?: (values: { [k: string]: string }, valid: boolean, form: any) => void | typeof noop;
24 // onSubmit?: (values: { [k: string]: string }) => void | typeof noop;
30 afterSubmit?: VoidFunction;
31 rest?: React.HTMLProps<HTMLFormElement>;
34export default function BridgeForm({
41 const _onSubmit = useCallback(
43 const errors = await onSubmit(...args);
50 [afterSubmit, onSubmit]
54 <Form mutators={{ ...arrayMutators }} onSubmit={_onSubmit} {...rest}>
56 formProps: FormRenderProps<any, Partial<any>> & {
61 style={formProps?.style || { display: 'contents' }}
62 onSubmit={formProps.handleSubmit}>
65 {onValues && <ValuesHandler {...formProps} onValues={onValues} />}
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list