@dnb/eufemia
Version:
DNB Eufemia Design System UI Library
22 lines (21 loc) • 840 B
TypeScript
import type { Path } from '../types';
import type { ContextState } from '../DataContext/Context';
export type UseDataValueProps<Value> = {
path?: Path | undefined;
value?: Value;
};
export type GetValueByPath<Value = unknown> = <T = Value>(path: Path) => T;
type UseDataValueOptions = {
pathType?: 'auto' | 'absolute' | 'iterate';
};
export default function useDataValue<Value>(pathProp?: Path | Array<Path> | undefined, value?: Value, options?: UseDataValueOptions): {
getSourceValue: (source: Path | Value) => any;
getValueByPath: (path: Path, data?: ContextState["data"]) => any;
getValueByIteratePath: (path: Path) => any;
moveValueToPath: <T>(path: Path, value: T, object?: {}) => T;
getData: (path: Path, options?: {
includeCurrentPath?: boolean;
}) => any;
value: Value;
};
export {};