@dnb/eufemia
Version:
DNB Eufemia Design System UI Library
45 lines (44 loc) • 1.53 kB
TypeScript
import type { RefObject } from 'react';
import type { Path } from '../../types';
export type FieldBoundaryContextState = {
/**
* Will be set to true when one or more nested fields are in error state.
*/
hasError?: boolean;
/**
* Will be set to true when the inherited data context has submit errors and the `hasError` has errors as well.
*/
hasSubmitError?: boolean;
/**
* Will be set to true when a nested field contains a visible error.
*/
hasVisibleError?: boolean;
/**
* Contains the nested field errors.
*/
errorsRef?: RefObject<unknown>;
/**
* Will be set to true when the boundary context error state should be shown.
* Support a number to ensure we can renew hooks each time we get a new value.
*/
showBoundaryErrors?: boolean | number;
/**
* To set the boundary context error state.
*/
setShowBoundaryErrors?: (showBoundaryErrors: FieldBoundaryContextState['showBoundaryErrors']) => void;
/**
* To set the local error state.
*/
setFieldError?: (path: Path, error: Error) => void;
/**
* To set the local visible error state.
*/
revealError?: (path: Path, hasError: boolean) => void;
/**
* To manually verify if there are any field errors.
* Use it for when "hasError" is one tick behind.
*/
verifyFieldError?: () => boolean;
};
declare const FieldBoundaryContext: import("react").Context<FieldBoundaryContextState>;
export default FieldBoundaryContext;