@prt-ts/fluent-react-table-v2 9.41.0-build.3.0 → 9.44.3-build.1.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.esm.d.ts +1 -0
- package/index.esm.js +2175 -0
- package/package.json +5 -6
- package/src/lib/components/filters/FilterDrawer.d.ts +4 -3
- package/src/lib/components/grid-header/GridHeader.d.ts +4 -5
- package/src/lib/components/reducer.d.ts +17 -0
- package/src/lib/components/table/useTableStaticStyles.d.ts +1 -1
- package/src/lib/components/tbody/TableBody.d.ts +11 -0
- package/src/lib/components/tbody/TableCell.d.ts +7 -0
- package/src/lib/components/tbody/TableRow.d.ts +8 -0
- package/src/lib/components/tbody/index.d.ts +3 -0
- package/src/lib/components/tbody/useTableBodyStyles.d.ts +1 -0
- package/src/lib/components/thead/HeaderCell.d.ts +4 -5
- package/src/lib/components/thead/HeaderRow.d.ts +10 -0
- package/src/lib/components/thead/TableHeader.d.ts +9 -0
- package/src/lib/components/thead/index.d.ts +2 -0
- package/src/lib/components/thead/useTableHeaderStyles.d.ts +1 -0
- package/src/lib/components/useGridContainer.d.ts +1 -2
- package/src/lib/components/views/ViewSaveForm.d.ts +1 -1
- package/src/lib/components/views/ViewsDrawer.d.ts +4 -4
- package/src/lib/index.d.ts +6 -1
- package/src/lib/types/TableRef.d.ts +2 -2
- package/src/lib/types/TableView.d.ts +1 -1
- package/vite.config.d.ts +1 -1
- package/index.js +0 -1124
package/index.js
DELETED
|
@@ -1,1124 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import * as React from 'react';
|
|
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, mergeClasses, Menu, MenuTrigger, MenuButton, MenuPopover, MenuList, MenuGroup, MenuItem, MenuDivider, Skeleton, SkeletonItem, Subtitle2Stronger, MenuItemRadio, DrawerFooter } from '@fluentui/react-components';
|
|
7
|
-
import { PreviousRegular, ArrowPreviousFilled, ArrowNextFilled, NextRegular, bundleIcon, SaveFilled, SaveRegular, TableSimpleCheckmarkFilled, TableSimpleCheckmarkRegular, SearchFilled, SearchRegular, FilterFilled, FilterRegular, CodeTextOff16Filled, CodeTextOff16Regular, ColumnEditFilled, ColumnEditRegular, GroupFilled, GroupRegular, ChevronRightFilled, ChevronRightRegular, ChevronDownRegular, ChevronDownFilled, DragFilled, DragRegular, Album24Regular, Search24Regular, FilterDismissFilled, Dismiss24Regular, ArrowSortDown20Filled, ArrowSortDown20Regular, ArrowSortUp20Filled, ArrowSortUp20Regular, GroupListRegular, PinRegular, TextSortAscendingFilled, TextSortDescendingFilled, GroupDismissFilled, ArrowStepInLeftRegular, ArrowStepInRightRegular, PinOffRegular, DocumentSearch24Regular, Save20Filled, ViewDesktop20Filled, ViewDesktop20Regular } from '@fluentui/react-icons';
|
|
8
|
-
import { useReactTable, getCoreRowModel, getPaginationRowModel, getSortedRowModel, getFilteredRowModel, getGroupedRowModel, getExpandedRowModel, getFacetedUniqueValues, getFacetedMinMaxValues, flexRender } from '@tanstack/react-table';
|
|
9
|
-
export { createColumnHelper } from '@tanstack/react-table';
|
|
10
|
-
import { useVirtual } from 'react-virtual';
|
|
11
|
-
import { DatePicker } from '@fluentui/react-datepicker-compat';
|
|
12
|
-
|
|
13
|
-
const useStaticStyles = makeStaticStyles({
|
|
14
|
-
"*": {
|
|
15
|
-
boxSizing: "border-box",
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
const useTableStaticStyles = makeStyles({
|
|
19
|
-
tableContainer: Object.assign(Object.assign({ height: "650px", width: "100%" }, shorthands.overflow("hidden", "auto")), {
|
|
20
|
-
/* width */
|
|
21
|
-
":hover": Object.assign({}, shorthands.overflow("auto", "auto")), "::-webkit-scrollbar": Object.assign({ width: "6px", height: "4px" }, shorthands.borderRadius("50%")),
|
|
22
|
-
/* Track */
|
|
23
|
-
"::-webkit-scrollbar-track": {
|
|
24
|
-
"background-color": "#f1f1f1",
|
|
25
|
-
},
|
|
26
|
-
/* Handle */
|
|
27
|
-
"::-webkit-scrollbar-thumb": {
|
|
28
|
-
"background-color": "#888",
|
|
29
|
-
},
|
|
30
|
-
/* Handle on hover */
|
|
31
|
-
"::-webkit-scrollbar-thumb:hover": {
|
|
32
|
-
"background-color": "#555",
|
|
33
|
-
} }),
|
|
34
|
-
table: {
|
|
35
|
-
width: "100%",
|
|
36
|
-
borderCollapse: "collapse",
|
|
37
|
-
},
|
|
38
|
-
tHead: Object.assign(Object.assign({}, shorthands.padding("0px", "0px", "0px", "0px")), { zIndex: 1, backgroundColor: tokens.colorPaletteAnchorBackground2, color: tokens.colorNeutralForeground1, position: "sticky", top: 0, width: "100%", boxShadow: tokens.shadow2 }),
|
|
39
|
-
tHeadRow: Object.assign(Object.assign({}, shorthands.padding("0px", "0px", "0px", "0px")), shorthands.borderBottom(tokens.strokeWidthThickest, "solid", tokens.colorNeutralStroke1)),
|
|
40
|
-
tBody: Object.assign(Object.assign({}, shorthands.padding("0px", "0px", "0px", "0px")), { zIndex: 0 }),
|
|
41
|
-
tBodyRow: Object.assign(Object.assign(Object.assign({}, shorthands.padding("0px", "0px", "0px", "0px")), shorthands.borderBottom(tokens.strokeWidthThin, "solid", tokens.colorNeutralStroke1)), { ":nth-child(even)": {
|
|
42
|
-
backgroundColor: tokens.colorNeutralBackground2,
|
|
43
|
-
}, ":hover": {
|
|
44
|
-
backgroundColor: tokens.colorNeutralBackground2Hover,
|
|
45
|
-
} }),
|
|
46
|
-
tBodySelectedRow: Object.assign(Object.assign({ backgroundColor: tokens.colorBrandBackground2 }, shorthands.borderBottom(tokens.strokeWidthThin, "solid", tokens.colorNeutralStroke1)), { ":hover": {
|
|
47
|
-
backgroundColor: tokens.colorBrandBackground2Hover,
|
|
48
|
-
} }),
|
|
49
|
-
tBodyGroupedRow: Object.assign({ backgroundColor: tokens.colorNeutralBackground2 }, shorthands.borderBottom(tokens.strokeWidthThin, "solid", tokens.colorNeutralStroke1)),
|
|
50
|
-
tBodyCell: Object.assign(Object.assign({ backgroundColor: "transparent" }, shorthands.padding("2px", "4px")), { minHeight: "35px", height: "35px" }),
|
|
51
|
-
tFoot: {
|
|
52
|
-
backgroundColor: tokens.colorNeutralBackground1,
|
|
53
|
-
color: tokens.colorNeutralForeground1,
|
|
54
|
-
position: "sticky",
|
|
55
|
-
bottom: 0,
|
|
56
|
-
left: 0,
|
|
57
|
-
width: "100%",
|
|
58
|
-
},
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
const usePaginationStyle = makeStyles({
|
|
62
|
-
paginationContainer: Object.assign({ width: "100%", backgroundColor: tokens.colorNeutralBackground2Hover }, shorthands.padding("5px")),
|
|
63
|
-
wrapper: {
|
|
64
|
-
columnGap: "0.2rem",
|
|
65
|
-
display: "flex",
|
|
66
|
-
alignItems: "center",
|
|
67
|
-
alignContent: "center",
|
|
68
|
-
justifyContent: "space-between",
|
|
69
|
-
// if smaller size display flex column
|
|
70
|
-
"@media screen and (max-width: 640px)": {
|
|
71
|
-
flexDirection: "column",
|
|
72
|
-
rowGap: "0.2rem",
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
pageBtnContainer: {
|
|
76
|
-
display: "flex",
|
|
77
|
-
columnGap: "3px",
|
|
78
|
-
},
|
|
79
|
-
pageBtn: {
|
|
80
|
-
minWidth: "1.5rem",
|
|
81
|
-
minHeight: "1.5rem",
|
|
82
|
-
alignContent: "center",
|
|
83
|
-
alignItems: "center",
|
|
84
|
-
},
|
|
85
|
-
pageSelectionWrapper: {
|
|
86
|
-
minWidth: "1.5rem",
|
|
87
|
-
},
|
|
88
|
-
pageSelectionDropdown: {
|
|
89
|
-
minWidth: "100%",
|
|
90
|
-
},
|
|
91
|
-
pageSizeInput: {
|
|
92
|
-
minWidth: "1.5rem",
|
|
93
|
-
width: "4rem",
|
|
94
|
-
},
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
const range = (from, to, step = 1) => {
|
|
98
|
-
var _a;
|
|
99
|
-
return (_a = [...Array(Math.floor((to - from) / step) + 1)]) === null || _a === void 0 ? void 0 : _a.map((_, i) => from + i * step);
|
|
100
|
-
};
|
|
101
|
-
const DEFAULT_NUMBER_OF_PAGE_BTN = 5;
|
|
102
|
-
const Pagination = (props) => {
|
|
103
|
-
const { table, pageSizeOptions = [10, 20, 50, 100, 1000] } = props;
|
|
104
|
-
const pageSizeSelectionId = useId("page-size-selector");
|
|
105
|
-
const styles = usePaginationStyle();
|
|
106
|
-
const totalNumberOfPage = table.getPageCount();
|
|
107
|
-
const currentPage = table.getState().pagination.pageIndex;
|
|
108
|
-
const pageSize = table.getState().pagination.pageSize;
|
|
109
|
-
const pageSelectionOptions = useMemo(() => {
|
|
110
|
-
let start = currentPage - Math.floor(DEFAULT_NUMBER_OF_PAGE_BTN / 2);
|
|
111
|
-
let end = currentPage + Math.floor(DEFAULT_NUMBER_OF_PAGE_BTN / 2);
|
|
112
|
-
if (start < 1) {
|
|
113
|
-
start = 1;
|
|
114
|
-
end =
|
|
115
|
-
totalNumberOfPage > DEFAULT_NUMBER_OF_PAGE_BTN
|
|
116
|
-
? DEFAULT_NUMBER_OF_PAGE_BTN
|
|
117
|
-
: totalNumberOfPage;
|
|
118
|
-
}
|
|
119
|
-
else if (end > totalNumberOfPage) {
|
|
120
|
-
const possibleStart = totalNumberOfPage - DEFAULT_NUMBER_OF_PAGE_BTN + 1;
|
|
121
|
-
start = possibleStart < 1 ? 1 : possibleStart;
|
|
122
|
-
end = totalNumberOfPage;
|
|
123
|
-
}
|
|
124
|
-
const currentPageOptions = end - start >= 0 ? range(start, end) : [];
|
|
125
|
-
return (currentPageOptions === null || currentPageOptions === void 0 ? void 0 : currentPageOptions.length) ? [...currentPageOptions] : [1];
|
|
126
|
-
}, [totalNumberOfPage, currentPage]);
|
|
127
|
-
return (jsx("div", Object.assign({ className: styles.paginationContainer }, { children: jsxs("div", Object.assign({ className: styles.wrapper }, { children: [jsx("div", Object.assign({ className: styles.pageSelectionWrapper }, { children: jsx(Dropdown, Object.assign({ 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, Object.assign({ value: `${option}` }, { children: `${option}` }), option))) })) })), jsxs("div", Object.assign({ 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) => {
|
|
128
|
-
const page = data.value ? Number(e.target.value) - 1 : 0;
|
|
129
|
-
if (page >= 0 && page < table.getPageCount()) {
|
|
130
|
-
table.setPageIndex(page);
|
|
131
|
-
}
|
|
132
|
-
}, 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, Object.assign({ 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" })] }))] })) })));
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
bundleIcon(SaveFilled, SaveRegular);
|
|
136
|
-
bundleIcon(TableSimpleCheckmarkFilled, TableSimpleCheckmarkRegular);
|
|
137
|
-
bundleIcon(SearchFilled, SearchRegular);
|
|
138
|
-
bundleIcon(FilterFilled, FilterRegular);
|
|
139
|
-
const ClearFilterIcon = bundleIcon(CodeTextOff16Filled, CodeTextOff16Regular);
|
|
140
|
-
const ToggleSelectColumnIcon = bundleIcon(ColumnEditFilled, ColumnEditRegular);
|
|
141
|
-
const ToggleGroupColumnIcon = bundleIcon(GroupFilled, GroupRegular);
|
|
142
|
-
const GroupCollapsedIcon = bundleIcon(ChevronRightFilled, ChevronRightRegular);
|
|
143
|
-
const GroupExpandedIcon = bundleIcon(ChevronDownRegular, ChevronDownFilled);
|
|
144
|
-
bundleIcon(DragFilled, DragRegular);
|
|
145
|
-
|
|
146
|
-
const useGridHeaderStyles = makeStyles({
|
|
147
|
-
tableTopHeaderContainer: Object.assign({ display: "flex", justifyContent: "space-between", alignItems: "flex-end", width: "100%", backgroundColor: tokens.colorBrandBackground2Hover }, shorthands.padding("5px")),
|
|
148
|
-
tableTopHeaderLeft: {
|
|
149
|
-
display: "flex",
|
|
150
|
-
justifyContent: "flex-start",
|
|
151
|
-
},
|
|
152
|
-
tableTopHeaderRight: Object.assign({ display: "flex", justifyContent: "flex-end" }, shorthands.gap("3px")),
|
|
153
|
-
tableTopHeaderColumnTogglePopover: {
|
|
154
|
-
display: "flex",
|
|
155
|
-
flexDirection: "column",
|
|
156
|
-
justifyContent: "flex-start",
|
|
157
|
-
alignItems: "flex-start",
|
|
158
|
-
width: "100%",
|
|
159
|
-
height: "100%",
|
|
160
|
-
},
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
const GridHeader = (props) => {
|
|
164
|
-
const { table, gridTitle, globalFilter, setGlobalFilter } = props;
|
|
165
|
-
const styles = useGridHeaderStyles();
|
|
166
|
-
return (jsxs("div", Object.assign({ className: styles.tableTopHeaderContainer }, { children: [jsx("div", Object.assign({ className: styles.tableTopHeaderLeft }, { children: gridTitle })), jsxs("div", Object.assign({ className: styles.tableTopHeaderRight }, { children: [props.headerMenu, props.headerMenu && jsx(Divider, { vertical: true }), jsxs(Popover, Object.assign({ withArrow: true }, { children: [jsx(PopoverTrigger, Object.assign({ disableButtonEnhancement: true }, { children: jsx(Tooltip, Object.assign({ content: 'Toggle Group Column', relationship: "label" }, { children: jsx(Button, { icon: jsx(ToggleGroupColumnIcon, {}), "aria-label": "Toggle Group Column" }) })) })), jsx(PopoverSurface, { children: jsxs("div", Object.assign({ className: styles.tableTopHeaderColumnTogglePopover }, { children: [jsx(MenuGroupHeader, { children: "Group Columns" }), table.getAllLeafColumns().map((column) => {
|
|
167
|
-
if (column.id === 'select')
|
|
168
|
-
return null;
|
|
169
|
-
if (column.id === 'id')
|
|
170
|
-
return null;
|
|
171
|
-
return (jsx(Checkbox, { checked: column.getIsGrouped(), onChange: column.getToggleGroupingHandler(), disabled: !column.getCanGroup() || !column.getIsVisible(), label: jsx("span", { children: column.columnDef.id }) }, column.id));
|
|
172
|
-
})] })) })] })), jsxs(Popover, Object.assign({ withArrow: true }, { children: [jsx(PopoverTrigger, Object.assign({ disableButtonEnhancement: true }, { children: jsx(Tooltip, Object.assign({ content: 'Toggle Column Visibility', relationship: "label" }, { children: jsx(Button, { icon: jsx(ToggleSelectColumnIcon, {}), "aria-label": "Toggle Column Visibility" }) })) })), jsx(PopoverSurface, { children: jsxs("div", Object.assign({ 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) => {
|
|
173
|
-
if (column.id === 'select')
|
|
174
|
-
return null;
|
|
175
|
-
return (jsx(Checkbox, { checked: column.getIsVisible(), onChange: column.getToggleVisibilityHandler(), label: column.id, disabled: !column.getCanHide() }, column.id));
|
|
176
|
-
})] })) })] })), jsx(Tooltip, Object.assign({ content: 'Table Views Management', relationship: "label" }, { children: jsx(Button
|
|
177
|
-
// appearance="subtle"
|
|
178
|
-
, {
|
|
179
|
-
// appearance="subtle"
|
|
180
|
-
onClick: () => props.setViewsDrawerOpen((value) => !value), 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...", openFilterDrawer: props.openFilterDrawer, setFilterDrawerOpen: props.setFilterDrawerOpen })] }))] })));
|
|
181
|
-
};
|
|
182
|
-
// A debounced input react component
|
|
183
|
-
function DebouncedInput({ value: initialValue, onChange, debounce = 500, openFilterDrawer, setFilterDrawerOpen, }) {
|
|
184
|
-
const [value, setValue] = React.useState('');
|
|
185
|
-
React.useEffect(() => {
|
|
186
|
-
setValue(initialValue);
|
|
187
|
-
}, [initialValue]);
|
|
188
|
-
React.useEffect(() => {
|
|
189
|
-
const timeout = setTimeout(() => {
|
|
190
|
-
onChange(value);
|
|
191
|
-
}, debounce);
|
|
192
|
-
return () => clearTimeout(timeout);
|
|
193
|
-
}, [value, onChange, debounce]);
|
|
194
|
-
return (jsx(Input, { placeholder: "Search Keyword", value: value, onChange: (_, data) => setValue(data.value), type: "search", autoComplete: "off", contentBefore: jsx(Search24Regular, {}), style: { width: '300px' }, contentAfter: jsx(Tooltip, Object.assign({ content: openFilterDrawer ? 'Close Filter Window' : 'Open Advance Filter', relationship: "label" }, { children: jsx(Button, { appearance: "subtle", icon: openFilterDrawer ? jsx(FilterDismissFilled, {}) : jsx(FilterFilled, {}), "aria-label": "View Menu", onClick: () => {
|
|
195
|
-
setFilterDrawerOpen((open) => !open);
|
|
196
|
-
} }) })) }));
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
const arrIncludesSome = (row, columnId, value) => {
|
|
200
|
-
// Rank the item
|
|
201
|
-
const rowValue = row.getValue(columnId);
|
|
202
|
-
const passed = Array.isArray(value) &&
|
|
203
|
-
((value === null || value === void 0 ? void 0 : value.length) === 0 || value.includes(`${rowValue}`));
|
|
204
|
-
return passed;
|
|
205
|
-
};
|
|
206
|
-
const dateRange = (row, columnId, value) => {
|
|
207
|
-
// filter by date range
|
|
208
|
-
const rowValue = row.getValue(columnId);
|
|
209
|
-
// compare the date range
|
|
210
|
-
// case if no start date or end date is selected
|
|
211
|
-
// case if start date is selected
|
|
212
|
-
// case if end date is selected
|
|
213
|
-
if (!value || value.length === 0) {
|
|
214
|
-
return true;
|
|
215
|
-
}
|
|
216
|
-
else if (value.length === 2 && value[0] && !value[1]) {
|
|
217
|
-
return typeof rowValue.getMonth === 'function' && rowValue >= value[0];
|
|
218
|
-
}
|
|
219
|
-
else if (value.length === 2 && !value[0] && value[1]) {
|
|
220
|
-
return typeof rowValue.getMonth === 'function' && rowValue <= value[1];
|
|
221
|
-
}
|
|
222
|
-
else if (value.length === 2 && !value[0] && !value[1]) {
|
|
223
|
-
return true;
|
|
224
|
-
}
|
|
225
|
-
const passed = typeof rowValue.getMonth === 'function' && value[0] <= rowValue && rowValue <= value[1];
|
|
226
|
-
return passed;
|
|
227
|
-
};
|
|
228
|
-
const date = (row, columnId, value) => {
|
|
229
|
-
var _a;
|
|
230
|
-
// filter by date range
|
|
231
|
-
const rowValue = row.getValue(columnId);
|
|
232
|
-
// compare the date range
|
|
233
|
-
// case if no start date or end date is selected
|
|
234
|
-
// case if start date is selected
|
|
235
|
-
// case if end date is selected
|
|
236
|
-
if (!value) {
|
|
237
|
-
return true;
|
|
238
|
-
}
|
|
239
|
-
const passed = typeof rowValue.getMonth === 'function' && ((_a = new Date(value)) === null || _a === void 0 ? void 0 : _a.toDateString()) === (rowValue === null || rowValue === void 0 ? void 0 : rowValue.toDateString());
|
|
240
|
-
return passed;
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
const getLeafColumns = (columns) => {
|
|
244
|
-
if (!columns || !columns.length) {
|
|
245
|
-
return [];
|
|
246
|
-
}
|
|
247
|
-
return columns.reduce((totalItems, col) => {
|
|
248
|
-
if (!col.columns) {
|
|
249
|
-
totalItems.push(col);
|
|
250
|
-
}
|
|
251
|
-
return totalItems.concat(getLeafColumns(col.columns));
|
|
252
|
-
}, []);
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
const useGridContainer = (props, ref) => {
|
|
256
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
257
|
-
const { columns, data, rowSelectionMode } = props;
|
|
258
|
-
const [pagination, setPagination] = React.useState({
|
|
259
|
-
pageSize: props.pageSize || 10,
|
|
260
|
-
pageIndex: 0,
|
|
261
|
-
});
|
|
262
|
-
const [sorting, setSorting] = React.useState((_a = props.sortingState) !== null && _a !== void 0 ? _a : []);
|
|
263
|
-
const [columnFilters, setColumnFilters] = React.useState((_b = props.columnFilterState) !== null && _b !== void 0 ? _b : []);
|
|
264
|
-
const [globalFilter, setGlobalFilter] = React.useState((_c = props.defaultGlobalFilter) !== null && _c !== void 0 ? _c : '');
|
|
265
|
-
const [grouping, setGrouping] = React.useState((_d = props.groupingState) !== null && _d !== void 0 ? _d : []);
|
|
266
|
-
const [rowSelection, setRowSelection] = React.useState((_e = props.rowSelectionState) !== null && _e !== void 0 ? _e : {});
|
|
267
|
-
const [columnVisibility, setColumnVisibility] = React.useState((_f = props.columnVisibility) !== null && _f !== void 0 ? _f : {});
|
|
268
|
-
const [columnOrder, setColumnOrder] = React.useState(() => {
|
|
269
|
-
if (props.columnOrderState) {
|
|
270
|
-
return props.columnOrderState;
|
|
271
|
-
}
|
|
272
|
-
const leafColumns = getLeafColumns(columns);
|
|
273
|
-
return leafColumns.map((col) => col.id);
|
|
274
|
-
});
|
|
275
|
-
const [expanded, setExpanded] = React.useState((_g = props.expandedState) !== null && _g !== void 0 ? _g : {});
|
|
276
|
-
const [columnPinning, setColumnPinning] = React.useState((_h = props.columnPinningState) !== null && _h !== void 0 ? _h : {});
|
|
277
|
-
const [columnSizing, setColumnSizing] = React.useState({});
|
|
278
|
-
const tableViews = React.useMemo(() => { var _a; return (_a = props.views) !== null && _a !== void 0 ? _a : []; }, [props.views]);
|
|
279
|
-
const table = useReactTable({
|
|
280
|
-
columns: columns,
|
|
281
|
-
data,
|
|
282
|
-
filterFns: {
|
|
283
|
-
arrIncludesSome: arrIncludesSome,
|
|
284
|
-
inDateRange: dateRange,
|
|
285
|
-
matchDate: date,
|
|
286
|
-
},
|
|
287
|
-
initialState: {
|
|
288
|
-
expanded: true,
|
|
289
|
-
},
|
|
290
|
-
state: {
|
|
291
|
-
pagination,
|
|
292
|
-
sorting,
|
|
293
|
-
columnFilters,
|
|
294
|
-
globalFilter,
|
|
295
|
-
grouping,
|
|
296
|
-
expanded,
|
|
297
|
-
rowSelection,
|
|
298
|
-
columnOrder,
|
|
299
|
-
columnVisibility,
|
|
300
|
-
columnPinning,
|
|
301
|
-
columnSizing,
|
|
302
|
-
},
|
|
303
|
-
columnResizeMode: 'onChange',
|
|
304
|
-
enableRowSelection: rowSelectionMode !== undefined,
|
|
305
|
-
enableMultiRowSelection: rowSelectionMode === 'multiple',
|
|
306
|
-
enableFilters: true,
|
|
307
|
-
enableGlobalFilter: true,
|
|
308
|
-
enableColumnFilters: true,
|
|
309
|
-
filterFromLeafRows: true,
|
|
310
|
-
autoResetExpanded: false,
|
|
311
|
-
onRowSelectionChange: setRowSelection,
|
|
312
|
-
onPaginationChange: setPagination,
|
|
313
|
-
onSortingChange: setSorting,
|
|
314
|
-
onColumnFiltersChange: setColumnFilters,
|
|
315
|
-
onGlobalFilterChange: setGlobalFilter,
|
|
316
|
-
onGroupingChange: setGrouping,
|
|
317
|
-
onColumnOrderChange: setColumnOrder,
|
|
318
|
-
onExpandedChange: setExpanded,
|
|
319
|
-
onColumnVisibilityChange: setColumnVisibility,
|
|
320
|
-
onColumnPinningChange: setColumnPinning,
|
|
321
|
-
onColumnSizingChange: setColumnSizing,
|
|
322
|
-
getCoreRowModel: getCoreRowModel(),
|
|
323
|
-
getPaginationRowModel: getPaginationRowModel(),
|
|
324
|
-
getSortedRowModel: getSortedRowModel(),
|
|
325
|
-
getFilteredRowModel: getFilteredRowModel(),
|
|
326
|
-
getGroupedRowModel: getGroupedRowModel(),
|
|
327
|
-
getExpandedRowModel: getExpandedRowModel(),
|
|
328
|
-
getFacetedUniqueValues: getFacetedUniqueValues(),
|
|
329
|
-
getFacetedMinMaxValues: getFacetedMinMaxValues(),
|
|
330
|
-
});
|
|
331
|
-
const getTableState = React.useCallback(() => {
|
|
332
|
-
return {
|
|
333
|
-
pagination,
|
|
334
|
-
sorting,
|
|
335
|
-
columnFilters,
|
|
336
|
-
globalFilter,
|
|
337
|
-
grouping,
|
|
338
|
-
expanded,
|
|
339
|
-
rowSelection,
|
|
340
|
-
columnOrder,
|
|
341
|
-
columnVisibility,
|
|
342
|
-
columnPinning,
|
|
343
|
-
columnSizing
|
|
344
|
-
};
|
|
345
|
-
}, [
|
|
346
|
-
pagination,
|
|
347
|
-
sorting,
|
|
348
|
-
columnFilters,
|
|
349
|
-
globalFilter,
|
|
350
|
-
grouping,
|
|
351
|
-
expanded,
|
|
352
|
-
rowSelection,
|
|
353
|
-
columnOrder,
|
|
354
|
-
columnVisibility,
|
|
355
|
-
columnPinning,
|
|
356
|
-
columnSizing
|
|
357
|
-
]);
|
|
358
|
-
const resetToDefaultView = () => {
|
|
359
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
360
|
-
const defaultTableState = {
|
|
361
|
-
pagination: {
|
|
362
|
-
pageSize: props.pageSize || 10,
|
|
363
|
-
pageIndex: 0,
|
|
364
|
-
},
|
|
365
|
-
sorting: (_a = props.sortingState) !== null && _a !== void 0 ? _a : [],
|
|
366
|
-
columnFilters: (_b = props.columnFilterState) !== null && _b !== void 0 ? _b : [],
|
|
367
|
-
globalFilter: (_c = props.defaultGlobalFilter) !== null && _c !== void 0 ? _c : '',
|
|
368
|
-
grouping: (_d = props.groupingState) !== null && _d !== void 0 ? _d : [],
|
|
369
|
-
expanded: (_e = props.expandedState) !== null && _e !== void 0 ? _e : {},
|
|
370
|
-
rowSelection: (_f = props.rowSelectionState) !== null && _f !== void 0 ? _f : {},
|
|
371
|
-
columnOrder: (() => {
|
|
372
|
-
if (props.columnOrderState) {
|
|
373
|
-
return props.columnOrderState;
|
|
374
|
-
}
|
|
375
|
-
const leafColumns = getLeafColumns(columns);
|
|
376
|
-
return leafColumns.map((col) => col.id);
|
|
377
|
-
})(),
|
|
378
|
-
columnVisibility: (_g = props.columnVisibility) !== null && _g !== void 0 ? _g : {},
|
|
379
|
-
columnPinning: (_h = props.columnPinningState) !== null && _h !== void 0 ? _h : {},
|
|
380
|
-
columnSizing: {}
|
|
381
|
-
};
|
|
382
|
-
return applyTableState(defaultTableState);
|
|
383
|
-
};
|
|
384
|
-
const applyTableState = (tableState) => {
|
|
385
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
386
|
-
if (tableState) {
|
|
387
|
-
setSorting((_a = tableState.sorting) !== null && _a !== void 0 ? _a : []);
|
|
388
|
-
setColumnFilters((_b = tableState.columnFilters) !== null && _b !== void 0 ? _b : []);
|
|
389
|
-
setGlobalFilter((_c = tableState.globalFilter) !== null && _c !== void 0 ? _c : '');
|
|
390
|
-
setGrouping((_d = tableState.grouping) !== null && _d !== void 0 ? _d : []);
|
|
391
|
-
setExpanded((_e = tableState.expanded) !== null && _e !== void 0 ? _e : {});
|
|
392
|
-
setRowSelection((_f = tableState.rowSelection) !== null && _f !== void 0 ? _f : {});
|
|
393
|
-
setColumnOrder((_g = tableState.columnOrder) !== null && _g !== void 0 ? _g : []);
|
|
394
|
-
setColumnVisibility((_h = tableState.columnVisibility) !== null && _h !== void 0 ? _h : {});
|
|
395
|
-
setColumnPinning((_j = tableState.columnPinning) !== null && _j !== void 0 ? _j : {});
|
|
396
|
-
setColumnSizing((_k = tableState.columnSizing) !== null && _k !== void 0 ? _k : {});
|
|
397
|
-
setTimeout(() => {
|
|
398
|
-
var _a;
|
|
399
|
-
setPagination((_a = tableState.pagination) !== null && _a !== void 0 ? _a : {
|
|
400
|
-
pageSize: props.pageSize || 10,
|
|
401
|
-
pageIndex: 0,
|
|
402
|
-
});
|
|
403
|
-
}, 10);
|
|
404
|
-
return true;
|
|
405
|
-
}
|
|
406
|
-
return false;
|
|
407
|
-
};
|
|
408
|
-
React.useImperativeHandle(ref, () => {
|
|
409
|
-
return {
|
|
410
|
-
table,
|
|
411
|
-
getTableState,
|
|
412
|
-
applyTableState,
|
|
413
|
-
resetToDefaultView
|
|
414
|
-
};
|
|
415
|
-
},
|
|
416
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
417
|
-
[table, getTableState]);
|
|
418
|
-
const headerMenu = React.useMemo(() => {
|
|
419
|
-
if (props.headerMenu) {
|
|
420
|
-
const selectedRows = (table === null || table === void 0 ? void 0 : table.getSelectedRowModel().flatRows.map((row) => row.original)) || [];
|
|
421
|
-
return props.headerMenu(selectedRows);
|
|
422
|
-
}
|
|
423
|
-
return null;
|
|
424
|
-
},
|
|
425
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
426
|
-
[props.headerMenu, rowSelection]);
|
|
427
|
-
// add event listeners to listen ctrl + shift + t and log current table state
|
|
428
|
-
React.useEffect(() => {
|
|
429
|
-
const handleKeyDown = (event) => {
|
|
430
|
-
if (event.ctrlKey && event.altKey && event.key === 'c') {
|
|
431
|
-
event.preventDefault();
|
|
432
|
-
const tableState = getTableState();
|
|
433
|
-
// log table state to console
|
|
434
|
-
console.log(tableState);
|
|
435
|
-
// save table state to local storage
|
|
436
|
-
localStorage.setItem('hotkey_table_state_temp', JSON.stringify(tableState));
|
|
437
|
-
// copy table state to clipboard
|
|
438
|
-
navigator.clipboard.writeText(JSON.stringify(tableState));
|
|
439
|
-
}
|
|
440
|
-
};
|
|
441
|
-
window.addEventListener('keydown', handleKeyDown);
|
|
442
|
-
return () => {
|
|
443
|
-
window.removeEventListener('keydown', handleKeyDown);
|
|
444
|
-
};
|
|
445
|
-
}, [getTableState]);
|
|
446
|
-
return {
|
|
447
|
-
table,
|
|
448
|
-
globalFilter,
|
|
449
|
-
tableViews,
|
|
450
|
-
headerMenu,
|
|
451
|
-
setGlobalFilter,
|
|
452
|
-
resetToDefaultView,
|
|
453
|
-
applyTableState,
|
|
454
|
-
getTableState
|
|
455
|
-
};
|
|
456
|
-
};
|
|
457
|
-
|
|
458
|
-
const useCheckboxFilterStyles = makeStyles({
|
|
459
|
-
searchInput: {
|
|
460
|
-
width: '90%',
|
|
461
|
-
marginBottom: '8px',
|
|
462
|
-
marginLeft: '10px',
|
|
463
|
-
marginRight: '10px',
|
|
464
|
-
},
|
|
465
|
-
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%')),
|
|
466
|
-
/* Track */
|
|
467
|
-
'::-webkit-scrollbar-track': {
|
|
468
|
-
'background-color': '#f1f1f1',
|
|
469
|
-
},
|
|
470
|
-
/* Handle */
|
|
471
|
-
'::-webkit-scrollbar-thumb': {
|
|
472
|
-
'background-color': '#888',
|
|
473
|
-
},
|
|
474
|
-
/* Handle on hover */
|
|
475
|
-
'::-webkit-scrollbar-thumb:hover': {
|
|
476
|
-
'background-color': '#555',
|
|
477
|
-
} }),
|
|
478
|
-
});
|
|
479
|
-
const FilterMultiSelectCheckbox = ({ column, table, }) => {
|
|
480
|
-
var _a, _b, _c;
|
|
481
|
-
const firstValue = (_a = table
|
|
482
|
-
.getPreFilteredRowModel()
|
|
483
|
-
.flatRows[0]) === null || _a === void 0 ? void 0 : _a.getValue(column.id);
|
|
484
|
-
const columnFilterValue = column.getFilterValue();
|
|
485
|
-
const [filterOptions, setFilterOptions] = React.useState([]);
|
|
486
|
-
React.useEffect(() => {
|
|
487
|
-
const uniqueSortedOptions = typeof firstValue === 'number' || !isNaN(firstValue)
|
|
488
|
-
? Array.from(column.getFacetedUniqueValues().keys()).sort((a, b) => Number(a) - Number(b))
|
|
489
|
-
: Array.from(column.getFacetedUniqueValues().keys()).sort();
|
|
490
|
-
setFilterOptions(uniqueSortedOptions);
|
|
491
|
-
},
|
|
492
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
493
|
-
[column.getFacetedUniqueValues()]);
|
|
494
|
-
const [localColumnFilterValue, setLocalColumnFilterValue] = React.useState('');
|
|
495
|
-
const filterOptionsFiltered = React.useMemo(() => {
|
|
496
|
-
if (!localColumnFilterValue)
|
|
497
|
-
return filterOptions;
|
|
498
|
-
return filterOptions.filter((option) => {
|
|
499
|
-
var _a, _b, _c;
|
|
500
|
-
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());
|
|
501
|
-
});
|
|
502
|
-
}, [localColumnFilterValue, filterOptions]);
|
|
503
|
-
const filterContainer = React.useRef(null);
|
|
504
|
-
const rowVirtualizer = useVirtual({
|
|
505
|
-
parentRef: filterContainer,
|
|
506
|
-
size: filterOptionsFiltered.length,
|
|
507
|
-
overscan: 15,
|
|
508
|
-
});
|
|
509
|
-
const { virtualItems: virtualRows, totalSize } = rowVirtualizer;
|
|
510
|
-
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;
|
|
511
|
-
const paddingBottom = virtualRows.length > 0
|
|
512
|
-
? totalSize - (((_c = virtualRows === null || virtualRows === void 0 ? void 0 : virtualRows[virtualRows.length - 1]) === null || _c === void 0 ? void 0 : _c.end) || 0)
|
|
513
|
-
: 0;
|
|
514
|
-
const allOptionChecked = (columnFilterValue === null || columnFilterValue === void 0 ? void 0 : columnFilterValue.length) > 0 &&
|
|
515
|
-
(columnFilterValue === null || columnFilterValue === void 0 ? void 0 : columnFilterValue.length) !== (filterOptions === null || filterOptions === void 0 ? void 0 : filterOptions.length)
|
|
516
|
-
? 'mixed'
|
|
517
|
-
: (columnFilterValue === null || columnFilterValue === void 0 ? void 0 : columnFilterValue.length) === (filterOptions === null || filterOptions === void 0 ? void 0 : filterOptions.length) &&
|
|
518
|
-
(filterOptions === null || filterOptions === void 0 ? void 0 : filterOptions.length) > 0;
|
|
519
|
-
const styles = useCheckboxFilterStyles();
|
|
520
|
-
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", Object.assign({ ref: filterContainer, className: styles.searchContainer }, { children: [paddingTop > 0 && (jsx("span", { style: { paddingTop: `${paddingTop}px` } })), jsx(Checkbox, { checked: allOptionChecked, onChange: () => {
|
|
521
|
-
if ((columnFilterValue === null || columnFilterValue === void 0 ? void 0 : columnFilterValue.length) > 0) {
|
|
522
|
-
column.setFilterValue(undefined);
|
|
523
|
-
return;
|
|
524
|
-
}
|
|
525
|
-
column.setFilterValue([
|
|
526
|
-
...((filterOptions === null || filterOptions === void 0 ? void 0 : filterOptions.map((x) => `${x}`)) || []),
|
|
527
|
-
]);
|
|
528
|
-
}, label: '(Toggle All)' }, `toggle-all-${column.id}`), virtualRows.map((row) => {
|
|
529
|
-
var _a;
|
|
530
|
-
const value = `${filterOptionsFiltered[row.index]}`;
|
|
531
|
-
return (jsx(Checkbox, { checked: (_a = columnFilterValue === null || columnFilterValue === void 0 ? void 0 : columnFilterValue.includes(value)) !== null && _a !== void 0 ? _a : false, onChange: () => {
|
|
532
|
-
if (columnFilterValue === null || columnFilterValue === void 0 ? void 0 : columnFilterValue.includes(value)) {
|
|
533
|
-
column.setFilterValue((old) => old === null || old === void 0 ? void 0 : old.filter((v) => v !== value));
|
|
534
|
-
return;
|
|
535
|
-
}
|
|
536
|
-
column.setFilterValue((old) => [
|
|
537
|
-
...(old || []),
|
|
538
|
-
value,
|
|
539
|
-
]);
|
|
540
|
-
}, label: value }, `${column.id}-${row.index}`));
|
|
541
|
-
}), paddingBottom > 0 && (jsx("span", { style: { paddingBottom: `${paddingBottom}px` } }))] }), 'filter-multi-select-checkbox')] }));
|
|
542
|
-
};
|
|
543
|
-
|
|
544
|
-
const useRadioFilterStyles = makeStyles({
|
|
545
|
-
searchInput: {
|
|
546
|
-
width: '90%',
|
|
547
|
-
marginBottom: '8px',
|
|
548
|
-
marginLeft: '10px',
|
|
549
|
-
marginRight: '10px',
|
|
550
|
-
},
|
|
551
|
-
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%')),
|
|
552
|
-
/* Track */
|
|
553
|
-
'::-webkit-scrollbar-track': {
|
|
554
|
-
'background-color': '#f1f1f1',
|
|
555
|
-
},
|
|
556
|
-
/* Handle */
|
|
557
|
-
'::-webkit-scrollbar-thumb': {
|
|
558
|
-
'background-color': '#888',
|
|
559
|
-
},
|
|
560
|
-
/* Handle on hover */
|
|
561
|
-
'::-webkit-scrollbar-thumb:hover': {
|
|
562
|
-
'background-color': '#555',
|
|
563
|
-
} }),
|
|
564
|
-
});
|
|
565
|
-
const FilterSelectRadio = ({ column, table, }) => {
|
|
566
|
-
var _a, _b, _c;
|
|
567
|
-
const firstValue = (_a = table
|
|
568
|
-
.getPreFilteredRowModel()
|
|
569
|
-
.flatRows[0]) === null || _a === void 0 ? void 0 : _a.getValue(column.id);
|
|
570
|
-
const columnFilterValue = column.getFilterValue();
|
|
571
|
-
const [filterOptions, setFilterOptions] = React.useState([]);
|
|
572
|
-
React.useEffect(() => {
|
|
573
|
-
const uniqueSortedOptions = typeof firstValue === 'number' || !isNaN(firstValue)
|
|
574
|
-
? Array.from(column.getFacetedUniqueValues().keys()).sort((a, b) => Number(a) - Number(b))
|
|
575
|
-
: Array.from(column.getFacetedUniqueValues().keys()).sort();
|
|
576
|
-
setFilterOptions(uniqueSortedOptions);
|
|
577
|
-
},
|
|
578
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
579
|
-
[column.getFacetedUniqueValues()]);
|
|
580
|
-
const [localColumnFilterValue, setLocalColumnFilterValue] = React.useState('');
|
|
581
|
-
const filterOptionsFiltered = React.useMemo(() => {
|
|
582
|
-
if (!localColumnFilterValue)
|
|
583
|
-
return filterOptions;
|
|
584
|
-
return filterOptions.filter((option) => {
|
|
585
|
-
var _a, _b, _c;
|
|
586
|
-
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());
|
|
587
|
-
});
|
|
588
|
-
}, [localColumnFilterValue, filterOptions]);
|
|
589
|
-
const filterContainer = React.useRef(null);
|
|
590
|
-
const rowVirtualizer = useVirtual({
|
|
591
|
-
parentRef: filterContainer,
|
|
592
|
-
size: filterOptionsFiltered.length,
|
|
593
|
-
overscan: 15,
|
|
594
|
-
});
|
|
595
|
-
const { virtualItems: virtualRows, totalSize } = rowVirtualizer;
|
|
596
|
-
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;
|
|
597
|
-
const paddingBottom = virtualRows.length > 0
|
|
598
|
-
? totalSize - (((_c = virtualRows === null || virtualRows === void 0 ? void 0 : virtualRows[virtualRows.length - 1]) === null || _c === void 0 ? void 0 : _c.end) || 0)
|
|
599
|
-
: 0;
|
|
600
|
-
const styles = useRadioFilterStyles();
|
|
601
|
-
return (jsxs("div", { children: [jsx(Input, { value: localColumnFilterValue, onChange: (_, data) => setLocalColumnFilterValue(data.value), placeholder: "Search Options...", size: "small", className: styles.searchInput }), jsxs("div", Object.assign({ ref: filterContainer, className: styles.searchContainer }, { children: [paddingTop > 0 && jsx("div", { style: { paddingTop: `${paddingTop}px` } }), jsxs(RadioGroup, Object.assign({ layout: "vertical", value: (columnFilterValue === null || columnFilterValue === void 0 ? void 0 : columnFilterValue[0]) || '', onChange: (_, data) => {
|
|
602
|
-
if (data.value === '') {
|
|
603
|
-
column.setFilterValue([]);
|
|
604
|
-
return;
|
|
605
|
-
}
|
|
606
|
-
column.setFilterValue([data.value]);
|
|
607
|
-
} }, { children: [jsx(Radio, { value: '', label: 'None' }), virtualRows.map((row) => {
|
|
608
|
-
const value = filterOptionsFiltered[row.index];
|
|
609
|
-
return jsx(Radio, { value: value, label: value }, value);
|
|
610
|
-
})] })), paddingBottom > 0 && (jsx("div", { style: { paddingBottom: `${paddingBottom}px` } }))] }))] }));
|
|
611
|
-
};
|
|
612
|
-
|
|
613
|
-
const useNumberRangeFilterStyles$2 = makeStyles({
|
|
614
|
-
searchInput: {
|
|
615
|
-
width: '100%',
|
|
616
|
-
},
|
|
617
|
-
searchInputField: {
|
|
618
|
-
width: '100%',
|
|
619
|
-
flexGrow: 1,
|
|
620
|
-
},
|
|
621
|
-
searchContainer: {
|
|
622
|
-
display: 'flex',
|
|
623
|
-
marginBottom: '8px',
|
|
624
|
-
marginLeft: '10px',
|
|
625
|
-
marginRight: '10px',
|
|
626
|
-
}
|
|
627
|
-
});
|
|
628
|
-
const FilterNumberRange = (props) => {
|
|
629
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
630
|
-
const { column } = props;
|
|
631
|
-
const columnFilterValue = column.getFilterValue();
|
|
632
|
-
const min = Number((_b = (_a = column.getFacetedMinMaxValues()) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : '');
|
|
633
|
-
const max = Number((_d = (_c = column.getFacetedMinMaxValues()) === null || _c === void 0 ? void 0 : _c[1]) !== null && _d !== void 0 ? _d : '');
|
|
634
|
-
const handleMinChange = (e, data) => {
|
|
635
|
-
const value = Number(data.value);
|
|
636
|
-
column.setFilterValue((old) => [value, old === null || old === void 0 ? void 0 : old[1]]);
|
|
637
|
-
};
|
|
638
|
-
const handleMaxChange = (e, data) => {
|
|
639
|
-
const value = Number(data.value);
|
|
640
|
-
column.setFilterValue((old) => [old === null || old === void 0 ? void 0 : old[0], value]);
|
|
641
|
-
};
|
|
642
|
-
const styles = useNumberRangeFilterStyles$2();
|
|
643
|
-
return (jsxs("div", Object.assign({ className: styles.searchContainer }, { children: [jsx(Field, Object.assign({ label: 'Min:', size: "small", className: styles.searchInputField }, { children: jsx(Input, { type: "number", value: `${(columnFilterValue === null || columnFilterValue === void 0 ? void 0 : columnFilterValue[0]) || ''}`, min: min, max: max, onChange: handleMinChange, className: styles.searchInput, placeholder: `Min ${((_e = column.getFacetedMinMaxValues()) === null || _e === void 0 ? void 0 : _e[0])
|
|
644
|
-
? `(${(_f = column.getFacetedMinMaxValues()) === null || _f === void 0 ? void 0 : _f[0]})`
|
|
645
|
-
: ''}` }) })), jsx(Field, Object.assign({ label: 'Max:', size: "small", className: styles.searchInputField }, { children: jsx(Input, { type: "number", value: `${(columnFilterValue === null || columnFilterValue === void 0 ? void 0 : columnFilterValue[1]) || ''}`, min: min, max: max, onChange: handleMaxChange, className: styles.searchInput, placeholder: `Max ${((_g = column.getFacetedMinMaxValues()) === null || _g === void 0 ? void 0 : _g[1])
|
|
646
|
-
? `(${(_h = column.getFacetedMinMaxValues()) === null || _h === void 0 ? void 0 : _h[1]})`
|
|
647
|
-
: ''}` }) }))] })));
|
|
648
|
-
};
|
|
649
|
-
|
|
650
|
-
const useNumberRangeFilterStyles$1 = makeStyles({
|
|
651
|
-
searchInput: {
|
|
652
|
-
width: '100%',
|
|
653
|
-
},
|
|
654
|
-
searchInputField: {
|
|
655
|
-
width: '100%',
|
|
656
|
-
flexGrow: 1,
|
|
657
|
-
},
|
|
658
|
-
searchContainer: {
|
|
659
|
-
display: 'flex',
|
|
660
|
-
flexDirection: 'column',
|
|
661
|
-
marginBottom: '8px',
|
|
662
|
-
marginLeft: '10px',
|
|
663
|
-
marginRight: '10px',
|
|
664
|
-
},
|
|
665
|
-
});
|
|
666
|
-
const FilterDateRange = (props) => {
|
|
667
|
-
var _a, _b, _c, _d;
|
|
668
|
-
const { column } = props;
|
|
669
|
-
const columnFilterValue = column.getFilterValue();
|
|
670
|
-
const min = (_b = (_a = column.getFacetedMinMaxValues()) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : undefined;
|
|
671
|
-
const max = (_d = (_c = column.getFacetedMinMaxValues()) === null || _c === void 0 ? void 0 : _c[1]) !== null && _d !== void 0 ? _d : undefined;
|
|
672
|
-
const handleMinChange = (date) => {
|
|
673
|
-
if (!date) {
|
|
674
|
-
column.setFilterValue((old) => [undefined, old === null || old === void 0 ? void 0 : old[1]]);
|
|
675
|
-
return;
|
|
676
|
-
}
|
|
677
|
-
column.setFilterValue((old) => [date, old === null || old === void 0 ? void 0 : old[1]]);
|
|
678
|
-
};
|
|
679
|
-
const handleMaxChange = (date) => {
|
|
680
|
-
if (!date) {
|
|
681
|
-
column.setFilterValue((old) => [old === null || old === void 0 ? void 0 : old[0], undefined]);
|
|
682
|
-
return;
|
|
683
|
-
}
|
|
684
|
-
column.setFilterValue((old) => [old === null || old === void 0 ? void 0 : old[0], date]);
|
|
685
|
-
};
|
|
686
|
-
const styles = useNumberRangeFilterStyles$1();
|
|
687
|
-
return (jsxs("div", Object.assign({ className: styles.searchContainer }, { children: [jsx(Field, Object.assign({ label: 'From Date:', size: "small", className: styles.searchInputField }, { children: jsx(DatePicker, { value: (columnFilterValue === null || columnFilterValue === void 0 ? void 0 : columnFilterValue[0]) || null, min: min, max: max, onSelectDate: handleMinChange, className: styles.searchInput, placeholder: `From Date`, size: 'small', allowTextInput: true }) })), jsx(Field, Object.assign({ label: 'To Date:', size: "small", className: styles.searchInputField }, { children: jsx(DatePicker, { value: (columnFilterValue === null || columnFilterValue === void 0 ? void 0 : columnFilterValue[1]) || null, min: min, max: max, onSelectDate: handleMaxChange, className: styles.searchInput, placeholder: `To Date`, size: 'small', allowTextInput: true }) }))] })));
|
|
688
|
-
};
|
|
689
|
-
|
|
690
|
-
const useNumberRangeFilterStyles = makeStyles({
|
|
691
|
-
searchInput: {
|
|
692
|
-
width: '100%',
|
|
693
|
-
},
|
|
694
|
-
searchInputField: {
|
|
695
|
-
width: '100%',
|
|
696
|
-
flexGrow: 1,
|
|
697
|
-
},
|
|
698
|
-
searchContainer: {
|
|
699
|
-
display: 'flex',
|
|
700
|
-
flexDirection: 'column',
|
|
701
|
-
marginBottom: '8px',
|
|
702
|
-
marginLeft: '10px',
|
|
703
|
-
marginRight: '10px',
|
|
704
|
-
},
|
|
705
|
-
});
|
|
706
|
-
const FilterDate = (props) => {
|
|
707
|
-
var _a, _b, _c, _d;
|
|
708
|
-
const { column } = props;
|
|
709
|
-
const columnFilterValue = column.getFilterValue();
|
|
710
|
-
const min = (_b = (_a = column.getFacetedMinMaxValues()) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : undefined;
|
|
711
|
-
const max = (_d = (_c = column.getFacetedMinMaxValues()) === null || _c === void 0 ? void 0 : _c[1]) !== null && _d !== void 0 ? _d : undefined;
|
|
712
|
-
const onDateSelect = (date) => {
|
|
713
|
-
if (!date) {
|
|
714
|
-
column.setFilterValue(undefined);
|
|
715
|
-
return;
|
|
716
|
-
}
|
|
717
|
-
column.setFilterValue(date);
|
|
718
|
-
};
|
|
719
|
-
const styles = useNumberRangeFilterStyles();
|
|
720
|
-
return (jsx("div", Object.assign({ className: styles.searchContainer }, { children: jsx(DatePicker, { value: columnFilterValue || null, min: min, max: max, onSelectDate: onDateSelect, className: styles.searchInput, placeholder: `Select a date`, size: 'small', allowTextInput: true }) })));
|
|
721
|
-
};
|
|
722
|
-
|
|
723
|
-
const useFilterStyles = makeStyles({
|
|
724
|
-
searchInput: {
|
|
725
|
-
width: '100%',
|
|
726
|
-
},
|
|
727
|
-
searchInputField: {
|
|
728
|
-
width: '100%',
|
|
729
|
-
flexGrow: 1,
|
|
730
|
-
},
|
|
731
|
-
searchContainer: {
|
|
732
|
-
display: 'flex',
|
|
733
|
-
marginBottom: '8px',
|
|
734
|
-
marginLeft: '10px',
|
|
735
|
-
marginRight: '10px',
|
|
736
|
-
},
|
|
737
|
-
});
|
|
738
|
-
const Filter = ({ column, table, }) => {
|
|
739
|
-
var _a, _b;
|
|
740
|
-
const filterFunctionName = column.columnDef.filterFn;
|
|
741
|
-
const styles = useFilterStyles();
|
|
742
|
-
switch (filterFunctionName) {
|
|
743
|
-
case 'arrIncludesSome':
|
|
744
|
-
return jsx(FilterMultiSelectCheckbox, { column: column, table: table });
|
|
745
|
-
case 'arrIncludesAll':
|
|
746
|
-
case 'arrIncludes':
|
|
747
|
-
return jsx(FilterSelectRadio, { column: column, table: table });
|
|
748
|
-
case 'inNumberRange':
|
|
749
|
-
return jsx(FilterNumberRange, { column: column, table: table });
|
|
750
|
-
case 'inDateRange': {
|
|
751
|
-
const firstValue = (_a = table
|
|
752
|
-
.getPreFilteredRowModel()
|
|
753
|
-
.flatRows[0]) === null || _a === void 0 ? void 0 : _a.getValue(column.id);
|
|
754
|
-
if (typeof firstValue.getMonth === 'function') {
|
|
755
|
-
return jsx(FilterDateRange, { column: column, table: table });
|
|
756
|
-
}
|
|
757
|
-
break;
|
|
758
|
-
}
|
|
759
|
-
case 'matchDate': {
|
|
760
|
-
const firstValue = (_b = table
|
|
761
|
-
.getPreFilteredRowModel()
|
|
762
|
-
.flatRows[0]) === null || _b === void 0 ? void 0 : _b.getValue(column.id);
|
|
763
|
-
if (typeof firstValue.getMonth === 'function') {
|
|
764
|
-
return jsx(FilterDate, { column: column, table: table });
|
|
765
|
-
}
|
|
766
|
-
break;
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
return (jsx("div", Object.assign({ className: styles.searchContainer }, { children: jsx(Field, Object.assign({ size: 'small', className: styles.searchInputField }, { children: jsx(Input, { value: (column.getFilterValue() || ''), onChange: (_, data) => {
|
|
770
|
-
column.setFilterValue(data.value);
|
|
771
|
-
}, placeholder: "Search Keyword...", size: "small", className: styles.searchInput }) })) })));
|
|
772
|
-
};
|
|
773
|
-
|
|
774
|
-
const useFilterDrawerStyles$1 = makeStyles({
|
|
775
|
-
drawerBody: Object.assign(Object.assign({}, shorthands.overflow('hidden', 'auto')), {
|
|
776
|
-
/* width */
|
|
777
|
-
':hover': Object.assign({}, shorthands.overflow('auto', 'auto')), '::-webkit-scrollbar': Object.assign({ width: '6px', height: '4px' }, shorthands.borderRadius('50%')),
|
|
778
|
-
/* Track */
|
|
779
|
-
'::-webkit-scrollbar-track': {
|
|
780
|
-
'background-color': '#f1f1f1',
|
|
781
|
-
},
|
|
782
|
-
/* Handle */
|
|
783
|
-
'::-webkit-scrollbar-thumb': {
|
|
784
|
-
'background-color': '#888',
|
|
785
|
-
},
|
|
786
|
-
/* Handle on hover */
|
|
787
|
-
'::-webkit-scrollbar-thumb:hover': {
|
|
788
|
-
'background-color': '#555',
|
|
789
|
-
} }),
|
|
790
|
-
});
|
|
791
|
-
const FilterDrawer = ({ open, setOpen, table }) => {
|
|
792
|
-
const headerGroups = table.getHeaderGroups();
|
|
793
|
-
const styles = useFilterDrawerStyles$1();
|
|
794
|
-
return (jsxs(InlineDrawer, Object.assign({ position: "end", open: open, separator: true }, { children: [jsx(DrawerHeader, { children: jsx(DrawerHeaderTitle, Object.assign({ action: jsx(Button, { appearance: "subtle", "aria-label": "Close", icon: jsx(Dismiss24Regular, {}), onClick: () => setOpen(false) }) }, { children: "Advanced Filters" })) }), jsx(DrawerBody, Object.assign({ className: styles.drawerBody }, { children: headerGroups.map((headerGroup) => {
|
|
795
|
-
const canApplyFilter = headerGroup.depth === (headerGroups === null || headerGroups === void 0 ? void 0 : headerGroups.length) - 1;
|
|
796
|
-
if (!canApplyFilter)
|
|
797
|
-
return null;
|
|
798
|
-
return headerGroup.headers.map((header) => {
|
|
799
|
-
const canFilter = header.column.getCanFilter();
|
|
800
|
-
if (!canFilter)
|
|
801
|
-
return null;
|
|
802
|
-
return (jsx("div", { children: header.column.getCanFilter() && (jsxs("div", { 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));
|
|
803
|
-
});
|
|
804
|
-
}) }))] })));
|
|
805
|
-
};
|
|
806
|
-
|
|
807
|
-
const SortAscIcon = bundleIcon(ArrowSortDown20Filled, ArrowSortDown20Regular);
|
|
808
|
-
const SortDescIcon = bundleIcon(ArrowSortUp20Filled, ArrowSortUp20Regular);
|
|
809
|
-
const reorderColumn = (draggedColumnId, targetColumnId, columnOrder) => {
|
|
810
|
-
columnOrder.splice(columnOrder.indexOf(targetColumnId), 0, columnOrder.splice(columnOrder.indexOf(draggedColumnId), 1)[0]);
|
|
811
|
-
return [...columnOrder];
|
|
812
|
-
};
|
|
813
|
-
const useTableHeaderCellStyles = makeStyles({
|
|
814
|
-
tHeadCell: Object.assign({ zIndex: 99, position: 'relative', fontSize: tokens.fontSizeBase300, fontWeight: tokens.fontWeightBold, minWidth: '1rem' }, shorthands.padding('2px', '4px')),
|
|
815
|
-
tHeadNonLeafCell: Object.assign({}, shorthands.borderBottom('1px', 'solid', tokens.colorNeutralBackground5)),
|
|
816
|
-
tHeadCellDraggable: {
|
|
817
|
-
height: '100%',
|
|
818
|
-
},
|
|
819
|
-
tHeadCellDragging: {
|
|
820
|
-
opacity: 0.5,
|
|
821
|
-
cursor: 'grab',
|
|
822
|
-
},
|
|
823
|
-
tHeadCellOver: Object.assign({ backgroundColor: tokens.colorNeutralStroke1 }, shorthands.border(tokens.strokeWidthThin, 'dashed', tokens.colorNeutralBackground5)),
|
|
824
|
-
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')),
|
|
825
|
-
tNonLeafHeadCellContent: Object.assign({ display: 'flex', alignContent: 'center', alignItems: 'center', justifyContent: 'center', cursor: 'pointer', width: '100%', minWidth: '1rem' }, shorthands.padding('3px', '4px')),
|
|
826
|
-
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' }),
|
|
827
|
-
tHeadMenuPopover: Object.assign(Object.assign({}, shorthands.padding('0px', '0px', '0px', '0px')), { width: '300px' }),
|
|
828
|
-
resizer: Object.assign(Object.assign({}, shorthands.borderRight('1px', 'solid', tokens.colorNeutralBackground5)), { width: '8px', position: 'absolute', top: 0, right: 0, bottom: 0, cursor: 'col-resize', resize: 'horizontal', ':hover': {
|
|
829
|
-
borderRightWidth: '4px',
|
|
830
|
-
borderRightColor: tokens.colorNeutralBackground2Pressed,
|
|
831
|
-
} }),
|
|
832
|
-
resizerActive: {
|
|
833
|
-
borderRightWidth: '4px',
|
|
834
|
-
borderRightColor: tokens.colorNeutralBackground2Pressed,
|
|
835
|
-
},
|
|
836
|
-
});
|
|
837
|
-
const HeaderCell = ({ header, table, hideMenu, headerDepth, totalNumberOfHeaderDepth, }) => {
|
|
838
|
-
var _a;
|
|
839
|
-
const { getState, setColumnOrder } = table;
|
|
840
|
-
const { columnOrder } = getState();
|
|
841
|
-
const { column } = header;
|
|
842
|
-
const [{ isOver }, dropRef] = useDrop({
|
|
843
|
-
accept: "column",
|
|
844
|
-
drop: (draggedColumn) => {
|
|
845
|
-
const newColumnOrder = reorderColumn(draggedColumn.id, column.id, columnOrder);
|
|
846
|
-
setColumnOrder(newColumnOrder);
|
|
847
|
-
},
|
|
848
|
-
collect: (monitor) => ({
|
|
849
|
-
isOver: monitor.isOver(),
|
|
850
|
-
}),
|
|
851
|
-
});
|
|
852
|
-
const [{ isDragging }, dragRef, previewRef] = useDrag({
|
|
853
|
-
collect: (monitor) => ({
|
|
854
|
-
isDragging: monitor.isDragging(),
|
|
855
|
-
}),
|
|
856
|
-
item: () => column,
|
|
857
|
-
type: "column",
|
|
858
|
-
});
|
|
859
|
-
const styles = useTableHeaderCellStyles();
|
|
860
|
-
const canDragDrop = headerDepth === totalNumberOfHeaderDepth && !header.isPlaceholder;
|
|
861
|
-
const isLeafHeaders = headerDepth === totalNumberOfHeaderDepth;
|
|
862
|
-
return (jsxs("th", Object.assign({ colSpan: header.colSpan, className: mergeClasses(styles.tHeadCell, isLeafHeaders || header.isPlaceholder
|
|
863
|
-
? undefined
|
|
864
|
-
: styles.tHeadNonLeafCell, isDragging && styles.tHeadCellDragging, isOver && isLeafHeaders && styles.tHeadCellOver) }, { children: [jsx("div", Object.assign({ className: styles.tHeadCellDraggable, ref: canDragDrop ? dragRef : undefined }, { children: jsxs("div", Object.assign({ className: isLeafHeaders
|
|
865
|
-
? styles.tLeafHeadCellContent
|
|
866
|
-
: styles.tNonLeafHeadCellContent, ref: canDragDrop ? dropRef : undefined }, { children: [jsx("div", Object.assign({ ref: canDragDrop ? previewRef : undefined }, { children: header.isPlaceholder ? null : (jsxs(Button, Object.assign({ style: {
|
|
867
|
-
display: 'flex',
|
|
868
|
-
alignItems: 'center',
|
|
869
|
-
justifyContent: 'left',
|
|
870
|
-
flex: 1,
|
|
871
|
-
}, onClick: (e) => {
|
|
872
|
-
if (!header.column.getCanSort())
|
|
873
|
-
return;
|
|
874
|
-
header.column.toggleSorting(header.column.getIsSorted() === 'asc', e.ctrlKey);
|
|
875
|
-
}, onDoubleClick: () => {
|
|
876
|
-
if (!header.column.getCanGroup())
|
|
877
|
-
return;
|
|
878
|
-
header.column.getToggleGroupingHandler()();
|
|
879
|
-
}, appearance: "transparent", className: styles.tHeadContentBtn, icon: (_a = {
|
|
880
|
-
asc: (jsx("strong", { children: jsx(SortAscIcon, {}) })),
|
|
881
|
-
desc: (jsx("strong", { children: jsx(SortDescIcon, {}) })),
|
|
882
|
-
}[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, {})] }))) })), !header.isPlaceholder &&
|
|
883
|
-
!hideMenu &&
|
|
884
|
-
(header.column.getCanSort() ||
|
|
885
|
-
header.column.getCanGroup() ||
|
|
886
|
-
header.column.getCanFilter()) && (jsx("div", { children: jsxs(Menu, { children: [jsx(MenuTrigger, Object.assign({ disableButtonEnhancement: true }, { children: jsx(MenuButton, { appearance: "transparent", "aria-label": "View Column Actions" }) })), jsx(MenuPopover, Object.assign({ 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, Object.assign({ onClick: (e) => {
|
|
887
|
-
var _a;
|
|
888
|
-
const isControlKeySelected = e.ctrlKey;
|
|
889
|
-
(_a = header.column) === null || _a === void 0 ? void 0 : _a.toggleSorting(false, isControlKeySelected);
|
|
890
|
-
}, icon: jsx(TextSortAscendingFilled, {}), disabled: header.column.getIsSorted() === 'asc' }, { children: "Sort A to Z" })), jsx(MenuItem, Object.assign({ onClick: (e) => {
|
|
891
|
-
var _a;
|
|
892
|
-
const isControlKeySelected = e.ctrlKey;
|
|
893
|
-
(_a = header.column) === null || _a === void 0 ? void 0 : _a.toggleSorting(true, isControlKeySelected);
|
|
894
|
-
}, 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, Object.assign({ onClick: () => header.column.getToggleGroupingHandler()(), icon: jsx(GroupFilled, {}) }, { children: ["Group by", ' ', flexRender(header.column.columnDef.header, header.getContext())] }))), header.column.getIsGrouped() && (jsxs(MenuItem, Object.assign({ 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, Object.assign({ onClick: () => {
|
|
895
|
-
var _a;
|
|
896
|
-
(_a = header.column) === null || _a === void 0 ? void 0 : _a.pin('left');
|
|
897
|
-
}, icon: jsx(ArrowStepInLeftRegular, {}), disabled: header.column.getIsPinned() === 'left' }, { children: "To Left" })), jsx(MenuItem, Object.assign({ onClick: () => {
|
|
898
|
-
var _a;
|
|
899
|
-
(_a = header.column) === null || _a === void 0 ? void 0 : _a.pin('right');
|
|
900
|
-
}, icon: jsx(ArrowStepInRightRegular, {}), disabled: header.column.getIsPinned() === 'right' }, { children: "To Right" })), ['left', 'right'].includes(header.column.getIsPinned()) && (jsx(MenuItem, Object.assign({ onClick: () => {
|
|
901
|
-
var _a;
|
|
902
|
-
(_a = header.column) === null || _a === void 0 ? void 0 : _a.pin(false);
|
|
903
|
-
}, 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'))] }) }))] }) }))] })) })), header.column.getCanResize() && (jsx("div", { onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler(), className: mergeClasses(styles.resizer, column.getIsResizing() && styles.resizerActive) }))] })));
|
|
904
|
-
};
|
|
905
|
-
|
|
906
|
-
const useLoadingStyles = makeStyles({
|
|
907
|
-
invertedWrapper: {
|
|
908
|
-
backgroundColor: tokens.colorNeutralBackground1,
|
|
909
|
-
},
|
|
910
|
-
row: Object.assign(Object.assign({ alignItems: "center", display: "grid", paddingBottom: "10px", position: "relative" }, shorthands.gap("10px")), { gridTemplateColumns: "min-content 20% 15% 30% 29%" }),
|
|
911
|
-
});
|
|
912
|
-
|
|
913
|
-
const Loading = (props) => {
|
|
914
|
-
const { numberOfItems = 16, numberOfColumns = 5 } = props;
|
|
915
|
-
const styles = useLoadingStyles();
|
|
916
|
-
return (jsx("div", Object.assign({ className: styles.invertedWrapper }, { children: jsx(Skeleton, { children: [...Array(numberOfItems)].map((_, i) => (jsx("div", Object.assign({ className: styles.row }, { children: [...Array(numberOfColumns)].map((_, i) => {
|
|
917
|
-
if (i === 0) {
|
|
918
|
-
return jsx(SkeletonItem, { shape: "circle", size: 24 }, i);
|
|
919
|
-
}
|
|
920
|
-
return jsx(SkeletonItem, { size: 16 }, i);
|
|
921
|
-
}) }), i))) }) })));
|
|
922
|
-
};
|
|
923
|
-
|
|
924
|
-
const useNoItemGridStyles = makeStyles({
|
|
925
|
-
wrapper: {
|
|
926
|
-
backgroundColor: tokens.colorNeutralBackground1,
|
|
927
|
-
display: "flex",
|
|
928
|
-
flexWrap: "wrap",
|
|
929
|
-
alignContent: "center",
|
|
930
|
-
justifyContent: "center",
|
|
931
|
-
minHeight: "300px",
|
|
932
|
-
}
|
|
933
|
-
});
|
|
934
|
-
|
|
935
|
-
const NoItemGrid = ({ message }) => {
|
|
936
|
-
const styles = useNoItemGridStyles();
|
|
937
|
-
return (jsx("div", Object.assign({ className: styles.wrapper }, { children: jsx("div", { children: message ? message : jsx(Subtitle2Stronger, { children: "No Data to Show." }) }) })));
|
|
938
|
-
};
|
|
939
|
-
|
|
940
|
-
const useNoFilterMatchStyles = makeStyles({
|
|
941
|
-
wrapper: {
|
|
942
|
-
backgroundColor: tokens.colorNeutralBackground1,
|
|
943
|
-
display: "flex",
|
|
944
|
-
flexDirection: "column",
|
|
945
|
-
flexWrap: "wrap",
|
|
946
|
-
alignContent: "center",
|
|
947
|
-
justifyContent: "center",
|
|
948
|
-
minHeight: "300px",
|
|
949
|
-
},
|
|
950
|
-
iconWrapper: {
|
|
951
|
-
display: "flex",
|
|
952
|
-
flexWrap: "wrap",
|
|
953
|
-
alignContent: "center",
|
|
954
|
-
justifyContent: "center",
|
|
955
|
-
}
|
|
956
|
-
});
|
|
957
|
-
|
|
958
|
-
const NoSearchResult = ({ message }) => {
|
|
959
|
-
const styles = useNoFilterMatchStyles();
|
|
960
|
-
return (jsxs("div", Object.assign({ className: styles.wrapper }, { children: [jsx("div", Object.assign({ className: styles.iconWrapper }, { children: jsx(DocumentSearch24Regular, {}) })), jsx("div", { children: message ? message : jsx(Subtitle2Stronger, { children: "No item found that matches your search term." }) })] })));
|
|
961
|
-
};
|
|
962
|
-
|
|
963
|
-
const TableContainer = (props) => {
|
|
964
|
-
var _a, _b, _c, _d;
|
|
965
|
-
const styles = useTableStaticStyles();
|
|
966
|
-
const { table, rowSelectionMode } = props;
|
|
967
|
-
const tableContainerRef = React.useRef(null);
|
|
968
|
-
const { rows } = table.getRowModel();
|
|
969
|
-
const rowVirtualizer = useVirtual({
|
|
970
|
-
parentRef: tableContainerRef,
|
|
971
|
-
size: rows.length,
|
|
972
|
-
overscan: 10,
|
|
973
|
-
});
|
|
974
|
-
const { virtualItems: virtualRows, totalSize } = rowVirtualizer;
|
|
975
|
-
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;
|
|
976
|
-
const paddingBottom = virtualRows.length > 0
|
|
977
|
-
? totalSize - (((_b = virtualRows === null || virtualRows === void 0 ? void 0 : virtualRows[virtualRows.length - 1]) === null || _b === void 0 ? void 0 : _b.end) || 0)
|
|
978
|
-
: 0;
|
|
979
|
-
const headerGroups = table.getHeaderGroups();
|
|
980
|
-
// utilities
|
|
981
|
-
const isLoading = props.isLoading && virtualRows.length === 0;
|
|
982
|
-
const noItems = !isLoading && ((_c = props.data) === null || _c === void 0 ? void 0 : _c.length) === 0;
|
|
983
|
-
const noSearchResult = !isLoading && ((_d = props === null || props === void 0 ? void 0 : props.data) === null || _d === void 0 ? void 0 : _d.length) > 0 && virtualRows.length === 0;
|
|
984
|
-
return (jsxs("div", Object.assign({ ref: tableContainerRef, className: styles.tableContainer }, { children: [jsxs("table", Object.assign({ className: styles.table, "aria-label": "Data Grid" }, { children: [jsx("thead", Object.assign({ className: styles.tHead }, { children: headerGroups === null || headerGroups === void 0 ? void 0 : headerGroups.map((headerGroup) => (jsxs("tr", { children: [rowSelectionMode === 'multiple' && (jsx("th", Object.assign({ style: { width: '1rem' }, "aria-label": "Select All Row Column" }, { children: headerGroup.depth === (headerGroups === null || headerGroups === void 0 ? void 0 : headerGroups.length) - 1 && (jsx(Checkbox, { checked: table.getIsSomeRowsSelected()
|
|
985
|
-
? 'mixed'
|
|
986
|
-
: table.getIsAllRowsSelected(), onChange: table.getToggleAllRowsSelectedHandler(), "aria-label": "Select All Rows", title: 'Select All Rows' })) }))), rowSelectionMode === 'single' && (jsx("th", Object.assign({ style: { width: '1rem' }, "aria-label": "Select All Row Column" }, { children: ' ' }))), headerGroup.headers.map((header) => {
|
|
987
|
-
return (jsx(HeaderCell, { header: header, table: table, hideMenu: headerGroup.depth !== (headerGroups === null || headerGroups === void 0 ? void 0 : headerGroups.length) - 1, headerDepth: headerGroup.depth, totalNumberOfHeaderDepth: (headerGroups === null || headerGroups === void 0 ? void 0 : headerGroups.length) - 1 }, header.id));
|
|
988
|
-
})] }, headerGroup.id))) })), jsxs("tbody", Object.assign({ className: styles.tBody }, { children: [paddingTop > 0 && (jsx("tr", Object.assign({ className: styles.tBodyRow, "aria-hidden": true }, { children: jsx("td", { style: { height: `${paddingTop}px` } }) }))), virtualRows.map((virtualRow) => {
|
|
989
|
-
const row = rows[virtualRow.index];
|
|
990
|
-
return (jsxs("tr", Object.assign({ className: row.getIsSelected() || row.getIsAllSubRowsSelected()
|
|
991
|
-
? styles.tBodySelectedRow
|
|
992
|
-
: styles.tBodyRow }, { children: [rowSelectionMode === 'multiple' && (jsx("td", Object.assign({ className: styles.tBodyCell, "aria-label": "Select Row Column" }, { children: jsx(Checkbox, { checked: row.getIsSomeSelected()
|
|
993
|
-
? 'mixed'
|
|
994
|
-
: row.getIsSelected() || row.getIsAllSubRowsSelected(), disabled: !row.getCanSelect(), onChange: row.getToggleSelectedHandler(), "aria-label": "Select Row" }) }))), rowSelectionMode === 'single' && (jsx("td", Object.assign({ 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) => {
|
|
995
|
-
var _a;
|
|
996
|
-
return (jsx("td", Object.assign({}, {
|
|
997
|
-
key: cell.id,
|
|
998
|
-
style: {
|
|
999
|
-
// background: cell.getIsGrouped()
|
|
1000
|
-
// ? "#0aff0082"
|
|
1001
|
-
// : cell.getIsAggregated()
|
|
1002
|
-
// ? "#ffa50078"
|
|
1003
|
-
// : cell.getIsPlaceholder()
|
|
1004
|
-
// ? "#ff000042"
|
|
1005
|
-
// : "white",
|
|
1006
|
-
width: cell.column.getSize(),
|
|
1007
|
-
},
|
|
1008
|
-
}, { className: styles.tBodyCell }, { children: cell.getIsGrouped() ? (
|
|
1009
|
-
// If it's a grouped cell, add an expander and row count
|
|
1010
|
-
jsx(Button, Object.assign({}, {
|
|
1011
|
-
onClick: row.getToggleExpandedHandler(),
|
|
1012
|
-
style: {
|
|
1013
|
-
cursor: row.getCanExpand() ? 'pointer' : 'normal',
|
|
1014
|
-
},
|
|
1015
|
-
}, { appearance: "transparent", icon: row.getIsExpanded() ? (jsx(GroupExpandedIcon, {})) : (jsx(GroupCollapsedIcon, {})) }, { children: jsxs("strong", { children: [flexRender(cell.column.columnDef.cell, cell.getContext()), ' ', "(", row.subRows.length, ")"] }) }))) : cell.getIsAggregated() ? (
|
|
1016
|
-
// If the cell is aggregated, use the Aggregated
|
|
1017
|
-
// renderer for cell
|
|
1018
|
-
jsx("strong", { children: flexRender((_a = cell.column.columnDef.aggregatedCell) !== null && _a !== void 0 ? _a : cell.column.columnDef.cell, cell.getContext()) })) : cell.getIsPlaceholder() ? null : ( // For cells with repeated values, render null
|
|
1019
|
-
// Otherwise, just render the regular cell
|
|
1020
|
-
flexRender(cell.column.columnDef.cell, cell.getContext())) })));
|
|
1021
|
-
})] }), row.id));
|
|
1022
|
-
}), paddingBottom > 0 && (jsx("tr", Object.assign({ className: styles.tBodyRow, "aria-hidden": true }, { children: jsx("td", { style: { height: `${paddingBottom}px` } }) })))] })), rowSelectionMode === 'multiple' &&
|
|
1023
|
-
!isLoading &&
|
|
1024
|
-
!noItems &&
|
|
1025
|
-
!noSearchResult && (jsx("tfoot", Object.assign({ className: styles.tFoot }, { children: jsxs("tr", { children: [jsx("td", Object.assign({ className: "p-1" }, { children: jsx(Checkbox, { checked: table.getIsSomePageRowsSelected()
|
|
1026
|
-
? 'mixed'
|
|
1027
|
-
: table.getIsAllPageRowsSelected(), onChange: table.getToggleAllPageRowsSelectedHandler(), "aria-label": "Select All Current Page Rows", title: 'Select All Current Page Rows' }) })), jsxs("td", Object.assign({ 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 })] })));
|
|
1028
|
-
};
|
|
1029
|
-
|
|
1030
|
-
const ViewSaveForm = (props) => {
|
|
1031
|
-
const [errorMessage, setErrorMessage] = React.useState('');
|
|
1032
|
-
const [isFormOpen, setIsFormOpen] = React.useState(false);
|
|
1033
|
-
const inputRef = React.useRef(null);
|
|
1034
|
-
const checkboxRef = React.useRef(null);
|
|
1035
|
-
if (!isFormOpen) {
|
|
1036
|
-
return (jsxs(Fragment, { children: [jsx(MenuList, { children: jsx(MenuItemRadio, Object.assign({ name: 'view-manager', value: 'View Manager', onClick: () => setIsFormOpen(true), icon: jsx(Save20Filled, {}) }, { children: "Save Current View" })) }), jsx(Divider, {})] }));
|
|
1037
|
-
}
|
|
1038
|
-
return (jsxs("div", Object.assign({ style: {
|
|
1039
|
-
boxSizing: 'border-box',
|
|
1040
|
-
padding: '0.4rem',
|
|
1041
|
-
border: '1px solid #ccc',
|
|
1042
|
-
marginBottom: '0.5rem'
|
|
1043
|
-
} }, { children: [jsx(Caption1Stronger, { children: "Enter View Details" }), jsx(Field, Object.assign({ label: "View Name", validationMessage: errorMessage, validationState: errorMessage ? "error" : undefined, hint: jsx(Fragment, { children: "Give your view a name and save it." }) }, { children: jsx(Input, { ref: inputRef, placeholder: "View Name" }) })), jsx(Field, Object.assign({ hint: jsx(Fragment, { children: "Global view is accessible to everybody in the system." }) }, { children: jsx(Checkbox, { ref: checkboxRef, label: "Set as global view" }) })), jsxs("div", Object.assign({ style: {
|
|
1044
|
-
display: 'flex',
|
|
1045
|
-
flexWrap: 'wrap',
|
|
1046
|
-
gap: '0.5rem'
|
|
1047
|
-
} }, { children: [jsx(Button, Object.assign({ onClick: () => {
|
|
1048
|
-
setIsFormOpen(false);
|
|
1049
|
-
setErrorMessage('');
|
|
1050
|
-
} }, { children: "Cancel" })), jsx(Button, Object.assign({ appearance: 'primary', onClick: () => {
|
|
1051
|
-
var _a, _b, _c;
|
|
1052
|
-
if (!((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.value)) {
|
|
1053
|
-
setErrorMessage('View name is required');
|
|
1054
|
-
return;
|
|
1055
|
-
}
|
|
1056
|
-
const viewName = inputRef.current.value;
|
|
1057
|
-
const isGlobal = (_b = checkboxRef.current) === null || _b === void 0 ? void 0 : _b.checked;
|
|
1058
|
-
const tableView = {
|
|
1059
|
-
id: Math.random() * 100,
|
|
1060
|
-
viewName: viewName,
|
|
1061
|
-
tableState: props.getTableState(),
|
|
1062
|
-
isGlobal: isGlobal,
|
|
1063
|
-
isViewOwner: true
|
|
1064
|
-
};
|
|
1065
|
-
(_c = props === null || props === void 0 ? void 0 : props.onSave) === null || _c === void 0 ? void 0 : _c.call(props, tableView);
|
|
1066
|
-
setErrorMessage('');
|
|
1067
|
-
setIsFormOpen(false);
|
|
1068
|
-
} }, { children: "Save" }))] }))] })));
|
|
1069
|
-
};
|
|
1070
|
-
|
|
1071
|
-
const useFilterDrawerStyles = makeStyles({
|
|
1072
|
-
drawerBody: Object.assign(Object.assign({}, shorthands.overflow('hidden', 'auto')), {
|
|
1073
|
-
/* width */
|
|
1074
|
-
':hover': Object.assign({}, shorthands.overflow('auto', 'auto')), '::-webkit-scrollbar': Object.assign({ width: '6px', height: '4px' }, shorthands.borderRadius('50%')),
|
|
1075
|
-
/* Track */
|
|
1076
|
-
'::-webkit-scrollbar-track': {
|
|
1077
|
-
'background-color': '#f1f1f1',
|
|
1078
|
-
},
|
|
1079
|
-
/* Handle */
|
|
1080
|
-
'::-webkit-scrollbar-thumb': {
|
|
1081
|
-
'background-color': '#888',
|
|
1082
|
-
},
|
|
1083
|
-
/* Handle on hover */
|
|
1084
|
-
'::-webkit-scrollbar-thumb:hover': {
|
|
1085
|
-
'background-color': '#555',
|
|
1086
|
-
} }),
|
|
1087
|
-
});
|
|
1088
|
-
const ViewsDrawer = (props) => {
|
|
1089
|
-
const { open, setOpen, table, tableViews, applyTableState, resetToGridDefaultView, getTableState, onTableViewSave } = props;
|
|
1090
|
-
const styles = useFilterDrawerStyles();
|
|
1091
|
-
const [checkedValues, setCheckedValues] = React.useState({ font: ["calibri"] });
|
|
1092
|
-
const onChange = (e, { name, checkedItems }) => {
|
|
1093
|
-
setCheckedValues((s) => (Object.assign(Object.assign({}, s), { [name]: checkedItems })));
|
|
1094
|
-
};
|
|
1095
|
-
const resetAllFilters = React.useCallback(() => {
|
|
1096
|
-
table.setGlobalFilter('');
|
|
1097
|
-
table.resetColumnFilters();
|
|
1098
|
-
}, [table]);
|
|
1099
|
-
const resetAllGrouping = React.useCallback(() => {
|
|
1100
|
-
table.resetGrouping();
|
|
1101
|
-
}, [table]);
|
|
1102
|
-
const clearAllSelection = React.useCallback(() => {
|
|
1103
|
-
table.toggleAllRowsSelected(false);
|
|
1104
|
-
}, [table]);
|
|
1105
|
-
return (jsxs(InlineDrawer, Object.assign({ position: "end", open: open, separator: true }, { children: [jsx(DrawerHeader, { children: jsx(DrawerHeaderTitle, Object.assign({ action: jsx(Button, { appearance: "subtle", "aria-label": "Close", icon: jsx(Dismiss24Regular, {}), onClick: () => setOpen(false) }) }, { children: "Table Views" })) }), jsxs(DrawerBody, Object.assign({ className: styles.drawerBody }, { children: [onTableViewSave && jsx(ViewSaveForm, { mode: 'create', getTableState: getTableState, onSave: onTableViewSave }), jsxs(MenuList, Object.assign({ checkedValues: checkedValues, onCheckedValueChange: onChange }, { children: [jsx(MenuItemRadio, Object.assign({ 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) => {
|
|
1106
|
-
return (jsxs("div", Object.assign({ style: {
|
|
1107
|
-
display: 'flex',
|
|
1108
|
-
justifyContent: 'space-between',
|
|
1109
|
-
alignItems: 'center',
|
|
1110
|
-
width: '100%',
|
|
1111
|
-
} }, { children: [jsx(MenuItemRadio, Object.assign({ 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));
|
|
1112
|
-
})] }))] })), jsx(DrawerFooter, { children: jsxs(MenuList, { children: [jsx(MenuDivider, {}), jsx(MenuItem, Object.assign({ icon: jsx(ClearFilterIcon, {}), onClick: resetAllFilters }, { children: "Clear All Filters" })), jsx(MenuItem, Object.assign({ icon: jsx(ClearFilterIcon, {}), onClick: resetAllGrouping }, { children: "Clear All Grouping" })), jsx(MenuItem, Object.assign({ icon: jsx(ClearFilterIcon, {}), onClick: clearAllSelection }, { children: "Clear All Selection" }))] }) })] })));
|
|
1113
|
-
};
|
|
1114
|
-
|
|
1115
|
-
function AdvancedTable(props, ref) {
|
|
1116
|
-
useStaticStyles();
|
|
1117
|
-
const { table, globalFilter, headerMenu, tableViews, setGlobalFilter, resetToDefaultView, applyTableState, getTableState } = useGridContainer(props, ref);
|
|
1118
|
-
const [isFilterDrawerOpen, setIsFilterDrawerOpen] = React.useState(false);
|
|
1119
|
-
const [isViewsDrawerOpen, setIsViewsDrawerOpen] = React.useState(false);
|
|
1120
|
-
return (jsxs(DndProvider, Object.assign({ backend: HTML5Backend }, { children: [jsx(GridHeader, { table: table, gridTitle: props.gridTitle, headerMenu: headerMenu, globalFilter: globalFilter, openFilterDrawer: isFilterDrawerOpen, openViewsDrawer: isViewsDrawerOpen, setGlobalFilter: setGlobalFilter, setFilterDrawerOpen: setIsFilterDrawerOpen, setViewsDrawerOpen: setIsViewsDrawerOpen, applyTableState: applyTableState }), jsxs("div", Object.assign({ 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, { open: isFilterDrawerOpen, setOpen: setIsFilterDrawerOpen, table: table }), jsx(ViewsDrawer, { table: table, open: isViewsDrawerOpen, setOpen: setIsViewsDrawerOpen, tableViews: tableViews, applyTableState: applyTableState, resetToGridDefaultView: resetToDefaultView, getTableState: getTableState, onTableViewSave: props.onTableViewSave, onTableViewDelete: props.onTableViewDelete })] })), jsx(Pagination, { table: table, pageSizeOptions: props.pageSizeOptions })] })));
|
|
1121
|
-
}
|
|
1122
|
-
const ForwardedAdvancedTable = React.forwardRef(AdvancedTable);
|
|
1123
|
-
|
|
1124
|
-
export { ForwardedAdvancedTable as Table };
|