@dnb/eufemia
Version:
DNB Eufemia Design System UI Library
22 lines (21 loc) • 777 B
TypeScript
import type { Path } from '../../types';
import type { SharedStateId } from '../../../../shared/helpers/useSharedState';
export type IterateCountProps = {
/**
* The path (JSON Pointer) to the array or object to count.
*/
path: Path;
/**
* A Form.Handler or DataContext `id` for when called outside of the context.
*/
id?: SharedStateId;
/**
* A filter function to filter the data before counting.
*/
filter?: (item: unknown) => boolean;
};
export declare function Count(props: IterateCountProps): number;
export declare function count(props: IterateCountProps): number;
export declare function useCount(id?: SharedStateId): {
count: (path: IterateCountProps["path"], filter?: IterateCountProps["filter"]) => number;
};