@bsol-oss/react-datatable5 1.0.38 → 1.0.39
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 +45 -10
- package/dist/index.js +35 -29
- package/dist/index.mjs +38 -32
- package/dist/types/components/DensityToggleButton.d.ts +6 -1
- package/dist/types/components/EditFilterButton.d.ts +9 -1
- package/dist/types/components/EditOrderButton.d.ts +7 -1
- package/dist/types/components/EditSortingButton.d.ts +7 -1
- package/dist/types/components/EditViewButton.d.ts +7 -1
- package/dist/types/components/ResetFilteringButton.d.ts +4 -1
- package/dist/types/components/ResetSelectionButton.d.ts +4 -1
- package/dist/types/components/ResetSortingButton.d.ts +4 -1
- package/dist/types/components/SelectAllRowsToggle.d.ts +8 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
3
|
import { RowData, OnChangeFn, Updater, FilterFn, ColumnDef, RowSelectionState, ColumnFiltersState, SortingState, Row } from '@tanstack/react-table';
|
|
4
4
|
import { RankingInfo } from '@tanstack/match-sorter-utils';
|
|
5
|
-
import { ReactNode } from 'react';
|
|
5
|
+
import React$1, { ReactNode } from 'react';
|
|
6
6
|
import { TextProps, TooltipProps } from '@chakra-ui/react';
|
|
7
7
|
import * as _tanstack_table_core from '@tanstack/table-core';
|
|
8
8
|
|
|
@@ -92,15 +92,41 @@ declare module "@tanstack/react-table" {
|
|
|
92
92
|
}
|
|
93
93
|
declare const DataTableServer: <TData>({ columns, url, enableRowSelection, enableMultiRowSelection, enableSubRowSelection, onRowSelect, columnOrder: defaultColumnOrder, columnFilters: defaultColumnFilter, density, globalFilter: defaultGlobalFilter, pagination: defaultPagination, sorting: defaultSorting, rowSelection: defaultRowSelection, children, }: DataTableServerProps<TData>) => react_jsx_runtime.JSX.Element;
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
interface DensityToggleButtonProps {
|
|
96
|
+
icon?: React$1.ReactElement;
|
|
97
|
+
text?: string;
|
|
98
|
+
}
|
|
99
|
+
declare const DensityToggleButton: ({ text, icon, }: DensityToggleButtonProps) => react_jsx_runtime.JSX.Element;
|
|
96
100
|
|
|
97
|
-
|
|
101
|
+
interface EditFilterButtonProps {
|
|
102
|
+
text?: string;
|
|
103
|
+
title?: string;
|
|
104
|
+
closeText?: string;
|
|
105
|
+
resetText?: string;
|
|
106
|
+
icon?: React.ReactElement;
|
|
107
|
+
}
|
|
108
|
+
declare const EditFilterButton: ({ text, title, closeText, resetText, icon, }: EditFilterButtonProps) => react_jsx_runtime.JSX.Element;
|
|
98
109
|
|
|
99
|
-
|
|
110
|
+
interface EditOrderButtonProps {
|
|
111
|
+
title?: string;
|
|
112
|
+
icon?: React$1.ReactElement;
|
|
113
|
+
text?: string;
|
|
114
|
+
}
|
|
115
|
+
declare const EditOrderButton: ({ text, icon, title, }: EditOrderButtonProps) => react_jsx_runtime.JSX.Element;
|
|
100
116
|
|
|
101
|
-
|
|
117
|
+
interface EditSortingButtonProps {
|
|
118
|
+
title?: string;
|
|
119
|
+
icon?: React.ReactElement;
|
|
120
|
+
text?: string;
|
|
121
|
+
}
|
|
122
|
+
declare const EditSortingButton: ({ text, icon, title, }: EditSortingButtonProps) => react_jsx_runtime.JSX.Element;
|
|
102
123
|
|
|
103
|
-
|
|
124
|
+
interface EditViewButtonProps {
|
|
125
|
+
text?: string;
|
|
126
|
+
icon?: React$1.ReactElement;
|
|
127
|
+
title?: string;
|
|
128
|
+
}
|
|
129
|
+
declare const EditViewButton: ({ text, icon, title, }: EditViewButtonProps) => react_jsx_runtime.JSX.Element;
|
|
104
130
|
|
|
105
131
|
declare const GlobalFilter: () => react_jsx_runtime.JSX.Element;
|
|
106
132
|
|
|
@@ -109,11 +135,20 @@ interface PageSizeControlProps {
|
|
|
109
135
|
}
|
|
110
136
|
declare const PageSizeControl: ({ pageSizes, }: PageSizeControlProps) => react_jsx_runtime.JSX.Element;
|
|
111
137
|
|
|
112
|
-
|
|
138
|
+
interface ResetFilteringButtonProps {
|
|
139
|
+
text?: string;
|
|
140
|
+
}
|
|
141
|
+
declare const ResetFilteringButton: ({ text, }: ResetFilteringButtonProps) => react_jsx_runtime.JSX.Element;
|
|
113
142
|
|
|
114
|
-
|
|
143
|
+
interface ResetSelectionButtonProps {
|
|
144
|
+
text?: string;
|
|
145
|
+
}
|
|
146
|
+
declare const ResetSelectionButton: ({ text, }: ResetSelectionButtonProps) => react_jsx_runtime.JSX.Element;
|
|
115
147
|
|
|
116
|
-
|
|
148
|
+
interface ResetSortingButtonProps {
|
|
149
|
+
text?: string;
|
|
150
|
+
}
|
|
151
|
+
declare const ResetSortingButton: ({ text, }: ResetSortingButtonProps) => react_jsx_runtime.JSX.Element;
|
|
117
152
|
|
|
118
153
|
interface TableProps {
|
|
119
154
|
showLoading?: boolean;
|
|
@@ -209,4 +244,4 @@ declare const useDataTable: () => {
|
|
|
209
244
|
loading: boolean;
|
|
210
245
|
};
|
|
211
246
|
|
|
212
|
-
export { type DataResponse, DataTable, type DataTableProps, DataTableServer, type DataTableServerProps, DensityToggleButton, EditFilterButton, EditOrderButton, EditSortingButton, EditViewButton, GlobalFilter, PageSizeControl, type PageSizeControlProps, type PaginationProps, ResetFilteringButton, ResetSelectionButton, ResetSortingButton, type Result, Table, TableBody, type TableBodyProps, TableCardContainer, type TableCardContainerProps, TableCards, type TableCardsProps, TableFilter, TableFooter, type TableFooterProps, TableHeader, type TableHeaderProps, TableOrderer, TablePagination, type TableProps, type TableRowSelectorProps, TableSelector, TableSorter, TableViewer, TextCell, type TextCellProps, useDataFromUrl, type useDataFromUrlProps, type useDataFromUrlReturn, useDataTable };
|
|
247
|
+
export { type DataResponse, DataTable, type DataTableProps, DataTableServer, type DataTableServerProps, DensityToggleButton, type DensityToggleButtonProps, EditFilterButton, type EditFilterButtonProps, EditOrderButton, type EditOrderButtonProps, EditSortingButton, type EditSortingButtonProps, EditViewButton, type EditViewButtonProps, GlobalFilter, PageSizeControl, type PageSizeControlProps, type PaginationProps, ResetFilteringButton, type ResetFilteringButtonProps, ResetSelectionButton, type ResetSelectionButtonProps, ResetSortingButton, type ResetSortingButtonProps, type Result, Table, TableBody, type TableBodyProps, TableCardContainer, type TableCardContainerProps, TableCards, type TableCardsProps, TableFilter, TableFooter, type TableFooterProps, TableHeader, type TableHeaderProps, TableOrderer, TablePagination, type TableProps, type TableRowSelectorProps, TableSelector, TableSorter, TableViewer, TextCell, type TextCellProps, useDataFromUrl, type useDataFromUrlProps, type useDataFromUrlReturn, useDataTable };
|
package/dist/index.js
CHANGED
|
@@ -129,7 +129,7 @@ const DataTable = ({ columns, data, enableRowSelection = true, enableMultiRowSel
|
|
|
129
129
|
columnOrder,
|
|
130
130
|
globalFilter,
|
|
131
131
|
density: densityState,
|
|
132
|
-
rowSelection
|
|
132
|
+
rowSelection,
|
|
133
133
|
},
|
|
134
134
|
onColumnOrderChange: (state) => {
|
|
135
135
|
setColumnOrder(state);
|
|
@@ -166,7 +166,7 @@ const DataTable = ({ columns, data, enableRowSelection = true, enableMultiRowSel
|
|
|
166
166
|
},
|
|
167
167
|
globalFilter: globalFilter,
|
|
168
168
|
setGlobalFilter: setGlobalFilter,
|
|
169
|
-
loading: false
|
|
169
|
+
loading: false,
|
|
170
170
|
}, children: children }));
|
|
171
171
|
};
|
|
172
172
|
|
|
@@ -297,18 +297,20 @@ const DataTableServer = ({ columns, url, enableRowSelection = true, enableMultiR
|
|
|
297
297
|
}, children: children }));
|
|
298
298
|
};
|
|
299
299
|
|
|
300
|
-
const DensityToggleButton = () => {
|
|
300
|
+
const DensityToggleButton = ({ text, icon = jsxRuntime.jsx(ai.AiOutlineColumnWidth, {}), }) => {
|
|
301
301
|
const { table } = react.useContext(TableContext);
|
|
302
|
-
return (jsxRuntime.
|
|
303
|
-
|
|
304
|
-
|
|
302
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!!text === false && (jsxRuntime.jsx(react$1.IconButton, { variant: "ghost", "aria-label": "Toggle Density", icon: icon, onClick: () => {
|
|
303
|
+
table.toggleDensity();
|
|
304
|
+
} })), !!text !== false && (jsxRuntime.jsx(react$1.Button, { leftIcon: icon, variant: "ghost", "aria-label": "Toggle Density", onClick: () => {
|
|
305
|
+
table.toggleDensity();
|
|
306
|
+
}, children: text }))] }));
|
|
305
307
|
};
|
|
306
308
|
|
|
307
|
-
const ResetFilteringButton = () => {
|
|
309
|
+
const ResetFilteringButton = ({ text = "Reset Filtering", }) => {
|
|
308
310
|
const { table } = react.useContext(TableContext);
|
|
309
311
|
return (jsxRuntime.jsx(react$1.Button, { onClick: () => {
|
|
310
312
|
table.resetColumnFilters();
|
|
311
|
-
}, children:
|
|
313
|
+
}, children: text }));
|
|
312
314
|
};
|
|
313
315
|
|
|
314
316
|
const useDataTable = () => {
|
|
@@ -330,8 +332,9 @@ const TableFilter = () => {
|
|
|
330
332
|
}) }));
|
|
331
333
|
};
|
|
332
334
|
|
|
333
|
-
const EditFilterButton = () => {
|
|
334
|
-
|
|
335
|
+
const EditFilterButton = ({ text, title = "Edit Filter", closeText = "Close", resetText = "Reset", icon = jsxRuntime.jsx(md.MdFilterAlt, {}), }) => {
|
|
336
|
+
const filterModal = react$1.useDisclosure();
|
|
337
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!!text === false && (jsxRuntime.jsx(react$1.IconButton, { icon: icon, variant: "ghost", onClick: filterModal.onOpen, "aria-label": "filter" })), !!text !== false && (jsxRuntime.jsx(react$1.Button, { leftIcon: icon, variant: "ghost", onClick: filterModal.onOpen, children: text })), jsxRuntime.jsxs(react$1.Modal, { isOpen: filterModal.isOpen, onClose: filterModal.onClose, size: ["full", "full", "md", "md"], children: [jsxRuntime.jsx(react$1.ModalOverlay, {}), jsxRuntime.jsxs(react$1.ModalContent, { children: [jsxRuntime.jsx(react$1.ModalHeader, { children: title }), jsxRuntime.jsx(react$1.ModalCloseButton, {}), jsxRuntime.jsx(react$1.ModalBody, { children: jsxRuntime.jsxs(react$1.Flex, { flexFlow: "column", gap: "1rem", children: [jsxRuntime.jsx(TableFilter, {}), jsxRuntime.jsx(ResetFilteringButton, { text: resetText })] }) }), jsxRuntime.jsx(react$1.ModalFooter, { children: jsxRuntime.jsx(react$1.Button, { onClick: filterModal.onClose, children: closeText }) })] })] })] }));
|
|
335
338
|
};
|
|
336
339
|
|
|
337
340
|
const ColumnOrderChanger = ({ columns }) => {
|
|
@@ -387,15 +390,16 @@ const TableOrderer = () => {
|
|
|
387
390
|
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(ColumnOrderChanger, { columns: table.getState().columnOrder }) }));
|
|
388
391
|
};
|
|
389
392
|
|
|
390
|
-
const EditOrderButton = () => {
|
|
391
|
-
|
|
393
|
+
const EditOrderButton = ({ text, icon = jsxRuntime.jsx(md.MdOutlineMoveDown, {}), title = "Change Order", }) => {
|
|
394
|
+
const orderModal = react$1.useDisclosure();
|
|
395
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!!text === false && (jsxRuntime.jsx(react$1.IconButton, { icon: icon, variant: "ghost", onClick: orderModal.onOpen, "aria-label": "change order" })), !!text !== false && (jsxRuntime.jsx(react$1.Button, { leftIcon: icon, variant: "ghost", onClick: orderModal.onOpen, children: text })), jsxRuntime.jsxs(react$1.Modal, { isOpen: orderModal.isOpen, onClose: orderModal.onClose, size: ["full", "full", "md", "md"], children: [jsxRuntime.jsx(react$1.ModalOverlay, {}), jsxRuntime.jsxs(react$1.ModalContent, { padding: "0 0 1rem 0", children: [jsxRuntime.jsx(react$1.ModalHeader, { children: title }), jsxRuntime.jsx(react$1.ModalCloseButton, {}), jsxRuntime.jsx(react$1.ModalBody, { children: jsxRuntime.jsx(react$1.Flex, { flexFlow: "column", gap: "0.25rem", children: jsxRuntime.jsx(TableOrderer, {}) }) })] })] })] }));
|
|
392
396
|
};
|
|
393
397
|
|
|
394
|
-
const ResetSortingButton = () => {
|
|
398
|
+
const ResetSortingButton = ({ text = "Reset Sorting", }) => {
|
|
395
399
|
const { table } = react.useContext(TableContext);
|
|
396
400
|
return (jsxRuntime.jsx(react$1.Button, { onClick: () => {
|
|
397
401
|
table.resetSorting();
|
|
398
|
-
}, children:
|
|
402
|
+
}, children: text }));
|
|
399
403
|
};
|
|
400
404
|
|
|
401
405
|
const TableSorter = () => {
|
|
@@ -418,8 +422,9 @@ const TableSorter = () => {
|
|
|
418
422
|
}) }))) }));
|
|
419
423
|
};
|
|
420
424
|
|
|
421
|
-
const EditSortingButton = () => {
|
|
422
|
-
|
|
425
|
+
const EditSortingButton = ({ text, icon = jsxRuntime.jsx(md.MdOutlineSort, {}), title = "Edit Sorting", }) => {
|
|
426
|
+
const sortingModal = react$1.useDisclosure();
|
|
427
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!!text === false && (jsxRuntime.jsx(react$1.IconButton, { icon: icon, variant: "ghost", onClick: sortingModal.onOpen, "aria-label": "change sorting" })), !!text !== false && (jsxRuntime.jsx(react$1.Button, { leftIcon: icon, variant: "ghost", onClick: sortingModal.onOpen, children: text })), jsxRuntime.jsxs(react$1.Modal, { isOpen: sortingModal.isOpen, onClose: sortingModal.onClose, size: ["full", "full", "md", "md"], children: [jsxRuntime.jsx(react$1.ModalOverlay, {}), jsxRuntime.jsxs(react$1.ModalContent, { padding: "0 0 1rem 0", children: [jsxRuntime.jsx(react$1.ModalHeader, { children: title }), jsxRuntime.jsx(react$1.ModalCloseButton, {}), jsxRuntime.jsx(react$1.ModalBody, { children: jsxRuntime.jsxs(react$1.Flex, { flexFlow: "column", gap: "0.25rem", children: [jsxRuntime.jsx(TableSorter, {}), jsxRuntime.jsx(ResetSortingButton, {})] }) })] })] })] }));
|
|
423
428
|
};
|
|
424
429
|
|
|
425
430
|
const TableViewer = () => {
|
|
@@ -432,8 +437,9 @@ const TableViewer = () => {
|
|
|
432
437
|
}) }));
|
|
433
438
|
};
|
|
434
439
|
|
|
435
|
-
const EditViewButton = () => {
|
|
436
|
-
|
|
440
|
+
const EditViewButton = ({ text, icon = jsxRuntime.jsx(io.IoMdEye, {}), title = "Edit View", }) => {
|
|
441
|
+
const viewModel = react$1.useDisclosure();
|
|
442
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!!text === false && (jsxRuntime.jsx(react$1.IconButton, { icon: icon, variant: "ghost", onClick: viewModel.onOpen, "aria-label": "change sorting" })), !!text !== false && (jsxRuntime.jsx(react$1.Button, { leftIcon: icon, variant: "ghost", onClick: viewModel.onOpen, children: text })), jsxRuntime.jsxs(react$1.Modal, { isOpen: viewModel.isOpen, onClose: viewModel.onClose, size: ["full", "full", "md", "md"], children: [jsxRuntime.jsx(react$1.ModalOverlay, {}), jsxRuntime.jsxs(react$1.ModalContent, { padding: "0 0 1rem 0", children: [jsxRuntime.jsx(react$1.ModalHeader, { children: title }), jsxRuntime.jsx(react$1.ModalCloseButton, {}), jsxRuntime.jsx(react$1.ModalBody, { children: jsxRuntime.jsx(TableViewer, {}) })] })] })] }));
|
|
437
443
|
};
|
|
438
444
|
|
|
439
445
|
const GlobalFilter = () => {
|
|
@@ -450,19 +456,19 @@ const PageSizeControl = ({ pageSizes = [10, 20, 30, 40, 50], }) => {
|
|
|
450
456
|
}, children: pageSize }))) })] }) }));
|
|
451
457
|
};
|
|
452
458
|
|
|
453
|
-
const ResetSelectionButton = () => {
|
|
459
|
+
const ResetSelectionButton = ({ text = "Reset Selection", }) => {
|
|
454
460
|
const { table } = react.useContext(TableContext);
|
|
455
461
|
return (jsxRuntime.jsx(react$1.Button, { onClick: () => {
|
|
456
462
|
table.resetRowSelection();
|
|
457
|
-
}, children:
|
|
463
|
+
}, children: text }));
|
|
458
464
|
};
|
|
459
465
|
|
|
460
466
|
const Table = ({ children, showLoading = false, loadingComponent = jsxRuntime.jsx(jsxRuntime.Fragment, { children: "Loading..." }), ...props }) => {
|
|
461
467
|
const { table, loading } = useDataTable();
|
|
462
468
|
if (showLoading) {
|
|
463
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [loading && loadingComponent, !loading && (jsxRuntime.jsx(react$1.Table, { width: table.getCenterTotalSize(), overflowX: "
|
|
469
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [loading && loadingComponent, !loading && (jsxRuntime.jsx(react$1.Table, { width: table.getCenterTotalSize(), overflowX: "auto", ...props, children: children }))] }));
|
|
464
470
|
}
|
|
465
|
-
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(react$1.Table, { width: table.getCenterTotalSize(), overflowX: "
|
|
471
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(react$1.Table, { width: table.getCenterTotalSize(), overflowX: "auto", ...props, children: children }) }));
|
|
466
472
|
};
|
|
467
473
|
|
|
468
474
|
const TableBody = ({ pinnedBgColor = { light: "gray.50", dark: "gray.700" }, }) => {
|
|
@@ -628,9 +634,7 @@ const TableHeader = ({ canResize, pinnedBgColor = { light: "gray.50", dark: "gra
|
|
|
628
634
|
// styling resize and pinning end
|
|
629
635
|
display: "grid", children: [jsxRuntime.jsxs(react$1.Menu, { children: [jsxRuntime.jsx(react$1.MenuButton, { as: react$1.Box, padding: `${table.getDensityValue()}px`, display: "flex", alignItems: "center", justifyContent: "start", borderRadius: "0rem", _hover: { backgroundColor: "gray.100" }, children: jsxRuntime.jsxs(react$1.Flex, { gap: "0.5rem", alignItems: "center", children: [header.isPlaceholder
|
|
630
636
|
? null
|
|
631
|
-
: reactTable.flexRender(header.column.columnDef.header, header.getContext()), jsxRuntime.jsx(react$1.Box, { children: header.column.getCanSort() && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [header.column.getIsSorted() === false && (
|
|
632
|
-
// <UpDownIcon />
|
|
633
|
-
jsxRuntime.jsx(jsxRuntime.Fragment, {})), header.column.getIsSorted() === "asc" && (jsxRuntime.jsx(icons.ChevronUpIcon, {})), header.column.getIsSorted() === "desc" && (jsxRuntime.jsx(icons.ChevronDownIcon, {}))] })) }), jsxRuntime.jsx(react$1.Box, { children: header.column.getIsFiltered() && jsxRuntime.jsx(md.MdFilterListAlt, {}) })] }) }), jsxRuntime.jsx(react$1.Portal, { children: jsxRuntime.jsxs(react$1.MenuList, { children: [!header.column.getIsPinned() && (jsxRuntime.jsx(react$1.MenuItem, { icon: jsxRuntime.jsx(md.MdPushPin, {}), onClick: () => {
|
|
637
|
+
: reactTable.flexRender(header.column.columnDef.header, header.getContext()), jsxRuntime.jsx(react$1.Box, { children: header.column.getCanSort() && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [header.column.getIsSorted() === false && (jsxRuntime.jsx(jsxRuntime.Fragment, {})), header.column.getIsSorted() === "asc" && (jsxRuntime.jsx(icons.ChevronUpIcon, {})), header.column.getIsSorted() === "desc" && (jsxRuntime.jsx(icons.ChevronDownIcon, {}))] })) }), jsxRuntime.jsx(react$1.Box, { children: header.column.getIsFiltered() && jsxRuntime.jsx(md.MdFilterListAlt, {}) })] }) }), jsxRuntime.jsx(react$1.Portal, { children: jsxRuntime.jsxs(react$1.MenuList, { children: [!header.column.getIsPinned() && (jsxRuntime.jsx(react$1.MenuItem, { icon: jsxRuntime.jsx(md.MdPushPin, {}), onClick: () => {
|
|
634
638
|
header.column.pin("left");
|
|
635
639
|
}, children: "Pin Column" })), header.column.getIsPinned() && (jsxRuntime.jsx(react$1.MenuItem, { icon: jsxRuntime.jsx(md.MdCancel, {}), onClick: () => {
|
|
636
640
|
header.column.pin(false);
|
|
@@ -651,11 +655,13 @@ const TablePagination = ({}) => {
|
|
|
651
655
|
return (jsxRuntime.jsxs(react$1.ButtonGroup, { isAttached: true, children: [jsxRuntime.jsx(react$1.IconButton, { icon: jsxRuntime.jsx(md.MdFirstPage, {}), onClick: () => firstPage(), isDisabled: !getCanPreviousPage(), "aria-label": "first-page", variant: "ghost" }), jsxRuntime.jsx(react$1.IconButton, { icon: jsxRuntime.jsx(md.MdArrowBack, {}), onClick: () => previousPage(), isDisabled: !getCanPreviousPage(), "aria-label": "previous-page", variant: "ghost" }), jsxRuntime.jsx(react$1.Button, { variant: "ghost", onClick: () => { }, disabled: !getCanPreviousPage(), children: getState().pagination.pageIndex + 1 }), jsxRuntime.jsx(react$1.IconButton, { onClick: () => nextPage(), isDisabled: !getCanNextPage(), "aria-label": "next-page", variant: "ghost", children: jsxRuntime.jsx(md.MdArrowForward, {}) }), jsxRuntime.jsx(react$1.IconButton, { onClick: () => lastPage(), isDisabled: !getCanNextPage(), "aria-label": "last-page", variant: "ghost", children: jsxRuntime.jsx(md.MdLastPage, {}) })] }));
|
|
652
656
|
};
|
|
653
657
|
|
|
654
|
-
const SelectAllRowsToggle = () => {
|
|
658
|
+
const SelectAllRowsToggle = ({ selectAllIcon = jsxRuntime.jsx(md.MdOutlineChecklist, {}), clearAllIcon = jsxRuntime.jsx(md.MdClear, {}), selectAllText, clearAllText, }) => {
|
|
655
659
|
const { table } = react.useContext(TableContext);
|
|
656
|
-
return (jsxRuntime.
|
|
657
|
-
|
|
658
|
-
|
|
660
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!!selectAllText === false && (jsxRuntime.jsx(react$1.IconButton, { icon: table.getIsAllRowsSelected() ? clearAllIcon : selectAllIcon, variant: "ghost", "aria-label": table.getIsAllRowsSelected() ? clearAllText : selectAllText, onClick: (event) => {
|
|
661
|
+
table.getToggleAllRowsSelectedHandler()(event);
|
|
662
|
+
} })), !!selectAllText !== false && (jsxRuntime.jsx(react$1.Button, { leftIcon: table.getIsAllRowsSelected() ? clearAllIcon : selectAllIcon, variant: "ghost", onClick: (event) => {
|
|
663
|
+
table.getToggleAllRowsSelectedHandler()(event);
|
|
664
|
+
}, children: table.getIsAllRowsSelected() ? clearAllText : selectAllText }))] }));
|
|
659
665
|
};
|
|
660
666
|
|
|
661
667
|
const TableSelector = () => {
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { jsx,
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { makeStateUpdater, functionalUpdate, useReactTable, getCoreRowModel, getFilteredRowModel, getSortedRowModel, getPaginationRowModel, flexRender } from '@tanstack/react-table';
|
|
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 {
|
|
6
|
+
import { IconButton, Button, Box, Text, Input, useDisclosure, Modal, ModalOverlay, ModalContent, ModalHeader, ModalCloseButton, ModalBody, Flex, ModalFooter, Switch, Menu, MenuButton, MenuList, MenuItem, Table as Table$1, FormLabel, Checkbox, Grid, Card, CardBody, Tfoot, Tr as Tr$1, Th, Thead, Portal, ButtonGroup, Icon, Tooltip } from '@chakra-ui/react';
|
|
7
7
|
import { AiOutlineColumnWidth } from 'react-icons/ai';
|
|
8
|
-
import { MdFilterAlt, MdArrowUpward, MdArrowDownward, MdOutlineMoveDown, MdOutlineSort, MdFilterListAlt, MdPushPin, MdCancel, MdSort, MdFirstPage, MdArrowBack, MdArrowForward, MdLastPage,
|
|
8
|
+
import { MdFilterAlt, MdArrowUpward, MdArrowDownward, MdOutlineMoveDown, MdOutlineSort, MdFilterListAlt, MdPushPin, MdCancel, MdSort, MdFirstPage, MdArrowBack, MdArrowForward, MdLastPage, MdOutlineChecklist, MdClear } from 'react-icons/md';
|
|
9
9
|
import { UpDownIcon, ChevronDownIcon, ChevronUpIcon, CloseIcon } from '@chakra-ui/icons';
|
|
10
10
|
import { IoMdEye, IoMdClose, IoMdCheckbox } from 'react-icons/io';
|
|
11
11
|
import { Tbody, Tr, Td } from '@chakra-ui/table';
|
|
@@ -127,7 +127,7 @@ const DataTable = ({ columns, data, enableRowSelection = true, enableMultiRowSel
|
|
|
127
127
|
columnOrder,
|
|
128
128
|
globalFilter,
|
|
129
129
|
density: densityState,
|
|
130
|
-
rowSelection
|
|
130
|
+
rowSelection,
|
|
131
131
|
},
|
|
132
132
|
onColumnOrderChange: (state) => {
|
|
133
133
|
setColumnOrder(state);
|
|
@@ -164,7 +164,7 @@ const DataTable = ({ columns, data, enableRowSelection = true, enableMultiRowSel
|
|
|
164
164
|
},
|
|
165
165
|
globalFilter: globalFilter,
|
|
166
166
|
setGlobalFilter: setGlobalFilter,
|
|
167
|
-
loading: false
|
|
167
|
+
loading: false,
|
|
168
168
|
}, children: children }));
|
|
169
169
|
};
|
|
170
170
|
|
|
@@ -295,18 +295,20 @@ const DataTableServer = ({ columns, url, enableRowSelection = true, enableMultiR
|
|
|
295
295
|
}, children: children }));
|
|
296
296
|
};
|
|
297
297
|
|
|
298
|
-
const DensityToggleButton = () => {
|
|
298
|
+
const DensityToggleButton = ({ text, icon = jsx(AiOutlineColumnWidth, {}), }) => {
|
|
299
299
|
const { table } = useContext(TableContext);
|
|
300
|
-
return (
|
|
301
|
-
|
|
302
|
-
|
|
300
|
+
return (jsxs(Fragment, { children: [!!text === false && (jsx(IconButton, { variant: "ghost", "aria-label": "Toggle Density", icon: icon, onClick: () => {
|
|
301
|
+
table.toggleDensity();
|
|
302
|
+
} })), !!text !== false && (jsx(Button, { leftIcon: icon, variant: "ghost", "aria-label": "Toggle Density", onClick: () => {
|
|
303
|
+
table.toggleDensity();
|
|
304
|
+
}, children: text }))] }));
|
|
303
305
|
};
|
|
304
306
|
|
|
305
|
-
const ResetFilteringButton = () => {
|
|
307
|
+
const ResetFilteringButton = ({ text = "Reset Filtering", }) => {
|
|
306
308
|
const { table } = useContext(TableContext);
|
|
307
309
|
return (jsx(Button, { onClick: () => {
|
|
308
310
|
table.resetColumnFilters();
|
|
309
|
-
}, children:
|
|
311
|
+
}, children: text }));
|
|
310
312
|
};
|
|
311
313
|
|
|
312
314
|
const useDataTable = () => {
|
|
@@ -328,8 +330,9 @@ const TableFilter = () => {
|
|
|
328
330
|
}) }));
|
|
329
331
|
};
|
|
330
332
|
|
|
331
|
-
const EditFilterButton = () => {
|
|
332
|
-
|
|
333
|
+
const EditFilterButton = ({ text, title = "Edit Filter", closeText = "Close", resetText = "Reset", icon = jsx(MdFilterAlt, {}), }) => {
|
|
334
|
+
const filterModal = useDisclosure();
|
|
335
|
+
return (jsxs(Fragment, { children: [!!text === false && (jsx(IconButton, { icon: icon, variant: "ghost", onClick: filterModal.onOpen, "aria-label": "filter" })), !!text !== false && (jsx(Button, { leftIcon: icon, variant: "ghost", onClick: filterModal.onOpen, children: text })), jsxs(Modal, { isOpen: filterModal.isOpen, onClose: filterModal.onClose, size: ["full", "full", "md", "md"], children: [jsx(ModalOverlay, {}), jsxs(ModalContent, { children: [jsx(ModalHeader, { children: title }), jsx(ModalCloseButton, {}), jsx(ModalBody, { children: jsxs(Flex, { flexFlow: "column", gap: "1rem", children: [jsx(TableFilter, {}), jsx(ResetFilteringButton, { text: resetText })] }) }), jsx(ModalFooter, { children: jsx(Button, { onClick: filterModal.onClose, children: closeText }) })] })] })] }));
|
|
333
336
|
};
|
|
334
337
|
|
|
335
338
|
const ColumnOrderChanger = ({ columns }) => {
|
|
@@ -385,15 +388,16 @@ const TableOrderer = () => {
|
|
|
385
388
|
return (jsx(Fragment, { children: jsx(ColumnOrderChanger, { columns: table.getState().columnOrder }) }));
|
|
386
389
|
};
|
|
387
390
|
|
|
388
|
-
const EditOrderButton = () => {
|
|
389
|
-
|
|
391
|
+
const EditOrderButton = ({ text, icon = jsx(MdOutlineMoveDown, {}), title = "Change Order", }) => {
|
|
392
|
+
const orderModal = useDisclosure();
|
|
393
|
+
return (jsxs(Fragment, { children: [!!text === false && (jsx(IconButton, { icon: icon, variant: "ghost", onClick: orderModal.onOpen, "aria-label": "change order" })), !!text !== false && (jsx(Button, { leftIcon: icon, variant: "ghost", onClick: orderModal.onOpen, children: text })), jsxs(Modal, { isOpen: orderModal.isOpen, onClose: orderModal.onClose, size: ["full", "full", "md", "md"], children: [jsx(ModalOverlay, {}), jsxs(ModalContent, { padding: "0 0 1rem 0", children: [jsx(ModalHeader, { children: title }), jsx(ModalCloseButton, {}), jsx(ModalBody, { children: jsx(Flex, { flexFlow: "column", gap: "0.25rem", children: jsx(TableOrderer, {}) }) })] })] })] }));
|
|
390
394
|
};
|
|
391
395
|
|
|
392
|
-
const ResetSortingButton = () => {
|
|
396
|
+
const ResetSortingButton = ({ text = "Reset Sorting", }) => {
|
|
393
397
|
const { table } = useContext(TableContext);
|
|
394
398
|
return (jsx(Button, { onClick: () => {
|
|
395
399
|
table.resetSorting();
|
|
396
|
-
}, children:
|
|
400
|
+
}, children: text }));
|
|
397
401
|
};
|
|
398
402
|
|
|
399
403
|
const TableSorter = () => {
|
|
@@ -416,8 +420,9 @@ const TableSorter = () => {
|
|
|
416
420
|
}) }))) }));
|
|
417
421
|
};
|
|
418
422
|
|
|
419
|
-
const EditSortingButton = () => {
|
|
420
|
-
|
|
423
|
+
const EditSortingButton = ({ text, icon = jsx(MdOutlineSort, {}), title = "Edit Sorting", }) => {
|
|
424
|
+
const sortingModal = useDisclosure();
|
|
425
|
+
return (jsxs(Fragment, { children: [!!text === false && (jsx(IconButton, { icon: icon, variant: "ghost", onClick: sortingModal.onOpen, "aria-label": "change sorting" })), !!text !== false && (jsx(Button, { leftIcon: icon, variant: "ghost", onClick: sortingModal.onOpen, children: text })), jsxs(Modal, { isOpen: sortingModal.isOpen, onClose: sortingModal.onClose, size: ["full", "full", "md", "md"], children: [jsx(ModalOverlay, {}), jsxs(ModalContent, { padding: "0 0 1rem 0", children: [jsx(ModalHeader, { children: title }), jsx(ModalCloseButton, {}), jsx(ModalBody, { children: jsxs(Flex, { flexFlow: "column", gap: "0.25rem", children: [jsx(TableSorter, {}), jsx(ResetSortingButton, {})] }) })] })] })] }));
|
|
421
426
|
};
|
|
422
427
|
|
|
423
428
|
const TableViewer = () => {
|
|
@@ -430,8 +435,9 @@ const TableViewer = () => {
|
|
|
430
435
|
}) }));
|
|
431
436
|
};
|
|
432
437
|
|
|
433
|
-
const EditViewButton = () => {
|
|
434
|
-
|
|
438
|
+
const EditViewButton = ({ text, icon = jsx(IoMdEye, {}), title = "Edit View", }) => {
|
|
439
|
+
const viewModel = useDisclosure();
|
|
440
|
+
return (jsxs(Fragment, { children: [!!text === false && (jsx(IconButton, { icon: icon, variant: "ghost", onClick: viewModel.onOpen, "aria-label": "change sorting" })), !!text !== false && (jsx(Button, { leftIcon: icon, variant: "ghost", onClick: viewModel.onOpen, children: text })), jsxs(Modal, { isOpen: viewModel.isOpen, onClose: viewModel.onClose, size: ["full", "full", "md", "md"], children: [jsx(ModalOverlay, {}), jsxs(ModalContent, { padding: "0 0 1rem 0", children: [jsx(ModalHeader, { children: title }), jsx(ModalCloseButton, {}), jsx(ModalBody, { children: jsx(TableViewer, {}) })] })] })] }));
|
|
435
441
|
};
|
|
436
442
|
|
|
437
443
|
const GlobalFilter = () => {
|
|
@@ -448,19 +454,19 @@ const PageSizeControl = ({ pageSizes = [10, 20, 30, 40, 50], }) => {
|
|
|
448
454
|
}, children: pageSize }))) })] }) }));
|
|
449
455
|
};
|
|
450
456
|
|
|
451
|
-
const ResetSelectionButton = () => {
|
|
457
|
+
const ResetSelectionButton = ({ text = "Reset Selection", }) => {
|
|
452
458
|
const { table } = useContext(TableContext);
|
|
453
459
|
return (jsx(Button, { onClick: () => {
|
|
454
460
|
table.resetRowSelection();
|
|
455
|
-
}, children:
|
|
461
|
+
}, children: text }));
|
|
456
462
|
};
|
|
457
463
|
|
|
458
464
|
const Table = ({ children, showLoading = false, loadingComponent = jsx(Fragment, { children: "Loading..." }), ...props }) => {
|
|
459
465
|
const { table, loading } = useDataTable();
|
|
460
466
|
if (showLoading) {
|
|
461
|
-
return (jsxs(Fragment, { children: [loading && loadingComponent, !loading && (jsx(Table$1, { width: table.getCenterTotalSize(), overflowX: "
|
|
467
|
+
return (jsxs(Fragment, { children: [loading && loadingComponent, !loading && (jsx(Table$1, { width: table.getCenterTotalSize(), overflowX: "auto", ...props, children: children }))] }));
|
|
462
468
|
}
|
|
463
|
-
return (jsx(Fragment, { children: jsx(Table$1, { width: table.getCenterTotalSize(), overflowX: "
|
|
469
|
+
return (jsx(Fragment, { children: jsx(Table$1, { width: table.getCenterTotalSize(), overflowX: "auto", ...props, children: children }) }));
|
|
464
470
|
};
|
|
465
471
|
|
|
466
472
|
const TableBody = ({ pinnedBgColor = { light: "gray.50", dark: "gray.700" }, }) => {
|
|
@@ -626,9 +632,7 @@ const TableHeader = ({ canResize, pinnedBgColor = { light: "gray.50", dark: "gra
|
|
|
626
632
|
// styling resize and pinning end
|
|
627
633
|
display: "grid", children: [jsxs(Menu, { children: [jsx(MenuButton, { as: Box, padding: `${table.getDensityValue()}px`, display: "flex", alignItems: "center", justifyContent: "start", borderRadius: "0rem", _hover: { backgroundColor: "gray.100" }, children: jsxs(Flex, { gap: "0.5rem", alignItems: "center", children: [header.isPlaceholder
|
|
628
634
|
? null
|
|
629
|
-
: flexRender(header.column.columnDef.header, header.getContext()), jsx(Box, { children: header.column.getCanSort() && (jsxs(Fragment, { children: [header.column.getIsSorted() === false && (
|
|
630
|
-
// <UpDownIcon />
|
|
631
|
-
jsx(Fragment, {})), header.column.getIsSorted() === "asc" && (jsx(ChevronUpIcon, {})), header.column.getIsSorted() === "desc" && (jsx(ChevronDownIcon, {}))] })) }), jsx(Box, { children: header.column.getIsFiltered() && jsx(MdFilterListAlt, {}) })] }) }), jsx(Portal, { children: jsxs(MenuList, { children: [!header.column.getIsPinned() && (jsx(MenuItem, { icon: jsx(MdPushPin, {}), onClick: () => {
|
|
635
|
+
: flexRender(header.column.columnDef.header, header.getContext()), jsx(Box, { children: header.column.getCanSort() && (jsxs(Fragment, { children: [header.column.getIsSorted() === false && (jsx(Fragment, {})), header.column.getIsSorted() === "asc" && (jsx(ChevronUpIcon, {})), header.column.getIsSorted() === "desc" && (jsx(ChevronDownIcon, {}))] })) }), jsx(Box, { children: header.column.getIsFiltered() && jsx(MdFilterListAlt, {}) })] }) }), jsx(Portal, { children: jsxs(MenuList, { children: [!header.column.getIsPinned() && (jsx(MenuItem, { icon: jsx(MdPushPin, {}), onClick: () => {
|
|
632
636
|
header.column.pin("left");
|
|
633
637
|
}, children: "Pin Column" })), header.column.getIsPinned() && (jsx(MenuItem, { icon: jsx(MdCancel, {}), onClick: () => {
|
|
634
638
|
header.column.pin(false);
|
|
@@ -649,11 +653,13 @@ const TablePagination = ({}) => {
|
|
|
649
653
|
return (jsxs(ButtonGroup, { isAttached: true, children: [jsx(IconButton, { icon: jsx(MdFirstPage, {}), onClick: () => firstPage(), isDisabled: !getCanPreviousPage(), "aria-label": "first-page", variant: "ghost" }), jsx(IconButton, { icon: jsx(MdArrowBack, {}), onClick: () => previousPage(), isDisabled: !getCanPreviousPage(), "aria-label": "previous-page", variant: "ghost" }), jsx(Button, { variant: "ghost", onClick: () => { }, disabled: !getCanPreviousPage(), children: getState().pagination.pageIndex + 1 }), jsx(IconButton, { onClick: () => nextPage(), isDisabled: !getCanNextPage(), "aria-label": "next-page", variant: "ghost", children: jsx(MdArrowForward, {}) }), jsx(IconButton, { onClick: () => lastPage(), isDisabled: !getCanNextPage(), "aria-label": "last-page", variant: "ghost", children: jsx(MdLastPage, {}) })] }));
|
|
650
654
|
};
|
|
651
655
|
|
|
652
|
-
const SelectAllRowsToggle = () => {
|
|
656
|
+
const SelectAllRowsToggle = ({ selectAllIcon = jsx(MdOutlineChecklist, {}), clearAllIcon = jsx(MdClear, {}), selectAllText, clearAllText, }) => {
|
|
653
657
|
const { table } = useContext(TableContext);
|
|
654
|
-
return (
|
|
655
|
-
|
|
656
|
-
|
|
658
|
+
return (jsxs(Fragment, { children: [!!selectAllText === false && (jsx(IconButton, { icon: table.getIsAllRowsSelected() ? clearAllIcon : selectAllIcon, variant: "ghost", "aria-label": table.getIsAllRowsSelected() ? clearAllText : selectAllText, onClick: (event) => {
|
|
659
|
+
table.getToggleAllRowsSelectedHandler()(event);
|
|
660
|
+
} })), !!selectAllText !== false && (jsx(Button, { leftIcon: table.getIsAllRowsSelected() ? clearAllIcon : selectAllIcon, variant: "ghost", onClick: (event) => {
|
|
661
|
+
table.getToggleAllRowsSelectedHandler()(event);
|
|
662
|
+
}, children: table.getIsAllRowsSelected() ? clearAllText : selectAllText }))] }));
|
|
657
663
|
};
|
|
658
664
|
|
|
659
665
|
const TableSelector = () => {
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface DensityToggleButtonProps {
|
|
3
|
+
icon?: React.ReactElement;
|
|
4
|
+
text?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const DensityToggleButton: ({ text, icon, }: DensityToggleButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export interface EditFilterButtonProps {
|
|
3
|
+
text?: string;
|
|
4
|
+
title?: string;
|
|
5
|
+
closeText?: string;
|
|
6
|
+
resetText?: string;
|
|
7
|
+
icon?: React.ReactElement;
|
|
8
|
+
}
|
|
9
|
+
export declare const EditFilterButton: ({ text, title, closeText, resetText, icon, }: EditFilterButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface EditOrderButtonProps {
|
|
3
|
+
title?: string;
|
|
4
|
+
icon?: React.ReactElement;
|
|
5
|
+
text?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const EditOrderButton: ({ text, icon, title, }: EditOrderButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export interface EditSortingButtonProps {
|
|
3
|
+
title?: string;
|
|
4
|
+
icon?: React.ReactElement;
|
|
5
|
+
text?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const EditSortingButton: ({ text, icon, title, }: EditSortingButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface EditViewButtonProps {
|
|
3
|
+
text?: string;
|
|
4
|
+
icon?: React.ReactElement;
|
|
5
|
+
title?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const EditViewButton: ({ text, icon, title, }: EditViewButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface ResetFilteringButtonProps {
|
|
2
|
+
text?: string;
|
|
3
|
+
}
|
|
4
|
+
export declare const ResetFilteringButton: ({ text, }: ResetFilteringButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface ResetSelectionButtonProps {
|
|
2
|
+
text?: string;
|
|
3
|
+
}
|
|
4
|
+
export declare const ResetSelectionButton: ({ text, }: ResetSelectionButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface ResetSortingButtonProps {
|
|
2
|
+
text?: string;
|
|
3
|
+
}
|
|
4
|
+
export declare const ResetSortingButton: ({ text, }: ResetSortingButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface SelectAllRowsToggleProps {
|
|
3
|
+
selectAllIcon: React.ReactElement;
|
|
4
|
+
clearAllIcon: React.ReactElement;
|
|
5
|
+
selectAllText: string;
|
|
6
|
+
clearAllText: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const SelectAllRowsToggle: ({ selectAllIcon, clearAllIcon, selectAllText, clearAllText, }: SelectAllRowsToggleProps) => import("react/jsx-runtime").JSX.Element;
|