@prt-ts/fluent-react-table-v2 9.46.8-build.4.0 → 9.46.8-build.5.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.
Files changed (33) hide show
  1. package/index.cjs.js +352 -190
  2. package/index.esm.js +353 -192
  3. package/package.json +8 -4
  4. package/src/lib/components/GridContainer.d.ts +3 -2
  5. package/src/lib/components/filters/Filter.d.ts +1 -1
  6. package/src/lib/components/filters/FilterDate.d.ts +3 -3
  7. package/src/lib/components/filters/FilterDateRange.d.ts +3 -3
  8. package/src/lib/components/filters/FilterDrawer.d.ts +3 -3
  9. package/src/lib/components/filters/FilterMultiSelectCheckbox.d.ts +1 -1
  10. package/src/lib/components/filters/FilterNumberRange.d.ts +3 -3
  11. package/src/lib/components/filters/FilterSelectRadio.d.ts +1 -1
  12. package/src/lib/components/grid-header/GridHeader.d.ts +3 -3
  13. package/src/lib/components/grid-header/useGridHeaderStyles.d.ts +1 -1
  14. package/src/lib/components/index.d.ts +1 -0
  15. package/src/lib/components/pagination/Pagination.d.ts +3 -4
  16. package/src/lib/components/table/Table.d.ts +3 -4
  17. package/src/lib/components/tbody/TableBody.d.ts +6 -9
  18. package/src/lib/components/tbody/TableCell.d.ts +3 -3
  19. package/src/lib/components/tbody/TableRow.d.ts +7 -3
  20. package/src/lib/components/tbody/useTableBodyStyles.d.ts +1 -1
  21. package/src/lib/components/thead/HeaderCell.d.ts +3 -3
  22. package/src/lib/components/thead/HeaderRow.d.ts +3 -3
  23. package/src/lib/components/thead/TableHeader.d.ts +3 -3
  24. package/src/lib/components/thead/useTableHeaderStyles.d.ts +1 -1
  25. package/src/lib/components/useGridContainer.d.ts +2 -3
  26. package/src/lib/components/useSkipper.d.ts +1 -0
  27. package/src/lib/components/views/ViewSaveForm.d.ts +3 -3
  28. package/src/lib/components/views/ViewsDrawer.d.ts +4 -6
  29. package/src/lib/helpers/Helpers.d.ts +1 -1
  30. package/src/lib/helpers/StylesHelper.d.ts +4 -0
  31. package/src/lib/index.d.ts +13 -2
  32. package/src/lib/types/TableProps.d.ts +18 -2
  33. package/src/lib/types/TableRef.d.ts +2 -2
package/index.esm.js CHANGED
@@ -1,13 +1,17 @@
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 { useDrop, useDrag, DndProvider } from 'react-dnd';
5
- import { HTML5Backend } from 'react-dnd-html5-backend';
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, Switch, 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 as Switch$1, 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
- import { useVirtual } from 'react-virtual';
8
+ import { useVirtualizer } from '@tanstack/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 { useVirtual } from 'react-virtual';
13
+ import { useSensor, PointerSensor, MouseSensor, TouchSensor, KeyboardSensor, useSensors, DndContext, closestCenter } from '@dnd-kit/core';
14
+ import { restrictToHorizontalAxis } from '@dnd-kit/modifiers';
11
15
 
12
16
  const useStaticStyles = makeStaticStyles({
13
17
  "*": {
@@ -15,7 +19,9 @@ const useStaticStyles = makeStaticStyles({
15
19
  },
16
20
  });
17
21
  const useTableStaticStyles = makeStyles({
18
- tableContainer: Object.assign(Object.assign({ height: "650px", width: "100%" }, shorthands.overflow("hidden", "auto")), {
22
+ tableContainer: Object.assign(Object.assign({
23
+ // height: "650px",
24
+ width: "100%" }, shorthands.overflow("hidden", "auto")), {
19
25
  /* width */
20
26
  ":hover": Object.assign({}, shorthands.overflow("auto", "auto")), "::-webkit-scrollbar": Object.assign({ width: "6px", height: "4px" }, shorthands.borderRadius("50%")),
21
27
  /* Track */
@@ -1001,6 +1007,7 @@ const GroupDismissFilled = /*#__PURE__*/createFluentIcon('GroupDismissFilled', "
1001
1007
  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
1008
  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
1009
 
1010
+ 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
1011
  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
1012
  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
1013
  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 +1080,8 @@ const range = (from, to, step = 1) => {
1073
1080
  };
1074
1081
  const DEFAULT_NUMBER_OF_PAGE_BTN = 5;
1075
1082
  const Pagination = (props) => {
1076
- const { table, pageSizeOptions = [10, 20, 50, 100, 1000] } = props;
1083
+ const { table } = props;
1084
+ const { pageSizeOptions } = table.options.meta || {};
1077
1085
  const pageSizeSelectionId = useId("page-size-selector");
1078
1086
  const styles = usePaginationStyle();
1079
1087
  const totalNumberOfPage = table.getPageCount();
@@ -1096,12 +1104,12 @@ const Pagination = (props) => {
1096
1104
  const currentPageOptions = end - start >= 0 ? range(start, end) : [];
1097
1105
  return (currentPageOptions === null || currentPageOptions === void 0 ? void 0 : currentPageOptions.length) ? [...currentPageOptions] : [1];
1098
1106
  }, [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: pageSizeOptions === null || pageSizeOptions === void 0 ? void 0 : pageSizeOptions.map((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) => {
1107
+ 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
1108
  const page = data.value ? Number(e.target.value) - 1 : 0;
1101
1109
  if (page >= 0 && page < table.getPageCount()) {
1102
1110
  table.setPageIndex(page);
1103
1111
  }
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" }), pageSelectionOptions === null || pageSelectionOptions === void 0 ? void 0 : pageSelectionOptions.map((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" })] })] }) }));
1112
+ }, 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
1113
  };
1106
1114
 
1107
1115
  bundleIcon$1(SaveFilled, SaveRegular);
@@ -1130,21 +1138,24 @@ const useGridHeaderStyles = makeStyles({
1130
1138
  width: "100%",
1131
1139
  height: "100%",
1132
1140
  },
1141
+ popoverSurface: {
1142
+ minWidth: "300px"
1143
+ }
1133
1144
  });
1134
1145
 
1135
1146
  const GridHeader = (props) => {
1136
1147
  const { table, gridTitle, globalFilter, setGlobalFilter, dispatch, drawerState } = props;
1137
1148
  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) => {
1149
+ 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
1150
  if (column.id === 'select')
1140
1151
  return null;
1141
1152
  if (column.id === 'id')
1142
1153
  return null;
1143
- 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
+ return (jsx(Switch, { checked: column.getIsGrouped(), onChange: column.getToggleGroupingHandler(), disabled: !column.getCanGroup() || !column.getIsVisible(), label: jsx("span", { children: column.columnDef.id }) }, column.id));
1155
+ })] }) })] }), 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(Switch, { checked: table.getIsAllColumnsVisible(), onChange: table.getToggleAllColumnsVisibilityHandler(), label: 'Toggle All' }), jsx(Divider, {}), table.getAllLeafColumns().map((column) => {
1145
1156
  if (column.id === 'select')
1146
1157
  return null;
1147
- return (jsx(Checkbox, { checked: column.getIsVisible(), onChange: column.getToggleVisibilityHandler(), label: column.id, disabled: !column.getCanHide() }, column.id));
1158
+ return (jsx(Switch, { checked: column.getIsVisible(), onChange: column.getToggleVisibilityHandler(), label: column.id, disabled: !column.getCanHide() }, column.id));
1148
1159
  })] }) })] }), jsx(Tooltip, { content: 'Table Views Management', relationship: "label", children: jsx(Button, { onClick: () => {
1149
1160
  dispatch({ type: "TOGGLE_VIEW_DRAWER" });
1150
1161
  }, icon: jsx(Album24Regular, {}), "aria-label": "View Menu" }) }), jsx(DebouncedInput, { value: globalFilter !== null && globalFilter !== void 0 ? globalFilter : '', onChange: (value) => setGlobalFilter(String(value)), className: "p-2 font-lg shadow border border-block", placeholder: "Search all columns...", drawerState: drawerState, dispatch: dispatch })] })] }));
@@ -1225,8 +1236,8 @@ const getLeafColumns = (columns) => {
1225
1236
  };
1226
1237
 
1227
1238
  const useGridContainer = (props, ref) => {
1228
- var _a, _b, _c, _d, _e, _f, _g, _h;
1229
- const { columns, data, rowSelectionMode } = props;
1239
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1240
+ const { defaultColumn, columns, data, rowSelectionMode, autoResetPageIndex, onUpdateData } = props;
1230
1241
  const [pagination, setPagination] = React.useState({
1231
1242
  pageSize: props.pageSize || 10,
1232
1243
  pageIndex: 0,
@@ -1247,7 +1258,12 @@ const useGridContainer = (props, ref) => {
1247
1258
  const [expanded, setExpanded] = React.useState((_g = props.expandedState) !== null && _g !== void 0 ? _g : {});
1248
1259
  const [columnPinning, setColumnPinning] = React.useState((_h = props.columnPinningState) !== null && _h !== void 0 ? _h : {});
1249
1260
  const [columnSizing, setColumnSizing] = React.useState({});
1261
+ const [rowPinning, setRowPinning] = React.useState((_j = props.rowPinningState) !== null && _j !== void 0 ? _j : {
1262
+ top: [],
1263
+ bottom: [],
1264
+ });
1250
1265
  const table = useReactTable({
1266
+ defaultColumn,
1251
1267
  columns: columns,
1252
1268
  data,
1253
1269
  filterFns: {
@@ -1270,6 +1286,11 @@ const useGridContainer = (props, ref) => {
1270
1286
  columnVisibility,
1271
1287
  columnPinning,
1272
1288
  columnSizing,
1289
+ rowPinning
1290
+ },
1291
+ getRowId(originalRow, index, parent) {
1292
+ const keyProps = props.dataPrimaryKye || 'id';
1293
+ return originalRow[keyProps] || `${index}`;
1273
1294
  },
1274
1295
  columnResizeMode: 'onChange',
1275
1296
  enableRowSelection: rowSelectionMode !== undefined,
@@ -1279,6 +1300,8 @@ const useGridContainer = (props, ref) => {
1279
1300
  enableColumnFilters: true,
1280
1301
  filterFromLeafRows: true,
1281
1302
  autoResetExpanded: false,
1303
+ autoResetPageIndex: autoResetPageIndex,
1304
+ keepPinnedRows: true,
1282
1305
  onRowSelectionChange: setRowSelection,
1283
1306
  onPaginationChange: setPagination,
1284
1307
  onSortingChange: setSorting,
@@ -1290,6 +1313,7 @@ const useGridContainer = (props, ref) => {
1290
1313
  onColumnVisibilityChange: setColumnVisibility,
1291
1314
  onColumnPinningChange: setColumnPinning,
1292
1315
  onColumnSizingChange: setColumnSizing,
1316
+ onRowPinningChange: setRowPinning,
1293
1317
  getCoreRowModel: getCoreRowModel(),
1294
1318
  getPaginationRowModel: getPaginationRowModel(),
1295
1319
  getSortedRowModel: getSortedRowModel(),
@@ -1298,10 +1322,18 @@ const useGridContainer = (props, ref) => {
1298
1322
  getExpandedRowModel: getExpandedRowModel(),
1299
1323
  getFacetedUniqueValues: getFacetedUniqueValues(),
1300
1324
  getFacetedMinMaxValues: getFacetedMinMaxValues(),
1325
+ meta: {
1326
+ pageSizeOptions: props.pageSizeOptions || [10, 20, 50, 100, 1000],
1327
+ rowSelectionMode: props.rowSelectionMode,
1328
+ tableHeight: props.tableHeight || "650px",
1329
+ updateData: onUpdateData,
1330
+ onTableViewDelete: props.onTableViewDelete,
1331
+ onTableViewSave: props.onTableViewSave
1332
+ }
1301
1333
  });
1302
1334
  const tableViews = React.useMemo(() => { var _a; return (_a = props.views) !== null && _a !== void 0 ? _a : []; }, [props.views]);
1303
1335
  const resetToDefaultView = () => {
1304
- var _a, _b, _c, _d, _e, _f, _g, _h;
1336
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1305
1337
  const defaultTableState = {
1306
1338
  pagination: {
1307
1339
  pageSize: props.pageSize || 10,
@@ -1323,7 +1355,7 @@ const useGridContainer = (props, ref) => {
1323
1355
  columnVisibility: (_g = props.columnVisibility) !== null && _g !== void 0 ? _g : {},
1324
1356
  columnPinning: (_h = props.columnPinningState) !== null && _h !== void 0 ? _h : {},
1325
1357
  columnSizing: {},
1326
- rowPinning: {},
1358
+ rowPinning: (_j = props.rowPinningState) !== null && _j !== void 0 ? _j : {},
1327
1359
  columnSizingInfo: {
1328
1360
  "startOffset": null,
1329
1361
  "startSize": null,
@@ -1356,6 +1388,7 @@ const useGridContainer = (props, ref) => {
1356
1388
  pageSize: props.pageSize || 10,
1357
1389
  pageIndex: 0,
1358
1390
  });
1391
+ setRowPinning(tableState.rowPinning);
1359
1392
  }, 10);
1360
1393
  return true;
1361
1394
  }
@@ -1421,10 +1454,11 @@ const useTableHeaderStyles = makeStyles({
1421
1454
  boxShadow: tokens.shadow2,
1422
1455
  },
1423
1456
  tHeadRow: {
1424
- backgroundColor: tokens.colorNeutralStroke2,
1457
+ backgroundColor: tokens.colorNeutralCardBackgroundSelected,
1425
1458
  },
1426
1459
  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('1px', 'solid', tokens.colorNeutralBackground1)),
1460
+ tHeadNonLeafCell: Object.assign({}, shorthands.borderBottom(0)),
1461
+ tHeadNonLeafCellFakeBorder: Object.assign({ width: '100%', height: '1px', position: "sticky", bottom: 0 }, shorthands.borderBottom('1px', 'solid', tokens.colorBrandBackgroundInverted)),
1428
1462
  tHeadCellDraggable: {
1429
1463
  height: '100%',
1430
1464
  cursor: 'grab',
@@ -1433,18 +1467,18 @@ const useTableHeaderStyles = makeStyles({
1433
1467
  opacity: 0.5,
1434
1468
  cursor: 'grabbing',
1435
1469
  },
1436
- tHeadCellOver: Object.assign({ backgroundColor: tokens.colorNeutralStroke1 }, shorthands.border(tokens.strokeWidthThin, 'dashed', tokens.colorBrandBackground2Pressed)),
1470
+ tHeadCellOver: Object.assign({ backgroundColor: tokens.colorNeutralStroke1 }, shorthands.border(tokens.strokeWidthThin, 'dashed', tokens.colorNeutralBackground2Pressed)),
1437
1471
  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
1472
  tNonLeafHeadCellContent: Object.assign({ display: 'flex', alignContent: 'center', alignItems: 'center', justifyContent: 'center', cursor: 'pointer', width: '100%', minWidth: '1rem' }, shorthands.padding('3px', '4px')),
1439
1473
  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
1474
  tHeadMenuPopover: Object.assign(Object.assign({}, shorthands.padding('0px', '0px', '0px', '0px')), { width: '300px' }),
1441
- resizer: Object.assign(Object.assign({}, shorthands.borderRight('1px', 'solid', tokens.colorNeutralBackground1)), { width: '8px', position: 'absolute', top: 0, right: 0, bottom: 0, cursor: 'col-resize', resize: 'horizontal', ':hover': {
1442
- borderRightWidth: '4px',
1443
- borderRightColor: tokens.colorNeutralBackground2Pressed,
1475
+ 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': {
1476
+ borderRightWidth: '2px',
1477
+ borderRightColor: tokens.colorBrandBackgroundInvertedHover,
1444
1478
  } }),
1445
1479
  resizerActive: {
1446
- borderRightWidth: '4px',
1447
- borderRightColor: tokens.colorNeutralBackground2Pressed,
1480
+ borderRightWidth: '2px',
1481
+ borderRightColor: tokens.colorBrandBackgroundInvertedPressed,
1448
1482
  },
1449
1483
  });
1450
1484
 
@@ -1455,7 +1489,7 @@ const useCheckboxFilterStyles = makeStyles({
1455
1489
  marginLeft: '10px',
1456
1490
  marginRight: '10px',
1457
1491
  },
1458
- searchContainer: Object.assign(Object.assign(Object.assign({ display: 'flex', flexDirection: 'column', maxHeight: '300px', width: '100%' }, shorthands.overflow('auto', 'auto')), shorthands.padding('0px', "0px", "2px", '0px')), { '::-webkit-scrollbar': Object.assign({ width: '6px', height: '4px' }, shorthands.borderRadius('50%')),
1492
+ searchContainer: Object.assign(Object.assign(Object.assign({ maxHeight: '300px', width: '100%' }, shorthands.overflow('auto', 'auto')), shorthands.padding('0px', "0px", "2px", '0px')), { '::-webkit-scrollbar': Object.assign({ width: '6px', height: '4px' }, shorthands.borderRadius('50%')),
1459
1493
  /* Track */
1460
1494
  '::-webkit-scrollbar-track': {
1461
1495
  'background-color': '#f1f1f1',
@@ -1470,7 +1504,7 @@ const useCheckboxFilterStyles = makeStyles({
1470
1504
  } }),
1471
1505
  });
1472
1506
  const FilterMultiSelectCheckbox = ({ column, table, }) => {
1473
- var _a, _b, _c;
1507
+ var _a;
1474
1508
  const firstValue = (_a = table
1475
1509
  .getPreFilteredRowModel()
1476
1510
  .flatRows[0]) === null || _a === void 0 ? void 0 : _a.getValue(column.id);
@@ -1493,45 +1527,45 @@ const FilterMultiSelectCheckbox = ({ column, table, }) => {
1493
1527
  return (_b = (_a = `${option}`) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === null || _b === void 0 ? void 0 : _b.includes((_c = `${localColumnFilterValue}`) === null || _c === void 0 ? void 0 : _c.toLowerCase());
1494
1528
  });
1495
1529
  }, [localColumnFilterValue, filterOptions]);
1496
- const filterContainer = React.useRef(null);
1497
- const rowVirtualizer = useVirtual({
1498
- parentRef: filterContainer,
1499
- size: filterOptionsFiltered.length,
1500
- overscan: 15,
1530
+ const parentRef = React.useRef(null);
1531
+ const virtualizer = useVirtualizer({
1532
+ count: (filterOptionsFiltered === null || filterOptionsFiltered === void 0 ? void 0 : filterOptionsFiltered.length) || 0,
1533
+ getScrollElement: () => parentRef.current,
1534
+ estimateSize: () => 30,
1535
+ overscan: 5,
1501
1536
  });
1502
- const { virtualItems: virtualRows, totalSize } = rowVirtualizer;
1503
- 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;
1504
- const paddingBottom = virtualRows.length > 0
1505
- ? totalSize - (((_c = virtualRows === null || virtualRows === void 0 ? void 0 : virtualRows[virtualRows.length - 1]) === null || _c === void 0 ? void 0 : _c.end) || 0)
1506
- : 0;
1537
+ const virtualItems = virtualizer.getVirtualItems();
1507
1538
  const allOptionChecked = (columnFilterValue === null || columnFilterValue === void 0 ? void 0 : columnFilterValue.length) > 0 &&
1508
1539
  (columnFilterValue === null || columnFilterValue === void 0 ? void 0 : columnFilterValue.length) !== (filterOptions === null || filterOptions === void 0 ? void 0 : filterOptions.length)
1509
1540
  ? 'mixed'
1510
1541
  : (columnFilterValue === null || columnFilterValue === void 0 ? void 0 : columnFilterValue.length) === (filterOptions === null || filterOptions === void 0 ? void 0 : filterOptions.length) &&
1511
1542
  (filterOptions === null || filterOptions === void 0 ? void 0 : filterOptions.length) > 0;
1512
1543
  const styles = useCheckboxFilterStyles();
1513
- return (jsxs("div", { children: [jsx(Input, { type: 'search', value: localColumnFilterValue, onChange: (_, data) => setLocalColumnFilterValue(data.value), placeholder: "Search Options...", size: "small", className: styles.searchInput }), jsxs("div", { ref: filterContainer, className: styles.searchContainer, children: [paddingTop > 0 && (jsx("span", { style: { paddingTop: `${paddingTop}px` } })), jsx(Checkbox, { checked: allOptionChecked, onChange: () => {
1514
- if ((columnFilterValue === null || columnFilterValue === void 0 ? void 0 : columnFilterValue.length) > 0) {
1515
- column.setFilterValue(undefined);
1516
- return;
1517
- }
1518
- column.setFilterValue([
1519
- ...((filterOptions === null || filterOptions === void 0 ? void 0 : filterOptions.map((x) => `${x}`)) || []),
1520
- ]);
1521
- }, label: '(Toggle All)' }, `toggle-all-${column.id}`), virtualRows.map((row) => {
1522
- var _a;
1523
- const value = `${filterOptionsFiltered[row.index]}`;
1524
- return (jsx(Checkbox, { checked: (_a = columnFilterValue === null || columnFilterValue === void 0 ? void 0 : columnFilterValue.includes(value)) !== null && _a !== void 0 ? _a : false, onChange: () => {
1525
- if (columnFilterValue === null || columnFilterValue === void 0 ? void 0 : columnFilterValue.includes(value)) {
1526
- column.setFilterValue((old) => old === null || old === void 0 ? void 0 : old.filter((v) => v !== value));
1544
+ return (jsxs("div", { children: [jsx(Input, { type: 'search', value: localColumnFilterValue, onChange: (_, data) => setLocalColumnFilterValue(data.value), placeholder: "Search Options...", size: "small", className: styles.searchInput }), jsx("div", { ref: parentRef, className: styles.searchContainer, children: jsxs("div", { style: { height: `${virtualizer.getTotalSize()}px` }, children: [jsx(Checkbox, { checked: allOptionChecked, onChange: () => {
1545
+ if ((columnFilterValue === null || columnFilterValue === void 0 ? void 0 : columnFilterValue.length) > 0) {
1546
+ column.setFilterValue(undefined);
1527
1547
  return;
1528
1548
  }
1529
- column.setFilterValue((old) => [
1530
- ...(old || []),
1531
- value,
1549
+ column.setFilterValue([
1550
+ ...((filterOptions === null || filterOptions === void 0 ? void 0 : filterOptions.map((x) => `${x}`)) || []),
1532
1551
  ]);
1533
- }, label: value }, `${column.id}-${row.index}`));
1534
- }), paddingBottom > 0 && (jsx("span", { style: { paddingBottom: `${paddingBottom}px` } }))] }, 'filter-multi-select-checkbox')] }));
1552
+ }, label: '(Toggle All)' }, `toggle-all-${column.id}`), (virtualItems || []).map((row, index) => {
1553
+ var _a;
1554
+ const value = `${filterOptionsFiltered[row.index]}`;
1555
+ return (jsx("div", { style: {
1556
+ height: `${row.size}px`,
1557
+ transform: `translateY(${row.start - index * row.size}px)`,
1558
+ }, children: jsx(Checkbox, { checked: (_a = columnFilterValue === null || columnFilterValue === void 0 ? void 0 : columnFilterValue.includes(value)) !== null && _a !== void 0 ? _a : false, onChange: () => {
1559
+ if (columnFilterValue === null || columnFilterValue === void 0 ? void 0 : columnFilterValue.includes(value)) {
1560
+ column.setFilterValue((old) => old === null || old === void 0 ? void 0 : old.filter((v) => v !== value));
1561
+ return;
1562
+ }
1563
+ column.setFilterValue((old) => [
1564
+ ...(old || []),
1565
+ value,
1566
+ ]);
1567
+ }, label: value }) }, `${column.id}-${row.index}`));
1568
+ })] }) })] }));
1535
1569
  };
1536
1570
 
1537
1571
  const useRadioFilterStyles = makeStyles({
@@ -1541,7 +1575,7 @@ const useRadioFilterStyles = makeStyles({
1541
1575
  marginLeft: '10px',
1542
1576
  marginRight: '10px',
1543
1577
  },
1544
- searchContainer: Object.assign(Object.assign({ display: 'flex', flexDirection: 'column', maxHeight: '300px', width: '100%' }, shorthands.overflow('auto', 'auto')), { '::-webkit-scrollbar': Object.assign({ width: '6px', height: '4px' }, shorthands.borderRadius('50%')),
1578
+ searchContainer: Object.assign(Object.assign({ maxHeight: '300px', width: '100%' }, shorthands.overflow('auto', 'auto')), { '::-webkit-scrollbar': Object.assign({ width: '6px', height: '4px' }, shorthands.borderRadius('50%')),
1545
1579
  /* Track */
1546
1580
  '::-webkit-scrollbar-track': {
1547
1581
  'background-color': '#f1f1f1',
@@ -1556,7 +1590,7 @@ const useRadioFilterStyles = makeStyles({
1556
1590
  } }),
1557
1591
  });
1558
1592
  const FilterSelectRadio = ({ column, table, }) => {
1559
- var _a, _b, _c;
1593
+ var _a;
1560
1594
  const firstValue = (_a = table
1561
1595
  .getPreFilteredRowModel()
1562
1596
  .flatRows[0]) === null || _a === void 0 ? void 0 : _a.getValue(column.id);
@@ -1579,28 +1613,28 @@ const FilterSelectRadio = ({ column, table, }) => {
1579
1613
  return (_b = (_a = `${option}`) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === null || _b === void 0 ? void 0 : _b.includes((_c = `${localColumnFilterValue}`) === null || _c === void 0 ? void 0 : _c.toLowerCase());
1580
1614
  });
1581
1615
  }, [localColumnFilterValue, filterOptions]);
1582
- const filterContainer = React.useRef(null);
1583
- const rowVirtualizer = useVirtual({
1584
- parentRef: filterContainer,
1585
- size: filterOptionsFiltered.length,
1586
- overscan: 15,
1616
+ const parentRef = React.useRef(null);
1617
+ const virtualizer = useVirtualizer({
1618
+ count: (filterOptionsFiltered === null || filterOptionsFiltered === void 0 ? void 0 : filterOptionsFiltered.length) || 0,
1619
+ getScrollElement: () => parentRef.current,
1620
+ estimateSize: () => 30,
1621
+ overscan: 5,
1587
1622
  });
1588
- const { virtualItems: virtualRows, totalSize } = rowVirtualizer;
1589
- 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;
1590
- const paddingBottom = virtualRows.length > 0
1591
- ? totalSize - (((_c = virtualRows === null || virtualRows === void 0 ? void 0 : virtualRows[virtualRows.length - 1]) === null || _c === void 0 ? void 0 : _c.end) || 0)
1592
- : 0;
1623
+ const virtualItems = virtualizer.getVirtualItems();
1593
1624
  const styles = useRadioFilterStyles();
1594
- return (jsxs("div", { children: [jsx(Input, { value: localColumnFilterValue, onChange: (_, data) => setLocalColumnFilterValue(data.value), placeholder: "Search Options...", size: "small", className: styles.searchInput }), jsxs("div", { ref: filterContainer, className: styles.searchContainer, children: [paddingTop > 0 && jsx("div", { style: { paddingTop: `${paddingTop}px` } }), jsxs(RadioGroup, { layout: "vertical", value: (columnFilterValue === null || columnFilterValue === void 0 ? void 0 : columnFilterValue[0]) || '', onChange: (_, data) => {
1625
+ return (jsxs("div", { children: [jsx(Input, { value: localColumnFilterValue, onChange: (_, data) => setLocalColumnFilterValue(data.value), placeholder: "Search Options...", size: "small", className: styles.searchInput }), jsx("div", { ref: parentRef, className: styles.searchContainer, children: jsx("div", { style: { height: `${virtualizer.getTotalSize()}px` }, children: jsxs(RadioGroup, { layout: "vertical", value: (columnFilterValue === null || columnFilterValue === void 0 ? void 0 : columnFilterValue[0]) || '', onChange: (_, data) => {
1595
1626
  if (data.value === '') {
1596
1627
  column.setFilterValue([]);
1597
1628
  return;
1598
1629
  }
1599
1630
  column.setFilterValue([data.value]);
1600
- }, children: [jsx(Radio, { value: '', label: 'None' }), virtualRows.map((row) => {
1631
+ }, children: [jsx(Radio, { value: '', label: 'None' }), (virtualItems || []).map((row, index) => {
1601
1632
  const value = filterOptionsFiltered[row.index];
1602
- return jsx(Radio, { value: value, label: value }, value);
1603
- })] }), paddingBottom > 0 && (jsx("div", { style: { paddingBottom: `${paddingBottom}px` } }))] })] }));
1633
+ return (jsx("div", { style: {
1634
+ height: `${row.size}px`,
1635
+ transform: `translateY(${row.start - index * row.size}px)`,
1636
+ }, children: jsx(Radio, { value: value, label: value }, value) }, `${column.id}-${row.index}`));
1637
+ })] }) }) })] }));
1604
1638
  };
1605
1639
 
1606
1640
  const useNumberRangeFilterStyles$2 = makeStyles({
@@ -1788,75 +1822,102 @@ const FilterDrawer = ({ drawerState, dispatch, table }) => {
1788
1822
  table.setGlobalFilter('');
1789
1823
  table.resetColumnFilters();
1790
1824
  }, [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
- const canApplyFilter = headerGroup.depth === (headerGroups === null || headerGroups === void 0 ? void 0 : headerGroups.length) - 1;
1793
- if (!canApplyFilter)
1794
- return null;
1795
- return headerGroup.headers.map((header) => {
1796
- const canFilter = header.column.getCanFilter();
1797
- if (!canFilter)
1825
+ 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) => {
1826
+ const canApplyFilter = headerGroup.depth === (headerGroups === null || headerGroups === void 0 ? void 0 : headerGroups.length) - 1;
1827
+ if (!canApplyFilter)
1798
1828
  return null;
1799
- return (jsx("div", { children: header.column.getCanFilter() && (jsxs("div", { style: {
1800
- marginTop: "20px",
1801
- }, children: [jsxs(Caption1Stronger, { children: ["Filter by", ' ', flexRender(header.column.columnDef.header, header.getContext())] }), jsx(Filter, { column: header.column, table: table })] }, 'filter-group')) }, header.column.id));
1802
- });
1803
- }) }), jsx(DrawerFooter, { children: jsx(Button, { icon: jsx(ClearFilterIcon, {}), onClick: resetAllFilters, style: { width: "100%" }, children: "Clear All Filters" }) })] }));
1829
+ return headerGroup.headers.map((header) => {
1830
+ const canFilter = header.column.getCanFilter();
1831
+ if (!canFilter)
1832
+ return null;
1833
+ 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));
1834
+ });
1835
+ }) }) }), jsx(DrawerFooter, { children: jsx(Button, { icon: jsx(ClearFilterIcon, {}), onClick: resetAllFilters, style: { width: "100%" }, children: "Clear All Filters" }) })] }));
1836
+ };
1837
+
1838
+ const getHeaderCellPinningStyles = (column) => {
1839
+ const isPinned = column.getIsPinned();
1840
+ const isLastLeftPinnedColumn = isPinned === 'left' && column.getIsLastColumn('left');
1841
+ const isFirstRightPinnedColumn = isPinned === 'right' && column.getIsFirstColumn('right');
1842
+ const styles = {
1843
+ boxShadow: isLastLeftPinnedColumn
1844
+ ? '-4px 0 4px -4px gray inset'
1845
+ : isFirstRightPinnedColumn
1846
+ ? '4px 0 4px -4px gray inset'
1847
+ : undefined,
1848
+ left: isPinned === 'left' ? `${column.getStart('left')}px` : undefined,
1849
+ right: isPinned === 'right' ? `${column.getAfter('right')}px` : undefined,
1850
+ opacity: isPinned ? 0.95 : 1,
1851
+ position: isPinned ? 'sticky' : 'relative',
1852
+ width: column.getSize(),
1853
+ zIndex: isPinned ? 99 : 1,
1854
+ backgroundColor: tokens.colorNeutralCardBackgroundSelected,
1855
+ };
1856
+ return styles;
1857
+ };
1858
+ const getBodyCellPinningStyles = (column) => {
1859
+ const isPinned = column.getIsPinned();
1860
+ const isLastLeftPinnedColumn = isPinned === 'left' && column.getIsLastColumn('left');
1861
+ const isFirstRightPinnedColumn = isPinned === 'right' && column.getIsFirstColumn('right');
1862
+ const styles = {
1863
+ boxShadow: isLastLeftPinnedColumn
1864
+ ? '-4px 0 4px -4px gray inset'
1865
+ : isFirstRightPinnedColumn
1866
+ ? '4px 0 4px -4px gray inset'
1867
+ : undefined,
1868
+ left: isPinned === 'left' ? `${column.getStart('left')}px` : undefined,
1869
+ right: isPinned === 'right' ? `${column.getAfter('right')}px` : undefined,
1870
+ opacity: isPinned ? 0.95 : 1,
1871
+ position: isPinned ? 'sticky' : 'relative',
1872
+ width: column.getSize(),
1873
+ zIndex: isPinned ? 1 : 0,
1874
+ };
1875
+ return styles;
1804
1876
  };
1805
1877
 
1806
1878
  const SortAscIcon = bundleIcon$1(ArrowSortDown20Filled, ArrowSortDown20Regular);
1807
1879
  const SortDescIcon = bundleIcon$1(ArrowSortUp20Filled, ArrowSortUp20Regular);
1808
- const reorderColumn = (draggedColumnId, targetColumnId, columnOrder) => {
1809
- columnOrder.splice(columnOrder.indexOf(targetColumnId), 0, columnOrder.splice(columnOrder.indexOf(draggedColumnId), 1)[0]);
1810
- return [...columnOrder];
1811
- };
1880
+ const PinIcon = bundleIcon$1(PinFilled, PinRegular);
1812
1881
  function HeaderCell({ header, table, hideMenu, headerDepth, totalNumberOfHeaderDepth, }) {
1813
1882
  var _a;
1814
- const { getState, setColumnOrder } = table;
1815
- const { columnOrder } = getState();
1816
1883
  const { column } = header;
1817
- const [{ isOver }, dropRef] = useDrop({
1818
- accept: "column",
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",
1884
+ const { isDragging, attributes, listeners, setNodeRef, transform, transition, } = useSortable({
1885
+ id: column.id
1833
1886
  });
1887
+ const dndStyle = {
1888
+ width: header.column.getSize(),
1889
+ opacity: isDragging ? 0.8 : 1,
1890
+ // position: isDragging ? 'relative' : "sticky",
1891
+ transform: CSS.Translate.toString(transform), // translate instead of transform to avoid squishing
1892
+ // transition: 'width transform 0.2s ease-in-out',
1893
+ whiteSpace: 'wrap',
1894
+ zIndex: isDragging ? 100 : 99,
1895
+ transition
1896
+ };
1834
1897
  const styles = useTableHeaderStyles();
1835
- const canDragDrop = headerDepth === totalNumberOfHeaderDepth && !header.isPlaceholder;
1836
1898
  const isLeafHeaders = headerDepth === totalNumberOfHeaderDepth;
1837
1899
  if (header.isPlaceholder) {
1838
- return (jsx("th", { colSpan: header.colSpan, className: styles.tHeadCell, children: header.column.getCanResize() && (jsx("div", { onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler(), className: mergeClasses$1(styles.resizer, column.getIsResizing() && styles.resizerActive) })) }));
1900
+ 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
1901
  }
1840
- return (jsxs("th", { colSpan: header.colSpan, className: mergeClasses$1(styles.tHeadCell, isLeafHeaders || header.isPlaceholder ? undefined
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
1902
+ 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
1903
  ? styles.tLeafHeadCellContent
1843
- : styles.tNonLeafHeadCellContent, ref: canDragDrop ? dragRef : undefined, children: [jsx("div", { ref: canDragDrop ? previewRef : undefined, children: header.isPlaceholder ? null : (jsxs(Button, { style: {
1844
- display: 'flex',
1845
- alignItems: 'center',
1846
- justifyContent: 'left',
1847
- flex: 1,
1848
- }, onClick: (e) => {
1849
- if (!header.column.getCanSort())
1850
- return;
1851
- header.column.toggleSorting(header.column.getIsSorted() === 'asc', e.ctrlKey);
1852
- }, onDoubleClick: () => {
1853
- if (!header.column.getCanGroup())
1854
- return;
1855
- header.column.getToggleGroupingHandler()();
1856
- }, appearance: "transparent", className: styles.tHeadContentBtn, icon: (_a = {
1857
- asc: (jsx("strong", { children: jsx(SortAscIcon, {}) })),
1858
- desc: (jsx("strong", { children: jsx(SortDescIcon, {}) })),
1859
- }[header.column.getIsSorted()]) !== null && _a !== void 0 ? _a : undefined, iconPosition: "after", children: [jsx("strong", { children: flexRender(header.column.columnDef.header, header.getContext()) }), header.column.getIsGrouped() && jsx(GroupListRegular, {}), header.column.getIsFiltered() && (jsx("strong", { children: jsx(FilterFilled, {}) })), header.column.getIsPinned() && jsx(PinRegular, {})] })) }), jsx(HeaderMenu, { header: header, table: table, hideMenu: hideMenu })] }) }), header.column.getCanResize() && (jsx("div", { onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler(), className: mergeClasses$1(styles.resizer, column.getIsResizing() && styles.resizerActive) }))] }));
1904
+ : styles.tNonLeafHeadCellContent, children: [jsx("div", { children: jsx(Show, { when: !header.isPlaceholder, children: jsxs(Button, { style: {
1905
+ display: 'flex',
1906
+ alignItems: 'center',
1907
+ justifyContent: 'left',
1908
+ flex: 1,
1909
+ }, onClick: (e) => {
1910
+ if (!header.column.getCanSort())
1911
+ return;
1912
+ header.column.toggleSorting(header.column.getIsSorted() === 'asc', e.ctrlKey);
1913
+ }, onDoubleClick: () => {
1914
+ if (!header.column.getCanGroup())
1915
+ return;
1916
+ header.column.getToggleGroupingHandler()();
1917
+ }, appearance: "transparent", className: styles.tHeadContentBtn, icon: (_a = {
1918
+ asc: (jsx("strong", { children: jsx(SortAscIcon, {}) })),
1919
+ desc: (jsx("strong", { children: jsx(SortDescIcon, {}) })),
1920
+ }[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
1921
  }
1861
1922
  function HeaderMenu(props) {
1862
1923
  const { header, table, hideMenu } = props;
@@ -1868,24 +1929,24 @@ function HeaderMenu(props) {
1868
1929
  header.column.getCanFilter();
1869
1930
  if (!canHavePopOver)
1870
1931
  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() && (jsxs(MenuGroup, { children: [jsxs(MenuGroupHeader, { children: ["Sort by", ' ', flexRender(header.column.columnDef.header, header.getContext())] }), jsx(MenuItem, { onClick: (e) => {
1872
- var _a;
1873
- const isControlKeySelected = e.ctrlKey;
1874
- (_a = header.column) === null || _a === void 0 ? void 0 : _a.toggleSorting(false, isControlKeySelected);
1875
- }, icon: jsx(TextSortAscendingFilled, {}), disabled: header.column.getIsSorted() === 'asc', children: "Sort A to Z" }), jsx(MenuItem, { onClick: (e) => {
1876
- var _a;
1877
- const isControlKeySelected = e.ctrlKey;
1878
- (_a = header.column) === null || _a === void 0 ? void 0 : _a.toggleSorting(true, isControlKeySelected);
1879
- }, icon: jsx(TextSortDescendingFilled, {}), disabled: header.column.getIsSorted() === 'desc', children: "Sort Z to A" }), jsx(MenuDivider, {})] }, 'sort-group')), header.column.getCanGroup() && (jsxs(MenuGroup, { children: [jsxs(MenuGroupHeader, { children: ["Group by", ' ', flexRender(header.column.columnDef.header, header.getContext())] }), !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')), header.column.getCanSort() && (jsxs(MenuGroup, { children: [jsxs(MenuGroupHeader, { children: ["Pin Column", ' ', flexRender(header.column.columnDef.header, header.getContext())] }), jsx(MenuItem, { onClick: () => {
1880
- var _a;
1881
- (_a = header.column) === null || _a === void 0 ? void 0 : _a.pin('left');
1882
- }, icon: jsx(ArrowStepInLeftRegular, {}), disabled: header.column.getIsPinned() === 'left', children: "To Left" }), jsx(MenuItem, { onClick: () => {
1883
- var _a;
1884
- (_a = header.column) === null || _a === void 0 ? void 0 : _a.pin('right');
1885
- }, icon: jsx(ArrowStepInRightRegular, {}), disabled: header.column.getIsPinned() === 'right', children: "To Right" }), ['left', 'right'].includes(header.column.getIsPinned()) && (jsx(MenuItem, { onClick: () => {
1886
- var _a;
1887
- (_a = header.column) === null || _a === void 0 ? void 0 : _a.pin(false);
1888
- }, icon: jsx(PinOffRegular, {}), children: "Unpin Column" })), jsx(MenuDivider, {})] }, 'pin columns')), header.column.getCanFilter() && (jsxs(MenuGroup, { children: [jsxs(MenuGroupHeader, { children: ["Filter by", ' ', flexRender(header.column.columnDef.header, header.getContext())] }), jsx(Filter, { column: header.column, table: table })] }, 'filter-group'))] }) })] }));
1932
+ 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) => {
1933
+ var _a;
1934
+ const isControlKeySelected = e.ctrlKey;
1935
+ (_a = header.column) === null || _a === void 0 ? void 0 : _a.toggleSorting(false, isControlKeySelected);
1936
+ }, icon: jsx(TextSortAscendingFilled, {}), disabled: header.column.getIsSorted() === 'asc', children: "Sort A to Z" }), jsx(MenuItem, { onClick: (e) => {
1937
+ var _a;
1938
+ const isControlKeySelected = e.ctrlKey;
1939
+ (_a = header.column) === null || _a === void 0 ? void 0 : _a.toggleSorting(true, isControlKeySelected);
1940
+ }, 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: () => {
1941
+ var _a;
1942
+ (_a = header.column) === null || _a === void 0 ? void 0 : _a.pin(false);
1943
+ }, icon: jsx(PinOffRegular, {}), children: "No Pin" }) }), jsx(MenuItem, { onClick: () => {
1944
+ var _a;
1945
+ (_a = header.column) === null || _a === void 0 ? void 0 : _a.pin('left');
1946
+ }, icon: jsx(ArrowStepInLeftRegular, {}), disabled: header.column.getIsPinned() === 'left', children: "Pin Left" }), jsx(MenuItem, { onClick: () => {
1947
+ var _a;
1948
+ (_a = header.column) === null || _a === void 0 ? void 0 : _a.pin('right');
1949
+ }, 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
1950
  }
1890
1951
 
1891
1952
  function HeaderRow(props) {
@@ -1901,7 +1962,7 @@ function HeaderRow(props) {
1901
1962
  function TableHeader(props) {
1902
1963
  const styles = useTableHeaderStyles();
1903
1964
  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))) }));
1965
+ 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
1966
  }
1906
1967
 
1907
1968
  const useLoadingStyles = makeStyles({
@@ -1974,75 +2035,149 @@ const useTableBodyStyles = makeStyles({
1974
2035
  backgroundColor: tokens.colorBrandBackground2Hover,
1975
2036
  } }),
1976
2037
  tBodyCell: Object.assign(Object.assign({ backgroundColor: "transparent" }, shorthands.padding("2px", "4px")), { minHeight: "35px", height: "35px" }),
2038
+ tBodyRowPinnedCell: {
2039
+ backgroundColor: tokens.colorPaletteYellowBackground2,
2040
+ ":hover": {
2041
+ backgroundColor: tokens.colorPaletteMarigoldBackground2,
2042
+ }
2043
+ },
2044
+ tBodyPinnedCell: {
2045
+ backgroundColor: tokens.colorNeutralBackground3,
2046
+ ":hover": {
2047
+ backgroundColor: tokens.colorNeutralBackground3Hover,
2048
+ }
2049
+ },
2050
+ tBodySelectedCell: {
2051
+ backgroundColor: tokens.colorBrandBackground2,
2052
+ ":hover": {
2053
+ backgroundColor: tokens.colorBrandBackground2Hover,
2054
+ }
2055
+ },
1977
2056
  });
1978
2057
 
1979
2058
  function TableCell({ cell, row }) {
1980
2059
  var _a;
1981
2060
  const styles = useTableBodyStyles();
2061
+ const isSelected = row.getIsSelected();
2062
+ const isRowPinned = row.getIsPinned();
2063
+ const isCellPinned = cell.column.getIsPinned();
2064
+ const { isDragging, transition, setNodeRef, transform } = useSortable({
2065
+ id: cell.column.id,
2066
+ });
1982
2067
  const tdStyle = {
1983
2068
  width: cell.column.getSize(),
2069
+ opacity: isDragging ? "0.8" : "1",
2070
+ transform: CSS.Translate.toString(transform),
2071
+ // transition: 'width transform 0.2s ease-in-out',
2072
+ zIndex: isDragging ? 1 : 0,
2073
+ transition
1984
2074
  };
2075
+ const cellClassNames = mergeClasses$1(styles.tBodyCell, isCellPinned && styles.tBodyPinnedCell, isSelected && styles.tBodySelectedCell, isRowPinned && styles.tBodyRowPinnedCell);
2076
+ const styleStyles = Object.assign(Object.assign({}, tdStyle), getBodyCellPinningStyles(cell.column));
1985
2077
  if (cell.getIsPlaceholder()) {
1986
- return jsx("td", { style: tdStyle, className: styles.tBodyCell }, cell.id);
2078
+ return jsx("td", { style: styleStyles, className: cellClassNames, ref: setNodeRef }, cell.id);
1987
2079
  }
1988
2080
  if (cell.getIsGrouped()) {
1989
- return (jsx("td", { style: tdStyle, className: styles.tBodyCell, children: jsx(Button, { onClick: row.getToggleExpandedHandler(), style: {
2081
+ return (jsx("td", { style: styleStyles, className: cellClassNames, ref: setNodeRef, children: jsx(Button, { onClick: row.getToggleExpandedHandler(), style: {
1990
2082
  cursor: row.getCanExpand() ? 'pointer' : 'normal',
1991
2083
  textAlign: 'left',
1992
2084
  }, 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
2085
  }
1994
2086
  if (cell.getIsAggregated()) {
1995
- return (jsx("td", { style: tdStyle, className: styles.tBodyCell, children: jsx("strong", { children: flexRender((_a = cell.column.columnDef.aggregatedCell) !== null && _a !== void 0 ? _a : cell.column.columnDef.cell, cell.getContext()) }) }, cell.id));
2087
+ 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
2088
  }
1997
- return (jsx("td", { style: tdStyle, className: styles.tBodyCell, children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id));
2089
+ return (jsx("td", { style: styleStyles, className: cellClassNames, ref: setNodeRef, children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id));
1998
2090
  }
1999
2091
 
2000
- function TableRow({ row, rowSelectionMode }) {
2092
+ function TableRow({ row, rowSelectionMode, style }) {
2001
2093
  const styles = useTableBodyStyles();
2002
2094
  return (jsxs("tr", { className: row.getIsSelected() || row.getIsAllSubRowsSelected()
2003
2095
  ? styles.tBodySelectedRow
2004
- : styles.tBodyRow, children: [rowSelectionMode === 'multiple' && (jsx("td", { className: styles.tBodyCell, "aria-label": "Select Row Column", children: jsx(Checkbox, { checked: row.getIsSomeSelected()
2005
- ? 'mixed'
2006
- : row.getIsSelected() || row.getIsAllSubRowsSelected(), disabled: !row.getCanSelect(), onChange: row.getToggleSelectedHandler(), "aria-label": "Select Row" }) })), rowSelectionMode === 'single' && (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));
2096
+ : styles.tBodyRow, style: style, children: [jsxs(Switch$1, { when: rowSelectionMode, children: [jsx(Case, { value: 'multiple', children: jsx("td", { className: styles.tBodyCell, "aria-label": "Select Row Column", children: jsx(Checkbox, { checked: row.getIsSomeSelected()
2097
+ ? 'mixed'
2098
+ : 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));
2099
+ }
2100
+ function PinnedRow({ row, rowSelectionMode, style, bottomRowLength }) {
2101
+ const styles = useTableBodyStyles();
2102
+ return (jsxs("tr", { className: row.getIsSelected() || row.getIsAllSubRowsSelected()
2103
+ ? styles.tBodySelectedRow
2104
+ : styles.tBodyRow, style: {
2105
+ backgroundColor: 'goldenrod',
2106
+ position: 'sticky',
2107
+ top: row.getIsPinned() === 'top'
2108
+ ? `${row.getPinnedIndex() * 35 + 48}px`
2109
+ : undefined,
2110
+ bottom: row.getIsPinned() === 'bottom'
2111
+ ? `${((bottomRowLength || 0) - 1 - row.getPinnedIndex()) * 35}px`
2112
+ : undefined
2113
+ }, children: [jsxs(Switch$1, { when: rowSelectionMode, children: [jsx(Case, { value: 'multiple', children: jsx("td", { className: styles.tBodyCell, "aria-label": "Select Row Column", children: jsx(Checkbox, { checked: row.getIsSomeSelected()
2114
+ ? 'mixed'
2115
+ : 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 => {
2116
+ return (jsx(TableCell, { cell: cell, row: row }, cell.id));
2117
+ })] }, row.id));
2007
2118
  }
2008
2119
 
2009
2120
  function TableBody(props) {
2010
- var _a, _b;
2121
+ var _a, _b, _c;
2011
2122
  const styles = useTableBodyStyles();
2012
- const { rows, rowSelectionMode, virtualRows, totalSize } = props;
2013
- const paddingTop = virtualRows.length > 0 ? ((_a = virtualRows === null || virtualRows === void 0 ? void 0 : virtualRows[0]) === null || _a === void 0 ? void 0 : _a.start) || 0 : 0;
2123
+ const { table, tableContainerRef } = props;
2124
+ const rowSelectionMode = (_a = table.options.meta) === null || _a === void 0 ? void 0 : _a.rowSelectionMode;
2125
+ let rows = [];
2126
+ let topRows = [];
2127
+ let bottomRows = [];
2128
+ try {
2129
+ rows = table.getCenterRows();
2130
+ topRows = table.getTopRows();
2131
+ bottomRows = table.getBottomRows();
2132
+ }
2133
+ catch (error) {
2134
+ rows = [];
2135
+ topRows = [];
2136
+ bottomRows = [];
2137
+ }
2138
+ const rowVirtualizer = useVirtual({
2139
+ parentRef: tableContainerRef,
2140
+ size: rows.length,
2141
+ overscan: 10,
2142
+ });
2143
+ const { virtualItems: virtualRows, totalSize } = rowVirtualizer;
2144
+ 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
2145
  const paddingBottom = virtualRows.length > 0
2015
- ? totalSize - (((_b = virtualRows === null || virtualRows === void 0 ? void 0 : virtualRows[virtualRows.length - 1]) === null || _b === void 0 ? void 0 : _b.end) || 0)
2146
+ ? totalSize - (((_c = virtualRows === null || virtualRows === void 0 ? void 0 : virtualRows[virtualRows.length - 1]) === null || _c === void 0 ? void 0 : _c.end) || 0)
2016
2147
  : 0;
2017
- return (jsxs("tbody", { className: styles.tBody, children: [paddingTop > 0 && (jsx("tr", { className: styles.tBodyRow, "aria-hidden": true, children: jsx("td", { style: { height: `${paddingTop}px` } }) })), virtualRows.map((virtualRow) => {
2018
- const row = rows[virtualRow.index];
2019
- return (jsx(TableRow, { row: row, rowSelectionMode: rowSelectionMode }, row.id));
2020
- }), paddingBottom > 0 && (jsx("tr", { className: styles.tBodyRow, "aria-hidden": true, children: jsx("td", { style: { height: `${paddingBottom}px` } }) }))] }));
2148
+ return (jsxs(Fragment, { children: [jsx(Show, { when: (topRows === null || topRows === void 0 ? void 0 : topRows.length) > 0, children: jsx("thead", { style: {
2149
+ position: "sticky",
2150
+ top: 0,
2151
+ zIndex: 99
2152
+ }, 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) => {
2153
+ const row = rows[virtualRow.index];
2154
+ return (jsx(TableRow, { row: row, rowSelectionMode: rowSelectionMode }, row.id));
2155
+ } }), 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: {
2156
+ position: "sticky",
2157
+ bottom: 0,
2158
+ zIndex: 99
2159
+ }, children: jsxs("tr", { style: { backgroundColor: "white" }, children: [jsx("td", { className: "p-1", children: jsx(Checkbox, { checked: table.getIsSomePageRowsSelected()
2160
+ ? 'mixed'
2161
+ : 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: {
2162
+ position: "sticky",
2163
+ bottom: 0,
2164
+ zIndex: 99
2165
+ }, 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
2166
  }
2022
2167
 
2023
2168
  const TableContainer = (props) => {
2024
2169
  var _a, _b;
2025
2170
  const styles = useTableStaticStyles();
2026
- const { table, rowSelectionMode } = props;
2171
+ const { table } = props;
2172
+ const { tableHeight, rowSelectionMode } = table.options.meta || {};
2027
2173
  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;
2174
+ const { rows: { length: itemLength } } = table.getRowModel();
2035
2175
  const headerGroups = table.getHeaderGroups();
2036
2176
  // utilities
2037
- const isLoading = props.isLoading && virtualRows.length === 0;
2177
+ const isLoading = props.isLoading && itemLength === 0;
2038
2178
  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 && virtualRows.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, { rows: rows, virtualRows: virtualRows, rowSelectionMode: rowSelectionMode, totalSize: totalSize }), rowSelectionMode === 'multiple' &&
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 })] }));
2179
+ const noSearchResult = !isLoading && ((_b = props === null || props === void 0 ? void 0 : props.data) === null || _b === void 0 ? void 0 : _b.length) > 0 && itemLength === 0;
2180
+ 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$1, { 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
2181
  };
2047
2182
 
2048
2183
  const ViewSaveForm = (props) => {
@@ -2104,29 +2239,20 @@ const useFilterDrawerStyles = makeStyles({
2104
2239
  } }),
2105
2240
  });
2106
2241
  const ViewsDrawer = (props) => {
2107
- const { table, drawerState, dispatch, tableViews, applyTableState, resetToGridDefaultView, onTableViewSave } = props;
2108
- const styles = useFilterDrawerStyles();
2242
+ const { table, drawerState, dispatch, tableViews, applyTableState, resetToGridDefaultView } = props;
2243
+ const { onTableViewDelete, onTableViewSave } = table.options.meta || {};
2109
2244
  const [checkedValues, setCheckedValues] = React.useState({ font: ["calibri"] });
2110
2245
  const onChange = (e, { name, checkedItems }) => {
2111
2246
  setCheckedValues((s) => (Object.assign(Object.assign({}, s), { [name]: checkedItems })));
2112
2247
  };
2113
- // const resetAllFilters = React.useCallback(() => {
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]);
2248
+ const styles = useFilterDrawerStyles();
2123
2249
  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
2250
  return (jsxs("div", { style: {
2125
2251
  display: 'flex',
2126
2252
  justifyContent: 'space-between',
2127
2253
  alignItems: 'center',
2128
2254
  width: '100%',
2129
- }, children: [jsx(MenuItemRadio, { name: "table-views", value: view.viewName, onClick: () => applyTableState(view.tableState), icon: jsx(ViewDesktop20Regular, {}), children: view.viewName }), props.onTableViewDelete && (view === null || view === void 0 ? void 0 : view.isViewOwner) && (jsx(Button, { appearance: "subtle", "aria-label": "Close", icon: jsx(Dismiss24Regular, {}), onClick: () => { var _a; return (_a = props.onTableViewDelete) === null || _a === void 0 ? void 0 : _a.call(props, view); } }))] }, view.id + view.viewName));
2255
+ }, 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
2256
  })] })] }), jsx(DrawerFooter, { children: jsxs(MenuList, { children: [jsx(MenuDivider, {}), jsx(MenuItem, { icon: jsx(ClearFilterIcon, {}), onClick: resetToGridDefaultView, children: "Reset to Default View" })] }) })] }));
2131
2257
  };
2132
2258
 
@@ -2165,8 +2291,43 @@ function AdvancedTable(props, ref) {
2165
2291
  isFilterDrawerOpen: false,
2166
2292
  isViewsDrawerOpen: false
2167
2293
  });
2168
- return (jsxs(DndProvider, { backend: HTML5Backend, 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, rowSelectionMode: props.rowSelectionMode, 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, onTableViewSave: props.onTableViewSave, onTableViewDelete: props.onTableViewDelete })] }), jsx(Pagination, { table: table, pageSizeOptions: props.pageSizeOptions })] }));
2294
+ const { getState, setColumnOrder } = table;
2295
+ const { columnOrder } = getState();
2296
+ function handleDragEnd(event) {
2297
+ const { active, over } = event;
2298
+ if (active && over && (active === null || active === void 0 ? void 0 : active.id) !== (over === null || over === void 0 ? void 0 : over.id)) {
2299
+ setColumnOrder((items) => {
2300
+ const oldIndex = items.indexOf(active === null || active === void 0 ? void 0 : active.id);
2301
+ const newIndex = items.indexOf(over === null || over === void 0 ? void 0 : over.id);
2302
+ return arrayMove(items, oldIndex, newIndex);
2303
+ });
2304
+ }
2305
+ }
2306
+ const pointerSensor = useSensor(PointerSensor, {
2307
+ activationConstraint: {
2308
+ distance: 0.01
2309
+ }
2310
+ });
2311
+ const mouseSensor = useSensor(MouseSensor);
2312
+ const touchSensor = useSensor(TouchSensor);
2313
+ const keyboardSensor = useSensor(KeyboardSensor);
2314
+ const sensors = useSensors(mouseSensor, touchSensor, keyboardSensor, pointerSensor);
2315
+ 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
2316
  }
2170
2317
  const ForwardedAdvancedTable = React.forwardRef(AdvancedTable);
2171
2318
 
2172
- export { ForwardedAdvancedTable as Table };
2319
+ /* eslint-disable */
2320
+ function useSkipper() {
2321
+ const shouldSkipRef = React.useRef(true);
2322
+ const shouldSkip = shouldSkipRef.current;
2323
+ // Wrap a function with this to skip a pagination reset temporarily
2324
+ const skip = React.useCallback(() => {
2325
+ shouldSkipRef.current = false;
2326
+ }, []);
2327
+ React.useEffect(() => {
2328
+ shouldSkipRef.current = true;
2329
+ });
2330
+ return [shouldSkip, skip];
2331
+ }
2332
+
2333
+ export { ForwardedAdvancedTable as Table, useSkipper };