UNPKG

react-select-table

Version:
135 lines (134 loc) 5.37 kB
/** * @namespace SelectorsTypes */ /** * @typedef {Selectors} SelectorsTypes.SelectorsClass */ /** * @typedef {import('../store/store').StoreTypes.State} StateType */ /** * @typedef {import('../store/store').StoreTypes.RowKey} RowKeyType */ export default class Selectors { constructor(options: any); /** @private */ private options; /** * Returns the slice of the state that belongs to the table * * @param {object} state The whole redux state * @returns {StateType} The table's state */ getTableState(state: object): StateType; /** * Returns the page size if pagination is enabled, or the total count of items if it is disabled * * @param {StateType} state The table's state * @returns {number} The maximum number of rows than can be visible at once */ getPageSize(state: StateType): number; /** * Returns the number of pages based on the page size * * @param {StateType} state The table's state * @returns {number} The number of pages */ getPageCount(state: StateType): number; /** * Returns the index of the page that a row is in * * @param {StateType} state The table's state * @param {number} itemIndex A row index * @returns {number} The index of the page the row is in */ getItemPageIndex(state: StateType, itemIndex: number): number; /** * Returns the index of the currently selected page * * @param {StateType} state The table's state * @returns {number} The index of the current page */ getPageIndex(state: StateType): number; /** * Returns the index of the top most visible row on the current page, relative to the first row of the first page * * @param {StateType} state The table's state * @returns {number} The index of the first visible row */ getPageIndexOffset(state: StateType): number; /** * Returns a serializable subset of the table's state, which can be passed to {@link Options.savedState} * to restore the table to the present state * * @param {StateType} state The table's state * @param {number} modules {@link https://docs.revenera.com/installshield19helplib/helplibrary/BitFlags.htm|Bit flags} * (exported as saveModules) that control which parts of the state to save * @returns {object} A part of the table's state */ getSaveState(state: StateType, modules: number): object; /** * Returns the index of the active row in the current page * * @function * @param {StateType} state The table's state * @returns {number} The index of the active row */ getActiveRowIndex(state: StateType): number; /** * Returns the key of the active row * * @param {StateType} state The table's state * @returns {RowKeyType} The key of the active row */ getActiveKey(state: StateType): RowKeyType; /** * Returns whether a row is selected * * @param {StateType} state The table's state * @param {number} rowIndex The index of the row in the current page * @returns {boolean} Whether the row is selected */ getSelected(state: StateType, rowIndex: number): boolean; /** * Returns true if the table is neither loading nor has an error occurred * * @param {StateType} state The table's state * @returns {boolean} Whether the state is normal */ getIsStateNormal(state: StateType): boolean; /** * If the table is loading or an error has occurred, returns an empty {@link SetTypes.Set}, * in all other cases returns the {@link StoreTypes.State.selected} property. * * @param {StateType} state The table's state * @returns {import('../utils/setUtils').SetTypes.Set} A set containing the selected keys */ getSelection(state: StateType): any; /** * Returns the value to be passed to event handlers that take the current selection as an argument * * @param {StateType} state The table's state * @returns {import('./Events').EventsTypes.SelectionArgType} See {@link EventsTypes.SelectionArg} */ getSelectionArg(state: StateType): any; /** * Returns the argument to be passed to the onContextMenu event handler * * @param {StateType} state The table's state * @param {boolean} [forceEmpty=false] Return an argument that reflects an empty selection, even if it isn't * @param {boolean} [forceSelection=false] Always return the selected keys, even in listBox mode * @returns {import('./Events').EventsTypes.ContextMenuArgType} * When {@link Options.listBox} is false or forceSelection is true, it is the same as {@link EventsTypes.SelectionArg}. * * In all other cases the key of the active row is returned: As is when {@link Options.multiSelect} is false, * or in a {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set|Set} * when Options.multiSelect is true. */ getContextMenuArg(state: StateType, forceEmpty?: boolean | undefined, forceSelection?: boolean | undefined): any; } export namespace SelectorsTypes { type SelectorsClass = Selectors; } export type StateType = import('../store/store').StoreTypes.State; export type RowKeyType = import('../store/store').StoreTypes.RowKey;