@trackunit/react-table 1.10.14 → 1.10.16
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/index.cjs.js +4 -2
- package/index.esm.js +4 -2
- package/package.json +9 -9
- package/src/Table.d.ts +1 -0
- package/src/hooks/useColumnDragDrop.d.ts +2 -1
package/index.cjs.js
CHANGED
|
@@ -577,14 +577,15 @@ const useCellsOffset = (headerGroups, draggingColumnId) => {
|
|
|
577
577
|
* @param options - Options including the ReactTable instance and optional callbacks
|
|
578
578
|
* @returns { object } Object containing drag state and handler functions
|
|
579
579
|
*/
|
|
580
|
-
const useColumnDragDrop = ({ table, }) => {
|
|
580
|
+
const useColumnDragDrop = ({ table, onColumnDragStart, }) => {
|
|
581
581
|
const [draggingColumnId, setDraggingColumnId] = react.useState(null);
|
|
582
582
|
const [dropTargetColumnId, setDropTargetColumnId] = react.useState(null);
|
|
583
583
|
const [dropPosition, setDropPosition] = react.useState(null);
|
|
584
584
|
const [droppedColumnId, setDroppedColumnId] = react.useState(null);
|
|
585
585
|
const startDragging = react.useCallback((columnId) => {
|
|
586
586
|
setDraggingColumnId(columnId);
|
|
587
|
-
|
|
587
|
+
onColumnDragStart?.(columnId);
|
|
588
|
+
}, [onColumnDragStart]);
|
|
588
589
|
const endDragging = react.useCallback(() => {
|
|
589
590
|
setDraggingColumnId(null);
|
|
590
591
|
setDropTargetColumnId(null);
|
|
@@ -995,6 +996,7 @@ const Table = ({ rowHeight = 50, ...props }) => {
|
|
|
995
996
|
// Add our drag and drop hook with enhanced functionality
|
|
996
997
|
const { getHeaderProps, getDragHandleProps, renderDropIndicator, isCellDropTarget, draggingColumnId, droppedColumnId, getCellProps, } = useColumnDragDrop({
|
|
997
998
|
table: props,
|
|
999
|
+
onColumnDragStart: props.onColumnDragStart,
|
|
998
1000
|
});
|
|
999
1001
|
const offsets = useCellsOffset(headerGroups.map(group => group.headers), draggingColumnId);
|
|
1000
1002
|
const hasResults = props.getRowModel().rows.length > 0;
|
package/index.esm.js
CHANGED
|
@@ -576,14 +576,15 @@ const useCellsOffset = (headerGroups, draggingColumnId) => {
|
|
|
576
576
|
* @param options - Options including the ReactTable instance and optional callbacks
|
|
577
577
|
* @returns { object } Object containing drag state and handler functions
|
|
578
578
|
*/
|
|
579
|
-
const useColumnDragDrop = ({ table, }) => {
|
|
579
|
+
const useColumnDragDrop = ({ table, onColumnDragStart, }) => {
|
|
580
580
|
const [draggingColumnId, setDraggingColumnId] = useState(null);
|
|
581
581
|
const [dropTargetColumnId, setDropTargetColumnId] = useState(null);
|
|
582
582
|
const [dropPosition, setDropPosition] = useState(null);
|
|
583
583
|
const [droppedColumnId, setDroppedColumnId] = useState(null);
|
|
584
584
|
const startDragging = useCallback((columnId) => {
|
|
585
585
|
setDraggingColumnId(columnId);
|
|
586
|
-
|
|
586
|
+
onColumnDragStart?.(columnId);
|
|
587
|
+
}, [onColumnDragStart]);
|
|
587
588
|
const endDragging = useCallback(() => {
|
|
588
589
|
setDraggingColumnId(null);
|
|
589
590
|
setDropTargetColumnId(null);
|
|
@@ -994,6 +995,7 @@ const Table = ({ rowHeight = 50, ...props }) => {
|
|
|
994
995
|
// Add our drag and drop hook with enhanced functionality
|
|
995
996
|
const { getHeaderProps, getDragHandleProps, renderDropIndicator, isCellDropTarget, draggingColumnId, droppedColumnId, getCellProps, } = useColumnDragDrop({
|
|
996
997
|
table: props,
|
|
998
|
+
onColumnDragStart: props.onColumnDragStart,
|
|
997
999
|
});
|
|
998
1000
|
const offsets = useCellsOffset(headerGroups.map(group => group.headers), draggingColumnId);
|
|
999
1001
|
const hasResults = props.getRowModel().rows.length > 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-table",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.16",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
"react-dnd-html5-backend": "16.0.1",
|
|
15
15
|
"@tanstack/react-router": "1.114.29",
|
|
16
16
|
"tailwind-merge": "^2.0.0",
|
|
17
|
-
"@trackunit/react-components": "1.14.
|
|
18
|
-
"@trackunit/shared-utils": "1.12.
|
|
19
|
-
"@trackunit/css-class-variance-utilities": "1.10.
|
|
20
|
-
"@trackunit/ui-icons": "1.10.
|
|
21
|
-
"@trackunit/react-table-base-components": "1.10.
|
|
22
|
-
"@trackunit/react-form-components": "1.11.
|
|
23
|
-
"@trackunit/i18n-library-translation": "1.10.
|
|
24
|
-
"@trackunit/iris-app-runtime-core-api": "1.10.
|
|
17
|
+
"@trackunit/react-components": "1.14.16",
|
|
18
|
+
"@trackunit/shared-utils": "1.12.14",
|
|
19
|
+
"@trackunit/css-class-variance-utilities": "1.10.14",
|
|
20
|
+
"@trackunit/ui-icons": "1.10.14",
|
|
21
|
+
"@trackunit/react-table-base-components": "1.10.16",
|
|
22
|
+
"@trackunit/react-form-components": "1.11.16",
|
|
23
|
+
"@trackunit/i18n-library-translation": "1.10.14",
|
|
24
|
+
"@trackunit/iris-app-runtime-core-api": "1.10.14",
|
|
25
25
|
"graphql": "^16.10.0"
|
|
26
26
|
},
|
|
27
27
|
"module": "./index.esm.js",
|
package/src/Table.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export interface TableProps<TData extends object> extends ReactTable<TData>, Com
|
|
|
16
16
|
selectionColId?: string;
|
|
17
17
|
renderFilterButton?: (filterKey: string | Array<string>) => ReactNode;
|
|
18
18
|
isRowClickable?: (row: TData) => boolean;
|
|
19
|
+
onColumnDragStart?: (columnId: string) => void;
|
|
19
20
|
}
|
|
20
21
|
/**
|
|
21
22
|
* Table component for displaying large sets of data in tables with infinite scroll, sorting, filtering and others.
|
|
@@ -2,6 +2,7 @@ import { Table as ReactTable } from "@tanstack/react-table";
|
|
|
2
2
|
import { HTMLAttributes, ReactNode } from "react";
|
|
3
3
|
interface ColumnDragDropOptions<TData extends object> {
|
|
4
4
|
table: ReactTable<TData>;
|
|
5
|
+
onColumnDragStart?: (columnId: string) => void;
|
|
5
6
|
}
|
|
6
7
|
type ColumnStyles = {
|
|
7
8
|
[x: string]: number | string | undefined;
|
|
@@ -12,7 +13,7 @@ type ColumnStyles = {
|
|
|
12
13
|
* @param options - Options including the ReactTable instance and optional callbacks
|
|
13
14
|
* @returns { object } Object containing drag state and handler functions
|
|
14
15
|
*/
|
|
15
|
-
export declare const useColumnDragDrop: <TData extends object>({ table, }: ColumnDragDropOptions<TData>) => {
|
|
16
|
+
export declare const useColumnDragDrop: <TData extends object>({ table, onColumnDragStart, }: ColumnDragDropOptions<TData>) => {
|
|
16
17
|
draggingColumnId: string | null;
|
|
17
18
|
droppedColumnId: string | null;
|
|
18
19
|
dropTargetColumnId: string | null;
|