@bsol-oss/react-datatable5 1.0.24 → 1.0.25
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.d.ts +12 -3
- package/dist/index.js +44 -12
- package/dist/index.mjs +45 -14
- package/dist/types/components/DataTableServer.d.ts +6 -1
- package/dist/types/components/TableViewer.d.ts +1 -0
- package/dist/types/components/TextCell.d.ts +3 -1
- package/dist/types/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
-
import { FilterFn, ColumnDef } from '@tanstack/react-table';
|
|
3
|
+
import { FilterFn, ColumnDef, RowData } from '@tanstack/react-table';
|
|
4
4
|
import { RankingInfo } from '@tanstack/match-sorter-utils';
|
|
5
5
|
import { ReactNode } from 'react';
|
|
6
6
|
import * as _tanstack_table_core from '@tanstack/table-core';
|
|
@@ -39,6 +39,11 @@ interface DataResponse<T> extends Result<T> {
|
|
|
39
39
|
count: number;
|
|
40
40
|
filterCount: number;
|
|
41
41
|
}
|
|
42
|
+
declare module "@tanstack/react-table" {
|
|
43
|
+
interface ColumnMeta<TData extends RowData, TValue> {
|
|
44
|
+
displayName: string;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
42
47
|
declare const DataTableServer: <TData>({ columns, url, enableRowSelection, enableMultiRowSelection, enableSubRowSelection, children, }: DataTableServerProps<TData>) => react_jsx_runtime.JSX.Element;
|
|
43
48
|
|
|
44
49
|
declare const EditFilterButton: () => react_jsx_runtime.JSX.Element;
|
|
@@ -97,11 +102,15 @@ declare const TableSelector: () => react_jsx_runtime.JSX.Element;
|
|
|
97
102
|
|
|
98
103
|
declare const TableSorter: () => react_jsx_runtime.JSX.Element;
|
|
99
104
|
|
|
105
|
+
declare const TableViewer: () => react_jsx_runtime.JSX.Element;
|
|
106
|
+
|
|
100
107
|
interface TextCellProps {
|
|
101
108
|
label?: string;
|
|
109
|
+
noOfLines?: number[];
|
|
110
|
+
padding?: string;
|
|
102
111
|
children: string | number | JSX.Element | JSX.Element[];
|
|
103
112
|
}
|
|
104
|
-
declare const TextCell: ({ label, children }: TextCellProps) => react_jsx_runtime.JSX.Element;
|
|
113
|
+
declare const TextCell: ({ label, noOfLines, padding, children, }: TextCellProps) => react_jsx_runtime.JSX.Element;
|
|
105
114
|
|
|
106
115
|
interface useDataFromUrlReturn<T> {
|
|
107
116
|
data: T;
|
|
@@ -123,4 +132,4 @@ declare const useDataTable: () => {
|
|
|
123
132
|
setGlobalFilter: (filter: string) => void;
|
|
124
133
|
};
|
|
125
134
|
|
|
126
|
-
export { type DataResponse, DataTable, type DataTableProps, DataTableServer, type DataTableServerProps, EditFilterButton, EditOrderButton, EditSortingButton, EditViewButton, GlobalFilter, PageSizeControl, type PageSizeControlProps, type PaginationProps, ResetFilteringButton, ResetSelectionButton, ResetSortingButton, type Result, Table, TableBody, TableCardContainer, type TableCardContainerProps, TableCards, type TableCardsProps, TableFilter, TableFooter, TableHeader, type TableHeaderProps, TableOrderer, TablePagination, type TableProps, TableSelector, TableSorter, TextCell, type TextCellProps, useDataFromUrl, type useDataFromUrlProps, type useDataFromUrlReturn, useDataTable };
|
|
135
|
+
export { type DataResponse, DataTable, type DataTableProps, DataTableServer, type DataTableServerProps, EditFilterButton, EditOrderButton, EditSortingButton, EditViewButton, GlobalFilter, PageSizeControl, type PageSizeControlProps, type PaginationProps, ResetFilteringButton, ResetSelectionButton, ResetSortingButton, type Result, Table, TableBody, TableCardContainer, type TableCardContainerProps, TableCards, type TableCardsProps, TableFilter, TableFooter, TableHeader, type TableHeaderProps, TableOrderer, TablePagination, type TableProps, TableSelector, TableSorter, TableViewer, TextCell, type TextCellProps, useDataFromUrl, type useDataFromUrlProps, type useDataFromUrlReturn, useDataTable };
|
package/dist/index.js
CHANGED
|
@@ -171,6 +171,13 @@ const DataTableServer = ({ columns, url, enableRowSelection = true, enableMultiR
|
|
|
171
171
|
setGlobalFilter(state);
|
|
172
172
|
},
|
|
173
173
|
rowCount: data.filterCount,
|
|
174
|
+
// for tanstack-table ts bug start
|
|
175
|
+
filterFns: {
|
|
176
|
+
fuzzy: () => {
|
|
177
|
+
return false;
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
// for tanstack-table ts bug end
|
|
174
181
|
});
|
|
175
182
|
react.useEffect(() => {
|
|
176
183
|
refreshData();
|
|
@@ -201,7 +208,10 @@ const useDataTable = () => {
|
|
|
201
208
|
const TableFilter = () => {
|
|
202
209
|
const { table } = useDataTable();
|
|
203
210
|
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: table.getLeafHeaders().map((header) => {
|
|
204
|
-
|
|
211
|
+
const displayName = header.column.columnDef.meta === undefined
|
|
212
|
+
? header.column.id
|
|
213
|
+
: header.column.columnDef.meta.displayName;
|
|
214
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: header.column.getCanFilter() && (jsxRuntime.jsxs(react$1.Box, { children: [jsxRuntime.jsx(react$1.Text, { children: displayName }), jsxRuntime.jsx(react$1.Input, { value: header.column.getFilterValue()
|
|
205
215
|
? String(header.column.getFilterValue())
|
|
206
216
|
: "", onChange: (e) => {
|
|
207
217
|
header.column.setFilterValue(e.target.value);
|
|
@@ -235,17 +245,27 @@ const ColumnOrderChanger = ({ columns }) => {
|
|
|
235
245
|
}
|
|
236
246
|
setOriginalOrder(columns);
|
|
237
247
|
}, [columns]);
|
|
238
|
-
return (jsxRuntime.jsxs(react$1.Flex, { gap: "0.5rem", flexFlow: "column", children: [jsxRuntime.jsx(react$1.Flex, { gap: "0.5rem", flexFlow: "column", children: order.map((
|
|
248
|
+
return (jsxRuntime.jsxs(react$1.Flex, { gap: "0.5rem", flexFlow: "column", children: [jsxRuntime.jsx(react$1.Flex, { gap: "0.5rem", flexFlow: "column", children: order.map((columnId, index) => (jsxRuntime.jsxs(react$1.Flex, { gap: "0.5rem", alignItems: "center", justifyContent: "space-between", children: [jsxRuntime.jsx(react$1.IconButton, { onClick: () => {
|
|
239
249
|
const prevIndex = index - 1;
|
|
240
250
|
if (prevIndex >= 0) {
|
|
241
251
|
handleChangeOrder(index, prevIndex);
|
|
242
252
|
}
|
|
243
|
-
}, disabled: index === 0, "aria-label": "", children: jsxRuntime.jsx(md.MdArrowUpward, {}) }),
|
|
253
|
+
}, disabled: index === 0, "aria-label": "", children: jsxRuntime.jsx(md.MdArrowUpward, {}) }), table
|
|
254
|
+
.getAllFlatColumns()
|
|
255
|
+
.filter((column) => {
|
|
256
|
+
return column.id === columnId;
|
|
257
|
+
})
|
|
258
|
+
.map((column) => {
|
|
259
|
+
const displayName = column.columnDef.meta === undefined
|
|
260
|
+
? column.id
|
|
261
|
+
: column.columnDef.meta.displayName;
|
|
262
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: displayName });
|
|
263
|
+
}), jsxRuntime.jsx(react$1.IconButton, { onClick: () => {
|
|
244
264
|
const nextIndex = index + 1;
|
|
245
265
|
if (nextIndex < order.length) {
|
|
246
266
|
handleChangeOrder(index, nextIndex);
|
|
247
267
|
}
|
|
248
|
-
}, disabled: index === order.length - 1, "aria-label": "", children: jsxRuntime.jsx(md.MdArrowDownward, {}) })] },
|
|
268
|
+
}, disabled: index === order.length - 1, "aria-label": "", children: jsxRuntime.jsx(md.MdArrowDownward, {}) })] }, columnId))) }), jsxRuntime.jsxs(react$1.Flex, { gap: "0.25rem", children: [jsxRuntime.jsx(react$1.Button, { onClick: () => {
|
|
249
269
|
table.setColumnOrder(order);
|
|
250
270
|
}, children: "Apply" }), jsxRuntime.jsx(react$1.Button, { onClick: () => {
|
|
251
271
|
table.setColumnOrder(originalOrder);
|
|
@@ -270,7 +290,10 @@ const ResetSortingButton = () => {
|
|
|
270
290
|
const TableSorter = () => {
|
|
271
291
|
const { table } = useDataTable();
|
|
272
292
|
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: table.getHeaderGroups().map((headerGroup) => (jsxRuntime.jsx(jsxRuntime.Fragment, { children: headerGroup.headers.map((header) => {
|
|
273
|
-
|
|
293
|
+
const displayName = header.column.columnDef.meta === undefined
|
|
294
|
+
? header.column.id
|
|
295
|
+
: header.column.columnDef.meta.displayName;
|
|
296
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: header.column.getCanSort() && (jsxRuntime.jsxs(react$1.Flex, { alignItems: "center", gap: "0.5rem", padding: "0.5rem", children: [jsxRuntime.jsx(react$1.Text, { children: displayName }), jsxRuntime.jsxs(react$1.Button, { variant: "ghost", onClick: (e) => {
|
|
274
297
|
header.column.toggleSorting();
|
|
275
298
|
}, children: [header.column.getIsSorted() === false && (
|
|
276
299
|
// <Text>To No sort</Text>
|
|
@@ -288,11 +311,19 @@ const EditSortingButton = () => {
|
|
|
288
311
|
return (jsxRuntime.jsxs(react$1.Popover, { placement: "auto", children: [jsxRuntime.jsx(react$1.Tooltip, { label: "Filter", children: jsxRuntime.jsx(react$1.PopoverTrigger, { children: jsxRuntime.jsx(react$1.IconButton, { "aria-label": "filter", variant: "ghost", icon: jsxRuntime.jsx(md.MdOutlineSort, {}) }) }) }), jsxRuntime.jsxs(react$1.PopoverContent, { width: "auto", children: [jsxRuntime.jsx(react$1.PopoverArrow, {}), jsxRuntime.jsx(react$1.PopoverBody, { children: jsxRuntime.jsxs(react$1.Flex, { flexFlow: "column", gap: "0.25rem", children: [jsxRuntime.jsx(TableSorter, {}), jsxRuntime.jsx(ResetSortingButton, {})] }) })] })] }));
|
|
289
312
|
};
|
|
290
313
|
|
|
314
|
+
const TableViewer = () => {
|
|
315
|
+
const { table } = useDataTable();
|
|
316
|
+
return (jsxRuntime.jsx(react$1.Flex, { flexFlow: "column", gap: "1rem", children: table.getAllLeafColumns().map((column) => {
|
|
317
|
+
console.log(column.columnDef.meta, "gokspo");
|
|
318
|
+
const displayName = column.columnDef.meta === undefined
|
|
319
|
+
? column.id
|
|
320
|
+
: column.columnDef.meta.displayName;
|
|
321
|
+
return (jsxRuntime.jsxs(react$1.Flex, { flexFlow: "row", gap: "0.5rem", alignItems: "center", children: [jsxRuntime.jsx(react$1.Switch, { isChecked: column.getIsVisible(), onChange: column.getToggleVisibilityHandler() }), displayName] }));
|
|
322
|
+
}) }));
|
|
323
|
+
};
|
|
324
|
+
|
|
291
325
|
const EditViewButton = () => {
|
|
292
|
-
|
|
293
|
-
return (jsxRuntime.jsxs(react$1.Popover, { placement: "auto", children: [jsxRuntime.jsx(react$1.PopoverTrigger, { children: jsxRuntime.jsx(react$1.IconButton, { "aria-label": "view", variant: "ghost", icon: jsxRuntime.jsx(io.IoMdEye, {}) }) }), jsxRuntime.jsxs(react$1.PopoverContent, { width: "auto", children: [jsxRuntime.jsx(react$1.PopoverArrow, {}), jsxRuntime.jsx(react$1.PopoverBody, { children: jsxRuntime.jsx(react$1.Flex, { flexFlow: "column", gap: "1rem", children: table.getAllLeafColumns().map((column) => {
|
|
294
|
-
return (jsxRuntime.jsx(react$1.FormControl, { width: "auto", children: jsxRuntime.jsx(react$1.Checkbox, { isChecked: column.getIsVisible(), onChange: column.getToggleVisibilityHandler(), children: column.id }) }, crypto.randomUUID()));
|
|
295
|
-
}) }) })] })] }));
|
|
326
|
+
return (jsxRuntime.jsxs(react$1.Popover, { placement: "auto", children: [jsxRuntime.jsx(react$1.PopoverTrigger, { children: jsxRuntime.jsx(react$1.IconButton, { "aria-label": "view", variant: "ghost", icon: jsxRuntime.jsx(io.IoMdEye, {}) }) }), jsxRuntime.jsxs(react$1.PopoverContent, { width: "auto", children: [jsxRuntime.jsx(react$1.PopoverArrow, {}), jsxRuntime.jsx(react$1.PopoverBody, { children: jsxRuntime.jsx(TableViewer, {}) })] })] }));
|
|
296
327
|
};
|
|
297
328
|
|
|
298
329
|
const GlobalFilter = () => {
|
|
@@ -472,11 +503,11 @@ const TableSelector = () => {
|
|
|
472
503
|
}, "aria-label": "reset selection" }))] }));
|
|
473
504
|
};
|
|
474
505
|
|
|
475
|
-
const TextCell = ({ label, children }) => {
|
|
506
|
+
const TextCell = ({ label, noOfLines = [1], padding = "0rem", children, }) => {
|
|
476
507
|
if (label) {
|
|
477
|
-
return (jsxRuntime.jsx(react$1.Tooltip, { label: jsxRuntime.jsx(react$1.Text, { as: "span", overflow: "hidden", textOverflow: "ellipsis", noOfLines: [5], children: label }), placement: "auto", children: jsxRuntime.jsx(react$1.Text, { as: "span", textOverflow: "ellipsis", noOfLines:
|
|
508
|
+
return (jsxRuntime.jsx(react$1.Box, { padding: padding, children: jsxRuntime.jsx(react$1.Tooltip, { label: jsxRuntime.jsx(react$1.Text, { as: "span", overflow: "hidden", textOverflow: "ellipsis", noOfLines: [5], children: label }), placement: "auto", children: jsxRuntime.jsx(react$1.Text, { as: "span", textOverflow: "ellipsis", noOfLines: noOfLines, children: children }) }) }));
|
|
478
509
|
}
|
|
479
|
-
return (jsxRuntime.jsx(react$1.Text, { as: "span", overflow: "hidden", textOverflow: "ellipsis", noOfLines:
|
|
510
|
+
return (jsxRuntime.jsx(react$1.Box, { padding: padding, children: jsxRuntime.jsx(react$1.Text, { as: "span", overflow: "hidden", textOverflow: "ellipsis", noOfLines: noOfLines, children: children }) }));
|
|
480
511
|
};
|
|
481
512
|
|
|
482
513
|
exports.DataTable = DataTable;
|
|
@@ -501,6 +532,7 @@ exports.TableOrderer = TableOrderer;
|
|
|
501
532
|
exports.TablePagination = TablePagination;
|
|
502
533
|
exports.TableSelector = TableSelector;
|
|
503
534
|
exports.TableSorter = TableSorter;
|
|
535
|
+
exports.TableViewer = TableViewer;
|
|
504
536
|
exports.TextCell = TextCell;
|
|
505
537
|
exports.useDataFromUrl = useDataFromUrl;
|
|
506
538
|
exports.useDataTable = useDataTable;
|
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { useReactTable, getCoreRowModel, getFilteredRowModel, getSortedRowModel,
|
|
|
3
3
|
import { createContext, useState, useEffect, useContext } from 'react';
|
|
4
4
|
import { rankItem } from '@tanstack/match-sorter-utils';
|
|
5
5
|
import axios from 'axios';
|
|
6
|
-
import { Button, Box, Text, Input, Popover, Tooltip, PopoverTrigger, IconButton, PopoverContent, PopoverArrow, PopoverBody, Flex,
|
|
6
|
+
import { Button, Box, Text, Input, Popover, Tooltip, PopoverTrigger, IconButton, PopoverContent, PopoverArrow, PopoverBody, Flex, Switch, Menu, MenuButton, MenuList, MenuItem, Container, Table as Table$1, Checkbox, Grid, Card, CardBody, Tfoot, Tr as Tr$1, Th, Thead, Portal, ButtonGroup, Icon } from '@chakra-ui/react';
|
|
7
7
|
import { MdFilterAlt, MdArrowUpward, MdArrowDownward, MdOutlineMoveDown, MdOutlineSort, MdPushPin, MdCancel, MdSort, MdFilterListAlt, MdFirstPage, MdArrowBack, MdArrowForward, MdLastPage, MdClear, MdOutlineChecklist } from 'react-icons/md';
|
|
8
8
|
import { UpDownIcon, ChevronDownIcon, ChevronUpIcon, CloseIcon } from '@chakra-ui/icons';
|
|
9
9
|
import { IoMdEye, IoMdClose, IoMdCheckbox } from 'react-icons/io';
|
|
@@ -169,6 +169,13 @@ const DataTableServer = ({ columns, url, enableRowSelection = true, enableMultiR
|
|
|
169
169
|
setGlobalFilter(state);
|
|
170
170
|
},
|
|
171
171
|
rowCount: data.filterCount,
|
|
172
|
+
// for tanstack-table ts bug start
|
|
173
|
+
filterFns: {
|
|
174
|
+
fuzzy: () => {
|
|
175
|
+
return false;
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
// for tanstack-table ts bug end
|
|
172
179
|
});
|
|
173
180
|
useEffect(() => {
|
|
174
181
|
refreshData();
|
|
@@ -199,7 +206,10 @@ const useDataTable = () => {
|
|
|
199
206
|
const TableFilter = () => {
|
|
200
207
|
const { table } = useDataTable();
|
|
201
208
|
return (jsx(Fragment, { children: table.getLeafHeaders().map((header) => {
|
|
202
|
-
|
|
209
|
+
const displayName = header.column.columnDef.meta === undefined
|
|
210
|
+
? header.column.id
|
|
211
|
+
: header.column.columnDef.meta.displayName;
|
|
212
|
+
return (jsx(Fragment, { children: header.column.getCanFilter() && (jsxs(Box, { children: [jsx(Text, { children: displayName }), jsx(Input, { value: header.column.getFilterValue()
|
|
203
213
|
? String(header.column.getFilterValue())
|
|
204
214
|
: "", onChange: (e) => {
|
|
205
215
|
header.column.setFilterValue(e.target.value);
|
|
@@ -233,17 +243,27 @@ const ColumnOrderChanger = ({ columns }) => {
|
|
|
233
243
|
}
|
|
234
244
|
setOriginalOrder(columns);
|
|
235
245
|
}, [columns]);
|
|
236
|
-
return (jsxs(Flex, { gap: "0.5rem", flexFlow: "column", children: [jsx(Flex, { gap: "0.5rem", flexFlow: "column", children: order.map((
|
|
246
|
+
return (jsxs(Flex, { gap: "0.5rem", flexFlow: "column", children: [jsx(Flex, { gap: "0.5rem", flexFlow: "column", children: order.map((columnId, index) => (jsxs(Flex, { gap: "0.5rem", alignItems: "center", justifyContent: "space-between", children: [jsx(IconButton, { onClick: () => {
|
|
237
247
|
const prevIndex = index - 1;
|
|
238
248
|
if (prevIndex >= 0) {
|
|
239
249
|
handleChangeOrder(index, prevIndex);
|
|
240
250
|
}
|
|
241
|
-
}, disabled: index === 0, "aria-label": "", children: jsx(MdArrowUpward, {}) }),
|
|
251
|
+
}, disabled: index === 0, "aria-label": "", children: jsx(MdArrowUpward, {}) }), table
|
|
252
|
+
.getAllFlatColumns()
|
|
253
|
+
.filter((column) => {
|
|
254
|
+
return column.id === columnId;
|
|
255
|
+
})
|
|
256
|
+
.map((column) => {
|
|
257
|
+
const displayName = column.columnDef.meta === undefined
|
|
258
|
+
? column.id
|
|
259
|
+
: column.columnDef.meta.displayName;
|
|
260
|
+
return jsx(Fragment, { children: displayName });
|
|
261
|
+
}), jsx(IconButton, { onClick: () => {
|
|
242
262
|
const nextIndex = index + 1;
|
|
243
263
|
if (nextIndex < order.length) {
|
|
244
264
|
handleChangeOrder(index, nextIndex);
|
|
245
265
|
}
|
|
246
|
-
}, disabled: index === order.length - 1, "aria-label": "", children: jsx(MdArrowDownward, {}) })] },
|
|
266
|
+
}, disabled: index === order.length - 1, "aria-label": "", children: jsx(MdArrowDownward, {}) })] }, columnId))) }), jsxs(Flex, { gap: "0.25rem", children: [jsx(Button, { onClick: () => {
|
|
247
267
|
table.setColumnOrder(order);
|
|
248
268
|
}, children: "Apply" }), jsx(Button, { onClick: () => {
|
|
249
269
|
table.setColumnOrder(originalOrder);
|
|
@@ -268,7 +288,10 @@ const ResetSortingButton = () => {
|
|
|
268
288
|
const TableSorter = () => {
|
|
269
289
|
const { table } = useDataTable();
|
|
270
290
|
return (jsx(Fragment, { children: table.getHeaderGroups().map((headerGroup) => (jsx(Fragment, { children: headerGroup.headers.map((header) => {
|
|
271
|
-
|
|
291
|
+
const displayName = header.column.columnDef.meta === undefined
|
|
292
|
+
? header.column.id
|
|
293
|
+
: header.column.columnDef.meta.displayName;
|
|
294
|
+
return (jsx(Fragment, { children: header.column.getCanSort() && (jsxs(Flex, { alignItems: "center", gap: "0.5rem", padding: "0.5rem", children: [jsx(Text, { children: displayName }), jsxs(Button, { variant: "ghost", onClick: (e) => {
|
|
272
295
|
header.column.toggleSorting();
|
|
273
296
|
}, children: [header.column.getIsSorted() === false && (
|
|
274
297
|
// <Text>To No sort</Text>
|
|
@@ -286,11 +309,19 @@ const EditSortingButton = () => {
|
|
|
286
309
|
return (jsxs(Popover, { placement: "auto", children: [jsx(Tooltip, { label: "Filter", children: jsx(PopoverTrigger, { children: jsx(IconButton, { "aria-label": "filter", variant: "ghost", icon: jsx(MdOutlineSort, {}) }) }) }), jsxs(PopoverContent, { width: "auto", children: [jsx(PopoverArrow, {}), jsx(PopoverBody, { children: jsxs(Flex, { flexFlow: "column", gap: "0.25rem", children: [jsx(TableSorter, {}), jsx(ResetSortingButton, {})] }) })] })] }));
|
|
287
310
|
};
|
|
288
311
|
|
|
312
|
+
const TableViewer = () => {
|
|
313
|
+
const { table } = useDataTable();
|
|
314
|
+
return (jsx(Flex, { flexFlow: "column", gap: "1rem", children: table.getAllLeafColumns().map((column) => {
|
|
315
|
+
console.log(column.columnDef.meta, "gokspo");
|
|
316
|
+
const displayName = column.columnDef.meta === undefined
|
|
317
|
+
? column.id
|
|
318
|
+
: column.columnDef.meta.displayName;
|
|
319
|
+
return (jsxs(Flex, { flexFlow: "row", gap: "0.5rem", alignItems: "center", children: [jsx(Switch, { isChecked: column.getIsVisible(), onChange: column.getToggleVisibilityHandler() }), displayName] }));
|
|
320
|
+
}) }));
|
|
321
|
+
};
|
|
322
|
+
|
|
289
323
|
const EditViewButton = () => {
|
|
290
|
-
|
|
291
|
-
return (jsxs(Popover, { placement: "auto", children: [jsx(PopoverTrigger, { children: jsx(IconButton, { "aria-label": "view", variant: "ghost", icon: jsx(IoMdEye, {}) }) }), jsxs(PopoverContent, { width: "auto", children: [jsx(PopoverArrow, {}), jsx(PopoverBody, { children: jsx(Flex, { flexFlow: "column", gap: "1rem", children: table.getAllLeafColumns().map((column) => {
|
|
292
|
-
return (jsx(FormControl, { width: "auto", children: jsx(Checkbox, { isChecked: column.getIsVisible(), onChange: column.getToggleVisibilityHandler(), children: column.id }) }, crypto.randomUUID()));
|
|
293
|
-
}) }) })] })] }));
|
|
324
|
+
return (jsxs(Popover, { placement: "auto", children: [jsx(PopoverTrigger, { children: jsx(IconButton, { "aria-label": "view", variant: "ghost", icon: jsx(IoMdEye, {}) }) }), jsxs(PopoverContent, { width: "auto", children: [jsx(PopoverArrow, {}), jsx(PopoverBody, { children: jsx(TableViewer, {}) })] })] }));
|
|
294
325
|
};
|
|
295
326
|
|
|
296
327
|
const GlobalFilter = () => {
|
|
@@ -470,11 +501,11 @@ const TableSelector = () => {
|
|
|
470
501
|
}, "aria-label": "reset selection" }))] }));
|
|
471
502
|
};
|
|
472
503
|
|
|
473
|
-
const TextCell = ({ label, children }) => {
|
|
504
|
+
const TextCell = ({ label, noOfLines = [1], padding = "0rem", children, }) => {
|
|
474
505
|
if (label) {
|
|
475
|
-
return (jsx(Tooltip, { label: jsx(Text, { as: "span", overflow: "hidden", textOverflow: "ellipsis", noOfLines: [5], children: label }), placement: "auto", children: jsx(Text, { as: "span", textOverflow: "ellipsis", noOfLines:
|
|
506
|
+
return (jsx(Box, { padding: padding, children: jsx(Tooltip, { label: jsx(Text, { as: "span", overflow: "hidden", textOverflow: "ellipsis", noOfLines: [5], children: label }), placement: "auto", children: jsx(Text, { as: "span", textOverflow: "ellipsis", noOfLines: noOfLines, children: children }) }) }));
|
|
476
507
|
}
|
|
477
|
-
return (jsx(Text, { as: "span", overflow: "hidden", textOverflow: "ellipsis", noOfLines:
|
|
508
|
+
return (jsx(Box, { padding: padding, children: jsx(Text, { as: "span", overflow: "hidden", textOverflow: "ellipsis", noOfLines: noOfLines, children: children }) }));
|
|
478
509
|
};
|
|
479
510
|
|
|
480
|
-
export { DataTable, DataTableServer, EditFilterButton, EditOrderButton, EditSortingButton, EditViewButton, GlobalFilter, PageSizeControl, ResetFilteringButton, ResetSelectionButton, ResetSortingButton, Table, TableBody, TableCardContainer, TableCards, TableFilter, TableFooter, TableHeader, TableOrderer, TablePagination, TableSelector, TableSorter, TextCell, useDataFromUrl, useDataTable };
|
|
511
|
+
export { DataTable, DataTableServer, EditFilterButton, EditOrderButton, EditSortingButton, EditViewButton, GlobalFilter, PageSizeControl, ResetFilteringButton, ResetSelectionButton, ResetSortingButton, Table, TableBody, TableCardContainer, TableCards, TableFilter, TableFooter, TableHeader, TableOrderer, TablePagination, TableSelector, TableSorter, TableViewer, TextCell, useDataFromUrl, useDataTable };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { ColumnDef } from "@tanstack/react-table";
|
|
2
|
+
import { ColumnDef, RowData } from "@tanstack/react-table";
|
|
3
3
|
export interface DataTableServerProps<T> {
|
|
4
4
|
children: JSX.Element | JSX.Element[];
|
|
5
5
|
url: string;
|
|
@@ -16,4 +16,9 @@ export interface DataResponse<T> extends Result<T> {
|
|
|
16
16
|
count: number;
|
|
17
17
|
filterCount: number;
|
|
18
18
|
}
|
|
19
|
+
declare module "@tanstack/react-table" {
|
|
20
|
+
interface ColumnMeta<TData extends RowData, TValue> {
|
|
21
|
+
displayName: string;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
19
24
|
export declare const DataTableServer: <TData>({ columns, url, enableRowSelection, enableMultiRowSelection, enableSubRowSelection, children, }: DataTableServerProps<TData>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const TableViewer: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
export interface TextCellProps {
|
|
3
3
|
label?: string;
|
|
4
|
+
noOfLines?: number[];
|
|
5
|
+
padding?: string;
|
|
4
6
|
children: string | number | JSX.Element | JSX.Element[];
|
|
5
7
|
}
|
|
6
|
-
export declare const TextCell: ({ label, children }: TextCellProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare const TextCell: ({ label, noOfLines, padding, children, }: TextCellProps) => import("react/jsx-runtime").JSX.Element;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export * from "./components/TableOrderer";
|
|
|
20
20
|
export * from "./components/TablePagination";
|
|
21
21
|
export * from "./components/TableSelector";
|
|
22
22
|
export * from "./components/TableSorter";
|
|
23
|
+
export * from "./components/TableViewer";
|
|
23
24
|
export * from "./components/TextCell";
|
|
24
25
|
export * from "./components/useDataFromUrl";
|
|
25
26
|
export * from "./components/useDataTable";
|