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.
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +12 -9
- package/dist/index.es.js.map +1 -1
- package/dist/types/components/BaseTable/BaseTable.d.ts +1 -1
- package/dist/types/components/BaseTable/contexts/useTableInteractionContext.d.ts +2 -2
- package/dist/types/components/BaseTable/hooks/useRowDragDrop.d.ts +6 -6
- package/dist/types/components/BaseTable/hooks/useTableInteractions.d.ts +8 -8
- package/dist/types/components/BaseTable/models/TableItem.d.ts +3 -3
- package/package.json +1 -1
|
@@ -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
|
|
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
|
|
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:
|
|
4
|
-
onRowsReordered?: (fromIndex: number, toIndex: number, draggedItem:
|
|
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:
|
|
12
|
-
handleDrop: (targetItem:
|
|
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:
|
|
32
|
-
onDeleteComment?: (comment: CommentData, item:
|
|
33
|
-
onSetHighlightCondition?: (highlightCondition: HighlightCondition, item:
|
|
34
|
-
onRemoveHighlightCondition?: (highlightCondition: HighlightCondition, cssPropertyToRemove: keyof CSSProperties, item:
|
|
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:
|
|
48
|
-
deleteCommentHandler: (comment: CommentData, item:
|
|
49
|
-
setHighlightCondition: (item:
|
|
50
|
-
removeHighlightCondition: (item:
|
|
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;
|