@dnb/eufemia
Version:
DNB Eufemia Design System UI Library
197 lines (196 loc) • 10.8 kB
TypeScript
/// <reference types="react" />
import { ContextState } from '../../DataContext/Context';
import { ContextProps } from '../../../../shared/Context';
import type { FieldProps } from '../../types';
import { FieldProviderProps } from './FieldProvider';
declare function useFieldProvider(props?: Omit<FieldProviderProps, 'children'>): {
extend: <T extends FieldProps>(fieldProps: T) => T;
inheritedProps: {
space?: import("../../../../shared/types").SpaceTypeAll;
left?: import("../../../../shared/types").SpaceType;
right?: import("../../../../shared/types").SpaceType;
error?: import("../../types").ErrorProp<unknown>;
label?: import("react").ReactNode;
path?: string;
'aria-hidden'?: boolean | "true" | "false";
value?: unknown;
info?: import("../../types").InfoProp<unknown>;
'aria-labelledby'?: string;
'aria-describedby'?: string;
'aria-details'?: string;
'aria-disabled'?: boolean | "true" | "false";
innerSpace?: import("../../../../shared/types").SpaceTypeAll | import("../../../../shared/types").SpaceTypeMedia;
top?: import("../../../../shared/types").SpaceType;
bottom?: import("../../../../shared/types").SpaceType;
required?: boolean;
defaultValue?: unknown;
className?: string;
id?: string;
placeholder?: import("react").ReactNode;
'aria-activedescendant'?: string;
'aria-atomic'?: boolean | "true" | "false";
'aria-autocomplete'?: "none" | "list" | "inline" | "both";
'aria-braillelabel'?: string;
'aria-brailleroledescription'?: string;
'aria-busy'?: boolean | "true" | "false";
'aria-checked'?: boolean | "true" | "false" | "mixed";
'aria-colcount'?: number;
'aria-colindex'?: number;
'aria-colindextext'?: string;
'aria-colspan'?: number;
'aria-controls'?: string;
'aria-current'?: boolean | "time" | "true" | "false" | "page" | "step" | "location" | "date";
'aria-description'?: string;
'aria-dropeffect'?: "copy" | "link" | "none" | "execute" | "move" | "popup";
'aria-errormessage'?: string;
'aria-expanded'?: boolean | "true" | "false";
'aria-flowto'?: string;
'aria-grabbed'?: boolean | "true" | "false";
'aria-haspopup'?: boolean | "dialog" | "menu" | "true" | "false" | "grid" | "listbox" | "tree";
'aria-invalid'?: boolean | "true" | "false" | "grammar" | "spelling";
'aria-keyshortcuts'?: string;
'aria-label'?: string;
'aria-level'?: number;
'aria-live'?: "off" | "assertive" | "polite";
'aria-modal'?: boolean | "true" | "false";
'aria-multiline'?: boolean | "true" | "false";
'aria-multiselectable'?: boolean | "true" | "false";
'aria-orientation'?: "horizontal" | "vertical";
'aria-owns'?: string;
'aria-placeholder'?: string;
'aria-posinset'?: number;
'aria-pressed'?: boolean | "true" | "false" | "mixed";
'aria-readonly'?: boolean | "true" | "false";
'aria-relevant'?: "text" | "additions" | "additions removals" | "additions text" | "all" | "removals" | "removals additions" | "removals text" | "text additions" | "text removals";
'aria-required'?: boolean | "true" | "false";
'aria-roledescription'?: string;
'aria-rowcount'?: number;
'aria-rowindex'?: number;
'aria-rowindextext'?: string;
'aria-rowspan'?: number;
'aria-selected'?: boolean | "true" | "false";
'aria-setsize'?: number;
'aria-sort'?: "other" | "none" | "ascending" | "descending";
'aria-valuemax'?: number;
'aria-valuemin'?: number;
'aria-valuenow'?: number;
'aria-valuetext'?: string;
onFocus?: (value: unknown, additionalArgs?: import("../../types").ProvideAdditionalEventArgs & {
errorMessages: import("../../types").DefaultErrorMessages;
connectWithPath: (path: string) => {
getValue: () => unknown;
};
connectWithItemPath: (path: string) => {
getValue: () => unknown;
};
getValueByPath: import("../../hooks/useDataValue").GetValueByPath<unknown>;
getSourceValue: import("../../hooks/useDataValue").GetValueByPath<unknown>;
setFieldEventListener: (path: string, type: "onSubmit" | "onSubmitCall" | "onSubmitRequest" | "onPathChange" | "onMount", callback: (params?: {
value: unknown;
} | {
preventSubmit: () => void;
}) => void | Promise<void | Error>) => void;
validators: Record<string, import("../../types").Validator<unknown, import("../../types").DefaultErrorMessages>>;
props: import("../../types").UseFieldProps<unknown, unknown, import("../../types").DefaultErrorMessages>;
dataContext: ContextState;
} & {
pattern?: string;
required?: string;
}) => void;
onBlur?: (value: unknown, additionalArgs?: import("../../types").ProvideAdditionalEventArgs & {
errorMessages: import("../../types").DefaultErrorMessages;
connectWithPath: (path: string) => {
getValue: () => unknown;
};
connectWithItemPath: (path: string) => {
getValue: () => unknown;
};
getValueByPath: import("../../hooks/useDataValue").GetValueByPath<unknown>;
getSourceValue: import("../../hooks/useDataValue").GetValueByPath<unknown>;
setFieldEventListener: (path: string, type: "onSubmit" | "onSubmitCall" | "onSubmitRequest" | "onPathChange" | "onMount", callback: (params?: {
value: unknown;
} | {
preventSubmit: () => void;
}) => void | Promise<void | Error>) => void;
validators: Record<string, import("../../types").Validator<unknown, import("../../types").DefaultErrorMessages>>;
props: import("../../types").UseFieldProps<unknown, unknown, import("../../types").DefaultErrorMessages>;
dataContext: ContextState;
} & {
pattern?: string;
required?: string;
}) => void;
onChange?: (value: unknown, additionalArgs?: import("../../types").ProvideAdditionalEventArgs & {
errorMessages: import("../../types").DefaultErrorMessages;
connectWithPath: (path: string) => {
getValue: () => unknown;
};
connectWithItemPath: (path: string) => {
getValue: () => unknown;
};
getValueByPath: import("../../hooks/useDataValue").GetValueByPath<unknown>;
getSourceValue: import("../../hooks/useDataValue").GetValueByPath<unknown>;
setFieldEventListener: (path: string, type: "onSubmit" | "onSubmitCall" | "onSubmitRequest" | "onPathChange" | "onMount", callback: (params?: {
value: unknown;
} | {
preventSubmit: () => void;
}) => void | Promise<void | Error>) => void;
validators: Record<string, import("../../types").Validator<unknown, import("../../types").DefaultErrorMessages>>;
props: import("../../types").UseFieldProps<unknown, unknown, import("../../types").DefaultErrorMessages>;
dataContext: ContextState;
} & {
pattern?: string;
required?: string;
}) => void | import("../../types").EventReturnWithStateObjectAndSuccess | Promise<void | import("../../types").EventReturnWithStateObjectAndSuccess>;
help?: import("../../../../components/help-button/HelpButtonInline").HelpProps;
locale?: string;
autoComplete?: AutoFill;
disabled?: boolean;
name?: string;
readOnly?: boolean;
width?: import("../../FieldBlock").FieldBlockWidth;
props?: Record<string, unknown>;
layout?: "horizontal" | "vertical";
translations?: import("../../../../shared/Context").Translations | import("../../../../shared/Context").TranslationCustomLocales;
valueType?: string | number | boolean | (string | number | boolean)[];
warning?: import("../../types").WarningProp<unknown>;
emptyValue?: unknown;
validateInitially?: boolean;
continuousValidation?: boolean;
validateContinuously?: boolean;
htmlAttributes?: Record<string, unknown>;
schema?: import("../../types").AllJSONSchemaVersions<unknown>;
validator?: import("../../types").Validator<unknown, import("../../types").DefaultErrorMessages>;
onChangeValidator?: import("../../types").Validator<unknown, import("../../types").DefaultErrorMessages>;
onBlurValidator?: import("../../types").Validator<unknown, import("../../types").DefaultErrorMessages>;
exportValidators?: Record<string, import("../../types").Validator<unknown, import("../../types").DefaultErrorMessages>>;
validateRequired?: (internal: unknown, { emptyValue, required, isChanged, error, }: {
emptyValue: unknown;
required: boolean;
isChanged: boolean;
error: import("../..").FormError;
}) => import("../..").FormError;
validateUnchanged?: boolean;
errorMessages?: import("../../types").DefaultErrorMessages;
transformIn?: (external: unknown) => unknown;
transformOut?: (internal: unknown, additionalArgs?: unknown) => unknown;
transformValue?: (value: unknown, currentValue?: unknown) => unknown;
provideAdditionalArgs?: (value: unknown, additionalArgs?: import("../../types").ProvideAdditionalEventArgs) => import("../../types").ProvideAdditionalEventArgs;
toInput?: (external: unknown) => unknown;
toEvent?: (internal: unknown, type: "onFocus" | "onBlur" | "onChange" | "onBlurValidator") => unknown;
fromInput?: (external: unknown) => unknown;
fromExternal?: (external: unknown) => unknown;
itemPath?: string;
layoutOptions?: {
width?: import("../../FieldBlock").FieldBlockHorizontalLabelWidth;
minWidth?: import("../../FieldBlock").FieldBlockHorizontalLabelWidth;
maxWidth?: import("../../FieldBlock").FieldBlockHorizontalLabelWidth;
};
labelSuffix?: import("react").ReactNode;
labelDescription?: import("react").ReactNode;
labelDescriptionInline?: boolean;
contentWidth?: import("../../FieldBlock").FieldBlockWidth;
};
inheritedContext: FieldProps;
sharedProviderParams: ContextProps;
};
export default useFieldProvider;