@atom-learning/components 2.27.0 → 2.28.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.
- package/CHANGELOG.md +22 -6
- package/dist/components/data-table/DataTable.d.ts +5 -0
- package/dist/components/data-table/DataTable.js +1 -1
- package/dist/components/data-table/DataTable.types.d.ts +18 -2
- package/dist/components/data-table/DataTableContext.d.ts +5 -10
- package/dist/components/data-table/DataTableContext.js +1 -1
- package/dist/components/data-table/DataTableRow.d.ts +1 -2
- package/dist/components/data-table/DataTableRow.js +1 -1
- package/dist/components/data-table/DataTableTable.d.ts +1 -2
- package/dist/components/data-table/drag-and-drop/DragAndDropContainer.d.ts +21 -0
- package/dist/components/data-table/drag-and-drop/DragAndDropContainer.js +1 -0
- package/dist/components/data-table/drag-and-drop/DragAndDropTable.d.ts +8 -0
- package/dist/components/data-table/drag-and-drop/DragAndDropTable.js +1 -0
- package/dist/components/data-table/drag-and-drop/DragAndDropTableBody.d.ts +5 -0
- package/dist/components/data-table/drag-and-drop/DragAndDropTableBody.js +1 -0
- package/dist/components/data-table/drag-and-drop/DraggableRow.d.ts +7 -0
- package/dist/components/data-table/drag-and-drop/DraggableRow.js +1 -0
- package/dist/components/data-table/drag-and-drop/Handle.d.ts +564 -0
- package/dist/components/data-table/drag-and-drop/Handle.js +1 -0
- package/dist/components/data-table/drag-and-drop/index.d.ts +4 -0
- package/dist/components/data-table/usePagination.d.ts +8 -0
- package/dist/components/data-table/usePagination.js +1 -0
- package/dist/components/data-table/useSorting.d.ts +9 -0
- package/dist/components/data-table/useSorting.js +1 -0
- package/dist/components/table/Table.js +1 -1
- package/dist/components/table/TableBody.js +1 -1
- package/dist/components/table/TableRow.d.ts +272 -1
- package/dist/components/table/TableRow.js +1 -1
- package/dist/docgen.json +1 -1
- package/dist/docs/DataTable.mdx +37 -1
- package/dist/index.cjs.js +1 -1
- package/package.json +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,17 +1,33 @@
|
|
|
1
|
-
# [2.
|
|
1
|
+
# [2.28.0](https://github.com/Atom-Learning/components/compare/v2.27.0...v2.28.0) (2023-01-16)
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
### Bug Fixes
|
|
5
5
|
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* declare @dnd-kit/utilities dep ([aa4d9dd](https://github.com/Atom-Learning/components/commit/aa4d9dd0b9923c4a2b159e3435294d9ce74ee44f))
|
|
7
|
+
* failing test with incorrect assertion ([f3cca92](https://github.com/Atom-Learning/components/commit/f3cca92da2bd3989b10afe809a11301424856b1c))
|
|
8
|
+
* import types explicitly ([d765fec](https://github.com/Atom-Learning/components/commit/d765fec26549eafca2671d1869b42641fde3d923))
|
|
9
|
+
* import types explicitly ([8b4d604](https://github.com/Atom-Learning/components/commit/8b4d6045f9daa1ffbd2d08bdf51f668e55219539))
|
|
10
|
+
* infinite loop in new table ([1335ba2](https://github.com/Atom-Learning/components/commit/1335ba201aadf3ab1291b52aaa9797e005725a0b))
|
|
11
|
+
* match handle size to icon size ([5c8f1ce](https://github.com/Atom-Learning/components/commit/5c8f1cebecfd4845aa9528a8382472a2f654f02a))
|
|
12
|
+
* revert bizzare text replace issue ([59132a7](https://github.com/Atom-Learning/components/commit/59132a756ae5d48d517e3e9bcfd0604a45f6329d))
|
|
13
|
+
* row ID nonsense ([b76b7cc](https://github.com/Atom-Learning/components/commit/b76b7cce1b583813c24801280b239d3752f26b80))
|
|
14
|
+
* target stitches component for table row styling ([b6f524b](https://github.com/Atom-Learning/components/commit/b6f524b12c1ad9cb2b4e0c5a86f1fee8aa586d36))
|
|
15
|
+
* typo ([f87db2f](https://github.com/Atom-Learning/components/commit/f87db2f842ac22b0762d5d7cc2fc87b246fa3d6c))
|
|
16
|
+
* update docs ([96d2a44](https://github.com/Atom-Learning/components/commit/96d2a441d322a33f0057cfc3c256e5f68cf2d0ea))
|
|
17
|
+
* update docs ([fc1b6e7](https://github.com/Atom-Learning/components/commit/fc1b6e7d16aaa0d36864db52866a6768e38ffc5c))
|
|
18
|
+
* update rowOrder usage ([6a546ab](https://github.com/Atom-Learning/components/commit/6a546abfbbed2600958ff7d44023af55fc06e568))
|
|
19
|
+
* update snapshots ([d02adaf](https://github.com/Atom-Learning/components/commit/d02adafcc44071f4e983d34ed7750126beafcb9b))
|
|
8
20
|
|
|
9
21
|
|
|
10
22
|
### Features
|
|
11
23
|
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
24
|
+
* DragAndDropTable ([c7a45c7](https://github.com/Atom-Learning/components/commit/c7a45c7130e4e05bb8112761aaf30e3e773589c4))
|
|
25
|
+
* DragAndDropTable ([31ef457](https://github.com/Atom-Learning/components/commit/31ef457c10cbd92393129f2122a0dbf3b05dd734))
|
|
26
|
+
* IDK why this doesn't work ([927414b](https://github.com/Atom-Learning/components/commit/927414bac03f69d51417ffecbfefcff873c64b5f))
|
|
27
|
+
* it basically works ([9934134](https://github.com/Atom-Learning/components/commit/99341343a17d1809a7f2a7709acf446f908eb934))
|
|
28
|
+
* separate drag-and-drop logic into DragAndDropContainer ([0be01bf](https://github.com/Atom-Learning/components/commit/0be01bf4961e735d1740d9ac64138f10ca1172cc))
|
|
29
|
+
* throw error if id is missing ([79af78d](https://github.com/Atom-Learning/components/commit/79af78dde39a0b620aaeb48310f1e487c9a83efe))
|
|
30
|
+
* WIP reorg of providers ([7bfbbb2](https://github.com/Atom-Learning/components/commit/7bfbbb2914f342178be6747a329b614841f31929))
|
|
15
31
|
|
|
16
32
|
# [1.4.0](https://github.com/Atom-Learning/components/compare/v1.3.0...v1.4.0) (2022-04-11)
|
|
17
33
|
|
|
@@ -9,6 +9,7 @@ import { DataTableHeaderCell } from './DataTableHeaderCell';
|
|
|
9
9
|
import { DataTableLoading } from './DataTableLoading';
|
|
10
10
|
import { DataTableRow } from './DataTableRow';
|
|
11
11
|
import { DataTableTable } from './DataTableTable';
|
|
12
|
+
import { DragAndDropTable } from './drag-and-drop';
|
|
12
13
|
import { Pagination } from './pagination';
|
|
13
14
|
declare type TDataTable = React.FC<React.ComponentProps<typeof DataTableProvider>> & {
|
|
14
15
|
/** Default table body implementation for `DataTable`.
|
|
@@ -22,6 +23,10 @@ declare type TDataTable = React.FC<React.ComponentProps<typeof DataTableProvider
|
|
|
22
23
|
*
|
|
23
24
|
*/
|
|
24
25
|
DataCell: typeof DataTableDataCell;
|
|
26
|
+
/**
|
|
27
|
+
* Used in place of `DataTable.Table` to render a table with rows that the user can sort by drag-and-drop
|
|
28
|
+
*/
|
|
29
|
+
DragAndDropTable: typeof DragAndDropTable;
|
|
25
30
|
/** Default global search implementation for `DataTable`
|
|
26
31
|
*
|
|
27
32
|
* If you need more customisation options, you can compose your own implementation with our UI-only input components and `useDataTable`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
import*as o from"react";import{DataTableBody as t}from"./DataTableBody.js";import{DataTableProvider as m}from"./DataTableContext.js";import{DataTableDataCell as e}from"./DataTableDataCell.js";import{DataTableError as l}from"./DataTableError.js";import{DataTableGlobalFilter as i}from"./DataTableGlobalFilter.js";import{DataTableHead as p}from"./DataTableHead.js";import{DataTableHeaderCell as b}from"./DataTableHeaderCell.js";import{DataTableLoading as D}from"./DataTableLoading.js";import{DataTableRow as T}from"./DataTableRow.js";import{DataTableTable as f}from"./DataTableTable.js";import"@dnd-kit/core";import"@dnd-kit/modifiers";import"@dnd-kit/sortable";import"../table/Table.js";import"@dnd-kit/utilities";import"@tanstack/react-table";import"./drag-and-drop/Handle.js";import{DragAndDropTable as d}from"./drag-and-drop/DragAndDropTable.js";import{Pagination as n}from"./pagination/Pagination.js";const a=r=>o.createElement(m,{...r});a.Body=t,a.DataCell=e,a.DragAndDropTable=d,a.Head=p,a.HeaderCell=b,a.Pagination=n,a.Row=T,a.GlobalFilter=i,a.Table=f,a.Loading=D,a.Error=l;export{a as DataTable};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { Table
|
|
1
|
+
import type { Table } from '@tanstack/react-table';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import type { VisibilityTableState, ColumnOrderTableState, ColumnPinningTableState, FiltersTableState, SortingTableState, ExpandedTableState, GroupingTableState, ColumnSizingTableState, PaginationTableState, RowSelectionTableState, SortDirection } from '@tanstack/react-table';
|
|
3
4
|
export declare enum AsyncDataState {
|
|
4
5
|
NONE = "none",
|
|
5
6
|
PENDING = "pending",
|
|
@@ -8,7 +9,7 @@ export declare enum AsyncDataState {
|
|
|
8
9
|
}
|
|
9
10
|
export declare type TAsyncDataResult = {
|
|
10
11
|
total: number;
|
|
11
|
-
results:
|
|
12
|
+
results: TableData;
|
|
12
13
|
};
|
|
13
14
|
export declare type TAsyncDataOptions = {
|
|
14
15
|
pageIndex: number;
|
|
@@ -25,4 +26,19 @@ export declare type DataTableContextType<T = unknown> = Table<T> & {
|
|
|
25
26
|
isSortable: boolean;
|
|
26
27
|
asyncDataState?: AsyncDataState;
|
|
27
28
|
runAsyncData?: (options: Partial<TAsyncDataOptions>) => Promise<void>;
|
|
29
|
+
data: TAsyncDataResult;
|
|
30
|
+
/**
|
|
31
|
+
* Directly update the data array that the table rows are built from.
|
|
32
|
+
* This is useful when re-ordering rows, but is high-risk if you're not sure what you're doing!
|
|
33
|
+
*
|
|
34
|
+
* Note in particular that this value is also updated if you update the value of the `DataTable`'s `data` prop
|
|
35
|
+
* — it's probably best to only use one of those two methods for any given table.
|
|
36
|
+
*/
|
|
37
|
+
setData: React.Dispatch<React.SetStateAction<TAsyncDataResult>>;
|
|
38
|
+
};
|
|
39
|
+
export declare type TableData = Array<Record<string, unknown>>;
|
|
40
|
+
export declare type InitialState = Partial<VisibilityTableState & ColumnOrderTableState & ColumnPinningTableState & FiltersTableState & SortingTableState & ExpandedTableState & GroupingTableState & ColumnSizingTableState & PaginationTableState & RowSelectionTableState>;
|
|
41
|
+
export declare type TDefaultSort = {
|
|
42
|
+
column: string;
|
|
43
|
+
direction: SortDirection;
|
|
28
44
|
};
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
declare type InitialState = Partial<VisibilityTableState & ColumnOrderTableState & ColumnPinningTableState & FiltersTableState & SortingTableState & ExpandedTableState & GroupingTableState & ColumnSizingTableState & PaginationTableState & RowSelectionTableState>;
|
|
5
|
-
declare type TableProviderProps = {
|
|
2
|
+
import { DataTableContextType, TDefaultSort, TGetAsyncData, TableData, InitialState } from './DataTable.types';
|
|
3
|
+
declare type DataTableProviderProps = {
|
|
6
4
|
columns: any;
|
|
7
|
-
defaultSort?:
|
|
8
|
-
column: string;
|
|
9
|
-
direction: SortDirection;
|
|
10
|
-
};
|
|
5
|
+
defaultSort?: TDefaultSort;
|
|
11
6
|
children: React.ReactNode;
|
|
12
7
|
initialState?: InitialState;
|
|
13
8
|
} & ({
|
|
14
|
-
data:
|
|
9
|
+
data: TableData;
|
|
15
10
|
getAsyncData?: never;
|
|
16
11
|
} | {
|
|
17
12
|
data?: never;
|
|
18
13
|
getAsyncData: TGetAsyncData;
|
|
19
14
|
});
|
|
20
|
-
export declare const DataTableProvider: ({ columns, data: dataProp, getAsyncData, defaultSort, initialState, children }:
|
|
15
|
+
export declare const DataTableProvider: ({ columns, data: dataProp, getAsyncData, defaultSort, initialState, children }: DataTableProviderProps) => JSX.Element;
|
|
21
16
|
export declare const useDataTable: <T extends Record<string, unknown>>() => DataTableContextType<T>;
|
|
22
17
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
import*as t from"react";import N from"use-deep-compare-effect";import{useReactTable as I,getCoreRowModel as x,getPaginationRowModel as A,getSortedRowModel as G,getFilteredRowModel as L}from"@tanstack/react-table";import{AsyncDataState as l}from"./DataTable.types.js";import{getNewAsyncData as z}from"./getNewAsyncData.js";import{useSortByColumn as k}from"./useSorting.js";import{usePagination as B}from"./usePagination.js";const w=t.createContext(null),J=({columns:n,data:a=[],getAsyncData:o,defaultSort:P,initialState:s=void 0,children:y})=>{var b;const[g,u]=t.useState({results:a!=null?a:[],total:(b=a==null?void 0:a.length)!=null?b:0}),{isPaginated:i,applyPagination:D,paginationState:e,setPaginationState:C}=B(s==null?void 0:s.pagination),[f,d]=t.useState(l.NONE),[c,h]=t.useState(""),{setIsSortable:E,isSortable:S,sorting:r,setSorting:M}=k(P),m=t.useCallback(async F=>{if(o)try{d(l.PENDING);const T=await z(o,F,e,r,c);u(T),d(l.FULFILLED)}catch{d(l.REJECTED)}},[o,e==null?void 0:e.pageIndex,e==null?void 0:e.pageSize,r,c]);t.useEffect(()=>{m({})},[m]),N(()=>{!a||u({results:a,total:a.length})},[a]);const p=()=>g.total,v=I({columns:n,data:g.results,pageCount:e?Math.ceil(p()/e.pageSize):-1,initialState:s,state:{sorting:r,globalFilter:c,pagination:e},manualPagination:o&&i,manualSorting:o&&i,enableSorting:f!==l.PENDING,enableGlobalFilter:!o,getCoreRowModel:x(),getPaginationRowModel:i?A():void 0,getSortedRowModel:S||r.length?G():void 0,getFilteredRowModel:L(),onPaginationChange:i?C:void 0,onSortingChange:M,onGlobalFilterChange:h}),R=t.useMemo(()=>({...v,data:g,setData:u,setIsSortable:E,applyPagination:D,getTotalRows:p,isSortable:S,asyncDataState:f,runAsyncData:m}),[v,D,p,S]);return t.createElement(w.Provider,{value:R},y)},O=()=>{const n=t.useContext(w);if(!n)throw new Error("useDataTable can only be called from inside a DataTableProvider");return n};export{J as DataTableProvider,O as useDataTable};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { Row } from '@tanstack/react-table';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { Table } from '../table';
|
|
4
|
-
declare type DataTableRowProps = React.ComponentProps<typeof Table.Row> & {
|
|
4
|
+
export declare type DataTableRowProps = React.ComponentProps<typeof Table.Row> & {
|
|
5
5
|
row: Row<Record<string, unknown>>;
|
|
6
6
|
};
|
|
7
7
|
export declare const DataTableRow: React.FC<DataTableRowProps>;
|
|
8
|
-
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as l from"react";import{Table as a}from"../table/Table.js";import{DataTableDataCell as o}from"./DataTableDataCell.js";const r=({row:t})=>l.createElement(a.Row,null,t.getVisibleCells().map(e=>l.createElement(o,{key:e.id,cell:e})));export{r as DataTableRow};
|
|
1
|
+
import*as l from"react";import{Table as a}from"../table/Table.js";import{DataTableDataCell as o}from"./DataTableDataCell.js";const r=({row:t})=>l.createElement(a.Row,null,t.getVisibleCells().map((e,m)=>l.createElement(o,{key:e.id,cell:e})));export{r as DataTableRow};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Table } from '../table';
|
|
3
3
|
import { DataTable } from './DataTable';
|
|
4
|
-
declare type DataTableTableProps = Omit<React.ComponentProps<typeof Table>, 'children'> & Partial<Pick<React.ComponentProps<typeof DataTable.Head>, 'theme' | 'sortable'>> & Partial<Pick<React.ComponentProps<typeof Table.Body>, 'striped'>>;
|
|
4
|
+
export declare type DataTableTableProps = Omit<React.ComponentProps<typeof Table>, 'children'> & Partial<Pick<React.ComponentProps<typeof DataTable.Head>, 'theme' | 'sortable'>> & Partial<Pick<React.ComponentProps<typeof Table.Body>, 'striped'>>;
|
|
5
5
|
export declare const DataTableTable: React.FC<DataTableTableProps>;
|
|
6
|
-
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { TAsyncDataResult, TableData } from '../DataTable.types';
|
|
2
|
+
import type { UniqueIdentifier } from '@dnd-kit/core';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
declare type DragAndDropContainerProps = {
|
|
5
|
+
idColumn?: string;
|
|
6
|
+
onChange?: (oldIndex: number, newIndex: number, newData: TableData) => void;
|
|
7
|
+
};
|
|
8
|
+
export declare const processDragEndEvent: (event: {
|
|
9
|
+
active: {
|
|
10
|
+
id: UniqueIdentifier;
|
|
11
|
+
};
|
|
12
|
+
over: {
|
|
13
|
+
id: UniqueIdentifier;
|
|
14
|
+
};
|
|
15
|
+
}, data: TAsyncDataResult, rowOrder: Array<UniqueIdentifier>, idColumn: UniqueIdentifier, onChange?: ((oldIndex: number, newIndex: number, newData: TableData) => void) | undefined) => {
|
|
16
|
+
results: Record<string, unknown>[];
|
|
17
|
+
total: number;
|
|
18
|
+
};
|
|
19
|
+
export declare const getRowOrder: (data: TAsyncDataResult, idColumn: string) => UniqueIdentifier[];
|
|
20
|
+
export declare const DragAndDropContainer: React.FC<DragAndDropContainerProps>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useDataTable as h}from"../DataTableContext.js";import{useSensors as D,useSensor as u,PointerSensor as f,KeyboardSensor as g,DndContext as y,closestCenter as C}from"@dnd-kit/core";import{restrictToVerticalAxis as S}from"@dnd-kit/modifiers";import{sortableKeyboardCoordinates as b,SortableContext as w,verticalListSortingStrategy as x,arrayMove as E}from"@dnd-kit/sortable";import*as c from"react";const p=(t,s,o,r,a)=>{const{active:i,over:d}=t,l=o.indexOf(i[r]),n=o.indexOf(d==null?void 0:d[r]),e=E(s.results,l,n);return a==null||a(l,n,e),{results:e,total:e.length}},m=(t,s)=>t.results.map(o=>{const r=o[s];if(r===void 0)throw new Error("To ensure drag-and-drop works correctly, please ensure that each row has a unique ID. Use the `id` property or pass DataTable an `idColumn` prop that defines the ID property on the rows.");return r}),T=({idColumn:t="id",onChange:s=void 0,children:o})=>{const{data:r,setData:a}=h(),i=c.useMemo(()=>m(r,t),[r]),d=D(u(f),u(g,{coordinateGetter:b}));return c.createElement(y,{sensors:d,collisionDetection:C,onDragEnd:l=>{const{active:n,over:e}=l;n.id&&(e==null?void 0:e.id)&&n.id!==(e==null?void 0:e.id)&&a(v=>p({active:n,over:e},v,i,t,s))},modifiers:[S]},c.createElement(w,{items:i,strategy:x},o))};export{T as DragAndDropContainer,m as getRowOrder,p as processDragEndEvent};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { DataTableTableProps } from '../DataTableTable';
|
|
3
|
+
declare type DragAndDropTableProps = DataTableTableProps & {
|
|
4
|
+
idColumn?: string;
|
|
5
|
+
onDragAndDrop?: (oldIndex: number, newIndex: number, newData: Record<string, unknown>[]) => void;
|
|
6
|
+
};
|
|
7
|
+
export declare const DragAndDropTable: React.FC<DragAndDropTableProps>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as e from"react";import{Table as s}from"../../table/Table.js";import{DataTable as D}from"../DataTable.js";import{AsyncDataState as c}from"../DataTable.types.js";import{useDataTable as d}from"../DataTableContext.js";import{DataTableLoading as b}from"../DataTableLoading.js";import{DragAndDropContainer as f}from"./DragAndDropContainer.js";import{DragAndDropTableBody as E}from"./DragAndDropTableBody.js";const g=({idColumn:t,onDragAndDrop:r,sortable:a,striped:o,theme:n,css:m,...i})=>{const{asyncDataState:l}=d(),p=l===c.PENDING;return e.createElement(f,{onChange:r,idColumn:t},e.createElement(b,null),e.createElement(s,{...i,css:{...m,...p&&{opacity:.5,pointerEvents:"none",transition:"opacity 250ms linear 150ms"}}},e.createElement(D.Head,{theme:n,sortable:a}),e.createElement(E,{striped:o})))};export{g as DragAndDropTable};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as r from"react";import{Table as m}from"../../table/Table.js";import{useDataTable as p}from"../DataTableContext.js";import{DraggableRow as d}from"./DraggableRow.js";const i=({striped:o=!1,...t})=>{const{getRowModel:a}=p();return r.createElement(m.Body,{...t,striped:o},a().rows.map(e=>r.createElement(d,{row:e,key:e.id})))};export{i as DragAndDropTableBody};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Row } from '@tanstack/react-table';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Table } from '../../table';
|
|
4
|
+
export declare type DataTableDraggableRowProps = React.ComponentProps<typeof Table.Row> & {
|
|
5
|
+
row: Row<Record<string, unknown>>;
|
|
6
|
+
};
|
|
7
|
+
export declare const DraggableRow: React.FC<DataTableDraggableRowProps>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as e from"react";import{Table as i}from"../../table/Table.js";import{DataTableDataCell as p}from"../DataTableDataCell.js";import"../DataTableContext.js";import"@dnd-kit/core";import"@dnd-kit/modifiers";import{useSortable as f}from"@dnd-kit/sortable";import{CSS as c}from"@dnd-kit/utilities";import{flexRender as d}from"@tanstack/react-table";import{Handle as g}from"./Handle.js";import"../DataTable.js";import"../DataTable.types.js";import"../DataTableLoading.js";const b=({row:t})=>{const{attributes:l,listeners:m,transform:a,setNodeRef:n,isDragging:o}=f({id:t.original.id});return e.createElement(i.Row,{ref:n,css:{transform:c.Transform.toString(a),zIndex:o?5:void 0}},t.getVisibleCells().map((r,s)=>s===0?e.createElement(i.Cell,{key:r.id},e.createElement(g,{...l,...m,isDragging:o,css:{display:"inline-block"},label:"drag and drop"}),d(r.column.columnDef.cell,r.getContext())):e.createElement(p,{key:r.id,cell:r})))};export{b as DraggableRow};
|