react-base-data-table 0.5.10 → 0.5.12

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.
@@ -50,4 +50,4 @@ export interface BaseTableProps<T> {
50
50
  onAddListOption?: (newOption: string, header: BaseTableHeader) => Promise<void> | void;
51
51
  onRowsReordered?: (fromIndex: number, toIndex: number) => Promise<void> | void;
52
52
  }
53
- export default function BaseTable<T extends TableItem>(props: Readonly<BaseTableProps<T>>): import("react/jsx-runtime").JSX.Element;
53
+ export default function BaseTable<T>(props: Readonly<BaseTableProps<T>>): import("react/jsx-runtime").JSX.Element;
@@ -1,11 +1,11 @@
1
1
  import { useTableInteractions, type TableInteractionsProps } from "../hooks/useTableInteractions";
2
2
  import type TableItem from "../models/TableItem";
3
3
  import { useRowDragDrop } from "../hooks/useRowDragDrop";
4
- type TableInteractionContextValue = ReturnType<typeof useTableInteractions> & ReturnType<typeof useRowDragDrop>;
4
+ type TableInteractionContextValue<T extends TableItem = TableItem> = ReturnType<typeof useTableInteractions<T>> & ReturnType<typeof useRowDragDrop<T>>;
5
5
  export declare const TableInteractionProvider: <T extends TableItem>({ children, groupedItemsEntries, onChange, onBulkChange, onBulkFieldChange, onRowDoubleClick, onRowsReordered, onSaveComment, onDeleteComment, onSetHighlightCondition, onRemoveHighlightCondition, onAddListOption, }: TableInteractionsProps<T> & {
6
6
  children: React.ReactNode;
7
7
  } & {
8
8
  onRowsReordered?: ((fromIndex: number, toIndex: number) => void) | undefined;
9
9
  }) => import("react/jsx-runtime").JSX.Element;
10
- export declare function useTableInteractionContext(): TableInteractionContextValue;
10
+ export declare function useTableInteractionContext(): TableInteractionContextValue<TableItem>;
11
11
  export {};
@@ -1,15 +1,15 @@
1
1
  import type TableItem from "../models/TableItem";
2
- interface UseRowDragDropProps {
3
- items: TableItem[];
4
- onRowsReordered?: (fromIndex: number, toIndex: number, draggedItem: TableItem, targetItem: TableItem) => void;
2
+ interface UseRowDragDropProps<T extends TableItem> {
3
+ items: T[];
4
+ onRowsReordered?: (fromIndex: number, toIndex: number, draggedItem: T, targetItem: T) => void;
5
5
  groupBy?: string;
6
6
  }
7
- export declare const useRowDragDrop: ({ items, onRowsReordered, groupBy, }: UseRowDragDropProps) => {
7
+ export declare const useRowDragDrop: <T extends TableItem>({ items, onRowsReordered, groupBy, }: UseRowDragDropProps<T>) => {
8
8
  draggedRowIndex: number | null;
9
9
  dropTargetIndex: number | null;
10
10
  isDraggingRow: boolean;
11
- handleRowDragStart: (index: number, tableItem: TableItem) => void;
12
- handleDrop: (targetItem: TableItem) => void;
11
+ handleRowDragStart: (index: number, tableItem: T) => void;
12
+ handleDrop: (targetItem: T) => void;
13
13
  handleDragEnd: () => void;
14
14
  handleRowDragOver: (index: number) => void;
15
15
  };
@@ -28,10 +28,10 @@ export interface TableInteractionsProps<T extends TableItem> {
28
28
  fromArrayIndex?: number;
29
29
  }[], headerId: string) => Promise<void> | void;
30
30
  onRowDoubleClick?: (item: T) => Promise<void> | void;
31
- onSaveComment?: (comment: CommentData, item: TableItem) => Promise<void> | void;
32
- onDeleteComment?: (comment: CommentData, item: TableItem) => Promise<void> | void;
33
- onSetHighlightCondition?: (highlightCondition: HighlightCondition, item: TableItem) => Promise<void> | void;
34
- onRemoveHighlightCondition?: (highlightCondition: HighlightCondition, cssPropertyToRemove: keyof CSSProperties, item: TableItem) => Promise<void> | void;
31
+ onSaveComment?: (comment: CommentData, item: T) => Promise<void> | void;
32
+ onDeleteComment?: (comment: CommentData, item: T) => Promise<void> | void;
33
+ onSetHighlightCondition?: (highlightCondition: HighlightCondition, item: T) => Promise<void> | void;
34
+ onRemoveHighlightCondition?: (highlightCondition: HighlightCondition, cssPropertyToRemove: keyof CSSProperties, item: T) => Promise<void> | void;
35
35
  onAddListOption?: (newOption: string, header: BaseTableHeader) => Promise<void> | void;
36
36
  }
37
37
  export declare function useTableInteractions<T extends TableItem>({ items, groupedItemsEntries, onChange, onBulkChange, onBulkFieldChange, onRowDoubleClick, onSaveComment, onDeleteComment, onSetHighlightCondition, onRemoveHighlightCondition, onAddListOption, }: TableInteractionsProps<T>): {
@@ -44,10 +44,10 @@ export declare function useTableInteractions<T extends TableItem>({ items, group
44
44
  handleCellKeyDown: (e: React.KeyboardEvent) => void;
45
45
  handleRowDoubleClick: (item: TableItem) => Promise<void>;
46
46
  resetDefaultValueForSelectedCells: () => Promise<void>;
47
- saveCommentHandler: (comment: CommentData, item: TableItem) => Promise<void>;
48
- deleteCommentHandler: (comment: CommentData, item: TableItem) => Promise<void>;
49
- setHighlightCondition: (item: TableItem, headerId: string, cssStyle: React.CSSProperties) => Promise<void>;
50
- removeHighlightCondition: (item: TableItem, headerId: string, cssPropertyToRemove: keyof CSSProperties) => void;
47
+ saveCommentHandler: (comment: CommentData, item: T) => Promise<void>;
48
+ deleteCommentHandler: (comment: CommentData, item: T) => Promise<void>;
49
+ setHighlightCondition: (item: T, headerId: string, cssStyle: React.CSSProperties) => Promise<void>;
50
+ removeHighlightCondition: (item: T, headerId: string, cssPropertyToRemove: keyof CSSProperties) => void;
51
51
  onCellMouseDown: (e: React.MouseEvent<HTMLTableCellElement>, cellCoordinate: CellCoordinate) => void;
52
52
  onCellMouseEnter: (e: React.MouseEvent<HTMLTableCellElement>, _cellCoordinate: CellCoordinate) => void;
53
53
  onMouseMove: (e: React.MouseEvent) => void;
@@ -1,4 +1,4 @@
1
- export default interface TableItem {
2
- [key: string]: string | number | Array<any> | undefined;
1
+ type TableItem = {
3
2
  section?: string;
4
- }
3
+ } & Record<string, unknown>;
4
+ export default TableItem;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-base-data-table",
3
- "version": "0.5.10",
3
+ "version": "0.5.12",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "types": "dist/types/index.d.ts",