@prt-ts/fluent-react-table-v2 9.55.0-build-1.0 → 9.66.2-build-3.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/README.md +7 -7
- package/index.cjs.d.ts +1 -1
- package/index.cjs.js +33 -19
- package/index.esm.d.ts +1 -1
- package/index.esm.js +33 -19
- package/package.json +3 -3
- package/src/lib/components/pagination/Pagination.d.ts +1 -1
- package/src/lib/components/pagination/usePaginationStyles.d.ts +1 -1
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# fluent-react-table-v2
|
|
2
|
-
|
|
3
|
-
This library was generated with [Nx](https://nx.dev).
|
|
4
|
-
|
|
5
|
-
## Running unit tests
|
|
6
|
-
|
|
7
|
-
Run `nx test fluent-react-table-v2` to execute the unit tests via [Vitest](https://vitest.dev/).
|
|
1
|
+
# fluent-react-table-v2
|
|
2
|
+
|
|
3
|
+
This library was generated with [Nx](https://nx.dev).
|
|
4
|
+
|
|
5
|
+
## Running unit tests
|
|
6
|
+
|
|
7
|
+
Run `nx test fluent-react-table-v2` to execute the unit tests via [Vitest](https://vitest.dev/).
|
package/index.cjs.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./src
|
|
1
|
+
export * from "./src/index";
|
package/index.cjs.js
CHANGED
|
@@ -106,13 +106,21 @@ const usePaginationStyle = reactComponents.makeStyles({
|
|
|
106
106
|
},
|
|
107
107
|
pageSelectionWrapper: {
|
|
108
108
|
minWidth: "1.5rem",
|
|
109
|
+
display: "flex",
|
|
110
|
+
alignItems: "center",
|
|
111
|
+
gap: "1rem",
|
|
109
112
|
},
|
|
110
113
|
pageSelectionDropdown: {
|
|
111
114
|
minWidth: "100%",
|
|
112
115
|
},
|
|
113
116
|
pageSizeInput: {
|
|
114
117
|
minWidth: "1.5rem",
|
|
115
|
-
width: "
|
|
118
|
+
width: "3rem",
|
|
119
|
+
},
|
|
120
|
+
pageSizeText: {
|
|
121
|
+
flex: 1,
|
|
122
|
+
minWidth: "100%",
|
|
123
|
+
fontSize: "0.8rem"
|
|
116
124
|
},
|
|
117
125
|
});
|
|
118
126
|
|
|
@@ -124,19 +132,25 @@ const DEFAULT_NUMBER_OF_PAGE_BTN = 5;
|
|
|
124
132
|
const Pagination = (props) => {
|
|
125
133
|
const { table } = props;
|
|
126
134
|
const { pageSizeOptions } = table.options.meta || {};
|
|
127
|
-
const pageSizeSelectionId = reactComponents.useId(
|
|
135
|
+
const pageSizeSelectionId = reactComponents.useId('page-size-selector');
|
|
128
136
|
const styles = usePaginationStyle();
|
|
129
137
|
const totalNumberOfPage = table.getPageCount();
|
|
130
138
|
const currentPage = table.getState().pagination.pageIndex;
|
|
131
139
|
const pageSize = table.getState().pagination.pageSize;
|
|
140
|
+
// get total item count and number of item in current page
|
|
141
|
+
const totalItemCount = table.getFilteredRowModel().rows.length;
|
|
142
|
+
const numberOfItemsInCurrentPage = table.getRowModel().rows.length;
|
|
143
|
+
const startNumber = currentPage * pageSize + 1;
|
|
144
|
+
const endNumber = Math.min(startNumber + numberOfItemsInCurrentPage - 1, totalItemCount);
|
|
132
145
|
const pageSelectionOptions = React.useMemo(() => {
|
|
133
146
|
let start = currentPage - Math.floor(DEFAULT_NUMBER_OF_PAGE_BTN / 2);
|
|
134
147
|
let end = currentPage + Math.floor(DEFAULT_NUMBER_OF_PAGE_BTN / 2);
|
|
135
148
|
if (start < 1) {
|
|
136
149
|
start = 1;
|
|
137
|
-
end =
|
|
138
|
-
|
|
139
|
-
|
|
150
|
+
end =
|
|
151
|
+
totalNumberOfPage > DEFAULT_NUMBER_OF_PAGE_BTN
|
|
152
|
+
? DEFAULT_NUMBER_OF_PAGE_BTN
|
|
153
|
+
: totalNumberOfPage;
|
|
140
154
|
}
|
|
141
155
|
else if (end > totalNumberOfPage) {
|
|
142
156
|
const possibleStart = totalNumberOfPage - DEFAULT_NUMBER_OF_PAGE_BTN + 1;
|
|
@@ -146,12 +160,12 @@ const Pagination = (props) => {
|
|
|
146
160
|
const currentPageOptions = end - start >= 0 ? range(start, end) : [];
|
|
147
161
|
return (currentPageOptions === null || currentPageOptions === void 0 ? void 0 : currentPageOptions.length) ? [...currentPageOptions] : [1];
|
|
148
162
|
}, [totalNumberOfPage, currentPage]);
|
|
149
|
-
return (jsxRuntime.jsx("div", { className: styles.paginationContainer, children: jsxRuntime.jsxs("div", { className: styles.wrapper, children: [jsxRuntime.
|
|
163
|
+
return (jsxRuntime.jsx("div", { className: styles.paginationContainer, children: jsxRuntime.jsxs("div", { className: styles.wrapper, children: [jsxRuntime.jsxs("div", { className: styles.pageSelectionWrapper, children: [jsxRuntime.jsx(reactComponents.Dropdown, { id: pageSizeSelectionId, size: "small", selectedOptions: [`${pageSize}`], placeholder: "Select Page Size", value: table.getState().pagination.pageSize.toString(), onOptionSelect: (_, data) => { var _a; return table.setPageSize(Number(+((_a = data.selectedOptions) === null || _a === void 0 ? void 0 : _a[0]))); }, className: styles.pageSelectionDropdown, "aria-label": 'Select Page Size', style: { minWidth: 80 }, children: jsxRuntime.jsx(reactControlFlow.Show, { when: (pageSelectionOptions === null || pageSelectionOptions === void 0 ? void 0 : pageSelectionOptions.length) > 0, children: jsxRuntime.jsx(reactControlFlow.For, { each: pageSizeOptions, children: (option) => (jsxRuntime.jsx(reactComponents.Option, { value: `${option}`, children: `${option}` }, option)) }) }) }), jsxRuntime.jsx(reactControlFlow.Show, { when: (pageSelectionOptions === null || pageSelectionOptions === void 0 ? void 0 : pageSelectionOptions.length) > 0 && totalItemCount > 0, children: jsxRuntime.jsxs("span", { className: styles.pageSizeText, children: ["Showing ", startNumber, " through ", endNumber, " of ", totalItemCount, ' ', "items"] }) })] }), jsxRuntime.jsxs("div", { className: styles.pageBtnContainer, children: [jsxRuntime.jsxs("div", { children: [jsxRuntime.jsxs("span", { children: ["Page", ' ', jsxRuntime.jsxs("strong", { children: [table.getState().pagination.pageIndex + 1, " of", ' ', table.getPageCount()] })] }), jsxRuntime.jsxs("span", { children: [' ', "| Go to page:", ' ', jsxRuntime.jsx(reactComponents.Input, { type: "number", size: "small", value: `${table.getState().pagination.pageIndex + 1}`, onChange: (e, data) => {
|
|
150
164
|
const page = data.value ? Number(e.target.value) - 1 : 0;
|
|
151
165
|
if (page >= 0 && page < table.getPageCount()) {
|
|
152
166
|
table.setPageIndex(page);
|
|
153
167
|
}
|
|
154
|
-
}, className: styles.pageSizeInput, "aria-label": "Page Number", autoComplete:
|
|
168
|
+
}, className: styles.pageSizeInput, "aria-label": "Page Number", autoComplete: 'off', autoCorrect: 'off' })] })] }), jsxRuntime.jsx(reactComponents.Button, { size: "small", className: styles.pageBtn, shape: "circular", onClick: () => table.setPageIndex(0), disabled: !table.getCanPreviousPage(), icon: jsxRuntime.jsx(reactIcons.PreviousRegular, {}), "aria-label": "Go to first page" }), jsxRuntime.jsx(reactComponents.Button, { size: "small", className: styles.pageBtn, shape: "circular", onClick: () => table.previousPage(), disabled: !table.getCanPreviousPage(), icon: jsxRuntime.jsx(reactIcons.ArrowPreviousFilled, {}), "aria-label": "Go to previous page" }), jsxRuntime.jsx(reactControlFlow.For, { each: pageSelectionOptions, children: (option, index) => (jsxRuntime.jsx(reactComponents.Button, { shape: "circular", appearance: option - 1 === currentPage ? 'primary' : undefined, onClick: () => table.setPageIndex(option - 1), "aria-label": `Show Page ${option}`, size: "small", className: styles.pageBtn, children: option }, index)) }), jsxRuntime.jsx(reactComponents.Button, { size: "small", className: styles.pageBtn, shape: "circular", onClick: () => table.nextPage(), disabled: !table.getCanNextPage(), icon: jsxRuntime.jsx(reactIcons.ArrowNextFilled, {}), "aria-label": "Go to next page" }), jsxRuntime.jsx(reactComponents.Button, { size: "small", shape: "circular", className: styles.pageBtn, onClick: () => table.setPageIndex(table.getPageCount() - 1), disabled: !table.getCanNextPage(), icon: jsxRuntime.jsx(reactIcons.NextRegular, {}), "aria-label": "Go to last page" })] })] }) }));
|
|
155
169
|
};
|
|
156
170
|
|
|
157
171
|
reactIcons.bundleIcon(reactIcons.SaveFilled, reactIcons.SaveRegular);
|
|
@@ -218,7 +232,7 @@ function DebouncedInput({ value: initialValue, onChange, debounce = 500, drawerS
|
|
|
218
232
|
}, debounce);
|
|
219
233
|
return () => clearTimeout(timeout);
|
|
220
234
|
}, [value, onChange, debounce]);
|
|
221
|
-
return (jsxRuntime.jsx(reactComponents.Input, { placeholder: "Search Keyword", value: value, onChange: (_, data) => setValue(data.value), type: "search", autoComplete: "off", contentBefore: jsxRuntime.jsx(reactIcons.Search24Regular, {}), style: { width: '300px' }, contentAfter: jsxRuntime.jsx(reactComponents.Tooltip, { content: (drawerState === null || drawerState === void 0 ? void 0 : drawerState.isFilterDrawerOpen) ? 'Close Filter Window' : 'Open Advance Filter', relationship: "label", children: jsxRuntime.jsx(reactComponents.Button, { appearance: "subtle", icon: (drawerState === null || drawerState === void 0 ? void 0 : drawerState.isFilterDrawerOpen) ? jsxRuntime.jsx(reactIcons.FilterDismissFilled, {}) : jsxRuntime.jsx(reactIcons.FilterFilled, {}), "aria-label":
|
|
235
|
+
return (jsxRuntime.jsx(reactComponents.Input, { "aria-label": "Search keyword", placeholder: "Search Keyword", value: value, onChange: (_, data) => setValue(data.value), type: "search", autoComplete: "off", contentBefore: jsxRuntime.jsx(reactIcons.Search24Regular, {}), style: { width: '300px' }, contentAfter: jsxRuntime.jsx(reactComponents.Tooltip, { content: (drawerState === null || drawerState === void 0 ? void 0 : drawerState.isFilterDrawerOpen) ? 'Close Filter Window' : 'Open Advance Filter', relationship: "label", children: jsxRuntime.jsx(reactComponents.Button, { appearance: "subtle", icon: (drawerState === null || drawerState === void 0 ? void 0 : drawerState.isFilterDrawerOpen) ? jsxRuntime.jsx(reactIcons.FilterDismissFilled, {}) : jsxRuntime.jsx(reactIcons.FilterFilled, {}), "aria-label": (drawerState === null || drawerState === void 0 ? void 0 : drawerState.isFilterDrawerOpen) ? 'Close filter panel' : 'Open advanced filter', onClick: () => {
|
|
222
236
|
dispatch === null || dispatch === void 0 ? void 0 : dispatch({ type: "TOGGLE_FILTER_DRAWER" });
|
|
223
237
|
} }) }) }));
|
|
224
238
|
}
|
|
@@ -243,15 +257,15 @@ const dateRange = (row, columnId, value) => {
|
|
|
243
257
|
return true;
|
|
244
258
|
}
|
|
245
259
|
else if (value.length === 2 && value[0] && !value[1]) {
|
|
246
|
-
return typeof rowValue.getMonth === 'function' && rowValue >= value[0];
|
|
260
|
+
return typeof (rowValue === null || rowValue === void 0 ? void 0 : rowValue.getMonth) === 'function' && rowValue >= value[0];
|
|
247
261
|
}
|
|
248
262
|
else if (value.length === 2 && !value[0] && value[1]) {
|
|
249
|
-
return typeof rowValue.getMonth === 'function' && rowValue <= value[1];
|
|
263
|
+
return typeof (rowValue === null || rowValue === void 0 ? void 0 : rowValue.getMonth) === 'function' && rowValue <= value[1];
|
|
250
264
|
}
|
|
251
265
|
else if (value.length === 2 && !value[0] && !value[1]) {
|
|
252
266
|
return true;
|
|
253
267
|
}
|
|
254
|
-
const passed = typeof rowValue.getMonth === 'function' && value[0] <= rowValue && rowValue <= value[1];
|
|
268
|
+
const passed = typeof (rowValue === null || rowValue === void 0 ? void 0 : rowValue.getMonth) === 'function' && value[0] <= rowValue && rowValue <= value[1];
|
|
255
269
|
return passed;
|
|
256
270
|
};
|
|
257
271
|
const date = (row, columnId, value) => {
|
|
@@ -265,7 +279,7 @@ const date = (row, columnId, value) => {
|
|
|
265
279
|
if (!value) {
|
|
266
280
|
return true;
|
|
267
281
|
}
|
|
268
|
-
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());
|
|
282
|
+
const passed = typeof (rowValue === null || rowValue === void 0 ? void 0 : rowValue.getMonth) === 'function' && ((_a = new Date(value)) === null || _a === void 0 ? void 0 : _a.toDateString()) === (rowValue === null || rowValue === void 0 ? void 0 : rowValue.toDateString());
|
|
269
283
|
return passed;
|
|
270
284
|
};
|
|
271
285
|
|
|
@@ -1235,7 +1249,7 @@ const useFilterStyles = reactComponents.makeStyles({
|
|
|
1235
1249
|
},
|
|
1236
1250
|
});
|
|
1237
1251
|
const Filter = ({ column, table, }) => {
|
|
1238
|
-
var _a, _b;
|
|
1252
|
+
var _a, _b, _c;
|
|
1239
1253
|
const filterFunctionName = column.columnDef.filterFn;
|
|
1240
1254
|
const styles = useFilterStyles();
|
|
1241
1255
|
switch (filterFunctionName) {
|
|
@@ -1247,18 +1261,18 @@ const Filter = ({ column, table, }) => {
|
|
|
1247
1261
|
case 'inNumberRange':
|
|
1248
1262
|
return jsxRuntime.jsx(FilterNumberRange, { column: column, table: table });
|
|
1249
1263
|
case 'inDateRange': {
|
|
1250
|
-
const firstValue = (_a = table
|
|
1264
|
+
const firstValue = (_b = (_a = table
|
|
1251
1265
|
.getPreFilteredRowModel()
|
|
1252
|
-
.flatRows
|
|
1253
|
-
if (typeof firstValue.getMonth === 'function') {
|
|
1266
|
+
.flatRows) === null || _a === void 0 ? void 0 : _a.find(x => Boolean(x.getValue(column.id)))) === null || _b === void 0 ? void 0 : _b.getValue(column.id);
|
|
1267
|
+
if (typeof (firstValue === null || firstValue === void 0 ? void 0 : firstValue.getMonth) === 'function') {
|
|
1254
1268
|
return jsxRuntime.jsx(FilterDateRange, { column: column, table: table });
|
|
1255
1269
|
}
|
|
1256
1270
|
break;
|
|
1257
1271
|
}
|
|
1258
1272
|
case 'matchDate': {
|
|
1259
|
-
const firstValue = (
|
|
1273
|
+
const firstValue = (_c = table
|
|
1260
1274
|
.getPreFilteredRowModel()
|
|
1261
|
-
.flatRows[0]) === null ||
|
|
1275
|
+
.flatRows[0]) === null || _c === void 0 ? void 0 : _c.getValue(column.id);
|
|
1262
1276
|
if (typeof firstValue.getMonth === 'function') {
|
|
1263
1277
|
return jsxRuntime.jsx(FilterDate, { column: column, table: table });
|
|
1264
1278
|
}
|
|
@@ -1296,7 +1310,7 @@ const FilterDrawer = ({ table }) => {
|
|
|
1296
1310
|
}, [table]);
|
|
1297
1311
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
1298
1312
|
const { dispatchDrawerAction, drawerState } = table.options.meta;
|
|
1299
|
-
return (jsxRuntime.jsxs(reactComponents.InlineDrawer, { position: "end", open: drawerState === null || drawerState === void 0 ? void 0 : drawerState.isFilterDrawerOpen, separator: true, children: [jsxRuntime.jsx(reactComponents.DrawerHeader, { children: jsxRuntime.jsx(reactComponents.DrawerHeaderTitle, { action: jsxRuntime.jsx(reactComponents.Button, { appearance: "subtle", "aria-label": "Close", icon: jsxRuntime.jsx(reactIcons.Dismiss24Regular, {}), onClick: () => dispatchDrawerAction === null || dispatchDrawerAction === void 0 ? void 0 : dispatchDrawerAction({ type: "CLOSE_FILTER_DRAWER" }) }), children: "Column Filters" }) }), jsxRuntime.jsx(reactComponents.DrawerBody, { className: styles.drawerBody, children: jsxRuntime.jsx(reactComponents.Accordion, { multiple: true, collapsible: true, children: headerGroups.map((headerGroup) => {
|
|
1313
|
+
return (jsxRuntime.jsxs(reactComponents.InlineDrawer, { position: "end", open: drawerState === null || drawerState === void 0 ? void 0 : drawerState.isFilterDrawerOpen, separator: true, size: 'medium', children: [jsxRuntime.jsx(reactComponents.DrawerHeader, { children: jsxRuntime.jsx(reactComponents.DrawerHeaderTitle, { action: jsxRuntime.jsx(reactComponents.Button, { appearance: "subtle", "aria-label": "Close", icon: jsxRuntime.jsx(reactIcons.Dismiss24Regular, {}), onClick: () => dispatchDrawerAction === null || dispatchDrawerAction === void 0 ? void 0 : dispatchDrawerAction({ type: "CLOSE_FILTER_DRAWER" }) }), children: "Column Filters" }) }), jsxRuntime.jsx(reactComponents.DrawerBody, { className: styles.drawerBody, children: jsxRuntime.jsx(reactComponents.Accordion, { multiple: true, collapsible: true, children: headerGroups.map((headerGroup) => {
|
|
1300
1314
|
const canApplyFilter = headerGroup.depth === (headerGroups === null || headerGroups === void 0 ? void 0 : headerGroups.length) - 1;
|
|
1301
1315
|
if (!canApplyFilter)
|
|
1302
1316
|
return null;
|
package/index.esm.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./src
|
|
1
|
+
export * from "./src/index";
|
package/index.esm.js
CHANGED
|
@@ -87,13 +87,21 @@ const usePaginationStyle = makeStyles({
|
|
|
87
87
|
},
|
|
88
88
|
pageSelectionWrapper: {
|
|
89
89
|
minWidth: "1.5rem",
|
|
90
|
+
display: "flex",
|
|
91
|
+
alignItems: "center",
|
|
92
|
+
gap: "1rem",
|
|
90
93
|
},
|
|
91
94
|
pageSelectionDropdown: {
|
|
92
95
|
minWidth: "100%",
|
|
93
96
|
},
|
|
94
97
|
pageSizeInput: {
|
|
95
98
|
minWidth: "1.5rem",
|
|
96
|
-
width: "
|
|
99
|
+
width: "3rem",
|
|
100
|
+
},
|
|
101
|
+
pageSizeText: {
|
|
102
|
+
flex: 1,
|
|
103
|
+
minWidth: "100%",
|
|
104
|
+
fontSize: "0.8rem"
|
|
97
105
|
},
|
|
98
106
|
});
|
|
99
107
|
|
|
@@ -105,19 +113,25 @@ const DEFAULT_NUMBER_OF_PAGE_BTN = 5;
|
|
|
105
113
|
const Pagination = (props) => {
|
|
106
114
|
const { table } = props;
|
|
107
115
|
const { pageSizeOptions } = table.options.meta || {};
|
|
108
|
-
const pageSizeSelectionId = useId(
|
|
116
|
+
const pageSizeSelectionId = useId('page-size-selector');
|
|
109
117
|
const styles = usePaginationStyle();
|
|
110
118
|
const totalNumberOfPage = table.getPageCount();
|
|
111
119
|
const currentPage = table.getState().pagination.pageIndex;
|
|
112
120
|
const pageSize = table.getState().pagination.pageSize;
|
|
121
|
+
// get total item count and number of item in current page
|
|
122
|
+
const totalItemCount = table.getFilteredRowModel().rows.length;
|
|
123
|
+
const numberOfItemsInCurrentPage = table.getRowModel().rows.length;
|
|
124
|
+
const startNumber = currentPage * pageSize + 1;
|
|
125
|
+
const endNumber = Math.min(startNumber + numberOfItemsInCurrentPage - 1, totalItemCount);
|
|
113
126
|
const pageSelectionOptions = useMemo(() => {
|
|
114
127
|
let start = currentPage - Math.floor(DEFAULT_NUMBER_OF_PAGE_BTN / 2);
|
|
115
128
|
let end = currentPage + Math.floor(DEFAULT_NUMBER_OF_PAGE_BTN / 2);
|
|
116
129
|
if (start < 1) {
|
|
117
130
|
start = 1;
|
|
118
|
-
end =
|
|
119
|
-
|
|
120
|
-
|
|
131
|
+
end =
|
|
132
|
+
totalNumberOfPage > DEFAULT_NUMBER_OF_PAGE_BTN
|
|
133
|
+
? DEFAULT_NUMBER_OF_PAGE_BTN
|
|
134
|
+
: totalNumberOfPage;
|
|
121
135
|
}
|
|
122
136
|
else if (end > totalNumberOfPage) {
|
|
123
137
|
const possibleStart = totalNumberOfPage - DEFAULT_NUMBER_OF_PAGE_BTN + 1;
|
|
@@ -127,12 +141,12 @@ const Pagination = (props) => {
|
|
|
127
141
|
const currentPageOptions = end - start >= 0 ? range(start, end) : [];
|
|
128
142
|
return (currentPageOptions === null || currentPageOptions === void 0 ? void 0 : currentPageOptions.length) ? [...currentPageOptions] : [1];
|
|
129
143
|
}, [totalNumberOfPage, currentPage]);
|
|
130
|
-
return (jsx("div", { className: styles.paginationContainer, children: jsxs("div", { className: styles.wrapper, children: [
|
|
144
|
+
return (jsx("div", { className: styles.paginationContainer, children: jsxs("div", { className: styles.wrapper, children: [jsxs("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', style: { minWidth: 80 }, 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)) }) }) }), jsx(Show, { when: (pageSelectionOptions === null || pageSelectionOptions === void 0 ? void 0 : pageSelectionOptions.length) > 0 && totalItemCount > 0, children: jsxs("span", { className: styles.pageSizeText, children: ["Showing ", startNumber, " through ", endNumber, " of ", totalItemCount, ' ', "items"] }) })] }), 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) => {
|
|
131
145
|
const page = data.value ? Number(e.target.value) - 1 : 0;
|
|
132
146
|
if (page >= 0 && page < table.getPageCount()) {
|
|
133
147
|
table.setPageIndex(page);
|
|
134
148
|
}
|
|
135
|
-
}, className: styles.pageSizeInput, "aria-label": "Page Number", autoComplete:
|
|
149
|
+
}, 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" })] })] }) }));
|
|
136
150
|
};
|
|
137
151
|
|
|
138
152
|
bundleIcon(SaveFilled, SaveRegular);
|
|
@@ -199,7 +213,7 @@ function DebouncedInput({ value: initialValue, onChange, debounce = 500, drawerS
|
|
|
199
213
|
}, debounce);
|
|
200
214
|
return () => clearTimeout(timeout);
|
|
201
215
|
}, [value, onChange, debounce]);
|
|
202
|
-
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, { content: (drawerState === null || drawerState === void 0 ? void 0 : drawerState.isFilterDrawerOpen) ? 'Close Filter Window' : 'Open Advance Filter', relationship: "label", children: jsx(Button, { appearance: "subtle", icon: (drawerState === null || drawerState === void 0 ? void 0 : drawerState.isFilterDrawerOpen) ? jsx(FilterDismissFilled, {}) : jsx(FilterFilled, {}), "aria-label":
|
|
216
|
+
return (jsx(Input, { "aria-label": "Search keyword", placeholder: "Search Keyword", value: value, onChange: (_, data) => setValue(data.value), type: "search", autoComplete: "off", contentBefore: jsx(Search24Regular, {}), style: { width: '300px' }, contentAfter: jsx(Tooltip, { content: (drawerState === null || drawerState === void 0 ? void 0 : drawerState.isFilterDrawerOpen) ? 'Close Filter Window' : 'Open Advance Filter', relationship: "label", children: jsx(Button, { appearance: "subtle", icon: (drawerState === null || drawerState === void 0 ? void 0 : drawerState.isFilterDrawerOpen) ? jsx(FilterDismissFilled, {}) : jsx(FilterFilled, {}), "aria-label": (drawerState === null || drawerState === void 0 ? void 0 : drawerState.isFilterDrawerOpen) ? 'Close filter panel' : 'Open advanced filter', onClick: () => {
|
|
203
217
|
dispatch === null || dispatch === void 0 ? void 0 : dispatch({ type: "TOGGLE_FILTER_DRAWER" });
|
|
204
218
|
} }) }) }));
|
|
205
219
|
}
|
|
@@ -224,15 +238,15 @@ const dateRange = (row, columnId, value) => {
|
|
|
224
238
|
return true;
|
|
225
239
|
}
|
|
226
240
|
else if (value.length === 2 && value[0] && !value[1]) {
|
|
227
|
-
return typeof rowValue.getMonth === 'function' && rowValue >= value[0];
|
|
241
|
+
return typeof (rowValue === null || rowValue === void 0 ? void 0 : rowValue.getMonth) === 'function' && rowValue >= value[0];
|
|
228
242
|
}
|
|
229
243
|
else if (value.length === 2 && !value[0] && value[1]) {
|
|
230
|
-
return typeof rowValue.getMonth === 'function' && rowValue <= value[1];
|
|
244
|
+
return typeof (rowValue === null || rowValue === void 0 ? void 0 : rowValue.getMonth) === 'function' && rowValue <= value[1];
|
|
231
245
|
}
|
|
232
246
|
else if (value.length === 2 && !value[0] && !value[1]) {
|
|
233
247
|
return true;
|
|
234
248
|
}
|
|
235
|
-
const passed = typeof rowValue.getMonth === 'function' && value[0] <= rowValue && rowValue <= value[1];
|
|
249
|
+
const passed = typeof (rowValue === null || rowValue === void 0 ? void 0 : rowValue.getMonth) === 'function' && value[0] <= rowValue && rowValue <= value[1];
|
|
236
250
|
return passed;
|
|
237
251
|
};
|
|
238
252
|
const date = (row, columnId, value) => {
|
|
@@ -246,7 +260,7 @@ const date = (row, columnId, value) => {
|
|
|
246
260
|
if (!value) {
|
|
247
261
|
return true;
|
|
248
262
|
}
|
|
249
|
-
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());
|
|
263
|
+
const passed = typeof (rowValue === null || rowValue === void 0 ? void 0 : rowValue.getMonth) === 'function' && ((_a = new Date(value)) === null || _a === void 0 ? void 0 : _a.toDateString()) === (rowValue === null || rowValue === void 0 ? void 0 : rowValue.toDateString());
|
|
250
264
|
return passed;
|
|
251
265
|
};
|
|
252
266
|
|
|
@@ -1216,7 +1230,7 @@ const useFilterStyles = makeStyles({
|
|
|
1216
1230
|
},
|
|
1217
1231
|
});
|
|
1218
1232
|
const Filter = ({ column, table, }) => {
|
|
1219
|
-
var _a, _b;
|
|
1233
|
+
var _a, _b, _c;
|
|
1220
1234
|
const filterFunctionName = column.columnDef.filterFn;
|
|
1221
1235
|
const styles = useFilterStyles();
|
|
1222
1236
|
switch (filterFunctionName) {
|
|
@@ -1228,18 +1242,18 @@ const Filter = ({ column, table, }) => {
|
|
|
1228
1242
|
case 'inNumberRange':
|
|
1229
1243
|
return jsx(FilterNumberRange, { column: column, table: table });
|
|
1230
1244
|
case 'inDateRange': {
|
|
1231
|
-
const firstValue = (_a = table
|
|
1245
|
+
const firstValue = (_b = (_a = table
|
|
1232
1246
|
.getPreFilteredRowModel()
|
|
1233
|
-
.flatRows
|
|
1234
|
-
if (typeof firstValue.getMonth === 'function') {
|
|
1247
|
+
.flatRows) === null || _a === void 0 ? void 0 : _a.find(x => Boolean(x.getValue(column.id)))) === null || _b === void 0 ? void 0 : _b.getValue(column.id);
|
|
1248
|
+
if (typeof (firstValue === null || firstValue === void 0 ? void 0 : firstValue.getMonth) === 'function') {
|
|
1235
1249
|
return jsx(FilterDateRange, { column: column, table: table });
|
|
1236
1250
|
}
|
|
1237
1251
|
break;
|
|
1238
1252
|
}
|
|
1239
1253
|
case 'matchDate': {
|
|
1240
|
-
const firstValue = (
|
|
1254
|
+
const firstValue = (_c = table
|
|
1241
1255
|
.getPreFilteredRowModel()
|
|
1242
|
-
.flatRows[0]) === null ||
|
|
1256
|
+
.flatRows[0]) === null || _c === void 0 ? void 0 : _c.getValue(column.id);
|
|
1243
1257
|
if (typeof firstValue.getMonth === 'function') {
|
|
1244
1258
|
return jsx(FilterDate, { column: column, table: table });
|
|
1245
1259
|
}
|
|
@@ -1277,7 +1291,7 @@ const FilterDrawer = ({ table }) => {
|
|
|
1277
1291
|
}, [table]);
|
|
1278
1292
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
1279
1293
|
const { dispatchDrawerAction, drawerState } = table.options.meta;
|
|
1280
|
-
return (jsxs(InlineDrawer, { position: "end", open: drawerState === null || drawerState === void 0 ? void 0 : drawerState.isFilterDrawerOpen, separator: true, children: [jsx(DrawerHeader, { children: jsx(DrawerHeaderTitle, { action: jsx(Button, { appearance: "subtle", "aria-label": "Close", icon: jsx(Dismiss24Regular, {}), onClick: () => dispatchDrawerAction === null || dispatchDrawerAction === void 0 ? void 0 : dispatchDrawerAction({ type: "CLOSE_FILTER_DRAWER" }) }), children: "Column Filters" }) }), jsx(DrawerBody, { className: styles.drawerBody, children: jsx(Accordion, { multiple: true, collapsible: true, children: headerGroups.map((headerGroup) => {
|
|
1294
|
+
return (jsxs(InlineDrawer, { position: "end", open: drawerState === null || drawerState === void 0 ? void 0 : drawerState.isFilterDrawerOpen, separator: true, size: 'medium', children: [jsx(DrawerHeader, { children: jsx(DrawerHeaderTitle, { action: jsx(Button, { appearance: "subtle", "aria-label": "Close", icon: jsx(Dismiss24Regular, {}), onClick: () => dispatchDrawerAction === null || dispatchDrawerAction === void 0 ? void 0 : dispatchDrawerAction({ type: "CLOSE_FILTER_DRAWER" }) }), children: "Column Filters" }) }), jsx(DrawerBody, { className: styles.drawerBody, children: jsx(Accordion, { multiple: true, collapsible: true, children: headerGroups.map((headerGroup) => {
|
|
1281
1295
|
const canApplyFilter = headerGroup.depth === (headerGroups === null || headerGroups === void 0 ? void 0 : headerGroups.length) - 1;
|
|
1282
1296
|
if (!canApplyFilter)
|
|
1283
1297
|
return null;
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prt-ts/fluent-react-table-v2",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.66.2-build-3.0",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"react": ">=17.0.0",
|
|
6
6
|
"react-dom": ">=17.0.0",
|
|
7
|
-
"@fluentui/react-components": ">=9.
|
|
7
|
+
"@fluentui/react-components": ">=9.66.2",
|
|
8
8
|
"@fluentui/react-icons": ">=2.0.260",
|
|
9
9
|
"@fluentui/react-datepicker-compat": ">=0.4.32"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@tanstack/react-table": ">=8.
|
|
12
|
+
"@tanstack/react-table": ">=8.21.3",
|
|
13
13
|
"@dnd-kit/core": "6.1.0",
|
|
14
14
|
"@dnd-kit/modifiers": "7.0.0",
|
|
15
15
|
"@dnd-kit/sortable": "8.0.0",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const usePaginationStyle: () => Record<"paginationContainer" | "wrapper" | "pageBtnContainer" | "pageBtn" | "pageSelectionWrapper" | "pageSelectionDropdown" | "pageSizeInput", string>;
|
|
1
|
+
export declare const usePaginationStyle: () => Record<"paginationContainer" | "wrapper" | "pageBtnContainer" | "pageBtn" | "pageSelectionWrapper" | "pageSelectionDropdown" | "pageSizeInput" | "pageSizeText", string>;
|