@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.cjs.js
CHANGED
|
@@ -4,12 +4,15 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var React = require('react');
|
|
7
|
-
var reactDnd = require('react-dnd');
|
|
8
|
-
var reactDndHtml5Backend = require('react-dnd-html5-backend');
|
|
9
7
|
var reactComponents = require('@fluentui/react-components');
|
|
8
|
+
var reactControlFlow = require('@prt-ts/react-control-flow');
|
|
10
9
|
var reactTable = require('@tanstack/react-table');
|
|
11
10
|
var reactVirtual = require('react-virtual');
|
|
12
11
|
var reactDatepickerCompat = require('@fluentui/react-datepicker-compat');
|
|
12
|
+
var sortable = require('@dnd-kit/sortable');
|
|
13
|
+
var utilities = require('@dnd-kit/utilities');
|
|
14
|
+
var core = require('@dnd-kit/core');
|
|
15
|
+
var modifiers = require('@dnd-kit/modifiers');
|
|
13
16
|
|
|
14
17
|
function _interopNamespace(e) {
|
|
15
18
|
if (e && e.__esModule) return e;
|
|
@@ -37,9 +40,11 @@ const useStaticStyles = reactComponents.makeStaticStyles({
|
|
|
37
40
|
},
|
|
38
41
|
});
|
|
39
42
|
const useTableStaticStyles = reactComponents.makeStyles({
|
|
40
|
-
tableContainer: Object.assign(Object.assign({
|
|
43
|
+
tableContainer: Object.assign(Object.assign({
|
|
44
|
+
// height: "650px",
|
|
45
|
+
width: "100%" }, reactComponents.shorthands.overflow("hidden", "auto")), {
|
|
41
46
|
/* width */
|
|
42
|
-
":hover": Object.assign({}, reactComponents.shorthands.overflow("auto", "auto")), "::-webkit-scrollbar": Object.assign({ width: "
|
|
47
|
+
":hover": Object.assign({}, reactComponents.shorthands.overflow("auto", "auto")), "::-webkit-scrollbar": Object.assign({ width: "8px", height: "4px" }, reactComponents.shorthands.borderRadius("50%")),
|
|
43
48
|
/* Track */
|
|
44
49
|
"::-webkit-scrollbar-track": {
|
|
45
50
|
"background-color": "#f1f1f1",
|
|
@@ -1023,6 +1028,7 @@ const GroupDismissFilled = /*#__PURE__*/createFluentIcon('GroupDismissFilled', "
|
|
|
1023
1028
|
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"]);
|
|
1024
1029
|
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"]);
|
|
1025
1030
|
|
|
1031
|
+
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"]);
|
|
1026
1032
|
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"]);
|
|
1027
1033
|
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"]);
|
|
1028
1034
|
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"]);
|
|
@@ -1095,7 +1101,8 @@ const range = (from, to, step = 1) => {
|
|
|
1095
1101
|
};
|
|
1096
1102
|
const DEFAULT_NUMBER_OF_PAGE_BTN = 5;
|
|
1097
1103
|
const Pagination = (props) => {
|
|
1098
|
-
const { table
|
|
1104
|
+
const { table } = props;
|
|
1105
|
+
const { pageSizeOptions } = table.options.meta || {};
|
|
1099
1106
|
const pageSizeSelectionId = reactComponents.useId("page-size-selector");
|
|
1100
1107
|
const styles = usePaginationStyle();
|
|
1101
1108
|
const totalNumberOfPage = table.getPageCount();
|
|
@@ -1118,12 +1125,12 @@ const Pagination = (props) => {
|
|
|
1118
1125
|
const currentPageOptions = end - start >= 0 ? range(start, end) : [];
|
|
1119
1126
|
return (currentPageOptions === null || currentPageOptions === void 0 ? void 0 : currentPageOptions.length) ? [...currentPageOptions] : [1];
|
|
1120
1127
|
}, [totalNumberOfPage, currentPage]);
|
|
1121
|
-
return (jsxRuntime.jsx("div", { className: styles.paginationContainer, children: jsxRuntime.jsxs("div", { className: styles.wrapper, children: [jsxRuntime.jsx("div", { className: styles.pageSelectionWrapper, children: jsxRuntime.jsx(reactComponents.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:
|
|
1128
|
+
return (jsxRuntime.jsx("div", { className: styles.paginationContainer, children: jsxRuntime.jsxs("div", { className: styles.wrapper, children: [jsxRuntime.jsx("div", { className: styles.pageSelectionWrapper, children: jsxRuntime.jsx(reactComponents.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: jsxRuntime.jsx(reactControlFlow.Show, { when: (pageSelectionOptions === null || pageSelectionOptions === void 0 ? void 0 : pageSelectionOptions.length) > 0, children: jsxRuntime.jsx(reactControlFlow.For, { each: pageSizeOptions, children: (option) => (jsxRuntime.jsx(reactComponents.Option, { value: `${option}`, children: `${option}` }, option)) }) }) }) }), jsxRuntime.jsxs("div", { className: styles.pageBtnContainer, children: [jsxRuntime.jsxs("div", { children: [jsxRuntime.jsxs("span", { children: ["Page", " ", jsxRuntime.jsxs("strong", { children: [table.getState().pagination.pageIndex + 1, " of", " ", table.getPageCount()] })] }), jsxRuntime.jsxs("span", { children: [" ", "| Go to page:", " ", jsxRuntime.jsx(reactComponents.Input, { type: "number", size: "small", value: `${table.getState().pagination.pageIndex + 1}`, onChange: (e, data) => {
|
|
1122
1129
|
const page = data.value ? Number(e.target.value) - 1 : 0;
|
|
1123
1130
|
if (page >= 0 && page < table.getPageCount()) {
|
|
1124
1131
|
table.setPageIndex(page);
|
|
1125
1132
|
}
|
|
1126
|
-
}, className: styles.pageSizeInput, "aria-label": "Page Number", autoComplete: "off", autoCorrect: "off" })] })] }), jsxRuntime.jsx(reactComponents.Button, { size: "small", className: styles.pageBtn, shape: "circular", onClick: () => table.setPageIndex(0), disabled: !table.getCanPreviousPage(), icon: jsxRuntime.jsx(PreviousRegular, {}), "aria-label": "Go to first page" }), jsxRuntime.jsx(reactComponents.Button, { size: "small", className: styles.pageBtn, shape: "circular", onClick: () => table.previousPage(), disabled: !table.getCanPreviousPage(), icon: jsxRuntime.jsx(ArrowPreviousFilled, {}), "aria-label": "Go to previous page" }),
|
|
1133
|
+
}, className: styles.pageSizeInput, "aria-label": "Page Number", autoComplete: "off", autoCorrect: "off" })] })] }), jsxRuntime.jsx(reactComponents.Button, { size: "small", className: styles.pageBtn, shape: "circular", onClick: () => table.setPageIndex(0), disabled: !table.getCanPreviousPage(), icon: jsxRuntime.jsx(PreviousRegular, {}), "aria-label": "Go to first page" }), jsxRuntime.jsx(reactComponents.Button, { size: "small", className: styles.pageBtn, shape: "circular", onClick: () => table.previousPage(), disabled: !table.getCanPreviousPage(), icon: jsxRuntime.jsx(ArrowPreviousFilled, {}), "aria-label": "Go to previous page" }), jsxRuntime.jsx(reactControlFlow.For, { each: pageSelectionOptions, children: (option, index) => (jsxRuntime.jsx(reactComponents.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)) }), jsxRuntime.jsx(reactComponents.Button, { size: "small", className: styles.pageBtn, shape: "circular", onClick: () => table.nextPage(), disabled: !table.getCanNextPage(), icon: jsxRuntime.jsx(ArrowNextFilled, {}), "aria-label": "Go to next page" }), jsxRuntime.jsx(reactComponents.Button, { size: "small", shape: "circular", className: styles.pageBtn, onClick: () => table.setPageIndex(table.getPageCount() - 1), disabled: !table.getCanNextPage(), icon: jsxRuntime.jsx(NextRegular, {}), "aria-label": "Go to last page" })] })] }) }));
|
|
1127
1134
|
};
|
|
1128
1135
|
|
|
1129
1136
|
bundleIcon$1(SaveFilled, SaveRegular);
|
|
@@ -1152,18 +1159,21 @@ const useGridHeaderStyles = reactComponents.makeStyles({
|
|
|
1152
1159
|
width: "100%",
|
|
1153
1160
|
height: "100%",
|
|
1154
1161
|
},
|
|
1162
|
+
popoverSurface: {
|
|
1163
|
+
minWidth: "300px"
|
|
1164
|
+
}
|
|
1155
1165
|
});
|
|
1156
1166
|
|
|
1157
1167
|
const GridHeader = (props) => {
|
|
1158
1168
|
const { table, gridTitle, globalFilter, setGlobalFilter, dispatch, drawerState } = props;
|
|
1159
1169
|
const styles = useGridHeaderStyles();
|
|
1160
|
-
return (jsxRuntime.jsxs("div", { className: styles.tableTopHeaderContainer, children: [jsxRuntime.jsx("div", { className: styles.tableTopHeaderLeft, children: gridTitle }), jsxRuntime.jsxs("div", { className: styles.tableTopHeaderRight, children: [props.headerMenu, props.headerMenu && jsxRuntime.jsx(reactComponents.Divider, { vertical: true }), jsxRuntime.jsxs(reactComponents.Popover, { withArrow: true, children: [jsxRuntime.jsx(reactComponents.PopoverTrigger, { disableButtonEnhancement: true, children: jsxRuntime.jsx(reactComponents.Tooltip, { content: 'Toggle Group Column', relationship: "label", children: jsxRuntime.jsx(reactComponents.Button, { icon: jsxRuntime.jsx(ToggleGroupColumnIcon, {}), "aria-label": "Toggle Group Column" }) }) }), jsxRuntime.jsx(reactComponents.PopoverSurface, { children: jsxRuntime.jsxs("div", { className: styles.tableTopHeaderColumnTogglePopover, children: [jsxRuntime.jsx(reactComponents.MenuGroupHeader, { children: "Group Columns" }), table.getAllLeafColumns().map((column) => {
|
|
1170
|
+
return (jsxRuntime.jsxs("div", { className: styles.tableTopHeaderContainer, children: [jsxRuntime.jsx("div", { className: styles.tableTopHeaderLeft, children: gridTitle }), jsxRuntime.jsxs("div", { className: styles.tableTopHeaderRight, children: [props.headerMenu, props.headerMenu && jsxRuntime.jsx(reactComponents.Divider, { vertical: true }), jsxRuntime.jsxs(reactComponents.Popover, { withArrow: true, children: [jsxRuntime.jsx(reactComponents.PopoverTrigger, { disableButtonEnhancement: true, children: jsxRuntime.jsx(reactComponents.Tooltip, { content: 'Toggle Group Column', relationship: "label", children: jsxRuntime.jsx(reactComponents.Button, { icon: jsxRuntime.jsx(ToggleGroupColumnIcon, {}), "aria-label": "Toggle Group Column" }) }) }), jsxRuntime.jsx(reactComponents.PopoverSurface, { className: styles.popoverSurface, children: jsxRuntime.jsxs("div", { className: styles.tableTopHeaderColumnTogglePopover, children: [jsxRuntime.jsx(reactComponents.MenuGroupHeader, { children: "Group Columns" }), table.getAllLeafColumns().map((column) => {
|
|
1161
1171
|
if (column.id === 'select')
|
|
1162
1172
|
return null;
|
|
1163
1173
|
if (column.id === 'id')
|
|
1164
1174
|
return null;
|
|
1165
1175
|
return (jsxRuntime.jsx(reactComponents.Checkbox, { checked: column.getIsGrouped(), onChange: column.getToggleGroupingHandler(), disabled: !column.getCanGroup() || !column.getIsVisible(), label: jsxRuntime.jsx("span", { children: column.columnDef.id }) }, column.id));
|
|
1166
|
-
})] }) })] }), jsxRuntime.jsxs(reactComponents.Popover, { withArrow: true, children: [jsxRuntime.jsx(reactComponents.PopoverTrigger, { disableButtonEnhancement: true, children: jsxRuntime.jsx(reactComponents.Tooltip, { content: 'Toggle Column Visibility', relationship: "label", children: jsxRuntime.jsx(reactComponents.Button, { icon: jsxRuntime.jsx(ToggleSelectColumnIcon, {}), "aria-label": "Toggle Column Visibility" }) }) }), jsxRuntime.jsx(reactComponents.PopoverSurface, { children: jsxRuntime.jsxs("div", { className: styles.tableTopHeaderColumnTogglePopover, children: [jsxRuntime.jsx(reactComponents.MenuGroupHeader, { children: "Toggle Columns" }), jsxRuntime.jsx(reactComponents.Checkbox, { checked: table.getIsAllColumnsVisible(), onChange: table.getToggleAllColumnsVisibilityHandler(), label: 'Toggle All' }), jsxRuntime.jsx(reactComponents.Divider, {}), table.getAllLeafColumns().map((column) => {
|
|
1176
|
+
})] }) })] }), jsxRuntime.jsxs(reactComponents.Popover, { withArrow: true, children: [jsxRuntime.jsx(reactComponents.PopoverTrigger, { disableButtonEnhancement: true, children: jsxRuntime.jsx(reactComponents.Tooltip, { content: 'Toggle Column Visibility', relationship: "label", children: jsxRuntime.jsx(reactComponents.Button, { icon: jsxRuntime.jsx(ToggleSelectColumnIcon, {}), "aria-label": "Toggle Column Visibility" }) }) }), jsxRuntime.jsx(reactComponents.PopoverSurface, { className: styles.popoverSurface, children: jsxRuntime.jsxs("div", { className: styles.tableTopHeaderColumnTogglePopover, children: [jsxRuntime.jsx(reactComponents.MenuGroupHeader, { children: "Toggle Columns" }), jsxRuntime.jsx(reactComponents.Checkbox, { checked: table.getIsAllColumnsVisible(), onChange: table.getToggleAllColumnsVisibilityHandler(), label: 'Toggle All' }), jsxRuntime.jsx(reactComponents.Divider, {}), table.getAllLeafColumns().map((column) => {
|
|
1167
1177
|
if (column.id === 'select')
|
|
1168
1178
|
return null;
|
|
1169
1179
|
return (jsxRuntime.jsx(reactComponents.Checkbox, { checked: column.getIsVisible(), onChange: column.getToggleVisibilityHandler(), label: column.id, disabled: !column.getCanHide() }, column.id));
|
|
@@ -1247,8 +1257,8 @@ const getLeafColumns = (columns) => {
|
|
|
1247
1257
|
};
|
|
1248
1258
|
|
|
1249
1259
|
const useGridContainer = (props, ref) => {
|
|
1250
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1251
|
-
const { columns, data, rowSelectionMode } = props;
|
|
1260
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
1261
|
+
const { defaultColumn, columns, data, rowSelectionMode, autoResetPageIndex, onUpdateData } = props;
|
|
1252
1262
|
const [pagination, setPagination] = React__namespace.useState({
|
|
1253
1263
|
pageSize: props.pageSize || 10,
|
|
1254
1264
|
pageIndex: 0,
|
|
@@ -1269,7 +1279,12 @@ const useGridContainer = (props, ref) => {
|
|
|
1269
1279
|
const [expanded, setExpanded] = React__namespace.useState((_g = props.expandedState) !== null && _g !== void 0 ? _g : {});
|
|
1270
1280
|
const [columnPinning, setColumnPinning] = React__namespace.useState((_h = props.columnPinningState) !== null && _h !== void 0 ? _h : {});
|
|
1271
1281
|
const [columnSizing, setColumnSizing] = React__namespace.useState({});
|
|
1282
|
+
const [rowPinning, setRowPinning] = React__namespace.useState((_j = props.rowPinningState) !== null && _j !== void 0 ? _j : {
|
|
1283
|
+
top: [],
|
|
1284
|
+
bottom: [],
|
|
1285
|
+
});
|
|
1272
1286
|
const table = reactTable.useReactTable({
|
|
1287
|
+
defaultColumn,
|
|
1273
1288
|
columns: columns,
|
|
1274
1289
|
data,
|
|
1275
1290
|
filterFns: {
|
|
@@ -1292,6 +1307,11 @@ const useGridContainer = (props, ref) => {
|
|
|
1292
1307
|
columnVisibility,
|
|
1293
1308
|
columnPinning,
|
|
1294
1309
|
columnSizing,
|
|
1310
|
+
rowPinning
|
|
1311
|
+
},
|
|
1312
|
+
getRowId(originalRow, index, parent) {
|
|
1313
|
+
const keyProps = props.dataPrimaryKye || 'id';
|
|
1314
|
+
return originalRow[keyProps] || `${index}`;
|
|
1295
1315
|
},
|
|
1296
1316
|
columnResizeMode: 'onChange',
|
|
1297
1317
|
enableRowSelection: rowSelectionMode !== undefined,
|
|
@@ -1301,6 +1321,8 @@ const useGridContainer = (props, ref) => {
|
|
|
1301
1321
|
enableColumnFilters: true,
|
|
1302
1322
|
filterFromLeafRows: true,
|
|
1303
1323
|
autoResetExpanded: false,
|
|
1324
|
+
autoResetPageIndex: autoResetPageIndex,
|
|
1325
|
+
keepPinnedRows: true,
|
|
1304
1326
|
onRowSelectionChange: setRowSelection,
|
|
1305
1327
|
onPaginationChange: setPagination,
|
|
1306
1328
|
onSortingChange: setSorting,
|
|
@@ -1312,6 +1334,7 @@ const useGridContainer = (props, ref) => {
|
|
|
1312
1334
|
onColumnVisibilityChange: setColumnVisibility,
|
|
1313
1335
|
onColumnPinningChange: setColumnPinning,
|
|
1314
1336
|
onColumnSizingChange: setColumnSizing,
|
|
1337
|
+
onRowPinningChange: setRowPinning,
|
|
1315
1338
|
getCoreRowModel: reactTable.getCoreRowModel(),
|
|
1316
1339
|
getPaginationRowModel: reactTable.getPaginationRowModel(),
|
|
1317
1340
|
getSortedRowModel: reactTable.getSortedRowModel(),
|
|
@@ -1320,10 +1343,18 @@ const useGridContainer = (props, ref) => {
|
|
|
1320
1343
|
getExpandedRowModel: reactTable.getExpandedRowModel(),
|
|
1321
1344
|
getFacetedUniqueValues: reactTable.getFacetedUniqueValues(),
|
|
1322
1345
|
getFacetedMinMaxValues: reactTable.getFacetedMinMaxValues(),
|
|
1346
|
+
meta: {
|
|
1347
|
+
pageSizeOptions: props.pageSizeOptions || [10, 20, 50, 100, 1000],
|
|
1348
|
+
rowSelectionMode: props.rowSelectionMode,
|
|
1349
|
+
tableHeight: props.tableHeight || "650px",
|
|
1350
|
+
updateData: onUpdateData,
|
|
1351
|
+
onTableViewDelete: props.onTableViewDelete,
|
|
1352
|
+
onTableViewSave: props.onTableViewSave
|
|
1353
|
+
}
|
|
1323
1354
|
});
|
|
1324
1355
|
const tableViews = React__namespace.useMemo(() => { var _a; return (_a = props.views) !== null && _a !== void 0 ? _a : []; }, [props.views]);
|
|
1325
1356
|
const resetToDefaultView = () => {
|
|
1326
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1357
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
1327
1358
|
const defaultTableState = {
|
|
1328
1359
|
pagination: {
|
|
1329
1360
|
pageSize: props.pageSize || 10,
|
|
@@ -1345,7 +1376,7 @@ const useGridContainer = (props, ref) => {
|
|
|
1345
1376
|
columnVisibility: (_g = props.columnVisibility) !== null && _g !== void 0 ? _g : {},
|
|
1346
1377
|
columnPinning: (_h = props.columnPinningState) !== null && _h !== void 0 ? _h : {},
|
|
1347
1378
|
columnSizing: {},
|
|
1348
|
-
rowPinning: {},
|
|
1379
|
+
rowPinning: (_j = props.rowPinningState) !== null && _j !== void 0 ? _j : {},
|
|
1349
1380
|
columnSizingInfo: {
|
|
1350
1381
|
"startOffset": null,
|
|
1351
1382
|
"startSize": null,
|
|
@@ -1378,6 +1409,7 @@ const useGridContainer = (props, ref) => {
|
|
|
1378
1409
|
pageSize: props.pageSize || 10,
|
|
1379
1410
|
pageIndex: 0,
|
|
1380
1411
|
});
|
|
1412
|
+
setRowPinning(tableState.rowPinning);
|
|
1381
1413
|
}, 10);
|
|
1382
1414
|
return true;
|
|
1383
1415
|
}
|
|
@@ -1443,10 +1475,11 @@ const useTableHeaderStyles = reactComponents.makeStyles({
|
|
|
1443
1475
|
boxShadow: reactComponents.tokens.shadow2,
|
|
1444
1476
|
},
|
|
1445
1477
|
tHeadRow: {
|
|
1446
|
-
backgroundColor: reactComponents.tokens.
|
|
1478
|
+
backgroundColor: reactComponents.tokens.colorNeutralCardBackgroundSelected,
|
|
1447
1479
|
},
|
|
1448
1480
|
tHeadCell: Object.assign({ zIndex: 99, position: 'relative', fontSize: reactComponents.tokens.fontSizeBase300, fontWeight: reactComponents.tokens.fontWeightBold, minWidth: '1rem' }, reactComponents.shorthands.padding('2px', '4px')),
|
|
1449
|
-
tHeadNonLeafCell: Object.assign({}, reactComponents.shorthands.borderBottom(
|
|
1481
|
+
tHeadNonLeafCell: Object.assign({}, reactComponents.shorthands.borderBottom(0)),
|
|
1482
|
+
tHeadNonLeafCellFakeBorder: Object.assign({ width: '100%', height: '1px', position: "sticky", bottom: 0 }, reactComponents.shorthands.borderBottom('1px', 'solid', reactComponents.tokens.colorBrandBackgroundInverted)),
|
|
1450
1483
|
tHeadCellDraggable: {
|
|
1451
1484
|
height: '100%',
|
|
1452
1485
|
cursor: 'grab',
|
|
@@ -1455,18 +1488,18 @@ const useTableHeaderStyles = reactComponents.makeStyles({
|
|
|
1455
1488
|
opacity: 0.5,
|
|
1456
1489
|
cursor: 'grabbing',
|
|
1457
1490
|
},
|
|
1458
|
-
tHeadCellOver: Object.assign({ backgroundColor: reactComponents.tokens.colorNeutralStroke1 }, reactComponents.shorthands.border(reactComponents.tokens.strokeWidthThin, 'dashed', reactComponents.tokens.
|
|
1491
|
+
tHeadCellOver: Object.assign({ backgroundColor: reactComponents.tokens.colorNeutralStroke1 }, reactComponents.shorthands.border(reactComponents.tokens.strokeWidthThin, 'dashed', reactComponents.tokens.colorNeutralBackground2Pressed)),
|
|
1459
1492
|
tLeafHeadCellContent: Object.assign({ display: 'flex', alignContent: 'space-between', alignItems: 'center', justifyContent: 'space-between', cursor: 'pointer', width: '100%', height: '100%', minWidth: '1rem' }, reactComponents.shorthands.padding('3px', '4px')),
|
|
1460
1493
|
tNonLeafHeadCellContent: Object.assign({ display: 'flex', alignContent: 'center', alignItems: 'center', justifyContent: 'center', cursor: 'pointer', width: '100%', minWidth: '1rem' }, reactComponents.shorthands.padding('3px', '4px')),
|
|
1461
1494
|
tHeadContentBtn: Object.assign(Object.assign(Object.assign(Object.assign({}, reactComponents.shorthands.padding('0px', '0px', '0px', '0px')), { display: 'flex' }), reactComponents.shorthands.gap('5px')), { alignContent: 'space-between', alignItems: 'center', justifyContent: 'space-between', cursor: 'pointer', width: '100%', height: '100%', minWidth: '1rem' }),
|
|
1462
1495
|
tHeadMenuPopover: Object.assign(Object.assign({}, reactComponents.shorthands.padding('0px', '0px', '0px', '0px')), { width: '300px' }),
|
|
1463
|
-
resizer: Object.assign(Object.assign({}, reactComponents.shorthands.borderRight('1px', 'solid', reactComponents.tokens.
|
|
1464
|
-
borderRightWidth: '
|
|
1465
|
-
borderRightColor: reactComponents.tokens.
|
|
1496
|
+
resizer: Object.assign(Object.assign({}, reactComponents.shorthands.borderRight('1px', 'solid', reactComponents.tokens.colorBrandBackgroundInverted)), { width: '8px', position: 'absolute', top: 0, right: 0, bottom: 0, cursor: 'col-resize', resize: 'horizontal', ':hover': {
|
|
1497
|
+
borderRightWidth: '2px',
|
|
1498
|
+
borderRightColor: reactComponents.tokens.colorBrandBackgroundInvertedHover,
|
|
1466
1499
|
} }),
|
|
1467
1500
|
resizerActive: {
|
|
1468
|
-
borderRightWidth: '
|
|
1469
|
-
borderRightColor: reactComponents.tokens.
|
|
1501
|
+
borderRightWidth: '2px',
|
|
1502
|
+
borderRightColor: reactComponents.tokens.colorBrandBackgroundInvertedPressed,
|
|
1470
1503
|
},
|
|
1471
1504
|
});
|
|
1472
1505
|
|
|
@@ -1810,75 +1843,102 @@ const FilterDrawer = ({ drawerState, dispatch, table }) => {
|
|
|
1810
1843
|
table.setGlobalFilter('');
|
|
1811
1844
|
table.resetColumnFilters();
|
|
1812
1845
|
}, [table]);
|
|
1813
|
-
return (jsxRuntime.jsxs(reactComponents.InlineDrawer, { position: "end", open: drawerState.isFilterDrawerOpen, separator: true, children: [jsxRuntime.jsx(reactComponents.DrawerHeader, { children: jsxRuntime.jsx(reactComponents.DrawerHeaderTitle, { action: jsxRuntime.jsx(reactComponents.Button, { appearance: "subtle", "aria-label": "Close", icon: jsxRuntime.jsx(Dismiss24Regular, {}), onClick: () => dispatch({ type: "CLOSE_FILTER_DRAWER" }) }), children: "Advanced Filters" }) }), jsxRuntime.jsx(reactComponents.DrawerBody, { className: styles.drawerBody, children: headerGroups.map((headerGroup) => {
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
return null;
|
|
1817
|
-
return headerGroup.headers.map((header) => {
|
|
1818
|
-
const canFilter = header.column.getCanFilter();
|
|
1819
|
-
if (!canFilter)
|
|
1846
|
+
return (jsxRuntime.jsxs(reactComponents.InlineDrawer, { position: "end", open: drawerState.isFilterDrawerOpen, separator: true, children: [jsxRuntime.jsx(reactComponents.DrawerHeader, { children: jsxRuntime.jsx(reactComponents.DrawerHeaderTitle, { action: jsxRuntime.jsx(reactComponents.Button, { appearance: "subtle", "aria-label": "Close", icon: jsxRuntime.jsx(Dismiss24Regular, {}), onClick: () => dispatch({ type: "CLOSE_FILTER_DRAWER" }) }), children: "Advanced Filters" }) }), jsxRuntime.jsx(reactComponents.DrawerBody, { className: styles.drawerBody, children: jsxRuntime.jsx(reactComponents.Accordion, { multiple: true, collapsible: true, children: headerGroups.map((headerGroup) => {
|
|
1847
|
+
const canApplyFilter = headerGroup.depth === (headerGroups === null || headerGroups === void 0 ? void 0 : headerGroups.length) - 1;
|
|
1848
|
+
if (!canApplyFilter)
|
|
1820
1849
|
return null;
|
|
1821
|
-
return
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1850
|
+
return headerGroup.headers.map((header) => {
|
|
1851
|
+
const canFilter = header.column.getCanFilter();
|
|
1852
|
+
if (!canFilter)
|
|
1853
|
+
return null;
|
|
1854
|
+
return (jsxRuntime.jsx(reactControlFlow.Show, { when: header.column.getCanFilter(), children: jsxRuntime.jsxs(reactComponents.AccordionItem, { value: header.column.id, children: [jsxRuntime.jsx(reactComponents.AccordionHeader, { expandIconPosition: 'end', children: jsxRuntime.jsxs(reactComponents.Caption1Stronger, { children: ["Filter by", ' ', reactTable.flexRender(header.column.columnDef.header, header.getContext())] }) }), jsxRuntime.jsx(reactComponents.AccordionPanel, { children: jsxRuntime.jsx(Filter, { column: header.column, table: table }) })] }, header.column.id) }, header.column.id));
|
|
1855
|
+
});
|
|
1856
|
+
}) }) }), jsxRuntime.jsx(reactComponents.DrawerFooter, { children: jsxRuntime.jsx(reactComponents.Button, { icon: jsxRuntime.jsx(ClearFilterIcon, {}), onClick: resetAllFilters, style: { width: "100%" }, children: "Clear All Filters" }) })] }));
|
|
1857
|
+
};
|
|
1858
|
+
|
|
1859
|
+
const getHeaderCellPinningStyles = (column) => {
|
|
1860
|
+
const isPinned = column.getIsPinned();
|
|
1861
|
+
const isLastLeftPinnedColumn = isPinned === 'left' && column.getIsLastColumn('left');
|
|
1862
|
+
const isFirstRightPinnedColumn = isPinned === 'right' && column.getIsFirstColumn('right');
|
|
1863
|
+
const styles = {
|
|
1864
|
+
boxShadow: isLastLeftPinnedColumn
|
|
1865
|
+
? '-4px 0 4px -4px gray inset'
|
|
1866
|
+
: isFirstRightPinnedColumn
|
|
1867
|
+
? '4px 0 4px -4px gray inset'
|
|
1868
|
+
: undefined,
|
|
1869
|
+
left: isPinned === 'left' ? `${column.getStart('left')}px` : undefined,
|
|
1870
|
+
right: isPinned === 'right' ? `${column.getAfter('right')}px` : undefined,
|
|
1871
|
+
opacity: isPinned ? 0.95 : 1,
|
|
1872
|
+
position: isPinned ? 'sticky' : 'relative',
|
|
1873
|
+
width: column.getSize(),
|
|
1874
|
+
zIndex: isPinned ? 99 : 1,
|
|
1875
|
+
backgroundColor: reactComponents.tokens.colorNeutralCardBackgroundSelected,
|
|
1876
|
+
};
|
|
1877
|
+
return styles;
|
|
1878
|
+
};
|
|
1879
|
+
const getBodyCellPinningStyles = (column) => {
|
|
1880
|
+
const isPinned = column.getIsPinned();
|
|
1881
|
+
const isLastLeftPinnedColumn = isPinned === 'left' && column.getIsLastColumn('left');
|
|
1882
|
+
const isFirstRightPinnedColumn = isPinned === 'right' && column.getIsFirstColumn('right');
|
|
1883
|
+
const styles = {
|
|
1884
|
+
boxShadow: isLastLeftPinnedColumn
|
|
1885
|
+
? '-4px 0 4px -4px gray inset'
|
|
1886
|
+
: isFirstRightPinnedColumn
|
|
1887
|
+
? '4px 0 4px -4px gray inset'
|
|
1888
|
+
: undefined,
|
|
1889
|
+
left: isPinned === 'left' ? `${column.getStart('left')}px` : undefined,
|
|
1890
|
+
right: isPinned === 'right' ? `${column.getAfter('right')}px` : undefined,
|
|
1891
|
+
opacity: isPinned ? 0.95 : 1,
|
|
1892
|
+
position: isPinned ? 'sticky' : 'relative',
|
|
1893
|
+
width: column.getSize(),
|
|
1894
|
+
zIndex: isPinned ? 1 : 0,
|
|
1895
|
+
};
|
|
1896
|
+
return styles;
|
|
1826
1897
|
};
|
|
1827
1898
|
|
|
1828
1899
|
const SortAscIcon = bundleIcon$1(ArrowSortDown20Filled, ArrowSortDown20Regular);
|
|
1829
1900
|
const SortDescIcon = bundleIcon$1(ArrowSortUp20Filled, ArrowSortUp20Regular);
|
|
1830
|
-
const
|
|
1831
|
-
columnOrder.splice(columnOrder.indexOf(targetColumnId), 0, columnOrder.splice(columnOrder.indexOf(draggedColumnId), 1)[0]);
|
|
1832
|
-
return [...columnOrder];
|
|
1833
|
-
};
|
|
1901
|
+
const PinIcon = bundleIcon$1(PinFilled, PinRegular);
|
|
1834
1902
|
function HeaderCell({ header, table, hideMenu, headerDepth, totalNumberOfHeaderDepth, }) {
|
|
1835
1903
|
var _a;
|
|
1836
|
-
const { getState, setColumnOrder } = table;
|
|
1837
|
-
const { columnOrder } = getState();
|
|
1838
1904
|
const { column } = header;
|
|
1839
|
-
const
|
|
1840
|
-
|
|
1841
|
-
drop: (draggedColumn) => {
|
|
1842
|
-
const newColumnOrder = reorderColumn(draggedColumn.id, column.id, columnOrder);
|
|
1843
|
-
setColumnOrder(newColumnOrder);
|
|
1844
|
-
},
|
|
1845
|
-
collect: (monitor) => ({
|
|
1846
|
-
isOver: monitor.isOver(),
|
|
1847
|
-
}),
|
|
1848
|
-
});
|
|
1849
|
-
const [{ isDragging }, dragRef, previewRef] = reactDnd.useDrag({
|
|
1850
|
-
collect: (monitor) => ({
|
|
1851
|
-
isDragging: monitor.isDragging(),
|
|
1852
|
-
}),
|
|
1853
|
-
item: () => column,
|
|
1854
|
-
type: "column",
|
|
1905
|
+
const { isDragging, attributes, listeners, setNodeRef, transform, transition, } = sortable.useSortable({
|
|
1906
|
+
id: column.id
|
|
1855
1907
|
});
|
|
1908
|
+
const dndStyle = {
|
|
1909
|
+
width: header.column.getSize(),
|
|
1910
|
+
opacity: isDragging ? 0.8 : 1,
|
|
1911
|
+
// position: isDragging ? 'relative' : "sticky",
|
|
1912
|
+
transform: utilities.CSS.Translate.toString(transform), // translate instead of transform to avoid squishing
|
|
1913
|
+
// transition: 'width transform 0.2s ease-in-out',
|
|
1914
|
+
whiteSpace: 'wrap',
|
|
1915
|
+
zIndex: isDragging ? 100 : 99,
|
|
1916
|
+
transition
|
|
1917
|
+
};
|
|
1856
1918
|
const styles = useTableHeaderStyles();
|
|
1857
|
-
const canDragDrop = headerDepth === totalNumberOfHeaderDepth && !header.isPlaceholder;
|
|
1858
1919
|
const isLeafHeaders = headerDepth === totalNumberOfHeaderDepth;
|
|
1859
1920
|
if (header.isPlaceholder) {
|
|
1860
|
-
return (jsxRuntime.jsx("th", { colSpan: header.colSpan, className: styles.tHeadCell, children: header.column.getCanResize()
|
|
1921
|
+
return (jsxRuntime.jsx("th", { colSpan: header.colSpan, className: styles.tHeadCell, style: Object.assign(Object.assign({}, dndStyle), getHeaderCellPinningStyles(column)), ref: setNodeRef, children: jsxRuntime.jsx(reactControlFlow.Show, { when: header.column.getCanResize(), children: jsxRuntime.jsx("div", { onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler(), className: reactComponents.mergeClasses(styles.resizer, column.getIsResizing() && styles.resizerActive) }) }) }));
|
|
1861
1922
|
}
|
|
1862
|
-
return (jsxRuntime.jsxs("th", { colSpan: header.colSpan, className: reactComponents.mergeClasses(styles.tHeadCell, isLeafHeaders
|
|
1863
|
-
: styles.tHeadNonLeafCell, isDragging && styles.tHeadCellDragging, isOver && isLeafHeaders && styles.tHeadCellOver), children: [jsxRuntime.jsx("div", { className: styles.tHeadCellDraggable, ref: canDragDrop ? dropRef : undefined, children: jsxRuntime.jsxs("div", { className: isLeafHeaders
|
|
1923
|
+
return (jsxRuntime.jsxs("th", { colSpan: header.colSpan, className: reactComponents.mergeClasses(styles.tHeadCell, isLeafHeaders && styles.tHeadNonLeafCell, isDragging && styles.tHeadCellDragging), style: Object.assign(Object.assign({}, dndStyle), getHeaderCellPinningStyles(column)), ref: setNodeRef, children: [jsxRuntime.jsx("div", Object.assign({ className: styles.tHeadCellDraggable }, attributes, listeners, { children: jsxRuntime.jsxs("div", { className: isLeafHeaders
|
|
1864
1924
|
? styles.tLeafHeadCellContent
|
|
1865
|
-
: styles.tNonLeafHeadCellContent,
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1925
|
+
: styles.tNonLeafHeadCellContent, children: [jsxRuntime.jsx("div", { children: jsxRuntime.jsx(reactControlFlow.Show, { when: !header.isPlaceholder, children: jsxRuntime.jsxs(reactComponents.Button, { style: {
|
|
1926
|
+
display: 'flex',
|
|
1927
|
+
alignItems: 'center',
|
|
1928
|
+
justifyContent: 'left',
|
|
1929
|
+
flex: 1,
|
|
1930
|
+
}, onClick: (e) => {
|
|
1931
|
+
if (!header.column.getCanSort())
|
|
1932
|
+
return;
|
|
1933
|
+
header.column.toggleSorting(header.column.getIsSorted() === 'asc', e.ctrlKey);
|
|
1934
|
+
}, onDoubleClick: () => {
|
|
1935
|
+
if (!header.column.getCanGroup())
|
|
1936
|
+
return;
|
|
1937
|
+
header.column.getToggleGroupingHandler()();
|
|
1938
|
+
}, appearance: "transparent", className: styles.tHeadContentBtn, icon: (_a = {
|
|
1939
|
+
asc: (jsxRuntime.jsx("strong", { children: jsxRuntime.jsx(SortAscIcon, {}) })),
|
|
1940
|
+
desc: (jsxRuntime.jsx("strong", { children: jsxRuntime.jsx(SortDescIcon, {}) })),
|
|
1941
|
+
}[header.column.getIsSorted()]) !== null && _a !== void 0 ? _a : undefined, iconPosition: "after", children: [jsxRuntime.jsx("strong", { children: reactTable.flexRender(header.column.columnDef.header, header.getContext()) }), jsxRuntime.jsx(reactControlFlow.Show, { when: header.column.getIsGrouped(), children: jsxRuntime.jsx("strong", { children: jsxRuntime.jsx(GroupListRegular, {}) }) }), jsxRuntime.jsx(reactControlFlow.Show, { when: header.column.getIsFiltered(), children: jsxRuntime.jsx("strong", { children: jsxRuntime.jsx(FilterFilled, {}) }) }), jsxRuntime.jsx(reactControlFlow.Show, { when: header.column.getIsPinned(), children: jsxRuntime.jsx("strong", { children: jsxRuntime.jsx(PinRegular, {}) }) })] }) }) }), jsxRuntime.jsx(HeaderMenu, { header: header, table: table, hideMenu: hideMenu })] }) })), jsxRuntime.jsx(reactControlFlow.Show, { when: header.column.getCanResize(), children: jsxRuntime.jsx("div", { onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler(), className: reactComponents.mergeClasses(styles.resizer, column.getIsResizing() && styles.resizerActive) }) }), jsxRuntime.jsx(reactControlFlow.Show, { when: !isLeafHeaders, children: jsxRuntime.jsx("div", { className: styles.tHeadNonLeafCellFakeBorder }) })] }));
|
|
1882
1942
|
}
|
|
1883
1943
|
function HeaderMenu(props) {
|
|
1884
1944
|
const { header, table, hideMenu } = props;
|
|
@@ -1890,24 +1950,24 @@ function HeaderMenu(props) {
|
|
|
1890
1950
|
header.column.getCanFilter();
|
|
1891
1951
|
if (!canHavePopOver)
|
|
1892
1952
|
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: " " }));
|
|
1893
|
-
return (jsxRuntime.jsxs(reactComponents.Menu, { children: [jsxRuntime.jsx(reactComponents.MenuTrigger, { disableButtonEnhancement: true, children: jsxRuntime.jsx(reactComponents.MenuButton, { appearance: "transparent", "aria-label": "View Column Actions" }) }), jsxRuntime.jsx(reactComponents.MenuPopover, { className: styles.tHeadMenuPopover, children: jsxRuntime.jsxs(reactComponents.MenuList, { children: [header.column.getCanSort()
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1953
|
+
return (jsxRuntime.jsxs(reactComponents.Menu, { children: [jsxRuntime.jsx(reactComponents.MenuTrigger, { disableButtonEnhancement: true, children: jsxRuntime.jsx(reactComponents.MenuButton, { appearance: "transparent", "aria-label": "View Column Actions" }) }), jsxRuntime.jsx(reactComponents.MenuPopover, { className: styles.tHeadMenuPopover, children: jsxRuntime.jsxs(reactComponents.MenuList, { children: [jsxRuntime.jsx(reactControlFlow.Show, { when: header.column.getCanSort(), children: jsxRuntime.jsxs(reactComponents.MenuGroup, { children: [jsxRuntime.jsx(reactComponents.MenuItem, { onClick: (e) => {
|
|
1954
|
+
var _a;
|
|
1955
|
+
const isControlKeySelected = e.ctrlKey;
|
|
1956
|
+
(_a = header.column) === null || _a === void 0 ? void 0 : _a.toggleSorting(false, isControlKeySelected);
|
|
1957
|
+
}, icon: jsxRuntime.jsx(TextSortAscendingFilled, {}), disabled: header.column.getIsSorted() === 'asc', children: "Sort A to Z" }), jsxRuntime.jsx(reactComponents.MenuItem, { onClick: (e) => {
|
|
1958
|
+
var _a;
|
|
1959
|
+
const isControlKeySelected = e.ctrlKey;
|
|
1960
|
+
(_a = header.column) === null || _a === void 0 ? void 0 : _a.toggleSorting(true, isControlKeySelected);
|
|
1961
|
+
}, icon: jsxRuntime.jsx(TextSortDescendingFilled, {}), disabled: header.column.getIsSorted() === 'desc', children: "Sort Z to A" }), jsxRuntime.jsx(reactComponents.MenuDivider, {})] }, 'sort-group') }), jsxRuntime.jsx(reactControlFlow.Show, { when: header.column.getCanGroup(), children: jsxRuntime.jsxs(reactComponents.MenuGroup, { children: [!header.column.getIsGrouped() && (jsxRuntime.jsxs(reactComponents.MenuItem, { onClick: () => header.column.getToggleGroupingHandler()(), icon: jsxRuntime.jsx(GroupFilled, {}), children: ["Group by", ' ', reactTable.flexRender(header.column.columnDef.header, header.getContext())] })), header.column.getIsGrouped() && (jsxRuntime.jsxs(reactComponents.MenuItem, { onClick: () => header.column.getToggleGroupingHandler()(), icon: jsxRuntime.jsx(GroupDismissFilled, {}), children: ["Remove Grouping on", ' ', reactTable.flexRender(header.column.columnDef.header, header.getContext())] })), jsxRuntime.jsx(reactComponents.MenuDivider, {})] }, 'grouping-group') }), jsxRuntime.jsxs(reactControlFlow.Show, { when: header.column.getCanPin(), children: [jsxRuntime.jsxs(reactComponents.Menu, { children: [jsxRuntime.jsx(reactComponents.MenuTrigger, { disableButtonEnhancement: true, children: jsxRuntime.jsx(reactComponents.MenuItem, { icon: jsxRuntime.jsx(PinIcon, {}), children: "Pin Column" }) }), jsxRuntime.jsx(reactComponents.MenuPopover, { children: jsxRuntime.jsxs(reactComponents.MenuList, { children: [jsxRuntime.jsx(reactControlFlow.Show, { when: ['left', 'right'].includes(header.column.getIsPinned()), children: jsxRuntime.jsx(reactComponents.MenuItem, { onClick: () => {
|
|
1962
|
+
var _a;
|
|
1963
|
+
(_a = header.column) === null || _a === void 0 ? void 0 : _a.pin(false);
|
|
1964
|
+
}, icon: jsxRuntime.jsx(PinOffRegular, {}), children: "No Pin" }) }), jsxRuntime.jsx(reactComponents.MenuItem, { onClick: () => {
|
|
1965
|
+
var _a;
|
|
1966
|
+
(_a = header.column) === null || _a === void 0 ? void 0 : _a.pin('left');
|
|
1967
|
+
}, icon: jsxRuntime.jsx(ArrowStepInLeftRegular, {}), disabled: header.column.getIsPinned() === 'left', children: "Pin Left" }), jsxRuntime.jsx(reactComponents.MenuItem, { onClick: () => {
|
|
1968
|
+
var _a;
|
|
1969
|
+
(_a = header.column) === null || _a === void 0 ? void 0 : _a.pin('right');
|
|
1970
|
+
}, icon: jsxRuntime.jsx(ArrowStepInRightRegular, {}), disabled: header.column.getIsPinned() === 'right', children: "Pin Right" })] }) })] }), jsxRuntime.jsx(reactComponents.MenuDivider, {})] }), jsxRuntime.jsx(reactControlFlow.Show, { when: header.column.getCanFilter(), children: jsxRuntime.jsxs(reactComponents.MenuGroup, { children: [jsxRuntime.jsxs(reactComponents.MenuGroupHeader, { children: ["Filter by", ' ', reactTable.flexRender(header.column.columnDef.header, header.getContext())] }), jsxRuntime.jsx(Filter, { column: header.column, table: table })] }, 'filter-group') })] }) })] }));
|
|
1911
1971
|
}
|
|
1912
1972
|
|
|
1913
1973
|
function HeaderRow(props) {
|
|
@@ -1923,7 +1983,7 @@ function HeaderRow(props) {
|
|
|
1923
1983
|
function TableHeader(props) {
|
|
1924
1984
|
const styles = useTableHeaderStyles();
|
|
1925
1985
|
const { table, headerGroups, rowSelectionMode } = props;
|
|
1926
|
-
return (jsxRuntime.jsx("thead", { className: styles.tHead, children: headerGroups === null || headerGroups === void 0 ? void 0 : headerGroups.map((headerGroup) => (jsxRuntime.jsx(HeaderRow, { table: table, rowSelectionMode: rowSelectionMode, headerGroup: headerGroup, headerGroupsLength: headerGroups.length }, headerGroup.id))) }));
|
|
1986
|
+
return (jsxRuntime.jsx("thead", { className: styles.tHead, style: { zIndex: 99 }, children: headerGroups === null || headerGroups === void 0 ? void 0 : headerGroups.map((headerGroup) => (jsxRuntime.jsx(HeaderRow, { table: table, rowSelectionMode: rowSelectionMode, headerGroup: headerGroup, headerGroupsLength: headerGroups.length }, headerGroup.id))) }));
|
|
1927
1987
|
}
|
|
1928
1988
|
|
|
1929
1989
|
const useLoadingStyles = reactComponents.makeStyles({
|
|
@@ -1996,75 +2056,149 @@ const useTableBodyStyles = reactComponents.makeStyles({
|
|
|
1996
2056
|
backgroundColor: reactComponents.tokens.colorBrandBackground2Hover,
|
|
1997
2057
|
} }),
|
|
1998
2058
|
tBodyCell: Object.assign(Object.assign({ backgroundColor: "transparent" }, reactComponents.shorthands.padding("2px", "4px")), { minHeight: "35px", height: "35px" }),
|
|
2059
|
+
tBodyRowPinnedCell: {
|
|
2060
|
+
backgroundColor: reactComponents.tokens.colorPaletteYellowBackground2,
|
|
2061
|
+
":hover": {
|
|
2062
|
+
backgroundColor: reactComponents.tokens.colorPaletteMarigoldBackground2,
|
|
2063
|
+
}
|
|
2064
|
+
},
|
|
2065
|
+
tBodyPinnedCell: {
|
|
2066
|
+
backgroundColor: reactComponents.tokens.colorNeutralBackground3,
|
|
2067
|
+
":hover": {
|
|
2068
|
+
backgroundColor: reactComponents.tokens.colorNeutralBackground3Hover,
|
|
2069
|
+
}
|
|
2070
|
+
},
|
|
2071
|
+
tBodySelectedCell: {
|
|
2072
|
+
backgroundColor: reactComponents.tokens.colorBrandBackground2,
|
|
2073
|
+
":hover": {
|
|
2074
|
+
backgroundColor: reactComponents.tokens.colorBrandBackground2Hover,
|
|
2075
|
+
}
|
|
2076
|
+
},
|
|
1999
2077
|
});
|
|
2000
2078
|
|
|
2001
2079
|
function TableCell({ cell, row }) {
|
|
2002
2080
|
var _a;
|
|
2003
2081
|
const styles = useTableBodyStyles();
|
|
2082
|
+
const isSelected = row.getIsSelected();
|
|
2083
|
+
const isRowPinned = row.getIsPinned();
|
|
2084
|
+
const isCellPinned = cell.column.getIsPinned();
|
|
2085
|
+
const { isDragging, transition, setNodeRef, transform } = sortable.useSortable({
|
|
2086
|
+
id: cell.column.id,
|
|
2087
|
+
});
|
|
2004
2088
|
const tdStyle = {
|
|
2005
2089
|
width: cell.column.getSize(),
|
|
2090
|
+
opacity: isDragging ? "0.8" : "1",
|
|
2091
|
+
transform: utilities.CSS.Translate.toString(transform),
|
|
2092
|
+
// transition: 'width transform 0.2s ease-in-out',
|
|
2093
|
+
zIndex: isDragging ? 1 : 0,
|
|
2094
|
+
transition
|
|
2006
2095
|
};
|
|
2096
|
+
const cellClassNames = reactComponents.mergeClasses(styles.tBodyCell, isCellPinned && styles.tBodyPinnedCell, isSelected && styles.tBodySelectedCell, isRowPinned && styles.tBodyRowPinnedCell);
|
|
2097
|
+
const styleStyles = Object.assign(Object.assign({}, tdStyle), getBodyCellPinningStyles(cell.column));
|
|
2007
2098
|
if (cell.getIsPlaceholder()) {
|
|
2008
|
-
return jsxRuntime.jsx("td", { style:
|
|
2099
|
+
return jsxRuntime.jsx("td", { style: styleStyles, className: cellClassNames, ref: setNodeRef }, cell.id);
|
|
2009
2100
|
}
|
|
2010
2101
|
if (cell.getIsGrouped()) {
|
|
2011
|
-
return (jsxRuntime.jsx("td", { style:
|
|
2102
|
+
return (jsxRuntime.jsx("td", { style: styleStyles, className: cellClassNames, ref: setNodeRef, children: jsxRuntime.jsx(reactComponents.Button, { onClick: row.getToggleExpandedHandler(), style: {
|
|
2012
2103
|
cursor: row.getCanExpand() ? 'pointer' : 'normal',
|
|
2013
2104
|
textAlign: 'left',
|
|
2014
2105
|
}, appearance: "transparent", icon: row.getIsExpanded() ? jsxRuntime.jsx(GroupExpandedIcon, {}) : jsxRuntime.jsx(GroupCollapsedIcon, {}), children: jsxRuntime.jsxs("strong", { children: [reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()), " (", row.subRows.length, ")"] }) }) }, cell.id));
|
|
2015
2106
|
}
|
|
2016
2107
|
if (cell.getIsAggregated()) {
|
|
2017
|
-
return (jsxRuntime.jsx("td", { style:
|
|
2108
|
+
return (jsxRuntime.jsx("td", { style: styleStyles, className: cellClassNames, ref: setNodeRef, children: jsxRuntime.jsx("strong", { children: reactTable.flexRender((_a = cell.column.columnDef.aggregatedCell) !== null && _a !== void 0 ? _a : cell.column.columnDef.cell, cell.getContext()) }) }, cell.id));
|
|
2018
2109
|
}
|
|
2019
|
-
return (jsxRuntime.jsx("td", { style:
|
|
2110
|
+
return (jsxRuntime.jsx("td", { style: styleStyles, className: cellClassNames, ref: setNodeRef, children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id));
|
|
2020
2111
|
}
|
|
2021
2112
|
|
|
2022
|
-
function TableRow({ row, rowSelectionMode }) {
|
|
2113
|
+
function TableRow({ row, rowSelectionMode, style }) {
|
|
2023
2114
|
const styles = useTableBodyStyles();
|
|
2024
2115
|
return (jsxRuntime.jsxs("tr", { className: row.getIsSelected() || row.getIsAllSubRowsSelected()
|
|
2025
2116
|
? styles.tBodySelectedRow
|
|
2026
|
-
: styles.tBodyRow, children: [rowSelectionMode
|
|
2027
|
-
|
|
2028
|
-
|
|
2117
|
+
: styles.tBodyRow, style: style, children: [jsxRuntime.jsxs(reactControlFlow.Switch, { when: rowSelectionMode, children: [jsxRuntime.jsx(reactControlFlow.Case, { value: 'multiple', children: jsxRuntime.jsx("td", { className: styles.tBodyCell, "aria-label": "Select Row Column", children: jsxRuntime.jsx(reactComponents.Checkbox, { checked: row.getIsSomeSelected()
|
|
2118
|
+
? 'mixed'
|
|
2119
|
+
: row.getIsSelected() || row.getIsAllSubRowsSelected(), disabled: !row.getCanSelect(), onChange: row.getToggleSelectedHandler(), "aria-label": "Select Row" }) }) }), jsxRuntime.jsx(reactControlFlow.Case, { value: 'single', children: jsxRuntime.jsx("td", { className: styles.tBodyCell, "aria-label": "Select Row Column", children: jsxRuntime.jsx(reactComponents.Radio, { checked: row.getIsSelected(), disabled: !row.getCanSelect(), onChange: row.getToggleSelectedHandler(), "aria-label": "Select Row" }) }) })] }), row.getVisibleCells().map((cell) => (jsxRuntime.jsx(TableCell, { cell: cell, row: row }, cell.id)))] }, row.id));
|
|
2120
|
+
}
|
|
2121
|
+
function PinnedRow({ row, rowSelectionMode, style, bottomRowLength }) {
|
|
2122
|
+
const styles = useTableBodyStyles();
|
|
2123
|
+
return (jsxRuntime.jsxs("tr", { className: row.getIsSelected() || row.getIsAllSubRowsSelected()
|
|
2124
|
+
? styles.tBodySelectedRow
|
|
2125
|
+
: styles.tBodyRow, style: {
|
|
2126
|
+
backgroundColor: 'goldenrod',
|
|
2127
|
+
position: 'sticky',
|
|
2128
|
+
top: row.getIsPinned() === 'top'
|
|
2129
|
+
? `${row.getPinnedIndex() * 35 + 48}px`
|
|
2130
|
+
: undefined,
|
|
2131
|
+
bottom: row.getIsPinned() === 'bottom'
|
|
2132
|
+
? `${((bottomRowLength || 0) - 1 - row.getPinnedIndex()) * 35}px`
|
|
2133
|
+
: undefined
|
|
2134
|
+
}, children: [jsxRuntime.jsxs(reactControlFlow.Switch, { when: rowSelectionMode, children: [jsxRuntime.jsx(reactControlFlow.Case, { value: 'multiple', children: jsxRuntime.jsx("td", { className: styles.tBodyCell, "aria-label": "Select Row Column", children: jsxRuntime.jsx(reactComponents.Checkbox, { checked: row.getIsSomeSelected()
|
|
2135
|
+
? 'mixed'
|
|
2136
|
+
: row.getIsSelected() || row.getIsAllSubRowsSelected(), disabled: !row.getCanSelect(), onChange: row.getToggleSelectedHandler(), "aria-label": "Select Row" }) }) }), jsxRuntime.jsx(reactControlFlow.Case, { value: 'single', children: jsxRuntime.jsx("td", { className: styles.tBodyCell, "aria-label": "Select Row Column", children: jsxRuntime.jsx(reactComponents.Radio, { checked: row.getIsSelected(), disabled: !row.getCanSelect(), onChange: row.getToggleSelectedHandler(), "aria-label": "Select Row" }) }) })] }), row.getVisibleCells().map(cell => {
|
|
2137
|
+
return (jsxRuntime.jsx(TableCell, { cell: cell, row: row }, cell.id));
|
|
2138
|
+
})] }, row.id));
|
|
2029
2139
|
}
|
|
2030
2140
|
|
|
2031
2141
|
function TableBody(props) {
|
|
2032
|
-
var _a, _b;
|
|
2142
|
+
var _a, _b, _c;
|
|
2033
2143
|
const styles = useTableBodyStyles();
|
|
2034
|
-
const {
|
|
2035
|
-
const
|
|
2144
|
+
const { table, tableContainerRef } = props;
|
|
2145
|
+
const rowSelectionMode = (_a = table.options.meta) === null || _a === void 0 ? void 0 : _a.rowSelectionMode;
|
|
2146
|
+
let rows = [];
|
|
2147
|
+
let topRows = [];
|
|
2148
|
+
let bottomRows = [];
|
|
2149
|
+
try {
|
|
2150
|
+
rows = table.getCenterRows();
|
|
2151
|
+
topRows = table.getTopRows();
|
|
2152
|
+
bottomRows = table.getBottomRows();
|
|
2153
|
+
}
|
|
2154
|
+
catch (error) {
|
|
2155
|
+
rows = [];
|
|
2156
|
+
topRows = [];
|
|
2157
|
+
bottomRows = [];
|
|
2158
|
+
}
|
|
2159
|
+
const rowVirtualizer = reactVirtual.useVirtual({
|
|
2160
|
+
parentRef: tableContainerRef,
|
|
2161
|
+
size: rows.length,
|
|
2162
|
+
overscan: 10,
|
|
2163
|
+
});
|
|
2164
|
+
const { virtualItems: virtualRows, totalSize } = rowVirtualizer;
|
|
2165
|
+
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;
|
|
2036
2166
|
const paddingBottom = virtualRows.length > 0
|
|
2037
|
-
? totalSize - (((
|
|
2167
|
+
? totalSize - (((_c = virtualRows === null || virtualRows === void 0 ? void 0 : virtualRows[virtualRows.length - 1]) === null || _c === void 0 ? void 0 : _c.end) || 0)
|
|
2038
2168
|
: 0;
|
|
2039
|
-
return (jsxRuntime.jsxs(
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2169
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(reactControlFlow.Show, { when: (topRows === null || topRows === void 0 ? void 0 : topRows.length) > 0, children: jsxRuntime.jsx("thead", { style: {
|
|
2170
|
+
position: "sticky",
|
|
2171
|
+
top: 0,
|
|
2172
|
+
zIndex: 99
|
|
2173
|
+
}, children: jsxRuntime.jsx(reactControlFlow.For, { each: topRows, children: (row, index) => (jsxRuntime.jsx(PinnedRow, { row: row, rowSelectionMode: rowSelectionMode, bottomRowLength: bottomRows === null || bottomRows === void 0 ? void 0 : bottomRows.length }, row.id)) }) }) }), jsxRuntime.jsxs("tbody", { className: styles.tBody, children: [paddingTop > 0 && (jsxRuntime.jsx("tr", { className: styles.tBodyRow, "aria-hidden": true, children: jsxRuntime.jsx("td", { style: { height: `${paddingTop}px` } }) })), jsxRuntime.jsx(reactControlFlow.For, { each: virtualRows || [], children: (virtualRow) => {
|
|
2174
|
+
const row = rows[virtualRow.index];
|
|
2175
|
+
return (jsxRuntime.jsx(TableRow, { row: row, rowSelectionMode: rowSelectionMode }, row.id));
|
|
2176
|
+
} }), paddingBottom > 0 && (jsxRuntime.jsx("tr", { className: styles.tBodyRow, "aria-hidden": true, children: jsxRuntime.jsx("td", { style: { height: `${paddingBottom}px` } }) }))] }), jsxRuntime.jsx(reactControlFlow.Show, { when: rowSelectionMode === 'multiple' && (rows === null || rows === void 0 ? void 0 : rows.length) > 0, children: jsxRuntime.jsx("tfoot", { style: {
|
|
2177
|
+
position: "sticky",
|
|
2178
|
+
bottom: 0,
|
|
2179
|
+
zIndex: 99
|
|
2180
|
+
}, children: jsxRuntime.jsxs("tr", { style: { backgroundColor: "white" }, children: [jsxRuntime.jsx("td", { className: "p-1", children: jsxRuntime.jsx(reactComponents.Checkbox, { checked: table.getIsSomePageRowsSelected()
|
|
2181
|
+
? 'mixed'
|
|
2182
|
+
: table.getIsAllPageRowsSelected(), onChange: table.getToggleAllPageRowsSelectedHandler(), "aria-label": "Select All Current Page Rows", title: 'Select All Current Page Rows' }) }), jsxRuntime.jsxs("td", { colSpan: 20, children: [table.getIsAllPageRowsSelected() ? 'Unselect' : 'Select', " All Current Page Rows (", table.getRowModel().rows.length, ")"] })] }) }) }), jsxRuntime.jsx(reactControlFlow.Show, { when: (bottomRows === null || bottomRows === void 0 ? void 0 : bottomRows.length) > 0, children: jsxRuntime.jsx("tfoot", { style: {
|
|
2183
|
+
position: "sticky",
|
|
2184
|
+
bottom: 0,
|
|
2185
|
+
zIndex: 99
|
|
2186
|
+
}, children: jsxRuntime.jsx(reactControlFlow.For, { each: bottomRows, children: (row) => (jsxRuntime.jsx(PinnedRow, { row: row, rowSelectionMode: rowSelectionMode, bottomRowLength: bottomRows === null || bottomRows === void 0 ? void 0 : bottomRows.length }, row.id)) }) }) })] }));
|
|
2043
2187
|
}
|
|
2044
2188
|
|
|
2045
2189
|
const TableContainer = (props) => {
|
|
2046
2190
|
var _a, _b;
|
|
2047
2191
|
const styles = useTableStaticStyles();
|
|
2048
|
-
const { table
|
|
2192
|
+
const { table } = props;
|
|
2193
|
+
const { tableHeight, rowSelectionMode } = table.options.meta || {};
|
|
2049
2194
|
const tableContainerRef = React__namespace.useRef(null);
|
|
2050
|
-
const { rows } = table.getRowModel();
|
|
2051
|
-
const rowVirtualizer = reactVirtual.useVirtual({
|
|
2052
|
-
parentRef: tableContainerRef,
|
|
2053
|
-
size: rows.length,
|
|
2054
|
-
overscan: 5,
|
|
2055
|
-
});
|
|
2056
|
-
const { virtualItems: virtualRows, totalSize } = rowVirtualizer;
|
|
2195
|
+
const { rows: { length: itemLength } } = table.getRowModel();
|
|
2057
2196
|
const headerGroups = table.getHeaderGroups();
|
|
2058
2197
|
// utilities
|
|
2059
|
-
const isLoading = props.isLoading &&
|
|
2198
|
+
const isLoading = props.isLoading && itemLength === 0;
|
|
2060
2199
|
const noItems = !isLoading && ((_a = props.data) === null || _a === void 0 ? void 0 : _a.length) === 0;
|
|
2061
|
-
const noSearchResult = !isLoading && ((_b = props === null || props === void 0 ? void 0 : props.data) === null || _b === void 0 ? void 0 : _b.length) > 0 &&
|
|
2062
|
-
return (jsxRuntime.jsxs("div", { ref: tableContainerRef, className: styles.tableContainer, children: [jsxRuntime.jsxs("table", { className: styles.table, "aria-label": "Data Grid", children: [jsxRuntime.jsx(TableHeader, { table: table, rowSelectionMode: rowSelectionMode, headerGroups: headerGroups }), jsxRuntime.jsx(TableBody, {
|
|
2063
|
-
!isLoading &&
|
|
2064
|
-
!noItems &&
|
|
2065
|
-
!noSearchResult && (jsxRuntime.jsx("tfoot", { className: styles.tFoot, children: jsxRuntime.jsxs("tr", { children: [jsxRuntime.jsx("td", { className: "p-1", children: jsxRuntime.jsx(reactComponents.Checkbox, { checked: table.getIsSomePageRowsSelected()
|
|
2066
|
-
? 'mixed'
|
|
2067
|
-
: table.getIsAllPageRowsSelected(), onChange: table.getToggleAllPageRowsSelectedHandler(), "aria-label": "Select All Current Page Rows", title: 'Select All Current Page Rows' }) }), jsxRuntime.jsxs("td", { colSpan: 20, children: [table.getIsAllPageRowsSelected() ? 'Unselect' : 'Select', " All Current Page Rows (", table.getRowModel().rows.length, ")"] })] }) }))] }), isLoading && jsxRuntime.jsx(Loading, {}), noItems && jsxRuntime.jsx(NoItemGrid, { message: props.noItemPage }), noSearchResult && jsxRuntime.jsx(NoSearchResult, { message: props.noFilterMatchPage })] }));
|
|
2200
|
+
const noSearchResult = !isLoading && ((_b = props === null || props === void 0 ? void 0 : props.data) === null || _b === void 0 ? void 0 : _b.length) > 0 && itemLength === 0;
|
|
2201
|
+
return (jsxRuntime.jsxs("div", { ref: tableContainerRef, className: styles.tableContainer, style: { height: tableHeight }, children: [jsxRuntime.jsxs("table", { className: styles.table, "aria-label": "Data Grid", style: { width: table.getTotalSize(), minWidth: "100%" }, children: [jsxRuntime.jsx(TableHeader, { table: table, rowSelectionMode: rowSelectionMode, headerGroups: headerGroups }), jsxRuntime.jsx(TableBody, { table: table, tableContainerRef: tableContainerRef })] }), jsxRuntime.jsxs(reactControlFlow.Switch, { when: true, children: [jsxRuntime.jsx(reactControlFlow.Case, { value: isLoading, children: jsxRuntime.jsx(Loading, {}) }), jsxRuntime.jsx(reactControlFlow.Case, { value: noItems, children: jsxRuntime.jsx(NoItemGrid, { message: props.noItemPage }) }), jsxRuntime.jsx(reactControlFlow.Case, { value: noSearchResult, children: jsxRuntime.jsx(NoSearchResult, { message: props.noFilterMatchPage }) })] })] }));
|
|
2068
2202
|
};
|
|
2069
2203
|
|
|
2070
2204
|
const ViewSaveForm = (props) => {
|
|
@@ -2126,29 +2260,20 @@ const useFilterDrawerStyles = reactComponents.makeStyles({
|
|
|
2126
2260
|
} }),
|
|
2127
2261
|
});
|
|
2128
2262
|
const ViewsDrawer = (props) => {
|
|
2129
|
-
const { table, drawerState, dispatch, tableViews, applyTableState, resetToGridDefaultView
|
|
2130
|
-
const
|
|
2263
|
+
const { table, drawerState, dispatch, tableViews, applyTableState, resetToGridDefaultView } = props;
|
|
2264
|
+
const { onTableViewDelete, onTableViewSave } = table.options.meta || {};
|
|
2131
2265
|
const [checkedValues, setCheckedValues] = React__namespace.useState({ font: ["calibri"] });
|
|
2132
2266
|
const onChange = (e, { name, checkedItems }) => {
|
|
2133
2267
|
setCheckedValues((s) => (Object.assign(Object.assign({}, s), { [name]: checkedItems })));
|
|
2134
2268
|
};
|
|
2135
|
-
|
|
2136
|
-
// table.setGlobalFilter('');
|
|
2137
|
-
// table.resetColumnFilters();
|
|
2138
|
-
// }, [table]);
|
|
2139
|
-
// const resetAllGrouping = React.useCallback(() => {
|
|
2140
|
-
// table.resetGrouping();
|
|
2141
|
-
// }, [table]);
|
|
2142
|
-
// const clearAllSelection = React.useCallback(() => {
|
|
2143
|
-
// table.toggleAllRowsSelected(false);
|
|
2144
|
-
// }, [table]);
|
|
2269
|
+
const styles = useFilterDrawerStyles();
|
|
2145
2270
|
return (jsxRuntime.jsxs(reactComponents.InlineDrawer, { position: "end", open: drawerState.isViewsDrawerOpen, separator: true, children: [jsxRuntime.jsx(reactComponents.DrawerHeader, { children: jsxRuntime.jsx(reactComponents.DrawerHeaderTitle, { action: jsxRuntime.jsx(reactComponents.Button, { appearance: "subtle", "aria-label": "Close", icon: jsxRuntime.jsx(Dismiss24Regular, {}), onClick: () => dispatch({ type: "CLOSE_VIEW_DRAWER" }) }), children: "Table Views" }) }), jsxRuntime.jsxs(reactComponents.DrawerBody, { className: styles.drawerBody, children: [onTableViewSave && jsxRuntime.jsx(ViewSaveForm, { mode: 'create', getTableState: table.getState, onSave: onTableViewSave }), jsxRuntime.jsxs(reactComponents.MenuList, { checkedValues: checkedValues, onCheckedValueChange: onChange, children: [jsxRuntime.jsx(reactComponents.MenuItemRadio, { name: 'table-views', value: 'Default View', icon: jsxRuntime.jsx(ViewDesktop20Filled, {}), onClick: resetToGridDefaultView, children: "Default View" }), tableViews.length > 0 && jsxRuntime.jsx(reactComponents.MenuDivider, { children: "Additional Views" }), tableViews.map((view) => {
|
|
2146
2271
|
return (jsxRuntime.jsxs("div", { style: {
|
|
2147
2272
|
display: 'flex',
|
|
2148
2273
|
justifyContent: 'space-between',
|
|
2149
2274
|
alignItems: 'center',
|
|
2150
2275
|
width: '100%',
|
|
2151
|
-
}, children: [jsxRuntime.jsx(reactComponents.MenuItemRadio, { name: "table-views", value: view.viewName, onClick: () => applyTableState(view.tableState), icon: jsxRuntime.jsx(ViewDesktop20Regular, {}), children: view.viewName }),
|
|
2276
|
+
}, children: [jsxRuntime.jsx(reactComponents.MenuItemRadio, { name: "table-views", value: view.viewName, onClick: () => applyTableState(view.tableState), icon: jsxRuntime.jsx(ViewDesktop20Regular, {}), children: view.viewName }), onTableViewDelete && (view === null || view === void 0 ? void 0 : view.isViewOwner) && (jsxRuntime.jsx(reactComponents.Button, { appearance: "subtle", "aria-label": "Close", icon: jsxRuntime.jsx(Dismiss24Regular, {}), onClick: () => onTableViewDelete === null || onTableViewDelete === void 0 ? void 0 : onTableViewDelete(view) }))] }, view.id + view.viewName));
|
|
2152
2277
|
})] })] }), jsxRuntime.jsx(reactComponents.DrawerFooter, { children: jsxRuntime.jsxs(reactComponents.MenuList, { children: [jsxRuntime.jsx(reactComponents.MenuDivider, {}), jsxRuntime.jsx(reactComponents.MenuItem, { icon: jsxRuntime.jsx(ClearFilterIcon, {}), onClick: resetToGridDefaultView, children: "Reset to Default View" })] }) })] }));
|
|
2153
2278
|
};
|
|
2154
2279
|
|
|
@@ -2187,12 +2312,48 @@ function AdvancedTable(props, ref) {
|
|
|
2187
2312
|
isFilterDrawerOpen: false,
|
|
2188
2313
|
isViewsDrawerOpen: false
|
|
2189
2314
|
});
|
|
2190
|
-
|
|
2315
|
+
const { getState, setColumnOrder } = table;
|
|
2316
|
+
const { columnOrder } = getState();
|
|
2317
|
+
function handleDragEnd(event) {
|
|
2318
|
+
const { active, over } = event;
|
|
2319
|
+
if (active && over && (active === null || active === void 0 ? void 0 : active.id) !== (over === null || over === void 0 ? void 0 : over.id)) {
|
|
2320
|
+
setColumnOrder((items) => {
|
|
2321
|
+
const oldIndex = items.indexOf(active === null || active === void 0 ? void 0 : active.id);
|
|
2322
|
+
const newIndex = items.indexOf(over === null || over === void 0 ? void 0 : over.id);
|
|
2323
|
+
return sortable.arrayMove(items, oldIndex, newIndex);
|
|
2324
|
+
});
|
|
2325
|
+
}
|
|
2326
|
+
}
|
|
2327
|
+
const pointerSensor = core.useSensor(core.PointerSensor, {
|
|
2328
|
+
activationConstraint: {
|
|
2329
|
+
distance: 0.01
|
|
2330
|
+
}
|
|
2331
|
+
});
|
|
2332
|
+
const mouseSensor = core.useSensor(core.MouseSensor);
|
|
2333
|
+
const touchSensor = core.useSensor(core.TouchSensor);
|
|
2334
|
+
const keyboardSensor = core.useSensor(core.KeyboardSensor);
|
|
2335
|
+
const sensors = core.useSensors(mouseSensor, touchSensor, keyboardSensor, pointerSensor);
|
|
2336
|
+
return (jsxRuntime.jsx(core.DndContext, { collisionDetection: core.closestCenter, modifiers: [modifiers.restrictToHorizontalAxis], onDragEnd: handleDragEnd, sensors: sensors, children: jsxRuntime.jsxs(sortable.SortableContext, { items: columnOrder, strategy: sortable.horizontalListSortingStrategy, children: [jsxRuntime.jsx(reactControlFlow.Show, { when: !props.disableTableHeader, children: jsxRuntime.jsx(GridHeader, { table: table, gridTitle: props.gridTitle, headerMenu: headerMenu, globalFilter: globalFilter, setGlobalFilter: setGlobalFilter, applyTableState: applyTableState, drawerState: drawerState, dispatch: dispatch }) }), jsxRuntime.jsxs("div", { style: { display: 'flex' }, children: [jsxRuntime.jsx(TableContainer, { table: table, data: props.data, isLoading: props.isLoading || false, noFilterMatchPage: props.noFilterMatchPage, noItemPage: props.noItemPage }), jsxRuntime.jsx(FilterDrawer, { drawerState: drawerState, dispatch: dispatch, table: table }), jsxRuntime.jsx(ViewsDrawer, { table: table, drawerState: drawerState, dispatch: dispatch, tableViews: tableViews, applyTableState: applyTableState, resetToGridDefaultView: resetToDefaultView })] }), jsxRuntime.jsx(Pagination, { table: table })] }) }));
|
|
2191
2337
|
}
|
|
2192
2338
|
const ForwardedAdvancedTable = React__namespace.forwardRef(AdvancedTable);
|
|
2193
2339
|
|
|
2340
|
+
/* eslint-disable */
|
|
2341
|
+
function useSkipper() {
|
|
2342
|
+
const shouldSkipRef = React__namespace.useRef(true);
|
|
2343
|
+
const shouldSkip = shouldSkipRef.current;
|
|
2344
|
+
// Wrap a function with this to skip a pagination reset temporarily
|
|
2345
|
+
const skip = React__namespace.useCallback(() => {
|
|
2346
|
+
shouldSkipRef.current = false;
|
|
2347
|
+
}, []);
|
|
2348
|
+
React__namespace.useEffect(() => {
|
|
2349
|
+
shouldSkipRef.current = true;
|
|
2350
|
+
});
|
|
2351
|
+
return [shouldSkip, skip];
|
|
2352
|
+
}
|
|
2353
|
+
|
|
2194
2354
|
Object.defineProperty(exports, 'createColumnHelper', {
|
|
2195
2355
|
enumerable: true,
|
|
2196
2356
|
get: function () { return reactTable.createColumnHelper; }
|
|
2197
2357
|
});
|
|
2198
2358
|
exports.Table = ForwardedAdvancedTable;
|
|
2359
|
+
exports.useSkipper = useSkipper;
|