UNPKG

react-ocean-forms

Version:
75 lines (74 loc) 2.66 kB
/** * Copyright (c) 2018-present, Umweltbundesamt GmbH * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ import React from 'react'; import { IFieldValues } from '../FormContext'; import { IFieldGroupProps } from './FieldGroup.types'; interface IFieldGroupState { fieldPrefix: string; notifyFieldEvent(name: string, event: string, args?: unknown): void; } /** * Wrapper for groups of input fields * managed by the form component */ export declare class BaseFieldGroup<TFieldValues extends object = IFieldValues> extends React.Component<IFieldGroupProps<TFieldValues>, IFieldGroupState> { static displayName: string; constructor(props: IFieldGroupProps<TFieldValues>); /** * Unregisters the field from the form */ componentWillUnmount(): void; /** * Helper function to get the correct value * of the group (including all values of the nested fields) */ private getGroupValue; /** * Returns the correct asyncValidateOnChange setting, * where the field setting takes priorty over the * form setting */ private getAsyncValidateOnChangeSetting; /** * Generates the form context for the FieldGroup children * Overrides fieldPrefix and notifyFieldEvent from the * parent context, and overrides defaultValues and values * for the group items if needed */ private getSubContext; /** * Checks if the FieldGroup is inside a valid form context * and throws an user friendly error if not */ private checkFormContext; /** * Checks if the FieldGroup has a prop with the given name * and overrides the according value in the parent form context. * @param name Property name */ private overrideContextValues; /** * Resets the validation state */ private reset; /** * Listens to child field events, triggers validation if * needed and passes them to the higher context * @param name Field name * @param event Event name * @param args Event args */ private notifyFieldEvent; /** * Triggers the validation of the group * @param args Options for the validate call */ private validate; render(): JSX.Element; } export declare const FieldGroup: React.ComponentType<Pick<IFieldGroupProps<object>, "name" | "label" | "asyncValidateOnChange" | "defaultValues" | "values" | "disabled" | "plaintext" | "render"> & import("../withValidation").IValidatedComponentProps>; export {};