simple-table-core 1.2.7 → 1.3.0

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.
@@ -13,7 +13,7 @@ export declare const ANIMATION_CONFIGS: {
13
13
  readonly delay: 0;
14
14
  };
15
15
  readonly ROW_REORDER: {
16
- readonly duration: 10000;
16
+ readonly duration: 200;
17
17
  readonly easing: "cubic-bezier(0.2, 0.0, 0.2, 1)";
18
18
  readonly delay: 0;
19
19
  };
@@ -9,6 +9,7 @@ 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";
12
13
  interface SimpleTableProps {
13
14
  allowAnimations?: boolean;
14
15
  cellUpdateFlash?: boolean;
@@ -19,6 +20,7 @@ interface SimpleTableProps {
19
20
  defaultHeaders: HeaderObject[];
20
21
  editColumns?: boolean;
21
22
  editColumnsInitOpen?: boolean;
23
+ enableRowSelection?: boolean;
22
24
  expandAll?: boolean;
23
25
  expandIcon?: ReactNode;
24
26
  externalFilterHandling?: boolean;
@@ -32,6 +34,7 @@ interface SimpleTableProps {
32
34
  onGridReady?: () => void;
33
35
  onLoadMore?: () => void;
34
36
  onNextPage?: OnNextPage;
37
+ onRowSelectionChange?: (props: RowSelectionChangeProps) => void;
35
38
  onSortChange?: (sort: SortColumn | null) => void;
36
39
  prevIcon?: ReactNode;
37
40
  rowGrouping?: Accessor[];
@@ -1,10 +1,11 @@
1
1
  import CellValue from "../../../types/CellValue";
2
2
  import EnumOption from "../../../types/EnumOption";
3
+ import { ColumnType } from "../../../types/HeaderObject";
3
4
  interface EditableCellProps {
4
5
  enumOptions?: EnumOption[];
5
6
  onChange: (newValue: CellValue) => void;
6
7
  setIsEditing: (isEditing: boolean) => void;
7
- type?: "string" | "number" | "boolean" | "date" | "enum";
8
+ type?: ColumnType;
8
9
  value: CellValue;
9
10
  }
10
11
  declare const EditableCell: ({ enumOptions, onChange, setIsEditing, type, value, }: EditableCellProps) => import("react/jsx-runtime").JSX.Element;
@@ -11,12 +11,15 @@ export interface CellRegistryEntry {
11
11
  }
12
12
  interface TableContextType {
13
13
  allowAnimations?: boolean;
14
+ areAllRowsSelected?: () => boolean;
14
15
  cellRegistry?: Map<string, CellRegistryEntry>;
15
16
  cellUpdateFlash?: boolean;
17
+ clearSelection?: () => void;
16
18
  columnReordering: boolean;
17
19
  columnResizing: boolean;
18
20
  draggedHeaderRef: MutableRefObject<HeaderObject | null>;
19
21
  editColumns?: boolean;
22
+ enableRowSelection?: boolean;
20
23
  expandIcon?: ReactNode;
21
24
  filters: TableFilterState;
22
25
  forceUpdate: () => void;
@@ -26,6 +29,9 @@ interface TableContextType {
26
29
  handleClearFilter: (accessor: Accessor) => void;
27
30
  handleMouseDown: (cell: Cell) => void;
28
31
  handleMouseOver: (cell: Cell) => void;
32
+ handleRowSelect?: (rowId: string, isSelected: boolean) => void;
33
+ handleSelectAll?: (isSelected: boolean) => void;
34
+ handleToggleRow?: (rowId: string) => void;
29
35
  headerContainerRef: RefObject<HTMLDivElement>;
30
36
  headers: HeaderObject[];
31
37
  hoveredHeaderRef: MutableRefObject<HeaderObject | null>;
@@ -33,6 +39,7 @@ interface TableContextType {
33
39
  isCopyFlashing: (cell: Cell) => boolean;
34
40
  isInitialFocusedCell: (cell: Cell) => boolean;
35
41
  isResizing: boolean;
42
+ isRowSelected?: (rowId: string) => boolean;
36
43
  isScrolling: boolean;
37
44
  isSelected: (cell: Cell) => boolean;
38
45
  isWarningFlashing: (cell: Cell) => boolean;
@@ -52,12 +59,16 @@ interface TableContextType {
52
59
  scrollbarWidth: number;
53
60
  selectColumns?: (columnIndices: number[], isShiftKey?: boolean) => void;
54
61
  selectableColumns: boolean;
62
+ selectedRows?: Set<string>;
63
+ selectedRowCount?: number;
64
+ selectedRowsData?: any[];
55
65
  setHeaders: Dispatch<SetStateAction<HeaderObject[]>>;
56
66
  setInitialFocusedCell: Dispatch<SetStateAction<Cell | null>>;
57
67
  setIsResizing: Dispatch<SetStateAction<boolean>>;
58
68
  setIsScrolling: Dispatch<SetStateAction<boolean>>;
59
69
  setSelectedCells: Dispatch<SetStateAction<Set<string>>>;
60
70
  setSelectedColumns: Dispatch<SetStateAction<Set<number>>>;
71
+ setSelectedRows?: Dispatch<SetStateAction<Set<string>>>;
61
72
  setUnexpandedRows: Dispatch<SetStateAction<Set<string>>>;
62
73
  shouldPaginate: boolean;
63
74
  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
@@ -6,7 +6,7 @@ import CellValue from "./types/CellValue";
6
6
  import ColumnEditorPosition from "./types/ColumnEditorPosition";
7
7
  import DragHandlerProps from "./types/DragHandlerProps";
8
8
  import EnumOption from "./types/EnumOption";
9
- import HeaderObject, { Accessor } from "./types/HeaderObject";
9
+ import HeaderObject, { Accessor, ColumnType } from "./types/HeaderObject";
10
10
  import { AggregationConfig, AggregationType } from "./types/AggregationTypes";
11
11
  import OnSortProps from "./types/OnSortProps";
12
12
  import Row from "./types/Row";
@@ -19,5 +19,6 @@ 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";
22
23
  export { SimpleTable };
23
- export type { Accessor, AggregationConfig, AggregationType, BoundingBox, Cell, CellChangeProps, CellValue, ColumnEditorPosition, DragHandlerProps, EnumOption, FilterCondition, HeaderObject, OnSortProps, Row, SharedTableProps, SortColumn, TableCellProps, TableFilterState, TableHeaderProps, TableRefType, TableRowProps, Theme, UpdateDataProps, };
24
+ export type { Accessor, AggregationConfig, AggregationType, BoundingBox, Cell, CellChangeProps, CellValue, ColumnEditorPosition, ColumnType, DragHandlerProps, EnumOption, FilterCondition, HeaderObject, OnSortProps, Row, RowSelectionChangeProps, SharedTableProps, SortColumn, TableCellProps, TableFilterState, TableHeaderProps, TableRefType, TableRowProps, Theme, UpdateDataProps, };