How to use the react-form.FormField function in react-form

To help you get started, we’ve selected a few react-form examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github argoproj / argo-cd / ui / src / app / settings / components / project-role-policies-edit / project-role-policies-edit.tsx View on Github external
return '';
        }
        return fields[5].trim();
    }
    private setPermission(permission: string) {
        const fields = (this.props.fieldApi.getValue() as string).split(',');
        if (fields.length !== 6) {
            this.props.fieldApi.setValue(generatePolicy(this.props.projName, this.props.roleName, '', '', permission));
            return;
        }
        fields[5] = ` ${permission}`;
        this.props.fieldApi.setValue(fields.join());
    }
}

const Policy = ReactForm.FormField(PolicyWrapper);
github argoproj / argo-cd-ui / src / app / shared / components / tags-editor / tags-editor.tsx View on Github external
import { Autocomplete } from 'argo-ui';
import * as classNames from 'classnames';
import * as React from 'react';
import * as ReactForm from 'react-form';

require('./tags-editor.scss');

export const TagsEditor = ReactForm.FormField((props: {options: string[], noTagsLabel?: string, fieldApi: ReactForm.FieldApi, className: string }) => {
    const { fieldApi: {getValue, setValue}} = props;
    const tags = (getValue() || []) as Array;

    return (
        <div>
            {tags.length &gt; 0 &amp;&amp; (
                <div>
                    {tags.map((path, i) =&gt; (
                        <span title="{path}"><i> {
                            const newPaths = tags.slice();
                            newPaths.splice(i, 1);
                            setValue(newPaths);
                        }}/&gt; {path}</i></span><i>
                    ))}
                </i></div></div>
github argoproj / argo-cd / ui / src / app / applications / components / application-sync-options / application-sync-options.tsx View on Github external
export const ApplicationSyncOptions = (props: ApplicationSyncOptionProps) =&gt; (
    <div>
        {syncOptions.map((render, i) =&gt; (
            <div style="{optionStyle}">
                {render(props)}
            </div>
        ))}
    </div>
);

export const ApplicationManualSyncFlags = ReactForm.FormField((props: {fieldApi: ReactForm.FieldApi}) =&gt; {
    const {
        fieldApi: {getValue, setValue, setTouched}
    } = props;
    const val = getValue() || false;
    return (
        <div style="{optionStyle}">
            {Object.keys(ManualSyncFlags).map(flag =&gt; (
                
                     {
                            setTouched(true);
                            const update = {...val};
                            update[flag] = newVal;
                            setValue(update);</div>
github argoproj / argo-cd / ui / src / app / settings / components / project-sync-windows-edit / project-sync-windows-edit.tsx View on Github external
<i> this.props.deleteApp()} style={{cursor: 'pointer'}} /&gt;
                
            
        );
    }

    private getApplication(): string {
        return this.props.fieldApi.getValue();
    }

    private setApplication(application: string) {
        this.props.fieldApi.setValue(application);
    }
}

const Attribute = ReactForm.FormField(AttributeWrapper);

function generateSchedule(minute?: string, hour?: string, dom?: string, month?: string, dow?: string): string {
    return `${minute} ${hour} ${dom} ${month} ${dow}`;
}

export const ProjectSyncWindowScheduleEdit = (props: ProjectSyncWindowProps) =&gt; (
    
        <h6>Schedule</h6>
        <div>
            <div>
                <div>Minute{helpTip('The minute/minutes assigned to the schedule')}</div>
                <div>Hour{helpTip('The hour/hours assigned to the schedule')}</div>
                <div>Day Of The Month{helpTip('The day/days of the month assigned to the schedule')}</div>
                <div>Month{helpTip('The month/months assigned to the schedule.')}</div>
                <div>Day Of the Week{helpTip('The day/days of the week assigned to the schedule')}</div>
            </div></div></i>
github argoproj / argo-cd / ui / src / app / applications / components / application-sync-options / application-sync-options.tsx View on Github external
checked={val[flag]}
                        onChange={(newVal: boolean) =&gt; {
                            setTouched(true);
                            const update = {...val};
                            update[flag] = newVal;
                            setValue(update);
                        }}
                    /&gt;
                    <label>{ManualSyncFlags[flag as keyof typeof ManualSyncFlags]}</label>{' '}
                
            ))}
        
    );
});

export const ApplicationSyncOptionsField = ReactForm.FormField((props: {fieldApi: ReactForm.FieldApi}) =&gt; {
    const {
        fieldApi: {getValue, setValue, setTouched}
    } = props;
    const val = getValue() || [];
    return (
        <div style="{{borderBottom:">
             {
                    setTouched(true);
                    setValue(opts);
                }}
            /&gt;
        </div>
    );
});
github argoproj / argo-cd / ui / src / app / shared / components / checkbox / checkbox-field.tsx View on Github external
import {Checkbox} from 'argo-ui';
import * as React from 'react';
import * as ReactForm from 'react-form';

export const CheckboxField = ReactForm.FormField((props: {fieldApi: ReactForm.FieldApi; id: string; className: string; checked: boolean}) =&gt; {
    const {
        fieldApi: {getValue, setValue}
    } = props;

    return ;
});
github argoproj / argo-cd / ui / src / app / applications / components / utils.tsx View on Github external
} catch (e) {
                    apis.notifications.show({
                        content: ,
                        type: NotificationType.Error
                    });
                }
            }
        },
        {name: 'argo-icon-warning', color: 'warning'},
        'yellow',
        {propagationPolicy: 'foreground'}
    );
    return confirmed;
}

const PropagationPolicyOption = ReactForm.FormField((props: {fieldApi: ReactForm.FieldApi; policy: string; message: string}) =&gt; {
    const {
        fieldApi: {setValue}
    } = props;
    return (
        <div>
            <input id="{props.policy}" value="{props.policy}" name="propagation-policy" type="radio"> setValue(props.policy.toLowerCase())}
            /&gt;
            <label></label></div>
github argoproj / argo-cd / ui / src / app / settings / components / project-sync-windows-edit / project-sync-windows-edit.tsx View on Github external
case 2:
                    this.props.fieldApi.setValue(generateSchedule('*', '*', values.join(','), '*', '*'));
                    break;
                case 3:
                    this.props.fieldApi.setValue(generateSchedule('*', '*', '*', values.join(','), '*'));
                    break;
                case 4:
                    this.props.fieldApi.setValue(generateSchedule('*', '*', '*', '*', values.join(',')));
                    break;
            }
        }
        return;
    }
}

const Schedule = ReactForm.FormField(ScheduleWrapper);
github argoproj / argo-cd / ui / src / app / settings / components / project-role-groups-edit / project-role-groups-edit.tsx View on Github external
}

class GroupWrapper extends React.Component {
    public render() {
        return (
            <div>
                <div>{this.props.groupName}</div>
                <div>
                    <i> this.props.deleteGroup()} style={{cursor: 'pointer'}} /&gt;
                </i></div><i>
            </i></div><i>
        );
    }
}

const Group = ReactForm.FormField(GroupWrapper);
</i>
github argoproj / argo-cd / ui / src / app / applications / components / application-create-panel / application-create-panel.tsx View on Github external
spec: {
        destination: {
            name: '',
            namespace: '',
            server: ''
        },
        source: {
            path: '',
            repoURL: '',
            targetRevision: 'HEAD'
        },
        project: ''
    }
};

const AutoSyncFormField = ReactFormField((props: {fieldApi: FieldApi; className: string}) =&gt; {
    const manual = 'Manual';
    const auto = 'Automatic';
    const {
        fieldApi: {getValue, setValue}
    } = props;
    const automated = getValue() as models.Automated;

    return (
        
            <label>Sync Policy</label>
            <select value="{automated"> {
                    setValue(opt.value === auto ? {prune: false, selfHeal: false} : null);
                }}</select>

react-form

⚛️ 💼 React hooks for managing form state and lifecycle

MIT
Latest version published 5 years ago

Package Health Score

72 / 100
Full package analysis

Popular react-form functions