simple-table-core 1.2.8 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/animate/animation-utils.d.ts +1 -1
- package/dist/components/simple-table/SimpleTable.d.ts +6 -0
- package/dist/context/TableContext.d.ts +13 -0
- package/dist/hooks/useRowSelection.d.ts +23 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.es.js +1 -1
- package/dist/index.js +1 -1
- package/dist/styles.css +1 -1
- package/dist/types/CellClickProps.d.ts +13 -0
- package/dist/types/HeaderObject.d.ts +2 -0
- package/dist/types/RowSelectionChangeProps.d.ts +7 -0
- package/dist/utils/rowSelectionUtils.d.ts +38 -0
- package/package.json +1 -1
|
@@ -9,9 +9,12 @@ import OnNextPage from "../../types/OnNextPage";
|
|
|
9
9
|
import "../../styles/simple-table.css";
|
|
10
10
|
import { TableFilterState } from "../../types/FilterTypes";
|
|
11
11
|
import SortColumn from "../../types/SortColumn";
|
|
12
|
+
import RowSelectionChangeProps from "../../types/RowSelectionChangeProps";
|
|
13
|
+
import CellClickProps from "../../types/CellClickProps";
|
|
12
14
|
interface SimpleTableProps {
|
|
13
15
|
allowAnimations?: boolean;
|
|
14
16
|
cellUpdateFlash?: boolean;
|
|
17
|
+
className?: string;
|
|
15
18
|
columnEditorPosition?: ColumnEditorPosition;
|
|
16
19
|
columnEditorText?: string;
|
|
17
20
|
columnReordering?: boolean;
|
|
@@ -19,6 +22,7 @@ interface SimpleTableProps {
|
|
|
19
22
|
defaultHeaders: HeaderObject[];
|
|
20
23
|
editColumns?: boolean;
|
|
21
24
|
editColumnsInitOpen?: boolean;
|
|
25
|
+
enableRowSelection?: boolean;
|
|
22
26
|
expandAll?: boolean;
|
|
23
27
|
expandIcon?: ReactNode;
|
|
24
28
|
externalFilterHandling?: boolean;
|
|
@@ -27,11 +31,13 @@ interface SimpleTableProps {
|
|
|
27
31
|
hideFooter?: boolean;
|
|
28
32
|
nextIcon?: ReactNode;
|
|
29
33
|
onCellEdit?: (props: CellChangeProps) => void;
|
|
34
|
+
onCellClick?: (props: CellClickProps) => void;
|
|
30
35
|
onColumnOrderChange?: (newHeaders: HeaderObject[]) => void;
|
|
31
36
|
onFilterChange?: (filters: TableFilterState) => void;
|
|
32
37
|
onGridReady?: () => void;
|
|
33
38
|
onLoadMore?: () => void;
|
|
34
39
|
onNextPage?: OnNextPage;
|
|
40
|
+
onRowSelectionChange?: (props: RowSelectionChangeProps) => void;
|
|
35
41
|
onSortChange?: (sort: SortColumn | null) => void;
|
|
36
42
|
prevIcon?: ReactNode;
|
|
37
43
|
rowGrouping?: Accessor[];
|
|
@@ -6,17 +6,21 @@ import HeaderObject, { Accessor } from "../types/HeaderObject";
|
|
|
6
6
|
import OnSortProps from "../types/OnSortProps";
|
|
7
7
|
import Theme from "../types/Theme";
|
|
8
8
|
import CellValue from "../types/CellValue";
|
|
9
|
+
import CellClickProps from "../types/CellClickProps";
|
|
9
10
|
export interface CellRegistryEntry {
|
|
10
11
|
updateContent: (newValue: CellValue) => void;
|
|
11
12
|
}
|
|
12
13
|
interface TableContextType {
|
|
13
14
|
allowAnimations?: boolean;
|
|
15
|
+
areAllRowsSelected?: () => boolean;
|
|
14
16
|
cellRegistry?: Map<string, CellRegistryEntry>;
|
|
15
17
|
cellUpdateFlash?: boolean;
|
|
18
|
+
clearSelection?: () => void;
|
|
16
19
|
columnReordering: boolean;
|
|
17
20
|
columnResizing: boolean;
|
|
18
21
|
draggedHeaderRef: MutableRefObject<HeaderObject | null>;
|
|
19
22
|
editColumns?: boolean;
|
|
23
|
+
enableRowSelection?: boolean;
|
|
20
24
|
expandIcon?: ReactNode;
|
|
21
25
|
filters: TableFilterState;
|
|
22
26
|
forceUpdate: () => void;
|
|
@@ -26,6 +30,9 @@ interface TableContextType {
|
|
|
26
30
|
handleClearFilter: (accessor: Accessor) => void;
|
|
27
31
|
handleMouseDown: (cell: Cell) => void;
|
|
28
32
|
handleMouseOver: (cell: Cell) => void;
|
|
33
|
+
handleRowSelect?: (rowId: string, isSelected: boolean) => void;
|
|
34
|
+
handleSelectAll?: (isSelected: boolean) => void;
|
|
35
|
+
handleToggleRow?: (rowId: string) => void;
|
|
29
36
|
headerContainerRef: RefObject<HTMLDivElement>;
|
|
30
37
|
headers: HeaderObject[];
|
|
31
38
|
hoveredHeaderRef: MutableRefObject<HeaderObject | null>;
|
|
@@ -33,12 +40,14 @@ interface TableContextType {
|
|
|
33
40
|
isCopyFlashing: (cell: Cell) => boolean;
|
|
34
41
|
isInitialFocusedCell: (cell: Cell) => boolean;
|
|
35
42
|
isResizing: boolean;
|
|
43
|
+
isRowSelected?: (rowId: string) => boolean;
|
|
36
44
|
isScrolling: boolean;
|
|
37
45
|
isSelected: (cell: Cell) => boolean;
|
|
38
46
|
isWarningFlashing: (cell: Cell) => boolean;
|
|
39
47
|
mainBodyRef: RefObject<HTMLDivElement>;
|
|
40
48
|
nextIcon: ReactNode;
|
|
41
49
|
onCellEdit?: (props: any) => void;
|
|
50
|
+
onCellClick?: (props: CellClickProps) => void;
|
|
42
51
|
onColumnOrderChange?: (newHeaders: HeaderObject[]) => void;
|
|
43
52
|
onLoadMore?: () => void;
|
|
44
53
|
onSort: OnSortProps;
|
|
@@ -52,12 +61,16 @@ interface TableContextType {
|
|
|
52
61
|
scrollbarWidth: number;
|
|
53
62
|
selectColumns?: (columnIndices: number[], isShiftKey?: boolean) => void;
|
|
54
63
|
selectableColumns: boolean;
|
|
64
|
+
selectedRows?: Set<string>;
|
|
65
|
+
selectedRowCount?: number;
|
|
66
|
+
selectedRowsData?: any[];
|
|
55
67
|
setHeaders: Dispatch<SetStateAction<HeaderObject[]>>;
|
|
56
68
|
setInitialFocusedCell: Dispatch<SetStateAction<Cell | null>>;
|
|
57
69
|
setIsResizing: Dispatch<SetStateAction<boolean>>;
|
|
58
70
|
setIsScrolling: Dispatch<SetStateAction<boolean>>;
|
|
59
71
|
setSelectedCells: Dispatch<SetStateAction<Set<string>>>;
|
|
60
72
|
setSelectedColumns: Dispatch<SetStateAction<Set<number>>>;
|
|
73
|
+
setSelectedRows?: Dispatch<SetStateAction<Set<string>>>;
|
|
61
74
|
setUnexpandedRows: Dispatch<SetStateAction<Set<string>>>;
|
|
62
75
|
shouldPaginate: boolean;
|
|
63
76
|
sortDownIcon: ReactNode;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import Row from "../types/Row";
|
|
3
|
+
import { Accessor } from "../types/HeaderObject";
|
|
4
|
+
import RowSelectionChangeProps from "../types/RowSelectionChangeProps";
|
|
5
|
+
interface UseRowSelectionProps {
|
|
6
|
+
rows: Row[];
|
|
7
|
+
rowIdAccessor: Accessor;
|
|
8
|
+
onRowSelectionChange?: (props: RowSelectionChangeProps) => void;
|
|
9
|
+
enableRowSelection?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const useRowSelection: ({ rows, rowIdAccessor, onRowSelectionChange, enableRowSelection, }: UseRowSelectionProps) => {
|
|
12
|
+
selectedRows: Set<string>;
|
|
13
|
+
setSelectedRows: import("react").Dispatch<import("react").SetStateAction<Set<string>>>;
|
|
14
|
+
isRowSelected: (rowId: string) => boolean;
|
|
15
|
+
areAllRowsSelected: () => boolean;
|
|
16
|
+
selectedRowCount: number;
|
|
17
|
+
selectedRowsData: Row[];
|
|
18
|
+
handleRowSelect: (rowId: string, isSelected: boolean) => void;
|
|
19
|
+
handleSelectAll: (isSelected: boolean) => void;
|
|
20
|
+
handleToggleRow: (rowId: string) => void;
|
|
21
|
+
clearSelection: () => void;
|
|
22
|
+
};
|
|
23
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -19,5 +19,7 @@ import TableRowProps from "./types/TableRowProps";
|
|
|
19
19
|
import Theme from "./types/Theme";
|
|
20
20
|
import UpdateDataProps from "./types/UpdateCellProps";
|
|
21
21
|
import { FilterCondition, TableFilterState } from "./types/FilterTypes";
|
|
22
|
+
import RowSelectionChangeProps from "./types/RowSelectionChangeProps";
|
|
23
|
+
import CellClickProps from "./types/CellClickProps";
|
|
22
24
|
export { SimpleTable };
|
|
23
|
-
export type { Accessor, AggregationConfig, AggregationType, BoundingBox, Cell, CellChangeProps, CellValue, ColumnEditorPosition, ColumnType, DragHandlerProps, EnumOption, FilterCondition, HeaderObject, OnSortProps, Row, SharedTableProps, SortColumn, TableCellProps, TableFilterState, TableHeaderProps, TableRefType, TableRowProps, Theme, UpdateDataProps, };
|
|
25
|
+
export type { Accessor, AggregationConfig, AggregationType, BoundingBox, Cell, CellChangeProps, CellClickProps, CellValue, ColumnEditorPosition, ColumnType, DragHandlerProps, EnumOption, FilterCondition, HeaderObject, OnSortProps, Row, RowSelectionChangeProps, SharedTableProps, SortColumn, TableCellProps, TableFilterState, TableHeaderProps, TableRefType, TableRowProps, Theme, UpdateDataProps, };
|