mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* react-bootstrap-table-next: add initial typings * [name react-bootstrap-table2] add modules * [react-bootstrap-table-next] add filter example * [react-bootstrap-table2-filter] add filter example * [react-bootstrap-table-next] update types - loosen table typing after testing with real life projects - remove enums in favour of constant declarations and aggregation types * [react-bootstrap-table-next] fix cell align type * [react-bootstrap-table-next] update tests * [react-bootstrap-table2-toolkit] narrow types * [react-bootstrap-table-next] fix test column * [react-bootstrap-table2-filter] update comments * [react-bootstrap-table-next] fix documentation * [react-bootstrap-table2-filter] fix typo in header * [react-bootstrap-table-next] fix issues * [react-bootstrap-table-next] add definitions - expand toolkit definitions - add standalone pagination component types * [react-bootstrap-table-next] loosen column type * update typescript version * fix: typescript version mixup * fix: remove optional chaining, change TS version
121 lines
3.2 KiB
TypeScript
121 lines
3.2 KiB
TypeScript
// Type definitions for react-bootstrap-table2-toolkit 2.1
|
|
// Project: https://github.com/react-bootstrap-table/react-bootstrap-table2#readme
|
|
// Definitions by: Wlad Meixner <https://github.com/gosticks>
|
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
// TypeScript Version: 3.0
|
|
|
|
// documentation taken from https://react-bootstrap-table.github.io/react-bootstrap-table2/docs/table-props.html
|
|
|
|
import { CSSProperties, ReactNode } from 'react';
|
|
import { ColumnDescription } from 'react-bootstrap-table-next';
|
|
|
|
/**
|
|
* declaration for table toolkit sub module
|
|
*/
|
|
export interface InjectedSearchProps {
|
|
searchText: string;
|
|
onSearch: (val: string) => void;
|
|
onClear: () => void;
|
|
}
|
|
|
|
export interface SearchMatchProps<T extends object = any> {
|
|
searchText: string;
|
|
value: string;
|
|
column: ColumnDescription<T>;
|
|
row: T;
|
|
}
|
|
|
|
export interface TableSearchProps<T extends object = any> {
|
|
searchFormatted?: boolean;
|
|
defaultSearch?: string;
|
|
placeholder?: string;
|
|
onColumnMatch?: (props: SearchMatchProps<T>) => void;
|
|
customMatchFunc?: (props: SearchMatchProps<T>) => boolean;
|
|
}
|
|
|
|
export interface TableToolkitProps<T extends object = any> {
|
|
bootstrap4?: boolean;
|
|
search?: TableSearchProps<T> | boolean;
|
|
keyField: keyof T | string;
|
|
data: T[];
|
|
ref?: any;
|
|
columns: Array<ColumnDescription<T>>;
|
|
children: (props: ToolkitContextType) => JSX.Element;
|
|
}
|
|
|
|
export interface ToolkitContextType {
|
|
searchProps: InjectedSearchProps;
|
|
csvProps: {
|
|
onExport: () => void;
|
|
};
|
|
columnToggleProps: {
|
|
columns: ColumnDescription[];
|
|
/**
|
|
* array of toggled columns
|
|
*/
|
|
toggles: boolean[];
|
|
onColumnToggle: (dataField: string) => void;
|
|
};
|
|
baseProps: {
|
|
/**
|
|
* table key field
|
|
*/
|
|
keyField: any;
|
|
columns: ColumnDescription[];
|
|
data: any[];
|
|
bootstrap4?: boolean;
|
|
};
|
|
}
|
|
|
|
export interface ToggleListProps {
|
|
columns: ColumnDescription[];
|
|
/**
|
|
* array of toggled columns
|
|
*/
|
|
toggles: boolean[];
|
|
onColumnToggle: (dataField: string) => void;
|
|
btnClassName?: string;
|
|
className?: string;
|
|
contextual?: string;
|
|
}
|
|
|
|
export namespace ColumnToggle {
|
|
function ToggleList(props: ToggleListProps): React.ReactElement | null;
|
|
}
|
|
|
|
export interface ExportCSVButtonProps {
|
|
children: ReactNode;
|
|
onExport: () => void;
|
|
style?: CSSProperties;
|
|
className?: string;
|
|
}
|
|
|
|
export namespace CSVExport {
|
|
function ToggleList(props: ExportCSVButtonProps): React.ReactElement | null;
|
|
}
|
|
|
|
export interface SearchBarProps {
|
|
onSearch: (searchText: string) => void;
|
|
className?: string;
|
|
placeholder?: string;
|
|
style?: CSSProperties;
|
|
delay?: number;
|
|
searchText?: string;
|
|
tableId?: string;
|
|
}
|
|
export interface ClearSearchButtonProps {
|
|
onClear?: () => void;
|
|
className?: string;
|
|
text?: string;
|
|
}
|
|
|
|
export namespace Search {
|
|
function SearchBar(props: SearchBarProps): React.ReactElement | null;
|
|
function ClearSearchButton(props: ExportCSVButtonProps): React.ReactElement | null;
|
|
}
|
|
|
|
export const ToolkitContext: React.Context<ToolkitContextType>;
|
|
|
|
declare function ToolkitProvider(props: TableToolkitProps): React.ReactElement | null;
|
|
export default ToolkitProvider;
|