react-select-table
Version:
React table component with selectable items
72 lines (71 loc) • 2.98 kB
TypeScript
/**
* @param {Partial<Options>} options The options to override the defaults
* @returns {Options} The complete set of options
*/
export function getOptions(options: Partial<Options>): Options;
/**
* Modifies the default table options
*
* @param {Partial<Options>} options The options to change
*/
export function setDefaultOptions(options: Partial<Options>): void;
export type ItemPredicate = (row: object, filter: any) => boolean;
export type ItemComparator = (left: object, right: object, key: string) => number | void;
export type SearchPhraseParser = (phrase: string) => string;
/**
* The table options
*/
export type Options = {
/**
* Takes a row and the item filter, and must return true if the row should be visible
*/
itemPredicate: ItemPredicate;
/**
* Takes the value of a property of two rows, and the path of that property, and must return: <ul><li>1, If the first is larger than the second</li> <li>0, If the values are equal</li> <li>-1, If the first is smaller than the second</li> <li>undefined, to fall back to the default lodash comparator</li></ul>
*/
itemComparator: ItemComparator;
/**
* Takes the search phrase typed in by the user, or the value of the {@link searchProperty } of a row. The returned values are compared to each other
*/
searchPhraseParser: SearchPhraseParser;
/**
* The path of a row property for the search phrase to be matched against. Set to empty string to disable searching
*/
searchProperty: string;
/**
* Allow multiple rows to be selected simultaneously
*/
multiSelect: boolean;
/**
* Retain selection when clicking in the space below the rows, and when right-clicking on another row
*/
listBox: boolean;
/**
* The path of a row property that has a unique value for each row, or a function that takes a row as an argument and returns a value unique to that row. In either case, the unique value must be a string or a number
*/
keyBy: string | ((arg0: object) => string | number);
/**
* When resizing a column, shrink the next one by the same amount, keeping the total width constant
*/
constantWidth: boolean;
/**
* The minimum width in pixels allowed for a column when resizing it, and before a scrollbar appears when resizing the container
*/
minColumnWidth: number;
/**
* The path of the redux table state. Set to empty string if the table reducer is the root
*/
statePath: string;
/**
* Load from a previously saved state, used for restoring a user's session. Takes an object returned from {@link Selectors.getSaveState }
*/
savedState: object;
/**
* Half the minimum number of rows that can be rendered at one time (set to 0 to disable chunking).
*/
chunkSize: number;
/**
* If you use a custom context for your Provider, you can pass it here
*/
context: import("react").Context<any>;
};