@prt-ts/fluent-react-table-v2 9.46.8-build.4.0 → 9.46.8-build.6.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/index.cjs.js +302 -141
- package/index.esm.js +303 -143
- package/package.json +7 -4
- package/src/lib/components/GridContainer.d.ts +3 -2
- package/src/lib/components/filters/Filter.d.ts +1 -1
- package/src/lib/components/filters/FilterDate.d.ts +3 -3
- package/src/lib/components/filters/FilterDateRange.d.ts +3 -3
- package/src/lib/components/filters/FilterDrawer.d.ts +3 -3
- package/src/lib/components/filters/FilterNumberRange.d.ts +3 -3
- package/src/lib/components/grid-header/GridHeader.d.ts +3 -3
- package/src/lib/components/grid-header/useGridHeaderStyles.d.ts +1 -1
- package/src/lib/components/index.d.ts +1 -0
- package/src/lib/components/pagination/Pagination.d.ts +3 -4
- package/src/lib/components/table/Table.d.ts +3 -4
- package/src/lib/components/tbody/TableBody.d.ts +6 -9
- package/src/lib/components/tbody/TableCell.d.ts +3 -3
- package/src/lib/components/tbody/TableRow.d.ts +7 -3
- package/src/lib/components/tbody/useTableBodyStyles.d.ts +1 -1
- package/src/lib/components/thead/HeaderCell.d.ts +3 -3
- package/src/lib/components/thead/HeaderRow.d.ts +3 -3
- package/src/lib/components/thead/TableHeader.d.ts +3 -3
- package/src/lib/components/thead/useTableHeaderStyles.d.ts +1 -1
- package/src/lib/components/useGridContainer.d.ts +2 -3
- package/src/lib/components/useSkipper.d.ts +1 -0
- package/src/lib/components/views/ViewSaveForm.d.ts +3 -3
- package/src/lib/components/views/ViewsDrawer.d.ts +4 -6
- package/src/lib/helpers/Helpers.d.ts +1 -1
- package/src/lib/helpers/StylesHelper.d.ts +4 -0
- package/src/lib/index.d.ts +13 -2
- package/src/lib/types/TableProps.d.ts +18 -2
- package/src/lib/types/TableRef.d.ts +2 -2
package/index.esm.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { makeStaticStyles, makeStyles, shorthands, tokens, useId, Dropdown, Option, Input, Button, Divider, Popover, PopoverTrigger, Tooltip, PopoverSurface, MenuGroupHeader, Checkbox, RadioGroup, Radio, Field, InlineDrawer, DrawerHeader, DrawerHeaderTitle, DrawerBody, Caption1Stronger, DrawerFooter, mergeClasses as mergeClasses$1, Menu, MenuTrigger, MenuButton, MenuPopover, MenuList, MenuGroup, MenuItem, MenuDivider, Skeleton, SkeletonItem, Subtitle2Stronger, MenuItemRadio } from '@fluentui/react-components';
|
|
4
|
+
import { makeStaticStyles, makeStyles, shorthands, tokens, useId, Dropdown, Option, Input, Button, Divider, Popover, PopoverTrigger, Tooltip, PopoverSurface, MenuGroupHeader, Checkbox, RadioGroup, Radio, Field, InlineDrawer, DrawerHeader, DrawerHeaderTitle, DrawerBody, Accordion, AccordionItem, AccordionHeader, Caption1Stronger, AccordionPanel, DrawerFooter, mergeClasses as mergeClasses$1, Menu, MenuTrigger, MenuButton, MenuPopover, MenuList, MenuGroup, MenuItem, MenuDivider, Skeleton, SkeletonItem, Subtitle2Stronger, MenuItemRadio } from '@fluentui/react-components';
|
|
5
|
+
import { Show, For, Switch, Case } from '@prt-ts/react-control-flow';
|
|
7
6
|
import { useReactTable, getCoreRowModel, getPaginationRowModel, getSortedRowModel, getFilteredRowModel, getGroupedRowModel, getExpandedRowModel, getFacetedUniqueValues, getFacetedMinMaxValues, flexRender } from '@tanstack/react-table';
|
|
8
7
|
export { createColumnHelper } from '@tanstack/react-table';
|
|
9
8
|
import { useVirtual } from 'react-virtual';
|
|
10
9
|
import { DatePicker } from '@fluentui/react-datepicker-compat';
|
|
10
|
+
import { useSortable, SortableContext, horizontalListSortingStrategy, arrayMove } from '@dnd-kit/sortable';
|
|
11
|
+
import { CSS } from '@dnd-kit/utilities';
|
|
12
|
+
import { useSensor, PointerSensor, MouseSensor, TouchSensor, KeyboardSensor, useSensors, DndContext, closestCenter } from '@dnd-kit/core';
|
|
13
|
+
import { restrictToHorizontalAxis } from '@dnd-kit/modifiers';
|
|
11
14
|
|
|
12
15
|
const useStaticStyles = makeStaticStyles({
|
|
13
16
|
"*": {
|
|
@@ -15,9 +18,11 @@ const useStaticStyles = makeStaticStyles({
|
|
|
15
18
|
},
|
|
16
19
|
});
|
|
17
20
|
const useTableStaticStyles = makeStyles({
|
|
18
|
-
tableContainer: Object.assign(Object.assign({
|
|
21
|
+
tableContainer: Object.assign(Object.assign({
|
|
22
|
+
// height: "650px",
|
|
23
|
+
width: "100%" }, shorthands.overflow("hidden", "auto")), {
|
|
19
24
|
/* width */
|
|
20
|
-
":hover": Object.assign({}, shorthands.overflow("auto", "auto")), "::-webkit-scrollbar": Object.assign({ width: "
|
|
25
|
+
":hover": Object.assign({}, shorthands.overflow("auto", "auto")), "::-webkit-scrollbar": Object.assign({ width: "8px", height: "4px" }, shorthands.borderRadius("50%")),
|
|
21
26
|
/* Track */
|
|
22
27
|
"::-webkit-scrollbar-track": {
|
|
23
28
|
"background-color": "#f1f1f1",
|
|
@@ -1001,6 +1006,7 @@ const GroupDismissFilled = /*#__PURE__*/createFluentIcon('GroupDismissFilled', "
|
|
|
1001
1006
|
const GroupListRegular = /*#__PURE__*/createFluentIcon('GroupListRegular', "1em", ["M2.5 3a.5.5 0 0 0-.5.5v5c0 .28.22.5.5.5h2a.5.5 0 0 0 0-1H3V4h1.5a.5.5 0 0 0 0-1h-2Zm0 8a.5.5 0 0 0-.5.5v5c0 .28.22.5.5.5h2a.5.5 0 0 0 0-1H3v-4h1.5a.5.5 0 0 0 0-1h-2ZM6 4.5c0-.28.22-.5.5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5Zm.5 7.5a.5.5 0 0 0 0 1h11a.5.5 0 0 0 0-1h-11ZM6 7.5c0-.28.22-.5.5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5Zm.5 7.5a.5.5 0 0 0 0 1h11a.5.5 0 0 0 0-1h-11Z"]);
|
|
1002
1007
|
const NextRegular = /*#__PURE__*/createFluentIcon('NextRegular', "1em", ["M17 3.5a.5.5 0 0 0-1 0v13a.5.5 0 1 0 1 0v-13ZM3 4.25c0-1 1.12-1.6 1.95-1.04l8.5 5.71c.73.5.73 1.57 0 2.07l-8.5 5.8A1.25 1.25 0 0 1 3 15.75V4.25Zm1.39-.2a.25.25 0 0 0-.39.2v11.5c0 .2.23.32.4.2l8.49-5.78a.25.25 0 0 0 0-.42l-8.5-5.7Z"]);
|
|
1003
1008
|
|
|
1009
|
+
const PinFilled = /*#__PURE__*/createFluentIcon('PinFilled', "1em", ["M13.33 2.62a2 2 0 0 0-3.2.52L8.38 6.6a1.5 1.5 0 0 1-.78.72L4 8.75a1 1 0 0 0-.33 1.64l2.61 2.6L3 16.3v.7h.7L7 13.72l2.61 2.6a1 1 0 0 0 1.64-.33l1.43-3.59c.14-.34.4-.62.72-.78l3.46-1.73a2 2 0 0 0 .52-3.2l-4.05-4.06Z"]);
|
|
1004
1010
|
const PinRegular = /*#__PURE__*/createFluentIcon('PinRegular', "1em", ["M10.12 3.14a2 2 0 0 1 3.2-.52l4.06 4.05a2 2 0 0 1-.52 3.2l-3.46 1.74a1.5 1.5 0 0 0-.72.78L11.25 16a1 1 0 0 1-1.64.33L7 13.7 3.7 17H3v-.7L6.3 13l-2.62-2.61a1 1 0 0 1 .34-1.64L7.6 7.32c.34-.14.62-.4.78-.72l1.73-3.46Zm2.5.18a1 1 0 0 0-1.6.26L9.29 7.04a2.5 2.5 0 0 1-1.31 1.2L4.39 9.69l5.93 5.93 1.43-3.59a2.5 2.5 0 0 1 1.2-1.3l3.46-1.74a1 1 0 0 0 .26-1.6l-4.05-4.06Z"]);
|
|
1005
1011
|
const PinOffRegular = /*#__PURE__*/createFluentIcon('PinOffRegular', "1em", ["M2.85 2.15a.5.5 0 1 0-.7.7L6.9 7.6 4.02 8.75a1 1 0 0 0-.34 1.64L6.3 13 3 16.3v.7h.7L7 13.7l2.61 2.62a1 1 0 0 0 1.64-.34l1.15-2.88 4.75 4.75a.5.5 0 0 0 .7-.7l-15-15Zm8.78 10.18-1.31 3.28-5.93-5.93 3.28-1.3 3.96 3.95Zm1.33-1.62-.08.04.74.75 3.24-1.62a2 2 0 0 0 .52-3.2l-4.05-4.06a2 2 0 0 0-3.2.52L8.5 6.38l.75.74.04-.08 1.73-3.45a1 1 0 0 1 1.6-.26l4.05 4.05a1 1 0 0 1-.26 1.6l-3.45 1.73Z"]);
|
|
1006
1012
|
const PreviousRegular = /*#__PURE__*/createFluentIcon('PreviousRegular', "1em", ["M3 3.5a.5.5 0 0 1 1 0v13a.5.5 0 0 1-1 0v-13Zm14 .75c0-1-1.12-1.6-1.95-1.04l-8.5 5.71c-.73.5-.73 1.57 0 2.07l8.5 5.8c.83.56 1.95-.03 1.95-1.04V4.25Zm-1.39-.2c.17-.12.39 0 .39.2v11.5c0 .2-.22.32-.4.2l-8.49-5.78a.25.25 0 0 1 0-.42l8.5-5.7Z"]);
|
|
@@ -1073,7 +1079,8 @@ const range = (from, to, step = 1) => {
|
|
|
1073
1079
|
};
|
|
1074
1080
|
const DEFAULT_NUMBER_OF_PAGE_BTN = 5;
|
|
1075
1081
|
const Pagination = (props) => {
|
|
1076
|
-
const { table
|
|
1082
|
+
const { table } = props;
|
|
1083
|
+
const { pageSizeOptions } = table.options.meta || {};
|
|
1077
1084
|
const pageSizeSelectionId = useId("page-size-selector");
|
|
1078
1085
|
const styles = usePaginationStyle();
|
|
1079
1086
|
const totalNumberOfPage = table.getPageCount();
|
|
@@ -1096,12 +1103,12 @@ const Pagination = (props) => {
|
|
|
1096
1103
|
const currentPageOptions = end - start >= 0 ? range(start, end) : [];
|
|
1097
1104
|
return (currentPageOptions === null || currentPageOptions === void 0 ? void 0 : currentPageOptions.length) ? [...currentPageOptions] : [1];
|
|
1098
1105
|
}, [totalNumberOfPage, currentPage]);
|
|
1099
|
-
return (jsx("div", { className: styles.paginationContainer, children: jsxs("div", { className: styles.wrapper, children: [jsx("div", { className: styles.pageSelectionWrapper, children: jsx(Dropdown, { id: pageSizeSelectionId, size: "small", selectedOptions: [`${pageSize}`], placeholder: "Select Page Size", value: table.getState().pagination.pageSize.toString(), onOptionSelect: (_, data) => { var _a; return table.setPageSize(Number(+((_a = data.selectedOptions) === null || _a === void 0 ? void 0 : _a[0]))); }, className: styles.pageSelectionDropdown, "aria-label": "Select Page Size", children:
|
|
1106
|
+
return (jsx("div", { className: styles.paginationContainer, children: jsxs("div", { className: styles.wrapper, children: [jsx("div", { className: styles.pageSelectionWrapper, children: jsx(Dropdown, { id: pageSizeSelectionId, size: "small", selectedOptions: [`${pageSize}`], placeholder: "Select Page Size", value: table.getState().pagination.pageSize.toString(), onOptionSelect: (_, data) => { var _a; return table.setPageSize(Number(+((_a = data.selectedOptions) === null || _a === void 0 ? void 0 : _a[0]))); }, className: styles.pageSelectionDropdown, "aria-label": "Select Page Size", children: jsx(Show, { when: (pageSelectionOptions === null || pageSelectionOptions === void 0 ? void 0 : pageSelectionOptions.length) > 0, children: jsx(For, { each: pageSizeOptions, children: (option) => (jsx(Option, { value: `${option}`, children: `${option}` }, option)) }) }) }) }), jsxs("div", { className: styles.pageBtnContainer, children: [jsxs("div", { children: [jsxs("span", { children: ["Page", " ", jsxs("strong", { children: [table.getState().pagination.pageIndex + 1, " of", " ", table.getPageCount()] })] }), jsxs("span", { children: [" ", "| Go to page:", " ", jsx(Input, { type: "number", size: "small", value: `${table.getState().pagination.pageIndex + 1}`, onChange: (e, data) => {
|
|
1100
1107
|
const page = data.value ? Number(e.target.value) - 1 : 0;
|
|
1101
1108
|
if (page >= 0 && page < table.getPageCount()) {
|
|
1102
1109
|
table.setPageIndex(page);
|
|
1103
1110
|
}
|
|
1104
|
-
}, className: styles.pageSizeInput, "aria-label": "Page Number", autoComplete: "off", autoCorrect: "off" })] })] }), jsx(Button, { size: "small", className: styles.pageBtn, shape: "circular", onClick: () => table.setPageIndex(0), disabled: !table.getCanPreviousPage(), icon: jsx(PreviousRegular, {}), "aria-label": "Go to first page" }), jsx(Button, { size: "small", className: styles.pageBtn, shape: "circular", onClick: () => table.previousPage(), disabled: !table.getCanPreviousPage(), icon: jsx(ArrowPreviousFilled, {}), "aria-label": "Go to previous page" }),
|
|
1111
|
+
}, className: styles.pageSizeInput, "aria-label": "Page Number", autoComplete: "off", autoCorrect: "off" })] })] }), jsx(Button, { size: "small", className: styles.pageBtn, shape: "circular", onClick: () => table.setPageIndex(0), disabled: !table.getCanPreviousPage(), icon: jsx(PreviousRegular, {}), "aria-label": "Go to first page" }), jsx(Button, { size: "small", className: styles.pageBtn, shape: "circular", onClick: () => table.previousPage(), disabled: !table.getCanPreviousPage(), icon: jsx(ArrowPreviousFilled, {}), "aria-label": "Go to previous page" }), jsx(For, { each: pageSelectionOptions, children: (option, index) => (jsx(Button, { shape: "circular", appearance: option - 1 === currentPage ? "primary" : undefined, onClick: () => table.setPageIndex(option - 1), "aria-label": `Show Page ${option}`, size: "small", className: styles.pageBtn, children: option }, index)) }), jsx(Button, { size: "small", className: styles.pageBtn, shape: "circular", onClick: () => table.nextPage(), disabled: !table.getCanNextPage(), icon: jsx(ArrowNextFilled, {}), "aria-label": "Go to next page" }), jsx(Button, { size: "small", shape: "circular", className: styles.pageBtn, onClick: () => table.setPageIndex(table.getPageCount() - 1), disabled: !table.getCanNextPage(), icon: jsx(NextRegular, {}), "aria-label": "Go to last page" })] })] }) }));
|
|
1105
1112
|
};
|
|
1106
1113
|
|
|
1107
1114
|
bundleIcon$1(SaveFilled, SaveRegular);
|
|
@@ -1130,18 +1137,21 @@ const useGridHeaderStyles = makeStyles({
|
|
|
1130
1137
|
width: "100%",
|
|
1131
1138
|
height: "100%",
|
|
1132
1139
|
},
|
|
1140
|
+
popoverSurface: {
|
|
1141
|
+
minWidth: "300px"
|
|
1142
|
+
}
|
|
1133
1143
|
});
|
|
1134
1144
|
|
|
1135
1145
|
const GridHeader = (props) => {
|
|
1136
1146
|
const { table, gridTitle, globalFilter, setGlobalFilter, dispatch, drawerState } = props;
|
|
1137
1147
|
const styles = useGridHeaderStyles();
|
|
1138
|
-
return (jsxs("div", { className: styles.tableTopHeaderContainer, children: [jsx("div", { className: styles.tableTopHeaderLeft, children: gridTitle }), jsxs("div", { className: styles.tableTopHeaderRight, children: [props.headerMenu, props.headerMenu && jsx(Divider, { vertical: true }), jsxs(Popover, { withArrow: true, children: [jsx(PopoverTrigger, { disableButtonEnhancement: true, children: jsx(Tooltip, { content: 'Toggle Group Column', relationship: "label", children: jsx(Button, { icon: jsx(ToggleGroupColumnIcon, {}), "aria-label": "Toggle Group Column" }) }) }), jsx(PopoverSurface, { children: jsxs("div", { className: styles.tableTopHeaderColumnTogglePopover, children: [jsx(MenuGroupHeader, { children: "Group Columns" }), table.getAllLeafColumns().map((column) => {
|
|
1148
|
+
return (jsxs("div", { className: styles.tableTopHeaderContainer, children: [jsx("div", { className: styles.tableTopHeaderLeft, children: gridTitle }), jsxs("div", { className: styles.tableTopHeaderRight, children: [props.headerMenu, props.headerMenu && jsx(Divider, { vertical: true }), jsxs(Popover, { withArrow: true, children: [jsx(PopoverTrigger, { disableButtonEnhancement: true, children: jsx(Tooltip, { content: 'Toggle Group Column', relationship: "label", children: jsx(Button, { icon: jsx(ToggleGroupColumnIcon, {}), "aria-label": "Toggle Group Column" }) }) }), jsx(PopoverSurface, { className: styles.popoverSurface, children: jsxs("div", { className: styles.tableTopHeaderColumnTogglePopover, children: [jsx(MenuGroupHeader, { children: "Group Columns" }), table.getAllLeafColumns().map((column) => {
|
|
1139
1149
|
if (column.id === 'select')
|
|
1140
1150
|
return null;
|
|
1141
1151
|
if (column.id === 'id')
|
|
1142
1152
|
return null;
|
|
1143
1153
|
return (jsx(Checkbox, { checked: column.getIsGrouped(), onChange: column.getToggleGroupingHandler(), disabled: !column.getCanGroup() || !column.getIsVisible(), label: jsx("span", { children: column.columnDef.id }) }, column.id));
|
|
1144
|
-
})] }) })] }), jsxs(Popover, { withArrow: true, children: [jsx(PopoverTrigger, { disableButtonEnhancement: true, children: jsx(Tooltip, { content: 'Toggle Column Visibility', relationship: "label", children: jsx(Button, { icon: jsx(ToggleSelectColumnIcon, {}), "aria-label": "Toggle Column Visibility" }) }) }), jsx(PopoverSurface, { children: jsxs("div", { className: styles.tableTopHeaderColumnTogglePopover, children: [jsx(MenuGroupHeader, { children: "Toggle Columns" }), jsx(Checkbox, { checked: table.getIsAllColumnsVisible(), onChange: table.getToggleAllColumnsVisibilityHandler(), label: 'Toggle All' }), jsx(Divider, {}), table.getAllLeafColumns().map((column) => {
|
|
1154
|
+
})] }) })] }), jsxs(Popover, { withArrow: true, children: [jsx(PopoverTrigger, { disableButtonEnhancement: true, children: jsx(Tooltip, { content: 'Toggle Column Visibility', relationship: "label", children: jsx(Button, { icon: jsx(ToggleSelectColumnIcon, {}), "aria-label": "Toggle Column Visibility" }) }) }), jsx(PopoverSurface, { className: styles.popoverSurface, children: jsxs("div", { className: styles.tableTopHeaderColumnTogglePopover, children: [jsx(MenuGroupHeader, { children: "Toggle Columns" }), jsx(Checkbox, { checked: table.getIsAllColumnsVisible(), onChange: table.getToggleAllColumnsVisibilityHandler(), label: 'Toggle All' }), jsx(Divider, {}), table.getAllLeafColumns().map((column) => {
|
|
1145
1155
|
if (column.id === 'select')
|
|
1146
1156
|
return null;
|
|
1147
1157
|
return (jsx(Checkbox, { checked: column.getIsVisible(), onChange: column.getToggleVisibilityHandler(), label: column.id, disabled: !column.getCanHide() }, column.id));
|
|
@@ -1225,8 +1235,8 @@ const getLeafColumns = (columns) => {
|
|
|
1225
1235
|
};
|
|
1226
1236
|
|
|
1227
1237
|
const useGridContainer = (props, ref) => {
|
|
1228
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1229
|
-
const { columns, data, rowSelectionMode } = props;
|
|
1238
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
1239
|
+
const { defaultColumn, columns, data, rowSelectionMode, autoResetPageIndex, onUpdateData } = props;
|
|
1230
1240
|
const [pagination, setPagination] = React.useState({
|
|
1231
1241
|
pageSize: props.pageSize || 10,
|
|
1232
1242
|
pageIndex: 0,
|
|
@@ -1247,7 +1257,12 @@ const useGridContainer = (props, ref) => {
|
|
|
1247
1257
|
const [expanded, setExpanded] = React.useState((_g = props.expandedState) !== null && _g !== void 0 ? _g : {});
|
|
1248
1258
|
const [columnPinning, setColumnPinning] = React.useState((_h = props.columnPinningState) !== null && _h !== void 0 ? _h : {});
|
|
1249
1259
|
const [columnSizing, setColumnSizing] = React.useState({});
|
|
1260
|
+
const [rowPinning, setRowPinning] = React.useState((_j = props.rowPinningState) !== null && _j !== void 0 ? _j : {
|
|
1261
|
+
top: [],
|
|
1262
|
+
bottom: [],
|
|
1263
|
+
});
|
|
1250
1264
|
const table = useReactTable({
|
|
1265
|
+
defaultColumn,
|
|
1251
1266
|
columns: columns,
|
|
1252
1267
|
data,
|
|
1253
1268
|
filterFns: {
|
|
@@ -1270,6 +1285,11 @@ const useGridContainer = (props, ref) => {
|
|
|
1270
1285
|
columnVisibility,
|
|
1271
1286
|
columnPinning,
|
|
1272
1287
|
columnSizing,
|
|
1288
|
+
rowPinning
|
|
1289
|
+
},
|
|
1290
|
+
getRowId(originalRow, index, parent) {
|
|
1291
|
+
const keyProps = props.dataPrimaryKye || 'id';
|
|
1292
|
+
return originalRow[keyProps] || `${index}`;
|
|
1273
1293
|
},
|
|
1274
1294
|
columnResizeMode: 'onChange',
|
|
1275
1295
|
enableRowSelection: rowSelectionMode !== undefined,
|
|
@@ -1279,6 +1299,8 @@ const useGridContainer = (props, ref) => {
|
|
|
1279
1299
|
enableColumnFilters: true,
|
|
1280
1300
|
filterFromLeafRows: true,
|
|
1281
1301
|
autoResetExpanded: false,
|
|
1302
|
+
autoResetPageIndex: autoResetPageIndex,
|
|
1303
|
+
keepPinnedRows: true,
|
|
1282
1304
|
onRowSelectionChange: setRowSelection,
|
|
1283
1305
|
onPaginationChange: setPagination,
|
|
1284
1306
|
onSortingChange: setSorting,
|
|
@@ -1290,6 +1312,7 @@ const useGridContainer = (props, ref) => {
|
|
|
1290
1312
|
onColumnVisibilityChange: setColumnVisibility,
|
|
1291
1313
|
onColumnPinningChange: setColumnPinning,
|
|
1292
1314
|
onColumnSizingChange: setColumnSizing,
|
|
1315
|
+
onRowPinningChange: setRowPinning,
|
|
1293
1316
|
getCoreRowModel: getCoreRowModel(),
|
|
1294
1317
|
getPaginationRowModel: getPaginationRowModel(),
|
|
1295
1318
|
getSortedRowModel: getSortedRowModel(),
|
|
@@ -1298,10 +1321,18 @@ const useGridContainer = (props, ref) => {
|
|
|
1298
1321
|
getExpandedRowModel: getExpandedRowModel(),
|
|
1299
1322
|
getFacetedUniqueValues: getFacetedUniqueValues(),
|
|
1300
1323
|
getFacetedMinMaxValues: getFacetedMinMaxValues(),
|
|
1324
|
+
meta: {
|
|
1325
|
+
pageSizeOptions: props.pageSizeOptions || [10, 20, 50, 100, 1000],
|
|
1326
|
+
rowSelectionMode: props.rowSelectionMode,
|
|
1327
|
+
tableHeight: props.tableHeight || "650px",
|
|
1328
|
+
updateData: onUpdateData,
|
|
1329
|
+
onTableViewDelete: props.onTableViewDelete,
|
|
1330
|
+
onTableViewSave: props.onTableViewSave
|
|
1331
|
+
}
|
|
1301
1332
|
});
|
|
1302
1333
|
const tableViews = React.useMemo(() => { var _a; return (_a = props.views) !== null && _a !== void 0 ? _a : []; }, [props.views]);
|
|
1303
1334
|
const resetToDefaultView = () => {
|
|
1304
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1335
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
1305
1336
|
const defaultTableState = {
|
|
1306
1337
|
pagination: {
|
|
1307
1338
|
pageSize: props.pageSize || 10,
|
|
@@ -1323,7 +1354,7 @@ const useGridContainer = (props, ref) => {
|
|
|
1323
1354
|
columnVisibility: (_g = props.columnVisibility) !== null && _g !== void 0 ? _g : {},
|
|
1324
1355
|
columnPinning: (_h = props.columnPinningState) !== null && _h !== void 0 ? _h : {},
|
|
1325
1356
|
columnSizing: {},
|
|
1326
|
-
rowPinning: {},
|
|
1357
|
+
rowPinning: (_j = props.rowPinningState) !== null && _j !== void 0 ? _j : {},
|
|
1327
1358
|
columnSizingInfo: {
|
|
1328
1359
|
"startOffset": null,
|
|
1329
1360
|
"startSize": null,
|
|
@@ -1356,6 +1387,7 @@ const useGridContainer = (props, ref) => {
|
|
|
1356
1387
|
pageSize: props.pageSize || 10,
|
|
1357
1388
|
pageIndex: 0,
|
|
1358
1389
|
});
|
|
1390
|
+
setRowPinning(tableState.rowPinning);
|
|
1359
1391
|
}, 10);
|
|
1360
1392
|
return true;
|
|
1361
1393
|
}
|
|
@@ -1421,10 +1453,11 @@ const useTableHeaderStyles = makeStyles({
|
|
|
1421
1453
|
boxShadow: tokens.shadow2,
|
|
1422
1454
|
},
|
|
1423
1455
|
tHeadRow: {
|
|
1424
|
-
backgroundColor: tokens.
|
|
1456
|
+
backgroundColor: tokens.colorNeutralCardBackgroundSelected,
|
|
1425
1457
|
},
|
|
1426
1458
|
tHeadCell: Object.assign({ zIndex: 99, position: 'relative', fontSize: tokens.fontSizeBase300, fontWeight: tokens.fontWeightBold, minWidth: '1rem' }, shorthands.padding('2px', '4px')),
|
|
1427
|
-
tHeadNonLeafCell: Object.assign({}, shorthands.borderBottom(
|
|
1459
|
+
tHeadNonLeafCell: Object.assign({}, shorthands.borderBottom(0)),
|
|
1460
|
+
tHeadNonLeafCellFakeBorder: Object.assign({ width: '100%', height: '1px', position: "sticky", bottom: 0 }, shorthands.borderBottom('1px', 'solid', tokens.colorBrandBackgroundInverted)),
|
|
1428
1461
|
tHeadCellDraggable: {
|
|
1429
1462
|
height: '100%',
|
|
1430
1463
|
cursor: 'grab',
|
|
@@ -1433,18 +1466,18 @@ const useTableHeaderStyles = makeStyles({
|
|
|
1433
1466
|
opacity: 0.5,
|
|
1434
1467
|
cursor: 'grabbing',
|
|
1435
1468
|
},
|
|
1436
|
-
tHeadCellOver: Object.assign({ backgroundColor: tokens.colorNeutralStroke1 }, shorthands.border(tokens.strokeWidthThin, 'dashed', tokens.
|
|
1469
|
+
tHeadCellOver: Object.assign({ backgroundColor: tokens.colorNeutralStroke1 }, shorthands.border(tokens.strokeWidthThin, 'dashed', tokens.colorNeutralBackground2Pressed)),
|
|
1437
1470
|
tLeafHeadCellContent: Object.assign({ display: 'flex', alignContent: 'space-between', alignItems: 'center', justifyContent: 'space-between', cursor: 'pointer', width: '100%', height: '100%', minWidth: '1rem' }, shorthands.padding('3px', '4px')),
|
|
1438
1471
|
tNonLeafHeadCellContent: Object.assign({ display: 'flex', alignContent: 'center', alignItems: 'center', justifyContent: 'center', cursor: 'pointer', width: '100%', minWidth: '1rem' }, shorthands.padding('3px', '4px')),
|
|
1439
1472
|
tHeadContentBtn: Object.assign(Object.assign(Object.assign(Object.assign({}, shorthands.padding('0px', '0px', '0px', '0px')), { display: 'flex' }), shorthands.gap('5px')), { alignContent: 'space-between', alignItems: 'center', justifyContent: 'space-between', cursor: 'pointer', width: '100%', height: '100%', minWidth: '1rem' }),
|
|
1440
1473
|
tHeadMenuPopover: Object.assign(Object.assign({}, shorthands.padding('0px', '0px', '0px', '0px')), { width: '300px' }),
|
|
1441
|
-
resizer: Object.assign(Object.assign({}, shorthands.borderRight('1px', 'solid', tokens.
|
|
1442
|
-
borderRightWidth: '
|
|
1443
|
-
borderRightColor: tokens.
|
|
1474
|
+
resizer: Object.assign(Object.assign({}, shorthands.borderRight('1px', 'solid', tokens.colorBrandBackgroundInverted)), { width: '8px', position: 'absolute', top: 0, right: 0, bottom: 0, cursor: 'col-resize', resize: 'horizontal', ':hover': {
|
|
1475
|
+
borderRightWidth: '2px',
|
|
1476
|
+
borderRightColor: tokens.colorBrandBackgroundInvertedHover,
|
|
1444
1477
|
} }),
|
|
1445
1478
|
resizerActive: {
|
|
1446
|
-
borderRightWidth: '
|
|
1447
|
-
borderRightColor: tokens.
|
|
1479
|
+
borderRightWidth: '2px',
|
|
1480
|
+
borderRightColor: tokens.colorBrandBackgroundInvertedPressed,
|
|
1448
1481
|
},
|
|
1449
1482
|
});
|
|
1450
1483
|
|
|
@@ -1788,75 +1821,102 @@ const FilterDrawer = ({ drawerState, dispatch, table }) => {
|
|
|
1788
1821
|
table.setGlobalFilter('');
|
|
1789
1822
|
table.resetColumnFilters();
|
|
1790
1823
|
}, [table]);
|
|
1791
|
-
return (jsxs(InlineDrawer, { position: "end", open: drawerState.isFilterDrawerOpen, separator: true, children: [jsx(DrawerHeader, { children: jsx(DrawerHeaderTitle, { action: jsx(Button, { appearance: "subtle", "aria-label": "Close", icon: jsx(Dismiss24Regular, {}), onClick: () => dispatch({ type: "CLOSE_FILTER_DRAWER" }) }), children: "Advanced Filters" }) }), jsx(DrawerBody, { className: styles.drawerBody, children: headerGroups.map((headerGroup) => {
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
return null;
|
|
1795
|
-
return headerGroup.headers.map((header) => {
|
|
1796
|
-
const canFilter = header.column.getCanFilter();
|
|
1797
|
-
if (!canFilter)
|
|
1824
|
+
return (jsxs(InlineDrawer, { position: "end", open: drawerState.isFilterDrawerOpen, separator: true, children: [jsx(DrawerHeader, { children: jsx(DrawerHeaderTitle, { action: jsx(Button, { appearance: "subtle", "aria-label": "Close", icon: jsx(Dismiss24Regular, {}), onClick: () => dispatch({ type: "CLOSE_FILTER_DRAWER" }) }), children: "Advanced Filters" }) }), jsx(DrawerBody, { className: styles.drawerBody, children: jsx(Accordion, { multiple: true, collapsible: true, children: headerGroups.map((headerGroup) => {
|
|
1825
|
+
const canApplyFilter = headerGroup.depth === (headerGroups === null || headerGroups === void 0 ? void 0 : headerGroups.length) - 1;
|
|
1826
|
+
if (!canApplyFilter)
|
|
1798
1827
|
return null;
|
|
1799
|
-
return (
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1828
|
+
return headerGroup.headers.map((header) => {
|
|
1829
|
+
const canFilter = header.column.getCanFilter();
|
|
1830
|
+
if (!canFilter)
|
|
1831
|
+
return null;
|
|
1832
|
+
return (jsx(Show, { when: header.column.getCanFilter(), children: jsxs(AccordionItem, { value: header.column.id, children: [jsx(AccordionHeader, { expandIconPosition: 'end', children: jsxs(Caption1Stronger, { children: ["Filter by", ' ', flexRender(header.column.columnDef.header, header.getContext())] }) }), jsx(AccordionPanel, { children: jsx(Filter, { column: header.column, table: table }) })] }, header.column.id) }, header.column.id));
|
|
1833
|
+
});
|
|
1834
|
+
}) }) }), jsx(DrawerFooter, { children: jsx(Button, { icon: jsx(ClearFilterIcon, {}), onClick: resetAllFilters, style: { width: "100%" }, children: "Clear All Filters" }) })] }));
|
|
1835
|
+
};
|
|
1836
|
+
|
|
1837
|
+
const getHeaderCellPinningStyles = (column) => {
|
|
1838
|
+
const isPinned = column.getIsPinned();
|
|
1839
|
+
const isLastLeftPinnedColumn = isPinned === 'left' && column.getIsLastColumn('left');
|
|
1840
|
+
const isFirstRightPinnedColumn = isPinned === 'right' && column.getIsFirstColumn('right');
|
|
1841
|
+
const styles = {
|
|
1842
|
+
boxShadow: isLastLeftPinnedColumn
|
|
1843
|
+
? '-4px 0 4px -4px gray inset'
|
|
1844
|
+
: isFirstRightPinnedColumn
|
|
1845
|
+
? '4px 0 4px -4px gray inset'
|
|
1846
|
+
: undefined,
|
|
1847
|
+
left: isPinned === 'left' ? `${column.getStart('left')}px` : undefined,
|
|
1848
|
+
right: isPinned === 'right' ? `${column.getAfter('right')}px` : undefined,
|
|
1849
|
+
opacity: isPinned ? 0.95 : 1,
|
|
1850
|
+
position: isPinned ? 'sticky' : 'relative',
|
|
1851
|
+
width: column.getSize(),
|
|
1852
|
+
zIndex: isPinned ? 99 : 1,
|
|
1853
|
+
backgroundColor: tokens.colorNeutralCardBackgroundSelected,
|
|
1854
|
+
};
|
|
1855
|
+
return styles;
|
|
1856
|
+
};
|
|
1857
|
+
const getBodyCellPinningStyles = (column) => {
|
|
1858
|
+
const isPinned = column.getIsPinned();
|
|
1859
|
+
const isLastLeftPinnedColumn = isPinned === 'left' && column.getIsLastColumn('left');
|
|
1860
|
+
const isFirstRightPinnedColumn = isPinned === 'right' && column.getIsFirstColumn('right');
|
|
1861
|
+
const styles = {
|
|
1862
|
+
boxShadow: isLastLeftPinnedColumn
|
|
1863
|
+
? '-4px 0 4px -4px gray inset'
|
|
1864
|
+
: isFirstRightPinnedColumn
|
|
1865
|
+
? '4px 0 4px -4px gray inset'
|
|
1866
|
+
: undefined,
|
|
1867
|
+
left: isPinned === 'left' ? `${column.getStart('left')}px` : undefined,
|
|
1868
|
+
right: isPinned === 'right' ? `${column.getAfter('right')}px` : undefined,
|
|
1869
|
+
opacity: isPinned ? 0.95 : 1,
|
|
1870
|
+
position: isPinned ? 'sticky' : 'relative',
|
|
1871
|
+
width: column.getSize(),
|
|
1872
|
+
zIndex: isPinned ? 1 : 0,
|
|
1873
|
+
};
|
|
1874
|
+
return styles;
|
|
1804
1875
|
};
|
|
1805
1876
|
|
|
1806
1877
|
const SortAscIcon = bundleIcon$1(ArrowSortDown20Filled, ArrowSortDown20Regular);
|
|
1807
1878
|
const SortDescIcon = bundleIcon$1(ArrowSortUp20Filled, ArrowSortUp20Regular);
|
|
1808
|
-
const
|
|
1809
|
-
columnOrder.splice(columnOrder.indexOf(targetColumnId), 0, columnOrder.splice(columnOrder.indexOf(draggedColumnId), 1)[0]);
|
|
1810
|
-
return [...columnOrder];
|
|
1811
|
-
};
|
|
1879
|
+
const PinIcon = bundleIcon$1(PinFilled, PinRegular);
|
|
1812
1880
|
function HeaderCell({ header, table, hideMenu, headerDepth, totalNumberOfHeaderDepth, }) {
|
|
1813
1881
|
var _a;
|
|
1814
|
-
const { getState, setColumnOrder } = table;
|
|
1815
|
-
const { columnOrder } = getState();
|
|
1816
1882
|
const { column } = header;
|
|
1817
|
-
const
|
|
1818
|
-
|
|
1819
|
-
drop: (draggedColumn) => {
|
|
1820
|
-
const newColumnOrder = reorderColumn(draggedColumn.id, column.id, columnOrder);
|
|
1821
|
-
setColumnOrder(newColumnOrder);
|
|
1822
|
-
},
|
|
1823
|
-
collect: (monitor) => ({
|
|
1824
|
-
isOver: monitor.isOver(),
|
|
1825
|
-
}),
|
|
1826
|
-
});
|
|
1827
|
-
const [{ isDragging }, dragRef, previewRef] = useDrag({
|
|
1828
|
-
collect: (monitor) => ({
|
|
1829
|
-
isDragging: monitor.isDragging(),
|
|
1830
|
-
}),
|
|
1831
|
-
item: () => column,
|
|
1832
|
-
type: "column",
|
|
1883
|
+
const { isDragging, attributes, listeners, setNodeRef, transform, transition, } = useSortable({
|
|
1884
|
+
id: column.id
|
|
1833
1885
|
});
|
|
1886
|
+
const dndStyle = {
|
|
1887
|
+
width: header.column.getSize(),
|
|
1888
|
+
opacity: isDragging ? 0.8 : 1,
|
|
1889
|
+
// position: isDragging ? 'relative' : "sticky",
|
|
1890
|
+
transform: CSS.Translate.toString(transform), // translate instead of transform to avoid squishing
|
|
1891
|
+
// transition: 'width transform 0.2s ease-in-out',
|
|
1892
|
+
whiteSpace: 'wrap',
|
|
1893
|
+
zIndex: isDragging ? 100 : 99,
|
|
1894
|
+
transition
|
|
1895
|
+
};
|
|
1834
1896
|
const styles = useTableHeaderStyles();
|
|
1835
|
-
const canDragDrop = headerDepth === totalNumberOfHeaderDepth && !header.isPlaceholder;
|
|
1836
1897
|
const isLeafHeaders = headerDepth === totalNumberOfHeaderDepth;
|
|
1837
1898
|
if (header.isPlaceholder) {
|
|
1838
|
-
return (jsx("th", { colSpan: header.colSpan, className: styles.tHeadCell, children: header.column.getCanResize()
|
|
1899
|
+
return (jsx("th", { colSpan: header.colSpan, className: styles.tHeadCell, style: Object.assign(Object.assign({}, dndStyle), getHeaderCellPinningStyles(column)), ref: setNodeRef, children: jsx(Show, { when: header.column.getCanResize(), children: jsx("div", { onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler(), className: mergeClasses$1(styles.resizer, column.getIsResizing() && styles.resizerActive) }) }) }));
|
|
1839
1900
|
}
|
|
1840
|
-
return (jsxs("th", { colSpan: header.colSpan, className: mergeClasses$1(styles.tHeadCell, isLeafHeaders
|
|
1841
|
-
: styles.tHeadNonLeafCell, isDragging && styles.tHeadCellDragging, isOver && isLeafHeaders && styles.tHeadCellOver), children: [jsx("div", { className: styles.tHeadCellDraggable, ref: canDragDrop ? dropRef : undefined, children: jsxs("div", { className: isLeafHeaders
|
|
1901
|
+
return (jsxs("th", { colSpan: header.colSpan, className: mergeClasses$1(styles.tHeadCell, isLeafHeaders && styles.tHeadNonLeafCell, isDragging && styles.tHeadCellDragging), style: Object.assign(Object.assign({}, dndStyle), getHeaderCellPinningStyles(column)), ref: setNodeRef, children: [jsx("div", Object.assign({ className: styles.tHeadCellDraggable }, attributes, listeners, { children: jsxs("div", { className: isLeafHeaders
|
|
1842
1902
|
? styles.tLeafHeadCellContent
|
|
1843
|
-
: styles.tNonLeafHeadCellContent,
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1903
|
+
: styles.tNonLeafHeadCellContent, children: [jsx("div", { children: jsx(Show, { when: !header.isPlaceholder, children: jsxs(Button, { style: {
|
|
1904
|
+
display: 'flex',
|
|
1905
|
+
alignItems: 'center',
|
|
1906
|
+
justifyContent: 'left',
|
|
1907
|
+
flex: 1,
|
|
1908
|
+
}, onClick: (e) => {
|
|
1909
|
+
if (!header.column.getCanSort())
|
|
1910
|
+
return;
|
|
1911
|
+
header.column.toggleSorting(header.column.getIsSorted() === 'asc', e.ctrlKey);
|
|
1912
|
+
}, onDoubleClick: () => {
|
|
1913
|
+
if (!header.column.getCanGroup())
|
|
1914
|
+
return;
|
|
1915
|
+
header.column.getToggleGroupingHandler()();
|
|
1916
|
+
}, appearance: "transparent", className: styles.tHeadContentBtn, icon: (_a = {
|
|
1917
|
+
asc: (jsx("strong", { children: jsx(SortAscIcon, {}) })),
|
|
1918
|
+
desc: (jsx("strong", { children: jsx(SortDescIcon, {}) })),
|
|
1919
|
+
}[header.column.getIsSorted()]) !== null && _a !== void 0 ? _a : undefined, iconPosition: "after", children: [jsx("strong", { children: flexRender(header.column.columnDef.header, header.getContext()) }), jsx(Show, { when: header.column.getIsGrouped(), children: jsx("strong", { children: jsx(GroupListRegular, {}) }) }), jsx(Show, { when: header.column.getIsFiltered(), children: jsx("strong", { children: jsx(FilterFilled, {}) }) }), jsx(Show, { when: header.column.getIsPinned(), children: jsx("strong", { children: jsx(PinRegular, {}) }) })] }) }) }), jsx(HeaderMenu, { header: header, table: table, hideMenu: hideMenu })] }) })), jsx(Show, { when: header.column.getCanResize(), children: jsx("div", { onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler(), className: mergeClasses$1(styles.resizer, column.getIsResizing() && styles.resizerActive) }) }), jsx(Show, { when: !isLeafHeaders, children: jsx("div", { className: styles.tHeadNonLeafCellFakeBorder }) })] }));
|
|
1860
1920
|
}
|
|
1861
1921
|
function HeaderMenu(props) {
|
|
1862
1922
|
const { header, table, hideMenu } = props;
|
|
@@ -1868,24 +1928,24 @@ function HeaderMenu(props) {
|
|
|
1868
1928
|
header.column.getCanFilter();
|
|
1869
1929
|
if (!canHavePopOver)
|
|
1870
1930
|
return (jsx(Fragment, { children: " " }));
|
|
1871
|
-
return (jsxs(Menu, { children: [jsx(MenuTrigger, { disableButtonEnhancement: true, children: jsx(MenuButton, { appearance: "transparent", "aria-label": "View Column Actions" }) }), jsx(MenuPopover, { className: styles.tHeadMenuPopover, children: jsxs(MenuList, { children: [header.column.getCanSort()
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1931
|
+
return (jsxs(Menu, { children: [jsx(MenuTrigger, { disableButtonEnhancement: true, children: jsx(MenuButton, { appearance: "transparent", "aria-label": "View Column Actions" }) }), jsx(MenuPopover, { className: styles.tHeadMenuPopover, children: jsxs(MenuList, { children: [jsx(Show, { when: header.column.getCanSort(), children: jsxs(MenuGroup, { children: [jsx(MenuItem, { onClick: (e) => {
|
|
1932
|
+
var _a;
|
|
1933
|
+
const isControlKeySelected = e.ctrlKey;
|
|
1934
|
+
(_a = header.column) === null || _a === void 0 ? void 0 : _a.toggleSorting(false, isControlKeySelected);
|
|
1935
|
+
}, icon: jsx(TextSortAscendingFilled, {}), disabled: header.column.getIsSorted() === 'asc', children: "Sort A to Z" }), jsx(MenuItem, { onClick: (e) => {
|
|
1936
|
+
var _a;
|
|
1937
|
+
const isControlKeySelected = e.ctrlKey;
|
|
1938
|
+
(_a = header.column) === null || _a === void 0 ? void 0 : _a.toggleSorting(true, isControlKeySelected);
|
|
1939
|
+
}, icon: jsx(TextSortDescendingFilled, {}), disabled: header.column.getIsSorted() === 'desc', children: "Sort Z to A" }), jsx(MenuDivider, {})] }, 'sort-group') }), jsx(Show, { when: header.column.getCanGroup(), children: jsxs(MenuGroup, { children: [!header.column.getIsGrouped() && (jsxs(MenuItem, { onClick: () => header.column.getToggleGroupingHandler()(), icon: jsx(GroupFilled, {}), children: ["Group by", ' ', flexRender(header.column.columnDef.header, header.getContext())] })), header.column.getIsGrouped() && (jsxs(MenuItem, { onClick: () => header.column.getToggleGroupingHandler()(), icon: jsx(GroupDismissFilled, {}), children: ["Remove Grouping on", ' ', flexRender(header.column.columnDef.header, header.getContext())] })), jsx(MenuDivider, {})] }, 'grouping-group') }), jsxs(Show, { when: header.column.getCanPin(), children: [jsxs(Menu, { children: [jsx(MenuTrigger, { disableButtonEnhancement: true, children: jsx(MenuItem, { icon: jsx(PinIcon, {}), children: "Pin Column" }) }), jsx(MenuPopover, { children: jsxs(MenuList, { children: [jsx(Show, { when: ['left', 'right'].includes(header.column.getIsPinned()), children: jsx(MenuItem, { onClick: () => {
|
|
1940
|
+
var _a;
|
|
1941
|
+
(_a = header.column) === null || _a === void 0 ? void 0 : _a.pin(false);
|
|
1942
|
+
}, icon: jsx(PinOffRegular, {}), children: "No Pin" }) }), jsx(MenuItem, { onClick: () => {
|
|
1943
|
+
var _a;
|
|
1944
|
+
(_a = header.column) === null || _a === void 0 ? void 0 : _a.pin('left');
|
|
1945
|
+
}, icon: jsx(ArrowStepInLeftRegular, {}), disabled: header.column.getIsPinned() === 'left', children: "Pin Left" }), jsx(MenuItem, { onClick: () => {
|
|
1946
|
+
var _a;
|
|
1947
|
+
(_a = header.column) === null || _a === void 0 ? void 0 : _a.pin('right');
|
|
1948
|
+
}, icon: jsx(ArrowStepInRightRegular, {}), disabled: header.column.getIsPinned() === 'right', children: "Pin Right" })] }) })] }), jsx(MenuDivider, {})] }), jsx(Show, { when: header.column.getCanFilter(), children: jsxs(MenuGroup, { children: [jsxs(MenuGroupHeader, { children: ["Filter by", ' ', flexRender(header.column.columnDef.header, header.getContext())] }), jsx(Filter, { column: header.column, table: table })] }, 'filter-group') })] }) })] }));
|
|
1889
1949
|
}
|
|
1890
1950
|
|
|
1891
1951
|
function HeaderRow(props) {
|
|
@@ -1901,7 +1961,7 @@ function HeaderRow(props) {
|
|
|
1901
1961
|
function TableHeader(props) {
|
|
1902
1962
|
const styles = useTableHeaderStyles();
|
|
1903
1963
|
const { table, headerGroups, rowSelectionMode } = props;
|
|
1904
|
-
return (jsx("thead", { className: styles.tHead, children: headerGroups === null || headerGroups === void 0 ? void 0 : headerGroups.map((headerGroup) => (jsx(HeaderRow, { table: table, rowSelectionMode: rowSelectionMode, headerGroup: headerGroup, headerGroupsLength: headerGroups.length }, headerGroup.id))) }));
|
|
1964
|
+
return (jsx("thead", { className: styles.tHead, style: { zIndex: 99 }, children: headerGroups === null || headerGroups === void 0 ? void 0 : headerGroups.map((headerGroup) => (jsx(HeaderRow, { table: table, rowSelectionMode: rowSelectionMode, headerGroup: headerGroup, headerGroupsLength: headerGroups.length }, headerGroup.id))) }));
|
|
1905
1965
|
}
|
|
1906
1966
|
|
|
1907
1967
|
const useLoadingStyles = makeStyles({
|
|
@@ -1974,75 +2034,149 @@ const useTableBodyStyles = makeStyles({
|
|
|
1974
2034
|
backgroundColor: tokens.colorBrandBackground2Hover,
|
|
1975
2035
|
} }),
|
|
1976
2036
|
tBodyCell: Object.assign(Object.assign({ backgroundColor: "transparent" }, shorthands.padding("2px", "4px")), { minHeight: "35px", height: "35px" }),
|
|
2037
|
+
tBodyRowPinnedCell: {
|
|
2038
|
+
backgroundColor: tokens.colorPaletteYellowBackground2,
|
|
2039
|
+
":hover": {
|
|
2040
|
+
backgroundColor: tokens.colorPaletteMarigoldBackground2,
|
|
2041
|
+
}
|
|
2042
|
+
},
|
|
2043
|
+
tBodyPinnedCell: {
|
|
2044
|
+
backgroundColor: tokens.colorNeutralBackground3,
|
|
2045
|
+
":hover": {
|
|
2046
|
+
backgroundColor: tokens.colorNeutralBackground3Hover,
|
|
2047
|
+
}
|
|
2048
|
+
},
|
|
2049
|
+
tBodySelectedCell: {
|
|
2050
|
+
backgroundColor: tokens.colorBrandBackground2,
|
|
2051
|
+
":hover": {
|
|
2052
|
+
backgroundColor: tokens.colorBrandBackground2Hover,
|
|
2053
|
+
}
|
|
2054
|
+
},
|
|
1977
2055
|
});
|
|
1978
2056
|
|
|
1979
2057
|
function TableCell({ cell, row }) {
|
|
1980
2058
|
var _a;
|
|
1981
2059
|
const styles = useTableBodyStyles();
|
|
2060
|
+
const isSelected = row.getIsSelected();
|
|
2061
|
+
const isRowPinned = row.getIsPinned();
|
|
2062
|
+
const isCellPinned = cell.column.getIsPinned();
|
|
2063
|
+
const { isDragging, transition, setNodeRef, transform } = useSortable({
|
|
2064
|
+
id: cell.column.id,
|
|
2065
|
+
});
|
|
1982
2066
|
const tdStyle = {
|
|
1983
2067
|
width: cell.column.getSize(),
|
|
2068
|
+
opacity: isDragging ? "0.8" : "1",
|
|
2069
|
+
transform: CSS.Translate.toString(transform),
|
|
2070
|
+
// transition: 'width transform 0.2s ease-in-out',
|
|
2071
|
+
zIndex: isDragging ? 1 : 0,
|
|
2072
|
+
transition
|
|
1984
2073
|
};
|
|
2074
|
+
const cellClassNames = mergeClasses$1(styles.tBodyCell, isCellPinned && styles.tBodyPinnedCell, isSelected && styles.tBodySelectedCell, isRowPinned && styles.tBodyRowPinnedCell);
|
|
2075
|
+
const styleStyles = Object.assign(Object.assign({}, tdStyle), getBodyCellPinningStyles(cell.column));
|
|
1985
2076
|
if (cell.getIsPlaceholder()) {
|
|
1986
|
-
return jsx("td", { style:
|
|
2077
|
+
return jsx("td", { style: styleStyles, className: cellClassNames, ref: setNodeRef }, cell.id);
|
|
1987
2078
|
}
|
|
1988
2079
|
if (cell.getIsGrouped()) {
|
|
1989
|
-
return (jsx("td", { style:
|
|
2080
|
+
return (jsx("td", { style: styleStyles, className: cellClassNames, ref: setNodeRef, children: jsx(Button, { onClick: row.getToggleExpandedHandler(), style: {
|
|
1990
2081
|
cursor: row.getCanExpand() ? 'pointer' : 'normal',
|
|
1991
2082
|
textAlign: 'left',
|
|
1992
2083
|
}, appearance: "transparent", icon: row.getIsExpanded() ? jsx(GroupExpandedIcon, {}) : jsx(GroupCollapsedIcon, {}), children: jsxs("strong", { children: [flexRender(cell.column.columnDef.cell, cell.getContext()), " (", row.subRows.length, ")"] }) }) }, cell.id));
|
|
1993
2084
|
}
|
|
1994
2085
|
if (cell.getIsAggregated()) {
|
|
1995
|
-
return (jsx("td", { style:
|
|
2086
|
+
return (jsx("td", { style: styleStyles, className: cellClassNames, ref: setNodeRef, children: jsx("strong", { children: flexRender((_a = cell.column.columnDef.aggregatedCell) !== null && _a !== void 0 ? _a : cell.column.columnDef.cell, cell.getContext()) }) }, cell.id));
|
|
1996
2087
|
}
|
|
1997
|
-
return (jsx("td", { style:
|
|
2088
|
+
return (jsx("td", { style: styleStyles, className: cellClassNames, ref: setNodeRef, children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id));
|
|
1998
2089
|
}
|
|
1999
2090
|
|
|
2000
|
-
function TableRow({ row, rowSelectionMode }) {
|
|
2091
|
+
function TableRow({ row, rowSelectionMode, style }) {
|
|
2001
2092
|
const styles = useTableBodyStyles();
|
|
2002
2093
|
return (jsxs("tr", { className: row.getIsSelected() || row.getIsAllSubRowsSelected()
|
|
2003
2094
|
? styles.tBodySelectedRow
|
|
2004
|
-
: styles.tBodyRow, children: [rowSelectionMode
|
|
2005
|
-
|
|
2006
|
-
|
|
2095
|
+
: styles.tBodyRow, style: style, children: [jsxs(Switch, { when: rowSelectionMode, children: [jsx(Case, { value: 'multiple', children: jsx("td", { className: styles.tBodyCell, "aria-label": "Select Row Column", children: jsx(Checkbox, { checked: row.getIsSomeSelected()
|
|
2096
|
+
? 'mixed'
|
|
2097
|
+
: row.getIsSelected() || row.getIsAllSubRowsSelected(), disabled: !row.getCanSelect(), onChange: row.getToggleSelectedHandler(), "aria-label": "Select Row" }) }) }), jsx(Case, { value: 'single', children: jsx("td", { className: styles.tBodyCell, "aria-label": "Select Row Column", children: jsx(Radio, { checked: row.getIsSelected(), disabled: !row.getCanSelect(), onChange: row.getToggleSelectedHandler(), "aria-label": "Select Row" }) }) })] }), row.getVisibleCells().map((cell) => (jsx(TableCell, { cell: cell, row: row }, cell.id)))] }, row.id));
|
|
2098
|
+
}
|
|
2099
|
+
function PinnedRow({ row, rowSelectionMode, style, bottomRowLength }) {
|
|
2100
|
+
const styles = useTableBodyStyles();
|
|
2101
|
+
return (jsxs("tr", { className: row.getIsSelected() || row.getIsAllSubRowsSelected()
|
|
2102
|
+
? styles.tBodySelectedRow
|
|
2103
|
+
: styles.tBodyRow, style: {
|
|
2104
|
+
backgroundColor: 'goldenrod',
|
|
2105
|
+
position: 'sticky',
|
|
2106
|
+
top: row.getIsPinned() === 'top'
|
|
2107
|
+
? `${row.getPinnedIndex() * 35 + 48}px`
|
|
2108
|
+
: undefined,
|
|
2109
|
+
bottom: row.getIsPinned() === 'bottom'
|
|
2110
|
+
? `${((bottomRowLength || 0) - 1 - row.getPinnedIndex()) * 35}px`
|
|
2111
|
+
: undefined
|
|
2112
|
+
}, children: [jsxs(Switch, { when: rowSelectionMode, children: [jsx(Case, { value: 'multiple', children: jsx("td", { className: styles.tBodyCell, "aria-label": "Select Row Column", children: jsx(Checkbox, { checked: row.getIsSomeSelected()
|
|
2113
|
+
? 'mixed'
|
|
2114
|
+
: row.getIsSelected() || row.getIsAllSubRowsSelected(), disabled: !row.getCanSelect(), onChange: row.getToggleSelectedHandler(), "aria-label": "Select Row" }) }) }), jsx(Case, { value: 'single', children: jsx("td", { className: styles.tBodyCell, "aria-label": "Select Row Column", children: jsx(Radio, { checked: row.getIsSelected(), disabled: !row.getCanSelect(), onChange: row.getToggleSelectedHandler(), "aria-label": "Select Row" }) }) })] }), row.getVisibleCells().map(cell => {
|
|
2115
|
+
return (jsx(TableCell, { cell: cell, row: row }, cell.id));
|
|
2116
|
+
})] }, row.id));
|
|
2007
2117
|
}
|
|
2008
2118
|
|
|
2009
2119
|
function TableBody(props) {
|
|
2010
|
-
var _a, _b;
|
|
2120
|
+
var _a, _b, _c;
|
|
2011
2121
|
const styles = useTableBodyStyles();
|
|
2012
|
-
const {
|
|
2013
|
-
const
|
|
2122
|
+
const { table, tableContainerRef } = props;
|
|
2123
|
+
const rowSelectionMode = (_a = table.options.meta) === null || _a === void 0 ? void 0 : _a.rowSelectionMode;
|
|
2124
|
+
let rows = [];
|
|
2125
|
+
let topRows = [];
|
|
2126
|
+
let bottomRows = [];
|
|
2127
|
+
try {
|
|
2128
|
+
rows = table.getCenterRows();
|
|
2129
|
+
topRows = table.getTopRows();
|
|
2130
|
+
bottomRows = table.getBottomRows();
|
|
2131
|
+
}
|
|
2132
|
+
catch (error) {
|
|
2133
|
+
rows = [];
|
|
2134
|
+
topRows = [];
|
|
2135
|
+
bottomRows = [];
|
|
2136
|
+
}
|
|
2137
|
+
const rowVirtualizer = useVirtual({
|
|
2138
|
+
parentRef: tableContainerRef,
|
|
2139
|
+
size: rows.length,
|
|
2140
|
+
overscan: 10,
|
|
2141
|
+
});
|
|
2142
|
+
const { virtualItems: virtualRows, totalSize } = rowVirtualizer;
|
|
2143
|
+
const paddingTop = virtualRows.length > 0 ? ((_b = virtualRows === null || virtualRows === void 0 ? void 0 : virtualRows[0]) === null || _b === void 0 ? void 0 : _b.start) || 0 : 0;
|
|
2014
2144
|
const paddingBottom = virtualRows.length > 0
|
|
2015
|
-
? totalSize - (((
|
|
2145
|
+
? totalSize - (((_c = virtualRows === null || virtualRows === void 0 ? void 0 : virtualRows[virtualRows.length - 1]) === null || _c === void 0 ? void 0 : _c.end) || 0)
|
|
2016
2146
|
: 0;
|
|
2017
|
-
return (jsxs(
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2147
|
+
return (jsxs(Fragment, { children: [jsx(Show, { when: (topRows === null || topRows === void 0 ? void 0 : topRows.length) > 0, children: jsx("thead", { style: {
|
|
2148
|
+
position: "sticky",
|
|
2149
|
+
top: 0,
|
|
2150
|
+
zIndex: 99
|
|
2151
|
+
}, children: jsx(For, { each: topRows, children: (row, index) => (jsx(PinnedRow, { row: row, rowSelectionMode: rowSelectionMode, bottomRowLength: bottomRows === null || bottomRows === void 0 ? void 0 : bottomRows.length }, row.id)) }) }) }), jsxs("tbody", { className: styles.tBody, children: [paddingTop > 0 && (jsx("tr", { className: styles.tBodyRow, "aria-hidden": true, children: jsx("td", { style: { height: `${paddingTop}px` } }) })), jsx(For, { each: virtualRows || [], children: (virtualRow) => {
|
|
2152
|
+
const row = rows[virtualRow.index];
|
|
2153
|
+
return (jsx(TableRow, { row: row, rowSelectionMode: rowSelectionMode }, row.id));
|
|
2154
|
+
} }), paddingBottom > 0 && (jsx("tr", { className: styles.tBodyRow, "aria-hidden": true, children: jsx("td", { style: { height: `${paddingBottom}px` } }) }))] }), jsx(Show, { when: rowSelectionMode === 'multiple' && (rows === null || rows === void 0 ? void 0 : rows.length) > 0, children: jsx("tfoot", { style: {
|
|
2155
|
+
position: "sticky",
|
|
2156
|
+
bottom: 0,
|
|
2157
|
+
zIndex: 99
|
|
2158
|
+
}, children: jsxs("tr", { style: { backgroundColor: "white" }, children: [jsx("td", { className: "p-1", children: jsx(Checkbox, { checked: table.getIsSomePageRowsSelected()
|
|
2159
|
+
? 'mixed'
|
|
2160
|
+
: table.getIsAllPageRowsSelected(), onChange: table.getToggleAllPageRowsSelectedHandler(), "aria-label": "Select All Current Page Rows", title: 'Select All Current Page Rows' }) }), jsxs("td", { colSpan: 20, children: [table.getIsAllPageRowsSelected() ? 'Unselect' : 'Select', " All Current Page Rows (", table.getRowModel().rows.length, ")"] })] }) }) }), jsx(Show, { when: (bottomRows === null || bottomRows === void 0 ? void 0 : bottomRows.length) > 0, children: jsx("tfoot", { style: {
|
|
2161
|
+
position: "sticky",
|
|
2162
|
+
bottom: 0,
|
|
2163
|
+
zIndex: 99
|
|
2164
|
+
}, children: jsx(For, { each: bottomRows, children: (row) => (jsx(PinnedRow, { row: row, rowSelectionMode: rowSelectionMode, bottomRowLength: bottomRows === null || bottomRows === void 0 ? void 0 : bottomRows.length }, row.id)) }) }) })] }));
|
|
2021
2165
|
}
|
|
2022
2166
|
|
|
2023
2167
|
const TableContainer = (props) => {
|
|
2024
2168
|
var _a, _b;
|
|
2025
2169
|
const styles = useTableStaticStyles();
|
|
2026
|
-
const { table
|
|
2170
|
+
const { table } = props;
|
|
2171
|
+
const { tableHeight, rowSelectionMode } = table.options.meta || {};
|
|
2027
2172
|
const tableContainerRef = React.useRef(null);
|
|
2028
|
-
const { rows } = table.getRowModel();
|
|
2029
|
-
const rowVirtualizer = useVirtual({
|
|
2030
|
-
parentRef: tableContainerRef,
|
|
2031
|
-
size: rows.length,
|
|
2032
|
-
overscan: 5,
|
|
2033
|
-
});
|
|
2034
|
-
const { virtualItems: virtualRows, totalSize } = rowVirtualizer;
|
|
2173
|
+
const { rows: { length: itemLength } } = table.getRowModel();
|
|
2035
2174
|
const headerGroups = table.getHeaderGroups();
|
|
2036
2175
|
// utilities
|
|
2037
|
-
const isLoading = props.isLoading &&
|
|
2176
|
+
const isLoading = props.isLoading && itemLength === 0;
|
|
2038
2177
|
const noItems = !isLoading && ((_a = props.data) === null || _a === void 0 ? void 0 : _a.length) === 0;
|
|
2039
|
-
const noSearchResult = !isLoading && ((_b = props === null || props === void 0 ? void 0 : props.data) === null || _b === void 0 ? void 0 : _b.length) > 0 &&
|
|
2040
|
-
return (jsxs("div", { ref: tableContainerRef, className: styles.tableContainer, children: [jsxs("table", { className: styles.table, "aria-label": "Data Grid", children: [jsx(TableHeader, { table: table, rowSelectionMode: rowSelectionMode, headerGroups: headerGroups }), jsx(TableBody, {
|
|
2041
|
-
!isLoading &&
|
|
2042
|
-
!noItems &&
|
|
2043
|
-
!noSearchResult && (jsx("tfoot", { className: styles.tFoot, children: jsxs("tr", { children: [jsx("td", { className: "p-1", children: jsx(Checkbox, { checked: table.getIsSomePageRowsSelected()
|
|
2044
|
-
? 'mixed'
|
|
2045
|
-
: table.getIsAllPageRowsSelected(), onChange: table.getToggleAllPageRowsSelectedHandler(), "aria-label": "Select All Current Page Rows", title: 'Select All Current Page Rows' }) }), jsxs("td", { colSpan: 20, children: [table.getIsAllPageRowsSelected() ? 'Unselect' : 'Select', " All Current Page Rows (", table.getRowModel().rows.length, ")"] })] }) }))] }), isLoading && jsx(Loading, {}), noItems && jsx(NoItemGrid, { message: props.noItemPage }), noSearchResult && jsx(NoSearchResult, { message: props.noFilterMatchPage })] }));
|
|
2178
|
+
const noSearchResult = !isLoading && ((_b = props === null || props === void 0 ? void 0 : props.data) === null || _b === void 0 ? void 0 : _b.length) > 0 && itemLength === 0;
|
|
2179
|
+
return (jsxs("div", { ref: tableContainerRef, className: styles.tableContainer, style: { height: tableHeight }, children: [jsxs("table", { className: styles.table, "aria-label": "Data Grid", style: { width: table.getTotalSize(), minWidth: "100%" }, children: [jsx(TableHeader, { table: table, rowSelectionMode: rowSelectionMode, headerGroups: headerGroups }), jsx(TableBody, { table: table, tableContainerRef: tableContainerRef })] }), jsxs(Switch, { when: true, children: [jsx(Case, { value: isLoading, children: jsx(Loading, {}) }), jsx(Case, { value: noItems, children: jsx(NoItemGrid, { message: props.noItemPage }) }), jsx(Case, { value: noSearchResult, children: jsx(NoSearchResult, { message: props.noFilterMatchPage }) })] })] }));
|
|
2046
2180
|
};
|
|
2047
2181
|
|
|
2048
2182
|
const ViewSaveForm = (props) => {
|
|
@@ -2104,29 +2238,20 @@ const useFilterDrawerStyles = makeStyles({
|
|
|
2104
2238
|
} }),
|
|
2105
2239
|
});
|
|
2106
2240
|
const ViewsDrawer = (props) => {
|
|
2107
|
-
const { table, drawerState, dispatch, tableViews, applyTableState, resetToGridDefaultView
|
|
2108
|
-
const
|
|
2241
|
+
const { table, drawerState, dispatch, tableViews, applyTableState, resetToGridDefaultView } = props;
|
|
2242
|
+
const { onTableViewDelete, onTableViewSave } = table.options.meta || {};
|
|
2109
2243
|
const [checkedValues, setCheckedValues] = React.useState({ font: ["calibri"] });
|
|
2110
2244
|
const onChange = (e, { name, checkedItems }) => {
|
|
2111
2245
|
setCheckedValues((s) => (Object.assign(Object.assign({}, s), { [name]: checkedItems })));
|
|
2112
2246
|
};
|
|
2113
|
-
|
|
2114
|
-
// table.setGlobalFilter('');
|
|
2115
|
-
// table.resetColumnFilters();
|
|
2116
|
-
// }, [table]);
|
|
2117
|
-
// const resetAllGrouping = React.useCallback(() => {
|
|
2118
|
-
// table.resetGrouping();
|
|
2119
|
-
// }, [table]);
|
|
2120
|
-
// const clearAllSelection = React.useCallback(() => {
|
|
2121
|
-
// table.toggleAllRowsSelected(false);
|
|
2122
|
-
// }, [table]);
|
|
2247
|
+
const styles = useFilterDrawerStyles();
|
|
2123
2248
|
return (jsxs(InlineDrawer, { position: "end", open: drawerState.isViewsDrawerOpen, separator: true, children: [jsx(DrawerHeader, { children: jsx(DrawerHeaderTitle, { action: jsx(Button, { appearance: "subtle", "aria-label": "Close", icon: jsx(Dismiss24Regular, {}), onClick: () => dispatch({ type: "CLOSE_VIEW_DRAWER" }) }), children: "Table Views" }) }), jsxs(DrawerBody, { className: styles.drawerBody, children: [onTableViewSave && jsx(ViewSaveForm, { mode: 'create', getTableState: table.getState, onSave: onTableViewSave }), jsxs(MenuList, { checkedValues: checkedValues, onCheckedValueChange: onChange, children: [jsx(MenuItemRadio, { name: 'table-views', value: 'Default View', icon: jsx(ViewDesktop20Filled, {}), onClick: resetToGridDefaultView, children: "Default View" }), tableViews.length > 0 && jsx(MenuDivider, { children: "Additional Views" }), tableViews.map((view) => {
|
|
2124
2249
|
return (jsxs("div", { style: {
|
|
2125
2250
|
display: 'flex',
|
|
2126
2251
|
justifyContent: 'space-between',
|
|
2127
2252
|
alignItems: 'center',
|
|
2128
2253
|
width: '100%',
|
|
2129
|
-
}, children: [jsx(MenuItemRadio, { name: "table-views", value: view.viewName, onClick: () => applyTableState(view.tableState), icon: jsx(ViewDesktop20Regular, {}), children: view.viewName }),
|
|
2254
|
+
}, children: [jsx(MenuItemRadio, { name: "table-views", value: view.viewName, onClick: () => applyTableState(view.tableState), icon: jsx(ViewDesktop20Regular, {}), children: view.viewName }), onTableViewDelete && (view === null || view === void 0 ? void 0 : view.isViewOwner) && (jsx(Button, { appearance: "subtle", "aria-label": "Close", icon: jsx(Dismiss24Regular, {}), onClick: () => onTableViewDelete === null || onTableViewDelete === void 0 ? void 0 : onTableViewDelete(view) }))] }, view.id + view.viewName));
|
|
2130
2255
|
})] })] }), jsx(DrawerFooter, { children: jsxs(MenuList, { children: [jsx(MenuDivider, {}), jsx(MenuItem, { icon: jsx(ClearFilterIcon, {}), onClick: resetToGridDefaultView, children: "Reset to Default View" })] }) })] }));
|
|
2131
2256
|
};
|
|
2132
2257
|
|
|
@@ -2165,8 +2290,43 @@ function AdvancedTable(props, ref) {
|
|
|
2165
2290
|
isFilterDrawerOpen: false,
|
|
2166
2291
|
isViewsDrawerOpen: false
|
|
2167
2292
|
});
|
|
2168
|
-
|
|
2293
|
+
const { getState, setColumnOrder } = table;
|
|
2294
|
+
const { columnOrder } = getState();
|
|
2295
|
+
function handleDragEnd(event) {
|
|
2296
|
+
const { active, over } = event;
|
|
2297
|
+
if (active && over && (active === null || active === void 0 ? void 0 : active.id) !== (over === null || over === void 0 ? void 0 : over.id)) {
|
|
2298
|
+
setColumnOrder((items) => {
|
|
2299
|
+
const oldIndex = items.indexOf(active === null || active === void 0 ? void 0 : active.id);
|
|
2300
|
+
const newIndex = items.indexOf(over === null || over === void 0 ? void 0 : over.id);
|
|
2301
|
+
return arrayMove(items, oldIndex, newIndex);
|
|
2302
|
+
});
|
|
2303
|
+
}
|
|
2304
|
+
}
|
|
2305
|
+
const pointerSensor = useSensor(PointerSensor, {
|
|
2306
|
+
activationConstraint: {
|
|
2307
|
+
distance: 0.01
|
|
2308
|
+
}
|
|
2309
|
+
});
|
|
2310
|
+
const mouseSensor = useSensor(MouseSensor);
|
|
2311
|
+
const touchSensor = useSensor(TouchSensor);
|
|
2312
|
+
const keyboardSensor = useSensor(KeyboardSensor);
|
|
2313
|
+
const sensors = useSensors(mouseSensor, touchSensor, keyboardSensor, pointerSensor);
|
|
2314
|
+
return (jsx(DndContext, { collisionDetection: closestCenter, modifiers: [restrictToHorizontalAxis], onDragEnd: handleDragEnd, sensors: sensors, children: jsxs(SortableContext, { items: columnOrder, strategy: horizontalListSortingStrategy, children: [jsx(Show, { when: !props.disableTableHeader, children: jsx(GridHeader, { table: table, gridTitle: props.gridTitle, headerMenu: headerMenu, globalFilter: globalFilter, setGlobalFilter: setGlobalFilter, applyTableState: applyTableState, drawerState: drawerState, dispatch: dispatch }) }), jsxs("div", { style: { display: 'flex' }, children: [jsx(TableContainer, { table: table, data: props.data, isLoading: props.isLoading || false, noFilterMatchPage: props.noFilterMatchPage, noItemPage: props.noItemPage }), jsx(FilterDrawer, { drawerState: drawerState, dispatch: dispatch, table: table }), jsx(ViewsDrawer, { table: table, drawerState: drawerState, dispatch: dispatch, tableViews: tableViews, applyTableState: applyTableState, resetToGridDefaultView: resetToDefaultView })] }), jsx(Pagination, { table: table })] }) }));
|
|
2169
2315
|
}
|
|
2170
2316
|
const ForwardedAdvancedTable = React.forwardRef(AdvancedTable);
|
|
2171
2317
|
|
|
2172
|
-
|
|
2318
|
+
/* eslint-disable */
|
|
2319
|
+
function useSkipper() {
|
|
2320
|
+
const shouldSkipRef = React.useRef(true);
|
|
2321
|
+
const shouldSkip = shouldSkipRef.current;
|
|
2322
|
+
// Wrap a function with this to skip a pagination reset temporarily
|
|
2323
|
+
const skip = React.useCallback(() => {
|
|
2324
|
+
shouldSkipRef.current = false;
|
|
2325
|
+
}, []);
|
|
2326
|
+
React.useEffect(() => {
|
|
2327
|
+
shouldSkipRef.current = true;
|
|
2328
|
+
});
|
|
2329
|
+
return [shouldSkip, skip];
|
|
2330
|
+
}
|
|
2331
|
+
|
|
2332
|
+
export { ForwardedAdvancedTable as Table, useSkipper };
|