util.d.ts 2.0 KB

1234567891011121314151617181920212223242526272829
  1. /// <reference types="react" />
  2. import { CSSObject } from 'styled-components';
  3. import { ConditionalStyles, TableColumn, Format, Selector, SortOrder, SortFunction } from './types';
  4. export declare function prop<T, K extends keyof T>(obj: T, key: K): T[K];
  5. export declare function isEmpty(field?: string | number | undefined): boolean;
  6. export declare function sort<T>(rows: T[], selector: Selector<T> | string | null | undefined, direction: SortOrder, sortFn?: SortFunction<T> | null): T[];
  7. export declare function parseSelector<T extends Record<string, any>>(row: T, selector: string): T;
  8. export declare function getProperty<T>(row: T, selector: Selector<T> | string | undefined | null | unknown, // unknown allows us to throw an error for JS code
  9. format: Format<T> | undefined | null, rowIndex: number): React.ReactNode;
  10. export declare function insertItem<T>(array: T[] | undefined, item: T, index?: number): T[];
  11. export declare function removeItem<T>(array: T[] | undefined, item: T, keyField?: string): T[];
  12. export declare function decorateColumns<T>(columns: TableColumn<T>[]): TableColumn<T>[];
  13. export declare function getSortDirection(ascDirection?: boolean | undefined): SortOrder;
  14. export declare function handleFunctionProps(object: {
  15. [key: string]: unknown;
  16. }, ...args: unknown[]): {
  17. [key: string]: unknown;
  18. };
  19. export declare function getNumberOfPages(rowCount: number, rowsPerPage: number): number;
  20. export declare function recalculatePage(prevPage: number, nextPage: number): number;
  21. export declare const noop: () => null;
  22. export declare function getConditionalStyle<T>(row: T, conditionalRowStyles?: ConditionalStyles<T>[], baseClassNames?: string[]): {
  23. style: CSSObject;
  24. classNames: string;
  25. };
  26. export declare function isRowSelected<T>(row: T, selectedRows?: T[], keyField?: string): boolean;
  27. export declare function isOdd(num: number): boolean;
  28. export declare function findColumnIndexById<T>(columns: TableColumn<T>[], id: string | undefined): number;
  29. export declare function equalizeId(a: string | number | undefined, b: string | number | undefined): boolean;