simple-table-core 1.3.0 → 1.3.3

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.
@@ -10,9 +10,14 @@ import "../../styles/simple-table.css";
10
10
  import { TableFilterState } from "../../types/FilterTypes";
11
11
  import SortColumn from "../../types/SortColumn";
12
12
  import RowSelectionChangeProps from "../../types/RowSelectionChangeProps";
13
+ import CellClickProps from "../../types/CellClickProps";
14
+ import { RowButton } from "../../types/RowButton";
15
+ import { HeaderDropdown } from "../../types/HeaderDropdownProps";
13
16
  interface SimpleTableProps {
14
17
  allowAnimations?: boolean;
15
18
  cellUpdateFlash?: boolean;
19
+ className?: string;
20
+ columnBorders?: boolean;
16
21
  columnEditorPosition?: ColumnEditorPosition;
17
22
  columnEditorText?: string;
18
23
  columnReordering?: boolean;
@@ -20,27 +25,34 @@ interface SimpleTableProps {
20
25
  defaultHeaders: HeaderObject[];
21
26
  editColumns?: boolean;
22
27
  editColumnsInitOpen?: boolean;
28
+ enableHeaderEditing?: boolean;
23
29
  enableRowSelection?: boolean;
24
30
  expandAll?: boolean;
25
31
  expandIcon?: ReactNode;
26
32
  externalFilterHandling?: boolean;
27
33
  externalSortHandling?: boolean;
34
+ headerDropdown?: HeaderDropdown;
28
35
  height?: string;
29
36
  hideFooter?: boolean;
30
37
  nextIcon?: ReactNode;
31
38
  onCellEdit?: (props: CellChangeProps) => void;
39
+ onCellClick?: (props: CellClickProps) => void;
32
40
  onColumnOrderChange?: (newHeaders: HeaderObject[]) => void;
41
+ onColumnSelect?: (header: HeaderObject) => void;
33
42
  onFilterChange?: (filters: TableFilterState) => void;
34
43
  onGridReady?: () => void;
44
+ onHeaderEdit?: (header: HeaderObject, newLabel: string) => void;
35
45
  onLoadMore?: () => void;
36
46
  onNextPage?: OnNextPage;
37
47
  onRowSelectionChange?: (props: RowSelectionChangeProps) => void;
38
48
  onSortChange?: (sort: SortColumn | null) => void;
39
49
  prevIcon?: ReactNode;
40
50
  rowGrouping?: Accessor[];
51
+ rowButtons?: RowButton[];
41
52
  rowHeight?: number;
42
53
  rowIdAccessor: Accessor;
43
54
  rows: Row[];
55
+ selectionColumnWidth?: number;
44
56
  rowsPerPage?: number;
45
57
  selectableCells?: boolean;
46
58
  selectableColumns?: boolean;
@@ -6,19 +6,28 @@ 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";
10
+ import { RowButton } from "../types/RowButton";
11
+ import { HeaderDropdown } from "../types/HeaderDropdownProps";
9
12
  export interface CellRegistryEntry {
10
13
  updateContent: (newValue: CellValue) => void;
11
14
  }
15
+ export interface HeaderRegistryEntry {
16
+ setEditing: (isEditing: boolean) => void;
17
+ }
12
18
  interface TableContextType {
19
+ activeHeaderDropdown?: HeaderObject | null;
13
20
  allowAnimations?: boolean;
14
21
  areAllRowsSelected?: () => boolean;
15
22
  cellRegistry?: Map<string, CellRegistryEntry>;
16
23
  cellUpdateFlash?: boolean;
17
24
  clearSelection?: () => void;
25
+ columnBorders: boolean;
18
26
  columnReordering: boolean;
19
27
  columnResizing: boolean;
20
28
  draggedHeaderRef: MutableRefObject<HeaderObject | null>;
21
29
  editColumns?: boolean;
30
+ enableHeaderEditing?: boolean;
22
31
  enableRowSelection?: boolean;
23
32
  expandIcon?: ReactNode;
24
33
  filters: TableFilterState;
@@ -33,6 +42,8 @@ interface TableContextType {
33
42
  handleSelectAll?: (isSelected: boolean) => void;
34
43
  handleToggleRow?: (rowId: string) => void;
35
44
  headerContainerRef: RefObject<HTMLDivElement>;
45
+ headerDropdown?: HeaderDropdown;
46
+ headerRegistry?: Map<string, HeaderRegistryEntry>;
36
47
  headers: HeaderObject[];
37
48
  hoveredHeaderRef: MutableRefObject<HeaderObject | null>;
38
49
  isAnimating: boolean;
@@ -46,22 +57,30 @@ interface TableContextType {
46
57
  mainBodyRef: RefObject<HTMLDivElement>;
47
58
  nextIcon: ReactNode;
48
59
  onCellEdit?: (props: any) => void;
60
+ onCellClick?: (props: CellClickProps) => void;
49
61
  onColumnOrderChange?: (newHeaders: HeaderObject[]) => void;
62
+ onColumnSelect?: (header: HeaderObject) => void;
63
+ onHeaderEdit?: (header: HeaderObject, newLabel: string) => void;
50
64
  onLoadMore?: () => void;
51
65
  onSort: OnSortProps;
52
66
  onTableHeaderDragEnd: (newHeaders: HeaderObject[]) => void;
53
67
  pinnedLeftRef: RefObject<HTMLDivElement>;
54
68
  pinnedRightRef: RefObject<HTMLDivElement>;
55
69
  prevIcon: ReactNode;
70
+ rowButtons?: RowButton[];
56
71
  rowGrouping?: Accessor[];
57
72
  rowHeight: number;
58
73
  rowIdAccessor: Accessor;
59
74
  scrollbarWidth: number;
60
75
  selectColumns?: (columnIndices: number[], isShiftKey?: boolean) => void;
61
76
  selectableColumns: boolean;
77
+ selectedColumns: Set<number>;
78
+ columnsWithSelectedCells: Set<number>;
79
+ rowsWithSelectedCells: Set<string>;
62
80
  selectedRows?: Set<string>;
63
81
  selectedRowCount?: number;
64
82
  selectedRowsData?: any[];
83
+ setActiveHeaderDropdown?: Dispatch<SetStateAction<HeaderObject | null>>;
65
84
  setHeaders: Dispatch<SetStateAction<HeaderObject[]>>;
66
85
  setInitialFocusedCell: Dispatch<SetStateAction<Cell | null>>;
67
86
  setIsResizing: Dispatch<SetStateAction<boolean>>;
@@ -0,0 +1,23 @@
1
+ /// <reference types="react" />
2
+ interface DropdownPosition {
3
+ top?: number;
4
+ left?: number;
5
+ right?: number;
6
+ bottom?: number;
7
+ }
8
+ interface UseDropdownPositionOptions {
9
+ isOpen: boolean;
10
+ estimatedHeight?: number;
11
+ estimatedWidth?: number;
12
+ margin?: number;
13
+ }
14
+ interface UseDropdownPositionReturn {
15
+ triggerRef: React.RefObject<HTMLDivElement>;
16
+ position: DropdownPosition;
17
+ }
18
+ /**
19
+ * Custom hook for calculating dropdown position relative to a trigger element
20
+ * Uses fixed positioning to work properly in overflow containers
21
+ */
22
+ export declare const useDropdownPosition: ({ isOpen, estimatedHeight, estimatedWidth, margin, }: UseDropdownPositionOptions) => UseDropdownPositionReturn;
23
+ export default useDropdownPosition;
@@ -1,8 +1,11 @@
1
- declare const useHandleOutsideClick: ({ selectableColumns, selectedCells, selectedColumns, setSelectedCells, setSelectedColumns, }: {
1
+ import HeaderObject from "../types/HeaderObject";
2
+ declare const useHandleOutsideClick: ({ selectableColumns, selectedCells, selectedColumns, setSelectedCells, setSelectedColumns, activeHeaderDropdown, setActiveHeaderDropdown, }: {
2
3
  selectableColumns: boolean;
3
4
  selectedCells: Set<string>;
4
5
  selectedColumns: Set<number>;
5
6
  setSelectedCells: (cells: Set<string>) => void;
6
7
  setSelectedColumns: (columns: Set<number>) => void;
8
+ activeHeaderDropdown?: HeaderObject | null | undefined;
9
+ setActiveHeaderDropdown?: ((header: HeaderObject | null) => void) | undefined;
7
10
  }) => void;
8
11
  export default useHandleOutsideClick;
@@ -29,5 +29,7 @@ declare const useSelection: ({ selectableCells, headers, tableRows, rowIdAccesso
29
29
  setSelectedCells: import("react").Dispatch<import("react").SetStateAction<Set<string>>>;
30
30
  setSelectedColumns: import("react").Dispatch<import("react").SetStateAction<Set<number>>>;
31
31
  deleteSelectedCells: () => void;
32
+ columnsWithSelectedCells: Set<number>;
33
+ rowsWithSelectedCells: Set<string>;
32
34
  };
33
35
  export default useSelection;
@@ -1,11 +1,12 @@
1
1
  import { MutableRefObject } from "react";
2
2
  import { Row, TableRefType } from "..";
3
- import { CellRegistryEntry } from "../context/TableContext";
3
+ import { CellRegistryEntry, HeaderRegistryEntry } from "../context/TableContext";
4
4
  import { Accessor } from "../types/HeaderObject";
5
- declare const useTableAPI: ({ tableRef, rows, rowIdAccessor, cellRegistryRef, }: {
5
+ declare const useTableAPI: ({ tableRef, rows, rowIdAccessor, cellRegistryRef, headerRegistryRef, }: {
6
6
  tableRef?: MutableRefObject<TableRefType | null> | undefined;
7
7
  rows: Row[];
8
8
  rowIdAccessor: Accessor;
9
9
  cellRegistryRef: MutableRefObject<Map<string, CellRegistryEntry>>;
10
+ headerRegistryRef: MutableRefObject<Map<string, HeaderRegistryEntry>>;
10
11
  }) => void;
11
12
  export default useTableAPI;
package/dist/index.d.ts CHANGED
@@ -14,11 +14,16 @@ import SharedTableProps from "./types/SharedTableProps";
14
14
  import SortColumn from "./types/SortColumn";
15
15
  import TableCellProps from "./types/TableCellProps";
16
16
  import TableHeaderProps from "./types/TableHeaderProps";
17
- import TableRefType from "./types/TableRefType";
17
+ import TableRefType, { SetHeaderRenameProps } from "./types/TableRefType";
18
18
  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
22
  import RowSelectionChangeProps from "./types/RowSelectionChangeProps";
23
+ import CellClickProps from "./types/CellClickProps";
24
+ import CellRendererProps, { CellRenderer } from "./types/CellRendererProps";
25
+ import HeaderRendererProps, { HeaderRenderer } from "./types/HeaderRendererProps";
26
+ import HeaderDropdownProps, { HeaderDropdown } from "./types/HeaderDropdownProps";
27
+ import { RowButtonProps } from "./types/RowButton";
23
28
  export { SimpleTable };
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, };
29
+ export type { Accessor, AggregationConfig, AggregationType, BoundingBox, Cell, CellChangeProps, CellClickProps, CellRenderer, CellRendererProps, CellValue, ColumnEditorPosition, ColumnType, DragHandlerProps, EnumOption, FilterCondition, HeaderDropdown, HeaderDropdownProps, HeaderObject, HeaderRenderer, HeaderRendererProps, OnSortProps, Row, RowButtonProps, RowSelectionChangeProps, SetHeaderRenameProps, SharedTableProps, SortColumn, TableCellProps, TableFilterState, TableHeaderProps, TableRefType, TableRowProps, Theme, UpdateDataProps, };