@prt-ts/fluent-react-table-v2 9.47.1-build-2.0 → 9.47.1-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/index.cjs.js +22 -5
- package/index.esm.d.ts +1 -0
- package/index.esm.js +22 -6
- package/package.json +1 -1
- package/src/lib/components/GridContainer.d.ts +3 -3
- package/src/lib/components/filters/Filter.d.ts +1 -1
- package/src/lib/helpers/Helpers.d.ts +1 -1
- package/src/lib/helpers/TableExportDataHelper.d.ts +3 -0
- package/src/lib/index.d.ts +1 -0
- package/src/lib/types/TableProps.d.ts +10 -3
package/index.cjs.js
CHANGED
|
@@ -1503,8 +1503,7 @@ const useGridContainer = (props, ref) => {
|
|
|
1503
1503
|
[table]);
|
|
1504
1504
|
const headerMenu = React__namespace.useMemo(() => {
|
|
1505
1505
|
if (props.headerMenu) {
|
|
1506
|
-
|
|
1507
|
-
return props.headerMenu(selectedRows);
|
|
1506
|
+
return props.headerMenu(table);
|
|
1508
1507
|
}
|
|
1509
1508
|
return null;
|
|
1510
1509
|
},
|
|
@@ -1718,9 +1717,9 @@ function HeaderRow(props) {
|
|
|
1718
1717
|
|
|
1719
1718
|
function TableHeader(props) {
|
|
1720
1719
|
const styles = useTableHeaderStyles();
|
|
1721
|
-
const { table, headerGroups
|
|
1720
|
+
const { table, headerGroups } = props;
|
|
1722
1721
|
const focusAttribute = reactComponents.useFocusableGroup({ tabBehavior: "limited-trap-focus" });
|
|
1723
|
-
return (jsxRuntime.jsx("thead", Object.assign({ className: styles.tHead, style: { zIndex: 99 } }, focusAttribute, { tabIndex: 0, children: headerGroups === null || headerGroups === void 0 ? void 0 : headerGroups.map((headerGroup) => (jsxRuntime.jsx(HeaderRow, { table: table,
|
|
1722
|
+
return (jsxRuntime.jsx("thead", Object.assign({ className: styles.tHead, style: { zIndex: 99 } }, focusAttribute, { tabIndex: 0, children: headerGroups === null || headerGroups === void 0 ? void 0 : headerGroups.map((headerGroup) => (jsxRuntime.jsx(HeaderRow, { table: table, headerGroup: headerGroup, headerGroupsLength: headerGroups.length }, headerGroup.id))) })));
|
|
1724
1723
|
}
|
|
1725
1724
|
|
|
1726
1725
|
const useLoadingStyles = reactComponents.makeStyles({
|
|
@@ -2404,7 +2403,7 @@ function AdvancedTable(props, ref) {
|
|
|
2404
2403
|
const touchSensor = core.useSensor(core.TouchSensor);
|
|
2405
2404
|
const keyboardSensor = core.useSensor(core.KeyboardSensor);
|
|
2406
2405
|
const sensors = core.useSensors(mouseSensor, touchSensor, keyboardSensor, pointerSensor);
|
|
2407
|
-
return (jsxRuntime.jsx(core.DndContext, { collisionDetection: core.closestCenter, modifiers: [modifiers.restrictToHorizontalAxis], onDragEnd: handleDragEnd, sensors: sensors, children: jsxRuntime.jsxs(sortable.SortableContext, { items: columnOrder, strategy: sortable.horizontalListSortingStrategy, children: [jsxRuntime.jsx(reactControlFlow.Show, { when: !props.disableTableHeader, children: jsxRuntime.jsx(GridHeader, { table: table, gridTitle: props.gridTitle, headerMenu: headerMenu, globalFilter: globalFilter, setGlobalFilter: setGlobalFilter, applyTableState: applyTableState }) }), jsxRuntime.jsxs("div", { style: { display: 'flex' }, children: [jsxRuntime.jsx(TableContainer, { table: table, data: props.data, isLoading: props.isLoading || false, noFilterMatchPage: props.noFilterMatchPage, noItemPage: props.noItemPage }), jsxRuntime.jsx(FilterDrawer, { table: table }), jsxRuntime.jsx(ViewsDrawer, { table: table, tableViews: tableViews, applyTableState: applyTableState, resetToGridDefaultView: resetToDefaultView })] }), jsxRuntime.jsx(Pagination, { table: table })] }) }));
|
|
2406
|
+
return (jsxRuntime.jsx(core.DndContext, { collisionDetection: core.closestCenter, modifiers: [modifiers.restrictToHorizontalAxis], onDragEnd: handleDragEnd, sensors: sensors, children: jsxRuntime.jsxs(sortable.SortableContext, { items: columnOrder, strategy: sortable.horizontalListSortingStrategy, children: [jsxRuntime.jsx(reactControlFlow.Show, { when: !props.disableTableHeader, children: jsxRuntime.jsx(GridHeader, { table: table, gridTitle: props.gridTitle, headerMenu: headerMenu, globalFilter: globalFilter, setGlobalFilter: setGlobalFilter, applyTableState: applyTableState }) }), jsxRuntime.jsxs("div", { style: { display: 'flex' }, children: [jsxRuntime.jsx(TableContainer, { table: table, data: props.data, isLoading: props.isLoading || false, noFilterMatchPage: props.noFilterMatchPage, noItemPage: props.noItemPage }), jsxRuntime.jsx(FilterDrawer, { table: table }), jsxRuntime.jsx(ViewsDrawer, { table: table, tableViews: tableViews, applyTableState: applyTableState, resetToGridDefaultView: resetToDefaultView })] }), jsxRuntime.jsx(reactControlFlow.Show, { when: !props.disablePagination, fallback: jsxRuntime.jsx(reactComponents.Divider, {}), children: jsxRuntime.jsx(Pagination, { table: table }) })] }) }));
|
|
2408
2407
|
}
|
|
2409
2408
|
const ForwardedAdvancedTable = React__namespace.forwardRef(AdvancedTable);
|
|
2410
2409
|
|
|
@@ -2422,6 +2421,23 @@ function useSkipper() {
|
|
|
2422
2421
|
return [shouldSkip, skip];
|
|
2423
2422
|
}
|
|
2424
2423
|
|
|
2424
|
+
const getTableData = (table) => {
|
|
2425
|
+
// format headers
|
|
2426
|
+
const { rows } = table.getCoreRowModel();
|
|
2427
|
+
// format rows key as a header and value as a row data
|
|
2428
|
+
const data = rows.map((row) => {
|
|
2429
|
+
const rowData = {};
|
|
2430
|
+
const cells = row.getVisibleCells();
|
|
2431
|
+
cells.forEach((cell) => {
|
|
2432
|
+
const columnId = cell.column.id;
|
|
2433
|
+
const value = cell.getValue();
|
|
2434
|
+
rowData[columnId] = value;
|
|
2435
|
+
});
|
|
2436
|
+
return rowData;
|
|
2437
|
+
});
|
|
2438
|
+
return data;
|
|
2439
|
+
};
|
|
2440
|
+
|
|
2425
2441
|
Object.defineProperty(exports, 'createColumnHelper', {
|
|
2426
2442
|
enumerable: true,
|
|
2427
2443
|
get: function () { return reactTable.createColumnHelper; }
|
|
@@ -2431,4 +2447,5 @@ exports.SelectRowCheckbox = SelectRowCheckbox;
|
|
|
2431
2447
|
exports.SelectRowRadio = SelectRowRadio;
|
|
2432
2448
|
exports.Table = ForwardedAdvancedTable;
|
|
2433
2449
|
exports.disableAllShorthand = disableAllShorthand;
|
|
2450
|
+
exports.getTableData = getTableData;
|
|
2434
2451
|
exports.useSkipper = useSkipper;
|
package/index.esm.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src\\index";
|
package/index.esm.js
CHANGED
|
@@ -1481,8 +1481,7 @@ const useGridContainer = (props, ref) => {
|
|
|
1481
1481
|
[table]);
|
|
1482
1482
|
const headerMenu = React.useMemo(() => {
|
|
1483
1483
|
if (props.headerMenu) {
|
|
1484
|
-
|
|
1485
|
-
return props.headerMenu(selectedRows);
|
|
1484
|
+
return props.headerMenu(table);
|
|
1486
1485
|
}
|
|
1487
1486
|
return null;
|
|
1488
1487
|
},
|
|
@@ -1696,9 +1695,9 @@ function HeaderRow(props) {
|
|
|
1696
1695
|
|
|
1697
1696
|
function TableHeader(props) {
|
|
1698
1697
|
const styles = useTableHeaderStyles();
|
|
1699
|
-
const { table, headerGroups
|
|
1698
|
+
const { table, headerGroups } = props;
|
|
1700
1699
|
const focusAttribute = useFocusableGroup({ tabBehavior: "limited-trap-focus" });
|
|
1701
|
-
return (jsx("thead", Object.assign({ className: styles.tHead, style: { zIndex: 99 } }, focusAttribute, { tabIndex: 0, children: headerGroups === null || headerGroups === void 0 ? void 0 : headerGroups.map((headerGroup) => (jsx(HeaderRow, { table: table,
|
|
1700
|
+
return (jsx("thead", Object.assign({ className: styles.tHead, style: { zIndex: 99 } }, focusAttribute, { tabIndex: 0, children: headerGroups === null || headerGroups === void 0 ? void 0 : headerGroups.map((headerGroup) => (jsx(HeaderRow, { table: table, headerGroup: headerGroup, headerGroupsLength: headerGroups.length }, headerGroup.id))) })));
|
|
1702
1701
|
}
|
|
1703
1702
|
|
|
1704
1703
|
const useLoadingStyles = makeStyles({
|
|
@@ -2382,7 +2381,7 @@ function AdvancedTable(props, ref) {
|
|
|
2382
2381
|
const touchSensor = useSensor(TouchSensor);
|
|
2383
2382
|
const keyboardSensor = useSensor(KeyboardSensor);
|
|
2384
2383
|
const sensors = useSensors(mouseSensor, touchSensor, keyboardSensor, pointerSensor);
|
|
2385
|
-
return (jsx(DndContext, { collisionDetection: closestCenter, modifiers: [restrictToHorizontalAxis], onDragEnd: handleDragEnd, sensors: sensors, children: jsxs(SortableContext, { items: columnOrder, strategy: horizontalListSortingStrategy, children: [jsx(Show, { when: !props.disableTableHeader, children: jsx(GridHeader, { table: table, gridTitle: props.gridTitle, headerMenu: headerMenu, globalFilter: globalFilter, setGlobalFilter: setGlobalFilter, applyTableState: applyTableState }) }), jsxs("div", { style: { display: 'flex' }, children: [jsx(TableContainer, { table: table, data: props.data, isLoading: props.isLoading || false, noFilterMatchPage: props.noFilterMatchPage, noItemPage: props.noItemPage }), jsx(FilterDrawer, { table: table }), jsx(ViewsDrawer, { table: table, tableViews: tableViews, applyTableState: applyTableState, resetToGridDefaultView: resetToDefaultView })] }), jsx(Pagination, { table: table })] }) }));
|
|
2384
|
+
return (jsx(DndContext, { collisionDetection: closestCenter, modifiers: [restrictToHorizontalAxis], onDragEnd: handleDragEnd, sensors: sensors, children: jsxs(SortableContext, { items: columnOrder, strategy: horizontalListSortingStrategy, children: [jsx(Show, { when: !props.disableTableHeader, children: jsx(GridHeader, { table: table, gridTitle: props.gridTitle, headerMenu: headerMenu, globalFilter: globalFilter, setGlobalFilter: setGlobalFilter, applyTableState: applyTableState }) }), jsxs("div", { style: { display: 'flex' }, children: [jsx(TableContainer, { table: table, data: props.data, isLoading: props.isLoading || false, noFilterMatchPage: props.noFilterMatchPage, noItemPage: props.noItemPage }), jsx(FilterDrawer, { table: table }), jsx(ViewsDrawer, { table: table, tableViews: tableViews, applyTableState: applyTableState, resetToGridDefaultView: resetToDefaultView })] }), jsx(Show, { when: !props.disablePagination, fallback: jsx(Divider, {}), children: jsx(Pagination, { table: table }) })] }) }));
|
|
2386
2385
|
}
|
|
2387
2386
|
const ForwardedAdvancedTable = React.forwardRef(AdvancedTable);
|
|
2388
2387
|
|
|
@@ -2400,4 +2399,21 @@ function useSkipper() {
|
|
|
2400
2399
|
return [shouldSkip, skip];
|
|
2401
2400
|
}
|
|
2402
2401
|
|
|
2403
|
-
|
|
2402
|
+
const getTableData = (table) => {
|
|
2403
|
+
// format headers
|
|
2404
|
+
const { rows } = table.getCoreRowModel();
|
|
2405
|
+
// format rows key as a header and value as a row data
|
|
2406
|
+
const data = rows.map((row) => {
|
|
2407
|
+
const rowData = {};
|
|
2408
|
+
const cells = row.getVisibleCells();
|
|
2409
|
+
cells.forEach((cell) => {
|
|
2410
|
+
const columnId = cell.column.id;
|
|
2411
|
+
const value = cell.getValue();
|
|
2412
|
+
rowData[columnId] = value;
|
|
2413
|
+
});
|
|
2414
|
+
return rowData;
|
|
2415
|
+
});
|
|
2416
|
+
return data;
|
|
2417
|
+
};
|
|
2418
|
+
|
|
2419
|
+
export { PinRowAction, SelectRowCheckbox, SelectRowRadio, ForwardedAdvancedTable as Table, disableAllShorthand, getTableData, useSkipper };
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@ import { TableProps, TableRef } from "../types";
|
|
|
3
3
|
import { RowData } from "@tanstack/react-table";
|
|
4
4
|
export declare function AdvancedTable<TItem extends RowData>(props: TableProps<TItem>, ref: React.ForwardedRef<TableRef<TItem>>): import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
export declare const ForwardedAdvancedTable: <TItem extends unknown>(props: TableProps<TItem> & {
|
|
6
|
-
ref?: React.ForwardedRef<TableRef<TItem
|
|
6
|
+
ref?: React.ForwardedRef<TableRef<TItem>>;
|
|
7
7
|
}) => React.ReactElement<TableProps<TItem> & {
|
|
8
|
-
ref?: React.ForwardedRef<TableRef<TItem
|
|
9
|
-
}
|
|
8
|
+
ref?: React.ForwardedRef<TableRef<TItem>>;
|
|
9
|
+
}>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Column, RowData, Table } from '@tanstack/react-table';
|
|
2
2
|
export declare const Filter: <TItem extends unknown>({ column, table, }: {
|
|
3
|
-
column: Column<TItem,
|
|
3
|
+
column: Column<TItem, RowData>;
|
|
4
4
|
table: Table<TItem>;
|
|
5
5
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Column } from "@tanstack/react-table";
|
|
2
|
-
export declare const getLeafColumns: <TItem extends unknown>(columns: Column<TItem
|
|
2
|
+
export declare const getLeafColumns: <TItem extends unknown>(columns: Column<TItem>[]) => Column<TItem>[];
|
package/src/lib/index.d.ts
CHANGED
|
@@ -46,3 +46,4 @@ declare module '@tanstack/react-table' {
|
|
|
46
46
|
export type { TableProps, TableRef, TableView } from "./types";
|
|
47
47
|
export type { TableState, ColumnDef, Column as ColumnType, Row as RowType, RowData as RowDataType, Table as TableType } from '@tanstack/react-table';
|
|
48
48
|
export { createColumnHelper } from "@tanstack/react-table";
|
|
49
|
+
export { getTableData } from "./helpers/TableExportDataHelper";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { ColumnDef, ColumnFiltersState, ColumnOrderState, ColumnPinningState, ExpandedState, GroupingState, RowData, RowPinningState, RowSelectionState, SortingState, VisibilityState } from "@tanstack/react-table";
|
|
2
|
+
import { ColumnDef, ColumnFiltersState, ColumnOrderState, ColumnPinningState, ExpandedState, GroupingState, RowData, RowPinningState, RowSelectionState, SortingState, Table, VisibilityState } from "@tanstack/react-table";
|
|
3
3
|
import { TableView } from "./TableView";
|
|
4
4
|
export type TableProps<TItem extends RowData> = {
|
|
5
5
|
/**
|
|
@@ -28,7 +28,7 @@ export type TableProps<TItem extends RowData> = {
|
|
|
28
28
|
/**
|
|
29
29
|
* Table header menu
|
|
30
30
|
*/
|
|
31
|
-
headerMenu?: (
|
|
31
|
+
headerMenu?: (table: Table<TItem>) => JSX.Element | React.ReactNode;
|
|
32
32
|
/**
|
|
33
33
|
* Table default page size.
|
|
34
34
|
*/
|
|
@@ -110,9 +110,16 @@ export type TableProps<TItem extends RowData> = {
|
|
|
110
110
|
*/
|
|
111
111
|
onTableViewDelete?: (tableView: TableView) => void;
|
|
112
112
|
/**
|
|
113
|
-
*
|
|
113
|
+
* remove table header
|
|
114
114
|
*/
|
|
115
115
|
disableTableHeader?: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* remove pagination bar
|
|
118
|
+
*/
|
|
119
|
+
disablePagination?: boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Additional settings for the table
|
|
122
|
+
*/
|
|
116
123
|
tableSettings?: TableSettings;
|
|
117
124
|
};
|
|
118
125
|
export type TableSettings = {
|